feat: complete playtest parity improvements
This commit is contained in:
@@ -116,7 +116,7 @@ func _serialize(run: RunState, game: GameState, dialogue_player) -> Dictionary:
|
||||
identified.append(String(id))
|
||||
return {
|
||||
"version": SCHEMA_VERSION,
|
||||
"run": {"seed": run.seed, "settings": {"seed": run.settings.seed, "difficulty_id": String(run.settings.difficulty_id), "permadeath": run.settings.permadeath, "pet_enabled": run.settings.pet_enabled}, "player_name": run.player_name, "base_archetype": String(run.base_archetype), "current_floor": run.current_floor, "current_turn": run.current_turn, "gold": run.gold, "floors": floors, "floor_deadlines": deadlines, "inventory": run.inventory.to_dict(), "equipment": equipment, "identified_instance_ids": identified, "quest_records": run.quest_records, "achievement_state": run.achievement_state, "audience_state": run.audience_state, "recap_state": run.recap_state, "faction_war_state": run.faction_war_state, "moderation_state": run.moderation_state, "endgame_state": {"victory": run.endgame_state.victory}, "is_game_over": run.is_game_over, "death_outcome": String(run.death_outcome), "slot_policy": String(run.slot_policy), "log": _events_to_data(run.log), "meta": {}},
|
||||
"run": {"seed": run.seed, "settings": {"seed": run.settings.seed, "difficulty_id": String(run.settings.difficulty_id), "permadeath": run.settings.permadeath, "pet_enabled": run.settings.pet_enabled, "pet_name": run.settings.pet_name, "pet_species": run.settings.pet_species}, "player_name": run.player_name, "base_archetype": String(run.base_archetype), "current_floor": run.current_floor, "current_turn": run.current_turn, "gold": run.gold, "floors": floors, "floor_deadlines": deadlines, "inventory": run.inventory.to_dict(), "equipment": equipment, "identified_instance_ids": identified, "quest_records": run.quest_records, "achievement_state": run.achievement_state, "audience_state": run.audience_state, "recap_state": run.recap_state, "faction_war_state": run.faction_war_state, "moderation_state": run.moderation_state, "endgame_state": {"victory": run.endgame_state.victory}, "is_game_over": run.is_game_over, "death_outcome": String(run.death_outcome), "slot_policy": String(run.slot_policy), "log": _events_to_data(run.log), "meta": {}},
|
||||
"runtime": {"player": _actor_to_data(game.player), "companion": _companion_to_data(game.companion), "party": _actors_to_data(game.party.members), "dialogue_player": _dialogue_to_data(dialogue_player)},
|
||||
"metadata": {"updated_at": Time.get_unix_time_from_system(), "source": "godot"},
|
||||
}
|
||||
@@ -124,7 +124,7 @@ func _serialize(run: RunState, game: GameState, dialogue_player) -> Dictionary:
|
||||
func _deserialize(data: Dictionary, catalog: ContentCatalog) -> Dictionary:
|
||||
var run_data: Dictionary = data.get("run", {})
|
||||
var settings_data: Dictionary = run_data.get("settings", {})
|
||||
var run := RunStateType.new(String(run_data.get("seed", "")), RunSettingsType.new(String(settings_data.get("seed", run_data.get("seed", ""))), StringName(settings_data.get("difficulty_id", "crawler")), bool(settings_data.get("permadeath", false)), bool(settings_data.get("pet_enabled", false))))
|
||||
var run := RunStateType.new(String(run_data.get("seed", "")), RunSettingsType.new(String(settings_data.get("seed", run_data.get("seed", ""))), StringName(settings_data.get("difficulty_id", "crawler")), bool(settings_data.get("permadeath", false)), bool(settings_data.get("pet_enabled", false)), String(settings_data.get("pet_name", "Familier")), String(settings_data.get("pet_species", "Animal"))))
|
||||
run.player_name = String(run_data.get("player_name", "Sans-Nom")); run.base_archetype = StringName(run_data.get("base_archetype", "vanguard")); run.current_floor = int(run_data.get("current_floor", 0)); run.current_turn = int(run_data.get("current_turn", 0)); run.gold = int(run_data.get("gold", 0))
|
||||
for key in (run_data.get("floors", {}) as Dictionary):
|
||||
var floor := _floor_from_data(run_data.floors[key], catalog)
|
||||
@@ -200,12 +200,36 @@ static func _actors_from_data(data: Array) -> Array[ActorState]:
|
||||
|
||||
static func _companion_to_data(companion: CompanionState):
|
||||
if companion == null: return null
|
||||
return {"choice_id": String(companion.choice_id), "stance": String(companion.stance), "actor": _actor_to_data(companion.actor)}
|
||||
return {"choice_id": String(companion.choice_id), "stance": String(companion.stance), "name": companion.name, "species": companion.species, "endurance": companion.endurance, "regeneration_skill": companion.regeneration_skill, "regeneration_perk_bonus": companion.regeneration_perk_bonus, "actor": _actor_to_data(companion.actor)}
|
||||
|
||||
static func _companion_from_data(data) -> CompanionState:
|
||||
if not data is Dictionary or data.is_empty(): return null
|
||||
var actor := _actor_from_data(data.get("actor", {})); if actor == null: return null
|
||||
var companion := CompanionStateType.new(StringName(data.get("choice_id", "moth")), actor); companion.stance = StringName(data.get("stance", "follow")); return companion
|
||||
var actor_data: Dictionary = data.get("actor", {})
|
||||
if actor_data.is_empty() and data.has("id"):
|
||||
actor_data = {
|
||||
"id": String(data.get("id", "companion")),
|
||||
"cell": [int(data.get("x", 0)), int(data.get("y", 0))],
|
||||
"hit_points": int(data.get("hp", 1)),
|
||||
"max_hit_points": int(data.get("max_hp", data.get("hp", 1))),
|
||||
"attack_damage": int(data.get("attack_damage", 3)),
|
||||
"xp": int(data.get("xp", 0)),
|
||||
}
|
||||
var actor := _actor_from_data(actor_data); if actor == null: return null
|
||||
var companion := CompanionStateType.new(StringName(data.get("choice_id", data.get("id", "moth"))), actor)
|
||||
companion.stance = _legacy_companion_stance(StringName(data.get("stance", data.get("behavior", "stay_back"))))
|
||||
companion.name = String(data.get("name", "Familier"))
|
||||
companion.species = String(data.get("species", "Animal"))
|
||||
var attributes: Dictionary = data.get("attributes", {})
|
||||
var skills: Dictionary = data.get("skills", {})
|
||||
var perks: Dictionary = data.get("perks", {})
|
||||
companion.endurance = int(data.get("endurance", attributes.get("end", 4)))
|
||||
companion.regeneration_skill = int(data.get("regeneration_skill", skills.get("regeneration", 1)))
|
||||
companion.regeneration_perk_bonus = int(data.get("regeneration_perk_bonus", perks.get("regen_bonus", 0)))
|
||||
return companion
|
||||
|
||||
static func _legacy_companion_stance(value: StringName) -> StringName:
|
||||
var normalized := CompanionStateType.normalize_stance(value)
|
||||
return normalized if normalized in CompanionStateType.VALID_STANCES else CompanionStateType.Stance.STAY_BACK
|
||||
|
||||
static func _events_to_data(events: Array[GameEvent]) -> Array:
|
||||
var data: Array = []
|
||||
|
||||
Reference in New Issue
Block a user