Add life rules and implement tests for civilization and life states
- Introduced a new file `life_rules.txt` to define life progression and degradation rules. - Created `test_civilization_state.gd` to validate the functionality of civilization rules and ethics. - Added `test_life.gd` to test life evolution, including initialization, batch processing, and state validation. - Implemented `civilization_state.gd` to manage civilization ethics and space civilization detachment logic. - Ensured all tests check for expected outcomes and validate state integrity after operations.
This commit is contained in:
@@ -181,6 +181,19 @@ func validate_data(data: Variant) -> String:
|
||||
for field in ["batch_origins", "distribution", "auto_resources", "production_remainders", "auto_star_deficits", "evolution_remainders", "planet_remainders", "blast_remainders", "destruction_remainders"]:
|
||||
if saved.has(field) and not _number_map(saved[field], field == "auto_resources", field != "auto_star_deficits"):
|
||||
return "invalid state." + field
|
||||
if saved.has("ethics"):
|
||||
if not saved.ethics is Dictionary:
|
||||
return "invalid state.ethics"
|
||||
for id in saved.ethics:
|
||||
if not Global.CivilizationRules.has(id) or not _number_map(saved.ethics[id], true):
|
||||
return "invalid state.ethics." + str(id)
|
||||
for ethic in saved.ethics[id]:
|
||||
if ethic not in ["m", "l", "w", "d", "c", "b"]:
|
||||
return "invalid ethic " + str(ethic)
|
||||
if saved.has("life_version") and saved.life_version not in [1, 2]:
|
||||
return "invalid state.life_version"
|
||||
if saved.has("life_remainders") and not _number_map(saved.life_remainders, false, false):
|
||||
return "invalid state.life_remainders"
|
||||
if saved.has("resource_remainders"):
|
||||
if not saved.resource_remainders is Dictionary:
|
||||
return "invalid state.resource_remainders"
|
||||
|
||||
Reference in New Issue
Block a user