Android build v1.0.44
This commit is contained in:
+33
-1
@@ -375,6 +375,31 @@ const server = createServer(async (request, response) => {
|
||||
SELECT from_item_id AS fromItemId, to_item_id AS toItemId
|
||||
FROM gear_upgrade_paths ORDER BY from_item_id
|
||||
`).all()
|
||||
const classes = database.prepare(`
|
||||
SELECT id, slug, name, resource_name AS resourceName,
|
||||
max_resource AS maxResource, theme_color AS themeColor, description
|
||||
FROM classes ORDER BY id
|
||||
`).all()
|
||||
const abilities = database.prepare(`
|
||||
SELECT id, class_id AS classId, slug, name, spell_type AS spellType,
|
||||
resource_cost AS cost, cooldown_seconds AS cooldown, power,
|
||||
unlock_level AS unlockLevel, glyph, description
|
||||
FROM spells ORDER BY class_id, unlock_level, id
|
||||
`).all()
|
||||
const talents = database.prepare(`
|
||||
SELECT talents.id, talents.class_id AS classId, talents.slug, talents.name,
|
||||
talents.max_rank AS maxRank, talents.tier, talents.branch,
|
||||
talents.prerequisite_talent_id AS prerequisiteTalentId,
|
||||
talents.prerequisite_rank AS prerequisiteRank,
|
||||
prerequisite.name AS prerequisiteName,
|
||||
talents.effect_type AS effectType,
|
||||
talents.effect_value_per_rank AS effectValuePerRank,
|
||||
talents.glyph, talents.description
|
||||
FROM talents
|
||||
LEFT JOIN talents AS prerequisite
|
||||
ON prerequisite.id = talents.prerequisite_talent_id
|
||||
ORDER BY talents.class_id, talents.tier, talents.branch
|
||||
`).all()
|
||||
sendJson(response, 200, {
|
||||
items,
|
||||
encounters,
|
||||
@@ -383,6 +408,11 @@ const server = createServer(async (request, response) => {
|
||||
craftingRecipes: [...recipes.values()],
|
||||
dungeons,
|
||||
gearUpgradePaths,
|
||||
classes: classes.map((gameClass) => ({
|
||||
...gameClass,
|
||||
abilities: abilities.filter((ability) => ability.classId === gameClass.id),
|
||||
talents: talents.filter((talent) => talent.classId === gameClass.id),
|
||||
})),
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -499,12 +529,14 @@ const server = createServer(async (request, response) => {
|
||||
const recipeComponents = request.url.match(/^\/api\/admin\/crafting-recipes\/(\d+)\/components$/)
|
||||
if (recipeComponents && request.method === 'POST') {
|
||||
const payload = await readJson(request)
|
||||
const quantity = Number(payload.quantity)
|
||||
if (!Number.isInteger(quantity) || quantity < 1) throw new Error('Component quantity must be at least 1.')
|
||||
database.prepare(`
|
||||
INSERT INTO crafting_recipe_components (recipe_id, item_id, quantity)
|
||||
VALUES (?, ?, ?)
|
||||
ON CONFLICT(recipe_id, item_id)
|
||||
DO UPDATE SET quantity = excluded.quantity
|
||||
`).run(Number(recipeComponents[1]), payload.itemId, payload.quantity)
|
||||
`).run(Number(recipeComponents[1]), payload.itemId, quantity)
|
||||
writeAdminOverrides(database)
|
||||
sendJson(response, 200, { ok: true })
|
||||
return
|
||||
|
||||
+11
-1
@@ -858,6 +858,8 @@ export function getProfile(database, characterId, accountId) {
|
||||
quantity,
|
||||
owned,
|
||||
}))
|
||||
const hasRequiredComponents = components.length > 0
|
||||
&& components.every((component) => component.quantity > 0)
|
||||
const { itemId, slug, name, slot, rarity, itemLevel, healingPower, maxResourceBonus, glyph, description, setId, setSlug, setName } = recipe
|
||||
return {
|
||||
id: recipe.id,
|
||||
@@ -880,7 +882,8 @@ export function getProfile(database, characterId, accountId) {
|
||||
setName,
|
||||
},
|
||||
components,
|
||||
canCraft: components.every((component) => component.owned >= component.quantity),
|
||||
canCraft: hasRequiredComponents
|
||||
&& components.every((component) => component.owned >= component.quantity),
|
||||
}
|
||||
}),
|
||||
dungeons: dungeons.map((dungeon) => ({
|
||||
@@ -1746,6 +1749,9 @@ function craftItem(database, characterId, recipeId) {
|
||||
WHERE crafting_recipe_components.recipe_id = ?
|
||||
`).all(characterId, recipeId)
|
||||
if (components.length === 0) throw new Error('That recipe has no component requirements.')
|
||||
if (components.some((component) => component.quantity <= 0)) {
|
||||
throw new Error('Recipe components must require at least one item.')
|
||||
}
|
||||
const missing = components.find((component) => component.owned < component.quantity)
|
||||
if (missing) {
|
||||
const item = itemById(database, missing.itemId)
|
||||
@@ -1845,6 +1851,10 @@ function upgradeItem(database, characterId, itemId) {
|
||||
AND character_inventory.character_id = ?
|
||||
WHERE crafting_recipe_components.recipe_id = ?
|
||||
`).all(characterId, targetRecipe.id)
|
||||
if (components.length === 0) throw new Error('That upgrade has no component requirements.')
|
||||
if (components.some((component) => component.quantity <= 0)) {
|
||||
throw new Error('Upgrade components must require at least one item.')
|
||||
}
|
||||
const missing = components.find((component) => component.owned < component.quantity)
|
||||
if (missing) {
|
||||
const componentItem = itemById(database, missing.itemId)
|
||||
|
||||
Reference in New Issue
Block a user