From 5c819a3b3cfca347a91e86f85881ed1d9c2bc2ea Mon Sep 17 00:00:00 2001 From: "wrenczes@gmail.com" Date: Wed, 8 Dec 2010 07:53:51 +0000 Subject: [PATCH] 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. --- projects/mtg/src/AIPlayer.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index 26b5993f1..6a94da9d4 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -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))