inventario
This commit is contained in:
parent
08ce45da58
commit
8dc914e5e6
@ -1,5 +1,26 @@
|
||||
use crate::objects::get_objects;
|
||||
|
||||
pub struct Player {
|
||||
pub tag: String,
|
||||
pub name: String,
|
||||
pub location: String,
|
||||
}
|
||||
|
||||
pub fn execute_inventory(player: &mut Player) -> String {
|
||||
let mut output: String;
|
||||
let current = &player.tag;
|
||||
let objetos = get_objects(current.to_string());
|
||||
|
||||
if objetos.is_ok() {
|
||||
output = String::from("Portas los siguientes objetos:\n");
|
||||
for objeto in objetos.unwrap() {
|
||||
let mut nombre = objeto.nombre;
|
||||
nombre.push_str("\n");
|
||||
output.push_str(&nombre);
|
||||
}
|
||||
} else {
|
||||
output = String::from("No portas ningún objeto.")
|
||||
}
|
||||
|
||||
output
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::io::{self, Write};
|
||||
use crate::rlocation::{execute_go, execute_look};
|
||||
use crate::player::Player;
|
||||
use crate::player::{Player, execute_inventory};
|
||||
use crate::objects::{execute_search, execute_pick};
|
||||
|
||||
pub struct Command {
|
||||
@ -58,6 +58,7 @@ pub fn update_state(player: &mut Player, command: &Command) -> String {
|
||||
"o" => output = execute_go(player, "o"),
|
||||
"buscar" => output = execute_search(player),
|
||||
"coger" => output = execute_pick(player, command.noun.as_str()),
|
||||
"inventario" => output = execute_inventory(player),
|
||||
_ => output = format!("No se como hacer eso."),
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user