You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

75 lines
1.7 KiB

  1. let io = require('../security/io');
  2. let configSkins = require('../config/skins');
  3. module.exports = {
  4. fixCharacter: function (player) {
  5. let inv = player.components.find(c => (c.type === 'inventory'));
  6. if ((inv) && (inv.items))
  7. this.fixItems(inv.items);
  8. },
  9. fixStash: function (stash) {
  10. this.fixItems(stash);
  11. },
  12. fixItems: function (items) {
  13. items
  14. .filter(i => ((i.name === 'Cowl of Obscurity') && (!i.factions)))
  15. .forEach(function (i) {
  16. i.factions = [{
  17. id: 'gaekatla',
  18. tier: 7
  19. }];
  20. });
  21. items
  22. .filter(i => (i.name === 'Steelclaw\'s Bite'))
  23. .forEach(function (i) {
  24. let effect = i.effects[0];
  25. if (!effect.properties) {
  26. effect.properties = {
  27. element: 'poison'
  28. };
  29. } else if (!effect.properties.element)
  30. effect.properties.element = 'poison';
  31. });
  32. items
  33. .filter(f => ((f.effects) && (f.effects[0].factionId === 'akarei') && (!f.effects[0].properties)))
  34. .forEach(function (i) {
  35. let effect = i.effects[0];
  36. let chance = parseFloat(effect.text.split(' ')[0].replace('%', ''));
  37. effect.properties = {
  38. chance: chance
  39. };
  40. });
  41. items
  42. .filter(f => ((f.stats) && (f.stats.dmgPercent)))
  43. .forEach(function (i) {
  44. i.stats.physicalPercent = i.stats.dmgPercent;
  45. delete i.stats.dmgPercent;
  46. if ((i.enchantedStats) && (i.enchantedStats.dmgPercent)) {
  47. i.enchantedStats.physicalPercent = i.enchantedStats.dmgPercent;
  48. delete i.enchantedStats.dmgPercent;
  49. }
  50. });
  51. },
  52. fixSkins: function (username, skins) {
  53. let length = skins.length;
  54. skins = skins.filter(s => !!configSkins.getBlueprint(s));
  55. if (length !== skins.length) {
  56. io.set({
  57. ent: username,
  58. field: 'skins',
  59. value: JSON.stringify(skins)
  60. });
  61. }
  62. }
  63. };