[KHM] Implemented Koll, the Forgemaster (#7359)

This commit is contained in:
Daniel Bomar 2021-01-09 21:37:35 -06:00 committed by GitHub
parent f38697194a
commit 59da4b15f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 112 additions and 0 deletions

View file

@ -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<Permanent> {
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<Permanent> {
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";
}
}

View file

@ -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));