Mentor d'écriture : champs d'histoire pour scènes, arcs et PNJ
- Scène : « Utilité » (ce que l'histoire perd si on la coupe) et « Tactique et moral des adversaires » (comment ils se battent, quand ils fuient ou se rendent), dans l'éditeur, la vue et le PDF (réservés au MJ). - Arc : « Histoire cachée » (la vérité que les joueurs reconstituent) et « Accroches » (une par ligne), nouvelle section de l'éditeur ; dans le PDF, histoire cachée en encadré secret et accroches, version MJ uniquement. - PNJ : bloc « Rôle dans l'histoire », indépendant du système de jeu : rôle (opposant, allié, ressource, figurant), motivation, ce qu'il sait, signe distinctif. Dans le PDF, le signe distinctif se voit aussi en version joueurs ; rôle, motivation et savoir restent réservés au MJ. - Huit fiches du coach pour ces champs, rédigées pour LoreMind. - Relecture d'éditeur : WRITE-016 (opposant ou allié sans motivation, lien vers la fiche du PNJ), WRITE-017 (arc avec une seule accroche) ; un combat dont la tactique est écrite n'est plus signalé « sans but » (WRITE-008). - Migration V27 (colonnes scènes/arcs, fiche PNJ en JSON) ; champs conservés à l'export/import de campagne. Vérifié : core clean verify (1277 tests, dont règles, rendu MJ/joueurs, aller-retour export/import), web build + 844 vitest, lint sans erreur, migration V27 appliquée sur une base existante et fiche PNJ enregistrée puis signalée par la relecture dans le navigateur. À redéployer : core + web (migration V27).
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.loremind.application.campaigncontext;
|
||||
|
||||
import com.loremind.domain.campaigncontext.bestiary.Npc;
|
||||
import com.loremind.domain.campaigncontext.bestiary.NpcStory;
|
||||
import com.loremind.domain.shared.ReorderSupport;
|
||||
import com.loremind.domain.campaigncontext.ports.NpcRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -29,8 +30,17 @@ public class NpcService {
|
||||
String campaignId,
|
||||
List<String> relatedPageIds,
|
||||
String folder,
|
||||
Integer order
|
||||
) {}
|
||||
Integer order,
|
||||
/** Rôle dans l'histoire ; null = inchangé (mise à jour) / non renseigné (création). */
|
||||
NpcStory story
|
||||
) {
|
||||
public NpcData(String name, String portraitImageId, String headerImageId, Map<String, String> values,
|
||||
Map<String, List<String>> imageValues, Map<String, Map<String, String>> keyValueValues,
|
||||
String campaignId, List<String> relatedPageIds, String folder, Integer order) {
|
||||
this(name, portraitImageId, headerImageId, values, imageValues, keyValueValues, campaignId,
|
||||
relatedPageIds, folder, order, null);
|
||||
}
|
||||
}
|
||||
|
||||
public Npc createNpc(NpcData data) {
|
||||
int order = data.order() != null
|
||||
@@ -47,6 +57,7 @@ public class NpcService {
|
||||
.relatedPageIds(data.relatedPageIds() != null ? new ArrayList<>(data.relatedPageIds()) : new ArrayList<>())
|
||||
.folder(normalizeFolder(data.folder()))
|
||||
.order(order)
|
||||
.story(cleanStory(data.story()))
|
||||
.build();
|
||||
return npcRepository.save(npc);
|
||||
}
|
||||
@@ -70,12 +81,22 @@ public class NpcService {
|
||||
existing.setKeyValueValues(data.keyValueValues() != null ? new HashMap<>(data.keyValueValues()) : new HashMap<>());
|
||||
existing.setRelatedPageIds(data.relatedPageIds() != null ? new ArrayList<>(data.relatedPageIds()) : new ArrayList<>());
|
||||
existing.setFolder(normalizeFolder(data.folder()));
|
||||
if (data.story() != null) {
|
||||
existing.setStory(cleanStory(data.story()));
|
||||
}
|
||||
if (data.order() != null) {
|
||||
existing.setOrder(data.order());
|
||||
}
|
||||
return npcRepository.save(existing);
|
||||
}
|
||||
|
||||
/** Fiche nettoyée, ou null si elle est vide (rien à stocker). */
|
||||
private static NpcStory cleanStory(NpcStory story) {
|
||||
if (story == null) return null;
|
||||
NpcStory clean = story.normalized();
|
||||
return clean.hasContent() ? clean : null;
|
||||
}
|
||||
|
||||
public void deleteNpc(String id) {
|
||||
npcRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@@ -125,6 +125,8 @@ public class SceneService {
|
||||
case "playerNarration" -> scene.setPlayerNarration(value);
|
||||
case "choicesConsequences" -> scene.setChoicesConsequences(value);
|
||||
case "combatDifficulty" -> scene.setCombatDifficulty(value);
|
||||
case "tactics" -> scene.setTactics(value);
|
||||
case "purpose" -> scene.setPurpose(value);
|
||||
case "enemies" -> scene.setEnemies(value);
|
||||
case "gmSecretNotes" -> scene.setGmSecretNotes(value);
|
||||
default -> { /* clé inconnue → ignorée (garde-fou anti-écrasement) */ }
|
||||
|
||||
+41
-2
@@ -4,6 +4,9 @@ import com.loremind.domain.campaigncontext.Campaign;
|
||||
import com.loremind.domain.campaigncontext.ports.ArcRepository;
|
||||
import com.loremind.domain.campaigncontext.ports.CampaignRepository;
|
||||
import com.loremind.domain.campaigncontext.ports.ChapterRepository;
|
||||
import com.loremind.domain.campaigncontext.bestiary.Npc;
|
||||
import com.loremind.domain.campaigncontext.bestiary.NpcStory;
|
||||
import com.loremind.domain.campaigncontext.ports.NpcRepository;
|
||||
import com.loremind.domain.campaigncontext.ports.QuestRepository;
|
||||
import com.loremind.domain.campaigncontext.ports.SceneRepository;
|
||||
import com.loremind.domain.campaigncontext.quest.Quest;
|
||||
@@ -91,17 +94,20 @@ public class WritingReviewService {
|
||||
private final ChapterRepository chapterRepository;
|
||||
private final SceneRepository sceneRepository;
|
||||
private final QuestRepository questRepository;
|
||||
private final NpcRepository npcRepository;
|
||||
|
||||
public WritingReviewService(CampaignRepository campaignRepository,
|
||||
ArcRepository arcRepository,
|
||||
ChapterRepository chapterRepository,
|
||||
SceneRepository sceneRepository,
|
||||
QuestRepository questRepository) {
|
||||
QuestRepository questRepository,
|
||||
NpcRepository npcRepository) {
|
||||
this.campaignRepository = campaignRepository;
|
||||
this.arcRepository = arcRepository;
|
||||
this.chapterRepository = chapterRepository;
|
||||
this.sceneRepository = sceneRepository;
|
||||
this.questRepository = questRepository;
|
||||
this.npcRepository = npcRepository;
|
||||
}
|
||||
|
||||
/** Relit toute la campagne et renvoie les remarques dans l'ordre de l'arbre. */
|
||||
@@ -122,6 +128,11 @@ public class WritingReviewService {
|
||||
chapters.sort(Comparator.comparingInt(Chapter::getOrder));
|
||||
boolean visibleArc = arc.getType() != ArcType.SYSTEM;
|
||||
|
||||
// WRITE-017 — une seule accroche : les personnages n'ont qu'une raison de s'en mêler.
|
||||
if (visibleArc && countLines(arc.getHooks()) == 1) {
|
||||
treeRemarks.add(arcRemark(arc, "WRITE-017-SINGLE-HOOK", WritingRemarkCategory.AGENCY, Map.of()));
|
||||
}
|
||||
|
||||
// WRITE-005 (arc) : seulement sur un arc qui a déjà du contenu.
|
||||
if (visibleArc && isBlank(arc.getStakes())
|
||||
&& (!chapters.isEmpty() || arcsWithQuests.contains(arc.getId()))) {
|
||||
@@ -164,6 +175,7 @@ public class WritingReviewService {
|
||||
|
||||
List<WritingRemark> remarks = new ArrayList<>(campaignRemarks);
|
||||
remarks.addAll(treeRemarks);
|
||||
remarks.addAll(reviewNpcs(campaignId));
|
||||
return new WritingReviewReport(campaignId, remarks);
|
||||
}
|
||||
|
||||
@@ -437,7 +449,8 @@ public class WritingReviewService {
|
||||
|
||||
/** WRITE-008 — combat sans but : ni choix décrits, ni notes sur les motivations des ennemis. */
|
||||
private void checkCombatPurpose(Arc arc, Chapter chapter, Scene scene, List<WritingRemark> out) {
|
||||
if (isCombat(scene) && isBlank(scene.getChoicesConsequences()) && isBlank(scene.getGmSecretNotes())) {
|
||||
if (isCombat(scene) && isBlank(scene.getChoicesConsequences()) && isBlank(scene.getGmSecretNotes())
|
||||
&& isBlank(scene.getTactics())) {
|
||||
out.add(sceneRemark(arc, chapter, scene, "WRITE-008-COMBAT-NO-PURPOSE", WritingRemarkCategory.STAKES,
|
||||
Map.of()));
|
||||
}
|
||||
@@ -455,8 +468,34 @@ public class WritingReviewService {
|
||||
}
|
||||
}
|
||||
|
||||
// --- PNJ ----------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* WRITE-016 — opposant ou allié sans motivation : un PNJ qui pèse sur l'intrigue doit
|
||||
* vouloir quelque chose, sinon le MJ ne sait pas comment le faire réagir. Les figurants
|
||||
* et les PNJ sans rôle précisé ne sont pas jugés (pas de bruit sur les seconds rôles).
|
||||
*/
|
||||
private List<WritingRemark> reviewNpcs(String campaignId) {
|
||||
List<WritingRemark> out = new ArrayList<>();
|
||||
for (Npc npc : npcRepository.findByCampaignId(campaignId)) {
|
||||
NpcStory story = npc.getStory();
|
||||
if (story != null && story.drivesThePlot() && story.normalized().motivation() == null) {
|
||||
out.add(new WritingRemark(ReadinessEntityType.NPC, npc.getId(), labelOr(npc.getName(), "PNJ"),
|
||||
"WRITE-016-NPC-NO-MOTIVATION", WritingRemarkCategory.STAKES,
|
||||
Map.of("role", story.normalized().role()), null, null));
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// --- Helpers ----------------------------------------------------------------------------
|
||||
|
||||
/** Nombre de lignes non vides (une accroche par ligne, puces « - » comprises). */
|
||||
private static int countLines(String text) {
|
||||
if (isBlank(text)) return 0;
|
||||
return (int) text.lines().filter(l -> !l.isBlank()).count();
|
||||
}
|
||||
|
||||
private static boolean isCombat(Scene scene) {
|
||||
return typeOf(scene) == SceneType.ENCOUNTER
|
||||
|| !isBlank(scene.getCombatDifficulty())
|
||||
|
||||
@@ -60,6 +60,9 @@ public class Npc {
|
||||
/** Ordre d'affichage dans la liste des PNJ de la campagne. */
|
||||
private int order;
|
||||
|
||||
/** Rôle dans l'histoire (rôle, motivation, ce qu'il sait, signe distinctif). Null = non renseigné. */
|
||||
private NpcStory story;
|
||||
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.loremind.domain.campaigncontext.bestiary;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Fiche « rôle dans l'histoire » d'un PNJ, indépendante du système de jeu (le gabarit du
|
||||
* système porte les caractéristiques) : ce qui rend le PNJ jouable et utile au récit.
|
||||
*
|
||||
* @param role place dans l'histoire : {@code OPPONENT} (s'oppose aux PJ), {@code ALLY}
|
||||
* (les aide), {@code RESOURCE} (détient une information ou un service),
|
||||
* {@code EXTRA} (figurant) ; null = non précisé
|
||||
* @param motivation ce qu'il veut, et ce qu'il est prêt à faire pour l'obtenir
|
||||
* @param knowledge ce qu'il sait (et peut révéler) — réservé au MJ
|
||||
* @param mannerism signe distinctif à jouer (geste, phrasé, tic)
|
||||
*/
|
||||
public record NpcStory(String role, String motivation, String knowledge, String mannerism) {
|
||||
|
||||
public static final Set<String> ROLES = Set.of("OPPONENT", "ALLY", "RESOURCE", "EXTRA");
|
||||
private static final int SHORT_MAX = 300;
|
||||
private static final int LONG_MAX = 10_000;
|
||||
|
||||
/** Copie nettoyée : rôle inconnu → null, textes rognés (blancs → null) et bornés. */
|
||||
public NpcStory normalized() {
|
||||
String r = role == null ? null : role.trim().toUpperCase(Locale.ROOT);
|
||||
// Set.of(...).contains(null) lève une NullPointerException : rôle absent testé à part.
|
||||
return new NpcStory(r != null && ROLES.contains(r) ? r : null,
|
||||
clean(motivation, LONG_MAX), clean(knowledge, LONG_MAX), clean(mannerism, SHORT_MAX));
|
||||
}
|
||||
|
||||
/** Vrai si au moins un élément est renseigné. */
|
||||
public boolean hasContent() {
|
||||
NpcStory n = normalized();
|
||||
return n.role() != null || n.motivation() != null || n.knowledge() != null || n.mannerism() != null;
|
||||
}
|
||||
|
||||
/** Un PNJ qui pèse sur l'intrigue (opposant ou allié) : sa motivation est attendue. */
|
||||
public boolean drivesThePlot() {
|
||||
String r = normalized().role();
|
||||
return "OPPONENT".equals(r) || "ALLY".equals(r);
|
||||
}
|
||||
|
||||
private static String clean(String s, int max) {
|
||||
if (s == null) return null;
|
||||
String t = s.trim();
|
||||
if (t.isEmpty()) return null;
|
||||
return t.length() > max ? t.substring(0, max) : t;
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,8 @@ public class Arc {
|
||||
private String gmNotes; // Notes privées du MJ (non exportées vers FoundryVTT)
|
||||
private String rewards; // Récompenses et progression
|
||||
private String resolution; // Dénouement prévu
|
||||
private String hiddenTruth; // Histoire cachée : ce qui s'est vraiment passé (réservé au MJ)
|
||||
private String hooks; // Accroches : pourquoi les personnages s'en mêlent (une par ligne)
|
||||
|
||||
/**
|
||||
* IDs des pages du Lore associées à cet arc (weak cross-context references).
|
||||
|
||||
@@ -48,6 +48,8 @@ public class Scene {
|
||||
|
||||
// === Combat ou rencontre ===
|
||||
private String combatDifficulty; // Difficulté estimée
|
||||
private String tactics; // Tactique et moral des adversaires (quand fuient-ils, se rendent-ils ?)
|
||||
private String purpose; // Utilité : ce que l'histoire perd si on coupe la scène
|
||||
private String enemies; // Liste des ennemis et créatures (texte libre)
|
||||
|
||||
/**
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.loremind.infrastructure.persistence.converter;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.loremind.domain.campaigncontext.bestiary.NpcStory;
|
||||
import jakarta.persistence.AttributeConverter;
|
||||
import jakarta.persistence.Converter;
|
||||
|
||||
/**
|
||||
* Convertit la fiche {@link NpcStory} (rôle dans l'histoire d'un PNJ) en JSON stocké dans une colonne TEXT,
|
||||
* et inversement. Fiche vide → NULL en base. Champs inconnus ignorés (fiche écrite par
|
||||
* une version plus récente).
|
||||
*/
|
||||
@Converter
|
||||
public class NpcStoryJsonConverter implements AttributeConverter<NpcStory, String> {
|
||||
|
||||
private static final ObjectMapper MAPPER = new ObjectMapper()
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
|
||||
@Override
|
||||
public String convertToDatabaseColumn(NpcStory attribute) {
|
||||
if (attribute == null || !attribute.hasContent()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return MAPPER.writeValueAsString(attribute);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Erreur sérialisation NpcStory → JSON", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NpcStory convertToEntityAttribute(String dbData) {
|
||||
if (dbData == null || dbData.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return MAPPER.readValue(dbData, NpcStory.class);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Erreur désérialisation JSON → NpcStory", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,12 @@ public class ArcJpaEntity {
|
||||
@Column(columnDefinition = "TEXT")
|
||||
private String resolution;
|
||||
|
||||
@Column(name = "hidden_truth", columnDefinition = "TEXT")
|
||||
private String hiddenTruth;
|
||||
|
||||
@Column(name = "hooks", columnDefinition = "TEXT")
|
||||
private String hooks;
|
||||
|
||||
/**
|
||||
* IDs des pages du Lore liées à cet arc, stockés en JSON dans une colonne TEXT.
|
||||
* Pas de FK cross-context : respect des Bounded Contexts.
|
||||
|
||||
@@ -67,6 +67,11 @@ public class NpcJpaEntity {
|
||||
@Column(name = "\"order\"", nullable = false)
|
||||
private int order;
|
||||
|
||||
/** Fiche « rôle dans l'histoire » (JSON). NULL = non renseignée. */
|
||||
@Column(name = "story", columnDefinition = "TEXT")
|
||||
@Convert(converter = com.loremind.infrastructure.persistence.converter.NpcStoryJsonConverter.class)
|
||||
private com.loremind.domain.campaigncontext.bestiary.NpcStory story;
|
||||
|
||||
@Column(name = "created_at", nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
|
||||
@@ -78,6 +78,14 @@ public class SceneJpaEntity {
|
||||
@Column(name = "choices_consequences", columnDefinition = "TEXT")
|
||||
private String choicesConsequences;
|
||||
|
||||
// Tactique et moral des adversaires
|
||||
@Column(name = "tactics", columnDefinition = "TEXT")
|
||||
private String tactics;
|
||||
|
||||
// Utilité de la scène dans l'histoire
|
||||
@Column(name = "purpose", columnDefinition = "TEXT")
|
||||
private String purpose;
|
||||
|
||||
// Combat
|
||||
@Column(name = "combat_difficulty", columnDefinition = "TEXT")
|
||||
private String combatDifficulty;
|
||||
|
||||
+4
@@ -77,6 +77,8 @@ public class PostgresArcRepository implements ArcRepository {
|
||||
.gmNotes(jpaEntity.getGmNotes())
|
||||
.rewards(jpaEntity.getRewards())
|
||||
.resolution(jpaEntity.getResolution())
|
||||
.hiddenTruth(jpaEntity.getHiddenTruth())
|
||||
.hooks(jpaEntity.getHooks())
|
||||
// Defensive copy : jamais de null en domaine pour simplifier les appelants.
|
||||
.relatedPageIds(jpaEntity.getRelatedPageIds() != null
|
||||
? new ArrayList<>(jpaEntity.getRelatedPageIds())
|
||||
@@ -104,6 +106,8 @@ public class PostgresArcRepository implements ArcRepository {
|
||||
.gmNotes(arc.getGmNotes())
|
||||
.rewards(arc.getRewards())
|
||||
.resolution(arc.getResolution())
|
||||
.hiddenTruth(arc.getHiddenTruth())
|
||||
.hooks(arc.getHooks())
|
||||
.relatedPageIds(arc.getRelatedPageIds() != null
|
||||
? new ArrayList<>(arc.getRelatedPageIds())
|
||||
: new ArrayList<>())
|
||||
|
||||
+2
@@ -68,6 +68,7 @@ public class PostgresNpcRepository implements NpcRepository {
|
||||
.campaignId(e.getCampaignId().toString())
|
||||
.relatedPageIds(e.getRelatedPageIds() != null ? new ArrayList<>(e.getRelatedPageIds()) : new ArrayList<>())
|
||||
.folder(e.getFolder())
|
||||
.story(e.getStory())
|
||||
.order(e.getOrder())
|
||||
.createdAt(e.getCreatedAt())
|
||||
.updatedAt(e.getUpdatedAt())
|
||||
@@ -87,6 +88,7 @@ public class PostgresNpcRepository implements NpcRepository {
|
||||
.campaignId(Long.parseLong(n.getCampaignId()))
|
||||
.relatedPageIds(n.getRelatedPageIds() != null ? new ArrayList<>(n.getRelatedPageIds()) : new ArrayList<>())
|
||||
.folder(n.getFolder())
|
||||
.story(n.getStory())
|
||||
.order(n.getOrder())
|
||||
.createdAt(n.getCreatedAt())
|
||||
.updatedAt(n.getUpdatedAt())
|
||||
|
||||
+4
@@ -80,6 +80,8 @@ public class PostgresSceneRepository implements SceneRepository {
|
||||
.gmSecretNotes(jpaEntity.getGmSecretNotes())
|
||||
.choicesConsequences(jpaEntity.getChoicesConsequences())
|
||||
.combatDifficulty(jpaEntity.getCombatDifficulty())
|
||||
.tactics(jpaEntity.getTactics())
|
||||
.purpose(jpaEntity.getPurpose())
|
||||
.enemies(jpaEntity.getEnemies())
|
||||
.enemyIds(jpaEntity.getEnemyIds() != null
|
||||
? new ArrayList<>(jpaEntity.getEnemyIds())
|
||||
@@ -123,6 +125,8 @@ public class PostgresSceneRepository implements SceneRepository {
|
||||
.gmSecretNotes(scene.getGmSecretNotes())
|
||||
.choicesConsequences(scene.getChoicesConsequences())
|
||||
.combatDifficulty(scene.getCombatDifficulty())
|
||||
.tactics(scene.getTactics())
|
||||
.purpose(scene.getPurpose())
|
||||
.enemies(scene.getEnemies())
|
||||
.enemyIds(scene.getEnemyIds() != null
|
||||
? new ArrayList<>(scene.getEnemyIds())
|
||||
|
||||
@@ -129,6 +129,8 @@ class CampaignContentInserter {
|
||||
e.setGmNotes(d.gmNotes());
|
||||
e.setRewards(d.rewards());
|
||||
e.setResolution(d.resolution());
|
||||
e.setHiddenTruth(d.hiddenTruth());
|
||||
e.setHooks(d.hooks());
|
||||
e.setRelatedPageIds(d.relatedPageIds()); // remappe en 2e passe
|
||||
e.setIllustrationImageIds(IdRemapper.remapStringList(maps.imageMap, d.illustrationImageIds()));
|
||||
maps.arcMap.put(d.id(), arcRepo.save(e).getId());
|
||||
@@ -267,6 +269,7 @@ class CampaignContentInserter {
|
||||
e.setRelatedPageIds(d.relatedPageIds()); // remappe en 2e passe
|
||||
e.setFolder(d.folder());
|
||||
e.setOrder(d.order());
|
||||
e.setStory(d.story());
|
||||
maps.npcMap.put(d.id(), npcRepo.save(e).getId());
|
||||
}
|
||||
result.count("npcs", maps.npcMap.size());
|
||||
@@ -317,6 +320,8 @@ class CampaignContentInserter {
|
||||
e.setBattlemaps(resolveBattlemaps(d, maps));
|
||||
e.setGraphX(d.graphX());
|
||||
e.setGraphY(d.graphY());
|
||||
e.setTactics(d.tactics());
|
||||
e.setPurpose(d.purpose());
|
||||
e.setBranches(d.branches()); // remappe en 2e passe
|
||||
// Rooms : l'id (UUID) et les branches restent tels quels ; seules leurs refs
|
||||
// d'images (galerie + plan) sont remappees vers les images importees.
|
||||
|
||||
@@ -614,7 +614,7 @@ public class ExportService {
|
||||
e.getType() != null ? e.getType().name() : null,
|
||||
e.getIcon(), e.getThemes(), e.getStakes(), e.getGmNotes(),
|
||||
e.getRewards(), e.getResolution(), e.getRelatedPageIds(),
|
||||
e.getIllustrationImageIds());
|
||||
e.getIllustrationImageIds(), e.getHiddenTruth(), e.getHooks());
|
||||
}
|
||||
|
||||
private ContentExport.ChapterDto toChapterDto(ChapterJpaEntity e) {
|
||||
@@ -643,7 +643,7 @@ public class ExportService {
|
||||
e.getEnemies(), e.getEnemyIds(), e.getRelatedPageIds(),
|
||||
e.getIllustrationImageIds(), null, null, // legacy battlemap : plus émis
|
||||
e.getBattlemaps(), e.getBranches(), e.getRooms(), e.getType(),
|
||||
e.getGraphX(), e.getGraphY());
|
||||
e.getGraphX(), e.getGraphY(), e.getTactics(), e.getPurpose());
|
||||
}
|
||||
|
||||
private ContentExport.CharacterDto toCharacterDto(CharacterJpaEntity e) {
|
||||
@@ -655,7 +655,7 @@ public class ExportService {
|
||||
private ContentExport.NpcDto toNpcDto(NpcJpaEntity e) {
|
||||
return new ContentExport.NpcDto(e.getId(), e.getName(), e.getPortraitImageId(),
|
||||
e.getHeaderImageId(), e.getValues(), e.getImageValues(), e.getKeyValueValues(),
|
||||
e.getCampaignId(), e.getRelatedPageIds(), e.getFolder(), e.getOrder());
|
||||
e.getCampaignId(), e.getRelatedPageIds(), e.getFolder(), e.getOrder(), e.getStory());
|
||||
}
|
||||
|
||||
private ContentExport.EnemyDto toEnemyDto(EnemyJpaEntity e) {
|
||||
|
||||
@@ -147,7 +147,10 @@ public record ContentExport(
|
||||
String rewards,
|
||||
String resolution,
|
||||
List<String> relatedPageIds,
|
||||
List<String> illustrationImageIds
|
||||
List<String> illustrationImageIds,
|
||||
/** Histoire cachée et accroches ; absentes des bundles antérieurs (null). */
|
||||
String hiddenTruth,
|
||||
String hooks
|
||||
) {}
|
||||
|
||||
public record ChapterDto(
|
||||
@@ -197,7 +200,10 @@ public record ContentExport(
|
||||
List<Room> rooms,
|
||||
SceneType type,
|
||||
Double graphX,
|
||||
Double graphY
|
||||
Double graphY,
|
||||
/** Tactique des adversaires et utilité ; absentes des bundles antérieurs (null). */
|
||||
String tactics,
|
||||
String purpose
|
||||
) {}
|
||||
|
||||
public record CharacterDto(
|
||||
@@ -224,7 +230,9 @@ public record ContentExport(
|
||||
Long campaignId,
|
||||
List<String> relatedPageIds,
|
||||
String folder,
|
||||
int order
|
||||
int order,
|
||||
/** Rôle dans l'histoire ; absent des bundles antérieurs (null). */
|
||||
com.loremind.domain.campaigncontext.bestiary.NpcStory story
|
||||
) {}
|
||||
|
||||
public record EnemyDto(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.loremind.infrastructure.transfer.pdf;
|
||||
|
||||
import com.loremind.domain.campaigncontext.CampaignPublication;
|
||||
import com.loremind.domain.campaigncontext.bestiary.NpcStory;
|
||||
import com.loremind.domain.campaigncontext.quest.NodeType;
|
||||
import com.loremind.domain.campaigncontext.quest.Prerequisite;
|
||||
import com.loremind.domain.campaigncontext.quest.QuestNodeRef;
|
||||
@@ -538,6 +539,8 @@ public class PdfExportService {
|
||||
private void arcFields(Ctx ctx, ArcJpaEntity arc) {
|
||||
illustrations(ctx, arc.getIllustrationImageIds());
|
||||
ctx.gmBlock(LABEL_DESCRIPTION, arc.getDescription());
|
||||
ctx.gmBox(CSS_SECRET, "Histoire cachée", arc.getHiddenTruth());
|
||||
ctx.gmBlock("Accroches", arc.getHooks());
|
||||
ctx.gmBlock(LABEL_THEMES, arc.getThemes());
|
||||
ctx.gmBlock(LABEL_ENJEUX, arc.getStakes());
|
||||
ctx.gmBlock(LABEL_RECOMPENSES, arc.getRewards());
|
||||
@@ -628,6 +631,7 @@ public class PdfExportService {
|
||||
.append(esc(sc.getName())).append(DIV_CLOSE);
|
||||
sceneMeta(b, sc);
|
||||
ctx.gmBlock("Résumé", sc.getDescription());
|
||||
ctx.gmBlock("Utilité", sc.getPurpose());
|
||||
block(b, "Ambiance", sc.getAtmosphere(), "ambiance");
|
||||
box(b, "readaloud", "À lire aux joueurs", sc.getPlayerNarration());
|
||||
ctx.gmBox(CSS_SECRET, "Notes secrètes MJ", sc.getGmSecretNotes());
|
||||
@@ -635,7 +639,7 @@ public class PdfExportService {
|
||||
if (ctx.gm) blockHtml(b, "Sorties", sceneBranchItems(sc.getBranches(), st));
|
||||
// Combat : difficulte + ennemis de la rencontre (fiches du bestiaire en renvoi
|
||||
// « p. N » + texte libre) dans le meme encadre rouge.
|
||||
combatBox(ctx, "Combat", sc.getCombatDifficulty(), sc.getEnemyIds(), sc.getEnemies(), st);
|
||||
combatBox(ctx, "Combat", sc.getCombatDifficulty(), sc.getEnemyIds(), sc.getEnemies(), sc.getTactics(), st);
|
||||
illustrations(ctx, sc.getIllustrationImageIds());
|
||||
if (ctx.maps != null) {
|
||||
mapLinks(ctx, sc);
|
||||
@@ -706,7 +710,7 @@ public class PdfExportService {
|
||||
if (r.getFloor() != null) b.append(" · Étage ").append(r.getFloor());
|
||||
b.append(SPAN_CLOSE).append(esc(r.getName())).append(DIV_CLOSE);
|
||||
ctx.gmBlock(LABEL_DESCRIPTION, r.getDescription());
|
||||
combatBox(ctx, "Ennemis", null, r.getEnemyIds(), r.getEnemies(), st);
|
||||
combatBox(ctx, "Ennemis", null, r.getEnemyIds(), r.getEnemies(), null, st);
|
||||
ctx.gmBlock("Butin", r.getLoot());
|
||||
ctx.gmBlock("Pièges", r.getTraps());
|
||||
ctx.gmBox(CSS_SECRET, LABEL_NOTES_MJ, r.getGmNotes());
|
||||
@@ -776,7 +780,7 @@ public class PdfExportService {
|
||||
* leur fiche (« Bandit (p. 24) »), puis texte libre. Rien si tout est vide.
|
||||
*/
|
||||
private static void combatBox(Ctx ctx, String label, String difficulty, List<String> enemyIds,
|
||||
String freeText, Structure st) {
|
||||
String freeText, String tactics, Structure st) {
|
||||
if (!ctx.gm) return;
|
||||
List<String> enemies = new ArrayList<>();
|
||||
if (enemyIds != null) {
|
||||
@@ -785,7 +789,7 @@ public class PdfExportService {
|
||||
if (name != null) enemies.add(xref("enemy-" + id, name) + " " + pageRef("enemy-" + id));
|
||||
}
|
||||
}
|
||||
if (!notBlank(difficulty) && enemies.isEmpty() && !notBlank(freeText)) return;
|
||||
if (!notBlank(difficulty) && enemies.isEmpty() && !notBlank(freeText) && !notBlank(tactics)) return;
|
||||
StringBuilder b = ctx.body;
|
||||
b.append("<div class=\"box combat\"><div class=\"box-label\">").append(esc(label)).append(DIV_CLOSE);
|
||||
prose(b, difficulty);
|
||||
@@ -795,6 +799,7 @@ public class PdfExportService {
|
||||
b.append("</ul>");
|
||||
}
|
||||
prose(b, freeText);
|
||||
block(b, "Tactique et moral", tactics);
|
||||
b.append(DIV_CLOSE);
|
||||
}
|
||||
|
||||
@@ -907,13 +912,14 @@ public class PdfExportService {
|
||||
/** Une fiche persona generique pour la mise en page (PNJ ou ennemi). */
|
||||
record PersonaRow(Long id, int order, String name, String folder, String level, String portraitId,
|
||||
Map<String, String> values, Map<String, Map<String, String>> keyValueValues,
|
||||
Map<String, List<String>> imageValues, Map<String, String> foundryStats) {}
|
||||
Map<String, List<String>> imageValues, Map<String, String> foundryStats,
|
||||
NpcStory story) {}
|
||||
|
||||
private List<PersonaRow> npcEntries(CampaignJpaEntity c) {
|
||||
List<PersonaRow> out = new ArrayList<>();
|
||||
for (NpcJpaEntity n : npcRepo.findByCampaignIdOrderByOrderAsc(c.getId())) {
|
||||
out.add(new PersonaRow(n.getId(), n.getOrder(), n.getName(), n.getFolder(), null, n.getPortraitImageId(),
|
||||
n.getValues(), n.getKeyValueValues(), n.getImageValues(), null));
|
||||
n.getValues(), n.getKeyValueValues(), n.getImageValues(), null, n.getStory()));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -922,7 +928,7 @@ public class PdfExportService {
|
||||
List<PersonaRow> out = new ArrayList<>();
|
||||
for (EnemyJpaEntity e : enemyRepo.findByCampaignIdOrderByOrderAsc(c.getId())) {
|
||||
out.add(new PersonaRow(e.getId(), e.getOrder(), e.getName(), e.getFolder(), e.getLevel(), e.getPortraitImageId(),
|
||||
e.getValues(), e.getKeyValueValues(), e.getImageValues(), e.getFoundryStats()));
|
||||
e.getValues(), e.getKeyValueValues(), e.getImageValues(), e.getFoundryStats(), null));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -1003,7 +1009,14 @@ public class PdfExportService {
|
||||
b.append("<td class=\"persona-content\">");
|
||||
b.append("<div class=\"persona-name\">").append(esc(r.name()));
|
||||
if (notBlank(r.level())) b.append(" <span class=\"level\">Niv. ").append(esc(r.level())).append(SPAN_CLOSE);
|
||||
String role = r.story() != null ? ROLE_LABELS.get(r.story().role()) : null;
|
||||
if (ctx.gm && role != null) b.append(" <span class=\"level\">").append(role).append(SPAN_CLOSE);
|
||||
b.append(DIV_CLOSE);
|
||||
if (r.story() != null) {
|
||||
block(b, "Signe distinctif", r.story().mannerism());
|
||||
ctx.gmBlock("Motivation", r.story().motivation());
|
||||
ctx.gmBlock("Ce qu'il sait", r.story().knowledge());
|
||||
}
|
||||
|
||||
renderFields(ctx, template, r.values(), r.keyValueValues(), r.imageValues(), null);
|
||||
|
||||
@@ -1023,6 +1036,10 @@ public class PdfExportService {
|
||||
b.append("</td></tr></table></div>");
|
||||
}
|
||||
|
||||
/** Libelles des roles d'un PNJ dans l'histoire (fiche « role dans l'histoire »). */
|
||||
private static final Map<String, String> ROLE_LABELS = Map.of(
|
||||
"OPPONENT", "Opposant", "ALLY", "Allié", "RESOURCE", "Ressource", "EXTRA", "Figurant");
|
||||
|
||||
/** Valeurs de stats considerees comme "vides"/bruit (masquees dans le livret). */
|
||||
private static final Set<String> STAT_NOISE_VALUES = Set.of("0", "0.0", "false", "none", "null", "", "-", "—");
|
||||
/** Premier segment de chemin a elaguer du libelle (purement structurel). */
|
||||
|
||||
@@ -83,7 +83,8 @@ public class NpcController {
|
||||
dto.getCampaignId(),
|
||||
dto.getRelatedPageIds(),
|
||||
dto.getFolder(),
|
||||
order
|
||||
order,
|
||||
dto.getStory()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ public class ArcDTO {
|
||||
private String gmNotes;
|
||||
private String rewards;
|
||||
private String resolution;
|
||||
private String hiddenTruth;
|
||||
private String hooks;
|
||||
|
||||
/** IDs des pages du Lore liées à cet arc (weak cross-context references). */
|
||||
private List<String> relatedPageIds = new ArrayList<>();
|
||||
|
||||
@@ -24,5 +24,6 @@ public class NpcDTO {
|
||||
/** IDs de Pages de Lore référencées par ce PNJ (référence faible cross-context). */
|
||||
private List<String> relatedPageIds = new ArrayList<>();
|
||||
private String folder;
|
||||
private com.loremind.domain.campaigncontext.bestiary.NpcStory story;
|
||||
private int order;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ public class SceneDTO {
|
||||
private String gmSecretNotes;
|
||||
private String choicesConsequences;
|
||||
private String combatDifficulty;
|
||||
private String tactics;
|
||||
private String purpose;
|
||||
private String enemies;
|
||||
|
||||
/** IDs des fiches du bestiaire engagées dans la rencontre (weak refs). */
|
||||
|
||||
@@ -32,6 +32,8 @@ public class ArcMapper {
|
||||
dto.setGmNotes(arc.getGmNotes());
|
||||
dto.setRewards(arc.getRewards());
|
||||
dto.setResolution(arc.getResolution());
|
||||
dto.setHiddenTruth(arc.getHiddenTruth());
|
||||
dto.setHooks(arc.getHooks());
|
||||
dto.setRelatedPageIds(copyList(arc.getRelatedPageIds()));
|
||||
dto.setIllustrationImageIds(copyList(arc.getIllustrationImageIds()));
|
||||
return dto;
|
||||
@@ -55,6 +57,8 @@ public class ArcMapper {
|
||||
.gmNotes(dto.getGmNotes())
|
||||
.rewards(dto.getRewards())
|
||||
.resolution(dto.getResolution())
|
||||
.hiddenTruth(dto.getHiddenTruth())
|
||||
.hooks(dto.getHooks())
|
||||
.relatedPageIds(copyList(dto.getRelatedPageIds()))
|
||||
.illustrationImageIds(copyList(dto.getIllustrationImageIds()))
|
||||
.build();
|
||||
|
||||
@@ -23,6 +23,7 @@ public class NpcMapper {
|
||||
dto.setCampaignId(n.getCampaignId());
|
||||
dto.setRelatedPageIds(n.getRelatedPageIds() != null ? new ArrayList<>(n.getRelatedPageIds()) : new ArrayList<>());
|
||||
dto.setFolder(n.getFolder());
|
||||
dto.setStory(n.getStory());
|
||||
dto.setOrder(n.getOrder());
|
||||
return dto;
|
||||
}
|
||||
@@ -40,6 +41,7 @@ public class NpcMapper {
|
||||
.campaignId(dto.getCampaignId())
|
||||
.relatedPageIds(dto.getRelatedPageIds() != null ? new ArrayList<>(dto.getRelatedPageIds()) : new ArrayList<>())
|
||||
.folder(dto.getFolder())
|
||||
.story(dto.getStory())
|
||||
.order(dto.getOrder())
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ public class SceneMapper {
|
||||
dto.setGmSecretNotes(scene.getGmSecretNotes());
|
||||
dto.setChoicesConsequences(scene.getChoicesConsequences());
|
||||
dto.setCombatDifficulty(scene.getCombatDifficulty());
|
||||
dto.setTactics(scene.getTactics());
|
||||
dto.setPurpose(scene.getPurpose());
|
||||
dto.setEnemies(scene.getEnemies());
|
||||
dto.setEnemyIds(scene.getEnemyIds() != null
|
||||
? new ArrayList<>(scene.getEnemyIds())
|
||||
@@ -81,6 +83,8 @@ public class SceneMapper {
|
||||
.gmSecretNotes(dto.getGmSecretNotes())
|
||||
.choicesConsequences(dto.getChoicesConsequences())
|
||||
.combatDifficulty(dto.getCombatDifficulty())
|
||||
.tactics(dto.getTactics())
|
||||
.purpose(dto.getPurpose())
|
||||
.enemies(dto.getEnemies())
|
||||
.enemyIds(dto.getEnemyIds() != null
|
||||
? new ArrayList<>(dto.getEnemyIds())
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
-- Champs d'écriture (mentor) :
|
||||
-- scène : tactique et moral des adversaires, utilité (ce qu'on perd si on la coupe) ;
|
||||
-- arc : histoire cachée, accroches ;
|
||||
-- PNJ : fiche « rôle dans l'histoire » (rôle, motivation, ce qu'il sait, signe distinctif) en JSON.
|
||||
ALTER TABLE scenes ADD COLUMN tactics TEXT;
|
||||
ALTER TABLE scenes ADD COLUMN purpose TEXT;
|
||||
ALTER TABLE arcs ADD COLUMN hidden_truth TEXT;
|
||||
ALTER TABLE arcs ADD COLUMN hooks TEXT;
|
||||
ALTER TABLE npcs ADD COLUMN story TEXT;
|
||||
+53
@@ -4,6 +4,9 @@ import com.loremind.domain.campaigncontext.Campaign;
|
||||
import com.loremind.domain.campaigncontext.ports.ArcRepository;
|
||||
import com.loremind.domain.campaigncontext.ports.CampaignRepository;
|
||||
import com.loremind.domain.campaigncontext.ports.ChapterRepository;
|
||||
import com.loremind.domain.campaigncontext.bestiary.Npc;
|
||||
import com.loremind.domain.campaigncontext.bestiary.NpcStory;
|
||||
import com.loremind.domain.campaigncontext.ports.NpcRepository;
|
||||
import com.loremind.domain.campaigncontext.ports.QuestRepository;
|
||||
import com.loremind.domain.campaigncontext.ports.SceneRepository;
|
||||
import com.loremind.domain.campaigncontext.quest.Quest;
|
||||
@@ -47,6 +50,7 @@ class WritingReviewServiceTest {
|
||||
@Mock private ChapterRepository chapterRepository;
|
||||
@Mock private SceneRepository sceneRepository;
|
||||
@Mock private QuestRepository questRepository;
|
||||
@Mock private NpcRepository npcRepository;
|
||||
|
||||
@InjectMocks private WritingReviewService service;
|
||||
|
||||
@@ -459,4 +463,53 @@ class WritingReviewServiceTest {
|
||||
assertEquals("3", r.params().get("count"));
|
||||
assertFalse(ruleIds().contains("WRITE-003-SINGLE-CLUE"));
|
||||
}
|
||||
|
||||
// --- WRITE-008 : la tactique des adversaires donne un but au combat ---
|
||||
|
||||
@Test
|
||||
void combatPurpose_notRaised_whenTacticsAreWritten() {
|
||||
tree(List.of(scene("fight", 0).type(SceneType.ENCOUNTER).choicesConsequences(null)
|
||||
.tactics("Ils fuient dès que leur chef tombe").build()));
|
||||
assertFalse(ruleIds().contains("WRITE-008-COMBAT-NO-PURPOSE"));
|
||||
}
|
||||
|
||||
// --- WRITE-016 : opposant ou allié sans motivation ---
|
||||
|
||||
@Test
|
||||
void npcWithoutMotivation_onlyForPlotDrivingRoles() {
|
||||
when(npcRepository.findByCampaignId(CAMP)).thenReturn(List.of(
|
||||
Npc.builder().id("n1").name("Ysolde").story(new NpcStory("OPPONENT", " ", null, null)).build(),
|
||||
Npc.builder().id("n2").name("Borin").story(new NpcStory("ALLY", "Protéger sa fille", null, null)).build(),
|
||||
Npc.builder().id("n3").name("Le passant").story(new NpcStory("EXTRA", null, null, null)).build(),
|
||||
Npc.builder().id("n4").name("Sans fiche").build()));
|
||||
|
||||
List<WritingRemark> remarks = service.review(CAMP).remarks().stream()
|
||||
.filter(r -> r.ruleId().equals("WRITE-016-NPC-NO-MOTIVATION")).toList();
|
||||
assertEquals(1, remarks.size());
|
||||
assertEquals("n1", remarks.get(0).entityId());
|
||||
assertEquals(ReadinessEntityType.NPC, remarks.get(0).entityType());
|
||||
assertEquals("OPPONENT", remarks.get(0).params().get("role"));
|
||||
}
|
||||
|
||||
// --- WRITE-017 : une seule accroche ---
|
||||
|
||||
@Test
|
||||
void singleHook_whenTheArcHasExactlyOne() {
|
||||
Arc arc = arc("arc", ArcType.HUB);
|
||||
arc.setHooks("- Le prêtre a disparu");
|
||||
tree(arc, chapter("chap", "arc"), List.of(scene("s1", 0).build()));
|
||||
assertEquals(ReadinessEntityType.ARC, remark("WRITE-017-SINGLE-HOOK").entityType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void singleHook_notRaised_withSeveralHooks_orNone() {
|
||||
Arc several = arc("arc", ArcType.HUB);
|
||||
several.setHooks("- Le prêtre a disparu\n\n- Une récompense est offerte");
|
||||
tree(several, chapter("chap", "arc"), List.of(scene("s1", 0).build()));
|
||||
assertFalse(ruleIds().contains("WRITE-017-SINGLE-HOOK"));
|
||||
|
||||
Arc none = arc("arc", ArcType.HUB);
|
||||
tree(none, chapter("chap", "arc"), List.of(scene("s1", 0).build()));
|
||||
assertFalse(ruleIds().contains("WRITE-017-SINGLE-HOOK"), "accroches non renseignées : pas de remarque");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.loremind.domain.campaigncontext.bestiary;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/** Fiche « rôle dans l'histoire » d'un PNJ : nettoyage et rôle moteur de l'intrigue. */
|
||||
class NpcStoryTest {
|
||||
|
||||
@Test
|
||||
void normalized_cleansRoleAndTexts() {
|
||||
NpcStory s = new NpcStory(" ally ", " Venger son frère ", " ", "x".repeat(400)).normalized();
|
||||
assertEquals("ALLY", s.role());
|
||||
assertEquals("Venger son frère", s.motivation());
|
||||
assertNull(s.knowledge());
|
||||
assertEquals(300, s.mannerism().length());
|
||||
assertNull(new NpcStory("BOSS", null, null, null).normalized().role(), "rôle inconnu écarté");
|
||||
}
|
||||
|
||||
@Test
|
||||
void contentAndPlotRole() {
|
||||
assertFalse(new NpcStory(" ", "", null, null).hasContent());
|
||||
assertTrue(new NpcStory(null, null, null, "Se gratte la barbe").hasContent());
|
||||
assertTrue(new NpcStory("OPPONENT", null, null, null).drivesThePlot());
|
||||
assertTrue(new NpcStory("ally", null, null, null).drivesThePlot());
|
||||
assertFalse(new NpcStory("EXTRA", null, null, null).drivesThePlot());
|
||||
assertFalse(new NpcStory(null, "x", null, null).drivesThePlot());
|
||||
}
|
||||
}
|
||||
+15
@@ -165,6 +165,7 @@ class ContentExportImportRoundTripTest {
|
||||
|
||||
ArcJpaEntity arc = arcRepo.save(ArcJpaEntity.builder()
|
||||
.name("RT Arc").campaignId(campaign.getId()).order(0).type(ArcType.HUB)
|
||||
.hiddenTruth("RT vérité").hooks("- RT accroche 1\n- RT accroche 2")
|
||||
.relatedPageIds(new ArrayList<>(List.of(String.valueOf(page.getId()))))
|
||||
.illustrationImageIds(new ArrayList<>(List.of(imageRef))).build());
|
||||
|
||||
@@ -189,6 +190,7 @@ class ContentExportImportRoundTripTest {
|
||||
|
||||
sceneRepo.save(SceneJpaEntity.builder()
|
||||
.name("RT Scene").chapterId(chapterB.getId()).order(0)
|
||||
.tactics("RT fuient à la moitié").purpose("RT révèle le traître")
|
||||
.enemyIds(new ArrayList<>(List.of(String.valueOf(enemy.getId()))))
|
||||
.relatedPageIds(new ArrayList<>(List.of(String.valueOf(page.getId()))))
|
||||
.illustrationImageIds(new ArrayList<>(List.of(imageRef)))
|
||||
@@ -198,6 +200,7 @@ class ContentExportImportRoundTripTest {
|
||||
|
||||
npcRepo.save(NpcJpaEntity.builder()
|
||||
.name("RT Npc").campaignId(campaign.getId()).portraitImageId(imageRef).folder("Ville").order(0)
|
||||
.story(new com.loremind.domain.campaigncontext.bestiary.NpcStory("ALLY", "RT venger son frère", null, "RT tic"))
|
||||
.relatedPageIds(new ArrayList<>(List.of(String.valueOf(page.getId())))).build());
|
||||
|
||||
ItemCatalogJpaEntity catalog = ItemCatalogJpaEntity.builder()
|
||||
@@ -353,6 +356,18 @@ class ContentExportImportRoundTripTest {
|
||||
assertEquals((int) playthroughsBefore, result.created().get("playthroughs"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void import_keepsStoryFields_ofArcsScenesAndNpcs() {
|
||||
assertEquals("RT vérité", importedArc.getHiddenTruth());
|
||||
assertTrue(importedArc.getHooks().contains("RT accroche 2"));
|
||||
assertEquals(2, rtScenes.size());
|
||||
assertTrue(rtScenes.stream().allMatch(s -> "RT fuient à la moitié".equals(s.getTactics())
|
||||
&& "RT révèle le traître".equals(s.getPurpose())));
|
||||
List<NpcJpaEntity> npcs = npcRepo.findAll().stream().filter(n -> "RT Npc".equals(n.getName())).toList();
|
||||
assertEquals(2, npcs.size());
|
||||
assertTrue(npcs.stream().allMatch(n -> n.getStory() != null && "RT venger son frère".equals(n.getStory().motivation())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void import_remapsPrepEntities_arcPointsToImportedPage() {
|
||||
assertTrue(importedArc.getRelatedPageIds().contains(String.valueOf(importedPageId)));
|
||||
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.loremind.infrastructure.transfer.pdf;
|
||||
|
||||
import com.loremind.domain.campaigncontext.bestiary.NpcStory;
|
||||
import com.loremind.domain.campaigncontext.structure.SceneType;
|
||||
import com.loremind.infrastructure.persistence.entity.*;
|
||||
import com.loremind.infrastructure.persistence.jpa.*;
|
||||
import com.loremind.infrastructure.transfer.pdf.PdfExportOptions.LoreScope;
|
||||
import com.loremind.infrastructure.transfer.pdf.PdfExportOptions.PageFormat;
|
||||
import com.loremind.infrastructure.transfer.pdf.PdfExportOptions.Section;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* Champs d'écriture dans le livret : histoire cachée et accroches de l'arc, utilité et
|
||||
* tactique des scènes, rôle dans l'histoire des PNJ — secrets réservés à la version MJ,
|
||||
* signe distinctif visible de tous.
|
||||
*/
|
||||
@SpringBootTest
|
||||
@Transactional
|
||||
class PdfExportStoryFieldsTest {
|
||||
|
||||
@Autowired private PdfExportService service;
|
||||
@Autowired private CampaignJpaRepository campaignRepo;
|
||||
@Autowired private ArcJpaRepository arcRepo;
|
||||
@Autowired private ChapterJpaRepository chapterRepo;
|
||||
@Autowired private SceneJpaRepository sceneRepo;
|
||||
@Autowired private NpcJpaRepository npcRepo;
|
||||
|
||||
private String campaignId;
|
||||
|
||||
@BeforeEach
|
||||
void seed() {
|
||||
CampaignJpaEntity camp = campaignRepo.save(CampaignJpaEntity.builder().name("Récit").arcsCount(1).build());
|
||||
campaignId = String.valueOf(camp.getId());
|
||||
ArcJpaEntity arc = arcRepo.save(ArcJpaEntity.builder().name("Acte I").campaignId(camp.getId()).order(0)
|
||||
.hiddenTruth("Le régent a empoisonné le roi.").hooks("- Un ami disparaît\n- Une prime est offerte").build());
|
||||
ChapterJpaEntity ch = chapterRepo.save(ChapterJpaEntity.builder().name("Chap").arcId(arc.getId()).order(0).build());
|
||||
chapterRepo.save(ChapterJpaEntity.builder().name("Chap 2").arcId(arc.getId()).order(1).build());
|
||||
sceneRepo.save(SceneJpaEntity.builder().name("L'embuscade").chapterId(ch.getId()).order(0)
|
||||
.type(SceneType.ENCOUNTER).combatDifficulty("Moyenne")
|
||||
.purpose("Montrer que le régent a des hommes partout.")
|
||||
.tactics("Ils fuient dès que leur sergent tombe.").build());
|
||||
npcRepo.save(NpcJpaEntity.builder().campaignId(camp.getId()).name("Ysolde").order(0)
|
||||
.story(new NpcStory("OPPONENT", "Garder le trône.", "Où est caché le prince.", "Tapote sa bague."))
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
void gmEdition_showsEveryStoryField() {
|
||||
String x = service.xhtml(campaignId, PdfExportOptions.defaults());
|
||||
for (String s : List.of("Histoire cachée", "Le régent a empoisonné le roi.", ">Accroches<", "Une prime est offerte",
|
||||
">Utilité<", "Montrer que le régent a des hommes partout.",
|
||||
"Tactique et moral", "Ils fuient dès que leur sergent tombe.",
|
||||
">Opposant<", "Garder le trône.", "Où est caché le prince.", "Tapote sa bague.")) {
|
||||
assertTrue(x.contains(s), "absent de la version MJ : " + s);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void playerEdition_keepsOnlyTheMannerism() {
|
||||
String x = service.xhtml(campaignId, new PdfExportOptions(false, PageFormat.A4, false,
|
||||
EnumSet.allOf(Section.class), LoreScope.ALL));
|
||||
assertTrue(x.contains("Tapote sa bague."), "le signe distinctif se voit");
|
||||
for (String s : List.of("Le régent a empoisonné le roi.", "Une prime est offerte",
|
||||
"Montrer que le régent a des hommes partout.", "Ils fuient dès que leur sergent tombe.",
|
||||
">Opposant<", "Garder le trône.", "Où est caché le prince.")) {
|
||||
assertFalse(x.contains(s), "secret présent dans la version joueurs : " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user