aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/static/mobeditor.js
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-01 16:37:45 -0400
committerhistoria <[not public]>2026-07-01 16:37:45 -0400
commite6b4cb9f5816c6ee239233bc85f74ee446a161c2 (patch)
tree1c3bf71c8b7f095baae989afe5e33183a7ed3929 /internal/admin/static/mobeditor.js
parent649ef4b7416ce7053145878841fc9b0bff2f5fec (diff)
downloadthehouseoficarus-e6b4cb9f5816c6ee239233bc85f74ee446a161c2.tar.gz
feat: shop system overhauled, gui conversation tree editor overhauled
Diffstat (limited to 'internal/admin/static/mobeditor.js')
-rw-r--r--internal/admin/static/mobeditor.js32
1 files changed, 28 insertions, 4 deletions
diff --git a/internal/admin/static/mobeditor.js b/internal/admin/static/mobeditor.js
index a65e578..59eb16c 100644
--- a/internal/admin/static/mobeditor.js
+++ b/internal/admin/static/mobeditor.js
@@ -90,6 +90,24 @@ var MOB_SECTIONS = [
fields: []
},
{
+ id: 'shop', label: 'Shop', path: 'shop',
+ detect: function(d) { return !!d.shop; },
+ fields: [
+ ['message', 'Greeting', 'text', 'What would you like to buy or sell?'],
+ ['buy_percentage', 'Buy %', 'number', '40', 'narrow'],
+ ['change_percentage', 'Change %', 'number', '3', 'narrow'],
+ ['restock_ticks', 'Restock Ticks', 'number', '', 'narrow'],
+ ['buys_anything', 'Buys Anything', 'checkbox'],
+ ],
+ subtables: [
+ {label:'Items', key:'items', addLabel:'+ Add Item', fields:[
+ ['item_id', 'Item ID', 'search', '', '', null, 'items'],
+ ['stock', 'Stock', 'number', '', 'narrow'],
+ ['restock_ticks', 'Restock Ticks', 'number', '', 'narrow'],
+ ]}
+ ]
+ },
+ {
id: 'drops', label: 'Drops', path: 'drops',
detect: function(d) { return d.drops && (d.drops.remains || (d.drops.loot && d.drops.loot.length > 0)); },
fields: [
@@ -197,7 +215,7 @@ function renderCurrent() {
function renderMobCard(sec, data) {
var collapsed = expandedCards[sec.id] === false;
- var h = '<div class="obj-card" data-card="' + sec.id + '">';
+ var h = '<div class="obj-card' + (sec.id === 'talk' ? ' obj-card-full' : '') + '" data-card="' + sec.id + '">';
h += '<div class="obj-card-header" onclick="toggleMobCard(\'' + sec.id + '\')">';
h += '<span class="obj-card-arrow">' + (collapsed ? '&#9654;' : '&#9660;') + '</span>';
h += '<span class="obj-card-label">' + sec.label + '</span>';
@@ -336,7 +354,7 @@ function renderMobSubtable(sec, st, data) {
h += '</div>';
});
if (!st.single || arr.length === 0) {
- h += '<button class="btn btn-sm obj-sub-add" onclick="addMobSubRow(\'' + sec.id + '\',\'' + st.key + '\')">+ Add Loot</button>';
+ h += '<button class="btn btn-sm obj-sub-add" onclick="addMobSubRow(\'' + sec.id + '\',\'' + st.key + '\')">' + esc(st.addLabel || '+ Add') + '</button>';
}
h += '</div>';
return h;
@@ -374,7 +392,9 @@ function mobAddSection() {
if (sec.id === 'drops') {
mobData[sec.path] = {remains:'', loot:[]};
} else if (sec.id === 'talk') {
- mobData[sec.path] = {nodes:{start:{message:'',options:[]}}};
+ mobData[sec.path] = {nodes:{start:{messages:[],options:[]}}};
+ } else if (sec.id === 'shop') {
+ mobData[sec.path] = {buy_percentage:40, change_percentage:3, buys_anything:true, items:[]};
} else {
mobData[sec.path] = {};
}
@@ -467,7 +487,11 @@ function saveMob() {
API.put('/api/mobs/' + encodeURIComponent(mobID), out).then(function(resp) {
notify('Mob ' + mobID + ' saved', 'success');
updateUndoBar();
- if (resp && resp._raw) mobData._raw = resp._raw;
+ if (resp && resp._raw) {
+ mobData._raw = resp._raw;
+ var pre = document.querySelector('#tabYaml pre');
+ if (pre) pre.textContent = mobData._raw;
+ }
}).catch(function(e) { notify('Save failed: ' + e.message, 'error'); });
}