-Improved AI using Sarkhan, the Dragonspeaker.

This commit is contained in:
Sloth
2014-11-08 21:35:31 +00:00
parent 43a32b9f89
commit d572f506de

View File

@@ -125,7 +125,7 @@ public class AnimateAi extends SpellAbilityAi {
// don't use instant speed animate abilities outside humans // don't use instant speed animate abilities outside humans
// Combat_Declare_Attackers_InstantAbility step // Combat_Declare_Attackers_InstantAbility step
if (ph.getPlayerTurn().isOpponentOf(aiPlayer) && if (ph.getPlayerTurn().isOpponentOf(aiPlayer) &&
(!ph.is(PhaseType.COMBAT_DECLARE_ATTACKERS, opponent) || (game.getCombat() != null && game.getCombat().getAttackersOf(aiPlayer).isEmpty()))) { (!ph.is(PhaseType.COMBAT_DECLARE_ATTACKERS, opponent) || game.getCombat() != null && game.getCombat().getAttackersOf(aiPlayer).isEmpty())) {
return false; return false;
} }
@@ -148,36 +148,40 @@ public class AnimateAi extends SpellAbilityAi {
} if ("Never".equals(sa.getParam("AILogic"))) { } if ("Never".equals(sa.getParam("AILogic"))) {
return false; return false;
} }
} else for (final Card c : defined) { } else {
bFlag |= !c.isCreature() && !c.isTapped() boolean givesHaste = sa.hasParam("Keywords") && sa.getParam("Keywords").contains("Haste");
&& !(c.getTurnInZone() == game.getPhaseHandler().getTurn()) System.out.println("animateAI : haste = " + givesHaste);
&& !c.isEquipping(); for (final Card c : defined) {
bFlag |= !c.isCreature() && !c.isTapped()
&& (c.getTurnInZone() != game.getPhaseHandler().getTurn() || givesHaste)
&& !c.isEquipping();
// for creatures that could be improved (like Figure of Destiny)
if (!bFlag && c.isCreature() && (sa.hasParam("Permanent") || (!c.isTapped() && !c.isSick()))) {
int power = -5;
if (sa.hasParam("Power")) {
power = AbilityUtils.calculateAmount(source, sa.getParam("Power"), sa);
}
int toughness = -5;
if (sa.hasParam("Toughness")) {
toughness = AbilityUtils.calculateAmount(source, sa.getParam("Toughness"), sa);
}
if ((power + toughness) > (c.getCurrentPower() + c.getCurrentToughness())) {
bFlag = true;
}
}
// for creatures that could be improved (like Figure of Destiny) if (!SpellAbilityAi.isSorcerySpeed(sa)) {
if (!bFlag && c.isCreature() && (sa.hasParam("Permanent") || (!c.isTapped() && !c.isSick()))) { Card animatedCopy = CardFactory.getCard(c.getPaperCard(), aiPlayer);
int power = -5; AnimateAi.becomeAnimated(animatedCopy, c.hasSickness(), sa);
if (sa.hasParam("Power")) { if (ph.isPlayerTurn(aiPlayer) && !ComputerUtilCard.doesSpecifiedCreatureAttackAI(aiPlayer, animatedCopy)) {
power = AbilityUtils.calculateAmount(source, sa.getParam("Power"), sa); return false;
} }
int toughness = -5; if (ph.getPlayerTurn().isOpponentOf(aiPlayer) && !ComputerUtilCard.doesSpecifiedCreatureBlock(aiPlayer, animatedCopy)) {
if (sa.hasParam("Toughness")) { return false;
toughness = AbilityUtils.calculateAmount(source, sa.getParam("Toughness"), sa); }
} }
if ((power + toughness) > (c.getCurrentPower() + c.getCurrentToughness())) { }
bFlag = true;
}
}
if (!SpellAbilityAi.isSorcerySpeed(sa)) {
Card animatedCopy = CardFactory.getCard(c.getPaperCard(), aiPlayer);
AnimateAi.becomeAnimated(animatedCopy, c.hasSickness(), sa);
if (ph.isPlayerTurn(aiPlayer) && !ComputerUtilCard.doesSpecifiedCreatureAttackAI(aiPlayer, animatedCopy)) {
return false;
}
if (ph.getPlayerTurn().isOpponentOf(aiPlayer) && !ComputerUtilCard.doesSpecifiedCreatureBlock(aiPlayer, animatedCopy)) {
return false;
}
}
} }
if (!bFlag) { // All of the defined stuff is animated, not very if (!bFlag) { // All of the defined stuff is animated, not very
@@ -224,8 +228,10 @@ public class AnimateAi extends SpellAbilityAi {
CardCollectionView list = aiPlayer.getGame().getCardsIn(tgt.getZone()); CardCollectionView list = aiPlayer.getGame().getCardsIn(tgt.getZone());
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), animateSource); list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), animateSource);
CardCollection prefList = CardLists.getValidCards(list, sa.getParam("AITgts"), sa.getActivatingPlayer(), animateSource); CardCollection prefList = CardLists.getValidCards(list, sa.getParam("AITgts"), sa.getActivatingPlayer(), animateSource);
CardLists.shuffle(prefList); if (!prefList.isEmpty()){
sa.getTargets().add(prefList.getFirst()); CardLists.shuffle(prefList);
sa.getTargets().add(prefList.getFirst());
}
} }
return true; return true;
} }