refactored lifestate check

This commit is contained in:
Anthony Calosa
2015-09-03 20:11:47 +08:00
parent 886eaa4002
commit 42d0480f77
4 changed files with 55 additions and 61 deletions

View File

@@ -4963,39 +4963,25 @@ int TriggeredAbility::receiveEvent(WEvent * e)
}
if(dynamic_cast<WEventLife*>(e))
{
//check life state... basic prevention for infinite loop of bugs\exquisite_blood_i953.txt test..
//exquisite blood and sanguine bond in play will stop looping as long as the triggered player
//met this condition... taken from gamestatebasecheck...
WEventLife * lifecheck = dynamic_cast<WEventLife*>(e);
if ((lifecheck->player->life <= 0)||(lifecheck->player->poisonCount >= 10))
{
int cantlosers = 0;
MTGGameZone * z = lifecheck->player->game->inPlay;
int nbcards = z->nb_cards;
for (int j = 0; j < nbcards; ++j)
{
MTGCardInstance * c = z->cards[j];
if (c->has(Constants::CANTLOSE) || (c->has(Constants::CANTLIFELOSE) && lifecheck->player->poisonCount < 10))
{
cantlosers++;
}
}
MTGGameZone * k = lifecheck->player->opponent()->game->inPlay;
int onbcards = k->nb_cards;
for (int m = 0; m < onbcards; ++m)
{
MTGCardInstance * e = k->cards[m];
if (e->has(Constants::CANTWIN))
{
cantlosers++;
}
}
if (cantlosers < 1)
{
//lifecheck->player->getObserver()->setLoser(lifecheck->player);
return 0;
}
}
//check life state on life triger
WEventLife * lifecheck = dynamic_cast<WEventLife*>(e);
if (lifecheck->player->DeadLifeState())
{
return 0;
}
fireAbility();
return 1;
}
if(dynamic_cast<WEventDamage*>(e))
{
//check life state on damage trigger
WEventDamage * lifecheck = dynamic_cast<WEventDamage*>(e);
if (lifecheck->damage->target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER)
{
Player * triggerPlayer = (Player *) lifecheck->damage->target;
if(triggerPlayer->DeadLifeState())
return 0;
}
fireAbility();
return 1;
}