Commit 5570d790 authored by Big Bad Waffle's avatar Big Bad Waffle

Merge branch 'v0.2.0' into 'master'

V0.2.0

Closes #679, #678, #677, #676, #675, #535, #467, #429, #493, #558, #557, #667, and #527

See merge request !301
parents 8f6ffec4 79fe1239
......@@ -5,3 +5,5 @@ storage.db
*.css
src/server/mods/iwd-*
!helpers/item-tooltip/styles.css
!helpers/passives/**/*.css
creds.js
.q0{color:#f2f5f5}.q1{color:#4ac441}.q2{color:#3fa7dd}.q3{color:#a24eff}.q4{color:#ff6942}.color-red{color:#d43346 !important}.color-redA{color:#ff4252 !important}.color-blueA{color:#48edff !important}.color-blueB{color:#3fa7dd !important}.color-greenB{color:#4ac441 !important}.color-yellowB{color:#faac45 !important}.color-green{color:#80f643 !important}.color-brownC{color:#b15a30 !important}.color-brownD{color:#763b3b !important}.color-grayA{color:#f2f5f5 !important}.color-grayB{color:#c0c3cf !important}.color-grayC{color:#929398 !important}.color-grayD{color:#69696e !important}.color-pinkB{color:#de43ae !important}html,body{width:100vw;height:100vh}body{background-color:#2d2136;padding:0;margin:0;overflow:hidden}.canvas,.ui-container{position:absolute}.ui-container{width:100%;height:100%;pointer-events:none}.ui-container>*{pointer-events:auto}*{box-sizing:border-box;font-family:bitty;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;font-family:"courier"}.disabled{opacity:.4 !important;pointer-events:none !important}::-webkit-scrollbar{width:16px}::-webkit-scrollbar-track{background-color:#3c3f4c;-webkit-border-radius:0;border-radius:0}::-webkit-scrollbar-thumb{-webkit-border-radius:10px;border-radius:0;background:#929398}
\ No newline at end of file
@import "../../../src/client/css/colors.less";
html, body {
width: 100vw;
height: 100vh;
}
body {
background-color: @black;
padding: 0px;
margin: 0px;
overflow: hidden;
}
.canvas, .ui-container {
position: absolute;
}
.ui-container {
width: 100%;
height: 100%;
pointer-events: none;
> * {
pointer-events: auto;
}
}
* {
box-sizing: border-box;
font-family: bitty;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
font-family: "courier";
}
.disabled {
opacity: 0.4 !important;
pointer-events: none !important;
}
::-webkit-scrollbar {
width: 16px;
}
::-webkit-scrollbar-track {
background-color: @gray;
-webkit-border-radius: 0px;
border-radius: 0px;
}
::-webkit-scrollbar-thumb {
-webkit-border-radius: 10px;
border-radius: 0px;
background: @lightGray;
}
@import "../../../src/client/css/colors.less";
<!doctype html>
<html>
<head>
<title>test</title>
<link rel="stylesheet" href="css/main.css">
<script src="plugins/require.js" data-main="js/app"></script>
</head>
<body>
<canvas class="canvas"></canvas>
<div class="ui-container"></div>
</body>
</html>
require.config({
baseUrl: '',
waitSeconds: 120,
paths: {
'jquery': 'plugins/jquery.min',
'text': 'plugins/text',
'html': 'plugins/html',
'css': 'plugins/css',
'socket': 'plugins/socket'
},
shim: {
'jquery': {
exports: '$'
},
'socket': {
exports: 'io'
}
}
});
require([
'js/helpers',
'jquery',
'js/main'
], function (
helpers,
jQuery,
main
) {
main.init();
});
define([
'socket'
], function (
io
) {
return {
socket: null,
init: function (onReady) {
var tType = 'websocket';
this.socket = io({
transports: [tType]
});
this.socket.on('connect', this.onConnected.bind(this, onReady));
},
load: function (fileName, callback) {
this.socket.emit('request', {
fileName: fileName,
action: 'load'
}, callback);
},
save: function (fileName, data, callback) {
this.socket.emit('request', {
fileName: fileName,
action: 'save',
data: data
}, callback);
},
getFileList: function (callback) {
this.socket.emit('request', {
action: 'getFileList'
}, callback);
},
onConnected: function (onReady) {
onReady();
}
};
});
define([
], function (
) {
return {
standAlone: false,
lineWidth: 5,
blockSize: 20,
defaultDistance: 50,
defaultDistanceInc: 60,
defaultAngle: Math.PI / 2,
defaultAngleInc: Math.PI / 8,
gridSize: 30,
scrollSpeed: 0.75,
stats: {
str: 'strength',
int: 'intellect',
dex: 'dexterity',
vit: 'vitality',
regenHp: 'health regeneration',
manaMax: 'maximum mana',
regenMana: 'mana regeneration',
armor: 'armor',
attackSpeed: 'attack speed',
castSpeed: 'cast speed',
blockAttackChance: 'chance to block attacks',
blockSpellChance: 'chance to block spells',
addCritChance: 'increased crit chance',
addCritMultiplier: 'increased 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',
elementAllResist: 'all resistance',
elementArcaneResist: 'arcane resistance',
elementFrostResist: 'frost resistance',
elementFireResist: 'fire resistance',
elementHolyResist: 'holy resistance',
elementPoisonResist: 'poison resistance',
elementAllResist: 'all resistance',
physicalPercent: 'increased physical damage',
spellPercent: 'increased spell damage',
elementPercent: 'increased elemental damage',
addSpellCritChance: 'increased spell crit chance',
addSpellCritMultiplier: 'increased spell crit multiplier',
addAttackCritChance: 'increased attack crit chance',
addAttackCritMultiplier: 'increased attack crit multiplier',
dodgeAttackChance: 'chance to dodge attacks'
}
};
});
define([
], function (
) {
var events = {
events: {},
on: function (event, callback) {
var list = this.events[event] || (this.events[event] = []);
list.push(callback);
return callback;
},
off: function (event, callback) {
var list = this.events[event] || [];
var lLen = list.length;
for (var i = 0; i < lLen; i++) {
if (list[i] == callback) {
list.splice(i, 1);
i--;
lLen--;
}
}
if (lLen == 0)
delete this.events[event];
},
emit: function (event) {
var args = [].slice.call(arguments, 1);
var list = this.events[event];
if (!list)
return;
var len = list.length
for (var i = 0; i < len; i++) {
var l = list[i];
l.apply(null, args);
}
}
};
return events;
});
define([
'js/tplNode',
'js/events',
'js/client',
'js/input'
], function (
tplNode,
events,
client,
input
) {
return {
links: [],
nodes: [],
mode: 'none',
init: function () {
events.on('onAreaSelect', this.events.onAreaSelect.bind(this));
events.on('onMouseMove', this.events.onMouseMove.bind(this));
},
findNode: function (x, y) {
var res = this.nodes.find(n => ((n.pos.x == x) && (n.pos.y == y)));
if (!res) {
res = this.nodes.find(function (n) {
return ((n.size > 0) && (Math.abs(n.pos.x - x) <= 1) && (Math.abs(n.pos.y - y) <= 1))
});
}
return res;
},
callAction: function (action, options = {}) {
var node = options.node || this.findNode(options.x, options.y);
options.node = node;
return !this.actions[action].call(this, options);
},
getSelected: function (single) {
var selected = this.nodes.filter(n => n.selected);
if ((single) && (selected.length != 1))
return null;
if (single)
return selected[0];
else
return selected;
},
serialize: function () {
return JSON.stringify({
nodes: this.nodes,
links: this.links.map(function (l) {
return {
from: {
id: l.from.id
},
to: {
id: l.to.id
}
};
})
});
},
getNextId: function () {
for (var i = 0; i < this.nodes.length; i++) {
if (!this.nodes.some(n => (n.id == i)))
return i;
}
return this.nodes.length;
},
setMode: function (mode) {
this.mode = mode;
},
actions: {
reset: function () {
this.nodes = [];
this.links = [];
events.emit('onNew');
},
load: function (data) {
this.nodes = data.nodes;
this.nodes.forEach(function (n) {
if ((n.group) && (!n.group.push))
n.group = [n.group];
});
this.links = data.links.map(function (l) {
l.from = this.nodes.find(n => (n.id == l.from.id));
l.to = this.nodes.find(n => (n.id == l.to.id));
return l;
}, this);
events.emit('onTreeLoaded', {
nodes: this.nodes,
links: this.links
});
},
selectNode: function (options) {
if (
(
(!options.node) ||
(!this.nodes.some(n => ((n.selected) && (n == options.node))))
) &&
(
(!input.isKeyDown('shift')) ||
(options.force)
)
)
this.nodes.forEach(n => (n.selected = false));
if (options.node)
options.node.selected = true;
else if (options instanceof Array)
options.forEach(n => (n.selected = true));
events.emit('onSelectNode', this.nodes.filter(n => n.selected));
if (options.node)
events.emit('onFocusNode', options.node);
return !options.node;
},
addNode: function (options) {
this.nodes.push(tplNode.build({
id: this.getNextId(),
x: options.x,
y: options.y
}));
this.callAction('selectNode');
},
connectNode: function (options) {
var node = options.node;
if (!node) {
this.callAction('selectNode');
return true;
}
var singleSelected = this.getSelected(true);
if ((singleSelected) && (input.isKeyDown('ctrl'))) {
if (options.shiftDown) {
this.links.spliceWhere(l => (
(
(l.from == node) ||
(l.to == node)
) &&
(
(l.from == singleSelected) ||
(l.to == singleSelected)
) &&
(node != singleSelected)
));
} else {
this.links.push({
from: singleSelected,
to: node
});
}
this.callAction('selectNode', {
force: true
});
this.callAction('selectNode', {
node: options.node
});
} else {
return this.callAction('selectNode', {
node: node
})
}
},
moveNode: function (options) {
var selected = this.getSelected();
if (!selected.length)
return true;
if (selected.length == 0)
return;
selected.sort(function (a, b) {
var distanceA = Math.abs(a.pos.x - options.x) + Math.abs(a.pos.y - options.y);
var distanceB = Math.abs(b.pos.x - options.x) + Math.abs(b.pos.y - options.y);
return (distanceA > distanceB) ? 1 : -1;
});
var deltaX = selected[0].pos.x - options.x;
var deltaY = selected[0].pos.y - options.y;
selected.forEach(function (s) {
s.pos.x -= deltaX;
s.pos.y -= deltaY;
});
},
deleteNode: function (options) {
var selected = this.getSelected();
selected.forEach(function (s) {
this.nodes.spliceWhere(n => (n == s));
this.links.spliceWhere(n => ((n.from == s) || (n.to == s)));
s.selected = false;
events.emit('onDeleteNode', s);
}, this);
},
recolorNode: function () {
var selected = this.getSelected(true);
if (!selected)
return true;
selected.color = (selected.color + 1) % 7;
},
resizeNode: function () {
var selected = this.getSelected(true);
if (!selected)
return true;
selected.size = (selected.size + 1) % 3;
}
},
events: {
onAreaSelect: function (from, to) {
if (!input.isKeyDown('ctrl'))
this.nodes.forEach(n => (n.selected = false));
var lowX = Math.min(from.x, to.x);
var lowY = Math.min(from.y, to.y);
var highX = Math.max(from.x, to.x);
var highY = Math.max(from.y, to.y);
for (var i = lowX; i <= highX; i++) {
for (var j = lowY; j <= highY; j++) {
var node = this.findNode(i, j);
if (!node)
continue;
node.selected = true;
}
}
events.emit('onSelectNode', this.nodes.filter(n => n.selected));
},
onMouseMove: function (e) {
var hoverNode = this.findNode(e.x, e.y);
if (hoverNode) {
var text = '';
var stats = hoverNode.stats || {};
for (var s in stats) {
text += s + ': ' + stats[s] + '<br />';
}
text = text.substr(0, text.length - 6);
if (text.length > 0)
events.emit('onShowTooltip', e, text);
} else
events.emit('onHideTooltip');
}
}
};
});
Array.prototype.firstIndex = function (callback, thisArg) {
var T = thisArg;
var O = Object(this);
var len = O.length >>> 0;
var k = 0;
while (k < len) {
var kValue;
if (k in O) {
kValue = O[k];
if (callback.call(T, kValue, k, O))
return k;
}
k++;
}
return -1;
};
Array.prototype.spliceWhere = function (callback, thisArg) {
var T = thisArg;
var O = Object(this);
var len = O.length >>> 0;
var k = 0;
while (k < len) {
var kValue;
if (k in O) {
kValue = O[k];
if (callback.call(T, kValue, k, O)) {
O.splice(k, 1);
k--;
}
}
k++;
}
};
Array.prototype.spliceFirstWhere = function (callback, thisArg) {
var T = thisArg;
var O = Object(this);
var len = O.length >>> 0;
var k = 0;
while (k < len) {
var kValue;
if (k in O) {
kValue = O[k];
if (callback.call(T, kValue, k, O)) {
O.splice(k, 1);
return kValue;
}
}
k++;
}
};
window._ = {
create: function () {
var result = {};
[].slice.call(arguments).forEach(function (a) {
$.extend(true, result, a);
});
return result;
},
get2dArray: function (w, h, def) {
def = def || 0;
var result = [];
for (var i = 0; i < w; i++) {
var inner = [];
for (var j = 0; j < h; j++) {
if (def == 'array')
inner.push([]);
else
inner.push(def);
}
result.push(inner);
}
return result;