22 lines
485 B
JavaScript
22 lines
485 B
JavaScript
|
import { updatePlayerDom } from "./dom.js";
|
||
|
|
||
|
export class Player {
|
||
|
constructor(id, name) {
|
||
|
this.name = name;
|
||
|
this.timeout = null;
|
||
|
this.id = id;
|
||
|
this.ready = false;
|
||
|
}
|
||
|
|
||
|
resetTimeout() {
|
||
|
if (this.timeout !== null) {
|
||
|
window.clearTimeout(players[data.author].timeout);
|
||
|
}
|
||
|
|
||
|
this.timeout = window.setTimeout(() => {
|
||
|
delete players[this.id];
|
||
|
updatePlayerDom();
|
||
|
}, TIMEOUT);
|
||
|
}
|
||
|
}
|