Files
wagic/projects/mtg/include/Rules.h
Xawotihs 9adb9d625d - 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.
2011-10-01 13:30:30 +00:00

88 lines
1.9 KiB
C++

#ifndef _RULES_H_
#define _RULES_H_
#include <string>
#include <vector>
using namespace std;
class ManaCost;
class Player;
class MTGPlayerCards;
class MTGDeck;
class MTGCardInstance;
class GameObserver;
#define MAX_RULES_CARDS 4096;
class RulesPlayerData
{
public:
vector<string> extraRules;
Player* player;
RulesPlayerData();
~RulesPlayerData();
void cleanup();
};
class RulesState
{
public:
int phase;
int player;
void parsePlayerState(int playerId, string s);
RulesState();
RulesPlayerData playerData[2];
void cleanup();
};
class Rules
{
protected:
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;
public:
enum
{
PARSE_UNDEFINED,
PARSE_INIT,
PARSE_PLAYER1,
PARSE_PLAYER2,
PARSE_PLAYERS
};
string bg;
string filename;
int gamemode;
bool hidden;
string displayName;
int unlockOption;
static vector<Rules *> RulesList;
Rules(string bg = "");
int load(string _filename);
static int loadAllRules();
static void unloadAllRules();
static Rules * getRulesByFilename(string _filename);
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(GameObserver *observer);
void initGame(GameObserver* observer);
//second part of the initialization, needs to happen after the first update call
void postUpdateInit(GameObserver* observer);
void cleanup();
vector<string> extraRules;
RulesState initState;
static int getMTGId(string name);
static MTGCardInstance * getCardByMTGId(GameObserver* observer, int mtgid);
};
#endif