better room ID handling (needs testing)

This commit is contained in:
synth-ruiner 2018-05-08 21:30:26 +01:00
parent 341f27ac11
commit 25c0e53696
1 changed files with 6 additions and 2 deletions

View File

@ -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?