MCPcopy Create free account
hub / github.com/Card-Forge/forge / destroy

Method destroy

forge-game/src/main/java/forge/game/GameAction.java:2135–2169  ·  view source on GitHub ↗
(final Card c, final SpellAbility sa, final boolean regenerate, Map<AbilityKey, Object> params)

Source from the content-addressed store, hash-verified

2133 }
2134
2135 public final boolean destroy(final Card c, final SpellAbility sa, final boolean regenerate, Map<AbilityKey, Object> params) {
2136 if (!c.canBeDestroyed()) {
2137 return false;
2138 }
2139
2140 final Map<AbilityKey, Object> repRunParams = AbilityKey.mapFromAffected(c);
2141 repRunParams.put(AbilityKey.Cause, sa);
2142 repRunParams.put(AbilityKey.Regeneration, regenerate);
2143 if (params != null) {
2144 repRunParams.putAll(params);
2145 }
2146 if (game.getReplacementHandler().run(ReplacementType.Destroy, repRunParams) != ReplacementResult.NotReplaced) {
2147 return false;
2148 }
2149
2150 Player activator = null;
2151 if (sa != null) {
2152 activator = sa.getActivatingPlayer();
2153 }
2154
2155 //for animation
2156 c.updateWasDestroyed(true);
2157 // Play the Destroy sound
2158 game.fireEvent(new GameEventCardDestroyed());
2159
2160 final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(c);
2161 runParams.put(AbilityKey.Causer, activator);
2162 if (params != null) {
2163 runParams.putAll(params);
2164 }
2165 game.getTriggerHandler().runTrigger(TriggerType.Destroyed, runParams, false);
2166
2167 final Card sacrificed = sacrificeDestroy(c, sa, params);
2168 return sacrificed != null;
2169 }
2170
2171 /**
2172 * @return the sacrificed Card in its new location, or {@code null} if the

Callers 7

checkStateEffectsMethod · 0.95
internalDestroyMethod · 0.80
resolveMethod · 0.80
resolveMethod · 0.80
resolveMethod · 0.80
onPauseMethod · 0.80

Calls 13

mapFromAffectedMethod · 0.95
mapFromCardMethod · 0.95
sacrificeDestroyMethod · 0.95
canBeDestroyedMethod · 0.80
getReplacementHandlerMethod · 0.80
runTriggerMethod · 0.80
getTriggerHandlerMethod · 0.80
runMethod · 0.65
putMethod · 0.45
putAllMethod · 0.45
getActivatingPlayerMethod · 0.45
updateWasDestroyedMethod · 0.45

Tested by

no test coverage detected