From b634a95498edfb51302c06514fa4d6373d6f8700 Mon Sep 17 00:00:00 2001 From: Daniel Eberhard Date: Sat, 17 Dec 2022 01:50:54 +0100 Subject: [PATCH] Added card "Holochess" and its abilities and effects --- .../src/mage/cards/d/DyadForceTransfer.java | 2 +- .../mage/cards/f/FestivalOfTheAncestors.java | 2 +- .../mage/cards/f/FirstOrderJetTrooper.java | 2 +- Mage.Sets/src/mage/cards/f/ForceLift.java | 2 +- Mage.Sets/src/mage/cards/g/GeneralOrgana.java | 2 +- Mage.Sets/src/mage/cards/h/HiddenBase.java | 2 +- Mage.Sets/src/mage/cards/h/HoldCaptive.java | 2 +- Mage.Sets/src/mage/cards/h/Holochess.java | 90 ++++++++++++++++++- 8 files changed, 96 insertions(+), 8 deletions(-) diff --git a/Mage.Sets/src/mage/cards/d/DyadForceTransfer.java b/Mage.Sets/src/mage/cards/d/DyadForceTransfer.java index c73fa70f53..86f180ae05 100644 --- a/Mage.Sets/src/mage/cards/d/DyadForceTransfer.java +++ b/Mage.Sets/src/mage/cards/d/DyadForceTransfer.java @@ -24,7 +24,7 @@ public class DyadForceTransfer extends CardImpl { this.getSpellAbility().addEffect(new ScryEffect(3, true)); } - public DyadForceTransfer(DyadForceTransfer card) { + public DyadForceTransfer(final DyadForceTransfer card) { super(card); } diff --git a/Mage.Sets/src/mage/cards/f/FestivalOfTheAncestors.java b/Mage.Sets/src/mage/cards/f/FestivalOfTheAncestors.java index 6b4d96fd65..e6a7d3d5e9 100644 --- a/Mage.Sets/src/mage/cards/f/FestivalOfTheAncestors.java +++ b/Mage.Sets/src/mage/cards/f/FestivalOfTheAncestors.java @@ -17,7 +17,7 @@ public class FestivalOfTheAncestors extends CardImpl { this.getSpellAbility().addTarget(new TargetPlayer()); } - public FestivalOfTheAncestors(FestivalOfTheAncestors card) { + public FestivalOfTheAncestors(final FestivalOfTheAncestors card) { super(card); } diff --git a/Mage.Sets/src/mage/cards/f/FirstOrderJetTrooper.java b/Mage.Sets/src/mage/cards/f/FirstOrderJetTrooper.java index d15926020b..4e7874d275 100644 --- a/Mage.Sets/src/mage/cards/f/FirstOrderJetTrooper.java +++ b/Mage.Sets/src/mage/cards/f/FirstOrderJetTrooper.java @@ -39,7 +39,7 @@ public class FirstOrderJetTrooper extends CardImpl { this.addAbility(ability); } - public FirstOrderJetTrooper(FirstOrderJetTrooper card) { + public FirstOrderJetTrooper(final FirstOrderJetTrooper card) { super(card); } diff --git a/Mage.Sets/src/mage/cards/f/ForceLift.java b/Mage.Sets/src/mage/cards/f/ForceLift.java index 6e474cb9db..a89faaebd3 100644 --- a/Mage.Sets/src/mage/cards/f/ForceLift.java +++ b/Mage.Sets/src/mage/cards/f/ForceLift.java @@ -34,7 +34,7 @@ public class ForceLift extends CardImpl { this.getSpellAbility().addEffect(new ScryEffect(1)); } - public ForceLift(ForceLift card) { + public ForceLift(final ForceLift card) { super(card); } diff --git a/Mage.Sets/src/mage/cards/g/GeneralOrgana.java b/Mage.Sets/src/mage/cards/g/GeneralOrgana.java index 5d921bd3a9..0e300d73d6 100644 --- a/Mage.Sets/src/mage/cards/g/GeneralOrgana.java +++ b/Mage.Sets/src/mage/cards/g/GeneralOrgana.java @@ -40,7 +40,7 @@ public class GeneralOrgana extends CardImpl { this.addAbility(new LeavesBattlefieldTriggeredAbility(new ScryEffect(2), false)); } - public GeneralOrgana(GeneralOrgana card) { + public GeneralOrgana(final GeneralOrgana card) { super(card); } diff --git a/Mage.Sets/src/mage/cards/h/HiddenBase.java b/Mage.Sets/src/mage/cards/h/HiddenBase.java index 572f62ff02..63841ce84c 100644 --- a/Mage.Sets/src/mage/cards/h/HiddenBase.java +++ b/Mage.Sets/src/mage/cards/h/HiddenBase.java @@ -39,7 +39,7 @@ public class HiddenBase extends CardImpl { this.addAbility(simpleActivatedAbility); } - public HiddenBase(HiddenBase card) { + public HiddenBase(final HiddenBase card) { super(card); } diff --git a/Mage.Sets/src/mage/cards/h/HoldCaptive.java b/Mage.Sets/src/mage/cards/h/HoldCaptive.java index 888a68aebe..c523058afc 100644 --- a/Mage.Sets/src/mage/cards/h/HoldCaptive.java +++ b/Mage.Sets/src/mage/cards/h/HoldCaptive.java @@ -32,7 +32,7 @@ public class HoldCaptive extends CardImpl { this.addAbility(new SimpleStaticAbility(new CantBlockAttackActivateAttachedEffect())); } - public HoldCaptive(HoldCaptive card) { + public HoldCaptive(final HoldCaptive card) { super(card); } diff --git a/Mage.Sets/src/mage/cards/h/Holochess.java b/Mage.Sets/src/mage/cards/h/Holochess.java index 894626446d..860c34661d 100644 --- a/Mage.Sets/src/mage/cards/h/Holochess.java +++ b/Mage.Sets/src/mage/cards/h/Holochess.java @@ -1,4 +1,92 @@ package mage.cards.h; -public class Holochess { +import mage.abilities.Ability; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CounterUnlessPaysEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetSpell; +import mage.target.common.TargetOpponent; +import mage.target.targetpointer.FixedTarget; + +import java.util.List; +import java.util.UUID; + +/** + * @author Merlingilb + */ +public class Holochess extends CardImpl { + public Holochess(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}"); + + //Choose a number between 0 and 3. If the chosen number is less than the number of creatures an opponent controls, + //draw X cards where X is the chosen number. Otherwise, counter target spell unless its controller pays {X}. + this.getSpellAbility().addEffect(new HolochessEffect()); + this.getSpellAbility().addTarget(new TargetOpponent()); + } + + public Holochess(Holochess card) { + super(card); + } + + @Override + public Holochess copy() { + return new Holochess(this); + } +} + +class HolochessEffect extends OneShotEffect { + + HolochessEffect() { + super(Outcome.Benefit); + staticText = "Choose a number between 0 and 3. If the chosen number is less than the number of creatures an " + + "opponent controls, draw X cards where X is the chosen number. Otherwise, counter target spell " + + "unless its controller pays {X}."; + } + + private HolochessEffect(final HolochessEffect effect) { + super(effect); + } + + @Override + public HolochessEffect copy() { + return new HolochessEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Player opponent = game.getPlayer(source.getFirstTarget()); + if (player == null || opponent == null) { + return false; + } + int chosenNumber = player.getAmount(0, 3, "Choose a number between 0 and 3", game); + List creaturesControlledByOpponent = game.getBattlefield().getActivePermanents( + StaticFilters.FILTER_PERMANENT_CREATURES, opponent.getId(), game); + if (chosenNumber < creaturesControlledByOpponent.size()) { + player.drawCards(chosenNumber, source, game); + } + else { + if (game.getStack().isEmpty()) { + return false; + } + CounterUnlessPaysEffect counterUnlessPaysEffect = new CounterUnlessPaysEffect( + new GenericManaCost(chosenNumber)); + TargetSpell targetSpell = new TargetSpell(); + player.chooseTarget(Outcome.Benefit, targetSpell, source, game); + if (targetSpell.getFirstTarget() == null) { + return false; + } + counterUnlessPaysEffect.setTargetPointer(new FixedTarget(targetSpell.getFirstTarget())); + return counterUnlessPaysEffect.apply(game, source); + } + return true; + } }