Codex (Civilopedia) Phase 1: data layer — parse Civilopedia.txt and attach pedia keys - #999
Open
Billytifft wants to merge 2 commits into
Open
Billytifft wants to merge 2 commits into
Billytifft wants to merge 2 commits into
Conversation
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.
Summary
Phase 1 (data layer) of the Civilopedia/Codex epic (#997): parse
Text/Civilopedia.txtinto a queryable model, attach civilopedia keys to all game objects during BIQ/SAV import, and load the text besidePediaIconsduring import.What's included
C7Engine/C7GameData/Codex.cs— new parser producingCodex(entry dictionary + game-concept keys),CodexEntry,CodexPage.#KEYheaders → entries;#DESC_<KEY>headers → additional pages;{Title}lines → page titles;^-prefixed lines → paragraphs (wrapped lines are rejoined).#GAME_CONCEPTS_KEYS→GameConceptKeyslist; empty placeholder markers (GAME_CONCEPTS,EOF) are filtered.$LINK<Text=Key>converted to markdown[Text](key:Key); keys are trimmed on lookup (the real file has trailing-space keys likeGCON_Enslavement).civilopediaEntryonSaveUnitPrototype/UnitPrototype,SaveBuilding/Building,Civilization). Techs/resources/governments/terrain already had them.GetCivilopediaTextPathfunc mirrors the existingGetPediaIconsPathpattern throughGameParams,CreateGame,SaveManager.LoadSave,ImportCiv3.ImportSav/Biq,SaveGame.Load,Game.cs,ScenarioSetup, andBuildDevSave.Codexlives onSaveGame/GameData. It is[JsonIgnore]onSaveGameand regenerated from the scenario search path on load, so C7 saves stay portable and text is never duplicated into JSON.EngineTests/GameData/CodexTest.cs(11 tests): parser semantics, Windows-1252, key trimming, game-concept keys, a real-file smoke test against the actual install, and an import integration test (2 Rise of Rome.biq) verifying keys attach and resolve.Design decisions
Civilopedia.txtparsed as-is, not a native format. Matches the legacy-mode direction and keeps mods working (per issue open question 1). Revisit native prose only if/when standalone content is authored.Codex*for our feature,Civilopediakept for legacy artifacts. The new model/API isCodex/CodexEntry/CodexPage;Civilopedianaming remains only where it refers to the Civ3 files/content (Civilopedia.txt,civilopediaEntrykeys, path lambdas).[Text](key:Key)links,\n\nparagraph breaks,{Title}pages) so Phase 2/3 UI can render with a stock markdown-capable control and thekey:links give deep-linking for free.Codexis not part of saves. It is regenerated on load ([JsonIgnore]), resolving issue open question 2: keeps the dictionary onGameData/SaveGamefor convenient access, but keeps saves small and language-agnostic.PRTO_Fire_Catapult) legitimately have no entry in the installed text.GetEntryreturnsnullrather than throwing; the integration test asserts graceful handling. UI must render a fallback (name + stats) for these.PediaIcons.txttoday; there is exactly oneCivilopedia.txtin a Complete install, so the path resolves toConquests/Text/Civilopedia.txt(via the sameUtil.Civ3MediaPath/ scenario-search convention asGetPediaIconsPath), keeping mod override support for any future mod-provided file.Verified
dotnet build C7/C7.sln— 0 errorsdotnet test C7/C7.sln— 83/83 passed (withCIV3_HOMEset)dotnet format C7/C7.sln whitespace --verify-no-changes— cleanOut of scope (later phases)
UI shell, stat blocks, rendering
key:links, deep-linking, and search are Phase 2/3 per #997. Standalone-mode fallback when no text file exists is covered by aCodexwarning path (renders empty, callers must handle null).