Phase 1 (3/3) : bascule "par joueur" dans le tableau de bord
Build and deploy / test (push) Failing after 8s
Build and deploy / build-and-push (push) Skipped
Build and deploy / deploy (push) Skipped

Dernier morceau du plan d'état par joueur : le créateur choisit, à la
création d'une variable globale ou d'un objet, si chaque joueur aura sa
propre valeur/ses propres lignes (coché par défaut) ou si elle est
explicitement PARTAGÉE par tous les joueurs (ex. un compteur de visiteurs
global, un catalogue commun) — voir db/global_vars/create_global_variable.py
et db/definitions/create_definition.py (Phase 1, 1er commit).

routes/global_vars/create_global_var.py, routes/objects/object_new.py :
lisent la case à cocher "per_player" du formulaire (absente => reste
per_player=1, comportement par défaut). templates/game_dashboard.html :
case à cocher sur les deux panneaux de création + colonne "Par joueur"
dans les deux tableaux existants, pour que ce réglage (immuable après
création, comme le nom d'une variable) reste visible.

db/definitions/list_definitions.py appelait _definitions directement
sans jamais migrer son schéma — un tableau de bord ouvert avant la toute
première création/modification d'objet aurait affiché "Non — partagé"
pour un objet en réalité per_player=1 (colonne absente => Undefined,
donc faux en Jinja) : corrigé en appelant ensure_field_bounds_schema()
ici aussi, comme le fait déjà create_definition.py/get_definition.py.

Vérifié : 239 tests passent (2 nouveaux, dont un qui aurait détecté le
bug ci-dessus). Phase 1 (état par joueur) est maintenant complète :
couche db/, route publique /jouer/<slug>, et ce réglage créateur.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
william
2026-08-30 15:54:37 +02:00
co-authored by Claude Sonnet 5
parent 3c39f1a249
commit 4585a72588
5 changed files with 60 additions and 4 deletions
+23 -2
View File
@@ -76,12 +76,13 @@
{% if definitions %}
<div class="fieldsTableWrap">
<table class="table is-fullwidth is-hoverable fieldsTable">
<thead><tr><th>Nom</th><th>Table SQL</th><th></th></tr></thead>
<thead><tr><th>Nom</th><th>Table SQL</th><th>Par joueur</th><th></th></tr></thead>
<tbody>
{% for d in definitions %}
<tr>
<td><button type="button" class="linkLikeButton" onclick="openObjectEditPanel({{ d.id }})">{{ d.name }}</button></td>
<td class="has-text-grey">{{ d.table_name }}</td>
<td><span class="hint">{{ 'Oui' if d.per_player else 'Non — partagé' }}</span></td>
<td class="fieldsTableActions">
<button type="button" class="button is-small" onclick="openObjectEditPanel({{ d.id }})" title="Modifier cet objet">✏️</button>
</td>
@@ -158,6 +159,15 @@
</select>
<input type="text" id="newVarValue" name="default_value" placeholder="Valeur de départ">
<button type="button" id="newVarConfigureBtn" class="button is-small" style="display:none;" onclick="openVarValuePanel('newVarValue', document.getElementById('newVarType').value)">🔧 Configurer la valeur</button>
<!-- État par joueur (Phase 1) : réglé une seule fois, à la création
(voir db/global_vars/create_global_variable.py) — coché par
défaut (chaque joueur a sa propre valeur), décoché pour une
variable explicitement PARTAGÉE par tous les joueurs (ex. un
compteur de visiteurs global). -->
<label class="checkbox" style="display:flex; align-items:center; gap:6px; font-size:12px; white-space:nowrap;" title="Décoché : une seule valeur, partagée par tous les joueurs.">
<input type="checkbox" name="per_player" value="1" checked style="width:auto;">
Par joueur
</label>
<button type="submit" class="primary">Créer</button>
</form>
{% if variables %}
@@ -166,7 +176,7 @@
{% endfor %}
<div class="fieldsTableWrap">
<table class="table is-fullwidth is-hoverable fieldsTable">
<thead><tr><th>Nom</th><th>Type</th><th>Valeur</th><th></th></tr></thead>
<thead><tr><th>Nom</th><th>Type</th><th>Valeur</th><th>Par joueur</th><th></th></tr></thead>
<tbody>
{% for v in variables %}
<tr>
@@ -188,6 +198,7 @@
<input type="text" form="varEditForm{{ v.id }}" name="value" value="{{ v.value or '' }}" aria-label="Valeur de « {{ v.name }} »">
{% endif %}
</td>
<td><span class="hint">{{ 'Oui' if v.per_player else 'Non — partagée' }}</span></td>
<td class="fieldsTableActions">
<button type="submit" form="varEditForm{{ v.id }}" class="button is-small">Enregistrer</button>
<form method="post" action="{{ url_for('global_var_delete', slug=game.slug, var_id=v.id) }}"
@@ -295,6 +306,16 @@
<input type="text" id="object_name" name="object_name" required autocomplete="off">
</div>
<!-- État par joueur (Phase 1) : réglé une seule fois, à la création
(voir db/definitions/create_definition.py) — coché par défaut
(chaque joueur a ses propres lignes, ex. un inventaire),
décoché pour un objet explicitement PARTAGÉ par tous les
joueurs (ex. un catalogue, une liste de questions). -->
<label class="checkbox" style="display:flex; align-items:center; gap:6px; margin-top:10px;" title="Décoché : les lignes de cet objet sont partagées par tous les joueurs.">
<input type="checkbox" name="per_player" value="1" checked style="width:auto;">
Chaque joueur a ses propres lignes ("par joueur")
</label>
<div class="dashPanelHeader" style="margin-top:14px;">
<h2>Champs</h2>
<button type="button" class="button is-small" id="btnAddField">+ Ajouter un champ</button>