From 6d619c28cc897580368a8ab509ccd91cf2610ccc Mon Sep 17 00:00:00 2001 From: David Gay Date: Sat, 14 Oct 2023 19:18:44 -0400 Subject: Hack class lookups by downcasing for now --- src/main.rs | 7 ++++++- src/random_tables.rs | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5f50fa7..6070e06 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,12 @@ fn main() { match random_command { ("henchman", _) => { let class_name = random_tables.roll_table("henchman_class").to_string(); - let class_ref = CLASSES.get(&*class_name).unwrap_or_else(|| { + // HACK: Need a proper way to do lookups, shouldn't rely on + // downcasing the class name. This whole situation is really + // indicative of the need for an architectural improvement. + // Need to think about roll_table()'s return type, + // and how we want to get table results in general. + let class_ref = CLASSES.get(&*class_name.to_lowercase()).unwrap_or_else(|| { eprintln!("Class '{}' not found.", &*class_name); std::process::exit(1); }); diff --git a/src/random_tables.rs b/src/random_tables.rs index 4411675..6d6896a 100644 --- a/src/random_tables.rs +++ b/src/random_tables.rs @@ -1,5 +1,5 @@ use crate::dice; -use crate::rules::classes::CLASSES; +use crate::rules::classes::{CLASSES, Class}; use include_dir::{include_dir, Dir}; use serde::Deserialize; use serde_yaml; @@ -25,6 +25,20 @@ struct TableRowStep { table: Option, text: Option, } +// +// enum TableOutcome { +// Text(String), +// Class(Class), +// } +// +// impl TableOutcome { +// fn to_string(&self) -> String { +// match self { +// TableOutcome::Text(text) => text.clone(), +// TableOutcome::Class(class) => class.name.clone(), +// } +// } +// } pub struct RandomTables { tables: HashMap, -- cgit v1.2.3