- Moved the card collection out of the GameApp class to clean up the dependencies
- Added method to build a card collection independently of the GUI to ease my unitary test application - Added part of some network GUI I'm working on, it's #ifdef out, I'm only committing this part to ease later merges - Added the beginning of a serialization code of the Player and related classes used for network support - various other minor cleanup
This commit is contained in:
@@ -2797,7 +2797,7 @@ public:
|
||||
ActivatedAbility(_id, _source, _cost, 0, _doTap), tokenId(tokenId), starfound(starfound),multiplier(multiplier), who(who),aLivingWeapon(aLivingWeapon)
|
||||
{
|
||||
if (!multiplier) this->multiplier = NEW WParsedInt(1);
|
||||
MTGCard * card = GameApp::collection->getCardById(tokenId);
|
||||
MTGCard * card = MTGCollection()->getCardById(tokenId);
|
||||
if (card) name = card->data->getName();
|
||||
battleReady = false;
|
||||
}
|
||||
@@ -2868,7 +2868,7 @@ public:
|
||||
//MTGCardInstance * myToken;
|
||||
if (tokenId)
|
||||
{
|
||||
MTGCard * card = GameApp::collection->getCardById(tokenId);
|
||||
MTGCard * card = MTGCollection()->getCardById(tokenId);
|
||||
myToken = NEW MTGCardInstance(card, source->controller()->game);
|
||||
|
||||
}
|
||||
|
||||
@@ -23,9 +23,12 @@
|
||||
|
||||
#include "CardEffect.h"
|
||||
|
||||
#define PLAYER_TYPE_CPU 0
|
||||
#define PLAYER_TYPE_HUMAN 1
|
||||
#define PLAYER_TYPE_TESTSUITE 2
|
||||
enum
|
||||
{
|
||||
PLAYER_TYPE_CPU = 0,
|
||||
PLAYER_TYPE_HUMAN=1,
|
||||
PLAYER_TYPE_TESTSUITE=2
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -78,7 +81,6 @@ public:
|
||||
static JMusic* music;
|
||||
static string currentMusicFile;
|
||||
static void playMusic(string filename, bool loop = true);
|
||||
static MTGAllCards * collection;
|
||||
static int players[2];
|
||||
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@ private:
|
||||
JGuiController* mGuiController;
|
||||
SimpleMenu* subMenuController;
|
||||
SimpleMenu* gameTypeMenu;
|
||||
int hasChosenGameType;
|
||||
bool hasChosenGameType;
|
||||
JQuadPtr mIcons[10];
|
||||
JTexture * bgTexture;
|
||||
JQuadPtr mBg;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "MTGDefinitions.h"
|
||||
#include "GameApp.h"
|
||||
#include "WResourceManager.h"
|
||||
#include <dirent.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -94,13 +95,18 @@ private:
|
||||
MTGCard * tempCard; //used by parser
|
||||
CardPrimitive * tempPrimitive; //used by parser
|
||||
int currentGrade; //used by Parser (we don't want an additional attribute for the primitives for that as it is only used at load time)
|
||||
static MTGAllCards* instance;
|
||||
|
||||
protected:
|
||||
int conf_read_mode;
|
||||
int colorsCount[Constants::MTG_NB_COLORS];
|
||||
int total_cards;
|
||||
GameApp * parent;
|
||||
void init();
|
||||
void initCounters();
|
||||
MTGAllCards();
|
||||
MTGAllCards(const char * config_file, const char * set_name);
|
||||
~MTGAllCards();
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
@@ -111,11 +117,7 @@ public:
|
||||
vector<int> ids;
|
||||
map<int, MTGCard *> collection;
|
||||
map<string, CardPrimitive *> primitives;
|
||||
MTGAllCards();
|
||||
~MTGAllCards();
|
||||
MTGCard * _(int id);
|
||||
void destroyAllCards();
|
||||
MTGAllCards(const char * config_file, const char * set_name);
|
||||
MTGCard * getCardById(int id);
|
||||
MTGCard * getCardByName(string name);
|
||||
int load(const char * config_file, const char * setName = NULL, int autoload = 1);
|
||||
@@ -124,6 +126,13 @@ public:
|
||||
int countBySet(int setId);
|
||||
int totalCards();
|
||||
int randomCardId();
|
||||
|
||||
static void loadPrimitives(const char *root_directory);
|
||||
static void loadSets(const char *root_directory, const char* filename);
|
||||
static void loadInstance();
|
||||
static void unloadAll();
|
||||
static inline MTGAllCards* getInstance() { return instance; };
|
||||
|
||||
private:
|
||||
map<string, MTGCard *> mtgCardByNameCache;
|
||||
int processConfLine(string &s, MTGCard* card, CardPrimitive * primitive);
|
||||
@@ -131,6 +140,8 @@ private:
|
||||
CardPrimitive * addPrimitive(CardPrimitive * primitive, MTGCard * card = NULL);
|
||||
};
|
||||
|
||||
#define MTGCollection() MTGAllCards::getInstance()
|
||||
|
||||
class MTGDeck
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -95,7 +95,7 @@ class MTGGameZone {
|
||||
static int zoneStringToId(string zoneName);
|
||||
static MTGGameZone *intToZone(int zoneId, MTGCardInstance * source = NULL,MTGCardInstance * target = NULL);
|
||||
bool needShuffle;
|
||||
virtual const char * getName(){return "zone";};
|
||||
virtual const char * getName(){return "zone";};
|
||||
virtual ostream& toString(ostream&) const;
|
||||
};
|
||||
|
||||
@@ -156,6 +156,7 @@ class MTGPlayerCards {
|
||||
MTGGameZone * garbage;
|
||||
MTGGameZone * temp;
|
||||
|
||||
MTGPlayerCards();
|
||||
MTGPlayerCards(int * idList, int idListSize);
|
||||
MTGPlayerCards(MTGDeck * deck);
|
||||
~MTGPlayerCards();
|
||||
@@ -178,5 +179,7 @@ class MTGPlayerCards {
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream&, const MTGGameZone&);
|
||||
ostream& operator<<(ostream&, const MTGPlayerCards&);
|
||||
istream& operator>>(istream&, MTGPlayerCards&);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -116,5 +116,6 @@ public:
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream&, const Player&);
|
||||
istream& operator>>(istream& in, Player& p);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user