- Allowing Charms to have subAbilities be chosen more than once (AI support needs improving to actually filter through all the permutations)

This commit is contained in:
Sol
2015-11-10 03:10:53 +00:00
parent 27a80bbae9
commit 022041a2f6
6 changed files with 19 additions and 14 deletions

View File

@@ -501,8 +501,8 @@ public class PlayerControllerAi extends PlayerController {
* @see forge.game.player.PlayerController#chooseModeForAbility(forge.card.spellability.SpellAbility, java.util.List, int, int) * @see forge.game.player.PlayerController#chooseModeForAbility(forge.card.spellability.SpellAbility, java.util.List, int, int)
*/ */
@Override @Override
public List<AbilitySub> chooseModeForAbility(SpellAbility sa, int min, int num) { public List<AbilitySub> chooseModeForAbility(SpellAbility sa, int min, int num, boolean allowRepeat) {
return CharmAi.chooseOptionsAi(sa, player, sa.isTrigger(), num, min, !player.equals(sa.getActivatingPlayer())); return CharmAi.chooseOptionsAi(sa, player, sa.isTrigger(), num, min, allowRepeat, !player.equals(sa.getActivatingPlayer()));
} }
@Override @Override

View File

@@ -26,7 +26,7 @@ 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(sa, ai, min) : chooseOptionsAi(sa, ai, timingRight, num, min, false); List<AbilitySub> chosenList = min > 1 ? chooseMultipleOptionsAi(sa, ai, min) : chooseOptionsAi(sa, ai, timingRight, num, min, sa.hasParam("CanRepeatModes"), false);
if (chosenList.isEmpty()) { if (chosenList.isEmpty()) {
return false; return false;
@@ -38,7 +38,7 @@ 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 opponentChoser) { public static List<AbilitySub> chooseOptionsAi(SpellAbility sa, final Player ai, boolean playNow, int num, int min, boolean allowRepeat, boolean opponentChoser) {
if (sa.getChosenList() != null) { if (sa.getChosenList() != null) {
return sa.getChosenList(); return sa.getChosenList();
} }

View File

@@ -52,9 +52,9 @@ public class CharmEffect extends SpellAbilityEffect {
// so nothing to do in this resolve // so nothing to do in this resolve
} }
@Override @Override
protected String getStackDescription(SpellAbility sa) { protected String getStackDescription(SpellAbility sa) {
// TODO Build StackDescription based on Chosen SubAbilities
return ""; return "";
} }
@@ -79,7 +79,7 @@ public class CharmEffect extends SpellAbilityEffect {
source.setChosenPlayer(chooser); source.setChosenPlayer(chooser);
} }
List<AbilitySub> chosen = chooser.getController().chooseModeForAbility(sa, min, num); List<AbilitySub> chosen = chooser.getController().chooseModeForAbility(sa, min, num, sa.hasParam(("CanRepeatModes")));
chainAbilities(sa, chosen); chainAbilities(sa, chosen);
} }
@@ -98,12 +98,15 @@ public class CharmEffect extends SpellAbilityEffect {
}); });
for (AbilitySub sub : chosen) { for (AbilitySub sub : chosen) {
saDeepest.setSubAbility(sub); // Clone the chosen, just in case the some subAb gets chosen multiple times
sub.setActivatingPlayer(saDeepest.getActivatingPlayer()); AbilitySub clone = (AbilitySub)sub.getCopy();
sub.setParent(saDeepest);
saDeepest.setSubAbility(clone);
clone.setActivatingPlayer(saDeepest.getActivatingPlayer());
clone.setParent(saDeepest);
// to chain the next one (but make sure it goes all the way at the end of the SA chain) // to chain the next one (but make sure it goes all the way at the end of the SA chain)
saDeepest = sub; saDeepest = clone;
while (saDeepest.getSubAbility() != null) { while (saDeepest.getSubAbility() != null) {
saDeepest = saDeepest.getSubAbility(); saDeepest = saDeepest.getSubAbility();
} }

View File

@@ -184,7 +184,7 @@ public abstract class PlayerController {
public abstract boolean chooseFlipResult(SpellAbility sa, Player flipper, boolean[] results, boolean call); public abstract boolean chooseFlipResult(SpellAbility sa, Player flipper, boolean[] results, boolean call);
public abstract Card chooseProtectionShield(GameEntity entityBeingDamaged, List<String> options, Map<String, Card> choiceMap); public abstract Card chooseProtectionShield(GameEntity entityBeingDamaged, List<String> options, Map<String, Card> choiceMap);
public abstract List<AbilitySub> chooseModeForAbility(SpellAbility sa, int min, int num); public abstract List<AbilitySub> chooseModeForAbility(SpellAbility sa, int min, int num, boolean allowRepeat);
public abstract byte chooseColor(String message, SpellAbility sa, ColorSet colors); public abstract byte chooseColor(String message, SpellAbility sa, ColorSet colors);
public abstract byte chooseColorAllowColorless(String message, Card c, ColorSet colors); public abstract byte chooseColorAllowColorless(String message, Card c, ColorSet colors);

View File

@@ -444,7 +444,7 @@ public class PlayerControllerForTests extends PlayerController {
} }
@Override @Override
public List<AbilitySub> chooseModeForAbility(SpellAbility sa, int min, int num) { public List<AbilitySub> chooseModeForAbility(SpellAbility sa, int min, int num, boolean allowRepeat) {
throw new IllegalStateException("Erring on the side of caution here..."); throw new IllegalStateException("Erring on the side of caution here...");
} }

View File

@@ -1082,7 +1082,7 @@ public class PlayerControllerHuman
* @see forge.game.player.PlayerController#chooseModeForAbility(forge.card.spellability.SpellAbility, java.util.List, int, int) * @see forge.game.player.PlayerController#chooseModeForAbility(forge.card.spellability.SpellAbility, java.util.List, int, int)
*/ */
@Override @Override
public List<AbilitySub> chooseModeForAbility(final SpellAbility sa, final int min, final int num) { public List<AbilitySub> chooseModeForAbility(final SpellAbility sa, final int min, final int num, boolean allowRepeat) {
final List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa); final List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa);
final String modeTitle = String.format("%s activated %s - Choose a mode", sa.getActivatingPlayer(), sa.getHostCard()); final String modeTitle = String.format("%s activated %s - Choose a mode", sa.getActivatingPlayer(), sa.getHostCard());
final List<AbilitySub> chosen = Lists.newArrayListWithCapacity(num); final List<AbilitySub> chosen = Lists.newArrayListWithCapacity(num);
@@ -1098,7 +1098,9 @@ public class PlayerControllerHuman
break; break;
} }
if (!allowRepeat) {
choices.remove(a); choices.remove(a);
}
chosen.add(a); chosen.add(a);
} }
return chosen; return chosen;