feat(renown): add Renown/Reputation/TurnIn web models and API client methods
This commit is contained in:
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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<EquipmentResponse> {
|
||||
return this.http.post<EquipmentResponse>('/api/equipment', { characterItemId });
|
||||
}
|
||||
|
||||
getReputation(): Observable<ReputationEntry[]> {
|
||||
return this.http.get<ReputationEntry[]>('/api/reputation');
|
||||
}
|
||||
|
||||
turnIn(turnInKey: string, quantity: number): Observable<TurnInResult> {
|
||||
return this.http.post<TurnInResult>('/api/turn-ins', { turnInKey, quantity });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user