No code change just reformatting of header files.

finishing up my reformatting of the source from November/December following the guidelines that were posted.
some extra things I added:
   * Any empty virtual declarations were kept to one line.  
   * Enums were split up into separate lines to promote uniformity across all headers. ( each header file had a different style for enums)
This commit is contained in:
techdragon.nguyen@gmail.com
2011-01-21 18:01:14 +00:00
parent 6d3d4c1792
commit e53c16f700
101 changed files with 6128 additions and 4684 deletions

View File

@@ -3,15 +3,15 @@
#include "AIPlayer.h" #include "AIPlayer.h"
class AIMomirPlayer: public AIPlayerBaka
class AIMomirPlayer:public AIPlayerBaka{ {
public: public:
AIMomirPlayer(MTGDeck * deck, string file, string fileSmall, string avatarFile); AIMomirPlayer(MTGDeck * deck, string file, string fileSmall, string avatarFile);
int getEfficiency(AIAction * action); int getEfficiency(AIAction * action);
int momir(); int momir();
int computeActions(); int computeActions();
static MTGAbility * momirAbility; static MTGAbility * momirAbility;
static MTGAbility * getMomirAbility(); static MTGAbility * getMomirAbility();
}; };
#endif #endif

View File

@@ -18,7 +18,6 @@ using std::queue;
#define INFO_CREATURESTOUGHNESS 3 #define INFO_CREATURESTOUGHNESS 3
#define INFO_CREATURESATTACKINGPOWER 4 #define INFO_CREATURESATTACKINGPOWER 4
class AIStats; class AIStats;
class AIAction class AIAction
@@ -35,22 +34,25 @@ public:
MTGCardInstance * click; MTGCardInstance * click;
MTGCardInstance * target; // TODO Improve MTGCardInstance * target; // TODO Improve
AIAction(MTGAbility * a, MTGCardInstance * c, MTGCardInstance * t = NULL) AIAction(MTGAbility * a, MTGCardInstance * c, MTGCardInstance * t = NULL) :
: efficiency(-1), ability(a), player(NULL), click(c), target(t) efficiency(-1), ability(a), player(NULL), click(c), target(t)
{ {
id = currentId++; id = currentId++;
}; }
;
AIAction(MTGCardInstance * c, MTGCardInstance * t = NULL) AIAction(MTGCardInstance * c, MTGCardInstance * t = NULL) :
: efficiency(-1), ability(NULL), player(NULL), click(c), target(t) efficiency(-1), ability(NULL), player(NULL), click(c), target(t)
{ {
id = currentId++; id = currentId++;
}; }
;
AIAction(Player * p) AIAction(Player * p) :
: efficiency(-1), ability(NULL), player(p), click(NULL), target(NULL) efficiency(-1), ability(NULL), player(p), click(NULL), target(NULL)
{ {
}; }
;
int getEfficiency(); int getEfficiency();
int Act(); int Act();
@@ -58,22 +60,24 @@ public:
// compares Abilities efficiency // compares Abilities efficiency
class CmpAbilities class CmpAbilities
{ {
public: public:
bool operator()(const AIAction& a1, const AIAction& a2) const bool operator()(const AIAction& a1, const AIAction& a2) const
{ {
AIAction* a1Ptr = const_cast<AIAction*>(&a1); AIAction* a1Ptr = const_cast<AIAction*> (&a1);
AIAction* a2Ptr = const_cast<AIAction*>(&a2); AIAction* a2Ptr = const_cast<AIAction*> (&a2);
int e1 = a1Ptr->getEfficiency(); int e1 = a1Ptr->getEfficiency();
int e2 = a2Ptr->getEfficiency(); int e2 = a2Ptr->getEfficiency();
if (e1 == e2) return a1Ptr->id < a2Ptr->id; if (e1 == e2)
return a1Ptr->id < a2Ptr->id;
return (e1 > e2); return (e1 > e2);
} }
}; };
typedef std::map<AIAction, int, CmpAbilities> RankingContainer; typedef std::map<AIAction, int, CmpAbilities> RankingContainer;
class AIPlayer: public Player{ class AIPlayer: public Player
{
protected: protected:
//Variables used by Test suite //Variables used by Test suite
MTGCardInstance * nextCardToPlay; MTGCardInstance * nextCardToPlay;
@@ -86,29 +90,40 @@ protected:
int chooseBlockers(); int chooseBlockers();
int canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy); int canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy);
int effectBadOrGood(MTGCardInstance * card, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL); int effectBadOrGood(MTGCardInstance * card, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL);
int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0); int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES, int untapMode = 0, int canAttack = 0);
AIStats * getStats(); AIStats * getStats();
// returns 1 if the AI algorithm supports a given cost (ex:simple mana cost), 0 otherwise (ex: cost involves Sacrificing a target) // returns 1 if the AI algorithm supports a given cost (ex:simple mana cost), 0 otherwise (ex: cost involves Sacrificing a target)
int CanHandleCost(ManaCost * cost); int CanHandleCost(ManaCost * cost);
public: public:
AIStats * stats; AIStats * stats;
int agressivity; int agressivity;
bool Checked; bool Checked;
bool forceBestAbilityUse; bool forceBestAbilityUse;
void End(){}; void End()
virtual int displayStack() {return 0;}; {
}
;
virtual int displayStack()
{
return 0;
}
;
int receiveEvent(WEvent * event); int receiveEvent(WEvent * event);
void Render(); void Render();
ManaCost * getPotentialMana(MTGCardInstance * card = NULL); ManaCost * getPotentialMana(MTGCardInstance * card = NULL);
AIPlayer(MTGDeck * deck, string deckFile, string deckFileSmall); AIPlayer(MTGDeck * deck, string deckFile, string deckFileSmall);
virtual ~AIPlayer(); virtual ~AIPlayer();
virtual MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0); virtual MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0);
virtual int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget =NULL); virtual int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget = NULL);
virtual int Act(float dt); virtual int Act(float dt);
virtual int affectCombatDamages(CombatStep); virtual int affectCombatDamages(CombatStep);
int isAI(){return 1;}; int isAI()
{
return 1;
}
;
int canHandleCost(MTGAbility * ability); int canHandleCost(MTGAbility * ability);
int selectAbility(); int selectAbility();
int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingContainer& ranking); int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingContainer& ranking);
@@ -117,24 +132,24 @@ public:
}; };
class AIPlayerBaka: public AIPlayer
class AIPlayerBaka: public AIPlayer{ {
protected: protected:
int oldGamePhase; int oldGamePhase;
float timer; float timer;
MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type); MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type);
public: public:
int deckId; int deckId;
AIPlayerBaka(MTGDeck * deck, string deckFile, string deckfileSmall, string avatarFile); AIPlayerBaka(MTGDeck * deck, string deckFile, string deckfileSmall, string avatarFile);
virtual int Act(float dt); virtual int Act(float dt);
void initTimer(); void initTimer();
virtual int computeActions(); virtual int computeActions();
}; };
class AIPlayerFactory{ class AIPlayerFactory
public: {
AIPlayer * createAIPlayer(MTGAllCards * collection, Player * opponent, int deckid = 0); public:
AIPlayer * createAIPlayer(MTGAllCards * collection, Player * opponent, int deckid = 0);
}; };
#endif #endif

View File

@@ -18,31 +18,35 @@ class MTGCard;
class Damage; class Damage;
class WEvent; class WEvent;
class AIStat{ class AIStat
public: {
int source; //MTGId of the card public:
int value; int source; //MTGId of the card
int occurences; int value;
bool direct; int occurences;
AIStat(int _source, int _value, int _occurences, bool _direct):source(_source), value(_value),occurences(_occurences),direct(_direct){}; bool direct;
AIStat(int _source, int _value, int _occurences, bool _direct) :
source(_source), value(_value), occurences(_occurences), direct(_direct)
{
}
;
}; };
class AIStats
{
class AIStats{ public:
public: Player * player;
Player * player; string filename;
string filename; list<AIStat *> stats;
list<AIStat *> stats; AIStats(Player * _player, char * filename);
AIStats(Player * _player, char * filename); ~AIStats();
~AIStats(); void load(char * filename);
void load(char * filename); void save();
void save(); AIStat * find(MTGCard * card);
AIStat * find(MTGCard * card); bool isInTop(MTGCardInstance * card, unsigned int max, bool tooSmallCountsForTrue = true);
bool isInTop(MTGCardInstance * card, unsigned int max, bool tooSmallCountsForTrue = true ); void updateStatsCard(MTGCardInstance * cardInstance, Damage * damage, float multiplier = 1.0);
void updateStatsCard(MTGCardInstance * cardInstance, Damage * damage, float multiplier = 1.0); int receiveEvent(WEvent * event);
int receiveEvent(WEvent * event); void Render();
void Render();
}; };
#endif #endif

View File

@@ -12,43 +12,73 @@
#define ACTION_REQUESTED 1 #define ACTION_REQUESTED 1
#define ACTIVE 2 #define ACTIVE 2
class MTGCardInstance; class MTGCardInstance;
class ManaCost; class ManaCost;
class Targetable; class Targetable;
class TargetChooser; class TargetChooser;
class WEvent; class WEvent;
class ActionElement: public JGuiObject{ class ActionElement: public JGuiObject
protected: {
int activeState; protected:
int activeState;
public:
int isClone;
TargetChooser * tc;
int currentPhase;
int newPhase;
int modal;
int waitingForAnswer;
int getActivity();
virtual void Update(float dt){};
virtual void Render(){};
virtual int testDestroy()
{
return 0;
}
;
virtual int destroy()
{
return 0;
}
;
virtual bool CheckUserInput(JButton key)
{
return false;
}
;
ActionElement(int id);
virtual ~ActionElement();
virtual int isReactingToTargetClick(Targetable * card);
virtual int reactToTargetClick(Targetable * card);
virtual int isReactingToClick(MTGCardInstance * card, ManaCost * man = NULL)
{
return 0;
}
;
virtual int stillInUse(MTGCardInstance * card)
{
return 0;
}
;
virtual int receiveEvent(WEvent * event)
{
return 0;
}
;
virtual int reactToClick(MTGCardInstance * card)
{
return 0;
}
;
virtual const char * getMenuText()
{
return "Ability";
}
;
virtual ActionElement * clone() const = 0;
public:
int isClone;
TargetChooser * tc;
int currentPhase;
int newPhase;
int modal;
int waitingForAnswer;
int getActivity();
virtual void Update(float dt){};
virtual void Render(){};
virtual int testDestroy(){return 0;};
virtual int destroy(){return 0;};
virtual bool CheckUserInput(JButton key){return false;};
ActionElement(int id);
virtual ~ActionElement();
virtual int isReactingToTargetClick(Targetable * card);
virtual int reactToTargetClick(Targetable * card);
virtual int isReactingToClick(MTGCardInstance * card, ManaCost * man = NULL){return 0;};
virtual int stillInUse(MTGCardInstance * card){return 0;};
virtual int receiveEvent(WEvent * event){return 0;};
virtual int reactToClick(MTGCardInstance * card){return 0;};
virtual const char * getMenuText(){return "Ability";};
virtual ActionElement * clone() const = 0;
}; };
#endif #endif

View File

@@ -16,40 +16,39 @@ class GuiLayer;
class Targetable; class Targetable;
class WEvent; class WEvent;
class ActionLayer: public GuiLayer, public JGuiListener{ class ActionLayer: public GuiLayer, public JGuiListener
public: {
vector <ActionElement *> garbage; public:
Targetable * menuObject; vector<ActionElement *> garbage;
SimpleMenu * abilitiesMenu; Targetable * menuObject;
int stuffHappened; SimpleMenu * abilitiesMenu;
virtual void Render(); int stuffHappened;
virtual void Update(float dt); virtual void Render();
bool CheckUserInput(JButton key); virtual void Update(float dt);
ActionLayer(); bool CheckUserInput(JButton key);
~ActionLayer(); ActionLayer();
int cancelCurrentAction(); ~ActionLayer();
ActionElement * isWaitingForAnswer(); int cancelCurrentAction();
int isReactingToTargetClick(Targetable * card); ActionElement * isWaitingForAnswer();
int receiveEventPlus(WEvent * event); int isReactingToTargetClick(Targetable * card);
int reactToTargetClick(Targetable * card); int receiveEventPlus(WEvent * event);
int isReactingToClick(MTGCardInstance * card); int reactToTargetClick(Targetable * card);
int reactToClick(MTGCardInstance * card); int isReactingToClick(MTGCardInstance * card);
int reactToClick(ActionElement * ability,MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
int reactToTargetClick(ActionElement * ability,Targetable * card); int reactToClick(ActionElement * ability, MTGCardInstance * card);
int stillInUse(MTGCardInstance * card); int reactToTargetClick(ActionElement * ability, Targetable * card);
void setMenuObject(Targetable * object, bool must = false); int stillInUse(MTGCardInstance * card);
void ButtonPressed(int controllerid, int controlid); void setMenuObject(Targetable * object, bool must = false);
void doReactTo(int menuIndex); void ButtonPressed(int controllerid, int controlid);
TargetChooser * getCurrentTargetChooser(); void doReactTo(int menuIndex);
void setCurrentWaitingAction(ActionElement * ae); TargetChooser * getCurrentTargetChooser();
MTGAbility * getAbility(int type); void setCurrentWaitingAction(ActionElement * ae);
int moveToGarbage(ActionElement * e); MTGAbility * getAbility(int type);
int cleanGarbage(); int moveToGarbage(ActionElement * e);
int cleanGarbage();
protected: protected:
ActionElement * currentWaitingAction; ActionElement * currentWaitingAction;
int cantCancel; int cantCancel;
}; };
#endif #endif

View File

@@ -9,7 +9,6 @@
#define MAX_SPELL_TARGETS 10 #define MAX_SPELL_TARGETS 10
#define ACTION_SPELL 10 #define ACTION_SPELL 10
#define ACTION_DAMAGE 11 #define ACTION_DAMAGE 11
#define ACTION_DAMAGES 12 #define ACTION_DAMAGES 12
@@ -39,161 +38,197 @@ class DamageStack;
class ManaCost; class ManaCost;
class TargetChooser; class TargetChooser;
#define ACTIONSTACK_STANDARD 0 #define ACTIONSTACK_STANDARD 0
#define ACTIONSTACK_TARGET 1 #define ACTIONSTACK_TARGET 1
class Interruptible: public PlayGuiObject, public Targetable{ class Interruptible: public PlayGuiObject, public Targetable
public: {
//TODO : remove these when they are back in PlayGuiObject public:
float x, y; //TODO : remove these when they are back in PlayGuiObject
float x, y;
int state, display; int state, display;
MTGCardInstance * source; MTGCardInstance * source;
virtual void Entering(){mHasFocus = true;}; virtual void Entering()
virtual bool Leaving(JButton key){mHasFocus = false;return true;}; {
virtual bool ButtonPressed(){return true;}; mHasFocus = true;
virtual int resolve(){return 0;}; }
virtual void Render(){}; ;
int typeAsTarget(){return TARGET_STACKACTION;}; virtual bool Leaving(JButton key)
Interruptible(bool hasFocus = false):PlayGuiObject(40,x,y,hasFocus){state=NOT_RESOLVED;display=0;source=NULL;}; {
virtual const string getDisplayName() const; mHasFocus = false;
void Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action, bool bigQuad = false); return true;
virtual int receiveEvent(WEvent * event) {return 0;}; }
;
virtual bool ButtonPressed()
{
return true;
}
;
virtual int resolve()
{
return 0;
}
;
virtual void Render()
{
}
;
int typeAsTarget()
{
return TARGET_STACKACTION;
}
;
Interruptible(bool hasFocus = false) :
PlayGuiObject(40, x, y, hasFocus)
{
state = NOT_RESOLVED;
display = 0;
source = NULL;
}
;
virtual const string getDisplayName() const;
void Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action, bool bigQuad = false);
virtual int receiveEvent(WEvent * event)
{
return 0;
}
;
#if defined (WIN32) || defined (LINUX) || defined (IOS) #if defined (WIN32) || defined (LINUX) || defined (IOS)
virtual void Dump(); virtual void Dump();
#endif #endif
protected: protected:
float GetVerticalTextOffset() const; float GetVerticalTextOffset() const;
}; };
class NextGamePhase: public Interruptible { class NextGamePhase: public Interruptible
public: {
int resolve(); public:
bool extraDamagePhase(); int resolve();
void Render(); bool extraDamagePhase();
virtual ostream& toString(ostream& out) const; void Render();
virtual const string getDisplayName() const; virtual ostream& toString(ostream& out) const;
NextGamePhase(int id); virtual const string getDisplayName() const;
NextGamePhase(int id);
}; };
class Spell: public Interruptible { class Spell: public Interruptible
protected: {
protected:
public: public:
MTGGameZone * from; MTGGameZone * from;
TargetChooser * tc; TargetChooser * tc;
ManaCost * cost; ManaCost * cost;
int payResult; int payResult;
int computeX(MTGCardInstance * card); int computeX(MTGCardInstance * card);
int computeXX(MTGCardInstance * card); int computeXX(MTGCardInstance * card);
Spell(MTGCardInstance* _source); Spell(MTGCardInstance* _source);
Spell(int id, MTGCardInstance* _source, TargetChooser *_tc, ManaCost * _cost, int payResult); Spell(int id, MTGCardInstance* _source, TargetChooser *_tc, ManaCost * _cost, int payResult);
~Spell(); ~Spell();
int resolve(); int resolve();
void Render(); void Render();
bool FullfilledAlternateCost(const int &costType); bool FullfilledAlternateCost(const int &costType);
const string getDisplayName() const; const string getDisplayName() const;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
MTGCardInstance * getNextCardTarget(MTGCardInstance * previous = 0); MTGCardInstance * getNextCardTarget(MTGCardInstance * previous = 0);
Player * getNextPlayerTarget(Player * previous = 0); Player * getNextPlayerTarget(Player * previous = 0);
Damageable * getNextDamageableTarget(Damageable * previous = 0); Damageable * getNextDamageableTarget(Damageable * previous = 0);
Interruptible * getNextInterruptible(Interruptible * previous, int type); Interruptible * getNextInterruptible(Interruptible * previous, int type);
Spell * getNextSpellTarget(Spell * previous = 0); Spell * getNextSpellTarget(Spell * previous = 0);
Damage * getNextDamageTarget(Damage * previous = 0); Damage * getNextDamageTarget(Damage * previous = 0);
Targetable * getNextTarget(Targetable * previous = 0, int type = -1); Targetable * getNextTarget(Targetable * previous = 0, int type = -1);
int getNbTargets(); int getNbTargets();
}; };
class StackAbility: public Interruptible { class StackAbility: public Interruptible
public: {
MTGAbility * ability; public:
int resolve(); MTGAbility * ability;
void Render(); int resolve();
virtual ostream& toString(ostream& out) const; void Render();
virtual const string getDisplayName() const; virtual ostream& toString(ostream& out) const;
StackAbility(int id, MTGAbility * _ability); virtual const string getDisplayName() const;
StackAbility(int id, MTGAbility * _ability);
}; };
class PutInGraveyard: public Interruptible { class PutInGraveyard: public Interruptible
public: {
MTGCardInstance * card; public:
int removeFromGame; MTGCardInstance * card;
int resolve(); int removeFromGame;
void Render(); int resolve();
virtual ostream& toString(ostream& out) const; void Render();
PutInGraveyard(int id, MTGCardInstance * _card); virtual ostream& toString(ostream& out) const;
PutInGraveyard(int id, MTGCardInstance * _card);
}; };
class DrawAction: public Interruptible
class DrawAction: public Interruptible { {
public: public:
int nbcards; int nbcards;
Player * player; Player * player;
int resolve(); int resolve();
void Render(); void Render();
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
DrawAction(int id, Player * _player, int _nbcards); DrawAction(int id, Player * _player, int _nbcards);
}; };
class ActionStack :public GuiLayer{ class ActionStack: public GuiLayer
protected: {
JQuad * pspIcons[8]; protected:
GameObserver* game; JQuad * pspIcons[8];
int interruptDecision[2]; GameObserver* game;
float timer; int interruptDecision[2];
int currentState; float timer;
int mode; int currentState;
int checked; int mode;
int checked;
public: public:
enum enum
{ {
NOT_DECIDED = 0, NOT_DECIDED = 0,
INTERRUPT = -1, INTERRUPT = -1,
DONT_INTERRUPT = 1, DONT_INTERRUPT = 1,
DONT_INTERRUPT_ALL = 2, DONT_INTERRUPT_ALL = 2,
}; };
int setIsInterrupting(Player * player); int setIsInterrupting(Player * player);
int count( int type = 0 , int state = 0 , int display = -1); int count(int type = 0, int state = 0, int display = -1);
Interruptible * getPrevious(Interruptible * next, int type = 0, int state = 0 , int display = -1); Interruptible * getPrevious(Interruptible * next, int type = 0, int state = 0, int display = -1);
int getPreviousIndex(Interruptible * next, int type = 0, int state = 0 , int display = -1); int getPreviousIndex(Interruptible * next, int type = 0, int state = 0, int display = -1);
Interruptible * getNext(Interruptible * previous, int type = 0, int state = 0 , int display = -1); Interruptible * getNext(Interruptible * previous, int type = 0, int state = 0, int display = -1);
int getNextIndex(Interruptible * previous, int type = 0, int state = 0 , int display = -1); int getNextIndex(Interruptible * previous, int type = 0, int state = 0, int display = -1);
void Fizzle(Interruptible * action); void Fizzle(Interruptible * action);
Interruptible * getAt(int id); Interruptible * getAt(int id);
void cancelInterruptOffer(int cancelMode = 1); void cancelInterruptOffer(int cancelMode = 1);
void endOfInterruption(); void endOfInterruption();
Interruptible * getLatest(int state); Interruptible * getLatest(int state);
Player * askIfWishesToInterrupt; Player * askIfWishesToInterrupt;
int garbageCollect(); int garbageCollect();
int addAction(Interruptible * interruptible); int addAction(Interruptible * interruptible);
Spell * addSpell(MTGCardInstance* card, TargetChooser * tc, ManaCost * mana, int payResult, int storm); Spell * addSpell(MTGCardInstance* card, TargetChooser * tc, ManaCost * mana, int payResult, int storm);
int AddNextGamePhase(); int AddNextGamePhase();
int AddNextCombatStep(); int AddNextCombatStep();
int addPutInGraveyard(MTGCardInstance * card); int addPutInGraveyard(MTGCardInstance * card);
int addDraw(Player * player, int nbcards = 1); int addDraw(Player * player, int nbcards = 1);
int addDamage(MTGCardInstance * _source, Damageable * target, int _damage); int addDamage(MTGCardInstance * _source, Damageable * target, int _damage);
int addAbility(MTGAbility * ability); int addAbility(MTGAbility * ability);
void Update(float dt); void Update(float dt);
bool CheckUserInput(JButton key); bool CheckUserInput(JButton key);
virtual void Render(); virtual void Render();
ActionStack(GameObserver* game); ActionStack(GameObserver* game);
int resolve(); int resolve();
int has(Interruptible * action); int has(Interruptible * action);
int has(MTGAbility * ability); int has(MTGAbility * ability);
int receiveEventPlus(WEvent * event); int receiveEventPlus(WEvent * event);
#if defined (WIN32) || defined (LINUX) || defined (IOS) #if defined (WIN32) || defined (LINUX) || defined (IOS)
void Dump(); void Dump();
#endif #endif
}; };
#endif #endif

View File

@@ -3177,7 +3177,7 @@ public:
{ {
for (int i = 0; i < nbOpponents; i++) for (int i = 0; i < nbOpponents; i++)
{ {
if (game->isInPlay(opponents[i])) if (game->isInPlay(opponents[i]))
opponents[i]->destroy(); opponents[i]->destroy();
} }
} }
@@ -3225,14 +3225,14 @@ public:
_target->controller()->game->putInZone(_target, _target->controller()->game->hand, _target->controller()->game->hand); _target->controller()->game->putInZone(_target, _target->controller()->game->hand, _target->controller()->game->hand);
return MTGAbility::addToGame(); return MTGAbility::addToGame();
} }
AResetCost * clone() const AResetCost * clone() const
{ {
AResetCost * a = NEW AResetCost(*this); AResetCost * a = NEW AResetCost(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
~AResetCost() ~AResetCost()
{ {
} }
@@ -3246,7 +3246,7 @@ public:
MTGAbility(id, source, target), amount(amount) MTGAbility(id, source, target), amount(amount)
{ {
} }
int addToGame() int addToGame()
{ {
MTGCardInstance * _target = (MTGCardInstance *) target; MTGCardInstance * _target = (MTGCardInstance *) target;
@@ -3260,14 +3260,14 @@ public:
} }
return MTGAbility::addToGame(); return MTGAbility::addToGame();
} }
ABloodThirst * clone() const ABloodThirst * clone() const
{ {
ABloodThirst * a = NEW ABloodThirst(*this); ABloodThirst * a = NEW ABloodThirst(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
~ABloodThirst() ~ABloodThirst()
{ {
} }

View File

@@ -1,6 +1,6 @@
/* /*
A Filter/Mask system for Card Instances to find cards matching specific settings such as color, type, etc... A Filter/Mask system for Card Instances to find cards matching specific settings such as color, type, etc...
*/ */
#ifndef _CARDDESCRIPTOR_H_ #ifndef _CARDDESCRIPTOR_H_
#define _CARDDESCRIPTOR_H_ #define _CARDDESCRIPTOR_H_
@@ -13,41 +13,42 @@
#define CD_AND 2 #define CD_AND 2
enum ENUM_COMPARISON_MODES enum ENUM_COMPARISON_MODES
{ {
COMPARISON_NONE = 0, // Needs to remain 0 for quick if(comparison_mode) checks COMPARISON_NONE = 0, // Needs to remain 0 for quick if(comparison_mode) checks
COMPARISON_AT_MOST, COMPARISON_AT_MOST,
COMPARISON_AT_LEAST, COMPARISON_AT_LEAST,
COMPARISON_EQUAL, COMPARISON_EQUAL,
COMPARISON_GREATER, COMPARISON_GREATER,
COMPARISON_LESS, COMPARISON_LESS,
COMPARISON_UNEQUAL COMPARISON_UNEQUAL
}; };
class CardDescriptor: public MTGCardInstance{ class CardDescriptor: public MTGCardInstance
protected: {
MTGCardInstance * match_or(MTGCardInstance * card); protected:
MTGCardInstance * match_and(MTGCardInstance * card); MTGCardInstance * match_or(MTGCardInstance * card);
bool valueInRange(int comparisonMode, int value, int criterion); MTGCardInstance * match_and(MTGCardInstance * card);
public: bool valueInRange(int comparisonMode, int value, int criterion);
int mode; public:
int powerComparisonMode; int mode;
int toughnessComparisonMode; int powerComparisonMode;
int manacostComparisonMode; int toughnessComparisonMode;
int counterComparisonMode; int manacostComparisonMode;
int convertedManacost; // might fit better into MTGCardInstance? int counterComparisonMode;
int anyCounter; int convertedManacost; // might fit better into MTGCardInstance?
int init(); int anyCounter;
CardDescriptor(); int init();
void unsecureSetTapped(int i); CardDescriptor();
void unsecuresetfresh(int k); void unsecureSetTapped(int i);
void setNegativeSubtype( string value); void unsecuresetfresh(int k);
int counterPower; void setNegativeSubtype(string value);
int counterToughness; int counterPower;
int counterNB; int counterToughness;
string counterName; int counterNB;
MTGCardInstance * match(MTGCardInstance * card); string counterName;
MTGCardInstance * match(MTGGameZone * zone); MTGCardInstance * match(MTGCardInstance * card);
MTGCardInstance * nextmatch(MTGGameZone * zone, MTGCardInstance * previous); MTGCardInstance * match(MTGGameZone * zone);
MTGCardInstance * nextmatch(MTGGameZone * zone, MTGCardInstance * previous);
}; };
#endif #endif

View File

@@ -7,28 +7,29 @@ class TargetChooser;
class MTGGameZone; class MTGGameZone;
class MTGCardInstance; class MTGCardInstance;
class CardDisplay:public PlayGuiObjectController{ class CardDisplay: public PlayGuiObjectController
int mId; {
GameObserver* game; int mId;
public: GameObserver* game;
int x, y , start_item, nb_displayed_items; public:
MTGGameZone * zone; int x, y, start_item, nb_displayed_items;
TargetChooser * tc; MTGGameZone * zone;
JGuiListener * listener; TargetChooser * tc;
CardDisplay(); JGuiListener * listener;
CardDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener = NULL, TargetChooser * tc = NULL, int nb_displayed_items = 7); CardDisplay();
void AddCard(MTGCardInstance * _card); CardDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener = NULL, TargetChooser * tc = NULL,
void rotateLeft(); int nb_displayed_items = 7);
void rotateRight(); void AddCard(MTGCardInstance * _card);
bool CheckUserInput(JButton key); void rotateLeft();
bool CheckUserInput(int x, int y); void rotateRight();
virtual void Update(float dt); bool CheckUserInput(JButton key);
void Render(); bool CheckUserInput(int x, int y);
void init(MTGGameZone * zone); virtual void Update(float dt);
virtual ostream& toString(ostream& out) const; void Render();
void init(MTGGameZone * zone);
virtual ostream& toString(ostream& out) const;
}; };
std::ostream& operator<<(std::ostream& out, const CardDisplay& m); std::ostream& operator<<(std::ostream& out, const CardDisplay& m);
#endif #endif

View File

@@ -6,17 +6,16 @@
struct CardGui; struct CardGui;
class CardEffect : public Effect class CardEffect: public Effect
{ {
public: public:
CardEffect(CardGui* target); CardEffect(CardGui* target);
~CardEffect(); ~CardEffect();
private: private:
CardGui* target; CardGui* target;
public: public:
virtual void Render(); virtual void Render();
}; };
#endif // _CARDEFFECT_H_ #endif // _CARDEFFECT_H_

View File

@@ -14,73 +14,84 @@ class PlayGuiObject;
namespace DrawMode namespace DrawMode
{ {
enum enum
{ {
kNormal = 0, kNormal,
kText, kText,
kHidden kHidden
}; };
const int kNumDrawModes = 3; const int kNumDrawModes = 3;
} }
struct CardGui : public PlayGuiObject { struct CardGui: public PlayGuiObject
protected: {
protected:
/* /*
** Tries to render the Big version of a card picture, backups to text version in case of failure ** Tries to render the Big version of a card picture, backups to text version in case of failure
*/ */
static void RenderBig(MTGCard * card, const Pos& pos); static void RenderBig(MTGCard * card, const Pos& pos);
void RenderCountersBig(const Pos& pos);
static void AlternateRender(MTGCard * card, const Pos& pos);
static void TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad);
public: void RenderCountersBig(const Pos& pos);
static const float Width; static void AlternateRender(MTGCard * card, const Pos& pos);
static const float Height; static void TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad);
static const float BigWidth;
static const float BigHeight;
MTGCardInstance* card; public:
CardGui(MTGCardInstance* card, float x, float y); static const float Width;
CardGui(MTGCardInstance* card, const Pos& ref); static const float Height;
virtual void Render(); static const float BigWidth;
virtual void Update(float dt); static const float BigHeight;
void DrawCard(const Pos& inPosition, int inMode = DrawMode::kNormal); MTGCardInstance* card;
static void DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode = DrawMode::kNormal); CardGui(MTGCardInstance* card, float x, float y);
CardGui(MTGCardInstance* card, const Pos& ref);
virtual void Render();
virtual void Update(float dt);
static JQuad * AlternateThumbQuad(MTGCard * card); void DrawCard(const Pos& inPosition, int inMode = DrawMode::kNormal);
virtual ostream& toString(ostream&) const; static void DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode = DrawMode::kNormal);
static JQuad * AlternateThumbQuad(MTGCard * card);
virtual ostream& toString(ostream&) const;
}; };
class CardView: public CardGui
{
public:
class CardView : public CardGui { typedef enum
public: {
nullZone, handZone, playZone
} SelectorZone;
typedef enum { const SelectorZone owner;
nullZone, handZone, playZone
} SelectorZone;
const SelectorZone owner; MTGCardInstance* getCard(); // remove this when possible
CardView(const SelectorZone, MTGCardInstance* card, float x, float y);
CardView(const SelectorZone, MTGCardInstance* card, const Pos& ref);
virtual ~CardView();
MTGCardInstance* getCard(); // remove this when possible void Render()
CardView(const SelectorZone, MTGCardInstance* card, float x, float y); {
CardView(const SelectorZone, MTGCardInstance* card, const Pos& ref); CardGui::Render();
virtual ~CardView(); }
;
void Render(JQuad* q)
{
Pos::Render(q);
}
;
virtual ostream& toString(ostream&) const;
void Render(){CardGui::Render();}; float GetCenterX();
void Render(JQuad* q){Pos::Render(q);}; float GetCenterY();
virtual ostream& toString(ostream&) const;
float GetCenterX();
float GetCenterY();
}; };
class TransientCardView : public CardGui { class TransientCardView: public CardGui
public: {
TransientCardView(MTGCardInstance* card, float x, float y); public:
TransientCardView(MTGCardInstance* card, const Pos& ref); TransientCardView(MTGCardInstance* card, float x, float y);
TransientCardView(MTGCardInstance* card, const Pos& ref);
}; };
#endif #endif

View File

@@ -1,7 +1,6 @@
#ifndef _CARDPRIMITIVE_H_ #ifndef _CARDPRIMITIVE_H_
#define _CARDPRIMITIVE_H_ #define _CARDPRIMITIVE_H_
#include <string> #include <string>
#include <vector> #include <vector>
#include <map> #include <map>
@@ -10,72 +9,72 @@
using namespace std; using namespace std;
class CardPrimitive { class CardPrimitive
protected: {
vector<string> ftdText; protected:
string lcname; vector<string> ftdText;
ManaCost manaCost; string lcname;
ManaCost manaCost;
public: public:
string text; string text;
string name; string name;
int init(); int init();
int colors[Constants::MTG_NB_COLORS]; int colors[Constants::MTG_NB_COLORS];
map<int,int> basicAbilities; map<int, int> basicAbilities;
map<string,string> magicTexts; map<string, string> magicTexts;
string magicText; string magicText;
int alias; int alias;
string spellTargetType; string spellTargetType;
int power; int power;
int toughness; int toughness;
vector<int>types; vector<int> types;
CardPrimitive(); CardPrimitive();
CardPrimitive(CardPrimitive * source); CardPrimitive(CardPrimitive * source);
void setColor(int _color, int removeAllOthers = 0); void setColor(int _color, int removeAllOthers = 0);
void setColor(string _color, int removeAllOthers = 0); void setColor(string _color, int removeAllOthers = 0);
void removeColor(int color); void removeColor(int color);
int getColor(); int getColor();
int hasColor(int _color); int hasColor(int _color);
int countColors(); int countColors();
int has(int ability); int has(int ability);
void setText(const string& value); void setText(const string& value);
const char * getText(); const char * getText();
void addMagicText(string value); void addMagicText(string value);
void addMagicText(string value, string zone); void addMagicText(string value, string zone);
void setName(const string& value); void setName(const string& value);
const string& getName() const; const string& getName() const;
const string& getLCName() const; const string& getLCName() const;
void addType(char * type_text); void addType(char * type_text);
void addType(int id); void addType(int id);
void setType(const string& type_text); void setType(const string& type_text);
void setSubtype(const string& value); void setSubtype(const string& value);
int removeType(string value, int removeAll = 0); int removeType(string value, int removeAll = 0);
int removeType(int value, int removeAll = 0); int removeType(int value, int removeAll = 0);
bool hasSubtype(int _subtype); bool hasSubtype(int _subtype);
bool hasSubtype(const char * _subtype); bool hasSubtype(const char * _subtype);
bool hasSubtype(string _subtype); bool hasSubtype(string _subtype);
bool hasType(int _type); bool hasType(int _type);
bool hasType(const char * type); bool hasType(const char * type);
void setManaCost(string value); void setManaCost(string value);
ManaCost * getManaCost(); ManaCost * getManaCost();
bool isCreature(); bool isCreature();
bool isLand(); bool isLand();
bool isSpell(); bool isSpell();
void setPower(int _power); void setPower(int _power);
int getPower(); int getPower();
void setToughness(int _toughness); void setToughness(int _toughness);
int getToughness(); int getToughness();
const vector<string>& formattedText(); const vector<string>& formattedText();
}; };
#endif #endif

View File

@@ -12,84 +12,87 @@ using std::vector;
class PlayGuiObject; class PlayGuiObject;
class DuelLayers; class DuelLayers;
template <typename T> template<typename T>
struct LimitorFunctor struct LimitorFunctor
{ {
virtual bool select(T*) = 0; virtual bool select(T*) = 0;
virtual bool greyout(T*) = 0; virtual bool greyout(T*) = 0;
typedef T Target; typedef T Target;
}; };
class CardSelectorBase : public GuiLayer class CardSelectorBase: public GuiLayer
{ {
public: public:
CardSelectorBase(int inDrawMode = DrawMode::kNormal) : mDrawMode(inDrawMode) {}; CardSelectorBase(int inDrawMode = DrawMode::kNormal) :
virtual void Add(PlayGuiObject*) = 0; mDrawMode(inDrawMode)
virtual void Remove(PlayGuiObject*) = 0; {
virtual bool CheckUserInput(JButton key) = 0; }
virtual bool CheckUserInput(int x, int y) = 0; ;
virtual void PushLimitor() = 0; virtual void Add(PlayGuiObject*) = 0;
virtual void PopLimitor() = 0; virtual void Remove(PlayGuiObject*) = 0;
virtual void Limit(LimitorFunctor<PlayGuiObject>* inLimitor, CardView::SelectorZone inZone) = 0; virtual bool CheckUserInput(JButton key) = 0;
virtual void Push() = 0; virtual bool CheckUserInput(int x, int y) = 0;
virtual void Pop() = 0; virtual void PushLimitor() = 0;
virtual int GetDrawMode() virtual void PopLimitor() = 0;
{ virtual void Limit(LimitorFunctor<PlayGuiObject>* inLimitor, CardView::SelectorZone inZone) = 0;
return mDrawMode; virtual void Push() = 0;
} virtual void Pop() = 0;
virtual int GetDrawMode()
{
return mDrawMode;
}
protected: protected:
int mDrawMode; int mDrawMode;
}; };
class CardSelector: public CardSelectorBase
class CardSelector : public CardSelectorBase
{ {
public: public:
struct SelectorMemory struct SelectorMemory
{ {
PlayGuiObject* object; PlayGuiObject* object;
float x, y; float x, y;
SelectorMemory(PlayGuiObject* object); SelectorMemory(PlayGuiObject* object);
SelectorMemory(); SelectorMemory();
}; };
protected: protected:
vector<PlayGuiObject*> cards; vector<PlayGuiObject*> cards;
PlayGuiObject* active; PlayGuiObject* active;
DuelLayers* duel; DuelLayers* duel;
LimitorFunctor<PlayGuiObject>* limitor; LimitorFunctor<PlayGuiObject>* limitor;
Pos bigpos; Pos bigpos;
map<const CardView::SelectorZone, SelectorMemory> lasts; map<const CardView::SelectorZone, SelectorMemory> lasts;
stack< pair<LimitorFunctor<PlayGuiObject>*, CardView::SelectorZone> > limitorStack; stack<pair<LimitorFunctor<PlayGuiObject>*, CardView::SelectorZone> > limitorStack;
stack<SelectorMemory> memoryStack; stack<SelectorMemory> memoryStack;
PlayGuiObject* fetchMemory(SelectorMemory&); PlayGuiObject* fetchMemory(SelectorMemory&);
public: public:
CardSelector(DuelLayers*); CardSelector(DuelLayers*);
void Add(PlayGuiObject*); void Add(PlayGuiObject*);
void Remove(PlayGuiObject*); void Remove(PlayGuiObject*);
bool CheckUserInput(JButton key); bool CheckUserInput(JButton key);
bool CheckUserInput(int x, int y); bool CheckUserInput(int x, int y);
void Update(float dt); void Update(float dt);
void Render(); void Render();
void Push(); void Push();
void Pop(); void Pop();
void Limit(LimitorFunctor<PlayGuiObject>* limitor, CardView::SelectorZone); void Limit(LimitorFunctor<PlayGuiObject>* limitor, CardView::SelectorZone);
void PushLimitor(); void PushLimitor();
void PopLimitor(); void PopLimitor();
typedef PlayGuiObject Target; typedef PlayGuiObject Target;
}; };
typedef LimitorFunctor<CardSelector::Target> Limitor; typedef LimitorFunctor<CardSelector::Target> Limitor;
struct Exp struct Exp
{ {
static inline bool test(CardSelector::Target*, CardSelector::Target*); static inline bool test(CardSelector::Target*, CardSelector::Target*);
}; };
#endif #endif

View File

@@ -7,24 +7,23 @@ class DuelLayers;
namespace CardSelectorSingleton namespace CardSelectorSingleton
{ {
/* /*
** CardSelector is essentially a singleton in its usage ** CardSelector is essentially a singleton in its usage
** It's not enforced, but it needs to eventually migrate to the real thing ** It's not enforced, but it needs to eventually migrate to the real thing
** For now, this function will fake it out - it's up to the client caller to make sure ** For now, this function will fake it out - it's up to the client caller to make sure
** that this gets destroyed via a Terminate call (this is currently handled in DualLayers's destructor) ** that this gets destroyed via a Terminate call (this is currently handled in DualLayers's destructor)
*/ */
CardSelectorBase* Instance(); CardSelectorBase* Instance();
/* /*
** Create the singleton pointer. Instance() isn't valid until this is called. ** Create the singleton pointer. Instance() isn't valid until this is called.
*/ */
CardSelectorBase* Create(DuelLayers* inDuelLayers); CardSelectorBase* Create(DuelLayers* inDuelLayers);
/* /*
** Teardown the singleton pointer instance. ** Teardown the singleton pointer instance.
*/ */
void Terminate(); void Terminate();
} }
#endif //CARDSELECTORSINGLETON_H #endif //CARDSELECTORSINGLETON_H

View File

@@ -2,43 +2,43 @@
#define _COUNTERS_H_ #define _COUNTERS_H_
#include <string> #include <string>
using std::string; using std::string;
class MTGCardInstance; class MTGCardInstance;
/* One family of counters. Ex : +1/+1 */ /* One family of counters. Ex : +1/+1 */
class Counter{ class Counter
public : {
string name; public:
int nb; string name;
int power, toughness; int nb;
MTGCardInstance * target; int power, toughness;
Counter(MTGCardInstance * _target, int _power, int _toughness); MTGCardInstance * target;
Counter(MTGCardInstance * _target, const char * _name,int _power = 0 , int _toughness = 0 ); Counter(MTGCardInstance * _target, int _power, int _toughness);
int init(MTGCardInstance * _target,const char * _name, int _power, int _toughness); Counter(MTGCardInstance * _target, const char * _name, int _power = 0, int _toughness = 0);
bool sameAs(const char * _name, int _power, int _toughness); int init(MTGCardInstance * _target, const char * _name, int _power, int _toughness);
bool cancels(int _power, int _toughness); bool sameAs(const char * _name, int _power, int _toughness);
int added(); bool cancels(int _power, int _toughness);
int removed(); int added();
int removed();
}; };
/* Various families of counters attached to an instance of a card */ /* Various families of counters attached to an instance of a card */
class Counters{ class Counters
public: {
int mCount; public:
Counter * counters[10]; int mCount;
MTGCardInstance * target; Counter * counters[10];
Counters(MTGCardInstance * _target); MTGCardInstance * target;
~Counters(); Counters(MTGCardInstance * _target);
int addCounter(const char * _name,int _power = 0, int _toughness = 0); ~Counters();
int addCounter(int _power, int _toughness); int addCounter(const char * _name, int _power = 0, int _toughness = 0);
int removeCounter(const char * _name,int _power = 0, int _toughness = 0); int addCounter(int _power, int _toughness);
int removeCounter(int _power, int _toughness); int removeCounter(const char * _name, int _power = 0, int _toughness = 0);
Counter * hasCounter(const char * _name,int _power = 0, int _toughness = 0); int removeCounter(int _power, int _toughness);
Counter * hasCounter(int _power, int _toughness); Counter * hasCounter(const char * _name, int _power = 0, int _toughness = 0);
Counter * getNext(Counter * previous = NULL); Counter * hasCounter(int _power, int _toughness);
int init(); Counter * getNext(Counter * previous = NULL);
int init();
}; };
#endif #endif

View File

@@ -1,7 +1,6 @@
#ifndef _CREDITS_H_ #ifndef _CREDITS_H_
#define _CREDITS_H_ #define _CREDITS_H_
#include <vector> #include <vector>
#include <string> #include <string>
#include <JGE.h> #include <JGE.h>
@@ -13,42 +12,43 @@ class GameApp;
using namespace std; using namespace std;
class CreditBonus
class CreditBonus{ {
public: public:
int value; int value;
string text; string text;
CreditBonus(int _value, string _text); CreditBonus(int _value, string _text);
void Render(float x, float y, WFont * font); void Render(float x, float y, WFont * font);
}; };
class Credits{ class Credits
{
private: private:
time_t gameLength; time_t gameLength;
int isDifficultyUnlocked(DeckStats * stats); int isDifficultyUnlocked(DeckStats * stats);
int isMomirUnlocked(); int isMomirUnlocked();
int isEvilTwinUnlocked(); int isEvilTwinUnlocked();
int isRandomDeckUnlocked(); int isRandomDeckUnlocked();
int IsMoreAIDecksUnlocked(DeckStats * stats); int IsMoreAIDecksUnlocked(DeckStats * stats);
string unlockedTextureName; string unlockedTextureName;
JQuad * GetUnlockedQuad(string texturename); JQuad * GetUnlockedQuad(string texturename);
public: public:
int value; int value;
Player * p1, *p2; Player * p1, *p2;
GameApp * app; GameApp * app;
int showMsg; int showMsg;
int unlocked; int unlocked;
string unlockedString; string unlockedString;
vector<CreditBonus *> bonus; vector<CreditBonus *> bonus;
Credits(); Credits();
~Credits(); ~Credits();
void compute(Player * _p1, Player * _p2, GameApp * _app); void compute(Player * _p1, Player * _p2, GameApp * _app);
void Render(); void Render();
static int unlockRandomSet(bool force = false); static int unlockRandomSet(bool force = false);
static int unlockSetByName(string name); static int unlockSetByName(string name);
static int addCreditBonus(int value); static int addCreditBonus(int value);
static int addCardToCollection(int cardId, MTGDeck * collection); static int addCardToCollection(int cardId, MTGDeck * collection);
static int addCardToCollection(int cardId); static int addCardToCollection(int cardId);
}; };
#endif #endif

View File

@@ -17,49 +17,77 @@ class GameObserver;
#define DAMAGE_COMBAT 1 #define DAMAGE_COMBAT 1
#define DAMAGE_OTHER 2 #define DAMAGE_OTHER 2
class Damageable:public Targetable { class Damageable: public Targetable
protected: {
public: protected:
int life; public:
int poisonCount; int life;
int damageCount; int poisonCount;
int preventable; int damageCount;
int type_as_damageable; int preventable;
Damageable(int _life){life=_life;}; int type_as_damageable;
int getLife(){return life;}; Damageable(int _life)
virtual int dealDamage(int damage){life-=damage;return life;}; {
virtual int afterDamage(){return 0;} life = _life;
virtual int poisoned(){return 0;} }
virtual int prevented(){return 0;} ;
virtual JQuad * getIcon(){return NULL;}; 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 JQuad * getIcon()
{
return NULL;
}
;
}; };
class Damage: public Interruptible { class Damage: public Interruptible
protected: {
void init(MTGCardInstance * source, Damageable * target, int damage, int typeOfDamage); protected:
public: void init(MTGCardInstance * source, Damageable * target, int damage, int typeOfDamage);
Damageable * target; public:
int typeOfDamage; Damageable * target;
int damage; int typeOfDamage;
void Render(); int damage;
Damage(MTGCardInstance* source, Damageable * target); void Render();
Damage(MTGCardInstance* source, Damageable * target, int damage, int typeOfDamage = DAMAGE_OTHER); Damage(MTGCardInstance* source, Damageable * target);
int resolve(); Damage(MTGCardInstance* source, Damageable * target, int damage, int typeOfDamage = DAMAGE_OTHER);
virtual ostream& toString(ostream& out) const; int resolve();
virtual ostream& toString(ostream& out) const;
}; };
class DamageStack: public GuiLayer, public Interruptible
{
protected:
int currentState;
GameObserver* game;
class DamageStack : public GuiLayer, public Interruptible{ public:
protected: int receiveEvent(WEvent * event);
int currentState; int resolve();
GameObserver* game; void Render();
virtual ostream& toString(ostream& out) const;
public: DamageStack();
int receiveEvent(WEvent * event);
int resolve();
void Render();
virtual ostream& toString(ostream& out) const;
DamageStack();
}; };
#endif #endif

View File

@@ -6,31 +6,33 @@
class Player; class Player;
struct DamagerDamaged : TransientCardView { struct DamagerDamaged: TransientCardView
bool show; {
Player * damageSelecter; bool show;
vector<Damage> damages; Player * damageSelecter;
int damageToDeal; vector<Damage> damages;
int damageToDeal;
void addDamage(int damage, DamagerDamaged* source); void addDamage(int damage, DamagerDamaged* source);
int removeDamagesTo(DamagerDamaged* target); int removeDamagesTo(DamagerDamaged* target);
int removeDamagesFrom(DamagerDamaged* source); int removeDamagesFrom(DamagerDamaged* source);
void clearDamage(); void clearDamage();
int sumDamages(); int sumDamages();
bool hasLethalDamage(); bool hasLethalDamage();
DamagerDamaged(MTGCardInstance* card, float x, float y, bool show, Player* damageSelecter); DamagerDamaged(MTGCardInstance* card, float x, float y, bool show, Player* damageSelecter);
DamagerDamaged(MTGCardInstance* card, const Pos& ref, bool show, Player* damageSelecter); DamagerDamaged(MTGCardInstance* card, const Pos& ref, bool show, Player* damageSelecter);
~DamagerDamaged(); ~DamagerDamaged();
void Render(CombatStep mode); void Render(CombatStep mode);
}; };
typedef DamagerDamaged DefenserDamaged; typedef DamagerDamaged DefenserDamaged;
struct AttackerDamaged : DamagerDamaged { struct AttackerDamaged: DamagerDamaged
vector<DefenserDamaged*> blockers; {
AttackerDamaged(MTGCardInstance* card, float x, float y, bool show, Player* damageSelecter); vector<DefenserDamaged*> blockers;
AttackerDamaged(MTGCardInstance* card, const Pos& ref, bool show, Player* damageSelecter); AttackerDamaged(MTGCardInstance* card, float x, float y, bool show, Player* damageSelecter);
~AttackerDamaged(); AttackerDamaged(MTGCardInstance* card, const Pos& ref, bool show, Player* damageSelecter);
~AttackerDamaged();
}; };
#endif #endif

View File

@@ -12,14 +12,25 @@ using std::string;
class MTGDeck; class MTGDeck;
class DeckDataWrapper: public WSrcDeck { class DeckDataWrapper: public WSrcDeck
public: {
MTGDeck * parent; public:
DeckDataWrapper(MTGDeck * deck); MTGDeck * parent;
bool next() {currentPos++; return true;}; DeckDataWrapper(MTGDeck * deck);
bool prev() {currentPos--; return true;}; bool next()
void save(); {
void save(string filepath, bool useExpandedCardNames, string &deckTitle, string &deckDesc); currentPos++;
return true;
}
;
bool prev()
{
currentPos--;
return true;
}
;
void save();
void save(string filepath, bool useExpandedCardNames, string &deckTitle, string &deckDesc);
}; };
#endif #endif

View File

@@ -3,20 +3,19 @@
#include "DeckDataWrapper.h" #include "DeckDataWrapper.h"
#include "DeckStats.h" #include "DeckStats.h"
class DeckEditorMenu : class DeckEditorMenu: public DeckMenu
public DeckMenu
{ {
protected: protected:
string deckTitle; string deckTitle;
private: private:
void drawDeckStatistics(); void drawDeckStatistics();
DeckDataWrapper *selectedDeck; DeckDataWrapper *selectedDeck;
StatsWrapper *stw; StatsWrapper *stw;
public: public:
DeckEditorMenu(int id, JGuiListener* listener = NULL, int fontId = 1, const char * _title = "", DeckDataWrapper *selectedDeck = NULL, StatsWrapper *stats = NULL); DeckEditorMenu(int id, JGuiListener* listener = NULL, int fontId = 1, const char * _title = "", DeckDataWrapper *selectedDeck = NULL, StatsWrapper *stats = NULL);
void Render(); void Render();
~DeckEditorMenu(); ~DeckEditorMenu();
}; };

View File

@@ -5,7 +5,6 @@
using namespace std; using namespace std;
class DeckManager class DeckManager
{ {
private: private:
@@ -17,24 +16,22 @@ private:
} }
public: public:
vector<DeckMetaData *> playerDeckOrderList; vector<DeckMetaData *> playerDeckOrderList;
vector<DeckMetaData *> aiDeckOrderList; vector<DeckMetaData *> aiDeckOrderList;
void updateMetaDataList(vector<DeckMetaData *>* refList, bool isAI ); void updateMetaDataList(vector<DeckMetaData *>* refList, bool isAI);
vector<DeckMetaData *> * getPlayerDeckOrderList(); vector<DeckMetaData *> * getPlayerDeckOrderList();
vector<DeckMetaData *> * getAIDeckOrderList(); vector<DeckMetaData *> * getAIDeckOrderList();
static DeckManager * GetInstance(); static DeckManager * GetInstance();
static void EndInstance(); static void EndInstance();
//convenience method to get the difficulty rating between two decks. This should be refined a little more //convenience method to get the difficulty rating between two decks. This should be refined a little more
//since the eventual move of all deck meta data should be managed by this class //since the eventual move of all deck meta data should be managed by this class
static int getDifficultyRating( Player *statsPlayer, Player *player ); static int getDifficultyRating(Player *statsPlayer, Player *player);
~DeckManager() ~DeckManager()
{ {
instanceFlag = false; instanceFlag = false;

View File

@@ -56,15 +56,20 @@ public:
JQuad * pspIcons[8]; JQuad * pspIcons[8];
JTexture * pspIconsTexture; JTexture * pspIconsTexture;
DeckMenu(int id, JGuiListener* listener, int fontId, const string _title = "", const int& startIndex = 0, bool alwaysShowDetailsButton = false); DeckMenu(int id, JGuiListener* listener, int fontId, const string _title = "", const int& startIndex = 0, bool alwaysShowDetailsButton = false);
~DeckMenu(); ~DeckMenu();
DeckMetaData * getSelectedDeck(); DeckMetaData * getSelectedDeck();
void enableDisplayDetailsOverride(); void enableDisplayDetailsOverride();
bool showDetailsScreen(); bool showDetailsScreen();
bool isClosed() { return mClosed; } bool isClosed()
int getSelectedDeckId() { return mSelectedDeckId; } {
return mClosed;
}
int getSelectedDeckId()
{
return mSelectedDeckId;
}
void Render(); void Render();
void Update(float dt); void Update(float dt);

View File

@@ -11,41 +11,53 @@ using std::string;
class DeckMenuItem: public JGuiObject class DeckMenuItem: public JGuiObject
{ {
private: private:
bool mHasFocus; bool mHasFocus;
bool mScrollEnabled; bool mScrollEnabled;
bool mDisplayInitialized; bool mDisplayInitialized;
DeckMenu* parent; DeckMenu* parent;
int fontId; int fontId;
string mText; string mText;
float mTitleResetWidth; float mTitleResetWidth;
public: public:
string imageFilename; string imageFilename;
string desc; string desc;
float mScrollerOffset; float mScrollerOffset;
DeckMetaData *meta; DeckMetaData *meta;
float mX; float mX;
float mY; float mY;
void Relocate(float x, float y); void Relocate(float x, float y);
float GetWidth(); float GetWidth();
string GetText() { return mText; } string GetText()
string GetDescription() { return desc; } {
bool hasFocus(); return mText;
}
string GetDescription()
{
return desc;
}
bool hasFocus();
DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus = false, bool autoTranslate = false, DeckMetaData *meta = NULL); DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus = false, bool autoTranslate = false, DeckMetaData *meta = NULL);
~DeckMenuItem(); ~DeckMenuItem();
void RenderWithOffset(float yOffset); void RenderWithOffset(float yOffset);
virtual void Render(); virtual void Render();
virtual void Update( float dt ); virtual void Update(float dt);
virtual void Entering(); virtual void Entering();
virtual bool Leaving(JButton key); virtual bool Leaving(JButton key);
virtual bool ButtonPressed(); virtual bool ButtonPressed();
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
virtual bool getTopLeft(float& top, float& left) {top = mY; left = mX; return true;}; virtual bool getTopLeft(float& top, float& left)
{
top = mY;
left = mX;
return true;
}
;
}; };
#endif #endif

View File

@@ -6,7 +6,6 @@
#include <map> #include <map>
#include "DeckStats.h" #include "DeckStats.h"
using namespace std; using namespace std;
enum DECK_DIFFICULTY enum DECK_DIFFICULTY
{ {
@@ -14,54 +13,55 @@ enum DECK_DIFFICULTY
NORMAL = 0, NORMAL = 0,
EASY = 1 EASY = 1
}; };
class DeckMetaData { class DeckMetaData
{
private: private:
string _filename; string _filename;
string _desc; string _desc;
string _name; string _name;
int _deckid; int _deckid;
string _avatarFilename; string _avatarFilename;
// statistical information // statistical information
int _nbGamesPlayed, _victories, _percentVictories, _difficulty; int _nbGamesPlayed, _victories, _percentVictories, _difficulty;
public: public:
DeckMetaData(); DeckMetaData();
DeckMetaData(string filename, Player * statsPlayer); DeckMetaData(string filename, Player * statsPlayer);
void load(string filename); void load(string filename);
void loadStatsForPlayer( Player * statsPlayer, string deckStatsFileName = "" ); void loadStatsForPlayer(Player * statsPlayer, string deckStatsFileName = "");
// Accessors
string getFilename();
string getDescription();
string getName();
string getAvatarFilename();
int getAvatarId(int deckId);
string getStatsSummary();
int getDeckId(); // Accessors
int getGamesPlayed(); string getFilename();
int getVictories(); string getDescription();
int getVictoryPercentage(); string getName();
int getDifficulty(); string getAvatarFilename();
string getDifficultyString(); int getAvatarId(int deckId);
string getStatsSummary();
int getDeckId();
int getGamesPlayed();
int getVictories();
int getVictoryPercentage();
int getDifficulty();
string getDifficultyString();
}; };
class DeckMetaDataList { class DeckMetaDataList
{
private: private:
map<string,DeckMetaData *>values; map<string, DeckMetaData *> values;
public: public:
void invalidate(string filename); void invalidate(string filename);
DeckMetaData * get(string filename, Player * statsPlayer = NULL); DeckMetaData * get(string filename, Player * statsPlayer = NULL);
~DeckMetaDataList(); ~DeckMetaDataList();
static DeckMetaDataList * decksMetaData; static DeckMetaDataList * decksMetaData;
}; };
#endif #endif

View File

@@ -45,9 +45,9 @@ public:
class StatsWrapper class StatsWrapper
{ {
private: private:
void initValues(); void initValues();
public: public:
StatsWrapper(int deckId); StatsWrapper(int deckId);
StatsWrapper(string filename); StatsWrapper(string filename);

View File

@@ -15,35 +15,36 @@ class GuiAvatars;
class CardSelectorBase; class CardSelectorBase;
struct Pos; struct Pos;
class DuelLayers { class DuelLayers
protected: {
int nbitems; protected:
vector<GuiLayer*> objects; int nbitems;
vector<Pos*> waiters; vector<GuiLayer*> objects;
GuiCombat* combat; vector<Pos*> waiters;
ActionLayer* action; GuiCombat* combat;
ActionStack* stack; ActionLayer* action;
GuiHandSelf *hand; ActionStack* stack;
GuiAvatars * avatars; GuiHandSelf *hand;
GuiAvatars * avatars;
public: public:
DuelLayers(); DuelLayers();
~DuelLayers(); ~DuelLayers();
ActionLayer * actionLayer(); ActionLayer * actionLayer();
ActionStack * stackLayer(); ActionStack * stackLayer();
GuiCombat * combatLayer(); GuiCombat * combatLayer();
GuiAvatars * GetAvatars(); GuiAvatars * GetAvatars();
void init(); void init();
virtual void Update(float dt, Player * player); virtual void Update(float dt, Player * player);
void CheckUserInput(int isAI); void CheckUserInput(int isAI);
void Render(); void Render();
void Add(GuiLayer * layer); void Add(GuiLayer * layer);
void Remove(); void Remove();
int receiveEvent(WEvent * e); int receiveEvent(WEvent * e);
float RightBoundary(); float RightBoundary();
CardSelectorBase* mCardSelector; CardSelectorBase* mCardSelector;
}; };
#include "ActionLayer.h" #include "ActionLayer.h"
@@ -52,5 +53,4 @@ public:
#include "ActionStack.h" #include "ActionStack.h"
#include "Damage.h" #include "Damage.h"
#endif #endif

View File

@@ -3,11 +3,11 @@
#include <JGui.h> #include <JGui.h>
class Effect : public JGuiObject class Effect: public JGuiObject
{ {
static int id_counter; static int id_counter;
public: public:
Effect() : JGuiObject(++id_counter) {}; Effect() : JGuiObject(++id_counter) {};
}; };
#endif // _EFFECTS_H_ #endif // _EFFECTS_H_

View File

@@ -9,143 +9,163 @@ class TargetChooser;
class MTGCardInstance; class MTGCardInstance;
class MTGAbility; class MTGAbility;
class ExtraCost{ class ExtraCost
{
public: public:
TargetChooser * tc; TargetChooser * tc;
MTGCardInstance * source; MTGCardInstance * source;
MTGCardInstance * target; MTGCardInstance * target;
std::string mCostRenderString; std::string mCostRenderString;
ExtraCost(const std::string& inCostRenderString, TargetChooser *_tc = NULL); ExtraCost(const std::string& inCostRenderString, TargetChooser *_tc = NULL);
virtual ~ExtraCost(); virtual ~ExtraCost();
virtual int setPayment(MTGCardInstance * card); virtual int setPayment(MTGCardInstance * card);
virtual int isPaymentSet() { return (target != NULL); } virtual int isPaymentSet()
virtual int canPay() { return 1; } {
virtual int doPay() = 0; return (target != NULL);
virtual void Render(); }
virtual int setSource(MTGCardInstance * _source); virtual int canPay()
virtual ExtraCost* clone() const = 0; {
return 1;
}
virtual int doPay() = 0;
virtual void Render();
virtual int setSource(MTGCardInstance * _source);
virtual ExtraCost* clone() const = 0;
}; };
class ExtraCosts{ class ExtraCosts
{
public: public:
vector<ExtraCost *>costs; vector<ExtraCost *> costs;
MTGCardInstance * source; MTGCardInstance * source;
MTGAbility * action; MTGAbility * action;
ExtraCosts(); ExtraCosts();
~ExtraCosts(); ~ExtraCosts();
void Render(); void Render();
int tryToSetPayment(MTGCardInstance * card); int tryToSetPayment(MTGCardInstance * card);
int isPaymentSet(); int isPaymentSet();
int canPay(); int canPay();
int doPay(); int doPay();
int reset(); int reset();
int setAction(MTGAbility * _action, MTGCardInstance * _source); int setAction(MTGAbility * _action, MTGCardInstance * _source);
void Dump(); void Dump();
ExtraCosts * clone() const; ExtraCosts * clone() const;
}; };
class SacrificeCost: public ExtraCost{ class SacrificeCost: public ExtraCost
{
public: public:
SacrificeCost(TargetChooser *_tc = NULL); SacrificeCost(TargetChooser *_tc = NULL);
virtual int doPay(); virtual int doPay();
virtual SacrificeCost * clone() const; virtual SacrificeCost * clone() const;
}; };
//life cost //life cost
class LifeCost: public ExtraCost{ class LifeCost: public ExtraCost
{
public: public:
LifeCost(TargetChooser *_tc = NULL); LifeCost(TargetChooser *_tc = NULL);
virtual int doPay(); virtual int doPay();
virtual LifeCost * clone() const; virtual LifeCost * clone() const;
}; };
//Discard a random card cost //Discard a random card cost
class DiscardRandomCost: public ExtraCost{ class DiscardRandomCost: public ExtraCost
{
public: public:
DiscardRandomCost(TargetChooser *_tc = NULL); DiscardRandomCost(TargetChooser *_tc = NULL);
virtual int canPay(); virtual int canPay();
virtual int doPay(); virtual int doPay();
virtual DiscardRandomCost * clone() const; virtual DiscardRandomCost * clone() const;
}; };
//a choosen discard //a choosen discard
class DiscardCost: public ExtraCost{ class DiscardCost: public ExtraCost
{
public: public:
DiscardCost(TargetChooser *_tc = NULL); DiscardCost(TargetChooser *_tc = NULL);
virtual int doPay(); virtual int doPay();
virtual DiscardCost * clone() const; virtual DiscardCost * clone() const;
}; };
//tolibrary cost //tolibrary cost
class ToLibraryCost: public ExtraCost{ class ToLibraryCost: public ExtraCost
{
public: public:
ToLibraryCost(TargetChooser *_tc = NULL); ToLibraryCost(TargetChooser *_tc = NULL);
virtual int doPay(); virtual int doPay();
virtual ToLibraryCost * clone() const; virtual ToLibraryCost * clone() const;
}; };
//Millyourself cost //Millyourself cost
class MillCost: public ExtraCost{ class MillCost: public ExtraCost
{
public: public:
MillCost(TargetChooser *_tc = NULL); MillCost(TargetChooser *_tc = NULL);
virtual int canPay(); virtual int canPay();
virtual int doPay(); virtual int doPay();
virtual MillCost * clone() const; virtual MillCost * clone() const;
}; };
//Mill to exile yourself cost //Mill to exile yourself cost
class MillExileCost: public MillCost{ class MillExileCost: public MillCost
{
public: public:
MillExileCost(TargetChooser *_tc = NULL); MillExileCost(TargetChooser *_tc = NULL);
virtual int doPay(); virtual int doPay();
}; };
//tap other cost //tap other cost
class TapTargetCost: public ExtraCost{ class TapTargetCost: public ExtraCost
{
public: public:
TapTargetCost(TargetChooser *_tc = NULL); TapTargetCost(TargetChooser *_tc = NULL);
virtual int doPay(); virtual int doPay();
virtual TapTargetCost * clone() const; virtual TapTargetCost * clone() const;
}; };
//exile as cost //exile as cost
class ExileTargetCost: public ExtraCost{ class ExileTargetCost: public ExtraCost
{
public: public:
ExileTargetCost(TargetChooser *_tc = NULL); ExileTargetCost(TargetChooser *_tc = NULL);
virtual int doPay(); virtual int doPay();
virtual ExileTargetCost * clone() const; virtual ExileTargetCost * clone() const;
}; };
//bounce cost //bounce cost
class BounceTargetCost: public ExtraCost{ class BounceTargetCost: public ExtraCost
{
public: public:
BounceTargetCost(TargetChooser *_tc = NULL); BounceTargetCost(TargetChooser *_tc = NULL);
virtual int doPay(); virtual int doPay();
virtual BounceTargetCost * clone() const; virtual BounceTargetCost * clone() const;
}; };
//bounce cost //bounce cost
class Ninja: public ExtraCost{ class Ninja: public ExtraCost
{
public: public:
Ninja(TargetChooser *_tc = NULL); Ninja(TargetChooser *_tc = NULL);
virtual int isPaymentSet(); virtual int isPaymentSet();
virtual int doPay(); virtual int doPay();
virtual Ninja * clone() const; virtual Ninja * clone() const;
}; };
class CounterCost: public ExtraCost{ class CounterCost: public ExtraCost
{
public: public:
Counter * counter; Counter * counter;
int hasCounters; int hasCounters;
CounterCost(Counter * _counter,TargetChooser *_tc = NULL); CounterCost(Counter * _counter, TargetChooser *_tc = NULL);
~CounterCost(); ~CounterCost();
virtual int setPayment(MTGCardInstance * card); virtual int setPayment(MTGCardInstance * card);
virtual int isPaymentSet(); virtual int isPaymentSet();
virtual int canPay(); virtual int canPay();
virtual int doPay(); virtual int doPay();
virtual CounterCost * clone() const; virtual CounterCost * clone() const;
}; };
#endif #endif

View File

@@ -4,10 +4,6 @@
* http://wololo.net/wagic/ * http://wololo.net/wagic/
*/ */
#ifndef _GAMEAPP_H_ #ifndef _GAMEAPP_H_
#define _GAMEAPP_H_ #define _GAMEAPP_H_
@@ -33,60 +29,57 @@
enum enum
{ {
GAME_TYPE_CLASSIC, GAME_TYPE_CLASSIC,
GAME_TYPE_MOMIR, GAME_TYPE_MOMIR,
GAME_TYPE_RANDOM1, GAME_TYPE_RANDOM1,
GAME_TYPE_RANDOM2, GAME_TYPE_RANDOM2,
GAME_TYPE_STORY GAME_TYPE_STORY
}; };
class MTGAllCards; class MTGAllCards;
class TransitionBase; class TransitionBase;
class GameApp: public JApp class GameApp: public JApp
{ {
private: private:
#ifdef DEBUG #ifdef DEBUG
int nbUpdates; int nbUpdates;
float totalFPS; float totalFPS;
#endif #endif
bool mShowDebugInfo; bool mShowDebugInfo;
int mScreenShotCount; int mScreenShotCount;
GameState* mCurrentState; GameState* mCurrentState;
GameState* mNextState; GameState* mNextState;
GameState* mGameStates[GAME_STATE_MAX]; GameState* mGameStates[GAME_STATE_MAX];
public: public:
int gameType;
int gameType; CardEffect *effect;
CardEffect *effect;
GameApp();
virtual ~GameApp();
GameApp(); virtual void Create();
virtual ~GameApp(); virtual void Destroy();
virtual void Update();
virtual void Render();
virtual void Pause();
virtual void Resume();
virtual void Create(); void LoadGameStates();
virtual void Destroy(); void SetNextState(int state);
virtual void Update(); void DoTransition(int trans, int tostate, float dur = -1, bool animonly = false);
virtual void Render(); void DoAnimation(int trans, float dur = -1);
virtual void Pause(); static hgeParticleSystem * Particles[6];
virtual void Resume(); static int HasMusic;
static string systemError;
static JMusic* music;
void LoadGameStates(); static string currentMusicFile;
void SetNextState(int state); static void playMusic(string filename, bool loop = true);
void DoTransition(int trans, int tostate, float dur=-1, bool animonly = false); static MTGAllCards * collection;
void DoAnimation(int trans, float dur=-1); static int players[2];
static hgeParticleSystem * Particles[6];
static int HasMusic;
static string systemError;
static JMusic* music;
static string currentMusicFile;
static void playMusic(string filename, bool loop = true);
static MTGAllCards * collection;
static int players[2];
}; };

View File

@@ -22,69 +22,70 @@ class TargetChooser;
class Rules; class Rules;
using namespace std; using namespace std;
class GameObserver{ class GameObserver
protected: {
static GameObserver * mInstance; protected:
MTGCardInstance * cardWaitingForTargets; static GameObserver * mInstance;
queue<WEvent *> eventsQueue; MTGCardInstance * cardWaitingForTargets;
queue<WEvent *> eventsQueue;
int nbPlayers; int nbPlayers;
int untap(MTGCardInstance * card); int untap(MTGCardInstance * card);
bool WaitForExtraPayment(MTGCardInstance* card); bool WaitForExtraPayment(MTGCardInstance* card);
public: public:
int currentPlayerId; int currentPlayerId;
CombatStep combatStep; CombatStep combatStep;
int turn; int turn;
int forceShuffleLibraries(); int forceShuffleLibraries();
int targetListIsSet(MTGCardInstance * card); int targetListIsSet(MTGCardInstance * card);
PhaseRing * phaseRing; PhaseRing * phaseRing;
int cancelCurrentAction(); int cancelCurrentAction();
int currentGamePhase; int currentGamePhase;
ExtraCosts * mExtraPayment; ExtraCosts * mExtraPayment;
int oldGamePhase; int oldGamePhase;
TargetChooser * targetChooser; TargetChooser * targetChooser;
DuelLayers * mLayers; DuelLayers * mLayers;
ReplacementEffects *replacementEffects; ReplacementEffects *replacementEffects;
Player * gameOver; Player * gameOver;
Player * players[2]; //created outside Player * players[2]; //created outside
time_t startedAt; time_t startedAt;
Rules * mRules; Rules * mRules;
TargetChooser * getCurrentTargetChooser(); TargetChooser * getCurrentTargetChooser();
void stackObjectClicked(Interruptible * action); void stackObjectClicked(Interruptible * action);
int cardClick(MTGCardInstance * card,Targetable * _object = NULL ); int cardClick(MTGCardInstance * card, Targetable * _object = NULL);
int getCurrentGamePhase(); int getCurrentGamePhase();
void nextCombatStep(); void nextCombatStep();
void userRequestNextGamePhase(); void userRequestNextGamePhase();
void nextGamePhase(); void nextGamePhase();
void cleanupPhase(); void cleanupPhase();
void nextPlayer(); void nextPlayer();
static void Init(Player * _players[], int _nbplayers); static void Init(Player * _players[], int _nbplayers);
static GameObserver * GetInstance(); static GameObserver * GetInstance();
static void EndInstance(); static void EndInstance();
Player * currentPlayer; Player * currentPlayer;
Player * currentActionPlayer; Player * currentActionPlayer;
Player * isInterrupting; Player * isInterrupting;
Player * opponent(); Player * opponent();
Player * currentlyActing(); Player * currentlyActing();
GameObserver(Player * _players[], int _nbplayers); GameObserver(Player * _players[], int _nbplayers);
~GameObserver(); ~GameObserver();
void gameStateBasedEffects(); void gameStateBasedEffects();
void eventOccured(); void eventOccured();
void addObserver(MTGAbility * observer); void addObserver(MTGAbility * observer);
void removeObserver(ActionElement * observer); void removeObserver(ActionElement * observer);
void startGame(Rules * rules); void startGame(Rules * rules);
void untapPhase(); void untapPhase();
void draw(); void draw();
int isInPlay(MTGCardInstance * card); int isInPlay(MTGCardInstance * card);
void Update(float dt); void Update(float dt);
void Render(); void Render();
void ButtonPressed(PlayGuiObject*); void ButtonPressed(PlayGuiObject*);
int receiveEvent(WEvent * event); int receiveEvent(WEvent * event);
}; };
#endif #endif

View File

@@ -23,251 +23,339 @@ class WStyle;
class StyleManager; class StyleManager;
class Player; class Player;
class Options { class Options
{
public: public:
friend class GameSettings; friend class GameSettings;
enum { enum
//Global settings {
ACTIVE_PROFILE, //Global settings
LANG, ACTIVE_PROFILE,
LAST_GLOBAL = LANG, //This must be the value above, to keep ordering. LANG,
//Values /must/ match ordering in optionNames, or everything loads wrong. LAST_GLOBAL = LANG, //This must be the value above, to keep ordering.
//Profile settings //Values /must/ match ordering in optionNames, or everything loads wrong.
ACTIVE_THEME, //Profile settings
ACTIVE_MODE, ACTIVE_THEME,
MUSICVOLUME, ACTIVE_MODE,
SFXVOLUME, MUSICVOLUME,
DIFFICULTY, SFXVOLUME,
CHEATMODE, DIFFICULTY,
OPTIMIZE_HAND, CHEATMODE,
CHEATMODEAIDECK, OPTIMIZE_HAND,
OSD, CHEATMODEAIDECK,
CLOSEDHAND, OSD,
HANDDIRECTION, CLOSEDHAND,
MANADISPLAY, HANDDIRECTION,
REVERSETRIGGERS, MANADISPLAY,
DISABLECARDS, REVERSETRIGGERS,
MAX_GRADE, DISABLECARDS,
ASPHASES, MAX_GRADE,
ECON_DIFFICULTY, ASPHASES,
TRANSITIONS, ECON_DIFFICULTY,
GUI_STYLE, TRANSITIONS,
INTERRUPT_SECONDS, GUI_STYLE,
KEY_BINDINGS, INTERRUPT_SECONDS,
AIDECKS_UNLOCKED, KEY_BINDINGS,
//My interrupts AIDECKS_UNLOCKED,
INTERRUPTMYSPELLS, //My interrupts
INTERRUPTMYABILITIES, INTERRUPTMYSPELLS,
//Other interrupts INTERRUPTMYABILITIES,
INTERRUPT_BEFOREBEGIN, //Other interrupts
INTERRUPT_UNTAP, INTERRUPT_BEFOREBEGIN,
INTERRUPT_UPKEEP, INTERRUPT_UNTAP,
INTERRUPT_DRAW, INTERRUPT_UPKEEP,
INTERRUPT_FIRSTMAIN, INTERRUPT_DRAW,
INTERRUPT_BEGINCOMBAT, INTERRUPT_FIRSTMAIN,
INTERRUPT_ATTACKERS, INTERRUPT_BEGINCOMBAT,
INTERRUPT_BLOCKERS, INTERRUPT_ATTACKERS,
INTERRUPT_DAMAGE, INTERRUPT_BLOCKERS,
INTERRUPT_ENDCOMBAT, INTERRUPT_DAMAGE,
INTERRUPT_SECONDMAIN, INTERRUPT_ENDCOMBAT,
INTERRUPT_ENDTURN, INTERRUPT_SECONDMAIN,
INTERRUPT_CLEANUP, INTERRUPT_ENDTURN,
INTERRUPT_AFTEREND, INTERRUPT_CLEANUP,
BEGIN_AWARDS, //Options after this use the GameOptionAward struct, which includes a timestamp. INTERRUPT_AFTEREND,
DIFFICULTY_MODE_UNLOCKED = BEGIN_AWARDS, BEGIN_AWARDS, //Options after this use the GameOptionAward struct, which includes a timestamp.
MOMIR_MODE_UNLOCKED, DIFFICULTY_MODE_UNLOCKED = BEGIN_AWARDS,
EVILTWIN_MODE_UNLOCKED, MOMIR_MODE_UNLOCKED,
RANDOMDECK_MODE_UNLOCKED, EVILTWIN_MODE_UNLOCKED,
AWARD_COLLECTOR, RANDOMDECK_MODE_UNLOCKED,
LAST_NAMED, //Any option after this does not look up in optionNames. AWARD_COLLECTOR,
SET_UNLOCKS = LAST_NAMED + 1, //For sets. LAST_NAMED, //Any option after this does not look up in optionNames.
SET_UNLOCKS = LAST_NAMED + 1,
//For sets.
}; };
static int optionSet(int setID);
static int optionInterrupt(int gamePhase);
static int getID(string name); static int optionSet(int setID);
static string getName(int option); static int optionInterrupt(int gamePhase);
static int getID(string name);
static string getName(int option);
private: private:
static const string optionNames[]; static const string optionNames[];
}; };
class GameOption { class GameOption
{
public: public:
virtual ~GameOption() {}; virtual ~GameOption()
int number; {
string str; }
//All calls to asColor should include a fallback color for people without a theme. ;
PIXEL_TYPE asColor(PIXEL_TYPE fallback = ARGB(255,255,255,255)); int number;
string str;
//All calls to asColor should include a fallback color for people without a theme.
PIXEL_TYPE asColor(PIXEL_TYPE fallback = ARGB(255,255,255,255));
virtual bool isDefault(); //Returns true when number is 0 and string is "" or "Default" virtual bool isDefault(); //Returns true when number is 0 and string is "" or "Default"
virtual string menuStr(); //The string we'll use for GameStateOptions. virtual string menuStr(); //The string we'll use for GameStateOptions.
virtual bool write(std::ofstream * file, string name); virtual bool write(std::ofstream * file, string name);
virtual bool read(string input); virtual bool read(string input);
GameOption(int value = 0); GameOption(int value = 0);
GameOption(string); GameOption(string);
GameOption(int, string); GameOption(int, string);
}; };
struct EnumDefinition { struct EnumDefinition
int findIndex(int value); {
int findIndex(int value);
typedef pair<int, string> assoc; typedef pair<int, string> assoc;
vector<assoc> values; vector<assoc> values;
}; };
class GameOptionEnum: public GameOption { class GameOptionEnum: public GameOption
{
public: public:
virtual string menuStr(); virtual string menuStr();
virtual bool write(std::ofstream * file, string name); virtual bool write(std::ofstream * file, string name);
virtual bool read(string input); virtual bool read(string input);
EnumDefinition * def; EnumDefinition * def;
}; };
class GameOptionAward: public GameOption { class GameOptionAward: public GameOption
{
public: public:
GameOptionAward(); GameOptionAward();
virtual string menuStr(); virtual string menuStr();
virtual bool write(std::ofstream * file, string name); virtual bool write(std::ofstream * file, string name);
virtual bool read(string input); virtual bool read(string input);
virtual bool giveAward(); //Returns false if already awarded virtual bool giveAward(); //Returns false if already awarded
virtual bool isViewed(); virtual bool isViewed();
virtual void setViewed(bool v = true) {viewed = v;}; virtual void setViewed(bool v = true)
{
viewed = v;
}
;
private: private:
time_t achieved; //When was it awarded? time_t achieved; //When was it awarded?
bool viewed; //Flag it as "New!" or not. bool viewed; //Flag it as "New!" or not.
}; };
class GameOptionKeyBindings : public GameOption { class GameOptionKeyBindings: public GameOption
virtual bool read(string input); {
virtual bool write(std::ofstream*, string); virtual bool read(string input);
virtual bool write(std::ofstream*, string);
}; };
class OptionVolume: public EnumDefinition{ class OptionVolume: public EnumDefinition
{
public: public:
enum { MUTE = 0, MAX = 100 }; enum
static EnumDefinition * getInstance() {return &mDef;}; {
MUTE = 0, MAX = 100
};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private: private:
OptionVolume(); OptionVolume();
static OptionVolume mDef; static OptionVolume mDef;
}; };
class OptionClosedHand: public EnumDefinition
class OptionClosedHand: public EnumDefinition { {
public: public:
enum { INVISIBLE = 0, VISIBLE = 1 }; enum
static EnumDefinition * getInstance() {return &mDef;}; {
private: INVISIBLE = 0, VISIBLE = 1
OptionClosedHand(); };
static OptionClosedHand mDef; static EnumDefinition * getInstance()
}; {
class OptionHandDirection: public EnumDefinition { return &mDef;
public: }
enum { VERTICAL = 0, HORIZONTAL = 1}; ;
static EnumDefinition * getInstance() {return &mDef;};
private: private:
OptionHandDirection(); OptionClosedHand();
static OptionHandDirection mDef; static OptionClosedHand mDef;
}; };
class OptionManaDisplay: public EnumDefinition { class OptionHandDirection: public EnumDefinition
{
public: public:
enum { DYNAMIC = 0, STATIC = 1, NOSTARSDYNAMIC = 2, BOTH = 3}; enum
static EnumDefinition * getInstance() {return &mDef;}; {
VERTICAL = 0, HORIZONTAL = 1
};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private: private:
OptionManaDisplay(); OptionHandDirection();
static OptionManaDisplay mDef; static OptionHandDirection mDef;
}; };
class OptionMaxGrade: public EnumDefinition { class OptionManaDisplay: public EnumDefinition
{
public: public:
static EnumDefinition * getInstance() {return &mDef;}; enum
{
DYNAMIC = 0, STATIC = 1, NOSTARSDYNAMIC = 2, BOTH = 3
};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private: private:
OptionMaxGrade(); OptionManaDisplay();
static OptionMaxGrade mDef; static OptionManaDisplay mDef;
}; };
class OptionASkipPhase: public EnumDefinition { class OptionMaxGrade: public EnumDefinition
{
public: public:
static EnumDefinition * getInstance() {return &mDef;}; static EnumDefinition * getInstance()
{
return &mDef;
}
;
private: private:
OptionASkipPhase(); OptionMaxGrade();
static OptionASkipPhase mDef; static OptionMaxGrade mDef;
}; };
class OptionEconDifficulty: public EnumDefinition { class OptionASkipPhase: public EnumDefinition
{
public: public:
static EnumDefinition * getInstance() {return &mDef;}; static EnumDefinition * getInstance()
{
return &mDef;
}
;
private: private:
OptionEconDifficulty(); OptionASkipPhase();
static OptionEconDifficulty mDef; static OptionASkipPhase mDef;
}; };
class OptionDifficulty: public EnumDefinition { class OptionEconDifficulty: public EnumDefinition
{
public: public:
enum { NORMAL = 0, HARD = 1, HARDER = 2, EVIL = 3}; static EnumDefinition * getInstance()
static EnumDefinition * getInstance() {return &mDef;}; {
return &mDef;
}
;
private: private:
OptionDifficulty(); OptionEconDifficulty();
static OptionDifficulty mDef; static OptionEconDifficulty mDef;
}; };
class OptionDifficulty: public EnumDefinition
class GameOptions { {
public:
string mFilename;
int save();
int load();
GameOption * get(int);
GameOption& operator[](int);
GameOptions(string filename);
~GameOptions();
private:
vector<GameOption*> values;
vector<string> unknown;
};
class GameSettings{
public: public:
friend class GameApp; enum
GameSettings(); {
~GameSettings(); NORMAL = 0, HARD = 1, HARDER = 2, EVIL = 3
int save(); };
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private:
OptionDifficulty();
static OptionDifficulty mDef;
};
SimplePad * keypadStart(string input, string * _dest = NULL, bool _cancel=true, bool _numpad=false, int _x = SCREEN_WIDTH/2, int _y = SCREEN_HEIGHT/2); class GameOptions
string keypadFinish(); {
void keypadShutdown(); public:
void keypadTitle(string set); string mFilename;
bool keypadActive() {if(keypad) return keypad->isActive(); return false;}; int save();
void keypadUpdate(float dt) {if(keypad) keypad->Update(dt);}; int load();
void keypadRender() {if(keypad) keypad->Render();};
bool newAward();
//These return a filepath accurate to the current mode/profile/theme, and can GameOption * get(int);
//optionally fallback to a file within a certain directory. GameOption& operator[](int);
//The sanity=false option returns the adjusted path even if the file doesn't exist. GameOptions(string filename);
string profileFile(string filename="", string fallback="", bool sanity=false,bool relative=false); ~GameOptions();
void reloadProfile(); //Reloads profile using current options[ACTIVE_PROFILE]
void checkProfile(); //Confirms that a profile is loaded and contains a collection.
void createUsersFirstDeck(int setId);
GameOption * get(int);
GameOption& operator[](int);
GameOptions* profileOptions;
GameOptions* globalOptions;
static GameOption invalid_option;
WStyle * getStyle();
StyleManager * getStyleMan();
void automaticStyle(Player * p1, Player * p2);
private: private:
GameApp * theGame; vector<GameOption*> values;
SimplePad * keypad; vector<string> unknown;
StyleManager * styleMan; };
class GameSettings
{
public:
friend class GameApp;
GameSettings();
~GameSettings();
int save();
SimplePad * keypadStart(string input, string * _dest = NULL, bool _cancel = true, bool _numpad = false, int _x = SCREEN_WIDTH
/ 2, int _y = SCREEN_HEIGHT / 2);
string keypadFinish();
void keypadShutdown();
void keypadTitle(string set);
bool keypadActive()
{
if (keypad)
return keypad->isActive();
return false;
}
;
void keypadUpdate(float dt)
{
if (keypad)
keypad->Update(dt);
}
;
void keypadRender()
{
if (keypad)
keypad->Render();
}
;
bool newAward();
//These return a filepath accurate to the current mode/profile/theme, and can
//optionally fallback to a file within a certain directory.
//The sanity=false option returns the adjusted path even if the file doesn't exist.
string profileFile(string filename = "", string fallback = "", bool sanity = false, bool relative = false);
void reloadProfile(); //Reloads profile using current options[ACTIVE_PROFILE]
void checkProfile(); //Confirms that a profile is loaded and contains a collection.
void createUsersFirstDeck(int setId);
GameOption * get(int);
GameOption& operator[](int);
GameOptions* profileOptions;
GameOptions* globalOptions;
static GameOption invalid_option;
WStyle * getStyle();
StyleManager * getStyleMan();
void automaticStyle(Player * p1, Player * p2);
private:
GameApp * theGame;
SimplePad * keypad;
StyleManager * styleMan;
}; };
extern GameSettings options; extern GameSettings options;

View File

@@ -15,7 +15,7 @@ class JGE;
using namespace std; using namespace std;
enum ENUM_GAME_STATE enum ENUM_GAME_STATE
{ {
GAME_STATE_NONE = -1, GAME_STATE_NONE = -1,
GAME_STATE_MENU = 1, GAME_STATE_MENU = 1,
GAME_STATE_DUEL = 2, GAME_STATE_DUEL = 2,
@@ -26,14 +26,14 @@ enum ENUM_GAME_STATE
GAME_STATE_STORY = 7, GAME_STATE_STORY = 7,
GAME_STATE_TRANSITION = 8, GAME_STATE_TRANSITION = 8,
GAME_STATE_MAX = 9, GAME_STATE_MAX = 9,
}; };
enum ENUM_GS_TRANSITION enum ENUM_GS_TRANSITION
{ {
TRANSITION_FADE = 0, TRANSITION_FADE = 0,
TRANSITION_FADE_IN = 1, TRANSITION_FADE_IN = 1,
MAX_TRANSITION MAX_TRANSITION
}; };
class GameApp; class GameApp;
class SimpleMenu; class SimpleMenu;
@@ -41,48 +41,48 @@ class Player;
class GameState class GameState
{ {
protected: protected:
GameApp* mParent; GameApp* mParent;
JGE* mEngine; JGE* mEngine;
public: public:
GameState(GameApp* parent); GameState(GameApp* parent);
virtual ~GameState() {} virtual ~GameState(){}
virtual void Create() {} virtual void Create(){}
virtual void Destroy() {} virtual void Destroy(){}
virtual void Start() {} virtual void Start(){}
virtual void End() {} virtual void End(){}
virtual void Update(float dt) = 0; virtual void Update(float dt) = 0;
virtual void Render() = 0; virtual void Render() = 0;
// deck manipulation methods // deck manipulation methods
// 2010/09/15: // 2010/09/15:
// this was originally one method to do everything. That has been split up into two distinct // this was originally one method to do everything. That has been split up into two distinct
// methods since the original was building a menu and returning a value. The first // methods since the original was building a menu and returning a value. The first
// creates the vector containing the deck information. The second will render that information // creates the vector containing the deck information. The second will render that information
// it makes it easier to manipulate the deck information menus. // it makes it easier to manipulate the deck information menus.
// generate the Deck Meta Data and build the menu items of the menu given
static vector<DeckMetaData *> fillDeckMenu(SimpleMenu * _menu, const string& path, const string& smallDeckPrefix = "", Player * statsPlayer = NULL);
// generate the Deck Meta Data and build the menu items of the menu given // generate the Deck Meta Data and build the menu items of the menu given
// Will display up to maxDecks if maxDecks is non 0,all decks in path otherwise static vector<DeckMetaData *> fillDeckMenu(SimpleMenu * _menu, const string& path, const string& smallDeckPrefix = "", Player * statsPlayer = NULL);
static vector<DeckMetaData *> fillDeckMenu(DeckMenu * _menu, const string& path, const string& smallDeckPrefix = "", Player * statsPlayer = NULL, int maxDecks = 0);
// generate the Deck Meta Data and build the menu items of the menu given
// build a vector of decks with the information passsed in. // Will display up to maxDecks if maxDecks is non 0,all decks in path otherwise
static vector<DeckMetaData *> getValidDeckMetaData(const string& path, const string& smallDeckPrefix = "", Player * statsPlayer = NULL, int maxDecks = 0); static vector<DeckMetaData *> fillDeckMenu(DeckMenu * _menu, const string& path, const string& smallDeckPrefix = "", Player * statsPlayer = NULL, int maxDecks = 0);
// build menu items based on the vector<DeckMetaData *> // build a vector of decks with the information passsed in.
static void renderDeckMenu(SimpleMenu * _menu, const vector<DeckMetaData *>& deckMetaDataList); static vector<DeckMetaData *> getValidDeckMetaData(const string& path, const string& smallDeckPrefix = "", Player * statsPlayer = NULL, int maxDecks = 0);
// build menu items based on the vector<DeckMetaData *> // build menu items based on the vector<DeckMetaData *>
static void renderDeckMenu(DeckMenu * _menu, const vector<DeckMetaData *>& deckMetaDataList); static void renderDeckMenu(SimpleMenu * _menu, const vector<DeckMetaData *>& deckMetaDataList);
}; // build menu items based on the vector<DeckMetaData *>
bool sortByName( DeckMetaData * d1, DeckMetaData * d2 ); static void renderDeckMenu(DeckMenu * _menu, const vector<DeckMetaData *>& deckMetaDataList);
};
bool sortByName(DeckMetaData * d1, DeckMetaData * d2);
#endif #endif

View File

@@ -11,30 +11,30 @@ class WSrcCards;
class GameStateAwards: public GameState, public JGuiListener class GameStateAwards: public GameState, public JGuiListener
{ {
private: private:
WGuiList * listview; WGuiList * listview;
WGuiMenu * detailview; WGuiMenu * detailview;
WSrcCards * setSrc; WSrcCards * setSrc;
SimpleMenu * menu; SimpleMenu * menu;
bool showMenu; bool showMenu;
bool showAlt; bool showAlt;
bool saveMe; bool saveMe;
int mState; int mState;
int mDetailItem; int mDetailItem;
public: public:
GameStateAwards(GameApp* parent); GameStateAwards(GameApp* parent);
bool enterSet(int setid); bool enterSet(int setid);
bool enterStats(int option); bool enterStats(int option);
virtual ~GameStateAwards(); virtual ~GameStateAwards();
virtual void Start(); virtual void Start();
virtual void End(); virtual void End();
virtual void Create(); virtual void Create();
virtual void Destroy(); virtual void Destroy();
virtual void Update(float dt); virtual void Update(float dt);
virtual void Render(); virtual void Render();
virtual void ButtonPressed(int controllerId, int controlId); virtual void ButtonPressed(int controllerId, int controlId);
}; };
#endif #endif

View File

@@ -149,5 +149,4 @@ public:
virtual void ButtonPressed(int controllerId, int controlId); virtual void ButtonPressed(int controllerId, int controlId);
}; };
#endif #endif

View File

@@ -9,73 +9,73 @@
class GameStateMenu: public GameState, public JGuiListener class GameStateMenu: public GameState, public JGuiListener
{ {
private: private:
TextScroller * scroller; TextScroller * scroller;
int scrollerSet; int scrollerSet;
JGuiController* mGuiController; JGuiController* mGuiController;
SimpleMenu* subMenuController; SimpleMenu* subMenuController;
SimpleMenu* gameTypeMenu; SimpleMenu* gameTypeMenu;
int hasChosenGameType; int hasChosenGameType;
JQuad * mIcons[10]; JQuad * mIcons[10];
JTexture * bgTexture; JTexture * bgTexture;
JQuad * mBg; JQuad * mBg;
JQuad * mSplash; JQuad * mSplash;
JTexture * splashTex; JTexture * splashTex;
float mCreditsYPos; float mCreditsYPos;
int currentState; int currentState;
//JMusic * bgMusic; //JMusic * bgMusic;
int mVolume; int mVolume;
char nbcardsStr[400]; char nbcardsStr[400];
vector<string> langs; vector<string> langs;
vector<string> primitives; vector<string> primitives;
string wallpaper; string wallpaper;
int primitivesLoadCounter; int primitivesLoadCounter;
DIR *mDip; DIR *mDip;
struct dirent *mDit; struct dirent *mDit;
char mCurrentSetName[32]; char mCurrentSetName[32];
char mCurrentSetFileName[512]; char mCurrentSetFileName[512];
int mReadConf; int mReadConf;
float timeIndex; float timeIndex;
float angleMultiplier; float angleMultiplier;
float angleW; float angleW;
float yW; float yW;
void fillScroller(); void fillScroller();
void setLang(int id); void setLang(int id);
string getLang(string s); string getLang(string s);
void loadLangMenu(); void loadLangMenu();
bool langChoices; bool langChoices;
void runTest(); //!! void runTest(); //!!
void listPrimitives(); void listPrimitives();
void genNbCardsStr(); //computes the contents of nbCardsStr void genNbCardsStr(); //computes the contents of nbCardsStr
void ensureMGuiController(); //creates the MGuiController if it doesn't exist void ensureMGuiController(); //creates the MGuiController if it doesn't exist
string loadRandomWallpaper(); //loads a list of string of textures that can be randolmy shown on the loading screen string loadRandomWallpaper(); //loads a list of string of textures that can be randolmy shown on the loading screen
public: public:
GameStateMenu(GameApp* parent); GameStateMenu(GameApp* parent);
virtual ~GameStateMenu(); virtual ~GameStateMenu();
virtual void Create(); virtual void Create();
virtual void Destroy(); virtual void Destroy();
virtual void Start(); virtual void Start();
virtual void End(); virtual void End();
virtual void Update(float dt); virtual void Update(float dt);
virtual void Render(); virtual void Render();
virtual void ButtonPressed(int controllerId, int controlId); virtual void ButtonPressed(int controllerId, int controlId);
int nextDirectory(const char * root, const char * file); // Retrieves the next directory to have matching file int nextDirectory(const char * root, const char * file); // Retrieves the next directory to have matching file
void resetDirectory(); void resetDirectory();
void createUsersFirstDeck(int setId); void createUsersFirstDeck(int setId);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
enum enum
{ {
MENU_CARD_PURCHASE = 2, MENU_CARD_PURCHASE = 2,
MENU_DECK_SELECTION = 10, MENU_DECK_SELECTION = 10,
MENU_DECK_BUILDER = 11, MENU_DECK_BUILDER = 11,
MENU_FIRST_DUEL_SUBMENU = 102, MENU_FIRST_DUEL_SUBMENU = 102,
MENU_LANGUAGE_SELECTION = 103, MENU_LANGUAGE_SELECTION = 103,
}; };
}; };
#endif #endif

View File

@@ -10,40 +10,42 @@ class WGuiTabMenu;
class SimpleMenu; class SimpleMenu;
class SimplePad; class SimplePad;
struct KeybGrabber { struct KeybGrabber
virtual void KeyPressed(LocalKeySym) = 0; {
virtual void KeyPressed(LocalKeySym) = 0;
}; };
class GameStateOptions: public GameState, public JGuiListener { class GameStateOptions: public GameState, public JGuiListener
{
private: private:
enum { enum
SHOW_OPTIONS, {
SHOW_OPTIONS_MENU, SHOW_OPTIONS,
SAVE SHOW_OPTIONS_MENU,
}; SAVE
float timer; };
bool mReload; float timer;
KeybGrabber* grabber; bool mReload;
KeybGrabber* grabber;
public: public:
SimpleMenu * optionsMenu; SimpleMenu * optionsMenu;
WGuiTabMenu * optionsTabs; WGuiTabMenu * optionsTabs;
int mState; int mState;
GameStateOptions(GameApp* parent); GameStateOptions(GameApp* parent);
virtual ~GameStateOptions(); virtual ~GameStateOptions();
virtual void Start(); virtual void Start();
virtual void End(); virtual void End();
virtual void Update(float dt); virtual void Update(float dt);
virtual void Render(); virtual void Render();
virtual void GrabKeyboard(KeybGrabber*); virtual void GrabKeyboard(KeybGrabber*);
virtual void UngrabKeyboard(const KeybGrabber*); virtual void UngrabKeyboard(const KeybGrabber*);
void ButtonPressed(int controllerId, int ControlId); void ButtonPressed(int controllerId, int ControlId);
string newProfile; string newProfile;
}; };
#endif #endif

View File

@@ -11,7 +11,6 @@
#include "DeckDataWrapper.h" #include "DeckDataWrapper.h"
#include "Tasks.h" #include "Tasks.h"
#define STATE_BUY 1 #define STATE_BUY 1
#define STATE_SELL 2 #define STATE_SELL 2
#define STAGE_SHOP_MENU 3 #define STAGE_SHOP_MENU 3
@@ -30,94 +29,96 @@
class MTGPack; class MTGPack;
class MTGPacks; class MTGPacks;
class BoosterDisplay:public CardDisplay { class BoosterDisplay: public CardDisplay
{
public: public:
BoosterDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener = NULL, TargetChooser * tc = NULL, int nb_displayed_items = 7); BoosterDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener = NULL, TargetChooser * tc = NULL,
bool CheckUserInput(JButton key); int nb_displayed_items = 7);
bool CheckUserInput(JButton key);
}; };
class ShopBooster{ class ShopBooster
{
public: public:
ShopBooster(); ShopBooster();
string getName(); string getName();
void randomize(MTGPacks * packlist); void randomize(MTGPacks * packlist);
int basePrice(); int basePrice();
int maxInventory(); int maxInventory();
void addToDeck(MTGDeck * d, WSrcCards * srcCards); void addToDeck(MTGDeck * d, WSrcCards * srcCards);
string getSort(); string getSort();
#ifdef TESTSUITE #ifdef TESTSUITE
bool unitTest(); bool unitTest();
#endif #endif
private: private:
void randomCustom(MTGPacks * packlist); void randomCustom(MTGPacks * packlist);
void randomStandard(); void randomStandard();
MTGPack * pack; MTGPack * pack;
MTGSetInfo * mainSet; MTGSetInfo * mainSet;
MTGSetInfo * altSet; MTGSetInfo * altSet;
}; };
class GameStateShop: public GameState, public JGuiListener class GameStateShop: public GameState, public JGuiListener
{ {
private: private:
JQuad * pspIcons[8]; JQuad * pspIcons[8];
WSrcCards * srcCards; WSrcCards * srcCards;
JTexture * altThumb[8]; JTexture * altThumb[8];
JQuad * mBack; JQuad * mBack;
TaskList * taskList; TaskList * taskList;
float mElapsed; float mElapsed;
WGuiMenu * shopMenu; WGuiMenu * shopMenu;
WGuiFilters * filterMenu; //Filter menu slides in sideways from right, or up from bottom. WGuiFilters * filterMenu; //Filter menu slides in sideways from right, or up from bottom.
WGuiCardImage * bigDisplay; WGuiCardImage * bigDisplay;
BoosterDisplay * boosterDisplay; BoosterDisplay * boosterDisplay;
vector<MTGCardInstance*> subBooster; vector<MTGCardInstance*> subBooster;
MTGDeck * booster; MTGDeck * booster;
bool bListCards; bool bListCards;
void beginFilters(); void beginFilters();
void deleteDisplay(); void deleteDisplay();
WSyncable bigSync; WSyncable bigSync;
SimpleMenu * menu; SimpleMenu * menu;
PriceList * pricelist; PriceList * pricelist;
PlayerData * playerdata; PlayerData * playerdata;
MTGPacks * packlist; MTGPacks * packlist;
bool mTouched; bool mTouched;
bool needLoad; bool needLoad;
int mPrices[SHOP_ITEMS]; int mPrices[SHOP_ITEMS];
int mCounts[SHOP_ITEMS]; int mCounts[SHOP_ITEMS];
int mInventory[SHOP_ITEMS]; int mInventory[SHOP_ITEMS];
int lightAlpha; int lightAlpha;
int alphaChange; int alphaChange;
int mBuying; int mBuying;
DeckDataWrapper * myCollection; DeckDataWrapper * myCollection;
int mStage; int mStage;
ShopBooster mBooster[BOOSTER_SLOTS]; ShopBooster mBooster[BOOSTER_SLOTS];
void load(); void load();
void save(bool force=false); void save(bool force = false);
void updateCounts(); void updateCounts();
void beginPurchase(int controlId); void beginPurchase(int controlId);
void purchaseCard(int controlId); void purchaseCard(int controlId);
void purchaseBooster(int controlId); void purchaseBooster(int controlId);
void cancelCard(int controlId); void cancelCard(int controlId);
void cancelBooster(int controlId); void cancelBooster(int controlId);
int purchasePrice(int offset); int purchasePrice(int offset);
string descPurchase(int controlId, bool tiny = false); string descPurchase(int controlId, bool tiny = false);
public: public:
GameStateShop(GameApp* parent); GameStateShop(GameApp* parent);
virtual ~GameStateShop(); virtual ~GameStateShop();
virtual void Start(); virtual void Start();
virtual void End(); virtual void End();
virtual void Create(); virtual void Create();
virtual void Destroy(); virtual void Destroy();
virtual void Update(float dt); virtual void Update(float dt);
virtual void Render(); virtual void Render();
virtual void ButtonPressed(int controllerId, int controlId); virtual void ButtonPressed(int controllerId, int controlId);
static float _x1[],_y1[],_x2[],_y2[],_x3[],_y3[],_x4[],_y4[]; static float _x1[], _y1[], _x2[], _y2[], _x3[], _y3[], _x4[], _y4[];
}; };
#endif #endif

View File

@@ -1,29 +1,28 @@
#ifndef _GAME_STATE_STORY_H_ #ifndef _GAME_STATE_STORY_H_
#define _GAME_STATE_STORY_H_ #define _GAME_STATE_STORY_H_
#include "GameState.h" #include "GameState.h"
#include <JGui.h> #include <JGui.h>
class StoryFlow; class StoryFlow;
class SimpleMenu; class SimpleMenu;
class GameStateStory: public GameState, public JGuiListener { class GameStateStory: public GameState, public JGuiListener
{
private: private:
StoryFlow * flow; StoryFlow * flow;
SimpleMenu * menu; SimpleMenu * menu;
vector<string> stories; vector<string> stories;
void loadStoriesMenu(const char * root); void loadStoriesMenu(const char * root);
public: public:
GameStateStory(GameApp* parent); GameStateStory(GameApp* parent);
~GameStateStory(); ~GameStateStory();
void Start(); void Start();
void End(); void End();
void Update(float dt); void Update(float dt);
void Render(); void Render();
void ButtonPressed(int controllerId, int controlId); void ButtonPressed(int controllerId, int controlId);
}; };
#endif #endif

View File

@@ -5,30 +5,36 @@
#include <JGui.h> #include <JGui.h>
#include "GameState.h" #include "GameState.h"
class TransitionBase: public GameState, public JGuiListener{ class TransitionBase: public GameState, public JGuiListener
{
public: public:
TransitionBase(GameApp* parent, GameState* _from, GameState* _to, float duration); TransitionBase(GameApp* parent, GameState* _from, GameState* _to, float duration);
~TransitionBase(); ~TransitionBase();
virtual void Start(); virtual void Start();
virtual void End(); virtual void End();
virtual bool Finished() {return (mElapsed >= mDuration);}; virtual bool Finished()
virtual void Update(float dt); {
virtual void Render() = 0; return (mElapsed >= mDuration);
virtual void ButtonPressed(int controllerId, int controlId); }
;
virtual void Update(float dt);
virtual void Render() = 0;
virtual void ButtonPressed(int controllerId, int controlId);
float mElapsed; float mElapsed;
float mDuration; float mDuration;
GameState* from; GameState* from;
GameState* to; GameState* to;
bool bAnimationOnly; //Does not call start or end on subordinates. bool bAnimationOnly; //Does not call start or end on subordinates.
}; };
class TransitionFade: public TransitionBase { class TransitionFade: public TransitionBase
{
public: public:
TransitionFade(GameApp* p, GameState* f, GameState* t, float dur, bool reversed); TransitionFade(GameApp* p, GameState* f, GameState* t, float dur, bool reversed);
virtual void Render(); virtual void Render();
bool mReversed; bool mReversed;
}; };
#endif #endif

View File

@@ -7,31 +7,30 @@ struct GuiAvatar;
class GuiGraveyard; class GuiGraveyard;
class GuiLibrary; class GuiLibrary;
class GuiOpponentHand; class GuiOpponentHand;
class GuiAvatars : public GuiLayer class GuiAvatars: public GuiLayer
{ {
protected: protected:
GuiAvatar* self, *opponent; GuiAvatar* self, *opponent;
GuiGraveyard* selfGraveyard, *opponentGraveyard; GuiGraveyard* selfGraveyard, *opponentGraveyard;
GuiLibrary* selfLibrary, *opponentLibrary; GuiLibrary* selfLibrary, *opponentLibrary;
GuiOpponentHand *opponentHand; GuiOpponentHand *opponentHand;
GuiAvatar* active; GuiAvatar* active;
public: public:
GuiAvatars(); GuiAvatars();
~GuiAvatars(); ~GuiAvatars();
GuiAvatar* GetSelf(); GuiAvatar* GetSelf();
GuiAvatar* GetOpponent(); GuiAvatar* GetOpponent();
void Update(float dt); void Update(float dt);
void Render(); void Render();
void Activate(PlayGuiObject* c); void Activate(PlayGuiObject* c);
void Deactivate(PlayGuiObject* c); void Deactivate(PlayGuiObject* c);
int receiveEventPlus(WEvent*); int receiveEventPlus(WEvent*);
int receiveEventMinus(WEvent*); int receiveEventMinus(WEvent*);
bool CheckUserInput(JButton key); bool CheckUserInput(JButton key);
bool CheckUserInput(int x, int y); bool CheckUserInput(int x, int y);
float LeftBoundarySelf(); float LeftBoundarySelf();
}; };
#endif // _GUIAVATARS_H_ #endif // _GUIAVATARS_H_

View File

@@ -4,15 +4,15 @@
#include "GuiLayers.h" #include "GuiLayers.h"
#include "WEvent.h" #include "WEvent.h"
class GuiBackground : public GuiLayer class GuiBackground: public GuiLayer
{ {
protected: protected:
JQuad* quad; JQuad* quad;
public: public:
GuiBackground(); GuiBackground();
~GuiBackground(); ~GuiBackground();
virtual void Render(); virtual void Render();
}; };
#endif // _GUIBACKGROUND_H_ #endif // _GUIBACKGROUND_H_

View File

@@ -1,13 +1,13 @@
#ifndef _GUI_CARDS_CONTROLLER_H_ #ifndef _GUI_CARDS_CONTROLLER_H_
#define _GUI_CARDS_CONTROLLER_H_ #define _GUI_CARDS_CONTROLLER_H_
#include "PlayGuiObjectController.h" #include "PlayGuiObjectController.h"
class GuiCardsController : public PlayGuiObjectController{ class GuiCardsController: public PlayGuiObjectController
public: {
GuiCardsController(){}; public:
GuiCardsController(){}
;
}; };
#endif #endif

View File

@@ -7,38 +7,45 @@
#include "MTGCardInstance.h" #include "MTGCardInstance.h"
#include "DamagerDamaged.h" #include "DamagerDamaged.h"
class GuiCombat : public GuiLayer class GuiCombat: public GuiLayer
{ {
protected: protected:
GameObserver* go; GameObserver* go;
DamagerDamaged* active; DamagerDamaged* active;
AttackerDamaged* activeAtk; AttackerDamaged* activeAtk;
static JTexture* ok_tex; static JTexture* ok_tex;
Pos ok, enemy_avatar; Pos ok, enemy_avatar;
DamagerDamaged* current; DamagerDamaged* current;
enum { BLK, ATK, OK, NONE } cursor_pos; enum
CombatStep step; {
void validateDamage(); BLK,
void addOne(DefenserDamaged* blocker, CombatStep); ATK,
void removeOne(DefenserDamaged* blocker, CombatStep); OK,
void remaskBlkViews(AttackerDamaged* before, AttackerDamaged* after); NONE
int resolve(); } cursor_pos;
public: CombatStep step;
void validateDamage();
void addOne(DefenserDamaged* blocker, CombatStep);
void removeOne(DefenserDamaged* blocker, CombatStep);
void remaskBlkViews(AttackerDamaged* before, AttackerDamaged* after);
int resolve();
vector<AttackerDamaged*> attackers; public:
void autoaffectDamage(AttackerDamaged* attacker, CombatStep);
GuiCombat(GameObserver* go); vector<AttackerDamaged*> attackers;
~GuiCombat(); void autoaffectDamage(AttackerDamaged* attacker, CombatStep);
virtual void Update(float dt);
virtual void Render();
bool clickOK();
virtual bool CheckUserInput(JButton key);
virtual int receiveEventPlus(WEvent* e);
virtual int receiveEventMinus(WEvent* e);
typedef vector<AttackerDamaged*>::iterator inner_iterator; GuiCombat(GameObserver* go);
~GuiCombat();
virtual void Update(float dt);
virtual void Render();
bool clickOK();
virtual bool CheckUserInput(JButton key);
virtual int receiveEventPlus(WEvent* e);
virtual int receiveEventMinus(WEvent* e);
typedef vector<AttackerDamaged*>::iterator inner_iterator;
}; };
#endif // _GUICOMBAT_H_ #endif // _GUICOMBAT_H_

View File

@@ -3,18 +3,18 @@
#include "GuiLayers.h" #include "GuiLayers.h"
class GuiFrame : public GuiLayer class GuiFrame: public GuiLayer
{ {
protected: protected:
JQuad* wood; JQuad* wood;
JQuad* gold1, *gold2, *goldGlow; JQuad* gold1, *gold2, *goldGlow;
float step; float step;
public: public:
GuiFrame(); GuiFrame();
~GuiFrame(); ~GuiFrame();
virtual void Render(); virtual void Render();
void Update(float dt); void Update(float dt);
}; };
#endif // _GUIFRAME_H_ #endif // _GUIFRAME_H_

View File

@@ -9,79 +9,79 @@
class GuiHand; class GuiHand;
struct HandLimitor : public Limitor struct HandLimitor: public Limitor
{ {
GuiHand* hand; GuiHand* hand;
virtual bool select(Target*); virtual bool select(Target*);
virtual bool greyout(Target*); virtual bool greyout(Target*);
HandLimitor(GuiHand* hand); HandLimitor(GuiHand* hand);
}; };
class GuiHand : public GuiLayer class GuiHand: public GuiLayer
{ {
public: public:
static const float ClosedRowX; static const float ClosedRowX;
static const float LeftRowX; static const float LeftRowX;
static const float RightRowX; static const float RightRowX;
static const float OpenX; static const float OpenX;
static const float ClosedX; static const float ClosedX;
static const float OpenY; static const float OpenY;
static const float ClosedY; static const float ClosedY;
protected: protected:
const MTGHand* hand; const MTGHand* hand;
JQuad *back; JQuad *back;
vector<CardView*> cards; vector<CardView*> cards;
public: public:
GuiHand(MTGHand* hand); GuiHand(MTGHand* hand);
~GuiHand(); ~GuiHand();
void Update(float dt); void Update(float dt);
bool isInHand(CardView*); bool isInHand(CardView*);
friend struct HandLimitor; friend struct HandLimitor;
}; };
class GuiHandOpponent : public GuiHand class GuiHandOpponent: public GuiHand
{ {
public: public:
GuiHandOpponent(MTGHand* hand); GuiHandOpponent(MTGHand* hand);
virtual void Render(); virtual void Render();
virtual int receiveEventPlus(WEvent* e); virtual int receiveEventPlus(WEvent* e);
virtual int receiveEventMinus(WEvent* e); virtual int receiveEventMinus(WEvent* e);
}; };
class GuiHandSelf : public GuiHand class GuiHandSelf: public GuiHand
{ {
protected: protected:
typedef enum typedef enum
{ {
Open, Open, Closed
Closed } HandState;
} HandState; HandState state;
HandState state; Pos backpos;
Pos backpos;
public: public:
GuiHandSelf(MTGHand* hand); GuiHandSelf(MTGHand* hand);
~GuiHandSelf(); ~GuiHandSelf();
virtual int receiveEventPlus(WEvent* e); virtual int receiveEventPlus(WEvent* e);
virtual int receiveEventMinus(WEvent* e); virtual int receiveEventMinus(WEvent* e);
void Repos(); void Repos();
bool CheckUserInput(JButton key); bool CheckUserInput(JButton key);
virtual void Render(); virtual void Render();
void Update(float dt); void Update(float dt);
float LeftBoundary(); float LeftBoundary();
HandState GetState() HandState GetState()
{ {
return state; return state;
}; }
;
HandLimitor* limitor; HandLimitor* limitor;
}; };
#endif // _GUIHAND_H_ #endif // _GUIHAND_H_

View File

@@ -12,33 +12,48 @@
class GameObserver; class GameObserver;
class Player; class Player;
class GuiLayer{ class GuiLayer
protected: {
JButton mActionButton; protected:
public: JButton mActionButton;
int mCount; public:
int mCurr; int mCount;
vector<JGuiObject *> mObjects; int mCurr;
void Add(JGuiObject * object); vector<JGuiObject *> mObjects;
int Remove(JGuiObject * object); void Add(JGuiObject * object);
int modal; int Remove(JGuiObject * object);
bool hasFocus; int modal;
virtual void resetObjects(); bool hasFocus;
int getMaxId(); virtual void resetObjects();
GuiLayer(); int getMaxId();
virtual ~GuiLayer(); GuiLayer();
virtual void Update(float dt); virtual ~GuiLayer();
virtual bool CheckUserInput(JButton key){ return false; }; virtual void Update(float dt);
int getIndexOf(JGuiObject * object); virtual bool CheckUserInput(JButton key)
JGuiObject * getByIndex (int index); {
virtual void Render(); return false;
int empty(){ }
if (mCount) return 0;
return 1; int getIndexOf(JGuiObject * object);
}; JGuiObject * getByIndex(int index);
virtual void Render();
int empty()
{
if (mCount)
return 0;
return 1;
}
virtual int receiveEventPlus(WEvent * e)
{
return 0;
}
virtual int receiveEventMinus(WEvent * e)
{
return 0;
}
virtual int receiveEventPlus(WEvent * e){return 0;};
virtual int receiveEventMinus(WEvent * e){return 0;};
}; };
#endif #endif

View File

@@ -6,40 +6,47 @@
#include "GameApp.h" #include "GameApp.h"
#include "GuiLayers.h" #include "GuiLayers.h"
class ManaIcon : public Pos class ManaIcon: public Pos
{ {
hgeParticleSystem* particleSys; hgeParticleSystem* particleSys;
JQuad* icon; JQuad* icon;
float zoomP1, zoomP2, zoomP3, zoomP4, zoomP5, zoomP6; float zoomP1, zoomP2, zoomP3, zoomP4, zoomP5, zoomP6;
float xP1, xP2, xP3; float xP1, xP2, xP3;
float yP1, yP2, yP3; float yP1, yP2, yP3;
float tP1; float tP1;
float f; float f;
float destx,desty; float destx, desty;
public: public:
enum { ALIVE, WITHERING, DROPPING, DEAD } mode; enum
int color; {
void Render(); ALIVE,
void Update(float dt, float shift); WITHERING,
void Wither(); DROPPING,
void Drop(); DEAD
ManaIcon(int color, float x, float y,float destx, float desty); } mode;
~ManaIcon();
int color;
void Render();
void Update(float dt, float shift);
void Wither();
void Drop();
ManaIcon(int color, float x, float y, float destx, float desty);
~ManaIcon();
}; };
class GuiMana : public GuiLayer class GuiMana: public GuiLayer
{ {
protected: protected:
vector<ManaIcon*> manas; vector<ManaIcon*> manas;
float x, y; float x, y;
Player * owner; Player * owner;
void RenderStatic(); void RenderStatic();
public: public:
GuiMana(float x, float y, Player *p); GuiMana(float x, float y, Player *p);
~GuiMana(); ~GuiMana();
virtual void Render(); virtual void Render();
virtual void Update(float dt); virtual void Update(float dt);
virtual int receiveEventPlus(WEvent * e); virtual int receiveEventPlus(WEvent * e);
virtual int receiveEventMinus(WEvent * e); virtual int receiveEventMinus(WEvent * e);
}; };

View File

@@ -5,18 +5,18 @@
#include "PhaseRing.h" #include "PhaseRing.h"
#include "WEvent.h" #include "WEvent.h"
class GuiPhaseBar : public GuiLayer class GuiPhaseBar: public GuiLayer
{ {
protected: protected:
Phase* phase; Phase* phase;
float angle; float angle;
public: public:
GuiPhaseBar(); GuiPhaseBar();
~GuiPhaseBar(); ~GuiPhaseBar();
void Update(float dt); void Update(float dt);
virtual void Render(); virtual void Render();
virtual int receiveEventMinus(WEvent * e); virtual int receiveEventMinus(WEvent * e);
}; };
#endif // _GUIPHASEBAR_H_ #endif // _GUIPHASEBAR_H_

View File

@@ -4,85 +4,89 @@
#include "GuiLayers.h" #include "GuiLayers.h"
#include "CardGui.h" #include "CardGui.h"
class GuiPlay : public GuiLayer class GuiPlay: public GuiLayer
{ {
public: public:
static const float HORZWIDTH; static const float HORZWIDTH;
static const float VERTHEIGHT; static const float VERTHEIGHT;
typedef vector<CardView*>::iterator iterator; typedef vector<CardView*>::iterator iterator;
protected: protected:
class CardStack { class CardStack
protected: {
unsigned total; protected:
float baseX, baseY; unsigned total;
float x, y; float baseX, baseY;
float x, y;
public: public:
void reset(unsigned total, float x, float y); void reset(unsigned total, float x, float y);
void Enstack(CardView*); void Enstack(CardView*);
void RenderSpell(MTGCardInstance*, iterator begin, iterator end, float x, float y); void RenderSpell(MTGCardInstance*, iterator begin, iterator end, float x, float y);
}; };
class HorzStack : public CardStack { class HorzStack: public CardStack
public: {
HorzStack(); public:
void Render(CardView*, iterator begin, iterator end); HorzStack();
void Enstack(CardView*); void Render(CardView*, iterator begin, iterator end);
}; void Enstack(CardView*);
class VertStack : public CardStack { };
protected: class VertStack: public CardStack
unsigned count; {
public: protected:
VertStack(); unsigned count;
void reset(unsigned total, float x, float y); public:
void Render(CardView*, iterator begin, iterator end); VertStack();
void Enstack(CardView*); void reset(unsigned total, float x, float y);
inline float nextX(); void Render(CardView*, iterator begin, iterator end);
}; void Enstack(CardView*);
class BattleField : public HorzStack { inline float nextX();
static const float HEIGHT; };
unsigned attackers; class BattleField: public HorzStack
unsigned blockers; {
unsigned currentAttacker; static const float HEIGHT;
float height; unsigned attackers;
unsigned blockers;
unsigned currentAttacker;
float height;
public: public:
int red; int red;
int colorFlow; int colorFlow;
void addAttacker(MTGCardInstance*); void addAttacker(MTGCardInstance*);
void removeAttacker(MTGCardInstance*); void removeAttacker(MTGCardInstance*);
void reset(float x, float y); void reset(float x, float y);
BattleField(); BattleField();
void EnstackAttacker(CardView*); void EnstackAttacker(CardView*);
void EnstackBlocker(CardView*); void EnstackBlocker(CardView*);
void Update(float dt);
void Render();
};
class Lands: public HorzStack {};
class Creatures: public HorzStack {};
class Spells: public VertStack {};
protected:
GameObserver* game;
Creatures selfCreatures, opponentCreatures;
BattleField battleField;
Lands selfLands, opponentLands;
Spells selfSpells, opponentSpells;
iterator end_spells;
vector<CardView*> cards;
public:
GuiPlay(GameObserver*);
~GuiPlay();
virtual void Render();
void Replace();
void Update(float dt); void Update(float dt);
void Render(); virtual int receiveEventPlus(WEvent * e);
}; virtual int receiveEventMinus(WEvent * e);
class Lands : public HorzStack {};
class Creatures : public HorzStack {};
class Spells : public VertStack {};
protected:
GameObserver* game;
Creatures selfCreatures, opponentCreatures;
BattleField battleField;
Lands selfLands, opponentLands;
Spells selfSpells, opponentSpells;
iterator end_spells;
vector<CardView*> cards;
public:
GuiPlay(GameObserver*);
~GuiPlay();
virtual void Render();
void Replace();
void Update(float dt);
virtual int receiveEventPlus(WEvent * e);
virtual int receiveEventMinus(WEvent * e);
}; };
#endif // _GUIPLAY_H_ #endif // _GUIPLAY_H_

View File

@@ -9,73 +9,84 @@
class CardView; class CardView;
struct GuiStatic : public PlayGuiObject{ struct GuiStatic: public PlayGuiObject
GuiAvatars* parent; {
GuiStatic(float desiredHeight, float x, float y, bool hasFocus, GuiAvatars* parent); GuiAvatars* parent;
virtual void Entering(); GuiStatic(float desiredHeight, float x, float y, bool hasFocus, GuiAvatars* parent);
virtual bool Leaving(JButton key); virtual void Entering();
virtual bool Leaving(JButton key);
}; };
struct GuiAvatar : public GuiStatic{ struct GuiAvatar: public GuiStatic
typedef enum { TOP_LEFT, BOTTOM_RIGHT } Corner; {
static const unsigned Width = 35; typedef enum
static const unsigned Height = 50; {
TOP_LEFT,
BOTTOM_RIGHT
} Corner;
protected: static const unsigned Width = 35;
int avatarRed; static const unsigned Height = 50;
int currentLife;
int currentpoisonCount;
Corner corner;
public:
Player * player;
virtual void Render();
GuiAvatar(float x, float y, bool hasFocus, Player * player, Corner corner, GuiAvatars* parent);
virtual ostream& toString(ostream& out) const;
};
struct GuiGameZone : public GuiStatic{ protected:
static const int Width = 20; int avatarRed;
static const int Height = 25; int currentLife;
vector<CardView*> cards; int currentpoisonCount;
Corner corner;
public:
MTGGameZone * zone;
CardDisplay * cd;
int showCards;
virtual void Render();
virtual bool CheckUserInput(JButton key);
virtual bool CheckUserInput(int x, int y);
virtual void Update(float dt);
GuiGameZone(float x, float y, bool hasFocus, MTGGameZone * zone, GuiAvatars* parent);
~GuiGameZone();
virtual void ButtonPressed(int controllerId, int controlId);
void toggleDisplay();
virtual ostream& toString(ostream& out) const;
};
//opponenthand
class GuiOpponentHand: public GuiGameZone{
public: public:
Player * player; Player * player;
GuiOpponentHand(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* Parent); virtual void Render();
int receiveEventPlus(WEvent*); GuiAvatar(float x, float y, bool hasFocus, Player * player, Corner corner, GuiAvatars* parent);
int receiveEventMinus(WEvent*); virtual ostream& toString(ostream& out) const;
virtual ostream& toString(ostream& out) const;
};
//end of my addition
class GuiGraveyard: public GuiGameZone{
public:
Player * player;
GuiGraveyard(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* parent);
int receiveEventPlus(WEvent*);
int receiveEventMinus(WEvent*);
virtual ostream& toString(ostream& out) const;
}; };
class GuiLibrary: public GuiGameZone{ struct GuiGameZone: public GuiStatic
public: {
Player * player; static const int Width = 20;
GuiLibrary(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* parent); static const int Height = 25;
virtual ostream& toString(ostream& out) const; vector<CardView*> cards;
public:
MTGGameZone * zone;
CardDisplay * cd;
int showCards;
virtual void Render();
virtual bool CheckUserInput(JButton key);
virtual bool CheckUserInput(int x, int y);
virtual void Update(float dt);
GuiGameZone(float x, float y, bool hasFocus, MTGGameZone * zone, GuiAvatars* parent);
~GuiGameZone();
virtual void ButtonPressed(int controllerId, int controlId);
void toggleDisplay();
virtual ostream& toString(ostream& out) const;
};
//opponenthand
class GuiOpponentHand: public GuiGameZone
{
public:
Player * player;
GuiOpponentHand(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* Parent);
int receiveEventPlus(WEvent*);
int receiveEventMinus(WEvent*);
virtual ostream& toString(ostream& out) const;
};
//end of my addition
class GuiGraveyard: public GuiGameZone
{
public:
Player * player;
GuiGraveyard(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* parent);
int receiveEventPlus(WEvent*);
int receiveEventMinus(WEvent*);
virtual ostream& toString(ostream& out) const;
};
class GuiLibrary: public GuiGameZone
{
public:
Player * player;
GuiLibrary(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* parent);
virtual ostream& toString(ostream& out) const;
}; };
#endif // _GUISTATIC_H_ #endif // _GUISTATIC_H_

View File

@@ -22,7 +22,6 @@ class Counter;
using std::string; using std::string;
using std::map; using std::map;
//stupid variables used to give a hint to the AI: //stupid variables used to give a hint to the AI:
// Should I cast a spell on an enemy or friendly unit ? // Should I cast a spell on an enemy or friendly unit ?
#define BAKA_EFFECT_GOOD 1 #define BAKA_EFFECT_GOOD 1
@@ -63,22 +62,38 @@ public:
MTGAbility(int id, MTGCardInstance* _source, Targetable* _target); MTGAbility(int id, MTGCardInstance* _source, Targetable* _target);
virtual int testDestroy(); virtual int testDestroy();
virtual ~MTGAbility(); virtual ~MTGAbility();
virtual void Render(){}; virtual void Render() {}
virtual int isReactingToClick(MTGCardInstance* card, ManaCost* mana = NULL){return 0;}; virtual int isReactingToClick(MTGCardInstance* card, ManaCost* mana = NULL)
virtual int reactToClick(MTGCardInstance* card){return 0;}; {
virtual int receiveEvent(WEvent* event){return 0;}; return 0;
virtual void Update(float dt){}; }
;
virtual int reactToClick(MTGCardInstance* card)
{
return 0;
}
;
virtual int receiveEvent(WEvent* event)
{
return 0;
}
;
virtual void Update(float dt) {};
virtual int fireAbility(); virtual int fireAbility();
virtual int stillInUse(MTGCardInstance* card); virtual int stillInUse(MTGCardInstance* card);
virtual int resolve(){return 0;}; virtual int resolve()
virtual MTGAbility* clone() const = 0; {
return 0;
}
;
virtual MTGAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
virtual int addToGame(); virtual int addToGame();
virtual int removeFromGame(); virtual int removeFromGame();
/*Poor man's casting */ /*Poor man's casting */
/* Todo replace that crap with dynamic casting */ /* Todo replace that crap with dynamic casting */
enum enum
{ {
UNKNOWN = 0, UNKNOWN = 0,
MANA_PRODUCER = 1, MANA_PRODUCER = 1,
@@ -116,26 +131,35 @@ public:
NestedAbility(MTGAbility* _ability); NestedAbility(MTGAbility* _ability);
}; };
class TriggeredAbility:public MTGAbility class TriggeredAbility: public MTGAbility
{ {
public: public:
TriggeredAbility(int id, MTGCardInstance* card); TriggeredAbility(int id, MTGCardInstance* card);
TriggeredAbility(int id, MTGCardInstance* _source, Targetable* _target); TriggeredAbility(int id, MTGCardInstance* _source, Targetable* _target);
virtual void Update(float dt); virtual void Update(float dt);
virtual void Render(){}; virtual void Render() {}
virtual int trigger(){return 0;}; ;
virtual int triggerOnEvent(WEvent* e){return 0;}; virtual int trigger()
{
return 0;
}
;
virtual int triggerOnEvent(WEvent* e)
{
return 0;
}
;
int receiveEvent(WEvent* e); int receiveEvent(WEvent* e);
virtual int resolve() = 0; virtual int resolve() = 0;
virtual TriggeredAbility* clone() const = 0; virtual TriggeredAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
class ActivatedAbility: public MTGAbility
class ActivatedAbility:public MTGAbility
{ {
public: public:
enum { enum
{
NO_RESTRICTION = 0, NO_RESTRICTION = 0,
PLAYER_TURN_ONLY = 1, PLAYER_TURN_ONLY = 1,
AS_SORCERY = 2, AS_SORCERY = 2,
@@ -190,21 +214,21 @@ public:
ManaCost* abilityCost; ManaCost* abilityCost;
int restrictions; int restrictions;
int needsTapping; int needsTapping;
ActivatedAbility(int id, MTGCardInstance* card,ManaCost* _cost = NULL, int _restrictions = NO_RESTRICTION,int tap = 1); ActivatedAbility(int id, MTGCardInstance* card, ManaCost* _cost = NULL, int _restrictions = NO_RESTRICTION, int tap = 1);
virtual ~ActivatedAbility(); virtual ~ActivatedAbility();
virtual int reactToClick(MTGCardInstance* card); virtual int reactToClick(MTGCardInstance* card);
virtual int isReactingToClick(MTGCardInstance* card, ManaCost* mana = NULL); virtual int isReactingToClick(MTGCardInstance* card, ManaCost* mana = NULL);
virtual int reactToTargetClick(Targetable* object); virtual int reactToTargetClick(Targetable* object);
virtual int resolve() = 0; virtual int resolve() = 0;
virtual ActivatedAbility* clone() const = 0; virtual ActivatedAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
class TargetAbility:public ActivatedAbility, public NestedAbility class TargetAbility: public ActivatedAbility, public NestedAbility
{ {
public: public:
TargetAbility(int id, MTGCardInstance* card, TargetChooser* _tc,ManaCost* _cost = NULL, int _playerturnonly = 0,int tap = 1); TargetAbility(int id, MTGCardInstance* card, TargetChooser* _tc, ManaCost* _cost = NULL, int _playerturnonly = 0, int tap = 1);
TargetAbility(int id, MTGCardInstance* card,ManaCost* _cost = NULL, int _playerturnonly = 0,int tap = 1); TargetAbility(int id, MTGCardInstance* card, ManaCost* _cost = NULL, int _playerturnonly = 0, int tap = 1);
virtual int reactToClick(MTGCardInstance* card); virtual int reactToClick(MTGCardInstance* card);
virtual int reactToTargetClick(Targetable* object); virtual int reactToTargetClick(Targetable* object);
virtual TargetAbility* clone() const = 0; virtual TargetAbility* clone() const = 0;
@@ -215,71 +239,100 @@ public:
~TargetAbility(); ~TargetAbility();
}; };
class InstantAbility:public MTGAbility class InstantAbility: public MTGAbility
{ {
public: public:
int init; int init;
virtual void Update(float dt); virtual void Update(float dt);
virtual int testDestroy(); virtual int testDestroy();
InstantAbility(int _id, MTGCardInstance* source); InstantAbility(int _id, MTGCardInstance* source);
InstantAbility(int _id, MTGCardInstance* source,Damageable* _target); InstantAbility(int _id, MTGCardInstance* source, Damageable* _target);
virtual int resolve(){return 0;}; virtual int resolve()
{
return 0;
}
;
virtual InstantAbility* clone() const = 0; virtual InstantAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
/* State based effects. This class works ONLY for InPlay and needs to be extended for other areas of the game !!! */ /* State based effects. This class works ONLY for InPlay and needs to be extended for other areas of the game !!! */
class ListMaintainerAbility:public MTGAbility class ListMaintainerAbility: public MTGAbility
{ {
public: public:
map<MTGCardInstance *,bool> cards; map<MTGCardInstance *, bool> cards;
map<Player *,bool> players; map<Player *, bool> players;
ListMaintainerAbility(int _id):MTGAbility(_id,NULL){}; ListMaintainerAbility(int _id) : MTGAbility(_id, NULL)
ListMaintainerAbility(int _id, MTGCardInstance *_source):MTGAbility(_id, _source){}; {
ListMaintainerAbility(int _id, MTGCardInstance *_source,Damageable* _target):MTGAbility(_id, _source, _target){}; }
;
ListMaintainerAbility(int _id, MTGCardInstance *_source) : MTGAbility(_id, _source)
{
}
;
ListMaintainerAbility(int _id, MTGCardInstance *_source, Damageable* _target) : MTGAbility(_id, _source, _target)
{
}
;
virtual void Update(float dt); virtual void Update(float dt);
void updateTargets(); void updateTargets();
virtual bool canTarget(MTGGameZone* zone); virtual bool canTarget(MTGGameZone* zone);
virtual int canBeInList(MTGCardInstance* card) = 0; virtual int canBeInList(MTGCardInstance* card) = 0;
virtual int added(MTGCardInstance* card) = 0; virtual int added(MTGCardInstance* card) = 0;
virtual int removed(MTGCardInstance* card) = 0; virtual int removed(MTGCardInstance* card) = 0;
virtual int canBeInList(Player* p){return 0;}; virtual int canBeInList(Player* p)
virtual int added(Player* p){return 0;}; {
virtual int removed(Player* p){return 0;}; return 0;
}
;
virtual int added(Player* p)
{
return 0;
}
;
virtual int removed(Player* p)
{
return 0;
}
;
virtual int destroy(); virtual int destroy();
virtual ListMaintainerAbility* clone() const = 0; virtual ListMaintainerAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
class TriggerAtPhase:public TriggeredAbility class TriggerAtPhase: public TriggeredAbility
{ {
public: public:
int phaseId; int phaseId;
int who; int who;
TriggerAtPhase(int id, MTGCardInstance* source, Targetable* target,int _phaseId, int who = 0); TriggerAtPhase(int id, MTGCardInstance* source, Targetable* target, int _phaseId, int who = 0);
virtual int trigger(); virtual int trigger();
int resolve(){return 0;}; int resolve()
{
return 0;
}
;
virtual TriggerAtPhase* clone() const; virtual TriggerAtPhase* clone() const;
}; };
class TriggerNextPhase:public TriggerAtPhase class TriggerNextPhase: public TriggerAtPhase
{ {
public: public:
int destroyActivated; int destroyActivated;
TriggerNextPhase(int id, MTGCardInstance* source, Targetable* target,int _phaseId, int who = 0); TriggerNextPhase(int id, MTGCardInstance* source, Targetable* target, int _phaseId, int who = 0);
virtual TriggerNextPhase* clone() const; virtual TriggerNextPhase* clone() const;
virtual int testDestroy(); virtual int testDestroy();
}; };
class GenericTriggeredAbility: public TriggeredAbility, public NestedAbility
class GenericTriggeredAbility:public TriggeredAbility, public NestedAbility
{ {
public: public:
TriggeredAbility* t; TriggeredAbility* t;
queue<Targetable *> targets; queue<Targetable *> targets;
MTGAbility* destroyCondition; MTGAbility* destroyCondition;
GenericTriggeredAbility(int id, MTGCardInstance* _source, TriggeredAbility* _t, MTGAbility* a,MTGAbility* dc = NULL, Targetable* _target = NULL); GenericTriggeredAbility(int id, MTGCardInstance* _source, TriggeredAbility* _t, MTGAbility* a, MTGAbility* dc = NULL,
Targetable* _target = NULL);
virtual int trigger(); virtual int trigger();
virtual int triggerOnEvent(WEvent* e); virtual int triggerOnEvent(WEvent* e);
virtual int resolve(); virtual int resolve();
@@ -301,17 +354,19 @@ private:
int countCards(TargetChooser* tc, Player* player = NULL, int option = 0); int countCards(TargetChooser* tc, Player* player = NULL, int option = 0);
TriggeredAbility* parseTrigger(string s, string magicText, int id, Spell* spell, MTGCardInstance *card, Targetable* target); TriggeredAbility* parseTrigger(string s, string magicText, int id, Spell* spell, MTGCardInstance *card, Targetable* target);
int parseRestriction(string s); int parseRestriction(string s);
MTGAbility* getAlternateCost( string s, int id, Spell *spell, MTGCardInstance *card ); MTGAbility* getAlternateCost(string s, int id, Spell *spell, MTGCardInstance *card);
MTGAbility* getManaReduxAbility(string s, int id, Spell *spell, MTGCardInstance *card, MTGCardInstance *target); MTGAbility* getManaReduxAbility(string s, int id, Spell *spell, MTGCardInstance *card, MTGCardInstance *target);
public: public:
Counter* parseCounter(string s, MTGCardInstance* target, Spell* spell = NULL); Counter* parseCounter(string s, MTGCardInstance* target, Spell* spell = NULL);
int parsePowerToughness(string s, int* power, int* toughness); int parsePowerToughness(string s, int* power, int* toughness);
int getAbilities(vector<MTGAbility *>* v, Spell* spell, MTGCardInstance* card = NULL, int id = 0,MTGGameZone* dest = NULL); int getAbilities(vector<MTGAbility *>* v, Spell* spell, MTGCardInstance* card = NULL, int id = 0, MTGGameZone* dest = NULL);
MTGAbility* parseMagicLine(string s, int id, Spell* spell, MTGCardInstance *card, int activated = 0, int forceUEOT = 0,int oneShot = 0,int forceForever = 0, MTGGameZone* dest = NULL); MTGAbility* parseMagicLine(string s, int id, Spell* spell, MTGCardInstance *card, int activated = 0, int forceUEOT = 0,
int oneShot = 0, int forceForever = 0, MTGGameZone* dest = NULL);
int abilityEfficiency(MTGAbility* a, Player* p, int mode = MODE_ABILITY, TargetChooser* tc = NULL); int abilityEfficiency(MTGAbility* a, Player* p, int mode = MODE_ABILITY, TargetChooser* tc = NULL);
int magicText(int id, Spell* spell, MTGCardInstance* card = NULL, int mode = MODE_PUTINTOPLAY, TargetChooser* tc = NULL, MTGGameZone* dest = NULL); int magicText(int id, Spell* spell, MTGCardInstance* card = NULL, int mode = MODE_PUTINTOPLAY, TargetChooser* tc = NULL,
MTGGameZone* dest = NULL);
static int computeX(Spell* spell, MTGCardInstance* card); static int computeX(Spell* spell, MTGCardInstance* card);
static int computeXX(Spell* spell, MTGCardInstance* card); static int computeXX(Spell* spell, MTGCardInstance* card);
static MTGAbility* getCoreAbility(MTGAbility* a); static MTGAbility* getCoreAbility(MTGAbility* a);
@@ -323,12 +378,12 @@ public:
void addAbilities(int _id, Spell* spell); void addAbilities(int _id, Spell* spell);
}; };
class ActivatedAbilityTP: public ActivatedAbility
class ActivatedAbilityTP:public ActivatedAbility
{ {
public: public:
int who; int who;
ActivatedAbilityTP(int id, MTGCardInstance* card, Targetable* _target = NULL, ManaCost* cost=NULL, int doTap = 0, int who = TargetChooser::UNSET); ActivatedAbilityTP(int id, MTGCardInstance* card, Targetable* _target = NULL, ManaCost* cost = NULL, int doTap = 0, int who =
TargetChooser::UNSET);
Targetable* getTarget(); Targetable* getTarget();
}; };
@@ -343,9 +398,9 @@ public:
ManaCost* output; ManaCost* output;
int tap; int tap;
AManaProducer(int id, MTGCardInstance* card, Targetable* t, ManaCost* _output, ManaCost* _cost = NULL, int doTap = 1, int who = TargetChooser::UNSET); AManaProducer(int id, MTGCardInstance* card, Targetable* t, ManaCost* _output, ManaCost* _cost = NULL, int doTap = 1, int who = TargetChooser::UNSET);
int isReactingToClick(MTGCardInstance* _card, ManaCost* mana = NULL); int isReactingToClick(MTGCardInstance* _card, ManaCost* mana = NULL);
int resolve(); int resolve();
int reactToClick(MTGCardInstance* _card); int reactToClick(MTGCardInstance* _card);
const char* getMenuText(); const char* getMenuText();
~AManaProducer(); ~AManaProducer();
virtual AManaProducer* clone() const; virtual AManaProducer* clone() const;

View File

@@ -17,34 +17,32 @@ class CardPrimitive;
using namespace std; using namespace std;
class MTGCard { class MTGCard
protected: {
friend class MTGSetInfo; protected:
int mtgid; friend class MTGSetInfo;
char rarity; int mtgid;
char image_name[MTGCARD_NAME_SIZE]; char rarity;
int init(); char image_name[MTGCARD_NAME_SIZE];
int init();
public: public:
int setId; int setId;
CardPrimitive * data; CardPrimitive * data;
MTGCard();
MTGCard(int set_id);
MTGCard(MTGCard * source);
void setMTGId(int id); MTGCard();
void setRarity(char _rarity); MTGCard(int set_id);
//void setImageName( char * value); MTGCard(MTGCard * source);
void setPrimitive(CardPrimitive * cp);
int getMTGId() const; void setMTGId(int id);
int getId() const; void setRarity(char _rarity);
char getRarity() const; //void setImageName( char * value);
char * getImageName(); void setPrimitive(CardPrimitive * cp);
int getMTGId() const;
int getId() const;
char getRarity() const;
char * getImageName();
}; };
#endif #endif

View File

@@ -10,7 +10,6 @@
#include "Damage.h" #include "Damage.h"
#include "Targetable.h" #include "Targetable.h"
class MTGCardInstance; class MTGCardInstance;
class MTGPlayerCards; class MTGPlayerCards;
class MTGAbility; class MTGAbility;
@@ -24,149 +23,150 @@ struct Pos;
#include <list> #include <list>
using namespace std; using namespace std;
class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable { class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable
protected: {
int untapping; protected:
int nb_damages; int untapping;
string sample; int nb_damages;
int tapped; string sample;
int tapped;
int lifeOrig; int lifeOrig;
MTGPlayerCards * belongs_to; MTGPlayerCards * belongs_to;
MTGCardInstance * getNextPartner(); MTGCardInstance * getNextPartner();
void initMTGCI(); void initMTGCI();
int setDefenser(MTGCardInstance * c); int setDefenser(MTGCardInstance * c);
int addBlocker(MTGCardInstance * c); int addBlocker(MTGCardInstance * c);
int removeBlocker(MTGCardInstance * c); int removeBlocker(MTGCardInstance * c);
int init(); int init();
public: public:
int setAttacker(int value); int setAttacker(int value);
MTGGameZone * currentZone; MTGGameZone * currentZone;
Pos* view; Pos* view;
int X; int X;
int XX; int XX;
int alternateCostPaid[ManaCost::MANA_PAID_WITH_RETRACE + 1]; int alternateCostPaid[ManaCost::MANA_PAID_WITH_RETRACE + 1];
int paymenttype; int paymenttype;
int frozen; int frozen;
int sunburst; int sunburst;
int equipment; int equipment;
int reduxamount; int reduxamount;
int flanked; int flanked;
int regenerateTokens; int regenerateTokens;
int isToken; int isToken;
int stillInUse(); int stillInUse();
int didattacked; int didattacked;
int didblocked; int didblocked;
int notblocked; int notblocked;
int fresh; int fresh;
int MaxLevelUp; int MaxLevelUp;
Player * lastController; Player * lastController;
MTGGameZone * getCurrentZone(); MTGGameZone * getCurrentZone();
MTGGameZone * previousZone; MTGGameZone * previousZone;
MTGCardInstance * previous; MTGCardInstance * previous;
MTGCardInstance * next; MTGCardInstance * next;
int doDamageTest; int doDamageTest;
int summoningSickness; int summoningSickness;
// The recommended method to test for summoning Sickness ! // The recommended method to test for summoning Sickness !
int hasSummoningSickness(); int hasSummoningSickness();
MTGCardInstance * changeController(Player * newcontroller); MTGCardInstance * changeController(Player * newcontroller);
Player * owner; Player * owner;
Counters * counters; Counters * counters;
int typeAsTarget(){return TARGET_CARD;} int typeAsTarget()
const string getDisplayName() const; {
MTGCardInstance * target; return TARGET_CARD;
}
const string getDisplayName() const;
MTGCardInstance * target;
//types
void addType(char * type_text);
virtual void addType(int id);
void setType(const char * type_text);
void setSubtype(string value);
int removeType(string value, int removeAll = 0);
int removeType(int value, int removeAll = 0);
//types //dangerranking is a hint to Ai which creatures are the ones it should be targetting for effects.
void addType(char * type_text); int DangerRanking();
virtual void addType(int id); //Combat
void setType(const char * type_text); bool blocked; //Blocked this turn or not?
void setSubtype( string value); MTGCardInstance * defenser;
int removeType(string value, int removeAll = 0); list<MTGCardInstance *> blockers;
int removeType(int value, int removeAll = 0); int attacker;
int toggleDefenser(MTGCardInstance * opponent);
int raiseBlockerRankOrder(MTGCardInstance * blocker);
//dangerranking is a hint to Ai which creatures are the ones it should be targetting for effects. //Returns rank of the card in blockers if it is a blocker of this (starting at 1), 0 otherwise
int DangerRanking(); int getDefenserRank(MTGCardInstance * blocker);
//Combat int toggleAttacker();
bool blocked; //Blocked this turn or not? MTGCardInstance * banding; // If belongs to a band when attacking
MTGCardInstance * defenser; int canBlock();
list<MTGCardInstance *>blockers; int canBlock(MTGCardInstance * opponent);
int attacker; int canAttack();
int toggleDefenser(MTGCardInstance * opponent); int isAttacker();
int raiseBlockerRankOrder(MTGCardInstance * blocker); MTGCardInstance * isDefenser();
int initAttackersDefensers();
MTGCardInstance * getNextOpponent(MTGCardInstance * previous = NULL);
int nbOpponents();
int stepPower(CombatStep step);
int afterDamage();
int has(int ability);
int cleanup();
//Returns rank of the card in blockers if it is a blocker of this (starting at 1), 0 otherwise MTGCard * model;
int getDefenserRank(MTGCardInstance * blocker); MTGCardInstance();
int toggleAttacker(); MTGCardInstance(MTGCard * card, MTGPlayerCards * _belongs_to);
MTGCardInstance * banding; // If belongs to a band when attacking int regenerate();
int canBlock(); int triggerRegenerate();
int canBlock(MTGCardInstance * opponent); Player * controller();
int canAttack();
int isAttacker();
MTGCardInstance * isDefenser();
int initAttackersDefensers();
MTGCardInstance * getNextOpponent(MTGCardInstance * previous=NULL);
int nbOpponents();
int stepPower(CombatStep step);
int afterDamage();
int has(int ability);
int cleanup();
MTGCard * model; virtual ~MTGCardInstance();
MTGCardInstance(); int bury();
MTGCardInstance(MTGCard * card, MTGPlayerCards * _belongs_to); int destroy();
int regenerate();
int triggerRegenerate();
Player * controller();
virtual ~MTGCardInstance(); int addToToughness(int value);
int bury(); int setToughness(int value);
int destroy();
vector<TargetChooser *> protections;
int addProtection(TargetChooser * tc);
int removeProtection(TargetChooser *tc, int erase = 0);
int protectedAgainst(MTGCardInstance * card);
int addToToughness(int value); vector<TargetChooser *> cantBeBlockedBys;
int setToughness(int value); int addCantBeBlockedBy(TargetChooser * tc);
int removeCantBeBlockedBy(TargetChooser *tc, int erase = 0);
int cantBeBlockedBy(MTGCardInstance * card);
vector<TargetChooser *>protections; void copy(MTGCardInstance * card);
int addProtection(TargetChooser * tc);
int removeProtection(TargetChooser *tc, int erase = 0);
int protectedAgainst(MTGCardInstance * card);
vector<TargetChooser *>cantBeBlockedBys; void setUntapping();
int addCantBeBlockedBy(TargetChooser * tc); int isUntapping();
int removeCantBeBlockedBy(TargetChooser *tc, int erase = 0); int isTapped();
int cantBeBlockedBy(MTGCardInstance * card); void untap();
void tap();
void attemptUntap();
void copy(MTGCardInstance * card); void eventattacked();
void eventattackedAlone();
void eventattackednotblocked();
void eventattackedblocked();
void eventblocked();
void setUntapping(); int isInPlay();
int isUntapping(); JSample * getSample();
int isTapped();
void untap();
void tap();
void attemptUntap();
void eventattacked(); JQuad * getIcon();
void eventattackedAlone();
void eventattackednotblocked();
void eventattackedblocked();
void eventblocked();
int isInPlay(); ostream& toString(ostream&) const;
JSample * getSample();
JQuad * getIcon(); static MTGCardInstance AnyCard;
static MTGCardInstance NoCard;
ostream& toString(ostream&) const; static MTGCardInstance ExtraRules[2];
static MTGCardInstance AnyCard;
static MTGCardInstance NoCard;
static MTGCardInstance ExtraRules[2];
}; };
ostream& operator<<(ostream&, const MTGCardInstance&); ostream& operator<<(ostream&, const MTGCardInstance&);
#endif #endif

View File

@@ -7,7 +7,6 @@
#include "GameApp.h" #include "GameApp.h"
#include "WResourceManager.h" #include "WResourceManager.h"
#include <string> #include <string>
using std::string; using std::string;
@@ -15,145 +14,150 @@ class GameApp;
class MTGCard; class MTGCard;
class CardPrimitive; class CardPrimitive;
class MTGPack; class MTGPack;
class MTGSetInfo{ class MTGSetInfo
{
public: public:
MTGSetInfo(string _id); MTGSetInfo(string _id);
~MTGSetInfo(); ~MTGSetInfo();
string id; //Short name: 10E, RAV, etc. Automatic from folder. string id; //Short name: 10E, RAV, etc. Automatic from folder.
string author; //Author of set, for crediting mod makers, etc. string author; //Author of set, for crediting mod makers, etc.
string name; //Long name: Tenth Edition string name; //Long name: Tenth Edition
int block; //For future use by tournament mode, etc. int block; //For future use by tournament mode, etc.
int year; //The year the set was released. int year; //The year the set was released.
//TODO Way to group cards by name, rather than mtgid. //TODO Way to group cards by name, rather than mtgid.
void count(MTGCard * c); void count(MTGCard * c);
int totalCards(); int totalCards();
string getName(); string getName();
string getBlock(); string getBlock();
void processConfLine(string line); void processConfLine(string line);
enum { enum
//For memoized counts {
LAND = 0, //For memoized counts
COMMON = 1, LAND = 0,
UNCOMMON = 2, COMMON = 1,
RARE = 3, UNCOMMON = 2,
MAX_RARITY = 4, //For boosters, mythic is part of rare... always. RARE = 3,
MYTHIC = 4, MAX_RARITY = 4, //For boosters, mythic is part of rare... always.
TOTAL_CARDS = 5, MYTHIC = 4,
MAX_COUNT = 6 TOTAL_CARDS = 5,
}; MAX_COUNT = 6
};
MTGPack * mPack; //Does it use a specialized booster pack? MTGPack * mPack; //Does it use a specialized booster pack?
bool bZipped; //Is this set's images present as a zip file? bool bZipped; //Is this set's images present as a zip file?
bool bThemeZipped; //[...] in the theme? bool bThemeZipped; //[...] in the theme?
int counts[MTGSetInfo::MAX_COUNT]; int counts[MTGSetInfo::MAX_COUNT];
}; };
class MTGSets{ class MTGSets
{
public: public:
//These values have to be < 0 //These values have to be < 0
// A setID with a value >=0 will be looked into the sets table, // A setID with a value >=0 will be looked into the sets table,
// Negative values will be compared to these enums throughout the code (shop, filters...) // Negative values will be compared to these enums throughout the code (shop, filters...)
enum { enum
INTERNAL_SET = -1, {
ALL_SETS = -2, INTERNAL_SET = -1, ALL_SETS = -2,
}; };
friend class MTGSetInfo; friend class MTGSetInfo;
MTGSets(); MTGSets();
~MTGSets(); ~MTGSets();
int Add(const char * subtype);
int findSet(string value);
int findBlock(string s);
int size();
int getSetNum(MTGSetInfo*i); int Add(const char * subtype);
int findSet(string value);
int findBlock(string s);
int size();
int getSetNum(MTGSetInfo*i);
int operator[](string id); //Returns set id index, -1 for failure.
string operator[](int id); //Returns set id name, "" for failure.
MTGSetInfo* getInfo(int setID);
MTGSetInfo* randomSet(int blockId = -1, int atleast = -1); //Tries to match, otherwise 100% random unlocked set
int operator[](string id); //Returns set id index, -1 for failure.
string operator[](int id); //Returns set id name, "" for failure.
MTGSetInfo* getInfo(int setID);
MTGSetInfo* randomSet(int blockId = -1, int atleast = -1); //Tries to match, otherwise 100% random unlocked set
protected: protected:
vector<string> blocks; vector<string> blocks;
vector<MTGSetInfo*> setinfo; vector<MTGSetInfo*> setinfo;
}; };
extern MTGSets setlist; extern MTGSets setlist;
class MTGAllCards { class MTGAllCards
{
private: private:
MTGCard * tempCard; //used by parser MTGCard * tempCard; //used by parser
CardPrimitive * tempPrimitive; //used by parser CardPrimitive * tempPrimitive; //used by parser
int currentGrade; //used by Parser (we don't want an additional attribute for the primitives for that as it is only used at load time) int currentGrade; //used by Parser (we don't want an additional attribute for the primitives for that as it is only used at load time)
protected: protected:
int conf_read_mode; int conf_read_mode;
int colorsCount[Constants::MTG_NB_COLORS]; int colorsCount[Constants::MTG_NB_COLORS];
int total_cards; int total_cards;
GameApp * parent; GameApp * parent;
void init(); void init();
void initCounters(); void initCounters();
public: public:
enum { enum
READ_ANYTHING = 0, {
READ_CARD = 1, READ_ANYTHING = 0,
READ_METADATA = 2, READ_CARD = 1,
}; READ_METADATA = 2,
vector<int> ids; };
map<int, MTGCard *> collection; vector<int> ids;
map<string,CardPrimitive *>primitives; map<int, MTGCard *> collection;
MTGAllCards(); map<string, CardPrimitive *> primitives;
~MTGAllCards(); MTGAllCards();
MTGCard * _(int id); ~MTGAllCards();
void destroyAllCards(); MTGCard * _(int id);
MTGAllCards(const char * config_file, const char * set_name); void destroyAllCards();
MTGCard * getCardById(int id); MTGAllCards(const char * config_file, const char * set_name);
MTGCard * getCardByName(string name); MTGCard * getCardById(int id);
int load(const char * config_file, const char * setName = NULL, int autoload = 1); MTGCard * getCardByName(string name);
int countByType(const char * _type); int load(const char * config_file, const char * setName = NULL, int autoload = 1);
int countByColor(int color); int countByType(const char * _type);
int countBySet(int setId); int countByColor(int color);
int totalCards(); int countBySet(int setId);
int randomCardId(); int totalCards();
private: int randomCardId();
int processConfLine(string &s, MTGCard* card, CardPrimitive * primitive); private:
bool addCardToCollection(MTGCard * card, int setId); int processConfLine(string &s, MTGCard* card, CardPrimitive * primitive);
CardPrimitive * addPrimitive(CardPrimitive * primitive, MTGCard * card = NULL); bool addCardToCollection(MTGCard * card, int setId);
CardPrimitive * addPrimitive(CardPrimitive * primitive, MTGCard * card = NULL);
}; };
class MTGDeck
{
protected:
string filename;
int total_cards;
class MTGDeck{ public:
protected: MTGAllCards * database;
string filename; map<int, int> cards;
int total_cards; string meta_desc;
string meta_name;
int totalCards();
int totalPrice();
MTGDeck(MTGAllCards * _allcards);
MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only = 0);
int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const char * subtype = NULL,
int * colors = NULL, int nbcolors = 0);
int add(int cardid);
int add(MTGDeck * deck); // adds the contents of "deck" into myself
int complete();
int remove(int cardid);
int removeAll();
int add(MTGCard * card);
int remove(MTGCard * card);
int save();
int save(string destFileName, bool useExpandedDescriptions, string &deckTitle, string &deckDesc);
MTGCard * getCardById(int id);
public:
MTGAllCards * database;
map <int,int> cards;
string meta_desc;
string meta_name;
int totalCards();
int totalPrice();
MTGDeck(MTGAllCards * _allcards);
MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only = 0);
int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const char * subtype = NULL, int * colors = NULL, int nbcolors = 0);
int add(int cardid);
int add(MTGDeck * deck); // adds the contents of "deck" into myself
int complete();
int remove(int cardid);
int removeAll();
int add(MTGCard * card);
int remove(MTGCard * card);
int save();
int save(string destFileName, bool useExpandedDescriptions, string &deckTitle, string &deckDesc);
MTGCard * getCardById(int id);
}; };
#endif #endif

View File

@@ -9,222 +9,217 @@ const float DEFAULT_TEXT_FONT_SCALE = 1.0f;
using std::string; using std::string;
class Constants class Constants
{ {
public: public:
// Exception Codes // Exception Codes
/* Exception codes */ /* Exception codes */
const static int PARSER_FAILED_INSTANTIATION = 1000; const static int PARSER_FAILED_INSTANTIATION = 1000;
const static int PARSER_KEYWORD_NOT_MATCHED = 2000; const static int PARSER_KEYWORD_NOT_MATCHED = 2000;
const static int PARSER_INVALID_KEYWORD = 3000; const static int PARSER_INVALID_KEYWORD = 3000;
// color constants
static const string kManaColorless;
static const string kManaGreen;
static const string kManaBlue;
static const string kManaRed;
static const string kManaBlack;
static const string kManaWhite;
// color constants // alternative costs constants
static const string kManaColorless;
static const string kManaGreen;
static const string kManaBlue;
static const string kManaRed;
static const string kManaBlack;
static const string kManaWhite;
// alternative costs constants static const string kAlternativeKeyword;
static const string kBuyBackKeyword;
static const string kFlashBackKeyword;
static const string kRetraceKeyword;
static const string kKickerKeyword;
static const string kAlternativeKeyword; // used for deck statistics
static const string kBuyBackKeyword; static const int STATS_FOR_TURNS = 8;
static const string kFlashBackKeyword; static const int STATS_MAX_MANA_COST = 9;
static const string kRetraceKeyword;
static const string kKickerKeyword;
// used for deck statistics enum
static const int STATS_FOR_TURNS = 8; {
static const int STATS_MAX_MANA_COST = 9; MTG_COLOR_ARTIFACT = 0,
MTG_COLOR_GREEN = 1,
enum MTG_COLOR_BLUE = 2,
{ MTG_COLOR_RED = 3,
MTG_COLOR_ARTIFACT = 0, MTG_COLOR_BLACK = 4,
MTG_COLOR_GREEN = 1, MTG_COLOR_WHITE = 5,
MTG_COLOR_BLUE = 2, MTG_COLOR_LAND = 6,
MTG_COLOR_RED = 3,
MTG_COLOR_BLACK = 4,
MTG_COLOR_WHITE = 5,
MTG_COLOR_LAND = 6,
MTG_NB_COLORS = 7, MTG_NB_COLORS = 7,
MTG_UNCOLORED = 0,
MTG_FOREST = 1,
MTG_ISLAND = 2,
MTG_MOUNTAIN = 3,
MTG_SWAMP = 4,
MTG_PLAIN = 5,
MTG_UNCOLORED = 0, MTG_TYPE_CREATURE = 10,
MTG_FOREST = 1, MTG_TYPE_ARTIFACT = 11,
MTG_ISLAND = 2, MTG_TYPE_ENCHANTMENT = 12,
MTG_MOUNTAIN = 3, MTG_TYPE_SORCERY = 13,
MTG_SWAMP = 4, MTG_TYPE_LAND = 14,
MTG_PLAIN = 5, MTG_TYPE_INSTANT = 15,
MTG_PHASE_BEFORE_BEGIN = 0,
MTG_PHASE_UNTAP = 1,
MTG_PHASE_UPKEEP = 2,
MTG_PHASE_DRAW = 3,
MTG_PHASE_FIRSTMAIN = 4,
MTG_PHASE_COMBATBEGIN = 5,
MTG_PHASE_COMBATATTACKERS = 6,
MTG_PHASE_COMBATBLOCKERS = 7,
MTG_PHASE_COMBATDAMAGE = 8,
MTG_PHASE_COMBATEND = 9,
MTG_PHASE_SECONDMAIN = 10,
MTG_PHASE_ENDOFTURN = 11,
MTG_PHASE_EOT = 11,
MTG_PHASE_CLEANUP = 12,
MTG_PHASE_AFTER_EOT = 13,
NB_MTG_PHASES = 14,
MTG_TYPE_CREATURE = 10, TRAMPLE = 0,
MTG_TYPE_ARTIFACT = 11, FORESTWALK = 1,
MTG_TYPE_ENCHANTMENT = 12, ISLANDWALK = 2,
MTG_TYPE_SORCERY = 13, MOUNTAINWALK = 3,
MTG_TYPE_LAND = 14, SWAMPWALK = 4,
MTG_TYPE_INSTANT = 15, PLAINSWALK = 5,
FLYING = 6,
FIRSTSTRIKE = 7,
DOUBLESTRIKE = 8,
FEAR = 9,
FLASH = 10,
HASTE = 11,
LIFELINK = 12,
REACH = 13,
SHROUD = 14,
VIGILANCE = 15,
DEFENSER = 16,
DEFENDER = 16,
BANDING = 17,
PROTECTIONGREEN = 18,
PROTECTIONBLUE = 19,
PROTECTIONRED = 20,
PROTECTIONBLACK = 21,
PROTECTIONWHITE = 22,
UNBLOCKABLE = 23,
WITHER = 24,
PERSIST = 25,
RETRACE = 26,
EXALTED = 27,
NOFIZZLE = 28,
SHADOW = 29,
REACHSHADOW = 30,
FORESTHOME = 31,
ISLANDHOME = 32,
MOUNTAINHOME = 33,
SWAMPHOME = 34,
PLAINSHOME = 35,
CLOUD = 36,
CANTATTACK = 37,
MUSTATTACK = 38,
CANTBLOCK = 39,
DOESNOTUNTAP = 40,
OPPONENTSHROUD = 41,
INDESTRUCTIBLE = 42,
INTIMIDATE = 43,
DEATHTOUCH = 44,
HORSEMANSHIP = 45,
CANTREGEN = 46,
ONEBLOCKER = 47,
INFECT = 48,
POISONTOXIC = 49,
POISONTWOTOXIC = 50,
POISONTHREETOXIC = 51,
PHANTOM = 52,
WILTING = 53,
VIGOR = 54,
CHANGELING = 55,
ABSORB = 56,//this need to be coded for players too "If a source would deal damage"
TREASON = 57,
UNEARTH = 58,
CANTLOSE = 59,
CANTLIFELOSE = 60,
CANTMILLLOSE = 61,
CANTCASTCREATURE = 62,
CANTCAST = 63,
CANTCASTTWO = 64,
STORM = 65,
BOTHCANTCAST = 66,
BOTHNOCREATURE = 67,
ONLYONEBOTH = 68,
AFFINITYARTIFACTS = 69,
AFFINITYPLAINS = 70,
AFFINITYFOREST = 71,
AFFINITYISLAND = 72,
AFFINITYMOUNTAIN = 73,
AFFINITYSWAMP = 74,
AFFINITYGREENCREATURES = 75,
CANTWIN = 76,
NOMAXHAND = 77,
LEYLINE = 78,
PLAYERSHROUD = 79,
CONTROLLERSHROUD = 80,
SUNBURST = 81,
FLANKING = 82,
EXILEDEATH = 83,
NB_BASIC_ABILITIES = 84,
MTG_PHASE_BEFORE_BEGIN = 0, RARITY_S = 'S', //Special Rarity
MTG_PHASE_UNTAP = 1, RARITY_M = 'M', //Mythics
MTG_PHASE_UPKEEP = 2, RARITY_R = 'R', //Rares
MTG_PHASE_DRAW = 3, RARITY_U = 'U', //Uncommons
MTG_PHASE_FIRSTMAIN = 4, RARITY_C = 'C', //Commons
MTG_PHASE_COMBATBEGIN = 5, RARITY_L = 'L', //Lands
MTG_PHASE_COMBATATTACKERS = 6, RARITY_T = 'T', //Tokens
MTG_PHASE_COMBATBLOCKERS = 7,
MTG_PHASE_COMBATDAMAGE = 8,
MTG_PHASE_COMBATEND = 9,
MTG_PHASE_SECONDMAIN = 10,
MTG_PHASE_ENDOFTURN = 11,
MTG_PHASE_EOT = 11,
MTG_PHASE_CLEANUP = 12,
MTG_PHASE_AFTER_EOT = 13,
NB_MTG_PHASES = 14,
TRAMPLE = 0, ECON_NORMAL = 0, //Options default to 0.
FORESTWALK = 1, ECON_HARD = 1,
ISLANDWALK = 2, ECON_LUCK = 2,
MOUNTAINWALK = 3, ECON_EASY = 3,
SWAMPWALK = 4,
PLAINSWALK = 5,
FLYING = 6,
FIRSTSTRIKE = 7,
DOUBLESTRIKE = 8,
FEAR = 9,
FLASH = 10,
HASTE = 11,
LIFELINK = 12,
REACH = 13,
SHROUD = 14,
VIGILANCE = 15,
DEFENSER = 16,
DEFENDER = 16,
BANDING = 17,
PROTECTIONGREEN = 18,
PROTECTIONBLUE = 19,
PROTECTIONRED = 20,
PROTECTIONBLACK = 21,
PROTECTIONWHITE = 22,
UNBLOCKABLE = 23,
WITHER = 24,
PERSIST = 25,
RETRACE = 26,
EXALTED = 27,
NOFIZZLE = 28,
SHADOW = 29,
REACHSHADOW = 30,
FORESTHOME = 31,
ISLANDHOME = 32,
MOUNTAINHOME = 33,
SWAMPHOME = 34,
PLAINSHOME = 35,
CLOUD = 36,
CANTATTACK = 37,
MUSTATTACK = 38,
CANTBLOCK = 39,
DOESNOTUNTAP = 40,
OPPONENTSHROUD = 41,
INDESTRUCTIBLE = 42,
INTIMIDATE = 43,
DEATHTOUCH = 44,
HORSEMANSHIP = 45,
CANTREGEN = 46,
ONEBLOCKER = 47,
INFECT = 48,
POISONTOXIC = 49,
POISONTWOTOXIC = 50,
POISONTHREETOXIC = 51,
PHANTOM = 52,
WILTING = 53,
VIGOR = 54,
CHANGELING = 55,
ABSORB = 56,//this need to be coded for players too "If a source would deal damage"
TREASON = 57,
UNEARTH = 58,
CANTLOSE = 59,
CANTLIFELOSE = 60,
CANTMILLLOSE = 61,
CANTCASTCREATURE = 62,
CANTCAST = 63,
CANTCASTTWO = 64,
STORM = 65,
BOTHCANTCAST = 66,
BOTHNOCREATURE = 67,
ONLYONEBOTH = 68,
AFFINITYARTIFACTS = 69,
AFFINITYPLAINS = 70,
AFFINITYFOREST = 71,
AFFINITYISLAND = 72,
AFFINITYMOUNTAIN = 73,
AFFINITYSWAMP = 74,
AFFINITYGREENCREATURES = 75,
CANTWIN = 76,
NOMAXHAND = 77,
LEYLINE = 78,
PLAYERSHROUD = 79,
CONTROLLERSHROUD = 80,
SUNBURST = 81,
FLANKING = 82,
EXILEDEATH = 83,
NB_BASIC_ABILITIES = 84, //Price for singles
PRICE_1M = 3000,
PRICE_1R = 500,
PRICE_1S = 200,
PRICE_1U = 100,
PRICE_1C = 20,
PRICE_1L = 5,
//Price in booster
PRICE_BOOSTER = 700,
PRICE_MIXED_BOOSTER = 800,
CHANCE_CUSTOM_PACK = 15,
CHANCE_PURE_OVERRIDE = 50,
CHANCE_MIXED_OVERRIDE = 25,
RARITY_S = 'S', //Special Rarity GRADE_SUPPORTED = 0,
RARITY_M = 'M', //Mythics GRADE_BORDERLINE = 1,
RARITY_R = 'R', //Rares GRADE_UNOFFICIAL = 2,
RARITY_U = 'U', //Uncommons GRADE_CRAPPY = 3,
RARITY_C = 'C', //Commons GRADE_UNSUPPORTED = 4,
RARITY_L = 'L', //Lands GRADE_DANGEROUS = 5,
RARITY_T = 'T', //Tokens
ECON_NORMAL = 0, //Options default to 0. ASKIP_NONE = 0,
ECON_HARD = 1, ASKIP_SAFE = 1,
ECON_LUCK = 2, ASKIP_FULL = 2,
ECON_EASY = 3, };
//Price for singles static char MTGColorChars[];
PRICE_1M = 3000, static const char* MTGColorStrings[];
PRICE_1R = 500, static int _r[], _g[], _b[];
PRICE_1S = 200,
PRICE_1U = 100,
PRICE_1C = 20,
PRICE_1L = 5,
//Price in booster static map<string, int> MTGBasicAbilitiesMap;
PRICE_BOOSTER = 700, static const char* MTGBasicAbilities[];
PRICE_MIXED_BOOSTER = 800, static const char* MTGPhaseNames[];
CHANCE_CUSTOM_PACK = 15, static const char* MTGPhaseCodeNames[];
CHANCE_PURE_OVERRIDE = 50,
CHANCE_MIXED_OVERRIDE = 25,
GRADE_SUPPORTED = 0, static int GetBasicAbilityIndex(string mtgAbility);
GRADE_BORDERLINE = 1, static int GetColorStringIndex(string mtgColor);
GRADE_UNOFFICIAL = 2,
GRADE_CRAPPY = 3,
GRADE_UNSUPPORTED = 4,
GRADE_DANGEROUS = 5,
ASKIP_NONE=0,
ASKIP_SAFE=1,
ASKIP_FULL=2,
};
static char MTGColorChars[];
static const char* MTGColorStrings[];
static int _r[], _g[], _b[];
static map<string,int> MTGBasicAbilitiesMap;
static const char* MTGBasicAbilities[];
static const char* MTGPhaseNames[];
static const char* MTGPhaseCodeNames[];
static int GetBasicAbilityIndex(string mtgAbility);
static int GetColorStringIndex(string mtgColor);
}; };
#endif #endif

View File

@@ -7,19 +7,18 @@
#include <JGui.h> #include <JGui.h>
#include "WFont.h" #include "WFont.h"
class MTGGamePhase: public ActionElement
class MTGGamePhase: public ActionElement { {
protected: protected:
float animation; float animation;
int currentState; int currentState;
WFont * mFont; WFont * mFont;
public: public:
MTGGamePhase(int id); MTGGamePhase(int id);
virtual void Update(float dt); virtual void Update(float dt);
bool CheckUserInput(JButton key); bool CheckUserInput(JButton key);
virtual MTGGamePhase * clone() const; virtual MTGGamePhase * clone() const;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
#endif #endif

View File

@@ -14,161 +14,191 @@ class MTGDeck;
class MTGCardInstance; class MTGCardInstance;
class Player; class Player;
class MTGGameZone { class MTGGameZone
protected: {
protected:
public: public:
enum{ enum
ALL_ZONES = -1, {
ALL_ZONES = -1,
MY_GRAVEYARD = 11, MY_GRAVEYARD = 11,
OPPONENT_GRAVEYARD = 12, OPPONENT_GRAVEYARD = 12,
TARGET_OWNER_GRAVEYARD = 13, TARGET_OWNER_GRAVEYARD = 13,
TARGET_CONTROLLER_GRAVEYARD = 14, TARGET_CONTROLLER_GRAVEYARD = 14,
GRAVEYARD = 15, GRAVEYARD = 15,
OWNER_GRAVEYARD = 16, OWNER_GRAVEYARD = 16,
MY_BATTLEFIELD = 21, MY_BATTLEFIELD = 21,
OPPONENT_BATTLEFIELD = 22, OPPONENT_BATTLEFIELD = 22,
TARGET_OWNER_BATTLEFIELD = 23, TARGET_OWNER_BATTLEFIELD = 23,
TARGET_CONTROLLER_BATTLEFIELD = 24, TARGET_CONTROLLER_BATTLEFIELD = 24,
BATTLEFIELD = 25, BATTLEFIELD = 25,
OWNER_BATTLEFIELD = 26, OWNER_BATTLEFIELD = 26,
MY_HAND = 31, MY_HAND = 31,
OPPONENT_HAND = 32, OPPONENT_HAND = 32,
TARGET_OWNER_HAND = 33, TARGET_OWNER_HAND = 33,
TARGET_CONTROLLER_HAND = 34, TARGET_CONTROLLER_HAND = 34,
HAND = 35, HAND = 35,
OWNER_HAND = 36, OWNER_HAND = 36,
MY_EXILE = 41, MY_EXILE = 41,
OPPONENT_EXILE = 42, OPPONENT_EXILE = 42,
TARGET_OWNER_EXILE = 43, TARGET_OWNER_EXILE = 43,
TARGET_CONTROLLER_EXILE = 44, TARGET_CONTROLLER_EXILE = 44,
EXILE = 45, EXILE = 45,
OWNER_EXILE = 46, OWNER_EXILE = 46,
MY_LIBRARY = 51, MY_LIBRARY = 51,
OPPONENT_LIBRARY = 52, OPPONENT_LIBRARY = 52,
TARGET_OWNER_LIBRARY = 53, TARGET_OWNER_LIBRARY = 53,
TARGET_CONTROLLER_LIBRARY = 54, TARGET_CONTROLLER_LIBRARY = 54,
LIBRARY = 55, LIBRARY = 55,
OWNER_LIBRARY = 56, OWNER_LIBRARY = 56,
MY_STACK = 61, MY_STACK = 61,
OPPONENT_STACK = 62, OPPONENT_STACK = 62,
TARGET_OWNER_STACK = 63, TARGET_OWNER_STACK = 63,
TARGET_CONTROLLER_STACK = 64, TARGET_CONTROLLER_STACK = 64,
STACK = 65, STACK = 65,
OWNER_STACK = 66, OWNER_STACK = 66,
}; };
Player * owner; Player * owner;
//Both cards and cardsMap contain the cards of a zone. The long term objective is to get rid of the array //Both cards and cardsMap contain the cards of a zone. The long term objective is to get rid of the array
vector<MTGCardInstance *> cards; //[MTG_MAX_PLAYER_CARDS]; vector<MTGCardInstance *> cards; //[MTG_MAX_PLAYER_CARDS];
map<MTGCardInstance *,int> cardsMap; map<MTGCardInstance *, int> cardsMap;
int nb_cards; int nb_cards;
MTGGameZone(); MTGGameZone();
~MTGGameZone(); ~MTGGameZone();
void shuffle(); void shuffle();
void addCard(MTGCardInstance * card); void addCard(MTGCardInstance * card);
void debugPrint(); void debugPrint();
MTGCardInstance * removeCard(MTGCardInstance * card, int createCopy = 1); MTGCardInstance * removeCard(MTGCardInstance * card, int createCopy = 1);
MTGCardInstance * hasCard(MTGCardInstance * card); MTGCardInstance * hasCard(MTGCardInstance * card);
void cleanupPhase(); void cleanupPhase();
int countByType(const char * value); int countByType(const char * value);
MTGCardInstance * findByName(string name); MTGCardInstance * findByName(string name);
int hasAbility(int ability); //returns 1 if one of the cards in the zone has the ability, 0 otherwise int hasAbility(int ability); //returns 1 if one of the cards in the zone has the ability, 0 otherwise
int hasType(const char * value); //returns 1 if one of the cards in the zone has the type, 0 otherwise int hasType(const char * value); //returns 1 if one of the cards in the zone has the type, 0 otherwise
int hasColor(int value); //returns 1 if one of the cards in the zone has the color, 0 otherwise int hasColor(int value); //returns 1 if one of the cards in the zone has the color, 0 otherwise
int hasX(); int hasX();
void setOwner(Player * player); void setOwner(Player * player);
MTGCardInstance * lastCardDrawn; MTGCardInstance * lastCardDrawn;
static MTGGameZone * stringToZone(string zoneName, MTGCardInstance * source, MTGCardInstance * target); static MTGGameZone * stringToZone(string zoneName, MTGCardInstance * source, MTGCardInstance * target);
static int zoneStringToId(string zoneName); static int zoneStringToId(string zoneName);
static MTGGameZone *intToZone(int zoneId, MTGCardInstance * source = NULL,MTGCardInstance * target = NULL); static MTGGameZone *intToZone(int zoneId, MTGCardInstance * source = NULL, MTGCardInstance * target = NULL);
bool needShuffle; bool needShuffle;
virtual const char * getName(){return "zone";}; virtual const char * getName()
virtual ostream& toString(ostream&) const; {
return "zone";
}
;
virtual ostream& toString(ostream&) const;
}; };
class MTGLibrary: public MTGGameZone { class MTGLibrary: public MTGGameZone
public: {
void shuffleTopToBottom(int nbcards); public:
virtual ostream& toString(ostream&) const; void shuffleTopToBottom(int nbcards);
const char * getName(){return "library";} virtual ostream& toString(ostream&) const;
const char * getName()
{
return "library";
}
}; };
class MTGGraveyard: public MTGGameZone { class MTGGraveyard: public MTGGameZone
public: {
virtual ostream& toString(ostream&) const; public:
const char * getName(){return "graveyard";} virtual ostream& toString(ostream&) const;
const char * getName()
{
return "graveyard";
}
}; };
class MTGHand: public MTGGameZone { class MTGHand: public MTGGameZone
public: {
virtual ostream& toString(ostream&) const; public:
const char * getName(){return "hand";} virtual ostream& toString(ostream&) const;
const char * getName()
{
return "hand";
}
}; };
class MTGRemovedFromGame: public MTGGameZone { class MTGRemovedFromGame: public MTGGameZone
public: {
virtual ostream& toString(ostream&) const; public:
const char * getName(){return "exile";} virtual ostream& toString(ostream&) const;
const char * getName()
{
return "exile";
}
}; };
class MTGStack: public MTGGameZone { class MTGStack: public MTGGameZone
public: {
virtual ostream& toString(ostream&) const; public:
const char * getName(){return "stack";} virtual ostream& toString(ostream&) const;
const char * getName()
{
return "stack";
}
}; };
class MTGInPlay: public MTGGameZone { class MTGInPlay: public MTGGameZone
public: {
void untapAll(); public:
MTGCardInstance * getNextAttacker(MTGCardInstance * previous); void untapAll();
virtual ostream& toString(ostream&) const; MTGCardInstance * getNextAttacker(MTGCardInstance * previous);
const char * getName(){return "battlefield";} virtual ostream& toString(ostream&) const;
const char * getName()
{
return "battlefield";
}
}; };
class MTGPlayerCards
{
protected:
void init();
class MTGPlayerCards { public:
protected: MTGLibrary * library;
void init(); MTGGraveyard * graveyard;
MTGHand * hand;
MTGInPlay * inPlay;
MTGInPlay * battlefield; //alias to inPlay
public: MTGStack * stack;
MTGLibrary * library; MTGRemovedFromGame * removedFromGame;
MTGGraveyard * graveyard; MTGRemovedFromGame * exile; //alias to removedFromZone
MTGHand * hand; MTGGameZone * garbage;
MTGInPlay * inPlay; MTGGameZone * temp;
MTGInPlay * battlefield; //alias to inPlay
MTGStack * stack; MTGPlayerCards(int * idList, int idListSize);
MTGRemovedFromGame * removedFromGame; MTGPlayerCards(MTGDeck * deck);
MTGRemovedFromGame * exile; //alias to removedFromZone ~MTGPlayerCards();
MTGGameZone * garbage; void initGame(int shuffle = 1, int draw = 1);
MTGGameZone * temp; void OptimizedHand(Player * who, int amount = 7, int lands = 3, int creatures = 0, int othercards = 4);
void setOwner(Player * player);
MTGPlayerCards(int * idList, int idListSize); void discardRandom(MTGGameZone * from, MTGCardInstance * source);
MTGPlayerCards(MTGDeck * deck); void drawFromLibrary();
~MTGPlayerCards(); void showHand();
void initGame(int shuffle = 1, int draw = 1); void resetLibrary();
void OptimizedHand(Player * who,int amount = 7,int lands = 3,int creatures = 0,int othercards = 4); void initDeck(MTGDeck * deck);
void setOwner(Player * player); MTGCardInstance * putInGraveyard(MTGCardInstance * card);
void discardRandom(MTGGameZone * from,MTGCardInstance * source); MTGCardInstance * putInExile(MTGCardInstance * card);
void drawFromLibrary(); MTGCardInstance * putInLibrary(MTGCardInstance * card);
void showHand(); MTGCardInstance * putInHand(MTGCardInstance * card);
void resetLibrary(); MTGCardInstance * putInZone(MTGCardInstance * card, MTGGameZone * from, MTGGameZone * to);
void initDeck(MTGDeck * deck); int isInPlay(MTGCardInstance * card);
MTGCardInstance * putInGraveyard(MTGCardInstance * card);
MTGCardInstance * putInExile(MTGCardInstance * card);
MTGCardInstance * putInLibrary(MTGCardInstance * card);
MTGCardInstance * putInHand(MTGCardInstance * card);
MTGCardInstance * putInZone(MTGCardInstance * card, MTGGameZone * from, MTGGameZone * to);
int isInPlay(MTGCardInstance * card);
}; };
ostream& operator<<(ostream&, const MTGGameZone&); ostream& operator<<(ostream&, const MTGGameZone&);

View File

@@ -3,86 +3,138 @@
class ShopBooster; class ShopBooster;
class MTGPackEntry{ class MTGPackEntry
{
public: public:
virtual ~MTGPackEntry() {}; virtual ~MTGPackEntry()
virtual int addCard(WSrcCards * pool,MTGDeck * to) = 0; {
int copies; }
;
virtual int addCard(WSrcCards * pool, MTGDeck * to) = 0;
int copies;
}; };
class MTGPackEntryRandom: public MTGPackEntry{ class MTGPackEntryRandom: public MTGPackEntry
{
public: public:
MTGPackEntryRandom() {filter = ""; copies=1;}; MTGPackEntryRandom()
MTGPackEntryRandom(string f, int c=1) {filter = f; copies = c;}; {
int addCard(WSrcCards * pool,MTGDeck * to); filter = "";
string filter; copies = 1;
}
;
MTGPackEntryRandom(string f, int c = 1)
{
filter = f;
copies = c;
}
;
int addCard(WSrcCards * pool, MTGDeck * to);
string filter;
}; };
class MTGPackEntrySpecific: public MTGPackEntry{ class MTGPackEntrySpecific: public MTGPackEntry
{
public: public:
int addCard(WSrcCards * pool,MTGDeck * to); int addCard(WSrcCards * pool, MTGDeck * to);
MTGCard * card; MTGCard * card;
}; };
class MTGPackEntryNothing: public MTGPackEntry{ class MTGPackEntryNothing: public MTGPackEntry
{
public: public:
int addCard(WSrcCards * pool,MTGDeck * to) {return 0;}; int addCard(WSrcCards * pool, MTGDeck * to)
{
return 0;
}
;
}; };
class MTGPackSlot{ class MTGPackSlot
{
public: public:
~MTGPackSlot(); ~MTGPackSlot();
int add(WSrcCards * ocean, MTGDeck * to, int carryover); int add(WSrcCards * ocean, MTGDeck * to, int carryover);
void addEntry(MTGPackEntry*item); void addEntry(MTGPackEntry*item);
int copies; int copies;
string pool; string pool;
vector<MTGPackEntry*> entries; vector<MTGPackEntry*> entries;
}; };
class MTGPack{ class MTGPack
{
public: public:
friend class MTGPacks; friend class MTGPacks;
friend class ShopBooster; friend class ShopBooster;
friend class MTGSetInfo; friend class MTGSetInfo;
bool meetsRequirements(); //Check if pool contains locked cards. bool meetsRequirements(); //Check if pool contains locked cards.
bool isUnlocked(); bool isUnlocked();
bool isValid() {return bValid;}; bool isValid()
void load(string filename); {
int assemblePack(MTGDeck * to); return bValid;
}
MTGPack() {bValid = false; unlockStatus = 0; price=Constants::PRICE_BOOSTER;}; ;
MTGPack(string s) {bValid = false; load(s); unlockStatus = 0;}; void load(string filename);
~MTGPack(); int assemblePack(MTGDeck * to);
string getName();
string getSort() {return sort;}; MTGPack()
int getPrice() {return price;}; {
static WSrcCards * getPool(string poolstr); bValid = false;
unlockStatus = 0;
price = Constants::PRICE_BOOSTER;
}
;
MTGPack(string s)
{
bValid = false;
load(s);
unlockStatus = 0;
}
;
~MTGPack();
string getName();
string getSort()
{
return sort;
}
;
int getPrice()
{
return price;
}
;
static WSrcCards * getPool(string poolstr);
protected: protected:
void countCards(); void countCards();
string name; //Name of the pack. string name; //Name of the pack.
string type; //"Booster", "Deck", "Whatever" string type; //"Booster", "Deck", "Whatever"
string pool; //The starting pool. string pool; //The starting pool.
string sort; //The sorting method. string sort; //The sorting method.
string check; //Unlock requirements. string check; //Unlock requirements.
string desc; //Big card description. string desc; //Big card description.
bool bValid; bool bValid;
int unlockStatus; int unlockStatus;
int price; //Base price. int price; //Base price.
int minCards, maxCards; int minCards, maxCards;
vector<MTGPackSlot*> slotss; vector<MTGPackSlot*> slotss;
}; };
class MTGPacks{ class MTGPacks
{
public: public:
~MTGPacks(); ~MTGPacks();
MTGPack * randomPack(int key=0); MTGPack * randomPack(int key = 0);
void loadAll(); void loadAll();
int size() {return (int)packs.size();}; int size()
void refreshUnlocked(); {
return (int) packs.size();
static MTGPack * getDefault(); }
;
void refreshUnlocked();
static MTGPack * getDefault();
private: private:
static MTGPack defaultBooster; static MTGPack defaultBooster;
vector<MTGPack*> packs; vector<MTGPack*> packs;
}; };
#endif #endif

View File

@@ -39,10 +39,10 @@ class MTGAlternativeCostRule: public MTGAbility
public: public:
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int isReactingToClick(MTGCardInstance * card, ManaCost * mana, ManaCost *alternateManaCost); int isReactingToClick(MTGCardInstance * card, ManaCost * mana, ManaCost *alternateManaCost);
int reactToClick(MTGCardInstance * card, ManaCost * alternateManaCost, int paymentType = ManaCost::MANA_PAID); int reactToClick(MTGCardInstance * card, ManaCost * alternateManaCost, int paymentType = ManaCost::MANA_PAID);
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
int testDestroy(); int testDestroy();
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
MTGAlternativeCostRule(int _id); MTGAlternativeCostRule(int _id);

View File

@@ -4,7 +4,6 @@
#include "utils.h" #include "utils.h"
#include "MTGDefinitions.h" #include "MTGDefinitions.h"
class ManaCostHybrid; class ManaCostHybrid;
class ExtraCosts; class ExtraCosts;
class ExtraCost; class ExtraCost;
@@ -12,87 +11,90 @@ class MTGAbility;
class MTGCardInstance; class MTGCardInstance;
class Player; class Player;
class ManaCost{ class ManaCost
protected: {
int cost[Constants::MTG_NB_COLORS+1]; protected:
ManaCostHybrid * hybrids[10]; int cost[Constants::MTG_NB_COLORS + 1];
unsigned int nbhybrids; ManaCostHybrid * hybrids[10];
int extraCostsIsCopy; unsigned int nbhybrids;
int extraCostsIsCopy;
public:
enum{
MANA_UNPAID = 0,
MANA_PAID = 1,
MANA_PAID_WITH_KICKER = 2,
MANA_PAID_WITH_ALTERNATIVE = 3,
MANA_PAID_WITH_BUYBACK = 4,
MANA_PAID_WITH_FLASHBACK = 5,
MANA_PAID_WITH_RETRACE = 6
}; public:
ExtraCosts * extraCosts; enum
ManaCost * kicker; {
ManaCost * alternative; MANA_UNPAID = 0,
ManaCost * BuyBack; MANA_PAID = 1,
ManaCost * FlashBack; MANA_PAID_WITH_KICKER = 2,
ManaCost * Retrace; MANA_PAID_WITH_ALTERNATIVE = 3,
static ManaCost * parseManaCost(string value, ManaCost * _manacost = NULL, MTGCardInstance * c = NULL); MANA_PAID_WITH_BUYBACK = 4,
virtual void init(); MANA_PAID_WITH_FLASHBACK = 5,
void x(); MANA_PAID_WITH_RETRACE = 6
int hasX();
ManaCost(int _cost[], int nb_elems = 1);
ManaCost();
~ManaCost();
ManaCost(ManaCost * _manaCost);
void copy (ManaCost * _manaCost);
int isNull();
int getConvertedCost();
string toString();
int getCost(int color);
//Returns NULL if i is greater than nbhybrids
ManaCostHybrid * getHybridCost(unsigned int i);
int hasColor(int color);
int remove (int color, int value);
int add(int color, int value);
// };
// Extra Costs (sacrifice,counters...) ExtraCosts * extraCosts;
// ManaCost * kicker;
int addExtraCost(ExtraCost * _cost); ManaCost * alternative;
int setExtraCostsAction(MTGAbility * action, MTGCardInstance * card); ManaCost * BuyBack;
int isExtraPaymentSet(); ManaCost * FlashBack;
int canPayExtra(); ManaCost * Retrace;
int doPayExtra(); static ManaCost * parseManaCost(string value, ManaCost * _manacost = NULL, MTGCardInstance * c = NULL);
virtual void init();
void x();
int hasX();
ManaCost(int _cost[], int nb_elems = 1);
ManaCost();
~ManaCost();
ManaCost(ManaCost * _manaCost);
void copy(ManaCost * _manaCost);
int isNull();
int getConvertedCost();
string toString();
int getCost(int color);
//Returns NULL if i is greater than nbhybrids
ManaCostHybrid * getHybridCost(unsigned int i);
int hasColor(int color);
int remove(int color, int value);
int add(int color, int value);
int addHybrid(int c1, int v1, int c2, int v2); //
int tryToPayHybrids(ManaCostHybrid * _hybrids[], int _nbhybrids, int diff[]); // Extra Costs (sacrifice,counters...)
void randomDiffHybrids(ManaCost * _cost, int diff[]); //
int add(ManaCost * _cost); int addExtraCost(ExtraCost * _cost);
int pay (ManaCost * _cost); int setExtraCostsAction(MTGAbility * action, MTGCardInstance * card);
int isExtraPaymentSet();
int canPayExtra();
int doPayExtra();
//return 1 if _cost can be paid with current data, 0 otherwise int addHybrid(int c1, int v1, int c2, int v2);
int canAfford(ManaCost * _cost); int tryToPayHybrids(ManaCostHybrid * _hybrids[], int _nbhybrids, int diff[]);
void randomDiffHybrids(ManaCost * _cost, int diff[]);
int add(ManaCost * _cost);
int pay(ManaCost * _cost);
int isPositive(); //return 1 if _cost can be paid with current data, 0 otherwise
ManaCost * Diff(ManaCost * _cost); int canAfford(ManaCost * _cost);
int isPositive();
ManaCost * Diff(ManaCost * _cost);
#ifdef WIN32 #ifdef WIN32
void Dump(); void Dump();
#endif #endif
}; };
std::ostream& operator<<(std::ostream& out, const ManaCost& m); std::ostream& operator<<(std::ostream& out, const ManaCost& m);
class ManaPool:public ManaCost{ class ManaPool: public ManaCost
{
protected: protected:
Player * player; Player * player;
public: public:
void init(); void init();
ManaPool(Player * player); ManaPool(Player * player);
ManaPool(ManaCost * _manaCost, Player * player); ManaPool(ManaCost * _manaCost, Player * player);
int remove (int color, int value); int remove(int color, int value);
int add(int color, int value, MTGCardInstance * source = NULL); int add(int color, int value, MTGCardInstance * source = NULL);
int add(ManaCost * _cost, MTGCardInstance * source = NULL); int add(ManaCost * _cost, MTGCardInstance * source = NULL);
int pay (ManaCost * _cost); int pay(ManaCost * _cost);
}; };
#endif #endif

View File

@@ -1,17 +1,18 @@
#ifndef _MANACOST_HYBRID_H_ #ifndef _MANACOST_HYBRID_H_
#define _MANACOST_HYBRID_H_ #define _MANACOST_HYBRID_H_
class ManaCostHybrid{ class ManaCostHybrid
public: {
int color1; public:
int color2; int color1;
int value1; int color2;
int value2; int value1;
ManaCostHybrid(); int value2;
int hasColor(int color); ManaCostHybrid();
ManaCostHybrid(int c1,int v1,int c2,int v2); int hasColor(int color);
void init(int c1,int v1,int c2,int v2); ManaCostHybrid(int c1, int v1, int c2, int v2);
int getConvertedCost(); void init(int c1, int v1, int c2, int v2);
int getConvertedCost();
}; };
#endif #endif

View File

@@ -14,34 +14,39 @@ class hgeParticleSystem;
class MenuItem: public JGuiObject class MenuItem: public JGuiObject
{ {
private: private:
bool mHasFocus; bool mHasFocus;
WFont *mFont; WFont *mFont;
string mText; string mText;
float mX; float mX;
float mY; float mY;
int updatedSinceLastRender; int updatedSinceLastRender;
float lastDt; float lastDt;
float mScale; float mScale;
float mTargetScale; float mTargetScale;
JQuad * onQuad; JQuad * onQuad;
JQuad * offQuad; JQuad * offQuad;
hgeParticleSystem* mParticleSys; hgeParticleSystem* mParticleSys;
public:
MenuItem(int id, WFont *font, string text, float x, float y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleQuad, bool hasFocus = false);
~MenuItem();
virtual void Render();
virtual void Update(float dt);
public: virtual void Entering();
MenuItem(int id, WFont *font, string text, float x, float y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleQuad, bool hasFocus = false); virtual bool Leaving(JButton key);
~MenuItem(); virtual bool ButtonPressed();
virtual void Render(); virtual bool getTopLeft(float& top, float& left)
virtual void Update(float dt); {
top = mY;
left = mX;
return true;
}
;
virtual void Entering(); virtual ostream& toString(ostream& out) const;
virtual bool Leaving(JButton key);
virtual bool ButtonPressed();
virtual bool getTopLeft(float& top, float& left) {top = mY; left = mX; return true;};
virtual ostream& toString(ostream& out) const;
}; };
#endif #endif

View File

@@ -9,52 +9,51 @@
#include <map> #include <map>
#include <vector> #include <vector>
// private class only used by Navigator, see implementation file // private class only used by Navigator, see implementation file
class CardZone; class CardZone;
class Navigator : public CardSelectorBase class Navigator: public CardSelectorBase
{ {
public: public:
Navigator(DuelLayers* inDuelLayers); Navigator(DuelLayers* inDuelLayers);
virtual ~Navigator(); virtual ~Navigator();
// Inherited functions from GuiLayer // Inherited functions from GuiLayer
bool CheckUserInput(JButton inKey); bool CheckUserInput(JButton inKey);
bool CheckUserInput(int x, int y); bool CheckUserInput(int x, int y);
void Update(float dt); void Update(float dt);
void Render(); void Render();
//Limitor operations //Limitor operations
void PushLimitor(); void PushLimitor();
void PopLimitor(); void PopLimitor();
void Limit(LimitorFunctor<PlayGuiObject>* inLimitor, CardView::SelectorZone inZone); void Limit(LimitorFunctor<PlayGuiObject>* inLimitor, CardView::SelectorZone inZone);
virtual void Add(PlayGuiObject*); virtual void Add(PlayGuiObject*);
virtual void Remove(PlayGuiObject*); virtual void Remove(PlayGuiObject*);
virtual void Push() {} virtual void Push() {}
virtual void Pop() {} virtual void Pop() {}
protected: protected:
PlayGuiObject* GetCurrentCard(); PlayGuiObject* GetCurrentCard();
/** /**
** Helper function that translates a card type into an internal zone ID (used as the index for the card zone map) ** Helper function that translates a card type into an internal zone ID (used as the index for the card zone map)
*/ */
int CardToCardZone(PlayGuiObject* card); int CardToCardZone(PlayGuiObject* card);
void HandleKeyStroke(JButton inKey); void HandleKeyStroke(JButton inKey);
private: private:
std::map<int, CardZone*> mCardZones; std::map<int, CardZone*> mCardZones;
CardZone* mCurrentZone; CardZone* mCurrentZone;
Pos mDrawPosition; Pos mDrawPosition;
DuelLayers* mDuelLayers; DuelLayers* mDuelLayers;
bool mLimitorEnabled; bool mLimitorEnabled;
std::stack<CardZone*> mCurrentZoneStack; std::stack<CardZone*> mCurrentZoneStack;
}; };
#endif //NAVIGATOR_H #endif //NAVIGATOR_H

View File

@@ -1,11 +1,11 @@
#ifndef _OSD_H_ #ifndef _OSD_H_
#define _OSD_H_ #define _OSD_H_
class OSDLayer : public PlayGuiObjectController class OSDLayer: public PlayGuiObjectController
{ {
virtual void Update(float dt); virtual void Update(float dt);
virtual bool CheckUserInput(JButton key); virtual bool CheckUserInput(JButton key);
virtual void Render(); virtual void Render();
}; };
#endif #endif

View File

@@ -20,144 +20,206 @@ using std::string;
#define PATH_MAX 4096 #define PATH_MAX 4096
#endif #endif
class OptionItem: public WGuiItem{ class OptionItem: public WGuiItem
{
public: public:
OptionItem( int _id, string _displayValue); OptionItem(int _id, string _displayValue);
virtual ~OptionItem() {}; virtual ~OptionItem() {};
//Accessors //Accessors
virtual int getId() {return id;}; virtual int getId()
virtual void setId(int _id){id = _id;}; {
return id;
}
virtual void setId(int _id)
{
id = _id;
}
protected: protected:
int id; int id;
}; };
class OptionInteger:public OptionItem{ class OptionInteger: public OptionItem
public: {
int value; //Current value. public:
int defValue; //Default value. int value; //Current value.
string strDefault; //What to call the default value. int defValue; //Default value.
int maxValue, increment, minValue; string strDefault; //What to call the default value.
int maxValue, increment, minValue;
OptionInteger(int _id, string _displayValue, int _maxValue = 1, int _increment = 1, int _defV = 0, string _sDef = "", int _minValue = 0); OptionInteger(int _id, string _displayValue, int _maxValue = 1, int _increment = 1, int _defV = 0, string _sDef = "", int _minValue = 0);
virtual void Reload()
{
if (id != INVALID_OPTION)
value = options[id].number;
}
virtual bool Changed()
{
return value != options[id].number;
}
virtual void Render();
virtual void setData();
virtual void updateValue()
{
value += increment;
if (value > maxValue)
value = minValue;
}
virtual void Reload() {if(id != INVALID_OPTION) value = options[id].number;};
virtual bool Changed() {return value != options[id].number;};
virtual void Render();
virtual void setData();
virtual void updateValue(){value+=increment; if (value>maxValue) value=minValue;};
}; };
class OptionSelect:public OptionItem{ class OptionSelect: public OptionItem
public: {
size_t value; public:
vector<string> selections; size_t value;
vector<string> selections;
virtual void addSelection(string s); virtual void addSelection(string s);
OptionSelect(int _id, string _displayValue): OptionItem(_id, _displayValue) {value = 0;}; OptionSelect(int _id, string _displayValue) :
virtual void Reload(){initSelections();}; OptionItem(_id, _displayValue)
virtual void Render(); {
virtual bool Selectable(); value = 0;
virtual void Entering(JButton key); }
virtual bool Changed() {return (value != prior_value);}; ;
virtual void setData(); virtual void Reload()
virtual void initSelections(); {
virtual void updateValue(){value++; if (value > selections.size() - 1) value=0;}; initSelections();
protected: }
size_t prior_value; ;
}; virtual void Render();
virtual bool Selectable();
virtual void Entering(JButton key);
virtual bool Changed()
{
return (value != prior_value);
}
class OptionLanguage: public OptionSelect{ virtual void setData();
public: virtual void initSelections();
OptionLanguage(string _displayValue); virtual void updateValue()
{
virtual void addSelection(string s) {addSelection(s,s);}; value++;
virtual void addSelection(string s,string show); if (value > selections.size() - 1)
virtual void initSelections(); value = 0;
virtual void confirmChange(bool confirmed); }
virtual void Reload(); ;
virtual bool Visible();
virtual bool Selectable();
virtual void setData();
protected: protected:
vector<string> actual_data; size_t prior_value;
}; };
class OptionThemeStyle: public OptionSelect{ class OptionLanguage: public OptionSelect
public: {
virtual bool Visible(); public:
virtual void Reload(); OptionLanguage(string _displayValue);
virtual void confirmChange(bool confirmed);
OptionThemeStyle(string _displayValue);
};
class OptionDirectory:public OptionSelect{
public:
virtual void Reload();
OptionDirectory(string root, int id, string displayValue, const string type);
protected:
const string root;
const string type;
};
class OptionTheme:public OptionDirectory{
private:
static const string DIRTESTER;
public:
OptionTheme(OptionThemeStyle * style = NULL);
JQuad * getImage();
virtual void updateValue();
virtual float getHeight();
virtual void Render();
virtual void confirmChange(bool confirmed);
virtual bool Visible();
virtual void addSelection(string s)
{
addSelection(s, s);
}
;
virtual void addSelection(string s, string show);
virtual void initSelections();
virtual void confirmChange(bool confirmed);
virtual void Reload();
virtual bool Visible();
virtual bool Selectable();
virtual void setData();
protected: protected:
OptionThemeStyle * ts; vector<string> actual_data;
string author;
bool bChecked;
}; };
class OptionProfile:public OptionDirectory{ class OptionThemeStyle: public OptionSelect
private: {
static const string DIRTESTER; public:
public: virtual bool Visible();
OptionProfile(GameApp * _app, JGuiListener * jgl); virtual void Reload();
virtual void addSelection(string s); virtual void confirmChange(bool confirmed);
virtual bool Selectable() {return canSelect;}; OptionThemeStyle(string _displayValue);
virtual bool Changed() {return (initialValue != value);}; };
virtual void Entering(JButton key); class OptionDirectory: public OptionSelect
virtual void Reload(); {
virtual void Render(); public:
virtual void initSelections(); virtual void Reload();
virtual void confirmChange(bool confirmed); OptionDirectory(string root, int id, string displayValue, const string type);
virtual void updateValue(); protected:
void populate(); const string root;
const string type;
};
class OptionTheme: public OptionDirectory
{
private: private:
GameApp * app; static const string DIRTESTER;
JGuiListener * listener; public:
bool canSelect; OptionTheme(OptionThemeStyle * style = NULL);
string preview; JQuad * getImage();
size_t initialValue; virtual void updateValue();
virtual float getHeight();
virtual void Render();
virtual void confirmChange(bool confirmed);
virtual bool Visible();
protected:
OptionThemeStyle * ts;
string author;
bool bChecked;
}; };
class OptionKey : public WGuiItem, public KeybGrabber { class OptionProfile: public OptionDirectory
public: {
OptionKey(GameStateOptions* g, LocalKeySym, JButton); private:
LocalKeySym from; static const string DIRTESTER;
JButton to; public:
virtual void Render(); OptionProfile(GameApp * _app, JGuiListener * jgl);
virtual void Update(float); virtual void addSelection(string s);
virtual void Overlay(); virtual bool Selectable()
virtual bool CheckUserInput(JButton key); {
virtual void KeyPressed(LocalKeySym key); return canSelect;
virtual bool isModal(); }
virtual void ButtonPressed(int controllerId, int controlId); ;
virtual bool Visible(); virtual bool Changed()
virtual bool Selectable(); {
protected: return (initialValue != value);
bool grabbed; }
GameStateOptions* g; ;
SimpleMenu* btnMenu; virtual void Entering(JButton key);
virtual void Reload();
virtual void Render();
virtual void initSelections();
virtual void confirmChange(bool confirmed);
virtual void updateValue();
void populate();
private:
GameApp * app;
JGuiListener * listener;
bool canSelect;
string preview;
size_t initialValue;
};
class OptionKey: public WGuiItem, public KeybGrabber
{
public:
OptionKey(GameStateOptions* g, LocalKeySym, JButton);
LocalKeySym from;
JButton to;
virtual void Render();
virtual void Update(float);
virtual void Overlay();
virtual bool CheckUserInput(JButton key);
virtual void KeyPressed(LocalKeySym key);
virtual bool isModal();
virtual void ButtonPressed(int controllerId, int controlId);
virtual bool Visible();
virtual bool Selectable();
protected:
bool grabbed;
GameStateOptions* g;
SimpleMenu* btnMenu;
}; };
#endif #endif

View File

@@ -6,36 +6,52 @@
using namespace std; using namespace std;
/* /*
The class that handles the phases of a turn The class that handles the phases of a turn
*/ */
class Player; class Player;
typedef enum { BLOCKERS, TRIGGERS, ORDER, FIRST_STRIKE, END_FIRST_STRIKE, DAMAGE, END_DAMAGE } CombatStep; typedef enum
class Phase{ {
public: BLOCKERS,
int id; TRIGGERS,
Player * player; ORDER,
Phase(int id, Player *player):id(id),player(player){}; FIRST_STRIKE,
END_FIRST_STRIKE,
DAMAGE,
END_DAMAGE
} CombatStep;
class Phase
{
public:
int id;
Player * player;
Phase(int id, Player *player) :
id(id), player(player)
{
}
;
}; };
class PhaseRing{ class PhaseRing
{
private: private:
static bool extraDamagePhase(int id); static bool extraDamagePhase(int id);
public: public:
list<Phase *> ring; list<Phase *> ring;
list<Phase *>::iterator current; list<Phase *>::iterator current;
Phase * getCurrentPhase(); Phase * getCurrentPhase();
Phase * forward(bool sendEvents = true); Phase * forward(bool sendEvents = true);
Phase * goToPhase(int id, Player * player,bool sendEvents = true); Phase * goToPhase(int id, Player * player, bool sendEvents = true);
PhaseRing(Player* players[], int nbPlayers=2); PhaseRing(Player* players[], int nbPlayers = 2);
~PhaseRing(); ~PhaseRing();
int addPhase(Phase * phase); int addPhase(Phase * phase);
int addPhaseBefore(int id, Player* player,int after_id, Player * after_player, int allOccurences = 1); int addPhaseBefore(int id, Player* player, int after_id, Player * after_player, int allOccurences = 1);
int removePhase (int id, Player * player, int allOccurences = 1); int removePhase(int id, Player * player, int allOccurences = 1);
static const char * phaseName(int id); static const char * phaseName(int id);
static int phaseStrToInt(string s); static int phaseStrToInt(string s);
}; };
#endif #endif

View File

@@ -1,6 +1,6 @@
/* /*
A class for all interactive objects in the play area (cards, avatars, etc...) A class for all interactive objects in the play area (cards, avatars, etc...)
*/ */
#ifndef _PLAYGUIOBJECT_H_ #ifndef _PLAYGUIOBJECT_H_
#define _PLAYGUIOBJECT_H_ #define _PLAYGUIOBJECT_H_
@@ -16,27 +16,53 @@
#include "WEvent.h" #include "WEvent.h"
#include "Pos.h" #include "Pos.h"
class PlayGuiObject: public JGuiObject, public JGuiListener, public Pos{ class PlayGuiObject: public JGuiObject, public JGuiListener, public Pos
protected: {
protected:
public: public:
int wave; int wave;
float mHeight; float mHeight;
float defaultHeight; float defaultHeight;
bool mHasFocus; bool mHasFocus;
int type; int type;
virtual void Entering(){mHasFocus = true; zoom = 1.4f;}; virtual void Entering()
virtual bool Leaving(JButton key){mHasFocus = false; zoom = 1.0; return true;}; {
virtual bool CheckUserInput(JButton key) {return false;}; mHasFocus = true;
virtual bool ButtonPressed(){return true;}; zoom = 1.4f;
virtual void Render(); }
virtual void Update(float dt); ;
PlayGuiObject(float desiredHeight, float x, float y, bool hasFocus); virtual bool Leaving(JButton key)
PlayGuiObject(float desiredHeight, const Pos& ref, bool hasFocus); {
virtual void ButtonPressed(int controllerId, int controlId){}; mHasFocus = false;
virtual bool getTopLeft(float& top, float& left) {top = actY; left = actX; return true;}; zoom = 1.0;
virtual ~PlayGuiObject(){}; return true;
vector<Effect*> effects; }
;
virtual bool CheckUserInput(JButton key)
{
return false;
}
;
virtual bool ButtonPressed()
{
return true;
}
;
virtual void Render();
virtual void Update(float dt);
PlayGuiObject(float desiredHeight, float x, float y, bool hasFocus);
PlayGuiObject(float desiredHeight, const Pos& ref, bool hasFocus);
virtual void ButtonPressed(int controllerId, int controlId) {}
virtual bool getTopLeft(float& top, float& left)
{
top = actY;
left = actX;
return true;
}
;
virtual ~PlayGuiObject() {};
vector<Effect*> effects;
}; };
#endif #endif

View File

@@ -5,19 +5,26 @@
#include "GuiLayers.h" #include "GuiLayers.h"
class PlayGuiObjectController : public GuiLayer{ class PlayGuiObjectController: public GuiLayer
protected: {
float last_user_move; protected:
int getClosestItem(int direction); float last_user_move;
int getClosestItem(int direction, float tolerance); int getClosestItem(int direction);
static int showBigCards;// 0 hide, 1 show, 2 show text int getClosestItem(int direction, float tolerance);
public: static int showBigCards;// 0 hide, 1 show, 2 show text
virtual void Update(float dt); public:
virtual bool CheckUserInput(JButton key); virtual void Update(float dt);
PlayGuiObjectController(){last_user_move=0;}; virtual bool CheckUserInput(JButton key);
virtual void Render(){GuiLayer::Render();}; PlayGuiObjectController()
{
last_user_move = 0;
}
;
virtual void Render()
{
GuiLayer::Render();
}
;
}; };
#endif #endif

View File

@@ -19,7 +19,9 @@ protected:
public: public:
enum ENUM_PLAY_MODE enum ENUM_PLAY_MODE
{ {
MODE_TEST_SUITE, MODE_HUMAN, MODE_AI, MODE_TEST_SUITE,
MODE_HUMAN,
MODE_AI
}; };
JTexture * mAvatarTex; JTexture * mAvatarTex;

View File

@@ -4,18 +4,19 @@
#include "MTGDeck.h" #include "MTGDeck.h"
#include "Tasks.h" #include "Tasks.h"
class PlayerData{ class PlayerData
protected: {
void init(); protected:
public: void init();
int credits; public:
map<string,string>storySaves; int credits;
MTGDeck * collection; map<string, string> storySaves;
TaskList * taskList; MTGDeck * collection;
PlayerData(); //This doesn't init the collection, do not use it to manipulate the player's collection TaskList * taskList;
PlayerData(MTGAllCards * allcards); PlayerData(); //This doesn't init the collection, do not use it to manipulate the player's collection
~PlayerData(); PlayerData(MTGAllCards * allcards);
int save(); ~PlayerData();
int save();
}; };
#endif #endif

View File

@@ -3,14 +3,15 @@
#include "JGE.h" #include "JGE.h"
struct Pos { struct Pos
float actX, actY, actZ, actT, actA; {
float x, y, zoom, t, alpha; float actX, actY, actZ, actT, actA;
Pos(float, float, float, float, float); float x, y, zoom, t, alpha;
virtual void Update(float dt); Pos(float, float, float, float, float);
void UpdateNow(); virtual void Update(float dt);
virtual void Render(); void UpdateNow();
void Render(JQuad*); virtual void Render();
void Render(JQuad*);
}; };
#endif // _POS_H_ #endif // _POS_H_

View File

@@ -8,23 +8,28 @@
class MTGAllCards; class MTGAllCards;
class PriceList{ class PriceList
private: {
MTGAllCards * collection; private:
string filename; MTGAllCards * collection;
map<int,int> prices; string filename;
static int randomKey; map<int, int> prices;
public: static int randomKey;
PriceList(const char * file, MTGAllCards * _collection); public:
~PriceList(); PriceList(const char * file, MTGAllCards * _collection);
int save(); ~PriceList();
int getSellPrice(int cardid); int save();
int getPurchasePrice(int cardid); int getSellPrice(int cardid);
int getPrice(int cardId); int getPurchasePrice(int cardid);
int setPrice(int cardId,int price); int getPrice(int cardId);
int getOtherPrice(int amt); int setPrice(int cardId, int price);
static float difficultyScalar(float price, int cardid=0); int getOtherPrice(int amt);
static void updateKey() {randomKey = rand();}; static float difficultyScalar(float price, int cardid = 0);
static void updateKey()
{
randomKey = rand();
}
;
}; };
#endif #endif

View File

@@ -9,35 +9,42 @@ using namespace std;
class TargetChooser; class TargetChooser;
class MTGAbility; class MTGAbility;
class ReplacementEffect { class ReplacementEffect
{
public: public:
virtual WEvent * replace (WEvent * e) {return e;}; virtual WEvent * replace(WEvent * e)
virtual ~ReplacementEffect(){}; {
return e;
}
;
virtual ~ReplacementEffect() {}
}; };
class REDamagePrevention: public ReplacementEffect { class REDamagePrevention: public ReplacementEffect
{
protected: protected:
MTGAbility * source; MTGAbility * source;
TargetChooser * tcSource; TargetChooser * tcSource;
TargetChooser * tcTarget; TargetChooser * tcTarget;
int damage; int damage;
bool oneShot; bool oneShot;
int typeOfDamage; int typeOfDamage;
public: public:
REDamagePrevention(MTGAbility * _source, TargetChooser *_tcSource = NULL,TargetChooser *_tcTarget = NULL, int _damage = -1, bool _oneShot = true, int typeOfDamage = DAMAGE_ALL_TYPES); REDamagePrevention(MTGAbility * _source, TargetChooser *_tcSource = NULL, TargetChooser *_tcTarget = NULL, int _damage = -1, bool _oneShot = true, int typeOfDamage = DAMAGE_ALL_TYPES);
WEvent * replace (WEvent *e); WEvent * replace(WEvent *e);
~REDamagePrevention(); ~REDamagePrevention();
}; };
class ReplacementEffects { class ReplacementEffects
{
protected: protected:
list<ReplacementEffect *>modifiers; list<ReplacementEffect *> modifiers;
public: public:
ReplacementEffects(); ReplacementEffects();
WEvent * replace(WEvent *e); WEvent * replace(WEvent *e);
int add(ReplacementEffect * re); int add(ReplacementEffect * re);
int remove (ReplacementEffect * re); int remove(ReplacementEffect * re);
~ReplacementEffects(); ~ReplacementEffects();
}; };
#endif #endif

View File

@@ -13,70 +13,74 @@ class MTGCardInstance;
#define MAX_RULES_CARDS 4096; #define MAX_RULES_CARDS 4096;
class RulesPlayerZone{ class RulesPlayerZone
public: {
vector<int> cards;
void add(int cardid);
RulesPlayerZone();
void cleanup();
};
class RulesPlayerData{
public:
vector <string> extraRules;
int life;
int poisonCount;
int damageCount;
int preventable;
string avatar;
ManaCost * manapool;
RulesPlayerZone zones[5];
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(int isAI);
Player * loadPlayerRandom(int isAI, int mode);
Player * initPlayer(int playerId);
MTGDeck * buildDeck( int playerId);
int strToGameMode(string s);
public: public:
enum { vector<int> cards;
PARSE_UNDEFINED, void add(int cardid);
PARSE_INIT, RulesPlayerZone();
PARSE_PLAYER1, void cleanup();
PARSE_PLAYER2, };
PARSE_PLAYERS
};
string bg; class RulesPlayerData
{
public:
vector<string> extraRules;
int life;
int poisonCount;
int damageCount;
int preventable;
string avatar;
ManaCost * manapool;
RulesPlayerZone zones[5];
RulesPlayerData();
~RulesPlayerData();
void cleanup();
Rules(string filename, string bg = ""); };
int load(string filename);
int gamemode; class RulesState
void initPlayers(); {
void addExtraRules(); public:
void initGame(); int phase;
void cleanup(); int player;
vector <string> extraRules; void parsePlayerState(int playerId, string s);
RulesState initState; RulesState();
static int getMTGId(string name); RulesPlayerData playerData[2];
static MTGCardInstance * getCardByMTGId(int mtgid); 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
};
string bg;
Rules(string filename, string bg = "");
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);
}; };

View File

@@ -1,6 +1,6 @@
/* /*
A class for very simple menus structure A class for very simple menus structure
*/ */
#ifndef _SIMPLEMENU_H_ #ifndef _SIMPLEMENU_H_
#define _SIMPLEMENU_H_ #define _SIMPLEMENU_H_
@@ -9,39 +9,42 @@
#include "WFont.h" #include "WFont.h"
#include "hge/hgeparticle.h" #include "hge/hgeparticle.h"
class SimpleMenu:public JGuiController{ class SimpleMenu: public JGuiController
private: {
float mHeight, mWidth, mX, mY; private:
int fontId; float mHeight, mWidth, mX, mY;
std::string title; int fontId;
int displaytitle; std::string title;
int maxItems,startId; int displaytitle;
float selectionT, selectionY; int maxItems, startId;
float timeOpen; float selectionT, selectionY;
bool mClosed; float timeOpen;
bool mClosed;
static JQuad *spadeR, *spadeL, *jewel, *side; static JQuad *spadeR, *spadeL, *jewel, *side;
static JTexture *spadeRTex, *spadeLTex, *jewelTex, *sideTex; static JTexture *spadeRTex, *spadeLTex, *jewelTex, *sideTex;
static WFont* titleFont; static WFont* titleFont;
static hgeParticleSystem* stars; static hgeParticleSystem* stars;
inline void MogrifyJewel(); inline void MogrifyJewel();
void drawHorzPole(float x, float y, float width); void drawHorzPole(float x, float y, float width);
void drawVertPole(float x, float y, float height); void drawVertPole(float x, float y, float height);
public: public:
bool autoTranslate; bool autoTranslate;
SimpleMenu(int id, JGuiListener* listener, int fontId, float x, float y, const char * _title = "", int _maxItems = 7); SimpleMenu(int id, JGuiListener* listener, int fontId, float x, float y, const char * _title = "", int _maxItems = 7);
virtual ~SimpleMenu(); virtual ~SimpleMenu();
void Render(); void Render();
void Update(float dt); void Update(float dt);
void Add(int id, const char * Text,string desc = "", bool forceFocus = false); void Add(int id, const char * Text, string desc = "", bool forceFocus = false);
void Close(); void Close();
float selectionTargetY; float selectionTargetY;
bool isClosed() { return mClosed; } bool isClosed()
static void destroy(); {
return mClosed;
}
static void destroy();
}; };
#endif #endif

View File

@@ -11,37 +11,42 @@ using std::string;
#define SCALE_SELECTED 1.2f #define SCALE_SELECTED 1.2f
#define SCALE_NORMAL 1.0f #define SCALE_NORMAL 1.0f
class SimpleMenuItem: public JGuiObject class SimpleMenuItem: public JGuiObject
{ {
private: private:
bool mHasFocus; bool mHasFocus;
SimpleMenu* parent; SimpleMenu* parent;
int fontId; int fontId;
string mText; string mText;
float mScale; float mScale;
float mTargetScale; float mTargetScale;
public: public:
string desc; string desc;
SimpleMenuItem(SimpleMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus = false, bool autoTranslate = false); SimpleMenuItem(SimpleMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus = false, bool autoTranslate = false);
float mX; float mX;
float mY; float mY;
void Relocate(float x, float y); void Relocate(float x, float y);
float GetWidth(); float GetWidth();
bool hasFocus(); bool hasFocus();
void RenderWithOffset(float yOffset); void RenderWithOffset(float yOffset);
virtual void Render(); virtual void Render();
virtual void Update(float dt); virtual void Update(float dt);
virtual void Entering(); virtual void Entering();
virtual bool Leaving(JButton key); virtual bool Leaving(JButton key);
virtual bool ButtonPressed(); virtual bool ButtonPressed();
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
virtual bool getTopLeft(float& top, float& left) {top = mY; left = mX; return true;}; virtual bool getTopLeft(float& top, float& left)
{
top = mY;
left = mX;
return true;
}
;
}; };
#endif #endif

View File

@@ -19,51 +19,54 @@ enum SIMPLE_KEYS{
KPD_INPUT = 255, KPD_INPUT = 255,
}; };
struct SimpleKey{ struct SimpleKey
SimpleKey( string _ds, int _id); {
string displayValue; SimpleKey(string _ds, int _id);
unsigned char id; string displayValue;
unsigned char adjacency[4]; unsigned char id;
unsigned char adjacency[4];
}; };
class SimplePad{ class SimplePad
public: {
friend class GameSettings; public:
friend class GameSettings;
string buffer; string buffer;
string title; string title;
unsigned int cursorPos(); unsigned int cursorPos();
bool isActive() {return bActive;}; bool isActive()
void Render(); {
void Update(float dt); return bActive;
void pressKey(unsigned char id); }
;
void Render();
void Update(float dt);
void pressKey(unsigned char id);
SimplePad();
~SimplePad();
float mX, mY;
SimplePad(); private:
~SimplePad(); void linkKeys(int from, int to, int dir);
SimpleKey * Add(string display, unsigned char id);
void MoveSelection(unsigned char dir);
void Start(string value, string * _dest = NULL);
string Finish();
float mX, mY; bool bActive;
bool bCapslock;
private: bool bShowCancel, bShowNumpad;
void linkKeys(int from, int to, int dir); bool bCanceled;
SimpleKey * Add(string display, unsigned char id); int nbitems;
void MoveSelection(unsigned char dir); unsigned int cursor;
void Start(string value, string * _dest=NULL); int selected;
string Finish(); int priorKey; //The prior key from those places.
SimpleKey * keys[KPD_MAX];
bool bActive; string * dest;
bool bCapslock; string original; //For cancelling.
bool bShowCancel, bShowNumpad;
bool bCanceled;
int nbitems;
unsigned int cursor;
int selected;
int priorKey; //The prior key from those places.
SimpleKey * keys[KPD_MAX];
string * dest;
string original; //For cancelling.
}; };
#endif #endif

View File

@@ -35,12 +35,17 @@ private:
public: public:
bool autoTranslate; bool autoTranslate;
SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title = "", DeckMetaData* deckInfo = NULL, MTGAllCards * collection = NULL); SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title = "", DeckMetaData* deckInfo = NULL, MTGAllCards * collection = NULL);
~SimplePopup(void); ~SimplePopup(void);
void drawBoundingBox( float x, float y, float width, float height ); void drawBoundingBox(float x, float y, float width, float height);
bool isClosed() { return mClosed; } bool isClosed()
MTGAllCards* getCollection() { return mCollection; } {
return mClosed;
}
MTGAllCards* getCollection()
{
return mCollection;
}
void Render(); void Render();
void Update(DeckMetaData* deckMetaData); void Update(DeckMetaData* deckMetaData);

View File

@@ -11,143 +11,168 @@ class GameObserver;
class MTGDeck; class MTGDeck;
#define CAMPAIGNS_FOLDER "campaigns/" #define CAMPAIGNS_FOLDER "campaigns/"
class StoryDialogElement: public JGuiObject
class StoryDialogElement:public JGuiObject { {
public: public:
float mX; float mX;
float mY; float mY;
StoryDialogElement(float x, float y, int id = 0); StoryDialogElement(float x, float y, int id = 0);
void Entering(){}; void Entering()
bool Leaving(JButton key) {return false;}; {
bool ButtonPressed() {return false;}; }
bool hasFocus() {return false;}; ;
virtual float getHeight() = 0; bool Leaving(JButton key)
{
return false;
}
;
bool ButtonPressed()
{
return false;
}
;
bool hasFocus()
{
return false;
}
;
virtual float getHeight() = 0;
}; };
class StoryText:public StoryDialogElement { class StoryText: public StoryDialogElement
public : {
string text;
int align;
int font;
StoryText(string text, float mX, float mY, string align = "center", int font = 0, int id = 0);
void Render();
void Update(float dt);
virtual ostream& toString(ostream& out) const;
float getHeight();
};
class StoryImage:public StoryDialogElement {
public :
string img;
StoryImage(string img, float mX, float mY);
void Render();
void Update(float dt);
virtual ostream& toString(ostream& out) const;
float getHeight();
};
class StoryReward:public StoryText {
public: public:
enum { string text;
STORY_REWARD_CREDITS, int align;
STORY_REWARD_SET, int font;
STORY_REWARD_CARD, StoryText(string text, float mX, float mY, string align = "center", int font = 0, int id = 0);
};
int rewardDone; void Render();
string value; void Update(float dt);
int type; virtual ostream& toString(ostream& out) const;
float getHeight();
StoryReward(string _type, string _value, string text, float _mX, float _mY, string align = "center", int font = 0, int id = 0); };
void Update(float dt); class StoryImage: public StoryDialogElement
void Render(); {
public:
static bool rewardSoundPlayed; string img;
static bool rewardsEnabled; StoryImage(string img, float mX, float mY);
static MTGDeck * collection; void Render();
void Update(float dt);
virtual ostream& toString(ostream& out) const;
float getHeight();
}; };
class StoryChoice:public StoryText { class StoryReward: public StoryText
{
public: public:
string pageId; enum
{
STORY_REWARD_CREDITS,
STORY_REWARD_SET,
STORY_REWARD_CARD,
};
bool mHasFocus; int rewardDone;
float mScale; string value;
float mTargetScale; int type;
StoryChoice(string id, string text, int JGOid, float mX, float mY, string _align, int _font, bool hasFocus);
void Render();
void Update(float dt);
void Entering(); StoryReward(string _type, string _value, string text, float _mX, float _mY, string align = "center", int font = 0, int id = 0);
bool Leaving(JButton key); void Update(float dt);
bool ButtonPressed(); void Render();
bool hasFocus();
virtual ostream& toString(ostream& out) const; static bool rewardSoundPlayed;
float getHeight(); static bool rewardsEnabled;
static MTGDeck * collection;
};
class StoryChoice: public StoryText
{
public:
string pageId;
bool mHasFocus;
float mScale;
float mTargetScale;
StoryChoice(string id, string text, int JGOid, float mX, float mY, string _align, int _font, bool hasFocus);
void Render();
void Update(float dt);
void Entering();
bool Leaving(JButton key);
bool ButtonPressed();
bool hasFocus();
virtual ostream& toString(ostream& out) const;
float getHeight();
}; };
class StoryFlow; class StoryFlow;
class StoryPage { class StoryPage
{
protected: protected:
string safeAttribute(TiXmlElement* element, string attribute); string safeAttribute(TiXmlElement* element, string attribute);
public:
StoryFlow * mParent;
string musicFile;
StoryPage(StoryFlow * mParent);
virtual void Update(float dt)=0;
virtual void Render()=0;
virtual ~StoryPage(){};
int loadElement(TiXmlElement* element);
};
class StoryDialog:public StoryPage, public JGuiListener,public JGuiController {
private:
vector<StoryDialogElement *>graphics;
void RenderElement(StoryDialogElement * elmt);
public: public:
StoryDialog(TiXmlElement* el,StoryFlow * mParent); StoryFlow * mParent;
~StoryDialog(); string musicFile;
void Update(float dt); StoryPage(StoryFlow * mParent);
void Render(); virtual void Update(float dt)=0;
void ButtonPressed(int,int); virtual void Render()=0;
virtual ~StoryPage()
static float currentY; {
static float previousY; }
;
int loadElement(TiXmlElement* element);
}; };
class StoryDialog: public StoryPage, public JGuiListener, public JGuiController
{
private:
vector<StoryDialogElement *> graphics;
void RenderElement(StoryDialogElement * elmt);
public:
StoryDialog(TiXmlElement* el, StoryFlow * mParent);
~StoryDialog();
void Update(float dt);
void Render();
void ButtonPressed(int, int);
static float currentY;
static float previousY;
};
class Rules; class Rules;
class StoryDuel:public StoryPage { class StoryDuel: public StoryPage
{
public: public:
string pageId; string pageId;
string onWin, onLose; string onWin, onLose;
string bg; //background file string bg; //background file
GameObserver * game; GameObserver * game;
Rules * rules; Rules * rules;
StoryDuel(TiXmlElement* el,StoryFlow * mParent); StoryDuel(TiXmlElement* el, StoryFlow * mParent);
virtual ~StoryDuel(); virtual ~StoryDuel();
void Update(float dt); void Update(float dt);
void Render(); void Render();
void init(); void init();
}; };
class StoryFlow{ class StoryFlow
{
private: private:
map<string,StoryPage *>pages; map<string, StoryPage *> pages;
bool parse(string filename); bool parse(string filename);
StoryPage * loadPage(TiXmlElement* element); StoryPage * loadPage(TiXmlElement* element);
bool _gotoPage(string id); bool _gotoPage(string id);
public: public:
string currentPageId; string currentPageId;
string folder; string folder;
StoryFlow(string folder); StoryFlow(string folder);
~StoryFlow(); ~StoryFlow();
bool gotoPage(string id); bool gotoPage(string id);
bool loadPageId(string id); bool loadPageId(string id);
void Update(float dt); void Update(float dt);
void Render(); void Render();
}; };
#endif #endif

View File

@@ -1,32 +1,36 @@
class WStyle{ class WStyle
{
public: public:
friend class StyleManager; friend class StyleManager;
string stylized(string filename); string stylized(string filename);
protected: protected:
map<string,string> mapping; map<string, string> mapping;
}; };
class WStyleRule{ class WStyleRule
{
public: public:
string filter; //The condition string filter; //The condition
string style; //The style to use. string style; //The style to use.
}; };
class MTGDeck; class MTGDeck;
class StyleManager{ class StyleManager
{
public: public:
friend class OptionThemeStyle; friend class OptionThemeStyle;
friend class OptionTheme; friend class OptionTheme;
StyleManager(); StyleManager();
~StyleManager(); ~StyleManager();
void determineActive(MTGDeck * p1, MTGDeck * p2); void determineActive(MTGDeck * p1, MTGDeck * p2);
WStyle * get(); WStyle * get();
protected: protected:
int topRule; int topSize; int topRule;
int playerSrc; int topSize;
int playerSrc;
void loadRules(); void loadRules();
void killRules(); void killRules();
vector<WStyleRule*> rules; vector<WStyleRule*> rules;
string activeStyle; string activeStyle;
map<string,WStyle*> styles; map<string, WStyle*> styles;
}; };

View File

@@ -1,38 +1,36 @@
#ifndef _SUBTYPES_H_ #ifndef _SUBTYPES_H_
#define _SUBTYPES_H_ #define _SUBTYPES_H_
#include <string> #include <string>
#include <map> #include <map>
#include <vector> #include <vector>
using namespace std; using namespace std;
class Subtypes
class Subtypes{ {
public: public:
//A list of commonly used types //A list of commonly used types
enum { enum
TYPE_CREATURE = 1, {
TYPE_ENCHANTMENT = 2, TYPE_CREATURE = 1,
TYPE_SORCERY = 3, TYPE_ENCHANTMENT = 2,
TYPE_INSTANT = 4, TYPE_SORCERY = 3,
TYPE_LAND = 5, TYPE_INSTANT = 4,
TYPE_ARTIFACT = 6, TYPE_LAND = 5,
TYPE_LEGENDARY = 7, TYPE_ARTIFACT = 6,
LAST_TYPE = TYPE_LEGENDARY, TYPE_LEGENDARY = 7,
}; LAST_TYPE = TYPE_LEGENDARY,
};
protected:
protected: map<string, int> values;
map<string,int> values; vector<string> valuesById;
vector<string> valuesById; public:
public: static Subtypes * subtypesList;
static Subtypes * subtypesList; Subtypes();
Subtypes(); int find(const char * subtype, bool forceAdd = true);
int find(const char * subtype, bool forceAdd = true); int find(string subtype, bool forceAdd = true);
int find(string subtype, bool forceAdd = true); string find(unsigned int id);
string find(unsigned int id);
}; };
#endif #endif

View File

@@ -20,160 +20,197 @@ class Damageable;
class Targetable; class Targetable;
class CardDescriptor; class CardDescriptor;
class TargetChooser: public TargetsList
{
protected:
int forceTargetListReady;
public:
class TargetChooser: public TargetsList { enum
protected: {
int forceTargetListReady; UNSET = 0,
OPPONENT = -1,
public: CONTROLLER = 1,
enum{ TARGET_CONTROLLER = 2,
UNSET = 0, OWNER = 3
OPPONENT = -1, };
CONTROLLER = 1,
TARGET_CONTROLLER = 2,
OWNER = 3
};
bool other; bool other;
TargetChooser(MTGCardInstance * card = NULL, int _maxtargets = -1, bool other = false); TargetChooser(MTGCardInstance * card = NULL, int _maxtargets = -1, bool other = false);
MTGCardInstance * source; MTGCardInstance * source;
MTGCardInstance * targetter; //Optional, usually equals source, used for protection from... MTGCardInstance * targetter; //Optional, usually equals source, used for protection from...
int maxtargets; //Set to -1 for "unlimited" int maxtargets; //Set to -1 for "unlimited"
bool validTargetsExist(); bool validTargetsExist();
virtual int setAllZones(){return 0;} virtual int setAllZones()
virtual bool targetsZone(MTGGameZone * z){return false;}; {
int ForceTargetListReady(); return 0;
int targetsReadyCheck(); }
virtual int addTarget(Targetable * target); virtual bool targetsZone(MTGGameZone * z)
virtual bool canTarget(Targetable * _target); {
virtual int full(){if (maxtargets != -1 && cursor>=maxtargets) {return 1;} else{return 0;}}; return false;
virtual int ready(){return cursor;}; }
virtual ~TargetChooser(){}; ;
int targetListSet(); int ForceTargetListReady();
virtual TargetChooser* clone() const = 0; int targetsReadyCheck();
virtual int addTarget(Targetable * target);
virtual bool canTarget(Targetable * _target);
virtual int full()
{
if (maxtargets != -1 && cursor >= maxtargets)
{
return 1;
}
else
{
return 0;
}
}
;
virtual int ready()
{
return cursor;
}
;
virtual ~TargetChooser()
{
}
;
int targetListSet();
virtual TargetChooser* clone() const = 0;
}; };
class TargetChooserFactory
class TargetChooserFactory{ {
public:
TargetChooser * createTargetChooser(string s, MTGCardInstance * card, MTGAbility * ability = NULL);
TargetChooser * createTargetChooser(MTGCardInstance * card);
};
class TargetZoneChooser:public TargetChooser{
public:
int zones[15];
int nbzones;
int init(int * _zones, int _nbzones);
bool targetsZone(MTGGameZone * z);
TargetZoneChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
TargetZoneChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
virtual bool canTarget(Targetable * _card);
int setAllZones();
virtual TargetZoneChooser * clone() const;
};
class CardTargetChooser:public TargetZoneChooser {
protected:
MTGCardInstance * validTarget;
public: public:
CardTargetChooser(MTGCardInstance * card, MTGCardInstance * source, int * zones = NULL, int nbzones = 0); TargetChooser * createTargetChooser(string s, MTGCardInstance * card, MTGAbility * ability = NULL);
virtual bool canTarget(Targetable * target); TargetChooser * createTargetChooser(MTGCardInstance * card);
virtual CardTargetChooser * clone() const;
}; };
class TargetZoneChooser: public TargetChooser
class CreatureTargetChooser:public TargetZoneChooser{ {
public: public:
CreatureTargetChooser(int * _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false); int zones[15];
CreatureTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false); int nbzones;
virtual bool canTarget(Targetable * _card); int init(int * _zones, int _nbzones);
virtual CreatureTargetChooser * clone() const; bool targetsZone(MTGGameZone * z);
TargetZoneChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
TargetZoneChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
virtual bool canTarget(Targetable * _card);
int setAllZones();
virtual TargetZoneChooser * clone() const;
}; };
class CardTargetChooser: public TargetZoneChooser
class DamageableTargetChooser:public CreatureTargetChooser{ {
public:
DamageableTargetChooser(int * _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false):CreatureTargetChooser( _zones,_nbzones, card, _maxtargets,other){};
DamageableTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false):CreatureTargetChooser(card, _maxtargets,other){};
virtual bool canTarget(Targetable * target);
virtual DamageableTargetChooser * clone() const;
};
class PlayerTargetChooser:public TargetChooser{
protected: protected:
Player * p; //In Case we can only target a specific player MTGCardInstance * validTarget;
public: public:
PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, Player *_p = NULL); CardTargetChooser(MTGCardInstance * card, MTGCardInstance * source, int * zones = NULL, int nbzones = 0);
virtual bool canTarget(Targetable * target); virtual bool canTarget(Targetable * target);
virtual PlayerTargetChooser * clone() const; virtual CardTargetChooser * clone() const;
}; };
class TypeTargetChooser:public TargetZoneChooser{ class CreatureTargetChooser: public TargetZoneChooser
public: {
int nbtypes; public:
int types[10]; CreatureTargetChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
TypeTargetChooser(const char * _type, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false); CreatureTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
TypeTargetChooser(const char * _type, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false); virtual bool canTarget(Targetable * _card);
void addType(int type); virtual CreatureTargetChooser * clone() const;
void addType(const char * type);
virtual bool canTarget(Targetable * target);
virtual TypeTargetChooser * clone() const;
}; };
class DescriptorTargetChooser:public TargetZoneChooser{ class DamageableTargetChooser: public CreatureTargetChooser
public: {
CardDescriptor * cd; public:
DescriptorTargetChooser(CardDescriptor * _cd, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false); DamageableTargetChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false) :
DescriptorTargetChooser(CardDescriptor * _cd, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false); CreatureTargetChooser(_zones, _nbzones, card, _maxtargets, other)
virtual bool canTarget(Targetable * target); {
~DescriptorTargetChooser(); }
virtual DescriptorTargetChooser * clone() const; ;
DamageableTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false) :
CreatureTargetChooser(card, _maxtargets, other)
{
}
;
virtual bool canTarget(Targetable * target);
virtual DamageableTargetChooser * clone() const;
}; };
class PlayerTargetChooser: public TargetChooser
class SpellTargetChooser:public TargetChooser{ {
public: protected:
int color; Player * p; //In Case we can only target a specific player
SpellTargetChooser( MTGCardInstance * card = NULL,int _color = -1, int _maxtargets = 1 , bool other = false); public:
virtual bool canTarget(Targetable * target); PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, Player *_p = NULL);
virtual SpellTargetChooser * clone() const; virtual bool canTarget(Targetable * target);
virtual PlayerTargetChooser * clone() const;
}; };
class SpellOrPermanentTargetChooser:public TargetZoneChooser{ class TypeTargetChooser: public TargetZoneChooser
public: {
int color; public:
SpellOrPermanentTargetChooser(MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1, bool other = false); int nbtypes;
virtual bool canTarget(Targetable * target); int types[10];
virtual SpellOrPermanentTargetChooser * clone() const; TypeTargetChooser(const char * _type, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
TypeTargetChooser(const char * _type, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
void addType(int type);
void addType(const char * type);
virtual bool canTarget(Targetable * target);
virtual TypeTargetChooser * clone() const;
}; };
class DescriptorTargetChooser: public TargetZoneChooser
{
public:
CardDescriptor * cd;
DescriptorTargetChooser(CardDescriptor * _cd, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
DescriptorTargetChooser(CardDescriptor * _cd, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
virtual bool canTarget(Targetable * target);
~DescriptorTargetChooser();
virtual DescriptorTargetChooser * clone() const;
};
class SpellTargetChooser: public TargetChooser
{
public:
int color;
SpellTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, bool other = false);
virtual bool canTarget(Targetable * target);
virtual SpellTargetChooser * clone() const;
};
class DamageTargetChooser:public TargetChooser{ class SpellOrPermanentTargetChooser: public TargetZoneChooser
public: {
int color; public:
int state; int color;
DamageTargetChooser( MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1, int state = NOT_RESOLVED); SpellOrPermanentTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, bool other = false);
virtual bool canTarget(Targetable * target); virtual bool canTarget(Targetable * target);
virtual DamageTargetChooser * clone() const; virtual SpellOrPermanentTargetChooser * clone() const;
};
class DamageTargetChooser: public TargetChooser
{
public:
int color;
int state;
DamageTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, int state = NOT_RESOLVED);
virtual bool canTarget(Targetable * target);
virtual DamageTargetChooser * clone() const;
}; };
//Should only be used for triggered abilities. //Should only be used for triggered abilities.
class TriggerTargetChooser:public TargetChooser{ class TriggerTargetChooser: public TargetChooser
{
public: public:
Targetable * target; Targetable * target;
int triggerTarget; int triggerTarget;
TriggerTargetChooser(int _triggerTarget); TriggerTargetChooser(int _triggerTarget);
virtual bool targetsZone(MTGGameZone * z); virtual bool targetsZone(MTGGameZone * z);
virtual bool canTarget(Targetable * _target); virtual bool canTarget(Targetable * _target);
virtual TriggerTargetChooser * clone() const; virtual TriggerTargetChooser * clone() const;
}; };
#endif #endif

View File

@@ -5,10 +5,11 @@
#define TARGET_PLAYER 2 #define TARGET_PLAYER 2
#define TARGET_STACKACTION 3 #define TARGET_STACKACTION 3
class Targetable{ class Targetable
public: {
virtual int typeAsTarget() = 0; public:
virtual const string getDisplayName() const = 0; virtual int typeAsTarget() = 0;
virtual const string getDisplayName() const = 0;
}; };
#endif #endif

View File

@@ -11,24 +11,29 @@ class Spell;
class Interruptible; class Interruptible;
class Damage; class Damage;
class TargetsList{ class TargetsList
public: {
int cursor; public:
TargetsList(); int cursor;
TargetsList(Targetable * _targets[], int nbtargets); TargetsList();
Targetable* targets[MAX_TARGETS]; TargetsList(Targetable * _targets[], int nbtargets);
int alreadyHasTarget(Targetable * target); Targetable* targets[MAX_TARGETS];
int removeTarget(Targetable * _card); int alreadyHasTarget(Targetable * target);
int toggleTarget(Targetable * _card); int removeTarget(Targetable * _card);
virtual int addTarget(Targetable * _target); int toggleTarget(Targetable * _card);
MTGCardInstance * getNextCardTarget(MTGCardInstance * previous = 0); virtual int addTarget(Targetable * _target);
Player * getNextPlayerTarget(Player * previous = 0); MTGCardInstance * getNextCardTarget(MTGCardInstance * previous = 0);
Damageable * getNextDamageableTarget(Damageable * previous = 0); Player * getNextPlayerTarget(Player * previous = 0);
Interruptible * getNextInterruptible(Interruptible * previous, int type); Damageable * getNextDamageableTarget(Damageable * previous = 0);
Spell * getNextSpellTarget(Spell * previous = 0); Interruptible * getNextInterruptible(Interruptible * previous, int type);
Damage * getNextDamageTarget(Damage * previous = 0); Spell * getNextSpellTarget(Spell * previous = 0);
Targetable * getNextTarget(Targetable * previous = 0, int type = -1); Damage * getNextDamageTarget(Damage * previous = 0);
void initTargets(){cursor = 0;}; Targetable * getNextTarget(Targetable * previous = 0, int type = -1);
void initTargets()
{
cursor = 0;
}
;
}; };
#endif #endif

View File

@@ -20,211 +20,223 @@
#define COMMON_ATTRIBS_COUNT 7 #define COMMON_ATTRIBS_COUNT 7
class Task { class Task
{
protected: protected:
int reward; // TODO: Complex rewards. Be consistent with other planned modes with rewards. int reward; // TODO: Complex rewards. Be consistent with other planned modes with rewards.
int opponent; int opponent;
bool accepted; bool accepted;
char type; char type;
int expiresIn; int expiresIn;
string description; string description;
string opponentName; string opponentName;
vector<string> persistentAttribs; // persistentAttributes vector<string> persistentAttribs; // persistentAttributes
void storeCommonAttribs(); void storeCommonAttribs();
int restoreCommonAttribs(); int restoreCommonAttribs();
string getOpponentName(); string getOpponentName();
virtual void storeCustomAttribs(); virtual void storeCustomAttribs();
virtual void restoreCustomAttribs(); virtual void restoreCustomAttribs();
virtual void randomize(); virtual void randomize();
virtual int computeReward() = 0; virtual int computeReward() = 0;
public: public:
// variable to store and method to obtain names of AI decks // variable to store and method to obtain names of AI decks
//!! Todo: This should _really_ be handled elsewhere (dedicated class?) //!! Todo: This should _really_ be handled elsewhere (dedicated class?)
static vector<string> sAIDeckNames; static vector<string> sAIDeckNames;
static void LoadAIDeckNames(); static void LoadAIDeckNames();
static int getAIDeckCount(); static int getAIDeckCount();
static string getAIDeckName(int id); static string getAIDeckName(int id);
// End of AI deck buffering code // End of AI deck buffering code
Task(char _type = ' '); Task(char _type = ' ');
static Task* createFromStr(string params, bool rand = false); static Task* createFromStr(string params, bool rand = false);
virtual string toString(); virtual string toString();
string getDesc(); string getDesc();
virtual string createDesc() = 0; virtual string createDesc() = 0;
virtual string getShortDesc() = 0; virtual string getShortDesc() = 0;
int getExpiration(); int getExpiration();
int getReward(); int getReward();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app) = 0; virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app) = 0;
bool isExpired(); bool isExpired();
void setExpiration(int _expiresIn); void setExpiration(int _expiresIn);
void passOneDay(); void passOneDay();
}; };
class TaskList { class TaskList
{
protected: protected:
string fileName; string fileName;
float vPos; float vPos;
float mElapsed; float mElapsed;
int mState; int mState;
JQuad * mBg[9]; JQuad * mBg[9];
JTexture * mBgTex; JTexture * mBgTex;
float sH, sW; float sH, sW;
public: public:
vector<Task*> tasks; vector<Task*> tasks;
enum{ enum
TASKS_IN, {
TASKS_ACTIVE, TASKS_IN,
TASKS_OUT, TASKS_ACTIVE,
TASKS_INACTIVE, TASKS_OUT,
}; TASKS_INACTIVE,
};
TaskList(string _fileName = ""); TaskList(string _fileName = "");
int load(string _fileName = ""); int load(string _fileName = "");
int save(string _fileName = ""); int save(string _fileName = "");
int getState() {return mState;}; int getState()
void addTask(string params, bool rand = false); {
void addTask(Task *task); return mState;
void addRandomTask(int diff = 100); }
void removeTask(Task *task); ;
void passOneDay(); void addTask(string params, bool rand = false);
void getDoneTasks(Player * _p1, Player * _p2, GameApp * _app, vector<Task*>* result); void addTask(Task *task);
int getTaskCount(); void addRandomTask(int diff = 100);
void removeTask(Task *task);
void passOneDay();
void getDoneTasks(Player * _p1, Player * _p2, GameApp * _app, vector<Task*>* result);
int getTaskCount();
void Start(); void Start();
void End(); void End();
void Update(float dt); void Update(float dt);
void Render(); void Render();
//!!virtual void ButtonPressed(int controllerId, int controlId); //!!virtual void ButtonPressed(int controllerId, int controlId);
~TaskList(); ~TaskList();
}; };
class TaskWinAgainst : public Task { class TaskWinAgainst: public Task
{
protected: protected:
virtual int computeReward(); virtual int computeReward();
public:
TaskWinAgainst(int _opponent = 0);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
};
class TaskSlaughter : public TaskWinAgainst {
protected:
int targetLife;
virtual int computeReward();
public: public:
TaskSlaughter(int _opponent = 0, int _targetLife = -15); TaskWinAgainst(int _opponent = 0);
virtual string createDesc(); virtual string createDesc();
virtual string getShortDesc(); virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app); virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
}; };
class TaskDelay : public TaskWinAgainst { class TaskSlaughter: public TaskWinAgainst
{
protected: protected:
int turn; int targetLife;
bool afterTurn; virtual int computeReward();
virtual int computeReward();
public: public:
TaskDelay(int _opponent = 0, int _turn = 20); TaskSlaughter(int _opponent = 0, int _targetLife = -15);
virtual string createDesc(); virtual string createDesc();
virtual string getShortDesc(); virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app); virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs(); virtual void storeCustomAttribs();
virtual void restoreCustomAttribs(); virtual void restoreCustomAttribs();
virtual void randomize(); virtual void randomize();
}; };
class TaskImmortal : public Task { class TaskDelay: public TaskWinAgainst
{
protected: protected:
int targetLife; int turn;
int level; bool afterTurn;
virtual int computeReward(); virtual int computeReward();
public: public:
TaskImmortal(int _targetLife = 20); TaskDelay(int _opponent = 0, int _turn = 20);
virtual string createDesc();
virtual string createDesc(); virtual string getShortDesc();
virtual string getShortDesc(); virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app); virtual void storeCustomAttribs();
virtual void storeCustomAttribs(); virtual void restoreCustomAttribs();
virtual void restoreCustomAttribs(); virtual void randomize();
virtual void randomize();
};
class TaskMassiveBurial : public Task {
protected:
int color;
int bodyCount;
virtual int computeReward();
public:
TaskMassiveBurial(int _color = 0, int _bodyCount = 0);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
}; };
class TaskWisdom : public Task { class TaskImmortal: public Task
{
protected: protected:
int color; int targetLife;
int cardCount; int level;
virtual int computeReward(); virtual int computeReward();
public: public:
TaskWisdom(int _color = 0, int _cardCount = 0); TaskImmortal(int _targetLife = 20);
virtual string createDesc(); virtual string createDesc();
virtual string getShortDesc(); virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app); virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs(); virtual void storeCustomAttribs();
virtual void restoreCustomAttribs(); virtual void restoreCustomAttribs();
virtual void randomize(); virtual void randomize();
}; };
class TaskPacifism : public Task { class TaskMassiveBurial: public Task
{
protected: protected:
virtual int computeReward(); int color;
int lifeSlashCardMin; int bodyCount;
public: virtual int computeReward();
TaskPacifism(int _lifeSlashCardMin = 0); public:
TaskMassiveBurial(int _color = 0, int _bodyCount = 0);
virtual string createDesc(); virtual string createDesc();
virtual string getShortDesc(); virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app); virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs(); virtual void storeCustomAttribs();
virtual void restoreCustomAttribs(); virtual void restoreCustomAttribs();
virtual void randomize(); virtual void randomize();
}; };
class TaskWisdom: public Task
{
protected:
int color;
int cardCount;
virtual int computeReward();
public:
TaskWisdom(int _color = 0, int _cardCount = 0);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
};
class TaskPacifism: public Task
{
protected:
virtual int computeReward();
int lifeSlashCardMin;
public:
TaskPacifism(int _lifeSlashCardMin = 0);
virtual string createDesc();
virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs();
virtual void restoreCustomAttribs();
virtual void randomize();
};
/* ------------ Task template ------------ /* ------------ Task template ------------
class TaskXX : public Task { class TaskXX : public Task {
protected: protected:
virtual int computeReward(); virtual int computeReward();
public: public:
TaskXX(); TaskXX();
virtual string createDesc(); virtual string createDesc();
virtual string getShortDesc(); virtual string getShortDesc();
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app); virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
virtual void storeCustomAttribs(); virtual void storeCustomAttribs();
virtual void restoreCustomAttribs(); virtual void restoreCustomAttribs();
virtual void randomize(); virtual void randomize();
}; };
*/ */
#endif #endif

View File

@@ -8,96 +8,98 @@
#include "AIPlayer.h" #include "AIPlayer.h"
class TestSuiteActions{ class TestSuiteActions
public: {
int nbitems; public:
string actions[MAX_TESTSUITE_ACTIONS]; int nbitems;
void add(string action); string actions[MAX_TESTSUITE_ACTIONS];
TestSuiteActions(); void add(string action);
void cleanup(); TestSuiteActions();
void cleanup();
}; };
class TestSuitePlayerZone{ class TestSuitePlayerZone
public: {
int cards[MAX_TESTUITE_CARDS]; public:
int nbitems; int cards[MAX_TESTUITE_CARDS];
void add(int cardid); int nbitems;
TestSuitePlayerZone(); void add(int cardid);
void cleanup(); TestSuitePlayerZone();
void cleanup();
}; };
class TestSuitePlayerData{ class TestSuitePlayerData
public: {
int life; public:
ManaCost * manapool; int life;
TestSuitePlayerZone zones[5]; ManaCost * manapool;
TestSuitePlayerData(); TestSuitePlayerZone zones[5];
~TestSuitePlayerData(); TestSuitePlayerData();
void cleanup(); ~TestSuitePlayerData();
void cleanup();
}; };
class TestSuite; class TestSuite;
class TestSuiteState{ class TestSuiteState
public: {
int phase; public:
void parsePlayerState(int playerId, string s); int phase;
TestSuiteState(); void parsePlayerState(int playerId, string s);
TestSuitePlayerData playerData[2]; TestSuiteState();
void cleanup(); TestSuitePlayerData playerData[2];
void cleanup();
}; };
class TestSuitePregame
class TestSuitePregame{ {
public: public:
virtual void performTest() = 0; virtual void performTest() = 0;
}; };
class TestSuite{ class TestSuite
public: {
MTGAllCards* collection; public:
int summoningSickness; MTGAllCards* collection;
bool forceAbility; int summoningSickness;
int gameType; bool forceAbility;
float timerLimit; int gameType;
unsigned int seed; float timerLimit;
int aiMaxCalls; unsigned int seed;
int currentAction; int aiMaxCalls;
TestSuiteState initState; int currentAction;
TestSuiteState endState; TestSuiteState initState;
TestSuiteActions actions; TestSuiteState endState;
string files[1024]; TestSuiteActions actions;
int nbfiles; string files[1024];
int currentfile; int nbfiles;
int nbFailed, nbTests, nbAIFailed, nbAITests; int currentfile;
int load(const char * filename); int nbFailed, nbTests, nbAIFailed, nbAITests;
TestSuite(const char * filename,MTGAllCards* _collection); int load(const char * filename);
void initGame(); TestSuite(const char * filename,MTGAllCards* _collection);
void pregameTests(); void initGame();
int assertGame(); void pregameTests();
MTGPlayerCards * buildDeck(int playerId); int assertGame();
string getNextAction(); MTGPlayerCards * buildDeck(int playerId);
Interruptible * getActionByMTGId(int mtgid); string getNextAction();
int loadNext(); Interruptible * getActionByMTGId(int mtgid);
void cleanup(); int loadNext();
static int Log(const char * text); void cleanup();
static int Log(const char * text);
}; };
class TestSuiteAI:public AIPlayerBaka{ class TestSuiteAI:public AIPlayerBaka
public: {
TestSuite * suite; public:
float timer; TestSuite * suite;
float timer;
TestSuiteAI(TestSuite * suite, int playerId);
virtual int Act(float dt); TestSuiteAI(TestSuite * suite, int playerId);
MTGCardInstance * getCard(string action); virtual int Act(float dt);
virtual int displayStack(); MTGCardInstance * getCard(string action);
virtual int displayStack();
}; };
#endif #endif
#endif #endif

View File

@@ -7,49 +7,49 @@ class JLBFont;
#include <vector> #include <vector>
using namespace std; using namespace std;
class TextScroller: public JGuiObject{ class TextScroller: public JGuiObject
{
protected: protected:
string mText; string mText;
string tempText; string tempText;
int fontId; int fontId;
float mWidth; // width of the text scroller object float mWidth; // width of the text scroller object
float mScrollSpeed; float mScrollSpeed;
float mX; float mX;
float mY; float mY;
float start; float start;
int timer; int timer;
vector<string> strings; vector<string> strings;
unsigned int currentId; unsigned int currentId;
int mRandom; int mRandom;
int scrollDirection; int scrollDirection;
public: public:
TextScroller(int fontId, float x, float y, float width, float speed = 30); TextScroller(int fontId, float x, float y, float width, float speed = 30);
void Add(string text); void Add(string text);
void Reset(); void Reset();
void setRandom(int mode = 1); void setRandom(int mode = 1);
void Render(); void Render();
void Update(float dt); void Update(float dt);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
class VerticalTextScroller: class VerticalTextScroller: public TextScroller
public TextScroller
{ {
private: private:
size_t mNbItemsShown; size_t mNbItemsShown;
float mHeight; // maximum height availble for display float mHeight; // maximum height availble for display
float mMarginX; float mMarginX;
float mMarginY; // margin used to allow text to scroll off screen without float mMarginY; // margin used to allow text to scroll off screen without
// affecting look and feel. Should be enough // affecting look and feel. Should be enough
// for at least one line of text ( mY - line height of current font ) // for at least one line of text ( mY - line height of current font )
float mOriginalY; // mY initially, used to restore scroller to original position after update float mOriginalY; // mY initially, used to restore scroller to original position after update
public: public:
VerticalTextScroller(int fontId, float x, float y, float width, float height, float scrollSpeed = 30, size_t _minimumItems = 1); VerticalTextScroller(int fontId, float x, float y, float width, float height, float scrollSpeed = 30, size_t _minimumItems = 1);
void Render(); void Render();
void Update(float dt); void Update(float dt);
void Add(string text); void Add(string text);
}; };
#endif #endif

View File

@@ -1,6 +1,6 @@
/* /*
Filter-like system for determining if a card meats certain criteria, for this and thisforeach autos Filter-like system for determining if a card meats certain criteria, for this and thisforeach autos
*/ */
#ifndef _THISDESCRIPTOR_H_ #ifndef _THISDESCRIPTOR_H_
#define _THISDESCRIPTOR_H_ #define _THISDESCRIPTOR_H_
@@ -10,91 +10,102 @@
#include "MTGCardInstance.h" #include "MTGCardInstance.h"
#include "CardDescriptor.h" #include "CardDescriptor.h"
class ThisDescriptor{ class ThisDescriptor
public: {
int comparisonMode;
int comparisonCriterion;
virtual int match(MTGCardInstance * card) = 0;
int matchValue(int value);
virtual ~ThisDescriptor();
};
class ThisDescriptorFactory{
public: public:
ThisDescriptor * createThisDescriptor(string s); int comparisonMode;
int comparisonCriterion;
virtual int match(MTGCardInstance * card) = 0;
int matchValue(int value);
virtual ~ThisDescriptor();
}; };
class ThisCounter:public ThisDescriptor{ class ThisDescriptorFactory
public: {
Counter * counter; public:
virtual int match(MTGCardInstance * card); ThisDescriptor * createThisDescriptor(string s);
ThisCounter(Counter * _counter);
ThisCounter(int power, int toughness, int nb, const char * name);
~ThisCounter();
}; };
class ThisCounterAny:public ThisDescriptor{ class ThisCounter: public ThisDescriptor
public: {
virtual int match(MTGCardInstance *card); public:
Counter * counter;
ThisCounterAny(int nb);
};
class ThisControllerlife:public ThisDescriptor{
public:
virtual int match(MTGCardInstance * card); virtual int match(MTGCardInstance * card);
ThisCounter(Counter * _counter);
ThisCounter(int power, int toughness, int nb, const char * name);
~ThisCounter();
};
class ThisCounterAny: public ThisDescriptor
{
public:
virtual int match(MTGCardInstance *card);
ThisCounterAny(int nb);
};
class ThisControllerlife: public ThisDescriptor
{
public:
virtual int match(MTGCardInstance * card);
ThisControllerlife(int life); ThisControllerlife(int life);
}; };
class ThisOpponentlife:public ThisDescriptor{ class ThisOpponentlife: public ThisDescriptor
public: {
public:
virtual int match(MTGCardInstance * card); virtual int match(MTGCardInstance * card);
ThisOpponentlife(int olife); ThisOpponentlife(int olife);
}; };
class ThisEquip:public ThisDescriptor{ class ThisEquip: public ThisDescriptor
public: {
public:
virtual int match(MTGCardInstance * card); virtual int match(MTGCardInstance * card);
ThisEquip(int equipment); ThisEquip(int equipment);
}; };
class ThisAttacked: public ThisDescriptor
class ThisAttacked:public ThisDescriptor{ {
public: public:
virtual int match(MTGCardInstance * card); virtual int match(MTGCardInstance * card);
ThisAttacked(int attack); ThisAttacked(int attack);
}; };
class ThisNotBlocked:public ThisDescriptor{ class ThisNotBlocked: public ThisDescriptor
public: {
public:
virtual int match(MTGCardInstance * card); virtual int match(MTGCardInstance * card);
ThisNotBlocked(int unblocked); ThisNotBlocked(int unblocked);
}; };
class ThisPower:public ThisDescriptor{ class ThisPower: public ThisDescriptor
public: {
public:
virtual int match(MTGCardInstance * card); virtual int match(MTGCardInstance * card);
ThisPower(int power); ThisPower(int power);
}; };
class ThisToughness:public ThisDescriptor{ class ThisToughness: public ThisDescriptor
public: {
public:
virtual int match(MTGCardInstance * card); virtual int match(MTGCardInstance * card);
ThisToughness(int toughness); ThisToughness(int toughness);
}; };
class ThisX:public ThisDescriptor{ class ThisX: public ThisDescriptor
public: {
public:
virtual int match(MTGCardInstance * card); virtual int match(MTGCardInstance * card);
ThisX(int x); ThisX(int x);
}; };
#endif #endif

View File

@@ -1,7 +1,6 @@
#ifndef THREADING_H #ifndef THREADING_H
#define THREADING_H #define THREADING_H
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
#include <boost/date_time.hpp> #include <boost/date_time.hpp>
@@ -18,7 +17,8 @@ namespace boost
public: public:
struct scoped_lock struct scoped_lock
{ {
scoped_lock(mutex& inMutex) : mID(inMutex.mID) scoped_lock(mutex& inMutex) :
mID(inMutex.mID)
{ {
sceKernelWaitSema(mID, 1, 0); sceKernelWaitSema(mID, 1, 0);
} }
@@ -43,9 +43,9 @@ namespace boost
int mID; int mID;
}; };
} }
#endif #endif
#endif // THREADING_H #endif // THREADING_H

View File

@@ -3,10 +3,11 @@
#include "MTGCardInstance.h" #include "MTGCardInstance.h"
class Token: public MTGCardInstance{ class Token: public MTGCardInstance
MTGCardInstance * tokenSource; {
MTGCardInstance * tokenSource;
public: public:
Token(string _name, MTGCardInstance * source, int _power=0, int _toughness=0); Token(string _name, MTGCardInstance * source, int _power = 0, int _toughness = 0);
}; };
#endif #endif

View File

@@ -4,37 +4,37 @@
#include <string> #include <string>
#include <map> #include <map>
#if defined _DEBUG #if defined _DEBUG
#define DEBUG_TRANSLATE #define DEBUG_TRANSLATE
#endif #endif
using namespace std; using namespace std;
class Translator{ class Translator
protected: {
static Translator * mInstance; protected:
bool initDone; static Translator * mInstance;
bool initDone;
void load(string filename, map<string,string> * dictionary);
void load(string filename, map<string, string> * dictionary);
public: public:
map<string,string> values; map<string, string> values;
map<string,string> tempValues; map<string, string> tempValues;
map<string,string> deckValues; map<string, string> deckValues;
#if defined DEBUG_TRANSLATE #if defined DEBUG_TRANSLATE
map<string,int> missingValues; map<string,int> missingValues;
map<string,int> dontCareValues; map<string,int> dontCareValues;
int checkMisses; int checkMisses;
#endif #endif
string translate(string toTranslate); string translate(string toTranslate);
Translator(); Translator();
~Translator(); ~Translator();
int Add(string from, string to); int Add(string from, string to);
void initCards(); void initCards();
void initDecks(); void initDecks();
void init(); void init();
static Translator * GetInstance(); static Translator * GetInstance();
static void EndInstance(); static void EndInstance();
}; };
string _(string toTranslate); string _(string toTranslate);

View File

@@ -5,21 +5,21 @@
#include "Pos.h" #include "Pos.h"
#include "WEvent.h" #include "WEvent.h"
template <class T> void trash(T*); template<class T> void trash(T*);
class Trash class Trash
{ {
public: public:
static void cleanup(); static void cleanup();
}; };
template <class T> template<class T>
class TrashBin class TrashBin
{ {
std::vector<T*> bin; std::vector<T*> bin;
void put_out(); void put_out();
int receiveEvent(WEvent* e); int receiveEvent(WEvent* e);
template <class Q> friend void trash(Q*); template<class Q> friend void trash(Q*);
friend class Trash; friend class Trash;
}; };
#endif // _TRASH_H_ #endif // _TRASH_H_

View File

@@ -8,114 +8,132 @@
#define INVALID_MTEX -1 #define INVALID_MTEX -1
#endif #endif
class WResource{ class WResource
{
public: public:
friend class WResourceManager; friend class WResourceManager;
friend struct WCacheSort; friend struct WCacheSort;
template<class cacheItem,class cacheActual> friend class WCache; template<class cacheItem, class cacheActual> friend class WCache;
WResource(); WResource();
virtual ~WResource(); virtual ~WResource();
virtual unsigned long size()=0; //Size of cached item in bytes.
virtual bool isGood()=0; //Return true if this has data.
virtual bool isLocked(); //Is the resource locked?
virtual void lock(); //Lock it.
virtual void unlock(bool force = false); //Unlock it. Forcing a lock will also remove "permanent" status.
bool isPermanent(); //Is the resource permanent? virtual unsigned long size()=0; //Size of cached item in bytes.
void deadbolt(); //Make it permanent. virtual bool isGood()=0; //Return true if this has data.
void hit(); //Update resource's last used time. virtual bool isLocked(); //Is the resource locked?
virtual void lock(); //Lock it.
virtual void unlock(bool force = false); //Unlock it. Forcing a lock will also remove "permanent" status.
bool isPermanent(); //Is the resource permanent?
void deadbolt(); //Make it permanent.
void hit(); //Update resource's last used time.
protected: protected:
int loadedMode; //What submode settings were we loaded with? (For refresh) int loadedMode; //What submode settings were we loaded with? (For refresh)
unsigned int lastTime; //When was the last time we were hit? unsigned int lastTime; //When was the last time we were hit?
unsigned char locks; //Remember to unlock when we're done using locked stuff, or else this'll be useless. unsigned char locks; //Remember to unlock when we're done using locked stuff, or else this'll be useless.
}; };
class WCachedResource: public WResource { class WCachedResource: public WResource
{
public: public:
friend class WResourceManager; friend class WResourceManager;
template<class cacheItem,class cacheActual> friend class WCache; template<class cacheItem, class cacheActual> friend class WCache;
virtual ~WCachedResource(); virtual ~WCachedResource();
string mFilename; string mFilename;
virtual void Refresh()=0; //Basically calls Attempt(filename) and remaps in situ. virtual void Refresh()=0; //Basically calls Attempt(filename) and remaps in situ.
virtual bool Attempt(string filename, int submode, int & error)=0; //Returns true if we've loaded our data and isGood(). virtual bool Attempt(string filename, int submode, int & error)=0; //Returns true if we've loaded our data and isGood().
}; };
class WTrackedQuad: public WResource
class WTrackedQuad: public WResource { {
public: public:
WTrackedQuad(string _resname); WTrackedQuad(string _resname);
~WTrackedQuad(); ~WTrackedQuad();
bool isGood(); bool isGood();
unsigned long size(); unsigned long size();
string resname; string resname;
JQuad * quad; JQuad * quad;
}; };
class WCachedTexture: public WCachedResource{ class WCachedTexture: public WCachedResource
{
public: public:
friend class WResourceManager; friend class WResourceManager;
template<class cacheItem,class cacheActual> friend class WCache; template<class cacheItem, class cacheActual> friend class WCache;
WCachedTexture(); WCachedTexture();
~WCachedTexture(); ~WCachedTexture();
void Refresh(); void Refresh();
unsigned long size(); unsigned long size();
bool isGood(); bool isGood();
bool isLocked(); //Is the resource locked? bool isLocked(); //Is the resource locked?
bool Attempt(string filename, int submode, int & error); bool Attempt(string filename, int submode, int & error);
bool compare(JTexture * t) {return (t == texture);}; bool compare(JTexture * t)
JTexture * Actual(); //Return this texture as is. Does not make a new one. {
JQuad * GetQuad(string resname); return (t == texture);
}
WTrackedQuad* GetTrackedQuad(float offX=0.0f, float offY=0.0f, float width=0.0f, float height=0.0f,string resname=""); //Get us a new/existing quad. ;
JTexture * Actual(); //Return this texture as is. Does not make a new one.
JQuad * GetQuad(string resname);
JQuad * GetQuad(float offX=0.0f, float offY=0.0f, float width=0.0f, float height=0.0f,string resname=""); //Alias to GetTrackedQuad. WTrackedQuad
JQuad * GetCard(float offX=0.0f, float offY=0.0f, float width=0.0f, float height=0.0f,string resname=""); //Same as above, but centered when new. * GetTrackedQuad(float offX = 0.0f, float offY = 0.0f, float width = 0.0f, float height = 0.0f, string resname = ""); //Get us a new/existing quad.
bool ReleaseQuad(JQuad* quad); //We're done with this quad, so delete and stop tracking. True if existed. JQuad * GetQuad(float offX = 0.0f, float offY = 0.0f, float width = 0.0f, float height = 0.0f, string resname = ""); //Alias to GetTrackedQuad.
protected: JQuad * GetCard(float offX = 0.0f, float offY = 0.0f, float width = 0.0f, float height = 0.0f, string resname = ""); //Same as above, but centered when new.
JTexture * texture;
vector<WTrackedQuad*> trackedQuads; bool ReleaseQuad(JQuad* quad); //We're done with this quad, so delete and stop tracking. True if existed.
protected:
JTexture * texture;
vector<WTrackedQuad*> trackedQuads;
}; };
class WCachedParticles: public WCachedResource{ class WCachedParticles: public WCachedResource
{
public: public:
friend class WResourceManager; friend class WResourceManager;
template<class cacheItem,class cacheActual> friend class WCache; template<class cacheItem, class cacheActual> friend class WCache;
WCachedParticles(); WCachedParticles();
~WCachedParticles(); ~WCachedParticles();
void Refresh(); void Refresh();
unsigned long size(); unsigned long size();
bool isGood();
bool Attempt(string filename, int submode, int & error);
bool compare(hgeParticleSystemInfo * p) {return (p == particles);};
hgeParticleSystemInfo * Actual(); bool isGood();
protected: bool Attempt(string filename, int submode, int & error);
hgeParticleSystemInfo * particles; bool compare(hgeParticleSystemInfo * p)
{
return (p == particles);
}
;
hgeParticleSystemInfo * Actual();
protected:
hgeParticleSystemInfo * particles;
}; };
class WCachedSample: public WCachedResource{ class WCachedSample: public WCachedResource
{
public: public:
friend class WResourceManager; friend class WResourceManager;
template<class cacheItem,class cacheActual> friend class WCache; template<class cacheItem, class cacheActual> friend class WCache;
WCachedSample(); WCachedSample();
~WCachedSample(); ~WCachedSample();
bool compare(JSample * s) {return (s == sample);}; bool compare(JSample * s)
unsigned long size(); {
bool isGood(); return (s == sample);
void Refresh(); }
bool Attempt(string filename, int submode, int & error); ;
unsigned long size();
bool isGood();
void Refresh();
bool Attempt(string filename, int submode, int & error);
JSample * Actual(); //Return this sample. JSample * Actual(); //Return this sample.
protected: protected:
JSample * sample; JSample * sample;
}; };
#endif #endif

View File

@@ -10,191 +10,383 @@ class MTGDeck;
class MTGAllCards; class MTGAllCards;
class JQuad; class JQuad;
class WSyncable{ class WSyncable
{
public: public:
WSyncable(int i=0) {hooked = NULL;currentPos = 0;}; WSyncable(int i = 0)
virtual ~WSyncable() {}; {
//Local hooked = NULL;
virtual bool Hook(WSyncable* s); currentPos = 0;
virtual int getOffset() {return currentPos;}; }
virtual bool setOffset(int i) {currentPos = i; return true;}; ;
//Recursive virtual ~WSyncable()
virtual int getPos(); {
virtual bool next(); }
virtual bool prev(); ;
//Local
virtual bool Hook(WSyncable* s);
virtual int getOffset()
{
return currentPos;
}
;
virtual bool setOffset(int i)
{
currentPos = i;
return true;
}
;
//Recursive
virtual int getPos();
virtual bool next();
virtual bool prev();
protected: protected:
WSyncable * hooked; //Simple link list WSyncable * hooked; //Simple link list
int currentPos; int currentPos;
}; };
class WDataSource: public WSyncable{ class WDataSource: public WSyncable
{
public: public:
WDataSource() {}; WDataSource()
virtual JQuad * getImage(int offset=0) {return NULL;}; {
virtual JQuad * getThumb(int offset=0) {return NULL;}; }
virtual MTGCard * getCard(int offset=0, bool ignore=false) {return NULL;}; ;
virtual MTGDeck * getDeck(int offset=0) {return NULL;}; virtual JQuad * getImage(int offset = 0)
virtual WDistort * getDistort(int offset=0) {return NULL;}; {
virtual bool thisCard(int mtgid) {return false;}; return NULL;
virtual int getControlID() {return -1;}; //TODO FIXME: Need a "not a valid button" define. }
virtual void Update(float dt) {mLastInput += dt;}; ;
virtual void Touch() {mLastInput = 0;}; virtual JQuad * getThumb(int offset = 0)
virtual float getElapsed() {return mLastInput;}; {
virtual void setElapsed(float f) {mLastInput = f;}; return NULL;
}
;
virtual MTGCard * getCard(int offset = 0, bool ignore = false)
{
return NULL;
}
;
virtual MTGDeck * getDeck(int offset = 0)
{
return NULL;
}
;
virtual WDistort * getDistort(int offset = 0)
{
return NULL;
}
;
virtual bool thisCard(int mtgid)
{
return false;
}
;
virtual int getControlID()
{
return -1;
}
; //TODO FIXME: Need a "not a valid button" define.
virtual void Update(float dt)
{
mLastInput += dt;
}
;
virtual void Touch()
{
mLastInput = 0;
}
;
virtual float getElapsed()
{
return mLastInput;
}
;
virtual void setElapsed(float f)
{
mLastInput = f;
}
;
protected: protected:
float mLastInput; float mLastInput;
}; };
class WSrcImage: public WDataSource{ class WSrcImage: public WDataSource
{
public: public:
virtual JQuad * getImage(int offset=0); virtual JQuad * getImage(int offset = 0);
WSrcImage(string s); WSrcImage(string s);
protected: protected:
string filename; string filename;
}; };
class WSrcCards: public WDataSource{ class WSrcCards: public WDataSource
{
protected: protected:
vector<MTGCard*> cards; vector<MTGCard*> cards;
vector<size_t> validated; vector<size_t> validated;
WCardFilter * filtersRoot; WCardFilter * filtersRoot;
float mDelay; float mDelay;
public: public:
WSrcCards(float delay=0.2); WSrcCards(float delay = 0.2);
~WSrcCards(); ~WSrcCards();
virtual JQuad * getImage(int offset=0);
virtual JQuad * getThumb(int offset=0);
virtual MTGCard * getCard(int offset=0, bool ignore=false);
virtual int Size(bool all=false); //Returns the number of cards, or the number of cards that match the filter. virtual JQuad * getImage(int offset = 0);
virtual JQuad * getThumb(int offset = 0);
virtual MTGCard * getCard(int offset = 0, bool ignore = false);
virtual void Shuffle(); virtual int Size(bool all = false); //Returns the number of cards, or the number of cards that match the filter.
virtual bool thisCard(int mtgid);
virtual bool next();
virtual bool prev();
virtual void Sort(int method);
virtual bool setOffset(int pos);
virtual bool isEmptySet(WCardFilter * f);
virtual void addFilter(WCardFilter * f);
virtual void clearFilters();
virtual WCardFilter* unhookFilters();
virtual bool matchesFilters(MTGCard * c);
virtual void validate();
virtual void bakeFilters(); //Discards all invalidated cards.
virtual float filterFee();
virtual void updateCounts() {};
virtual void clearCounts() {};
virtual void addCount(MTGCard * c, int qty=1) {};
//Loads into us. Calls validate() virtual void Shuffle();
virtual int loadMatches(MTGAllCards* ac); //loadMatches adds the cards from something virtual bool thisCard(int mtgid);
virtual int loadMatches(MTGDeck * deck); //into this, if it matches our filter virtual bool next();
virtual int loadMatches(WSrcCards* src, bool all=false); //If all==true, ignore filters on src. virtual bool prev();
//We put it into something else
virtual int addRandomCards(MTGDeck * i, int howmany=1);
virtual int addToDeck(MTGDeck * i, int num=-1); //Returns num that didn't add
virtual WCardFilter * getFiltersRoot(){return filtersRoot;};
enum { virtual void Sort(int method);
MAX_CYCLES = 4, //How many cycles to search, for addToDeck virtual bool setOffset(int pos);
SORT_COLLECTOR, virtual bool isEmptySet(WCardFilter * f);
SORT_ALPHA, virtual void addFilter(WCardFilter * f);
SORT_RARITY virtual void clearFilters();
}; virtual WCardFilter* unhookFilters();
virtual bool matchesFilters(MTGCard * c);
virtual void validate();
virtual void bakeFilters(); //Discards all invalidated cards.
virtual float filterFee();
virtual void updateCounts() {};
virtual void clearCounts() {};
virtual void addCount(MTGCard * c, int qty = 1) {};
//Loads into us. Calls validate()
virtual int loadMatches(MTGAllCards* ac); //loadMatches adds the cards from something
virtual int loadMatches(MTGDeck * deck); //into this, if it matches our filter
virtual int loadMatches(WSrcCards* src, bool all = false); //If all==true, ignore filters on src.
//We put it into something else
virtual int addRandomCards(MTGDeck * i, int howmany = 1);
virtual int addToDeck(MTGDeck * i, int num = -1); //Returns num that didn't add
virtual WCardFilter * getFiltersRoot()
{
return filtersRoot;
}
;
enum
{
MAX_CYCLES = 4, //How many cycles to search, for addToDeck
SORT_COLLECTOR,
SORT_ALPHA,
SORT_RARITY
};
}; };
class WSrcDeckViewer: public WSrcCards{ class WSrcDeckViewer: public WSrcCards
{
public: public:
WSrcDeckViewer(WSrcCards * _active, WSrcCards * _inactive); WSrcDeckViewer(WSrcCards * _active, WSrcCards * _inactive);
~WSrcDeckViewer(); ~WSrcDeckViewer();
void swapSrc(); void swapSrc();
//Wrapped functions //Wrapped functions
JQuad * getImage(int offset=0) {return active->getImage(offset);}; JQuad * getImage(int offset = 0)
JQuad * getThumb(int offset=0) {return active->getThumb(offset);}; {
MTGCard * getCard(int offset=0, bool ignore=false) {return active->getCard(offset,ignore);}; return active->getImage(offset);
int Size(bool all=false) {return active->Size();}; }
WCardFilter * getfiltersRoot() {return active->getFiltersRoot();}; ;
void Shuffle() {active->Shuffle();}; JQuad * getThumb(int offset = 0)
bool thisCard(int mtgid) {return active->thisCard(mtgid);}; {
bool next() {return active->next();}; return active->getThumb(offset);
bool prev() {return active->prev();}; }
void Sort(int method) {active->Sort(method);}; ;
bool setOffset(int pos) {return active->setOffset(pos);}; MTGCard * getCard(int offset = 0, bool ignore = false)
bool isEmptySet(WCardFilter * f) {return active->isEmptySet(f);}; {
void addFilter(WCardFilter * f) {active->addFilter(f);}; return active->getCard(offset, ignore);
void clearFilters() {active->clearFilters();}; }
WCardFilter* unhookFilters() {return active->unhookFilters();}; ;
bool matchesFilters(MTGCard * c) {return active->matchesFilters(c);}; int Size(bool all = false)
void validate() {active->validate();}; {
void bakeFilters() {active->bakeFilters();}; //Discards all invalidated cards. return active->Size();
float filterFee() {return active->filterFee();}; }
void updateCounts() {active->updateCounts();}; ;
void clearCounts() {active->clearCounts();}; WCardFilter * getfiltersRoot()
void addCount(MTGCard * c, int qty=1) { active->addCount(c,qty); }; {
int loadMatches(MTGAllCards* ac) {return active->loadMatches(ac);}; return active->getFiltersRoot();
int loadMatches(MTGDeck * deck) {return active->loadMatches(deck);}; }
int loadMatches(WSrcCards* src, bool all=false) {return loadMatches(src,all);}; ;
int addRandomCards(MTGDeck * i, int howmany=1) {return active->addRandomCards(i,howmany);}; void Shuffle()
int addToDeck(MTGDeck * i, int num=-1) {return active->addToDeck(i,num);}; {
active->Shuffle();
}
;
bool thisCard(int mtgid)
{
return active->thisCard(mtgid);
}
;
bool next()
{
return active->next();
}
;
bool prev()
{
return active->prev();
}
;
void Sort(int method)
{
active->Sort(method);
}
;
bool setOffset(int pos)
{
return active->setOffset(pos);
}
;
bool isEmptySet(WCardFilter * f)
{
return active->isEmptySet(f);
}
;
void addFilter(WCardFilter * f)
{
active->addFilter(f);
}
;
void clearFilters()
{
active->clearFilters();
}
;
WCardFilter* unhookFilters()
{
return active->unhookFilters();
}
;
bool matchesFilters(MTGCard * c)
{
return active->matchesFilters(c);
}
;
void validate()
{
active->validate();
}
;
void bakeFilters()
{
active->bakeFilters();
}
; //Discards all invalidated cards.
float filterFee()
{
return active->filterFee();
}
;
void updateCounts()
{
active->updateCounts();
}
;
void clearCounts()
{
active->clearCounts();
}
;
void addCount(MTGCard * c, int qty = 1)
{
active->addCount(c, qty);
}
;
int loadMatches(MTGAllCards* ac)
{
return active->loadMatches(ac);
}
;
int loadMatches(MTGDeck * deck)
{
return active->loadMatches(deck);
}
;
int loadMatches(WSrcCards* src, bool all = false)
{
return loadMatches(src, all);
}
;
int addRandomCards(MTGDeck * i, int howmany = 1)
{
return active->addRandomCards(i, howmany);
}
;
int addToDeck(MTGDeck * i, int num = -1)
{
return active->addToDeck(i, num);
}
;
protected: protected:
WSrcCards * active; WSrcCards * active;
WSrcCards * inactive; WSrcCards * inactive;
}; };
class WSrcUnlockedCards: public WSrcCards{ //Only unlocked cards. class WSrcUnlockedCards: public WSrcCards
{ //Only unlocked cards.
public: public:
WSrcUnlockedCards(float mDelay=0.2); WSrcUnlockedCards(float mDelay = 0.2);
}; };
class WSrcDeck: public WSrcCards{ class WSrcDeck: public WSrcCards
{
public: public:
WSrcDeck(float delay=0.2) : WSrcCards(delay) {clearCounts();}; WSrcDeck(float delay = 0.2) :
virtual int loadMatches(MTGDeck * deck); WSrcCards(delay)
virtual int Add(MTGCard * c, int quantity=1); {
virtual int Remove(MTGCard * c, int quantity=1, bool erase=false); clearCounts();
void Rebuild(MTGDeck * d); }
int count(MTGCard * c); ;
int countByName(MTGCard * card, bool editions=false); virtual int loadMatches(MTGDeck * deck);
int totalPrice(); virtual int Add(MTGCard * c, int quantity = 1);
enum { virtual int Remove(MTGCard * c, int quantity = 1, bool erase = false);
//0 to MTG_NB_COLORS are colors. See MTG_COLOR_ in Constants::. void Rebuild(MTGDeck * d);
UNFILTERED_COPIES = Constants::MTG_NB_COLORS, int count(MTGCard * c);
UNFILTERED_UNIQUE, int countByName(MTGCard * card, bool editions = false);
UNFILTERED_MIN_COPIES, //For 'unlock all' cheat, awards screen int totalPrice();
UNFILTERED_MAX_COPIES, //future use in format restriction, awards screen enum
FILTERED_COPIES, {
FILTERED_UNIQUE, //0 to MTG_NB_COLORS are colors. See MTG_COLOR_ in Constants::.
MAX_COUNTS UNFILTERED_COPIES = Constants::MTG_NB_COLORS,
}; UNFILTERED_UNIQUE,
void clearCounts(); UNFILTERED_MIN_COPIES, //For 'unlock all' cheat, awards screen
void updateCounts(); UNFILTERED_MAX_COPIES, //future use in format restriction, awards screen
void addCount(MTGCard * c, int qty=1); FILTERED_COPIES,
int getCount(int count=UNFILTERED_COPIES); FILTERED_UNIQUE,
MAX_COUNTS
};
void clearCounts();
void updateCounts();
void addCount(MTGCard * c, int qty = 1);
int getCount(int count = UNFILTERED_COPIES);
protected: protected:
map<int,int> copies; //Maps MTGID to card counts. map<int, int> copies; //Maps MTGID to card counts.
int counts[MAX_COUNTS]; int counts[MAX_COUNTS];
}; };
struct WCSortCollector{ struct WCSortCollector
bool operator()(const MTGCard*l, const MTGCard*r); {
bool operator()(const MTGCard*l, const MTGCard*r);
}; };
struct WCSortAlpha{ struct WCSortAlpha
bool operator()(const MTGCard*l, const MTGCard*r); {
bool operator()(const MTGCard*l, const MTGCard*r);
}; };
struct WCSortRarity{ struct WCSortRarity
int rareToInt(char r); {
bool operator()(const MTGCard*l, const MTGCard*r); int rareToInt(char r);
bool operator()(const MTGCard*l, const MTGCard*r);
}; };
#endif #endif

View File

@@ -26,189 +26,217 @@ public:
TARGET_FROM, TARGET_FROM,
}; };
int type; //Deprecated, use dynamic casting instead int type; //Deprecated, use dynamic casting instead
WEvent(int type = NOT_SPECIFIED); WEvent(int type = NOT_SPECIFIED);
virtual ~WEvent() {}; virtual ~WEvent() {};
virtual std::ostream& toString(std::ostream& out) const; virtual std::ostream& toString(std::ostream& out) const;
virtual int getValue() {return 0;}; virtual int getValue()
virtual Targetable * getTarget(int target) {return 0;}; {
return 0;
}
;
virtual Targetable * getTarget(int target)
{
return 0;
}
;
}; };
struct WEventZoneChange : public WEvent { struct WEventZoneChange: public WEvent
MTGCardInstance * card; {
MTGGameZone * from; MTGCardInstance * card;
MTGGameZone * to; MTGGameZone * from;
WEventZoneChange(MTGCardInstance * card, MTGGameZone * from, MTGGameZone *to); MTGGameZone * to;
virtual ~WEventZoneChange() {}; WEventZoneChange(MTGCardInstance * card, MTGGameZone * from, MTGGameZone *to);
virtual std::ostream& toString(std::ostream& out) const; virtual ~WEventZoneChange() {};
virtual Targetable * getTarget(int target); virtual std::ostream& toString(std::ostream& out) const;
virtual Targetable * getTarget(int target);
}; };
struct WEventDamage: public WEvent
struct WEventDamage : public WEvent { {
Damage * damage; Damage * damage;
WEventDamage(Damage * damage); WEventDamage(Damage * damage);
virtual std::ostream& toString(std::ostream& out) const; virtual std::ostream& toString(std::ostream& out) const;
virtual int getValue(); virtual int getValue();
virtual Targetable * getTarget(int target); virtual Targetable * getTarget(int target);
}; };
struct WEventDamageStackResolved : public WEvent { struct WEventDamageStackResolved: public WEvent
WEventDamageStackResolved(); {
WEventDamageStackResolved();
}; };
struct WEventPhaseChange : public WEvent { struct WEventPhaseChange: public WEvent
Phase * from; {
Phase * to; Phase * from;
WEventPhaseChange(Phase * from, Phase * to); Phase * to;
WEventPhaseChange(Phase * from, Phase * to);
}; };
//Abstract class of event when a card's status changes //Abstract class of event when a card's status changes
struct WEventCardUpdate : public WEvent { struct WEventCardUpdate: public WEvent
MTGCardInstance * card; {
WEventCardUpdate(MTGCardInstance * card); MTGCardInstance * card;
WEventCardUpdate(MTGCardInstance * card);
}; };
//Event when a card gains/looses types //Event when a card gains/looses types
struct WEventCardChangeType : public WEventCardUpdate { struct WEventCardChangeType: public WEventCardUpdate
int type; {
bool before; int type;
bool after; bool before;
WEventCardChangeType(MTGCardInstance * card, int type, bool before, bool after); bool after;
WEventCardChangeType(MTGCardInstance * card, int type, bool before, bool after);
}; };
//Event when a card is tapped/untapped //Event when a card is tapped/untapped
struct WEventCardTap : public WEventCardUpdate { struct WEventCardTap: public WEventCardUpdate
bool before; {
bool after; bool before;
WEventCardTap(MTGCardInstance * card, bool before, bool after); bool after;
virtual Targetable * getTarget(int target); WEventCardTap(MTGCardInstance * card, bool before, bool after);
virtual Targetable * getTarget(int target);
}; };
struct WEventCardTappedForMana : public WEventCardUpdate { struct WEventCardTappedForMana: public WEventCardUpdate
bool before; {
bool after; bool before;
WEventCardTappedForMana(MTGCardInstance * card, bool before, bool after); bool after;
virtual Targetable * getTarget(int target); WEventCardTappedForMana(MTGCardInstance * card, bool before, bool after);
virtual Targetable * getTarget(int target);
}; };
//Event when a card's "attacker" status changes //Event when a card's "attacker" status changes
//before:Player/Planeswalker that card was attacking previously //before:Player/Planeswalker that card was attacking previously
//after: Player/Planeswalker that card is attacking now //after: Player/Planeswalker that card is attacking now
struct WEventCreatureAttacker : public WEventCardUpdate { struct WEventCreatureAttacker: public WEventCardUpdate
Targetable * before; {
Targetable * after; Targetable * before;
WEventCreatureAttacker(MTGCardInstance * card, Targetable * from, Targetable * to); Targetable * after;
WEventCreatureAttacker(MTGCardInstance * card, Targetable * from, Targetable * to);
}; };
//event when card attacks. //event when card attacks.
struct WEventCardAttacked : public WEventCardUpdate { struct WEventCardAttacked: public WEventCardUpdate
WEventCardAttacked(MTGCardInstance * card); {
virtual Targetable * getTarget(int target); WEventCardAttacked(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
}; };
//event when card attacks alone. //event when card attacks alone.
struct WEventCardAttackedAlone : public WEventCardUpdate { struct WEventCardAttackedAlone: public WEventCardUpdate
WEventCardAttackedAlone(MTGCardInstance * card); {
virtual Targetable * getTarget(int target); WEventCardAttackedAlone(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
}; };
//event when card attacks but is not blocked. //event when card attacks but is not blocked.
struct WEventCardAttackedNotBlocked : public WEventCardUpdate { struct WEventCardAttackedNotBlocked: public WEventCardUpdate
WEventCardAttackedNotBlocked(MTGCardInstance * card); {
virtual Targetable * getTarget(int target); WEventCardAttackedNotBlocked(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
}; };
//event when card attacks but is blocked. //event when card attacks but is blocked.
struct WEventCardAttackedBlocked : public WEventCardUpdate { struct WEventCardAttackedBlocked: public WEventCardUpdate
WEventCardAttackedBlocked(MTGCardInstance * card); {
virtual Targetable * getTarget(int target); WEventCardAttackedBlocked(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
}; };
//event when card blocked. //event when card blocked.
struct WEventCardBlocked : public WEventCardUpdate { struct WEventCardBlocked: public WEventCardUpdate
WEventCardBlocked(MTGCardInstance * card); {
virtual Targetable * getTarget(int target); WEventCardBlocked(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
}; };
//event when card is sacrificed. //event when card is sacrificed.
struct WEventCardSacrifice : public WEventCardUpdate { struct WEventCardSacrifice: public WEventCardUpdate
WEventCardSacrifice(MTGCardInstance * card); {
virtual Targetable * getTarget(int target); WEventCardSacrifice(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
}; };
//event when card is discarded. //event when card is discarded.
struct WEventCardDiscard : public WEventCardUpdate { struct WEventCardDiscard: public WEventCardUpdate
WEventCardDiscard(MTGCardInstance * card); {
virtual Targetable * getTarget(int target); WEventCardDiscard(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
}; };
//Event when a card's "defenser" status changes //Event when a card's "defenser" status changes
//before : attacker that card was blocking previously //before : attacker that card was blocking previously
//after: attacker that card is blocking now //after: attacker that card is blocking now
struct WEventCreatureBlocker : public WEventCardUpdate { struct WEventCreatureBlocker: public WEventCardUpdate
MTGCardInstance * before; {
MTGCardInstance * after; MTGCardInstance * before;
WEventCreatureBlocker(MTGCardInstance * card,MTGCardInstance * from,MTGCardInstance * to); MTGCardInstance * after;
WEventCreatureBlocker(MTGCardInstance * card, MTGCardInstance * from, MTGCardInstance * to);
}; };
//Event sent when attackers have been chosen and they //Event sent when attackers have been chosen and they
//cannot be changed any more. //cannot be changed any more.
struct WEventAttackersChosen : public WEvent { struct WEventAttackersChosen: public WEvent
{
}; };
//Event sent when blockers have been chosen and they //Event sent when blockers have been chosen and they
//cannot be changed any more. //cannot be changed any more.
struct WEventBlockersChosen : public WEvent { struct WEventBlockersChosen: public WEvent
{
}; };
struct WEventcardDraw : public WEvent { struct WEventcardDraw: public WEvent
WEventcardDraw(Player * player,int nb_cards); {
Player * player; WEventcardDraw(Player * player, int nb_cards);
int nb_cards; Player * player;
virtual Targetable * getTarget(Player * player); int nb_cards;
virtual Targetable * getTarget(Player * player);
}; };
//Event when a blocker is reordered //Event when a blocker is reordered
//exchangeWith: exchange card's position with exchangeWith's position //exchangeWith: exchange card's position with exchangeWith's position
//attacker:both card and exchangeWith *should* be in attacker's "blockers" list. //attacker:both card and exchangeWith *should* be in attacker's "blockers" list.
struct WEventCreatureBlockerRank : public WEventCardUpdate { struct WEventCreatureBlockerRank: public WEventCardUpdate
MTGCardInstance * exchangeWith; {
MTGCardInstance * attacker; MTGCardInstance * exchangeWith;
WEventCreatureBlockerRank(MTGCardInstance * card,MTGCardInstance * exchangeWith, MTGCardInstance * attacker); MTGCardInstance * attacker;
WEventCreatureBlockerRank(MTGCardInstance * card, MTGCardInstance * exchangeWith, MTGCardInstance * attacker);
}; };
//Event when a combat phase step ends //Event when a combat phase step ends
struct WEventCombatStepChange : public WEvent struct WEventCombatStepChange: public WEvent
{ {
CombatStep step; CombatStep step;
WEventCombatStepChange(CombatStep); WEventCombatStepChange(CombatStep);
}; };
//Event when a mana is engaged //Event when a mana is engaged
//color : color //color : color
struct WEventEngageMana : public WEvent { struct WEventEngageMana: public WEvent
int color; {
MTGCardInstance* card; int color;
ManaPool * destination; MTGCardInstance* card;
WEventEngageMana(int color, MTGCardInstance* card, ManaPool * destination); ManaPool * destination;
WEventEngageMana(int color, MTGCardInstance* card, ManaPool * destination);
}; };
//Event when a mana is consumed //Event when a mana is consumed
//color : color //color : color
struct WEventConsumeMana : public WEvent { struct WEventConsumeMana: public WEvent
int color; {
ManaPool * source; int color;
WEventConsumeMana(int color, ManaPool * source); ManaPool * source;
WEventConsumeMana(int color, ManaPool * source);
}; };
//Event when a manapool is emptied //Event when a manapool is emptied
//color : color //color : color
struct WEventEmptyManaPool : public WEvent { struct WEventEmptyManaPool: public WEvent
ManaPool * source; {
WEventEmptyManaPool(ManaPool * source); ManaPool * source;
WEventEmptyManaPool(ManaPool * source);
}; };
std::ostream& operator<<(std::ostream&, const WEvent&); std::ostream& operator<<(std::ostream&, const WEvent&);

View File

@@ -3,192 +3,344 @@
class WCardFilter; class WCardFilter;
class WCFilterFactory{ class WCFilterFactory
{
public: public:
WCFilterFactory() {}; WCFilterFactory(){};
static WCFilterFactory * GetInstance(); static WCFilterFactory * GetInstance();
static void Destroy(); static void Destroy();
WCardFilter * Construct(string src); WCardFilter * Construct(string src);
private: private:
size_t findNext(string src, size_t start, char open='(', char close=')'); size_t findNext(string src, size_t start, char open = '(', char close = ')');
WCardFilter * Leaf(string src); WCardFilter * Leaf(string src);
WCardFilter * Terminal(string src, string arg); WCardFilter * Terminal(string src, string arg);
static WCFilterFactory * me; static WCFilterFactory * me;
}; };
class WCardFilter{ class WCardFilter
{
public: public:
WCardFilter() {}; WCardFilter() {};
virtual ~WCardFilter() {}; virtual ~WCardFilter() {};
virtual bool isMatch(MTGCard * c) {return true;}; virtual bool isMatch(MTGCard * c)
virtual string getCode() = 0; {
virtual float filterFee() {return 0.0f;}; return true;
}
;
virtual string getCode() = 0;
virtual float filterFee()
{
return 0.0f;
}
;
}; };
class WCFBranch: public WCardFilter{ class WCFBranch: public WCardFilter
{
public: public:
WCFBranch(WCardFilter * a, WCardFilter * b) {lhs=a;rhs=b;}; WCFBranch(WCardFilter * a, WCardFilter * b)
~WCFBranch() {SAFE_DELETE(lhs); SAFE_DELETE(rhs);}; {
virtual bool isMatch(MTGCard * c) = 0; lhs = a;
virtual string getCode() = 0; rhs = b;
virtual WCardFilter * Right(){return rhs;}; }
virtual WCardFilter * Left(){return lhs;}; ;
~WCFBranch()
{
SAFE_DELETE(lhs);
SAFE_DELETE(rhs);
}
;
virtual bool isMatch(MTGCard * c) = 0;
virtual string getCode() = 0;
virtual WCardFilter * Right()
{
return rhs;
}
;
virtual WCardFilter * Left()
{
return lhs;
}
;
protected: protected:
WCardFilter *lhs, *rhs; WCardFilter *lhs, *rhs;
}; };
class WCFilterOR: public WCFBranch{ class WCFilterOR: public WCFBranch
{
public: public:
WCFilterOR(WCardFilter * a, WCardFilter * b): WCFBranch(a,b) {}; WCFilterOR(WCardFilter * a, WCardFilter * b) :
bool isMatch(MTGCard *c); WCFBranch(a, b)
string getCode(); {
float filterFee(); }
;
bool isMatch(MTGCard *c);
string getCode();
float filterFee();
}; };
class WCFilterAND: public WCFBranch{ class WCFilterAND: public WCFBranch
{
public: public:
WCFilterAND(WCardFilter * a, WCardFilter * b): WCFBranch(a,b) {}; WCFilterAND(WCardFilter * a, WCardFilter * b) :
bool isMatch(MTGCard *c) {return (lhs->isMatch(c) && rhs->isMatch(c));}; WCFBranch(a, b)
string getCode(); {
float filterFee(); }
;
bool isMatch(MTGCard *c)
{
return (lhs->isMatch(c) && rhs->isMatch(c));
}
;
string getCode();
float filterFee();
}; };
class WCFilterGROUP: public WCardFilter{ class WCFilterGROUP: public WCardFilter
{
public: public:
WCFilterGROUP(WCardFilter * _k) {kid = _k;}; WCFilterGROUP(WCardFilter * _k)
~WCFilterGROUP() {SAFE_DELETE(kid);}; {
bool isMatch(MTGCard *c) {return kid->isMatch(c);}; kid = _k;
string getCode(); }
float filterFee() {return kid->filterFee();}; ;
~WCFilterGROUP()
{
SAFE_DELETE(kid);
}
;
bool isMatch(MTGCard *c)
{
return kid->isMatch(c);
}
;
string getCode();
float filterFee()
{
return kid->filterFee();
}
;
protected: protected:
WCardFilter * kid; WCardFilter * kid;
}; };
class WCFilterNOT: public WCardFilter{ class WCFilterNOT: public WCardFilter
{
public: public:
WCFilterNOT(WCardFilter * _k) {kid = _k;}; WCFilterNOT(WCardFilter * _k)
~WCFilterNOT() {SAFE_DELETE(kid);}; {
bool isMatch(MTGCard *c) {return !kid->isMatch(c);}; kid = _k;
string getCode(); }
;
~WCFilterNOT()
{
SAFE_DELETE(kid);
}
;
bool isMatch(MTGCard *c)
{
return !kid->isMatch(c);
}
;
string getCode();
protected: protected:
WCardFilter * kid; WCardFilter * kid;
}; };
class WCFilterNULL: public WCardFilter{ class WCFilterNULL: public WCardFilter
{
public: public:
WCFilterNULL() {}; WCFilterNULL()
string getCode() {return "NULL";}; {
bool isMatch(MTGCard *c) {return true;}; }
;
string getCode()
{
return "NULL";
}
;
bool isMatch(MTGCard *c)
{
return true;
}
;
}; };
//Filter terminals: //Filter terminals:
class WCFilterSet: public WCardFilter{ class WCFilterSet: public WCardFilter
{
public: public:
WCFilterSet(int _setid=MTGSets::ALL_SETS) {setid=_setid;}; WCFilterSet(int _setid = MTGSets::ALL_SETS)
WCFilterSet(string arg); {
bool isMatch(MTGCard *c) {return (setid==MTGSets::ALL_SETS || c->setId == setid);}; setid = _setid;
string getCode(); }
float filterFee() {return 0.2f;}; ;
WCFilterSet(string arg);
bool isMatch(MTGCard *c)
{
return (setid == MTGSets::ALL_SETS || c->setId == setid);
}
;
string getCode();
float filterFee()
{
return 0.2f;
}
;
protected: protected:
int setid; int setid;
}; };
class WCFilterLetter: public WCardFilter{ class WCFilterLetter: public WCardFilter
{
public: public:
WCFilterLetter(string arg); WCFilterLetter(string arg);
bool isMatch(MTGCard * c); bool isMatch(MTGCard * c);
string getCode(); string getCode();
float filterFee() {return 4.0f;}; //Alpha searches are expensive! float filterFee()
{
return 4.0f;
}
; //Alpha searches are expensive!
protected: protected:
char alpha; char alpha;
}; };
class WCFilterColor: public WCardFilter{ class WCFilterColor: public WCardFilter
{
public: public:
WCFilterColor(int _c) {color = _c;}; WCFilterColor(int _c)
WCFilterColor(string arg); {
bool isMatch(MTGCard * c); color = _c;
string getCode(); }
float filterFee() {return 0.2f;}; ;
WCFilterColor(string arg);
bool isMatch(MTGCard * c);
string getCode();
float filterFee()
{
return 0.2f;
}
;
protected: protected:
int color; int color;
}; };
class WCFilterOnlyColor: public WCFilterColor{ class WCFilterOnlyColor: public WCFilterColor
{
public: public:
WCFilterOnlyColor(int _c) : WCFilterColor(_c) {}; WCFilterOnlyColor(int _c) : WCFilterColor(_c) {};
WCFilterOnlyColor(string arg) : WCFilterColor(arg) {}; WCFilterOnlyColor(string arg) : WCFilterColor(arg) {};
bool isMatch(MTGCard * c); bool isMatch(MTGCard * c);
string getCode(); string getCode();
}; };
class WCFilterProducesColor: public WCFilterColor{ class WCFilterProducesColor: public WCFilterColor
{
public: public:
WCFilterProducesColor(int _c) : WCFilterColor(_c) {}; WCFilterProducesColor(int _c) : WCFilterColor(_c) {};
WCFilterProducesColor(string arg) : WCFilterColor(arg) {}; WCFilterProducesColor(string arg) : WCFilterColor(arg) {};
bool isMatch(MTGCard * c); bool isMatch(MTGCard * c);
string getCode(); string getCode();
}; };
class WCFilterNumeric: public WCardFilter{ class WCFilterNumeric: public WCardFilter
{
public: public:
WCFilterNumeric(int _num) {number = _num;}; WCFilterNumeric(int _num)
WCFilterNumeric(string arg); {
bool isMatch(MTGCard * c) = 0; number = _num;
string getCode() = 0; }
float filterFee() = 0; ;
WCFilterNumeric(string arg);
bool isMatch(MTGCard * c) = 0;
string getCode() = 0;
float filterFee() = 0;
protected: protected:
int number; int number;
}; };
class WCFilterCMC: public WCFilterNumeric{ class WCFilterCMC: public WCFilterNumeric
{
public: public:
WCFilterCMC(int amt) : WCFilterNumeric(amt) {}; WCFilterCMC(int amt) : WCFilterNumeric(amt) {};
WCFilterCMC(string arg) : WCFilterNumeric(arg) {}; WCFilterCMC(string arg) : WCFilterNumeric(arg) {};
bool isMatch(MTGCard * c); bool isMatch(MTGCard * c);
string getCode(); string getCode();
float filterFee() {return number/20.0f;}; float filterFee()
{
return number / 20.0f;
}
;
}; };
class WCFilterPower: public WCFilterNumeric{ class WCFilterPower: public WCFilterNumeric
{
public: public:
WCFilterPower(int amt) : WCFilterNumeric(amt) {}; WCFilterPower(int amt) : WCFilterNumeric(amt) {};
WCFilterPower(string arg) : WCFilterNumeric(arg) {}; WCFilterPower(string arg) : WCFilterNumeric(arg) {};
bool isMatch(MTGCard * c); bool isMatch(MTGCard * c);
string getCode(); string getCode();
float filterFee() {return 2*number/12.0f;}; float filterFee()
{
return 2 * number / 12.0f;
}
;
}; };
class WCFilterToughness: public WCFilterNumeric{ class WCFilterToughness: public WCFilterNumeric
{
public: public:
WCFilterToughness(int amt) : WCFilterNumeric(amt) {}; WCFilterToughness(int amt) : WCFilterNumeric(amt) {};
WCFilterToughness(string arg) : WCFilterNumeric(arg) {}; WCFilterToughness(string arg) : WCFilterNumeric(arg) {};
bool isMatch(MTGCard * c); bool isMatch(MTGCard * c);
string getCode(); string getCode();
float filterFee() {return 2*number/12.0f;}; float filterFee()
{
return 2 * number / 12.0f;
}
;
}; };
class WCFilterType: public WCardFilter{ class WCFilterType: public WCardFilter
{
public: public:
WCFilterType(string arg) {type = arg;}; WCFilterType(string arg)
bool isMatch(MTGCard * c); {
string getCode(); type = arg;
float filterFee() {return 0.4f;}; }
;
bool isMatch(MTGCard * c);
string getCode();
float filterFee()
{
return 0.4f;
}
;
protected: protected:
string type; string type;
}; };
class WCFilterRarity: public WCardFilter{ class WCFilterRarity: public WCardFilter
{
public: public:
WCFilterRarity(char _r) {rarity = _r;}; WCFilterRarity(char _r)
WCFilterRarity(string arg); {
bool isMatch(MTGCard * c); rarity = _r;
string getCode(); }
float filterFee(); ;
WCFilterRarity(string arg);
bool isMatch(MTGCard * c);
string getCode();
float filterFee();
protected: protected:
char rarity; char rarity;
}; };
class WCFilterAbility: public WCardFilter{ class WCFilterAbility: public WCardFilter
{
public: public:
WCFilterAbility(int _a) {ability = _a;}; WCFilterAbility(int _a)
WCFilterAbility(string arg); {
bool isMatch(MTGCard * c); ability = _a;
string getCode(); }
float filterFee(); ;
WCFilterAbility(string arg);
bool isMatch(MTGCard * c);
string getCode();
float filterFee();
protected: protected:
int ability; int ability;
}; };
#endif #endif

View File

@@ -8,151 +8,198 @@
namespace Fonts namespace Fonts
{ {
enum Font_Type enum Font_Type
{ {
MAIN_FONT = 0, MAIN_FONT = 0,
MENU_FONT = 1, MENU_FONT = 1,
OPTION_FONT = 1, OPTION_FONT = 1,
MAGIC_FONT = 2, MAGIC_FONT = 2,
SMALLFACE_FONT = 3 SMALLFACE_FONT = 3
}; };
// when using gbk languages and we need to keep around single byte font variants, // when using gbk languages and we need to keep around single byte font variants,
// the single byte fonts will be offset by this value // the single byte fonts will be offset by this value
const unsigned int kSingleByteFontOffset = 100; const unsigned int kSingleByteFontOffset = 100;
} }
class WFont class WFont
{ {
public: public:
int mFontID; int mFontID;
// Rendering text to screen. // Rendering text to screen.
// Note: // Note:
// align=JGETEXT_LEFT, string region (x-leftOffset, x-leftOffset+StringWidth), display window (x, x+displayWidth) // align=JGETEXT_LEFT, string region (x-leftOffset, x-leftOffset+StringWidth), display window (x, x+displayWidth)
// align=JGETEXT_CENTER, string region (x-leftOffset-StringWidth/2, x-leftOffset+StringWidth/2), display window (x-displayWidth/2, x+displayWidth/2) // align=JGETEXT_CENTER, string region (x-leftOffset-StringWidth/2, x-leftOffset+StringWidth/2), display window (x-displayWidth/2, x+displayWidth/2)
// align=JGETEXT_RIGHT, string region (x-leftOffset-StringWidth, x-leftOffset), display window (x-displayWidth, x) // align=JGETEXT_RIGHT, string region (x-leftOffset-StringWidth, x-leftOffset), display window (x-displayWidth, x)
// Only when width is NOT zero, characters outside the display window are not rendered. // Only when width is NOT zero, characters outside the display window are not rendered.
// //
virtual void DrawString(const char *s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float displayWidth = 0) = 0; virtual void DrawString(const char *s, float x, float y, int align = JGETEXT_LEFT, float leftOffset = 0, float displayWidth = 0) = 0;
virtual void DrawString(std::string s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float displayWidth = 0) = 0; virtual void DrawString(std::string s, float x, float y, int align = JGETEXT_LEFT, float leftOffset = 0, float displayWidth = 0) = 0;
// Set font color. // Set font color.
virtual void SetColor(PIXEL_TYPE color) = 0; virtual void SetColor(PIXEL_TYPE color) = 0;
// Get font color. // Get font color.
virtual PIXEL_TYPE GetColor() const = 0; virtual PIXEL_TYPE GetColor() const = 0;
// Set scale for rendering. // Set scale for rendering.
virtual void SetScale(float scale) = 0; virtual void SetScale(float scale) = 0;
// Get rendering scale. // Get rendering scale.
virtual float GetScale() const = 0; virtual float GetScale() const = 0;
// Get height of font. // Get height of font.
virtual float GetHeight() const = 0; virtual float GetHeight() const = 0;
// Get width of rendering string on screen. // Get width of rendering string on screen.
virtual float GetStringWidth(const char *s) const = 0; virtual float GetStringWidth(const char *s) const = 0;
// Set font tracking. // Set font tracking.
virtual void SetTracking(float tracking) = 0; virtual void SetTracking(float tracking) = 0;
// Set Base for the character set to use. // Set Base for the character set to use.
virtual void SetBase(int base) = 0; virtual void SetBase(int base) = 0;
// Format text. // Format text.
virtual void FormatText(string &s, vector<string>& output) = 0; virtual void FormatText(string &s, vector<string>& output) = 0;
WFont(int inID) : mFontID(inID) {}; WFont(int inID) : mFontID(inID) {};
virtual ~WFont() {}; virtual ~WFont() {};
}; };
class WLBFont : public WFont class WLBFont: public WFont
{ {
public: public:
WLBFont(int inFontID, const char *fontname, int lineheight, bool useVideoRAM=false); WLBFont(int inFontID, const char *fontname, int lineheight, bool useVideoRAM = false);
~WLBFont() {SAFE_DELETE(it);}; ~WLBFont()
{
SAFE_DELETE(it);
}
;
void DrawString(const char *s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float width = 0) {it->DrawString(s,x,y,align,leftOffset,width);}; void DrawString(const char *s, float x, float y, int align = JGETEXT_LEFT, float leftOffset = 0, float width = 0)
void DrawString(std::string s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float width = 0) {it->DrawString(s,x,y,align,leftOffset,width);}; {
void SetColor(PIXEL_TYPE color) {it->SetColor(color);}; it->DrawString(s, x, y, align, leftOffset, width);
PIXEL_TYPE GetColor() const {return it->GetColor();}; }
void SetScale(float scale) {it->SetScale(scale);}; ;
float GetScale() const {return it->GetScale();}; void DrawString(std::string s, float x, float y, int align = JGETEXT_LEFT, float leftOffset = 0, float width = 0)
float GetHeight() const {return it->GetHeight();}; {
float GetStringWidth(const char *s) const {return it->GetStringWidth(s);}; it->DrawString(s, x, y, align, leftOffset, width);
void SetTracking(float tracking) {it->SetTracking(tracking);}; }
void SetBase(int base) {it->SetBase(base);}; ;
void FormatText(string &s, vector<string>& output); void SetColor(PIXEL_TYPE color)
{
it->SetColor(color);
}
;
PIXEL_TYPE GetColor() const
{
return it->GetColor();
}
;
void SetScale(float scale)
{
it->SetScale(scale);
}
;
float GetScale() const
{
return it->GetScale();
}
;
float GetHeight() const
{
return it->GetHeight();
}
;
float GetStringWidth(const char *s) const
{
return it->GetStringWidth(s);
}
;
void SetTracking(float tracking)
{
it->SetTracking(tracking);
}
;
void SetBase(int base)
{
it->SetBase(base);
}
;
void FormatText(string &s, vector<string>& output);
private: private:
JLBFont * it; JLBFont * it;
}; };
class WFBFont : public WFont class WFBFont: public WFont
{ {
public: public:
WFBFont(int inFontID, const char *fontname, int lineheight, bool useVideoRAM=false); WFBFont(int inFontID, const char *fontname, int lineheight, bool useVideoRAM = false);
WFBFont(int inFontID) : WFont(inFontID) {}; // Legacy : remove it when possible WFBFont(int inFontID) : WFont(inFontID) {}; // Legacy : remove it when possible
~WFBFont(); ~WFBFont();
void DrawString(std::string s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float width = 0); void DrawString(std::string s, float x, float y, int align = JGETEXT_LEFT, float leftOffset = 0, float width = 0);
void SetColor(PIXEL_TYPE color); void SetColor(PIXEL_TYPE color);
PIXEL_TYPE GetColor() const {return mColor0;}; PIXEL_TYPE GetColor() const
void SetScale(float scale); {
float GetScale() const; return mColor0;
float GetHeight() const; }
virtual float GetStringWidth(const char *s) const; ;
void SetTracking(float tracking) {}; void SetScale(float scale);
void SetBase(int base) {}; float GetScale() const;
void FormatText(string &s, vector<string>& output) {}; float GetHeight() const;
virtual float GetStringWidth(const char *s) const;
void SetTracking(float tracking) {};
void SetBase(int base) {};
void FormatText(string &s, vector<string>& output) {};
virtual void DrawString(const char *s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float width = 0); virtual void DrawString(const char *s, float x, float y, int align = JGETEXT_LEFT, float leftOffset = 0, float width = 0);
virtual int GetCode(const u8 *ch, int *charLength) const = 0; virtual int GetCode(const u8 *ch, int *charLength) const = 0;
virtual int GetMana(const u8 *ch) const = 0; virtual int GetMana(const u8 *ch) const = 0;
protected: protected:
static JRenderer* mRenderer; static JRenderer* mRenderer;
u16* mIndex; u16* mIndex;
u8* mStdFont; u8* mStdFont;
u8* mExtraFont; u8* mExtraFont;
PIXEL_TYPE mColor0; PIXEL_TYPE mColor0;
PIXEL_TYPE mColor; PIXEL_TYPE mColor;
unsigned int mFontSize; unsigned int mFontSize;
float mScale; float mScale;
unsigned int mBytesPerChar; unsigned int mBytesPerChar;
unsigned int mBytesPerRow; unsigned int mBytesPerRow;
int mCacheImageWidth; int mCacheImageWidth;
int mCacheImageHeight; int mCacheImageHeight;
int mCol; int mCol;
int mRow; int mRow;
int mCacheSize; int mCacheSize;
JTexture * mTexture; JTexture * mTexture;
JQuad ** mSprites; JQuad ** mSprites;
int *mGBCode; int *mGBCode;
int mCurr; int mCurr;
u32 * mCharBuffer; u32 * mCharBuffer;
virtual int PreCacheChar(const u8 *ch); virtual int PreCacheChar(const u8 *ch);
}; };
class WGBKFont : public WFBFont class WGBKFont: public WFBFont
{ {
public: public:
WGBKFont(int inFontID, const char *fontname, int lineheight, bool useVideoRAM = false); WGBKFont(int inFontID, const char *fontname, int lineheight, bool useVideoRAM = false);
int PreCacheChar(const u8 *ch); int PreCacheChar(const u8 *ch);
float GetStringWidth(const char *s) const; float GetStringWidth(const char *s) const;
void DrawString(const char *s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float width = 0); void DrawString(const char *s, float x, float y, int align = JGETEXT_LEFT, float leftOffset = 0, float width = 0);
int GetCode(const u8 *ch, int *charLength) const; int GetCode(const u8 *ch, int *charLength) const;
int GetMana(const u8 *ch) const; int GetMana(const u8 *ch) const;
void FormatText(string &s, vector<string>& output); void FormatText(string &s, vector<string>& output);
}; };
class WUFont : public WFBFont class WUFont: public WFBFont
{ {
public: public:
WUFont(int inFontID, const char *fontname, int lineheight, bool useVideoRAM = false) WUFont(int inFontID, const char *fontname, int lineheight, bool useVideoRAM = false) :
: WFBFont(inFontID, fontname, lineheight, useVideoRAM) {}; WFBFont(inFontID, fontname, lineheight, useVideoRAM) {};
int GetCode(const u8 *ch, int *charLength) const; int GetCode(const u8 *ch, int *charLength) const;
int GetMana(const u8 *ch) const; int GetMana(const u8 *ch) const;
void FormatText(string &s, vector<string>& output); void FormatText(string &s, vector<string>& output);
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@@ -20,7 +20,6 @@
#define MAX_CACHE_TIME 2000000000 #define MAX_CACHE_TIME 2000000000
#endif #endif
#define THUMBNAILS_OFFSET 100000000 #define THUMBNAILS_OFFSET 100000000
#define OTHERS_OFFSET 2000000000 #define OTHERS_OFFSET 2000000000
@@ -31,54 +30,61 @@
#define MAX_CACHED_SAMPLES 50 #define MAX_CACHED_SAMPLES 50
#define MAX_CACHE_GARBAGE 10 #define MAX_CACHE_GARBAGE 10
enum ENUM_WRES_INFO
enum ENUM_WRES_INFO{ {
WRES_UNLOCKED = 0, //Resource is unlocked. WRES_UNLOCKED = 0, //Resource is unlocked.
WRES_MAX_LOCK = 250, //Maximum number of locks for a resource. WRES_MAX_LOCK = 250, //Maximum number of locks for a resource.
WRES_PERMANENT = 251, //Resource is permanent (ie, managed) WRES_PERMANENT = 251, //Resource is permanent (ie, managed)
WRES_UNDERLOCKED = 252, //Resource was released too many times. WRES_UNDERLOCKED = 252,
//Resource was released too many times.
}; };
enum ENUM_RETRIEVE_STYLE{ enum ENUM_RETRIEVE_STYLE
RETRIEVE_EXISTING, //Only returns a resource if it already exists. Does not lock or unlock. {
RETRIEVE_NORMAL, //Returns or creates a resource. Does not change lock status. RETRIEVE_EXISTING, //Only returns a resource if it already exists. Does not lock or unlock.
RETRIEVE_LOCK, //As above, locks cached resource. Not for quads. RETRIEVE_NORMAL, //Returns or creates a resource. Does not change lock status.
RETRIEVE_UNLOCK, //As above, unlocks cached resource. Not for quads. RETRIEVE_LOCK, //As above, locks cached resource. Not for quads.
RETRIEVE_RESOURCE, //Only retrieves a managed resource. Does not make a new one. RETRIEVE_UNLOCK, //As above, unlocks cached resource. Not for quads.
RETRIEVE_MANAGE, //Makes resource permanent. RETRIEVE_RESOURCE, //Only retrieves a managed resource. Does not make a new one.
RETRIEVE_THUMB, //Retrieve it as a thumbnail. RETRIEVE_MANAGE, //Makes resource permanent.
CACHE_THUMB = RETRIEVE_THUMB, //Backwords compatibility. RETRIEVE_THUMB, //Retrieve it as a thumbnail.
CACHE_THUMB = RETRIEVE_THUMB,
//Backwords compatibility.
}; };
enum ENUM_CACHE_SUBTYPE{ enum ENUM_CACHE_SUBTYPE
CACHE_NORMAL = (1<<0), //Use default values. Not really a flag. {
CACHE_EXISTING = (1<<1), //Retrieve it only if it already exists CACHE_NORMAL = (1 << 0), //Use default values. Not really a flag.
CACHE_EXISTING = (1 << 1), //Retrieve it only if it already exists
//Because these bits only modify how a cached resource's Attempt() is called, //Because these bits only modify how a cached resource's Attempt() is called,
//We can use them over and over for each resource type. //We can use them over and over for each resource type.
TEXTURE_SUB_EXACT = (1<<2), //Don't do any fiddling with the filename. TEXTURE_SUB_EXACT = (1 << 2), //Don't do any fiddling with the filename.
TEXTURE_SUB_CARD = (1<<3), //Retrieve using cardFile, not graphicsFile. TEXTURE_SUB_CARD = (1 << 3), //Retrieve using cardFile, not graphicsFile.
TEXTURE_SUB_AVATAR = (1<<4), //Retrieve using avatarFile, not graphicsFile. TEXTURE_SUB_AVATAR = (1 << 4), //Retrieve using avatarFile, not graphicsFile.
TEXTURE_SUB_THUMB = (1<<5),//Retrieve prepending "thumbnails\" to the filename. TEXTURE_SUB_THUMB = (1 << 5),//Retrieve prepending "thumbnails\" to the filename.
TEXTURE_SUB_5551 = (1<<6), //For textures. If we have to allocate, use RGBA5551. TEXTURE_SUB_5551 = (1 << 6),
//For textures. If we have to allocate, use RGBA5551.
}; };
enum ENUM_CACHE_ERROR{ enum ENUM_CACHE_ERROR
{
CACHE_ERROR_NONE = 0, CACHE_ERROR_NONE = 0,
CACHE_ERROR_NOT_CACHED = CACHE_ERROR_NONE, CACHE_ERROR_NOT_CACHED = CACHE_ERROR_NONE,
CACHE_ERROR_404, CACHE_ERROR_404,
CACHE_ERROR_BAD, //Something went wrong with item->attempt() CACHE_ERROR_BAD, //Something went wrong with item->attempt()
CACHE_ERROR_BAD_ALLOC, //Couldn't allocate item CACHE_ERROR_BAD_ALLOC, //Couldn't allocate item
CACHE_ERROR_LOST, CACHE_ERROR_LOST,
CACHE_ERROR_NOT_MANAGED, CACHE_ERROR_NOT_MANAGED,
}; };
struct WCacheSort{ struct WCacheSort
{
bool operator()(const WResource * l, const WResource * r); //Predicate for use in sorting. See flatten(). bool operator()(const WResource * l, const WResource * r); //Predicate for use in sorting. See flatten().
}; };
template <class cacheItem, class cacheActual> template<class cacheItem, class cacheActual>
class WCache class WCache
{ {
public: public:
@@ -87,13 +93,13 @@ public:
WCache(); WCache();
~WCache(); ~WCache();
cacheItem* Retrieve(int id, const string& filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL); //Primary interface function. cacheItem* Retrieve(int id, const string& filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL); //Primary interface function.
bool Release(cacheActual* actual); //Releases an item, and deletes it if unlocked. bool Release(cacheActual* actual); //Releases an item, and deletes it if unlocked.
bool RemoveMiss(int id=0); //Removes a cache miss. bool RemoveMiss(int id = 0); //Removes a cache miss.
bool RemoveOldest(); //Remove oldest unlocked item. bool RemoveOldest(); //Remove oldest unlocked item.
bool Cleanup(); //Repeats RemoveOldest() until cache fits in size limits bool Cleanup(); //Repeats RemoveOldest() until cache fits in size limits
void ClearUnlocked(); //Remove all unlocked items. void ClearUnlocked(); //Remove all unlocked items.
void Refresh(); //Refreshes all cache items. void Refresh(); //Refreshes all cache items.
unsigned int Flatten(); //Ensures that the times don't loop. Returns new lastTime. unsigned int Flatten(); //Ensures that the times don't loop. Returns new lastTime.
void Resize(unsigned long size, int items); //Sets new limits, then enforces them. Lock safe, so not a "hard limit". void Resize(unsigned long size, int items); //Sets new limits, then enforces them. Lock safe, so not a "hard limit".
protected: protected:
@@ -101,25 +107,24 @@ protected:
bool UnlinkCache(cacheItem * item); //Removes an item from our cache, does not delete it. Use with care. bool UnlinkCache(cacheItem * item); //Removes an item from our cache, does not delete it. Use with care.
bool Delete(cacheItem * item); //SAFE_DELETE and garbage collect. If maxCached == 0, nullify first. (This means you have to free that cacheActual later!) bool Delete(cacheItem * item); //SAFE_DELETE and garbage collect. If maxCached == 0, nullify first. (This means you have to free that cacheActual later!)
cacheItem* Get(int id, const string& filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL); //Subordinate to Retrieve. cacheItem* Get(int id, const string& filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL); //Subordinate to Retrieve.
cacheItem* AttemptNew(const string& filename, int submode); //Attempts a new cache item, progressively clearing cache if it fails. cacheItem* AttemptNew(const string& filename, int submode); //Attempts a new cache item, progressively clearing cache if it fails.
int makeID(int id, const string& filename, int submode); //Makes an ID appropriate to the submode. int makeID(int id, const string& filename, int submode); //Makes an ID appropriate to the submode.
map<string,int> ids; map<string, int> ids;
map<int,cacheItem*> cache; map<int, cacheItem*> cache;
map<int,cacheItem*> managed; //Cache can be arbitrarily large, so managed items are seperate. map<int, cacheItem*> managed; //Cache can be arbitrarily large, so managed items are seperate.
unsigned long totalSize; unsigned long totalSize;
unsigned long cacheSize; unsigned long cacheSize;
//Applies to cacheSize only. //Applies to cacheSize only.
unsigned long maxCacheSize; unsigned long maxCacheSize;
unsigned int maxCached; unsigned int maxCached;
unsigned int cacheItems; unsigned int cacheItems;
int mError; int mError;
}; };
struct WManagedQuad struct WManagedQuad
{ {
WCachedTexture * texture; WCachedTexture * texture;
@@ -149,10 +154,10 @@ public:
virtual ~WResourceManager(); virtual ~WResourceManager();
void Unmiss(string filename); void Unmiss(string filename);
JQuad * RetrieveCard(MTGCard * card, int style = RETRIEVE_NORMAL,int submode = CACHE_NORMAL); JQuad * RetrieveCard(MTGCard * card, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL);
JSample * RetrieveSample(const string& filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL); JSample * RetrieveSample(const string& filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL);
JTexture * RetrieveTexture(const string& filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL); JTexture * RetrieveTexture(const string& filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL);
JQuad * RetrieveQuad(const string& filename, float offX=0.0f, float offY=0.0f, float width=0.0f, float height=0.0f, string resname="", int style = RETRIEVE_LOCK, int submode = CACHE_NORMAL, int id = 0); JQuad * RetrieveQuad(const string& filename, float offX = 0.0f, float offY = 0.0f, float width = 0.0f, float height = 0.0f, string resname = "", int style = RETRIEVE_LOCK, int submode = CACHE_NORMAL, int id = 0);
JQuad * RetrieveTempQuad(const string& filename, int submode = CACHE_NORMAL); JQuad * RetrieveTempQuad(const string& filename, int submode = CACHE_NORMAL);
hgeParticleSystemInfo * RetrievePSI(const string& filename, JQuad * texture, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL); hgeParticleSystemInfo * RetrievePSI(const string& filename, JQuad * texture, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL);
int RetrieveError(); int RetrieveError();
@@ -161,19 +166,19 @@ public:
void Release(JSample * sample); void Release(JSample * sample);
bool RemoveOldest(); bool RemoveOldest();
bool Cleanup(); //Force a cleanup. Return false if nothing removed. bool Cleanup(); //Force a cleanup. Return false if nothing removed.
void ClearUnlocked(); //Remove unlocked items. void ClearUnlocked(); //Remove unlocked items.
void Refresh(); //Refreshes all files in cache, for when mode/profile changes. void Refresh(); //Refreshes all files in cache, for when mode/profile changes.
unsigned int nowTime(); unsigned int nowTime();
unsigned long Size(); unsigned long Size();
unsigned long SizeCached(); unsigned long SizeCached();
unsigned long SizeManaged(); unsigned long SizeManaged();
unsigned int Count(); unsigned int Count();
unsigned int CountCached(); unsigned int CountCached();
unsigned int CountManaged(); unsigned int CountManaged();
int CreateQuad(const string &quadName, const string &textureName, float x, float y, float width, float height); int CreateQuad(const string &quadName, const string &textureName, float x, float y, float width, float height);
JQuad* GetQuad(const string &quadName); JQuad* GetQuad(const string &quadName);
@@ -206,7 +211,7 @@ public:
JMusic * ssLoadMusic(const char *fileName); JMusic * ssLoadMusic(const char *fileName);
//Resets the cache limits on when it starts to purge data. //Resets the cache limits on when it starts to purge data.
void ResetCacheLimits(); void ResetCacheLimits();
void DebugRender(); void DebugRender();
@@ -217,17 +222,17 @@ public:
private: private:
/* /*
** Singleton object only accessibly via Instance(), constructor is private ** Singleton object only accessibly via Instance(), constructor is private
*/ */
WResourceManager(); WResourceManager();
bool bThemedCards; //Does the theme have a "sets" directory for overwriting cards? bool bThemedCards; //Does the theme have a "sets" directory for overwriting cards?
void FlattenTimes(); //To prevent bad cache timing on int overflow void FlattenTimes(); //To prevent bad cache timing on int overflow
//For cached stuff //For cached stuff
WCache<WCachedTexture,JTexture> textureWCache; WCache<WCachedTexture, JTexture> textureWCache;
WCache<WCachedSample,JSample> sampleWCache; WCache<WCachedSample, JSample> sampleWCache;
WCache<WCachedParticles,hgeParticleSystemInfo> psiWCache; WCache<WCachedParticles, hgeParticleSystemInfo> psiWCache;
typedef std::map<std::string, WManagedQuad> ManagedQuadMap; typedef std::map<std::string, WManagedQuad> ManagedQuadMap;
ManagedQuadMap mManagedQuads; ManagedQuadMap mManagedQuads;
@@ -239,7 +244,7 @@ private:
unsigned int lastTime; unsigned int lastTime;
int lastError; int lastError;
typedef std::map<int, WFont*> FontMap; typedef std::map<int, WFont*> FontMap;
FontMap mWFontMap; FontMap mWFontMap;
std::string mFontFileExtension; std::string mFontFileExtension;

View File

@@ -12,12 +12,8 @@
#define OutputDebugString(val) {} #define OutputDebugString(val) {}
#endif #endif
#include "limits.h" #include "limits.h"
#if defined (_DEBUG) && defined (WIN32) #if defined (_DEBUG) && defined (WIN32)
#include "crtdbg.h" #include "crtdbg.h"
#define NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) #define NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
@@ -38,7 +34,6 @@
#endif #endif
#endif #endif
#ifndef RESPATH #ifndef RESPATH
#define RESPATH "Res" #define RESPATH "Res"
#endif #endif

Some files were not shown because too many files have changed in this diff Show More