- reworked the testsuite and the rules (storyflow) to use the same game deserialization code, moved that code to the players and zone classes

- removed every references to the gameobserver singleton. This object can now be instantiated several times as it's needed for minmax. To be able to do that, I mostly added a reference to a gameobserver from any targetable object (cards, players, spells) and abilities.
This commit is contained in:
Xawotihs
2011-10-01 13:30:30 +00:00
parent d6db0c4f63
commit 9adb9d625d
86 changed files with 1902 additions and 1961 deletions
+10 -26
View File
@@ -10,31 +10,15 @@ class Player;
class MTGPlayerCards;
class MTGDeck;
class MTGCardInstance;
class GameObserver;
#define MAX_RULES_CARDS 4096;
class RulesPlayerZone
{
public:
vector<int> cards;
void add(int cardid);
RulesPlayerZone();
void cleanup();
};
class RulesPlayerData
{
public:
vector<string> extraRules;
string phaseRing;
int offerInterruptOnPhase;
int life;
int poisonCount;
int damageCount;
int preventable;
string avatar;
ManaCost * manapool;
RulesPlayerZone zones[5];
Player* player;
RulesPlayerData();
~RulesPlayerData();
void cleanup();
@@ -55,9 +39,9 @@ public:
class Rules
{
protected:
Player * loadPlayerMomir(int isAI);
Player * loadPlayerRandom(int isAI, int mode);
Player * initPlayer(int playerId);
Player * loadPlayerMomir(GameObserver* observer, int isAI);
Player * loadPlayerRandom(GameObserver* observer, int isAI, int mode);
Player * initPlayer(GameObserver *observer, int playerId);
MTGDeck * buildDeck(int playerId);
int strToGameMode(string s);
bool postUpdateInitDone;
@@ -84,17 +68,17 @@ public:
static int loadAllRules();
static void unloadAllRules();
static Rules * getRulesByFilename(string _filename);
void initPlayers();
void initPlayers(GameObserver *observer);
bool canChooseDeck(); //True if the players get to select their decks, false if the decks are automatically generated by the mode
void addExtraRules();
void initGame();
void addExtraRules(GameObserver *observer);
void initGame(GameObserver* observer);
//second part of the initialization, needs to happen after the first update call
void postUpdateInit();
void postUpdateInit(GameObserver* observer);
void cleanup();
vector<string> extraRules;
RulesState initState;
static int getMTGId(string name);
static MTGCardInstance * getCardByMTGId(int mtgid);
static MTGCardInstance * getCardByMTGId(GameObserver* observer, int mtgid);
};