* Remove ^M's.
* Re-indent automatically.
* Remove whitespace at the end of lines.
This commit is contained in:
jean.chalard
2008-11-12 13:45:42 +00:00
parent 6ad6f9b668
commit c97dd1f260
116 changed files with 18073 additions and 18073 deletions
+62 -62
View File
@@ -1,62 +1,62 @@
/*
* Wagic, The Homebrew ?! is licensed under the BSD license
* See LICENSE in the Folder's root
* http://wololo.net/wagic/
*/
#ifndef _IAPLAYER_H
#define _IAPLAYER_H
#include "Player.h"
#define INFO_NBCREATURES 0
#define INFO_CREATURESPOWER 1
class AIStats;
class AIPlayer: public Player{
protected:
MTGCardInstance * nextCardToPlay;
ManaCost * potentialMana;
void tapLandsForMana(ManaCost * potentialMana, ManaCost * cost);
int checkInterrupt();
int combatDamages();
int chooseAttackers();
int chooseBlockers();
int effectBadOrGood(MTGCardInstance * card);
int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0);
AIStats * getStats();
public:
virtual int displayStack(){return 0;}
AIStats * stats;
ManaCost * getPotentialMana();
AIPlayer(MTGPlayerCards * _deck, string deckFile);
virtual ~AIPlayer();
virtual MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0);
virtual int chooseTarget(TargetChooser * tc = NULL);
virtual int Act(float dt);
int isAI(){return 1;};
};
class AIPlayerBaka: public AIPlayer{
protected:
int oldGamePhase;
int timer;
MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type);
public:
AIPlayerBaka(MTGPlayerCards * _deck, char * deckFile);
virtual int Act(float dt);
void initTimer();
};
class AIPlayerFactory{
public:
AIPlayer * createAIPlayer(MTGAllCards * collection, MTGPlayerCards * oponents_deck);
};
#endif
/*
* Wagic, The Homebrew ?! is licensed under the BSD license
* See LICENSE in the Folder's root
* http://wololo.net/wagic/
*/
#ifndef _IAPLAYER_H
#define _IAPLAYER_H
#include "Player.h"
#define INFO_NBCREATURES 0
#define INFO_CREATURESPOWER 1
class AIStats;
class AIPlayer: public Player{
protected:
MTGCardInstance * nextCardToPlay;
ManaCost * potentialMana;
void tapLandsForMana(ManaCost * potentialMana, ManaCost * cost);
int checkInterrupt();
int combatDamages();
int chooseAttackers();
int chooseBlockers();
int effectBadOrGood(MTGCardInstance * card);
int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0);
AIStats * getStats();
public:
virtual int displayStack(){return 0;}
AIStats * stats;
ManaCost * getPotentialMana();
AIPlayer(MTGPlayerCards * _deck, string deckFile);
virtual ~AIPlayer();
virtual MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0);
virtual int chooseTarget(TargetChooser * tc = NULL);
virtual int Act(float dt);
int isAI(){return 1;};
};
class AIPlayerBaka: public AIPlayer{
protected:
int oldGamePhase;
int timer;
MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type);
public:
AIPlayerBaka(MTGPlayerCards * _deck, char * deckFile);
virtual int Act(float dt);
void initTimer();
};
class AIPlayerFactory{
public:
AIPlayer * createAIPlayer(MTGAllCards * collection, MTGPlayerCards * oponents_deck);
};
#endif
+39 -39
View File
@@ -1,42 +1,42 @@
#ifndef _AISTATS_H_
#define _AISTATS_H_
#define STATS_PLAYER_MULTIPLIER 15
#define STATS_CREATURE_MULTIPLIER 10
#define STATS_AURA_MULTIPLIER 9
#ifndef _AISTATS_H_
#define _AISTATS_H_
#define STATS_PLAYER_MULTIPLIER 15
#define STATS_CREATURE_MULTIPLIER 10
#define STATS_AURA_MULTIPLIER 9
#include <list>
#include <string>
using std::list;
using std::string;
class Player;
class MTGCardInstance;
class MTGCard;
class Damage;
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){};
};
class AIStats{
public:
Player * player;
string filename;
list<AIStat *> stats;
AIStats(Player * _player, char * filename);
~AIStats();
void updateStats();
void load(char * filename);
void save();
AIStat * find(MTGCard * card);
bool isInTop(MTGCardInstance * card, unsigned int max, bool tooSmallCountsForTrue = true );
void updateStatsCard(MTGCardInstance * cardInstance, Damage * damage, float multiplier = 1.0);
};
using std::list;
using std::string;
class Player;
class MTGCardInstance;
class MTGCard;
class Damage;
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){};
};
class AIStats{
public:
Player * player;
string filename;
list<AIStat *> stats;
AIStats(Player * _player, char * filename);
~AIStats();
void updateStats();
void load(char * filename);
void save();
AIStat * find(MTGCard * card);
bool isInTop(MTGCardInstance * card, unsigned int max, bool tooSmallCountsForTrue = true );
void updateStatsCard(MTGCardInstance * cardInstance, Damage * damage, float multiplier = 1.0);
};
#endif
+26 -26
View File
@@ -1,8 +1,8 @@
/*
* Wagic, The Homebrew ?! is licensed under the BSD license
* See LICENSE in the Folder's root
* http://wololo.net/wagic/
*/
/*
* Wagic, The Homebrew ?! is licensed under the BSD license
* See LICENSE in the Folder's root
* http://wololo.net/wagic/
*/
#ifndef _ACTIONELEMENT_H_
#define _ACTIONELEMENT_H_
@@ -18,30 +18,30 @@ class Targetable;
class TargetChooser;
class ActionElement: public JGuiObject{
protected:
int activeState;
protected:
int activeState;
public:
TargetChooser * tc;
int currentPhase;
int newPhase;
int modal;
int waitingForAnswer;
public:
TargetChooser * tc;
int currentPhase;
int newPhase;
int modal;
int waitingForAnswer;
void RenderMessageBackground(float y0, int height);
int getActivity();
virtual void Update(float dt){};
virtual void Render(){};
virtual int testDestroy(){return 0;};
virtual int destroy(){return 0;};
virtual void CheckUserInput(float dt){};
ActionElement(int id);
virtual int isReactingToTargetClick(Targetable * card);
virtual int reactToTargetClick(Targetable * card);
virtual int isReactingToClick(MTGCardInstance * card){return 0;};
virtual int reactToClick(MTGCardInstance * card){return 0;};
virtual const char * getMenuText(){return "Ability";};
int getActivity();
virtual void Update(float dt){};
virtual void Render(){};
virtual int testDestroy(){return 0;};
virtual int destroy(){return 0;};
virtual void CheckUserInput(float dt){};
ActionElement(int id);
virtual int isReactingToTargetClick(Targetable * card);
virtual int reactToTargetClick(Targetable * card);
virtual int isReactingToClick(MTGCardInstance * card){return 0;};
virtual int reactToClick(MTGCardInstance * card){return 0;};
virtual const char * getMenuText(){return "Ability";};
};
+21 -21
View File
@@ -1,8 +1,8 @@
/*
* Wagic, The Homebrew ?! is licensed under the BSD license
* See LICENSE in the Folder's root
* http://wololo.net/wagic/
*/
/*
* Wagic, The Homebrew ?! is licensed under the BSD license
* See LICENSE in the Folder's root
* http://wololo.net/wagic/
*/
#ifndef _ACTIONLAYER_H_
#define _ACTIONLAYER_H_
@@ -16,22 +16,22 @@ class Targetable;
class ActionLayer: public GuiLayer, public JGuiListener{
public:
Targetable * menuObject;
SimpleMenu * abilitiesMenu;
virtual void Render();
virtual void Update(float dt);
int unstopableRenderInProgress();
void CheckUserInput(float dt);
ActionLayer(int id, GameObserver* _game):GuiLayer(id, _game){ menuObject = NULL; abilitiesMenu = NULL;};
int isWaitingForAnswer();
int isReactingToTargetClick(Targetable * card);
int reactToTargetClick(Targetable * card);
int isReactingToClick(MTGCardInstance * card);
int reactToClick(MTGCardInstance * card);
int isModal();
void setMenuObject(Targetable * object);
void ButtonPressed(int controllerid, int controlid);
TargetChooser * getCurrentTargetChooser();
Targetable * menuObject;
SimpleMenu * abilitiesMenu;
virtual void Render();
virtual void Update(float dt);
int unstopableRenderInProgress();
void CheckUserInput(float dt);
ActionLayer(int id, GameObserver* _game):GuiLayer(id, _game){ menuObject = NULL; abilitiesMenu = NULL;};
int isWaitingForAnswer();
int isReactingToTargetClick(Targetable * card);
int reactToTargetClick(Targetable * card);
int isReactingToClick(MTGCardInstance * card);
int reactToClick(MTGCardInstance * card);
int isModal();
void setMenuObject(Targetable * object);
void ButtonPressed(int controllerid, int controlid);
TargetChooser * getCurrentTargetChooser();
};
+151 -151
View File
@@ -1,151 +1,151 @@
/*
* Wagic, The Homebrew ?! is licensed under the BSD license
* See LICENSE in the Folder's root
* http://wololo.net/wagic/
*/
#ifndef _SPELLSTACK_H_
#define _SPELLSTACK_H_
#define MAX_SPELL_TARGETS 10
#define ACTION_SPELL 10
#define ACTION_DAMAGE 11
#define ACTION_DAMAGES 12
#define ACTION_NEXTGAMEPHASE 13
#define ACTION_DRAW 14
#define ACTION_PUTINGRAVEYARD 15
#define ACTION_ABILITY 16
#define NOT_RESOLVED -2
#define RESOLVED_OK 1
#define RESOLVED_NOK -1
#include "../include/PlayGuiObject.h"
#include "GuiLayers.h"
#include "../include/TargetsList.h"
#include "../include/Targetable.h"
class GuiLayer;
class PlayGuiObject;
class MTGCardInstance;
class GameObserver;
class Player;
class Damageable;
class MTGAbility;
class Targetable;
class DamageStack;
class ManaCost;
#define ACTIONSTACK_STANDARD 0
#define ACTIONSTACK_TARGET 1
class Interruptible: public PlayGuiObject, public Targetable{
public:
int state, display;
MTGCardInstance * source;
virtual void Entering(){mHasFocus = true;};
virtual bool Leaving(u32 key){mHasFocus = false;return true;};
virtual bool ButtonPressed(){return true;};
virtual int resolve(){return 0;};
virtual void Render(){};
int typeAsTarget(){return TARGET_STACKACTION;};
Interruptible(int id,bool hasFocus = false):PlayGuiObject(id,40,x,y,hasFocus){state=NOT_RESOLVED;display=0;source=NULL;};
};
class NextGamePhase: public Interruptible {
public:
int resolve();
void Render();
NextGamePhase(int id);
};
class Spell: public Interruptible, public TargetsList {
protected:
public:
ManaCost * cost;
Spell(MTGCardInstance* _source);
Spell(int id, MTGCardInstance* _source, Targetable * _targets[], int _nbtargets, ManaCost * _cost);
~Spell();
int resolve();
void Render();
};
class StackAbility: public Interruptible {
public:
MTGAbility * ability;
int resolve();
void Render();
StackAbility(int id, MTGAbility * _ability);
};
class PutInGraveyard: public Interruptible {
public:
MTGCardInstance * card;
int removeFromGame;
int resolve();
void Render();
PutInGraveyard(int id, MTGCardInstance * _card);
};
class DrawAction: public Interruptible {
public:
int nbcards;
Player * player;
int resolve();
void Render();
DrawAction(int id, Player * _player, int _nbcards);
};
class ActionStack :public GuiLayer{
protected:
int interruptDecision[2];
int timer;
int currentState;
int mode;
int checked;
void unpackDamageStacks();
void unpackDamageStack(DamageStack * ds);
void repackDamageStacks();
public:
int setIsInterrupting(Player * player);
int count( int type = 0 , int state = 0 , int display = -1);
Interruptible * getPrevious(Interruptible * next, int type = 0, int state = 0 , int display = -1);
int getPreviousIndex(Interruptible * next, int type = 0, int state = 0 , int display = -1);
Interruptible * getNext(Interruptible * previous, int type = 0, int state = 0 , int display = -1);
int getNextIndex(Interruptible * previous, int type = 0, int state = 0 , int display = -1);
void Fizzle(Interruptible * action);
Interruptible * _(int id);
void cancelInterruptOffer(int cancelMode = 1);
void endOfInterruption();
Interruptible * getLatest(int state);
Player * askIfWishesToInterrupt;
int garbageCollect();
int addAction(Interruptible * interruptible);
int addSpell(MTGCardInstance* card, Targetable * targets[], int nbtargets, ManaCost * mana);
int AddNextGamePhase();
int addPutInGraveyard(MTGCardInstance * card);
int addDraw(Player * player, int nbcards = 1);
int addDamage(MTGCardInstance * _source, Damageable * target, int _damage);
int addAbility(MTGAbility * ability);
void Update(float dt);
void CheckUserInput(float dt);
virtual void Render();
ActionStack(int id, GameObserver* _game);
int resolve();
int CombatDamages();
int CombatDamages(int firststrike);
int has(Interruptible * action);
};
#endif
/*
* Wagic, The Homebrew ?! is licensed under the BSD license
* See LICENSE in the Folder's root
* http://wololo.net/wagic/
*/
#ifndef _SPELLSTACK_H_
#define _SPELLSTACK_H_
#define MAX_SPELL_TARGETS 10
#define ACTION_SPELL 10
#define ACTION_DAMAGE 11
#define ACTION_DAMAGES 12
#define ACTION_NEXTGAMEPHASE 13
#define ACTION_DRAW 14
#define ACTION_PUTINGRAVEYARD 15
#define ACTION_ABILITY 16
#define NOT_RESOLVED -2
#define RESOLVED_OK 1
#define RESOLVED_NOK -1
#include "../include/PlayGuiObject.h"
#include "GuiLayers.h"
#include "../include/TargetsList.h"
#include "../include/Targetable.h"
class GuiLayer;
class PlayGuiObject;
class MTGCardInstance;
class GameObserver;
class Player;
class Damageable;
class MTGAbility;
class Targetable;
class DamageStack;
class ManaCost;
#define ACTIONSTACK_STANDARD 0
#define ACTIONSTACK_TARGET 1
class Interruptible: public PlayGuiObject, public Targetable{
public:
int state, display;
MTGCardInstance * source;
virtual void Entering(){mHasFocus = true;};
virtual bool Leaving(u32 key){mHasFocus = false;return true;};
virtual bool ButtonPressed(){return true;};
virtual int resolve(){return 0;};
virtual void Render(){};
int typeAsTarget(){return TARGET_STACKACTION;};
Interruptible(int id,bool hasFocus = false):PlayGuiObject(id,40,x,y,hasFocus){state=NOT_RESOLVED;display=0;source=NULL;};
};
class NextGamePhase: public Interruptible {
public:
int resolve();
void Render();
NextGamePhase(int id);
};
class Spell: public Interruptible, public TargetsList {
protected:
public:
ManaCost * cost;
Spell(MTGCardInstance* _source);
Spell(int id, MTGCardInstance* _source, Targetable * _targets[], int _nbtargets, ManaCost * _cost);
~Spell();
int resolve();
void Render();
};
class StackAbility: public Interruptible {
public:
MTGAbility * ability;
int resolve();
void Render();
StackAbility(int id, MTGAbility * _ability);
};
class PutInGraveyard: public Interruptible {
public:
MTGCardInstance * card;
int removeFromGame;
int resolve();
void Render();
PutInGraveyard(int id, MTGCardInstance * _card);
};
class DrawAction: public Interruptible {
public:
int nbcards;
Player * player;
int resolve();
void Render();
DrawAction(int id, Player * _player, int _nbcards);
};
class ActionStack :public GuiLayer{
protected:
int interruptDecision[2];
int timer;
int currentState;
int mode;
int checked;
void unpackDamageStacks();
void unpackDamageStack(DamageStack * ds);
void repackDamageStacks();
public:
int setIsInterrupting(Player * player);
int count( int type = 0 , int state = 0 , int display = -1);
Interruptible * getPrevious(Interruptible * next, int type = 0, int state = 0 , int display = -1);
int getPreviousIndex(Interruptible * next, int type = 0, int state = 0 , int display = -1);
Interruptible * getNext(Interruptible * previous, int type = 0, int state = 0 , int display = -1);
int getNextIndex(Interruptible * previous, int type = 0, int state = 0 , int display = -1);
void Fizzle(Interruptible * action);
Interruptible * _(int id);
void cancelInterruptOffer(int cancelMode = 1);
void endOfInterruption();
Interruptible * getLatest(int state);
Player * askIfWishesToInterrupt;
int garbageCollect();
int addAction(Interruptible * interruptible);
int addSpell(MTGCardInstance* card, Targetable * targets[], int nbtargets, ManaCost * mana);
int AddNextGamePhase();
int addPutInGraveyard(MTGCardInstance * card);
int addDraw(Player * player, int nbcards = 1);
int addDamage(MTGCardInstance * _source, Damageable * target, int _damage);
int addAbility(MTGAbility * ability);
void Update(float dt);
void CheckUserInput(float dt);
virtual void Render();
ActionStack(int id, GameObserver* _game);
int resolve();
int CombatDamages();
int CombatDamages(int firststrike);
int has(Interruptible * action);
};
#endif
File diff suppressed because it is too large Load Diff
+26 -26
View File
@@ -13,36 +13,36 @@ class GameObserver;
class MTGAbility;
class Blocker : public MTGAbility {
protected:
ManaCost * manaCost;
int currentPhase;
void init(ManaCost * _cost);
public:
virtual ManaCost * untapManaCost(){return manaCost;};
virtual int unblock(){return 1;};
Blocker(int id, MTGCardInstance * card, ManaCost * _cost);
Blocker(int id, MTGCardInstance * card);
Blocker(int id, MTGCardInstance * card, MTGCardInstance *_target, ManaCost * _cost);
~Blocker();
virtual void Update(float dt);
virtual int destroy();
protected:
ManaCost * manaCost;
int currentPhase;
void init(ManaCost * _cost);
public:
virtual ManaCost * untapManaCost(){return manaCost;};
virtual int unblock(){return 1;};
Blocker(int id, MTGCardInstance * card, ManaCost * _cost);
Blocker(int id, MTGCardInstance * card);
Blocker(int id, MTGCardInstance * card, MTGCardInstance *_target, ManaCost * _cost);
~Blocker();
virtual void Update(float dt);
virtual int destroy();
};
class Blockers {
protected:
int cursor;
int blockers[MAX_BLOCKERS];
GameObserver * game;
public:
Blockers();
~Blockers();
int Add (Blocker * ability);
int Remove (Blocker * ability);
int init();
Blocker * next();
int rewind();
int isEmpty();
protected:
int cursor;
int blockers[MAX_BLOCKERS];
GameObserver * game;
public:
Blockers();
~Blockers();
int Add (Blocker * ability);
int Remove (Blocker * ability);
int init();
Blocker * next();
int rewind();
int isEmpty();
};
+12 -12
View File
@@ -1,5 +1,5 @@
/*
A Filter/Mask system for Card Instances to find cards matching specific settings such as color, type, etc...
A Filter/Mask system for Card Instances to find cards matching specific settings such as color, type, etc...
*/
#ifndef _CARDDESCRIPTOR_H_
@@ -12,16 +12,16 @@ A Filter/Mask system for Card Instances to find cards matching specific settings
#define CD_AND 2
class CardDescriptor: public MTGCardInstance{
protected:
MTGCardInstance * match_or(MTGCardInstance * card);
MTGCardInstance * match_and(MTGCardInstance * card);
public:
int mode;
int init();
CardDescriptor();
MTGCardInstance * match(MTGCardInstance * card);
MTGCardInstance * match(MTGGameZone * zone);
MTGCardInstance * nextmatch(MTGGameZone * zone, MTGCardInstance * previous);
protected:
MTGCardInstance * match_or(MTGCardInstance * card);
MTGCardInstance * match_and(MTGCardInstance * card);
public:
int mode;
int init();
CardDescriptor();
MTGCardInstance * match(MTGCardInstance * card);
MTGCardInstance * match(MTGGameZone * zone);
MTGCardInstance * nextmatch(MTGGameZone * zone, MTGCardInstance * previous);
};
#endif
#endif
+32 -32
View File
@@ -1,32 +1,32 @@
#ifndef _CARD_DISPLAY_H_
#define _CARD_DISPLAY_H_
#include "../include/PlayGuiObjectController.h"
class TargetChooser;
class MTGGameZone;
class MTGCardInstance;
class CardDisplay:public PlayGuiObjectController{
public:
int x, y , start_item, nb_displayed_items;
TargetChooser * tc;
JGuiListener * listener;
CardDisplay();
CardDisplay(int id, GameObserver* _game, int _x, int _y, JGuiListener * _listener, TargetChooser * _tc = NULL, int _nb_displayed_items = 7 );
void AddCard(MTGCardInstance * _card);
void rotateLeft();
void rotateRight();
void CheckUserInput(float dt);
void Render();
void init(MTGGameZone * zone);
};
class DefaultTargetDisplay:CardDisplay{
public:
DefaultTargetDisplay(int id, GameObserver* _game, int _x, int _y, JGuiListener * _listener, int _nb_displayed_items );
~DefaultTargetDisplay();
};
#endif
#ifndef _CARD_DISPLAY_H_
#define _CARD_DISPLAY_H_
#include "../include/PlayGuiObjectController.h"
class TargetChooser;
class MTGGameZone;
class MTGCardInstance;
class CardDisplay:public PlayGuiObjectController{
public:
int x, y , start_item, nb_displayed_items;
TargetChooser * tc;
JGuiListener * listener;
CardDisplay();
CardDisplay(int id, GameObserver* _game, int _x, int _y, JGuiListener * _listener, TargetChooser * _tc = NULL, int _nb_displayed_items = 7 );
void AddCard(MTGCardInstance * _card);
void rotateLeft();
void rotateRight();
void CheckUserInput(float dt);
void Render();
void init(MTGGameZone * zone);
};
class DefaultTargetDisplay:CardDisplay{
public:
DefaultTargetDisplay(int id, GameObserver* _game, int _x, int _y, JGuiListener * _listener, int _nb_displayed_items );
~DefaultTargetDisplay();
};
#endif
+7 -7
View File
@@ -12,18 +12,18 @@ class MTGCardInstance;
class PlayGuiObject;
class CardGui: public PlayGuiObject{
protected:
hgeParticleSystem * mParticleSys;
int alpha;
protected:
hgeParticleSystem * mParticleSys;
int alpha;
public:
MTGCardInstance * card;
CardGui(int id, MTGCardInstance * _card, float desiredHeight, float _x=0, float _y=0, bool hasFocus = false);
virtual void Render();
virtual void Update(float dt);
virtual void Update(float dt);
void RenderBig(float x=-1, float y = -1);
static void alternateRender(MTGCard * card, JLBFont * mFont, JQuad ** manaIcons, float x, float y, float rotation= 0, float scale=1);
~CardGui();
void RenderBig(float x=-1, float y = -1);
static void alternateRender(MTGCard * card, JLBFont * mFont, JQuad ** manaIcons, float x, float y, float rotation= 0, float scale=1);
~CardGui();
};
+3 -3
View File
@@ -6,9 +6,9 @@
class ConstraintResolver {
protected:
public:
static int untap(GameObserver * game, MTGCardInstance * card);
protected:
public:
static int untap(GameObserver * game, MTGCardInstance * card);
};
#endif
+43 -43
View File
@@ -1,43 +1,43 @@
#ifndef _COUNTERS_H_
#define _COUNTERS_H_
#include <string>
using std::string;
class MTGCardInstance;
/* One family of counters. Ex : +1/+1 */
class Counter{
public :
string name;
int nb;
int power, toughness;
MTGCardInstance * target;
Counter(MTGCardInstance * _target, int _power, int _toughness);
Counter(MTGCardInstance * _target, const char * _name,int _power = 0 , int _toughness = 0 );
int init(MTGCardInstance * _target,const char * _name, int _power, int _toughness);
bool sameAs(const char * _name, int _power, int _toughness);
bool cancels(int _power, int _toughness);
int added();
int removed();
};
/* Various families of counters attached to an instance of a card */
class Counters{
public:
int mCount;
Counter * counters[10];
MTGCardInstance * target;
Counters(MTGCardInstance * _target);
~Counters();
int addCounter(const char * _name,int _power = 0, int _toughness = 0);
int addCounter(int _power, int _toughness);
int removeCounter(const char * _name,int _power = 0, int _toughness = 0);
int removeCounter(int _power, int _toughness);
Counter * hasCounter(const char * _name,int _power = 0, int _toughness = 0);
Counter * hasCounter(int _power, int _toughness);
Counter * getNext(Counter * previous = NULL);
};
#endif
#ifndef _COUNTERS_H_
#define _COUNTERS_H_
#include <string>
using std::string;
class MTGCardInstance;
/* One family of counters. Ex : +1/+1 */
class Counter{
public :
string name;
int nb;
int power, toughness;
MTGCardInstance * target;
Counter(MTGCardInstance * _target, int _power, int _toughness);
Counter(MTGCardInstance * _target, const char * _name,int _power = 0 , int _toughness = 0 );
int init(MTGCardInstance * _target,const char * _name, int _power, int _toughness);
bool sameAs(const char * _name, int _power, int _toughness);
bool cancels(int _power, int _toughness);
int added();
int removed();
};
/* Various families of counters attached to an instance of a card */
class Counters{
public:
int mCount;
Counter * counters[10];
MTGCardInstance * target;
Counters(MTGCardInstance * _target);
~Counters();
int addCounter(const char * _name,int _power = 0, int _toughness = 0);
int addCounter(int _power, int _toughness);
int removeCounter(const char * _name,int _power = 0, int _toughness = 0);
int removeCounter(int _power, int _toughness);
Counter * hasCounter(const char * _name,int _power = 0, int _toughness = 0);
Counter * hasCounter(int _power, int _toughness);
Counter * getNext(Counter * previous = NULL);
};
#endif
+27 -27
View File
@@ -14,43 +14,43 @@ class GameObserver;
#define DAMAGEABLE_PLAYER 1
class Damageable {
protected:
protected:
public:
int life;
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 JQuad * getIcon(){return NULL;};
public:
int life;
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 JQuad * getIcon(){return NULL;};
};
class Damage: public Interruptible {
protected:
void init(MTGCardInstance * _source, Damageable * _target, int _damage);
public:
Damageable * target;
MTGCardInstance * source;
int damage;
void Render();
Damage(int id, MTGCardInstance* _source, Damageable * _target);
Damage(int id, MTGCardInstance* _source, Damageable * _target, int _damage);
int resolve();
protected:
void init(MTGCardInstance * _source, Damageable * _target, int _damage);
public:
Damageable * target;
MTGCardInstance * source;
int damage;
void Render();
Damage(int id, MTGCardInstance* _source, Damageable * _target);
Damage(int id, MTGCardInstance* _source, Damageable * _target, int _damage);
int resolve();
};
class DamageStack :public GuiLayer, public Interruptible{
protected:
int currentState;
protected:
int currentState;
public:
int resolve();
void Render();
int CombatDamages();//Deprecated ?
int CombatDamages(int strike);
DamageStack(int id, GameObserver* _game);
public:
int resolve();
void Render();
int CombatDamages();//Deprecated ?
int CombatDamages(int strike);
DamageStack(int id, GameObserver* _game);
};
+38 -38
View File
@@ -1,38 +1,38 @@
#ifndef _DAMAGERESOLVERLAYER_H_
#define _DAMAGERESOLVERLAYER_H_
#include "../include/PlayGuiObjectController.h"
class MTGCardInstance;
class DamagerDamaged;
class DamageStack;
class DamageResolverLayer:public PlayGuiObjectController{
protected:
int trampleDamage();
public:
int buttonOk;
int currentPhase;
int remainingDamageSteps;
Player * currentChoosingPlayer;
DamageStack * damageStack;
DamagerDamaged * currentSource;
DamageResolverLayer(int id, GameObserver* _game);
int init();
int initResolve();
Player * whoSelectsDamagesDealtBy(MTGCardInstance * card);
int addAutoDamageToOpponents(MTGCardInstance * card);
int addIfNotExists(MTGCardInstance * card, Player * selecter);
int addDamager(MTGCardInstance * card, Player * selecter);
DamagerDamaged * findByCard(MTGCardInstance * card);
int canStopDealDamages();
int resolveDamages();
int isOpponent(DamagerDamaged * a, DamagerDamaged * b);
void nextPlayer();
virtual void Update(float dt);
virtual void CheckUserInput(float dt);
virtual void Render();
};
#endif
#ifndef _DAMAGERESOLVERLAYER_H_
#define _DAMAGERESOLVERLAYER_H_
#include "../include/PlayGuiObjectController.h"
class MTGCardInstance;
class DamagerDamaged;
class DamageStack;
class DamageResolverLayer:public PlayGuiObjectController{
protected:
int trampleDamage();
public:
int buttonOk;
int currentPhase;
int remainingDamageSteps;
Player * currentChoosingPlayer;
DamageStack * damageStack;
DamagerDamaged * currentSource;
DamageResolverLayer(int id, GameObserver* _game);
int init();
int initResolve();
Player * whoSelectsDamagesDealtBy(MTGCardInstance * card);
int addAutoDamageToOpponents(MTGCardInstance * card);
int addIfNotExists(MTGCardInstance * card, Player * selecter);
int addDamager(MTGCardInstance * card, Player * selecter);
DamagerDamaged * findByCard(MTGCardInstance * card);
int canStopDealDamages();
int resolveDamages();
int isOpponent(DamagerDamaged * a, DamagerDamaged * b);
void nextPlayer();
virtual void Update(float dt);
virtual void CheckUserInput(float dt);
virtual void Render();
};
#endif
+30 -30
View File
@@ -1,30 +1,30 @@
#ifndef _DAMAGERDAMAGED_H_
#define _DAMAGERDAMAGED_H_
#include "../include/CardGui.h"
class Player;
class DamagerDamaged:public CardGui{
public:
Player * damageSelecter;
int mCount;
Damage * damages[10];
int damageToDeal;
int dealOneDamage(DamagerDamaged * target);
int addDamage(int damage, DamagerDamaged * source);
int removeDamagesTo(DamagerDamaged * target);
int removeDamagesFrom(DamagerDamaged * source);
int sumDamages();
int hasLethalDamage();
DamagerDamaged(CardGui * cardg, Player * _damageSelecter, bool _hasFocus);
~DamagerDamaged();
void Render(Player * currentPlayer);
};
#endif
#ifndef _DAMAGERDAMAGED_H_
#define _DAMAGERDAMAGED_H_
#include "../include/CardGui.h"
class Player;
class DamagerDamaged:public CardGui{
public:
Player * damageSelecter;
int mCount;
Damage * damages[10];
int damageToDeal;
int dealOneDamage(DamagerDamaged * target);
int addDamage(int damage, DamagerDamaged * source);
int removeDamagesTo(DamagerDamaged * target);
int removeDamagesFrom(DamagerDamaged * source);
int sumDamages();
int hasLethalDamage();
DamagerDamaged(CardGui * cardg, Player * _damageSelecter, bool _hasFocus);
~DamagerDamaged();
void Render(Player * currentPlayer);
};
#endif
+46 -46
View File
@@ -1,48 +1,48 @@
#ifndef _DECKDATAWRAPPER_H_
#define _DECKDATAWRAPPER_H_
#include "../include/MTGDefinitions.h"
#include "../include/MTGCard.h"
#ifndef _DECKDATAWRAPPER_H_
#define _DECKDATAWRAPPER_H_
#include "../include/MTGDefinitions.h"
#include "../include/MTGCard.h"
#include <map>
#include <string>
using std::map;
using std::string;
class MTGDeck;
class Cmp1 { // compares cards by their name
public:
bool operator()(MTGCard * card1, MTGCard * card2) const {
if (!card2) return true;
if (!card1) return false;
string name1 = card1->name;
string name2 = card2->name;
int result = name1.compare(name2);
if (!result) return card1->getMTGId() < card2->getMTGId();
return ( result < 0);
}
};
class DeckDataWrapper{
public:
int colors[MTG_NB_COLORS+1];
int currentColor;
map<MTGCard *, int,Cmp1> cards;
int currentposition;
MTGDeck * parent;
DeckDataWrapper(MTGDeck * deck);
~DeckDataWrapper();
int Add(MTGCard * card);
int Remove(MTGCard * card);
MTGCard * getNext(MTGCard * previous = NULL, int color = -1);
MTGCard * getPrevious(MTGCard * next = NULL, int color = -1);
void updateCounts(MTGCard * card = NULL, int removed = 0);
void updateCurrentPosition(MTGCard * currentCard,int color = -1);
int getCount(int color = -1);
void save();
};
#endif
using std::map;
using std::string;
class MTGDeck;
class Cmp1 { // compares cards by their name
public:
bool operator()(MTGCard * card1, MTGCard * card2) const {
if (!card2) return true;
if (!card1) return false;
string name1 = card1->name;
string name2 = card2->name;
int result = name1.compare(name2);
if (!result) return card1->getMTGId() < card2->getMTGId();
return ( result < 0);
}
};
class DeckDataWrapper{
public:
int colors[MTG_NB_COLORS+1];
int currentColor;
map<MTGCard *, int,Cmp1> cards;
int currentposition;
MTGDeck * parent;
DeckDataWrapper(MTGDeck * deck);
~DeckDataWrapper();
int Add(MTGCard * card);
int Remove(MTGCard * card);
MTGCard * getNext(MTGCard * previous = NULL, int color = -1);
MTGCard * getPrevious(MTGCard * next = NULL, int color = -1);
void updateCounts(MTGCard * card = NULL, int removed = 0);
void updateCurrentPosition(MTGCard * currentCard,int color = -1);
int getCount(int color = -1);
void save();
};
#endif
+34 -34
View File
@@ -1,34 +1,34 @@
#ifndef _DUELLAYERS_H_
#define _DUELLAYERS_H_
#include "GuiLayers.h"
class MTGGuiHand;
class MTGGuiPlay;
class ActionLayer;
class ActionStack;
class DamageResolverLayer;
class DuelLayers: public GuiLayers{
public:
ActionLayer * actionLayer();
MTGGuiHand * handLayer();
MTGGuiPlay * playLayer();
ActionStack * stackLayer();
DamageResolverLayer * combatLayer();
void init();
};
#include "ActionLayer.h"
#include "GameObserver.h"
#include "MTGGamePhase.h"
#include "MTGGuiHand.h"
#include "MTGGuiPlay.h"
#include "ActionStack.h"
#include "Damage.h"
#endif
#ifndef _DUELLAYERS_H_
#define _DUELLAYERS_H_
#include "GuiLayers.h"
class MTGGuiHand;
class MTGGuiPlay;
class ActionLayer;
class ActionStack;
class DamageResolverLayer;
class DuelLayers: public GuiLayers{
public:
ActionLayer * actionLayer();
MTGGuiHand * handLayer();
MTGGuiPlay * playLayer();
ActionStack * stackLayer();
DamageResolverLayer * combatLayer();
void init();
};
#include "ActionLayer.h"
#include "GameObserver.h"
#include "MTGGamePhase.h"
#include "MTGGuiHand.h"
#include "MTGGuiPlay.h"
#include "ActionStack.h"
#include "Damage.h"
#endif
+88 -88
View File
@@ -1,88 +1,88 @@
/*
* Wagic, The Homebrew ?! is licensed under the BSD license
* See LICENSE in the Folder's root
* http://wololo.net/wagic/
*/
#ifndef _GAMEAPP_H_
#define _GAMEAPP_H_
#include "../include/Logger.h"
#include <JApp.h>
#include <JGE.h>
#include <JSprite.h>
#include <JLBFont.h>
#include <hge/hgeparticle.h>
#include <JResourceManager.h>
#include "../include/GameState.h"
#include "../include/MTGDeck.h"
#include "../include/MTGCard.h"
#include "../include/MTGGameZones.h"
#include "../include/TexturesCache.h"
#define MAX_STATE 6
#define PLAYER_TYPE_CPU 0
#define PLAYER_TYPE_HUMAN 1
#define PLAYER_TYPE_TESTSUITE 2
class MTGAllCards;
class TexturesCache;
class GameApp: public JApp
{
private:
bool mShowDebugInfo;
int mScreenShotCount;
GameState* mCurrentState;
GameState* mNextState;
GameState* mGameStates[MAX_STATE];
public:
int players[2];
MTGAllCards * collection;
TexturesCache * cache;
GameApp();
virtual ~GameApp();
virtual void Create();
virtual void Destroy();
virtual void Update();
virtual void Render();
virtual void Pause();
virtual void Resume();
void LoadGameStates();
void SetNextState(int state);
static JResourceManager * CommonRes;
static hgeParticleSystem * Particles[6];
static int HasMusic;
};
#endif
/*
* Wagic, The Homebrew ?! is licensed under the BSD license
* See LICENSE in the Folder's root
* http://wololo.net/wagic/
*/
#ifndef _GAMEAPP_H_
#define _GAMEAPP_H_
#include "../include/Logger.h"
#include <JApp.h>
#include <JGE.h>
#include <JSprite.h>
#include <JLBFont.h>
#include <hge/hgeparticle.h>
#include <JResourceManager.h>
#include "../include/GameState.h"
#include "../include/MTGDeck.h"
#include "../include/MTGCard.h"
#include "../include/MTGGameZones.h"
#include "../include/TexturesCache.h"
#define MAX_STATE 6
#define PLAYER_TYPE_CPU 0
#define PLAYER_TYPE_HUMAN 1
#define PLAYER_TYPE_TESTSUITE 2
class MTGAllCards;
class TexturesCache;
class GameApp: public JApp
{
private:
bool mShowDebugInfo;
int mScreenShotCount;
GameState* mCurrentState;
GameState* mNextState;
GameState* mGameStates[MAX_STATE];
public:
int players[2];
MTGAllCards * collection;
TexturesCache * cache;
GameApp();
virtual ~GameApp();
virtual void Create();
virtual void Destroy();
virtual void Update();
virtual void Render();
virtual void Pause();
virtual void Resume();
void LoadGameStates();
void SetNextState(int state);
static JResourceManager * CommonRes;
static hgeParticleSystem * Particles[6];
static int HasMusic;
};
#endif
+29 -29
View File
@@ -23,49 +23,49 @@ class TargetChooser;
class GameObserver{
protected:
int reaction;
static GameObserver * mInstance;
MTGCardInstance * cardWaitingForTargets;
int reaction;
static GameObserver * mInstance;
MTGCardInstance * cardWaitingForTargets;
int nbPlayers;
int currentPlayerId;
int currentRound;
int targetListIsSet(MTGCardInstance * card);
int targetListIsSet(MTGCardInstance * card);
public:
PhaseRing * phaseRing;
int cancelCurrentAction();
int currentGamePhase;
int oldGamePhase;
TargetChooser * targetChooser;
DuelLayers * mLayers;
Player * gameOver;
Player * players[2]; //created outside
int oldGamePhase;
TargetChooser * targetChooser;
DuelLayers * mLayers;
Player * gameOver;
Player * players[2]; //created outside
MTGGamePhase * gamePhaseManager; //Created Outside ?
TargetChooser * getCurrentTargetChooser();
void stackObjectClicked(Interruptible * action);
TargetChooser * getCurrentTargetChooser();
void stackObjectClicked(Interruptible * action);
void cardClick(MTGCardInstance * card,Targetable * _object = NULL );
int enteringPhase(int phase);
int getCurrentGamePhase();
void userRequestNextGamePhase();
void nextGamePhase();
void cleanupPhase();
void nextPlayer();
static void Init(Player * _players[], int _nbplayers);
static GameObserver * GetInstance();
static void EndInstance();
void cardClick(MTGCardInstance * card,Targetable * _object = NULL );
int enteringPhase(int phase);
int getCurrentGamePhase();
void userRequestNextGamePhase();
void nextGamePhase();
void cleanupPhase();
void nextPlayer();
static void Init(Player * _players[], int _nbplayers);
static GameObserver * GetInstance();
static void EndInstance();
Player * currentPlayer;
Player * currentActionPlayer;
Player * isInterrupting;
Player * opponent();
Player * currentlyActing();
Player * currentActionPlayer;
Player * isInterrupting;
Player * opponent();
Player * currentlyActing();
GameObserver(Player * _players[], int _nbplayers);
~GameObserver();
~GameObserver();
void setGamePhaseManager(MTGGamePhase * _phases);
void stateEffects();
void stateEffects();
void eventOccured();
void addObserver(MTGAbility * observer);
void removeObserver(ActionElement * observer);
@@ -73,7 +73,7 @@ class GameObserver{
void nextStep();
void untapPhase();
void draw();
int canPutInPlay(MTGCardInstance * card);
int canPutInPlay(MTGCardInstance * card);
void putInPlay(MTGCardInstance * card);
int isInPlay(MTGCardInstance * card);
int isACreature(MTGCardInstance * card);
+24 -24
View File
@@ -1,24 +1,24 @@
#ifndef _GAME_OPTIONS_H_
#define _GAME_OPTIONS_H_
#define MAX_OPTIONS 50
#define OPTIONS_MUSICVOLUME 0
#define OPTIONS_INTERRUPTATENDOFPHASE_OFFSET 1
#define OPTIONS_SAVEFILE "Res/settings/options.txt"
class GameOptions {
public:
int values[MAX_OPTIONS];
static GameOptions * GetInstance();
static void Destroy();
int save();
int load();
private:
GameOptions();
~GameOptions();
static GameOptions* mInstance;
};
#endif
#ifndef _GAME_OPTIONS_H_
#define _GAME_OPTIONS_H_
#define MAX_OPTIONS 50
#define OPTIONS_MUSICVOLUME 0
#define OPTIONS_INTERRUPTATENDOFPHASE_OFFSET 1
#define OPTIONS_SAVEFILE "Res/settings/options.txt"
class GameOptions {
public:
int values[MAX_OPTIONS];
static GameOptions * GetInstance();
static void Destroy();
int save();
int load();
private:
GameOptions();
~GameOptions();
static GameOptions* mInstance;
};
#endif
+46 -46
View File
@@ -1,46 +1,46 @@
#ifndef _GAME_STATE_H_
#define _GAME_STATE_H_
#define FADING_SPEED 350.0f
class JGE;
#include <JSoundSystem.h>
enum _gameSates
{
GAME_STATE_MENU,
GAME_STATE_DUEL,
GAME_STATE_DECK_VIEWER,
GAME_STATE_SHOP,
GAME_STATE_OPTIONS
};
class GameApp;
class GameState
{
protected:
GameApp* mParent;
JGE* mEngine;
public:
static const char * const menuTexts[];
GameState(GameApp* parent);
virtual ~GameState() {}
virtual void Create() {}
virtual void Destroy() {}
virtual void Start() {}
virtual void End() {}
virtual void Update(float dt) = 0;
virtual void Render() = 0;
};
#endif
#ifndef _GAME_STATE_H_
#define _GAME_STATE_H_
#define FADING_SPEED 350.0f
class JGE;
#include <JSoundSystem.h>
enum _gameSates
{
GAME_STATE_MENU,
GAME_STATE_DUEL,
GAME_STATE_DECK_VIEWER,
GAME_STATE_SHOP,
GAME_STATE_OPTIONS
};
class GameApp;
class GameState
{
protected:
GameApp* mParent;
JGE* mEngine;
public:
static const char * const menuTexts[];
GameState(GameApp* parent);
virtual ~GameState() {}
virtual void Create() {}
virtual void Destroy() {}
virtual void Start() {}
virtual void End() {}
virtual void Update(float dt) = 0;
virtual void Render() = 0;
};
#endif
File diff suppressed because it is too large Load Diff
+54 -54
View File
@@ -1,55 +1,55 @@
#ifndef _GAME_STATE_DUEL_H_
#define _GAME_STATE_DUEL_H_
#include "../include/GameState.h"
#include "_includeAll.h"
#include "../include/SimpleMenu.h"
#define DUEL_START 0
#define DUEL_END 1
#define DUEL_CHOOSE_DECK1 2
#define DUEL_CHOOSE_DECK2 3
#define ERROR_NO_DECK 4
#define DUEL_PLAY 5
#define DUEL_MENU 6
#ifdef TESTSUITE
class TestSuite;
#endif
class GameStateDuel: public GameState, public JGuiListener
{
private:
#ifdef TESTSUITE
TestSuite * testSuite;
#endif
int mGamePhase;
Player * mCurrentPlayer;
Player * mPlayers[2];
MTGPlayerCards * deck[2];
GameObserver * game;
SimpleMenu * deckmenu;
SimpleMenu * menu;
JLBFont* mFont;
void loadPlayer(int playerId, int decknb = 0);
public:
GameStateDuel(GameApp* parent);
virtual ~GameStateDuel();
#ifndef _GAME_STATE_DUEL_H_
#define _GAME_STATE_DUEL_H_
#include "../include/GameState.h"
#include "_includeAll.h"
#include "../include/SimpleMenu.h"
#define DUEL_START 0
#define DUEL_END 1
#define DUEL_CHOOSE_DECK1 2
#define DUEL_CHOOSE_DECK2 3
#define ERROR_NO_DECK 4
#define DUEL_PLAY 5
#define DUEL_MENU 6
#ifdef TESTSUITE
void loadTestSuitePlayers();
#endif
virtual void ButtonPressed(int ControllerId, int ControlId);
virtual void Start();
virtual void End();
virtual void Update(float dt);
virtual void Render();
};
#endif
class TestSuite;
#endif
class GameStateDuel: public GameState, public JGuiListener
{
private:
#ifdef TESTSUITE
TestSuite * testSuite;
#endif
int mGamePhase;
Player * mCurrentPlayer;
Player * mPlayers[2];
MTGPlayerCards * deck[2];
GameObserver * game;
SimpleMenu * deckmenu;
SimpleMenu * menu;
JLBFont* mFont;
void loadPlayer(int playerId, int decknb = 0);
public:
GameStateDuel(GameApp* parent);
virtual ~GameStateDuel();
#ifdef TESTSUITE
void loadTestSuitePlayers();
#endif
virtual void ButtonPressed(int ControllerId, int ControlId);
virtual void Start();
virtual void End();
virtual void Update(float dt);
virtual void Render();
};
#endif
+432 -432
View File
@@ -1,432 +1,432 @@
#ifndef _GAME_STATE_MENU_H_
#define _GAME_STATE_MENU_H_
#include <JGui.h>
#include <dirent.h>
#include "GameState.h"
#include "MenuItem.h"
#include "SimpleMenu.h"
#include "../include/GameOptions.h"
#define STATE_MENU 0
#define STATE_SUBMENU 1
#define STATE_LOADING_MENU 2
#define STATE_LOADING_CARDS 3
#define STATE_FIRST_TIME 4
#define STATE_WARNING 5
#define GAME_VERSION "WTH?! 0.2.2 - by WilLoW"
#define ALPHA_WARNING 0
class GameStateMenu: public GameState, public JGuiListener
{
private:
JGuiController* mGuiController;
SimpleMenu* subMenuController;
JLBFont* mFont;
JQuad * mIcons[10];
JTexture * mIconsTexture;
JTexture * bgTexture;
JQuad * mBg;
float mCreditsYPos;
int currentState;
JMusic * bgMusic;
int mVolume;
char nbcardsStr[400];
DIR *mDip;
struct dirent *mDit;
char mCurrentSetName[10];
char mCurrentSetFileName[512];
int mReadConf;
public:
GameStateMenu(GameApp* parent): GameState(parent)
{
mGuiController = NULL;
subMenuController = NULL;
mIconsTexture = NULL;
bgMusic = NULL;
}
virtual ~GameStateMenu()
{
}
virtual void Create()
{
mDip = NULL;
mReadConf = 0;
mCurrentSetName[0] = 0;
mIconsTexture = JRenderer::GetInstance()->LoadTexture("graphics/menuicons.png", TEX_TYPE_USE_VRAM);
bgTexture = JRenderer::GetInstance()->LoadTexture("graphics/menutitle.png", TEX_TYPE_USE_VRAM);
mBg = NEW JQuad(bgTexture, 10, 0, 220, 80); // Create background quad for rendering.
mBg->SetHotSpot(105,32);
//load all the icon images
int n = 0;
for (int i=0;i<5;i++)
{
for (int j=0;j<2;j++)
{
mIcons[n] = NEW JQuad(mIconsTexture, 10 + i*32, j*32, 32, 32);
mIcons[n]->SetHotSpot(16,16);
n++;
}
}
mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
//mFont->SetBase(0); // using 2nd font
mGuiController = NEW JGuiController(100, this);
//mGuiController->SetShadingBackground(10, 45, 80, 100, ARGB(255,0,0,0));
if (mGuiController)
{
mGuiController->Add(NEW MenuItem(1, mFont, "Play", 80, SCREEN_HEIGHT/2, mIcons[8], mIcons[9],"graphics/particle1.psi",GameApp::CommonRes->GetQuad("particles"), true));
mGuiController->Add(NEW MenuItem(2, mFont, "Deck Editor", 160, SCREEN_HEIGHT/2, mIcons[2], mIcons[3],"graphics/particle2.psi",GameApp::CommonRes->GetQuad("particles")));
mGuiController->Add(NEW MenuItem(3, mFont, "Shop", 240, SCREEN_HEIGHT/2, mIcons[0], mIcons[1],"graphics/particle3.psi",GameApp::CommonRes->GetQuad("particles")));
mGuiController->Add(NEW MenuItem(4, mFont, "Options", 320, SCREEN_HEIGHT/2, mIcons[6], mIcons[7],"graphics/particle4.psi",GameApp::CommonRes->GetQuad("particles")));
mGuiController->Add(NEW MenuItem(5, mFont, "Exit", 400, SCREEN_HEIGHT/2, mIcons[4], mIcons[5],"graphics/particle5.psi",GameApp::CommonRes->GetQuad("particles")));
}
currentState = STATE_LOADING_CARDS;
}
virtual void Destroy()
{
if (mGuiController)
delete mGuiController;
if (subMenuController)
delete subMenuController;
if (mIconsTexture)
delete mIconsTexture;
for (int i = 0; i < 10 ; i++){
delete mIcons[i];
}
if (mBg) delete mBg;
SAFE_DELETE (bgMusic);
}
virtual void Start(){
JRenderer::GetInstance()->ResetPrivateVRAM();
JRenderer::GetInstance()->EnableVSync(true);
if (GameApp::HasMusic && !bgMusic && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME] > 0){
bgMusic = JSoundSystem::GetInstance()->LoadMusic("sound/track0.mp3");
}
if (bgMusic){
mVolume = 0;
JSoundSystem::GetInstance()->SetVolume(mVolume);
JSoundSystem::GetInstance()->PlayMusic(bgMusic, true);
}
}
/* Retrieves the next set subfolder automatically
*/
int nextCardSet(){
int found = 0;
if (!mDip){
mDip = opendir("Res/sets/");
}
while (!found && (mDit = readdir(mDip))){
sprintf(mCurrentSetFileName, "Res/sets/%s/_cards.dat", mDit->d_name);
std::ifstream file(mCurrentSetFileName);
if(file){
sprintf(mCurrentSetName, "%s", mDit->d_name);
file.close();
found = 1;
}
}
if (!mDit) {
closedir(mDip);
mDip = NULL;
}
return found;
}
virtual void End()
{
//mEngine->EnableVSync(false);
if (bgMusic)
{
JSoundSystem::GetInstance()->StopMusic(bgMusic);
}
JRenderer::GetInstance()->EnableVSync(false);
}
virtual void Update(float dt)
{
if (bgMusic && mVolume < 2*GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME]){
mVolume++;
JSoundSystem::GetInstance()->SetVolume(mVolume/2);
}
if (currentState == STATE_LOADING_CARDS){
if (mReadConf){
mParent->collection->load(mCurrentSetFileName, mCurrentSetName);
}else{
mReadConf = 1;
}
if (!nextCardSet()){
//How many cards total ?
sprintf(nbcardsStr, "Database: %i cards", mParent->collection->totalCards());
//Check for first time comer
std::ifstream file("Res/player/collection.dat");
if(file){
file.close();
currentState = STATE_WARNING;
}else{
currentState = STATE_FIRST_TIME;
}
}
}else if (currentState == STATE_FIRST_TIME){
//Give the player cards from the set for which we have the most variety
int setId = 0;
int maxcards = 0;
for (int i=0; i< MtgSets::SetsList->nb_items; i++){
int value = mParent->collection->countBySet(i);
if (value > maxcards){
maxcards = value;
setId = i;
}
}
createUsersFirstDeck(setId);
currentState = STATE_WARNING;
}else if (currentState == STATE_WARNING){
if (!ALPHA_WARNING){
currentState = STATE_MENU;
}else{
if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE)) currentState = STATE_MENU;
}
}else{
if (currentState == STATE_MENU && mGuiController!=NULL)
mGuiController->Update(dt);
if (currentState == STATE_SUBMENU){
if( subMenuController != NULL){
subMenuController->Update(dt);
}else{
subMenuController = NEW SimpleMenu(102, this,mFont, 50,170,SCREEN_WIDTH-120);
if (subMenuController){
subMenuController->Add(11,"1 Player");
subMenuController->Add(12, "2 Players");
subMenuController->Add(13,"Demo");
subMenuController->Add(14, "Cancel");
#ifdef TESTSUITE
subMenuController->Add(666, "Test Suite");
#endif
}
}
}
}
if (currentState == STATE_WARNING && !ALPHA_WARNING) currentState = STATE_MENU;
}
void createUsersFirstDeck(int setId){
#if defined (WIN32) || defined (LINUX)
char buf[4096];
sprintf(buf, "setID: %i", setId);
OutputDebugString(buf);
#endif
MTGDeck *mCollection = NEW MTGDeck("Res/player/collection.dat", mParent->cache, mParent->collection);
//10 lands of each
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Forest")){
mCollection->addRandomCards(10, -1,RARITY_L,"Forest");
}
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Plains")){
mCollection->addRandomCards(10, -1,RARITY_L,"Plains");
}
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Swamp")){
mCollection->addRandomCards(10, -1,RARITY_L,"Swamp");
}
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Mountain")){
mCollection->addRandomCards(10, -1,RARITY_L,"Mountain");
}
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Island")){
mCollection->addRandomCards(10, -1,RARITY_L,"Island");
}
#if defined (WIN32) || defined (LINUX)
OutputDebugString("1\n");
#endif
//Starter Deck
mCollection->addRandomCards(3, setId,RARITY_R,NULL);
mCollection->addRandomCards(9, setId,RARITY_U,NULL);
mCollection->addRandomCards(48, setId,RARITY_C,NULL);
#if defined (WIN32) || defined (LINUX)
OutputDebugString("2\n");
#endif
//Boosters
for (int i = 0; i< 2; i++){
mCollection->addRandomCards(1, setId,RARITY_R);
mCollection->addRandomCards(3, setId,RARITY_U);
mCollection->addRandomCards(11, setId,RARITY_C);
}
mCollection->save();
delete mCollection;
}
virtual void Render()
{
JRenderer * renderer = JRenderer::GetInstance();
renderer->ClearScreen(ARGB(0,0,0,0));
if (currentState == STATE_LOADING_CARDS){
char text[512];
sprintf(text, "LOADING SET: %s", mCurrentSetName);
mFont->DrawString(text,SCREEN_WIDTH/2,SCREEN_HEIGHT/2,JGETEXT_CENTER);
}else{
PIXEL_TYPE colors[] =
{
ARGB(255,17,17,17),
ARGB(255,17,17,17),
ARGB(255,62,62,62),
ARGB(255,62,62,62)
};
renderer->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,colors);
renderer->RenderQuad(mBg, SCREEN_WIDTH/2 , 50);
if (mGuiController!=NULL)
mGuiController->Render();
mFont->SetScale(0.7);
mFont->SetColor(ARGB(128,255,255,255));
mFont->DrawString(GAME_VERSION, SCREEN_WIDTH-10,SCREEN_HEIGHT-15,JGETEXT_RIGHT);
mFont->DrawString(nbcardsStr,10, SCREEN_HEIGHT-15);
mFont->SetScale(1.f);
mFont->SetColor(ARGB(255,255,255,255));
if (currentState == STATE_SUBMENU && subMenuController != NULL){
subMenuController->Render();
}
if (currentState == STATE_WARNING){
renderer->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB(128,0,0,0));
mFont->DrawString("IMPORTANT NOTE" ,SCREEN_WIDTH/2,10,JGETEXT_CENTER);
mFont->DrawString("This is an alpha version with lots of bugs.",SCREEN_WIDTH/2,35,JGETEXT_CENTER);
mFont->DrawString("It WILL crash your psp" ,SCREEN_WIDTH/2,50,JGETEXT_CENTER);
mFont->DrawString("If you use it anyway, your feedback is welcome" ,SCREEN_WIDTH/2,65,JGETEXT_CENTER);
mFont->DrawString("This freeware game is NOT published or endorsed" ,SCREEN_WIDTH/2,110,JGETEXT_CENTER);
mFont->DrawString("by Wizard of the Coast, Inc." ,SCREEN_WIDTH/2,125,JGETEXT_CENTER);
mFont->DrawString("Infos & updates at http://wololo.net/wagic/" ,SCREEN_WIDTH/2,170,JGETEXT_CENTER);
mFont->DrawString("PRESS CIRCLE TO CONTINUE OR HOME TO QUIT" ,SCREEN_WIDTH/2,210,JGETEXT_CENTER);
}
}
}
virtual void ButtonPressed(int controllerId, int controlId)
{
#if defined (WIN32) || defined (LINUX)
char buf[4096];
sprintf(buf, "cnotrollerId: %i", controllerId);
OutputDebugString(buf);
#endif
switch (controllerId){
case 101:
createUsersFirstDeck(controlId);
currentState = STATE_MENU;
SAFE_DELETE(subMenuController);
break;
default:
switch (controlId)
{
case 1:
currentState = STATE_SUBMENU;
break;
case 2:
mParent->SetNextState(GAME_STATE_DECK_VIEWER);
break;
case 3:
mParent->SetNextState(GAME_STATE_SHOP);
break;
case 4:
mParent->SetNextState(GAME_STATE_OPTIONS);
break;
case 5:
mEngine->End();
break;
case 11:
mParent->players[0] = PLAYER_TYPE_HUMAN;
mParent->players[1] = PLAYER_TYPE_CPU;
mParent->SetNextState(GAME_STATE_DUEL);
break;
case 12:
mParent->players[0] = PLAYER_TYPE_HUMAN;
mParent->players[1] = PLAYER_TYPE_HUMAN;
mParent->SetNextState(GAME_STATE_DUEL);
break;
case 13:
mParent->players[0] = PLAYER_TYPE_CPU;
mParent->players[1] = PLAYER_TYPE_CPU;
mParent->SetNextState(GAME_STATE_DUEL);
break;
case 14:
currentState = STATE_MENU;
delete subMenuController;
subMenuController = NULL;
break;
#ifdef TESTSUITE
case 666:
mParent->players[0] = PLAYER_TYPE_TESTSUITE;
mParent->players[1] = PLAYER_TYPE_TESTSUITE;
mParent->SetNextState(GAME_STATE_DUEL);
break;
#endif
}
break;
}
}
};
#endif
#ifndef _GAME_STATE_MENU_H_
#define _GAME_STATE_MENU_H_
#include <JGui.h>
#include <dirent.h>
#include "GameState.h"
#include "MenuItem.h"
#include "SimpleMenu.h"
#include "../include/GameOptions.h"
#define STATE_MENU 0
#define STATE_SUBMENU 1
#define STATE_LOADING_MENU 2
#define STATE_LOADING_CARDS 3
#define STATE_FIRST_TIME 4
#define STATE_WARNING 5
#define GAME_VERSION "WTH?! 0.2.2 - by WilLoW"
#define ALPHA_WARNING 0
class GameStateMenu: public GameState, public JGuiListener
{
private:
JGuiController* mGuiController;
SimpleMenu* subMenuController;
JLBFont* mFont;
JQuad * mIcons[10];
JTexture * mIconsTexture;
JTexture * bgTexture;
JQuad * mBg;
float mCreditsYPos;
int currentState;
JMusic * bgMusic;
int mVolume;
char nbcardsStr[400];
DIR *mDip;
struct dirent *mDit;
char mCurrentSetName[10];
char mCurrentSetFileName[512];
int mReadConf;
public:
GameStateMenu(GameApp* parent): GameState(parent)
{
mGuiController = NULL;
subMenuController = NULL;
mIconsTexture = NULL;
bgMusic = NULL;
}
virtual ~GameStateMenu()
{
}
virtual void Create()
{
mDip = NULL;
mReadConf = 0;
mCurrentSetName[0] = 0;
mIconsTexture = JRenderer::GetInstance()->LoadTexture("graphics/menuicons.png", TEX_TYPE_USE_VRAM);
bgTexture = JRenderer::GetInstance()->LoadTexture("graphics/menutitle.png", TEX_TYPE_USE_VRAM);
mBg = NEW JQuad(bgTexture, 10, 0, 220, 80); // Create background quad for rendering.
mBg->SetHotSpot(105,32);
//load all the icon images
int n = 0;
for (int i=0;i<5;i++)
{
for (int j=0;j<2;j++)
{
mIcons[n] = NEW JQuad(mIconsTexture, 10 + i*32, j*32, 32, 32);
mIcons[n]->SetHotSpot(16,16);
n++;
}
}
mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
//mFont->SetBase(0); // using 2nd font
mGuiController = NEW JGuiController(100, this);
//mGuiController->SetShadingBackground(10, 45, 80, 100, ARGB(255,0,0,0));
if (mGuiController)
{
mGuiController->Add(NEW MenuItem(1, mFont, "Play", 80, SCREEN_HEIGHT/2, mIcons[8], mIcons[9],"graphics/particle1.psi",GameApp::CommonRes->GetQuad("particles"), true));
mGuiController->Add(NEW MenuItem(2, mFont, "Deck Editor", 160, SCREEN_HEIGHT/2, mIcons[2], mIcons[3],"graphics/particle2.psi",GameApp::CommonRes->GetQuad("particles")));
mGuiController->Add(NEW MenuItem(3, mFont, "Shop", 240, SCREEN_HEIGHT/2, mIcons[0], mIcons[1],"graphics/particle3.psi",GameApp::CommonRes->GetQuad("particles")));
mGuiController->Add(NEW MenuItem(4, mFont, "Options", 320, SCREEN_HEIGHT/2, mIcons[6], mIcons[7],"graphics/particle4.psi",GameApp::CommonRes->GetQuad("particles")));
mGuiController->Add(NEW MenuItem(5, mFont, "Exit", 400, SCREEN_HEIGHT/2, mIcons[4], mIcons[5],"graphics/particle5.psi",GameApp::CommonRes->GetQuad("particles")));
}
currentState = STATE_LOADING_CARDS;
}
virtual void Destroy()
{
if (mGuiController)
delete mGuiController;
if (subMenuController)
delete subMenuController;
if (mIconsTexture)
delete mIconsTexture;
for (int i = 0; i < 10 ; i++){
delete mIcons[i];
}
if (mBg) delete mBg;
SAFE_DELETE (bgMusic);
}
virtual void Start(){
JRenderer::GetInstance()->ResetPrivateVRAM();
JRenderer::GetInstance()->EnableVSync(true);
if (GameApp::HasMusic && !bgMusic && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME] > 0){
bgMusic = JSoundSystem::GetInstance()->LoadMusic("sound/track0.mp3");
}
if (bgMusic){
mVolume = 0;
JSoundSystem::GetInstance()->SetVolume(mVolume);
JSoundSystem::GetInstance()->PlayMusic(bgMusic, true);
}
}
/* Retrieves the next set subfolder automatically
*/
int nextCardSet(){
int found = 0;
if (!mDip){
mDip = opendir("Res/sets/");
}
while (!found && (mDit = readdir(mDip))){
sprintf(mCurrentSetFileName, "Res/sets/%s/_cards.dat", mDit->d_name);
std::ifstream file(mCurrentSetFileName);
if(file){
sprintf(mCurrentSetName, "%s", mDit->d_name);
file.close();
found = 1;
}
}
if (!mDit) {
closedir(mDip);
mDip = NULL;
}
return found;
}
virtual void End()
{
//mEngine->EnableVSync(false);
if (bgMusic)
{
JSoundSystem::GetInstance()->StopMusic(bgMusic);
}
JRenderer::GetInstance()->EnableVSync(false);
}
virtual void Update(float dt)
{
if (bgMusic && mVolume < 2*GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME]){
mVolume++;
JSoundSystem::GetInstance()->SetVolume(mVolume/2);
}
if (currentState == STATE_LOADING_CARDS){
if (mReadConf){
mParent->collection->load(mCurrentSetFileName, mCurrentSetName);
}else{
mReadConf = 1;
}
if (!nextCardSet()){
//How many cards total ?
sprintf(nbcardsStr, "Database: %i cards", mParent->collection->totalCards());
//Check for first time comer
std::ifstream file("Res/player/collection.dat");
if(file){
file.close();
currentState = STATE_WARNING;
}else{
currentState = STATE_FIRST_TIME;
}
}
}else if (currentState == STATE_FIRST_TIME){
//Give the player cards from the set for which we have the most variety
int setId = 0;
int maxcards = 0;
for (int i=0; i< MtgSets::SetsList->nb_items; i++){
int value = mParent->collection->countBySet(i);
if (value > maxcards){
maxcards = value;
setId = i;
}
}
createUsersFirstDeck(setId);
currentState = STATE_WARNING;
}else if (currentState == STATE_WARNING){
if (!ALPHA_WARNING){
currentState = STATE_MENU;
}else{
if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE)) currentState = STATE_MENU;
}
}else{
if (currentState == STATE_MENU && mGuiController!=NULL)
mGuiController->Update(dt);
if (currentState == STATE_SUBMENU){
if( subMenuController != NULL){
subMenuController->Update(dt);
}else{
subMenuController = NEW SimpleMenu(102, this,mFont, 50,170,SCREEN_WIDTH-120);
if (subMenuController){
subMenuController->Add(11,"1 Player");
subMenuController->Add(12, "2 Players");
subMenuController->Add(13,"Demo");
subMenuController->Add(14, "Cancel");
#ifdef TESTSUITE
subMenuController->Add(666, "Test Suite");
#endif
}
}
}
}
if (currentState == STATE_WARNING && !ALPHA_WARNING) currentState = STATE_MENU;
}
void createUsersFirstDeck(int setId){
#if defined (WIN32) || defined (LINUX)
char buf[4096];
sprintf(buf, "setID: %i", setId);
OutputDebugString(buf);
#endif
MTGDeck *mCollection = NEW MTGDeck("Res/player/collection.dat", mParent->cache, mParent->collection);
//10 lands of each
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Forest")){
mCollection->addRandomCards(10, -1,RARITY_L,"Forest");
}
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Plains")){
mCollection->addRandomCards(10, -1,RARITY_L,"Plains");
}
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Swamp")){
mCollection->addRandomCards(10, -1,RARITY_L,"Swamp");
}
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Mountain")){
mCollection->addRandomCards(10, -1,RARITY_L,"Mountain");
}
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Island")){
mCollection->addRandomCards(10, -1,RARITY_L,"Island");
}
#if defined (WIN32) || defined (LINUX)
OutputDebugString("1\n");
#endif
//Starter Deck
mCollection->addRandomCards(3, setId,RARITY_R,NULL);
mCollection->addRandomCards(9, setId,RARITY_U,NULL);
mCollection->addRandomCards(48, setId,RARITY_C,NULL);
#if defined (WIN32) || defined (LINUX)
OutputDebugString("2\n");
#endif
//Boosters
for (int i = 0; i< 2; i++){
mCollection->addRandomCards(1, setId,RARITY_R);
mCollection->addRandomCards(3, setId,RARITY_U);
mCollection->addRandomCards(11, setId,RARITY_C);
}
mCollection->save();
delete mCollection;
}
virtual void Render()
{
JRenderer * renderer = JRenderer::GetInstance();
renderer->ClearScreen(ARGB(0,0,0,0));
if (currentState == STATE_LOADING_CARDS){
char text[512];
sprintf(text, "LOADING SET: %s", mCurrentSetName);
mFont->DrawString(text,SCREEN_WIDTH/2,SCREEN_HEIGHT/2,JGETEXT_CENTER);
}else{
PIXEL_TYPE colors[] =
{
ARGB(255,17,17,17),
ARGB(255,17,17,17),
ARGB(255,62,62,62),
ARGB(255,62,62,62)
};
renderer->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,colors);
renderer->RenderQuad(mBg, SCREEN_WIDTH/2 , 50);
if (mGuiController!=NULL)
mGuiController->Render();
mFont->SetScale(0.7);
mFont->SetColor(ARGB(128,255,255,255));
mFont->DrawString(GAME_VERSION, SCREEN_WIDTH-10,SCREEN_HEIGHT-15,JGETEXT_RIGHT);
mFont->DrawString(nbcardsStr,10, SCREEN_HEIGHT-15);
mFont->SetScale(1.f);
mFont->SetColor(ARGB(255,255,255,255));
if (currentState == STATE_SUBMENU && subMenuController != NULL){
subMenuController->Render();
}
if (currentState == STATE_WARNING){
renderer->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB(128,0,0,0));
mFont->DrawString("IMPORTANT NOTE" ,SCREEN_WIDTH/2,10,JGETEXT_CENTER);
mFont->DrawString("This is an alpha version with lots of bugs.",SCREEN_WIDTH/2,35,JGETEXT_CENTER);
mFont->DrawString("It WILL crash your psp" ,SCREEN_WIDTH/2,50,JGETEXT_CENTER);
mFont->DrawString("If you use it anyway, your feedback is welcome" ,SCREEN_WIDTH/2,65,JGETEXT_CENTER);
mFont->DrawString("This freeware game is NOT published or endorsed" ,SCREEN_WIDTH/2,110,JGETEXT_CENTER);
mFont->DrawString("by Wizard of the Coast, Inc." ,SCREEN_WIDTH/2,125,JGETEXT_CENTER);
mFont->DrawString("Infos & updates at http://wololo.net/wagic/" ,SCREEN_WIDTH/2,170,JGETEXT_CENTER);
mFont->DrawString("PRESS CIRCLE TO CONTINUE OR HOME TO QUIT" ,SCREEN_WIDTH/2,210,JGETEXT_CENTER);
}
}
}
virtual void ButtonPressed(int controllerId, int controlId)
{
#if defined (WIN32) || defined (LINUX)
char buf[4096];
sprintf(buf, "cnotrollerId: %i", controllerId);
OutputDebugString(buf);
#endif
switch (controllerId){
case 101:
createUsersFirstDeck(controlId);
currentState = STATE_MENU;
SAFE_DELETE(subMenuController);
break;
default:
switch (controlId)
{
case 1:
currentState = STATE_SUBMENU;
break;
case 2:
mParent->SetNextState(GAME_STATE_DECK_VIEWER);
break;
case 3:
mParent->SetNextState(GAME_STATE_SHOP);
break;
case 4:
mParent->SetNextState(GAME_STATE_OPTIONS);
break;
case 5:
mEngine->End();
break;
case 11:
mParent->players[0] = PLAYER_TYPE_HUMAN;
mParent->players[1] = PLAYER_TYPE_CPU;
mParent->SetNextState(GAME_STATE_DUEL);
break;
case 12:
mParent->players[0] = PLAYER_TYPE_HUMAN;
mParent->players[1] = PLAYER_TYPE_HUMAN;
mParent->SetNextState(GAME_STATE_DUEL);
break;
case 13:
mParent->players[0] = PLAYER_TYPE_CPU;
mParent->players[1] = PLAYER_TYPE_CPU;
mParent->SetNextState(GAME_STATE_DUEL);
break;
case 14:
currentState = STATE_MENU;
delete subMenuController;
subMenuController = NULL;
break;
#ifdef TESTSUITE
case 666:
mParent->players[0] = PLAYER_TYPE_TESTSUITE;
mParent->players[1] = PLAYER_TYPE_TESTSUITE;
mParent->SetNextState(GAME_STATE_DUEL);
break;
#endif
}
break;
}
}
};
#endif
+34 -34
View File
@@ -1,34 +1,34 @@
#ifndef _GAME_STATE_OPTIONS_H_
#define _GAME_STATE_OPTIONS_H_
#include <JGui.h>
#include "../include/GameState.h"
#define SHOW_OPTIONS 1
#define SHOW_OPTIONS_MENU 2
class GameApp;
class OptionsList;
class SimpleMenu;
class GameStateOptions: public GameState, public JGuiListener
{
public:
SimpleMenu * optionsMenu;
int mState;
OptionsList * optionsList;
GameStateOptions(GameApp* parent);
virtual ~GameStateOptions();
virtual void Start();
virtual void End();
virtual void Update(float dt);
virtual void Render();
void ButtonPressed(int controllerId, int ControlId);
};
#endif
#ifndef _GAME_STATE_OPTIONS_H_
#define _GAME_STATE_OPTIONS_H_
#include <JGui.h>
#include "../include/GameState.h"
#define SHOW_OPTIONS 1
#define SHOW_OPTIONS_MENU 2
class GameApp;
class OptionsList;
class SimpleMenu;
class GameStateOptions: public GameState, public JGuiListener
{
public:
SimpleMenu * optionsMenu;
int mState;
OptionsList * optionsList;
GameStateOptions(GameApp* parent);
virtual ~GameStateOptions();
virtual void Start();
virtual void End();
virtual void Update(float dt);
virtual void Render();
void ButtonPressed(int controllerId, int ControlId);
};
#endif
+46 -46
View File
@@ -1,46 +1,46 @@
#ifndef _GAME_STATE_SHOP_H_
#define _GAME_STATE_SHOP_H_
#include <JGE.h>
#include "../include/GameState.h"
#include "../include/SimpleMenu.h"
#include "../include/ShopItem.h"
#define STATE_BUY 1
#define STATE_SELL 2
#define STAGE_SHOP_MENU 3
#define STAGE_SHOP_SHOP 4
class GameStateShop: public GameState, public JGuiListener
{
private:
ShopItems * shop;
JLBFont * mFont;
JQuad * mBg;
JTexture * bgTexture;
JQuad * mBack;
JTexture * backTexture;
SimpleMenu * menu;
int mStage;
char starterBuffer[128], boosterBuffer[128];
int setId;
public:
GameStateShop(GameApp* parent);
virtual ~GameStateShop();
virtual void Start();
virtual void End();
virtual void Create();
virtual void Destroy();
virtual void Update(float dt);
virtual void Render();
virtual void ButtonPressed(int controllerId, int controlId);
};
#endif
#ifndef _GAME_STATE_SHOP_H_
#define _GAME_STATE_SHOP_H_
#include <JGE.h>
#include "../include/GameState.h"
#include "../include/SimpleMenu.h"
#include "../include/ShopItem.h"
#define STATE_BUY 1
#define STATE_SELL 2
#define STAGE_SHOP_MENU 3
#define STAGE_SHOP_SHOP 4
class GameStateShop: public GameState, public JGuiListener
{
private:
ShopItems * shop;
JLBFont * mFont;
JQuad * mBg;
JTexture * bgTexture;
JQuad * mBack;
JTexture * backTexture;
SimpleMenu * menu;
int mStage;
char starterBuffer[128], boosterBuffer[128];
int setId;
public:
GameStateShop(GameApp* parent);
virtual ~GameStateShop();
virtual void Start();
virtual void End();
virtual void Create();
virtual void Destroy();
virtual void Update(float dt);
virtual void Render();
virtual void ButtonPressed(int controllerId, int controlId);
};
#endif
+2 -2
View File
@@ -5,8 +5,8 @@
#include "PlayGuiObjectController.h"
class GuiCardsController : public PlayGuiObjectController{
public:
GuiCardsController(int id, GameObserver* _game):PlayGuiObjectController(id, _game){};
public:
GuiCardsController(int id, GameObserver* _game):PlayGuiObjectController(id, _game){};
};
+7 -7
View File
@@ -20,9 +20,9 @@ class GuiLayer: public JGuiController{
GameObserver * game;
public:
virtual void resetObjects();
int hasFocus;
int getMaxId();
void RenderMessageBackground(float x0, float y0, float width, int height);
int hasFocus;
int getMaxId();
void RenderMessageBackground(float x0, float y0, float width, int height);
void RenderMessageBackground(float y0, int height);
GuiLayer(int id, GameObserver* _game);
virtual int isModal();
@@ -34,10 +34,10 @@ class GuiLayer: public JGuiController{
int getIndexOf(JGuiObject * object);
JGuiObject * getByIndex (int index);
virtual void Render(){JGuiController::Render();};
int empty(){
if (mCount) return 0;
return 1;
};
int empty(){
if (mCount) return 0;
return 1;
};
};
class GuiLayers{
+20 -20
View File
@@ -1,20 +1,20 @@
#ifndef _LOGGER_H
#define _LOGGER_H_
#ifdef DOLOG
#define LOG(x) Logger::Log(x);
#else
#define LOG(x)
#endif
#define LOG_FILE "Res/debug.txt"
class Logger{
public:
static void Log(char * text);
};
#endif
#ifndef _LOGGER_H
#define _LOGGER_H_
#ifdef DOLOG
#define LOG(x) Logger::Log(x);
#else
#define LOG(x)
#endif
#define LOG_FILE "Res/debug.txt"
class Logger{
public:
static void Log(char * text);
};
#endif
+118 -118
View File
@@ -1,118 +1,118 @@
#ifndef _MTGABILITY_H_
#define _MTGABILITY_H_
class MTGCardInstance;
class GameObserver;
class Spell;
class Damageable;
class PlayGuiObject;
class TargetChooser;
class ManaCost;
class MTGGameZone;
class Player;
#include "ActionElement.h"
#include <string>
#include <map>
using std::string;
using std::map;
#define BAKA_EFFECT_GOOD 10
#define BAKA_EFFECT_BAD 11
class AbilityFactory{
private:
int destroyAllFromTypeInPlay(const char * type, MTGCardInstance * source, int bury = 0);
int destroyAllFromColorInPlay(int color, MTGCardInstance * source, int bury = 0);
int putInPlayFromZone(MTGCardInstance * card, MTGGameZone * zone, Player * p);
public:
int magicText(int id, Spell * spell, MTGCardInstance * card = NULL);
void addAbilities(int _id, Spell * spell);
};
class MTGAbility: public ActionElement{
protected:
char menuText[25];
Damageable * target;
GameObserver * game;
public:
MTGCardInstance * source;
MTGAbility(int id, MTGCardInstance * card);
MTGAbility(int id, MTGCardInstance * _source, Damageable * _target);
virtual int testDestroy();
virtual ~MTGAbility();
virtual void Render(){};
virtual int isReactingToClick(MTGCardInstance * card){return 0;};
virtual int reactToClick(MTGCardInstance * card){return 0;};
virtual void Update(float dt){};
virtual int fireAbility();
virtual int resolve(){return 0;};
};
class TriggeredAbility:public MTGAbility{
public:
TriggeredAbility(int id, MTGCardInstance * card);
TriggeredAbility(int id, MTGCardInstance * _source, Damageable * _target);
virtual void Update(float dt);
virtual void Render(){};
virtual int trigger()=0;
virtual int resolve() = 0;
};
class ActivatedAbility:public MTGAbility{
public:
ManaCost * cost;
int playerturnonly;
int needsTapping;
ActivatedAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
virtual int reactToClick(MTGCardInstance * card);
virtual int isReactingToClick(MTGCardInstance * card);
virtual int reactToTargetClick(Targetable * object);
virtual int resolve() = 0;
virtual ~ActivatedAbility();
};
class TargetAbility:public ActivatedAbility{
public:
TargetAbility(int id, MTGCardInstance * card, TargetChooser * _tc,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
TargetAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
virtual void Update(float dt);
virtual int reactToClick(MTGCardInstance * card);
virtual int reactToTargetClick(Targetable * object);
virtual void Render();
};
class InstantAbility:public MTGAbility{
public:
int init;
virtual void Update(float dt);
virtual int testDestroy();
InstantAbility(int _id, MTGCardInstance * source);
InstantAbility(int _id, MTGCardInstance * source,Damageable * _target);
virtual int resolve(){return 0;};
};
/* State based effects. This class works ONLY for InPlay and needs to be extended for other areas of the game !!! */
class ListMaintainerAbility:public MTGAbility{
public:
map<MTGCardInstance *,bool> cards;
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);
virtual int canBeInList(MTGCardInstance * card) = 0;
virtual int added(MTGCardInstance * card) = 0;
virtual int removed(MTGCardInstance * card) = 0;
virtual int destroy();
};
#include "MTGCardInstance.h"
#endif
#ifndef _MTGABILITY_H_
#define _MTGABILITY_H_
class MTGCardInstance;
class GameObserver;
class Spell;
class Damageable;
class PlayGuiObject;
class TargetChooser;
class ManaCost;
class MTGGameZone;
class Player;
#include "ActionElement.h"
#include <string>
#include <map>
using std::string;
using std::map;
#define BAKA_EFFECT_GOOD 10
#define BAKA_EFFECT_BAD 11
class AbilityFactory{
private:
int destroyAllFromTypeInPlay(const char * type, MTGCardInstance * source, int bury = 0);
int destroyAllFromColorInPlay(int color, MTGCardInstance * source, int bury = 0);
int putInPlayFromZone(MTGCardInstance * card, MTGGameZone * zone, Player * p);
public:
int magicText(int id, Spell * spell, MTGCardInstance * card = NULL);
void addAbilities(int _id, Spell * spell);
};
class MTGAbility: public ActionElement{
protected:
char menuText[25];
Damageable * target;
GameObserver * game;
public:
MTGCardInstance * source;
MTGAbility(int id, MTGCardInstance * card);
MTGAbility(int id, MTGCardInstance * _source, Damageable * _target);
virtual int testDestroy();
virtual ~MTGAbility();
virtual void Render(){};
virtual int isReactingToClick(MTGCardInstance * card){return 0;};
virtual int reactToClick(MTGCardInstance * card){return 0;};
virtual void Update(float dt){};
virtual int fireAbility();
virtual int resolve(){return 0;};
};
class TriggeredAbility:public MTGAbility{
public:
TriggeredAbility(int id, MTGCardInstance * card);
TriggeredAbility(int id, MTGCardInstance * _source, Damageable * _target);
virtual void Update(float dt);
virtual void Render(){};
virtual int trigger()=0;
virtual int resolve() = 0;
};
class ActivatedAbility:public MTGAbility{
public:
ManaCost * cost;
int playerturnonly;
int needsTapping;
ActivatedAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
virtual int reactToClick(MTGCardInstance * card);
virtual int isReactingToClick(MTGCardInstance * card);
virtual int reactToTargetClick(Targetable * object);
virtual int resolve() = 0;
virtual ~ActivatedAbility();
};
class TargetAbility:public ActivatedAbility{
public:
TargetAbility(int id, MTGCardInstance * card, TargetChooser * _tc,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
TargetAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
virtual void Update(float dt);
virtual int reactToClick(MTGCardInstance * card);
virtual int reactToTargetClick(Targetable * object);
virtual void Render();
};
class InstantAbility:public MTGAbility{
public:
int init;
virtual void Update(float dt);
virtual int testDestroy();
InstantAbility(int _id, MTGCardInstance * source);
InstantAbility(int _id, MTGCardInstance * source,Damageable * _target);
virtual int resolve(){return 0;};
};
/* State based effects. This class works ONLY for InPlay and needs to be extended for other areas of the game !!! */
class ListMaintainerAbility:public MTGAbility{
public:
map<MTGCardInstance *,bool> cards;
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);
virtual int canBeInList(MTGCardInstance * card) = 0;
virtual int added(MTGCardInstance * card) = 0;
virtual int removed(MTGCardInstance * card) = 0;
virtual int destroy();
};
#include "MTGCardInstance.h"
#endif
+119 -119
View File
@@ -1,119 +1,119 @@
#ifndef _MTGCARD_H_
#define _MTGCARD_H_
#define MTGCARD_NAME_SIZE 30
#define MTGCARD_TEXT_SIZE 300
#define MTG_IMAGE_WIDTH 200
#define MTG_IMAGE_HEIGHT 285
#define MAX_TYPES_PER_CARD 10
#include "ManaCost.h"
class TexturesCache;
#include <string>
#include <vector>
using namespace std;
class MTGCard {
protected:
int mtgid;
TexturesCache * mCache;
ManaCost manaCost;
char rarity;
char image_name[MTGCARD_NAME_SIZE];
int init();
public:
string text;
string name;
int colors[MTG_NB_COLORS];
int basicAbilities[NB_BASIC_ABILITIES];
vector<string> formattedText;
string magicText;
int alias;
string spellTargetType;
int formattedTextInit;
int power;
int toughness;
int setId;
static const char * const Colors_To_Text[];
int nb_types;
int types[MAX_TYPES_PER_CARD];
MTGCard();
MTGCard(TexturesCache * cache, int set_id);
MTGCard(MTGCard * source);
JQuad * getQuad(TexturesCache * cache);
JQuad * getQuad(int type=1);
JQuad * getThumb();
void setColor(int _color, int removeAllOthers = 0);
int getColor();
int hasColor(int _color);
const char * colorToString();
void setMTGId(int id);
int getMTGId();
int getId();
int has(int ability);
char getRarity();
void setRarity(char _rarity);
const char * getSetName();
//void setImageName( char * value);
char * getImageName ();
void setText( string value);
const char * getText();
void addMagicText(string value);
void setName( string value);
const char * getName();
void addType(char * type_text);
void addType(int id);
void setType(const char * type_text);
void setSubtype( string value);
int removeType(string value, int removeAll = 0);
int removeType(int value, int removeAll = 0);
int hasSubtype(int _subtype);
int hasSubtype(const char * _subtype);
int hasSubtype(string _subtype);
int hasType(int _type);
int hasType(const char * type);
void setManaCost(string value);
ManaCost * getManaCost();
int isACreature();
void setPower(int _power);
int getPower();
void setToughness(int _toughness);
int getToughness();
};
#endif
#ifndef _MTGCARD_H_
#define _MTGCARD_H_
#define MTGCARD_NAME_SIZE 30
#define MTGCARD_TEXT_SIZE 300
#define MTG_IMAGE_WIDTH 200
#define MTG_IMAGE_HEIGHT 285
#define MAX_TYPES_PER_CARD 10
#include "ManaCost.h"
class TexturesCache;
#include <string>
#include <vector>
using namespace std;
class MTGCard {
protected:
int mtgid;
TexturesCache * mCache;
ManaCost manaCost;
char rarity;
char image_name[MTGCARD_NAME_SIZE];
int init();
public:
string text;
string name;
int colors[MTG_NB_COLORS];
int basicAbilities[NB_BASIC_ABILITIES];
vector<string> formattedText;
string magicText;
int alias;
string spellTargetType;
int formattedTextInit;
int power;
int toughness;
int setId;
static const char * const Colors_To_Text[];
int nb_types;
int types[MAX_TYPES_PER_CARD];
MTGCard();
MTGCard(TexturesCache * cache, int set_id);
MTGCard(MTGCard * source);
JQuad * getQuad(TexturesCache * cache);
JQuad * getQuad(int type=1);
JQuad * getThumb();
void setColor(int _color, int removeAllOthers = 0);
int getColor();
int hasColor(int _color);
const char * colorToString();
void setMTGId(int id);
int getMTGId();
int getId();
int has(int ability);
char getRarity();
void setRarity(char _rarity);
const char * getSetName();
//void setImageName( char * value);
char * getImageName ();
void setText( string value);
const char * getText();
void addMagicText(string value);
void setName( string value);
const char * getName();
void addType(char * type_text);
void addType(int id);
void setType(const char * type_text);
void setSubtype( string value);
int removeType(string value, int removeAll = 0);
int removeType(int value, int removeAll = 0);
int hasSubtype(int _subtype);
int hasSubtype(const char * _subtype);
int hasSubtype(string _subtype);
int hasType(int _type);
int hasType(const char * type);
void setManaCost(string value);
ManaCost * getManaCost();
int isACreature();
void setPower(int _power);
int getPower();
void setToughness(int _toughness);
int getToughness();
};
#endif
+49 -49
View File
@@ -25,68 +25,68 @@ class Counters;
class MTGCardInstance: public MTGCard, public Damageable, public Targetable {
protected:
int untapping;
int untapping;
int nb_damages;
int lifeOrig;
Blockers * blockers;
int lifeOrig;
Blockers * blockers;
MTGPlayerCards * belongs_to;
MTGAbility * UntapBlockers[10];
void unband();
MTGCardInstance * getNextPartner();
void initMTGCI();
void unband();
MTGCardInstance * getNextPartner();
void initMTGCI();
public:
MTGGameZone * getCurrentZone();
int doDamageTest;
int summoningSickness;
// The recommended method to test for summoning Sickness !
int hasSummoningSickness();
int changeController(Player * newcontroller);
MTGCardInstance * defenser;
float changedZoneRecently;
Player * owner;
Counters * counters;
int typeAsTarget(){return TARGET_CARD;}
int attacker;
MTGCardInstance * banding; // If belongs to a band when attacking
MTGGameZone * getCurrentZone();
int doDamageTest;
int summoningSickness;
// The recommended method to test for summoning Sickness !
int hasSummoningSickness();
int changeController(Player * newcontroller);
MTGCardInstance * defenser;
float changedZoneRecently;
Player * owner;
Counters * counters;
int typeAsTarget(){return TARGET_CARD;}
int attacker;
MTGCardInstance * banding; // If belongs to a band when attacking
MTGCardInstance * target;
int tapped;
void addType(int type);
int canBlock();
int canBlock(MTGCardInstance * opponent);
int canAttack();
int tapped;
void addType(int type);
int canBlock();
int canBlock(MTGCardInstance * opponent);
int canAttack();
int afterDamage();
void setUntapping();
int isUntapping();
int has(int ability);
int cleanup();
int reset();
int isAttacker();
MTGCardInstance * isDefenser();
int toggleDefenser(MTGCardInstance * opponent);
int toggleAttacker();
void setUntapping();
int isUntapping();
int has(int ability);
int cleanup();
int reset();
int isAttacker();
MTGCardInstance * isDefenser();
int toggleDefenser(MTGCardInstance * opponent);
int toggleAttacker();
MTGCard * model;
MTGCardInstance();
MTGCardInstance();
MTGCardInstance(MTGCard * card, MTGPlayerCards * _belongs_to);
Blockers * getBlockers();
Blockers * getBlockers();
void regenerate();
Player * controller();
JQuad * getIcon();
int initAttackersDefensers();
MTGCardInstance * getNextOpponent(MTGCardInstance * previous=NULL);
int nbOpponents();
~MTGCardInstance();
Player * controller();
JQuad * getIcon();
int initAttackersDefensers();
MTGCardInstance * getNextOpponent(MTGCardInstance * previous=NULL);
int nbOpponents();
~MTGCardInstance();
int addToToughness(int value);
int setToughness(int value);
int addToToughness(int value);
int setToughness(int value);
CardDescriptor * protections[10];
int nbprotections;
int addProtection(CardDescriptor * cd);
int removeProtection(CardDescriptor *cd, int erase = 0);
int protectedAgainst(MTGCardInstance * card);
CardDescriptor * protections[10];
int nbprotections;
int addProtection(CardDescriptor * cd);
int removeProtection(CardDescriptor *cd, int erase = 0);
int protectedAgainst(MTGCardInstance * card);
// in game
int isTapped();
+91 -91
View File
@@ -1,91 +1,91 @@
#ifndef _MTGDECK_H_
#define _MTGDECK_H_
#define MTG_ERROR -1
#include "../include/MTGDefinitions.h"
#include "../include/GameApp.h"
#include "../include/TexturesCache.h"
#include <string>
using std::string;
class GameApp;
class MTGCard;
#define MAX_SETS 30
class MtgSets{
protected:
public:
int nb_items;
string values[MAX_SETS];
public:
static MtgSets * SetsList;
MtgSets();
int Add(const char * subtype);
};
class MTGAllCards {
protected:
int conf_read_mode;
int conf_fd;
char * conf_buffer;
int read_cursor;
int colorsCount[MTG_NB_COLORS];
int total_cards;
GameApp * parent;
void init();
void initCounters();
public:
TexturesCache * mCache;
MTGCard * _(int i);
MTGCard * collection[TOTAL_NUMBER_OF_CARDS];
MTGAllCards();
~MTGAllCards();
MTGAllCards(TexturesCache * cache);
void destroyAllCards();
MTGAllCards(const char * config_file, const char * set_name);
MTGAllCards(const char * config_file, const char * set_name, TexturesCache * cache);
MTGCard * getCardById(int id);
int load(const char * config_file, const char * setName, int autoload = 1);
int countByType(const char * _type);
int countByColor(int color);
int countBySet(int setId);
int readConfLine(int set_id);
int totalCards();
int randomCardId();
private:
int processConfLine(char* file, MTGCard* card);
};
class MTGDeck:public MTGAllCards{
protected:
string filename;
MTGAllCards * allcards;
public:
MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards);
int addRandomCards(int howmany, int setId = -1, int rarity = -1, const char * subtype = NULL);
int add(int cardid);
int remove(int cardid);
int removeAll();
int add(MTGCard * card);
int remove(MTGCard * card);
int save();
};
#endif
#ifndef _MTGDECK_H_
#define _MTGDECK_H_
#define MTG_ERROR -1
#include "../include/MTGDefinitions.h"
#include "../include/GameApp.h"
#include "../include/TexturesCache.h"
#include <string>
using std::string;
class GameApp;
class MTGCard;
#define MAX_SETS 30
class MtgSets{
protected:
public:
int nb_items;
string values[MAX_SETS];
public:
static MtgSets * SetsList;
MtgSets();
int Add(const char * subtype);
};
class MTGAllCards {
protected:
int conf_read_mode;
int conf_fd;
char * conf_buffer;
int read_cursor;
int colorsCount[MTG_NB_COLORS];
int total_cards;
GameApp * parent;
void init();
void initCounters();
public:
TexturesCache * mCache;
MTGCard * _(int i);
MTGCard * collection[TOTAL_NUMBER_OF_CARDS];
MTGAllCards();
~MTGAllCards();
MTGAllCards(TexturesCache * cache);
void destroyAllCards();
MTGAllCards(const char * config_file, const char * set_name);
MTGAllCards(const char * config_file, const char * set_name, TexturesCache * cache);
MTGCard * getCardById(int id);
int load(const char * config_file, const char * setName, int autoload = 1);
int countByType(const char * _type);
int countByColor(int color);
int countBySet(int setId);
int readConfLine(int set_id);
int totalCards();
int randomCardId();
private:
int processConfLine(char* file, MTGCard* card);
};
class MTGDeck:public MTGAllCards{
protected:
string filename;
MTGAllCards * allcards;
public:
MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards);
int addRandomCards(int howmany, int setId = -1, int rarity = -1, const char * subtype = NULL);
int add(int cardid);
int remove(int cardid);
int removeAll();
int add(MTGCard * card);
int remove(MTGCard * card);
int save();
};
#endif
+176 -176
View File
@@ -1,176 +1,176 @@
#ifndef _MTGDEFINITION_H_
#define _MTGDEFINITION_H_
#define TOTAL_NUMBER_OF_CARDS 4000
#define MTG_NB_COLORS 7
#define MTG_COLOR_ARTIFACT 0
#define MTG_COLOR_GREEN 1
#define MTG_COLOR_BLUE 2
#define MTG_COLOR_RED 3
#define MTG_COLOR_BLACK 4
#define MTG_COLOR_WHITE 5
#define MTG_COLOR_LAND 6
static char MTGColorChars[] = {'x','g','u','r','b','w','l'};
static const char * MTGColorStrings[] = {"artifact", "green", "blue", "red", "black", "white", "land"};
static int _r[7] = {75, 20, 20, 200,50,255,128};
static int _g[7] = {30, 140, 30, 15, 50,255,128};
static int _b[7] = {20, 0, 140,15, 50,255,128};
#define MTG_UNCOLORED 0
#define MTG_FOREST 1
#define MTG_ISLAND 2
#define MTG_MOUNTAIN 3
#define MTG_SWAMP 4
#define MTG_PLAIN 5
#define MTG_TYPE_CREATURE 10
#define MTG_TYPE_ARTIFACT 11
#define MTG_TYPE_ENCHANTMENT 12
#define MTG_TYPE_SORCERY 13
#define MTG_TYPE_LAND 14
#define MTG_TYPE_INSTANT 15
#define MTG_PHASE_BEFORE_BEGIN 0
#define MTG_PHASE_UNTAP 1
#define MTG_PHASE_UPKEEP 2
#define MTG_PHASE_DRAW 3
#define MTG_PHASE_FIRSTMAIN 4
#define MTG_PHASE_COMBATBEGIN 5
#define MTG_PHASE_COMBATATTACKERS 6
#define MTG_PHASE_COMBATBLOCKERS 7
#define MTG_PHASE_COMBATDAMAGE 8
#define MTG_PHASE_COMBATEND 9
#define MTG_PHASE_SECONDMAIN 10
#define MTG_PHASE_ENDOFTURN 11
#define MTG_PHASE_EOT 11
#define MTG_PHASE_CLEANUP 12
#define MTG_PHASE_AFTER_EOT 13
#define NB_MTG_PHASES 14
#define TRAMPLE 0
#define FORESTWALK 1
#define ISLANDWALK 2
#define MOUNTAINWALK 3
#define SWAMPWALK 4
#define PLAINSWALK 5
#define FLYING 6
#define FIRSTSTRIKE 7
#define DOUBLESTRIKE 8
#define FEAR 9
#define FLASH 10
#define HASTE 11
#define LIFELINK 12
#define REACH 13
#define SHROUD 14
#define VIGILANCE 15
#define DEFENSER 16
#define DEFENDER 16
#define BANDING 17
#define PROTECTIONGREEN 18
#define PROTECTIONBLUE 19
#define PROTECTIONRED 20
#define PROTECTIONBLACK 21
#define PROTECTIONWHITE 22
#define UNBLOCKABLE 23
#define WITHER 24
#define PERSIST 25
#define RETRACE 26
#define EXALTED 27
#define LEGENDARY 28
#define SHADOW 29
#define REACHSHADOW 30
#define FORESTHOME 31
#define ISLANDHOME 32
#define MOUNTAINHOME 33
#define SWAMPHOME 34
#define PLAINSHOME 35
#define FLANKING 36
#define RAMPAGE1 37
#define NB_BASIC_ABILITIES 38
static const char * MTGBasicAbilities[] = {
"trample",
"forestwalk",
"islandwalk",
"mountainwalk",
"swampwalk",
"plainwalk",
"flying",
"first strike",
"double strike",
"fear",
"flash",
"haste",
"lifelink",
"reach",
"shroud",
"vigilance",
"defender",
"banding",
"protection from green",
"protection from blue",
"protection from red",
"protection from black",
"protection from white",
"unblockable",
"wither",
"persist",
"retrace",
"exalted",
"legendary",
"shadow",
"reachshadow",
"foresthome",
"islandhome",
"moutainhome",
"swamphome",
"plainshome",
"flanking",
"rampage",
};
#define RARITY_M 'M'
#define RARITY_R 'R'
#define RARITY_U 'U'
#define RARITY_C 'C'
#define RARITY_L 'L'
#define MAIN_FONT 0
#define MAGIC_FONT 1
static const char *MTGPhaseNames[] =
{
"---",
"Untap",
"Upkeep",
"Draw",
"Main phase 1",
"Combat begins",
"Attackers",
"Blockers",
"Combat damage",
"Combat ends",
"Main phase 2",
"End of turn",
"cleanup",
"---"
};
#endif
#ifndef _MTGDEFINITION_H_
#define _MTGDEFINITION_H_
#define TOTAL_NUMBER_OF_CARDS 4000
#define MTG_NB_COLORS 7
#define MTG_COLOR_ARTIFACT 0
#define MTG_COLOR_GREEN 1
#define MTG_COLOR_BLUE 2
#define MTG_COLOR_RED 3
#define MTG_COLOR_BLACK 4
#define MTG_COLOR_WHITE 5
#define MTG_COLOR_LAND 6
static char MTGColorChars[] = {'x','g','u','r','b','w','l'};
static const char * MTGColorStrings[] = {"artifact", "green", "blue", "red", "black", "white", "land"};
static int _r[7] = {75, 20, 20, 200,50,255,128};
static int _g[7] = {30, 140, 30, 15, 50,255,128};
static int _b[7] = {20, 0, 140,15, 50,255,128};
#define MTG_UNCOLORED 0
#define MTG_FOREST 1
#define MTG_ISLAND 2
#define MTG_MOUNTAIN 3
#define MTG_SWAMP 4
#define MTG_PLAIN 5
#define MTG_TYPE_CREATURE 10
#define MTG_TYPE_ARTIFACT 11
#define MTG_TYPE_ENCHANTMENT 12
#define MTG_TYPE_SORCERY 13
#define MTG_TYPE_LAND 14
#define MTG_TYPE_INSTANT 15
#define MTG_PHASE_BEFORE_BEGIN 0
#define MTG_PHASE_UNTAP 1
#define MTG_PHASE_UPKEEP 2
#define MTG_PHASE_DRAW 3
#define MTG_PHASE_FIRSTMAIN 4
#define MTG_PHASE_COMBATBEGIN 5
#define MTG_PHASE_COMBATATTACKERS 6
#define MTG_PHASE_COMBATBLOCKERS 7
#define MTG_PHASE_COMBATDAMAGE 8
#define MTG_PHASE_COMBATEND 9
#define MTG_PHASE_SECONDMAIN 10
#define MTG_PHASE_ENDOFTURN 11
#define MTG_PHASE_EOT 11
#define MTG_PHASE_CLEANUP 12
#define MTG_PHASE_AFTER_EOT 13
#define NB_MTG_PHASES 14
#define TRAMPLE 0
#define FORESTWALK 1
#define ISLANDWALK 2
#define MOUNTAINWALK 3
#define SWAMPWALK 4
#define PLAINSWALK 5
#define FLYING 6
#define FIRSTSTRIKE 7
#define DOUBLESTRIKE 8
#define FEAR 9
#define FLASH 10
#define HASTE 11
#define LIFELINK 12
#define REACH 13
#define SHROUD 14
#define VIGILANCE 15
#define DEFENSER 16
#define DEFENDER 16
#define BANDING 17
#define PROTECTIONGREEN 18
#define PROTECTIONBLUE 19
#define PROTECTIONRED 20
#define PROTECTIONBLACK 21
#define PROTECTIONWHITE 22
#define UNBLOCKABLE 23
#define WITHER 24
#define PERSIST 25
#define RETRACE 26
#define EXALTED 27
#define LEGENDARY 28
#define SHADOW 29
#define REACHSHADOW 30
#define FORESTHOME 31
#define ISLANDHOME 32
#define MOUNTAINHOME 33
#define SWAMPHOME 34
#define PLAINSHOME 35
#define FLANKING 36
#define RAMPAGE1 37
#define NB_BASIC_ABILITIES 38
static const char * MTGBasicAbilities[] = {
"trample",
"forestwalk",
"islandwalk",
"mountainwalk",
"swampwalk",
"plainwalk",
"flying",
"first strike",
"double strike",
"fear",
"flash",
"haste",
"lifelink",
"reach",
"shroud",
"vigilance",
"defender",
"banding",
"protection from green",
"protection from blue",
"protection from red",
"protection from black",
"protection from white",
"unblockable",
"wither",
"persist",
"retrace",
"exalted",
"legendary",
"shadow",
"reachshadow",
"foresthome",
"islandhome",
"moutainhome",
"swamphome",
"plainshome",
"flanking",
"rampage",
};
#define RARITY_M 'M'
#define RARITY_R 'R'
#define RARITY_U 'U'
#define RARITY_C 'C'
#define RARITY_L 'L'
#define MAIN_FONT 0
#define MAGIC_FONT 1
static const char *MTGPhaseNames[] =
{
"---",
"Untap",
"Upkeep",
"Draw",
"Main phase 1",
"Combat begins",
"Attackers",
"Blockers",
"Combat damage",
"Combat ends",
"Main phase 2",
"End of turn",
"cleanup",
"---"
};
#endif
+2 -2
View File
@@ -14,10 +14,10 @@ class MTGGamePhase: public ActionElement {
int currentState;
JLBFont * mFont;
public:
MTGGamePhase(int id);
MTGGamePhase(int id);
virtual void Render();
virtual void Update(float dt);
void CheckUserInput(float dt);
void CheckUserInput(float dt);
};
+98 -98
View File
@@ -1,98 +1,98 @@
#ifndef _MTGGAMEZONES_H_
#define _MTGGAMEZONES_H_
#include <map>
using std::map;
#include "MTGDeck.h"
#include "MTGCardInstance.h"
#define MTG_MAX_PLAYER_CARDS 100
class MTGAllCards;
class MTGCardInstance;
class Player;
class MTGGameZone {
protected:
Player * owner;
public:
//Both cards and cardsMap contain the cards of a zone. The long term objective is to get rid of the array
MTGCardInstance * cards[MTG_MAX_PLAYER_CARDS];
map<MTGCardInstance *,int> cardsMap;
int nb_cards;
MTGGameZone();
~MTGGameZone();
void shuffle();
virtual MTGCardInstance * draw();
void addCard(MTGCardInstance * card);
void debugPrint();
MTGCardInstance * removeCard(MTGCardInstance * card);
MTGCardInstance * hasCard(MTGCardInstance * card);
void cleanupPhase();
int countByType(const char * value);
int hasType(const char * value);
void setOwner(Player * player);
MTGCardInstance * lastCardDrawn;
};
class MTGLibrary: public MTGGameZone {
public:
// MTGLibrary();
void shuffleTopToBottom(int nbcards);
MTGCardInstance * draw();
};
class MTGGraveyard: public MTGGameZone {
public:
// MTGGraveyard();
};
class MTGHand: public MTGGameZone {
public:
};
class MTGStack: public MTGGameZone {
public:
};
class MTGInPlay: public MTGGameZone {
public:
//MTGInPlay();
void untapAll();
MTGCardInstance * getNextAttacker(MTGCardInstance * previous);
MTGCardInstance * getNextDefenser(MTGCardInstance * previous, MTGCardInstance * attacker);
int nbDefensers( MTGCardInstance * attacker);
int nbPartners(MTGCardInstance * attacker);
};
class MTGPlayerCards {
protected:
void init();
public:
MTGLibrary * library;
MTGGraveyard * graveyard;
MTGHand * hand;
MTGInPlay * inPlay;
MTGStack * stack;
MTGAllCards * collection;
MTGPlayerCards(MTGAllCards * _collection, int * idList, int idListSize);
~MTGPlayerCards();
void initGame(int shuffle = 1, int draw = 1);
void setOwner(Player * player);
void discardRandom(MTGGameZone * from);
void drawFromLibrary();
void showHand();
void putInGraveyard(MTGCardInstance * card);
void putInZone(MTGCardInstance * card, MTGGameZone * from, MTGGameZone * to);
void putInPlay(MTGCardInstance * card);
int isInPlay(MTGCardInstance * card);
};
#endif
#ifndef _MTGGAMEZONES_H_
#define _MTGGAMEZONES_H_
#include <map>
using std::map;
#include "MTGDeck.h"
#include "MTGCardInstance.h"
#define MTG_MAX_PLAYER_CARDS 100
class MTGAllCards;
class MTGCardInstance;
class Player;
class MTGGameZone {
protected:
Player * owner;
public:
//Both cards and cardsMap contain the cards of a zone. The long term objective is to get rid of the array
MTGCardInstance * cards[MTG_MAX_PLAYER_CARDS];
map<MTGCardInstance *,int> cardsMap;
int nb_cards;
MTGGameZone();
~MTGGameZone();
void shuffle();
virtual MTGCardInstance * draw();
void addCard(MTGCardInstance * card);
void debugPrint();
MTGCardInstance * removeCard(MTGCardInstance * card);
MTGCardInstance * hasCard(MTGCardInstance * card);
void cleanupPhase();
int countByType(const char * value);
int hasType(const char * value);
void setOwner(Player * player);
MTGCardInstance * lastCardDrawn;
};
class MTGLibrary: public MTGGameZone {
public:
// MTGLibrary();
void shuffleTopToBottom(int nbcards);
MTGCardInstance * draw();
};
class MTGGraveyard: public MTGGameZone {
public:
// MTGGraveyard();
};
class MTGHand: public MTGGameZone {
public:
};
class MTGStack: public MTGGameZone {
public:
};
class MTGInPlay: public MTGGameZone {
public:
//MTGInPlay();
void untapAll();
MTGCardInstance * getNextAttacker(MTGCardInstance * previous);
MTGCardInstance * getNextDefenser(MTGCardInstance * previous, MTGCardInstance * attacker);
int nbDefensers( MTGCardInstance * attacker);
int nbPartners(MTGCardInstance * attacker);
};
class MTGPlayerCards {
protected:
void init();
public:
MTGLibrary * library;
MTGGraveyard * graveyard;
MTGHand * hand;
MTGInPlay * inPlay;
MTGStack * stack;
MTGAllCards * collection;
MTGPlayerCards(MTGAllCards * _collection, int * idList, int idListSize);
~MTGPlayerCards();
void initGame(int shuffle = 1, int draw = 1);
void setOwner(Player * player);
void discardRandom(MTGGameZone * from);
void drawFromLibrary();
void showHand();
void putInGraveyard(MTGCardInstance * card);
void putInZone(MTGCardInstance * card, MTGGameZone * from, MTGGameZone * to);
void putInPlay(MTGCardInstance * card);
int isInPlay(MTGCardInstance * card);
};
#endif
+1 -1
View File
@@ -17,7 +17,7 @@ class GuiCardscontroller;
class MTGGuiHand: public GuiCardsController{
protected:
int currentId[2];
int currentId[2];
Player * currentPlayer;
int mShowHand;
float mAnimState;
+33 -33
View File
@@ -11,42 +11,42 @@ class GameObserver;
class CardGui;
class MTGGuiPlay: public PlayGuiObjectController {
protected:
int offset;
Player * currentPlayer;
MTGCardInstance * cardsGrid[SCREEN_WIDTH/5][SCREEN_HEIGHT/5];
int nb_creatures;
int nb_spells;
int nb_lands;
int cards_x_limit;
protected:
int offset;
Player * currentPlayer;
MTGCardInstance * cardsGrid[SCREEN_WIDTH/5][SCREEN_HEIGHT/5];
int nb_creatures;
int nb_spells;
int nb_lands;
int cards_x_limit;
JQuad * phaseIcons[24];
JQuad * mGlitter;
int mGlitterAlpha;
float mGlitterX, mGlitterY;
JTexture * mPhaseBarTexture;
JQuad * mIcons[7];
JTexture * mIconsTexture;
JTexture * mBgTex;
JQuad * mBg;
JQuad * phaseIcons[24];
JQuad * mGlitter;
int mGlitterAlpha;
float mGlitterX, mGlitterY;
JTexture * mPhaseBarTexture;
JQuad * mIcons[7];
JTexture * mIconsTexture;
JTexture * mBgTex;
JQuad * mBg;
JTexture * mBgTex2;
JQuad * mBg2;
int alphaBg[4];
void RenderPhaseBar();
void RenderPlayerInfo(int player);
JLBFont* mFont;
JTexture * mBgTex2;
JQuad * mBg2;
int alphaBg[4];
void RenderPhaseBar();
void RenderPlayerInfo(int player);
JLBFont* mFont;
void AddPlayersGuiInfo();
void initCardsDisplay();
void setCardPosition(CardGui * cardg, int player, int playerTurn, int spellMode);
void setTargettingCardPosition(CardGui * cardg, int player, int playerTurn);
void adjustCardPosition(CardGui * cardg);
public:
CardGui * getByCard(MTGCardInstance * card);
MTGGuiPlay(int id, GameObserver * game);
~MTGGuiPlay();
void Update(float dt);
void AddPlayersGuiInfo();
void initCardsDisplay();
void setCardPosition(CardGui * cardg, int player, int playerTurn, int spellMode);
void setTargettingCardPosition(CardGui * cardg, int player, int playerTurn);
void adjustCardPosition(CardGui * cardg);
public:
CardGui * getByCard(MTGCardInstance * card);
MTGGuiPlay(int id, GameObserver * game);
~MTGGuiPlay();
void Update(float dt);
void CheckUserInput(float dt);
virtual void Render();
void updateCards();
+120 -120
View File
@@ -1,120 +1,120 @@
/* Default observers/Abilities that are added to the game for a standard Magic Game
*/
#ifndef _MTGRULES_H_
#define _MTGRULES_H_
#include "../include/MTGAbility.h"
#include "../include/Counters.h"
class MTGAttackRule:public MTGAbility{
public:
int isReactingToClick(MTGCardInstance * card);
int reactToClick(MTGCardInstance * card);
int testDestroy();
MTGAttackRule(int _id);
const char * getMenuText(){return "Attacker";}
};
class MTGBlockRule:public MTGAbility{
public:
int isReactingToClick(MTGCardInstance * card);
int reactToClick(MTGCardInstance * card);
int testDestroy();
MTGBlockRule(int _id);
const char * getMenuText(){return "Blocker";}
};
/* Persist Rule */
class MTGPersistRule:public ListMaintainerAbility{
public:
MTGPersistRule(int _id):ListMaintainerAbility(_id){};
virtual void Update(float dt){
map<MTGCardInstance *,bool>::iterator it;
for ( it=cards.begin() ; it != cards.end(); it++ ){
MTGCardInstance * card = ((*it).first);
Player * p = card->controller();
if (p->game->graveyard->hasCard(card)){
#if defined (WIN32) || defined (LINUX)
OutputDebugString("persist passed test 1 !\n");
#endif
p->game->putInZone(card, p->game->graveyard, p->game->hand);
Spell * spell = NEW Spell(card);
p->game->putInZone(card, p->game->hand, p->game->stack);
spell->resolve();
delete spell;
#if defined (WIN32) || defined (LINUX)
OutputDebugString("persist passed test 2 !\n");
#endif
card->counters->addCounter(-1,-1);
#if defined (WIN32) || defined (LINUX)
OutputDebugString("persist passed test 3 !\n");
#endif
}
}
ListMaintainerAbility::Update(dt);
}
int canBeInList(MTGCardInstance * card){
if (card->basicAbilities[PERSIST] && !card->counters->hasCounter(-1,-1) ){
#if defined (WIN32) || defined (LINUX)
OutputDebugString("yay, persist !\n");
#endif
return 1;
}
return 0;
}
int added(MTGCardInstance * card){return 1;}
int removed(MTGCardInstance * card){return 0;}
int testDestroy(){return 0;}
};
/*
* Rule 420.5e (Legend Rule)
* If two or more legendary permanents with the same name are in play, all are put into their
* owners' graveyards. This is called the "legend rule." If only one of those permanents is
* legendary, this rule doesn't apply.
*/
class MTGLegendRule:public ListMaintainerAbility{
public:
MTGLegendRule(int _id):ListMaintainerAbility(_id){};
int canBeInList(MTGCardInstance * card){
if (card->basicAbilities[LEGENDARY]){
return 1;
}
return 0;
}
int added(MTGCardInstance * card){
map<MTGCardInstance *,bool>::iterator it;
int destroy = 0;
for ( it=cards.begin() ; it != cards.end(); it++ ){
MTGCardInstance * comparison = (*it).first;
if (comparison!= card && !strcmp(comparison->getName(), card->getName())){
comparison->owner->game->putInGraveyard(comparison);
destroy = 1;
}
}
if (destroy){
card->owner->game->putInGraveyard(card);
}
return 1;
}
int removed(MTGCardInstance * card){return 0;}
int testDestroy(){return 0;}
};
#endif
/* Default observers/Abilities that are added to the game for a standard Magic Game
*/
#ifndef _MTGRULES_H_
#define _MTGRULES_H_
#include "../include/MTGAbility.h"
#include "../include/Counters.h"
class MTGAttackRule:public MTGAbility{
public:
int isReactingToClick(MTGCardInstance * card);
int reactToClick(MTGCardInstance * card);
int testDestroy();
MTGAttackRule(int _id);
const char * getMenuText(){return "Attacker";}
};
class MTGBlockRule:public MTGAbility{
public:
int isReactingToClick(MTGCardInstance * card);
int reactToClick(MTGCardInstance * card);
int testDestroy();
MTGBlockRule(int _id);
const char * getMenuText(){return "Blocker";}
};
/* Persist Rule */
class MTGPersistRule:public ListMaintainerAbility{
public:
MTGPersistRule(int _id):ListMaintainerAbility(_id){};
virtual void Update(float dt){
map<MTGCardInstance *,bool>::iterator it;
for ( it=cards.begin() ; it != cards.end(); it++ ){
MTGCardInstance * card = ((*it).first);
Player * p = card->controller();
if (p->game->graveyard->hasCard(card)){
#if defined (WIN32) || defined (LINUX)
OutputDebugString("persist passed test 1 !\n");
#endif
p->game->putInZone(card, p->game->graveyard, p->game->hand);
Spell * spell = NEW Spell(card);
p->game->putInZone(card, p->game->hand, p->game->stack);
spell->resolve();
delete spell;
#if defined (WIN32) || defined (LINUX)
OutputDebugString("persist passed test 2 !\n");
#endif
card->counters->addCounter(-1,-1);
#if defined (WIN32) || defined (LINUX)
OutputDebugString("persist passed test 3 !\n");
#endif
}
}
ListMaintainerAbility::Update(dt);
}
int canBeInList(MTGCardInstance * card){
if (card->basicAbilities[PERSIST] && !card->counters->hasCounter(-1,-1) ){
#if defined (WIN32) || defined (LINUX)
OutputDebugString("yay, persist !\n");
#endif
return 1;
}
return 0;
}
int added(MTGCardInstance * card){return 1;}
int removed(MTGCardInstance * card){return 0;}
int testDestroy(){return 0;}
};
/*
* Rule 420.5e (Legend Rule)
* If two or more legendary permanents with the same name are in play, all are put into their
* owners' graveyards. This is called the "legend rule." If only one of those permanents is
* legendary, this rule doesn't apply.
*/
class MTGLegendRule:public ListMaintainerAbility{
public:
MTGLegendRule(int _id):ListMaintainerAbility(_id){};
int canBeInList(MTGCardInstance * card){
if (card->basicAbilities[LEGENDARY]){
return 1;
}
return 0;
}
int added(MTGCardInstance * card){
map<MTGCardInstance *,bool>::iterator it;
int destroy = 0;
for ( it=cards.begin() ; it != cards.end(); it++ ){
MTGCardInstance * comparison = (*it).first;
if (comparison!= card && !strcmp(comparison->getName(), card->getName())){
comparison->owner->game->putInGraveyard(comparison);
destroy = 1;
}
}
if (destroy){
card->owner->game->putInGraveyard(card);
}
return 1;
}
int removed(MTGCardInstance * card){return 0;}
int testDestroy(){return 0;}
};
#endif
+15 -15
View File
@@ -10,29 +10,29 @@ class ManaCostHybrid;
class ManaCost{
protected:
int cost[MTG_NB_COLORS+1];
ManaCostHybrid * hybrids[10];
int nbhybrids;
ManaCostHybrid * hybrids[10];
int nbhybrids;
public:
static ManaCost * parseManaCost(string value, ManaCost * _manacost = NULL);
static ManaCost * parseManaCost(string value, ManaCost * _manacost = NULL);
void init();
void x();
void x();
ManaCost(int _cost[], int nb_elems);
ManaCost();
~ManaCost();
~ManaCost();
ManaCost(ManaCost * _manaCost);
void copy (ManaCost * _manaCost);
int getConvertedCost();
void copy (ManaCost * _manaCost);
int getConvertedCost();
string toString();
int getCost(int color);
int getMainColor();
int hasColor(int color);
int remove (int color, int value);
int getMainColor();
int hasColor(int color);
int remove (int color, int value);
int add(int color, int value);
int addHybrid(int c1, int v1, int c2, int v2);
int tryToPayHybrids(ManaCostHybrid * _hybrids[], int _nbhybrids, int diff[]);
void randomDiffHybrids(ManaCost * _cost, int diff[]);
int add(ManaCost * _cost);
int pay (ManaCost * _cost);
int addHybrid(int c1, int v1, int c2, int v2);
int tryToPayHybrids(ManaCostHybrid * _hybrids[], int _nbhybrids, int diff[]);
void randomDiffHybrids(ManaCost * _cost, int diff[]);
int add(ManaCost * _cost);
int pay (ManaCost * _cost);
//return 1 if _cost can be paid with current data, 0 otherwise
int canAfford(ManaCost * _cost);
+17 -17
View File
@@ -1,17 +1,17 @@
#ifndef _MANACOST_HYBRID_H_
#define _MANACOST_HYBRID_H_
class ManaCostHybrid{
public:
int color1;
int color2;
int value1;
int value2;
ManaCostHybrid();
int hasColor(int color);
ManaCostHybrid(int c1,int v1,int c2,int v2);
void init(int c1,int v1,int c2,int v2);
int getConvertedCost();
};
#endif
#ifndef _MANACOST_HYBRID_H_
#define _MANACOST_HYBRID_H_
class ManaCostHybrid{
public:
int color1;
int color2;
int value1;
int value2;
ManaCostHybrid();
int hasColor(int color);
ManaCostHybrid(int c1,int v1,int c2,int v2);
void init(int c1,int v1,int c2,int v2);
int getConvertedCost();
};
#endif
+43 -43
View File
@@ -1,43 +1,43 @@
#ifndef _MENU_ITEM_H
#define _MENU_ITEM_H
#include <JLBFont.h>
#include <JGui.h>
#include <hge/hgeparticle.h>
#define SCALE_SELECTED 1.2f
#define SCALE_NORMAL 1.0f
class hgeParticleSystem;
class MenuItem: public JGuiObject
{
private:
bool mHasFocus;
JLBFont *mFont;
const char* const mText;
int mX;
int mY;
int updatedSinceLastRender;
float lastDt;
float mScale;
float mTargetScale;
JQuad * onQuad;
JQuad * offQuad;
hgeParticleSystem* mParticleSys;
public:
MenuItem(int id, JLBFont *font, const char* text, int x, int y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleQuad, bool hasFocus = false);
~MenuItem();
virtual void Render();
virtual void Update(float dt);
virtual void Entering();
virtual bool Leaving(u32 key);
virtual bool ButtonPressed();
};
#endif
#ifndef _MENU_ITEM_H
#define _MENU_ITEM_H
#include <JLBFont.h>
#include <JGui.h>
#include <hge/hgeparticle.h>
#define SCALE_SELECTED 1.2f
#define SCALE_NORMAL 1.0f
class hgeParticleSystem;
class MenuItem: public JGuiObject
{
private:
bool mHasFocus;
JLBFont *mFont;
const char* const mText;
int mX;
int mY;
int updatedSinceLastRender;
float lastDt;
float mScale;
float mTargetScale;
JQuad * onQuad;
JQuad * offQuad;
hgeParticleSystem* mParticleSys;
public:
MenuItem(int id, JLBFont *font, const char* text, int x, int y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleQuad, bool hasFocus = false);
~MenuItem();
virtual void Render();
virtual void Update(float dt);
virtual void Entering();
virtual bool Leaving(u32 key);
virtual bool ButtonPressed();
};
#endif
+40 -40
View File
@@ -1,40 +1,40 @@
#ifndef _OPTION_ITEM_H_
#define _OPTION_ITEM_H_
#include <JGui.h>
#include <string>
using std::string;
class OptionItem:public JGuiObject{
public:
string displayValue;
int id, value;
int hasFocus;
int maxValue, increment;
float x, y;
OptionItem(int id, string _displayValue, int _maxValue = 1, int _increment = 1);
~OptionItem();
virtual void Render();
virtual void Update(float dt);
virtual void Entering();
virtual bool Leaving();
void setData();
virtual void updateValue(){value+=increment; if (value>maxValue) value=0;};
};
class OptionsList{
public:
OptionItem * options[20];
int nbitems;
int current;
OptionsList();
~OptionsList();
void Render();
void Update(float dt);
void Add(OptionItem * item);
void save();
};
#endif
#ifndef _OPTION_ITEM_H_
#define _OPTION_ITEM_H_
#include <JGui.h>
#include <string>
using std::string;
class OptionItem:public JGuiObject{
public:
string displayValue;
int id, value;
int hasFocus;
int maxValue, increment;
float x, y;
OptionItem(int id, string _displayValue, int _maxValue = 1, int _increment = 1);
~OptionItem();
virtual void Render();
virtual void Update(float dt);
virtual void Entering();
virtual bool Leaving();
void setData();
virtual void updateValue(){value+=increment; if (value>maxValue) value=0;};
};
class OptionsList{
public:
OptionItem * options[20];
int nbitems;
int current;
OptionsList();
~OptionsList();
void Render();
void Update(float dt);
void Add(OptionItem * item);
void save();
};
#endif
+34 -34
View File
@@ -1,34 +1,34 @@
#ifndef _PHASERING_H_
#define _PHASERING_H_
#include <list>
using std::list;
/*
The class that handles the phases of a turn
*/
class Player;
class Phase{
public:
int id;
Player * player;
Phase(int _id, Player * _player):id(_id),player(_player){};
};
class PhaseRing{
public:
list<Phase *> ring;
list<Phase *>::iterator current;
Phase * getCurrentPhase();
Phase * forward();
Phase * goToPhase(int id, Player * player);
PhaseRing(Player* players[], int nbPlayers=2);
~PhaseRing();
int addPhase(Phase * phase);
int addPhaseBefore(int id, Player* player,int after_id, Player * after_player, int allOccurences = 1);
int removePhase (int id, Player * player, int allOccurences = 1);
};
#endif
#ifndef _PHASERING_H_
#define _PHASERING_H_
#include <list>
using std::list;
/*
The class that handles the phases of a turn
*/
class Player;
class Phase{
public:
int id;
Player * player;
Phase(int _id, Player * _player):id(_id),player(_player){};
};
class PhaseRing{
public:
list<Phase *> ring;
list<Phase *>::iterator current;
Phase * getCurrentPhase();
Phase * forward();
Phase * goToPhase(int id, Player * player);
PhaseRing(Player* players[], int nbPlayers=2);
~PhaseRing();
int addPhase(Phase * phase);
int addPhaseBefore(int id, Player* player,int after_id, Player * after_player, int allOccurences = 1);
int removePhase (int id, Player * player, int allOccurences = 1);
};
#endif
+77 -77
View File
@@ -1,78 +1,78 @@
/*
A class for all interactive objects in the play area (cards, avatars, etc...)
*/
#ifndef _PLAYGUIOBJECT_H_
#define _PLAYGUIOBJECT_H_
#define GUI_AVATAR 1
#define GUI_CARD 2
#define GUI_GRAVEYARD 3
#define GUI_LIBRARY 4
#include <JGui.h>
class MTGGameZone;
class Player;
class CardDisplay;
class PlayGuiObject: public JGuiObject, public JGuiListener{
protected:
public:
int wave;
float mHeight;
float defaultHeight;
bool mHasFocus;
int x;
int y;
int type;
virtual void Entering(){mHasFocus = true;};
virtual bool Leaving(u32 key){mHasFocus = false;return true;};
virtual bool ButtonPressed(){return true;};
virtual void Render(){};
virtual void Update(float dt);
PlayGuiObject(int id, float desiredHeight,float _x, float _y, bool hasFocus);
virtual void ButtonPressed(int controllerId, int controlId){};
virtual ~PlayGuiObject(){};
};
class GuiAvatar: public PlayGuiObject{
protected:
/*
A class for all interactive objects in the play area (cards, avatars, etc...)
*/
int avatarRed;
int currentLife;
public:
Player * player;
virtual void Render();
GuiAvatar(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * _player);
};
class GuiGameZone: public PlayGuiObject{
protected:
MTGGameZone * zone;
public:
CardDisplay * cd;
int showCards;
virtual void Render();
virtual void Update(float dt);
GuiGameZone(int id, float desiredHeight,float _x, float _y, bool hasFocus,MTGGameZone * _zone);
~GuiGameZone();
virtual void ButtonPressed(int controllerId, int controlId);
void toggleDisplay();
};
class GuiGraveyard: public GuiGameZone{
public:
GuiGraveyard(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * player);
};
class GuiLibrary: public GuiGameZone{
public:
GuiLibrary(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * player);
};
#endif
#ifndef _PLAYGUIOBJECT_H_
#define _PLAYGUIOBJECT_H_
#define GUI_AVATAR 1
#define GUI_CARD 2
#define GUI_GRAVEYARD 3
#define GUI_LIBRARY 4
#include <JGui.h>
class MTGGameZone;
class Player;
class CardDisplay;
class PlayGuiObject: public JGuiObject, public JGuiListener{
protected:
public:
int wave;
float mHeight;
float defaultHeight;
bool mHasFocus;
int x;
int y;
int type;
virtual void Entering(){mHasFocus = true;};
virtual bool Leaving(u32 key){mHasFocus = false;return true;};
virtual bool ButtonPressed(){return true;};
virtual void Render(){};
virtual void Update(float dt);
PlayGuiObject(int id, float desiredHeight,float _x, float _y, bool hasFocus);
virtual void ButtonPressed(int controllerId, int controlId){};
virtual ~PlayGuiObject(){};
};
class GuiAvatar: public PlayGuiObject{
protected:
int avatarRed;
int currentLife;
public:
Player * player;
virtual void Render();
GuiAvatar(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * _player);
};
class GuiGameZone: public PlayGuiObject{
protected:
MTGGameZone * zone;
public:
CardDisplay * cd;
int showCards;
virtual void Render();
virtual void Update(float dt);
GuiGameZone(int id, float desiredHeight,float _x, float _y, bool hasFocus,MTGGameZone * _zone);
~GuiGameZone();
virtual void ButtonPressed(int controllerId, int controlId);
void toggleDisplay();
};
class GuiGraveyard: public GuiGameZone{
public:
GuiGraveyard(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * player);
};
class GuiLibrary: public GuiGameZone{
public:
GuiLibrary(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * player);
};
#endif
@@ -1,6 +1,6 @@
#ifndef _PLAYGUIOBJECTCONTROLLER_H_
#define _PLAYGUIOBJECTCONTROLLER_H_
#ifndef _PLAYGUIOBJECTCONTROLLER_H_
#define _PLAYGUIOBJECTCONTROLLER_H_
#include "GuiLayers.h"
@@ -8,14 +8,14 @@ class PlayGuiObjectController : public GuiLayer{
protected:
int getClosestItem(int direction);
int getClosestItem(int direction, float tolerance);
static bool showBigCards;
static bool showBigCards;
public:
virtual void Update(float dt);
virtual void CheckUserInput(float dt);
PlayGuiObjectController(int id, GameObserver* _game):GuiLayer(id, _game){};
PlayGuiObjectController(int id, GameObserver* _game):GuiLayer(id, _game){};
virtual void Render(){GuiLayer::Render();};
};
#endif
#endif
+15 -15
View File
@@ -15,33 +15,33 @@ class Player: public Damageable, public Targetable{
ManaCost * manaPool;
public:
int typeAsTarget(){return TARGET_PLAYER;}
virtual int displayStack(){return 1;}
int typeAsTarget(){return TARGET_PLAYER;}
virtual int displayStack(){return 1;}
JTexture * mAvatarTex;
JQuad * mAvatar;
int canPutLandsIntoPlay;
MTGPlayerCards * game;
int testLife();
int afterDamage();
MTGPlayerCards * game;
int testLife();
int afterDamage();
Player(MTGPlayerCards * _deck, string deckFile);
virtual ~Player();
virtual ~Player();
void unTapPhase();
MTGInPlay * inPlay();
ManaCost * getManaPool();
int manaBurn();
void cleanupPhase();
virtual int Act(float dt){return 0;};
virtual int isAI(){return 0;};
Player * opponent();
int getId();
JQuad * getIcon();
string deckFile;
int manaBurn();
void cleanupPhase();
virtual int Act(float dt){return 0;};
virtual int isAI(){return 0;};
Player * opponent();
int getId();
JQuad * getIcon();
string deckFile;
};
class HumanPlayer: public Player{
public:
HumanPlayer(MTGPlayerCards * _deck, char * _deckFile);
};
+18 -18
View File
@@ -1,18 +1,18 @@
#ifndef _PLAYER_DATA_H_
#define _PLAYER_DATA_H_
#define PLAYER_SAVEFILE "Res/player/data.dat"
#include "../include/MTGDeck.h"
class PlayerData{
protected:
public:
int credits;
MTGDeck * collection;
PlayerData(MTGAllCards * allcards);
~PlayerData();
int save();
};
#endif
#ifndef _PLAYER_DATA_H_
#define _PLAYER_DATA_H_
#define PLAYER_SAVEFILE "Res/player/data.dat"
#include "../include/MTGDeck.h"
class PlayerData{
protected:
public:
int credits;
MTGDeck * collection;
PlayerData(MTGAllCards * allcards);
~PlayerData();
int save();
};
#endif
+31 -31
View File
@@ -1,31 +1,31 @@
#ifndef _PRICELIST_H_
#define _PRICELIST_H_
#include<string>
#include "../include/MTGDefinitions.h"
#include "../include/MTGDeck.h"
#include <stdio.h>
class Price{
public:
int cardid;
int price;
Price(int _cardid, int _price);
};
class PriceList{
private:
MTGAllCards * collection;
string filename;
Price * prices[TOTAL_NUMBER_OF_CARDS];
int nbprices;
public:
PriceList(const char * file, MTGAllCards * _collection);
~PriceList();
int save();
int getPrice(int cardId);
int setPrice(int cardId, int price);
};
#endif
#ifndef _PRICELIST_H_
#define _PRICELIST_H_
#include<string>
#include "../include/MTGDefinitions.h"
#include "../include/MTGDeck.h"
#include <stdio.h>
class Price{
public:
int cardid;
int price;
Price(int _cardid, int _price);
};
class PriceList{
private:
MTGAllCards * collection;
string filename;
Price * prices[TOTAL_NUMBER_OF_CARDS];
int nbprices;
public:
PriceList(const char * file, MTGAllCards * _collection);
~PriceList();
int save();
int getPrice(int cardId);
int setPrice(int cardId, int price);
};
#endif
+71 -71
View File
@@ -1,71 +1,71 @@
#ifndef _SHOP_ITEM_H
#define _SHOP_ITEM_H
#include <JGui.h>
#include <JLBFont.h>
#include "SimpleMenu.h"
#include "MTGDeck.h"
#include "../include/PriceList.h"
#include "../include/PlayerData.h"
#include "../include/CardDisplay.h"
#include <string>
using std::string;
class ShopItem:public JGuiObject{
private:
bool mHasFocus;
JLBFont *mFont;
string mText;
int mX;
int mY;
JQuad * quad;
JQuad * thumb;
float mScale;
float mTargetScale;
public:
int quantity;
MTGCard * card;
int price;
ShopItem(int id, JLBFont * font, int _cardid, int x, int y, bool hasFocus, MTGAllCards * collection, int _price);
ShopItem(int id, JLBFont * font, char* text, JQuad * _quad, JQuad * _thumb,int x, int y, bool hasFocus, int _price);
~ShopItem();
virtual void Render();
virtual void Update(float dt);
virtual void Entering();
virtual bool Leaving(u32 key);
virtual bool ButtonPressed();
const char * getText();
};
class ShopItems:public JGuiController,public JGuiListener{
private:
PlayerData * playerdata;
PriceList * pricelist;
int mX, mY, mHeight;
JLBFont* mFont;
MTGAllCards * collection;
SimpleMenu * dialog;
int showPriceDialog;
int setId;
MTGCardInstance * displayCards[100];
CardDisplay * display;
void safeDeleteDisplay();
public:
ShopItems(int id, JGuiListener* listener, JLBFont* font, int x, int y, MTGAllCards * _collection, int setId);
~ShopItems();
void Render();
virtual void Update(float dt);
void Add(int cardid);
void Add(char * text, JQuad * quad, JQuad * thumb,int _price);
void pricedialog(int id, int mode=1);
virtual void ButtonPressed(int controllerId, int controlId);
void savePriceList();
void saveAll();
};
#endif
#ifndef _SHOP_ITEM_H
#define _SHOP_ITEM_H
#include <JGui.h>
#include <JLBFont.h>
#include "SimpleMenu.h"
#include "MTGDeck.h"
#include "../include/PriceList.h"
#include "../include/PlayerData.h"
#include "../include/CardDisplay.h"
#include <string>
using std::string;
class ShopItem:public JGuiObject{
private:
bool mHasFocus;
JLBFont *mFont;
string mText;
int mX;
int mY;
JQuad * quad;
JQuad * thumb;
float mScale;
float mTargetScale;
public:
int quantity;
MTGCard * card;
int price;
ShopItem(int id, JLBFont * font, int _cardid, int x, int y, bool hasFocus, MTGAllCards * collection, int _price);
ShopItem(int id, JLBFont * font, char* text, JQuad * _quad, JQuad * _thumb,int x, int y, bool hasFocus, int _price);
~ShopItem();
virtual void Render();
virtual void Update(float dt);
virtual void Entering();
virtual bool Leaving(u32 key);
virtual bool ButtonPressed();
const char * getText();
};
class ShopItems:public JGuiController,public JGuiListener{
private:
PlayerData * playerdata;
PriceList * pricelist;
int mX, mY, mHeight;
JLBFont* mFont;
MTGAllCards * collection;
SimpleMenu * dialog;
int showPriceDialog;
int setId;
MTGCardInstance * displayCards[100];
CardDisplay * display;
void safeDeleteDisplay();
public:
ShopItems(int id, JGuiListener* listener, JLBFont* font, int x, int y, MTGAllCards * _collection, int setId);
~ShopItems();
void Render();
virtual void Update(float dt);
void Add(int cardid);
void Add(char * text, JQuad * quad, JQuad * thumb,int _price);
void pricedialog(int id, int mode=1);
virtual void ButtonPressed(int controllerId, int controlId);
void savePriceList();
void saveAll();
};
#endif
+24 -24
View File
@@ -1,24 +1,24 @@
/*
A class for very simple menus structure
*/
#ifndef _SIMPLEMENU_H_
#define _SIMPLEMENU_H_
#include <JGui.h>
#include <JLBFont.h>
#include <string>
class SimpleMenu:public JGuiController{
private:
int mHeight, mWidth, mX, mY;
JLBFont* mFont;
std::string title;
int displaytitle;
public:
SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, int width, const char * _title = NULL);
void Render();
void Add(int id, const char * Text);
};
#endif
/*
A class for very simple menus structure
*/
#ifndef _SIMPLEMENU_H_
#define _SIMPLEMENU_H_
#include <JGui.h>
#include <JLBFont.h>
#include <string>
class SimpleMenu:public JGuiController{
private:
int mHeight, mWidth, mX, mY;
JLBFont* mFont;
std::string title;
int displaytitle;
public:
SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, int width, const char * _title = NULL);
void Render();
void Add(int id, const char * Text);
};
#endif
+37 -37
View File
@@ -1,37 +1,37 @@
#ifndef _SIMPLEMENU_ITEM_H
#define _SIMPLEMENU_ITEM_H
#include <JLBFont.h>
#include <JGui.h>
#define SCALE_SELECTED 1.2f
#define SCALE_NORMAL 1.0f
class SimpleMenuItem: public JGuiObject
{
private:
bool mHasFocus;
JLBFont *mFont;
const char* mText;
int mX;
int mY;
float mScale;
float mTargetScale;
public:
SimpleMenuItem(int id, JLBFont *font, const char* text, int x, int y, bool hasFocus = false);
virtual void Render();
virtual void Update(float dt);
virtual void Entering();
virtual bool Leaving(u32 key);
virtual bool ButtonPressed();
};
#endif
#ifndef _SIMPLEMENU_ITEM_H
#define _SIMPLEMENU_ITEM_H
#include <JLBFont.h>
#include <JGui.h>
#define SCALE_SELECTED 1.2f
#define SCALE_NORMAL 1.0f
class SimpleMenuItem: public JGuiObject
{
private:
bool mHasFocus;
JLBFont *mFont;
const char* mText;
int mX;
int mY;
float mScale;
float mTargetScale;
public:
SimpleMenuItem(int id, JLBFont *font, const char* text, int x, int y, bool hasFocus = false);
virtual void Render();
virtual void Update(float dt);
virtual void Entering();
virtual bool Leaving(u32 key);
virtual bool ButtonPressed();
};
#endif
+25 -25
View File
@@ -1,25 +1,25 @@
#ifndef _SUBTYPES_H_
#define _SUBTYPES_H_
#include <string>
#include <map>
using std::string;
using std::map;
class Subtypes{
protected:
int nb_items;
map<string,int> values;
public:
static Subtypes * subtypesList;
Subtypes();
int Add(const char * subtype);
int find(const char * subtype);
int Add(string subtype);
int find(string subtype);
};
#endif
#ifndef _SUBTYPES_H_
#define _SUBTYPES_H_
#include <string>
#include <map>
using std::string;
using std::map;
class Subtypes{
protected:
int nb_items;
map<string,int> values;
public:
static Subtypes * subtypesList;
Subtypes();
int Add(const char * subtype);
int find(const char * subtype);
int Add(string subtype);
int find(string subtype);
};
#endif
+64 -64
View File
@@ -23,22 +23,22 @@ class CardDescriptor;
class TargetChooser: public TargetsList {
protected:
int forceTargetListReady;
protected:
int forceTargetListReady;
public:
TargetChooser(MTGCardInstance * card = NULL, int _maxtargets = -1);
public:
TargetChooser(MTGCardInstance * card = NULL, int _maxtargets = -1);
MTGCardInstance * source; //Optionnal source, used for protection from...
int maxtargets; //Set to -1 for "unlimited"
MTGCardInstance * source; //Optionnal source, used for protection from...
int maxtargets; //Set to -1 for "unlimited"
int ForceTargetListReady();
int targetsReadyCheck();
virtual int addTarget(Targetable * target);
virtual int canTarget(Targetable * _target);
virtual int full(){if (maxtargets != -1 && cursor>=maxtargets) {return 1;} else{return 0;}};
virtual int ready(){return cursor;};
int targetListSet();
int ForceTargetListReady();
int targetsReadyCheck();
virtual int addTarget(Targetable * target);
virtual int canTarget(Targetable * _target);
virtual int full(){if (maxtargets != -1 && cursor>=maxtargets) {return 1;} else{return 0;}};
virtual int ready(){return cursor;};
int targetListSet();
};
@@ -46,94 +46,94 @@ public:
class TargetChooserFactory{
public:
TargetChooser * createTargetChooser(string s, MTGCardInstance * card);
TargetChooser * createTargetChooser(string s, MTGCardInstance * card);
TargetChooser * createTargetChooser(MTGCardInstance * card);
};
class TargetZoneChooser:public TargetChooser{
public:
MTGGameZone * zones[6];
int nbzones;
int init(MTGGameZone ** _zones, int _nbzones);
TargetZoneChooser(MTGCardInstance * card = NULL, int _maxtargets = 1);
TargetZoneChooser(MTGGameZone ** _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
virtual int canTarget(Targetable * _card);
public:
MTGGameZone * zones[6];
int nbzones;
int init(MTGGameZone ** _zones, int _nbzones);
TargetZoneChooser(MTGCardInstance * card = NULL, int _maxtargets = 1);
TargetZoneChooser(MTGGameZone ** _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
virtual int canTarget(Targetable * _card);
};
class CreatureTargetChooser:public TargetZoneChooser{
public:
int maxpower;
int maxtoughness;
CreatureTargetChooser(MTGGameZone ** _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1);
CreatureTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1);
virtual int canTarget(Targetable * _card);
public:
int maxpower;
int maxtoughness;
CreatureTargetChooser(MTGGameZone ** _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1);
CreatureTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1);
virtual int canTarget(Targetable * _card);
};
class DamageableTargetChooser:public CreatureTargetChooser{
public:
DamageableTargetChooser(MTGGameZone ** _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1):CreatureTargetChooser( _zones,_nbzones, card, _maxtargets){};
DamageableTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1):CreatureTargetChooser(card, _maxtargets){};
virtual int canTarget(Targetable * target);
public:
DamageableTargetChooser(MTGGameZone ** _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1):CreatureTargetChooser( _zones,_nbzones, card, _maxtargets){};
DamageableTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1):CreatureTargetChooser(card, _maxtargets){};
virtual int canTarget(Targetable * target);
};
class PlayerTargetChooser:public TargetChooser{
public:
PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1):TargetChooser(card, _maxtargets){};
virtual int canTarget(Targetable * target);
public:
PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1):TargetChooser(card, _maxtargets){};
virtual int canTarget(Targetable * target);
};
class TypeTargetChooser:public TargetZoneChooser{
public:
int nbtypes;
int types[10];
TypeTargetChooser(const char * _type, MTGCardInstance * card = NULL, int _maxtargets = 1);
TypeTargetChooser(const char * _type, MTGGameZone ** _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
void addType(int type);
void addType(const char * type);
virtual int canTarget(Targetable * targe);
public:
int nbtypes;
int types[10];
TypeTargetChooser(const char * _type, MTGCardInstance * card = NULL, int _maxtargets = 1);
TypeTargetChooser(const char * _type, MTGGameZone ** _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
void addType(int type);
void addType(const char * type);
virtual int canTarget(Targetable * targe);
};
class DescriptorTargetChooser:public TargetZoneChooser{
public:
CardDescriptor * cd;
DescriptorTargetChooser(CardDescriptor * _cd, MTGCardInstance * card = NULL, int _maxtargets = 1);
DescriptorTargetChooser(CardDescriptor * _cd, MTGGameZone ** _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
virtual int canTarget(Targetable * target);
public:
CardDescriptor * cd;
DescriptorTargetChooser(CardDescriptor * _cd, MTGCardInstance * card = NULL, int _maxtargets = 1);
DescriptorTargetChooser(CardDescriptor * _cd, MTGGameZone ** _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
virtual int canTarget(Targetable * target);
};
class SpellTargetChooser:public TargetChooser{
public:
int color;
SpellTargetChooser( MTGCardInstance * card = NULL,int _color = -1, int _maxtargets = 1 );
virtual int canTarget(Targetable * target);
public:
int color;
SpellTargetChooser( MTGCardInstance * card = NULL,int _color = -1, int _maxtargets = 1 );
virtual int canTarget(Targetable * target);
};
class SpellOrPermanentTargetChooser:public TargetZoneChooser{
public:
int color;
SpellOrPermanentTargetChooser(MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1);
virtual int canTarget(Targetable * target);
public:
int color;
SpellOrPermanentTargetChooser(MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1);
virtual int canTarget(Targetable * target);
};
class DamageTargetChooser:public TargetChooser{
public:
int color;
int state;
DamageTargetChooser( MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1, int state = NOT_RESOLVED);
virtual int canTarget(Targetable * target);
public:
int color;
int state;
DamageTargetChooser( MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1, int state = NOT_RESOLVED);
virtual int canTarget(Targetable * target);
};
class DamageOrPermanentTargetChooser:public TargetZoneChooser{
public:
int color;
DamageOrPermanentTargetChooser(MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1);
virtual int canTarget(Targetable * target);
public:
int color;
DamageOrPermanentTargetChooser(MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1);
virtual int canTarget(Targetable * target);
};
#endif
+13 -13
View File
@@ -1,13 +1,13 @@
#ifndef _TARGETABLE_H_
#define _TARGETABLE_H_
#define TARGET_CARD 1
#define TARGET_PLAYER 2
#define TARGET_STACKACTION 3
class Targetable{
public:
virtual int typeAsTarget() = 0;
};
#endif
#ifndef _TARGETABLE_H_
#define _TARGETABLE_H_
#define TARGET_CARD 1
#define TARGET_PLAYER 2
#define TARGET_STACKACTION 3
class Targetable{
public:
virtual int typeAsTarget() = 0;
};
#endif
+34 -34
View File
@@ -1,34 +1,34 @@
#ifndef _TARGETSLIST_H_
#define _TARGETSLIST_H_
#define MAX_TARGETS 20
class Targetable;
class MTGCardInstance;
class Player;
class Damageable;
class Spell;
class Interruptible;
class Damage;
class TargetsList{
public:
int cursor;
TargetsList();
TargetsList(Targetable * _targets[], int nbtargets);
Targetable* targets[MAX_TARGETS];
int alreadyHasTarget(Targetable * target);
int removeTarget(Targetable * _card);
int toggleTarget(Targetable * _card);
virtual int addTarget(Targetable * _target);
MTGCardInstance * getNextCardTarget(MTGCardInstance * previous = 0);
Player * getNextPlayerTarget(Player * previous = 0);
Damageable * getNextDamageableTarget(Damageable * previous = 0);
Interruptible * getNextInterruptible(Interruptible * previous, int type);
Spell * getNextSpellTarget(Spell * previous = 0);
Damage * getNextDamageTarget(Damage * previous = 0);
Targetable * getNextTarget(Targetable * previous, int type);
void initTargets(){cursor = 0;};
};
#endif
#ifndef _TARGETSLIST_H_
#define _TARGETSLIST_H_
#define MAX_TARGETS 20
class Targetable;
class MTGCardInstance;
class Player;
class Damageable;
class Spell;
class Interruptible;
class Damage;
class TargetsList{
public:
int cursor;
TargetsList();
TargetsList(Targetable * _targets[], int nbtargets);
Targetable* targets[MAX_TARGETS];
int alreadyHasTarget(Targetable * target);
int removeTarget(Targetable * _card);
int toggleTarget(Targetable * _card);
virtual int addTarget(Targetable * _target);
MTGCardInstance * getNextCardTarget(MTGCardInstance * previous = 0);
Player * getNextPlayerTarget(Player * previous = 0);
Damageable * getNextDamageableTarget(Damageable * previous = 0);
Interruptible * getNextInterruptible(Interruptible * previous, int type);
Spell * getNextSpellTarget(Spell * previous = 0);
Damage * getNextDamageTarget(Damage * previous = 0);
Targetable * getNextTarget(Targetable * previous, int type);
void initTargets(){cursor = 0;};
};
#endif
+85 -85
View File
@@ -1,85 +1,85 @@
#ifndef _TESTSUITE_AI_H_
#define _TESTSUITE_AI_H_
#define MAX_TESTSUITE_ACTIONS 100
#define MAX_TESTUITE_CARDS 100
#include "../include/AIPlayer.h"
class TestSuiteActions{
public:
int nbitems;
string actions[MAX_TESTSUITE_ACTIONS];
void add(string action);
TestSuiteActions();
void cleanup();
};
class TestSuitePlayerZone{
public:
int cards[MAX_TESTUITE_CARDS];
int nbitems;
void add(int cardid);
TestSuitePlayerZone();
void cleanup();
};
class TestSuitePlayerData{
public:
int life;
ManaCost * manapool;
TestSuitePlayerZone zones[5];
TestSuitePlayerData();
~TestSuitePlayerData();
void cleanup();
};
class TestSuiteState{
public:
int phase;
void parsePlayerState(int playerId, string s);
TestSuiteState();
TestSuitePlayerData playerData[2];
void cleanup();
};
class TestSuite{
public:
float timerLimit;
int currentAction;
TestSuiteState initState;
TestSuiteState endState;
TestSuiteActions actions;
string files[128];
int nbfiles;
int currentfile;
void load(const char * filename);
TestSuite(const char * filename);
void initGame();
int assertGame();
MTGPlayerCards * buildDeck(MTGAllCards * collection, int playerId);
string getNextAction();
int phaseStrToInt(string s);
MTGCardInstance * getCardByMTGId(int mtgid);
Interruptible * getActionByMTGId(int mtgid);
int loadNext();
void cleanup();
int Log(const char * text);
};
class TestSuiteAI:public AIPlayer{
public:
TestSuite * suite;
float timer;
TestSuiteAI(MTGAllCards * collection,TestSuite * suite, int playerId);
virtual int Act(float dt);
virtual int displayStack(){return 1;}
};
#endif
#ifndef _TESTSUITE_AI_H_
#define _TESTSUITE_AI_H_
#define MAX_TESTSUITE_ACTIONS 100
#define MAX_TESTUITE_CARDS 100
#include "../include/AIPlayer.h"
class TestSuiteActions{
public:
int nbitems;
string actions[MAX_TESTSUITE_ACTIONS];
void add(string action);
TestSuiteActions();
void cleanup();
};
class TestSuitePlayerZone{
public:
int cards[MAX_TESTUITE_CARDS];
int nbitems;
void add(int cardid);
TestSuitePlayerZone();
void cleanup();
};
class TestSuitePlayerData{
public:
int life;
ManaCost * manapool;
TestSuitePlayerZone zones[5];
TestSuitePlayerData();
~TestSuitePlayerData();
void cleanup();
};
class TestSuiteState{
public:
int phase;
void parsePlayerState(int playerId, string s);
TestSuiteState();
TestSuitePlayerData playerData[2];
void cleanup();
};
class TestSuite{
public:
float timerLimit;
int currentAction;
TestSuiteState initState;
TestSuiteState endState;
TestSuiteActions actions;
string files[128];
int nbfiles;
int currentfile;
void load(const char * filename);
TestSuite(const char * filename);
void initGame();
int assertGame();
MTGPlayerCards * buildDeck(MTGAllCards * collection, int playerId);
string getNextAction();
int phaseStrToInt(string s);
MTGCardInstance * getCardByMTGId(int mtgid);
Interruptible * getActionByMTGId(int mtgid);
int loadNext();
void cleanup();
int Log(const char * text);
};
class TestSuiteAI:public AIPlayer{
public:
TestSuite * suite;
float timer;
TestSuiteAI(MTGAllCards * collection,TestSuite * suite, int playerId);
virtual int Act(float dt);
virtual int displayStack(){return 1;}
};
#endif
+9 -9
View File
@@ -22,9 +22,9 @@ class CardTexture{
JTexture* tex;
JQuad* quad;
public:
int lastTime;
int type;
int nbpixels;
int lastTime;
int type;
int nbpixels;
int getId();
JQuad * getQuad();
@@ -39,18 +39,18 @@ class TexturesCache{
int lastTime;
int nb_textures;
int delete_previous;
int totalsize;
int totalsize;
CardTexture * cache[MAX_CACHE_OBJECTS];
public:
int isInCache(MTGCard * card, int type=CACHE_CARD);
TexturesCache();
~TexturesCache();
int getOldestQuad();
void removeQuad(int id);
int cleanup();
~TexturesCache();
int getOldestQuad();
void removeQuad(int id);
int cleanup();
int getCacheById(int id, int type=CACHE_CARD);
JQuad * getQuad(MTGCard * card, int type=CACHE_CARD);
JQuad * getThumb(MTGCard * card){return getQuad(card, CACHE_THUMB);};
JQuad * getThumb(MTGCard * card){return getQuad(card, CACHE_THUMB);};
};
+22 -22
View File
@@ -1,22 +1,22 @@
#ifndef _DEBUG_H_
#define _DEBUG_H_
#if defined (WIN32) || defined (LINUX)
#define TESTSUITE 1
#endif
#ifdef _DEBUG
#define NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#else
#define NEW new
#endif
#ifdef LINUX
#ifdef _DEBUG
#define OutputDebugString(val) (std::cerr << val);
#else
#define OutputDebugString(val) {}
#endif
#endif
#endif
#ifndef _DEBUG_H_
#define _DEBUG_H_
#if defined (WIN32) || defined (LINUX)
#define TESTSUITE 1
#endif
#ifdef _DEBUG
#define NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#else
#define NEW new
#endif
#ifdef LINUX
#ifdef _DEBUG
#define OutputDebugString(val) (std::cerr << val);
#else
#define OutputDebugString(val) {}
#endif
#endif
#endif
+50 -50
View File
@@ -1,50 +1,50 @@
#ifndef _UTILS_H_
#define _UTILS_H_
#include <JGE.h>
#if defined (WIN32) || defined (LINUX)
#else
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspiofilemgr.h>
#include <pspdebug.h>
#include <psputility.h>
#include <pspgu.h>
#include <psprtc.h>
#endif
#include <math.h>
#include <stdio.h>
#include <string>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#define BUFSIZE 600
using std::string;
template <typename T, size_t N>
char ( &_ArraySizeHelper( T (&array)[N] ))[N];
#define countof( array ) (sizeof( _ArraySizeHelper( array ) ))
int lowercase(string source);
int substr_copy(char *source, char *target, int start, int len);
int append_str(char * s1, char * s2, char * target);
int filesize(const char * filename);
int read_file (const char * filename, char * buffer, int filesize);
int readline (char * in_buffer, char * out_buffer, int cursor);
int readfile_to_ints(const char * filename, int * out_buffer);
#endif
#ifndef _UTILS_H_
#define _UTILS_H_
#include <JGE.h>
#if defined (WIN32) || defined (LINUX)
#else
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspiofilemgr.h>
#include <pspdebug.h>
#include <psputility.h>
#include <pspgu.h>
#include <psprtc.h>
#endif
#include <math.h>
#include <stdio.h>
#include <string>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#define BUFSIZE 600
using std::string;
template <typename T, size_t N>
char ( &_ArraySizeHelper( T (&array)[N] ))[N];
#define countof( array ) (sizeof( _ArraySizeHelper( array ) ))
int lowercase(string source);
int substr_copy(char *source, char *target, int start, int len);
int append_str(char * s1, char * s2, char * target);
int filesize(const char * filename);
int read_file (const char * filename, char * buffer, int filesize);
int readline (char * in_buffer, char * out_buffer, int cursor);
int readfile_to_ints(const char * filename, int * out_buffer);
#endif