Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | 6x 6x 6x 6x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 6x | import { createTitle, paginateTable } from "../helper";
import { Encounter } from "../@models";
export const loadEncounters = (body: HTMLBodyElement, encounters: Encounter[]): void => {
createTitle("Encounters", body);
// console.table(encounters);
const table = document.createElement("table");
table.id = "encounters";
const tableHeader = document.createElement("thead");
const firstRow = document.createElement("tr");
const scenario = document.createElement("th");
scenario.innerText = "Scenario";
const module = document.createElement("th");
module.innerText = "Modular Sets";
const difficulty = document.createElement("th");
difficulty.innerText = "Difficulty";
const hero1 = document.createElement("th");
hero1.innerText = "Hero 1";
const hero2 = document.createElement("th");
hero2.innerText = "Hero 2";
const hero3 = document.createElement("th");
hero3.innerText = "Hero 3";
const hero4 = document.createElement("th");
hero4.innerText = "Hero 4";
const result = document.createElement("th");
result.innerText = "Result";
firstRow.appendChild(scenario);
firstRow.appendChild(module);
firstRow.appendChild(difficulty);
firstRow.appendChild(hero1);
firstRow.appendChild(hero2);
firstRow.appendChild(hero3);
firstRow.appendChild(hero4);
firstRow.appendChild(result);
tableHeader.appendChild(firstRow);
table.appendChild(tableHeader);
const tableBody = document.createElement("tbody");
// load encounters
encounters.forEach((encounter) => {
const row = document.createElement("tr");
const scenario = document.createElement("td");
scenario.innerText = encounter.scenario.name;
const module = document.createElement("td");
module.innerText =
null != encounter.modularSets ? encounter.modularSets.map((modularSet) => modularSet.name).join(", ") : "";
const difficulty = document.createElement("td");
difficulty.innerText = encounter.difficulty;
const hero1 = document.createElement("td");
hero1.innerText = `${encounter.heroes[0].name}`;
const hero2 = document.createElement("td");
hero2.innerText = null != encounter.heroes[1] ? `${encounter.heroes[1]?.name}` : "";
const hero3 = document.createElement("td");
hero3.innerText = null != encounter.heroes[2] ? `${encounter.heroes[2]?.name}` : "";
const hero4 = document.createElement("td");
hero4.innerText = null != encounter.heroes[3] ? `${encounter.heroes[3]?.name}` : "";
const result = document.createElement("td");
result.innerText = encounter.result;
row.appendChild(scenario);
row.appendChild(module);
row.appendChild(difficulty);
row.appendChild(hero1);
row.appendChild(hero2);
row.appendChild(hero3);
row.appendChild(hero4);
row.appendChild(result);
tableBody.appendChild(row);
});
table.appendChild(tableBody);
body.appendChild(table);
paginateTable("#encounters", 10);
};
|