Browse Source

linting

tags/v0.4.2^2
Big Bad Waffle 4 years ago
parent
commit
1fc705536f
4 changed files with 112 additions and 91 deletions
  1. +20
    -0
      helpers/sqlite-to-rethink/cheatsheet.js
  2. +2
    -3
      src/server/components/inventory.js
  3. +90
    -87
      src/server/config/eventPhases/phaseSpawnMob.js
  4. +0
    -1
      src/server/world/map.js

+ 20
- 0
helpers/sqlite-to-rethink/cheatsheet.js View File

@@ -52,6 +52,26 @@ r.db('live').table('character')
});
});

r.db('live').table('character')
.concatMap(row => {
return row('value')('components')
.filter(cpn => {
return cpn('type').eq('inventory');
})
.concatMap(c => {
return [{
name: row('value')('name'),
account: row('value')('account'),
cpn: c('items').filter(item => {
return item('quantity').ge(30000);
})
}];
})
.filter(c => {
return c('cpn').count().ge(1);
});
});

//Play time per account from low to high
r.db('live').table('character')
.concatMap(row => {


+ 2
- 3
src/server/components/inventory.js View File

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

mailItem: async function (msg) {
return;
let item = this.findItem(msg.itemId);
/*let item = this.findItem(msg.itemId);
if ((!item) || (item.noDrop) || (item.quest)) {
this.resolveCallback(msg);
return;
@@ -482,7 +481,7 @@ module.exports = {
}
this.destroyItem(item.id);

this.resolveCallback(msg);
this.resolveCallback(msg);*/
},

hookItemEvents: function (items) {


+ 90
- 87
src/server/config/eventPhases/phaseSpawnMob.js View File

@@ -1,12 +1,97 @@
let mobBuilder = require('../../world/mobBuilder');

const buildMob = (objects, mobConfig, x, y, mobIndex) => {
const { id, sheetName, cell, name, properties, originX, originY, maxChaseDistance, dialogue, trade, chats, events } = mobConfig;

let mob = objects.buildObjects([{
x: x,
y: y,
sheetName: sheetName || 'mobs',
cell: cell,
name: name,
properties: properties
}]);

mobBuilder.build(mob, mobConfig);

if (id)
mob.id = id.split('$').join(mobIndex);

if (originX) {
mob.mob.originX = originX;
mob.mob.originY = originY;
mob.mob.goHome = true;
mob.mob.maxChaseDistance = maxChaseDistance;
//This is a hack to make mobs that run somewhere able to take damage
delete mob.mob.events.beforeTakeDamage;
}

if (dialogue) {
mob.addComponent('dialogue', {
config: dialogue.config
});

if (dialogue.auto) {
mob.dialogue.trigger = objects.buildObjects([{
properties: {
x: mob.x - 1,
y: mob.y - 1,
width: 3,
height: 3,
cpnNotice: {
actions: {
enter: {
cpn: 'dialogue',
method: 'talk',
args: [{
targetName: 'angler nayla'
}]
},
exit: {
cpn: 'dialogue',
method: 'stopTalk'
}
}
}
}
}]);
}
}

if (trade)
mob.addComponent('trade', trade);

if (chats)
mob.addComponent('chatter', chats);

if (events) {
mob.addBuiltComponent({
type: 'eventComponent',
events: events
});
}

return mob;
};

const spawnAnimation = (syncer, { x, y }) => {
syncer.queue('onGetObject', {
x: x,
y: y,
components: [{
type: 'attackAnimation',
row: 0,
col: 4
}]
}, -1);
};

module.exports = {
spawnRect: null,
mobs: null,

init: function () {
let objects = this.instance.objects;
let spawnRect = this.spawnRect;
const { spawnRect, instance: { objects, syncer } } = this;

if (!this.mobs.push)
this.mobs = [this.mobs];
@@ -60,97 +145,15 @@ module.exports = {
this.spawnAnimation(mob);
this.event.objects.push(mob);
} else {
let mob = objects.buildObjects([{
x: x,
y: y,
sheetName: l.sheetName || 'mobs',
cell: l.cell,
name: l.name,
properties: l.properties
}]);

mob.event = this.event;

mobBuilder.build(mob, l);
this.spawnAnimation(mob);

if (l.id) {
let id = l.id.split('$').join(i);
mob.id = id;
}

if (l.originX) {
mob.mob.originX = l.originX;
mob.mob.originY = l.originY;
mob.mob.goHome = true;
mob.mob.maxChaseDistance = l.maxChaseDistance;
//This is a hack to make mobs that run somewhere able to take damage
delete mob.mob.events.beforeTakeDamage;
}

const mob = buildMob(objects, l, x, y, i);
this.event.objects.push(mob);

if (l.dialogue) {
mob.addComponent('dialogue', {
config: l.dialogue.config
});

if (l.dialogue.auto) {
mob.dialogue.trigger = objects.buildObjects([{
properties: {
x: mob.x - 1,
y: mob.y - 1,
width: 3,
height: 3,
cpnNotice: {
actions: {
enter: {
cpn: 'dialogue',
method: 'talk',
args: [{
targetName: 'angler nayla'
}]
},
exit: {
cpn: 'dialogue',
method: 'stopTalk'
}
}
}
}
}]);
}
}

if (l.trade)
mob.addComponent('trade', l.trade);

if (l.chats)
mob.addComponent('chatter', l.chats);

if (l.events) {
mob.addBuiltComponent({
type: 'eventComponent',
events: l.events
});
}
mob.event = this.event;
spawnAnimation(syncer, mob);
}
}
}, this);

if (!this.endMark)
this.end = true;
},

spawnAnimation: function (mob) {
this.instance.syncer.queue('onGetObject', {
x: mob.x,
y: mob.y,
components: [{
type: 'attackAnimation',
row: 0,
col: 4
}]
}, -1);
}
};

+ 0
- 1
src/server/world/map.js View File

@@ -69,7 +69,6 @@ module.exports = {
try {
this.zone = require('../' + this.path + '/' + this.name + '/zone');
} catch (e) {
console.log(e);
this.zone = globalZone;
}
events.emit('onAfterGetZone', this.name, this.zone);


Loading…
Cancel
Save