Commit 042ce6fb authored by Shaun Kichenbrand's avatar Shaun Kichenbrand

refactoring

parent 9d0bfd7b
......@@ -81,6 +81,10 @@ module.exports = {
return;
}
this.completeGathering(gathering, isFish);
},
completeGathering: function (gathering, isFish) {
let resourceNode = gathering.resourceNode;
let gatherResult = extend({
obj: gathering
......
......@@ -137,6 +137,49 @@ module.exports = {
}
},
sendPrivateMessage: function (messageString) {
let playerName = '';
//Check if there's a space in the name
if (messageString[1] === "'") {
playerName = messageString.substring(2, messageString.indexOf("'", 2));
messageString = messageString.replace("@'" + playerName + "' ", '');
} else {
playerName = messageString.substring(1, messageString.indexOf(' '));
messageString = messageString.replace('@' + playerName + ' ', '');
}
if (playerName === this.obj.name)
return;
let target = cons.players.find(p => p.name === playerName);
if (!target)
return;
this.obj.socket.emit('event', {
event: 'onGetMessages',
data: {
messages: [{
class: 'color-yellowB',
message: '(you to ' + playerName + '): ' + messageString,
type: 'chat',
source: this.obj.name
}]
}
});
target.socket.emit('event', {
event: 'onGetMessages',
data: {
messages: [{
class: 'color-yellowB',
message: '(' + this.obj.name + ' to you): ' + messageString,
type: 'chat',
source: this.obj.name
}]
}
});
},
chat: function (msg) {
if (!msg.data.message)
return;
......@@ -201,48 +244,9 @@ module.exports = {
};
events.emit('onBeforeSendMessage', msgEvent);
messageString = msgEvent.msg;
if (messageString[0] === '@') {
let playerName = '';
//Check if there's a space in the name
if (messageString[1] === "'") {
playerName = messageString.substring(2, messageString.indexOf("'", 2));
messageString = messageString.replace("@'" + playerName + "' ", '');
} else {
playerName = messageString.substring(1, messageString.indexOf(' '));
messageString = messageString.replace('@' + playerName + ' ', '');
}
if (playerName === this.obj.name)
return;
let target = cons.players.find(p => p.name === playerName);
if (!target)
return;
this.obj.socket.emit('event', {
event: 'onGetMessages',
data: {
messages: [{
class: 'color-yellowB',
message: '(you to ' + playerName + '): ' + messageString,
type: 'chat',
source: this.obj.name
}]
}
});
target.socket.emit('event', {
event: 'onGetMessages',
data: {
messages: [{
class: 'color-yellowB',
message: '(' + this.obj.name + ' to you): ' + messageString,
type: 'chat',
source: this.obj.name
}]
}
});
} else if (messageString[0] === '$')
if (messageString[0] === '@')
this.sendPrivateMessage(messageString);
else if (messageString[0] === '$')
this.sendCustomChannelMessage(msg);
else if (messageString[0] === '%')
this.sendPartyMessage(msg);
......
......@@ -6,6 +6,8 @@ let globalZone = require('../config/zoneBase');
let randomMap = require('./randomMap');
let events = require('../misc/events');
const mapObjects = require('./map/mapObjects');
let mapFile = null;
let mapScale = null;
let padding = null;
......@@ -370,34 +372,8 @@ module.exports = {
} else if (cell.width === 24)
blueprint.x++;
if (cell.polyline) {
let lowX = this.size.w;
let lowY = this.size.h;
let highX = 0;
let highY = 0;
blueprint.area = cell.polyline.map(function (v) {
let x = ~~((v.x + cell.x) / mapScale);
let y = ~~((v.y + cell.y) / mapScale);
if (x < lowX)
lowX = x;
if (x > highX)
highX = x;
if (y < lowY)
lowY = y;
if (y > highY)
highY = y;
return [x, y];
});
blueprint.x = lowX;
blueprint.y = lowY;
blueprint.width = (highX - lowX);
blueprint.height = (highY - lowY);
}
if (cell.polyline)
mapObjects.polyline(this.size, blueprint, cell, mapScale);
if (layerName === 'rooms') {
if (blueprint.properties.exit) {
......
module.exports = {
polyline: function (size, blueprint, cell, mapScale) {
let lowX = size.w;
let lowY = size.h;
let highX = 0;
let highY = 0;
blueprint.area = cell.polyline.map(function (v) {
let x = ~~((v.x + cell.x) / mapScale);
let y = ~~((v.y + cell.y) / mapScale);
if (x < lowX)
lowX = x;
if (x > highX)
highX = x;
if (y < lowY)
lowY = y;
if (y > highY)
highY = y;
return [x, y];
});
blueprint.x = lowX;
blueprint.y = lowY;
blueprint.width = (highX - lowX);
blueprint.height = (highY - lowY);
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment