Merge pull request #786 from zethfoxster/master

pushing to master
This commit is contained in:
zethfoxster
2016-07-24 07:33:17 -04:00
committed by GitHub
2 changed files with 63 additions and 16 deletions

View File

@@ -1141,7 +1141,8 @@ int Offering::canPay()
{ {
if (target) 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()); reduced->remove(Constants::MTG_COLOR_ARTIFACT, target->getManaCost()->getConvertedCost());
if (target && (!source->controller()->getManaPool()->canAfford(reduced))) if (target && (!source->controller()->getManaPool()->canAfford(reduced)))
@@ -1161,14 +1162,22 @@ int Offering::canPay()
} }
else else
{ {
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost())))) if (target)
{ {
tc->removeTarget(target); ManaCost * diff = source->getManaCost()->Diff(target->getManaCost());
target = NULL; if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
return 0; {
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; return 0;
} }
@@ -1179,7 +1188,8 @@ int Offering::isPaymentSet()
{ {
if (target) 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()); reduced->remove(Constants::MTG_COLOR_ARTIFACT, target->getManaCost()->getConvertedCost());
if (target && (!source->controller()->getManaPool()->canAfford(reduced))) if (target && (!source->controller()->getManaPool()->canAfford(reduced)))
@@ -1199,14 +1209,22 @@ int Offering::isPaymentSet()
} }
else else
{ {
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost())))) if (target)
{ {
tc->removeTarget(target); ManaCost * diff = source->getManaCost()->Diff(target->getManaCost());
target = NULL; if (target && (!source->controller()->getManaPool()->canAfford(diff)))
return 0; {
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; return 0;
} }
@@ -1217,13 +1235,18 @@ int Offering::doPay()
{ {
if (emerge) 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()); reduced->remove(Constants::MTG_COLOR_ARTIFACT, target->getManaCost()->getConvertedCost());
target->controller()->getManaPool()->pay(reduced); target->controller()->getManaPool()->pay(reduced);
SAFE_DELETE(reduced); SAFE_DELETE(reduced);
} }
else 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; MTGCardInstance * beforeCard = target;
source->storedCard = target->createSnapShot(); source->storedCard = target->createSnapShot();
target->controller()->game->putInGraveyard(target); target->controller()->game->putInGraveyard(target);

View File

@@ -760,6 +760,30 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
ManaCost * cost = card->getManaCost(); ManaCost * cost = card->getManaCost();
cost->Dump(); cost->Dump();
#endif #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<Offering*>(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)) if (playerMana->canAfford(alternateManaCost))
{ {
return 1; return 1;