- Little improvement for the AI of AF LoseLife (the AI will no longer wait until Main2 or blocking or use randomness if the ability can kill the human).

This commit is contained in:
Sloth
2011-10-11 09:32:31 +00:00
parent 41c4dc6a06
commit 44fb8577a0

View File

@@ -496,6 +496,7 @@ public class AbilityFactory_AlterLife {
Cost abCost = sa.getPayCosts(); Cost abCost = sa.getPayCosts();
final Card source = sa.getSourceCard(); final Card source = sa.getSourceCard();
HashMap<String, String> params = af.getMapParams(); HashMap<String, String> params = af.getMapParams();
boolean priority = false;
String amountStr = params.get("LifeAmount"); String amountStr = params.get("LifeAmount");
@@ -520,12 +521,15 @@ public class AbilityFactory_AlterLife {
if (!AllZone.getHumanPlayer().canLoseLife()) if (!AllZone.getHumanPlayer().canLoseLife())
return false; return false;
if (amount >= AllZone.getHumanPlayer().getLife())
priority = true; //killing the human should be done asap
//Don't use loselife before main 2 if possible //Don't use loselife before main 2 if possible
if (AllZone.getPhase().isBefore(Constant.Phase.Main2) && !params.containsKey("ActivationPhases")) if (AllZone.getPhase().isBefore(Constant.Phase.Main2) && !params.containsKey("ActivationPhases") && !priority)
return false; return false;
//Don't tap creatures that may be able to block //Don't tap creatures that may be able to block
if (AbilityFactory.waitForBlocking(sa)) if (AbilityFactory.waitForBlocking(sa) && !priority)
return false; return false;
// prevent run-away activations - first time will always return true // prevent run-away activations - first time will always return true
@@ -545,7 +549,7 @@ public class AbilityFactory_AlterLife {
} }
boolean randomReturn = r.nextFloat() <= .6667; boolean randomReturn = r.nextFloat() <= .6667;
if (AbilityFactory.playReusable(sa)) if (AbilityFactory.playReusable(sa) || priority)
randomReturn = true; randomReturn = true;
return (randomReturn && chance); return (randomReturn && chance);