- Adding external rules mechanism. It is very crude for the moment, but I hope it will grow. Have a look at Rules/mtg.txt for basic usage
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-12-06 04:47:29 +00:00
parent c5e106ba27
commit 0d2c6cf3e5
26 changed files with 638 additions and 195 deletions

View File

@@ -0,0 +1,74 @@
#ifndef _RULES_H_
#define _RULES_H_
#include <string>
#include <vector>
using namespace std;
class ManaCost;
class Player;
class MTGPlayerCards;
class MTGDeck;
class MTGCardInstance;
#define MAX_RULES_CARDS 4096;
class RulesPlayerZone{
public:
vector<int> cards;
void add(int cardid);
RulesPlayerZone();
void cleanup();
};
class RulesPlayerData{
public:
vector <string> extraRules;
int life;
ManaCost * manapool;
RulesPlayerZone zones[5];
RulesPlayerData();
~RulesPlayerData();
void cleanup();
};
class RulesState{
public:
int phase;
void parsePlayerState(int playerId, string s);
RulesState();
RulesPlayerData playerData[2];
void cleanup();
};
class Rules{
protected:
Player * loadPlayerMomir(int isAI);
Player * loadPlayerRandom(int isAI, int mode);
Player * initPlayer(int playerId);
MTGDeck * buildDeck( int playerId);
int strToGameMode(string s);
public:
enum {
PARSE_UNDEFINED,
PARSE_INIT,
PARSE_PLAYER1,
PARSE_PLAYER2,
PARSE_PLAYERS
};
Rules(string filename);
int load(string filename);
int gamemode;
void initPlayers();
void addExtraRules();
void initGame();
void cleanup();
vector <string> extraRules;
RulesState initState;
static int getMTGId(string name);
static MTGCardInstance * getCardByMTGId(int mtgid);
};
#endif