Sfoglia il codice sorgente

merged v0.5.1 from master

tags/v0.5.1
Shaun 4 anni fa
parent
commit
5ce3bb47e5
25 ha cambiato i file con 928 aggiunte e 811 eliminazioni
  1. +1
    -1
      .gitignore
  2. +13
    -3
      src/client/js/components/social.js
  3. +11
    -0
      src/client/js/main.js
  4. +1
    -1
      src/client/js/objects/objects.js
  5. +2
    -2
      src/client/package.json
  6. +2
    -2
      src/client/ui/templates/login/template.html
  7. +1
    -8
      src/client/ui/templates/messages/messages.js
  8. +2
    -8
      src/client/ui/templates/online/online.js
  9. +1
    -2
      src/server/combat/combat.js
  10. +2
    -0
      src/server/components/auth.js
  11. +27
    -25
      src/server/components/extensions/socialCommands.js
  12. +1
    -1
      src/server/components/inventory.js
  13. +32
    -0
      src/server/components/social.js
  14. +3
    -4
      src/server/components/spellbook.js
  15. +1
    -1
      src/server/config/serverConfig.js
  16. +17
    -24
      src/server/db/ioRethink.js
  17. +11
    -4
      src/server/db/ioSqlite.js
  18. +1
    -1
      src/server/items/enchanter.js
  19. +1
    -1
      src/server/items/generator.js
  20. +1
    -0
      src/server/items/generators/recipeBook.js
  21. +2
    -2
      src/server/mail/mailRethinkDb.js
  22. +1
    -1
      src/server/mail/mailSqlite.js
  23. +773
    -702
      src/server/package-lock.json
  24. +7
    -7
      src/server/package.json
  25. +14
    -11
      src/server/security/sheets.js

+ 1
- 1
.gitignore Vedi File

@@ -15,6 +15,6 @@ helpers/sqlite-to-rethink/rethinkdb_data
helpers/sqlite-to-rethink/tmp
helpers/sqlite-to-rethink/log_file
helpers/sqlite-to-rethink/rethinkdb.exe
.directory
.idea
.vscode

+ 13
- 3
src/client/js/components/social.js Vedi File

@@ -13,15 +13,25 @@ define([
if (this.customChannels)
events.emit('onGetCustomChatChannels', this.customChannels);

if (blueprint.blockedPlayers) {
if (blueprint.blockedPlayers)
this.blockedList = blueprint.blockedList;
events.emit('onGetBlockedPlayers', this.blockedPlayers);
}

if (blueprint.actions) {
this.actions = blueprint.actions;
events.emit('onGetSocialActions', this.actions);
}
},

extend: function (blueprint) {
if (blueprint.blockedPlayers)
this.blockedPlayers = blueprint.blockedPlayers;
},

isPlayerBlocked: function (playerName) {
if (!this.blockedPlayers)
return false;

return this.blockedPlayers.includes(playerName);
}
};
});

+ 11
- 0
src/client/js/main.js Vedi File

