Added action logging during attack/block of the AI player. To do that, I wrapped some of the direct access from the player to the action layer into the game observer.
First version where I managed to finish a normal game while undoing several actions until the end. There are still some problems in direct damage spells and interruption management. I added several assert in the code to catch them.
This commit is contained in:
@@ -1985,10 +1985,9 @@ int AIPlayerBaka::chooseAttackers()
|
||||
cd.init();
|
||||
cd.setType("creature");
|
||||
MTGCardInstance * card = NULL;
|
||||
MTGAbility * a = observer->mLayers->actionLayer()->getAbility(MTGAbility::MTG_ATTACK_RULE);
|
||||
while ((card = cd.nextmatch(game->inPlay, card)))
|
||||
{
|
||||
observer->mLayers->actionLayer()->reactToClick(a, card);
|
||||
observer->cardClick(card, MTGAbility::MTG_ATTACK_RULE);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@@ -2033,12 +2032,11 @@ int AIPlayerBaka::chooseBlockers()
|
||||
cd.setType("Creature");
|
||||
cd.unsecureSetTapped(-1);
|
||||
card = NULL;
|
||||
MTGAbility * a = observer->mLayers->actionLayer()->getAbility(MTGAbility::MTG_BLOCK_RULE);
|
||||
|
||||
// We first try to block the major threats, those that are marked in the Top 3 of our stats
|
||||
while ((card = cd.nextmatch(game->inPlay, card)))
|
||||
{
|
||||
observer->mLayers->actionLayer()->reactToClick(a, card);
|
||||
observer->cardClick(card, MTGAbility::MTG_BLOCK_RULE);
|
||||
int set = 0;
|
||||
while (!set)
|
||||
{
|
||||
@@ -2062,7 +2060,7 @@ int AIPlayerBaka::chooseBlockers()
|
||||
}
|
||||
else
|
||||
{
|
||||
observer->mLayers->actionLayer()->reactToClick(a, card);
|
||||
observer->cardClick(card, MTGAbility::MTG_BLOCK_RULE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2077,7 +2075,7 @@ int AIPlayerBaka::chooseBlockers()
|
||||
{
|
||||
while (card->defenser)
|
||||
{
|
||||
observer->mLayers->actionLayer()->reactToClick(a, card);
|
||||
observer->cardClick(card, MTGAbility::MTG_BLOCK_RULE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2088,7 +2086,7 @@ int AIPlayerBaka::chooseBlockers()
|
||||
{
|
||||
if (!card->defenser)
|
||||
{
|
||||
observer->mLayers->actionLayer()->reactToClick(a, card);
|
||||
observer->cardClick(card, MTGAbility::MTG_BLOCK_RULE);
|
||||
int set = 0;
|
||||
while (!set)
|
||||
{
|
||||
@@ -2102,7 +2100,7 @@ int AIPlayerBaka::chooseBlockers()
|
||||
if (opponentsToughness[attacker] <= 0 || (card->toughness <= attacker->power && opponentForce * 2 < life
|
||||
&& !canFirstStrikeKill(card, attacker)) || attacker->nbOpponents() > 1)
|
||||
{
|
||||
observer->mLayers->actionLayer()->reactToClick(a, card);
|
||||
observer->cardClick(card, MTGAbility::MTG_BLOCK_RULE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user