Handle strings and keys involving orange

This commit is contained in:
Sebastian Lundegård Kylander
2026-03-29 20:46:55 +02:00
parent 396fc63213
commit 90d089b9ab
4 changed files with 56 additions and 24 deletions

View File

@@ -438,6 +438,7 @@ colors_from_mana_symbols := {
if contains(input, match:"B") then str := str + ["black"]
if contains(input, match:"R") then str := str + ["red"]
if contains(input, match:"G") then str := str + ["green"]
if contains(input, match:"O") then str := str + ["orange"]
join(str, sep:", ")
}
@@ -590,6 +591,7 @@ colorless_color := {
else if cc == "black" then "b"
else if cc == "red" then "r"
else if cc == "green" then "g"
else if cc == "orange" then "o"
else "c"
}
@@ -620,6 +622,7 @@ color_name := {
else if input == "B" then "black"
else if input == "R" then "red"
else if input == "G" then "green"
else if input == "O" then "orange"
else ""
}
mana_name := {
@@ -628,6 +631,7 @@ mana_name := {
else if input == "black" then "B"
else if input == "red" then "R"
else if input == "green" then "G"
else if input == "orange" then "O"
else "C"
}
color_names_1 := { color_name(colors.0) }
@@ -701,6 +705,7 @@ land_to_color := {
else if watermark == "mana symbol black" then "black, land"
else if watermark == "mana symbol red" then "red, land"
else if watermark == "mana symbol green" then "green, land"
else if watermark == "mana symbol orange" then "orange, land"
else land_multicolor(colors:color_text_filter(input: rules))
}@(rules:card.rule_text)
@@ -708,7 +713,7 @@ land_to_color := {
text_to_color := {
#### Note: running filter_text is quite slow, do a quick 'contains' check first
if contains(match: card_name + " is") then (
text := filter_text(match: "is (colorless|all colors|((blue|white|green|red|black)((,|,? and) (blue|white|green|red|black))*))", in_context: regex_escape(card_name)+"(</[-a-z]+>)* <match>\\.")
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"
@@ -721,6 +726,7 @@ text_to_color := {
if contains(text, match: "black") then colors := colors + "B"
if contains(text, match: "red") then colors := colors + "R"
if contains(text, match: "green") then colors := colors + "G"
if contains(text, match: "orange") then colors := colors + "O"
if land == true then land_multicolor()
else mana_to_color(hybrid: "")
)
@@ -743,7 +749,7 @@ card_color := {
else text_color
};
#### Number of colors in a card_color
card_color_color_count := count_chosen@(choices: "white,blue,black,red,green,artifact")
card_color_color_count := count_chosen@(choices: "white,blue,black,red,green,orange,artifact")
#### Clean up color field
card_color_filter := {
colors := card_color_color_count()
@@ -777,6 +783,7 @@ card_color_to_letters := {
+(if contains(color_string, match:"black") then "B" else "")
+(if contains(color_string, match:"red") then "R" else "")
+(if contains(color_string, match:"green") then "G" else "")
+(if contains(color_string, match:"orange") then "O" else "")
}
card_color_field := { if input <= 1 then card.card_color else card["card_color_" + input] }
@@ -1059,6 +1066,7 @@ write_wubrg := {(if match(input, match:"white") then "W" else "")
+ (if match(input, match:"black") then "B" else "")
+ (if match(input, match:"red") then "R" else "")
+ (if match(input, match:"green") then "G" else "")
+ (if match(input, match:"orange") then "O" else "")
}
colored_mana := {to_number(
for each sym in cmc_split(to_text()) do (
@@ -1084,6 +1092,7 @@ primary_card_color := {
or chosen(choice:"black")
or chosen(choice:"red")
or chosen(choice:"green")
or chosen(choice:"orange")
)
land := chosen(choice:"land")
multi := chosen(choice:"multicolor")
@@ -1104,6 +1113,7 @@ primary_card_color := {
else if black then "black"
else if red then "red"
else if green then "green"
else if orange then "orange"
else input
}
sparker_card_color := {
@@ -1113,6 +1123,7 @@ sparker_card_color := {
or chosen(choice:"black")
or chosen(choice:"red")
or chosen(choice:"green")
or chosen(choice:"orange")
)
land := chosen(choice:"land")
multi := chosen(choice:"multicolor")
@@ -1133,6 +1144,7 @@ sparker_card_color := {
else if black then "black"
else if red then "red"
else if green then "green"
else if orange then "orange"
else "colorless"
}
@@ -1153,6 +1165,7 @@ color_to_mana := replace@(match: "white", replace: "[W]")
+ replace@(match: "black", replace: "[B]")
+ replace@(match: "red", replace: "[R]")
+ replace@(match: "green", replace: "[G]")
+ replace@(match: "orange", replace: "[O]")
#### convert number word to digit
digital_number := {
@@ -2638,6 +2651,7 @@ card_new_color := {
else if card.card_color == "black" then "b"
else if card.card_color == "red" then "r"
else if card.card_color == "green" then "g"
else if card.card_color == "orange" then "o"
else if contains(card.card_color, match:"artifact") then "a"
else if contains(card.card_color, match:"multi") or contains(card.card_color, match:"hybrid") then "m"
else "c"
@@ -5568,6 +5582,7 @@ alias_colors := {
b: rgb(39, 38, 36),
r: rgb(168, 88, 81),
g: rgb(6, 120, 69),
o: rgb(253, 196, 41),
a: rgb(239, 238, 236),
m: rgb(243, 210, 105),
c: rgb(173, 151, 137)
@@ -5894,12 +5909,14 @@ skeleton_runner := {
,"black"
,"red"
,"green"
,"orange"
]
,letter_list:["W"
,"U"
,"B"
,"R"
,"G"
,"O"
]
,mana_list:"nope"
)