Skip to content

Commit

Permalink
Enable prettier locally
Browse files Browse the repository at this point in the history
  • Loading branch information
neu5 committed Sep 19, 2023
1 parent 2df761d commit 95cb511
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
6 changes: 2 additions & 4 deletions packages/server/src/scene/scene.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { Body, Plane, Vec3, World } from "cannon-es";
import type {
Actions,
} from "@neu5/types/src";
import type { Actions } from "@neu5/types/src";
import { addRigidVehicle, getMapWalls } from "../utils";

import type { Game } from "../index";
import type { Room } from "../room";
import type { InMemorySessionStore } from "../sessionStore";

const FRAME_IN_MS = 1000 / 30; // 30 FPS
let loop = setInterval(() => { }, FRAME_IN_MS);
let loop = setInterval(() => {}, FRAME_IN_MS);

const ACCELERATE = "accelerate";
const BRAKE = "brake";
Expand Down
28 changes: 19 additions & 9 deletions packages/server/src/sockets/sockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ACTIONS = {
[ACCELERATE]: ACCELERATE,
[BRAKE]: BRAKE,
[LEFT]: LEFT,
[RIGHT]: RIGHT
[RIGHT]: RIGHT,
};

let raceLoop: NodeJS.Timer | null = null;
Expand Down Expand Up @@ -69,11 +69,11 @@ const playersMapToArray = (list: PlayersList) =>
userID,
...(vehicle
? {
vehicle: {
body: vehicle?.body,
wheels: vehicle?.wheels,
},
}
vehicle: {
body: vehicle?.body,
wheels: vehicle?.wheels,
},
}
: undefined),
}));

Expand Down Expand Up @@ -176,7 +176,13 @@ const createSocketHandlers = ({

socket.on(
"client:action",
({ playerActions, id }: { playerActions: Array<ActionTypes>; id: string }) => {
({
playerActions,
id,
}: {
playerActions: Array<ActionTypes>;
id: string;
}) => {
if (playersMap === null) {
return;
}
Expand Down Expand Up @@ -208,7 +214,9 @@ const createSocketHandlers = ({

socket.on("client:join race room", async () => {
if (game.race.isStarted) {
socket.emit("server:show error", { message: "The race is already going on! You can't join the room now." });
socket.emit("server:show error", {
message: "The race is already going on! You can't join the room now.",
});
return;
}

Expand All @@ -231,7 +239,9 @@ const createSocketHandlers = ({

socket.on("client:start the race", async () => {
if (game.race.isStarted) {
socket.emit("server:show error", { message: "The race is already going on!" });
socket.emit("server:show error", {
message: "The race is already going on!",
});
return;
}

Expand Down

0 comments on commit 95cb511

Please sign in to comment.