From c926e31e23ebbd3bf94176123ac4e5521058b13b Mon Sep 17 00:00:00 2001 From: melvin Date: Thu, 17 Oct 2013 21:01:21 +0800 Subject: [PATCH] replace groovy code with ability in card script --- ...xt => 1_1_green_Insect_creature_token.txt} | 2 +- release/Magarena/scripts/Ant_Queen.groovy | 23 ------------------- release/Magarena/scripts/Ant_Queen.txt | 2 +- .../Magarena/scripts/Symbiotic_Beast.groovy | 20 ---------------- release/Magarena/scripts/Symbiotic_Beast.txt | 2 +- release/Magarena/scripts/Symbiotic_Elf.groovy | 20 ---------------- release/Magarena/scripts/Symbiotic_Elf.txt | 2 +- .../Magarena/scripts/Symbiotic_Wurm.groovy | 20 ---------------- release/Magarena/scripts/Symbiotic_Wurm.txt | 2 +- .../model/event/MagicRuleEventAction.java | 11 +++++---- 10 files changed, 12 insertions(+), 92 deletions(-) rename release/Magarena/scripts/{Insect4.txt => 1_1_green_Insect_creature_token.txt} (78%) delete mode 100644 release/Magarena/scripts/Ant_Queen.groovy delete mode 100644 release/Magarena/scripts/Symbiotic_Beast.groovy delete mode 100644 release/Magarena/scripts/Symbiotic_Elf.groovy delete mode 100644 release/Magarena/scripts/Symbiotic_Wurm.groovy diff --git a/release/Magarena/scripts/Insect4.txt b/release/Magarena/scripts/1_1_green_Insect_creature_token.txt similarity index 78% rename from release/Magarena/scripts/Insect4.txt rename to release/Magarena/scripts/1_1_green_Insect_creature_token.txt index 4bdf5cb1ee..16298b4405 100644 --- a/release/Magarena/scripts/Insect4.txt +++ b/release/Magarena/scripts/1_1_green_Insect_creature_token.txt @@ -1,4 +1,4 @@ -name=Insect4 +name=1/1 green Insect creature token token=Insect image=http://magiccards.info/extras/token/magic-2010/insect.jpg value=2 diff --git a/release/Magarena/scripts/Ant_Queen.groovy b/release/Magarena/scripts/Ant_Queen.groovy deleted file mode 100644 index dfbc92a045..0000000000 --- a/release/Magarena/scripts/Ant_Queen.groovy +++ /dev/null @@ -1,23 +0,0 @@ -[ - new MagicPermanentActivation( - new MagicActivationHints(MagicTiming.Flash), - "Token" - ) { - @Override - public Iterable getCostEvent(final MagicPermanent source) { - return [new MagicPayManaCostEvent(source,"{1}{G}")]; - } - @Override - public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) { - return new MagicEvent( - source, - this, - "Put a 1/1 green Insect creature token onto the battlefield." - ); - } - @Override - public void executeEvent(final MagicGame game, final MagicEvent event) { - game.doAction(new MagicPlayTokenAction(event.getPlayer(), TokenCardDefinitions.get("Insect4"))); - } - } -] diff --git a/release/Magarena/scripts/Ant_Queen.txt b/release/Magarena/scripts/Ant_Queen.txt index b83c4708d7..8d1705b8ec 100644 --- a/release/Magarena/scripts/Ant_Queen.txt +++ b/release/Magarena/scripts/Ant_Queen.txt @@ -7,5 +7,5 @@ type=Creature subtype=Insect cost={3}{G}{G} pt=5/5 +ability=pay {1}{G}: PN puts a 1/1 green Insect creature token onto the battlefield. timing=main -requires_groovy_code diff --git a/release/Magarena/scripts/Symbiotic_Beast.groovy b/release/Magarena/scripts/Symbiotic_Beast.groovy deleted file mode 100644 index c0b11c5e48..0000000000 --- a/release/Magarena/scripts/Symbiotic_Beast.groovy +++ /dev/null @@ -1,20 +0,0 @@ -[ - new MagicWhenDiesTrigger() { - @Override - public MagicEvent getEvent(final MagicPermanent permanent) { - return new MagicEvent( - permanent, - this, - "PN puts four 1/1 green Insect creature tokens onto the battlefield." - ); - } - @Override - public void executeEvent(final MagicGame game, final MagicEvent event) { - game.doAction(new MagicPlayTokensAction( - event.getPlayer(), - TokenCardDefinitions.get("Insect4"), - 4 - )); - } - } -] diff --git a/release/Magarena/scripts/Symbiotic_Beast.txt b/release/Magarena/scripts/Symbiotic_Beast.txt index c1ce69a566..6a43909239 100644 --- a/release/Magarena/scripts/Symbiotic_Beast.txt +++ b/release/Magarena/scripts/Symbiotic_Beast.txt @@ -7,5 +7,5 @@ type=Creature subtype=Insect,Beast cost={4}{G}{G} pt=4/4 +ability=dies effect PN puts four 1/1 green Insect creature tokens onto the battlefield. timing=main -requires_groovy_code diff --git a/release/Magarena/scripts/Symbiotic_Elf.groovy b/release/Magarena/scripts/Symbiotic_Elf.groovy deleted file mode 100644 index 53d1c9eaf7..0000000000 --- a/release/Magarena/scripts/Symbiotic_Elf.groovy +++ /dev/null @@ -1,20 +0,0 @@ -[ - new MagicWhenDiesTrigger() { - @Override - public MagicEvent getEvent(final MagicPermanent permanent) { - return new MagicEvent( - permanent, - this, - "PN puts two 1/1 green Insect creature tokens onto the battlefield." - ); - } - @Override - public void executeEvent(final MagicGame game, final MagicEvent event) { - game.doAction(new MagicPlayTokensAction( - event.getPlayer(), - TokenCardDefinitions.get("Insect4"), - 2 - )); - } - } -] diff --git a/release/Magarena/scripts/Symbiotic_Elf.txt b/release/Magarena/scripts/Symbiotic_Elf.txt index 2a87189eb5..2da94dffba 100644 --- a/release/Magarena/scripts/Symbiotic_Elf.txt +++ b/release/Magarena/scripts/Symbiotic_Elf.txt @@ -7,5 +7,5 @@ type=Creature subtype=Elf cost={3}{G} pt=2/2 +ability=dies effect PN puts two 1/1 green Insect creature tokens onto the battlefield. timing=main -requires_groovy_code diff --git a/release/Magarena/scripts/Symbiotic_Wurm.groovy b/release/Magarena/scripts/Symbiotic_Wurm.groovy deleted file mode 100644 index c724073d8c..0000000000 --- a/release/Magarena/scripts/Symbiotic_Wurm.groovy +++ /dev/null @@ -1,20 +0,0 @@ -[ - new MagicWhenDiesTrigger() { - @Override - public MagicEvent getEvent(final MagicPermanent permanent) { - return new MagicEvent( - permanent, - this, - "PN puts seven 1/1 green Insect creature tokens onto the battlefield." - ); - } - @Override - public void executeEvent(final MagicGame game, final MagicEvent event) { - game.doAction(new MagicPlayTokensAction( - event.getPlayer(), - TokenCardDefinitions.get("Insect4"), - 7 - )); - } - } -] diff --git a/release/Magarena/scripts/Symbiotic_Wurm.txt b/release/Magarena/scripts/Symbiotic_Wurm.txt index a14c5d9274..fdd9ee4999 100644 --- a/release/Magarena/scripts/Symbiotic_Wurm.txt +++ b/release/Magarena/scripts/Symbiotic_Wurm.txt @@ -7,5 +7,5 @@ type=Creature subtype=Wurm cost={5}{G}{G}{G} pt=7/7 +ability=dies effect PN puts seven 1/1 green Insect creature tokens onto the battlefield. timing=main -requires_groovy_code diff --git a/src/magic/model/event/MagicRuleEventAction.java b/src/magic/model/event/MagicRuleEventAction.java index 517e75cc1f..e52742bd52 100644 --- a/src/magic/model/event/MagicRuleEventAction.java +++ b/src/magic/model/event/MagicRuleEventAction.java @@ -20,7 +20,7 @@ import magic.model.action.MagicChangeLifeAction; import magic.model.action.MagicTapAction; import magic.model.action.MagicUntapAction; import magic.model.action.MagicChangeCountersAction; -import magic.model.action.MagicPlayTokenAction; +import magic.model.action.MagicPlayTokensAction; import magic.model.stack.MagicCardOnStack; import magic.model.target.MagicTarget; import magic.model.target.MagicTargetHint; @@ -321,18 +321,20 @@ public enum MagicRuleEventAction { } ), Token( - "pn puts a(n)? (?[^\\.]*) onto the battlefield.", + "pn puts (?[a-z]+) (?[^\\.]*) onto the battlefield.", MagicTiming.Token, "Token" ) { public MagicEventAction getAction(final String rule) { final Matcher matcher = matched(rule); + final int amount = englishToInt(matcher.group("amount")); return new MagicEventAction() { @Override public void executeEvent(final MagicGame game, final MagicEvent event) { - game.doAction(new MagicPlayTokenAction( + game.doAction(new MagicPlayTokensAction( event.getPlayer(), - TokenCardDefinitions.get(matcher.group("name")) + TokenCardDefinitions.get(matcher.group("name")), + amount )); } }; @@ -447,6 +449,7 @@ public enum MagicRuleEventAction { public static int englishToInt(String num) { switch (num) { case "a": return 1; + case "an": return 1; case "two": return 2; case "three" : return 3; case "four" : return 4;