From 667b2affdf54a3581d17aee04063b93414919473 Mon Sep 17 00:00:00 2001 From: spjspj Date: Sat, 16 Dec 2017 00:34:21 +1100 Subject: [PATCH] Add 2 unstable cards. --- .../src/mage/cards/k/KrarksOtherThumb.java | 123 ++++++++++++++ Mage.Sets/src/mage/cards/s/SteelSquirrel.java | 151 ++++++++++++++++++ Mage.Sets/src/mage/sets/Unstable.java | 2 + .../main/java/mage/players/PlayerImpl.java | 7 +- 4 files changed, 281 insertions(+), 2 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/k/KrarksOtherThumb.java create mode 100644 Mage.Sets/src/mage/cards/s/SteelSquirrel.java diff --git a/Mage.Sets/src/mage/cards/k/KrarksOtherThumb.java b/Mage.Sets/src/mage/cards/k/KrarksOtherThumb.java new file mode 100644 index 00000000000..b37ef0e660e --- /dev/null +++ b/Mage.Sets/src/mage/cards/k/KrarksOtherThumb.java @@ -0,0 +1,123 @@ +/* + * 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.k; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SuperType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.players.Player; +import mage.util.RandomUtil; + +/** + * + * @author spjspj + */ +public class KrarksOtherThumb extends CardImpl { + + public KrarksOtherThumb(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}"); + + addSuperType(SuperType.LEGENDARY); + + // If you would roll a die, instead roll two of those dice and ignore one of those results. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new KrarksOtherThumbEffect())); + } + + public KrarksOtherThumb(final KrarksOtherThumb card) { + super(card); + } + + @Override + public KrarksOtherThumb copy() { + return new KrarksOtherThumb(this); + } +} + +class KrarksOtherThumbEffect extends ReplacementEffectImpl { + + KrarksOtherThumbEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "If you would roll a die, instead roll two die and ignore one"; + } + + KrarksOtherThumbEffect(final KrarksOtherThumbEffect effect) { + super(effect); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + Player player = game.getPlayer(event.getPlayerId()); + if (player != null) { + // event.getData holds the num of sides of the die to roll + String data = event.getData(); + int numSides = Integer.parseInt(data); + int secondDieRoll = RandomUtil.nextInt(numSides) + 1; + + if (!game.isSimulation()) { + game.informPlayers("[Roll a die] " + player.getLogName() + " rolled a " + secondDieRoll); + } + if (player.chooseUse(outcome, "Ignore the first die roll?", source, game)) { + event.setAmount(secondDieRoll); + game.informPlayers(player.getLogName() + " ignores the first die roll."); + } else { + game.informPlayers(player.getLogName() + " ignores the second die roll."); + } + } + return false; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ROLL_DICE; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + return source.getControllerId().equals(event.getPlayerId()); + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public KrarksOtherThumbEffect copy() { + return new KrarksOtherThumbEffect(this); + } +} diff --git a/Mage.Sets/src/mage/cards/s/SteelSquirrel.java b/Mage.Sets/src/mage/cards/s/SteelSquirrel.java new file mode 100644 index 00000000000..9dd2a0e8be7 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SteelSquirrel.java @@ -0,0 +1,151 @@ +/* + * 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.s; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.RollDiceEffect; +import mage.abilities.effects.common.continuous.BoostSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author spjspj + */ +public class SteelSquirrel extends CardImpl { + + public SteelSquirrel(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{2}"); + + this.subtype.add(SubType.SQUIRREL); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + + // Whenever you roll a 5 or higher on a die, Steel Squirrel gets +X/+X until end of turn, where X is the result. + this.addAbility(new SteelSquirrelTriggeredAbility()); + + // 6: Roll a six-sided die. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RollDiceEffect(null, 6), new GenericManaCost(6)); + this.addAbility(ability); + } + + public SteelSquirrel(final SteelSquirrel card) { + super(card); + } + + @Override + public SteelSquirrel copy() { + return new SteelSquirrel(this); + } +} + +class SteelSquirrelTriggeredAbility extends TriggeredAbilityImpl { + + public SteelSquirrelTriggeredAbility() { + super(Zone.BATTLEFIELD, new SteelSquirrelEffect()); + } + + public SteelSquirrelTriggeredAbility(final SteelSquirrelTriggeredAbility ability) { + super(ability); + } + + @Override + public SteelSquirrelTriggeredAbility copy() { + return new SteelSquirrelTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DICE_ROLLED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (this.getControllerId().equals(event.getPlayerId()) && event.getFlag()) { + if (event.getAmount() >= 5) { + for (Effect effect : this.getEffects()) { + effect.setValue("rolled", event.getAmount()); + } + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever you roll a 5 or higher on a die, " + super.getRule(); + } +} + +class SteelSquirrelEffect extends OneShotEffect { + + public SteelSquirrelEffect() { + super(Outcome.Benefit); + this.staticText = "{this} gets +X/+X until end of turn, where X is the result"; + } + + public SteelSquirrelEffect(final SteelSquirrelEffect effect) { + super(effect); + } + + @Override + public SteelSquirrelEffect copy() { + return new SteelSquirrelEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanent(source.getSourceId()); + if (controller != null && permanent != null) { + if (this.getValue("rolled") != null) { + int rolled = (Integer) this.getValue("rolled"); + game.addEffect(new BoostSourceEffect(rolled, rolled, Duration.EndOfTurn), source); + return true; + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/Unstable.java b/Mage.Sets/src/mage/sets/Unstable.java index cc204b77c64..e7a07efbcec 100644 --- a/Mage.Sets/src/mage/sets/Unstable.java +++ b/Mage.Sets/src/mage/sets/Unstable.java @@ -59,6 +59,7 @@ public class Unstable extends ExpansionSet { cards.add(new SetCardInfo("Hammer Helper", 85, Rarity.COMMON, mage.cards.h.HammerHelper.class)); cards.add(new SetCardInfo("Hydradoodle", 112, Rarity.RARE, mage.cards.h.Hydradoodle.class)); cards.add(new SetCardInfo("Island", 213, Rarity.LAND, mage.cards.basiclands.Island.class, new CardGraphicInfo(FrameStyle.UNH_FULL_ART_BASIC, false))); + cards.add(new SetCardInfo("Krark's Other Thumb", 151, Rarity.UNCOMMON, mage.cards.k.KrarksOtherThumb.class)); cards.add(new SetCardInfo("Lobe Lobber", 153, Rarity.UNCOMMON, mage.cards.l.LobeLobber.class)); cards.add(new SetCardInfo("Mad Science Fair Project", 154, Rarity.COMMON, mage.cards.m.MadScienceFairProject.class)); cards.add(new SetCardInfo("Mountain", 215, Rarity.LAND, mage.cards.basiclands.Mountain.class, new CardGraphicInfo(FrameStyle.UNH_FULL_ART_BASIC, false))); @@ -66,6 +67,7 @@ public class Unstable extends ExpansionSet { cards.add(new SetCardInfo("Plains", 212, Rarity.LAND, mage.cards.basiclands.Plains.class, new CardGraphicInfo(FrameStyle.UNH_FULL_ART_BASIC, false))); cards.add(new SetCardInfo("Snickering Squirrel", 68, Rarity.COMMON, mage.cards.s.SnickeringSquirrel.class)); cards.add(new SetCardInfo("Squirrel-Powered Scheme", 70, Rarity.UNCOMMON, mage.cards.s.SquirrelPoweredScheme.class)); + cards.add(new SetCardInfo("Steel Squirrel", 162, Rarity.UNCOMMON, mage.cards.s.SteelSquirrel.class)); cards.add(new SetCardInfo("Swamp", 214, Rarity.LAND, mage.cards.basiclands.Swamp.class, new CardGraphicInfo(FrameStyle.UNH_FULL_ART_BASIC, false))); cards.add(new SetCardInfo("Sword of Dungeons and Dragons", 1, Rarity.MYTHIC, mage.cards.s.SwordOfDungeonsAndDragons.class)); cards.add(new SetCardInfo("Target Minotaur", 98, Rarity.COMMON, mage.cards.t.TargetMinotaur.class)); diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index c37fc4ab0df..42fc10f5533 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -2346,13 +2346,16 @@ public abstract class PlayerImpl implements Player, Serializable { public int rollDice(Game game, ArrayList appliedEffects, int numSides) { int result = RandomUtil.nextInt(numSides) + 1; if (!game.isSimulation()) { - game.informPlayers("[Roll a dice] " + getLogName() + " rolled a " + result + " on a " + numSides + " sided dice"); + game.informPlayers("[Roll a die] " + getLogName() + " rolled a " + result + " on a " + numSides + " sided dice"); } GameEvent event = new GameEvent(GameEvent.EventType.ROLL_DICE, playerId, null, playerId, result, true); event.setAppliedEffects(appliedEffects); event.setAmount(result); + event.setData(numSides + ""); if (!game.replaceEvent(event)) { - game.fireEvent(new GameEvent(GameEvent.EventType.DICE_ROLLED, playerId, null, playerId, event.getAmount(), event.getFlag())); + GameEvent ge = new GameEvent(GameEvent.EventType.DICE_ROLLED, playerId, null, playerId, event.getAmount(), event.getFlag()); + ge.setData(numSides + ""); + game.fireEvent(ge); } return event.getAmount(); }