Commit Graph

333 Commits

Author SHA1 Message Date
yairm210
d12c6c10e7 Fix tests 2024-06-21 19:02:01 +03:00
Yair Morgenstern
79be14e291 Resolved #11082 - Added "Will not be replaced by automated units" unique 2024-06-17 23:12:50 +03:00
Oskar Niesen
bbea08364b
TechDebt: Made getDiplomacyManger() nullable (#11771)
* Made getDiplomacyManager nullable and added getDiplomacyMangerOrMeet

* Fixed AI Automation having problems when playing as a oneCityChallenger civ
2024-06-16 23:40:45 +03:00
SomeTroglodyte
3c91647fb2
Streamline and thereby reduce size of the save game json (#11728) 2024-06-14 17:39:59 +03:00
SomeTroglodyte
e74897469c
Improvement queue (#11677)
* Improvement queue: Framework

* Improvement queue: Minimal UI

* Remove debug code

* Fix merge error

* Address tuvus's input

* Implement tuvus's UI wishes

* Fix merge errors

* Fix more merge errors
2024-06-14 17:39:46 +03:00
Oskar Niesen
728713dc3e
Giving the AI good trades is stored as credit (#11326)
* AI Civs now are happy for good trades

* Each gift point is worth 100 gold without inflation

* Gifts can now be used as credit for future trades

* Fixed giftAmount conversions

* Fixed get inflation returning NAN when gpt is negative

* diplomatic gifts are now rounded when checking trade acceptability

* Changed gold gift scaling to account for relationship level

* Fixed percent based value reduction

* Added gold gifting functions to DiplomacyManager

* Added tests

* Declaring war removes gold gifts

* Reversed trade evaluation

* Added more tests for trading

* Fixed who the gifts are given to

* Added more comments

* Added more tests and fixed stuff

* Gifting does not occur with trade treaties

* Renamed handleGoldGifted to GiftGold

* Added two more tests

* Improved comments

* Liberating a civ no longer gives positive relations from open borders
2024-06-14 17:38:54 +03:00
yairm210
3160416138 Fix tests 2024-06-13 13:50:00 +03:00
yairm210
4f436e98bd rename: changeImprovement -> setImprovement 2024-06-13 12:23:25 +03:00
SomeTroglodyte
cf7f5a1c52
Remove 'Strategic Balance' and 'Legendary Start' from resource abundance select (#11699)
* Convert MapResources into an Enum

* Fix IsPartOfGameInfoSerialization where actually only the String is part of serialization

* Refactor MapResources to own file, package mapgenerator

* Refactor MapSize/MapSizeNew to own file and rename
2024-06-08 21:58:19 +03:00
SomeTroglodyte
a046e43dbf
UI candy: WLTK fireworks (#11616)
* Particle effect fireworks for WLTK

* Refactor fireworks, try another location calculation

* Save todo list

* Fireworks assets

* ParticleEffectAnimation framework refactor and FasterUIDevelopment

* ParticleEffectAnimation rework - works correctly now

* ParticleEffectAnimation - credits and fine-tune

* ParticleEffectAnimation - atlas

* ParticleEffectAnimation - clean up testing code

* ParticleEffectAnimation - fix bungled texture move
2024-06-04 18:00:44 +03:00
yairm210
bed8d3b176 minor docs and city resource conditional test 2024-05-31 13:55:38 +03:00
yairm210
a45c057b48 Better location for resource tests 2024-05-31 13:47:14 +03:00
SomeTroglodyte
9e5c113ee8
UI: Allow any mod sound to be selected as a multiplayer turn notification sound (#11623)
* Linting

* Fix potential crash when having a multiplayer notification sound configured that is no longer available

* New media finder architecture

* Unit tests for new media finder architecture

* Apply new media finder architecture to solve "allow all mod sounds as multiplayer notifications" request
2024-05-29 23:59:57 +03:00
SomeTroglodyte
e1ec448f81
Cleaner Json custom serialization and unit tests (#11624)
* Barbarian encampments are no longer a HashMap since #9374 so that old compat code is unreachable

* Rename SerializationTests to GameSerializationTests and add a barb camp to the game

* Add SerializationTests (roundtrip tests for classes with custom serialization)

* Convert setSerializer to implement Json.Serializable where possible
2024-05-27 12:37:49 +03:00
Yair Morgenstern
11cee77fb9
"for every [countable]" unique modifier (#11641)
* "for every [countable]" unique modifier

* detekt fix

* Test city-unique edge cases
2024-05-27 12:32:12 +03:00
SomeTroglodyte
c5df845611
Fix bug in ModConstants handling (#11645)
* Fix a few unhelpful mod checker warnings

* Fix a problems with ModConstants and unit tests for them

* Minor linting
2024-05-27 12:30:51 +03:00
Oskar Niesen
8b27de26d5
Declare War Reason (#11490)
* Created DeclareWarReason enum

* Created a new notifyOfWar function and a DeclareWarReason class

* moved handleCityStateDirectAttack to it's own function

* Moved changing modifiers to its own function

* Moved notifyOfWar above onWarDeclared

* Fixed defensive pact canceling notifications

* Added more comments

* Fixed DiplomacyManagerTests

* Warmongering does not stack with defensive pacts

* Reworked how shared enemy modifiers are given out

* Fixed JoinWar notifications

* Added join war translations

* Added missing defensive pact translations

* Fixed translation parameter problems

* Changed "canceled" to "cancelled"
2024-04-24 00:01:26 +03:00
SomeTroglodyte
9dcfb963e3
Multi-filter improve code clarity and more unit tests (#11503)
* Some linting and region reorder

* Make MultiFilter accept a negated "and" list plus more unit tests

* MultiFilter gets 'or' capability

* Revert "MultiFilter gets 'or' capability"

This reverts commit 9f6e7c794a.
2024-04-24 00:00:40 +03:00
SomeTroglodyte
5c6d9171c4
UX: Auto rename new capital in rare cases to prevent confusing notifications later (#11507)
* Rename new capital when a civ survives losing their civ-named capital

* Linting

* Make "overflow" city founding names translatable

* Fix some unit tests relying on hardcoded Random() results
2024-04-23 23:59:53 +03:00
SomeTroglodyte
2d4e8bc83e
Clean up github runner output (#11451) 2024-04-11 21:45:25 +03:00
Oskar Niesen
ef9965e218
Espionage Uniques, Buildings and Policy (#11401)
* Added OneTimeSpiesLevelUp, OneTimeGainSpy, SpyEffectiveness, EnemySpyEffectiveness and HiddenWithoutEspionage Uniques

* Spy effectiveness affects stealing tech and rigging elections

* Fixed HiddenWithoutEspionage

* Added Constabulary and Police Station

* Added cityFilter to SpyEffectiveness

* Added national Intelligence agency

* Added Great Firewall

* Fixed great firewall having a float value

* EspionageManager addSpy now returns Spy instead of name

* Added some simple espionage tests

* Fixed OneTimeSpiesLevelUp still wanting parameter

* Spy efficiency occurs after skill modifier

* Added another test

* Added Police State spy efficiency reduction unique

* Fixed "Hidden when espionage is disabled" wording

* Fixed "effectiveness" wording

* Changed "enemy spy effectiveness" unique to use negative matters

* Spy effectiveness only affect tech steal rate

* Changed "Gain an extra spy" and "Promotes all spies" uniques

* Removed Police State comment that is no longer accurate

* Changed spy effectiveness to be multiplicative
2024-04-09 23:12:21 +03:00
SeventhM
91f87fec9f
Allow improvements that don't need removal to build (#11299)
* Fix improvements that remove features only not checking for all terrains

* Allow improvements that don't need removal to build without improving resource

* spot the missing import

* Add in tests

* typo

* Assert Forest is still there
2024-03-17 23:12:24 +02:00
Oskar Niesen
c6058cdf73
Melee Escort Attacking Fix (#11310)
* Added a test

* Fixed melee units attack moving into tiles that the escorting unit can't move to

* Added tests

* Update core/src/com/unciv/logic/battle/TargetHelper.kt

---------

Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
2024-03-15 11:30:37 +02:00
SeventhM
b60dabc089
Allow resources from follower beliefs (#11252)
* Allow resources from follower beliefs

* incorporate suggestions
2024-03-13 23:19:18 +02:00
Yair Morgenstern
b577f5ee9a
Fix double-count of civ-wide resources, while allowing propagation of city-wide resources via uniques (#11236)
* Fix double-count of civ-wide resources, while allowing propagation of city-wide resources via uniques

* Added test to ensure civ-wide resources propagate between cities (they do)

GetResourceAmount -> GetAvailableResourceAmount

* Extra clarity in function names! Better than possible confusion.
2024-03-03 20:02:21 +02:00
SomeTroglodyte
6a61a71c36
Type declaration colon blanks linting (#11216) 2024-02-28 23:46:21 +02:00
Oskar Niesen
04083de766
Added unit escorting formation!!! (#11057)
* Added escort button

* Added basic escort movement

* Improved escort movement

* Swapping breaks escorting

* Added stop escorting button

* Added link icon to unit

* getDistanceToTiles() now automatically includes escorting

* Multi-turn movement with different units works somewhat

* Escorting units persist to escort across saves

* Escorting units are only idle if their partner unit is idle as well

* Fixed multi-turn escort movement where one unit has more movement points left over

* Added basic tests

* Added a test for formation idle units

* Added some basic movement tests

* Added some canMoveTo tests

* getDistanceToTiles only caches when includeEscort is true

* added getDistanceToTiles test

* An entire commit to remove one line of white space just for you! And yes, there are no semi-colons;

* Added translations

* Added more stopEscorting() calls when the unit is removed

* Added extra comments and refactoring

* Refactored removeAllTilesNotInSet to use a mutableIterator

* Refactored code based on review

* Refactored removing tiles in PathsToTilesWithinTurn that aren't in another PathsToTilesWithinTurn
2024-02-24 22:39:04 +02:00
Yair Morgenstern
23edf07a41
Terraforming! (#11152)
* Terraforming!

* comment

* whoops

* And better tests, that actually output text.

* SomeTrog caught this doc error :)

* Fix natural wonder placement, it better belongs with base terrain
Also, normalize tiles to ruleset after plonking a new terrain

* Out Of Cheese Error, Redo From Start

- Only terrains, no improvements - one problem at a time
- Fit new functional trigger format
- Respect occursOn
- Teleport units out of tiles if they can't pass through (nat wonders for example)
- No need for terrainFeature unique parameter
- Tested with "Turn this tile into a [Grand Mesa] tile <for [0] movement>", "Turn this tile into a [Forest] tile <for [0] movement>" uniques

* Don't allow city tiles to turn into water/wonders etc kudos @SomeTrog
2024-02-20 23:38:23 +02:00
SomeTroglodyte
df7072b550
Clean up console output of unit test runs (#11134)
* Allow tests to discard console output selectively, by default collect and discard unless result is failure

* Fix debug change and a little source clarification
2024-02-16 11:57:42 +02:00
Yair Morgenstern
e7a2b94c60
SomeTrog's versioning test - compile on jdk 17 FOR jre 11, includes gradle upgrade (#11111) 2024-02-10 19:44:47 +02:00
SeventhM
d53766b7d7
Unify unit and civ triggers (#11011)
* Unify unit and civ triggers

* Update conditionalsApply check

* add tile in the city override

* Add StateForConditionals for unit uniques when founding a city

* Accidentally removed unit triggers from uponBuildingImprovement

* Accidentally removed parenthesis

* add "tile = tile" to improvement trigger's StateForContitionals

* Add unit's tile to default tile

Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>

* Accidentally did getMatchingUniques instead of getTriggeredUniqued

* Merge triggerUnitWideUniques into TrigerUniques

* checkOnGameInfo Helper to shorten line length

* StateForConditionals secondary constructors

* accidentally deleted

* also accidentally deleted

---------

Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
2024-01-28 11:06:43 +02:00
SomeTroglodyte
e576b03fc6
Unit actions "paging" new architecture (#10988)
* Linting (and prioritize addGiftAction efficiency over the get used only by unit test)

* Move "paging" out of MapUnit, drop Normal/Additional getter split, "page" preference via UnitActionType

* Optimize UnitActions API a little - fallback does not enumerate actionTypeToFunctions again

* Cleaner access to GiftUnit action from unit test

* Allow freely switching from Sleep to Sleep-until-healed and back
2024-01-24 23:43:31 +02:00
SeventhM
dabd105cf8
Allow units to upgrade to more than one unit (#10947)
* Allow units to upgrade to more than one unit

* Actaully add changes to Base Unit

* And actually add the unique

* Kdocs fixes

* upgradeUnits to getUpgradeUnits and add missing state for condititonalss

* unique.params[0] shouldn't be empty..., right?

* Make old var first in the list, in case it matters

* wait... We're never yielding a null result

* Remove unnecessary function call

* Remove some indentation in RulesetValidation

* isEmpty instead none

* min cost instead of first

* Ruleset helper functions

* Imports

* helper functions part 2

* sanity check in case the unit actually isn't upgradable here

* I missed a spot

* This is NOT using a filter, itis looking for a unitName. Also, why do we use "unit" instead of "unitName"?

* Avoid crash in Scene2dExtentions, part 1

* Avoid crash in Scene2dExtentions, part 2

* inevitable request to move it to its own function

* Upgrade to the correct unit when upgrading all units

* Kdocs I overlooked

* Whoops

* Revert kdocs changes

* Should probably make sure action isn't null

* Fix loop in checkUnitRulesetInvariant

* Minor irrelevant fix

* No response, Removing getUpgradePath part 1 as it's redundant if we upgrade one at a time

* Move to UnitAutomation

* Imports

* Irrelevant fix: ignore consturctionRejections for upgrades

* Irrelevant fix: We should be able to upgrade to obsolete units, just not build new ones

* Simplify for clarity

* Irrelevant fix: unit is not destroyed is it doesn't upgrade

* Whoops

* Imports

* Remove getUpgradePath part 2: simplify UnitAutomation

* Remove now unnecessary circular reference check. We already check if it upgrades to itself

* Whoops, if we use a special upgrade, we should go back to a normal upgrade if we find no special upgrade unique

* Basic tests for last commit

* Forgot special to normal upgrade test

* whoops, forgot to change comment

* Not at computer: List.isEmpty to Sequence.none

* Not at computer: List.size to Sequence.count()
2024-01-24 23:43:07 +02:00
SomeTroglodyte
77c12fcae4
Unit actions builders use sequence (#10966)
* Change actionTypeToFunctions signature to use Sequence

* Linting and a little left pad for the unit action buttons
2024-01-21 19:14:54 +02:00
Oskar Niesen
169ccf5d03
AI worker road priority rework (#10918)
* WorkerAutomation now caches the roads to use

* Workers now build roads differently

* Fixed error if unit movement is zero

* Fixed civ researching an unwanted tech in a test

* Fixed spelling

* Increased road building priority

* getRoadConnectionBetweenCities no longer does unnecessary sorting

* roadsToConnectCitiesCache no longer stores roads that are already built

* ChooseImprovement now builds roads on resource tiles!

* Fixed tryConnectingCities error related to using minByOrNull instead of firstOrNull

* Roads can't have a negative value if they are bigger
2024-01-21 19:12:14 +02:00
Oskar Niesen
c3a4b5f7af
Worker remove feature AI fix (#10917)
* Workers now value the improvement that they want to build after removing a terrain feature

* Restructured getImprovementRanking
2024-01-15 18:55:45 +02:00
SomeTroglodyte
975b2ba165
Unit test against unmatched placeholders in a translation (#10863) 2024-01-09 12:42:04 +02:00
SeventhM
665b5aa87c
Add unique to allow for generalized great generals (#10828)
* Add unique to allow for generalized great generals

* Don't add compatibility for rulesets with conditional generals

* Add to rulesets

* add in pre Kotlin 9 parenthesis

* whoops missed a parenthesis

* I guess pre Kotlin 9 parenthesis was unnecessary, whoops

* Add back old variables to clone function

* Move the list of all potential generals to Ruleset

* Move list of unit construction rejections to IConstruction

* flip !any{} to none{}

* Fix imports

* Typo
2024-01-04 09:03:14 +02:00
Yair Morgenstern
35c19bf9de Fixed tests 2023-12-31 22:59:33 +02:00
Yair Morgenstern
783f846761 Remove source compatibility to java 8, in preparation for Gradle 8.5 upgrade
See #10740
2023-12-28 23:07:24 +02:00
Oskar Niesen
7745cd1c88
Worker AI Rework (#10776)
* WorkerAutomation now uses UnitAutomations's getDangerous tiles

* getPriority now values the current unit tile

* getPriority now values if the tile is worked instead of if it provides a yield

* getPriority prioritises clearing fallout

* getPriority prioritises new resources

* Fixed error in WorkerAutomationTest

* FindTileToWork now uses tilesToAvoid instead of checking for enemies itself

* Workers prioritise their own tile first

* Began reworking tile priority

* Changed getBasePriority() to account for tile damage

* findTileToWork now groups tiles and finds the best tile from the top group

* Fixed method calling findTileToWork()

* Workers don't build roads if their GPT is below 20

* Workers have multiple stages of wanting to connect cities

* Workers prioritise best tiles based on closeness

* Changed stuff

* Fixed a situation where a worker would be on a tile without improving it

* Reduced city connection priority

* Worker prioritises improving closer tiles more

* Worker prioritises improvements that are closer to being finished

* Reverted changes that broke tryConnectingCities more (it is already a little broken)

* Improved repair priority

* Added cityDistanceWant to tryConnectingCities

* Created a partial Test

* Finished first test

* Fixed a merge issue

* Fixed tileHasWorkToDo not accounting for base improvement values

* Added a failing test

* CityPopulationManager now assigns population to tiles in a predictable way for the Worker BasePriority tileProvidesYield

* Added an extra test with two cities and no roads

* Fixed Test creating new workers which ends up failing the test

* Test no longer research and have unnecessary research

* Test no longer include city center tiles as improvements built

* Added a failing test and removed a tryConnectCity filter

* Workers now improve tiles with unseeable resources on them

* Added a resource test

* Fixed should build roads in turns test

* Added an extra test

* tryConnectingCities takes into account the improvement priority

* Separated the improvement stat bonus from the base priority for tryConnectCities

* getBasePriority() now ranks a tile based on its base stats

* replaced mostUnderdevelopedCity with closestUnderDevelopedCity

* changed build road distances wanted

* getImprovementRanking now accounts for resources

* tilePriority now uses a float instead of an int

* Fixed float to int conversion in SpecificUnitAutomation

* Added a test for pillaging
2023-12-28 22:42:11 +02:00
Yair Morgenstern
b56a168e86
Save city focus as string, to allow changes in available city focuses without breaking games (#10794) 2023-12-22 10:07:28 +02:00
dHannasch
4b5bb54b72
Add BaseUnit.automaticallyUpgradedInProductionToUnitByTech() (#10664)
* Update BaseUnit.kt

* Update RulesetValidator.kt

* Update BasicTests.kt

* Update BaseUnit.kt

* Update TechManager.kt

* Update BaseUnit.kt

* Update BaseUnit.kt
2023-12-17 22:00:45 +02:00
Yair Morgenstern
2ae5a018de Added initial pathfinding tests 2023-12-08 14:48:48 +02:00
Yair Morgenstern
cce678800f Fixed pillage tests 2023-12-08 14:10:56 +02:00
Yair Morgenstern
8f049f45f1 Standardized 'create improvement' uniques - need to remember to deprecate the water improvements! 2023-12-07 19:47:45 +02:00
dHannasch
155498dc43
Wrap BaseUnit.obsoleteTech into function (#10648)
* Update BaseUnit.kt

* Update BaseUnit.kt

* Update TechManager.kt

* Update BaseUnit.kt

* Update RulesetValidator.kt

* Update BasicTests.kt
2023-12-03 22:26:16 +02:00
Oskar Niesen
f1ceaa216a
Get distance to nearest enemy rework (#10481)
* Initial refactor

* Moved checking if a tile has an enemy to a new method

* Rewrote getDistanceToEnemyUnit

* changed the position of the logic of checking if the enemy is still there

* Changed some of the other methods to use the ThreatManager getClosestEnemy()

* Added a new getTilesWithEnemyUnitsInDistance method

* Added a new getEnemyMilitaryUnitsInDistance method

* Converted a few lines to use ThreatManager

* Changed Air units to use threat manager

* Fixed tileWithEnemy error

* distanceToClosestEnemyTiles now clears at the start of every turn

* Added blank lines to end of ThreatManager.kt

* Renamed tilesInRange to tilesWithEnemyUnitsInRange

* Changed ArrayList return to a MutableList

* Removed ClosestEnemyTileData being a data class

* Improved commenting

* Improved commenting2

* getEnemyMilitaryUnitsInDistance now uses a flatMap and moved getDangerousTiles to threat manager

* Created a new helper method getEnemyUnitsOnTiles

* Renamed clearThreatData to clear

* Added shortcut if maxDist is less than or equal to distanceSearched

* Fixed distanceWithNoEnemies in getTilesWithEnemyUnitsInDistance

* Fixed notFoundDistance being higher than maxDistance when takeLargerValues is false

* Added some ThreatManager tests

* Added some more ThreatManager tests

* Removed visible map after use

* getTilesWithEnemyUnitsInDistance doesn't search distances <= tileData.distanceSearched (previously was <)

* Added 3 more tests

---------

Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
2023-11-25 20:11:10 +02:00
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