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
149 changes: 42 additions & 107 deletions packages/client/src/components/ActionsPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,121 +1,56 @@
import { Stack, Text } from '@chakra-ui/react';

enum ActionEvents {
Attack = 'attack',
Defend = 'defend against',
GainGold = 'gold',
GainExperience = 'experience',
}
// enum ActionEvents {
// Attack = 'attack',
// Defend = 'defend against',
// GainGold = 'gold',
// GainExperience = 'experience',
// }

type BattleEvent = {
type: ActionEvents;
monster: string;
amount: number;
};
// type BattleEvent = {
// type: ActionEvents;
// monster: string;
// amount: number;
// };

type ResolutionEvent = {
type: ActionEvents;
amount: number;
};
// type ResolutionEvent = {
// type: ActionEvents;
// amount: number;
// };

const BATTLE_EVENTS: BattleEvent[] = [
{
type: ActionEvents.Defend,
amount: 1,
monster: 'Green Slime',
},
{
type: ActionEvents.Attack,
amount: 2,
monster: 'Green Slime',
},
];
// const BATTLE_EVENTS: BattleEvent[] = [
// {
// type: ActionEvents.Defend,
// amount: 1,
// monster: 'Green Slime',
// },
// {
// type: ActionEvents.Attack,
// amount: 2,
// monster: 'Green Slime',
// },
// ];

const RESOLUTION_EVENTS: ResolutionEvent[] = [
{
type: ActionEvents.GainGold,
amount: 2,
},
{
type: ActionEvents.GainExperience,
amount: 3,
},
];
// const RESOLUTION_EVENTS: ResolutionEvent[] = [
// {
// type: ActionEvents.GainGold,
// amount: 2,
// },
// {
// type: ActionEvents.GainExperience,
// amount: 3,
// },
// ];

export const ActionsPanel = (): JSX.Element => {
return (
<Stack spacing={8}>
<Stack>
{BATTLE_EVENTS.map((event, i) => (
<Text
key={`battle-event-${i}`}
size={{ base: 'xs', sm: 'sm', lg: 'md' }}
>
You {event.type}{' '}
<Text as="span" color="green">
{event.monster}
</Text>{' '}
{event.type === ActionEvents.Attack ? 'for' : 'taking'}{' '}
<Text as="span" color="red">
{event.amount} damage
</Text>
.
</Text>
))}
</Stack>
<Stack>
{RESOLUTION_EVENTS.map((event, i) => (
<Text
key={`resolution-event-${i}`}
size={{ base: 'xs', sm: 'sm', lg: 'md' }}
>
You gain {event.amount}{' '}
<Text
as="span"
color={event.type === ActionEvents.GainGold ? 'yellow' : 'green'}
>
{event.type === ActionEvents.GainGold ? '$GOLD' : 'experience'}
</Text>
!
</Text>
))}
</Stack>
<Stack>
{BATTLE_EVENTS.map((event, i) => (
<Text
key={`battle-event-${i}`}
size={{ base: 'xs', sm: 'sm', lg: 'md' }}
>
You {event.type}{' '}
<Text as="span" color="green">
{event.monster}
</Text>{' '}
{event.type === ActionEvents.Attack ? 'for' : 'taking'}{' '}
<Text as="span" color="red">
{event.amount} damage
</Text>
.
</Text>
))}
</Stack>
<Stack>
{RESOLUTION_EVENTS.map((event, i) => (
<Text
key={`resolution-event-${i}`}
size={{ base: 'xs', sm: 'sm', lg: 'md' }}
>
You gain {event.amount}{' '}
<Text
as="span"
color={event.type === ActionEvents.GainGold ? 'yellow' : 'green'}
>
{event.type === ActionEvents.GainGold ? '$GOLD' : 'experience'}
</Text>
!
</Text>
))}
<Text size={{ base: 'xs', sm: 'sm', lg: 'md' }}>
You must spawn on the map to start battling.
</Text>
</Stack>
<Stack>
{/* <Stack>
{BATTLE_EVENTS.map((event, i) => (
<Text
key={`battle-event-${i}`}
Expand Down Expand Up @@ -149,7 +84,7 @@ export const ActionsPanel = (): JSX.Element => {
!
</Text>
))}
</Stack>
</Stack> */}
</Stack>
);
};
19 changes: 15 additions & 4 deletions packages/client/src/components/DevTools.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import mudConfig from 'contracts/mud.config';
import { useEffect } from 'react';
import characterSystemAbi from 'contracts/out/CharacterSystem.sol/CharacterSystem.abi.json';
import mapSystemAbi from 'contracts/out/MapSystem.sol/MapSystem.abi.json';
import { useEffect, useMemo } from 'react';

import { useMUD } from '../contexts/MUDContext';

// Displays dev-tools connected to the burner wallet
export function DevTools(): null {
const { network } = useMUD();
const { delegatorAddress, network } = useMUD();

const allAbi = useMemo(
() => [
...network.worldContract.abi,
...characterSystemAbi,
...mapSystemAbi,
],
[network.worldContract.abi],
);

useEffect(() => {
let unmount: (() => void) | undefined;
Expand All @@ -19,7 +30,7 @@ export function DevTools(): null {
latestBlock$: network.latestBlock$,
storedBlockLogs$: network.storedBlockLogs$,
worldAddress: network.worldContract.address,
worldAbi: network.worldContract.abi,
worldAbi: allAbi,
write$: network.write$,
recsWorld: network.world,
}),
Expand All @@ -33,7 +44,7 @@ export function DevTools(): null {
unmount();
}
};
}, [network]);
}, [allAbi, delegatorAddress, network]);

return null;
}
Loading