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:
2026-04-22 11:58:50 +02:00
parent bf38b6695f
commit 8f4dd3e9d6
63 changed files with 2840 additions and 36 deletions

View File

@@ -41,7 +41,7 @@ export type ChatStreamEvent =
* décode ligne par ligne pour extraire les événements SSE.
*/
/** Type d'entité narrative focus pour le chat Campagne. */
export type NarrativeEntityType = 'arc' | 'chapter' | 'scene';
export type NarrativeEntityType = 'arc' | 'chapter' | 'scene' | 'character';
@Injectable({ providedIn: 'root' })
export class AiChatService {

View File

@@ -8,6 +8,8 @@ export interface Campaign {
chapterCount?: number;
/** ID du Lore associé (weak reference cross-context). `null` = pas d'univers lié. */
loreId?: string | null;
/** ID du GameSystem associé (weak reference cross-context). `null` = campagne générique. */
gameSystemId?: string | null;
}
// Interface pour la création de Campaign (sans id)
@@ -16,6 +18,7 @@ export interface CampaignCreate {
description: string;
playerCount: number;
loreId?: string | null;
gameSystemId?: string | null;
}
export interface Arc {

View File

@@ -0,0 +1,18 @@
/**
* Fiche de personnage joueur (PJ) d'une campagne.
* MVP : markdownContent libre. Évolution prévue vers des fiches templatées
* par GameSystem (stats structurées selon le JDR joué).
*/
export interface Character {
id?: string;
name: string;
markdownContent?: string | null;
campaignId: string;
order?: number;
}
export interface CharacterCreate {
name: string;
markdownContent?: string | null;
campaignId: string;
}

View File

@@ -0,0 +1,34 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Character, CharacterCreate } from './character.model';
/**
* Service HTTP pour les fiches de personnages (PJ) d'une campagne.
*/
@Injectable({ providedIn: 'root' })
export class CharacterService {
private apiUrl = 'http://localhost:8080/api/characters';
constructor(private http: HttpClient) {}
getByCampaign(campaignId: string): Observable<Character[]> {
return this.http.get<Character[]>(`${this.apiUrl}/campaign/${campaignId}`);
}
getById(id: string): Observable<Character> {
return this.http.get<Character>(`${this.apiUrl}/${id}`);
}
create(payload: CharacterCreate): Observable<Character> {
return this.http.post<Character>(this.apiUrl, payload);
}
update(id: string, payload: Character): Observable<Character> {
return this.http.put<Character>(`${this.apiUrl}/${id}`, payload);
}
delete(id: string): Observable<void> {
return this.http.delete<void>(`${this.apiUrl}/${id}`);
}
}

View File

@@ -26,7 +26,7 @@ export interface Conversation {
export interface ConversationContext {
loreId?: string | null;
campaignId?: string | null;
entityType?: 'page' | 'arc' | 'chapter' | 'scene' | null;
entityType?: 'page' | 'arc' | 'chapter' | 'scene' | 'character' | null;
entityId?: string | null;
}

View File

@@ -0,0 +1,24 @@
/**
* Interface TypeScript pour GameSystemDTO (jumeau du DTO Java).
*
* rulesMarkdown : markdown monolithique, sections découpées par titres H2
* (## Combat, ## Classes, etc.). Le découpage et la sélection des sections
* à injecter dans le prompt IA sont faits côté backend Java.
*/
export interface GameSystem {
id?: string;
name: string;
description?: string | null;
rulesMarkdown?: string | null;
author?: string | null;
isPublic?: boolean;
}
/** Payload de création/mise à jour (sans id). */
export interface GameSystemCreate {
name: string;
description?: string | null;
rulesMarkdown?: string | null;
author?: string | null;
isPublic: boolean;
}

View File

@@ -0,0 +1,39 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { GameSystem, GameSystemCreate } from './game-system.model';
/**
* Service HTTP pour les GameSystems (systèmes de JDR).
*/
@Injectable({ providedIn: 'root' })
export class GameSystemService {
private apiUrl = 'http://localhost:8080/api/game-systems';
constructor(private http: HttpClient) {}
getAll(): Observable<GameSystem[]> {
return this.http.get<GameSystem[]>(this.apiUrl);
}
getById(id: string): Observable<GameSystem> {
return this.http.get<GameSystem>(`${this.apiUrl}/${id}`);
}
create(payload: GameSystemCreate): Observable<GameSystem> {
return this.http.post<GameSystem>(this.apiUrl, payload);
}
update(id: string, payload: GameSystemCreate): Observable<GameSystem> {
return this.http.put<GameSystem>(`${this.apiUrl}/${id}`, payload);
}
delete(id: string): Observable<void> {
return this.http.delete<void>(`${this.apiUrl}/${id}`);
}
search(q: string): Observable<GameSystem[]> {
const params = new HttpParams().set('q', q);
return this.http.get<GameSystem[]>(`${this.apiUrl}/search`, { params });
}
}