Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
b170443d
Commit
b170443d
authored
Sep 02, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some tweaks of the regular expressions to improve performance (in_context is slow!)
parent
206868fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
data/magic.mse-game/script
data/magic.mse-game/script
+17
-7
No files found.
data/magic.mse-game/script
View file @
b170443d
...
@@ -10,6 +10,8 @@ mana_sort := sort_text@(order: "XYZI[0123456789]S(WUBRG)")
...
@@ -10,6 +10,8 @@ mana_sort := sort_text@(order: "XYZI[0123456789]S(WUBRG)")
# correctly sort guild mana
# correctly sort guild mana
mana_sort_guild := sort_text@(order: "[XYZI01234567890SWUBRG/|]") +
mana_sort_guild := sort_text@(order: "[XYZI01234567890SWUBRG/|]") +
replace@(
replace@(
# No lookbehind :(
#match: "(?<!/)(./.|././.|./././.|.[|])(?!/)",
match: "./.|././.|./././.|.[|]",
match: "./.|././.|./././.|.[|]",
in_context: "(^|[^/])<match>($|[^/])",
in_context: "(^|[^/])<match>($|[^/])",
replace: {sort_text(order:"in_place((WUBRG)")}
replace: {sort_text(order:"in_place((WUBRG)")}
...
@@ -272,9 +274,12 @@ card_count := {
...
@@ -272,9 +274,12 @@ card_count := {
############################################################## Utilities for keywords
############################################################## Utilities for keywords
# Replace spaces by a spacer
separate_words := remove_tags + trim + replace@(match:" ", replace: {spacer})
# replaces — correctly
# replaces — correctly
add := "" # default is nothing
add := "" # default is nothing
separate_words := remove_tags + trim + replace@(match:" ", replace: {spacer})
# If the 'input' parameter is a mana costs, then adds 'add'
for_mana_costs := format_cost := {
for_mana_costs := format_cost := {
if input.separator_before == "—" and contains(input.param, match: " ") then (
if input.separator_before == "—" and contains(input.param, match: " ") then (
if contains(input.param, match:",") then (
if contains(input.param, match:",") then (
...
@@ -286,15 +291,19 @@ for_mana_costs := format_cost := {
...
@@ -286,15 +291,19 @@ for_mana_costs := format_cost := {
) else
) else
"{add}<param-mana>{input.param}</param-mana>"
"{add}<param-mana>{input.param}</param-mana>"
}
}
# Convert first character to lower case
alternative_cost := replace@(match:"^[A-Z]", replace: { to_lower() })
alternative_cost := replace@(match:"^[A-Z]", replace: { to_lower() })
#
combined_cost := replace@(match:", [A-Z]", replace: { to_lower() })+
combined_cost := replace@(match:", [A-Z]", replace: { to_lower() })+
replace@(match:",", replace:" and")+
replace@(match:",", replace:" and")+
replace@(match:"^[STQXYZIWUBRG0-9/|]", in_context: "(^|[[:space:]])<match>", replace: "<sym-auto>&</sym-auto>")+
replace@(match:"^[STQXYZIWUBRG0-9/|]", in_context: "(^|[[:space:]])<match>", replace: "<sym-auto>&</sym-auto>")+
replace@(match:"^[A-Z]", replace: { to_lower() })
replace@(match:"^[A-Z]", replace: { to_lower() })
long_dash := replace@(match:"-", replace:"—")
long_dash := replace@(match:"-", replace:"—")
# Utilities for keywords
# Utilities for keywords
has_cc := { card.casting_cost != "" }
has_cc := { card.casting_cost != "" }
has_pt := { card.pt != "" }
has_pt := { card.pt != "" }
contains_target := match@(match:"(?i)([^a-z]|^)target([^a-z]|$)")
contains_target := match@(match:"(?i)([^a-z]|^)target([^a-z]|$)")
is_targeted := { contains_target(card.rule_text) }
is_targeted := { contains_target(card.rule_text) }
...
@@ -322,8 +331,8 @@ mana_context :=
...
@@ -322,8 +331,8 @@ mana_context :=
)
)
)
)
| <param-mana><match></param-mana> # keyword argument that is declared as mana
| <param-mana><match></param-mana> # keyword argument that is declared as mana
| <param-cost>[ ]*<match></param-cost>
# keyword argument that is declared as cost
| <param-cost>[ ]*<match></param-cost> # keyword argument that is declared as cost
| <param-cost><match>, # keyword argument that is declared as cost
| <param-cost><match>,
# keyword argument that is declared as cost
";
";
# truncates the name of legends
# truncates the name of legends
legend_filter := replace@(match:"(, | of | the ).*", replace: "" )
legend_filter := replace@(match:"(, | of | the ).*", replace: "" )
...
@@ -383,7 +392,7 @@ text_filter :=
...
@@ -383,7 +392,7 @@ text_filter :=
replace: {"<nosym>" + mana_filter_t() + "</nosym>"} ) +
replace: {"<nosym>" + mana_filter_t() + "</nosym>"} ) +
# step 5 : add mana & tap symbols
# step 5 : add mana & tap symbols
replace@(
replace@(
match: "
[STQXYZIWUBRG0-9/|]+
",
match: "
\b[STQXYZIWUBRG0-9/|]+\b
",
in_context: mana_context,
in_context: mana_context,
replace: {"<sym-auto>" + mana_filter_t() + "</sym-auto>"} ) +
replace: {"<sym-auto>" + mana_filter_t() + "</sym-auto>"} ) +
# step 5b : add explict mana symbols
# step 5b : add explict mana symbols
...
@@ -397,9 +406,10 @@ text_filter :=
...
@@ -397,9 +406,10 @@ text_filter :=
replace: "<i-auto>&</i-auto>") +
replace: "<i-auto>&</i-auto>") +
# step 8 : automatic capitalization
# step 8 : automatic capitalization
replace@(
replace@(
match: "[a-z]",
match: "([(](?:<param-[a-z]*>)?|[ ]*: <param-cost>|—| — )" # preceded by this
in_context: "[(](<param-[a-z]*>)?<match>[^)]|[ ]*: <param-cost><match>|—<match>| — <match>",
+ "([[:lower:]])" # match this
replace: to_upper) +
+ "(?![)])", # not followed by this
replace: { _1 + to_upper(_2) }) +
curly_quotes
curly_quotes
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment