Get all civwide unit discount uniques once, and then filter them by-conditional only when checking each specific unit.
This saves a LOT of memory allocation and time.
A result of the investigation at #5919.
* Since we have the old unique typed, and the new replacement unique typed, we can show modders EXACTLY the new unique they'll need to have!
The final step of this process is having a 'replace old uniques' button which will automagically replace old uniques in a mod with the new versions. This will of course require some manual intervention since it's possible we added some parameters that didn't exist in the old one, but should work well for 95%+ of uniques.
* Also allow "[-amount]" replacements
Better replacements - "[+amount]" etc - where relevant
* Fixed misadded + in unique
* Caught more mod failure conditions, removed certain assumptions from map creation
* Military unit in Era can be "Era Specific Unit"
* Resolved#6078 - even more ruleset assumptions removed :)
* We now catch missing military units from the difficulties as well, as well as missing settler and worker units from eras
* Possibly fixed a crash accessing gameInfo before it is initialized
* Inlined an otherwise unused variable
* Alternative version using an extra constructor instead of weird getters/setters
* Current map generation is extremely dependant on specific terrains existing in the ruleset.
This attempts to eliminate those dependencies.
All changes indicate areas where a crash occured before the change.
I still encounter problems in generateRegions when trying to generate a map with no water tiles - @SimorCedar I think the splitRegion doesn't like the fact that there are land tiles on edges of the map?
* Split 'equal fertility' regions as close to the center as possible
Also, don't crash if no luxury resources are defined
The cost of casting getEra() constantly is definitely non-trivial, and why do we even generate the era every time? It only changes when we add a new tech! So we can save it as a transient in the civInfo.tech and be done with it!
* Step 1 - converted stat bonus list to tree.
No visual difference yet, since the stat bonus list is still generated in the same way.
* Step 2 - updateStatPercentBonusList converted to tree form
* Step 3 - buildings converted to tree form - now user visible!
* Step 4 - Bonuses from uniques are now drilldownable
* Removed unneeded todo
* Welp, turns out I forgot to apply conditionals
Due to changes since that was written, the cityInfo.getMatchingUniques has a default parameter of 'local uniques that are of the unique type', so not only was it making a mess, it was also inefficient!
* Added a json file for unhappiness effects
* Change existing code to handle these effects
* Made a weird and unexpendable way to add unhappiness effects to the civilopedia
* Add the default unhappinesseffects to mods without the json
* Added revolts when at very low happiness
* Renamed a few often-used functions
* Added a file for uniques that are always active
* Fixed tests
* Nullifies [Food] -> Nullifies Growth
* Initial attempt
* Allow Ranged to move into unguarded Civilian Unit
* Comment for clarity
* Fix unit test so that it doesn't segfault and checks you can't move into military units
* Unify that all units can move on to (and through) unguarded civilians that you are at war with
Add TileInfo.getUnguardedCivilian() to quickly respond if there is an unguarded Civilian on the tile
Something is bugged in movement code
* Fix MapUnit.moveThroughTile() so that it doesn't segfault by fixing getUnguardedCivilian()
* captureCivilianUnit() call is now redundant in postBattleMoveToAttackedTile() since canMoveTo() will now return true and capture will happen during the moveToTile() call
Co-authored-by: temurakami <spellman23@gmail.com>
* Converted stat list to stat tree - current changes do not affect UI at all, since we're still going by the shallow mapping that existed beforehand
* Display details of both buildings and uniques
* Unique stats now add correctly to building base stats, good thing we have tests :)
* Stat details are now click-to-expand, and calculate correctly :)
* Added small +/- button to show it's expandable
* Typed some uniques, etc.
* Missed a few square braces
* Missed a parameter
* Missed another parameter
* Made a conditional, spelling, added check to `isStatRelated`
Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
This also means we don't need a special coastal check, since it's caught by the regular check
IIRC there are nations in Original Civ that have 'mountain' start bias - if so this will also enable that :)
* Remove unused Constants.
* Remove outdated comments.
* Typified "Will not be displayed in Civilopedia" Unique.
* Fix pre-existing inconsistency that would display religious UBs with broken links in the Civilopedia when religion was disabled.
* Use Sequences, and fewer function params, in Nations' Civilopedia texts.
* Accidentally hid a Unique that should be visible.
* Oops… Missed a negation.
* Unhide limitations on Religious Ruin rewards— But I'm not sure they'll be displayed anywhere even so.
* Typified some building uniques
I noticed that the code allows "[stats] from every [buildingFilter]" but the UniqueType was limited to "[stats] from every [buildingName]", so now that that's available we don't actually need the "[stats] from every Wonder" unique :)
* buildings-only unique moved to buildings section
* Make unknown nation placeholder translatable.
* Make MultiplayerScreen help button clearer and translatable.
* Use `Constants.spectator` more.
* Make random/unknown nation icon translatable.
I tested this out with RekMOD, 150 simulated turns, to see if this was working.
Not only did I discover that workers were squatting on Antiquity Sites since they had resource improvements that they couldn't build, I also discovered something much worse.
Even after fixing that, most cities were woefully underimproved.
Turns out, the construction automation would limit worker construction to a measly *3 workers* even for a *10 city* civ!
After removing this limitation and making civs aim for a 1:1 ratio between cities and workers, everything started looking much, much better.
I'm not sure what the exact effect on the AI will be but I'm _sure_ that this leads to a major improvement. More improved tiles means more stats means more everything.
I came to the mod management screen to add a functionality to download the latest version of an installed mod by adding a 'download latest version' button to its action menu.
I did not expect the code to be this intractable. I've been reading and writing Kotlin daily for the past 5 years now, and even I struggle to understand what's going on here.
(also instead of adding button and counting duplicate entries just to remove them from both UI and count, just - don't add them to begin with)
The same change we made in the move to getStatsFromUniquesBySource()
This should be faster, more generic, more accurate (buildings vs wonders), and catch all usecases (i.e. stat bonuses from uniques attached to *techs* or who knows what else
* Worker AI for mods, step 2
Support for removing terrain features, both when we need to get rid of them for a resource, and when they plain reduce the yield of a tile
Note that the "Remove <improvement>" was implemented WAY before templating and uniques were a thing - the correct solution in these enlightened times would be to separate the improvement *name* from the *effect*, so we could have e.g. a "Deforestation" improvement which would contain botth ["Removes [Jungle]", "Removes [Forest]"] or whatnot.
For now I Constant'D the "Remove " so we can at least follow where it's used.
* Reverted some of the auto-formatting so the PR is cleaner
* Caught 'nullify yields' unique for terrain removal
* Use toTextButton for WorldScreenTopbar "Overview".
* Use toTextButton for AddMultiplayerGameScreen "Paste gameID from clipboard".
* Use toTextButton in MultiplayerScreen.
* Use toTextButton for CityOverviewTable city.name.
Current worker automation assumes A LOT about the current ruleset.
This is only step 1, which allows skipping irrelevant improvements to reach actually useful improvements.
Comments welcome.
The NewGameScreen was written by a past version of myself that had no idea how to handle threading, and thus was extremely strange. Checking an object _on render_ and if it's set then activate? Totally clueless.
* Simplified conditional checks - where I felt it would make it more readable.
Also added checks to ensure that era exists when checking era.
* Now passes tests
* Simplified unit tile checks
* Add crashHandlingThread.
* Replace all uses of `thread` with `crashHandlingThread`.
* Add `postCrashHandlingRunnable`.
* Replace all uses of `Gdx.app.postRunnable` with `postCrashHandlingRunnable`.
* Remove CrashController and CrashReport; Strip down CrashReportSender to CrashReportSysInfo; Fold their functionality into CrashScreen.
* Typo in comments, rename `SafeCrashStage` to `CrashHandlingStage`.
* Tweak docs.
* Tweak docs, comments, text. Undo an accidentally recursive Replace All change.
* Remove replaced translations.
* More readable indentation handling in report template.
* Expanded the buildingFilter to include options national wonders
* Also instruct the translation file writer on the changes
* Typo
* Non-national -> World
* Disables '[cityState] is afraid of your military power' for spectators
* Do the same for a few other similar notifications
* And more, for patronage complete policy
* Print stacktraces in more cases when crashing, useful for debugging
* Conditionalized no oceans before astronomy unique
* Cannot be built on tile before tech conditionalized
* Added "Cannot build unitFilter units" unique
* Fixed tests failing
* Merge branch master into some-uniques
* Fixed typo
* Apparently I made the same mistake twice
* Globalized unique
* Fixed a rare bug where in one-more-turn mode after conquering all other civs, players could be asked to vote, despite having no one to vote for
* Removed code duplication
* Fixed a bug where bonusses applying 'in friendly tiles' would not apply
* Reworded something so it actually makes sense
* Fixed capitalization error leading to autocracy complete bonus no longer working
* Fixed save serialization errors and finally correctly implemented the time limit for autocracy bonus
* Made value const and static
* Show arrows on map for unit actions.
* Don't wrap arrows unless world wrap is actually enabled.
* Fix transported air units always being treated like teleports.
* Simple reviews.
* Separate movement arrow visibility checks from WorldScreen.
* Assets for map arrows overlay.
Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
* Show arrows on map for unit actions.
* Don't wrap arrows unless world wrap is actually enabled.
* Fix transported air units always being treated like teleports.
* Simple reviews.
* Separate movement arrow visibility checks from WorldScreen.
Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
* Converted the time victory drop down to a slider, idea courtesy of SomeTroglodyte
* Added a score breakdown to stat overview screen
* Removed score factors with value 0 & applied SomeTroglodyte's patch
* Removed 2000 max turns, should never be reached anyways
* Added a score calculation
* Added the score in multiple places of the UI
* Added time victory and a max turns
* Made time victory functional
* Added translation files
* Add new crash handler and error reporting screen.
* Minor cleanup.
* Word choice.
* Rename `SafeCrashStage` to `CrashHandlingStage`.
* Reviews.
* Reference stack traces in comments for thread and postRunnable exceptions.
* Remove excessive line breaks, superfluous .apply{}.
* Changed 'in [tileFilter] tiles' to also apply outside of combat
* Changed unique docs writer to also sort applicables, so these are also not regenerated constantly
* Fixed an infinite loop where foreign legion upgraded to the unit it replaced
* Changed the wrong variable
* Maybe it is useful to also change its unlock tech
* Whoops, should only be for non-null values
* Add new UniqueType.NoMaintenance to support Guided Missile
* revert gradle
Add UnitMaintenanceDiscount
Rename UnitMaintenanceDiscount->UnitMaintenanceDiscountGlobal
Rework maintenance equation to account for overlapping reductions
Add maintenance variable to MapUnit
* Add square brackets in string (apparently didn't check in?)
More robust uniques check code so not assuming only one matching unique
Use toPercent()
* Proper toPercent() math
* Use fixed point Long to help in sorting to avoid float bug?
* Use fixed point Long to help in sorting to avoid float bug?
Co-authored-by: temurakami <spellman23@gmail.com>
* Added necessary utils
Added the FileNotFoundException which is also part of #5593
* Added preview download to MultiplayerScreen
* Added preview download to TurnChecker
* Fixed uncomplete commit
* Removed debug print in MultiplayerScreen
* First pull request to add missionaries and inquisitors
* First pull request to add missionaries and inquisitors
* First pull request to add missionaries and inquisitors
* First pull request to add missionaries and inquisitors
* Ai choice
* some fixes
* some fixes
* adding a system for the ai to buy with faith
* adding a system for the ai to buy with faith
* adding a system for the ai to buy with faith
* adding a system for the ai to buy with faith
* adding a system for the ai to buy with faith
* adding a system for the ai to buy with faith
* adding a system for the ai to buy with faith
* adding a system for the ai to buy with faith
* adding a system for the ai to buy with faith
* adding a system for the ai to buy with faith
* adding a system for the ai to buy with faith
* finally done
* finally done
* some fixes
* some fixes
* some fixes
* some fixes
* some fixes
* some fixes
* some fixes
* Add support to UniqueType.MaxNumberBuilding (including rejectionReasons)
Add Recycling Center entry to JSON
Need Graphical Icon
* Fix typo
Add TODO
* adding Recycling Center icon
* Credit update for icon
Rephrase Rejection text
Updated .atlas and .png
Add code to block showing Recycling Center
* Fix using placeholderText
Set shouldShow to True so iot still appears while under construction but not completed
* Rejection Text now working
Remove debug prints
* Remove odd extra lines
* extra lines
* Remove excessive if statement in shouldBeDisplayed
Reword text. Unique can apply to Buildings and Units
Refactor Signature since not just Buildings
* Adding code to remove building in transferred city
Co-authored-by: temurakami <spellman23@gmail.com>