- Little improvements in the AI part of AF Discard (triggers and drawbacks).

- Enabled the AI of AF ChooseColor for spells (strictly dependent on the subabilities).
This commit is contained in:
Sloth
2011-10-29 20:10:37 +00:00
parent e38b709257
commit 51ef05be11
2 changed files with 10 additions and 17 deletions

View File

@@ -569,7 +569,13 @@ public final class AbilityFactory_Choose {
*/ */
private static boolean chooseColorCanPlayAI(final AbilityFactory af, final SpellAbility sa) { private static boolean chooseColorCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
// Note: if (AILogic == MostProminentAttackers) return isDuringCombat(); // Note: if (AILogic == MostProminentAttackers) return isDuringCombat();
return AbilityFactory_Choose.chooseColorTriggerAI(af, sa, false); boolean chance = true;
Ability_Sub subAb = sa.getSubAbility();
if (subAb != null) {
chance &= subAb.chkAIDrawback();
}
return chance;
} }
/** /**
@@ -588,18 +594,6 @@ public final class AbilityFactory_Choose {
private static boolean chooseColorTriggerAI(final AbilityFactory af, private static boolean chooseColorTriggerAI(final AbilityFactory af,
final SpellAbility sa, final boolean mandatory) { final SpellAbility sa, final boolean mandatory) {
return false; return false;
/*
* if (!ComputerUtil.canPayCost(sa)) { return false; }
*
* Target tgt = sa.getTarget();
*
* if (sa.getTarget() != null) { tgt.resetTargets();
* sa.getTarget().addTarget(AllZone.getComputerPlayer()); } else {
* ArrayList<Player> tgtPlayers =
* AbilityFactory.getDefinedPlayers(sa.getSourceCard(),
* af.getMapParams().get("Defined"), sa); for (Player p : tgtPlayers) {
* if (p.isHuman() && !mandatory) { return false; } } } return true;
*/
} }
/** /**

View File

@@ -1355,9 +1355,6 @@ public class AbilityFactory_ZoneAffecting {
boolean humanHasHand = AllZone.getHumanPlayer().getCardsIn(Constant.Zone.Hand).size() > 0; boolean humanHasHand = AllZone.getHumanPlayer().getCardsIn(Constant.Zone.Hand).size() > 0;
if (tgt != null) { if (tgt != null) {
if (!humanHasHand) {
return false;
}
discardTargetAI(af, sa); discardTargetAI(af, sa);
} else { } else {
// TODO: Add appropriate restrictions // TODO: Add appropriate restrictions
@@ -1442,6 +1439,8 @@ public class AbilityFactory_ZoneAffecting {
*/ */
private static boolean discardTargetAI(final AbilityFactory af, final SpellAbility sa) { private static boolean discardTargetAI(final AbilityFactory af, final SpellAbility sa) {
Target tgt = af.getAbTgt(); Target tgt = af.getAbTgt();
if(AllZone.getHumanPlayer().getCardsIn(Constant.Zone.Hand).size() < 1)
return false;
if (tgt != null) { if (tgt != null) {
if (AllZone.getHumanPlayer().canTarget(sa)) { if (AllZone.getHumanPlayer().canTarget(sa)) {
tgt.addTarget(AllZone.getHumanPlayer()); tgt.addTarget(AllZone.getHumanPlayer());
@@ -1499,7 +1498,7 @@ public class AbilityFactory_ZoneAffecting {
// if parent draws cards, make sure cards in hand + cards drawn > 0 // if parent draws cards, make sure cards in hand + cards drawn > 0
Target tgt = af.getAbTgt(); Target tgt = af.getAbTgt();
if (tgt != null) { if (tgt != null) {
discardTargetAI(af, subAb); return discardTargetAI(af, subAb);
} }
// TODO: check for some extra things // TODO: check for some extra things
return true; return true;