Added userState (isReady and isConnection)
This commit is contained in:
parent
29cb4a279d
commit
63fc8c56bf
13 changed files with 311 additions and 358 deletions
|
@ -33,15 +33,17 @@ function WithDots({ children }: { children: ReactNode }) {
|
|||
}
|
||||
|
||||
function LobbyFrame({ openSettings }: { openSettings: () => void }) {
|
||||
const { payload, full, leave, reset } = useGameProps()
|
||||
const { payload, userStates, full, leave, reset } = useGameProps()
|
||||
const { isConnected } = useSocket()
|
||||
const router = useRouter()
|
||||
const { data: session } = useSession()
|
||||
const [launchTime, setLaunchTime] = useState(3)
|
||||
|
||||
const launching = useMemo(
|
||||
() => payload?.player1?.isReady && payload?.player2?.isReady,
|
||||
[payload?.player1?.isReady, payload?.player2?.isReady]
|
||||
() =>
|
||||
payload?.users.length === 2 &&
|
||||
!userStates.filter((user) => !user.isReady).length,
|
||||
[payload?.users.length, userStates]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -88,23 +90,21 @@ function LobbyFrame({ openSettings }: { openSettings: () => void }) {
|
|||
</Icon>
|
||||
</div>
|
||||
<div className="flex items-center justify-around">
|
||||
<Player
|
||||
src="player_blue.png"
|
||||
player={payload?.player1}
|
||||
userId={session?.user.id}
|
||||
/>
|
||||
{isConnected ? (
|
||||
<>
|
||||
<Player src="player_blue.png" i={0} userId={session?.user.id} />
|
||||
<p className="font-farro m-4 text-6xl font-semibold">VS</p>
|
||||
{payload?.player2 ? (
|
||||
<Player
|
||||
src="player_red.png"
|
||||
player={payload?.player2}
|
||||
userId={session?.user.id}
|
||||
/>
|
||||
{payload?.users[1] ? (
|
||||
<Player src="player_red.png" i={1} userId={session?.user.id} />
|
||||
) : (
|
||||
<p className="font-farro w-96 text-center text-4xl font-medium">
|
||||
<WithDots>
|
||||
{"Warte auf " + (isConnected ? "Spieler 2" : "Verbindung")}
|
||||
</WithDots>
|
||||
<WithDots>Warte auf Spieler 2</WithDots>
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<p className="font-farro m-48 text-center text-6xl font-medium">
|
||||
Warte auf Verbindung
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
@ -11,7 +11,6 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
|||
import { faCaretDown } from "@fortawesome/sharp-solid-svg-icons"
|
||||
import { useGameProps } from "@hooks/useGameProps"
|
||||
import { socket } from "@lib/socket"
|
||||
import { PlayerSchema } from "@lib/zodSchemas"
|
||||
import classNames from "classnames"
|
||||
import { CSSProperties, useEffect, useMemo, useState } from "react"
|
||||
|
||||
|
@ -45,17 +44,19 @@ function HourGlass() {
|
|||
|
||||
function Player({
|
||||
src,
|
||||
player,
|
||||
i,
|
||||
userId,
|
||||
}: {
|
||||
src: string
|
||||
player?: PlayerSchema
|
||||
i: number
|
||||
userId?: string
|
||||
}) {
|
||||
const { setIsReady } = useGameProps()
|
||||
const { payload, userStates, setIsReady } = useGameProps()
|
||||
const player = useMemo(() => payload?.users[i], [i, payload?.users])
|
||||
const { isReady, isConnected } = useMemo(() => userStates[i], [i, userStates])
|
||||
const primary = useMemo(
|
||||
() => userId && userId === player?.id,
|
||||
[player?.id, userId]
|
||||
() => userId && userId === payload?.users[i]?.id,
|
||||
[i, payload?.users, userId]
|
||||
)
|
||||
|
||||
return (
|
||||
|
@ -66,7 +67,7 @@ function Player({
|
|||
primary ? "font-semibold" : "font-normal"
|
||||
)}
|
||||
>
|
||||
{player?.name ?? "Spieler " + (player?.index === "player2" ? "2" : "1")}
|
||||
{player?.name ?? "Spieler " + (player?.index === 2 ? "2" : "1")}
|
||||
</p>
|
||||
<div className="relative">
|
||||
<img className="pixelart w-64" src={"/assets/" + src} alt={src} />
|
||||
|
@ -82,21 +83,22 @@ function Player({
|
|||
)}
|
||||
</div>
|
||||
<Button
|
||||
type={player?.isReady ? "green" : "orange"}
|
||||
type={isConnected ? (isReady ? "green" : "orange") : "gray"}
|
||||
latching
|
||||
isLatched={!!player?.isReady}
|
||||
isLatched={!!isReady}
|
||||
onClick={() => {
|
||||
if (!player) return
|
||||
socket.emit("isReady", !player?.isReady)
|
||||
console.log(i, !isReady)
|
||||
setIsReady({
|
||||
index: player.index,
|
||||
isReady: !player?.isReady,
|
||||
i,
|
||||
isReady: !isReady,
|
||||
})
|
||||
socket.emit("isReady", !isReady)
|
||||
}}
|
||||
disabled={!primary}
|
||||
>
|
||||
Ready
|
||||
{player?.isReady ? (
|
||||
{isReady && isConnected ? (
|
||||
<FontAwesomeIcon icon={faCheck} className="ml-4 w-12" />
|
||||
) : primary ? (
|
||||
<FontAwesomeIcon
|
||||
|
|
|
@ -1,28 +1,39 @@
|
|||
import { GameSettings } from "@components/Lobby/SettingsFrame/Setting"
|
||||
import { getPayloadwithChecksum } from "@lib/getPayloadwithChecksum"
|
||||
import { socket } from "@lib/socket"
|
||||
import { GamePropsSchema, PlayerSchema } from "@lib/zodSchemas"
|
||||
import { PlayerN } from "@prisma/client"
|
||||
import {
|
||||
GamePropsSchema,
|
||||
optionalGamePropsSchema,
|
||||
PlayerSchema,
|
||||
} from "@lib/zodSchemas"
|
||||
import { produce } from "immer"
|
||||
import { toast } from "react-toastify"
|
||||
import { create } from "zustand"
|
||||
import { devtools } from "zustand/middleware"
|
||||
|
||||
const initialState: GamePropsSchema & {
|
||||
queue: { payload: string; hash: string }[]
|
||||
} = { payload: null, hash: null, queue: [] }
|
||||
const initialState: optionalGamePropsSchema & {
|
||||
userStates: {
|
||||
isReady: boolean
|
||||
isConnected: boolean
|
||||
}[]
|
||||
} = {
|
||||
payload: null,
|
||||
hash: null,
|
||||
userStates: Array.from(Array(2), () => ({
|
||||
isReady: false,
|
||||
isConnected: false,
|
||||
})),
|
||||
}
|
||||
|
||||
export type State = typeof initialState
|
||||
|
||||
export type Action = {
|
||||
setSetting: (settings: GameSettings) => string | null
|
||||
setPlayer: (payload: {
|
||||
player1?: PlayerSchema
|
||||
player2?: PlayerSchema
|
||||
}) => string | null
|
||||
setPlayer: (payload: { users: PlayerSchema[] }) => string | null
|
||||
full: (newProps: GamePropsSchema) => void
|
||||
leave: (cb: () => void) => void
|
||||
setIsReady: (payload: { index: PlayerN; isReady: boolean }) => void
|
||||
setIsReady: (payload: { i: number; isReady: boolean }) => void
|
||||
setIsConnected: (payload: { i: number; isConnected: boolean }) => void
|
||||
reset: () => void
|
||||
}
|
||||
|
||||
|
@ -35,7 +46,7 @@ export const useGameProps = create<State & Action>()(
|
|||
set(
|
||||
produce((state: State) => {
|
||||
if (!state.payload) return
|
||||
Object.assign(state.payload, payload)
|
||||
state.payload.users = payload.users
|
||||
const body = getPayloadwithChecksum(state.payload)
|
||||
if (!body.hash) {
|
||||
toast.warn("Something is wrong... ", {
|
||||
|
@ -55,10 +66,6 @@ export const useGameProps = create<State & Action>()(
|
|||
let hash: string | null = null
|
||||
set(
|
||||
produce((state: State) => {
|
||||
const length = state.queue.length
|
||||
state.queue.filter((e) => e.payload !== payload || e.hash !== hash)
|
||||
if (state.queue.length !== length) return
|
||||
|
||||
if (!state.payload?.game) return
|
||||
Object.assign(state.payload.game, settings)
|
||||
const body = getPayloadwithChecksum(state.payload)
|
||||
|
@ -71,7 +78,6 @@ export const useGameProps = create<State & Action>()(
|
|||
}
|
||||
hash = body.hash
|
||||
state.hash = hash
|
||||
state.queue.push({ payload, hash })
|
||||
})
|
||||
)
|
||||
return hash
|
||||
|
@ -106,14 +112,19 @@ export const useGameProps = create<State & Action>()(
|
|||
cb()
|
||||
})
|
||||
},
|
||||
setIsReady: ({ index, isReady }) =>
|
||||
setIsReady: ({ i, isReady }) =>
|
||||
set(
|
||||
produce((state: State) => {
|
||||
if (!state.payload) return
|
||||
const player = state.payload[index]
|
||||
if (!player) return
|
||||
player.isReady = isReady
|
||||
state.payload[index] = player
|
||||
state.userStates[i].isReady = isReady
|
||||
state.userStates[i].isConnected = true
|
||||
})
|
||||
),
|
||||
setIsConnected: ({ i, isConnected }) =>
|
||||
set(
|
||||
produce((state: State) => {
|
||||
state.userStates[i].isConnected = isConnected
|
||||
if (isConnected) return
|
||||
state.userStates[i].isReady = false
|
||||
})
|
||||
),
|
||||
reset: () => {
|
||||
|
|
|
@ -3,32 +3,48 @@ import { socket } from "@lib/socket"
|
|||
import status from "http-status"
|
||||
import { useSession } from "next-auth/react"
|
||||
import { useRouter } from "next/router"
|
||||
import { useEffect, useState } from "react"
|
||||
import { useEffect, useMemo, useState } from "react"
|
||||
import { toast } from "react-toastify"
|
||||
|
||||
/** This function should only be called once per page, otherwise there will be multiple socket connections and duplicate event listeners. */
|
||||
function useSocket() {
|
||||
const [isConnected, setIsConnected] = useState(false)
|
||||
const [isConnectedState, setIsConnectedState] = useState(false)
|
||||
const {
|
||||
payload,
|
||||
userStates,
|
||||
setPlayer,
|
||||
setSetting,
|
||||
full,
|
||||
setIsReady,
|
||||
setIsConnected,
|
||||
hash: stateHash,
|
||||
} = useGameProps()
|
||||
const { data: session } = useSession()
|
||||
const router = useRouter()
|
||||
|
||||
const { i, isIndex } = useMemo(() => {
|
||||
const i = payload?.users.findIndex((user) => session?.user?.id === user?.id)
|
||||
const isIndex = !(i === undefined || i < 0)
|
||||
if (!isIndex) return { i: undefined, isIndex }
|
||||
return { i, isIndex }
|
||||
}, [payload?.users, session?.user?.id])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isIndex) return
|
||||
setIsConnected({
|
||||
i,
|
||||
isConnected: isConnectedState,
|
||||
})
|
||||
}, [i, isConnectedState, isIndex, setIsConnected])
|
||||
|
||||
useEffect(() => {
|
||||
if (!session?.user.id) return
|
||||
socket.connect()
|
||||
|
||||
socket.on("connect", () => {
|
||||
setIsConnected(true)
|
||||
console.log("connected")
|
||||
|
||||
const toastId = "connect_error"
|
||||
toast.dismiss(toastId)
|
||||
toast.dismiss("connect_error")
|
||||
setIsConnectedState(true)
|
||||
})
|
||||
|
||||
socket.on("connect_error", (error) => {
|
||||
|
@ -57,11 +73,17 @@ function useSocket() {
|
|||
})
|
||||
})
|
||||
|
||||
socket.on("playerEvent", (type, payload, hash, userId) => {
|
||||
socket.on("playerEvent", (event) => {
|
||||
const { type, i, userId } = event
|
||||
if (userId === session?.user.id) return
|
||||
let message: string
|
||||
console.log(type)
|
||||
switch (type) {
|
||||
case "disconnect":
|
||||
setIsConnected({
|
||||
i,
|
||||
isConnected: false,
|
||||
})
|
||||
message = "Player is disconnected."
|
||||
break
|
||||
|
||||
|
@ -69,9 +91,12 @@ function useSocket() {
|
|||
message = "Player has left the lobby."
|
||||
break
|
||||
|
||||
case "join":
|
||||
console.log(hash === stateHash, !stateHash, hash, stateHash)
|
||||
if (stateHash && hash === stateHash) return
|
||||
case "connect":
|
||||
setIsConnected({
|
||||
i,
|
||||
isConnected: true,
|
||||
})
|
||||
socket.emit("isReady", userStates[i].isReady)
|
||||
message = "Player has joined the lobby."
|
||||
break
|
||||
|
||||
|
@ -80,7 +105,8 @@ function useSocket() {
|
|||
break
|
||||
}
|
||||
toast.info(message, { toastId: message })
|
||||
console.log(payload)
|
||||
if (type === "disconnect") return
|
||||
const { payload, hash } = event
|
||||
const newHash = setPlayer(payload)
|
||||
console.log(newHash, hash, !newHash, newHash === hash)
|
||||
if (!newHash || newHash === hash) return
|
||||
|
@ -91,21 +117,44 @@ function useSocket() {
|
|||
})
|
||||
})
|
||||
|
||||
socket.on("isReady", (payload, hash, userId) => {
|
||||
socket.on("isReady", (payload, userId) => {
|
||||
if (userId === session?.user.id) return
|
||||
setIsReady(payload)
|
||||
})
|
||||
|
||||
socket.on("disconnect", () => {
|
||||
console.log("disconnect")
|
||||
setIsConnected(false)
|
||||
setIsConnectedState(false)
|
||||
})
|
||||
|
||||
return () => {
|
||||
socket.removeAllListeners()
|
||||
socket.disconnect()
|
||||
}
|
||||
}, [session])
|
||||
}, [
|
||||
full,
|
||||
i,
|
||||
router,
|
||||
session?.user.id,
|
||||
setIsConnected,
|
||||
setIsReady,
|
||||
setPlayer,
|
||||
setSetting,
|
||||
stateHash,
|
||||
])
|
||||
useEffect(
|
||||
() =>
|
||||
console.log(
|
||||
i,
|
||||
isIndex,
|
||||
userStates[i ?? 0].isConnected,
|
||||
isConnectedState,
|
||||
isIndex ? userStates[i].isConnected : isConnectedState,
|
||||
userStates,
|
||||
session?.user.id
|
||||
),
|
||||
[i, isIndex, isConnectedState, session?.user.id, userStates]
|
||||
)
|
||||
useEffect(() => console.log("warst", isConnectedState), [isConnectedState])
|
||||
|
||||
// useEffect(() => {
|
||||
// if (!isConnected) return
|
||||
|
@ -120,7 +169,7 @@ function useSocket() {
|
|||
// return () => clearInterval(interval)
|
||||
// }, [isConnected])
|
||||
|
||||
return { isConnected }
|
||||
return { isConnected: isIndex ? userStates[i].isConnected : isConnectedState }
|
||||
}
|
||||
|
||||
export default useSocket
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { GameSettings } from "@components/Lobby/SettingsFrame/Setting"
|
||||
import { GamePropsSchema, PlayerSchema } from "@lib/zodSchemas"
|
||||
import { PlayerN, User } from "@prisma/client"
|
||||
import type { Server as HTTPServer } from "http"
|
||||
import type { Socket as NetSocket } from "net"
|
||||
import type { NextApiResponse } from "next"
|
||||
import { Session } from "next-auth"
|
||||
import type {
|
||||
Server as IOServer,
|
||||
Server,
|
||||
|
@ -29,17 +29,32 @@ export interface ServerToClientEvents {
|
|||
// withAck: (d: string, ) => void
|
||||
gameSetting: (payload: GameSettings, hash: string, userId: string) => void
|
||||
playerEvent: (
|
||||
type: "join" | "leave" | "disconnect",
|
||||
payload: { player1?: PlayerSchema; player2?: PlayerSchema },
|
||||
hash: string,
|
||||
event:
|
||||
| {
|
||||
type: "connect" | "leave"
|
||||
i: number
|
||||
payload: { users: PlayerSchema[] }
|
||||
hash: string
|
||||
userId: string
|
||||
}
|
||||
| {
|
||||
type: "disconnect"
|
||||
i: number
|
||||
userId: string
|
||||
}
|
||||
) => void
|
||||
isReady: (
|
||||
payload: {
|
||||
index: PlayerN
|
||||
i: number
|
||||
isReady: boolean
|
||||
},
|
||||
hash: string,
|
||||
userId: string
|
||||
) => void
|
||||
isConnected: (
|
||||
payload: {
|
||||
i: number
|
||||
isConnected: boolean
|
||||
},
|
||||
userId: string
|
||||
) => void
|
||||
}
|
||||
|
@ -47,6 +62,7 @@ export interface ServerToClientEvents {
|
|||
export interface ClientToServerEvents {
|
||||
update: (callback: (game: GamePropsSchema) => void) => void
|
||||
isReady: (isReady: boolean) => void
|
||||
isConnected: (isReady: boolean) => void
|
||||
ping: (count: number, callback: (count: number) => void) => void
|
||||
join: (withAck: (ack: boolean) => void) => void
|
||||
gameSetting: (payload: GameSettings, callback: (hash: string) => void) => void
|
||||
|
@ -58,8 +74,14 @@ interface InterServerEvents {
|
|||
}
|
||||
|
||||
interface SocketData {
|
||||
user: User | null
|
||||
props: {
|
||||
userId: string
|
||||
gameId: string
|
||||
index: number
|
||||
}
|
||||
user: Session["user"]
|
||||
gameId: string | null
|
||||
index: number
|
||||
}
|
||||
|
||||
export type sServer = Server<
|
||||
|
|
|
@ -2,9 +2,8 @@ import { GamePropsSchema } from "./zodSchemas"
|
|||
import crypto from "crypto"
|
||||
|
||||
export function getPayloadwithChecksum(
|
||||
payload: GamePropsSchema["payload"] | null
|
||||
payload: GamePropsSchema["payload"]
|
||||
): GamePropsSchema {
|
||||
if (payload === null) return { payload: null, hash: null }
|
||||
const objString = JSON.stringify(payload)
|
||||
const hash = crypto.createHash("md5").update(objString).digest("hex")
|
||||
return { payload, hash }
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
import { GameState, PlayerN } from "@prisma/client"
|
||||
import { GameState } from "@prisma/client"
|
||||
import { z } from "zod"
|
||||
|
||||
export const PlayerSchema = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
name: z.string().nullable(),
|
||||
index: z.nativeEnum(PlayerN),
|
||||
isReady: z.boolean(),
|
||||
isConnected: z.boolean(),
|
||||
index: z.number(),
|
||||
chats: z
|
||||
.object({
|
||||
id: z.string(),
|
||||
|
@ -27,8 +25,7 @@ export const PlayerSchema = z
|
|||
|
||||
export type PlayerSchema = z.infer<typeof PlayerSchema>
|
||||
|
||||
export const CreateSchema = z
|
||||
.object({
|
||||
export const CreateSchema = z.object({
|
||||
game: z
|
||||
.object({
|
||||
id: z.string(),
|
||||
|
@ -40,14 +37,17 @@ export const CreateSchema = z
|
|||
})
|
||||
.nullable(),
|
||||
gamePin: z.string().nullable(),
|
||||
player1: PlayerSchema,
|
||||
player2: PlayerSchema,
|
||||
users: PlayerSchema.array(),
|
||||
})
|
||||
.nullable()
|
||||
|
||||
export const GamePropsSchema = z.object({
|
||||
payload: CreateSchema,
|
||||
hash: z.string(),
|
||||
})
|
||||
export const optionalGamePropsSchema = z.object({
|
||||
payload: CreateSchema.nullable(),
|
||||
hash: z.string().nullable(),
|
||||
})
|
||||
|
||||
export type GamePropsSchema = z.infer<typeof GamePropsSchema>
|
||||
export type optionalGamePropsSchema = z.infer<typeof optionalGamePropsSchema>
|
||||
|
|
|
@ -42,7 +42,7 @@ export default async function create(
|
|||
users: {
|
||||
create: {
|
||||
userId: id,
|
||||
index: "player1",
|
||||
index: 1,
|
||||
chats: {
|
||||
create: {
|
||||
event: "created",
|
||||
|
|
|
@ -64,7 +64,7 @@ export default async function join(
|
|||
data: {
|
||||
gameId: game.id,
|
||||
userId: id,
|
||||
index: "player2",
|
||||
index: 2,
|
||||
},
|
||||
select: {
|
||||
game: gameSelects,
|
||||
|
|
|
@ -24,8 +24,6 @@ export const gameSelects = {
|
|||
select: {
|
||||
id: true,
|
||||
index: true,
|
||||
isReady: true,
|
||||
isConnected: true,
|
||||
chats: {
|
||||
select: {
|
||||
id: true,
|
||||
|
@ -85,17 +83,16 @@ export function composeBody(
|
|||
gameDB: NonNullable<Awaited<ReturnType<typeof getAnyRunningGame>>>
|
||||
): GamePropsSchema {
|
||||
const { gamePin, ...game } = gameDB
|
||||
const users = gameDB.users.map(({ user, ...props }) => ({
|
||||
const users = gameDB.users
|
||||
.map(({ user, ...props }) => ({
|
||||
...props,
|
||||
...user,
|
||||
}))
|
||||
const player1 = users.find((user) => user.index === "player1")
|
||||
const player2 = users.find((user) => user.index === "player2")
|
||||
.sort((user1, user2) => user1.index - user2.index)
|
||||
const payload = {
|
||||
game: game,
|
||||
gamePin: gamePin?.pin ?? null,
|
||||
player1: player1 ?? null,
|
||||
player2: player2 ?? null,
|
||||
users,
|
||||
}
|
||||
return getPayloadwithChecksum(payload)
|
||||
}
|
||||
|
|
|
@ -42,11 +42,8 @@ const SocketHandler = async (
|
|||
const session = await getSession({
|
||||
req: socket.request,
|
||||
})
|
||||
socket.data.user = await prisma.user.findUnique({
|
||||
where: {
|
||||
id: session?.user.id,
|
||||
},
|
||||
})
|
||||
if (!session) return next(new Error(status["401"]))
|
||||
socket.data.user = session.user
|
||||
|
||||
const game = await getAnyRunningGame(socket.data.user?.id ?? "")
|
||||
if (!game) {
|
||||
|
@ -56,25 +53,29 @@ const SocketHandler = async (
|
|||
["debug"],
|
||||
socket.request
|
||||
)
|
||||
next(new Error(status["403"]))
|
||||
return
|
||||
return next(new Error(status["403"]))
|
||||
}
|
||||
socket.data.gameId = game.id
|
||||
socket.join(game.id)
|
||||
|
||||
const { payload, hash } = composeBody(game)
|
||||
if (!hash) return socket.disconnect()
|
||||
io.to(game.id).emit(
|
||||
"playerEvent",
|
||||
"join",
|
||||
{ player1: payload?.player1, player2: payload?.player2 },
|
||||
hash,
|
||||
socket.data.user?.id ?? ""
|
||||
// let index: number | null = null
|
||||
const index = payload.users.findIndex(
|
||||
(user) => socket.data.user?.id === user?.id
|
||||
)
|
||||
if (index < 0) return next(new Error(status["401"]))
|
||||
socket.data.index = index
|
||||
socket.data.gameId = game.id
|
||||
socket.join(game.id)
|
||||
io.to(game.id).emit("playerEvent", {
|
||||
type: "connect",
|
||||
i: socket.data.index,
|
||||
payload: { users: payload.users },
|
||||
hash,
|
||||
userId: socket.data.user?.id ?? "",
|
||||
})
|
||||
|
||||
next()
|
||||
} catch (err) {
|
||||
logging(status["401"], ["warn"], socket.request)
|
||||
} catch (err: any) {
|
||||
logging("Unkonwn error - " + status["401"], ["warn"], socket.request)
|
||||
next(new Error(status["401"]))
|
||||
}
|
||||
})
|
||||
|
@ -132,16 +133,16 @@ const SocketHandler = async (
|
|||
},
|
||||
})
|
||||
let body: GamePropsSchema
|
||||
if (user_Game.index === "player1" && enemy) {
|
||||
if (user_Game.index === 1 && enemy) {
|
||||
const { game } = await prisma.user_Game.update({
|
||||
where: {
|
||||
gameId_index: {
|
||||
gameId: socket.data.gameId,
|
||||
index: "player2",
|
||||
index: 2,
|
||||
},
|
||||
},
|
||||
data: {
|
||||
index: "player1",
|
||||
index: 1,
|
||||
},
|
||||
select: {
|
||||
game: { ...gameSelects },
|
||||
|
@ -159,17 +160,18 @@ const SocketHandler = async (
|
|||
body = composeBody(game)
|
||||
}
|
||||
const { payload, hash } = body
|
||||
if (!payload || !hash) return cb(false)
|
||||
io.to(socket.data.gameId).emit(
|
||||
"playerEvent",
|
||||
"leave",
|
||||
{ player1: payload.player1, player2: payload.player2 },
|
||||
if (!payload || !hash || socket.data.index === undefined)
|
||||
return cb(false)
|
||||
io.to(socket.data.gameId).emit("playerEvent", {
|
||||
type: "leave",
|
||||
i: socket.data.index,
|
||||
payload: { users: payload.users },
|
||||
hash,
|
||||
socket.data.user?.id ?? ""
|
||||
)
|
||||
userId: socket.data.user?.id ?? "",
|
||||
})
|
||||
cb(true)
|
||||
|
||||
if (!payload?.player1 && !payload?.player2) {
|
||||
if (!payload.users.length) {
|
||||
await prisma.game.delete({
|
||||
where: {
|
||||
id: socket.data.gameId,
|
||||
|
@ -179,26 +181,15 @@ const SocketHandler = async (
|
|||
})
|
||||
|
||||
socket.on("isReady", async (isReady) => {
|
||||
const { index, game } = await prisma.user_Game.update({
|
||||
where: {
|
||||
gameId_userId: {
|
||||
userId: socket.data.user?.id ?? "",
|
||||
gameId: socket.data.gameId ?? "",
|
||||
},
|
||||
},
|
||||
data: { isReady },
|
||||
select: { index: true, game: gameSelects },
|
||||
})
|
||||
const payload = {
|
||||
index,
|
||||
isReady,
|
||||
}
|
||||
const { hash } = composeBody(game)
|
||||
if (!hash) return
|
||||
io.to(game.id).emit(
|
||||
if (socket.data.index === undefined || !socket.data.gameId) return
|
||||
io.to(socket.data.gameId).emit(
|
||||
"isReady",
|
||||
payload,
|
||||
hash,
|
||||
{ i: socket.data.index, isReady },
|
||||
socket.data.user?.id ?? ""
|
||||
)
|
||||
io.to(socket.data.gameId).emit(
|
||||
"isConnected",
|
||||
{ i: socket.data.index, isConnected: true },
|
||||
socket.data.user?.id ?? ""
|
||||
)
|
||||
})
|
||||
|
@ -209,17 +200,12 @@ const SocketHandler = async (
|
|||
["debug"],
|
||||
socket.request
|
||||
)
|
||||
// if (!socket.data.gameId) return
|
||||
// const game = await prisma.game.findUnique({
|
||||
// where: {
|
||||
// id: socket.data.gameId
|
||||
// },
|
||||
// ...gameSelects
|
||||
// })
|
||||
// if (!game) return
|
||||
// const { payload, hash } = composeBody(game, socket.data.user?.id ?? "")
|
||||
// if (!hash) return
|
||||
// io.to(socket.data.gameId).emit("playerEvent", {}, hash, "disconnect")
|
||||
if (socket.data.index === undefined || !socket.data.gameId) return
|
||||
io.to(socket.data.gameId).emit("playerEvent", {
|
||||
type: "disconnect",
|
||||
i: socket.data.index,
|
||||
userId: socket.data.user?.id ?? "",
|
||||
})
|
||||
})
|
||||
|
||||
socket.on("disconnect", () => {
|
||||
|
|
|
@ -28,7 +28,7 @@ export const TransactionIsolationLevelSchema = z.enum(['ReadUncommitted','ReadCo
|
|||
|
||||
export const UserScalarFieldEnumSchema = z.enum(['id','name','email','emailVerified','image','createdAt','updatedAt']);
|
||||
|
||||
export const User_GameScalarFieldEnumSchema = z.enum(['id','createdAt','gameId','userId','isReady','isConnected','index']);
|
||||
export const User_GameScalarFieldEnumSchema = z.enum(['id','createdAt','gameId','userId','index']);
|
||||
|
||||
export const VerificationTokenScalarFieldEnumSchema = z.enum(['identifier','token','expires']);
|
||||
|
||||
|
@ -36,10 +36,6 @@ export const GameStateSchema = z.enum(['launching','running','ended']);
|
|||
|
||||
export type GameStateType = `${z.infer<typeof GameStateSchema>}`
|
||||
|
||||
export const PlayerNSchema = z.enum(['player1','player2']);
|
||||
|
||||
export type PlayerNType = `${z.infer<typeof PlayerNSchema>}`
|
||||
|
||||
/////////////////////////////////////////
|
||||
// MODELS
|
||||
/////////////////////////////////////////
|
||||
|
@ -144,13 +140,11 @@ export type Gamepin = z.infer<typeof GamepinSchema>
|
|||
/////////////////////////////////////////
|
||||
|
||||
export const User_GameSchema = z.object({
|
||||
index: PlayerNSchema,
|
||||
id: z.string().cuid(),
|
||||
createdAt: z.coerce.date(),
|
||||
gameId: z.string(),
|
||||
userId: z.string(),
|
||||
isReady: z.boolean(),
|
||||
isConnected: z.boolean(),
|
||||
index: z.number().int(),
|
||||
})
|
||||
|
||||
export type User_Game = z.infer<typeof User_GameSchema>
|
||||
|
@ -371,8 +365,6 @@ export const User_GameSelectSchema: z.ZodType<Prisma.User_GameSelect> = z.object
|
|||
createdAt: z.boolean().optional(),
|
||||
gameId: z.boolean().optional(),
|
||||
userId: z.boolean().optional(),
|
||||
isReady: z.boolean().optional(),
|
||||
isConnected: z.boolean().optional(),
|
||||
index: z.boolean().optional(),
|
||||
moves: z.union([z.boolean(),z.lazy(() => MoveFindManyArgsSchema)]).optional(),
|
||||
chats: z.union([z.boolean(),z.lazy(() => ChatFindManyArgsSchema)]).optional(),
|
||||
|
@ -773,9 +765,7 @@ export const User_GameWhereInputSchema: z.ZodType<Prisma.User_GameWhereInput> =
|
|||
createdAt: z.union([ z.lazy(() => DateTimeFilterSchema),z.coerce.date() ]).optional(),
|
||||
gameId: z.union([ z.lazy(() => StringFilterSchema),z.string() ]).optional(),
|
||||
userId: z.union([ z.lazy(() => StringFilterSchema),z.string() ]).optional(),
|
||||
isReady: z.union([ z.lazy(() => BoolFilterSchema),z.boolean() ]).optional(),
|
||||
isConnected: z.union([ z.lazy(() => BoolFilterSchema),z.boolean() ]).optional(),
|
||||
index: z.union([ z.lazy(() => EnumPlayerNFilterSchema),z.lazy(() => PlayerNSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => IntFilterSchema),z.number() ]).optional(),
|
||||
moves: z.lazy(() => MoveListRelationFilterSchema).optional(),
|
||||
chats: z.lazy(() => ChatListRelationFilterSchema).optional(),
|
||||
game: z.union([ z.lazy(() => GameRelationFilterSchema),z.lazy(() => GameWhereInputSchema) ]).optional(),
|
||||
|
@ -787,8 +777,6 @@ export const User_GameOrderByWithRelationInputSchema: z.ZodType<Prisma.User_Game
|
|||
createdAt: z.lazy(() => SortOrderSchema).optional(),
|
||||
gameId: z.lazy(() => SortOrderSchema).optional(),
|
||||
userId: z.lazy(() => SortOrderSchema).optional(),
|
||||
isReady: z.lazy(() => SortOrderSchema).optional(),
|
||||
isConnected: z.lazy(() => SortOrderSchema).optional(),
|
||||
index: z.lazy(() => SortOrderSchema).optional(),
|
||||
moves: z.lazy(() => MoveOrderByRelationAggregateInputSchema).optional(),
|
||||
chats: z.lazy(() => ChatOrderByRelationAggregateInputSchema).optional(),
|
||||
|
@ -807,12 +795,12 @@ export const User_GameOrderByWithAggregationInputSchema: z.ZodType<Prisma.User_G
|
|||
createdAt: z.lazy(() => SortOrderSchema).optional(),
|
||||
gameId: z.lazy(() => SortOrderSchema).optional(),
|
||||
userId: z.lazy(() => SortOrderSchema).optional(),
|
||||
isReady: z.lazy(() => SortOrderSchema).optional(),
|
||||
isConnected: z.lazy(() => SortOrderSchema).optional(),
|
||||
index: z.lazy(() => SortOrderSchema).optional(),
|
||||
_count: z.lazy(() => User_GameCountOrderByAggregateInputSchema).optional(),
|
||||
_avg: z.lazy(() => User_GameAvgOrderByAggregateInputSchema).optional(),
|
||||
_max: z.lazy(() => User_GameMaxOrderByAggregateInputSchema).optional(),
|
||||
_min: z.lazy(() => User_GameMinOrderByAggregateInputSchema).optional()
|
||||
_min: z.lazy(() => User_GameMinOrderByAggregateInputSchema).optional(),
|
||||
_sum: z.lazy(() => User_GameSumOrderByAggregateInputSchema).optional()
|
||||
}).strict();
|
||||
|
||||
export const User_GameScalarWhereWithAggregatesInputSchema: z.ZodType<Prisma.User_GameScalarWhereWithAggregatesInput> = z.object({
|
||||
|
@ -823,9 +811,7 @@ export const User_GameScalarWhereWithAggregatesInputSchema: z.ZodType<Prisma.Use
|
|||
createdAt: z.union([ z.lazy(() => DateTimeWithAggregatesFilterSchema),z.coerce.date() ]).optional(),
|
||||
gameId: z.union([ z.lazy(() => StringWithAggregatesFilterSchema),z.string() ]).optional(),
|
||||
userId: z.union([ z.lazy(() => StringWithAggregatesFilterSchema),z.string() ]).optional(),
|
||||
isReady: z.union([ z.lazy(() => BoolWithAggregatesFilterSchema),z.boolean() ]).optional(),
|
||||
isConnected: z.union([ z.lazy(() => BoolWithAggregatesFilterSchema),z.boolean() ]).optional(),
|
||||
index: z.union([ z.lazy(() => EnumPlayerNWithAggregatesFilterSchema),z.lazy(() => PlayerNSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => IntWithAggregatesFilterSchema),z.number() ]).optional(),
|
||||
}).strict();
|
||||
|
||||
export const MoveWhereInputSchema: z.ZodType<Prisma.MoveWhereInput> = z.object({
|
||||
|
@ -1354,9 +1340,7 @@ export const GamepinUncheckedUpdateManyInputSchema: z.ZodType<Prisma.GamepinUnch
|
|||
export const User_GameCreateInputSchema: z.ZodType<Prisma.User_GameCreateInput> = z.object({
|
||||
id: z.string().cuid().optional(),
|
||||
createdAt: z.coerce.date().optional(),
|
||||
isReady: z.boolean().optional(),
|
||||
isConnected: z.boolean().optional(),
|
||||
index: z.lazy(() => PlayerNSchema),
|
||||
index: z.number().int(),
|
||||
moves: z.lazy(() => MoveCreateNestedManyWithoutUser_gameInputSchema).optional(),
|
||||
chats: z.lazy(() => ChatCreateNestedManyWithoutUser_gameInputSchema).optional(),
|
||||
game: z.lazy(() => GameCreateNestedOneWithoutUsersInputSchema),
|
||||
|
@ -1368,9 +1352,7 @@ export const User_GameUncheckedCreateInputSchema: z.ZodType<Prisma.User_GameUnch
|
|||
createdAt: z.coerce.date().optional(),
|
||||
gameId: z.string(),
|
||||
userId: z.string(),
|
||||
isReady: z.boolean().optional(),
|
||||
isConnected: z.boolean().optional(),
|
||||
index: z.lazy(() => PlayerNSchema),
|
||||
index: z.number().int(),
|
||||
moves: z.lazy(() => MoveUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional(),
|
||||
chats: z.lazy(() => ChatUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional()
|
||||
}).strict();
|
||||
|
@ -1378,9 +1360,7 @@ export const User_GameUncheckedCreateInputSchema: z.ZodType<Prisma.User_GameUnch
|
|||
export const User_GameUpdateInputSchema: z.ZodType<Prisma.User_GameUpdateInput> = z.object({
|
||||
id: z.union([ z.string().cuid(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isReady: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isConnected: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.number().int(),z.lazy(() => IntFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
moves: z.lazy(() => MoveUpdateManyWithoutUser_gameNestedInputSchema).optional(),
|
||||
chats: z.lazy(() => ChatUpdateManyWithoutUser_gameNestedInputSchema).optional(),
|
||||
game: z.lazy(() => GameUpdateOneRequiredWithoutUsersNestedInputSchema).optional(),
|
||||
|
@ -1392,9 +1372,7 @@ export const User_GameUncheckedUpdateInputSchema: z.ZodType<Prisma.User_GameUnch
|
|||
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
gameId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
userId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isReady: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isConnected: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.number().int(),z.lazy(() => IntFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
moves: z.lazy(() => MoveUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional(),
|
||||
chats: z.lazy(() => ChatUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional()
|
||||
}).strict();
|
||||
|
@ -1404,17 +1382,13 @@ export const User_GameCreateManyInputSchema: z.ZodType<Prisma.User_GameCreateMan
|
|||
createdAt: z.coerce.date().optional(),
|
||||
gameId: z.string(),
|
||||
userId: z.string(),
|
||||
isReady: z.boolean().optional(),
|
||||
isConnected: z.boolean().optional(),
|
||||
index: z.lazy(() => PlayerNSchema)
|
||||
index: z.number().int()
|
||||
}).strict();
|
||||
|
||||
export const User_GameUpdateManyMutationInputSchema: z.ZodType<Prisma.User_GameUpdateManyMutationInput> = z.object({
|
||||
id: z.union([ z.string().cuid(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isReady: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isConnected: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.number().int(),z.lazy(() => IntFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
}).strict();
|
||||
|
||||
export const User_GameUncheckedUpdateManyInputSchema: z.ZodType<Prisma.User_GameUncheckedUpdateManyInput> = z.object({
|
||||
|
@ -1422,9 +1396,7 @@ export const User_GameUncheckedUpdateManyInputSchema: z.ZodType<Prisma.User_Game
|
|||
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
gameId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
userId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isReady: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isConnected: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.number().int(),z.lazy(() => IntFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
}).strict();
|
||||
|
||||
export const MoveCreateInputSchema: z.ZodType<Prisma.MoveCreateInput> = z.object({
|
||||
|
@ -1941,11 +1913,15 @@ export const GamepinMinOrderByAggregateInputSchema: z.ZodType<Prisma.GamepinMinO
|
|||
gameId: z.lazy(() => SortOrderSchema).optional()
|
||||
}).strict();
|
||||
|
||||
export const EnumPlayerNFilterSchema: z.ZodType<Prisma.EnumPlayerNFilter> = z.object({
|
||||
equals: z.lazy(() => PlayerNSchema).optional(),
|
||||
in: z.union([ z.lazy(() => PlayerNSchema).array(),z.lazy(() => PlayerNSchema) ]).optional(),
|
||||
notIn: z.union([ z.lazy(() => PlayerNSchema).array(),z.lazy(() => PlayerNSchema) ]).optional(),
|
||||
not: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => NestedEnumPlayerNFilterSchema) ]).optional(),
|
||||
export const IntFilterSchema: z.ZodType<Prisma.IntFilter> = z.object({
|
||||
equals: z.number().optional(),
|
||||
in: z.union([ z.number().array(),z.number() ]).optional(),
|
||||
notIn: z.union([ z.number().array(),z.number() ]).optional(),
|
||||
lt: z.number().optional(),
|
||||
lte: z.number().optional(),
|
||||
gt: z.number().optional(),
|
||||
gte: z.number().optional(),
|
||||
not: z.union([ z.number(),z.lazy(() => NestedIntFilterSchema) ]).optional(),
|
||||
}).strict();
|
||||
|
||||
export const MoveListRelationFilterSchema: z.ZodType<Prisma.MoveListRelationFilter> = z.object({
|
||||
|
@ -1970,7 +1946,7 @@ export const ChatOrderByRelationAggregateInputSchema: z.ZodType<Prisma.ChatOrder
|
|||
|
||||
export const User_GameGameIdIndexCompoundUniqueInputSchema: z.ZodType<Prisma.User_GameGameIdIndexCompoundUniqueInput> = z.object({
|
||||
gameId: z.string(),
|
||||
index: z.lazy(() => PlayerNSchema)
|
||||
index: z.number()
|
||||
}).strict();
|
||||
|
||||
export const User_GameGameIdUserIdCompoundUniqueInputSchema: z.ZodType<Prisma.User_GameGameIdUserIdCompoundUniqueInput> = z.object({
|
||||
|
@ -1983,8 +1959,10 @@ export const User_GameCountOrderByAggregateInputSchema: z.ZodType<Prisma.User_Ga
|
|||
createdAt: z.lazy(() => SortOrderSchema).optional(),
|
||||
gameId: z.lazy(() => SortOrderSchema).optional(),
|
||||
userId: z.lazy(() => SortOrderSchema).optional(),
|
||||
isReady: z.lazy(() => SortOrderSchema).optional(),
|
||||
isConnected: z.lazy(() => SortOrderSchema).optional(),
|
||||
index: z.lazy(() => SortOrderSchema).optional()
|
||||
}).strict();
|
||||
|
||||
export const User_GameAvgOrderByAggregateInputSchema: z.ZodType<Prisma.User_GameAvgOrderByAggregateInput> = z.object({
|
||||
index: z.lazy(() => SortOrderSchema).optional()
|
||||
}).strict();
|
||||
|
||||
|
@ -1993,8 +1971,6 @@ export const User_GameMaxOrderByAggregateInputSchema: z.ZodType<Prisma.User_Game
|
|||
createdAt: z.lazy(() => SortOrderSchema).optional(),
|
||||
gameId: z.lazy(() => SortOrderSchema).optional(),
|
||||
userId: z.lazy(() => SortOrderSchema).optional(),
|
||||
isReady: z.lazy(() => SortOrderSchema).optional(),
|
||||
isConnected: z.lazy(() => SortOrderSchema).optional(),
|
||||
index: z.lazy(() => SortOrderSchema).optional()
|
||||
}).strict();
|
||||
|
||||
|
@ -2003,22 +1979,14 @@ export const User_GameMinOrderByAggregateInputSchema: z.ZodType<Prisma.User_Game
|
|||
createdAt: z.lazy(() => SortOrderSchema).optional(),
|
||||
gameId: z.lazy(() => SortOrderSchema).optional(),
|
||||
userId: z.lazy(() => SortOrderSchema).optional(),
|
||||
isReady: z.lazy(() => SortOrderSchema).optional(),
|
||||
isConnected: z.lazy(() => SortOrderSchema).optional(),
|
||||
index: z.lazy(() => SortOrderSchema).optional()
|
||||
}).strict();
|
||||
|
||||
export const EnumPlayerNWithAggregatesFilterSchema: z.ZodType<Prisma.EnumPlayerNWithAggregatesFilter> = z.object({
|
||||
equals: z.lazy(() => PlayerNSchema).optional(),
|
||||
in: z.union([ z.lazy(() => PlayerNSchema).array(),z.lazy(() => PlayerNSchema) ]).optional(),
|
||||
notIn: z.union([ z.lazy(() => PlayerNSchema).array(),z.lazy(() => PlayerNSchema) ]).optional(),
|
||||
not: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => NestedEnumPlayerNWithAggregatesFilterSchema) ]).optional(),
|
||||
_count: z.lazy(() => NestedIntFilterSchema).optional(),
|
||||
_min: z.lazy(() => NestedEnumPlayerNFilterSchema).optional(),
|
||||
_max: z.lazy(() => NestedEnumPlayerNFilterSchema).optional()
|
||||
export const User_GameSumOrderByAggregateInputSchema: z.ZodType<Prisma.User_GameSumOrderByAggregateInput> = z.object({
|
||||
index: z.lazy(() => SortOrderSchema).optional()
|
||||
}).strict();
|
||||
|
||||
export const IntFilterSchema: z.ZodType<Prisma.IntFilter> = z.object({
|
||||
export const IntWithAggregatesFilterSchema: z.ZodType<Prisma.IntWithAggregatesFilter> = z.object({
|
||||
equals: z.number().optional(),
|
||||
in: z.union([ z.number().array(),z.number() ]).optional(),
|
||||
notIn: z.union([ z.number().array(),z.number() ]).optional(),
|
||||
|
@ -2026,7 +1994,12 @@ export const IntFilterSchema: z.ZodType<Prisma.IntFilter> = z.object({
|
|||
lte: z.number().optional(),
|
||||
gt: z.number().optional(),
|
||||
gte: z.number().optional(),
|
||||
not: z.union([ z.number(),z.lazy(() => NestedIntFilterSchema) ]).optional(),
|
||||
not: z.union([ z.number(),z.lazy(() => NestedIntWithAggregatesFilterSchema) ]).optional(),
|
||||
_count: z.lazy(() => NestedIntFilterSchema).optional(),
|
||||
_avg: z.lazy(() => NestedFloatFilterSchema).optional(),
|
||||
_sum: z.lazy(() => NestedIntFilterSchema).optional(),
|
||||
_min: z.lazy(() => NestedIntFilterSchema).optional(),
|
||||
_max: z.lazy(() => NestedIntFilterSchema).optional()
|
||||
}).strict();
|
||||
|
||||
export const User_GameRelationFilterSchema: z.ZodType<Prisma.User_GameRelationFilter> = z.object({
|
||||
|
@ -2068,22 +2041,6 @@ export const MoveSumOrderByAggregateInputSchema: z.ZodType<Prisma.MoveSumOrderBy
|
|||
index: z.lazy(() => SortOrderSchema).optional()
|
||||
}).strict();
|
||||
|
||||
export const IntWithAggregatesFilterSchema: z.ZodType<Prisma.IntWithAggregatesFilter> = z.object({
|
||||
equals: z.number().optional(),
|
||||
in: z.union([ z.number().array(),z.number() ]).optional(),
|
||||
notIn: z.union([ z.number().array(),z.number() ]).optional(),
|
||||
lt: z.number().optional(),
|
||||
lte: z.number().optional(),
|
||||
gt: z.number().optional(),
|
||||
gte: z.number().optional(),
|
||||
not: z.union([ z.number(),z.lazy(() => NestedIntWithAggregatesFilterSchema) ]).optional(),
|
||||
_count: z.lazy(() => NestedIntFilterSchema).optional(),
|
||||
_avg: z.lazy(() => NestedFloatFilterSchema).optional(),
|
||||
_sum: z.lazy(() => NestedIntFilterSchema).optional(),
|
||||
_min: z.lazy(() => NestedIntFilterSchema).optional(),
|
||||
_max: z.lazy(() => NestedIntFilterSchema).optional()
|
||||
}).strict();
|
||||
|
||||
export const ChatCountOrderByAggregateInputSchema: z.ZodType<Prisma.ChatCountOrderByAggregateInput> = z.object({
|
||||
id: z.lazy(() => SortOrderSchema).optional(),
|
||||
createdAt: z.lazy(() => SortOrderSchema).optional(),
|
||||
|
@ -2422,8 +2379,12 @@ export const ChatUncheckedCreateNestedManyWithoutUser_gameInputSchema: z.ZodType
|
|||
connect: z.union([ z.lazy(() => ChatWhereUniqueInputSchema),z.lazy(() => ChatWhereUniqueInputSchema).array() ]).optional(),
|
||||
}).strict();
|
||||
|
||||
export const EnumPlayerNFieldUpdateOperationsInputSchema: z.ZodType<Prisma.EnumPlayerNFieldUpdateOperationsInput> = z.object({
|
||||
set: z.lazy(() => PlayerNSchema).optional()
|
||||
export const IntFieldUpdateOperationsInputSchema: z.ZodType<Prisma.IntFieldUpdateOperationsInput> = z.object({
|
||||
set: z.number().optional(),
|
||||
increment: z.number().optional(),
|
||||
decrement: z.number().optional(),
|
||||
multiply: z.number().optional(),
|
||||
divide: z.number().optional()
|
||||
}).strict();
|
||||
|
||||
export const MoveUpdateManyWithoutUser_gameNestedInputSchema: z.ZodType<Prisma.MoveUpdateManyWithoutUser_gameNestedInput> = z.object({
|
||||
|
@ -2504,14 +2465,6 @@ export const User_GameCreateNestedOneWithoutMovesInputSchema: z.ZodType<Prisma.U
|
|||
connect: z.lazy(() => User_GameWhereUniqueInputSchema).optional()
|
||||
}).strict();
|
||||
|
||||
export const IntFieldUpdateOperationsInputSchema: z.ZodType<Prisma.IntFieldUpdateOperationsInput> = z.object({
|
||||
set: z.number().optional(),
|
||||
increment: z.number().optional(),
|
||||
decrement: z.number().optional(),
|
||||
multiply: z.number().optional(),
|
||||
divide: z.number().optional()
|
||||
}).strict();
|
||||
|
||||
export const User_GameUpdateOneRequiredWithoutMovesNestedInputSchema: z.ZodType<Prisma.User_GameUpdateOneRequiredWithoutMovesNestedInput> = z.object({
|
||||
create: z.union([ z.lazy(() => User_GameCreateWithoutMovesInputSchema),z.lazy(() => User_GameUncheckedCreateWithoutMovesInputSchema) ]).optional(),
|
||||
connectOrCreate: z.lazy(() => User_GameCreateOrConnectWithoutMovesInputSchema).optional(),
|
||||
|
@ -2725,23 +2678,6 @@ export const NestedBoolWithAggregatesFilterSchema: z.ZodType<Prisma.NestedBoolWi
|
|||
_max: z.lazy(() => NestedBoolFilterSchema).optional()
|
||||
}).strict();
|
||||
|
||||
export const NestedEnumPlayerNFilterSchema: z.ZodType<Prisma.NestedEnumPlayerNFilter> = z.object({
|
||||
equals: z.lazy(() => PlayerNSchema).optional(),
|
||||
in: z.union([ z.lazy(() => PlayerNSchema).array(),z.lazy(() => PlayerNSchema) ]).optional(),
|
||||
notIn: z.union([ z.lazy(() => PlayerNSchema).array(),z.lazy(() => PlayerNSchema) ]).optional(),
|
||||
not: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => NestedEnumPlayerNFilterSchema) ]).optional(),
|
||||
}).strict();
|
||||
|
||||
export const NestedEnumPlayerNWithAggregatesFilterSchema: z.ZodType<Prisma.NestedEnumPlayerNWithAggregatesFilter> = z.object({
|
||||
equals: z.lazy(() => PlayerNSchema).optional(),
|
||||
in: z.union([ z.lazy(() => PlayerNSchema).array(),z.lazy(() => PlayerNSchema) ]).optional(),
|
||||
notIn: z.union([ z.lazy(() => PlayerNSchema).array(),z.lazy(() => PlayerNSchema) ]).optional(),
|
||||
not: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => NestedEnumPlayerNWithAggregatesFilterSchema) ]).optional(),
|
||||
_count: z.lazy(() => NestedIntFilterSchema).optional(),
|
||||
_min: z.lazy(() => NestedEnumPlayerNFilterSchema).optional(),
|
||||
_max: z.lazy(() => NestedEnumPlayerNFilterSchema).optional()
|
||||
}).strict();
|
||||
|
||||
export const NestedIntWithAggregatesFilterSchema: z.ZodType<Prisma.NestedIntWithAggregatesFilter> = z.object({
|
||||
equals: z.number().optional(),
|
||||
in: z.union([ z.number().array(),z.number() ]).optional(),
|
||||
|
@ -2888,9 +2824,7 @@ export const UserUncheckedUpdateWithoutSessionsInputSchema: z.ZodType<Prisma.Use
|
|||
export const User_GameCreateWithoutUserInputSchema: z.ZodType<Prisma.User_GameCreateWithoutUserInput> = z.object({
|
||||
id: z.string().cuid().optional(),
|
||||
createdAt: z.coerce.date().optional(),
|
||||
isReady: z.boolean().optional(),
|
||||
isConnected: z.boolean().optional(),
|
||||
index: z.lazy(() => PlayerNSchema),
|
||||
index: z.number().int(),
|
||||
moves: z.lazy(() => MoveCreateNestedManyWithoutUser_gameInputSchema).optional(),
|
||||
chats: z.lazy(() => ChatCreateNestedManyWithoutUser_gameInputSchema).optional(),
|
||||
game: z.lazy(() => GameCreateNestedOneWithoutUsersInputSchema)
|
||||
|
@ -2900,9 +2834,7 @@ export const User_GameUncheckedCreateWithoutUserInputSchema: z.ZodType<Prisma.Us
|
|||
id: z.string().cuid().optional(),
|
||||
createdAt: z.coerce.date().optional(),
|
||||
gameId: z.string(),
|
||||
isReady: z.boolean().optional(),
|
||||
isConnected: z.boolean().optional(),
|
||||
index: z.lazy(() => PlayerNSchema),
|
||||
index: z.number().int(),
|
||||
moves: z.lazy(() => MoveUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional(),
|
||||
chats: z.lazy(() => ChatUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional()
|
||||
}).strict();
|
||||
|
@ -3007,9 +2939,7 @@ export const User_GameScalarWhereInputSchema: z.ZodType<Prisma.User_GameScalarWh
|
|||
createdAt: z.union([ z.lazy(() => DateTimeFilterSchema),z.coerce.date() ]).optional(),
|
||||
gameId: z.union([ z.lazy(() => StringFilterSchema),z.string() ]).optional(),
|
||||
userId: z.union([ z.lazy(() => StringFilterSchema),z.string() ]).optional(),
|
||||
isReady: z.union([ z.lazy(() => BoolFilterSchema),z.boolean() ]).optional(),
|
||||
isConnected: z.union([ z.lazy(() => BoolFilterSchema),z.boolean() ]).optional(),
|
||||
index: z.union([ z.lazy(() => EnumPlayerNFilterSchema),z.lazy(() => PlayerNSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => IntFilterSchema),z.number() ]).optional(),
|
||||
}).strict();
|
||||
|
||||
export const AccountUpsertWithWhereUniqueWithoutUserInputSchema: z.ZodType<Prisma.AccountUpsertWithWhereUniqueWithoutUserInput> = z.object({
|
||||
|
@ -3095,9 +3025,7 @@ export const GamepinCreateOrConnectWithoutGameInputSchema: z.ZodType<Prisma.Game
|
|||
export const User_GameCreateWithoutGameInputSchema: z.ZodType<Prisma.User_GameCreateWithoutGameInput> = z.object({
|
||||
id: z.string().cuid().optional(),
|
||||
createdAt: z.coerce.date().optional(),
|
||||
isReady: z.boolean().optional(),
|
||||
isConnected: z.boolean().optional(),
|
||||
index: z.lazy(() => PlayerNSchema),
|
||||
index: z.number().int(),
|
||||
moves: z.lazy(() => MoveCreateNestedManyWithoutUser_gameInputSchema).optional(),
|
||||
chats: z.lazy(() => ChatCreateNestedManyWithoutUser_gameInputSchema).optional(),
|
||||
user: z.lazy(() => UserCreateNestedOneWithoutGamesInputSchema)
|
||||
|
@ -3107,9 +3035,7 @@ export const User_GameUncheckedCreateWithoutGameInputSchema: z.ZodType<Prisma.Us
|
|||
id: z.string().cuid().optional(),
|
||||
createdAt: z.coerce.date().optional(),
|
||||
userId: z.string(),
|
||||
isReady: z.boolean().optional(),
|
||||
isConnected: z.boolean().optional(),
|
||||
index: z.lazy(() => PlayerNSchema),
|
||||
index: z.number().int(),
|
||||
moves: z.lazy(() => MoveUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional(),
|
||||
chats: z.lazy(() => ChatUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional()
|
||||
}).strict();
|
||||
|
@ -3433,9 +3359,7 @@ export const UserUncheckedUpdateWithoutGamesInputSchema: z.ZodType<Prisma.UserUn
|
|||
export const User_GameCreateWithoutMovesInputSchema: z.ZodType<Prisma.User_GameCreateWithoutMovesInput> = z.object({
|
||||
id: z.string().cuid().optional(),
|
||||
createdAt: z.coerce.date().optional(),
|
||||
isReady: z.boolean().optional(),
|
||||
isConnected: z.boolean().optional(),
|
||||
index: z.lazy(() => PlayerNSchema),
|
||||
index: z.number().int(),
|
||||
chats: z.lazy(() => ChatCreateNestedManyWithoutUser_gameInputSchema).optional(),
|
||||
game: z.lazy(() => GameCreateNestedOneWithoutUsersInputSchema),
|
||||
user: z.lazy(() => UserCreateNestedOneWithoutGamesInputSchema)
|
||||
|
@ -3446,9 +3370,7 @@ export const User_GameUncheckedCreateWithoutMovesInputSchema: z.ZodType<Prisma.U
|
|||
createdAt: z.coerce.date().optional(),
|
||||
gameId: z.string(),
|
||||
userId: z.string(),
|
||||
isReady: z.boolean().optional(),
|
||||
isConnected: z.boolean().optional(),
|
||||
index: z.lazy(() => PlayerNSchema),
|
||||
index: z.number().int(),
|
||||
chats: z.lazy(() => ChatUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional()
|
||||
}).strict();
|
||||
|
||||
|
@ -3465,9 +3387,7 @@ export const User_GameUpsertWithoutMovesInputSchema: z.ZodType<Prisma.User_GameU
|
|||
export const User_GameUpdateWithoutMovesInputSchema: z.ZodType<Prisma.User_GameUpdateWithoutMovesInput> = z.object({
|
||||
id: z.union([ z.string().cuid(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isReady: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isConnected: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.number().int(),z.lazy(() => IntFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
chats: z.lazy(() => ChatUpdateManyWithoutUser_gameNestedInputSchema).optional(),
|
||||
game: z.lazy(() => GameUpdateOneRequiredWithoutUsersNestedInputSchema).optional(),
|
||||
user: z.lazy(() => UserUpdateOneRequiredWithoutGamesNestedInputSchema).optional()
|
||||
|
@ -3478,18 +3398,14 @@ export const User_GameUncheckedUpdateWithoutMovesInputSchema: z.ZodType<Prisma.U
|
|||
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
gameId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
userId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isReady: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isConnected: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.number().int(),z.lazy(() => IntFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
chats: z.lazy(() => ChatUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional()
|
||||
}).strict();
|
||||
|
||||
export const User_GameCreateWithoutChatsInputSchema: z.ZodType<Prisma.User_GameCreateWithoutChatsInput> = z.object({
|
||||
id: z.string().cuid().optional(),
|
||||
createdAt: z.coerce.date().optional(),
|
||||
isReady: z.boolean().optional(),
|
||||
isConnected: z.boolean().optional(),
|
||||
index: z.lazy(() => PlayerNSchema),
|
||||
index: z.number().int(),
|
||||
moves: z.lazy(() => MoveCreateNestedManyWithoutUser_gameInputSchema).optional(),
|
||||
game: z.lazy(() => GameCreateNestedOneWithoutUsersInputSchema),
|
||||
user: z.lazy(() => UserCreateNestedOneWithoutGamesInputSchema)
|
||||
|
@ -3500,9 +3416,7 @@ export const User_GameUncheckedCreateWithoutChatsInputSchema: z.ZodType<Prisma.U
|
|||
createdAt: z.coerce.date().optional(),
|
||||
gameId: z.string(),
|
||||
userId: z.string(),
|
||||
isReady: z.boolean().optional(),
|
||||
isConnected: z.boolean().optional(),
|
||||
index: z.lazy(() => PlayerNSchema),
|
||||
index: z.number().int(),
|
||||
moves: z.lazy(() => MoveUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional()
|
||||
}).strict();
|
||||
|
||||
|
@ -3519,9 +3433,7 @@ export const User_GameUpsertWithoutChatsInputSchema: z.ZodType<Prisma.User_GameU
|
|||
export const User_GameUpdateWithoutChatsInputSchema: z.ZodType<Prisma.User_GameUpdateWithoutChatsInput> = z.object({
|
||||
id: z.union([ z.string().cuid(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isReady: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isConnected: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.number().int(),z.lazy(() => IntFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
moves: z.lazy(() => MoveUpdateManyWithoutUser_gameNestedInputSchema).optional(),
|
||||
game: z.lazy(() => GameUpdateOneRequiredWithoutUsersNestedInputSchema).optional(),
|
||||
user: z.lazy(() => UserUpdateOneRequiredWithoutGamesNestedInputSchema).optional()
|
||||
|
@ -3532,9 +3444,7 @@ export const User_GameUncheckedUpdateWithoutChatsInputSchema: z.ZodType<Prisma.U
|
|||
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
gameId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
userId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isReady: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isConnected: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.number().int(),z.lazy(() => IntFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
moves: z.lazy(() => MoveUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional()
|
||||
}).strict();
|
||||
|
||||
|
@ -3542,9 +3452,7 @@ export const User_GameCreateManyUserInputSchema: z.ZodType<Prisma.User_GameCreat
|
|||
id: z.string().cuid().optional(),
|
||||
createdAt: z.coerce.date().optional(),
|
||||
gameId: z.string(),
|
||||
isReady: z.boolean().optional(),
|
||||
isConnected: z.boolean().optional(),
|
||||
index: z.lazy(() => PlayerNSchema)
|
||||
index: z.number().int()
|
||||
}).strict();
|
||||
|
||||
export const AccountCreateManyUserInputSchema: z.ZodType<Prisma.AccountCreateManyUserInput> = z.object({
|
||||
|
@ -3573,9 +3481,7 @@ export const SessionCreateManyUserInputSchema: z.ZodType<Prisma.SessionCreateMan
|
|||
export const User_GameUpdateWithoutUserInputSchema: z.ZodType<Prisma.User_GameUpdateWithoutUserInput> = z.object({
|
||||
id: z.union([ z.string().cuid(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isReady: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isConnected: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.number().int(),z.lazy(() => IntFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
moves: z.lazy(() => MoveUpdateManyWithoutUser_gameNestedInputSchema).optional(),
|
||||
chats: z.lazy(() => ChatUpdateManyWithoutUser_gameNestedInputSchema).optional(),
|
||||
game: z.lazy(() => GameUpdateOneRequiredWithoutUsersNestedInputSchema).optional()
|
||||
|
@ -3585,9 +3491,7 @@ export const User_GameUncheckedUpdateWithoutUserInputSchema: z.ZodType<Prisma.Us
|
|||
id: z.union([ z.string().cuid(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
gameId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isReady: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isConnected: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.number().int(),z.lazy(() => IntFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
moves: z.lazy(() => MoveUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional(),
|
||||
chats: z.lazy(() => ChatUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional()
|
||||
}).strict();
|
||||
|
@ -3596,9 +3500,7 @@ export const User_GameUncheckedUpdateManyWithoutGamesInputSchema: z.ZodType<Pris
|
|||
id: z.union([ z.string().cuid(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
gameId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isReady: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isConnected: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.number().int(),z.lazy(() => IntFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
}).strict();
|
||||
|
||||
export const AccountUpdateWithoutUserInputSchema: z.ZodType<Prisma.AccountUpdateWithoutUserInput> = z.object({
|
||||
|
@ -3674,17 +3576,13 @@ export const User_GameCreateManyGameInputSchema: z.ZodType<Prisma.User_GameCreat
|
|||
id: z.string().cuid().optional(),
|
||||
createdAt: z.coerce.date().optional(),
|
||||
userId: z.string(),
|
||||
isReady: z.boolean().optional(),
|
||||
isConnected: z.boolean().optional(),
|
||||
index: z.lazy(() => PlayerNSchema)
|
||||
index: z.number().int()
|
||||
}).strict();
|
||||
|
||||
export const User_GameUpdateWithoutGameInputSchema: z.ZodType<Prisma.User_GameUpdateWithoutGameInput> = z.object({
|
||||
id: z.union([ z.string().cuid(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isReady: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isConnected: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.number().int(),z.lazy(() => IntFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
moves: z.lazy(() => MoveUpdateManyWithoutUser_gameNestedInputSchema).optional(),
|
||||
chats: z.lazy(() => ChatUpdateManyWithoutUser_gameNestedInputSchema).optional(),
|
||||
user: z.lazy(() => UserUpdateOneRequiredWithoutGamesNestedInputSchema).optional()
|
||||
|
@ -3694,9 +3592,7 @@ export const User_GameUncheckedUpdateWithoutGameInputSchema: z.ZodType<Prisma.Us
|
|||
id: z.union([ z.string().cuid(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
userId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isReady: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isConnected: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.number().int(),z.lazy(() => IntFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
moves: z.lazy(() => MoveUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional(),
|
||||
chats: z.lazy(() => ChatUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional()
|
||||
}).strict();
|
||||
|
@ -3705,9 +3601,7 @@ export const User_GameUncheckedUpdateManyWithoutUsersInputSchema: z.ZodType<Pris
|
|||
id: z.union([ z.string().cuid(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
userId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isReady: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
isConnected: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
index: z.union([ z.number().int(),z.lazy(() => IntFieldUpdateOperationsInputSchema) ]).optional(),
|
||||
}).strict();
|
||||
|
||||
export const MoveCreateManyUser_gameInputSchema: z.ZodType<Prisma.MoveCreateManyUser_gameInput> = z.object({
|
||||
|
|
|
@ -95,19 +95,12 @@ model Gamepin {
|
|||
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
enum PlayerN {
|
||||
player1
|
||||
player2
|
||||
}
|
||||
|
||||
model User_Game {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
gameId String
|
||||
userId String
|
||||
isReady Boolean @default(false)
|
||||
isConnected Boolean @default(false)
|
||||
index PlayerN
|
||||
index Int
|
||||
moves Move[]
|
||||
chats Chat[]
|
||||
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue