Commit Graph

285 Commits

Author SHA1 Message Date
SomeTroglodyte
987f67d9cd
[code quality] Reorg, clean up and comment a few things (#10527)
* UncivGame is a pure class file again, GUI split off

* Purify GameSettings step 1 - non-multiplayer nested classes

* Purify GameSettings step 2 - multiplayer nested classes

* Purify GameParameters - BaseRuleset to own file

* Rework WindowState to centralize minimum/maximum treatment

* Rename MultiplayerTurnNotifierDesktop to UncivWindowListener

* Clarifications on what the WindowListener actually does (and now the attention-getting does something on non-Windows too)
2023-11-19 23:52:15 +02:00
Yair Morgenstern
fb1e57668e Added tests for parameters for complex filters, fixed nested complex filter returning 'possible filtering' when it should have been known 2023-11-19 00:06:34 +02:00
Framonti
8c9e6b07e0
Test/add tests for cityexpansionmanager (#10510)
* improve error message and add test for precondition checking

* add tests for CityExpansionManager
2023-11-18 22:34:26 +02:00
Yair Morgenstern
dc6413d707 Modding: Added "non-[filter]" filtering for unit filters
Cleaned up unit filter validations to match actual filters
2023-11-18 22:16:43 +02:00
SomeTroglodyte
cfeed82800
Whitespace linting for opening curly braces and inheritance colon (#10490) 2023-11-13 22:11:55 +02:00
Framonti
02844e51d7
add tests for CityFounder (#10439)
* 🎨 add spaces to better format code

*  add tests for CityFounder

* ️ exploit early returns to avoid computing some values
2023-11-07 10:39:34 +02:00
Framonti
e9b3ec5282
fix flaky tests by properly assigning pop to work on specific tile (#10421) 2023-11-04 21:24:26 +02:00
Yair Morgenstern
e43d870b43 Fastlane fixes 2023-10-30 12:43:28 +02:00
Yair Morgenstern
f9134c90dc @Framonti
This test seems to be flaky - works from my computer but fails sometimes on github
2023-10-30 11:11:11 +02:00
Framonti
f27fa7bab6
💚 add tests for city population manager (#10347) 2023-10-29 18:59:38 +02:00
SomeTroglodyte
13e3baac74
Split Fonts.kt (#10267)
* Fix font "symbols" not showing

* Move Fonts.kt to sub-package

* Re-sort imports

* Move top-level constants to prepare split

* Split Fonts.kt each existing class to its own file

* Split off FontRulesetIcons

* Linting and comments
2023-10-08 22:03:53 +03:00
Yair Morgenstern
2bd65f9f42 chore: Extracted all 'next turn' logic from DiplomacyManager to DiplomacyTurnManager 2023-10-08 11:48:33 +03:00
SomeTroglodyte
49e2979427
Align ruleset icons in text to font metrics (#10233)
* Try to respect actual font layout, so fontSizeMultiplier works for ruleset icons too

* Replace font-based nation symbol in top bar with statically sized actor

* Reuse getReadonlyPixmap in extractPixmapFromTextureRegion

* Tweak topbar selected civ vertical align to be more pleasing to the human eye

* FasterUIDevelopment missing implementation of FontMetricsCommon

* Address hardcoded pixel coordinates comment

* Readability and comment cleanup

* More readability changes
2023-10-07 22:00:30 +03:00
SomeTroglodyte
5db8489bcb
Tweak FasterUIDevelopment to offer normal Scene2D debugging, and some linting (#10263) 2023-10-07 21:58:19 +03:00
Framonti
3a3abd20fa
add golden age manager tests (#10226)
* 🚚 move test to right package

* 💚 add tests for golden age manager
2023-10-03 13:04:44 +03:00
SeventhM
98533b91f9
Reimplement and fix #10142 (#10213)
* Test Free Buildings

* Flip the order of logging free buildings to avoid loops with stat buildings

* unprivate constructionComplete for the notification and add validating the queue to addBuilding

* reimplement #10142

* Switch free buildings in cityFilter to also use constructionComplete for consistency
2023-10-03 12:10:43 +03:00
Framonti
b01353eee7
Test city conquest functions (#10196)
* 💚 add tests covering most city conquest functions

* ♻️ change var to val when values don't change
2023-09-29 16:27:43 +03:00
Yair Morgenstern
190d488c06 modding: Mod checker displays *all* unknown uniques 2023-09-28 20:46:31 +03:00
Yair Morgenstern
d1b2d652e3 reorg: Separated UnitActions into 3 files:
- UnitActionsFromUniques
- UnitActionModifiers
- UnitActions retains actions relevant to all units
2023-09-28 15:30:39 +03:00
Yair Morgenstern
b6f3c8571f chore: Move files to correct folders 2023-09-27 13:19:13 +03:00
Yair Morgenstern
0d942ac175 Reload images when downloading or removing a mod 2023-09-21 14:58:23 +03:00
Framonti
26bae52508
💚 add tests covering most nukes functionalities (#10146) 2023-09-19 10:31:39 +03:00
Framonti
fba3198887
Unit tests for Battle.kt (#10127)
*  add testing helper function to create the barbarian civilization

* add tests for Battle class

* add more tests for Battle class

* ♻️ let compiler infer types

* add helper test methods to create unit with uniques

* use unit with unique explicitly created to loose tests from specific ruleset

* add even more tests for Battle
2023-09-14 18:53:40 +03:00
Oskar Niesen
ee81b3e84e
Defensive pact Tests (#10088) 2023-09-11 09:06:09 +03:00
Framonti
885675bea3
💚 add tests for Diplomacy manager (#10087) 2023-09-09 21:27:03 +03:00
Yair Morgenstern
30570747a8
Unify placeholder parsing for unique parameters (#10072)
* Unify placeholder parsing for unique parameters

* Remove double "remove conditional" call - kudos @SomeTroglodyte
2023-09-07 09:57:40 +03:00
Yair Morgenstern
55a3fa2a75 cleanup: Copy Zero vectors before passing to localToStageCoordinates (#10048) 2023-09-06 12:38:14 +03:00
Framonti
538330db87
Test/refactor target helper and test it (#10048)
* ♻️ merge together two branches executing same code

* ♻️ swap if-else chain with when to improve readability

* ️ swap conditions to first check the lighter computationally-wise

* ♻️ extract method to increase readability

* 💚 add some tests for TargetHelper

* 💡 add comment explaining how Unciv grid system works using a graphical example

* 💚 add other tests

* ♻️ change method name to better reflect what it does

* 🐛 fix import after rebase

* 🔥 remove parameter when value is the default and use static field for Vector2(0f, 0f)

* ♻️ split setTileTerrainAndFeatures in two different methods

* ♻️ update older tests to use the new functions
2023-09-05 22:25:28 +03:00
Yair Morgenstern
93f882d3c8 tests: Load vanilla game test fixed 2023-09-04 17:08:52 +03:00
Yair Morgenstern
df03f36207 chore: Added missing imports 2023-09-04 16:09:55 +03:00
Yair Morgenstern
f4c7dc4890 chore: Reorg tests, so /testing folder contains only test-helper classes 2023-09-04 16:06:06 +03:00
Framonti
7952366afb
Refactor BattleDamage object and test it (#9992)
* 💡 add some comments providing examples

* ♻ refactor getGeneralModifiers to increase readability

* ♻ refactor getAttackModifiers to increase readability

* 🏗 move constants expressed as magic number to separated class to increase maintainability and expressivity

* ♻ invert condition to remove continue statement and simplify code

* 💚 add some tests for battle damage class
2023-08-30 23:37:10 +03:00
Yair Morgenstern
5585dfa470 Resolved #10005 - Great person points for units not in ruleset are ignored, and warned against 2023-08-30 23:10:14 +03:00
SeventhM
bda3215006
Refactor: Remove unnecessary ruleset checks (#9973)
* address unnecessary ruleset checks

* Add missing imports

* Fix units not getting the ability uses set if it the city has your own religion

* Remove unnecessary cityConstructions check

* Remove more cases of unnecessary ruleset checks
2023-08-27 22:48:20 +03:00
Framonti
53748a40d7
Add tests for city class and introduce small refactor (#9965)
* ♻ extract methods to improve readability

* 💚 introduce tests for city logic
2023-08-24 17:14:02 +03:00
SeventhM
67adabb78f
Additional unit tests (#9866)
* Additional unit tests

* Missing import

* Changing stuff solely to avoid an import

* Example of the test, in different orders

* New PromotionTree test

* Add functions to make PromotionTree easier to work with

* Changing values to be lateinit variables
2023-08-17 09:17:23 +03:00
Yair Morgenstern
0561a7951c Much more accurate improvement stat effects 2023-08-09 00:46:33 +03:00
Yair Morgenstern
60ea752c1f chore: Modernized DiplomacyManagerTests 2023-08-08 23:55:37 +03:00
Yair Morgenstern
3cbd447620 Removed HandleImprovementCompletion function, added test for citadel tile takeover 2023-08-08 22:00:18 +03:00
Yair Morgenstern
55b4191be3 changeImprovement now contains 'terrain feature removal' logic 2023-08-08 19:25:51 +03:00
Yair Morgenstern
d9ceb9290d 4.7.12-patch1 2023-08-04 09:21:51 +03:00
SomeTroglodyte
bcb26b6d2a
Treat remaining untyped Uniques in default rulesets (#9763)
* Treat remaining untyped Uniques in default rulesets, make unit test catch them

* Change untyped filtering Uniques check to Validation by inclusion in GlobalUniques instead of UniqueType.AircraftMarker

* Wiki for untyped filtering Uniques

* Re-include the "Who knows" of Future Tech on the Tech picker
2023-08-03 11:38:50 +03:00
Yair Morgenstern
fc40da11d9
Added tests to ensure that resources from buildings behave as expected (#9860)
* Added tests to ensure that resources from buildings behave as expected

* More tests suggested by @SeventhM

* Caught an edge case - if you pillage your own tile improvement, your resources would not have updated!

* Actually every time an improvement changes you could have a resource change

* Update resources eon every improvement change because they could be providing resources via uniques
2023-08-03 11:38:36 +03:00
SeventhM
eb17398d78
Modernize Connection Tests (#9831) 2023-07-23 08:18:39 +03:00
SeventhM
1ca9766811
Fix issues when transferring capitals (#9801)
* Revert previous patches

* Fix the unit test, I guess
2023-07-18 18:08:30 +03:00
SeventhM
1e66c2e131
Avoid built buildings (#9806)
* Removing most interactions with builtBuildings

* Might as well edit this too

* Fix issues and edit isBuilt

* Simplify isAllBuilt
2023-07-16 23:01:17 +03:00
Yair Morgenstern
ee092a5851
City-level resources (#9774)
* City-level resources are...
- Not displayed in civ top bar
- Not considered civ-level resources (for trade, non-city conditionals, etc)
- Are explicitly treated in city conditionals
- ARE considered for constructing buildings requiring resource
- ARE NOT considered for construction units requiring resource

* getCityResources separates resources by origin so we need to sum them - kudos @SeventhM

* CR fixes

* Added new Civilization.getResourceAmount function

* More usages of civInfo.getResourceAmount()

* Don't add city resource table if it's empty
2023-07-10 16:24:50 +03:00
Yair Morgenstern
19bf15558d Fixed India's 'double unhappiness' unique 2023-07-05 21:10:22 +03:00
Yair Morgenstern
c787ab1a30 chore: Modernized WorkerAutomationTest 2023-07-04 15:09:40 +03:00
Yair Morgenstern
86cde678b3 chore: Modernized TileImprovementConstructionTests 2023-07-03 23:43:03 +03:00