mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-30 04:07:18 +00:00
Add button for remove building (#1609)
## Description: Added a red delete button with trash can icon to the right-click radial menu that allows players to voluntarily delete their own units. ## 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 have read and accepted the CLA agreement (only required once). ## Please put your Discord username so you can be contacted if a bug or regression is found: Kipstz <img width="286" height="209" alt="image" src="https://github.com/user-attachments/assets/85142be3-2aa5-4c84-ab30-0c68289c8f85" /> --------- Co-authored-by: Drills Kibo <59177241+drillskibo@users.noreply.github.com>
This commit is contained in:
@@ -95,6 +95,8 @@ export class PlayerImpl implements Player {
|
||||
|
||||
private relations = new Map<Player, number>();
|
||||
|
||||
private lastDeleteUnitTick: Tick = -1;
|
||||
|
||||
public _incomingAttacks: Attack[] = [];
|
||||
public _outgoingAttacks: Attack[] = [];
|
||||
public _outgoingLandAttacks: Attack[] = [];
|
||||
@@ -632,6 +634,17 @@ export class PlayerImpl implements Player {
|
||||
return true;
|
||||
}
|
||||
|
||||
canDeleteUnit(): boolean {
|
||||
return (
|
||||
this.mg.ticks() - this.lastDeleteUnitTick >=
|
||||
this.mg.config().deleteUnitCooldown()
|
||||
);
|
||||
}
|
||||
|
||||
recordDeleteUnit(): void {
|
||||
this.lastDeleteUnitTick = this.mg.ticks();
|
||||
}
|
||||
|
||||
hasEmbargoAgainst(other: Player): boolean {
|
||||
return this.embargoes.has(other.id());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user