dynamic radial menu build options (#1152)

## Description:
Show different build options depending on where player clicked. If they
clicked on their own territory show structures, if not show nukes &
warship.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

<DISCORD USERNAME>
This commit is contained in:
evanpelle
2025-06-12 10:13:55 -07:00
committed by GitHub
parent 22caa9c5d2
commit ef5ed59e08
@@ -3,6 +3,7 @@ import {
Cell,
PlayerActions,
TerraNullius,
UnitType,
} from "../../../core/game/Game";
import { TileRef } from "../../../core/game/GameMap";
import { GameView, PlayerView } from "../../../core/game/GameView";
@@ -309,8 +310,23 @@ export const buildMenuElement: MenuElement = {
color: COLORS.build,
subMenu: (params: MenuElementParams) => {
const buildElements: MenuElement[] = flattenedBuildTable.map(
(item: BuildItemDisplay) => ({
const unitTypes: Set<UnitType> = new Set<UnitType>();
if (params.selected === params.myPlayer) {
unitTypes.add(UnitType.City);
unitTypes.add(UnitType.DefensePost);
unitTypes.add(UnitType.Port);
unitTypes.add(UnitType.MissileSilo);
unitTypes.add(UnitType.SAMLauncher);
} else {
unitTypes.add(UnitType.Warship);
unitTypes.add(UnitType.HydrogenBomb);
unitTypes.add(UnitType.MIRV);
unitTypes.add(UnitType.AtomBomb);
}
const buildElements: MenuElement[] = flattenedBuildTable
.filter((item) => unitTypes.has(item.unitType))
.map((item: BuildItemDisplay) => ({
id: `build_${item.unitType}`,
name: item.key
? item.key.replace("unit_type.", "")
@@ -341,19 +357,7 @@ export const buildMenuElement: MenuElement = {
);
params.closeMenu();
},
}),
);
buildElements.push({
id: "build_menu",
name: "build",
disabled: () => false,
color: COLORS.build,
icon: buildIcon,
action: (params: MenuElementParams) => {
params.buildMenu.showMenu(params.tile);
},
});
}));
return buildElements;
},