better logging

This commit is contained in:
biglyderv 2024-11-25 14:14:20 -05:00
parent d9daef380e
commit 13cd3db387
3 changed files with 22 additions and 8 deletions

View file

@ -135,9 +135,15 @@ class Game extends GameBasic {
this.sync();
}
}
sync() {
sync(first = false) {
let { player } = this;
if (first) {
player.ref = new URL(window.location).searchParams.get('ref') || 'nobody';
} else {
player.ref = false;
}
this.ws.send(JSON.stringify(player.legalProps.map(prop => player[prop])));
}
recv({ data }) {
@ -215,8 +221,12 @@ class Game extends GameBasic {
this.ws.addEventListener('message', function (e) { that.recv(e) });
this.ws.addEventListener('open', function () {
that.sync(true);
setInterval(function () { that.sync() }, 1000 / 5);
})
setInterval(function () { that.render() }, 1000 / 60);
setInterval(function () { that.sync() }, 1000 / 5);
game.canvas.onclick = () => that.click();
}