Mentor d'écriture (M1-M3) : coach dans les champs, relecture d'éditeur, méthode guidée « Donjon en 5 salles »
Qualité & Sécurité / MegaLinter (PMD · Ruff · Bandit · gitleaks · hadolint) (push) Successful in 13m48s
Qualité & Sécurité / Web (ESLint · angular-eslint + sonarjs) (push) Successful in 13m16s
Qualité & Sécurité / Trivy (CVE dépendances Maven / pip / npm) (push) Failing after 3m3s
Build & Push Images / build (core) (push) Successful in 4m50s
Build & Push Images / build (web) (push) Successful in 3m26s
Build & Push Images / build-switcher (push) Successful in 26s
Build & Push Images / build (brain) (push) Canceled after 1m5s
Qualité & Sécurité / MegaLinter (PMD · Ruff · Bandit · gitleaks · hadolint) (push) Successful in 13m48s
Qualité & Sécurité / Web (ESLint · angular-eslint + sonarjs) (push) Successful in 13m16s
Qualité & Sécurité / Trivy (CVE dépendances Maven / pip / npm) (push) Failing after 3m3s
Build & Push Images / build (core) (push) Successful in 4m50s
Build & Push Images / build (web) (push) Successful in 3m26s
Build & Push Images / build-switcher (push) Successful in 26s
Build & Push Images / build (brain) (push) Canceled after 1m5s
- M1 coach : bouton ampoule sur 17 champs narratifs (scène, chapitre, arc),
panneau de conseils (à quoi ça sert, questions, exemple, piège classique).
Contenu statique i18n fr/en, sans IA ; ampoule aussi dans l'en-tête des
sections repliables (input coachTopic d'expandable-section).
- M2 relecture d'éditeur : WritingReviewService + GET
/api/campaigns/{id}/writing-review, 10 règles déterministes WRITE-001 à 010
(couloir, faux choix, révélation à chemin unique, rythme monotone, enjeux
absents, narration trop longue ou qui décide à la place des PJ, combat sans
but, fin unique, scènes non typées). Le back renvoie ruleId + params, les
textes fr/en sont dans l'i18n. Panneau sur le hub, encart dans les éditeurs,
liens « Voir » avec ?focus= (nouveaux focus : narration, choices, stakes).
- M3 méthode guidée : POST /api/campaigns/{id}/guided-skeleton (arc existant
ou nouveau, chapitre, scènes typées, chaînage optionnel, transactionnel)
+ assistant pas à pas générique /campaigns/:id/guided/:method, première
méthode « Donjon en 5 salles ». Entrées sur le hub de campagne.
- Garde-fous vitest : complétude des textes fr/en du coach, de la relecture
(règles lues dans le Java) et des méthodes guidées.
Vérifié : core clean verify (1182 tests), web build + 299 tests vitest, lint
sans erreur, parcours testés dans l'appli (back Postgres de dev).
À redéployer : core (2 endpoints, aucune migration) + web.
This commit is contained in:
@@ -29,6 +29,9 @@
|
||||
<!-- Tout est optionnel sauf le titre : identité visible, le reste replié. -->
|
||||
<p class="optional-hint">{{ 'arcEdit.optionalHint' | translate }}</p>
|
||||
|
||||
<!-- Mentor d'écriture (M2) : conseils de relecture qui concernent cette entité. -->
|
||||
<app-writing-review-hints [campaignId]="campaignId" entityType="ARC" [entityId]="arcId"></app-writing-review-hints>
|
||||
|
||||
<!-- Co-création (Pilier A) : le co-MJ propose, validation champ par champ → remplit le formulaire. -->
|
||||
<app-entity-assist-panel
|
||||
[entityType]="'arc'" [entityId]="arcId" [campaignId]="campaignId"
|
||||
@@ -47,7 +50,10 @@
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="arc-edit-description">{{ 'arcEdit.synopsisLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="arc-edit-description">{{ 'arcEdit.synopsisLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="arc.synopsis"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="arc-edit-description"
|
||||
formControlName="description"
|
||||
@@ -89,10 +95,13 @@
|
||||
</app-expandable-section>
|
||||
|
||||
<!-- Thèmes et enjeux -->
|
||||
<app-expandable-section [title]="'arcEdit.themesStakesSectionTitle' | translate" icon="🎭" [filled]="themesStakesFilled">
|
||||
<app-expandable-section [title]="'arcEdit.themesStakesSectionTitle' | translate" icon="🎭" [initiallyOpen]="focusSection === 'stakes'" [filled]="themesStakesFilled">
|
||||
<div class="field-row">
|
||||
<div class="field">
|
||||
<label for="arc-edit-themes">{{ 'arcEdit.themesLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="arc-edit-themes">{{ 'arcEdit.themesLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="arc.themes"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="arc-edit-themes"
|
||||
formControlName="themes"
|
||||
@@ -101,7 +110,10 @@
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="arc-edit-stakes">{{ 'arcEdit.stakesLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="arc-edit-stakes">{{ 'arcEdit.stakesLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="arc.stakes"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="arc-edit-stakes"
|
||||
formControlName="stakes"
|
||||
@@ -129,7 +141,10 @@
|
||||
<!-- Récompenses et dénouement -->
|
||||
<app-expandable-section [title]="'arcEdit.rewardsResolutionSectionTitle' | translate" icon="🎁" [filled]="rewardsResolutionFilled">
|
||||
<div class="field">
|
||||
<label for="arc-edit-rewards">{{ 'arcEdit.rewardsLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="arc-edit-rewards">{{ 'arcEdit.rewardsLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="arc.rewards"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="arc-edit-rewards"
|
||||
formControlName="rewards"
|
||||
@@ -138,7 +153,10 @@
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="arc-edit-resolution">{{ 'arcEdit.resolutionLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="arc-edit-resolution">{{ 'arcEdit.resolutionLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="arc.resolution"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="arc-edit-resolution"
|
||||
formControlName="resolution"
|
||||
|
||||
@@ -26,6 +26,8 @@ import { CAMPAIGN_ICON_OPTIONS } from '../../campaign-icons';
|
||||
import { ConfirmDialogService } from '../../../shared/confirm-dialog/confirm-dialog.service';
|
||||
import { EntityAssistPanelComponent } from '../../../shared/entity-assist-panel/entity-assist-panel.component';
|
||||
import { FieldProposal } from '../../../services/entity-assist.model';
|
||||
import { WritingCoachTriggerComponent } from '../../../shared/writing-coach/writing-coach-trigger.component';
|
||||
import { WritingReviewHintsComponent } from '../../../shared/writing-review/writing-review-hints.component';
|
||||
|
||||
/**
|
||||
* Écran de détail/modification d'un Arc.
|
||||
@@ -38,7 +40,7 @@ import { FieldProposal } from '../../../services/entity-assist.model';
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-arc-edit',
|
||||
imports: [ReactiveFormsModule, LucideAngularModule, LoreLinkPickerComponent, AiChatDrawerComponent, ImageGalleryComponent, IconPickerComponent, ExpandableSectionComponent, EntityAssistPanelComponent, TranslatePipe],
|
||||
imports: [ReactiveFormsModule, LucideAngularModule, LoreLinkPickerComponent, AiChatDrawerComponent, ImageGalleryComponent, IconPickerComponent, ExpandableSectionComponent, EntityAssistPanelComponent, TranslatePipe, WritingCoachTriggerComponent, WritingReviewHintsComponent],
|
||||
templateUrl: './arc-edit.component.html',
|
||||
styleUrls: ['./arc-edit.component.scss']
|
||||
})
|
||||
@@ -74,6 +76,9 @@ export class ArcEditComponent implements OnInit {
|
||||
arcId = '';
|
||||
arc: Arc | null = null;
|
||||
|
||||
/** `?focus=stakes` (lien « Voir » de la relecture d'éditeur) → section dépliée d'office. */
|
||||
focusSection: string | null = null;
|
||||
|
||||
/** Pages disponibles pour le picker (vide si la campagne n'a pas de loreId). */
|
||||
availablePages: Page[] = [];
|
||||
/** ID du Lore associé à la campagne (null si campagne sans univers). */
|
||||
@@ -135,6 +140,7 @@ export class ArcEditComponent implements OnInit {
|
||||
if (newArcId !== this.arcId || newCampaignId !== this.campaignId) {
|
||||
this.campaignId = newCampaignId;
|
||||
this.arcId = newArcId;
|
||||
this.focusSection = this.route.snapshot.queryParamMap.get('focus');
|
||||
this.loadAll();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -62,6 +62,8 @@
|
||||
<!-- ============ Guidage co-MJ : « Prochaines étapes » (Pilier B) ============ -->
|
||||
@if (!editing && campaign.id) {
|
||||
<app-readiness-panel [campaignId]="campaign.id" [assessment]="readiness"></app-readiness-panel>
|
||||
<!-- Mentor d'écriture (M2) : conseils d'auteur sur la qualité, à côté de la complétude. -->
|
||||
<app-writing-review-panel [campaignId]="campaign.id"></app-writing-review-panel>
|
||||
}
|
||||
<!-- ============ Header : mode édition inline ============ -->
|
||||
@if (editing) {
|
||||
@@ -206,6 +208,11 @@
|
||||
<lucide-icon [img]="Plus" [size]="14"></lucide-icon>
|
||||
{{ 'campaignDetail.newArc' | translate }}
|
||||
</button>
|
||||
<!-- Mentor d'écriture (M3) : écrire une aventure question par question. -->
|
||||
<a class="btn-add btn-guided" [routerLink]="['/campaigns', campaign.id, 'guided', 'five-room']">
|
||||
<lucide-icon [img]="Sparkles" [size]="14"></lucide-icon>
|
||||
{{ 'guided.entry' | translate }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@if (arcs.length > 0 && !showQuickAddScene) {
|
||||
@@ -235,6 +242,10 @@
|
||||
<lucide-icon [img]="Plus" [size]="14"></lucide-icon>
|
||||
{{ 'campaignDetail.quickSceneFirst' | translate }}
|
||||
</button>
|
||||
<a class="btn-add-first btn-guided" [routerLink]="['/campaigns', campaign.id, 'guided', 'five-room']">
|
||||
<lucide-icon [img]="Sparkles" [size]="14"></lucide-icon>
|
||||
{{ 'guided.entryFirst' | translate }}
|
||||
</a>
|
||||
<button type="button" class="empty-alt-action" (click)="createArc()">
|
||||
{{ 'campaignDetail.organizeInArcs' | translate }}
|
||||
</button>
|
||||
|
||||
@@ -486,6 +486,18 @@
|
||||
&:hover { background: #5b52e0; }
|
||||
}
|
||||
|
||||
// Entrée « Méthode guidée » (Mentor d'écriture, M3) : un lien stylé en bouton,
|
||||
// accent ambré du mentor pour le distinguer des créations « à la main ».
|
||||
.btn-guided {
|
||||
text-decoration: none;
|
||||
background: rgba(251, 191, 36, 0.12);
|
||||
color: #fde68a;
|
||||
border: 1px solid rgba(251, 191, 36, 0.35);
|
||||
|
||||
&:hover { background: rgba(251, 191, 36, 0.2); }
|
||||
&:focus-visible { outline: 2px solid #6c63ff; outline-offset: 2px; }
|
||||
}
|
||||
|
||||
// Action secondaire de l'état vide (« ou créer un arc ») — bouton texte discret.
|
||||
.empty-alt-action {
|
||||
background: none;
|
||||
|
||||
@@ -32,11 +32,12 @@ import { ConfirmDialogService } from '../../../shared/confirm-dialog/confirm-dia
|
||||
import { FolderGroup, groupByFolder, byOrder } from '../../../shared/folder-grouping.util';
|
||||
import { CampaignReadinessAssessment } from '../../../services/readiness.model';
|
||||
import { ReadinessPanelComponent } from '../../../shared/readiness-panel/readiness-panel.component';
|
||||
import { WritingReviewPanelComponent } from '../../../shared/writing-review/writing-review-panel.component';
|
||||
import { FoundryExportDialogComponent } from '../foundry-export-dialog/foundry-export-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-campaign-detail',
|
||||
imports: [FormsModule, LucideAngularModule, RouterLink, TranslatePipe, CdkDropList, CdkDrag, ReadinessPanelComponent, FoundryExportDialogComponent],
|
||||
imports: [FormsModule, LucideAngularModule, RouterLink, TranslatePipe, CdkDropList, CdkDrag, ReadinessPanelComponent, WritingReviewPanelComponent, FoundryExportDialogComponent],
|
||||
templateUrl: './campaign-detail.component.html',
|
||||
styleUrls: ['./campaign-detail.component.scss']
|
||||
})
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
<!-- Tout est optionnel sauf le titre : identité visible, le reste replié. -->
|
||||
<p class="optional-hint">{{ 'chapterEdit.optionalHint' | translate }}</p>
|
||||
|
||||
<!-- Mentor d'écriture (M2) : conseils de relecture qui concernent cette entité. -->
|
||||
<app-writing-review-hints [campaignId]="campaignId" entityType="CHAPTER" [entityId]="chapterId"></app-writing-review-hints>
|
||||
|
||||
<!-- Co-création (Pilier A) : le co-MJ propose, validation champ par champ → remplit le formulaire. -->
|
||||
<app-entity-assist-panel
|
||||
[entityType]="'chapter'" [entityId]="chapterId" [campaignId]="campaignId"
|
||||
@@ -53,7 +56,10 @@
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="chapter-edit-description">{{ 'chapterEdit.synopsisLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="chapter-edit-description">{{ 'chapterEdit.synopsisLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="chapter.synopsis"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="chapter-edit-description"
|
||||
formControlName="description"
|
||||
@@ -93,10 +99,13 @@
|
||||
</app-expandable-section>
|
||||
|
||||
<!-- Objectifs et enjeux -->
|
||||
<app-expandable-section [title]="'chapterEdit.objectivesStakesSectionTitle' | translate" icon="🎯" [filled]="objectivesStakesFilled">
|
||||
<app-expandable-section [title]="'chapterEdit.objectivesStakesSectionTitle' | translate" icon="🎯" [initiallyOpen]="focusSection === 'stakes'" [filled]="objectivesStakesFilled">
|
||||
<div class="field-row">
|
||||
<div class="field">
|
||||
<label for="chapter-edit-player-objectives">{{ 'chapterEdit.playerObjectivesLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="chapter-edit-player-objectives">{{ 'chapterEdit.playerObjectivesLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="chapter.objectives"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="chapter-edit-player-objectives"
|
||||
formControlName="playerObjectives"
|
||||
@@ -105,7 +114,10 @@
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="chapter-edit-narrative-stakes">{{ 'chapterEdit.narrativeStakesLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="chapter-edit-narrative-stakes">{{ 'chapterEdit.narrativeStakesLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="chapter.stakes"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="chapter-edit-narrative-stakes"
|
||||
formControlName="narrativeStakes"
|
||||
|
||||
@@ -27,6 +27,8 @@ import { ConfirmDialogService } from '../../../shared/confirm-dialog/confirm-dia
|
||||
import { EntityAssistPanelComponent } from '../../../shared/entity-assist-panel/entity-assist-panel.component';
|
||||
import { FieldProposal } from '../../../services/entity-assist.model';
|
||||
import { SceneDraftPanelComponent } from '../../../shared/scene-draft-panel/scene-draft-panel.component';
|
||||
import { WritingCoachTriggerComponent } from '../../../shared/writing-coach/writing-coach-trigger.component';
|
||||
import { WritingReviewHintsComponent } from '../../../shared/writing-review/writing-review-hints.component';
|
||||
|
||||
/**
|
||||
* Écran d'édition d'un Chapitre. Donnée de SCÉNARIO uniquement.
|
||||
@@ -47,7 +49,8 @@ import { SceneDraftPanelComponent } from '../../../shared/scene-draft-panel/scen
|
||||
ExpandableSectionComponent,
|
||||
EntityAssistPanelComponent,
|
||||
SceneDraftPanelComponent,
|
||||
TranslatePipe
|
||||
TranslatePipe,
|
||||
WritingCoachTriggerComponent, WritingReviewHintsComponent
|
||||
],
|
||||
templateUrl: './chapter-edit.component.html',
|
||||
styleUrls: ['./chapter-edit.component.scss']
|
||||
@@ -88,6 +91,9 @@ export class ChapterEditComponent implements OnInit {
|
||||
/** `?assist=draft-scenes` (bouton « Corriger » du guidage) → panneau IA déployé d'office. */
|
||||
assistParam: string | null = null;
|
||||
|
||||
/** `?focus=stakes` (lien « Voir » de la relecture d'éditeur) → section dépliée d'office. */
|
||||
focusSection: string | null = null;
|
||||
|
||||
availablePages: Page[] = [];
|
||||
loreId: string | null = null;
|
||||
relatedPageIds: string[] = [];
|
||||
@@ -144,6 +150,7 @@ export class ChapterEditComponent implements OnInit {
|
||||
this.arcId = newArcId;
|
||||
this.chapterId = newChapterId;
|
||||
this.assistParam = this.route.snapshot.queryParamMap.get('assist');
|
||||
this.focusSection = this.route.snapshot.queryParamMap.get('focus');
|
||||
this.loadAll();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import { GuidedChapterSpec, GuidedSceneSpec } from '../../services/guided-skeleton.model';
|
||||
|
||||
/**
|
||||
* Définition d'une méthode guidée (Mentor d'écriture, phases M3/M5). L'assistant
|
||||
* `guided-wizard` est générique : il affiche les étapes d'une méthode et lui délègue
|
||||
* la construction du squelette. Ajouter une méthode = un fichier de définition + ses
|
||||
* textes i18n (`guided.<i18nKey>.*`) + son entrée dans `GUIDED_METHODS`.
|
||||
*
|
||||
* Conventions i18n (préfixe `guided.<i18nKey>.`) :
|
||||
* - `name`, `tagline` : présentation de la méthode ;
|
||||
* - `steps.<stepId>.title|why|example` : chaque étape (pourquoi + exemple, posture mentor) ;
|
||||
* - `fields.<fieldKey>.label|placeholder` : chaque champ (`fieldKey` peut contenir des points) ;
|
||||
* - `options.<fieldKey>.<option>` : libellés des choix ;
|
||||
* - `defaults.<fieldKey>` : valeur proposée d'office (ex. nom d'une salle).
|
||||
*/
|
||||
|
||||
/** Réponses du MJ, par clé de champ. */
|
||||
export type GuidedAnswers = Record<string, string>;
|
||||
|
||||
export interface GuidedField {
|
||||
key: string;
|
||||
kind: 'text' | 'textarea' | 'choice';
|
||||
required?: boolean;
|
||||
/** Valeurs possibles d'un champ `choice` (la 1re est sélectionnée par défaut). */
|
||||
options?: string[];
|
||||
/** Pré-remplir avec `defaults.<key>` (traduit) à la première visite. */
|
||||
prefilled?: boolean;
|
||||
/** Sujet du coach d'écriture (💡) associé, ex. `scene.choices`. */
|
||||
coachTopic?: string;
|
||||
}
|
||||
|
||||
export interface GuidedStep {
|
||||
id: string;
|
||||
/** `placement` : où ranger l'aventure ; `form` : questions ; `review` : récapitulatif. */
|
||||
kind: 'placement' | 'form' | 'review';
|
||||
fields?: GuidedField[];
|
||||
}
|
||||
|
||||
/** Ce que la méthode produit à partir des réponses (le placement est ajouté par l'assistant). */
|
||||
export interface GuidedDraft {
|
||||
chapter: GuidedChapterSpec;
|
||||
scenes: GuidedSceneSpec[];
|
||||
}
|
||||
|
||||
export interface GuidedMethod {
|
||||
/** Identifiant d'URL (`/campaigns/:id/guided/:method`). */
|
||||
id: string;
|
||||
/** Préfixe i18n sous `guided.`. */
|
||||
i18nKey: string;
|
||||
steps: GuidedStep[];
|
||||
toDraft(answers: GuidedAnswers): GuidedDraft;
|
||||
}
|
||||
|
||||
/** Valeur nettoyée d'une réponse (chaîne vide → null). */
|
||||
export function answer(answers: GuidedAnswers, key: string): string | null {
|
||||
const value = answers[key]?.trim();
|
||||
return value ? value : null;
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { GuidedField, GuidedStep } from './guided-method.model';
|
||||
import { GUIDED_METHODS } from './guided-methods';
|
||||
import { FIVE_ROOM_METHOD } from './methods/five-room.method';
|
||||
|
||||
/**
|
||||
* Garde-fous des méthodes guidées : chaque étape / champ / option / valeur par défaut
|
||||
* a son texte en fr ET en en (sinon l'assistant afficherait des clés brutes), et la
|
||||
* méthode « 5 salles » produit le bon squelette.
|
||||
*/
|
||||
const FRAGMENTS_DIR = join(process.cwd(), 'src/assets/i18n/fragments');
|
||||
|
||||
function i18n(lang: 'fr' | 'en'): Record<string, unknown> {
|
||||
return JSON.parse(readFileSync(join(FRAGMENTS_DIR, `guided.${lang}.json`), 'utf-8')).guided;
|
||||
}
|
||||
|
||||
function lookup(root: Record<string, unknown>, path: string): unknown {
|
||||
return path.split('.').reduce<unknown>((node, part) =>
|
||||
node && typeof node === 'object' ? (node as Record<string, unknown>)[part] : undefined, root);
|
||||
}
|
||||
|
||||
function fieldKeys(p: string, f: GuidedField): string[] {
|
||||
return [
|
||||
`${p}.fields.${f.key}.label`,
|
||||
...(f.kind === 'choice' ? [] : [`${p}.fields.${f.key}.placeholder`]),
|
||||
...(f.options ?? []).map(o => `${p}.options.${f.key}.${o}`),
|
||||
...(f.prefilled ? [`${p}.defaults.${f.key}`] : [])
|
||||
];
|
||||
}
|
||||
|
||||
function stepKeys(p: string, step: GuidedStep): string[] {
|
||||
return [
|
||||
`${p}.steps.${step.id}.title`,
|
||||
`${p}.steps.${step.id}.why`,
|
||||
...(step.kind === 'review' ? [] : [`${p}.steps.${step.id}.example`]),
|
||||
...(step.fields ?? []).flatMap(f => fieldKeys(p, f))
|
||||
];
|
||||
}
|
||||
|
||||
function requiredKeys(): string[] {
|
||||
return GUIDED_METHODS.flatMap(m => [`${m.i18nKey}.name`, ...m.steps.flatMap(s => stepKeys(m.i18nKey, s))]);
|
||||
}
|
||||
|
||||
describe('guided methods content', () => {
|
||||
const keys = requiredKeys();
|
||||
|
||||
for (const lang of ['fr', 'en'] as const) {
|
||||
it.each(keys)(`${lang}: guided.%s is a non-empty text`, key => {
|
||||
const value = lookup(i18n(lang), key);
|
||||
expect(typeof value === 'string' && value.trim().length > 0, `guided.${key} (${lang})`).toBe(true);
|
||||
});
|
||||
}
|
||||
|
||||
it('has unique method ids and step ids', () => {
|
||||
expect(new Set(GUIDED_METHODS.map(m => m.id)).size).toBe(GUIDED_METHODS.length);
|
||||
for (const m of GUIDED_METHODS) {
|
||||
expect(new Set(m.steps.map(s => s.id)).size).toBe(m.steps.length);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('five-room method', () => {
|
||||
const answers = {
|
||||
title: ' Le reliquaire volé ',
|
||||
location: 'La crypte',
|
||||
hook: 'Le prêtre a disparu',
|
||||
objectives: 'Ramener la relique',
|
||||
stakes: '',
|
||||
'room1.name': "L'entrée gardée",
|
||||
'room1.nature': 'social',
|
||||
'room1.choices': 'Convaincre ou ruser',
|
||||
'room2.name': "L'épreuve",
|
||||
'room2.nature': 'puzzle',
|
||||
'room3.name': 'Le revers',
|
||||
'room4.name': 'Le climax',
|
||||
'room4.enemies': "L'envoûteuse",
|
||||
'room5.name': 'La récompense',
|
||||
'room5.secret': 'Le symbole de la confrérie'
|
||||
};
|
||||
|
||||
it('builds the chapter from the frame and stakes answers', () => {
|
||||
expect(FIVE_ROOM_METHOD.toDraft(answers).chapter).toEqual({
|
||||
name: 'Le reliquaire volé',
|
||||
description: 'Le prêtre a disparu',
|
||||
playerObjectives: 'Ramener la relique',
|
||||
narrativeStakes: null
|
||||
});
|
||||
});
|
||||
|
||||
it('builds five typed scenes in the same place', () => {
|
||||
const scenes = FIVE_ROOM_METHOD.toDraft(answers).scenes;
|
||||
expect(scenes.map(s => s.type)).toEqual(['NPC', 'LOCATION', 'EVENT', 'ENCOUNTER', 'REVELATION']);
|
||||
expect(scenes.every(s => s.location === 'La crypte')).toBe(true);
|
||||
expect(scenes[0].choicesConsequences).toBe('Convaincre ou ruser');
|
||||
expect(scenes[3].enemies).toBe("L'envoûteuse");
|
||||
expect(scenes[4].gmSecretNotes).toBe('Le symbole de la confrérie');
|
||||
});
|
||||
|
||||
it('defaults room 1 to a fight when no nature was chosen', () => {
|
||||
expect(FIVE_ROOM_METHOD.toDraft({}).scenes[0].type).toBe('ENCOUNTER');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import { GuidedMethod } from './guided-method.model';
|
||||
import { FIVE_ROOM_METHOD } from './methods/five-room.method';
|
||||
|
||||
/** Méthodes guidées disponibles (M5 : préparation minimale, enquête, casse, bac à sable…). */
|
||||
export const GUIDED_METHODS: GuidedMethod[] = [FIVE_ROOM_METHOD];
|
||||
|
||||
export function findGuidedMethod(id: string | null): GuidedMethod | undefined {
|
||||
return GUIDED_METHODS.find(m => m.id === id);
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
@if (method && step) {
|
||||
<div class="wizard">
|
||||
|
||||
<header class="wizard-top">
|
||||
<a class="wizard-back" [routerLink]="['/campaigns', campaignId]">
|
||||
<lucide-icon [img]="ArrowLeft" [size]="14"></lucide-icon>
|
||||
{{ 'guided.backToCampaign' | translate }}
|
||||
</a>
|
||||
<div class="wizard-method">
|
||||
<lucide-icon [img]="Sparkles" [size]="14"></lucide-icon>
|
||||
{{ k('name') | translate }}
|
||||
</div>
|
||||
<div class="wizard-progress" role="progressbar"
|
||||
[attr.aria-valuenow]="stepIndex + 1" aria-valuemin="1" [attr.aria-valuemax]="total"
|
||||
[attr.aria-label]="'guided.progress' | translate: { n: stepIndex + 1, total: total }">
|
||||
<span class="progress-text">{{ 'guided.progress' | translate: { n: stepIndex + 1, total: total } }}</span>
|
||||
<span class="progress-track"><span class="progress-fill" [style.width.%]="progress"></span></span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="wizard-step">
|
||||
<h1 #stepTitle tabindex="-1">{{ k('steps.' + step.id + '.title') | translate }}</h1>
|
||||
<p class="step-why">{{ k('steps.' + step.id + '.why') | translate }}</p>
|
||||
|
||||
@if (step.kind !== 'review') {
|
||||
<aside class="step-example">
|
||||
<span class="example-label">{{ 'guided.exampleLabel' | translate }}</span>
|
||||
<p>{{ k('steps.' + step.id + '.example') | translate }}</p>
|
||||
</aside>
|
||||
}
|
||||
|
||||
<!-- Où ranger l'aventure -->
|
||||
@if (step.kind === 'placement') {
|
||||
<fieldset class="placement">
|
||||
<legend class="sr-only">{{ k('steps.placement.title') | translate }}</legend>
|
||||
@if (linearArcs.length > 0) {
|
||||
<label class="option-card" [class.selected]="answers['placement.mode'] === 'existing'">
|
||||
<input type="radio" name="placement-mode" value="existing"
|
||||
[ngModel]="answers['placement.mode']" (ngModelChange)="setAnswer('placement.mode', $event)" />
|
||||
<span>{{ 'guided.placementExisting' | translate }}</span>
|
||||
</label>
|
||||
@if (answers['placement.mode'] === 'existing') {
|
||||
<div class="field nested">
|
||||
<label for="guided-arc">{{ 'guided.placementArcLabel' | translate }}</label>
|
||||
<select id="guided-arc" [ngModel]="answers['placement.arcId']"
|
||||
(ngModelChange)="setAnswer('placement.arcId', $event)">
|
||||
@for (arc of linearArcs; track arc.id) {
|
||||
<option [value]="arc.id">{{ arc.name }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
<label class="option-card" [class.selected]="answers['placement.mode'] === 'new'">
|
||||
<input type="radio" name="placement-mode" value="new"
|
||||
[ngModel]="answers['placement.mode']" (ngModelChange)="setAnswer('placement.mode', $event)" />
|
||||
<span>{{ 'guided.placementNew' | translate }}</span>
|
||||
</label>
|
||||
@if (answers['placement.mode'] === 'new') {
|
||||
<div class="field nested">
|
||||
<label for="guided-new-arc">{{ 'guided.placementNewArcLabel' | translate }} *</label>
|
||||
<input id="guided-new-arc" type="text" [ngModel]="answers['placement.newArcName']"
|
||||
(ngModelChange)="setAnswer('placement.newArcName', $event)"
|
||||
[placeholder]="'guided.placementNewArcPlaceholder' | translate" />
|
||||
</div>
|
||||
}
|
||||
</fieldset>
|
||||
}
|
||||
|
||||
<!-- Questions de l'étape -->
|
||||
@if (step.kind === 'form') {
|
||||
<div class="step-fields">
|
||||
@for (field of step.fields; track field.key) {
|
||||
@if (field.kind === 'choice') {
|
||||
<fieldset class="field choice-field">
|
||||
<legend>{{ k('fields.' + field.key + '.label') | translate }}</legend>
|
||||
<div class="choice-row">
|
||||
@for (option of field.options; track option) {
|
||||
<label class="choice-chip" [class.selected]="answers[field.key] === option">
|
||||
<!-- attr.* : name/value doivent exister dans le DOM (groupe radio natif,
|
||||
navigation clavier) ; [value] seul est consommé par le ControlValueAccessor. -->
|
||||
<input type="radio" [attr.name]="fieldId(field)" [attr.value]="option" [value]="option"
|
||||
[ngModel]="answers[field.key]" (ngModelChange)="setAnswer(field.key, $event)" />
|
||||
{{ k('options.' + field.key + '.' + option) | translate }}
|
||||
</label>
|
||||
}
|
||||
</div>
|
||||
</fieldset>
|
||||
} @else {
|
||||
<div class="field">
|
||||
<div class="field-label-row">
|
||||
<label [for]="fieldId(field)">
|
||||
{{ k('fields.' + field.key + '.label') | translate }}@if (field.required) { * }
|
||||
</label>
|
||||
@if (field.coachTopic) {
|
||||
<app-writing-coach-trigger [topic]="field.coachTopic"></app-writing-coach-trigger>
|
||||
}
|
||||
</div>
|
||||
@if (field.kind === 'textarea') {
|
||||
<textarea [id]="fieldId(field)" rows="3"
|
||||
[ngModel]="answers[field.key]" (ngModelChange)="setAnswer(field.key, $event)"
|
||||
[placeholder]="k('fields.' + field.key + '.placeholder') | translate"></textarea>
|
||||
} @else {
|
||||
<input [id]="fieldId(field)" type="text"
|
||||
[ngModel]="answers[field.key]" (ngModelChange)="setAnswer(field.key, $event)"
|
||||
[placeholder]="k('fields.' + field.key + '.placeholder') | translate" />
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Récapitulatif -->
|
||||
@if (step.kind === 'review' && draft; as d) {
|
||||
<div class="review">
|
||||
<dl class="review-meta">
|
||||
<dt>{{ 'guided.reviewArc' | translate }}</dt>
|
||||
<dd>{{ placementLabel }}</dd>
|
||||
<dt>{{ 'guided.reviewChapter' | translate }}</dt>
|
||||
<dd>{{ d.chapter.name }}</dd>
|
||||
</dl>
|
||||
<ol class="review-scenes">
|
||||
@for (scene of d.scenes; track $index) {
|
||||
<li>
|
||||
<span class="scene-name">{{ scene.name }}</span>
|
||||
<span class="scene-type">{{ ('sceneType.' + scene.type) | translate }}</span>
|
||||
</li>
|
||||
}
|
||||
</ol>
|
||||
<label class="link-toggle">
|
||||
<input type="checkbox" [(ngModel)]="linkScenes" />
|
||||
{{ 'guided.linkScenes' | translate }}
|
||||
</label>
|
||||
<p class="review-after">{{ 'guided.reviewAfter' | translate }}</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (error) {
|
||||
<p class="wizard-error" role="alert">{{ error }}</p>
|
||||
}
|
||||
</main>
|
||||
|
||||
<footer class="wizard-nav">
|
||||
<button type="button" class="btn-secondary" (click)="previous()" [disabled]="stepIndex === 0">
|
||||
<lucide-icon [img]="ArrowLeft" [size]="14"></lucide-icon>
|
||||
{{ 'guided.previous' | translate }}
|
||||
</button>
|
||||
<button type="button" class="btn-ghost" (click)="restart()">
|
||||
<lucide-icon [img]="RotateCcw" [size]="14"></lucide-icon>
|
||||
{{ 'guided.restart' | translate }}
|
||||
</button>
|
||||
@if (isLast) {
|
||||
<button type="button" class="btn-primary" (click)="create()" [disabled]="submitting">
|
||||
<lucide-icon [img]="Check" [size]="14"></lucide-icon>
|
||||
{{ (submitting ? 'guided.creating' : 'guided.create') | translate }}
|
||||
</button>
|
||||
} @else {
|
||||
<button type="button" class="btn-primary" (click)="next()" [disabled]="!canProceed()">
|
||||
{{ 'guided.next' | translate }}
|
||||
<lucide-icon [img]="ArrowRight" [size]="14"></lucide-icon>
|
||||
</button>
|
||||
}
|
||||
</footer>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="wizard">
|
||||
<p class="wizard-error">{{ 'guided.unknownMethod' | translate }}</p>
|
||||
<a [routerLink]="['/campaigns', campaignId]">{{ 'guided.backToCampaign' | translate }}</a>
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
// Une étape par écran, colonne unique et étroite : lisible sur ordinateur comme
|
||||
// sur téléphone (la barre de navigation reste collée en bas de l'écran).
|
||||
.wizard {
|
||||
max-width: 680px;
|
||||
margin: 0 auto;
|
||||
padding: 1.5rem 0 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.wizard-top {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.6rem 1rem;
|
||||
}
|
||||
|
||||
.wizard-back {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
color: #9ca3af;
|
||||
font-size: 0.85rem;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover { color: #e5e7eb; }
|
||||
&:focus-visible { outline: 2px solid #6c63ff; outline-offset: 2px; border-radius: 4px; }
|
||||
}
|
||||
|
||||
.wizard-method {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
color: #fbbf24;
|
||||
font-size: 0.78rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.wizard-progress {
|
||||
flex-basis: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.progress-text {
|
||||
flex-shrink: 0;
|
||||
font-size: 0.8rem;
|
||||
color: #9ca3af;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.progress-track {
|
||||
flex: 1;
|
||||
height: 6px;
|
||||
border-radius: 999px;
|
||||
background: #1f2937;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: #6c63ff;
|
||||
border-radius: 999px;
|
||||
transition: width 0.25s ease;
|
||||
}
|
||||
|
||||
.wizard-step {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.1rem;
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
color: white;
|
||||
text-wrap: balance;
|
||||
|
||||
&:focus { outline: none; }
|
||||
}
|
||||
}
|
||||
|
||||
.step-why {
|
||||
margin: 0;
|
||||
font-size: 0.95rem;
|
||||
line-height: 1.6;
|
||||
color: #d1d5db;
|
||||
}
|
||||
|
||||
.step-example {
|
||||
padding: 0.85rem 1rem;
|
||||
border-radius: 8px;
|
||||
background: rgba(108, 99, 255, 0.08);
|
||||
border: 1px solid rgba(108, 99, 255, 0.25);
|
||||
|
||||
p {
|
||||
margin: 0.3rem 0 0;
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.55;
|
||||
font-style: italic;
|
||||
color: #d1d5db;
|
||||
}
|
||||
}
|
||||
|
||||
.example-label {
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: #a5b4fc;
|
||||
}
|
||||
|
||||
.step-fields {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.1rem;
|
||||
}
|
||||
|
||||
// --- Placement & choix ---------------------------------------------------------------
|
||||
|
||||
.placement {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.option-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.7rem;
|
||||
padding: 0.9rem 1rem;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #374151;
|
||||
background: #111827;
|
||||
color: #e5e7eb;
|
||||
font-size: 0.92rem;
|
||||
cursor: pointer;
|
||||
|
||||
&.selected { border-color: #6c63ff; background: rgba(108, 99, 255, 0.1); }
|
||||
input { accent-color: #6c63ff; width: 18px; height: 18px; margin: 0; }
|
||||
}
|
||||
|
||||
.nested {
|
||||
margin: 0 0 0.4rem 1.6rem;
|
||||
}
|
||||
|
||||
.choice-field {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: none;
|
||||
|
||||
legend {
|
||||
margin-bottom: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: #d1d5db;
|
||||
}
|
||||
}
|
||||
|
||||
.choice-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.choice-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
min-height: 44px;
|
||||
padding: 0 1rem;
|
||||
border-radius: 999px;
|
||||
border: 1px solid #374151;
|
||||
background: #111827;
|
||||
color: #d1d5db;
|
||||
font-size: 0.88rem;
|
||||
cursor: pointer;
|
||||
|
||||
&.selected { border-color: #6c63ff; color: white; background: rgba(108, 99, 255, 0.15); }
|
||||
input { accent-color: #6c63ff; margin: 0; }
|
||||
&:focus-within { outline: 2px solid #6c63ff; outline-offset: 2px; }
|
||||
}
|
||||
|
||||
// --- Récapitulatif --------------------------------------------------------------------
|
||||
|
||||
.review {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.review-meta {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 0.4rem 1rem;
|
||||
margin: 0;
|
||||
|
||||
dt { color: #9ca3af; font-size: 0.85rem; }
|
||||
dd { margin: 0; color: #f3f4f6; font-weight: 600; font-size: 0.9rem; overflow-wrap: anywhere; }
|
||||
}
|
||||
|
||||
.review-scenes {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
counter-reset: scene;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.45rem;
|
||||
|
||||
li {
|
||||
counter-increment: scene;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.7rem 0.9rem;
|
||||
border-radius: 8px;
|
||||
background: #111827;
|
||||
border: 1px solid #1f2937;
|
||||
|
||||
&::before {
|
||||
content: counter(scene);
|
||||
flex-shrink: 0;
|
||||
width: 1.6rem;
|
||||
height: 1.6rem;
|
||||
border-radius: 50%;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: #1f2937;
|
||||
color: #a5b4fc;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.scene-name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
color: #f3f4f6;
|
||||
font-size: 0.9rem;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.scene-type {
|
||||
flex-shrink: 0;
|
||||
padding: 0.1rem 0.55rem;
|
||||
border-radius: 999px;
|
||||
background: #1f2937;
|
||||
color: #9ca3af;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.link-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.6rem;
|
||||
color: #d1d5db;
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
|
||||
input { accent-color: #6c63ff; width: 18px; height: 18px; margin: 0; }
|
||||
}
|
||||
|
||||
.review-after {
|
||||
margin: 0;
|
||||
color: #9ca3af;
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.wizard-error {
|
||||
margin: 0;
|
||||
color: #fca5a5;
|
||||
font-size: 0.88rem;
|
||||
}
|
||||
|
||||
// --- Navigation -------------------------------------------------------------------------
|
||||
|
||||
.wizard-nav {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
margin-top: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem 0;
|
||||
background: #0a0a14;
|
||||
border-top: 1px solid #1f2937;
|
||||
|
||||
.btn-primary { margin-left: auto; }
|
||||
|
||||
button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.4rem;
|
||||
min-height: 44px;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-ghost {
|
||||
padding: 0.6rem 0.8rem;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
color: #9ca3af;
|
||||
font-size: 0.85rem;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover { color: #e5e7eb; background: #111827; }
|
||||
&:focus-visible { outline: 2px solid #6c63ff; }
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.wizard { padding-top: 1rem; }
|
||||
.wizard-step h1 { font-size: 1.3rem; }
|
||||
.wizard-nav {
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
|
||||
.btn-secondary,
|
||||
.btn-primary { flex: 1; padding-left: 0.75rem; padding-right: 0.75rem; }
|
||||
.btn-ghost { order: -1; flex-basis: 100%; justify-content: flex-start; padding-left: 0; }
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.progress-fill { transition: none; }
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
import { Component, DestroyRef, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
|
||||
import { LucideAngularModule, ArrowLeft, ArrowRight, Check, RotateCcw, Sparkles } from 'lucide-angular';
|
||||
|
||||
import { Arc } from '../../../services/campaign.model';
|
||||
import { CampaignService } from '../../../services/campaign.service';
|
||||
import { GuidedSkeletonService } from '../../../services/guided-skeleton.service';
|
||||
import { ConfirmDialogService } from '../../../shared/confirm-dialog/confirm-dialog.service';
|
||||
import { WritingCoachTriggerComponent } from '../../../shared/writing-coach/writing-coach-trigger.component';
|
||||
import { GuidedAnswers, GuidedDraft, GuidedField, GuidedMethod, GuidedStep, answer } from '../guided-method.model';
|
||||
import { findGuidedMethod } from '../guided-methods';
|
||||
|
||||
/** Clés de réponse réservées à l'assistant (placement + chaînage), communes à toutes les méthodes. */
|
||||
const PLACEMENT_MODE = 'placement.mode';
|
||||
const PLACEMENT_ARC = 'placement.arcId';
|
||||
const PLACEMENT_NEW_ARC = 'placement.newArcName';
|
||||
const LINK_SCENES = 'link';
|
||||
|
||||
/**
|
||||
* Assistant pas à pas d'une méthode guidée (Mentor d'écriture, phase M3) :
|
||||
* une étape par écran (lisible sur téléphone), chacune expliquée (pourquoi + exemple),
|
||||
* avec le coach 💡 sur les champs. Les réponses sont celles du MJ : rien n'est généré.
|
||||
* Le brouillon est gardé dans le navigateur pour pouvoir quitter et revenir.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-guided-wizard',
|
||||
imports: [FormsModule, RouterLink, TranslatePipe, LucideAngularModule, WritingCoachTriggerComponent],
|
||||
templateUrl: './guided-wizard.component.html',
|
||||
styleUrls: ['./guided-wizard.component.scss']
|
||||
})
|
||||
export class GuidedWizardComponent implements OnInit {
|
||||
readonly ArrowLeft = ArrowLeft;
|
||||
readonly ArrowRight = ArrowRight;
|
||||
readonly Check = Check;
|
||||
readonly RotateCcw = RotateCcw;
|
||||
readonly Sparkles = Sparkles;
|
||||
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
private readonly translate = inject(TranslateService);
|
||||
private readonly campaignService = inject(CampaignService);
|
||||
private readonly skeletonService = inject(GuidedSkeletonService);
|
||||
private readonly confirmDialog = inject(ConfirmDialogService);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
@ViewChild('stepTitle') stepTitle?: ElementRef<HTMLHeadingElement>;
|
||||
|
||||
campaignId = '';
|
||||
method: GuidedMethod | null = null;
|
||||
answers: GuidedAnswers = {};
|
||||
stepIndex = 0;
|
||||
/** Arcs linéaires de la campagne : seuls candidats pour y ranger l'aventure. */
|
||||
linearArcs: Arc[] = [];
|
||||
/** Le placement par défaut dépend des arcs : on attend leur chargement pour le choisir. */
|
||||
private arcsLoaded = false;
|
||||
submitting = false;
|
||||
error: string | null = null;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.paramMap.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(pm => {
|
||||
this.campaignId = pm.get('campaignId') ?? '';
|
||||
this.method = findGuidedMethod(pm.get('method')) ?? null;
|
||||
if (!this.method) return;
|
||||
this.restoreDraft();
|
||||
this.arcsLoaded = false;
|
||||
this.campaignService.getArcs(this.campaignId).subscribe(arcs => {
|
||||
this.linearArcs = arcs
|
||||
.filter(a => (a.type ?? 'LINEAR') === 'LINEAR')
|
||||
.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
||||
this.arcsLoaded = true;
|
||||
this.applyDefaults();
|
||||
});
|
||||
this.applyDefaults();
|
||||
});
|
||||
}
|
||||
|
||||
// --- Navigation ------------------------------------------------------------------
|
||||
|
||||
get step(): GuidedStep | null {
|
||||
return this.method?.steps[this.stepIndex] ?? null;
|
||||
}
|
||||
|
||||
get total(): number {
|
||||
return this.method?.steps.length ?? 0;
|
||||
}
|
||||
|
||||
get progress(): number {
|
||||
return this.total ? Math.round(((this.stepIndex + 1) / this.total) * 100) : 0;
|
||||
}
|
||||
|
||||
get isLast(): boolean {
|
||||
return this.stepIndex === this.total - 1;
|
||||
}
|
||||
|
||||
next(): void {
|
||||
if (!this.canProceed() || this.isLast) return;
|
||||
this.goTo(this.stepIndex + 1);
|
||||
}
|
||||
|
||||
previous(): void {
|
||||
if (this.stepIndex > 0) this.goTo(this.stepIndex - 1);
|
||||
}
|
||||
|
||||
private goTo(index: number): void {
|
||||
this.stepIndex = index;
|
||||
this.error = null;
|
||||
this.applyDefaults();
|
||||
this.saveDraft();
|
||||
// Nouvelle étape = nouvel écran : on remonte et on place le focus sur son titre.
|
||||
setTimeout(() => {
|
||||
this.stepTitle?.nativeElement.focus();
|
||||
this.stepTitle?.nativeElement.scrollIntoView({ block: 'start' });
|
||||
});
|
||||
}
|
||||
|
||||
canProceed(): boolean {
|
||||
const step = this.step;
|
||||
if (!step) return false;
|
||||
if (step.kind === 'placement') {
|
||||
return this.answers[PLACEMENT_MODE] === 'existing'
|
||||
? !!this.answers[PLACEMENT_ARC]
|
||||
: !!answer(this.answers, PLACEMENT_NEW_ARC);
|
||||
}
|
||||
return (step.fields ?? []).every(f => !f.required || !!answer(this.answers, f.key));
|
||||
}
|
||||
|
||||
// --- Réponses ----------------------------------------------------------------------
|
||||
|
||||
/** Clé i18n de la méthode courante. */
|
||||
k(path: string): string {
|
||||
return `guided.${this.method?.i18nKey}.${path}`;
|
||||
}
|
||||
|
||||
fieldId(field: GuidedField): string {
|
||||
return `guided-${field.key.replace(/\./g, '-')}`;
|
||||
}
|
||||
|
||||
setAnswer(key: string, value: string): void {
|
||||
this.answers = { ...this.answers, [key]: value };
|
||||
this.saveDraft();
|
||||
}
|
||||
|
||||
/** Placement par défaut + valeurs pré-remplies + premier choix des champs `choice`. */
|
||||
private applyDefaults(): void {
|
||||
const a = { ...this.answers };
|
||||
if (this.arcsLoaded) this.applyPlacementDefaults(a);
|
||||
a[LINK_SCENES] ??= 'true';
|
||||
for (const field of this.step?.fields ?? []) {
|
||||
if (a[field.key] !== undefined) continue;
|
||||
if (field.kind === 'choice' && field.options?.length) a[field.key] = field.options[0];
|
||||
else if (field.prefilled) a[field.key] = this.translate.instant(this.k(`defaults.${field.key}`));
|
||||
}
|
||||
this.answers = a;
|
||||
}
|
||||
|
||||
/** Arc existant par défaut s'il y en a ; sinon (ou arc disparu) nouvel arc. */
|
||||
private applyPlacementDefaults(a: GuidedAnswers): void {
|
||||
a[PLACEMENT_MODE] ??= this.linearArcs.length > 0 ? 'existing' : 'new';
|
||||
if (a[PLACEMENT_MODE] === 'existing' && !this.linearArcs.some(arc => arc.id === a[PLACEMENT_ARC])) {
|
||||
a[PLACEMENT_ARC] = this.linearArcs[0]?.id ?? '';
|
||||
if (!a[PLACEMENT_ARC]) a[PLACEMENT_MODE] = 'new';
|
||||
}
|
||||
}
|
||||
|
||||
// --- Récapitulatif & création --------------------------------------------------------
|
||||
|
||||
get draft(): GuidedDraft | null {
|
||||
return this.method ? this.method.toDraft(this.answers) : null;
|
||||
}
|
||||
|
||||
get placementLabel(): string {
|
||||
if (this.answers[PLACEMENT_MODE] === 'existing') {
|
||||
return this.linearArcs.find(a => a.id === this.answers[PLACEMENT_ARC])?.name ?? '';
|
||||
}
|
||||
return answer(this.answers, PLACEMENT_NEW_ARC) ?? '';
|
||||
}
|
||||
|
||||
get linkScenes(): boolean {
|
||||
return this.answers[LINK_SCENES] !== 'false';
|
||||
}
|
||||
|
||||
set linkScenes(value: boolean) {
|
||||
this.setAnswer(LINK_SCENES, String(value));
|
||||
}
|
||||
|
||||
create(): void {
|
||||
const draft = this.draft;
|
||||
if (!draft || this.submitting) return;
|
||||
const existing = this.answers[PLACEMENT_MODE] === 'existing';
|
||||
this.submitting = true;
|
||||
this.error = null;
|
||||
this.skeletonService.create(this.campaignId, {
|
||||
arcId: existing ? this.answers[PLACEMENT_ARC] : null,
|
||||
newArcName: existing ? null : answer(this.answers, PLACEMENT_NEW_ARC),
|
||||
chapter: draft.chapter,
|
||||
scenes: draft.scenes,
|
||||
linkSequentially: this.linkScenes,
|
||||
linkLabel: this.translate.instant('guided.linkLabel')
|
||||
}).subscribe({
|
||||
next: result => {
|
||||
this.clearDraft();
|
||||
this.router.navigate(['/campaigns', this.campaignId, 'arcs', result.arcId, 'chapters', result.chapterId]);
|
||||
},
|
||||
error: () => {
|
||||
this.submitting = false;
|
||||
this.error = this.translate.instant('guided.createError');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async restart(): Promise<void> {
|
||||
const ok = await this.confirmDialog.confirm({
|
||||
title: this.translate.instant('guided.restartTitle'),
|
||||
message: this.translate.instant('guided.restartMessage'),
|
||||
confirmLabel: this.translate.instant('guided.restart')
|
||||
});
|
||||
if (!ok) return;
|
||||
this.clearDraft();
|
||||
this.answers = {};
|
||||
this.goTo(0);
|
||||
}
|
||||
|
||||
// --- Brouillon (confort par navigateur : jamais indispensable) -------------------------
|
||||
|
||||
private get storageKey(): string {
|
||||
return `loremind.guided.${this.campaignId}.${this.method?.id}`;
|
||||
}
|
||||
|
||||
private restoreDraft(): void {
|
||||
this.answers = {};
|
||||
this.stepIndex = 0;
|
||||
try {
|
||||
const raw = localStorage.getItem(this.storageKey);
|
||||
if (!raw) return;
|
||||
const saved = JSON.parse(raw) as { answers?: GuidedAnswers; step?: number };
|
||||
this.answers = saved.answers ?? {};
|
||||
this.stepIndex = Math.min(Math.max(saved.step ?? 0, 0), this.total - 1);
|
||||
} catch { /* brouillon illisible ou stockage bloqué : on repart de zéro */ }
|
||||
}
|
||||
|
||||
private saveDraft(): void {
|
||||
try {
|
||||
localStorage.setItem(this.storageKey, JSON.stringify({ answers: this.answers, step: this.stepIndex }));
|
||||
} catch { /* stockage indisponible : le brouillon n'est simplement pas gardé */ }
|
||||
}
|
||||
|
||||
private clearDraft(): void {
|
||||
try {
|
||||
localStorage.removeItem(this.storageKey);
|
||||
} catch { /* rien à nettoyer */ }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import { SceneType } from '../../../services/campaign.model';
|
||||
import { GuidedSceneSpec } from '../../../services/guided-skeleton.model';
|
||||
import { GuidedAnswers, GuidedField, GuidedMethod, answer } from '../guided-method.model';
|
||||
|
||||
/**
|
||||
* « Donjon en 5 salles » (méthode popularisée par Johnn Four ; textes écrits pour
|
||||
* LoreMind). Une aventure courte en cinq temps : un gardien à l'entrée, une épreuve
|
||||
* qui ne se règle pas à l'épée, un revers, le climax, puis la récompense ou la
|
||||
* révélation. Le « donjon » peut être n'importe quel lieu : manoir, navire, forêt…
|
||||
*
|
||||
* Produit 1 chapitre (accroche, objectifs, enjeux) + 5 scènes typées dans le même lieu.
|
||||
*/
|
||||
|
||||
/** Champs communs à chaque salle : nom (pré-rempli), ce qui s'y passe, choix, secret du MJ. */
|
||||
function roomFields(room: number, extra: GuidedField[] = []): GuidedField[] {
|
||||
return [
|
||||
{ key: `room${room}.name`, kind: 'text', required: true, prefilled: true },
|
||||
...extra.filter(f => f.kind === 'choice'),
|
||||
{ key: `room${room}.description`, kind: 'textarea', coachTopic: 'scene.description' },
|
||||
...extra.filter(f => f.kind !== 'choice'),
|
||||
{ key: `room${room}.choices`, kind: 'textarea', coachTopic: 'scene.choices' },
|
||||
{ key: `room${room}.secret`, kind: 'textarea', coachTopic: 'scene.gmNotes' }
|
||||
];
|
||||
}
|
||||
|
||||
/** Nature de la salle (choix du MJ) → type de scène, pour que la relecture juge le rythme. */
|
||||
const NATURE_TO_TYPE: Record<string, SceneType> = {
|
||||
combat: 'ENCOUNTER',
|
||||
social: 'NPC',
|
||||
obstacle: 'LOCATION',
|
||||
puzzle: 'LOCATION',
|
||||
exploration: 'LOCATION'
|
||||
};
|
||||
|
||||
export const FIVE_ROOM_METHOD: GuidedMethod = {
|
||||
id: 'five-room',
|
||||
i18nKey: 'fiveRoom',
|
||||
steps: [
|
||||
{ id: 'placement', kind: 'placement' },
|
||||
{
|
||||
id: 'frame', kind: 'form', fields: [
|
||||
{ key: 'title', kind: 'text', required: true },
|
||||
{ key: 'location', kind: 'text', coachTopic: 'scene.setting' },
|
||||
{ key: 'hook', kind: 'textarea', coachTopic: 'chapter.synopsis' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'stakes', kind: 'form', fields: [
|
||||
{ key: 'objectives', kind: 'textarea', coachTopic: 'chapter.objectives' },
|
||||
{ key: 'stakes', kind: 'textarea', coachTopic: 'chapter.stakes' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'room1', kind: 'form', fields: roomFields(1, [
|
||||
{ key: 'room1.nature', kind: 'choice', options: ['combat', 'social', 'obstacle'] },
|
||||
{ key: 'room1.enemies', kind: 'text' }
|
||||
])
|
||||
},
|
||||
{
|
||||
id: 'room2', kind: 'form', fields: roomFields(2, [
|
||||
{ key: 'room2.nature', kind: 'choice', options: ['puzzle', 'social', 'exploration'] }
|
||||
])
|
||||
},
|
||||
{ id: 'room3', kind: 'form', fields: roomFields(3) },
|
||||
{
|
||||
id: 'room4', kind: 'form', fields: roomFields(4, [
|
||||
{ key: 'room4.enemies', kind: 'text', coachTopic: 'scene.combat' }
|
||||
])
|
||||
},
|
||||
{ id: 'room5', kind: 'form', fields: roomFields(5) },
|
||||
{ id: 'review', kind: 'review' }
|
||||
],
|
||||
|
||||
toDraft(answers: GuidedAnswers) {
|
||||
const location = answer(answers, 'location');
|
||||
const room = (n: number, type: SceneType): GuidedSceneSpec => ({
|
||||
name: answer(answers, `room${n}.name`) ?? '',
|
||||
description: answer(answers, `room${n}.description`),
|
||||
type,
|
||||
location,
|
||||
choicesConsequences: answer(answers, `room${n}.choices`),
|
||||
gmSecretNotes: answer(answers, `room${n}.secret`),
|
||||
enemies: answer(answers, `room${n}.enemies`)
|
||||
});
|
||||
return {
|
||||
chapter: {
|
||||
name: answer(answers, 'title') ?? '',
|
||||
description: answer(answers, 'hook'),
|
||||
playerObjectives: answer(answers, 'objectives'),
|
||||
narrativeStakes: answer(answers, 'stakes')
|
||||
},
|
||||
scenes: [
|
||||
room(1, NATURE_TO_TYPE[answers['room1.nature']] ?? 'ENCOUNTER'),
|
||||
room(2, NATURE_TO_TYPE[answers['room2.nature']] ?? 'LOCATION'),
|
||||
room(3, 'EVENT'),
|
||||
room(4, 'ENCOUNTER'),
|
||||
room(5, 'REVELATION')
|
||||
]
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -30,6 +30,9 @@
|
||||
est dans des sections repliables avec pastille « rempli ». -->
|
||||
<p class="optional-hint">{{ 'sceneEdit.optionalHint' | translate }}</p>
|
||||
|
||||
<!-- Mentor d'écriture (M2) : conseils de relecture qui concernent cette entité. -->
|
||||
<app-writing-review-hints [campaignId]="campaignId" entityType="SCENE" [entityId]="sceneId"></app-writing-review-hints>
|
||||
|
||||
<!-- Co-création (Pilier A) : le co-MJ propose, l'utilisateur valide champ par champ.
|
||||
Les champs retenus remplissent le formulaire ; rien n'est enregistré avant la sauvegarde. -->
|
||||
<app-entity-assist-panel
|
||||
@@ -49,7 +52,10 @@
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="scene-edit-description">{{ 'sceneEdit.descriptionLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="scene-edit-description">{{ 'sceneEdit.descriptionLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="scene.description"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="scene-edit-description"
|
||||
formControlName="description"
|
||||
@@ -65,7 +71,10 @@
|
||||
|
||||
<!-- Type narratif du nœud (Niveau 2 — graphe de nœuds typés) -->
|
||||
<div class="field">
|
||||
<label for="scene-edit-type">{{ 'sceneEdit.nodeTypeLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="scene-edit-type">{{ 'sceneEdit.nodeTypeLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="scene.nodeType"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<select id="scene-edit-type" formControlName="type">
|
||||
@for (opt of sceneTypeOptions; track opt) {
|
||||
<option [value]="opt">{{ 'sceneType.' + opt | translate }}</option>
|
||||
@@ -181,7 +190,10 @@
|
||||
<app-expandable-section [title]="'sceneEdit.contextSectionTitle' | translate" icon="📍" [initiallyOpen]="true" [filled]="contextFilled">
|
||||
<div class="field-row">
|
||||
<div class="field">
|
||||
<label for="scene-edit-location">{{ 'sceneEdit.locationLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="scene-edit-location">{{ 'sceneEdit.locationLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="scene.setting"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<input id="scene-edit-location" type="text" formControlName="location" [placeholder]="'sceneEdit.locationPlaceholder' | translate" />
|
||||
</div>
|
||||
<div class="field">
|
||||
@@ -190,7 +202,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="scene-edit-atmosphere">{{ 'sceneEdit.atmosphereLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="scene-edit-atmosphere">{{ 'sceneEdit.atmosphereLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="scene.atmosphere"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="scene-edit-atmosphere"
|
||||
formControlName="atmosphere"
|
||||
@@ -201,7 +216,7 @@
|
||||
</app-expandable-section>
|
||||
|
||||
<!-- Section : Narration pour les joueurs -->
|
||||
<app-expandable-section [title]="'sceneEdit.narrationSectionTitle' | translate" icon="📖" [filled]="narrationFilled">
|
||||
<app-expandable-section [title]="'sceneEdit.narrationSectionTitle' | translate" coachTopic="scene.narration" icon="📖" [initiallyOpen]="focusSection === 'narration'" [filled]="narrationFilled">
|
||||
<div class="field">
|
||||
<textarea
|
||||
formControlName="playerNarration"
|
||||
@@ -213,7 +228,7 @@
|
||||
</app-expandable-section>
|
||||
|
||||
<!-- Section : Notes et secrets du MJ (privé) -->
|
||||
<app-expandable-section [title]="'sceneEdit.gmNotesSectionTitle' | translate" icon="🔒" variant="private" [filled]="gmNotesFilled">
|
||||
<app-expandable-section [title]="'sceneEdit.gmNotesSectionTitle' | translate" coachTopic="scene.gmNotes" icon="🔒" variant="private" [filled]="gmNotesFilled">
|
||||
<div class="field">
|
||||
<textarea
|
||||
formControlName="gmSecretNotes"
|
||||
@@ -225,7 +240,7 @@
|
||||
</app-expandable-section>
|
||||
|
||||
<!-- Section : Choix et conséquences -->
|
||||
<app-expandable-section [title]="'sceneEdit.choicesSectionTitle' | translate" icon="🔀" [filled]="choicesFilled">
|
||||
<app-expandable-section [title]="'sceneEdit.choicesSectionTitle' | translate" coachTopic="scene.choices" icon="🔀" [initiallyOpen]="focusSection === 'choices'" [filled]="choicesFilled">
|
||||
<div class="field">
|
||||
<textarea
|
||||
formControlName="choicesConsequences"
|
||||
@@ -236,7 +251,7 @@
|
||||
</app-expandable-section>
|
||||
|
||||
<!-- Section : Branches narratives (graphe intra-chapitre) -->
|
||||
<app-expandable-section [title]="'sceneEdit.branchesSectionTitle' | translate" icon="🌿" [initiallyOpen]="focusSection === 'branches'" [filled]="branchesFilled">
|
||||
<app-expandable-section [title]="'sceneEdit.branchesSectionTitle' | translate" coachTopic="scene.branches" icon="🌿" [initiallyOpen]="focusSection === 'branches'" [filled]="branchesFilled">
|
||||
@if (siblingScenes.length === 0) {
|
||||
<div class="branches-hint">
|
||||
<small class="field-hint">
|
||||
@@ -307,7 +322,7 @@
|
||||
</app-expandable-section>
|
||||
|
||||
<!-- Section : Combat ou rencontre -->
|
||||
<app-expandable-section [title]="'sceneEdit.combatSectionTitle' | translate" icon="⚔️" [initiallyOpen]="focusSection === 'combat'" [filled]="combatFilled">
|
||||
<app-expandable-section [title]="'sceneEdit.combatSectionTitle' | translate" coachTopic="scene.combat" icon="⚔️" [initiallyOpen]="focusSection === 'combat'" [filled]="combatFilled">
|
||||
<div class="field">
|
||||
<label for="scene-edit-combat-difficulty">{{ 'sceneEdit.combatDifficultyLabel' | translate }}</label>
|
||||
<input id="scene-edit-combat-difficulty" type="text" formControlName="combatDifficulty" [placeholder]="'sceneEdit.combatDifficultyPlaceholder' | translate" />
|
||||
|
||||
@@ -31,6 +31,8 @@ import { FieldProposal } from '../../../services/entity-assist.model';
|
||||
import { FileDropDirective } from '../../../shared/file-drop.directive';
|
||||
import { CAMPAIGN_ICON_OPTIONS } from '../../campaign-icons';
|
||||
import { ConfirmDialogService } from '../../../shared/confirm-dialog/confirm-dialog.service';
|
||||
import { WritingCoachTriggerComponent } from '../../../shared/writing-coach/writing-coach-trigger.component';
|
||||
import { WritingReviewHintsComponent } from '../../../shared/writing-review/writing-review-hints.component';
|
||||
|
||||
/**
|
||||
* État d'édition d'UNE battlemap de la scène (une carte par variante : Jour, Nuit,
|
||||
@@ -63,7 +65,7 @@ interface BattlemapEdit {
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-scene-edit',
|
||||
imports: [ReactiveFormsModule, LucideAngularModule, ExpandableSectionComponent, LoreLinkPickerComponent, EnemyLinkPickerComponent, AiChatDrawerComponent, ImageGalleryComponent, IconPickerComponent, RoomsEditorComponent, EntityAssistPanelComponent, FileDropDirective, TranslatePipe],
|
||||
imports: [ReactiveFormsModule, LucideAngularModule, ExpandableSectionComponent, LoreLinkPickerComponent, EnemyLinkPickerComponent, AiChatDrawerComponent, ImageGalleryComponent, IconPickerComponent, RoomsEditorComponent, EntityAssistPanelComponent, FileDropDirective, TranslatePipe, WritingCoachTriggerComponent, WritingReviewHintsComponent],
|
||||
templateUrl: './scene-edit.component.html',
|
||||
styleUrls: ['./scene-edit.component.scss']
|
||||
})
|
||||
@@ -95,7 +97,7 @@ export class SceneEditComponent implements OnInit {
|
||||
scene: Scene | null = null;
|
||||
|
||||
/**
|
||||
* Section à déplier d'office (query param `?focus=combat|branches|rooms`) — posé par
|
||||
* Section à déplier d'office (query param `?focus=combat|branches|rooms|narration|choices`) — posé par
|
||||
* le bouton « Corriger » du guidage pour atterrir directement sur l'outil fautif.
|
||||
*/
|
||||
focusSection: string | null = null;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { WritingRemark } from '../services/writing-review.model';
|
||||
import { GapAction } from './gap-action.helper';
|
||||
|
||||
/**
|
||||
* Lien « Voir » d'une remarque de relecture : ouvre l'éditeur concerné avec la
|
||||
* section en cause dépliée (`?focus=…`), comme le « Corriger » du readiness.
|
||||
*/
|
||||
export function remarkAction(remark: WritingRemark, campaignId: string): GapAction {
|
||||
const base = ['/campaigns', campaignId];
|
||||
const focus = FOCUS_BY_RULE[remark.ruleId];
|
||||
const queryParams = focus ? { focus } : undefined;
|
||||
switch (remark.entityType) {
|
||||
case 'SCENE':
|
||||
return {
|
||||
link: [...base, 'arcs', remark.arcId ?? '', 'chapters', remark.chapterId ?? '', 'scenes', remark.entityId, 'edit'],
|
||||
queryParams
|
||||
};
|
||||
case 'CHAPTER':
|
||||
// Couloir / rythme : c'est l'enchaînement des scènes qu'il faut voir (vue du chapitre).
|
||||
if (!focus) return { link: [...base, 'arcs', remark.arcId ?? '', 'chapters', remark.entityId] };
|
||||
return { link: [...base, 'arcs', remark.arcId ?? '', 'chapters', remark.entityId, 'edit'], queryParams };
|
||||
case 'ARC':
|
||||
return { link: [...base, 'arcs', remark.entityId, 'edit'], queryParams };
|
||||
default:
|
||||
return { link: base };
|
||||
}
|
||||
}
|
||||
|
||||
/** Section de l'éditeur à déplier selon la règle (clé = ruleId complet). */
|
||||
const FOCUS_BY_RULE: Record<string, string> = {
|
||||
'WRITE-002-FAKE-CHOICE': 'branches',
|
||||
'WRITE-003-SINGLE-CLUE': 'branches',
|
||||
'WRITE-005-NO-STAKES': 'stakes',
|
||||
'WRITE-006-LONG-NARRATION': 'narration',
|
||||
'WRITE-007-NARRATION-DECIDES': 'narration',
|
||||
'WRITE-008-COMBAT-NO-PURPOSE': 'combat',
|
||||
'WRITE-009-SINGLE-ENDING': 'choices'
|
||||
};
|
||||
Reference in New Issue
Block a user