From 284b46cd4316502fd4c95dd263a3c98b6f9a9e6b Mon Sep 17 00:00:00 2001 From: ECWireless Date: Mon, 10 Jun 2024 11:53:51 -0600 Subject: [PATCH] Add ActionsPanel --- .../client/src/components/ActionsPanel.tsx | 196 ++++++++++++++++++ packages/client/src/components/MapPanel.tsx | 99 +++++---- .../src/components/StatsPanel/index.tsx | 2 +- .../src/components/TileDetailsPanel/index.tsx | 2 +- packages/client/src/pages/GameBoard.tsx | 44 ++-- 5 files changed, 275 insertions(+), 68 deletions(-) create mode 100644 packages/client/src/components/ActionsPanel.tsx diff --git a/packages/client/src/components/ActionsPanel.tsx b/packages/client/src/components/ActionsPanel.tsx new file mode 100644 index 000000000..5cc0c339a --- /dev/null +++ b/packages/client/src/components/ActionsPanel.tsx @@ -0,0 +1,196 @@ +import { Stack, Text } from '@chakra-ui/react'; + +export const ActionsPanel = (): JSX.Element => { + return ( + + + + You attack{' '} + + Green Slime + {' '} + for{' '} + + 2 damage + + . + + + + Green Slime + {' '} + attacks and misses! + + + You attack{' '} + + Green Slime + {' '} + for{' '} + + 1 damage + + . + + Green slime is slain! You gain 2 $GOLD! + + + + You gain 2{' '} + + $GOLD + + ! + + + You gain 3{' '} + + experience + + ! + + + + + You attack{' '} + + Green Slime + {' '} + for{' '} + + 2 damage + + . + + + + Green Slime + {' '} + attacks and misses! + + + You attack{' '} + + Green Slime + {' '} + for{' '} + + 1 damage + + . + + Green slime is slain! You gain 2 $GOLD! + + + + You gain 2{' '} + + $GOLD + + ! + + + You gain 3{' '} + + experience + + ! + + + + + You attack{' '} + + Green Slime + {' '} + for{' '} + + 2 damage + + . + + + + Green Slime + {' '} + attacks and misses! + + + You attack{' '} + + Green Slime + {' '} + for{' '} + + 1 damage + + . + + Green slime is slain! You gain 2 $GOLD! + + + + You gain 2{' '} + + $GOLD + + ! + + + You gain 3{' '} + + experience + + ! + + + + + You attack{' '} + + Green Slime + {' '} + for{' '} + + 2 damage + + . + + + + Green Slime + {' '} + attacks and misses! + + + You attack{' '} + + Green Slime + {' '} + for{' '} + + 1 damage + + . + + Green slime is slain! You gain 2 $GOLD! + + + + You gain 2{' '} + + $GOLD + + ! + + + You gain 3{' '} + + experience + + ! + + + + ); +}; diff --git a/packages/client/src/components/MapPanel.tsx b/packages/client/src/components/MapPanel.tsx index 881bc578c..1c533ff92 100644 --- a/packages/client/src/components/MapPanel.tsx +++ b/packages/client/src/components/MapPanel.tsx @@ -22,6 +22,15 @@ export const MapPanel = (): JSX.Element => { const onMove = useCallback( async (direction: 'up' | 'down' | 'left' | 'right') => { + if ( + (direction === 'up' && position.y === 9) || + (direction === 'down' && position.y === 0) || + (direction === 'left' && position.x === 0) || + (direction === 'right' && position.x === 9) + ) { + return; + } + setPosition(prevPosition => { switch (direction) { case 'up': @@ -37,58 +46,58 @@ export const MapPanel = (): JSX.Element => { } }); }, - [], + [position], ); return ( - - - {[...Array(100)].map((_, i) => { - const row = 9 - Math.floor(i / 10); // Reverse the row - const col = i % 10; - const currentTile = position.x === col && position.y === row; + + + + {[...Array(100)].map((_, i) => { + const row = 9 - Math.floor(i / 10); // Reverse the row + const col = i % 10; + const currentTile = position.x === col && position.y === row; - const hasSafeZoneTopBorder = - row === SAFE_ZONE_AREA.topLeft.y && - col >= SAFE_ZONE_AREA.topLeft.x && - col <= SAFE_ZONE_AREA.bottomRight.x; + const hasSafeZoneTopBorder = + row === SAFE_ZONE_AREA.topLeft.y && + col >= SAFE_ZONE_AREA.topLeft.x && + col <= SAFE_ZONE_AREA.bottomRight.x; - const hasSafeZoneRightBorder = - col === SAFE_ZONE_AREA.bottomRight.x && - row >= SAFE_ZONE_AREA.bottomRight.y && - row <= SAFE_ZONE_AREA.topLeft.y; + const hasSafeZoneRightBorder = + col === SAFE_ZONE_AREA.bottomRight.x && + row >= SAFE_ZONE_AREA.bottomRight.y && + row <= SAFE_ZONE_AREA.topLeft.y; - return ( - - {currentTile && } - - ); - })} - - - - - - {position.x}, {position.y} - + return ( + + {currentTile && } + + ); + })} + + + + + + {position.x}, {position.y} + + + Dark Cave - 2,344 Players - Dark Cave - 2,344 Players - + { return ( - + diff --git a/packages/client/src/components/TileDetailsPanel/index.tsx b/packages/client/src/components/TileDetailsPanel/index.tsx index c4275cdb5..baaa3edc1 100644 --- a/packages/client/src/components/TileDetailsPanel/index.tsx +++ b/packages/client/src/components/TileDetailsPanel/index.tsx @@ -6,7 +6,7 @@ import { SafeZone } from './SafeZone'; export const TileDetailsPanel = (): JSX.Element => { return ( - + diff --git a/packages/client/src/pages/GameBoard.tsx b/packages/client/src/pages/GameBoard.tsx index f3cc16be6..1621f9361 100644 --- a/packages/client/src/pages/GameBoard.tsx +++ b/packages/client/src/pages/GameBoard.tsx @@ -1,5 +1,6 @@ import { Grid, GridItem, Heading } from '@chakra-ui/react'; +import { ActionsPanel } from '../components/ActionsPanel'; import { MapPanel } from '../components/MapPanel'; import { StatsPanel } from '../components/StatsPanel'; import { TileDetailsPanel } from '../components/TileDetailsPanel'; @@ -10,62 +11,63 @@ export const GameBoard = (): JSX.Element => { gap={2} minH="100vh" mt={4} - templateColumns={{ base: 'repeat(8, 1fr)', md: 'repeat(8, 1fr)' }} + templateColumns={{ base: 'repeat(16, 1fr)', md: 'repeat(16, 1fr)' }} templateRows={{ base: 'repeat(13, 1fr)', md: 'repeat(12, 1fr)' }} > - ActionPanel + - Chat - + */}