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/* node_modules/*
*.json *.json

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

@@ -4,51 +4,51 @@ require.config({
baseUrl: '', baseUrl: '',
waitSeconds: 120, waitSeconds: 120,
paths: { 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: { shim: {
'howler': {
howler: {
exports: 'howl' exports: 'howl'
}, },
'socket': {
socket: {
exports: 'io' exports: 'io'
}, },
'jquery': {
jquery: {
exports: '$' exports: '$'
}, },
'helpers': {
helpers: {
deps: [ deps: [
'jquery' 'jquery'
] ]
}, },
'pixi': {
pixi: {
exports: 'PIXI' exports: 'PIXI'
}, },
'particles': {
particles: {
deps: [ deps: [
'pixi' 'pixi'
] ]
}, },
'picture': {
picture: {
deps: [ deps: [
'pixi' 'pixi'
] ]
}, },
'main': {
main: {
deps: [ deps: [
'helpers', 'helpers',
'js/input' 'js/input'


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

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

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

@@ -1,6 +1,6 @@
define([ define([
'js/rendering/renderer' 'js/rendering/renderer'
], function(
], function (
renderer renderer
) { ) {
return { return {
@@ -23,7 +23,7 @@ define([


oldTexture: null, oldTexture: null,


init: function(blueprint) {
init: function (blueprint) {
if (!this.obj.sprite) if (!this.obj.sprite)
return true; return true;
@@ -32,16 +32,15 @@ define([
this.frame = 0; this.frame = 0;
this.frameDelayCd = 0; this.frameDelayCd = 0;


for (var p in this.template) {
for (let p in this.template)
this[p] = this.template[p]; this[p] = this.template[p];
}


this.frameDelayCd = this.frameDelay; this.frameDelayCd = this.frameDelay;


this.setSprite(); this.setSprite();
}, },


setSprite: function() {
setSprite: function () {
renderer.setSprite({ renderer.setSprite({
sprite: this.obj.sprite, sprite: this.obj.sprite,
cell: (this.row * 8) + this.col + this.frame, cell: (this.row * 8) + this.col + this.frame,
@@ -49,7 +48,7 @@ define([
}); });
}, },


update: function() {
update: function () {
if (this.frameDelayCd > 0) if (this.frameDelayCd > 0)
this.frameDelayCd--; this.frameDelayCd--;
else { else {
@@ -61,16 +60,15 @@ define([
this.destroyed = true; this.destroyed = true;
return; return;
} }
else
this.frame = 0;
this.frame = 0;
} }
} }


this.setSprite(); this.setSprite();
}, },


destroy: function() {
destroy: function () {
this.obj.sprite.texture = this.oldTexture; this.obj.sprite.texture = this.oldTexture;
} }
}; };
});
});

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

@@ -5,7 +5,7 @@ define([
effects, effects,
renderer renderer
) { ) {
var scale = 40;
let scale = 40;


return { return {
type: 'attackAnimation', type: 'attackAnimation',
@@ -39,7 +39,7 @@ define([


this.frameDelayCd = this.frameDelay; 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({ this.sprite = renderer.buildObject({
sheetName: this.spritesheet || this.spriteSheet, sheetName: this.spritesheet || this.spriteSheet,
@@ -71,8 +71,7 @@ define([
this.destroyed = true; this.destroyed = true;
} }
return; return;
} else
this.frame = 0;
} this.frame = 0;
} }
} }


@@ -81,7 +80,7 @@ define([
this.sprite.y = this.obj.y * scale; 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({ renderer.setSprite({
sheetName: this.spritesheet || this.spriteSheet, sheetName: this.spritesheet || this.spriteSheet,


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

@@ -23,21 +23,21 @@ define([
init: function (blueprint) { init: function (blueprint) {
//Only allow one bumper at a time //Only allow one bumper at a time
if (this.obj.components.filter(function (c) { if (this.obj.components.filter(function (c) {
c.type == this.type
}) > 1)
c.type == this.type;
}) > 1)
return true; return true;
}, },


update: function () { update: function () {
var deltaX = this.deltaX;
let deltaX = this.deltaX;
if (deltaX < 0) if (deltaX < 0)
this.obj.flipX = true; this.obj.flipX = true;
else if (deltaX > 0) else if (deltaX > 0)
this.obj.flipX = false; this.obj.flipX = false;


if (this.updateCd > 0) {
if (this.updateCd > 0)
this.updateCd--; this.updateCd--;
} else {
else {
this.obj.offsetX += (this.deltaX * this.direction * this.speed); this.obj.offsetX += (this.deltaX * this.direction * this.speed);
this.obj.offsetY += (this.deltaY * 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 ( ], function (
renderer renderer
) { ) {
var scale = 40;
let scale = 40;


return { return {
type: 'chatter', type: 'chatter',
@@ -18,13 +18,13 @@ define([
}, },


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


if (this.cd > 0) {
if (this.cd > 0)
this.cd--; this.cd--;
} else if (this.cd == 0) {
else if (this.cd == 0) {
renderer.destroyObject({ renderer.destroyObject({
sprite: chatSprite sprite: chatSprite
}); });
@@ -33,10 +33,10 @@ define([
}, },


extend: function (serverMsg) { extend: function (serverMsg) {
var msg = serverMsg.msg + '\n\'';
let msg = serverMsg.msg + '\n\'';
this.msg = msg; this.msg = msg;


var obj = this.obj;
let obj = this.obj;


if (obj.chatSprite) { if (obj.chatSprite) {
renderer.destroyObject({ renderer.destroyObject({
@@ -44,11 +44,11 @@ define([
}); });
} }


var color = this.color;
let color = this.color;
if (msg[0] == '*') if (msg[0] == '*')
color = 0xffeb38; color = 0xffeb38;


var yOffset = (msg.split('\r\n').length - 1);
let yOffset = (msg.split('\r\n').length - 1);


obj.chatSprite = renderer.buildText({ obj.chatSprite = renderer.buildText({
layerName: 'effects', layerName: 'effects',
@@ -63,7 +63,7 @@ define([
}, },


destroy: function () { destroy: function () {
var chatSprite = this.obj.chatSprite;
let chatSprite = this.obj.chatSprite;
if (!chatSprite) if (!chatSprite)
return; return;




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

@@ -1,9 +1,9 @@
define([ define([


], function(
], function (


) { ) {
var colors = [
let colors = [
'929398', '929398',
'3fa7dd', '3fa7dd',
'faac45', 'faac45',
@@ -11,7 +11,7 @@ define([
'ffeb38' 'ffeb38'
]; ];


var chances = [
let chances = [
0.0075, 0.0075,
0.02, 0.02,
0.04, 0.04,
@@ -19,12 +19,12 @@ define([
0.095 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 { return {
@@ -32,7 +32,7 @@ define([


ownerId: null, ownerId: null,


init: function(blueprint) {
init: function (blueprint) {
if (this.ownerId != -1) { if (this.ownerId != -1) {
if (!window.player) { if (!window.player) {
this.hideSprite(); 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', { this.obj.addComponent('particles', {
chance: chances[index], chance: chances[index],
@@ -75,9 +75,9 @@ define([
}); });
}, },


hideSprite: function() {
hideSprite: function () {
if (this.obj.sprite) if (this.obj.sprite)
this.obj.sprite.visible = false; this.obj.sprite.visible = false;
} }
}; };
});
});

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

@@ -1,4 +1,4 @@
var components = [
let components = [
'keyboardMover', 'keyboardMover',
'mouseMover', 'mouseMover',
'player', 'player',
@@ -38,7 +38,7 @@ var components = [
}); });


define(components, function () { define(components, function () {
var templates = {};
let templates = {};


[].forEach.call(arguments, function (t) { [].forEach.call(arguments, function (t) {
templates[t.type] = 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/client',
'js/system/events', 'js/system/events',
'ui/factory' 'ui/factory'
], function(
], function (
client, client,
events, events,
factory factory
@@ -10,11 +10,11 @@ define([
return { return {
type: 'dialogue', type: 'dialogue',


init: function() {
init: function () {


}, },


talk: function(target) {
talk: function (target) {
client.request({ client.request({
cpn: 'player', cpn: 'player',
method: 'performAction', method: 'performAction',
@@ -28,8 +28,8 @@ define([
}); });
}, },


extend: function(blueprint) {
extend: function (blueprint) {
events.emit('onGetTalk', blueprint.state); events.emit('onGetTalk', blueprint.state);
} }
}; };
});
});

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

@@ -1,23 +1,23 @@
define([ define([
'js/system/events' 'js/system/events'
], function(
], function (
events events
) { ) {
return { return {
type: 'events', type: 'events',
list: [], list: [],


init: function() {
this.list.forEach(function(q) {
init: function () {
this.list.forEach(function (q) {
events.emit('onObtainEvent', q); events.emit('onObtainEvent', q);
}); });
}, },


extend: function(blueprint) {
extend: function (blueprint) {
if (blueprint.updateList) { if (blueprint.updateList) {
blueprint.updateList.forEach(function(q) {
blueprint.updateList.forEach(function (q) {
events.emit('onObtainEvent', q); events.emit('onObtainEvent', q);
this.list.spliceWhere(function(l) {
this.list.spliceWhere(function (l) {
return (l.id == q.id); return (l.id == q.id);
}); });
this.list.push(q); this.list.push(q);
@@ -25,13 +25,13 @@ define([
} }


if (blueprint.removeList) { if (blueprint.removeList) {
blueprint.removeList.forEach(function(q) {
blueprint.removeList.forEach(function (q) {
events.emit('onRemoveEvent', q.id); events.emit('onRemoveEvent', q.id);
this.list.spliceWhere(function(l) {
this.list.spliceWhere(function (l) {
return (l.id == q.id); return (l.id == q.id);
}); });
}, this); }, this);
} }
} }
}; };
});
});

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

@@ -1,6 +1,6 @@
define([ define([
'js/rendering/effects' 'js/rendering/effects'
], function(
], function (
effects effects
) { ) {
return { return {
@@ -11,7 +11,7 @@ define([
blueprint: null, blueprint: null,
particles: null, particles: null,


init: function(blueprint) {
init: function (blueprint) {
this.blueprint = { this.blueprint = {
new: true, new: true,
blueprint: $.extend(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 = this.obj.addComponent('particles', this.blueprint);


this.particles.emitter.update(0.2); this.particles.emitter.update(0.2);
this.particles.emitter.emit = false; this.particles.emitter.emit = false;
} }
}; };
});
});

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

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


getColor: function () { 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) if (hex.length < 6)
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; 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 = parseInt(hex.substr(i * 2, 2), 16);
c = Math.round(Math.min(Math.max(0, c + (c * this.lum)), 255)).toString(16); c = Math.round(Math.min(Math.max(0, c + (c * this.lum)), 255)).toString(16);
rgb += ('00' + c).substr(c.length); rgb += ('00' + c).substr(c.length);


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

@@ -21,8 +21,8 @@ define([
if (this.effect) if (this.effect)
this.effect.destroyed = true; this.effect.destroyed = true;


var x = 0;
var y = 0;
let x = 0;
let y = 0;
while (true) { while (true) {
x = msg.x + ~~(Math.random() * msg.width); x = msg.x + ~~(Math.random() * msg.width);
y = msg.y + ~~(Math.random() * msg.height); y = msg.y + ~~(Math.random() * msg.height);


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

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


keyMove: function () { keyMove: function () {
var delta = {
let delta = {
x: input.getAxis('horizontal'), x: input.getAxis('horizontal'),
y: input.getAxis('vertical') y: input.getAxis('vertical')
}; };
@@ -65,11 +65,11 @@ define([
this.direction.x = delta.x; this.direction.x = delta.x;
this.direction.y = delta.y; 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)) { if (physics.isTileBlocking(~~newX, ~~newY)) {
this.bump(delta.x, delta.y)
this.bump(delta.x, delta.y);
return; return;
} }




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

@@ -1,11 +1,11 @@
define([ define([
'js/rendering/effects', 'js/rendering/effects',
'js/rendering/renderer' 'js/rendering/renderer'
], function(
], function (
effects, effects,
renderer renderer
) { ) {
var scale = 40;
let scale = 40;


return { return {
type: 'light', type: 'light',
@@ -17,20 +17,20 @@ define([


range: 3, range: 3,


init: function(blueprint) {
init: function (blueprint) {
this.blueprint = this.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({ this.emitters[n] = renderer.buildEmitter({
pos: { 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]]; delete this.emitters[keys[i]];


renderer.destroyEmitter(emitter); renderer.destroyEmitter(emitter);
} }
} }
}; };
});
});

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

@@ -1,12 +1,12 @@
define([ define([
'js/rendering/renderer', 'js/rendering/renderer',
'picture' 'picture'
], function(
], function (
renderer, renderer,
picture picture
) { ) {
var scale = 40;
var scaleMult = 5;
let scale = 40;
let scaleMult = 5;


return { return {
type: 'lightPatch', type: 'lightPatch',
@@ -15,21 +15,21 @@ define([
patches: [], patches: [],
rays: [], rays: [],


init: function(blueprint) {
init: function (blueprint) {
this.blueprint = this.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 i = 0; i < obj.width; i++) {
for (var j = 0; j < obj.height; j++) { 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), x: (x + i),
y: (y + j), y: (y + j),
sheetName: 'white', 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++) { 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' layerName: 'lightBeams'
}); });
this.rays.push(rContainer); this.rays.push(rContainer);


for (var j = 0; j < h; j++) { for (var j = 0; j < h; j++) {
var ray = renderer.buildObject({
let ray = renderer.buildObject({
x: nx, x: nx,
y: ny, y: ny,
cell: 0, 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; r.alpha += (Math.random() * 0.03) - 0.015;
if (r.alpha < 0.3) 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); p.parent.removeChild(p);
}); });
this.patches = []; this.patches = [];


this.rays.forEach(function(r) {
this.rays.forEach(function (r) {
r.parent.removeChild(r); r.parent.removeChild(r);
}); });
this.rays = []; this.rays = [];
} }
}; };
});
});

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

@@ -1,7 +1,7 @@
define([ define([
'js/rendering/lightningBuilder', 'js/rendering/lightningBuilder',
'js/rendering/effects' 'js/rendering/effects'
], function(
], function (
lightningBuilder, lightningBuilder,
effects effects
) { ) {
@@ -20,16 +20,16 @@ define([
lineShrink: false, lineShrink: false,
shrinking: false, shrinking: false,


init: function() {
init: function () {
effects.register(this); 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({ this.effect = lightningBuilder.build({
fromX: fromX, 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))) if (((this.lineGrow) && (this.linePercentage < 1)) || ((this.shrinking) && (this.linePercentage > 0)))
cdMax = 1; 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.lineGrow) &&
(this.linePercentage < 1) (this.linePercentage < 1)
@@ -86,17 +86,17 @@ define([


if (changeTo) { if (changeTo) {
var linePercentage = this.linePercentage; var linePercentage = this.linePercentage;
if (this.shrinking) {
if (this.shrinking)
linePercentage /= 1.5; linePercentage /= 1.5;
} else {
else {
linePercentage *= 1.5; linePercentage *= 1.5;
if (linePercentage > 1) if (linePercentage > 1)
linePercentage = 1; linePercentage = 1;
} }
this.linePercentage = linePercentage; 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); toX = fromX + (Math.cos(angle) * distance * this.linePercentage);
toY = fromY + (Math.sin(angle) * distance * this.linePercentage); toY = fromY + (Math.sin(angle) * distance * this.linePercentage);
} }
@@ -115,7 +115,7 @@ define([
this.destroyed = true; this.destroyed = true;
}, },


destroyManual: function() {
destroyManual: function () {
if ((!this.lineShrink) || (this.shrinking)) { if ((!this.lineShrink) || (this.shrinking)) {
if (this.effect) if (this.effect)
lightningBuilder.destroy(this.effect); lightningBuilder.destroy(this.effect);
@@ -130,4 +130,4 @@ define([
return true; return true;
} }
}; };
});
});

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

@@ -11,7 +11,7 @@ define([
input, input,
objects objects
) { ) {
var scale = 40;
let scale = 40;


return { return {
type: 'mouseMover', type: 'mouseMover',
@@ -49,7 +49,7 @@ define([
renderer.destroyObject({ renderer.destroyObject({
sprite: p.sprite, sprite: p.sprite,
layerName: 'effects' layerName: 'effects'
})
});
} }
}); });


@@ -67,8 +67,8 @@ define([
if ((e.button != null) && (e.button != 0)) if ((e.button != null) && (e.button != 0))
return; 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)) if ((tileX == this.hoverTile.x) && (tileY == this.hoverTile.y))
return; return;
@@ -94,7 +94,7 @@ define([
return { return {
x: p.x, x: p.x,
y: p.y y: p.y
}
};
}) })
}); });




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

@@ -1,6 +1,6 @@
define([ define([
'js/rendering/renderer' 'js/rendering/renderer'
], function(
], function (
renderer renderer
) { ) {
return { return {
@@ -17,7 +17,7 @@ define([


particles: null, particles: null,


init: function(blueprint) {
init: function (blueprint) {
this.particles = this.obj.addComponent('particles', { this.particles = this.obj.addComponent('particles', {
blueprint: { blueprint: {
scale: { 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.x = obj.x;
this.y = obj.y; this.y = obj.y;


if (this.targetX > this.x) {
if (this.targetX > this.x)
this.obj.flipX = false; this.obj.flipX = false;
}
else if (this.targetX < this.x) else if (this.targetX < this.x)
this.obj.flipX = true; this.obj.flipX = true;


this.obj.setSpritePosition(); 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) { if (ticksLeft <= 0) {
this.obj.x = this.targetX; this.obj.x = this.targetX;
@@ -118,4 +118,4 @@ define([
renderer.updateSprites(); renderer.updateSprites();
} }
}; };
});
});

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

@@ -1,15 +1,15 @@
define([ define([
'js/rendering/renderer' 'js/rendering/renderer'
], function(
], function (
renderer renderer
) { ) {
var scale = 40;
let scale = 40;


return { return {
type: 'particles', type: 'particles',
emitter: null, emitter: null,


init: function(blueprint) {
init: function (blueprint) {
this.blueprint = this.blueprint || {}; this.blueprint = this.blueprint || {};
this.blueprint.pos = { this.blueprint.pos = {
x: (this.obj.x * scale) + (scale / 2), x: (this.obj.x * scale) + (scale / 2),
@@ -20,7 +20,7 @@ define([
this.emitter = renderer.buildEmitter(this.blueprint); this.emitter = renderer.buildEmitter(this.blueprint);
}, },


update: function() {
update: function () {
if (this.ttl != null) { if (this.ttl != null) {
this.ttl--; this.ttl--;
if (this.ttl <= 0) { if (this.ttl <= 0) {
@@ -39,8 +39,8 @@ define([
this.emitter.spawnPos.y = (this.obj.y * scale) + (scale / 2); this.emitter.spawnPos.y = (this.obj.y * scale) + (scale / 2);
}, },


destroy: function() {
destroy: function () {
renderer.destroyEmitter(this.emitter); renderer.destroyEmitter(this.emitter);
} }
}; };
});
});

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

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


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


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


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

@@ -1,14 +1,14 @@
define([ define([
'js/rendering/renderer', 'js/rendering/renderer',
'js/system/events' 'js/system/events'
], function(
], function (
renderer, renderer,
events 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 { return {
type: 'pather', type: 'pather',
@@ -26,7 +26,7 @@ define([
lastX: 0, lastX: 0,
lastY: 0, lastY: 0,


init: function() {
init: function () {
events.on('onDeath', this.onDeath.bind(this)); events.on('onDeath', this.onDeath.bind(this));
events.on('onClearQueue', this.onDeath.bind(this)); events.on('onClearQueue', this.onDeath.bind(this));


@@ -34,8 +34,8 @@ define([
this.pathPos.y = round(this.obj.y); this.pathPos.y = round(this.obj.y);
}, },


clearPath: function() {
this.path.forEach(function(p) {
clearPath: function () {
this.path.forEach(function (p) {
renderer.destroyObject({ renderer.destroyObject({
layerName: 'effects', layerName: 'effects',
sprite: p.sprite sprite: p.sprite
@@ -45,14 +45,14 @@ define([
this.path = []; this.path = [];
}, },


onDeath: function() {
onDeath: function () {
this.clearPath(); this.clearPath();
this.pathPos.x = round(this.obj.x); this.pathPos.x = round(this.obj.x);
this.pathPos.y = round(this.obj.y); this.pathPos.y = round(this.obj.y);
}, },


add: function(x, y) {
add: function (x, y) {
if (this.path.length >= maxPathLength) if (this.path.length >= maxPathLength)
return; return;


@@ -73,9 +73,9 @@ define([
return true; 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) { if (this.path.length == 0) {
this.pathPos.x = round(x); this.pathPos.x = round(x);
@@ -88,11 +88,11 @@ define([
this.lastX = x; this.lastX = x;
this.lastY = y; 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)) { if ((p.x == x) && (p.y == y)) {
for (var j = 0; j <= i; j++) {
for (let j = 0; j <= i; j++) {
renderer.destroyObject({ renderer.destroyObject({
layerName: 'effects', layerName: 'effects',
sprite: this.path[j].sprite sprite: this.path[j].sprite
@@ -104,7 +104,7 @@ define([
} }
}, },


setPath: function(path) {
setPath: function (path) {
this.path = this.path.concat(path); this.path = this.path.concat(path);


this.pathPos.x = round(path[path.length - 1].x); 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, physics,
sound sound
) { ) {
var scale = 40;
let scale = 40;


return { return {
type: 'player', type: 'player',
@@ -30,16 +30,16 @@ define([
}, },


update: function () { 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)) if ((oldPos.x == obj.x) && (oldPos.y == obj.y))
return; 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)) if ((dx > 5) || (dy > 5))
instant = true; instant = true;


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


canvasFollow: function (delta, instant) { canvasFollow: function (delta, instant) {
var obj = this.obj;
let obj = this.obj;
delta = delta || { delta = delta || {
x: 0, x: 0,
y: 0 y: 0
@@ -80,6 +80,6 @@ define([
x: (obj.x - (renderer.width / (scale * 2))) * scale, x: (obj.x - (renderer.width / (scale * 2))) * scale,
y: (obj.y - (renderer.height / (scale * 2))) * scale y: (obj.y - (renderer.height / (scale * 2))) * scale
}, instant); }, instant);
},
}
}; };
}); });

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

@@ -1,9 +1,9 @@
define([ define([
'js/rendering/effects' 'js/rendering/effects'
], function(
], function (
effects effects
) { ) {
var scale = 40;
let scale = 40;


return { return {
type: 'projectile', type: 'projectile',
@@ -22,15 +22,15 @@ define([


particles: null, particles: null,


init: function(blueprint) {
init: function (blueprint) {
if ((!this.source) || (!this.target)) { if ((!this.source) || (!this.target)) {
this.obj.destroyed = true; this.obj.destroyed = true;
return; 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.x = source.x;
this.y = source.y; this.y = source.y;


@@ -45,7 +45,7 @@ define([
this.obj.x = this.x; this.obj.x = this.x;
this.obj.y = this.y; this.obj.y = this.y;


var particlesBlueprint = this.particles ? {
let particlesBlueprint = this.particles ? {
blueprint: this.particles blueprint: this.particles
} : { } : {
blueprint: { blueprint: {
@@ -83,14 +83,14 @@ define([
effects.register(this); 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) { if (ticksLeft <= 0) {
this.obj.x = target.x; this.obj.x = target.x;
@@ -99,8 +99,7 @@ define([
if (!this.noExplosion) if (!this.noExplosion)
this.obj.explosion.explode(); this.obj.explosion.explode();
this.obj.destroyed = true; this.obj.destroyed = true;
}
else {
} else {
dx /= ticksLeft; dx /= ticksLeft;
dy /= ticksLeft; dy /= ticksLeft;


@@ -112,8 +111,8 @@ define([
} }
}, },


destroy: function() {
destroy: function () {
effects.unregister(this); effects.unregister(this);
} }
}; };
});
});

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

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

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

@@ -1,42 +1,42 @@
define([ define([
'js/system/events' 'js/system/events'
], function(
], function (
events events
) { ) {
return { return {
type: 'quests', type: 'quests',
quests: [], quests: [],


init: function() {
this.quests.forEach(function(q) {
init: function () {
this.quests.forEach(function (q) {
events.emit('onObtainQuest', q); events.emit('onObtainQuest', q);
}); });
}, },


extend: function(blueprint) {
extend: function (blueprint) {
if (blueprint.updateQuests) { if (blueprint.updateQuests) {
blueprint.updateQuests.forEach(function(q) {
blueprint.updateQuests.forEach(function (q) {
events.emit('onUpdateQuest', q); events.emit('onUpdateQuest', q);
var index = this.quests.firstIndex(function(qq) {
let index = this.quests.firstIndex(function (qq) {
return (qq.id == q.id); return (qq.id == q.id);
}); });
this.quests.splice(index, 1, q); this.quests.splice(index, 1, q);
}, this); }, this);
} }
if (blueprint.completeQuests) { if (blueprint.completeQuests) {
blueprint.completeQuests.forEach(function(q) {
blueprint.completeQuests.forEach(function (q) {
events.emit('onCompleteQuest', q); events.emit('onCompleteQuest', q);
this.quests.spliceWhere(function(qq) {
this.quests.spliceWhere(function (qq) {
return (qq.id == q); return (qq.id == q);
}); });
}, this); }, this);
} }
if (blueprint.obtainQuests) { if (blueprint.obtainQuests) {
blueprint.obtainQuests.forEach(function(q) {
blueprint.obtainQuests.forEach(function (q) {
events.emit('onObtainQuest', q); events.emit('onObtainQuest', q);
this.quests.push(q); this.quests.push(q);
}, this); }, this);
} }
} }
}; };
});
});

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

@@ -16,13 +16,12 @@ define([
extend: function (blueprint) { extend: function (blueprint) {
if (blueprint.modifyRep) { if (blueprint.modifyRep) {
blueprint.modifyRep.forEach(function (m) { 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) if (!exists)
this.list.push(m); this.list.push(m);
else { else {
for (var p in m) {
for (let p in m)
exists[p] = m[p]; exists[p] = m[p];
}
} }
}, this); }, this);




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

@@ -1,9 +1,9 @@
define([ define([
'js/misc/physics' 'js/misc/physics'
], function(
], function (
physics physics
) { ) {
var bptParticles = {
let bptParticles = {
chance: 0.1, chance: 0.1,
blueprint: { blueprint: {
color: { color: {
@@ -25,21 +25,20 @@ define([
} }
}; };



return { return {
type: 'resourceNode', 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 new: true
}); });


@@ -70,4 +69,4 @@ define([
} }
} }
}; };
});
});

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

@@ -1,7 +1,7 @@
define([ define([
'js/system/events', 'js/system/events',
'js/system/client' 'js/system/client'
], function(
], function (
events, events,
client client
) { ) {
@@ -10,12 +10,12 @@ define([


actions: [], actions: [],


init: function(blueprint) {
init: function (blueprint) {
events.on('onKeyUp', this.onKeyUp.bind(this)); 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) if (a.key != key)
return; return;


@@ -27,10 +27,10 @@ define([
}, this); }, this);
}, },


extend: function(blueprint) {
extend: function (blueprint) {
if (blueprint.addActions) { 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)); return ((ta.targetId == a.targetId) && (ta.cpn == a.cpn) && (ta.method == a.method));
}); });
if (exists) if (exists)
@@ -43,8 +43,8 @@ define([
} }


if (blueprint.removeActions) { 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)); return ((ta.targetId == a.targetId) && (ta.cpn == a.cpn) && (ta.method == a.method));
}); });
}, this); }, this);
@@ -53,4 +53,4 @@ define([
} }
} }
}; };
});
});

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

@@ -1,6 +1,6 @@
define([ define([
'js/system/events' 'js/system/events'
], function(
], function (
events events
) { ) {
return { return {
@@ -8,7 +8,7 @@ define([


customChannels: null, customChannels: null,


init: function() {
init: function () {
if (this.customChannels) if (this.customChannels)
events.emit('onGetCustomChatChannels', this.customChannels); events.emit('onGetCustomChatChannels', this.customChannels);
} }


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

@@ -7,9 +7,9 @@ define([
renderer, renderer,
events events
) { ) {
var scale = 40;
let scale = 40;


var objects = null;
let objects = null;
require(['js/objects/objects'], function (o) { require(['js/objects/objects'], function (o) {
objects = o; objects = o;
}); });
@@ -36,14 +36,14 @@ define([
this.targetSprite = renderer.buildObject({ this.targetSprite = renderer.buildObject({
sheetName: 'ui', sheetName: 'ui',
layerName: 'effects', layerName: 'effects',
cell: this.reticleState,
cell: this.reticleState
}); });
this.targetSprite.visible = false; this.targetSprite.visible = false;


this.reticleSprite = renderer.buildObject({ this.reticleSprite = renderer.buildObject({
sheetName: 'ui', sheetName: 'ui',
layerName: 'effects', layerName: 'effects',
cell: 8 + this.reticleState,
cell: 8 + this.reticleState
}); });
this.reticleSprite.visible = false; this.reticleSprite.visible = false;


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


if (blueprint.getSpells) { if (blueprint.getSpells) {
blueprint.getSpells.forEach(function (s) { blueprint.getSpells.forEach(function (s) {
var existIndex = this.spells.firstIndex(function (spell) {
let existIndex = this.spells.firstIndex(function (spell) {
return (spell.id == s.id); return (spell.id == s.id);
}); });


@@ -93,9 +93,9 @@ define([
}, },


getSpell: function (number) { 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); return (s.id == spellNumber);
}); });
if (!spell) if (!spell)
@@ -134,7 +134,7 @@ define([
}, },


tabTarget: function () { 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.target = closest;
this.targetSprite.visible = !!this.target; this.targetSprite.visible = !!this.target;
@@ -176,11 +176,11 @@ define([
return; return;
} }


var spell = this.getSpell(key);
let spell = this.getSpell(key);
if (!spell) if (!spell)
return; return;


var oldTarget = null;
let oldTarget = null;
if (this.shiftDown) { if (this.shiftDown) {
oldTarget = this.target; oldTarget = this.target;
this.target = this.obj; this.target = this.obj;
@@ -189,8 +189,8 @@ define([
if ((!spell.aura) && (!spell.targetGround) && (!spell.autoTargetFollower) && (!this.target)) if ((!spell.aura) && (!spell.targetGround) && (!spell.autoTargetFollower) && (!this.target))
return; return;


var hoverTile = this.obj.mouseMover.hoverTile;
var target = hoverTile;
let hoverTile = this.obj.mouseMover.hoverTile;
let target = hoverTile;
if ((spell.autoTargetFollower) && (!this.target)) if ((spell.autoTargetFollower) && (!this.target))
target = null; target = null;
else if ((!spell.targetGround) && (this.target)) else if ((!spell.targetGround) && (this.target))


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

@@ -1,6 +1,6 @@
define([ define([
'js/system/events' 'js/system/events'
], function(
], function (
events events
) { ) {
return { return {
@@ -10,24 +10,24 @@ define([


items: null, items: null,


init: function() {
init: function () {
events.emit('onGetStashItems', this.items); events.emit('onGetStashItems', this.items);
}, },


extend: function(blueprint) {
extend: function (blueprint) {
if (blueprint.active != null) if (blueprint.active != null)
this.active = blueprint.active; this.active = blueprint.active;


if (blueprint.getItems) { 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 nId = nItem.id;


var findItem = items.find(function(item) {
let findItem = items.find(function (item) {
return (item.id == nId); return (item.id == nId);
}); });
if (findItem) { if (findItem) {
@@ -44,9 +44,8 @@ define([
events.emit('onGetStashItems', this.items); events.emit('onGetStashItems', this.items);
} }


if (blueprint.destroyItems) {
if (blueprint.destroyItems)
events.emit('onDestroyStashItems', blueprint.destroyItems); events.emit('onDestroyStashItems', blueprint.destroyItems);
}
} }
}; };
});
});

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

@@ -5,7 +5,7 @@ define([
events, events,
renderer renderer
) { ) {
var scale = 40;
let scale = 40;


return { return {
type: 'stats', type: 'stats',
@@ -19,13 +19,13 @@ define([
if (this.obj.self) if (this.obj.self)
events.emit('onGetStats', this.values); events.emit('onGetStats', this.values);


var serverId = this.obj.serverId;
let serverId = this.obj.serverId;
if (serverId != null) if (serverId != null)
events.emit('onGetPartyStats', serverId, this.values); events.emit('onGetPartyStats', serverId, this.values);


var obj = this.obj;
let obj = this.obj;


var yOffset = -12;
let yOffset = -12;
if (obj.isChampion) if (obj.isChampion)
yOffset = -18; yOffset = -18;


@@ -54,14 +54,14 @@ define([
if (this.obj.dead) if (this.obj.dead)
return; return;


var obj = this.obj;
let obj = this.obj;


var yOffset = -12;
let yOffset = -12;
if (obj.isChampion) if (obj.isChampion)
yOffset = -18; 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({ renderer.moveRectangle({
sprite: this.hpSprite, sprite: this.hpSprite,
@@ -84,18 +84,17 @@ define([
}, },


extend: function (blueprint) { 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]; values[b] = bValues[b];
}


if (this.obj.self) if (this.obj.self)
events.emit('onGetStats', this.values); events.emit('onGetStats', this.values);


var serverId = this.obj.serverId;
let serverId = this.obj.serverId;
if (serverId != null) if (serverId != null)
events.emit('onGetPartyStats', serverId, this.values); events.emit('onGetPartyStats', serverId, this.values);




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

@@ -1,6 +1,6 @@
define([ define([
'js/system/events' 'js/system/events'
], function(
], function (
events events
) { ) {
return { return {
@@ -9,12 +9,12 @@ define([
itemList: null, itemList: null,
action: 'buy', action: 'buy',


init: function(blueprint) {
init: function (blueprint) {
}, },


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


if (blueprint.buyList) { if (blueprint.buyList) {
this.itemList = blueprint.buyList; this.itemList = blueprint.buyList;
@@ -24,8 +24,7 @@ define([
this.action = 'buyback'; this.action = 'buyback';
delete blueprint.buyList; delete blueprint.buyList;
}
else if (blueprint.sellList) {
} else if (blueprint.sellList) {
this.itemList = blueprint.sellList; this.itemList = blueprint.sellList;
redraw = true; redraw = true;
this.action = 'sell'; this.action = 'sell';
@@ -33,7 +32,7 @@ define([
} }


if (blueprint.removeItems) { if (blueprint.removeItems) {
this.itemList.items.spliceWhere(function(b) {
this.itemList.items.spliceWhere(function (b) {
return (blueprint.removeItems.indexOf(b.id) > -1); return (blueprint.removeItems.indexOf(b.id) > -1);
}); });
redraw = true; redraw = true;
@@ -43,9 +42,8 @@ define([
if (blueprint.redraw) if (blueprint.redraw)
redraw = true; redraw = true;


for (var p in blueprint) {
for (let p in blueprint)
this[p] = blueprint[p]; this[p] = blueprint[p];
}


if (redraw) if (redraw)
events.emit('onGetTradeList', this.itemList, this.action); events.emit('onGetTradeList', this.itemList, this.action);
@@ -54,4 +52,4 @@ define([
events.emit('onCloseTrade'); events.emit('onCloseTrade');
} }
}; };
});
});

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

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


mappings: { 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 //hacks for mac cmd key
'17': 'ctrl',
'224': 'ctrl',
'91': 'ctrl',
'93': 'ctrl'
17: 'ctrl',
224: 'ctrl',
91: 'ctrl',
93: 'ctrl'
}, },


mouse: { mouse: {
@@ -60,9 +60,8 @@ define([
}, },


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


this.keys = {}; this.keys = {};
}, },
@@ -75,27 +74,24 @@ define([
this.mappings[charCode] || this.mappings[charCode] ||
String.fromCharCode(charCode).toLowerCase() String.fromCharCode(charCode).toLowerCase()
); );

}, },


isKeyDown: function (key, noConsume) { isKeyDown: function (key, noConsume) {
var down = this.keys[key];
let down = this.keys[key];
if (down != null) { if (down != null) {
if (noConsume) if (noConsume)
return true; 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) { getAxis: function (name) {
var axis = this.axes[name];
let axis = this.axes[name];
if (!axis) if (!axis)
return 0; return 0;


var result = 0;
let result = 0;


for (var i = 0; i < axis.negative.length; i++) { for (var i = 0; i < axis.negative.length; i++) {
if (this.keys[axis.negative[i]]) { if (this.keys[axis.negative[i]]) {
@@ -125,7 +121,7 @@ define([
if ((e.keyCode == 9) || (e.keyCode == 8) || (e.keyCode == 122)) if ((e.keyCode == 9) || (e.keyCode == 8) || (e.keyCode == 122))
e.preventDefault(); e.preventDefault();


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


if (this.keys[key] != null) if (this.keys[key] != null)
this.keys[key] = 2; this.keys[key] = 2;
@@ -146,7 +142,7 @@ define([
if (e.target != document.body) if (e.target != document.body)
return; return;


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


delete this.keys[key]; delete this.keys[key];


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


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


var button = e.button;
let button = e.button;
this.mouse.button = null; this.mouse.button = null;
this.mouse.down = false; this.mouse.down = false;


@@ -186,7 +182,7 @@ define([
if (!e) if (!e)
return; return;


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




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

@@ -58,9 +58,9 @@ define([
window.onfocus = this.onFocus.bind(this, true); window.onfocus = this.onFocus.bind(this, true);
window.onblur = this.onFocus.bind(this, false); window.onblur = this.onFocus.bind(this, false);
$(window).on('contextmenu', function (e) { $(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); 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) { while (k < len) {
var kValue; var kValue;
@@ -20,12 +20,12 @@ Array.prototype.firstIndex = function(callback, thisArg) {
return -1; 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) { while (k < len) {
var kValue; 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) { while (k < len) {
var kValue; var kValue;
@@ -65,22 +65,22 @@ Array.prototype.spliceFirstWhere = function(callback, thisArg) {
}; };


window._ = { 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); $.extend(true, result, a);
}); });


return result; return result;
}, },
get2dArray: function(w, h, def) {
get2dArray: function (w, h, def) {
def = def || 0; 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') if (def == 'array')
inner.push([]); inner.push([]);
else else
@@ -92,12 +92,11 @@ window._ = {


return result; 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); sample.push(i);
}
}); });


return sample[~~(Math.random() * sample.length)]; return sample[~~(Math.random() * sample.length)];
@@ -106,8 +105,8 @@ window._ = {


define([ define([
], function(
], function (
) { ) {
return window._; return window._;
});
});

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

@@ -6,20 +6,19 @@
// http://eloquentjavascript.net/appendix2.html // http://eloquentjavascript.net/appendix2.html
(function (definition) { (function (definition) {
/* global module, define */ /* global module, define */
if (typeof module === 'object' && typeof module.exports === 'object') {
if (typeof module === 'object' && typeof module.exports === 'object')
module.exports = definition(); module.exports = definition();
} else if (typeof define === 'function' && define.amd) {
else if (typeof define === 'function' && define.amd)
define([], definition); define([], definition);
} else {
var exports = definition();
else {
let exports = definition();
window.astar = exports.astar; window.astar = exports.astar;
window.Graph = exports.Graph; window.Graph = exports.Graph;
} }
})(function () { })(function () {

function pathTo(node) {
var curr = node;
var path = [];
function pathTo (node) {
let curr = node;
let path = [];
while (curr.parent) { while (curr.parent) {
path.unshift(curr); path.unshift(curr);
curr = curr.parent; curr = curr.parent;
@@ -27,7 +26,7 @@
return path; return path;
} }


function getHeap() {
function getHeap () {
return new BinaryHeap(function (node) { return new BinaryHeap(function (node) {
return node.f; return node.f;
}); });
@@ -54,15 +53,15 @@


graph.cleanDirty(); graph.cleanDirty();
options = options || {}; 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) if (distance)
heuristic = astar.heuristics.manhattanDistance; 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); start.h = heuristic(start, end, distance);
graph.markDirty(start); graph.markDirty(start);
@@ -70,11 +69,10 @@
openHeap.push(start); openHeap.push(start);


while (openHeap.size() > 0) { while (openHeap.size() > 0) {

// Grab the lowest f(x) to process next. Heap keeps this sorted for us. // 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 (!onWall) {
if (distance) { if (distance) {
@@ -82,9 +80,8 @@
return pathTo(currentNode); return pathTo(currentNode);
} else { } else {
// End case -- result has been found, return the traced path. // End case -- result has been found, return the traced path.
if (currentNode === end) {
if (currentNode === end)
return pathTo(currentNode); return pathTo(currentNode);
}
} }
} }


@@ -92,10 +89,10 @@
currentNode.closed = true; currentNode.closed = true;


// Find all neighbors for the current node. // 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()) { if (neighbor.closed || neighbor.isWall()) {
// Not a valid node to process, skip to next neighbor. // 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. // 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. // 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) { if (!beenVisited || gScore < neighbor.g) {

// Found an optimal (so far) path to this node. Take score for node to see how good it is. // Found an optimal (so far) path to this node. Take score for node to see how good it is.
neighbor.visited = true; neighbor.visited = true;
neighbor.parent = currentNode; neighbor.parent = currentNode;
@@ -119,9 +115,8 @@
if (closest) { if (closest) {
// If the neighbour is closer than the current closestNode or if it's equally close but has // 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 // 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; closestNode = neighbor;
}
} }


if (!beenVisited) { if (!beenVisited) {
@@ -135,9 +130,8 @@
} }
} }


if (closest) {
if (closest)
return pathTo(closestNode); return pathTo(closestNode);
}


// No result was found - empty array signifies failure to find path. // No result was found - empty array signifies failure to find path.
return []; return [];
@@ -145,20 +139,20 @@
// See list of heuristics: http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html // See list of heuristics: http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html
heuristics: { heuristics: {
manhattan: function (pos0, pos1) { 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); return Math.max(d1, d2);
}, },
manhattanDistance: function (pos0, pos1, distance) { 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; return Math.abs(distance - Math.max(d1, d2)) + 1;
}, },
diagonal: function (pos0, pos1) { 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)); return (D * (d1 + d2)) + ((D2 - (2 * D)) * Math.min(d1, d2));
} }
}, },
@@ -180,16 +174,16 @@
* @param {Object} [options] * @param {Object} [options]
* @param {bool} [options.diagonal] Specifies whether diagonal moves are allowed * @param {bool} [options.diagonal] Specifies whether diagonal moves are allowed
*/ */
function Graph(gridIn, options) {
function Graph (gridIn, options) {
options = options || {}; options = options || {};
this.nodes = []; this.nodes = [];
this.diagonal = !!options.diagonal; this.diagonal = !!options.diagonal;
this.grid = []; this.grid = [];


for (var x = 0; x < gridIn.length; x++) {
for (let x = 0; x < gridIn.length; x++) {
this.grid[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]) { if (!row[y]) {
node = new GridNode(x, y, row[y] ? 0 : 1); node = new GridNode(x, y, row[y] ? 0 : 1);
this.grid[x][y] = node; this.grid[x][y] = node;
@@ -202,15 +196,14 @@


Graph.prototype.init = function () { Graph.prototype.init = function () {
this.dirtyNodes = []; 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]); astar.cleanNode(this.nodes[i]);
}
}; };


Graph.prototype.cleanDirty = function () { 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]); astar.cleanNode(this.dirtyNodes[i]);
}
this.dirtyNodes = []; this.dirtyNodes = [];
}; };


