From 7d8a02bf636af14bb138b1b8e4635f2d205c9584 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 6 Nov 2016 08:28:49 +0100 Subject: [PATCH] [C16] Added Orzhov Advokist. --- .../src/mage/cards/o/OrzhovAdvokist.java | 136 ++++++++++++++++++ Mage.Sets/src/mage/sets/Commander2016.java | 2 +- .../common/combat/CantAttackYouAllEffect.java | 14 +- 3 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java diff --git a/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java b/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java new file mode 100644 index 0000000000..2525f817ce --- /dev/null +++ b/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java @@ -0,0 +1,136 @@ +/* + * 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.cards.o; + +import java.util.ArrayList; +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.combat.CantAttackYouAllEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.counters.CounterType; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.other.PlayerIdPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.Target; +import mage.target.common.TargetControlledCreaturePermanent; + +/** + * + * @author LevelX2 + */ +public class OrzhovAdvokist extends CardImpl { + + public OrzhovAdvokist(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}"); + + this.subtype.add("Human"); + this.subtype.add("Advisor"); + this.power = new MageInt(1); + this.toughness = new MageInt(4); + + // At the beginning of your upkeep, each player may put two +1/+1 counters on a creature he or she controls. If a player does, creatures that player controls can't attack you or a planeswalker you control until your next turn. + this.addAbility(new BeginningOfUpkeepTriggeredAbility(new OrzhovAdvokistEffect(), TargetController.YOU, false)); + } + + public OrzhovAdvokist(final OrzhovAdvokist card) { + super(card); + } + + @Override + public OrzhovAdvokist copy() { + return new OrzhovAdvokist(this); + } +} + +class OrzhovAdvokistEffect extends OneShotEffect { + + public OrzhovAdvokistEffect() { + super(Outcome.Benefit); + this.staticText = "each player may put two +1/+1 counters on a creature he or she controls. " + + "If a player does, creatures that player controls can't attack you or a planeswalker you control until your next turn"; + } + + public OrzhovAdvokistEffect(final OrzhovAdvokistEffect effect) { + super(effect); + } + + @Override + public OrzhovAdvokistEffect copy() { + return new OrzhovAdvokistEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + ArrayList players = new ArrayList<>(); + ArrayList creatures = new ArrayList<>(); + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + if (player.chooseUse(outcome, "Put two +1/+1 counters on a creature you control?", source, game)) { + Target target = new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("a creature you control (to add two +1/+1 counters on it)")); + if (player.choose(outcome, target, playerId, game)) { + creatures.add(target.getFirstTarget()); + players.add(player.getId()); + Permanent creature = game.getPermanent(target.getFirstTarget()); + if (creature != null) { + creature.addCounters(CounterType.P1P1.createInstance(2), game); + } + } + + } + } + } + for (UUID creatureId : creatures) { + Permanent creature = game.getPermanent(creatureId); + if (creature != null) { + creature.addCounters(CounterType.P1P1.createInstance(2), game); + } + } + for (UUID playerId : players) { + FilterCreaturePermanent filter = new FilterCreaturePermanent(); + filter.add(new PlayerIdPredicate(playerId)); + game.addEffect(new CantAttackYouAllEffect(Duration.UntilYourNextTurn, filter, true), source); + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2016.java b/Mage.Sets/src/mage/sets/Commander2016.java index 037cf8817e..12aa1c9146 100644 --- a/Mage.Sets/src/mage/sets/Commander2016.java +++ b/Mage.Sets/src/mage/sets/Commander2016.java @@ -36,7 +36,6 @@ import mage.constants.SetType; * * @author fireshoeS */ - public class Commander2016 extends ExpansionSet { private static final Commander2016 fINSTANCE = new Commander2016(); @@ -259,6 +258,7 @@ public class Commander2016 extends ExpansionSet { cards.add(new SetCardInfo("Open the Vaults", 72, Rarity.RARE, mage.cards.o.OpenTheVaults.class)); cards.add(new SetCardInfo("Opulent Palace", 313, Rarity.UNCOMMON, mage.cards.o.OpulentPalace.class)); cards.add(new SetCardInfo("Order // Chaos", 240, Rarity.UNCOMMON, mage.cards.o.OrderChaos.class)); + cards.add(new SetCardInfo("Orzhov Advokist", 3, Rarity.UNCOMMON, mage.cards.o.OrzhovAdvokist.class)); cards.add(new SetCardInfo("Orzhov Basilica", 314, Rarity.UNCOMMON, mage.cards.o.OrzhovBasilica.class)); cards.add(new SetCardInfo("Orzhov Signet", 266, Rarity.COMMON, mage.cards.o.OrzhovSignet.class)); cards.add(new SetCardInfo("Past in Flames", 131, Rarity.MYTHIC, mage.cards.p.PastInFlames.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouAllEffect.java index 8a06d99ad6..1dbf2cf026 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouAllEffect.java @@ -43,20 +43,29 @@ import mage.game.permanent.Permanent; public class CantAttackYouAllEffect extends RestrictionEffect { private final FilterCreaturePermanent filterAttacker; + private final boolean alsoPlaneswalker; public CantAttackYouAllEffect(Duration duration) { this(duration, new FilterCreaturePermanent("creatures")); } public CantAttackYouAllEffect(Duration duration, FilterCreaturePermanent filter) { + this(duration, filter, false); + } + + public CantAttackYouAllEffect(Duration duration, FilterCreaturePermanent filter, boolean alsoPlaneswalker) { super(duration, Outcome.Benefit); this.filterAttacker = filter; - staticText = filterAttacker.getMessage() + " can't attack you"; + this.alsoPlaneswalker = alsoPlaneswalker; + staticText = filterAttacker.getMessage() + " can't attack you" + + (alsoPlaneswalker ? " or a planeswalker you control" : "") + + (duration.equals(Duration.UntilYourNextTurn) ? " until your next turn" : ""); } CantAttackYouAllEffect(final CantAttackYouAllEffect effect) { super(effect); this.filterAttacker = effect.filterAttacker; + this.alsoPlaneswalker = effect.alsoPlaneswalker; } @Override @@ -66,7 +75,8 @@ public class CantAttackYouAllEffect extends RestrictionEffect { @Override public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) { - return !defenderId.equals(source.getControllerId()); + return (!alsoPlaneswalker && !defenderId.equals(source.getControllerId())) + || (alsoPlaneswalker && !game.getCombat().getDefendingPlayerId(attacker.getId(), game).equals(source.getControllerId())); } @Override