From 10314558af366f69cd5a77c76798717b5b87394e Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Thu, 24 Mar 2016 20:24:44 +0700 Subject: [PATCH] Random IDs mess up the saves. IDs have to be predictable. --- lib/util/dialogue.coffee | 3 +-- lib/util/phrase.coffee | 3 +-- lib/util/randomid.coffee | 6 ------ 3 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 lib/util/randomid.coffee diff --git a/lib/util/dialogue.coffee b/lib/util/dialogue.coffee index 04b3fd6..6e4c121 100644 --- a/lib/util/dialogue.coffee +++ b/lib/util/dialogue.coffee @@ -1,5 +1,4 @@ room = require("../room.coffee") -randomid = require("./randomid.coffee") ### A dialogue shortcut. Usage: @@ -9,7 +8,7 @@ Usage: """, "character.sandbox.mild = true" ### dialogue = (title, salet, startTag, endTag, text, effect) -> - retval = room(randomid(), salet, { + retval = room("dialogue_"+salet.rooms.length, salet, { optionText: title dsc: text clear: false # backlog is useful in dialogues diff --git a/lib/util/phrase.coffee b/lib/util/phrase.coffee index bca234a..cf2a060 100644 --- a/lib/util/phrase.coffee +++ b/lib/util/phrase.coffee @@ -1,5 +1,4 @@ room = require("../room.coffee") -randomid = require("./randomid.coffee") ### A phrase shortcut. Usage: @@ -15,7 +14,7 @@ Usage: @param string effect an optional parameter, eval'd code ### phrase = (title, salet, tag, text, effect) -> - retval = room(randomid(), salet, { + retval = room("phrase_"+salet.rooms.length, salet, { optionText: title dsc: text clear: false # backlog is useful in dialogues diff --git a/lib/util/randomid.coffee b/lib/util/randomid.coffee deleted file mode 100644 index f907d74..0000000 --- a/lib/util/randomid.coffee +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = () -> - alphabet = "abcdefghijklmnopqrstuvwxyz0123456789" # see the dreaded linkRe expression in Undum - rndstr = [] - for i in [1..10] - rndstr.push alphabet.charAt(Math.floor(Math.random() * alphabet.length)) - return rndstr.join('').toString()