refactor(personajes): replace per-character capacity table with single reference table (lv0-lv3, baseWeight 115.230)
CI / Build Native (push) Successful in 6m45s

This commit is contained in:
2026-08-24 10:13:58 -04:00
parent 38902f972e
commit 5d7e6b610e
2 changed files with 32 additions and 93 deletions
@@ -27,6 +27,12 @@ window.shots = {
return w > 0 ? Math.floor(maxW / w) : 0;
},
referenceCapacity(tipo, grado, skillLevel, baseWeight = 115230) {
const pesoMax = baseWeight * (1 + skillLevel);
const w = this.itemWeight(tipo, grado);
return w > 0 ? Math.floor(pesoMax / w) : 0;
},
totalCapacityOf(c) {
let total = 0;
for (const t of this.TIPOS) {
@@ -157,65 +157,38 @@
</div>
</article>
<article x-show="characters.length > 0">
<article>
<header>
<h2>💼 Capacidad de inventario de shots (por peso)</h2>
<p class="text-sm text-muted">Cuántos shots de cada tipo×grado caben en el inventario según el pasivo de cada personaje. Peso máx = baseWeight × (1 + skillLevel).</p>
<h2>💼 Capacidad de inventario — Referencia (baseWeight 115.230)</h2>
<p class="text-sm text-muted">Shots que entran según skill del personaje (peso máx = 115.230 × (1 + skillLevel)). Variará si tu personaje tiene otro baseWeight.</p>
</header>
<div class="table-wrapper" style="overflow-x: auto;">
<table style="font-size: 0.75rem;">
<thead>
<tr>
<th class="cell-label text-left" rowspan="2">Personaje</th>
<th class="cell-label text-center" rowspan="2">Clase / Lv</th>
<th class="cell-label text-right" rowspan="2">Peso máx</th>
<template x-for="t in shots.TIPOS" :key="t">
<th class="cell-label text-center" colspan="5" x-text="shots.tipoShort(t)"></th>
</template>
<th class="cell-label text-right" rowspan="2">Total shots</th>
</tr>
<tr>
<template x-for="t in shots.TIPOS" :key="'h-' + t">
<template x-for="g in shots.GRADOS" :key="t + '-' + g">
<th class="cell-label text-center" x-text="g"></th>
</template>
</template>
<th class="cell-label text-left">Tipo</th>
<th class="cell-label text-center">Grado</th>
<th class="cell-label text-right">lv0 (×1)<br/><span class="text-xs text-mono" style="font-weight: normal;">115.230</span></th>
<th class="cell-label text-right">lv1 (×2)<br/><span class="text-xs text-mono" style="font-weight: normal;">230.460</span></th>
<th class="cell-label text-right">lv2 (×3)<br/><span class="text-xs text-mono" style="font-weight: normal;">345.690</span></th>
<th class="cell-label text-right">lv3 (×4)<br/><span class="text-xs text-mono" style="font-weight: normal;">460.920</span></th>
</tr>
</thead>
<tbody>
<template x-for="c in characters" :key="c.id">
<tr>
<td class="text-bold" x-text="c.name"></td>
<td class="text-muted" style="white-space: nowrap;"
x-text="c.characterClass + ' · Lv ' + c.level"></td>
<td class="text-right text-mono">
<span x-text="fmtAdena(shots.maxWeight(c))"></span>
<span class="text-xs"
:class="c.skillLevel > 0 ? 'badge-success' : 'badge-muted'"
style="margin-left: 0.25rem;"
x-text="c.skillLevel === 0 ? 'sin pasivo' : '+' + (c.skillLevel * 100) + '%'"></span>
</td>
<template x-for="t in shots.TIPOS" :key="'r-' + t">
<template x-for="g in shots.GRADOS" :key="c.id + '-' + t + '-' + g">
<td class="text-right text-mono" x-text="fmtAdena(shots.capacityOf(c, t, g))"></td>
</template>
</template>
<td class="text-right text-mono text-bold" x-text="fmtAdena(shots.totalCapacityOf(c))"></td>
</tr>
<template x-for="t in shots.TIPOS" :key="'row-' + t">
<template x-for="g in shots.GRADOS" :key="'cell-' + t + '-' + g">
<tr>
<td class="text-bold" x-text="t"></td>
<td class="text-center"><span class="grade-badge" x-text="g"></span></td>
<td class="text-right text-mono" x-text="fmtAdena(shots.referenceCapacity(t, g, 0))"></td>
<td class="text-right text-mono" x-text="fmtAdena(shots.referenceCapacity(t, g, 1))"></td>
<td class="text-right text-mono" x-text="fmtAdena(shots.referenceCapacity(t, g, 2))"></td>
<td class="text-right text-mono" x-text="fmtAdena(shots.referenceCapacity(t, g, 3))"></td>
</tr>
</template>
</template>
</tbody>
<tfoot>
<tr>
<td class="cell-label" colspan="3">Totales</td>
<template x-for="t in shots.TIPOS" :key="'f-' + t">
<template x-for="g in shots.GRADOS" :key="'f-' + t + '-' + g">
<td class="text-right text-mono text-bold" x-text="fmtAdena(columnTotals[t + '-' + g])"></td>
</template>
</template>
<td class="text-right text-mono text-bold" x-text="fmtAdena(rowTotal())"></td>
</tr>
</tfoot>
</table>
</div>
</article>
@@ -228,11 +201,11 @@
</p>
</footer>
<script src="/static/js/defaults.js?v=6"></script>
<script src="/static/js/api.js?v=6"></script>
<script src="/static/js/shots.js?v=6"></script>
<script src="/static/js/app.js?v=6"></script>
<script defer src="/static/js/alpine.min.js?v=6"></script>
<script src="/static/js/defaults.js?v=7"></script>
<script src="/static/js/api.js?v=7"></script>
<script src="/static/js/shots.js?v=7"></script>
<script src="/static/js/app.js?v=7"></script>
<script defer src="/static/js/alpine.min.js?v=7"></script>
<script>
document.addEventListener('alpine:init', () => {
@@ -266,7 +239,6 @@
async loadCharacters() {
try {
this.characters = await window.api.listCharacters();
this.updateColumnTotals();
} catch (e) {
this.error = e.message || 'Error cargando personajes';
} finally {
@@ -302,47 +274,9 @@
}
},
tipoShort(tipo) {
return window.shots.tipoShort(tipo);
},
maxWeightOf(c) {
return window.shots.maxWeight(c);
},
capacityOf(c, tipo, grado) {
return window.shots.capacityOf(c, tipo, grado);
},
totalCapacityOf(c) {
return window.shots.totalCapacityOf(c);
},
columnTotals: {},
rowTotal() {
let total = 0;
for (const c of this.characters) {
total += window.shots.totalCapacityOf(c);
}
return total;
},
updateColumnTotals() {
const totals = {};
for (const t of window.shots.TIPOS) {
for (const g of window.shots.GRADOS) {
let sum = 0;
for (const c of this.characters) {
sum += window.shots.capacityOf(c, t, g);
}
totals[t + '-' + g] = sum;
}
}
this.columnTotals = totals;
},
async updateLevel(c) {
}, async updateLevel(c) {
if (c.level <= 0 || c.level > 100) {
c.level = Math.min(100, Math.max(1, c.level));
}
@@ -360,7 +294,6 @@
c.skillLevel = sk;
try {
await window.api.updateCharacterWeight(c.id, bw, sk);
this.updateColumnTotals();
} catch (e) {
this.error = e.message || 'Error al actualizar peso/skill';
}