gammatools/web/assets/js/createAttacksSection.js

21 lines
738 B
JavaScript
Raw Normal View History

import {formatDiceMnemonic} from "./formatDiceMnemonic.js";
export function createAttacksSection(data) {
// Attacks section
let attacks = document.createElement('div');
attacks.className = 'creature_attacks';
let attacksHTML = '<h3>Attacks</h3>';
let attacksTable = '<table>';
for (let attack in data.attacks) {
let mnemonic_display;
mnemonic_display = formatDiceMnemonic(data.attacks[attack]);
if (mnemonic_display === "0d0") {
mnemonic_display = 'See Description';
}
attacksTable += `<tr><td><b>${attack}</b></td><td>${mnemonic_display}</td></tr>`
}
attacksTable += '</table>';
attacks.innerHTML = attacksHTML + attacksTable;
return attacks
}