Browse Source

removed unused code in ui/stash and allowed dialogue methods to be async

tags/v0.14.0^2
Shaun 4 months ago
parent
commit
6f8e57621f
2 changed files with 8 additions and 18 deletions
  1. +0
    -12
      src/client/ui/templates/stash/stash.js
  2. +8
    -6
      src/server/components/dialogue.js

+ 0
- 12
src/client/ui/templates/stash/stash.js View File

@@ -112,18 +112,6 @@ define([
events.emit('onShowItemTooltip', item, ttPos, true); events.emit('onShowItemTooltip', item, ttPos, true);
}, },


onClick: function (el, item) {
client.request({
cpn: 'player',
method: 'performAction',
data: {
cpn: 'equipment',
method: 'equip',
data: item.id
}
});
},

onGetStashItems: function (items) { onGetStashItems: function (items) {
this.items = items; this.items = items;




+ 8
- 6
src/server/components/dialogue.js View File

@@ -15,7 +15,7 @@ module.exports = {
this.trigger.destroyed = true; this.trigger.destroyed = true;
}, },


talk: function (msg) {
talk: async function (msg) {
if (!msg) if (!msg)
return false; return false;


@@ -41,7 +41,7 @@ module.exports = {
if ((target.trade) && (target.trade.faction)) if ((target.trade) && (target.trade.faction))
this.obj.reputation.discoverFaction(target.trade.faction.id); this.obj.reputation.discoverFaction(target.trade.faction.id);


let state = target.dialogue.getState(this.obj, msg.state);
let state = await target.dialogue.getState(this.obj, msg.state);
if (!state) { if (!state) {
this.obj.syncer.set(true, 'dialogue', 'state', null); this.obj.syncer.set(true, 'dialogue', 'state', null);
return false; return false;
@@ -54,7 +54,8 @@ module.exports = {
this.obj.syncer.set(true, 'dialogue', 'state', null); this.obj.syncer.set(true, 'dialogue', 'state', null);
}, },


getState: function (sourceObj, state = 1) {
/* eslint-disable-next-line max-lines-per-function */
getState: async function (sourceObj, state = 1) {
let result = null; let result = null;
if ((state + '').indexOf('.') > -1) { if ((state + '').indexOf('.') > -1) {
let config = this.states[(state + '').split('.')[0]]; let config = this.states[(state + '').split('.')[0]];
@@ -93,8 +94,9 @@ module.exports = {


if (stateConfig.goto) { if (stateConfig.goto) {
if (result) if (result)
return this.getState(sourceObj, stateConfig.goto.success);
return this.getState(sourceObj, stateConfig.goto.failure);
return await this.getState(sourceObj, stateConfig.goto.success);

return await this.getState(sourceObj, stateConfig.goto.failure);
} }
if (result) { if (result) {
useMsg = extend([], useMsg); useMsg = extend([], useMsg);
@@ -102,7 +104,7 @@ module.exports = {
} else } else
return null; return null;
} else if (stateConfig.method) { } else if (stateConfig.method) {
let methodResult = stateConfig.method.call(this.obj, sourceObj);
let methodResult = await stateConfig.method.call(this.obj, sourceObj);
if (methodResult) { if (methodResult) {
useMsg = extend([], useMsg); useMsg = extend([], useMsg);
useMsg[0].msg = methodResult; useMsg[0].msg = methodResult;


Loading…
Cancel
Save