decouples depth from difficulty, and renames depth to ID

for future impl of branches
This commit is contained in:
Llywelwyn 2023-07-27 17:59:46 +01:00
parent 8b2acab576
commit 1239597422
20 changed files with 164 additions and 204 deletions

View file

@ -249,14 +249,20 @@ fn get_renderable_component(renderable: &super::item_structs::Renderable) -> cra
}
}
pub fn table_by_name(raws: &RawMaster, key: &str, depth: i32) -> RandomTable {
pub fn table_by_name(raws: &RawMaster, key: &str, difficulty: i32) -> RandomTable {
if raws.table_index.contains_key(key) {
let spawn_table = &raws.raws.spawn_tables[raws.table_index[key]];
use super::SpawnTableEntry;
let available_options: Vec<&SpawnTableEntry> =
spawn_table.table.iter().filter(|a| depth >= a.min && depth <= a.max).collect();
let upper_bound = difficulty;
let lower_bound = 1;
let available_options: Vec<&SpawnTableEntry> = spawn_table
.table
.iter()
.filter(|entry| entry.difficulty >= lower_bound && entry.difficulty <= upper_bound)
.collect();
let mut rt = RandomTable::new();
for e in available_options.iter() {