unused potions now are collected in the inventory and can be consumed with the p key
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -103,12 +103,13 @@ fn main() -> Result<()> {
|
||||
.style(Style::default().bg(Color::Blue));
|
||||
frame.render_widget(
|
||||
Paragraph::new(format!(
|
||||
"Health: {}/{}\nExp: {}\nGold: {}\nLevel: {}",
|
||||
"Health: {}/{}\nExp: {}\nGold: {}\nLevel: {}\nInventory: {}",
|
||||
game.get_player().get_life(),
|
||||
game.get_player().get_max_life(),
|
||||
game.get_player().get_experience(),
|
||||
game.get_player().get_gold(),
|
||||
game.get_player().get_immutable_position().get_level() + 1
|
||||
game.get_player().get_immutable_position().get_level() + 1,
|
||||
game.get_player().inventory_size(),
|
||||
))
|
||||
.block(block)
|
||||
.wrap(Wrap { trim: true }),
|
||||
@@ -155,6 +156,19 @@ fn main() -> Result<()> {
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
KeyCode::Char('p') => {
|
||||
let gained_health = game.get_mutable_player().consume_inventory();
|
||||
if gained_health > 0 {
|
||||
game.messages.insert(
|
||||
0,
|
||||
format!(
|
||||
"used a potion from inventory and gained {} health.",
|
||||
gained_health
|
||||
)
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
}
|
||||
KeyCode::Char('q') => {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user