mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
add mapFromAffected convenience function
This commit is contained in:
@@ -2850,8 +2850,7 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
// Run any applicable replacement effects.
|
||||
final Map<AbilityKey, Object> repParams = AbilityKey.newMap();
|
||||
repParams.put(AbilityKey.Affected, player);
|
||||
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(player);
|
||||
repParams.put(AbilityKey.LifeGained, 1);
|
||||
repParams.put(AbilityKey.Source, source);
|
||||
|
||||
@@ -2881,8 +2880,7 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
// Run any applicable replacement effects.
|
||||
final Map<AbilityKey, Object> repParams = AbilityKey.newMap();
|
||||
repParams.put(AbilityKey.Affected, player);
|
||||
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(player);
|
||||
repParams.put(AbilityKey.LifeGained, n);
|
||||
repParams.put(AbilityKey.Source, source);
|
||||
|
||||
|
||||
@@ -2584,8 +2584,7 @@ public class ComputerUtilCombat {
|
||||
final Game game = attacker.getGame();
|
||||
|
||||
// first try to replace the damage
|
||||
final Map<AbilityKey, Object> repParams = AbilityKey.newMap();
|
||||
repParams.put(AbilityKey.Affected, target);
|
||||
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(target);
|
||||
repParams.put(AbilityKey.DamageSource, attacker);
|
||||
repParams.put(AbilityKey.DamageAmount, damage);
|
||||
repParams.put(AbilityKey.IsCombat, true);
|
||||
|
||||
@@ -98,8 +98,7 @@ public class ManifestAi extends SpellAbilityAi {
|
||||
topCopy.turnFaceDownNoUpdate();
|
||||
topCopy.setManifested(true);
|
||||
|
||||
final Map<AbilityKey, Object> repParams = AbilityKey.newMap();
|
||||
repParams.put(AbilityKey.Affected, topCopy);
|
||||
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(topCopy);
|
||||
repParams.put(AbilityKey.Origin, card.getZone().getZoneType());
|
||||
repParams.put(AbilityKey.Destination, ZoneType.Battlefield);
|
||||
repParams.put(AbilityKey.Source, sa.getHostCard());
|
||||
|
||||
@@ -290,8 +290,7 @@ public class GameAction {
|
||||
copied.getOwner().addInboundToken(copied);
|
||||
}
|
||||
|
||||
Map<AbilityKey, Object> repParams = AbilityKey.newMap();
|
||||
repParams.put(AbilityKey.Affected, copied);
|
||||
Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(copied);
|
||||
repParams.put(AbilityKey.CardLKI, lastKnownInfo);
|
||||
repParams.put(AbilityKey.Cause, cause);
|
||||
repParams.put(AbilityKey.Origin, zoneFrom != null ? zoneFrom.getZoneType() : null);
|
||||
|
||||
@@ -3,6 +3,7 @@ package forge.game.ability;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.card.Card;
|
||||
|
||||
/**
|
||||
@@ -144,4 +145,11 @@ public enum AbilityKey {
|
||||
runParams.put(Card, card);
|
||||
return runParams;
|
||||
}
|
||||
|
||||
public static Map<AbilityKey, Object> mapFromAffected(GameEntity gameEntity) {
|
||||
final Map<AbilityKey, Object> runParams = newMap();
|
||||
|
||||
runParams.put(Affected, gameEntity);
|
||||
return runParams;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,9 +687,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|
||||
if (result && runTriggers) {
|
||||
// Run replacement effects
|
||||
Map<AbilityKey, Object> repParams = AbilityKey.newMap();
|
||||
repParams.put(AbilityKey.Affected, this);
|
||||
getGame().getReplacementHandler().run(ReplacementType.TurnFaceUp, repParams);
|
||||
getGame().getReplacementHandler().run(ReplacementType.TurnFaceUp, AbilityKey.mapFromAffected(this));
|
||||
|
||||
// Run triggers
|
||||
getGame().getTriggerHandler().registerActiveTrigger(this, false);
|
||||
|
||||
Reference in New Issue
Block a user