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 {
|
export interface CharacterResponse {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
level: number;
|
renown: number;
|
||||||
experience: number;
|
|
||||||
silver: number;
|
silver: number;
|
||||||
currentHp: number;
|
currentHp: number;
|
||||||
maxHp: number;
|
maxHp: number;
|
||||||
@@ -207,7 +206,6 @@ export interface CombatRewardItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface CombatReward {
|
export interface CombatReward {
|
||||||
experience: number;
|
|
||||||
silver: number;
|
silver: number;
|
||||||
items: CombatRewardItem[];
|
items: CombatRewardItem[];
|
||||||
}
|
}
|
||||||
@@ -230,7 +228,6 @@ export interface InventoryItem {
|
|||||||
name: string;
|
name: string;
|
||||||
rarity: ItemRarity;
|
rarity: ItemRarity;
|
||||||
equipmentSlot: EquipmentSlot | null;
|
equipmentSlot: EquipmentSlot | null;
|
||||||
requiredLevel: number;
|
|
||||||
weaponDamage: number;
|
weaponDamage: number;
|
||||||
bonusAttack: number;
|
bonusAttack: number;
|
||||||
bonusHp: number;
|
bonusHp: number;
|
||||||
@@ -266,3 +263,26 @@ export interface EquipmentResponse {
|
|||||||
slots: EquipmentSlots;
|
slots: EquipmentSlots;
|
||||||
stats: EquipmentStats;
|
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' });
|
expect(request.request.body).toEqual({ action: 'ATTACK' });
|
||||||
request.flush({});
|
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,
|
HuntResult,
|
||||||
InventoryResponse,
|
InventoryResponse,
|
||||||
LocationInteractionResult,
|
LocationInteractionResult,
|
||||||
|
ReputationEntry,
|
||||||
|
TurnInResult,
|
||||||
} from './game-api.models';
|
} from './game-api.models';
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
@@ -79,4 +81,12 @@ export class GameApiService {
|
|||||||
equipItem(characterItemId: string): Observable<EquipmentResponse> {
|
equipItem(characterItemId: string): Observable<EquipmentResponse> {
|
||||||
return this.http.post<EquipmentResponse>('/api/equipment', { characterItemId });
|
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