From 2c5d68010f3dbc9d68b39761acd3b00b89c17359 Mon Sep 17 00:00:00 2001 From: melvin Date: Sat, 15 Dec 2012 10:41:34 +0800 Subject: [PATCH] allow action to be followed by if condition --- grammar/mtg.peg | 2 +- grammar/parsable.txt | 2 ++ src/magic/grammar/MagicRuleParser.java | 20 +++++++++++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/grammar/mtg.peg b/grammar/mtg.peg index 3f3d6007e0..19b97aa830 100644 --- a/grammar/mtg.peg +++ b/grammar/mtg.peg @@ -19,7 +19,7 @@ Effect ; SingleEffect - = (Duration SEP)? (Optional SPACE)? (SelectPlayer SPACE)? (Optional SPACE)? Action (SPACE Duration)? + = (Duration SEP)? (Optional SPACE)? (SelectPlayer SPACE)? (Optional SPACE)? Action (SPACE Duration)? (SPACE IfCondition)? ; Optional diff --git a/grammar/parsable.txt b/grammar/parsable.txt index b149079191..f07cefec17 100644 --- a/grammar/parsable.txt +++ b/grammar/parsable.txt @@ -2106,6 +2106,8 @@ modular 3 modular 4 modular 6 morbid — at the beginning of each end step, if a creature died this turn, destroy target non-demon creature. +morbid — @ enters the battlefield with four +1/+1 counters on it if a creature died this turn. +morbid — @ enters the battlefield with two +1/+1 counters on it if a creature died this turn. morbid — when @ enters the battlefield, if a creature died this turn, put a 2/2 black zombie creature token onto the battlefield. morbid — when @ enters the battlefield, if a creature died this turn, put two +1/+1 counters on target creature. morbid — when @ enters the battlefield, if a creature died this turn, target creature gets -4/-4 until end of turn. diff --git a/src/magic/grammar/MagicRuleParser.java b/src/magic/grammar/MagicRuleParser.java index fb58ce183f..ed371410f2 100644 --- a/src/magic/grammar/MagicRuleParser.java +++ b/src/magic/grammar/MagicRuleParser.java @@ -1,6 +1,6 @@ //========================================================================= // -// This file was generated by Mouse 1.5 at 2012-12-13 05:52:01 GMT +// This file was generated by Mouse 1.5 at 2012-12-15 02:40:20 GMT // from grammar '/home/melvin/Modules/magarena/grammar/mtg.peg'. // //========================================================================= @@ -137,7 +137,8 @@ public class MagicRuleParser extends magic.grammar.ParserMemo //===================================================================== // SingleEffect = (Duration SEP)? (Optional SPACE)? (SelectPlayer - // SPACE)? (Optional SPACE)? Action (SPACE Duration)? ; + // SPACE)? (Optional SPACE)? Action (SPACE Duration)? (SPACE + // IfCondition)? ; //===================================================================== private boolean SingleEffect() { @@ -148,6 +149,7 @@ public class MagicRuleParser extends magic.grammar.ParserMemo SingleEffect_1(); if (!Action()) return reject(); SingleEffect_3(); + SingleEffect_4(); return sem.action() && accept(); } @@ -195,6 +197,17 @@ public class MagicRuleParser extends magic.grammar.ParserMemo return acceptInner(); } + //------------------------------------------------------------------- + // SingleEffect_4 = SPACE IfCondition + //------------------------------------------------------------------- + private boolean SingleEffect_4() + { + if (savedInner(SingleEffect_4)) return reuseInner(); + if (!SPACE()) return rejectInner(); + if (!IfCondition()) return rejectInner(); + return acceptInner(); + } + //===================================================================== // Optional = "you may have" / "you may" / "if you don't," / "if you // can't," / "if you do," / "may" ; @@ -4431,6 +4444,7 @@ public class MagicRuleParser extends magic.grammar.ParserMemo final Cache SingleEffect_1 = new Cache("SingleEffect_1"); // Optional SPACE final Cache SingleEffect_2 = new Cache("SingleEffect_2"); // SelectPlayer SPACE final Cache SingleEffect_3 = new Cache("SingleEffect_3"); // SPACE Duration + final Cache SingleEffect_4 = new Cache("SingleEffect_4"); // SPACE IfCondition final Cache ActivatedAbility_0 = new Cache("ActivatedAbility_0"); // SPACE AbilityRestriction EOS final Cache ActivationCosts_0 = new Cache("ActivationCosts_0"); // SEP Action final Cache TriggeredAbility_0 = new Cache("TriggeredAbility_0"); // SEP IfCondition @@ -4620,7 +4634,7 @@ public class MagicRuleParser extends magic.grammar.ParserMemo Enchantment,Permanent,Card,Spell,NoRegen,PowerToughness, SignedNumber,Number,Sign,SEP,EOC,SPACE,EOS,EOR,Rule_0, SpellEffect_0,Effect_0,SingleEffect_0,SingleEffect_1, - SingleEffect_2,SingleEffect_3,ActivatedAbility_0, + SingleEffect_2,SingleEffect_3,SingleEffect_4,ActivatedAbility_0, ActivationCosts_0,TriggeredAbility_0,Keyword_0,Keyword_1, Keyword_2,Keyword_3,Keyword_4,Keyword_5,Keyword_6,Keyword_7, Keyword_8,Keyword_9,Keyword_10,Keyword_11,Keyword_12,Keyword_13,