-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/webdevcody/survive-the-nigh…
…t-sim merging the pulled changes from the main branch
- Loading branch information
Showing
14 changed files
with
340 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Doc } from "@/convex/_generated/dataModel"; | ||
|
||
export function ResultStatus({ result }: { result: Doc<"results"> }) { | ||
return ( | ||
<div | ||
className={`font-bold ${result.isWin ? "text-green-500" : "text-red-500"}`} | ||
> | ||
{result.isWin ? "Won" : "Lost"} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use client"; | ||
|
||
import { useQuery } from "convex/react"; | ||
import Result from "./result"; | ||
import { api } from "@/convex/_generated/api"; | ||
|
||
export default function GamePage() { | ||
const results = useQuery(api.results.getLastCompletedResults); | ||
|
||
if (results === undefined) { | ||
return <p>Loading...</p>; | ||
} | ||
|
||
return ( | ||
<div className="container mx-auto pt-12 pb-24 space-y-8"> | ||
<h1 className="text-2xl font-bold">Recent Games</h1> | ||
<div className="flex flex-wrap justify-betweengap-x-2 gap-12"> | ||
{results.map((result) => ( | ||
<Result key={result._id} result={result} /> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use client"; | ||
|
||
import { ResultStatus } from "../result-status"; | ||
import { type ResultWithGame } from "@/convex/results"; | ||
import { Visualizer } from "../visualizer"; | ||
import { format } from "date-fns"; | ||
|
||
export default function Result({ result }: { result: ResultWithGame }) { | ||
return ( | ||
<div className="flex gap-8 border rounded-xl p-4 bg-black"> | ||
{result.game !== null && ( | ||
<div className="flex flex-col gap-2"> | ||
<div className="flex gap-2"> | ||
<ResultStatus result={result} /> | ||
<p>at {format(new Date(result._creationTime), "h:mma")}</p> | ||
</div> | ||
<p>Level {result.level}</p> | ||
<p>{result.game.modelId}</p> | ||
</div> | ||
)} | ||
<Visualizer autoReplay autoStart controls={false} map={result.map} /> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.