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:
@@ -50,3 +50,21 @@ static func check_dictation(data: Dictionary, path: String) -> Array[String]:
|
||||
)
|
||||
)
|
||||
return errors
|
||||
|
||||
|
||||
static func check_reward_item(data: Dictionary, path: String) -> Array[String]:
|
||||
var errors: Array[String] = []
|
||||
var unlock: Dictionary = data.get("unlock", {})
|
||||
var count: int = int(unlock.get("count", 0))
|
||||
match unlock.get("type", ""):
|
||||
"total_stars":
|
||||
if unlock.has("mission_id"):
|
||||
errors.append("%s : total_stars ne prend pas de mission_id" % path)
|
||||
"mission_stars":
|
||||
if not unlock.has("mission_id"):
|
||||
errors.append("%s : mission_stars exige un mission_id" % path)
|
||||
if count > 3:
|
||||
errors.append(
|
||||
"%s : une mission rapporte au plus 3 etoiles (count=%d)" % [path, count]
|
||||
)
|
||||
return errors
|
||||
|
||||
@@ -13,6 +13,7 @@ func _init() -> void:
|
||||
checked += _validate_dictations("res://data/dictations", failures)
|
||||
checked += _validate_exercises("res://data/exercises", failures)
|
||||
checked += _validate_missions("res://data/missions", failures)
|
||||
checked += _validate_rewards("res://data/rewards", failures)
|
||||
checked += _validate_simple_dir("res://data/localization", "localization", failures)
|
||||
|
||||
if failures.is_empty():
|
||||
@@ -92,3 +93,27 @@ func _validate_exercises(dir_path: String, failures: Array[String]) -> int:
|
||||
"sentence_correction":
|
||||
failures.append_array(SemanticChecks.check_sentence_correction(data, path))
|
||||
return count
|
||||
|
||||
|
||||
func _validate_rewards(dir_path: String, failures: Array[String]) -> int:
|
||||
var known_mission_ids: Array[String] = []
|
||||
for path in DataLoader.find_json_files("res://data/missions"):
|
||||
var mission: Variant = DataLoader.read_json(path)
|
||||
if typeof(mission) == TYPE_DICTIONARY and mission.has("mission_id"):
|
||||
known_mission_ids.append(mission["mission_id"])
|
||||
|
||||
var count := 0
|
||||
for path in DataLoader.find_json_files(dir_path):
|
||||
count += 1
|
||||
var schema_errors := DataLoader.validate_file(path, "reward_item")
|
||||
failures.append_array(schema_errors)
|
||||
if not schema_errors.is_empty():
|
||||
continue
|
||||
var data: Dictionary = DataLoader.read_json(path)
|
||||
failures.append_array(SemanticChecks.check_reward_item(data, path))
|
||||
var mission_id: String = data["unlock"].get("mission_id", "")
|
||||
if not mission_id.is_empty() and not known_mission_ids.has(mission_id):
|
||||
failures.append(
|
||||
"%s : mission_id '%s' ne correspond a aucune mission" % [path, mission_id]
|
||||
)
|
||||
return count
|
||||
|
||||
Reference in New Issue
Block a user