From f4db8078b8dbaba2c45cb5ec6521860b8075c3b0 Mon Sep 17 00:00:00 2001 From: swordshine Date: Tue, 4 Feb 2014 08:13:50 +0000 Subject: [PATCH] - Converted Chains of Mephistopheles to script (it's a normal replacement effect, the original hardcoded script is not correct) --- .../main/java/forge/game/player/Player.java | 38 ------------------- .../forge/game/replacement/ReplaceDraw.java | 4 +- .../c/chains_of_mephistopheles.txt | 8 ++-- 3 files changed, 7 insertions(+), 43 deletions(-) diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index 91589788654..086488f4e17 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -1306,44 +1306,6 @@ public class Player extends GameEntity implements Comparable { return drawn; } - // ======== Chains of Mephistopheles hardcode. ========= - // This card requires player to either discard a card, and then he may proceed drawing, or mill 1 - then no draw will happen - // It's oracle-worded as a replacement effect ("If a player would draw a card ... discards a card instead") (rule 419.1a) - // Yet, gatherer's rulings read: The effect is cumulative. If there are two of these on the battlefield, each of them will modify each draw - // That means player isn't supposed to choose one replacement effect out of two (generated by Chains Of Mephistopheles), but both happen. - // So it's not a common replacement effect and has to be handled by special code. - - // This is why the code is placed after any other replacement effects could affect the draw event. - List chainsList = null; - for(Card c : game.getCardsIn(ZoneType.Battlefield)) { - if ( c.getName().equals("Chains of Mephistopheles") ) { - if ( null == chainsList ) - chainsList = new ArrayList(); - chainsList.add(c); - } - } - if (chainsList != null && (numDrawnThisDrawStep > 0 || !game.getPhaseHandler().is(PhaseType.DRAW))) { - for(Card c : chainsList) { - // I have to target this player - don't know how to do it. - - - if (getCardsIn(ZoneType.Hand).isEmpty()) { - SpellAbility saMill = AbilityFactory.getAbility(c.getSVar("MillOne"), c); - saMill.setActivatingPlayer(c.getController()); - saMill.getTargets().add(this); - AbilityUtils.resolve(saMill); - - return drawn; // Draw is cancelled - } else { - SpellAbility saDiscard = AbilityFactory.getAbility(c.getSVar("DiscardOne"), c); - saDiscard.setActivatingPlayer(c.getController()); - saDiscard.getTargets().add(this); - AbilityUtils.resolve(saDiscard); - } - } - } - // End of = Chains of Mephistopheles hardcode. ========= - if (!library.isEmpty()) { Card c = library.get(0); diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceDraw.java b/forge-game/src/main/java/forge/game/replacement/ReplaceDraw.java index bc35a5ec832..ed462672ae2 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceDraw.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceDraw.java @@ -56,8 +56,8 @@ public class ReplaceDraw extends ReplacementEffect { if (this.getMapParams().containsKey("NotFirstCardInDrawStep")) { final Player p = (Player)runParams.get("Affected"); if (p.numDrawnThisDrawStep() == 0 - && this.getHostCard().getController().getGame().getPhaseHandler().is(PhaseType.DRAW) - && this.getHostCard().getController().getGame().getPhaseHandler().getPlayerTurn().equals(p)) { + && this.getHostCard().getGame().getPhaseHandler().is(PhaseType.DRAW) + && this.getHostCard().getGame().getPhaseHandler().isPlayerTurn(p)) { return false; } } diff --git a/forge-gui/res/cardsfolder/c/chains_of_mephistopheles.txt b/forge-gui/res/cardsfolder/c/chains_of_mephistopheles.txt index c53aed00812..45ce6346fe0 100644 --- a/forge-gui/res/cardsfolder/c/chains_of_mephistopheles.txt +++ b/forge-gui/res/cardsfolder/c/chains_of_mephistopheles.txt @@ -1,9 +1,11 @@ Name:Chains of Mephistopheles ManaCost:1 B Types:Enchantment -Text:If a player would draw a card except the first one he or she draws in his or her draw step each turn, that player discards a card instead. If the player discards a card this way, he or she draws a card. If the player doesn't discard a card this way, he or she puts the top card of his or her library into his or her graveyard. -SVar:MillOne:DB$ Mill | NumCards$ 1 -SVar:DiscardOne:DB$ Discard | Mandatory$ True | NumCards$ 1 | Mode$ TgtChoose +R:Event$ Draw | ActiveZones$ Battlefield | ValidPlayer$ Player | ReplaceWith$ DiscardOne | NotFirstCardInDrawStep$ True | Description$ If a player would draw a card except the first one he or she draws in his or her draw step each turn, that player discards a card instead. If the player discards a card this way, he or she draws a card. If the player doesn't discard a card this way, he or she puts the top card of his or her library into his or her graveyard. +SVar:DiscardOne:DB$ Discard | Defined$ ReplacedPlayer | Mandatory$ True | NumCards$ 1 | Mode$ TgtChoose | RememberDiscarded$ True | SubAbility$ DBDraw +SVar:DBDraw:DB$ Draw | Defined$ ReplacedPlayer | ConditionDefined$ Remembered | ConditionPresent$ Card | ConditionCompare$ GE1 | NumCards$ 1 | SubAbility$ MillOne +SVar:MillOne:DB$ Mill | NumCards$ 1 | Defined$ ReplacedPlayer | ConditionDefined$ Remembered | ConditionPresent$ Card | ConditionCompare$ EQ0 | SubAbility$ DBCleanup +SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True SVar:RemRandomDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/chains_of_mephistopheles.jpg Oracle:If a player would draw a card except the first one he or she draws in his or her draw step each turn, that player discards a card instead. If the player discards a card this way, he or she draws a card. If the player doesn't discard a card this way, he or she puts the top card of his or her library into his or her graveyard. \ No newline at end of file