Add Lobby #43

Merged
hamcha merged 18 commits from feature/lobby into master 2019-10-16 08:31:04 +00:00
Showing only changes of commit 07d5e9b2ba - Show all commits

View file

@ -29,16 +29,21 @@ export abstract class Client extends EventEmitter {
this.metadata.name = data.newname; this.metadata.name = data.newname;
} }
let idx = this.players.indexOf(data.oldname); // Only mutate player list if we have one
if (idx < 0) { // This is because rename messages can be received during the initial
// Weird // handshake, to signal a forced name change before joining.
console.warn( if (this.players) {
`Someone (${data.oldname}) changed name but wasn't on the player list` let idx = this.players.indexOf(data.oldname);
); if (idx < 0) {
this.players.push(data.newname); // Weird
break; console.warn(
`Someone (${data.oldname}) changed name but wasn't on the player list`
);
this.players.push(data.newname);
break;
}
Vue.set(this.players, idx, data.newname);
} }
Vue.set(this.players, idx, data.newname);
this.emit("rename", data.oldname, data.newname); this.emit("rename", data.oldname, data.newname);
break; break;
// A new player joined the room (this includes us) // A new player joined the room (this includes us)