diff --git a/projects/mtg/src/ExtraCost.cpp b/projects/mtg/src/ExtraCost.cpp index 98609951b..9946291a8 100644 --- a/projects/mtg/src/ExtraCost.cpp +++ b/projects/mtg/src/ExtraCost.cpp @@ -1141,7 +1141,8 @@ int Offering::canPay() { if (target) { - ManaCost * reduced = NEW ManaCost(source->getManaCost()); + ManaCost * reduced = NEW ManaCost(source->getManaCost()->getAlternative()); + reduced->extraCosts = NULL; reduced->remove(Constants::MTG_COLOR_ARTIFACT, target->getManaCost()->getConvertedCost()); if (target && (!source->controller()->getManaPool()->canAfford(reduced))) @@ -1161,14 +1162,22 @@ int Offering::canPay() } else { - if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost())))) + if (target) { - tc->removeTarget(target); - target = NULL; - return 0; + ManaCost * diff = source->getManaCost()->Diff(target->getManaCost()); + if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost())))) + { + SAFE_DELETE(diff); + tc->removeTarget(target); + target = NULL; + return 0; + } + if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost())))) + { + SAFE_DELETE(diff); + return 1; + } } - if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost())))) - return 1; } return 0; } @@ -1179,7 +1188,8 @@ int Offering::isPaymentSet() { if (target) { - ManaCost * reduced = NEW ManaCost(source->getManaCost()); + ManaCost * reduced = NEW ManaCost(source->getManaCost()->getAlternative()); + reduced->extraCosts = NULL; reduced->remove(Constants::MTG_COLOR_ARTIFACT, target->getManaCost()->getConvertedCost()); if (target && (!source->controller()->getManaPool()->canAfford(reduced))) @@ -1199,14 +1209,22 @@ int Offering::isPaymentSet() } else { - if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost())))) + if (target) { - tc->removeTarget(target); - target = NULL; - return 0; + ManaCost * diff = source->getManaCost()->Diff(target->getManaCost()); + if (target && (!source->controller()->getManaPool()->canAfford(diff))) + { + SAFE_DELETE(diff); + tc->removeTarget(target); + target = NULL; + return 0; + } + if (target && (source->controller()->getManaPool()->canAfford(diff))) + { + SAFE_DELETE(diff); + return 1; + } } - if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost())))) - return 1; } return 0; } @@ -1217,13 +1235,18 @@ int Offering::doPay() { if (emerge) { - ManaCost * reduced = NEW ManaCost(source->getManaCost()); + ManaCost * reduced = NEW ManaCost(source->getManaCost()->getAlternative()); + reduced->extraCosts = NULL; reduced->remove(Constants::MTG_COLOR_ARTIFACT, target->getManaCost()->getConvertedCost()); target->controller()->getManaPool()->pay(reduced); SAFE_DELETE(reduced); } else - target->controller()->getManaPool()->pay(source->getManaCost()->Diff(target->getManaCost())); + { + ManaCost * diff = source->getManaCost()->Diff(target->getManaCost()); + target->controller()->getManaPool()->pay(diff); + SAFE_DELETE(diff); + } MTGCardInstance * beforeCard = target; source->storedCard = target->createSnapShot(); target->controller()->game->putInGraveyard(target); diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 995fb30bb..134456d79 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -760,6 +760,30 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * ManaCost * cost = card->getManaCost(); cost->Dump(); #endif + if (alternateManaCost->extraCosts) + { + //offerings handle thier own casting and cost payments. + //we add this condiational here because offering can also have a completely different + //manacost from orginal cost, this allows us to simulate reacting to click for cards that + //would be able to afford the cost AFTER the sacrifice is made, we use isPaymentSet to determine + //legality of casting. + if (alternateManaCost->getExtraCost(0) == dynamic_cast(alternateManaCost->getExtraCost(0))) + { + if (alternateManaCost->isExtraPaymentSet())//cant get past this section without doing it. you either pay the cost or dont + { + if (!game->targetListIsSet(card)) + return 0; + } + else + { + alternateManaCost->setExtraCostsAction(this, card); + game->mExtraPayment = alternateManaCost->extraCosts; + return 0; + } + return 1; + } + } + if (playerMana->canAfford(alternateManaCost)) { return 1;