This create_game_with_id method will be helpful in pre-allocating
a game for convenien in the development of flempires.
return [...Array(4)].map(() => LMNO.letters.charAt(Math.floor(Math.random() * LMNO.letters.length))).join('');
}
return [...Array(4)].map(() => LMNO.letters.charAt(Math.floor(Math.random() * LMNO.letters.length))).join('');
}
- create_game(engine_name) {
- do {
- var id = this.generate_id();
- } while (id in this.games);
+ create_game_with_id(engine_name, id) {
+ if (this.games[id])
+ return null;
const engine = engines[engine_name];
const engine = engines[engine_name];
+
+ create_game(engine_name) {
+ do {
+ var id = this.generate_id();
+ } while (id in this.games);
+
+ return this.create_game_with_id(engine_name, id);
+ }
}
/* Some letters we don't use in our IDs:
}
/* Some letters we don't use in our IDs: