}
}
+function start_welcome_timer() {
+ const tardis = state.tardis;
+ tardis.timer = 30;
+ emit_tardis_timer();
+ tardis_interval = setInterval(emit_tardis_timer, 1000);
+}
+
io_tardis.on("connection", (socket) => {
if (! socket.request.session.name) {
console.log("Error: Someone showed up at the Tardis without a name.");
// Let the new user know the state of the game
socket.emit("state", tardis.state);
+ // And the level if relevant
+ if (tardis.state === "game") {
+ socket.emit("level", levels[tardis.level].title);
+ }
+
// Put each of our boys into a different room
switch (name[0]) {
case 'C':
}
if (tardis.companions.count === 0) {
- tardis.timer = 30;
- emit_tardis_timer();
- tardis_interval = setInterval(emit_tardis_timer, 1000);
+ start_welcome_timer();
}
if (! tardis.companions.names.includes(name)) {
}
});
+ socket.on('reboot', () => {
+ const tardis = state.tardis;
+
+ if (show_word_interval) {
+ clearInterval(show_word_interval);
+ show_word_interval = 0;
+ }
+
+ tardis.state = "welcome";
+ io_tardis.emit("state", tardis.state);
+ io_tardis.emit('companions', tardis.companions.count);
+
+ start_welcome_timer();
+ });
+
socket.on('disconnect', () => {
const names = tardis.companions.names;