mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 15:40:43 +00:00
936928fed9
## Description: Adds **Enter** and **Numpad Enter** as confirmation for placing a ghost structure after selecting a building with hotkeys (1–0 or numpad). Players can cancel with Esc but previously had to click to confirm; they can now confirm with Enter or Numpad Enter at the current cursor position. This supports keyboard-only or mouse + numpad workflows (e.g. one hand on numpad for select + confirm, one on mouse for aiming). ## 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 ## Please put your Discord username so you can be contacted if a bug or regression is found: .wozniakpl
39 lines
1.9 KiB
TypeScript
39 lines
1.9 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
import { shouldPreserveGhostAfterBuild } from "../../../../src/client/graphics/layers/StructureIconsLayer";
|
|
import { UnitType } from "../../../../src/core/game/Game";
|
|
|
|
/**
|
|
* Tests for StructureIconsLayer edge cases mentioned in comments:
|
|
* - Locked nuke / AtomBomb / HydrogenBomb: when confirming placement (Enter or key),
|
|
* the ghost is preserved so the user can place multiple nukes or keep the nuke
|
|
* selected. Other structure types clear the ghost after placement.
|
|
*/
|
|
describe("StructureIconsLayer ghost preservation (locked nuke / Enter confirm)", () => {
|
|
describe("shouldPreserveGhostAfterBuild", () => {
|
|
test("returns true for AtomBomb so ghost is not cleared after placement", () => {
|
|
expect(shouldPreserveGhostAfterBuild(UnitType.AtomBomb)).toBe(true);
|
|
});
|
|
|
|
test("returns true for HydrogenBomb so ghost is not cleared after placement", () => {
|
|
expect(shouldPreserveGhostAfterBuild(UnitType.HydrogenBomb)).toBe(true);
|
|
});
|
|
|
|
test("returns false for City so ghost is cleared after placement", () => {
|
|
expect(shouldPreserveGhostAfterBuild(UnitType.City)).toBe(false);
|
|
});
|
|
|
|
test("returns false for Factory so ghost is cleared after placement", () => {
|
|
expect(shouldPreserveGhostAfterBuild(UnitType.Factory)).toBe(false);
|
|
});
|
|
|
|
test("returns false for other buildable types (Port, DefensePost, MissileSilo, SAMLauncher, Warship, MIRV)", () => {
|
|
expect(shouldPreserveGhostAfterBuild(UnitType.Port)).toBe(false);
|
|
expect(shouldPreserveGhostAfterBuild(UnitType.DefensePost)).toBe(false);
|
|
expect(shouldPreserveGhostAfterBuild(UnitType.MissileSilo)).toBe(false);
|
|
expect(shouldPreserveGhostAfterBuild(UnitType.SAMLauncher)).toBe(false);
|
|
expect(shouldPreserveGhostAfterBuild(UnitType.Warship)).toBe(false);
|
|
expect(shouldPreserveGhostAfterBuild(UnitType.MIRV)).toBe(false);
|
|
});
|
|
});
|
|
});
|