From 20c6b4c7cfd75e16b20640d8e57ae2f6f3b6e3cb Mon Sep 17 00:00:00 2001 From: Erin Date: Tue, 7 Dec 2021 22:58:41 +0100 Subject: [PATCH] Implemented Abool -> Functio --- ablescript/src/variables.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ablescript/src/variables.rs b/ablescript/src/variables.rs index 11e2d6a..241654b 100644 --- a/ablescript/src/variables.rs +++ b/ablescript/src/variables.rs @@ -218,8 +218,25 @@ impl Value { }, tape_len: crate::brian::DEFAULT_TAPE_SIZE_LIMIT, }, - Value::Bool(_) => todo!(), - Value::Abool(_) => todo!(), + Value::Bool(b) => Functio::Eval( + if b { + r#"loop{"Buy Able products!"print;}"# + } else { + "" + } + .to_owned(), + ), + Value::Abool(a) => Functio::Eval(match a { + Abool::Never => "".to_owned(), + Abool::Sometimes => { + use rand::seq::SliceRandom; + let mut str_chars: Vec<_> = "Buy Able Products!".chars().collect(); + str_chars.shuffle(&mut rand::thread_rng()); + + format!(r#""{}"print;"#, str_chars.iter().collect::()) + } + Abool::Always => r#"loop{"Buy Able products!"print;}"#.to_owned(), + }), Value::Functio(f) => f, Value::Cart(_) => todo!(), }