Relecture d'éditeur : règles sur la forme du graphe (ne jamais bloquer les joueurs)
Qualité & Sécurité / Web (ESLint · angular-eslint + sonarjs) (push) Successful in 42s
Qualité & Sécurité / MegaLinter (PMD · Ruff · Bandit · gitleaks · hadolint) (push) Successful in 1m8s
Qualité & Sécurité / Trivy (CVE dépendances Maven / pip / npm) (push) Failing after 1m4s
Qualité & Sécurité / Web (ESLint · angular-eslint + sonarjs) (push) Successful in 42s
Qualité & Sécurité / MegaLinter (PMD · Ruff · Bandit · gitleaks · hadolint) (push) Successful in 1m8s
Qualité & Sécurité / Trivy (CVE dépendances Maven / pip / npm) (push) Failing after 1m4s
- WRITE-003 : une révélation doit être atteinte par au moins 3 scènes (règle des 3 indices, seuil relevé de 2 à 3). - WRITE-011 Scène isolée : dans un chapitre qui utilise des liens, scène sans lien entrant ni sortant (hors ouverture ; une scène qui ne fait que partir vers d'autres reste valable, c'est une scène que le MJ déclenche). - WRITE-012 Passage obligé : tous les chemins de l'ouverture vers les fins du chapitre traversent une même scène (une remarque par chapitre). - WRITE-013 Donjon en couloir : 4 pièces ou plus reliées sans aucune boucle. - WRITE-014 Enquête sans relance : révélations mais aucune scène d'événement à déclencher quand les joueurs piétinent. - WRITE-015 Indices d'un seul genre : 3 chemins ou plus vers une révélation, tous depuis le même type de scène. - Textes fr/en des cinq règles, lien « Voir » vers la bonne section de l'éditeur de scène (liens, choix, pièces). Vérifié : core clean verify (1258 tests, cas positif et négatif par règle), web build + 367 vitest, lint sans erreur, relecture d'une vraie campagne de test (un seul passage obligé signalé, sur un chapitre en ligne droite). À redéployer : core + web (aucune migration).
This commit is contained in:
+175
-8
@@ -11,14 +11,21 @@ import com.loremind.domain.campaigncontext.readiness.ReadinessEntityType;
|
|||||||
import com.loremind.domain.campaigncontext.structure.Arc;
|
import com.loremind.domain.campaigncontext.structure.Arc;
|
||||||
import com.loremind.domain.campaigncontext.structure.ArcType;
|
import com.loremind.domain.campaigncontext.structure.ArcType;
|
||||||
import com.loremind.domain.campaigncontext.structure.Chapter;
|
import com.loremind.domain.campaigncontext.structure.Chapter;
|
||||||
|
import com.loremind.domain.campaigncontext.structure.Room;
|
||||||
|
import com.loremind.domain.campaigncontext.structure.RoomBranch;
|
||||||
import com.loremind.domain.campaigncontext.structure.Scene;
|
import com.loremind.domain.campaigncontext.structure.Scene;
|
||||||
import com.loremind.domain.campaigncontext.structure.SceneBranch;
|
import com.loremind.domain.campaigncontext.structure.SceneBranch;
|
||||||
import com.loremind.domain.campaigncontext.structure.SceneType;
|
import com.loremind.domain.campaigncontext.structure.SceneType;
|
||||||
import com.loremind.domain.campaigncontext.writingreview.WritingRemarkCategory;
|
import com.loremind.domain.campaigncontext.writingreview.WritingRemarkCategory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.Deque;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -44,8 +51,16 @@ public class WritingReviewService {
|
|||||||
|
|
||||||
/** WRITE-001 : à partir de combien de scènes un chapitre sans aucun choix devient un couloir. */
|
/** WRITE-001 : à partir de combien de scènes un chapitre sans aucun choix devient un couloir. */
|
||||||
static final int CORRIDOR_MIN_SCENES = 3;
|
static final int CORRIDOR_MIN_SCENES = 3;
|
||||||
/** WRITE-003 : nombre minimal de chemins menant à une révélation (en deçà : un seul chemin). */
|
/** WRITE-003 : nombre minimal de scènes menant à une révélation (règle des 3 indices). */
|
||||||
static final int REVELATION_MIN_INCOMING = 2;
|
static final int REVELATION_MIN_INCOMING = 3;
|
||||||
|
/** WRITE-011 / 012 / 014 : un chapitre « qui utilise le graphe » a au moins ce nombre de scènes reliées. */
|
||||||
|
static final int LINKED_MIN_SCENES = 2;
|
||||||
|
/** WRITE-012 : taille minimale d'un chapitre pour juger un passage obligé. */
|
||||||
|
static final int CHOKEPOINT_MIN_SCENES = 4;
|
||||||
|
/** WRITE-013 : nombre minimal de pièces pour juger la forme d'un donjon. */
|
||||||
|
static final int DUNGEON_MIN_ROOMS = 4;
|
||||||
|
/** WRITE-014 : taille minimale d'une enquête pour attendre une scène de relance. */
|
||||||
|
static final int PROACTIVE_MIN_SCENES = 3;
|
||||||
/** WRITE-004 : longueur d'une suite de scènes du même genre jugée monotone. */
|
/** WRITE-004 : longueur d'une suite de scènes du même genre jugée monotone. */
|
||||||
static final int MONOTONOUS_RUN = 3;
|
static final int MONOTONOUS_RUN = 3;
|
||||||
/** WRITE-006 : au-delà, la narration dépasse ~1 min de lecture à voix haute (~900 car./min). */
|
/** WRITE-006 : au-delà, la narration dépasse ~1 min de lecture à voix haute (~900 car./min). */
|
||||||
@@ -126,6 +141,7 @@ public class WritingReviewService {
|
|||||||
for (Scene scene : scenes) {
|
for (Scene scene : scenes) {
|
||||||
reviewScene(arc, chapter, scene, scenes, treeRemarks);
|
reviewScene(arc, chapter, scene, scenes, treeRemarks);
|
||||||
}
|
}
|
||||||
|
reviewGraph(arc, chapter, scenes, treeRemarks);
|
||||||
if (!scenes.isEmpty()) {
|
if (!scenes.isEmpty()) {
|
||||||
lastChapterScenes = scenes;
|
lastChapterScenes = scenes;
|
||||||
}
|
}
|
||||||
@@ -175,6 +191,14 @@ public class WritingReviewService {
|
|||||||
if (isBlank(chapter.getNarrativeStakes())) {
|
if (isBlank(chapter.getNarrativeStakes())) {
|
||||||
out.add(chapterRemark(arc, chapter, "WRITE-005-NO-STAKES", WritingRemarkCategory.STAKES, Map.of()));
|
out.add(chapterRemark(arc, chapter, "WRITE-005-NO-STAKES", WritingRemarkCategory.STAKES, Map.of()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WRITE-014 — enquête sans relance : des révélations, mais aucun événement que le MJ
|
||||||
|
// peut déclencher si les joueurs tournent en rond.
|
||||||
|
boolean investigation = scenes.stream().anyMatch(s -> typeOf(s) == SceneType.REVELATION);
|
||||||
|
boolean proactive = scenes.stream().anyMatch(s -> typeOf(s) == SceneType.EVENT);
|
||||||
|
if (investigation && !proactive && scenes.size() >= PROACTIVE_MIN_SCENES && usesLinks(scenes)) {
|
||||||
|
out.add(chapterRemark(arc, chapter, "WRITE-014-NO-PROACTIVE", WritingRemarkCategory.PACING, Map.of()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private record MonotonousRun(String kind, int length) {}
|
private record MonotonousRun(String kind, int length) {}
|
||||||
@@ -215,6 +239,142 @@ public class WritingReviewService {
|
|||||||
checkSingleClue(arc, chapter, scene, chapterScenes, out);
|
checkSingleClue(arc, chapter, scene, chapterScenes, out);
|
||||||
checkNarration(arc, chapter, scene, out);
|
checkNarration(arc, chapter, scene, out);
|
||||||
checkCombatPurpose(arc, chapter, scene, out);
|
checkCombatPurpose(arc, chapter, scene, out);
|
||||||
|
checkLinearDungeon(arc, chapter, scene, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WRITE-013 — donjon en couloir : des pièces reliées entre elles, mais sans aucune boucle
|
||||||
|
* (graphe des liens = arbre). Les joueurs ne choisissent pas leur route et ne peuvent ni
|
||||||
|
* contourner un obstacle ni revenir par un autre chemin. Muet si les pièces ne sont pas reliées.
|
||||||
|
*/
|
||||||
|
private void checkLinearDungeon(Arc arc, Chapter chapter, Scene scene, List<WritingRemark> out) {
|
||||||
|
List<Room> rooms = scene.getRooms();
|
||||||
|
if (rooms == null || rooms.size() < DUNGEON_MIN_ROOMS) return;
|
||||||
|
Set<String> ids = rooms.stream().map(Room::getId).filter(id -> !isBlank(id)).collect(Collectors.toSet());
|
||||||
|
// Arêtes non orientées distinctes (A→B et B→A = un seul passage).
|
||||||
|
Set<String> edges = new HashSet<>();
|
||||||
|
for (Room r : rooms) {
|
||||||
|
if (r.getBranches() == null) continue;
|
||||||
|
for (RoomBranch b : r.getBranches()) {
|
||||||
|
String to = b.targetRoomId();
|
||||||
|
if (isBlank(r.getId()) || !ids.contains(to) || r.getId().equals(to)) continue;
|
||||||
|
edges.add(r.getId().compareTo(to) < 0 ? r.getId() + "|" + to : to + "|" + r.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (edges.isEmpty()) return;
|
||||||
|
int components = countComponents(ids, edges);
|
||||||
|
int loops = edges.size() - ids.size() + components;
|
||||||
|
if (loops == 0 && components == 1) {
|
||||||
|
out.add(sceneRemark(arc, chapter, scene, "WRITE-013-LINEAR-DUNGEON", WritingRemarkCategory.AGENCY,
|
||||||
|
Map.of("rooms", String.valueOf(ids.size()))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int countComponents(Set<String> nodes, Set<String> edges) {
|
||||||
|
Map<String, Set<String>> adj = new HashMap<>();
|
||||||
|
for (String n : nodes) adj.put(n, new HashSet<>());
|
||||||
|
for (String e : edges) {
|
||||||
|
String[] ab = e.split("\\|", 2);
|
||||||
|
adj.get(ab[0]).add(ab[1]);
|
||||||
|
adj.get(ab[1]).add(ab[0]);
|
||||||
|
}
|
||||||
|
Set<String> seen = new HashSet<>();
|
||||||
|
int components = 0;
|
||||||
|
for (String start : nodes) {
|
||||||
|
if (!seen.add(start)) continue;
|
||||||
|
components++;
|
||||||
|
Deque<String> stack = new ArrayDeque<>(List.of(start));
|
||||||
|
while (!stack.isEmpty()) {
|
||||||
|
for (String next : adj.get(stack.pop())) {
|
||||||
|
if (seen.add(next)) stack.push(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return components;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Graphe du chapitre -------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Règles sur la forme du graphe des scènes d'un chapitre, seulement s'il utilise des liens
|
||||||
|
* (sans aucun lien, c'est WRITE-001 qui parle) : WRITE-011 scène isolée, WRITE-012 passage
|
||||||
|
* obligé. Les liens sont internes au chapitre (règle de SceneService).
|
||||||
|
*/
|
||||||
|
private void reviewGraph(Arc arc, Chapter chapter, List<Scene> scenes, List<WritingRemark> out) {
|
||||||
|
if (!usesLinks(scenes)) return;
|
||||||
|
Map<String, Set<String>> next = successors(scenes);
|
||||||
|
Set<String> withIncoming = next.values().stream().flatMap(Set::stream).collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// WRITE-011 — scène isolée : ni lien entrant ni lien sortant (hors scène d'ouverture).
|
||||||
|
for (int i = 1; i < scenes.size(); i++) {
|
||||||
|
Scene s = scenes.get(i);
|
||||||
|
if (next.get(s.getId()).isEmpty() && !withIncoming.contains(s.getId())) {
|
||||||
|
out.add(sceneRemark(arc, chapter, s, "WRITE-011-ISOLATED-SCENE", WritingRemarkCategory.PACING, Map.of()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkChokepoint(arc, chapter, scenes, next, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WRITE-012 — passage obligé : depuis la scène d'ouverture, tous les chemins vers les
|
||||||
|
* fins du chapitre traversent une même scène. Si les joueurs y échouent ou passent à côté,
|
||||||
|
* tout s'arrête. Une seule remarque par chapitre (le premier passage obligé).
|
||||||
|
*/
|
||||||
|
private void checkChokepoint(Arc arc, Chapter chapter, List<Scene> scenes, Map<String, Set<String>> next,
|
||||||
|
List<WritingRemark> out) {
|
||||||
|
if (scenes.size() < CHOKEPOINT_MIN_SCENES) return;
|
||||||
|
String entry = scenes.get(0).getId();
|
||||||
|
if (next.get(entry).isEmpty()) return;
|
||||||
|
Set<String> reachable = reach(entry, next, null);
|
||||||
|
Set<String> ends = reachable.stream().filter(id -> next.get(id).isEmpty()).collect(Collectors.toSet());
|
||||||
|
if (ends.isEmpty()) return; // Boucle sans fin : rien à juger.
|
||||||
|
|
||||||
|
List<Scene> chokepoints = new ArrayList<>();
|
||||||
|
for (Scene s : scenes) {
|
||||||
|
String id = s.getId();
|
||||||
|
if (id.equals(entry) || ends.contains(id) || !reachable.contains(id)) continue;
|
||||||
|
Set<String> without = reach(entry, next, id);
|
||||||
|
if (ends.stream().noneMatch(without::contains)) chokepoints.add(s);
|
||||||
|
}
|
||||||
|
if (chokepoints.isEmpty()) return;
|
||||||
|
out.add(sceneRemark(arc, chapter, chokepoints.get(0), "WRITE-012-CHOKEPOINT", WritingRemarkCategory.AGENCY,
|
||||||
|
Map.of("count", String.valueOf(chokepoints.size()))));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Successeurs de chaque scène du chapitre (liens vers des scènes du même chapitre seulement). */
|
||||||
|
private static Map<String, Set<String>> successors(List<Scene> scenes) {
|
||||||
|
Set<String> ids = scenes.stream().map(Scene::getId).collect(Collectors.toSet());
|
||||||
|
Map<String, Set<String>> next = new HashMap<>();
|
||||||
|
for (Scene s : scenes) {
|
||||||
|
Set<String> targets = new LinkedHashSet<>();
|
||||||
|
if (s.getBranches() != null) {
|
||||||
|
for (SceneBranch b : s.getBranches()) {
|
||||||
|
String to = b.targetSceneId();
|
||||||
|
if (ids.contains(to) && !to.equals(s.getId())) targets.add(to);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next.put(s.getId(), targets);
|
||||||
|
}
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Scènes atteignables depuis {@code from} en suivant les liens, sans passer par {@code removed}. */
|
||||||
|
private static Set<String> reach(String from, Map<String, Set<String>> next, String removed) {
|
||||||
|
Set<String> seen = new HashSet<>();
|
||||||
|
Deque<String> stack = new ArrayDeque<>(List.of(from));
|
||||||
|
seen.add(from);
|
||||||
|
while (!stack.isEmpty()) {
|
||||||
|
for (String n : next.getOrDefault(stack.pop(), Set.of())) {
|
||||||
|
if (!n.equals(removed) && seen.add(n)) stack.push(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return seen;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Le chapitre utilise le graphe : au moins {@link #LINKED_MIN_SCENES} scènes portent des liens. */
|
||||||
|
private static boolean usesLinks(List<Scene> scenes) {
|
||||||
|
return scenes.stream().filter(WritingReviewService::hasBranches).count() >= LINKED_MIN_SCENES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** WRITE-002 — faux carrefour : plusieurs sorties qui mènent toutes au même endroit. */
|
/** WRITE-002 — faux carrefour : plusieurs sorties qui mènent toutes au même endroit. */
|
||||||
@@ -241,14 +401,21 @@ public class WritingReviewService {
|
|||||||
List<WritingRemark> out) {
|
List<WritingRemark> out) {
|
||||||
if (typeOf(scene) != SceneType.REVELATION || isBlank(scene.getId())) return;
|
if (typeOf(scene) != SceneType.REVELATION || isBlank(scene.getId())) return;
|
||||||
if (chapterScenes.stream().noneMatch(WritingReviewService::hasBranches)) return;
|
if (chapterScenes.stream().noneMatch(WritingReviewService::hasBranches)) return;
|
||||||
long incoming = chapterScenes.stream()
|
List<Scene> sources = chapterScenes.stream()
|
||||||
.filter(s -> !scene.getId().equals(s.getId()) && s.getBranches() != null)
|
.filter(s -> !scene.getId().equals(s.getId()) && s.getBranches() != null)
|
||||||
.flatMap(s -> s.getBranches().stream().map(SceneBranch::targetSceneId).distinct())
|
.filter(s -> s.getBranches().stream().anyMatch(b -> scene.getId().equals(b.targetSceneId())))
|
||||||
.filter(scene.getId()::equals)
|
.toList();
|
||||||
.count();
|
if (sources.size() < REVELATION_MIN_INCOMING) {
|
||||||
if (incoming < REVELATION_MIN_INCOMING) {
|
|
||||||
out.add(sceneRemark(arc, chapter, scene, "WRITE-003-SINGLE-CLUE", WritingRemarkCategory.AGENCY,
|
out.add(sceneRemark(arc, chapter, scene, "WRITE-003-SINGLE-CLUE", WritingRemarkCategory.AGENCY,
|
||||||
Map.of("incoming", String.valueOf(incoming))));
|
Map.of("incoming", String.valueOf(sources.size()))));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// WRITE-015 — assez de chemins, mais tous du même genre (que des interrogatoires…) :
|
||||||
|
// un groupe qui n'aime pas ce genre de scène passe à côté de tous les indices.
|
||||||
|
Set<SceneType> kinds = sources.stream().map(WritingReviewService::typeOf).collect(Collectors.toSet());
|
||||||
|
if (kinds.size() == 1 && !kinds.contains(SceneType.GENERIC)) {
|
||||||
|
out.add(sceneRemark(arc, chapter, scene, "WRITE-015-SAME-SOURCE-CLUES", WritingRemarkCategory.AGENCY,
|
||||||
|
Map.of("kind", kinds.iterator().next().name(), "count", String.valueOf(sources.size()))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+141
-1
@@ -11,6 +11,8 @@ import com.loremind.domain.campaigncontext.readiness.ReadinessEntityType;
|
|||||||
import com.loremind.domain.campaigncontext.structure.Arc;
|
import com.loremind.domain.campaigncontext.structure.Arc;
|
||||||
import com.loremind.domain.campaigncontext.structure.ArcType;
|
import com.loremind.domain.campaigncontext.structure.ArcType;
|
||||||
import com.loremind.domain.campaigncontext.structure.Chapter;
|
import com.loremind.domain.campaigncontext.structure.Chapter;
|
||||||
|
import com.loremind.domain.campaigncontext.structure.Room;
|
||||||
|
import com.loremind.domain.campaigncontext.structure.RoomBranch;
|
||||||
import com.loremind.domain.campaigncontext.structure.Scene;
|
import com.loremind.domain.campaigncontext.structure.Scene;
|
||||||
import com.loremind.domain.campaigncontext.structure.SceneBranch;
|
import com.loremind.domain.campaigncontext.structure.SceneBranch;
|
||||||
import com.loremind.domain.campaigncontext.structure.SceneType;
|
import com.loremind.domain.campaigncontext.structure.SceneType;
|
||||||
@@ -153,12 +155,23 @@ class WritingReviewServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void singleClue_notRaised_withTwoPaths_orInChapterWithoutLinks() {
|
void singleClue_twoPathsAreStillBelowTheThreeClueRule() {
|
||||||
tree(List.of(
|
tree(List.of(
|
||||||
scene("s1", 0).branches(List.of(SceneBranch.of("A", "rev"))).build(),
|
scene("s1", 0).branches(List.of(SceneBranch.of("A", "rev"))).build(),
|
||||||
scene("s2", 1).type(SceneType.LOCATION).branches(List.of(SceneBranch.of("B", "rev"))).build(),
|
scene("s2", 1).type(SceneType.LOCATION).branches(List.of(SceneBranch.of("B", "rev"))).build(),
|
||||||
scene("rev", 2).type(SceneType.REVELATION).build()));
|
scene("rev", 2).type(SceneType.REVELATION).build()));
|
||||||
|
assertEquals("2", remark("WRITE-003-SINGLE-CLUE").params().get("incoming"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void singleClue_notRaised_withThreeVariedPaths() {
|
||||||
|
tree(List.of(
|
||||||
|
scene("s1", 0).branches(List.of(SceneBranch.of("A", "rev"))).build(),
|
||||||
|
scene("s2", 1).type(SceneType.LOCATION).branches(List.of(SceneBranch.of("B", "rev"))).build(),
|
||||||
|
scene("s3", 2).type(SceneType.EVENT).branches(List.of(SceneBranch.of("C", "rev"))).build(),
|
||||||
|
scene("rev", 3).type(SceneType.REVELATION).build()));
|
||||||
assertFalse(ruleIds().contains("WRITE-003-SINGLE-CLUE"));
|
assertFalse(ruleIds().contains("WRITE-003-SINGLE-CLUE"));
|
||||||
|
assertFalse(ruleIds().contains("WRITE-015-SAME-SOURCE-CLUES"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -319,4 +332,131 @@ class WritingReviewServiceTest {
|
|||||||
tree(List.of(scene("s1", 0).type(SceneType.GENERIC).build()));
|
tree(List.of(scene("s1", 0).type(SceneType.GENERIC).build()));
|
||||||
assertFalse(ruleIds().contains("WRITE-010-UNTYPED-SCENES"));
|
assertFalse(ruleIds().contains("WRITE-010-UNTYPED-SCENES"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- WRITE-011 : scène isolée ---
|
||||||
|
|
||||||
|
private static SceneBranch to(String target) {
|
||||||
|
return SceneBranch.of("vers " + target, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void isolatedScene_noLinkInNorOut_inALinkedChapter() {
|
||||||
|
tree(List.of(
|
||||||
|
scene("s1", 0).branches(List.of(to("s2"))).build(),
|
||||||
|
scene("s2", 1).type(SceneType.LOCATION).branches(List.of(to("s3"))).build(),
|
||||||
|
scene("s3", 2).build(),
|
||||||
|
scene("lost", 3).type(SceneType.LOCATION).build()));
|
||||||
|
|
||||||
|
WritingRemark r = remark("WRITE-011-ISOLATED-SCENE");
|
||||||
|
assertEquals("lost", r.entityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void isolatedScene_notRaised_forAnOpeningOrAProactiveScene_orWithoutLinks() {
|
||||||
|
// « event » n'a pas de lien entrant mais en a un sortant : scène que le MJ déclenche.
|
||||||
|
tree(List.of(
|
||||||
|
scene("s1", 0).branches(List.of(to("s2"))).build(),
|
||||||
|
scene("s2", 1).type(SceneType.LOCATION).build(),
|
||||||
|
scene("event", 2).type(SceneType.EVENT).branches(List.of(to("s2"))).build()));
|
||||||
|
assertFalse(ruleIds().contains("WRITE-011-ISOLATED-SCENE"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void isolatedScene_notRaised_whenTheChapterDoesNotUseLinks() {
|
||||||
|
tree(List.of(scene("s1", 0).branches(List.of(to("s2"))).build(),
|
||||||
|
scene("s2", 1).type(SceneType.LOCATION).build(),
|
||||||
|
scene("s3", 2).build()));
|
||||||
|
assertFalse(ruleIds().contains("WRITE-011-ISOLATED-SCENE"), "une seule scène reliée : pas un graphe");
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- WRITE-012 : passage obligé ---
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void chokepoint_everyPathGoesThroughOneScene() {
|
||||||
|
// s1 → (a | b) → gate → (end1 | end2)
|
||||||
|
tree(List.of(
|
||||||
|
scene("s1", 0).branches(List.of(to("a"), to("b"))).build(),
|
||||||
|
scene("a", 1).type(SceneType.LOCATION).branches(List.of(to("gate"))).build(),
|
||||||
|
scene("b", 2).branches(List.of(to("gate"))).build(),
|
||||||
|
scene("gate", 3).type(SceneType.LOCATION).branches(List.of(to("end1"), to("end2"))).build(),
|
||||||
|
scene("end1", 4).build(),
|
||||||
|
scene("end2", 5).type(SceneType.EVENT).build()));
|
||||||
|
|
||||||
|
WritingRemark r = remark("WRITE-012-CHOKEPOINT");
|
||||||
|
assertEquals("gate", r.entityId());
|
||||||
|
assertEquals("1", r.params().get("count"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void chokepoint_notRaised_whenAnotherRouteExists() {
|
||||||
|
// s1 → a → end ; s1 → b → end : deux routes indépendantes.
|
||||||
|
tree(List.of(
|
||||||
|
scene("s1", 0).branches(List.of(to("a"), to("b"))).build(),
|
||||||
|
scene("a", 1).type(SceneType.LOCATION).branches(List.of(to("end"))).build(),
|
||||||
|
scene("b", 2).branches(List.of(to("end"))).build(),
|
||||||
|
scene("end", 3).type(SceneType.EVENT).build()));
|
||||||
|
assertFalse(ruleIds().contains("WRITE-012-CHOKEPOINT"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- WRITE-013 : donjon en couloir ---
|
||||||
|
|
||||||
|
private static Room room(String id, String... targets) {
|
||||||
|
List<RoomBranch> branches = new ArrayList<>();
|
||||||
|
for (String t : targets) branches.add(RoomBranch.of("porte", t));
|
||||||
|
return Room.builder().id(id).name(id).order(0).branches(branches).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void linearDungeon_roomsLinkedWithoutAnyLoop() {
|
||||||
|
tree(List.of(scene("crypt", 0).type(SceneType.LOCATION).rooms(List.of(
|
||||||
|
room("r1", "r2"), room("r2", "r1", "r3"), room("r3", "r4"), room("r4"))).build()));
|
||||||
|
|
||||||
|
WritingRemark r = remark("WRITE-013-LINEAR-DUNGEON");
|
||||||
|
assertEquals("4", r.params().get("rooms"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void linearDungeon_notRaised_withALoop_orUnlinkedRooms() {
|
||||||
|
tree(List.of(
|
||||||
|
scene("loop", 0).type(SceneType.LOCATION).rooms(List.of(
|
||||||
|
room("r1", "r2"), room("r2", "r3"), room("r3", "r4"), room("r4", "r1"))).build(),
|
||||||
|
scene("plain", 1).rooms(List.of(room("x1"), room("x2"), room("x3"), room("x4"))).build()));
|
||||||
|
assertFalse(ruleIds().contains("WRITE-013-LINEAR-DUNGEON"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- WRITE-014 : enquête sans relance ---
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void noProactive_investigationWithoutAnyEvent() {
|
||||||
|
tree(List.of(
|
||||||
|
scene("s1", 0).branches(List.of(to("s2"), to("rev"))).build(),
|
||||||
|
scene("s2", 1).type(SceneType.LOCATION).branches(List.of(to("rev"))).build(),
|
||||||
|
scene("rev", 2).type(SceneType.REVELATION).build()));
|
||||||
|
assertEquals(ReadinessEntityType.CHAPTER, remark("WRITE-014-NO-PROACTIVE").entityType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void noProactive_notRaised_withAnEventScene() {
|
||||||
|
tree(List.of(
|
||||||
|
scene("s1", 0).branches(List.of(to("s2"), to("rev"))).build(),
|
||||||
|
scene("s2", 1).type(SceneType.EVENT).branches(List.of(to("rev"))).build(),
|
||||||
|
scene("rev", 2).type(SceneType.REVELATION).build()));
|
||||||
|
assertFalse(ruleIds().contains("WRITE-014-NO-PROACTIVE"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- WRITE-015 : indices tous du même genre ---
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void sameSourceClues_threePathsAllFromNpcScenes() {
|
||||||
|
tree(List.of(
|
||||||
|
scene("n1", 0).branches(List.of(to("rev"))).build(),
|
||||||
|
scene("n2", 1).branches(List.of(to("rev"))).build(),
|
||||||
|
scene("n3", 2).branches(List.of(to("rev"))).build(),
|
||||||
|
scene("rev", 3).type(SceneType.REVELATION).build()));
|
||||||
|
|
||||||
|
WritingRemark r = remark("WRITE-015-SAME-SOURCE-CLUES");
|
||||||
|
assertEquals("NPC", r.params().get("kind"));
|
||||||
|
assertEquals("3", r.params().get("count"));
|
||||||
|
assertFalse(ruleIds().contains("WRITE-003-SINGLE-CLUE"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,5 +34,9 @@ const FOCUS_BY_RULE: Record<string, string> = {
|
|||||||
'WRITE-006-LONG-NARRATION': 'narration',
|
'WRITE-006-LONG-NARRATION': 'narration',
|
||||||
'WRITE-007-NARRATION-DECIDES': 'narration',
|
'WRITE-007-NARRATION-DECIDES': 'narration',
|
||||||
'WRITE-008-COMBAT-NO-PURPOSE': 'combat',
|
'WRITE-008-COMBAT-NO-PURPOSE': 'combat',
|
||||||
'WRITE-009-SINGLE-ENDING': 'choices'
|
'WRITE-009-SINGLE-ENDING': 'choices',
|
||||||
|
'WRITE-011-ISOLATED-SCENE': 'branches',
|
||||||
|
'WRITE-012-CHOKEPOINT': 'choices',
|
||||||
|
'WRITE-013-LINEAR-DUNGEON': 'rooms',
|
||||||
|
'WRITE-015-SAME-SOURCE-CLUES': 'branches'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ describe('writing review content', () => {
|
|||||||
const rules = emittedRules();
|
const rules = emittedRules();
|
||||||
|
|
||||||
it('finds the rules emitted by the core', () => {
|
it('finds the rules emitted by the core', () => {
|
||||||
expect(rules).toHaveLength(10);
|
expect(rules).toHaveLength(15);
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const lang of ['fr', 'en'] as const) {
|
for (const lang of ['fr', 'en'] as const) {
|
||||||
|
|||||||
@@ -2208,6 +2208,31 @@
|
|||||||
"observation": "{{percent}}% of the campaign's scenes have no type ({{count}} scenes).",
|
"observation": "{{percent}}% of the campaign's scenes have no type ({{count}} scenes).",
|
||||||
"why": "Without types, you can't see the adventure's pacing at a glance, and the review can't help you with it.",
|
"why": "Without types, you can't see the adventure's pacing at a glance, and the review can't help you with it.",
|
||||||
"question": "For each scene: will the players mostly explore, fight, talk, go through an event or discover something?"
|
"question": "For each scene: will the players mostly explore, fight, talk, go through an event or discover something?"
|
||||||
|
},
|
||||||
|
"WRITE-011-ISOLATED-SCENE": {
|
||||||
|
"observation": "\"{{entity}}\" isn't linked to any other scene: no link leads to it and none leaves it.",
|
||||||
|
"why": "In a chapter built with links, an isolated scene is likely never to be played: nothing brings the players there.",
|
||||||
|
"question": "From which scene could the players arrive here, and where does this scene lead them next?"
|
||||||
|
},
|
||||||
|
"WRITE-012-CHOKEPOINT": {
|
||||||
|
"observation": "\"{{entity}}\" is a chokepoint: every path through the chapter goes through it ({{count}} scene(s) like this).",
|
||||||
|
"why": "If the players fail here, miss the clue or head elsewhere, the story stops. A chokepoint is only a problem if it can be missed.",
|
||||||
|
"question": "What happens if the players fail or bypass this scene? Could another path lead to what comes next?"
|
||||||
|
},
|
||||||
|
"WRITE-013-LINEAR-DUNGEON": {
|
||||||
|
"observation": "The {{rooms}} rooms of \"{{entity}}\" follow one another without any loop.",
|
||||||
|
"why": "A place without loops plays like a corridor: a single path, no shortcut, no way to get around an obstacle or escape another way.",
|
||||||
|
"question": "Could two distant rooms be connected (secret passage, duct, hidden stairs) to open a second route?"
|
||||||
|
},
|
||||||
|
"WRITE-014-NO-PROACTIVE": {
|
||||||
|
"observation": "\"{{entity}}\" contains revelations but no event scene.",
|
||||||
|
"why": "When an investigation stalls, the GM needs a scene they can trigger themselves: the enemy strikes back, a witness comes forward, the threat moves on. It restarts play and brings new leads.",
|
||||||
|
"question": "What does the enemy do if the players go round in circles? Which scene could come to them with a new clue?"
|
||||||
|
},
|
||||||
|
"WRITE-015-SAME-SOURCE-CLUES": {
|
||||||
|
"observation": "The {{count}} paths leading to \"{{entity}}\" all start from \"{{kind}}\" scenes.",
|
||||||
|
"why": "If all the information goes through one kind of scene (only interrogations, only searches), a table that dislikes it or fails at it will miss every clue at once.",
|
||||||
|
"question": "Could a clue come from another kind of scene: a place to search, a document, an event?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2208,6 +2208,31 @@
|
|||||||
"observation": "{{percent}} % des scènes de la campagne n'ont pas de type ({{count}} scènes).",
|
"observation": "{{percent}} % des scènes de la campagne n'ont pas de type ({{count}} scènes).",
|
||||||
"why": "Sans type, impossible de voir d'un coup d'œil le rythme de l'aventure, et la relecture ne peut pas t'aider sur ce point.",
|
"why": "Sans type, impossible de voir d'un coup d'œil le rythme de l'aventure, et la relecture ne peut pas t'aider sur ce point.",
|
||||||
"question": "Pour chaque scène : les joueurs vont-ils surtout explorer, combattre, parler, subir un événement ou découvrir quelque chose ?"
|
"question": "Pour chaque scène : les joueurs vont-ils surtout explorer, combattre, parler, subir un événement ou découvrir quelque chose ?"
|
||||||
|
},
|
||||||
|
"WRITE-011-ISOLATED-SCENE": {
|
||||||
|
"observation": "« {{entity}} » n'est reliée à aucune autre scène : aucun lien n'y mène et aucun n'en part.",
|
||||||
|
"why": "Dans un chapitre construit avec des liens, une scène isolée a de bonnes chances de n'être jamais jouée : rien n'y conduit les joueurs.",
|
||||||
|
"question": "Depuis quelle scène les joueurs pourraient-ils arriver ici, et où cette scène les mène-t-elle ensuite ?"
|
||||||
|
},
|
||||||
|
"WRITE-012-CHOKEPOINT": {
|
||||||
|
"observation": "« {{entity}} » est un passage obligé : tous les chemins du chapitre passent par elle ({{count}} scène(s) dans ce cas).",
|
||||||
|
"why": "Si les joueurs échouent ici, ratent l'indice ou prennent une autre direction, l'histoire s'arrête. Un passage obligé ne pose problème que s'il peut être raté.",
|
||||||
|
"question": "Que se passe-t-il si les joueurs échouent ou contournent cette scène ? Un autre chemin pourrait-il mener à la suite ?"
|
||||||
|
},
|
||||||
|
"WRITE-013-LINEAR-DUNGEON": {
|
||||||
|
"observation": "Les {{rooms}} pièces de « {{entity}} » s'enchaînent sans aucune boucle.",
|
||||||
|
"why": "Un lieu sans boucle se visite comme un couloir : un seul chemin, aucun raccourci, aucune façon de contourner un obstacle ou de fuir par ailleurs.",
|
||||||
|
"question": "Pourrait-on relier deux pièces éloignées (passage secret, conduit, escalier dérobé) pour ouvrir un second chemin ?"
|
||||||
|
},
|
||||||
|
"WRITE-014-NO-PROACTIVE": {
|
||||||
|
"observation": "« {{entity}} » contient des révélations mais aucune scène d'événement.",
|
||||||
|
"why": "Quand une enquête piétine, le MJ a besoin d'une scène à déclencher lui-même : l'adversaire riposte, un témoin se manifeste, la menace progresse. Elle relance la partie et apporte de nouvelles pistes.",
|
||||||
|
"question": "Que fait l'adversaire si les joueurs tournent en rond ? Quelle scène pourrait leur arriver dessus avec un nouvel indice ?"
|
||||||
|
},
|
||||||
|
"WRITE-015-SAME-SOURCE-CLUES": {
|
||||||
|
"observation": "Les {{count}} chemins qui mènent à « {{entity}} » partent tous de scènes « {{kind}} ».",
|
||||||
|
"why": "Si toute l'information passe par le même genre de scène (que des interrogatoires, que des fouilles), une table qui n'aime pas ce genre ou y échoue manquera tous les indices à la fois.",
|
||||||
|
"question": "Un indice pourrait-il venir d'un autre genre de scène : un lieu à fouiller, un document, un événement ?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -64,6 +64,31 @@
|
|||||||
"observation": "{{percent}}% of the campaign's scenes have no type ({{count}} scenes).",
|
"observation": "{{percent}}% of the campaign's scenes have no type ({{count}} scenes).",
|
||||||
"why": "Without types, you can't see the adventure's pacing at a glance, and the review can't help you with it.",
|
"why": "Without types, you can't see the adventure's pacing at a glance, and the review can't help you with it.",
|
||||||
"question": "For each scene: will the players mostly explore, fight, talk, go through an event or discover something?"
|
"question": "For each scene: will the players mostly explore, fight, talk, go through an event or discover something?"
|
||||||
|
},
|
||||||
|
"WRITE-011-ISOLATED-SCENE": {
|
||||||
|
"observation": "\"{{entity}}\" isn't linked to any other scene: no link leads to it and none leaves it.",
|
||||||
|
"why": "In a chapter built with links, an isolated scene is likely never to be played: nothing brings the players there.",
|
||||||
|
"question": "From which scene could the players arrive here, and where does this scene lead them next?"
|
||||||
|
},
|
||||||
|
"WRITE-012-CHOKEPOINT": {
|
||||||
|
"observation": "\"{{entity}}\" is a chokepoint: every path through the chapter goes through it ({{count}} scene(s) like this).",
|
||||||
|
"why": "If the players fail here, miss the clue or head elsewhere, the story stops. A chokepoint is only a problem if it can be missed.",
|
||||||
|
"question": "What happens if the players fail or bypass this scene? Could another path lead to what comes next?"
|
||||||
|
},
|
||||||
|
"WRITE-013-LINEAR-DUNGEON": {
|
||||||
|
"observation": "The {{rooms}} rooms of \"{{entity}}\" follow one another without any loop.",
|
||||||
|
"why": "A place without loops plays like a corridor: a single path, no shortcut, no way to get around an obstacle or escape another way.",
|
||||||
|
"question": "Could two distant rooms be connected (secret passage, duct, hidden stairs) to open a second route?"
|
||||||
|
},
|
||||||
|
"WRITE-014-NO-PROACTIVE": {
|
||||||
|
"observation": "\"{{entity}}\" contains revelations but no event scene.",
|
||||||
|
"why": "When an investigation stalls, the GM needs a scene they can trigger themselves: the enemy strikes back, a witness comes forward, the threat moves on. It restarts play and brings new leads.",
|
||||||
|
"question": "What does the enemy do if the players go round in circles? Which scene could come to them with a new clue?"
|
||||||
|
},
|
||||||
|
"WRITE-015-SAME-SOURCE-CLUES": {
|
||||||
|
"observation": "The {{count}} paths leading to \"{{entity}}\" all start from \"{{kind}}\" scenes.",
|
||||||
|
"why": "If all the information goes through one kind of scene (only interrogations, only searches), a table that dislikes it or fails at it will miss every clue at once.",
|
||||||
|
"question": "Could a clue come from another kind of scene: a place to search, a document, an event?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,31 @@
|
|||||||
"observation": "{{percent}} % des scènes de la campagne n'ont pas de type ({{count}} scènes).",
|
"observation": "{{percent}} % des scènes de la campagne n'ont pas de type ({{count}} scènes).",
|
||||||
"why": "Sans type, impossible de voir d'un coup d'œil le rythme de l'aventure, et la relecture ne peut pas t'aider sur ce point.",
|
"why": "Sans type, impossible de voir d'un coup d'œil le rythme de l'aventure, et la relecture ne peut pas t'aider sur ce point.",
|
||||||
"question": "Pour chaque scène : les joueurs vont-ils surtout explorer, combattre, parler, subir un événement ou découvrir quelque chose ?"
|
"question": "Pour chaque scène : les joueurs vont-ils surtout explorer, combattre, parler, subir un événement ou découvrir quelque chose ?"
|
||||||
|
},
|
||||||
|
"WRITE-011-ISOLATED-SCENE": {
|
||||||
|
"observation": "« {{entity}} » n'est reliée à aucune autre scène : aucun lien n'y mène et aucun n'en part.",
|
||||||
|
"why": "Dans un chapitre construit avec des liens, une scène isolée a de bonnes chances de n'être jamais jouée : rien n'y conduit les joueurs.",
|
||||||
|
"question": "Depuis quelle scène les joueurs pourraient-ils arriver ici, et où cette scène les mène-t-elle ensuite ?"
|
||||||
|
},
|
||||||
|
"WRITE-012-CHOKEPOINT": {
|
||||||
|
"observation": "« {{entity}} » est un passage obligé : tous les chemins du chapitre passent par elle ({{count}} scène(s) dans ce cas).",
|
||||||
|
"why": "Si les joueurs échouent ici, ratent l'indice ou prennent une autre direction, l'histoire s'arrête. Un passage obligé ne pose problème que s'il peut être raté.",
|
||||||
|
"question": "Que se passe-t-il si les joueurs échouent ou contournent cette scène ? Un autre chemin pourrait-il mener à la suite ?"
|
||||||
|
},
|
||||||
|
"WRITE-013-LINEAR-DUNGEON": {
|
||||||
|
"observation": "Les {{rooms}} pièces de « {{entity}} » s'enchaînent sans aucune boucle.",
|
||||||
|
"why": "Un lieu sans boucle se visite comme un couloir : un seul chemin, aucun raccourci, aucune façon de contourner un obstacle ou de fuir par ailleurs.",
|
||||||
|
"question": "Pourrait-on relier deux pièces éloignées (passage secret, conduit, escalier dérobé) pour ouvrir un second chemin ?"
|
||||||
|
},
|
||||||
|
"WRITE-014-NO-PROACTIVE": {
|
||||||
|
"observation": "« {{entity}} » contient des révélations mais aucune scène d'événement.",
|
||||||
|
"why": "Quand une enquête piétine, le MJ a besoin d'une scène à déclencher lui-même : l'adversaire riposte, un témoin se manifeste, la menace progresse. Elle relance la partie et apporte de nouvelles pistes.",
|
||||||
|
"question": "Que fait l'adversaire si les joueurs tournent en rond ? Quelle scène pourrait leur arriver dessus avec un nouvel indice ?"
|
||||||
|
},
|
||||||
|
"WRITE-015-SAME-SOURCE-CLUES": {
|
||||||
|
"observation": "Les {{count}} chemins qui mènent à « {{entity}} » partent tous de scènes « {{kind}} ».",
|
||||||
|
"why": "Si toute l'information passe par le même genre de scène (que des interrogatoires, que des fouilles), une table qui n'aime pas ce genre ou y échoue manquera tous les indices à la fois.",
|
||||||
|
"question": "Un indice pourrait-il venir d'un autre genre de scène : un lieu à fouiller, un document, un événement ?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user