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