Files
LoreMind/web/src/app/services/character.service.ts
IETM_FIXE\ietm6 6035df262d
All checks were successful
Build & Push Images / build (brain) (push) Successful in 1m32s
Build & Push Images / build (core) (push) Successful in 1m52s
Build & Push Images / build-switcher (push) Successful in 20s
Build & Push Images / build (web) (push) Successful in 1m48s
Ajout de la possibilité de faire des stats blocs pour tout ce qui est ennemis / créatures adverses.
Dorénavant, l'IA est capable de prendre en compte le format des quêtes, chapitres, Arc.... pour proposer des blocs plus complets.
Les ennemis sont également référençables directement dans la campagne.
Les références vers les ennemis dans la partie "donjon" est en cours d'ajout
2026-06-12 23:38:43 +02:00

49 lines
1.5 KiB
TypeScript

import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Character, CharacterCreate } from './character.model';
/** Résultat de recherche d'un PJ, enrichi du campaignId pour la navigation. */
export interface CharacterSearchResult {
id: string;
name: string;
playthroughId: string;
campaignId: string;
}
/**
* Service HTTP pour les fiches de personnages (PJ) d'une campagne.
*/
@Injectable({ providedIn: 'root' })
export class CharacterService {
private apiUrl = '/api/characters';
constructor(private http: HttpClient) {}
getByPlaythrough(playthroughId: string): Observable<Character[]> {
return this.http.get<Character[]>(`${this.apiUrl}/playthrough/${playthroughId}`);
}
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}`);
}
/** Recherche par nom — alimente la recherche globale (Ctrl+K). */
search(q: string): Observable<CharacterSearchResult[]> {
const params = new HttpParams().set('q', q);
return this.http.get<CharacterSearchResult[]>(`${this.apiUrl}/search`, { params });
}
}