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
+42 -10
View File
@@ -1,28 +1,60 @@
extends Control
## Ecran de recompense : une mission terminee rapporte toujours la meme
## recompense, que l'enfant ait eu besoin d'aide ou non (cahier des charges
## §2, principe 6 : pas de recompense liee a la vitesse ou a la performance).
## Sauvegarde groupee ici, en fin de mission (docs/specs/decisions.md point 7).
const STARS_PER_MISSION := 1
## Ecran de fin de mission : etoiles gagnees (1 a 3, selon la reussite et
## l'aide utilisee, jamais selon la vitesse : cahier des charges §2), total,
## nouveaux objets de la collection. Une mission terminee rapporte toujours
## au moins une etoile. Sauvegarde groupee ici, en fin de mission
## (docs/specs/decisions.md point 7).
@onready var _title_label: Label = %TitleLabel
@onready var _stars_label: Label = %StarsLabel
@onready var _message_label: Label = %MessageLabel
@onready var _record_label: Label = %RecordLabel
@onready var _total_label: Label = %TotalLabel
@onready var _new_items_label: Label = %NewItemsLabel
@onready var _collection_button: Button = %CollectionButton
@onready var _continue_button: Button = %ContinueButton
func _ready() -> void:
ProgressManager.add_stars(STARS_PER_MISSION)
var summary := ProgressManager.complete_mission(
GameManager.pending_mission_id, GameManager.last_outcomes
)
ProgressManager.save_now()
_title_label.text = UIText.get_text("reward_screen.title")
_stars_label.text = "%s %d" % [
UIText.get_text("reward_screen.stars_label"), ProgressManager.stars()
]
_stars_label.text = (
"%s %d/%d"
% [UIText.get_text("reward_screen.stars_label"), summary["stars"], MissionScoring.MAX_STARS]
)
_message_label.text = UIText.get_text("reward_screen.message_%d" % summary["stars"])
_record_label.text = UIText.get_text("reward_screen.record_label")
_record_label.visible = summary["is_record"]
_total_label.text = (
"%s %d" % [UIText.get_text("reward_screen.total_label"), summary["total_stars"]]
)
var new_items: Array = summary["new_items"]
_new_items_label.visible = not new_items.is_empty()
if not new_items.is_empty():
var titles: Array[String] = []
for item in ExerciseEngine.get_reward_items():
if new_items.has(item["item_id"]):
titles.append(item["title"])
_new_items_label.text = (
"%s\n%s" % [UIText.get_text("reward_screen.new_items_label"), "\n".join(titles)]
)
_collection_button.text = UIText.get_text("reward_screen.collection_button")
_collection_button.pressed.connect(_on_collection_pressed)
_continue_button.text = UIText.get_text("reward_screen.continue_button")
_continue_button.pressed.connect(_on_continue_pressed)
func _on_collection_pressed() -> void:
GameManager.pending_mission_id = ""
GameManager.goto(GameManager.SCENE_COLLECTION)
func _on_continue_pressed() -> void:
GameManager.pending_mission_id = ""
GameManager.goto(GameManager.SCENE_WORLD_MAP)