Skip to content

Commit

Permalink
Move action related code to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
delasy committed Nov 8, 2024
1 parent 3752bef commit fd92050
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
7 changes: 0 additions & 7 deletions convex/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
10 changes: 2 additions & 8 deletions convex/helpers.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
3 changes: 2 additions & 1 deletion convex/multiplayerGames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 6 additions & 0 deletions simulator/Action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum ActionType {
PlayerShoot = "player-shoot",
PlayerWalk = "player-walk",
ZombieSpawn = "zombie-spawn",
ZombieStep = "zombie-step",
}

0 comments on commit fd92050

Please sign in to comment.