From d74c2c8355c63b12994c1a3668c7a94f208d5252 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 21 Jun 2020 22:14:03 -0400 Subject: [PATCH] Implemented Tinybones, Trinket Thief --- .../mage/cards/t/TinybonesTrinketThief.java | 128 ++++++++++++++++++ Mage.Sets/src/mage/sets/Jumpstart.java | 1 + .../common/LoseLifeOpponentsEffect.java | 2 +- 3 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/t/TinybonesTrinketThief.java diff --git a/Mage.Sets/src/mage/cards/t/TinybonesTrinketThief.java b/Mage.Sets/src/mage/cards/t/TinybonesTrinketThief.java new file mode 100644 index 0000000000..8c5cfdfd5b --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TinybonesTrinketThief.java @@ -0,0 +1,128 @@ +package mage.cards.t; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.condition.Condition; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.LoseLifeSourceControllerEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.players.Player; +import mage.watchers.Watcher; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TinybonesTrinketThief extends CardImpl { + + public TinybonesTrinketThief(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.SKELETON); + this.subtype.add(SubType.ROGUE); + this.power = new MageInt(1); + this.toughness = new MageInt(2); + + // At the beginning of each end step, if an opponent discarded a card this turn, you draw a card and you lose 1 life. + Ability ability = new ConditionalInterveningIfTriggeredAbility( + new BeginningOfEndStepTriggeredAbility( + new DrawCardSourceControllerEffect(1), + TargetController.EACH_PLAYER, false + ), TinybonesTrinketThiefCondition.instance, "At the beginning of each end step, " + + "if an opponent discarded a card this turn, you draw a card and you lose 1 life." + ); + ability.addEffect(new LoseLifeSourceControllerEffect(1)); + this.addAbility(ability, new TinybonesTrinketThiefWatcher()); + + // {4}{B}{B}: Each opponent with no cards in hand loses 10 life. + this.addAbility(new SimpleActivatedAbility(new TinybonesTrinketThiefEffect(), new ManaCostsImpl("{4}{B}{B}"))); + } + + private TinybonesTrinketThief(final TinybonesTrinketThief card) { + super(card); + } + + @Override + public TinybonesTrinketThief copy() { + return new TinybonesTrinketThief(this); + } +} + +enum TinybonesTrinketThiefCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + TinybonesTrinketThiefWatcher watcher = game.getState().getWatcher(TinybonesTrinketThiefWatcher.class); + return watcher != null && watcher.checkPlayer(source.getControllerId()); + } +} + +class TinybonesTrinketThiefWatcher extends Watcher { + + private final Set playerSet = new HashSet<>(); + + TinybonesTrinketThiefWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.DISCARDED_CARD) { + playerSet.addAll(game.getOpponents(event.getPlayerId())); + } + } + + @Override + public void reset() { + playerSet.clear(); + super.reset(); + } + + boolean checkPlayer(UUID playerId) { + return playerSet.contains(playerId); + } +} + +class TinybonesTrinketThiefEffect extends OneShotEffect { + + TinybonesTrinketThiefEffect() { + super(Outcome.Benefit); + staticText = "each opponent with no cards in hand loses 10 life"; + } + + private TinybonesTrinketThiefEffect(final TinybonesTrinketThiefEffect effect) { + super(effect); + } + + @Override + public TinybonesTrinketThiefEffect copy() { + return new TinybonesTrinketThiefEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + for (UUID playerId : game.getOpponents(source.getControllerId())) { + Player player = game.getPlayer(source.getControllerId()); + if (player != null && player.getHand().isEmpty()) { + player.loseLife(10, game, false); + } + } + return true; + } +} +// tiny bones comin out my +// tiny bones comin out my mouth diff --git a/Mage.Sets/src/mage/sets/Jumpstart.java b/Mage.Sets/src/mage/sets/Jumpstart.java index cedf51fe57..344f54847e 100644 --- a/Mage.Sets/src/mage/sets/Jumpstart.java +++ b/Mage.Sets/src/mage/sets/Jumpstart.java @@ -426,6 +426,7 @@ public final class Jumpstart extends ExpansionSet { cards.add(new SetCardInfo("Thundering Spineback", 437, Rarity.UNCOMMON, mage.cards.t.ThunderingSpineback.class)); cards.add(new SetCardInfo("Tibalt's Rager", 366, Rarity.UNCOMMON, mage.cards.t.TibaltsRager.class)); cards.add(new SetCardInfo("Time to Feed", 438, Rarity.COMMON, mage.cards.t.TimeToFeed.class)); + cards.add(new SetCardInfo("Tinybones, Trinket Thief", 17, Rarity.MYTHIC, mage.cards.t.TinybonesTrinketThief.class)); cards.add(new SetCardInfo("Tithebearer Giant", 284, Rarity.COMMON, mage.cards.t.TithebearerGiant.class)); cards.add(new SetCardInfo("Torch Fiend", 367, Rarity.COMMON, mage.cards.t.TorchFiend.class)); cards.add(new SetCardInfo("Towering Titan", 31, Rarity.MYTHIC, mage.cards.t.ToweringTitan.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/LoseLifeOpponentsEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LoseLifeOpponentsEffect.java index ead8433dc7..eaa3c26e12 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/LoseLifeOpponentsEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/LoseLifeOpponentsEffect.java @@ -20,7 +20,7 @@ public class LoseLifeOpponentsEffect extends OneShotEffect { private DynamicValue amount; - public LoseLifeOpponentsEffect(int amount) { + publicLoseLifeOpponentsEffect(int amount) { this(StaticValue.get(amount)); }