Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* HTML Template Asset: "entity table.html" */
- <table class="outertable" style="width: 50vw; height: 100vh;" ><tbody class="outertable">
- <tr class="outertable"><td class="bevel-border outertable" colspan="3">
- <table class="outertable" style="width:100%;"><tbody class="outertable">
- <tr class="outertable"><td class="bevel-border lefttable" colspan="2">card</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">namesake</td><td class="bevel-border lefttable">"{{ @card::.namesake }}"</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">graphic</td><td class="bevel-border lefttable"><img src="http://{{ host }}/GFX/{{ @card::.graphic }}____.png" alt="{{ @card::.graphic }}"></td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">action</td><td class="bevel-border lefttable">{{ @card::.action }}</td></tr>
- </tbody></table>
- </td></tr>
- <tr class="outertable"><td>
- <table class="outertable" style="width:100%;"><tbody class="outertable">
- <tr class="outertable"><td class="bevel-border lefttable" colspan="2">health</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">current</td><td class="bevel-border righttable">{{ @health::.current }}</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">maximum</td><td class="bevel-border righttable">{{ @health::.maximum }}</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">recovery</td><td class="bevel-border righttable">{{ @health::.recovery }}</td></tr>
- </tbody></table>
- </td><td>
- <table class="outertable" style="width:100%;"><tbody class="outertable">
- <tr class="outertable"><td class="bevel-border lefttable" colspan="2">stamina</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">current</td><td class="bevel-border righttable">{{ @stamina::.current }}</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">maximum</td><td class="bevel-border righttable">{{ @stamina::.maximum }}</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">recovery</td><td class="bevel-border righttable">{{ @stamina::.recovery }}</td></tr>
- </tbody></table>
- </td><td>
- <table class="outertable" style="width:100%;"><tbody class="outertable">
- <tr class="outertable"><td class="bevel-border lefttable" colspan="2">essence</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">current</td><td class="bevel-border righttable">{{ @essence::.current }}</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">maximum</td><td class="bevel-border righttable">{{ @essence::.maximum }}</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">recovery</td><td class="bevel-border righttable">{{ @essence::.recovery }}</td></tr>
- </tbody></table>
- </td></tr>
- <tr class="outertable"><td>
- <table class="outertable" style="width:100%;"><tbody class="outertable">
- <tr class="outertable"><td class="bevel-border lefttable" colspan="2">combat</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">piercing</td><td class="bevel-border righttable">{{ @combat::.piercing }}</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">armored</td><td class="bevel-border righttable">{{ @combat::.armored }}</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">evasion</td><td class="bevel-border righttable">{{ @combat::.evasion }}</td></tr>
- </tbody></table>
- </td><td>
- <table class="outertable" style="width:100%;"><tbody class="outertable">
- <tr class="outertable"><td class="bevel-border lefttable" colspan="2">skill</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">level</td><td class="bevel-border righttable">{{ @skill::.level }}</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">experience</td><td class="bevel-border righttable">{{ @skill::.experience }}</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">appraisal</td><td class="bevel-border righttable">{{ @skill::.appraisal }}</td></tr>
- </tbody></table>
- </td><td>
- <table class="outertable" style="width:100%;"><tbody class="outertable">
- <tr class="outertable"><td class="bevel-border lefttable" colspan="2">affinity</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable">identity</td><td class="bevel-border righttable">{{ @affinity::.identity }}</td></tr>
- <tr class="outertable"><td class="bevel-border lefttable" colspan="2"> </td></tr>
- <tr class="outertable"><td class="bevel-border lefttable" colspan="2"> </td></tr>
- </tbody></table>
- </td></tr>
- </tbody></table>
- /* JSON Spreadsheet Asset: "pndx.js" */
- {
- "pndx": {
- "stats": {
- "card": {
- "namesake": "Poindexter",
- "action": "wstf",
- "graphic": "pndx"
- },
- "affinity": {
- "identity": 5
- },
- "health": {
- "current": 30,
- "maximum": 30,
- "recovery": 0
- },
- "stamina": {
- "current": 90,
- "maximum": 90,
- "recovery": 3
- },
- "essence": {
- "current": 0,
- "maximum": 30,
- "recovery": 0.1
- },
- "combat": {
- "armored": 2,
- "piercing": 2,
- "evasion": 0.07
- },
- "skill": {
- "experience": 10,
- "level": 1,
- "appraisal": 0
- },
- },
- "dice": {
- "rolls": {
- "dust": "ROLL(1d2)"
- },
- "reward": {
- "ON(dust);EQU;2": [
- "card::action;&=;dust"
- ]
- }
- }
- }
- }
- /* Js Script: "files.js" */
- function loadDocument(filePath) {
- var xhr = new XMLHttpRequest();
- xhr.open("GET", filePath, false); // 'false' makes the request synchronous
- xhr.setRequestHeader("Accept", "text/plain");
- xhr.send(null);
- if (xhr.status === 200) {
- return xhr.responseText;
- } else {
- throw new Error('Error loading document: ' + xhr.status);
- }
- }
- function loadJSON(filePath) {
- var xhr = new XMLHttpRequest();
- xhr.open("GET", filePath, false); // 'false' makes the request synchronous
- xhr.setRequestHeader("Accept", "application/json");
- xhr.send(null);
- if (xhr.status === 200) {
- return JSON.parse(xhr.responseText);
- } else {
- throw new Error('Error loading JSON file: ' + xhr.status);
- }
- }
- // return;
- async function loadFullMap() {
- // Load the full map
- const full_map = await fetch(`http://${host}/maps/roe2a/${map}.json`).then(response => response.json());
- // Initialize full_stats array
- const full_stats = [];
- for (let x = 0; x < full_map.length; x++) {
- full_stats[x] = []; // Initialize the second dimension
- for (let y = 0; y < full_map[x].length; y++) {
- full_stats[x][y] = []; // Initialize the third dimension
- for (let z = 0; z < layers.gui; z++) {
- const sectionValue = section(full_map[x][y][z], 0);
- const url = `http://${host}/entity dictionary/json/${sectionValue}.json`;
- if(preloaded.indexOf(sectionValue) !== -1){
- full_stats[x][y][z] = preloaded[section(full_map[x][y][z],0)];
- continue;
- }
- full_stats[x][y][z] = preloaded[section(full_map[x][y][z],0)];
- // Check if the file exists before fetching it
- if (await fileExists(url)) {
- full_stats[x][y][z] = await fetch(url).then(response => response.json());
- } else {
- // console.warn(`File not found: ${url}`);
- full_stats[x][y][z] = null; // or handle the missing file case as needed
- continue;
- }
- // Capture the first key
- const keys = layers.Object.keys(full_stats[x][y][z]);
- if (keys.length === 0) {
- full_stats[x][y][z] = null;
- continue;
- }
- const key = keys[0];
- if ( key === section( full_map[x][y][z], 0 ) ){
- preloaded[section(full_map[x][y][z],0)] = full_stats[x][y][z][section(full_map[x][y][z],0)];
- }else{
- preloaded[section(full_map[x][y][z],0)] = null;
- }
- }
- }
- }
- return full_stats;
- }
- // Function to check if a file exists using a HEAD request
- async function fileExists(url) {
- try {
- // const response = await fetch(url, { method: 'HEAD' });
- return response.ok;
- } catch (error) {
- // console.error(`Error checking file existence: ${error}`);
- return false;
- }
- }
- /* Js Script: "ini stats.js" */
- var entities = [];
- var defaultStats = [];
- function loadStats(){
- entities =
- {
- terrain: ['dirt','hole','watr','stps','stpw'],
- critter: ['dtby','spdr','grml','imp_','emgd','shkt','pndx'],
- object: ['door','wall','bldr','ccts','chst','pwch'],
- ailment: ['web_','wing','cure','vnom','fire','loc1','loc2','loc3','dust','zzzz']
- };
- defaultStats = [];
- for (let index = 0; index < entities.critter.length; index++) {
- const url = `http://${host}/entity%20dictionary/json/${section(entities.critter[index], 0)}.json`;
- console.log(url);
- const jsonData = loadJSON(url);
- defaultStats.push(jsonData);
- }
- console.log(defaultStats);
- }
- /* Js Script: "generate tray stats.js" */
- function generateTrayStats ([x,y,z]){
- if(oob([x,y]) !== true){
- return false;
- }
- if(z !== layers.critter){
- return false;
- }
- full_stats[x][y][z] = defaultStats[section(full_map[x][y][z],0)];
- ledger = prefabLedger;
- ledger = ledger.replace(/@card::.namesake/, `${full_stats[x][y].card.namesake}`);
- ledger = ledger.replace(/@card::.graphic/, `${full_stats[x][y].card.graphic}`);
- ledger = ledger.replace(/@card::.action/, `${full_stats[x][y].card.action}`);
- ledger = ledger.replace(/@health::.current/, `${full_stats[x][y].health.current}`);
- ledger = ledger.replace(/@health::.maximum/, `${full_stats[x][y].health.maximum}`);
- ledger = ledger.replace(/@health::.recovery/, `${full_stats[x][y].health.recovery}`);
- ledger = ledger.replace(/@stamina::.current/, `${full_stats[x][y].stamina.current}`);
- ledger = ledger.replace(/@stamina::.maximum/, `${full_stats[x][y].stamina.maximum}`);
- ledger = ledger.replace(/@stamina::.recovery/, `${full_stats[x][y].stamina.recovery}`);
- ledger = ledger.replace(/@skill::.current/, `${full_stats[x][y].skill.current}`);
- ledger = ledger.replace(/@skill::.maximum/, `${full_stats[x][y].skill.maximum}`);
- ledger = ledger.replace(/@skill::.recovery/, `${full_stats[x][y].skill.recovery}`);
- ledger = ledger.replace(/@combat::.piercing/, `${full_stats[x][y].combat.piercing}`);
- ledger = ledger.replace(/@combat::.armored/, `${full_stats[x][y].combat.armored}`);
- ledger = ledger.replace(/@combat::.evasion/, `${full_stats[x][y].combat.evasion}`);
- ledger = ledger.replace(/@skill::.level/, `${full_stats[x][y].skill.level}`);
- ledger = ledger.replace(/@skill::.experience/, `${full_stats[x][y].skill.experience}`);
- ledger = ledger.replace(/@skill::.appraisal/, `${full_stats[x][y].skill.appraisal}`);
- ledger = ledger.replace(/@affinity::.identity/, `${full_stats[x][y].affinity.identity}`);
- return ledger;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement