From 4a024a47d937be0e0a36d96737e1b23ff60f42f4 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Sat, 9 Dec 2023 17:39:26 +0100 Subject: [PATCH] randomize artifact generation --- src/level_generator.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/level_generator.rs b/src/level_generator.rs index 024b3d2..b8e62c4 100644 --- a/src/level_generator.rs +++ b/src/level_generator.rs @@ -11,7 +11,7 @@ use rand::rngs::ThreadRng; use crate::level::{Level, StructureElement}; use crate::monster::Monster; -use crate::artifacts::{Artifact, Chest}; +use crate::artifacts::{Artifact, Chest, Potion}; use crate::position::Position; const ROOMS_VERTICAL: usize = 7; @@ -264,7 +264,11 @@ impl LevelGenerator { if room.kind == RoomType::TreasureRoom { 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); - 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 { let t_x = left + room.offset_x + rng.gen_range(0..room.width);