diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 26396643f..f379e3dba 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -39,6 +39,8 @@ class MTGCardInstance: public MTGCard, public Damageable { MTGCardInstance * getNextPartner(); void initMTGCI(); int setDefenser(MTGCardInstance * c); + int addBlocker(MTGCardInstance * c); + int removeBlocker(MTGCardInstance * c); int setAttacker(int value); public: Pos* view; @@ -62,6 +64,7 @@ class MTGCardInstance: public MTGCard, public Damageable { const string getDisplayName() const; MTGCardInstance * target; void addType(int type); + bool blocked; //Blocked this turn or not? //Combat MTGCardInstance * defenser; diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 3602e5093..16836bcd1 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -105,6 +105,7 @@ void MTGCardInstance::initMTGCI(){ next = NULL; lastController = NULL; regenerateTokens = 0; + blocked = false; } @@ -171,10 +172,6 @@ int MTGCardInstance::has(int basicAbility){ return basicAbilities[basicAbility]; } - - - - //Taps the card void MTGCardInstance::tap(){ if (tapped) return; @@ -182,7 +179,6 @@ void MTGCardInstance::tap(){ WEvent * e = NEW WEventCardTap(this, 0, 1); GameObserver * game = GameObserver::GetInstance(); game->receiveEvent(e); - //delete e; } void MTGCardInstance::untap(){ @@ -191,7 +187,6 @@ void MTGCardInstance::untap(){ WEvent * e = NEW WEventCardTap(this, 1, 0); GameObserver * game = GameObserver::GetInstance(); game->receiveEvent(e); - //delete e; } @@ -217,9 +212,6 @@ int MTGCardInstance::isTapped(){ } void MTGCardInstance::resetAllDamage(){ - //for (int i=0;ireceiveEvent(e); - //delete e; return 1; } @@ -491,6 +483,18 @@ int MTGCardInstance::bringBlockerToFrontOfOrder(MTGCardInstance * blocker){ return 1; } +int MTGCardInstance::removeBlocker(MTGCardInstance * blocker){ + blockers.remove(blocker); + if (!blockers.size()) blocked = false; + return 1; +} + +int MTGCardInstance::addBlocker(MTGCardInstance * blocker){ + blockers.push_back(blocker); + blocked = true; + return 1; +} + //Returns opponents to this card for this turn. This * should * take into account banding MTGCardInstance * MTGCardInstance::getNextOpponent(MTGCardInstance * previous){ GameObserver * game = GameObserver::GetInstance(); @@ -530,13 +534,13 @@ int MTGCardInstance::setDefenser(MTGCardInstance * opponent){ if (defenser) { if (g->players[0]->game->battlefield->hasCard(defenser) || g->players[1]->game->battlefield->hasCard(defenser) ) { - defenser->blockers.remove(this); + defenser->removeBlocker(this); } } WEvent * e = NULL; if (defenser != opponent) e = NEW WEventCreatureBlocker(this, defenser, opponent); defenser = opponent; - if (defenser) defenser->blockers.push_back(this); + if (defenser) defenser->addBlocker(this); if (e) g->receiveEvent(e); return 1; } diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 47dc1b61d..9da977238 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -214,7 +214,6 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy cardsMap.erase(card); for (i=0; i<(nb_cards); i++) { if (cards[i] == card){ - //cards[i] = cards[nb_cards -1]; nb_cards--; cards.erase(cards.begin()+i); MTGCardInstance * copy = card; diff --git a/projects/mtg/src/WResourceManager.cpp b/projects/mtg/src/WResourceManager.cpp index 2b8bd4aa9..8042059f7 100644 --- a/projects/mtg/src/WResourceManager.cpp +++ b/projects/mtg/src/WResourceManager.cpp @@ -852,12 +852,14 @@ int WResourceManager::fileOK(string filename, bool relative){ else fp = NEW std::ifstream(filename.c_str()); - if(fp && *fp){ + int result = 0; + if(fp){ + if(*fp) result = 1; fp->close(); - return 1; + delete fp; } - return 0; + return result; } int WResourceManager::CreateTexture(const string &textureName) {