Skip to content

Commit 3ea21fc

Browse files
committed
fixed lint and format error
1 parent bf13bd4 commit 3ea21fc

6 files changed

Lines changed: 27 additions & 31 deletions

File tree

src/client/puzzle/setup-puzzle.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useState } from "react";
2-
import { SetupBase } from "../setup/setup-base";
32
import { SelectPuzzle } from "./select-puzzle";
43
import { NonIdealState, Spinner } from "@blueprintjs/core";
54
import { get, useEffectQuery } from "../api";
@@ -29,10 +28,10 @@ export function SetupPuzzle() {
2928
}
3029

3130
return (
32-
<SelectPuzzle
33-
puzzles={data}
34-
selectedPuzzle={selectedPuzzle}
35-
onPuzzleSelected={setSelectedPuzzle}
36-
/>
31+
<SelectPuzzle
32+
puzzles={data}
33+
selectedPuzzle={selectedPuzzle}
34+
onPuzzleSelected={setSelectedPuzzle}
35+
/>
3736
);
3837
}

src/client/setup/setup-base.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function SetupBase(props: SetupBaseProps): JSX.Element {
4646
</div>
4747
</Dialog>
4848
</div>
49-
<Sidebar/>
49+
<Sidebar />
5050
</>
5151
);
5252
}

src/server/api/api.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,8 @@ export const websocketHandler: WebsocketRequestHandler = (ws, req) => {
248248
message instanceof GameEndMessage
249249
) {
250250
// TODO: Handle game manager not existing
251-
if(gameManager == null)
252-
{
253-
console.log("BRUHHH")
251+
if (gameManager === null) {
252+
console.log("BRUHHH");
254253
}
255254
await gameManager?.handleMessage(message, req.cookies.id);
256255
} else if (message instanceof DriveRobotMessage) {
@@ -260,9 +259,11 @@ export const websocketHandler: WebsocketRequestHandler = (ws, req) => {
260259
} else if (message instanceof JoinQueue) {
261260
console.log("So we got the join message");
262261
// this was initially !isPlayer, shouldn't it be isPlayer?
263-
if (pageString.indexOf("debug") == -1 && !clientManager.isPlayer(req.cookies.id)) {
264-
if (queue.find(req.cookies.id) === undefined)
265-
{
262+
if (
263+
pageString.indexOf("debug") === -1 &&
264+
!clientManager.isPlayer(req.cookies.id)
265+
) {
266+
if (queue.find(req.cookies.id) === undefined) {
266267
queue.insert(req.cookies.id, 0);
267268
}
268269
names.set(req.cookies.id, message.playerName);
@@ -379,7 +380,7 @@ apiRouter.get("/game-state", (req, res) => {
379380
* returns a success message
380381
*/
381382
apiRouter.post("/start-computer-game", async (req, res) => {
382-
console.log("start comp game")
383+
console.log("start comp game");
383384
canReloadQueue = true;
384385
const side = req.query.side as Side;
385386
const difficulty = parseInt(req.query.difficulty as string) as Difficulty;

src/server/api/client-manager.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class ClientManager {
4848
public sendToClient(message: Message): boolean {
4949
const sockets = this.getClientSocket();
5050
if (sockets !== undefined) {
51-
for(const socket of sockets) socket.send(message.toJson());
51+
for (const socket of sockets) socket.send(message.toJson());
5252
}
5353
return sockets !== undefined;
5454
}
@@ -61,10 +61,9 @@ export class ClientManager {
6161
public sendToSpectators(message: Message): boolean {
6262
if (this.spectatorIds.size !== 0) {
6363
for (const item of this.spectatorIds) {
64-
const potentialSocket = this.socketManager.getSockets(item)
65-
if (potentialSocket != null) {
66-
for (const socket of potentialSocket)
67-
{
64+
const potentialSocket = this.socketManager.getSockets(item);
65+
if (potentialSocket !== null && potentialSocket !== undefined) {
66+
for (const socket of potentialSocket) {
6867
socket.send(message.toJson());
6968
}
7069
}

src/server/api/game-manager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ export class HumanGameManager extends GameManager {
119119
* @param id - id of the sender
120120
*/
121121
public async handleMessage(message: Message, id: string): Promise<void> {
122-
console.log("handling message")
123-
122+
console.log("handling message");
123+
124124
// check which type the id is
125125
const clientType = this.clientManager.getClientType(id);
126126
let sendToPlayer: SendMessage;
@@ -150,7 +150,7 @@ export class HumanGameManager extends GameManager {
150150
const ids = this.clientManager.getIds();
151151
const currentSave = SaveManager.loadGame(id);
152152
// update the internal chess object if it is a move massage and game not paused
153-
console.log("up to here")
153+
console.log("up to here");
154154
if (message instanceof MoveMessage && !gamePaused) {
155155
// Call path materializer and send to bots
156156
const command = materializePath(message.move);

src/server/api/socket-manager.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import WebSocket from "ws";
1+
import type WebSocket from "ws";
22
import type { Message } from "../../common/message/message";
33

44
/**
@@ -8,9 +8,8 @@ export class SocketManager {
88
constructor(private sockets: Record<string, Set<WebSocket>>) {}
99

1010
public registerSocket(id: string, socket: WebSocket): void {
11-
if(this.sockets[id] == null)
12-
{
13-
this.sockets[id] = new Set<WebSocket>()
11+
if (this.sockets[id] === null) {
12+
this.sockets[id] = new Set<WebSocket>();
1413
}
1514
console.log(`Id is: ${id}`);
1615
this.sockets[id].add(socket);
@@ -20,7 +19,7 @@ export class SocketManager {
2019
* deletes the socket at the provided id
2120
* @param id - id to be deleted
2221
*/
23-
public handleSocketClosed(id: string, socket : WebSocket): void {
22+
public handleSocketClosed(id: string, socket: WebSocket): void {
2423
// find if the socket exists and is in the set for that user
2524
if (this.sockets[id] && this.sockets[id].has(socket)) {
2625
// if so, KILL IT!
@@ -59,10 +58,8 @@ export class SocketManager {
5958
public sendToAll(message: Message): boolean {
6059
const sockets = Object.values(this.sockets);
6160
console.log(`Current list of connections are: ${sockets.length}`);
62-
for (const socketSet of sockets)
63-
{
64-
for(const socket of socketSet )
65-
{
61+
for (const socketSet of sockets) {
62+
for (const socket of socketSet) {
6663
socket.send(message.toJson());
6764
}
6865
}

0 commit comments

Comments
 (0)