Skip to content

Commit

Permalink
fix some hydration errors, start collecting gameplay sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
danreeves committed Oct 22, 2023
1 parent 9385b92 commit bedced1
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/components/MissionTimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ export function MissionTimer({ start, end }: { start: number; end: number }) {
return (
<div className="absolute bottom-0 right-0 flex w-full flex-row items-end justify-between">
<div
suppressHydrationWarning
className={`h-2 rounded-bl bg-yellow-400`}
style={{
width: `calc(${(end - dateNow) / (end - start)} * (100% - 3.5rem))`,
}}
></div>

<div className="flex h-6 px-1.5 flex-row items-center justify-center rounded-br rounded-tl bg-gray-800 text-sm text-green-50">
<span className="tabular-nums">{msToClockString(end - dateNow)}</span>
<span className="tabular-nums" suppressHydrationWarning>
{msToClockString(end - dateNow)}
</span>
</div>
</div>
)
Expand Down
8 changes: 8 additions & 0 deletions app/data/gameplaySessions.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { GameplaySession } from "@prisma/client"
import { prisma } from "~/data/db.server"

export async function saveGameplaySession(
session: Omit<GameplaySession, "createdAt">,
) {
return await prisma.gameplaySession.create({ data: session })
}
2 changes: 1 addition & 1 deletion app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function App() {
useRevalidateOnFocus()

return (
<html lang="en" className="h-screen">
<html lang="en" className="h-screen" suppressHydrationWarning>
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
Expand Down
31 changes: 31 additions & 0 deletions app/routes/api.gameplay_session.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { ActionArgs } from "@remix-run/server-runtime"
import { json } from "@remix-run/server-runtime"
import { z } from "zod"
import { saveGameplaySession } from "~/data/gameplaySessions.server"

let GameplaySessionSchema = z.object({
account_id: z.string(),
character_id: z.string(),
session_id: z.string(),
})

export async function action({ request }: ActionArgs) {
let body = await request.json()
let { account_id, character_id, session_id } =
GameplaySessionSchema.parse(body)

await saveGameplaySession({
accountId: account_id,
sessionId: session_id,
characterId: character_id,
})

return json({ ok: true })
}

export async function loader() {
throw new Response(null, {
status: 404,
statusText: "Not Found",
})
}
15 changes: 15 additions & 0 deletions mods/DTAuth/scripts/mods/DTAuth/DTAuth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,18 @@ function mod.authenticate_steam()
end
end)
end

mod:hook_safe("GameplaySession", "poll_for_end_of_round", function(_self, session_id, participant)
local url = domain .. "/api/gameplay_session"
local parts = string.split(participant, "|")
Managers.backend:url_request(url, {
method = "POST",
body = {
session_id = session_id,
account_id = parts[1],
character_id = parts[2]
}
})
end)

mod.start_authentication()
7 changes: 7 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,10 @@ model MissionInstance {
expiry DateTime
sideMission String?
}

model GameplaySession {
createdAt DateTime @default(now())
accountId String
characterId String
sessionId String @unique
}

0 comments on commit bedced1

Please sign in to comment.