Add alliance renewal action to Radial Menu (#3148)

## Description:

The following PR replaces the (disabled) alliance request button with an
alliance extension/renewal button when the alliance with the target
player is expiring.

Agreeing to renewal via radial menu also hides the message in the
EventsDisplay.

<img width="369" height="364" alt="image"
src="https://github.com/user-attachments/assets/d8040f5c-ad7b-47d0-852f-925ecbf273a8"
/>


https://github.com/user-attachments/assets/aa589edf-6505-46bf-88a3-aa4c2df9137f

Icon size adjusted:

<img width="294" height="252" alt="image"
src="https://github.com/user-attachments/assets/7ca63500-b1fb-427b-965c-cf121a5213da"
/>

## 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:

deshack_82603

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Mattia Migliorini
2026-02-19 19:47:57 -06:00
committed by GitHub
co-authored by Claude Opus 4.6 coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
parent f6a08e16db
commit 90204f6628
10 changed files with 491 additions and 36 deletions
@@ -352,6 +352,112 @@ describe("RadialMenuElements", () => {
expect(allyMenu).toBeDefined();
});
it("should show extend element when inAllianceExtensionWindow is true", () => {
const allyPlayer = {
id: () => 2,
isAlliedWith: vi.fn(() => true),
isPlayer: vi.fn(() => true),
} as unknown as PlayerView;
mockParams.selected = allyPlayer;
mockGame.owner = vi.fn(() => allyPlayer);
mockPlayerActions.interaction = {
...mockPlayerActions.interaction,
canBreakAlliance: true,
allianceInfo: {
expiresAt: 100,
inExtensionWindow: true,
myPlayerAgreedToExtend: true,
otherAgreedToExtend: false,
canExtend: false,
},
};
const subMenu = rootMenuElement.subMenu!(mockParams);
const extendMenu = subMenu.find((item) => item.id === "ally_extend");
expect(extendMenu).toBeDefined();
});
it("should not show extend element when inAllianceExtensionWindow is false", () => {
const allyPlayer = {
id: () => 2,
isAlliedWith: vi.fn(() => true),
isPlayer: vi.fn(() => true),
} as unknown as PlayerView;
mockParams.selected = allyPlayer;
mockGame.owner = vi.fn(() => allyPlayer);
mockPlayerActions.interaction = {
...mockPlayerActions.interaction,
canBreakAlliance: true,
allianceInfo: {
expiresAt: 100,
inExtensionWindow: false,
myPlayerAgreedToExtend: false,
otherAgreedToExtend: false,
canExtend: false,
},
};
const subMenu = rootMenuElement.subMenu!(mockParams);
const extendMenu = subMenu.find((item) => item.id === "ally_extend");
expect(extendMenu).toBeUndefined();
});
it("should show extend element as disabled when canExtend is false", () => {
const allyPlayer = {
id: () => 2,
isAlliedWith: vi.fn(() => true),
isPlayer: vi.fn(() => true),
} as unknown as PlayerView;
mockParams.selected = allyPlayer;
mockGame.owner = vi.fn(() => allyPlayer);
mockPlayerActions.interaction = {
...mockPlayerActions.interaction,
canBreakAlliance: true,
allianceInfo: {
expiresAt: 100,
inExtensionWindow: true,
myPlayerAgreedToExtend: true,
otherAgreedToExtend: false,
canExtend: false,
},
};
const subMenu = rootMenuElement.subMenu!(mockParams);
const extendMenu = subMenu.find((item) => item.id === "ally_extend");
expect(extendMenu).toBeDefined();
expect(extendMenu!.disabled(mockParams)).toBe(true);
});
it("should show extend element as enabled when canExtend is true", () => {
const allyPlayer = {
id: () => 2,
isAlliedWith: vi.fn(() => true),
isPlayer: vi.fn(() => true),
} as unknown as PlayerView;
mockParams.selected = allyPlayer;
mockGame.owner = vi.fn(() => allyPlayer);
mockPlayerActions.interaction = {
...mockPlayerActions.interaction,
canBreakAlliance: true,
allianceInfo: {
expiresAt: 100,
inExtensionWindow: true,
myPlayerAgreedToExtend: false,
otherAgreedToExtend: false,
canExtend: true,
},
};
const subMenu = rootMenuElement.subMenu!(mockParams);
const extendMenu = subMenu.find((item) => item.id === "ally_extend");
expect(extendMenu).toBeDefined();
expect(extendMenu!.disabled(mockParams)).toBe(false);
});
});
describe("Menu element actions", () => {