|
|
|
@ -2,13 +2,13 @@ import type { Request, Response } from "express"; |
|
|
|
|
import { rewriteQueryParamsWith, safeGetQueryValue } from "../utils.ts"; |
|
|
|
|
import { BoardgameState } from "../../shared/boardgame-state.ts"; |
|
|
|
|
import { getBoardgameHtml } from "../components/boardgame.tsx"; |
|
|
|
|
import { gamesRules } from "../../shared/rules.ts"; |
|
|
|
|
import { GameVariantName, gamesRules } from "../../shared/rules.ts"; |
|
|
|
|
import { getTargetGameState } from "../../shared/boardgame.ts"; |
|
|
|
|
|
|
|
|
|
// Returns nothing if query parameter is uninitialized and a redirect was made,
|
|
|
|
|
// or component if query parameter is initialized.
|
|
|
|
|
export const handleBoardgame = (req: Request, res: Response, key: string) => { |
|
|
|
|
const rules = gamesRules.tictactoe; |
|
|
|
|
export const handleBoardgame = (req: Request, res: Response, key: string, gameVariant: GameVariantName) => { |
|
|
|
|
const rules = gamesRules[gameVariant]; |
|
|
|
|
|
|
|
|
|
const serializedState = safeGetQueryValue(req, key); |
|
|
|
|
const inputState = BoardgameState.fromSerialized(serializedState); |
|
|
|
@ -19,5 +19,5 @@ export const handleBoardgame = (req: Request, res: Response, key: string) => { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return getBoardgameHtml(key, state, rules); |
|
|
|
|
return getBoardgameHtml(key, state, gameVariant); |
|
|
|
|
}; |
|
|
|
|