mirror of
https://github.com/deunix-educ/aventuriers-des-mots.git
synced 2026-10-13 02:11:58 +02:00
Add the playable scene loop: boot through mission to reward
Wires every autoload up to a real UI: boot -> profile select/create -> world map (three mission markers, positioned from data, not hardcoded pixels) -> mission intro (narrative from data/missions/, a new data type with its own schema) -> rule panel -> exercise host -> one of the three exercise type scenes -> feedback panel -> reward screen -> back to the map. exercise_host is the only piece with real orchestration logic: picks exercises via ExerciseEngine (now fully implemented, validating at load like make validate-data does), validates answers through the pure AnswerValidator/DictationAnalyzer, escalates aid over 3 attempts via AttemptFlow, feeds DifficultyManager so adaptive difficulty is actually wired in rather than dead code, and records every attempt through ProgressManager. Every exercise-type scene (multiple_choice, sentence_correction, dictation) only emits its answer by signal, per the architecture invariant. All child-facing text now comes from data/localization/fr.json via UIText, not hardcoded in scripts or scenes. Getting that right required extending SchemaValidator to support "additionalProperties" as a schema (dynamic keys), which also closed a real gap: save.skills was previously unvalidated against SkillState's actual shape. 16 new headless tests, including two integration tests that instance exercise_host.tscn directly and drive it by emitting child-scene signals, stopping short of the final scene transition (which would tear down the test runner's own tree). Everything that needs a screen -- layout at different sizes, touch, virtual keyboard, actual audio playback (no .ogg files exist yet) -- is listed in the new docs/testing/manual-checklist.md instead of claimed as verified. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
class_name ExercisePicker
|
||||
extends RefCounted
|
||||
## Choisit un exercice parmi une liste de candidats, sans jamais redonner celui
|
||||
## qui vient d'etre traite ("Points durs" du prompt de lancement : une revision
|
||||
## tire un autre exercice de la meme regle, jamais celui qui vient d'etre
|
||||
## rate). Code pur : le generateur aleatoire est injecte, jamais lu
|
||||
## directement.
|
||||
|
||||
|
||||
## Retourne null si `candidates` est vide. Si tous les candidats sont exclus
|
||||
## (un seul exercice disponible), le redonne : pas d'autre choix possible.
|
||||
static func pick(
|
||||
candidates: Array[Dictionary], exclude_id: String, rng: RandomNumberGenerator
|
||||
) -> Variant:
|
||||
if candidates.is_empty():
|
||||
return null
|
||||
|
||||
var pool: Array[Dictionary] = []
|
||||
for candidate in candidates:
|
||||
if candidate["id"] != exclude_id:
|
||||
pool.append(candidate)
|
||||
if pool.is_empty():
|
||||
pool = candidates
|
||||
|
||||
return pool[rng.randi_range(0, pool.size() - 1)]
|
||||
@@ -0,0 +1 @@
|
||||
uid://deb67kr6jsoe
|
||||
@@ -81,8 +81,13 @@ static func _validate_object(
|
||||
for key: String in value.keys():
|
||||
if properties.has(key):
|
||||
_validate_node(value[key], properties[key], "%s.%s" % [path, key], errors)
|
||||
elif additional_allowed == false:
|
||||
elif typeof(additional_allowed) == TYPE_BOOL and additional_allowed == false:
|
||||
errors.append("%s : propriete inattendue '%s'" % [path, key])
|
||||
elif typeof(additional_allowed) == TYPE_DICTIONARY:
|
||||
# additionalProperties est lui-meme un schema : toute cle non
|
||||
# listee dans "properties" doit s'y conformer (cles dynamiques,
|
||||
# ex. une competence par skill_id dans une sauvegarde).
|
||||
_validate_node(value[key], additional_allowed, "%s.%s" % [path, key], errors)
|
||||
|
||||
|
||||
static func _validate_array(
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
class_name UIText
|
||||
extends RefCounted
|
||||
## Textes d'interface destines a l'enfant, charges depuis
|
||||
## data/localization/fr.json : jamais en dur dans les scripts ou les scenes
|
||||
## (voir CLAUDE.md, Conventions de code).
|
||||
|
||||
const LOCALIZATION_PATH := "res://data/localization/fr.json"
|
||||
|
||||
static var _cache: Dictionary = {}
|
||||
|
||||
|
||||
static func get_text(key: String) -> String:
|
||||
if _cache.is_empty():
|
||||
_load()
|
||||
if not _cache.has(key):
|
||||
push_error("Cle de traduction manquante : %s" % key)
|
||||
return key
|
||||
return _cache[key]
|
||||
|
||||
|
||||
static func _load() -> void:
|
||||
var file := FileAccess.open(LOCALIZATION_PATH, FileAccess.READ)
|
||||
if file == null:
|
||||
push_error("Fichier de traduction introuvable : %s" % LOCALIZATION_PATH)
|
||||
return
|
||||
var parsed: Variant = JSON.parse_string(file.get_as_text())
|
||||
_cache = parsed if typeof(parsed) == TYPE_DICTIONARY else {}
|
||||
@@ -0,0 +1 @@
|
||||
uid://ccyua7ei6gssv
|
||||
@@ -12,6 +12,8 @@ func _init() -> void:
|
||||
checked += _validate_simple_dir("res://data/curriculum", "curriculum", failures)
|
||||
checked += _validate_dictations("res://data/dictations", failures)
|
||||
checked += _validate_exercises("res://data/exercises", failures)
|
||||
checked += _validate_missions("res://data/missions", failures)
|
||||
checked += _validate_simple_dir("res://data/localization", "localization", failures)
|
||||
|
||||
if failures.is_empty():
|
||||
print("validate-data : %d fichier(s) JSON valide(s)" % checked)
|
||||
@@ -43,6 +45,30 @@ func _validate_dictations(dir_path: String, failures: Array[String]) -> int:
|
||||
return count
|
||||
|
||||
|
||||
func _validate_missions(dir_path: String, failures: Array[String]) -> int:
|
||||
var known_rule_ids: Array[String] = []
|
||||
for path in DataLoader.find_json_files("res://data/rules"):
|
||||
var rule: Variant = DataLoader.read_json(path)
|
||||
if typeof(rule) == TYPE_DICTIONARY and rule.has("rule_id"):
|
||||
known_rule_ids.append(rule["rule_id"])
|
||||
|
||||
var count := 0
|
||||
for path in DataLoader.find_json_files(dir_path):
|
||||
count += 1
|
||||
var schema_errors := DataLoader.validate_file(path, "mission")
|
||||
failures.append_array(schema_errors)
|
||||
if not schema_errors.is_empty():
|
||||
continue
|
||||
var data: Dictionary = DataLoader.read_json(path)
|
||||
if not known_rule_ids.has(data["rule_id"]):
|
||||
var message := (
|
||||
"%s : rule_id '%s' ne correspond a aucune regle de data/rules"
|
||||
% [path, data["rule_id"]]
|
||||
)
|
||||
failures.append(message)
|
||||
return count
|
||||
|
||||
|
||||
func _validate_exercises(dir_path: String, failures: Array[String]) -> int:
|
||||
var count := 0
|
||||
for path in DataLoader.find_json_files(dir_path):
|
||||
|
||||
@@ -58,3 +58,14 @@ static func unlock_region(save_data: Dictionary, region_id: String) -> Dictionar
|
||||
regions.append(region_id)
|
||||
updated["unlocked_regions"] = regions
|
||||
return updated
|
||||
|
||||
|
||||
## Les recompenses valorisent l'effort et la progression, jamais la vitesse
|
||||
## (cahier des charges §2, principe 6) : un nombre fixe d'etoiles par mission
|
||||
## terminee, quel que soit le temps pris ou le nombre d'aides utilisees.
|
||||
static func add_stars(save_data: Dictionary, amount: int) -> Dictionary:
|
||||
var updated: Dictionary = save_data.duplicate(true)
|
||||
var rewards: Dictionary = updated["rewards"].duplicate(true)
|
||||
rewards["stars"] = int(rewards["stars"]) + amount
|
||||
updated["rewards"] = rewards
|
||||
return updated
|
||||
|
||||
Reference in New Issue
Block a user