25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

83 satır
1.9 KiB

  1. module.exports = {
  2. type: 'gatherResource',
  3. need: null,
  4. gatherType: null,
  5. requiredQuality: 0,
  6. have: 0,
  7. build: function () {
  8. if (!this.need) {
  9. const { quantity, subType } = this;
  10. this.need = quantity[0] + ~~(Math.random() * (quantity[1] - quantity[0]));
  11. this.gatherType = subType ?? ['herb', 'fish'][~~(Math.random() * 2)];
  12. if (this.gatherType === 'fish') {
  13. this.name = 'Lure of the Sea';
  14. let isQualityQ = (Math.random() < 0.3);
  15. if (isQualityQ) {
  16. this.requiredQuality = 1 + ~~(Math.random() * 2);
  17. this.need = 1;
  18. }
  19. }
  20. }
  21. if (['herb', 'fish'].indexOf(this.gatherType) === -1)
  22. this.gatherType = 'herb';
  23. this.typeName = (this.gatherType === 'herb') ? 'herbs' : 'fish';
  24. this.updateDescription();
  25. return true;
  26. },
  27. getXpMultiplier: function () {
  28. if (this.requiredQuality === 2)
  29. return 8;
  30. else if (this.requiredQuality === 1)
  31. return 6;
  32. return this.need;
  33. },
  34. updateDescription: function () {
  35. let typeName = this.typeName;
  36. if (this.requiredQuality > 0)
  37. typeName = ['big', 'giant'][this.requiredQuality - 1] + ' ' + typeName;
  38. let action = ({
  39. herb: 'Gather',
  40. fish: 'Catch'
  41. })[this.gatherType];
  42. this.description = `${action} ${this.have}/${this.need} ${typeName}`;
  43. },
  44. events: {
  45. afterGatherResource: function (gatherResult) {
  46. if (gatherResult.nodeType !== this.gatherType)
  47. return;
  48. else if ((this.requiredQuality) && (gatherResult.items[0].quality < this.requiredQuality))
  49. return;
  50. else if (gatherResult.items[0].name.toLowerCase() === 'cerulean pearl') {
  51. //This is a hack but we have no other way to tell fish from pearls at the moment
  52. return;
  53. }
  54. if ((this.obj.zoneName !== this.zoneName) || (this.have >= this.need))
  55. return;
  56. this.have++;
  57. this.updateDescription();
  58. this.obj.syncer.setArray(true, 'quests', 'updateQuests', this.simplify(true));
  59. if (this.have >= this.need)
  60. this.ready();
  61. }
  62. }
  63. };