From 3afcc7fdf9afdda1fb35a911845b098e2325d10e Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sat, 11 Feb 2017 18:25:45 +0800 Subject: [PATCH] fix hang aicode ability controller aicode should be dedicated for AI only... --- projects/mtg/src/AllAbilities.cpp | 12 ++++++++++++ projects/mtg/src/MTGAbility.cpp | 12 +----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index ed5a4f6fd..9d5d3030d 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -54,6 +54,18 @@ GenericRevealAbility::GenericRevealAbility(GameObserver* observer, int id, MTGCa int GenericRevealAbility::resolve() { + if(source->lastController->isAI() && source->getAICustomCode().size()) + { + string abi = source->getAICustomCode(); + std::transform(abi.begin(), abi.end(), abi.begin(), ::tolower);//fix crash + AbilityFactory af(game); + MTGAbility * a3 = af.parseMagicLine(abi, this->GetId(), NULL, source); + a3->oneShot = 1; + a3->canBeInterrupted = false; + a3->resolve(); + SAFE_DELETE(a3); + return 1; + } MTGAbility * ability = NEW MTGRevealingCards(game, this->GetId(), source, howMany); ability->addToGame(); return 1; diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index fc6832afa..d9cfc823b 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -3684,17 +3684,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG a->oneShot = 1; a->canBeInterrupted = false; a->named = newName; - if(card->getAICustomCode().size() && card->controller()->isAI()) - { - string abi = card->getAICustomCode(); - std::transform(abi.begin(), abi.end(), abi.begin(), ::tolower);//fix crash - MTGAbility * a3 = parseMagicLine(abi, id, spell, card); - a3->oneShot = 1; - a3->canBeInterrupted = false; - return a3; - } - else - return a; + return a; } //scry:x (activate aility)