From c85b4830a51979c445d01324bbf04e3729bd6fa0 Mon Sep 17 00:00:00 2001 From: spjspj Date: Sat, 20 May 2017 15:44:30 +1000 Subject: [PATCH 1/2] spjspj - Implement Infernal Darkness (ME2 & ICE) --- .../src/mage/cards/i/InfernalDarkness.java | 172 ++++++++++++++++++ Mage.Sets/src/mage/sets/IceAge.java | 1 + Mage.Sets/src/mage/sets/MastersEditionII.java | 1 + 3 files changed, 174 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/i/InfernalDarkness.java diff --git a/Mage.Sets/src/mage/cards/i/InfernalDarkness.java b/Mage.Sets/src/mage/cards/i/InfernalDarkness.java new file mode 100644 index 0000000000..52dce517c0 --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/InfernalDarkness.java @@ -0,0 +1,172 @@ +/* + * 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.i; + +import java.util.UUID; +import mage.MageObject; +import mage.Mana; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.CostImpl; +import mage.abilities.costs.common.PayLifeCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.keyword.CumulativeUpkeepAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.game.events.ManaEvent; +import mage.players.Player; + +/** + * + * @author spjspj + */ +public class InfernalDarkness extends CardImpl { + + public InfernalDarkness(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}{B}"); + + // Cumulative upkeep-Pay {B} and 1 life. + this.addAbility(new CumulativeUpkeepAbility(new InfernalDarknessCost())); + + // If a land is tapped for mana, it produces {B} instead of any other type. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new InfernalDarknessReplacementEffect())); + + } + + public InfernalDarkness(final InfernalDarkness card) { + super(card); + } + + @Override + public InfernalDarkness copy() { + return new InfernalDarkness(this); + } +} + +class InfernalDarknessCost extends CostImpl { + + ManaCostsImpl manaCost = new ManaCostsImpl("{B}"); + Cost lifeCost = new PayLifeCost(1); + + public InfernalDarknessCost() { + this.text = "Pay {B} and 1 life"; + } + + public InfernalDarknessCost(InfernalDarknessCost cost) { + super(cost); + this.manaCost = cost.manaCost; + this.lifeCost = cost.lifeCost; + } + + @Override + public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { + + Player player = game.getPlayer(controllerId); + if (player == null) { + return false; + } + + paid = false; + + manaCost.clearPaid(); + if (manaCost.pay(ability, game, player.getId(), player.getId(), false) + && player.canPayLifeCost() + && player.getLife() >= 1 + && lifeCost.pay(ability, game, player.getId(), player.getId(), false)) { + paid = true; + } + + return paid; + } + + @Override + public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { + Player player = game.getPlayer(controllerId); + if (player != null + && player.canPayLifeCost() + && player.getLife() >= 1) { + return true; + } + return false; + } + + @Override + public InfernalDarknessCost copy() { + return new InfernalDarknessCost(this); + } +} + +class InfernalDarknessReplacementEffect extends ReplacementEffectImpl { + + InfernalDarknessReplacementEffect() { + super(Duration.WhileOnBattlefield, Outcome.Neutral); + staticText = "If a land is tapped for mana, it produces {B} instead of any other type"; + } + + InfernalDarknessReplacementEffect(final InfernalDarknessReplacementEffect effect) { + super(effect); + } + + @Override + public InfernalDarknessReplacementEffect copy() { + return new InfernalDarknessReplacementEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + ManaEvent manaEvent = (ManaEvent) event; + Mana mana = manaEvent.getMana(); + mana.setToMana(Mana.BlackMana(mana.count())); + return false; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == EventType.TAPPED_FOR_MANA; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + MageObject mageObject = game.getObject(event.getSourceId()); + return mageObject != null && mageObject.isLand(); + } +} diff --git a/Mage.Sets/src/mage/sets/IceAge.java b/Mage.Sets/src/mage/sets/IceAge.java index 68aa630f9f..672f7c76a9 100644 --- a/Mage.Sets/src/mage/sets/IceAge.java +++ b/Mage.Sets/src/mage/sets/IceAge.java @@ -154,6 +154,7 @@ public class IceAge extends ExpansionSet { cards.add(new SetCardInfo("Illusions of Grandeur", 79, Rarity.RARE, mage.cards.i.IllusionsOfGrandeur.class)); cards.add(new SetCardInfo("Imposing Visage", 193, Rarity.COMMON, mage.cards.i.ImposingVisage.class)); cards.add(new SetCardInfo("Incinerate", 194, Rarity.COMMON, mage.cards.i.Incinerate.class)); + cards.add(new SetCardInfo("Infernal Darkness", 23, Rarity.RARE, mage.cards.i.InfernalDarkness.class)); cards.add(new SetCardInfo("Infuse", 80, Rarity.COMMON, mage.cards.i.Infuse.class)); cards.add(new SetCardInfo("Island", 334, Rarity.LAND, mage.cards.basiclands.Island.class, new CardGraphicInfo(null, true))); cards.add(new SetCardInfo("Island", 335, Rarity.LAND, mage.cards.basiclands.Island.class, new CardGraphicInfo(null, true))); diff --git a/Mage.Sets/src/mage/sets/MastersEditionII.java b/Mage.Sets/src/mage/sets/MastersEditionII.java index 1fcdf2b2f6..c57ee4af00 100644 --- a/Mage.Sets/src/mage/sets/MastersEditionII.java +++ b/Mage.Sets/src/mage/sets/MastersEditionII.java @@ -139,6 +139,7 @@ public class MastersEditionII extends ExpansionSet { cards.add(new SetCardInfo("Imperial Recruiter", 130, Rarity.RARE, mage.cards.i.ImperialRecruiter.class)); cards.add(new SetCardInfo("Imperial Seal", 96, Rarity.RARE, mage.cards.i.ImperialSeal.class)); cards.add(new SetCardInfo("Incinerate", 131, Rarity.COMMON, mage.cards.i.Incinerate.class)); + cards.add(new SetCardInfo("Infernal Darkness", 97, Rarity.RARE, mage.cards.i.InfernalDarkness.class)); cards.add(new SetCardInfo("Inheritance", 18, Rarity.UNCOMMON, mage.cards.i.Inheritance.class)); cards.add(new SetCardInfo("Ironclaw Orcs", 132, Rarity.COMMON, mage.cards.i.IronclawOrcs.class)); cards.add(new SetCardInfo("Jester's Mask", 211, Rarity.RARE, mage.cards.j.JestersMask.class)); From e752ee3156e04177a860ed6f4761aa58b7f3acfd Mon Sep 17 00:00:00 2001 From: spjspj Date: Sat, 20 May 2017 15:45:40 +1000 Subject: [PATCH 2/2] EDH Power level fix --- .../util/CardViewEDHPowerLevelComparator.java | 7 ++++++- .../src/mage/deck/Commander.java | 19 ++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/util/CardViewEDHPowerLevelComparator.java b/Mage.Client/src/main/java/mage/client/util/CardViewEDHPowerLevelComparator.java index 105c9cbeed..2a1aa37a0c 100644 --- a/Mage.Client/src/main/java/mage/client/util/CardViewEDHPowerLevelComparator.java +++ b/Mage.Client/src/main/java/mage/client/util/CardViewEDHPowerLevelComparator.java @@ -96,6 +96,7 @@ public class CardViewEDHPowerLevelComparator implements Comparator { boolean xCost = false; boolean youControlTarget = false; boolean yourOpponentsControl = false; + boolean whenYouCast = false; for (String str : card.getRules()) { String s = str.toLowerCase(); @@ -103,7 +104,7 @@ public class CardViewEDHPowerLevelComparator implements Comparator { anyNumberOfTarget |= s.contains("any number"); buyback |= s.contains("buyback"); cantBe |= s.contains("can't be"); - cantUntap |= s.contains("can't untap"); + cantUntap |= s.contains("can't untap") || s.contains("don't untap"); cascade |= s.contains("cascade"); copy |= s.contains("copy"); costLessEach |= s.contains("cost") || s.contains("less") || s.contains("each"); @@ -155,6 +156,7 @@ public class CardViewEDHPowerLevelComparator implements Comparator { wheneverEnters |= s.contains("when") && s.contains("another") && s.contains("enters"); youControlTarget |= s.contains("you control target"); yourOpponentsControl |= s.contains("your opponents control"); + whenYouCast |= s.contains("when you cast") || s.contains("whenever you cast"); } if (extraTurns) { @@ -256,6 +258,9 @@ public class CardViewEDHPowerLevelComparator implements Comparator { if (yourOpponentsControl) { thisMaxPower = Math.max(thisMaxPower, 4); } + if (whenYouCast) { + thisMaxPower = Math.max(thisMaxPower, 4); + } if (anyNumberOfTarget) { thisMaxPower = Math.max(thisMaxPower, 3); } diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Commander.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Commander.java index 03e3790980..ec32c1aa96 100644 --- a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Commander.java +++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Commander.java @@ -272,6 +272,7 @@ public class Commander extends Constructed { boolean xCost = false; boolean youControlTarget = false; boolean yourOpponentsControl = false; + boolean whenYouCast = false; for (String str : card.getRules()) { String s = str.toLowerCase(); @@ -331,6 +332,7 @@ public class Commander extends Constructed { wheneverEnters |= s.contains("when") && s.contains("another") && s.contains("enters"); youControlTarget |= s.contains("you control target"); yourOpponentsControl |= s.contains("your opponents control"); + whenYouCast |= s.contains("when you cast") || s.contains("whenever you cast"); } for (ManaCost cost : card.getManaCost()) { @@ -445,6 +447,9 @@ public class Commander extends Constructed { if (yourOpponentsControl) { thisMaxPower = Math.max(thisMaxPower, 4); } + if (whenYouCast) { + thisMaxPower = Math.max(thisMaxPower, 4); + } if (anyNumberOfTarget) { thisMaxPower = Math.max(thisMaxPower, 3); } @@ -749,16 +754,16 @@ public class Commander extends Constructed { } edhPowerLevel += numberInfinitePieces * 12; - edhPowerLevel = (int) Math.round(edhPowerLevel / 4.5); - if (edhPowerLevel > 100) { - edhPowerLevel = 100; + edhPowerLevel = (int) Math.round(edhPowerLevel / 10); + if (edhPowerLevel >= 100) { + edhPowerLevel = 99; } if (color != null) { edhPowerLevel += (color.isWhite() ? 10000000 : 0); - edhPowerLevel += (color.isBlue() ? 1000000 : 0); - edhPowerLevel += (color.isBlack() ? 100000 : 0); - edhPowerLevel += (color.isRed() ? 10000 : 0); - edhPowerLevel += (color.isGreen() ? 1000 : 0); + edhPowerLevel += (color.isBlue() ? 1000000 : 0); + edhPowerLevel += (color.isBlack() ? 100000 : 0); + edhPowerLevel += (color.isRed() ? 10000 : 0); + edhPowerLevel += (color.isGreen() ? 1000 : 0); } return edhPowerLevel; }