mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
moved the possible options evaluation down the call stack
This commit is contained in:
@@ -22,8 +22,8 @@ public class CharmAi extends SpellAbilityAi {
|
||||
final int min = sa.hasParam("MinCharmNum") ? Integer.parseInt(sa.getParam("MinCharmNum")) : num;
|
||||
boolean timingRight = sa.isTrigger(); //is there a reason to play the charm now?
|
||||
|
||||
List<AbilitySub> chooseFrom = CharmEffect.makePossibleOptions(sa);
|
||||
List<AbilitySub> chosenList = chooseOptionsAi(ai, timingRight, chooseFrom, num, min, false);
|
||||
|
||||
List<AbilitySub> chosenList = chooseOptionsAi(sa, ai, timingRight, num, min, false);
|
||||
|
||||
if (chosenList.isEmpty()) {
|
||||
return false;
|
||||
@@ -33,7 +33,8 @@ public class CharmAi extends SpellAbilityAi {
|
||||
return r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||
}
|
||||
|
||||
public static List<AbilitySub> chooseOptionsAi(final Player ai, boolean playNow, List<AbilitySub> choices, int num, int min, boolean opponentChoser) {
|
||||
public static List<AbilitySub> chooseOptionsAi(SpellAbility sa, final Player ai, boolean playNow, int num, int min, boolean opponentChoser) {
|
||||
List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa);
|
||||
List<AbilitySub> chosenList = new ArrayList<AbilitySub>();
|
||||
|
||||
if (opponentChoser) {
|
||||
|
||||
@@ -35,10 +35,7 @@ public class CharmEffect extends SpellAbilityEffect {
|
||||
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
// nothing stack specific for Charm
|
||||
|
||||
return sb.toString();
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void makeChoices(SpellAbility sa) {
|
||||
@@ -47,7 +44,6 @@ public class CharmEffect extends SpellAbilityEffect {
|
||||
|
||||
final int num = Integer.parseInt(sa.hasParam("CharmNum") ? sa.getParam("CharmNum") : "1");
|
||||
final int min = sa.hasParam("MinCharmNum") ? Integer.parseInt(sa.getParam("MinCharmNum")) : num;
|
||||
final List<AbilitySub> choices = makePossibleOptions(sa);
|
||||
|
||||
Card source = sa.getSourceCard();
|
||||
Player activator = sa.getActivatingPlayer();
|
||||
@@ -63,7 +59,7 @@ public class CharmEffect extends SpellAbilityEffect {
|
||||
source.setChosenPlayer(chooser);
|
||||
}
|
||||
|
||||
List<AbilitySub> chosen = chooser.getController().chooseModeForAbility(sa, choices, min, num);
|
||||
List<AbilitySub> chosen = chooser.getController().chooseModeForAbility(sa, min, num);
|
||||
chainAbilities(sa, chosen);
|
||||
}
|
||||
|
||||
|
||||
@@ -161,6 +161,6 @@ public abstract class PlayerController {
|
||||
public abstract boolean chooseFilpResult(SpellAbility sa, Player flipper, boolean[] results, boolean call);
|
||||
public abstract Card chooseProtectionShield(GameEntity entityBeingDamaged, List<String> options, Map<String, Card> choiceMap);
|
||||
|
||||
public abstract List<AbilitySub> chooseModeForAbility(SpellAbility sa, List<AbilitySub> choices, int min, int num);
|
||||
public abstract List<AbilitySub> chooseModeForAbility(SpellAbility sa, int min, int num);
|
||||
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
* @see forge.game.player.PlayerController#chooseModeForAbility(forge.card.spellability.SpellAbility, java.util.List, int, int)
|
||||
*/
|
||||
@Override
|
||||
public List<AbilitySub> chooseModeForAbility(SpellAbility sa, List<AbilitySub> choices, int min, int num) {
|
||||
return CharmAi.chooseOptionsAi(player, sa.isTrigger(), choices, num, min, !player.equals(sa.getActivatingPlayer()));
|
||||
public List<AbilitySub> chooseModeForAbility(SpellAbility sa, int min, int num) {
|
||||
return CharmAi.chooseOptionsAi(sa, player, sa.isTrigger(), num, min, !player.equals(sa.getActivatingPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import forge.Card;
|
||||
import forge.GameEntity;
|
||||
import forge.ITargetable;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.effects.CharmEffect;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.mana.Mana;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
@@ -710,7 +711,8 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
* @see forge.game.player.PlayerController#chooseModeForAbility(forge.card.spellability.SpellAbility, java.util.List, int, int)
|
||||
*/
|
||||
@Override
|
||||
public List<AbilitySub> chooseModeForAbility(SpellAbility sa, List<AbilitySub> choices, int min, int num) {
|
||||
public List<AbilitySub> chooseModeForAbility(SpellAbility sa, int min, int num) {
|
||||
List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa);
|
||||
String modeTitle = String.format("%s activated %s - Choose a mode", sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
List<AbilitySub> chosen = new ArrayList<AbilitySub>();
|
||||
for (int i = 0; i < num; i++) {
|
||||
|
||||
Reference in New Issue
Block a user