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:
Denis Defolie
2026-10-11 22:20:59 +02:00
parent 57182172a9
commit 65a0cb46f9
47 changed files with 897 additions and 36 deletions
+54
View File
@@ -0,0 +1,54 @@
extends Control
## Collection d'objets gagnes avec les etoiles. Un objet non debloque reste
## mysterieux mais indique comment l'obtenir (jamais de mystere frustrant).
@onready var _title_label: Label = %TitleLabel
@onready var _progress_label: Label = %ProgressLabel
@onready var _items_box: VBoxContainer = %ItemsBox
@onready var _back_button: Button = %BackButton
func _ready() -> void:
_title_label.text = UIText.get_text("collection.title")
_back_button.text = UIText.get_text("collection.back_button")
_back_button.pressed.connect(_on_back_pressed)
var owned: Array = ProgressManager.owned_items()
var catalog := ExerciseEngine.get_reward_items()
var found := 0
for item in catalog:
var is_owned := owned.has(item["item_id"])
if is_owned:
found += 1
_items_box.add_child(_build_row(item, is_owned))
_progress_label.text = (
"%s %d/%d" % [UIText.get_text("collection.progress_label"), found, catalog.size()]
)
func _build_row(item: Dictionary, is_owned: bool) -> Control:
var label := Label.new()
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
label.custom_minimum_size = Vector2(560, 0)
if is_owned:
label.text = (
"%s — %s\n%s"
% [item["title"], UIText.get_text("collection.owned_marker"), item["description"]]
)
else:
label.text = (
"%s\n%s" % [UIText.get_text("collection.locked_title"), _unlock_hint(item["unlock"])]
)
return label
func _unlock_hint(unlock: Dictionary) -> String:
var count: int = int(unlock["count"])
if unlock["type"] == "mission_stars":
var mission := ExerciseEngine.get_mission(unlock.get("mission_id", ""))
return UIText.get_text("collection.unlock_mission_stars") % [count, mission.get("title", "")]
return UIText.get_text("collection.unlock_total_stars") % count
func _on_back_pressed() -> void:
GameManager.goto(GameManager.SCENE_WORLD_MAP)