Ver código fonte

closes #792

tags/v0.6^2
Shaun 4 anos atrás
pai
commit
db47714254
2 arquivos alterados com 33 adições e 42 exclusões
  1. +0
    -11
      src/client/ui/templates/middleHud/middleHud.js
  2. +33
    -31
      src/server/components/gatherer.js

+ 0
- 11
src/client/ui/templates/middleHud/middleHud.js Ver arquivo

@@ -14,11 +14,6 @@ define([
this.onEvent('onGetSelfCasting', this.onGetCasting.bind(this));

if (isMobile) {
this.onEvent('onEnterGatherNode', this.toggleGatherButton.bind(this, true));
this.onEvent('onExitGatherNode', this.toggleGatherButton.bind(this, false));
this.onEvent('onRespawn', this.toggleGatherButton.bind(this, false));
this.onEvent('onShowProgress', this.toggleGatherButton.bind(this, false));

this.onEvent('onGetServerActions', this.onGetServerActions.bind(this));

this.find('.btnGather').on('click', this.gather.bind(this));
@@ -38,12 +33,6 @@ define([
}
},

toggleGatherButton: function (show) {
let btn = this.find('.btnGather').hide();
if (show)
btn.show();
},

gather: function () {
let btn = this.find('.btnGather');
let action = btn.data('action');


+ 33
- 31
src/server/components/gatherer.js Ver arquivo

@@ -187,6 +187,7 @@ module.exports = {
this.sendAnnouncement('The school has been depleted');

this.nodes.spliceWhere(n => (n === gathering));
this.updateServerActions(false);
}

this.gathering = null;
@@ -201,36 +202,33 @@ module.exports = {
},

enter: function (node) {
const { obj } = this;

let gatherResult = extend({
nodeName: node.name
});
this.obj.instance.eventEmitter.emitNoSticky('beforeEnterPool', gatherResult, this.obj);
obj.instance.eventEmitter.emitNoSticky('beforeEnterPool', gatherResult, obj);

let nodeType = node.resourceNode.nodeType;
let msg = `Press G to $ (${gatherResult.nodeName})`;
msg = msg.replace('$', {
herb: 'gather',
fish: 'fish for'
}[nodeType]);

if (nodeType === 'fish') {
if (!this.obj.equipment.eq.has('tool'))
msg = 'You need a fishing rod to fish';
if (!obj.equipment.eq.has('tool')) {
this.sendAnnouncement('You need a fishing rod to fish');

return;
}
}

this.sendAnnouncement(msg);
this.updateServerActions(true);

process.send({
method: 'events',
data: {
onEnterGatherNode: [{
obj: {
id: node.id
},
to: [this.obj.serverId]
}]
}
});
let action = null;
if (nodeType === 'fish')
action = 'fish for';
else if (nodeType === 'herb')
action = 'gather the';
const actionString = `${action} ${gatherResult.nodeName}`;

this.sendAnnouncement(`Press U to ${actionString}`);

this.nodes.spliceWhere(n => (n === node));
this.nodes.push(node);
@@ -240,17 +238,7 @@ module.exports = {
if (!this.nodes.includes(node))
return;

process.send({
method: 'events',
data: {
onExitGatherNode: [{
obj: {
id: node.id
},
to: [this.obj.serverId]
}]
}
});
this.updateServerActions(false);

this.nodes.spliceWhere(n => (n === node));
},
@@ -269,6 +257,20 @@ module.exports = {
});
},

updateServerActions: function (isAdd) {
const { obj } = this;

const action = isAdd ? 'addActions' : 'removeActions';
obj.syncer.setArray(true, 'serverActions', action, {
key: 'u',
action: {
targetId: obj.id,
cpn: 'gatherer',
method: 'gather'
}
});
},

events: {
beforeRezone: function () {
this.events.beforeMove.call(this);


Carregando…
Cancelar
Salvar