decouples depth from difficulty, and renames depth to ID
for future impl of branches
This commit is contained in:
parent
8b2acab576
commit
1239597422
20 changed files with 164 additions and 204 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,5 @@ pub struct SpawnTable {
|
|||
pub struct SpawnTableEntry {
|
||||
pub id: String,
|
||||
pub weight: i32,
|
||||
pub min: i32,
|
||||
pub max: i32,
|
||||
pub difficulty: i32,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue