Phase 3 : hardening qualite de code - typage strict, securite, dead code, a11y
Config strictement stricte partout (ruff, mypy --strict, bandit, vulture, import-linter, eslint, stylelint), aucune regle desactivee "pour ne pas casser le build" - l'existant a ete corrige pour la satisfaire plutot que l'inverse. Hooks pre-commit locaux (language: system) bloquants. - Typage mypy --strict propage a tout le moteur (db, screens, auth, core, ai, routes, puis publish/scripts/tests/app.py/build_css.py). - Securite : fuite de handle fichier Windows corrigee dans l'export SCORM (routes/publish/export_scorm.py), CSRF/RNG non-crypto/xAPI documentes (# nosec, # NOSONAR justifies), nouveau db.json_for_script() (echappe "</script>" dans le JSON embarque en <script>, 25 sites). - Architecture : imports circulaires/F811 nettoyes, contrats import-linter respectes, code mort retire (vulture). - Accessibilite : 69 champs de formulaire sans label correctement associe corriges (for/id ou aria-label) sur 11 templates. - ESLint/Stylelint : lot mecanique JS/CSS, regles ajustees puis appliquees (aucune desactivee sans verification individuelle). - Tests : isolation du compte admin partage (nettoyage ponctuel + fixture de teardown automatique en filet de securite), suite complete verte (591 tests Python, 241 tests JS). - SonarQube Community Build self-heberge (Docker + PostgreSQL) : rapport complet analyse point par point, faux positifs documentes. - .gitattributes ajoute (LF force) : core.autocrlf=true sur cette machine faisait echouer ESLint (linebreak-style) via un bug connu de git (checkout "en place" qui ignore l'eol force sur un fichier deja present sur disque - contourne en supprimant puis recreant chaque fichier suivi). djLint (H021, styles inline) volontairement saute pour ce commit - backlog assume, deja documente, traite dans un lot separe. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
7db4803b93
commit
c57420c8c9
@@ -24,7 +24,18 @@ _DECOR_DEFAULT_SIZE = (200, 200)
|
||||
_DECOR_COLLISION_SIZE = (150, 150)
|
||||
|
||||
|
||||
def add_scene_object(slug, scene_id, kind="personnage", forge_character=None, background_slug=None, image_url=None, image_width=None, image_height=None, x=None, y=None):
|
||||
def add_scene_object(
|
||||
slug: str,
|
||||
scene_id: int,
|
||||
kind: str = "personnage",
|
||||
forge_character: str | None = None,
|
||||
background_slug: str | None = None,
|
||||
image_url: str | None = None,
|
||||
image_width: int | None = None,
|
||||
image_height: int | None = None,
|
||||
x: float | None = None,
|
||||
y: float | None = None,
|
||||
) -> int:
|
||||
"""Pose un nouvel objet sur une scène (voir ensure_scene_schema.py).
|
||||
kind="personnage" : attributes._personnage_data, MÊME structure/mêmes
|
||||
fonctions resolve_personnage_* que le widget "personnage" de l'éditeur
|
||||
@@ -64,8 +75,9 @@ def add_scene_object(slug, scene_id, kind="personnage", forge_character=None, ba
|
||||
if kind == "personnage":
|
||||
data = dict(_DEFAULT_PERSONNAGE_DATA)
|
||||
if forge_character:
|
||||
from ..labels.sprite_library import PUBLIC_SPRITE_LIBRARY
|
||||
from ..labels.animal_sprite_library import ADMIN_SPRITE_LIBRARY
|
||||
from ..labels.sprite_library import PUBLIC_SPRITE_LIBRARY
|
||||
|
||||
if forge_character in PUBLIC_SPRITE_LIBRARY or forge_character in ADMIN_SPRITE_LIBRARY:
|
||||
data["forge_character"] = forge_character
|
||||
attributes["_personnage_data"] = json.dumps(data)
|
||||
@@ -86,11 +98,15 @@ def add_scene_object(slug, scene_id, kind="personnage", forge_character=None, ba
|
||||
elif kind == "decor" and image_url:
|
||||
attributes["src"] = image_url
|
||||
width, height = _DECOR_DEFAULT_SIZE
|
||||
attributes["_collision"] = json.dumps({
|
||||
"width": _DECOR_COLLISION_SIZE[0], "height": _DECOR_COLLISION_SIZE[1],
|
||||
})
|
||||
attributes["_collision"] = json.dumps(
|
||||
{
|
||||
"width": _DECOR_COLLISION_SIZE[0],
|
||||
"height": _DECOR_COLLISION_SIZE[1],
|
||||
}
|
||||
)
|
||||
elif kind == "fond" and background_slug:
|
||||
from ..labels.background_library import BACKGROUND_LIBRARY
|
||||
|
||||
background = BACKGROUND_LIBRARY.get(background_slug)
|
||||
if background:
|
||||
attributes["src"] = background["url"]
|
||||
@@ -104,9 +120,9 @@ def add_scene_object(slug, scene_id, kind="personnage", forge_character=None, ba
|
||||
if kind == "fond":
|
||||
z_index = -1000
|
||||
else:
|
||||
max_z = conn.execute(
|
||||
"SELECT MAX(z_index) AS m FROM _scene_objects WHERE scene_id = ?", (scene_id,)
|
||||
).fetchone()["m"]
|
||||
max_z = conn.execute("SELECT MAX(z_index) AS m FROM _scene_objects WHERE scene_id = ?", (scene_id,)).fetchone()[
|
||||
"m"
|
||||
]
|
||||
z_index = (max_z or 0) + 1
|
||||
cols = ["scene_id", "kind", "attributes", "z_index"]
|
||||
values = [scene_id, kind, json.dumps(attributes), z_index]
|
||||
@@ -123,8 +139,8 @@ def add_scene_object(slug, scene_id, kind="personnage", forge_character=None, ba
|
||||
cols += ["x", "y"]
|
||||
values += [x, y]
|
||||
placeholders = ", ".join(["?"] * len(values))
|
||||
conn.execute(f"INSERT INTO _scene_objects ({', '.join(cols)}) VALUES ({placeholders})", values)
|
||||
object_id = conn.execute("SELECT last_insert_rowid() AS id").fetchone()["id"]
|
||||
conn.execute(f"INSERT INTO _scene_objects ({', '.join(cols)}) VALUES ({placeholders})", values) # nosec B608 # noqa: S608 - cols construit uniquement a partir de litteraux Python, jamais d'une cle arbitraire ; valeurs parametrees (?)
|
||||
object_id = int(conn.execute("SELECT last_insert_rowid() AS id").fetchone()["id"])
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return object_id
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
from typing import Any
|
||||
|
||||
from ..rendering.collision_rules import resolve_collision_rules, sanitize_collision_rules, set_then_action_in_rules
|
||||
from .get_scene_object import get_scene_object
|
||||
from .set_scene_object_collision_rules import set_scene_object_collision_rules
|
||||
from ..rendering.collision_rules import resolve_collision_rules, sanitize_collision_rules, set_then_action_in_rules
|
||||
|
||||
|
||||
def append_action_to_trigger(slug, object_id, after_id, raw_action):
|
||||
""""+ Ajouter une action" — extrait de routes/triggers/triggers.py::
|
||||
def append_action_to_trigger(slug: str, object_id: int, after_id: str, raw_action: Any) -> bool:
|
||||
""" "+ Ajouter une action" — extrait de routes/triggers/triggers.py::
|
||||
trigger_append_action pour être l'UNIQUE chemin d'écriture, partagé
|
||||
par la route HTTP ET par l'agent IA (voir ai/tools.py) : ni l'un ni
|
||||
l'autre n'écrit `_collision_rules` directement, tous deux passent par
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
from typing import Any
|
||||
|
||||
import screens
|
||||
|
||||
_DEFAULT_OBJECT_LABELS = {"personnage": "Personnage", "fond": "Fond"}
|
||||
_COLLISION_EXCLUDED_KINDS = ("fond", "dialogue_box", "quiz_box", "score_widget")
|
||||
|
||||
|
||||
def build_collision_rule_objects(objects):
|
||||
def build_collision_rule_objects(objects: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||
"""Une carte "🧩 Collision" (voir templates/scene_edit.html) par objet
|
||||
ÉLIGIBLE (jamais un "fond", jamais le personnage "joueur" — ce sont
|
||||
TOUJOURS les AUTRES objets qui réagissent à SA présence, voir
|
||||
@@ -33,14 +35,13 @@ def build_collision_rule_objects(objects):
|
||||
rôle explicite sont traités comme "pnj" ici, sans rien réécrire en
|
||||
base."""
|
||||
implicit_joueur_claimed = any(
|
||||
(o.get("attributes") or {}).get("_personnage_role") == "joueur"
|
||||
for o in objects if o["kind"] == "personnage"
|
||||
(o.get("attributes") or {}).get("_personnage_role") == "joueur" for o in objects if o["kind"] == "personnage"
|
||||
)
|
||||
result = []
|
||||
result: list[dict[str, Any]] = []
|
||||
for o in objects:
|
||||
if o["kind"] in _COLLISION_EXCLUDED_KINDS:
|
||||
continue
|
||||
role = None
|
||||
role: str | None = None
|
||||
if o["kind"] == "personnage":
|
||||
explicit_role = (o.get("attributes") or {}).get("_personnage_role")
|
||||
if explicit_role in screens.PERSONNAGE_ROLES:
|
||||
@@ -52,12 +53,14 @@ def build_collision_rule_objects(objects):
|
||||
role = "pnj"
|
||||
if role == "joueur":
|
||||
continue
|
||||
result.append({
|
||||
"id": o["id"],
|
||||
"name": o.get("name") or _DEFAULT_OBJECT_LABELS.get(o["kind"], "Décor"),
|
||||
"kind": o["kind"],
|
||||
"role": role,
|
||||
"thumbnail_html": o["rendered_html"],
|
||||
"rules": screens.resolve_collision_rules(o),
|
||||
})
|
||||
result.append(
|
||||
{
|
||||
"id": o["id"],
|
||||
"name": o.get("name") or _DEFAULT_OBJECT_LABELS.get(o["kind"], "Décor"),
|
||||
"kind": o["kind"],
|
||||
"role": role,
|
||||
"thumbnail_html": o["rendered_html"],
|
||||
"rules": screens.resolve_collision_rules(o),
|
||||
}
|
||||
)
|
||||
return result
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import db
|
||||
|
||||
from .ensure_scene_schema import ensure_scene_schema
|
||||
from ..animations.ensure_animation_schema import ensure_animation_schema
|
||||
from ..flow.ensure_flow_schema import ensure_flow_schema
|
||||
from .ensure_scene_schema import ensure_scene_schema
|
||||
|
||||
|
||||
def delete_scene_object(slug, object_id):
|
||||
def delete_scene_object(slug: str, object_id: int) -> None:
|
||||
"""Supprime un objet de scène ET les nœuds de logique qui le
|
||||
référencent (trigger_object_id/target_object_id/cond_element_a/
|
||||
cond_element_b — aucun n'a de contrainte FK, voir
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import db
|
||||
|
||||
|
||||
def ensure_scene_schema(slug):
|
||||
def ensure_scene_schema(slug: str) -> None:
|
||||
"""Crée _scene_objects si nécessaire — le contenu d'une scène pour un
|
||||
jeu "jeu_2d" (voir db/games/get_game_type.py), équivalent de
|
||||
_screen_elements pour un jeu "document" mais en coordonnées PIXEL
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
import db
|
||||
|
||||
from .ensure_scene_schema import ensure_scene_schema
|
||||
|
||||
|
||||
def get_scene_object(slug, object_id):
|
||||
def get_scene_object(slug: str, object_id: int) -> dict[str, Any] | None:
|
||||
ensure_scene_schema(slug)
|
||||
conn = db.connect(slug)
|
||||
row = conn.execute("SELECT * FROM _scene_objects WHERE id = ?", (object_id,)).fetchone()
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
import db
|
||||
|
||||
from .ensure_scene_schema import ensure_scene_schema
|
||||
|
||||
|
||||
def list_scene_objects(slug, scene_id):
|
||||
def list_scene_objects(slug: str, scene_id: int) -> list[dict[str, Any]]:
|
||||
ensure_scene_schema(slug)
|
||||
conn = db.connect(slug)
|
||||
rows = conn.execute(
|
||||
"SELECT * FROM _scene_objects WHERE scene_id = ? ORDER BY z_index, id", (scene_id,)
|
||||
).fetchall()
|
||||
rows = conn.execute("SELECT * FROM _scene_objects WHERE scene_id = ? ORDER BY z_index, id", (scene_id,)).fetchall()
|
||||
conn.close()
|
||||
result = []
|
||||
result: list[dict[str, Any]] = []
|
||||
for r in rows:
|
||||
d = dict(r)
|
||||
d["attributes"] = json.loads(d["attributes"] or "{}")
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from ..rendering.collision_rules import move_action_in_rules, resolve_collision_rules, sanitize_collision_rules
|
||||
from .get_scene_object import get_scene_object
|
||||
from .set_scene_object_collision_rules import set_scene_object_collision_rules
|
||||
from ..rendering.collision_rules import resolve_collision_rules, sanitize_collision_rules, move_action_in_rules
|
||||
|
||||
|
||||
def move_action_in_trigger(slug, object_id, leaf_id, direction):
|
||||
def move_action_in_trigger(slug: str, object_id: int, leaf_id: str, direction: str) -> bool:
|
||||
"""Déplace une action précise d'un cran ("up"/"down", voir
|
||||
screens/rendering/collision_rules.py::move_action_in_rules) dans son
|
||||
déclencheur d'OBJET — même patron qu'append_action_to_trigger."""
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from ..rendering.collision_rules import remove_action_from_rules, resolve_collision_rules, sanitize_collision_rules
|
||||
from .get_scene_object import get_scene_object
|
||||
from .set_scene_object_collision_rules import set_scene_object_collision_rules
|
||||
from ..rendering.collision_rules import resolve_collision_rules, sanitize_collision_rules, remove_action_from_rules
|
||||
|
||||
|
||||
def remove_action_from_trigger(slug, object_id, leaf_id):
|
||||
def remove_action_from_trigger(slug: str, object_id: int, leaf_id: str) -> bool:
|
||||
"""Retire une action précise (voir screens/rendering/collision_rules.py
|
||||
::remove_action_from_rules) d'un déclencheur d'OBJET — même patron
|
||||
qu'append_action_to_trigger : UNIQUE chemin d'écriture, partagé par la
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import html as html_lib
|
||||
from typing import Any
|
||||
|
||||
from ..rendering.personnage_data import resolve_personnage_idle_frame
|
||||
from ..rendering.dialogue_box_style import resolve_dialogue_box_style
|
||||
from ..rendering.personnage_data import resolve_personnage_idle_frame
|
||||
from ..rendering.quiz_box_config import resolve_quiz_box_config
|
||||
from ..rendering.quiz_box_templates import render_quiz_box
|
||||
|
||||
|
||||
def render_scene_object(obj):
|
||||
def render_scene_object(obj: dict[str, Any]) -> str:
|
||||
"""HTML d'un objet de scène — positionnement en PIXELS ABSOLUS (pas de
|
||||
% fluide, voir ensure_scene_schema.py), mirror volontairement plus
|
||||
simple que render_element_html.py (pas d'arbre de nesting, pas de
|
||||
@@ -52,12 +53,12 @@ def render_scene_object(obj):
|
||||
# collision "dialogue" ait un dialogue à afficher. Toujours VISIBLE
|
||||
# dans l'éditeur (avec un texte d'exemple) pour pouvoir le
|
||||
# positionner/styliser.
|
||||
style = resolve_dialogue_box_style(obj)
|
||||
box_theme = resolve_dialogue_box_style(obj)
|
||||
box_style = (
|
||||
f"position:absolute; left:{obj['x']}px; top:{obj['y']}px; "
|
||||
f"width:{obj['width']}px; height:{obj['height']}px; z-index:{obj['z_index']}; "
|
||||
f"font-family:{html_lib.escape(style['font_family'])}; font-size:{style['font_size']}px; "
|
||||
f"font-weight:{style['font_weight']}; color:{html_lib.escape(style['text_color'])};"
|
||||
f"font-family:{html_lib.escape(box_theme['font_family'])}; font-size:{box_theme['font_size']}px; "
|
||||
f"font-weight:{box_theme['font_weight']}; color:{html_lib.escape(box_theme['text_color'])};"
|
||||
)
|
||||
return (
|
||||
# role="dialog"/aria-live (RGAA/WCAG 4.1.3) : le texte de
|
||||
@@ -65,12 +66,17 @@ def render_scene_object(obj):
|
||||
# static/js/play/dialogue-box-controller.js) sans jamais
|
||||
# recharger la page — sans annonce explicite, un lecteur
|
||||
# d'écran ne détecte aucun changement.
|
||||
f'<div class="dialogueBoxWidget" role="dialog" aria-live="polite" aria-atomic="true" data-object-id="{obj["id"]}" data-element-id="{obj["id"]}" style="{box_style}">'
|
||||
f'<div class="dialogueBoxHeader" data-dialogue-role="header" style="background:{html_lib.escape(style["header_bg"])}">Nom du personnage</div>'
|
||||
f'<div class="dialogueBoxBody" data-dialogue-role="body" style="background:{html_lib.escape(style["body_bg"])}">Le texte du dialogue s\'affiche ici.</div>'
|
||||
f'<div class="dialogueBoxFooter" data-dialogue-role="footer" style="background:{html_lib.escape(style["footer_bg"])}">'
|
||||
f'<button type="button" class="dialogueBoxNextBtn" data-dialogue-role="next-btn" onclick="forgeDialogueBoxAdvance({obj["id"]})">Suivant →</button>'
|
||||
f'</div></div>'
|
||||
f'<div class="dialogueBoxWidget" role="dialog" aria-live="polite" aria-atomic="true" '
|
||||
f'data-object-id="{obj["id"]}" data-element-id="{obj["id"]}" style="{box_style}">'
|
||||
f'<div class="dialogueBoxHeader" data-dialogue-role="header" '
|
||||
f'style="background:{html_lib.escape(box_theme["header_bg"])}">Nom du personnage</div>'
|
||||
f'<div class="dialogueBoxBody" data-dialogue-role="body" '
|
||||
f'style="background:{html_lib.escape(box_theme["body_bg"])}">Le texte du dialogue s\'affiche ici.</div>'
|
||||
f'<div class="dialogueBoxFooter" data-dialogue-role="footer" '
|
||||
f'style="background:{html_lib.escape(box_theme["footer_bg"])}">'
|
||||
f'<button type="button" class="dialogueBoxNextBtn" data-dialogue-role="next-btn" '
|
||||
f'onclick="forgeDialogueBoxAdvance({obj["id"]})">Suivant →</button>'
|
||||
f"</div></div>"
|
||||
)
|
||||
if obj["kind"] == "quiz_box":
|
||||
# Widget "❓ Boîte à quiz" (voir "🖥️ Interface") — réutilise le
|
||||
@@ -85,9 +91,9 @@ def render_scene_object(obj):
|
||||
# respectent le même contrat de data-quiz-role, lu EN JEU par
|
||||
# static/js/play/dialogue-box-controller.js. "defaut" (Classique)
|
||||
# reste pixel-identique au rendu d'avant cette extension.
|
||||
style = resolve_dialogue_box_style(obj)
|
||||
box_theme = resolve_dialogue_box_style(obj)
|
||||
config = resolve_quiz_box_config(obj)
|
||||
return render_quiz_box(obj, config, style)
|
||||
return render_quiz_box(obj, config, box_theme)
|
||||
if obj["kind"] == "score_widget":
|
||||
# Widget "🏆 Score" (voir "🖥️ Interface") — toujours VISIBLE une
|
||||
# fois posé (pas de collision/déclencheur, contrairement aux deux
|
||||
@@ -95,18 +101,18 @@ def render_scene_object(obj):
|
||||
# cours (voir static/js/play/dialogue-box-controller.js::
|
||||
# forgeUpdateAllScoreWidgets). Même style que les deux autres
|
||||
# widgets, header_bg sert de fond unique (pas de zone body/footer).
|
||||
style = resolve_dialogue_box_style(obj)
|
||||
box_theme = resolve_dialogue_box_style(obj)
|
||||
box_style = (
|
||||
f"position:absolute; left:{obj['x']}px; top:{obj['y']}px; "
|
||||
f"width:{obj['width']}px; height:{obj['height']}px; z-index:{obj['z_index']}; "
|
||||
f"font-family:{html_lib.escape(style['font_family'])}; font-size:{style['font_size']}px; "
|
||||
f"font-weight:{style['font_weight']}; color:{html_lib.escape(style['text_color'])}; "
|
||||
f"background:{html_lib.escape(style['header_bg'])};"
|
||||
f"font-family:{html_lib.escape(box_theme['font_family'])}; font-size:{box_theme['font_size']}px; "
|
||||
f"font-weight:{box_theme['font_weight']}; color:{html_lib.escape(box_theme['text_color'])}; "
|
||||
f"background:{html_lib.escape(box_theme['header_bg'])};"
|
||||
)
|
||||
return (
|
||||
f'<div class="scoreWidget" data-object-id="{obj["id"]}" data-element-id="{obj["id"]}" style="{box_style}">'
|
||||
f'🏆 <span data-score-role="value">0</span>'
|
||||
f'</div>'
|
||||
f"</div>"
|
||||
)
|
||||
if obj["kind"] == "personnage":
|
||||
src = resolve_personnage_idle_frame(obj)
|
||||
@@ -117,8 +123,10 @@ def render_scene_object(obj):
|
||||
# un dialogue de quête réutilise le même nom). alt="" (décoratif)
|
||||
# sinon, jamais le nom de fichier brut par défaut du navigateur.
|
||||
alt_attr = f' alt="{html_lib.escape(obj.get("name") or "")}"'
|
||||
return (f'<img class="sceneObjectSprite" data-object-id="{obj["id"]}" data-element-id="{obj["id"]}" '
|
||||
f'data-anim-target="{obj["id"]}" data-personnage="1" style="{style}"{src_attr}{alt_attr}>')
|
||||
return (
|
||||
f'<img class="sceneObjectSprite" data-object-id="{obj["id"]}" data-element-id="{obj["id"]}" '
|
||||
f'data-anim-target="{obj["id"]}" data-personnage="1" style="{style}"{src_attr}{alt_attr}>'
|
||||
)
|
||||
src = (obj.get("attributes") or {}).get("src", "")
|
||||
src_attr = f' src="{html_lib.escape(src)}"' if src else ""
|
||||
# "fond" (voir add_scene_object.py) : même image fixe que "decor",
|
||||
@@ -132,5 +140,7 @@ def render_scene_object(obj):
|
||||
# information à transmettre) — un "decor" nommé par l'auteur utilise
|
||||
# ce nom, sinon alt="" plutôt qu'aucun attribut du tout.
|
||||
alt_attr = ' alt=""' if obj["kind"] == "fond" else f' alt="{html_lib.escape(obj.get("name") or "")}"'
|
||||
return (f'<img class="{css_class}" data-object-id="{obj["id"]}" data-element-id="{obj["id"]}" '
|
||||
f'data-anim-target="{obj["id"]}" style="{style}"{src_attr}{alt_attr}>')
|
||||
return (
|
||||
f'<img class="{css_class}" data-object-id="{obj["id"]}" data-element-id="{obj["id"]}" '
|
||||
f'data-anim-target="{obj["id"]}" style="{style}"{src_attr}{alt_attr}>'
|
||||
)
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
def resolve_scene_world_size(screen, objects):
|
||||
from typing import Any
|
||||
|
||||
|
||||
def resolve_scene_world_size(screen: dict[str, Any], objects: list[dict[str, Any]]) -> tuple[int, int]:
|
||||
"""Taille du "monde" d'une scène 2D (voir static/js/play/personnage-
|
||||
controller.js::forgeUpdateSceneWorldSize, même principe côté serveur) :
|
||||
un "fond" posé à sa taille RÉELLE (souvent plus grande que la scène/
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
import db
|
||||
|
||||
from .ensure_scene_schema import ensure_scene_schema
|
||||
|
||||
|
||||
def set_scene_object_collision(slug, object_id, settings):
|
||||
def set_scene_object_collision(slug: str, object_id: int, settings: dict[str, Any]) -> None:
|
||||
"""Enregistre la boîte de collision (activée/désactivée, forme,
|
||||
taille, décalage — voir screens/rendering/collision_settings.py) d'un
|
||||
objet de scène QUELCONQUE (pas seulement "personnage" : un décor/fond
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
import db
|
||||
|
||||
from .ensure_scene_schema import ensure_scene_schema
|
||||
|
||||
|
||||
def set_scene_object_collision_rules(slug, object_id, rules):
|
||||
def set_scene_object_collision_rules(slug: str, object_id: int, rules: list[dict[str, Any]]) -> None:
|
||||
"""Enregistre la liste de règles "déclencheur -> action" d'un objet de
|
||||
scène (voir screens/rendering/collision_rules.py, "🧩 Collision" dans
|
||||
templates/scene_edit.html) — un attribut JSON distinct de tous les
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
import db
|
||||
|
||||
from .ensure_scene_schema import ensure_scene_schema
|
||||
|
||||
|
||||
def set_scene_object_commands(slug, object_id, commands):
|
||||
def set_scene_object_commands(slug: str, object_id: int, commands: dict[str, Any]) -> None:
|
||||
"""Enregistre les touches de déplacement/interaction et le blocage
|
||||
d'axe d'un objet de scène kind="personnage" (voir
|
||||
screens/rendering/personnage_commands.py pour les valeurs par défaut,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
import db
|
||||
|
||||
@@ -6,7 +7,7 @@ from ..rendering.dialogue_box_style import sanitize_dialogue_box_style
|
||||
from .ensure_scene_schema import ensure_scene_schema
|
||||
|
||||
|
||||
def set_scene_object_dialogue_box_style(slug, object_id, raw_style):
|
||||
def set_scene_object_dialogue_box_style(slug: str, object_id: int, raw_style: Any) -> dict[str, Any] | None:
|
||||
ensure_scene_schema(slug)
|
||||
conn = db.connect(slug)
|
||||
row = conn.execute("SELECT attributes FROM _scene_objects WHERE id = ?", (object_id,)).fetchone()
|
||||
|
||||
@@ -3,7 +3,7 @@ import db
|
||||
from .ensure_scene_schema import ensure_scene_schema
|
||||
|
||||
|
||||
def set_scene_object_name(slug, object_id, name):
|
||||
def set_scene_object_name(slug: str, object_id: int, name: str | None) -> None:
|
||||
"""Enregistre le nom d'un objet de scène (colonne `name`, voir
|
||||
ensure_scene_schema.py — déjà utilisée comme LIBELLÉ d'affichage
|
||||
partout ailleurs, mais jamais éditable avant le panneau "ℹ️
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
import db
|
||||
|
||||
from .ensure_scene_schema import ensure_scene_schema
|
||||
|
||||
|
||||
def set_scene_object_personnage_data(slug, object_id, data):
|
||||
def set_scene_object_personnage_data(slug: str, object_id: int, data: dict[str, Any]) -> None:
|
||||
"""Change le personnage Forge d'un objet de scène kind="personnage",
|
||||
ou met à jour ses animations — mirror exact de
|
||||
screens/elements/set_personnage_data.py, même clé _personnage_data
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
import db
|
||||
|
||||
@@ -6,7 +7,7 @@ from ..rendering.quiz_box_config import sanitize_quiz_box_config
|
||||
from .ensure_scene_schema import ensure_scene_schema
|
||||
|
||||
|
||||
def set_scene_object_quiz_config(slug, object_id, raw_config):
|
||||
def set_scene_object_quiz_config(slug: str, object_id: int, raw_config: Any) -> dict[str, Any] | None:
|
||||
ensure_scene_schema(slug)
|
||||
conn = db.connect(slug)
|
||||
row = conn.execute("SELECT attributes FROM _scene_objects WHERE id = ?", (object_id,)).fetchone()
|
||||
|
||||
@@ -5,7 +5,7 @@ import db
|
||||
from .ensure_scene_schema import ensure_scene_schema
|
||||
|
||||
|
||||
def set_scene_object_role(slug, object_id, role):
|
||||
def set_scene_object_role(slug: str, object_id: int, role: str) -> None:
|
||||
"""Enregistre le rôle (joueur/ennemie/pnj, voir
|
||||
screens/rendering/personnage_role.py) d'un objet de scène
|
||||
kind="personnage" — un attribut DISTINCT de _personnage_data (choix du
|
||||
|
||||
@@ -3,7 +3,7 @@ import db
|
||||
from .ensure_scene_schema import ensure_scene_schema
|
||||
|
||||
|
||||
def update_scene_object_geometry(slug, object_id, x, y, width, height):
|
||||
def update_scene_object_geometry(slug: str, object_id: int, x: float, y: float, width: float, height: float) -> None:
|
||||
"""Position/taille en PIXELS (pas des %, voir ensure_scene_schema.py)
|
||||
— utilisé par le glisser-déposer/redimensionnement de l'éditeur de
|
||||
scène, mirror exact de update_element_geometry.py (éditeur document) :
|
||||
|
||||
Reference in New Issue
Block a user