|
@@ -487,6 +509,7 @@
modalDetails: null,
modalLoading: false,
modalError: null,
+ modalMode: 'snapshot',
sort: { field: 'createdAt', dir: 'desc' },
async init() {
@@ -549,6 +572,71 @@
}));
},
+ displayItems() {
+ if (this.modalMode === 'snapshot' || !this.modalDetails) {
+ return this.allItems();
+ }
+ return this.allItems().map(item => this.recomputeItem(item));
+ },
+
+ recomputeItem(item) {
+ const insumos = this.store()?.state?.insumos;
+ if (!insumos) return item;
+ const precioCristal = insumos.cristales?.[item.grado] || 0;
+ const orePrice = item.tipo === 'Soulshot'
+ ? (insumos.soulOre || 0)
+ : (insumos.spiritOre || 0);
+ const ventaPrice = insumos.venta?.[item.tipo]?.[item.grado] || 0;
+ const dwarvenFee = insumos.dwarvenFeePerCraft || 0;
+
+ const costoCristales = item.cristalesUsados * precioCristal;
+ const costoOre = item.oreNecesario * orePrice;
+ const costoDwarven = item.crafteosPosibles * dwarvenFee;
+ const costoTotal = costoCristales + costoOre + costoDwarven;
+ const valorVenta = item.shotsObtenidos * ventaPrice;
+ const ganancia = valorVenta - costoTotal;
+
+ return {
+ ...item,
+ costoCristales,
+ costoOre,
+ costoDwarven,
+ costoTotal,
+ valorVenta,
+ ganancia,
+ };
+ },
+
+ displayTotals() {
+ const items = this.displayItems();
+ let costo = 0, venta = 0, ganancia = 0;
+ let costCristales = 0, costOre = 0, costDwarven = 0;
+ let shots = 0;
+ for (const item of items) {
+ costo += item.costoTotal || 0;
+ venta += item.valorVenta || 0;
+ ganancia += item.ganancia || 0;
+ costCristales += item.costoCristales || 0;
+ costOre += item.costoOre || 0;
+ costDwarven += item.costoDwarven || 0;
+ shots += item.shotsObtenidos || 0;
+ }
+ return {
+ totalCost: costo,
+ totalSale: venta,
+ totalProfit: ganancia,
+ totalShots: shots,
+ costCristales,
+ costOre,
+ costDwarven,
+ };
+ },
+
+ recomputeDelta() {
+ if (this.modalMode !== 'current' || !this.modalDetails) return null;
+ return this.modalDetails.totalProfit - this.displayTotals().totalProfit;
+ },
+
get sortedRuns() {
const field = this.sort.field;
const dir = this.sort.dir === 'asc' ? 1 : -1;
@@ -657,39 +745,53 @@
return Math.round(details.totalProfit / details.totalShots);
},
+ marginPctCurrent() {
+ const t = this.displayTotals();
+ if (!t.totalCost) return 0;
+ return Math.round((t.totalProfit / t.totalCost) * 1000) / 10;
+ },
+
+ costPerShotCurrent() {
+ const t = this.displayTotals();
+ if (!t.totalShots) return 0;
+ return Math.round(t.totalCost / t.totalShots);
+ },
+
+ profitPerShotCurrent() {
+ const t = this.displayTotals();
+ if (!t.totalShots) return 0;
+ return Math.round(t.totalProfit / t.totalShots);
+ },
+
totalCrafteos() {
- if (!this.modalDetails?.items) return 0;
- return this.modalDetails.items.reduce((s, i) => s + (i.crafteosPosibles || 0), 0);
+ return this.displayItems().reduce((s, i) => s + (i.crafteosPosibles || 0), 0);
},
costCristalesTotal() {
- if (!this.modalDetails?.items) return 0;
- return this.modalDetails.items.reduce((s, i) => s + (i.costoCristales || 0), 0);
+ return this.displayItems().reduce((s, i) => s + (i.costoCristales || 0), 0);
},
costOreTotal() {
- if (!this.modalDetails?.items) return 0;
- return this.modalDetails.items.reduce((s, i) => s + (i.costoOre || 0), 0);
+ return this.displayItems().reduce((s, i) => s + (i.costoOre || 0), 0);
},
costDwarvenTotal() {
- if (!this.modalDetails?.items) return 0;
- return this.modalDetails.items.reduce((s, i) => s + (i.costoDwarven || 0), 0);
+ return this.displayItems().reduce((s, i) => s + (i.costoDwarven || 0), 0);
},
costCristalesPct() {
- const total = this.modalDetails?.totalCost || 0;
- return total > 0 ? Math.round((this.costCristalesTotal() * 1000) / total) / 10 : 0;
+ const t = this.displayTotals();
+ return t.totalCost > 0 ? Math.round((t.costCristales * 1000) / t.totalCost) / 10 : 0;
},
costOrePct() {
- const total = this.modalDetails?.totalCost || 0;
- return total > 0 ? Math.round((this.costOreTotal() * 1000) / total) / 10 : 0;
+ const t = this.displayTotals();
+ return t.totalCost > 0 ? Math.round((t.costOre * 1000) / t.totalCost) / 10 : 0;
},
costDwarvenPct() {
- const total = this.modalDetails?.totalCost || 0;
- return total > 0 ? Math.round((this.costDwarvenTotal() * 1000) / total) / 10 : 0;
+ const t = this.displayTotals();
+ return t.totalCost > 0 ? Math.round((t.costDwarven * 1000) / t.totalCost) / 10 : 0;
},
snapshotCristalesUsed() {
|