diff --git a/convex/constants.ts b/convex/constants.ts index d1ff30d..7595257 100644 --- a/convex/constants.ts +++ b/convex/constants.ts @@ -21,13 +21,6 @@ export const AI_MODELS = { }, } as const; -export enum ActionType { - PlayerShoot = "player-shoot", - PlayerWalk = "player-walk", - ZombieSpawn = "zombie-spawn", - ZombieStep = "zombie-step", -} - export type ModelSlug = (typeof AI_MODELS)[keyof typeof AI_MODELS]["slug"]; export const AI_MODEL_SLUGS = Object.keys(AI_MODELS) as ModelSlug[]; diff --git a/convex/helpers.ts b/convex/helpers.ts index bbca6c2..78fb0fa 100644 --- a/convex/helpers.ts +++ b/convex/helpers.ts @@ -1,14 +1,8 @@ import { v } from "convex/values"; -import { ActionType } from "./constants"; +import { ActionType } from "@/simulator/Action"; export const multiplayerGameActionValidator = v.object({ - // type: v.union(...Object.values(ActionType).map((t) => v.literal(t))), - type: v.union( - v.literal("player-shoot"), - v.literal("player-walk"), - v.literal("zombie-spawn"), - v.literal("zombie-step"), - ), + type: v.union(...Object.values(ActionType).map((t) => v.literal(t))), token: v.string(), position: v.optional( v.object({ diff --git a/convex/multiplayerGames.ts b/convex/multiplayerGames.ts index d16f488..173c701 100644 --- a/convex/multiplayerGames.ts +++ b/convex/multiplayerGames.ts @@ -9,8 +9,9 @@ import { type Infer, v } from "convex/values"; import { api, internal } from "./_generated/api"; import { Doc } from "./_generated/dataModel"; import { internalAction, internalMutation, query } from "./_generated/server"; -import { ActionType, ModelSlug } from "./constants"; +import { ModelSlug } from "./constants"; import { multiplayerGameActionValidator } from "./helpers"; +import { ActionType } from "@/simulator/Action"; const TURN_DELAY = 500; diff --git a/simulator/Action.ts b/simulator/Action.ts new file mode 100644 index 0000000..685f9c4 --- /dev/null +++ b/simulator/Action.ts @@ -0,0 +1,6 @@ +export enum ActionType { + PlayerShoot = "player-shoot", + PlayerWalk = "player-walk", + ZombieSpawn = "zombie-spawn", + ZombieStep = "zombie-step", +}