From 7ef725d2cdada3f7eba9e36e80f5b6c0b26d3eeb Mon Sep 17 00:00:00 2001 From: L_J Date: Wed, 14 Feb 2018 18:28:12 +0000 Subject: [PATCH] Implemented Urza's Avenger --- Mage.Sets/src/mage/cards/u/UrzasAvenger.java | 143 +++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/u/UrzasAvenger.java diff --git a/Mage.Sets/src/mage/cards/u/UrzasAvenger.java b/Mage.Sets/src/mage/cards/u/UrzasAvenger.java new file mode 100644 index 00000000000..e16b83fa6a4 --- /dev/null +++ b/Mage.Sets/src/mage/cards/u/UrzasAvenger.java @@ -0,0 +1,143 @@ +/* + * 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.u; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; +import mage.abilities.keyword.BandingAbility; +import mage.abilities.keyword.FirstStrikeAbility; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.TrampleAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.choices.Choice; +import mage.choices.ChoiceImpl; +import mage.constants.*; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author Styxo & L_J + */ +public class UrzasAvenger extends CardImpl { + + public UrzasAvenger(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT,CardType.CREATURE}, "{6}"); + + this.subtype.add(SubType.SHAPESHIFTER); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // {0}: Urza's Avenger gets -1/-1 and gains your choice of banding, flying, first strike, or trample until end of turn. + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new UrzasAvengerEffect(), new ManaCostsImpl("{0}"))); + } + + public UrzasAvenger(final UrzasAvenger card) { + super(card); + } + + @Override + public UrzasAvenger copy() { + return new UrzasAvenger(this); + } +} + +class UrzasAvengerEffect extends ContinuousEffectImpl { + + private static final Set choices = new HashSet<>(); + private Ability gainedAbility; + + static { + choices.add("Banding"); + choices.add("Flying"); + choices.add("First strike"); + choices.add("Trample"); + } + + public UrzasAvengerEffect() { + super(Duration.EndOfTurn, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.AddAbility); + this.staticText = "{this} gets -1/-1 and gains your choice of banding, flying, first strike, or trample until end of turn"; + } + + public UrzasAvengerEffect(final UrzasAvengerEffect effect) { + super(effect); + } + + @Override + public UrzasAvengerEffect copy() { + return new UrzasAvengerEffect(this); + } + + @Override + public void init(Ability source, Game game) { + super.init(source, game); + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Choice choice = new ChoiceImpl(true); + choice.setMessage("Choose one"); + choice.setChoices(choices); + if (controller.choose(outcome, choice, game)) { + switch (choice.getChoice()) { + case "Banding": + gainedAbility = BandingAbility.getInstance(); + break; + case "Flying": + gainedAbility = FlyingAbility.getInstance(); + break; + case "First strike": + gainedAbility = FirstStrikeAbility.getInstance(); + break; + default: + gainedAbility = TrampleAbility.getInstance(); + break; + } + } + } + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent sourceObject = game.getPermanent(source.getSourceId()); + if (sourceObject != null) { + sourceObject.addPower(-1); + sourceObject.addToughness(-1); + game.addEffect(new GainAbilitySourceEffect(gainedAbility, Duration.EndOfTurn), source); + return true; + } + return false; + } +}