diff --git a/.gitignore b/.gitignore index 373edb9..156481d 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ next-env.d.ts # ignored for the template, you probably want to remove it: package-lock.json + +.env.local diff --git a/app/play/[level]/page.tsx b/app/play/[level]/page.tsx index 0c4f886..59f3918 100644 --- a/app/play/[level]/page.tsx +++ b/app/play/[level]/page.tsx @@ -39,6 +39,8 @@ export default function PlayLevelPage({ const [placementMode, setPlacementMode] = useState("player"); const [blockCount, setBlockCount] = useState(0); const [landmineCount, setLandmineCount] = useState(0); + const [maxBlocks, setMaxBlocks] = useState(0); + const [maxLandmines, setMaxLandmines] = useState(0); const flags = useQuery(api.flags.getFlags); const [mode, setMode] = useState<"play" | "test">("play"); const [replaySpeed, setReplaySpeed] = useState(DEFAULT_REPLAY_SPEED); @@ -47,6 +49,8 @@ export default function PlayLevelPage({ useEffect(() => { if (map) { setPlayerMap(map.grid.map((row) => [...row])); + setMaxBlocks(Number(map.maxBlocks) ?? 0); + setMaxLandmines(Number(map.maxLandmines) ?? 0); } }, [map]); @@ -219,20 +223,27 @@ export default function PlayLevelPage({ > Place Player - - + {maxBlocks > 0 && ( + + )} + + {maxLandmines > 0 && ( + + )}

diff --git a/app/playground/page.tsx b/app/playground/page.tsx index f55bd46..437b043 100644 --- a/app/playground/page.tsx +++ b/app/playground/page.tsx @@ -26,6 +26,8 @@ import { DialogHeader, DialogTitle, } from "@/components/ui/dialog"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; import { useToast } from "@/components/ui/use-toast"; import { api } from "@/convex/_generated/api"; import { Id } from "@/convex/_generated/dataModel"; @@ -61,6 +63,8 @@ export default function PlaygroundPage() { const [userSolution, setUserSolution] = useState([]); const [visualizingUserSolution, setVisualizingUserSolution] = useState(false); const [openSignInModal, setOpenSignInModal] = useState(false); + const [maxBlocks, setMaxBlocks] = useState(2); + const [maxLandmines, setMaxLandmines] = useState(0); const { isSimulating, @@ -89,7 +93,7 @@ export default function PlaygroundPage() { setPublishing(true); try { - const submitted = await submitMap({ map }); + const submitted = await submitMap({ map, maxBlocks, maxLandmines }); if (submitted == 200) { toast({ @@ -341,9 +345,9 @@ export default function PlaygroundPage() { if (cell === " ") { if (playerCount === 0) { newMap[y][x] = "P"; - } else if (blockCount < 2) { + } else if (blockCount < maxBlocks) { newMap[y][x] = "B"; - } else if (landmineCount === 0) { + } else if (landmineCount === maxLandmines) { newMap[y][x] = "L"; } } else if (cell === "P") { @@ -472,6 +476,31 @@ export default function PlaygroundPage() { ) : ( <> +
+
+ + setMaxBlocks(Number(e.target.value))} + value={maxBlocks} + /> +
+
+ + + setMaxLandmines(Number(e.target.value)) + } + value={maxLandmines} + /> +
+
+