issue 547

fixed the bug where the ai "attacks/blocks" its own attackers during the combat phase.
Strangely, creatures only die in this bug when there are two or more suffering from
summoning sickness.

If somebody can double check this code change to make sure that it is appropriate.
My playtesting indicates a success but I don't have the variety of player decks others have.
This commit is contained in:
techdragon.nguyen@gmail.com
2010-12-04 21:26:12 +00:00
parent ba3ca7018b
commit a7675ec216
3 changed files with 1133 additions and 1123 deletions
+2 -1
View File
@@ -59,7 +59,8 @@ protected:
//Variables used by Test suite //Variables used by Test suite
MTGCardInstance * nextCardToPlay; MTGCardInstance * nextCardToPlay;
queue<AIAction *> clickstream; queue<AIAction *> clickstream;
void tapLandsForMana(ManaCost * cost, MTGCardInstance * card = NULL); bool mFindingAbility;//is Ai currently looking for an activated ability to use?
bool tapLandsForMana(ManaCost * cost, MTGCardInstance * card = NULL);
int orderBlockers(); int orderBlockers();
int combatDamages(); int combatDamages();
int interruptIfICan(); int interruptIfICan();
+11 -5
View File
@@ -80,9 +80,16 @@ int AIPlayer::Act(float dt)
return 1; return 1;
} }
void AIPlayer::tapLandsForMana(ManaCost * cost, MTGCardInstance * target) bool AIPlayer::tapLandsForMana(ManaCost * cost, MTGCardInstance * target)
{ {
if (!cost) return;DebugTrace(" AI tapping land for mana"); DebugTrace(" AI attempting to tap land for mana." << endl
<< "- Target: " << (target ? target->name : "None" ) << endl
<< "- Cost: " << (cost ? cost->toString() : "NULL") );
if (!cost)
{
DebugTrace("Mana cost is NULL. ");
return false;
}
ManaCost * pMana = getPotentialMana(target); ManaCost * pMana = getPotentialMana(target);
ManaCost * diff = pMana->Diff(cost); ManaCost * diff = pMana->Diff(cost);
@@ -121,7 +128,7 @@ void AIPlayer::tapLandsForMana(ManaCost * cost, MTGCardInstance * target)
} }
} }
delete (diff); delete (diff);
return true;
} }
ManaCost * AIPlayer::getPotentialMana(MTGCardInstance * target) ManaCost * AIPlayer::getPotentialMana(MTGCardInstance * target)
@@ -644,7 +651,7 @@ int AIPlayer::selectAbility()
if (!clickstream.size()) if (!clickstream.size())
{ {
DebugTrace("AIPlayer:Using Activated ability"); DebugTrace("AIPlayer:Using Activated ability");
tapLandsForMana(a->ability->cost, a->click); if (tapLandsForMana(a->ability->cost, a->click))
clickstream.push(a); clickstream.push(a);
} }
else else
@@ -912,7 +919,6 @@ int AIPlayer::chooseBlockers()
{ {
while (card->defenser) while (card->defenser)
{ {
g->mLayers->actionLayer()->reactToClick(a, card); g->mLayers->actionLayer()->reactToClick(a, card);
} }
} }
+7 -4
View File
@@ -1238,13 +1238,16 @@ int MTGBlockRule::reactToClick(MTGCardInstance * card)
return 0; return 0;
MTGCardInstance * currentOpponent = card->isDefenser(); MTGCardInstance * currentOpponent = card->isDefenser();
bool result = false; bool result = false;
int candefend = 0; int canDefend = 0;
while (!result) while (!result)
{ {
currentOpponent = game->currentPlayer->game->inPlay->getNextAttacker(currentOpponent); currentOpponent = game->currentPlayer->game->inPlay->getNextAttacker(currentOpponent);
DebugTrace("Defenser Toggle: " << card->getName()); canDefend = card->toggleDefenser(currentOpponent);
candefend = card->toggleDefenser(currentOpponent);
result = (candefend || currentOpponent == NULL); DebugTrace("Defenser Toggle: " << card->getName() << endl
<< "- canDefend: " << (canDefend == 0) << endl
<< "- currentOpponent: " << currentOpponent);
result = (canDefend || currentOpponent == NULL);
} }
return 1; return 1;
} }