randomize artifact generation

This commit is contained in:
Joachim Lusiardi 2023-12-09 17:39:26 +01:00
parent e47036bd8d
commit 4a024a47d9
1 changed files with 6 additions and 2 deletions

View File

@ -11,7 +11,7 @@ use rand::rngs::ThreadRng;
use crate::level::{Level, StructureElement}; use crate::level::{Level, StructureElement};
use crate::monster::Monster; use crate::monster::Monster;
use crate::artifacts::{Artifact, Chest}; use crate::artifacts::{Artifact, Chest, Potion};
use crate::position::Position; use crate::position::Position;
const ROOMS_VERTICAL: usize = 7; const ROOMS_VERTICAL: usize = 7;
@ -264,7 +264,11 @@ impl LevelGenerator {
if room.kind == RoomType::TreasureRoom { if room.kind == RoomType::TreasureRoom {
let t_x = left + room.offset_x + rng.gen_range(0..room.width); 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); let t_y = top + room.offset_y + rng.gen_range(0..room.height);
artifacts.push(Box::new(Chest::new(Position::new(self.level, t_x, t_y)))); // TODO randomize artifacts
match rng.gen_range(1..=100) {
1..=50 => { artifacts.push(Box::new(Chest::new(Position::new(self.level, t_x, t_y)))); }
_ => { artifacts.push(Box::new(Potion::new(Position::new(self.level, t_x, t_y)))); }
};
} }
if room.kind == RoomType::MonsterRoom { if room.kind == RoomType::MonsterRoom {
let t_x = left + room.offset_x + rng.gen_range(0..room.width); let t_x = left + room.offset_x + rng.gen_range(0..room.width);