From 1b1f0aa1d2abcc728f22d49d2a5b56db062829e6 Mon Sep 17 00:00:00 2001 From: chrisfarms Date: Sat, 11 May 2024 17:14:59 +0100 Subject: [PATCH 1/2] disable construct intent for buggy zones there's a contract bug preventing the CONSTRUCT_BUILDING_MOBILE_UNIT action for working as intended when the zone id is 40 or more. as a temporary measure we are disabling the build intent for the affected zones so that it reduces the potential confusion of either the resulting "out of bounds" error or the silent failing due to these errors only being debug visisble. --- frontend/src/components/views/shell/index.tsx | 9 +++- frontend/src/plugins/action-bar/index.tsx | 50 +++++++++++-------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/frontend/src/components/views/shell/index.tsx b/frontend/src/components/views/shell/index.tsx index 59643c3ab..8af791c9b 100644 --- a/frontend/src/components/views/shell/index.tsx +++ b/frontend/src/components/views/shell/index.tsx @@ -31,6 +31,12 @@ import styled from 'styled-components'; import { pipe, subscribe } from 'wonka'; import { styles } from './shell.styles'; +// there is a bug that means that the CONSTRUCT_BUILDING_MOBILE_UNIT action +// fails for zone ids above 40. As a temporary measure to limit confusion we +// will disable the construct button on these zones while we consider options +// see: https://github.com/playmint/ds/issues/1402 +const isBuggyZone = (id: number) => id >= 40; + export interface ShellProps extends ComponentProps {} const StyledShell = styled('div')` @@ -63,6 +69,7 @@ export const Shell: FunctionComponent = () => { const kinds = global?.buildingKinds || []; const unitTimeoutBlocks = parseInt(global?.gameSettings?.unitTimeoutBlocks?.value || '0x0', 16); const zoneUnitLimit = parseInt(global?.gameSettings?.zoneUnitLimit?.value || '0x0', 16); + const zoneId = parseInt(zone?.key || 0, 16); const ui = usePluginState(); const [questsActive, setQuestsActive] = useState(true); @@ -413,7 +420,7 @@ export const Shell: FunctionComponent = () => {
- +
diff --git a/frontend/src/plugins/action-bar/index.tsx b/frontend/src/plugins/action-bar/index.tsx index 0f6dd3ef0..986555a4b 100644 --- a/frontend/src/plugins/action-bar/index.tsx +++ b/frontend/src/plugins/action-bar/index.tsx @@ -11,13 +11,17 @@ const CONSTRUCT_INTENT = 'construct'; const MOVE_INTENT = 'move'; const COMBAT_INTENT = 'combat'; -export interface ActionBarProps extends ComponentProps {} +export interface ActionBarProps extends ComponentProps { + construct: boolean; + move: boolean; + combat: boolean; +} const StyledActionBar = styled('div')` ${styles} `; -export const ActionBar: FunctionComponent = ({}: ActionBarProps) => { +export const ActionBar: FunctionComponent = ({ construct, move, combat }: ActionBarProps) => { const { selectIntent, intent, mobileUnit, selectTiles, selectMapElement } = useSelection(); const handleSelectIntent = useCallback( @@ -44,24 +48,30 @@ export const ActionBar: FunctionComponent = ({}: ActionBarProps) return (
- handleSelectIntent(MOVE_INTENT)} - > - Move - - handleSelectIntent(CONSTRUCT_INTENT)} - > - Build - - handleSelectIntent(COMBAT_INTENT)} - > - Attack - + {move && ( + handleSelectIntent(MOVE_INTENT)} + > + Move + + )} + {construct && ( + handleSelectIntent(CONSTRUCT_INTENT)} + > + Build + + )} + {combat && ( + handleSelectIntent(COMBAT_INTENT)} + > + Attack + + )}
); From da5e5debb92fae5ff27e7f24e3fa15b784d8c29b Mon Sep 17 00:00:00 2001 From: chrisfarms Date: Sat, 11 May 2024 17:49:15 +0100 Subject: [PATCH 2/2] 40 is fine --- frontend/src/components/views/shell/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/views/shell/index.tsx b/frontend/src/components/views/shell/index.tsx index 8af791c9b..95de415ed 100644 --- a/frontend/src/components/views/shell/index.tsx +++ b/frontend/src/components/views/shell/index.tsx @@ -35,7 +35,7 @@ import { styles } from './shell.styles'; // fails for zone ids above 40. As a temporary measure to limit confusion we // will disable the construct button on these zones while we consider options // see: https://github.com/playmint/ds/issues/1402 -const isBuggyZone = (id: number) => id >= 40; +const isBuggyZone = (id: number) => id > 40; export interface ShellProps extends ComponentProps {}