diff --git a/plugins/srd-aedifex-router/specimen.js b/plugins/srd-aedifex-router/specimen.js index 73f0ae4..6c44d7d 100644 --- a/plugins/srd-aedifex-router/specimen.js +++ b/plugins/srd-aedifex-router/specimen.js @@ -15,10 +15,62 @@ function readSpecimens(collection, v) { for (let s of v.specimens) { // Assign file family to specimen type just for sorting simplicity. s.type = v.family + s.combatvalue = calculateCV(s) collection.insert(s) } } +function calculateCV(t) { + if (!t) return 0 + if (t.combatvalue) return t.combatvalue + let v = 0 + if (t.health) { + v += 1 + t.health/2 + } + if(t.move) { + v += t.move + } + if (t.attack) { + v += t.attack + } + if (Array.isArray(t.attacks) && t.attacks.length > 0) { + let avgDmg = 0 + let avgAtk = 0 + let hasOpportunity = 0 + for (let a of t.attacks) { + let aDmg = 0 + for (let d of a.damage) { + aDmg += d.value + } + avgDmg += aDmg / a.damage.length + avgAtk += a.attack + if (a.opportunistic) { + hasOpportunity = 1 + } + } + avgDmg /= t.attacks.length + avgAtk /= t.attacks.length + v += avgDmg / avgAtk + hasOpportunity + } + if (Array.isArray(t.defenses)) { + let maxDef = 0 + let defs = t.defenses.length + let perfects = 0 + for (let d of t.defenses) { + if (d.perfect) { + perfects++ + } + maxDef = Math.max(maxDef, d.value) + } + v += maxDef + defs + perfects + } + if (Array.isArray(t.specials)) { + v += t.specials.length + } + + return Math.round(v) +} + module.exports = { readSpecimens, } diff --git a/public/style.css b/public/style.css index 2932e90..dba0ca5 100644 --- a/public/style.css +++ b/public/style.css @@ -343,3 +343,7 @@ td:last-child { cursor: copy; text-align: center; } + +small { + font-size: 70%; +} \ No newline at end of file diff --git a/views/tables.dot b/views/tables.dot index 5998ae2..3b3204d 100644 --- a/views/tables.dot +++ b/views/tables.dot @@ -159,11 +159,12 @@ Sort: Name Worth #}} {{##def.specimens_table_entry:item: -

{{=item.name || ''}}

+

{{=item.name || ''}}

{{=item.description || ''}}

Move {{=item.move || ''}}; Attack {{=item.attack || ''}}; -Health {{=item.health || ''}} () +Health {{=item.health || ''}} (); +CV {{=item.combatvalue || ''}}

Attacks

{{~item.attacks :attack}}

{{=attack.name || 'unknown'}} ({{=attack.attacktype || 'melee' }})