mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- Improved AI for charm and life-gain effects and removed RemAiDeck for Ojutai's Command
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user