diff --git a/src/controllers/game/game.ts b/src/controllers/game/game.ts index 0f62141..8b2cc1c 100644 --- a/src/controllers/game/game.ts +++ b/src/controllers/game/game.ts @@ -12,4 +12,12 @@ router.get("/player", (req: Request, res: Response) => { res.json(state.player); }); +router.get("/car", (req: Request, res: Response) => { + res.json(state.car); +}); + +router.get("/home", (req: Request, res: Response) => { + res.json(state.home); +}); + export default router; diff --git a/src/controllers/inventory/types.ts b/src/controllers/inventory/types.ts index e1f8218..0fafd9b 100644 --- a/src/controllers/inventory/types.ts +++ b/src/controllers/inventory/types.ts @@ -1,10 +1,12 @@ +import type { AllInventories } from "../../helpers.js"; + interface MoveParams { id: number; } interface MoveRequest { - source: "player" | "car" | "home"; - destination: "player" | "car" | "home" | "workbench"; + source: AllInventories; + destination: AllInventories; } export { type MoveParams, type MoveRequest }; diff --git a/src/controllers/state/state.ts b/src/controllers/state/state.ts index 5929788..0c2de07 100644 --- a/src/controllers/state/state.ts +++ b/src/controllers/state/state.ts @@ -7,6 +7,24 @@ import config from "../../config.json" with { type: "json" }; const router = Router(); +router.get("/stop", (req: Request, res: Response) => { + writeFile(config.savepath, JSON.stringify(game.state), "utf8", (err) => { + if (err) { + res.json({ + message: "error", + error: err.message, + }); + return; + } + + res.json({ + message: "ok", + }); + + process.exit(0); + }); +}); + router.get("/load", (req: Request, res: Response) => { readFile(config.savepath, "utf8", (err, data) => { if (err) { @@ -41,22 +59,4 @@ router.get("/save", (req: Request, res: Response) => { }); }); -router.get("/stop", (req: Request, res: Response) => { - writeFile(config.savepath, JSON.stringify(game.state), "utf8", (err) => { - if (err) { - res.json({ - message: "error", - error: err.message, - }); - return; - } - - res.json({ - message: "ok", - }); - - process.exit(0); - }); -}); - export default router; diff --git a/src/controllers/workbench/workbench.ts b/src/controllers/workbench/workbench.ts index 7da6ff4..6b437ce 100644 --- a/src/controllers/workbench/workbench.ts +++ b/src/controllers/workbench/workbench.ts @@ -12,6 +12,10 @@ import { const router = Router(); +router.get("/", (req: Request, res: Response) => { + res.json(state.home.workbench); +}); + router.get("/devices", (req: Request, res: Response) => { res.json(state.home.workbench.devices); }); diff --git a/src/services/workbench/workbench.ts b/src/services/workbench/workbench.ts index c13fd4a..00ccf98 100644 --- a/src/services/workbench/workbench.ts +++ b/src/services/workbench/workbench.ts @@ -3,7 +3,6 @@ import { GetItemContainerOfType, GetItemOfType, GetItemsAsInventory, - GetItemsOfType, GetWorkbenchAsInventory, } from "../../helpers.js"; import { ItemType, type ICase, type IMotherboard } from "../../state/item.js"; diff --git a/src/state/company.ts b/src/state/company.ts index 8435f26..cbbc706 100644 --- a/src/state/company.ts +++ b/src/state/company.ts @@ -1,4 +1,4 @@ -export enum Company { +enum Company { Intel, AMD, Nvidia, @@ -55,3 +55,5 @@ export enum Company { Fairphone, Razer, } + +export { Company }; diff --git a/src/state/connector.ts b/src/state/connector.ts index 4d5ad11..8e99612 100644 --- a/src/state/connector.ts +++ b/src/state/connector.ts @@ -1,4 +1,4 @@ -export enum ConnectorType { +enum ConnectorType { USB1, USB2, USB3, @@ -27,3 +27,5 @@ export enum ConnectorType { PCIE8, PCIE9, } + +export { ConnectorType }; diff --git a/src/state/cpu.ts b/src/state/cpu.ts index 9800940..375d9e2 100644 --- a/src/state/cpu.ts +++ b/src/state/cpu.ts @@ -1,4 +1,4 @@ -export enum CPUArchitecture { +enum CPUArchitecture { M_6502, M_6800, M_6809, @@ -19,14 +19,16 @@ export enum CPUArchitecture { LoongArch, } -export enum CPUFeatures { +enum CPUFeatures { AVX, AVX2, AVX512, } -export enum SocketType { +enum SocketType { INTEL_LGA_1155, INTEL_LGA_1156, INTEL_LGA_2011, } + +export { CPUArchitecture, CPUFeatures, SocketType }; diff --git a/src/state/gpu.ts b/src/state/gpu.ts index 1284636..44868fa 100644 --- a/src/state/gpu.ts +++ b/src/state/gpu.ts @@ -1,4 +1,4 @@ -export enum GPUArchitecture { +enum GPUArchitecture { Fahrenheit, Celsius, Kelvin, @@ -35,3 +35,5 @@ export enum GPUArchitecture { CDNA3, UDNA, } + +export { GPUArchitecture }; diff --git a/src/state/item.ts b/src/state/item.ts index 4206ff7..f3b2cb2 100644 --- a/src/state/item.ts +++ b/src/state/item.ts @@ -5,7 +5,7 @@ import type { MemoryType } from "./memory.js"; import type { DiscType, DiskType, IStorage } from "./storage.js"; import type { INet } from "./types.js"; -export enum ItemType { +enum ItemType { SCREWDRIVER, CPU, GRAPHIC_CARD, @@ -41,7 +41,7 @@ export enum ItemType { SECURITY_KEY, } -export enum FormFactorType { +enum FormFactorType { M_ATX, ATX, E_ATX, @@ -196,6 +196,8 @@ interface IModem extends IItem { } export { + ItemType, + FormFactorType, type IItem, type IConnectedDevice, type IScrewdriver, diff --git a/src/state/location.ts b/src/state/location.ts index 0d143a0..8a8d4bd 100644 --- a/src/state/location.ts +++ b/src/state/location.ts @@ -1,4 +1,7 @@ -export enum Location { +enum Location { PLAYER_HOME, + PLAYER_CAR, LOCAL_STORE, } + +export { Location }; diff --git a/src/state/memory.ts b/src/state/memory.ts index d1841a1..953d279 100644 --- a/src/state/memory.ts +++ b/src/state/memory.ts @@ -1,4 +1,4 @@ -export enum MemoryType { +enum MemoryType { DDR, LPDDR, LPDDRX, @@ -49,3 +49,5 @@ export enum MemoryType { HBM3, HBM4, } + +export { MemoryType }; diff --git a/src/state/motherboard.ts b/src/state/motherboard.ts index daf5886..d2ae0dc 100644 --- a/src/state/motherboard.ts +++ b/src/state/motherboard.ts @@ -1,4 +1,6 @@ -export enum MotherboardFeatures { +enum MotherboardFeatures { BIOS, UEFI, } + +export { MotherboardFeatures }; diff --git a/src/state/software.ts b/src/state/software.ts index e36e010..b8bbd9e 100644 --- a/src/state/software.ts +++ b/src/state/software.ts @@ -1,11 +1,13 @@ -export enum SoftwareType { +enum SoftwareType { OS, } -export interface ISoftware { +interface ISoftware { type: SoftwareType; name: string; cpuUsage: number; memoryUsage: number; storageUsage: number; } + +export { SoftwareType, type ISoftware };