Android build v1.0.44

This commit is contained in:
Warren H
2026-06-20 23:04:39 -04:00
parent 6e10b37f8e
commit 4b45483ac3
10 changed files with 519 additions and 98 deletions
+8 -1
View File
@@ -364,10 +364,13 @@ function updateCraftingRecipes(profile: CharacterProfile) {
...component,
owned: owned.get(component.item.id) ?? 0,
}))
const hasRequiredComponents = components.length > 0
&& components.every((component) => component.quantity > 0)
return {
...recipe,
components,
canCraft: components.every((component) => component.owned >= component.quantity),
canCraft: hasRequiredComponents
&& components.every((component) => component.owned >= component.quantity),
}
})
}
@@ -1301,12 +1304,14 @@ function createLocalRepository(store: LocalSaveStore): GameRepository {
if (!recipe) throw new Error('That crafting recipe does not exist.')
const requiresUpgrade = !DIRECT_CRAFT_ITEM_LEVELS.has(recipe.item.itemLevel)
if (requiresUpgrade) throw new Error('Upgrade the previous item tier instead.')
if (recipe.components.length === 0) throw new Error('That recipe has no component requirements.')
const missing = recipe.components.find((component) => component.owned < component.quantity)
if (missing) {
throw new Error(`Need ${missing.quantity} ${missing.item.name} to craft this item.`)
}
for (const component of recipe.components) {
if (component.quantity <= 0) throw new Error('Recipe components must require at least one item.')
const owned = profile.inventory.find((candidate) => candidate.id === component.item.id)
if (!owned) throw new Error(`Need ${component.quantity} ${component.item.name} to craft this item.`)
owned.quantity -= component.quantity
@@ -1331,12 +1336,14 @@ function createLocalRepository(store: LocalSaveStore): GameRepository {
? selectUpgradeRecipe(profile.gearUpgradePaths ?? [], profile.craftingRecipes, item)
: null
if (!targetRecipe) throw new Error('No upgrade is available for this item.')
if (targetRecipe.components.length === 0) throw new Error('That upgrade has no component requirements.')
const missing = targetRecipe.components.find((component) => component.owned < component.quantity)
if (missing) {
throw new Error(`Need ${missing.quantity} ${missing.item.name} to upgrade this item.`)
}
for (const component of targetRecipe.components) {
if (component.quantity <= 0) throw new Error('Upgrade components must require at least one item.')
const owned = profile.inventory.find((candidate) => candidate.id === component.item.id)
if (!owned) throw new Error(`Need ${component.quantity} ${component.item.name} to upgrade this item.`)
owned.quantity -= component.quantity