38 lines
942 B
Rust
38 lines
942 B
Rust
use crate::items::print_box;
|
|
use crate::stats::Stats;
|
|
|
|
pub struct Player {
|
|
pub name: String,
|
|
pub stats: Stats,
|
|
pub next_level_exp: usize,
|
|
pub current_exp: usize,
|
|
}
|
|
|
|
impl Player {
|
|
pub fn new(name: String) -> Self {
|
|
Self {
|
|
name,
|
|
stats: Stats::new(),
|
|
next_level_exp: 10,
|
|
current_exp: 0,
|
|
}
|
|
}
|
|
|
|
pub fn show_stats(&self) {
|
|
let stats: &Stats = &self.stats;
|
|
|
|
print_box(&[
|
|
format!("Name: {}", self.name),
|
|
format!(
|
|
"Level: {} ({}/{})",
|
|
stats.level, self.current_exp, self.next_level_exp
|
|
),
|
|
format!("Strength: {}", stats.strength),
|
|
format!("Dexterity: {}", stats.dexterity),
|
|
format!("Constitution: {}", stats.constitution),
|
|
format!("Charisma: {}", stats.charisma),
|
|
format!("Luck: {}", stats.luck),
|
|
]);
|
|
}
|
|
}
|