add local production bonuses

This commit is contained in:
2026-03-05 02:20:21 -05:00
parent f1deb33360
commit 4214eeb659
10 changed files with 103 additions and 59 deletions

View File

@@ -179,7 +179,7 @@
<span class="text-gray-200">{{ formatSilver(totals.rawCost) }}</span>
</div>
<div class="flex justify-between gap-4">
<span class="text-gray-400">RRR savings ({{ filters.rrr }}%)</span>
<span class="text-gray-400">RRR savings</span>
<span class="text-green-400">{{ formatSilver(totals.rrrSavings) }}</span>
</div>
<div class="flex justify-between gap-4 border-t border-gray-700/50 pt-2">
@@ -209,6 +209,7 @@ import { useAlbionPrices } from '../composables/useAlbionPrices'
import { useFilters } from '../composables/useFilters'
import { formatSilver, formatItemId, formatLastUpdated, tierStyle, itemImageUrl } from '../utils/formatting'
import { fameTypeOf, craftsPerJournal } from '../data/constants'
import { cityRrr, isRrrExempt } from '../data/cityBonuses'
import type { Tier, JournalType } from '../types/crafting'
const vFocus = { mounted: (el: HTMLElement) => el.focus() }
@@ -277,11 +278,11 @@ const JOURNAL_ITEM_ID: Record<JournalType, string> = {
// ─── Per-item computed values ─────────────────────────────────────────────────
const computedItems = computed(() => {
const city = filters.value.city
const rrrFactor = 1 - filters.value.rrr / 100
const city = filters.value.city
return orderItems.value.map(({ recipe, qty }) => {
let rawCost = 0
let basicCost = 0
let artefactCost = 0
let missingPrices = false
for (const ing of recipe.ingredients) {
@@ -289,12 +290,15 @@ const computedItems = computed(() => {
if (!entry || entry.sell_price_min === 0) {
missingPrices = true
} else {
rawCost += entry.sell_price_min * ing.quantity
if (isRrrExempt(ing.itemId)) artefactCost += entry.sell_price_min * ing.quantity
else basicCost += entry.sell_price_min * ing.quantity
}
}
const craftCostPerUnit = rawCost * rrrFactor
return { recipe, qty, craftCostPerUnit, totalCraftCost: craftCostPerUnit * qty, missingPrices }
const rawCost = basicCost + artefactCost
const rrr = cityRrr(city, recipe.outputItemId)
const craftCostPerUnit = basicCost * (1 - rrr / 100) + artefactCost
return { recipe, qty, rawCostPerUnit: rawCost, craftCostPerUnit, totalCraftCost: craftCostPerUnit * qty, rrr, missingPrices }
})
})
@@ -323,21 +327,21 @@ const aggregatedMaterials = computed(() => {
// ─── Totals + journals ────────────────────────────────────────────────────────
const totals = computed(() => {
const rrrFactor = 1 - filters.value.rrr / 100
let rawCost = 0
let effectiveCost = 0
let totalCrafts = 0
let totalItems = 0
for (const item of computedItems.value) {
if (!item.missingPrices) {
rawCost += item.craftCostPerUnit / rrrFactor * item.qty // back to raw
rawCost += item.rawCostPerUnit * item.qty
effectiveCost += item.craftCostPerUnit * item.qty
}
totalCrafts += item.qty
totalItems += item.qty
}
const effectiveCost = rawCost * rrrFactor
const rrrSavings = rawCost - effectiveCost
const rrrSavings = rawCost - effectiveCost
return { rawCost, effectiveCost, rrrSavings, totalCrafts, totalItems }
})