force event for token sacrifice
This commit is contained in:
@@ -1370,6 +1370,8 @@ public:
|
|||||||
{
|
{
|
||||||
WEventCardSacrifice * e = dynamic_cast<WEventCardSacrifice *> (event);
|
WEventCardSacrifice * e = dynamic_cast<WEventCardSacrifice *> (event);
|
||||||
if (!e) return 0;
|
if (!e) return 0;
|
||||||
|
if (e->istoken)
|
||||||
|
return 1;
|
||||||
MTGCardInstance * check = e->cardAfter;
|
MTGCardInstance * check = e->cardAfter;
|
||||||
MTGGameZone * oldZone = e->cardAfter->currentZone;
|
MTGGameZone * oldZone = e->cardAfter->currentZone;
|
||||||
check->currentZone = check->previousZone;
|
check->currentZone = check->previousZone;
|
||||||
|
|||||||
@@ -184,7 +184,8 @@ struct WEventCardBlocked : public WEventCardUpdate {
|
|||||||
//event when card is sacrificed.
|
//event when card is sacrificed.
|
||||||
struct WEventCardSacrifice : public WEventCardUpdate {
|
struct WEventCardSacrifice : public WEventCardUpdate {
|
||||||
MTGCardInstance * cardAfter;
|
MTGCardInstance * cardAfter;
|
||||||
WEventCardSacrifice(MTGCardInstance * card,MTGCardInstance * afterCard);
|
bool istoken;
|
||||||
|
WEventCardSacrifice(MTGCardInstance * card,MTGCardInstance * afterCard, bool token = false);
|
||||||
virtual Targetable * getTarget(int target);
|
virtual Targetable * getTarget(int target);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2704,10 +2704,14 @@ int AASacrificeCard::resolve()
|
|||||||
{
|
{
|
||||||
Player * p = _target->controller();
|
Player * p = _target->controller();
|
||||||
MTGCardInstance * beforeCard = _target;
|
MTGCardInstance * beforeCard = _target;
|
||||||
|
WEvent * e;
|
||||||
|
if(!_target->isToken)
|
||||||
|
e = NEW WEventCardSacrifice(beforeCard,_target);
|
||||||
|
else
|
||||||
|
e = NEW WEventCardSacrifice(beforeCard,_target,true);
|
||||||
p->game->putInGraveyard(_target);
|
p->game->putInGraveyard(_target);
|
||||||
while(_target->next)
|
while(_target->next)
|
||||||
_target = _target->next;
|
_target = _target->next;
|
||||||
WEvent * e = NEW WEventCardSacrifice(beforeCard,_target);
|
|
||||||
game->receiveEvent(e);
|
game->receiveEvent(e);
|
||||||
if(andAbility)
|
if(andAbility)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -978,14 +978,14 @@ ManaCost * Convoke::getReduction()
|
|||||||
tc->maxtargets = source->getManaCost()->getConvertedCost();
|
tc->maxtargets = source->getManaCost()->getConvertedCost();
|
||||||
if (tc->getNbTargets())
|
if (tc->getNbTargets())
|
||||||
{
|
{
|
||||||
vector<Targetable*>targetlist = tc->getTargetsFrom();
|
vector<Targetable*>targetlist = tc->getTargetsFrom();
|
||||||
for (vector<Targetable*>::iterator it = targetlist.begin(); it != targetlist.end(); it++)
|
for (vector<Targetable*>::iterator it = targetlist.begin(); it != targetlist.end(); it++)
|
||||||
{
|
{
|
||||||
bool next = false;
|
bool next = false;
|
||||||
for (int i = Constants::MTG_COLOR_GREEN; i <= Constants::MTG_COLOR_WHITE; ++i)
|
for (int i = Constants::MTG_COLOR_GREEN; i <= Constants::MTG_COLOR_WHITE; ++i)
|
||||||
{
|
{
|
||||||
if (next == true)
|
if (next == true)
|
||||||
break;
|
break;
|
||||||
MTGCardInstance * targetCard = dynamic_cast<MTGCardInstance*>(*it);
|
MTGCardInstance * targetCard = dynamic_cast<MTGCardInstance*>(*it);
|
||||||
if ((targetCard->getManaCost()->hasColor(i) || targetCard->hasColor(i)) && toReduce->hasColor(i))
|
if ((targetCard->getManaCost()->hasColor(i) || targetCard->hasColor(i)) && toReduce->hasColor(i))
|
||||||
{
|
{
|
||||||
@@ -1004,13 +1004,13 @@ ManaCost * Convoke::getReduction()
|
|||||||
{
|
{
|
||||||
SAFE_DELETE(toReduce);
|
SAFE_DELETE(toReduce);
|
||||||
toReduce = NEW ManaCost(source->getManaCost());
|
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;
|
bool next = false;
|
||||||
for (int i = Constants::MTG_COLOR_GREEN; i <= Constants::MTG_COLOR_WHITE; ++i)
|
for (int i = Constants::MTG_COLOR_GREEN; i <= Constants::MTG_COLOR_WHITE; ++i)
|
||||||
{
|
{
|
||||||
if (next == true)
|
if (next == true)
|
||||||
break;
|
break;
|
||||||
MTGCardInstance * targetCard = dynamic_cast<MTGCardInstance*>(*it);
|
MTGCardInstance * targetCard = dynamic_cast<MTGCardInstance*>(*it);
|
||||||
if ((targetCard->getManaCost()->hasColor(i) || targetCard->hasColor(i)) && toReduce->hasColor(i))
|
if ((targetCard->getManaCost()->hasColor(i) || targetCard->hasColor(i)) && toReduce->hasColor(i))
|
||||||
{
|
{
|
||||||
@@ -1036,9 +1036,9 @@ int Convoke::doPay()
|
|||||||
ManaCost * toReduce = getReduction();
|
ManaCost * toReduce = getReduction();
|
||||||
target->controller()->getManaPool()->pay(toReduce);
|
target->controller()->getManaPool()->pay(toReduce);
|
||||||
SAFE_DELETE(toReduce);
|
SAFE_DELETE(toReduce);
|
||||||
vector<Targetable*>targetlist = tc->getTargetsFrom();
|
vector<Targetable*>targetlist = tc->getTargetsFrom();
|
||||||
for (vector<Targetable*>::iterator it = targetlist.begin(); it != targetlist.end(); it++)
|
for (vector<Targetable*>::iterator it = targetlist.begin(); it != targetlist.end(); it++)
|
||||||
{
|
{
|
||||||
MTGCardInstance * targetCard = dynamic_cast<MTGCardInstance*>(*it);
|
MTGCardInstance * targetCard = dynamic_cast<MTGCardInstance*>(*it);
|
||||||
source->storedCard = targetCard->createSnapShot();
|
source->storedCard = targetCard->createSnapShot();
|
||||||
targetCard->tap();
|
targetCard->tap();
|
||||||
@@ -1104,9 +1104,9 @@ int Delve::doPay()
|
|||||||
|
|
||||||
target->controller()->getManaPool()->pay(toReduce);
|
target->controller()->getManaPool()->pay(toReduce);
|
||||||
SAFE_DELETE(toReduce);
|
SAFE_DELETE(toReduce);
|
||||||
vector<Targetable*>targetlist = tc->getTargetsFrom();
|
vector<Targetable*>targetlist = tc->getTargetsFrom();
|
||||||
for (vector<Targetable*>::iterator it = targetlist.begin(); it != targetlist.end(); it++)
|
for (vector<Targetable*>::iterator it = targetlist.begin(); it != targetlist.end(); it++)
|
||||||
{
|
{
|
||||||
MTGCardInstance * targetCard = dynamic_cast<MTGCardInstance*>(*it);
|
MTGCardInstance * targetCard = dynamic_cast<MTGCardInstance*>(*it);
|
||||||
source->storedCard = targetCard->createSnapShot();
|
source->storedCard = targetCard->createSnapShot();
|
||||||
targetCard->controller()->game->putInExile(targetCard);
|
targetCard->controller()->game->putInExile(targetCard);
|
||||||
@@ -1288,8 +1288,12 @@ int SacrificeCost::doPay()
|
|||||||
{
|
{
|
||||||
MTGCardInstance * beforeCard = target;
|
MTGCardInstance * beforeCard = target;
|
||||||
source->storedCard = target->createSnapShot();
|
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);
|
target->controller()->game->putInGraveyard(target);
|
||||||
WEvent * e = NEW WEventCardSacrifice(beforeCard,target);
|
|
||||||
GameObserver * game = target->owner->getObserver();
|
GameObserver * game = target->owner->getObserver();
|
||||||
game->receiveEvent(e);
|
game->receiveEvent(e);
|
||||||
target = NULL;
|
target = NULL;
|
||||||
@@ -1567,11 +1571,11 @@ int ExtraCosts::doPay()
|
|||||||
}
|
}
|
||||||
if (costs[i]->tc)
|
if (costs[i]->tc)
|
||||||
{
|
{
|
||||||
vector<Targetable*>targetlist = costs[i]->tc->getTargetsFrom();
|
vector<Targetable*>targetlist = costs[i]->tc->getTargetsFrom();
|
||||||
for (vector<Targetable*>::iterator it = targetlist.begin(); it != targetlist.end(); it++)
|
for (vector<Targetable*>::iterator it = targetlist.begin(); it != targetlist.end(); it++)
|
||||||
{
|
{
|
||||||
costs[i]->target = dynamic_cast<MTGCardInstance*>(*it);
|
costs[i]->target = dynamic_cast<MTGCardInstance*>(*it);
|
||||||
costs[i]->doPay();
|
costs[i]->doPay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ player(player), nb_cards(nb_cards),drawAbility(cardDraw)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
WEventCardSacrifice::WEventCardSacrifice(MTGCardInstance * card, MTGCardInstance * after) :
|
WEventCardSacrifice::WEventCardSacrifice(MTGCardInstance * card, MTGCardInstance * after, bool token) :
|
||||||
WEventCardUpdate(card),cardAfter(after)
|
WEventCardUpdate(card),cardAfter(after),istoken(token)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user