Prod hardening: one-game-per-player, selectable music, bargevasat.ir config
- One running game per player: server rejects a 2nd matchmake while in a live room (re-syncs the existing game); client guards Home vs-computer + Lobby random/create — resumes the running match + notifies instead of starting another (game-store hasActiveMatch()). - Background music is now selectable: santoor (سنتی, calm Persian loop) and playful (bouncy UNO-like) — sound.ts TRACKS + setMusicTrack (persisted), sound-store musicTrack, picker in Profile → Audio. i18n added. - Production config for bargevasat.ir (prepare-only; no live deploy): appsettings.Production.example (CORS + ZarinPal + IAB to the domain), docker-compose.caddy.yml + Caddyfile (auto-HTTPS reverse proxy bargevasat.ir→web, api.bargevasat.ir→server), ENV_FILE PRODUCTION block, PRODUCTION.md go-live + Cafe Bazaar publish/IAB checklist. Fixed IAB package name to match Capacitor appId (com.bargevasat.app). Verified: tsc + next build + dotnet build all pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -9,9 +9,27 @@ import { MATCH_LEAGUES, leagueById } from "@/lib/online/gamification";
|
||||
import { useOnlineStore } from "@/lib/online-store";
|
||||
import { useSessionStore } from "@/lib/session-store";
|
||||
import { useUIStore } from "@/lib/ui-store";
|
||||
import { useGameStore, hasActiveMatch } from "@/lib/game-store";
|
||||
import { pushNotification } from "@/lib/notification-store";
|
||||
import { useI18n } from "@/lib/i18n";
|
||||
import { cn } from "@/lib/cn";
|
||||
|
||||
/** Block starting a 2nd game while one is running — resume it instead. */
|
||||
function guardActiveMatch(): boolean {
|
||||
if (!hasActiveMatch()) return false;
|
||||
useGameStore.getState().resume();
|
||||
useUIStore.getState().goGame("online");
|
||||
pushNotification({
|
||||
kind: "system",
|
||||
titleFa: "بازی در جریان",
|
||||
titleEn: "Game in progress",
|
||||
bodyFa: "ابتدا بازی فعلی را تمام کنید یا تسلیم شوید.",
|
||||
bodyEn: "Finish or forfeit your current game first.",
|
||||
icon: "🎮",
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
export function OnlineLobbyScreen() {
|
||||
const { t, locale } = useI18n();
|
||||
const createRoom = useOnlineStore((s) => s.createRoom);
|
||||
@@ -27,12 +45,14 @@ export function OnlineLobbyScreen() {
|
||||
|
||||
// Private rooms with friends are free.
|
||||
const onCreate = async () => {
|
||||
if (guardActiveMatch()) return;
|
||||
await createRoom({ targetScore: 7, stake: 0, ranked: false });
|
||||
go("room");
|
||||
};
|
||||
|
||||
// Ranked random always costs the entry (you stake it).
|
||||
const onRandom = async () => {
|
||||
if (guardActiveMatch()) return;
|
||||
if (lockedLeague) return;
|
||||
if (coins < entry) {
|
||||
go("buycoins");
|
||||
|
||||
@@ -469,12 +469,34 @@ function SocialSettings() {
|
||||
|
||||
function SoundSettings() {
|
||||
const { t } = useI18n();
|
||||
const { sfx, music, toggleSfx, toggleMusic } = useSoundStore();
|
||||
const { sfx, music, musicTrack, toggleSfx, toggleMusic, setMusicTrack } = useSoundStore();
|
||||
const tracks = [
|
||||
{ id: "santoor" as const, label: t("settings.trackSantoor") },
|
||||
{ id: "playful" as const, label: t("settings.trackPlayful") },
|
||||
];
|
||||
return (
|
||||
<div className="glass rounded-2xl p-4 mt-4">
|
||||
<h3 className="text-sm font-bold text-cream/80 mb-2">{t("settings.audio")}</h3>
|
||||
<ToggleRow icon={<Volume2 className="size-4 text-gold-400" />} label={t("settings.sound")} on={sfx} onClick={toggleSfx} />
|
||||
<ToggleRow icon={<Music className="size-4 text-gold-400" />} label={t("settings.music")} on={music} onClick={toggleMusic} />
|
||||
{/* music style picker */}
|
||||
<div className="mt-3">
|
||||
<div className="text-[11px] text-cream/55 mb-1.5">{t("settings.musicStyle")}</div>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{tracks.map((tr) => (
|
||||
<button
|
||||
key={tr.id}
|
||||
onClick={() => setMusicTrack(tr.id)}
|
||||
className={cn(
|
||||
"press-3d rounded-xl py-2.5 text-sm font-bold",
|
||||
musicTrack === tr.id ? "btn-gold" : "bg-navy-900/70 gold-border text-cream/70"
|
||||
)}
|
||||
>
|
||||
{tr.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user