sync with full pack
stats and localization bugfixes
This commit is contained in:
@@ -11,12 +11,12 @@ version_date := {"2023-02-21"}
|
||||
############################################################## Sorting mana symbols
|
||||
|
||||
# correctly sort a mana symbol (no guild mana)
|
||||
mana_sort := sort_text@(order: "\\?XYZI[0123456789]VLHSFCAIE(WUBRG)")
|
||||
mana_sort := sort_text@(order: "\\?XYZI[0123456789]VLHSFCAIE[TK](WUBRG)")
|
||||
# correctly sort wedge mana
|
||||
mana_sort_wedge := sort_text@(order: "\\?XYZI[0123456789]VLHSFCAIE(WBGUR)")
|
||||
mana_unsort := sort_text@(order:"[/\\?XYZI0123456789VLHSCAIEWUBRG]")
|
||||
mana_sort_wedge := sort_text@(order: "\\?XYZI[0123456789]VLHSFCAIE[TK](WBGUR)")
|
||||
mana_unsort := sort_text@(order:"[/\\?XYZI0123456789VLHSCAIETKWUBRG]")
|
||||
# correctly sort guild mana
|
||||
mana_sort_guild := sort_text@(order: "[\\?XYZI01234567890VLHSFCAIEWUBRG/|]") +
|
||||
mana_sort_guild := sort_text@(order: "[\\?XYZI01234567890VLHSFCAIETKWUBRG/|]") +
|
||||
replace@(
|
||||
# No lookbehind :(
|
||||
#match: "(?<!/)(./.|././.|./././.|.[|])(?!/)",
|
||||
@@ -55,9 +55,10 @@ mana_filter := to_upper + {
|
||||
}
|
||||
# Like mana filter, only also allow tap symbols:
|
||||
tap_reduction :=
|
||||
replace@(match:"(TK)+", replace:"")+
|
||||
replace@(match:"T+", replace:"T")+
|
||||
replace@(match:"Q+", replace:"Q")
|
||||
tap_filter := sort_text@(order: "<TQ>")
|
||||
tap_filter := filter_text@(match: "[TKQ]")
|
||||
mana_filter_t := replace@( # Remove [] used for forcing mana symbols
|
||||
match: "[\\[\\]]",
|
||||
replace: ""
|
||||
@@ -432,16 +433,16 @@ trim_reminder_x := replace@(match: ". X can’t be 0.", replace: "")
|
||||
for_mana_costs := {
|
||||
if input.separator_before == "—" and contains(input.param, match: " ") then ( ##multi word
|
||||
if comma_count(input.param) == "," then ( ##two part
|
||||
if match(match: "^[VLHSCAIETQ\\?XYZIWUBRG0-9/|]+,", input.param) then ##starts with mana
|
||||
if match(match: "^[VLHSCAIETKQ\\?XYZIWUBRG0-9/|]+,", input.param) then ##starts with mana
|
||||
"{add}<param-cost>{alternative_cost(input.param, trim:combined_cost, s:action)}</param-cost>" ##"add" mana
|
||||
else "<param-cost>{alternative_cost(input.param, trim:combined_cost, s:action)}</param-cost>{non}" ## else cost "non"
|
||||
) else if contains(input.param, match: ",") then ( ##three+ parts
|
||||
if match(match: "^[VLHSCAIETQ\\?XYZIWUBRG0-9/|]+,", input.param) then ##starts with mana
|
||||
if match(match: "^[VLHSCAIETKQ\\?XYZIWUBRG0-9/|]+,", input.param) then ##starts with mana
|
||||
"{add}<param-cost>{alternative_cost(input.param, trim:long_cost, s:action)}</param-cost>" ##"add" mana with long formatting
|
||||
else "<param-cost>{alternative_cost(input.param, trim:long_nomana_cost, s:action)}</param-cost>{non}" ## else cost "non" with long formatting
|
||||
) else
|
||||
"<param-cost>{alternative_cost(input.param, s:action, trim:lower_first)}{non}</param-cost>" ##one, nonmana, part
|
||||
) else if match(match: "^[VLHSCAIETQ\\?XYZIWUBRG0-9/|]+$", input.param) then ##one word
|
||||
) else if match(match: "^[VLHSCAIETKQ\\?XYZIWUBRG0-9/|]+$", input.param) then ##one word
|
||||
"{add}<param-mana>{input.param}</param-mana>" ##mana
|
||||
else
|
||||
"<param-cost>{alternative_cost(input.param, trim:combined_cost, s:action)}</param-cost>{non}" ##nonmana
|
||||
@@ -454,7 +455,7 @@ long_nomana_cost := replace@(match:"[A-Z]", replace: { to_lower() })
|
||||
lower_first := replace@(match:"^[A-Z]", replace: { to_lower() })
|
||||
combined_cost := replace@(match:", [A-Z]", replace: { to_lower() })+
|
||||
replace@(match:",", replace:" and")+
|
||||
replace@(match:"^[VLHSCETQ\\?XYZIWUBRG0-9/|]+", in_context: "(^|[[:space:]])<match>(?![a-z])", replace: "<sym-auto>&</sym-auto>")+
|
||||
replace@(match:"^[VLHSCETKQ\\?XYZIWUBRG0-9/|]+", in_context: "(^|[[:space:]])<match>(?![a-z])", replace: "<sym-auto>&</sym-auto>")+
|
||||
replace@(match:"^[A-Z]", replace: { to_lower() })
|
||||
alternative_cost := {
|
||||
input := trim(input)
|
||||
@@ -780,8 +781,8 @@ mana_context :=
|
||||
| <match>[ ]can[ ]be[ ]paid
|
||||
| (pays?|additional|costs?|the|adds?|pay(ed)?[ ](with|using)) # pay X. creatures cost 1 less. pay an additional G.
|
||||
([ ]either)? # pay either X or Y
|
||||
([ ](<sym[^>]*>)?[-+=]?[VLHSCETQ\\?XYZIEWUBRG0-9/|]+(</sym[^>]*>)?,)* # pay X, Y or Z
|
||||
([ ](<sym[^>]*>)?[-+=]?[VLHSCETQ\\?XYZIEWUBRG0-9/|]+(</sym[^>]*>)?[ ](and|or|and/or))* # pay X or Y
|
||||
([ ](<sym[^>]*>)?[-+=]?[VLHSCETKQ\\?XYZIEWUBRG0-9/|]+(</sym[^>]*>)?,)* # pay X, Y or Z
|
||||
([ ](<sym[^>]*>)?[-+=]?[VLHSCETKQ\\?XYZIEWUBRG0-9/|]+(</sym[^>]*>)?[ ](and|or|and/or))* # pay X or Y
|
||||
[ ]<match>
|
||||
([,.)\"”]|$ # (end of word)
|
||||
|[ ][^ .,]*$ # still typing...
|
||||
@@ -846,12 +847,13 @@ auto_correct :=
|
||||
replace: { _1 + _2 + to_lower(_3)})
|
||||
auto_errata :=
|
||||
replace@(match:"converted mana cost", replace:"mana value")
|
||||
+replace@(match:"(?i)(Totem armor|Totembeistand|Armadura tótem|totémique|Armatura totem|Armadura de totem|族霊鎧|替身甲)", replace:{errata_map[_1]})
|
||||
+replace@(match:"(?i)(Totem armor|Totembeistand|Armadura tótem|totémique|Armatura totem|Armadura de totem|族霊鎧|替身甲)", replace:{errata_map[_1] or else _1})
|
||||
+replace@(match:"hen shuffle your library", replace:"hen shuffle")
|
||||
+replace@(match:"this (?:ability )?(?:only )?(?:any ?time you could cast|as) a", in_context: "(Activate|Play) <match>n? (instant|sorcery)", replace:"only as a")
|
||||
|
||||
errata_map := [
|
||||
"Totem armor": "Umbra armor",
|
||||
"Totem Armor": "Umbra armor",
|
||||
"totem armor": "umbra armor",
|
||||
"Totembeistand": "Schattenbeistand",
|
||||
"totembeistand": "schattenbeistand",
|
||||
@@ -1009,7 +1011,7 @@ text_filter :=
|
||||
} +
|
||||
# step 4 : explict non mana symbols
|
||||
replace@(
|
||||
match: "\\][-+=]?[VLHSCETQ\\?XYZIWUBRG0-9/|]+\\[",
|
||||
match: "\\][-+=]?[VLHSCETKQ\\?XYZIWUBRG0-9/|]+\\[",
|
||||
replace: {"<nosym>" + mana_filter_t() + "</nosym>"} ) +
|
||||
# step 5 : add mana & tap symbols
|
||||
replace@(
|
||||
@@ -1017,17 +1019,17 @@ text_filter :=
|
||||
in_context: mana_context,
|
||||
replace: {"<sym-auto>" + _1 + "</sym-auto>"} ) +
|
||||
replace@(
|
||||
match: "\\b[VLHSCETQ\\?XYZIWUBRG0-9/|]+\\b",
|
||||
match: "\\b[VLHSCETKQ\\?XYZIWUBRG0-9/|]+\\b",
|
||||
in_context: mana_context,
|
||||
replace: {"<sym-auto>" + mana_filter_t() + "</sym-auto>"} ) +
|
||||
# step 5b : remove false positive mana & tap symbols
|
||||
replace@(
|
||||
match: "<sym-auto>([VLHSCETQ\\?XYZIWUBRG0-9/|]+)</sym-auto>",
|
||||
match: "<sym-auto>([VLHSCETKQ\\?XYZIWUBRG0-9/|]+)</sym-auto>",
|
||||
in_context: mana_un_context,
|
||||
replace: "\\1" ) +
|
||||
# step 5c : add explicit mana symbols
|
||||
replace@(
|
||||
match: "\\[[-+=]?[VLHSCETQE\\?XYZIWUBRG0-9/|]+\\]",
|
||||
match: "\\[[-+=]?[VLHSCETKQE\\?XYZIWUBRG0-9/|]+\\]",
|
||||
replace: {"<sym>" + mana_filter_t() + "</sym>"} ) +
|
||||
# step 6 : curly quotes
|
||||
{if set.curly_quotes then curly_quotes(input) else input} +
|
||||
@@ -1105,10 +1107,9 @@ super_type_filter := {
|
||||
"<{tag}>{input}</{tag}>"
|
||||
}
|
||||
|
||||
break_subtypes := split_text@(match: " +|<atom-sep>[^<]*</atom-sep>", include_empty:false)
|
||||
break_subtypes := split_text@(match: "<atom-sep>[^<]*</atom-sep>|</?word-list-[^>]*>", include_empty:false) # splitting at word-list tags is for backwards compatibility, when atom-sep was not yet inserted everywhere.
|
||||
break_supertypes := split_text@(match: "<atom-sep>[^<]*</atom-sep>", include_empty:false)
|
||||
sub_type_filter := {
|
||||
input := remove_tag(tag: "<word-list-")
|
||||
input := remove_tag(tag: "<soft")
|
||||
# What word list to use?
|
||||
list_type_rest := if lang_setting("is_creature")(type) or lang_setting("is_kindred")(type) then "class-"+lang_setting("code")
|
||||
@@ -1129,9 +1130,11 @@ sub_type_filter := {
|
||||
);
|
||||
# wrap wordlist tag around each part
|
||||
parts := break_subtypes()
|
||||
(for each i:part in parts do
|
||||
if i == 0 then
|
||||
"<word-list-{list_type_first}>{part}</word-list-{list_type_first}>"
|
||||
checked_first := false
|
||||
(for each part in parts do
|
||||
if trim(part) == "" then ""
|
||||
else if not checked_first then
|
||||
(checked_first := true; "<word-list-{list_type_first}>{part}</word-list-{list_type_first}>")
|
||||
else
|
||||
languages[lang_name()].subtype_separator + "<word-list-{list_type_rest}>{part}</word-list-{list_type_rest}>"
|
||||
) +
|
||||
@@ -1229,7 +1232,7 @@ is_half_mana := match@(match: "1/2|[|][WUBRGS]")
|
||||
is_half_generic := match@(match: "1/2")
|
||||
is_colored_mana := match@(match: "[WUBRG]")
|
||||
only_numbers := filter_text@(match: "^[0123456789]+")
|
||||
cmc_split := break_text@(match: "(?ix) 1/2 | [|][WUBRGC] | [0-9](/[WUBRGCVLHSCETQ2]) | [0-9]+(?!/[WUBRGCVLHSCETQ2]) | [WUBRGCVLHS0-9](/[WUBRGCVLHS])\{0,4} ")
|
||||
cmc_split := break_text@(match: "(?ix) 1/2 | [|][WUBRGC] | TK | [0-9](/[WUBRGCVLHSCETQ2]) | [0-9]+(?!/[WUBRGCVLHSCETQ2]) | [WUBRGCVLHS0-9](/[WUBRGCVLHS])\{0,4} ")
|
||||
cmc := {to_number(
|
||||
for each sym in cmc_split(to_text()) do (
|
||||
numbers := only_numbers(sym)
|
||||
|
||||
Reference in New Issue
Block a user