Refactor confirmAction

This commit is contained in:
tool4EvEr
2021-05-07 18:14:20 +02:00
parent d6e7d1ffee
commit 3ab7886eab
80 changed files with 135 additions and 102 deletions

View File

@@ -1281,7 +1281,7 @@ public class AiController {
return discardList; return discardList;
} }
public boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
ApiType api = sa.getApi(); ApiType api = sa.getApi();
// Abilities without api may also use this routine, However they should provide a unique mode value ?? How could this work? // Abilities without api may also use this routine, However they should provide a unique mode value ?? How could this work?
@@ -1290,7 +1290,7 @@ public class AiController {
mode); mode);
throw new IllegalArgumentException(exMsg); throw new IllegalArgumentException(exMsg);
} }
return SpellApiToAi.Converter.get(api).confirmAction(player, sa, mode, message); return SpellApiToAi.Converter.get(api).confirmAction(player, sa, mode, message, params);
} }
public boolean confirmBidAction(SpellAbility sa, PlayerActionConfirmMode mode, String message, int bid, Player winner) { public boolean confirmBidAction(SpellAbility sa, PlayerActionConfirmMode mode, String message, int bid, Player winner) {

View File

@@ -237,8 +237,8 @@ public class PlayerControllerAi extends PlayerController {
} }
@Override @Override
public boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return getAi().confirmAction(sa, mode, message); return getAi().confirmAction(sa, mode, message, params);
} }
@Override @Override

View File

@@ -305,7 +305,7 @@ public abstract class SpellAbilityAi {
return SpellApiToAi.Converter.get(ab.getApi()).chkAIDrawback(ab, aiPlayer) && (subAb == null || chkDrawbackWithSubs(aiPlayer, subAb)); return SpellApiToAi.Converter.get(ab.getApi()).chkAIDrawback(ab, aiPlayer) && (subAb == null || chkDrawbackWithSubs(aiPlayer, subAb));
} }
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
System.err.println("Warning: default (ie. inherited from base class) implementation of confirmAction is used by " + sa.getHostCard().getName() + " for " + this.getClass().getName() + ". Consider declaring an overloaded method"); System.err.println("Warning: default (ie. inherited from base class) implementation of confirmAction is used by " + sa.getHostCard().getName() + " for " + this.getClass().getName() + ". Consider declaring an overloaded method");
return true; return true;
} }

View File

@@ -1,6 +1,8 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.Map;
import forge.ai.SpellAbilityAi; import forge.ai.SpellAbilityAi;
import forge.game.player.Player; import forge.game.player.Player;
import forge.game.player.PlayerActionConfirmMode; import forge.game.player.PlayerActionConfirmMode;
@@ -16,7 +18,7 @@ public class AlwaysPlayAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return true; return true;
} }
} }

View File

@@ -85,7 +85,7 @@ public class AmassAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return true; return true;
} }

View File

@@ -245,7 +245,7 @@ public class AnimateAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return player.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2); return player.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2);
} }

View File

@@ -1727,7 +1727,7 @@ public class AttachAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return true; return true;
} }

View File

@@ -1714,7 +1714,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
// AI was never asked // AI was never asked
return true; return true;
} }

View File

@@ -1,6 +1,7 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.Collections; import java.util.Collections;
import java.util.Map;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@@ -330,7 +331,7 @@ public class ChangeZoneAllAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player ai, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player ai, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
final String hostName = source.getName(); final String hostName = source.getName();
final ZoneType origin = ZoneType.listValueOf(sa.getParam("Origin")).get(0); final ZoneType origin = ZoneType.listValueOf(sa.getParam("Origin")).get(0);

View File

@@ -156,7 +156,7 @@ public class CloneAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
if (sa.hasParam("AILogic") && (!sa.usesTargeting() || sa.isTargetNumberValid())) { if (sa.hasParam("AILogic") && (!sa.usesTargeting() || sa.isTargetNumberValid())) {
// Had a special logic for it and managed to target, so confirm if viable // Had a special logic for it and managed to target, so confirm if viable
if ("CloneBestCreature".equals(sa.getParam("AILogic"))) { if ("CloneBestCreature".equals(sa.getParam("AILogic"))) {

View File

@@ -209,7 +209,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
//TODO: add logic here //TODO: add logic here
return true; return true;
} }

View File

@@ -137,7 +137,7 @@ public class CopySpellAbilityAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
// Chain of Acid requires special attention here since otherwise the AI will confirm the copy and then // Chain of Acid requires special attention here since otherwise the AI will confirm the copy and then
// run into the necessity of confirming a mandatory Destroy, thus destroying all of its own permanents. // run into the necessity of confirming a mandatory Destroy, thus destroying all of its own permanents.
if ("ChainOfAcid".equals(sa.getParam("AILogic"))) { if ("ChainOfAcid".equals(sa.getParam("AILogic"))) {

View File

@@ -890,7 +890,7 @@ public class CountersPutAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
if (mode == PlayerActionConfirmMode.Tribute) { if (mode == PlayerActionConfirmMode.Tribute) {
// add counter if that opponent has a giant creature // add counter if that opponent has a giant creature

View File

@@ -1,6 +1,7 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.List; import java.util.List;
import java.util.Map;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -152,7 +153,7 @@ public class CountersPutAllAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return player.getCreaturesInPlay().size() >= player.getWeakestOpponent().getCreaturesInPlay().size(); return player.getCreaturesInPlay().size() >= player.getWeakestOpponent().getCreaturesInPlay().size();
} }

View File

@@ -185,7 +185,7 @@ public class DigAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
Card topc = player.getZone(ZoneType.Library).get(0); Card topc = player.getZone(ZoneType.Library).get(0);
// AI actions for individual cards (until this AI can be generalized) // AI actions for individual cards (until this AI can be generalized)

View File

@@ -1,5 +1,7 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.Map;
import forge.ai.AiAttackController; import forge.ai.AiAttackController;
import forge.ai.ComputerUtil; import forge.ai.ComputerUtil;
import forge.ai.SpellAbilityAi; import forge.ai.SpellAbilityAi;
@@ -95,7 +97,7 @@ public class DigMultipleAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return true; return true;
} }
} }

View File

@@ -1,6 +1,7 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.List; import java.util.List;
import java.util.Map;
import forge.ai.AiAttackController; import forge.ai.AiAttackController;
import forge.ai.ComputerUtilCost; import forge.ai.ComputerUtilCost;
@@ -123,7 +124,7 @@ public class DigUntilAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
if (sa.hasParam("AILogic")) { if (sa.hasParam("AILogic")) {
final String logic = sa.getParam("AILogic"); final String logic = sa.getParam("AILogic");
if ("OathOfDruids".equals(logic)) { if ("OathOfDruids".equals(logic)) {

View File

@@ -1,6 +1,7 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.List; import java.util.List;
import java.util.Map;
import forge.ai.AiAttackController; import forge.ai.AiAttackController;
import forge.ai.ComputerUtil; import forge.ai.ComputerUtil;
@@ -212,11 +213,11 @@ public class DiscardAi extends SpellAbilityAi {
} // discardCheckDrawbackAI() } // discardCheckDrawbackAI()
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
if ( mode == PlayerActionConfirmMode.Random ) { // if ( mode == PlayerActionConfirmMode.Random ) { //
// TODO For now AI will always discard Random used currently with: Balduvian Horde and similar cards // TODO For now AI will always discard Random used currently with: Balduvian Horde and similar cards
return true; return true;
} }
return super.confirmAction(player, sa, mode, message); return super.confirmAction(player, sa, mode, message, params);
} }
} }

