mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
TriggerExiled: make new Trigger for exile keyword action for Soulherder
This commit is contained in:
committed by
Michael Kamensky
parent
f3ba20452d
commit
244fa13961
@@ -700,8 +700,23 @@ public class GameAction {
|
||||
if (game.isCardExiled(c)) {
|
||||
return c;
|
||||
}
|
||||
|
||||
final Zone origin = c.getZone();
|
||||
final PlayerZone removed = c.getOwner().getZone(ZoneType.Exile);
|
||||
return moveTo(removed, c, cause, params);
|
||||
final Card copied = moveTo(removed, c, cause, params);
|
||||
|
||||
// Run triggers
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Card", c);
|
||||
runParams.put("Cause", cause);
|
||||
runParams.put("Origin", origin.getZoneType().name());
|
||||
if (params != null) {
|
||||
runParams.putAll(params);
|
||||
}
|
||||
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Exiled, runParams, false);
|
||||
|
||||
return copied;
|
||||
}
|
||||
|
||||
public final Card moveTo(final ZoneType name, final Card c, SpellAbility cause) {
|
||||
|
||||
109
forge-game/src/main/java/forge/game/trigger/TriggerExiled.java
Normal file
109
forge-game/src/main/java/forge/game/trigger/TriggerExiled.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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 forge.game.card.Card;
|
||||
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Trigger_ChangesZone class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class TriggerExiled extends Trigger {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for TriggerExiled.
|
||||
* </p>
|
||||
*
|
||||
* @param params
|
||||
* a {@link java.util.Map} object.
|
||||
* @param host
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param intrinsic
|
||||
* the intrinsic
|
||||
*/
|
||||
public TriggerExiled(final 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 (hasParam("Origin")) {
|
||||
if (!getParam("Origin").equals("Any")) {
|
||||
if (getParam("Origin") == null) {
|
||||
return false;
|
||||
}
|
||||
if (!ArrayUtils.contains(
|
||||
getParam("Origin").split(","), runParams2.get("Origin")
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasParam("ValidCard")) {
|
||||
Card moved = (Card) runParams2.get("Card");
|
||||
|
||||
if (!moved.isValid(getParam("ValidCard").split(","), getHostCard().getController(),
|
||||
getHostCard(), null)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasParam("ValidCause")) {
|
||||
if (!runParams2.containsKey("Cause") ) {
|
||||
return false;
|
||||
}
|
||||
SpellAbility cause = (SpellAbility) runParams2.get("Cause");
|
||||
if (cause == null) {
|
||||
return false;
|
||||
}
|
||||
if (!cause.getHostCard().isValid(getParam("ValidCause").split(","), getHostCard().getController(),
|
||||
getHostCard(), null)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void setTriggeringObjects(final SpellAbility sa) {
|
||||
sa.setTriggeringObject("Card", this.getRunParams().get("Card"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImportantStackObjects(SpellAbility sa) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Exiled: ").append(sa.getTriggeringObject("Card"));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,6 +53,7 @@ public enum TriggerType {
|
||||
Drawn(TriggerDrawn.class),
|
||||
Evolved(TriggerEvolved.class),
|
||||
Exerted(TriggerExerted.class),
|
||||
Exiled(TriggerExiled.class),
|
||||
Exploited(TriggerExploited.class),
|
||||
Explores(TriggerExplores.class),
|
||||
Fight(TriggerFight.class),
|
||||
|
||||
@@ -2,7 +2,7 @@ Name:Soulherder
|
||||
ManaCost:1 W U
|
||||
Types:Creature Spirit
|
||||
PT:1/1
|
||||
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Exile | ValidCard$ Creature | TriggerZones$ Battlefield | Execute$ TrigPutCounter | TriggerDescription$ Whenever a creature is exiled from the battlefield, put a +1/+1 counter on CARDNAME.
|
||||
T:Mode$ Exiled | Origin$ Battlefield | ValidCard$ Creature | TriggerZones$ Battlefield | Execute$ TrigPutCounter | TriggerDescription$ Whenever a creature is exiled from the battlefield, put a +1/+1 counter on CARDNAME.
|
||||
SVar:TrigPutCounter:DB$PutCounter | Defined$ Self | CounterType$ P1P1 | CounterNum$ 1
|
||||
SVar:PlayMain1:TRUE
|
||||
T:Mode$ Phase | Phase$ End of Turn | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ ConjurerExile | OptionalDecider$ You | TriggerDescription$ At the beginning of your end step, you may exile another target creature you control, then return it to the battlefield under its owner's control.
|
||||
|
||||
Reference in New Issue
Block a user