Commit a3b0d8ac authored by Ryan Wiedemann's avatar Ryan Wiedemann

do the remaining easy `repRunParams` changeovers

parent a9e97d65
......@@ -1395,13 +1395,12 @@ public class GameAction {
}
// Replacement effects
final Map<String, Object> repRunParams = Maps.newHashMap();
repRunParams.put("Source", sa);
repRunParams.put("Card", c);
repRunParams.put("Affected", c);
repRunParams.put("Regeneration", regenerate);
final Map<AbilityKey, Object> repRunParams = AbilityKey.mapFromCard(c);
repRunParams.put(AbilityKey.Source, sa);
repRunParams.put(AbilityKey.Affected, c);
repRunParams.put(AbilityKey.Regeneration, regenerate);
if (game.getReplacementHandler().runOld(ReplacementType.Destroy, repRunParams) != ReplacementResult.NotReplaced) {
if (game.getReplacementHandler().run(ReplacementType.Destroy, repRunParams) != ReplacementResult.NotReplaced) {
return false;
}
......
......@@ -115,25 +115,24 @@ public abstract class GameEntity extends GameObject implements IIdentifiable {
public int replaceDamage(final int damage, final Card source, final boolean isCombat, final boolean prevention,
final CardDamageMap damageMap, final CardDamageMap preventMap, GameEntityCounterTable counterTable, final SpellAbility cause) {
// Replacement effects
final Map<String, Object> repParams = Maps.newHashMap();
repParams.put("Affected", this);
repParams.put("DamageSource", source);
repParams.put("DamageAmount", damage);
repParams.put("IsCombat", isCombat);
repParams.put("NoPreventDamage", !prevention);
repParams.put("DamageMap", damageMap);
repParams.put("PreventMap", preventMap);
repParams.put("CounterTable", counterTable);
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(this);
repParams.put(AbilityKey.DamageSource, source);
repParams.put(AbilityKey.DamageAmount, damage);
repParams.put(AbilityKey.IsCombat, isCombat);
repParams.put(AbilityKey.NoPreventDamage, !prevention);
repParams.put(AbilityKey.DamageMap, damageMap);
repParams.put(AbilityKey.PreventMap, preventMap);
repParams.put(AbilityKey.CounterTable, counterTable);
if (cause != null) {
repParams.put("Cause", cause);
repParams.put(AbilityKey.Cause, cause);
}
switch (getGame().getReplacementHandler().runOld(ReplacementType.DamageDone, repParams)) {
switch (getGame().getReplacementHandler().run(ReplacementType.DamageDone, repParams)) {
case NotReplaced:
return damage;
case Updated:
int newDamage = (int) repParams.get("DamageAmount");
GameEntity newTarget = (GameEntity) repParams.get("Affected");
int newDamage = (int) repParams.get(AbilityKey.DamageAmount);
GameEntity newTarget = (GameEntity) repParams.get(AbilityKey.Affected);
// check if this is still the affected card or player
if (this.equals(newTarget)) {
return newDamage;
......@@ -170,23 +169,22 @@ public abstract class GameEntity extends GameObject implements IIdentifiable {
int restDamage = damage;
// first try to replace the damage
final Map<String, Object> repParams = Maps.newHashMap();
repParams.put("Affected", this);
repParams.put("DamageSource", source);
repParams.put("DamageAmount", damage);
repParams.put("IsCombat", isCombat);
repParams.put("Prevention", true);
repParams.put("PreventMap", preventMap);
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(this);
repParams.put(AbilityKey.DamageSource, source);
repParams.put(AbilityKey.DamageAmount, damage);
repParams.put(AbilityKey.IsCombat, isCombat);
repParams.put(AbilityKey.Prevention, true);
repParams.put(AbilityKey.PreventMap, preventMap);
if (cause != null) {
repParams.put("Cause", cause);
repParams.put(AbilityKey.Cause, cause);
}
switch (getGame().getReplacementHandler().runOld(ReplacementType.DamageDone, repParams)) {
switch (getGame().getReplacementHandler().run(ReplacementType.DamageDone, repParams)) {
case NotReplaced:
restDamage = damage;
break;
case Updated:
restDamage = (int) repParams.get("DamageAmount");
restDamage = (int) repParams.get(AbilityKey.DamageAmount);
break;
default:
restDamage = 0;
......
......@@ -38,12 +38,15 @@ public enum AbilityKey {
CostStack("CostStack"),
CounterAmount("CounterAmount"),
CounteredSA("CounteredSA"),
CounterNum("CounterNum"),
CounterTable("CounterTable"),
CounterType("CounterType"),
Crew("Crew"),
CumulativeUpkeepPaid("CumulativeUpkeepPaid"),
CurrentCastSpells("CurrentCastSpells"),
CurrentStormCount("CurrentStormCount"),
DamageAmount("DamageAmount"),
DamageMap("DamageMap"),
DamageSource("DamageSource"),
DamageSources("DamageSources"),
DamageTarget("DamageTarget"),
......@@ -54,6 +57,7 @@ public enum AbilityKey {
Destination("Destination"),
Devoured("Devoured"),
EchoPaid("EchoPaid"),
EffectOnly("EffectOnly"),
Exploited("Exploited"),
Explorer("Explorer"),
Event("Event"),
......@@ -66,8 +70,10 @@ public enum AbilityKey {
IsMadness("IsMadness"),
LifeAmount("LifeAmount"), //TODO confirm that this and LifeGained can be merged
LifeGained("LifeGained"),
Mana("Mana"),
MonstrosityAmount("MonstrosityAmount"),
NewCounterAmount("NewCounterAmount"),
NoPreventDamage("NoPreventDamage"),
Num("Num"), // TODO confirm that this and NumThisTurn can be merged
NumBlockers("NumBlockers"),
NumThisTurn("NumThisTurn"),
......@@ -82,8 +88,10 @@ public enum AbilityKey {
PayingMana("PayingMana"),
Phase("Phase"),
Player("Player"),
PreventMap("PreventMap"),
Prevention("Prevention"),
Produced("Produced"),
Regeneration("Regeneration"),
Result("Result"),
Scheme("Scheme"),
Source("Source"),
......@@ -95,8 +103,12 @@ public enum AbilityKey {
StackInstance("StackInstance"),
StackSa("StackSa"),
StackSi("StackSi"),
SurveilNum("SurveilNum"),
Target("Target"),
Targets("Targets"),
TgtSA("TgtSA"),
Token("Token"),
TokenNum("TokenNum"),
Transformer("Transformer"),
Vehicle("Vehicle"),
Won("Won");
......
......@@ -155,11 +155,10 @@ public class CounterEffect extends SpellAbilityEffect {
final SpellAbility srcSA, final SpellAbilityStackInstance si) {
final Game game = tgtSA.getActivatingPlayer().getGame();
// Run any applicable replacement effects.
final Map<String, Object> repParams = Maps.newHashMap();
repParams.put("TgtSA", tgtSA);
repParams.put("Affected", tgtSA.getHostCard());
repParams.put("Cause", srcSA.getHostCard());
if (game.getReplacementHandler().runOld(ReplacementType.Counter, repParams) != ReplacementResult.NotReplaced) {
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(tgtSA.getHostCard());
repParams.put(AbilityKey.TgtSA, tgtSA);
repParams.put(AbilityKey.Cause, srcSA.getHostCard());
if (game.getReplacementHandler().run(ReplacementType.Counter, repParams) != ReplacementResult.NotReplaced) {
return;
}
game.getStack().remove(si);
......
......@@ -1231,18 +1231,17 @@ public class Card extends GameEntity implements Comparable<Card> {
addAmount = 0; // As per rule 107.1b
return 0;
}
final Map<String, Object> repParams = Maps.newHashMap();
repParams.put("Affected", this);
repParams.put("Source", source);
repParams.put("CounterType", counterType);
repParams.put("CounterNum", addAmount);
repParams.put("EffectOnly", applyMultiplier);
switch (getGame().getReplacementHandler().runOld(ReplacementType.AddCounter, repParams)) {
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(this);
repParams.put(AbilityKey.Source, source);
repParams.put(AbilityKey.CounterType, counterType);
repParams.put(AbilityKey.CounterNum, addAmount);
repParams.put(AbilityKey.EffectOnly, applyMultiplier);
switch (getGame().getReplacementHandler().run(ReplacementType.AddCounter, repParams)) {
case NotReplaced:
break;
case Updated: {
addAmount = (int) repParams.get("CounterNum");
addAmount = (int) repParams.get(AbilityKey.CounterNum);
break;
}
default:
......@@ -3570,10 +3569,7 @@ public class Card extends GameEntity implements Comparable<Card> {
if (!tapped) { return; }
// Run Replacement effects
final Map<String, Object> repRunParams = Maps.newHashMap();
repRunParams.put("Affected", this);
if (getGame().getReplacementHandler().runOld(ReplacementType.Untap, repRunParams) != ReplacementResult.NotReplaced) {
if (getGame().getReplacementHandler().run(ReplacementType.Untap, AbilityKey.mapFromAffected(this)) != ReplacementResult.NotReplaced) {
return;
}
......
......@@ -9,6 +9,7 @@ import forge.StaticData;
import forge.card.CardType;
import forge.card.MagicColor;
import forge.game.Game;
import forge.game.ability.AbilityKey;
import forge.game.ability.AbilityUtils;
import forge.game.card.Card;
import forge.game.card.CardFactory;
......@@ -166,19 +167,18 @@ public class TokenInfo {
Player player = controller;
Card proto = prototype;
final Map<String, Object> repParams = Maps.newHashMap();
repParams.put("Affected", player);
repParams.put("Token", prototype);
repParams.put("TokenNum", multiplier);
repParams.put("EffectOnly", applyMultiplier);
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(player);
repParams.put(AbilityKey.Token, prototype);
repParams.put(AbilityKey.TokenNum, multiplier);
repParams.put(AbilityKey.EffectOnly, applyMultiplier);
switch (game.getReplacementHandler().runOld(ReplacementType.CreateToken, repParams)) {
switch (game.getReplacementHandler().run(ReplacementType.CreateToken, repParams)) {
case NotReplaced:
break;
case Updated: {
multiplier = (int) repParams.get("TokenNum");
player = (Player) repParams.get("Affected");
proto = (Card) repParams.get("Token");
multiplier = (int) repParams.get(AbilityKey.TokenNum);
player = (Player) repParams.get(AbilityKey.Affected);
proto = (Card) repParams.get(AbilityKey.Token);
break;
}
default:
......
......@@ -400,22 +400,21 @@ public class Player extends GameEntity implements Comparable<Player> {
public final boolean gainLife(int lifeGain, final Card source, final SpellAbility sa) {
// Run any applicable replacement effects.
final Map<String, Object> repParams = Maps.newHashMap();
repParams.put("Affected", this);
repParams.put("LifeGained", lifeGain);
repParams.put("Source", source);
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(this);
repParams.put(AbilityKey.LifeGained, lifeGain);
repParams.put(AbilityKey.Source, source);
if (!canGainLife()) {
return false;
}
switch (getGame().getReplacementHandler().runOld(ReplacementType.GainLife, repParams)) {
switch (getGame().getReplacementHandler().run(ReplacementType.GainLife, repParams)) {
case NotReplaced:
break;
case Updated:
// check if this is still the affected player
if (this.equals(repParams.get("Affected"))) {
lifeGain = (int) repParams.get("LifeGained");
if (this.equals(repParams.get(AbilityKey.Affected))) {
lifeGain = (int) repParams.get(AbilityKey.LifeGained);
// negative update means life loss
if (lifeGain < 0) {
this.loseLife(-lifeGain);
......@@ -911,18 +910,17 @@ public class Player extends GameEntity implements Comparable<Player> {
return 0;
}
final Map<String, Object> repParams = Maps.newHashMap();
repParams.put("Affected", this);
repParams.put("Source", source);
repParams.put("CounterType", counterType);
repParams.put("CounterNum", addAmount);
repParams.put("EffectOnly", applyMultiplier);
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(this);
repParams.put(AbilityKey.Source, source);
repParams.put(AbilityKey.CounterType, counterType);
repParams.put(AbilityKey.CounterNum, addAmount);
repParams.put(AbilityKey.EffectOnly, applyMultiplier);
switch (getGame().getReplacementHandler().runOld(ReplacementType.AddCounter, repParams)) {
switch (getGame().getReplacementHandler().run(ReplacementType.AddCounter, repParams)) {
case NotReplaced:
break;
case Updated: {
addAmount = (int) repParams.get("CounterNum");
addAmount = (int) repParams.get(AbilityKey.CounterNum);
break;
}
default:
......@@ -1273,16 +1271,15 @@ public class Player extends GameEntity implements Comparable<Player> {
public void surveil(int num, SpellAbility cause) {
final Map<String, Object> repParams = Maps.newHashMap();
repParams.put("Affected", this);
repParams.put("Source", cause);
repParams.put("SurveilNum", num);
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(this);
repParams.put(AbilityKey.Source, cause);
repParams.put(AbilityKey.SurveilNum, num);
switch (getGame().getReplacementHandler().runOld(ReplacementType.Surveil, repParams)) {
switch (getGame().getReplacementHandler().run(ReplacementType.Surveil, repParams)) {
case NotReplaced:
break;
case Updated: {
num = (int) repParams.get("SurveilNum");
num = (int) repParams.get(AbilityKey.SurveilNum);
break;
}
default:
......@@ -1343,11 +1340,10 @@ public class Player extends GameEntity implements Comparable<Player> {
final CardCollection toReveal = new CardCollection();
// Replacement effects
final Map<String, Object> repRunParams = Maps.newHashMap();
repRunParams.put("Affected", this);
repRunParams.put("Number", n);
final Map<AbilityKey, Object> repRunParams = AbilityKey.mapFromAffected(this);
repRunParams.put(AbilityKey.Number, n);
if (game.getReplacementHandler().runOld(ReplacementType.DrawCards, repRunParams) != ReplacementResult.NotReplaced) {
if (game.getReplacementHandler().run(ReplacementType.DrawCards, repRunParams) != ReplacementResult.NotReplaced) {
return drawn;
}
......@@ -1550,12 +1546,11 @@ public class Player extends GameEntity implements Comparable<Player> {
// that should not trigger other Replacement again
if (!discardToTopOfLibrary && !discardMadness) {
// Replacement effects
final Map<String, Object> repRunParams = Maps.newHashMap();
repRunParams.put("Card", c);
repRunParams.put("Source", source);
repRunParams.put("Affected", this);
final Map<AbilityKey, Object> repRunParams = AbilityKey.mapFromCard(c);
repRunParams.put(AbilityKey.Source, source);
repRunParams.put(AbilityKey.Affected, this);
if (game.getReplacementHandler().runOld(ReplacementType.Discard, repRunParams) != ReplacementResult.NotReplaced) {
if (game.getReplacementHandler().run(ReplacementType.Discard, repRunParams) != ReplacementResult.NotReplaced) {
return null;
}
}
......
......@@ -128,12 +128,11 @@ public class AbilityManaPart implements java.io.Serializable {
final Card source = this.getSourceCard();
final ManaPool manaPool = player.getManaPool();
String afterReplace = applyManaReplacement(sa, produced);
final Map<String, Object> repParams = Maps.newHashMap();
repParams.put("Mana", afterReplace);
repParams.put("Affected", source);
repParams.put("Player", player);
repParams.put("AbilityMana", sa);
if (player.getGame().getReplacementHandler().runOld(ReplacementType.ProduceMana, repParams) != ReplacementResult.NotReplaced) {
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(source);
repParams.put(AbilityKey.Mana, afterReplace);
repParams.put(AbilityKey.Player, player);
repParams.put(AbilityKey.AbilityMana, sa);
if (player.getGame().getReplacementHandler().run(ReplacementType.ProduceMana, repParams) != ReplacementResult.NotReplaced) {
return;
}
//clear lastProduced
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment