I'm trying to automate some player actions to quickly modify and return to a set game state (yes, I know about the saved state slots - not quite what I need). I think this will allow for rapid iteration on minor game state manipulations. In addition to learning a bit about the state machine, I've run into a few head scratchers.
The first one is something people already know but I can't find documented anywhere. The game breaks if in multipleactiveplayer state and the "automated" code calls a function that uses self::getCurrentPlayerId();. When that function is called by way of an ajax request / player action (non-automated), the self::getCurrentPlayerId() works correctly. I wonder if there's a way to set the active player in multipleactiveplayer so that a subsequent call to self::getCurrentPlayerId() returns the desired player? That is to say, how does the game framework handle current player for ajax / player actions in multi-active?
The second one is really a ... don't know. Lost a couple hours to this one. I'm comparing a int pulled from the db to an int stored as a gameStateValue. The int from the db gets pulled as a string (self::getObjectListFromDB). The gameStateValue is initially set as an int (from material.inc.php) but in "normal" mode, when the game is played through the UI, it's gotten as a string. However, when that same function is called in my "automated" mode, that gameStateValue is pulled as an int. The comparison is using !== so it fails, always. I'm not sure why it's using !==. Perhaps I should just switch it to != and allow php to handle types. Either way, a couple questions:
* Are all values pulled from the db pulled as strings?
* Why would the gameStateValue be a string in one case but int in the other?
Help or speculation much appreciated!
The first one is something people already know but I can't find documented anywhere. The game breaks if in multipleactiveplayer state and the "automated" code calls a function that uses self::getCurrentPlayerId();. When that function is called by way of an ajax request / player action (non-automated), the self::getCurrentPlayerId() works correctly. I wonder if there's a way to set the active player in multipleactiveplayer so that a subsequent call to self::getCurrentPlayerId() returns the desired player? That is to say, how does the game framework handle current player for ajax / player actions in multi-active?
The second one is really a ... don't know. Lost a couple hours to this one. I'm comparing a int pulled from the db to an int stored as a gameStateValue. The int from the db gets pulled as a string (self::getObjectListFromDB). The gameStateValue is initially set as an int (from material.inc.php) but in "normal" mode, when the game is played through the UI, it's gotten as a string. However, when that same function is called in my "automated" mode, that gameStateValue is pulled as an int. The comparison is using !== so it fails, always. I'm not sure why it's using !==. Perhaps I should just switch it to != and allow php to handle types. Either way, a couple questions:
* Are all values pulled from the db pulled as strings?
* Why would the gameStateValue be a string in one case but int in the other?
Help or speculation much appreciated!