Skip to content

Fix Philosophy's free tech being auto-spent, and the Science Advisor picker - #1038

Open
Billytifft wants to merge 3 commits into
C7-Game:Developmentfrom
Billytifft:billy/free-tech-research-prompt-impl
Open

Billytifft wants to merge 3 commits into
C7-Game:Developmentfrom
Billytifft:billy/free-tech-research-prompt-impl

Conversation

@Billytifft

@Billytifft Billytifft commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What was wrong

Philosophy awards a free tech to the first civ that researches it (#1003), but the advance was spent automatically — completing the tech ran straight into MaybePickTechToResearch, which spent the counter before the player ever saw it. There was no prompt and no indication it happened, and the counter wasn't saved, so a pending advance vanished on save/load.

Separately, picking a tech in the Science Advisor via "What's the big picture?" didn't start researching it. The tech landed in the queue but nothing was set as the current research target, so the bottom-bar indicator kept reading "Not selected".

What changed

  • Spending a free advance is now a separate action from setting the research target. Completing a bonus tech no longer silently consumes it: the human chooses via a popup, and AI players spend theirs automatically (they get no prompt).
  • Finishing a bonus tech now asks the player: a popup appears ("You have earned a free advance. Choose a technology:"), and "What's the big picture?" opens the Science Advisor to pick there. The advance is applied on whatever tech is queued when the advisor closes.
  • freeTechsRemaining is persisted in the save.
  • Queueing the first tech in the advisor now also sets it as the current research target.
  • The "Ask which tech to research next" preference added in Add Preferences panel for music volume and research prompt setting #1015 is now honoured. With it on (the default) you get the usual turn-start research prompt; with it off a tech is picked for you instead of prompting.

Two separate popups

Worth not conflating these — they share the same Science Advisor selection popup but are different flows:

  • Next-tech prompt — shown at the start of a turn when you have no current research and at least one city. Governed by the "Ask which tech to research next" preference; turning the preference off silences it and a tech is auto-picked.
  • Free tech popup — shown whenever you have a free advance to spend (e.g. finishing Philosophy first). It always prompts, independent of that preference, since the advance is a one-off the player should choose.

In-game testing

Played a normal game out to Philosophy as the first civ to research it:

  • On completion the free-advance popup appears instead of silently spending the tech. Picked a tech from the dropdown; confirmed it was granted and the counter dropped to 0.
  • Repeated via "What's the big picture?": picked a tech in the Science Advisor, closed it, and confirmed the advance was applied to the queued tech.
  • Confirmed the lower-right research indicator now updates when selecting this way (previously stuck on "Not selected").
  • Confirmed the free tech popup shows even with "Ask which tech to research next" turned off, while the turn-start research prompt is correctly silenced with it off and shown with it on.
  • Saved and reloaded with an advance still pending and confirmed it survived the round trip.

AI free-advance spending is covered by a unit test; the AI path was not exercised in-game.

Build 0 errors / tests pass / dotnet format --verify-no-changes clean.

Fixes #1003.

…picker

Spending a free advance is now a separate action from setting the research
target, so MaybePickTechToResearch no longer consumes it. Completing a bonus
tech (e.g. Philosophy) now prompts the player to choose, and the counter is
persisted in the save. Selecting a tech in the Science Advisor now sets it as
the current research target, and the 'Ask which tech to research next'
preference is honoured for the turn-start prompt.

Fixes C7-Game#1003.
button.Pressed += () => {
action();
ReleaseFocus();
action();

@Billytifft Billytifft Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to fix a crash when selecting Whats the Big Picture from Science Advisor popup.

knownTechs = player.knownTechs;
currentlyResearchedTech = player.currentlyResearchedTech;
researchQueue = new List<ID>(player.ResearchQueue.Select(t => t.id));
freeTechsRemaining = player.freeTechsRemaining;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure if this is necessary as you cant really save between gaining philosophy and spending the free tech. Would love your input though

The free-advance spend moved out of SetCurrentlyResearchedTech into
ClaimFreeTech, which only the human UI reaches. AI players research bonus
techs (e.g. Philosophy first) and accumulate freeTechsRemaining without
ever spending it. Spend it in MaybePickTechToResearch, the shared choke
point for AI research decisions, before picking the next tech.
@Billytifft

Copy link
Copy Markdown
Contributor Author

I know this will likely have to have a slight refactor after #1018 is merged

@Billytifft
Billytifft marked this pull request as ready for review October 11, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Philosophy's bonus tech is auto-spent before the player can choose, and is lost on save/load

1 participant