Commit 13526524 authored by twanvl's avatar twanvl

formating; explicitly return nil from text_to_color on failure. The latter is...

formating; explicitly return nil from text_to_color on failure. The latter is needed because a warning will be added to 2.0.1 about missing returns (not yet in trunk)
parent 7eca7be1
...@@ -74,14 +74,14 @@ mana_to_color := { ...@@ -74,14 +74,14 @@ mana_to_color := {
else "multicolor" else "multicolor"
else if contains(type, match:"Artifact") then else if contains(type, match:"Artifact") then
# hybrid, but artifact # hybrid, but artifact
if count == 0 then "artifact" if count == 0 then "artifact"
else if count == 1 then color_names_1() + ", artifact" else if count == 1 then color_names_1() + ", artifact"
else if count == 2 then color_names_2() + ", artifact" else if count == 2 then color_names_2() + ", artifact"
else "artifact, multicolor" else "artifact, multicolor"
else else
# hybrid, not artifact # hybrid, not artifact
if count == 0 then "colorless" if count == 0 then "colorless"
else if count == 1 then color_names_1() else if count == 1 then color_names_1()
else if count == 2 then color_names_2() + ", hybrid" else if count == 2 then color_names_2() + ", hybrid"
else "multicolor" else "multicolor"
} }
...@@ -118,24 +118,24 @@ land_to_color := { ...@@ -118,24 +118,24 @@ land_to_color := {
text_to_color := { text_to_color := {
# Note: running filter_text is quite slow, do a quick 'contains' check first # Note: running filter_text is quite slow, do a quick 'contains' check first
if contains(match: card_name) then ( if contains(match: card_name) 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)((,|,? and) (blue|white|green|red|black))*))", in_context: regex_escape(card_name)+"(</[-a-z]+>)* <match>\\.")
if text != "" then ( if text != "" then (
if contains(text, match: "all colors") then ( if contains(text, match: "all colors") then (
colors := "WUBRG" colors := "WUBRG"
if land = "land" then land_multicolor() if land = "land" then land_multicolor()
else mana_to_color(hybrid: "") else mana_to_color(hybrid: "")
) else ( ) else (
colors := "" colors := ""
if contains(text, match: "white") then colors := colors + "W" if contains(text, match: "white") then colors := colors + "W"
if contains(text, match: "blue") then colors := colors + "U" if contains(text, match: "blue") then colors := colors + "U"
if contains(text, match: "black") then colors := colors + "B" if contains(text, match: "black") then colors := colors + "B"
if contains(text, match: "red") then colors := colors + "R" if contains(text, match: "red") then colors := colors + "R"
if contains(text, match: "green") then colors := colors + "G" if contains(text, match: "green") then colors := colors + "G"
if land = "land" then land_multicolor() if land = "land" then land_multicolor()
else mana_to_color(hybrid: "") else mana_to_color(hybrid: "")
) )
) )
) ) else nil
} }
# The color of a card # The color of a card
...@@ -148,7 +148,7 @@ is_spell := match@(match: "(?i)Instant|Sorcery") ...@@ -148,7 +148,7 @@ is_spell := match@(match: "(?i)Instant|Sorcery")
card_color := { card_color := {
# usually the color of mana # usually the color of mana
text_color := text_to_color(rules_text, land: is_land(type)); text_color := text_to_color(rules_text, land: is_land(type));
if text_color == "" then ( if text_color == nil then (
mana_color := mana_to_color(colors: color_filter(casting_cost), hybrid: color_filterH(casting_cost)) mana_color := mana_to_color(colors: color_filter(casting_cost), hybrid: color_filterH(casting_cost))
if mana_color == "colorless" and is_land (type) then land_to_color(watermark) if mana_color == "colorless" and is_land (type) then land_to_color(watermark)
else if mana_color == "colorless" and is_artifact(type) then "artifact" else if mana_color == "colorless" and is_artifact(type) then "artifact"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment