Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable construct intent for buggy zones #1403

Merged
merged 2 commits into from
May 11, 2024
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
9 changes: 8 additions & 1 deletion frontend/src/components/views/shell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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')`
Expand Down Expand Up @@ -63,6 +69,7 @@ export const Shell: FunctionComponent<ShellProps> = () => {
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<boolean>(true);
Expand Down Expand Up @@ -413,7 +420,7 @@ export const Shell: FunctionComponent<ShellProps> = () => {
<div className="flex-spacer"></div>
<div className="bottom-middle">
<ActionContextPanel pluginTileProperties={pluginTileProperties} />
<ActionBar />
<ActionBar move={true} combat={true} construct={!isBuggyZone(zoneId)} />
</div>
<div className="flex-spacer"></div>
</div>
Expand Down
50 changes: 30 additions & 20 deletions frontend/src/plugins/action-bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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> = ({}: ActionBarProps) => {
export const ActionBar: FunctionComponent<ActionBarProps> = ({ construct, move, combat }: ActionBarProps) => {
const { selectIntent, intent, mobileUnit, selectTiles, selectMapElement } = useSelection();

const handleSelectIntent = useCallback(
Expand All @@ -44,24 +48,30 @@ export const ActionBar: FunctionComponent<ActionBarProps> = ({}: ActionBarProps)
return (
<StyledActionBar>
<div className="actions">
<UnitActionButton
className={`${intent === MOVE_INTENT ? 'toggleOn' : ''}`}
onClick={() => handleSelectIntent(MOVE_INTENT)}
>
Move
</UnitActionButton>
<UnitActionButton
className={`${intent === CONSTRUCT_INTENT ? 'toggleOn' : ''}`}
onClick={() => handleSelectIntent(CONSTRUCT_INTENT)}
>
Build
</UnitActionButton>
<UnitActionButton
className={`${intent === COMBAT_INTENT ? 'toggleOn' : ''}`}
onClick={() => handleSelectIntent(COMBAT_INTENT)}
>
Attack
</UnitActionButton>
{move && (
<UnitActionButton
className={`${intent === MOVE_INTENT ? 'toggleOn' : ''}`}
onClick={() => handleSelectIntent(MOVE_INTENT)}
>
Move
</UnitActionButton>
)}
{construct && (
<UnitActionButton
className={`${intent === CONSTRUCT_INTENT ? 'toggleOn' : ''}`}
onClick={() => handleSelectIntent(CONSTRUCT_INTENT)}
>
Build
</UnitActionButton>
)}
{combat && (
<UnitActionButton
className={`${intent === COMBAT_INTENT ? 'toggleOn' : ''}`}
onClick={() => handleSelectIntent(COMBAT_INTENT)}
>
Attack
</UnitActionButton>
)}
</div>
</StyledActionBar>
);
Expand Down
Loading