support ability containing comma by quoting them like in rules text
parent
1195fb4242
commit
3f4b7fb05a
|
@ -7,6 +7,6 @@ type=Creature
|
|||
subtype=Sliver
|
||||
cost={B}{R}
|
||||
pt=2/2
|
||||
ability=lord all slivers have pay {2},{S}: SN deals 2 damage to target creature or player.
|
||||
ability=lord all slivers have "pay {2},{S}: SN deals 2 damage to target creature or player."
|
||||
static=all
|
||||
timing=main
|
||||
|
|
|
@ -7,7 +7,7 @@ type=Creature
|
|||
subtype=Sliver
|
||||
cost={R}{W}
|
||||
pt=2/2
|
||||
ability=lord all slivers have pay {1},{S}: SN deals 1 damage to target creature or player.
|
||||
ability=lord all slivers have "pay {1},{S}: SN deals 1 damage to target creature or player."
|
||||
static=all
|
||||
timing=main
|
||||
requires_groovy_code
|
||||
|
|
|
@ -7,6 +7,6 @@ type=Creature
|
|||
subtype=Sliver
|
||||
cost={2}{U}
|
||||
pt=2/2
|
||||
ability=lord all slivers have pay {2},{S}: PN draws a card.
|
||||
ability=lord all slivers have "pay {2},{S}: PN draws a card."
|
||||
static=all
|
||||
timing=main
|
||||
|
|
|
@ -87,6 +87,8 @@ import magic.model.trigger.MagicWhenDamageIsDealtTrigger;
|
|||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public enum MagicAbility {
|
||||
|
||||
|
@ -811,7 +813,7 @@ public enum MagicAbility {
|
|||
card.add(MagicStatic.genPTStatic(filter, power, toughness));
|
||||
}
|
||||
} else {
|
||||
final MagicAbilityList abilityList = MagicAbility.getAbilityList(tokens[1].split(", "));
|
||||
final MagicAbilityList abilityList = MagicAbility.getAbilityList(tokens[1]);
|
||||
if (other) {
|
||||
card.add(MagicStatic.genABStaticOther(filter, abilityList));
|
||||
} else {
|
||||
|
@ -912,6 +914,18 @@ public enum MagicAbility {
|
|||
return abilityList;
|
||||
}
|
||||
|
||||
private static final Pattern SUB_ABILITY_LIST = Pattern.compile("\"([^\"]*)\"|([A-Za-z][^,]*)");
|
||||
|
||||
public static MagicAbilityList getAbilityList(final String names) {
|
||||
final MagicAbilityList abilityList = new MagicAbilityList();
|
||||
final Matcher m = SUB_ABILITY_LIST.matcher(names);
|
||||
while (m.find()) {
|
||||
final String name = m.group(1) != null ? m.group(1) : m.group(2);
|
||||
getAbility(name).addAbility(abilityList, name);
|
||||
}
|
||||
return abilityList;
|
||||
}
|
||||
|
||||
public static Set<MagicAbility> of(final MagicAbility first, MagicAbility... rest) {
|
||||
return EnumSet.of(first, rest);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue