From 17bb12a25a346cc74568f2b67dd83fdf9ac53a1e Mon Sep 17 00:00:00 2001 From: Loki Date: Tue, 4 Jan 2011 00:25:56 +0200 Subject: [PATCH] Kemba Kha Regent and new common triggered ability --- .../sets/scarsofmirrodin/GolemFoundry.java | 115 ++++++++++++++++ .../sets/scarsofmirrodin/KembaKhaRegent.java | 127 ++++++++++++++++++ .../mage/sets/zendikar/VampireLacerator.java | 39 +----- ...ingOfControllerUpkeepTriggeredAbility.java | 36 +++++ 4 files changed, 285 insertions(+), 32 deletions(-) create mode 100644 Mage.Sets/src/mage/sets/scarsofmirrodin/GolemFoundry.java create mode 100644 Mage.Sets/src/mage/sets/scarsofmirrodin/KembaKhaRegent.java create mode 100644 Mage/src/mage/abilities/common/BeginningOfControllerUpkeepTriggeredAbility.java diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/GolemFoundry.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/GolemFoundry.java new file mode 100644 index 00000000000..bbbc78928bd --- /dev/null +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/GolemFoundry.java @@ -0,0 +1,115 @@ +/* + * 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.scarsofmirrodin; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.MageInt; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.RemoveCountersSourceCost; +import mage.abilities.effects.common.AddCountersSourceEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.GainLifeEffect; +import mage.cards.CardImpl; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.token.Token; +import mage.game.stack.Spell; + +/** + * + * @author Loki + */ +public class GolemFoundry extends CardImpl { + + public GolemFoundry (UUID ownerId) { + super(ownerId, 160, "Golem Foundry", Rarity.COMMON, new CardType[]{CardType.ARTIFACT}, "{3}"); + this.expansionSetCode = "SOM"; + this.addAbility(new GolemFoundryAbility()); + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new GolemToken()), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance(3)))); + } + + public GolemFoundry (final GolemFoundry card) { + super(card); + } + + @Override + public GolemFoundry copy() { + return new GolemFoundry(this); + } + +} + +class GolemFoundryAbility extends TriggeredAbilityImpl { + + public GolemFoundryAbility() { + super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), true); + } + + public GolemFoundryAbility(final GolemFoundryAbility ability) { + super(ability); + } + + @Override + public GolemFoundryAbility copy() { + return new GolemFoundryAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.SPELL_CAST) { + Spell spell = game.getStack().getSpell(event.getTargetId()); + if (spell != null && spell.getCardType().contains(CardType.ARTIFACT)) { + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever you cast an artifact spell, you may put a charge counter on Golem Foundry."; + } +} + +class GolemToken extends Token { + public GolemToken() { + super("Golem", "a 3/3 colorless Golem artifact creature token"); + cardType.add(CardType.ARTIFACT); + cardType.add(CardType.CREATURE); + subtype.add("Golem"); + power = new MageInt(3); + toughness = new MageInt(3); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/KembaKhaRegent.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/KembaKhaRegent.java new file mode 100644 index 00000000000..590b03b681b --- /dev/null +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/KembaKhaRegent.java @@ -0,0 +1,127 @@ +/* + * 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.scarsofmirrodin; + +import java.util.UUID; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.BeginningOfControllerUpkeepTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.Token; + +/** + * + * @author Loki + */ +public class KembaKhaRegent extends CardImpl { + + public KembaKhaRegent (UUID ownerId) { + super(ownerId, 12, "Kemba, Kha Regent", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{W}{W}"); + this.expansionSetCode = "SOM"; + this.subtype.add("Legendary"); + this.subtype.add("Cat"); + this.subtype.add("Cleric"); + this.color.setWhite(true); + this.power = new MageInt(2); + this.toughness = new MageInt(4); + this.addAbility(new BeginningOfControllerUpkeepTriggeredAbility(new KembaKhaRegentEffect(), false)); + } + + public KembaKhaRegent (final KembaKhaRegent card) { + super(card); + } + + @Override + public KembaKhaRegent copy() { + return new KembaKhaRegent(this); + } +} + +class KembaKhaRegentEffect extends OneShotEffect { + public KembaKhaRegentEffect() { + super(Constants.Outcome.PutCreatureInPlay); + } + + public KembaKhaRegentEffect(final KembaKhaRegentEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent p = game.getPermanent(source.getSourceId()); + int count = 0; + if (p != null) { + for (UUID attachmentId : p.getAttachments()) { + Permanent attached = game.getPermanent(attachmentId); + if (attached != null && attached.getSubtype().contains("Equipment")) + count++; + } + if (count > 0) { + CatToken token = new CatToken(); + for (int i = 0; i < count; i++) { + token.putOntoBattlefield(game, source.getId(), source.getControllerId()); + } + } + + } + return false; + } + + @Override + public KembaKhaRegentEffect copy() { + return new KembaKhaRegentEffect(this); + } + + @Override + public String getText(Ability source) { + return "put a 2/2 white Cat creature token onto the battlefield for each Equipment attached to Kemba, Kha Regent"; + } +} + +class CatToken extends Token { + public CatToken() { + super("Cat", "a 2/2 white Cat creature token"); + cardType.add(CardType.CREATURE); + color = ObjectColor.WHITE; + subtype.add("Cat"); + power = new MageInt(2); + toughness = new MageInt(2); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/zendikar/VampireLacerator.java b/Mage.Sets/src/mage/sets/zendikar/VampireLacerator.java index a7065edfaaf..9a66542a717 100644 --- a/Mage.Sets/src/mage/sets/zendikar/VampireLacerator.java +++ b/Mage.Sets/src/mage/sets/zendikar/VampireLacerator.java @@ -28,6 +28,7 @@ package mage.sets.zendikar; import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.BeginningOfControllerUpkeepTriggeredAbility; import mage.abilities.condition.common.MyTurn; import java.util.UUID; import mage.Constants.CardType; @@ -56,12 +57,16 @@ public class VampireLacerator extends CardImpl { this.expansionSetCode = "ZEN"; this.subtype.add("Vampire"); this.subtype.add("Warrior"); - this.color.setBlack(true); this.power = new MageInt(2); this.toughness = new MageInt(2); - this.addAbility(new VampireLaceratorTriggeredAbility()); + this.addAbility(new BeginningOfControllerUpkeepTriggeredAbility( + new ConditionalOneShotEffect( + new LoseLifeSourceEffect(1), + new Unless( new TenOrLessLife(AN_OPPONENT) ), + "At the beginning of your upkeep, you lose 1 " + + "life unless an opponent has 10 or less life."), false)); } public VampireLacerator(final VampireLacerator card) { @@ -73,33 +78,3 @@ public class VampireLacerator extends CardImpl { return new VampireLacerator(this); } } - -class VampireLaceratorTriggeredAbility extends TriggeredAbilityImpl { - VampireLaceratorTriggeredAbility ( ) { - super(Zone.BATTLEFIELD, - new ConditionalOneShotEffect( - new LoseLifeSourceEffect(1), - new Unless( new TenOrLessLife(AN_OPPONENT) ), - "At the beginning of your upkeep, you lose 1 " - + "life unless an opponent has 10 or less life.")); - } - - VampireLaceratorTriggeredAbility ( VampireLaceratorTriggeredAbility ability ) { - super(ability); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - return MyTurn.getInstance().apply(game, this) && event.getType() == EventType.UPKEEP_STEP_PRE; - } - - @Override - public String getRule() { - return super.getRule(); - } - - @Override - public VampireLaceratorTriggeredAbility copy() { - return new VampireLaceratorTriggeredAbility(this); - } -} diff --git a/Mage/src/mage/abilities/common/BeginningOfControllerUpkeepTriggeredAbility.java b/Mage/src/mage/abilities/common/BeginningOfControllerUpkeepTriggeredAbility.java new file mode 100644 index 00000000000..446d1f786ce --- /dev/null +++ b/Mage/src/mage/abilities/common/BeginningOfControllerUpkeepTriggeredAbility.java @@ -0,0 +1,36 @@ +package mage.abilities.common; + +import mage.Constants; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.game.Game; +import mage.game.events.GameEvent; + +public class BeginningOfControllerUpkeepTriggeredAbility extends TriggeredAbilityImpl { + + public BeginningOfControllerUpkeepTriggeredAbility(Effect effect, boolean isOptional) { + super(Constants.Zone.BATTLEFIELD, effect, isOptional); + } + + public BeginningOfControllerUpkeepTriggeredAbility(final BeginningOfControllerUpkeepTriggeredAbility ability) { + super(ability); + } + + @Override + public BeginningOfControllerUpkeepTriggeredAbility copy() { + return new BeginningOfControllerUpkeepTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && event.getPlayerId().equals(this.controllerId)) { + return true; + } + return false; + } + + @Override + public String getRule() { + return "At the beginning of your upkeep, " + effects.getText(this); + } +}