add IsForetold trigger

This commit is contained in:
Northmoc
2021-12-24 14:25:58 -05:00
parent 4b7c5cd059
commit 15b52a1a2c
3 changed files with 77 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import forge.game.event.GameEventCardForetold; import forge.game.event.GameEventCardForetold;
import forge.game.trigger.TriggerType;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@@ -2892,6 +2893,7 @@ public class CardFactoryUtil {
final Game game = getHostCard().getGame(); final Game game = getHostCard().getGame();
final Card c = game.getAction().exile(getHostCard(), this); final Card c = game.getAction().exile(getHostCard(), this);
c.setForetold(true); c.setForetold(true);
game.getTriggerHandler().runTrigger(TriggerType.IsForetold, AbilityKey.mapFromCard(c), false);
c.setForetoldThisTurn(true); c.setForetoldThisTurn(true);
c.turnFaceDown(true); c.turnFaceDown(true);
// look at the exiled card // look at the exiled card

View File

@@ -0,0 +1,74 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2021 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.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.card.CardState;
import forge.game.spellability.SpellAbility;
import forge.util.Localizer;
/**
* <p>
* Trigger_IsForetold class.
* </p>
* (Mainly copied from TriggerBecomeMonstrous)
*/
public class TriggerIsForetold extends Trigger {
/**
* <p>
* Constructor for Trigger_IsForetold.
* </p>
*
* @param params
* a {@link java.util.HashMap} object.
* @param host
* a {@link forge.game.card.Card} object.
* @param intrinsic
* the intrinsic
*/
public TriggerIsForetold(Map<String, String> params, final Card host, final boolean intrinsic) {
super(params, host, intrinsic);
}
/** {@inheritDoc}
* @param runParams*/
@Override
public final boolean performTest(Map<AbilityKey, Object> runParams) {
if (!matchesValidParam("ValidCard", runParams.get(AbilityKey.Card))) {
return false;
}
return true;
}
/** {@inheritDoc} */
@Override
public final void setTriggeringObjects(final SpellAbility sa, Map<AbilityKey, Object> runParams) {
sa.setTriggeringObjectsFrom(runParams, AbilityKey.Card);
}
@Override
public String getImportantStackObjects(SpellAbility sa) {
//nothing here because foretelling is secretive - generally will be Static anyway
return "";
}
}

View File

@@ -73,6 +73,7 @@ public enum TriggerType {
Foretell(TriggerForetell.class), Foretell(TriggerForetell.class),
Immediate(TriggerImmediate.class), Immediate(TriggerImmediate.class),
Investigated(TriggerInvestigated.class), Investigated(TriggerInvestigated.class),
IsForetold(TriggerIsForetold.class),
LandPlayed(TriggerLandPlayed.class), LandPlayed(TriggerLandPlayed.class),
LifeGained(TriggerLifeGained.class), LifeGained(TriggerLifeGained.class),
LifeLost(TriggerLifeLost.class), LifeLost(TriggerLifeLost.class),