From c25a7c67145478891c6b7df523b9335fcc5b250d Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Fri, 4 Nov 2022 18:26:05 -0500 Subject: [PATCH] [BRO] Implemented Tower Worker --- Mage.Sets/src/mage/cards/t/TowerWorker.java | 84 +++++++++++++++++++++ Mage.Sets/src/mage/sets/TheBrothersWar.java | 1 + 2 files changed, 85 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/TowerWorker.java diff --git a/Mage.Sets/src/mage/cards/t/TowerWorker.java b/Mage.Sets/src/mage/cards/t/TowerWorker.java new file mode 100644 index 0000000000..96e6150f87 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TowerWorker.java @@ -0,0 +1,84 @@ +package mage.cards.t; + +import java.util.UUID; +import mage.MageInt; +import mage.Mana; +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.mana.DynamicManaAbility; +import mage.constants.SubType; +import mage.abilities.keyword.ReachAbility; +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; + +/** + * + * @author weirddan455 + */ +public final class TowerWorker extends CardImpl { + + public TowerWorker(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}"); + + this.subtype.add(SubType.ASSEMBLY_WORKER); + this.power = new MageInt(1); + this.toughness = new MageInt(3); + + // Reach + this.addAbility(ReachAbility.getInstance()); + + // {T}: Add {C}. If you control creatures named Mine Worker and Power Plant Worker, add {C}{C}{C} instead. + this.addAbility(new DynamicManaAbility( + Mana.ColorlessMana(1), TowerWorkerValue.instance, + "Add {C}. If you control creatures named Mine Worker and Power Plant Worker, add {C}{C}{C} instead" + )); + } + + private TowerWorker(final TowerWorker card) { + super(card); + } + + @Override + public TowerWorker copy() { + return new TowerWorker(this); + } +} + +enum TowerWorkerValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + String mineName = "Mine Worker"; + String powerPlantName = "Power Plant Worker"; + boolean mine = false; + boolean powerPlant = false; + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, sourceAbility.getControllerId(), game)) { + String name = permanent.getName(); + if (!mine && mineName.equals(name)) { + mine = true; + } else if (!powerPlant && powerPlantName.equals(name)) { + powerPlant = true; + } + if (mine && powerPlant) { + return 3; + } + } + return 1; + } + + @Override + public TowerWorkerValue copy() { + return instance; + } + + @Override + public String getMessage() { + return ""; + } +} diff --git a/Mage.Sets/src/mage/sets/TheBrothersWar.java b/Mage.Sets/src/mage/sets/TheBrothersWar.java index 1326f27f9b..093aeb7fca 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWar.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWar.java @@ -188,6 +188,7 @@ public final class TheBrothersWar extends ExpansionSet { cards.add(new SetCardInfo("Tocasia's Onulet", 39, Rarity.COMMON, mage.cards.t.TocasiasOnulet.class)); cards.add(new SetCardInfo("Tocasia's Welcome", 30, Rarity.RARE, mage.cards.t.TocasiasWelcome.class)); cards.add(new SetCardInfo("Tomakul Honor Guard", 195, Rarity.COMMON, mage.cards.t.TomakulHonorGuard.class)); + cards.add(new SetCardInfo("Tower Worker", 255, Rarity.COMMON, mage.cards.t.TowerWorker.class)); cards.add(new SetCardInfo("Transmogrant's Crown", 125, Rarity.RARE, mage.cards.t.TransmograntsCrown.class)); cards.add(new SetCardInfo("Tyrant of Kher Ridges", 154, Rarity.RARE, mage.cards.t.TyrantOfKherRidges.class)); cards.add(new SetCardInfo("Underground River", 267, Rarity.RARE, mage.cards.u.UndergroundRiver.class));