From 6e750492b2ee732adee38a29de4288c056d6c742 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Sat, 30 Mar 2024 21:39:45 -0400 Subject: [PATCH] [OTJ] Implement Luxurious Locomotive --- .../src/mage/cards/l/LuxuriousLocomotive.java | 76 +++++++++++++++++++ .../mage/sets/OutlawsOfThunderJunction.java | 1 + .../mage/abilities/keyword/CrewAbility.java | 5 +- .../watchers/common/CrewedVehicleWatcher.java | 9 +++ 4 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/l/LuxuriousLocomotive.java diff --git a/Mage.Sets/src/mage/cards/l/LuxuriousLocomotive.java b/Mage.Sets/src/mage/cards/l/LuxuriousLocomotive.java new file mode 100644 index 00000000000..ea128b5dcce --- /dev/null +++ b/Mage.Sets/src/mage/cards/l/LuxuriousLocomotive.java @@ -0,0 +1,76 @@ +package mage.cards.l; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.ActivatedAbility; +import mage.abilities.common.AttacksTriggeredAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.keyword.CrewAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.game.Game; +import mage.game.permanent.token.TreasureToken; +import mage.watchers.common.CrewedVehicleWatcher; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class LuxuriousLocomotive extends CardImpl { + + public LuxuriousLocomotive(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{5}"); + + this.subtype.add(SubType.VEHICLE); + this.power = new MageInt(6); + this.toughness = new MageInt(5); + + // Whenever Luxurious Locomotive attacks, create a Treasure token for each creature that crewed it this turn. + this.addAbility(new AttacksTriggeredAbility(new CreateTokenEffect( + new TreasureToken(), LuxuriousLocomotiveValue.instance + )), new CrewedVehicleWatcher()); + + // Crew 1. Activate only once each turn. + ActivatedAbility ability = new CrewAbility(1); + ability.setMaxActivationsPerTurn(1); + this.addAbility(ability); + } + + private LuxuriousLocomotive(final LuxuriousLocomotive card) { + super(card); + } + + @Override + public LuxuriousLocomotive copy() { + return new LuxuriousLocomotive(this); + } +} + +enum LuxuriousLocomotiveValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + return CrewedVehicleWatcher.getCrewCount(sourceAbility.getSourcePermanentOrLKI(game), game); + } + + @Override + public LuxuriousLocomotiveValue copy() { + return this; + } + + @Override + public String getMessage() { + return "creature that crewed it this turn"; + } + + @Override + public String toString() { + return "1"; + } +} diff --git a/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java b/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java index 98c2ba80d64..74655ff7156 100644 --- a/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java +++ b/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java @@ -111,6 +111,7 @@ public final class OutlawsOfThunderJunction extends ExpansionSet { cards.add(new SetCardInfo("Loan Shark", 55, Rarity.COMMON, mage.cards.l.LoanShark.class)); cards.add(new SetCardInfo("Lonely Arroyo", 260, Rarity.COMMON, mage.cards.l.LonelyArroyo.class)); cards.add(new SetCardInfo("Lush Oasis", 261, Rarity.COMMON, mage.cards.l.LushOasis.class)); + cards.add(new SetCardInfo("Luxurious Locomotive", 244, Rarity.UNCOMMON, mage.cards.l.LuxuriousLocomotive.class)); cards.add(new SetCardInfo("Magda, the Hoardmaster", 133, Rarity.RARE, mage.cards.m.MagdaTheHoardmaster.class)); cards.add(new SetCardInfo("Malcolm, the Eyes", 219, Rarity.RARE, mage.cards.m.MalcolmTheEyes.class)); cards.add(new SetCardInfo("Map the Frontier", 170, Rarity.UNCOMMON, mage.cards.m.MapTheFrontier.class)); diff --git a/Mage/src/main/java/mage/abilities/keyword/CrewAbility.java b/Mage/src/main/java/mage/abilities/keyword/CrewAbility.java index db154867f9a..04967f90f02 100644 --- a/Mage/src/main/java/mage/abilities/keyword/CrewAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/CrewAbility.java @@ -72,8 +72,9 @@ public class CrewAbility extends SimpleActivatedAbility { @Override public String getRule() { - return "Crew " + value + " (Tap any number of creatures you control with total power " - + value + " or more: This Vehicle becomes an artifact creature until end of turn.)"; + return "Crew " + value + (this.maxActivationsPerTurn == 1 ? ". Activate only once each turn." : "") + + " (Tap any number of creatures you control with total power " + value + + " or more: This Vehicle becomes an artifact creature until end of turn.)"; } } diff --git a/Mage/src/main/java/mage/watchers/common/CrewedVehicleWatcher.java b/Mage/src/main/java/mage/watchers/common/CrewedVehicleWatcher.java index 1b43c367e35..677e5ec0015 100644 --- a/Mage/src/main/java/mage/watchers/common/CrewedVehicleWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CrewedVehicleWatcher.java @@ -43,4 +43,13 @@ public class CrewedVehicleWatcher extends Watcher { .stream() .anyMatch(mor -> mor.refersTo(crewer, game)); } + + public static int getCrewCount(Permanent vehicle, Game game) { + return game + .getState() + .getWatcher(CrewedVehicleWatcher.class) + .crewMap + .getOrDefault(new MageObjectReference(vehicle, game), Collections.emptySet()) + .size(); + } }