Mentor d'écriture : champs d'histoire pour scènes, arcs et PNJ
Qualité & Sécurité / Web (ESLint · angular-eslint + sonarjs) (push) Successful in 52s
Qualité & Sécurité / MegaLinter (PMD · Ruff · Bandit · gitleaks · hadolint) (push) Successful in 54s
Qualité & Sécurité / Trivy (CVE dépendances Maven / pip / npm) (push) Failing after 54s

- 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:
2026-10-17 17:07:10 +02:00
parent 0c0581e894
commit 106754fd77
57 changed files with 1262 additions and 51 deletions
@@ -95,6 +95,35 @@
</app-expandable-section>
<!-- Thèmes et enjeux -->
<!-- Histoire cachée et accroches : la vérité que les joueurs découvriront, et pourquoi ils s'en mêlent. -->
<app-expandable-section [title]="'arcEdit.truthHooksSectionTitle' | translate" icon="🗝️" [initiallyOpen]="focusSection === 'hooks'" [filled]="truthHooksFilled">
<div class="field">
<div class="field-label-row">
<label for="arc-edit-hidden-truth">{{ 'arcEdit.hiddenTruthLabel' | translate }}</label>
<app-writing-coach-trigger topic="arc.hiddenTruth"></app-writing-coach-trigger>
</div>
<textarea
id="arc-edit-hidden-truth"
formControlName="hiddenTruth"
[placeholder]="'arcEdit.hiddenTruthPlaceholder' | translate"
rows="4">
</textarea>
</div>
<div class="field">
<div class="field-label-row">
<label for="arc-edit-hooks">{{ 'arcEdit.hooksLabel' | translate }}</label>
<app-writing-coach-trigger topic="arc.hooks"></app-writing-coach-trigger>
</div>
<textarea
id="arc-edit-hooks"
formControlName="hooks"
[placeholder]="'arcEdit.hooksPlaceholder' | translate"
rows="4">
</textarea>
<small class="field-hint">{{ 'arcEdit.hooksHint' | translate }}</small>
</div>
</app-expandable-section>
<app-expandable-section [title]="'arcEdit.themesStakesSectionTitle' | translate" icon="🎭" [initiallyOpen]="focusSection === 'stakes'" [filled]="themesStakesFilled">
<div class="field-row">
<div class="field">
@@ -97,6 +97,10 @@ export class ArcEditComponent implements OnInit {
return !!(v.themes || v.stakes);
}
get gmNotesFilled(): boolean { return !!this.form.value.gmNotes; }
get truthHooksFilled(): boolean {
const v = this.form.value;
return !!(v.hiddenTruth || v.hooks);
}
get rewardsResolutionFilled(): boolean {
const v = this.form.value;
return !!(v.rewards || v.resolution);
@@ -126,7 +130,9 @@ export class ArcEditComponent implements OnInit {
stakes: [''],
gmNotes: [''],
rewards: [''],
resolution: ['']
resolution: [''],
hiddenTruth: [''],
hooks: ['']
});
}
@@ -179,7 +185,9 @@ export class ArcEditComponent implements OnInit {
stakes: arc.stakes ?? '',
gmNotes: arc.gmNotes ?? '',
rewards: arc.rewards ?? '',
resolution: arc.resolution ?? ''
resolution: arc.resolution ?? '',
hiddenTruth: arc.hiddenTruth ?? '',
hooks: arc.hooks ?? ''
});
this.layoutService.show(buildCampaignSidebarConfig(campaign, allCampaigns, treeData, this.campaignId, this.translate));
@@ -199,6 +207,8 @@ export class ArcEditComponent implements OnInit {
gmNotes: this.form.value.gmNotes,
rewards: this.form.value.rewards,
resolution: this.form.value.resolution,
hiddenTruth: this.form.value.hiddenTruth,
hooks: this.form.value.hooks,
relatedPageIds: this.relatedPageIds,
illustrationImageIds: this.illustrationImageIds,
icon: this.selectedIcon
@@ -84,6 +84,18 @@
}
</section>
</div>
@if (arc.hooks?.trim()) {
<section class="view-section">
<h2 class="view-section-title"><span class="view-section-icon">🪝</span> {{ 'arcView.hooksTitle' | translate }}</h2>
<p class="view-section-body">{{ arc.hooks }}</p>
</section>
}
@if (arc.hiddenTruth?.trim()) {
<section class="view-section view-section--private">
<h2 class="view-section-title"><span class="view-section-icon">🗝️</span> {{ 'arcView.hiddenTruthTitle' | translate }}</h2>
<p class="view-section-body">{{ arc.hiddenTruth }}</p>
</section>
}
<section class="view-section">
<h2 class="view-section-title"><span class="view-section-icon">🎁</span> {{ 'arcView.rewardsTitle' | translate }}</h2>
@if (arc.rewards?.trim()) {
@@ -87,6 +87,48 @@
</app-dynamic-fields-form>
</div>
<!-- Rôle dans l'histoire : indépendant du système de jeu (le gabarit porte les caractéristiques). -->
<fieldset class="story-block">
<legend>{{ 'npcEdit.storyTitle' | translate }}</legend>
<p class="hint">{{ 'npcEdit.storyHint' | translate }}</p>
<div class="field">
<div class="field-label-row">
<label for="npc-role">{{ 'npcEdit.roleLabel' | translate }}</label>
<app-writing-coach-trigger topic="npc.role"></app-writing-coach-trigger>
</div>
<select id="npc-role" name="role" [(ngModel)]="story.role">
<option [ngValue]="null">{{ 'npcEdit.roleNone' | translate }}</option>
@for (r of roles; track r) {
<option [ngValue]="r">{{ ('npcEdit.role.' + r) | translate }}</option>
}
</select>
</div>
<div class="field">
<div class="field-label-row">
<label for="npc-motivation">{{ 'npcEdit.motivationLabel' | translate }}</label>
<app-writing-coach-trigger topic="npc.motivation"></app-writing-coach-trigger>
</div>
<textarea id="npc-motivation" name="motivation" rows="3" [(ngModel)]="story.motivation"
[placeholder]="'npcEdit.motivationPlaceholder' | translate"></textarea>
</div>
<div class="field">
<div class="field-label-row">
<label for="npc-knowledge">{{ 'npcEdit.knowledgeLabel' | translate }}</label>
<app-writing-coach-trigger topic="npc.knowledge"></app-writing-coach-trigger>
</div>
<textarea id="npc-knowledge" name="knowledge" rows="3" [(ngModel)]="story.knowledge"
[placeholder]="'npcEdit.knowledgePlaceholder' | translate"></textarea>
</div>
<div class="field">
<div class="field-label-row">
<label for="npc-mannerism">{{ 'npcEdit.mannerismLabel' | translate }}</label>
<app-writing-coach-trigger topic="npc.mannerism"></app-writing-coach-trigger>
</div>
<input id="npc-mannerism" name="mannerism" type="text" [(ngModel)]="story.mannerism"
[placeholder]="'npcEdit.mannerismPlaceholder' | translate" />
</div>
</fieldset>
<!-- Pages de Lore liées (uniquement si la campagne est rattachée à un Lore) -->
@if (loreId) {
<div class="field">
@@ -155,3 +155,23 @@
background: rgba(248, 113, 113, 0.08);
}
}
// Rôle dans l'histoire : bloc encadré, indépendant des champs du système de jeu.
.story-block {
border: 1px solid #1f2937;
border-radius: 10px;
padding: 0.9rem 1rem 1rem;
margin: 1rem 0;
display: flex;
flex-direction: column;
gap: 0.9rem;
legend {
padding: 0 0.4rem;
color: #e5e7eb;
font-weight: 600;
font-size: 0.95rem;
}
.hint { margin: 0; }
}
@@ -5,6 +5,7 @@ import { FormsModule } from '@angular/forms';
import { LucideAngularModule, Save, ArrowLeft, Drama, Trash2, Sparkles } from 'lucide-angular';
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
import { NpcService } from '../../../services/npc.service';
import { NPC_ROLES, NpcStory } from '../../../services/npc.model';
import { CampaignService } from '../../../services/campaign.service';
import { GameSystemService } from '../../../services/game-system.service';
import { PageService } from '../../../services/page.service';
@@ -16,6 +17,7 @@ import { DynamicFieldsFormComponent } from '../../../shared/dynamic-fields-form/
import { SingleImagePickerComponent } from '../../../shared/single-image-picker/single-image-picker.component';
import { LoreLinkPickerComponent } from '../../../shared/lore-link-picker/lore-link-picker.component';
import { ConfirmDialogService } from '../../../shared/confirm-dialog/confirm-dialog.service';
import { WritingCoachTriggerComponent } from '../../../shared/writing-coach/writing-coach-trigger.component';
/**
* Editeur plein ecran d'une fiche de PNJ.
@@ -25,7 +27,7 @@ import { ConfirmDialogService } from '../../../shared/confirm-dialog/confirm-dia
*/
@Component({
selector: 'app-npc-edit',
imports: [FormsModule, LucideAngularModule, TranslatePipe, AiChatDrawerComponent, DynamicFieldsFormComponent, SingleImagePickerComponent, LoreLinkPickerComponent],
imports: [FormsModule, LucideAngularModule, TranslatePipe, AiChatDrawerComponent, DynamicFieldsFormComponent, SingleImagePickerComponent, LoreLinkPickerComponent, WritingCoachTriggerComponent],
templateUrl: './npc-edit.component.html',
styleUrls: ['./npc-edit.component.scss']
})
@@ -68,6 +70,9 @@ export class NpcEditComponent implements OnInit {
lorePages: Page[] = [];
/** IDs des pages de lore référencées par ce PNJ. */
relatedPageIds: string[] = [];
/** Rôle dans l'histoire (fiche indépendante du système de jeu). */
story: NpcStory = { role: null };
readonly roles = NPC_ROLES;
constructor(
private route: ActivatedRoute,
@@ -103,6 +108,7 @@ export class NpcEditComponent implements OnInit {
this.imageValues = n.imageValues ?? {};
this.keyValueValues = n.keyValueValues ?? {};
this.relatedPageIds = [...(n.relatedPageIds ?? [])];
this.story = { ...(n.story ?? {}), role: n.story?.role ?? null };
this.order = n.order ?? 0;
},
error: () => this.back()
@@ -157,7 +163,8 @@ export class NpcEditComponent implements OnInit {
imageValues: this.imageValues,
keyValueValues: this.keyValueValues,
campaignId: this.campaignId,
relatedPageIds: this.relatedPageIds
relatedPageIds: this.relatedPageIds,
story: { ...this.story, role: this.story.role || null }
};
const isCreation = !this.npcId;
const req = this.npcId
@@ -19,6 +19,26 @@
<app-persona-view [persona]="npc" [templateFields]="templateFields"></app-persona-view>
@if (npc?.story; as story) {
<section class="nv-story">
<h2 class="nv-story-title">
{{ 'npcView.storyTitle' | translate }}
@if (story.role) {
<span class="nv-role">{{ ('npcEdit.role.' + story.role) | translate }}</span>
}
</h2>
@if (story.mannerism) {
<p><strong>{{ 'npcEdit.mannerismLabel' | translate }} :</strong> {{ story.mannerism }}</p>
}
@if (story.motivation) {
<p><strong>{{ 'npcEdit.motivationLabel' | translate }} :</strong> {{ story.motivation }}</p>
}
@if (story.knowledge) {
<p class="nv-private"><strong>{{ 'npcEdit.knowledgeLabel' | translate }} :</strong> {{ story.knowledge }}</p>
}
</section>
}
<!-- Pages de Lore liées à ce PNJ (sa ville, sa faction…) -->
@if (loreId && (npc?.relatedPageIds?.length ?? 0) > 0) {
<section class="nv-lore-links">
@@ -92,3 +92,39 @@
}
}
}
// Fiche « rôle dans l'histoire » (indépendante du système de jeu).
.nv-story {
margin: 1.25rem 0;
padding: 0.9rem 1rem;
border: 1px solid #1f2937;
border-radius: 10px;
background: #111827;
p { margin: 0.35rem 0; color: #d1d5db; line-height: 1.5; white-space: pre-line; }
strong { color: #e5e7eb; }
}
.nv-story-title {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.95rem;
color: white;
margin: 0 0 0.4rem;
}
.nv-role {
font-size: 0.72rem;
text-transform: uppercase;
letter-spacing: 0.05em;
padding: 0.1rem 0.5rem;
border-radius: 999px;
background: rgba(108, 99, 255, 0.15);
color: #c7d2fe;
}
.nv-private {
border-left: 2px dashed #ab9fd6;
padding-left: 0.6rem;
}
@@ -64,6 +64,20 @@
</textarea>
</div>
<!-- Utilité : ce que l'histoire perd si on coupe la scène (aide à trier et à rythmer). -->
<div class="field">
<div class="field-label-row">
<label for="scene-edit-purpose">{{ 'sceneEdit.purposeLabel' | translate }}</label>
<app-writing-coach-trigger topic="scene.purpose"></app-writing-coach-trigger>
</div>
<textarea
id="scene-edit-purpose"
formControlName="purpose"
[placeholder]="'sceneEdit.purposePlaceholder' | translate"
rows="2">
</textarea>
</div>
<div class="field">
<label>{{ 'sceneEdit.iconLabel' | translate }}</label>
<app-icon-picker [options]="campaignIconOptions" [(selected)]="selectedIcon"></app-icon-picker>
@@ -348,6 +362,18 @@
rows="4">
</textarea>
</div>
<div class="field">
<div class="field-label-row">
<label for="scene-edit-tactics">{{ 'sceneEdit.tacticsLabel' | translate }}</label>
<app-writing-coach-trigger topic="scene.tactics"></app-writing-coach-trigger>
</div>
<textarea
id="scene-edit-tactics"
formControlName="tactics"
[placeholder]="'sceneEdit.tacticsPlaceholder' | translate"
rows="3">
</textarea>
</div>
</app-expandable-section>
<!-- Section : Pages Lore associées (B2 cross-context) -->
@@ -154,7 +154,7 @@ export class SceneEditComponent implements OnInit {
get branchesFilled(): boolean { return this.branches.length > 0; }
get combatFilled(): boolean {
const v = this.form.value;
return !!(v.combatDifficulty || v.enemies) || this.enemyIds.length > 0;
return !!(v.combatDifficulty || v.enemies || v.tactics) || this.enemyIds.length > 0;
}
get loreFilled(): boolean { return this.relatedPageIds.length > 0; }
get dungeonFilled(): boolean { return this.rooms.length > 0; }
@@ -191,7 +191,10 @@ export class SceneEditComponent implements OnInit {
choicesConsequences: [''],
// Combat
combatDifficulty: [''],
enemies: ['']
enemies: [''],
tactics: [''],
// Utilité dans l'histoire
purpose: ['']
});
}
@@ -281,7 +284,9 @@ export class SceneEditComponent implements OnInit {
gmSecretNotes: scene.gmSecretNotes ?? '',
choicesConsequences: scene.choicesConsequences ?? '',
combatDifficulty: scene.combatDifficulty ?? '',
enemies: scene.enemies ?? ''
enemies: scene.enemies ?? '',
tactics: scene.tactics ?? '',
purpose: scene.purpose ?? ''
});
this.layoutService.show(buildCampaignSidebarConfig(campaign, allCampaigns, treeData, this.campaignId, this.translate));
@@ -304,6 +309,8 @@ export class SceneEditComponent implements OnInit {
choicesConsequences: this.form.value.choicesConsequences,
combatDifficulty: this.form.value.combatDifficulty,
enemies: this.form.value.enemies,
tactics: this.form.value.tactics,
purpose: this.form.value.purpose,
enemyIds: this.enemyIds,
relatedPageIds: this.relatedPageIds,
illustrationImageIds: this.illustrationImageIds,
@@ -73,6 +73,12 @@
<p class="view-section-body">{{ scene.choicesConsequences }}</p>
</section>
}
@if (scene.purpose?.trim()) {
<section class="view-section">
<h2 class="view-section-title"><span class="view-section-icon">🎯</span> {{ 'sceneView.purposeSectionTitle' | translate }}</h2>
<p class="view-section-body">{{ scene.purpose }}</p>
</section>
}
<!-- Combat ou rencontre -->
@if (scene.combatDifficulty?.trim() || scene.enemies?.trim() || linkedEnemies.length > 0) {
@if (scene.combatDifficulty?.trim()) {
@@ -100,6 +106,12 @@
</section>
}
}
@if (scene.tactics?.trim()) {
<section class="view-section">
<h2 class="view-section-title"><span class="view-section-icon">🛡️</span> {{ 'sceneView.tacticsSectionTitle' | translate }}</h2>
<p class="view-section-body">{{ scene.tactics }}</p>
</section>
}
<!-- Notes et secrets du MJ (privé) -->
@if (scene.gmSecretNotes?.trim()) {
<section class="view-section view-section--private">
@@ -21,6 +21,8 @@ export function remarkAction(remark: WritingRemark, campaignId: string): GapActi
return { link: [...base, 'arcs', remark.arcId ?? '', 'chapters', remark.entityId, 'edit'], queryParams };
case 'ARC':
return { link: [...base, 'arcs', remark.entityId, 'edit'], queryParams };
case 'NPC':
return { link: [...base, 'npcs', remark.entityId, 'edit'] };
default:
return { link: base };
}
@@ -38,5 +40,6 @@ const FOCUS_BY_RULE: Record<string, string> = {
'WRITE-011-ISOLATED-SCENE': 'branches',
'WRITE-012-CHOKEPOINT': 'choices',
'WRITE-013-LINEAR-DUNGEON': 'rooms',
'WRITE-015-SAME-SOURCE-CLUES': 'branches'
'WRITE-015-SAME-SOURCE-CLUES': 'branches',
'WRITE-017-SINGLE-HOOK': 'hooks'
};
+16
View File
@@ -67,6 +67,10 @@ export interface Arc {
gmNotes?: string;
rewards?: string;
resolution?: string;
/** Histoire cachée (réservée au MJ). */
hiddenTruth?: string;
/** Accroches : une par ligne. */
hooks?: string;
/** IDs des pages du Lore liées à cet arc (weak cross-context refs). */
relatedPageIds?: string[];
@@ -89,6 +93,10 @@ export interface ArcCreate {
gmNotes?: string;
rewards?: string;
resolution?: string;
/** Histoire cachée (réservée au MJ). */
hiddenTruth?: string;
/** Accroches : une par ligne. */
hooks?: string;
relatedPageIds?: string[];
illustrationImageIds?: string[];
@@ -297,6 +305,10 @@ export interface Scene {
gmSecretNotes?: string;
choicesConsequences?: string;
combatDifficulty?: string;
/** Tactique et moral des adversaires. */
tactics?: string;
/** Utilité : ce que l'histoire perd si on coupe la scène. */
purpose?: string;
enemies?: string;
/** IDs des fiches du bestiaire engagées dans la rencontre (weak refs). */
@@ -340,6 +352,10 @@ export interface SceneCreate {
gmSecretNotes?: string;
choicesConsequences?: string;
combatDifficulty?: string;
/** Tactique et moral des adversaires. */
tactics?: string;
/** Utilité : ce que l'histoire perd si on coupe la scène. */
purpose?: string;
enemies?: string;
/** IDs des fiches du bestiaire engagées dans la rencontre (weak refs). */
+19
View File
@@ -16,6 +16,24 @@ export interface Npc {
/** Dossier de classement (ex. « Bard's Gate »). Vide/absent = non classé. */
folder?: string | null;
order?: number;
/** Rôle dans l'histoire (indépendant du système de jeu). */
story?: NpcStory | null;
}
/** Place d'un PNJ dans l'histoire. */
export type NpcRole = 'OPPONENT' | 'ALLY' | 'RESOURCE' | 'EXTRA';
export const NPC_ROLES: NpcRole[] = ['OPPONENT', 'ALLY', 'RESOURCE', 'EXTRA'];
/** Fiche « rôle dans l'histoire » d'un PNJ (miroir du record Java NpcStory). */
export interface NpcStory {
role?: NpcRole | null;
/** Ce qu'il veut, et ce qu'il est prêt à faire. */
motivation?: string | null;
/** Ce qu'il sait (réservé au MJ). */
knowledge?: string | null;
/** Signe distinctif à jouer (geste, phrasé, tic). */
mannerism?: string | null;
}
export interface NpcCreate {
@@ -28,4 +46,5 @@ export interface NpcCreate {
campaignId: string;
relatedPageIds?: string[];
folder?: string | null;
story?: NpcStory | null;
}
@@ -25,7 +25,7 @@ describe('writing review content', () => {
const rules = emittedRules();
it('finds the rules emitted by the core', () => {
expect(rules).toHaveLength(15);
expect(rules).toHaveLength(17);
});
for (const lang of ['fr', 'en'] as const) {
@@ -72,3 +72,19 @@ describe('remarkAction', () => {
expect(remarkAction(r, 'camp').link).toEqual(['/campaigns', 'camp']);
});
});
describe('remarkAction for NPCs and hooks', () => {
const base: WritingRemark = {
entityType: 'NPC', entityId: 'n1', ruleId: 'WRITE-016-NPC-NO-MOTIVATION',
category: 'STAKES', params: { role: 'OPPONENT' }, arcId: null, chapterId: null
};
it('opens the NPC editor', () => {
expect(remarkAction(base, 'camp')).toEqual({ link: ['/campaigns', 'camp', 'npcs', 'n1', 'edit'] });
});
it('opens the arc editor on the hooks section', () => {
expect(remarkAction({ ...base, entityType: 'ARC', entityId: 'a1', ruleId: 'WRITE-017-SINGLE-HOOK' }, 'camp'))
.toEqual({ link: ['/campaigns', 'camp', 'arcs', 'a1', 'edit'], queryParams: { focus: 'hooks' } });
});
});