Ajout de la partie "Système de jeu" avec toute la partie stockage de règles de notre jeu.
Ajout de possibilité de stocker des fiches de personnages associés à une campagne également (personnages joueurs pour le moment)
This commit is contained in:
56
web/src/app/game-systems/game-systems.component.ts
Normal file
56
web/src/app/game-systems/game-systems.component.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Router } from '@angular/router';
|
||||
import { LucideAngularModule, Dices, Plus, Pencil, Trash2 } from 'lucide-angular';
|
||||
import { GameSystemService } from '../services/game-system.service';
|
||||
import { GameSystem } from '../services/game-system.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-game-systems',
|
||||
standalone: true,
|
||||
imports: [CommonModule, LucideAngularModule],
|
||||
templateUrl: './game-systems.component.html',
|
||||
styleUrls: ['./game-systems.component.scss']
|
||||
})
|
||||
export class GameSystemsComponent implements OnInit {
|
||||
readonly Dices = Dices;
|
||||
readonly Plus = Plus;
|
||||
readonly Pencil = Pencil;
|
||||
readonly Trash2 = Trash2;
|
||||
|
||||
gameSystems: GameSystem[] = [];
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private gameSystemService: GameSystemService
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.load();
|
||||
}
|
||||
|
||||
load(): void {
|
||||
this.gameSystemService.getAll().subscribe({
|
||||
next: (data) => this.gameSystems = data,
|
||||
error: () => this.gameSystems = []
|
||||
});
|
||||
}
|
||||
|
||||
create(): void {
|
||||
this.router.navigate(['/game-systems/create']);
|
||||
}
|
||||
|
||||
edit(id: string): void {
|
||||
this.router.navigate(['/game-systems', id, 'edit']);
|
||||
}
|
||||
|
||||
delete(system: GameSystem, event: MouseEvent): void {
|
||||
event.stopPropagation();
|
||||
if (!system.id) return;
|
||||
if (!confirm(`Supprimer le système "${system.name}" ? Les campagnes qui l'utilisent ne seront plus associées à aucun système.`)) return;
|
||||
this.gameSystemService.delete(system.id).subscribe({
|
||||
next: () => this.load(),
|
||||
error: () => console.error('Erreur suppression GameSystem')
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user