Commandes personnage : détection de touche au clavier + touches d'animation supplémentaires
Build and deploy / test-python (push) Successful in 6m17s
Build and deploy / test-js (push) Successful in 53s
Build and deploy / build-and-push (push) Skipped
Build and deploy / deploy (push) Skipped

Deux retours utilisateur sur le panneau "Commandes" (déplacement/
animation automatiques, voir précédent commit) :
- Les champs de touche (haut/bas/gauche/droite/interagir) capturent
  maintenant la touche au clavier (clic puis appui — event.key, même
  valeur que heldKeys/triggers.js) au lieu d'être tapés à la main,
  source d'erreurs ("Espace" vs " ", "flèche haut" vs "ArrowUp"...).
- Nouvelle section "Animations supplémentaires" : un nombre illimité de
  touches, chacune liée à UNE pose au choix parmi celles réellement
  disponibles pour ce personnage (sauter, attaquer, courir...) — pas
  seulement les 4 touches de déplacement + interagir.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
william
2026-09-02 11:50:29 +02:00
co-authored by Claude Sonnet 5
parent 74f7ca396f
commit 5891c82c62
8 changed files with 209 additions and 22 deletions
+43 -1
View File
@@ -51,10 +51,52 @@ def test_commands_route_persists_remapped_keys_and_axis_lock(client, tmp_game_sl
commands = screens.resolve_personnage_commands(obj)
assert commands == {
"haut": "ArrowUp", "bas": "ArrowDown", "gauche": "ArrowLeft", "droite": "ArrowRight",
"interagir": " ", "axe": "horizontal", "vitesse": 8,
"interagir": " ", "axe": "horizontal", "vitesse": 8, "extra": [],
}
def test_commands_route_persists_extra_animation_bound_keys(client, tmp_game_slug_cleanup):
"""Touches supplémentaires (sauter, attaquer...) — bug remonté par
l'utilisateur : au-delà des 4 touches de déplacement et de
"interagir", il manquait un moyen de lier une touche à N'IMPORTE
QUELLE autre pose du personnage."""
slug, screen_id = _create_jeu2d_game(client, tmp_game_slug_cleanup)
obj_id = _add_personnage(client, slug, screen_id)
resp = client.post(
f"/game/{slug}/scene-objects/{obj_id}/commandes",
data='{"extra": [{"touche": "j", "animation": "jump"}, {"touche": "a", "animation": "attack"}]}',
content_type="application/json",
)
commands = resp.get_json()["commands"]
assert commands["extra"] == [{"touche": "j", "animation": "jump"}, {"touche": "a", "animation": "attack"}]
obj = screens.get_scene_object(slug, obj_id)
assert screens.resolve_personnage_commands(obj)["extra"] == commands["extra"]
def test_commands_route_drops_malformed_extra_entries(client, tmp_game_slug_cleanup):
"""Une entrée sans touche/animation, un doublon de type, ou une liste
qui n'en est pas une : ignorée plutôt que de planter ou de polluer le
panneau avec une ligne inutilisable côté client."""
slug, screen_id = _create_jeu2d_game(client, tmp_game_slug_cleanup)
obj_id = _add_personnage(client, slug, screen_id)
resp = client.post(
f"/game/{slug}/scene-objects/{obj_id}/commandes",
data='{"extra": [{"touche": "j", "animation": "jump"}, {"touche": ""}, {"animation": "attack"}, "pas un objet", 42]}',
content_type="application/json",
)
assert resp.get_json()["commands"]["extra"] == [{"touche": "j", "animation": "jump"}]
resp = client.post(
f"/game/{slug}/scene-objects/{obj_id}/commandes",
data='{"extra": "pas une liste"}',
content_type="application/json",
)
assert resp.get_json()["commands"]["extra"] == []
def test_commands_route_rejects_invalid_axis_and_clamps_speed(client, tmp_game_slug_cleanup):
"""Un axe inconnu retombe sur "libre", une vitesse hors bornes est
ramenée dans [1, 20] — jamais une valeur qui planterait le calcul