From 831c8f73b01ffb9a89f84231f0ab34432edf6a6a Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 6 Feb 2017 21:48:41 +0800 Subject: [PATCH] some bug fixes fix where the copier is treated as the same copied card, also fixes the display ability of momir (forced), disabled reveal for AI if aicode is not found (should add alternate for ai). --- projects/mtg/include/MTGCardInstance.h | 2 +- projects/mtg/src/ActionStack.cpp | 7 ++++++- projects/mtg/src/AllAbilities.cpp | 12 ++++++++++++ projects/mtg/src/MTGAbility.cpp | 13 ++++++++++++- projects/mtg/src/MTGCardInstance.cpp | 22 ++++------------------ projects/mtg/src/MTGRules.cpp | 6 ++++-- projects/mtg/src/Token.cpp | 12 ++++++++++-- 7 files changed, 49 insertions(+), 25 deletions(-) diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index b37441878..2d8e9f328 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -48,7 +48,6 @@ public: vectorparentCards; vectorchildrenCards; vectorcardsAbilities; - //vectorcardsAbilitiesFilter; int setAttacker(int value); int setDefenser(MTGCardInstance * c); @@ -263,6 +262,7 @@ public: bool bypassTC; bool discarded; int copiedID; + int copiedSetID; bool StackIsEmptyandSorcerySpeed(); bool isTargetted(); int cardistargetted; diff --git a/projects/mtg/src/ActionStack.cpp b/projects/mtg/src/ActionStack.cpp index 86106aa0c..731682c91 100644 --- a/projects/mtg/src/ActionStack.cpp +++ b/projects/mtg/src/ActionStack.cpp @@ -593,7 +593,12 @@ int ActionStack::addAbility(MTGAbility * ability) int result = addAction(stackAbility); if (!observer->players[0]->isAI() && ability->source->controller() == observer->players[0] && 0 == options[Options::INTERRUPTMYABILITIES].number) - interruptDecision[0] = DONT_INTERRUPT; + { + if(observer->gameType() == GAME_TYPE_MOMIR && ability->aType == MTGAbility::FORCED_TOKEN_CREATOR) + interruptDecision[0] = NOT_DECIDED; + else + interruptDecision[0] = DONT_INTERRUPT; + } if (observer->OpenedDisplay && observer->players[0]->game->reveal->cards.size()) { interruptDecision[0] = DONT_INTERRUPT; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 4e1a4a7ab..06c5054df 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -1799,6 +1799,18 @@ AACounter::AACounter(GameObserver* observer, int id, MTGCardInstance * source, M while (_target->next) _target = _target->next; + + if(_target->getCurrentZone() != _target->controller()->game->battlefield || + _target->getCurrentZone() != _target->controller()->opponent()->game->battlefield) + { + if(power||toughness) + { + if(_target->previousZone == _target->controller()->game->battlefield || + _target->previousZone == _target->controller()->opponent()->game->battlefield) + return 0; + } + } + Counter * targetCounter = NULL; int currentAmount = 0; if (_target->counters && _target->counters->hasCounter(name.c_str(), power, toughness)) diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 15287c569..c4688b2bf 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -3638,7 +3638,18 @@ 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()) + /***********do nothing***********/ + if((card->controller()->isAI() && + card->controller()->opponent()->isAI())|| + !card->getAICustomCode().size()) + { + MTGAbility * a2 = parseMagicLine("activate donothing", id, spell, card); + a2->oneShot = 1; + a2->canBeInterrupted = false; + return a2; + } + /*******************************/ + else if(card->getAICustomCode().size() && card->controller()->isAI()) { MTGAbility * a3 = parseMagicLine(card->getAICustomCode(), id, spell, card); a3->oneShot = 1; diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 758543db9..be1c0b1fe 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -64,6 +64,7 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to bypassTC = false; discarded = false; copiedID = getId(); + copiedSetID = 0; LKIpower = power; LKItoughness = toughness; cardistargetted = 0; @@ -143,6 +144,7 @@ void MTGCardInstance::copy(MTGCardInstance * card) spellTargetType = data->spellTargetType; alias = data->alias; copiedID = card->copiedID; + copiedSetID = card->setId; doubleFaced = data->doubleFaced; AICustomCode = data->AICustomCode; CrewAbility = data->CrewAbility; @@ -156,25 +158,9 @@ void MTGCardInstance::copy(MTGCardInstance * card) int castMethodBackUP = this->castMethod; mtgid = source->getId(); MTGCardInstance * oldStored = this->storedSourceCard; - //test copy filtered - /*cardsAbilitiesFilter.clear(); - for(unsigned int i = 0;i < card->cardsAbilities.size();i++) - { - MTGAbility * a = dynamic_cast(card->cardsAbilities[i]); - if(a && a->source == card) - { - cardsAbilitiesFilter.push_back(a); - } - }*/ - if(observer->players[1]->playMode == Player::MODE_TEST_SUITE) - mtgid = backupid; // there must be a way to get the token id... - else - { - mtgid = card->getMTGId(); /////////////////////////////////////////////////// - setId = card->setId; // Copier/Cloner cards produces the same token...// - rarity = card->getRarity(); /////////////////////////////////////////////////// - } + mtgid = backupid; // found a way :) + castMethod = castMethodBackUP; backupTargets = this->backupTargets; storedCard = oldStored; diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index a0cebf18f..d981838b5 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -3262,7 +3262,8 @@ int MTGLegendRule::added(MTGCardInstance * card) { MTGCardInstance * comparison = (*it).first; if (comparison != card && comparison->controller() == card->controller() && !(comparison->getName().compare(card->getName()))) - destroy = 1; + if (!(game->getCurrentTargetChooser() || game->mLayers->actionLayer()->isWaitingForAnswer())) + destroy = 1; } if(destroy) { @@ -3340,7 +3341,8 @@ int MTGPlaneWalkerRule::added(MTGCardInstance * card) { MTGCardInstance * comparison = (*it).first; if (comparison != card && comparison->types == card->types && comparison->controller() == card->controller()) - destroy = 1; + if (!(game->getCurrentTargetChooser() || game->mLayers->actionLayer()->isWaitingForAnswer())) + destroy = 1; } if (destroy) { diff --git a/projects/mtg/src/Token.cpp b/projects/mtg/src/Token.cpp index bb303558f..ae4c841ae 100644 --- a/projects/mtg/src/Token.cpp +++ b/projects/mtg/src/Token.cpp @@ -18,8 +18,16 @@ Token::Token(string _name, MTGCardInstance * source, int _power, int _toughness) rarity = Constants::RARITY_T; name = _name; if (name.size() && name[0] >= 97 && name[0] <= 122) name[0] -= 32; //Poor man's camelcase. We assume strings we get are either Camelcased or lowercase - setMTGId(-source->getMTGId()); - setId = source->setId; + if(source->isACopier && source->copiedSetID) + { + setMTGId(-source->copiedID); + setId = source->copiedSetID; + } + else + { + setMTGId(-source->getMTGId()); + setId = source->setId; + } model = this; data = this; owner = source->owner;