Added support for separators that are part of a parameter;

Keywords match whole words only;
Added english_singular/plural functions;
Fixed possible infinite loop in reader

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@347 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-05-12 20:17:49 +00:00
parent 175e246579
commit 2d48f27fe0
7 changed files with 329 additions and 101 deletions
+48 -53
View File
@@ -152,15 +152,15 @@ init script:
};
# replaces — correctly
alternative_cost := replace_rule(match:"—|\\.", replace:"") + replace_rule(match:"[A-Z]", in_context:"<param-[a-z]*><match>", replace: { to_lower() })
mana_cost := replace_rule(match:"<param-cost> ", replace: "<param-cost>")
alternative_cost := replace_rule(match:"\\.$", replace:"") + replace_rule(match:"^[A-Z]", replace: { to_lower() })
add := "" # default is nothing
format_cost := {
if substring(begin: 0, end: 13)=="<param-cost>—" then
alternative_cost()
else add + mana_cost()
};
format_cost_start := replace_rule(match:"^(<param-cost>)?[ ]?-", replace:"\\1—")
for_mana_costs := format_cost := {
if input.separator=="—" then
"<param-cost>{alternative_cost(input.param)}</param-cost>"
else
"<param-mana>{add}{input.param}</param-mana>"
}
long_dash := replace_rule(match:"-", replace:"—")
# Utilities for keywords
has_cc := { card.casting_cost != "" }
has_pt := { card.pt != "" }
@@ -237,10 +237,6 @@ init script:
replace_rule(
match: "AE",
replace: "Æ" ) +
# step 6c : "s" remover for keywords
replace_rule(
match: "s</param-name><s>"
replace: "" ) +
# step 7 : italic reminder text
replace_rule(
match: "[(][^)\n]*[)]?",
@@ -1125,23 +1121,22 @@ keyword parameter type:
keyword parameter type:
name: cost
match: [ ][STXYZ0-9WUBRG/|]*|[-—][^(\n]*
separator before is: [ —-]
optional: false
# note: the separator is part of match
refer script:
name: normal
description: standard cost
script: \{{input}\}
refer script:
name: add nothing for mana costs
description: When using mana only costs, doesn't include anything extra in the reminder text
script: \{format_cost({input})\}
script: \{{input}\}
refer script:
name: add "pay an additional " for mana costs
description: When using mana only costs, words the reminder text as "pay an additional <cost>"
script: \{format_cost(add:"pay an additional ",{input})\}
script: \{for_mana_costs(add:"pay an additional ",{input})\}
refer script:
name: add "pay " for mana costs
description: When using mana only costs, words the reminder text as "pay <cost>"
script: \{format_cost(add:"pay ",{input})\}
script: format_cost_start()
script: \{for_mana_costs(add:"pay ",{input})\}
separator script: long_dash()
keyword parameter type:
name: number
match: [XYZ0-9]+
@@ -1204,9 +1199,9 @@ keyword:
reminder: Target a {param1} as you play this. This card comes into play attached to that {param1}.
keyword:
keyword: Cycling
match: Cycling<atom-param>cost</atom-param>
match: Cycling <atom-param>cost</atom-param>
mode: expert
reminder: {format_cost(param1)}, Discard this card: Draw a card.
reminder: {param1}, Discard this card: Draw a card.
keyword:
keyword: Trample
match: Trample
@@ -1239,9 +1234,9 @@ keyword:
reminder: This creature cant attack.
keyword:
keyword: Cumulative upkeep
match: Cumulative upkeep<atom-param>cost</atom-param>
match: Cumulative upkeep <atom-param>cost</atom-param>
mode: old
reminder: At the beginning of your upkeep, put an age counter on this permanent, then sacrifice it unless you {format_cost(add:"pay ",param1)} for each age counter on it.
reminder: At the beginning of your upkeep, put an age counter on this permanent, then sacrifice it unless you {for_mana_costs(add:"pay ",param1)} for each age counter on it.
keyword:
keyword: Horsemanship
match: Horsemanship
@@ -1264,19 +1259,19 @@ keyword:
reminder: This creature can block or be blocked only by creatures with shadow.
keyword:
keyword: Buyback
match: Buyback<atom-param>cost</atom-param>
match: Buyback <atom-param>cost</atom-param>
mode: expert
reminder: You may {format_cost(add:"pay ",param1)} in addition to any other costs as you play this spell. If you do, put this card into your hand as it resolves.
reminder: You may {for_mana_costs(add:"pay ",param1)} in addition to any other costs as you play this spell. If you do, put this card into your hand as it resolves.
keyword:
keyword: Echo
match: Echo<atom-param>cost</atom-param>
match: Echo <atom-param>cost</atom-param>
mode: expert
reminder: At the beginning of your upkeep, if this came under your control since the beginning of your last upkeep, sacrifice it unless you pay its echo cost.
keyword:
keyword: Cardcycling
match: <atom-param>prefix</atom-param>cycling<atom-param>cost</atom-param>
match: <atom-param>prefix</atom-param>cycling <atom-param>cost</atom-param>
mode: expert
reminder: {format_cost(param2)}, Discard this card: Search your library for a {param1} card, reveal it, and put it into your hand. Then shuffle your library.
reminder: {param2}, Discard this card: Search your library for a {param1} card, reveal it, and put it into your hand. Then shuffle your library.
keyword:
keyword: Fading
match: Fading <atom-param>number</atom-param>
@@ -1284,22 +1279,22 @@ keyword:
reminder: This comes into play with {english_number_a(param1)} fade counter(s) on it. At the beginning of your upkeep, remove a fade counter from it. If you cant, sacrifice it.
keyword:
keyword: Kicker
match: Kicker<atom-param>cost</atom-param>
match: Kicker <atom-param>cost</atom-param>
mode: expert
reminder: You may {format_cost(add:"pay an additional ",param1)} as you play this spell.
reminder: You may {for_mana_costs(add:"pay an additional ",param1)} as you play this spell.
keyword:
keyword: Madness
match: Madness<atom-param>cost</atom-param>
match: Madness <atom-param>cost</atom-param>
mode: expert
reminder: You may play this card for its madness cost at the time you discard it.
keyword:
keyword: Flashback
match: Flashback<atom-param>cost</atom-param>
match: Flashback <atom-param>cost</atom-param>
mode: expert
reminder: You may play this card from your graveyard for its flashback cost. Then remove it from the game.
keyword:
keyword: Morph
match: Morph<atom-param>cost</atom-param>
match: Morph <atom-param>cost</atom-param>
mode: expert
reminder: You may play this face down as a 2/2 creature for <sym>3</sym>. Turn it face up any time for its morph cost.
keyword:
@@ -1326,17 +1321,17 @@ keyword:
keyword: Affinity for
match: Affinity for <atom-param>name</atom-param>
mode: expert
reminder: This spell costs <sym>1</sym> less to play for each {param1}<s> you control.
reminder: This spell costs <sym>1</sym> less to play for each {english_singular(param1)} you control.
keyword:
keyword: Entwine
match: Entwine<atom-param>cost</atom-param>
match: Entwine <atom-param>cost</atom-param>
mode: expert
reminder: Choose both if you pay the entwine cost.
keyword:
keyword: Equip
match: Equip<atom-param>cost</atom-param>
match: Equip <atom-param>cost</atom-param>
mode: expert
reminder: {format_cost(param1)}: Attach to target creature you control. Equip only as a sorcery.
reminder: {param1}: Attach to target creature you control. Equip only as a sorcery.
keyword:
keyword: Imprint
match: Imprint—<atom-param>action</atom-param>
@@ -1380,9 +1375,9 @@ keyword:
reminder: When this blocks or becomes blocked, it gets +{param1}/+{param1} until end of turn.
keyword:
keyword: Ninjutsu
match: Ninjutsu<atom-param>cost</atom-param>
match: Ninjutsu <atom-param>cost</atom-param>
mode: expert
reminder: {format_cost(param1)}, Return an unblocked attacker you control to hand: Put this card into play from your hand tapped and attacking.
reminder: {param1}, Return an unblocked attacker you control to hand: Put this card into play from your hand tapped and attacking.
keyword:
keyword: Soulshift
match: Soulshift <atom-param>number</atom-param>
@@ -1400,9 +1395,9 @@ keyword:
reminder: Each creature you tap while playing this spell reduces its cost by <sym>1</sym> or by one mana of that creatures color.
keyword:
keyword: Transmute
match: Transmute<atom-param>cost</atom-param>
match: Transmute <atom-param>cost</atom-param>
mode: expert
reminder: {format_cost(param1)}, Discard this card: Search your library for a card with the same converted mana cost as this card, reveal it, and put it into your hand. Then shuffle your library. Play only as a sorcery.
reminder: {param1}, Discard this card: Search your library for a card with the same converted mana cost as this card, reveal it, and put it into your hand. Then shuffle your library. Play only as a sorcery.
keyword:
keyword: Haunt
match: Haunt
@@ -1415,7 +1410,7 @@ keyword:
reminder: If an opponent was dealt damage this turn, this creature comes into play with {english_number_a(param1)} +1/+1 counter(s) on it.
keyword:
keyword: Replicate
match: Replicate<atom-param>cost</atom-param>
match: Replicate <atom-param>cost</atom-param>
mode: expert
reminder: When you play this spell, copy it for each time you paid its replicate cost. You may choose new targets for the copies.
keyword:
@@ -1432,7 +1427,7 @@ keyword:
keyword: Protection from
match: Protection from <atom-param>name</atom-param>
mode: core
reminder: This creature cant be blocked, targeted, dealt damage, or enchanted, or equipped by anything {param1}<s>.
reminder: This creature cant be blocked, targeted, dealt damage, or enchanted, or equipped by anything {english_singular(param1)}.
keyword:
keyword: Dredge
match: Dredge <atom-param>number</atom-param>
@@ -1445,14 +1440,14 @@ keyword:
reminder: This creature comes into play with {english_number_a(param1)} +1/+1 counter(s) on it. Whenever another creature comes into play, you may move a +1/+1 counter from this creature onto it.
keyword:
keyword: Forecast
match: Forecast<atom-param>cost</atom-param>, Reveal <atom-param>name</atom-param> from your hand: <atom-param>action</atom-param>
match: Forecast <atom-param>cost</atom-param>, Reveal <atom-param>name</atom-param> from your hand: <atom-param>action</atom-param>
mode: expert
reminder: Play this ability only during your upkeep and only once each turn.
keyword:
keyword: Recover
match: Recover<atom-param>cost</atom-param>
match: Recover <atom-param>cost</atom-param>
mode: expert
reminder: When a creature is put into your graveyard from play, you may {format_cost(add:"pay ",param1)}. If you do, return this card from your graveyard to your hand. Otherwise, remove this card from the game.
reminder: When a creature is put into your graveyard from play, you may {for_mana_costs(add:"pay ",param1)}. If you do, return this card from your graveyard to your hand. Otherwise, remove this card from the game.
keyword:
keyword: Ripple
match: Ripple <atom-param>number</atom-param>
@@ -1510,14 +1505,14 @@ keyword:
reminder: Look at the top {english_number_multiple(param1)} card(s) of an opponent's library, then put any number of them on the bottom of that player's library and the rest on top in any order.
keyword:
keyword: Transfigure
match: Transfigure<atom-param>cost</atom-param>
match: Transfigure <atom-param>cost</atom-param>
mode: expert
reminder: {format_cost(param1)}, Sacrifice this creature: Search your library for a creature card with the same converted mana cost as this creature and put that card into play. Then shuffle your library. Play only as a sorcery.
reminder: {param1}, Sacrifice this creature: Search your library for a creature card with the same converted mana cost as this creature and put that card into play. Then shuffle your library. Play only as a sorcery.
keyword:
keyword: Aura swap
match: Aura swap<atom-param>cost</atom-param>
match: Aura swap <atom-param>cost</atom-param>
mode: expert
reminder: {format_cost(param1)}: Exchange this Aura with an Aura card in your hand.
reminder: {param1}: Exchange this Aura with an Aura card in your hand.
keyword:
keyword: Frenzy
match: Frenzy <atom-param>number</atom-param>
@@ -1568,6 +1563,6 @@ keyword:
mode: pseudo
keyword:
keyword: Fortify
match: Fortify<atom-param>cost</atom-param>
match: Fortify <atom-param>cost</atom-param>
mode: expert
reminder: {format_cost(param1)}: Attach to target land you control. Fortify only as a sorcery. This card comes into play unattached and stays in play if the land leaves play.
reminder: {param1}: Attach to target land you control. Fortify only as a sorcery. This card comes into play unattached and stays in play if the land leaves play.