Conversation
| let newPlayer = false; | ||
| if (this.players.has(auth.playerId)) { | ||
| player = this.players.get(auth.playerId); | ||
| let playerIsAuthed = false; |
There was a problem hiding this comment.
This can largely be the same as in current, just using getAllPlayers aince you can work backwards from the playerId to the team
cjs8487
left a comment
There was a problem hiding this comment.
Couple of additional stray thoughts that apply in too many places to reasonably call out in individual comments.
- We should probably have a helper function in Room to get a player by id rather than having to write out the whole getAllPlayers...find... each time.
- Should we have a teams toggle for the room and corresponding helpers that determine how we display/format messages? So that, for example, in single player, we're not constantly saying "Player X's Team" rather than "Player X"
| // is not available in the current Prisma Client generation. | ||
| // We also need to fetch the roomId to create the team in the correct room. | ||
| const players: any[] = await tx.$queryRawUnsafe( | ||
| 'SELECT id, spectator, "roomId", nickname FROM "Player"' |
There was a problem hiding this comment.
Since we're no longer dropping the spectator column in the current migration, you should be able to write this as a properly typed sequence fully within prisma
| handleSocketClose(ws: WebSocket) { | ||
| let player: Player | undefined; | ||
| for (const p of this.players.values()) { | ||
| for (const p of this.getAllPlayers()) { |
There was a problem hiding this comment.
I'm not a huge stickler on this, but I believe it's generally better to use .forEach rather than a for ... of loop
| contents: player.nickname, | ||
| color: player.color, | ||
| contents: team.name, | ||
| // TODO: Which color should this be? |
There was a problem hiding this comment.
Unresolved TODO, if we're doing a full conversion of player -> team generally I would think this should just be team.color
There was a problem hiding this comment.
I generally wanted to leave colors on player so that different players can have different colors
There was a problem hiding this comment.
If that's the case, how are we going to show marked goals in the frontend? I don't have a problem with maintaining color per player, but I do think we definitely also need a team level color. I haven't fully mapped out what the frontend will be yet, but I think if anything the ability to view marks per-player will be a toggle of some sort
| import { HiddenCell, RevealedCell, Team as TeamData } from '@playbingo/types'; | ||
| import { computeRevealedMask, rowColToMask } from '../util/RoomUtils'; | ||
|
|
||
| export default class Team { |
There was a problem hiding this comment.
Teams should probably have a color
There was a problem hiding this comment.
See above, my idea was to leave colors on players so that each player in a team can have a different colour if wanted
While the title is as simple as saying "Support Teams" the underlying code changes are pretty big, refactoring the entire player and room model.