From 495786686d941386c52e11c2e93cef1f0d1bcbf5 Mon Sep 17 00:00:00 2001 From: melvin Date: Sat, 1 Feb 2014 11:58:32 +0800 Subject: [PATCH] convert all gain rules to use MagicAbilityList --- .../Magarena/scripts/Sydri__Galvanic_Genius.txt | 2 +- src/magic/model/action/MagicGainAbilityAction.java | 14 +++++++++++--- src/magic/model/event/MagicRuleEventAction.java | 12 ++++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/release/Magarena/scripts/Sydri__Galvanic_Genius.txt b/release/Magarena/scripts/Sydri__Galvanic_Genius.txt index 690f7ace6a..9f5d36aa57 100644 --- a/release/Magarena/scripts/Sydri__Galvanic_Genius.txt +++ b/release/Magarena/scripts/Sydri__Galvanic_Genius.txt @@ -7,6 +7,6 @@ type=Legendary,Creature subtype=Human,Artificer cost={W}{U}{B} pt=2/2 -ability=pay {W}{B}:Target artifact creature gains deathtouch and lifelink until end of turn. +ability=pay {W}{B}:Target artifact creature gains deathtouch, lifelink until end of turn. timing=main requires_groovy_code diff --git a/src/magic/model/action/MagicGainAbilityAction.java b/src/magic/model/action/MagicGainAbilityAction.java index 53199418f5..717fbdc239 100644 --- a/src/magic/model/action/MagicGainAbilityAction.java +++ b/src/magic/model/action/MagicGainAbilityAction.java @@ -17,11 +17,19 @@ public class MagicGainAbilityAction extends MagicAction { private final MagicPermanent permanent; private final MagicAbilityList abilityList; private final boolean duration; + + public MagicGainAbilityAction(final MagicPermanent permanent,final MagicAbilityList abilityList, final boolean duration) { + this.permanent=permanent; + this.abilityList=abilityList; + this.duration=duration; + } public MagicGainAbilityAction(final MagicPermanent permanent,final Set abilities, final boolean duration) { - this.permanent=permanent; - this.abilityList=MagicAbility.getAbilityList(abilities); - this.duration=duration; + this(permanent,MagicAbility.getAbilityList(abilities), duration); + } + + public MagicGainAbilityAction(final MagicPermanent permanent,final MagicAbilityList abilityList) { + this(permanent,abilityList,MagicStatic.UntilEOT); } public MagicGainAbilityAction(final MagicPermanent permanent,final List abilities) { diff --git a/src/magic/model/event/MagicRuleEventAction.java b/src/magic/model/event/MagicRuleEventAction.java index 1dd7f76db3..d0e51eb92c 100644 --- a/src/magic/model/event/MagicRuleEventAction.java +++ b/src/magic/model/event/MagicRuleEventAction.java @@ -530,7 +530,7 @@ public enum MagicRuleEventAction { ) { public MagicEventAction getAction(final String rule) { final Matcher matcher = matched(rule); - final MagicAbility ability = MagicAbility.getAbility(matcher.group("ability")); + final MagicAbilityList abilityList = MagicAbility.getAbilityList(matcher.group("ability")); final String[] pt = matcher.group("pt").replace("+","").split("/"); final int power = Integer.parseInt(pt[0]); final int toughness = Integer.parseInt(pt[1]); @@ -540,7 +540,7 @@ public enum MagicRuleEventAction { event.processTargetPermanent(game,new MagicPermanentAction() { public void doAction(final MagicPermanent creature) { game.doAction(new MagicChangeTurnPTAction(creature,power,toughness)); - game.doAction(new MagicGainAbilityAction(creature,ability)); + game.doAction(new MagicGainAbilityAction(creature,abilityList)); } }); } @@ -671,7 +671,7 @@ public enum MagicRuleEventAction { ) { public MagicEventAction getAction(final String rule) { final Matcher matcher = matched(rule); - final MagicAbility ability = MagicAbility.getAbility(matcher.group("ability")); + final MagicAbilityList abilityList = MagicAbility.getAbilityList(matcher.group("ability")); final String[] pt = matcher.group("pt").replace("+","").split("/"); final int power = Integer.parseInt(pt[0]); final int toughness = Integer.parseInt(pt[1]); @@ -681,7 +681,7 @@ public enum MagicRuleEventAction { event.processTargetPermanent(game,new MagicPermanentAction() { public void doAction(final MagicPermanent creature) { game.doAction(new MagicChangeTurnPTAction(creature,power,toughness)); - game.doAction(new MagicGainAbilityAction(creature,ability)); + game.doAction(new MagicGainAbilityAction(creature,abilityList)); } }); } @@ -737,13 +737,13 @@ public enum MagicRuleEventAction { ) { public MagicEventAction getAction(final String rule) { final Matcher matcher = matched(rule); - final MagicAbility ability = MagicAbility.getAbility(matcher.group("ability")); + final MagicAbilityList abilityList = MagicAbility.getAbilityList(matcher.group("ability")); return new MagicEventAction() { @Override public void executeEvent(final MagicGame game, final MagicEvent event) { event.processTargetPermanent(game,new MagicPermanentAction() { public void doAction(final MagicPermanent creature) { - game.doAction(new MagicGainAbilityAction(creature,ability)); + game.doAction(new MagicGainAbilityAction(creature,abilityList)); } }); }