- 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
|
||||
|
||||
@@ -205,7 +205,7 @@ void AIStats::Render()
|
||||
AIStat * stat = *it;
|
||||
if (stat->value > 0)
|
||||
{
|
||||
MTGCard * card = GameApp::collection->getCardById(stat->source);
|
||||
MTGCard * card = MTGCollection()->getCardById(stat->source);
|
||||
if (card)
|
||||
{
|
||||
sprintf(buffer, "%s %i", card->data->getName().c_str(), stat->value);
|
||||
|
||||
@@ -1384,7 +1384,7 @@ AACloner::AACloner(int _id, MTGCardInstance * _source, MTGCardInstance * _target
|
||||
if (_target)
|
||||
{
|
||||
MTGCardInstance * myClone = NULL;
|
||||
MTGCard* clone = (_target->isToken ? _target: GameApp::collection->getCardByName(_target->name));
|
||||
MTGCard* clone = (_target->isToken ? _target: MTGCollection()->getCardByName(_target->name));
|
||||
if (who != 1)
|
||||
{
|
||||
myClone = NEW MTGCardInstance(clone, source->controller()->game);
|
||||
|
||||
@@ -49,7 +49,7 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app)
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
if (!g->turn)
|
||||
return;
|
||||
PlayerData * playerdata = NEW PlayerData(app->collection);
|
||||
PlayerData * playerdata = NEW PlayerData(MTGCollection());
|
||||
if (!p1->isAI() && p2->isAI() && p1 != g->gameOver)
|
||||
{
|
||||
gameLength = time(0) - g->startedAt;
|
||||
@@ -383,8 +383,7 @@ int Credits::addCardToCollection(int cardId, MTGDeck * collection)
|
||||
*/
|
||||
int Credits::addCardToCollection(int cardId)
|
||||
{
|
||||
MTGAllCards * ac = GameApp::collection;
|
||||
PlayerData * playerdata = NEW PlayerData(ac);
|
||||
PlayerData * playerdata = NEW PlayerData(MTGCollection());
|
||||
int result = addCardToCollection(cardId, playerdata->collection);
|
||||
playerdata->collection->save();
|
||||
return result;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
#define DEFAULT_DURATION .25
|
||||
|
||||
MTGAllCards * GameApp::collection = NULL;
|
||||
int GameApp::players[] = { 0, 0 };
|
||||
int GameApp::HasMusic = 1;
|
||||
JMusic * GameApp::music = NULL;
|
||||
@@ -67,7 +66,6 @@ GameApp::GameApp() :
|
||||
|
||||
mCurrentState = NULL;
|
||||
mNextState = NULL;
|
||||
collection = NULL;
|
||||
|
||||
music = NULL;
|
||||
}
|
||||
@@ -215,7 +213,7 @@ void GameApp::Create()
|
||||
jq = WResourceManager::Instance()->RetrieveQuad("phasebar.png", 0, 0, 0, 0, "phasebar", RETRIEVE_MANAGE);
|
||||
|
||||
LOG("Init Collection");
|
||||
collection = NEW MTGAllCards();
|
||||
MTGAllCards::loadInstance();
|
||||
|
||||
LOG("Creating Game States");
|
||||
mGameStates[GAME_STATE_DECK_VIEWER] = NEW GameStateDeckViewer(this);
|
||||
@@ -271,11 +269,7 @@ void GameApp::Destroy()
|
||||
}
|
||||
}
|
||||
|
||||
if (collection)
|
||||
{
|
||||
collection->destroyAllCards();
|
||||
SAFE_DELETE(collection);
|
||||
}
|
||||
MTGAllCards::unloadAll();
|
||||
|
||||
DeckManager::EndInstance();
|
||||
DeckStats::EndInstance();
|
||||
|
||||
@@ -511,7 +511,7 @@ void GameSettings::automaticStyle(Player * p1, Player * p2)
|
||||
MTGDeck * decks[2];
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
decks[i] = new MTGDeck(GameApp::collection);
|
||||
decks[i] = new MTGDeck(MTGCollection());
|
||||
Player * p;
|
||||
if (i == 0)
|
||||
p = p1;
|
||||
@@ -677,7 +677,7 @@ void GameSettings::checkProfile()
|
||||
}
|
||||
|
||||
//Validation of collection, etc, only happens if the game is up.
|
||||
if (theGame == NULL || theGame->collection == NULL)
|
||||
if (theGame == NULL || MTGCollection() == NULL)
|
||||
return;
|
||||
|
||||
string pcFile = profileFile(PLAYER_COLLECTION, "", false);
|
||||
@@ -707,7 +707,7 @@ void GameSettings::checkProfile()
|
||||
int ok = 0;
|
||||
for (int i = 0; i < setlist.size(); i++)
|
||||
{
|
||||
int value = theGame->collection->countBySet(i);
|
||||
int value = MTGCollection()->countBySet(i);
|
||||
if (value > maxcards)
|
||||
{
|
||||
maxcards = value;
|
||||
@@ -734,10 +734,10 @@ void GameSettings::checkProfile()
|
||||
void GameSettings::createUsersFirstDeck(int setId)
|
||||
{
|
||||
|
||||
if (theGame == NULL || theGame->collection == NULL)
|
||||
if (theGame == NULL || MTGCollection() == NULL)
|
||||
return;
|
||||
|
||||
MTGDeck *mCollection = NEW MTGDeck(options.profileFile(PLAYER_COLLECTION, "", false).c_str(), theGame->collection);
|
||||
MTGDeck *mCollection = NEW MTGDeck(options.profileFile(PLAYER_COLLECTION, "", false).c_str(), MTGCollection());
|
||||
if (mCollection->totalCards() > 0)
|
||||
return;
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ bool GameStateAwards::enterSet(int setid)
|
||||
|
||||
setSrc = NEW WSrcCards();
|
||||
setSrc->addFilter(NEW WCFilterSet(setid));
|
||||
setSrc->loadMatches(mParent->collection);
|
||||
setSrc->loadMatches(MTGCollection());
|
||||
setSrc->bakeFilters();
|
||||
setSrc->Sort(WSrcCards::SORT_COLLECTOR);
|
||||
|
||||
@@ -255,7 +255,7 @@ bool GameStateAwards::enterStats(int option)
|
||||
{
|
||||
if (option != Options::AWARD_COLLECTOR)
|
||||
return false;
|
||||
DeckDataWrapper* ddw = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), mParent->collection));
|
||||
DeckDataWrapper* ddw = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), MTGCollection()));
|
||||
if (!ddw)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -216,8 +216,8 @@ void GameStateDeckViewer::Start()
|
||||
lastPos = 0;
|
||||
lastTotal = 0;
|
||||
|
||||
pricelist = NEW PriceList(JGE_GET_RES("settings/prices.dat").c_str(), mParent->collection);
|
||||
playerdata = NEW PlayerData(mParent->collection);
|
||||
pricelist = NEW PriceList(JGE_GET_RES("settings/prices.dat").c_str(), MTGCollection());
|
||||
playerdata = NEW PlayerData(MTGCollection());
|
||||
myCollection = NEW DeckDataWrapper(playerdata->collection);
|
||||
myCollection->Sort(WSrcCards::SORT_ALPHA);
|
||||
displayed_deck = myCollection;
|
||||
@@ -1415,14 +1415,14 @@ int GameStateDeckViewer::loadDeck(int deckid)
|
||||
if (!stw)
|
||||
{
|
||||
DeckManager *deckManager = DeckManager::GetInstance();
|
||||
stw = deckManager->getExtendedStatsForDeckId( deckid, mParent->collection, false );
|
||||
stw = deckManager->getExtendedStatsForDeckId( deckid, MTGCollection(), false );
|
||||
}
|
||||
|
||||
stw->currentPage = 0;
|
||||
stw->pageCount = 9;
|
||||
stw->needUpdate = true;
|
||||
|
||||
if (!playerdata) playerdata = NEW PlayerData(mParent->collection);
|
||||
if (!playerdata) playerdata = NEW PlayerData(MTGCollection());
|
||||
SAFE_DELETE(myCollection);
|
||||
myCollection = NEW DeckDataWrapper(playerdata->collection);
|
||||
myCollection->Sort(WSrcCards::SORT_ALPHA);
|
||||
@@ -1435,7 +1435,7 @@ int GameStateDeckViewer::loadDeck(int deckid)
|
||||
SAFE_DELETE(myDeck->parent);
|
||||
SAFE_DELETE(myDeck);
|
||||
}
|
||||
myDeck = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(deckname, "", false, false).c_str(), mParent->collection));
|
||||
myDeck = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(deckname, "", false, false).c_str(), MTGCollection()));
|
||||
|
||||
// Check whether the cards in the deck are actually available in the player's collection:
|
||||
int cheatmode = options[Options::CHEATMODE].number;
|
||||
|
||||
@@ -92,7 +92,7 @@ void GameStateDuel::Start()
|
||||
|
||||
#ifdef TESTSUITE
|
||||
SAFE_DELETE(testSuite);
|
||||
testSuite = NEW TestSuite(JGE_GET_RES("test/_tests.txt").c_str(),mParent->collection);
|
||||
testSuite = NEW TestSuite(JGE_GET_RES("test/_tests.txt").c_str(),MTGCollection());
|
||||
#endif
|
||||
|
||||
mGamePhase = DUEL_STATE_CHOOSE_DECK1;
|
||||
@@ -169,7 +169,7 @@ void GameStateDuel::loadPlayer(int playerId, int decknb, int isAI)
|
||||
sprintf(deckFile, "%s/deck%i.txt", options.profileFile().c_str(), decknb);
|
||||
char deckFileSmall[255];
|
||||
sprintf(deckFileSmall, "player_deck%i", decknb);
|
||||
MTGDeck * tempDeck = NEW MTGDeck(deckFile, mParent->collection);
|
||||
MTGDeck * tempDeck = NEW MTGDeck(deckFile, MTGCollection());
|
||||
mPlayers[playerId] = NEW HumanPlayer(tempDeck, deckFile, deckFileSmall);
|
||||
SAFE_DELETE( tempDeck );
|
||||
}
|
||||
@@ -178,7 +178,7 @@ void GameStateDuel::loadPlayer(int playerId, int decknb, int isAI)
|
||||
AIPlayerFactory playerCreator;
|
||||
Player * opponent = NULL;
|
||||
if (playerId == 1) opponent = mPlayers[0];
|
||||
mPlayers[playerId] = playerCreator.createAIPlayer(mParent->collection, opponent, decknb);
|
||||
mPlayers[playerId] = playerCreator.createAIPlayer(MTGCollection(), opponent, decknb);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -186,7 +186,7 @@ void GameStateDuel::loadPlayer(int playerId, int decknb, int isAI)
|
||||
AIPlayerFactory playerCreator;
|
||||
Player * opponent = NULL;
|
||||
if (playerId == 1) opponent = mPlayers[0];
|
||||
mPlayers[playerId] = playerCreator.createAIPlayer(mParent->collection, opponent);
|
||||
mPlayers[playerId] = playerCreator.createAIPlayer(MTGCollection(), opponent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ void GameStateDuel::loadTestSuitePlayers()
|
||||
game->startGame(rules);
|
||||
if (mParent->gameType == GAME_TYPE_MOMIR)
|
||||
{
|
||||
game->addObserver(NEW MTGMomirRule(-1, mParent->collection));
|
||||
game->addObserver(NEW MTGMomirRule(-1, MTGCollection()));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -228,8 +228,8 @@ void GameStateDuel::End()
|
||||
mPlayers[0]->End();
|
||||
if (mParent->players[1] != PLAYER_TYPE_TESTSUITE)
|
||||
{
|
||||
DeckManager::GetInstance()->saveDeck( mPlayers[1]->deckFile, mParent->collection);
|
||||
DeckManager::GetInstance()->saveDeck( mPlayers[0]->deckFile, mParent->collection);
|
||||
DeckManager::GetInstance()->saveDeck( mPlayers[1]->deckFile, MTGCollection());
|
||||
DeckManager::GetInstance()->saveDeck( mPlayers[0]->deckFile, MTGCollection());
|
||||
}
|
||||
}
|
||||
else if ( !mPlayers[1] && mPlayers[0] )
|
||||
@@ -405,7 +405,7 @@ void GameStateDuel::Update(float dt)
|
||||
game->startGame(rules);
|
||||
if (mParent->gameType == GAME_TYPE_MOMIR)
|
||||
{
|
||||
game->addObserver(NEW MTGMomirRule(-1, mParent->collection));
|
||||
game->addObserver(NEW MTGMomirRule(-1, MTGCollection()));
|
||||
}
|
||||
|
||||
//start of in game music code
|
||||
@@ -493,7 +493,7 @@ void GameStateDuel::Update(float dt)
|
||||
menu->Update(dt);
|
||||
if (menu->isClosed())
|
||||
{
|
||||
PlayerData * playerdata = NEW PlayerData(mParent->collection);
|
||||
PlayerData * playerdata = NEW PlayerData(MTGCollection());
|
||||
playerdata->taskList->passOneDay();
|
||||
playerdata->taskList->save();
|
||||
SAFE_DELETE(playerdata);
|
||||
@@ -672,7 +672,7 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
|
||||
if (!popupScreen)
|
||||
{
|
||||
popupScreen = NEW SimplePopup(DUEL_MENU_DETAILED_DECK2_INFO, this, Fonts::MAIN_FONT, "Detailed Information",
|
||||
selectedDeck, mParent->collection);
|
||||
selectedDeck, MTGCollection());
|
||||
popupScreen->Render();
|
||||
selectedAIDeckId = selectedDeck->getDeckId();
|
||||
}
|
||||
@@ -721,7 +721,7 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
|
||||
if (!popupScreen)
|
||||
{
|
||||
popupScreen = NEW SimplePopup(DUEL_MENU_DETAILED_DECK1_INFO, this, Fonts::MAIN_FONT, "Detailed Information",
|
||||
selectedDeck, mParent->collection);
|
||||
selectedDeck, MTGCollection());
|
||||
popupScreen->Render();
|
||||
selectedPlayerDeckId = deckmenu->getSelectedDeckId();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
#include "utils.h"
|
||||
#include "WFont.h"
|
||||
#include <JLogger.h>
|
||||
#ifdef NETWORK_SUPPORT
|
||||
#include <JNetwork.h>
|
||||
#endif//NETWORK_SUPPORT
|
||||
|
||||
static const char* GAME_VERSION = "WTH?! 0.14.1 - wololo.net";
|
||||
|
||||
@@ -57,14 +60,17 @@ enum
|
||||
MENUITEM_OPTIONS,
|
||||
MENUITEM_EXIT,
|
||||
SUBMENUITEM_1PLAYER,
|
||||
SUBMENUITEM_2PLAYER,
|
||||
#ifdef NETWORK_SUPPORT
|
||||
SUBMENUITEM_2PLAYER_SERVER,
|
||||
SUBMENUITEM_2PLAYER_CLIENT,
|
||||
#endif //NETWORK_SUPPORT
|
||||
SUBMENUITEM_DEMO,
|
||||
SUBMENUITEM_TESTSUITE,
|
||||
SUBMENUITEM_MOMIR,
|
||||
SUBMENUITEM_CLASSIC,
|
||||
SUBMENUITEM_RANDOM1,
|
||||
SUBMENUITEM_RANDOM2,
|
||||
SUBMENUITEM_STORY,
|
||||
SUBMENUITEM_STORY
|
||||
};
|
||||
|
||||
GameStateMenu::GameStateMenu(GameApp* parent) :
|
||||
@@ -147,7 +153,7 @@ void GameStateMenu::Start()
|
||||
|
||||
GameApp::playMusic("Track0.mp3");
|
||||
|
||||
hasChosenGameType = 0;
|
||||
hasChosenGameType = false;
|
||||
mParent->gameType = GAME_TYPE_CLASSIC;
|
||||
|
||||
/*
|
||||
@@ -169,14 +175,14 @@ void GameStateMenu::Start()
|
||||
void GameStateMenu::genNbCardsStr()
|
||||
{
|
||||
//How many cards total ?
|
||||
PlayerData * playerdata = NEW PlayerData(mParent->collection);
|
||||
PlayerData * playerdata = NEW PlayerData(MTGCollection());
|
||||
if (playerdata && !options[Options::ACTIVE_PROFILE].isDefault())
|
||||
sprintf(nbcardsStr, _("%s: %i cards (%i) (%i unique)").c_str(), options[Options::ACTIVE_PROFILE].str.c_str(),
|
||||
playerdata->collection->totalCards(), mParent->collection->totalCards(),
|
||||
mParent->collection->primitives.size());
|
||||
playerdata->collection->totalCards(), MTGCollection()->totalCards(),
|
||||
MTGCollection()->primitives.size());
|
||||
else
|
||||
sprintf(nbcardsStr, _("%i cards (%i unique)").c_str(), mParent->collection->totalCards(),
|
||||
mParent->collection->primitives.size());
|
||||
sprintf(nbcardsStr, _("%i cards (%i unique)").c_str(), MTGCollection()->totalCards(),
|
||||
MTGCollection()->primitives.size());
|
||||
|
||||
SAFE_DELETE(playerdata);
|
||||
}
|
||||
@@ -238,7 +244,7 @@ void GameStateMenu::fillScroller()
|
||||
sprintf(buff2, _("You have unlocked %i expansions out of %i").c_str(), nbunlocked, setlist.size());
|
||||
scroller->Add(buff2);
|
||||
|
||||
PlayerData * playerdata = NEW PlayerData(mParent->collection);
|
||||
PlayerData * playerdata = NEW PlayerData(MTGCollection());
|
||||
int totalCards = playerdata->collection->totalCards();
|
||||
if (totalCards)
|
||||
{
|
||||
@@ -466,14 +472,14 @@ void GameStateMenu::Update(float dt)
|
||||
}
|
||||
if (primitivesLoadCounter < (int) (primitives.size()))
|
||||
{
|
||||
mParent->collection->load(primitives[primitivesLoadCounter].c_str());
|
||||
MTGCollection()->load(primitives[primitivesLoadCounter].c_str());
|
||||
primitivesLoadCounter++;
|
||||
break;
|
||||
}
|
||||
primitivesLoadCounter = primitives.size() + 1;
|
||||
if (mReadConf)
|
||||
{
|
||||
mParent->collection->load(mCurrentSetFileName, mCurrentSetName);
|
||||
MTGCollection()->load(mCurrentSetFileName, mCurrentSetName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -485,8 +491,8 @@ void GameStateMenu::Update(float dt)
|
||||
Translator::GetInstance()->tempValues.clear();
|
||||
|
||||
DebugTrace(std::endl << "==" << std::endl <<
|
||||
"Total MTGCards: " << mParent->collection->collection.size() << std::endl <<
|
||||
"Total CardPrimitives: " << mParent->collection->primitives.size() << std::endl << "==");
|
||||
"Total MTGCards: " << MTGCollection()->collection.size() << std::endl <<
|
||||
"Total CardPrimitives: " << MTGCollection()->primitives.size() << std::endl << "==");
|
||||
|
||||
//Force default, if necessary.
|
||||
if (options[Options::ACTIVE_PROFILE].str == "")
|
||||
@@ -719,6 +725,8 @@ void GameStateMenu::Render()
|
||||
|
||||
void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
||||
{
|
||||
int deckId;
|
||||
int result;
|
||||
|
||||
DebugTrace("GameStateMenu: controllerId " << controllerId << " selected");
|
||||
switch (controllerId)
|
||||
@@ -743,7 +751,10 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
||||
subMenuController->Add(SUBMENUITEM_1PLAYER, "1 Player");
|
||||
// TODO Put 2 players mode back
|
||||
// This requires to fix the hand (to accept 2 players) OR to implement network game
|
||||
//subMenuController->Add(SUBMENUITEM_2PLAYER, "2 Players");
|
||||
#ifdef NETWORK_SUPPORT
|
||||
subMenuController->Add(SUBMENUITEM_2PLAYER_SERVER, "2 Players - server");
|
||||
subMenuController->Add(SUBMENUITEM_2PLAYER_CLIENT, "2 Players - client");
|
||||
#endif //NETWORK_SUPPORT
|
||||
subMenuController->Add(SUBMENUITEM_DEMO, "Demo");
|
||||
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
|
||||
#ifdef TESTSUITE
|
||||
@@ -770,12 +781,24 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
||||
subMenuController->Close();
|
||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
case SUBMENUITEM_2PLAYER:
|
||||
#ifdef NETWORK_SUPPORT
|
||||
case SUBMENUITEM_2PLAYER_SERVER:
|
||||
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
||||
mParent->players[1] = PLAYER_TYPE_HUMAN;
|
||||
this->hasChosenGameType = true;
|
||||
mParent->gameType = GAME_TYPE_CLASSIC;
|
||||
subMenuController->Close();
|
||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
case SUBMENUITEM_2PLAYER_CLIENT:
|
||||
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
||||
mParent->players[1] = PLAYER_TYPE_HUMAN;
|
||||
this->hasChosenGameType = true;
|
||||
mParent->gameType = GAME_TYPE_CLASSIC;
|
||||
subMenuController->Close();
|
||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
#endif //NETWORK_SUPPORT
|
||||
case SUBMENUITEM_DEMO:
|
||||
mParent->players[0] = PLAYER_TYPE_CPU;
|
||||
mParent->players[1] = PLAYER_TYPE_CPU;
|
||||
@@ -791,35 +814,35 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
||||
break;
|
||||
|
||||
case SUBMENUITEM_CLASSIC:
|
||||
this->hasChosenGameType = 1;
|
||||
this->hasChosenGameType = true;
|
||||
mParent->gameType = GAME_TYPE_CLASSIC;
|
||||
subMenuController->Close();
|
||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
|
||||
case SUBMENUITEM_MOMIR:
|
||||
this->hasChosenGameType = 1;
|
||||
this->hasChosenGameType = true;
|
||||
mParent->gameType = GAME_TYPE_MOMIR;
|
||||
subMenuController->Close();
|
||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
|
||||
case SUBMENUITEM_RANDOM1:
|
||||
this->hasChosenGameType = 1;
|
||||
this->hasChosenGameType = true;
|
||||
mParent->gameType = GAME_TYPE_RANDOM1;
|
||||
subMenuController->Close();
|
||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
|
||||
case SUBMENUITEM_RANDOM2:
|
||||
this->hasChosenGameType = 1;
|
||||
this->hasChosenGameType = true;
|
||||
mParent->gameType = GAME_TYPE_RANDOM2;
|
||||
subMenuController->Close();
|
||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
|
||||
case SUBMENUITEM_STORY:
|
||||
this->hasChosenGameType = 1;
|
||||
this->hasChosenGameType = true;
|
||||
mParent->gameType = GAME_TYPE_STORY;
|
||||
subMenuController->Close();
|
||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
|
||||
@@ -104,7 +104,7 @@ void GameStateShop::Start()
|
||||
|
||||
bigSync = 0;
|
||||
shopMenu = NEW WGuiMenu(JGE_BTN_DOWN, JGE_BTN_UP, true, &bigSync);
|
||||
MTGAllCards * ac = GameApp::collection;
|
||||
MTGAllCards * ac = MTGCollection();
|
||||
playerdata = NEW PlayerData(ac);
|
||||
myCollection = NEW DeckDataWrapper(playerdata->collection);
|
||||
pricelist = NEW PriceList(JGE_GET_RES("settings/prices.dat").c_str(), ac);
|
||||
@@ -310,7 +310,7 @@ void GameStateShop::purchaseBooster(int controlId)
|
||||
mInventory[controlId]--;
|
||||
SAFE_DELETE(booster);
|
||||
deleteDisplay();
|
||||
booster = NEW MTGDeck(mParent->collection);
|
||||
booster = NEW MTGDeck(MTGCollection());
|
||||
boosterDisplay = NEW BoosterDisplay(12, NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT / 2, this, NULL, 5);
|
||||
mBooster[controlId].addToDeck(booster, srcCards);
|
||||
|
||||
@@ -950,7 +950,7 @@ void ShopBooster::addToDeck(MTGDeck * d, WSrcCards * srcCards)
|
||||
bool ShopBooster::unitTest()
|
||||
{
|
||||
//this tests the default random pack creation.
|
||||
MTGDeck * d = NEW MTGDeck(GameApp::collection);
|
||||
MTGDeck * d = NEW MTGDeck(MTGCollection());
|
||||
char result[1024];
|
||||
|
||||
randomStandard();
|
||||
|
||||
@@ -1696,7 +1696,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
}
|
||||
if (tokenId)
|
||||
{
|
||||
MTGCard * safetycard = GameApp::collection->getCardById(tokenId);
|
||||
MTGCard * safetycard = MTGCollection()->getCardById(tokenId);
|
||||
if (safetycard)
|
||||
{//contenue
|
||||
ATokenCreator * tok = NEW ATokenCreator(id, card,target, NULL, tokenId, 0, starfound, multiplier, who);
|
||||
@@ -2969,7 +2969,7 @@ int AbilityFactory::getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCar
|
||||
}
|
||||
if (card->alias && magicText.size() == 0 && !dest)
|
||||
{
|
||||
MTGCard * c = GameApp::collection->getCardById(card->alias);
|
||||
MTGCard * c = MTGCollection()->getCardById(card->alias);
|
||||
if (!c)
|
||||
return 0;
|
||||
magicText = c->data->magicText;
|
||||
|
||||
@@ -366,6 +366,41 @@ void MTGAllCards::init()
|
||||
initCounters();
|
||||
}
|
||||
|
||||
void MTGAllCards::loadPrimitives(const char *root_directory)
|
||||
{
|
||||
DIR *dir = opendir(root_directory);
|
||||
struct dirent *dit;
|
||||
|
||||
while ((dit = readdir(dir)))
|
||||
{
|
||||
char fullname[1000];
|
||||
sprintf(fullname, "%s/%s", root_directory, dit->d_name);
|
||||
wagic::ifstream file(fullname);
|
||||
if (!file)
|
||||
continue;
|
||||
file.close();
|
||||
MTGCollection()->load(fullname);
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
void MTGAllCards::loadSets(const char *root_directory, const char* filename)
|
||||
{
|
||||
DIR *dir = opendir(root_directory);
|
||||
struct dirent *dit;
|
||||
|
||||
while ((dit = readdir(dir)))
|
||||
{
|
||||
char fullname[1000];
|
||||
sprintf(fullname, "%s/%s/%s", root_directory, dit->d_name, filename);
|
||||
wagic::ifstream file(fullname);
|
||||
if (!file)
|
||||
continue;
|
||||
file.close();
|
||||
MTGCollection()->load(fullname, dit->d_name);
|
||||
}
|
||||
closedir(dir);}
|
||||
|
||||
int MTGAllCards::load(const char * config_file, const char * set_name, int autoload)
|
||||
{
|
||||
conf_read_mode = 0;
|
||||
@@ -445,19 +480,21 @@ int MTGAllCards::load(const char * config_file, const char * set_name, int autol
|
||||
return total_cards;
|
||||
}
|
||||
|
||||
MTGAllCards* MTGAllCards::instance = NULL;
|
||||
|
||||
MTGAllCards::MTGAllCards()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
MTGAllCards::~MTGAllCards()
|
||||
MTGAllCards::MTGAllCards(const char * config_file, const char * set_name)
|
||||
{
|
||||
//Why don't we call destroyAllCards from here ???
|
||||
init();
|
||||
load(config_file, set_name, 0);
|
||||
}
|
||||
|
||||
void MTGAllCards::destroyAllCards()
|
||||
MTGAllCards::~MTGAllCards()
|
||||
{
|
||||
|
||||
for (map<int, MTGCard *>::iterator it = collection.begin(); it != collection.end(); it++)
|
||||
delete (it->second);
|
||||
collection.clear();
|
||||
@@ -466,13 +503,20 @@ void MTGAllCards::destroyAllCards()
|
||||
for (map<string, CardPrimitive *>::iterator it = primitives.begin(); it != primitives.end(); it++)
|
||||
delete (it->second);
|
||||
primitives.clear();
|
||||
|
||||
}
|
||||
|
||||
MTGAllCards::MTGAllCards(const char * config_file, const char * set_name)
|
||||
void MTGAllCards::loadInstance()
|
||||
{
|
||||
init();
|
||||
load(config_file, set_name, 0);
|
||||
if(!instance)
|
||||
instance = new MTGAllCards();
|
||||
}
|
||||
|
||||
void MTGAllCards::unloadAll()
|
||||
{
|
||||
if(instance) {
|
||||
delete instance;
|
||||
instance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int MTGAllCards::randomCardId()
|
||||
@@ -687,7 +731,7 @@ MTGDeck::MTGDeck(MTGAllCards * _allcards)
|
||||
int MTGDeck::totalPrice()
|
||||
{
|
||||
int total = 0;
|
||||
PriceList * pricelist = NEW PriceList(JGE_GET_RES("settings/prices.dat").c_str(), GameApp::collection);
|
||||
PriceList * pricelist = NEW PriceList(JGE_GET_RES("settings/prices.dat").c_str(), MTGCollection());
|
||||
map<int, int>::iterator it;
|
||||
for (it = cards.begin(); it != cards.end(); it++)
|
||||
{
|
||||
|
||||
@@ -14,13 +14,18 @@
|
||||
//Players Game
|
||||
//------------------------------
|
||||
|
||||
MTGPlayerCards::MTGPlayerCards()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
MTGPlayerCards::MTGPlayerCards(int * idList, int idListSize)
|
||||
{
|
||||
init();
|
||||
int i;
|
||||
for (i = 0; i < idListSize; i++)
|
||||
{
|
||||
MTGCard * card = GameApp::collection->getCardById(idList[i]);
|
||||
MTGCard * card = MTGCollection()->getCardById(idList[i]);
|
||||
if (card)
|
||||
{
|
||||
MTGCardInstance * newCard = NEW MTGCardInstance(card, this);
|
||||
@@ -845,29 +850,64 @@ ostream& MTGGameZone::toString(ostream& out) const
|
||||
}
|
||||
ostream& MTGLibrary::toString(ostream& out) const
|
||||
{
|
||||
return out << "Library " << *owner;
|
||||
return out << "Library " << owner->getDisplayName();
|
||||
}
|
||||
ostream& MTGGraveyard::toString(ostream& out) const
|
||||
{
|
||||
return out << "Graveyard " << *owner;
|
||||
return out << "Graveyard " << owner->getDisplayName();
|
||||
}
|
||||
ostream& MTGHand::toString(ostream& out) const
|
||||
{
|
||||
return out << "Hand " << *owner;
|
||||
return out << "Hand " << owner->getDisplayName();
|
||||
}
|
||||
ostream& MTGRemovedFromGame::toString(ostream& out) const
|
||||
{
|
||||
return out << "RemovedFromGame " << *owner;
|
||||
return out << "RemovedFromGame " << owner->getDisplayName();
|
||||
}
|
||||
ostream& MTGStack::toString(ostream& out) const
|
||||
{
|
||||
return out << "Stack " << *owner;
|
||||
return out << "Stack " << owner->getDisplayName();
|
||||
}
|
||||
ostream& MTGInPlay::toString(ostream& out) const
|
||||
{
|
||||
return out << "InPlay " << *owner;
|
||||
return out << "InPlay " << owner->getDisplayName();
|
||||
}
|
||||
ostream& operator<<(ostream& out, const MTGGameZone& z)
|
||||
{
|
||||
return z.toString(out);
|
||||
}
|
||||
ostream& operator<<(ostream& out, const MTGPlayerCards& z)
|
||||
{
|
||||
out << z.library->nb_cards << endl;
|
||||
for (int i = 0; i < z.library->nb_cards; i++)
|
||||
out << z.library->cards[i]->getMTGId() << " ";
|
||||
|
||||
out << endl;
|
||||
return out;
|
||||
}
|
||||
|
||||
istream& operator>>(istream& in, MTGPlayerCards& z)
|
||||
{
|
||||
int nb, mtgid;
|
||||
in >> nb;
|
||||
|
||||
for (int i = 0; i < z.library->nb_cards; i++)
|
||||
{
|
||||
SAFE_DELETE( z.library->cards[i] );
|
||||
}
|
||||
z.library->cards.clear();
|
||||
z.library->cardsMap.clear();
|
||||
|
||||
for (int i = 0; i < nb; i++)
|
||||
{
|
||||
in >> mtgid;
|
||||
MTGCard * card = MTGCollection()->getCardById(mtgid);
|
||||
if (card)
|
||||
{
|
||||
MTGCardInstance * newCard = NEW MTGCardInstance(card, &z);
|
||||
z.library->addCard(newCard);
|
||||
}
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
@@ -85,11 +85,11 @@ WSrcCards * MTGPack::getPool(string poolstr)
|
||||
if (sub.size())
|
||||
{
|
||||
mySrc->addFilter(ff->Construct(sub));
|
||||
mySrc->loadMatches(GameApp::collection);
|
||||
mySrc->loadMatches(MTGCollection());
|
||||
mySrc->bakeFilters();
|
||||
}
|
||||
else
|
||||
mySrc->loadMatches(GameApp::collection);
|
||||
mySrc->loadMatches(MTGCollection());
|
||||
}
|
||||
mySrc->Shuffle();
|
||||
return mySrc;
|
||||
@@ -223,7 +223,7 @@ void MTGPack::load(string filename)
|
||||
es->copies = atoi(holder);
|
||||
else
|
||||
es->copies = 1;
|
||||
es->card = GameApp::collection->getCardByName(pEntry->Value());
|
||||
es->card = MTGCollection()->getCardByName(pEntry->Value());
|
||||
s->addEntry(es);
|
||||
}
|
||||
else if (tag == "random_card")
|
||||
|
||||
@@ -162,7 +162,7 @@ void OptionProfile::populate()
|
||||
return;
|
||||
}
|
||||
options[Options::ACTIVE_PROFILE].str = selections[value];
|
||||
PlayerData * pdata = NEW PlayerData(app->collection);
|
||||
PlayerData * pdata = NEW PlayerData(MTGCollection());
|
||||
|
||||
int unlocked = 0, sets = setlist.size();
|
||||
wagic::ifstream file(options.profileFile(PLAYER_SETTINGS).c_str());
|
||||
|
||||
@@ -8,35 +8,36 @@
|
||||
Player::Player(MTGDeck * deck, string file, string fileSmall) :
|
||||
Damageable(20)
|
||||
{
|
||||
deckFile = file;
|
||||
deckFileSmall = fileSmall;
|
||||
manaPool = NEW ManaPool(this);
|
||||
canPutLandsIntoPlay = true;
|
||||
landsPlayerCanStillPlay = 1;
|
||||
nomaxhandsize = false;
|
||||
castedspellsthisturn = 0;
|
||||
castrestrictedspell = false;
|
||||
castrestrictedcreature = false;
|
||||
bothrestrictedspell = false;
|
||||
bothrestrictedcreature = false;
|
||||
onlyoneboth = false;
|
||||
onlyonecast = false;
|
||||
castcount = 0;
|
||||
nocreatureinstant = false;
|
||||
nospellinstant = false;
|
||||
onlyoneinstant = false;
|
||||
poisonCount = 0;
|
||||
damageCount = 0;
|
||||
preventable = 0;
|
||||
mAvatarTex = NULL;
|
||||
type_as_damageable = DAMAGEABLE_PLAYER;
|
||||
playMode = MODE_HUMAN;
|
||||
if (deck != NULL)
|
||||
{
|
||||
game = NEW MTGPlayerCards(deck);
|
||||
game->setOwner(this);
|
||||
deckName = deck->meta_name;
|
||||
}
|
||||
game = NULL;
|
||||
deckFile = file;
|
||||
deckFileSmall = fileSmall;
|
||||
manaPool = NEW ManaPool(this);
|
||||
canPutLandsIntoPlay = true;
|
||||
landsPlayerCanStillPlay = 1;
|
||||
nomaxhandsize = false;
|
||||
castedspellsthisturn = 0;
|
||||
castrestrictedspell = false;
|
||||
castrestrictedcreature = false;
|
||||
bothrestrictedspell = false;
|
||||
bothrestrictedcreature = false;
|
||||
onlyoneboth = false;
|
||||
onlyonecast = false;
|
||||
castcount = 0;
|
||||
nocreatureinstant = false;
|
||||
nospellinstant = false;
|
||||
onlyoneinstant = false;
|
||||
poisonCount = 0;
|
||||
damageCount = 0;
|
||||
preventable = 0;
|
||||
mAvatarTex = NULL;
|
||||
type_as_damageable = DAMAGEABLE_PLAYER;
|
||||
playMode = MODE_HUMAN;
|
||||
if (deck != NULL)
|
||||
{
|
||||
game = NEW MTGPlayerCards(deck);
|
||||
game->setOwner(this);
|
||||
deckName = deck->meta_name;
|
||||
}
|
||||
}
|
||||
|
||||
/*Method to call at the end of a game, before all objects involved in the game are destroyed */
|
||||
@@ -201,7 +202,20 @@ std::string Player::GetCurrentDeckStatsFile()
|
||||
return options.profileFile(filename.str());
|
||||
}
|
||||
|
||||
|
||||
ostream& operator<<(ostream& out, const Player& p)
|
||||
{
|
||||
return out << p.getDisplayName();
|
||||
return out << *(p.game);
|
||||
}
|
||||
|
||||
istream& operator>>(istream& in, Player& p)
|
||||
{
|
||||
if(!p.game)
|
||||
{
|
||||
p.game = new MTGPlayerCards();
|
||||
}
|
||||
|
||||
in >> *(p.game);
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ int Rules::getMTGId(string cardName)
|
||||
int cardnb = atoi(cardName.c_str());
|
||||
if (cardnb) return cardnb;
|
||||
if (cardName.compare("*") == 0) return -1; //Any card
|
||||
MTGCard * card = GameApp::collection->getCardByName(cardName);
|
||||
MTGCard * card = MTGCollection()->getCardByName(cardName);
|
||||
if (card) return card->getMTGId();
|
||||
DebugTrace("RULES: Can't find card:" << cardName.c_str());
|
||||
return 0;
|
||||
@@ -259,7 +259,7 @@ Player * Rules::loadPlayerMomir(int isAI)
|
||||
string deckFileSmall = "momir";
|
||||
char empty[] = "";
|
||||
|
||||
MTGDeck * tempDeck = NEW MTGDeck(GameApp::collection); //Autogenerate a momir deck. Leave the "momir.txt" bits below for stats.
|
||||
MTGDeck * tempDeck = NEW MTGDeck(MTGCollection()); //Autogenerate a momir deck. Leave the "momir.txt" bits below for stats.
|
||||
tempDeck->addRandomCards(12, 0, 0, Constants::RARITY_L, "Forest");
|
||||
tempDeck->addRandomCards(12, 0, 0, Constants::RARITY_L, "Plains");
|
||||
tempDeck->addRandomCards(12, 0, 0, Constants::RARITY_L, "Swamp");
|
||||
@@ -287,7 +287,7 @@ Player * Rules::loadPlayerRandom(int isAI, int mode)
|
||||
|
||||
string lands[] = { "forest", "forest", "island", "mountain", "swamp", "plains", "forest" };
|
||||
|
||||
MTGDeck * tempDeck = NEW MTGDeck(GameApp::collection);
|
||||
MTGDeck * tempDeck = NEW MTGDeck(MTGCollection());
|
||||
tempDeck->addRandomCards(9, 0, 0, -1, lands[color1].c_str());
|
||||
tempDeck->addRandomCards(9, 0, 0, -1, lands[color2].c_str());
|
||||
tempDeck->addRandomCards(1, 0, 0, 'U', "land");
|
||||
@@ -337,7 +337,7 @@ Player * Rules::initPlayer(int playerId)
|
||||
MTGDeck * Rules::buildDeck(int playerId)
|
||||
{
|
||||
int nbcards = 0;
|
||||
MTGDeck * deck = NEW MTGDeck(GameApp::collection);
|
||||
MTGDeck * deck = NEW MTGDeck(MTGCollection());
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
for (size_t k = 0; k < initState.playerData[playerId].zones[j].cards.size(); k++)
|
||||
|
||||
@@ -126,7 +126,7 @@ void StoryReward::Update(float dt)
|
||||
MTGCard * card = NULL;
|
||||
if (value.size())
|
||||
{
|
||||
card = GameApp::collection->getCardByName(value);
|
||||
card = MTGCollection()->getCardByName(value);
|
||||
if (card)
|
||||
{
|
||||
cardId = card->getId();
|
||||
@@ -134,15 +134,15 @@ void StoryReward::Update(float dt)
|
||||
}
|
||||
else
|
||||
{
|
||||
cardId = GameApp::collection->randomCardId();
|
||||
card = GameApp::collection->getCardById(cardId);
|
||||
cardId = MTGCollection()->randomCardId();
|
||||
card = MTGCollection()->getCardById(cardId);
|
||||
}
|
||||
|
||||
if (!cardId) break;
|
||||
|
||||
if (!collection)
|
||||
{
|
||||
collection = NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), GameApp::collection);
|
||||
collection = NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), MTGCollection());
|
||||
}
|
||||
|
||||
result = Credits::addCardToCollection(cardId, collection);
|
||||
@@ -305,13 +305,13 @@ void StoryDuel::init()
|
||||
sprintf(folder, JGE_GET_RES(CAMPAIGNS_FOLDER"%s/%s").c_str(), mParent->folder.c_str(), pageId.c_str());
|
||||
|
||||
sprintf(deckFile, "%s/deck.txt", folder);
|
||||
MTGDeck * tempDeck = NEW MTGDeck(deckFile, GameApp::collection);
|
||||
MTGDeck * tempDeck = NEW MTGDeck(deckFile, MTGCollection());
|
||||
sprintf(deckFileSmall, "campaign_%s", mParent->folder.c_str());
|
||||
players[0] = NEW HumanPlayer(tempDeck, deckFile, deckFileSmall);
|
||||
SAFE_DELETE(tempDeck);
|
||||
|
||||
sprintf(deckFile, "%s/opponent_deck.txt", folder);
|
||||
tempDeck = NEW MTGDeck(deckFile, GameApp::collection);
|
||||
tempDeck = NEW MTGDeck(deckFile, MTGCollection());
|
||||
sprintf(deckFileSmall, "campaign_ennemy_%s_%s", mParent->folder.c_str(), pageId.c_str());
|
||||
players[1] = NEW AIPlayerBaka(tempDeck, deckFile, deckFileSmall, "baka.jpg");
|
||||
SAFE_DELETE(tempDeck);
|
||||
|
||||
@@ -126,7 +126,7 @@ void StyleManager::determineActive(MTGDeck * p1, MTGDeck * p2)
|
||||
topRule = -1;
|
||||
topSize = 0;
|
||||
|
||||
MTGDeck * tempDeck = NEW MTGDeck(GameApp::collection);
|
||||
MTGDeck * tempDeck = NEW MTGDeck(MTGCollection());
|
||||
if (p1 && playerSrc != 2) tempDeck->add(p1);
|
||||
if (p2 && playerSrc != 1) tempDeck->add(p2);
|
||||
WCFilterFactory * ff = WCFilterFactory::GetInstance();
|
||||
|
||||
@@ -378,7 +378,7 @@ void WSrcCards::Sort(int method)
|
||||
WSrcUnlockedCards::WSrcUnlockedCards(float delay) :
|
||||
WSrcCards(delay)
|
||||
{
|
||||
MTGAllCards * ac = GameApp::collection;
|
||||
MTGAllCards * ac = MTGCollection();
|
||||
map<int, MTGCard*>::iterator it;
|
||||
|
||||
char * unlocked = NULL;
|
||||
@@ -549,7 +549,7 @@ int WSrcDeck::getCount(int count)
|
||||
int WSrcDeck::totalPrice()
|
||||
{
|
||||
int total = 0;
|
||||
PriceList * pricelist = NEW PriceList(JGE_GET_RES("settings/prices.dat").c_str(), GameApp::collection);
|
||||
PriceList * pricelist = NEW PriceList(JGE_GET_RES("settings/prices.dat").c_str(), MTGCollection());
|
||||
map<int, int>::iterator it;
|
||||
for (it = copies.begin(); it != copies.end(); it++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user