View File

@@ -18,6 +18,8 @@
*/ */
package forge.ai.ability; package forge.ai.ability;
import java.util.Map;
import forge.ai.AiCostDecision; import forge.ai.AiCostDecision;
import forge.ai.AiProps; import forge.ai.AiProps;
import forge.ai.ComputerUtil; import forge.ai.ComputerUtil;
@@ -534,7 +536,7 @@ public class DrawAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
int numCards = sa.hasParam("NumCards") ? AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumCards"), sa) : 1; int numCards = sa.hasParam("NumCards") ? AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumCards"), sa) : 1;
// AI shouldn't mill itself // AI shouldn't mill itself
if (numCards < player.getZone(ZoneType.Library).size()) if (numCards < player.getZone(ZoneType.Library).size())

View File

@@ -72,7 +72,7 @@ public final class EncodeAi extends SpellAbilityAi {
* forge.game.player.PlayerActionConfirmMode, java.lang.String) * forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
// only try to encode if there is a creature it can be used on // only try to encode if there is a creature it can be used on
return chooseCard(player, player.getCreaturesInPlay(), true) != null; return chooseCard(player, player.getCreaturesInPlay(), true) != null;
} }

View File

@@ -1,6 +1,8 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.Map;
import forge.ai.SpellAbilityAi; import forge.ai.SpellAbilityAi;
import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType; import forge.game.phase.PhaseType;
@@ -20,7 +22,7 @@ public class InvestigateAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return true; return true;
} }
} }

View File

@@ -1,6 +1,8 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.Map;
import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCard;
import forge.ai.PlayerControllerAi; import forge.ai.PlayerControllerAi;
import forge.ai.SpellAbilityAi; import forge.ai.SpellAbilityAi;
@@ -32,7 +34,7 @@ public class LearnAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return true; return true;
} }

View File

@@ -43,7 +43,7 @@ public class ManifestAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return true; return true;
} }

View File

@@ -193,7 +193,7 @@ public class MillAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
if ("TimmerianFiends".equals(sa.getParam("AILogic"))) { if ("TimmerianFiends".equals(sa.getParam("AILogic"))) {
return SpecialCardAi.TimmerianFiends.consider(player, sa); return SpecialCardAi.TimmerianFiends.consider(player, sa);
} }

View File

@@ -63,7 +63,7 @@ public class MutateAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return true; return true;
} }
} }

View File

@@ -1,5 +1,7 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.Map;
import forge.ai.SpellAbilityAi; import forge.ai.SpellAbilityAi;
import forge.ai.SpellApiToAi; import forge.ai.SpellApiToAi;
import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseHandler;
@@ -45,7 +47,7 @@ public class PeekAndRevealAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
AbilitySub subAb = sa.getSubAbility(); AbilitySub subAb = sa.getSubAbility();
return subAb != null && SpellApiToAi.Converter.get(subAb.getApi()).chkDrawbackWithSubs(player, subAb); return subAb != null && SpellApiToAi.Converter.get(subAb.getApi()).chkDrawbackWithSubs(player, subAb);
} }

View File

@@ -29,7 +29,6 @@ import forge.game.cost.Cost;
import forge.game.keyword.Keyword; import forge.game.keyword.Keyword;
import forge.game.player.Player; import forge.game.player.Player;
import forge.game.player.PlayerActionConfirmMode; import forge.game.player.PlayerActionConfirmMode;
import forge.game.ability.effects.PlayEffect;
import forge.game.spellability.Spell; import forge.game.spellability.Spell;
import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbility;
import forge.game.spellability.SpellAbilityPredicates; import forge.game.spellability.SpellAbilityPredicates;
@@ -164,9 +163,9 @@ public class PlayAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player ai, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player ai, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
// as called from PlayEffect // as called from PlayEffect
return chooseSingleCard(ai, sa, new CardCollection(((PlayEffect)(sa.getApi().getSpellEffect())).getTgtCard()), true, ai, null) != null; return chooseSingleCard(ai, sa, new CardCollection((Card) params.get("Card")), true, ai, null) != null;
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@@ -2,6 +2,7 @@ package forge.ai.ability;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -806,7 +807,7 @@ public class PumpAi extends PumpAiBase {
} // pumpDrawbackAI() } // pumpDrawbackAI()
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
//TODO Add logic here if necessary but I think the AI won't cast //TODO Add logic here if necessary but I think the AI won't cast
//the spell in the first place if it would curse its own creature //the spell in the first place if it would curse its own creature
//and the pump isn't mandatory //and the pump isn't mandatory

View File

@@ -1,6 +1,8 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.Map;
import forge.ai.AiCardMemory; import forge.ai.AiCardMemory;
import forge.ai.AiController; import forge.ai.AiController;
import forge.ai.AiProps; import forge.ai.AiProps;
@@ -92,7 +94,7 @@ public class RearrangeTopOfLibraryAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
// Confirming this action means shuffling the library if asked. // Confirming this action means shuffling the library if asked.
// First, let's check if we can play the top card of the library // First, let's check if we can play the top card of the library

View File

@@ -1,6 +1,8 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.Map;
import forge.ai.AiAttackController; import forge.ai.AiAttackController;
import forge.ai.AiController; import forge.ai.AiController;
import forge.ai.ComputerUtilCost; import forge.ai.ComputerUtilCost;
@@ -38,7 +40,7 @@ public class RepeatAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
//TODO add logic to have computer make better choice (ArsenalNut) //TODO add logic to have computer make better choice (ArsenalNut)
return false; return false;
} }

View File

@@ -1,6 +1,8 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.Map;
import forge.ai.SpellAbilityAi; import forge.ai.SpellAbilityAi;
import forge.game.Game; import forge.game.Game;
import forge.game.card.Card; import forge.game.card.Card;
@@ -43,7 +45,7 @@ public class RollDiceAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return true; return true;
} }
} }

View File

@@ -1,6 +1,7 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.List; import java.util.List;
import java.util.Map;
import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCard;
import forge.ai.ComputerUtilCost; import forge.ai.ComputerUtilCost;
@@ -170,7 +171,7 @@ public class SacrificeAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return true; return true;
} }

View File

@@ -1,5 +1,7 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.Map;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import forge.ai.ComputerUtilMana; import forge.ai.ComputerUtilMana;
@@ -135,7 +137,7 @@ public class ScryAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return true; return true;
} }
} }

View File

@@ -1,5 +1,7 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.Map;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCard;
@@ -264,7 +266,7 @@ public class SetStateAi extends SpellAbilityAi {
return true; return true;
} }
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
// TODO: improve the AI for when it may want to transform something that's optional to transform // TODO: improve the AI for when it may want to transform something that's optional to transform
return isSafeToTransformIntoLegendary(player, sa.getHostCard()); return isSafeToTransformIntoLegendary(player, sa.getHostCard());
} }

