Fix send to library as a cost and add support for moving a card to
graveyard as a cost(cards like Void Attendant from Battle for Zendikar)
This commit is contained in:
Anthony Calosa
2016-05-29 17:56:33 +08:00
parent 506adf63c9
commit c472a0215d
3 changed files with 43 additions and 1 deletions

View File

@@ -155,6 +155,15 @@ public:
virtual ToLibraryCost * clone() const;
};
//toGraveyard cost
class ToGraveCost : public ExtraCost
{
public:
ToGraveCost(TargetChooser *_tc = NULL);
virtual int doPay();
virtual ToGraveCost * clone() const;
};
//Millyourself cost
class MillCost : public ExtraCost
{

View File

@@ -391,6 +391,35 @@ int ToLibraryCost::doPay()
return 0;
}
//to graveyard cost
ToGraveCost * ToGraveCost::clone() const
{
ToGraveCost * ec = NEW ToGraveCost(*this);
if (tc)
ec->tc = tc->clone();
return ec;
}
ToGraveCost::ToGraveCost(TargetChooser *_tc)
: ExtraCost("Move a card to Graveyard", _tc)
{
}
int ToGraveCost::doPay()
{
MTGCardInstance * _target = (MTGCardInstance *) target;
if (target)
{
source->storedCard = target->createSnapShot();
_target->controller()->game->putInGraveyard(target);
target = NULL;
if (tc)
tc->initTargets();
return 1;
}
return 0;
}
//Mill yourself as a cost
MillCost * MillCost::clone() const
{

View File

@@ -139,10 +139,14 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
}
break;
case 's':
if (value == "s2l")
if (value.find("s2l") != string::npos)
{ //Send To Library Cost (move from anywhere to Library)
manaCost->addExtraCost(NEW ToLibraryCost(tc));
}
else if (value.find("s2g") != string::npos)
{ //Send to Graveyard Cost (move from anywhere to Graveyard)
manaCost->addExtraCost(NEW ToGraveCost(tc));
}
else
{ //Sacrifice
manaCost->addExtraCost(NEW SacrificeCost(tc));