feat(web): add inventory/equipment API models and client methods
This commit is contained in:
@@ -132,3 +132,58 @@ export interface CombatReward {
|
||||
silver: number;
|
||||
items: CombatRewardItem[];
|
||||
}
|
||||
|
||||
export type EquipmentSlot =
|
||||
| 'WEAPON'
|
||||
| 'HEAD'
|
||||
| 'CHEST'
|
||||
| 'HANDS'
|
||||
| 'LEGS'
|
||||
| 'FEET'
|
||||
| 'AMULET';
|
||||
|
||||
export interface InventoryItem {
|
||||
id: string;
|
||||
quantity: number;
|
||||
equipped: boolean;
|
||||
item: {
|
||||
key: string;
|
||||
name: string;
|
||||
rarity: ItemRarity;
|
||||
equipmentSlot: EquipmentSlot | null;
|
||||
requiredLevel: number;
|
||||
weaponDamage: number;
|
||||
bonusAttack: number;
|
||||
bonusHp: number;
|
||||
bonusArmor: number;
|
||||
iconPath: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface InventoryResponse {
|
||||
items: InventoryItem[];
|
||||
}
|
||||
|
||||
export interface EquipmentSlotItem {
|
||||
characterItemId: string;
|
||||
item: {
|
||||
key: string;
|
||||
name: string;
|
||||
rarity: ItemRarity;
|
||||
iconPath: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type EquipmentSlots = Record<EquipmentSlot, EquipmentSlotItem | null>;
|
||||
|
||||
export interface EquipmentStats {
|
||||
maxHp: number;
|
||||
attack: number;
|
||||
weaponDamage: number;
|
||||
armor: number;
|
||||
}
|
||||
|
||||
export interface EquipmentResponse {
|
||||
slots: EquipmentSlots;
|
||||
stats: EquipmentStats;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ import {
|
||||
CombatAction,
|
||||
CurrentLocationResponse,
|
||||
CurrentTravel,
|
||||
EquipmentResponse,
|
||||
HuntResult,
|
||||
InventoryResponse,
|
||||
} from './game-api.models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
@@ -53,4 +55,16 @@ export class GameApiService {
|
||||
performCombatAction(combatId: string, action: CombatAction): Observable<Combat> {
|
||||
return this.http.post<Combat>(`/api/combats/${combatId}/actions`, { action });
|
||||
}
|
||||
|
||||
getInventory(): Observable<InventoryResponse> {
|
||||
return this.http.get<InventoryResponse>('/api/inventory');
|
||||
}
|
||||
|
||||
getEquipment(): Observable<EquipmentResponse> {
|
||||
return this.http.get<EquipmentResponse>('/api/equipment');
|
||||
}
|
||||
|
||||
equipItem(characterItemId: string): Observable<EquipmentResponse> {
|
||||
return this.http.post<EquipmentResponse>('/api/equipment', { characterItemId });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user