From fd4a36788d70186d145904d2ed0a1fc95338d2dc Mon Sep 17 00:00:00 2001 From: theelk801 Date: Sat, 21 Jan 2023 11:50:50 -0500 Subject: [PATCH] [ONE] Implement Goliath Hatchery --- .../src/mage/cards/g/GoliathHatchery.java | 96 +++++++++++++++++++ .../src/mage/sets/PhyrexiaAllWillBeOne.java | 1 + .../token/PhyrexianBeastToxicToken.java | 41 ++++++++ 3 files changed, 138 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/GoliathHatchery.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/PhyrexianBeastToxicToken.java diff --git a/Mage.Sets/src/mage/cards/g/GoliathHatchery.java b/Mage.Sets/src/mage/cards/g/GoliathHatchery.java new file mode 100644 index 0000000000..dee49a09d6 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GoliathHatchery.java @@ -0,0 +1,96 @@ +package mage.cards.g; + +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.condition.common.CorruptedCondition; +import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.keyword.ToxicAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.PhyrexianBeastToxicToken; +import mage.game.permanent.token.PhyrexianGolemToken; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetControlledCreaturePermanent; +import mage.util.CardUtil; + +/** + * @author TheElk801 + */ +public final class GoliathHatchery extends CardImpl { + + public GoliathHatchery(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{4}{G}{G}"); + + // When Goliath Hatchery enters the battlefield, create two 3/3 green Phyrexian Beast creature tokens with toxic 1. + this.addAbility(new EntersBattlefieldTriggeredAbility( + new CreateTokenEffect(new PhyrexianBeastToxicToken(), 2) + )); + + // Corrupted -- At the beginning of your upkeep, if an opponent has three or more poison counters, choose a creature you control, then draw cards equal to its total toxic value. + this.addAbility(new ConditionalInterveningIfTriggeredAbility( + new BeginningOfUpkeepTriggeredAbility( + new GoliathHatcheryEffect(), TargetController.YOU, false + ), CorruptedCondition.instance, null + )); + } + + private GoliathHatchery(final GoliathHatchery card) { + super(card); + } + + @Override + public GoliathHatchery copy() { + return new GoliathHatchery(this); + } +} + +class GoliathHatcheryEffect extends OneShotEffect { + + GoliathHatcheryEffect() { + super(Outcome.Benefit); + staticText = "if an opponent has three or more poison counters, " + + "choose a creature you control, then draw cards equal to its total toxic value"; + } + + private GoliathHatcheryEffect(final GoliathHatcheryEffect effect) { + super(effect); + } + + @Override + public GoliathHatcheryEffect copy() { + return new GoliathHatcheryEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null || !game.getBattlefield().contains( + StaticFilters.FILTER_CONTROLLED_CREATURE, source, game, 1 + )) { + return false; + } + TargetPermanent target = new TargetControlledCreaturePermanent(); + target.setNotTarget(true); + player.choose(outcome, target, source, game); + Permanent permanent = game.getPermanent(target.getFirstTarget()); + if (permanent == null) { + return false; + } + int amount = CardUtil.castStream( + permanent.getAbilities(game).stream(), ToxicAbility.class + ).mapToInt(ToxicAbility::getAmount).sum(); + return amount > 0 && player.drawCards(amount, source, game) > 0; + } +} diff --git a/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java b/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java index 2a35cfcc10..8af19788f4 100644 --- a/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java +++ b/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java @@ -46,6 +46,7 @@ public final class PhyrexiaAllWillBeOne extends ExpansionSet { cards.add(new SetCardInfo("Feed the Infection", 93, Rarity.UNCOMMON, mage.cards.f.FeedTheInfection.class)); cards.add(new SetCardInfo("Forest", 276, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Furnace Skullbomb", 228, Rarity.COMMON, mage.cards.f.FurnaceSkullbomb.class)); + cards.add(new SetCardInfo("Goliath Hatchery", 408, Rarity.RARE, mage.cards.g.GoliathHatchery.class)); cards.add(new SetCardInfo("Graaz, Unstoppable Juggernaut", 229, Rarity.RARE, mage.cards.g.GraazUnstoppableJuggernaut.class)); cards.add(new SetCardInfo("Hexgold Halberd", 136, Rarity.UNCOMMON, mage.cards.h.HexgoldHalberd.class)); cards.add(new SetCardInfo("Incisor Glider", 15, Rarity.COMMON, mage.cards.i.IncisorGlider.class)); diff --git a/Mage/src/main/java/mage/game/permanent/token/PhyrexianBeastToxicToken.java b/Mage/src/main/java/mage/game/permanent/token/PhyrexianBeastToxicToken.java new file mode 100644 index 0000000000..d7c1fb2414 --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/PhyrexianBeastToxicToken.java @@ -0,0 +1,41 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.abilities.keyword.ToxicAbility; +import mage.constants.CardType; +import mage.constants.SubType; + +import java.util.Arrays; + +/** + * @author TheElk801 + */ +public final class PhyrexianBeastToxicToken extends TokenImpl { + + public PhyrexianBeastToxicToken() { + super("Phyrexian Golem Token", "3/3 green Phyrexian Beast creature token with toxic 1"); + color.setGreen(true); + cardType.add(CardType.CREATURE); + subtype.add(SubType.PHYREXIAN); + subtype.add(SubType.BEAST); + power = new MageInt(3); + toughness = new MageInt(3); + + addAbility(new ToxicAbility(1)); + + availableImageSetCodes = Arrays.asList("ONE"); + } + + public PhyrexianBeastToxicToken(final PhyrexianBeastToxicToken token) { + super(token); + } + + public PhyrexianBeastToxicToken copy() { + return new PhyrexianBeastToxicToken(this); + } + + @Override + public void setExpansionSetCodeForImage(String code) { + super.setExpansionSetCodeForImage(code); + } +}