+function start_level() {
+ const tardis = state.tardis;
+
+ // Inform all players of the new level
+ io_tardis.emit("level", levels[tardis.level].title);
+
+ // Then start the timer that shows the words
+ show_word_interval = setInterval(show_word, 1200);
+}
+
+function level_up() {
+ const tardis = state.tardis;
+
+ if (show_word_interval) {
+ clearInterval(show_word_interval);
+ show_word_interval = 0;
+ }
+
+ if (tardis.state === "game") {
+ tardis.level = tardis.level + 1;
+ tardis.word = 0;
+
+ if (tardis.level >= levels.length) {
+ tardis.state = "over";
+ io_tardis.emit("state", tardis.state);
+ } else {
+ setTimeout(() => {
+ start_level();
+ }, 2000);
+ }
+
+ }
+}
+