mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Add trigger that triggers once for each block made, and fix Dead-Iron Sledge by using it.
This should actually be used by any card with "Whenever this blocks/becomes blocked by a creature, ..."
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -583,6 +583,7 @@ forge-game/src/main/java/forge/game/trigger/Trigger.java svneol=native#text/plai
|
||||
forge-game/src/main/java/forge/game/trigger/TriggerAlways.java svneol=native#text/plain
|
||||
forge-game/src/main/java/forge/game/trigger/TriggerAttached.java -text
|
||||
forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java svneol=native#text/plain
|
||||
forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlockedByCreature.java -text
|
||||
forge-game/src/main/java/forge/game/trigger/TriggerAttackerUnblocked.java svneol=native#text/plain
|
||||
forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java svneol=native#text/plain
|
||||
forge-game/src/main/java/forge/game/trigger/TriggerAttacks.java svneol=native#text/plain
|
||||
|
||||
@@ -650,6 +650,14 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
runParams.put("Blockers", blockers);
|
||||
runParams.put("NumBlockers", blockers.size());
|
||||
game.getTriggerHandler().runTrigger(TriggerType.AttackerBlocked, runParams, false);
|
||||
|
||||
// Run this trigger once for each blocker
|
||||
for (final Card b : blockers) {
|
||||
final HashMap<String, Object> runParams2 = new HashMap<String, Object>();
|
||||
runParams2.put("Attacker", a);
|
||||
runParams2.put("Blocker", b);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.AttackerBlockedByCreature, runParams2, false);
|
||||
}
|
||||
|
||||
if (!a.getDamageHistory().getCreatureGotBlockedThisCombat()) {
|
||||
// Bushido
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.game.trigger;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Trigger_AttackerBlocked class. Should trigger once for each blocking creature.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id: TriggerAttackerBlocked.java 24769 2014-02-09 13:56:04Z Hellfish $
|
||||
*/
|
||||
public class TriggerAttackerBlockedByCreature extends Trigger {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for Trigger_AttackerBlocked.
|
||||
* </p>
|
||||
*
|
||||
* @param params
|
||||
* a {@link java.util.HashMap} object.
|
||||
* @param host
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param intrinsic
|
||||
* the intrinsic
|
||||
*/
|
||||
public TriggerAttackerBlockedByCreature(final java.util.Map<String, String> params, final Card host, final boolean intrinsic) {
|
||||
super(params, host, intrinsic);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final boolean performTest(final Map<String, Object> runParams2) {
|
||||
if (this.mapParams.containsKey("ValidCard")) {
|
||||
if (!matchesValid(runParams2.get("Attacker"), this.mapParams.get("ValidCard").split(","),
|
||||
this.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (this.mapParams.containsKey("ValidBlocker")) {
|
||||
final Object o = runParams2.get("Blocker");
|
||||
if (!matchesValid(o, this.mapParams.get("ValidBlocker").split(","), this.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void setTriggeringObjects(final SpellAbility sa) {
|
||||
sa.setTriggeringObject("Attacker", this.getRunParams().get("Attacker"));
|
||||
sa.setTriggeringObject("Blocker", this.getRunParams().get("Blocker"));
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public enum TriggerType {
|
||||
Always(TriggerAlways.class),
|
||||
Attached(TriggerAttached.class),
|
||||
AttackerBlocked(TriggerAttackerBlocked.class),
|
||||
AttackerBlockedByCreature(TriggerAttackerBlockedByCreature.class),
|
||||
AttackersDeclared(TriggerAttackersDeclared.class),
|
||||
AttackerUnblocked(TriggerAttackerUnblocked.class),
|
||||
Attacks(TriggerAttacks.class),
|
||||
|
||||
@@ -2,8 +2,9 @@ Name:Dead-Iron Sledge
|
||||
ManaCost:1
|
||||
Types:Artifact Equipment
|
||||
K:Equip 2
|
||||
T:Mode$ AttackerBlocked | ValidCard$ Creature | ValidBlocker$ Creature.AttachedBy | TriggerZones$ Battlefield | Execute$ TrigDestroy | TriggerDescription$ Whenever equipped creature blocks or becomes blocked by a creature, destroy both creatures.
|
||||
T:Mode$ Blocks | ValidCard$ Creature | ValidBlocked$ Creature.AttachedBy | TriggerZones$ Battlefield | Execute$ TrigDestroy | Secondary$ True | TriggerDescription$ Whenever equipped creature blocks or becomes blocked by a creature, destroy both creatures.
|
||||
T:Mode$ AttackerBlockedByCreature | ValidCard$ Creature | ValidBlocker$ Creature.AttachedBy | TriggerZones$ Battlefield | Execute$ TrigDestroy | TriggerDescription$ Whenever equipped creature blocks or becomes blocked by a creature, destroy both creatures.
|
||||
T:Mode$ AttackerBlockedByCreature | ValidCard$ Creature.AttachedBy | ValidBlocker$ Creature | TriggerZones$ Battlefield | Execute$ TrigDestroy | TriggerDescription$ Whenever equipped creature blocks or becomes blocked by a creature, destroy both creatures.
|
||||
#T:Mode$ Blocks | ValidCard$ Creature | ValidBlocked$ Creature.AttachedBy | TriggerZones$ Battlefield | Execute$ TrigDestroy | Secondary$ True | TriggerDescription$ Whenever equipped creature blocks or becomes blocked by a creature, destroy both creatures.
|
||||
SVar:TrigDestroy:AB$Destroy | Cost$ 0 | Defined$ TriggeredAttacker | SubAbility$ DBDestroy
|
||||
SVar:DBDestroy:DB$Destroy | Defined$ TriggeredBlocker
|
||||
SVar:RemAIDeck:True
|
||||
|
||||
Reference in New Issue
Block a user