Add shared battleFighterParse/Serialize, use it everywhere a fighter is (de)serialized
Replaces three independently hand-rolled battlefighter_t JSON readers/ writers (party.jsonc roster loading, BATTLE_START enemy definitions, and the v1 save-file party member format) with one generic pair in battlefighter.c: battleFighterParse(fighter, obj) and its inverse battleFighterSerialize(fighter, doc). Covers team/controller/status (optional, default ally/player/normal), the 7 base stats (required), current health/mp (optional, default to max), and an optional abilities name array. - party.c: partyInit now parses each roster member via battleFighterParse directly, dropping the old partyParseStats/partyParseStatField. - cutscenebattlestart.c/.h: cutscenebattlestartenemy_t now embeds a full battlefighter_t, parsed once at Load time; Start just copies it into the enemy pool instead of re-initializing. battletest.jsonc's enemies are now flat (dropped the "stats" wrapper) to match. - saveslotver1.c/.h: rewritten in place to use the shared parser/ serializer, changing the v1 on-disk field names/shape (no migration - acceptable pre-release, documented in saveslotver1.h). Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
@@ -4,17 +4,13 @@
|
||||
"type": "BATTLE_START",
|
||||
"enemies": [
|
||||
{
|
||||
"stats": {
|
||||
"attack": 8, "defense": 4, "magic": 0, "speed": 5, "luck": 2,
|
||||
"healthMax": 30, "mpMax": 0
|
||||
},
|
||||
"attack": 8, "defense": 4, "magic": 0, "speed": 5, "luck": 2,
|
||||
"healthMax": 30, "mpMax": 0,
|
||||
"abilities": ["fire"]
|
||||
},
|
||||
{
|
||||
"stats": {
|
||||
"attack": 6, "defense": 3, "magic": 0, "speed": 7, "luck": 2,
|
||||
"healthMax": 20, "mpMax": 0
|
||||
}
|
||||
"attack": 6, "defense": 3, "magic": 0, "speed": 7, "luck": 2,
|
||||
"healthMax": 20, "mpMax": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user