mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Improve trigger
This commit is contained in:
@@ -17,13 +17,18 @@
|
|||||||
*/
|
*/
|
||||||
package forge.game.cost;
|
package forge.game.cost;
|
||||||
|
|
||||||
import forge.game.ability.AbilityFactory;
|
import java.util.Map;
|
||||||
import forge.game.ability.AbilityUtils;
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardCollectionView;
|
import forge.game.card.CardCollectionView;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
|
import forge.game.trigger.Trigger;
|
||||||
|
import forge.game.trigger.TriggerHandler;
|
||||||
|
import forge.game.trigger.TriggerType;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,10 +103,20 @@ public class CostExert extends CostPartWithList {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Card doPayment(SpellAbility ability, Card targetCard, final boolean effect) {
|
protected Card doPayment(SpellAbility ability, Card targetCard, final boolean effect) {
|
||||||
if (trigger != null) {
|
if (payingTrigSA != null) {
|
||||||
SpellAbility trig = AbilityFactory.getAbility(targetCard.getSVar(trigger), targetCard);
|
Map<String, String> mapParams = Maps.newHashMap();
|
||||||
trig.setActivatingPlayer(ability.getActivatingPlayer());
|
mapParams.put("TriggerDescription", payingTrigSA.getParam("SpellDescription"));
|
||||||
AbilityUtils.resolve(trig);
|
mapParams.put("Mode", TriggerType.Immediate.name());
|
||||||
|
|
||||||
|
SpellAbility sa = payingTrigSA.copy(targetCard, ability.getActivatingPlayer(), false);
|
||||||
|
|
||||||
|
final Trigger immediateTrig = TriggerHandler.parseTrigger(mapParams, targetCard, sa.isIntrinsic(), null);
|
||||||
|
immediateTrig.setSpawningAbility(ability); // make the StaticAbility the Spawning one?
|
||||||
|
|
||||||
|
immediateTrig.setOverridingAbility(sa);
|
||||||
|
|
||||||
|
// Instead of registering this, add to the delayed triggers as an immediate trigger type? Which means it'll fire as soon as possible
|
||||||
|
targetCard.getGame().getTriggerHandler().registerDelayedTrigger(immediateTrig);
|
||||||
}
|
}
|
||||||
targetCard.exert();
|
targetCard.exert();
|
||||||
return targetCard;
|
return targetCard;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public abstract class CostPart implements Comparable<CostPart>, Cloneable, Seria
|
|||||||
private final String originalType, originalTypeDescription;
|
private final String originalType, originalTypeDescription;
|
||||||
private String typeDescription, type;
|
private String typeDescription, type;
|
||||||
|
|
||||||
protected String trigger;
|
protected transient SpellAbility payingTrigSA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new cost part.
|
* Instantiates a new cost part.
|
||||||
@@ -156,8 +156,8 @@ public abstract class CostPart implements Comparable<CostPart>, Cloneable, Seria
|
|||||||
return AbilityUtils.calculateAmount(ability.getHostCard(), getAmount(), ability);
|
return AbilityUtils.calculateAmount(ability.getHostCard(), getAmount(), ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTrigger(String trig) {
|
public void setTrigger(SpellAbility sa) {
|
||||||
trigger = trig;
|
payingTrigSA = sa;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import forge.game.Game;
|
|||||||
import forge.game.GameEntity;
|
import forge.game.GameEntity;
|
||||||
import forge.game.GameStage;
|
import forge.game.GameStage;
|
||||||
import forge.game.IIdentifiable;
|
import forge.game.IIdentifiable;
|
||||||
|
import forge.game.ability.AbilityFactory;
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardCollection;
|
import forge.game.card.CardCollection;
|
||||||
@@ -41,6 +42,7 @@ import forge.game.cost.Cost;
|
|||||||
import forge.game.phase.PhaseHandler;
|
import forge.game.phase.PhaseHandler;
|
||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.zone.Zone;
|
import forge.game.zone.Zone;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.CardTranslation;
|
import forge.util.CardTranslation;
|
||||||
@@ -63,6 +65,8 @@ public class StaticAbility extends CardTraitBase implements IIdentifiable, Clone
|
|||||||
private final List<Player> ignoreEffectPlayers = Lists.newArrayList();
|
private final List<Player> ignoreEffectPlayers = Lists.newArrayList();
|
||||||
private int mayPlayTurn = 0;
|
private int mayPlayTurn = 0;
|
||||||
|
|
||||||
|
private SpellAbility payingTrigSA;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final int getId() {
|
public final int getId() {
|
||||||
return id;
|
return id;
|
||||||
@@ -78,6 +82,14 @@ public class StaticAbility extends CardTraitBase implements IIdentifiable, Clone
|
|||||||
return obj instanceof StaticAbility && this.id == ((StaticAbility) obj).id;
|
return obj instanceof StaticAbility && this.id == ((StaticAbility) obj).id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SpellAbility getPayingTrigSA() {
|
||||||
|
// already cached?
|
||||||
|
if (payingTrigSA == null) {
|
||||||
|
payingTrigSA = AbilityFactory.getAbility(getSVar(getParam("Trigger")), getHostCard());
|
||||||
|
}
|
||||||
|
return payingTrigSA;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Getter for the field <code>mapParams</code>.
|
* Getter for the field <code>mapParams</code>.
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ public class StaticAbilityCantAttackBlock {
|
|||||||
Cost cost = new Cost(costString, true);
|
Cost cost = new Cost(costString, true);
|
||||||
|
|
||||||
if (stAb.hasParam("Trigger")) {
|
if (stAb.hasParam("Trigger")) {
|
||||||
cost.getCostParts().get(0).setTrigger(stAb.getParam("Trigger"));
|
cost.getCostParts().get(0).setTrigger(stAb.getPayingTrigSA());
|
||||||
}
|
}
|
||||||
|
|
||||||
return cost;
|
return cost;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ ManaCost:2 R
|
|||||||
Types:Creature Minotaur Warrior
|
Types:Creature Minotaur Warrior
|
||||||
PT:3/2
|
PT:3/2
|
||||||
K:Haste
|
K:Haste
|
||||||
S:Mode$ CantAttackUnless | ValidCard$ Card.Self | Trigger$ TrigExert | Cost$ Exert<1/CARDNAME> | Description$ You may exert CARDNAME as it attacks. When you do, target creature can't block this turn.
|
S:Mode$ CantAttackUnless | ValidCard$ Card.Self | Trigger$ TrigCanNotBlock | Cost$ Exert<1/CARDNAME> | Description$ You may exert CARDNAME as it attacks. When you do, target creature can't block this turn.
|
||||||
SVar:TrigExert:DB$ ImmediateTrigger | Execute$ TrigCanNotBlock | TriggerDescription$ When you exert CARDNAME, target creature can't block this turn.
|
SVar:TrigCanNotBlock:DB$ Pump | ValidTgts$ Creature | KW$ HIDDEN CARDNAME can't block. | TgtPrompt$ Select target creature. | IsCurse$ True | SpellDescription$ When you do, target creature can't block this turn.
|
||||||
SVar:TrigCanNotBlock:DB$ Pump | ValidTgts$ Creature | KW$ HIDDEN CARDNAME can't block. | TgtPrompt$ Select target creature. | IsCurse$ True | SpellDescription$ Target creature can't block this turn.
|
|
||||||
Oracle:Haste\nYou may exert Ahn-Crop Crasher as it attacks. When you do, target creature can't block this turn. (An exerted creature won't untap during your next untap step.)
|
Oracle:Haste\nYou may exert Ahn-Crop Crasher as it attacks. When you do, target creature can't block this turn. (An exerted creature won't untap during your next untap step.)
|
||||||
|
|||||||
Reference in New Issue
Block a user