Commit f6134e3c authored by Ryan Wiedemann's avatar Ryan Wiedemann

update `canReplace` method

parent a3355ba0
Pipeline #1775 passed with stage
......@@ -13,6 +13,7 @@ import forge.card.mana.ManaCostParser;
import forge.card.mana.ManaCostShard;
import forge.game.Game;
import forge.game.GameActionUtil;
import forge.game.ability.AbilityKey;
import forge.game.ability.AbilityUtils;
import forge.game.ability.ApiType;
import forge.game.card.*;
......@@ -1408,11 +1409,11 @@ public class ComputerUtilMana {
AbilityManaPart mp = m.getManaPart();
// setup produce mana replacement effects
final Map<String, Object> repParams = new HashMap<>();
repParams.put("Mana", mp.getOrigProduced());
repParams.put("Affected", sourceCard);
repParams.put("Player", ai);
repParams.put("AbilityMana", m);
final Map<AbilityKey, Object> repParams = AbilityKey.newMap();
repParams.put(AbilityKey.Mana, mp.getOrigProduced());
repParams.put(AbilityKey.Affected, sourceCard);
repParams.put(AbilityKey.Player, ai);
repParams.put(AbilityKey.AbilityMana, m);
for (final ReplacementEffect replacementEffect : replacementEffects) {
if (replacementEffect.canReplace(repParams)) {
......
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.card.CounterType;
import forge.game.player.Player;
......@@ -27,20 +28,20 @@ public class ReplaceAddCounter extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
if (((int) runParams.get("CounterNum")) <= 0) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
if (((int) runParams.get(AbilityKey.CounterNum)) <= 0) {
return false;
}
if (hasParam("EffectOnly")) {
final Boolean effectOnly = (Boolean) runParams.get("EffectOnly");
final Boolean effectOnly = (Boolean) runParams.get(AbilityKey.EffectOnly);
if (!effectOnly) {
return false;
}
}
if (hasParam("ValidCard")) {
Object o = runParams.get("Affected");
Object o = runParams.get(AbilityKey.Affected);
if (!(o instanceof Card)) {
return false;
}
......@@ -48,7 +49,7 @@ public class ReplaceAddCounter extends ReplacementEffect {
return false;
}
} else if (hasParam("ValidPlayer")) {
Object o = runParams.get("Affected");
Object o = runParams.get(AbilityKey.Affected);
if (!(o instanceof Player)) {
return false;
}
......@@ -59,7 +60,7 @@ public class ReplaceAddCounter extends ReplacementEffect {
if (hasParam("ValidCounterType")) {
String type = getParam("ValidCounterType");
if (CounterType.getType(type) != runParams.get("CounterType")) {
if (CounterType.getType(type) != runParams.get(AbilityKey.CounterType)) {
return false;
}
}
......
......@@ -17,6 +17,7 @@
*/
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.spellability.SpellAbility;
......@@ -42,15 +43,15 @@ public class ReplaceCounter extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
final SpellAbility spellAbility = (SpellAbility) runParams.get("TgtSA");
public boolean canReplace(Map<AbilityKey, Object> runParams) {
final SpellAbility spellAbility = (SpellAbility) runParams.get(AbilityKey.TgtSA);
if (hasParam("ValidCard")) {
if (!matchesValid(runParams.get("Affected"), getParam("ValidCard").split(","), this.getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Affected), getParam("ValidCard").split(","), this.getHostCard())) {
return false;
}
}
if (hasParam("ValidCause")) {
if (!matchesValid(runParams.get("Cause"), getParam("ValidCause").split(","), this.getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Cause), getParam("ValidCause").split(","), this.getHostCard())) {
return false;
}
}
......
......@@ -17,6 +17,7 @@
*/
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.ability.AbilityUtils;
import forge.game.card.Card;
import forge.game.card.CardFactoryUtil;
......@@ -46,49 +47,49 @@ public class ReplaceDamage extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
if (!(runParams.containsKey("Prevention") == (hasParam("PreventionEffect") || hasParam("Prevent")))) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
if (!(runParams.containsKey(AbilityKey.Prevention) == (hasParam("PreventionEffect") || hasParam("Prevent")))) {
return false;
}
if (((Integer) runParams.get("DamageAmount")) == 0) {
if (((Integer) runParams.get(AbilityKey.DamageAmount)) == 0) {
// If no actual damage is dealt, there is nothing to replace
return false;
}
if (hasParam("ValidSource")) {
String validSource = getParam("ValidSource");
validSource = AbilityUtils.applyAbilityTextChangeEffects(validSource, this);
if (!matchesValid(runParams.get("DamageSource"), validSource.split(","), getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.DamageSource), validSource.split(","), getHostCard())) {
return false;
}
}
if (hasParam("ValidTarget")) {
String validTarget = getParam("ValidTarget");
validTarget = AbilityUtils.applyAbilityTextChangeEffects(validTarget, this);
if (!matchesValid(runParams.get("Affected"), validTarget.split(","), getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Affected), validTarget.split(","), getHostCard())) {
return false;
}
}
if (hasParam("ValidCause")) {
if (!runParams.containsKey("Cause")) {
if (!runParams.containsKey(AbilityKey.Cause)) {
return false;
}
SpellAbility cause = (SpellAbility) runParams.get("Cause");
SpellAbility cause = (SpellAbility) runParams.get(AbilityKey.Cause);
String validCause = getParam("ValidCause");
validCause = AbilityUtils.applyAbilityTextChangeEffects(validCause, this);
if (!matchesValid(cause, validCause.split(","), getHostCard())) {
return false;
}
if (hasParam("CauseIsSource")) {
if (!cause.getHostCard().equals(runParams.get("DamageSource"))) {
if (!cause.getHostCard().equals(runParams.get(AbilityKey.DamageSource))) {
return false;
}
}
}
if (hasParam("RelativeToSource")) {
Card source = (Card) runParams.get("DamageSource");
Card source = (Card) runParams.get(AbilityKey.DamageSource);
String validRelative = getParam("RelativeToSource");
validRelative = AbilityUtils.applyAbilityTextChangeEffects(validRelative, this);
if (!matchesValid(runParams.get("DamageTarget"), validRelative.split(","), source)) {
if (!matchesValid(runParams.get(AbilityKey.DamageTarget), validRelative.split(","), source)) {
return false;
}
}
......@@ -103,17 +104,17 @@ public class ReplaceDamage extends ReplacementEffect {
intoperand = CardFactoryUtil.xCount(getHostCard(), getHostCard().getSVar(operand));
}
if (!Expressions.compare((Integer) runParams.get("DamageAmount"), operator, intoperand)) {
if (!Expressions.compare((Integer) runParams.get(AbilityKey.DamageAmount), operator, intoperand)) {
return false;
}
}
if (hasParam("IsCombat")) {
if (getParam("IsCombat").equals("True")) {
if (!((Boolean) runParams.get("IsCombat"))) {
if (!((Boolean) runParams.get(AbilityKey.IsCombat))) {
return false;
}
} else {
if ((Boolean) runParams.get("IsCombat")) {
if ((Boolean) runParams.get(AbilityKey.IsCombat)) {
return false;
}
}
......
......@@ -17,6 +17,7 @@
*/
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.spellability.SpellAbility;
......@@ -42,23 +43,23 @@ public class ReplaceDestroy extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
if (hasParam("ValidPlayer")) {
if (!matchesValid(runParams.get("Affected"), getParam("ValidPlayer").split(","), getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Affected), getParam("ValidPlayer").split(","), getHostCard())) {
return false;
}
}
if (hasParam("ValidCard")) {
Card card = (Card)runParams.get("Card");
Card card = (Card)runParams.get(AbilityKey.Card);
if (!matchesValid(card, getParam("ValidCard").split(","), getHostCard())) {
return false;
}
// extra check for Regeneration
if (hasParam("Regeneration")) {
if (!runParams.containsKey("Regeneration")) {
if (!runParams.containsKey(AbilityKey.Regeneration)) {
return false;
}
if (!(Boolean)runParams.get("Regeneration")) {
if (!(Boolean)runParams.get(AbilityKey.Regeneration)) {
return false;
}
if (!card.canBeShielded()) {
......@@ -71,7 +72,7 @@ public class ReplaceDestroy extends ReplacementEffect {
}
}
if (hasParam("ValidSource")) {
if (!matchesValid(runParams.get("Source"), getParam("ValidSource").split(","), getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Source), getParam("ValidSource").split(","), getHostCard())) {
return false;
}
}
......
......@@ -17,6 +17,7 @@
*/
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.spellability.SpellAbility;
......@@ -42,24 +43,24 @@ public class ReplaceDiscard extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
if (hasParam("ValidPlayer")) {
if (!matchesValid(runParams.get("Affected"), getParam("ValidPlayer").split(","), this.getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Affected), getParam("ValidPlayer").split(","), this.getHostCard())) {
return false;
}
}
if (hasParam("ValidCard")) {
if (!matchesValid(runParams.get("Card"), getParam("ValidCard").split(","), this.getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Card), getParam("ValidCard").split(","), this.getHostCard())) {
return false;
}
}
if (hasParam("ValidSource")) {
if (!matchesValid(runParams.get("Source"), getParam("ValidSource").split(","), this.getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Source), getParam("ValidSource").split(","), this.getHostCard())) {
return false;
}
}
if (hasParam("DiscardFromEffect")) {
if (null == runParams.get("Source")) {
if (null == runParams.get(AbilityKey.Source)) {
return false;
}
}
......
......@@ -17,6 +17,7 @@
*/
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.phase.PhaseType;
import forge.game.player.Player;
......@@ -44,14 +45,14 @@ public class ReplaceDraw extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
if (hasParam("ValidPlayer")) {
if (!matchesValid(runParams.get("Affected"), getParam("ValidPlayer").split(","), this.getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Affected), getParam("ValidPlayer").split(","), this.getHostCard())) {
return false;
}
}
if (hasParam("NotFirstCardInDrawStep")) {
final Player p = (Player)runParams.get("Affected");
final Player p = (Player)runParams.get(AbilityKey.Affected);
if (p.numDrawnThisDrawStep() == 0
&& this.getHostCard().getGame().getPhaseHandler().is(PhaseType.DRAW)
&& this.getHostCard().getGame().getPhaseHandler().isPlayerTurn(p)) {
......
......@@ -17,6 +17,7 @@
*/
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.spellability.SpellAbility;
import forge.util.Expressions;
......@@ -43,14 +44,14 @@ public class ReplaceDrawCards extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
if (hasParam("ValidPlayer")) {
if (!matchesValid(runParams.get("Affected"), getParam("ValidPlayer").split(","), this.getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Affected), getParam("ValidPlayer").split(","), this.getHostCard())) {
return false;
}
}
if (hasParam("Number")) {
final int n = (Integer)runParams.get("Number");
final int n = (Integer)runParams.get(AbilityKey.Number);
String comparator = getParam("Number");
final String operator = comparator.substring(0, 2);
final int operandValue = Integer.parseInt(comparator.substring(2));
......
......@@ -17,6 +17,7 @@
*/
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.spellability.SpellAbility;
......@@ -42,22 +43,22 @@ public class ReplaceGainLife extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
if (((int)runParams.get("LifeGained")) <= 0) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
if (((int)runParams.get(AbilityKey.LifeGained)) <= 0) {
return false;
}
if (hasParam("ValidPlayer")) {
if (!matchesValid(runParams.get("Affected"), getParam("ValidPlayer").split(","), this.getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Affected), getParam("ValidPlayer").split(","), this.getHostCard())) {
return false;
}
}
if (hasParam("ValidSource")) {
if (!matchesValid(runParams.get("Source"), getParam("ValidSource").split(","), this.getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Source), getParam("ValidSource").split(","), this.getHostCard())) {
return false;
}
}
if ("True".equals(getParam("SourceController"))) {
if (runParams.get("Source") == null || !runParams.get("Affected").equals(((Card)runParams.get("Source")).getController())) {
if (runParams.get(AbilityKey.Source) == null || !runParams.get(AbilityKey.Affected).equals(((Card)runParams.get(AbilityKey.Source)).getController())) {
return false;
}
}
......
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import java.util.Map;
......@@ -24,9 +25,9 @@ public class ReplaceGameLoss extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
if (hasParam("ValidPlayer")) {
if (!matchesValid(runParams.get("Affected"), getParam("ValidPlayer").split(","), this.getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Affected), getParam("ValidPlayer").split(","), this.getHostCard())) {
return false;
}
}
......
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.player.Player;
......@@ -28,9 +29,9 @@ public class ReplaceMoved extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
final Player controller = getHostCard().getController();
final Card affected = (Card) runParams.get("Affected");
final Card affected = (Card) runParams.get(AbilityKey.Affected);
if (hasParam("ValidCard")) {
if (!matchesValid(affected, getParam("ValidCard").split(","), getHostCard())) {
......@@ -39,27 +40,27 @@ public class ReplaceMoved extends ReplacementEffect {
}
if (hasParam("ValidLKI")) {
if (!matchesValid(runParams.get("CardLKI"), getParam("ValidLKI").split(","), getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.CardLKI), getParam("ValidLKI").split(","), getHostCard())) {
return false;
}
}
if (hasParam("Origin")) {
ZoneType zt = (ZoneType) runParams.get("Origin");
ZoneType zt = (ZoneType) runParams.get(AbilityKey.Origin);
if (!ZoneType.listValueOf(getParam("Origin")).contains(zt)) {
return false;
}
}
if (hasParam("Destination")) {
ZoneType zt = (ZoneType) runParams.get("Destination");
ZoneType zt = (ZoneType) runParams.get(AbilityKey.Destination);
if (!ZoneType.listValueOf(getParam("Destination")).contains(zt)) {
return false;
}
}
if (hasParam("ExcludeDestination")) {
ZoneType zt = (ZoneType) runParams.get("Destination");
ZoneType zt = (ZoneType) runParams.get(AbilityKey.Destination);
if (ZoneType.listValueOf(getParam("ExcludeDestination")).contains(zt)) {
return false;
}
......@@ -67,29 +68,29 @@ public class ReplaceMoved extends ReplacementEffect {
if (hasParam("Fizzle")) {
// if Replacement look for Fizzle
if (!runParams.containsKey("Fizzle")) {
if (!runParams.containsKey(AbilityKey.Fizzle)) {
return false;
}
Boolean val = (Boolean) runParams.get("Fizzle");
Boolean val = (Boolean) runParams.get(AbilityKey.Fizzle);
if ("True".equals(getParam("Fizzle")) != val) {
return false;
}
}
if (hasParam("ValidStackSa")) {
if (!runParams.containsKey("StackSa")) {
if (!runParams.containsKey(AbilityKey.StackSa)) {
return false;
}
if (!((SpellAbility)runParams.get("StackSa")).isValid(getParam("ValidStackSa").split(","), getHostCard().getController(), getHostCard(), null)) {
if (!((SpellAbility)runParams.get(AbilityKey.StackSa)).isValid(getParam("ValidStackSa").split(","), getHostCard().getController(), getHostCard(), null)) {
return false;
}
}
if (hasParam("Cause")) {
if (!runParams.containsKey("Cause")) {
if (!runParams.containsKey(AbilityKey.Cause)) {
return false;
}
SpellAbility cause = (SpellAbility) runParams.get("Cause");
SpellAbility cause = (SpellAbility) runParams.get(AbilityKey.Cause);
if (cause == null) {
return false;
}
......@@ -99,8 +100,8 @@ public class ReplaceMoved extends ReplacementEffect {
}
if (hasParam("NotCause")) {
if (runParams.containsKey("Cause")) {
SpellAbility cause = (SpellAbility) runParams.get("Cause");
if (runParams.containsKey(AbilityKey.Cause)) {
SpellAbility cause = (SpellAbility) runParams.get(AbilityKey.Cause);
if (cause != null) {
if (cause.isValid(getParam("NotCause").split(","), controller, getHostCard(), null)) {
return false;
......
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.card.CardFactoryUtil;
import forge.game.spellability.SpellAbility;
......@@ -29,10 +30,10 @@ public class ReplaceProduceMana extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
//Check for tapping
if (!hasParam("NoTapCheck")) {
final SpellAbility manaAbility = (SpellAbility) runParams.get("AbilityMana");
final SpellAbility manaAbility = (SpellAbility) runParams.get(AbilityKey.AbilityMana);
if (manaAbility == null || manaAbility.getRootAbility().getPayCosts() == null || !manaAbility.getRootAbility().getPayCosts().hasTapCost()) {
return false;
}
......@@ -48,14 +49,14 @@ public class ReplaceProduceMana extends ReplacementEffect {
} catch (NumberFormatException e) {
intoperand = CardFactoryUtil.xCount(getHostCard(), getHostCard().getSVar(operand));
}
int manaAmount = StringUtils.countMatches((String) runParams.get("Mana"), " ") + 1;
int manaAmount = StringUtils.countMatches((String) runParams.get(AbilityKey.Mana), " ") + 1;
if (!Expressions.compare(manaAmount, operator, intoperand)) {
return false;
}
}
if (hasParam("ValidCard")) {
if (!matchesValid(runParams.get("Affected"), getParam("ValidCard").split(","), this.getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Affected), getParam("ValidCard").split(","), this.getHostCard())) {
return false;
}
}
......
......@@ -17,6 +17,7 @@
*/
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import java.util.Map;
......@@ -41,9 +42,9 @@ public class ReplaceSetInMotion extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
if (hasParam("ValidPlayer")) {
if (!matchesValid(runParams.get("Affected"), getParam("ValidPlayer").split(","), getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Affected), getParam("ValidPlayer").split(","), getHostCard())) {
return false;
}
}
......
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.spellability.SpellAbility;
......@@ -25,13 +26,13 @@ public class ReplaceSurveil extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.Map)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
if (((int) runParams.get("SurveilNum")) <= 0) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
if (((int) runParams.get(AbilityKey.SurveilNum)) <= 0) {
return false;
}
if (hasParam("ValidPlayer")) {
if (!matchesValid(runParams.get("Affected"), getParam("ValidPlayer").split(","), this.getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Affected), getParam("ValidPlayer").split(","), this.getHostCard())) {
return false;
}
}
......
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.spellability.SpellAbility;
......@@ -25,27 +26,27 @@ public class ReplaceToken extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.Map)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
if (((int) runParams.get("TokenNum")) <= 0) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
if (((int) runParams.get(AbilityKey.TokenNum)) <= 0) {
return false;
}
if (hasParam("EffectOnly")) {
final Boolean effectOnly = (Boolean) runParams.get("EffectOnly");
final Boolean effectOnly = (Boolean) runParams.get(AbilityKey.EffectOnly);
if (!effectOnly) {
return false;
}
}
if (hasParam("ValidPlayer")) {
if (!matchesValid(runParams.get("Affected"), getParam("ValidPlayer").split(","), getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Affected), getParam("ValidPlayer").split(","), getHostCard())) {
return false;
}
}
if (hasParam("ValidToken")) {
if (runParams.containsKey("Token")) {
if (!matchesValid(runParams.get("Token"), getParam("ValidToken").split(","), getHostCard())) {
if (runParams.containsKey(AbilityKey.Token)) {
if (!matchesValid(runParams.get(AbilityKey.Token), getParam("ValidToken").split(","), getHostCard())) {
return false;
}
} else {
......
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.spellability.SpellAbility;
......@@ -25,9 +26,9 @@ public class ReplaceTurnFaceUp extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
if (hasParam("ValidCard")) {
if (!matchesValid(runParams.get("Affected"), getParam("ValidCard").split(","), this.getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Affected), getParam("ValidCard").split(","), this.getHostCard())) {
return false;
}
}
......
......@@ -17,6 +17,7 @@
*/
package forge.game.replacement;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.player.Player;
import forge.game.phase.PhaseType;
......@@ -44,14 +45,14 @@ public class ReplaceUntap extends ReplacementEffect {
* @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap)
*/
@Override
public boolean canReplace(Map<String, Object> runParams) {
public boolean canReplace(Map<AbilityKey, Object> runParams) {
if (hasParam("ValidCard")) {
if (!matchesValid(runParams.get("Affected"), getParam("ValidCard").split(","), this.getHostCard())) {
if (!matchesValid(runParams.get(AbilityKey.Affected), getParam("ValidCard").split(","), this.getHostCard())) {
return false;
}
}
if (hasParam("UntapStep")) {
final Object o = runParams.get("Affected");
final Object o = runParams.get(AbilityKey.Affected);
//normally should not happen, but protect from possible crash.
if (!(o instanceof Card)) {
return false;
......
......@@ -19,6 +19,7 @@ package forge.game.replacement;
import forge.game.Game;
import forge.game.TriggerReplacementBase;
import forge.game.ability.AbilityKey;
import forge.game.ability.AbilityUtils;
import forge.game.card.Card;
import forge.game.phase.PhaseType;
......@@ -121,7 +122,7 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
* the run params
* @return true, if successful
*/
public abstract boolean canReplace(final Map<String, Object> runParams);
public abstract boolean canReplace (final Map<AbilityKey, Object> runParams);