Split TORCharacterStatsModel health calculation by character category; fix champion HP and start-time crash - #33
Draft
RandyChihuahua wants to merge 1 commit into
Draft
RandyChihuahua wants to merge 1 commit into
RandyChihuahua wants to merge 1 commit 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.
Reorganises
MaxHitpointsinto four character categories — Troop, Player, Companion, Lord —and fixes two bugs found on the way. Numbers are unchanged everywhere except those two fixes.
Bugs
Necromancer champion doubled instead of dying. The fallback for unreadable career-ability
scaling logged "Champion being set to 1 hp and being left to die", then did
value = ResultNumber - 1; Add(value)— yielding2R−1, roughly double health. It now replacesthe number outright and returns. The log message was right; the arithmetic was missing a sign.
(bool)(model?.CampaignStartTime.IsNow)throws when the model is null — the?.yields a nullbool?and the unboxing cast fails, so the null-safe operator caused the crash it looked like itwas preventing.
Why the split is shaped this way
Forest harmony deliberately does not hang off the hero-kind switch. Your own clan's lords can
ride in the main party and are not
IsPlayerCompanion, so keying the Asrai block on kind wouldhave silently stripped their harmony debuff. It stays keyed on party membership.
Race bonuses were duplicated verbatim across the troop and hero paths (
IsDwarf(Hero)andIsDwarf(CharacterObject)are byte-identical) and now apply once for all four categories.Reordering is safe —
AddFactorapplies to the accumulated total regardless of insertion point,and the one order-sensitive read (the champion block) stays last.
Not done, deliberately: a static race→bonus dictionary.
FaceGen.GetRaceOrDefaultreturns 0 foran unregistered race, so a static initialiser running before races load would throw
TypeInitializationExceptionon a duplicate key.The
IsTreeman()/else if (IsTreeSpirit())pairing looks like a bug and isn't.tor_we_treemancarries
race="large_humanoid_monster"and theTreeSpiritattribute, so theelseis whatkeeps treemen at +1000 rather than +1100. Commented in place.
Other behaviour deltas
Hero.MainHero.GetForestHarmonyLevel()rather thanPartyBelongedTo.LeaderHero...— same hero in every reachable case, matches howForestHarmonyHelperreads it elsewhere, and removes a nullLeaderHerodereference.AddFactor(0.1f)per unlocked upgrade, producing N identical tooltip rows.Now one row at
0.1f × count— same factor.Add(…)gained a description, so the tooltip explains Everchosen, Orion, Tough, thetroop tier step, the undead penalty and the race bonuses instead of showing an unattributed
delta. Twelve new
tor_stats_*strings.Testing
Not yet run. No build path on the dev machine resolves this project's PackageReferences (non-SDK
csproj, no VS MSBuild), so a clean build wasn't obtainable; Roslyn binds the file with no
diagnostics of its own. 17 manual scenarios in
docs/character-stats-refactor-test-plan.md—scenario 3b (champion fallback now 1 HP) and 13 (clan lord in main party keeps harmony) are the
ones that matter. Save-compatible: no saved fields added or renamed.