Browse Source

eslint autofix on clients folder

tags/v0.2.1^2
big bad waffle 5 years ago
parent
commit
77aa9a9587
98 changed files with 3965 additions and 4037 deletions
  1. +1
    -0
      src/.eslintignore
  2. +23
    -23
      src/client/js/app.js
  3. +2
    -2
      src/client/js/components/aggro.js
  4. +8
    -10
      src/client/js/components/animation.js
  5. +4
    -5
      src/client/js/components/attackAnimation.js
  6. +5
    -5
      src/client/js/components/bumpAnimation.js
  7. +9
    -9
      src/client/js/components/chatter.js
  8. +14
    -14
      src/client/js/components/chest.js
  9. +2
    -2
      src/client/js/components/components.js
  10. +5
    -5
      src/client/js/components/dialogue.js
  11. +9
    -9
      src/client/js/components/events.js
  12. +4
    -4
      src/client/js/components/explosion.js
  13. +4
    -4
      src/client/js/components/flash.js
  14. +2
    -2
      src/client/js/components/gatherer.js
  15. +4
    -4
      src/client/js/components/keyboardMover.js
  16. +17
    -17
      src/client/js/components/light.js
  17. +28
    -28
      src/client/js/components/lightPatch.js
  18. +21
    -21
      src/client/js/components/lightningEffect.js
  19. +5
    -5
      src/client/js/components/mouseMover.js
  20. +13
    -13
      src/client/js/components/moveAnimation.js
  21. +6
    -6
      src/client/js/components/particles.js
  22. +1
    -1
      src/client/js/components/passives.js
  23. +17
    -17
      src/client/js/components/pather.js
  24. +8
    -8
      src/client/js/components/player.js
  25. +15
    -16
      src/client/js/components/projectile.js
  26. +2
    -2
      src/client/js/components/prophecies.js
  27. +10
    -10
      src/client/js/components/quests.js
  28. +2
    -3
      src/client/js/components/reputation.js
  29. +12
    -13
      src/client/js/components/resourceNode.js
  30. +10
    -10
      src/client/js/components/serverActions.js
  31. +2
    -2
      src/client/js/components/social.js
  32. +12
    -12
      src/client/js/components/spellbook.js
  33. +11
    -12
      src/client/js/components/stash.js
  34. +12
    -13
      src/client/js/components/stats.js
  35. +8
    -10
      src/client/js/components/trade.js
  36. +30
    -34
      src/client/js/input.js
  37. +2
    -2
      src/client/js/main.js
  38. +29
    -30
      src/client/js/misc/helpers.js
  39. +85
    -107
      src/client/js/misc/pathfinder.js
  40. +96
    -99
      src/client/js/misc/physics.js
  41. +50
    -50
      src/client/js/misc/statTranslations.js
  42. +24
    -25
      src/client/js/objects/objBase.js
  43. +55
    -56
      src/client/js/objects/objects.js
  44. +13
    -13
      src/client/js/rendering/effects.js
  45. +37
    -37
      src/client/js/rendering/lightningBuilder.js
  46. +16
    -16
      src/client/js/rendering/numbers.js
  47. +2
    -2
      src/client/js/rendering/particleDefaults.js
  48. +17
    -17
      src/client/js/rendering/particles.js
  49. +798
    -800
      src/client/js/rendering/renderer.js
  50. +11
    -12
      src/client/js/rendering/shaders/outline.js
  51. +3
    -3
      src/client/js/rendering/shaders/outline/frag.js
  52. +2
    -2
      src/client/js/rendering/shaders/outline/vert.js
  53. +11
    -13
      src/client/js/rendering/spritePool.js
  54. +65
    -66
      src/client/js/rendering/tileOpacity.js
  55. +4
    -4
      src/client/js/resources.js
  56. +5
    -5
      src/client/js/sound/sound.js
  57. +25
    -27
      src/client/js/spriteBuilder.js
  58. +4
    -4
      src/client/js/system/addons.js
  59. +6
    -7
      src/client/js/system/client.js
  60. +12
    -12
      src/client/js/system/events.js
  61. +2
    -2
      src/client/js/system/globals.js
  62. +7
    -7
      src/client/ui/factory.js
  63. +12
    -12
      src/client/ui/templates/announcements/announcements.js
  64. +8
    -8
      src/client/ui/templates/buffs/buffs.js
  65. +15
    -16
      src/client/ui/templates/characters/characters.js
  66. +12
    -12
      src/client/ui/templates/context/context.js
  67. +24
    -24
      src/client/ui/templates/createCharacter/createCharacter.js
  68. +2
    -2
      src/client/ui/templates/death/death.js
  69. +14
    -14
      src/client/ui/templates/dialogue/dialogue.js
  70. +18
    -18
      src/client/ui/templates/events/events.js
  71. +4
    -4
      src/client/ui/templates/fame/fame.js
  72. +6
    -7
      src/client/ui/templates/help/help.js
  73. +17
    -17
      src/client/ui/templates/leaderboard/leaderboard.js
  74. +1
    -1
      src/client/ui/templates/login/login.js
  75. +8
    -8
      src/client/ui/templates/mail/mail.js
  76. +2
    -2
      src/client/ui/templates/menu/menu.js
  77. +21
    -23
      src/client/ui/templates/messages/messages.js
  78. +7
    -9
      src/client/ui/templates/online/online.js
  79. +3
    -3
      src/client/ui/templates/options/options.js
  80. +5
    -5
      src/client/ui/templates/overlay/overlay.js
  81. +24
    -25
      src/client/ui/templates/party/party.js
  82. +30
    -34
      src/client/ui/templates/passives/input.js
  83. +27
    -28
      src/client/ui/templates/passives/passives.js
  84. +1784
    -1784
      src/client/ui/templates/passives/temp.js
  85. +11
    -11
      src/client/ui/templates/progressBar/progressBar.js
  86. +7
    -7
      src/client/ui/templates/quests/quests.js
  87. +13
    -14
      src/client/ui/templates/reputation/reputation.js
  88. +18
    -18
      src/client/ui/templates/smithing/smithing.js
  89. +28
    -28
      src/client/ui/templates/spells/spells.js
  90. +23
    -27
      src/client/ui/templates/stash/stash.js
  91. +11
    -12
      src/client/ui/templates/talk/talk.js
  92. +10
    -10
      src/client/ui/templates/target/target.js
  93. +5
    -5
      src/client/ui/templates/tooltipInfo/tooltipInfo.js
  94. +36
    -40
      src/client/ui/templates/tooltipItem/tooltipItem.js
  95. +19
    -19
      src/client/ui/templates/trade/trade.js
  96. +9
    -9
      src/client/ui/templates/wardrobe/wardrobe.js
  97. +2
    -2
      src/client/ui/templates/workbench/workbench.js
  98. +10
    -10
      src/client/ui/uiBase.js

+ 1
- 0
src/.eslintignore View File

