Page 1 of 1

Multiple simulataneous games

PostPosted: 28 Jan 2015, 15:37
by elcnesh
I've been trying to get simultaneous games to work, which basically means changing a lot of static fields/methods and singleton classes to normal objects. However, I've come across something which I don't know how to solve... When a PlayerControllerHuman is asked to make a decision, it directs that decision to SGuiChoose, which will always direct it to the static GuiDesktop (or GuiMobile). But that GuiDesktop then has no idea in which game something is asked, so it can't place the dialog in the proper game window. Somehow the PlayerControllerHuman needs to know a little bit more specific to which Gui it's connected.

Which brings me to the following: this is actually what I implemented in first instance with the Gui code overhaul, but was quickly (and rightly so) removed again by Dan. The problem was that I had made a variable out of the entire IGuiBase, which is definitely not right, as that encompasses much more than a single game. However, I do believe we need some kind of variable to which a PlayerControllerHuman can direct its questions; like an IGameGui, which then gets picked up by the right screen so that multiple games don't interfere. I think we'll otherwise never get to simultaneous games (or network games, for that matter).

Any thoughts on this? Maybe any alternatives that would be less work to implement? I'm not very experienced with this kind of stuff, but right now I'm hitting a wall in coding this, so somewhere something probably has to change...

Re: Multiple simulataneous games

PostPosted: 01 Feb 2015, 01:00
by Myrd
Another possibility is for all the GUI functions to take a game param. Then, in GUI code there can be a map from the game to the tab.

I agree that having an object that keeps that state is cleaner though.

Re: Multiple simulataneous games

PostPosted: 05 Feb 2015, 12:30
by elcnesh
Ok, I've actually managed to get it working! Have played the first games simultaneously on my machine!!! :D

Some bugs are to be fixed which have to do with quests, but otherwise I think it's ready. I'll post a patch here later today, maybe some of you can test it. It's gonna be quite a huge commit, but I'm fairly confident that the changes I've made are a necessary step in the direction of looser View-Game coupling, which is also a requirement for Network games.

Re: Multiple simulataneous games

PostPosted: 05 Feb 2015, 14:40
by KrazyTheFox
elcnesh wrote:Ok, I've actually managed to get it working! Have played the first games simultaneously on my machine!!! :D

Some bugs are to be fixed which have to do with quests, but otherwise I think it's ready. I'll post a patch here later today, maybe some of you can test it. It's gonna be quite a huge commit, but I'm fairly confident that the changes I've made are a necessary step in the direction of looser View-Game coupling, which is also a requirement for Network games.
This will help out greatly with quest drafts as well! I'll have to look into that this weekend.

Re: Multiple simulataneous games

PostPosted: 10 Feb 2015, 15:06
by elcnesh
So the weekend passed by really quickly and Eclipse was failing miserably, but in the end I managed to extract a working patch:

Forge-Patch-GUI-r28820.txt
(738.25 KiB) Downloaded 782 times


As I said, it's a HUGE change, so if a couple of devs are willing to give it a whirl that'd be great :) Some known issues:
  • Targeting arrows not working (I know, big, but at least doesn't affect gameplay much)
  • Human vs human on Android doesn't always correctly lock the UI of the player without priority;
  • Human vs human on Android doesn't always correctly unlock the UI as the turn ends after auto-yielding;
  • Human vs human on Desktop has two win screens that could now actually have a function, but right now they don't do very much;
  • This patch also includes some preliminary work I've been doing on creating a card script syntax parser integrated into the workshop. Please ignore the red stuff that pops up in the workshop right now, I'll add an option to disable it before committing anything (or get it to work at least partially).

EDIT: Updated file, fixing some bugs related mainly to quests, win/lose screen display, and viewing cards.