diff --git a/app/game/diceplane.tsx b/app/game/diceplane.tsx new file mode 100644 index 0000000..c4728ea --- /dev/null +++ b/app/game/diceplane.tsx @@ -0,0 +1,77 @@ +'use client'; + +import { useState } from 'react'; + +type PlaneCell = { id: number; x: number; y: number; type: string }; + +const PLANE_SIZE = { width: 9, height: 7 } as const; + +const CELL_TYPES = ['한잔', '안주', '모두한잔', '두잔', '벌칙1', '벌칙2'] as const; + +function randomType() { + return CELL_TYPES[Math.floor(Math.random() * CELL_TYPES.length)]; +} + +/** 시계방향 둘레 칸. 모서리는 한 번만 넣어서 9x7 기준 28칸이 된다. */ +function buildPerimeter(width: number, height: number): PlaneCell[] { + const cells: PlaneCell[] = []; + let id = 0; + + for (let x = 0; x < width; x++) { + cells.push({ id: id++, x, y: 0, type: randomType() }); + } + for (let y = 1; y < height; y++) { + cells.push({ id: id++, x: width - 1, y, type: randomType() }); + } + for (let x = width - 2; x >= 0; x--) { + cells.push({ id: id++, x, y: height - 1, type: randomType() }); + } + for (let y = height - 2; y >= 1; y--) { + cells.push({ id: id++, x: 0, y, type: randomType() }); + } + + return cells; +} + +export default function DicePlane() { + const [dicePlaneArray] = useState(() => + buildPerimeter(PLANE_SIZE.width, PLANE_SIZE.height), + ); + + return ( +
+ {dicePlaneArray.map((plane) => ( +
+ {plane.type} +
+ ))} +
+ ); +} diff --git a/app/game/page.tsx b/app/game/page.tsx new file mode 100644 index 0000000..c131967 --- /dev/null +++ b/app/game/page.tsx @@ -0,0 +1,12 @@ +import DicePlane from './diceplane'; + +export default function GamePage() { + return ( +
+ +

+ Game +

+
+ ); +} diff --git a/app/home/page.tsx b/app/home/page.tsx deleted file mode 100644 index aedb6f8..0000000 --- a/app/home/page.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import React from 'react'; - -export default function Home() { - - - return ( -
-

Home

-
- ); -} \ No newline at end of file diff --git a/app/main/page.tsx b/app/main/page.tsx new file mode 100644 index 0000000..81d2518 --- /dev/null +++ b/app/main/page.tsx @@ -0,0 +1,16 @@ +import React from 'react'; +import { useRouter } from 'next/navigation'; + +export default function MainPage() { + + const router = useRouter(); + + return ( +
+

주루마블!

+ +
+ ); +} \ No newline at end of file