@@ -1,2 +1,3 @@
/client/plugins/*
node_modules/*
*.json

+ 23
- 23
src/client/js/app.js View File

@@ -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'


+ 2
- 2
src/client/js/components/aggro.js View File

@@ -1,9 +1,9 @@
define([
], function(
], function (
) {
return {
type: 'aggro'
};
});
});

+ 8
- 10
src/client/js/components/animation.js View File

@@ -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;
}
};
});
});

+ 4
- 5
src/client/js/components/attackAnimation.js View File

@@ -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,


+ 5
- 5
src/client/js/components/bumpAnimation.js View File

@@ -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);



+ 9
- 9
src/client/js/components/chatter.js View File

@@ -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;



+ 14
- 14
src/client/js/components/chest.js View File

@@ -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;
}
};
});
});

+ 2
- 2
src/client/js/components/components.js View File

@@ -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;


+ 5
- 5
src/client/js/components/dialogue.js View File

@@ -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);
}
};
});
});

+ 9
- 9
src/client/js/components/events.js View File

@@ -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);
}
}
};
});
});

+ 4
- 4
src/client/js/components/explosion.js View File

@@ -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;
}
};
});
});

+ 4
- 4
src/client/js/components/flash.js View File

@@ -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);


+ 2
- 2
src/client/js/components/gatherer.js View File

@@ -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);


+ 4
- 4
src/client/js/components/keyboardMover.js View File

@@ -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;
}



+ 17
- 17
src/client/js/components/light.js View File

@@ -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);
}
}
};
});
});

+ 28
- 28
src/client/js/components/lightPatch.js View File

@@ -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 = [];
}
};
});
});

+ 21
- 21
src/client/js/components/lightningEffect.js View File

@@ -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;
}
};
});
});

+ 5
- 5
src/client/js/components/mouseMover.js View File

@@ -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
}
};
})
});



+ 13
- 13
src/client/js/components/moveAnimation.js View File

@@ -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();
}
};
});
});

+ 6
- 6
src/client/js/components/particles.js View File

@@ -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);
}
};
});
});

+ 1
- 1
src/client/js/components/passives.js View File

@@ -15,7 +15,7 @@ define([
},

extend: function (blueprint) {
var rerender = false;
let rerender = false;

if (blueprint.tickNodes) {
blueprint.tickNodes.forEach(function (n) {


+ 17
- 17
src/client/js/components/pather.js View File

@@ -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);


+ 8
- 8
src/client/js/components/player.js View File

@@ -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);
},
}
};
});

+ 15
- 16
src/client/js/components/projectile.js View File

@@ -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);
}
};
});
});

+ 2
- 2
src/client/js/components/prophecies.js View File

@@ -1,9 +1,9 @@
define([
], function(
], function (
) {
return {
type: 'prophecies'
};
});
});

+ 10
- 10
src/client/js/components/quests.js View File

@@ -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);
}
}
};
});
});

+ 2
- 3
src/client/js/components/reputation.js View File

@@ -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);



+ 12
- 13
src/client/js/components/resourceNode.js View File

@@ -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([
}
}
};
});
});

+ 10
- 10
src/client/js/components/serverActions.js View File

@@ -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([
}
}
};
});
});

+ 2
- 2
src/client/js/components/social.js View File

@@ -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);
}


+ 12
- 12
src/client/js/components/spellbook.js View File

@@ -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))


+ 11
- 12
src/client/js/components/stash.js View File

@@ -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);
}
}
};
});
});

+ 12
- 13
src/client/js/components/stats.js View File

@@ -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);



+ 8
- 10
src/client/js/components/trade.js View File

@@ -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');
}
};
});
});

+ 30
- 34
src/client/js/input.js View File

@@ -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;



+ 2
- 2
src/client/js/main.js View File

@@ -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);
});



+ 29
- 30
src/client/js/misc/helpers.js View File

@@ -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._;
});
});

+ 85
- 107
src/client/js/misc/pathfinder.js View File

@@ -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
};

});

+ 96
- 99
src/client/js/misc/physics.js View File

@@ -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);
}



+ 50
- 50
src/client/js/misc/statTranslations.js View File

@@ -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 {


+ 24
- 25
src/client/js/objects/objBase.js View File

@@ -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();
}


+ 55
- 56
src/client/js/objects/objects.js View File

@@ -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;



+ 13
- 13
src/client/js/rendering/effects.js View File

@@ -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([
}
}
};
});
});

+ 37
- 37
src/client/js/rendering/lightningBuilder.js View File

@@ -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);
});
});
}
};
});
});

+ 16
- 16
src/client/js/rendering/numbers.js View File

@@ -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;


+ 2
- 2
src/client/js/rendering/particleDefaults.js View File

@@ -1,6 +1,6 @@
define([
], function(
], function (
) {
return {
@@ -50,4 +50,4 @@ define([

allowRotation: false
};
});
});

+ 17
- 17
src/client/js/rendering/particles.js View File

@@ -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;
}
};
});
});

+ 798
- 800
src/client/js/rendering/renderer.js
File diff suppressed because it is too large
View File


+ 11
- 12
src/client/js/rendering/shaders/outline.js View File

@@ -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;
});
});

+ 3
- 3
src/client/js/rendering/shaders/outline/frag.js View File

@@ -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);
}
`;
});
});

+ 2
- 2
src/client/js/rendering/shaders/outline/vert.js View File

@@ -1,6 +1,6 @@
define([
], function(
], function (
) {
return `
@@ -15,4 +15,4 @@ define([
vTextureCoord = aTextureCoord;
}
`;
});
});

+ 11
- 13
src/client/js/rendering/spritePool.js View File

@@ -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);
}
};
});
});

+ 65
- 66
src/client/js/rendering/tileOpacity.js View File

@@ -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);
}
};


+ 4
- 4
src/client/js/resources.js View File

@@ -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++;
}


+ 5
- 5
src/client/js/sound/sound.js View File

@@ -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,


+ 25
- 27
src/client/js/spriteBuilder.js View File

@@ -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([
}
}
};
});
});

+ 4
- 4
src/client/js/system/addons.js View File

@@ -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);
}
};
};

+ 6
- 7
src/client/js/system/client.js View File

@@ -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) {


+ 12
- 12
src/client/js/system/events.js View File

@@ -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);
}
}


+ 2
- 2
src/client/js/system/globals.js View File

@@ -1,9 +1,9 @@
define([
], function(
], function (
) {
return {
};
});
});

+ 7
- 7
src/client/ui/factory.js View File

@@ -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();
}


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

@@ -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();
}
}
});
};
});

+ 8
- 8
src/client/ui/templates/buffs/buffs.js View File

@@ -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];
}
}
};
});

+ 15
- 16
src/client/ui/templates/characters/characters.js View File

@@ -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 += '<font class="color-yellowB"> (' + c.level + ')</font>'
name += '<font class="color-yellowB"> (' + c.level + ')</font>';

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;
}


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

@@ -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();
}
}
});
};
});

+ 24
- 24
src/client/ui/templates/createCharacter/createCharacter.js View File

@@ -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. <br /><br />Upon level up, you gain 1 Intellect.`,
bear: `The towering Bear strenghtens you; lending force to your blows. <br /><br />Upon level up, you gain 1 Strength.`,
lynx: `The nimble Lynx hastens you; allowing your strikes to land true. <br /><br />Upon level up, you gain 1 Dexterity.`
let text = ({
owl: 'The wise Owl guides you; granting you the focus needed to cast spells. <br /><br />Upon level up, you gain 1 Intellect.',
bear: 'The towering Bear strenghtens you; lending force to your blows. <br /><br />Upon level up, you gain 1 Strength.',
lynx: 'The nimble Lynx hastens you; allowing your strikes to land true. <br /><br />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');


+ 2
- 2
src/client/ui/templates/death/death.js View File

@@ -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 [ <div class="inner">' + event.source + '</div> ]');
this.find('.penalty')
.html('you lost ' + event.xpLoss + ' experience')


+ 14
- 14
src/client/ui/templates/dialogue/dialogue.js View File

@@ -3,7 +3,7 @@ define([
'js/system/client',
'html!ui/templates/dialogue/template',
'css!ui/templates/dialogue/styles'
], function(
], function (
events,
client,
template,
@@ -15,13 +15,13 @@ define([

centeredX: true,

postRender: function() {
postRender: function () {
this.onEvent('onGetDialogue', this.onGetDialogue.bind(this));
this.onEvent('onRemoveDialogue', this.onRemoveDialogue.bind(this));
},

onGetDialogue: function(msg) {
this.text.spliceWhere(function(t) {
onGetDialogue: function (msg) {
this.text.spliceWhere(function (t) {
return (t.src == msg.src);
});

@@ -29,18 +29,18 @@ define([
this.setText();
},

onRemoveDialogue: function(msg) {
this.text.spliceWhere(function(t) {
onRemoveDialogue: function (msg) {
this.text.spliceWhere(function (t) {
return (t.src == msg.src);
});

this.setText();
},

setText: function() {
var text = '';
for (var i = 0; i < this.text.length; i++) {
var t = this.text[i];
setText: function () {
let text = '';
for (let i = 0; i < this.text.length; i++) {
let t = this.text[i];

text += t.msg;
if (i < this.text.length - 1)
@@ -49,11 +49,11 @@ define([
this.find('.textBox').html(text);

if (text != '') {
if (text != '')
this.show();
}
else
this.hide();
}
}
});
};
});

+ 18
- 18
src/client/ui/templates/events/events.js View File

@@ -4,7 +4,7 @@ define([
'html!ui/templates/events/template',
'html!ui/templates/events/templateEvent',
'css!ui/templates/events/styles'
], function(
], function (
client,
events,
tpl,
@@ -18,7 +18,7 @@ define([

container: '.right',

postRender: function() {
postRender: function () {
this.onEvent('onRezone', this.onRezone.bind(this));

this.onEvent('onObtainEvent', this.onObtainEvent.bind(this));
@@ -27,13 +27,13 @@ define([
this.onEvent('onCompleteEvent', this.onCompleteEvent.bind(this));
},

onRezone: function() {
onRezone: function () {
this.list = [];
this.el.find('.list').empty();
},

onRemoveEvent: function(id) {
var l = this.list.spliceFirstWhere(function(l) {
onRemoveEvent: function (id) {
let l = this.list.spliceFirstWhere(function (l) {
return (l.id == id);
});

@@ -41,8 +41,8 @@ define([
l.el.remove();
},

onObtainEvent: function(event) {
var exists = this.list.find(function(l) {
onObtainEvent: function (event) {
let exists = this.list.find(function (l) {
return (l.id == event.id);
});
if (exists) {
@@ -51,13 +51,13 @@ define([
return;
}

var container = this.el.find('.list');
let container = this.el.find('.list');

var html = templateEvent
let html = templateEvent
.replace('$NAME$', event.name)
.replace('$DESCRIPTION$', event.description);

var el = $(html).appendTo(container);
let el = $(html).appendTo(container);

if (event.isReady)
el.addClass('ready');
@@ -71,7 +71,7 @@ define([
var event = container.find('.event');

event
.sort(function(a, b) {
.sort(function (a, b) {
a = $(a).hasClass('active') ? 1 : 0;
b = $(b).hasClass('active') ? 1 : 0;
return b - a;
@@ -79,8 +79,8 @@ define([
.appendTo(container);
},

onUpdateEvent: function(event) {
var e = this.list.find(function(l) {
onUpdateEvent: function (event) {
let e = this.list.find(function (l) {
return (l.id == event.id);
});

@@ -95,8 +95,8 @@ define([
}
},

onCompleteEvent: function(id) {
var e = this.list.find(function(l) {
onCompleteEvent: function (id) {
let e = this.list.find(function (l) {
return (l.id == id);
});

@@ -104,9 +104,9 @@ define([
return;

e.el.remove();
this.list.spliceWhere(function(l) {
this.list.spliceWhere(function (l) {
return (l.id == id);
});
}
}
});
};
});

+ 4
- 4
src/client/ui/templates/fame/fame.js View File

@@ -3,7 +3,7 @@ define([
'js/system/client',
'html!ui/templates/fame/template',
'css!ui/templates/fame/styles'
], function(
], function (
events,
client,
template,
@@ -16,8 +16,8 @@ define([
centeredX: true,
modal: true,

postRender: function() {
postRender: function () {
}
}
});
};
});

+ 6
- 7
src/client/ui/templates/help/help.js View File

@@ -2,7 +2,7 @@ define([
'js/system/events',
'html!ui/templates/help/template',
'css!ui/templates/help/styles'
], function(
], function (
events,
template,
styles
@@ -13,18 +13,17 @@ define([

modal: true,

postRender: function() {
postRender: function () {
this.onEvent('onKeyDown', this.onKeyDown.bind(this));
this.onEvent('onShowHelp', this.toggle.bind(this));
},

onKeyDown: function(key) {
if (key == 'h') {
onKeyDown: function (key) {
if (key == 'h')
this.toggle();
}
},

toggle: function() {
toggle: function () {
this.shown = !this.el.is(':visible');

if (this.shown)
@@ -33,4 +32,4 @@ define([
this.hide();
}
};
});
});

+ 17
- 17
src/client/ui/templates/leaderboard/leaderboard.js View File

@@ -39,8 +39,8 @@ define([
},

onPage: function (e) {
var el = $(e.currentTarget);
var offset = ~~el.attr('offset');
let el = $(e.currentTarget);
let offset = ~~el.attr('offset');

this.offset += offset;
if (this.offset < 0)
@@ -52,7 +52,7 @@ define([
},

onMine: function () {
var prophecies = window.player.prophecies;
let prophecies = window.player.prophecies;
prophecies = prophecies ? prophecies.list : [];

this.prophecyFilter = [];
@@ -75,13 +75,13 @@ define([
},

onProphecyClick: function (e) {
var el = $(e.currentTarget);
let el = $(e.currentTarget);

el.toggleClass('selected');

var prophecyName = el.attr('prophecy');
let prophecyName = el.attr('prophecy');

var exists = this.prophecyFilter.some(function (p) {
let exists = this.prophecyFilter.some(function (p) {
return (p == prophecyName);
}, this);

@@ -97,7 +97,7 @@ define([
this.el.addClass('disabled');

if (!this.prophecyFilter) {
var prophecies = window.player.prophecies;
let prophecies = window.player.prophecies;
this.prophecyFilter = prophecies ? prophecies.list : [];
this.prophecyFilter = $.extend(true, [], this.prophecyFilter);
}
@@ -119,30 +119,30 @@ define([
if (!keepOffset) {
this.offset = 0;

var foundIndex = this.records.list.firstIndex(function (r) {
let foundIndex = this.records.list.firstIndex(function (r) {
return (r.name == window.player.name);
}, this);
if (foundIndex != -1)
this.offset = ~~(foundIndex / this.pageSize);
}

var container = this.find('.list').empty();
let container = this.find('.list').empty();

var low = this.offset * this.pageSize;
var high = Math.min(result.length, low + this.pageSize);
let low = this.offset * this.pageSize;
let high = Math.min(result.length, low + this.pageSize);
this.maxOffset = Math.ceil(result.length / this.pageSize) - 1;

for (var i = 0; i < this.records.list.length; i++) {
for (let i = 0; i < this.records.list.length; i++) {
var r = this.records.list[i];

var html = '<div class="row"><div class="col">' + r.level + '</div><div class="col">' + r.name + '</div></div>';
var el = $(html)
let html = '<div class="row"><div class="col">' + r.level + '</div><div class="col">' + r.name + '</div></div>';
let el = $(html)
.appendTo(container);

if (r.name == window.player.name)
el.addClass('self');
else {
var online = globals.onlineList.some(function (o) {
let online = globals.onlineList.some(function (o) {
return (o.name == r.name);
});
if (online)
@@ -169,11 +169,11 @@ define([
},

toggle: function () {
var shown = !this.el.is(':visible');
let shown = !this.el.is(':visible');

if (shown) {
this.find('.prophecy[prophecy]').removeClass('selected');
var prophecies = window.player.prophecies;
let prophecies = window.player.prophecies;
prophecies = prophecies ? prophecies.list : [];
prophecies.forEach(function (p) {
this.find('.prophecy[prophecy="' + p + '"]').addClass('selected');


+ 1
- 1
src/client/ui/templates/login/login.js View File

@@ -38,7 +38,7 @@ define([
},

redirect: function (e) {
var location = $(e.target).attr('location');
let location = $(e.target).attr('location');
window.open(location, '_blank');
},



+ 8
- 8
src/client/ui/templates/mail/mail.js View File

@@ -28,7 +28,7 @@ define([
if (!this.item)
return;

var recipient = this.find('.txtRecipient').val();
let recipient = this.find('.txtRecipient').val();
if (recipient.length == 0)
return;

@@ -63,12 +63,12 @@ define([
this.toggle();
this.item = msg.item;

var item = msg.item;
let item = msg.item;

var imgX = -item.sprite[0] * 64;
var imgY = -item.sprite[1] * 64;
let imgX = -item.sprite[0] * 64;
let imgY = -item.sprite[1] * 64;

var spritesheet = item.spritesheet || '../../../images/items.png';
let spritesheet = item.spritesheet || '../../../images/items.png';
if (item.material)
spritesheet = '../../../images/materials.png';
else if (item.quest)
@@ -76,7 +76,7 @@ define([
else if (item.type == 'consumable')
spritesheet = '../../../images/consumables.png';

var el = this.find('.item');
let el = this.find('.item');

el
.data('item', item)
@@ -84,7 +84,7 @@ define([
.css('background', 'url(' + spritesheet + ') ' + imgX + 'px ' + imgY + 'px');

if (item.quantity) {
var quantityText = item.quantity;
let quantityText = item.quantity;
el.find('.quantity').html(item.quantity);
} else
el.find('.quantity').html('');
@@ -101,5 +101,5 @@ define([
} else
this.hide();
}
}
};
});

+ 2
- 2
src/client/ui/templates/menu/menu.js View File

@@ -24,7 +24,7 @@ define([
},

onGetPassivePoints: function (points) {
var el = this.find('.btnPassives .points');
let el = this.find('.btnPassives .points');
el
.html('')
.hide();
@@ -35,5 +35,5 @@ define([
.show();
}
}
}
};
});

+ 21
- 23
src/client/ui/templates/messages/messages.js View File

@@ -50,8 +50,8 @@ define([
},

checkChatLength: function () {
var textbox = this.find('input');
var val = textbox.val();
let textbox = this.find('input');
let val = textbox.val();

if (val.length <= this.maxChatLength)
return;
@@ -69,8 +69,8 @@ define([
onJoinChannel: function (channel) {
this.find('[filter="' + channel.trim() + '"]').remove();

var container = this.find('.filters');
var newFilter = $(tplTab)
let container = this.find('.filters');
let newFilter = $(tplTab)
.appendTo(container)
.addClass('channel')
.attr('filter', channel.trim())
@@ -89,20 +89,19 @@ define([
},

onClickFilter: function (e) {
var el = $(e.currentTarget);
let el = $(e.currentTarget);
el.toggleClass('active');

var filter = el.attr('filter');
var method = (el.hasClass('active') ? 'show' : 'hide');
let filter = el.attr('filter');
let method = (el.hasClass('active') ? 'show' : 'hide');

if (method == 'show')
this.find('.list').addClass(filter);
else
this.find('.list').removeClass(filter);

if (el.hasClass('channel')) {
if (el.hasClass('channel'))
this.find('.list .' + filter)[method]();
}
},

onKeyDown: function (key, state) {
@@ -112,7 +111,7 @@ define([

onDoWhisper: function (charName) {
this.toggle(true);
var toName = charName;
let toName = charName;
if (charName.indexOf(' ') > -1)
toName = "'" + toName + "'";

@@ -120,20 +119,20 @@ define([
},

onGetMessages: function (e) {
var messages = e.messages;
let messages = e.messages;
if (!messages.length)
messages = [messages];

var container = this.find('.list');
let container = this.find('.list');

messages.forEach(function (m) {
var message = m.message;
let message = m.message;
if (m.item) {
var source = message.split(':')[0] + ': ';
let source = message.split(':')[0] + ': ';
message = source + '<span class="q' + (m.item.quality || 0) + '">' + message.replace(source, '') + '</span>';
}

var el = $('<div class="list-message ' + m.class + '">' + message + '</div>')
let el = $('<div class="list-message ' + m.class + '">' + message + '</div>')
.appendTo(container);

if (m.type != null)
@@ -148,7 +147,7 @@ define([
}

if (m.type) {
var isChannel = (['info', 'chat', 'loot', 'rep'].indexOf(m.type) == -1);
let isChannel = (['info', 'chat', 'loot', 'rep'].indexOf(m.type) == -1);
if (isChannel) {
if (this.find('.filter[filter="' + m.type + '"]').hasClass('active'))
el.show();
@@ -182,7 +181,7 @@ define([
if (!item)
return;

var ttPos = null;
let ttPos = null;
if (el) {
ttPos = {
x: ~~(e.clientX + 32),
@@ -201,15 +200,14 @@ define([

this.el.removeClass('typing');

var textbox = this.find('input');
let textbox = this.find('input');

if (show) {
this.el.addClass('typing');
textbox.focus();
this.find('.list').scrollTop(9999999);
} else {
} else
textbox.val('');
}
},

sendChat: function (e) {
@@ -224,8 +222,8 @@ define([
return;
}

var textbox = this.find('input');
var val = textbox.val()
let textbox = this.find('input');
let val = textbox.val()
.split('<')
.join('&lt;')
.split('>')
@@ -244,5 +242,5 @@ define([
}
});
}
}
};
});

+ 7
- 9
src/client/ui/templates/online/online.js View File

@@ -50,10 +50,10 @@ define([
if (!list.length)
list = [list];

var onlineList = this.onlineList;
let onlineList = this.onlineList;

list.forEach(function (l) {
var exists = onlineList.find(function (o) {
let exists = onlineList.find(function (o) {
return (o.name == l.name);
});
if (exists)
@@ -67,10 +67,8 @@ define([
if (a.level == b.level) {
if (a.name > b.name)
return 1;
else
return -1;
} else
return b.level - a.level;
return -1;
} return b.level - a.level;
});

if (this.shown)
@@ -78,7 +76,7 @@ define([
},

onGetDisconnectedPlayer: function (name) {
var onlineList = this.onlineList;
let onlineList = this.onlineList;

onlineList.spliceWhere(function (o) {
return (o.name == name);
@@ -89,13 +87,13 @@ define([
},

build: function () {
var container = this.el.find('.list');
let container = this.el.find('.list');
container
.children(':not(.heading)')
.remove();

this.onlineList.forEach(function (l) {
var html = templateListItem
let html = templateListItem
.replace('$NAME$', l.name)
.replace('$LEVEL$', l.level)
.replace('$CLASS$', l.class);


+ 3
- 3
src/client/ui/templates/options/options.js View File

@@ -57,7 +57,7 @@ define([

events.emit('onShowCharacterSelect');
$('[class^="ui"]:not(.ui-container)').each(function (i, el) {
var ui = $(el).data('ui');
let ui = $(el).data('ui');
if ((ui) && (ui.destroy))
ui.destroy();
});
@@ -69,7 +69,7 @@ define([
},

onResize: function () {
var isFullscreen = (window.innerHeight == screen.height);
let isFullscreen = (window.innerHeight == screen.height);
if (isFullscreen)
this.el.find('.btnScreen').html('Windowed');
else
@@ -98,5 +98,5 @@ define([
if (key == 'esc')
this.toggle();
}
}
};
});

+ 5
- 5
src/client/ui/templates/overlay/overlay.js View File

@@ -2,7 +2,7 @@ define([
'js/system/events',
'html!ui/templates/overlay/template',
'css!ui/templates/overlay/styles'
], function(
], function (
events,
template,
styles
@@ -13,19 +13,19 @@ define([
focusEl: null,
lastZIndex: 0,

postRender: function() {
postRender: function () {
events.on('onShowOverlay', this.onShowOverlay.bind(this));
events.on('onHideOverlay', this.onHideOverlay.bind(this));
},

onShowOverlay: function(focusEl) {
onShowOverlay: function (focusEl) {
this.focusEl = focusEl;
this.lastZIndex = focusEl.css('z-index');
focusEl.css('z-index', ~~this.el.css('z-index') + 1);
this.show();
},

onHideOverlay: function(focusEl) {
onHideOverlay: function (focusEl) {
if (!this.focusEl)
return;
@@ -36,4 +36,4 @@ define([
this.hide();
}
};
});
});

+ 24
- 25
src/client/ui/templates/party/party.js View File

@@ -34,7 +34,7 @@ define([
},

onGetConnectedPlayer: function (msg) {
var party = this.party;
let party = this.party;
if (!party)
return;

@@ -45,21 +45,21 @@ define([
if (party.indexOf(m.id) == -1)
return;

var zone = m.zone;
let zone = m.zone;
if (m.id == window.player.serverId) {
party.forEach(function (p) {
var player = globals.onlineList.find(function (o) {
return (o.id == p)
let player = globals.onlineList.find(function (o) {
return (o.id == p);
});

var el = this.find('.member[memberId="' + p + '"]');
let el = this.find('.member[memberId="' + p + '"]');
el.removeClass('differentZone');

if (player.zone != zone)
el.addClass('differentZone');
}, this);
} else {
var el = this.find('.member[memberId="' + m.id + '"]');
let el = this.find('.member[memberId="' + m.id + '"]');
el.removeClass('differentZone');

if (m.zone != window.player.zone)
@@ -71,27 +71,26 @@ define([
},

onGetPartyStats: function (id, stats) {
var party = this.party;
let party = this.party;
if (!party)
return;

var el = this.find('.member[memberId="' + id + '"]');
let el = this.find('.member[memberId="' + id + '"]');
if (el.length == 0)
return;

if ((stats.hp != null) && (stats.hpMax != null)) {
var hpPercentage = Math.min(100, (stats.hp / stats.hpMax) * 100);
let hpPercentage = Math.min(100, (stats.hp / stats.hpMax) * 100);
el.find('.statHp').css('width', hpPercentage + '%');
}

if ((stats.mana != null) && (stats.manaMax != null)) {
var manaPercentage = Math.min((stats.mana / stats.manaMax) * 100, 100);
let manaPercentage = Math.min((stats.mana / stats.manaMax) * 100, 100);
el.find('.statMana').css('width', manaPercentage + '%');
}

if (stats.level != null) {
if (stats.level != null)
el.find('.txtLevel').html('level: ' + stats.level);
}
},

onPartyDisband: function () {
@@ -104,7 +103,7 @@ define([
if (this.invite)
this.destroyInvite();

var container = this.find('.party .list')
let container = this.find('.party .list')
.empty();

this.party = party;
@@ -115,17 +114,17 @@ define([
if (p == window.player.serverId)
return;

var player = globals.onlineList.find(function (o) {
return (o.id == p)
let player = globals.onlineList.find(function (o) {
return (o.id == p);
});
var name = player ? player.name : 'unknown';
var level = 'level: ' + (player ? player.level : '?');
let name = player ? player.name : 'unknown';
let level = 'level: ' + (player ? player.level : '?');

var html = templatePartyMember
let html = templatePartyMember
.replace('$NAME$', name)
.replace('$LEVEL$', level);

var el = $(html)
let el = $(html)
.appendTo(container)
.attr('memberId', p)
.on('contextmenu', this.showContext.bind(this, name, p));
@@ -134,7 +133,7 @@ define([
el.addClass('differentZone');

//Find stats
var memberObj = objects.objects.find(function (o) {
let memberObj = objects.objects.find(function (o) {
return (o.serverId == p);
});
if ((memberObj) && (memberObj.stats))
@@ -162,14 +161,14 @@ define([
if (this.invite)
this.destroyInvite();

var sourcePlayer = globals.onlineList.find(function (o) {
return (o.id == sourceId)
let sourcePlayer = globals.onlineList.find(function (o) {
return (o.id == sourceId);
});

var html = templateInvite
let html = templateInvite
.replace('$NAME$', sourcePlayer.name);

var el = $(html)
let el = $(html)
.appendTo(this.el);
el
.find('[class^="btn"]')
@@ -227,5 +226,5 @@ define([
method: 'leaveParty'
});
}
}
};
});

+ 30
- 34
src/client/ui/templates/passives/input.js View File

@@ -16,23 +16,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: {
@@ -54,9 +54,8 @@ define([
},

resetKeys: function () {
for (var k in this.keys) {
for (let k in this.keys)
events.emit('onKeyUp', k);
}

this.keys = {};
},
@@ -69,27 +68,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]]) {
@@ -119,7 +115,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;
@@ -140,7 +136,7 @@ define([
if (e.target != document.body)
return;

var key = this.getMapping(e.which);
let key = this.getMapping(e.which);

delete this.keys[key];

@@ -149,11 +145,11 @@ define([
},
mouse: {
mouseDown: function (e) {
var el = $(e.target);
let el = $(e.target);
if ((!el.hasClass('canvas')) || (el.hasClass('blocking')))
return;

var button = e.button;
let button = e.button;
this.mouse.button = button;
this.mouse.down = true;
this.mouse.event = e;
@@ -162,11 +158,11 @@ define([
events.emit('uiMouseDown', this.mouse);
},
mouseUp: function (e) {
var el = $(e.target);
let el = $(e.target);
if ((!el.hasClass('canvas')) || (el.hasClass('blocking')))
return;

var button = e.button;
let button = e.button;
this.mouse.button = null;
this.mouse.down = false;
this.mouse.raw = e;
@@ -182,7 +178,7 @@ define([
if (!e)
return;

var el = $(e.target);
let el = $(e.target);
if ((!el.hasClass('canvas')) || (el.hasClass('blocking')))
return;



+ 27
- 28
src/client/ui/templates/passives/passives.js View File

@@ -95,11 +95,11 @@ define([

this.renderers.clear.call(this);

var links = this.data.links;
var nodes = this.data.nodes;
let links = this.data.links;
let nodes = this.data.nodes;

links.forEach(function (l) {
var linked = (
let linked = (
nodes.find(function (n) {
return (n.id == l.from.id);
}).selected &&
@@ -120,7 +120,7 @@ define([

if (this.shown) {
//Calculate midpoint
var start = this.data.nodes.find(function (n) {
let start = this.data.nodes.find(function (n) {
return (n.spiritStart == window.player.class);
});

@@ -150,7 +150,7 @@ define([

renderers: {
clear: function () {
var pos = this.oldPos || this.pos;
let pos = this.oldPos || this.pos;

this.ctx.clearRect(0, 0, this.size.w, this.size.h);

@@ -158,7 +158,7 @@ define([
},

node: function (node) {
var color = (node.color >= 0) ? (node.color + 1) : -1;
let color = (node.color >= 0) ? (node.color + 1) : -1;
if (((!node.stats) || (Object.keys(node.stats).length == 0)) && (!node.spiritStart))
color = 0;

@@ -178,15 +178,15 @@ define([
'#44cb95',
'#fafcfc'
])[color];
var size = ([
let size = ([
constants.blockSize,
constants.blockSize * 2,
constants.blockSize * 3
])[node.size];
var x = (node.pos.x * constants.gridSize) - ((size - constants.blockSize) / 2) - this.pos.x;
var y = (node.pos.y * constants.gridSize) - ((size - constants.blockSize) / 2) - this.pos.y;
let x = (node.pos.x * constants.gridSize) - ((size - constants.blockSize) / 2) - this.pos.x;
let y = (node.pos.y * constants.gridSize) - ((size - constants.blockSize) / 2) - this.pos.y;

var linked = this.data.links.some(function (l) {
let linked = this.data.links.some(function (l) {
if ((l.from.id != node.id) && (l.to.id != node.id))
return false;

@@ -225,12 +225,11 @@ define([

if (!linked)
this.ctx.globalAlpha = 1;

},

line: function (fromNode, toNode, linked) {
var ctx = this.ctx;
var halfSize = constants.blockSize / 2;
let ctx = this.ctx;
let halfSize = constants.blockSize / 2;

fromNode = this.data.nodes.find(function (n) {
return (n.id == fromNode.id);
@@ -240,11 +239,11 @@ define([
return (n.id == toNode.id);
});

var fromX = (fromNode.pos.x * constants.gridSize) + halfSize - this.pos.x;
var fromY = (fromNode.pos.y * constants.gridSize) + halfSize - this.pos.y;
let fromX = (fromNode.pos.x * constants.gridSize) + halfSize - this.pos.x;
let fromY = (fromNode.pos.y * constants.gridSize) + halfSize - this.pos.y;

var toX = (toNode.pos.x * constants.gridSize) + halfSize - this.pos.x;
var toY = (toNode.pos.y * constants.gridSize) + halfSize - this.pos.y;
let toX = (toNode.pos.x * constants.gridSize) + halfSize - this.pos.x;
let toY = (toNode.pos.y * constants.gridSize) + halfSize - this.pos.y;

if ((!linked) && (!fromNode.selected) && (!toNode.selected))
this.ctx.globalAlpha = 0.25;
@@ -271,12 +270,12 @@ define([
y: pos.y
};

var cell = {
let cell = {
x: ~~((this.pos.x + this.mouse.x) / constants.gridSize),
y: ~~((this.pos.y + this.mouse.y) / constants.gridSize)
};

var node = this.hoverNode = this.data.nodes.find(function (n) {
let node = this.hoverNode = this.data.nodes.find(function (n) {
return (
(n.pos.x == cell.x) &&
(n.pos.y == cell.y)
@@ -284,7 +283,7 @@ define([
});

if (node) {
var percentageStats = [
let percentageStats = [
'addCritChance',
'addCritMultiplier',
'sprintChance',
@@ -301,11 +300,11 @@ define([
'fishItems'
];

var text = Object.keys(node.stats)
let text = Object.keys(node.stats)
.map(function (s) {
var statName = statTranslations.translate(s);
var statValue = node.stats[s];
var negative = ((statValue + '')[0] == '-');
let statName = statTranslations.translate(s);
let statValue = node.stats[s];
let negative = ((statValue + '')[0] == '-');
if (percentageStats.indexOf(s) > -1)
statValue += '%';

@@ -353,8 +352,8 @@ define([
};
}

var zoomPanMultiplier = this.currentZoom;
var scrollSpeed = constants.scrollSpeed / zoomPanMultiplier;
let zoomPanMultiplier = this.currentZoom;
let scrollSpeed = constants.scrollSpeed / zoomPanMultiplier;

this.pos.x += (this.panOrigin.x - e.raw.clientX) * scrollSpeed;
this.pos.y += (this.panOrigin.y - e.raw.clientY) * scrollSpeed;
@@ -399,7 +398,7 @@ define([
},

onGetPassivePoints: function (points) {
var el = this.find('.points')
let el = this.find('.points')
.html('Points Available: ' + points);
},

@@ -417,5 +416,5 @@ define([
});
}
}
}
};
});

+ 1784
- 1784
src/client/ui/templates/passives/temp.js
File diff suppressed because it is too large
View File


+ 11
- 11
src/client/ui/templates/progressBar/progressBar.js View File

@@ -4,7 +4,7 @@ define([
'html!ui/templates/progressBar/template',
'html!ui/templates/progressBar/templateBar',
'css!ui/templates/progressBar/styles'
], function(
], function (
events,
client,
tpl,
@@ -16,24 +16,24 @@ define([

bars: [],

postRender: function() {
postRender: function () {
this.onEvent('onShowProgress', this.onShowProgress.bind(this));
},

onShowProgress: function(text, percentage) {
var bar = this.bars.find(function(b) {
onShowProgress: function (text, percentage) {
let bar = this.bars.find(function (b) {
return (b.text == text);
});

if (bar) {
if (percentage >= 100) {
bar.el.remove();
this.bars.spliceWhere(function(b) { return (b == bar)});
}
else
this.bars.spliceWhere(function (b) {
return (b == bar);
});
} else
bar.el.find('.bar').css('width', percentage + '%');
}
else if (percentage < 100) {
} else if (percentage < 100) {
bar = $(tplBar).appendTo(this.el);
bar.find('.bar').css('width', percentage + '%');
bar.find('.text').html(text);
@@ -44,5 +44,5 @@ define([
});
}
}
}
});
};
});

+ 7
- 7
src/client/ui/templates/quests/quests.js View File

@@ -31,15 +31,15 @@ define([
},

onObtainQuest: function (quest) {
var list = this.el.find('.list');
let list = this.el.find('.list');

var html = templateQuest
let html = templateQuest
.replace('$ZONE$', quest.zoneName)
.replace('$NAME$', quest.name)
.replace('$DESCRIPTION$', quest.description)
.replace('$REWARD$', quest.xp + ' xp');

var el = $(html)
let el = $(html)
.appendTo(list);

if (quest.isReady)
@@ -58,7 +58,7 @@ define([
quest: quest
});

var quests = list.find('.quest');
let quests = list.find('.quest');

quests
.sort(function (a, b) {
@@ -85,7 +85,7 @@ define([
},

onUpdateQuest: function (quest) {
var q = this.quests.find(function (q) {
let q = this.quests.find(function (q) {
return (q.id == quest.id);
});

@@ -101,7 +101,7 @@ define([
},

onCompleteQuest: function (id) {
var q = this.quests.find(function (q) {
let q = this.quests.find(function (q) {
return (q.id == id);
});

@@ -113,5 +113,5 @@ define([
return (q.id == id);
});
}
}
};
});

+ 13
- 14
src/client/ui/templates/reputation/reputation.js View File

@@ -23,7 +23,7 @@ define([
},

build: function () {
var list = this.list;
let list = this.list;

this.find('.info .heading-bottom').html('');
this.find('.info .description').html('');
@@ -34,15 +34,15 @@ define([
else
this.find('.heading-bottom').html('select a faction to see more info');

var elList = this.find('.list').empty();
let elList = this.find('.list').empty();

list.forEach(function (l) {
if (l.noGainRep)
return;

var html = '<div class="faction">' + l.name.toLowerCase() + '</div>';
let html = '<div class="faction">' + l.name.toLowerCase() + '</div>';

var el = $(html)
let el = $(html)
.appendTo(elList);

el
@@ -57,20 +57,20 @@ define([
this.find('.info .heading-bottom').html(faction.name.toLowerCase());
this.find('.info .description').html(faction.description.toLowerCase());

var rep = faction.rep;
var tier = faction.tier;
var tiers = faction.tiers;
var prevTier = tiers[tier];
var nextTier = (tier == tiers.length - 1) ? tiers[tiers.length - 1] : tiers[tier + 1];
let rep = faction.rep;
let tier = faction.tier;
let tiers = faction.tiers;
let prevTier = tiers[tier];
let nextTier = (tier == tiers.length - 1) ? tiers[tiers.length - 1] : tiers[tier + 1];

var percentage = (rep - prevTier.rep) / (nextTier.rep - prevTier.rep) * 100;
let percentage = (rep - prevTier.rep) / (nextTier.rep - prevTier.rep) * 100;
this.find('.bar-outer').show();

this.find('.front').css({
width: percentage + '%'
});

var w = ~~(this.find('.front').width() / 5) * 5;
let w = ~~(this.find('.front').width() / 5) * 5;
this.find('.front').css({
width: w + 'px'
});
@@ -85,8 +85,7 @@ define([
this.list.sort(function (a, b) {
if (a.name[0] < b.name[0])
return -1;
else
return 1;
return 1;
});

if (this.el.is(':visible'))
@@ -94,7 +93,7 @@ define([
},

toggle: function () {
var shown = !this.el.is(':visible');
let shown = !this.el.is(':visible');

if (shown) {
this.build();


+ 18
- 18
src/client/ui/templates/smithing/smithing.js View File

@@ -43,11 +43,11 @@ define([
},

clickAction: function (e) {
var el = $(e.currentTarget);
let el = $(e.currentTarget);
this.find('.col-btn').removeClass('selected');

var action = el.attr('action');
var changed = (action != this.action);
let action = el.attr('action');
let changed = (action != this.action);
this.action = action;

el.addClass('selected');
@@ -77,7 +77,7 @@ define([
onSmith: function (item, result) {
this.setDisabled(false);

var msg = {
let msg = {
msg: 'Item Enhancement Succeeded',
type: 'success',
zIndex: 9999999,
@@ -101,7 +101,7 @@ define([

this.getMaterials(this.item);

var augment = this.find('[action="augment"]').addClass('disabled');
let augment = this.find('[action="augment"]').addClass('disabled');
if ((result.item.power || 0) < 3)
augment.removeClass('disabled');
else
@@ -155,19 +155,19 @@ define([
this.find('[action="augment"]').addClass('selected');
this.action = 'augment';

var augment = this.find('[action="augment"]').addClass('disabled');
let augment = this.find('[action="augment"]').addClass('disabled');
if ((msg.item.power || 0) < 3)
augment.removeClass('disabled');

var reforge = this.find('[action="reforge"]').addClass('disabled');
let reforge = this.find('[action="reforge"]').addClass('disabled');
if (msg.item.spell)
reforge.removeClass('disabled');

var reslot = this.find('[action="reslot"]').addClass('disabled');
let reslot = this.find('[action="reslot"]').addClass('disabled');
if (!msg.item.effects)
reslot.removeClass('disabled');

var relevel = this.find('[action="relevel"]').addClass('disabled');
let relevel = this.find('[action="relevel"]').addClass('disabled');
if (msg.item.slot == 'tool')
relevel.removeClass('disabled');

@@ -212,9 +212,9 @@ define([
this.find('.actionButton').removeClass('disabled').addClass('disabled');

if (result.materials) {
var material = result.materials[0];
let material = result.materials[0];
if (material) {
var hasMaterials = window.player.inventory.items.find(function (i) {
let hasMaterials = window.player.inventory.items.find(function (i) {
return (i.name == material.name);
});
if (hasMaterials) {
@@ -239,10 +239,10 @@ define([
drawItem: function (container, item, redQuantity) {
container.find('.icon').hide();

var imgX = -item.sprite[0] * 64;
var imgY = -item.sprite[1] * 64;
let imgX = -item.sprite[0] * 64;
let imgY = -item.sprite[1] * 64;

var spritesheet = item.spritesheet || '../../../images/items.png';
let spritesheet = item.spritesheet || '../../../images/items.png';
if (item.material)
spritesheet = '../../../images/materials.png';
else if (item.quest)
@@ -250,7 +250,7 @@ define([
else if (item.type == 'consumable')
spritesheet = '../../../images/consumables.png';

var el = $(templateItem)
let el = $(templateItem)
.appendTo(container);

el
@@ -261,7 +261,7 @@ define([
.css('background', 'url(' + spritesheet + ') ' + imgX + 'px ' + imgY + 'px');

if (item.quantity) {
var quantityText = item.quantityText;
let quantityText = item.quantityText;
el.find('.quantity').html(quantityText);
if (redQuantity)
el.find('.quantity').addClass('red');
@@ -274,10 +274,10 @@ define([
else
item = this.hoverItem;

var ttPos = null;
let ttPos = null;

if (el) {
var elOffset = el.offset();
let elOffset = el.offset();
ttPos = {
x: ~~(e.clientX + 32),
y: ~~(e.clientY)


+ 28
- 28
src/client/ui/templates/spells/spells.js View File

@@ -29,26 +29,26 @@ define([

this.spells = spells;

for (var i = 0; i < spells.length; i++) {
var icon = spells[i].icon;
var x = -(icon[0] * 64);
var y = -(icon[1] * 64);
for (let i = 0; i < spells.length; i++) {
let icon = spells[i].icon;
let x = -(icon[0] * 64);
let y = -(icon[1] * 64);

var hotkey = (spells[i].id == 0) ? 'space' : spells[i].id;
let hotkey = (spells[i].id == 0) ? 'space' : spells[i].id;

var html = templateSpell
let html = templateSpell
.replace('$HOTKEY$', hotkey);

var el = $(html)
let el = $(html)
.appendTo(this.el);
el
.on('mouseover', this.onShowTooltip.bind(this, el, spells[i]))
.on('mouseleave', this.onHideTooltip.bind(this, el));

var spritesheet = spells[i].spritesheet || '../../../images/abilityIcons.png';
let spritesheet = spells[i].spritesheet || '../../../images/abilityIcons.png';
el
.find('.icon').css({
'background': 'url("' + spritesheet + '") ' + x + 'px ' + y + 'px'
background: 'url("' + spritesheet + '") ' + x + 'px ' + y + 'px'
})
.next().html(hotkey);

@@ -60,25 +60,25 @@ define([
},

onShowTooltip: function (el, spell) {
var pos = el.offset();
let pos = el.offset();
pos = {
x: pos.left + 56,
y: pos.top + el.height() + 16
};

var cd = ~~((spell.cdMax * 350) / 1000);
let cd = ~~((spell.cdMax * 350) / 1000);

var values = Object.keys(spell.values).filter(function (v) {
let values = Object.keys(spell.values).filter(function (v) {
return ((v != 'damage') && (v != 'healing'));
}).map(function (v) {
return v + ': ' + spell.values[v];
}).join('<br />');

var manaCost = spell.manaCost;
let manaCost = spell.manaCost;
if (spell.manaReserve)
manaCost = ~~(spell.manaReserve.percentage * 100) + '% reserved';

var tooltip = templateTooltip
let tooltip = templateTooltip
.replace('$NAME$', spell.name)
.replace('$DESCRIPTION$', spell.description)
.replace('$MANA$', manaCost)
@@ -101,24 +101,24 @@ define([
},

onGetSpellCooldowns: function (options) {
var spell = this.spells.find(function (s) {
let spell = this.spells.find(function (s) {
return (s.id == options.spell);
});
spell.ttl = options.cd;
spell.ttlStart = +new Date;
spell.ttlStart = +new Date();
},

onGetStats: function (stats) {
var mana = stats.mana;
let mana = stats.mana;

var spells = this.spells;
let spells = this.spells;
if (!spells)
return;

for (var i = 0; i < spells.length; i++) {
var spell = spells[i];
for (let i = 0; i < spells.length; i++) {
let spell = spells[i];

var el = this.el.children('div').eq(i).find('.hotkey');
let el = this.el.children('div').eq(i).find('.hotkey');
el.removeClass('no-mana');
if (spell.manaCost > mana)
el.addClass('no-mana');
@@ -126,14 +126,14 @@ define([
},

update: function () {
var spells = this.spells;
let spells = this.spells;
if (!spells)
return;

var time = +new Date;
let time = +new Date();

for (var i = 0; i < spells.length; i++) {
var spell = spells[i];
for (let i = 0; i < spells.length; i++) {
let spell = spells[i];

if (!spell.ttl) {
this.el.children('div').eq(i).find('.cooldown').css({
@@ -142,8 +142,8 @@ define([
continue;
}

var elapsed = time - spell.ttlStart;
var width = 1 - (elapsed / spell.ttl);
let elapsed = time - spell.ttlStart;
let width = 1 - (elapsed / spell.ttl);
if (width <= 0) {
delete spell.ttl;
width = 0;
@@ -156,5 +156,5 @@ define([
});
}
}
}
};
});

+ 23
- 27
src/client/ui/templates/stash/stash.js View File

@@ -31,28 +31,28 @@ define([
},

build: function () {
var container = this.el.find('.grid')
let container = this.el.find('.grid')
.empty();

var items = this.items;
var iLen = items.length;
let items = this.items;
let iLen = items.length;

var remainder = iLen % 8;
var startNoPad = ~~(iLen / 8);
let remainder = iLen % 8;
let startNoPad = ~~(iLen / 8);
if (remainder == 0)
startNoPad--;
startNoPad *= 8;

for (var i = 0; i < iLen; i++) {
var item = items[i];
for (let i = 0; i < iLen; i++) {
let item = items[i];

var imgX = -item.sprite[0] * 64;
var imgY = -item.sprite[1] * 64;
let imgX = -item.sprite[0] * 64;
let imgY = -item.sprite[1] * 64;

var itemEl = $(tplItem)
let itemEl = $(tplItem)
.appendTo(container);

var spritesheet = item.spritesheet || '../../../images/items.png';
let spritesheet = item.spritesheet || '../../../images/items.png';
if (!item.spritesheet) {
if (item.material)
spritesheet = '../../../images/materials.png';
@@ -107,20 +107,20 @@ define([
else
item = this.hoverItem;

var ttPos = null;
let ttPos = null;

if (el) {
el.removeClass('new');
delete item.isNew;

var elOffset = el.offset();
let elOffset = el.offset();
ttPos = {
x: ~~(elOffset.left + 74),
y: ~~(elOffset.top + 4)
};
}

var compare = null;
let compare = null;
if (this.shiftDown) {
compare = window.player.inventory.items.find(function (i) {
return ((i.eq) && (i.slot == item.slot));
@@ -154,14 +154,12 @@ define([
return 0;
else if (a.name > b.name)
return 1;
} else {
if ((a.type || '') < (b.type || ''))
return -1;
else if ((a.type || '') == (b.type || ''))
return 0;
else if ((a.type || '') > (b.type || ''))
return 1;
}
} else if ((a.type || '') < (b.type || ''))
return -1;
else if ((a.type || '') == (b.type || ''))
return 0;
else if ((a.type || '') > (b.type || ''))
return 1;
} else if ((a.quest) && (!b.quest))
return -1;
else if ((b.quest) && (!a.quest))
@@ -174,9 +172,8 @@ define([
return -1;
else if (a.slot < b.slot)
return 1;
else {
else
return b.id - a.id;
}
});

if (this.shown)
@@ -184,10 +181,9 @@ define([
},
onDestroyStashItems: function (itemIds) {
itemIds.forEach(function (id) {
var item = this.items.find(i => i.id == id);
if (item == this.hoverItem) {
let item = this.items.find(i => i.id == id);
if (item == this.hoverItem)
this.hideTooltip();
}

this.items.spliceWhere(i => i.id == id);
}, this);


+ 11
- 12
src/client/ui/templates/talk/talk.js View File

@@ -4,7 +4,7 @@ define([
'html!ui/templates/talk/template',
'css!ui/templates/talk/styles',
'html!ui/templates/talk/tplOption'
], function(
], function (
events,
client,
template,
@@ -16,32 +16,31 @@ define([

modal: true,

postRender: function() {
postRender: function () {
this.onEvent('onGetTalk', this.onGetTalk.bind(this));
this.onEvent('onRezone', this.onRezone.bind(this));
},

onRezone: function() {
onRezone: function () {
this.hide();
},

onGetTalk: function(dialogue) {
onGetTalk: function (dialogue) {
this.state = dialogue;

if (!dialogue) {
this.hide();
return;
}
else {
this.show();
}
this.show();

this.find('.name').html(dialogue.from);
this.find('.msg').html('"' + dialogue.msg + '"');
var options = this.find('.options').empty();
let options = this.find('.options').empty();

dialogue.options.forEach(function(o) {
var html = tplOption;
dialogue.options.forEach(function (o) {
let html = tplOption;

$(html)
.appendTo(options)
@@ -52,7 +51,7 @@ define([
this.center(true, false);
},

onReply: function(option) {
onReply: function (option) {
client.request({
cpn: 'player',
method: 'performAction',
@@ -67,4 +66,4 @@ define([
});
}
};
});
});

+ 10
- 10
src/client/ui/templates/target/target.js View File

@@ -21,13 +21,13 @@ define([
},

onContextMenu: function (e) {
var target = this.target;
let target = this.target;
//This is kind of a hack. We check if the target has a prophecies component since we can't check for
// target.player (only the logged-in player has a player component)
if ((e.button != 2) || (!target) || (!target.dialogue) || (target == window.player) || (target.prophecies))
return;

var context = [
let context = [
target.name,
'----------', {
text: 'talk',
@@ -54,13 +54,13 @@ define([
this.lastLevel = null;
this.el.hide();
} else {
var el = this.el;
let el = this.el;
el.find('.infoName').html(target.name);
el.find('.infoLevel')
.html('(' + target.stats.values.level + ')')
.removeClass('high-level');

var crushing = (target.stats.values.level - 5 >= window.player.stats.values.level);
let crushing = (target.stats.values.level - 5 >= window.player.stats.values.level);
if (crushing)
el.find('.infoLevel').addClass('high-level');

@@ -72,16 +72,16 @@ define([
},

buildBar: function (barIndex, value, max) {
var box = this.el.find('.statBox').eq(barIndex);
let box = this.el.find('.statBox').eq(barIndex);

var w = ~~((value / max) * 100);
let w = ~~((value / max) * 100);
box.find('[class^="stat"]').css('width', w + '%');

box.find('.text').html(Math.floor(value) + '/' + Math.floor(max));
},

update: function () {
var target = this.target;
let target = this.target;

if (!target)
return;
@@ -91,14 +91,14 @@ define([
return;
}

var stats = target.stats.values;
let stats = target.stats.values;

if (stats.level != this.lastLevel) {
this.el.find('.infoLevel')
.html('(' + stats.level + ')')
.removeClass('high-level');

var crushing = (stats.level - 5 >= window.player.stats.level);
let crushing = (stats.level - 5 >= window.player.stats.level);
if (crushing)
this.el.find('.infoLevel').addClass('high-level');
}
@@ -113,5 +113,5 @@ define([
this.lastMana = stats.mana;
}
}
}
};
});

+ 5
- 5
src/client/ui/templates/tooltipInfo/tooltipInfo.js View File

@@ -26,11 +26,11 @@ define([
return;
}

var values = mob.stats.values;
let values = mob.stats.values;
this.lastHp = values.hp;
this.lastHpMax = values.hpMax;

var html = mob.name + ' (' + mob.stats.values.level + ')';
let html = mob.name + ' (' + mob.stats.values.level + ')';
if (mob.stats.values.level - 5 >= window.player.stats.values.level)
html = '<font class="color-red">' + html + '</font>';
if (mob.aggro) {
@@ -45,7 +45,7 @@ define([
},

update: function () {
var mob = this.mob;
let mob = this.mob;
if (!mob)
return;

@@ -53,12 +53,12 @@ define([
this.mob = null;
this.el.hide();
} else {
var values = mob.stats.values;
let values = mob.stats.values;
if (values.hp != this.lastHp)
this.onMobHover(mob);
else if (values.hpMax != this.lastHpMax)
this.onMobHover(mob);
}
}
}
};
});

+ 36
- 40
src/client/ui/templates/tooltipItem/tooltipItem.js View File

@@ -11,7 +11,7 @@ define([
tplTooltip,
statTranslations
) {
var percentageStats = [
let percentageStats = [
'addCritChance',
'addCritMultiplier',
'addAttackCritChance',
@@ -67,12 +67,12 @@ define([
onShowItemTooltip: function (item, pos, compare, bottomAlign, shiftDown) {
this.item = item;

var tempStats = $.extend(true, {}, item.stats);
var enchantedStats = item.enchantedStats || {};
let tempStats = $.extend(true, {}, item.stats);
let enchantedStats = item.enchantedStats || {};

if ((compare) && (shiftDown)) {
if (!item.eq) {
var compareStats = compare.stats;
let compareStats = compare.stats;
for (var s in tempStats) {
if (compareStats[s]) {
var delta = tempStats[s] - compareStats[s];
@@ -84,9 +84,8 @@ define([
tempStats[s] = '+' + tempStats[s];
}
for (var s in compareStats) {
if (!tempStats[s]) {
if (!tempStats[s])
tempStats[s] = -compareStats[s];
}
}
}
} else {
@@ -103,21 +102,21 @@ define([

stats = Object.keys(tempStats)
.map(function (s) {
var isEnchanted = (s[0] == '_');
var statName = s;
let isEnchanted = (s[0] == '_');
let statName = s;
if (isEnchanted)
statName = statName.substr(1);

statName = statTranslations.translate(statName);
var value = tempStats[s];
let value = tempStats[s];

if (percentageStats.indexOf(s) > -1)
value += '%';
else if ((s.indexOf('element') == 0) && (s.indexOf('Resist') == -1))
value += '%';

var row = value + ' ' + statName;
var rowClass = '';
let row = value + ' ' + statName;
let rowClass = '';

if (compare) {
if (row.indexOf('-') > -1)
@@ -140,37 +139,36 @@ define([
return 1;
else if ((a.indexOf('enchanted') == -1) && (b.indexOf('enchanted') > -1))
return -1;
else
return 0;
return 0;
})
.join('');

var implicitStats = (item.implicitStats || []).map(function (s) {
var stat = s.stat;
var statName = statTranslations.translate(stat);
var value = s.value;
let implicitStats = (item.implicitStats || []).map(function (s) {
let stat = s.stat;
let statName = statTranslations.translate(stat);
let value = s.value;

if (percentageStats.indexOf(stat) > -1)
value += '%';
else if ((stat.indexOf('element') == 0) && (stat.indexOf('Resist') == -1))
value += '%';

var row = value + ' ' + statName;
var rowClass = '';
let row = value + ' ' + statName;
let rowClass = '';
row = '<div class="' + rowClass + '">' + row + '</div>';

return row;
}).join('');

var name = item.name;
let name = item.name;
if (item.quantity > 1)
name += ' x' + item.quantity;

var level = null;
let level = null;
if (item.level)
level = item.level.push ? item.level[0] + ' - ' + item.level[1] : item.level;

var html = tplTooltip
let html = tplTooltip
.replace('$NAME$', name)
.replace('$QUALITY$', item.quality)
.replace('$TYPE$', item.type)
@@ -189,29 +187,28 @@ define([
html = html.replace('$POWER$', ' ' + (new Array(item.power + 1)).join('+'));

if ((item.spell) && (item.spell.values)) {
var abilityValues = '';
for (var p in item.spell.values) {
let abilityValues = '';
for (let p in item.spell.values) {
if ((compare) && (shiftDown)) {
var delta = item.spell.values[p] - compare.spell.values[p];
// adjust by EPSILON to handle float point imprecision, otherwise 3.15 - 2 = 1.14 or 2 - 3.15 = -1.14
// have to move away from zero by EPSILON, not a simple add
if (delta >= 0) {
if (delta >= 0)
delta += Number.EPSILON;
} else {
else
delta -= Number.EPSILON;
}
delta = ~~((delta) * 100) / 100;
var rowClass = '';
let rowClass = '';
if (delta > 0) {
rowClass = 'gainDamage';
delta = '+' + delta;
} else if (delta < 0) {
} else if (delta < 0)
rowClass = 'loseDamage';
}
abilityValues += '<div class="' + rowClass + '">' + p + ': ' + delta + '</div>';
} else {
} else
abilityValues += p + ': ' + item.spell.values[p] + '<br/>';
}
}
if (!item.ability)
abilityValues = abilityValues;
@@ -235,8 +232,7 @@ define([
this.tooltip.find('.requires').hide();
else
this.tooltip.find('.requires .stats').hide();
}
else
} else
this.tooltip.find('.requires .stats').show();

if ((!item.stats) || (!Object.keys(item.stats).length))
@@ -253,7 +249,7 @@ define([
if (item.power)
this.tooltip.find('.power').show();

var equipErrors = window.player.inventory.equipItemErrors(item);
let equipErrors = window.player.inventory.equipItemErrors(item);
equipErrors.forEach(function (e) {
this.tooltip.find('.requires').addClass('high-level');
this.tooltip.find('.requires .' + e).addClass('high-level');
@@ -270,9 +266,9 @@ define([
} else if (item.eq)
this.tooltip.find('.info').hide();

if (!item.ability) {
if (!item.ability)
this.tooltip.find('.damage').hide();
} else
else
this.tooltip.find('.info').hide();

if (item.spell) {
@@ -290,7 +286,7 @@ define([
this.tooltip.find('.worth').html(item.worthText ? ('<br />value: ' + item.worthText) : '');

if ((item.effects) && (item.type != 'mtx')) {
var htmlEffects = '';
let htmlEffects = '';

item.effects.forEach(function (e, i) {
htmlEffects += e.text;
@@ -315,10 +311,10 @@ define([
}

if (item.factions) {
var htmlFactions = '';
let htmlFactions = '';

item.factions.forEach(function (f, i) {
var htmlF = f.name + ': ' + f.tierName;
let htmlF = f.name + ': ' + f.tierName;
if (f.noEquip)
htmlF = '<font class="color-red">' + htmlF + '</font>';



+ 19
- 19
src/client/ui/templates/trade/trade.js View File

@@ -35,19 +35,19 @@ define([

this.find('.heading-text').html(action);

var uiInventory = $('.uiInventory').data('ui');
let uiInventory = $('.uiInventory').data('ui');

var container = this.el.find('.grid')
let container = this.el.find('.grid')
.empty();

var buyItems = itemList.items;
let buyItems = itemList.items;

buyItems.forEach(function (item) {
if ((item == this.hoverItem))
this.onHover(null, item);
}, this);

var iLen = Math.max(buyItems.length, 50);
let iLen = Math.max(buyItems.length, 50);
for (var i = 0; i < iLen; i++) {
var item = buyItems[i];

@@ -65,13 +65,13 @@ define([

item = $.extend(true, {}, item);

var size = 64;
var offset = 0;
let size = 64;
let offset = 0;

var itemEl = $(tplItem)
let itemEl = $(tplItem)
.appendTo(container);

var spritesheet = item.spritesheet || '../../../images/items.png';
let spritesheet = item.spritesheet || '../../../images/items.png';
if (item.material)
spritesheet = '../../../images/materials.png';
else if (item.quest)
@@ -85,8 +85,8 @@ define([
spritesheet = '../../../images/characters.png';
}

var imgX = (-item.sprite[0] * size) + offset;
var imgY = (-item.sprite[1] * size) + offset;
let imgX = (-item.sprite[0] * size) + offset;
let imgY = (-item.sprite[1] * size) + offset;

itemEl
.data('item', item)
@@ -103,14 +103,14 @@ define([
itemEl.find('.quantity').html('EQ');

if (action == 'buy') {
var noAfford = false;
let noAfford = false;
if (item.worth.currency) {
var currencyItems = window.player.inventory.items.find(function (i) {
let currencyItems = window.player.inventory.items.find(function (i) {
return (i.name == item.worth.currency);
});
noAfford = ((!currencyItems) || (currencyItems.quantity < item.worth.amount));
} else
noAfford = (item.worth * this.itemList.markup > window.player.trade.gold)
noAfford = (item.worth * this.itemList.markup > window.player.trade.gold);

if ((!noAfford) && (item.factions)) {
noAfford = item.factions.some(function (f) {
@@ -156,26 +156,26 @@ define([
callback: this.onServerRespond.bind(this, el)
});

var uiInventory = $('.uiInventory').data('ui');
let uiInventory = $('.uiInventory').data('ui');
uiInventory.hideTooltip(el, item, e);
},

onHover: function (el, item, action, e) {
var uiInventory = $('.uiInventory').data('ui');
let uiInventory = $('.uiInventory').data('ui');
uiInventory.onHover(el, item, e);

var canAfford = true;
let canAfford = true;
if (action == 'buy') {
if (item.worth.currency) {
var currencyItems = window.player.inventory.items.find(function (i) {
let currencyItems = window.player.inventory.items.find(function (i) {
return (i.name == item.worth.currency);
});
canAfford = ((currencyItems) && (currencyItems.quantity >= item.worth.amount));
} else
canAfford = (item.worth * this.itemList.markup <= window.player.trade.gold)
canAfford = (item.worth * this.itemList.markup <= window.player.trade.gold);
}

var uiTooltipItem = $('.uiTooltipItem').data('ui');
let uiTooltipItem = $('.uiTooltipItem').data('ui');
uiTooltipItem.showWorth(canAfford);
},



+ 9
- 9
src/client/ui/templates/wardrobe/wardrobe.js View File

@@ -28,15 +28,15 @@ define([
},

onGetWardrobeSkins: function (msg) {
var list = msg.skins;
let list = msg.skins;
this.wardrobeId = msg.id;

var container = this.find('.list').empty();
let container = this.find('.list').empty();

list.forEach(function (l) {
var html = '<div class="skinName">' + l.name + '</div>';
let html = '<div class="skinName">' + l.name + '</div>';

var el = $(html)
let el = $(html)
.appendTo(container);

el.on('click', this.setPreview.bind(this, l, el));
@@ -57,11 +57,11 @@ define([

this.skin = skin;

var costume = skin.sprite.split(',');
var spirteX = -costume[0] * 8;
var spriteY = -costume[1] * 8;
let costume = skin.sprite.split(',');
let spirteX = -costume[0] * 8;
let spriteY = -costume[1] * 8;

var spritesheet = skin.spritesheet || '../../../images/characters.png';
let spritesheet = skin.spritesheet || '../../../images/characters.png';

this.find('.sprite')
.css('background', 'url("' + spritesheet + '") ' + spirteX + 'px ' + spriteY + 'px');
@@ -81,5 +81,5 @@ define([
}
});
}
}
};
});

+ 2
- 2
src/client/ui/templates/workbench/workbench.js View File

@@ -123,11 +123,11 @@ define([
});
},

onAfterShow: function() {
onAfterShow: function () {
this.clear();
},

clear: function() {
clear: function () {
this.find('.left .list .selected').removeClass('selected');
this.find('.title').html('');
this.find('.description').html('');


+ 10
- 10
src/client/ui/uiBase.js View File

@@ -14,7 +14,7 @@ define([
eventCallbacks: {},

render: function () {
var container = '.ui-container';
let container = '.ui-container';
if (this.container)
container += ' > ' + this.container;

@@ -49,13 +49,13 @@ define([
this.options = options;
},
on: function (el, event, callback) {
if (typeof (el) == 'string')
if (typeof (el) === 'string')
el = this.find(el);
else
el = $(el);

el.on(event, function () {
var args = [].slice.call(arguments, 1);
let args = [].slice.call(arguments, 1);
args.splice(0, 0, event);

callback.apply(null, args);
@@ -73,11 +73,11 @@ define([
this.centeredX = x;
this.centeredY = y;

var el = this.el;
var pat = el.parent();
let el = this.el;
let pat = el.parent();

var posX = ~~((pat.width() / 2) - (el.width() / 2)) - 10;
var posY = ~~((pat.height() / 2) - (el.height() / 2)) - 10;
let posX = ~~((pat.width() / 2) - (el.width() / 2)) - 10;
let posY = ~~((pat.height() / 2) - (el.height() / 2)) - 10;

el.css('position', 'absolute');
if (x)
@@ -115,15 +115,15 @@ define([
},

setDisabled: function (isDisabled) {
this.el.removeClass('disabled')
this.el.removeClass('disabled');

if (isDisabled)
this.el.addClass('disabled');
},

onEvent: function (event, callback) {
var list = this.eventCallbacks[event] || (this.eventCallbacks[event] = []);
var eventCallback = events.on(event, callback);
let list = this.eventCallbacks[event] || (this.eventCallbacks[event] = []);
let eventCallback = events.on(event, callback);
list.push(eventCallback);

return eventCallback;


Loading…
Cancel
Save