From b0defa6f734d7991184c58745b26587062f41709 Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Mon, 6 Apr 2020 14:23:37 +0100 Subject: [PATCH] handle items --- src/main.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index e455798..3d3f955 100644 --- a/src/main.rs +++ b/src/main.rs @@ -659,14 +659,12 @@ fn room_from_string(string: String) -> Room { palette = last_line.replace("PAL ", "").to_string(); } else if last_line.starts_with("ITM") { let last_line = last_line.replace("ITM ", ""); - let item_pos: Vec<&str> = last_line.split(' ').collect(); - let item_id = item_pos[0]; - let pos = item_pos[1]; + let item_position: Vec<&str> = last_line.split(' ').collect(); + let item_id = item_position[0]; + let position = item_position[1]; + let position = position_from_string(position.to_string()); - items.insert( - position_from_string(pos.to_string()), - item_id.to_string() - ); + items.insert(position, item_id.to_string()); } else if last_line.starts_with("EXT") { let last_line = last_line.replace("EXT ", ""); let parts: Vec<&str> = last_line.split(' ').collect(); @@ -686,7 +684,7 @@ fn room_from_string(string: String) -> Room { palette, name, tiles: vec![], - items: Default::default(), + items, exits, endings: Default::default() } @@ -705,5 +703,5 @@ fn room_from_string(string: String) -> Room { // } fn main() { - println!("why am I here?") + println!("why does a crate need a main function?") }