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"
class AIMomirPlayer:public AIPlayerBaka{
class AIMomirPlayer: public AIPlayerBaka
{
public:
AIMomirPlayer(MTGDeck * deck, string file, string fileSmall, string avatarFile);
int getEfficiency(AIAction * action);
+34 -19
View File
@@ -18,7 +18,6 @@ using std::queue;
#define INFO_CREATURESTOUGHNESS 3
#define INFO_CREATURESATTACKINGPOWER 4
class AIStats;
class AIAction
@@ -35,22 +34,25 @@ public:
MTGCardInstance * click;
MTGCardInstance * target; // TODO Improve
AIAction(MTGAbility * a, MTGCardInstance * c, MTGCardInstance * t = NULL)
: efficiency(-1), ability(a), player(NULL), click(c), target(t)
AIAction(MTGAbility * a, MTGCardInstance * c, MTGCardInstance * t = NULL) :
efficiency(-1), ability(a), player(NULL), click(c), target(t)
{
id = currentId++;
};
}
;
AIAction(MTGCardInstance * c, MTGCardInstance * t = NULL)
: efficiency(-1), ability(NULL), player(NULL), click(c), target(t)
AIAction(MTGCardInstance * c, MTGCardInstance * t = NULL) :
efficiency(-1), ability(NULL), player(NULL), click(c), target(t)
{
id = currentId++;
};
}
;
AIAction(Player * p)
: efficiency(-1), ability(NULL), player(p), click(NULL), target(NULL)
AIAction(Player * p) :
efficiency(-1), ability(NULL), player(p), click(NULL), target(NULL)
{
};
}
;
int getEfficiency();
int Act();
@@ -66,14 +68,16 @@ public:
AIAction* a2Ptr = const_cast<AIAction*> (&a2);
int e1 = a1Ptr->getEfficiency();
int e2 = a2Ptr->getEfficiency();
if (e1 == e2) return a1Ptr->id < a2Ptr->id;
if (e1 == e2)
return a1Ptr->id < a2Ptr->id;
return (e1 > e2);
}
};
typedef std::map<AIAction, int, CmpAbilities> RankingContainer;
class AIPlayer: public Player{
class AIPlayer: public Player
{
protected:
//Variables used by Test suite
MTGCardInstance * nextCardToPlay;
@@ -97,8 +101,15 @@ public:
int agressivity;
bool Checked;
bool forceBestAbilityUse;
void End(){};
virtual int displayStack() {return 0;};
void End()
{
}
;
virtual int displayStack()
{
return 0;
}
;
int receiveEvent(WEvent * event);
void Render();
ManaCost * getPotentialMana(MTGCardInstance * card = NULL);
@@ -108,7 +119,11 @@ public:
virtual int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget = NULL);
virtual int Act(float dt);
virtual int affectCombatDamages(CombatStep);
int isAI(){return 1;};
int isAI()
{
return 1;
}
;
int canHandleCost(MTGAbility * ability);
int selectAbility();
int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingContainer& ranking);
@@ -117,8 +132,8 @@ public:
};
class AIPlayerBaka: public AIPlayer{
class AIPlayerBaka: public AIPlayer
{
protected:
int oldGamePhase;
float timer;
@@ -131,10 +146,10 @@ class AIPlayerBaka: public AIPlayer{
virtual int computeActions();
};
class AIPlayerFactory{
class AIPlayerFactory
{
public:
AIPlayer * createAIPlayer(MTGAllCards * collection, Player * opponent, int deckid = 0);
};
#endif
+9 -5
View File
@@ -18,18 +18,22 @@ class MTGCard;
class Damage;
class WEvent;
class AIStat{
class AIStat
{
public:
int source; //MTGId of the card
int value;
int occurences;
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:
Player * player;
string filename;
+43 -13
View File
@@ -12,19 +12,17 @@
#define ACTION_REQUESTED 1
#define ACTIVE 2
class MTGCardInstance;
class ManaCost;
class Targetable;
class TargetChooser;
class WEvent;
class ActionElement: public JGuiObject{
class ActionElement: public JGuiObject
{
protected:
int activeState;
public:
int isClone;
TargetChooser * tc;
@@ -35,20 +33,52 @@ class ActionElement: public JGuiObject{
int getActivity();
virtual void Update(float dt){};
virtual void Render(){};
virtual int testDestroy(){return 0;};
virtual int destroy(){return 0;};
virtual bool CheckUserInput(JButton key){return false;};
virtual int testDestroy()
{
return 0;
}
;
virtual int destroy()
{
return 0;
}
;
virtual bool CheckUserInput(JButton key)
{
return false;
}
;
ActionElement(int id);
virtual ~ActionElement();
virtual int isReactingToTargetClick(Targetable * card);
virtual int reactToTargetClick(Targetable * card);
virtual int isReactingToClick(MTGCardInstance * card, ManaCost * man = NULL){return 0;};
virtual int stillInUse(MTGCardInstance * card){return 0;};
virtual int receiveEvent(WEvent * event){return 0;};
virtual int reactToClick(MTGCardInstance * card){return 0;};
virtual const char * getMenuText(){return "Ability";};
virtual int isReactingToClick(MTGCardInstance * card, ManaCost * man = NULL)
{
return 0;
}
;
virtual int stillInUse(MTGCardInstance * card)
{
return 0;
}
;
virtual int receiveEvent(WEvent * event)
{
return 0;
}
;
virtual int reactToClick(MTGCardInstance * card)
{
return 0;
}
;
virtual const char * getMenuText()
{
return "Ability";
}
;
virtual ActionElement * clone() const = 0;
};
#endif
+2 -3
View File
@@ -16,7 +16,8 @@ class GuiLayer;
class Targetable;
class WEvent;
class ActionLayer: public GuiLayer, public JGuiListener{
class ActionLayer: public GuiLayer, public JGuiListener
{
public:
vector<ActionElement *> garbage;
Targetable * menuObject;
@@ -50,6 +51,4 @@ protected:
int cantCancel;
};
#endif
+57 -22
View File
@@ -9,7 +9,6 @@
#define MAX_SPELL_TARGETS 10
#define ACTION_SPELL 10
#define ACTION_DAMAGE 11
#define ACTION_DAMAGES 12
@@ -39,27 +38,62 @@ class DamageStack;
class ManaCost;
class TargetChooser;
#define ACTIONSTACK_STANDARD 0
#define ACTIONSTACK_TARGET 1
class Interruptible: public PlayGuiObject, public Targetable{
class Interruptible: public PlayGuiObject, public Targetable
{
public:
//TODO : remove these when they are back in PlayGuiObject
float x, y;
int state, display;
MTGCardInstance * source;
virtual void Entering(){mHasFocus = true;};
virtual bool Leaving(JButton key){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 void Entering()
{
mHasFocus = true;
}
;
virtual bool Leaving(JButton key)
{
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;
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)
virtual void Dump();
#endif
@@ -68,7 +102,8 @@ protected:
float GetVerticalTextOffset() const;
};
class NextGamePhase: public Interruptible {
class NextGamePhase: public Interruptible
{
public:
int resolve();
bool extraDamagePhase();
@@ -78,7 +113,8 @@ class NextGamePhase: public Interruptible {
NextGamePhase(int id);
};
class Spell: public Interruptible {
class Spell: public Interruptible
{
protected:
public:
@@ -106,7 +142,8 @@ class Spell: public Interruptible {
int getNbTargets();
};
class StackAbility: public Interruptible {
class StackAbility: public Interruptible
{
public:
MTGAbility * ability;
int resolve();
@@ -116,7 +153,8 @@ class StackAbility: public Interruptible {
StackAbility(int id, MTGAbility * _ability);
};
class PutInGraveyard: public Interruptible {
class PutInGraveyard: public Interruptible
{
public:
MTGCardInstance * card;
int removeFromGame;
@@ -126,8 +164,8 @@ class PutInGraveyard: public Interruptible {
PutInGraveyard(int id, MTGCardInstance * _card);
};
class DrawAction: public Interruptible {
class DrawAction: public Interruptible
{
public:
int nbcards;
Player * player;
@@ -137,7 +175,8 @@ class DrawAction: public Interruptible {
DrawAction(int id, Player * _player, int _nbcards);
};
class ActionStack :public GuiLayer{
class ActionStack: public GuiLayer
{
protected:
JQuad * pspIcons[8];
GameObserver* game;
@@ -192,8 +231,4 @@ class ActionStack :public GuiLayer{
};
#endif
+2 -1
View File
@@ -23,7 +23,8 @@ enum ENUM_COMPARISON_MODES
COMPARISON_UNEQUAL
};
class CardDescriptor: public MTGCardInstance{
class CardDescriptor: public MTGCardInstance
{
protected:
MTGCardInstance * match_or(MTGCardInstance * card);
MTGCardInstance * match_and(MTGCardInstance * card);
+4 -3
View File
@@ -7,7 +7,8 @@ class TargetChooser;
class MTGGameZone;
class MTGCardInstance;
class CardDisplay:public PlayGuiObjectController{
class CardDisplay: public PlayGuiObjectController
{
int mId;
GameObserver* game;
public:
@@ -16,7 +17,8 @@ class CardDisplay:public PlayGuiObjectController{
TargetChooser * tc;
JGuiListener * listener;
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 rotateLeft();
void rotateRight();
@@ -28,7 +30,6 @@ class CardDisplay:public PlayGuiObjectController{
virtual ostream& toString(ostream& out) const;
};
std::ostream& operator<<(std::ostream& out, const CardDisplay& m);
#endif
-1
View File
@@ -18,5 +18,4 @@ class CardEffect : public Effect
virtual void Render();
};
#endif // _CARDEFFECT_H_
+19 -8
View File
@@ -16,14 +16,15 @@ namespace DrawMode
{
enum
{
kNormal = 0,
kNormal,
kText,
kHidden
};
const int kNumDrawModes = 3;
}
struct CardGui : public PlayGuiObject {
struct CardGui: public PlayGuiObject
{
protected:
/*
@@ -54,11 +55,12 @@ struct CardGui : public PlayGuiObject {
virtual ostream& toString(ostream&) const;
};
class CardView : public CardGui {
class CardView: public CardGui
{
public:
typedef enum {
typedef enum
{
nullZone, handZone, playZone
} SelectorZone;
@@ -69,15 +71,24 @@ class CardView : public CardGui {
CardView(const SelectorZone, MTGCardInstance* card, const Pos& ref);
virtual ~CardView();
void Render(){CardGui::Render();};
void Render(JQuad* q){Pos::Render(q);};
void Render()
{
CardGui::Render();
}
;
void Render(JQuad* q)
{
Pos::Render(q);
}
;
virtual ostream& toString(ostream&) const;
float GetCenterX();
float GetCenterY();
};
class TransientCardView : public CardGui {
class TransientCardView: public CardGui
{
public:
TransientCardView(MTGCardInstance* card, float x, float y);
TransientCardView(MTGCardInstance* card, const Pos& ref);
+2 -3
View File
@@ -1,7 +1,6 @@
#ifndef _CARDPRIMITIVE_H_
#define _CARDPRIMITIVE_H_
#include <string>
#include <vector>
#include <map>
@@ -10,7 +9,8 @@
using namespace std;
class CardPrimitive {
class CardPrimitive
{
protected:
vector<string> ftdText;
string lcname;
@@ -77,5 +77,4 @@ class CardPrimitive {
const vector<string>& formattedText();
};
#endif
+5 -2
View File
@@ -24,7 +24,11 @@ class CardSelectorBase : public GuiLayer
{
public:
CardSelectorBase(int inDrawMode = DrawMode::kNormal) : mDrawMode(inDrawMode) {};
CardSelectorBase(int inDrawMode = DrawMode::kNormal) :
mDrawMode(inDrawMode)
{
}
;
virtual void Add(PlayGuiObject*) = 0;
virtual void Remove(PlayGuiObject*) = 0;
virtual bool CheckUserInput(JButton key) = 0;
@@ -43,7 +47,6 @@ protected:
int mDrawMode;
};
class CardSelector: public CardSelectorBase
{
public:
@@ -26,5 +26,4 @@ namespace CardSelectorSingleton
void Terminate();
}
#endif //CARDSELECTORSINGLETON_H
+4 -4
View File
@@ -2,12 +2,12 @@
#define _COUNTERS_H_
#include <string>
using std::string;
class MTGCardInstance;
/* One family of counters. Ex : +1/+1 */
class Counter{
class Counter
{
public:
string name;
int nb;
@@ -23,7 +23,8 @@ class Counter{
};
/* Various families of counters attached to an instance of a card */
class Counters{
class Counters
{
public:
int mCount;
Counter * counters[10];
@@ -40,5 +41,4 @@ class Counters{
int init();
};
#endif
+4 -4
View File
@@ -1,7 +1,6 @@
#ifndef _CREDITS_H_
#define _CREDITS_H_
#include <vector>
#include <string>
#include <JGE.h>
@@ -13,8 +12,8 @@ class GameApp;
using namespace std;
class CreditBonus{
class CreditBonus
{
public:
int value;
string text;
@@ -22,7 +21,8 @@ public:
void Render(float x, float y, WFont * font);
};
class Credits{
class Credits
{
private:
time_t gameLength;
int isDifficultyUnlocked(DeckStats * stats);
+39 -11
View File
@@ -17,7 +17,8 @@ class GameObserver;
#define DAMAGE_COMBAT 1
#define DAMAGE_OTHER 2
class Damageable:public Targetable {
class Damageable: public Targetable
{
protected:
public:
int life;
@@ -25,16 +26,43 @@ class Damageable:public Targetable {
int damageCount;
int preventable;
int type_as_damageable;
Damageable(int _life){life=_life;};
int getLife(){return life;};
virtual int dealDamage(int damage){life-=damage;return life;};
virtual int afterDamage(){return 0;}
virtual int poisoned(){return 0;}
virtual int prevented(){return 0;}
virtual JQuad * getIcon(){return NULL;};
Damageable(int _life)
{
life = _life;
}
;
int getLife()
{
return life;
}
;
virtual int dealDamage(int damage)
{
life -= damage;
return life;
}
;
virtual int afterDamage()
{
return 0;
}
virtual int poisoned()
{
return 0;
}
virtual int prevented()
{
return 0;
}
virtual JQuad * getIcon()
{
return NULL;
}
;
};
class Damage: public Interruptible {
class Damage: public Interruptible
{
protected:
void init(MTGCardInstance * source, Damageable * target, int damage, int typeOfDamage);
public:
@@ -48,8 +76,8 @@ class Damage: public Interruptible {
virtual ostream& toString(ostream& out) const;
};
class DamageStack : public GuiLayer, public Interruptible{
class DamageStack: public GuiLayer, public Interruptible
{
protected:
int currentState;
GameObserver* game;
+4 -2
View File
@@ -6,7 +6,8 @@
class Player;
struct DamagerDamaged : TransientCardView {
struct DamagerDamaged: TransientCardView
{
bool show;
Player * damageSelecter;
vector<Damage> damages;
@@ -26,7 +27,8 @@ struct DamagerDamaged : TransientCardView {
};
typedef DamagerDamaged DefenserDamaged;
struct AttackerDamaged : DamagerDamaged {
struct AttackerDamaged: DamagerDamaged
{
vector<DefenserDamaged*> blockers;
AttackerDamaged(MTGCardInstance* card, float x, float y, bool show, Player* damageSelecter);
AttackerDamaged(MTGCardInstance* card, const Pos& ref, bool show, Player* damageSelecter);
+14 -3
View File
@@ -12,12 +12,23 @@ using std::string;
class MTGDeck;
class DeckDataWrapper: public WSrcDeck {
class DeckDataWrapper: public WSrcDeck
{
public:
MTGDeck * parent;
DeckDataWrapper(MTGDeck * deck);
bool next() {currentPos++; return true;};
bool prev() {currentPos--; return true;};
bool next()
{
currentPos++;
return true;
}
;
bool prev()
{
currentPos--;
return true;
}
;
void save();
void save(string filepath, bool useExpandedCardNames, string &deckTitle, string &deckDesc);
};
+1 -2
View File
@@ -3,8 +3,7 @@
#include "DeckDataWrapper.h"
#include "DeckStats.h"
class DeckEditorMenu :
public DeckMenu
class DeckEditorMenu: public DeckMenu
{
protected:
string deckTitle;
-3
View File
@@ -5,7 +5,6 @@
using namespace std;
class DeckManager
{
private:
@@ -18,7 +17,6 @@ private:
public:
vector<DeckMetaData *> playerDeckOrderList;
vector<DeckMetaData *> aiDeckOrderList;
@@ -34,7 +32,6 @@ public:
static int getDifficultyRating(Player *statsPlayer, Player *player);
~DeckManager()
{
instanceFlag = false;
+8 -3
View File
@@ -56,15 +56,20 @@ public:
JQuad * pspIcons[8];
JTexture * pspIconsTexture;
DeckMenu(int id, JGuiListener* listener, int fontId, const string _title = "", const int& startIndex = 0, bool alwaysShowDetailsButton = false);
~DeckMenu();
DeckMetaData * getSelectedDeck();
void enableDisplayDetailsOverride();
bool showDetailsScreen();
bool isClosed() { return mClosed; }
int getSelectedDeckId() { return mSelectedDeckId; }
bool isClosed()
{
return mClosed;
}
int getSelectedDeckId()
{
return mSelectedDeckId;
}
void Render();
void Update(float dt);
+15 -3
View File
@@ -31,8 +31,14 @@ public:
void Relocate(float x, float y);
float GetWidth();
string GetText() { return mText; }
string GetDescription() { return desc; }
string GetText()
{
return mText;
}
string GetDescription()
{
return desc;
}
bool hasFocus();
DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus = false, bool autoTranslate = false, DeckMetaData *meta = NULL);
@@ -45,7 +51,13 @@ public:
virtual bool Leaving(JButton key);
virtual bool ButtonPressed();
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
+4 -4
View File
@@ -6,7 +6,6 @@
#include <map>
#include "DeckStats.h"
using namespace std;
enum DECK_DIFFICULTY
{
@@ -15,7 +14,8 @@ enum DECK_DIFFICULTY
EASY = 1
};
class DeckMetaData {
class DeckMetaData
{
private:
string _filename;
@@ -51,7 +51,8 @@ public:
};
class DeckMetaDataList {
class DeckMetaDataList
{
private:
map<string, DeckMetaData *> values;
@@ -61,7 +62,6 @@ public:
~DeckMetaDataList();
static DeckMetaDataList * decksMetaData;
};
#endif
+2 -2
View File
@@ -15,7 +15,8 @@ class GuiAvatars;
class CardSelectorBase;
struct Pos;
class DuelLayers {
class DuelLayers
{
protected:
int nbitems;
vector<GuiLayer*> objects;
@@ -52,5 +53,4 @@ public:
#include "ActionStack.h"
#include "Damage.h"
#endif
+36 -16
View File
@@ -9,7 +9,8 @@ class TargetChooser;
class MTGCardInstance;
class MTGAbility;
class ExtraCost{
class ExtraCost
{
public:
TargetChooser * tc;
MTGCardInstance * source;
@@ -19,15 +20,22 @@ public:
ExtraCost(const std::string& inCostRenderString, TargetChooser *_tc = NULL);
virtual ~ExtraCost();
virtual int setPayment(MTGCardInstance * card);
virtual int isPaymentSet() { return (target != NULL); }
virtual int canPay() { return 1; }
virtual int isPaymentSet()
{
return (target != NULL);
}
virtual int canPay()
{
return 1;
}
virtual int doPay() = 0;
virtual void Render();
virtual int setSource(MTGCardInstance * _source);
virtual ExtraCost* clone() const = 0;
};
class ExtraCosts{
class ExtraCosts
{
public:
vector<ExtraCost *> costs;
MTGCardInstance * source;
@@ -45,7 +53,8 @@ public:
ExtraCosts * clone() const;
};
class SacrificeCost: public ExtraCost{
class SacrificeCost: public ExtraCost
{
public:
SacrificeCost(TargetChooser *_tc = NULL);
virtual int doPay();
@@ -53,7 +62,8 @@ public:
};
//life cost
class LifeCost: public ExtraCost{
class LifeCost: public ExtraCost
{
public:
LifeCost(TargetChooser *_tc = NULL);
@@ -62,7 +72,8 @@ public:
};
//Discard a random card cost
class DiscardRandomCost: public ExtraCost{
class DiscardRandomCost: public ExtraCost
{
public:
DiscardRandomCost(TargetChooser *_tc = NULL);
virtual int canPay();
@@ -71,7 +82,8 @@ public:
};
//a choosen discard
class DiscardCost: public ExtraCost{
class DiscardCost: public ExtraCost
{
public:
DiscardCost(TargetChooser *_tc = NULL);
virtual int doPay();
@@ -79,7 +91,8 @@ public:
};
//tolibrary cost
class ToLibraryCost: public ExtraCost{
class ToLibraryCost: public ExtraCost
{
public:
ToLibraryCost(TargetChooser *_tc = NULL);
virtual int doPay();
@@ -87,7 +100,8 @@ public:
};
//Millyourself cost
class MillCost: public ExtraCost{
class MillCost: public ExtraCost
{
public:
MillCost(TargetChooser *_tc = NULL);
virtual int canPay();
@@ -96,14 +110,16 @@ public:
};
//Mill to exile yourself cost
class MillExileCost: public MillCost{
class MillExileCost: public MillCost
{
public:
MillExileCost(TargetChooser *_tc = NULL);
virtual int doPay();
};
//tap other cost
class TapTargetCost: public ExtraCost{
class TapTargetCost: public ExtraCost
{
public:
TapTargetCost(TargetChooser *_tc = NULL);
virtual int doPay();
@@ -111,7 +127,8 @@ public:
};
//exile as cost
class ExileTargetCost: public ExtraCost{
class ExileTargetCost: public ExtraCost
{
public:
ExileTargetCost(TargetChooser *_tc = NULL);
virtual int doPay();
@@ -119,7 +136,8 @@ public:
};
//bounce cost
class BounceTargetCost: public ExtraCost{
class BounceTargetCost: public ExtraCost
{
public:
BounceTargetCost(TargetChooser *_tc = NULL);
virtual int doPay();
@@ -127,7 +145,8 @@ public:
};
//bounce cost
class Ninja: public ExtraCost{
class Ninja: public ExtraCost
{
public:
Ninja(TargetChooser *_tc = NULL);
virtual int isPaymentSet();
@@ -135,7 +154,8 @@ public:
virtual Ninja * clone() const;
};
class CounterCost: public ExtraCost{
class CounterCost: public ExtraCost
{
public:
Counter * counter;
int hasCounters;
-7
View File
@@ -4,10 +4,6 @@
* http://wololo.net/wagic/
*/
#ifndef _GAMEAPP_H_
#define _GAMEAPP_H_
@@ -59,11 +55,9 @@ class GameApp: public JApp
GameState* mGameStates[GAME_STATE_MAX];
public:
int gameType;
CardEffect *effect;
GameApp();
virtual ~GameApp();
@@ -74,7 +68,6 @@ class GameApp: public JApp
virtual void Pause();
virtual void Resume();
void LoadGameStates();
void SetNextState(int state);
void DoTransition(int trans, int tostate, float dur = -1, bool animonly = false);
+2 -1
View File
@@ -22,7 +22,8 @@ class TargetChooser;
class Rules;
using namespace std;
class GameObserver{
class GameObserver
{
protected:
static GameObserver * mInstance;
MTGCardInstance * cardWaitingForTargets;
+126 -38
View File
@@ -23,10 +23,12 @@ class WStyle;
class StyleManager;
class Player;
class Options {
class Options
{
public:
friend class GameSettings;
enum {
enum
{
//Global settings
ACTIVE_PROFILE,
LANG,
@@ -80,7 +82,8 @@ public:
RANDOMDECK_MODE_UNLOCKED,
AWARD_COLLECTOR,
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[];
};
class GameOption {
class GameOption
{
public:
virtual ~GameOption() {};
virtual ~GameOption()
{
}
;
int number;
string str;
//All calls to asColor should include a fallback color for people without a theme.
@@ -112,14 +119,16 @@ public:
GameOption(int, string);
};
struct EnumDefinition {
struct EnumDefinition
{
int findIndex(int value);
typedef pair<int, string> assoc;
vector<assoc> values;
};
class GameOptionEnum: public GameOption {
class GameOptionEnum: public GameOption
{
public:
virtual string menuStr();
virtual bool write(std::ofstream * file, string name);
@@ -127,7 +136,8 @@ public:
EnumDefinition * def;
};
class GameOptionAward: public GameOption {
class GameOptionAward: public GameOption
{
public:
GameOptionAward();
virtual string menuStr();
@@ -135,82 +145,142 @@ public:
virtual bool read(string input);
virtual bool giveAward(); //Returns false if already awarded
virtual bool isViewed();
virtual void setViewed(bool v = true) {viewed = v;};
virtual void setViewed(bool v = true)
{
viewed = v;
}
;
private:
time_t achieved; //When was it awarded?
bool viewed; //Flag it as "New!" or not.
};
class GameOptionKeyBindings : public GameOption {
class GameOptionKeyBindings: public GameOption
{
virtual bool read(string input);
virtual bool write(std::ofstream*, string);
};
class OptionVolume: public EnumDefinition{
class OptionVolume: public EnumDefinition
{
public:
enum { MUTE = 0, MAX = 100 };
static EnumDefinition * getInstance() {return &mDef;};
enum
{
MUTE = 0, MAX = 100
};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private:
OptionVolume();
static OptionVolume mDef;
};
class OptionClosedHand: public EnumDefinition {
class OptionClosedHand: public EnumDefinition
{
public:
enum { INVISIBLE = 0, VISIBLE = 1 };
static EnumDefinition * getInstance() {return &mDef;};
enum
{
INVISIBLE = 0, VISIBLE = 1
};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private:
OptionClosedHand();
static OptionClosedHand mDef;
};
class OptionHandDirection: public EnumDefinition {
class OptionHandDirection: public EnumDefinition
{
public:
enum { VERTICAL = 0, HORIZONTAL = 1};
static EnumDefinition * getInstance() {return &mDef;};
enum
{
VERTICAL = 0, HORIZONTAL = 1
};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private:
OptionHandDirection();
static OptionHandDirection mDef;
};
class OptionManaDisplay: public EnumDefinition {
class OptionManaDisplay: public EnumDefinition
{
public:
enum { DYNAMIC = 0, STATIC = 1, NOSTARSDYNAMIC = 2, BOTH = 3};
static EnumDefinition * getInstance() {return &mDef;};
enum
{
DYNAMIC = 0, STATIC = 1, NOSTARSDYNAMIC = 2, BOTH = 3
};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private:
OptionManaDisplay();
static OptionManaDisplay mDef;
};
class OptionMaxGrade: public EnumDefinition {
class OptionMaxGrade: public EnumDefinition
{
public:
static EnumDefinition * getInstance() {return &mDef;};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private:
OptionMaxGrade();
static OptionMaxGrade mDef;
};
class OptionASkipPhase: public EnumDefinition {
class OptionASkipPhase: public EnumDefinition
{
public:
static EnumDefinition * getInstance() {return &mDef;};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private:
OptionASkipPhase();
static OptionASkipPhase mDef;
};
class OptionEconDifficulty: public EnumDefinition {
class OptionEconDifficulty: public EnumDefinition
{
public:
static EnumDefinition * getInstance() {return &mDef;};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private:
OptionEconDifficulty();
static OptionEconDifficulty mDef;
};
class OptionDifficulty: public EnumDefinition {
class OptionDifficulty: public EnumDefinition
{
public:
enum { NORMAL = 0, HARD = 1, HARDER = 2, EVIL = 3};
static EnumDefinition * getInstance() {return &mDef;};
enum
{
NORMAL = 0, HARD = 1, HARDER = 2, EVIL = 3
};
static EnumDefinition * getInstance()
{
return &mDef;
}
;
private:
OptionDifficulty();
static OptionDifficulty mDef;
};
class GameOptions {
class GameOptions
{
public:
string mFilename;
int save();
@@ -226,20 +296,38 @@ class GameOptions {
vector<string> unknown;
};
class GameSettings{
class GameSettings
{
public:
friend class GameApp;
GameSettings();
~GameSettings();
int save();
SimplePad * keypadStart(string input, string * _dest = NULL, bool _cancel=true, bool _numpad=false, int _x = SCREEN_WIDTH/2, int _y = SCREEN_HEIGHT/2);
SimplePad * keypadStart(string input, string * _dest = NULL, bool _cancel = true, bool _numpad = false, int _x = SCREEN_WIDTH
/ 2, int _y = SCREEN_HEIGHT / 2);
string keypadFinish();
void keypadShutdown();
void keypadTitle(string set);
bool keypadActive() {if(keypad) return keypad->isActive(); return false;};
void keypadUpdate(float dt) {if(keypad) keypad->Update(dt);};
void keypadRender() {if(keypad) keypad->Render();};
bool keypadActive()
{
if (keypad)
return keypad->isActive();
return false;
}
;
void keypadUpdate(float dt)
{
if (keypad)
keypad->Update(dt);
}
;
void keypadRender()
{
if (keypad)
keypad->Render();
}
;
bool newAward();
@@ -149,5 +149,4 @@ public:
virtual void ButtonPressed(int controllerId, int controlId);
};
#endif
+6 -4
View File
@@ -10,13 +10,16 @@ class WGuiTabMenu;
class SimpleMenu;
class SimplePad;
struct KeybGrabber {
struct KeybGrabber
{
virtual void KeyPressed(LocalKeySym) = 0;
};
class GameStateOptions: public GameState, public JGuiListener {
class GameStateOptions: public GameState, public JGuiListener
{
private:
enum {
enum
{
SHOW_OPTIONS,
SHOW_OPTIONS_MENU,
SAVE
@@ -45,5 +48,4 @@ private:
};
#endif
+6 -5
View File
@@ -11,7 +11,6 @@
#include "DeckDataWrapper.h"
#include "Tasks.h"
#define STATE_BUY 1
#define STATE_SELL 2
#define STAGE_SHOP_MENU 3
@@ -30,13 +29,16 @@
class MTGPack;
class MTGPacks;
class BoosterDisplay:public CardDisplay {
class BoosterDisplay: public CardDisplay
{
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);
};
class ShopBooster{
class ShopBooster
{
public:
ShopBooster();
string getName();
@@ -118,6 +120,5 @@ class GameStateShop: public GameState, public JGuiListener
static float _x1[], _y1[], _x2[], _y2[], _x3[], _y3[], _x4[], _y4[];
};
#endif
+2 -3
View File
@@ -1,14 +1,14 @@
#ifndef _GAME_STATE_STORY_H_
#define _GAME_STATE_STORY_H_
#include "GameState.h"
#include <JGui.h>
class StoryFlow;
class SimpleMenu;
class GameStateStory: public GameState, public JGuiListener {
class GameStateStory: public GameState, public JGuiListener
{
private:
StoryFlow * flow;
SimpleMenu * menu;
@@ -25,5 +25,4 @@ private:
};
#endif
+9 -3
View File
@@ -5,14 +5,19 @@
#include <JGui.h>
#include "GameState.h"
class TransitionBase: public GameState, public JGuiListener{
class TransitionBase: public GameState, public JGuiListener
{
public:
TransitionBase(GameApp* parent, GameState* _from, GameState* _to, float duration);
~TransitionBase();
virtual void Start();
virtual void End();
virtual bool Finished() {return (mElapsed >= mDuration);};
virtual bool Finished()
{
return (mElapsed >= mDuration);
}
;
virtual void Update(float dt);
virtual void Render() = 0;
virtual void ButtonPressed(int controllerId, int controlId);
@@ -24,7 +29,8 @@ public:
bool bAnimationOnly; //Does not call start or end on subordinates.
};
class TransitionFade: public TransitionBase {
class TransitionFade: public TransitionBase
{
public:
TransitionFade(GameApp* p, GameState* f, GameState* t, float dur, bool reversed);
virtual void Render();
-1
View File
@@ -16,7 +16,6 @@ class GuiAvatars : public GuiLayer
GuiOpponentHand *opponentHand;
GuiAvatar* active;
public:
GuiAvatars();
~GuiAvatars();
+4 -4
View File
@@ -1,13 +1,13 @@
#ifndef _GUI_CARDS_CONTROLLER_H_
#define _GUI_CARDS_CONTROLLER_H_
#include "PlayGuiObjectController.h"
class GuiCardsController : public PlayGuiObjectController{
class GuiCardsController: public PlayGuiObjectController
{
public:
GuiCardsController(){};
GuiCardsController(){}
;
};
#endif
+8 -1
View File
@@ -16,7 +16,14 @@ class GuiCombat : public GuiLayer
static JTexture* ok_tex;
Pos ok, enemy_avatar;
DamagerDamaged* current;
enum { BLK, ATK, OK, NONE } cursor_pos;
enum
{
BLK,
ATK,
OK,
NONE
} cursor_pos;
CombatStep step;
void validateDamage();
void addOne(DefenserDamaged* blocker, CombatStep);
+3 -3
View File
@@ -58,8 +58,7 @@ class GuiHandSelf : public GuiHand
protected:
typedef enum
{
Open,
Closed
Open, Closed
} HandState;
HandState state;
Pos backpos;
@@ -79,7 +78,8 @@ class GuiHandSelf : public GuiHand
HandState GetState()
{
return state;
};
}
;
HandLimitor* limitor;
};
+22 -7
View File
@@ -12,7 +12,8 @@
class GameObserver;
class Player;
class GuiLayer{
class GuiLayer
{
protected:
JButton mActionButton;
public:
@@ -28,17 +29,31 @@ class GuiLayer{
GuiLayer();
virtual ~GuiLayer();
virtual void Update(float dt);
virtual bool CheckUserInput(JButton key){ return false; };
virtual bool CheckUserInput(JButton key)
{
return false;
}
int getIndexOf(JGuiObject * object);
JGuiObject * getByIndex(int index);
virtual void Render();
int empty(){
if (mCount) return 0;
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
+8 -1
View File
@@ -18,7 +18,14 @@ class ManaIcon : public Pos
float f;
float destx, desty;
public:
enum { ALIVE, WITHERING, DROPPING, DEAD } mode;
enum
{
ALIVE,
WITHERING,
DROPPING,
DEAD
} mode;
int color;
void Render();
void Update(float dt, float shift);
+8 -4
View File
@@ -12,7 +12,8 @@ class GuiPlay : public GuiLayer
typedef vector<CardView*>::iterator iterator;
protected:
class CardStack {
class CardStack
{
protected:
unsigned total;
float baseX, baseY;
@@ -24,13 +25,15 @@ class GuiPlay : public GuiLayer
void RenderSpell(MTGCardInstance*, iterator begin, iterator end, float x, float y);
};
class HorzStack : public CardStack {
class HorzStack: public CardStack
{
public:
HorzStack();
void Render(CardView*, iterator begin, iterator end);
void Enstack(CardView*);
};
class VertStack : public CardStack {
class VertStack: public CardStack
{
protected:
unsigned count;
public:
@@ -40,7 +43,8 @@ class GuiPlay : public GuiLayer
void Enstack(CardView*);
inline float nextX();
};
class BattleField : public HorzStack {
class BattleField: public HorzStack
{
static const float HEIGHT;
unsigned attackers;
unsigned blockers;
+18 -7
View File
@@ -9,15 +9,22 @@
class CardView;
struct GuiStatic : public PlayGuiObject{
struct GuiStatic: public PlayGuiObject
{
GuiAvatars* parent;
GuiStatic(float desiredHeight, float x, float y, bool hasFocus, GuiAvatars* parent);
virtual void Entering();
virtual bool Leaving(JButton key);
};
struct GuiAvatar : public GuiStatic{
typedef enum { TOP_LEFT, BOTTOM_RIGHT } Corner;
struct GuiAvatar: public GuiStatic
{
typedef enum
{
TOP_LEFT,
BOTTOM_RIGHT
} Corner;
static const unsigned Width = 35;
static const unsigned Height = 50;
@@ -33,7 +40,8 @@ struct GuiAvatar : public GuiStatic{
virtual ostream& toString(ostream& out) const;
};
struct GuiGameZone : public GuiStatic{
struct GuiGameZone: public GuiStatic
{
static const int Width = 20;
static const int Height = 25;
vector<CardView*> cards;
@@ -53,7 +61,8 @@ struct GuiGameZone : public GuiStatic{
virtual ostream& toString(ostream& out) const;
};
//opponenthand
class GuiOpponentHand: public GuiGameZone{
class GuiOpponentHand: public GuiGameZone
{
public:
Player * player;
GuiOpponentHand(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* Parent);
@@ -62,7 +71,8 @@ public:
virtual ostream& toString(ostream& out) const;
};
//end of my addition
class GuiGraveyard: public GuiGameZone{
class GuiGraveyard: public GuiGameZone
{
public:
Player * player;
GuiGraveyard(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* parent);
@@ -71,7 +81,8 @@ class GuiGraveyard: public GuiGameZone{
virtual ostream& toString(ostream& out) const;
};
class GuiLibrary: public GuiGameZone{
class GuiLibrary: public GuiGameZone
{
public:
Player * player;
GuiLibrary(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* parent);
+80 -25
View File
@@ -22,7 +22,6 @@ class Counter;
using std::string;
using std::map;
//stupid variables used to give a hint to the AI:
// Should I cast a spell on an enemy or friendly unit ?
#define BAKA_EFFECT_GOOD 1
@@ -63,14 +62,30 @@ public:
MTGAbility(int id, MTGCardInstance* _source, Targetable* _target);
virtual int testDestroy();
virtual ~MTGAbility();
virtual void Render(){};
virtual int isReactingToClick(MTGCardInstance* card, ManaCost* mana = NULL){return 0;};
virtual int reactToClick(MTGCardInstance* card){return 0;};
virtual int receiveEvent(WEvent* event){return 0;};
virtual void Render() {}
virtual int isReactingToClick(MTGCardInstance* card, ManaCost* mana = NULL)
{
return 0;
}
;
virtual int reactToClick(MTGCardInstance* card)
{
return 0;
}
;
virtual int receiveEvent(WEvent* event)
{
return 0;
}
;
virtual void Update(float dt) {};
virtual int fireAbility();
virtual int stillInUse(MTGCardInstance* card);
virtual int resolve(){return 0;};
virtual int resolve()
{
return 0;
}
;
virtual MTGAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const;
virtual int addToGame();
@@ -122,20 +137,29 @@ public:
TriggeredAbility(int id, MTGCardInstance* card);
TriggeredAbility(int id, MTGCardInstance* _source, Targetable* _target);
virtual void Update(float dt);
virtual void Render(){};
virtual int trigger(){return 0;};
virtual int triggerOnEvent(WEvent* e){return 0;};
virtual void Render() {}
;
virtual int trigger()
{
return 0;
}
;
virtual int triggerOnEvent(WEvent* e)
{
return 0;
}
;
int receiveEvent(WEvent* e);
virtual int resolve() = 0;
virtual TriggeredAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const;
};
class ActivatedAbility: public MTGAbility
{
public:
enum {
enum
{
NO_RESTRICTION = 0,
PLAYER_TURN_ONLY = 1,
AS_SORCERY = 2,
@@ -223,7 +247,11 @@ public:
virtual int testDestroy();
InstantAbility(int _id, MTGCardInstance* source);
InstantAbility(int _id, MTGCardInstance* source, Damageable* _target);
virtual int resolve(){return 0;};
virtual int resolve()
{
return 0;
}
;
virtual InstantAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const;
};
@@ -234,18 +262,39 @@ class ListMaintainerAbility:public MTGAbility
public:
map<MTGCardInstance *, bool> cards;
map<Player *, bool> players;
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) : MTGAbility(_id, NULL)
{
}
;
ListMaintainerAbility(int _id, MTGCardInstance *_source) : MTGAbility(_id, _source)
{
}
;
ListMaintainerAbility(int _id, MTGCardInstance *_source, Damageable* _target) : MTGAbility(_id, _source, _target)
{
}
;
virtual void Update(float dt);
void updateTargets();
virtual bool canTarget(MTGGameZone* zone);
virtual int canBeInList(MTGCardInstance* card) = 0;
virtual int added(MTGCardInstance* card) = 0;
virtual int removed(MTGCardInstance* card) = 0;
virtual int canBeInList(Player* p){return 0;};
virtual int added(Player* p){return 0;};
virtual int removed(Player* p){return 0;};
virtual int canBeInList(Player* p)
{
return 0;
}
;
virtual int added(Player* p)
{
return 0;
}
;
virtual int removed(Player* p)
{
return 0;
}
;
virtual int destroy();
virtual ListMaintainerAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const;
@@ -258,7 +307,11 @@ public:
int who;
TriggerAtPhase(int id, MTGCardInstance* source, Targetable* target, int _phaseId, int who = 0);
virtual int trigger();
int resolve(){return 0;};
int resolve()
{
return 0;
}
;
virtual TriggerAtPhase* clone() const;
};
@@ -272,14 +325,14 @@ public:
};
class GenericTriggeredAbility: public TriggeredAbility, public NestedAbility
{
public:
TriggeredAbility* t;
queue<Targetable *> targets;
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 triggerOnEvent(WEvent* e);
virtual int resolve();
@@ -308,10 +361,12 @@ public:
Counter* parseCounter(string s, MTGCardInstance* target, Spell* spell = NULL);
int parsePowerToughness(string s, int* power, int* toughness);
int getAbilities(vector<MTGAbility *>* v, Spell* spell, MTGCardInstance* card = NULL, int id = 0, MTGGameZone* dest = NULL);
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 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 computeXX(Spell* spell, MTGCardInstance* card);
static MTGAbility* getCoreAbility(MTGAbility* a);
@@ -323,12 +378,12 @@ public:
void addAbilities(int _id, Spell* spell);
};
class ActivatedAbilityTP: public ActivatedAbility
{
public:
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();
};
+2 -4
View File
@@ -17,7 +17,8 @@ class CardPrimitive;
using namespace std;
class MTGCard {
class MTGCard
{
protected:
friend class MTGSetInfo;
int mtgid;
@@ -44,7 +45,4 @@ class MTGCard {
char * getImageName();
};
#endif
+6 -6
View File
@@ -10,7 +10,6 @@
#include "Damage.h"
#include "Targetable.h"
class MTGCardInstance;
class MTGPlayerCards;
class MTGAbility;
@@ -24,7 +23,8 @@ struct Pos;
#include <list>
using namespace std;
class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable
{
protected:
int untapping;
int nb_damages;
@@ -72,11 +72,13 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
MTGCardInstance * changeController(Player * newcontroller);
Player * owner;
Counters * counters;
int typeAsTarget(){return TARGET_CARD;}
int typeAsTarget()
{
return TARGET_CARD;
}
const string getDisplayName() const;
MTGCardInstance * target;
//types
void addType(char * type_text);
virtual void addType(int id);
@@ -123,7 +125,6 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
int bury();
int destroy();
int addToToughness(int value);
int setToughness(int value);
@@ -168,5 +169,4 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
ostream& operator<<(ostream&, const MTGCardInstance&);
#endif
+17 -13
View File
@@ -7,7 +7,6 @@
#include "GameApp.h"
#include "WResourceManager.h"
#include <string>
using std::string;
@@ -15,7 +14,8 @@ class GameApp;
class MTGCard;
class CardPrimitive;
class MTGPack;
class MTGSetInfo{
class MTGSetInfo
{
public:
MTGSetInfo(string _id);
~MTGSetInfo();
@@ -33,7 +33,8 @@ public:
string getBlock();
void processConfLine(string line);
enum {
enum
{
//For memoized counts
LAND = 0,
COMMON = 1,
@@ -51,15 +52,16 @@ public:
int counts[MTGSetInfo::MAX_COUNT];
};
class MTGSets{
class MTGSets
{
public:
//These values have to be < 0
// 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...)
enum {
INTERNAL_SET = -1,
ALL_SETS = -2,
enum
{
INTERNAL_SET = -1, ALL_SETS = -2,
};
friend class MTGSetInfo;
@@ -86,7 +88,8 @@ protected:
extern MTGSets setlist;
class MTGAllCards {
class MTGAllCards
{
private:
MTGCard * tempCard; //used by parser
CardPrimitive * tempPrimitive; //used by parser
@@ -99,7 +102,8 @@ private:
void init();
void initCounters();
public:
enum {
enum
{
READ_ANYTHING = 0,
READ_CARD = 1,
READ_METADATA = 2,
@@ -126,8 +130,8 @@ private:
CardPrimitive * addPrimitive(CardPrimitive * primitive, MTGCard * card = NULL);
};
class MTGDeck{
class MTGDeck
{
protected:
string filename;
int total_cards;
@@ -141,7 +145,8 @@ class MTGDeck{
int totalPrice();
MTGDeck(MTGAllCards * _allcards);
MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only = 0);
int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const char * subtype = NULL, int * colors = NULL, int nbcolors = 0);
int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const char * subtype = NULL,
int * colors = NULL, int nbcolors = 0);
int add(int cardid);
int add(MTGDeck * deck); // adds the contents of "deck" into myself
int complete();
@@ -155,5 +160,4 @@ class MTGDeck{
};
#endif
-5
View File
@@ -17,7 +17,6 @@ class Constants
const static int PARSER_KEYWORD_NOT_MATCHED = 2000;
const static int PARSER_INVALID_KEYWORD = 3000;
// color constants
static const string kManaColorless;
static const string kManaGreen;
@@ -50,7 +49,6 @@ class Constants
MTG_NB_COLORS = 7,
MTG_UNCOLORED = 0,
MTG_FOREST = 1,
MTG_ISLAND = 2,
@@ -58,7 +56,6 @@ class Constants
MTG_SWAMP = 4,
MTG_PLAIN = 5,
MTG_TYPE_CREATURE = 10,
MTG_TYPE_ARTIFACT = 11,
MTG_TYPE_ENCHANTMENT = 12,
@@ -66,7 +63,6 @@ class Constants
MTG_TYPE_LAND = 14,
MTG_TYPE_INSTANT = 15,
MTG_PHASE_BEFORE_BEGIN = 0,
MTG_PHASE_UNTAP = 1,
MTG_PHASE_UPKEEP = 2,
@@ -172,7 +168,6 @@ class Constants
NB_BASIC_ABILITIES = 84,
RARITY_S = 'S', //Special Rarity
RARITY_M = 'M', //Mythics
RARITY_R = 'R', //Rares
+2 -3
View File
@@ -7,8 +7,8 @@
#include <JGui.h>
#include "WFont.h"
class MTGGamePhase: public ActionElement {
class MTGGamePhase: public ActionElement
{
protected:
float animation;
int currentState;
@@ -21,5 +21,4 @@ class MTGGamePhase: public ActionElement {
virtual ostream& toString(ostream& out) const;
};
#endif
+47 -17
View File
@@ -14,12 +14,14 @@ class MTGDeck;
class MTGCardInstance;
class Player;
class MTGGameZone {
class MTGGameZone
{
protected:
public:
enum{
enum
{
ALL_ZONES = -1,
MY_GRAVEYARD = 11,
@@ -91,51 +93,79 @@ class MTGGameZone {
static int zoneStringToId(string zoneName);
static MTGGameZone *intToZone(int zoneId, MTGCardInstance * source = NULL, MTGCardInstance * target = NULL);
bool needShuffle;
virtual const char * getName(){return "zone";};
virtual const char * getName()
{
return "zone";
}
;
virtual ostream& toString(ostream&) const;
};
class MTGLibrary: public MTGGameZone {
class MTGLibrary: public MTGGameZone
{
public:
void shuffleTopToBottom(int nbcards);
virtual ostream& toString(ostream&) const;
const char * getName(){return "library";}
const char * getName()
{
return "library";
}
};
class MTGGraveyard: public MTGGameZone {
class MTGGraveyard: public MTGGameZone
{
public:
virtual ostream& toString(ostream&) const;
const char * getName(){return "graveyard";}
const char * getName()
{
return "graveyard";
}
};
class MTGHand: public MTGGameZone {
class MTGHand: public MTGGameZone
{
public:
virtual ostream& toString(ostream&) const;
const char * getName(){return "hand";}
const char * getName()
{
return "hand";
}
};
class MTGRemovedFromGame: public MTGGameZone {
class MTGRemovedFromGame: public MTGGameZone
{
public:
virtual ostream& toString(ostream&) const;
const char * getName(){return "exile";}
const char * getName()
{
return "exile";
}
};
class MTGStack: public MTGGameZone {
class MTGStack: public MTGGameZone
{
public:
virtual ostream& toString(ostream&) const;
const char * getName(){return "stack";}
const char * getName()
{
return "stack";
}
};
class MTGInPlay: public MTGGameZone {
class MTGInPlay: public MTGGameZone
{
public:
void untapAll();
MTGCardInstance * getNextAttacker(MTGCardInstance * previous);
virtual ostream& toString(ostream&) const;
const char * getName(){return "battlefield";}
const char * getName()
{
return "battlefield";
}
};
class MTGPlayerCards {
class MTGPlayerCards
{
protected:
void init();
+69 -17
View File
@@ -3,32 +3,54 @@
class ShopBooster;
class MTGPackEntry{
class MTGPackEntry
{
public:
virtual ~MTGPackEntry() {};
virtual ~MTGPackEntry()
{
}
;
virtual int addCard(WSrcCards * pool, MTGDeck * to) = 0;
int copies;
};
class MTGPackEntryRandom: public MTGPackEntry{
class MTGPackEntryRandom: public MTGPackEntry
{
public:
MTGPackEntryRandom() {filter = ""; copies=1;};
MTGPackEntryRandom(string f, int c=1) {filter = f; copies = c;};
MTGPackEntryRandom()
{
filter = "";
copies = 1;
}
;
MTGPackEntryRandom(string f, int c = 1)
{
filter = f;
copies = c;
}
;
int addCard(WSrcCards * pool, MTGDeck * to);
string filter;
};
class MTGPackEntrySpecific: public MTGPackEntry{
class MTGPackEntrySpecific: public MTGPackEntry
{
public:
int addCard(WSrcCards * pool, MTGDeck * to);
MTGCard * card;
};
class MTGPackEntryNothing: public MTGPackEntry{
class MTGPackEntryNothing: public MTGPackEntry
{
public:
int addCard(WSrcCards * pool,MTGDeck * to) {return 0;};
int addCard(WSrcCards * pool, MTGDeck * to)
{
return 0;
}
;
};
class MTGPackSlot{
class MTGPackSlot
{
public:
~MTGPackSlot();
int add(WSrcCards * ocean, MTGDeck * to, int carryover);
@@ -38,23 +60,48 @@ public:
vector<MTGPackEntry*> entries;
};
class MTGPack{
class MTGPack
{
public:
friend class MTGPacks;
friend class ShopBooster;
friend class MTGSetInfo;
bool meetsRequirements(); //Check if pool contains locked cards.
bool isUnlocked();
bool isValid() {return bValid;};
bool isValid()
{
return bValid;
}
;
void load(string filename);
int assemblePack(MTGDeck * to);
MTGPack() {bValid = false; unlockStatus = 0; price=Constants::PRICE_BOOSTER;};
MTGPack(string s) {bValid = false; load(s); unlockStatus = 0;};
MTGPack()
{
bValid = false;
unlockStatus = 0;
price = Constants::PRICE_BOOSTER;
}
;
MTGPack(string s)
{
bValid = false;
load(s);
unlockStatus = 0;
}
;
~MTGPack();
string getName();
string getSort() {return sort;};
int getPrice() {return price;};
string getSort()
{
return sort;
}
;
int getPrice()
{
return price;
}
;
static WSrcCards * getPool(string poolstr);
protected:
void countCards();
@@ -72,12 +119,17 @@ protected:
vector<MTGPackSlot*> slotss;
};
class MTGPacks{
class MTGPacks
{
public:
~MTGPacks();
MTGPack * randomPack(int key = 0);
void loadAll();
int size() {return (int)packs.size();};
int size()
{
return (int) packs.size();
}
;
void refreshUnlocked();
static MTGPack * getDefault();
+6 -4
View File
@@ -4,7 +4,6 @@
#include "utils.h"
#include "MTGDefinitions.h"
class ManaCostHybrid;
class ExtraCosts;
class ExtraCost;
@@ -12,7 +11,8 @@ class MTGAbility;
class MTGCardInstance;
class Player;
class ManaCost{
class ManaCost
{
protected:
int cost[Constants::MTG_NB_COLORS + 1];
ManaCostHybrid * hybrids[10];
@@ -20,7 +20,8 @@ class ManaCost{
int extraCostsIsCopy;
public:
enum{
enum
{
MANA_UNPAID = 0,
MANA_PAID = 1,
MANA_PAID_WITH_KICKER = 2,
@@ -82,7 +83,8 @@ class ManaCost{
std::ostream& operator<<(std::ostream& out, const ManaCost& m);
class ManaPool:public ManaCost{
class ManaPool: public ManaCost
{
protected:
Player * player;
public:
+2 -1
View File
@@ -1,7 +1,8 @@
#ifndef _MANACOST_HYBRID_H_
#define _MANACOST_HYBRID_H_
class ManaCostHybrid{
class ManaCostHybrid
{
public:
int color1;
int color2;
+7 -2
View File
@@ -29,7 +29,6 @@ class MenuItem: public JGuiObject
JQuad * offQuad;
hgeParticleSystem* mParticleSys;
public:
MenuItem(int id, WFont *font, string text, float x, float y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleQuad, bool hasFocus = false);
~MenuItem();
@@ -39,7 +38,13 @@ class MenuItem: public JGuiObject
virtual void Entering();
virtual bool Leaving(JButton key);
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;
};
-1
View File
@@ -9,7 +9,6 @@
#include <map>
#include <vector>
// private class only used by Navigator, see implementation file
class CardZone;
+83 -21
View File
@@ -20,20 +20,29 @@ using std::string;
#define PATH_MAX 4096
#endif
class OptionItem: public WGuiItem{
class OptionItem: public WGuiItem
{
public:
OptionItem(int _id, string _displayValue);
virtual ~OptionItem() {};
//Accessors
virtual int getId() {return id;};
virtual void setId(int _id){id = _id;};
virtual int getId()
{
return id;
}
virtual void setId(int _id)
{
id = _id;
}
protected:
int id;
};
class OptionInteger:public OptionItem{
class OptionInteger: public OptionItem
{
public:
int value; //Current value.
int defValue; //Default value.
@@ -42,37 +51,77 @@ class OptionInteger:public OptionItem{
OptionInteger(int _id, string _displayValue, int _maxValue = 1, int _increment = 1, int _defV = 0, string _sDef = "", int _minValue = 0);
virtual void Reload() {if(id != INVALID_OPTION) value = options[id].number;};
virtual bool Changed() {return value != options[id].number;};
virtual void Reload()
{
if (id != INVALID_OPTION)
value = options[id].number;
}
virtual bool Changed()
{
return value != options[id].number;
}
virtual void Render();
virtual void setData();
virtual void updateValue(){value+=increment; if (value>maxValue) value=minValue;};
virtual void updateValue()
{
value += increment;
if (value > maxValue)
value = minValue;
}
};
class OptionSelect:public OptionItem{
class OptionSelect: public OptionItem
{
public:
size_t value;
vector<string> selections;
virtual void addSelection(string s);
OptionSelect(int _id, string _displayValue): OptionItem(_id, _displayValue) {value = 0;};
virtual void Reload(){initSelections();};
OptionSelect(int _id, string _displayValue) :
OptionItem(_id, _displayValue)
{
value = 0;
}
;
virtual void Reload()
{
initSelections();
}
;
virtual void Render();
virtual bool Selectable();
virtual void Entering(JButton key);
virtual bool Changed() {return (value != prior_value);};
virtual bool Changed()
{
return (value != prior_value);
}
virtual void setData();
virtual void initSelections();
virtual void updateValue(){value++; if (value > selections.size() - 1) value=0;};
virtual void updateValue()
{
value++;
if (value > selections.size() - 1)
value = 0;
}
;
protected:
size_t prior_value;
};
class OptionLanguage: public OptionSelect{
class OptionLanguage: public OptionSelect
{
public:
OptionLanguage(string _displayValue);
virtual void addSelection(string s) {addSelection(s,s);};
virtual void addSelection(string s)
{
addSelection(s, s);
}
;
virtual void addSelection(string s, string show);
virtual void initSelections();
virtual void confirmChange(bool confirmed);
@@ -84,14 +133,16 @@ protected:
vector<string> actual_data;
};
class OptionThemeStyle: public OptionSelect{
class OptionThemeStyle: public OptionSelect
{
public:
virtual bool Visible();
virtual void Reload();
virtual void confirmChange(bool confirmed);
OptionThemeStyle(string _displayValue);
};
class OptionDirectory:public OptionSelect{
class OptionDirectory: public OptionSelect
{
public:
virtual void Reload();
OptionDirectory(string root, int id, string displayValue, const string type);
@@ -100,7 +151,8 @@ class OptionDirectory:public OptionSelect{
const string type;
};
class OptionTheme:public OptionDirectory{
class OptionTheme: public OptionDirectory
{
private:
static const string DIRTESTER;
public:
@@ -118,14 +170,23 @@ protected:
bool bChecked;
};
class OptionProfile:public OptionDirectory{
class OptionProfile: public OptionDirectory
{
private:
static const string DIRTESTER;
public:
OptionProfile(GameApp * _app, JGuiListener * jgl);
virtual void addSelection(string s);
virtual bool Selectable() {return canSelect;};
virtual bool Changed() {return (initialValue != value);};
virtual bool Selectable()
{
return canSelect;
}
;
virtual bool Changed()
{
return (initialValue != value);
}
;
virtual void Entering(JButton key);
virtual void Reload();
virtual void Render();
@@ -141,7 +202,8 @@ private:
size_t initialValue;
};
class OptionKey : public WGuiItem, public KeybGrabber {
class OptionKey: public WGuiItem, public KeybGrabber
{
public:
OptionKey(GameStateOptions* g, LocalKeySym, JButton);
LocalKeySym from;
+20 -4
View File
@@ -11,15 +11,31 @@ using namespace std;
class Player;
typedef enum { BLOCKERS, TRIGGERS, ORDER, FIRST_STRIKE, END_FIRST_STRIKE, DAMAGE, END_DAMAGE } CombatStep;
class Phase{
typedef enum
{
BLOCKERS,
TRIGGERS,
ORDER,
FIRST_STRIKE,
END_FIRST_STRIKE,
DAMAGE,
END_DAMAGE
} CombatStep;
class Phase
{
public:
int id;
Player * player;
Phase(int id, Player *player):id(id),player(player){};
Phase(int id, Player *player) :
id(id), player(player)
{
}
;
};
class PhaseRing{
class PhaseRing
{
private:
static bool extraDamagePhase(int id);
public:
+33 -7
View File
@@ -16,7 +16,8 @@
#include "WEvent.h"
#include "Pos.h"
class PlayGuiObject: public JGuiObject, public JGuiListener, public Pos{
class PlayGuiObject: public JGuiObject, public JGuiListener, public Pos
{
protected:
public:
@@ -25,16 +26,41 @@ class PlayGuiObject: public JGuiObject, public JGuiListener, public Pos{
float defaultHeight;
bool mHasFocus;
int type;
virtual void Entering(){mHasFocus = 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 Entering()
{
mHasFocus = 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 Update(float dt);
PlayGuiObject(float desiredHeight, float x, float y, bool hasFocus);
PlayGuiObject(float desiredHeight, const Pos& ref, bool hasFocus);
virtual void ButtonPressed(int controllerId, int controlId){};
virtual bool getTopLeft(float& top, float& left) {top = actY; left = actX; return true;};
virtual void ButtonPressed(int controllerId, int controlId) {}
virtual bool getTopLeft(float& top, float& left)
{
top = actY;
left = actX;
return true;
}
;
virtual ~PlayGuiObject() {};
vector<Effect*> effects;
};
+12 -5
View File
@@ -5,7 +5,8 @@
#include "GuiLayers.h"
class PlayGuiObjectController : public GuiLayer{
class PlayGuiObjectController: public GuiLayer
{
protected:
float last_user_move;
int getClosestItem(int direction);
@@ -14,10 +15,16 @@ class PlayGuiObjectController : public GuiLayer{
public:
virtual void Update(float dt);
virtual bool CheckUserInput(JButton key);
PlayGuiObjectController(){last_user_move=0;};
virtual void Render(){GuiLayer::Render();};
PlayGuiObjectController()
{
last_user_move = 0;
}
;
virtual void Render()
{
GuiLayer::Render();
}
;
};
#endif
+3 -1
View File
@@ -19,7 +19,9 @@ protected:
public:
enum ENUM_PLAY_MODE
{
MODE_TEST_SUITE, MODE_HUMAN, MODE_AI,
MODE_TEST_SUITE,
MODE_HUMAN,
MODE_AI
};
JTexture * mAvatarTex;
+2 -1
View File
@@ -4,7 +4,8 @@
#include "MTGDeck.h"
#include "Tasks.h"
class PlayerData{
class PlayerData
{
protected:
void init();
public:
+2 -1
View File
@@ -3,7 +3,8 @@
#include "JGE.h"
struct Pos {
struct Pos
{
float actX, actY, actZ, actT, actA;
float x, y, zoom, t, alpha;
Pos(float, float, float, float, float);
+7 -2
View File
@@ -8,7 +8,8 @@
class MTGAllCards;
class PriceList{
class PriceList
{
private:
MTGAllCards * collection;
string filename;
@@ -24,7 +25,11 @@ class PriceList{
int setPrice(int cardId, int price);
int getOtherPrice(int amt);
static float difficultyScalar(float price, int cardid = 0);
static void updateKey() {randomKey = rand();};
static void updateKey()
{
randomKey = rand();
}
;
};
#endif
+12 -5
View File
@@ -9,13 +9,19 @@ using namespace std;
class TargetChooser;
class MTGAbility;
class ReplacementEffect {
class ReplacementEffect
{
public:
virtual WEvent * replace (WEvent * e) {return e;};
virtual ~ReplacementEffect(){};
virtual WEvent * replace(WEvent * e)
{
return e;
}
;
virtual ~ReplacementEffect() {}
};
class REDamagePrevention: public ReplacementEffect {
class REDamagePrevention: public ReplacementEffect
{
protected:
MTGAbility * source;
TargetChooser * tcSource;
@@ -29,7 +35,8 @@ public:
~REDamagePrevention();
};
class ReplacementEffects {
class ReplacementEffects
{
protected:
list<ReplacementEffect *> modifiers;
public:
+10 -6
View File
@@ -13,7 +13,8 @@ class MTGCardInstance;
#define MAX_RULES_CARDS 4096;
class RulesPlayerZone{
class RulesPlayerZone
{
public:
vector<int> cards;
void add(int cardid);
@@ -21,7 +22,8 @@ class RulesPlayerZone{
void cleanup();
};
class RulesPlayerData{
class RulesPlayerData
{
public:
vector<string> extraRules;
int life;
@@ -37,7 +39,8 @@ class RulesPlayerData{
};
class RulesState{
class RulesState
{
public:
int phase;
int player;
@@ -47,8 +50,8 @@ class RulesState{
void cleanup();
};
class Rules{
class Rules
{
protected:
Player * loadPlayerMomir(int isAI);
Player * loadPlayerRandom(int isAI, int mode);
@@ -56,7 +59,8 @@ protected:
MTGDeck * buildDeck(int playerId);
int strToGameMode(string s);
public:
enum {
enum
{
PARSE_UNDEFINED,
PARSE_INIT,
PARSE_PLAYER1,
+6 -3
View File
@@ -9,7 +9,8 @@
#include "WFont.h"
#include "hge/hgeparticle.h"
class SimpleMenu:public JGuiController{
class SimpleMenu: public JGuiController
{
private:
float mHeight, mWidth, mX, mY;
int fontId;
@@ -39,9 +40,11 @@ class SimpleMenu:public JGuiController{
void Close();
float selectionTargetY;
bool isClosed() { return mClosed; }
bool isClosed()
{
return mClosed;
}
static void destroy();
};
#endif
+7 -2
View File
@@ -11,7 +11,6 @@ using std::string;
#define SCALE_SELECTED 1.2f
#define SCALE_NORMAL 1.0f
class SimpleMenuItem: public JGuiObject
{
private:
@@ -41,7 +40,13 @@ class SimpleMenuItem: public JGuiObject
virtual bool Leaving(JButton key);
virtual bool ButtonPressed();
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
+9 -6
View File
@@ -19,27 +19,31 @@ enum SIMPLE_KEYS{
KPD_INPUT = 255,
};
struct SimpleKey{
struct SimpleKey
{
SimpleKey(string _ds, int _id);
string displayValue;
unsigned char id;
unsigned char adjacency[4];
};
class SimplePad{
class SimplePad
{
public:
friend class GameSettings;
string buffer;
string title;
unsigned int cursorPos();
bool isActive() {return bActive;};
bool isActive()
{
return bActive;
}
;
void Render();
void Update(float dt);
void pressKey(unsigned char id);
SimplePad();
~SimplePad();
@@ -65,5 +69,4 @@ private:
string original; //For cancelling.
};
#endif
+8 -3
View File
@@ -35,12 +35,17 @@ private:
public:
bool autoTranslate;
SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title = "", DeckMetaData* deckInfo = NULL, MTGAllCards * collection = NULL);
~SimplePopup(void);
void drawBoundingBox(float x, float y, float width, float height);
bool isClosed() { return mClosed; }
MTGAllCards* getCollection() { return mCollection; }
bool isClosed()
{
return mClosed;
}
MTGAllCards* getCollection()
{
return mCollection;
}
void Render();
void Update(DeckMetaData* deckMetaData);
+43 -18
View File
@@ -11,20 +11,36 @@ class GameObserver;
class MTGDeck;
#define CAMPAIGNS_FOLDER "campaigns/"
class StoryDialogElement:public JGuiObject {
class StoryDialogElement: public JGuiObject
{
public:
float mX;
float mY;
StoryDialogElement(float x, float y, int id = 0);
void Entering(){};
bool Leaving(JButton key) {return false;};
bool ButtonPressed() {return false;};
bool hasFocus() {return false;};
void Entering()
{
}
;
bool Leaving(JButton key)
{
return false;
}
;
bool ButtonPressed()
{
return false;
}
;
bool hasFocus()
{
return false;
}
;
virtual float getHeight() = 0;
};
class StoryText:public StoryDialogElement {
class StoryText: public StoryDialogElement
{
public:
string text;
int align;
@@ -36,7 +52,8 @@ StoryText(string text, float mX, float mY, string align = "center", int font = 0
virtual ostream& toString(ostream& out) const;
float getHeight();
};
class StoryImage:public StoryDialogElement {
class StoryImage: public StoryDialogElement
{
public:
string img;
StoryImage(string img, float mX, float mY);
@@ -46,9 +63,11 @@ StoryImage(string img, float mX, float mY);
float getHeight();
};
class StoryReward:public StoryText {
class StoryReward: public StoryText
{
public:
enum {
enum
{
STORY_REWARD_CREDITS,
STORY_REWARD_SET,
STORY_REWARD_CARD,
@@ -67,7 +86,8 @@ public:
static MTGDeck * collection;
};
class StoryChoice:public StoryText {
class StoryChoice: public StoryText
{
public:
string pageId;
@@ -87,7 +107,8 @@ public:
};
class StoryFlow;
class StoryPage {
class StoryPage
{
protected:
string safeAttribute(TiXmlElement* element, string attribute);
public:
@@ -96,11 +117,15 @@ public:
StoryPage(StoryFlow * mParent);
virtual void Update(float dt)=0;
virtual void Render()=0;
virtual ~StoryPage(){};
virtual ~StoryPage()
{
}
;
int loadElement(TiXmlElement* element);
};
class StoryDialog:public StoryPage, public JGuiListener,public JGuiController {
class StoryDialog: public StoryPage, public JGuiListener, public JGuiController
{
private:
vector<StoryDialogElement *> graphics;
void RenderElement(StoryDialogElement * elmt);
@@ -115,9 +140,9 @@ public:
static float previousY;
};
class Rules;
class StoryDuel:public StoryPage {
class StoryDuel: public StoryPage
{
public:
string pageId;
string onWin, onLose;
@@ -131,7 +156,8 @@ public:
void init();
};
class StoryFlow{
class StoryFlow
{
private:
map<string, StoryPage *> pages;
bool parse(string filename);
@@ -149,5 +175,4 @@ public:
void Render();
};
#endif
+8 -4
View File
@@ -1,4 +1,5 @@
class WStyle{
class WStyle
{
public:
friend class StyleManager;
string stylized(string filename);
@@ -6,13 +7,15 @@ protected:
map<string, string> mapping;
};
class WStyleRule{
class WStyleRule
{
public:
string filter; //The condition
string style; //The style to use.
};
class MTGDeck;
class StyleManager{
class StyleManager
{
public:
friend class OptionThemeStyle;
friend class OptionTheme;
@@ -21,7 +24,8 @@ public:
void determineActive(MTGDeck * p1, MTGDeck * p2);
WStyle * get();
protected:
int topRule; int topSize;
int topRule;
int topSize;
int playerSrc;
void loadRules();
+4 -6
View File
@@ -1,17 +1,17 @@
#ifndef _SUBTYPES_H_
#define _SUBTYPES_H_
#include <string>
#include <map>
#include <vector>
using namespace std;
class Subtypes{
class Subtypes
{
public:
//A list of commonly used types
enum {
enum
{
TYPE_CREATURE = 1,
TYPE_ENCHANTMENT = 2,
TYPE_SORCERY = 3,
@@ -22,7 +22,6 @@ public:
LAST_TYPE = TYPE_LEGENDARY,
};
protected:
map<string, int> values;
vector<string> valuesById;
@@ -34,5 +33,4 @@ public:
string find(unsigned int id);
};
#endif
+68 -31
View File
@@ -20,14 +20,14 @@ class Damageable;
class Targetable;
class CardDescriptor;
class TargetChooser: public TargetsList {
class TargetChooser: public TargetsList
{
protected:
int forceTargetListReady;
public:
enum{
enum
{
UNSET = 0,
OPPONENT = -1,
CONTROLLER = 1,
@@ -43,28 +43,53 @@ class TargetChooser: public TargetsList {
int maxtargets; //Set to -1 for "unlimited"
bool validTargetsExist();
virtual int setAllZones(){return 0;}
virtual bool targetsZone(MTGGameZone * z){return false;};
virtual int setAllZones()
{
return 0;
}
virtual bool targetsZone(MTGGameZone * z)
{
return false;
}
;
int ForceTargetListReady();
int targetsReadyCheck();
virtual int addTarget(Targetable * target);
virtual bool canTarget(Targetable * _target);
virtual int full(){if (maxtargets != -1 && cursor>=maxtargets) {return 1;} else{return 0;}};
virtual int ready(){return cursor;};
virtual ~TargetChooser(){};
virtual int full()
{
if (maxtargets != -1 && cursor >= maxtargets)
{
return 1;
}
else
{
return 0;
}
}
;
virtual int ready()
{
return cursor;
}
;
virtual ~TargetChooser()
{
}
;
int targetListSet();
virtual TargetChooser* clone() const = 0;
};
class TargetChooserFactory{
class TargetChooserFactory
{
public:
TargetChooser * createTargetChooser(string s, MTGCardInstance * card, MTGAbility * ability = NULL);
TargetChooser * createTargetChooser(MTGCardInstance * card);
};
class TargetZoneChooser:public TargetChooser{
class TargetZoneChooser: public TargetChooser
{
public:
int zones[15];
int nbzones;
@@ -77,7 +102,8 @@ class TargetZoneChooser:public TargetChooser{
virtual TargetZoneChooser * clone() const;
};
class CardTargetChooser:public TargetZoneChooser {
class CardTargetChooser: public TargetZoneChooser
{
protected:
MTGCardInstance * validTarget;
public:
@@ -86,8 +112,8 @@ public:
virtual CardTargetChooser * clone() const;
};
class CreatureTargetChooser:public TargetZoneChooser{
class CreatureTargetChooser: public TargetZoneChooser
{
public:
CreatureTargetChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
CreatureTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
@@ -96,17 +122,25 @@ class CreatureTargetChooser:public TargetZoneChooser{
};
class DamageableTargetChooser:public CreatureTargetChooser{
class DamageableTargetChooser: public CreatureTargetChooser
{
public:
DamageableTargetChooser(int * _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false):CreatureTargetChooser( _zones,_nbzones, card, _maxtargets,other){};
DamageableTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false):CreatureTargetChooser(card, _maxtargets,other){};
DamageableTargetChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false) :
CreatureTargetChooser(_zones, _nbzones, card, _maxtargets, other)
{
}
;
DamageableTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false) :
CreatureTargetChooser(card, _maxtargets, other)
{
}
;
virtual bool canTarget(Targetable * target);
virtual DamageableTargetChooser * clone() const;
};
class PlayerTargetChooser:public TargetChooser{
class PlayerTargetChooser: public TargetChooser
{
protected:
Player * p; //In Case we can only target a specific player
public:
@@ -115,7 +149,8 @@ protected:
virtual PlayerTargetChooser * clone() const;
};
class TypeTargetChooser:public TargetZoneChooser{
class TypeTargetChooser: public TargetZoneChooser
{
public:
int nbtypes;
int types[10];
@@ -127,7 +162,8 @@ class TypeTargetChooser:public TargetZoneChooser{
virtual TypeTargetChooser * clone() const;
};
class DescriptorTargetChooser:public TargetZoneChooser{
class DescriptorTargetChooser: public TargetZoneChooser
{
public:
CardDescriptor * cd;
DescriptorTargetChooser(CardDescriptor * _cd, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
@@ -137,8 +173,8 @@ class DescriptorTargetChooser:public TargetZoneChooser{
virtual DescriptorTargetChooser * clone() const;
};
class SpellTargetChooser:public TargetChooser{
class SpellTargetChooser: public TargetChooser
{
public:
int color;
SpellTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, bool other = false);
@@ -146,7 +182,8 @@ class SpellTargetChooser:public TargetChooser{
virtual SpellTargetChooser * clone() const;
};
class SpellOrPermanentTargetChooser:public TargetZoneChooser{
class SpellOrPermanentTargetChooser: public TargetZoneChooser
{
public:
int color;
SpellOrPermanentTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, bool other = false);
@@ -154,9 +191,8 @@ class SpellOrPermanentTargetChooser:public TargetZoneChooser{
virtual SpellOrPermanentTargetChooser * clone() const;
};
class DamageTargetChooser:public TargetChooser{
class DamageTargetChooser: public TargetChooser
{
public:
int color;
int state;
@@ -166,7 +202,8 @@ class DamageTargetChooser:public TargetChooser{
};
//Should only be used for triggered abilities.
class TriggerTargetChooser:public TargetChooser{
class TriggerTargetChooser: public TargetChooser
{
public:
Targetable * target;
int triggerTarget;
+2 -1
View File
@@ -5,7 +5,8 @@
#define TARGET_PLAYER 2
#define TARGET_STACKACTION 3
class Targetable{
class Targetable
{
public:
virtual int typeAsTarget() = 0;
virtual const string getDisplayName() const = 0;
+7 -2
View File
@@ -11,7 +11,8 @@ class Spell;
class Interruptible;
class Damage;
class TargetsList{
class TargetsList
{
public:
int cursor;
TargetsList();
@@ -28,7 +29,11 @@ class TargetsList{
Spell * getNextSpellTarget(Spell * previous = 0);
Damage * getNextDamageTarget(Damage * previous = 0);
Targetable * getNextTarget(Targetable * previous = 0, int type = -1);
void initTargets(){cursor = 0;};
void initTargets()
{
cursor = 0;
}
;
};
#endif
+25 -13
View File
@@ -20,7 +20,8 @@
#define COMMON_ATTRIBS_COUNT 7
class Task {
class Task
{
protected:
int reward; // TODO: Complex rewards. Be consistent with other planned modes with rewards.
int opponent;
@@ -64,7 +65,8 @@ public:
void passOneDay();
};
class TaskList {
class TaskList
{
protected:
string fileName;
float vPos;
@@ -74,11 +76,11 @@ protected:
JTexture * mBgTex;
float sH, sW;
public:
vector<Task*> tasks;
enum{
enum
{
TASKS_IN,
TASKS_ACTIVE,
TASKS_OUT,
@@ -88,7 +90,11 @@ public:
TaskList(string _fileName = "");
int load(string _fileName = "");
int save(string _fileName = "");
int getState() {return mState;};
int getState()
{
return mState;
}
;
void addTask(string params, bool rand = false);
void addTask(Task *task);
void addRandomTask(int diff = 100);
@@ -107,7 +113,8 @@ public:
~TaskList();
};
class TaskWinAgainst : public Task {
class TaskWinAgainst: public Task
{
protected:
virtual int computeReward();
public:
@@ -117,7 +124,8 @@ public:
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
};
class TaskSlaughter : public TaskWinAgainst {
class TaskSlaughter: public TaskWinAgainst
{
protected:
int targetLife;
virtual int computeReward();
@@ -131,7 +139,8 @@ public:
virtual void randomize();
};
class TaskDelay : public TaskWinAgainst {
class TaskDelay: public TaskWinAgainst
{
protected:
int turn;
bool afterTurn;
@@ -146,7 +155,8 @@ public:
virtual void randomize();
};
class TaskImmortal : public Task {
class TaskImmortal: public Task
{
protected:
int targetLife;
int level;
@@ -162,7 +172,8 @@ public:
virtual void randomize();
};
class TaskMassiveBurial : public Task {
class TaskMassiveBurial: public Task
{
protected:
int color;
int bodyCount;
@@ -178,7 +189,8 @@ public:
virtual void randomize();
};
class TaskWisdom : public Task {
class TaskWisdom: public Task
{
protected:
int color;
int cardCount;
@@ -194,7 +206,8 @@ public:
virtual void randomize();
};
class TaskPacifism : public Task {
class TaskPacifism: public Task
{
protected:
virtual int computeReward();
int lifeSlashCardMin;
@@ -209,7 +222,6 @@ public:
virtual void randomize();
};
/* ------------ Task template ------------
class TaskXX : public Task {
+14 -12
View File
@@ -8,7 +8,8 @@
#include "AIPlayer.h"
class TestSuiteActions{
class TestSuiteActions
{
public:
int nbitems;
string actions[MAX_TESTSUITE_ACTIONS];
@@ -17,7 +18,8 @@ class TestSuiteActions{
void cleanup();
};
class TestSuitePlayerZone{
class TestSuitePlayerZone
{
public:
int cards[MAX_TESTUITE_CARDS];
int nbitems;
@@ -26,7 +28,8 @@ class TestSuitePlayerZone{
void cleanup();
};
class TestSuitePlayerData{
class TestSuitePlayerData
{
public:
int life;
ManaCost * manapool;
@@ -37,10 +40,9 @@ class TestSuitePlayerData{
};
class TestSuite;
class TestSuiteState{
class TestSuiteState
{
public:
int phase;
void parsePlayerState(int playerId, string s);
@@ -49,13 +51,14 @@ class TestSuiteState{
void cleanup();
};
class TestSuitePregame{
class TestSuitePregame
{
public:
virtual void performTest() = 0;
};
class TestSuite{
class TestSuite
{
public:
MTGAllCards* collection;
int summoningSickness;
@@ -86,7 +89,8 @@ class TestSuite{
};
class TestSuiteAI:public AIPlayerBaka{
class TestSuiteAI:public AIPlayerBaka
{
public:
TestSuite * suite;
float timer;
@@ -97,7 +101,5 @@ class TestSuiteAI:public AIPlayerBaka{
virtual int displayStack();
};
#endif
#endif
+3 -3
View File
@@ -7,7 +7,8 @@ class JLBFont;
#include <vector>
using namespace std;
class TextScroller: public JGuiObject{
class TextScroller: public JGuiObject
{
protected:
string mText;
string tempText;
@@ -34,8 +35,7 @@ public:
virtual ostream& toString(ostream& out) const;
};
class VerticalTextScroller:
public TextScroller
class VerticalTextScroller: public TextScroller
{
private:
size_t mNbItemsShown;
+24 -13
View File
@@ -10,7 +10,8 @@
#include "MTGCardInstance.h"
#include "CardDescriptor.h"
class ThisDescriptor{
class ThisDescriptor
{
public:
int comparisonMode;
int comparisonCriterion;
@@ -19,12 +20,14 @@ class ThisDescriptor{
virtual ~ThisDescriptor();
};
class ThisDescriptorFactory{
class ThisDescriptorFactory
{
public:
ThisDescriptor * createThisDescriptor(string s);
};
class ThisCounter:public ThisDescriptor{
class ThisCounter: public ThisDescriptor
{
public:
Counter * counter;
virtual int match(MTGCardInstance * card);
@@ -34,64 +37,72 @@ class ThisCounter:public ThisDescriptor{
~ThisCounter();
};
class ThisCounterAny:public ThisDescriptor{
class ThisCounterAny: public ThisDescriptor
{
public:
virtual int match(MTGCardInstance *card);
ThisCounterAny(int nb);
};
class ThisControllerlife:public ThisDescriptor{
class ThisControllerlife: public ThisDescriptor
{
public:
virtual int match(MTGCardInstance * card);
ThisControllerlife(int life);
};
class ThisOpponentlife:public ThisDescriptor{
class ThisOpponentlife: public ThisDescriptor
{
public:
virtual int match(MTGCardInstance * card);
ThisOpponentlife(int olife);
};
class ThisEquip:public ThisDescriptor{
class ThisEquip: public ThisDescriptor
{
public:
virtual int match(MTGCardInstance * card);
ThisEquip(int equipment);
};
class ThisAttacked:public ThisDescriptor{
class ThisAttacked: public ThisDescriptor
{
public:
virtual int match(MTGCardInstance * card);
ThisAttacked(int attack);
};
class ThisNotBlocked:public ThisDescriptor{
class ThisNotBlocked: public ThisDescriptor
{
public:
virtual int match(MTGCardInstance * card);
ThisNotBlocked(int unblocked);
};
class ThisPower:public ThisDescriptor{
class ThisPower: public ThisDescriptor
{
public:
virtual int match(MTGCardInstance * card);
ThisPower(int power);
};
class ThisToughness:public ThisDescriptor{
class ThisToughness: public ThisDescriptor
{
public:
virtual int match(MTGCardInstance * card);
ThisToughness(int toughness);
};
class ThisX:public ThisDescriptor{
class ThisX: public ThisDescriptor
{
public:
virtual int match(MTGCardInstance * card);
ThisX(int x);
+2 -2
View File
@@ -1,7 +1,6 @@
#ifndef THREADING_H
#define THREADING_H
#if defined (WIN32) || defined (LINUX)
#include <boost/date_time.hpp>
@@ -18,7 +17,8 @@ namespace boost
public:
struct scoped_lock
{
scoped_lock(mutex& inMutex) : mID(inMutex.mID)
scoped_lock(mutex& inMutex) :
mID(inMutex.mID)
{
sceKernelWaitSema(mID, 1, 0);
}
+2 -1
View File
@@ -3,7 +3,8 @@
#include "MTGCardInstance.h"
class Token: public MTGCardInstance{
class Token: public MTGCardInstance
{
MTGCardInstance * tokenSource;
public:
Token(string _name, MTGCardInstance * source, int _power = 0, int _toughness = 0);
+2 -2
View File
@@ -4,14 +4,14 @@
#include <string>
#include <map>
#if defined _DEBUG
#define DEBUG_TRANSLATE
#endif
using namespace std;
class Translator{
class Translator
{
protected:
static Translator * mInstance;
bool initDone;
+29 -11
View File
@@ -8,7 +8,8 @@
#define INVALID_MTEX -1
#endif
class WResource{
class WResource
{
public:
friend class WResourceManager;
friend struct WCacheSort;
@@ -33,7 +34,8 @@ protected:
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:
friend class WResourceManager;
template<class cacheItem, class cacheActual> friend class WCache;
@@ -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().
};
class WTrackedQuad: public WResource {
class WTrackedQuad: public WResource
{
public:
WTrackedQuad(string _resname);
~WTrackedQuad();
@@ -56,7 +58,8 @@ public:
JQuad * quad;
};
class WCachedTexture: public WCachedResource{
class WCachedTexture: public WCachedResource
{
public:
friend class WResourceManager;
template<class cacheItem, class cacheActual> friend class WCache;
@@ -68,11 +71,16 @@ public:
bool isGood();
bool isLocked(); //Is the resource locked?
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.
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 * 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.
@@ -83,7 +91,8 @@ protected:
vector<WTrackedQuad*> trackedQuads;
};
class WCachedParticles: public WCachedResource{
class WCachedParticles: public WCachedResource
{
public:
friend class WResourceManager;
template<class cacheItem, class cacheActual> friend class WCache;
@@ -94,20 +103,29 @@ public:
bool isGood();
bool Attempt(string filename, int submode, int & error);
bool compare(hgeParticleSystemInfo * p) {return (p == particles);};
bool compare(hgeParticleSystemInfo * p)
{
return (p == particles);
}
;
hgeParticleSystemInfo * Actual();
protected:
hgeParticleSystemInfo * particles;
};
class WCachedSample: public WCachedResource{
class WCachedSample: public WCachedResource
{
public:
friend class WResourceManager;
template<class cacheItem, class cacheActual> friend class WCache;
WCachedSample();
~WCachedSample();
bool compare(JSample * s) {return (s == sample);};
bool compare(JSample * s)
{
return (s == sample);
}
;
unsigned long size();
bool isGood();
void Refresh();
+250 -58
View File
@@ -10,14 +10,32 @@ class MTGDeck;
class MTGAllCards;
class JQuad;
class WSyncable{
class WSyncable
{
public:
WSyncable(int i=0) {hooked = NULL;currentPos = 0;};
virtual ~WSyncable() {};
WSyncable(int i = 0)
{
hooked = NULL;
currentPos = 0;
}
;
virtual ~WSyncable()
{
}
;
//Local
virtual bool Hook(WSyncable* s);
virtual int getOffset() {return currentPos;};
virtual bool setOffset(int i) {currentPos = i; return true;};
virtual int getOffset()
{
return currentPos;
}
;
virtual bool setOffset(int i)
{
currentPos = i;
return true;
}
;
//Recursive
virtual int getPos();
virtual bool next();
@@ -27,25 +45,74 @@ protected:
int currentPos;
};
class WDataSource: public WSyncable{
class WDataSource: public WSyncable
{
public:
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 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;};
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 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:
float mLastInput;
};
class WSrcImage: public WDataSource{
class WSrcImage: public WDataSource
{
public:
virtual JQuad * getImage(int offset = 0);
WSrcImage(string s);
@@ -54,7 +121,8 @@ protected:
string filename;
};
class WSrcCards: public WDataSource{
class WSrcCards: public WDataSource
{
protected:
vector<MTGCard*> cards;
vector<size_t> validated;
@@ -99,9 +167,14 @@ public:
//We put it into something else
virtual int addRandomCards(MTGDeck * i, int howmany = 1);
virtual int addToDeck(MTGDeck * i, int num = -1); //Returns num that didn't add
virtual WCardFilter * getFiltersRoot(){return filtersRoot;};
virtual WCardFilter * getFiltersRoot()
{
return filtersRoot;
}
;
enum {
enum
{
MAX_CYCLES = 4, //How many cycles to search, for addToDeck
SORT_COLLECTOR,
SORT_ALPHA,
@@ -110,53 +183,169 @@ public:
};
class WSrcDeckViewer: public WSrcCards{
class WSrcDeckViewer: public WSrcCards
{
public:
WSrcDeckViewer(WSrcCards * _active, WSrcCards * _inactive);
~WSrcDeckViewer();
void swapSrc();
//Wrapped functions
JQuad * getImage(int offset=0) {return active->getImage(offset);};
JQuad * getThumb(int offset=0) {return active->getThumb(offset);};
MTGCard * getCard(int offset=0, bool ignore=false) {return active->getCard(offset,ignore);};
int Size(bool all=false) {return active->Size();};
WCardFilter * getfiltersRoot() {return active->getFiltersRoot();};
void Shuffle() {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);};
JQuad * getImage(int offset = 0)
{
return active->getImage(offset);
}
;
JQuad * getThumb(int offset = 0)
{
return active->getThumb(offset);
}
;
MTGCard * getCard(int offset = 0, bool ignore = false)
{
return active->getCard(offset, ignore);
}
;
int Size(bool all = false)
{
return active->Size();
}
;
WCardFilter * getfiltersRoot()
{
return active->getFiltersRoot();
}
;
void Shuffle()
{
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:
WSrcCards * active;
WSrcCards * inactive;
};
class WSrcUnlockedCards: public WSrcCards{ //Only unlocked cards.
class WSrcUnlockedCards: public WSrcCards
{ //Only unlocked cards.
public:
WSrcUnlockedCards(float mDelay = 0.2);
};
class WSrcDeck: public WSrcCards{
class WSrcDeck: public WSrcCards
{
public:
WSrcDeck(float delay=0.2) : WSrcCards(delay) {clearCounts();};
WSrcDeck(float delay = 0.2) :
WSrcCards(delay)
{
clearCounts();
}
;
virtual int loadMatches(MTGDeck * deck);
virtual int Add(MTGCard * c, int quantity = 1);
virtual int Remove(MTGCard * c, int quantity = 1, bool erase = false);
@@ -164,7 +353,8 @@ public:
int count(MTGCard * c);
int countByName(MTGCard * card, bool editions = false);
int totalPrice();
enum {
enum
{
//0 to MTG_NB_COLORS are colors. See MTG_COLOR_ in Constants::.
UNFILTERED_COPIES = Constants::MTG_NB_COLORS,
UNFILTERED_UNIQUE,
@@ -183,18 +373,20 @@ protected:
int counts[MAX_COUNTS];
};
struct WCSortCollector{
struct WCSortCollector
{
bool operator()(const MTGCard*l, const MTGCard*r);
};
struct WCSortAlpha{
struct WCSortAlpha
{
bool operator()(const MTGCard*l, const MTGCard*r);
};
struct WCSortRarity{
struct WCSortRarity
{
int rareToInt(char r);
bool operator()(const MTGCard*l, const MTGCard*r);
};
#endif
+58 -30
View File
@@ -29,11 +29,20 @@ public:
WEvent(int type = NOT_SPECIFIED);
virtual ~WEvent() {};
virtual std::ostream& toString(std::ostream& out) const;
virtual int getValue() {return 0;};
virtual Targetable * getTarget(int target) {return 0;};
virtual int getValue()
{
return 0;
}
;
virtual Targetable * getTarget(int target)
{
return 0;
}
;
};
struct WEventZoneChange : public WEvent {
struct WEventZoneChange: public WEvent
{
MTGCardInstance * card;
MTGGameZone * from;
MTGGameZone * to;
@@ -43,8 +52,8 @@ struct WEventZoneChange : public WEvent {
virtual Targetable * getTarget(int target);
};
struct WEventDamage : public WEvent {
struct WEventDamage: public WEvent
{
Damage * damage;
WEventDamage(Damage * damage);
virtual std::ostream& toString(std::ostream& out) const;
@@ -52,25 +61,28 @@ struct WEventDamage : public WEvent {
virtual Targetable * getTarget(int target);
};
struct WEventDamageStackResolved : public WEvent {
struct WEventDamageStackResolved: public WEvent
{
WEventDamageStackResolved();
};
struct WEventPhaseChange : public WEvent {
struct WEventPhaseChange: public WEvent
{
Phase * from;
Phase * to;
WEventPhaseChange(Phase * from, Phase * to);
};
//Abstract class of event when a card's status changes
struct WEventCardUpdate : public WEvent {
struct WEventCardUpdate: public WEvent
{
MTGCardInstance * card;
WEventCardUpdate(MTGCardInstance * card);
};
//Event when a card gains/looses types
struct WEventCardChangeType : public WEventCardUpdate {
struct WEventCardChangeType: public WEventCardUpdate
{
int type;
bool before;
bool after;
@@ -78,68 +90,77 @@ struct WEventCardChangeType : public WEventCardUpdate {
};
//Event when a card is tapped/untapped
struct WEventCardTap : public WEventCardUpdate {
struct WEventCardTap: public WEventCardUpdate
{
bool before;
bool after;
WEventCardTap(MTGCardInstance * card, bool before, bool after);
virtual Targetable * getTarget(int target);
};
struct WEventCardTappedForMana : public WEventCardUpdate {
struct WEventCardTappedForMana: public WEventCardUpdate
{
bool before;
bool after;
WEventCardTappedForMana(MTGCardInstance * card, bool before, bool after);
virtual Targetable * getTarget(int target);
};
//Event when a card's "attacker" status changes
//before:Player/Planeswalker that card was attacking previously
//after: Player/Planeswalker that card is attacking now
struct WEventCreatureAttacker : public WEventCardUpdate {
struct WEventCreatureAttacker: public WEventCardUpdate
{
Targetable * before;
Targetable * after;
WEventCreatureAttacker(MTGCardInstance * card, Targetable * from, Targetable * to);
};
//event when card attacks.
struct WEventCardAttacked : public WEventCardUpdate {
struct WEventCardAttacked: public WEventCardUpdate
{
WEventCardAttacked(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//event when card attacks alone.
struct WEventCardAttackedAlone : public WEventCardUpdate {
struct WEventCardAttackedAlone: public WEventCardUpdate
{
WEventCardAttackedAlone(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//event when card attacks but is not blocked.
struct WEventCardAttackedNotBlocked : public WEventCardUpdate {
struct WEventCardAttackedNotBlocked: public WEventCardUpdate
{
WEventCardAttackedNotBlocked(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//event when card attacks but is blocked.
struct WEventCardAttackedBlocked : public WEventCardUpdate {
struct WEventCardAttackedBlocked: public WEventCardUpdate
{
WEventCardAttackedBlocked(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//event when card blocked.
struct WEventCardBlocked : public WEventCardUpdate {
struct WEventCardBlocked: public WEventCardUpdate
{
WEventCardBlocked(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//event when card is sacrificed.
struct WEventCardSacrifice : public WEventCardUpdate {
struct WEventCardSacrifice: public WEventCardUpdate
{
WEventCardSacrifice(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//event when card is discarded.
struct WEventCardDiscard : public WEventCardUpdate {
struct WEventCardDiscard: public WEventCardUpdate
{
WEventCardDiscard(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
@@ -147,7 +168,8 @@ struct WEventCardDiscard : public WEventCardUpdate {
//Event when a card's "defenser" status changes
//before : attacker that card was blocking previously
//after: attacker that card is blocking now
struct WEventCreatureBlocker : public WEventCardUpdate {
struct WEventCreatureBlocker: public WEventCardUpdate
{
MTGCardInstance * before;
MTGCardInstance * after;
WEventCreatureBlocker(MTGCardInstance * card, MTGCardInstance * from, MTGCardInstance * to);
@@ -155,15 +177,18 @@ struct WEventCreatureBlocker : public WEventCardUpdate {
//Event sent when attackers have been chosen and they
//cannot be changed any more.
struct WEventAttackersChosen : public WEvent {
struct WEventAttackersChosen: public WEvent
{
};
//Event sent when blockers have been chosen and they
//cannot be changed any more.
struct WEventBlockersChosen : public WEvent {
struct WEventBlockersChosen: public WEvent
{
};
struct WEventcardDraw : public WEvent {
struct WEventcardDraw: public WEvent
{
WEventcardDraw(Player * player, int nb_cards);
Player * player;
int nb_cards;
@@ -173,7 +198,8 @@ struct WEventcardDraw : public WEvent {
//Event when a blocker is reordered
//exchangeWith: exchange card's position with exchangeWith's position
//attacker:both card and exchangeWith *should* be in attacker's "blockers" list.
struct WEventCreatureBlockerRank : public WEventCardUpdate {
struct WEventCreatureBlockerRank: public WEventCardUpdate
{
MTGCardInstance * exchangeWith;
MTGCardInstance * attacker;
WEventCreatureBlockerRank(MTGCardInstance * card, MTGCardInstance * exchangeWith, MTGCardInstance * attacker);
@@ -186,10 +212,10 @@ struct WEventCombatStepChange : public WEvent
WEventCombatStepChange(CombatStep);
};
//Event when a mana is engaged
//color : color
struct WEventEngageMana : public WEvent {
struct WEventEngageMana: public WEvent
{
int color;
MTGCardInstance* card;
ManaPool * destination;
@@ -198,7 +224,8 @@ struct WEventEngageMana : public WEvent {
//Event when a mana is consumed
//color : color
struct WEventConsumeMana : public WEvent {
struct WEventConsumeMana: public WEvent
{
int color;
ManaPool * source;
WEventConsumeMana(int color, ManaPool * source);
@@ -206,7 +233,8 @@ struct WEventConsumeMana : public WEvent {
//Event when a manapool is emptied
//color : color
struct WEventEmptyManaPool : public WEvent {
struct WEventEmptyManaPool: public WEvent
{
ManaPool * source;
WEventEmptyManaPool(ManaPool * source);
};
+206 -54
View File
@@ -3,7 +3,8 @@
class WCardFilter;
class WCFilterFactory{
class WCFilterFactory
{
public:
WCFilterFactory(){};
static WCFilterFactory * GetInstance();
@@ -16,119 +17,236 @@ private:
static WCFilterFactory * me;
};
class WCardFilter{
class WCardFilter
{
public:
WCardFilter() {};
virtual ~WCardFilter() {};
virtual bool isMatch(MTGCard * c) {return true;};
virtual bool isMatch(MTGCard * c)
{
return true;
}
;
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:
WCFBranch(WCardFilter * a, WCardFilter * b) {lhs=a;rhs=b;};
~WCFBranch() {SAFE_DELETE(lhs); SAFE_DELETE(rhs);};
WCFBranch(WCardFilter * a, WCardFilter * b)
{
lhs = a;
rhs = b;
}
;
~WCFBranch()
{
SAFE_DELETE(lhs);
SAFE_DELETE(rhs);
}
;
virtual bool isMatch(MTGCard * c) = 0;
virtual string getCode() = 0;
virtual WCardFilter * Right(){return rhs;};
virtual WCardFilter * Left(){return lhs;};
virtual WCardFilter * Right()
{
return rhs;
}
;
virtual WCardFilter * Left()
{
return lhs;
}
;
protected:
WCardFilter *lhs, *rhs;
};
class WCFilterOR: public WCFBranch{
class WCFilterOR: public WCFBranch
{
public:
WCFilterOR(WCardFilter * a, WCardFilter * b): WCFBranch(a,b) {};
WCFilterOR(WCardFilter * a, WCardFilter * b) :
WCFBranch(a, b)
{
}
;
bool isMatch(MTGCard *c);
string getCode();
float filterFee();
};
class WCFilterAND: public WCFBranch{
class WCFilterAND: public WCFBranch
{
public:
WCFilterAND(WCardFilter * a, WCardFilter * b): WCFBranch(a,b) {};
bool isMatch(MTGCard *c) {return (lhs->isMatch(c) && rhs->isMatch(c));};
WCFilterAND(WCardFilter * a, WCardFilter * b) :
WCFBranch(a, b)
{
}
;
bool isMatch(MTGCard *c)
{
return (lhs->isMatch(c) && rhs->isMatch(c));
}
;
string getCode();
float filterFee();
};
class WCFilterGROUP: public WCardFilter{
class WCFilterGROUP: public WCardFilter
{
public:
WCFilterGROUP(WCardFilter * _k) {kid = _k;};
~WCFilterGROUP() {SAFE_DELETE(kid);};
bool isMatch(MTGCard *c) {return kid->isMatch(c);};
WCFilterGROUP(WCardFilter * _k)
{
kid = _k;
}
;
~WCFilterGROUP()
{
SAFE_DELETE(kid);
}
;
bool isMatch(MTGCard *c)
{
return kid->isMatch(c);
}
;
string getCode();
float filterFee() {return kid->filterFee();};
float filterFee()
{
return kid->filterFee();
}
;
protected:
WCardFilter * kid;
};
class WCFilterNOT: public WCardFilter{
class WCFilterNOT: public WCardFilter
{
public:
WCFilterNOT(WCardFilter * _k) {kid = _k;};
~WCFilterNOT() {SAFE_DELETE(kid);};
bool isMatch(MTGCard *c) {return !kid->isMatch(c);};
WCFilterNOT(WCardFilter * _k)
{
kid = _k;
}
;
~WCFilterNOT()
{
SAFE_DELETE(kid);
}
;
bool isMatch(MTGCard *c)
{
return !kid->isMatch(c);
}
;
string getCode();
protected:
WCardFilter * kid;
};
class WCFilterNULL: public WCardFilter{
class WCFilterNULL: public WCardFilter
{
public:
WCFilterNULL() {};
string getCode() {return "NULL";};
bool isMatch(MTGCard *c) {return true;};
WCFilterNULL()
{
}
;
string getCode()
{
return "NULL";
}
;
bool isMatch(MTGCard *c)
{
return true;
}
;
};
//Filter terminals:
class WCFilterSet: public WCardFilter{
class WCFilterSet: public WCardFilter
{
public:
WCFilterSet(int _setid=MTGSets::ALL_SETS) {setid=_setid;};
WCFilterSet(int _setid = MTGSets::ALL_SETS)
{
setid = _setid;
}
;
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();
float filterFee() {return 0.2f;};
float filterFee()
{
return 0.2f;
}
;
protected:
int setid;
};
class WCFilterLetter: public WCardFilter{
class WCFilterLetter: public WCardFilter
{
public:
WCFilterLetter(string arg);
bool isMatch(MTGCard * c);
string getCode();
float filterFee() {return 4.0f;}; //Alpha searches are expensive!
float filterFee()
{
return 4.0f;
}
; //Alpha searches are expensive!
protected:
char alpha;
};
class WCFilterColor: public WCardFilter{
class WCFilterColor: public WCardFilter
{
public:
WCFilterColor(int _c) {color = _c;};
WCFilterColor(int _c)
{
color = _c;
}
;
WCFilterColor(string arg);
bool isMatch(MTGCard * c);
string getCode();
float filterFee() {return 0.2f;};
float filterFee()
{
return 0.2f;
}
;
protected:
int color;
};
class WCFilterOnlyColor: public WCFilterColor{
class WCFilterOnlyColor: public WCFilterColor
{
public:
WCFilterOnlyColor(int _c) : WCFilterColor(_c) {};
WCFilterOnlyColor(string arg) : WCFilterColor(arg) {};
bool isMatch(MTGCard * c);
string getCode();
};
class WCFilterProducesColor: public WCFilterColor{
class WCFilterProducesColor: public WCFilterColor
{
public:
WCFilterProducesColor(int _c) : WCFilterColor(_c) {};
WCFilterProducesColor(string arg) : WCFilterColor(arg) {};
bool isMatch(MTGCard * c);
string getCode();
};
class WCFilterNumeric: public WCardFilter{
class WCFilterNumeric: public WCardFilter
{
public:
WCFilterNumeric(int _num) {number = _num;};
WCFilterNumeric(int _num)
{
number = _num;
}
;
WCFilterNumeric(string arg);
bool isMatch(MTGCard * c) = 0;
string getCode() = 0;
@@ -136,43 +254,72 @@ public:
protected:
int number;
};
class WCFilterCMC: public WCFilterNumeric{
class WCFilterCMC: public WCFilterNumeric
{
public:
WCFilterCMC(int amt) : WCFilterNumeric(amt) {};
WCFilterCMC(string arg) : WCFilterNumeric(arg) {};
bool isMatch(MTGCard * c);
string getCode();
float filterFee() {return number/20.0f;};
float filterFee()
{
return number / 20.0f;
}
;
};
class WCFilterPower: public WCFilterNumeric{
class WCFilterPower: public WCFilterNumeric
{
public:
WCFilterPower(int amt) : WCFilterNumeric(amt) {};
WCFilterPower(string arg) : WCFilterNumeric(arg) {};
bool isMatch(MTGCard * c);
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:
WCFilterToughness(int amt) : WCFilterNumeric(amt) {};
WCFilterToughness(string arg) : WCFilterNumeric(arg) {};
bool isMatch(MTGCard * c);
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:
WCFilterType(string arg) {type = arg;};
WCFilterType(string arg)
{
type = arg;
}
;
bool isMatch(MTGCard * c);
string getCode();
float filterFee() {return 0.4f;};
float filterFee()
{
return 0.4f;
}
;
protected:
string type;
};
class WCFilterRarity: public WCardFilter{
class WCFilterRarity: public WCardFilter
{
public:
WCFilterRarity(char _r) {rarity = _r;};
WCFilterRarity(char _r)
{
rarity = _r;
}
;
WCFilterRarity(string arg);
bool isMatch(MTGCard * c);
string getCode();
@@ -180,9 +327,14 @@ public:
protected:
char rarity;
};
class WCFilterAbility: public WCardFilter{
class WCFilterAbility: public WCardFilter
{
public:
WCFilterAbility(int _a) {ability = _a;};
WCFilterAbility(int _a)
{
ability = _a;
}
;
WCFilterAbility(string arg);
bool isMatch(MTGCard * c);
string getCode();
+62 -15
View File
@@ -22,7 +22,6 @@ namespace Fonts
const unsigned int kSingleByteFontOffset = 100;
}
class WFont
{
public:
@@ -62,18 +61,62 @@ class WLBFont : public WFont
{
public:
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(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);};
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 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(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);
}
;
PIXEL_TYPE GetColor() const
{
return it->GetColor();
}
;
void SetScale(float scale)
{
it->SetScale(scale);
}
;
float GetScale() const
{
return it->GetScale();
}
;
float GetHeight() const
{
return it->GetHeight();
}
;
float GetStringWidth(const char *s) const
{
return it->GetStringWidth(s);
}
;
void SetTracking(float tracking)
{
it->SetTracking(tracking);
}
;
void SetBase(int base)
{
it->SetBase(base);
}
;
void FormatText(string &s, vector<string>& output);
private:
@@ -89,7 +132,11 @@ public:
void DrawString(std::string s, float x, float y, int align = JGETEXT_LEFT, float leftOffset = 0, float width = 0);
void SetColor(PIXEL_TYPE color);
PIXEL_TYPE GetColor() const {return mColor0;};
PIXEL_TYPE GetColor() const
{
return mColor0;
}
;
void SetScale(float scale);
float GetScale() const;
float GetHeight() const;
@@ -147,8 +194,8 @@ public:
class WUFont: public WFBFont
{
public:
WUFont(int inFontID, const char *fontname, int lineheight, bool useVideoRAM = false)
: WFBFont(inFontID, fontname, lineheight, useVideoRAM) {};
WUFont(int inFontID, const char *fontname, int lineheight, bool useVideoRAM = false) :
WFBFont(inFontID, fontname, lineheight, useVideoRAM) {};
int GetCode(const u8 *ch, int *charLength) const;
int GetMana(const u8 *ch) const;
+442 -117
View File
@@ -5,11 +5,12 @@
class hgeDistortionMesh;
class GameStateOptions;
class WGuiColor{
class WGuiColor
{
public:
enum {
SCROLLBAR,
SCROLLBUTTON,
enum
{
SCROLLBAR, SCROLLBUTTON,
//Foregrounds only after this
TEXT,
TEXT_HEADER,
@@ -25,7 +26,8 @@ public:
};
};
struct WDistort {
struct WDistort
{
WDistort();
WDistort(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
float & operator[](int p);
@@ -34,27 +36,50 @@ protected:
};
//Complete item interface
class WGuiBase: public JGuiListener {
class WGuiBase: public JGuiListener
{
public:
typedef enum {
typedef enum
{
CONFIRM_NEED, // Still needs confirmation
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;
WGuiBase() {};
virtual ~WGuiBase() {};
virtual bool Selectable() {return true;};
virtual bool isModal() {return false;};
virtual bool Visible() {return true;};
virtual bool Selectable()
{
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 CONFIRM_TYPE needsConfirm();
virtual bool yieldFocus();
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 bool Leaving(JButton key)=0;
@@ -74,10 +99,26 @@ public:
virtual float getY()=0;
virtual float getWidth()=0;
virtual float getHeight()=0;
virtual int getId() {return INVALID_ID;};
virtual string getDisplay() const {return "";};
virtual float minWidth(){return getWidth();};
virtual float minHeight(){return getHeight();};
virtual int getId()
{
return INVALID_ID;
}
;
virtual string getDisplay() const
{
return "";
}
;
virtual float minWidth()
{
return getWidth();
}
;
virtual float minHeight()
{
return getHeight();
}
;
virtual void setModal(bool val) {};
virtual void setDisplay(string s) {};
@@ -88,17 +129,21 @@ public:
virtual void setId(int _id) {};
virtual void setHidden(bool bHidden){};
virtual void setVisible(bool bVisisble) {};
virtual void renderBack(WGuiBase * it);
virtual void subBack(WGuiBase * item) {};
virtual bool CheckUserInput(JButton key) {return false;};
virtual bool CheckUserInput(JButton key)
{
return false;
}
;
protected:
vector<WGuiBase*> items;
};
//This is our base class for concrete items.
class WGuiItem: public WGuiBase{
class WGuiItem: public WGuiBase
{
public:
virtual void Entering(JButton key);
virtual bool Leaving(JButton key);
@@ -113,25 +158,78 @@ public:
virtual void setData() {};
virtual bool hasFocus() {return mFocus;};
virtual void setFocus(bool bFocus) {mFocus = bFocus;};
virtual bool hasFocus()
{
return mFocus;
}
;
virtual void setFocus(bool bFocus)
{
mFocus = bFocus;
}
;
virtual string getDisplay() const {return displayValue;};
virtual void setDisplay(string s){displayValue=s;};
virtual string getDisplay() const
{
return displayValue;
}
;
virtual void setDisplay(string s)
{
displayValue = s;
}
;
virtual int getId() {return INVALID_ID;};
virtual float getX() {return x;};
virtual float getY() {return y;};
virtual float getWidth() {return width;};
virtual float getHeight() {return height;};
virtual int getId()
{
return INVALID_ID;
}
;
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 minHeight();
virtual void setId(int _id) {};
virtual void setX(float _x){x = _x;};
virtual void setY(float _y){y = _y;};
virtual void setWidth(float _w){width = _w;};
virtual void setHeight(float _h){height = _h;};
enum {
virtual void setX(float _x)
{
x = _x;
}
;
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),
};
@@ -144,20 +242,31 @@ protected:
string displayValue;
};
class WGuiImage: public WGuiItem{
class WGuiImage: public WGuiItem
{
public:
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 float getHeight();
virtual void imageScale(float _w, float _h);
virtual void setSource(WDataSource *s) {source = s;};
virtual void setSource(WDataSource *s)
{
source = s;
}
;
protected:
int margin;
float imgW, imgH;
WDataSource * source;};
WDataSource * source;
};
class WGuiCardImage: public WGuiImage{
class WGuiCardImage: public WGuiImage
{
public:
WGuiCardImage(WDataSource * wds, bool _thumb = false);
virtual void Render();
@@ -166,77 +275,244 @@ protected:
bool bThumb;
};
class WGuiCardDistort: public WGuiCardImage{
class WGuiCardDistort: public WGuiCardImage
{
public:
WGuiCardDistort(WDataSource * wds, bool _thumb = false, WDataSource * _distort = NULL);
~WGuiCardDistort();
virtual void Render();
WDistort xy;
/* we assume first xy is the top left of the distorted card */
virtual float getX() {return xy[0];};
virtual float getY() {return xy[1];};
virtual float getX()
{
return xy[0];
}
;
virtual float getY()
{
return xy[1];
}
;
protected:
hgeDistortionMesh* mesh;
WDataSource * distortSrc;
};
//This is our base class for decorators. It wraps everything about WGuiBase.
class WGuiDeco: public WGuiBase{
class WGuiDeco: public WGuiBase
{
public:
WGuiDeco(WGuiBase* _it) {it = _it;};
virtual ~WGuiDeco() {SAFE_DELETE(it);};
WGuiDeco(WGuiBase* _it)
{
it = _it;
}
;
virtual ~WGuiDeco()
{
SAFE_DELETE(it);
}
;
virtual bool Selectable() {return it->Selectable();};
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 bool Selectable()
{
return it->Selectable();
}
;
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 bool Leaving(JButton key) {return it->Leaving(key);};
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 Entering(JButton key)
{
it->Entering(key);
}
;
virtual bool Leaving(JButton key)
{
return it->Leaving(key);
}
;
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 string getDisplay() const {return it->getDisplay();};
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 bool hasFocus()
{
return it->hasFocus();
}
;
virtual string getDisplay() const
{
return it->getDisplay();
}
;
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 setDisplay(string s) {it->setDisplay(s);};
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);};
virtual void setFocus(bool bFocus)
{
it->setFocus(bFocus);
}
;
virtual void setDisplay(string s)
{
it->setDisplay(s);
}
;
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:
WGuiBase * it;
};
class WGuiAward: public WGuiItem{
class WGuiAward: public WGuiItem
{
public:
WGuiAward(int _id, string name, string _text, string _details = "");
virtual ~WGuiAward();
virtual void Render();
virtual bool Selectable() {return Visible();};
virtual bool Selectable()
{
return Visible();
}
;
virtual bool Visible();
virtual int getId() {return id;};
virtual int getId()
{
return id;
}
;
virtual void Underlay();
virtual void Overlay();
@@ -246,7 +522,8 @@ protected:
string text;
};
class WGuiSplit: public WGuiItem{
class WGuiSplit: public WGuiItem
{
public:
WGuiSplit(WGuiBase* _left, WGuiBase* _right);
virtual ~WGuiSplit();
@@ -278,7 +555,8 @@ public:
WGuiBase* left;
};
class WDecoConfirm: public WGuiDeco{
class WDecoConfirm: public WGuiDeco
{
public:
WDecoConfirm(JGuiListener * _listener, WGuiBase * it);
virtual ~WDecoConfirm();
@@ -296,17 +574,20 @@ public:
string confirm;
string cancel;
protected:
enum {
enum
{
OP_UNCONFIRMED,
OP_CONFIRMING,
OP_CONFIRMED,
} mState;
SimpleMenu * confirmMenu;
JGuiListener * listener;
bool bModal;
};
class WDecoEnum : public WGuiDeco {
class WDecoEnum: public WGuiDeco
{
public:
WDecoEnum(WGuiBase * _it, EnumDefinition *_edef = NULL);
virtual void Render();
@@ -315,7 +596,8 @@ class WDecoEnum : public WGuiDeco {
EnumDefinition * edef;
};
class WDecoCheat: public WGuiDeco {
class WDecoCheat: public WGuiDeco
{
public:
WDecoCheat(WGuiBase * _it);
virtual bool Visible();
@@ -325,45 +607,67 @@ protected:
bool bVisible;
};
class WGuiButton: public WGuiDeco{
class WGuiButton: public WGuiDeco
{
public:
WGuiButton(WGuiBase* _it, int _controller, int _control, JGuiListener * jgl);
virtual void updateValue();
virtual bool CheckUserInput(JButton key);
virtual bool Selectable() {return Visible();};
virtual bool Selectable()
{
return Visible();
}
;
virtual PIXEL_TYPE getColor(int type);
virtual int getControlID() {return control;};
virtual int getControllerID() {return controller;};
virtual int getControlID()
{
return control;
}
;
virtual int getControllerID()
{
return controller;
}
;
protected:
int control, controller;
JGuiListener * mListener;
};
class WGuiHeader:public WGuiItem{
class WGuiHeader: public WGuiItem
{
public:
WGuiHeader(string _displayValue) : WGuiItem(_displayValue) {};
virtual bool Selectable() {return false;};
virtual bool Selectable()
{
return false;
}
;
virtual void Render();
};
class WDecoStyled: public WGuiDeco{
class WDecoStyled: public WGuiDeco
{
public:
WDecoStyled(WGuiItem * _it) : WGuiDeco(_it) {mStyle=DS_DEFAULT;};
WDecoStyled(WGuiItem * _it) :
WGuiDeco(_it)
{
mStyle = DS_DEFAULT;
}
;
PIXEL_TYPE getColor(int type);
void subBack(WGuiBase * item);
enum {
DS_DEFAULT = (1<<0),
DS_COLOR_BRIGHT = (1<<1),
DS_COLOR_DARK = (1<<2),
DS_STYLE_ALERT = (1<<3),
DS_STYLE_EDGED = (1<<4),
DS_STYLE_BACKLESS = (1<<5),
enum
{
DS_DEFAULT = (1 << 0), DS_COLOR_BRIGHT = (1 << 1), DS_COLOR_DARK = (1 << 2), DS_STYLE_ALERT = (1 << 3),
DS_STYLE_EDGED = (1 << 4), DS_STYLE_BACKLESS = (1 << 5),
};
u8 mStyle;
};
class WGuiMenu: public WGuiItem{
class WGuiMenu: public WGuiItem
{
public:
friend class WGuiFilters;
virtual ~WGuiMenu();
@@ -381,9 +685,17 @@ public:
virtual void subBack(WGuiBase * item);
virtual bool CheckUserInput(JButton key);
WGuiBase * Current();
virtual int getSelected() {return currentItem;};
virtual void setSelected(vector<WGuiBase*>::iterator& it) {
int c = it - items.begin();setSelected(c);};
virtual int getSelected()
{
return currentItem;
}
;
virtual void setSelected(vector<WGuiBase*>::iterator& it)
{
int c = it - items.begin();
setSelected(c);
}
;
virtual void setSelected(int newItem);
virtual bool nextItem();
virtual bool prevItem();
@@ -403,7 +715,8 @@ protected:
float duration;
};
class WGuiList: public WGuiMenu{
class WGuiList: public WGuiMenu
{
public:
WGuiList(string name, WSyncable * syncme = NULL);
@@ -417,7 +730,8 @@ class WGuiList: public WGuiMenu{
protected:
bool mFocus;
};
class WGuiTabMenu: public WGuiMenu {
class WGuiTabMenu: public WGuiMenu
{
public:
WGuiTabMenu() : WGuiMenu(JGE_BTN_NEXT, JGE_BTN_PREV) {};
virtual void Render();
@@ -425,13 +739,15 @@ class WGuiTabMenu: public WGuiMenu {
void save();
virtual bool CheckUserInput(JButton key);
};
class WGuiListRow: public WGuiList{
class WGuiListRow: public WGuiList
{
public:
WGuiListRow(string n, WSyncable * s = NULL);
virtual void Render();
};
class WGuiFilters: public WGuiItem {
class WGuiFilters: public WGuiItem
{
public:
friend class WGuiFilterItem;
WGuiFilters(string header, WSrcCards * src);
@@ -446,7 +762,11 @@ public:
bool isAvailable(int type);
bool isAvailableCode(string code);
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 buildList();
void setSrc(WSrcCards * wsc);
@@ -461,7 +781,8 @@ protected:
WGuiList * list;
};
class WGuiFilterItem: public WGuiItem {
class WGuiFilterItem: public WGuiItem
{
public:
friend class WGuiFilters;
friend struct WLFiltersSort;
@@ -470,7 +791,8 @@ public:
void ButtonPressed(int controllerId, int controlId);
string getCode();
bool isModal();
enum {
enum
{
STATE_UNSET,
STATE_CHOOSE_TYPE,
STATE_CHOOSE_VAL,
@@ -500,15 +822,18 @@ protected:
WGuiFilters * mParent;
};
struct WListSort{
struct WListSort
{
virtual bool operator()(const WGuiBase*l, const WGuiBase*r);
};
struct WLFiltersSort{
struct WLFiltersSort
{
bool operator()(const WGuiBase*l, const WGuiBase*r);
};
class WGuiKeyBinder : public WGuiList {
class WGuiKeyBinder: public WGuiList
{
public:
WGuiKeyBinder(string name, GameStateOptions* parent);
virtual bool isModal();
+16 -11
View File
@@ -20,7 +20,6 @@
#define MAX_CACHE_TIME 2000000000
#endif
#define THUMBNAILS_OFFSET 100000000
#define OTHERS_OFFSET 2000000000
@@ -31,15 +30,17 @@
#define MAX_CACHED_SAMPLES 50
#define MAX_CACHE_GARBAGE 10
enum ENUM_WRES_INFO{
enum ENUM_WRES_INFO
{
WRES_UNLOCKED = 0, //Resource is unlocked.
WRES_MAX_LOCK = 250, //Maximum number of locks for a resource.
WRES_PERMANENT = 251, //Resource is permanent (ie, managed)
WRES_UNDERLOCKED = 252, //Resource was released too many times.
WRES_UNDERLOCKED = 252,
//Resource was released too many times.
};
enum ENUM_RETRIEVE_STYLE{
enum ENUM_RETRIEVE_STYLE
{
RETRIEVE_EXISTING, //Only returns a resource if it already exists. Does not lock or unlock.
RETRIEVE_NORMAL, //Returns or creates a resource. Does not change lock status.
RETRIEVE_LOCK, //As above, locks cached resource. Not for quads.
@@ -47,10 +48,12 @@ enum ENUM_RETRIEVE_STYLE{
RETRIEVE_RESOURCE, //Only retrieves a managed resource. Does not make a new one.
RETRIEVE_MANAGE, //Makes resource permanent.
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
@@ -60,11 +63,13 @@ enum ENUM_CACHE_SUBTYPE{
TEXTURE_SUB_CARD = (1 << 3), //Retrieve using cardFile, 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_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_NOT_CACHED = CACHE_ERROR_NONE,
CACHE_ERROR_404,
@@ -74,7 +79,8 @@ enum ENUM_CACHE_ERROR{
CACHE_ERROR_NOT_MANAGED,
};
struct WCacheSort{
struct WCacheSort
{
bool operator()(const WResource * l, const WResource * r); //Predicate for use in sorting. See flatten().
};
@@ -119,7 +125,6 @@ protected:
int mError;
};
struct WManagedQuad
{
WCachedTexture * texture;
-5
View File
@@ -12,12 +12,8 @@
#define OutputDebugString(val) {}
#endif
#include "limits.h"
#if defined (_DEBUG) && defined (WIN32)
#include "crtdbg.h"
#define NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
@@ -38,7 +34,6 @@
#endif
#endif
#ifndef RESPATH
#define RESPATH "Res"
#endif
-3
View File
@@ -20,7 +20,6 @@
#endif
#include <math.h>
#include <stdio.h>
#include <string>
@@ -72,7 +71,6 @@ typedef std::ifstream ifstream;
using std::string;
//string manipulation methods
string& trim(string& str);
string& ltrim(string& str);
@@ -93,7 +91,6 @@ int WRand();
void dumpStack();
#endif
/* RAM simple check functions header */
// *** DEFINES ***