...
 
Commits (27)
......@@ -2,12 +2,14 @@ define([
'js/rendering/renderer',
'js/system/events',
'js/misc/physics',
'js/sound/sound'
'js/sound/sound',
'js/system/client'
], function (
renderer,
events,
physics,
sound
sound,
client
) {
return {
type: 'player',
......@@ -17,6 +19,9 @@ define([
y: 0
},
lastPing: null,
pingDelay: 5000,
init: function () {
const obj = this.obj;
......@@ -39,6 +44,8 @@ define([
},
update: function () {
this.ping();
const obj = this.obj;
const x = obj.x;
const y = obj.y;
......@@ -56,6 +63,22 @@ define([
this.positionCamera(x, y);
},
ping: function () {
let time = +new Date();
if (time - this.lastPing > this.pingDelay) {
this.lastPing = time;
client.request({
cpn: 'player',
method: 'performAction',
data: {
cpn: 'auth',
method: 'ping'
}
});
}
},
positionCamera: function (x, y, instant) {
renderer.setPosition({
x: (x - (renderer.width / (scale * 2))) * scale,
......
......@@ -7,10 +7,16 @@ define([
type: 'social',
customChannels: null,
blockedPlayers: null,
init: function () {
init: function (blueprint) {
if (this.customChannels)
events.emit('onGetCustomChatChannels', this.customChannels);
if (blueprint.blockedPlayers) {
this.blockedList = blueprint.blockedList;
events.emit('onGetBlockedPlayers', this.blockedPlayers);
}
}
};
});
......@@ -86,7 +86,7 @@ define([
},
onMouseDown: function (e, target) {
if (!target && this.target && (!this.hoverTarget || this.hoverTarget.id != this.target.id)) {
if (!target && this.target && (!this.hoverTarget || this.hoverTarget.id !== this.target.id)) {
client.request({
cpn: 'player',
method: 'queueAction',
......
......@@ -178,13 +178,13 @@ define([
for (let j = 0; j < h; j++) {
let roll = Math.sin(((j * 0.2) % 5) + Math.cos(ii % 8));
let tile = 61;
let tile = 5;
if (roll < -0.2)
tile = 63;
tile = 3;
else if (roll < 0.2)
tile = 64;
tile = 4;
else if (roll < 0.5)
tile = 34;
tile = 53;
let alpha = mRandom();
......@@ -195,10 +195,11 @@ define([
if (mRandom() < 0.35) {
tile = {
61: 62,
63: 64,
64: 63,
34: 33
2: 7,
5: 6,
3: 0,
4: 1,
53: 54
}[tile];
}
......
......@@ -82,7 +82,7 @@ define([
.forEach(function (c, i) {
let charName = c.name;
if (c.level !== null)
charName += '<font class="color-redA"> (' + c.level + ')</font>';
charName += '<font class="color-yellowB"> (' + c.level + ')</font>';
let html = templateListItem
.replace('$NAME$', charName);
......
......@@ -103,7 +103,7 @@
}
.button {
background-color: @orangeC;
background-color: @blueC;
width: calc((100% - (16px * 2)) / 3);
float: left;
margin-right: 16px;
......@@ -114,7 +114,7 @@
}
&:hover {
background-color: @orangeB;
background-color: @blueB;
}
&.deleting {
......
<div class="uiCharacters">
<img class="logo" src="server/mods/iwd-souls-moor/images/logo.png"ii alt="">
<img class="logo" src="images/logo_0.png"ii alt="">
<div class="left">
<div class="character">loading characters...</div>
</div>
......
......@@ -92,7 +92,7 @@
}
.button {
background-color: @orangeC;
background-color: @blueC;
width: calc((100% - @boxPadding) / 2);
float: left;
margin-right: @boxPadding;
......@@ -103,7 +103,7 @@
}
&:hover {
background-color: @orangeB;
background-color: @blueB;
}
}
......
<div class="uiCreateCharacter">
<img class="logo" src="server/mods/iwd-souls-moor/images/logo.png" alt="">
<img class="logo" src="images/logo_0.png" alt="">
<div class="box-left">
<div class="left">
<input type="text" class="el textbox txtName" placeholder="name" maxlength="12">
......
......@@ -49,15 +49,14 @@ define([
this.shown = !this.el.is(':visible');
this.isInspecting = false;
this.find('.itemList').hide();
if (this.shown) {
this.find('.itemList').hide();
this.show();
this.onGetStats();
this.onGetItems();
} else {
this.find('.itemList').hide();
} else
this.hide();
}
this.onHoverItem(null, null, null);
},
......@@ -104,16 +103,16 @@ define([
.css('background-position', '')
.on('click', this.buildSlot.bind(this));
this.find('[slot]').toArray().forEach(function (el) {
this.find('[slot]').toArray().forEach(el => {
el = $(el);
let slot = el.attr('slot');
let newItems = window.player.inventory.items.some(function (i) {
let newItems = window.player.inventory.items.some(i => {
if (slot.indexOf('finger') === 0)
slot = 'finger';
else if (slot === 'oneHanded')
return ((['oneHanded', 'twoHanded'].indexOf(slot) > -1) && (i.isNew));
return (['oneHanded', 'twoHanded'].includes(slot) && i.isNew);
return ((i.slot === slot) && (i.isNew));
return (i.slot === slot && i.isNew);
});
if (newItems)
......@@ -121,10 +120,8 @@ define([
});
items
.filter(function (item) {
return (item.has('quickSlot') || (item.eq && (item.slot || item.has('runeSlot'))));
}, this)
.forEach(function (item) {
.filter(item => item.has('quickSlot') || (item.eq && (item.slot || item.has('runeSlot'))))
.forEach(item => {
let imgX = -item.sprite[0] * 64;
let imgY = -item.sprite[1] * 64;
......@@ -151,7 +148,7 @@ define([
.on('mousemove', this.onHoverItem.bind(this, elSlot, item, null))
.on('mouseleave', this.onHoverItem.bind(this, null, null))
.on('click', this.buildSlot.bind(this, elSlot));
}, this);
});
},
onInspectTarget: function (result) {
......@@ -164,6 +161,9 @@ define([
},
buildSlot: function (el) {
if (this.isInspecting)
return;
if (el.target)
el = $(el.target).parent();
......@@ -175,38 +175,34 @@ define([
.empty()
.show();
this.hoverCompare = el.data('item');
let hoverCompare = this.hoverCompare = el.data('item');
let items = this.items
.filter(function (item) {
.filter(item => {
if (isRune)
return ((!item.slot) && (item.spell) && (!item.eq));
return (!item.slot && item.spell && !item.eq);
else if (isConsumable)
return (item.type === 'consumable' && !item.has('quickSlot'));
let checkSlot = (slot.indexOf('finger') === 0) ? 'finger' : slot;
if (slot === 'oneHanded')
return ((!item.eq) && ((item.slot === 'oneHanded') || (item.slot === 'twoHanded')));
return (!item.eq && (item.slot === 'oneHanded' || item.slot === 'twoHanded'));
return ((item.slot === checkSlot) && (!item.eq));
}, this);
return (item.slot === checkSlot && !item.eq);
});
if (isConsumable) {
items = items
.filter(function (item, i) {
return (items.firstIndex(f => f.name === item.name) === i);
});
}
if (isConsumable)
items = items.filter((item, i) => items.firstIndex(f => f.name === item.name) === i);
items.splice(0, 0, {
name: 'None',
slot: this.hoverCompare ? this.hoverCompare.slot : null,
id: (this.hoverCompare && !isConsumable) ? this.hoverCompare.id : null,
slot: hoverCompare ? hoverCompare.slot : null,
id: (hoverCompare && !isConsumable) ? hoverCompare.id : null,
type: isConsumable ? 'consumable' : null,
empty: true
});
if (this.hoverCompare)
items.splice(1, 0, this.hoverCompare);
if (hoverCompare)
items.splice(1, 0, hoverCompare);
items
.forEach(function (item, i) {
......@@ -228,13 +224,13 @@ define([
.on('mouseleave', this.onHoverItem.bind(this, null, null))
.on('click', this.equipItem.bind(this, item, slot));
if (item === this.hoverCompare)
if (item === hoverCompare)
itemEl.find('.icon').addClass('eq');
else if (item.isNew)
el.find('.icon').addClass('new');
}, this);
if (items.length === 0)
if (!items.length)
container.hide();
},
......
......@@ -41,7 +41,7 @@
.label {
width: 30%;
padding-top: 10px;
color: @yellow;
color: @green;
}
input {
......@@ -92,7 +92,7 @@
height: 35px;
.button {
background-color: @orangeC;
background-color: @blueC;
width: calc((100% - @boxPadding) / 2);
float: left;
margin-right: @boxPadding;
......@@ -103,7 +103,7 @@
}
&:hover {
background-color: @orangeB;
background-color: @blueB;
}
}
}
......@@ -140,7 +140,7 @@
padding-right: 10px;
width: 100%;
margin-bottom: 10px;
background-color: @purpleC;
background-color: @blueD;
color: @white;
&:last-child {
......@@ -148,7 +148,7 @@
}
&:hover {
background-color: @purpleA;
background-color: @blueC;
}
}
}
......
<div class="uiLogin">
<img class="logo" src="server/mods/iwd-souls-moor/images/logo.png" alt="">
<img class="logo" src="images/logo_0.png" alt="">
<div class="right">
<div class="label">username</div>
<input type="text" class="el textbox txtUsername" placeholder="username">
......@@ -11,11 +11,11 @@
</div>
<div class="message"></div>
</div>
<div class="news" location="https://gitlab.com/Isleward/isleward/tags/v0.3.0">[ Seasonal Event: <a class="q3">Soul's Moor</a> ]</div>
<div class="news" location="https://gitlab.com/Isleward/isleward/tags/v0.3.1">[ Latest Release Notes ]</div>
<div class="extra">
<div class="el button btnPatreon" location="https://patreon.com/bigbadwaffle">Pledge on Patreon</div>
<div class="el button btnPaypal" location="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BR2CC82WUAVEA">Donate on Paypal</div>
<div class="el button btnWiki" location="http://wiki.isleward.com/Main_Page">Access the Wiki</div>
</div>
<div class="version" location="https://gitlab.com/Isleward/isleward/tags/v0.3.0">v0.3.0</div>
<div class="version" location="https://gitlab.com/Isleward/isleward/tags/v0.3.1">v0.3.1</div>
</div>
......@@ -27,12 +27,15 @@ define([
hoverFilter: false,
blockedPlayers: [],
postRender: function () {
this.onEvent('onGetMessages', this.onGetMessages.bind(this));
this.onEvent('onDoWhisper', this.onDoWhisper.bind(this));
this.onEvent('onJoinChannel', this.onJoinChannel.bind(this));
this.onEvent('onLeaveChannel', this.onLeaveChannel.bind(this));
this.onEvent('onGetCustomChatChannels', this.onGetCustomChatChannels.bind(this));
this.onEvent('onGetBlockedPlayers', this.onGetBlockedPlayers.bind(this));
this.find('input')
.on('keydown', this.sendChat.bind(this))
......@@ -77,6 +80,10 @@ define([
textbox.val(val);
},
onGetBlockedPlayers: function (list) {
this.blockedPlayers = list;
},
onGetCustomChatChannels: function (channels) {
channels.forEach(function (c) {
this.onJoinChannel(c);
......@@ -149,12 +156,15 @@ define([
let container = this.find('.list');
messages.forEach(function (m) {
messages.forEach(m => {
let message = m.message;
if (m.item) {
let source = message.split(':')[0] + ': ';
let source = message.split(':') + ': ';
if (this.blockedPlayers.includes(m.source))
return;
if (m.item)
message = source + '<span class="q' + (m.item.quality || 0) + '">' + message.replace(source, '') + '</span>';
}
let el = $('<div class="list-message ' + m.class + '">' + message + '</div>')
.appendTo(container);
......@@ -182,7 +192,7 @@ define([
ttl: this.maxTtl,
el: el
});
}, this);
});
container.scrollTop(9999999);
},
......
......@@ -18,6 +18,7 @@ define([
centered: true,
onlineList: [],
blockedList: [],
modal: true,
......@@ -27,10 +28,16 @@ define([
this.onEvent('onGetConnectedPlayer', this.onGetConnectedPlayer.bind(this));
this.onEvent('onGetDisconnectedPlayer', this.onGetDisconnectedPlayer.bind(this));
this.onEvent('onGetBlockedPlayers', this.onGetBlockedPlayers.bind(this));
this.onEvent('onKeyDown', this.onKeyDown.bind(this));
this.onEvent('onShowOnline', this.toggle.bind(this));
},
onGetBlockedPlayers: function (list) {
this.blockedPlayers = list;
},
onKeyDown: function (key) {
if (key === 'o')
this.toggle();
......@@ -106,12 +113,16 @@ define([
showContext: function (char, e) {
if (char.name !== window.player.name) {
let isBlocked = this.blockedPlayers.includes(char.name);
events.emit('onContextMenu', [{
text: 'invite to party',
callback: this.invite.bind(this, char.id)
}, {
text: 'whisper',
callback: events.emit.bind(events, 'onDoWhisper', char.name)
}, {
text: isBlocked ? 'unblock' : 'block',
callback: this.block.bind(this, char.name)
}], e);
}
......@@ -119,6 +130,19 @@ define([
return false;
},
block: function (charName) {
let isBlocked = this.blockedPlayers.includes(charName);
let method = isBlocked ? 'unblock' : 'block';
client.request({
cpn: 'social',
method: 'chat',
data: {
message: `/${method} ${charName}`
}
});
},
invite: function (charId) {
this.hide();
......
......@@ -51,7 +51,7 @@ define([
input.init(this.el);
this.data.nodes = temp.nodes;
this.data.links = temp.links.map(function (l) {
this.data.links = temp.links.map(l => {
return {
from: {
id: l.from
......@@ -106,21 +106,15 @@ define([
let links = this.data.links;
let nodes = this.data.nodes;
links.forEach(function (l) {
links.forEach(l => {
let linked = (
nodes.find(function (n) {
return (n.id === l.from.id);
}).selected &&
nodes.find(function (n) {
return (n.id === l.to.id);
}).selected
nodes.find(n => n.id === l.from.id).selected &&
nodes.find(n => n.id === l.to.id).selected
);
this.renderers.line.call(this, l.from, l.to, linked);
}, this);
});
nodes.forEach(function (n) {
this.renderers.node.call(this, n, n.pos.x, n.pos.y);
}, this);
nodes.forEach(n => this.renderers.node.call(this, n, n.pos.x, n.pos.y));
},
toggle: function (show) {
......@@ -128,9 +122,7 @@ define([
if (this.shown) {
//Calculate midpoint
let start = this.data.nodes.find(function (n) {
return (n.spiritStart === window.player.class);
});
let start = this.data.nodes.find(n => n.spiritStart === window.player.class);
this.pos.x = start.pos.x * constants.gridSize;
this.pos.y = start.pos.y * constants.gridSize;
......@@ -165,7 +157,7 @@ define([
node: function (node) {
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;
if (node.spiritStart) {
......@@ -192,17 +184,17 @@ define([
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;
let linked = this.data.links.some(function (l) {
if ((l.from.id !== node.id) && (l.to.id !== node.id))
let linked = this.data.links.some(l => {
if (l.from.id !== node.id && l.to.id !== node.id)
return false;
return this.data.nodes.some(function (n) {
return this.data.nodes.some(n => {
return (
((n.id === l.from.id) && (n.selected)) ||
((n.id === l.to.id) && (n.selected))
(n.id === l.from.id && n.selected) ||
(n.id === l.to.id && n.selected)
);
});
}, this);
});
if (!linked)
this.ctx.globalAlpha = 0.25;
......@@ -237,13 +229,9 @@ define([
let ctx = this.ctx;
let halfSize = constants.blockSize / 2;
fromNode = this.data.nodes.find(function (n) {
return (n.id === fromNode.id);
});
fromNode = this.data.nodes.find(n => n.id === fromNode.id);
toNode = this.data.nodes.find(function (n) {
return (n.id === toNode.id);
});
toNode = this.data.nodes.find(n => n.id === toNode.id);
let fromX = (fromNode.pos.x * constants.gridSize) + halfSize - this.pos.x;
let fromY = (fromNode.pos.y * constants.gridSize) + halfSize - this.pos.y;
......@@ -261,14 +249,14 @@ define([
ctx.closePath();
ctx.stroke();
if ((!linked) && (!fromNode.selected) && (!toNode.selected))
if (!linked && !fromNode.selected && !toNode.selected)
this.ctx.globalAlpha = 1;
}
},
events: {
onMouseMove: function (pos) {
if ((this.mouse.x === pos.x) && (this.mouse.y === pos.y))
if (this.mouse.x === pos.x && this.mouse.y === pos.y)
return;
this.mouse = {
......@@ -292,13 +280,20 @@ define([
let percentageStats = [
'addCritChance',
'addCritMultiplier',
'addAttackCritChance',
'addAttackCritMultiplier',
'addSpellCritChance',
'addSpellCritMultiplier',
'sprintChance',
'xpIncrease',
'blockAttackChance',
'blockSpellChance',
'dodgeAttackChance',
'dodgeSpellChance',
'attackSpeed',
'castSpeed',
'itemQuantity',
'magicFind',
'catchChance',
'catchSpeed',
'fishRarity',
......@@ -310,8 +305,10 @@ define([
.map(function (s) {
let statName = statTranslations.translate(s);
let statValue = node.stats[s];
if (s.indexOf('CritChance') > -1)
statValue /= 20;
let negative = ((statValue + '')[0] === '-');
if (percentageStats.indexOf(s) > -1)
if (percentageStats.includes(s))
statValue += '%';
return ((negative ? '' : '+') + statValue + ' ' + statName);
......@@ -394,10 +391,8 @@ define([
},
onGetPassives: function (selected) {
this.data.nodes.forEach(function (n) {
n.selected = selected.some(function (s) {
return (s === n.id);
});
this.data.nodes.forEach(n => {
n.selected = selected.some(s => s === n.id);
});
this.renderNodes();
......
......@@ -29,15 +29,17 @@ define([
postRender: function () {
this.onEvent('onShowSmithing', this.toggle.bind(this));
this.onEvent('onKeyDown', this.onKeyDown.bind(this));
this.onEvent('onKeyDown', this.onKey.bind(this, true));
this.onEvent('onKeyUp', this.onKey.bind(this, false));
this.find('.item-picker').on('click', this.openInventory.bind(this));
this.find('.actionButton').on('click', this.smith.bind(this));
this.onEvent('onHideInventory', this.hackMethod.bind(this));
this.onEvent('beforeInventoryClickItem', this.hackMethod.bind(this));
this.onEvent('onGetItems', this.onGetItems.bind(this));
//If we don't listen to these events, they'll be queued
this.onEvent('onHideInventory', () => {});
this.onEvent('beforeInventoryClickItem', () => {});
this.onEvent('onGetItems', this.onGetItems.bind(this));
this.onEvent('onSetSmithItem', this.onHideInventory.bind(this));
this.find('.col-btn').on('click', this.clickAction.bind(this));
......@@ -53,7 +55,7 @@ define([
el.addClass('selected');
if ((this.item) && (changed))
if (this.item && changed)
this.getMaterials(this.item);
},
......@@ -91,8 +93,9 @@ define([
else if (this.action === 'reslot')
msg.msg = 'Item Reslot Succeeded';
result.addStatMsgs.forEach(function (a) {
msg.msg += '<br /> ' + ((a.value > 0) ? '+' : '') + a.value + ' ' + statTranslations.translate(a.stat);
result.addStatMsgs.forEach(a => {
let statName = statTranslations.translate(a.stat);
msg.msg += `<br />${(a.value > 0) ? '+' : ''}${a.value} ${statName}`;
});
events.emit('onGetAnnouncement', msg);
......@@ -105,15 +108,10 @@ define([
let augment = this.find('[action="augment"]').addClass('disabled');
if ((result.item.power || 0) < 3)
augment.removeClass('disabled');
else
else if (this.action === 'augment')
this.find('[action="reroll"]').click();
},
//Something needs to listen to events or they'll be queued
hackMethod: function () {
},
openInventory: function () {
this.eventCloseInv = this.onEvent('onHideInventory', this.onHideInventory.bind(this));
this.eventClickInv = this.onEvent('beforeInventoryClickItem', this.onHideInventory.bind(this));
......@@ -126,11 +124,12 @@ define([
if (msg)
msg.success = false;
if ((!msg) || (!msg.item)) {
if (!msg || !msg.item) {
this.offEvent(this.eventCloseInv);
this.offEvent(this.eventClickInv);
return;
} else if ((!msg.item.slot) || (msg.item.noAugment)) {
} else if (!msg.item.slot || msg.item.noAugment) {
let resultMsg = {
msg: 'Incorrect Item Type',
type: 'failure',
......@@ -328,16 +327,11 @@ define([
this.hide();
},
onKeyDown: function (key) {
if (key === 'm')
onKey: function (isDown, key) {
if (isDown && key === 'm')
this.toggle();
else if (key === 'shift' && this.hoverItem)
this.onHover();
},
onKeyUp: function (key) {
if (key === 'shift' && this.hoverItem)
this.onHover();
}
};
});
......@@ -67,8 +67,6 @@ define([
y: pos.top + el.height() + 16
};
let cd = ~~((spell.cdMax * 350) / 1000);
let values = Object.keys(spell.values).filter(function (v) {
return ((v !== 'damage') && (v !== 'healing'));
}).map(function (v) {
......@@ -83,7 +81,7 @@ define([
.replace('$NAME$', spell.name)
.replace('$DESCRIPTION$', spell.description)
.replace('$MANA$', manaCost)
.replace('$CD$', cd + 's')
.replace('$CD$', spell.cdMax + ' Ticks')
.replace('$VALUES$', values)
.replace('$ELEMENT$', spell.element ? 'element: ' + spell.element : '');
......
......@@ -10,6 +10,7 @@
<div class="quest">quest item</div>
<div class="spellName">$SPELLNAME$</div>
<div class="damage">$DAMAGE$</div>
<div class="spellCost">$SPELLCOST$</div>
<div class="requires">
requires:
<div class="level">level: $LEVEL$</div>
......
......@@ -177,13 +177,8 @@ define([
if (isEnchanted)
statName = statName.substr(1);
let value = this.getStatValue(statName, tempStats[s]);
statName = statTranslations.translate(statName);
let value = tempStats[s];
if (percentageStats.indexOf(s) > -1)
value += '%';
else if ((s.indexOf('element') === 0) && (s.indexOf('Resist') === -1))
value += '%';
let row = value + ' ' + statName;
let rowClass = '';
......@@ -215,13 +210,9 @@ define([
let implicitStats = (item.implicitStats || []).map(function (s) {
let stat = s.stat;
let statName = statTranslations.translate(stat);
let value = s.value;
if (percentageStats.indexOf(stat) > -1)
value += '%';
else if ((stat.indexOf('element') === 0) && (stat.indexOf('Resist') === -1))
value += '%';
let value = this.getStatValue(stat, s.value);
let statName = statTranslations.translate(stat);
let row = value + ' ' + statName;
let rowClass = '';
......@@ -285,75 +276,84 @@ define([
html = html.replace('$DAMAGE$', abilityValues);
}
this.tooltip.html(html);
let tooltip = this.tooltip;
tooltip.html(html);
if (!item.level)
this.tooltip.find('.level').hide();
tooltip.find('.level').hide();
else
this.tooltip.find('.level').show();
tooltip.find('.level').show();
if (!item.implicitStats)
this.tooltip.find('.implicitStats').hide();
tooltip.find('.implicitStats').hide();
else
this.tooltip.find('.implicitStats').show();
tooltip.find('.implicitStats').show();
if (!item.requires) {
if (!item.level)
this.tooltip.find('.requires').hide();
tooltip.find('.requires').hide();
else
this.tooltip.find('.requires .stats').hide();
tooltip.find('.requires .stats').hide();
} else
this.tooltip.find('.requires .stats').show();
tooltip.find('.requires .stats').show();
if (!stats.length)
this.tooltip.children('.stats').hide();
tooltip.children('.stats').hide();
if ((!item.type) || (item.type === item.name))
this.tooltip.find('.type').hide();
tooltip.find('.type').hide();
else {
this.tooltip.find('.type')
tooltip.find('.type')
.html(item.type)
.show();
}
if (item.power)
this.tooltip.find('.power').show();
tooltip.find('.power').show();
let equipErrors = window.player.inventory.equipItemErrors(item);
equipErrors.forEach(function (e) {
this.tooltip.find('.requires').addClass('high-level');
this.tooltip.find('.requires .' + e).addClass('high-level');
tooltip.find('.requires').addClass('high-level');
tooltip.find('.requires .' + e).addClass('high-level');
}, this);
if ((item.material) || (item.quest)) {
this.tooltip.find('.level').hide();
this.tooltip.find('.info').hide();
tooltip.find('.level').hide();
tooltip.find('.info').hide();
if (item.material)
this.tooltip.find('.material').show();
tooltip.find('.material').show();
else if (item.quest)
this.tooltip.find('.quest').show();
tooltip.find('.quest').show();
} else if (item.eq)
this.tooltip.find('.info').hide();
tooltip.find('.info').hide();
if (!item.ability)
this.tooltip.find('.damage').hide();
tooltip.find('.damage').hide();
else
this.tooltip.find('.info').hide();
tooltip.find('.info').hide();
if (item.spell) {
this.tooltip.find('.spellName')
tooltip.find('.spellName')
.html(item.spell.name)
.addClass('q' + item.spell.quality)
.show();
this.tooltip.find('.damage')
tooltip.find('.damage')
.show();
if (item.spell.manaCost) {
tooltip.find('.spellCost')
.html(item.spell.manaCost + ' mana')
.show();
}
if (item.ability)
this.tooltip.find('.spellName').hide();
} else
this.tooltip.find('.spellName').hide();
tooltip.find('.spellName').hide();
} else {
tooltip.find('.spellName').hide();
tooltip.find('.spellCost').hide();
}
this.tooltip.find('.worth').html(item.worthText ? ('<br />value: ' + item.worthText) : '');
tooltip.find('.worth').html(item.worthText ? ('<br />value: ' + item.worthText) : '');
if (item.effects && item.effects[0].text && item.type !== 'mtx') {
let htmlEffects = '';
......@@ -400,14 +400,14 @@ define([
this.find('.faction').hide();
if (shiftDown || !compare)
this.tooltip.find('.info').hide();
tooltip.find('.info').hide();
if (item.cd) {
this.tooltip.find('.info')
tooltip.find('.info')
.html('cooldown: ' + item.cd)
.show();
} else if (item.uses) {
this.tooltip.find('.info')
tooltip.find('.info')
.html('uses: ' + item.uses)
.show();
}
......@@ -428,6 +428,17 @@ define([
events.emit('onBuiltItemTooltip', this.tooltip);
},
getStatValue: function (statName, statValue) {
let res = statValue;
if (statName.indexOf('CritChance') > -1)
res = res / 20;
if (percentageStats.includes(statName) || (statName.indexOf('element') === 0 && statName.indexOf('Resist') === -1))
res += '%';
return res;
},
showWorth: function (canAfford) {
this.tooltip.find('.worth').show();
......
......@@ -81,6 +81,8 @@ module.exports = {
}
}
amount = 0.001;
return {
amount: amount,
blocked: blocked,
......
......@@ -21,6 +21,13 @@ module.exports = {
customChannels: [],
lastPing: null,
isAfk: false,
init: function () {
this.lastPing = +new Date();
},
play: function (data) {
if (!this.username)
return;
......@@ -35,9 +42,14 @@ module.exports = {
character.stash = this.stash;
character.account = this.username;
let relog = (this.charname === character.name);
this.charname = character.name;
this.checkLoginReward(data, character);
if (relog) {
data.callback();
atlas.relog(this.obj);
} else
this.checkLoginReward(data, character);
},
checkLoginReward: function (data, character) {
......@@ -45,7 +57,7 @@ module.exports = {
let time = scheduler.getTime();
let lastLogin = accountInfo.lastLogin;
if ((!lastLogin) || (lastLogin.day !== time.day)) {
if (!lastLogin || lastLogin.day !== time.day) {
let daysSkipped = 1;
if (lastLogin) {
if (time.day > lastLogin.day)
......@@ -271,7 +283,9 @@ module.exports = {
}
this.username = msg.data.username;
connections.logOut(this.obj);
let relogged = connections.logOut(this.obj);
if (relogged)
cons.players.spliceWhere(p => p === this.obj);
await this.getSkins();
......@@ -391,7 +405,9 @@ module.exports = {
skinId: data.skinId,
class: data.class,
cell: skins.getCell(data.skinId),
sheetName: skins.getSpritesheet(data.skinId)
sheetName: skins.getSpritesheet(data.skinId),
x: null,
y: null
});
let simple = this.obj.getSimple(true);
......@@ -484,5 +500,47 @@ module.exports = {
dead: true
}
});
},
ping: function () {
let time = +new Date();
//this.lastPing = time;
if (this.afk)
this.setAfk(false);
},
setAfk: function (isAfk) {
if (this.isAfk === isAfk)
return;
this.isAfk = isAfk;
let msg = `${this.obj.name} has gone afk`;
if (!isAfk)
msg = `${this.obj.name} is no longer afk`;
this.obj.instance.syncer.queue('onGetMessages', {
messages: {
class: 'color-blueB',
message: msg
}
}, -1);
},
update: function () {
let time = +new Date();
let delta = time - this.lastPing;
if (delta > 120000) {
process.send({
method: 'object',
serverId: this.obj.serverId,
obj: {
offline: true
}
});
} else if (delta > 10000)
this.setAfk(true);
}
};
......@@ -109,8 +109,8 @@ module.exports = {
let item = extend({}, e);
if (item.type === 'skin') {
let skinBlueprint = skins.getBlueprint(item.id);
item.skinId = item.id;
let skinBlueprint = skins.getBlueprint(item.skinId);
item.skinId = item.skinId;
item.name = skinBlueprint.name;
item.sprite = skinBlueprint.sprite;
} else if (item.generate) {
......
......@@ -10,6 +10,8 @@ let commandRoles = {
leave: 0,
unEq: 0,
roll: 0,
block: 0,
unblock: 0,
//Mods
mute: 5,
......@@ -36,7 +38,9 @@ let localCommands = [
'mute',
'unmute',
'setPassword',
'roll'
'roll',
'block',
'unblock'
];
module.exports = {
......@@ -192,6 +196,40 @@ module.exports = {
});
},
block: function (target) {
if (this.blockedPlayers.includes(target)) {
this.sendMessage('That player has already been blocked', 'color-redA');
return;
}
this.blockedPlayers.push(target);
this.sendMessage(`Successfully blocked ${target}`, 'color-yellowB');
this.updateMainThread('blockedPlayers', this.blockedPlayers);
this.obj.socket.emit('event', {
event: 'onGetBlockedPlayers',
data: this.blockedPlayers
});
},
unblock: function (target) {
if (!this.blockedPlayers.includes(target)) {
this.sendMessage('That player is not blocked', 'color-redA');
return;
}
this.blockedPlayers.spliceWhere(f => f === target);
this.sendMessage(`Successfully unblocked ${target}`, 'color-yellowB');
this.updateMainThread('blockedPlayers', this.blockedPlayers);
this.obj.socket.emit('event', {
event: 'onGetBlockedPlayers',
data: this.blockedPlayers
});
},
isInChannel: function (character, channel) {
return character.auth.customChannels.some(c => (c === channel));
},
......
......@@ -32,18 +32,7 @@ module.exports = {
if (firstNode.resourceNode.nodeType === 'fish') {
let rod = this.obj.equipment.eq.tool;
if (!rod) {
process.send({
method: 'events',
data: {
onGetAnnouncement: [{
obj: {
msg: 'You need a fishing rod to fish'
},
to: [this.obj.serverId]
}]
}
});
this.sendAnnouncement('You need a fishing rod to fish');
this.gathering = null;
return;
......@@ -109,18 +98,7 @@ module.exports = {
if (isFish) {
let catchChance = 40 + this.obj.stats.values.catchChance;
if (~~(Math.random() * 100) >= catchChance) {
process.send({
method: 'events',
data: {
onGetAnnouncement: [{
obj: {
msg: 'The fish got away'
},
to: [this.obj.serverId]
}]
}
});
this.sendAnnouncement('The fish got away');
this.gathering = null;
return;
......@@ -170,7 +148,7 @@ module.exports = {
let blueprint = gatherResult.blueprint;
gatherResult.items.forEach(function (item, i) {
gatherResult.items.forEach((item, i) => {
delete item.pos;
if (i === 0) {
......@@ -184,7 +162,7 @@ module.exports = {
if (item.material)
this.obj.fireEvent('afterGatherResource', gatherResult);
}, this);
});
if (!gatherResult.noChangeAmount)
resourceNode.gather();
......@@ -192,19 +170,8 @@ module.exports = {
this.obj.stats.getXp(gatherResult.xp, this.obj, gatherResult.obj);
if (gathering.destroyed) {
if (isFish) {
process.send({
method: 'events',
data: {
onGetAnnouncement: [{
obj: {
msg: 'The school has been depleted'
},
to: [this.obj.serverId]
}]
}
});
}
if (isFish)
this.sendAnnouncement('The school has been depleted');
this.nodes.spliceWhere(n => (n === gathering));
}
......@@ -230,6 +197,17 @@ module.exports = {
msg = 'You need a fishing rod to fish';
}
this.sendAnnouncement(msg);
this.nodes.spliceWhere(n => (n === node));
this.nodes.push(node);
},
exit: function (node) {
this.nodes.spliceWhere(n => (n === node));
},
sendAnnouncement: function (msg) {
process.send({
method: 'events',
data: {
......@@ -241,13 +219,6 @@ module.exports = {
}]
}
});
this.nodes.spliceWhere(n => (n === node));
this.nodes.push(node);
},
exit: function (node) {
this.nodes.spliceWhere(n => (n === node));
},
events: {
......@@ -259,9 +230,9 @@ module.exports = {
if (!this.gathering)
return;
['x', 'y', 'width', 'height'].forEach(function (p) {
['x', 'y', 'width', 'height'].forEach(p => {
this.obj.syncer.delete(false, 'gatherer', p);
}, this);
});
this.obj.syncer.set(true, 'gatherer', 'progress', 100);
this.obj.syncer.set(false, 'gatherer', 'progress', 100);
......@@ -272,6 +243,14 @@ module.exports = {
this.gathering = null;
},
beforeCastSpell: function () {
this.events.beforeMove.call(this);
},
beforeTakeDamage: function () {
this.events.beforeMove.call(this);
},
afterEquipItem: function (item) {
let nodes = this.nodes;
let nLen = nodes.length;
......@@ -283,17 +262,7 @@ module.exports = {
if (node.resourceNode.nodeType === 'fish') {
if (!this.obj.equipment.eq.has('tool')) {
process.send({
method: 'events',
data: {
onGetAnnouncement: [{
obj: {
msg: 'You need a fishing rod to fish'
},
to: [this.obj.serverId]
}]
}
});
this.sendAnnouncement('You need a fishing rod to fish');
if (this.gathering === node) {
if (this.gathering.resourceNode.nodeType === 'fish')
......
......@@ -522,14 +522,21 @@ module.exports = {
});
},