- Improved AI for charm and life-gain effects and removed RemAiDeck for Ojutai's Command

This commit is contained in:
excessum
2015-08-17 13:01:49 +00:00
parent 368d98fd98
commit 8f90f5532b
4 changed files with 25 additions and 9 deletions

View File

@@ -98,19 +98,27 @@ public class CharmAi extends SpellAbilityAi {
return sa.getChosenList();
}
List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa);
AbilitySub goodChoice = null;
List<AbilitySub> chosenList = new ArrayList<AbilitySub>();
// select first n playable options
AiController aic = ((PlayerControllerAi) ai.getController()).getAi();
for (AbilitySub sub : choices) {
sub.setActivatingPlayer(ai);
if (AiPlayDecision.WillPlay == aic.canPlaySa(sub)) {
chosenList.add(sub);
if (chosenList.size() == min) {
break;
if ("Good".equals(sub.getParam("AILogic")) && aic.doTrigger(sub, false)) {
goodChoice = sub;
} else {
if (AiPlayDecision.WillPlay == aic.canPlaySa(sub)) {
chosenList.add(sub);
if (chosenList.size() == min) {
break;
}
}
}
}
if (chosenList.size() == min - 1 && goodChoice != null) {
chosenList.add(goodChoice);
return chosenList;
}
if (chosenList.size() != min) {
return new ArrayList<AbilitySub>();
} else {

View File

@@ -11,6 +11,7 @@ import forge.game.player.Player;
import forge.game.spellability.AbilitySub;
import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetRestrictions;
import forge.util.MyRandom;
public class LifeGainAi extends SpellAbilityAi {
@@ -127,7 +128,15 @@ public class LifeGainAi extends SpellAbilityAi {
return false;
}
}
// Save instant-speed life-gain unless it is really worth it
if (!SpellAbilityAi.isSorcerySpeed(sa)) {
final float value = 0.9f * lifeAmount / life;
if (value < 0.2f) {
return false;
} else {
return MyRandom.getRandom().nextFloat() < value;
}
}
return true;
}