- 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
+2 -2
View File
@@ -6,12 +6,12 @@
class AIMomirPlayer: public AIPlayerBaka
{
public:
AIMomirPlayer(string file, string fileSmall, string avatarFile, MTGDeck * deck = NULL);
AIMomirPlayer(GameObserver *observer, string file, string fileSmall, string avatarFile, MTGDeck * deck = NULL);
int getEfficiency(OrderedAIAction * action);
int momir();
int computeActions();
static MTGAbility * momirAbility;
static MTGAbility * getMomirAbility();
MTGAbility * getMomirAbility();
};
#endif
+3 -3
View File
@@ -88,7 +88,7 @@ public:
virtual int receiveEvent(WEvent * event);
virtual void Render();
AIPlayer(string deckFile, string deckFileSmall, MTGDeck * deck = NULL);
AIPlayer(GameObserver *observer, string deckFile, string deckFileSmall, MTGDeck * deck = NULL);
virtual ~AIPlayer();
virtual int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget = NULL, MTGCardInstance * Chosencard = NULL, bool checkonly = false) = 0;
@@ -105,9 +105,9 @@ public:
class AIPlayerFactory{
public:
AIPlayer * createAIPlayer(MTGAllCards * collection, Player * opponent, int deckid = 0);
AIPlayer * createAIPlayer(GameObserver *observer, MTGAllCards * collection, Player * opponent, int deckid = 0);
#ifdef AI_CHANGE_TESTING
AIPlayer * createAIPlayerTest(MTGAllCards * collection, Player * opponent, string folder);
AIPlayer * createAIPlayerTest(GameObserver *observer, MTGAllCards * collection, Player * opponent, string folder);
#endif
};
+2 -2
View File
@@ -114,7 +114,7 @@ class AIPlayerBaka: public AIPlayer{
vector<MTGAbility*>gotPayments;
int deckId;
AIPlayerBaka(string deckFile, string deckfileSmall, string avatarFile, MTGDeck * deck = NULL);
AIPlayerBaka(GameObserver *observer, string deckFile, string deckfileSmall, string avatarFile, MTGDeck * deck = NULL);
virtual int Act(float dt);
void initTimer();
virtual int computeActions();
@@ -129,4 +129,4 @@ class AIPlayerBaka: public AIPlayer{
virtual int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingContainer& ranking);
};
#endif
#endif
+2 -2
View File
@@ -49,7 +49,7 @@ protected:
public:
AIPlayerBakaB(string deckFile, string deckfileSmall, string avatarFile, MTGDeck * deck = NULL);
AIPlayerBakaB(GameObserver *observer, string deckFile, string deckfileSmall, string avatarFile, MTGDeck * deck = NULL);
virtual int Act(float dt);
void initTimer();
virtual int computeActions();
@@ -66,4 +66,4 @@ protected:
#endif
#endif
#endif
+1 -1
View File
@@ -29,7 +29,7 @@ public:
virtual void Render();
virtual void Update(float dt);
bool CheckUserInput(JButton key);
ActionLayer();
ActionLayer(GameObserver *observer);
~ActionLayer();
int cancelCurrentAction();
ActionElement * isWaitingForAnswer();
+9 -10
View File
@@ -83,8 +83,8 @@ public:
return TARGET_STACKACTION;
}
Interruptible(int inID = 0, bool hasFocus = false)
: PlayGuiObject(40, x, y, inID, hasFocus), state(NOT_RESOLVED), display(0), source(NULL)
Interruptible(GameObserver* observer, int inID = 0, bool hasFocus = false)
: Targetable(observer), PlayGuiObject(40, x, y, inID, hasFocus), state(NOT_RESOLVED), display(0), source(NULL)
{
}
@@ -112,7 +112,7 @@ public:
void Render();
virtual ostream& toString(ostream& out) const;
virtual const string getDisplayName() const;
NextGamePhase(int id);
NextGamePhase(GameObserver* observer, int id);
};
class Spell: public Interruptible
@@ -125,8 +125,8 @@ public:
ManaCost * cost;
int payResult;
int computeX(MTGCardInstance * card);
Spell(MTGCardInstance* _source);
Spell(int id, MTGCardInstance* _source, TargetChooser *_tc, ManaCost * _cost, int payResult);
Spell(GameObserver* observer, MTGCardInstance* _source);
Spell(GameObserver* observer, int id, MTGCardInstance* _source, TargetChooser *_tc, ManaCost * _cost, int payResult);
~Spell();
int resolve();
void Render();
@@ -151,7 +151,7 @@ public:
void Render();
virtual ostream& toString(ostream& out) const;
virtual const string getDisplayName() const;
StackAbility(int id, MTGAbility * _ability);
StackAbility(GameObserver* observer, int id, MTGAbility * _ability);
};
class PutInGraveyard: public Interruptible {
@@ -161,7 +161,7 @@ public:
int resolve();
void Render();
virtual ostream& toString(ostream& out) const;
PutInGraveyard(int id, MTGCardInstance * _card);
PutInGraveyard(GameObserver* observer, int id, MTGCardInstance * _card);
};
@@ -173,7 +173,7 @@ public:
int resolve();
void Render();
virtual ostream& toString(ostream& out) const;
DrawAction(int id, Player * _player, int _nbcards);
DrawAction(GameObserver* observer, int id, Player * _player, int _nbcards);
};
class LifeAction: public Interruptible
@@ -184,14 +184,13 @@ public:
int resolve();
void Render();
virtual ostream& toString(ostream& out) const;
LifeAction(int id, Damageable * _target, int amount);
LifeAction(GameObserver* observer, int id, Damageable * _target, int amount);
};
class ActionStack :public GuiLayer
{
protected:
JQuadPtr pspIcons[8];
GameObserver* game;
int interruptDecision[2];
float timer;
int currentState;
File diff suppressed because it is too large Load Diff
+1 -2
View File
@@ -10,13 +10,12 @@ class MTGCardInstance;
class CardDisplay: public PlayGuiObjectController
{
int mId;
GameObserver* game;
public:
int x, y, start_item, nb_displayed_items;
MTGGameZone * zone;
TargetChooser * tc;
JGuiListener * listener;
CardDisplay();
CardDisplay(GameObserver* game);
CardDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener = NULL, TargetChooser * tc = NULL,
int nb_displayed_items = 7);
void AddCard(MTGCardInstance * _card);
+4 -3
View File
@@ -24,8 +24,9 @@ class CardSelectorBase: public GuiLayer
{
public:
CardSelectorBase(int inDrawMode = DrawMode::kNormal) :
mDrawMode(inDrawMode)
CardSelectorBase(GameObserver *observer, int inDrawMode = DrawMode::kNormal) :
GuiLayer(observer), mDrawMode(inDrawMode)
{
}
;
@@ -70,7 +71,7 @@ protected:
PlayGuiObject* fetchMemory(SelectorMemory&);
public:
CardSelector(DuelLayers*);
CardSelector(GameObserver *observer, DuelLayers*);
void Add(PlayGuiObject*);
void Remove(PlayGuiObject*);
bool CheckUserInput(JButton key);
+1 -1
View File
@@ -18,7 +18,7 @@ namespace CardSelectorSingleton
/*
** Create the singleton pointer. Instance() isn't valid until this is called.
*/
CardSelectorBase* Create(DuelLayers* inDuelLayers);
CardSelectorBase* Create(GameObserver* observer, DuelLayers* inDuelLayers);
/*
** Teardown the singleton pointer instance.
+2 -1
View File
@@ -38,6 +38,7 @@ private:
public:
int value;
Player * p1, *p2;
GameObserver* observer;
GameApp * app;
int showMsg;
int unlocked;
@@ -45,7 +46,7 @@ public:
vector<CreditBonus *> bonus;
Credits();
~Credits();
void compute(Player * _p1, Player * _p2, GameApp * _app);
void compute(GameObserver* observer, GameApp * _app);
void Render();
static int unlockRandomSet(bool force = false);
static int unlockSetByName(string name);
+17 -12
View File
@@ -23,20 +23,22 @@ class Damageable:public Targetable
protected:
public:
int life;
int handsize;
int handsize;
int poisonCount;
int damageCount;
int preventable;
int thatmuch;
int lifeLostThisTurn;
int type_as_damageable;
Damageable(int _life){life=_life;lifeLostThisTurn = 0;};
int getLife(){return life;};
virtual int dealDamage(int damage){life-=damage;return life;};
virtual int afterDamage(){return 0;}
virtual int poisoned(){return 0;}
virtual int prevented(){return 0;}
virtual JQuadPtr getIcon(){return JQuadPtr();}
Damageable(GameObserver* observer, int _life)
: Targetable(observer)
{life=_life;lifeLostThisTurn = 0;};
int getLife(){return life;};
virtual int dealDamage(int damage){life-=damage;return life;};
virtual int afterDamage(){return 0;}
virtual int poisoned(){return 0;}
virtual int prevented(){return 0;}
virtual JQuadPtr getIcon(){return JQuadPtr();}
};
class Damage: public Interruptible
@@ -48,8 +50,8 @@ class Damage: public Interruptible
int typeOfDamage;
int damage;
void Render();
Damage(MTGCardInstance* source, Damageable * target);
Damage(MTGCardInstance* source, Damageable * target, int damage, int typeOfDamage = DAMAGE_OTHER);
Damage(GameObserver* observer, MTGCardInstance* source, Damageable * target);
Damage(GameObserver* observer, MTGCardInstance* source, Damageable * target, int damage, int typeOfDamage = DAMAGE_OTHER);
int resolve();
virtual ostream& toString(ostream& out) const;
};
@@ -58,14 +60,17 @@ class DamageStack : public GuiLayer, public Interruptible
{
protected:
int currentState;
GameObserver* game;
public:
int receiveEvent(WEvent * event);
int resolve();
void Render();
virtual ostream& toString(ostream& out) const;
DamageStack();
DamageStack(GameObserver *observer);
};
ostream& operator<<(ostream& out, const Damageable& p);
istream& operator>>(istream& in, Damageable& p);
#endif
+1 -1
View File
@@ -35,7 +35,7 @@ public:
ActionStack * stackLayer();
GuiCombat * combatLayer();
GuiAvatars * GetAvatars();
void init();
void init(GameObserver* go);
virtual void Update(float dt, Player * player);
void CheckUserInput(int isAI);
void Render();
+6 -4
View File
@@ -24,13 +24,13 @@ using namespace std;
class GameObserver{
protected:
static GameObserver * mInstance;
MTGCardInstance * cardWaitingForTargets;
queue<WEvent *> eventsQueue;
int nbPlayers;
int untap(MTGCardInstance * card);
bool WaitForExtraPayment(MTGCardInstance* card);
void initialize();
public:
int currentPlayerId;
@@ -56,19 +56,20 @@ class GameObserver{
int cardClick(MTGCardInstance * card,Targetable * _object = NULL );
int getCurrentGamePhase();
const char * getCurrentGamePhaseName();
const char * getNextGamePhaseName();
void nextCombatStep();
void userRequestNextGamePhase();
void nextGamePhase();
void cleanupPhase();
void nextPlayer();
static void Init(Player * _players[], int _nbplayers);
static GameObserver * GetInstance();
static void EndInstance();
void setPlayers(Player * _players[], int _nbplayers);
Player * currentPlayer;
Player * currentActionPlayer;
Player * isInterrupting;
Player * opponent();
Player * currentlyActing();
GameObserver();
GameObserver(Player * _players[], int _nbplayers);
~GameObserver();
void gameStateBasedEffects();
@@ -86,6 +87,7 @@ class GameObserver{
void Update(float dt);
void Render();
void ButtonPressed(PlayGuiObject*);
int getPlayersNumber() {return nbPlayers;};
int receiveEvent(WEvent * event);
bool connectRule;
+1 -1
View File
@@ -17,7 +17,7 @@ protected:
GuiAvatar* active;
public:
GuiAvatars();
GuiAvatars(GameObserver *observer);
~GuiAvatars();
GuiAvatar* GetSelf();
+1 -1
View File
@@ -10,7 +10,7 @@ protected:
JQuad* quad;
public:
GuiBackground();
GuiBackground(GameObserver* observer);
~GuiBackground();
virtual void Render();
};
+4 -2
View File
@@ -6,8 +6,10 @@
class GuiCardsController: public PlayGuiObjectController
{
public:
GuiCardsController(){}
;
GuiCardsController(GameObserver*observer)
: PlayGuiObjectController(observer)
{
};
};
#endif
-1
View File
@@ -10,7 +10,6 @@
class GuiCombat: public GuiLayer
{
protected:
GameObserver* go;
DamagerDamaged* active;
AttackerDamaged* activeAtk;
static JTexture* ok_tex;
+1 -1
View File
@@ -11,7 +11,7 @@ protected:
float step;
public:
GuiFrame();
GuiFrame(GameObserver* observer);
~GuiFrame();
virtual void Render();
void Update(float dt);
+3 -3
View File
@@ -36,7 +36,7 @@ protected:
vector<CardView*> cards;
public:
GuiHand(MTGHand* hand);
GuiHand(GameObserver* observer, MTGHand* hand);
~GuiHand();
void Update(float dt);
bool isInHand(CardView*);
@@ -47,7 +47,7 @@ public:
class GuiHandOpponent : public GuiHand
{
public:
GuiHandOpponent(MTGHand* hand);
GuiHandOpponent(GameObserver* observer, MTGHand* hand);
virtual void Render();
virtual int receiveEventPlus(WEvent* e);
virtual int receiveEventMinus(WEvent* e);
@@ -65,7 +65,7 @@ protected:
Pos backpos;
public:
GuiHandSelf(MTGHand* hand);
GuiHandSelf(GameObserver* observer, MTGHand* hand);
~GuiHandSelf();
virtual int receiveEventPlus(WEvent* e);
virtual int receiveEventMinus(WEvent* e);
+2 -1
View File
@@ -16,6 +16,7 @@ class GuiLayer
{
protected:
JButton mActionButton;
GameObserver* observer;
public:
int mCurr;
vector<JGuiObject *> mObjects;
@@ -26,7 +27,7 @@ public:
bool hasFocus;
virtual void resetObjects();
int getMaxId();
GuiLayer();
GuiLayer(GameObserver *observer);
virtual ~GuiLayer();
virtual void Update(float dt);
virtual bool CheckUserInput(JButton key)
+1 -1
View File
@@ -13,7 +13,7 @@ protected:
float zoomFactor;
public:
GuiPhaseBar();
GuiPhaseBar(GameObserver* observer);
~GuiPhaseBar();
void Update(float dt);
virtual void Render();
-1
View File
@@ -71,7 +71,6 @@ protected:
class Spells: public VertStack {};
protected:
GameObserver* game;
Creatures selfCreatures, opponentCreatures;
BattleField battleField;
Lands selfLands, opponentLands;
+29 -27
View File
@@ -130,10 +130,10 @@ public:
int abilitygranted;
MTGCardInstance * source;
static int allowedToCast(MTGCardInstance* card, Player* player);
static int allowedToAltCast(MTGCardInstance* card, Player* player);
MTGAbility(int id, MTGCardInstance * card);
MTGAbility(int id, MTGCardInstance * _source, Targetable * _target);
int allowedToCast(MTGCardInstance* card, Player* player);
int allowedToAltCast(MTGCardInstance* card, Player* player);
MTGAbility(GameObserver* observer, int id, MTGCardInstance * card);
MTGAbility(GameObserver* observer, int id, MTGCardInstance * _source, Targetable * _target);
MTGAbility(const MTGAbility& copyFromMe);
virtual int testDestroy();
virtual ~MTGAbility();
@@ -226,8 +226,8 @@ public:
class TriggeredAbility : public MTGAbility
{
public:
TriggeredAbility(int id, MTGCardInstance* card);
TriggeredAbility(int id, MTGCardInstance* _source, Targetable* _target);
TriggeredAbility(GameObserver* observer, int id, MTGCardInstance* card);
TriggeredAbility(GameObserver* observer, int id, MTGCardInstance* _source, Targetable* _target);
virtual void Update(float dt);
virtual void Render()
@@ -259,7 +259,7 @@ private:
bool mActiveTrigger;
public:
Trigger(int id, MTGCardInstance * source, bool once, TargetChooser * _tc = NULL);
Trigger(GameObserver* observer, int id, MTGCardInstance * source, bool once, TargetChooser * _tc = NULL);
int resolve()
{
return 0; //This is a trigger, this function should not be called
@@ -284,7 +284,7 @@ public:
int uses;
string castRestriction;
ActivatedAbility(int id, MTGCardInstance* card, ManaCost* _cost = NULL, int _restrictions = NO_RESTRICTION, string limit = "", MTGAbility* sideEffect = NULL, string usesBeforeSideEffects = "",string castRestriction = "");
ActivatedAbility(GameObserver* observer, int id, MTGCardInstance* card, ManaCost* _cost = NULL, int _restrictions = NO_RESTRICTION, string limit = "", MTGAbility* sideEffect = NULL, string usesBeforeSideEffects = "",string castRestriction = "");
virtual ~ActivatedAbility();
virtual void Update(float dt)
@@ -308,8 +308,8 @@ public:
class TargetAbility : public ActivatedAbility, public NestedAbility
{
public:
TargetAbility(int id, MTGCardInstance * card, TargetChooser * _tc,ManaCost * _cost = NULL, int _playerturnonly = 0, string castRestriction = "");
TargetAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0, string castRestriction = "");
TargetAbility(GameObserver* observer, int id, MTGCardInstance * card, TargetChooser * _tc,ManaCost * _cost = NULL, int _playerturnonly = 0, string castRestriction = "");
TargetAbility(GameObserver* observer, int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0, string castRestriction = "");
~TargetAbility();
virtual int reactToClick(MTGCardInstance * card);
@@ -327,8 +327,8 @@ public:
int init;
virtual void Update(float dt);
virtual int testDestroy();
InstantAbility(int _id, MTGCardInstance * source);
InstantAbility(int _id, MTGCardInstance * source,Targetable * _target);
InstantAbility(GameObserver* observer, int _id, MTGCardInstance * source);
InstantAbility(GameObserver* observer, int _id, MTGCardInstance * source,Targetable * _target);
virtual int resolve()
{
@@ -346,18 +346,18 @@ public:
map<MTGCardInstance *,bool> cards;
map<MTGCardInstance *,bool> checkCards;
map<Player *,bool> players;
ListMaintainerAbility(int _id)
: MTGAbility(_id, NULL)
ListMaintainerAbility(GameObserver* observer, int _id)
: MTGAbility(observer, _id, NULL)
{
}
ListMaintainerAbility(int _id, MTGCardInstance *_source)
: MTGAbility(_id, _source)
ListMaintainerAbility(GameObserver* observer, int _id, MTGCardInstance *_source)
: MTGAbility(observer, _id, _source)
{
}
ListMaintainerAbility(int _id, MTGCardInstance *_source,Damageable * _target)
: MTGAbility(_id, _source, _target)
ListMaintainerAbility(GameObserver* observer, int _id, MTGCardInstance *_source,Damageable * _target)
: MTGAbility(observer, _id, _source, _target)
{
}
@@ -399,7 +399,7 @@ public:
bool lifelost;
int lifeamount;
bool once,activeTrigger;
TriggerAtPhase(int id, MTGCardInstance * source, Targetable * target,int _phaseId, int who = 0,bool sourceUntapped = false,bool sourceTap = false,bool lifelost = false, int lifeamount = 0, bool once = false);
TriggerAtPhase(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target,int _phaseId, int who = 0,bool sourceUntapped = false,bool sourceTap = false,bool lifelost = false, int lifeamount = 0, bool once = false);
virtual int trigger();
int resolve(){return 0;};
virtual TriggerAtPhase* clone() const;
@@ -412,7 +412,7 @@ public:
bool sourceUntapped;
bool sourceTap;
bool once,activeTrigger;
TriggerNextPhase(int id, MTGCardInstance * source, Targetable * target,int _phaseId, int who = 0,bool sourceUntapped = false,bool sourceTap = false,bool once = false);
TriggerNextPhase(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target,int _phaseId, int who = 0,bool sourceUntapped = false,bool sourceTap = false,bool once = false);
virtual TriggerNextPhase* clone() const;
virtual int testDestroy();
@@ -425,7 +425,7 @@ public:
TriggeredAbility * t;
queue<Targetable *> targets;
MTGAbility * destroyCondition;
GenericTriggeredAbility(int id, MTGCardInstance * _source, TriggeredAbility * _t, MTGAbility * a,MTGAbility * dc = NULL, Targetable * _target = NULL);
GenericTriggeredAbility(GameObserver* observer, int id, MTGCardInstance * _source, TriggeredAbility * _t, MTGAbility * a,MTGAbility * dc = NULL, Targetable * _target = NULL);
virtual int trigger();
virtual int triggerOnEvent(WEvent * e);
virtual int resolve();
@@ -450,10 +450,12 @@ private:
MTGAbility * getAlternateCost( string s, int id, Spell *spell, MTGCardInstance *card );
MTGAbility * getManaReduxAbility(string s, int id, Spell *spell, MTGCardInstance *card, MTGCardInstance *target);
TargetChooser * parseSimpleTC(const std::string& s, const std::string& starter, MTGCardInstance *card, bool forceNoTarget = true);
GameObserver *observer;
public:
static int parseRestriction(string s);
static int parseCastRestrictions(MTGCardInstance * card, Player * player, string restrictions);
AbilityFactory(GameObserver *observer) : observer(observer) {};
int parseRestriction(string s);
int parseCastRestrictions(MTGCardInstance * card, Player * player, string restrictions);
Counter * parseCounter(string s, MTGCardInstance * target, Spell * spell = NULL);
int parsePowerToughness(string s, int *power, int *toughness);
int getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCardInstance * card = NULL, int id = 0, MTGGameZone * dest = NULL);
@@ -478,7 +480,7 @@ class ActivatedAbilityTP : public ActivatedAbility
{
public:
int who;
ActivatedAbilityTP(int id, MTGCardInstance * card, Targetable * _target = NULL, ManaCost * cost=NULL, int who = TargetChooser::UNSET);
ActivatedAbilityTP(GameObserver* observer, int id, MTGCardInstance * card, Targetable * _target = NULL, ManaCost * cost=NULL, int who = TargetChooser::UNSET);
Targetable * getTarget();
};
@@ -486,7 +488,7 @@ class InstantAbilityTP : public InstantAbility
{
public:
int who;
InstantAbilityTP(int id, MTGCardInstance * card, Targetable * _target = NULL, int who = TargetChooser::UNSET);
InstantAbilityTP(GameObserver* observer, int id, MTGCardInstance * card, Targetable * _target = NULL, int who = TargetChooser::UNSET);
Targetable * getTarget();
};
@@ -494,7 +496,7 @@ class AbilityTP : public MTGAbility
{
public:
int who;
AbilityTP(int id, MTGCardInstance * card, Targetable * _target = NULL, int who = TargetChooser::UNSET);
AbilityTP(GameObserver* observer, int id, MTGCardInstance * card, Targetable * _target = NULL, int who = TargetChooser::UNSET);
Targetable * getTarget();
@@ -513,7 +515,7 @@ public:
string menutext;
ManaCost * output;
int tap;
AManaProducer(int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost = NULL, int who = TargetChooser::UNSET);
AManaProducer(GameObserver* observer, int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost = NULL, int who = TargetChooser::UNSET);
int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL);
int resolve();
int reactToClick(MTGCardInstance* _card);
+1 -1
View File
@@ -196,7 +196,7 @@ public:
void eventattackedblocked(MTGCardInstance * opponent);
void eventblocked(MTGCardInstance * opponent);
int isInPlay();
int isInPlay(GameObserver* game);
JSample * getSample();
JQuadPtr getIcon();
+2 -1
View File
@@ -14,9 +14,10 @@ protected:
int currentState;
WFont * mFont;
static MTGGamePhase* instance;
GameObserver* observer;
public:
MTGGamePhase(int id);
MTGGamePhase(GameObserver* g, int id);
static MTGGamePhase* GetInstance() { return instance; };
virtual void Update(float dt);
bool CheckUserInput(JButton key);
+4 -3
View File
@@ -108,9 +108,9 @@ class MTGGameZone {
void setOwner(Player * player);
MTGCardInstance * lastCardDrawn;
static MTGGameZone * stringToZone(string zoneName, MTGCardInstance * source, MTGCardInstance * target);
static MTGGameZone * stringToZone(GameObserver *g, string zoneName, MTGCardInstance * source, MTGCardInstance * target);
static int zoneStringToId(string zoneName);
static MTGGameZone *intToZone(int zoneId, MTGCardInstance * source = NULL,MTGCardInstance * target = NULL);
static MTGGameZone *intToZone(GameObserver *g, int zoneId, MTGCardInstance * source = NULL,MTGCardInstance * target = NULL);
static MTGGameZone *intToZone(int zoneId, Player * source, Player * target = NULL);
bool needShuffle;
virtual const char * getName(){return "zone";};
@@ -177,7 +177,7 @@ public:
MTGGameZone * temp;
MTGPlayerCards();
MTGPlayerCards(int * idList, int idListSize);
MTGPlayerCards(Player*, int * idList, int idListSize);
MTGPlayerCards(MTGDeck * deck);
~MTGPlayerCards();
void initGame(int shuffle = 1, int draw = 1);
@@ -200,6 +200,7 @@ public:
};
ostream& operator<<(ostream&, const MTGGameZone&);
istream& operator>>(istream&, MTGGameZone&);
ostream& operator<<(ostream&, const MTGPlayerCards&);
istream& operator>>(istream&, MTGPlayerCards&);
+26 -26
View File
@@ -15,7 +15,7 @@ class OtherAbilitiesEventReceiver: public MTGAbility
public:
int testDestroy();
int receiveEvent(WEvent * event);
OtherAbilitiesEventReceiver(int _id);
OtherAbilitiesEventReceiver(GameObserver* observer, int _id);
OtherAbilitiesEventReceiver * clone() const;
};
@@ -58,7 +58,7 @@ public:
int testDestroy();
void Update(float dt);
void Render();
MTGEventBonus(int _id);
MTGEventBonus(GameObserver* observer, int _id);
virtual MTGEventBonus * clone() const;
};
@@ -69,7 +69,7 @@ public:
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGPutInPlayRule(int _id);
MTGPutInPlayRule(GameObserver* observer, int _id);
const char * getMenuText()
{
return "cast card normally";
@@ -84,7 +84,7 @@ public:
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGKickerRule(int _id);
MTGKickerRule(GameObserver* observer, int _id);
const char * getMenuText()
{
return "pay kicker";
@@ -104,7 +104,7 @@ public:
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGAlternativeCostRule(int _id);
MTGAlternativeCostRule(GameObserver* observer, int _id);
const char * getMenuText()
{
if(alternativeName.size())
@@ -121,7 +121,7 @@ public:
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGBuyBackRule(int _id);
MTGBuyBackRule(GameObserver* observer, int _id);
const char * getMenuText()
{
return "cast and buy back";
@@ -137,7 +137,7 @@ public:
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGFlashBackRule(int _id);
MTGFlashBackRule(GameObserver* observer, int _id);
const char * getMenuText()
{
return "flash back";
@@ -152,7 +152,7 @@ public:
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGRetraceRule(int _id);
MTGRetraceRule(GameObserver* observer, int _id);
const char * getMenuText()
{
return "retrace";
@@ -168,7 +168,7 @@ public:
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGMorphCostRule(int _id);
MTGMorphCostRule(GameObserver* observer, int _id);
const char * getMenuText()
{
return "play morphed";
@@ -185,7 +185,7 @@ public:
int testDestroy();
string suspendmenu;
virtual ostream& toString(ostream& out) const;
MTGSuspendRule(int _id);
MTGSuspendRule(GameObserver* observer, int _id);
const char * getMenuText()
{
suspendmenu = "suspend";
@@ -208,7 +208,7 @@ public:
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGAttackRule(int _id);
MTGAttackRule(GameObserver* observer, int _id);
const char * getMenuText()
{
return "Attacker";
@@ -221,7 +221,7 @@ public:
class MTGCombatTriggersRule: public MTGAbility
{
public:
MTGCombatTriggersRule(int _id);
MTGCombatTriggersRule(GameObserver* observer, int _id);
int receiveEvent(WEvent * event);
virtual ostream& toString(ostream& out) const;
int testDestroy();
@@ -235,7 +235,7 @@ public:
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGBlockRule(int _id);
MTGBlockRule(GameObserver* observer, int _id);
const char * getMenuText()
{
return "Blocker";
@@ -247,7 +247,7 @@ public:
class MTGPersistRule: public MTGAbility
{
public:
MTGPersistRule(int _id);
MTGPersistRule(GameObserver* observer, int _id);
int receiveEvent(WEvent * event);
virtual ostream& toString(ostream& out) const;
int testDestroy();
@@ -257,7 +257,7 @@ public:
class MTGVampireRule: public MTGAbility
{
public:
MTGVampireRule(int _id);
MTGVampireRule(GameObserver* observer, int _id);
map<MTGCardInstance*,vector<MTGCardInstance*> > victems;
int receiveEvent(WEvent * event);
virtual ostream& toString(ostream& out) const;
@@ -268,7 +268,7 @@ public:
class MTGUnearthRule: public MTGAbility
{
public:
MTGUnearthRule(int _id);
MTGUnearthRule(GameObserver* observer, int _id);
int receiveEvent(WEvent * event);
virtual ostream& toString(ostream& out) const;
int testDestroy();
@@ -278,7 +278,7 @@ class MTGTokensCleanup: public MTGAbility
{
public:
vector<MTGCardInstance *> list;
MTGTokensCleanup(int _id);
MTGTokensCleanup(GameObserver* observer, int _id);
int receiveEvent(WEvent * event);
int testDestroy();
virtual MTGTokensCleanup * clone() const;
@@ -293,7 +293,7 @@ public:
class MTGLegendRule: public ListMaintainerAbility
{
public:
MTGLegendRule(int _id);
MTGLegendRule(GameObserver* observer, int _id);
int canBeInList(MTGCardInstance * card);
int added(MTGCardInstance * card);
int removed(MTGCardInstance * card);
@@ -304,7 +304,7 @@ public:
class MTGPlaneWalkerRule: public ListMaintainerAbility
{
public:
MTGPlaneWalkerRule(int _id);
MTGPlaneWalkerRule(GameObserver* observer, int _id);
int canBeInList(MTGCardInstance * card);
int added(MTGCardInstance * card);
int removed(MTGCardInstance * card);
@@ -330,7 +330,7 @@ public:
int testDestroy();
void Update(float dt);
void Render();
MTGMomirRule(int _id, MTGAllCards * _collection);
MTGMomirRule(GameObserver* observer, int _id, MTGAllCards * _collection);
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int reactToClick(MTGCardInstance * card);
int reactToClick(MTGCardInstance * card, int id);
@@ -353,7 +353,7 @@ public:
MTGAllCards * collection;
MTGCardInstance * genEquip(int id);
int testDestroy();
MTGStoneHewerRule(int _id, MTGAllCards * _collection);
MTGStoneHewerRule(GameObserver* observer, int _id, MTGAllCards * _collection);
int receiveEvent(WEvent * event);
const char * getMenuText()
{
@@ -367,7 +367,7 @@ class MTGHermitRule: public MTGAbility
{
public:
int testDestroy();
MTGHermitRule(int _id);
MTGHermitRule(GameObserver* observer, int _id);
int receiveEvent(WEvent * event);
const char * getMenuText()
{
@@ -380,7 +380,7 @@ public:
class MTGLifelinkRule: public MTGAbility
{
public:
MTGLifelinkRule(int _id);
MTGLifelinkRule(GameObserver* observer, int _id);
int receiveEvent(WEvent * event);
@@ -395,7 +395,7 @@ public:
class MTGDeathtouchRule: public MTGAbility
{
public:
MTGDeathtouchRule(int _id);
MTGDeathtouchRule(GameObserver* observer, int _id);
int receiveEvent(WEvent * event);
@@ -412,7 +412,7 @@ public:
class ParentChildRule: public MTGAbility
{
public:
ParentChildRule(int _id);
ParentChildRule(GameObserver* observer, int _id);
int receiveEvent(WEvent * event);
virtual ostream& toString(ostream& out) const;
int testDestroy();
@@ -448,7 +448,7 @@ public:
int receiveEvent(WEvent * event);
void Update(float dt);
void Render();
HUDDisplay(int _id);
HUDDisplay(GameObserver* observer, int _id);
~HUDDisplay();
virtual HUDDisplay * clone() const;
};
+5 -3
View File
@@ -10,6 +10,7 @@ using namespace std;
*/
class Player;
class GameObserver;
typedef enum
{
@@ -37,19 +38,20 @@ public:
class PhaseRing
{
private:
static bool extraDamagePhase(int id);
bool extraDamagePhase(int id);
GameObserver* observer;
public:
list<Phase *> ring;
list<Phase *>::iterator current;
Phase * getCurrentPhase();
Phase * forward(bool sendEvents = true);
Phase * goToPhase(int id, Player * player, bool sendEvents = true);
PhaseRing(Player* players[], int nbPlayers = 2);
PhaseRing(GameObserver* observer);
~PhaseRing();
int addPhase(Phase * phase);
int addPhaseBefore(int id, Player* player, int after_id, Player * after_player, int allOccurences = 1);
int removePhase(int id, Player * player, int allOccurences = 1);
static const char * phaseName(int id);
const char * phaseName(int id);
static int phaseStrToInt(string s);
};
@@ -15,7 +15,8 @@ protected:
public:
virtual void Update(float dt);
virtual bool CheckUserInput(JButton key);
PlayGuiObjectController()
PlayGuiObjectController(GameObserver *observer)
: GuiLayer(observer)
{
last_user_move = 0;
}
+6 -5
View File
@@ -24,6 +24,7 @@ public:
MODE_AI
};
string mAvatarName;
JTexture * mAvatarTex;
JQuadPtr mAvatar;
int playMode;
@@ -35,9 +36,9 @@ public:
string deckName;
string phaseRing;
int offerInterruptOnPhase;
Player(string deckFile, string deckFileSmall, MTGDeck * deck = NULL);
Player(GameObserver *observer, string deckFile, string deckFileSmall, MTGDeck * deck = NULL);
virtual ~Player();
virtual void setObserver(GameObserver*g);
virtual void End();
virtual int displayStack()
{
@@ -94,17 +95,17 @@ public:
** Returns the path to the stats file of currently selected deck.
*/
std::string GetCurrentDeckStatsFile();
friend istream& operator>>(istream& in, Player& p);
};
class HumanPlayer: public Player
{
public:
HumanPlayer(string deckFile, string deckFileSmall, MTGDeck * deck = NULL);
HumanPlayer(string deckFile);
HumanPlayer(GameObserver *observer, string deckFile, string deckFileSmall = "", MTGDeck * deck = NULL);
};
ostream& operator<<(ostream&, const Player&);
istream& operator>>(istream& in, Player& p);
#endif
+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);
};
+28 -25
View File
@@ -36,8 +36,9 @@ public:
};
bool other;
bool withoutProtections;
TargetChooser(MTGCardInstance * card = NULL, int _maxtargets = UNLITMITED_TARGETS, bool other = false, bool targetMin = false);
TargetChooser(GameObserver *observer, MTGCardInstance * card = NULL, int _maxtargets = UNLITMITED_TARGETS, bool other = false, bool targetMin = false);
Player * Owner;
GameObserver *observer;
MTGCardInstance * source;
MTGCardInstance * targetter; //Optional, usually equals source, used for protection from...
int maxtargets;
@@ -96,7 +97,9 @@ public:
class TargetChooserFactory
{
GameObserver* observer;
public:
TargetChooserFactory(GameObserver *observer) : observer(observer) {};
TargetChooser * createTargetChooser(string s, MTGCardInstance * card, MTGAbility * ability = NULL);
TargetChooser * createTargetChooser(MTGCardInstance * card);
};
@@ -110,8 +113,8 @@ public:
bool targetsZone(MTGGameZone * z);
bool targetsZone(MTGGameZone * z,MTGCardInstance * mSource);
bool withoutProtections;
TargetZoneChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false);
TargetZoneChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false);
TargetZoneChooser(GameObserver *observer, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false);
TargetZoneChooser(GameObserver *observer, int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false);
virtual bool canTarget(Targetable * _card,bool withoutProtections = false);
int setAllZones();
virtual TargetZoneChooser * clone() const;
@@ -124,7 +127,7 @@ protected:
MTGCardInstance * validTarget;
public:
bool withoutProtections;
CardTargetChooser(MTGCardInstance * card, MTGCardInstance * source, int * zones = NULL, int nbzones = 0);
CardTargetChooser(GameObserver *observer, MTGCardInstance * card, MTGCardInstance * source, int * zones = NULL, int nbzones = 0);
virtual bool canTarget(Targetable * target,bool withoutProtections = false);
virtual CardTargetChooser * clone() const;
virtual bool equals(TargetChooser * tc);
@@ -136,8 +139,8 @@ public:
int nbtypes;
int types[10];
bool withoutProtections;
TypeTargetChooser(const char * _type, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false);
TypeTargetChooser(const char * _type, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false);
TypeTargetChooser(GameObserver *observer, const char * _type, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false);
TypeTargetChooser(GameObserver *observer, const char * _type, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false);
void addType(int type);
void addType(const char * type);
virtual bool canTarget(Targetable * target,bool withoutProtections = false);
@@ -149,13 +152,13 @@ class DamageableTargetChooser: public TypeTargetChooser
{
public:
bool withoutProtections;
DamageableTargetChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false) :
TypeTargetChooser("creature",_zones, _nbzones, card, _maxtargets, other, targetMin)
DamageableTargetChooser(GameObserver *observer, int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false) :
TypeTargetChooser(observer, "creature",_zones, _nbzones, card, _maxtargets, other, targetMin)
{
}
;
DamageableTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false) :
TypeTargetChooser("creature", card, _maxtargets, other, targetMin)
DamageableTargetChooser(GameObserver *observer, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false) :
TypeTargetChooser(observer, "creature", card, _maxtargets, other, targetMin)
{
}
;
@@ -170,7 +173,7 @@ protected:
Player * p; //In Case we can only target a specific player
public:
bool withoutProtections;
PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, Player *_p = NULL);
PlayerTargetChooser(GameObserver *observer, MTGCardInstance * card = NULL, int _maxtargets = 1, Player *_p = NULL);
virtual bool canTarget(Targetable * target, bool withoutProtections = false);
virtual PlayerTargetChooser * clone() const;
virtual bool equals(TargetChooser * tc);
@@ -181,8 +184,8 @@ class DescriptorTargetChooser: public TargetZoneChooser
public:
CardDescriptor * cd;
bool withoutProtections;
DescriptorTargetChooser(CardDescriptor * _cd, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false,bool targetMin = false);
DescriptorTargetChooser(CardDescriptor * _cd, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false,bool targetMin = false);
DescriptorTargetChooser(GameObserver *observer, CardDescriptor * _cd, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false,bool targetMin = false);
DescriptorTargetChooser(GameObserver *observer, CardDescriptor * _cd, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false,bool targetMin = false);
virtual bool canTarget(Targetable * target,bool withoutProtections = false);
~DescriptorTargetChooser();
virtual DescriptorTargetChooser * clone() const;
@@ -194,7 +197,7 @@ class SpellTargetChooser: public TargetChooser
public:
int color;
bool withoutProtections;
SpellTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, bool other = false, bool targetMin = false);
SpellTargetChooser(GameObserver *observer, MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, bool other = false, bool targetMin = false);
virtual bool canTarget(Targetable * target, bool withoutProtections = false);
virtual SpellTargetChooser * clone() const;
virtual bool equals(TargetChooser * tc);
@@ -205,7 +208,7 @@ class SpellOrPermanentTargetChooser: public TargetZoneChooser
public:
int color;
bool withoutProtections;
SpellOrPermanentTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, bool other = false, bool targetMin = false);
SpellOrPermanentTargetChooser(GameObserver *observer, MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, bool other = false, bool targetMin = false);
virtual bool canTarget(Targetable * target, bool withoutProtections = false);
virtual SpellOrPermanentTargetChooser * clone() const;
virtual bool equals(TargetChooser * tc);
@@ -217,7 +220,7 @@ public:
int color;
int state;
bool withoutProtections;
DamageTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, int state = NOT_RESOLVED);
DamageTargetChooser(GameObserver *observer, MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, int state = NOT_RESOLVED);
virtual bool canTarget(Targetable * target, bool withoutProtections = false);
virtual DamageTargetChooser * clone() const;
virtual bool equals(TargetChooser * tc);
@@ -230,7 +233,7 @@ public:
Targetable * target;
int triggerTarget;
bool withoutProtections;
TriggerTargetChooser(int _triggerTarget);
TriggerTargetChooser(GameObserver *observer, int _triggerTarget);
virtual bool targetsZone(MTGGameZone * z);
virtual bool canTarget(Targetable * _target, bool withoutProtections = false);
virtual TriggerTargetChooser * clone() const;
@@ -241,13 +244,13 @@ class ProliferateChooser: public TypeTargetChooser
{
public:
bool withoutProtections;
ProliferateChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false) :
TypeTargetChooser("*",_zones, _nbzones, card, _maxtargets, other, targetMin)
ProliferateChooser(GameObserver *observer, int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false) :
TypeTargetChooser(observer, "*",_zones, _nbzones, card, _maxtargets, other, targetMin)
{
}
;
ProliferateChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false,bool targetMin = false) :
TypeTargetChooser("*", card, _maxtargets, other,targetMin)
ProliferateChooser(GameObserver *observer, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false,bool targetMin = false) :
TypeTargetChooser(observer, "*", card, _maxtargets, other,targetMin)
{
}
;
@@ -262,13 +265,13 @@ public:
bool withoutProtections;
int type;
TargetChooser * deeperTargeting;
ParentChildChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1,TargetChooser * deepTc = NULL,int type = 1, bool other = false, bool targetMin = false) :
TypeTargetChooser("*",_zones, _nbzones, card, _maxtargets, other, targetMin),type(type),deeperTargeting(deepTc)
ParentChildChooser(GameObserver *observer, int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1,TargetChooser * deepTc = NULL,int type = 1, bool other = false, bool targetMin = false) :
TypeTargetChooser(observer, "*",_zones, _nbzones, card, _maxtargets, other, targetMin),type(type),deeperTargeting(deepTc)
{
}
;
ParentChildChooser(MTGCardInstance * card = NULL, int _maxtargets = 1,TargetChooser * deepTc = NULL,int type = 1, bool other = false,bool targetMin = false) :
TypeTargetChooser("*", card, _maxtargets, other,targetMin),type(type),deeperTargeting(deepTc)
ParentChildChooser(GameObserver *observer, MTGCardInstance * card = NULL, int _maxtargets = 1,TargetChooser * deepTc = NULL,int type = 1, bool other = false,bool targetMin = false) :
TypeTargetChooser(observer, "*", card, _maxtargets, other,targetMin),type(type),deeperTargeting(deepTc)
{
}
;
+5
View File
@@ -7,9 +7,14 @@
class Targetable
{
protected:
GameObserver* observer;
public:
Targetable(GameObserver* observer) : observer(observer) {};
virtual int typeAsTarget() = 0;
virtual const string getDisplayName() const = 0;
inline GameObserver* getObserver() { return observer; };
virtual void setObserver(GameObserver*g) { observer = g; };
};
#endif
+10 -10
View File
@@ -59,7 +59,7 @@ public:
virtual string getShortDesc() = 0;
int getExpiration();
int getReward();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app) = 0;
virtual bool isDone(GameObserver* observer, GameApp * _app) = 0;
bool isExpired();
void setExpiration(int _expiresIn);
void passOneDay();
@@ -100,7 +100,7 @@ public:
void addRandomTask(int diff = 100);
void removeTask(Task *task);
void passOneDay();
void getDoneTasks(Player * _p1, Player * _p2, GameApp * _app, vector<Task*>* result);
void getDoneTasks(GameObserver* observer, GameApp * _app, vector<Task*>* result);
int getTaskCount();
void Start();
@@ -121,7 +121,7 @@ public:
TaskWinAgainst(int _opponent = 0);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual bool isDone(GameObserver* observer, GameApp * _app);
};
class TaskSlaughter: public TaskWinAgainst
@@ -133,7 +133,7 @@ public:
TaskSlaughter(int _opponent = 0, int _targetLife = -15);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual bool isDone(GameObserver* observer, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
@@ -149,7 +149,7 @@ public:
TaskDelay(int _opponent = 0, int _turn = 20);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual bool isDone(GameObserver* observer, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
@@ -166,7 +166,7 @@ public:
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual bool isDone(GameObserver* observer, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
@@ -183,7 +183,7 @@ public:
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual bool isDone(GameObserver* observer, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
@@ -200,7 +200,7 @@ public:
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual bool isDone(GameObserver* observer, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
@@ -216,7 +216,7 @@ public:
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual bool isDone(GameObserver* observer, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
@@ -232,7 +232,7 @@ public:
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual bool isDone(GameObserver* observer, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
+11 -30
View File
@@ -18,37 +18,18 @@ public:
void cleanup();
};
class TestSuitePlayerZone
{
public:
int cards[MAX_TESTUITE_CARDS];
int nbitems;
void add(int cardid);
TestSuitePlayerZone();
void cleanup();
};
class TestSuitePlayerData
{
public:
int life;
ManaCost * manapool;
TestSuitePlayerZone zones[5];
TestSuitePlayerData();
~TestSuitePlayerData();
void cleanup();
};
class TestSuite;
class TestSuiteAI;
class TestSuiteState
{
public:
int phase;
void parsePlayerState(int playerId, string s);
TestSuiteState();
TestSuitePlayerData playerData[2];
void cleanup();
TestSuiteAI* players[2];
void cleanup(TestSuite*);
};
class TestSuitePregame
@@ -66,8 +47,6 @@ private:
TestSuiteState endState;
TestSuiteActions actions;
bool forceAbility;
int summoningSickness;
int load(const char * filename);
void cleanup();
@@ -77,12 +56,13 @@ public:
float timerLimit;
int aiMaxCalls;
int currentAction;
int summoningSickness;
TestSuiteState initState;
string getNextAction();
MTGPlayerCards * buildDeck(int playerId);
Interruptible * getActionByMTGId(int mtgid);
int assertGame();
MTGPlayerCards * buildDeck(Player*, int playerId);
Interruptible * getActionByMTGId(GameObserver* observer, int mtgid);
int assertGame(GameObserver*);
public:
int startTime, endTime;
@@ -90,7 +70,7 @@ public:
unsigned int seed;
int nbFailed, nbTests, nbAIFailed, nbAITests;
TestSuite(const char * filename);
void initGame();
void initGame(GameObserver* g);
void pregameTests();
int loadNext();
static int Log(const char * text);
@@ -106,9 +86,10 @@ private:
TestSuite * suite;
public:
TestSuiteAI(TestSuite * suite, int playerId);
TestSuiteAI(GameObserver *observer, TestSuite * suite, int playerId);
virtual int Act(float dt);
virtual int displayStack();
bool summoningSickness() {return (suite->summoningSickness == 1); }
};
#endif
+1 -1
View File
@@ -22,7 +22,7 @@ class ThisDescriptor{
class ThisDescriptorFactory{
public:
ThisDescriptor * createThisDescriptor(string s);
ThisDescriptor * createThisDescriptor(GameObserver* observer, string s);
};
class ThisCounter:public ThisDescriptor{
+1
View File
@@ -8,6 +8,7 @@ class Token: public MTGCardInstance
MTGCardInstance * tokenSource;
public:
Token(string _name, MTGCardInstance * source, int _power = 0, int _toughness = 0);
Token(int id);
};
#endif