Compare commits

...

2 Commits

Author SHA1 Message Date
Joachim Lusiardi 74831857cf fix monster percentage 2024-10-27 06:24:40 +01:00
Joachim Lusiardi 1ae7ff45ab Rename treasure room 2024-10-27 06:24:14 +01:00
2 changed files with 6 additions and 6 deletions

View File

@ -29,13 +29,13 @@ pub const LEVEL_WIDTH: usize = 1 + ROOMS_VERTICAL * ROOM_WIDTH;
pub const LEVEL_HEIGHT: usize = 1 + ROOMS_HORIZONTAL * ROOM_HEIGHT;
pub fn get_monsters_per_level() -> Vec<HashMap<MonsterTypes, std::ops::RangeInclusive<u8>>> {
let tmp = vec![
let tmp =[
// level 1
vec![(MonsterTypes::Rat, 50), (MonsterTypes::Spider, 50)],
// level 2
vec![(MonsterTypes::Rat, 50), (MonsterTypes::Snake, 50)],
// level 3
vec![(MonsterTypes::Orc, 33), (MonsterTypes::Skeleton, 33), (MonsterTypes::Snake, 33)],
vec![(MonsterTypes::Orc, 34), (MonsterTypes::Skeleton, 33), (MonsterTypes::Snake, 33)],
];
if tmp.len() != LEVELS {
panic!("Only {} monster sets defined for {} levels!", tmp.len(), LEVELS);

View File

@ -24,7 +24,7 @@ enum RoomType {
StairUp,
StairDown,
BasicRoom,
TreasureRoom,
ArtifactRoom,
MonsterRoom,
EmptyRoom,
}
@ -105,13 +105,13 @@ impl LevelGenerator {
room_types.push(RoomType::StairDown);
}
room_types.push(RoomType::MonsterRoom);
room_types.push(RoomType::TreasureRoom);
room_types.push(RoomType::ArtifactRoom);
// generate a random set of rooms and shuffle them
for _ in room_types.len()..ROOMS_HORIZONTAL * ROOMS_VERTICAL {
match rng.gen_range(1..=100) {
// TODO tune room type distribution
1..=33 => room_types.push(RoomType::EmptyRoom),
34..=66 => room_types.push(RoomType::TreasureRoom),
34..=66 => room_types.push(RoomType::ArtifactRoom),
67..=90 => room_types.push(RoomType::MonsterRoom),
_ => room_types.push(RoomType::BasicRoom),
}
@ -298,7 +298,7 @@ impl LevelGenerator {
StructureElement::Floor;
}
}
if room.kind == RoomType::TreasureRoom {
if room.kind == RoomType::ArtifactRoom {
let t_x = left + room.offset_x + rng.gen_range(0..room.width);
let t_y = top + room.offset_y + rng.gen_range(0..room.height);
// TODO randomize artifacts