From cf9f6ed474397436336261f541262035aed62f20 Mon Sep 17 00:00:00 2001 From: Vittorio Alfieri Date: Mon, 8 Feb 2021 23:10:01 +0100 Subject: [PATCH] Fixed cost reduction issue for card with X in their cost. --- projects/mtg/src/MTGRules.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index c93349925..204945cc9 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -419,11 +419,11 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card) else colorlessx -= costcx; int options = cost->hasSpecificX() ? amountx + 1 +colorlessx : (playerMana->getConvertedCost() - cost->getConvertedCost()) + 1; + options += card->getReducedManaCost()->getConvertedCost();//Try to Apply cost reduction to X. //you can set up to 20 for specific X, if you cant afford it, it cancels. I couldnt think of a equation that would //give me the correct amount sorry. for (int i = 0; i < options; ++i) { - MTGAbility * setX = NEW AAWhatsX(game, game->mLayers->actionLayer()->getMaxId(), card, card, i, this); MTGAbility * setCardX = setX->clone(); setCardX->oneShot = true; @@ -456,6 +456,8 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card) Xcost->copy(cost); Xcost->add(Constants::MTG_COLOR_ARTIFACT, card->setX); Xcost->remove(7, 1); + if(card->getReducedManaCost()->getConvertedCost() > 0)//Try to Apply cost reduction to X. + Xcost->remove(Constants::MTG_COLOR_ARTIFACT, card->getReducedManaCost()->getConvertedCost()); if (playerMana->canAfford(Xcost,card->has(Constants::ANYTYPEOFMANA))) { cost->copy(Xcost); @@ -568,6 +570,8 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card) if (!card->has(Constants::STORM)) { copy->X = spell->computeX(copy); + if(card->setX > -1 && (card->getReducedManaCost()->getConvertedCost() > 0 || card->getIncreasedManaCost()->getConvertedCost() > 0)) //Try to Apply cost reduction/increasement to X. + copy->X = card->setX; copy->castX = copy->X; } } @@ -889,11 +893,11 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter { vectorselection; int options = alternateCost->hasSpecificX()? 20 : (playerMana->getConvertedCost() - alternateCost->getConvertedCost()) + 1; + options += card->getReducedManaCost()->getConvertedCost();//Try to Apply cost reduction to X. //you can set up to 20 for specific X, if you cant afford it, it cancels. I couldnt think of a equation that would //give me the correct amount sorry. for (int i = 0; i < options; ++i) { - MTGAbility * setX = NEW AAWhatsX(game, game->mLayers->actionLayer()->getMaxId(), card, card, i, this); MTGAbility * setCardX = setX->clone(); setCardX->oneShot = true; @@ -927,6 +931,8 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter Xcost->add(Constants::MTG_COLOR_ARTIFACT, card->setX); card->X = card->setX; // Fix to don't loose X value on alternative cast Xcost->remove(7, 1);//remove the X + if(card->getReducedManaCost()->getConvertedCost() > 0)//Try to Apply cost reduction to X. + Xcost->remove(Constants::MTG_COLOR_ARTIFACT, card->getReducedManaCost()->getConvertedCost()); if (playerMana->canAfford(Xcost,card->has(Constants::ANYTYPEOFMANA))) { alternateCost->copy(Xcost);