Found & fixed a crash while testing trample. The bug: if the AI's player hand dropped to zero cards. This broke in r2696.

Zeth, please review, I put in a comment where there's something that doesn't make sense- probably an early change that's now obsolete.
This commit is contained in:
wrenczes@gmail.com
2010-12-08 07:53:51 +00:00
parent d3a4745686
commit 5c819a3b3c

View File

@@ -441,15 +441,23 @@ int AIAction::getEfficiency()
AbilityFactory af;
int suggestion = af.abilityEfficiency(a, p, MODE_ABILITY);
int efficiencyModifier = (25 * target->DangerRanking());
if (p->game->hand->nb_cards > 1)
{
efficiencyModifier /= p->game->hand->nb_cards;
}
// Z, please review. If this condition is hit, it's immediately wiped out later at line 464 (the don't give flying twice check),
// since both satisfy the check for (target->has(a->abilitygranted)).
// Is this if statement section obsolete?
if (suggestion == BAKA_EFFECT_BAD && p != target->controller() && target->has(a->abilitygranted) && p->isAI())
{
efficiency += (25 * target->DangerRanking()) / p->game->hand->nb_cards;
efficiency += efficiencyModifier;
}
if (!target->has(a->abilitygranted) && g->getCurrentGamePhase() == Constants::MTG_PHASE_COMBATBEGIN && p == target->controller() && p->isAI())
{
efficiency += (25 * target->DangerRanking()) / p->game->hand->nb_cards;
efficiency += efficiencyModifier;
}
if (target->has(a->abilitygranted))