randomize content of chests and potions

This commit is contained in:
2024-10-21 08:27:55 +02:00
parent b3d85ac7b3
commit 8dfe56a3c2
5 changed files with 9 additions and 8 deletions

View File

@@ -1,3 +1,4 @@
use rand::Rng;
use ratatui::style::Color;
use crate::player::Player;
@@ -22,11 +23,11 @@ pub struct Chest {
impl Chest {
pub fn new(position: Position) -> Self {
let level = position.get_level();
let min_gold = 10 * (position.get_level()+1);
let max_gold = min_gold + 10*position.get_level();
Self {
position,
// TODO maybe randomize this?
gold: (level + 1) * 10,
gold: rand::thread_rng().gen_range(min_gold..=max_gold),
}
}
}
@@ -61,9 +62,11 @@ pub struct Potion {
impl Potion {
pub fn new(position: Position) -> Self {
let min_health_gain = 5 + position.get_level();
let max_health_gain = min_health_gain + 3 * position.get_level();
Self {
position,
health: 5,
health: rand::thread_rng().gen_range(min_health_gain..=max_health_gain),
}
}
}