--- id: unit-rules title: A force's battle value is ours to compute, and the same on both sides status: blocked repos: [helm, headquarters] dependsOn: [unit-library] exitCriterion: > A force's battle value is computed the same way in the browser and on the server, agreeing with MegaMek on every unit in the library except where a deviation is registered as their bug — including the crews' skill, which changes it. --- # unit-rules Battle value is computed when MegaMek loads a design, and helm borrows it from `bridge/`. That is enough while a force is a list of stock units and nothing else, and stops being enough the moment anything about a unit changes. ## What this epic is not, any more It was written assuming a force builder where players design units, which needed the whole construction rules layer. That is not what is being built: players pick from the library, then vary pilots, models and ammunition; fully custom designs are a much later question, and porting MegaMekLab is [declined](declined.md). So **construction validation is out of scope here** until custom design is on the table. What is left is smaller and sharper, and most of it is arithmetic over figures helm already has. - [ ] **Battle value for a varied unit.** Swapping ammunition or an omni configuration changes a design, so its battle value is no longer the one the bridge computed for the stock unit. This is the first real rules work, and it is narrower than a full implementation: the delta from a known design rather than a number from nothing. - [ ] **Double verification across the wire.** The same crate compiled twice — wasm in the browser while a player edits a force, native on the server as the authority. The failure mode to design against is version skew: a cached stale wasm disagreeing with the server looks like a rules bug and is not, so every result carries a `rules_version` the server acts on. - [ ] **Pin the rounding.** Battle value is full of half-point rounding steps, and "client and server round differently" is a miserable bug to chase. - [ ] **The oracle harness still earns its place, with a smaller target.** 10,988 units each carrying MegaMek's own battle value turns "does our arithmetic agree" into a number rather than a hope. The first use is not replacing the bridge but checking the skill multiplier and the force totals against forces MegaMek scores itself. ## Deferred, deliberately - [ ] **Construction validation.** Needed when a design can be authored here and not before. MegaMek flags 83 units `invalid`, which is a partial oracle waiting for it. - [ ] **Battle value from nothing.** A full conformant implementation, for designs the library has never seen. This is the long pole and it stays parked until custom design is real. ## Where the campaign layer picks this up, and an open question Salvage, repair, refit and damage carried between matches came up as wanted. Some of that is already provided for: a `.mul` records armour points, internal structure, destroyed locations and remaining shots per unit, so **the interchange format already carries a damaged unit** and [campaign](campaign.md) does not need a new one. The open question is where the line sits. `campaign`'s exit criterion is "a pilot carries damage and experience from one match into the next", and [declined](declined.md) puts MekHQ and StratCon outside the project on the grounds that campaign is "what a pilot carries out of a match, not a company's books". Salvage and refit read like the company's books. Either the line moves or the feature is smaller than it sounds, and that is worth settling before either epic plans around it — refits in particular are what would drag full construction validation back into scope. ## Done - [x] **Pilot skill changes battle value, and a force carries pilots.** `helm-force` ports MegaMek's 9x9 `bvSkillMultiplier` table and rounds per unit the way MegaMek does rather than on the total. The same four Meks are 4,809 BV with regular crews and 6,348 with veterans, which is what made "a 5,000 BV force" ambiguous until the crews were named. - [x] **Force-level totals.** A roster totals, with the base and the skill adjustment reported separately — a force over budget because of its units is a different problem from one over budget because of its pilots.