From de2d6639689f1972b5ccec09f350fbd1c3bed80e Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 26 Jan 2017 02:12:02 +0800 Subject: [PATCH] unattach animated equipment another bug found is when the equipment becomes a creature, its ability is granted to itself... --- projects/mtg/include/MTGRules.h | 6 ++++-- projects/mtg/src/GameObserver.cpp | 4 ++-- projects/mtg/src/MTGRules.cpp | 6 ++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index 92eacfc07..bc4e44d98 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -73,6 +73,8 @@ public: class MTGPutInPlayRule: public PermanentAbility { +protected: + string defaultPlayName; public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); @@ -80,8 +82,8 @@ public: MTGPutInPlayRule(GameObserver* observer, int _id); const string getMenuText() { - if(game && game->gameType() == GAME_TYPE_MOMIR) - return "Play Land"; + if(defaultPlayName.size()) + return defaultPlayName.c_str(); return "Cast Card Normally"; } virtual MTGPutInPlayRule * clone() const; diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 6c987a84e..ba614275a 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -773,7 +773,7 @@ void GameObserver::gameStateBasedEffects() //////////////////////////////////////////////////// //Unattach Equipments that dont have valid targets// //////////////////////////////////////////////////// - if (!card->isCreature() && card->hasType(Subtypes::TYPE_EQUIPMENT)) + if (card->hasType(Subtypes::TYPE_EQUIPMENT)) { if(isInPlay(card)) { @@ -785,7 +785,7 @@ void GameObserver::gameStateBasedEffects() { if(card->target)//unattach equipments from cards that has protection from quality ex. protection from artifacts { - if((card->target)->protectedAgainst(card)) + if((card->target)->protectedAgainst(card)||card->isCreature()) ((AEquip*)a)->unequip(); } if(card->controller()) diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index f33f2ea25..750d4883c 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -296,11 +296,13 @@ MTGPutInPlayRule::MTGPutInPlayRule(GameObserver* observer, int _id) : PermanentAbility(observer, _id) { aType = MTGAbility::PUT_INTO_PLAY; + defaultPlayName = ""; } int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost *) { int cardsinhand = game->players[0]->game->hand->nb_cards; + defaultPlayName = card->isLand()?"Play Land":"Cast Card Normally"; Player * player = game->currentlyActing(); if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card)) return 0; @@ -753,6 +755,8 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * if(!allowedToAltCast(card,player)) return 0; + + alternativeName = "Pay Alternative Cost"; if(card->has(Constants::CANPLAYFROMGRAVEYARD)) alternativeName = "Alternate Cast From Graveyard"; @@ -763,6 +767,8 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * if (card->isLand()) { + alternativeName = "Play Land"; + if (game->currentActionPlayer->game->playRestrictions->canPutIntoZone(card, game->currentActionPlayer->game->inPlay) == PlayRestriction::CANT_PLAY) return 0; if (card->StackIsEmptyandSorcerySpeed())