From c32d1804d30a85a30613cdfbf9b39144102b54c8 Mon Sep 17 00:00:00 2001 From: Bastian Wagner Date: Fri, 21 Aug 2026 14:41:11 +0200 Subject: [PATCH] feat(renown): add Renown/Reputation/TurnIn web models and API client methods --- apps/web/src/app/core/api/game-api.models.ts | 28 +++++++++++++++--- .../src/app/core/api/game-api.service.spec.ts | 29 +++++++++++++++++++ apps/web/src/app/core/api/game-api.service.ts | 10 +++++++ 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/apps/web/src/app/core/api/game-api.models.ts b/apps/web/src/app/core/api/game-api.models.ts index c1cc082..82cc915 100644 --- a/apps/web/src/app/core/api/game-api.models.ts +++ b/apps/web/src/app/core/api/game-api.models.ts @@ -7,8 +7,7 @@ export interface LocationSummary { export interface CharacterResponse { id: string; name: string; - level: number; - experience: number; + renown: number; silver: number; currentHp: number; maxHp: number; @@ -207,7 +206,6 @@ export interface CombatRewardItem { } export interface CombatReward { - experience: number; silver: number; items: CombatRewardItem[]; } @@ -230,7 +228,6 @@ export interface InventoryItem { name: string; rarity: ItemRarity; equipmentSlot: EquipmentSlot | null; - requiredLevel: number; weaponDamage: number; bonusAttack: number; bonusHp: number; @@ -266,3 +263,26 @@ export interface EquipmentResponse { slots: EquipmentSlots; stats: EquipmentStats; } + +export interface ReputationEntry { + factionKey: string; + factionName: string; + reputation: number; + rank: string; + rankLabel: string; + nextThreshold: number | null; +} + +export interface TurnInResult { + turnInKey: string; + quantityConsumed: number; + silverGranted: number; + reputationResult: { + factionKey: string; + previousReputation: number; + newReputation: number; + previousRank: string; + newRank: string; + rankChanged: boolean; + }; +} diff --git a/apps/web/src/app/core/api/game-api.service.spec.ts b/apps/web/src/app/core/api/game-api.service.spec.ts index ffc16ff..8601e53 100644 --- a/apps/web/src/app/core/api/game-api.service.spec.ts +++ b/apps/web/src/app/core/api/game-api.service.spec.ts @@ -99,4 +99,33 @@ describe('GameApiService', () => { expect(request.request.body).toEqual({ action: 'ATTACK' }); request.flush({}); }); + + it('fetches reputation', () => { + service.getReputation().subscribe(); + + const req = http.expectOne('/api/reputation'); + expect(req.request.method).toBe('GET'); + req.flush([]); + }); + + it('submits a turn-in with only turnInKey and quantity', () => { + service.turnIn('ash-pelt-border-guard', 3).subscribe(); + + const req = http.expectOne('/api/turn-ins'); + expect(req.request.method).toBe('POST'); + expect(req.request.body).toEqual({ turnInKey: 'ash-pelt-border-guard', quantity: 3 }); + req.flush({ + turnInKey: 'ash-pelt-border-guard', + quantityConsumed: 3, + silverGranted: 12, + reputationResult: { + factionKey: 'border-guard', + previousReputation: 0, + newReputation: 3, + previousRank: 'STRANGER', + newRank: 'STRANGER', + rankChanged: false, + }, + }); + }); }); diff --git a/apps/web/src/app/core/api/game-api.service.ts b/apps/web/src/app/core/api/game-api.service.ts index 2149104..6729403 100644 --- a/apps/web/src/app/core/api/game-api.service.ts +++ b/apps/web/src/app/core/api/game-api.service.ts @@ -11,6 +11,8 @@ import { HuntResult, InventoryResponse, LocationInteractionResult, + ReputationEntry, + TurnInResult, } from './game-api.models'; @Injectable({ providedIn: 'root' }) @@ -79,4 +81,12 @@ export class GameApiService { equipItem(characterItemId: string): Observable { return this.http.post('/api/equipment', { characterItemId }); } + + getReputation(): Observable { + return this.http.get('/api/reputation'); + } + + turnIn(turnInKey: string, quantity: number): Observable { + return this.http.post('/api/turn-ins', { turnInKey, quantity }); + } }