mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-30 10:22:12 +00:00
Improve TribeExecution deleteAllStructures 🏛️ (#3777)
## Description: `deleteAllStructures` did not check for `isMarkedForDeletion`, not very clean. Now its clean. Also rename to `deleteNextStructure` because its not possible to delete more than 1 structure at a time. ## 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: FloPinguin
This commit is contained in:
@@ -60,7 +60,7 @@ export class TribeExecution implements Execution {
|
||||
}
|
||||
|
||||
this.acceptAllAllianceRequests();
|
||||
this.deleteAllStructures();
|
||||
this.deleteNextStructure();
|
||||
this.maybeAttack();
|
||||
}
|
||||
|
||||
@@ -83,11 +83,13 @@ export class TribeExecution implements Execution {
|
||||
}
|
||||
}
|
||||
|
||||
private deleteAllStructures() {
|
||||
private deleteNextStructure() {
|
||||
if (!this.tribe.canDeleteUnit()) return;
|
||||
for (const unit of this.tribe.units()) {
|
||||
if (Structures.has(unit.type()) && this.tribe.canDeleteUnit()) {
|
||||
this.mg.addExecution(new DeleteUnitExecution(this.tribe, unit.id()));
|
||||
}
|
||||
if (!Structures.has(unit.type())) continue;
|
||||
if (unit.isMarkedForDeletion()) continue;
|
||||
this.mg.addExecution(new DeleteUnitExecution(this.tribe, unit.id()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user