mirror of
https://github.com/deunix-educ/aventuriers-des-mots.git
synced 2026-10-13 02:11:58 +02:00
Add mission scoring, rewards collection and save schema v2
Phase "score et récompenses" of the post-0.1.0 plan (user feedback: wants a more game-like experience with scoring and rewards). - MissionScoring: 1-3 stars from how each exercise was solved (never speed; a finished mission always gives at least one star). - Save schema v2: mission_results (best/last stars, completions) with a v1->v2 migration that keeps existing stars and items. - Total only grows by the improvement over a mission's best score. - Data-driven collection (data/rewards, reward_item schema, validated incl. mission cross-check) unlocked by RewardRules. - Reward screen, collection screen, stars on the world map. - Version 0.2.0. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,12 +3,26 @@ extends GutTest
|
||||
|
||||
|
||||
func test_current_version_is_returned_unchanged() -> void:
|
||||
var data := {"schema_version": 1, "profile_id": "profile_test"}
|
||||
var data := {"schema_version": 2, "profile_id": "profile_test", "mission_results": {}}
|
||||
var migrated := SaveMigration.migrate(data)
|
||||
assert_eq(migrated["schema_version"], 1)
|
||||
assert_eq(migrated["schema_version"], 2)
|
||||
assert_eq(migrated["profile_id"], "profile_test")
|
||||
|
||||
|
||||
func test_version_1_save_gains_empty_mission_results_and_keeps_its_stars() -> void:
|
||||
var data := SaveFactory.new_save("profile_test", "Explorateur", "CE1")
|
||||
data["schema_version"] = 1
|
||||
data.erase("mission_results")
|
||||
data["rewards"] = {"stars": 4, "items": ["item_a"]}
|
||||
|
||||
var migrated := SaveMigration.migrate(data)
|
||||
|
||||
assert_eq(migrated["schema_version"], 2)
|
||||
assert_eq(migrated["mission_results"], {})
|
||||
assert_eq(migrated["rewards"], {"stars": 4, "items": ["item_a"]})
|
||||
assert_eq(SchemaValidator.validate(migrated, DataLoader.load_schema("save")), [])
|
||||
|
||||
|
||||
func test_missing_version_is_rejected() -> void:
|
||||
var data := {"profile_id": "profile_test"}
|
||||
assert_eq(SaveMigration.migrate(data), {})
|
||||
|
||||
Reference in New Issue
Block a user