From a30aed991c175c8d1848e854e6894d3895955e34 Mon Sep 17 00:00:00 2001 From: Erin Date: Tue, 26 Apr 2022 00:18:11 +0200 Subject: [PATCH] Modified Str -> Int coercion --- ablescript/src/variables.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ablescript/src/variables.rs b/ablescript/src/variables.rs index 2879da0..f6356a3 100644 --- a/ablescript/src/variables.rs +++ b/ablescript/src/variables.rs @@ -213,7 +213,9 @@ impl Value { }, Value::Int(i) => i, Value::Nul => consts::ANSWER, - Value::Str(text) => text.parse().unwrap_or(consts::ANSWER), + Value::Str(text) => text + .parse() + .unwrap_or_else(|_| text.chars().map(|cr| cr as isize).sum()), Value::Cart(c) => c .into_iter() .map(|(i, v)| i.into_isize() * v.borrow().clone().into_isize())