diff options
Diffstat (limited to 'internal/admin/static/mobeditor.js')
| -rw-r--r-- | internal/admin/static/mobeditor.js | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/internal/admin/static/mobeditor.js b/internal/admin/static/mobeditor.js index 5e2b9cc..05d33da 100644 --- a/internal/admin/static/mobeditor.js +++ b/internal/admin/static/mobeditor.js @@ -11,8 +11,8 @@ var MOB_SECTIONS = [ fields: [ ['name', 'Name', 'text', 'spaceport attendant'], ['description', 'Description', 'textarea', 'A lanky man in a wrinkled grey uniform.'], - ['unique', 'Unique', 'checkbox'], - ['protected', 'Protected', 'checkbox'], + ['unique', 'Unique', 'checkbox', '', '', null, null, 'Mob name is displayed without an article (e.g. "John Smith" instead of "a John Smith")'], + ['protected', 'Protected', 'checkbox', '', '', null, null, 'Cannot be attacked.'], ], inline: [ {label:'Idle Descriptions', key:'idle_descriptions', type:'tags'}, @@ -53,7 +53,6 @@ var MOB_SECTIONS = [ ['size', 'Size', 'text', 'small'], ], inline: [ - {label:'Combat Descriptions', key:'combat_descriptions', type:'tags'}, ] }, { @@ -437,9 +436,23 @@ function renderMobCombatCard(data) { h += renderMobField(sec, byKey['damage_without'], data, -1); h += '</div>'; - sec.inline.forEach(function(il) { - h += ced_renderTags(sec, il, data); + var combat = data.combat || {}; + var combatDescs = Array.isArray(combat.combat_descriptions) ? combat.combat_descriptions : []; + var cdgid = 'cdg_combat'; + var hasCD = combatDescs.length > 0; + h += '<div class="obj-inline-group" id="' + cdgid + '"' + (hasCD ? '' : ' style="display:none"') + '>'; + h += '<div style="display:flex;align-items:center;margin-bottom:4px">'; + h += '<span class="obj-inline-label" style="margin-bottom:0;flex:1">Combat Descriptions</span>'; + h += '<button class="btn btn-sm btn-danger" style="padding:2px 6px;font-size:10px;min-width:auto" onclick="var g=document.getElementById(\'' + cdgid + '\');g.style.display=\'none\';var b=document.getElementById(\'' + cdgid + '_btn\');b.style.display=\'block\';var list=g.querySelector(\'.obj-combat-desc-list\');while(list.firstChild)list.firstChild.remove()">X</button>'; + h += '</div>'; + h += '<div class="obj-combat-desc-list">'; + combatDescs.forEach(function(desc) { + h += '<div class="obj-combat-desc-row" style="display:flex;align-items:center;gap:4px;margin-bottom:4px"><input class="obj-combat-desc" value="' + escAttr(desc) + '" placeholder="e.g. slashes at %s with a blade" style="flex:1"><button class="btn btn-sm btn-danger" style="padding:2px 6px;font-size:10px;min-width:auto" onclick="this.parentElement.remove()">X</button></div>'; }); + h += '</div>'; + h += '<button class="btn btn-sm obj-sub-add" onclick="addCombatDescRow(\'' + cdgid + '\')">+ Add</button>'; + h += '</div>'; + h += '<button class="btn btn-sm obj-sub-add" id="' + cdgid + '_btn"' + (hasCD ? ' style="display:none"' : '') + ' onclick="var b=document.getElementById(\'' + cdgid + '_btn\');b.style.display=\'none\';var g=document.getElementById(\'' + cdgid + '\');g.style.display=\'block\';addCombatDescRow(\'' + cdgid + '\')">+ Add Combat Descriptions</button>'; return h; } @@ -834,6 +847,16 @@ function addMobLootRow(cardID, subKey, kind) { renderCurrent(); } +function addCombatDescRow(cdgid) { + var list = document.querySelector('#' + cdgid + ' .obj-combat-desc-list'); + if (!list) return; + var row = document.createElement('div'); + row.className = 'obj-combat-desc-row'; + row.style.cssText = 'display:flex;align-items:center;gap:4px;margin-bottom:4px'; + row.innerHTML = '<input class="obj-combat-desc" value="" placeholder="e.g. slashes at %s with a blade" style="flex:1"><button class="btn btn-sm btn-danger" style="padding:2px 6px;font-size:10px;min-width:auto" onclick="this.parentElement.remove()">X</button>'; + list.appendChild(row); +} + // ---- Save ---- function saveMob() { @@ -901,6 +924,17 @@ function saveMob() { 'stats.bonuses.science_percent_bonus','stats.bonuses.ranged_bonus','stats.bonuses.ranged_strength_bonus']; taskStrip.forEach(function(k) { delete sectionObj[k]; }); } + var descRows = document.querySelectorAll('.obj-combat-desc'); + if (descRows.length > 0) { + var descs = []; + descRows.forEach(function(inp) { + var v = inp.value.trim(); + if (v) descs.push(v); + }); + if (descs.length > 0) { + sectionObj['combat_descriptions'] = descs; + } + } } if (sec.subtables) { |
