Cleanup tabs

This commit is contained in:
Anthony Calosa
2016-07-07 13:25:36 +08:00
parent c544206437
commit 4da7f77089
27 changed files with 1875 additions and 1875 deletions
+191 -191
View File
@@ -72,10 +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.
//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;
@@ -166,7 +166,7 @@ int SnowCost::isPaymentSet()
return 1;
else
return 0;
}
}
}
return 0;
}
@@ -763,7 +763,7 @@ int TapTargetCost::doPay()
if (target)
{
source->storedCard = target->createSnapShot();
source->storedCard = target->createSnapShot();
_target->tap();
target = NULL;
if (tc)
@@ -807,7 +807,7 @@ int UnTapTargetCost::doPay()
if (target)
{
source->storedCard = target->createSnapShot();
source->storedCard = target->createSnapShot();
_target->untap();
target = NULL;
if (tc)
@@ -929,189 +929,189 @@ int Ninja::doPay()
//Convoke
Convoke * Convoke::clone() const
{
Convoke * ec = NEW Convoke(*this);
if (tc)
ec->tc = tc->clone();
return ec;
Convoke * ec = NEW Convoke(*this);
if (tc)
ec->tc = tc->clone();
return ec;
}
Convoke::Convoke(TargetChooser *_tc) :
ExtraCost("Select Cards To Tap", _tc)
ExtraCost("Select Cards To Tap", _tc)
{
}
int Convoke::canPay()
{
return isPaymentSet();
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;
}
SAFE_DELETE(toReduce);
return 0;
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;
}
SAFE_DELETE(toReduce);
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;
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;
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 * ec = NEW Delve(*this);
if (tc)
ec->tc = tc->clone();
return ec;
}
Delve::Delve(TargetChooser *_tc) :
ExtraCost("Select Cards To Exile", _tc)
ExtraCost("Select Cards To Exile", _tc)
{
}
int Delve::canPay()
{
return isPaymentSet();
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;
}
SAFE_DELETE(toReduce);
return 0;
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;
}
SAFE_DELETE(toReduce);
return 0;
}
int Delve::doPay()
{
if (target && tc->getNbTargets())
{
ManaCost * toReduce = NEW ManaCost(source->getManaCost());
if (target && tc->getNbTargets())
{
ManaCost * toReduce = NEW ManaCost(source->getManaCost());
toReduce->remove(Constants::MTG_COLOR_ARTIFACT, tc->getNbTargets());
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;
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;
}
///////////////
@@ -1402,41 +1402,41 @@ int ExtraCosts::tryToSetPayment(MTGCardInstance * card)
{
for(size_t k = 0; k < costs.size(); k++)
{
if (card == costs[k]->target)
{
//tapping or sacrificing a target to pay for its own cost
//is allowed, unless the source is already being tapped and contains a tap target
//or sacced and contains a sactarget
//cost like {t}{s(creature)} the source is allowed to be targeted for this
//if it is a creature. these cases below should be added whenever we a need
//for extra cost that have both a source and target version used on cards.
if (dynamic_cast<TapCost*>(costs[k]))
{
for (size_t tapCheck = 0; tapCheck < costs.size(); tapCheck++)
{
if (dynamic_cast<TapTargetCost*>(costs[tapCheck]))
{
return 0;//{t}{t(creature)}
}
}
if (card == costs[k]->target)
{
//tapping or sacrificing a target to pay for its own cost
//is allowed, unless the source is already being tapped and contains a tap target
//or sacced and contains a sactarget
//cost like {t}{s(creature)} the source is allowed to be targeted for this
//if it is a creature. these cases below should be added whenever we a need
//for extra cost that have both a source and target version used on cards.
if (dynamic_cast<TapCost*>(costs[k]))
{
for (size_t tapCheck = 0; tapCheck < costs.size(); tapCheck++)
{
if (dynamic_cast<TapTargetCost*>(costs[tapCheck]))
{
return 0;//{t}{t(creature)}
}
}
}
else if (SacrificeCost * checking = dynamic_cast<SacrificeCost*>(costs[k]))
{
for (size_t sacCheck = 0; sacCheck < costs.size(); sacCheck++)
{
SacrificeCost * checking2 = dynamic_cast<SacrificeCost*>(costs[sacCheck]);
if (checking2)
if ((checking->tc != NULL && checking2->tc == NULL)
|| (checking->tc == NULL && checking2->tc != NULL))
{
return 0; //{s}{s(creature)}
}
}
}
else
return 0;
}
}
else if (SacrificeCost * checking = dynamic_cast<SacrificeCost*>(costs[k]))
{
for (size_t sacCheck = 0; sacCheck < costs.size(); sacCheck++)
{
SacrificeCost * checking2 = dynamic_cast<SacrificeCost*>(costs[sacCheck]);
if (checking2)
if ((checking->tc != NULL && checking2->tc == NULL)
|| (checking->tc == NULL && checking2->tc != NULL))
{
return 0; //{s}{s(creature)}
}
}
}
else
return 0;
}
}
if (int result = costs[i]->setPayment(card))
{
@@ -1481,16 +1481,16 @@ int ExtraCosts::doPay()
{
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
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;