@@ -219,85 +212,77 @@
}; };


Graph.prototype.neighbors = function (node) { 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 // West
if (grid[x - 1] && grid[x - 1][y]) {
if (grid[x - 1] && grid[x - 1][y])
ret.push(grid[x - 1][y]); ret.push(grid[x - 1][y]);
}


// East // East
if (grid[x + 1] && grid[x + 1][y]) {
if (grid[x + 1] && grid[x + 1][y])
ret.push(grid[x + 1][y]); ret.push(grid[x + 1][y]);
}


// South // South
if (grid[x] && grid[x][y - 1]) {
if (grid[x] && grid[x][y - 1])
ret.push(grid[x][y - 1]); ret.push(grid[x][y - 1]);
}


// North // North
if (grid[x] && grid[x][y + 1]) {
if (grid[x] && grid[x][y + 1])
ret.push(grid[x][y + 1]); ret.push(grid[x][y + 1]);
}


if (this.diagonal) { if (this.diagonal) {
// Southwest // 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]); ret.push(grid[x - 1][y - 1]);
}


// Southeast // 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]); ret.push(grid[x + 1][y - 1]);
}


// Northwest // 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]); ret.push(grid[x - 1][y + 1]);
}


// Northeast // 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]); ret.push(grid[x + 1][y + 1]);
}
} }


