From 6d3e29078c0466814d1b2cf42e1a34ad0714a997 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Sun, 10 Jan 2021 14:04:21 -0600 Subject: [PATCH] [KHM] Implemented Tyvar Kell --- Mage.Sets/src/mage/cards/t/TyvarKell.java | 74 +++++++++++++ Mage.Sets/src/mage/sets/Kaldheim.java | 1 + .../src/main/java/mage/constants/SubType.java | 1 + .../game/command/emblems/TyvarKellEmblem.java | 103 ++++++++++++++++++ 4 files changed, 179 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/TyvarKell.java create mode 100644 Mage/src/main/java/mage/game/command/emblems/TyvarKellEmblem.java diff --git a/Mage.Sets/src/mage/cards/t/TyvarKell.java b/Mage.Sets/src/mage/cards/t/TyvarKell.java new file mode 100644 index 00000000000..b23f20d568c --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TyvarKell.java @@ -0,0 +1,74 @@ +package mage.cards.t; + +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.LoyaltyAbility; +import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.GetEmblemEffect; +import mage.abilities.effects.common.UntapTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.abilities.keyword.DeathtouchAbility; +import mage.abilities.mana.BlackManaAbility; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.game.command.emblems.TyvarKellEmblem; +import mage.game.permanent.token.ElfToken; +import mage.target.TargetPermanent; + +/** + * + * @author weirddan455 + */ +public final class TyvarKell extends CardImpl { + + private static final FilterPermanent filter = new FilterPermanent(SubType.ELF, "Elves"); + private static final FilterPermanent filter2 = new FilterPermanent(SubType.ELF, "Elf"); + + public TyvarKell(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{2}{G}{G}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.TYVAR); + this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(3)); + + // Elves you control have "{T}: Add {B}." + this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect( + new BlackManaAbility(), Duration.WhileOnBattlefield, filter + ))); + + // +1: Put a +1/+1 counter on up to one target Elf. Untap it. It gains deathtouch until end of turn. + Ability ability = new LoyaltyAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance()), 1); + ability.addEffect(new UntapTargetEffect().setText("Untap it")); + ability.addEffect(new GainAbilityTargetEffect(DeathtouchAbility.getInstance(), Duration.EndOfTurn) + .setText("It gains deathtouch until end of turn") + ); + ability.addTarget(new TargetPermanent(0, 1, filter2, false)); + this.addAbility(ability); + + // 0: Create a 1/1 green Elf Warrior creature token. + this.addAbility(new LoyaltyAbility(new CreateTokenEffect(new ElfToken()), 0)); + + // −6: You get an emblem with "Whenever you cast an Elf spell, it gains haste until end of turn and you draw two cards." + this.addAbility(new LoyaltyAbility(new GetEmblemEffect(new TyvarKellEmblem()), -6)); + } + + private TyvarKell(final TyvarKell card) { + super(card); + } + + @Override + public TyvarKell copy() { + return new TyvarKell(this); + } +} diff --git a/Mage.Sets/src/mage/sets/Kaldheim.java b/Mage.Sets/src/mage/sets/Kaldheim.java index c2eb3dbf206..ca164306b73 100644 --- a/Mage.Sets/src/mage/sets/Kaldheim.java +++ b/Mage.Sets/src/mage/sets/Kaldheim.java @@ -119,6 +119,7 @@ public final class Kaldheim extends ExpansionSet { cards.add(new SetCardInfo("The World Tree", 275, Rarity.RARE, mage.cards.t.TheWorldTree.class)); cards.add(new SetCardInfo("Thornmantle Striker", 387, Rarity.UNCOMMON, mage.cards.t.ThornmantleStriker.class)); cards.add(new SetCardInfo("Toski, Bearer of Secrets", 197, Rarity.RARE, mage.cards.t.ToskiBearerOfSecrets.class)); + cards.add(new SetCardInfo("Tyvar Kell", 287, Rarity.MYTHIC, mage.cards.t.TyvarKell.class)); cards.add(new SetCardInfo("Undersea Invader", 78, Rarity.COMMON, mage.cards.u.UnderseaInvader.class)); cards.add(new SetCardInfo("Valkyrie Harbinger", 374, Rarity.RARE, mage.cards.v.ValkyrieHarbinger.class)); cards.add(new SetCardInfo("Varragoth, Bloodsky Sire", 115, Rarity.RARE, mage.cards.v.VarragothBloodskySire.class)); diff --git a/Mage/src/main/java/mage/constants/SubType.java b/Mage/src/main/java/mage/constants/SubType.java index 4682c8bda60..5fb465db118 100644 --- a/Mage/src/main/java/mage/constants/SubType.java +++ b/Mage/src/main/java/mage/constants/SubType.java @@ -433,6 +433,7 @@ public enum SubType { TEYO("Teyo", SubTypeSet.PlaneswalkerType), TEZZERET("Tezzeret", SubTypeSet.PlaneswalkerType), TIBALT("Tibalt", SubTypeSet.PlaneswalkerType), + TYVAR("Tyvar", SubTypeSet.PlaneswalkerType), UGIN("Ugin", SubTypeSet.PlaneswalkerType), URZA("Urza", SubTypeSet.PlaneswalkerType, true), // Unstable VENSER("Venser", SubTypeSet.PlaneswalkerType), diff --git a/Mage/src/main/java/mage/game/command/emblems/TyvarKellEmblem.java b/Mage/src/main/java/mage/game/command/emblems/TyvarKellEmblem.java new file mode 100644 index 00000000000..6d7e144176f --- /dev/null +++ b/Mage/src/main/java/mage/game/command/emblems/TyvarKellEmblem.java @@ -0,0 +1,103 @@ +package mage.game.command.emblems; + +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.abilities.common.SpellCastControllerTriggeredAbility; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.keyword.HasteAbility; +import mage.cards.Card; +import mage.constants.*; +import mage.filter.FilterSpell; +import mage.game.Game; +import mage.game.command.Emblem; +import mage.game.permanent.Permanent; +import mage.game.stack.Spell; + +import java.util.Iterator; +import java.util.UUID; + +/** + * + * @author weirddan455 + */ +public final class TyvarKellEmblem extends Emblem { + + private static final FilterSpell filter = new FilterSpell("an Elf spell"); + + static { + filter.add(SubType.ELF.getPredicate()); + } + + // −6: You get an emblem with "Whenever you cast an Elf spell, it gains haste until end of turn and you draw two cards." + public TyvarKellEmblem() { + this.setName("Emblem Tyvar"); + this.setExpansionSetCodeForImage("KHM"); + Ability ability = new SpellCastControllerTriggeredAbility(Zone.COMMAND, new TyvarKellEmblemEffect( + HasteAbility.getInstance(), Duration.EndOfTurn), filter, false, true + ); + ability.addEffect(new DrawCardSourceControllerEffect(2).setText("and you draw two cards")); + this.getAbilities().add(ability); + } +} + +class TyvarKellEmblemEffect extends ContinuousEffectImpl { + + protected Ability ability; + + public TyvarKellEmblemEffect(Ability ability, Duration duration) { + super(duration, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility); + this.ability = ability; + this.generateGainAbilityDependencies(ability, null); + this.staticText = "it gains haste until end of turn"; + } + + public TyvarKellEmblemEffect(final TyvarKellEmblemEffect effect) { + super(effect); + this.ability = effect.ability.copy(); + } + + @Override + public TyvarKellEmblemEffect copy() { + return new TyvarKellEmblemEffect(this); + } + + @Override + public void init (Ability source, Game game) { + super.init(source, game); + if (this.affectedObjectsSet) { + Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source)); + if (spell != null) { + Card card = game.getCard(spell.getSourceId()); + if (card != null) { + affectedObjectList.add(new MageObjectReference(card, game)); + } + } + } + } + + @Override + public boolean apply(Game game, Ability source) { + if (this.affectedObjectsSet) { + for (Iterator it = affectedObjectList.iterator(); it.hasNext(); ) { + UUID sourceId = it.next().getSourceId(); + Card card = game.getCard(sourceId); + Permanent perm = game.getPermanent(sourceId); + if (card != null && !card.hasAbility(ability, game)) { + game.getState().addOtherAbility(card, ability); + } + if (perm != null) { + perm.addAbility(ability, source.getSourceId(), game); + } + if (card == null && perm == null) { + it.remove(); + if (affectedObjectList.isEmpty()) { + discard(); + } + } + } + return true; + } + return false; + } +}