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.
 
 
 

84 satır
1.8 KiB

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