View File

@@ -1,5 +1,7 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.Map;
import forge.ai.SpellAbilityAi; import forge.ai.SpellAbilityAi;
import forge.game.phase.PhaseType; import forge.game.phase.PhaseType;
import forge.game.player.Player; import forge.game.player.Player;
@@ -55,7 +57,7 @@ public class ShuffleAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
// ai could analyze parameter denoting the player to shuffle // ai could analyze parameter denoting the player to shuffle
return true; return true;
} }

View File

@@ -1,5 +1,7 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.Map;
import forge.ai.SpellAbilityAi; import forge.ai.SpellAbilityAi;
import forge.game.player.Player; import forge.game.player.Player;
import forge.game.player.PlayerActionConfirmMode; import forge.game.player.PlayerActionConfirmMode;
@@ -17,7 +19,7 @@ public class SkipPhaseAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return true; return true;
} }
} }

View File

@@ -1,5 +1,7 @@
package forge.ai.ability; package forge.ai.ability;
import java.util.Map;
import forge.ai.AiCardMemory; import forge.ai.AiCardMemory;
import forge.ai.AiProps; import forge.ai.AiProps;
import forge.ai.ComputerUtilCost; import forge.ai.ComputerUtilCost;
@@ -120,7 +122,7 @@ public class SurveilAi extends SpellAbilityAi {
} }
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return true; return true;
} }
} }

View File

@@ -297,7 +297,7 @@ public class TokenAi extends SpellAbilityAi {
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String) * @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
// TODO: AILogic // TODO: AILogic
return true; return true;
} }

View File

@@ -1394,7 +1394,7 @@ public class GameAction {
private boolean stateBasedAction903_9a(Card c) { private boolean stateBasedAction903_9a(Card c) {
if (c.isRealCommander() && c.canMoveToCommandZone()) { if (c.isRealCommander() && c.canMoveToCommandZone()) {
c.setMoveToCommandZone(false); c.setMoveToCommandZone(false);
if (c.getOwner().getController().confirmAction(c.getSpellPermanent(), PlayerActionConfirmMode.ChangeZoneToAltDestination, c.getName() + ": If a commander is in a graveyard or in exile and that card was put into that zone since the last time state-based actions were checked, its owner may put it into the command zone.")) { if (c.getOwner().getController().confirmAction(c.getSpellPermanent(), PlayerActionConfirmMode.ChangeZoneToAltDestination, c.getName() + ": If a commander is in a graveyard or in exile and that card was put into that zone since the last time state-based actions were checked, its owner may put it into the command zone.", null)) {
moveTo(c.getOwner().getZone(ZoneType.Command), c, null); moveTo(c.getOwner().getZone(ZoneType.Command), c, null);
return true; return true;
} }

View File

@@ -25,7 +25,7 @@ public class AbandonEffect extends SpellAbilityEffect {
Player controller = source.getController(); Player controller = source.getController();
boolean isOptional = sa.hasParam("Optional"); boolean isOptional = sa.hasParam("Optional");
if (isOptional && !controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblWouldYouLikeAbandonSource", CardTranslation.getTranslatedName(source.getName())))) { if (isOptional && !controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblWouldYouLikeAbandonSource", CardTranslation.getTranslatedName(source.getName())), null)) {
return; return;
} }

View File

@@ -147,7 +147,7 @@ public class AnimateEffect extends AnimateEffectBase {
? TextUtil.fastReplace(sa.getParam("OptionQuestion"), "TARGETS", targets) ? TextUtil.fastReplace(sa.getParam("OptionQuestion"), "TARGETS", targets)
: getStackDescription(sa); : getStackDescription(sa);
if (!sa.getActivatingPlayer().getController().confirmAction(sa, null, message)) { if (!sa.getActivatingPlayer().getController().confirmAction(sa, null, message, null)) {
return; return;
} }
} }

View File

@@ -90,7 +90,7 @@ public class AttachEffect extends SpellAbilityEffect {
// If Cast Targets will be checked on the Stack // If Cast Targets will be checked on the Stack
for (final Card attachment : attachments) { for (final Card attachment : attachments) {
String message = Localizer.getInstance().getMessage("lblDoYouWantAttachSourceToTarget", CardTranslation.getTranslatedName(attachment.getName()), attachToName); String message = Localizer.getInstance().getMessage("lblDoYouWantAttachSourceToTarget", CardTranslation.getTranslatedName(attachment.getName()), attachToName);
if ( sa.hasParam("Optional") && !p.getController().confirmAction(sa, null, message) ) if ( sa.hasParam("Optional") && !p.getController().confirmAction(sa, null, message, null) )
continue; continue;
handleAttachment(attachment, attachTo, sa); handleAttachment(attachment, attachTo, sa);
} }

View File

@@ -50,7 +50,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
// Redirect rules read 'you MAY choose new targets' ... okay! // Redirect rules read 'you MAY choose new targets' ... okay!
// TODO: Don't even ask to change targets, if the SA and subs don't actually have targets // TODO: Don't even ask to change targets, if the SA and subs don't actually have targets
boolean isOptional = sa.hasParam("Optional"); boolean isOptional = sa.hasParam("Optional");
if (isOptional && !chooser.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantChangeAbilityTargets", tgtSA.getHostCard().toString()))) { if (isOptional && !chooser.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantChangeAbilityTargets", tgtSA.getHostCard().toString()), null)) {
continue; continue;
} }
if (sa.hasParam("ChangeSingleTarget")) { if (sa.hasParam("ChangeSingleTarget")) {

View File

@@ -116,7 +116,7 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
message = Localizer.getInstance().getMessage("lblMoveTargetFromOriginToDestination", targets, Lang.joinHomogenous(origin, ZoneType.Accessors.GET_TRANSLATED_NAME), destination.getTranslatedName()); message = Localizer.getInstance().getMessage("lblMoveTargetFromOriginToDestination", targets, Lang.joinHomogenous(origin, ZoneType.Accessors.GET_TRANSLATED_NAME), destination.getTranslatedName());
} }
if (!sa.getActivatingPlayer().getController().confirmAction(sa, null, message)) { if (!sa.getActivatingPlayer().getController().confirmAction(sa, null, message, null)) {
return; return;
} }
} }

View File

