make variable inventory slots
This commit is contained in:
@@ -12,6 +12,7 @@ pub struct Player {
|
||||
gold: usize,
|
||||
experience: usize,
|
||||
inventory: Vec<Potion>,
|
||||
inventory_slots: usize,
|
||||
}
|
||||
|
||||
impl Player {
|
||||
@@ -24,6 +25,7 @@ impl Player {
|
||||
gold: 0,
|
||||
experience: 0,
|
||||
inventory: vec![],
|
||||
inventory_slots: 2,
|
||||
}
|
||||
}
|
||||
pub fn get_name(&self) -> String {
|
||||
@@ -70,7 +72,7 @@ impl Player {
|
||||
}
|
||||
|
||||
pub fn add_to_inventory(&mut self, potion: &Potion) -> bool {
|
||||
if self.inventory.len() < 10 {
|
||||
if self.inventory.len() < self.inventory_slots {
|
||||
self.inventory.push(*potion);
|
||||
true
|
||||
} else {
|
||||
@@ -78,8 +80,8 @@ impl Player {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn inventory_size(&self) -> usize {
|
||||
self.inventory.len()
|
||||
pub fn inventory_size(&self) -> (usize, usize) {
|
||||
(self.inventory.len(), self.inventory_slots)
|
||||
}
|
||||
|
||||
pub fn consume_inventory(&mut self) -> usize {
|
||||
|
||||
Reference in New Issue
Block a user