From 86903f9efb7b84eb2fe43f811318ba47bf7feec0 Mon Sep 17 00:00:00 2001 From: fireshoes Date: Fri, 4 Dec 2015 10:12:15 -0600 Subject: [PATCH] Fixed some cards with "When this becomes blocked, it gets +x/+x for each creature blocking it" so that it is one trigger instead of a trigger for each creature blocking. --- .../src/mage/sets/iceage/JohtullWurm.java | 1 - .../src/mage/sets/invasion/SparringGolem.java | 57 +++++- .../sets/ninthedition/ElvishBerserker.java | 56 +++++- .../src/mage/sets/odyssey/RabidElephant.java | 182 +++++++++++------- .../src/mage/sets/urzaslegacy/GangOfElk.java | 61 +++++- 5 files changed, 280 insertions(+), 77 deletions(-) diff --git a/Mage.Sets/src/mage/sets/iceage/JohtullWurm.java b/Mage.Sets/src/mage/sets/iceage/JohtullWurm.java index 843ff67b60c..524fbde5197 100644 --- a/Mage.Sets/src/mage/sets/iceage/JohtullWurm.java +++ b/Mage.Sets/src/mage/sets/iceage/JohtullWurm.java @@ -102,7 +102,6 @@ class JohtullWurmValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - int count = 0; for(CombatGroup combatGroup : game.getCombat().getGroups()) { if(combatGroup.getAttackers().contains(sourceAbility.getSourceId())) { int blockers = combatGroup.getBlockers().size(); diff --git a/Mage.Sets/src/mage/sets/invasion/SparringGolem.java b/Mage.Sets/src/mage/sets/invasion/SparringGolem.java index 7755d0645e7..9f9a2844949 100644 --- a/Mage.Sets/src/mage/sets/invasion/SparringGolem.java +++ b/Mage.Sets/src/mage/sets/invasion/SparringGolem.java @@ -29,13 +29,17 @@ package mage.sets.invasion; import java.util.UUID; import mage.MageInt; -import mage.abilities.common.BecomesBlockedByCreatureTriggeredAbility; +import mage.abilities.Ability; +import mage.abilities.common.BecomesBlockedTriggeredAbility; +import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.effects.Effect; import mage.abilities.effects.common.continuous.BoostSourceEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Rarity; +import mage.game.Game; +import mage.game.combat.CombatGroup; /** * @@ -51,9 +55,7 @@ public class SparringGolem extends CardImpl { this.toughness = new MageInt(2); // Whenever Sparring Golem becomes blocked, it gets +1/+1 until end of turn for each creature blocking it. - Effect effect = new BoostSourceEffect(1, 1, Duration.EndOfTurn); - effect.setText("it gets +1/+1 until end of turn for each creature blocking it"); - this.addAbility(new BecomesBlockedByCreatureTriggeredAbility(effect, false)); + this.addAbility(new SparringGolemAbility()); } public SparringGolem(final SparringGolem card) { @@ -65,3 +67,50 @@ public class SparringGolem extends CardImpl { return new SparringGolem(this); } } + +class SparringGolemAbility extends BecomesBlockedTriggeredAbility { + + public SparringGolemAbility() { + super(null, false); + SparringGolemValue value = new SparringGolemValue(); + this.addEffect(new BoostSourceEffect(value, value, Duration.EndOfTurn)); + } + + public SparringGolemAbility(final SparringGolemAbility ability) { + super(ability); + } + + @Override + public SparringGolemAbility copy() { + return new SparringGolemAbility(this); + } + + @Override + public String getRule() { + return "Whenever {this} becomes blocked, it gets +1/+1 until end of turn for each creature blocking it."; + } +} + +class SparringGolemValue implements DynamicValue { + + @Override + public SparringGolemValue copy() { + return new SparringGolemValue(); + } + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + for(CombatGroup combatGroup : game.getCombat().getGroups()) { + if(combatGroup.getAttackers().contains(sourceAbility.getSourceId())) { + int blockers = combatGroup.getBlockers().size(); + return blockers > 1 ? (blockers) : 0; + } + } + return 0; + } + + @Override + public String getMessage() { + return "+1/+1 until end of turn for each creature blocking it"; + } +} diff --git a/Mage.Sets/src/mage/sets/ninthedition/ElvishBerserker.java b/Mage.Sets/src/mage/sets/ninthedition/ElvishBerserker.java index b111c600ed6..b53ffa4298b 100644 --- a/Mage.Sets/src/mage/sets/ninthedition/ElvishBerserker.java +++ b/Mage.Sets/src/mage/sets/ninthedition/ElvishBerserker.java @@ -29,12 +29,17 @@ package mage.sets.ninthedition; import java.util.UUID; import mage.MageInt; -import mage.abilities.common.BecomesBlockedByCreatureTriggeredAbility; +import mage.abilities.Ability; +import mage.abilities.common.BecomesBlockedTriggeredAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; import mage.abilities.effects.common.continuous.BoostSourceEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Rarity; +import mage.game.Game; +import mage.game.combat.CombatGroup; /** * @@ -51,7 +56,7 @@ public class ElvishBerserker extends CardImpl { this.toughness = new MageInt(1); // Whenever Elvish Berserker becomes blocked, it gets +1/+1 until end of turn for each creature blocking it. - this.addAbility(new BecomesBlockedByCreatureTriggeredAbility(new BoostSourceEffect(1, 1, Duration.EndOfTurn), false)); + this.addAbility(new ElvishBerserkerAbility()); } public ElvishBerserker(final ElvishBerserker card) { @@ -63,3 +68,50 @@ public class ElvishBerserker extends CardImpl { return new ElvishBerserker(this); } } + +class ElvishBerserkerAbility extends BecomesBlockedTriggeredAbility { + + public ElvishBerserkerAbility() { + super(null, false); + ElvishBerserkerValue value = new ElvishBerserkerValue(); + this.addEffect(new BoostSourceEffect(value, value, Duration.EndOfTurn)); + } + + public ElvishBerserkerAbility(final ElvishBerserkerAbility ability) { + super(ability); + } + + @Override + public ElvishBerserkerAbility copy() { + return new ElvishBerserkerAbility(this); + } + + @Override + public String getRule() { + return "Whenever {this} becomes blocked, it gets +1/+1 until end of turn for each creature blocking it."; + } +} + +class ElvishBerserkerValue implements DynamicValue { + + @Override + public ElvishBerserkerValue copy() { + return new ElvishBerserkerValue(); + } + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + for(CombatGroup combatGroup : game.getCombat().getGroups()) { + if(combatGroup.getAttackers().contains(sourceAbility.getSourceId())) { + int blockers = combatGroup.getBlockers().size(); + return blockers > 1 ? (blockers) : 0; + } + } + return 0; + } + + @Override + public String getMessage() { + return "+1/+1 until end of turn for each creature blocking it"; + } +} diff --git a/Mage.Sets/src/mage/sets/odyssey/RabidElephant.java b/Mage.Sets/src/mage/sets/odyssey/RabidElephant.java index d34fc022f7e..4c496f27b80 100644 --- a/Mage.Sets/src/mage/sets/odyssey/RabidElephant.java +++ b/Mage.Sets/src/mage/sets/odyssey/RabidElephant.java @@ -1,65 +1,117 @@ -/* - * 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.odyssey; - -import java.util.UUID; -import mage.MageInt; -import mage.abilities.common.BecomesBlockedByCreatureTriggeredAbility; -import mage.abilities.effects.common.continuous.BoostSourceEffect; -import mage.cards.CardImpl; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Rarity; - -/** - * - * @author LevelX2 - */ -public class RabidElephant extends CardImpl { - - public RabidElephant(UUID ownerId) { - super(ownerId, 263, "Rabid Elephant", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{G}"); - this.expansionSetCode = "ODY"; - this.subtype.add("Elephant"); - - this.power = new MageInt(3); - this.toughness = new MageInt(4); - - // Whenever Rabid Elephant becomes blocked, it gets +2/+2 until end of turn for each creature blocking it. - this.addAbility(new BecomesBlockedByCreatureTriggeredAbility(new BoostSourceEffect(2, 2, Duration.EndOfTurn), false)); - } - - public RabidElephant(final RabidElephant card) { - super(card); - } - - @Override - public RabidElephant copy() { - return new RabidElephant(this); - } -} +/* + * 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.odyssey; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BecomesBlockedTriggeredAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.continuous.BoostSourceEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.game.Game; +import mage.game.combat.CombatGroup; + +/** + * + * @author LevelX2 + */ +public class RabidElephant extends CardImpl { + + public RabidElephant(UUID ownerId) { + super(ownerId, 263, "Rabid Elephant", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{G}"); + this.expansionSetCode = "ODY"; + this.subtype.add("Elephant"); + + this.power = new MageInt(3); + this.toughness = new MageInt(4); + + // Whenever Rabid Elephant becomes blocked, it gets +2/+2 until end of turn for each creature blocking it. + this.addAbility(new RabidElephantAbility()); + } + + public RabidElephant(final RabidElephant card) { + super(card); + } + + @Override + public RabidElephant copy() { + return new RabidElephant(this); + } +} + +class RabidElephantAbility extends BecomesBlockedTriggeredAbility { + + public RabidElephantAbility() { + super(null, false); + RabidElephantValue value = new RabidElephantValue(); + this.addEffect(new BoostSourceEffect(value, value, Duration.EndOfTurn)); + } + + public RabidElephantAbility(final RabidElephantAbility ability) { + super(ability); + } + + @Override + public RabidElephantAbility copy() { + return new RabidElephantAbility(this); + } + + @Override + public String getRule() { + return "Whenever {this} becomes blocked, it gets +2/+2 until end of turn for each creature blocking it."; + } +} + +class RabidElephantValue implements DynamicValue { + + @Override + public RabidElephantValue copy() { + return new RabidElephantValue(); + } + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + for(CombatGroup combatGroup : game.getCombat().getGroups()) { + if(combatGroup.getAttackers().contains(sourceAbility.getSourceId())) { + int blockers = combatGroup.getBlockers().size(); + return blockers > 1 ? (blockers) * 2 : 0; + } + } + return 0; + } + + @Override + public String getMessage() { + return "+2/+2 until end of turn for each creature blocking it"; + } +} diff --git a/Mage.Sets/src/mage/sets/urzaslegacy/GangOfElk.java b/Mage.Sets/src/mage/sets/urzaslegacy/GangOfElk.java index 1d3ac6bc20f..ec2120547f7 100644 --- a/Mage.Sets/src/mage/sets/urzaslegacy/GangOfElk.java +++ b/Mage.Sets/src/mage/sets/urzaslegacy/GangOfElk.java @@ -28,14 +28,18 @@ package mage.sets.urzaslegacy; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.MageInt; -import mage.abilities.common.BecomesBlockedByCreatureTriggeredAbility; +import mage.abilities.Ability; +import mage.abilities.common.BecomesBlockedTriggeredAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; import mage.abilities.effects.common.continuous.BoostSourceEffect; import mage.cards.CardImpl; +import mage.constants.CardType; import mage.constants.Duration; +import mage.constants.Rarity; +import mage.game.Game; +import mage.game.combat.CombatGroup; /** * @@ -53,7 +57,7 @@ public class GangOfElk extends CardImpl { this.toughness = new MageInt(4); // Whenever Gang of Elk becomes blocked, it gets +2/+2 until end of turn for each creature blocking it. - this.addAbility(new BecomesBlockedByCreatureTriggeredAbility(new BoostSourceEffect(2, 2, Duration.EndOfTurn), false)); + this.addAbility(new GangOfElkAbility()); } public GangOfElk(final GangOfElk card) { @@ -65,3 +69,50 @@ public class GangOfElk extends CardImpl { return new GangOfElk(this); } } + +class GangOfElkAbility extends BecomesBlockedTriggeredAbility { + + public GangOfElkAbility() { + super(null, false); + GangOfElkValue value = new GangOfElkValue(); + this.addEffect(new BoostSourceEffect(value, value, Duration.EndOfTurn)); + } + + public GangOfElkAbility(final GangOfElkAbility ability) { + super(ability); + } + + @Override + public GangOfElkAbility copy() { + return new GangOfElkAbility(this); + } + + @Override + public String getRule() { + return "Whenever {this} becomes blocked, it gets +2/+2 until end of turn for each creature blocking it."; + } +} + +class GangOfElkValue implements DynamicValue { + + @Override + public GangOfElkValue copy() { + return new GangOfElkValue(); + } + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + for(CombatGroup combatGroup : game.getCombat().getGroups()) { + if(combatGroup.getAttackers().contains(sourceAbility.getSourceId())) { + int blockers = combatGroup.getBlockers().size(); + return blockers > 1 ? (blockers) * 2 : 0; + } + } + return 0; + } + + @Override + public String getMessage() { + return "+2/+2 until end of turn for each creature blocking it"; + } +}