force event for token sacrifice

This commit is contained in:
Anthony Calosa
2016-07-27 07:11:30 +08:00
parent 2971e64182
commit 014ca36a4a
5 changed files with 36 additions and 25 deletions

View File

@@ -978,14 +978,14 @@ ManaCost * Convoke::getReduction()
tc->maxtargets = source->getManaCost()->getConvertedCost();
if (tc->getNbTargets())
{
vector<Targetable*>targetlist = tc->getTargetsFrom();
for (vector<Targetable*>::iterator it = targetlist.begin(); it != targetlist.end(); it++)
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;
{
if (next == true)
break;
MTGCardInstance * targetCard = dynamic_cast<MTGCardInstance*>(*it);
if ((targetCard->getManaCost()->hasColor(i) || targetCard->hasColor(i)) && toReduce->hasColor(i))
{
@@ -1004,13 +1004,13 @@ ManaCost * Convoke::getReduction()
{
SAFE_DELETE(toReduce);
toReduce = NEW ManaCost(source->getManaCost());
for (vector<Targetable*>::reverse_iterator it = targetlist.rbegin(); it != targetlist.rend(); it++)
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;
{
if (next == true)
break;
MTGCardInstance * targetCard = dynamic_cast<MTGCardInstance*>(*it);
if ((targetCard->getManaCost()->hasColor(i) || targetCard->hasColor(i)) && toReduce->hasColor(i))
{
@@ -1036,9 +1036,9 @@ int Convoke::doPay()
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++)
{
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();
@@ -1104,9 +1104,9 @@ int Delve::doPay()
target->controller()->getManaPool()->pay(toReduce);
SAFE_DELETE(toReduce);
vector<Targetable*>targetlist = tc->getTargetsFrom();
for (vector<Targetable*>::iterator it = targetlist.begin(); it != targetlist.end(); it++)
{
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);
@@ -1288,8 +1288,12 @@ int SacrificeCost::doPay()
{
MTGCardInstance * beforeCard = target;
source->storedCard = target->createSnapShot();
WEvent * e;
if(!target->isToken)
e = NEW WEventCardSacrifice(beforeCard,target);
else
e = NEW WEventCardSacrifice(beforeCard,target,true);
target->controller()->game->putInGraveyard(target);
WEvent * e = NEW WEventCardSacrifice(beforeCard,target);
GameObserver * game = target->owner->getObserver();
game->receiveEvent(e);
target = NULL;
@@ -1567,11 +1571,11 @@ int ExtraCosts::doPay()
}
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();
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