refactor room exit, ending changes

This commit is contained in:
Max Bradbury 2020-06-28 20:42:53 +01:00
parent 6113bb12a6
commit 0a7ed21ea6
1 changed files with 9 additions and 5 deletions

View File

@ -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();