diff --git a/src/main.rs b/src/main.rs index 06004f7..0bc3dde 100644 --- a/src/main.rs +++ b/src/main.rs @@ -676,8 +676,7 @@ fn player_matchup( g_func((deviation1 * deviation1 + deviation2 * deviation2).sqrt()) * advantage, )); - let color = ansi_num_color(advantage, 0.2, 2.0); - let other_color = ansi_num_color(-advantage, 0.2, 2.0); + let (color, other_color) = ansi_num_color(advantage, 0.2, 2.0); let len1 = prefix1.as_deref().map(|s| s.len() + 1).unwrap_or(0) + name1.len(); let len2 = prefix2.as_deref().map(|s| s.len() + 1).unwrap_or(0) + name2.len(); diff --git a/src/util.rs b/src/util.rs index fe037cc..feea160 100644 --- a/src/util.rs +++ b/src/util.rs @@ -41,7 +41,7 @@ pub fn read_string() -> String { line.trim().to_owned() } -pub fn ansi_num_color(num: f64, threshold1: f64, threshold2: f64) -> &'static str { +pub fn ansi_num_color(num: f64, threshold1: f64, threshold2: f64) -> (&'static str, &'static str) { let sign = num > 0.0; let num_abs = num.abs(); let severity = if num_abs < threshold1 { @@ -53,11 +53,11 @@ pub fn ansi_num_color(num: f64, threshold1: f64, threshold2: f64) -> &'static st }; match (sign, severity) { - (false, 1) => "31", - (true, 1) => "32", - (false, 2) => "91", - (true, 2) => "92", - _ => "39", + (false, 1) => ("31", "32"), + (true, 1) => ("32", "31"), + (false, 2) => ("91", "92"), + (true, 2) => ("92", "91"), + _ => ("39", "39"), } }