added other={cost}
other={emerge}
This commit is contained in:
@@ -299,7 +299,8 @@ public:
|
||||
class Offering : public ExtraCost
|
||||
{
|
||||
public:
|
||||
Offering(TargetChooser *_tc = NULL);
|
||||
bool emerge;
|
||||
Offering(TargetChooser *_tc = NULL, bool emerge = false);
|
||||
virtual int canPay();
|
||||
virtual int isPaymentSet();
|
||||
virtual int doPay();
|
||||
|
||||
@@ -1128,8 +1128,8 @@ Offering * Offering::clone() const
|
||||
return ec;
|
||||
}
|
||||
|
||||
Offering::Offering(TargetChooser *_tc) :
|
||||
ExtraCost("Select creature to offer", _tc)
|
||||
Offering::Offering(TargetChooser *_tc,bool emerge) :
|
||||
ExtraCost("Select creature to offer", _tc), emerge(emerge)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1137,28 +1137,77 @@ int Offering::canPay()
|
||||
{
|
||||
if (target && target->has(Constants::CANTBESACRIFIED))
|
||||
return 0;
|
||||
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
|
||||
if (emerge)
|
||||
{
|
||||
tc->removeTarget(target);
|
||||
target = NULL;
|
||||
return 0;
|
||||
if (target)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
int Offering::isPaymentSet()
|
||||
{
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
|
||||
if (emerge)
|
||||
{
|
||||
tc->removeTarget(target);
|
||||
target = NULL;
|
||||
return 0;
|
||||
if (target)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1166,6 +1215,14 @@ int Offering::doPay()
|
||||
{
|
||||
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()));
|
||||
MTGCardInstance * beforeCard = target;
|
||||
source->storedCard = target->createSnapShot();
|
||||
|
||||
@@ -153,6 +153,13 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
|
||||
}
|
||||
break;
|
||||
case 'e':
|
||||
if (value == "emerge")
|
||||
{
|
||||
if (!tc)
|
||||
tc = tcf.createTargetChooser("creature|mybattlefield", c);
|
||||
manaCost->addExtraCost(NEW Offering(tc,true));
|
||||
}
|
||||
else
|
||||
//Exile
|
||||
manaCost->addExtraCost(NEW ExileTargetCost(tc));
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user