|
|
|
|
@@ -312,7 +312,7 @@ get_alpha_percentage :=
|
|
|
|
|
|
|
|
|
|
############################################################## For the user
|
|
|
|
|
#### Remove card codes
|
|
|
|
|
cc_filter := replace@(match:"^[CURMSL][WUBRGMZACL][0-9]+ ?[-—]? ?", replace:"")
|
|
|
|
|
cc_filter := replace@(match:"^[CURMSL][WUBRGOMZACL][0-9]+ ?[-—]? ?", replace:"")
|
|
|
|
|
has_alchemy := contains@(match:"alchemy")
|
|
|
|
|
strip_card_codes := {
|
|
|
|
|
save := input
|
|
|
|
|
@@ -507,25 +507,25 @@ crop_multi_image := {
|
|
|
|
|
|
|
|
|
|
############################################################## Sorting mana symbols
|
|
|
|
|
#### correctly sort a mana symbol (no guild mana)
|
|
|
|
|
mana_sort := sort_text@(order: "\\?XYZI[0123456789]VHSFCAI(EKPLO)(WUBRG)")
|
|
|
|
|
mana_sort := sort_text@(order: "\\?XYZI[0123456789]VHSFCAI(EKPLO)(WUBRGO)")
|
|
|
|
|
#### correctly sort wedge mana
|
|
|
|
|
mana_sort_wedge := sort_text@(order: "\\?XYZI[0123456789]VHSFCAI(EPOKL)(WBGUR)")
|
|
|
|
|
#### sort nothing
|
|
|
|
|
mana_unsort := sort_text@(order:"[/\\?XYZI0123456789VHSCAIEKPLOMWUBRG]")
|
|
|
|
|
mana_unsort := sort_text@(order:"[/\\?XYZI0123456789VHSCAIEKPLOMWUBRGO]")
|
|
|
|
|
#### correctly sort guild mana
|
|
|
|
|
mana_sort_guild := sort_text@(order: "[\\?XYZI01234567890VHSFCAIEKPLOWUBRG/|]") +
|
|
|
|
|
mana_sort_guild := sort_text@(order: "[\\?XYZI01234567890VHSFCAIEKPLOWUBRGO/|]") +
|
|
|
|
|
replace@(
|
|
|
|
|
#### No lookbehind :(
|
|
|
|
|
#match: "(?<!/)(./.|././.|./././.|.[|])(?!/)",
|
|
|
|
|
match: "./.|././.|./././.|.[|]",
|
|
|
|
|
in_context: "(^|[^/])<match>($|[^/])",
|
|
|
|
|
replace: {sort_text(order:"in_place((WUBRG))")}
|
|
|
|
|
replace: {sort_text(order:"in_place((WUBRGO))")}
|
|
|
|
|
)
|
|
|
|
|
#### mana filter helpers
|
|
|
|
|
mana_has_guild := match@(match: "[/|]") #### Is there guild or half mana in the input?
|
|
|
|
|
mana_is_wedge := { chosen(set.mana_cost_sorting, choice: "tarkir wedge sorting") and ( number_of_items(in: sort_text(order:"<WUBRG>", input), filter: "<WUBRG>") == 3 ) }
|
|
|
|
|
mana_is_wedge := { chosen(set.mana_cost_sorting, choice: "tarkir wedge sorting") and ( number_of_items(in: sort_text(order:"<WUBRGO>", input), filter: "<WUBRGO>") == 3 ) }
|
|
|
|
|
mana_has_wedge := {
|
|
|
|
|
wedge_check := sort_text(order:"<WUBRG>", input)
|
|
|
|
|
wedge_check := sort_text(order:"<WUBRGO>", input)
|
|
|
|
|
mana_is_wedge() and (wedge_check == "WUR" or wedge_check == "WBR" or wedge_check == "WBG" or wedge_check == "UBG" or wedge_check == "URG")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -640,7 +640,7 @@ color_names_3 := { color_name(colors.0) + ", " + color_name(colors.1) + ", " + c
|
|
|
|
|
color_names_4 := { color_name(colors.0) + ", " + color_name(colors.1) + ", " + color_name(colors.2) + ", " + color_name(colors.3) }
|
|
|
|
|
color_names_5 := { color_name(colors.0) + ", " + color_name(colors.1) + ", " + color_name(colors.2) + ", " + color_name(colors.3) + ", " + color_name(colors.4) }
|
|
|
|
|
#### color based on mana cost, input == a mana cost
|
|
|
|
|
color_filter := sort_text@(order: "<WUBRG>")
|
|
|
|
|
color_filter := sort_text@(order: "<WUBRGO>")
|
|
|
|
|
color_filterH := sort_text@(order: "</>")
|
|
|
|
|
mana_to_color := {
|
|
|
|
|
count := number_of_items(in: colors)
|
|
|
|
|
@@ -690,7 +690,7 @@ color_text_filter :=
|
|
|
|
|
) +
|
|
|
|
|
#### keep only mana
|
|
|
|
|
filter_text@(match: "<sym[^>]*>([^<]+)") + color_filter;
|
|
|
|
|
#### get the land frame for a "WUBRG"-style input.
|
|
|
|
|
#### get the land frame for a "WUBRGO"-style input.
|
|
|
|
|
land_multicolor := {
|
|
|
|
|
count := number_of_items(in: colors)
|
|
|
|
|
if count == 0 then "land"
|
|
|
|
|
@@ -716,7 +716,7 @@ text_to_color := {
|
|
|
|
|
text := filter_text(match: "is (colorless|all colors|((blue|white|green|red|black|orange)((,|,? and) (blue|white|green|red|black|orange))*))", in_context: regex_escape(card_name)+"(</[-a-z]+>)* <match>\\.")
|
|
|
|
|
if text != "" then (
|
|
|
|
|
if contains(text, match: "all colors") then (
|
|
|
|
|
colors := "WUBRG"
|
|
|
|
|
colors := "WUBRGO"
|
|
|
|
|
if land == true then land_multicolor()
|
|
|
|
|
else mana_to_color(hybrid: "")
|
|
|
|
|
) else (
|
|
|
|
|
@@ -775,7 +775,7 @@ list_colors := {
|
|
|
|
|
list := replace(list, match:", ", replace:", and ", in_context:"<match>[^ ]+$")
|
|
|
|
|
list
|
|
|
|
|
}
|
|
|
|
|
#### convert card_color to WUBRG
|
|
|
|
|
#### convert card_color to WUBRGO
|
|
|
|
|
card_color_to_letters := {
|
|
|
|
|
color_string := trim_colors(input)
|
|
|
|
|
(if contains(color_string, match:"white") then "W" else "")
|
|
|
|
|
@@ -877,7 +877,7 @@ basic_land_sort := {
|
|
|
|
|
else "MA" #### other basic lands
|
|
|
|
|
}
|
|
|
|
|
hybrid_color_pair_sort := {
|
|
|
|
|
colors := sort_text(casting_cost, order: "<WUBRG>")
|
|
|
|
|
colors := sort_text(casting_cost, order: "<WUBRGO>")
|
|
|
|
|
if not set.sort_hybrid_in_pairs then "HK"
|
|
|
|
|
else if colors == "WU" then "HA"
|
|
|
|
|
else if colors == "UB" then "HB"
|
|
|
|
|
@@ -892,7 +892,7 @@ hybrid_color_pair_sort := {
|
|
|
|
|
else "HK"
|
|
|
|
|
}
|
|
|
|
|
multi_color_pair_sort := {
|
|
|
|
|
colors := sort_text(casting_cost, order: "<WUBRG>")
|
|
|
|
|
colors := sort_text(casting_cost, order: "<WUBRGO>")
|
|
|
|
|
if not set.sort_multicolor_in_pairs then "GK"
|
|
|
|
|
else if colors == "WU" then "GA"
|
|
|
|
|
else if colors == "UB" then "GB"
|
|
|
|
|
@@ -1039,11 +1039,11 @@ rarity_code := {
|
|
|
|
|
is_unsorted := { false }
|
|
|
|
|
############################################################## Statistics utilities
|
|
|
|
|
#### Converted mana cost
|
|
|
|
|
is_half_mana := match@(match: "1/2|[|][WUBRGS]")
|
|
|
|
|
is_half_mana := match@(match: "1/2|[|][WUBRGOS]")
|
|
|
|
|
is_half_generic := match@(match: "1/2")
|
|
|
|
|
is_colored_mana := match@(match: "[WUBRG]")
|
|
|
|
|
is_colored_mana := match@(match: "[WUBRGO]")
|
|
|
|
|
only_numbers := filter_text@(match: "^[0123456789]+")
|
|
|
|
|
cmc_split := break_text@(match: "(?ix) 1/2 | [|][WUBRGC] | TK | [0-9](/[WUBRGCVHSCEKPLOTQ2]) | [0-9]+(?!/[WUBRGCVHSCEKPLOTQ2]) | [WUBRGCVHS0-9](/[WUBRGCVHS])\{0,4} ")
|
|
|
|
|
cmc_split := break_text@(match: "(?ix) 1/2 | [|][WUBRGOC] | TK | [0-9](/[WUBRGOCVHSCEKPLOTQ2]) | [0-9]+(?!/[WUBRGOCVHSCEKPLOTQ2]) | [WUBRGOCVHS0-9](/[WUBRGOCVHS])\{0,4} ")
|
|
|
|
|
cmc := {to_number(
|
|
|
|
|
for each sym in cmc_split(to_text()) do (
|
|
|
|
|
numbers := only_numbers(sym)
|
|
|
|
|
@@ -1236,11 +1236,11 @@ digital_map := [
|
|
|
|
|
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: "^[VHSCAIETKPLOQ\\?XYZIWUBRG0-9/|]+,", input.param) then #### starts with mana
|
|
|
|
|
if match(match: "^[VHSCAIETKPLOQ\\?XYZIWUBRGO0-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: "^[VHSCAIETKPLOQ\\?XYZIWUBRG0-9/|]+,", input.param) then #### starts with mana
|
|
|
|
|
if match(match: "^[VHSCAIETKPLOQ\\?XYZIWUBRGO0-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
|
|
|
|
|
@@ -1252,7 +1252,7 @@ for_mana_costs := {
|
|
|
|
|
}@(non:" in addition to any other costs", action:false, add:"")
|
|
|
|
|
#### return bool; is the input is a simple mana cost?
|
|
|
|
|
is_mana_cost := {
|
|
|
|
|
match(match: "^[VHSCAIETKPLOQ\\?XYZIWUBRG0-9/|]+$", input.param)
|
|
|
|
|
match(match: "^[VHSCAIETKPLOQ\\?XYZIWUBRGO0-9/|]+$", input.param)
|
|
|
|
|
}
|
|
|
|
|
#### Convert extra costs
|
|
|
|
|
long_cost := replace@(match:", [A-Z]", replace: { to_lower() } )
|
|
|
|
|
@@ -1261,7 +1261,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:"^[VHSCETKPLOQ\\?XYZIWUBRG0-9/|]+", in_context: "(^|[[:space:]])<match>(?![a-z])", replace: "<sym-auto>&</sym-auto>")+
|
|
|
|
|
replace@(match:"^[VHSCETKPLOQ\\?XYZIWUBRGO0-9/|]+", in_context: "(^|[[:space:]])<match>(?![a-z])", replace: "<sym-auto>&</sym-auto>")+
|
|
|
|
|
replace@(match:"^[A-Z]", replace: { to_lower() })
|
|
|
|
|
alternative_cost := {
|
|
|
|
|
input := trim(input)
|
|
|
|
|
@@ -1322,7 +1322,7 @@ protection_code := {
|
|
|
|
|
else if match(input, match:"^(converted|mana|power|toughness)") then "anything with " + replace(input, match:"and from", replace:"or", in_context:" <match> ")
|
|
|
|
|
else if contains(input, match:"the chosen player") then "anything " + replace(input, match:"the chosen", replace:"controlled by that")
|
|
|
|
|
else if contains(input, match:"the chosen") then "anything with " + replace(input, match:"the chosen", replace:"that")
|
|
|
|
|
else if contains(input, match:"all colors") then "anything " + replace(input, match:"all colors", replace:"that's white, blue, black, red, or green")
|
|
|
|
|
else if contains(input, match:"all colors") then "anything " + replace(input, match:"all colors", replace:"that's white, blue, black, red, green, or orange")
|
|
|
|
|
else if match(input, match:"^you$") then "anything you control"
|
|
|
|
|
else if match(input, match:"^its owner$") then "anything its owner controls"
|
|
|
|
|
else if match(input, match:"^(each of )?your opponents$") then "anything " + replace(input, match:"(each of )?your opponents", replace:"controlled by those players")
|
|
|
|
|
@@ -1348,7 +1348,7 @@ protection_code := {
|
|
|
|
|
output
|
|
|
|
|
}
|
|
|
|
|
phy_reminder := {
|
|
|
|
|
phy_match := filter_text(input, match:"(/[WUBRG])+", in_context:"H<match>")
|
|
|
|
|
phy_match := filter_text(input, match:"(/[WUBRGO])+", in_context:"H<match>")
|
|
|
|
|
letters := split_text(phy_match, match:"/")
|
|
|
|
|
reminder_text := ""
|
|
|
|
|
if length(letters) == 2 then
|
|
|
|
|
@@ -1532,8 +1532,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[^>]*>)?[-+=]?[VHSCETKPLOQ\\?XYZIEWUBRG0-9/|]+(</sym[^>]*>)?,)* #### pay X, Y or Z
|
|
|
|
|
([ ](<sym[^>]*>)?[-+=]?[VHSCETKPLOQ\\?XYZIEWUBRG0-9/|]+(</sym[^>]*>)?[ ](and|or|and/or))* #### pay X or Y
|
|
|
|
|
([ ](<sym[^>]*>)?[-+=]?[VHSCETKPLOQ\\?XYZIEWUBRGO0-9/|]+(</sym[^>]*>)?,)* #### pay X, Y or Z
|
|
|
|
|
([ ](<sym[^>]*>)?[-+=]?[VHSCETKPLOQ\\?XYZIEWUBRGO0-9/|]+(</sym[^>]*>)?[ ](and|or|and/or))* #### pay X or Y
|
|
|
|
|
[ ]<match>
|
|
|
|
|
(
|
|
|
|
|
[,.)\"”]|$ #### (end of word)
|
|
|
|
|
@@ -1893,7 +1893,7 @@ text_filter :=
|
|
|
|
|
} +
|
|
|
|
|
#### step 4 : explict non mana symbols
|
|
|
|
|
replace@(
|
|
|
|
|
match: "\\][-+=]?[VHSCEKPLOTQINF\\?XYZIWUBRG0-9/|]+\\[",
|
|
|
|
|
match: "\\][-+=]?[VHSCEKPLOTQINF\\?XYZIWUBRGO0-9/|]+\\[",
|
|
|
|
|
replace: {"<nosym>" + mana_filter_t() + "</nosym>"}
|
|
|
|
|
) +
|
|
|
|
|
#### step 5 : add mana & tap symbols
|
|
|
|
|
@@ -1908,13 +1908,13 @@ text_filter :=
|
|
|
|
|
replace: {"<sym-auto>" + _1 + "</sym-auto>" + _3}
|
|
|
|
|
) +
|
|
|
|
|
replace@(
|
|
|
|
|
match: "\\b[VHSCEKPLOTQ\\?XYZIWUBRG0-9/|]+\\b",
|
|
|
|
|
match: "\\b[VHSCEKPLOTQ\\?XYZIWUBRGO0-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>([VHSCEKPLOTQ\\?XYZIWUBRG0-9/|]+)</sym-auto>",
|
|
|
|
|
match: "<sym-auto>([VHSCEKPLOTQ\\?XYZIWUBRGO0-9/|]+)</sym-auto>",
|
|
|
|
|
in_context: mana_un_context,
|
|
|
|
|
replace: "\\1"
|
|
|
|
|
) +
|
|
|
|
|
@@ -1924,7 +1924,7 @@ text_filter :=
|
|
|
|
|
replace: {"<sym>INF</sym>" }
|
|
|
|
|
) +
|
|
|
|
|
replace@(
|
|
|
|
|
match: "\\[[-+=]?[VHSCEKPLOTQ\\?XYZIWUBRG0-9/|]+\\]",
|
|
|
|
|
match: "\\[[-+=]?[VHSCEKPLOTQ\\?XYZIWUBRGO0-9/|]+\\]",
|
|
|
|
|
replace: {"<sym>" + mana_filter_t() + "</sym>"}
|
|
|
|
|
) +
|
|
|
|
|
#### step 6a : auto reminder
|
|
|
|
|
|