limit inventory to 10 slots

This commit is contained in:
2024-10-21 21:59:55 +02:00
parent 2b8f7eebba
commit 5949b2a2d6
3 changed files with 11 additions and 5 deletions

View File

@@ -69,8 +69,13 @@ impl Player {
rand::thread_rng().gen_range(1..4)
}
pub fn add_to_inventory(&mut self, potion: &Potion) {
self.inventory.push(*potion);
pub fn add_to_inventory(&mut self, potion: &Potion) -> bool {
if self.inventory.len() < 10 {
self.inventory.push(*potion);
true
} else {
false
}
}
pub fn inventory_size(&self) -> usize {