Implement Keeper of the Beasts

This commit is contained in:
Noah Gleason 2018-06-27 22:02:53 -04:00
parent aea831aeff
commit e2da104d6d
No known key found for this signature in database
GPG key ID: EC030EC6B0650A40
3 changed files with 158 additions and 1 deletions

View file

@ -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<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
Set<UUID> 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);
}
}

View file

@ -68,6 +68,7 @@ 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("Killer Whale", 37, Rarity.UNCOMMON, mage.cards.k.KillerWhale.class));

View file

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