diff --git a/src/.eslintignore b/src/.eslintignore
index 78ed6fac..b5bab615 100644
--- a/src/.eslintignore
+++ b/src/.eslintignore
@@ -1,2 +1,3 @@
+/client/plugins/*
node_modules/*
*.json
diff --git a/src/client/js/app.js b/src/client/js/app.js
index 35f1f9aa..cd991c85 100644
--- a/src/client/js/app.js
+++ b/src/client/js/app.js
@@ -4,51 +4,51 @@ require.config({
baseUrl: '',
waitSeconds: 120,
paths: {
- 'socket': 'plugins/socket',
- 'jquery': 'plugins/jquery.min',
- 'json': 'plugins/json',
- 'text': 'plugins/text',
- 'html': 'plugins/html',
- 'css': 'plugins/css',
- 'bin': 'plugins/bin',
- 'audio': 'plugins/audio',
- 'worker': 'plugins/worker',
- 'main': 'js/main',
- 'helpers': 'js/misc/helpers',
- 'particles': 'plugins/pixi.particles',
- 'picture': 'plugins/pixi.picture',
- 'pixi': 'plugins/pixi.min',
- 'howler': 'plugins/howler.min'
+ socket: 'plugins/socket',
+ jquery: 'plugins/jquery.min',
+ json: 'plugins/json',
+ text: 'plugins/text',
+ html: 'plugins/html',
+ css: 'plugins/css',
+ bin: 'plugins/bin',
+ audio: 'plugins/audio',
+ worker: 'plugins/worker',
+ main: 'js/main',
+ helpers: 'js/misc/helpers',
+ particles: 'plugins/pixi.particles',
+ picture: 'plugins/pixi.picture',
+ pixi: 'plugins/pixi.min',
+ howler: 'plugins/howler.min'
},
shim: {
- 'howler': {
+ howler: {
exports: 'howl'
},
- 'socket': {
+ socket: {
exports: 'io'
},
- 'jquery': {
+ jquery: {
exports: '$'
},
- 'helpers': {
+ helpers: {
deps: [
'jquery'
]
},
- 'pixi': {
+ pixi: {
exports: 'PIXI'
},
- 'particles': {
+ particles: {
deps: [
'pixi'
]
},
- 'picture': {
+ picture: {
deps: [
'pixi'
]
},
- 'main': {
+ main: {
deps: [
'helpers',
'js/input'
diff --git a/src/client/js/components/aggro.js b/src/client/js/components/aggro.js
index 6360c378..bcb00eeb 100644
--- a/src/client/js/components/aggro.js
+++ b/src/client/js/components/aggro.js
@@ -1,9 +1,9 @@
define([
-], function(
+], function (
) {
return {
type: 'aggro'
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/animation.js b/src/client/js/components/animation.js
index 4a9c5181..1b10bf63 100644
--- a/src/client/js/components/animation.js
+++ b/src/client/js/components/animation.js
@@ -1,6 +1,6 @@
define([
'js/rendering/renderer'
-], function(
+], function (
renderer
) {
return {
@@ -23,7 +23,7 @@ define([
oldTexture: null,
- init: function(blueprint) {
+ init: function (blueprint) {
if (!this.obj.sprite)
return true;
@@ -32,16 +32,15 @@ define([
this.frame = 0;
this.frameDelayCd = 0;
- for (var p in this.template) {
+ for (let p in this.template)
this[p] = this.template[p];
- }
this.frameDelayCd = this.frameDelay;
this.setSprite();
},
- setSprite: function() {
+ setSprite: function () {
renderer.setSprite({
sprite: this.obj.sprite,
cell: (this.row * 8) + this.col + this.frame,
@@ -49,7 +48,7 @@ define([
});
},
- update: function() {
+ update: function () {
if (this.frameDelayCd > 0)
this.frameDelayCd--;
else {
@@ -61,16 +60,15 @@ define([
this.destroyed = true;
return;
}
- else
- this.frame = 0;
+ this.frame = 0;
}
}
this.setSprite();
},
- destroy: function() {
+ destroy: function () {
this.obj.sprite.texture = this.oldTexture;
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/attackAnimation.js b/src/client/js/components/attackAnimation.js
index 23c8f856..0e153420 100644
--- a/src/client/js/components/attackAnimation.js
+++ b/src/client/js/components/attackAnimation.js
@@ -5,7 +5,7 @@ define([
effects,
renderer
) {
- var scale = 40;
+ let scale = 40;
return {
type: 'attackAnimation',
@@ -39,7 +39,7 @@ define([
this.frameDelayCd = this.frameDelay;
- var cell = (this.row * 8) + this.col + this.frame;
+ let cell = (this.row * 8) + this.col + this.frame;
this.sprite = renderer.buildObject({
sheetName: this.spritesheet || this.spriteSheet,
@@ -71,8 +71,7 @@ define([
this.destroyed = true;
}
return;
- } else
- this.frame = 0;
+ } this.frame = 0;
}
}
@@ -81,7 +80,7 @@ define([
this.sprite.y = this.obj.y * scale;
}
- var cell = (this.row * 8) + this.col + this.frame;
+ let cell = (this.row * 8) + this.col + this.frame;
renderer.setSprite({
sheetName: this.spritesheet || this.spriteSheet,
diff --git a/src/client/js/components/bumpAnimation.js b/src/client/js/components/bumpAnimation.js
index 1fc43692..5b6ee587 100644
--- a/src/client/js/components/bumpAnimation.js
+++ b/src/client/js/components/bumpAnimation.js
@@ -23,21 +23,21 @@ define([
init: function (blueprint) {
//Only allow one bumper at a time
if (this.obj.components.filter(function (c) {
- c.type == this.type
- }) > 1)
+ c.type == this.type;
+ }) > 1)
return true;
},
update: function () {
- var deltaX = this.deltaX;
+ let deltaX = this.deltaX;
if (deltaX < 0)
this.obj.flipX = true;
else if (deltaX > 0)
this.obj.flipX = false;
- if (this.updateCd > 0) {
+ if (this.updateCd > 0)
this.updateCd--;
- } else {
+ else {
this.obj.offsetX += (this.deltaX * this.direction * this.speed);
this.obj.offsetY += (this.deltaY * this.direction * this.speed);
diff --git a/src/client/js/components/chatter.js b/src/client/js/components/chatter.js
index 8f315c82..c35b1c3a 100644
--- a/src/client/js/components/chatter.js
+++ b/src/client/js/components/chatter.js
@@ -3,7 +3,7 @@ define([
], function (
renderer
) {
- var scale = 40;
+ let scale = 40;
return {
type: 'chatter',
@@ -18,13 +18,13 @@ define([
},
update: function () {
- var chatSprite = this.obj.chatSprite;
+ let chatSprite = this.obj.chatSprite;
if (!chatSprite)
return;
- if (this.cd > 0) {
+ if (this.cd > 0)
this.cd--;
- } else if (this.cd == 0) {
+ else if (this.cd == 0) {
renderer.destroyObject({
sprite: chatSprite
});
@@ -33,10 +33,10 @@ define([
},
extend: function (serverMsg) {
- var msg = serverMsg.msg + '\n\'';
+ let msg = serverMsg.msg + '\n\'';
this.msg = msg;
- var obj = this.obj;
+ let obj = this.obj;
if (obj.chatSprite) {
renderer.destroyObject({
@@ -44,11 +44,11 @@ define([
});
}
- var color = this.color;
+ let color = this.color;
if (msg[0] == '*')
color = 0xffeb38;
- var yOffset = (msg.split('\r\n').length - 1);
+ let yOffset = (msg.split('\r\n').length - 1);
obj.chatSprite = renderer.buildText({
layerName: 'effects',
@@ -63,7 +63,7 @@ define([
},
destroy: function () {
- var chatSprite = this.obj.chatSprite;
+ let chatSprite = this.obj.chatSprite;
if (!chatSprite)
return;
diff --git a/src/client/js/components/chest.js b/src/client/js/components/chest.js
index cfc5a1ba..983b73c7 100644
--- a/src/client/js/components/chest.js
+++ b/src/client/js/components/chest.js
@@ -1,9 +1,9 @@
define([
-], function(
+], function (
) {
- var colors = [
+ let colors = [
'929398',
'3fa7dd',
'faac45',
@@ -11,7 +11,7 @@ define([
'ffeb38'
];
- var chances = [
+ let chances = [
0.0075,
0.02,
0.04,
@@ -19,12 +19,12 @@ define([
0.095
];
- var indices = {
- '50': 0,
- '51': 1,
- '128': 2,
- '52': 3,
- '53': 4
+ let indices = {
+ 50: 0,
+ 51: 1,
+ 128: 2,
+ 52: 3,
+ 53: 4
};
return {
@@ -32,7 +32,7 @@ define([
ownerId: null,
- init: function(blueprint) {
+ init: function (blueprint) {
if (this.ownerId != -1) {
if (!window.player) {
this.hideSprite();
@@ -45,9 +45,9 @@ define([
}
}
- var index = indices[this.obj.cell];
+ let index = indices[this.obj.cell];
- var color = colors[index];
+ let color = colors[index];
this.obj.addComponent('particles', {
chance: chances[index],
@@ -75,9 +75,9 @@ define([
});
},
- hideSprite: function() {
+ hideSprite: function () {
if (this.obj.sprite)
this.obj.sprite.visible = false;
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/components.js b/src/client/js/components/components.js
index 626be49d..7360defd 100644
--- a/src/client/js/components/components.js
+++ b/src/client/js/components/components.js
@@ -1,4 +1,4 @@
-var components = [
+let components = [
'keyboardMover',
'mouseMover',
'player',
@@ -38,7 +38,7 @@ var components = [
});
define(components, function () {
- var templates = {};
+ let templates = {};
[].forEach.call(arguments, function (t) {
templates[t.type] = t;
diff --git a/src/client/js/components/dialogue.js b/src/client/js/components/dialogue.js
index a6b4b6a7..d5be51ec 100644
--- a/src/client/js/components/dialogue.js
+++ b/src/client/js/components/dialogue.js
@@ -2,7 +2,7 @@ define([
'js/system/client',
'js/system/events',
'ui/factory'
-], function(
+], function (
client,
events,
factory
@@ -10,11 +10,11 @@ define([
return {
type: 'dialogue',
- init: function() {
+ init: function () {
},
- talk: function(target) {
+ talk: function (target) {
client.request({
cpn: 'player',
method: 'performAction',
@@ -28,8 +28,8 @@ define([
});
},
- extend: function(blueprint) {
+ extend: function (blueprint) {
events.emit('onGetTalk', blueprint.state);
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/events.js b/src/client/js/components/events.js
index 4ee16292..74788adf 100644
--- a/src/client/js/components/events.js
+++ b/src/client/js/components/events.js
@@ -1,23 +1,23 @@
define([
'js/system/events'
-], function(
+], function (
events
) {
return {
type: 'events',
list: [],
- init: function() {
- this.list.forEach(function(q) {
+ init: function () {
+ this.list.forEach(function (q) {
events.emit('onObtainEvent', q);
});
},
- extend: function(blueprint) {
+ extend: function (blueprint) {
if (blueprint.updateList) {
- blueprint.updateList.forEach(function(q) {
+ blueprint.updateList.forEach(function (q) {
events.emit('onObtainEvent', q);
- this.list.spliceWhere(function(l) {
+ this.list.spliceWhere(function (l) {
return (l.id == q.id);
});
this.list.push(q);
@@ -25,13 +25,13 @@ define([
}
if (blueprint.removeList) {
- blueprint.removeList.forEach(function(q) {
+ blueprint.removeList.forEach(function (q) {
events.emit('onRemoveEvent', q.id);
- this.list.spliceWhere(function(l) {
+ this.list.spliceWhere(function (l) {
return (l.id == q.id);
});
}, this);
}
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/explosion.js b/src/client/js/components/explosion.js
index 7640d7cf..743f65df 100644
--- a/src/client/js/components/explosion.js
+++ b/src/client/js/components/explosion.js
@@ -1,6 +1,6 @@
define([
'js/rendering/effects'
-], function(
+], function (
effects
) {
return {
@@ -11,7 +11,7 @@ define([
blueprint: null,
particles: null,
- init: function(blueprint) {
+ init: function (blueprint) {
this.blueprint = {
new: true,
blueprint: $.extend(true, {
@@ -68,11 +68,11 @@ define([
};
},
- explode: function(blueprint) {
+ explode: function (blueprint) {
this.particles = this.obj.addComponent('particles', this.blueprint);
this.particles.emitter.update(0.2);
this.particles.emitter.emit = false;
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/flash.js b/src/client/js/components/flash.js
index 036b1b05..1fe8f539 100644
--- a/src/client/js/components/flash.js
+++ b/src/client/js/components/flash.js
@@ -37,13 +37,13 @@ define([
},
getColor: function () {
- var hex = String(this.color).replace(/[^0-9a-f]/gi, '');
+ let hex = String(this.color).replace(/[^0-9a-f]/gi, '');
if (hex.length < 6)
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
- var rgb = '#';
- var c = 0;
- for (var i = 0; i < 3; i++) {
+ let rgb = '#';
+ let c = 0;
+ for (let i = 0; i < 3; i++) {
c = parseInt(hex.substr(i * 2, 2), 16);
c = Math.round(Math.min(Math.max(0, c + (c * this.lum)), 255)).toString(16);
rgb += ('00' + c).substr(c.length);
diff --git a/src/client/js/components/gatherer.js b/src/client/js/components/gatherer.js
index c190679c..3e1c7aa5 100644
--- a/src/client/js/components/gatherer.js
+++ b/src/client/js/components/gatherer.js
@@ -21,8 +21,8 @@ define([
if (this.effect)
this.effect.destroyed = true;
- var x = 0;
- var y = 0;
+ let x = 0;
+ let y = 0;
while (true) {
x = msg.x + ~~(Math.random() * msg.width);
y = msg.y + ~~(Math.random() * msg.height);
diff --git a/src/client/js/components/keyboardMover.js b/src/client/js/components/keyboardMover.js
index 31d6a3ff..dbb779e5 100644
--- a/src/client/js/components/keyboardMover.js
+++ b/src/client/js/components/keyboardMover.js
@@ -54,7 +54,7 @@ define([
},
keyMove: function () {
- var delta = {
+ let delta = {
x: input.getAxis('horizontal'),
y: input.getAxis('vertical')
};
@@ -65,11 +65,11 @@ define([
this.direction.x = delta.x;
this.direction.y = delta.y;
- var newX = this.obj.pather.pathPos.x + delta.x;
- var newY = this.obj.pather.pathPos.y + delta.y;
+ let newX = this.obj.pather.pathPos.x + delta.x;
+ let newY = this.obj.pather.pathPos.y + delta.y;
if (physics.isTileBlocking(~~newX, ~~newY)) {
- this.bump(delta.x, delta.y)
+ this.bump(delta.x, delta.y);
return;
}
diff --git a/src/client/js/components/light.js b/src/client/js/components/light.js
index d200e6cb..35901c3c 100644
--- a/src/client/js/components/light.js
+++ b/src/client/js/components/light.js
@@ -1,11 +1,11 @@
define([
'js/rendering/effects',
'js/rendering/renderer'
-], function(
+], function (
effects,
renderer
) {
- var scale = 40;
+ let scale = 40;
return {
type: 'light',
@@ -17,20 +17,20 @@ define([
range: 3,
- init: function(blueprint) {
+ init: function (blueprint) {
this.blueprint = this.blueprint || {};
- var x = this.obj.x;
- var y = this.obj.y;
+ let x = this.obj.x;
+ let y = this.obj.y;
- var range = this.range;
- var halfRange = (range - 1) / 2;
+ let range = this.range;
+ let halfRange = (range - 1) / 2;
- for (var i = 0; i < range; i++) {
- for (var j = 0; j < range; j++) {
- var n = i + '|' + j;
+ for (let i = 0; i < range; i++) {
+ for (let j = 0; j < range; j++) {
+ let n = i + '|' + j;
- var maxAlpha = (1 + ((halfRange * 2) - (Math.abs(halfRange - i) + Math.abs(halfRange - j)))) * 0.1;
+ let maxAlpha = (1 + ((halfRange * 2) - (Math.abs(halfRange - i) + Math.abs(halfRange - j)))) * 0.1;
this.emitters[n] = renderer.buildEmitter({
pos: {
@@ -79,18 +79,18 @@ define([
}
},
- update: function() {
+ update: function () {
},
- destroy: function() {
- var keys = Object.keys(this.emitters);
- for (var i = 0; i < keys.length; i++) {
- var emitter = this.emitters[keys[i]];
+ destroy: function () {
+ let keys = Object.keys(this.emitters);
+ for (let i = 0; i < keys.length; i++) {
+ let emitter = this.emitters[keys[i]];
delete this.emitters[keys[i]];
renderer.destroyEmitter(emitter);
}
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/lightPatch.js b/src/client/js/components/lightPatch.js
index 8b6a84fe..a010260f 100644
--- a/src/client/js/components/lightPatch.js
+++ b/src/client/js/components/lightPatch.js
@@ -1,12 +1,12 @@
define([
'js/rendering/renderer',
'picture'
-], function(
+], function (
renderer,
picture
) {
- var scale = 40;
- var scaleMult = 5;
+ let scale = 40;
+ let scaleMult = 5;
return {
type: 'lightPatch',
@@ -15,21 +15,21 @@ define([
patches: [],
rays: [],
- init: function(blueprint) {
+ init: function (blueprint) {
this.blueprint = this.blueprint || {};
- var obj = this.obj;
+ let obj = this.obj;
- var x = obj.x;
- var y = obj.y;
+ let x = obj.x;
+ let y = obj.y;
- var maxDistance = Math.sqrt(Math.pow(obj.width / 2, 2) + Math.pow(obj.height / 2, 2));
+ let maxDistance = Math.sqrt(Math.pow(obj.width / 2, 2) + Math.pow(obj.height / 2, 2));
for (var i = 0; i < obj.width; i++) {
for (var j = 0; j < obj.height; j++) {
- var distance = maxDistance - Math.sqrt(Math.pow((obj.width / 2) - i, 2) + Math.pow((obj.width / 2) - i, 2));
- var alpha = distance / maxDistance;
+ let distance = maxDistance - Math.sqrt(Math.pow((obj.width / 2) - i, 2) + Math.pow((obj.width / 2) - i, 2));
+ let alpha = distance / maxDistance;
- var sprite = renderer.buildObject({
+ let sprite = renderer.buildObject({
x: (x + i),
y: (y + j),
sheetName: 'white',
@@ -46,21 +46,21 @@ define([
}
}
- var rCount = ((obj.width * obj.height) / 10) + ~~(Math.random() + 2);
+ let rCount = ((obj.width * obj.height) / 10) + ~~(Math.random() + 2);
for (var i = 0; i < rCount; i++) {
- var nx = x + 3 + ~~(Math.random() * (obj.width - 1));
- var ny = y - 4 + ~~(Math.random() * (obj.height));
- var w = 1 + ~~(Math.random() * 2);
- var h = 6 + ~~(Math.random() * 13);
- var hm = 2;
+ let nx = x + 3 + ~~(Math.random() * (obj.width - 1));
+ let ny = y - 4 + ~~(Math.random() * (obj.height));
+ let w = 1 + ~~(Math.random() * 2);
+ let h = 6 + ~~(Math.random() * 13);
+ let hm = 2;
- var rContainer = renderer.buildContainer({
+ let rContainer = renderer.buildContainer({
layerName: 'lightBeams'
});
this.rays.push(rContainer);
for (var j = 0; j < h; j++) {
- var ray = renderer.buildObject({
+ let ray = renderer.buildObject({
x: nx,
y: ny,
cell: 0,
@@ -78,11 +78,11 @@ define([
}
},
- update: function() {
- var rays = this.rays;
- var rLen = rays.length;
- for (var i = 0; i < rLen; i++) {
- var r = rays[i];
+ update: function () {
+ let rays = this.rays;
+ let rLen = rays.length;
+ for (let i = 0; i < rLen; i++) {
+ let r = rays[i];
r.alpha += (Math.random() * 0.03) - 0.015;
if (r.alpha < 0.3)
@@ -92,16 +92,16 @@ define([
}
},
- destroy: function() {
- this.patches.forEach(function(p) {
+ destroy: function () {
+ this.patches.forEach(function (p) {
p.parent.removeChild(p);
});
this.patches = [];
- this.rays.forEach(function(r) {
+ this.rays.forEach(function (r) {
r.parent.removeChild(r);
});
this.rays = [];
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/lightningEffect.js b/src/client/js/components/lightningEffect.js
index fb58b011..f335e0fa 100644
--- a/src/client/js/components/lightningEffect.js
+++ b/src/client/js/components/lightningEffect.js
@@ -1,7 +1,7 @@
define([
'js/rendering/lightningBuilder',
'js/rendering/effects'
-], function(
+], function (
lightningBuilder,
effects
) {
@@ -20,16 +20,16 @@ define([
lineShrink: false,
shrinking: false,
- init: function() {
+ init: function () {
effects.register(this);
- var xOffset = (this.toX >= this.obj.x) ? 1 : 0;
+ let xOffset = (this.toX >= this.obj.x) ? 1 : 0;
- var fromX = this.obj.x + xOffset;
- var fromY = this.obj.y + 0.5;
+ let fromX = this.obj.x + xOffset;
+ let fromY = this.obj.y + 0.5;
- var toX = this.lineGrow ? fromX : this.toX + 0.5;
- var toY = this.lineGrow ? fromY : this.toY + 0.5;
+ let toX = this.lineGrow ? fromX : this.toX + 0.5;
+ let toY = this.lineGrow ? fromY : this.toY + 0.5;
this.effect = lightningBuilder.build({
fromX: fromX,
@@ -42,8 +42,8 @@ define([
});
},
- renderManual: function() {
- var cdMax = this.cdMax;
+ renderManual: function () {
+ let cdMax = this.cdMax;
if (((this.lineGrow) && (this.linePercentage < 1)) || ((this.shrinking) && (this.linePercentage > 0)))
cdMax = 1;
@@ -65,15 +65,15 @@ define([
}
}
- var xOffset = (this.toX >= this.obj.x) ? 1 : 0;
+ let xOffset = (this.toX >= this.obj.x) ? 1 : 0;
- var fromX = this.obj.x + xOffset;
- var fromY = this.obj.y + 0.5;
+ let fromX = this.obj.x + xOffset;
+ let fromY = this.obj.y + 0.5;
- var toX = this.toX + 0.5;
- var toY = this.toY + 0.5;
+ let toX = this.toX + 0.5;
+ let toY = this.toY + 0.5;
- var changeTo = (
+ let changeTo = (
(
(this.lineGrow) &&
(this.linePercentage < 1)
@@ -86,17 +86,17 @@ define([
if (changeTo) {
var linePercentage = this.linePercentage;
- if (this.shrinking) {
+ if (this.shrinking)
linePercentage /= 1.5;
- } else {
+ else {
linePercentage *= 1.5;
if (linePercentage > 1)
linePercentage = 1;
}
this.linePercentage = linePercentage;
- var angle = Math.atan2(toY - fromY, toX - fromX);
- var distance = Math.sqrt(Math.pow(fromX - toX, 2) + Math.pow(fromY - toY, 2));
+ let angle = Math.atan2(toY - fromY, toX - fromX);
+ let distance = Math.sqrt(Math.pow(fromX - toX, 2) + Math.pow(fromY - toY, 2));
toX = fromX + (Math.cos(angle) * distance * this.linePercentage);
toY = fromY + (Math.sin(angle) * distance * this.linePercentage);
}
@@ -115,7 +115,7 @@ define([
this.destroyed = true;
},
- destroyManual: function() {
+ destroyManual: function () {
if ((!this.lineShrink) || (this.shrinking)) {
if (this.effect)
lightningBuilder.destroy(this.effect);
@@ -130,4 +130,4 @@ define([
return true;
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/mouseMover.js b/src/client/js/components/mouseMover.js
index 42b213a1..dd1bca40 100644
--- a/src/client/js/components/mouseMover.js
+++ b/src/client/js/components/mouseMover.js
@@ -11,7 +11,7 @@ define([
input,
objects
) {
- var scale = 40;
+ let scale = 40;
return {
type: 'mouseMover',
@@ -49,7 +49,7 @@ define([
renderer.destroyObject({
sprite: p.sprite,
layerName: 'effects'
- })
+ });
}
});
@@ -67,8 +67,8 @@ define([
if ((e.button != null) && (e.button != 0))
return;
- var tileX = ~~(e.x / scale);
- var tileY = ~~(e.y / scale);
+ let tileX = ~~(e.x / scale);
+ let tileY = ~~(e.y / scale);
if ((tileX == this.hoverTile.x) && (tileY == this.hoverTile.y))
return;
@@ -94,7 +94,7 @@ define([
return {
x: p.x,
y: p.y
- }
+ };
})
});
diff --git a/src/client/js/components/moveAnimation.js b/src/client/js/components/moveAnimation.js
index bfaacab1..33cefbfb 100644
--- a/src/client/js/components/moveAnimation.js
+++ b/src/client/js/components/moveAnimation.js
@@ -1,6 +1,6 @@
define([
'js/rendering/renderer'
-], function(
+], function (
renderer
) {
return {
@@ -17,7 +17,7 @@ define([
particles: null,
- init: function(blueprint) {
+ init: function (blueprint) {
this.particles = this.obj.addComponent('particles', {
blueprint: {
scale: {
@@ -58,29 +58,29 @@ define([
}
});
- this.endTime = +new Date + this.ttl;
+ this.endTime = +new Date() + this.ttl;
- var obj = this.obj;
+ let obj = this.obj;
this.x = obj.x;
this.y = obj.y;
- if (this.targetX > this.x) {
+ if (this.targetX > this.x)
this.obj.flipX = false;
- }
+
else if (this.targetX < this.x)
this.obj.flipX = true;
this.obj.setSpritePosition();
},
- update: function() {
- var source = this.obj;
- var target = this.target;
+ update: function () {
+ let source = this.obj;
+ let target = this.target;
- var dx = this.targetX - this.x;
- var dy = this.targetY - this.y;
+ let dx = this.targetX - this.x;
+ let dy = this.targetY - this.y;
- var ticksLeft = ~~((this.endTime - (+new Date)) / 16);
+ let ticksLeft = ~~((this.endTime - (+new Date())) / 16);
if (ticksLeft <= 0) {
this.obj.x = this.targetX;
@@ -118,4 +118,4 @@ define([
renderer.updateSprites();
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/particles.js b/src/client/js/components/particles.js
index 111f606b..a453123f 100644
--- a/src/client/js/components/particles.js
+++ b/src/client/js/components/particles.js
@@ -1,15 +1,15 @@
define([
'js/rendering/renderer'
-], function(
+], function (
renderer
) {
- var scale = 40;
+ let scale = 40;
return {
type: 'particles',
emitter: null,
- init: function(blueprint) {
+ init: function (blueprint) {
this.blueprint = this.blueprint || {};
this.blueprint.pos = {
x: (this.obj.x * scale) + (scale / 2),
@@ -20,7 +20,7 @@ define([
this.emitter = renderer.buildEmitter(this.blueprint);
},
- update: function() {
+ update: function () {
if (this.ttl != null) {
this.ttl--;
if (this.ttl <= 0) {
@@ -39,8 +39,8 @@ define([
this.emitter.spawnPos.y = (this.obj.y * scale) + (scale / 2);
},
- destroy: function() {
+ destroy: function () {
renderer.destroyEmitter(this.emitter);
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/passives.js b/src/client/js/components/passives.js
index 9a2842a0..0ca9b764 100644
--- a/src/client/js/components/passives.js
+++ b/src/client/js/components/passives.js
@@ -15,7 +15,7 @@ define([
},
extend: function (blueprint) {
- var rerender = false;
+ let rerender = false;
if (blueprint.tickNodes) {
blueprint.tickNodes.forEach(function (n) {
diff --git a/src/client/js/components/pather.js b/src/client/js/components/pather.js
index 371d6c9d..55a9dd16 100644
--- a/src/client/js/components/pather.js
+++ b/src/client/js/components/pather.js
@@ -1,14 +1,14 @@
define([
'js/rendering/renderer',
'js/system/events'
-], function(
+], function (
renderer,
events
) {
- var scale = 40;
- var scaleMult = 5;
- var round = Math.round.bind(Math);
- var maxPathLength = 50;
+ let scale = 40;
+ let scaleMult = 5;
+ let round = Math.round.bind(Math);
+ let maxPathLength = 50;
return {
type: 'pather',
@@ -26,7 +26,7 @@ define([
lastX: 0,
lastY: 0,
- init: function() {
+ init: function () {
events.on('onDeath', this.onDeath.bind(this));
events.on('onClearQueue', this.onDeath.bind(this));
@@ -34,8 +34,8 @@ define([
this.pathPos.y = round(this.obj.y);
},
- clearPath: function() {
- this.path.forEach(function(p) {
+ clearPath: function () {
+ this.path.forEach(function (p) {
renderer.destroyObject({
layerName: 'effects',
sprite: p.sprite
@@ -45,14 +45,14 @@ define([
this.path = [];
},
- onDeath: function() {
+ onDeath: function () {
this.clearPath();
this.pathPos.x = round(this.obj.x);
this.pathPos.y = round(this.obj.y);
},
- add: function(x, y) {
+ add: function (x, y) {
if (this.path.length >= maxPathLength)
return;
@@ -73,9 +73,9 @@ define([
return true;
},
- update: function() {
- var x = this.obj.x;
- var y = this.obj.y;
+ update: function () {
+ let x = this.obj.x;
+ let y = this.obj.y;
if (this.path.length == 0) {
this.pathPos.x = round(x);
@@ -88,11 +88,11 @@ define([
this.lastX = x;
this.lastY = y;
- for (var i = 0; i < this.path.length; i++) {
- var p = this.path[i];
+ for (let i = 0; i < this.path.length; i++) {
+ let p = this.path[i];
if ((p.x == x) && (p.y == y)) {
- for (var j = 0; j <= i; j++) {
+ for (let j = 0; j <= i; j++) {
renderer.destroyObject({
layerName: 'effects',
sprite: this.path[j].sprite
@@ -104,7 +104,7 @@ define([
}
},
- setPath: function(path) {
+ setPath: function (path) {
this.path = this.path.concat(path);
this.pathPos.x = round(path[path.length - 1].x);
diff --git a/src/client/js/components/player.js b/src/client/js/components/player.js
index efcbb591..b60a3132 100644
--- a/src/client/js/components/player.js
+++ b/src/client/js/components/player.js
@@ -9,7 +9,7 @@ define([
physics,
sound
) {
- var scale = 40;
+ let scale = 40;
return {
type: 'player',
@@ -30,16 +30,16 @@ define([
},
update: function () {
- var obj = this.obj;
- var oldPos = this.oldPos;
+ let obj = this.obj;
+ let oldPos = this.oldPos;
if ((oldPos.x == obj.x) && (oldPos.y == obj.y))
return;
- var dx = obj.x - oldPos.x;
- var dy = obj.y - oldPos.y;
+ let dx = obj.x - oldPos.x;
+ let dy = obj.y - oldPos.y;
- var instant = false;
+ let instant = false;
if ((dx > 5) || (dy > 5))
instant = true;
@@ -70,7 +70,7 @@ define([
},
canvasFollow: function (delta, instant) {
- var obj = this.obj;
+ let obj = this.obj;
delta = delta || {
x: 0,
y: 0
@@ -80,6 +80,6 @@ define([
x: (obj.x - (renderer.width / (scale * 2))) * scale,
y: (obj.y - (renderer.height / (scale * 2))) * scale
}, instant);
- },
+ }
};
});
diff --git a/src/client/js/components/projectile.js b/src/client/js/components/projectile.js
index 407ec935..113b765f 100644
--- a/src/client/js/components/projectile.js
+++ b/src/client/js/components/projectile.js
@@ -1,9 +1,9 @@
define([
'js/rendering/effects'
-], function(
+], function (
effects
) {
- var scale = 40;
+ let scale = 40;
return {
type: 'projectile',
@@ -22,15 +22,15 @@ define([
particles: null,
- init: function(blueprint) {
+ init: function (blueprint) {
if ((!this.source) || (!this.target)) {
this.obj.destroyed = true;
return;
}
- this.endTime = +new Date + this.ttl;
+ this.endTime = +new Date() + this.ttl;
- var source = this.source;
+ let source = this.source;
this.x = source.x;
this.y = source.y;
@@ -45,7 +45,7 @@ define([
this.obj.x = this.x;
this.obj.y = this.y;
- var particlesBlueprint = this.particles ? {
+ let particlesBlueprint = this.particles ? {
blueprint: this.particles
} : {
blueprint: {
@@ -83,14 +83,14 @@ define([
effects.register(this);
},
- renderManual: function() {
- var source = this.obj;
- var target = this.target;
+ renderManual: function () {
+ let source = this.obj;
+ let target = this.target;
- var dx = target.x - this.x;
- var dy = target.y - this.y;
+ let dx = target.x - this.x;
+ let dy = target.y - this.y;
- var ticksLeft = ~~((this.endTime - (+new Date)) / 16);
+ let ticksLeft = ~~((this.endTime - (+new Date())) / 16);
if (ticksLeft <= 0) {
this.obj.x = target.x;
@@ -99,8 +99,7 @@ define([
if (!this.noExplosion)
this.obj.explosion.explode();
this.obj.destroyed = true;
- }
- else {
+ } else {
dx /= ticksLeft;
dy /= ticksLeft;
@@ -112,8 +111,8 @@ define([
}
},
- destroy: function() {
+ destroy: function () {
effects.unregister(this);
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/prophecies.js b/src/client/js/components/prophecies.js
index 9951afb2..0d65fac6 100644
--- a/src/client/js/components/prophecies.js
+++ b/src/client/js/components/prophecies.js
@@ -1,9 +1,9 @@
define([
-], function(
+], function (
) {
return {
type: 'prophecies'
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/quests.js b/src/client/js/components/quests.js
index 2cb4a3b0..fe472575 100644
--- a/src/client/js/components/quests.js
+++ b/src/client/js/components/quests.js
@@ -1,42 +1,42 @@
define([
'js/system/events'
-], function(
+], function (
events
) {
return {
type: 'quests',
quests: [],
- init: function() {
- this.quests.forEach(function(q) {
+ init: function () {
+ this.quests.forEach(function (q) {
events.emit('onObtainQuest', q);
});
},
- extend: function(blueprint) {
+ extend: function (blueprint) {
if (blueprint.updateQuests) {
- blueprint.updateQuests.forEach(function(q) {
+ blueprint.updateQuests.forEach(function (q) {
events.emit('onUpdateQuest', q);
- var index = this.quests.firstIndex(function(qq) {
+ let index = this.quests.firstIndex(function (qq) {
return (qq.id == q.id);
});
this.quests.splice(index, 1, q);
}, this);
}
if (blueprint.completeQuests) {
- blueprint.completeQuests.forEach(function(q) {
+ blueprint.completeQuests.forEach(function (q) {
events.emit('onCompleteQuest', q);
- this.quests.spliceWhere(function(qq) {
+ this.quests.spliceWhere(function (qq) {
return (qq.id == q);
});
}, this);
}
if (blueprint.obtainQuests) {
- blueprint.obtainQuests.forEach(function(q) {
+ blueprint.obtainQuests.forEach(function (q) {
events.emit('onObtainQuest', q);
this.quests.push(q);
}, this);
}
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/reputation.js b/src/client/js/components/reputation.js
index ff37abb5..0206cc9f 100644
--- a/src/client/js/components/reputation.js
+++ b/src/client/js/components/reputation.js
@@ -16,13 +16,12 @@ define([
extend: function (blueprint) {
if (blueprint.modifyRep) {
blueprint.modifyRep.forEach(function (m) {
- var exists = this.list.find(l => (l.id == m.id));
+ let exists = this.list.find(l => (l.id == m.id));
if (!exists)
this.list.push(m);
else {
- for (var p in m) {
+ for (let p in m)
exists[p] = m[p];
- }
}
}, this);
diff --git a/src/client/js/components/resourceNode.js b/src/client/js/components/resourceNode.js
index 817c6f35..e5cfcaba 100644
--- a/src/client/js/components/resourceNode.js
+++ b/src/client/js/components/resourceNode.js
@@ -1,9 +1,9 @@
define([
'js/misc/physics'
-], function(
+], function (
physics
) {
- var bptParticles = {
+ let bptParticles = {
chance: 0.1,
blueprint: {
color: {
@@ -25,21 +25,20 @@ define([
}
};
-
return {
type: 'resourceNode',
- init: function() {
- var x = this.obj.x;
- var y = this.obj.y;
- var w = this.obj.width || 1;
- var h = this.obj.height || 1;
+ init: function () {
+ let x = this.obj.x;
+ let y = this.obj.y;
+ let w = this.obj.width || 1;
+ let h = this.obj.height || 1;
- var isFish = (this.nodeType == 'fish');
+ let isFish = (this.nodeType == 'fish');
- for (var i = x; i < x + w; i++) {
- for (var j = y; j < y + h; j++) {
- var bpt = $.extend(true, {}, bptParticles, {
+ for (let i = x; i < x + w; i++) {
+ for (let j = y; j < y + h; j++) {
+ let bpt = $.extend(true, {}, bptParticles, {
new: true
});
@@ -70,4 +69,4 @@ define([
}
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/serverActions.js b/src/client/js/components/serverActions.js
index 922b2f41..751f8e5d 100644
--- a/src/client/js/components/serverActions.js
+++ b/src/client/js/components/serverActions.js
@@ -1,7 +1,7 @@
define([
'js/system/events',
'js/system/client'
-], function(
+], function (
events,
client
) {
@@ -10,12 +10,12 @@ define([
actions: [],
- init: function(blueprint) {
+ init: function (blueprint) {
events.on('onKeyUp', this.onKeyUp.bind(this));
},
- onKeyUp: function(key) {
- this.actions.forEach(function(a) {
+ onKeyUp: function (key) {
+ this.actions.forEach(function (a) {
if (a.key != key)
return;
@@ -27,10 +27,10 @@ define([
}, this);
},
- extend: function(blueprint) {
+ extend: function (blueprint) {
if (blueprint.addActions) {
- blueprint.addActions.forEach(function(a) {
- var exists = this.actions.some(function(ta) {
+ blueprint.addActions.forEach(function (a) {
+ let exists = this.actions.some(function (ta) {
return ((ta.targetId == a.targetId) && (ta.cpn == a.cpn) && (ta.method == a.method));
});
if (exists)
@@ -43,8 +43,8 @@ define([
}
if (blueprint.removeActions) {
- blueprint.removeActions.forEach(function(a) {
- this.actions.spliceWhere(function(ta) {
+ blueprint.removeActions.forEach(function (a) {
+ this.actions.spliceWhere(function (ta) {
return ((ta.targetId == a.targetId) && (ta.cpn == a.cpn) && (ta.method == a.method));
});
}, this);
@@ -53,4 +53,4 @@ define([
}
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/social.js b/src/client/js/components/social.js
index 9c0aa2dc..ea3365f4 100644
--- a/src/client/js/components/social.js
+++ b/src/client/js/components/social.js
@@ -1,6 +1,6 @@
define([
'js/system/events'
-], function(
+], function (
events
) {
return {
@@ -8,7 +8,7 @@ define([
customChannels: null,
- init: function() {
+ init: function () {
if (this.customChannels)
events.emit('onGetCustomChatChannels', this.customChannels);
}
diff --git a/src/client/js/components/spellbook.js b/src/client/js/components/spellbook.js
index 00543d0b..0ac91b5f 100644
--- a/src/client/js/components/spellbook.js
+++ b/src/client/js/components/spellbook.js
@@ -7,9 +7,9 @@ define([
renderer,
events
) {
- var scale = 40;
+ let scale = 40;
- var objects = null;
+ let objects = null;
require(['js/objects/objects'], function (o) {
objects = o;
});
@@ -36,14 +36,14 @@ define([
this.targetSprite = renderer.buildObject({
sheetName: 'ui',
layerName: 'effects',
- cell: this.reticleState,
+ cell: this.reticleState
});
this.targetSprite.visible = false;
this.reticleSprite = renderer.buildObject({
sheetName: 'ui',
layerName: 'effects',
- cell: 8 + this.reticleState,
+ cell: 8 + this.reticleState
});
this.reticleSprite.visible = false;
@@ -72,7 +72,7 @@ define([
if (blueprint.getSpells) {
blueprint.getSpells.forEach(function (s) {
- var existIndex = this.spells.firstIndex(function (spell) {
+ let existIndex = this.spells.firstIndex(function (spell) {
return (spell.id == s.id);
});
@@ -93,9 +93,9 @@ define([
},
getSpell: function (number) {
- var spellNumber = (number == ' ') ? 0 : number;
+ let spellNumber = (number == ' ') ? 0 : number;
- var spell = this.spells.find(function (s) {
+ let spell = this.spells.find(function (s) {
return (s.id == spellNumber);
});
if (!spell)
@@ -134,7 +134,7 @@ define([
},
tabTarget: function () {
- var closest = objects.getClosest(window.player.x, window.player.y, 10, this.shiftDown, this.target);
+ let closest = objects.getClosest(window.player.x, window.player.y, 10, this.shiftDown, this.target);
this.target = closest;
this.targetSprite.visible = !!this.target;
@@ -176,11 +176,11 @@ define([
return;
}
- var spell = this.getSpell(key);
+ let spell = this.getSpell(key);
if (!spell)
return;
- var oldTarget = null;
+ let oldTarget = null;
if (this.shiftDown) {
oldTarget = this.target;
this.target = this.obj;
@@ -189,8 +189,8 @@ define([
if ((!spell.aura) && (!spell.targetGround) && (!spell.autoTargetFollower) && (!this.target))
return;
- var hoverTile = this.obj.mouseMover.hoverTile;
- var target = hoverTile;
+ let hoverTile = this.obj.mouseMover.hoverTile;
+ let target = hoverTile;
if ((spell.autoTargetFollower) && (!this.target))
target = null;
else if ((!spell.targetGround) && (this.target))
diff --git a/src/client/js/components/stash.js b/src/client/js/components/stash.js
index bcd8c475..ae46d92c 100644
--- a/src/client/js/components/stash.js
+++ b/src/client/js/components/stash.js
@@ -1,6 +1,6 @@
define([
'js/system/events'
-], function(
+], function (
events
) {
return {
@@ -10,24 +10,24 @@ define([
items: null,
- init: function() {
+ init: function () {
events.emit('onGetStashItems', this.items);
},
- extend: function(blueprint) {
+ extend: function (blueprint) {
if (blueprint.active != null)
this.active = blueprint.active;
if (blueprint.getItems) {
- var items = this.items;
- var newItems = blueprint.getItems || [];
- var nLen = newItems.length;
+ let items = this.items;
+ let newItems = blueprint.getItems || [];
+ let nLen = newItems.length;
- for (var i = 0; i < nLen; i++) {
- var nItem = newItems[i];
+ for (let i = 0; i < nLen; i++) {
+ let nItem = newItems[i];
var nId = nItem.id;
- var findItem = items.find(function(item) {
+ let findItem = items.find(function (item) {
return (item.id == nId);
});
if (findItem) {
@@ -44,9 +44,8 @@ define([
events.emit('onGetStashItems', this.items);
}
- if (blueprint.destroyItems) {
+ if (blueprint.destroyItems)
events.emit('onDestroyStashItems', blueprint.destroyItems);
- }
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/components/stats.js b/src/client/js/components/stats.js
index bcccf755..7805f33f 100644
--- a/src/client/js/components/stats.js
+++ b/src/client/js/components/stats.js
@@ -5,7 +5,7 @@ define([
events,
renderer
) {
- var scale = 40;
+ let scale = 40;
return {
type: 'stats',
@@ -19,13 +19,13 @@ define([
if (this.obj.self)
events.emit('onGetStats', this.values);
- var serverId = this.obj.serverId;
+ let serverId = this.obj.serverId;
if (serverId != null)
events.emit('onGetPartyStats', serverId, this.values);
- var obj = this.obj;
+ let obj = this.obj;
- var yOffset = -12;
+ let yOffset = -12;
if (obj.isChampion)
yOffset = -18;
@@ -54,14 +54,14 @@ define([
if (this.obj.dead)
return;
- var obj = this.obj;
+ let obj = this.obj;
- var yOffset = -12;
+ let yOffset = -12;
if (obj.isChampion)
yOffset = -18;
- var x = obj.x * scale;
- var y = (obj.y * scale) + yOffset;
+ let x = obj.x * scale;
+ let y = (obj.y * scale) + yOffset;
renderer.moveRectangle({
sprite: this.hpSprite,
@@ -84,18 +84,17 @@ define([
},
extend: function (blueprint) {
- var bValues = blueprint.values || {};
+ let bValues = blueprint.values || {};
- var values = this.values;
+ let values = this.values;
- for (var b in bValues) {
+ for (let b in bValues)
values[b] = bValues[b];
- }
if (this.obj.self)
events.emit('onGetStats', this.values);
- var serverId = this.obj.serverId;
+ let serverId = this.obj.serverId;
if (serverId != null)
events.emit('onGetPartyStats', serverId, this.values);
diff --git a/src/client/js/components/trade.js b/src/client/js/components/trade.js
index 75814fa5..92a0304c 100644
--- a/src/client/js/components/trade.js
+++ b/src/client/js/components/trade.js
@@ -1,6 +1,6 @@
define([
'js/system/events'
-], function(
+], function (
events
) {
return {
@@ -9,12 +9,12 @@ define([
itemList: null,
action: 'buy',
- init: function(blueprint) {
+ init: function (blueprint) {
},
- extend: function(blueprint) {
- var redraw = false;
+ extend: function (blueprint) {
+ let redraw = false;
if (blueprint.buyList) {
this.itemList = blueprint.buyList;
@@ -24,8 +24,7 @@ define([
this.action = 'buyback';
delete blueprint.buyList;
- }
- else if (blueprint.sellList) {
+ } else if (blueprint.sellList) {
this.itemList = blueprint.sellList;
redraw = true;
this.action = 'sell';
@@ -33,7 +32,7 @@ define([
}
if (blueprint.removeItems) {
- this.itemList.items.spliceWhere(function(b) {
+ this.itemList.items.spliceWhere(function (b) {
return (blueprint.removeItems.indexOf(b.id) > -1);
});
redraw = true;
@@ -43,9 +42,8 @@ define([
if (blueprint.redraw)
redraw = true;
- for (var p in blueprint) {
+ for (let p in blueprint)
this[p] = blueprint[p];
- }
if (redraw)
events.emit('onGetTradeList', this.itemList, this.action);
@@ -54,4 +52,4 @@ define([
events.emit('onCloseTrade');
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/input.js b/src/client/js/input.js
index fdab68e0..9fe6f6c6 100644
--- a/src/client/js/input.js
+++ b/src/client/js/input.js
@@ -18,23 +18,23 @@ define([
},
mappings: {
- '8': 'backspace',
- '9': 'tab',
- '13': 'enter',
- '16': 'shift',
- '17': 'ctrl',
- '27': 'esc',
- '37': 'left',
- '38': 'up',
- '39': 'right',
- '40': 'down',
- '46': 'del',
+ 8: 'backspace',
+ 9: 'tab',
+ 13: 'enter',
+ 16: 'shift',
+ 17: 'ctrl',
+ 27: 'esc',
+ 37: 'left',
+ 38: 'up',
+ 39: 'right',
+ 40: 'down',
+ 46: 'del',
//hacks for mac cmd key
- '17': 'ctrl',
- '224': 'ctrl',
- '91': 'ctrl',
- '93': 'ctrl'
+ 17: 'ctrl',
+ 224: 'ctrl',
+ 91: 'ctrl',
+ 93: 'ctrl'
},
mouse: {
@@ -60,9 +60,8 @@ define([
},
resetKeys: function () {
- for (var k in this.keys) {
+ for (let k in this.keys)
events.emit('onKeyUp', k);
- }
this.keys = {};
},
@@ -75,27 +74,24 @@ define([
this.mappings[charCode] ||
String.fromCharCode(charCode).toLowerCase()
);
-
},
isKeyDown: function (key, noConsume) {
- var down = this.keys[key];
+ let down = this.keys[key];
if (down != null) {
if (noConsume)
return true;
- else {
- this.keys[key] = 2;
- return (down == 1);
- }
- } else
- return false;
+
+ this.keys[key] = 2;
+ return (down == 1);
+ } return false;
},
getAxis: function (name) {
- var axis = this.axes[name];
+ let axis = this.axes[name];
if (!axis)
return 0;
- var result = 0;
+ let result = 0;
for (var i = 0; i < axis.negative.length; i++) {
if (this.keys[axis.negative[i]]) {
@@ -125,7 +121,7 @@ define([
if ((e.keyCode == 9) || (e.keyCode == 8) || (e.keyCode == 122))
e.preventDefault();
- var key = this.getMapping(e.which);
+ let key = this.getMapping(e.which);
if (this.keys[key] != null)
this.keys[key] = 2;
@@ -146,7 +142,7 @@ define([
if (e.target != document.body)
return;
- var key = this.getMapping(e.which);
+ let key = this.getMapping(e.which);
delete this.keys[key];
@@ -155,11 +151,11 @@ define([
},
mouse: {
mouseDown: function (e) {
- var el = $(e.target);
+ let el = $(e.target);
if ((!el.hasClass('ui-container')) || (el.hasClass('blocking')))
return;
- var button = e.button;
+ let button = e.button;
this.mouse.button = button;
this.mouse.down = true;
this.mouse.event = e;
@@ -167,11 +163,11 @@ define([
events.emit('mouseDown', this.mouse);
},
mouseUp: function (e) {
- var el = $(e.target);
+ let el = $(e.target);
if ((!el.hasClass('ui-container')) || (el.hasClass('blocking')))
return;
- var button = e.button;
+ let button = e.button;
this.mouse.button = null;
this.mouse.down = false;
@@ -186,7 +182,7 @@ define([
if (!e)
return;
- var el = $(e.target);
+ let el = $(e.target);
if ((!el.hasClass('ui-container')) || (el.hasClass('blocking')))
return;
diff --git a/src/client/js/main.js b/src/client/js/main.js
index 2ac57ae1..abb25111 100644
--- a/src/client/js/main.js
+++ b/src/client/js/main.js
@@ -58,9 +58,9 @@ define([
window.onfocus = this.onFocus.bind(this, true);
window.onblur = this.onFocus.bind(this, false);
$(window).on('contextmenu', function (e) {
- var allowedList = ['txtUsername', 'txtPassword'];
+ let allowedList = ['txtUsername', 'txtPassword'];
- var allowed = allowedList.some(function (item) {
+ let allowed = allowedList.some(function (item) {
return $(e.target).hasClass(item);
});
diff --git a/src/client/js/misc/helpers.js b/src/client/js/misc/helpers.js
index 3714e75f..b9be99df 100644
--- a/src/client/js/misc/helpers.js
+++ b/src/client/js/misc/helpers.js
@@ -1,9 +1,9 @@
-Array.prototype.firstIndex = function(callback, thisArg) {
- var T = thisArg;
- var O = Object(this);
- var len = O.length >>> 0;
+Array.prototype.firstIndex = function (callback, thisArg) {
+ let T = thisArg;
+ let O = Object(this);
+ let len = O.length >>> 0;
- var k = 0;
+ let k = 0;
while (k < len) {
var kValue;
@@ -20,12 +20,12 @@ Array.prototype.firstIndex = function(callback, thisArg) {
return -1;
};
-Array.prototype.spliceWhere = function(callback, thisArg) {
- var T = thisArg;
- var O = Object(this);
- var len = O.length >>> 0;
+Array.prototype.spliceWhere = function (callback, thisArg) {
+ let T = thisArg;
+ let O = Object(this);
+ let len = O.length >>> 0;
- var k = 0;
+ let k = 0;
while (k < len) {
var kValue;
@@ -42,12 +42,12 @@ Array.prototype.spliceWhere = function(callback, thisArg) {
}
};
-Array.prototype.spliceFirstWhere = function(callback, thisArg) {
- var T = thisArg;
- var O = Object(this);
- var len = O.length >>> 0;
+Array.prototype.spliceFirstWhere = function (callback, thisArg) {
+ let T = thisArg;
+ let O = Object(this);
+ let len = O.length >>> 0;
- var k = 0;
+ let k = 0;
while (k < len) {
var kValue;
@@ -65,22 +65,22 @@ Array.prototype.spliceFirstWhere = function(callback, thisArg) {
};
window._ = {
- create: function() {
- var result = {};
+ create: function () {
+ let result = {};
- [].slice.call(arguments).forEach(function(a) {
+ [].slice.call(arguments).forEach(function (a) {
$.extend(true, result, a);
});
return result;
},
- get2dArray: function(w, h, def) {
+ get2dArray: function (w, h, def) {
def = def || 0;
- var result = [];
- for (var i = 0; i < w; i++) {
- var inner = [];
- for (var j = 0; j < h; j++) {
+ let result = [];
+ for (let i = 0; i < w; i++) {
+ let inner = [];
+ for (let j = 0; j < h; j++) {
if (def == 'array')
inner.push([]);
else
@@ -92,12 +92,11 @@ window._ = {
return result;
},
- randWeighted: function(weights) {
- var sample = [];
- weights.forEach(function(w, i) {
- for (var j = 0; j < w; j++) {
+ randWeighted: function (weights) {
+ let sample = [];
+ weights.forEach(function (w, i) {
+ for (let j = 0; j < w; j++)
sample.push(i);
- }
});
return sample[~~(Math.random() * sample.length)];
@@ -106,8 +105,8 @@ window._ = {
define([
-], function(
+], function (
) {
return window._;
-});
\ No newline at end of file
+});
diff --git a/src/client/js/misc/pathfinder.js b/src/client/js/misc/pathfinder.js
index 01cf588c..af54f20b 100644
--- a/src/client/js/misc/pathfinder.js
+++ b/src/client/js/misc/pathfinder.js
@@ -6,20 +6,19 @@
// http://eloquentjavascript.net/appendix2.html
(function (definition) {
/* global module, define */
- if (typeof module === 'object' && typeof module.exports === 'object') {
+ if (typeof module === 'object' && typeof module.exports === 'object')
module.exports = definition();
- } else if (typeof define === 'function' && define.amd) {
+ else if (typeof define === 'function' && define.amd)
define([], definition);
- } else {
- var exports = definition();
+ else {
+ let exports = definition();
window.astar = exports.astar;
window.Graph = exports.Graph;
}
})(function () {
-
- function pathTo(node) {
- var curr = node;
- var path = [];
+ function pathTo (node) {
+ let curr = node;
+ let path = [];
while (curr.parent) {
path.unshift(curr);
curr = curr.parent;
@@ -27,7 +26,7 @@
return path;
}
- function getHeap() {
+ function getHeap () {
return new BinaryHeap(function (node) {
return node.f;
});
@@ -54,15 +53,15 @@
graph.cleanDirty();
options = options || {};
- var heuristic = options.heuristic || astar.heuristics.manhattan;
- var closest = options.closest || false;
- var distance = options.distance;
+ let heuristic = options.heuristic || astar.heuristics.manhattan;
+ let closest = options.closest || false;
+ let distance = options.distance;
if (distance)
heuristic = astar.heuristics.manhattanDistance;
- var openHeap = getHeap();
- var closestNode = start; // set the start node to be the closest if required
+ let openHeap = getHeap();
+ let closestNode = start; // set the start node to be the closest if required
start.h = heuristic(start, end, distance);
graph.markDirty(start);
@@ -70,11 +69,10 @@
openHeap.push(start);
while (openHeap.size() > 0) {
-
// Grab the lowest f(x) to process next. Heap keeps this sorted for us.
- var currentNode = openHeap.pop();
+ let currentNode = openHeap.pop();
- var onWall = !currentNode.isWall || currentNode.isWall();
+ let onWall = !currentNode.isWall || currentNode.isWall();
if (!onWall) {
if (distance) {
@@ -82,9 +80,8 @@
return pathTo(currentNode);
} else {
// End case -- result has been found, return the traced path.
- if (currentNode === end) {
+ if (currentNode === end)
return pathTo(currentNode);
- }
}
}
@@ -92,10 +89,10 @@
currentNode.closed = true;
// Find all neighbors for the current node.
- var neighbors = graph.neighbors(currentNode);
+ let neighbors = graph.neighbors(currentNode);
- for (var i = 0, il = neighbors.length; i < il; ++i) {
- var neighbor = neighbors[i];
+ for (let i = 0, il = neighbors.length; i < il; ++i) {
+ let neighbor = neighbors[i];
if (neighbor.closed || neighbor.isWall()) {
// Not a valid node to process, skip to next neighbor.
@@ -104,11 +101,10 @@
// The g score is the shortest distance from start to current node.
// We need to check if the path we have arrived at this neighbor is the shortest one we have seen yet.
- var gScore = currentNode.g + neighbor.getCost(currentNode);
- var beenVisited = neighbor.visited;
+ let gScore = currentNode.g + neighbor.getCost(currentNode);
+ let beenVisited = neighbor.visited;
if (!beenVisited || gScore < neighbor.g) {
-
// Found an optimal (so far) path to this node. Take score for node to see how good it is.
neighbor.visited = true;
neighbor.parent = currentNode;
@@ -119,9 +115,8 @@
if (closest) {
// If the neighbour is closer than the current closestNode or if it's equally close but has
// a cheaper path than the current closest node then it becomes the closest node
- if (neighbor.h < closestNode.h || (neighbor.h === closestNode.h && neighbor.g < closestNode.g)) {
+ if (neighbor.h < closestNode.h || (neighbor.h === closestNode.h && neighbor.g < closestNode.g))
closestNode = neighbor;
- }
}
if (!beenVisited) {
@@ -135,9 +130,8 @@
}
}
- if (closest) {
+ if (closest)
return pathTo(closestNode);
- }
// No result was found - empty array signifies failure to find path.
return [];
@@ -145,20 +139,20 @@
// See list of heuristics: http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html
heuristics: {
manhattan: function (pos0, pos1) {
- var d1 = Math.abs(pos1.x - pos0.x);
- var d2 = Math.abs(pos1.y - pos0.y);
+ let d1 = Math.abs(pos1.x - pos0.x);
+ let d2 = Math.abs(pos1.y - pos0.y);
return Math.max(d1, d2);
},
manhattanDistance: function (pos0, pos1, distance) {
- var d1 = Math.abs(pos1.x - pos0.x);
- var d2 = Math.abs(pos1.y - pos0.y);
+ let d1 = Math.abs(pos1.x - pos0.x);
+ let d2 = Math.abs(pos1.y - pos0.y);
return Math.abs(distance - Math.max(d1, d2)) + 1;
},
diagonal: function (pos0, pos1) {
- var D = 1;
- var D2 = Math.sqrt(2);
- var d1 = Math.abs(pos1.x - pos0.x);
- var d2 = Math.abs(pos1.y - pos0.y);
+ let D = 1;
+ let D2 = Math.sqrt(2);
+ let d1 = Math.abs(pos1.x - pos0.x);
+ let d2 = Math.abs(pos1.y - pos0.y);
return (D * (d1 + d2)) + ((D2 - (2 * D)) * Math.min(d1, d2));
}
},
@@ -180,16 +174,16 @@
* @param {Object} [options]
* @param {bool} [options.diagonal] Specifies whether diagonal moves are allowed
*/
- function Graph(gridIn, options) {
+ function Graph (gridIn, options) {
options = options || {};
this.nodes = [];
this.diagonal = !!options.diagonal;
this.grid = [];
- for (var x = 0; x < gridIn.length; x++) {
+ for (let x = 0; x < gridIn.length; x++) {
this.grid[x] = [];
- for (var y = 0, row = gridIn[x]; y < row.length; y++) {
+ for (let y = 0, row = gridIn[x]; y < row.length; y++) {
if (!row[y]) {
node = new GridNode(x, y, row[y] ? 0 : 1);
this.grid[x][y] = node;
@@ -202,15 +196,14 @@
Graph.prototype.init = function () {
this.dirtyNodes = [];
- for (var i = 0; i < this.nodes.length; i++) {
+ for (let i = 0; i < this.nodes.length; i++)
astar.cleanNode(this.nodes[i]);
- }
};
Graph.prototype.cleanDirty = function () {
- for (var i = 0; i < this.dirtyNodes.length; i++) {
+ for (let i = 0; i < this.dirtyNodes.length; i++)
astar.cleanNode(this.dirtyNodes[i]);
- }
+
this.dirtyNodes = [];
};
@@ -219,85 +212,77 @@
};
Graph.prototype.neighbors = function (node) {
- var ret = [];
- var x = node.x;
- var y = node.y;
- var grid = this.grid;
+ let ret = [];
+ let x = node.x;
+ let y = node.y;
+ let grid = this.grid;
// West
- if (grid[x - 1] && grid[x - 1][y]) {
+ if (grid[x - 1] && grid[x - 1][y])
ret.push(grid[x - 1][y]);
- }
// East
- if (grid[x + 1] && grid[x + 1][y]) {
+ if (grid[x + 1] && grid[x + 1][y])
ret.push(grid[x + 1][y]);
- }
// South
- if (grid[x] && grid[x][y - 1]) {
+ if (grid[x] && grid[x][y - 1])
ret.push(grid[x][y - 1]);
- }
// North
- if (grid[x] && grid[x][y + 1]) {
+ if (grid[x] && grid[x][y + 1])
ret.push(grid[x][y + 1]);
- }
if (this.diagonal) {
// Southwest
- if (grid[x - 1] && grid[x - 1][y - 1]) {
+ if (grid[x - 1] && grid[x - 1][y - 1])
ret.push(grid[x - 1][y - 1]);
- }
// Southeast
- if (grid[x + 1] && grid[x + 1][y - 1]) {
+ if (grid[x + 1] && grid[x + 1][y - 1])
ret.push(grid[x + 1][y - 1]);
- }
// Northwest
- if (grid[x - 1] && grid[x - 1][y + 1]) {
+ if (grid[x - 1] && grid[x - 1][y + 1])
ret.push(grid[x - 1][y + 1]);
- }
// Northeast
- if (grid[x + 1] && grid[x + 1][y + 1]) {
+ if (grid[x + 1] && grid[x + 1][y + 1])
ret.push(grid[x + 1][y + 1]);
- }
}
return ret;
};
Graph.prototype.toString = function () {
- var graphString = [];
- var nodes = this.grid;
- for (var x = 0; x < nodes.length; x++) {
- var rowDebug = [];
- var row = nodes[x];
- for (var y = 0; y < row.length; y++) {
+ let graphString = [];
+ let nodes = this.grid;
+ for (let x = 0; x < nodes.length; x++) {
+ let rowDebug = [];
+ let row = nodes[x];
+ for (let y = 0; y < row.length; y++)
rowDebug.push(row[y].weight);
- }
- graphString.push(rowDebug.join(" "));
+
+ graphString.push(rowDebug.join(' '));
}
- return graphString.join("\n");
+ return graphString.join('\n');
};
- function GridNode(x, y, weight) {
+ function GridNode (x, y, weight) {
this.x = x;
this.y = y;
this.weight = weight;
}
GridNode.prototype.toString = function () {
- return "[" + this.x + " " + this.y + "]";
+ return '[' + this.x + ' ' + this.y + ']';
};
GridNode.prototype.getCost = function (fromNeighbor) {
// Take diagonal weight into consideration.
- if (fromNeighbor && fromNeighbor.x != this.x && fromNeighbor.y != this.y) {
+ if (fromNeighbor && fromNeighbor.x != this.x && fromNeighbor.y != this.y)
return this.weight * 1.41421;
- }
+
return this.weight;
};
@@ -305,7 +290,7 @@
return this.weight === 0;
};
- function BinaryHeap(scoreFunction) {
+ function BinaryHeap (scoreFunction) {
this.content = [];
this.scoreFunction = scoreFunction;
}
@@ -320,9 +305,9 @@
},
pop: function () {
// Store the first element so we can return it later.
- var result = this.content[0];
+ let result = this.content[0];
// Get the element at the end of the array.
- var end = this.content.pop();
+ let end = this.content.pop();
// If there are any elements left, put the end element at the
// start, and let it bubble up.
if (this.content.length > 0) {
@@ -332,20 +317,19 @@
return result;
},
remove: function (node) {
- var i = this.content.indexOf(node);
+ let i = this.content.indexOf(node);
// When it is found, the process seen in 'pop' is repeated
// to fill up the hole.
- var end = this.content.pop();
+ let end = this.content.pop();
if (i !== this.content.length - 1) {
this.content[i] = end;
- if (this.scoreFunction(end) < this.scoreFunction(node)) {
+ if (this.scoreFunction(end) < this.scoreFunction(node))
this.sinkDown(i);
- } else {
+ else
this.bubbleUp(i);
- }
}
},
size: function () {
@@ -356,14 +340,13 @@
},
sinkDown: function (n) {
// Fetch the element that has to be sunk.
- var element = this.content[n];
+ let element = this.content[n];
// When at 0, an element can not sink any further.
while (n > 0) {
-
// Compute the parent element's index, and fetch it.
- var parentN = ((n + 1) >> 1) - 1;
- var parent = this.content[parentN];
+ let parentN = ((n + 1) >> 1) - 1;
+ let parent = this.content[parentN];
// Swap the elements if the parent is greater.
if (this.scoreFunction(element) < this.scoreFunction(parent)) {
this.content[parentN] = element;
@@ -372,43 +355,40 @@
n = parentN;
}
// Found a parent that is less, no need to sink any further.
- else {
+ else
break;
- }
}
},
bubbleUp: function (n) {
// Look up the target element and its score.
- var length = this.content.length;
- var element = this.content[n];
- var elemScore = this.scoreFunction(element);
+ let length = this.content.length;
+ let element = this.content[n];
+ let elemScore = this.scoreFunction(element);
while (true) {
// Compute the indices of the child elements.
- var child2N = (n + 1) << 1;
- var child1N = child2N - 1;
+ let child2N = (n + 1) << 1;
+ let child1N = child2N - 1;
// This is used to store the new position of the element, if any.
- var swap = null;
+ let swap = null;
var child1Score;
// If the first child exists (is inside the array)...
if (child1N < length) {
// Look it up and compute its score.
- var child1 = this.content[child1N];
+ let child1 = this.content[child1N];
child1Score = this.scoreFunction(child1);
// If the score is less than our element's, we need to swap.
- if (child1Score < elemScore) {
+ if (child1Score < elemScore)
swap = child1N;
- }
}
// Do the same checks for the other child.
if (child2N < length) {
- var child2 = this.content[child2N];
- var child2Score = this.scoreFunction(child2);
- if (child2Score < (swap === null ? elemScore : child1Score)) {
+ let child2 = this.content[child2N];
+ let child2Score = this.scoreFunction(child2);
+ if (child2Score < (swap === null ? elemScore : child1Score))
swap = child2N;
- }
}
// If the element needs to be moved, swap it, and continue.
@@ -418,9 +398,8 @@
n = swap;
}
// Otherwise, we are done.
- else {
+ else
break;
- }
}
}
};
@@ -430,5 +409,4 @@
Graph: Graph,
gridNode: GridNode
};
-
});
diff --git a/src/client/js/misc/physics.js b/src/client/js/misc/physics.js
index c4a45231..75412146 100644
--- a/src/client/js/misc/physics.js
+++ b/src/client/js/misc/physics.js
@@ -3,9 +3,9 @@ define([
], function (
pathfinder
) {
- var sqrt = Math.sqrt.bind(Math);
- var ceil = Math.ceil.bind(Math);
- var random = Math.random.bind(Math);
+ let sqrt = Math.sqrt.bind(Math);
+ let ceil = Math.ceil.bind(Math);
+ let random = Math.random.bind(Math);
return {
graph: null,
@@ -29,34 +29,33 @@ define([
},
addRegion: function (obj) {
- var lowX = obj.x;
- var lowY = obj.y;
- var highX = lowX + obj.width;
- var highY = lowY + obj.height;
- var cells = this.cells;
-
- for (var i = lowX; i <= highX; i++) {
- var row = cells[i];
- for (var j = lowY; j <= highY; j++) {
+ let lowX = obj.x;
+ let lowY = obj.y;
+ let highX = lowX + obj.width;
+ let highY = lowY + obj.height;
+ let cells = this.cells;
+
+ for (let i = lowX; i <= highX; i++) {
+ let row = cells[i];
+ for (let j = lowY; j <= highY; j++)
row[j].push(obj);
- }
}
},
addObject: function (obj, x, y, fromX, fromY) {
- var row = this.cells[x];
+ let row = this.cells[x];
if (!row)
return;
- var cell = row[y];
+ let cell = row[y];
if (!cell)
return;
- var cLen = cell.length;
- for (var i = 0; i < cLen; i++) {
- var c = cell[i];
+ let cLen = cell.length;
+ for (let i = 0; i < cLen; i++) {
+ let c = cell[i];
//If we have fromX and fromY, check if the target cell doesn't contain the same obj (like a notice area)
if ((c.width) && (fromX)) {
@@ -74,20 +73,20 @@ define([
return true;
},
removeObject: function (obj, x, y, toX, toY) {
- var row = this.cells[x];
+ let row = this.cells[x];
if (!row)
return;
- var cell = row[y];
+ let cell = row[y];
if (!cell)
return;
- var oId = obj.id;
- var cLen = cell.length;
- for (var i = 0; i < cLen; i++) {
- var c = cell[i];
+ let oId = obj.id;
+ let cLen = cell.length;
+ for (let i = 0; i < cLen; i++) {
+ let c = cell[i];
if (c.id != oId) {
//If we have toX and toY, check if the target cell doesn't contain the same obj (like a notice area)
@@ -109,21 +108,20 @@ define([
},
isValid: function (x, y) {
- var row = this.cells[x];
+ let row = this.cells[x];
if ((!row) || (row.length <= y) || (!this.graph.grid[x][y]))
return false;
- else
- return true;
+ return true;
},
getCell: function (x, y) {
- var row = this.cells[x];
+ let row = this.cells[x];
if (!row)
return [];
- var cell = row[y];
+ let cell = row[y];
if (!cell)
return [];
@@ -131,8 +129,8 @@ define([
return cell;
},
getArea: function (x1, y1, x2, y2, filter) {
- var width = this.width;
- var height = this.height;
+ let width = this.width;
+ let height = this.height;
x1 = ~~x1;
y1 = ~~y1;
@@ -149,21 +147,21 @@ define([
else if (y2 >= height)
y2 = height - 1;
- var cells = this.cells;
- var grid = this.graph.grid;
+ let cells = this.cells;
+ let grid = this.graph.grid;
- var result = [];
- for (var i = x1; i <= x2; i++) {
- var row = cells[i];
- var gridRow = grid[i];
- for (var j = y1; j <= y2; j++) {
+ let result = [];
+ for (let i = x1; i <= x2; i++) {
+ let row = cells[i];
+ let gridRow = grid[i];
+ for (let j = y1; j <= y2; j++) {
if (!gridRow[j])
continue;
- var cell = row[j];
- var cLen = cell.length;
- for (var k = 0; k < cLen; k++) {
- var c = cell[k];
+ let cell = row[j];
+ let cLen = cell.length;
+ for (let k = 0; k < cLen; k++) {
+ let c = cell[k];
if (filter) {
if (filter(c))
@@ -178,8 +176,8 @@ define([
},
getOpenCellInArea: function (x1, y1, x2, y2) {
- var width = this.width;
- var height = this.height;
+ let width = this.width;
+ let height = this.height;
x1 = ~~x1;
y1 = ~~y1;
@@ -196,18 +194,18 @@ define([
else if (y2 >= height)
y2 = height - 1;
- var cells = this.cells;
- var grid = this.graph.grid;
+ let cells = this.cells;
+ let grid = this.graph.grid;
- var result = [];
- for (var i = x1; i <= x2; i++) {
- var row = cells[i];
- var gridRow = grid[i];
- for (var j = y1; j <= y2; j++) {
+ let result = [];
+ for (let i = x1; i <= x2; i++) {
+ let row = cells[i];
+ let gridRow = grid[i];
+ for (let j = y1; j <= y2; j++) {
if (!gridRow[j])
continue;
- var cell = row[j];
+ let cell = row[j];
if (cell.length == 0) {
return {
x: i,
@@ -221,8 +219,8 @@ define([
},
getPath: function (from, to) {
- var graph = this.graph;
- var grid = graph.grid;
+ let graph = this.graph;
+ let grid = graph.grid;
if (!to) {
to = {
@@ -231,19 +229,19 @@ define([
};
}
- var fromX = ~~from.x;
- var fromY = ~~from.y;
+ let fromX = ~~from.x;
+ let fromY = ~~from.y;
if ((!grid[fromX]) || (grid[fromX].length <= fromY) || (fromX < 0) || (fromY < 0))
return [];
- var toX = ~~to.x;
- var toY = ~~to.y;
+ let toX = ~~to.x;
+ let toY = ~~to.y;
if ((!grid[toX]) || (grid[toX].length <= toY) || (toX < 0) || (toY < 0))
return [];
- var path = pathfinder.astar.search(graph, {
+ let path = pathfinder.astar.search(graph, {
x: fromX,
y: fromY
}, {
@@ -262,7 +260,7 @@ define([
x = ~~x;
y = ~~y;
- var node = this.graph.grid[x][y];
+ let node = this.graph.grid[x][y];
return ((!node) || (node.weight == 0));
},
@@ -276,15 +274,15 @@ define([
if ((fromX < 0) || (fromY < 0) || (fromX >= this.width) | (fromY >= this.height) || (toX < 0) || (toY < 0) || (toX >= this.width) | (toY >= this.height))
return false;
- var graphGrid = this.graph.grid;
+ let graphGrid = this.graph.grid;
if ((!graphGrid[fromX][fromY]) || (!graphGrid[toX][toY]))
return false;
- var dx = toX - fromX;
- var dy = toY - fromY;
+ let dx = toX - fromX;
+ let dy = toY - fromY;
- var distance = sqrt((dx * dx) + (dy * dy));
+ let distance = sqrt((dx * dx) + (dy * dy));
dx /= distance;
dy /= distance;
@@ -294,10 +292,10 @@ define([
distance = ceil(distance);
- var x = 0;
- var y = 0;
+ let x = 0;
+ let y = 0;
- for (var i = 0; i < distance; i++) {
+ for (let i = 0; i < distance; i++) {
fromX += dx;
fromY += dy;
@@ -314,24 +312,24 @@ define([
},
getClosestPos: function (fromX, fromY, toX, toY, target) {
- var tried = {};
+ let tried = {};
- var hasLos = this.hasLos.bind(this, toX, toY);
+ let hasLos = this.hasLos.bind(this, toX, toY);
- var width = this.width;
- var height = this.height;
+ let width = this.width;
+ let height = this.height;
- var collisionMap = this.collisionMap;
- var cells = this.cells;
+ let collisionMap = this.collisionMap;
+ let cells = this.cells;
- var reverseX = (fromX > toX);
- var reverseY = (fromY > toY);
+ let reverseX = (fromX > toX);
+ let reverseY = (fromY > toY);
- for (var c = 1; c <= 10; c++) {
- var x1 = toX - c;
- var y1 = toY - c;
- var x2 = toX + c;
- var y2 = toY + c;
+ for (let c = 1; c <= 10; c++) {
+ let x1 = toX - c;
+ let y1 = toY - c;
+ let x2 = toX + c;
+ let y2 = toY + c;
var lowX, lowY, highX, highY, incX, incY;
@@ -355,19 +353,18 @@ define([
highY = y2 + 1;
}
- for (var i = lowX; i != highX; i += incX) {
+ for (let i = lowX; i != highX; i += incX) {
if ((i < 0) || (i >= width))
continue;
- var row = collisionMap[i];
- var cellRow = cells[i];
+ let row = collisionMap[i];
+ let cellRow = cells[i];
- var t = tried[i];
- if (!t) {
+ let t = tried[i];
+ if (!t)
t = tried[i] = {};
- }
- for (var j = lowY; j != highY; j += incY) {
+ for (let j = lowY; j != highY; j += incY) {
if (t[j])
continue;
@@ -380,11 +377,11 @@ define([
)
continue;
- var cell = cellRow[j];
- var cLen = cell.length;
- var blocking = false;
- for (var k = 0; k < cLen; k++) {
- var aggro = cell[k].aggro;
+ let cell = cellRow[j];
+ let cLen = cell.length;
+ let blocking = false;
+ for (let k = 0; k < cLen; k++) {
+ let aggro = cell[k].aggro;
if (aggro) {
blocking = aggro.list.some(a => a.obj == target);
if (blocking)
@@ -409,15 +406,15 @@ define([
if ((x < 0) || (y < 0) || (x >= this.width) | (y >= this.height))
return true;
- var cell = this.cells[x][y];
- var cLen = cell.length;
+ let cell = this.cells[x][y];
+ let cLen = cell.length;
if (cLen == 1)
return false;
- var found = false;
- for (var i = 0; i < cLen; i++) {
- var c = cell[i];
+ let found = false;
+ for (let i = 0; i < cLen; i++) {
+ let c = cell[i];
if (c.aggro) {
if ((!found) && (c == obj))
found = true;
@@ -430,9 +427,9 @@ define([
},
setCollision: function (x, y, collides) {
- var node = this.graph.grid[x][y];
+ let node = this.graph.grid[x][y];
if (!node) {
- var grid = this.graph.grid;
+ let grid = this.graph.grid;
node = grid[x][y] = new pathfinder.gridNode(x, y, collides ? 0 : 1);
}
diff --git a/src/client/js/misc/statTranslations.js b/src/client/js/misc/statTranslations.js
index 7899ce41..d58b5b5e 100644
--- a/src/client/js/misc/statTranslations.js
+++ b/src/client/js/misc/statTranslations.js
@@ -3,69 +3,69 @@ define([
], function (
) {
- var stats = {
- 'vit': 'vitality',
- 'regenHp': 'health regeneration',
- 'manaMax': 'maximum mana',
- 'regenMana': 'mana regeneration',
- 'str': 'strength',
- 'int': 'intellect',
- 'dex': 'dexterity',
- 'armor': 'armor',
+ let stats = {
+ vit: 'vitality',
+ regenHp: 'health regeneration',
+ manaMax: 'maximum mana',
+ regenMana: 'mana regeneration',
+ str: 'strength',
+ int: 'intellect',
+ dex: 'dexterity',
+ armor: 'armor',
- 'blockAttackChance': 'chance to block attacks',
- 'blockSpellChance': 'chance to block spells',
+ blockAttackChance: 'chance to block attacks',
+ blockSpellChance: 'chance to block spells',
- 'dodgeAttackChance': 'chance to dodge attacks',
- 'dodgeSpellChance': 'chance to dodge spells',
+ dodgeAttackChance: 'chance to dodge attacks',
+ dodgeSpellChance: 'chance to dodge spells',
- 'addCritChance': 'global crit chance',
- 'addCritMultiplier': 'global crit multiplier',
- 'addAttackCritChance': 'attack crit chance',
- 'addAttackCritMultiplier': 'attack crit multiplier',
- 'addSpellCritChance': 'spell crit chance',
- 'addSpellCritMultiplier': 'spell crit multiplier',
- 'magicFind': 'increased item quality',
- 'itemQuantity': 'increased item quantity',
- 'sprintChance': 'sprint chance',
- 'allAttributes': 'to all attributes',
- 'xpIncrease': 'additional xp per kill',
- 'lvlRequire': 'level requirement reduction',
+ addCritChance: 'global crit chance',
+ addCritMultiplier: 'global crit multiplier',
+ addAttackCritChance: 'attack crit chance',
+ addAttackCritMultiplier: 'attack crit multiplier',
+ addSpellCritChance: 'spell crit chance',
+ addSpellCritMultiplier: 'spell crit multiplier',
+ magicFind: 'increased item quality',
+ itemQuantity: 'increased item quantity',
+ sprintChance: 'sprint chance',
+ allAttributes: 'to all attributes',
+ xpIncrease: 'additional xp per kill',
+ lvlRequire: 'level requirement reduction',
- 'elementArcanePercent': 'increased arcane damage',
- 'elementFrostPercent': 'increased frost damage',
- 'elementFirePercent': 'increased fire damage',
- 'elementHolyPercent': 'increased holy damage',
- 'elementPoisonPercent': 'increased poison damage',
- 'physicalPercent': 'increased physical damage',
+ elementArcanePercent: 'increased arcane damage',
+ elementFrostPercent: 'increased frost damage',
+ elementFirePercent: 'increased fire damage',
+ elementHolyPercent: 'increased holy damage',
+ elementPoisonPercent: 'increased poison damage',
+ physicalPercent: 'increased physical damage',
- 'elementPercent': 'increased elemental damage',
- 'spellPercent': 'increased spell damage',
+ elementPercent: 'increased elemental damage',
+ spellPercent: 'increased spell damage',
- 'elementAllResist': 'all resistance',
- 'elementArcaneResist': 'arcane resistance',
- 'elementFrostResist': 'frost resistance',
- 'elementFireResist': 'fire resistance',
- 'elementHolyResist': 'holy resistance',
- 'elementPoisonResist': 'poison resistance',
- 'elementAllResist': 'all resistance',
+ elementAllResist: 'all resistance',
+ elementArcaneResist: 'arcane resistance',
+ elementFrostResist: 'frost resistance',
+ elementFireResist: 'fire resistance',
+ elementHolyResist: 'holy resistance',
+ elementPoisonResist: 'poison resistance',
+ elementAllResist: 'all resistance',
- 'attackSpeed': 'attack speed',
- 'castSpeed': 'cast speed',
+ attackSpeed: 'attack speed',
+ castSpeed: 'cast speed',
- 'auraReserveMultiplier': 'aura mana reservation multiplier',
+ auraReserveMultiplier: 'aura mana reservation multiplier',
//This stat is used for gambling when you can't see the stats
- 'stats': 'stats',
+ stats: 'stats',
//Fishing
- 'weight': 'lb',
+ weight: 'lb',
//Rods
- 'catchChance': 'extra catch chance',
- 'catchSpeed': 'faster catch speed',
- 'fishRarity': 'higher fish rarity',
- 'fishWeight': 'increased fish weight',
- 'fishItems': 'extra chance to hook items'
+ catchChance: 'extra catch chance',
+ catchSpeed: 'faster catch speed',
+ fishRarity: 'higher fish rarity',
+ fishWeight: 'increased fish weight',
+ fishItems: 'extra chance to hook items'
};
return {
diff --git a/src/client/js/objects/objBase.js b/src/client/js/objects/objBase.js
index b2a52540..df8d833b 100644
--- a/src/client/js/objects/objBase.js
+++ b/src/client/js/objects/objBase.js
@@ -7,8 +7,8 @@ define([
renderer,
events
) {
- var scale = 40;
- var scaleMult = 5;
+ let scale = 40;
+ let scaleMult = 5;
return {
components: [],
@@ -17,19 +17,18 @@ define([
eventCallbacks: {},
addComponent: function (type, options) {
- var c = this[type];
+ let c = this[type];
if ((!c) || (options.new)) {
- var template = components.getTemplate(type);
+ let template = components.getTemplate(type);
if (!template)
return;
c = $.extend(true, {}, template);
c.obj = this;
- for (var o in options) {
+ for (let o in options)
c[o] = options[o];
- }
//Only use component to initialize other components?
if ((c.init) && (c.init(options)))
@@ -39,16 +38,15 @@ define([
this.components.push(c);
return c;
- } else {
- if (c.extend)
- c.extend(options);
+ }
+ if (c.extend)
+ c.extend(options);
- return c;
- }
+ return c;
},
removeComponent: function (type) {
- var cpn = this[type];
+ let cpn = this[type];
if (!cpn)
return;
@@ -60,10 +58,10 @@ define([
},
update: function () {
- var components = this.components;
- var len = components.length;
- for (var i = 0; i < len; i++) {
- var c = components[i];
+ let components = this.components;
+ let len = components.length;
+ for (let i = 0; i < len; i++) {
+ let c = components[i];
if (c.update)
c.update();
@@ -80,7 +78,7 @@ define([
},
on: function (event, callback) {
- var list = this.eventCallbacks[event] || (this.eventCallbacks[event] = []);
+ let list = this.eventCallbacks[event] || (this.eventCallbacks[event] = []);
list.push(events.on(event, callback));
},
@@ -89,7 +87,7 @@ define([
return;
this.sprite.x = (this.x * scale) + (this.flipX ? scale : 0) + this.offsetX;
- var oldY = this.sprite.x;
+ let oldY = this.sprite.x;
this.sprite.y = (this.y * scale) + this.offsetY;
if (this.sprite.width > scale) {
@@ -107,11 +105,11 @@ define([
this.sprite.scale.x = (this.flipX ? -scaleMult : scaleMult);
['nameSprite', 'chatSprite'].forEach(function (s, i) {
- var sprite = this[s];
+ let sprite = this[s];
if (!sprite)
return;
- var yAdd = scale;
+ let yAdd = scale;
if (i == 1) {
yAdd *= -0.8;
yAdd -= (this.chatter.msg.split('\r\n').length - 1) * scale * 0.8;
@@ -128,16 +126,17 @@ define([
destroy: function () {
if (this.sprite)
renderer.destroyObject(this);
- if (this.nameSprite)
+ if (this.nameSprite) {
renderer.destroyObject({
layerName: 'effects',
sprite: this.nameSprite
});
+ }
- var components = this.components;
- var cLen = components.length;
- for (var i = 0; i < cLen; i++) {
- var c = components[i];
+ let components = this.components;
+ let cLen = components.length;
+ for (let i = 0; i < cLen; i++) {
+ let c = components[i];
if (c.destroy)
c.destroy();
}
diff --git a/src/client/js/objects/objects.js b/src/client/js/objects/objects.js
index de06f6ee..a4606da5 100644
--- a/src/client/js/objects/objects.js
+++ b/src/client/js/objects/objects.js
@@ -9,7 +9,7 @@ define([
renderer,
sound
) {
- var scale = 40;
+ let scale = 40;
return {
showNames: false,
@@ -24,24 +24,24 @@ define([
events.on('onChangeHoverTile', this.getLocation.bind(this));
//Get saved value for showNames, or use the value set above
- var showNames = window.localStorage.getItem('iwd_opt_shownames');
+ let showNames = window.localStorage.getItem('iwd_opt_shownames');
this.showNames = showNames ? (showNames == 'true') : this.showNames;
},
getLocation: function (x, y) {
- var objects = this.objects;
- var oLen = objects.length;
+ let objects = this.objects;
+ let oLen = objects.length;
- var closest = 999;
- var mob = null;
- for (var i = 0; i < oLen; i++) {
- var o = objects[i];
+ let closest = 999;
+ let mob = null;
+ for (let i = 0; i < oLen; i++) {
+ let o = objects[i];
if ((!o.stats) || (o.nonSelectable))
continue;
- var dx = Math.abs(o.x - x);
+ let dx = Math.abs(o.x - x);
if ((dx < 3) && (dx < closest)) {
- var dy = Math.abs(o.y - y);
+ let dy = Math.abs(o.y - y);
if ((dy < 3) && (dy < closest)) {
mob = o;
closest = Math.max(dx, dy);
@@ -53,16 +53,16 @@ define([
},
getClosest: function (x, y, maxDistance, reverse, fromMob) {
- var objects = this.objects;
- var oLen = objects.length;
+ let objects = this.objects;
+ let oLen = objects.length;
- var list = objects.filter(function (o) {
+ let list = objects.filter(function (o) {
if ((!o.stats) || (o.nonSelectable) || (o == window.player))
return false;
- var dx = Math.abs(o.x - x);
+ let dx = Math.abs(o.x - x);
if (dx < maxDistance) {
- var dy = Math.abs(o.y - y);
+ let dy = Math.abs(o.y - y);
if (dy < maxDistance)
return true;
}
@@ -72,35 +72,34 @@ define([
return null;
list.sort(function (a, b) {
- var aDistance = Math.max(Math.abs(x - a.x), Math.abs(y - a.y));
- var bDistance = Math.max(Math.abs(x - b.x), Math.abs(y - b.y));
+ let aDistance = Math.max(Math.abs(x - a.x), Math.abs(y - a.y));
+ let bDistance = Math.max(Math.abs(x - b.x), Math.abs(y - b.y));
return (aDistance - bDistance);
});
- list = list.filter((o) => ((o.aggro) && (o.aggro.faction != window.player.aggro.faction)));
+ list = list.filter(o => ((o.aggro) && (o.aggro.faction != window.player.aggro.faction)));
if (!fromMob)
return list[0];
- var fromIndex = list.firstIndex(function (l) {
+ let fromIndex = list.firstIndex(function (l) {
return (l.id == fromMob.id);
});
- if (reverse) {
+ if (reverse)
fromIndex = (fromIndex === 0 ? list.length : fromIndex) - 1;
- } else {
+ else
fromIndex = (fromIndex + 1) % list.length;
- }
return list[fromIndex];
},
onRezone: function (oldZone) {
- var objects = this.objects;
- var oLen = objects.length
- for (var i = 0; i < oLen; i++) {
- var o = objects[i];
+ let objects = this.objects;
+ let oLen = objects.length;
+ for (let i = 0; i < oLen; i++) {
+ let o = objects[i];
if (oldZone == null)
o.destroy();
@@ -115,7 +114,7 @@ define([
this.dirty = true;
//Things like attacks don't have ids
- var exists = null;
+ let exists = null;
if (obj.id != null) {
exists = this.objects.find(function (o) {
return ((o.id == obj.id) && (!o.destroyed));
@@ -128,16 +127,16 @@ define([
this.updateObject(exists, obj);
},
buildObject: function (template) {
- var obj = $.extend(true, {}, objBase);
+ let obj = $.extend(true, {}, objBase);
- var components = template.components || [];
+ let components = template.components || [];
delete template.components;
- var syncTypes = ['portrait'];
+ let syncTypes = ['portrait'];
- for (var p in template) {
- var value = template[p];
- var type = typeof (value);
+ for (let p in template) {
+ let value = template[p];
+ let type = typeof (value);
if (type == 'object') {
if (syncTypes.indexOf(p) > -1)
@@ -161,12 +160,12 @@ define([
components.forEach(function (c) {
//Map ids to objects
- var keys = Object.keys(c).filter(function (k) {
+ let keys = Object.keys(c).filter(function (k) {
return ((k.indexOf('id') == 0) && (k.length > 2));
});
keys.forEach(function (k) {
- var value = c[k];
- var newKey = k.substr(2, k.length).toLowerCase();
+ let value = c[k];
+ let newKey = k.substr(2, k.length).toLowerCase();
c[newKey] = this.objects.find(function (o) {
return (o.id == value);
@@ -204,16 +203,16 @@ define([
return obj;
},
updateObject: function (obj, template) {
- var components = template.components || [];
+ let components = template.components || [];
components.forEach(function (c) {
//Map ids to objects
- var keys = Object.keys(c).filter(function (k) {
+ let keys = Object.keys(c).filter(function (k) {
return ((k.indexOf('id') == 0) && (k.length > 2));
});
keys.forEach(function (k) {
- var value = c[k];
- var newKey = k.substr(2, k.length).toLowerCase();
+ let value = c[k];
+ let newKey = k.substr(2, k.length).toLowerCase();
c[newKey] = this.objects.find(function (o) {
return (o.id == value);
@@ -233,13 +232,13 @@ define([
delete template.removeComponents;
}
- var oldX = obj.x;
+ let oldX = obj.x;
- var sprite = obj.sprite;
- var moved = false;
- for (var p in template) {
- var value = template[p];
- var type = typeof (value);
+ let sprite = obj.sprite;
+ let moved = false;
+ for (let p in template) {
+ let value = template[p];
+ let type = typeof (value);
if (type != 'object')
obj[p] = value;
@@ -295,11 +294,11 @@ define([
obj.setSpritePosition();
},
update: function () {
- var objects = this.objects;
- var len = objects.length;
+ let objects = this.objects;
+ let len = objects.length;
- for (var i = 0; i < len; i++) {
- var o = objects[i];
+ for (let i = 0; i < len; i++) {
+ let o = objects[i];
if (o.destroyed) {
o.destroy();
@@ -322,13 +321,13 @@ define([
//Set new value in localStorage for showNames
window.localStorage.setItem('iwd_opt_shownames', this.showNames);
- var showNames = this.showNames;
+ let showNames = this.showNames;
- var objects = this.objects;
- var oLen = objects.length;
- for (var i = 0; i < oLen; i++) {
- var obj = objects[i];
- var ns = obj.nameSprite;
+ let objects = this.objects;
+ let oLen = objects.length;
+ for (let i = 0; i < oLen; i++) {
+ let obj = objects[i];
+ let ns = obj.nameSprite;
if ((!ns) || (obj.dead))
continue;
diff --git a/src/client/js/rendering/effects.js b/src/client/js/rendering/effects.js
index a16e6a0b..d8cfc0ea 100644
--- a/src/client/js/rendering/effects.js
+++ b/src/client/js/rendering/effects.js
@@ -1,6 +1,6 @@
define([
-], function(
+], function (
) {
return {
@@ -8,15 +8,15 @@ define([
particles: [],
fog: [],
- register: function(cpn) {
+ register: function (cpn) {
this.list.push(cpn);
},
- unregister: function(cpn) {
- var list = this.list;
- var lLen = list.length;
+ unregister: function (cpn) {
+ let list = this.list;
+ let lLen = list.length;
- for (var i = 0; i < lLen; i++) {
- var l = list[i];
+ for (let i = 0; i < lLen; i++) {
+ let l = list[i];
if (l == cpn) {
list.splice(i, 1);
@@ -25,12 +25,12 @@ define([
}
},
- render: function() {
- var list = this.list;
- var lLen = list.length;
+ render: function () {
+ let list = this.list;
+ let lLen = list.length;
- for (var i = 0; i < lLen; i++) {
- var l = list[i];
+ for (let i = 0; i < lLen; i++) {
+ let l = list[i];
if ((l.destroyed) || (!l.obj) || (l.obj.destroyed)) {
if (((l.destroyManual) && (!l.destroyManual())) || (!l.destroyManual)) {
@@ -46,4 +46,4 @@ define([
}
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/rendering/lightningBuilder.js b/src/client/js/rendering/lightningBuilder.js
index 5d11121c..329a425f 100644
--- a/src/client/js/rendering/lightningBuilder.js
+++ b/src/client/js/rendering/lightningBuilder.js
@@ -1,59 +1,59 @@
define([
'js/rendering/renderer',
'picture'
-], function(
+], function (
renderer,
picture
) {
- var scale = 40;
- var scaleMult = 5;
+ let scale = 40;
+ let scaleMult = 5;
return {
- build: function(config) {
- var obj = {
+ build: function (config) {
+ let obj = {
lines: []
};
- var maxDeviate = config.maxDeviate || (scale * 0.3);
+ let maxDeviate = config.maxDeviate || (scale * 0.3);
- var fx = config.fromX * scale;
- var fy = config.fromY * scale;
+ let fx = config.fromX * scale;
+ let fy = config.fromY * scale;
- var tx = config.toX * scale;
- var ty = config.toY * scale;
+ let tx = config.toX * scale;
+ let ty = config.toY * scale;
- var angle = Math.atan2(ty - fy, tx - fx);
- var distance = Math.sqrt(Math.pow(tx - fx, 2) + Math.pow(ty - fy, 2));
- var divDistance = Math.min(20, distance);
- var divisions = config.divisions || Math.max(1, distance / divDistance);
+ let angle = Math.atan2(ty - fy, tx - fx);
+ let distance = Math.sqrt(Math.pow(tx - fx, 2) + Math.pow(ty - fy, 2));
+ let divDistance = Math.min(20, distance);
+ let divisions = config.divisions || Math.max(1, distance / divDistance);
- var x = fx;
- var y = fy;
+ let x = fx;
+ let y = fy;
- for (var i = 0; i < divisions; i++) {
- var line = {
+ for (let i = 0; i < divisions; i++) {
+ let line = {
sprites: []
};
- var ntx = fx + (Math.cos(angle) * (divDistance * i)) + ~~(Math.random() * (maxDeviate * 2)) - maxDeviate;
- var nty = fy + (Math.sin(angle) * (divDistance * i)) + ~~(Math.random() * (maxDeviate * 2)) - maxDeviate;
+ let ntx = fx + (Math.cos(angle) * (divDistance * i)) + ~~(Math.random() * (maxDeviate * 2)) - maxDeviate;
+ let nty = fy + (Math.sin(angle) * (divDistance * i)) + ~~(Math.random() * (maxDeviate * 2)) - maxDeviate;
if (i == divisions - 1) {
ntx = tx;
nty = ty;
}
- var nAngle = Math.atan2(nty - y, ntx - x);
- var steps = ~~(Math.sqrt(Math.pow(ntx - x, 2) + Math.pow(nty - y, 2)) / scaleMult);
+ let nAngle = Math.atan2(nty - y, ntx - x);
+ let steps = ~~(Math.sqrt(Math.pow(ntx - x, 2) + Math.pow(nty - y, 2)) / scaleMult);
- var patches = {};
+ let patches = {};
- for (var j = 0; j < steps; j++) {
- var alpha = 1;
+ for (let j = 0; j < steps; j++) {
+ let alpha = 1;
if ((config.colors) && (i == divisions - 1) && (j > (steps * 0.75)))
alpha = 1 - (j / steps);
- var c = (config.colors || [0xffeb38, 0xfaac45, 0xfafcfc])[~~(Math.random() * (config.colors ? config.colors.length : 3))];
+ let c = (config.colors || [0xffeb38, 0xfaac45, 0xfafcfc])[~~(Math.random() * (config.colors ? config.colors.length : 3))];
line.sprites.push(renderer.buildRectangle({
x: ~~(x / scaleMult) * scaleMult,
y: ~~(y / scaleMult) * scaleMult,
@@ -64,12 +64,12 @@ define([
layerName: 'effects'
}));
- var xx = x;
- var yy = y;
+ let xx = x;
+ let yy = y;
if ((!patches[xx + '-' + yy]) && (!config.colors)) {
patches[xx + '-' + yy] = 1;
- var lightPatch = renderer.buildObject({
+ let lightPatch = renderer.buildObject({
sheetName: 'white',
x: 0,
y: 0,
@@ -99,25 +99,25 @@ define([
return obj;
},
- toHex: function rgbToHex(r, g, b) {
- var componentToHex = function(c) {
- var hex = c.toString(16);
+ toHex: function rgbToHex (r, g, b) {
+ let componentToHex = function (c) {
+ let hex = c.toString(16);
return hex.length == 1 ? '0' + hex : hex;
};
return '0x' + componentToHex(r) + componentToHex(g) + componentToHex(b);
},
- update: function(obj) {
+ update: function (obj) {
},
- destroy: function(obj) {
- obj.lines.forEach(function(l) {
- l.sprites.forEach(function(s) {
+ destroy: function (obj) {
+ obj.lines.forEach(function (l) {
+ l.sprites.forEach(function (s) {
s.parent.removeChild(s);
});
});
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/rendering/numbers.js b/src/client/js/rendering/numbers.js
index deff41a5..2322cf60 100644
--- a/src/client/js/rendering/numbers.js
+++ b/src/client/js/rendering/numbers.js
@@ -7,8 +7,8 @@ define([
objects,
renderer
) {
- var scale = 40;
- var scaleMult = 5;
+ let scale = 40;
+ let scaleMult = 5;
return {
list: [],
@@ -18,17 +18,17 @@ define([
},
onGetDamage: function (msg) {
- var target = objects.objects.find(function (o) {
+ let target = objects.objects.find(function (o) {
return (o.id == msg.id);
});
if (!target)
return;
- var addY = msg.event ? scale : -(scale * 0.75);
+ let addY = msg.event ? scale : -(scale * 0.75);
- var ttl = 35;
+ let ttl = 35;
- var numberObj = {
+ let numberObj = {
obj: target,
amount: msg.amount,
x: (target.x * scale),
@@ -41,17 +41,17 @@ define([
heal: msg.heal
};
- if (numberObj.event) {
+ if (numberObj.event)
numberObj.y += (scale / 2);
- } else if (numberObj.heal)
+ else if (numberObj.heal)
numberObj.x -= scale;
else
numberObj.x += scale;
- var text = numberObj.text;
+ let text = numberObj.text;
if (!numberObj.event) {
- var amount = numberObj.amount;
- var div = ((~~(amount * 10) / 10) > 0) ? 10 : 100;
+ let amount = numberObj.amount;
+ let div = ((~~(amount * 10) / 10) > 0) ? 10 : 100;
text = (numberObj.heal ? '+' : '') + (~~(amount * div) / div);
}
@@ -67,11 +67,11 @@ define([
},
render: function () {
- var list = this.list;
- var lLen = list.length;
+ let list = this.list;
+ let lLen = list.length;
- for (var i = 0; i < lLen; i++) {
- var l = list[i];
+ for (let i = 0; i < lLen; i++) {
+ let l = list[i];
l.ttl--;
if (l.ttl == 0) {
@@ -90,7 +90,7 @@ define([
else
l.y -= 1;
- var alpha = l.ttl / l.ttlMax;
+ let alpha = l.ttl / l.ttlMax;
l.sprite.x = ~~(l.x / scaleMult) * scaleMult;
l.sprite.y = ~~(l.y / scaleMult) * scaleMult;
diff --git a/src/client/js/rendering/particleDefaults.js b/src/client/js/rendering/particleDefaults.js
index d0ce0524..ce50f264 100644
--- a/src/client/js/rendering/particleDefaults.js
+++ b/src/client/js/rendering/particleDefaults.js
@@ -1,6 +1,6 @@
define([
-], function(
+], function (
) {
return {
@@ -50,4 +50,4 @@ define([
allowRotation: false
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/rendering/particles.js b/src/client/js/rendering/particles.js
index 3854a7e9..0d6f5a7e 100644
--- a/src/client/js/rendering/particles.js
+++ b/src/client/js/rendering/particles.js
@@ -2,7 +2,7 @@ define([
'particles',
'js/rendering/particleDefaults',
'js/rendering/shaders/outline'
-], function(
+], function (
pixiParticles,
particleDefaults,
shaderOutline
@@ -15,17 +15,17 @@ define([
lastTick: null,
- init: function(options) {
+ init: function (options) {
this.r = options.r;
this.renderer = options.renderer;
this.stage = options.stage;
this.lastTick = Date.now();
},
- buildEmitter: function(config) {
- var options = $.extend(true, {}, particleDefaults, config);
+ buildEmitter: function (config) {
+ let options = $.extend(true, {}, particleDefaults, config);
- var emitter = new PIXI.particles.Emitter(this.r.layers.particles, ['images/particles.png'], options);
+ let emitter = new PIXI.particles.Emitter(this.r.layers.particles, ['images/particles.png'], options);
emitter.emit = true;
this.emitters.push(emitter);
@@ -33,21 +33,21 @@ define([
return emitter;
},
- destroyEmitter: function(emitter) {
+ destroyEmitter: function (emitter) {
emitter.emit = false;
},
- update: function() {
- var renderer = this.r;
- var now = Date.now();
+ update: function () {
+ let renderer = this.r;
+ let now = Date.now();
- var emitters = this.emitters;
- var eLen = emitters.length;
- for (var i = 0; i < eLen; i++) {
+ let emitters = this.emitters;
+ let eLen = emitters.length;
+ for (let i = 0; i < eLen; i++) {
var e = emitters[i];
- var visible = null;
- var destroy = !e.emit;
+ let visible = null;
+ let destroy = !e.emit;
if (destroy) {
if (e.particleCount > 0) {
visible = renderer.isVisible(e.spawnPos.x, e.spawnPos.y);
@@ -71,8 +71,8 @@ define([
if (!visible)
continue;
- var r = e.update((now - this.lastTick) * 0.001);
- r.forEach(function(rr) {
+ let r = e.update((now - this.lastTick) * 0.001);
+ r.forEach(function (rr) {
if (e.blendMode == 'overlay')
rr.pluginName = 'picture';
}, this);
@@ -81,4 +81,4 @@ define([
this.lastTick = now;
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/rendering/renderer.js b/src/client/js/rendering/renderer.js
index 8d4df35c..2c685c30 100644
--- a/src/client/js/rendering/renderer.js
+++ b/src/client/js/rendering/renderer.js
@@ -1,807 +1,805 @@
define([
- 'js/resources',
- 'js/system/events',
- 'js/misc/physics',
- 'js/rendering/effects',
- 'js/rendering/tileOpacity',
- 'js/rendering/particles',
- 'js/rendering/shaders/outline',
- 'js/rendering/spritePool',
- 'picture'
+ 'js/resources',
+ 'js/system/events',
+ 'js/misc/physics',
+ 'js/rendering/effects',
+ 'js/rendering/tileOpacity',
+ 'js/rendering/particles',
+ 'js/rendering/shaders/outline',
+ 'js/rendering/spritePool',
+ 'picture'
], function (
- resources,
- events,
- physics,
- effects,
- tileOpacity,
- particles,
- shaderOutline,
- spritePool,
- picture
+ resources,
+ events,
+ physics,
+ effects,
+ tileOpacity,
+ particles,
+ shaderOutline,
+ spritePool,
+ picture
) {
- var scale = 40;
- var scaleMult = 5;
- var pixi = PIXI;
-
- return {
- stage: null,
- layers: {
- objects: null,
- mobs: null,
- characters: null,
- attacks: null,
- effects: null,
- particles: null,
- lightPatches: null,
- lightBeams: null,
- tileSprites: null,
- hiders: null
- },
-
- titleScreen: false,
-
- width: 0,
- height: 0,
-
- showTilesW: 0,
- showTilesH: 0,
-
- pos: {
- x: 0,
- y: 0
- },
- moveTo: null,
- moveSpeed: 0,
- moveSpeedMax: 1.50,
- moveSpeedInc: 0.5,
-
- lastUpdatePos: {
- x: 0,
- y: 0
- },
-
- zoneId: null,
-
- textures: {},
- textureCache: {},
-
- sprites: [],
-
- lastTick: null,
-
- hiddenRooms: null,
-
- init: function () {
- PIXI.GC_MODES.DEFAULT = PIXI.GC_MODES.AUTO;
- PIXI.SCALE_MODES.DEFAULT = PIXI.SCALE_MODES.NEAREST;
-
- events.on('onGetMap', this.onGetMap.bind(this));
- events.on('onToggleFullscreen', this.toggleScreen.bind(this));
-
- this.width = $('body').width();
- this.height = $('body').height();
-
- this.showTilesW = Math.ceil((this.width / scale) / 2) + 3;
- this.showTilesH = Math.ceil((this.height / scale) / 2) + 3;
-
- this.renderer = pixi.autoDetectRenderer(this.width, this.height, {
- backgroundColor: '0x2d2136'
- });
-
- window.onresize = this.onResize.bind(this);
-
- $(this.renderer.view)
- .appendTo('.canvasContainer');
-
- this.stage = new pixi.Container();
-
- var layers = this.layers;
- Object.keys(layers).forEach(function (l) {
- if (l == 'tileSprites') {
- layers[l] = new pixi.Container();
- layers[l].layer = 'tiles';
- } else {
- layers[l] = new pixi.Container();
- layers[l].layer = l;
- }
-
- this.stage.addChild(layers[l])
- }, this);
-
- var spriteNames = ['tiles', 'mobs', 'bosses', 'animBigObjects', 'bigObjects', 'objects', 'characters', 'attacks', 'auras', 'walls', 'ui', 'animChar', 'animMob', 'animBoss', 'white', 'ray'];
- resources.spriteNames.forEach(function (s) {
- if (s.indexOf('.png') > -1)
- spriteNames.push(s);
- });
-
- spriteNames.forEach(function (t) {
- this.textures[t] = new pixi.BaseTexture(resources.sprites[t].image);
- this.textures[t].scaleMode = pixi.SCALE_MODES.NEAREST;
- }, this);
-
- particles.init({
- r: this,
- renderer: this.renderer,
- stage: this.layers.particles
- });
-
- this.buildSpritesTexture();
- },
-
- buildSpritesTexture: function () {
- var container = new pixi.Container();
-
- var totalHeight = 0;
- ['tiles', 'walls', 'objects'].forEach(function (t) {
- var texture = this.textures[t];
- var tile = new pixi.Sprite(new pixi.Texture(texture));
- tile.width = texture.width;
- tile.height = texture.height;
- tile.x = 0;
- tile.y = totalHeight;
-
- container.addChild(tile);
-
- totalHeight += tile.height;
- }, this);
-
- var renderTexture = pixi.RenderTexture.create(this.textures.tiles.width, totalHeight);
- this.renderer.render(container, renderTexture);
-
- this.textures.sprites = renderTexture;
- this.textures.scaleMult = pixi.SCALE_MODES.NEAREST;
- },
-
- toggleScreen: function () {
- var screenMode = 0;
-
- var isFullscreen = (window.innerHeight == screen.height);
- if (isFullscreen)
- screenMode = 0;
- else
- screenMode = 1;
-
- if (screenMode == 0) {
- (document.cancelFullscreen || document.msCancelFullscreen || document.mozCancelFullscreen || document.webkitCancelFullScreen).call(document);
- return 'Windowed';
- } else if (screenMode == 1) {
- var el = $('body')[0];
- (el.requestFullscreen || el.msRequestFullscreen || el.mozRequestFullscreen || el.webkitRequestFullscreen).call(el);
- return 'Fullscreen';
- }
- },
-
- buildTitleScreen: function () {
- this.titleScreen = true;
-
- this.setPosition({
- x: 0,
- y: 0
- }, true);
-
- var w = Math.ceil(this.width / scale) + 1;
- var h = Math.ceil(this.height / scale) + 1;
-
- var container = this.layers.tileSprites;
-
- for (var i = 0; i < w; i++) {
- for (var j = 0; j < h; j++) {
- var ii = i / 10;
- var alpha = Math.sin(((j * 0.2) % 5) + Math.cos(ii % 8));
- var tile = 5;
- if (j < 7)
- tile = 5;
- else if (alpha < -0.2)
- tile = 3;
- else if (alpha < 0.2)
- tile = 4;
- else if ((alpha < 0.5) && (j > 7))
- tile = 53;
-
- alpha = Math.random();
-
- if (tile == 5)
- alpha *= 2;
- else if (tile == 3)
- alpha *= 1;
- else if (tile == 4)
- alpha *= 1;
- else if (tile == 53)
- alpha *= 2;
-
- alpha = Math.min(Math.max(0.15, alpha), 0.65);
-
- if (Math.random() < 0.35) {
- tile = {
- '2': 7,
- '5': 6,
- '3': 0,
- '4': 1,
- '53': 54
- }[tile];
- }
-
- var tile = new pixi.Sprite(this.getTexture('sprites', tile));
-
- tile.alpha = alpha;
- tile.position.x = i * scale;
- tile.position.y = j * scale;
- tile.width = scale;
- tile.height = scale;
-
- if (Math.random() < 0.5) {
- tile.position.x += scale;
- tile.scale.x = -scaleMult;
- }
-
- container.addChild(tile);
- }
- }
- },
-
- onResize: function () {
- var zoom = window.devicePixelRatio;
-
- this.width = $('body').width() * zoom;
- this.height = $('body').height() * zoom;
-
- this.showTilesW = Math.ceil((this.width / scale) / 2) + 3;
- this.showTilesH = Math.ceil((this.height / scale) / 2) + 3;
-
- this.renderer.resize(this.width, this.height);
- if (window.player) {
- this.setPosition({
- x: (window.player.x - (this.width / (scale * 2))) * scale,
- y: (window.player.y - (this.height / (scale * 2))) * scale
- }, true);
- }
-
- if (this.titleScreen) {
- this.clean();
- this.buildTitleScreen();
- }
-
- events.emit('onResize');
- },
-
- getTexture: function (baseTex, cell, size) {
- size = size || 8;
- var name = baseTex + '_' + cell;
-
- var textureCache = this.textureCache;
-
- var cached = textureCache[name];
-
- if (!cached) {
- var y = ~~(cell / 8);
- var x = cell - (y * 8);
- cached = new pixi.Texture(this.textures[baseTex], new pixi.Rectangle(x * size, y * size, size, size));
- textureCache[name] = cached;
- }
-
- return cached;
- },
-
- clean: function () {
- this.stage.removeChild(this.layers.hiders);
- this.layers.hiders = new pixi.Container();
- this.layers.hiders.layer = 'hiders';
- this.stage.addChild(this.layers.hiders);
-
- var container = this.layers.tileSprites;
- this.stage.removeChild(container);
-
- this.layers.tileSprites = container = new pixi.Container();
- container.layer = 'tiles';
- this.stage.addChild(container);
-
- this.stage.children.sort(function (a, b) {
- if (a.layer == 'hiders')
- return 1;
- else if (b.layer == 'hiders')
- return -1;
- else if (a.layer == 'tiles')
- return -1;
- else if (b.layer == 'tiles')
- return 1;
- else
- return 0;
- }, this);
- },
-
- onGetMapCustomization: function (msg) {
- if (!msg.collide) {
- var children = this.layers.tiles.children;
- var cLen = children.length;
- var x = msg.x * scale;
- var y = msg.y * scale;
- for (var i = cLen - 1; i >= 0; i--) {
- var c = children[i];
- var cx = c.x;
- if (c.scale.x < 0)
- cx -= scale;
- if ((cx == x) && (c.y == y)) {
- c.parent.removeChild(c);
- break;
- }
- }
- }
-
- var tile = new pixi.Sprite(this.getTexture('sprites', msg.tile))
-
- tile.alpha = tileOpacity.map(msg.tile);
- tile.position.x = msg.x * scale;
- tile.position.y = msg.y * scale;
- tile.width = scale;
- tile.height = scale;
-
- if (Math.random() < 0.5) {
- tile.position.x += scale;
- tile.scale.x = -scaleMult;
- }
-
- this.layers.tiles.addChild(tile);
-
- physics.collisionMap[msg.x][msg.y] = msg.collide;
- physics.graph.grid[msg.x][msg.y] = !msg.collide;
- },
-
- buildTile: function (c, i, j) {
- var alpha = tileOpacity.map(c);
- var canFlip = tileOpacity.canFlip(c);
-
- var tile = new pixi.Sprite(this.getTexture('sprites', c));
-
- tile.alpha = alpha;
- tile.position.x = i * scale;
- tile.position.y = j * scale;
- tile.width = scale;
- tile.height = scale;
-
- if (canFlip) {
- if (Math.random() < 0.5) {
- tile.position.x += scale;
- tile.scale.x = -scaleMult;
- }
- }
-
- return tile;
- },
-
- onGetMap: function (msg) {
- this.titleScreen = false;
- physics.init(msg.collisionMap);
-
- var map = this.map = msg.map;
- var w = this.w = map.length;
- var h = this.h = map[0].length;
-
- this.clean();
- spritePool.clean();
-
- this.stage.filters = [new PIXI.filters.VoidFilter()];
- this.stage.filterArea = new PIXI.Rectangle(0, 0, w * scale, h * scale);
-
- this.buildHiddenRooms(msg);
-
- this.sprites = _.get2dArray(w, h, 'array');
-
- this.stage.children.sort(function (a, b) {
- if (a.layer == 'tiles')
- return -1;
- else if (b.layer == 'tiles')
- return 1;
- else
- return 0;
- }, this);
-
- if (this.zoneId != null)
- events.emit('onRezone', this.zoneId);
- this.zoneId = msg.zoneId;
-
- msg.clientObjects.forEach(function (c) {
- c.zoneId = this.zoneId;
- events.emit('onGetObject', c);
- }, this);
- },
-
- buildHiddenRooms: function (msg) {
- var hiddenWalls = msg.hiddenWalls;
- var hiddenTiles = msg.hiddenTiles;
-
- this.hiddenRooms = msg.hiddenRooms;
- this.hiddenRooms.forEach(function (h) {
- h.container = new pixi.Container();
- this.layers.hiders.addChild(h.container);
- this.buildRectangle({
- x: h.x * scale,
- y: h.y * scale,
- w: h.width * scale,
- h: h.height * scale,
- color: 0x2d2136,
- parent: h.container
- });
- for (var i = h.x; i < h.x + h.width; i++) {
- for (var j = h.y; j < h.y + h.height; j++) {
- [hiddenTiles, hiddenWalls].forEach(function (k) {
- var cell = k[i][j];
- if (cell == 0)
- return;
-
- var tile = this.buildTile(cell - 1, i, j);
- tile.width = scale;
- tile.height = scale;
- h.container.addChild(tile);
- }, this);
- }
- }
- }, this);
- },
- hideHiders: function () {
- var player = window.player;
- if (!player)
- return;
-
- var x = player.x;
- var y = player.y;
-
- var hiddenRooms = this.hiddenRooms;
- var hLen = hiddenRooms.length;
- for (var i = 0; i < hLen; i++) {
- var h = hiddenRooms[i];
- h.container.visible = (
- (x < h.x) ||
+ let scale = 40;
+ let scaleMult = 5;
+ let pixi = PIXI;
+
+ return {
+ stage: null,
+ layers: {
+ objects: null,
+ mobs: null,
+ characters: null,
+ attacks: null,
+ effects: null,
+ particles: null,
+ lightPatches: null,
+ lightBeams: null,
+ tileSprites: null,
+ hiders: null
+ },
+
+ titleScreen: false,
+
+ width: 0,
+ height: 0,
+
+ showTilesW: 0,
+ showTilesH: 0,
+
+ pos: {
+ x: 0,
+ y: 0
+ },
+ moveTo: null,
+ moveSpeed: 0,
+ moveSpeedMax: 1.50,
+ moveSpeedInc: 0.5,
+
+ lastUpdatePos: {
+ x: 0,
+ y: 0
+ },
+
+ zoneId: null,
+
+ textures: {},
+ textureCache: {},
+
+ sprites: [],
+
+ lastTick: null,
+
+ hiddenRooms: null,
+
+ init: function () {
+ PIXI.GC_MODES.DEFAULT = PIXI.GC_MODES.AUTO;
+ PIXI.SCALE_MODES.DEFAULT = PIXI.SCALE_MODES.NEAREST;
+
+ events.on('onGetMap', this.onGetMap.bind(this));
+ events.on('onToggleFullscreen', this.toggleScreen.bind(this));
+
+ this.width = $('body').width();
+ this.height = $('body').height();
+
+ this.showTilesW = Math.ceil((this.width / scale) / 2) + 3;
+ this.showTilesH = Math.ceil((this.height / scale) / 2) + 3;
+
+ this.renderer = pixi.autoDetectRenderer(this.width, this.height, {
+ backgroundColor: '0x2d2136'
+ });
+
+ window.onresize = this.onResize.bind(this);
+
+ $(this.renderer.view)
+ .appendTo('.canvasContainer');
+
+ this.stage = new pixi.Container();
+
+ let layers = this.layers;
+ Object.keys(layers).forEach(function (l) {
+ if (l == 'tileSprites') {
+ layers[l] = new pixi.Container();
+ layers[l].layer = 'tiles';
+ } else {
+ layers[l] = new pixi.Container();
+ layers[l].layer = l;
+ }
+
+ this.stage.addChild(layers[l]);
+ }, this);
+
+ let spriteNames = ['tiles', 'mobs', 'bosses', 'animBigObjects', 'bigObjects', 'objects', 'characters', 'attacks', 'auras', 'walls', 'ui', 'animChar', 'animMob', 'animBoss', 'white', 'ray'];
+ resources.spriteNames.forEach(function (s) {
+ if (s.indexOf('.png') > -1)
+ spriteNames.push(s);
+ });
+
+ spriteNames.forEach(function (t) {
+ this.textures[t] = new pixi.BaseTexture(resources.sprites[t].image);
+ this.textures[t].scaleMode = pixi.SCALE_MODES.NEAREST;
+ }, this);
+
+ particles.init({
+ r: this,
+ renderer: this.renderer,
+ stage: this.layers.particles
+ });
+
+ this.buildSpritesTexture();
+ },
+
+ buildSpritesTexture: function () {
+ let container = new pixi.Container();
+
+ let totalHeight = 0;
+ ['tiles', 'walls', 'objects'].forEach(function (t) {
+ let texture = this.textures[t];
+ let tile = new pixi.Sprite(new pixi.Texture(texture));
+ tile.width = texture.width;
+ tile.height = texture.height;
+ tile.x = 0;
+ tile.y = totalHeight;
+
+ container.addChild(tile);
+
+ totalHeight += tile.height;
+ }, this);
+
+ let renderTexture = pixi.RenderTexture.create(this.textures.tiles.width, totalHeight);
+ this.renderer.render(container, renderTexture);
+
+ this.textures.sprites = renderTexture;
+ this.textures.scaleMult = pixi.SCALE_MODES.NEAREST;
+ },
+
+ toggleScreen: function () {
+ let screenMode = 0;
+
+ let isFullscreen = (window.innerHeight == screen.height);
+ if (isFullscreen)
+ screenMode = 0;
+ else
+ screenMode = 1;
+
+ if (screenMode == 0) {
+ (document.cancelFullscreen || document.msCancelFullscreen || document.mozCancelFullscreen || document.webkitCancelFullScreen).call(document);
+ return 'Windowed';
+ } else if (screenMode == 1) {
+ let el = $('body')[0];
+ (el.requestFullscreen || el.msRequestFullscreen || el.mozRequestFullscreen || el.webkitRequestFullscreen).call(el);
+ return 'Fullscreen';
+ }
+ },
+
+ buildTitleScreen: function () {
+ this.titleScreen = true;
+
+ this.setPosition({
+ x: 0,
+ y: 0
+ }, true);
+
+ let w = Math.ceil(this.width / scale) + 1;
+ let h = Math.ceil(this.height / scale) + 1;
+
+ let container = this.layers.tileSprites;
+
+ for (let i = 0; i < w; i++) {
+ for (let j = 0; j < h; j++) {
+ let ii = i / 10;
+ let alpha = Math.sin(((j * 0.2) % 5) + Math.cos(ii % 8));
+ var tile = 5;
+ if (j < 7)
+ tile = 5;
+ else if (alpha < -0.2)
+ tile = 3;
+ else if (alpha < 0.2)
+ tile = 4;
+ else if ((alpha < 0.5) && (j > 7))
+ tile = 53;
+
+ alpha = Math.random();
+
+ if (tile == 5)
+ alpha *= 2;
+ else if (tile == 3)
+ alpha *= 1;
+ else if (tile == 4)
+ alpha *= 1;
+ else if (tile == 53)
+ alpha *= 2;
+
+ alpha = Math.min(Math.max(0.15, alpha), 0.65);
+
+ if (Math.random() < 0.35) {
+ tile = {
+ 2: 7,
+ 5: 6,
+ 3: 0,
+ 4: 1,
+ 53: 54
+ }[tile];
+ }
+
+ var tile = new pixi.Sprite(this.getTexture('sprites', tile));
+
+ tile.alpha = alpha;
+ tile.position.x = i * scale;
+ tile.position.y = j * scale;
+ tile.width = scale;
+ tile.height = scale;
+
+ if (Math.random() < 0.5) {
+ tile.position.x += scale;
+ tile.scale.x = -scaleMult;
+ }
+
+ container.addChild(tile);
+ }
+ }
+ },
+
+ onResize: function () {
+ let zoom = window.devicePixelRatio;
+
+ this.width = $('body').width() * zoom;
+ this.height = $('body').height() * zoom;
+
+ this.showTilesW = Math.ceil((this.width / scale) / 2) + 3;
+ this.showTilesH = Math.ceil((this.height / scale) / 2) + 3;
+
+ this.renderer.resize(this.width, this.height);
+ if (window.player) {
+ this.setPosition({
+ x: (window.player.x - (this.width / (scale * 2))) * scale,
+ y: (window.player.y - (this.height / (scale * 2))) * scale
+ }, true);
+ }
+
+ if (this.titleScreen) {
+ this.clean();
+ this.buildTitleScreen();
+ }
+
+ events.emit('onResize');
+ },
+
+ getTexture: function (baseTex, cell, size) {
+ size = size || 8;
+ let name = baseTex + '_' + cell;
+
+ let textureCache = this.textureCache;
+
+ let cached = textureCache[name];
+
+ if (!cached) {
+ let y = ~~(cell / 8);
+ let x = cell - (y * 8);
+ cached = new pixi.Texture(this.textures[baseTex], new pixi.Rectangle(x * size, y * size, size, size));
+ textureCache[name] = cached;
+ }
+
+ return cached;
+ },
+
+ clean: function () {
+ this.stage.removeChild(this.layers.hiders);
+ this.layers.hiders = new pixi.Container();
+ this.layers.hiders.layer = 'hiders';
+ this.stage.addChild(this.layers.hiders);
+
+ let container = this.layers.tileSprites;
+ this.stage.removeChild(container);
+
+ this.layers.tileSprites = container = new pixi.Container();
+ container.layer = 'tiles';
+ this.stage.addChild(container);
+
+ this.stage.children.sort(function (a, b) {
+ if (a.layer == 'hiders')
+ return 1;
+ else if (b.layer == 'hiders')
+ return -1;
+ else if (a.layer == 'tiles')
+ return -1;
+ else if (b.layer == 'tiles')
+ return 1;
+ return 0;
+ }, this);
+ },
+
+ onGetMapCustomization: function (msg) {
+ if (!msg.collide) {
+ let children = this.layers.tiles.children;
+ let cLen = children.length;
+ let x = msg.x * scale;
+ let y = msg.y * scale;
+ for (let i = cLen - 1; i >= 0; i--) {
+ let c = children[i];
+ let cx = c.x;
+ if (c.scale.x < 0)
+ cx -= scale;
+ if ((cx == x) && (c.y == y)) {
+ c.parent.removeChild(c);
+ break;
+ }
+ }
+ }
+
+ let tile = new pixi.Sprite(this.getTexture('sprites', msg.tile));
+
+ tile.alpha = tileOpacity.map(msg.tile);
+ tile.position.x = msg.x * scale;
+ tile.position.y = msg.y * scale;
+ tile.width = scale;
+ tile.height = scale;
+
+ if (Math.random() < 0.5) {
+ tile.position.x += scale;
+ tile.scale.x = -scaleMult;
+ }
+
+ this.layers.tiles.addChild(tile);
+
+ physics.collisionMap[msg.x][msg.y] = msg.collide;
+ physics.graph.grid[msg.x][msg.y] = !msg.collide;
+ },
+
+ buildTile: function (c, i, j) {
+ let alpha = tileOpacity.map(c);
+ let canFlip = tileOpacity.canFlip(c);
+
+ let tile = new pixi.Sprite(this.getTexture('sprites', c));
+
+ tile.alpha = alpha;
+ tile.position.x = i * scale;
+ tile.position.y = j * scale;
+ tile.width = scale;
+ tile.height = scale;
+
+ if (canFlip) {
+ if (Math.random() < 0.5) {
+ tile.position.x += scale;
+ tile.scale.x = -scaleMult;
+ }
+ }
+
+ return tile;
+ },
+
+ onGetMap: function (msg) {
+ this.titleScreen = false;
+ physics.init(msg.collisionMap);
+
+ let map = this.map = msg.map;
+ let w = this.w = map.length;
+ let h = this.h = map[0].length;
+
+ this.clean();
+ spritePool.clean();
+
+ this.stage.filters = [new PIXI.filters.VoidFilter()];
+ this.stage.filterArea = new PIXI.Rectangle(0, 0, w * scale, h * scale);
+
+ this.buildHiddenRooms(msg);
+
+ this.sprites = _.get2dArray(w, h, 'array');
+
+ this.stage.children.sort(function (a, b) {
+ if (a.layer == 'tiles')
+ return -1;
+ else if (b.layer == 'tiles')
+ return 1;
+ return 0;
+ }, this);
+
+ if (this.zoneId != null)
+ events.emit('onRezone', this.zoneId);
+ this.zoneId = msg.zoneId;
+
+ msg.clientObjects.forEach(function (c) {
+ c.zoneId = this.zoneId;
+ events.emit('onGetObject', c);
+ }, this);
+ },
+
+ buildHiddenRooms: function (msg) {
+ let hiddenWalls = msg.hiddenWalls;
+ let hiddenTiles = msg.hiddenTiles;
+
+ this.hiddenRooms = msg.hiddenRooms;
+ this.hiddenRooms.forEach(function (h) {
+ h.container = new pixi.Container();
+ this.layers.hiders.addChild(h.container);
+ this.buildRectangle({
+ x: h.x * scale,
+ y: h.y * scale,
+ w: h.width * scale,
+ h: h.height * scale,
+ color: 0x2d2136,
+ parent: h.container
+ });
+ for (var i = h.x; i < h.x + h.width; i++) {
+ for (var j = h.y; j < h.y + h.height; j++) {
+ [hiddenTiles, hiddenWalls].forEach(function (k) {
+ let cell = k[i][j];
+ if (cell == 0)
+ return;
+
+ let tile = this.buildTile(cell - 1, i, j);
+ tile.width = scale;
+ tile.height = scale;
+ h.container.addChild(tile);
+ }, this);
+ }
+ }
+ }, this);
+ },
+ hideHiders: function () {
+ let player = window.player;
+ if (!player)
+ return;
+
+ let x = player.x;
+ let y = player.y;
+
+ let hiddenRooms = this.hiddenRooms;
+ let hLen = hiddenRooms.length;
+ for (let i = 0; i < hLen; i++) {
+ let h = hiddenRooms[i];
+ h.container.visible = (
+ (x < h.x) ||
(x >= h.x + h.width) ||
(y < h.y) ||
(y >= h.y + h.height)
- );
- }
- },
-
- setPosition: function (pos, instant) {
- pos.x += 16;
- pos.y += 16;
-
- this.hideHiders();
-
- if (instant) {
- this.moveTo = null;
- this.pos = pos;
- this.stage.x = -~~this.pos.x;
- this.stage.y = -~~this.pos.y;
- } else
- this.moveTo = pos;
-
- this.updateSprites();
- },
-
- isVisible: function (x, y) {
- var stage = this.stage;
- var sx = -stage.x;
- var sy = -stage.y;
-
- var sw = this.width;
- var sh = this.height;
-
- return (!((x < sx) || (y < sy) || (x >= sx + sw) || (y >= sy + sh)));
- },
-
- updateSprites: function () {
- if (this.titleScreen)
- return;
-
- var player = window.player;
- if (!player)
- return;
-
- var w = this.w;
- var h = this.h;
-
- var x = ~~((-this.stage.x / scale) + (this.width / (scale * 2)));
- var y = ~~((-this.stage.y / scale) + (this.height / (scale * 2)));
-
- this.lastUpdatePos.x = this.stage.x;
- this.lastUpdatePos.y = this.stage.y;
-
- var sprites = this.sprites;
- var map = this.map;
- var container = this.layers.tileSprites;
-
- var sw = this.showTilesW;
- var sh = this.showTilesH;
-
- var lowX = Math.max(0, x - sw + 1);
- var lowY = Math.max(0, y - sh + 2);
- var highX = Math.min(w, x + sw - 2);
- var highY = Math.min(h, y + sh - 2);
-
- var addedSprite = false;
-
- for (var i = lowX; i < highX; i++) {
- for (var j = lowY; j < highY; j++) {
- cell = map[i][j];
- if (!cell)
- continue;
-
- var rendered = sprites[i][j];
- if (rendered.length > 0)
- continue;
- else if (!cell.split)
- cell += '';
- cell = cell.split(',');
- for (var k = 0; k < cell.length; k++) {
- var c = cell[k];
- if (c == 0)
- continue;
-
- c--;
-
- var flipped = '';
- if (tileOpacity.canFlip(c)) {
- if (Math.random() < 0.5)
- flipped = 'flip';
- }
-
- var tile = spritePool.getSprite(flipped + c);
- if (!tile) {
- tile = this.buildTile(c, i, j);
- container.addChild(tile);
- tile.type = c;
- tile.sheetNum = tileOpacity.getSheetNum(c);
- addedSprite = true;
- } else {
- tile.position.x = i * scale;
- tile.position.y = j * scale;
- if (flipped != '')
- tile.position.x += scale;
- tile.visible = true;
- }
-
- rendered.push(tile);
- }
- }
- }
-
- lowX = Math.max(0, lowX - 10);
- lowY = Math.max(0, lowY - 10);
- highX = Math.min(w - 1, highX + 10);
- highY = Math.min(h - 1, highY + 10);
-
- for (var i = lowX; i < highX; i++) {
- var outside = ((i >= x - sw) && (i < x + sw));
- for (var j = lowY; j < highY; j++) {
- if ((outside) && (j >= y - sh) && (j < y + sh))
- continue;
-
- var list = sprites[i][j];
- var lLen = list.length;
- for (var k = 0; k < lLen; k++) {
- var sprite = list[k];
- sprite.visible = false;
- spritePool.store(sprite);
- }
- sprites[i][j] = [];
- }
- }
-
- //Reorder
- if (addedSprite) {
- container.children.sort(function (a, b) {
- return (a.sheetNum - b.sheetNum);
- });
- }
- },
-
- update: function () {
- var time = +new Date;
-
- if (this.moveTo) {
- var deltaX = this.moveTo.x - this.pos.x;
- var deltaY = this.moveTo.y - this.pos.y;
-
- if ((deltaX != 0) || (deltaY != 0)) {
- var moveSpeed = this.moveSpeed;
- var distance = Math.max(Math.abs(deltaX), Math.abs(deltaY));
-
- var moveSpeedMax = this.moveSpeedMax;
- if (distance > 100)
- moveSpeedMax *= 1.75;
- if (this.moveSpeed < moveSpeedMax)
- this.moveSpeed += this.moveSpeedInc;
-
- var elapsed = time - this.lastTick;
- moveSpeed *= (elapsed / 16.67);
-
- if (moveSpeed > distance)
- moveSpeed = distance;
-
- deltaX = (deltaX / distance) * moveSpeed;
- deltaY = (deltaY / distance) * moveSpeed;
-
- this.pos.x = this.pos.x + (deltaX);
- this.pos.y = this.pos.y + (deltaY);
- } else {
- this.moveSpeed = 0;
- this.moveTo = null;
- }
-
- var stage = this.stage;
- stage.x = -~~this.pos.x;
- stage.y = -~~this.pos.y;
-
- var halfScale = scale / 2;
- if ((Math.abs(stage.x - this.lastUpdatePos.x) > halfScale) || (Math.abs(stage.y - this.lastUpdatePos.y) > halfScale))
- this.updateSprites();
-
- events.emit('onSceneMove');
- }
-
- this.lastTick = time;
- },
-
- buildContainer: function (obj) {
- var container = new pixi.Container;
- this.layers[obj.layerName || obj.sheetName].addChild(container);
-
- return container;
- },
-
- buildRectangle: function (obj) {
- var graphics = new pixi.Graphics;
-
- var alpha = obj.alpha;
- if (alpha != null)
- graphics.alpha = alpha;
-
- var fillAlpha = obj.fillAlpha;
- if (fillAlpha == null)
- fillAlpha = 1;
-
- graphics.beginFill(obj.color || '0x48edff', fillAlpha);
-
- if (obj.strokeColor)
- graphics.lineStyle(scaleMult, obj.strokeColor);
-
- graphics.drawRect(0, 0, obj.w, obj.h);
-
- graphics.endFill();
-
- (obj.parent || this.layers[obj.layerName || obj.sheetName]).addChild(graphics);
-
- graphics.position.x = obj.x;
- graphics.position.y = obj.y;
-
- return graphics;
- },
-
- moveRectangle: function (obj) {
- obj.sprite.position.x = obj.x;
- obj.sprite.position.y = obj.y;
- obj.sprite.width = obj.w;
- obj.sprite.height = obj.h;
- },
-
- buildObject: function (obj) {
- var w = 8;
- var h = 8;
- if (obj.w) {
- w = obj.w / scaleMult;
- h = obj.h / scaleMult;
- }
-
- var bigSheets = ['bosses', 'bigObjects', 'animBigObjects'];
- if ((bigSheets.indexOf(obj.sheetName) > -1) || (obj.sheetName.indexOf('bosses') > -1)) {
- obj.layerName = 'mobs';
- w = 24;
- h = 24;
- obj.w = w * scaleMult;
- obj.h = h * scaleMult;
- }
-
- var sprite = new pixi.Sprite(this.getTexture(obj.sheetName, obj.cell, w))
- sprite.x = obj.x * scale;
- sprite.y = obj.y * scale;
- sprite.width = obj.w || scale;
- sprite.height = obj.h || scale;
-
- if ((bigSheets.indexOf(obj.sheetName) > -1) || (obj.sheetName.indexOf('bosses') > -1)) {
- sprite.x -= scale;
- sprite.y -= (scale * 2);
- }
-
- if (obj.flipX) {
- sprite.scale.x *= -1;
- if (bigSheets.indexOf(obj.sheetName) > -1)
- sprite.x += (scale * 2);
- else
- sprite.x += scale;
- }
-
- (obj.parent || this.layers[obj.layerName || obj.sheetName] || this.layers.objects).addChild(sprite);
-
- return sprite;
- },
-
- addFilter: function (sprite) {
- var thickness = 16;
- if (sprite.width > scale)
- thickness = 8;
-
- var filter = new shaderOutline(this.renderer.width, this.renderer.height, thickness, '0xffffff');
-
- if (!sprite.filters)
- sprite.filters = [filter];
- else
- sprite.filters.push();
-
- return filter;
- },
-
- removeFilter: function (sprite, filter) {
- if (!sprite.filters)
- return;
-
- sprite.filters = null;
- },
-
- buildText: function (obj) {
- var textSprite = new pixi.Text(obj.text, {
- fontFamily: 'bitty',
- fontSize: (obj.fontSize || 14),
- fill: obj.color || 0xF2F5F5,
- stroke: 0x2d2136,
- strokeThickness: 4,
- align: 'center'
- });
-
- textSprite.x = obj.x - (textSprite.width / 2);
- textSprite.y = obj.y;
-
- var parent = obj.parent || this.layers[obj.layerName]
- parent.addChild(textSprite);
-
- return textSprite;
- },
-
- buildEmitter: function (config) {
- return particles.buildEmitter(config);
- },
-
- destroyEmitter: function (emitter) {
- particles.destroyEmitter(emitter);
- },
-
- setSprite: function (obj) {
- var cell = obj.cell;
- var y = ~~(cell / 8);
- var x = cell - (y * 8);
-
- var baseTex = this.textures[obj.sheetName];
- obj.sprite.texture = this.getTexture(obj.sheetName, obj.cell, obj.sprite.width / scaleMult);
- },
-
- reorder: function (sprite) {
- var mobLayer = this.layers.mobs;
- var mobs = mobLayer.children;
- mobs.sort(function (a, b) {
- return (b.y - a.y);
- });
- },
-
- destroyObject: function (obj) {
- if (!obj.sprite.parent)
- return;
- obj.sprite.parent.removeChild(obj.sprite);
- },
-
- render: function () {
- if (!this.stage)
- return;
-
- effects.render();
- particles.update();
-
- this.renderer.render(this.stage);
- }
- };
+ );
+ }
+ },
+
+ setPosition: function (pos, instant) {
+ pos.x += 16;
+ pos.y += 16;
+
+ this.hideHiders();
+
+ if (instant) {
+ this.moveTo = null;
+ this.pos = pos;
+ this.stage.x = -~~this.pos.x;
+ this.stage.y = -~~this.pos.y;
+ } else
+ this.moveTo = pos;
+
+ this.updateSprites();
+ },
+
+ isVisible: function (x, y) {
+ let stage = this.stage;
+ let sx = -stage.x;
+ let sy = -stage.y;
+
+ let sw = this.width;
+ let sh = this.height;
+
+ return (!((x < sx) || (y < sy) || (x >= sx + sw) || (y >= sy + sh)));
+ },
+
+ updateSprites: function () {
+ if (this.titleScreen)
+ return;
+
+ let player = window.player;
+ if (!player)
+ return;
+
+ let w = this.w;
+ let h = this.h;
+
+ let x = ~~((-this.stage.x / scale) + (this.width / (scale * 2)));
+ let y = ~~((-this.stage.y / scale) + (this.height / (scale * 2)));
+
+ this.lastUpdatePos.x = this.stage.x;
+ this.lastUpdatePos.y = this.stage.y;
+
+ let sprites = this.sprites;
+ let map = this.map;
+ let container = this.layers.tileSprites;
+
+ let sw = this.showTilesW;
+ let sh = this.showTilesH;
+
+ let lowX = Math.max(0, x - sw + 1);
+ let lowY = Math.max(0, y - sh + 2);
+ let highX = Math.min(w, x + sw - 2);
+ let highY = Math.min(h, y + sh - 2);
+
+ let addedSprite = false;
+
+ for (var i = lowX; i < highX; i++) {
+ for (var j = lowY; j < highY; j++) {
+ cell = map[i][j];
+ if (!cell)
+ continue;
+
+ let rendered = sprites[i][j];
+ if (rendered.length > 0)
+ continue;
+ else if (!cell.split)
+ cell += '';
+ cell = cell.split(',');
+ for (var k = 0; k < cell.length; k++) {
+ let c = cell[k];
+ if (c == 0)
+ continue;
+
+ c--;
+
+ let flipped = '';
+ if (tileOpacity.canFlip(c)) {
+ if (Math.random() < 0.5)
+ flipped = 'flip';
+ }
+
+ let tile = spritePool.getSprite(flipped + c);
+ if (!tile) {
+ tile = this.buildTile(c, i, j);
+ container.addChild(tile);
+ tile.type = c;
+ tile.sheetNum = tileOpacity.getSheetNum(c);
+ addedSprite = true;
+ } else {
+ tile.position.x = i * scale;
+ tile.position.y = j * scale;
+ if (flipped != '')
+ tile.position.x += scale;
+ tile.visible = true;
+ }
+
+ rendered.push(tile);
+ }
+ }
+ }
+
+ lowX = Math.max(0, lowX - 10);
+ lowY = Math.max(0, lowY - 10);
+ highX = Math.min(w - 1, highX + 10);
+ highY = Math.min(h - 1, highY + 10);
+
+ for (var i = lowX; i < highX; i++) {
+ let outside = ((i >= x - sw) && (i < x + sw));
+ for (var j = lowY; j < highY; j++) {
+ if ((outside) && (j >= y - sh) && (j < y + sh))
+ continue;
+
+ let list = sprites[i][j];
+ let lLen = list.length;
+ for (var k = 0; k < lLen; k++) {
+ let sprite = list[k];
+ sprite.visible = false;
+ spritePool.store(sprite);
+ }
+ sprites[i][j] = [];
+ }
+ }
+
+ //Reorder
+ if (addedSprite) {
+ container.children.sort(function (a, b) {
+ return (a.sheetNum - b.sheetNum);
+ });
+ }
+ },
+
+ update: function () {
+ let time = +new Date();
+
+ if (this.moveTo) {
+ let deltaX = this.moveTo.x - this.pos.x;
+ let deltaY = this.moveTo.y - this.pos.y;
+
+ if ((deltaX != 0) || (deltaY != 0)) {
+ let moveSpeed = this.moveSpeed;
+ let distance = Math.max(Math.abs(deltaX), Math.abs(deltaY));
+
+ let moveSpeedMax = this.moveSpeedMax;
+ if (distance > 100)
+ moveSpeedMax *= 1.75;
+ if (this.moveSpeed < moveSpeedMax)
+ this.moveSpeed += this.moveSpeedInc;
+
+ let elapsed = time - this.lastTick;
+ moveSpeed *= (elapsed / 16.67);
+
+ if (moveSpeed > distance)
+ moveSpeed = distance;
+
+ deltaX = (deltaX / distance) * moveSpeed;
+ deltaY = (deltaY / distance) * moveSpeed;
+
+ this.pos.x = this.pos.x + (deltaX);
+ this.pos.y = this.pos.y + (deltaY);
+ } else {
+ this.moveSpeed = 0;
+ this.moveTo = null;
+ }
+
+ let stage = this.stage;
+ stage.x = -~~this.pos.x;
+ stage.y = -~~this.pos.y;
+
+ let halfScale = scale / 2;
+ if ((Math.abs(stage.x - this.lastUpdatePos.x) > halfScale) || (Math.abs(stage.y - this.lastUpdatePos.y) > halfScale))
+ this.updateSprites();
+
+ events.emit('onSceneMove');
+ }
+
+ this.lastTick = time;
+ },
+
+ buildContainer: function (obj) {
+ let container = new pixi.Container();
+ this.layers[obj.layerName || obj.sheetName].addChild(container);
+
+ return container;
+ },
+
+ buildRectangle: function (obj) {
+ let graphics = new pixi.Graphics();
+
+ let alpha = obj.alpha;
+ if (alpha != null)
+ graphics.alpha = alpha;
+
+ let fillAlpha = obj.fillAlpha;
+ if (fillAlpha == null)
+ fillAlpha = 1;
+
+ graphics.beginFill(obj.color || '0x48edff', fillAlpha);
+
+ if (obj.strokeColor)
+ graphics.lineStyle(scaleMult, obj.strokeColor);
+
+ graphics.drawRect(0, 0, obj.w, obj.h);
+
+ graphics.endFill();
+
+ (obj.parent || this.layers[obj.layerName || obj.sheetName]).addChild(graphics);
+
+ graphics.position.x = obj.x;
+ graphics.position.y = obj.y;
+
+ return graphics;
+ },
+
+ moveRectangle: function (obj) {
+ obj.sprite.position.x = obj.x;
+ obj.sprite.position.y = obj.y;
+ obj.sprite.width = obj.w;
+ obj.sprite.height = obj.h;
+ },
+
+ buildObject: function (obj) {
+ let w = 8;
+ let h = 8;
+ if (obj.w) {
+ w = obj.w / scaleMult;
+ h = obj.h / scaleMult;
+ }
+
+ let bigSheets = ['bosses', 'bigObjects', 'animBigObjects'];
+ if ((bigSheets.indexOf(obj.sheetName) > -1) || (obj.sheetName.indexOf('bosses') > -1)) {
+ obj.layerName = 'mobs';
+ w = 24;
+ h = 24;
+ obj.w = w * scaleMult;
+ obj.h = h * scaleMult;
+ }
+
+ let sprite = new pixi.Sprite(this.getTexture(obj.sheetName, obj.cell, w));
+ sprite.x = obj.x * scale;
+ sprite.y = obj.y * scale;
+ sprite.width = obj.w || scale;
+ sprite.height = obj.h || scale;
+
+ if ((bigSheets.indexOf(obj.sheetName) > -1) || (obj.sheetName.indexOf('bosses') > -1)) {
+ sprite.x -= scale;
+ sprite.y -= (scale * 2);
+ }
+
+ if (obj.flipX) {
+ sprite.scale.x *= -1;
+ if (bigSheets.indexOf(obj.sheetName) > -1)
+ sprite.x += (scale * 2);
+ else
+ sprite.x += scale;
+ }
+
+ (obj.parent || this.layers[obj.layerName || obj.sheetName] || this.layers.objects).addChild(sprite);
+
+ return sprite;
+ },
+
+ addFilter: function (sprite) {
+ let thickness = 16;
+ if (sprite.width > scale)
+ thickness = 8;
+
+ let filter = new shaderOutline(this.renderer.width, this.renderer.height, thickness, '0xffffff');
+
+ if (!sprite.filters)
+ sprite.filters = [filter];
+ else
+ sprite.filters.push();
+
+ return filter;
+ },
+
+ removeFilter: function (sprite, filter) {
+ if (!sprite.filters)
+ return;
+
+ sprite.filters = null;
+ },
+
+ buildText: function (obj) {
+ let textSprite = new pixi.Text(obj.text, {
+ fontFamily: 'bitty',
+ fontSize: (obj.fontSize || 14),
+ fill: obj.color || 0xF2F5F5,
+ stroke: 0x2d2136,
+ strokeThickness: 4,
+ align: 'center'
+ });
+
+ textSprite.x = obj.x - (textSprite.width / 2);
+ textSprite.y = obj.y;
+
+ let parent = obj.parent || this.layers[obj.layerName];
+ parent.addChild(textSprite);
+
+ return textSprite;
+ },
+
+ buildEmitter: function (config) {
+ return particles.buildEmitter(config);
+ },
+
+ destroyEmitter: function (emitter) {
+ particles.destroyEmitter(emitter);
+ },
+
+ setSprite: function (obj) {
+ let cell = obj.cell;
+ let y = ~~(cell / 8);
+ let x = cell - (y * 8);
+
+ let baseTex = this.textures[obj.sheetName];
+ obj.sprite.texture = this.getTexture(obj.sheetName, obj.cell, obj.sprite.width / scaleMult);
+ },
+
+ reorder: function (sprite) {
+ let mobLayer = this.layers.mobs;
+ let mobs = mobLayer.children;
+ mobs.sort(function (a, b) {
+ return (b.y - a.y);
+ });
+ },
+
+ destroyObject: function (obj) {
+ if (!obj.sprite.parent)
+ return;
+ obj.sprite.parent.removeChild(obj.sprite);
+ },
+
+ render: function () {
+ if (!this.stage)
+ return;
+
+ effects.render();
+ particles.update();
+
+ this.renderer.render(this.stage);
+ }
+ };
});
diff --git a/src/client/js/rendering/shaders/outline.js b/src/client/js/rendering/shaders/outline.js
index 5d2d8756..331e802d 100644
--- a/src/client/js/rendering/shaders/outline.js
+++ b/src/client/js/rendering/shaders/outline.js
@@ -2,12 +2,12 @@ define([
'pixi',
'js/rendering/shaders/outline/vert',
'js/rendering/shaders/outline/frag'
-], function(
+], function (
pixi,
vert,
frag
) {
- var OutlineFilter = function(viewWidth, viewHeight, thickness, color) {
+ let OutlineFilter = function (viewWidth, viewHeight, thickness, color) {
thickness = thickness || 1;
pixi.Filter.call(this,
vert,
@@ -19,9 +19,8 @@ define([
this.uniforms.thickness = thickness;
this.uniforms.outlineColor = new Float32Array([0, 0, 0, 1]);
this.alpha = 0;
- if (color) {
+ if (color)
this.color = color;
- }
};
OutlineFilter.prototype = Object.create(pixi.Filter.prototype);
@@ -29,38 +28,38 @@ define([
Object.defineProperties(OutlineFilter.prototype, {
color: {
- get: function() {
+ get: function () {
return pixi.utils.rgb2hex(this.uniforms.outlineColor);
},
- set: function(value) {
+ set: function (value) {
pixi.utils.hex2rgb(value, this.uniforms.outlineColor);
}
},
alpha: {
- set: function(value) {
+ set: function (value) {
this.uniforms.alpha = value;
}
},
viewWidth: {
- get: function() {
+ get: function () {
return 1 / this.uniforms.pixelWidth;
},
- set: function(value) {
+ set: function (value) {
this.uniforms.pixelWidth = 1 / value;
}
},
viewHeight: {
- get: function() {
+ get: function () {
return 1 / this.uniforms.pixelHeight;
},
- set: function(value) {
+ set: function (value) {
this.uniforms.pixelHeight = 1 / value;
}
}
});
return OutlineFilter;
-});
\ No newline at end of file
+});
diff --git a/src/client/js/rendering/shaders/outline/frag.js b/src/client/js/rendering/shaders/outline/frag.js
index 675f03e9..a0b125c8 100644
--- a/src/client/js/rendering/shaders/outline/frag.js
+++ b/src/client/js/rendering/shaders/outline/frag.js
@@ -1,9 +1,9 @@
define([
-], function(
+], function (
) {
- return `
+ return `
varying vec2 vTextureCoord;
uniform sampler2D uSampler;
@@ -30,4 +30,4 @@ define([
gl_FragColor = vec4((ownColor.rgb + outlineColor.rgb * (1. - ownColor.a)) * resultAlpha, resultAlpha);
}
`;
-});
\ No newline at end of file
+});
diff --git a/src/client/js/rendering/shaders/outline/vert.js b/src/client/js/rendering/shaders/outline/vert.js
index a2cc478c..242a65e1 100644
--- a/src/client/js/rendering/shaders/outline/vert.js
+++ b/src/client/js/rendering/shaders/outline/vert.js
@@ -1,6 +1,6 @@
define([
-], function(
+], function (
) {
return `
@@ -15,4 +15,4 @@ define([
vTextureCoord = aTextureCoord;
}
`;
-});
\ No newline at end of file
+});
diff --git a/src/client/js/rendering/spritePool.js b/src/client/js/rendering/spritePool.js
index a7b92d8a..921a367c 100644
--- a/src/client/js/rendering/spritePool.js
+++ b/src/client/js/rendering/spritePool.js
@@ -1,36 +1,34 @@
define([
-], function(
+], function (
) {
return {
pool: {},
- clean: function() {
+ clean: function () {
this.pool = {};
},
- getSprite: function(type) {
- var list = this.pool[type];
+ getSprite: function (type) {
+ let list = this.pool[type];
if (!list)
return null;
else if (list.length == 0)
return null;
- else
- return list.pop();
+ return list.pop();
},
- store: function(sprite) {
- var pool = this.pool;
- var type = sprite.type;
+ store: function (sprite) {
+ let pool = this.pool;
+ let type = sprite.type;
if (sprite.scale.x < 0)
type = 'flip' + type;
- var list = pool[type];
- if (!list) {
+ let list = pool[type];
+ if (!list)
list = pool[type] = [];
- }
list.push(sprite);
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/rendering/tileOpacity.js b/src/client/js/rendering/tileOpacity.js
index e9b459ad..d374efa3 100644
--- a/src/client/js/rendering/tileOpacity.js
+++ b/src/client/js/rendering/tileOpacity.js
@@ -6,74 +6,74 @@ define([
return {
sheetHeight: 20,
- 'tiles': {
+ tiles: {
default: 0.4,
max: 0.55,
- '5': 0.7,
- '6': 0.9,
- '23': 0.9,
- '24': 0.9,
- '25': 0.9,
- '50': 1,
- '51': 1,
- '52': 1,
- '53': 0.7,
- '54': 0.5,
- '57': 1,
- '58': 1,
- '59': 1,
- '60': 0.9,
- '61': 0.9,
- '62': 0.75,
- '76': 0.9,
- '80': 1,
- '81': 1,
- '82': 1,
- '83': 1,
- '87': 1,
- '90': 1,
- '95': 1,
- '102': 0.9,
- '152': 0.9,
- '153': 1,
- '163': 0.9,
+ 5: 0.7,
+ 6: 0.9,
+ 23: 0.9,
+ 24: 0.9,
+ 25: 0.9,
+ 50: 1,
+ 51: 1,
+ 52: 1,
+ 53: 0.7,
+ 54: 0.5,
+ 57: 1,
+ 58: 1,
+ 59: 1,
+ 60: 0.9,
+ 61: 0.9,
+ 62: 0.75,
+ 76: 0.9,
+ 80: 1,
+ 81: 1,
+ 82: 1,
+ 83: 1,
+ 87: 1,
+ 90: 1,
+ 95: 1,
+ 102: 0.9,
+ 152: 0.9,
+ 153: 1,
+ 163: 0.9,
//snow
- '176': 0.55,
- '184': 0.55,
- '185': 0.55
+ 176: 0.55,
+ 184: 0.55,
+ 185: 0.55
},
objects: {
default: 0.9,
- '50': 1
+ 50: 1
},
- 'walls': {
+ walls: {
default: 0.85,
max: 1,
- '84': 1,
- '103': 0.9,
- '107': 0.9,
- '116': 1,
- '120': 0.9,
- '132': 0.9,
- '133': 0.9,
- '134': 0.85,
- '139': 1,
- '148': 1,
- '150': 0.85,
- '156': 1,
- '157': 1,
- '158': 1,
- '159': 1,
- '160': 0.9,
- '161': 1,
- '162': 1,
- '163': 1,
- '164': 0.8,
- '165': 1,
- '166': 0.95,
- '167': 1,
- '168': 1,
- '169': 1
+ 84: 1,
+ 103: 0.9,
+ 107: 0.9,
+ 116: 1,
+ 120: 0.9,
+ 132: 0.9,
+ 133: 0.9,
+ 134: 0.85,
+ 139: 1,
+ 148: 1,
+ 150: 0.85,
+ 156: 1,
+ 157: 1,
+ 158: 1,
+ 159: 1,
+ 160: 0.9,
+ 161: 1,
+ 162: 1,
+ 163: 1,
+ 164: 0.8,
+ 165: 1,
+ 166: 0.95,
+ 167: 1,
+ 168: 1,
+ 169: 1
},
tilesNoFlip: [
@@ -98,12 +98,11 @@ define([
return 0;
else if (tile < 448)
return 1;
- else
- return 2;
+ return 2;
},
map: function (tile) {
- var sheetNum;
+ let sheetNum;
if (tile < 192)
sheetNum = 0;
@@ -115,9 +114,9 @@ define([
sheetNum = 2;
}
- var tilesheet = [this.tiles, this.walls, this.objects][sheetNum];
+ let tilesheet = [this.tiles, this.walls, this.objects][sheetNum];
- var alpha = (tilesheet[tile] || tilesheet.default);
+ let alpha = (tilesheet[tile] || tilesheet.default);
if (tilesheet.max != null) {
alpha = alpha + (Math.random() * (alpha * 0.2));
alpha = Math.min(1, alpha);
@@ -127,7 +126,7 @@ define([
},
canFlip: function (tile) {
- var sheetNum;
+ let sheetNum;
if (tile < 192)
sheetNum = 0;
@@ -139,7 +138,7 @@ define([
sheetNum = 2;
}
- var tilesheet = [this.tilesNoFlip, this.wallsNoFlip, this.objectsNoFlip][sheetNum];
+ let tilesheet = [this.tilesNoFlip, this.wallsNoFlip, this.objectsNoFlip][sheetNum];
return (tilesheet.indexOf(tile) == -1);
}
};
diff --git a/src/client/js/resources.js b/src/client/js/resources.js
index 47bd1c83..507144f8 100644
--- a/src/client/js/resources.js
+++ b/src/client/js/resources.js
@@ -3,7 +3,7 @@ define([
], function (
events
) {
- var resources = {
+ let resources = {
spriteNames: [
'charas',
'tiles',
@@ -40,7 +40,7 @@ define([
}, this);
this.spriteNames.forEach(function (s) {
- var sprite = {
+ let sprite = {
image: (new Image()),
ready: false
};
@@ -53,8 +53,8 @@ define([
onSprite: function (sprite) {
sprite.ready = true;
- var readyCount = 0;
- for (var s in this.sprites) {
+ let readyCount = 0;
+ for (let s in this.sprites) {
if (this.sprites[s].ready)
readyCount++;
}
diff --git a/src/client/js/sound/sound.js b/src/client/js/sound/sound.js
index c03172bb..0a4b77ab 100644
--- a/src/client/js/sound/sound.js
+++ b/src/client/js/sound/sound.js
@@ -28,22 +28,22 @@ define([
update: function (x, y) {
this.sounds.forEach(function (s) {
- var dx = Math.abs(s.x - x);
+ let dx = Math.abs(s.x - x);
if (dx > 10) {
if (s.sound)
s.sound.volume(0);
return;
}
- var dy = Math.abs(s.y - y);
+ let dy = Math.abs(s.y - y);
if (dy > 10) {
if (s.sound)
s.sound.volume(0);
return;
}
- var dist = 10 - Math.max(dx, dy);
+ let dist = 10 - Math.max(dx, dy);
dist = (dist * dist) / 100;
- var volume = 0.3 * dist;
+ let volume = 0.3 * dist;
if (!s.sound) {
s.sound = new Howl({
@@ -59,7 +59,7 @@ define([
},
addSound: function (file, x, y) {
- var sound = {
+ let sound = {
file: file,
x: x,
y: y,
diff --git a/src/client/js/spriteBuilder.js b/src/client/js/spriteBuilder.js
index 77cfb5a8..df5212ec 100644
--- a/src/client/js/spriteBuilder.js
+++ b/src/client/js/spriteBuilder.js
@@ -1,19 +1,19 @@
define([
'js/resources',
'js/rendering/tileOpacity'
-], function(
+], function (
resources,
tileOpacity
) {
- var tileSize = 32;
- var width = 0;
- var height = 0;
+ let tileSize = 32;
+ let width = 0;
+ let height = 0;
- var canvas = null;
- var ctx = null;
+ let canvas = null;
+ let ctx = null;
return {
- buildSprite: function(layers, maps, opacities) {
+ buildSprite: function (layers, maps, opacities) {
width = maps[0].length;
height = maps[0][0].length;
@@ -34,41 +34,40 @@ define([
return canvas[0];
},
- build: function(layers, maps, opacities) {
- var random = Math.random.bind(Math);
+ build: function (layers, maps, opacities) {
+ let random = Math.random.bind(Math);
- for (var m = 0; m < maps.length; m++) {
- var map = maps[m];
+ for (let m = 0; m < maps.length; m++) {
+ let map = maps[m];
if (!map)
continue;
- var layer = layers[m];
- var sprite = resources.sprites[layer].image;
+ let layer = layers[m];
+ let sprite = resources.sprites[layer].image;
- var opacity = opacities[m];
+ let opacity = opacities[m];
- for (var i = 0; i < width; i++) {
- var x = i * tileSize;
- for (var j = 0; j < height; j++) {
- var y = j * tileSize;
+ for (let i = 0; i < width; i++) {
+ let x = i * tileSize;
+ for (let j = 0; j < height; j++) {
+ let y = j * tileSize;
- var cell = map[i][j];
+ let cell = map[i][j];
if (cell == 0)
continue;
cell--;
- var tileY = ~~(cell / 8);
- var tileX = cell - (tileY * 8);
+ let tileY = ~~(cell / 8);
+ let tileX = cell - (tileY * 8);
- var tileO = tileOpacity[layer];
+ let tileO = tileOpacity[layer];
if (tileO) {
if (tileO[cell])
ctx.globalAlpha = tileO[cell];
else
ctx.globalAlpha = opacity;
- }
- else
+ } else
ctx.globalAlpha = opacity;
if (random() > 0.5) {
@@ -83,8 +82,7 @@ define([
tileSize,
tileSize
);
- }
- else {
+ } else {
ctx.save();
ctx.scale(-1, 1);
ctx.drawImage(
@@ -105,4 +103,4 @@ define([
}
}
};
-});
\ No newline at end of file
+});
diff --git a/src/client/js/system/addons.js b/src/client/js/system/addons.js
index 1bf896d3..7890e512 100644
--- a/src/client/js/system/addons.js
+++ b/src/client/js/system/addons.js
@@ -2,18 +2,18 @@ window.addons = {
addons: [],
events: null,
- register: function(addon) {
+ register: function (addon) {
this.addons.push(addon);
if (this.events)
addon.init(this.events);
},
- init: function(events) {
+ init: function (events) {
this.events = events;
- this.addons.forEach(function(m) {
+ this.addons.forEach(function (m) {
m.init(this.events);
}, this);
}
-};
\ No newline at end of file
+};
diff --git a/src/client/js/system/client.js b/src/client/js/system/client.js
index 1ebfca4c..f84f1657 100644
--- a/src/client/js/system/client.js
+++ b/src/client/js/system/client.js
@@ -5,11 +5,11 @@ define([
io,
events
) {
- var client = {
+ let client = {
doneConnect: false,
init: function (onReady) {
- var tType = 'websocket';
+ let tType = 'websocket';
if (window.location.href.indexOf('polling') > -1)
tType = 'polling';
@@ -49,9 +49,9 @@ define([
//If we get objects, self needs to be first
// otherwise we might create the object (setting his position or attack animation)
// before instantiating it
- var oList = response.onGetObject;
+ let oList = response.onGetObject;
if (oList) {
- var prepend = oList.filter(function (o) {
+ let prepend = oList.filter(function (o) {
return o.self;
});
oList.spliceWhere(function (o) {
@@ -63,7 +63,7 @@ define([
}
for (var e in response) {
- var r = response[e];
+ let r = response[e];
//Certain messages expect to be performed last (because the object they act on hasn't been greated when they get queued)
r.sort(function (a, b) {
@@ -71,8 +71,7 @@ define([
return 1;
else if (b.performLast)
return -1;
- else
- return 0;
+ return 0;
});
r.forEach(function (o) {
diff --git a/src/client/js/system/events.js b/src/client/js/system/events.js
index 6916e6e0..4bbd4ef9 100644
--- a/src/client/js/system/events.js
+++ b/src/client/js/system/events.js
@@ -3,15 +3,15 @@ define([
], function (
) {
- var events = {
+ let events = {
events: {},
queue: [],
on: function (event, callback) {
- var list = this.events[event] || (this.events[event] = []);
+ let list = this.events[event] || (this.events[event] = []);
list.push(callback);
- for (var i = 0; i < this.queue.length; i++) {
- var q = this.queue[i];
+ for (let i = 0; i < this.queue.length; i++) {
+ let q = this.queue[i];
if (q.event != event)
continue;
@@ -32,9 +32,9 @@ define([
});
},
off: function (event, callback) {
- var list = this.events[event] || [];
- var lLen = list.length;
- for (var i = 0; i < lLen; i++) {
+ let list = this.events[event] || [];
+ let lLen = list.length;
+ for (let i = 0; i < lLen; i++) {
if (list[i] == callback) {
list.splice(i, 1);
i--;
@@ -46,9 +46,9 @@ define([
delete this.events[event];
},
emit: function (event) {
- var args = [].slice.call(arguments, 1);
+ let args = [].slice.call(arguments, 1);
- var list = this.events[event];
+ let list = this.events[event];
if (!list) {
this.queue.push({
event: event,
@@ -58,9 +58,9 @@ define([
return;
}
- var len = list.length
- for (var i = 0; i < len; i++) {
- var l = list[i];
+ let len = list.length;
+ for (let i = 0; i < len; i++) {
+ let l = list[i];
l.apply(null, args);
}
}
diff --git a/src/client/js/system/globals.js b/src/client/js/system/globals.js
index 10fecfd1..f9a3a202 100644
--- a/src/client/js/system/globals.js
+++ b/src/client/js/system/globals.js
@@ -1,9 +1,9 @@
define([
-], function(
+], function (
) {
return {
};
-});
\ No newline at end of file
+});
diff --git a/src/client/ui/factory.js b/src/client/ui/factory.js
index 332ada1f..0c221eea 100644
--- a/src/client/ui/factory.js
+++ b/src/client/ui/factory.js
@@ -60,8 +60,8 @@ define([
build: function (type, options) {
//Don't make doubles?
- var className = 'ui' + type[0].toUpperCase() + type.substr(1);
- var el = $('.' + className);
+ let className = 'ui' + type[0].toUpperCase() + type.substr(1);
+ let el = $('.' + className);
if (el.length > 0)
return;
@@ -71,7 +71,7 @@ define([
require([this.root + 'ui/templates/' + type + '/' + type], this.onGetTemplate.bind(this, options));
},
onGetTemplate: function (options, template) {
- var ui = _.create(uiBase, template);
+ let ui = _.create(uiBase, template);
ui.setOptions(options);
ui.render();
ui.el.data('ui', ui);
@@ -102,10 +102,10 @@ define([
},
update: function () {
- var uis = this.uis;
- var uLen = uis.length;
- for (var i = 0; i < uLen; i++) {
- var u = uis[i];
+ let uis = this.uis;
+ let uLen = uis.length;
+ for (let i = 0; i < uLen; i++) {
+ let u = uis[i];
if (u.update)
u.update();
}
diff --git a/src/client/ui/templates/announcements/announcements.js b/src/client/ui/templates/announcements/announcements.js
index 24da080f..27d63478 100644
--- a/src/client/ui/templates/announcements/announcements.js
+++ b/src/client/ui/templates/announcements/announcements.js
@@ -3,7 +3,7 @@ define([
'html!ui/templates/announcements/template',
'css!ui/templates/announcements/styles',
'html!ui/templates/announcements/templateLine'
-], function(
+], function (
events,
template,
styles,
@@ -15,19 +15,19 @@ define([
message: null,
maxTtl: 160,
- postRender: function() {
+ postRender: function () {
this.onEvent('onGetAnnouncement', this.onGetAnnouncement.bind(this));
},
- onGetAnnouncement: function(e) {
+ onGetAnnouncement: function (e) {
this.clearMessage();
- var container = this.find('.list');
+ let container = this.find('.list');
- var html = templateLine
+ let html = templateLine
.replace('$MSG$', e.msg);
- var el = $(html)
+ let el = $(html)
.appendTo(container);
if (e.type)
@@ -43,8 +43,8 @@ define([
};
},
- update: function() {
- var message = this.message;
+ update: function () {
+ let message = this.message;
if (!message)
return;
@@ -54,13 +54,13 @@ define([
this.clearMessage();
},
- clearMessage: function() {
- var message = this.message;
+ clearMessage: function () {
+ let message = this.message;
if (!message)
return;
this.message = null;
message.el.remove();
}
- }
-});
\ No newline at end of file
+ };
+});
diff --git a/src/client/ui/templates/buffs/buffs.js b/src/client/ui/templates/buffs/buffs.js
index 72eda6b3..73340c51 100644
--- a/src/client/ui/templates/buffs/buffs.js
+++ b/src/client/ui/templates/buffs/buffs.js
@@ -9,7 +9,7 @@ define([
styles,
templateBuff
) {
- var icons = {
+ let icons = {
stunned: [4, 0],
regenHp: [3, 1],
regenMana: [4, 1],
@@ -30,15 +30,15 @@ define([
},
onGetBuff: function (buff) {
- var icon = icons[buff.type];
+ let icon = icons[buff.type];
if (!icon)
return;
- var imgX = icon[0] * -32;
- var imgY = icon[1] * -32;
+ let imgX = icon[0] * -32;
+ let imgY = icon[1] * -32;
- var html = templateBuff;
- var el = $(html).appendTo(this.el)
+ let html = templateBuff;
+ let el = $(html).appendTo(this.el)
.find('.inner')
.css({
background: 'url(../../../images/statusIcons.png) ' + imgX + 'px ' + imgY + 'px'
@@ -48,12 +48,12 @@ define([
},
onRemoveBuff: function (buff) {
- var el = this.icons[buff.id];
+ let el = this.icons[buff.id];
if (!el)
return;
el.remove();
delete this.icons[buff.id];
}
- }
+ };
});
diff --git a/src/client/ui/templates/characters/characters.js b/src/client/ui/templates/characters/characters.js
index 233be79f..adbe1db1 100644
--- a/src/client/ui/templates/characters/characters.js
+++ b/src/client/ui/templates/characters/characters.js
@@ -31,7 +31,7 @@ define([
},
onPlayClick: function () {
- var char = this.selected;
+ let char = this.selected;
if (!char)
return;
@@ -72,7 +72,7 @@ define([
this.el.removeClass('disabled');
- var list = this.find('.left')
+ let list = this.find('.left')
.empty();
characters
@@ -80,14 +80,14 @@ define([
return (b.level - a.level);
})
.forEach(function (c, i) {
- var name = c.name;
+ let name = c.name;
if (c.level != null)
- name += ' (' + c.level + ')'
+ name += ' (' + c.level + ')';
- var html = templateListItem
+ let html = templateListItem
.replace('$NAME$', name);
- var li = $(html)
+ let li = $(html)
.appendTo(list);
li.on('click', this.onCharacterClick.bind(this, c.name));
@@ -99,11 +99,11 @@ define([
onCharacterClick: function (name, e) {
this.el.addClass('disabled');
- var el = $(e.target);
+ let el = $(e.target);
el.parent().find('.selected').removeClass('selected');
el.addClass('selected');
- var charInfo = this.characterInfo[name];
+ let charInfo = this.characterInfo[name];
if (charInfo) {
this.onGetCharacter(name, charInfo);
@@ -122,13 +122,13 @@ define([
onGetCharacter: function (name, result) {
this.find('.button').removeClass('disabled');
- var spriteY = ~~(result.cell / 8);
- var spirteX = result.cell - (spriteY * 8);
+ let spriteY = ~~(result.cell / 8);
+ let spirteX = result.cell - (spriteY * 8);
spirteX = -(spirteX * 8);
spriteY = -(spriteY * 8);
- var spritesheet = result.sheetName;
+ let spritesheet = result.sheetName;
if (spritesheet == 'characters')
spritesheet = '../../../images/characters.png';
@@ -137,7 +137,7 @@ define([
.show();
this.find('.name').html(name);
- var stats = result.components.find(function (c) {
+ let stats = result.components.find(function (c) {
return (c.type == 'stats');
});
if (stats) {
@@ -146,16 +146,15 @@ define([
' ' +
result.class[0].toUpperCase() + result.class.substr(1)
);
- } else {
+ } else
this.find('.class').html('');
- }
this.el.removeClass('disabled');
this.characterInfo[name] = result;
this.selected = name;
- var prophecies = result.components.find(function (c) {
+ let prophecies = result.components.find(function (c) {
return (c.type == 'prophecies');
});
@@ -186,7 +185,7 @@ define([
this.find('.btnDelete')
.removeClass('deleting')
.addClass('deleting')
- .html('delete (' + (4 - this.deleteCount) + ')')
+ .html('delete (' + (4 - this.deleteCount) + ')');
return;
}
diff --git a/src/client/ui/templates/context/context.js b/src/client/ui/templates/context/context.js
index 4d08f647..467c65e4 100644
--- a/src/client/ui/templates/context/context.js
+++ b/src/client/ui/templates/context/context.js
@@ -3,7 +3,7 @@ define([
'html!ui/templates/context/template',
'css!ui/templates/context/styles',
'html!ui/templates/context/templateItem'
-], function(
+], function (
events,
template,
styles,
@@ -13,7 +13,7 @@ define([
tpl: template,
modal: true,
- postRender: function() {
+ postRender: function () {
this.onEvent('onContextMenu', this.onContextMenu.bind(this));
this.onEvent('onHideContextMenu', this.onMouseDown.bind(this));
this.onEvent('mouseDown', this.onMouseDown.bind(this));
@@ -21,17 +21,17 @@ define([
$('.ui-container').on('mouseup', this.onMouseDown.bind(this));
},
- onContextMenu: function(config, e) {
- var container = this.el.find('.list')
+ onContextMenu: function (config, e) {
+ let container = this.el.find('.list')
.empty();
- config.forEach(function(c, i) {
- var text = c.text ? c.text : c;
+ config.forEach(function (c, i) {
+ let text = c.text ? c.text : c;
- var html = templateItem
+ let html = templateItem
.replace('$TEXT$', text);
- var row = $(html)
+ let row = $(html)
.appendTo(container);
if (c.callback)
@@ -48,16 +48,16 @@ define([
.show();
},
- onClick: function(index, callback) {
+ onClick: function (index, callback) {
this.el.hide();
callback();
},
- onMouseDown: function(e) {
+ onMouseDown: function (e) {
if ((!this.el.is(':visible')) || (e.cancel) || (e.button == 2))
return;
this.el.hide();
}
- }
-});
\ No newline at end of file
+ };
+});
diff --git a/src/client/ui/templates/createCharacter/createCharacter.js b/src/client/ui/templates/createCharacter/createCharacter.js
index 116ca639..905124ce 100644
--- a/src/client/ui/templates/createCharacter/createCharacter.js
+++ b/src/client/ui/templates/createCharacter/createCharacter.js
@@ -72,25 +72,25 @@ define([
},
onProphecyHover: function (e) {
- var el = $(e.currentTarget);
+ let el = $(e.currentTarget);
- var pos = {
+ let pos = {
x: e.clientX + 25,
y: e.clientY
};
- var text = el.attr('tooltip');
+ let text = el.attr('tooltip');
events.emit('onShowTooltip', text, el[0], pos);
$('.uiTooltips .tooltip').addClass('bright');
},
onProphecyUnhover: function (e) {
- var el = $(e.currentTarget);
+ let el = $(e.currentTarget);
events.emit('onHideTooltip', el[0]);
},
onProphecyClick: function (e) {
- var el = $(e.currentTarget);
- var pName = el.attr('prophecy');
+ let el = $(e.currentTarget);
+ let pName = el.attr('prophecy');
if (el.hasClass('active')) {
this.prophecies.spliceWhere(function (p) {
@@ -143,32 +143,32 @@ define([
},
onClassHover: function (e) {
- var el = $(e.currentTarget);
+ let el = $(e.currentTarget);
- var pos = {
+ let pos = {
x: e.clientX + 25,
y: e.clientY
};
- var text = ({
- owl: `The wise Owl guides you; granting you the focus needed to cast spells.
Upon level up, you gain 1 Intellect.`,
- bear: `The towering Bear strenghtens you; lending force to your blows.
Upon level up, you gain 1 Strength.`,
- lynx: `The nimble Lynx hastens you; allowing your strikes to land true.
Upon level up, you gain 1 Dexterity.`
+ let text = ({
+ owl: 'The wise Owl guides you; granting you the focus needed to cast spells.
Upon level up, you gain 1 Intellect.',
+ bear: 'The towering Bear strenghtens you; lending force to your blows.
Upon level up, you gain 1 Strength.',
+ lynx: 'The nimble Lynx hastens you; allowing your strikes to land true.
Upon level up, you gain 1 Dexterity.'
})[this.class];
events.emit('onShowTooltip', text, el[0], pos, 200);
$('.uiTooltips .tooltip').addClass('bright');
},
onClassUnhover: function (e) {
- var el = $(e.currentTarget);
+ let el = $(e.currentTarget);
events.emit('onHideTooltip', el[0]);
},
changeClass: function (e) {
- var el = $(e.target);
- var classes = ['owl', 'bear', 'lynx'];
- var nextIndex = (classes.indexOf(this.class) + 1) % classes.length;
+ let el = $(e.target);
+ let classes = ['owl', 'bear', 'lynx'];
+ let nextIndex = (classes.indexOf(this.class) + 1) % classes.length;
- var newClass = classes[nextIndex];
+ let newClass = classes[nextIndex];
el.html(newClass[0].toUpperCase() + newClass.substr(1));
@@ -178,9 +178,9 @@ define([
},
changeCostume: function (e) {
- var el = $(e.target);
+ let el = $(e.target);
- var spriteList = this.classSprites;
+ let spriteList = this.classSprites;
if (!spriteList)
return;
@@ -193,12 +193,12 @@ define([
},
setSprite: function () {
- var classSprite = this.classSprites[this.costume];
- var costume = classSprite.sprite.split(',');
- var spirteX = -costume[0] * 8;
- var spriteY = -costume[1] * 8;
+ let classSprite = this.classSprites[this.costume];
+ let costume = classSprite.sprite.split(',');
+ let spirteX = -costume[0] * 8;
+ let spriteY = -costume[1] * 8;
- var spritesheet = classSprite.spritesheet || '../../../images/characters.png';
+ let spritesheet = classSprite.spritesheet || '../../../images/characters.png';
this.find('.sprite')
.css('background', 'url("' + spritesheet + '") ' + spirteX + 'px ' + spriteY + 'px');
diff --git a/src/client/ui/templates/death/death.js b/src/client/ui/templates/death/death.js
index 76b5f729..738a8dcf 100644
--- a/src/client/ui/templates/death/death.js
+++ b/src/client/ui/templates/death/death.js
@@ -47,9 +47,9 @@ define([
},
onDeath: function (event) {
- if (!event.source) {
+ if (!event.source)
this.find('.msg').html('you are dead');
- } else
+ else
this.find('.msg').html('you were killed by [