Skip to content
This repository was archived by the owner on Mar 21, 2026. It is now read-only.

Commit 8c77676

Browse files
made it so that the players username cannot be the same with the host's
1 parent 86876a0 commit 8c77676

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

changelog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
New mayor project: TypeWord. Check it out in the projects tab
1+
TypeWord bug fixes

src/routes/typeword.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@ router.post("/join", async (req: Request, res: Response) => {
4747
if(username && room){
4848
if(await verify(req)){
4949
if(typeWordRooms[room]){
50-
typeWordRooms[room].player = username;
51-
io.emit("typewordjoin", {"room": room, "username": username});
52-
res.render("projects/typeword/game", { room: room, user: username, host: typeWordRooms[room].host, player: username });
50+
if(username != typeWordRooms[room].host){
51+
typeWordRooms[room].player = username;
52+
io.emit("typewordjoin", {"room": room, "username": username});
53+
res.render("projects/typeword/game", { room: room, user: username, host: typeWordRooms[room].host, player: username });
54+
}
55+
else{
56+
res.render("error", { error: "Username cannot be the host's username" });
57+
}
5358
}
5459
else{
5560
res.status(404).render("error", { error: "Room doesn't exists" })

0 commit comments

Comments
 (0)