added other={cost}

other={emerge}
This commit is contained in:
zethfoxster
2016-07-20 20:06:18 -04:00
parent 9a60a8838f
commit 9f8ead5e4e
3 changed files with 81 additions and 16 deletions

View File

@@ -299,7 +299,8 @@ public:
class Offering : public ExtraCost class Offering : public ExtraCost
{ {
public: public:
Offering(TargetChooser *_tc = NULL); bool emerge;
Offering(TargetChooser *_tc = NULL, bool emerge = false);
virtual int canPay(); virtual int canPay();
virtual int isPaymentSet(); virtual int isPaymentSet();
virtual int doPay(); virtual int doPay();

View File

@@ -1128,8 +1128,8 @@ Offering * Offering::clone() const
return ec; return ec;
} }
Offering::Offering(TargetChooser *_tc) : Offering::Offering(TargetChooser *_tc,bool emerge) :
ExtraCost("Select creature to offer", _tc) ExtraCost("Select creature to offer", _tc), emerge(emerge)
{ {
} }
@@ -1137,28 +1137,77 @@ int Offering::canPay()
{ {
if (target && target->has(Constants::CANTBESACRIFIED)) if (target && target->has(Constants::CANTBESACRIFIED))
return 0; return 0;
if (emerge)
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
{ {
tc->removeTarget(target); if (target)
target = NULL; {
return 0; ManaCost * reduced = NEW ManaCost(source->getManaCost());
reduced->remove(Constants::MTG_COLOR_ARTIFACT, target->getManaCost()->getConvertedCost());
if (target && (!source->controller()->getManaPool()->canAfford(reduced)))
{
tc->removeTarget(target);
target = NULL;
SAFE_DELETE(reduced);
return 0;
}
if (target && source->controller()->getManaPool()->canAfford(reduced))
{
SAFE_DELETE(reduced);
return 1;
}
}
}
else
{
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
{
tc->removeTarget(target);
target = NULL;
return 0;
}
if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
return 1;
} }
if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
return 1;
return 0; return 0;
} }
int Offering::isPaymentSet() int Offering::isPaymentSet()
{ {
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost())))) if (emerge)
{ {
tc->removeTarget(target); if (target)
target = NULL; {
return 0; ManaCost * reduced = NEW ManaCost(source->getManaCost());
reduced->remove(Constants::MTG_COLOR_ARTIFACT, target->getManaCost()->getConvertedCost());
if (target && (!source->controller()->getManaPool()->canAfford(reduced)))
{
tc->removeTarget(target);
target = NULL;
SAFE_DELETE(reduced);
return 0;
}
if (target && source->controller()->getManaPool()->canAfford(reduced))
{
SAFE_DELETE(reduced);
return 1;
}
}
}
else
{
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
{
tc->removeTarget(target);
target = NULL;
return 0;
}
if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
return 1;
} }
if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
return 1;
return 0; return 0;
} }
@@ -1166,6 +1215,14 @@ int Offering::doPay()
{ {
if (target) if (target)
{ {
if (emerge)
{
ManaCost * reduced = NEW ManaCost(source->getManaCost());
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())); target->controller()->getManaPool()->pay(source->getManaCost()->Diff(target->getManaCost()));
MTGCardInstance * beforeCard = target; MTGCardInstance * beforeCard = target;
source->storedCard = target->createSnapShot(); source->storedCard = target->createSnapShot();

View File

@@ -153,6 +153,13 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
} }
break; break;
case 'e': case 'e':
if (value == "emerge")
{
if (!tc)
tc = tcf.createTargetChooser("creature|mybattlefield", c);
manaCost->addExtraCost(NEW Offering(tc,true));
}
else
//Exile //Exile
manaCost->addExtraCost(NEW ExileTargetCost(tc)); manaCost->addExtraCost(NEW ExileTargetCost(tc));
break; break;