From f67c8e9e7416b29b1491d55c9622369c6533d74d Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 12 Apr 2021 18:35:01 -0400 Subject: [PATCH] [C21] Implemented Gyome, Master Chef --- .../src/mage/cards/g/GyomeMasterChef.java | 132 ++++++++++++++++++ .../src/mage/sets/Commander2021Edition.java | 1 + 2 files changed, 133 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/GyomeMasterChef.java diff --git a/Mage.Sets/src/mage/cards/g/GyomeMasterChef.java b/Mage.Sets/src/mage/cards/g/GyomeMasterChef.java new file mode 100644 index 0000000000..d8a3d1d251 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GyomeMasterChef.java @@ -0,0 +1,132 @@ +package mage.cards.g; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.TapTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.abilities.keyword.IndestructibleAbility; +import mage.abilities.keyword.TrampleAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.common.FilterControlledPermanent; +import mage.game.Game; +import mage.game.events.EntersTheBattlefieldEvent; +import mage.game.events.GameEvent; +import mage.game.permanent.PermanentToken; +import mage.game.permanent.token.FoodToken; +import mage.target.common.TargetControlledPermanent; +import mage.target.common.TargetCreaturePermanent; +import mage.watchers.Watcher; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class GyomeMasterChef extends CardImpl { + + private static final FilterControlledPermanent filter = new FilterControlledPermanent(SubType.FOOD, "a Food"); + private static final Hint hint = new ValueHint("Nontoken creatures entered this turn", GyomeMasterChefValue.instance); + + public GyomeMasterChef(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}{G}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.TROLL); + this.subtype.add(SubType.WARLOCK); + this.power = new MageInt(5); + this.toughness = new MageInt(3); + + // Trample + this.addAbility(TrampleAbility.getInstance()); + + // At the beginning of your end step, create a number of Food tokens equal to the number of nontoken creatures you had enter the battlefield under your control this turn. + this.addAbility(new BeginningOfEndStepTriggeredAbility( + new CreateTokenEffect( + new FoodToken(), GyomeMasterChefValue.instance + ).setText("create a number of Food tokens equal to the number of nontoken creatures " + + "you had enter the battlefield under your control this turn"), + TargetController.YOU, false + ).addHint(hint), new GyomeMasterChefWatcher()); + + // {1}, Sacrifice a Food: Target creature gains indestructible until end of turn. Tap it. + Ability ability = new SimpleActivatedAbility(new GainAbilityTargetEffect( + IndestructibleAbility.getInstance(), Duration.EndOfTurn + ), new GenericManaCost(1)); + ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(filter))); + ability.addEffect(new TapTargetEffect().setText("it")); + ability.addTarget(new TargetCreaturePermanent()); + this.addAbility(ability); + } + + private GyomeMasterChef(final GyomeMasterChef card) { + super(card); + } + + @Override + public GyomeMasterChef copy() { + return new GyomeMasterChef(this); + } +} + +enum GyomeMasterChefValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + return GyomeMasterChefWatcher.getValue(sourceAbility.getControllerId(), game); + } + + @Override + public GyomeMasterChefValue copy() { + return instance; + } + + @Override + public String getMessage() { + return ""; + } +} + +class GyomeMasterChefWatcher extends Watcher { + + private final Map playerMap = new HashMap<>(); + + GyomeMasterChefWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD + && !(((EntersTheBattlefieldEvent) event).getTarget() instanceof PermanentToken)) { + playerMap.compute(event.getPlayerId(), (u, i) -> i != null ? Integer.sum(i, 1) : 1); + } + } + + @Override + public void reset() { + super.reset(); + playerMap.clear(); + } + + static int getValue(UUID playerId, Game game) { + GyomeMasterChefWatcher watcher = game.getState().getWatcher(GyomeMasterChefWatcher.class); + if (watcher == null) { + return 0; + } + return watcher != null ? watcher.playerMap.getOrDefault(playerId, 0) : 0; + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2021Edition.java b/Mage.Sets/src/mage/sets/Commander2021Edition.java index 2f4257c079..0f4d2d4fb6 100644 --- a/Mage.Sets/src/mage/sets/Commander2021Edition.java +++ b/Mage.Sets/src/mage/sets/Commander2021Edition.java @@ -106,6 +106,7 @@ public final class Commander2021Edition extends ExpansionSet { cards.add(new SetCardInfo("Gideon, Champion of Justice", 93, Rarity.MYTHIC, mage.cards.g.GideonChampionOfJustice.class)); cards.add(new SetCardInfo("Great Furnace", 292, Rarity.COMMON, mage.cards.g.GreatFurnace.class)); cards.add(new SetCardInfo("Guardian Augmenter", 62, Rarity.RARE, mage.cards.g.GuardianAugmenter.class)); + cards.add(new SetCardInfo("Gyome, Master Chef", 5, Rarity.MYTHIC, mage.cards.g.GyomeMasterChef.class)); cards.add(new SetCardInfo("Healing Technique", 63, Rarity.RARE, mage.cards.h.HealingTechnique.class)); cards.add(new SetCardInfo("Hedron Archive", 244, Rarity.UNCOMMON, mage.cards.h.HedronArchive.class)); cards.add(new SetCardInfo("Hellkite Igniter", 171, Rarity.RARE, mage.cards.h.HellkiteIgniter.class));