@@ -462,7 +462,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
if (sa.hasParam("AlternativeDecider")) { if (sa.hasParam("AlternativeDecider")) {
alterDecider = AbilityUtils.getDefinedPlayers(hostCard, sa.getParam("AlternativeDecider"), sa).get(0); alterDecider = AbilityUtils.getDefinedPlayers(hostCard, sa.getParam("AlternativeDecider"), sa).get(0);
} }
if (!alterDecider.getController().confirmAction(sa, PlayerActionConfirmMode.ChangeZoneToAltDestination, sb.toString())) { if (!alterDecider.getController().confirmAction(sa, PlayerActionConfirmMode.ChangeZoneToAltDestination, sb.toString(), null)) {
destination = ZoneType.smartValueOf(sa.getParam("DestinationAlternative")); destination = ZoneType.smartValueOf(sa.getParam("DestinationAlternative"));
altDest = true; altDest = true;
} }
@@ -521,7 +521,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
} }
final String prompt = TextUtil.concatWithSpace(Localizer.getInstance().getMessage("lblDoYouWantMoveTargetFromOriToDest", CardTranslation.getTranslatedName(gameCard.getName()), Lang.joinHomogenous(origin, ZoneType.Accessors.GET_TRANSLATED_NAME), destination.getTranslatedName())); final String prompt = TextUtil.concatWithSpace(Localizer.getInstance().getMessage("lblDoYouWantMoveTargetFromOriToDest", CardTranslation.getTranslatedName(gameCard.getName()), Lang.joinHomogenous(origin, ZoneType.Accessors.GET_TRANSLATED_NAME), destination.getTranslatedName()));
if (optional && !chooser.getController().confirmAction(sa, null, prompt) ) if (optional && !chooser.getController().confirmAction(sa, null, prompt, null) )
continue; continue;
final Zone originZone = game.getZoneOf(gameCard); final Zone originZone = game.getZoneOf(gameCard);
@@ -911,7 +911,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
sb.append(sa.getParam("AlternativeMessage")).append(" "); sb.append(sa.getParam("AlternativeMessage")).append(" ");
sb.append(altFetchList.size()).append(" " + Localizer.getInstance().getMessage("lblCardMatchSearchingTypeInAlternateZones")); sb.append(altFetchList.size()).append(" " + Localizer.getInstance().getMessage("lblCardMatchSearchingTypeInAlternateZones"));
if (!decider.getController().confirmAction(sa, PlayerActionConfirmMode.ChangeZoneFromAltSource, sb.toString())) { if (!decider.getController().confirmAction(sa, PlayerActionConfirmMode.ChangeZoneFromAltSource, sb.toString(), null)) {
origin = alt; origin = alt;
} }
} }
@@ -923,7 +923,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append(sa.getParam("AlternativeDestinationMessage")); sb.append(sa.getParam("AlternativeDestinationMessage"));
if (!decider.getController().confirmAction(sa, PlayerActionConfirmMode.ChangeZoneToAltDestination, sb.toString())) { if (!decider.getController().confirmAction(sa, PlayerActionConfirmMode.ChangeZoneToAltDestination, sb.toString(), null)) {
destination = ZoneType.smartValueOf(sa.getParam("DestinationAlternative")); destination = ZoneType.smartValueOf(sa.getParam("DestinationAlternative"));
libraryPos = sa.hasParam("LibraryPositionAlternative") ? Integer.parseInt(sa.getParam("LibraryPositionAlternative")) : 0; libraryPos = sa.hasParam("LibraryPositionAlternative") ? Integer.parseInt(sa.getParam("LibraryPositionAlternative")) : 0;
} }
@@ -941,7 +941,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
prompt = Localizer.getInstance().getMessage("lblSearchPlayerZoneConfirm", "{player's}", Lang.joinHomogenous(origin, ZoneType.Accessors.GET_TRANSLATED_NAME).toLowerCase()); prompt = Localizer.getInstance().getMessage("lblSearchPlayerZoneConfirm", "{player's}", Lang.joinHomogenous(origin, ZoneType.Accessors.GET_TRANSLATED_NAME).toLowerCase());
} }
String message = MessageUtil.formatMessage(prompt , decider, player); String message = MessageUtil.formatMessage(prompt , decider, player);
if (!decider.getController().confirmAction(sa, PlayerActionConfirmMode.ChangeZoneGeneral, message)) { if (!decider.getController().confirmAction(sa, PlayerActionConfirmMode.ChangeZoneGeneral, message, null)) {
return; return;
} }
} }
@@ -1024,7 +1024,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
continue; continue;
} }
SpellAbility tgtSA = decider.getController().getAbilityToPlay(tgtCard, sas); SpellAbility tgtSA = decider.getController().getAbilityToPlay(tgtCard, sas);
if (!decider.getController().confirmAction(tgtSA, null, Localizer.getInstance().getMessage("lblDoYouWantPlayCard", CardTranslation.getTranslatedName(tgtCard.getName())))) { if (!decider.getController().confirmAction(tgtSA, null, Localizer.getInstance().getMessage("lblDoYouWantPlayCard", CardTranslation.getTranslatedName(tgtCard.getName())), null)) {
continue; continue;
} }
tgtSA.setSVar("IsCastFromPlayEffect", "True"); tgtSA.setSVar("IsCastFromPlayEffect", "True");
@@ -1133,7 +1133,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
final int num = Math.min(fetchList.size(), changeNum - i); final int num = Math.min(fetchList.size(), changeNum - i);
String message = Localizer.getInstance().getMessage("lblCancelSearchUpToSelectNumCards", String.valueOf(num)); String message = Localizer.getInstance().getMessage("lblCancelSearchUpToSelectNumCards", String.valueOf(num));
if (fetchList.isEmpty() || decider.getController().confirmAction(sa, PlayerActionConfirmMode.ChangeZoneGeneral, message)) { if (fetchList.isEmpty() || decider.getController().confirmAction(sa, PlayerActionConfirmMode.ChangeZoneGeneral, message, null)) {
break; break;
} }
i--; i--;

View File

@@ -166,7 +166,7 @@ public class CharmEffect extends SpellAbilityEffect {
} }
boolean isOptional = sa.hasParam("Optional"); boolean isOptional = sa.hasParam("Optional");
if (isOptional && !activator.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblWouldYouLikeCharm", CardTranslation.getTranslatedName(source.getName())))) { if (isOptional && !activator.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblWouldYouLikeCharm", CardTranslation.getTranslatedName(source.getName())), null)) {
return false; return false;
} }

View File

@@ -101,7 +101,7 @@ public class ChooseCardEffect extends SpellAbilityEffect {
Localizer.getInstance().getMessage("lblSelectCreatureWithTotalPowerLessOrEqualTo", (totP - chosenP - negativeNum)) Localizer.getInstance().getMessage("lblSelectCreatureWithTotalPowerLessOrEqualTo", (totP - chosenP - negativeNum))
+ "\r\n(" + Localizer.getInstance().getMessage("lblSelected") + ":" + chosenPool + ")\r\n(" + Localizer.getInstance().getMessage("lblTotalPowerNum", chosenP) + ")", chosenP <= totP, null); + "\r\n(" + Localizer.getInstance().getMessage("lblSelected") + ":" + chosenPool + ")\r\n(" + Localizer.getInstance().getMessage("lblTotalPowerNum", chosenP) + ")", chosenP <= totP, null);
if (c == null) { if (c == null) {
if (p.getController().confirmAction(sa, PlayerActionConfirmMode.OptionalChoose, Localizer.getInstance().getMessage("lblCancelChooseConfirm"))) { if (p.getController().confirmAction(sa, PlayerActionConfirmMode.OptionalChoose, Localizer.getInstance().getMessage("lblCancelChooseConfirm"), null)) {
break; break;
} }
} else { } else {

View File

@@ -105,7 +105,7 @@ public class CloneEffect extends SpellAbilityEffect {
} }
final boolean optional = sa.hasParam("Optional"); final boolean optional = sa.hasParam("Optional");
if (optional && !host.getController().getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantCopy", CardTranslation.getTranslatedName(cardToCopy.getName())))) { if (optional && !host.getController().getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantCopy", CardTranslation.getTranslatedName(cardToCopy.getName())), null)) {
return; return;
} }

