From 0a7ed21ea654fdb31937b4d586f71201a5cf91db Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Sun, 28 Jun 2020 20:42:53 +0100 Subject: [PATCH] refactor room exit, ending changes --- src/game.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/game.rs b/src/game.rs index 1d13000..bb3b46a 100644 --- a/src/game.rs +++ b/src/game.rs @@ -471,17 +471,21 @@ impl Game { room.exits = room.exits.iter().map(|exit| { let mut exit = exit.clone(); - if room_id_changes.contains_key(&exit.exit.room_id) { - let new_id = room_id_changes.get(&exit.exit.room_id).unwrap(); - exit.exit.room_id = new_id.clone(); + + let key = exit.exit.room_id.clone(); + let change = room_id_changes.get(&key); + if change.is_some() { + exit.exit.room_id = change.unwrap().clone(); } exit }).collect(); room.endings = room.endings.iter().map(|ending| { let mut ending = ending.clone(); - if ending_id_changes.contains_key(&ending.id) { - ending.id = ending_id_changes[&ending.id].clone(); + let key = ending.id.clone(); + let change = ending_id_changes.get(&key); + if change.is_some() { + ending.id = change.unwrap().clone(); } ending }).collect();