Repository navigation
Added Golden Ages - #1134
Open
zack-the-coding-actuary wants to merge 12 commits into
Open
Added Golden Ages#1134zack-the-coding-actuary wants to merge 12 commits into
zack-the-coding-actuary wants to merge 12 commits into
Conversation
- Took away 100% saturation from minimap colors, which causes similarly hued colors to collide visually on the map - Slightly increased opacity of civ colors on the minimap, so less of the base terrain colors show through
Add golden age duration and tile bonuses to Rules, and track each player's golden age end turn through save/load. - Rules: add GoldenAgeDuration (default 20) and GoldenAgeBonuses, a new GoldenAgeBonus struct (Shields, Commerce; default 1, 1) - ImportCiv3: read GoldenAgeDuration from the BIQ RULE section. The bonuses are not in the BIQ, so they are always set to 1, 1 - ImportCiv3: read each player's golden age end turn from LEAD.GoldenAgeEndTurn when importing a SAV - Player/SavePlayer: make goldenAgeEnds public and round-trip it through OpenCiv3 saves - civ3/ruleset.json: add goldenAgeDuration and goldenAgeBonuses - standalone: add golden_age.lua and apply it from ruleset.lua. It is required at the top of the file because the module loader path is unset by the time the addon function runs
Units with the "starts golden age" flag now start their owner's golden age when they kill a unit belonging to another civ, if the owner has not yet had one. - SaveUnitPrototype.Flag/UnitPrototype: add StartsGoldenAge flag and startsGoldenAge property - ImportCiv3: set the flag from the BIQ PRTO StartsGoldenAge field - civ3/ruleset.json: add the flag to the 31 units that have it in conquests.biq - Player: add TryStartGoldenAge(), which sets goldenAgeEnds to the current turn plus Rules.GoldenAgeDuration. It does nothing for barbarians or for a player who has already had a golden age - MapUnit.Fight: call StartGoldenAgeIfEarned on kills only, for either the attacker or the defender. Retreats do not count, and neither do fights against barbarians. AI combat counts - Add GoldenAgeTriggerTest
zack-the-coding-actuary
marked this pull request as draft
November 23, 2026 22:45
- Fixed whitespace - Golden Age check only runs when enemy unit is a combat unit - Added unit test to ensure GA does not trigger off killing non-combat unit
This reverts commit 0b999cc.
Completing a great wonder now starts the owner's golden age if the traits of all great wonders the owner currently has, including the new one, cover all of the owner's civ traits. Only great wonders the player owns at that moment count, so a wonder in a lost city no longer helps. Small wonders and regular buildings never trigger or contribute. A player who has already had a golden age does not get another. - City.HandleCityProduction: after a great wonder is built, collect the traits of the owner's great wonders and call Player.TryStartGoldenAge() when they cover the civ's traits. Obsolete wonders are included - Add a TODO noting that a civ with no traits gets a golden age on its first great wonder. No edge case handling implemented at this time. - Add wonder trigger tests to GoldenAgeTriggerTest, driving the real HandleCityProduction: all traits in one wonder, traits covered by owned wonders (including in another city), traits not covered, regular buildings and small wonders never triggering or counting, and no second golden age
… golden age A unit with the starts-golden-age flag is no longer treated as obsolete by UnitPrototype.IsUnitObsolete while its owner has not yet had a golden age, even if the unit it upgrades to can be built. Once the owner has had a golden age (HasHadGA stays true after it ends), normal obsolescence applies again. - UnitPrototype.IsUnitObsolete: return false for units with startsGoldenAge when the owner has not had a golden age. The check comes before the AllowLesserUnitProduction check. - GoldenAgeTriggerTest: add tests confirming an obsolete golden age unit stays producible before the owner's first golden age, and becomes (and stays) obsolete afterwards. - UnitPrototypeTest: give each player in the Conquests unit availability test a prior golden age, because Swiss Mercenary starts golden ages and would otherwise no longer be obsolete in the SAV case. The JSON case is covered by the same change. Note: the remote JSON save used by UnitAvailability_JSON predates the golden age flag, so its prototypes do not carry it and behave as before. Older JSON saves may not get the combat trigger or this obsolescence exemption until their prototypes are regenerated.
While the human player is in a golden age, the research progress line in the lower right info box is prefixed with the number of turns remaining, for example "Golden Age (12) - Writing (4 turns)". Outside a golden age the line is unchanged. - LowerRightInfoBox._Process: when player.IsInGA is true, prefix the SummarizeScience text with "Golden Age (N) - ", where N is player.goldenAgeEnds minus the current turn. A golden age ends on the turn goldenAgeEnds, so that turn is not counted.
The human player now sees a domestic advisor pop-up when their golden age begins ("Our civilization has entered a Golden Age!", happy advisor) and on the turn it ends ("Our Golden Age has ended, so says our analysis", sad advisor). Golden ages are disabled when the rules specify a duration of 0.
- MessageToUI: add MsgGoldenAgeStarted and MsgGoldenAgeEnded, each carrying the controller id so the UI only shows them to the player they belong to.
- Player.TryStartGoldenAge: return false without changing any state when GoldenAgeDuration is 0, so a disabled golden age sends no message and does not use up the player's one golden age. Send MsgGoldenAgeStarted when the golden age begins, which covers both the combat and wonder triggers.
- TurnHandling.AdvanceTurn: after the turn advances, send MsgGoldenAgeEnded for each player whose golden age ends on that turn.
- Game.cs / Game_EmitMessages.cs: handle both messages for the UI controller and show an InformationPopup with the Domestic Advisor, following the EmitScienceGuidanceSignal pattern.
- standalone/golden_age.lua: clamp the golden age duration to a minimum of 0 so a negative value cannot be loaded.
Note: the clamp only covers the standalone Lua path. Civ3 mode reads the duration from ruleset.json and BIQ/SAV imports copy it from the BIQ, so a hand-edited negative value there is not clamped. A save loaded exactly on the turn a golden age ends does not show the end pop-up, because the check only runs when the turn advances.
zack-the-coding-actuary
marked this pull request as ready for review
November 24, 2026 20:02
New games started from inside OpenCiv3 now take their golden age duration and tile bonuses from Lua, in both the base civ3 and standalone modes. Loaded OpenCiv3 saves, SAV imports, BIQ imports and scenarios are unaffected and keep their own values. - gameplay.lua: add golden_age_config (duration 20, shields 1, commerce 1) and gameplay.golden_age.duration/shields/commerce functions, each clamped with math.max(0, value) so a negative value cannot be loaded. - GameMode.GetSave: after cloning the ruleset, set Rules.GoldenAgeDuration and Rules.GoldenAgeBonuses from those functions. GetSave is only used when starting a new game, so loads and imports never go through it. - ruleset.json: remove the goldenAgeDuration and goldenAgeBonuses entries from the rules block, since Lua now supplies them. The startsGoldenAge unit flags stay, because they are static unit data. - standalone: delete golden_age.lua and remove its require and call from ruleset.lua, since GetSave overwrites those values anyway. The defaults on Rules (20 turns, bonuses of 1 and 1) are unchanged and remain the fallback for older OpenCiv3 saves that lack the fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ready for review.
Addressing issue #1119
Done:
Playerclass to support golden agesTile_YieldclassRulesclass for Golden Age duration and bonus yields (configurable from Lua)ruleset.jsonhas a duration of 0 (for Civ 3 games), or if golden_age.lua has a duration of 0 or less (clamped to 0, for standalone games)