From bad00742b2ad5cd3173b61d7f280c01b77b91b60 Mon Sep 17 00:00:00 2001 From: ciaccona007 Date: Sat, 9 Jan 2021 16:30:47 -0500 Subject: [PATCH] [KHM] Implement Giant's Amulet (#7357) --- Mage.Sets/src/mage/cards/g/GiantsAmulet.java | 105 ++++++++++++++++++ Mage.Sets/src/mage/sets/Kaldheim.java | 1 + .../permanent/token/GiantsAmuletToken.java | 26 +++++ 3 files changed, 132 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/GiantsAmulet.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/GiantsAmuletToken.java diff --git a/Mage.Sets/src/mage/cards/g/GiantsAmulet.java b/Mage.Sets/src/mage/cards/g/GiantsAmulet.java new file mode 100644 index 00000000000..1dd16107dbe --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GiantsAmulet.java @@ -0,0 +1,105 @@ +package mage.cards.g; + +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.InvertCondition; +import mage.abilities.condition.common.SourceTappedCondition; +import mage.abilities.costs.Cost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.decorator.ConditionalContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.continuous.BoostEquippedEffect; +import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; +import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; +import mage.abilities.keyword.EquipAbility; +import mage.abilities.keyword.HexproofAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.GiantsAmuletToken; +import mage.players.Player; + +import java.util.UUID; + +/** + * @author ciaccona007 + */ +public final class GiantsAmulet extends CardImpl { + + public GiantsAmulet(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{U}"); + + this.subtype.add(SubType.EQUIPMENT); + + // When Giant's Amulet enters the battlefield, you may pay {3}{U}. If you do, create a 4/4 blue Giant Wizard creature token, then attach Giant's Amulet to it. + this.addAbility(new EntersBattlefieldTriggeredAbility(new GiantsAmuletEffect())); + + // Equipped creature gets +0/+1 and has "This creature has hexproof as long as it's untapped." + Ability ability = new SimpleStaticAbility(new BoostEquippedEffect(0, 1)); + ability.addEffect(new GainAbilityAttachedEffect( + new SimpleStaticAbility(new ConditionalContinuousEffect( + new GainAbilitySourceEffect( + HexproofAbility.getInstance(), + Duration.WhileOnBattlefield + ), new InvertCondition(SourceTappedCondition.instance), + "{this} has hexproof as long as it's untapped") + ), AttachmentType.EQUIPMENT)); + this.addAbility(ability); + + // Equip {2} + this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(2))); + } + + private GiantsAmulet(final GiantsAmulet card) { + super(card); + } + + @Override + public GiantsAmulet copy() { + return new GiantsAmulet(this); + } +} + +class GiantsAmuletEffect extends OneShotEffect { + + GiantsAmuletEffect() { + super(Outcome.Benefit); + this.staticText = "you may pay {3}{U}. If you do, create a 4/4 blue Giant Wizard creature token, then attach Giant's Amulet to it."; + } + + GiantsAmuletEffect(final GiantsAmuletEffect effect) { + super(effect); + } + + @Override + public GiantsAmuletEffect copy() { + return new GiantsAmuletEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + + if (player != null) { + if (player.chooseUse(Outcome.BoostCreature, "Do you want to pay {3}{U}?", source, game)) { + Cost cost = new ManaCostsImpl<>("{3}{U}"); + if (cost.pay(source, game, source, source.getControllerId(), false, null)) { + CreateTokenEffect effect = new CreateTokenEffect(new GiantsAmuletToken()); + if (effect.apply(game, source)) { + Permanent p = game.getPermanent(effect.getLastAddedTokenId()); + if (p != null) { + p.addAttachment(source.getSourceId(), source, game); + return true; + } + } + } + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/Kaldheim.java b/Mage.Sets/src/mage/sets/Kaldheim.java index cbfe1b2d87a..0516cd31d55 100644 --- a/Mage.Sets/src/mage/sets/Kaldheim.java +++ b/Mage.Sets/src/mage/sets/Kaldheim.java @@ -67,6 +67,7 @@ public final class Kaldheim extends ExpansionSet { cards.add(new SetCardInfo("Firja, Judge of Valor", 209, Rarity.UNCOMMON, mage.cards.f.FirjaJudgeOfValor.class)); cards.add(new SetCardInfo("Forging the Tyrite Sword", 211, Rarity.UNCOMMON, mage.cards.f.ForgingTheTyriteSword.class)); cards.add(new SetCardInfo("Frost Bite", 138, Rarity.COMMON, mage.cards.f.FrostBite.class)); + cards.add(new SetCardInfo("Giant's Amulet", 59, Rarity.UNCOMMON, mage.cards.g.GiantsAmulet.class)); cards.add(new SetCardInfo("Giant's Grasp", 384, Rarity.UNCOMMON, mage.cards.g.GiantsGrasp.class)); cards.add(new SetCardInfo("Gilded Assault Cart", 390, Rarity.UNCOMMON, mage.cards.g.GildedAssaultCart.class)); cards.add(new SetCardInfo("Glacial Floodplain", 257, Rarity.COMMON, mage.cards.g.GlacialFloodplain.class)); diff --git a/Mage/src/main/java/mage/game/permanent/token/GiantsAmuletToken.java b/Mage/src/main/java/mage/game/permanent/token/GiantsAmuletToken.java new file mode 100644 index 00000000000..e5861ed5aec --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/GiantsAmuletToken.java @@ -0,0 +1,26 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.constants.CardType; +import mage.constants.SubType; + +public final class GiantsAmuletToken extends TokenImpl { + + public GiantsAmuletToken() { + super("Giant Wizard", "4/4 blue Giant Wizard creature token"); + cardType.add(CardType.CREATURE); + color.setBlue(true); + subtype.add(SubType.GIANT); + subtype.add(SubType.WIZARD); + power = new MageInt(4); + toughness = new MageInt(4); + } + + public GiantsAmuletToken(final GiantsAmuletToken token) { + super(token); + } + + public GiantsAmuletToken copy() { + return new GiantsAmuletToken(this); + } +}