return ret; return ret;
}; };


Graph.prototype.toString = function () { 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); 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.x = x;
this.y = y; this.y = y;
this.weight = weight; this.weight = weight;
} }


GridNode.prototype.toString = function () { GridNode.prototype.toString = function () {
return "[" + this.x + " " + this.y + "]";
return '[' + this.x + ' ' + this.y + ']';
}; };


GridNode.prototype.getCost = function (fromNeighbor) { GridNode.prototype.getCost = function (fromNeighbor) {
// Take diagonal weight into consideration. // 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 * 1.41421;
}
return this.weight; return this.weight;
}; };


@@ -305,7 +290,7 @@
return this.weight === 0; return this.weight === 0;
}; };


function BinaryHeap(scoreFunction) {
function BinaryHeap (scoreFunction) {
this.content = []; this.content = [];
this.scoreFunction = scoreFunction; this.scoreFunction = scoreFunction;
} }
@@ -320,9 +305,9 @@
}, },
pop: function () { pop: function () {
// Store the first element so we can return it later. // 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. // 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 // If there are any elements left, put the end element at the
// start, and let it bubble up. // start, and let it bubble up.
if (this.content.length > 0) { if (this.content.length > 0) {
@@ -332,20 +317,19 @@
return result; return result;
}, },
remove: function (node) { 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 // When it is found, the process seen in 'pop' is repeated
// to fill up the hole. // to fill up the hole.
var end = this.content.pop();
let end = this.content.pop();


if (i !== this.content.length - 1) { if (i !== this.content.length - 1) {
this.content[i] = end; this.content[i] = end;


if (this.scoreFunction(end) < this.scoreFunction(node)) {
if (this.scoreFunction(end) < this.scoreFunction(node))
this.sinkDown(i); this.sinkDown(i);
} else {
else
this.bubbleUp(i); this.bubbleUp(i);
}
} }
}, },
size: function () { size: function () {
@@ -356,14 +340,13 @@
}, },
sinkDown: function (n) { sinkDown: function (n) {
// Fetch the element that has to be sunk. // 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. // When at 0, an element can not sink any further.
while (n > 0) { while (n > 0) {

// Compute the parent element's index, and fetch it. // 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. // Swap the elements if the parent is greater.
if (this.scoreFunction(element) < this.scoreFunction(parent)) { if (this.scoreFunction(element) < this.scoreFunction(parent)) {
this.content[parentN] = element; this.content[parentN] = element;
@@ -372,43 +355,40 @@
n = parentN; n = parentN;
} }
// Found a parent that is less, no need to sink any further. // Found a parent that is less, no need to sink any further.
else {
else
break; break;
}
} }
}, },
bubbleUp: function (n) { bubbleUp: function (n) {
// Look up the target element and its score. // 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) { while (true) {
// Compute the indices of the child elements. // 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. // This is used to store the new position of the element, if any.
var swap = null;
let swap = null;
var child1Score; var child1Score;
// If the first child exists (is inside the array)... // If the first child exists (is inside the array)...
if (child1N < length) { if (child1N < length) {
// Look it up and compute its score. // Look it up and compute its score.
var child1 = this.content[child1N];
let child1 = this.content[child1N];
child1Score = this.scoreFunction(child1); child1Score = this.scoreFunction(child1);


// If the score is less than our element's, we need to swap. // If the score is less than our element's, we need to swap.
if (child1Score < elemScore) {
if (child1Score < elemScore)
swap = child1N; swap = child1N;
}
} }


// Do the same checks for the other child. // Do the same checks for the other child.
if (child2N < length) { 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; swap = child2N;
}
} }


// If the element needs to be moved, swap it, and continue. // If the element needs to be moved, swap it, and continue.
@@ -418,9 +398,8 @@
n = swap; n = swap;
} }
// Otherwise, we are done. // Otherwise, we are done.
else {
else
break; break;
}
} }
} }
}; };
@@ -430,5 +409,4 @@
Graph: Graph, Graph: Graph,
gridNode: GridNode gridNode: GridNode
}; };

}); });

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

