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
+17
View File
@@ -23,6 +23,8 @@ var _current_difficulty := 1
var _attempt_number := 1
var _completed_count := 0
var _last_exercise_id := ""
var _outcomes: Array[String] = []
var _pending_outcome := ""
@onready var _exercise_container: Control = %ExerciseContainer
@onready var _overlay_container: Control = %OverlayContainer
@@ -43,6 +45,10 @@ func get_completed_count() -> int:
return _completed_count
func get_outcomes() -> Array[String]:
return _outcomes
func _ready() -> void:
_mission = ExerciseEngine.get_mission(GameManager.pending_mission_id)
_rule = ExerciseEngine.get_rule(_mission["rule_id"])
@@ -126,6 +132,15 @@ func _handle_result(result: CorrectionResult) -> void:
support_level = AttemptFlow.support_level_for_attempt(_attempt_number)
is_terminal = AttemptFlow.should_end_exercise(_attempt_number)
if result.is_correct:
_pending_outcome = (
MissionScoring.OUTCOME_FIRST_TRY
if _attempt_number == 1
else MissionScoring.OUTCOME_WITH_HELP
)
elif is_terminal:
_pending_outcome = MissionScoring.OUTCOME_REVEALED
ProgressManager.record_attempt(
_skill_id, result.is_correct, _attempt_number > 1, _mission["exercise_type"]
)
@@ -154,8 +169,10 @@ func _on_feedback_continued(feedback: Control, is_terminal: bool) -> void:
)
_last_exercise_id = _current_exercise.get("id", "")
_completed_count += 1
_outcomes.append(_pending_outcome)
if _completed_count >= MISSION_LENGTH:
GameManager.last_outcomes = _outcomes.duplicate()
GameManager.goto(GameManager.SCENE_REWARD)
else:
_load_next_exercise()