View File

@@ -90,7 +90,7 @@ public class ControlExchangeEffect extends SpellAbilityEffect {
if (!sa.getActivatingPlayer().getController().confirmAction(sa, null, if (!sa.getActivatingPlayer().getController().confirmAction(sa, null,
Localizer.getInstance().getMessage("lblExchangeControl", Localizer.getInstance().getMessage("lblExchangeControl",
CardTranslation.getTranslatedName(object1.getName()), CardTranslation.getTranslatedName(object1.getName()),
CardTranslation.getTranslatedName(object2.getName())))) { CardTranslation.getTranslatedName(object2.getName())), null)) {
return; return;
} }
} }

View File

@@ -60,7 +60,7 @@ public class CopyPermanentEffect extends TokenEffectBase {
final Game game = host.getGame(); final Game game = host.getGame();
if (sa.hasParam("Optional")) { if (sa.hasParam("Optional")) {
if (!activator.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblCopyPermanentConfirm"))) { if (!activator.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblCopyPermanentConfirm"), null)) {
return; return;
} }
} }
@@ -150,7 +150,7 @@ public class CopyPermanentEffect extends TokenEffectBase {
if (choosen != null) { if (choosen != null) {
tgtCards.add(choosen); tgtCards.add(choosen);
choices = CardLists.filter(choices, Predicates.not(CardPredicates.sharesNameWith(choosen))); choices = CardLists.filter(choices, Predicates.not(CardPredicates.sharesNameWith(choosen)));
} else if (chooser.getController().confirmAction(sa, PlayerActionConfirmMode.OptionalChoose, Localizer.getInstance().getMessage("lblCancelChooseConfirm"))) { } else if (chooser.getController().confirmAction(sa, PlayerActionConfirmMode.OptionalChoose, Localizer.getInstance().getMessage("lblCancelChooseConfirm"), null)) {
break; break;
} }
} }

View File

@@ -88,7 +88,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
SpellAbility chosenSA = controller.getController().chooseSingleSpellForEffect(tgtSpells, sa, SpellAbility chosenSA = controller.getController().chooseSingleSpellForEffect(tgtSpells, sa,
Localizer.getInstance().getMessage("lblSelectASpellCopy"), ImmutableMap.of()); Localizer.getInstance().getMessage("lblSelectASpellCopy"), ImmutableMap.of());
if (isOptional && !controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoyouWantCopyTheSpell", CardTranslation.getTranslatedName(chosenSA.getHostCard().getName())))) { if (isOptional && !controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoyouWantCopyTheSpell", CardTranslation.getTranslatedName(chosenSA.getHostCard().getName())), null)) {
continue; continue;
} }

View File

@@ -192,7 +192,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
} }
if (sa.hasParam("Optional") && !pc.confirmAction if (sa.hasParam("Optional") && !pc.confirmAction
(sa, null, Localizer.getInstance().getMessage("lblDoYouWantPutCounter"))) { (sa, null, Localizer.getInstance().getMessage("lblDoYouWantPutCounter"), null)) {
return; return;
} }
@@ -327,7 +327,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
String message = Localizer.getInstance().getMessage("lblDoYouWantPutTargetP1P1CountersOnCard", String.valueOf(counterAmount), CardTranslation.getTranslatedName(gameCard.getName())); String message = Localizer.getInstance().getMessage("lblDoYouWantPutTargetP1P1CountersOnCard", String.valueOf(counterAmount), CardTranslation.getTranslatedName(gameCard.getName()));
Player chooser = pc.chooseSingleEntityForEffect(activator.getOpponents(), sa, Localizer.getInstance().getMessage("lblChooseAnOpponent"), params); Player chooser = pc.chooseSingleEntityForEffect(activator.getOpponents(), sa, Localizer.getInstance().getMessage("lblChooseAnOpponent"), params);
if (chooser.getController().confirmAction(sa, PlayerActionConfirmMode.Tribute, message)) { if (chooser.getController().confirmAction(sa, PlayerActionConfirmMode.Tribute, message, null)) {
gameCard.setTributed(true); gameCard.setTributed(true);
} else { } else {
continue; continue;

View File

@@ -87,7 +87,7 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
if (sa.hasParam("Optional")) { if (sa.hasParam("Optional")) {
String ctrs = cntToRemove > 1 ? Localizer.getInstance().getMessage("lblCounters") : num.equals("All") ? Localizer.getInstance().getMessage("lblAllCounters") : Localizer.getInstance().getMessage("lblACounters"); String ctrs = cntToRemove > 1 ? Localizer.getInstance().getMessage("lblCounters") : num.equals("All") ? Localizer.getInstance().getMessage("lblAllCounters") : Localizer.getInstance().getMessage("lblACounters");
if (!sa.getActivatingPlayer().getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblRemove") + " " + ctrs + "?")) { if (!sa.getActivatingPlayer().getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblRemove") + " " + ctrs + "?", null)) {
return; return;
} }
} }

View File

@@ -152,7 +152,7 @@ public class DamageDealEffect extends DamageBaseEffect {
List<GameObject> tgts = getTargets(sa); List<GameObject> tgts = getTargets(sa);
if (sa.hasParam("OptionalDecider")) { if (sa.hasParam("OptionalDecider")) {
Player decider = Iterables.getFirst(AbilityUtils.getDefinedPlayers(hostCard, sa.getParam("OptionalDecider"), sa), null); Player decider = Iterables.getFirst(AbilityUtils.getDefinedPlayers(hostCard, sa.getParam("OptionalDecider"), sa), null);
if (decider != null && !decider.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoyouWantDealTargetDamageToTarget", String.valueOf(dmg), tgts.toString()))) { if (decider != null && !decider.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoyouWantDealTargetDamageToTarget", String.valueOf(dmg), tgts.toString()), null)) {
return; return;
} }
} }

View File

