diff --git a/src/client/game.ts b/src/client/game.ts index 1a3b9bc..8c03083 100644 --- a/src/client/game.ts +++ b/src/client/game.ts @@ -44,6 +44,25 @@ export class Game { // end of this.chat.registerSendFunction((message) => { + if (message.startsWith('!party')) { + const array = message.split(' '); + const name = array.slice(2).join(' '); + + if (array[1] === 'join') { + this.party.push(name); + } + + if (array[1] === 'leave') { + this.party.splice(this.party.indexOf(name), 1); + } + + if (array[1] === 'clear') { + this.party.length = 0; + } + + localStorage.setItem('party', this.party.join('|')); + } + this.socket.emit('chat-send', message); }); @@ -163,23 +182,6 @@ export class Game { } private experimentalPlayerCmd(message: string, sender: string) { - if (message.startsWith('!party')) { - const [cmd, task, name] = message.split(' ', 2); - if (task === 'join') { - this.party.push(name); - } - - if (task === 'leave') { - this.party.splice(this.party.indexOf(name), 1); - } - - if (task === 'clear') { - this.party.length = 0; - } - - localStorage.setItem('party', this.party.join('|')); - } - if (!(sender === this.me.display_name || this.party.includes(sender))) { return; }