Ver código fonte

getitem and getgold commands

tags/v0.1.4^2
Big Bad Waffle 7 anos atrás
pai
commit
9d412fe8b0
9 arquivos alterados com 82 adições e 38 exclusões
  1. +0
    -18
      src/server/components/extensions/adminCommands.js
  2. +65
    -0
      src/server/components/extensions/socialCommands.js
  3. +9
    -6
      src/server/components/inventory.js
  4. +1
    -0
      src/server/components/player.js
  5. +4
    -11
      src/server/components/social.js
  6. +1
    -1
      src/server/config/roles.js
  7. +1
    -1
      src/server/items/generators/quality.js
  8. +1
    -1
      src/server/items/generators/stats.js
  9. BIN
     

+ 0
- 18
src/server/components/extensions/adminCommands.js Ver arquivo

@@ -1,18 +0,0 @@
define([
], function(
) {
return {
roleLevel: null,

init: function(blueprint) {
this.roleLevel = blueprint.roleLevel;
},

onBeforeChat: function(msg) {
console.log(msg.message);
msg.ignore = true;
}
};
});

+ 65
- 0
src/server/components/extensions/socialCommands.js Ver arquivo

@@ -0,0 +1,65 @@
define([
'config/roles',
'world/atlas',
'items/generator',
'misc/random'
], function(
roles,
atlas,
generator,
random
) {
return {
roleLevel: null,

init: function(blueprint) {
this.roleLevel = roles.getRoleLevel(this.obj);
},

onBeforeChat: function(msg) {
if (this.roleLevel < 10)
return;

var messageText = msg.message;
if (messageText[0] != '/')
return;

messageText = messageText.substr(1).split(' ');
var actionName = messageText.splice(0, 1)[0].toLowerCase();
actionName = Object.keys(this).find(a => (a.toLowerCase() == actionName));
if (!actionName)
return;

var config = {};
if ((messageText.length == 1) && (messageText[0].indexOf('=') == -1))
config = messageText[0];
else {
messageText.forEach(function(m) {
m = m.split('=');
config[m[0]] = m[1];
});
}

msg.ignore = true;

atlas.performAction(this.obj, {
cpn: 'social',
method: actionName,
data: config
});
},

//actions
getItem: function(config) {
if (config.stats)
config.stats = config.stats.split(',');

this.obj.inventory.getItem(generator.generate(config));
},

getGold: function(amount) {
this.obj.trade.gold += ~~amount;
this.obj.syncer.set(true, 'trade', 'gold', this.obj.trade.gold);
}
};
});

+ 9
- 6
src/server/components/inventory.js Ver arquivo

@@ -34,9 +34,12 @@ define([
var item = items[i];

//Hacks for old items
if ((item.spell) && (!item.spell.rolls))
if (((item.spell) && (!item.spell.rolls)) || (!item.sprite)) {
items.splice(i, 1);
i--;
iLen--;
continue;
else if ((item.spell) && (item.type == 'Spear')) {
} else if ((item.spell) && (item.type == 'Spear')) {
item.spell.properties = item.spell.properties || {};
item.spell.properties.range = item.range;
}
@@ -150,7 +153,7 @@ define([
this.obj.syncer.setArray(true, 'inventory', 'getItems', replaceItem);
}
}
if (spellbook.spells.length >= 3) {
if (item.slot)
item.spellId = -1;
@@ -176,7 +179,7 @@ define([
var stash = this.obj.stash;
if (!stash.active)
return;
var clonedItem = extend(true, {}, item);
this.destroyItem(id);
stash.deposit(clonedItem);
@@ -390,7 +393,7 @@ define([

return obj;
},
getItem: function(item, hideMessage) {
//We need to know if a mob dropped it for quest purposes
var fromMob = item.fromMob;
@@ -521,7 +524,7 @@ define([
text: e.text,
properties: e.properties
}));
var reputation = this.obj.reputation;

//Don't do this check if we don't have a reputation cpn. That means this is most likely a bag


+ 1
- 0
src/server/components/player.js Ver arquivo

@@ -67,6 +67,7 @@ define([
obj.addComponent('reputation', character.components.find(c => c.type == 'reputation'));

obj.addComponent('social');
obj.social.init();
obj.addComponent('aggro', {
faction: 1
});


+ 4
- 11
src/server/components/social.js Ver arquivo

@@ -13,12 +13,7 @@ define([
party: null,

init: function() {
var roleLevel = roles.getRoleLevel(this.obj);
if (roleLevel >= 10) {
this.obj.extendComponent('social', 'adminCommands', {
roleLevel: roleLevel
});
}
this.obj.extendComponent('social', 'socialCommands', {});
},

simplify: function() {
@@ -75,11 +70,9 @@ define([
},

chat: function(msg) {
if (this.onBeforeChat) {
this.onBeforeChat(msg.data);
if (msg.data.ignore)
return;
}
this.onBeforeChat(msg.data);
if (msg.data.ignore)
return;

var charname = this.obj.auth.charname;
var level = this.obj.stats.values.level;


+ 1
- 1
src/server/config/roles.js Ver arquivo

@@ -5,7 +5,7 @@ define([
) {
return {
accounts: {
admin: {
waffle: {
level: 10,
messageStyle: 'color-cyan',
messagePrefix: '(dev) ',


+ 1
- 1
src/server/items/generators/quality.js Ver arquivo

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

generate: function(item, blueprint) {
if (blueprint.quality != null) {
item.quality = blueprint.quality;
item.quality = ~~blueprint.quality;
return;
}



+ 1
- 1
src/server/items/generators/stats.js Ver arquivo

@@ -209,7 +209,7 @@ define([
var addStats = Math.min(statCount, blueprint.stats.length);
for (var i = 0; i < addStats; i++) {
var choice = useStats[~~(Math.random() * useStats.length)];
useStats.spliceWhere(s => s == choice);
useStats.spliceFirstWhere(s => s == choice);
this.buildStat(item, blueprint, choice, result);
statCount--;
}



Carregando…
Cancelar
Salvar