Cloak Effect

This commit is contained in:
Hans Mackowiak
2024-01-20 22:49:15 +01:00
committed by Chris H
parent f9239f2d2a
commit d5fde9c7af
3 changed files with 80 additions and 0 deletions

View File

@@ -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),

View File

@@ -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<AbilityKey, Object> 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);
}
}
}

View File

@@ -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 its a creature card.)\n• Put a +1/+1 counter on each colorless creature you control.