@@ -27,6 +27,8 @@ define([
) {
return {
hasFocus: true,
lastRender: 0,
msPerFrame: ~~(1000 / 60),

init: function () {
if (isMobile)
@@ -89,6 +91,13 @@ define([
},

update: function () {
const time = +new Date();
if (time - this.lastRender < this.msPerFrame - 1) {
requestAnimationFrame(this.update.bind(this));

return;
}

objects.update();
renderer.update();
uiFactory.update();
@@ -96,6 +105,8 @@ define([
numbers.render();
renderer.render();

this.lastRender = time;

requestAnimationFrame(this.update.bind(this));
}
};


+ 1
- 1
src/client/js/objects/objects.js Vedi File

@@ -108,7 +108,7 @@ define([
//Things like attacks don't have ids
let exists = null;
if (obj.has('id'))
exists = this.objects.find(f => (f.id === obj.id && !f.destroyed));
exists = this.objects.find(({ id, destroyed }) => id === obj.id && !destroyed);

if (!exists)
exists = this.buildObject(obj);


+ 2
- 2
src/client/package.json Vedi File

@@ -1,6 +1,6 @@
{
"name": "isleward client",
"version": "0.0.2",
"name": "isleward_client",
"version": "0.5.1",
"description": "isleward",
"dependencies": {},
"devDependencies": {


+ 2
- 2
src/client/ui/templates/login/template.html Vedi File

@@ -11,11 +11,11 @@
</div>
<div class="message"></div>
</div>
<div class="news" location="https://gitlab.com/Isleward/isleward/tags/v0.5">[ Latest Release Notes ]</div>
<div class="news" location="https://gitlab.com/Isleward/isleward/tags/v0.5.1">[ Latest Release Notes ]</div>
<div class="extra">
<div class="el btn btnPatreon" location="https://patreon.com/bigbadwaffle">Pledge on Patreon</div>
<div class="el btn btnPaypal" location="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BR2CC82WUAVEA">Donate on Paypal</div>
<div class="el btn btnWiki" location="http://wiki.isleward.com/Main_Page">Access the Wiki</div>
</div>
<div class="version" location="https://gitlab.com/Isleward/isleward/tags/v0.5">v0.5</div>
<div class="version" location="https://gitlab.com/Isleward/isleward/tags/v0.5.1">v0.5.1</div>
</div>

+ 1
- 8
src/client/ui/templates/messages/messages.js Vedi File

@@ -29,8 +29,6 @@ define([

hoverFilter: false,

blockedPlayers: [],

lastChannel: null,

postRender: function () {
@@ -39,7 +37,6 @@ define([
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.onEvent('onToggleLastChannel', this.onToggleLastChannel.bind(this));

this
@@ -204,10 +201,6 @@ define([
textbox.val(val);
},

onGetBlockedPlayers: function (list) {
this.blockedPlayers = list;
},

onGetCustomChatChannels: function (channels) {
channels.forEach(function (c) {
this.onJoinChannel(c);
@@ -284,7 +277,7 @@ define([
messages.forEach(m => {
let message = m.message;

if (m.source && this.blockedPlayers.includes(m.source))
if (m.source && window.player.social.isPlayerBlocked(m.source))
return;

if (m.item) {


+ 2
- 8
src/client/ui/templates/online/online.js Vedi File

@@ -18,7 +18,6 @@ define([
centered: true,

onlineList: [],
blockedList: [],

modal: true,
hasClose: true,
@@ -31,7 +30,6 @@ define([
this.onEvent('onGetConnectedPlayer', this.onGetConnectedPlayer.bind(this));
this.onEvent('onGetDisconnectedPlayer', this.onGetDisconnectedPlayer.bind(this));

this.onEvent('onGetBlockedPlayers', this.onGetBlockedPlayers.bind(this));
this.onEvent('onGetSocialActions', this.onGetSocialActions.bind(this));

this.onEvent('onKeyDown', this.onKeyDown.bind(this));
@@ -42,10 +40,6 @@ define([
this.actions = actions;
},

onGetBlockedPlayers: function (list) {
this.blockedPlayers = list;
},

onKeyDown: function (key) {
if (key === 'o')
this.toggle();
@@ -131,7 +125,7 @@ define([
};
});

const isBlocked = this.blockedPlayers.includes(char.name);
const isBlocked = window.player.social.isPlayerBlocked(char.name);

const actions = [{
text: 'invite to party',
@@ -162,7 +156,7 @@ define([
},

block: function (charName) {
let isBlocked = this.blockedPlayers.includes(charName);
const isBlocked = window.player.social.isPlayerBlocked(charName);
let method = isBlocked ? 'unblock' : 'block';

this.performAction(method, charName);


+ 1
- 2
src/server/combat/combat.js Vedi File

@@ -55,11 +55,10 @@ module.exports = {
if (config.element) {
let elementName = 'element' + config.element[0].toUpperCase() + config.element.substr(1);
dmgPercent += (srcValues[elementName + 'Percent'] || 0);
dmgPercent += srcValues.elementPercent || 0;

//Don't mitigate heals
if (!config.noMitigate) {
let resist = tgtValues.elementAllResist + (tgtValues[elementName + 'Resist'] || 0);
let resist = tgtValues[elementName + 'Resist'] || 0;
amount *= max(0.5 + max((1 - (resist / 100)) / 2, -0.5), 0.5);
}
} else if (!config.noMitigate)


+ 2
- 0
src/server/components/auth.js Vedi File

@@ -298,6 +298,7 @@ module.exports = {

let exists = await io.getAsync({
key: credentials.username,
ignoreCase: true,
table: 'login',
noDefault: true,
noParse: true
@@ -372,6 +373,7 @@ module.exports = {

let exists = await io.getAsync({
key: name,
ignoreCase: true,
table: 'character',
noDefault: true
});


+ 27
- 25
src/server/components/extensions/socialCommands.js Vedi File

@@ -62,8 +62,6 @@ const localCommands = [
'setPassword',
'roll',
'giveSkin',
'block',
'unblock',
'broadcast',
'saveAll',
'ban',
@@ -142,6 +140,7 @@ module.exports = {
}

let config = {};
const originalConfig = messageText.join(' ');
if ((messageText.length === 1) && (messageText[0].indexOf('=') === -1))
config = messageText[0];
else {
@@ -152,7 +151,7 @@ module.exports = {
}

if (localCommands.includes(actionName))
this[actionName](config);
this[actionName](config, originalConfig);
else {
atlas.performAction(this.obj, {
cpn: 'social',
@@ -279,41 +278,44 @@ module.exports = {
},

block: function (target) {
if (this.blockedPlayers.includes(target)) {
this.sendMessage('That player has already been blocked', 'color-redA');
const { obj, blockedPlayers } = this;
const { name, social, syncer } = obj;

if (blockedPlayers.includes(target)) {
social.notifySelf({ message: 'That player has already been blocked' });

return;
}
} else if (target === name) {
social.notifySelf({ message: 'You cannot block yourself' });

if (target === this.obj.name) {
this.sendMessage('You cannot block yourself', 'color-redA');
return;
}

this.blockedPlayers.push(target);
this.sendMessage(`Successfully blocked ${target}`, 'color-yellowB');

this.updateMainThread('blockedPlayers', this.blockedPlayers);
blockedPlayers.push(target);
syncer.set(true, 'social', 'blockedPlayers', blockedPlayers);

this.obj.socket.emit('event', {
event: 'onGetBlockedPlayers',
data: this.blockedPlayers
social.notifySelf({
message: `Successfully blocked ${target}`,
className: 'color-yellowB'
});
},

unblock: function (target) {
if (!this.blockedPlayers.includes(target)) {
this.sendMessage('That player is not blocked', 'color-redA');
const { obj, blockedPlayers } = this;
const { social, syncer } = obj;

if (!blockedPlayers.includes(target)) {
social.notifySelf({ message: 'That player is not blocked' });

return;
}

this.blockedPlayers.spliceWhere(f => f === target);
this.sendMessage(`Successfully unblocked ${target}`, 'color-yellowB');

this.updateMainThread('blockedPlayers', this.blockedPlayers);
blockedPlayers.spliceWhere(f => f === target);
syncer.set(true, 'social', 'blockedPlayers', blockedPlayers);

this.obj.socket.emit('event', {
event: 'onGetBlockedPlayers',
data: this.blockedPlayers
social.notifySelf({
message: `Successfully unblocked ${target}`,
className: 'color-yellowB'
});
},

@@ -708,7 +710,7 @@ module.exports = {
});
},

broadcast: function (msg) {
broadcast: function (config, msg) {
if (typeof(msg) === 'object')
msg = Object.keys(msg).join(' ');



+ 1
- 1
src/server/components/inventory.js Vedi File

@@ -362,7 +362,7 @@ module.exports = {
this.destroyItem(id);
for (const material of items) {
this.getItem(material, false, false, false, true);
this.getItem(material, true, false, false, true);
messages.push({
class: 'q' + material.quality,


+ 32
- 0
src/server/components/social.js Vedi File

@@ -395,5 +395,37 @@ module.exports = {
[property]: value
}]
});
},

//Sends a notification to yourself
// arg1 = { message, className, type }
notifySelf: function ({ message, className = 'color-redA', type = 'info' }) {
const { obj: { id, serverId, instance: { syncer } } } = this;

syncer.queue('onGetMessages', {
id,
messages: [{
class: className,
message,
type
}]
}, [serverId]);
},

//Sends multiple notifications to yourself
// messages = [{ msg, className, type }]
notifySelfArray: function (messages) {
const { obj: { id, serverId, instance: { syncer } } } = this;

messages.forEach(m => {
const { className = 'color-redA', type = 'info ' } = m;
m.className = className;
m.type = type;
});

syncer.queue('onGetMessages', {
id,
messages
}, [serverId]);
}
};

+ 3
- 4
src/server/components/spellbook.js Vedi File

@@ -404,13 +404,12 @@ module.exports = {
if (!spell.active) {
if (1 - this.obj.stats.values.manaReservePercent < reserve.percentage) {
this.sendAnnouncement('Insufficient mana to cast spell');
success = false;
} else
this.obj.stats.addStat('manaReservePercent', reserveEvent.reservePercent);
return;
} this.obj.stats.addStat('manaReservePercent', reserveEvent.reservePercent);
} else
this.obj.stats.addStat('manaReservePercent', -reserveEvent.reservePercent);
}
}
}

if (spell.targetFurthest)
spell.target = this.obj.aggro.getFurthest();


+ 1
- 1
src/server/config/serverConfig.js Vedi File

@@ -1,5 +1,5 @@
module.exports = {
version: '0.4.4',
version: '0.5.1',
port: 4000,
startupMessage: 'Server: ready',
defaultZone: 'fjolarok',


+ 17
- 24
src/server/db/ioRethink.js Vedi File

@@ -7,12 +7,6 @@ const r = require('rethinkdbdash')({
db: serverConfig.dbName
});

const dbConfig = {
host: serverConfig.dbHost,
port: serverConfig.dbPort,
db: 'live'
};

module.exports = {
staticCon: null,

@@ -22,13 +16,7 @@ module.exports = {
cbReady();
},

getConnection: async function () {
return await r.connect(dbConfig);
},

create: async function () {
const con = await this.getConnection();

try {
await r.dbCreate(serverConfig.dbName).run();
} catch (e) {
@@ -43,29 +31,38 @@ module.exports = {
_.log(e);
}
}
},

getAsyncIgnoreCase: async function (table, key) {
const res = await r.table(table)
.filter(doc => doc('id').match(`(?i)^${key}$`))
.run();

con.close();
return res[0];
},

getAsync: async function ({
table,
key,
isArray,
noDefault
noDefault,
ignoreCase
}) {
const con = await this.getConnection();
let res = null;

let res = await r.table(table)
.get(key)
.run();
if (ignoreCase)
res = await this.getAsyncIgnoreCase(table, key);
else {
res = await r.table(table)
.get(key)
.run();
}

if (res)
return res.value;
else if (isArray && !noDefault)
return [];

con.close();

return res;
},

@@ -75,8 +72,6 @@ module.exports = {
isArray,
noDefault
}) {
const con = await this.getConnection();

let res = await r.table(table)
.run();

@@ -85,8 +80,6 @@ module.exports = {
else if (isArray && !noDefault)
return [];

con.close();

return res;
},



+ 11
- 4
src/server/db/ioSqlite.js Vedi File

@@ -136,9 +136,6 @@ module.exports = {
else if (config.type === 'delete')
await this.processDelete(options);
} catch (e) {
if (e.toString().indexOf('unrecognized token') > -1)
_.log(e);
_.log(e);

this.buffer.splice(0, 0, next);
@@ -153,7 +150,10 @@ module.exports = {
},

processGet: async function (options) {
let res = await util.promisify(this.db.get.bind(this.db))(`SELECT * FROM ${options.table} WHERE key = '${options.key}' LIMIT 1`);
const collate = options.ignoreCase ? 'COLLATE NOCASE' : '';
const query = `SELECT * FROM ${options.table} WHERE key = '${options.key}' ${collate} LIMIT 1`;
let res = await util.promisify(this.db.get.bind(this.db))(query);

if (res) {
res = res.value;

@@ -207,6 +207,13 @@ module.exports = {
if (options.serialize)
value = JSON.stringify(value);

//Clean single quotes
if (value.split) {
value = value
.split('\'')
.join('`');
}

let exists = await util.promisify(this.db.get.bind(this.db))(`SELECT * FROM ${table} WHERE key = '${key}' LIMIT 1`);

let query = `INSERT INTO ${table} (key, value) VALUES('${key}', '${value}')`;


+ 1
- 1
src/server/items/enchanter.js Vedi File

@@ -16,7 +16,7 @@ const reroll = (item, msg) => {
delete msg.addStatMsgs;

if ((item.stats) && (item.stats.lvlRequire)) {
item.level += item.stats.lvlRequire;
item.level = Math.min(consts.maxLevel, item.level + item.stats.lvlRequire);
delete item.originalLevel;
}



+ 1
- 1
src/server/items/generator.js Vedi File

@@ -15,7 +15,7 @@ let g13 = require('./generators/recipeBook');
let generators = [g1, g2, g3, g4, g5, g6, g11, g12, g7];
let materialGenerators = [g6, g8];
let spellGenerators = [g1, g9, g7];
let currencyGenerators = [g10];
let currencyGenerators = [g10, g8];
let recipeGenerators = [g6, g13];

module.exports = {


+ 1
- 0
src/server/items/generators/recipeBook.js Vedi File

@@ -3,6 +3,7 @@ module.exports = {
item.sprite = sprite;
item.spritesheet = '../../../images/consumables.png';
item.type = 'recipe';
item.noSalvage = true;

item.recipe = {
profession,


+ 2
- 2
src/server/mail/mailRethinkDb.js Vedi File

@@ -18,7 +18,7 @@ module.exports = {
if (!doc)
return;

let player = this.instance.objects.objects.find(o => (o.name === doc.id));
let player = this.instance.objects.objects.find(o => o.name === doc.id && o.player);
if (!player)
return;

@@ -90,7 +90,7 @@ module.exports = {
if (!items || !(items instanceof Array))
return;

let player = this.instance.objects.objects.find(o => (o.name === playerName));
let player = this.instance.objects.objects.find(o => o.name === playerName && o.player);
if (!player)
return;



+ 1
- 1
src/server/mail/mailSqlite.js Vedi File

@@ -10,7 +10,7 @@ module.exports = {
if (!noBlock)
this.busy[playerName] = (this.busy[playerName] || 0) + 1;

let player = this.instance.objects.objects.find(o => (o.name === playerName));
let player = this.instance.objects.objects.find(o => o.name === playerName && o.player);
if (!player) {
process.send({
method: 'callDifferentThread',


+ 773
- 702
src/server/package-lock.json
File diff soppresso perché troppo grande
Vedi File


+ 7
- 7
src/server/package.json Vedi File

@@ -1,22 +1,22 @@
{
"name": "isleward",
"version": "0.0.2",
"name": "isleward_server",
"version": "0.5.1",
"description": "isleward",
"dependencies": {
"bcrypt-nodejs": "0.0.3",
"compression": "^1.7.3",
"express": "^4.16.4",
"compression": "^1.7.4",
"express": "^4.17.1",
"express-minify": "^1.0.0",
"google-spreadsheet": "^2.0.7",
"google-spreadsheet": "^3.0.10",
"less-middleware": "^3.1.0",
"rethinkdbdash": "^2.3.31",
"socket.io": "^2.2.0",
"socket.io": "^2.3.0",
"universal-analytics": "^0.4.20"
},
"devDependencies": {
"babel-eslint": "^10.1.0",
"eslint": "^6.8.0",
"eslint-plugin-prettier": "^3.1.2",
"sqlite3": "^4.1.0"
"sqlite3": "^4.1.1"
}
}

+ 14
- 11
src/server/security/sheets.js Vedi File

@@ -1,4 +1,4 @@
let googleSheets = require('google-spreadsheet');
const { GoogleSpreadsheet: googleSheets } = require('google-spreadsheet');
let creds = require('./creds');
let sheetsConfig = require('./sheetsConfig');

@@ -8,7 +8,7 @@ module.exports = {

records: null,

init: function () {
init: async function () {
if (sheetsConfig.roles) {
this.update = function () {};
this.onGetRows(null, sheetsConfig.roles);
@@ -16,21 +16,23 @@ module.exports = {
}

this.doc = new googleSheets(sheetsConfig.sheetId);
this.doc.useServiceAccountAuth(creds, this.onAuth.bind(this));
await this.doc.useServiceAccountAuth(creds);
await this.loadInfo();
},

onAuth: function () {
this.doc.getInfo(this.onGetInfo.bind(this));
loadInfo: async function () {
await this.doc.loadInfo();
this.onGetInfo();
},

onGetInfo: function () {
if (!this.doc.worksheets) {
setTimeout(this.onAuth.bind(this), 300000);
this.sheet = this.doc.sheetsByIndex[0];

if (!this.sheet) {
setTimeout(this.loadInfo.bind(this), 300000);
return;
}

this.sheet = this.doc.worksheets[0];

this.update();
},

@@ -72,7 +74,8 @@ module.exports = {
setTimeout(this.update.bind(this), 300000);
},

update: function () {
this.sheet.getRows({}, this.onGetRows.bind(this));
update: async function () {
const records = await this.sheet.getRows();
this.onGetRows(null, records);
}
};

Caricamento…
Annulla
Salva