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

@ -102,23 +102,23 @@ impl PrefabBuilder {
}
'%' => {
build_data.map.tiles[idx] = TileType::Floor;
build_data.spawn_list.push((idx, spawner::food_table(build_data.map.depth).roll(rng)));
build_data.spawn_list.push((idx, spawner::food_table(build_data.map.difficulty).roll(rng)));
}
'!' => {
build_data.map.tiles[idx] = TileType::Floor;
build_data.spawn_list.push((idx, spawner::potion_table(build_data.map.depth).roll(rng)));
build_data.spawn_list.push((idx, spawner::potion_table(build_data.map.difficulty).roll(rng)));
}
'/' => {
build_data.map.tiles[idx] = TileType::Floor;
build_data.spawn_list.push((idx, spawner::wand_table(build_data.map.depth).roll(rng)));
build_data.spawn_list.push((idx, spawner::wand_table(build_data.map.difficulty).roll(rng)));
}
'?' => {
build_data.map.tiles[idx] = TileType::Floor;
build_data.spawn_list.push((idx, spawner::scroll_table(build_data.map.depth).roll(rng)));
build_data.spawn_list.push((idx, spawner::scroll_table(build_data.map.difficulty).roll(rng)));
}
')' => {
build_data.map.tiles[idx] = TileType::Floor;
build_data.spawn_list.push((idx, spawner::equipment_table(build_data.map.depth).roll(rng)));
build_data.spawn_list.push((idx, spawner::equipment_table(build_data.map.difficulty).roll(rng)));
}
_ => {
rltk::console::log(format!("Unknown glyph '{}' when loading prefab", (ch as u8) as char));
@ -255,7 +255,7 @@ impl PrefabBuilder {
self.apply_previous_iteration(|_x, _y| true, rng, build_data);
// Do we want a vault at all?
let vault_roll = rng.roll_dice(1, 6) + build_data.map.depth;
let vault_roll = rng.roll_dice(1, 6) + build_data.map.difficulty;
if vault_roll < 4 {
return;
}
@ -276,10 +276,10 @@ impl PrefabBuilder {
ORC_HOUSE_8X8,
];
// Filter the vault list down to ones that are applicable to the current depth
// Filter the vault list down to ones that are applicable to the current id
let mut possible_vaults: Vec<&PrefabVault> = master_vault_list
.iter()
.filter(|v| build_data.map.depth >= v.first_depth && build_data.map.depth <= v.last_depth)
.filter(|v| build_data.map.id >= v.first_id && build_data.map.id <= v.last_id)
.collect();
if possible_vaults.is_empty() {

View file

@ -12,8 +12,8 @@ pub struct PrefabVault {
pub template: &'static str,
pub width: usize,
pub height: usize,
pub first_depth: i32,
pub last_depth: i32,
pub first_id: i32,
pub last_id: i32,
pub can_flip: Flipping,
}
@ -21,8 +21,8 @@ pub const CLASSIC_TRAP_5X5: PrefabVault = PrefabVault {
template: CLASSIC_TRAP_5X5_V,
width: 5,
height: 5,
first_depth: 0,
last_depth: 100,
first_id: 0,
last_id: 100,
can_flip: Flipping::None,
};
const CLASSIC_TRAP_5X5_V: &str = "
@ -37,8 +37,8 @@ pub const CLASSIC_TRAP_CARDINALGAP_5X5: PrefabVault = PrefabVault {
template: CLASSIC_TRAP_CARDINALGAP_5X5_V,
width: 5,
height: 5,
first_depth: 0,
last_depth: 100,
first_id: 0,
last_id: 100,
can_flip: Flipping::Both,
};
const CLASSIC_TRAP_CARDINALGAP_5X5_V: &str = "
@ -53,8 +53,8 @@ pub const CLASSIC_TRAP_DIAGONALGAP_5X5: PrefabVault = PrefabVault {
template: CLASSIC_TRAP_DIAGONALGAP_5X5_V,
width: 5,
height: 5,
first_depth: 0,
last_depth: 100,
first_id: 0,
last_id: 100,
can_flip: Flipping::Both,
};
const CLASSIC_TRAP_DIAGONALGAP_5X5_V: &str = "
@ -65,14 +65,8 @@ const CLASSIC_TRAP_DIAGONALGAP_5X5_V: &str = "
     
";
pub const GOBLINS_4X4: PrefabVault = PrefabVault {
template: GOBLINS_4X4_V,
width: 4,
height: 4,
first_depth: 0,
last_depth: 100,
can_flip: Flipping::Both,
};
pub const GOBLINS_4X4: PrefabVault =
PrefabVault { template: GOBLINS_4X4_V, width: 4, height: 4, first_id: 0, last_id: 100, can_flip: Flipping::Both };
const GOBLINS_4X4_V: &str = "
#^  
#G#
@ -80,14 +74,8 @@ const GOBLINS_4X4_V: &str = "
^g^
";
pub const GOBLINS2_4X4: PrefabVault = PrefabVault {
template: GOBLINS2_4X4_V,
width: 4,
height: 4,
first_depth: 0,
last_depth: 100,
can_flip: Flipping::Both,
};
pub const GOBLINS2_4X4: PrefabVault =
PrefabVault { template: GOBLINS2_4X4_V, width: 4, height: 4, first_id: 0, last_id: 100, can_flip: Flipping::Both };
const GOBLINS2_4X4_V: &str = "
#^#g
G# #
@ -95,14 +83,8 @@ G# #
# g^
";
pub const GOBLINS_5X5: PrefabVault = PrefabVault {
template: GOBLINS_5X5_V,
width: 5,
height: 5,
first_depth: 0,
last_depth: 100,
can_flip: Flipping::Both,
};
pub const GOBLINS_5X5: PrefabVault =
PrefabVault { template: GOBLINS_5X5_V, width: 5, height: 5, first_id: 0, last_id: 100, can_flip: Flipping::Both };
const GOBLINS_5X5_V: &str = "
 ^#g 
G#?#^
@ -111,14 +93,8 @@ G#?#^
^# # 
";
pub const GOBLINS_6X6: PrefabVault = PrefabVault {
template: GOBLINS_6X6_V,
width: 6,
height: 6,
first_depth: 0,
last_depth: 100,
can_flip: Flipping::Both,
};
pub const GOBLINS_6X6: PrefabVault =
PrefabVault { template: GOBLINS_6X6_V, width: 6, height: 6, first_id: 0, last_id: 100, can_flip: Flipping::Both };
const GOBLINS_6X6_V: &str = "
   #  
 #^#g 
@ -128,28 +104,16 @@ g##$^
 ^ # ^
";
pub const FLUFF_6X3: PrefabVault = PrefabVault {
template: FLUFF_6X3_V,
width: 6,
height: 3,
first_depth: 0,
last_depth: 100,
can_flip: Flipping::Both,
};
pub const FLUFF_6X3: PrefabVault =
PrefabVault { template: FLUFF_6X3_V, width: 6, height: 3, first_id: 0, last_id: 100, can_flip: Flipping::Both };
const FLUFF_6X3_V: &str = "
###^ 
 ^ #
 ## 
";
pub const FLUFF2_6X3: PrefabVault = PrefabVault {
template: FLUFF2_6X3_V,
width: 6,
height: 3,
first_depth: 0,
last_depth: 100,
can_flip: Flipping::Both,
};
pub const FLUFF2_6X3: PrefabVault =
PrefabVault { template: FLUFF2_6X3_V, width: 6, height: 3, first_id: 0, last_id: 100, can_flip: Flipping::Both };
const FLUFF2_6X3_V: &str = "
 ^###
# ^ 
@ -160,8 +124,8 @@ pub const HOUSE_NOTRAP_7X7: PrefabVault = PrefabVault {
template: HOUSE_NOTRAP_7X7_V,
width: 7,
height: 7,
first_depth: 0,
last_depth: 100,
first_id: 0,
last_id: 100,
can_flip: Flipping::Both,
};
const HOUSE_NOTRAP_7X7_V: &str = "
@ -178,8 +142,8 @@ pub const HOUSE_TRAP_7X7: PrefabVault = PrefabVault {
template: HOUSE_TRAP_7X7_V,
width: 7,
height: 7,
first_depth: 0,
last_depth: 100,
first_id: 0,
last_id: 100,
can_flip: Flipping::Both,
};
const HOUSE_TRAP_7X7_V: &str = "
@ -192,14 +156,8 @@ const HOUSE_TRAP_7X7_V: &str = "
##   ##
";
pub const ORC_HOUSE_8X8: PrefabVault = PrefabVault {
template: ORC_HOUSE_8X8_V,
width: 8,
height: 8,
first_depth: 0,
last_depth: 100,
can_flip: Flipping::Both,
};
pub const ORC_HOUSE_8X8: PrefabVault =
PrefabVault { template: ORC_HOUSE_8X8_V, width: 8, height: 8, first_id: 0, last_id: 100, can_flip: Flipping::Both };
const ORC_HOUSE_8X8_V: &str = "
######