Refactor save manager validation and update state structure

- Updated the save manager to enforce a new format version (2) and improved validation checks for the save data structure.
- Enhanced the `validate_data` function to ensure all required fields are present and valid.
- Adjusted the handling of legacy saves and introduced new checks for various state fields.
- Improved number formatting in the global script for better readability of large numbers.
- Updated tests to reflect changes in the save manager and validation logic, ensuring compatibility with the new state structure.
- Added new tests for group indexing and production transactions to ensure correctness of entity management and resource production.
This commit is contained in:
Kirill
2026-09-20 20:56:15 +03:00
parent 26347fca30
commit a09e3df220
15 changed files with 295 additions and 154 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ func invariants(world) -> void:
check(sum_ethics(world, id) == physical.get(id, 0.0), "Ethics equal physical population for " + id)
for n in world.state.ethics[id].values():
if n < 0.0 or n != floorf(n): check(false, "Invalid ethic amount")
check(root.get_node("SaveManager").validate_data({"state": world.state}) == "", "Civilization state validates")
check(root.get_node("SaveManager").validate_data({"format_version": 2, "app_version": "", "ui": {"current_page": 0}, "state": world.state}) == "", "Civilization state validates")
func run() -> void:
var global: Node = root.get_node("Global")