Skip to content

Allow construction upgrades to be placed when the construction limit is reached#14553

Draft
VictoryFirst1 wants to merge 2 commits into
triplea-game:mainfrom
VictoryFirst1:placing-construction-upgrades
Draft

Allow construction upgrades to be placed when the construction limit is reached#14553
VictoryFirst1 wants to merge 2 commits into
triplea-game:mainfrom
VictoryFirst1:placing-construction-upgrades

Conversation

@VictoryFirst1

@VictoryFirst1 VictoryFirst1 commented Jun 9, 2026

Copy link
Copy Markdown
Member

When trying to place a construction that consumes a construction with the same constructionType in a territory, and maxConstructionsPerTypePerTerr is temporarily violated because the sum of the old constructions and the new constructions exceeds this value, the engine prevents the placement of the new construction(s), even though the old construction(s) will be consumed, and resulting in no net gain of the number of constructions with that constructionType. Thus the engine should allow this as the maxConstructionsPerTypePerTerr is not technically exceeded.

Example, the factory_upgrade unit in WWII Global 1940. This unit is has constructionType 'factory', and consumes 'factory_minor' which is also labeled as 'factory'. When maxFactoriesPerTerritory is '1', the factory_upgrade cannot be placed because territories with a minor factory have the maxFactoriesPerTerritory limit reached.

This PR will allow placement of the factory_upgrade unit in this specific situation. A check is made if the new construction consumes a construction in that territory with the same constructionType. If so, the cap is increased by 1 the number of existing units in the territory with that constructionType when trying to place this unit.

Another example, you have units called "trench" and "bunker", both having constructionType "defensive_structure". "Bunker" consumes one "trench" during placement. Let's say maxConstructionsPerTypePerTerr is 6. If you have 4 trenches in a territory, the engine would formerly allow you to place only 2 bunkers in the territory. Then, there are 2 bunkers and 2 trenches in the territory, and the engine would allow you to place 2 more bunkers. If there were 6 trenches in the territory, the engine would prevent you from placing any bunkers in the territory at all.

With the PR, in the case of 4 trenches in the territory. the limit is increased to 10. Whatever the cap is, is increased by the existing number of units with that constructionType in the territory (in this case, 4 trenches). This allows you to place 6 bunkers in the territory, which is more than the required 4. When you try to place more than 4 bunkers, the engine will prevent this and show a warning message that there aren't enough units to consume.

Attempts to fix: #3359.

Notes to Reviewer

In the cases of the trenches/bunkers, ideal would be if the limit was equal to the sum of

  1. the number of units that are being placed that can consume units
  2. the number of units in the territory that are consumed by the placed units

So in the example above with the trenches/bunkers, best would be if the new cap was 8, because you could realistically only place 4 bunkers in the territory, resulting in a temporary max of 8 units. However, I don't know how to do this, so that's why I simply used "existingCount" to increase the cap with, as that will guarantee you will have enough placement slots to place all your units with a single prompt.

…is reached

When trying to place a construction that consumes a construction in a territory, while both having the same constructionType, and maxConstructionPerTerritory is reached at the time of placing, the engine prevents the placement of the new construction, even though the old construction will be consumed, thus resulting in no net gain of the number of constructions with that constructionType.

Example, the factory_upgrade unit in WWII Global 1940. This unit is labeled as 'factory', and consumes 'factory_minor' which is also labeled as 'factory'. When maxFactoriesPerTerritory is '1', the factory_upgrade cannot be placed because territories with a minor factory  have the maxFactoriesPerTerritory limit reached.

This PR will allow placement of the factory_upgrade unit in this specific situation. A check is made if the new construction consumes a construction in that territory with the same constructionType. If so, the cap is increased by 1 when trying to place this unit.
@VictoryFirst1 VictoryFirst1 marked this pull request as draft June 9, 2026 15:12
Changed the consumptionBonus from 1 to "existingCount". This way, when you have multiple units in the territory that can be consumed, you can place the new units in a single prompt. Otherwise, you would only be able to place one unit at a time. Pretty time-consuming when you have like 6. (example, trenches that can be upgraded by bunkers).

Thanks to @Cernelius for this suggestion.
@VictoryFirst1 VictoryFirst1 marked this pull request as ready for review June 9, 2026 18:20
@VictoryFirst1 VictoryFirst1 marked this pull request as draft June 10, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No limit on minor industrial complex placement.

1 participant