Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 196 additions & 0 deletions packages/client/src/components/ActionsPanel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
import { Stack, Text } from '@chakra-ui/react';

export const ActionsPanel = (): JSX.Element => {
return (
<Stack spacing={8}>
<Stack>
<Text>
You attack{' '}
<Text as="span" color="green">
Green Slime
</Text>{' '}
for{' '}
<Text as="span" color="red">
2 damage
</Text>
.
</Text>
<Text>
<Text as="span" color="green">
Green Slime
</Text>{' '}
attacks and misses!
</Text>
<Text>
You attack{' '}
<Text as="span" color="green">
Green Slime
</Text>{' '}
for{' '}
<Text as="span" color="red">
1 damage
</Text>
.
</Text>
<Text>Green slime is slain! You gain 2 $GOLD!</Text>
</Stack>
<Stack>
<Text>
You gain 2{' '}
<Text as="span" color="yellow">
$GOLD
</Text>
!
</Text>
<Text>
You gain 3{' '}
<Text as="span" color="green">
experience
</Text>
!
</Text>
</Stack>
<Stack>
<Text>
You attack{' '}
<Text as="span" color="green">
Green Slime
</Text>{' '}
for{' '}
<Text as="span" color="red">
2 damage
</Text>
.
</Text>
<Text>
<Text as="span" color="green">
Green Slime
</Text>{' '}
attacks and misses!
</Text>
<Text>
You attack{' '}
<Text as="span" color="green">
Green Slime
</Text>{' '}
for{' '}
<Text as="span" color="red">
1 damage
</Text>
.
</Text>
<Text>Green slime is slain! You gain 2 $GOLD!</Text>
</Stack>
<Stack>
<Text>
You gain 2{' '}
<Text as="span" color="yellow">
$GOLD
</Text>
!
</Text>
<Text>
You gain 3{' '}
<Text as="span" color="green">
experience
</Text>
!
</Text>
</Stack>
<Stack>
<Text>
You attack{' '}
<Text as="span" color="green">
Green Slime
</Text>{' '}
for{' '}
<Text as="span" color="red">
2 damage
</Text>
.
</Text>
<Text>
<Text as="span" color="green">
Green Slime
</Text>{' '}
attacks and misses!
</Text>
<Text>
You attack{' '}
<Text as="span" color="green">
Green Slime
</Text>{' '}
for{' '}
<Text as="span" color="red">
1 damage
</Text>
.
</Text>
<Text>Green slime is slain! You gain 2 $GOLD!</Text>
</Stack>
<Stack>
<Text>
You gain 2{' '}
<Text as="span" color="yellow">
$GOLD
</Text>
!
</Text>
<Text>
You gain 3{' '}
<Text as="span" color="green">
experience
</Text>
!
</Text>
</Stack>
<Stack>
<Text>
You attack{' '}
<Text as="span" color="green">
Green Slime
</Text>{' '}
for{' '}
<Text as="span" color="red">
2 damage
</Text>
.
</Text>
<Text>
<Text as="span" color="green">
Green Slime
</Text>{' '}
attacks and misses!
</Text>
<Text>
You attack{' '}
<Text as="span" color="green">
Green Slime
</Text>{' '}
for{' '}
<Text as="span" color="red">
1 damage
</Text>
.
</Text>
<Text>Green slime is slain! You gain 2 $GOLD!</Text>
</Stack>
<Stack>
<Text>
You gain 2{' '}
<Text as="span" color="yellow">
$GOLD
</Text>
!
</Text>
<Text>
You gain 3{' '}
<Text as="span" color="green">
experience
</Text>
!
</Text>
</Stack>
</Stack>
);
};
99 changes: 54 additions & 45 deletions packages/client/src/components/MapPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -37,58 +46,58 @@ export const MapPanel = (): JSX.Element => {
}
});
},
[],
[position],
);

return (
<VStack h="100%" w="100%">
<Box
border="2px solid black"
borderRight="none"
borderTop="none"
display="grid"
gridTemplateColumns="repeat(10, 1fr)"
gridTemplateRows="repeat(10, 1fr)"
>
{[...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;
<VStack>
<Box w="100%">
<Box
border="2px solid black"
borderRight="none"
borderTop="none"
display="grid"
gridTemplateColumns="repeat(10, 1fr)"
gridTemplateRows="repeat(10, 1fr)"
>
{[...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 (
<Box
borderTop={hasSafeZoneTopBorder ? '3px solid' : '2px solid'}
borderTopColor={hasSafeZoneTopBorder ? 'yellow' : 'black'}
borderRight={hasSafeZoneRightBorder ? '3px solid' : '2px solid'}
borderRightColor={hasSafeZoneRightBorder ? 'yellow' : 'black'}
key={`map-tile${i}`}
h="30px"
w="30px"
>
{currentTile && <CharacterPiece />}
</Box>
);
})}
</Box>
<HStack justifyContent="space-between" w="100%">
<HStack>
<BiSolidNavigation />
<Text fontWeight={700} size="sm">
{position.x}, {position.y}
</Text>
return (
<VStack
borderTop={hasSafeZoneTopBorder ? '3px solid' : '2px solid'}
borderTopColor={hasSafeZoneTopBorder ? 'yellow' : 'black'}
borderRight={hasSafeZoneRightBorder ? '3px solid' : '2px solid'}
borderRightColor={hasSafeZoneRightBorder ? 'yellow' : 'black'}
key={`map-tile${i}`}
>
{currentTile && <CharacterPiece />}
</VStack>
);
})}
</Box>
<HStack justifyContent="space-between" w="100%">
<HStack>
<BiSolidNavigation />
<Text fontWeight={700} size="sm">
{position.x}, {position.y}
</Text>
</HStack>
<Text size="xs">Dark Cave - 2,344 Players</Text>
</HStack>
<Text size="xs">Dark Cave - 2,344 Players</Text>
</HStack>
</Box>
<VStack
alignItems="stretch"
h={175}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/components/StatsPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { TopBar } from './TopBar';

export const StatsPanel = (): JSX.Element => {
return (
<VStack h="100%" p={3}>
<VStack h="100%">
<TopBar />
<Spacer />
<Stats />
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/components/TileDetailsPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SafeZone } from './SafeZone';

export const TileDetailsPanel = (): JSX.Element => {
return (
<Grid h="100%" p={3} templateColumns="repeat(4, 1fr)" gap={5}>
<Grid h="100%" templateColumns="repeat(4, 1fr)" gap={5}>
<GridItem colSpan={2}>
<Monsters />
</GridItem>
Expand Down
Loading