tom_bombadil.txt + TriggerAbilityResolves

This commit is contained in:
Northmoc
2023-03-29 11:05:58 -04:00
parent 9f1950132f
commit 32ba1f7fa4
4 changed files with 87 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
/*
* 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.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.spellability.SpellAbility;
import forge.util.Localizer;
import java.util.Map;
public class TriggerAbilityResolves extends Trigger {
public TriggerAbilityResolves(final Map<String, String> params, final Card host, final boolean intrinsic) {
super(params, host, intrinsic);
}
/** {@inheritDoc}
* @param runParams*/
@Override
public final boolean performTest(final Map<AbilityKey, Object> runParams) {
final SpellAbility spellAbility = (SpellAbility) runParams.get(AbilityKey.SpellAbility);
if (spellAbility == null) {
System.out.println("TriggerAbilityResolves performTest encountered spellAbility == null. runParams2 = " + runParams);
return false;
}
final Card source = spellAbility.getHostCard();
if (!matchesValidParam("ValidSpellAbility", spellAbility)) {
return false;
}
if (!matchesValidParam("ValidSource", source)) {
return false;
}
return true;
}
/** {@inheritDoc} */
@Override
public final void setTriggeringObjects(final SpellAbility sa, Map<AbilityKey, Object> runParams) {
final SpellAbility triggeredSA = (SpellAbility) runParams.get(AbilityKey.SpellAbility);
sa.setTriggeringObject(AbilityKey.Source, triggeredSA.getHostCard());
sa.setTriggeringObjectsFrom(
runParams,
AbilityKey.SpellAbility,
AbilityKey.Cause);
}
@Override
public String getImportantStackObjects(SpellAbility sa) {
StringBuilder sb = new StringBuilder();
sb.append(Localizer.getInstance().getMessage("lblSpellAbility")).append(": ").append(sa.getTriggeringObject(AbilityKey.SpellAbility));
return sb.toString();
}
}

View File

@@ -14,6 +14,7 @@ import forge.game.card.Card;
public enum TriggerType {
Abandoned(TriggerAbandoned.class),
AbilityCast(TriggerSpellAbilityCastOrCopy.class),
AbilityResolves(TriggerAbilityResolves.class),
AbilityTriggered(TriggerAbilityTriggered.class),
Adapt(TriggerAdapt.class),
Always(TriggerAlways.class),

View File

@@ -526,6 +526,9 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
}
} else if (sa.getApi() != null) {
AbilityUtils.handleRemembering(sa);
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(source);
runParams.put(AbilityKey.SpellAbility, sa);
game.getTriggerHandler().runTrigger(TriggerType.AbilityResolves, runParams, false);
AbilityUtils.resolve(sa);
} else {
sa.resolve();

View File

@@ -0,0 +1,10 @@
Name:Tom Bombadil
ManaCost:W U B R G
Types:Legendary Creature God Bard
PT:4/4
S:Mode$ Continuous | Affected$ Card.Self | AddKeyword$ Hexproof & Indestructible | CheckSVar$ X | SVarCompare$ GE4 | Description$ As long as there are four or more lore counters among Sagas you control, CARDNAME has hexproof and indestructible.
SVar:X:Count$Valid Saga.YouCtrl$CardCounters.LORE
T:Mode$ AbilityResolves | ValidSource$ Saga.YouCtrl | ValidSpellAbility$ Ability.LastChapter | TriggerZones$ Battlefield | ActivationLimit$ 1 | Execute$ TrigDigUntil | TriggerDescription$ Whenever the final chapter ability of a Saga you control resolves, reveal cards from the top of your library until you reveal a Saga card. Put that onto the battlefield and the rest on the bottom of your library in a random order. This ability triggers only once each turn.
SVar:TrigDigUntil:DB$ DigUntil | Valid$ Saga | FoundDestination$ Battlefield | RevealedDestination$ Library | RevealedLibraryPosition$ -1 | RevealRandomOrder$ True
DeckNeeds:Type$Saga
Oracle:As long as there are four or more lore counters among Sagas you control, Tom Bombadil has hexproof and indestructible.\nWhenever the final chapter ability of a Saga you control resolves, reveal cards from the top of your library until you reveal a Saga card. Put that onto the battlefield and the rest on the bottom of your library in a random order. This ability triggers only once each turn.