From ee91e0698de85cc9da65f2f81c2dbeb4ef8b4b39 Mon Sep 17 00:00:00 2001 From: zethfoxster Date: Sat, 9 Jul 2016 00:11:21 -0400 Subject: [PATCH] corrected some logic with computenewcost. there is a bug im working on with newaffinity and cards that contain targetchoosers with CD tcs. experimental change also added with lords. im making the abilities grants by lord forcedalive until the lord is removed from game. some instances of forcedalive in master primitives did not contain abilities which resolved, meaning they would contenue even though the source had left play. --- projects/mtg/include/AllAbilities.h | 2 ++ projects/mtg/src/GameObserver.cpp | 5 +++-- projects/mtg/src/MTGCardInstance.cpp | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 6d677c33b..392c89eb4 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -3256,6 +3256,7 @@ public: } else { + a->forcedAlive = 1; a->addToGame(); abilities[d] = a; } @@ -3278,6 +3279,7 @@ public: if (abilities.find(card) != abilities.end() && !(forceDestroy == -1 && forcedAlive == 1)) //only embelms have forcedestroy = -1 and forcedalive = 1 { + abilities[card]->forcedAlive = 0; game->removeObserver(abilities[card]); abilities.erase(card); } diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 3d65cd041..28801ae3c 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -1079,7 +1079,8 @@ void GameObserver::Affinity() } } } - //////////////////////////// + + /////////////////////// bool NewAffinityFound = false; for (unsigned int na = 0; na < card->cardsAbilities.size(); na++) { @@ -1114,7 +1115,7 @@ void GameObserver::Affinity() //only do any of the following if a card with the stated ability is in your hand. //kicker is an addon to normal cost, suspend is not casting. add cost as needed EXACTLY as seen below. card->getManaCost()->resetCosts(); - ManaCost * newCost = NEW ManaCost(); + ManaCost *newCost = NEW ManaCost(); newCost->copy(card->computeNewCost(card, card->getManaCost(), card->model->data->getManaCost())); card->getManaCost()->copy(newCost); SAFE_DELETE(newCost); diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index e5fc325fe..9fcbee96d 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -970,6 +970,14 @@ ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * Cos string type = ""; ManaCost * original = NEW ManaCost(); original->copy(Data); + Cost->copy(original); + if (Cost->extraCosts) + { + for (unsigned int i = 0; i < Cost->extraCosts->costs.size(); i++) + { + Cost->extraCosts->costs[i]->setSource(card); + } + } if (card->getIncreasedManaCost()->getConvertedCost() || card->getReducedManaCost()->getConvertedCost()) {//start1 if (card->getIncreasedManaCost()->getConvertedCost()) @@ -1076,6 +1084,13 @@ ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * Cos Cost->extraCosts->costs[i]->setSource(card); } } + if (Cost->extraCosts) + { + for (unsigned int i = 0; i < Cost->extraCosts->costs.size(); i++) + { + Cost->extraCosts->costs[i]->setSource(card); + } + } int reduce = 0; if (card->has(Constants::AFFINITYGREENCREATURES)) {