ChairmanTraitCSVHandler
Overview
CSV import/export utility for ChairmanTrait content. Uses a semicolon (;) separated schema by default (falls back to comma if no semicolons are present). Supports up to five effects per trait row and is tolerant of unknown parameters or malformed numbers.
CSV Header (expected)
Level;Title;Description;CostType;Cost;Effect1Param;Effect1Value;Effect2Param;Effect2Value;Effect3Param;Effect3Value;Effect4Param;Effect4Value;Effect5Param;Effect5Value
ReadTraitsFromCSV(path)
- Validates existence; returns an empty list if missing.
- Parses the header, builds a column index (case‑insensitive), then iterates rows.
- Maps:
Level→level(int)Title→titleDescription→descCostType→costType(parsed toUpgrade.CostType)Cost→requiredTokens(float)
- For
Effect1..5pairs:- If
EffectNParamparses toChairmanTraitEffect.Parameter, append a new effect witheffectValueparsed using a culture‑invariant float that accepts decimal commas.
- If
- Returns
List<ChairmanTrait>.
WriteTraitsToCSV(traits, path)
- Emits the canonical header above.
- Writes one row per trait, flattening up to 5 effects into
(Param,Value)pairs. - Replaces semicolons in text fields to keep the simple CSV contract.
Implementation Notes
- Split helper prefers
;but supports,as a fallback. - Unknown effect parameters are silently skipped to be author‑friendly.
- Numbers are formatted using
InvariantCultureon write.