From 0c2132f7b958e83f24271af531019981ca87fcad Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 17 Apr 2018 16:57:55 -0400 Subject: [PATCH] Implemented Chainer's Torment --- .../src/mage/cards/c/ChainersTorment.java | 116 ++++++++++++++++++ Mage.Sets/src/mage/sets/Dominaria.java | 1 + .../token/ChainersTormentNightmareToken.java | 55 +++++++++ 3 files changed, 172 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/ChainersTorment.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/ChainersTormentNightmareToken.java diff --git a/Mage.Sets/src/mage/cards/c/ChainersTorment.java b/Mage.Sets/src/mage/cards/c/ChainersTorment.java new file mode 100644 index 00000000000..446eae23666 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/ChainersTorment.java @@ -0,0 +1,116 @@ +/* + * 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.c; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.SagaAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.DamagePlayersEffect; +import mage.abilities.effects.common.GainLifeEffect; +import mage.constants.SubType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SagaChapter; +import mage.constants.TargetController; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.ChainersTormentNightmareToken; +import mage.players.Player; + +/** + * + * @author TheElk801 + */ +public class ChainersTorment extends CardImpl { + + public ChainersTorment(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{B}"); + + this.subtype.add(SubType.SAGA); + + // (As this Saga enters and after your draw step, add a lore counter. Sacrifice after III.) + SagaAbility sagaAbility = new SagaAbility(this, SagaChapter.CHAPTER_III); + + // I, II — Chainer's Torment deals 2 damage to each opponent and you gain 2 life. + Ability ability = sagaAbility.addChapterEffect(this, SagaChapter.CHAPTER_I, SagaChapter.CHAPTER_II, new DamagePlayersEffect(2, TargetController.OPPONENT)); + ability.addEffect(new GainLifeEffect(2).setText("and you gain 2 life")); + + // III — Create an X/X black Nightmare Horror creature token, where X is half your life total, rounded up. It deals X damage to you. + sagaAbility.addChapterEffect(this, SagaChapter.CHAPTER_III, new ChainersTormentEffect()); + this.addAbility(sagaAbility); + } + + public ChainersTorment(final ChainersTorment card) { + super(card); + } + + @Override + public ChainersTorment copy() { + return new ChainersTorment(this); + } +} + +class ChainersTormentEffect extends OneShotEffect { + + ChainersTormentEffect() { + super(Outcome.Benefit); + this.staticText = "Create an X/X black Nightmare Horror creature token, where X is half your life total, rounded up. It deals X damage to you"; + } + + ChainersTormentEffect(final ChainersTormentEffect effect) { + super(effect); + } + + @Override + public ChainersTormentEffect copy() { + return new ChainersTormentEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + int xValue = (int) Math.ceil((1.0 * Math.max(0, player.getLife())) / 2); + CreateTokenEffect effect = new CreateTokenEffect(new ChainersTormentNightmareToken(xValue)); + if (effect.apply(game, source)) { + for (UUID tokenId : effect.getLastAddedTokenIds()) { + Permanent token = game.getPermanentOrLKIBattlefield(tokenId); + if (token != null) { + player.damage(xValue, tokenId, game, false, true); + } + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/Dominaria.java b/Mage.Sets/src/mage/sets/Dominaria.java index 7c398d73eec..1cd5a3e4f08 100644 --- a/Mage.Sets/src/mage/sets/Dominaria.java +++ b/Mage.Sets/src/mage/sets/Dominaria.java @@ -86,6 +86,7 @@ public class Dominaria extends ExpansionSet { cards.add(new SetCardInfo("Caligo Skin-Witch", 80, Rarity.COMMON, mage.cards.c.CaligoSkinWitch.class)); cards.add(new SetCardInfo("Call the Cavalry", 9, Rarity.COMMON, mage.cards.c.CallTheCavalry.class)); cards.add(new SetCardInfo("Cast Down", 81, Rarity.UNCOMMON, mage.cards.c.CastDown.class)); + cards.add(new SetCardInfo("Chainer's Torment", 82, Rarity.UNCOMMON, mage.cards.c.ChainersTorment.class)); cards.add(new SetCardInfo("Champion of the Flame", 116, Rarity.UNCOMMON, mage.cards.c.ChampionOfTheFlame.class)); cards.add(new SetCardInfo("Charge", 10, Rarity.COMMON, mage.cards.c.Charge.class)); cards.add(new SetCardInfo("Clifftop Retreat", 239, Rarity.RARE, mage.cards.c.ClifftopRetreat.class)); diff --git a/Mage/src/main/java/mage/game/permanent/token/ChainersTormentNightmareToken.java b/Mage/src/main/java/mage/game/permanent/token/ChainersTormentNightmareToken.java new file mode 100644 index 00000000000..db1d907981b --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/ChainersTormentNightmareToken.java @@ -0,0 +1,55 @@ +/* +* 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 mage.constants.CardType; +import mage.constants.SubType; +import mage.MageInt; + +/** + * + * @author spjspj + */ +public class ChainersTormentNightmareToken extends TokenImpl { + + public ChainersTormentNightmareToken(int xValue) { + super("Nightmare", "X/X black Nightmare artifact creature token"); + cardType.add(CardType.CREATURE); + subtype.add(SubType.NIGHTMARE); + power = new MageInt(xValue); + toughness = new MageInt(xValue); + } + + public ChainersTormentNightmareToken(final ChainersTormentNightmareToken token) { + super(token); + } + + public ChainersTormentNightmareToken copy() { + return new ChainersTormentNightmareToken(this); + } +}