Livret PDF (export campagne) :
- refonte lisibilité façon livre de JdR : sommaire paginé, libellés de champs
en tête de ligne, encadrés « À lire aux joueurs » / secrets MJ / combat,
ligne de contexte des scènes, en-tête courant, tables zébrées
- reflète la fusion quête/conteneur : arc SYSTEM masqué, quêtes de hub
fusionnées dans leur chapitre, partie « Quêtes » sans doublon
- contenu complété : sorties de scènes, ennemis liés au bestiaire, pièces
explorables, partie « Tables aléatoires »
- polices DejaVu embarquées (couverture Unicode, licence incluse) et harness
visuel PdfExportPreviewTest (Mockito pur, tourne sans Postgres)
Graphe des liens :
- déplacé du Lore vers la campagne (les PNJ sont des entités de campagne) ;
endpoint /api/npcs/lore/{id} supprimé
- layout retravaillé (anti-chevauchement des libellés, éventail des feuilles
autour des hubs), scènes et quêtes ajoutées, libellés sur 2 lignes,
filtres de légende mémorisés, focus au survol
- positions drag & drop persistées sur la campagne (migration V23,
PUT /api/campaigns/{id}/graph-positions, bouton « Disposition auto »)
Divers :
- ImportService découpé en classes dédiées (parser d'archive, remapper d'ids,
inserters campagne/lore/état de jeu, conversion legacy des quêtes)
- fuites d'abonnements corrigées (takeUntilDestroyed sur paramMap) sur ~15 écrans
- garde-fou i18n fragments/consolidés branché sur npm run build (check-i18n.mjs),
budget SCSS anyComponentStyle relevé à 12 ko
95 lines
3.1 KiB
TypeScript
95 lines
3.1 KiB
TypeScript
import { Component, OnInit, DestroyRef } from '@angular/core';
|
||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||
|
||
import { ActivatedRoute, Router } from '@angular/router';
|
||
import { LucideAngularModule, ArrowLeft, Edit3, Dices } from 'lucide-angular';
|
||
import { TranslatePipe } from '@ngx-translate/core';
|
||
import { RandomTableService } from '../../../services/random-table.service';
|
||
import { CampaignSidebarService } from '../../../services/campaign-sidebar.service';
|
||
import { RandomTable, RandomTableEntry } from '../../../services/random-table.model';
|
||
import { DiceUtils, DiceRoll } from '../../../shared/dice.utils';
|
||
|
||
/**
|
||
* Vue d'une table aléatoire : affiche les entrées et permet de LANCER le dé
|
||
* (jet côté client) → surligne l'entrée tombée + montre son détail.
|
||
* Route : /campaigns/:campaignId/random-tables/:tableId
|
||
*/
|
||
@Component({
|
||
selector: 'app-random-table-view',
|
||
imports: [LucideAngularModule, TranslatePipe],
|
||
templateUrl: './random-table-view.component.html',
|
||
styleUrls: ['./random-table-view.component.scss']
|
||
})
|
||
export class RandomTableViewComponent implements OnInit {
|
||
readonly ArrowLeft = ArrowLeft;
|
||
readonly Edit3 = Edit3;
|
||
readonly Dices = Dices;
|
||
|
||
campaignId: string | null = null;
|
||
tableId: string | null = null;
|
||
table: RandomTable | null = null;
|
||
|
||
lastRoll: DiceRoll | null = null;
|
||
matched: RandomTableEntry | null = null;
|
||
|
||
constructor(
|
||
private route: ActivatedRoute,
|
||
private router: Router,
|
||
private service: RandomTableService,
|
||
private campaignSidebar: CampaignSidebarService,
|
||
private destroyRef: DestroyRef
|
||
) {}
|
||
|
||
ngOnInit(): void {
|
||
this.route.paramMap.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(pm => {
|
||
const newCampaignId = pm.get('campaignId');
|
||
const newTableId = pm.get('tableId');
|
||
if (newCampaignId === this.campaignId && newTableId === this.tableId) return;
|
||
this.campaignId = newCampaignId;
|
||
this.tableId = newTableId;
|
||
this.table = null;
|
||
this.lastRoll = null;
|
||
this.matched = null;
|
||
if (this.tableId) {
|
||
this.service.getById(this.tableId).subscribe({
|
||
next: t => this.table = t,
|
||
error: () => this.back()
|
||
});
|
||
}
|
||
if (this.campaignId) {
|
||
this.campaignSidebar.show(this.campaignId);
|
||
}
|
||
});
|
||
}
|
||
|
||
roll(): void {
|
||
if (!this.table) return;
|
||
const result = DiceUtils.roll(this.table.diceFormula);
|
||
if (!result) { this.lastRoll = null; this.matched = null; return; }
|
||
this.lastRoll = result;
|
||
this.matched = this.table.entries.find(
|
||
e => result.total >= e.minRoll && result.total <= e.maxRoll
|
||
) ?? null;
|
||
}
|
||
|
||
isMatched(entry: RandomTableEntry): boolean {
|
||
return this.matched === entry;
|
||
}
|
||
|
||
rangeLabel(entry: RandomTableEntry): string {
|
||
return entry.minRoll === entry.maxRoll
|
||
? String(entry.minRoll)
|
||
: `${entry.minRoll}–${entry.maxRoll}`;
|
||
}
|
||
|
||
edit(): void {
|
||
if (this.campaignId && this.tableId) {
|
||
this.router.navigate(['/campaigns', this.campaignId, 'random-tables', this.tableId, 'edit']);
|
||
}
|
||
}
|
||
|
||
back(): void {
|
||
this.router.navigate(this.campaignId ? ['/campaigns', this.campaignId] : ['/campaigns']);
|
||
}
|
||
}
|