From 25442651deefc8d475c2ff3920ebfd699a038e09 Mon Sep 17 00:00:00 2001 From: melvin Date: Tue, 15 Nov 2011 22:24:28 +0800 Subject: [PATCH] simplified MagicCardDefinition.setAbility, separate ability name and arg in CardDefinitions --- src/magic/data/CardDefinitions.java | 4 +++- src/magic/model/MagicCardDefinition.java | 28 ++++++------------------ 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/magic/data/CardDefinitions.java b/src/magic/data/CardDefinitions.java index b0648cdc8c..744c70b43a 100644 --- a/src/magic/data/CardDefinitions.java +++ b/src/magic/data/CardDefinitions.java @@ -99,7 +99,9 @@ public class CardDefinitions { } else if ("ability".equals(property)) { final String names[]=value.split(","); for (final String name : names) { - card.setAbility(MagicAbility.getAbility(name)); + final MagicAbility ability = MagicAbility.getAbility(name); + final String arg = name.substring(ability.toString().length()).trim(); + card.setAbility(ability, arg); } } else if ("given_pt".equals(property)) { if (!card.isEquipment() && !card.isAura()) { diff --git a/src/magic/model/MagicCardDefinition.java b/src/magic/model/MagicCardDefinition.java index 08c2e961f2..d5853e6a31 100644 --- a/src/magic/model/MagicCardDefinition.java +++ b/src/magic/model/MagicCardDefinition.java @@ -13,12 +13,6 @@ import magic.model.event.MagicPlayCardEvent; import magic.model.event.MagicSpellCardEvent; import magic.model.event.MagicTapManaActivation; import magic.model.event.MagicTiming; -import magic.model.trigger.MagicBattleCryTrigger; -import magic.model.trigger.MagicExaltedTrigger; -import magic.model.trigger.MagicLivingWeaponTrigger; -import magic.model.trigger.MagicEchoTrigger; -import magic.model.trigger.MagicTappedIntoPlayTrigger; -import magic.model.trigger.MagicModularTrigger; import magic.model.trigger.MagicTrigger; import magic.model.mstatic.MagicStatic; import magic.model.mstatic.MagicCDA; @@ -600,22 +594,14 @@ public class MagicCardDefinition { } return pt; } - + public void setAbility(final MagicAbility ability) { - abilityFlags|=ability.getMask(); - if (ability==MagicAbility.Exalted) { - add(MagicExaltedTrigger.getInstance()); - } else if (ability==MagicAbility.BattleCry) { - add(MagicBattleCryTrigger.getInstance()); - } else if (ability==MagicAbility.LivingWeapon) { - add(MagicLivingWeaponTrigger.getInstance()); - } else if (ability==MagicAbility.Echo) { - add(MagicEchoTrigger.create()); - } else if (ability==MagicAbility.EntersTapped) { - add(MagicTappedIntoPlayTrigger.create()); - } else if (ability==MagicAbility.Modular) { - add(MagicModularTrigger.create()); - } + setAbility(ability, ""); + } + + public void setAbility(final MagicAbility ability, final String arg) { + abilityFlags |= ability.getMask(); + ability.addAbilityImpl(this, arg); } public long getAbilityFlags() {