1 import {Profession} from "./profession";
2 import {SkillID} from "./skills";
3 import { max } from 'lodash';
5 export type InventoryType = 'ARMOUR' | 'WEAPON' | 'SPELL';
7 export type ArmourEquipmentSlot = 'HEAD' | 'LEGS' | 'ARMS' | 'CHEST';
8 export type WeaponEquipmentSlot = 'LEFT_HAND' | 'RIGHT_HAND' | 'TWO_HANDED' | 'ANY_HAND';
10 export type EquipmentSlot = ArmourEquipmentSlot | WeaponEquipmentSlot;
13 export type InventoryItem = {
18 profession: Profession;
19 equipment_slot: EquipmentSlot;
36 damage_mitigation: number;
41 affectedSkills: SkillID[];
44 // shop items have a numeric id since they're tracked in a separate spreadsheet
45 // and they are also tied to a specific location
46 export type ShopEquipment = Omit<InventoryItem, 'id' | 'player_id'> & {
51 export function repairCost(item: InventoryItem): number {
52 const totalCost = item.cost * 0.7;
54 const damageRatio = 1 - (item.currentAp / item.maxAp);
56 return max([Math.floor(totalCost * damageRatio), 1]);