feat(multi): add configurable time limit per round with countdown display
This commit is contained in:
@@ -14,6 +14,7 @@ function dbToRoom(row: {
|
|||||||
maxPlayers: number;
|
maxPlayers: number;
|
||||||
gameMode: string;
|
gameMode: string;
|
||||||
searchAllowed: boolean;
|
searchAllowed: boolean;
|
||||||
|
timeLimit: number;
|
||||||
startArticle: string;
|
startArticle: string;
|
||||||
targetArticle: string;
|
targetArticle: string;
|
||||||
roundWinner: string | null;
|
roundWinner: string | null;
|
||||||
@@ -30,6 +31,7 @@ function dbToRoom(row: {
|
|||||||
maxPlayers: row.maxPlayers,
|
maxPlayers: row.maxPlayers,
|
||||||
gameMode: (row.gameMode ?? "race") as Room["gameMode"],
|
gameMode: (row.gameMode ?? "race") as Room["gameMode"],
|
||||||
searchAllowed: row.searchAllowed ?? false,
|
searchAllowed: row.searchAllowed ?? false,
|
||||||
|
timeLimit: row.timeLimit ?? 0,
|
||||||
startArticle: row.startArticle,
|
startArticle: row.startArticle,
|
||||||
targetArticle: row.targetArticle,
|
targetArticle: row.targetArticle,
|
||||||
roundWinner: row.roundWinner,
|
roundWinner: row.roundWinner,
|
||||||
@@ -332,6 +334,41 @@ export async function PATCH(
|
|||||||
return Response.json({ room });
|
return Response.json({ room });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hôte change la limite de temps
|
||||||
|
case "setTimeLimit": {
|
||||||
|
const host = room.players.find((p) => p.id === playerId);
|
||||||
|
if (!host?.isHost) {
|
||||||
|
return Response.json({ error: "Seul l'hôte peut modifier ce paramètre" }, { status: 403 });
|
||||||
|
}
|
||||||
|
room.timeLimit = typeof value === "number" ? Math.max(0, Math.floor(value)) : 0;
|
||||||
|
await saveRoom(room);
|
||||||
|
return Response.json({ room });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fin du temps imparti — déclenché par le client qui détecte l'expiration
|
||||||
|
case "timeUp": {
|
||||||
|
if (room.phase !== "playing") {
|
||||||
|
return Response.json({ room });
|
||||||
|
}
|
||||||
|
if (!room.timeLimit || !room.roundStart) {
|
||||||
|
return Response.json({ room });
|
||||||
|
}
|
||||||
|
const elapsed = Date.now() - room.roundStart;
|
||||||
|
if (elapsed < room.timeLimit * 1000 - 1000) {
|
||||||
|
// Pas encore expiré (tolérance 1s pour le lag réseau)
|
||||||
|
return Response.json({ room });
|
||||||
|
}
|
||||||
|
// Marquer les non-finis comme abandonnés
|
||||||
|
for (const p of room.players) {
|
||||||
|
if (!p.hasWon && !p.hasSurrendered) {
|
||||||
|
p.hasSurrendered = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assignAllFinishPoints(room); // attribue les points aux gagnants selon l'ordre
|
||||||
|
await saveRoom(room);
|
||||||
|
return Response.json({ room });
|
||||||
|
}
|
||||||
|
|
||||||
// Manche suivante / rejouer
|
// Manche suivante / rejouer
|
||||||
case "nextRound": {
|
case "nextRound": {
|
||||||
const host = room.players.find((p) => p.id === playerId);
|
const host = room.players.find((p) => p.id === playerId);
|
||||||
@@ -394,6 +431,7 @@ async function saveRoom(room: Room) {
|
|||||||
maxPlayers: room.maxPlayers,
|
maxPlayers: room.maxPlayers,
|
||||||
gameMode: room.gameMode,
|
gameMode: room.gameMode,
|
||||||
searchAllowed: room.searchAllowed,
|
searchAllowed: room.searchAllowed,
|
||||||
|
timeLimit: room.timeLimit,
|
||||||
startArticle: room.startArticle,
|
startArticle: room.startArticle,
|
||||||
targetArticle: room.targetArticle,
|
targetArticle: room.targetArticle,
|
||||||
roundWinner: room.roundWinner,
|
roundWinner: room.roundWinner,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export type Room = {
|
|||||||
maxPlayers: number;
|
maxPlayers: number;
|
||||||
gameMode: "race" | "all_finish"; // race = 1er gagne, all_finish = tout le monde joue
|
gameMode: "race" | "all_finish"; // race = 1er gagne, all_finish = tout le monde joue
|
||||||
searchAllowed: boolean;
|
searchAllowed: boolean;
|
||||||
|
timeLimit: number; // secondes par manche, 0 = illimité
|
||||||
startArticle: string;
|
startArticle: string;
|
||||||
targetArticle: string;
|
targetArticle: string;
|
||||||
roundWinner: string | null;
|
roundWinner: string | null;
|
||||||
@@ -59,6 +60,7 @@ function dbToRoom(row: {
|
|||||||
maxPlayers: number;
|
maxPlayers: number;
|
||||||
gameMode: string;
|
gameMode: string;
|
||||||
searchAllowed: boolean;
|
searchAllowed: boolean;
|
||||||
|
timeLimit: number;
|
||||||
startArticle: string;
|
startArticle: string;
|
||||||
targetArticle: string;
|
targetArticle: string;
|
||||||
roundWinner: string | null;
|
roundWinner: string | null;
|
||||||
@@ -75,6 +77,7 @@ function dbToRoom(row: {
|
|||||||
maxPlayers: row.maxPlayers,
|
maxPlayers: row.maxPlayers,
|
||||||
gameMode: (row.gameMode ?? "race") as Room["gameMode"],
|
gameMode: (row.gameMode ?? "race") as Room["gameMode"],
|
||||||
searchAllowed: row.searchAllowed ?? false,
|
searchAllowed: row.searchAllowed ?? false,
|
||||||
|
timeLimit: row.timeLimit ?? 0,
|
||||||
startArticle: row.startArticle,
|
startArticle: row.startArticle,
|
||||||
targetArticle: row.targetArticle,
|
targetArticle: row.targetArticle,
|
||||||
roundWinner: row.roundWinner,
|
roundWinner: row.roundWinner,
|
||||||
@@ -95,11 +98,12 @@ async function pruneOldRooms() {
|
|||||||
// Response: { room: Room, playerId: string }
|
// Response: { room: Room, playerId: string }
|
||||||
export async function POST(request: NextRequest) {
|
export async function POST(request: NextRequest) {
|
||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
const { playerName, maxPlayers, totalRounds, gameMode } = body as {
|
const { playerName, maxPlayers, totalRounds, gameMode, timeLimit } = body as {
|
||||||
playerName: string;
|
playerName: string;
|
||||||
maxPlayers?: number;
|
maxPlayers?: number;
|
||||||
totalRounds?: number;
|
totalRounds?: number;
|
||||||
gameMode?: string;
|
gameMode?: string;
|
||||||
|
timeLimit?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -135,6 +139,7 @@ export async function POST(request: NextRequest) {
|
|||||||
const now = BigInt(Date.now());
|
const now = BigInt(Date.now());
|
||||||
|
|
||||||
const clampedMode: Room["gameMode"] = gameMode === "all_finish" ? "all_finish" : "race";
|
const clampedMode: Room["gameMode"] = gameMode === "all_finish" ? "all_finish" : "race";
|
||||||
|
const clampedTime = typeof timeLimit === "number" ? Math.max(0, Math.floor(timeLimit)) : 0;
|
||||||
|
|
||||||
const players: Player[] = [
|
const players: Player[] = [
|
||||||
{
|
{
|
||||||
@@ -160,6 +165,7 @@ export async function POST(request: NextRequest) {
|
|||||||
maxPlayers: clampedMax,
|
maxPlayers: clampedMax,
|
||||||
gameMode: clampedMode,
|
gameMode: clampedMode,
|
||||||
searchAllowed: false,
|
searchAllowed: false,
|
||||||
|
timeLimit: clampedTime,
|
||||||
startArticle: "",
|
startArticle: "",
|
||||||
targetArticle: "",
|
targetArticle: "",
|
||||||
roundWinner: null,
|
roundWinner: null,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ type GameScreenProps = {
|
|||||||
clicks: number;
|
clicks: number;
|
||||||
elapsed: string;
|
elapsed: string;
|
||||||
countdown: number | null;
|
countdown: number | null;
|
||||||
|
timeLeft: number | null;
|
||||||
onNavigate: (title: string) => void;
|
onNavigate: (title: string) => void;
|
||||||
onGoBack: () => void;
|
onGoBack: () => void;
|
||||||
canGoBack: boolean;
|
canGoBack: boolean;
|
||||||
@@ -37,6 +38,7 @@ export function GameScreen({
|
|||||||
clicks,
|
clicks,
|
||||||
elapsed,
|
elapsed,
|
||||||
countdown,
|
countdown,
|
||||||
|
timeLeft,
|
||||||
onNavigate,
|
onNavigate,
|
||||||
onGoBack,
|
onGoBack,
|
||||||
canGoBack,
|
canGoBack,
|
||||||
@@ -261,10 +263,15 @@ export function GameScreen({
|
|||||||
<Breadcrumbs history={history} endRef={breadcrumbEndRef} />
|
<Breadcrumbs history={history} endRef={breadcrumbEndRef} />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2 sm:gap-3 shrink-0">
|
<div className="flex items-center gap-2 sm:gap-3 shrink-0">
|
||||||
<div className="flex items-center gap-2 sm:gap-3 text-[10px] sm:text-xs font-bold text-[#888] tabular-nums">
|
<div className="flex items-center gap-2 sm:gap-3 text-[10px] sm:text-xs font-bold tabular-nums">
|
||||||
<span>{elapsed}</span>
|
{timeLeft !== null && (
|
||||||
<span>{clicks} clics</span>
|
<span className={`font-black ${timeLeft <= 10 ? "text-red-400 animate-pulse" : timeLeft <= 30 ? "text-orange-400" : "text-[#888]"}`}>
|
||||||
<span className="hidden sm:inline">{myPlayer?.score ?? 0} pts</span>
|
{timeLeft}s
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<span className="text-[#888]">{elapsed}</span>
|
||||||
|
<span className="text-[#888]">{clicks} clics</span>
|
||||||
|
<span className="hidden sm:inline text-[#888]">{myPlayer?.score ?? 0} pts</span>
|
||||||
</div>
|
</div>
|
||||||
{!myFinished && canGoBack && (
|
{!myFinished && canGoBack && (
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ type LobbyScreenProps = {
|
|||||||
gameMode: Room["gameMode"];
|
gameMode: Room["gameMode"];
|
||||||
setGameMode: (v: Room["gameMode"]) => void;
|
setGameMode: (v: Room["gameMode"]) => void;
|
||||||
onSetSearchAllowed: (v: boolean) => void;
|
onSetSearchAllowed: (v: boolean) => void;
|
||||||
|
onSetTimeLimit: (v: number) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function LobbyScreen({
|
export function LobbyScreen({
|
||||||
@@ -37,6 +38,7 @@ export function LobbyScreen({
|
|||||||
gameMode,
|
gameMode,
|
||||||
setGameMode,
|
setGameMode,
|
||||||
onSetSearchAllowed,
|
onSetSearchAllowed,
|
||||||
|
onSetTimeLimit,
|
||||||
}: LobbyScreenProps) {
|
}: LobbyScreenProps) {
|
||||||
const isHost = room.players.find((p) => p.id === playerId)?.isHost ?? false;
|
const isHost = room.players.find((p) => p.id === playerId)?.isHost ?? false;
|
||||||
const [copied, setCopied] = useState(false);
|
const [copied, setCopied] = useState(false);
|
||||||
@@ -188,6 +190,21 @@ export function LobbyScreen({
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex flex-col gap-1.5">
|
||||||
|
<span className="text-xs text-[#888]">Temps par manche</span>
|
||||||
|
<select
|
||||||
|
value={room.timeLimit}
|
||||||
|
onChange={(e) => onSetTimeLimit(Number(e.target.value))}
|
||||||
|
className="w-full min-h-11 px-2 bg-[#0f0f0f] border border-[#2e2e2e] rounded-xl text-sm text-[#f0f0f0] outline-none focus:border-[#7c3aed] cursor-pointer transition-colors"
|
||||||
|
>
|
||||||
|
<option value={0}>Illimité</option>
|
||||||
|
{[60, 120, 180, 300, 600].map((s) => (
|
||||||
|
<option key={s} value={s}>
|
||||||
|
{s < 60 ? `${s}s` : `${s / 60} min`}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<button
|
<button
|
||||||
onClick={() => onSetSearchAllowed(!room.searchAllowed)}
|
onClick={() => onSetSearchAllowed(!room.searchAllowed)}
|
||||||
className={`w-full min-h-11 rounded-xl text-sm font-semibold border transition-colors cursor-pointer flex items-center justify-between px-4 ${room.searchAllowed ? "bg-[#7c3aed]/10 border-[#7c3aed] text-[#a78bfa]" : "bg-[#1a1a1a] border-[#2e2e2e] text-[#888]"}`}
|
className={`w-full min-h-11 rounded-xl text-sm font-semibold border transition-colors cursor-pointer flex items-center justify-between px-4 ${room.searchAllowed ? "bg-[#7c3aed]/10 border-[#7c3aed] text-[#a78bfa]" : "bg-[#1a1a1a] border-[#2e2e2e] text-[#888]"}`}
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ export function ScreenRouter({
|
|||||||
gameMode={gameMode}
|
gameMode={gameMode}
|
||||||
setGameMode={setGameMode}
|
setGameMode={setGameMode}
|
||||||
onSetSearchAllowed={(v) => multi.setSearchAllowed(v)}
|
onSetSearchAllowed={(v) => multi.setSearchAllowed(v)}
|
||||||
|
onSetTimeLimit={(v) => multi.setTimeLimit(v)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -175,6 +176,7 @@ export function ScreenRouter({
|
|||||||
clicks={multi.clicks}
|
clicks={multi.clicks}
|
||||||
elapsed={fmt(multi.elapsed)}
|
elapsed={fmt(multi.elapsed)}
|
||||||
countdown={multi.countdown}
|
countdown={multi.countdown}
|
||||||
|
timeLeft={multi.timeLeft}
|
||||||
onNavigate={multi.navigate}
|
onNavigate={multi.navigate}
|
||||||
onGoBack={multi.goBack}
|
onGoBack={multi.goBack}
|
||||||
canGoBack={multi.canGoBack}
|
canGoBack={multi.canGoBack}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -864,6 +864,7 @@ export const RoomScalarFieldEnum = {
|
|||||||
maxPlayers: 'maxPlayers',
|
maxPlayers: 'maxPlayers',
|
||||||
gameMode: 'gameMode',
|
gameMode: 'gameMode',
|
||||||
searchAllowed: 'searchAllowed',
|
searchAllowed: 'searchAllowed',
|
||||||
|
timeLimit: 'timeLimit',
|
||||||
startArticle: 'startArticle',
|
startArticle: 'startArticle',
|
||||||
targetArticle: 'targetArticle',
|
targetArticle: 'targetArticle',
|
||||||
roundWinner: 'roundWinner',
|
roundWinner: 'roundWinner',
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ export const RoomScalarFieldEnum = {
|
|||||||
maxPlayers: 'maxPlayers',
|
maxPlayers: 'maxPlayers',
|
||||||
gameMode: 'gameMode',
|
gameMode: 'gameMode',
|
||||||
searchAllowed: 'searchAllowed',
|
searchAllowed: 'searchAllowed',
|
||||||
|
timeLimit: 'timeLimit',
|
||||||
startArticle: 'startArticle',
|
startArticle: 'startArticle',
|
||||||
targetArticle: 'targetArticle',
|
targetArticle: 'targetArticle',
|
||||||
roundWinner: 'roundWinner',
|
roundWinner: 'roundWinner',
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export type RoomAvgAggregateOutputType = {
|
|||||||
round: number | null
|
round: number | null
|
||||||
totalRounds: number | null
|
totalRounds: number | null
|
||||||
maxPlayers: number | null
|
maxPlayers: number | null
|
||||||
|
timeLimit: number | null
|
||||||
countdownStart: number | null
|
countdownStart: number | null
|
||||||
roundStart: number | null
|
roundStart: number | null
|
||||||
createdAt: number | null
|
createdAt: number | null
|
||||||
@@ -39,6 +40,7 @@ export type RoomSumAggregateOutputType = {
|
|||||||
round: number | null
|
round: number | null
|
||||||
totalRounds: number | null
|
totalRounds: number | null
|
||||||
maxPlayers: number | null
|
maxPlayers: number | null
|
||||||
|
timeLimit: number | null
|
||||||
countdownStart: bigint | null
|
countdownStart: bigint | null
|
||||||
roundStart: bigint | null
|
roundStart: bigint | null
|
||||||
createdAt: bigint | null
|
createdAt: bigint | null
|
||||||
@@ -52,6 +54,7 @@ export type RoomMinAggregateOutputType = {
|
|||||||
maxPlayers: number | null
|
maxPlayers: number | null
|
||||||
gameMode: string | null
|
gameMode: string | null
|
||||||
searchAllowed: boolean | null
|
searchAllowed: boolean | null
|
||||||
|
timeLimit: number | null
|
||||||
startArticle: string | null
|
startArticle: string | null
|
||||||
targetArticle: string | null
|
targetArticle: string | null
|
||||||
roundWinner: string | null
|
roundWinner: string | null
|
||||||
@@ -69,6 +72,7 @@ export type RoomMaxAggregateOutputType = {
|
|||||||
maxPlayers: number | null
|
maxPlayers: number | null
|
||||||
gameMode: string | null
|
gameMode: string | null
|
||||||
searchAllowed: boolean | null
|
searchAllowed: boolean | null
|
||||||
|
timeLimit: number | null
|
||||||
startArticle: string | null
|
startArticle: string | null
|
||||||
targetArticle: string | null
|
targetArticle: string | null
|
||||||
roundWinner: string | null
|
roundWinner: string | null
|
||||||
@@ -87,6 +91,7 @@ export type RoomCountAggregateOutputType = {
|
|||||||
maxPlayers: number
|
maxPlayers: number
|
||||||
gameMode: number
|
gameMode: number
|
||||||
searchAllowed: number
|
searchAllowed: number
|
||||||
|
timeLimit: number
|
||||||
startArticle: number
|
startArticle: number
|
||||||
targetArticle: number
|
targetArticle: number
|
||||||
roundWinner: number
|
roundWinner: number
|
||||||
@@ -102,6 +107,7 @@ export type RoomAvgAggregateInputType = {
|
|||||||
round?: true
|
round?: true
|
||||||
totalRounds?: true
|
totalRounds?: true
|
||||||
maxPlayers?: true
|
maxPlayers?: true
|
||||||
|
timeLimit?: true
|
||||||
countdownStart?: true
|
countdownStart?: true
|
||||||
roundStart?: true
|
roundStart?: true
|
||||||
createdAt?: true
|
createdAt?: true
|
||||||
@@ -111,6 +117,7 @@ export type RoomSumAggregateInputType = {
|
|||||||
round?: true
|
round?: true
|
||||||
totalRounds?: true
|
totalRounds?: true
|
||||||
maxPlayers?: true
|
maxPlayers?: true
|
||||||
|
timeLimit?: true
|
||||||
countdownStart?: true
|
countdownStart?: true
|
||||||
roundStart?: true
|
roundStart?: true
|
||||||
createdAt?: true
|
createdAt?: true
|
||||||
@@ -124,6 +131,7 @@ export type RoomMinAggregateInputType = {
|
|||||||
maxPlayers?: true
|
maxPlayers?: true
|
||||||
gameMode?: true
|
gameMode?: true
|
||||||
searchAllowed?: true
|
searchAllowed?: true
|
||||||
|
timeLimit?: true
|
||||||
startArticle?: true
|
startArticle?: true
|
||||||
targetArticle?: true
|
targetArticle?: true
|
||||||
roundWinner?: true
|
roundWinner?: true
|
||||||
@@ -141,6 +149,7 @@ export type RoomMaxAggregateInputType = {
|
|||||||
maxPlayers?: true
|
maxPlayers?: true
|
||||||
gameMode?: true
|
gameMode?: true
|
||||||
searchAllowed?: true
|
searchAllowed?: true
|
||||||
|
timeLimit?: true
|
||||||
startArticle?: true
|
startArticle?: true
|
||||||
targetArticle?: true
|
targetArticle?: true
|
||||||
roundWinner?: true
|
roundWinner?: true
|
||||||
@@ -159,6 +168,7 @@ export type RoomCountAggregateInputType = {
|
|||||||
maxPlayers?: true
|
maxPlayers?: true
|
||||||
gameMode?: true
|
gameMode?: true
|
||||||
searchAllowed?: true
|
searchAllowed?: true
|
||||||
|
timeLimit?: true
|
||||||
startArticle?: true
|
startArticle?: true
|
||||||
targetArticle?: true
|
targetArticle?: true
|
||||||
roundWinner?: true
|
roundWinner?: true
|
||||||
@@ -264,6 +274,7 @@ export type RoomGroupByOutputType = {
|
|||||||
maxPlayers: number
|
maxPlayers: number
|
||||||
gameMode: string
|
gameMode: string
|
||||||
searchAllowed: boolean
|
searchAllowed: boolean
|
||||||
|
timeLimit: number
|
||||||
startArticle: string
|
startArticle: string
|
||||||
targetArticle: string
|
targetArticle: string
|
||||||
roundWinner: string | null
|
roundWinner: string | null
|
||||||
@@ -305,6 +316,7 @@ export type RoomWhereInput = {
|
|||||||
maxPlayers?: Prisma.IntFilter<"Room"> | number
|
maxPlayers?: Prisma.IntFilter<"Room"> | number
|
||||||
gameMode?: Prisma.StringFilter<"Room"> | string
|
gameMode?: Prisma.StringFilter<"Room"> | string
|
||||||
searchAllowed?: Prisma.BoolFilter<"Room"> | boolean
|
searchAllowed?: Prisma.BoolFilter<"Room"> | boolean
|
||||||
|
timeLimit?: Prisma.IntFilter<"Room"> | number
|
||||||
startArticle?: Prisma.StringFilter<"Room"> | string
|
startArticle?: Prisma.StringFilter<"Room"> | string
|
||||||
targetArticle?: Prisma.StringFilter<"Room"> | string
|
targetArticle?: Prisma.StringFilter<"Room"> | string
|
||||||
roundWinner?: Prisma.StringNullableFilter<"Room"> | string | null
|
roundWinner?: Prisma.StringNullableFilter<"Room"> | string | null
|
||||||
@@ -323,6 +335,7 @@ export type RoomOrderByWithRelationInput = {
|
|||||||
maxPlayers?: Prisma.SortOrder
|
maxPlayers?: Prisma.SortOrder
|
||||||
gameMode?: Prisma.SortOrder
|
gameMode?: Prisma.SortOrder
|
||||||
searchAllowed?: Prisma.SortOrder
|
searchAllowed?: Prisma.SortOrder
|
||||||
|
timeLimit?: Prisma.SortOrder
|
||||||
startArticle?: Prisma.SortOrder
|
startArticle?: Prisma.SortOrder
|
||||||
targetArticle?: Prisma.SortOrder
|
targetArticle?: Prisma.SortOrder
|
||||||
roundWinner?: Prisma.SortOrderInput | Prisma.SortOrder
|
roundWinner?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||||
@@ -344,6 +357,7 @@ export type RoomWhereUniqueInput = Prisma.AtLeast<{
|
|||||||
maxPlayers?: Prisma.IntFilter<"Room"> | number
|
maxPlayers?: Prisma.IntFilter<"Room"> | number
|
||||||
gameMode?: Prisma.StringFilter<"Room"> | string
|
gameMode?: Prisma.StringFilter<"Room"> | string
|
||||||
searchAllowed?: Prisma.BoolFilter<"Room"> | boolean
|
searchAllowed?: Prisma.BoolFilter<"Room"> | boolean
|
||||||
|
timeLimit?: Prisma.IntFilter<"Room"> | number
|
||||||
startArticle?: Prisma.StringFilter<"Room"> | string
|
startArticle?: Prisma.StringFilter<"Room"> | string
|
||||||
targetArticle?: Prisma.StringFilter<"Room"> | string
|
targetArticle?: Prisma.StringFilter<"Room"> | string
|
||||||
roundWinner?: Prisma.StringNullableFilter<"Room"> | string | null
|
roundWinner?: Prisma.StringNullableFilter<"Room"> | string | null
|
||||||
@@ -362,6 +376,7 @@ export type RoomOrderByWithAggregationInput = {
|
|||||||
maxPlayers?: Prisma.SortOrder
|
maxPlayers?: Prisma.SortOrder
|
||||||
gameMode?: Prisma.SortOrder
|
gameMode?: Prisma.SortOrder
|
||||||
searchAllowed?: Prisma.SortOrder
|
searchAllowed?: Prisma.SortOrder
|
||||||
|
timeLimit?: Prisma.SortOrder
|
||||||
startArticle?: Prisma.SortOrder
|
startArticle?: Prisma.SortOrder
|
||||||
targetArticle?: Prisma.SortOrder
|
targetArticle?: Prisma.SortOrder
|
||||||
roundWinner?: Prisma.SortOrderInput | Prisma.SortOrder
|
roundWinner?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||||
@@ -388,6 +403,7 @@ export type RoomScalarWhereWithAggregatesInput = {
|
|||||||
maxPlayers?: Prisma.IntWithAggregatesFilter<"Room"> | number
|
maxPlayers?: Prisma.IntWithAggregatesFilter<"Room"> | number
|
||||||
gameMode?: Prisma.StringWithAggregatesFilter<"Room"> | string
|
gameMode?: Prisma.StringWithAggregatesFilter<"Room"> | string
|
||||||
searchAllowed?: Prisma.BoolWithAggregatesFilter<"Room"> | boolean
|
searchAllowed?: Prisma.BoolWithAggregatesFilter<"Room"> | boolean
|
||||||
|
timeLimit?: Prisma.IntWithAggregatesFilter<"Room"> | number
|
||||||
startArticle?: Prisma.StringWithAggregatesFilter<"Room"> | string
|
startArticle?: Prisma.StringWithAggregatesFilter<"Room"> | string
|
||||||
targetArticle?: Prisma.StringWithAggregatesFilter<"Room"> | string
|
targetArticle?: Prisma.StringWithAggregatesFilter<"Room"> | string
|
||||||
roundWinner?: Prisma.StringNullableWithAggregatesFilter<"Room"> | string | null
|
roundWinner?: Prisma.StringNullableWithAggregatesFilter<"Room"> | string | null
|
||||||
@@ -406,6 +422,7 @@ export type RoomCreateInput = {
|
|||||||
maxPlayers?: number
|
maxPlayers?: number
|
||||||
gameMode?: string
|
gameMode?: string
|
||||||
searchAllowed?: boolean
|
searchAllowed?: boolean
|
||||||
|
timeLimit?: number
|
||||||
startArticle?: string
|
startArticle?: string
|
||||||
targetArticle?: string
|
targetArticle?: string
|
||||||
roundWinner?: string | null
|
roundWinner?: string | null
|
||||||
@@ -424,6 +441,7 @@ export type RoomUncheckedCreateInput = {
|
|||||||
maxPlayers?: number
|
maxPlayers?: number
|
||||||
gameMode?: string
|
gameMode?: string
|
||||||
searchAllowed?: boolean
|
searchAllowed?: boolean
|
||||||
|
timeLimit?: number
|
||||||
startArticle?: string
|
startArticle?: string
|
||||||
targetArticle?: string
|
targetArticle?: string
|
||||||
roundWinner?: string | null
|
roundWinner?: string | null
|
||||||
@@ -442,6 +460,7 @@ export type RoomUpdateInput = {
|
|||||||
maxPlayers?: Prisma.IntFieldUpdateOperationsInput | number
|
maxPlayers?: Prisma.IntFieldUpdateOperationsInput | number
|
||||||
gameMode?: Prisma.StringFieldUpdateOperationsInput | string
|
gameMode?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
searchAllowed?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
searchAllowed?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||||
|
timeLimit?: Prisma.IntFieldUpdateOperationsInput | number
|
||||||
startArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
startArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
targetArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
targetArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
roundWinner?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
roundWinner?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||||
@@ -460,6 +479,7 @@ export type RoomUncheckedUpdateInput = {
|
|||||||
maxPlayers?: Prisma.IntFieldUpdateOperationsInput | number
|
maxPlayers?: Prisma.IntFieldUpdateOperationsInput | number
|
||||||
gameMode?: Prisma.StringFieldUpdateOperationsInput | string
|
gameMode?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
searchAllowed?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
searchAllowed?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||||
|
timeLimit?: Prisma.IntFieldUpdateOperationsInput | number
|
||||||
startArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
startArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
targetArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
targetArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
roundWinner?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
roundWinner?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||||
@@ -478,6 +498,7 @@ export type RoomCreateManyInput = {
|
|||||||
maxPlayers?: number
|
maxPlayers?: number
|
||||||
gameMode?: string
|
gameMode?: string
|
||||||
searchAllowed?: boolean
|
searchAllowed?: boolean
|
||||||
|
timeLimit?: number
|
||||||
startArticle?: string
|
startArticle?: string
|
||||||
targetArticle?: string
|
targetArticle?: string
|
||||||
roundWinner?: string | null
|
roundWinner?: string | null
|
||||||
@@ -496,6 +517,7 @@ export type RoomUpdateManyMutationInput = {
|
|||||||
maxPlayers?: Prisma.IntFieldUpdateOperationsInput | number
|
maxPlayers?: Prisma.IntFieldUpdateOperationsInput | number
|
||||||
gameMode?: Prisma.StringFieldUpdateOperationsInput | string
|
gameMode?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
searchAllowed?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
searchAllowed?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||||
|
timeLimit?: Prisma.IntFieldUpdateOperationsInput | number
|
||||||
startArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
startArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
targetArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
targetArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
roundWinner?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
roundWinner?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||||
@@ -514,6 +536,7 @@ export type RoomUncheckedUpdateManyInput = {
|
|||||||
maxPlayers?: Prisma.IntFieldUpdateOperationsInput | number
|
maxPlayers?: Prisma.IntFieldUpdateOperationsInput | number
|
||||||
gameMode?: Prisma.StringFieldUpdateOperationsInput | string
|
gameMode?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
searchAllowed?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
searchAllowed?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||||
|
timeLimit?: Prisma.IntFieldUpdateOperationsInput | number
|
||||||
startArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
startArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
targetArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
targetArticle?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
roundWinner?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
roundWinner?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||||
@@ -532,6 +555,7 @@ export type RoomCountOrderByAggregateInput = {
|
|||||||
maxPlayers?: Prisma.SortOrder
|
maxPlayers?: Prisma.SortOrder
|
||||||
gameMode?: Prisma.SortOrder
|
gameMode?: Prisma.SortOrder
|
||||||
searchAllowed?: Prisma.SortOrder
|
searchAllowed?: Prisma.SortOrder
|
||||||
|
timeLimit?: Prisma.SortOrder
|
||||||
startArticle?: Prisma.SortOrder
|
startArticle?: Prisma.SortOrder
|
||||||
targetArticle?: Prisma.SortOrder
|
targetArticle?: Prisma.SortOrder
|
||||||
roundWinner?: Prisma.SortOrder
|
roundWinner?: Prisma.SortOrder
|
||||||
@@ -545,6 +569,7 @@ export type RoomAvgOrderByAggregateInput = {
|
|||||||
round?: Prisma.SortOrder
|
round?: Prisma.SortOrder
|
||||||
totalRounds?: Prisma.SortOrder
|
totalRounds?: Prisma.SortOrder
|
||||||
maxPlayers?: Prisma.SortOrder
|
maxPlayers?: Prisma.SortOrder
|
||||||
|
timeLimit?: Prisma.SortOrder
|
||||||
countdownStart?: Prisma.SortOrder
|
countdownStart?: Prisma.SortOrder
|
||||||
roundStart?: Prisma.SortOrder
|
roundStart?: Prisma.SortOrder
|
||||||
createdAt?: Prisma.SortOrder
|
createdAt?: Prisma.SortOrder
|
||||||
@@ -558,6 +583,7 @@ export type RoomMaxOrderByAggregateInput = {
|
|||||||
maxPlayers?: Prisma.SortOrder
|
maxPlayers?: Prisma.SortOrder
|
||||||
gameMode?: Prisma.SortOrder
|
gameMode?: Prisma.SortOrder
|
||||||
searchAllowed?: Prisma.SortOrder
|
searchAllowed?: Prisma.SortOrder
|
||||||
|
timeLimit?: Prisma.SortOrder
|
||||||
startArticle?: Prisma.SortOrder
|
startArticle?: Prisma.SortOrder
|
||||||
targetArticle?: Prisma.SortOrder
|
targetArticle?: Prisma.SortOrder
|
||||||
roundWinner?: Prisma.SortOrder
|
roundWinner?: Prisma.SortOrder
|
||||||
@@ -575,6 +601,7 @@ export type RoomMinOrderByAggregateInput = {
|
|||||||
maxPlayers?: Prisma.SortOrder
|
maxPlayers?: Prisma.SortOrder
|
||||||
gameMode?: Prisma.SortOrder
|
gameMode?: Prisma.SortOrder
|
||||||
searchAllowed?: Prisma.SortOrder
|
searchAllowed?: Prisma.SortOrder
|
||||||
|
timeLimit?: Prisma.SortOrder
|
||||||
startArticle?: Prisma.SortOrder
|
startArticle?: Prisma.SortOrder
|
||||||
targetArticle?: Prisma.SortOrder
|
targetArticle?: Prisma.SortOrder
|
||||||
roundWinner?: Prisma.SortOrder
|
roundWinner?: Prisma.SortOrder
|
||||||
@@ -588,6 +615,7 @@ export type RoomSumOrderByAggregateInput = {
|
|||||||
round?: Prisma.SortOrder
|
round?: Prisma.SortOrder
|
||||||
totalRounds?: Prisma.SortOrder
|
totalRounds?: Prisma.SortOrder
|
||||||
maxPlayers?: Prisma.SortOrder
|
maxPlayers?: Prisma.SortOrder
|
||||||
|
timeLimit?: Prisma.SortOrder
|
||||||
countdownStart?: Prisma.SortOrder
|
countdownStart?: Prisma.SortOrder
|
||||||
roundStart?: Prisma.SortOrder
|
roundStart?: Prisma.SortOrder
|
||||||
createdAt?: Prisma.SortOrder
|
createdAt?: Prisma.SortOrder
|
||||||
@@ -624,6 +652,7 @@ export type RoomSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = r
|
|||||||
maxPlayers?: boolean
|
maxPlayers?: boolean
|
||||||
gameMode?: boolean
|
gameMode?: boolean
|
||||||
searchAllowed?: boolean
|
searchAllowed?: boolean
|
||||||
|
timeLimit?: boolean
|
||||||
startArticle?: boolean
|
startArticle?: boolean
|
||||||
targetArticle?: boolean
|
targetArticle?: boolean
|
||||||
roundWinner?: boolean
|
roundWinner?: boolean
|
||||||
@@ -642,6 +671,7 @@ export type RoomSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensio
|
|||||||
maxPlayers?: boolean
|
maxPlayers?: boolean
|
||||||
gameMode?: boolean
|
gameMode?: boolean
|
||||||
searchAllowed?: boolean
|
searchAllowed?: boolean
|
||||||
|
timeLimit?: boolean
|
||||||
startArticle?: boolean
|
startArticle?: boolean
|
||||||
targetArticle?: boolean
|
targetArticle?: boolean
|
||||||
roundWinner?: boolean
|
roundWinner?: boolean
|
||||||
@@ -660,6 +690,7 @@ export type RoomSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensio
|
|||||||
maxPlayers?: boolean
|
maxPlayers?: boolean
|
||||||
gameMode?: boolean
|
gameMode?: boolean
|
||||||
searchAllowed?: boolean
|
searchAllowed?: boolean
|
||||||
|
timeLimit?: boolean
|
||||||
startArticle?: boolean
|
startArticle?: boolean
|
||||||
targetArticle?: boolean
|
targetArticle?: boolean
|
||||||
roundWinner?: boolean
|
roundWinner?: boolean
|
||||||
@@ -678,6 +709,7 @@ export type RoomSelectScalar = {
|
|||||||
maxPlayers?: boolean
|
maxPlayers?: boolean
|
||||||
gameMode?: boolean
|
gameMode?: boolean
|
||||||
searchAllowed?: boolean
|
searchAllowed?: boolean
|
||||||
|
timeLimit?: boolean
|
||||||
startArticle?: boolean
|
startArticle?: boolean
|
||||||
targetArticle?: boolean
|
targetArticle?: boolean
|
||||||
roundWinner?: boolean
|
roundWinner?: boolean
|
||||||
@@ -687,7 +719,7 @@ export type RoomSelectScalar = {
|
|||||||
updatedAt?: boolean
|
updatedAt?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RoomOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"code" | "players" | "phase" | "round" | "totalRounds" | "maxPlayers" | "gameMode" | "searchAllowed" | "startArticle" | "targetArticle" | "roundWinner" | "countdownStart" | "roundStart" | "createdAt" | "updatedAt", ExtArgs["result"]["room"]>
|
export type RoomOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"code" | "players" | "phase" | "round" | "totalRounds" | "maxPlayers" | "gameMode" | "searchAllowed" | "timeLimit" | "startArticle" | "targetArticle" | "roundWinner" | "countdownStart" | "roundStart" | "createdAt" | "updatedAt", ExtArgs["result"]["room"]>
|
||||||
|
|
||||||
export type $RoomPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
export type $RoomPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||||
name: "Room"
|
name: "Room"
|
||||||
@@ -701,6 +733,7 @@ export type $RoomPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs =
|
|||||||
maxPlayers: number
|
maxPlayers: number
|
||||||
gameMode: string
|
gameMode: string
|
||||||
searchAllowed: boolean
|
searchAllowed: boolean
|
||||||
|
timeLimit: number
|
||||||
startArticle: string
|
startArticle: string
|
||||||
targetArticle: string
|
targetArticle: string
|
||||||
roundWinner: string | null
|
roundWinner: string | null
|
||||||
@@ -1139,6 +1172,7 @@ export interface RoomFieldRefs {
|
|||||||
readonly maxPlayers: Prisma.FieldRef<"Room", 'Int'>
|
readonly maxPlayers: Prisma.FieldRef<"Room", 'Int'>
|
||||||
readonly gameMode: Prisma.FieldRef<"Room", 'String'>
|
readonly gameMode: Prisma.FieldRef<"Room", 'String'>
|
||||||
readonly searchAllowed: Prisma.FieldRef<"Room", 'Boolean'>
|
readonly searchAllowed: Prisma.FieldRef<"Room", 'Boolean'>
|
||||||
|
readonly timeLimit: Prisma.FieldRef<"Room", 'Int'>
|
||||||
readonly startArticle: Prisma.FieldRef<"Room", 'String'>
|
readonly startArticle: Prisma.FieldRef<"Room", 'String'>
|
||||||
readonly targetArticle: Prisma.FieldRef<"Room", 'String'>
|
readonly targetArticle: Prisma.FieldRef<"Room", 'String'>
|
||||||
readonly roundWinner: Prisma.FieldRef<"Room", 'String'>
|
readonly roundWinner: Prisma.FieldRef<"Room", 'String'>
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ export function useMultiGame() {
|
|||||||
const timerStartedRef = useRef(false);
|
const timerStartedRef = useRef(false);
|
||||||
|
|
||||||
const [countdown, setCountdown] = useState<number | null>(null);
|
const [countdown, setCountdown] = useState<number | null>(null);
|
||||||
|
const [timeLeft, setTimeLeft] = useState<number | null>(null);
|
||||||
|
const timeLimitTimerRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||||
const countdownRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
const countdownRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||||
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||||
const prevPhaseRef = useRef<string | null>(null);
|
const prevPhaseRef = useRef<string | null>(null);
|
||||||
@@ -145,9 +147,23 @@ export function useMultiGame() {
|
|||||||
historyRef.current = [room.startArticle];
|
historyRef.current = [room.startArticle];
|
||||||
setHistory([room.startArticle]);
|
setHistory([room.startArticle]);
|
||||||
loadArticle(room.startArticle);
|
loadArticle(room.startArticle);
|
||||||
|
// Démarrer le timer de temps limité si configuré
|
||||||
|
if (timeLimitTimerRef.current) clearInterval(timeLimitTimerRef.current);
|
||||||
|
if (room.timeLimit > 0) {
|
||||||
|
const tick = () => {
|
||||||
|
const left = Math.ceil(((room.roundStart ?? Date.now()) + room.timeLimit * 1000 - Date.now()) / 1000);
|
||||||
|
setTimeLeft(left <= 0 ? 0 : left);
|
||||||
|
};
|
||||||
|
tick();
|
||||||
|
timeLimitTimerRef.current = setInterval(tick, 200);
|
||||||
|
} else {
|
||||||
|
setTimeLeft(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (room.phase === "results" && prevPhase !== "results") {
|
if (room.phase === "results" && prevPhase !== "results") {
|
||||||
timer.stop();
|
timer.stop();
|
||||||
|
if (timeLimitTimerRef.current) { clearInterval(timeLimitTimerRef.current); timeLimitTimerRef.current = null; }
|
||||||
|
setTimeLeft(null);
|
||||||
}
|
}
|
||||||
if (room.round !== prevRound && room.phase === "playing") {
|
if (room.round !== prevRound && room.phase === "playing") {
|
||||||
loadArticle(room.startArticle);
|
loadArticle(room.startArticle);
|
||||||
@@ -155,6 +171,19 @@ export function useMultiGame() {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [room]);
|
}, [room]);
|
||||||
|
|
||||||
|
// Temps limité : envoie timeUp quand le compteur atteint 0
|
||||||
|
useEffect(() => {
|
||||||
|
if (timeLeft !== 0 || !room || room.phase !== "playing" || !playerId || !room.timeLimit) return;
|
||||||
|
fetch(`/api/rooms/${room.code}`, {
|
||||||
|
method: "PATCH",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ action: "timeUp", playerId }),
|
||||||
|
}).then((r) => r.json()).then((d) => {
|
||||||
|
if ((d as { room: Room }).room) setRoom((d as { room: Room }).room);
|
||||||
|
}).catch(() => {});
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [timeLeft]);
|
||||||
|
|
||||||
// Countdown -> playing transition
|
// Countdown -> playing transition
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!room || room.phase !== "countdown" || !playerId) return;
|
if (!room || room.phase !== "countdown" || !playerId) return;
|
||||||
@@ -332,6 +361,16 @@ export function useMultiGame() {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [room, playerId]);
|
}, [room, playerId]);
|
||||||
|
|
||||||
|
async function setTimeLimit(value: number) {
|
||||||
|
if (!room || !playerId) return;
|
||||||
|
const res = await fetch(`/api/rooms/${room.code}`, {
|
||||||
|
method: "PATCH",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ action: "setTimeLimit", playerId, value }),
|
||||||
|
});
|
||||||
|
if (res.ok) setRoom((await res.json() as { room: Room }).room);
|
||||||
|
}
|
||||||
|
|
||||||
async function setSearchAllowed(value: boolean) {
|
async function setSearchAllowed(value: boolean) {
|
||||||
if (!room || !playerId) return;
|
if (!room || !playerId) return;
|
||||||
const res = await fetch(`/api/rooms/${room.code}`, {
|
const res = await fetch(`/api/rooms/${room.code}`, {
|
||||||
@@ -428,6 +467,8 @@ export function useMultiGame() {
|
|||||||
goBack,
|
goBack,
|
||||||
canGoBack: historyRef.current.length > 1,
|
canGoBack: historyRef.current.length > 1,
|
||||||
surrender,
|
surrender,
|
||||||
|
timeLeft,
|
||||||
|
setTimeLimit,
|
||||||
setSearchAllowed,
|
setSearchAllowed,
|
||||||
restore,
|
restore,
|
||||||
retryLoad: () => title && loadArticle(title),
|
retryLoad: () => title && loadArticle(title),
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ model Room {
|
|||||||
maxPlayers Int @default(16)
|
maxPlayers Int @default(16)
|
||||||
gameMode String @default("race")
|
gameMode String @default("race")
|
||||||
searchAllowed Boolean @default(false)
|
searchAllowed Boolean @default(false)
|
||||||
|
timeLimit Int @default(0)
|
||||||
startArticle String @default("")
|
startArticle String @default("")
|
||||||
targetArticle String @default("")
|
targetArticle String @default("")
|
||||||
roundWinner String?
|
roundWinner String?
|
||||||
|
|||||||
Reference in New Issue
Block a user