@@ -130,7 +130,7 @@ public class DigEffect extends SpellAbilityEffect {
else if (sa.hasParam("RevealOptional")) { else if (sa.hasParam("RevealOptional")) {
String question = TextUtil.concatWithSpace(Localizer.getInstance().getMessage("lblReveal") + ":", TextUtil.addSuffix(Lang.joinHomogenous(top),"?")); String question = TextUtil.concatWithSpace(Localizer.getInstance().getMessage("lblReveal") + ":", TextUtil.addSuffix(Lang.joinHomogenous(top),"?"));
hasRevealed = p.getController().confirmAction(sa, null, question); hasRevealed = p.getController().confirmAction(sa, null, question, null);
if (hasRevealed) { if (hasRevealed) {
game.getAction().reveal(top, p); game.getAction().reveal(top, p);
} }
@@ -208,7 +208,7 @@ public class DigEffect extends SpellAbilityEffect {
// Optional abilities that use a dialog box to prompt the user to skip the ability (e.g. Explorer's Scope, Quest for Ula's Temple) // Optional abilities that use a dialog box to prompt the user to skip the ability (e.g. Explorer's Scope, Quest for Ula's Temple)
if (optional && mayBeSkipped && !valid.isEmpty()) { if (optional && mayBeSkipped && !valid.isEmpty()) {
String prompt = !optionalAbilityPrompt.isEmpty() ? optionalAbilityPrompt : Localizer.getInstance().getMessage("lblWouldYouLikeProceedWithOptionalAbility") + " " + sa.getHostCard() + "?\n\n(" + sa.getDescription() + ")"; String prompt = !optionalAbilityPrompt.isEmpty() ? optionalAbilityPrompt : Localizer.getInstance().getMessage("lblWouldYouLikeProceedWithOptionalAbility") + " " + sa.getHostCard() + "?\n\n(" + sa.getDescription() + ")";
if (!p.getController().confirmAction(sa, null, TextUtil.fastReplace(prompt, "CARDNAME", CardTranslation.getTranslatedName(sa.getHostCard().getName())))) { if (!p.getController().confirmAction(sa, null, TextUtil.fastReplace(prompt, "CARDNAME", CardTranslation.getTranslatedName(sa.getHostCard().getName())), null)) {
return; return;
} }
} }

View File

@@ -119,7 +119,7 @@ public class DigUntilEffect extends SpellAbilityEffect {
continue; continue;
} }
if (!sa.usesTargeting() || p.canBeTargetedBy(sa)) { if (!sa.usesTargeting() || p.canBeTargetedBy(sa)) {
if (optional && !p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantDigYourLibrary"))) { if (optional && !p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantDigYourLibrary"), null)) {
continue; continue;
} }
CardCollection found = new CardCollection(); CardCollection found = new CardCollection();
@@ -171,7 +171,7 @@ public class DigUntilEffect extends SpellAbilityEffect {
final Card c = itr.next(); final Card c = itr.next();
final ZoneType origin = c.getZone().getZoneType(); final ZoneType origin = c.getZone().getZoneType();
if (optionalFound && !p.getController().confirmAction(sa, null, if (optionalFound && !p.getController().confirmAction(sa, null,
Localizer.getInstance().getMessage("lblDoYouWantPutCardToZone", foundDest.getTranslatedName()))) { Localizer.getInstance().getMessage("lblDoYouWantPutCardToZone", foundDest.getTranslatedName()), null)) {
continue; continue;
} else { } else {
Card m = null; Card m = null;

View File

@@ -140,7 +140,7 @@ public class DiscardEffect extends SpellAbilityEffect {
} }
boolean runDiscard = !sa.hasParam("Optional") boolean runDiscard = !sa.hasParam("Optional")
|| p.getController().confirmAction(sa, PlayerActionConfirmMode.Random, sa.getParam("DiscardMessage")); || p.getController().confirmAction(sa, PlayerActionConfirmMode.Random, sa.getParam("DiscardMessage"), null);
if (runDiscard) { if (runDiscard) {
toBeDiscarded = AbilityUtils.getDefinedCards(source, sa.getParam("DefinedCards"), sa); toBeDiscarded = AbilityUtils.getDefinedCards(source, sa.getParam("DefinedCards"), sa);
@@ -182,7 +182,7 @@ public class DiscardEffect extends SpellAbilityEffect {
continue; continue;
} }
String message = Localizer.getInstance().getMessage("lblWouldYouLikeRandomDiscardTargetCard", String.valueOf(numCards)); String message = Localizer.getInstance().getMessage("lblWouldYouLikeRandomDiscardTargetCard", String.valueOf(numCards));
boolean runDiscard = !sa.hasParam("Optional") || p.getController().confirmAction(sa, PlayerActionConfirmMode.Random, message); boolean runDiscard = !sa.hasParam("Optional") || p.getController().confirmAction(sa, PlayerActionConfirmMode.Random, message, null);
if (runDiscard) { if (runDiscard) {
final String valid = sa.hasParam("DiscardValid") ? sa.getParam("DiscardValid") : "Card"; final String valid = sa.hasParam("DiscardValid") ? sa.getParam("DiscardValid") : "Card";

View File

@@ -50,7 +50,7 @@ public class DrawEffect extends SpellAbilityEffect {
for (final Player p : getDefinedPlayersOrTargeted(sa)) { for (final Player p : getDefinedPlayersOrTargeted(sa)) {
if ((tgt == null) || p.canBeTargetedBy(sa)) if ((tgt == null) || p.canBeTargetedBy(sa))
if (optional && !p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantDrawCards", Lang.nounWithAmount(numCards, " card")))) if (optional && !p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantDrawCards", Lang.nounWithAmount(numCards, " card")), null))
continue; continue;
int actualNum = numCards; int actualNum = numCards;

View File

@@ -46,7 +46,7 @@ public class EncodeEffect extends SpellAbilityEffect {
// Handle choice of whether or not to encoded // Handle choice of whether or not to encoded
if (!player.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantExileCardAndEncodeOntoYouCreature", CardTranslation.getTranslatedName(host.getName())))) { if (!player.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantExileCardAndEncodeOntoYouCreature", CardTranslation.getTranslatedName(host.getName())), null)) {
return; return;
} }

View File

@@ -26,7 +26,7 @@ public class EndTurnEffect extends SpellAbilityEffect {
final List<Player> enders = getDefinedPlayersOrTargeted(sa, "Defined"); final List<Player> enders = getDefinedPlayersOrTargeted(sa, "Defined");
final Player ender = enders.isEmpty() ? sa.getActivatingPlayer() : enders.get(0); final Player ender = enders.isEmpty() ? sa.getActivatingPlayer() : enders.get(0);
if (sa.hasParam("Optional")) { if (sa.hasParam("Optional")) {
if (!ender.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantEndTurn"))) { if (!ender.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantEndTurn"), null)) {
return; return;
} }
} }

View File

@@ -63,7 +63,7 @@ public class FightEffect extends DamageBaseEffect {
Player controller = host.getController(); Player controller = host.getController();
boolean isOptional = sa.hasParam("Optional"); boolean isOptional = sa.hasParam("Optional");
if (isOptional && !controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblWouldYouLikeFight", CardTranslation.getTranslatedName(fighters.get(0).getName()), CardTranslation.getTranslatedName(fighters.get(1).getName())))) { if (isOptional && !controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblWouldYouLikeFight", CardTranslation.getTranslatedName(fighters.get(0).getName()), CardTranslation.getTranslatedName(fighters.get(1).getName())), null)) {
return; return;
} else { } else {
dealDamage(sa, fighters.get(0), fighters.get(1)); dealDamage(sa, fighters.get(0), fighters.get(1));

View File

@@ -41,7 +41,7 @@ public class ManaEffect extends SpellAbilityEffect {
final boolean optional = sa.hasParam("Optional"); final boolean optional = sa.hasParam("Optional");
final Game game = sa.getActivatingPlayer().getGame(); final Game game = sa.getActivatingPlayer().getGame();
if (optional && !sa.getActivatingPlayer().getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantAddMana"))) { if (optional && !sa.getActivatingPlayer().getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantAddMana"), null)) {
return; return;
} }

View File

@@ -40,7 +40,7 @@ public class MillEffect extends SpellAbilityEffect {
if (!sa.usesTargeting() || p.canBeTargetedBy(sa)) { if (!sa.usesTargeting() || p.canBeTargetedBy(sa)) {
if (sa.hasParam("Optional")) { if (sa.hasParam("Optional")) {
final String prompt = TextUtil.concatWithSpace(Localizer.getInstance().getMessage("lblDoYouWantPutLibraryCardsTo", destination.getTranslatedName())); final String prompt = TextUtil.concatWithSpace(Localizer.getInstance().getMessage("lblDoYouWantPutLibraryCardsTo", destination.getTranslatedName()));
if (!p.getController().confirmAction(sa, null, prompt)) { if (!p.getController().confirmAction(sa, null, prompt, null)) {
continue; continue;
} }
} }

View File

@@ -61,7 +61,7 @@ public class PeekAndRevealEffect extends SpellAbilityEffect {
} }
if( doReveal && sa.hasParam("RevealOptional") ) if( doReveal && sa.hasParam("RevealOptional") )
doReveal = peekingPlayer.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblRevealCardToOtherPlayers")); doReveal = peekingPlayer.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblRevealCardToOtherPlayers"), null);
if (doReveal) { if (doReveal) {
peekingPlayer.getGame().getAction().reveal(revealableCards, peekingPlayer); peekingPlayer.getGame().getAction().reveal(revealableCards, peekingPlayer);

View File

@@ -2,6 +2,7 @@ package forge.game.ability.effects;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -10,6 +11,7 @@ import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import forge.GameCommand; import forge.GameCommand;
import forge.StaticData; import forge.StaticData;
@@ -40,10 +42,6 @@ import forge.util.Lang;
import forge.util.Localizer; import forge.util.Localizer;
public class PlayEffect extends SpellAbilityEffect { public class PlayEffect extends SpellAbilityEffect {
private Card tgtCard;
public Card getTgtCard() { return tgtCard; }
@Override @Override
protected String getStackDescription(final SpellAbility sa) { protected String getStackDescription(final SpellAbility sa) {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
@@ -185,7 +183,7 @@ public class PlayEffect extends SpellAbilityEffect {
final CardCollection saidNoTo = new CardCollection(); final CardCollection saidNoTo = new CardCollection();
while (tgtCards.size() > saidNoTo.size() && saidNoTo.size() < amount && amount > 0) { while (tgtCards.size() > saidNoTo.size() && saidNoTo.size() < amount && amount > 0) {
activator.getController().tempShowCards(showCards); activator.getController().tempShowCards(showCards);
tgtCard = controller.getController().chooseSingleEntityForEffect(tgtCards, sa, Localizer.getInstance().getMessage("lblSelectCardToPlay"), null); Card tgtCard = controller.getController().chooseSingleEntityForEffect(tgtCards, sa, Localizer.getInstance().getMessage("lblSelectCardToPlay"), null);
activator.getController().endTempShowCards(); activator.getController().endTempShowCards();
if (tgtCard == null) { if (tgtCard == null) {
break; break;
@@ -203,7 +201,9 @@ public class PlayEffect extends SpellAbilityEffect {
game.getAction().revealTo(tgtCard, activator); game.getAction().revealTo(tgtCard, activator);
} }
if (optional && !controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantPlayCard", CardTranslation.getTranslatedName(tgtCard.getName())))) { Map<String, Object> params = Maps.newHashMap();
params.put("Card", tgtCard);
if (optional && !controller.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantPlayCard", CardTranslation.getTranslatedName(tgtCard.getName())), params)) {
if (wasFaceDown) { if (wasFaceDown) {
tgtCard.turnFaceDownNoUpdate(); tgtCard.turnFaceDownNoUpdate();
} }

View File

@@ -341,7 +341,7 @@ public class PumpEffect extends SpellAbilityEffect {
? TextUtil.fastReplace(sa.getParam("OptionQuestion"), "TARGETS", targets) ? TextUtil.fastReplace(sa.getParam("OptionQuestion"), "TARGETS", targets)
: Localizer.getInstance().getMessage("lblApplyPumpToTarget", targets); : Localizer.getInstance().getMessage("lblApplyPumpToTarget", targets);
if (!sa.getActivatingPlayer().getController().confirmAction(sa, null, message)) { if (!sa.getActivatingPlayer().getController().confirmAction(sa, null, message, null)) {
return; return;
} }
} }

View File

@@ -117,7 +117,7 @@ public class RearrangeTopOfLibraryEffect extends SpellAbilityEffect {
Card next = orderedCards.get(i); Card next = orderedCards.get(i);
player.getGame().getAction().moveToLibrary(next, 0, sa); player.getGame().getAction().moveToLibrary(next, 0, sa);
} }
if (mayshuffle && activator.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoyouWantShuffleTheLibrary"))) { if (mayshuffle && activator.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoyouWantShuffleTheLibrary"), null)) {
player.shuffle(sa); player.shuffle(sa);
} }
} }

View File

@@ -145,7 +145,7 @@ public class RepeatEachEffect extends SpellAbilityEffect {
} }
} }
for (final Player p : repeatPlayers) { for (final Player p : repeatPlayers) {
if (optional && !p.getController().confirmAction(repeat, null, sa.getParam("RepeatOptionalMessage"))) { if (optional && !p.getController().confirmAction(repeat, null, sa.getParam("RepeatOptionalMessage"), null)) {
continue; continue;
} }
if (nextTurn) { if (nextTurn) {

View File

@@ -121,7 +121,7 @@ public class RepeatEffect extends SpellAbilityEffect {
Player decider = sa.hasParam("RepeatOptionalDecider") Player decider = sa.hasParam("RepeatOptionalDecider")
? AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("RepeatOptionalDecider"), sa).get(0) ? AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("RepeatOptionalDecider"), sa).get(0)
: sa.getActivatingPlayer(); : sa.getActivatingPlayer();
return decider.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantRepeatProcessAgain")); return decider.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantRepeatProcessAgain"), null);
} }
return true; return true;

View File

@@ -42,7 +42,7 @@ public class RevealHandEffect extends SpellAbilityEffect {
for (final Player p : getTargetPlayers(sa)) { for (final Player p : getTargetPlayers(sa)) {
if ((tgt == null) || p.canBeTargetedBy(sa)) { if ((tgt == null) || p.canBeTargetedBy(sa)) {
if (optional && !p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantRevealYourHand"))) { if (optional && !p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantRevealYourHand"), null)) {
continue; continue;
} }
final CardCollectionView hand = p.getCardsIn(ZoneType.Hand); final CardCollectionView hand = p.getCardsIn(ZoneType.Hand);

View File

@@ -41,7 +41,7 @@ public class SacrificeEffect extends SpellAbilityEffect {
if (sa.hasParam("Echo")) { if (sa.hasParam("Echo")) {
boolean isPaid; boolean isPaid;
if (activator.hasKeyword("You may pay 0 rather than pay the echo cost for permanents you control.") if (activator.hasKeyword("You may pay 0 rather than pay the echo cost for permanents you control.")
&& activator.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantPayEcho") + " {0}?")) { && activator.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantPayEcho") + " {0}?", null)) {
isPaid = true; isPaid = true;
} else { } else {
isPaid = activator.getController().payManaOptional(card, new Cost(sa.getParam("Echo"), true), isPaid = activator.getController().payManaOptional(card, new Cost(sa.getParam("Echo"), true),
@@ -128,7 +128,7 @@ public class SacrificeEffect extends SpellAbilityEffect {
if (sa.hasParam("Random")) { if (sa.hasParam("Random")) {
choosenToSacrifice = Aggregates.random(validTargets, Math.min(amount, validTargets.size()), new CardCollection()); choosenToSacrifice = Aggregates.random(validTargets, Math.min(amount, validTargets.size()), new CardCollection());
} else if (sa.hasParam("OptionalSacrifice") && !p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantSacrifice"))) { } else if (sa.hasParam("OptionalSacrifice") && !p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantSacrifice"), null)) {
choosenToSacrifice = CardCollection.EMPTY; choosenToSacrifice = CardCollection.EMPTY;
} else { } else {
boolean isOptional = sa.hasParam("Optional"); boolean isOptional = sa.hasParam("Optional");

View File

@@ -43,7 +43,7 @@ public class ScryEffect extends SpellAbilityEffect {
// Optional here for spells that have optional multi-player scrying // Optional here for spells that have optional multi-player scrying
for (final Player p : getTargetPlayers(sa)) { for (final Player p : getTargetPlayers(sa)) {
if ( (!sa.usesTargeting() || p.canBeTargetedBy(sa)) && if ( (!sa.usesTargeting() || p.canBeTargetedBy(sa)) &&
(!isOptional || p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWanttoScry"))) ) { (!isOptional || p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWanttoScry"), null)) ) {
players.add(p); players.add(p);
} }
} }

View File

@@ -128,7 +128,7 @@ public class SetStateEffect extends SpellAbilityEffect {
if (optional) { if (optional) {
String message = TextUtil.concatWithSpace("Transform", gameCard.getName(), "?"); String message = TextUtil.concatWithSpace("Transform", gameCard.getName(), "?");
if (!p.getController().confirmAction(sa, PlayerActionConfirmMode.Random, message)) { if (!p.getController().confirmAction(sa, PlayerActionConfirmMode.Random, message, null)) {
return; return;
} }
} }

View File

@@ -21,7 +21,7 @@ public class ShuffleEffect extends SpellAbilityEffect {
for (final Player p : tgtPlayers) { for (final Player p : tgtPlayers) {
if ((tgt == null) || p.canBeTargetedBy(sa)) { if ((tgt == null) || p.canBeTargetedBy(sa)) {
boolean mustShuffle = !optional || sa.getActivatingPlayer().getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblHaveTargetShuffle", p.getName())); boolean mustShuffle = !optional || sa.getActivatingPlayer().getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblHaveTargetShuffle", p.getName()), null);
if (mustShuffle) if (mustShuffle)
p.shuffle(sa); p.shuffle(sa);
} }

View File

@@ -34,7 +34,7 @@ public class SurveilEffect extends SpellAbilityEffect {
for (final Player p : getTargetPlayers(sa)) { for (final Player p : getTargetPlayers(sa)) {
if (!sa.usesTargeting() || p.canBeTargetedBy(sa)) { if (!sa.usesTargeting() || p.canBeTargetedBy(sa)) {
if (isOptional && !p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantSurveil"))) { if (isOptional && !p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantSurveil"), null)) {
continue; continue;
} }

View File

@@ -769,7 +769,7 @@ public class Combat {
"defending player and/or any number of creatures they control.") "defending player and/or any number of creatures they control.")
&& attacker.getController().getController().confirmAction(null, null, && attacker.getController().getController().confirmAction(null, null,
Localizer.getInstance().getMessage("lblAssignCombatDamageAsChoose", Localizer.getInstance().getMessage("lblAssignCombatDamageAsChoose",
CardTranslation.getTranslatedName(attacker.getName())))); CardTranslation.getTranslatedName(attacker.getName())), null));
boolean trampler = attacker.hasKeyword(Keyword.TRAMPLE); boolean trampler = attacker.hasKeyword(Keyword.TRAMPLE);
orderedBlockers = blockersOrderedForDamageAssignment.get(attacker); orderedBlockers = blockersOrderedForDamageAssignment.get(attacker);
if (divideCombatDamageAsChoose) { if (divideCombatDamageAsChoose) {

View File

@@ -132,7 +132,7 @@ public abstract class PlayerController {
public abstract <T extends GameEntity> List<T> chooseEntitiesForEffect(FCollectionView<T> optionList, int min, int max, DelayedReveal delayedReveal, SpellAbility sa, String title, Player relatedPlayer, Map<String, Object> params); public abstract <T extends GameEntity> List<T> chooseEntitiesForEffect(FCollectionView<T> optionList, int min, int max, DelayedReveal delayedReveal, SpellAbility sa, String title, Player relatedPlayer, Map<String, Object> params);
public abstract boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message); public abstract boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params);
public abstract boolean confirmBidAction(SpellAbility sa, PlayerActionConfirmMode bidlife, String string, int bid, Player winner); public abstract boolean confirmBidAction(SpellAbility sa, PlayerActionConfirmMode bidlife, String string, int bid, Player winner);
public abstract boolean confirmStaticApplication(Card hostCard, GameEntity affected, String logic, String message); public abstract boolean confirmStaticApplication(Card hostCard, GameEntity affected, String logic, String message);
public abstract boolean confirmTrigger(WrappedAbility sa); public abstract boolean confirmTrigger(WrappedAbility sa);

View File

@@ -197,7 +197,7 @@ public class PlayerControllerForTests extends PlayerController {
} }
@Override @Override
public boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message) { public boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
return true; return true;
} }

View File

@@ -103,7 +103,7 @@ public class HumanPlaySpellAbility {
} }
final boolean playerManaConversion = human.hasManaConversion() final boolean playerManaConversion = human.hasManaConversion()
&& human.getController().confirmAction(ability, null, "Do you want to spend mana as though it were mana of any color to pay the cost?"); && human.getController().confirmAction(ability, null, "Do you want to spend mana as though it were mana of any color to pay the cost?", null);
Cost abCost = ability.getPayCosts(); Cost abCost = ability.getPayCosts();
CostPayment payment = new CostPayment(abCost, ability); CostPayment payment = new CostPayment(abCost, ability);

View File

@@ -679,7 +679,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
* SpellAbility, java.lang.String, java.lang.String) * SpellAbility, java.lang.String, java.lang.String)
*/ */
@Override @Override
public boolean confirmAction(final SpellAbility sa, final PlayerActionConfirmMode mode, final String message) { public boolean confirmAction(final SpellAbility sa, final PlayerActionConfirmMode mode, final String message, Map<String, Object> params) {
if (sa != null && sa.getHostCard() != null && sa.hasParam("ShowCardInPrompt")) { if (sa != null && sa.getHostCard() != null && sa.hasParam("ShowCardInPrompt")) {
// The card wants another thing displayed in the prompt on mouse over rather than itself // The card wants another thing displayed in the prompt on mouse over rather than itself
Card show = null; Card show = null;