@@ -9,7 +9,8 @@ import Layout from "./components/Layout.tsx";
99import HomePage from "./components/HomePage.tsx" ;
1010import AdminPage from "./components/AdminPage.tsx" ;
1111import TalmanPage from "./components/TalmanPage.tsx" ;
12- import cards from "./cards-SM.ts" ;
12+ import cardsVM from "./cards-VM.ts" ;
13+ import cardsSM from "./cards-SM.ts" ;
1314import { setupAdminSocket , setupPlayerSocket } from "./server/chat.ts" ;
1415import { handleUploadRequest } from "./server/upload.ts" ;
1516import { cookieSecret , DEV_MODE , loginRedirectUrl } from "./server/config.ts" ;
@@ -21,6 +22,9 @@ import {
2122} from "./server/auth.ts" ;
2223import { createSeededRandom } from "./server/random.ts" ;
2324
25+ // Global configuration state
26+ let currentCardSet : "VM" | "SM" = "SM" ; // Default to SM
27+
2428const smingoCss = Deno . readTextFileSync (
2529 new URL ( "./public/smingo.css" , import . meta. url ) ,
2630) ;
@@ -45,6 +49,25 @@ app.post("/api/upload", async (c: Context) => {
4549 return handleUploadRequest ( c ) ;
4650} ) ;
4751
52+ // API endpoints for card set management
53+ app . get ( "/api/cardset" , async ( c : Context ) => {
54+ const session = await ensureAdminSession ( c ) ;
55+ if ( session instanceof Response ) return session ;
56+ return c . json ( { cardSet : currentCardSet } ) ;
57+ } ) ;
58+
59+ app . post ( "/api/cardset" , async ( c : Context ) => {
60+ const session = await ensureAdminSession ( c ) ;
61+ if ( session instanceof Response ) return session ;
62+
63+ const body = await c . req . json ( ) ;
64+ if ( body . cardSet === "SM" || body . cardSet === "VM" ) {
65+ currentCardSet = body . cardSet ;
66+ return c . json ( { success : true , cardSet : currentCardSet } ) ;
67+ }
68+ return c . json ( { success : false , error : "Invalid card set" } , 400 ) ;
69+ } ) ;
70+
4871app . get ( "/assets/smingo.css" , ( ) =>
4972 new Response ( smingoCss , {
5073 headers : {
@@ -124,6 +147,7 @@ app.get("/callback/:code", async (c: Context) => {
124147} ) ;
125148
126149app . get ( "/" , async ( c : Context ) => {
150+ const cards = currentCardSet === "SM" ? cardsSM : cardsVM ;
127151 const things = cards . toSorted ( ) ;
128152
129153 const session = await ensurePlayerSession ( c ) ;
0 commit comments