Skip to content

Commit

Permalink
making play a bit better
Browse files Browse the repository at this point in the history
  • Loading branch information
webdevcody committed Oct 18, 2024
1 parent 02d751e commit de74819
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 7 deletions.
18 changes: 11 additions & 7 deletions app/play/[level]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,16 @@ export default function PlayLevelPage({
if (newMap[y][x] === " ") {
newMap[y][x] = "P";
}
} else if (placementMode === "block" && blockCount < 2) {
} else if (placementMode === "block") {
// Place new block
if (newMap[y][x] === " ") {
newMap[y][x] = "B";
setBlockCount(blockCount + 1);
if (newMap[y][x] === "B") {
newMap[y][x] = " ";
setBlockCount(blockCount - 1);
} else if (blockCount < 2) {
if (newMap[y][x] === " ") {
newMap[y][x] = "B";
setBlockCount(blockCount + 1);
}
}
}
setPlayerMap(newMap);
Expand Down Expand Up @@ -164,7 +169,6 @@ export default function PlayLevelPage({
<div className="mb-4 flex justify-center gap-4">
<Button
onClick={() => handlePlacementModeChange("player")}
disabled={playerMap.some((row) => row.includes("P"))}
variant={placementMode === "player" ? "default" : "outline"}
className="h-10"
>
Expand Down Expand Up @@ -213,10 +217,10 @@ export default function PlayLevelPage({
<div
key={`${x}-${y}`}
className={`
${cell === " " ? "cursor-pointer hover:border-2 z-10 hover:border-dashed hover:border-slate-300" : ""}
${cell === " " || cell === "B" ? "cursor-pointer hover:border-2 z-10 hover:border-dashed hover:border-slate-300" : ""}
border border-transparent
`}
onClick={() => cell === " " && handleCellClick(x, y)}
onClick={() => handleCellClick(x, y)}
/>
)),
)}
Expand Down
45 changes: 45 additions & 0 deletions convex/maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,51 @@ const LEVELS = [
[" ", " ", "Z"],
],
},
{
grid: [
[" ", " ", "R", "Z"],
["Z", " ", " ", "Z"],
],
},
{
grid: [
[" ", " ", " ", "Z"],
[" ", "R", "R", " "],
["Z", " ", " ", " "],
],
},
{
grid: [
["R", " ", " ", " "],
[" ", " ", " ", " "],
["Z", " ", "Z", "Z"],
],
},
{
grid: [
[" ", " ", "Z", " "],
["R", " ", " ", " "],
[" ", "Z", "R", " "],
["Z", "Z", " ", " "],
],
},
{
grid: [
["Z", " ", " ", " ", " ", "R"],
["Z", " ", " ", " ", " ", " "],
["Z", " ", " ", "R", " ", "Z"],
["Z", " ", " ", " ", " ", "R"],
],
},
{
grid: [
["R", "Z", " ", " ", "Z", " "],
["Z", " ", " ", " ", " ", " "],
[" ", " ", "R", " ", "R", " "],
[" ", " ", " ", "Z", " ", " "],
["R", " ", " ", " ", " ", "R"],
],
},
];

export const addMap = mutation({
Expand Down

0 comments on commit de74819

Please sign in to comment.