From eb1f689286edb622484cccc33c26ef12c6aed91d Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Thu, 3 Nov 2022 12:31:10 -0500 Subject: [PATCH] [BRO] Implemented Mine Worker --- Mage.Sets/src/mage/cards/m/MineWorker.java | 88 +++++++++++++++++++++ Mage.Sets/src/mage/sets/TheBrothersWar.java | 1 + 2 files changed, 89 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/m/MineWorker.java diff --git a/Mage.Sets/src/mage/cards/m/MineWorker.java b/Mage.Sets/src/mage/cards/m/MineWorker.java new file mode 100644 index 00000000000..8461036fe37 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MineWorker.java @@ -0,0 +1,88 @@ +package mage.cards.m; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author weirddan455 + */ +public final class MineWorker extends CardImpl { + + public MineWorker(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{2}"); + + this.subtype.add(SubType.ASSEMBLY_WORKER); + this.power = new MageInt(2); + this.toughness = new MageInt(1); + + // {T}: You gain 1 life. If you control creatures named Power Plant Worker and Tower Worker, you gain 3 life instead. + this.addAbility(new SimpleActivatedAbility(new MineWorkerEffect(), new TapSourceCost())); + } + + private MineWorker(final MineWorker card) { + super(card); + } + + @Override + public MineWorker copy() { + return new MineWorker(this); + } +} + +class MineWorkerEffect extends OneShotEffect { + + public MineWorkerEffect() { + super(Outcome.GainLife); + this.staticText = "You gain 1 life. If you control creatures named Power Plant Worker and Tower Worker, you gain 3 life instead."; + } + + private MineWorkerEffect(final MineWorkerEffect effect) { + super(effect); + } + + @Override + public MineWorkerEffect copy() { + return new MineWorkerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + String powerPlantName = "Power Plant Worker"; + String towerName = "Tower Worker"; + boolean powerPlant = false; + boolean tower = false; + int life = 1; + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) { + String name = permanent.getName(); + if (!powerPlant && powerPlantName.equals(name)) { + powerPlant = true; + } else if (!tower && towerName.equals(name)) { + tower = true; + } + if (powerPlant && tower) { + life = 3; + break; + } + } + controller.gainLife(life, game, source); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/TheBrothersWar.java b/Mage.Sets/src/mage/sets/TheBrothersWar.java index cba7f8e6dcd..304c77ffeba 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWar.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWar.java @@ -89,6 +89,7 @@ public final class TheBrothersWar extends ExpansionSet { cards.add(new SetCardInfo("Loran of the Third Path", 12, Rarity.RARE, mage.cards.l.LoranOfTheThirdPath.class)); cards.add(new SetCardInfo("Loran, Disciple of History", 13, Rarity.UNCOMMON, mage.cards.l.LoranDiscipleOfHistory.class)); cards.add(new SetCardInfo("Mass Production", 15, Rarity.UNCOMMON, mage.cards.m.MassProduction.class)); + cards.add(new SetCardInfo("Mine Worker", 239, Rarity.COMMON, mage.cards.m.MineWorker.class)); cards.add(new SetCardInfo("Mishra's Command", 141, Rarity.RARE, mage.cards.m.MishrasCommand.class)); cards.add(new SetCardInfo("Mishra's Foundry", 265, Rarity.RARE, mage.cards.m.MishrasFoundry.class)); cards.add(new SetCardInfo("Mishra's Juggernaut", 161, Rarity.COMMON, mage.cards.m.MishrasJuggernaut.class));