Você não pode selecionar mais de 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.
 
 
 

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