diff --git a/Mage.Sets/src/mage/cards/k/KeeperOfTheBeasts.java b/Mage.Sets/src/mage/cards/k/KeeperOfTheBeasts.java new file mode 100644 index 0000000000..cc4ccc8fcd --- /dev/null +++ b/Mage.Sets/src/mage/cards/k/KeeperOfTheBeasts.java @@ -0,0 +1,111 @@ +package mage.cards.k; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.constants.SubType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.filter.FilterOpponent; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.token.BeastToken2; +import mage.game.permanent.token.BeastToken4; +import mage.players.Player; +import mage.target.TargetPlayer; +import mage.target.common.TargetOpponent; + +/** + * + * @author noahg + */ +public final class KeeperOfTheBeasts extends CardImpl { + + public KeeperOfTheBeasts(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G}{G}"); + + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.WIZARD); + this.power = new MageInt(1); + this.toughness = new MageInt(2); + + // {G}, {tap}: Choose target opponent who controlled more creatures than you did as you activated this ability. Put a 2/2 green Beast creature token onto the battlefield. + Ability ability = new SimpleActivatedAbility(new CreateTokenEffect(new BeastToken4()).setText("Choose target opponent who controlled more creatures than you did as you activated this ability. Put a 2/2 green Beast creature token onto the battlefield."), + new ManaCostsImpl("{G}")); + ability.addCost(new TapSourceCost()); + ability.addTarget(new KeeperOfTheBeastsTarget()); + this.addAbility(ability); + } + + public KeeperOfTheBeasts(final KeeperOfTheBeasts card) { + super(card); + } + + @Override + public KeeperOfTheBeasts copy() { + return new KeeperOfTheBeasts(this); + } +} + +class KeeperOfTheBeastsTarget extends TargetPlayer { + + public KeeperOfTheBeastsTarget() { + super(1, 1, false, new FilterOpponent("opponent that controls more creatures than you")); + } + + public KeeperOfTheBeastsTarget(final KeeperOfTheBeastsTarget target) { + super(target); + } + + @Override + public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { + Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); + Set possibleTargets = new HashSet<>(); + int creaturesController = game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, sourceControllerId, game); + + for (UUID targetId : availablePossibleTargets) { + if (game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, targetId, game) > creaturesController) { + possibleTargets.add(targetId); + } + } + return possibleTargets; + } + + @Override + public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { + int count = 0; + MageObject targetSource = game.getObject(sourceId); + Player controller = game.getPlayer(sourceControllerId); + if (controller != null) { + for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { + Player player = game.getPlayer(playerId); + if (player != null + && game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, sourceControllerId, game) + < game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, playerId, game) + && !player.hasLeft() + && filter.match(player, sourceId, sourceControllerId, game) + && player.canBeTargetedBy(targetSource, sourceControllerId, game)) { + count++; + if (count >= this.minNumberOfTargets) { + return true; + } + } + } + } + return false; + } + + @Override + public KeeperOfTheBeastsTarget copy() { + return new KeeperOfTheBeastsTarget(this); + } +} + diff --git a/Mage.Sets/src/mage/sets/Exodus.java b/Mage.Sets/src/mage/sets/Exodus.java index 0322801819..c80118de2c 100644 --- a/Mage.Sets/src/mage/sets/Exodus.java +++ b/Mage.Sets/src/mage/sets/Exodus.java @@ -68,8 +68,9 @@ public final class Exodus extends ExpansionSet { cards.add(new SetCardInfo("Hatred", 64, Rarity.RARE, mage.cards.h.Hatred.class)); cards.add(new SetCardInfo("High Ground", 7, Rarity.UNCOMMON, mage.cards.h.HighGround.class)); cards.add(new SetCardInfo("Jackalope Herd", 111, Rarity.COMMON, mage.cards.j.JackalopeHerd.class)); + cards.add(new SetCardInfo("Keeper of the Beasts", 112, Rarity.UNCOMMON, mage.cards.k.KeeperOfTheBeasts.class)); cards.add(new SetCardInfo("Keeper of the Dead", 65, Rarity.UNCOMMON, mage.cards.k.KeeperOfTheDead.class)); - cards.add(new SetCardInfo("Keeper of the Light", 8, Rarity.UNCOMMON, mage.cards.k.KeeperOfTheLight.class)); + cards.add(new SetCardInfo("Keeper of the Light", 8, Rarity.UNCOMMON, mage.cards.k.KeeperOfTheLight.class)); cards.add(new SetCardInfo("Killer Whale", 37, Rarity.UNCOMMON, mage.cards.k.KillerWhale.class)); cards.add(new SetCardInfo("Kor Chant", 9, Rarity.COMMON, mage.cards.k.KorChant.class)); cards.add(new SetCardInfo("Mage il-Vec", 86, Rarity.COMMON, mage.cards.m.MageIlVec.class)); diff --git a/Mage/src/main/java/mage/game/permanent/token/BeastToken4.java b/Mage/src/main/java/mage/game/permanent/token/BeastToken4.java new file mode 100644 index 0000000000..d6b579b451 --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/BeastToken4.java @@ -0,0 +1,45 @@ + +package mage.game.permanent.token; + +import mage.MageInt; +import mage.constants.CardType; +import mage.constants.SubType; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public final class BeastToken4 extends TokenImpl { + + public BeastToken4() { + this(null, 0); + } + + public BeastToken4(String setCode) { + this(setCode, 0); + } + + public BeastToken4(String setCode, int tokenType) { + super("Beast", "2/2 green Beast creature token"); + setOriginalExpansionSetCode(setCode != null ? setCode : "EXO"); + cardType.add(CardType.CREATURE); + color.setGreen(true); + subtype.add(SubType.BEAST); + power = new MageInt(2); + toughness = new MageInt(2); + + } + + public BeastToken4(final BeastToken4 token) { + super(token); + } + + @Override + public BeastToken4 copy() { + return new BeastToken4(this); + } +}