Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

66 строки
1.6 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('onBeforeDropBag', this.onBeforeDropBag.bind(this));
  8. this.events.on('onBeforeGetRecipes', this.onBeforeGetRecipes.bind(this));
  9. this.events.on('onAfterGetZone', this.onAfterGetZone.bind(this));
  10. this.events.on('onAfterGetLayerObjects', this.onAfterGetLayerObjects.bind(this));
  11. },
  12. onAfterGetZone: function (zoneName, config) {
  13. const { zoneName: dealerZoneName, zoneConfig } = dealer;
  14. const dealerName = zoneConfig.name.toLowerCase();
  15. if (zoneName !== dealerZoneName)
  16. return;
  17. zoneConfig.sheetName = zoneConfig.sheetName.replace('$MODFOLDER$', this.folderName);
  18. config.objects[dealerName] = zoneConfig;
  19. },
  20. onAfterGetLayerObjects: function ({ map, layer, objects, mapScale }) {
  21. const { zoneName: dealerZoneName, pos: { x, y }, zoneConfig: { name } } = dealer;
  22. if (map !== dealerZoneName || layer !== 'objects')
  23. return;
  24. objects.push({
  25. name,
  26. x: x * mapScale,
  27. y: y * mapScale,
  28. height: 8,
  29. width: 8,
  30. visible: true
  31. });
  32. },
  33. onBeforeGetRecipes: function (recipes) {
  34. recipes.gambling = cardRecipes;
  35. },
  36. onBeforeDropBag: function (dropper, items, looter) {
  37. if (!looter.player)
  38. return;
  39. let dropEvent = {
  40. chanceMultiplier: 1,
  41. source: dropper
  42. };
  43. looter.fireEvent('beforeGenerateLoot', dropEvent);
  44. if (Math.random() >= dropEvent.chanceMultiplier)
  45. return;
  46. let res = cards.getCard(this.folderName, looter, dropper);
  47. if (!res)
  48. return;
  49. items.push(res);
  50. }
  51. };