From 59da4b15f6bfd75ca53b9be9a0fcc7189a0aa912 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Sat, 9 Jan 2021 21:37:35 -0600 Subject: [PATCH] [KHM] Implemented Koll, the Forgemaster (#7359) --- .../src/mage/cards/k/KollTheForgemaster.java | 111 ++++++++++++++++++ Mage.Sets/src/mage/sets/Kaldheim.java | 1 + 2 files changed, 112 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/k/KollTheForgemaster.java diff --git a/Mage.Sets/src/mage/cards/k/KollTheForgemaster.java b/Mage.Sets/src/mage/cards/k/KollTheForgemaster.java new file mode 100644 index 0000000000..c67001d66b --- /dev/null +++ b/Mage.Sets/src/mage/cards/k/KollTheForgemaster.java @@ -0,0 +1,111 @@ +package mage.cards.k; + +import java.util.Objects; +import java.util.UUID; +import mage.MageInt; +import mage.MageObject; +import mage.abilities.common.DiesCreatureTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.ReturnToHandTargetEffect; +import mage.abilities.effects.common.continuous.BoostControlledEffect; +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.filter.common.FilterControlledCreaturePermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicate; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.permanent.AnotherPredicate; +import mage.filter.predicate.permanent.EnchantedPredicate; +import mage.filter.predicate.permanent.EquippedPredicate; +import mage.filter.predicate.permanent.TokenPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author weirddan455 + */ +public final class KollTheForgemaster extends CardImpl { + + private static final FilterControlledCreaturePermanent filter + = new FilterControlledCreaturePermanent("another nontoken creature you control"); + private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent(); + + static { + filter.add(AnotherPredicate.instance); + filter.add(Predicates.not(TokenPredicate.instance)); + filter.add(Predicates.or(KollTheForgemasterEnchantedPredicate.instance, KollTheForgemasterEquippedPredicate.instance)); + filter2.add(TokenPredicate.instance); + filter2.add(Predicates.or(EnchantedPredicate.instance, EquippedPredicate.instance)); + } + + public KollTheForgemaster(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}{W}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.DWARF); + this.subtype.add(SubType.WARRIOR); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Whenever another nontoken creature you control dies, if it was enchanted or equipped, return it to its owner's hand. + this.addAbility(new DiesCreatureTriggeredAbility(new ReturnToHandTargetEffect() + .setText("if it was enchanted or equipped, return it to its owner's hand"), false, filter, true + )); + + // Creature tokens you control that are enchanted or equipped get +1/+1. + this.addAbility(new SimpleStaticAbility(new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filter2) + .setText("Creature tokens you control that are enchanted or equipped get +1/+1") + )); + } + + private KollTheForgemaster(final KollTheForgemaster card) { + super(card); + } + + @Override + public KollTheForgemaster copy() { + return new KollTheForgemaster(this); + } +} + +// Custom predicates call getPermanentOrLKIBattlefield (needed for the death trigger to work correctly) +enum KollTheForgemasterEnchantedPredicate implements Predicate { + instance; + + @Override + public boolean apply(Permanent input, Game game) { + return input.getAttachments() + .stream() + .map(game::getPermanentOrLKIBattlefield) + .filter(Objects::nonNull) + .anyMatch(MageObject::isEnchantment); + } + + @Override + public String toString() { + return "Enchanted"; + } +} + +enum KollTheForgemasterEquippedPredicate implements Predicate { + instance; + + @Override + public boolean apply(Permanent input, Game game) { + return input.getAttachments() + .stream() + .map(game::getPermanentOrLKIBattlefield) + .filter(Objects::nonNull) + .anyMatch(attachment -> attachment.hasSubtype(SubType.EQUIPMENT, game)); + } + + @Override + public String toString() { + return "equipped"; + } +} diff --git a/Mage.Sets/src/mage/sets/Kaldheim.java b/Mage.Sets/src/mage/sets/Kaldheim.java index 275f4782ad..1707a2dcc6 100644 --- a/Mage.Sets/src/mage/sets/Kaldheim.java +++ b/Mage.Sets/src/mage/sets/Kaldheim.java @@ -86,6 +86,7 @@ public final class Kaldheim extends ExpansionSet { cards.add(new SetCardInfo("Inga Rune-Eyes", 64, Rarity.UNCOMMON, mage.cards.i.IngaRuneEyes.class)); cards.add(new SetCardInfo("Invasion of the Giants", 215, Rarity.UNCOMMON, mage.cards.i.InvasionOfTheGiants.class)); cards.add(new SetCardInfo("Kaya the Inexorable", 218, Rarity.MYTHIC, mage.cards.k.KayaTheInexorable.class)); + cards.add(new SetCardInfo("Koll, the Forgemaster", 220, Rarity.UNCOMMON, mage.cards.k.KollTheForgemaster.class)); cards.add(new SetCardInfo("Koma's Faithful", 102, Rarity.COMMON, mage.cards.k.KomasFaithful.class)); cards.add(new SetCardInfo("Magda, Brazen Outlaw", 142, Rarity.RARE, mage.cards.m.MagdaBrazenOutlaw.class)); cards.add(new SetCardInfo("Masked Vandal", 184, Rarity.COMMON, mage.cards.m.MaskedVandal.class));