mirror of
https://github.com/deunix-educ/aventuriers-des-mots.git
synced 2026-10-13 10:21:58 +02:00
65a0cb46f9
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>
35 lines
1.4 KiB
GDScript
35 lines
1.4 KiB
GDScript
extends GutTest
|
|
## Tests de RewardRules : deblocage des objets selon le total d'etoiles ou le
|
|
## meilleur score d'une mission.
|
|
|
|
var _catalog: Array[Dictionary] = [
|
|
{"item_id": "item_total_3", "unlock": {"type": "total_stars", "count": 3}},
|
|
{"item_id": "item_total_6", "unlock": {"type": "total_stars", "count": 6}},
|
|
{
|
|
"item_id": "item_trophy",
|
|
"unlock": {"type": "mission_stars", "count": 3, "mission_id": "mission_a"}
|
|
},
|
|
]
|
|
|
|
|
|
func test_nothing_unlocks_with_no_stars() -> void:
|
|
assert_eq(RewardRules.newly_unlocked(_catalog, 0, {}, []), [])
|
|
|
|
|
|
func test_total_stars_threshold_unlocks_items_reached() -> void:
|
|
assert_eq(RewardRules.newly_unlocked(_catalog, 3, {}, []), ["item_total_3"])
|
|
assert_eq(RewardRules.newly_unlocked(_catalog, 7, {}, []), ["item_total_3", "item_total_6"])
|
|
|
|
|
|
func test_owned_items_are_not_unlocked_again() -> void:
|
|
assert_eq(RewardRules.newly_unlocked(_catalog, 7, {}, ["item_total_3"]), ["item_total_6"])
|
|
|
|
|
|
func test_mission_trophy_needs_the_best_score_on_that_mission() -> void:
|
|
var two_stars := {"mission_a": {"best_stars": 2}}
|
|
var three_stars := {"mission_a": {"best_stars": 3}}
|
|
assert_eq(RewardRules.newly_unlocked(_catalog, 0, two_stars, []), [])
|
|
assert_eq(RewardRules.newly_unlocked(_catalog, 0, three_stars, []), ["item_trophy"])
|
|
var other_mission := {"mission_b": {"best_stars": 3}}
|
|
assert_eq(RewardRules.newly_unlocked(_catalog, 0, other_mission, []), [])
|