maxBuiltPerPlayer error resets Purchase UI (was How to limit the number of units purchased)
I am looking for a solution to limit the number of units which can be purchased.
Ex: Japanese player can only build a maximum of 1 carrier per turn and has a piece limit of 6 armor.
Is there a way to display the summary of a players unit count per unit type ?
The maxBuiltPerPlayer unitType option can be used to implement piece limits:
- However unlike when you don't have enough PUs, maxBuiltPerPlayer isn't directly applied to the purchase interface. You only get an error message (informing about the current limit) after the purchasing is complete, and the purchase interface is then reset to 0, which isn't user friendly.
- I suppose it would be possible to implement this with a system of unit tokens (as a ressource) but it would be rather complicated
<attachment name="unitAttachment" attachTo="artillery" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <option name="maxBuiltPerPlayer" value="15"/> <option name="placementLimit" value="owned" count="10"/> </attachment>
Would it be possible to implement a maxBuiltPerPlayerPerTurn unitType option which could be applied to the Purchasing interface ?
A placementLimit can be used to avoid huge stacks, but it doesn't prevent from purchasing the units (you just can't place them).
TheDog last edited by
#4. For avoiding huge stacks Im a big fan of upkeep/maintenance using
<option name="createsResourcesList" value="-1:PUs"/>
for each unit.
TorpedoA last edited by
@thedog Not only to avoid huge stacks. The whole game is much more open. In the sense that if you loose a big army, you free up alot of PUs per turn.
Because without upkeep, one big battle loss or win, is too cruicial. I had alot of those situations in the far past, where i did still play without upkeep vs AI on NWO maps, and if you loose that one battle where the most hp/units clashed, if i then lost this, i just started a new game. There was often no chance coming back.
With upkeep now, i have no huge stacks and every battle is just a battle and not the war that you can loose.
Furthermore, the gap between cost per hp is much more dimished, the longer the game goes.
Never again without upkeep.
@butterw You could create a specialized factory type, with a capacity of 1 that can only build carriers and don't let regular factories build carriers.
Sounds correct: a custom Factory can be used.
The extra complexity is maybe not warranted in this example, given the high cost of purchasing an aircraft carrier.
My main issue is that maxBuiltPerPlayer piece limits aren't applied in the Purchase interface (the purchase is reset if you have gone beyond the limit) and there doesn't seem to be any way to get info on the current number of pieces used.
By contrast, when you buy more units than you can place you get the following warning after the purchase (the purchase info is not reset):
End Purchase: You have purchased 13 units, and can only place 8 of them. Continue with Purchase ?
@butterw I agree that a better interface would be good, but build limits work and are even supported by the AI. The original 1981 edition of A&A limited players to the counter mix.
@butterw said in How to limit the number of units purchased in a turn ?:
- Is there a way to display the summary of a players unit count per unit type ?
Per player Unit type count history is available in the export game stats csv file. This info doesn't seem to be available anywhere else.
A fix to the User Interface for purchases with maxBuiltPerPlayer limits is needed
- Attempting to buy above the maxBuiltPerPlayer piece-limits, results in an error and a complete reset of the planned purchases: you have to start over which is very frustrating.
- This is made worse by the fact that the current number of piece is not known beforehand by the player (the only way to know is by getting the error).
- At the end of the game it is expected multiple limits (ex: infantry because it is cheapest unit, armour because the japanese piece limit is low, fighters) will be hit every turn. This will result in a purchase reset for each limit.
- Currently the player has to test each limit, get errors and remember the values to know what he can actually purchase for the turn.
PurchaseDelegate.java "May only build "
- Planned purchase should not be completely reset if a limit is hit.
- The error message should provide status on all the player's maxBuiltPerPlayer limits.
- Instead of a final error it should be a warning tested each time the Purchase interface is validated with Done (like when you attempt to purchase beyond production capacity).
**EDIT: ** As suggested by @TheDog displaying the max which can be purchased for each unit type in the purchase interface might be an easier/better fix
ex: Infantry (7)
TheDog last edited by
Another suggestion, show how many can be bought, as in the image below;
So a maximum of 2 Wizards and 3 Sorcerers can be can be purchased, the rest are unlimited, to the PU available.
If the red numbers were 0 then, 0 can be purchased.
@thedog Why not show the total number of pieces you already have of each type regardless of the maxBuilt property? That can be useful for planning purposes.
Using the max button would be the best way to prevent going above maxBuiltPerPlayer-currentlyBuilt.
To display the players currentlyBuilt units the produce tooltip or an extra value could be could be added to the unit name or info label.
The unit count gets redone everytime the production panel is opened (in fact it gets redone twice, probably because of the tabs), but otherwise my mod seems to be working ok.
I'm struggling to find a word to describe the maxBuiltPerPlayer-unitCount value in the UI.
I've used "Left" or "Available", but maybe "to piece-Limit" or just "limit" would be preferable (producing beyond the piece-limit isn't allowed) ?
I would also like to feature the Production Capacity (ex: 13 units), I've modified the bottom label to display:
0/13 total units purchased.
The improved Production Panel is available in my test build v3.5.1-bu:
see also: https://github.com/triplea-game/triplea/issues/9231