randomize content of chests and potions
This commit is contained in:
@@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user