mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Cleaned up CharmAi
This commit is contained in:
@@ -9,7 +9,6 @@ import com.google.common.collect.Multimap;
|
|||||||
|
|
||||||
import forge.LobbyPlayer;
|
import forge.LobbyPlayer;
|
||||||
import forge.ai.ability.ChangeZoneAi;
|
import forge.ai.ability.ChangeZoneAi;
|
||||||
import forge.ai.ability.CharmAi;
|
|
||||||
import forge.ai.ability.ProtectAi;
|
import forge.ai.ability.ProtectAi;
|
||||||
import forge.card.ColorSet;
|
import forge.card.ColorSet;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
@@ -497,7 +496,7 @@ public class PlayerControllerAi extends PlayerController {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<AbilitySub> chooseModeForAbility(SpellAbility sa, int min, int num, boolean allowRepeat) {
|
public List<AbilitySub> chooseModeForAbility(SpellAbility sa, int min, int num, boolean allowRepeat) {
|
||||||
return CharmAi.chooseOptionsAi(sa, player, sa.isTrigger(), num, min, allowRepeat, !player.equals(sa.getActivatingPlayer()));
|
return sa.getChosenList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -27,8 +27,9 @@ public class CharmAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
// reset the chosen list. Otherwise it will be locked in forever
|
// reset the chosen list. Otherwise it will be locked in forever
|
||||||
sa.setChosenList(null);
|
sa.setChosenList(null);
|
||||||
List<AbilitySub> chosenList = min > 1 ? chooseMultipleOptionsAi(CharmEffect.makePossibleOptions(sa), ai, min)
|
List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa);
|
||||||
: chooseOptionsAi(sa, ai, timingRight, num, min, sa.hasParam("CanRepeatModes"), false);
|
List<AbilitySub> chosenList = min > 1 ? chooseMultipleOptionsAi(choices, ai, min)
|
||||||
|
: chooseOptionsAi(choices, sa, ai, timingRight, num, min, sa.hasParam("CanRepeatModes"), false);
|
||||||
|
|
||||||
if (chosenList.isEmpty()) {
|
if (chosenList.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -40,11 +41,8 @@ public class CharmAi extends SpellAbilityAi {
|
|||||||
return r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
return r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<AbilitySub> chooseOptionsAi(SpellAbility sa, final Player ai, boolean playNow, int num, int min, boolean allowRepeat, boolean opponentChoser) {
|
private List<AbilitySub> chooseOptionsAi(List<AbilitySub> choices, SpellAbility sa, final Player ai,
|
||||||
if (sa.getChosenList() != null) {
|
boolean playNow, int num, int min, boolean allowRepeat, boolean opponentChoser) {
|
||||||
return sa.getChosenList();
|
|
||||||
}
|
|
||||||
List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa);
|
|
||||||
List<AbilitySub> chosenList = new ArrayList<AbilitySub>();
|
List<AbilitySub> chosenList = new ArrayList<AbilitySub>();
|
||||||
|
|
||||||
if (opponentChoser) {
|
if (opponentChoser) {
|
||||||
@@ -180,7 +178,6 @@ public class CharmAi extends SpellAbilityAi {
|
|||||||
private List<AbilitySub> chooseMultipleOptionsAi(List<AbilitySub> choices, final Player ai, int min) {
|
private List<AbilitySub> chooseMultipleOptionsAi(List<AbilitySub> choices, final Player ai, int min) {
|
||||||
AbilitySub goodChoice = null;
|
AbilitySub goodChoice = null;
|
||||||
List<AbilitySub> chosenList = new ArrayList<AbilitySub>();
|
List<AbilitySub> chosenList = new ArrayList<AbilitySub>();
|
||||||
// select first n playable options
|
|
||||||
AiController aic = ((PlayerControllerAi) ai.getController()).getAi();
|
AiController aic = ((PlayerControllerAi) ai.getController()).getAi();
|
||||||
for (AbilitySub sub : choices) {
|
for (AbilitySub sub : choices) {
|
||||||
sub.setActivatingPlayer(ai);
|
sub.setActivatingPlayer(ai);
|
||||||
@@ -200,13 +197,11 @@ public class CharmAi extends SpellAbilityAi {
|
|||||||
// Add generic good choice if one more choice is needed
|
// Add generic good choice if one more choice is needed
|
||||||
if (chosenList.size() == min - 1 && goodChoice != null) {
|
if (chosenList.size() == min - 1 && goodChoice != null) {
|
||||||
chosenList.add(0, goodChoice); // hack to make Dromoka's Command fight targets work
|
chosenList.add(0, goodChoice); // hack to make Dromoka's Command fight targets work
|
||||||
return chosenList;
|
|
||||||
}
|
}
|
||||||
if (chosenList.size() != min) {
|
if (chosenList.size() != min) {
|
||||||
return new ArrayList<AbilitySub>();
|
chosenList.clear();
|
||||||
} else {
|
|
||||||
return chosenList;
|
|
||||||
}
|
}
|
||||||
|
return chosenList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user