mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-02 16:18:06 +00:00
Improve alliance UX, prevent hung alliance requests (#1868)
## Description: This PR does two things: 1. Allows you to send an alliance request to approve an existing request, ex: * player A sends req to player B * now player B can send an ally request to player A, which accepts the request from player A. This way even if you lose or don't see the alliance notification, you can still accept the alliance. 2. Have AllianceRequestExecution reject the request if not accepted or rejected. There is a bug where sometimes the EventDisplay does not trigger the delete() function, resulting in hung alliance requests. I couldn't figure out why the delete() function is sometimes not called, but I think it's better design to have core/ itself handle abandoned alliance requests, this was UI bugs can't break the game state. ## Please complete the following: - [ ] I have added screenshots for all UI updates - [ ] I process any text displayed to the user through translateText() and I've added it to the en.json file - [ ] I have added relevant tests to the test directory - [ ] 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: evan
This commit is contained in:
@@ -66,6 +66,7 @@ interface GameEvent {
|
||||
duration?: Tick;
|
||||
focusID?: number;
|
||||
unitView?: UnitView;
|
||||
shouldDelete?: (game: GameView) => boolean;
|
||||
}
|
||||
|
||||
@customElement("events-display")
|
||||
@@ -195,7 +196,8 @@ export class EventsDisplay extends LitElement implements Layer {
|
||||
|
||||
let remainingEvents = this.events.filter((event) => {
|
||||
const shouldKeep =
|
||||
this.game.ticks() - event.createdAt < (event.duration ?? 600);
|
||||
this.game.ticks() - event.createdAt < (event.duration ?? 600) &&
|
||||
!event.shouldDelete?.(this.game);
|
||||
if (!shouldKeep && event.onDelete) {
|
||||
event.onDelete();
|
||||
}
|
||||
@@ -456,12 +458,12 @@ export class EventsDisplay extends LitElement implements Layer {
|
||||
highlight: true,
|
||||
type: MessageType.ALLIANCE_REQUEST,
|
||||
createdAt: this.game.ticks(),
|
||||
onDelete: () =>
|
||||
this.eventBus.emit(
|
||||
new SendAllianceReplyIntentEvent(requestor, recipient, false),
|
||||
),
|
||||
priority: 0,
|
||||
duration: 150,
|
||||
duration: this.game.config().allianceRequestDuration() - 20, // 2 second buffer
|
||||
shouldDelete: (game) => {
|
||||
// Recipient sent a separate request, so they became allied without the recipient responding.
|
||||
return requestor.isAlliedWith(recipient);
|
||||
},
|
||||
focusID: update.requestorID,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user