From 26d1162d2334b268cf81cd70c3cbedc644e0c3f5 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 23:38:35 +0000 Subject: [PATCH] - The AI will no longer use activated loseLife, poison and setLife abilities before main2. --- .../AbilityFactory_AlterLife.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/forge/card/abilityFactory/AbilityFactory_AlterLife.java b/src/forge/card/abilityFactory/AbilityFactory_AlterLife.java index fe6f55e85c6..9cf8662355c 100644 --- a/src/forge/card/abilityFactory/AbilityFactory_AlterLife.java +++ b/src/forge/card/abilityFactory/AbilityFactory_AlterLife.java @@ -422,10 +422,11 @@ public class AbilityFactory_AlterLife { Random r = MyRandom.random; Cost abCost = sa.getPayCosts(); final Card source = sa.getSourceCard(); + HashMap params = af.getMapParams(); int humanLife = AllZone.HumanPlayer.getLife(); int aiLife = AllZone.ComputerPlayer.getLife(); - String amountStr = af.getMapParams().get("LifeAmount"); + String amountStr = params.get("LifeAmount"); // TODO handle proper calculation of X values based on Cost and what would be paid final int amount = AbilityFactory.calculateAmount(af.getHostCard(), amountStr, sa); @@ -455,6 +456,10 @@ public class AbilityFactory_AlterLife { if (!AllZone.HumanPlayer.canLoseLife()) return false; + //Don't use loselife before main 2 if possible + if(AllZone.Phase.isBefore(Constant.Phase.Main2) && !params.containsKey("ActivatingPhases")) + return false; + // prevent run-away activations - first time will always return true boolean chance = r.nextFloat() <= Math.pow(.6667, source.getAbilityUsed()); @@ -750,8 +755,9 @@ public class AbilityFactory_AlterLife { private static boolean poisonCanPlayAI(final AbilityFactory af, final SpellAbility sa, final String amountStr){ Cost abCost = sa.getPayCosts(); + HashMap params = af.getMapParams(); //int humanPoison = AllZone.HumanPlayer.getPoisonCounters(); - int humanLife = AllZone.HumanPlayer.getLife(); + //int humanLife = AllZone.HumanPlayer.getLife(); //int aiPoison = AllZone.ComputerPlayer.getPoisonCounters(); int aiLife = AllZone.ComputerPlayer.getLife(); @@ -764,11 +770,15 @@ public class AbilityFactory_AlterLife { if (amountStr.contains("X")) return false; } - if(abCost.getLifeCost() && aiLife - abCost.getLifeAmount() < humanLife - amount) return false; + if(abCost.getLifeCost() && aiLife - abCost.getLifeAmount() <= 0) return false; } if (!ComputerUtil.canPayCost(sa)) return false; + + //Don't use poison before main 2 if possible + if(AllZone.Phase.isBefore(Constant.Phase.Main2) && !params.containsKey("ActivatingPhases")) + return false; Target tgt = sa.getTarget(); @@ -918,6 +928,10 @@ public class AbilityFactory_AlterLife { if(!AllZone.ComputerPlayer.canGainLife()) return false; + + //Don't use setLife before main 2 if possible + if(AllZone.Phase.isBefore(Constant.Phase.Main2) && !params.containsKey("ActivatingPhases")) + return false; // TODO handle proper calculation of X values based on Cost and what would be paid int amount;