FEATURE: chat tweak
This commit is contained in:
parent
c30c6b7fbd
commit
f840034d9c
8 changed files with 58 additions and 32 deletions
|
@ -3,6 +3,8 @@ import type { PlayerInterface } from "../Phaser/Game/PlayerInterface";
|
|||
import type { RoomConnection } from "../Connexion/RoomConnection";
|
||||
import { getRandomColor } from "../WebRtc/ColorGenerator";
|
||||
|
||||
let idCount = 0;
|
||||
|
||||
/**
|
||||
* A store that contains the list of players currently known.
|
||||
*/
|
||||
|
@ -40,6 +42,27 @@ function createPlayersStore() {
|
|||
getPlayerById(userId: number): PlayerInterface | undefined {
|
||||
return players.get(userId);
|
||||
},
|
||||
addFacticePlayer(name: string): number {
|
||||
let userId: number | null = null;
|
||||
players.forEach((p) => {
|
||||
if (p.name === name) userId = p.userId;
|
||||
});
|
||||
if (userId) return userId;
|
||||
const newUserId = idCount--;
|
||||
update((users) => {
|
||||
users.set(newUserId, {
|
||||
userId: newUserId,
|
||||
name,
|
||||
characterLayers: [],
|
||||
visitCardUrl: null,
|
||||
companion: null,
|
||||
userUuid: "dummy",
|
||||
color: getRandomColor(),
|
||||
});
|
||||
return users;
|
||||
});
|
||||
return newUserId;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue