diff --git a/Mage.Sets/src/mage/cards/e/EivorWolfKissed.java b/Mage.Sets/src/mage/cards/e/EivorWolfKissed.java new file mode 100644 index 00000000000..dde65298155 --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/EivorWolfKissed.java @@ -0,0 +1,131 @@ +package mage.cards.e; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.assignment.common.TypeAssignment; +import mage.abilities.common.DealsCombatDamageTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.HasteAbility; +import mage.abilities.keyword.TrampleAbility; +import mage.cards.*; +import mage.constants.*; +import mage.filter.FilterCard; +import mage.filter.predicate.Predicates; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class EivorWolfKissed extends CardImpl { + + public EivorWolfKissed(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}{G}{W}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.ASSASSIN); + this.subtype.add(SubType.WARRIOR); + this.power = new MageInt(7); + this.toughness = new MageInt(6); + + // Trample + this.addAbility(TrampleAbility.getInstance()); + + // Haste + this.addAbility(HasteAbility.getInstance()); + + // Whenever Eivor, Wolf-Kissed deals combat damage to a player, you mill that many cards. You may put a Saga card and/or a land card from among them onto the battlefield. + this.addAbility(new DealsCombatDamageTriggeredAbility(new EivorWolfKissedEffect(), false)); + } + + private EivorWolfKissed(final EivorWolfKissed card) { + super(card); + } + + @Override + public EivorWolfKissed copy() { + return new EivorWolfKissed(this); + } +} + +class EivorWolfKissedEffect extends OneShotEffect { + + EivorWolfKissedEffect() { + super(Outcome.Benefit); + staticText = "you mill that many cards. You may put a Saga card " + + "and/or a land card from among them onto the battlefield"; + } + + private EivorWolfKissedEffect(final EivorWolfKissedEffect effect) { + super(effect); + } + + @Override + public EivorWolfKissedEffect copy() { + return new EivorWolfKissedEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + int damage = (Integer) getValue("damage"); + if (player == null || damage < 1) { + return false; + } + Cards cards = player.millCards(damage, source, game); + TargetCard target = new EivorWolfKissedTarget(); + player.choose(outcome, cards, target, source, game); + player.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game); + return true; + } +} + +class EivorWolfKissedTarget extends TargetCard { + + private static final FilterCard filter + = new FilterCard("a Saga card and/or a land card"); + + static { + filter.add(Predicates.or( + SubType.SAGA.getPredicate(), + CardType.LAND.getPredicate() + )); + } + + private static final TypeAssignment typeAssigner = new TypeAssignment(SubType.SAGA, CardType.LAND); + + EivorWolfKissedTarget() { + super(0, 2, Zone.ALL, filter); + notTarget = true; + } + + private EivorWolfKissedTarget(final EivorWolfKissedTarget target) { + super(target); + } + + @Override + public EivorWolfKissedTarget copy() { + return new EivorWolfKissedTarget(this); + } + + @Override + public boolean canTarget(UUID playerId, UUID id, Ability source, Game game) { + if (!super.canTarget(playerId, id, source, game)) { + return false; + } + Card card = game.getCard(id); + if (card == null) { + return false; + } + if (this.getTargets().isEmpty()) { + return true; + } + Cards cards = new CardsImpl(this.getTargets()); + cards.add(card); + return typeAssigner.getRoleCount(cards, game) >= cards.size(); + } +} diff --git a/Mage.Sets/src/mage/sets/AssassinsCreed.java b/Mage.Sets/src/mage/sets/AssassinsCreed.java index 3c8b67d16bc..131f5c0545e 100644 --- a/Mage.Sets/src/mage/sets/AssassinsCreed.java +++ b/Mage.Sets/src/mage/sets/AssassinsCreed.java @@ -40,6 +40,7 @@ public final class AssassinsCreed extends ExpansionSet { cards.add(new SetCardInfo("Detained by Legionnaires", 277, Rarity.COMMON, mage.cards.d.DetainedByLegionnaires.class)); cards.add(new SetCardInfo("Eagle Vision", 17, Rarity.UNCOMMON, mage.cards.e.EagleVision.class)); cards.add(new SetCardInfo("Eivor, Battle-Ready", 274, Rarity.MYTHIC, mage.cards.e.EivorBattleReady.class)); + cards.add(new SetCardInfo("Eivor, Wolf-Kissed", 54, Rarity.MYTHIC, mage.cards.e.EivorWolfKissed.class)); cards.add(new SetCardInfo("Escarpment Fortress", 278, Rarity.RARE, mage.cards.e.EscarpmentFortress.class)); cards.add(new SetCardInfo("Ezio, Blade of Vengeance", 275, Rarity.MYTHIC, mage.cards.e.EzioBladeOfVengeance.class)); cards.add(new SetCardInfo("Fatal Push", 90, Rarity.UNCOMMON, mage.cards.f.FatalPush.class)); diff --git a/Mage/src/main/java/mage/abilities/assignment/common/TypeAssignment.java b/Mage/src/main/java/mage/abilities/assignment/common/TypeAssignment.java new file mode 100644 index 00000000000..216eac4f8ae --- /dev/null +++ b/Mage/src/main/java/mage/abilities/assignment/common/TypeAssignment.java @@ -0,0 +1,24 @@ +package mage.abilities.assignment.common; + +import mage.abilities.assignment.RoleAssignment; +import mage.cards.Card; +import mage.constants.MagicType; +import mage.game.Game; + +import java.util.Set; +import java.util.stream.Collectors; + +public class TypeAssignment extends RoleAssignment { + + public TypeAssignment(MagicType... types) { + super(types); + } + + @Override + protected Set makeSet(Card card, Game game) { + return attributes + .stream() + .filter(type -> type.checkObject(card, game)) + .collect(Collectors.toSet()); + } +} diff --git a/Mage/src/main/java/mage/constants/CardType.java b/Mage/src/main/java/mage/constants/CardType.java index f372fd82caf..7f8874dcd9e 100644 --- a/Mage/src/main/java/mage/constants/CardType.java +++ b/Mage/src/main/java/mage/constants/CardType.java @@ -11,7 +11,7 @@ import java.util.List; /** * @author North */ -public enum CardType { +public enum CardType implements MagicType { ARTIFACT("Artifact", true, true), BATTLE("Battle", true, true), CONSPIRACY("Conspiracy", false, false), @@ -49,6 +49,11 @@ public enum CardType { return text.endsWith("y") ? text.substring(0, text.length() - 1) + "ies" : text + 's'; } + @Override + public boolean checkObject(MageObject mageObject, Game game) { + return mageObject != null && mageObject.getCardType(game).contains(this); + } + public static CardType fromString(String value) { for (CardType ct : CardType.values()) { if (ct.toString().equals(value)) { diff --git a/Mage/src/main/java/mage/constants/MagicType.java b/Mage/src/main/java/mage/constants/MagicType.java new file mode 100644 index 00000000000..d04b3319403 --- /dev/null +++ b/Mage/src/main/java/mage/constants/MagicType.java @@ -0,0 +1,12 @@ +package mage.constants; + +import mage.MageObject; +import mage.game.Game; + +/** + * @author TheElk801 + */ +public interface MagicType { + + boolean checkObject(MageObject mageObject, Game game); +} diff --git a/Mage/src/main/java/mage/constants/SubType.java b/Mage/src/main/java/mage/constants/SubType.java index 1f4a6d5181c..8645cf62a10 100644 --- a/Mage/src/main/java/mage/constants/SubType.java +++ b/Mage/src/main/java/mage/constants/SubType.java @@ -7,7 +7,7 @@ import mage.game.Game; import java.util.*; import java.util.stream.Collectors; -public enum SubType { +public enum SubType implements MagicType { //205.3k Instants and sorceries share their lists of subtypes; these subtypes are called spell types. ADVENTURE("Adventure", SubTypeSet.SpellType), @@ -578,6 +578,11 @@ public enum SubType { this.predicate = new SubTypePredicate(this); } + @Override + public boolean checkObject(MageObject mageObject, Game game) { + return mageObject != null && mageObject.hasSubtype(this, game); + } + public String getDescription() { return description; } diff --git a/Mage/src/main/java/mage/constants/SuperType.java b/Mage/src/main/java/mage/constants/SuperType.java index 90b67bd68c9..059135fb752 100644 --- a/Mage/src/main/java/mage/constants/SuperType.java +++ b/Mage/src/main/java/mage/constants/SuperType.java @@ -7,7 +7,7 @@ import mage.game.Game; /** * Created by IGOUDT on 26-3-2017. */ -public enum SuperType { +public enum SuperType implements MagicType { BASIC("Basic"), ELITE("Elite"), @@ -51,4 +51,9 @@ public enum SuperType { public SuperTypePredicate getPredicate() { return predicate; } + + @Override + public boolean checkObject(MageObject mageObject, Game game) { + return mageObject != null && mageObject.getSuperType(game).contains(this); + } }