Build Hokm card game: offline vs-AI + online social/gamification (mock backend)

- Pure-TS Hokm engine (deal, hakem, trump, tricks, scoring, Kot) + AI bots
- Persian-luxury RTL UI (Next 16 / React 19 / Tailwind v4 / Framer Motion / Zustand)
- Online platform behind OnlineService seam (mock now, .NET SignalR later):
  auth (phone OTP + email/Google), profiles, friends, private rooms with
  partner pick, ranked matchmaking, leaderboard, shop
- Gamification: ranks/leagues, coins, XP/levels, daily rewards, achievements
- i18n fa/en, PWA manifest, engine + gamification sims

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-04 10:11:00 +03:30
parent dff1a34f95
commit e2d0a602b6
41 changed files with 5766 additions and 93 deletions
+87
View File
@@ -0,0 +1,87 @@
"use client";
import { create } from "zustand";
import { getService } from "./online/service";
import { AuthSession, UserProfile } from "./online/types";
interface SessionStore {
session: AuthSession | null;
profile: UserProfile | null;
loading: boolean;
isAuthed: boolean;
init: () => Promise<void>;
refreshProfile: () => Promise<void>;
setProfile: (p: UserProfile) => void;
requestOtp: (phone: string) => Promise<{ devCode?: string }>;
verifyOtp: (phone: string, code: string) => Promise<void>;
signInEmail: (email: string, password: string) => Promise<void>;
signUpEmail: (email: string, password: string, name: string) => Promise<void>;
signInGoogle: () => Promise<void>;
signOut: () => Promise<void>;
updateProfile: (patch: Partial<Pick<UserProfile, "displayName" | "avatar">>) => Promise<void>;
}
export const useSessionStore = create<SessionStore>((set, get) => ({
session: null,
profile: null,
loading: true,
isAuthed: false,
init: async () => {
const svc = getService();
const restored = await svc.restore();
if (restored) {
set({ session: restored.session, profile: restored.profile, isAuthed: true, loading: false });
} else {
// ensure a (guest) profile exists so the top bar can render
const profile = await svc.getProfile();
set({ profile, isAuthed: false, loading: false });
}
},
refreshProfile: async () => {
const profile = await getService().getProfile();
set({ profile });
},
setProfile: (p) => set({ profile: p }),
requestOtp: (phone) => getService().requestOtp(phone),
verifyOtp: async (phone, code) => {
const session = await getService().verifyOtp(phone, code);
const profile = await getService().getProfile();
set({ session, profile, isAuthed: true });
},
signInEmail: async (email, password) => {
const session = await getService().signInEmail(email, password);
const profile = await getService().getProfile();
set({ session, profile, isAuthed: true });
},
signUpEmail: async (email, password, name) => {
const session = await getService().signUpEmail(email, password, name);
const profile = await getService().getProfile();
set({ session, profile, isAuthed: true });
},
signInGoogle: async () => {
const session = await getService().signInGoogle();
const profile = await getService().getProfile();
set({ session, profile, isAuthed: true });
},
signOut: async () => {
await getService().signOut();
set({ session: null, isAuthed: false });
},
updateProfile: async (patch) => {
const profile = await getService().updateProfile(patch);
set({ profile });
},
}));