From 9b5d508e2c62b28e39bf6bc531cc812a0d987f1a Mon Sep 17 00:00:00 2001 From: "Alex W. Jackson" Date: Sun, 24 Jul 2022 13:54:54 -0400 Subject: [PATCH] [MMQ] Implement Bargaining Table, Erithizon and Ley Line --- .../src/mage/cards/b/BargainingTable.java | 72 ++++++++++++++++ Mage.Sets/src/mage/cards/e/Erithizon.java | 61 +++++++++++++ Mage.Sets/src/mage/cards/l/LeyLine.java | 85 +++++++++++++++++++ Mage.Sets/src/mage/sets/MercadianMasques.java | 3 + 4 files changed, 221 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/b/BargainingTable.java create mode 100644 Mage.Sets/src/mage/cards/e/Erithizon.java create mode 100644 Mage.Sets/src/mage/cards/l/LeyLine.java diff --git a/Mage.Sets/src/mage/cards/b/BargainingTable.java b/Mage.Sets/src/mage/cards/b/BargainingTable.java new file mode 100644 index 0000000000..f5790a7cbc --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BargainingTable.java @@ -0,0 +1,72 @@ +package mage.cards.b; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.CostAdjuster; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.InfoEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetOpponent; +import mage.util.CardUtil; + +/** + * + * @author awjackson + */ +public final class BargainingTable extends CardImpl { + + public BargainingTable(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{5}"); + + // {X}, {T}: Draw a card. X is the number of cards in an opponent's hand. + Ability ability = new SimpleActivatedAbility(new DrawCardSourceControllerEffect(1), new ManaCostsImpl<>("{X}")); + ability.addCost(new TapSourceCost()); + ability.addEffect(new InfoEffect("X is the number of cards in an opponent's hand")); + // You choose an opponent on announcement. This is not targeted, but a choice is still made. + // This choice is made before determining the value for X that is used in the cost. (2004-10-04) + ability.addTarget(new TargetOpponent(true)); + ability.setCostAdjuster(BargainingTableAdjuster.instance); + this.addAbility(ability); + } + + private BargainingTable(final BargainingTable card) { + super(card); + } + + @Override + public BargainingTable copy() { + return new BargainingTable(this); + } +} + +enum BargainingTableAdjuster implements CostAdjuster { + instance; + + @Override + public void adjustCosts(Ability ability, Game game) { + int handSize = Integer.MAX_VALUE; + if (game.inCheckPlayableState()) { + for (UUID playerId : CardUtil.getAllPossibleTargets(ability, game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + handSize = Math.min(handSize, player.getHand().size()); + } + } + } else { + Player player = game.getPlayer(ability.getFirstTarget()); + if (player != null) { + handSize = player.getHand().size(); + } + } + ability.getManaCostsToPay().clear(); + ability.getManaCostsToPay().add(new GenericManaCost(handSize)); + } +} diff --git a/Mage.Sets/src/mage/cards/e/Erithizon.java b/Mage.Sets/src/mage/cards/e/Erithizon.java new file mode 100644 index 0000000000..c06e46173a --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/Erithizon.java @@ -0,0 +1,61 @@ +package mage.cards.e; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.AttacksTriggeredAbility; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.counters.CounterType; +import mage.filter.common.FilterCreaturePermanent; +import mage.game.Game; +import mage.target.common.TargetCreaturePermanent; +import mage.target.targetadjustment.TargetAdjuster; + +/** + * + * @author awjackson + */ +public final class Erithizon extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature of defending player's choice"); + + public Erithizon(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{G}"); + this.subtype.add(SubType.BEAST); + + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Whenever Erithizon attacks, put a +1/+1 counter on target creature of defending player's choice. + Ability ability = new AttacksTriggeredAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance())); + ability.addTarget(new TargetCreaturePermanent(filter)); + ability.setTargetAdjuster(ErithizonAdjuster.instance); + this.addAbility(ability); + } + + private Erithizon(final Erithizon card) { + super(card); + } + + @Override + public Erithizon copy() { + return new Erithizon(this); + } +} + +enum ErithizonAdjuster implements TargetAdjuster { + instance; + + @Override + public void adjustTargets(Ability ability, Game game) { + TargetCreaturePermanent target = new TargetCreaturePermanent(); + target.setAbilityController(ability.getControllerId()); + target.setTargetController(game.getCombat().getDefendingPlayerId(ability.getSourceId(), game)); + ability.getTargets().clear(); + ability.getTargets().add(target); + } +} diff --git a/Mage.Sets/src/mage/cards/l/LeyLine.java b/Mage.Sets/src/mage/cards/l/LeyLine.java new file mode 100644 index 0000000000..59e1baf254 --- /dev/null +++ b/Mage.Sets/src/mage/cards/l/LeyLine.java @@ -0,0 +1,85 @@ +package mage.cards.l; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCreaturePermanent; +import mage.target.targetadjustment.TargetAdjuster; + +/** + * + * @author awjackson + */ +public final class LeyLine extends CardImpl { + + public LeyLine(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}"); + + // At the beginning of each player's upkeep, that player may put a +1/+1 counter on target creature of their choice. + Ability ability = new BeginningOfUpkeepTriggeredAbility(new LeyLineEffect(), TargetController.ANY, false); + ability.setTargetAdjuster(LeyLineAdjuster.instance); + this.addAbility(ability); + } + + private LeyLine(final LeyLine card) { + super(card); + } + + @Override + public LeyLine copy() { + return new LeyLine(this); + } +} + +enum LeyLineAdjuster implements TargetAdjuster { + instance; + + @Override + public void adjustTargets(Ability ability, Game game) { + TargetCreaturePermanent target = new TargetCreaturePermanent(); + target.setAbilityController(ability.getControllerId()); + target.setTargetController(game.getActivePlayerId()); + ability.getTargets().clear(); + ability.getTargets().add(target); + } +} + +class LeyLineEffect extends OneShotEffect { + + public LeyLineEffect() { + super(Outcome.BoostCreature); + staticText = "that player may put a +1/+1 counter on target creature of their choice"; + } + + public LeyLineEffect(LeyLineEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(game.getActivePlayerId()); + Permanent permanent = game.getPermanent(source.getFirstTarget()); + if (player == null || permanent == null) { + return false; + } + if (player.chooseUse(Outcome.BoostCreature, "Put a +1/+1 counter on " + permanent.getName() + "?", source, game)) { + permanent.addCounters(CounterType.P1P1.createInstance(), player.getId(), source, game); + } + return true; + } + + @Override + public LeyLineEffect copy() { + return new LeyLineEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/MercadianMasques.java b/Mage.Sets/src/mage/sets/MercadianMasques.java index a7398bf630..2d0d50fb0b 100644 --- a/Mage.Sets/src/mage/sets/MercadianMasques.java +++ b/Mage.Sets/src/mage/sets/MercadianMasques.java @@ -36,6 +36,7 @@ public final class MercadianMasques extends ExpansionSet { cards.add(new SetCardInfo("Ballista Squad", 5, Rarity.UNCOMMON, mage.cards.b.BallistaSquad.class)); cards.add(new SetCardInfo("Balloon Peddler", 59, Rarity.COMMON, mage.cards.b.BalloonPeddler.class)); cards.add(new SetCardInfo("Barbed Wire", 287, Rarity.UNCOMMON, mage.cards.b.BarbedWire.class)); + cards.add(new SetCardInfo("Bargaining Table", 288, Rarity.RARE, mage.cards.b.BargainingTable.class)); cards.add(new SetCardInfo("Battle Rampart", 173, Rarity.COMMON, mage.cards.b.BattleRampart.class)); cards.add(new SetCardInfo("Battle Squadron", 174, Rarity.RARE, mage.cards.b.BattleSquadron.class)); cards.add(new SetCardInfo("Bifurcate", 230, Rarity.RARE, mage.cards.b.Bifurcate.class)); @@ -121,6 +122,7 @@ public final class MercadianMasques extends ExpansionSet { cards.add(new SetCardInfo("Embargo", 77, Rarity.RARE, mage.cards.e.Embargo.class)); cards.add(new SetCardInfo("Energy Flux", 78, Rarity.UNCOMMON, mage.cards.e.EnergyFlux.class)); cards.add(new SetCardInfo("Enslaved Horror", 134, Rarity.UNCOMMON, mage.cards.e.EnslavedHorror.class)); + cards.add(new SetCardInfo("Erithizon", 244, Rarity.RARE, mage.cards.e.Erithizon.class)); cards.add(new SetCardInfo("Extortion", 135, Rarity.RARE, mage.cards.e.Extortion.class)); cards.add(new SetCardInfo("Extravagant Spirit", 79, Rarity.RARE, mage.cards.e.ExtravagantSpirit.class)); cards.add(new SetCardInfo("Eye of Ramos", 294, Rarity.RARE, mage.cards.e.EyeOfRamos.class)); @@ -194,6 +196,7 @@ public final class MercadianMasques extends ExpansionSet { cards.add(new SetCardInfo("Larceny", 143, Rarity.UNCOMMON, mage.cards.l.Larceny.class)); cards.add(new SetCardInfo("Last Breath", 27, Rarity.UNCOMMON, mage.cards.l.LastBreath.class)); cards.add(new SetCardInfo("Lava Runner", 200, Rarity.RARE, mage.cards.l.LavaRunner.class)); + cards.add(new SetCardInfo("Ley Line", 256, Rarity.UNCOMMON, mage.cards.l.LeyLine.class)); cards.add(new SetCardInfo("Liability", 144, Rarity.RARE, mage.cards.l.Liability.class)); cards.add(new SetCardInfo("Lightning Hounds", 201, Rarity.COMMON, mage.cards.l.LightningHounds.class)); cards.add(new SetCardInfo("Lithophage", 202, Rarity.RARE, mage.cards.l.Lithophage.class));