Files
LoreMind/web/src/app/campaigns/chapter/chapter-create/chapter-create.component.ts
T
ietm64 6c1d74f9a5 Bêta 1.7.0 : catalogue de sorts, entraînement aux règles, fiches tirées des règles
Systèmes de jeu
- Édition d'un système en onglets : Présentation, Règles, Structure des fiches, Sorts ;
  recherche dans les règles, sections repliées, enregistrement toujours visible.
- Catalogue de sorts (V32) : un sort par fiche, champs propres au système, recherche et
  filtres par niveau et par école ; inclus dans l'export et l'import du contenu.
- Proposition de sorts à partir des règles : lecture morceau par morceau, un sort n'est
  proposé que si son nom et un passage cité se retrouvent dans le texte.
- Sorts connus des fiches PJ, PNJ et ennemi (V33, table à part) et onglet Sorts du mode
  séance.
- Proposition des champs d'une fiche (PJ, PNJ, ennemi) à partir des règles.

Campagnes
- Entraînement aux règles : situations tirées des scènes, corrigé qui cite les règles ;
  sections et citations dans la langue de l'interface.
- Fiches de campagne en noyau + rubriques (scène, arc, aventure, quête annexe).
- Vocabulaire : aventure, ordre libre, quête annexe.
- Méthode guidée mémorisée sur l'aventure (V30).

Livret PDF
- Thème « Parchemin », placement des illustrations (V31), renvois vers les PNJ.

Bureau et IA
- Journal du Brain (logs/brain.log) et erreurs de l'IA mieux rapportées.

Passage à la 1.7.0-beta.
2026-11-13 01:13:44 +01:00

99 lines
4.0 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { ReactiveFormsModule, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
import { forkJoin } from 'rxjs';
import { LucideAngularModule, ArrowRight, Sparkles } from 'lucide-angular';
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
import { CampaignService } from '../../../services/campaign.service';
import { NpcService } from '../../../services/npc.service';
import { RandomTableService } from '../../../services/random-table.service';
import { EnemyService } from '../../../services/enemy.service';
import { LayoutService } from '../../../services/layout.service';
import { loadCampaignTreeData, buildCampaignSidebarConfig } from '../../campaign-tree.helper';
import { implicitArc } from '../../flat-structure';
import { IconPickerComponent } from '../../../shared/icon-picker/icon-picker.component';
import { CAMPAIGN_ICON_OPTIONS } from '../../campaign-icons';
/**
* Écran de création d'un nouveau chapitre rattaché à un arc.
* Route : /campaigns/:campaignId/arcs/:arcId/chapters/create
*/
@Component({
selector: 'app-chapter-create',
imports: [ReactiveFormsModule, RouterLink, LucideAngularModule, IconPickerComponent, TranslatePipe],
templateUrl: './chapter-create.component.html',
styleUrls: ['./chapter-create.component.scss']
})
export class ChapterCreateComponent implements OnInit {
readonly campaignIconOptions = CAMPAIGN_ICON_OPTIONS;
readonly ArrowRight = ArrowRight;
readonly Sparkles = Sparkles;
/** Les méthodes guidées rangent leur chapitre dans un arc linéaire : proposées seulement là. */
arcIsLinear = false;
selectedIcon: string | null = null;
form: FormGroup;
campaignId = '';
arcId = '';
arcName = '';
private existingChapterCount = 0;
constructor(
private fb: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private campaignService: CampaignService,
private npcService: NpcService,
private randomTableService: RandomTableService,
private enemyService: EnemyService,
private layoutService: LayoutService,
private translate: TranslateService
) {
this.form = this.fb.group({
name: ['', Validators.required],
description: ['']
});
}
ngOnInit(): void {
this.campaignId = this.route.snapshot.paramMap.get('campaignId')!;
this.arcId = this.route.snapshot.paramMap.get('arcId')!;
this.loadLayout();
}
private loadLayout(): void {
forkJoin({
campaign: this.campaignService.getCampaignById(this.campaignId),
allCampaigns: this.campaignService.getAllCampaigns(),
treeData: loadCampaignTreeData(this.campaignService, this.campaignId, this.npcService, this.randomTableService, this.enemyService)
}).subscribe(({ campaign, allCampaigns, treeData }) => {
const currentArc = treeData.arcs.find(a => a.id === this.arcId);
// Arc créé d'office : on ne le cite pas, l'auteur ne l'a jamais vu.
this.arcName = implicitArc(treeData.arcs)?.id === this.arcId ? '' : currentArc?.name ?? '';
this.arcIsLinear = !!currentArc && (currentArc.type ?? 'LINEAR') === 'LINEAR';
this.existingChapterCount = treeData.chaptersByArc[this.arcId]?.length ?? 0;
this.layoutService.show(buildCampaignSidebarConfig(campaign, allCampaigns, treeData, this.campaignId, this.translate));
});
}
submit(): void {
if (this.form.invalid) return;
this.campaignService.createChapter({
name: this.form.value.name,
description: this.form.value.description,
arcId: this.arcId,
order: this.existingChapterCount + 1,
icon: this.selectedIcon
}).subscribe({
next: (created) => this.router.navigate(['/campaigns', this.campaignId, 'arcs', this.arcId, 'chapters', created.id]),
error: () => console.error('Erreur lors de la création du chapitre')
});
}
cancel(): void {
this.router.navigate(['/campaigns', this.campaignId]);
}
}