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