@@ -3,9 +3,9 @@ define([
], function ( ], function (
pathfinder 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 { return {
graph: null, graph: null,
@@ -29,34 +29,33 @@ define([
}, },


addRegion: function (obj) { 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); row[j].push(obj);
}
} }
}, },


addObject: function (obj, x, y, fromX, fromY) { addObject: function (obj, x, y, fromX, fromY) {
var row = this.cells[x];
let row = this.cells[x];


if (!row) if (!row)
return; return;


var cell = row[y];
let cell = row[y];


if (!cell) if (!cell)
return; 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 we have fromX and fromY, check if the target cell doesn't contain the same obj (like a notice area)
if ((c.width) && (fromX)) { if ((c.width) && (fromX)) {
@@ -74,20 +73,20 @@ define([
return true; return true;
}, },
removeObject: function (obj, x, y, toX, toY) { removeObject: function (obj, x, y, toX, toY) {
var row = this.cells[x];
let row = this.cells[x];


if (!row) if (!row)
return; return;


var cell = row[y];
let cell = row[y];


if (!cell) if (!cell)
return; 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 (c.id != oId) {
//If we have toX and toY, check if the target cell doesn't contain the same obj (like a notice area) //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) { isValid: function (x, y) {
var row = this.cells[x];
let row = this.cells[x];


if ((!row) || (row.length <= y) || (!this.graph.grid[x][y])) if ((!row) || (row.length <= y) || (!this.graph.grid[x][y]))
return false; return false;
else
return true;
return true;
}, },


getCell: function (x, y) { getCell: function (x, y) {
var row = this.cells[x];
let row = this.cells[x];


if (!row) if (!row)
return []; return [];


var cell = row[y];
let cell = row[y];


if (!cell) if (!cell)
return []; return [];
@@ -131,8 +129,8 @@ define([
return cell; return cell;
}, },
getArea: function (x1, y1, x2, y2, filter) { 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; x1 = ~~x1;
y1 = ~~y1; y1 = ~~y1;
@@ -149,21 +147,21 @@ define([
else if (y2 >= height) else if (y2 >= height)
y2 = height - 1; 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]) if (!gridRow[j])
continue; 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) {
if (filter(c)) if (filter(c))
@@ -178,8 +176,8 @@ define([
}, },


getOpenCellInArea: function (x1, y1, x2, y2) { getOpenCellInArea: function (x1, y1, x2, y2) {
var width = this.width;
var height = this.height;
let width = this.width;
let height = this.height;


x1 = ~~x1; x1 = ~~x1;
y1 = ~~y1; y1 = ~~y1;
@@ -196,18 +194,18 @@ define([
else if (y2 >= height) else if (y2 >= height)
y2 = height - 1; 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]) if (!gridRow[j])
continue; continue;


var cell = row[j];
let cell = row[j];
if (cell.length == 0) { if (cell.length == 0) {
return { return {
x: i, x: i,
@@ -221,8 +219,8 @@ define([
}, },


getPath: function (from, to) { getPath: function (from, to) {
var graph = this.graph;
var grid = graph.grid;
let graph = this.graph;
let grid = graph.grid;


if (!to) { if (!to) {
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)) if ((!grid[fromX]) || (grid[fromX].length <= fromY) || (fromX < 0) || (fromY < 0))
return []; 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)) if ((!grid[toX]) || (grid[toX].length <= toY) || (toX < 0) || (toY < 0))
return []; return [];


var path = pathfinder.astar.search(graph, {
let path = pathfinder.astar.search(graph, {
x: fromX, x: fromX,
y: fromY y: fromY
}, { }, {
@@ -262,7 +260,7 @@ define([
x = ~~x; x = ~~x;
y = ~~y; y = ~~y;


var node = this.graph.grid[x][y];
let node = this.graph.grid[x][y];


return ((!node) || (node.weight == 0)); 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)) if ((fromX < 0) || (fromY < 0) || (fromX >= this.width) | (fromY >= this.height) || (toX < 0) || (toY < 0) || (toX >= this.width) | (toY >= this.height))
return false; return false;


var graphGrid = this.graph.grid;
let graphGrid = this.graph.grid;


if ((!graphGrid[fromX][fromY]) || (!graphGrid[toX][toY])) if ((!graphGrid[fromX][fromY]) || (!graphGrid[toX][toY]))
return false; 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; dx /= distance;
dy /= distance; dy /= distance;
@@ -294,10 +292,10 @@ define([


distance = ceil(distance); 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; fromX += dx;
fromY += dy; fromY += dy;


@@ -314,24 +312,24 @@ define([
}, },


getClosestPos: function (fromX, fromY, toX, toY, target) { 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; var lowX, lowY, highX, highY, incX, incY;


@@ -355,19 +353,18 @@ define([
highY = y2 + 1; highY = y2 + 1;
} }


for (var i = lowX; i != highX; i += incX) {
for (let i = lowX; i != highX; i += incX) {
if ((i < 0) || (i >= width)) if ((i < 0) || (i >= width))
continue; 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] = {}; t = tried[i] = {};
}


for (var j = lowY; j != highY; j += incY) {
for (let j = lowY; j != highY; j += incY) {
if (t[j]) if (t[j])
continue; continue;


@@ -380,11 +377,11 @@ define([
) )
continue; 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) { if (aggro) {
blocking = aggro.list.some(a => a.obj == target); blocking = aggro.list.some(a => a.obj == target);
if (blocking) if (blocking)
@@ -409,15 +406,15 @@ define([
if ((x < 0) || (y < 0) || (x >= this.width) | (y >= this.height)) if ((x < 0) || (y < 0) || (x >= this.width) | (y >= this.height))
return true; 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) if (cLen == 1)
return false; 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 (c.aggro) {
if ((!found) && (c == obj)) if ((!found) && (c == obj))
found = true; found = true;
@@ -430,9 +427,9 @@ define([
}, },


setCollision: function (x, y, collides) { setCollision: function (x, y, collides) {
var node = this.graph.grid[x][y];
let node = this.graph.grid[x][y];
if (!node) { if (!node) {
var grid = this.graph.grid;
let grid = this.graph.grid;
node = grid[x][y] = new pathfinder.gridNode(x, y, collides ? 0 : 1); 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 ( ], 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 //This stat is used for gambling when you can't see the stats
'stats': 'stats',
stats: 'stats',


//Fishing //Fishing
'weight': 'lb',
weight: 'lb',
//Rods //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 { return {


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

@@ -7,8 +7,8 @@ define([
renderer, renderer,
events events
) { ) {
var scale = 40;
var scaleMult = 5;
let scale = 40;
let scaleMult = 5;


return { return {
components: [], components: [],
@@ -17,19 +17,18 @@ define([
eventCallbacks: {}, eventCallbacks: {},


addComponent: function (type, options) { addComponent: function (type, options) {
var c = this[type];
let c = this[type];


if ((!c) || (options.new)) { if ((!c) || (options.new)) {
var template = components.getTemplate(type);
let template = components.getTemplate(type);
if (!template) if (!template)
return; return;


c = $.extend(true, {}, template); c = $.extend(true, {}, template);
c.obj = this; c.obj = this;


for (var o in options) {
for (let o in options)
c[o] = options[o]; c[o] = options[o];
}


//Only use component to initialize other components? //Only use component to initialize other components?
if ((c.init) && (c.init(options))) if ((c.init) && (c.init(options)))
@@ -39,16 +38,15 @@ define([
this.components.push(c); this.components.push(c);


return c; return c;
} else {
if (c.extend)
c.extend(options);
}
if (c.extend)
c.extend(options);


return c;
}
return c;
}, },


removeComponent: function (type) { removeComponent: function (type) {
var cpn = this[type];
let cpn = this[type];
if (!cpn) if (!cpn)
return; return;


@@ -60,10 +58,10 @@ define([
}, },


update: function () { 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) if (c.update)
c.update(); c.update();


@@ -80,7 +78,7 @@ define([
}, },


on: function (event, callback) { 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)); list.push(events.on(event, callback));
}, },


@@ -89,7 +87,7 @@ define([
return; return;


this.sprite.x = (this.x * scale) + (this.flipX ? scale : 0) + this.offsetX; 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; this.sprite.y = (this.y * scale) + this.offsetY;


if (this.sprite.width > scale) { if (this.sprite.width > scale) {
@@ -107,11 +105,11 @@ define([
this.sprite.scale.x = (this.flipX ? -scaleMult : scaleMult); this.sprite.scale.x = (this.flipX ? -scaleMult : scaleMult);


['nameSprite', 'chatSprite'].forEach(function (s, i) { ['nameSprite', 'chatSprite'].forEach(function (s, i) {
var sprite = this[s];
let sprite = this[s];
if (!sprite) if (!sprite)
return; return;


var yAdd = scale;
let yAdd = scale;
if (i == 1) { if (i == 1) {
yAdd *= -0.8; yAdd *= -0.8;
yAdd -= (this.chatter.msg.split('\r\n').length - 1) * scale * 0.8; yAdd -= (this.chatter.msg.split('\r\n').length - 1) * scale * 0.8;
@@ -128,16 +126,17 @@ define([
destroy: function () { destroy: function () {
if (this.sprite) if (this.sprite)
renderer.destroyObject(this); renderer.destroyObject(this);
if (this.nameSprite)
if (this.nameSprite) {
renderer.destroyObject({ renderer.destroyObject({
layerName: 'effects', layerName: 'effects',
sprite: this.nameSprite 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) if (c.destroy)
c.destroy(); c.destroy();
} }


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

@@ -9,7 +9,7 @@ define([
renderer, renderer,
sound sound
) { ) {
var scale = 40;
let scale = 40;


return { return {
showNames: false, showNames: false,
@@ -24,24 +24,24 @@ define([
events.on('onChangeHoverTile', this.getLocation.bind(this)); events.on('onChangeHoverTile', this.getLocation.bind(this));


//Get saved value for showNames, or use the value set above //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; this.showNames = showNames ? (showNames == 'true') : this.showNames;
}, },


getLocation: function (x, y) { 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)) if ((!o.stats) || (o.nonSelectable))
continue; continue;


var dx = Math.abs(o.x - x);
let dx = Math.abs(o.x - x);
if ((dx < 3) && (dx < closest)) { if ((dx < 3) && (dx < closest)) {
var dy = Math.abs(o.y - y);
let dy = Math.abs(o.y - y);
if ((dy < 3) && (dy < closest)) { if ((dy < 3) && (dy < closest)) {
mob = o; mob = o;
closest = Math.max(dx, dy); closest = Math.max(dx, dy);
@@ -53,16 +53,16 @@ define([
}, },


getClosest: function (x, y, maxDistance, reverse, fromMob) { 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)) if ((!o.stats) || (o.nonSelectable) || (o == window.player))
return false; return false;


var dx = Math.abs(o.x - x);
let dx = Math.abs(o.x - x);
if (dx < maxDistance) { if (dx < maxDistance) {
var dy = Math.abs(o.y - y);
let dy = Math.abs(o.y - y);
if (dy < maxDistance) if (dy < maxDistance)
return true; return true;
} }
@@ -72,35 +72,34 @@ define([
return null; return null;


list.sort(function (a, b) { 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); 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) if (!fromMob)
return list[0]; return list[0];


var fromIndex = list.firstIndex(function (l) {
let fromIndex = list.firstIndex(function (l) {
return (l.id == fromMob.id); return (l.id == fromMob.id);
}); });


if (reverse) {
if (reverse)
fromIndex = (fromIndex === 0 ? list.length : fromIndex) - 1; fromIndex = (fromIndex === 0 ? list.length : fromIndex) - 1;
} else {
else
fromIndex = (fromIndex + 1) % list.length; fromIndex = (fromIndex + 1) % list.length;
}


return list[fromIndex]; return list[fromIndex];
}, },


onRezone: function (oldZone) { 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) if (oldZone == null)
o.destroy(); o.destroy();
@@ -115,7 +114,7 @@ define([
this.dirty = true; this.dirty = true;


//Things like attacks don't have ids //Things like attacks don't have ids
var exists = null;
let exists = null;
if (obj.id != null) { if (obj.id != null) {
exists = this.objects.find(function (o) { exists = this.objects.find(function (o) {
return ((o.id == obj.id) && (!o.destroyed)); return ((o.id == obj.id) && (!o.destroyed));
@@ -128,16 +127,16 @@ define([
this.updateObject(exists, obj); this.updateObject(exists, obj);
}, },
buildObject: function (template) { buildObject: function (template) {
var obj = $.extend(true, {}, objBase);
let obj = $.extend(true, {}, objBase);


var components = template.components || [];
let components = template.components || [];
delete 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 (type == 'object') {
if (syncTypes.indexOf(p) > -1) if (syncTypes.indexOf(p) > -1)
@@ -161,12 +160,12 @@ define([


components.forEach(function (c) { components.forEach(function (c) {
//Map ids to objects //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)); return ((k.indexOf('id') == 0) && (k.length > 2));
}); });
keys.forEach(function (k) { 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) { c[newKey] = this.objects.find(function (o) {
return (o.id == value); return (o.id == value);
@@ -204,16 +203,16 @@ define([
return obj; return obj;
}, },
updateObject: function (obj, template) { updateObject: function (obj, template) {
var components = template.components || [];
let components = template.components || [];


components.forEach(function (c) { components.forEach(function (c) {
//Map ids to objects //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)); return ((k.indexOf('id') == 0) && (k.length > 2));
}); });
keys.forEach(function (k) { 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) { c[newKey] = this.objects.find(function (o) {
return (o.id == value); return (o.id == value);
@@ -233,13 +232,13 @@ define([
delete template.removeComponents; 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') if (type != 'object')
obj[p] = value; obj[p] = value;
@@ -295,11 +294,11 @@ define([
obj.setSpritePosition(); obj.setSpritePosition();
}, },
update: function () { 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) { if (o.destroyed) {
o.destroy(); o.destroy();
@@ -322,13 +321,13 @@ define([
//Set new value in localStorage for showNames //Set new value in localStorage for showNames
window.localStorage.setItem('iwd_opt_shownames', this.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)) if ((!ns) || (obj.dead))
continue; continue;




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

@@ -1,6 +1,6 @@
define([ define([
], function(
], function (
) { ) {
return { return {
@@ -8,15 +8,15 @@ define([
particles: [], particles: [],
fog: [], fog: [],


register: function(cpn) {
register: function (cpn) {
this.list.push(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) { if (l == cpn) {
list.splice(i, 1); 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.destroyed) || (!l.obj) || (l.obj.destroyed)) {
if (((l.destroyManual) && (!l.destroyManual())) || (!l.destroyManual)) { 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([ define([
'js/rendering/renderer', 'js/rendering/renderer',
'picture' 'picture'
], function(
], function (
renderer, renderer,
picture picture
) { ) {
var scale = 40;
var scaleMult = 5;
let scale = 40;
let scaleMult = 5;


return { return {
build: function(config) {
var obj = {
build: function (config) {
let obj = {
lines: [] 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: [] 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) { if (i == divisions - 1) {
ntx = tx; ntx = tx;
nty = ty; 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))) if ((config.colors) && (i == divisions - 1) && (j > (steps * 0.75)))
alpha = 1 - (j / steps); 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({ line.sprites.push(renderer.buildRectangle({
x: ~~(x / scaleMult) * scaleMult, x: ~~(x / scaleMult) * scaleMult,
y: ~~(y / scaleMult) * scaleMult, y: ~~(y / scaleMult) * scaleMult,
@@ -64,12 +64,12 @@ define([
layerName: 'effects' layerName: 'effects'
})); }));


var xx = x;
var yy = y;
let xx = x;
let yy = y;
if ((!patches[xx + '-' + yy]) && (!config.colors)) { if ((!patches[xx + '-' + yy]) && (!config.colors)) {
patches[xx + '-' + yy] = 1; patches[xx + '-' + yy] = 1;


var lightPatch = renderer.buildObject({
let lightPatch = renderer.buildObject({
sheetName: 'white', sheetName: 'white',
x: 0, x: 0,
y: 0, y: 0,
@@ -99,25 +99,25 @@ define([
return obj; 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 hex.length == 1 ? '0' + hex : hex;
}; };


return '0x' + componentToHex(r) + componentToHex(g) + componentToHex(b); 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); s.parent.removeChild(s);
}); });
}); });
} }
}; };
});
});

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

@@ -7,8 +7,8 @@ define([
objects, objects,
renderer renderer
) { ) {
var scale = 40;
var scaleMult = 5;
let scale = 40;
let scaleMult = 5;


return { return {
list: [], list: [],
@@ -18,17 +18,17 @@ define([
}, },


onGetDamage: function (msg) { onGetDamage: function (msg) {
var target = objects.objects.find(function (o) {
let target = objects.objects.find(function (o) {
return (o.id == msg.id); return (o.id == msg.id);
}); });
if (!target) if (!target)
return; 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, obj: target,
amount: msg.amount, amount: msg.amount,
x: (target.x * scale), x: (target.x * scale),
@@ -41,17 +41,17 @@ define([
heal: msg.heal heal: msg.heal
}; };


if (numberObj.event) {
if (numberObj.event)
numberObj.y += (scale / 2); numberObj.y += (scale / 2);
} else if (numberObj.heal)
else if (numberObj.heal)
numberObj.x -= scale; numberObj.x -= scale;
else else
numberObj.x += scale; numberObj.x += scale;


var text = numberObj.text;
let text = numberObj.text;
if (!numberObj.event) { 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); text = (numberObj.heal ? '+' : '') + (~~(amount * div) / div);
} }


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


render: function () { 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--; l.ttl--;


if (l.ttl == 0) { if (l.ttl == 0) {
@@ -90,7 +90,7 @@ define([
else else
l.y -= 1; l.y -= 1;


var alpha = l.ttl / l.ttlMax;
let alpha = l.ttl / l.ttlMax;


l.sprite.x = ~~(l.x / scaleMult) * scaleMult; l.sprite.x = ~~(l.x / scaleMult) * scaleMult;
l.sprite.y = ~~(l.y / scaleMult) * scaleMult; l.sprite.y = ~~(l.y / scaleMult) * scaleMult;


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

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


allowRotation: false allowRotation: false
}; };
});
});

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

@@ -2,7 +2,7 @@ define([
'particles', 'particles',
'js/rendering/particleDefaults', 'js/rendering/particleDefaults',
'js/rendering/shaders/outline' 'js/rendering/shaders/outline'
], function(
], function (
pixiParticles, pixiParticles,
particleDefaults, particleDefaults,
shaderOutline shaderOutline
@@ -15,17 +15,17 @@ define([


lastTick: null, lastTick: null,


init: function(options) {
init: function (options) {
this.r = options.r; this.r = options.r;
this.renderer = options.renderer; this.renderer = options.renderer;
this.stage = options.stage; this.stage = options.stage;
this.lastTick = Date.now(); 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; emitter.emit = true;


this.emitters.push(emitter); this.emitters.push(emitter);
@@ -33,21 +33,21 @@ define([
return emitter; return emitter;
}, },


destroyEmitter: function(emitter) {
destroyEmitter: function (emitter) {
emitter.emit = false; 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 e = emitters[i];


var visible = null;
var destroy = !e.emit;
let visible = null;
let destroy = !e.emit;
if (destroy) { if (destroy) {
if (e.particleCount > 0) { if (e.particleCount > 0) {
visible = renderer.isVisible(e.spawnPos.x, e.spawnPos.y); visible = renderer.isVisible(e.spawnPos.x, e.spawnPos.y);
@@ -71,8 +71,8 @@ define([
if (!visible) if (!visible)
continue; 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') if (e.blendMode == 'overlay')
rr.pluginName = 'picture'; rr.pluginName = 'picture';
}, this); }, this);
@@ -81,4 +81,4 @@ define([
this.lastTick = now; 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', 'pixi',
'js/rendering/shaders/outline/vert', 'js/rendering/shaders/outline/vert',
'js/rendering/shaders/outline/frag' 'js/rendering/shaders/outline/frag'
], function(
], function (
pixi, pixi,
vert, vert,
frag frag
) { ) {
var OutlineFilter = function(viewWidth, viewHeight, thickness, color) {
let OutlineFilter = function (viewWidth, viewHeight, thickness, color) {
thickness = thickness || 1; thickness = thickness || 1;
pixi.Filter.call(this, pixi.Filter.call(this,
vert, vert,
@@ -19,9 +19,8 @@ define([
this.uniforms.thickness = thickness; this.uniforms.thickness = thickness;
this.uniforms.outlineColor = new Float32Array([0, 0, 0, 1]); this.uniforms.outlineColor = new Float32Array([0, 0, 0, 1]);
this.alpha = 0; this.alpha = 0;
if (color) {
if (color)
this.color = color; this.color = color;
}
}; };


OutlineFilter.prototype = Object.create(pixi.Filter.prototype); OutlineFilter.prototype = Object.create(pixi.Filter.prototype);
@@ -29,38 +28,38 @@ define([


Object.defineProperties(OutlineFilter.prototype, { Object.defineProperties(OutlineFilter.prototype, {
color: { color: {
get: function() {
get: function () {
return pixi.utils.rgb2hex(this.uniforms.outlineColor); return pixi.utils.rgb2hex(this.uniforms.outlineColor);
}, },
set: function(value) {
set: function (value) {
pixi.utils.hex2rgb(value, this.uniforms.outlineColor); pixi.utils.hex2rgb(value, this.uniforms.outlineColor);
} }
}, },


alpha: { alpha: {
set: function(value) {
set: function (value) {
this.uniforms.alpha = value; this.uniforms.alpha = value;
} }
}, },


viewWidth: { viewWidth: {
get: function() {
get: function () {
return 1 / this.uniforms.pixelWidth; return 1 / this.uniforms.pixelWidth;
}, },
set: function(value) {
set: function (value) {
this.uniforms.pixelWidth = 1 / value; this.uniforms.pixelWidth = 1 / value;
} }
}, },


viewHeight: { viewHeight: {
get: function() {
get: function () {
return 1 / this.uniforms.pixelHeight; return 1 / this.uniforms.pixelHeight;
}, },
set: function(value) {
set: function (value) {
this.uniforms.pixelHeight = 1 / value; this.uniforms.pixelHeight = 1 / value;
} }
} }
}); });


return OutlineFilter; return OutlineFilter;
});
});

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

@@ -1,9 +1,9 @@
define([ define([


], function(
], function (


) { ) {
return `
return `
varying vec2 vTextureCoord; varying vec2 vTextureCoord;
uniform sampler2D uSampler; uniform sampler2D uSampler;


@@ -30,4 +30,4 @@ define([
gl_FragColor = vec4((ownColor.rgb + outlineColor.rgb * (1. - ownColor.a)) * resultAlpha, resultAlpha); 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([ define([
], function(
], function (
) { ) {
return ` return `
@@ -15,4 +15,4 @@ define([
vTextureCoord = aTextureCoord; vTextureCoord = aTextureCoord;
} }
`; `;
});
});

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

@@ -1,36 +1,34 @@
define([ define([
], function(
], function (
) { ) {
return { return {
pool: {}, pool: {},


clean: function() {
clean: function () {
this.pool = {}; this.pool = {};
}, },


getSprite: function(type) {
var list = this.pool[type];
getSprite: function (type) {
let list = this.pool[type];
if (!list) if (!list)
return null; return null;
else if (list.length == 0) else if (list.length == 0)
return null; 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) if (sprite.scale.x < 0)
type = 'flip' + type; type = 'flip' + type;
var list = pool[type];
if (!list) {
let list = pool[type];
if (!list)
list = pool[type] = []; list = pool[type] = [];
}


list.push(sprite); list.push(sprite);
} }
}; };
});
});

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

@@ -6,74 +6,74 @@ define([
return { return {
sheetHeight: 20, sheetHeight: 20,


'tiles': {
tiles: {
default: 0.4, default: 0.4,
max: 0.55, 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 //snow
'176': 0.55,
'184': 0.55,
'185': 0.55
176: 0.55,
184: 0.55,
185: 0.55
}, },
objects: { objects: {
default: 0.9, default: 0.9,
'50': 1
50: 1
}, },
'walls': {
walls: {
default: 0.85, default: 0.85,
max: 1, 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: [ tilesNoFlip: [
@@ -98,12 +98,11 @@ define([
return 0; return 0;
else if (tile < 448) else if (tile < 448)
return 1; return 1;
else
return 2;
return 2;
}, },


map: function (tile) { map: function (tile) {
var sheetNum;
let sheetNum;


if (tile < 192) if (tile < 192)
sheetNum = 0; sheetNum = 0;
@@ -115,9 +114,9 @@ define([
sheetNum = 2; 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) { if (tilesheet.max != null) {
alpha = alpha + (Math.random() * (alpha * 0.2)); alpha = alpha + (Math.random() * (alpha * 0.2));
alpha = Math.min(1, alpha); alpha = Math.min(1, alpha);
@@ -127,7 +126,7 @@ define([
}, },


canFlip: function (tile) { canFlip: function (tile) {
var sheetNum;
let sheetNum;


if (tile < 192) if (tile < 192)
sheetNum = 0; sheetNum = 0;
@@ -139,7 +138,7 @@ define([
sheetNum = 2; 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); return (tilesheet.indexOf(tile) == -1);
} }
}; };


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

@@ -3,7 +3,7 @@ define([
], function ( ], function (
events events
) { ) {
var resources = {
let resources = {
spriteNames: [ spriteNames: [
'charas', 'charas',
'tiles', 'tiles',
@@ -40,7 +40,7 @@ define([
}, this); }, this);


this.spriteNames.forEach(function (s) { this.spriteNames.forEach(function (s) {
var sprite = {
let sprite = {
image: (new Image()), image: (new Image()),
ready: false ready: false
}; };
@@ -53,8 +53,8 @@ define([
onSprite: function (sprite) { onSprite: function (sprite) {
sprite.ready = true; 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) if (this.sprites[s].ready)
readyCount++; readyCount++;
} }


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

@@ -28,22 +28,22 @@ define([


update: function (x, y) { update: function (x, y) {
this.sounds.forEach(function (s) { this.sounds.forEach(function (s) {
var dx = Math.abs(s.x - x);
let dx = Math.abs(s.x - x);
if (dx > 10) { if (dx > 10) {
if (s.sound) if (s.sound)
s.sound.volume(0); s.sound.volume(0);
return; return;
} }
var dy = Math.abs(s.y - y);
let dy = Math.abs(s.y - y);
if (dy > 10) { if (dy > 10) {
if (s.sound) if (s.sound)
s.sound.volume(0); s.sound.volume(0);
return; return;
} }


var dist = 10 - Math.max(dx, dy);
let dist = 10 - Math.max(dx, dy);
dist = (dist * dist) / 100; dist = (dist * dist) / 100;
var volume = 0.3 * dist;
let volume = 0.3 * dist;


if (!s.sound) { if (!s.sound) {
s.sound = new Howl({ s.sound = new Howl({
@@ -59,7 +59,7 @@ define([
}, },


addSound: function (file, x, y) { addSound: function (file, x, y) {
var sound = {
let sound = {
file: file, file: file,
x: x, x: x,
y: y, y: y,


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

@@ -1,19 +1,19 @@
define([ define([
'js/resources', 'js/resources',
'js/rendering/tileOpacity' 'js/rendering/tileOpacity'
], function(
], function (
resources, resources,
tileOpacity 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 { return {
buildSprite: function(layers, maps, opacities) {
buildSprite: function (layers, maps, opacities) {
width = maps[0].length; width = maps[0].length;
height = maps[0][0].length; height = maps[0][0].length;


@@ -34,41 +34,40 @@ define([
return canvas[0]; 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) if (!map)
continue; 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) if (cell == 0)
continue; continue;


cell--; 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) {
if (tileO[cell]) if (tileO[cell])
ctx.globalAlpha = tileO[cell]; ctx.globalAlpha = tileO[cell];
else else
ctx.globalAlpha = opacity; ctx.globalAlpha = opacity;
}
else
} else
ctx.globalAlpha = opacity; ctx.globalAlpha = opacity;


if (random() > 0.5) { if (random() > 0.5) {
@@ -83,8 +82,7 @@ define([
tileSize, tileSize,
tileSize tileSize
); );
}
else {
} else {
ctx.save(); ctx.save();
ctx.scale(-1, 1); ctx.scale(-1, 1);
ctx.drawImage( ctx.drawImage(
@@ -105,4 +103,4 @@ define([
} }
} }
}; };
});
});

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

@@ -2,18 +2,18 @@ window.addons = {
addons: [], addons: [],
events: null, events: null,


register: function(addon) {
register: function (addon) {
this.addons.push(addon); this.addons.push(addon);


if (this.events) if (this.events)
addon.init(this.events); addon.init(this.events);
}, },


init: function(events) {
init: function (events) {
this.events = events; this.events = events;


this.addons.forEach(function(m) {
this.addons.forEach(function (m) {
m.init(this.events); m.init(this.events);
}, this); }, this);
} }
};
};

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

@@ -5,11 +5,11 @@ define([
io, io,
events events
) { ) {
var client = {
let client = {
doneConnect: false, doneConnect: false,


init: function (onReady) { init: function (onReady) {
var tType = 'websocket';
let tType = 'websocket';
if (window.location.href.indexOf('polling') > -1) if (window.location.href.indexOf('polling') > -1)
tType = 'polling'; tType = 'polling';


@@ -49,9 +49,9 @@ define([
//If we get objects, self needs to be first //If we get objects, self needs to be first
// otherwise we might create the object (setting his position or attack animation) // otherwise we might create the object (setting his position or attack animation)
// before instantiating it // before instantiating it
var oList = response.onGetObject;
let oList = response.onGetObject;
if (oList) { if (oList) {
var prepend = oList.filter(function (o) {
let prepend = oList.filter(function (o) {
return o.self; return o.self;
}); });
oList.spliceWhere(function (o) { oList.spliceWhere(function (o) {
@@ -63,7 +63,7 @@ define([
} }


for (var e in response) { 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) //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) { r.sort(function (a, b) {
@@ -71,8 +71,7 @@ define([
return 1; return 1;
else if (b.performLast) else if (b.performLast)
return -1; return -1;
else
return 0;
return 0;
}); });


r.forEach(function (o) { r.forEach(function (o) {


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

@@ -3,15 +3,15 @@ define([
], function ( ], function (


) { ) {
var events = {
let events = {
events: {}, events: {},
queue: [], queue: [],
on: function (event, callback) { on: function (event, callback) {
var list = this.events[event] || (this.events[event] = []);
let list = this.events[event] || (this.events[event] = []);
list.push(callback); 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) if (q.event != event)
continue; continue;


@@ -32,9 +32,9 @@ define([
}); });
}, },
off: function (event, callback) { 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) { if (list[i] == callback) {
list.splice(i, 1); list.splice(i, 1);
i--; i--;
@@ -46,9 +46,9 @@ define([
delete this.events[event]; delete this.events[event];
}, },
emit: function (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) { if (!list) {
this.queue.push({ this.queue.push({
event: event, event: event,
@@ -58,9 +58,9 @@ define([
return; 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); l.apply(null, args);
} }
} }


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

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

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

@@ -60,8 +60,8 @@ define([


build: function (type, options) { build: function (type, options) {
//Don't make doubles? //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) if (el.length > 0)
return; return;


@@ -71,7 +71,7 @@ define([
require([this.root + 'ui/templates/' + type + '/' + type], this.onGetTemplate.bind(this, options)); require([this.root + 'ui/templates/' + type + '/' + type], this.onGetTemplate.bind(this, options));
}, },
onGetTemplate: function (options, template) { onGetTemplate: function (options, template) {
var ui = _.create(uiBase, template);
let ui = _.create(uiBase, template);
ui.setOptions(options); ui.setOptions(options);
ui.render(); ui.render();
ui.el.data('ui', ui); ui.el.data('ui', ui);
@@ -102,10 +102,10 @@ define([
}, },


update: function () { 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) if (u.update)
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', 'html!ui/templates/announcements/template',
'css!ui/templates/announcements/styles', 'css!ui/templates/announcements/styles',
'html!ui/templates/announcements/templateLine' 'html!ui/templates/announcements/templateLine'
], function(
], function (
events, events,
template, template,
styles, styles,
@@ -15,19 +15,19 @@ define([
message: null, message: null,
maxTtl: 160, maxTtl: 160,


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


onGetAnnouncement: function(e) {
onGetAnnouncement: function (e) {
this.clearMessage(); this.clearMessage();


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


var html = templateLine
let html = templateLine
.replace('$MSG$', e.msg); .replace('$MSG$', e.msg);


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


if (e.type) if (e.type)
@@ -43,8 +43,8 @@ define([
}; };
}, },


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


@@ -54,13 +54,13 @@ define([
this.clearMessage(); this.clearMessage();
}, },


clearMessage: function() {
var message = this.message;
clearMessage: function () {
let message = this.message;
if (!message) if (!message)
return; return;


this.message = null; this.message = null;
message.el.remove(); message.el.remove();
} }
}
});
};
});

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

@@ -9,7 +9,7 @@ define([
styles, styles,
templateBuff templateBuff
) { ) {
var icons = {
let icons = {
stunned: [4, 0], stunned: [4, 0],
regenHp: [3, 1], regenHp: [3, 1],
regenMana: [4, 1], regenMana: [4, 1],
@@ -30,15 +30,15 @@ define([
}, },


onGetBuff: function (buff) { onGetBuff: function (buff) {
var icon = icons[buff.type];
let icon = icons[buff.type];
if (!icon) if (!icon)
return; 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') .find('.inner')
.css({ .css({
background: 'url(../../../images/statusIcons.png) ' + imgX + 'px ' + imgY + 'px' background: 'url(../../../images/statusIcons.png) ' + imgX + 'px ' + imgY + 'px'
@@ -48,12 +48,12 @@ define([
}, },


onRemoveBuff: function (buff) { onRemoveBuff: function (buff) {
var el = this.icons[buff.id];
let el = this.icons[buff.id];
if (!el) if (!el)
return; return;


el.remove(); el.remove();
delete this.icons[buff.id]; delete this.icons[buff.id];
} }
}
};
}); });

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

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


onPlayClick: function () { onPlayClick: function () {
var char = this.selected;
let char = this.selected;
if (!char) if (!char)
return; return;


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


this.el.removeClass('disabled'); this.el.removeClass('disabled');


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


characters characters
@@ -80,14 +80,14 @@ define([
return (b.level - a.level); return (b.level - a.level);
}) })
.forEach(function (c, i) { .forEach(function (c, i) {
var name = c.name;
let name = c.name;
if (c.level != null) 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); .replace('$NAME$', name);


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


li.on('click', this.onCharacterClick.bind(this, c.name)); li.on('click', this.onCharacterClick.bind(this, c.name));
@@ -99,11 +99,11 @@ define([
onCharacterClick: function (name, e) { onCharacterClick: function (name, e) {
this.el.addClass('disabled'); this.el.addClass('disabled');


var el = $(e.target);
let el = $(e.target);
el.parent().find('.selected').removeClass('selected'); el.parent().find('.selected').removeClass('selected');
el.addClass('selected'); el.addClass('selected');


var charInfo = this.characterInfo[name];
let charInfo = this.characterInfo[name];
if (charInfo) { if (charInfo) {
this.onGetCharacter(name, charInfo); this.onGetCharacter(name, charInfo);


@@ -122,13 +122,13 @@ define([
onGetCharacter: function (name, result) { onGetCharacter: function (name, result) {
this.find('.button').removeClass('disabled'); 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); spirteX = -(spirteX * 8);
spriteY = -(spriteY * 8); spriteY = -(spriteY * 8);


var spritesheet = result.sheetName;
let spritesheet = result.sheetName;
if (spritesheet == 'characters') if (spritesheet == 'characters')
spritesheet = '../../../images/characters.png'; spritesheet = '../../../images/characters.png';


@@ -137,7 +137,7 @@ define([
.show(); .show();


this.find('.name').html(name); this.find('.name').html(name);
var stats = result.components.find(function (c) {
let stats = result.components.find(function (c) {
return (c.type == 'stats'); return (c.type == 'stats');
}); });
if (stats) { if (stats) {
@@ -146,16 +146,15 @@ define([
' ' + ' ' +
result.class[0].toUpperCase() + result.class.substr(1) result.class[0].toUpperCase() + result.class.substr(1)
); );
} else {
} else
this.find('.class').html(''); this.find('.class').html('');
}


this.el.removeClass('disabled'); this.el.removeClass('disabled');


this.characterInfo[name] = result; this.characterInfo[name] = result;
this.selected = name; this.selected = name;


var prophecies = result.components.find(function (c) {
let prophecies = result.components.find(function (c) {
return (c.type == 'prophecies'); return (c.type == 'prophecies');
}); });


@@ -186,7 +185,7 @@ define([
this.find('.btnDelete') this.find('.btnDelete')
.removeClass('deleting') .removeClass('deleting')
.addClass('deleting') .addClass('deleting')
.html('delete (' + (4 - this.deleteCount) + ')')
.html('delete (' + (4 - this.deleteCount) + ')');


return; return;
} }


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

@@ -3,7 +3,7 @@ define([
'html!ui/templates/context/template', 'html!ui/templates/context/template',
'css!ui/templates/context/styles', 'css!ui/templates/context/styles',
'html!ui/templates/context/templateItem' 'html!ui/templates/context/templateItem'
], function(
], function (
events, events,
template, template,
styles, styles,
@@ -13,7 +13,7 @@ define([
tpl: template, tpl: template,
modal: true, modal: true,


postRender: function() {
postRender: function () {
this.onEvent('onContextMenu', this.onContextMenu.bind(this)); this.onEvent('onContextMenu', this.onContextMenu.bind(this));
this.onEvent('onHideContextMenu', this.onMouseDown.bind(this)); this.onEvent('onHideContextMenu', this.onMouseDown.bind(this));
this.onEvent('mouseDown', this.onMouseDown.bind(this)); this.onEvent('mouseDown', this.onMouseDown.bind(this));
@@ -21,17 +21,17 @@ define([
$('.ui-container').on('mouseup', this.onMouseDown.bind(this)); $('.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(); .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); .replace('$TEXT$', text);


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


if (c.callback) if (c.callback)
@@ -48,16 +48,16 @@ define([
.show(); .show();
}, },


onClick: function(index, callback) {
onClick: function (index, callback) {
this.el.hide(); this.el.hide();
callback(); callback();
}, },


onMouseDown: function(e) {
onMouseDown: function (e) {
if ((!this.el.is(':visible')) || (e.cancel) || (e.button == 2)) if ((!this.el.is(':visible')) || (e.cancel) || (e.button == 2))
return; return;


this.el.hide(); this.el.hide();
} }
}
});
};
});

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

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


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


var pos = {
let pos = {
x: e.clientX + 25, x: e.clientX + 25,
y: e.clientY y: e.clientY
}; };


var text = el.attr('tooltip');
let text = el.attr('tooltip');


events.emit('onShowTooltip', text, el[0], pos); events.emit('onShowTooltip', text, el[0], pos);
$('.uiTooltips .tooltip').addClass('bright'); $('.uiTooltips .tooltip').addClass('bright');
}, },
onProphecyUnhover: function (e) { onProphecyUnhover: function (e) {
var el = $(e.currentTarget);
let el = $(e.currentTarget);
events.emit('onHideTooltip', el[0]); events.emit('onHideTooltip', el[0]);
}, },
onProphecyClick: function (e) { 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')) { if (el.hasClass('active')) {
this.prophecies.spliceWhere(function (p) { this.prophecies.spliceWhere(function (p) {
@@ -143,32 +143,32 @@ define([
}, },


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


var pos = {
let pos = {
x: e.clientX + 25, x: e.clientX + 25,
y: e.clientY 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]; })[this.class];


events.emit('onShowTooltip', text, el[0], pos, 200); events.emit('onShowTooltip', text, el[0], pos, 200);
$('.uiTooltips .tooltip').addClass('bright'); $('.uiTooltips .tooltip').addClass('bright');
}, },
onClassUnhover: function (e) { onClassUnhover: function (e) {
var el = $(e.currentTarget);
let el = $(e.currentTarget);
events.emit('onHideTooltip', el[0]); events.emit('onHideTooltip', el[0]);
}, },
changeClass: function (e) { 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)); el.html(newClass[0].toUpperCase() + newClass.substr(1));


@@ -178,9 +178,9 @@ define([
}, },


changeCostume: function (e) { changeCostume: function (e) {
var el = $(e.target);
let el = $(e.target);


var spriteList = this.classSprites;
let spriteList = this.classSprites;
if (!spriteList) if (!spriteList)
return; return;


@@ -193,12 +193,12 @@ define([
}, },


setSprite: function () { 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') this.find('.sprite')
.css('background', 'url("' + spritesheet + '") ' + spirteX + 'px ' + spriteY + 'px'); .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) { onDeath: function (event) {
if (!event.source) {
if (!event.source)
this.find('.msg').html('you are dead'); 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('.msg').html('you were killed by [ <div class="inner">' + event.source + '</div> ]');
this.find('.penalty') this.find('.penalty')
.html('you lost ' + event.xpLoss + ' experience') .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', 'js/system/client',
'html!ui/templates/dialogue/template', 'html!ui/templates/dialogue/template',
'css!ui/templates/dialogue/styles' 'css!ui/templates/dialogue/styles'
], function(
], function (
events, events,
client, client,
template, template,
@@ -15,13 +15,13 @@ define([


centeredX: true, centeredX: true,


postRender: function() {
postRender: function () {
this.onEvent('onGetDialogue', this.onGetDialogue.bind(this)); this.onEvent('onGetDialogue', this.onGetDialogue.bind(this));
this.onEvent('onRemoveDialogue', this.onRemoveDialogue.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); return (t.src == msg.src);
}); });


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


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


this.setText(); 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; text += t.msg;
if (i < this.text.length - 1) if (i < this.text.length - 1)
@@ -49,11 +49,11 @@ define([
this.find('.textBox').html(text); this.find('.textBox').html(text);


if (text != '') {
if (text != '')
this.show(); this.show();
}
else else
this.hide(); 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/template',
'html!ui/templates/events/templateEvent', 'html!ui/templates/events/templateEvent',
'css!ui/templates/events/styles' 'css!ui/templates/events/styles'
], function(
], function (
client, client,
events, events,
tpl, tpl,
@@ -18,7 +18,7 @@ define([


container: '.right', container: '.right',


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


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


onRezone: function() {
onRezone: function () {
this.list = []; this.list = [];
this.el.find('.list').empty(); 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); return (l.id == id);
}); });


@@ -41,8 +41,8 @@ define([
l.el.remove(); 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); return (l.id == event.id);
}); });
if (exists) { if (exists) {
@@ -51,13 +51,13 @@ define([
return; return;
} }


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


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


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


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


event event
.sort(function(a, b) {
.sort(function (a, b) {
a = $(a).hasClass('active') ? 1 : 0; a = $(a).hasClass('active') ? 1 : 0;
b = $(b).hasClass('active') ? 1 : 0; b = $(b).hasClass('active') ? 1 : 0;
return b - a; return b - a;
@@ -79,8 +79,8 @@ define([
.appendTo(container); .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); 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); return (l.id == id);
}); });


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


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

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

@@ -3,7 +3,7 @@ define([
'js/system/client', 'js/system/client',
'html!ui/templates/fame/template', 'html!ui/templates/fame/template',
'css!ui/templates/fame/styles' 'css!ui/templates/fame/styles'
], function(
], function (
events, events,
client, client,
template, template,
@@ -16,8 +16,8 @@ define([
centeredX: true, centeredX: true,
modal: 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', 'js/system/events',
'html!ui/templates/help/template', 'html!ui/templates/help/template',
'css!ui/templates/help/styles' 'css!ui/templates/help/styles'
], function(
], function (
events, events,
template, template,
styles styles
@@ -13,18 +13,17 @@ define([


modal: true, modal: true,


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


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


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


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

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

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


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


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


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


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


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


el.toggleClass('selected'); 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); return (p == prophecyName);
}, this); }, this);


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


if (!this.prophecyFilter) { if (!this.prophecyFilter) {
var prophecies = window.player.prophecies;
let prophecies = window.player.prophecies;
this.prophecyFilter = prophecies ? prophecies.list : []; this.prophecyFilter = prophecies ? prophecies.list : [];
this.prophecyFilter = $.extend(true, [], this.prophecyFilter); this.prophecyFilter = $.extend(true, [], this.prophecyFilter);
} }
@@ -119,30 +119,30 @@ define([
if (!keepOffset) { if (!keepOffset) {
this.offset = 0; 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); return (r.name == window.player.name);
}, this); }, this);
if (foundIndex != -1) if (foundIndex != -1)
this.offset = ~~(foundIndex / this.pageSize); 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; 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 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); .appendTo(container);


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


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


if (shown) { if (shown) {
this.find('.prophecy[prophecy]').removeClass('selected'); this.find('.prophecy[prophecy]').removeClass('selected');
var prophecies = window.player.prophecies;
let prophecies = window.player.prophecies;
prophecies = prophecies ? prophecies.list : []; prophecies = prophecies ? prophecies.list : [];
prophecies.forEach(function (p) { prophecies.forEach(function (p) {
this.find('.prophecy[prophecy="' + p + '"]').addClass('selected'); 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) { redirect: function (e) {
var location = $(e.target).attr('location');
let location = $(e.target).attr('location');
window.open(location, '_blank'); window.open(location, '_blank');
}, },




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

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


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


@@ -63,12 +63,12 @@ define([
this.toggle(); this.toggle();
this.item = msg.item; 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) if (item.material)
spritesheet = '../../../images/materials.png'; spritesheet = '../../../images/materials.png';
else if (item.quest) else if (item.quest)
@@ -76,7 +76,7 @@ define([
else if (item.type == 'consumable') else if (item.type == 'consumable')
spritesheet = '../../../images/consumables.png'; spritesheet = '../../../images/consumables.png';


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


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


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

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

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


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

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

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


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


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


onClickFilter: function (e) { onClickFilter: function (e) {
var el = $(e.currentTarget);
let el = $(e.currentTarget);
el.toggleClass('active'); 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') if (method == 'show')
this.find('.list').addClass(filter); this.find('.list').addClass(filter);
else else
this.find('.list').removeClass(filter); this.find('.list').removeClass(filter);


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


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


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


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


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


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


messages.forEach(function (m) { messages.forEach(function (m) {
var message = m.message;
let message = m.message;
if (m.item) { 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>'; 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); .appendTo(container);


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


if (m.type) { 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 (isChannel) {
if (this.find('.filter[filter="' + m.type + '"]').hasClass('active')) if (this.find('.filter[filter="' + m.type + '"]').hasClass('active'))
el.show(); el.show();
@@ -182,7 +181,7 @@ define([
if (!item) if (!item)
return; return;


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


this.el.removeClass('typing'); this.el.removeClass('typing');


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


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


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


var textbox = this.find('input');
var val = textbox.val()
let textbox = this.find('input');
let val = textbox.val()
.split('<') .split('<')
.join('&lt;') .join('&lt;')
.split('>') .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) if (!list.length)
list = [list]; list = [list];


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


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


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


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


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


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


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


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

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


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


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

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

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


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


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


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

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

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


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


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


var zone = m.zone;
let zone = m.zone;
if (m.id == window.player.serverId) { if (m.id == window.player.serverId) {
party.forEach(function (p) { 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'); el.removeClass('differentZone');


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


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


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


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


if ((stats.hp != null) && (stats.hpMax != null)) { 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 + '%'); el.find('.statHp').css('width', hpPercentage + '%');
} }


if ((stats.mana != null) && (stats.manaMax != null)) { 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 + '%'); el.find('.statMana').css('width', manaPercentage + '%');
} }


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


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


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


this.party = party; this.party = party;
@@ -115,17 +114,17 @@ define([
if (p == window.player.serverId) if (p == window.player.serverId)
return; 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('$NAME$', name)
.replace('$LEVEL$', level); .replace('$LEVEL$', level);


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


//Find stats //Find stats
var memberObj = objects.objects.find(function (o) {
let memberObj = objects.objects.find(function (o) {
return (o.serverId == p); return (o.serverId == p);
}); });
if ((memberObj) && (memberObj.stats)) if ((memberObj) && (memberObj.stats))
@@ -162,14 +161,14 @@ define([
if (this.invite) if (this.invite)
this.destroyInvite(); 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); .replace('$NAME$', sourcePlayer.name);


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

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

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


mappings: { 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 //hacks for mac cmd key
'17': 'ctrl',
'224': 'ctrl',
'91': 'ctrl',
'93': 'ctrl'
17: 'ctrl',
224: 'ctrl',
91: 'ctrl',
93: 'ctrl'
}, },


mouse: { mouse: {
@@ -54,9 +54,8 @@ define([
}, },


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


this.keys = {}; this.keys = {};
}, },
@@ -69,27 +68,24 @@ define([
this.mappings[charCode] || this.mappings[charCode] ||
String.fromCharCode(charCode).toLowerCase() String.fromCharCode(charCode).toLowerCase()
); );

}, },


isKeyDown: function (key, noConsume) { isKeyDown: function (key, noConsume) {
var down = this.keys[key];
let down = this.keys[key];
if (down != null) { if (down != null) {
if (noConsume) if (noConsume)
return true; 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) { getAxis: function (name) {
var axis = this.axes[name];
let axis = this.axes[name];
if (!axis) if (!axis)
return 0; return 0;


var result = 0;
let result = 0;


for (var i = 0; i < axis.negative.length; i++) { for (var i = 0; i < axis.negative.length; i++) {
if (this.keys[axis.negative[i]]) { if (this.keys[axis.negative[i]]) {
@@ -119,7 +115,7 @@ define([
if ((e.keyCode == 9) || (e.keyCode == 8) || (e.keyCode == 122)) if ((e.keyCode == 9) || (e.keyCode == 8) || (e.keyCode == 122))
e.preventDefault(); e.preventDefault();


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


if (this.keys[key] != null) if (this.keys[key] != null)
this.keys[key] = 2; this.keys[key] = 2;
@@ -140,7 +136,7 @@ define([
if (e.target != document.body) if (e.target != document.body)
return; return;


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


delete this.keys[key]; delete this.keys[key];


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


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


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


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




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

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


this.renderers.clear.call(this); 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) { links.forEach(function (l) {
var linked = (
let linked = (
nodes.find(function (n) { nodes.find(function (n) {
return (n.id == l.from.id); return (n.id == l.from.id);
}).selected && }).selected &&
@@ -120,7 +120,7 @@ define([


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


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


renderers: { renderers: {
clear: function () { 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); this.ctx.clearRect(0, 0, this.size.w, this.size.h);


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


node: function (node) { 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)) if (((!node.stats) || (Object.keys(node.stats).length == 0)) && (!node.spiritStart))
color = 0; color = 0;


@@ -178,15 +178,15 @@ define([
'#44cb95', '#44cb95',
'#fafcfc' '#fafcfc'
])[color]; ])[color];
var size = ([
let size = ([
constants.blockSize, constants.blockSize,
constants.blockSize * 2, constants.blockSize * 2,
constants.blockSize * 3 constants.blockSize * 3
])[node.size]; ])[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)) if ((l.from.id != node.id) && (l.to.id != node.id))
return false; return false;


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


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

}, },


line: function (fromNode, toNode, linked) { 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) { fromNode = this.data.nodes.find(function (n) {
return (n.id == fromNode.id); return (n.id == fromNode.id);
@@ -240,11 +239,11 @@ define([
return (n.id == toNode.id); 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)) if ((!linked) && (!fromNode.selected) && (!toNode.selected))
this.ctx.globalAlpha = 0.25; this.ctx.globalAlpha = 0.25;
@@ -271,12 +270,12 @@ define([
y: pos.y y: pos.y
}; };


var cell = {
let cell = {
x: ~~((this.pos.x + this.mouse.x) / constants.gridSize), x: ~~((this.pos.x + this.mouse.x) / constants.gridSize),
y: ~~((this.pos.y + this.mouse.y) / 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 ( return (
(n.pos.x == cell.x) && (n.pos.x == cell.x) &&
(n.pos.y == cell.y) (n.pos.y == cell.y)
@@ -284,7 +283,7 @@ define([
}); });


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


var text = Object.keys(node.stats)
let text = Object.keys(node.stats)
.map(function (s) { .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) if (percentageStats.indexOf(s) > -1)
statValue += '%'; 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.x += (this.panOrigin.x - e.raw.clientX) * scrollSpeed;
this.pos.y += (this.panOrigin.y - e.raw.clientY) * scrollSpeed; this.pos.y += (this.panOrigin.y - e.raw.clientY) * scrollSpeed;
@@ -399,7 +398,7 @@ define([
}, },


onGetPassivePoints: function (points) { onGetPassivePoints: function (points) {
var el = this.find('.points')
let el = this.find('.points')
.html('Points Available: ' + 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/template',
'html!ui/templates/progressBar/templateBar', 'html!ui/templates/progressBar/templateBar',
'css!ui/templates/progressBar/styles' 'css!ui/templates/progressBar/styles'
], function(
], function (
events, events,
client, client,
tpl, tpl,
@@ -16,24 +16,24 @@ define([


bars: [], bars: [],


postRender: function() {
postRender: function () {
this.onEvent('onShowProgress', this.onShowProgress.bind(this)); 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); return (b.text == text);
}); });


if (bar) { if (bar) {
if (percentage >= 100) { if (percentage >= 100) {
bar.el.remove(); 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 + '%'); bar.el.find('.bar').css('width', percentage + '%');
}
else if (percentage < 100) {
} else if (percentage < 100) {
bar = $(tplBar).appendTo(this.el); bar = $(tplBar).appendTo(this.el);
bar.find('.bar').css('width', percentage + '%'); bar.find('.bar').css('width', percentage + '%');
bar.find('.text').html(text); 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) { 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('$ZONE$', quest.zoneName)
.replace('$NAME$', quest.name) .replace('$NAME$', quest.name)
.replace('$DESCRIPTION$', quest.description) .replace('$DESCRIPTION$', quest.description)
.replace('$REWARD$', quest.xp + ' xp'); .replace('$REWARD$', quest.xp + ' xp');


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


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


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


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


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


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


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


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

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

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


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


this.find('.info .heading-bottom').html(''); this.find('.info .heading-bottom').html('');
this.find('.info .description').html(''); this.find('.info .description').html('');
@@ -34,15 +34,15 @@ define([
else else
this.find('.heading-bottom').html('select a faction to see more info'); 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) { list.forEach(function (l) {
if (l.noGainRep) if (l.noGainRep)
return; 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); .appendTo(elList);


el el
@@ -57,20 +57,20 @@ define([
this.find('.info .heading-bottom').html(faction.name.toLowerCase()); this.find('.info .heading-bottom').html(faction.name.toLowerCase());
this.find('.info .description').html(faction.description.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('.bar-outer').show();


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


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


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


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


if (shown) { if (shown) {
this.build(); this.build();


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

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


clickAction: function (e) { clickAction: function (e) {
var el = $(e.currentTarget);
let el = $(e.currentTarget);
this.find('.col-btn').removeClass('selected'); 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; this.action = action;


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


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


this.getMaterials(this.item); 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) if ((result.item.power || 0) < 3)
augment.removeClass('disabled'); augment.removeClass('disabled');
else else
@@ -155,19 +155,19 @@ define([
this.find('[action="augment"]').addClass('selected'); this.find('[action="augment"]').addClass('selected');
this.action = 'augment'; 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) if ((msg.item.power || 0) < 3)
augment.removeClass('disabled'); augment.removeClass('disabled');


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


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


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


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


if (result.materials) { if (result.materials) {
var material = result.materials[0];
let material = result.materials[0];
if (material) { 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); return (i.name == material.name);
}); });
if (hasMaterials) { if (hasMaterials) {
@@ -239,10 +239,10 @@ define([
drawItem: function (container, item, redQuantity) { drawItem: function (container, item, redQuantity) {
container.find('.icon').hide(); 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) if (item.material)
spritesheet = '../../../images/materials.png'; spritesheet = '../../../images/materials.png';
else if (item.quest) else if (item.quest)
@@ -250,7 +250,7 @@ define([
else if (item.type == 'consumable') else if (item.type == 'consumable')
spritesheet = '../../../images/consumables.png'; spritesheet = '../../../images/consumables.png';


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


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


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


var ttPos = null;
let ttPos = null;


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


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

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


this.spells = spells; 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); .replace('$HOTKEY$', hotkey);


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


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


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


onShowTooltip: function (el, spell) { onShowTooltip: function (el, spell) {
var pos = el.offset();
let pos = el.offset();
pos = { pos = {
x: pos.left + 56, x: pos.left + 56,
y: pos.top + el.height() + 16 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')); return ((v != 'damage') && (v != 'healing'));
}).map(function (v) { }).map(function (v) {
return v + ': ' + spell.values[v]; return v + ': ' + spell.values[v];
}).join('<br />'); }).join('<br />');


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


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


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


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


var spells = this.spells;
let spells = this.spells;
if (!spells) if (!spells)
return; 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'); el.removeClass('no-mana');
if (spell.manaCost > mana) if (spell.manaCost > mana)
el.addClass('no-mana'); el.addClass('no-mana');
@@ -126,14 +126,14 @@ define([
}, },


update: function () { update: function () {
var spells = this.spells;
let spells = this.spells;
if (!spells) if (!spells)
return; 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) { if (!spell.ttl) {
this.el.children('div').eq(i).find('.cooldown').css({ this.el.children('div').eq(i).find('.cooldown').css({
@@ -142,8 +142,8 @@ define([
continue; 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) { if (width <= 0) {
delete spell.ttl; delete spell.ttl;
width = 0; 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 () { build: function () {
var container = this.el.find('.grid')
let container = this.el.find('.grid')
.empty(); .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) if (remainder == 0)
startNoPad--; startNoPad--;
startNoPad *= 8; 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); .appendTo(container);


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


var ttPos = null;
let ttPos = null;


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


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


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


if (this.shown) if (this.shown)
@@ -184,10 +181,9 @@ define([
}, },
onDestroyStashItems: function (itemIds) { onDestroyStashItems: function (itemIds) {
itemIds.forEach(function (id) { 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.hideTooltip();
}


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


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

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


modal: true, modal: true,


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


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


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


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


this.find('.name').html(dialogue.from); this.find('.name').html(dialogue.from);
this.find('.msg').html('"' + dialogue.msg + '"'); 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) $(html)
.appendTo(options) .appendTo(options)
@@ -52,7 +51,7 @@ define([
this.center(true, false); this.center(true, false);
}, },


onReply: function(option) {
onReply: function (option) {
client.request({ client.request({
cpn: 'player', cpn: 'player',
method: 'performAction', 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) { 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 //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) // target.player (only the logged-in player has a player component)
if ((e.button != 2) || (!target) || (!target.dialogue) || (target == window.player) || (target.prophecies)) if ((e.button != 2) || (!target) || (!target.dialogue) || (target == window.player) || (target.prophecies))
return; return;


var context = [
let context = [
target.name, target.name,
'----------', { '----------', {
text: 'talk', text: 'talk',
@@ -54,13 +54,13 @@ define([
this.lastLevel = null; this.lastLevel = null;
this.el.hide(); this.el.hide();
} else { } else {
var el = this.el;
let el = this.el;
el.find('.infoName').html(target.name); el.find('.infoName').html(target.name);
el.find('.infoLevel') el.find('.infoLevel')
.html('(' + target.stats.values.level + ')') .html('(' + target.stats.values.level + ')')
.removeClass('high-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) if (crushing)
el.find('.infoLevel').addClass('high-level'); el.find('.infoLevel').addClass('high-level');


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


buildBar: function (barIndex, value, max) { 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('[class^="stat"]').css('width', w + '%');


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


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


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


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


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


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

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

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


var values = mob.stats.values;
let values = mob.stats.values;
this.lastHp = values.hp; this.lastHp = values.hp;
this.lastHpMax = values.hpMax; 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) if (mob.stats.values.level - 5 >= window.player.stats.values.level)
html = '<font class="color-red">' + html + '</font>'; html = '<font class="color-red">' + html + '</font>';
if (mob.aggro) { if (mob.aggro) {
@@ -45,7 +45,7 @@ define([
}, },


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


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

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

@@ -11,7 +11,7 @@ define([
tplTooltip, tplTooltip,
statTranslations statTranslations
) { ) {
var percentageStats = [
let percentageStats = [
'addCritChance', 'addCritChance',
'addCritMultiplier', 'addCritMultiplier',
'addAttackCritChance', 'addAttackCritChance',
@@ -67,12 +67,12 @@ define([
onShowItemTooltip: function (item, pos, compare, bottomAlign, shiftDown) { onShowItemTooltip: function (item, pos, compare, bottomAlign, shiftDown) {
this.item = item; 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 ((compare) && (shiftDown)) {
if (!item.eq) { if (!item.eq) {
var compareStats = compare.stats;
let compareStats = compare.stats;
for (var s in tempStats) { for (var s in tempStats) {
if (compareStats[s]) { if (compareStats[s]) {
var delta = tempStats[s] - compareStats[s]; var delta = tempStats[s] - compareStats[s];
@@ -84,9 +84,8 @@ define([
tempStats[s] = '+' + tempStats[s]; tempStats[s] = '+' + tempStats[s];
} }
for (var s in compareStats) { for (var s in compareStats) {
if (!tempStats[s]) {
if (!tempStats[s])
tempStats[s] = -compareStats[s]; tempStats[s] = -compareStats[s];
}
} }
} }
} else { } else {
@@ -103,21 +102,21 @@ define([


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


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


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


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


if (compare) { if (compare) {
if (row.indexOf('-') > -1) if (row.indexOf('-') > -1)
@@ -140,37 +139,36 @@ define([
return 1; return 1;
else if ((a.indexOf('enchanted') == -1) && (b.indexOf('enchanted') > -1)) else if ((a.indexOf('enchanted') == -1) && (b.indexOf('enchanted') > -1))
return -1; return -1;
else
return 0;
return 0;
}) })
.join(''); .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) if (percentageStats.indexOf(stat) > -1)
value += '%'; value += '%';
else if ((stat.indexOf('element') == 0) && (stat.indexOf('Resist') == -1)) else if ((stat.indexOf('element') == 0) && (stat.indexOf('Resist') == -1))
value += '%'; value += '%';


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


var spritesheet = item.spritesheet || '../../../images/items.png';
let spritesheet = item.spritesheet || '../../../images/items.png';
if (item.material) if (item.material)
spritesheet = '../../../images/materials.png'; spritesheet = '../../../images/materials.png';
else if (item.quest) else if (item.quest)
@@ -85,8 +85,8 @@ define([
spritesheet = '../../../images/characters.png'; 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 itemEl
.data('item', item) .data('item', item)
@@ -103,14 +103,14 @@ define([
itemEl.find('.quantity').html('EQ'); itemEl.find('.quantity').html('EQ');


if (action == 'buy') { if (action == 'buy') {
var noAfford = false;
let noAfford = false;
if (item.worth.currency) { 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); return (i.name == item.worth.currency);
}); });
noAfford = ((!currencyItems) || (currencyItems.quantity < item.worth.amount)); noAfford = ((!currencyItems) || (currencyItems.quantity < item.worth.amount));
} else } 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)) { if ((!noAfford) && (item.factions)) {
noAfford = item.factions.some(function (f) { noAfford = item.factions.some(function (f) {
@@ -156,26 +156,26 @@ define([
callback: this.onServerRespond.bind(this, el) callback: this.onServerRespond.bind(this, el)
}); });


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


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


var canAfford = true;
let canAfford = true;
if (action == 'buy') { if (action == 'buy') {
if (item.worth.currency) { 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); return (i.name == item.worth.currency);
}); });
canAfford = ((currencyItems) && (currencyItems.quantity >= item.worth.amount)); canAfford = ((currencyItems) && (currencyItems.quantity >= item.worth.amount));
} else } 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); uiTooltipItem.showWorth(canAfford);
}, },




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

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


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


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


list.forEach(function (l) { 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); .appendTo(container);


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


this.skin = skin; 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') this.find('.sprite')
.css('background', 'url("' + spritesheet + '") ' + spirteX + 'px ' + spriteY + 'px'); .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(); this.clear();
}, },


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


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

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


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


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


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


callback.apply(null, args); callback.apply(null, args);
@@ -73,11 +73,11 @@ define([
this.centeredX = x; this.centeredX = x;
this.centeredY = y; 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'); el.css('position', 'absolute');
if (x) if (x)
@@ -115,15 +115,15 @@ define([
}, },


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


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


onEvent: function (event, callback) { 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); list.push(eventCallback);


return eventCallback; return eventCallback;


Loading…
Cancel
Save