Release v0.1.6 2026-07-12
This commit is contained in:
@@ -156,6 +156,17 @@ export function canAffordGearUpgrade(inventory: readonly MaterialStack[], costs:
|
||||
return costs.every((cost) => (inventory.find((item) => item.id === cost.itemId)?.quantity ?? 0) >= cost.quantity);
|
||||
}
|
||||
|
||||
export function canUpgradeGearSlot(
|
||||
progress: GearProgress,
|
||||
inventory: readonly MaterialStack[],
|
||||
ownerId: GearOwnerId,
|
||||
slotId: GearSlotId,
|
||||
): boolean {
|
||||
const currentLevel = progress[ownerId].slots[slotId].level;
|
||||
return currentLevel < MAX_GEAR_LEVEL
|
||||
&& canAffordGearUpgrade(inventory, gearUpgradeCosts(ownerId, slotId, currentLevel));
|
||||
}
|
||||
|
||||
export function spendGearCosts(inventory: readonly MaterialStack[], costs: readonly GearUpgradeCost[]): MaterialStack[] {
|
||||
if (!canAffordGearUpgrade(inventory, costs)) {
|
||||
const missing = costs.find((cost) => (inventory.find((item) => item.id === cost.itemId)?.quantity ?? 0) < cost.quantity);
|
||||
|
||||
Reference in New Issue
Block a user