diff --git a/includes/script.js b/includes/script.js index 809a6bd..07ca460 100644 --- a/includes/script.js +++ b/includes/script.js @@ -495,9 +495,13 @@ $(document).ready(function() { // handle rooms // need to import IDs so we don't give the new room a conflicting ID - var roomNames = newGameData.match(/ROOM \d+/g); + var roomIds = newGameData.match(/ROOM \d+\n/g); - var newRoomId = parseInt(_.last(roomNames).replace(/[^\d]+/g, "")) + 1; + roomIds = _.map(roomIds, function(roomId) { + return parseInt(roomId.replace(/[^\d]+/g, "")); + }); + + var newRoomId = _.max(roomIds) + 1; var newRoomName = $('#roomName').val(); // remove invalid chars? what's invalid? newlines? are those possible?