From 06440fd6060a063e1e12cc48d96e1fa21836e80a Mon Sep 17 00:00:00 2001 From: LoneFox Date: Sat, 26 Sep 2015 10:35:31 +0300 Subject: [PATCH] Add red and white Soldier token with haste and use it for existing cards. Kill unnecessary custom effect from Assemble the Legion. --- .../mage/sets/dragonsmaze/BlazeCommando.java | 35 +++-------- .../sets/gatecrash/AssembleTheLegion.java | 62 +++---------------- .../mage/sets/gatecrash/SunhomeGuildmage.java | 27 +------- Mage/src/mage/counters/CounterType.java | 1 + .../token/SoldierTokenWithHaste.java | 53 ++++++++++++++++ 5 files changed, 76 insertions(+), 102 deletions(-) create mode 100644 Mage/src/mage/game/permanent/token/SoldierTokenWithHaste.java diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/BlazeCommando.java b/Mage.Sets/src/mage/sets/dragonsmaze/BlazeCommando.java index cc64ee14378..f819fdc768d 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/BlazeCommando.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/BlazeCommando.java @@ -31,22 +31,20 @@ package mage.sets.dragonsmaze; import java.util.ArrayList; import java.util.List; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; -import mage.constants.Zone; import mage.MageInt; import mage.MageObject; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.common.CreateTokenEffect; -import mage.abilities.keyword.HasteAbility; import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.game.Game; -import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; +import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import mage.game.permanent.token.Token; +import mage.game.permanent.token.SoldierTokenWithHaste; import mage.game.stack.StackObject; /** @@ -82,12 +80,13 @@ public class BlazeCommando extends CardImpl { } } + class BlazeCommandoTriggeredAbility extends TriggeredAbilityImpl { private final List handledStackObjects = new ArrayList<>(); public BlazeCommandoTriggeredAbility() { - super(Zone.BATTLEFIELD, new CreateTokenEffect(new BlazeCommandoSoldierToken(), 2), false); + super(Zone.BATTLEFIELD, new CreateTokenEffect(new SoldierTokenWithHaste(), 2), false); } public BlazeCommandoTriggeredAbility(final BlazeCommandoTriggeredAbility ability) { @@ -103,10 +102,10 @@ class BlazeCommandoTriggeredAbility extends TriggeredAbilityImpl { public void reset(Game game) { /** * Blaze Commando's ability triggers each time an instant or sorcery spell you control - * deals damage (or, put another way, the number of times the word “deals” appears in + * deals damage (or, put another way, the number of times the word “deals” appears in * its instructions), no matter how much damage is dealt or how many players or permanents - * are dealt damage. For example, if you cast Punish the Enemy and it “deals 3 damage to - * target player and 3 damage to target creature,” Blaze Commando's ability will trigger + * are dealt damage. For example, if you cast Punish the Enemy and it “deals 3 damage to + * target player and 3 damage to target creature,” Blaze Commando's ability will trigger * once and you'll get two Soldier tokens. */ handledStackObjects.clear(); @@ -138,17 +137,3 @@ class BlazeCommandoTriggeredAbility extends TriggeredAbilityImpl { return new StringBuilder("Whenever an instant or sorcery spell you control deals damage, ").append(super.getRule()).toString(); } } - -class BlazeCommandoSoldierToken extends Token { - - public BlazeCommandoSoldierToken() { - super("Soldier", "1/1 red and white Soldier creature tokens with haste"); - cardType.add(CardType.CREATURE); - color.setRed(true); - color.setWhite(true); - subtype.add("Soldier"); - power = new MageInt(1); - toughness = new MageInt(1); - this.addAbility(HasteAbility.getInstance()); - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/gatecrash/AssembleTheLegion.java b/Mage.Sets/src/mage/sets/gatecrash/AssembleTheLegion.java index faac70e3640..7bbe22befb8 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/AssembleTheLegion.java +++ b/Mage.Sets/src/mage/sets/gatecrash/AssembleTheLegion.java @@ -28,20 +28,17 @@ package mage.sets.gatecrash; import java.util.UUID; -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.common.BeginningOfUpkeepTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.CountersCount; import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.cards.CardImpl; -import mage.counters.Counter; -import mage.game.Game; -import mage.game.permanent.Permanent; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.TargetController; +import mage.counters.CounterType; +import mage.game.permanent.token.SoldierTokenWithHaste; /** * @@ -55,7 +52,9 @@ public class AssembleTheLegion extends CardImpl { // At the beginning of your upkeep, put a muster counter on Assemble the Legion. Then put a 1/1 red and white Soldier creature token with haste onto the battlefield for each muster counter on Assemble the Legion. - this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AssembleTheLegionEffect(), TargetController.YOU, false)); + Ability ability = new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.MUSTER.createInstance()), TargetController.YOU, false); + ability.addEffect(new CreateTokenEffect(new SoldierTokenWithHaste(), new CountersCount(CounterType.MUSTER))); + this.addAbility(ability); } public AssembleTheLegion(final AssembleTheLegion card) { @@ -67,46 +66,3 @@ public class AssembleTheLegion extends CardImpl { return new AssembleTheLegion(this); } } - -class AssembleTheLegionEffect extends OneShotEffect { - private static final String MUSTER_COUNTER_NAME = "Muster"; - - public AssembleTheLegionEffect() { - super(Outcome.Copy); - this.staticText = "put a muster counter on {this}. Then put a 1/1 red and white Soldier creature token with haste onto the battlefield for each muster counter on {this}"; - } - - public AssembleTheLegionEffect(final AssembleTheLegionEffect effect) { - super(effect); - } - - @Override - public AssembleTheLegionEffect copy() { - return new AssembleTheLegionEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - /* 1/24/2013: If Assemble the Legion isn’t on the battlefield when its ability resolves, - * use the number of muster counters it had when it was last on the battlefield to - * determine how many Soldier tokens to put onto the battlefield. - */ - - Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - int amountCounters = 0; - if (sourcePermanent == null) { - Permanent lki = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (lki != null) { - amountCounters = lki.getCounters().getCount(MUSTER_COUNTER_NAME); - } - } else { - new AddCountersSourceEffect(new Counter(MUSTER_COUNTER_NAME),false).apply(game, source); - amountCounters = sourcePermanent.getCounters().getCount(MUSTER_COUNTER_NAME); - - } - if (amountCounters > 0) { - return new CreateTokenEffect(new SoldierToken(), amountCounters).apply(game, source); - } - return false; - } -} diff --git a/Mage.Sets/src/mage/sets/gatecrash/SunhomeGuildmage.java b/Mage.Sets/src/mage/sets/gatecrash/SunhomeGuildmage.java index 0adc3c7a3a6..4930c6e8ef3 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/SunhomeGuildmage.java +++ b/Mage.Sets/src/mage/sets/gatecrash/SunhomeGuildmage.java @@ -34,13 +34,12 @@ import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.continuous.BoostControlledEffect; -import mage.abilities.keyword.HasteAbility; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Rarity; import mage.constants.Zone; -import mage.game.permanent.token.Token; +import mage.game.permanent.token.SoldierTokenWithHaste; /** * @@ -54,17 +53,14 @@ public class SunhomeGuildmage extends CardImpl { this.subtype.add("Human"); this.subtype.add("Wizard"); - this.power = new MageInt(2); this.toughness = new MageInt(2); - //{1}{R}{W}: Creatures you control get +1/+0 until end of turn. this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl("{1}{R}{W}"))); - + //{2}{R}{W}: Put a 1/1 red and white Soldier creature token with haste onto the battlefield. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new SoldierToken()), new ManaCostsImpl("{2}{R}{W}"))); - + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new SoldierTokenWithHaste()), new ManaCostsImpl("{2}{R}{W}"))); } public SunhomeGuildmage(final SunhomeGuildmage card) { @@ -76,20 +72,3 @@ public class SunhomeGuildmage extends CardImpl { return new SunhomeGuildmage(this); } } - - -class SoldierToken extends Token { - - public SoldierToken() { - super("Soldier", "1/1 red and white Soldier creature token with haste"); - cardType.add(CardType.CREATURE); - color.setWhite(true); - color.setRed(true); - subtype.add("Soldier"); - power = new MageInt(1); - toughness = new MageInt(1); - - this.addAbility(HasteAbility.getInstance()); - } - -} diff --git a/Mage/src/mage/counters/CounterType.java b/Mage/src/mage/counters/CounterType.java index 52ebd732211..3f952c8ef96 100644 --- a/Mage/src/mage/counters/CounterType.java +++ b/Mage/src/mage/counters/CounterType.java @@ -71,6 +71,7 @@ public enum CounterType { M1M1(new BoostCounter(-1, -1).name), M2M2(new BoostCounter(-2, -2).name), MINING("mining"), + MUSTER("muster"), P1P0(new BoostCounter(1, 0).name), P1P1(new BoostCounter(1, 1).name), P2P2(new BoostCounter(2, 2).name), diff --git a/Mage/src/mage/game/permanent/token/SoldierTokenWithHaste.java b/Mage/src/mage/game/permanent/token/SoldierTokenWithHaste.java new file mode 100644 index 00000000000..221ac747a76 --- /dev/null +++ b/Mage/src/mage/game/permanent/token/SoldierTokenWithHaste.java @@ -0,0 +1,53 @@ +/* +* 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.game.permanent.token; + +import java.util.Arrays; +import mage.constants.CardType; +import mage.MageInt; +import mage.abilities.keyword.HasteAbility; + +/** + * + * @author LoneFox + */ +public class SoldierTokenWithHaste extends Token { + + public SoldierTokenWithHaste() { + super("Soldier", "1/1 red and white Soldier creature token with haste"); + cardType.add(CardType.CREATURE); + color.setWhite(true); + color.setRed(true); + subtype.add("Soldier"); + power = new MageInt(1); + toughness = new MageInt(1); + addAbility(HasteAbility.getInstance()); + setOriginalExpansionSetCode("GTC"); + } +}