mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 09:30:45 +00:00
Fix Nations building more than allowed (#1176)
## Description: According to the code, Nations aren't meant to build more than 1 port, 2 cities, 1 missile silo. Of course they may acquire more if they conquer territory. However they are seen to be building more than for example 1 missile silo in-game. While the code checks how many of a type of unit they have, it doesn't include units currently in construction. This PR fixes that by using an existing function that includes units in construction. Note: this nerves Nations ever so slightly, so may be noticable in the meta. Although it's a bug that's already present on v23 and before, and it could be hotfixed into v23, there's something to say to leave it for v24 testing including meta changes. BEFORE:  AFTER: https://github.com/user-attachments/assets/9b1cc5ac-89f8-48d4-a399-04535e944e79 ## 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 understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: tryout33
This commit is contained in:
@@ -443,7 +443,7 @@ export class FakeHumanExecution implements Execution {
|
||||
|
||||
private maybeSpawnStructure(type: UnitType, maxNum: number): boolean {
|
||||
if (this.player === null) throw new Error("not initialized");
|
||||
const units = this.player.units(type);
|
||||
const units = this.player.unitsIncludingConstruction(type);
|
||||
if (units.length >= maxNum) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user