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
+2 -2
View File
@@ -3,8 +3,8 @@
#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);
+41 -26
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();
@@ -62,18 +64,20 @@ 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,7 +90,7 @@ 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)
@@ -97,18 +101,29 @@ public:
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,13 +132,13 @@ 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);
@@ -131,10 +146,10 @@ class AIPlayerBaka: public AIPlayer{
virtual int computeActions(); virtual int computeActions();
}; };
class AIPlayerFactory{ class AIPlayerFactory
public: {
public:
AIPlayer * createAIPlayer(MTGAllCards * collection, Player * opponent, int deckid = 0); AIPlayer * createAIPlayer(MTGAllCards * collection, Player * opponent, int deckid = 0);
}; };
#endif #endif
+12 -8
View File
@@ -18,19 +18,23 @@ class MTGCard;
class Damage; class Damage;
class WEvent; class WEvent;
class AIStat{ class AIStat
public: {
public:
int source; //MTGId of the card int source; //MTGId of the card
int value; int value;
int occurences; int occurences;
bool direct; bool direct;
AIStat(int _source, int _value, int _occurences, bool _direct):source(_source), value(_value),occurences(_occurences),direct(_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;
@@ -39,7 +43,7 @@ class 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();
+45 -15
View File
@@ -12,20 +12,18 @@
#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: {
protected:
int activeState; int activeState;
public:
public:
int isClone; int isClone;
TargetChooser * tc; TargetChooser * tc;
int currentPhase; int currentPhase;
@@ -35,20 +33,52 @@ class ActionElement: public JGuiObject{
int getActivity(); int getActivity();
virtual void Update(float dt){}; virtual void Update(float dt){};
virtual void Render(){}; virtual void Render(){};
virtual int testDestroy(){return 0;}; virtual int testDestroy()
virtual int destroy(){return 0;}; {
virtual bool CheckUserInput(JButton key){return false;}; return 0;
}
;
virtual int destroy()
{
return 0;
}
;
virtual bool CheckUserInput(JButton key)
{
return false;
}
;
ActionElement(int id); ActionElement(int id);
virtual ~ActionElement(); virtual ~ActionElement();
virtual int isReactingToTargetClick(Targetable * card); virtual int isReactingToTargetClick(Targetable * card);
virtual int reactToTargetClick(Targetable * card); virtual int reactToTargetClick(Targetable * card);
virtual int isReactingToClick(MTGCardInstance * card, ManaCost * man = NULL){return 0;}; virtual int isReactingToClick(MTGCardInstance * card, ManaCost * man = NULL)
virtual int stillInUse(MTGCardInstance * card){return 0;}; {
virtual int receiveEvent(WEvent * event){return 0;}; return 0;
virtual int reactToClick(MTGCardInstance * card){return 0;}; }
virtual const char * getMenuText(){return "Ability";}; ;
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; virtual ActionElement * clone() const = 0;
}; };
#endif #endif
+6 -7
View File
@@ -16,9 +16,10 @@ 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:
vector<ActionElement *> garbage;
Targetable * menuObject; Targetable * menuObject;
SimpleMenu * abilitiesMenu; SimpleMenu * abilitiesMenu;
int stuffHappened; int stuffHappened;
@@ -34,8 +35,8 @@ class ActionLayer: public GuiLayer, public JGuiListener{
int reactToTargetClick(Targetable * card); int reactToTargetClick(Targetable * card);
int isReactingToClick(MTGCardInstance * card); int isReactingToClick(MTGCardInstance * card);
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
int reactToClick(ActionElement * ability,MTGCardInstance * card); int reactToClick(ActionElement * ability, MTGCardInstance * card);
int reactToTargetClick(ActionElement * ability,Targetable * card); int reactToTargetClick(ActionElement * ability, Targetable * card);
int stillInUse(MTGCardInstance * card); int stillInUse(MTGCardInstance * card);
void setMenuObject(Targetable * object, bool must = false); void setMenuObject(Targetable * object, bool must = false);
void ButtonPressed(int controllerid, int controlid); void ButtonPressed(int controllerid, int controlid);
@@ -50,6 +51,4 @@ protected:
int cantCancel; int cantCancel;
}; };
#endif #endif
+71 -36
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,27 +38,62 @@ 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: {
public:
//TODO : remove these when they are back in PlayGuiObject //TODO : remove these when they are back in PlayGuiObject
float x, y; 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;}; {
mHasFocus = false;
return true;
}
;
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; virtual const string getDisplayName() const;
void Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action, bool bigQuad = false); void Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action, bool bigQuad = false);
virtual int receiveEvent(WEvent * event) {return 0;}; 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
@@ -68,8 +102,9 @@ protected:
float GetVerticalTextOffset() const; float GetVerticalTextOffset() const;
}; };
class NextGamePhase: public Interruptible { class NextGamePhase: public Interruptible
public: {
public:
int resolve(); int resolve();
bool extraDamagePhase(); bool extraDamagePhase();
void Render(); void Render();
@@ -78,10 +113,11 @@ class NextGamePhase: public Interruptible {
NextGamePhase(int id); 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;
@@ -106,8 +142,9 @@ class Spell: public Interruptible {
int getNbTargets(); int getNbTargets();
}; };
class StackAbility: public Interruptible { class StackAbility: public Interruptible
public: {
public:
MTGAbility * ability; MTGAbility * ability;
int resolve(); int resolve();
void Render(); void Render();
@@ -116,8 +153,9 @@ class StackAbility: public Interruptible {
StackAbility(int id, MTGAbility * _ability); StackAbility(int id, MTGAbility * _ability);
}; };
class PutInGraveyard: public Interruptible { class PutInGraveyard: public Interruptible
public: {
public:
MTGCardInstance * card; MTGCardInstance * card;
int removeFromGame; int removeFromGame;
int resolve(); int resolve();
@@ -126,9 +164,9 @@ class PutInGraveyard: public Interruptible {
PutInGraveyard(int id, MTGCardInstance * _card); 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();
@@ -137,8 +175,9 @@ class DrawAction: public Interruptible {
DrawAction(int id, Player * _player, int _nbcards); DrawAction(int id, Player * _player, int _nbcards);
}; };
class ActionStack :public GuiLayer{ class ActionStack: public GuiLayer
protected: {
protected:
JQuad * pspIcons[8]; JQuad * pspIcons[8];
GameObserver* game; GameObserver* game;
int interruptDecision[2]; int interruptDecision[2];
@@ -147,7 +186,7 @@ class ActionStack :public GuiLayer{
int mode; int mode;
int checked; int checked;
public: public:
enum enum
{ {
@@ -158,11 +197,11 @@ class ActionStack :public GuiLayer{
}; };
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);
@@ -192,8 +231,4 @@ class ActionStack :public GuiLayer{
}; };
#endif #endif
+8 -7
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,7 +13,7 @@
#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,
@@ -21,14 +21,15 @@ enum ENUM_COMPARISON_MODES
COMPARISON_GREATER, COMPARISON_GREATER,
COMPARISON_LESS, COMPARISON_LESS,
COMPARISON_UNEQUAL COMPARISON_UNEQUAL
}; };
class CardDescriptor: public MTGCardInstance{ class CardDescriptor: public MTGCardInstance
protected: {
protected:
MTGCardInstance * match_or(MTGCardInstance * card); MTGCardInstance * match_or(MTGCardInstance * card);
MTGCardInstance * match_and(MTGCardInstance * card); MTGCardInstance * match_and(MTGCardInstance * card);
bool valueInRange(int comparisonMode, int value, int criterion); bool valueInRange(int comparisonMode, int value, int criterion);
public: public:
int mode; int mode;
int powerComparisonMode; int powerComparisonMode;
int toughnessComparisonMode; int toughnessComparisonMode;
@@ -40,7 +41,7 @@ class CardDescriptor: public MTGCardInstance{
CardDescriptor(); CardDescriptor();
void unsecureSetTapped(int i); void unsecureSetTapped(int i);
void unsecuresetfresh(int k); void unsecuresetfresh(int k);
void setNegativeSubtype( string value); void setNegativeSubtype(string value);
int counterPower; int counterPower;
int counterToughness; int counterToughness;
int counterNB; int counterNB;
+6 -5
View File
@@ -7,16 +7,18 @@ class TargetChooser;
class MTGGameZone; class MTGGameZone;
class MTGCardInstance; class MTGCardInstance;
class CardDisplay:public PlayGuiObjectController{ class CardDisplay: public PlayGuiObjectController
{
int mId; int mId;
GameObserver* game; GameObserver* game;
public: public:
int x, y , start_item, nb_displayed_items; int x, y, start_item, nb_displayed_items;
MTGGameZone * zone; MTGGameZone * zone;
TargetChooser * tc; TargetChooser * tc;
JGuiListener * listener; JGuiListener * listener;
CardDisplay(); CardDisplay();
CardDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener = NULL, TargetChooser * tc = NULL, int nb_displayed_items = 7); CardDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener = NULL, TargetChooser * tc = NULL,
int nb_displayed_items = 7);
void AddCard(MTGCardInstance * _card); void AddCard(MTGCardInstance * _card);
void rotateLeft(); void rotateLeft();
void rotateRight(); void rotateRight();
@@ -28,7 +30,6 @@ class CardDisplay:public PlayGuiObjectController{
virtual ostream& toString(ostream& out) const; 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
+4 -5
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_
+23 -12
View File
@@ -16,15 +16,16 @@ 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
@@ -35,7 +36,7 @@ struct CardGui : public PlayGuiObject {
static void AlternateRender(MTGCard * card, const Pos& pos); static void AlternateRender(MTGCard * card, const Pos& pos);
static void TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad); static void TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad);
public: public:
static const float Width; static const float Width;
static const float Height; static const float Height;
static const float BigWidth; static const float BigWidth;
@@ -54,11 +55,12 @@ struct CardGui : public PlayGuiObject {
virtual ostream& toString(ostream&) const; virtual ostream& toString(ostream&) const;
}; };
class CardView: public CardGui
{
public:
class CardView : public CardGui { typedef enum
public: {
typedef enum {
nullZone, handZone, playZone nullZone, handZone, playZone
} SelectorZone; } SelectorZone;
@@ -69,16 +71,25 @@ class CardView : public CardGui {
CardView(const SelectorZone, MTGCardInstance* card, const Pos& ref); CardView(const SelectorZone, MTGCardInstance* card, const Pos& ref);
virtual ~CardView(); virtual ~CardView();
void Render(){CardGui::Render();}; void Render()
void Render(JQuad* q){Pos::Render(q);}; {
CardGui::Render();
}
;
void Render(JQuad* q)
{
Pos::Render(q);
}
;
virtual ostream& toString(ostream&) const; virtual ostream& toString(ostream&) const;
float GetCenterX(); float GetCenterX();
float GetCenterY(); float GetCenterY();
}; };
class TransientCardView : public CardGui { class TransientCardView: public CardGui
public: {
public:
TransientCardView(MTGCardInstance* card, float x, float y); TransientCardView(MTGCardInstance* card, float x, float y);
TransientCardView(MTGCardInstance* card, const Pos& ref); TransientCardView(MTGCardInstance* card, const Pos& ref);
}; };
+7 -8
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,26 +9,27 @@
using namespace std; using namespace std;
class CardPrimitive { class CardPrimitive
protected: {
protected:
vector<string> ftdText; vector<string> ftdText;
string lcname; string lcname;
ManaCost manaCost; 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);
@@ -77,5 +77,4 @@ class CardPrimitive {
const vector<string>& formattedText(); const vector<string>& formattedText();
}; };
#endif #endif
+9 -6
View File
@@ -12,7 +12,7 @@ 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;
@@ -20,11 +20,15 @@ struct LimitorFunctor
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) :
mDrawMode(inDrawMode)
{
}
;
virtual void Add(PlayGuiObject*) = 0; virtual void Add(PlayGuiObject*) = 0;
virtual void Remove(PlayGuiObject*) = 0; virtual void Remove(PlayGuiObject*) = 0;
virtual bool CheckUserInput(JButton key) = 0; virtual bool CheckUserInput(JButton key) = 0;
@@ -43,8 +47,7 @@ protected:
int mDrawMode; int mDrawMode;
}; };
class CardSelector: public CardSelectorBase
class CardSelector : public CardSelectorBase
{ {
public: public:
struct SelectorMemory struct SelectorMemory
@@ -62,7 +65,7 @@ protected:
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&);
@@ -26,5 +26,4 @@ namespace CardSelectorSingleton
void Terminate(); void Terminate();
} }
#endif //CARDSELECTORSINGLETON_H #endif //CARDSELECTORSINGLETON_H
+11 -11
View File
@@ -2,20 +2,20 @@
#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 : {
public:
string name; string name;
int nb; int nb;
int power, toughness; int power, toughness;
MTGCardInstance * target; MTGCardInstance * target;
Counter(MTGCardInstance * _target, int _power, int _toughness); Counter(MTGCardInstance * _target, int _power, int _toughness);
Counter(MTGCardInstance * _target, const char * _name,int _power = 0 , int _toughness = 0 ); Counter(MTGCardInstance * _target, const char * _name, int _power = 0, int _toughness = 0);
int init(MTGCardInstance * _target,const char * _name, int _power, int _toughness); int init(MTGCardInstance * _target, const char * _name, int _power, int _toughness);
bool sameAs(const char * _name, int _power, int _toughness); bool sameAs(const char * _name, int _power, int _toughness);
bool cancels(int _power, int _toughness); bool cancels(int _power, int _toughness);
int added(); int added();
@@ -23,22 +23,22 @@ class Counter{
}; };
/* 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: {
public:
int mCount; int mCount;
Counter * counters[10]; Counter * counters[10];
MTGCardInstance * target; MTGCardInstance * target;
Counters(MTGCardInstance * _target); Counters(MTGCardInstance * _target);
~Counters(); ~Counters();
int addCounter(const char * _name,int _power = 0, int _toughness = 0); int addCounter(const char * _name, int _power = 0, int _toughness = 0);
int addCounter(int _power, int _toughness); int addCounter(int _power, int _toughness);
int removeCounter(const char * _name,int _power = 0, int _toughness = 0); int removeCounter(const char * _name, int _power = 0, int _toughness = 0);
int removeCounter(int _power, int _toughness); int removeCounter(int _power, int _toughness);
Counter * hasCounter(const char * _name,int _power = 0, int _toughness = 0); Counter * hasCounter(const char * _name, int _power = 0, int _toughness = 0);
Counter * hasCounter(int _power, int _toughness); Counter * hasCounter(int _power, int _toughness);
Counter * getNext(Counter * previous = NULL); Counter * getNext(Counter * previous = NULL);
int init(); int init();
}; };
#endif #endif
+4 -4
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,8 +12,8 @@ class GameApp;
using namespace std; using namespace std;
class CreditBonus
class CreditBonus{ {
public: public:
int value; int value;
string text; string text;
@@ -22,7 +21,8 @@ public:
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);
+45 -17
View File
@@ -17,27 +17,55 @@ 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:
public:
int life; int life;
int poisonCount; int poisonCount;
int damageCount; int damageCount;
int preventable; int preventable;
int type_as_damageable; int type_as_damageable;
Damageable(int _life){life=_life;}; Damageable(int _life)
int getLife(){return life;}; {
virtual int dealDamage(int damage){life-=damage;return life;}; life = _life;
virtual int afterDamage(){return 0;} }
virtual int poisoned(){return 0;} ;
virtual int prevented(){return 0;} int getLife()
virtual JQuad * getIcon(){return NULL;}; {
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: {
protected:
void init(MTGCardInstance * source, Damageable * target, int damage, int typeOfDamage); void init(MTGCardInstance * source, Damageable * target, int damage, int typeOfDamage);
public: public:
Damageable * target; Damageable * target;
int typeOfDamage; int typeOfDamage;
int damage; int damage;
@@ -48,13 +76,13 @@ class Damage: public Interruptible {
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
class DamageStack: public GuiLayer, public Interruptible
class DamageStack : public GuiLayer, public Interruptible{ {
protected: protected:
int currentState; int currentState;
GameObserver* game; GameObserver* game;
public: public:
int receiveEvent(WEvent * event); int receiveEvent(WEvent * event);
int resolve(); int resolve();
void Render(); void Render();
+4 -2
View File
@@ -6,7 +6,8 @@
class Player; class Player;
struct DamagerDamaged : TransientCardView { struct DamagerDamaged: TransientCardView
{
bool show; bool show;
Player * damageSelecter; Player * damageSelecter;
vector<Damage> damages; vector<Damage> damages;
@@ -26,7 +27,8 @@ struct DamagerDamaged : TransientCardView {
}; };
typedef DamagerDamaged DefenserDamaged; typedef DamagerDamaged DefenserDamaged;
struct AttackerDamaged : DamagerDamaged { struct AttackerDamaged: DamagerDamaged
{
vector<DefenserDamaged*> blockers; vector<DefenserDamaged*> blockers;
AttackerDamaged(MTGCardInstance* card, float x, float y, bool show, Player* damageSelecter); AttackerDamaged(MTGCardInstance* card, float x, float y, bool show, Player* damageSelecter);
AttackerDamaged(MTGCardInstance* card, const Pos& ref, bool show, Player* damageSelecter); AttackerDamaged(MTGCardInstance* card, const Pos& ref, bool show, Player* damageSelecter);
+15 -4
View File
@@ -12,12 +12,23 @@ using std::string;
class MTGDeck; class MTGDeck;
class DeckDataWrapper: public WSrcDeck { class DeckDataWrapper: public WSrcDeck
public: {
public:
MTGDeck * parent; MTGDeck * parent;
DeckDataWrapper(MTGDeck * deck); DeckDataWrapper(MTGDeck * deck);
bool next() {currentPos++; return true;}; bool next()
bool prev() {currentPos--; return true;}; {
currentPos++;
return true;
}
;
bool prev()
{
currentPos--;
return true;
}
;
void save(); void save();
void save(string filepath, bool useExpandedCardNames, string &deckTitle, string &deckDesc); void save(string filepath, bool useExpandedCardNames, string &deckTitle, string &deckDesc);
}; };
+1 -2
View File
@@ -3,8 +3,7 @@
#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;
+2 -5
View File
@@ -5,7 +5,6 @@
using namespace std; using namespace std;
class DeckManager class DeckManager
{ {
private: private:
@@ -18,11 +17,10 @@ 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();
@@ -32,8 +30,7 @@ public:
//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()
{ {
+8 -3
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);
+16 -4
View File
@@ -31,8 +31,14 @@ public:
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; } {
return mText;
}
string GetDescription()
{
return desc;
}
bool hasFocus(); 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);
@@ -40,12 +46,18 @@ public:
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
+6 -6
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
{ {
@@ -15,7 +14,8 @@ enum DECK_DIFFICULTY
EASY = 1 EASY = 1
}; };
class DeckMetaData { class DeckMetaData
{
private: private:
string _filename; string _filename;
@@ -32,7 +32,7 @@ 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 // Accessors
string getFilename(); string getFilename();
@@ -51,9 +51,10 @@ public:
}; };
class DeckMetaDataList { class DeckMetaDataList
{
private: private:
map<string,DeckMetaData *>values; map<string, DeckMetaData *> values;
public: public:
void invalidate(string filename); void invalidate(string filename);
@@ -61,7 +62,6 @@ public:
~DeckMetaDataList(); ~DeckMetaDataList();
static DeckMetaDataList * decksMetaData; static DeckMetaDataList * decksMetaData;
}; };
#endif #endif
+3 -3
View File
@@ -15,8 +15,9 @@ class GuiAvatars;
class CardSelectorBase; class CardSelectorBase;
struct Pos; struct Pos;
class DuelLayers { class DuelLayers
protected: {
protected:
int nbitems; int nbitems;
vector<GuiLayer*> objects; vector<GuiLayer*> objects;
vector<Pos*> waiters; vector<Pos*> waiters;
@@ -52,5 +53,4 @@ public:
#include "ActionStack.h" #include "ActionStack.h"
#include "Damage.h" #include "Damage.h"
#endif #endif
+2 -2
View File
@@ -3,10 +3,10 @@
#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) {};
}; };
+38 -18
View File
@@ -9,7 +9,8 @@ class TargetChooser;
class MTGCardInstance; class MTGCardInstance;
class MTGAbility; class MTGAbility;
class ExtraCost{ class ExtraCost
{
public: public:
TargetChooser * tc; TargetChooser * tc;
MTGCardInstance * source; MTGCardInstance * source;
@@ -19,17 +20,24 @@ public:
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; } {
return (target != NULL);
}
virtual int canPay()
{
return 1;
}
virtual int doPay() = 0; virtual int doPay() = 0;
virtual void Render(); virtual void Render();
virtual int setSource(MTGCardInstance * _source); virtual int setSource(MTGCardInstance * _source);
virtual ExtraCost* clone() const = 0; 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();
@@ -45,7 +53,8 @@ public:
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();
@@ -53,7 +62,8 @@ public:
}; };
//life cost //life cost
class LifeCost: public ExtraCost{ class LifeCost: public ExtraCost
{
public: public:
LifeCost(TargetChooser *_tc = NULL); LifeCost(TargetChooser *_tc = NULL);
@@ -62,7 +72,8 @@ public:
}; };
//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();
@@ -71,7 +82,8 @@ public:
}; };
//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();
@@ -79,7 +91,8 @@ public:
}; };
//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();
@@ -87,7 +100,8 @@ public:
}; };
//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();
@@ -96,14 +110,16 @@ public:
}; };
//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();
@@ -111,7 +127,8 @@ public:
}; };
//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();
@@ -119,7 +136,8 @@ public:
}; };
//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();
@@ -127,7 +145,8 @@ public:
}; };
//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();
@@ -135,11 +154,12 @@ public:
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();
+4 -11
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_
@@ -46,7 +42,7 @@ class TransitionBase;
class GameApp: public JApp class GameApp: public JApp
{ {
private: private:
#ifdef DEBUG #ifdef DEBUG
int nbUpdates; int nbUpdates;
float totalFPS; float totalFPS;
@@ -57,13 +53,11 @@ class GameApp: public JApp
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(); GameApp();
virtual ~GameApp(); virtual ~GameApp();
@@ -74,11 +68,10 @@ class GameApp: public JApp
virtual void Pause(); virtual void Pause();
virtual void Resume(); virtual void Resume();
void LoadGameStates(); void LoadGameStates();
void SetNextState(int state); void SetNextState(int state);
void DoTransition(int trans, int tostate, float dur=-1, bool animonly = false); void DoTransition(int trans, int tostate, float dur = -1, bool animonly = false);
void DoAnimation(int trans, float dur=-1); void DoAnimation(int trans, float dur = -1);
static hgeParticleSystem * Particles[6]; static hgeParticleSystem * Particles[6];
static int HasMusic; static int HasMusic;
static string systemError; static string systemError;
+5 -4
View File
@@ -22,8 +22,9 @@ class TargetChooser;
class Rules; class Rules;
using namespace std; using namespace std;
class GameObserver{ class GameObserver
protected: {
protected:
static GameObserver * mInstance; static GameObserver * mInstance;
MTGCardInstance * cardWaitingForTargets; MTGCardInstance * cardWaitingForTargets;
queue<WEvent *> eventsQueue; queue<WEvent *> eventsQueue;
@@ -32,7 +33,7 @@ class GameObserver{
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;
@@ -54,7 +55,7 @@ class GameObserver{
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();
+129 -41
View File
@@ -23,10 +23,12 @@ 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 //Global settings
ACTIVE_PROFILE, ACTIVE_PROFILE,
LANG, LANG,
@@ -80,7 +82,8 @@ public:
RANDOMDECK_MODE_UNLOCKED, RANDOMDECK_MODE_UNLOCKED,
AWARD_COLLECTOR, AWARD_COLLECTOR,
LAST_NAMED, //Any option after this does not look up in optionNames. LAST_NAMED, //Any option after this does not look up in optionNames.
SET_UNLOCKS = LAST_NAMED + 1, //For sets. SET_UNLOCKS = LAST_NAMED + 1,
//For sets.
}; };
@@ -94,9 +97,13 @@ private:
static const string optionNames[]; static const string optionNames[];
}; };
class GameOption { class GameOption
{
public: public:
virtual ~GameOption() {}; virtual ~GameOption()
{
}
;
int number; int number;
string str; string str;
//All calls to asColor should include a fallback color for people without a theme. //All calls to asColor should include a fallback color for people without a theme.
@@ -112,14 +119,16 @@ public:
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);
@@ -127,7 +136,8 @@ public:
EnumDefinition * def; EnumDefinition * def;
}; };
class GameOptionAward: public GameOption { class GameOptionAward: public GameOption
{
public: public:
GameOptionAward(); GameOptionAward();
virtual string menuStr(); virtual string menuStr();
@@ -135,83 +145,143 @@ public:
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 read(string input);
virtual bool write(std::ofstream*, string); 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;}; {
INVISIBLE = 0, VISIBLE = 1
};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private: private:
OptionClosedHand(); OptionClosedHand();
static OptionClosedHand mDef; static OptionClosedHand mDef;
}; };
class OptionHandDirection: public EnumDefinition { class OptionHandDirection: public EnumDefinition
{
public: public:
enum { VERTICAL = 0, HORIZONTAL = 1}; enum
static EnumDefinition * getInstance() {return &mDef;}; {
VERTICAL = 0, HORIZONTAL = 1
};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private: private:
OptionHandDirection(); OptionHandDirection();
static OptionHandDirection mDef; static OptionHandDirection mDef;
}; };
class OptionManaDisplay: public EnumDefinition { class OptionManaDisplay: public EnumDefinition
{
public: public:
enum { DYNAMIC = 0, STATIC = 1, NOSTARSDYNAMIC = 2, BOTH = 3}; enum
static EnumDefinition * getInstance() {return &mDef;}; {
DYNAMIC = 0, STATIC = 1, NOSTARSDYNAMIC = 2, BOTH = 3
};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private: private:
OptionManaDisplay(); OptionManaDisplay();
static OptionManaDisplay mDef; static OptionManaDisplay mDef;
}; };
class OptionMaxGrade: public EnumDefinition { class OptionMaxGrade: public EnumDefinition
{
public: public:
static EnumDefinition * getInstance() {return &mDef;}; static EnumDefinition * getInstance()
{
return &mDef;
}
;
private: private:
OptionMaxGrade(); OptionMaxGrade();
static OptionMaxGrade mDef; static OptionMaxGrade mDef;
}; };
class OptionASkipPhase: public EnumDefinition { class OptionASkipPhase: public EnumDefinition
{
public: public:
static EnumDefinition * getInstance() {return &mDef;}; static EnumDefinition * getInstance()
{
return &mDef;
}
;
private: private:
OptionASkipPhase(); OptionASkipPhase();
static OptionASkipPhase mDef; static OptionASkipPhase mDef;
}; };
class OptionEconDifficulty: public EnumDefinition { class OptionEconDifficulty: public EnumDefinition
{
public: public:
static EnumDefinition * getInstance() {return &mDef;}; static EnumDefinition * getInstance()
{
return &mDef;
}
;
private: private:
OptionEconDifficulty(); OptionEconDifficulty();
static OptionEconDifficulty mDef; static OptionEconDifficulty mDef;
}; };
class OptionDifficulty: public EnumDefinition { class OptionDifficulty: public EnumDefinition
{
public: public:
enum { NORMAL = 0, HARD = 1, HARDER = 2, EVIL = 3}; enum
static EnumDefinition * getInstance() {return &mDef;}; {
NORMAL = 0, HARD = 1, HARDER = 2, EVIL = 3
};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private: private:
OptionDifficulty(); OptionDifficulty();
static OptionDifficulty mDef; static OptionDifficulty mDef;
}; };
class GameOptions { class GameOptions
public: {
public:
string mFilename; string mFilename;
int save(); int save();
int load(); int load();
@@ -221,32 +291,50 @@ class GameOptions {
GameOptions(string filename); GameOptions(string filename);
~GameOptions(); ~GameOptions();
private: private:
vector<GameOption*> values; vector<GameOption*> values;
vector<string> unknown; vector<string> unknown;
}; };
class GameSettings{ class GameSettings
{
public: public:
friend class GameApp; friend class GameApp;
GameSettings(); GameSettings();
~GameSettings(); ~GameSettings();
int save(); 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); 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(); string keypadFinish();
void keypadShutdown(); void keypadShutdown();
void keypadTitle(string set); void keypadTitle(string set);
bool keypadActive() {if(keypad) return keypad->isActive(); return false;}; bool keypadActive()
void keypadUpdate(float dt) {if(keypad) keypad->Update(dt);}; {
void keypadRender() {if(keypad) keypad->Render();}; if (keypad)
return keypad->isActive();
return false;
}
;
void keypadUpdate(float dt)
{
if (keypad)
keypad->Update(dt);
}
;
void keypadRender()
{
if (keypad)
keypad->Render();
}
;
bool newAward(); bool newAward();
//These return a filepath accurate to the current mode/profile/theme, and can //These return a filepath accurate to the current mode/profile/theme, and can
//optionally fallback to a file within a certain directory. //optionally fallback to a file within a certain directory.
//The sanity=false option returns the adjusted path even if the file doesn't exist. //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); string profileFile(string filename = "", string fallback = "", bool sanity = false, bool relative = false);
void reloadProfile(); //Reloads profile using current options[ACTIVE_PROFILE] void reloadProfile(); //Reloads profile using current options[ACTIVE_PROFILE]
void checkProfile(); //Confirms that a profile is loaded and contains a collection. void checkProfile(); //Confirms that a profile is loaded and contains a collection.
+13 -13
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,19 +41,19 @@ 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;
@@ -81,8 +81,8 @@ class GameState
// 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(DeckMenu * _menu, const vector<DeckMetaData *>& deckMetaDataList);
}; };
bool sortByName( DeckMetaData * d1, DeckMetaData * d2 ); bool sortByName(DeckMetaData * d1, DeckMetaData * d2);
#endif #endif
+2 -2
View File
@@ -11,7 +11,7 @@ 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;
@@ -22,7 +22,7 @@ class GameStateAwards: public GameState, public JGuiListener
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);
@@ -149,5 +149,4 @@ public:
virtual void ButtonPressed(int controllerId, int controlId); virtual void ButtonPressed(int controllerId, int controlId);
}; };
#endif #endif
+4 -4
View File
@@ -9,7 +9,7 @@
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;
@@ -52,7 +52,7 @@ class GameStateMenu: public GameState, public JGuiListener
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();
@@ -69,13 +69,13 @@ class GameStateMenu: public GameState, public JGuiListener
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
+7 -5
View File
@@ -10,13 +10,16 @@ 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,
SHOW_OPTIONS_MENU, SHOW_OPTIONS_MENU,
SAVE SAVE
@@ -25,7 +28,7 @@ private:
bool mReload; bool mReload;
KeybGrabber* grabber; KeybGrabber* grabber;
public: public:
SimpleMenu * optionsMenu; SimpleMenu * optionsMenu;
WGuiTabMenu * optionsTabs; WGuiTabMenu * optionsTabs;
int mState; int mState;
@@ -45,5 +48,4 @@ private:
}; };
#endif #endif
+10 -9
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,13 +29,16 @@
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,
int nb_displayed_items = 7);
bool CheckUserInput(JButton key); bool CheckUserInput(JButton key);
}; };
class ShopBooster{ class ShopBooster
{
public: public:
ShopBooster(); ShopBooster();
string getName(); string getName();
@@ -58,7 +60,7 @@ private:
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];
@@ -96,7 +98,7 @@ class GameStateShop: public GameState, public JGuiListener
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);
@@ -105,7 +107,7 @@ class GameStateShop: public GameState, public JGuiListener
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();
@@ -115,9 +117,8 @@ class GameStateShop: public GameState, public JGuiListener
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
+3 -4
View File
@@ -1,20 +1,20 @@
#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();
@@ -25,5 +25,4 @@ private:
}; };
#endif #endif
+9 -3
View File
@@ -5,14 +5,19 @@
#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()
{
return (mElapsed >= mDuration);
}
;
virtual void Update(float dt); virtual void Update(float dt);
virtual void Render() = 0; virtual void Render() = 0;
virtual void ButtonPressed(int controllerId, int controlId); virtual void ButtonPressed(int controllerId, int controlId);
@@ -24,7 +29,8 @@ public:
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();
+3 -4
View File
@@ -7,17 +7,16 @@ 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();
+3 -3
View File
@@ -4,12 +4,12 @@
#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();
+5 -5
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
+11 -4
View File
@@ -7,16 +7,23 @@
#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
{
BLK,
ATK,
OK,
NONE
} cursor_pos;
CombatStep step; CombatStep step;
void validateDamage(); void validateDamage();
void addOne(DefenserDamaged* blocker, CombatStep); void addOne(DefenserDamaged* blocker, CombatStep);
@@ -24,7 +31,7 @@ class GuiCombat : public GuiLayer
void remaskBlkViews(AttackerDamaged* before, AttackerDamaged* after); void remaskBlkViews(AttackerDamaged* before, AttackerDamaged* after);
int resolve(); int resolve();
public: public:
vector<AttackerDamaged*> attackers; vector<AttackerDamaged*> attackers;
void autoaffectDamage(AttackerDamaged* attacker, CombatStep); void autoaffectDamage(AttackerDamaged* attacker, CombatStep);
+3 -3
View File
@@ -3,14 +3,14 @@
#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();
+13 -13
View File
@@ -9,7 +9,7 @@
class GuiHand; class GuiHand;
struct HandLimitor : public Limitor struct HandLimitor: public Limitor
{ {
GuiHand* hand; GuiHand* hand;
virtual bool select(Target*); virtual bool select(Target*);
@@ -18,9 +18,9 @@ struct HandLimitor : public Limitor
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;
@@ -30,12 +30,12 @@ class GuiHand : public GuiLayer
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);
@@ -44,27 +44,26 @@ class GuiHand : public GuiLayer
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);
@@ -79,7 +78,8 @@ class GuiHandSelf : public GuiHand
HandState GetState() HandState GetState()
{ {
return state; return state;
}; }
;
HandLimitor* limitor; HandLimitor* limitor;
}; };
+28 -13
View File
@@ -12,10 +12,11 @@
class GameObserver; class GameObserver;
class Player; class Player;
class GuiLayer{ class GuiLayer
protected: {
protected:
JButton mActionButton; JButton mActionButton;
public: public:
int mCount; int mCount;
int mCurr; int mCurr;
vector<JGuiObject *> mObjects; vector<JGuiObject *> mObjects;
@@ -28,17 +29,31 @@ class GuiLayer{
GuiLayer(); GuiLayer();
virtual ~GuiLayer(); virtual ~GuiLayer();
virtual void Update(float dt); virtual void Update(float dt);
virtual bool CheckUserInput(JButton key){ return false; }; virtual bool CheckUserInput(JButton key)
int getIndexOf(JGuiObject * object); {
JGuiObject * getByIndex (int index); return false;
virtual void Render(); }
int empty(){
if (mCount) return 0; int getIndexOf(JGuiObject * object);
return 1; 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
+15 -8
View File
@@ -6,7 +6,7 @@
#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;
@@ -16,26 +16,33 @@ class ManaIcon : public Pos
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
{
ALIVE,
WITHERING,
DROPPING,
DEAD
} mode;
int color; int color;
void Render(); void Render();
void Update(float dt, float shift); void Update(float dt, float shift);
void Wither(); void Wither();
void Drop(); void Drop();
ManaIcon(int color, float x, float y,float destx, float desty); ManaIcon(int color, float x, float y, float destx, float desty);
~ManaIcon(); ~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();
+3 -3
View File
@@ -5,13 +5,13 @@
#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);
+16 -12
View File
@@ -4,15 +4,16 @@
#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: protected:
unsigned total; unsigned total;
float baseX, baseY; float baseX, baseY;
@@ -24,13 +25,15 @@ class GuiPlay : public GuiLayer
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: public:
HorzStack(); HorzStack();
void Render(CardView*, iterator begin, iterator end); void Render(CardView*, iterator begin, iterator end);
void Enstack(CardView*); void Enstack(CardView*);
}; };
class VertStack : public CardStack { class VertStack: public CardStack
{
protected: protected:
unsigned count; unsigned count;
public: public:
@@ -40,7 +43,8 @@ class GuiPlay : public GuiLayer
void Enstack(CardView*); void Enstack(CardView*);
inline float nextX(); inline float nextX();
}; };
class BattleField : public HorzStack { class BattleField: public HorzStack
{
static const float HEIGHT; static const float HEIGHT;
unsigned attackers; unsigned attackers;
unsigned blockers; unsigned blockers;
@@ -61,11 +65,11 @@ class GuiPlay : public GuiLayer
void Render(); void Render();
}; };
class Lands : public HorzStack {}; class Lands: public HorzStack {};
class Creatures : public HorzStack {}; class Creatures: public HorzStack {};
class Spells : public VertStack {}; class Spells: public VertStack {};
protected: protected:
GameObserver* game; GameObserver* game;
Creatures selfCreatures, opponentCreatures; Creatures selfCreatures, opponentCreatures;
BattleField battleField; BattleField battleField;
@@ -75,7 +79,7 @@ class GuiPlay : public GuiLayer
vector<CardView*> cards; vector<CardView*> cards;
public: public:
GuiPlay(GameObserver*); GuiPlay(GameObserver*);
~GuiPlay(); ~GuiPlay();
virtual void Render(); virtual void Render();
+23 -12
View File
@@ -9,36 +9,44 @@
class CardView; class CardView;
struct GuiStatic : public PlayGuiObject{ struct GuiStatic: public PlayGuiObject
{
GuiAvatars* parent; GuiAvatars* parent;
GuiStatic(float desiredHeight, float x, float y, bool hasFocus, GuiAvatars* parent); GuiStatic(float desiredHeight, float x, float y, bool hasFocus, GuiAvatars* parent);
virtual void Entering(); virtual void Entering();
virtual bool Leaving(JButton key); virtual bool Leaving(JButton key);
}; };
struct GuiAvatar : public GuiStatic{ struct GuiAvatar: public GuiStatic
typedef enum { TOP_LEFT, BOTTOM_RIGHT } Corner; {
typedef enum
{
TOP_LEFT,
BOTTOM_RIGHT
} Corner;
static const unsigned Width = 35; static const unsigned Width = 35;
static const unsigned Height = 50; static const unsigned Height = 50;
protected: protected:
int avatarRed; int avatarRed;
int currentLife; int currentLife;
int currentpoisonCount; int currentpoisonCount;
Corner corner; Corner corner;
public: public:
Player * player; Player * player;
virtual void Render(); virtual void Render();
GuiAvatar(float x, float y, bool hasFocus, Player * player, Corner corner, GuiAvatars* parent); GuiAvatar(float x, float y, bool hasFocus, Player * player, Corner corner, GuiAvatars* parent);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
struct GuiGameZone : public GuiStatic{ struct GuiGameZone: public GuiStatic
{
static const int Width = 20; static const int Width = 20;
static const int Height = 25; static const int Height = 25;
vector<CardView*> cards; vector<CardView*> cards;
public: public:
MTGGameZone * zone; MTGGameZone * zone;
CardDisplay * cd; CardDisplay * cd;
int showCards; int showCards;
@@ -53,7 +61,8 @@ struct GuiGameZone : public GuiStatic{
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
//opponenthand //opponenthand
class GuiOpponentHand: public GuiGameZone{ class GuiOpponentHand: public GuiGameZone
{
public: public:
Player * player; Player * player;
GuiOpponentHand(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* Parent); GuiOpponentHand(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* Parent);
@@ -62,8 +71,9 @@ public:
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
//end of my addition //end of my addition
class GuiGraveyard: public GuiGameZone{ class GuiGraveyard: public GuiGameZone
public: {
public:
Player * player; Player * player;
GuiGraveyard(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* parent); GuiGraveyard(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* parent);
int receiveEventPlus(WEvent*); int receiveEventPlus(WEvent*);
@@ -71,8 +81,9 @@ class GuiGraveyard: public GuiGameZone{
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
class GuiLibrary: public GuiGameZone{ class GuiLibrary: public GuiGameZone
public: {
public:
Player * player; Player * player;
GuiLibrary(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* parent); GuiLibrary(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* parent);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
+100 -45
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,14 +62,30 @@ 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()
{
return 0;
}
;
virtual MTGAbility* clone() const = 0; virtual MTGAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
virtual int addToGame(); virtual int addToGame();
@@ -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,7 +214,7 @@ 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);
@@ -200,11 +224,11 @@ public:
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();
}; };
+4 -6
View File
@@ -17,15 +17,16 @@ class CardPrimitive;
using namespace std; using namespace std;
class MTGCard { class MTGCard
protected: {
protected:
friend class MTGSetInfo; friend class MTGSetInfo;
int mtgid; int mtgid;
char rarity; char rarity;
char image_name[MTGCARD_NAME_SIZE]; char image_name[MTGCARD_NAME_SIZE];
int init(); int init();
public: public:
int setId; int setId;
CardPrimitive * data; CardPrimitive * data;
@@ -44,7 +45,4 @@ class MTGCard {
char * getImageName(); char * getImageName();
}; };
#endif #endif
+13 -13
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,8 +23,9 @@ 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: {
protected:
int untapping; int untapping;
int nb_damages; int nb_damages;
string sample; string sample;
@@ -39,7 +39,7 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
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;
@@ -72,16 +72,18 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
MTGCardInstance * changeController(Player * newcontroller); MTGCardInstance * changeController(Player * newcontroller);
Player * owner; Player * owner;
Counters * counters; Counters * counters;
int typeAsTarget(){return TARGET_CARD;} int typeAsTarget()
{
return TARGET_CARD;
}
const string getDisplayName() const; const string getDisplayName() const;
MTGCardInstance * target; MTGCardInstance * target;
//types //types
void addType(char * type_text); void addType(char * type_text);
virtual void addType(int id); virtual void addType(int id);
void setType(const char * type_text); void setType(const char * type_text);
void setSubtype( string value); void setSubtype(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);
@@ -90,7 +92,7 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
//Combat //Combat
bool blocked; //Blocked this turn or not? bool blocked; //Blocked this turn or not?
MTGCardInstance * defenser; MTGCardInstance * defenser;
list<MTGCardInstance *>blockers; list<MTGCardInstance *> blockers;
int attacker; int attacker;
int toggleDefenser(MTGCardInstance * opponent); int toggleDefenser(MTGCardInstance * opponent);
int raiseBlockerRankOrder(MTGCardInstance * blocker); int raiseBlockerRankOrder(MTGCardInstance * blocker);
@@ -105,7 +107,7 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
int isAttacker(); int isAttacker();
MTGCardInstance * isDefenser(); MTGCardInstance * isDefenser();
int initAttackersDefensers(); int initAttackersDefensers();
MTGCardInstance * getNextOpponent(MTGCardInstance * previous=NULL); MTGCardInstance * getNextOpponent(MTGCardInstance * previous = NULL);
int nbOpponents(); int nbOpponents();
int stepPower(CombatStep step); int stepPower(CombatStep step);
int afterDamage(); int afterDamage();
@@ -123,16 +125,15 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
int bury(); int bury();
int destroy(); int destroy();
int addToToughness(int value); int addToToughness(int value);
int setToughness(int value); int setToughness(int value);
vector<TargetChooser *>protections; vector<TargetChooser *> protections;
int addProtection(TargetChooser * tc); int addProtection(TargetChooser * tc);
int removeProtection(TargetChooser *tc, int erase = 0); int removeProtection(TargetChooser *tc, int erase = 0);
int protectedAgainst(MTGCardInstance * card); int protectedAgainst(MTGCardInstance * card);
vector<TargetChooser *>cantBeBlockedBys; vector<TargetChooser *> cantBeBlockedBys;
int addCantBeBlockedBy(TargetChooser * tc); int addCantBeBlockedBy(TargetChooser * tc);
int removeCantBeBlockedBy(TargetChooser *tc, int erase = 0); int removeCantBeBlockedBy(TargetChooser *tc, int erase = 0);
int cantBeBlockedBy(MTGCardInstance * card); int cantBeBlockedBy(MTGCardInstance * card);
@@ -168,5 +169,4 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
ostream& operator<<(ostream&, const MTGCardInstance&); ostream& operator<<(ostream&, const MTGCardInstance&);
#endif #endif
+24 -20
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,7 +14,8 @@ 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();
@@ -33,7 +33,8 @@ public:
string getBlock(); string getBlock();
void processConfLine(string line); void processConfLine(string line);
enum { enum
{
//For memoized counts //For memoized counts
LAND = 0, LAND = 0,
COMMON = 1, COMMON = 1,
@@ -51,15 +52,16 @@ public:
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;
@@ -86,27 +88,29 @@ protected:
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_ANYTHING = 0,
READ_CARD = 1, READ_CARD = 1,
READ_METADATA = 2, READ_METADATA = 2,
}; };
vector<int> ids; vector<int> ids;
map<int, MTGCard *> collection; map<int, MTGCard *> collection;
map<string,CardPrimitive *>primitives; map<string, CardPrimitive *> primitives;
MTGAllCards(); MTGAllCards();
~MTGAllCards(); ~MTGAllCards();
MTGCard * _(int id); MTGCard * _(int id);
@@ -120,28 +124,29 @@ private:
int countBySet(int setId); int countBySet(int setId);
int totalCards(); int totalCards();
int randomCardId(); int randomCardId();
private: private:
int processConfLine(string &s, MTGCard* card, CardPrimitive * primitive); int processConfLine(string &s, MTGCard* card, CardPrimitive * primitive);
bool addCardToCollection(MTGCard * card, int setId); bool addCardToCollection(MTGCard * card, int setId);
CardPrimitive * addPrimitive(CardPrimitive * primitive, MTGCard * card = NULL); CardPrimitive * addPrimitive(CardPrimitive * primitive, MTGCard * card = NULL);
}; };
class MTGDeck
class MTGDeck{ {
protected: protected:
string filename; string filename;
int total_cards; int total_cards;
public: public:
MTGAllCards * database; MTGAllCards * database;
map <int,int> cards; map<int, int> cards;
string meta_desc; string meta_desc;
string meta_name; string meta_name;
int totalCards(); int totalCards();
int totalPrice(); int totalPrice();
MTGDeck(MTGAllCards * _allcards); MTGDeck(MTGAllCards * _allcards);
MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only = 0); 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 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(int cardid);
int add(MTGDeck * deck); // adds the contents of "deck" into myself int add(MTGDeck * deck); // adds the contents of "deck" into myself
int complete(); int complete();
@@ -155,5 +160,4 @@ class MTGDeck{
}; };
#endif #endif
+6 -11
View File
@@ -9,15 +9,14 @@ 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 // color constants
static const string kManaColorless; static const string kManaColorless;
static const string kManaGreen; static const string kManaGreen;
@@ -50,7 +49,6 @@ class Constants
MTG_NB_COLORS = 7, MTG_NB_COLORS = 7,
MTG_UNCOLORED = 0, MTG_UNCOLORED = 0,
MTG_FOREST = 1, MTG_FOREST = 1,
MTG_ISLAND = 2, MTG_ISLAND = 2,
@@ -58,7 +56,6 @@ class Constants
MTG_SWAMP = 4, MTG_SWAMP = 4,
MTG_PLAIN = 5, MTG_PLAIN = 5,
MTG_TYPE_CREATURE = 10, MTG_TYPE_CREATURE = 10,
MTG_TYPE_ARTIFACT = 11, MTG_TYPE_ARTIFACT = 11,
MTG_TYPE_ENCHANTMENT = 12, MTG_TYPE_ENCHANTMENT = 12,
@@ -66,7 +63,6 @@ class Constants
MTG_TYPE_LAND = 14, MTG_TYPE_LAND = 14,
MTG_TYPE_INSTANT = 15, MTG_TYPE_INSTANT = 15,
MTG_PHASE_BEFORE_BEGIN = 0, MTG_PHASE_BEFORE_BEGIN = 0,
MTG_PHASE_UNTAP = 1, MTG_PHASE_UNTAP = 1,
MTG_PHASE_UPKEEP = 2, MTG_PHASE_UPKEEP = 2,
@@ -172,7 +168,6 @@ class Constants
NB_BASIC_ABILITIES = 84, NB_BASIC_ABILITIES = 84,
RARITY_S = 'S', //Special Rarity RARITY_S = 'S', //Special Rarity
RARITY_M = 'M', //Mythics RARITY_M = 'M', //Mythics
RARITY_R = 'R', //Rares RARITY_R = 'R', //Rares
@@ -208,16 +203,16 @@ class Constants
GRADE_UNSUPPORTED = 4, GRADE_UNSUPPORTED = 4,
GRADE_DANGEROUS = 5, GRADE_DANGEROUS = 5,
ASKIP_NONE=0, ASKIP_NONE = 0,
ASKIP_SAFE=1, ASKIP_SAFE = 1,
ASKIP_FULL=2, ASKIP_FULL = 2,
}; };
static char MTGColorChars[]; static char MTGColorChars[];
static const char* MTGColorStrings[]; static const char* MTGColorStrings[];
static int _r[], _g[], _b[]; static int _r[], _g[], _b[];
static map<string,int> MTGBasicAbilitiesMap; static map<string, int> MTGBasicAbilitiesMap;
static const char* MTGBasicAbilities[]; static const char* MTGBasicAbilities[];
static const char* MTGPhaseNames[]; static const char* MTGPhaseNames[];
static const char* MTGPhaseCodeNames[]; static const char* MTGPhaseCodeNames[];
+4 -5
View File
@@ -7,13 +7,13 @@
#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);
@@ -21,5 +21,4 @@ class MTGGamePhase: public ActionElement {
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
#endif #endif
+61 -31
View File
@@ -14,12 +14,14 @@ 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,
@@ -69,7 +71,7 @@ class MTGGameZone {
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();
@@ -89,57 +91,85 @@ class MTGGameZone {
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()
{
return "zone";
}
;
virtual ostream& toString(ostream&) const; virtual ostream& toString(ostream&) const;
}; };
class MTGLibrary: public MTGGameZone { class MTGLibrary: public MTGGameZone
public: {
public:
void shuffleTopToBottom(int nbcards); void shuffleTopToBottom(int nbcards);
virtual ostream& toString(ostream&) const; virtual ostream& toString(ostream&) const;
const char * getName(){return "library";} const char * getName()
{
return "library";
}
}; };
class MTGGraveyard: public MTGGameZone { class MTGGraveyard: public MTGGameZone
public: {
public:
virtual ostream& toString(ostream&) const; virtual ostream& toString(ostream&) const;
const char * getName(){return "graveyard";} const char * getName()
{
return "graveyard";
}
}; };
class MTGHand: public MTGGameZone { class MTGHand: public MTGGameZone
public: {
public:
virtual ostream& toString(ostream&) const; virtual ostream& toString(ostream&) const;
const char * getName(){return "hand";} const char * getName()
{
return "hand";
}
}; };
class MTGRemovedFromGame: public MTGGameZone { class MTGRemovedFromGame: public MTGGameZone
public: {
public:
virtual ostream& toString(ostream&) const; virtual ostream& toString(ostream&) const;
const char * getName(){return "exile";} const char * getName()
{
return "exile";
}
}; };
class MTGStack: public MTGGameZone { class MTGStack: public MTGGameZone
public: {
public:
virtual ostream& toString(ostream&) const; virtual ostream& toString(ostream&) const;
const char * getName(){return "stack";} const char * getName()
{
return "stack";
}
}; };
class MTGInPlay: public MTGGameZone { class MTGInPlay: public MTGGameZone
public: {
public:
void untapAll(); void untapAll();
MTGCardInstance * getNextAttacker(MTGCardInstance * previous); MTGCardInstance * getNextAttacker(MTGCardInstance * previous);
virtual ostream& toString(ostream&) const; virtual ostream& toString(ostream&) const;
const char * getName(){return "battlefield";} const char * getName()
{
return "battlefield";
}
}; };
class MTGPlayerCards
class MTGPlayerCards { {
protected: protected:
void init(); void init();
public: public:
MTGLibrary * library; MTGLibrary * library;
MTGGraveyard * graveyard; MTGGraveyard * graveyard;
MTGHand * hand; MTGHand * hand;
@@ -156,9 +186,9 @@ class MTGPlayerCards {
MTGPlayerCards(MTGDeck * deck); MTGPlayerCards(MTGDeck * deck);
~MTGPlayerCards(); ~MTGPlayerCards();
void initGame(int shuffle = 1, int draw = 1); void initGame(int shuffle = 1, int draw = 1);
void OptimizedHand(Player * who,int amount = 7,int lands = 3,int creatures = 0,int othercards = 4); void OptimizedHand(Player * who, int amount = 7, int lands = 3, int creatures = 0, int othercards = 4);
void setOwner(Player * player); void setOwner(Player * player);
void discardRandom(MTGGameZone * from,MTGCardInstance * source); void discardRandom(MTGGameZone * from, MTGCardInstance * source);
void drawFromLibrary(); void drawFromLibrary();
void showHand(); void showHand();
void resetLibrary(); void resetLibrary();
+73 -21
View File
@@ -3,32 +3,54 @@
class ShopBooster; class ShopBooster;
class MTGPackEntry{ class MTGPackEntry
{
public: public:
virtual ~MTGPackEntry() {}; virtual ~MTGPackEntry()
virtual int addCard(WSrcCards * pool,MTGDeck * to) = 0; {
}
;
virtual int addCard(WSrcCards * pool, MTGDeck * to) = 0;
int copies; 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 = "";
copies = 1;
}
;
MTGPackEntryRandom(string f, int c = 1)
{
filter = f;
copies = c;
}
;
int addCard(WSrcCards * pool, MTGDeck * to);
string filter; 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);
@@ -38,23 +60,48 @@ public:
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()
{
return bValid;
}
;
void load(string filename); void load(string filename);
int assemblePack(MTGDeck * to); int assemblePack(MTGDeck * to);
MTGPack() {bValid = false; unlockStatus = 0; price=Constants::PRICE_BOOSTER;}; MTGPack()
MTGPack(string s) {bValid = false; load(s); unlockStatus = 0;}; {
bValid = false;
unlockStatus = 0;
price = Constants::PRICE_BOOSTER;
}
;
MTGPack(string s)
{
bValid = false;
load(s);
unlockStatus = 0;
}
;
~MTGPack(); ~MTGPack();
string getName(); string getName();
string getSort() {return sort;}; string getSort()
int getPrice() {return price;}; {
return sort;
}
;
int getPrice()
{
return price;
}
;
static WSrcCards * getPool(string poolstr); static WSrcCards * getPool(string poolstr);
protected: protected:
void countCards(); void countCards();
@@ -72,12 +119,17 @@ protected:
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()
{
return (int) packs.size();
}
;
void refreshUnlocked(); void refreshUnlocked();
static MTGPack * getDefault(); static MTGPack * getDefault();
+14 -12
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,15 +11,17 @@ class MTGAbility;
class MTGCardInstance; class MTGCardInstance;
class Player; class Player;
class ManaCost{ class ManaCost
protected: {
int cost[Constants::MTG_NB_COLORS+1]; protected:
int cost[Constants::MTG_NB_COLORS + 1];
ManaCostHybrid * hybrids[10]; ManaCostHybrid * hybrids[10];
unsigned int nbhybrids; unsigned int nbhybrids;
int extraCostsIsCopy; int extraCostsIsCopy;
public: public:
enum{ enum
{
MANA_UNPAID = 0, MANA_UNPAID = 0,
MANA_PAID = 1, MANA_PAID = 1,
MANA_PAID_WITH_KICKER = 2, MANA_PAID_WITH_KICKER = 2,
@@ -44,7 +45,7 @@ class ManaCost{
ManaCost(); ManaCost();
~ManaCost(); ~ManaCost();
ManaCost(ManaCost * _manaCost); ManaCost(ManaCost * _manaCost);
void copy (ManaCost * _manaCost); void copy(ManaCost * _manaCost);
int isNull(); int isNull();
int getConvertedCost(); int getConvertedCost();
string toString(); string toString();
@@ -52,7 +53,7 @@ class ManaCost{
//Returns NULL if i is greater than nbhybrids //Returns NULL if i is greater than nbhybrids
ManaCostHybrid * getHybridCost(unsigned int i); ManaCostHybrid * getHybridCost(unsigned int i);
int hasColor(int color); int hasColor(int color);
int remove (int color, int value); int remove(int color, int value);
int add(int color, int value); int add(int color, int value);
// //
@@ -68,7 +69,7 @@ class ManaCost{
int tryToPayHybrids(ManaCostHybrid * _hybrids[], int _nbhybrids, int diff[]); int tryToPayHybrids(ManaCostHybrid * _hybrids[], int _nbhybrids, int diff[]);
void randomDiffHybrids(ManaCost * _cost, int diff[]); void randomDiffHybrids(ManaCost * _cost, int diff[]);
int add(ManaCost * _cost); int add(ManaCost * _cost);
int pay (ManaCost * _cost); int pay(ManaCost * _cost);
//return 1 if _cost can be paid with current data, 0 otherwise //return 1 if _cost can be paid with current data, 0 otherwise
int canAfford(ManaCost * _cost); int canAfford(ManaCost * _cost);
@@ -82,17 +83,18 @@ class ManaCost{
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
+5 -4
View File
@@ -1,16 +1,17 @@
#ifndef _MANACOST_HYBRID_H_ #ifndef _MANACOST_HYBRID_H_
#define _MANACOST_HYBRID_H_ #define _MANACOST_HYBRID_H_
class ManaCostHybrid{ class ManaCostHybrid
public: {
public:
int color1; int color1;
int color2; int color2;
int value1; int value1;
int value2; int value2;
ManaCostHybrid(); ManaCostHybrid();
int hasColor(int color); int hasColor(int color);
ManaCostHybrid(int c1,int v1,int c2,int v2); ManaCostHybrid(int c1, int v1, int c2, int v2);
void init(int c1,int v1,int c2,int v2); void init(int c1, int v1, int c2, int v2);
int getConvertedCost(); int getConvertedCost();
}; };
+9 -4
View File
@@ -14,7 +14,7 @@ class hgeParticleSystem;
class MenuItem: public JGuiObject class MenuItem: public JGuiObject
{ {
private: private:
bool mHasFocus; bool mHasFocus;
WFont *mFont; WFont *mFont;
string mText; string mText;
@@ -29,8 +29,7 @@ class MenuItem: public JGuiObject
JQuad * offQuad; JQuad * offQuad;
hgeParticleSystem* mParticleSys; hgeParticleSystem* mParticleSys;
public:
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(int id, WFont *font, string text, float x, float y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleQuad, bool hasFocus = false);
~MenuItem(); ~MenuItem();
virtual void Render(); virtual void Render();
@@ -39,7 +38,13 @@ class MenuItem: public JGuiObject
virtual void Entering(); virtual void Entering();
virtual bool Leaving(JButton key); virtual bool Leaving(JButton key);
virtual bool ButtonPressed(); virtual bool ButtonPressed();
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;
}
;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
+1 -2
View File
@@ -9,11 +9,10 @@
#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:
+1 -1
View File
@@ -1,7 +1,7 @@
#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);
+98 -36
View File
@@ -20,21 +20,30 @@ 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: {
public:
int value; //Current value. int value; //Current value.
int defValue; //Default value. int defValue; //Default value.
string strDefault; //What to call the default value. string strDefault; //What to call the default value.
@@ -42,38 +51,78 @@ class OptionInteger:public OptionItem{
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 void Reload()
virtual bool Changed() {return value != options[id].number;}; {
if (id != INVALID_OPTION)
value = options[id].number;
}
virtual bool Changed()
{
return value != options[id].number;
}
virtual void Render(); virtual void Render();
virtual void setData(); virtual void setData();
virtual void updateValue(){value+=increment; if (value>maxValue) value=minValue;}; virtual void updateValue()
{
value += increment;
if (value > maxValue)
value = minValue;
}
}; };
class OptionSelect:public OptionItem{ class OptionSelect: public OptionItem
public: {
public:
size_t value; size_t value;
vector<string> selections; 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)
{
value = 0;
}
;
virtual void Reload()
{
initSelections();
}
;
virtual void Render(); virtual void Render();
virtual bool Selectable(); virtual bool Selectable();
virtual void Entering(JButton key); virtual void Entering(JButton key);
virtual bool Changed() {return (value != prior_value);}; virtual bool Changed()
{
return (value != prior_value);
}
virtual void setData(); virtual void setData();
virtual void initSelections(); virtual void initSelections();
virtual void updateValue(){value++; if (value > selections.size() - 1) value=0;}; virtual void updateValue()
protected: {
value++;
if (value > selections.size() - 1)
value = 0;
}
;
protected:
size_t prior_value; size_t prior_value;
}; };
class OptionLanguage: public OptionSelect{ class OptionLanguage: public OptionSelect
public: {
public:
OptionLanguage(string _displayValue); OptionLanguage(string _displayValue);
virtual void addSelection(string s) {addSelection(s,s);}; virtual void addSelection(string s)
virtual void addSelection(string s,string show); {
addSelection(s, s);
}
;
virtual void addSelection(string s, string show);
virtual void initSelections(); virtual void initSelections();
virtual void confirmChange(bool confirmed); virtual void confirmChange(bool confirmed);
virtual void Reload(); virtual void Reload();
@@ -84,26 +133,29 @@ protected:
vector<string> actual_data; vector<string> actual_data;
}; };
class OptionThemeStyle: public OptionSelect{ class OptionThemeStyle: public OptionSelect
public: {
public:
virtual bool Visible(); virtual bool Visible();
virtual void Reload(); virtual void Reload();
virtual void confirmChange(bool confirmed); virtual void confirmChange(bool confirmed);
OptionThemeStyle(string _displayValue); OptionThemeStyle(string _displayValue);
}; };
class OptionDirectory:public OptionSelect{ class OptionDirectory: public OptionSelect
public: {
public:
virtual void Reload(); virtual void Reload();
OptionDirectory(string root, int id, string displayValue, const string type); OptionDirectory(string root, int id, string displayValue, const string type);
protected: protected:
const string root; const string root;
const string type; const string type;
}; };
class OptionTheme:public OptionDirectory{ class OptionTheme: public OptionDirectory
private: {
private:
static const string DIRTESTER; static const string DIRTESTER;
public: public:
OptionTheme(OptionThemeStyle * style = NULL); OptionTheme(OptionThemeStyle * style = NULL);
JQuad * getImage(); JQuad * getImage();
virtual void updateValue(); virtual void updateValue();
@@ -118,14 +170,23 @@ protected:
bool bChecked; bool bChecked;
}; };
class OptionProfile:public OptionDirectory{ class OptionProfile: public OptionDirectory
private: {
private:
static const string DIRTESTER; static const string DIRTESTER;
public: public:
OptionProfile(GameApp * _app, JGuiListener * jgl); OptionProfile(GameApp * _app, JGuiListener * jgl);
virtual void addSelection(string s); virtual void addSelection(string s);
virtual bool Selectable() {return canSelect;}; virtual bool Selectable()
virtual bool Changed() {return (initialValue != value);}; {
return canSelect;
}
;
virtual bool Changed()
{
return (initialValue != value);
}
;
virtual void Entering(JButton key); virtual void Entering(JButton key);
virtual void Reload(); virtual void Reload();
virtual void Render(); virtual void Render();
@@ -141,8 +202,9 @@ private:
size_t initialValue; size_t initialValue;
}; };
class OptionKey : public WGuiItem, public KeybGrabber { class OptionKey: public WGuiItem, public KeybGrabber
public: {
public:
OptionKey(GameStateOptions* g, LocalKeySym, JButton); OptionKey(GameStateOptions* g, LocalKeySym, JButton);
LocalKeySym from; LocalKeySym from;
JButton to; JButton to;
@@ -155,7 +217,7 @@ class OptionKey : public WGuiItem, public KeybGrabber {
virtual void ButtonPressed(int controllerId, int controlId); virtual void ButtonPressed(int controllerId, int controlId);
virtual bool Visible(); virtual bool Visible();
virtual bool Selectable(); virtual bool Selectable();
protected: protected:
bool grabbed; bool grabbed;
GameStateOptions* g; GameStateOptions* g;
SimpleMenu* btnMenu; SimpleMenu* btnMenu;
+27 -11
View File
@@ -7,32 +7,48 @@ 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,
TRIGGERS,
ORDER,
FIRST_STRIKE,
END_FIRST_STRIKE,
DAMAGE,
END_DAMAGE
} CombatStep;
class Phase
{
public:
int id; int id;
Player * player; Player * player;
Phase(int id, Player *player):id(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);
+37 -11
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,26 +16,52 @@
#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 bool Leaving(JButton key)
{
mHasFocus = false;
zoom = 1.0;
return true;
}
;
virtual bool CheckUserInput(JButton key)
{
return false;
}
;
virtual bool ButtonPressed()
{
return true;
}
;
virtual void Render(); virtual void Render();
virtual void Update(float dt); virtual void Update(float dt);
PlayGuiObject(float desiredHeight, float x, float y, bool hasFocus); PlayGuiObject(float desiredHeight, float x, float y, bool hasFocus);
PlayGuiObject(float desiredHeight, const Pos& ref, bool hasFocus); PlayGuiObject(float desiredHeight, const Pos& ref, bool hasFocus);
virtual void ButtonPressed(int controllerId, int controlId){}; virtual void ButtonPressed(int controllerId, int controlId) {}
virtual bool getTopLeft(float& top, float& left) {top = actY; left = actX; return true;}; virtual bool getTopLeft(float& top, float& left)
virtual ~PlayGuiObject(){}; {
top = actY;
left = actX;
return true;
}
;
virtual ~PlayGuiObject() {};
vector<Effect*> effects; vector<Effect*> effects;
}; };
+14 -7
View File
@@ -5,19 +5,26 @@
#include "GuiLayers.h" #include "GuiLayers.h"
class PlayGuiObjectController : public GuiLayer{ class PlayGuiObjectController: public GuiLayer
protected: {
protected:
float last_user_move; float last_user_move;
int getClosestItem(int direction); int getClosestItem(int direction);
int getClosestItem(int direction, float tolerance); int getClosestItem(int direction, float tolerance);
static int showBigCards;// 0 hide, 1 show, 2 show text static int showBigCards;// 0 hide, 1 show, 2 show text
public: public:
virtual void Update(float dt); virtual void Update(float dt);
virtual bool CheckUserInput(JButton key); virtual bool CheckUserInput(JButton key);
PlayGuiObjectController(){last_user_move=0;}; PlayGuiObjectController()
virtual void Render(){GuiLayer::Render();}; {
last_user_move = 0;
}
;
virtual void Render()
{
GuiLayer::Render();
}
;
}; };
#endif #endif
+3 -1
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;
+5 -4
View File
@@ -4,12 +4,13 @@
#include "MTGDeck.h" #include "MTGDeck.h"
#include "Tasks.h" #include "Tasks.h"
class PlayerData{ class PlayerData
protected: {
protected:
void init(); void init();
public: public:
int credits; int credits;
map<string,string>storySaves; map<string, string> storySaves;
MTGDeck * collection; MTGDeck * collection;
TaskList * taskList; TaskList * taskList;
PlayerData(); //This doesn't init the collection, do not use it to manipulate the player's collection PlayerData(); //This doesn't init the collection, do not use it to manipulate the player's collection
+2 -1
View File
@@ -3,7 +3,8 @@
#include "JGE.h" #include "JGE.h"
struct Pos { struct Pos
{
float actX, actY, actZ, actT, actA; float actX, actY, actZ, actT, actA;
float x, y, zoom, t, alpha; float x, y, zoom, t, alpha;
Pos(float, float, float, float, float); Pos(float, float, float, float, float);
+12 -7
View File
@@ -8,23 +8,28 @@
class MTGAllCards; class MTGAllCards;
class PriceList{ class PriceList
private: {
private:
MTGAllCards * collection; MTGAllCards * collection;
string filename; string filename;
map<int,int> prices; map<int, int> prices;
static int randomKey; static int randomKey;
public: public:
PriceList(const char * file, MTGAllCards * _collection); PriceList(const char * file, MTGAllCards * _collection);
~PriceList(); ~PriceList();
int save(); int save();
int getSellPrice(int cardid); int getSellPrice(int cardid);
int getPurchasePrice(int cardid); int getPurchasePrice(int cardid);
int getPrice(int cardId); int getPrice(int cardId);
int setPrice(int cardId,int price); int setPrice(int cardId, int price);
int getOtherPrice(int amt); int getOtherPrice(int amt);
static float difficultyScalar(float price, int cardid=0); static float difficultyScalar(float price, int cardid = 0);
static void updateKey() {randomKey = rand();}; static void updateKey()
{
randomKey = rand();
}
;
}; };
#endif #endif
+16 -9
View File
@@ -9,13 +9,19 @@ 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;
@@ -24,19 +30,20 @@ protected:
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();
}; };
+16 -12
View File
@@ -13,17 +13,19 @@ class MTGCardInstance;
#define MAX_RULES_CARDS 4096; #define MAX_RULES_CARDS 4096;
class RulesPlayerZone{ class RulesPlayerZone
public: {
public:
vector<int> cards; vector<int> cards;
void add(int cardid); void add(int cardid);
RulesPlayerZone(); RulesPlayerZone();
void cleanup(); void cleanup();
}; };
class RulesPlayerData{ class RulesPlayerData
public: {
vector <string> extraRules; public:
vector<string> extraRules;
int life; int life;
int poisonCount; int poisonCount;
int damageCount; int damageCount;
@@ -37,8 +39,9 @@ class RulesPlayerData{
}; };
class RulesState{ class RulesState
public: {
public:
int phase; int phase;
int player; int player;
void parsePlayerState(int playerId, string s); void parsePlayerState(int playerId, string s);
@@ -47,16 +50,17 @@ class RulesState{
void cleanup(); void cleanup();
}; };
class Rules
class Rules{ {
protected: protected:
Player * loadPlayerMomir(int isAI); Player * loadPlayerMomir(int isAI);
Player * loadPlayerRandom(int isAI, int mode); Player * loadPlayerRandom(int isAI, int mode);
Player * initPlayer(int playerId); Player * initPlayer(int playerId);
MTGDeck * buildDeck( int playerId); MTGDeck * buildDeck(int playerId);
int strToGameMode(string s); int strToGameMode(string s);
public: public:
enum { enum
{
PARSE_UNDEFINED, PARSE_UNDEFINED,
PARSE_INIT, PARSE_INIT,
PARSE_PLAYER1, PARSE_PLAYER1,
@@ -73,7 +77,7 @@ public:
void addExtraRules(); void addExtraRules();
void initGame(); void initGame();
void cleanup(); void cleanup();
vector <string> extraRules; vector<string> extraRules;
RulesState initState; RulesState initState;
static int getMTGId(string name); static int getMTGId(string name);
static MTGCardInstance * getCardByMTGId(int mtgid); static MTGCardInstance * getCardByMTGId(int mtgid);
+11 -8
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,13 +9,14 @@
#include "WFont.h" #include "WFont.h"
#include "hge/hgeparticle.h" #include "hge/hgeparticle.h"
class SimpleMenu:public JGuiController{ class SimpleMenu: public JGuiController
private: {
private:
float mHeight, mWidth, mX, mY; float mHeight, mWidth, mX, mY;
int fontId; int fontId;
std::string title; std::string title;
int displaytitle; int displaytitle;
int maxItems,startId; int maxItems, startId;
float selectionT, selectionY; float selectionT, selectionY;
float timeOpen; float timeOpen;
bool mClosed; bool mClosed;
@@ -29,19 +30,21 @@ class SimpleMenu:public JGuiController{
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()
{
return mClosed;
}
static void destroy(); static void destroy();
}; };
#endif #endif
+9 -4
View File
@@ -11,10 +11,9 @@ 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;
@@ -22,7 +21,7 @@ class SimpleMenuItem: public JGuiObject
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);
@@ -41,7 +40,13 @@ class SimpleMenuItem: public JGuiObject
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
+11 -8
View File
@@ -19,27 +19,31 @@ enum SIMPLE_KEYS{
KPD_INPUT = 255, KPD_INPUT = 255,
}; };
struct SimpleKey{ struct SimpleKey
SimpleKey( string _ds, int _id); {
SimpleKey(string _ds, int _id);
string displayValue; string displayValue;
unsigned char id; unsigned char id;
unsigned char adjacency[4]; unsigned char adjacency[4];
}; };
class SimplePad{ class SimplePad
{
public: public:
friend class GameSettings; friend class GameSettings;
string buffer; string buffer;
string title; string title;
unsigned int cursorPos(); unsigned int cursorPos();
bool isActive() {return bActive;}; bool isActive()
{
return bActive;
}
;
void Render(); void Render();
void Update(float dt); void Update(float dt);
void pressKey(unsigned char id); void pressKey(unsigned char id);
SimplePad(); SimplePad();
~SimplePad(); ~SimplePad();
@@ -49,7 +53,7 @@ private:
void linkKeys(int from, int to, int dir); void linkKeys(int from, int to, int dir);
SimpleKey * Add(string display, unsigned char id); SimpleKey * Add(string display, unsigned char id);
void MoveSelection(unsigned char dir); void MoveSelection(unsigned char dir);
void Start(string value, string * _dest=NULL); void Start(string value, string * _dest = NULL);
string Finish(); string Finish();
bool bActive; bool bActive;
@@ -65,5 +69,4 @@ private:
string original; //For cancelling. string original; //For cancelling.
}; };
#endif #endif
+9 -4
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);
+59 -34
View File
@@ -11,44 +11,63 @@ 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;}; ;
bool Leaving(JButton key)
{
return false;
}
;
bool ButtonPressed()
{
return false;
}
;
bool hasFocus()
{
return false;
}
;
virtual float getHeight() = 0; virtual float getHeight() = 0;
}; };
class StoryText:public StoryDialogElement { class StoryText: public StoryDialogElement
public : {
public:
string text; string text;
int align; int align;
int font; int font;
StoryText(string text, float mX, float mY, string align = "center", int font = 0, int id = 0); StoryText(string text, float mX, float mY, string align = "center", int font = 0, int id = 0);
void Render(); void Render();
void Update(float dt); void Update(float dt);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
float getHeight(); float getHeight();
}; };
class StoryImage:public StoryDialogElement { 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 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:
enum
{
STORY_REWARD_CREDITS, STORY_REWARD_CREDITS,
STORY_REWARD_SET, STORY_REWARD_SET,
STORY_REWARD_CARD, STORY_REWARD_CARD,
@@ -67,7 +86,8 @@ public:
static MTGDeck * collection; static MTGDeck * collection;
}; };
class StoryChoice:public StoryText { class StoryChoice: public StoryText
{
public: public:
string pageId; string pageId;
@@ -87,7 +107,8 @@ public:
}; };
class StoryFlow; class StoryFlow;
class StoryPage { class StoryPage
{
protected: protected:
string safeAttribute(TiXmlElement* element, string attribute); string safeAttribute(TiXmlElement* element, string attribute);
public: public:
@@ -96,44 +117,49 @@ public:
StoryPage(StoryFlow * mParent); StoryPage(StoryFlow * mParent);
virtual void Update(float dt)=0; virtual void Update(float dt)=0;
virtual void Render()=0; virtual void Render()=0;
virtual ~StoryPage(){}; virtual ~StoryPage()
{
}
;
int loadElement(TiXmlElement* element); int loadElement(TiXmlElement* element);
}; };
class StoryDialog:public StoryPage, public JGuiListener,public JGuiController { class StoryDialog: public StoryPage, public JGuiListener, public JGuiController
{
private: private:
vector<StoryDialogElement *>graphics; vector<StoryDialogElement *> graphics;
void RenderElement(StoryDialogElement * elmt); void RenderElement(StoryDialogElement * elmt);
public: public:
StoryDialog(TiXmlElement* el,StoryFlow * mParent); StoryDialog(TiXmlElement* el, StoryFlow * mParent);
~StoryDialog(); ~StoryDialog();
void Update(float dt); void Update(float dt);
void Render(); void Render();
void ButtonPressed(int,int); void ButtonPressed(int, int);
static float currentY; static float currentY;
static float previousY; 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);
@@ -149,5 +175,4 @@ public:
void Render(); void Render();
}; };
#endif #endif
+10 -6
View File
@@ -1,18 +1,21 @@
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;
@@ -21,12 +24,13 @@ public:
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 topSize;
int playerSrc; 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;
}; };
+7 -9
View File
@@ -1,17 +1,17 @@
#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_CREATURE = 1,
TYPE_ENCHANTMENT = 2, TYPE_ENCHANTMENT = 2,
TYPE_SORCERY = 3, TYPE_SORCERY = 3,
@@ -22,11 +22,10 @@ public:
LAST_TYPE = TYPE_LEGENDARY, 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);
@@ -34,5 +33,4 @@ public:
string find(unsigned int id); string find(unsigned int id);
}; };
#endif #endif
+84 -47
View File
@@ -20,14 +20,14 @@ class Damageable;
class Targetable; class Targetable;
class CardDescriptor; class CardDescriptor;
class TargetChooser: public TargetsList
{
class TargetChooser: public TargetsList { protected:
protected:
int forceTargetListReady; int forceTargetListReady;
public: public:
enum{ enum
{
UNSET = 0, UNSET = 0,
OPPONENT = -1, OPPONENT = -1,
CONTROLLER = 1, CONTROLLER = 1,
@@ -43,29 +43,54 @@ class TargetChooser: public TargetsList {
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;}; {
return 0;
}
virtual bool targetsZone(MTGGameZone * z)
{
return false;
}
;
int ForceTargetListReady(); int ForceTargetListReady();
int targetsReadyCheck(); int targetsReadyCheck();
virtual int addTarget(Targetable * target); virtual int addTarget(Targetable * target);
virtual bool canTarget(Targetable * _target); virtual bool canTarget(Targetable * _target);
virtual int full(){if (maxtargets != -1 && cursor>=maxtargets) {return 1;} else{return 0;}}; virtual int full()
virtual int ready(){return cursor;}; {
virtual ~TargetChooser(){}; if (maxtargets != -1 && cursor >= maxtargets)
{
return 1;
}
else
{
return 0;
}
}
;
virtual int ready()
{
return cursor;
}
;
virtual ~TargetChooser()
{
}
;
int targetListSet(); int targetListSet();
virtual TargetChooser* clone() const = 0; virtual TargetChooser* clone() const = 0;
}; };
class TargetChooserFactory
class TargetChooserFactory{ {
public: public:
TargetChooser * createTargetChooser(string s, MTGCardInstance * card, MTGAbility * ability = NULL); TargetChooser * createTargetChooser(string s, MTGCardInstance * card, MTGAbility * ability = NULL);
TargetChooser * createTargetChooser(MTGCardInstance * card); TargetChooser * createTargetChooser(MTGCardInstance * card);
}; };
class TargetZoneChooser: public TargetChooser
class TargetZoneChooser:public TargetChooser{ {
public: public:
int zones[15]; int zones[15];
int nbzones; int nbzones;
int init(int * _zones, int _nbzones); int init(int * _zones, int _nbzones);
@@ -77,7 +102,8 @@ class TargetZoneChooser:public TargetChooser{
virtual TargetZoneChooser * clone() const; virtual TargetZoneChooser * clone() const;
}; };
class CardTargetChooser:public TargetZoneChooser { class CardTargetChooser: public TargetZoneChooser
{
protected: protected:
MTGCardInstance * validTarget; MTGCardInstance * validTarget;
public: public:
@@ -86,37 +112,46 @@ public:
virtual CardTargetChooser * clone() const; virtual CardTargetChooser * clone() const;
}; };
class CreatureTargetChooser: public TargetZoneChooser
class CreatureTargetChooser:public TargetZoneChooser{ {
public: public:
CreatureTargetChooser(int * _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false); CreatureTargetChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
CreatureTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false); CreatureTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
virtual bool canTarget(Targetable * _card); virtual bool canTarget(Targetable * _card);
virtual CreatureTargetChooser * clone() const; virtual CreatureTargetChooser * clone() const;
}; };
class DamageableTargetChooser: public CreatureTargetChooser
class DamageableTargetChooser:public CreatureTargetChooser{ {
public: public:
DamageableTargetChooser(int * _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false):CreatureTargetChooser( _zones,_nbzones, card, _maxtargets,other){}; DamageableTargetChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false) :
DamageableTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false):CreatureTargetChooser(card, _maxtargets,other){}; 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 bool canTarget(Targetable * target);
virtual DamageableTargetChooser * clone() const; virtual DamageableTargetChooser * clone() const;
}; };
class PlayerTargetChooser: public TargetChooser
class PlayerTargetChooser:public TargetChooser{ {
protected: protected:
Player * p; //In Case we can only target a specific player Player * p; //In Case we can only target a specific player
public: public:
PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, Player *_p = NULL); PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, Player *_p = NULL);
virtual bool canTarget(Targetable * target); virtual bool canTarget(Targetable * target);
virtual PlayerTargetChooser * clone() const; virtual PlayerTargetChooser * clone() const;
}; };
class TypeTargetChooser:public TargetZoneChooser{ class TypeTargetChooser: public TargetZoneChooser
public: {
public:
int nbtypes; int nbtypes;
int types[10]; int types[10];
TypeTargetChooser(const char * _type, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false); TypeTargetChooser(const char * _type, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
@@ -127,8 +162,9 @@ class TypeTargetChooser:public TargetZoneChooser{
virtual TypeTargetChooser * clone() const; virtual TypeTargetChooser * clone() const;
}; };
class DescriptorTargetChooser:public TargetZoneChooser{ class DescriptorTargetChooser: public TargetZoneChooser
public: {
public:
CardDescriptor * cd; CardDescriptor * cd;
DescriptorTargetChooser(CardDescriptor * _cd, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false); 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); DescriptorTargetChooser(CardDescriptor * _cd, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
@@ -137,36 +173,37 @@ class DescriptorTargetChooser:public TargetZoneChooser{
virtual DescriptorTargetChooser * clone() const; virtual DescriptorTargetChooser * clone() const;
}; };
class SpellTargetChooser: public TargetChooser
class SpellTargetChooser:public TargetChooser{ {
public: public:
int color; int color;
SpellTargetChooser( MTGCardInstance * card = NULL,int _color = -1, int _maxtargets = 1 , bool other = false); SpellTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, bool other = false);
virtual bool canTarget(Targetable * target); virtual bool canTarget(Targetable * target);
virtual SpellTargetChooser * clone() const; virtual SpellTargetChooser * clone() const;
}; };
class SpellOrPermanentTargetChooser:public TargetZoneChooser{ class SpellOrPermanentTargetChooser: public TargetZoneChooser
public: {
public:
int color; int color;
SpellOrPermanentTargetChooser(MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1, bool other = false); SpellOrPermanentTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, bool other = false);
virtual bool canTarget(Targetable * target); virtual bool canTarget(Targetable * target);
virtual SpellOrPermanentTargetChooser * clone() const; virtual SpellOrPermanentTargetChooser * clone() const;
}; };
class DamageTargetChooser: public TargetChooser
{
class DamageTargetChooser:public TargetChooser{ public:
public:
int color; int color;
int state; int state;
DamageTargetChooser( MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1, int state = NOT_RESOLVED); DamageTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, int state = NOT_RESOLVED);
virtual bool canTarget(Targetable * target); virtual bool canTarget(Targetable * target);
virtual DamageTargetChooser * clone() const; 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;
+3 -2
View File
@@ -5,8 +5,9 @@
#define TARGET_PLAYER 2 #define TARGET_PLAYER 2
#define TARGET_STACKACTION 3 #define TARGET_STACKACTION 3
class Targetable{ class Targetable
public: {
public:
virtual int typeAsTarget() = 0; virtual int typeAsTarget() = 0;
virtual const string getDisplayName() const = 0; virtual const string getDisplayName() const = 0;
}; };
+8 -3
View File
@@ -11,8 +11,9 @@ class Spell;
class Interruptible; class Interruptible;
class Damage; class Damage;
class TargetsList{ class TargetsList
public: {
public:
int cursor; int cursor;
TargetsList(); TargetsList();
TargetsList(Targetable * _targets[], int nbtargets); TargetsList(Targetable * _targets[], int nbtargets);
@@ -28,7 +29,11 @@ class TargetsList{
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);
void initTargets(){cursor = 0;}; void initTargets()
{
cursor = 0;
}
;
}; };
#endif #endif
+30 -18
View File
@@ -20,7 +20,8 @@
#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;
@@ -64,7 +65,8 @@ public:
void passOneDay(); void passOneDay();
}; };
class TaskList { class TaskList
{
protected: protected:
string fileName; string fileName;
float vPos; float vPos;
@@ -74,11 +76,11 @@ protected:
JTexture * mBgTex; JTexture * mBgTex;
float sH, sW; float sH, sW;
public: public:
vector<Task*> tasks; vector<Task*> tasks;
enum{ enum
{
TASKS_IN, TASKS_IN,
TASKS_ACTIVE, TASKS_ACTIVE,
TASKS_OUT, TASKS_OUT,
@@ -88,7 +90,11 @@ public:
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()
{
return mState;
}
;
void addTask(string params, bool rand = false); void addTask(string params, bool rand = false);
void addTask(Task *task); void addTask(Task *task);
void addRandomTask(int diff = 100); void addRandomTask(int diff = 100);
@@ -107,7 +113,8 @@ public:
~TaskList(); ~TaskList();
}; };
class TaskWinAgainst : public Task { class TaskWinAgainst: public Task
{
protected: protected:
virtual int computeReward(); virtual int computeReward();
public: public:
@@ -117,7 +124,8 @@ public:
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app); virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
}; };
class TaskSlaughter : public TaskWinAgainst { class TaskSlaughter: public TaskWinAgainst
{
protected: protected:
int targetLife; int targetLife;
virtual int computeReward(); virtual int computeReward();
@@ -131,7 +139,8 @@ public:
virtual void randomize(); virtual void randomize();
}; };
class TaskDelay : public TaskWinAgainst { class TaskDelay: public TaskWinAgainst
{
protected: protected:
int turn; int turn;
bool afterTurn; bool afterTurn;
@@ -146,7 +155,8 @@ public:
virtual void randomize(); virtual void randomize();
}; };
class TaskImmortal : public Task { class TaskImmortal: public Task
{
protected: protected:
int targetLife; int targetLife;
int level; int level;
@@ -162,7 +172,8 @@ public:
virtual void randomize(); virtual void randomize();
}; };
class TaskMassiveBurial : public Task { class TaskMassiveBurial: public Task
{
protected: protected:
int color; int color;
int bodyCount; int bodyCount;
@@ -178,7 +189,8 @@ public:
virtual void randomize(); virtual void randomize();
}; };
class TaskWisdom : public Task { class TaskWisdom: public Task
{
protected: protected:
int color; int color;
int cardCount; int cardCount;
@@ -194,7 +206,8 @@ public:
virtual void randomize(); virtual void randomize();
}; };
class TaskPacifism : public Task { class TaskPacifism: public Task
{
protected: protected:
virtual int computeReward(); virtual int computeReward();
int lifeSlashCardMin; int lifeSlashCardMin;
@@ -209,13 +222,12 @@ public:
virtual void randomize(); 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();
@@ -224,7 +236,7 @@ public:
virtual void storeCustomAttribs(); virtual void storeCustomAttribs();
virtual void restoreCustomAttribs(); virtual void restoreCustomAttribs();
virtual void randomize(); virtual void randomize();
}; };
*/ */
#endif #endif
+21 -19
View File
@@ -8,8 +8,9 @@
#include "AIPlayer.h" #include "AIPlayer.h"
class TestSuiteActions{ class TestSuiteActions
public: {
public:
int nbitems; int nbitems;
string actions[MAX_TESTSUITE_ACTIONS]; string actions[MAX_TESTSUITE_ACTIONS];
void add(string action); void add(string action);
@@ -17,8 +18,9 @@ class TestSuiteActions{
void cleanup(); void cleanup();
}; };
class TestSuitePlayerZone{ class TestSuitePlayerZone
public: {
public:
int cards[MAX_TESTUITE_CARDS]; int cards[MAX_TESTUITE_CARDS];
int nbitems; int nbitems;
void add(int cardid); void add(int cardid);
@@ -26,8 +28,9 @@ class TestSuitePlayerZone{
void cleanup(); void cleanup();
}; };
class TestSuitePlayerData{ class TestSuitePlayerData
public: {
public:
int life; int life;
ManaCost * manapool; ManaCost * manapool;
TestSuitePlayerZone zones[5]; TestSuitePlayerZone zones[5];
@@ -37,11 +40,10 @@ class TestSuitePlayerData{
}; };
class TestSuite; class TestSuite;
class TestSuiteState{ class TestSuiteState
public: {
public:
int phase; int phase;
void parsePlayerState(int playerId, string s); void parsePlayerState(int playerId, string s);
TestSuiteState(); TestSuiteState();
@@ -49,14 +51,15 @@ class TestSuiteState{
void cleanup(); void cleanup();
}; };
class TestSuitePregame
class TestSuitePregame{ {
public: public:
virtual void performTest() = 0; virtual void performTest() = 0;
}; };
class TestSuite{ class TestSuite
public: {
public:
MTGAllCards* collection; MTGAllCards* collection;
int summoningSickness; int summoningSickness;
bool forceAbility; bool forceAbility;
@@ -86,8 +89,9 @@ class TestSuite{
}; };
class TestSuiteAI:public AIPlayerBaka{ class TestSuiteAI:public AIPlayerBaka
public: {
public:
TestSuite * suite; TestSuite * suite;
float timer; float timer;
@@ -97,7 +101,5 @@ class TestSuiteAI:public AIPlayerBaka{
virtual int displayStack(); virtual int displayStack();
}; };
#endif #endif
#endif #endif
+3 -3
View File
@@ -7,7 +7,8 @@ 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;
@@ -34,8 +35,7 @@ public:
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;
+36 -25
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,8 +10,9 @@
#include "MTGCardInstance.h" #include "MTGCardInstance.h"
#include "CardDescriptor.h" #include "CardDescriptor.h"
class ThisDescriptor{ class ThisDescriptor
public: {
public:
int comparisonMode; int comparisonMode;
int comparisonCriterion; int comparisonCriterion;
virtual int match(MTGCardInstance * card) = 0; virtual int match(MTGCardInstance * card) = 0;
@@ -19,13 +20,15 @@ class ThisDescriptor{
virtual ~ThisDescriptor(); virtual ~ThisDescriptor();
}; };
class ThisDescriptorFactory{ class ThisDescriptorFactory
{
public: public:
ThisDescriptor * createThisDescriptor(string s); ThisDescriptor * createThisDescriptor(string s);
}; };
class ThisCounter:public ThisDescriptor{ class ThisCounter: public ThisDescriptor
public: {
public:
Counter * counter; Counter * counter;
virtual int match(MTGCardInstance * card); virtual int match(MTGCardInstance * card);
@@ -34,65 +37,73 @@ class ThisCounter:public ThisDescriptor{
~ThisCounter(); ~ThisCounter();
}; };
class ThisCounterAny:public ThisDescriptor{ class ThisCounterAny: public ThisDescriptor
public: {
public:
virtual int match(MTGCardInstance *card); virtual int match(MTGCardInstance *card);
ThisCounterAny(int nb); ThisCounterAny(int nb);
}; };
class ThisControllerlife:public ThisDescriptor{ class ThisControllerlife: public ThisDescriptor
public: {
public:
virtual int match(MTGCardInstance * card); 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);
}; };
+2 -2
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);
} }
+3 -2
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
+7 -7
View File
@@ -4,23 +4,23 @@
#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: {
protected:
static Translator * mInstance; static Translator * mInstance;
bool initDone; 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;
+4 -4
View File
@@ -5,20 +5,20 @@
#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;
}; };
+36 -18
View File
@@ -8,11 +8,12 @@
#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();
@@ -33,10 +34,11 @@ protected:
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();
@@ -45,8 +47,8 @@ public:
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();
@@ -56,10 +58,11 @@ public:
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();
@@ -68,14 +71,19 @@ public:
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)
{
return (t == texture);
}
;
JTexture * Actual(); //Return this texture as is. Does not make a new one. JTexture * Actual(); //Return this texture as is. Does not make a new one.
JQuad * GetQuad(string resname); JQuad * GetQuad(string resname);
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. 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.
JQuad * GetQuad(float offX=0.0f, float offY=0.0f, float width=0.0f, float height=0.0f,string resname=""); //Alias to GetTrackedQuad. JQuad * GetQuad(float offX = 0.0f, float offY = 0.0f, float width = 0.0f, float height = 0.0f, string resname = ""); //Alias to GetTrackedQuad.
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. 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.
bool ReleaseQuad(JQuad* quad); //We're done with this quad, so delete and stop tracking. True if existed. bool ReleaseQuad(JQuad* quad); //We're done with this quad, so delete and stop tracking. True if existed.
protected: protected:
@@ -83,10 +91,11 @@ protected:
vector<WTrackedQuad*> trackedQuads; 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();
@@ -94,20 +103,29 @@ public:
bool isGood(); bool isGood();
bool Attempt(string filename, int submode, int & error); bool Attempt(string filename, int submode, int & error);
bool compare(hgeParticleSystemInfo * p) {return (p == particles);}; bool compare(hgeParticleSystemInfo * p)
{
return (p == particles);
}
;
hgeParticleSystemInfo * Actual(); hgeParticleSystemInfo * Actual();
protected: protected:
hgeParticleSystemInfo * particles; 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)
{
return (s == sample);
}
;
unsigned long size(); unsigned long size();
bool isGood(); bool isGood();
void Refresh(); void Refresh();
+268 -76
View File
@@ -10,14 +10,32 @@ 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() {}; {
hooked = NULL;
currentPos = 0;
}
;
virtual ~WSyncable()
{
}
;
//Local //Local
virtual bool Hook(WSyncable* s); virtual bool Hook(WSyncable* s);
virtual int getOffset() {return currentPos;}; virtual int getOffset()
virtual bool setOffset(int i) {currentPos = i; return true;}; {
return currentPos;
}
;
virtual bool setOffset(int i)
{
currentPos = i;
return true;
}
;
//Recursive //Recursive
virtual int getPos(); virtual int getPos();
virtual bool next(); virtual bool next();
@@ -27,34 +45,84 @@ protected:
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;
@@ -62,14 +130,14 @@ protected:
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 * getImage(int offset = 0);
virtual JQuad * getThumb(int offset=0); virtual JQuad * getThumb(int offset = 0);
virtual MTGCard * getCard(int offset=0, bool ignore=false); 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 int Size(bool all = false); //Returns the number of cards, or the number of cards that match the filter.
virtual void Shuffle(); virtual void Shuffle();
virtual bool thisCard(int mtgid); virtual bool thisCard(int mtgid);
@@ -89,19 +157,24 @@ public:
virtual void updateCounts() {}; virtual void updateCounts() {};
virtual void clearCounts() {}; virtual void clearCounts() {};
virtual void addCount(MTGCard * c, int qty=1) {}; virtual void addCount(MTGCard * c, int qty = 1) {};
//Loads into us. Calls validate() //Loads into us. Calls validate()
virtual int loadMatches(MTGAllCards* ac); //loadMatches adds the cards from something 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(MTGDeck * deck); //into this, if it matches our filter
virtual int loadMatches(WSrcCards* src, bool all=false); //If all==true, ignore filters on src. virtual int loadMatches(WSrcCards* src, bool all = false); //If all==true, ignore filters on src.
//We put it into something else //We put it into something else
virtual int addRandomCards(MTGDeck * i, int howmany=1); virtual int addRandomCards(MTGDeck * i, int howmany = 1);
virtual int addToDeck(MTGDeck * i, int num=-1); //Returns num that didn't add virtual int addToDeck(MTGDeck * i, int num = -1); //Returns num that didn't add
virtual WCardFilter * getFiltersRoot(){return filtersRoot;}; virtual WCardFilter * getFiltersRoot()
{
return filtersRoot;
}
;
enum { enum
{
MAX_CYCLES = 4, //How many cycles to search, for addToDeck MAX_CYCLES = 4, //How many cycles to search, for addToDeck
SORT_COLLECTOR, SORT_COLLECTOR,
SORT_ALPHA, SORT_ALPHA,
@@ -110,61 +183,178 @@ public:
}; };
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) :
WSrcCards(delay)
{
clearCounts();
}
;
virtual int loadMatches(MTGDeck * deck); virtual int loadMatches(MTGDeck * deck);
virtual int Add(MTGCard * c, int quantity=1); virtual int Add(MTGCard * c, int quantity = 1);
virtual int Remove(MTGCard * c, int quantity=1, bool erase=false); virtual int Remove(MTGCard * c, int quantity = 1, bool erase = false);
void Rebuild(MTGDeck * d); void Rebuild(MTGDeck * d);
int count(MTGCard * c); int count(MTGCard * c);
int countByName(MTGCard * card, bool editions=false); int countByName(MTGCard * card, bool editions = false);
int totalPrice(); int totalPrice();
enum { enum
{
//0 to MTG_NB_COLORS are colors. See MTG_COLOR_ in Constants::. //0 to MTG_NB_COLORS are colors. See MTG_COLOR_ in Constants::.
UNFILTERED_COPIES = Constants::MTG_NB_COLORS, UNFILTERED_COPIES = Constants::MTG_NB_COLORS,
UNFILTERED_UNIQUE, UNFILTERED_UNIQUE,
@@ -176,25 +366,27 @@ public:
}; };
void clearCounts(); void clearCounts();
void updateCounts(); void updateCounts();
void addCount(MTGCard * c, int qty=1); void addCount(MTGCard * c, int qty = 1);
int getCount(int count=UNFILTERED_COPIES); 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); int rareToInt(char r);
bool operator()(const MTGCard*l, const MTGCard*r); bool operator()(const MTGCard*l, const MTGCard*r);
}; };
#endif #endif
+62 -34
View File
@@ -29,11 +29,20 @@ public:
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; MTGCardInstance * card;
MTGGameZone * from; MTGGameZone * from;
MTGGameZone * to; MTGGameZone * to;
@@ -43,8 +52,8 @@ struct WEventZoneChange : public WEvent {
virtual Targetable * getTarget(int target); 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;
@@ -52,25 +61,28 @@ struct WEventDamage : public WEvent {
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 * from;
Phase * to; Phase * to;
WEventPhaseChange(Phase * from, 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; MTGCardInstance * card;
WEventCardUpdate(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; int type;
bool before; bool before;
bool after; bool after;
@@ -78,68 +90,77 @@ struct WEventCardChangeType : public WEventCardUpdate {
}; };
//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 before;
bool after; bool after;
WEventCardTap(MTGCardInstance * card, bool before, bool after); WEventCardTap(MTGCardInstance * card, bool before, bool after);
virtual Targetable * getTarget(int target); virtual Targetable * getTarget(int target);
}; };
struct WEventCardTappedForMana : public WEventCardUpdate { struct WEventCardTappedForMana: public WEventCardUpdate
{
bool before; bool before;
bool after; bool after;
WEventCardTappedForMana(MTGCardInstance * card, bool before, bool after); WEventCardTappedForMana(MTGCardInstance * card, bool before, bool after);
virtual Targetable * getTarget(int target); 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 * before;
Targetable * after; Targetable * after;
WEventCreatureAttacker(MTGCardInstance * card, Targetable * from, Targetable * to); 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); WEventCardAttacked(MTGCardInstance * card);
virtual Targetable * getTarget(int target); 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); WEventCardAttackedAlone(MTGCardInstance * card);
virtual Targetable * getTarget(int target); 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); WEventCardAttackedNotBlocked(MTGCardInstance * card);
virtual Targetable * getTarget(int target); 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); WEventCardAttackedBlocked(MTGCardInstance * card);
virtual Targetable * getTarget(int target); virtual Targetable * getTarget(int target);
}; };
//event when card blocked. //event when card blocked.
struct WEventCardBlocked : public WEventCardUpdate { struct WEventCardBlocked: public WEventCardUpdate
{
WEventCardBlocked(MTGCardInstance * card); WEventCardBlocked(MTGCardInstance * card);
virtual Targetable * getTarget(int target); 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); WEventCardSacrifice(MTGCardInstance * card);
virtual Targetable * getTarget(int target); 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); WEventCardDiscard(MTGCardInstance * card);
virtual Targetable * getTarget(int target); virtual Targetable * getTarget(int target);
}; };
@@ -147,24 +168,28 @@ struct WEventCardDiscard : public WEventCardUpdate {
//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 * before;
MTGCardInstance * after; MTGCardInstance * after;
WEventCreatureBlocker(MTGCardInstance * card,MTGCardInstance * from,MTGCardInstance * to); 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); {
WEventcardDraw(Player * player, int nb_cards);
Player * player; Player * player;
int nb_cards; int nb_cards;
virtual Targetable * getTarget(Player * player); virtual Targetable * getTarget(Player * player);
@@ -173,23 +198,24 @@ struct WEventcardDraw : public WEvent {
//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 * exchangeWith;
MTGCardInstance * attacker; MTGCardInstance * attacker;
WEventCreatureBlockerRank(MTGCardInstance * card,MTGCardInstance * exchangeWith, 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; int color;
MTGCardInstance* card; MTGCardInstance* card;
ManaPool * destination; ManaPool * destination;
@@ -198,7 +224,8 @@ struct WEventEngageMana : public WEvent {
//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; int color;
ManaPool * source; ManaPool * source;
WEventConsumeMana(int color, ManaPool * source); WEventConsumeMana(int color, ManaPool * source);
@@ -206,7 +233,8 @@ struct WEventConsumeMana : public WEvent {
//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; ManaPool * source;
WEventEmptyManaPool(ManaPool * source); WEventEmptyManaPool(ManaPool * source);
}; };
+208 -56
View File
@@ -3,132 +3,250 @@
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)
{
return true;
}
;
virtual string getCode() = 0; virtual string getCode() = 0;
virtual float filterFee() {return 0.0f;}; 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);}; {
lhs = a;
rhs = b;
}
;
~WCFBranch()
{
SAFE_DELETE(lhs);
SAFE_DELETE(rhs);
}
;
virtual bool isMatch(MTGCard * c) = 0; virtual bool isMatch(MTGCard * c) = 0;
virtual string getCode() = 0; virtual string getCode() = 0;
virtual WCardFilter * Right(){return rhs;}; virtual WCardFilter * Right()
virtual WCardFilter * Left(){return lhs;}; {
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) :
WCFBranch(a, b)
{
}
;
bool isMatch(MTGCard *c); bool isMatch(MTGCard *c);
string getCode(); string getCode();
float filterFee(); 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)
{
}
;
bool isMatch(MTGCard *c)
{
return (lhs->isMatch(c) && rhs->isMatch(c));
}
;
string getCode(); string getCode();
float filterFee(); 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;
}
;
~WCFilterGROUP()
{
SAFE_DELETE(kid);
}
;
bool isMatch(MTGCard *c)
{
return kid->isMatch(c);
}
;
string getCode(); string getCode();
float filterFee() {return kid->filterFee();}; 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;
}
;
~WCFilterNOT()
{
SAFE_DELETE(kid);
}
;
bool isMatch(MTGCard *c)
{
return !kid->isMatch(c);
}
;
string getCode(); 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)
{
setid = _setid;
}
;
WCFilterSet(string arg); WCFilterSet(string arg);
bool isMatch(MTGCard *c) {return (setid==MTGSets::ALL_SETS || c->setId == setid);}; bool isMatch(MTGCard *c)
{
return (setid == MTGSets::ALL_SETS || c->setId == setid);
}
;
string getCode(); string getCode();
float filterFee() {return 0.2f;}; 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)
{
color = _c;
}
;
WCFilterColor(string arg); WCFilterColor(string arg);
bool isMatch(MTGCard * c); bool isMatch(MTGCard * c);
string getCode(); string getCode();
float filterFee() {return 0.2f;}; 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)
{
number = _num;
}
;
WCFilterNumeric(string arg); WCFilterNumeric(string arg);
bool isMatch(MTGCard * c) = 0; bool isMatch(MTGCard * c) = 0;
string getCode() = 0; string getCode() = 0;
@@ -136,43 +254,72 @@ public:
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)
{
type = arg;
}
;
bool isMatch(MTGCard * c); bool isMatch(MTGCard * c);
string getCode(); string getCode();
float filterFee() {return 0.4f;}; 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)
{
rarity = _r;
}
;
WCFilterRarity(string arg); WCFilterRarity(string arg);
bool isMatch(MTGCard * c); bool isMatch(MTGCard * c);
string getCode(); string getCode();
@@ -180,9 +327,14 @@ public:
protected: protected:
char rarity; char rarity;
}; };
class WCFilterAbility: public WCardFilter{ class WCFilterAbility: public WCardFilter
{
public: public:
WCFilterAbility(int _a) {ability = _a;}; WCFilterAbility(int _a)
{
ability = _a;
}
;
WCFilterAbility(string arg); WCFilterAbility(string arg);
bool isMatch(MTGCard * c); bool isMatch(MTGCard * c);
string getCode(); string getCode();
+74 -27
View File
@@ -22,7 +22,6 @@ namespace Fonts
const unsigned int kSingleByteFontOffset = 100; const unsigned int kSingleByteFontOffset = 100;
} }
class WFont class WFont
{ {
public: public:
@@ -34,8 +33,8 @@ public:
// 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.
@@ -58,38 +57,86 @@ public:
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 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); 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
{
return mColor0;
}
;
void SetScale(float scale); void SetScale(float scale);
float GetScale() const; float GetScale() const;
float GetHeight() const; float GetHeight() const;
@@ -98,11 +145,11 @@ public:
void SetBase(int base) {}; void SetBase(int base) {};
void FormatText(string &s, vector<string>& output) {}; 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;
@@ -131,24 +178,24 @@ public:
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;
+477 -152
View File
@@ -5,11 +5,12 @@
class hgeDistortionMesh; class hgeDistortionMesh;
class GameStateOptions; class GameStateOptions;
class WGuiColor{ class WGuiColor
{
public: public:
enum { enum
SCROLLBAR, {
SCROLLBUTTON, SCROLLBAR, SCROLLBUTTON,
//Foregrounds only after this //Foregrounds only after this
TEXT, TEXT,
TEXT_HEADER, TEXT_HEADER,
@@ -25,7 +26,8 @@ public:
}; };
}; };
struct WDistort { struct WDistort
{
WDistort(); WDistort();
WDistort(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4); WDistort(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
float & operator[](int p); float & operator[](int p);
@@ -34,39 +36,62 @@ protected:
}; };
//Complete item interface //Complete item interface
class WGuiBase: public JGuiListener { class WGuiBase: public JGuiListener
{
public: public:
typedef enum { typedef enum
{
CONFIRM_NEED, // Still needs confirmation CONFIRM_NEED, // Still needs confirmation
CONFIRM_OK, // Is okay (no need to confirm, or has been confirmed) CONFIRM_OK, // Is okay (no need to confirm, or has been confirmed)
CONFIRM_CANCEL, // Is not okay, must cancel save CONFIRM_CANCEL,
// Is not okay, must cancel save
} CONFIRM_TYPE; } CONFIRM_TYPE;
WGuiBase() {}; WGuiBase() {};
virtual ~WGuiBase() {}; virtual ~WGuiBase() {};
virtual bool Selectable() {return true;}; virtual bool Selectable()
virtual bool isModal() {return false;}; {
virtual bool Visible() {return true;}; return true;
}
;
virtual bool isModal()
{
return false;
}
;
virtual bool Visible()
{
return true;
}
;
virtual bool Changed() {return false;}; virtual bool Changed()
{
return false;
}
;
virtual void confirmChange(bool confirmed) {}; virtual void confirmChange(bool confirmed) {};
virtual CONFIRM_TYPE needsConfirm(); virtual CONFIRM_TYPE needsConfirm();
virtual bool yieldFocus(); virtual bool yieldFocus();
virtual PIXEL_TYPE getColor(int type); virtual PIXEL_TYPE getColor(int type);
virtual float getMargin(int type) {return 4;}; virtual float getMargin(int type)
{
return 4;
}
;
virtual void Entering(JButton key)=0; virtual void Entering(JButton key)=0;
virtual bool Leaving(JButton key)=0; virtual bool Leaving(JButton key)=0;
virtual void Update(float dt)=0; virtual void Update(float dt)=0;
virtual void updateValue(){}; virtual void updateValue() {};
virtual void Render()=0; virtual void Render()=0;
virtual void setData()=0; virtual void setData()=0;
virtual void ButtonPressed(int controllerId, int controlId){}; virtual void ButtonPressed(int controllerId, int controlId) {};
virtual void Reload(){}; virtual void Reload() {};
virtual void Overlay(){}; virtual void Overlay() {};
virtual void Underlay(){}; virtual void Underlay() {};
virtual bool hasFocus()=0; virtual bool hasFocus()=0;
virtual void setFocus(bool bFocus)=0; virtual void setFocus(bool bFocus)=0;
@@ -74,31 +99,51 @@ public:
virtual float getY()=0; virtual float getY()=0;
virtual float getWidth()=0; virtual float getWidth()=0;
virtual float getHeight()=0; virtual float getHeight()=0;
virtual int getId() {return INVALID_ID;}; virtual int getId()
virtual string getDisplay() const {return "";}; {
virtual float minWidth(){return getWidth();}; return INVALID_ID;
virtual float minHeight(){return getHeight();}; }
;
virtual string getDisplay() const
{
return "";
}
;
virtual float minWidth()
{
return getWidth();
}
;
virtual float minHeight()
{
return getHeight();
}
;
virtual void setModal(bool val){}; virtual void setModal(bool val) {};
virtual void setDisplay(string s){}; virtual void setDisplay(string s) {};
virtual void setX(float _x){}; virtual void setX(float _x) {};
virtual void setY(float _y){}; virtual void setY(float _y) {};
virtual void setWidth(float _w){}; virtual void setWidth(float _w) {};
virtual void setHeight(float _h){}; virtual void setHeight(float _h) {};
virtual void setId(int _id){}; virtual void setId(int _id) {};
virtual void setHidden(bool bHidden) {}; virtual void setHidden(bool bHidden){};
virtual void setVisible(bool bVisisble) {}; virtual void setVisible(bool bVisisble) {};
virtual void renderBack(WGuiBase * it); virtual void renderBack(WGuiBase * it);
virtual void subBack(WGuiBase * item) {}; virtual void subBack(WGuiBase * item) {};
virtual bool CheckUserInput(JButton key) {return false;}; virtual bool CheckUserInput(JButton key)
protected: {
return false;
}
;
protected:
vector<WGuiBase*> items; vector<WGuiBase*> items;
}; };
//This is our base class for concrete items. //This is our base class for concrete items.
class WGuiItem: public WGuiBase{ class WGuiItem: public WGuiBase
{
public: public:
virtual void Entering(JButton key); virtual void Entering(JButton key);
virtual bool Leaving(JButton key); virtual bool Leaving(JButton key);
@@ -111,28 +156,81 @@ public:
string _(string input); //Override global with our flag checker. string _(string input); //Override global with our flag checker.
virtual void setData(){}; virtual void setData() {};
virtual bool hasFocus() {return mFocus;}; virtual bool hasFocus()
virtual void setFocus(bool bFocus) {mFocus = bFocus;}; {
return mFocus;
}
;
virtual void setFocus(bool bFocus)
{
mFocus = bFocus;
}
;
virtual string getDisplay() const {return displayValue;}; virtual string getDisplay() const
virtual void setDisplay(string s){displayValue=s;}; {
return displayValue;
}
;
virtual void setDisplay(string s)
{
displayValue = s;
}
;
virtual int getId() {return INVALID_ID;}; virtual int getId()
virtual float getX() {return x;}; {
virtual float getY() {return y;}; return INVALID_ID;
virtual float getWidth() {return width;}; }
virtual float getHeight() {return height;}; ;
virtual float getX()
{
return x;
}
;
virtual float getY()
{
return y;
}
;
virtual float getWidth()
{
return width;
}
;
virtual float getHeight()
{
return height;
}
;
virtual float minWidth(); virtual float minWidth();
virtual float minHeight(); virtual float minHeight();
virtual void setId(int _id){}; virtual void setId(int _id) {};
virtual void setX(float _x){x = _x;}; virtual void setX(float _x)
virtual void setY(float _y){y = _y;}; {
virtual void setWidth(float _w){width = _w;}; x = _x;
virtual void setHeight(float _h){height = _h;}; }
enum { ;
NO_TRANSLATE = (1<<1), virtual void setY(float _y)
{
y = _y;
}
;
virtual void setWidth(float _w)
{
width = _w;
}
;
virtual void setHeight(float _h)
{
height = _h;
}
;
enum
{
NO_TRANSLATE = (1 << 1),
}; };
u8 mFlags; u8 mFlags;
@@ -144,99 +242,277 @@ protected:
string displayValue; string displayValue;
}; };
class WGuiImage: public WGuiItem{ class WGuiImage: public WGuiItem
{
public: public:
WGuiImage(WDataSource * wds, float _w = 0, float _h = 0, int _margin = 0); WGuiImage(WDataSource * wds, float _w = 0, float _h = 0, int _margin = 0);
virtual bool Selectable() {return false;}; virtual bool Selectable()
{
return false;
}
;
virtual void Render(); virtual void Render();
virtual float getHeight(); virtual float getHeight();
virtual void imageScale(float _w, float _h); virtual void imageScale(float _w, float _h);
virtual void setSource(WDataSource *s) {source = s;}; virtual void setSource(WDataSource *s)
{
source = s;
}
;
protected: protected:
int margin; int margin;
float imgW, imgH; float imgW, imgH;
WDataSource * source;}; WDataSource * source;
};
class WGuiCardImage: public WGuiImage{ class WGuiCardImage: public WGuiImage
{
public: public:
WGuiCardImage(WDataSource * wds, bool _thumb=false); WGuiCardImage(WDataSource * wds, bool _thumb = false);
virtual void Render(); virtual void Render();
WSyncable mOffset; WSyncable mOffset;
protected: protected:
bool bThumb; bool bThumb;
}; };
class WGuiCardDistort: public WGuiCardImage{ class WGuiCardDistort: public WGuiCardImage
{
public: public:
WGuiCardDistort(WDataSource * wds, bool _thumb=false, WDataSource * _distort=NULL); WGuiCardDistort(WDataSource * wds, bool _thumb = false, WDataSource * _distort = NULL);
~WGuiCardDistort(); ~WGuiCardDistort();
virtual void Render(); virtual void Render();
WDistort xy; WDistort xy;
/* we assume first xy is the top left of the distorted card */ /* we assume first xy is the top left of the distorted card */
virtual float getX() {return xy[0];}; virtual float getX()
virtual float getY() {return xy[1];}; {
return xy[0];
}
;
virtual float getY()
{
return xy[1];
}
;
protected: protected:
hgeDistortionMesh* mesh; hgeDistortionMesh* mesh;
WDataSource * distortSrc; WDataSource * distortSrc;
}; };
//This is our base class for decorators. It wraps everything about WGuiBase. //This is our base class for decorators. It wraps everything about WGuiBase.
class WGuiDeco: public WGuiBase{ class WGuiDeco: public WGuiBase
{
public: public:
WGuiDeco(WGuiBase* _it) {it = _it;}; WGuiDeco(WGuiBase* _it)
virtual ~WGuiDeco() {SAFE_DELETE(it);}; {
it = _it;
}
;
virtual ~WGuiDeco()
{
SAFE_DELETE(it);
}
;
virtual bool Selectable() {return it->Selectable();}; virtual bool Selectable()
virtual bool Visible() {return it->Visible();}; {
virtual bool Changed() {return it->Changed();}; return it->Selectable();
virtual void confirmChange(bool confirmed) {it->confirmChange(confirmed);}; }
virtual CONFIRM_TYPE needsConfirm() { return it->needsConfirm();}; ;
virtual bool yieldFocus() {return it->yieldFocus();}; virtual bool Visible()
{
return it->Visible();
}
;
virtual bool Changed()
{
return it->Changed();
}
;
virtual void confirmChange(bool confirmed)
{
it->confirmChange(confirmed);
}
;
virtual CONFIRM_TYPE needsConfirm()
{
return it->needsConfirm();
}
;
virtual bool yieldFocus()
{
return it->yieldFocus();
}
;
virtual void Entering(JButton key) {it->Entering(key);}; virtual void Entering(JButton key)
virtual bool Leaving(JButton key) {return it->Leaving(key);}; {
virtual void Update(float dt) {it->Update(dt);}; it->Entering(key);
virtual void updateValue() {it->updateValue();}; }
virtual void Reload() {it->Reload();}; ;
virtual void Overlay() {it->Overlay();}; virtual bool Leaving(JButton key)
virtual void Underlay() {it->Underlay();}; {
virtual void Render() {it->Render();}; return it->Leaving(key);
virtual void setData() {it->setData();}; }
;
virtual void Update(float dt)
{
it->Update(dt);
}
;
virtual void updateValue()
{
it->updateValue();
}
;
virtual void Reload()
{
it->Reload();
}
;
virtual void Overlay()
{
it->Overlay();
}
;
virtual void Underlay()
{
it->Underlay();
}
;
virtual void Render()
{
it->Render();
}
;
virtual void setData()
{
it->setData();
}
;
virtual void ButtonPressed(int controllerId, int controlId) {it->ButtonPressed(controllerId, controlId);}; virtual void ButtonPressed(int controllerId, int controlId)
{
it->ButtonPressed(controllerId, controlId);
}
;
virtual bool hasFocus() {return it->hasFocus();}; virtual bool hasFocus()
virtual string getDisplay() const {return it->getDisplay();}; {
virtual int getId() {return it->getId();}; return it->hasFocus();
virtual float getX() {return it->getX();}; }
virtual float getY() {return it->getY();}; ;
virtual float getWidth() {return it->getWidth();}; virtual string getDisplay() const
virtual float getHeight() {return it->getHeight();}; {
virtual PIXEL_TYPE getColor(int type) {return it->getColor(type);}; return it->getDisplay();
WGuiBase * getDecorated() {return it;}; }
;
virtual int getId()
{
return it->getId();
}
;
virtual float getX()
{
return it->getX();
}
;
virtual float getY()
{
return it->getY();
}
;
virtual float getWidth()
{
return it->getWidth();
}
;
virtual float getHeight()
{
return it->getHeight();
}
;
virtual PIXEL_TYPE getColor(int type)
{
return it->getColor(type);
}
;
WGuiBase * getDecorated()
{
return it;
}
;
virtual void setFocus(bool bFocus) {it->setFocus(bFocus);}; virtual void setFocus(bool bFocus)
virtual void setDisplay(string s) {it->setDisplay(s);}; {
virtual void setId(int _id) {it->setId(_id);}; it->setFocus(bFocus);
virtual void setX(float _x) {it->setX(_x);}; }
virtual void setY(float _y) {it->setY(_y);}; ;
virtual void setWidth(float _w) {it->setWidth(_w);}; virtual void setDisplay(string s)
virtual void setHeight(float _h) {it->setHeight(_h);}; {
virtual void setHidden(bool bHidden) {it->setHidden(bHidden);}; it->setDisplay(s);
virtual void setVisible(bool bVisisble) {it->setVisible(bVisisble);}; }
virtual bool CheckUserInput(JButton key) {return it->CheckUserInput(key);}; ;
virtual void setId(int _id)
{
it->setId(_id);
}
;
virtual void setX(float _x)
{
it->setX(_x);
}
;
virtual void setY(float _y)
{
it->setY(_y);
}
;
virtual void setWidth(float _w)
{
it->setWidth(_w);
}
;
virtual void setHeight(float _h)
{
it->setHeight(_h);
}
;
virtual void setHidden(bool bHidden)
{
it->setHidden(bHidden);
}
;
virtual void setVisible(bool bVisisble)
{
it->setVisible(bVisisble);
}
;
virtual bool CheckUserInput(JButton key)
{
return it->CheckUserInput(key);
}
;
protected: protected:
WGuiBase * it; WGuiBase * it;
}; };
class WGuiAward: public WGuiItem{ class WGuiAward: public WGuiItem
{
public: public:
WGuiAward(int _id, string name, string _text, string _details=""); WGuiAward(int _id, string name, string _text, string _details = "");
virtual ~WGuiAward(); virtual ~WGuiAward();
virtual void Render(); virtual void Render();
virtual bool Selectable() {return Visible();}; virtual bool Selectable()
{
return Visible();
}
;
virtual bool Visible(); virtual bool Visible();
virtual int getId() {return id;}; virtual int getId()
{
return id;
}
;
virtual void Underlay(); virtual void Underlay();
virtual void Overlay(); virtual void Overlay();
@@ -246,9 +522,10 @@ protected:
string text; string text;
}; };
class WGuiSplit: public WGuiItem{ class WGuiSplit: public WGuiItem
{
public: public:
WGuiSplit(WGuiBase* _left,WGuiBase* _right); WGuiSplit(WGuiBase* _left, WGuiBase* _right);
virtual ~WGuiSplit(); virtual ~WGuiSplit();
virtual bool yieldFocus(); virtual bool yieldFocus();
@@ -278,7 +555,8 @@ public:
WGuiBase* left; WGuiBase* left;
}; };
class WDecoConfirm: public WGuiDeco{ class WDecoConfirm: public WGuiDeco
{
public: public:
WDecoConfirm(JGuiListener * _listener, WGuiBase * it); WDecoConfirm(JGuiListener * _listener, WGuiBase * it);
virtual ~WDecoConfirm(); virtual ~WDecoConfirm();
@@ -296,27 +574,31 @@ public:
string confirm; string confirm;
string cancel; string cancel;
protected: protected:
enum { enum
{
OP_UNCONFIRMED, OP_UNCONFIRMED,
OP_CONFIRMING, OP_CONFIRMING,
OP_CONFIRMED, OP_CONFIRMED,
} mState; } mState;
SimpleMenu * confirmMenu; SimpleMenu * confirmMenu;
JGuiListener * listener; JGuiListener * listener;
bool bModal; bool bModal;
}; };
class WDecoEnum : public WGuiDeco { class WDecoEnum: public WGuiDeco
public: {
WDecoEnum(WGuiBase * _it,EnumDefinition *_edef = NULL); public:
WDecoEnum(WGuiBase * _it, EnumDefinition *_edef = NULL);
virtual void Render(); virtual void Render();
string lookupVal(int value); string lookupVal(int value);
protected: protected:
EnumDefinition * edef; EnumDefinition * edef;
}; };
class WDecoCheat: public WGuiDeco { class WDecoCheat: public WGuiDeco
public: {
public:
WDecoCheat(WGuiBase * _it); WDecoCheat(WGuiBase * _it);
virtual bool Visible(); virtual bool Visible();
bool Selectable(); bool Selectable();
@@ -325,49 +607,71 @@ protected:
bool bVisible; bool bVisible;
}; };
class WGuiButton: public WGuiDeco{ class WGuiButton: public WGuiDeco
{
public: public:
WGuiButton( WGuiBase* _it, int _controller, int _control, JGuiListener * jgl); WGuiButton(WGuiBase* _it, int _controller, int _control, JGuiListener * jgl);
virtual void updateValue(); virtual void updateValue();
virtual bool CheckUserInput(JButton key); virtual bool CheckUserInput(JButton key);
virtual bool Selectable() {return Visible();}; virtual bool Selectable()
{
return Visible();
}
;
virtual PIXEL_TYPE getColor(int type); virtual PIXEL_TYPE getColor(int type);
virtual int getControlID() {return control;}; virtual int getControlID()
virtual int getControllerID() {return controller;}; {
return control;
}
;
virtual int getControllerID()
{
return controller;
}
;
protected: protected:
int control, controller; int control, controller;
JGuiListener * mListener; JGuiListener * mListener;
}; };
class WGuiHeader:public WGuiItem{ class WGuiHeader: public WGuiItem
public: {
WGuiHeader(string _displayValue): WGuiItem(_displayValue) {}; public:
virtual bool Selectable() {return false;}; WGuiHeader(string _displayValue) : WGuiItem(_displayValue) {};
virtual bool Selectable()
{
return false;
}
;
virtual void Render(); virtual void Render();
}; };
class WDecoStyled: public WGuiDeco{ class WDecoStyled: public WGuiDeco
{
public: public:
WDecoStyled(WGuiItem * _it) : WGuiDeco(_it) {mStyle=DS_DEFAULT;}; WDecoStyled(WGuiItem * _it) :
WGuiDeco(_it)
{
mStyle = DS_DEFAULT;
}
;
PIXEL_TYPE getColor(int type); PIXEL_TYPE getColor(int type);
void subBack(WGuiBase * item); void subBack(WGuiBase * item);
enum { enum
DS_DEFAULT = (1<<0), {
DS_COLOR_BRIGHT = (1<<1), DS_DEFAULT = (1 << 0), DS_COLOR_BRIGHT = (1 << 1), DS_COLOR_DARK = (1 << 2), DS_STYLE_ALERT = (1 << 3),
DS_COLOR_DARK = (1<<2), DS_STYLE_EDGED = (1 << 4), DS_STYLE_BACKLESS = (1 << 5),
DS_STYLE_ALERT = (1<<3),
DS_STYLE_EDGED = (1<<4),
DS_STYLE_BACKLESS = (1<<5),
}; };
u8 mStyle; u8 mStyle;
}; };
class WGuiMenu: public WGuiItem{ class WGuiMenu: public WGuiItem
{
public: public:
friend class WGuiFilters; friend class WGuiFilters;
virtual ~WGuiMenu(); virtual ~WGuiMenu();
WGuiMenu(JButton next, JButton prev, bool mDPad = false, WSyncable * syncme=NULL); WGuiMenu(JButton next, JButton prev, bool mDPad = false, WSyncable * syncme = NULL);
virtual bool yieldFocus(); virtual bool yieldFocus();
virtual void Render(); virtual void Render();
@@ -381,9 +685,17 @@ public:
virtual void subBack(WGuiBase * item); virtual void subBack(WGuiBase * item);
virtual bool CheckUserInput(JButton key); virtual bool CheckUserInput(JButton key);
WGuiBase * Current(); WGuiBase * Current();
virtual int getSelected() {return currentItem;}; virtual int getSelected()
virtual void setSelected(vector<WGuiBase*>::iterator& it) { {
int c = it - items.begin();setSelected(c);}; return currentItem;
}
;
virtual void setSelected(vector<WGuiBase*>::iterator& it)
{
int c = it - items.begin();
setSelected(c);
}
;
virtual void setSelected(int newItem); virtual void setSelected(int newItem);
virtual bool nextItem(); virtual bool nextItem();
virtual bool prevItem(); virtual bool prevItem();
@@ -403,8 +715,9 @@ protected:
float duration; float duration;
}; };
class WGuiList: public WGuiMenu{ class WGuiList: public WGuiMenu
public: {
public:
WGuiList(string name, WSyncable * syncme = NULL); WGuiList(string name, WSyncable * syncme = NULL);
string failMsg; string failMsg;
@@ -417,21 +730,24 @@ class WGuiList: public WGuiMenu{
protected: protected:
bool mFocus; bool mFocus;
}; };
class WGuiTabMenu: public WGuiMenu { class WGuiTabMenu: public WGuiMenu
public: {
public:
WGuiTabMenu() : WGuiMenu(JGE_BTN_NEXT, JGE_BTN_PREV) {}; WGuiTabMenu() : WGuiMenu(JGE_BTN_NEXT, JGE_BTN_PREV) {};
virtual void Render(); virtual void Render();
virtual void Add(WGuiBase * it); virtual void Add(WGuiBase * it);
void save(); void save();
virtual bool CheckUserInput(JButton key); virtual bool CheckUserInput(JButton key);
}; };
class WGuiListRow: public WGuiList{ class WGuiListRow: public WGuiList
public: {
public:
WGuiListRow(string n, WSyncable * s = NULL); WGuiListRow(string n, WSyncable * s = NULL);
virtual void Render(); virtual void Render();
}; };
class WGuiFilters: public WGuiItem { class WGuiFilters: public WGuiItem
{
public: public:
friend class WGuiFilterItem; friend class WGuiFilterItem;
WGuiFilters(string header, WSrcCards * src); WGuiFilters(string header, WSrcCards * src);
@@ -446,14 +762,18 @@ public:
bool isAvailable(int type); bool isAvailable(int type);
bool isAvailableCode(string code); bool isAvailableCode(string code);
bool Finish(bool emptyset = false); //Returns true if card set reasonably expected to be changed. bool Finish(bool emptyset = false); //Returns true if card set reasonably expected to be changed.
bool isFinished() {return bFinished;}; bool isFinished()
{
return bFinished;
}
;
void ButtonPressed(int controllerId, int controlId); void ButtonPressed(int controllerId, int controlId);
void buildList(); void buildList();
void setSrc(WSrcCards * wsc); void setSrc(WSrcCards * wsc);
protected: protected:
void clearArgs(); void clearArgs();
void addArg(string display, string code); void addArg(string display, string code);
vector< pair<string,string> > tempArgs; //TODO FIXME this is inefficient vector<pair<string, string> > tempArgs; //TODO FIXME this is inefficient
bool bFinished; bool bFinished;
int recolorTo; int recolorTo;
WSrcCards* source; WSrcCards* source;
@@ -461,7 +781,8 @@ protected:
WGuiList * list; WGuiList * list;
}; };
class WGuiFilterItem: public WGuiItem { class WGuiFilterItem: public WGuiItem
{
public: public:
friend class WGuiFilters; friend class WGuiFilters;
friend struct WLFiltersSort; friend struct WLFiltersSort;
@@ -470,7 +791,8 @@ public:
void ButtonPressed(int controllerId, int controlId); void ButtonPressed(int controllerId, int controlId);
string getCode(); string getCode();
bool isModal(); bool isModal();
enum { enum
{
STATE_UNSET, STATE_UNSET,
STATE_CHOOSE_TYPE, STATE_CHOOSE_TYPE,
STATE_CHOOSE_VAL, STATE_CHOOSE_VAL,
@@ -500,16 +822,19 @@ protected:
WGuiFilters * mParent; WGuiFilters * mParent;
}; };
struct WListSort{ struct WListSort
{
virtual bool operator()(const WGuiBase*l, const WGuiBase*r); virtual bool operator()(const WGuiBase*l, const WGuiBase*r);
}; };
struct WLFiltersSort{ struct WLFiltersSort
{
bool operator()(const WGuiBase*l, const WGuiBase*r); bool operator()(const WGuiBase*l, const WGuiBase*r);
}; };
class WGuiKeyBinder : public WGuiList { class WGuiKeyBinder: public WGuiList
public: {
public:
WGuiKeyBinder(string name, GameStateOptions* parent); WGuiKeyBinder(string name, GameStateOptions* parent);
virtual bool isModal(); virtual bool isModal();
virtual bool CheckUserInput(JButton); virtual bool CheckUserInput(JButton);
@@ -519,7 +844,7 @@ class WGuiKeyBinder : public WGuiList {
virtual CONFIRM_TYPE needsConfirm(); virtual CONFIRM_TYPE needsConfirm();
virtual void ButtonPressed(int controllerId, int controlId); virtual void ButtonPressed(int controllerId, int controlId);
virtual bool yieldFocus(); virtual bool yieldFocus();
protected: protected:
GameStateOptions* parent; GameStateOptions* parent;
SimpleMenu* confirmMenu; SimpleMenu* confirmMenu;
bool modal; bool modal;
+32 -27
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,15 +30,17 @@
#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_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_NORMAL, //Returns or creates a resource. Does not change lock status.
RETRIEVE_LOCK, //As above, locks cached resource. Not for quads. RETRIEVE_LOCK, //As above, locks cached resource. Not for quads.
@@ -47,24 +48,28 @@ enum ENUM_RETRIEVE_STYLE{
RETRIEVE_RESOURCE, //Only retrieves a managed resource. Does not make a new one. RETRIEVE_RESOURCE, //Only retrieves a managed resource. Does not make a new one.
RETRIEVE_MANAGE, //Makes resource permanent. RETRIEVE_MANAGE, //Makes resource permanent.
RETRIEVE_THUMB, //Retrieve it as a thumbnail. RETRIEVE_THUMB, //Retrieve it as a thumbnail.
CACHE_THUMB = RETRIEVE_THUMB, //Backwords compatibility. 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,
@@ -74,11 +79,12 @@ enum ENUM_CACHE_ERROR{
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:
@@ -89,7 +95,7 @@ public:
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.
@@ -105,9 +111,9 @@ protected:
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;
@@ -119,7 +125,6 @@ protected:
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();
@@ -225,9 +230,9 @@ private:
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;
-5
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
+3 -6
View File
@@ -20,7 +20,6 @@
#endif #endif
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
@@ -65,14 +64,13 @@ namespace wagic
}; };
#else #else
typedef std::ifstream ifstream; typedef std::ifstream ifstream;
#endif #endif
} //namespace wagic } //namespace wagic
using std::string; using std::string;
//string manipulation methods //string manipulation methods
string& trim(string& str); string& trim(string& str);
string& ltrim(string& str); string& ltrim(string& str);
@@ -93,7 +91,6 @@ int WRand();
void dumpStack(); void dumpStack();
#endif #endif
/* RAM simple check functions header */ /* RAM simple check functions header */
// *** DEFINES *** // *** DEFINES ***
@@ -106,8 +103,8 @@ void dumpStack();
// *** FUNCTIONS DECLARATIONS *** // *** FUNCTIONS DECLARATIONS ***
u32 ramAvailableLineareMax (void); u32 ramAvailableLineareMax(void);
u32 ramAvailable (void); u32 ramAvailable(void);
#ifdef WIN32 #ifdef WIN32
#include <direct.h> #include <direct.h>