other={convoke} name(Convoke)
delve
other={delve}
they might be able to be added directly to the real manacost.

added an ability that grants an ability while the source remains tapped
grant ability grantend...

added dethrone
abilities=dethrone

added support of multitargeting to extra cost, it acts the same as normal multitargeting, repeats dopay() the effects for each.
This commit is contained in:
zethfoxster
2016-07-01 21:29:51 -04:00
parent 9841ce32ae
commit f76c28fa64
13 changed files with 467 additions and 22 deletions
+204 -3
View File
@@ -72,6 +72,10 @@ int ExtraCost::setPayment(MTGCardInstance * card)
if (tc)
{
result = tc->addTarget(card);
//this is flawed logic, we need to fix. if there is a target in list
//we return targetready instead, the card is not pushed back into list
//how ever, it is made the target becuase the result is 1 even if we couldnt
//target it with the targetchooser.
if (result)
{
target = card;
@@ -748,7 +752,7 @@ int TapTargetCost::isPaymentSet()
target = NULL;
return 0;
}
if (target)
if (target && (tc->getNbTargets() == tc->maxtargets || tc->done))
return 1;
return 0;
}
@@ -922,6 +926,193 @@ int Ninja::doPay()
//endbouncetargetcostforninja
//Convoke
Convoke * Convoke::clone() const
{
Convoke * ec = NEW Convoke(*this);
if (tc)
ec->tc = tc->clone();
return ec;
}
Convoke::Convoke(TargetChooser *_tc) :
ExtraCost("Select Cards To Tap", _tc)
{
}
int Convoke::canPay()
{
return isPaymentSet();
}
int Convoke::isPaymentSet()
{
if (target && target->isTapped())
{
tc->removeTarget(target);
target->isExtraCostTarget = false;
target = NULL;
return 0;
}
ManaCost * toReduce = getReduction();
if (target && (!source->controller()->getManaPool()->canAfford(toReduce)))
{
target = NULL;
SAFE_DELETE(toReduce);
return 0;
}
if (target && (source->controller()->getManaPool()->canAfford(toReduce)))
{
SAFE_DELETE(toReduce);
return 1;
}
return 0;
}
ManaCost * Convoke::getReduction()
{
ManaCost * toReduce = NEW ManaCost(source->getManaCost());
tc->maxtargets = source->getManaCost()->getConvertedCost();
if (tc->getNbTargets())
{
vector<Targetable*>targetlist = tc->getTargetsFrom();
for (vector<Targetable*>::iterator it = targetlist.begin(); it != targetlist.end(); it++)
{
bool next = false;
for (int i = Constants::MTG_COLOR_GREEN; i <= Constants::MTG_COLOR_WHITE; ++i)
{
if (next == true)
break;
MTGCardInstance * targetCard = dynamic_cast<MTGCardInstance*>(*it);
if ((targetCard->getManaCost()->hasColor(i) || targetCard->hasColor(i)) && toReduce->hasColor(i))
{
toReduce->remove(i, 1);
next = true;
}
else
{
toReduce->remove(Constants::MTG_COLOR_ARTIFACT, 1);
next = true;
}
}
}
//if we didnt find it payable one way, lets try again backwards.
if (!source->controller()->getManaPool()->canAfford(toReduce))
{
SAFE_DELETE(toReduce);
toReduce = NEW ManaCost(source->getManaCost());
for (vector<Targetable*>::reverse_iterator it = targetlist.rbegin(); it != targetlist.rend(); it++)
{
bool next = false;
for (int i = Constants::MTG_COLOR_GREEN; i <= Constants::MTG_COLOR_WHITE; ++i)
{
if (next == true)
break;
MTGCardInstance * targetCard = dynamic_cast<MTGCardInstance*>(*it);
if ((targetCard->getManaCost()->hasColor(i) || targetCard->hasColor(i)) && toReduce->hasColor(i))
{
toReduce->remove(i, 1);
next = true;
}
else
{
toReduce->remove(Constants::MTG_COLOR_ARTIFACT, 1);
next = true;
}
}
}
}
}
return toReduce;
}
int Convoke::doPay()
{
if (target && tc->getNbTargets())
{
ManaCost * toReduce = getReduction();
target->controller()->getManaPool()->pay(toReduce);
SAFE_DELETE(toReduce);
vector<Targetable*>targetlist = tc->getTargetsFrom();
for (vector<Targetable*>::iterator it = targetlist.begin(); it != targetlist.end(); it++)
{
MTGCardInstance * targetCard = dynamic_cast<MTGCardInstance*>(*it);
source->storedCard = targetCard->createSnapShot();
targetCard->tap();
}
if (tc)
tc->initTargets();
return 1;
}
return 0;
}
//DELVE
Delve * Delve::clone() const
{
Delve * ec = NEW Delve(*this);
if (tc)
ec->tc = tc->clone();
return ec;
}
Delve::Delve(TargetChooser *_tc) :
ExtraCost("Select Cards To Exile", _tc)
{
}
int Delve::canPay()
{
return isPaymentSet();
}
int Delve::isPaymentSet()
{
ManaCost * toReduce = NEW ManaCost(source->getManaCost());
tc->maxtargets = source->getManaCost()->getCost(Constants::MTG_COLOR_ARTIFACT);
if (tc->getNbTargets())
{
toReduce->remove(Constants::MTG_COLOR_ARTIFACT, tc->getNbTargets());
}
if (target && (!source->controller()->getManaPool()->canAfford(toReduce)))
{
target = NULL;
SAFE_DELETE(toReduce);
return 0;
}
if (target && (source->controller()->getManaPool()->canAfford(toReduce)))
{
SAFE_DELETE(toReduce);
return 1;
}
return 0;
}
int Delve::doPay()
{
if (target && tc->getNbTargets())
{
ManaCost * toReduce = NEW ManaCost(source->getManaCost());
toReduce->remove(Constants::MTG_COLOR_ARTIFACT, tc->getNbTargets());
target->controller()->getManaPool()->pay(toReduce);
SAFE_DELETE(toReduce);
vector<Targetable*>targetlist = tc->getTargetsFrom();
for (vector<Targetable*>::iterator it = targetlist.begin(); it != targetlist.end(); it++)
{
MTGCardInstance * targetCard = dynamic_cast<MTGCardInstance*>(*it);
source->storedCard = targetCard->createSnapShot();
targetCard->controller()->game->putInExile(targetCard);
}
if (tc)
tc->initTargets();
return 1;
}
return 0;
}
///////////////
//Sacrifice target as cost for Offering
Offering * Offering::clone() const
{
@@ -1214,7 +1405,7 @@ int ExtraCosts::tryToSetPayment(MTGCardInstance * card)
}
if (int result = costs[i]->setPayment(card))
{
card->isExtraCostTarget = true;
//card->isExtraCostTarget = true;//moved to gameobserver, flawed logic was setting this to true even when it wasnt really a target
return result;
}
}
@@ -1251,10 +1442,20 @@ int ExtraCosts::doPay()
int result = 0;
for (size_t i = 0; i < costs.size(); i++)
{
if(costs[i]->target)
if(costs[i]->target)//todo deprecate this let gameobserver control this.
{
costs[i]->target->isExtraCostTarget = false;
}
if (costs[i]->tc)
{
vector<Targetable*>targetlist = costs[i]->tc->getTargetsFrom();
for (vector<Targetable*>::iterator it = targetlist.begin(); it != targetlist.end(); it++)
{
costs[i]->target = dynamic_cast<MTGCardInstance*>(*it);
costs[i]->doPay();
}
}
else
result += costs[i]->doPay();
}
return result;