summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Gay <eapoems@riseup.net>2023-10-14 19:18:44 -0400
committerDavid Gay <eapoems@riseup.net>2023-10-14 19:18:44 -0400
commit6d619c28cc897580368a8ab509ccd91cf2610ccc (patch)
treea91f913a8cc4053f2a8de40283a9ca6c68fe03a4 /src
parent83f0d8e32cff5ba7c86838bc0a6057aa952f1526 (diff)
Hack class lookups by downcasing for now
Diffstat (limited to 'src')
-rw-r--r--src/main.rs7
-rw-r--r--src/random_tables.rs16
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<String>,
text: Option<String>,
}
+//
+// 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<String, RandomTable>,