From d5fde9c7af295074734cd4fd7dfc448fe32a56ea Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Sat, 20 Jan 2024 22:49:15 +0100 Subject: [PATCH] Cloak Effect --- .../main/java/forge/game/ability/ApiType.java | 1 + .../game/ability/effects/CloakEffect.java | 69 +++++++++++++++++++ .../upcoming/vannifar_evolved_enigma.txt | 10 +++ 3 files changed, 80 insertions(+) create mode 100644 forge-game/src/main/java/forge/game/ability/effects/CloakEffect.java create mode 100644 forge-gui/res/cardsfolder/upcoming/vannifar_evolved_enigma.txt diff --git a/forge-game/src/main/java/forge/game/ability/ApiType.java b/forge-game/src/main/java/forge/game/ability/ApiType.java index 6abe59bf53a..7358802d7f2 100644 --- a/forge-game/src/main/java/forge/game/ability/ApiType.java +++ b/forge-game/src/main/java/forge/game/ability/ApiType.java @@ -53,6 +53,7 @@ public enum ApiType { Clash (ClashEffect.class), ClassLevelUp (ClassLevelUpEffect.class), Cleanup (CleanUpEffect.class), + Cloak (CloakEffect.class), Clone (CloneEffect.class), CompanionChoose (ChooseCompanionEffect.class), Connive (ConniveEffect.class), diff --git a/forge-game/src/main/java/forge/game/ability/effects/CloakEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CloakEffect.java new file mode 100644 index 00000000000..55130bcb49f --- /dev/null +++ b/forge-game/src/main/java/forge/game/ability/effects/CloakEffect.java @@ -0,0 +1,69 @@ +package forge.game.ability.effects; + +import java.util.Map; + +import forge.game.Game; +import forge.game.ability.AbilityKey; +import forge.game.ability.AbilityUtils; +import forge.game.ability.SpellAbilityEffect; +import forge.game.card.Card; +import forge.game.card.CardCollection; +import forge.game.card.CardCollectionView; +import forge.game.card.CardLists; +import forge.game.card.CardZoneTable; +import forge.game.player.Player; +import forge.game.spellability.SpellAbility; +import forge.game.zone.ZoneType; +import forge.util.Localizer; + +public class CloakEffect extends SpellAbilityEffect { + @Override + public void resolve(SpellAbility sa) { + final Card source = sa.getHostCard(); + final Player activator = sa.getActivatingPlayer(); + final Game game = source.getGame(); + final int amount = sa.hasParam("Amount") ? AbilityUtils.calculateAmount(source, + sa.getParam("Amount"), sa) : 1; + + for (final Player p : getTargetPlayers(sa, "DefinedPlayer")) { + CardCollection tgtCards; + if (sa.hasParam("Choices") || sa.hasParam("ChoiceZone")) { + ZoneType choiceZone = ZoneType.Hand; + if (sa.hasParam("ChoiceZone")) { + choiceZone = ZoneType.smartValueOf(sa.getParam("ChoiceZone")); + } + CardCollectionView choices = game.getCardsIn(choiceZone); + if (sa.hasParam("Choices")) { + choices = CardLists.getValidCards(choices, sa.getParam("Choices"), activator, source, sa); + } + if (choices.isEmpty()) { + continue; + } + + String title = sa.hasParam("ChoiceTitle") ? sa.getParam("ChoiceTitle") : Localizer.getInstance().getMessage("lblChooseCards") + " "; + + tgtCards = new CardCollection(activator.getController().chooseCardsForEffect(choices, sa, title, amount, amount, false, null)); + } else { + tgtCards = getTargetCards(sa); + } + + if (sa.hasParam("Shuffle")) { + CardLists.shuffle(tgtCards); + } + + CardZoneTable triggerList = new CardZoneTable(); + + Map moveParams = AbilityKey.newMap(); + moveParams.put(AbilityKey.LastStateBattlefield, triggerList.getLastStateBattlefield()); + moveParams.put(AbilityKey.LastStateGraveyard, triggerList.getLastStateGraveyard()); + moveParams.put(AbilityKey.InternalTriggerTable, triggerList); + for (Card c : tgtCards) { + Card rem = c.cloak(p, sa, moveParams); + if (rem != null && sa.hasParam("RememberCloaked") && rem.isCloaked()) { + source.addRemembered(rem); + } + } + triggerList.triggerChangesZoneAll(game, sa); + } + } +} diff --git a/forge-gui/res/cardsfolder/upcoming/vannifar_evolved_enigma.txt b/forge-gui/res/cardsfolder/upcoming/vannifar_evolved_enigma.txt new file mode 100644 index 00000000000..cd64db40bd0 --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/vannifar_evolved_enigma.txt @@ -0,0 +1,10 @@ +Name:Vannifar, Evolved Enigma +ManaCost:2 G U +Types:Legendary Creature Elf Ooze Wizard +PT:3/4 +T:Mode$ Phase | Phase$ BeginCombat | ValidPlayer$ You | Execute$ TrigCharm | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of combat on your turn, ABILITY +SVar:TrigCharm:DB$ Charm | Choices$ DBCloak,DBPutCounters | CharmNum$ 1 +SVar:DBCloak:DB$ Cloak | Choices$ Card.YouCtrl | SpellDescription$ Cloak a card from your hand. +SVar:DBPutCounters:DB$ PutCounterAll | ValidCards$ Creature.Colorless+YouCtrl | CounterType$ P1P1 | CounterNum$ 1 | SpellDescription$ Put a +1/+1 counter on each colorless creature you control. +Oracle:At the beginning of combat on your turn, choose one —\n• Cloak a card from your hand. (Put it onto the battlefield face down as a 2/2 creature with ward {2}. Turn it face up any time for its mana cost if it’s a creature card.)\n• Put a +1/+1 counter on each colorless creature you control. +