From 7efc3b953bb8f9b9bdf9d1491fc3cefeb9deece3 Mon Sep 17 00:00:00 2001 From: Loki Date: Wed, 1 Jun 2011 23:29:29 +0300 Subject: [PATCH] Sickleslicer and Living Weapon mechanic support --- .../plugins/card/images/DownloadPictures.java | 1 + .../src/main/resources/card-pictures-tok.txt | 2 + .../mage/sets/newphyrexia/Sickleslicer.java | 67 +++++++++++++++++++ .../keyword/LivingWeaponAbility.java | 59 ++++++++++++++++ Mage/src/mage/game/permanent/token/Token.java | 8 ++- 5 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/sets/newphyrexia/Sickleslicer.java create mode 100644 Mage/src/mage/abilities/keyword/LivingWeaponAbility.java diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/images/DownloadPictures.java b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/images/DownloadPictures.java index ba66c39356..ba1bc253d4 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/images/DownloadPictures.java +++ b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/images/DownloadPictures.java @@ -369,6 +369,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab final static Map setNameReplacement = new HashMap() { { + put("MBS", "mirrodin-besieged"); put("SOM", "scars-of-mirrodin"); put("M11", "magic-2011"); put("ROE", "rise-of-the-eldrazi"); diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/resources/card-pictures-tok.txt b/Mage.Plugins/Mage.Card.Plugin/src/main/resources/card-pictures-tok.txt index 5a1c70d308..2b98e54143 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/resources/card-pictures-tok.txt +++ b/Mage.Plugins/Mage.Card.Plugin/src/main/resources/card-pictures-tok.txt @@ -1,3 +1,5 @@ +|Generate|TOK:MBS|Germ| + |Generate|TOK:SOM|Cat| |Generate|TOK:SOM|Soldier| |Generate|TOK:SOM|Goblin| diff --git a/Mage.Sets/src/mage/sets/newphyrexia/Sickleslicer.java b/Mage.Sets/src/mage/sets/newphyrexia/Sickleslicer.java new file mode 100644 index 0000000000..ae9d593ed4 --- /dev/null +++ b/Mage.Sets/src/mage/sets/newphyrexia/Sickleslicer.java @@ -0,0 +1,67 @@ +/* + * 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.newphyrexia; + +import java.util.UUID; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.common.continious.BoostEquippedEffect; +import mage.abilities.keyword.EquipAbility; +import mage.abilities.keyword.LivingWeaponAbility; +import mage.cards.CardImpl; + +/** + * + * @author Loki + */ +public class Sickleslicer extends CardImpl { + + public Sickleslicer (UUID ownerId) { + super(ownerId, 157, "Sickleslicer", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{3}"); + this.expansionSetCode = "NPH"; + this.subtype.add("Equipment"); + this.addAbility(new EquipAbility(Constants.Outcome.BoostCreature, new GenericManaCost(4))); + this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new BoostEquippedEffect(2, 2))); + this.addAbility(new LivingWeaponAbility()); + } + + public Sickleslicer (final Sickleslicer card) { + super(card); + } + + @Override + public Sickleslicer copy() { + return new Sickleslicer(this); + } + +} diff --git a/Mage/src/mage/abilities/keyword/LivingWeaponAbility.java b/Mage/src/mage/abilities/keyword/LivingWeaponAbility.java new file mode 100644 index 0000000000..bdd2108d25 --- /dev/null +++ b/Mage/src/mage/abilities/keyword/LivingWeaponAbility.java @@ -0,0 +1,59 @@ +package mage.abilities.keyword; + +import mage.Constants; +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.Token; + +public class LivingWeaponAbility extends EntersBattlefieldTriggeredAbility { + public LivingWeaponAbility() { + super(new LivingWeaponEffect()); + } + + @Override + public String getRule() { + return "Living weapon"; + } +} + +class LivingWeaponEffect extends OneShotEffect { + LivingWeaponEffect() { + super(Constants.Outcome.PutCreatureInPlay); + } + + LivingWeaponEffect(final LivingWeaponEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + GermToken token = new GermToken(); + token.putOntoBattlefield(game, source.getId(), source.getControllerId()); + Permanent p = game.getPermanent(token.getLastAddedToken()); + if (p != null) { + p.addAttachment(source.getSourceId(), game); + } + return false; + } + + @Override + public LivingWeaponEffect copy() { + return new LivingWeaponEffect(this); + } +} + +class GermToken extends Token { + public GermToken() { + super("Germ", "a 0/0 black Germ creature token"); + cardType.add(Constants.CardType.CREATURE); + color = ObjectColor.BLACK; + subtype.add("Germ"); + power = new MageInt(0); + toughness = new MageInt(0); + } +} \ No newline at end of file diff --git a/Mage/src/mage/game/permanent/token/Token.java b/Mage/src/mage/game/permanent/token/Token.java index 37dd8dc279..a4b3a51b01 100644 --- a/Mage/src/mage/game/permanent/token/Token.java +++ b/Mage/src/mage/game/permanent/token/Token.java @@ -43,6 +43,7 @@ import mage.game.permanent.PermanentToken; public class Token extends MageObjectImpl { protected String description; + private UUID lastAddedTokenId; public Token(String name, String description) { this.name = name; @@ -70,7 +71,11 @@ public class Token extends MageObjectImpl { return description; } - public void addAbility(Ability ability) { + public UUID getLastAddedToken() { + return lastAddedTokenId; + } + + public void addAbility(Ability ability) { ability.setSourceId(this.getId()); abilities.add(ability); } @@ -83,6 +88,7 @@ public class Token extends MageObjectImpl { public boolean putOntoBattlefield(Game game, UUID sourceId, UUID controllerId) { PermanentToken permanent = new PermanentToken(this, controllerId); game.getBattlefield().addPermanent(permanent); + this.lastAddedTokenId = permanent.getId(); permanent.entersBattlefield(sourceId, game); game.applyEffects(); game.fireEvent(new ZoneChangeEvent(permanent, controllerId, Zone.OUTSIDE, Zone.BATTLEFIELD));