From 160f14eed19e0b930c6845d46edcfd3dd8ead22c Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 15 Nov 2015 18:54:26 +0100 Subject: [PATCH] [C15] Oreskos Explorer, Bastion Protector and Dawnbreak Reclaimer. --- .../sets/commander2015/BastionProtector.java | 82 +++++++++++ .../commander2015/DawnbreakReclaimer.java | 135 ++++++++++++++++++ .../sets/commander2015/OreskosExplorer.java | 129 +++++++++++++++++ .../mage/sets/magic2013/BoundlessRealms.java | 39 ++--- .../permanent/CommanderPredicate.java | 32 +++++ 5 files changed, 390 insertions(+), 27 deletions(-) create mode 100644 Mage.Sets/src/mage/sets/commander2015/BastionProtector.java create mode 100644 Mage.Sets/src/mage/sets/commander2015/DawnbreakReclaimer.java create mode 100644 Mage.Sets/src/mage/sets/commander2015/OreskosExplorer.java create mode 100644 Mage/src/mage/filter/predicate/permanent/CommanderPredicate.java diff --git a/Mage.Sets/src/mage/sets/commander2015/BastionProtector.java b/Mage.Sets/src/mage/sets/commander2015/BastionProtector.java new file mode 100644 index 00000000000..0293878ca10 --- /dev/null +++ b/Mage.Sets/src/mage/sets/commander2015/BastionProtector.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.commander2015; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.continuous.BoostControlledEffect; +import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; +import mage.abilities.keyword.IndestructibleAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.CommanderPredicate; + +/** + * + * @author LevelX2 + */ +public class BastionProtector extends CardImpl { + + private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("Commander creatures you control"); + + static { + filter.add(new CommanderPredicate()); + } + + public BastionProtector(UUID ownerId) { + super(ownerId, 1, "Bastion Protector", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{W}"); + this.expansionSetCode = "C15"; + this.subtype.add("Human"); + this.subtype.add("Soldier"); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // Commander creatures you control get +2/+2 and have indestructible. + Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(2, 2, Duration.WhileOnBattlefield, filter)); + Effect effect = new GainAbilityControlledEffect(IndestructibleAbility.getInstance(), Duration.WhileOnBattlefield, filter); + effect.setText("and have indestructible"); + ability.addEffect(effect); + this.addAbility(ability); + } + + public BastionProtector(final BastionProtector card) { + super(card); + } + + @Override + public BastionProtector copy() { + return new BastionProtector(this); + } +} diff --git a/Mage.Sets/src/mage/sets/commander2015/DawnbreakReclaimer.java b/Mage.Sets/src/mage/sets/commander2015/DawnbreakReclaimer.java new file mode 100644 index 00000000000..6e47df60283 --- /dev/null +++ b/Mage.Sets/src/mage/sets/commander2015/DawnbreakReclaimer.java @@ -0,0 +1,135 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.commander2015; + +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.BeginningOfEndStepTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.filter.common.FilterCreatureCard; +import mage.filter.predicate.other.OwnerIdPredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCardInGraveyard; +import mage.target.common.TargetCardInOpponentsGraveyard; +import mage.util.MessageToClient; + +/** + * + * @author LevelX2 + */ +public class DawnbreakReclaimer extends CardImpl { + + public DawnbreakReclaimer(UUID ownerId) { + super(ownerId, 2, "Dawnbreak Reclaimer", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{4}{W}{W}"); + this.expansionSetCode = "C15"; + this.subtype.add("Angel"); + this.power = new MageInt(5); + this.toughness = new MageInt(5); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + // At the beginning of your end step, choose a creature card in an opponent's graveyard, then that player chooses a creature card in your graveyard. + // You may return those cards to the battlefield under their owners' control. + this.addAbility(new BeginningOfEndStepTriggeredAbility(new DawnbreakReclaimerEffect(), TargetController.YOU, false)); + } + + public DawnbreakReclaimer(final DawnbreakReclaimer card) { + super(card); + } + + @Override + public DawnbreakReclaimer copy() { + return new DawnbreakReclaimer(this); + } +} + +class DawnbreakReclaimerEffect extends OneShotEffect { + + public DawnbreakReclaimerEffect() { + super(Outcome.Detriment); + this.staticText = "choose a creature card in an opponent's graveyard, then that player chooses a creature card in your graveyard. You may return those cards to the battlefield under their owners' control"; + } + + public DawnbreakReclaimerEffect(final DawnbreakReclaimerEffect effect) { + super(effect); + } + + @Override + public DawnbreakReclaimerEffect copy() { + return new DawnbreakReclaimerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (controller != null && sourceObject != null) { + TargetCardInOpponentsGraveyard targetCreature = new TargetCardInOpponentsGraveyard(new FilterCreatureCard("a creature card in an opponent's graveyard")); + if (controller.choose(Outcome.Detriment, targetCreature, source.getSourceId(), game)) { + Card creatureCard = game.getCard(targetCreature.getFirstTarget()); + Player opponent = game.getPlayer(creatureCard.getOwnerId()); + if (opponent != null) { + game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen " + creatureCard.getIdName() + " of " + opponent.getLogName()); + FilterCreatureCard filter = new FilterCreatureCard("a creature card in " + controller.getName() + "'s the graveyard"); + filter.add(new OwnerIdPredicate(controller.getId())); + TargetCardInGraveyard targetCard = new TargetCardInGraveyard(filter); + targetCard.setNotTarget(true); + if (opponent.choose(outcome, targetCard, source.getSourceId(), game)) { + Card controllerCreatureCard = game.getCard(targetCard.getFirstTarget()); + if (controllerCreatureCard != null) { + MessageToClient message = new MessageToClient("Return those cards to the battlefield under their owners' control?", + "Opponent's creature card: " + creatureCard.getLogName() + " - Your creature: " + controllerCreatureCard.getLogName()); + if (controller.chooseUse(outcome, message, source, game)) { + Set cards = new HashSet<>(); + cards.add(creatureCard); + cards.add(controllerCreatureCard); + opponent.moveCards(cards, Zone.BATTLEFIELD, source, game, false, false, true, null); + } + } + } + } + } + return true; + } + return false; + + } +} diff --git a/Mage.Sets/src/mage/sets/commander2015/OreskosExplorer.java b/Mage.Sets/src/mage/sets/commander2015/OreskosExplorer.java new file mode 100644 index 00000000000..2eaff4701ed --- /dev/null +++ b/Mage.Sets/src/mage/sets/commander2015/OreskosExplorer.java @@ -0,0 +1,129 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.commander2015; + +import java.util.UUID; +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.filter.common.FilterBasicLandCard; +import mage.filter.common.FilterLandPermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCardInLibrary; + +/** + * + * @author LevelX2 + */ +public class OreskosExplorer extends CardImpl { + + public OreskosExplorer(UUID ownerId) { + super(ownerId, 6, "Oreskos Explorer", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{W}"); + this.expansionSetCode = "C15"; + this.subtype.add("Cat"); + this.subtype.add("Scout"); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // When Oreskos Explorer enters the battlefield, search your library for up to X Plains cards, + // where X is the number of players who control more lands than you. Reveal those cards, put them into your hand, then shuffle your library. + this.addAbility(new EntersBattlefieldTriggeredAbility(new OreskosExplorerEffect())); + + } + + public OreskosExplorer(final OreskosExplorer card) { + super(card); + } + + @Override + public OreskosExplorer copy() { + return new OreskosExplorer(this); + } +} + +class OreskosExplorerEffect extends OneShotEffect { + + public OreskosExplorerEffect() { + super(Outcome.PutLandInPlay); + this.staticText = "search your library for up to X Plains cards, where X is the number of players who control more lands than you. Reveal those cards, put them into your hand, then shuffle your library"; + } + + public OreskosExplorerEffect(final OreskosExplorerEffect effect) { + super(effect); + } + + @Override + public OreskosExplorerEffect copy() { + return new OreskosExplorerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (controller == null || sourceObject == null) { + return false; + } + + int controllerLands = game.getBattlefield().countAll(new FilterLandPermanent(), controller.getId(), game); + int landsToSearch = 0; + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { + if (!playerId.equals(controller.getId())) { + if (controllerLands < game.getBattlefield().countAll(new FilterLandPermanent(), playerId, game)) { + landsToSearch++; + } + } + } + if (landsToSearch > 0) { + FilterBasicLandCard filterPlains = new FilterBasicLandCard("up to " + landsToSearch + " Plains cards"); + filterPlains.add(new ControllerPredicate(TargetController.YOU)); + filterPlains.add(new SubtypePredicate("Plains")); + TargetCardInLibrary target = new TargetCardInLibrary(0, landsToSearch, filterPlains); + if (controller.searchLibrary(target, game)) { + Cards cards = new CardsImpl(target.getTargets()); + controller.revealCards(sourceObject.getIdName(), cards, game); + controller.moveCards(cards.getCards(game), Zone.HAND, source, game); + } + } + controller.shuffleLibrary(game); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/magic2013/BoundlessRealms.java b/Mage.Sets/src/mage/sets/magic2013/BoundlessRealms.java index 9896e6a5422..c4b28fababa 100644 --- a/Mage.Sets/src/mage/sets/magic2013/BoundlessRealms.java +++ b/Mage.Sets/src/mage/sets/magic2013/BoundlessRealms.java @@ -28,21 +28,20 @@ package mage.sets.magic2013; import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.TargetController; import mage.constants.Zone; -import mage.abilities.Ability; -import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.cards.CardImpl; import mage.filter.common.FilterBasicLandCard; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; -import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetCardInLibrary; @@ -56,7 +55,6 @@ public class BoundlessRealms extends CardImpl { super(ownerId, 162, "Boundless Realms", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{6}{G}"); this.expansionSetCode = "M13"; - // Search your library for up to X basic land cards, where X is the number of lands you control, and put them onto the battlefield tapped. Then shuffle your library. this.getSpellAbility().addEffect(new BoundlessRealmsEffect()); } @@ -89,32 +87,19 @@ class BoundlessRealmsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } FilterLandPermanent filter = new FilterLandPermanent(); filter.add(new ControllerPredicate(TargetController.YOU)); int amount = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this); TargetCardInLibrary target = new TargetCardInLibrary(0, amount, new FilterBasicLandCard()); - - Player player = game.getPlayer(source.getControllerId()); - if (player == null) { - return false; + if (controller.searchLibrary(target, game)) { + controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.HAND, source, game, true, false, false, null); } - - if (player.searchLibrary(target, game)) { - for (UUID cardId : target.getTargets()) { - Card card = player.getLibrary().getCard(cardId, game); - if (card != null) { - if (card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId())) { - Permanent permanent = game.getPermanent(card.getId()); - if (permanent != null) { - permanent.setTapped(true); - } - } - } - } - } - - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return true; } } diff --git a/Mage/src/mage/filter/predicate/permanent/CommanderPredicate.java b/Mage/src/mage/filter/predicate/permanent/CommanderPredicate.java new file mode 100644 index 00000000000..1e12b9d6acf --- /dev/null +++ b/Mage/src/mage/filter/predicate/permanent/CommanderPredicate.java @@ -0,0 +1,32 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.filter.predicate.permanent; + +import mage.constants.CardType; +import mage.filter.predicate.Predicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author LevelX2 + */ +public class CommanderPredicate implements Predicate { + + @Override + public boolean apply(Permanent input, Game game) { + Player owner = game.getPlayer(input.getOwnerId()); + return input.getCardType().contains(CardType.CREATURE) + && owner != null + && input.getId().equals(owner.getCommanderId()); + } + + @Override + public String toString() { + return "Commander creature"; + } +}