Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

71 linhas
1.8 KiB

  1. const cardRecipes = require('./recipes/recipes');
  2. const cards = require('./cards');
  3. const { dealer } = require('./config');
  4. module.exports = {
  5. name: 'Feature: Cards',
  6. init: function () {
  7. this.events.on('onBeforeGetClientConfig', this.onBeforeGetClientConfig.bind(this));
  8. this.events.on('onBeforeDropBag', this.onBeforeDropBag.bind(this));
  9. this.events.on('onBeforeGetRecipes', this.onBeforeGetRecipes.bind(this));
  10. this.events.on('onAfterGetZone', this.onAfterGetZone.bind(this));
  11. this.events.on('onAfterGetLayerObjects', this.onAfterGetLayerObjects.bind(this));
  12. },
  13. onBeforeGetClientConfig: function (config) {
  14. config.textureList.push(`${this.folderName}/images/mobs.png`);
  15. },
  16. onAfterGetZone: function (zoneName, config) {
  17. const { zoneName: dealerZoneName, zoneConfig } = dealer;
  18. const dealerName = zoneConfig.name.toLowerCase();
  19. if (zoneName !== dealerZoneName)
  20. return;
  21. zoneConfig.sheetName = zoneConfig.sheetName.replace('$MODFOLDER$', this.folderName);
  22. config.objects[dealerName] = zoneConfig;
  23. },
  24. onAfterGetLayerObjects: function ({ map, layer, objects, mapScale }) {
  25. const { zoneName: dealerZoneName, pos: { x, y }, zoneConfig: { name } } = dealer;
  26. if (map !== dealerZoneName || layer !== 'objects')
  27. return;
  28. objects.push({
  29. name,
  30. x: x * mapScale,
  31. y: y * mapScale,
  32. height: 8,
  33. width: 8,
  34. visible: true
  35. });
  36. },
  37. onBeforeGetRecipes: function (recipes) {
  38. recipes.gambling = cardRecipes;
  39. },
  40. onBeforeDropBag: function (dropper, items, looter) {
  41. if (!looter.player)
  42. return;
  43. let dropEvent = {
  44. chanceMultiplier: 1,
  45. source: dropper
  46. };
  47. looter.fireEvent('beforeGenerateLoot', dropEvent);
  48. if (Math.random() >= dropEvent.chanceMultiplier)
  49. return;
  50. let res = cards.getCard(this.folderName, looter, dropper);
  51. if (!res)
  52. return;
  53. items.push(res);
  54. }
  55. };