Files
Forge-Engine/db/quests/sanitize_quest_dialogues.py
T
williamandClaude Sonnet 5 521792fe00
Build and deploy / test-python (push) Successful in 7m32s
Build and deploy / test-js (push) Successful in 1m2s
Build and deploy / build-and-push (push) Skipped
Build and deploy / deploy (push) Skipped
Dialogues de quête : bulles illimitées, n'importe quel objet, timeline reliée
- "qui parle" n'est plus réservé au personnage : N'IMPORTE QUEL objet de
  scène nommé (personnage, décor, fond — voir "ℹ️ Informations",
  screens/rendering/scene_object_names.py, ex-personnage_names.py) peut
  parler dans un dialogue.
- Confirmé/documenté : aucune limite au nombre de répliques par colonne
  (bouton "+ Réplique" reste toujours disponible).
- Bulle = header (menu déroulant du "qui parle") + body (le texte),
  centrée dans sa colonne à 70% de largeur, alignée verticalement et
  reliée à la suivante par un trait — remplace l'ancien alignement
  gauche/droite façon chat.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-03 11:54:06 +02:00

38 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from .constants import QUEST_STATUS_CHOICES
_MAX_LINES_PER_COLUMN = 200
_MAX_SPEAKER_LENGTH = 60
def sanitize_quest_dialogues(raw_dialogues):
"""Une réplique = {speaker: '<nom du personnage>', text: '...'} — le
nom vient du champ "ℹ️ Informations" d'un objet de scène kind=
"personnage" (voir screens/rendering/scene_object_names.py), ou
"Joueur" (toujours proposé, voir static/js/quests/quest-editor.js) :
texte libre côté serveur (jamais un enum fixe — n'importe quel nom
donné à un personnage doit être accepté), juste borné en longueur.
Une colonne par statut de quête (voir QUEST_STATUS_CHOICES), même
esprit que resolve_collision_rules.sanitize_collision_rules : rejette
tout élément invalide plutôt que de lever, ne garde jamais un texte
ou un nom vide."""
result = {status: [] for status in QUEST_STATUS_CHOICES}
if not isinstance(raw_dialogues, dict):
return result
for status in QUEST_STATUS_CHOICES:
raw_lines = raw_dialogues.get(status)
if not isinstance(raw_lines, list):
continue
cleaned = []
for raw_line in raw_lines[:_MAX_LINES_PER_COLUMN]:
if not isinstance(raw_line, dict):
continue
speaker = raw_line.get("speaker")
text = raw_line.get("text")
if not isinstance(speaker, str) or not speaker.strip():
continue
if not isinstance(text, str) or not text.strip():
continue
cleaned.append({"speaker": speaker.strip()[:_MAX_SPEAKER_LENGTH], "text": text.strip()})
result[status] = cleaned
return result