You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

86 line
1.7 KiB

  1. define([
  2. ], function (
  3. ) {
  4. return {
  5. rewards: [],
  6. init: function (hideMessage) {
  7. if (!this.build())
  8. return false;
  9. this.obj.syncer.setArray(true, 'quests', 'obtainQuests', this.simplify(true));
  10. if (!hideMessage) {
  11. this.obj.instance.syncer.queue('onGetMessages', {
  12. id: this.obj.id,
  13. messages: [{
  14. class: 'color-yellowB',
  15. message: 'quest obtained (' + this.name + ')'
  16. }]
  17. }, [this.obj.serverId]);
  18. }
  19. return true;
  20. },
  21. ready: function () {
  22. this.isReady = true;
  23. if (this.oReady)
  24. this.oReady();
  25. this.obj.instance.syncer.queue('onGetMessages', {
  26. id: this.obj.id,
  27. messages: [{
  28. class: 'color-yellowB',
  29. message: 'quest ready for turn-in (' + this.name + ')'
  30. }]
  31. }, [this.obj.serverId]);
  32. this.obj.syncer.setArray(true, 'quests', 'updateQuests', this.simplify(true));
  33. },
  34. complete: function () {
  35. if (this.oComplete)
  36. this.oComplete();
  37. var obj = this.obj;
  38. this.obj.instance.eventEmitter.emitNoSticky('beforeCompleteAutoquest', this, obj);
  39. obj.instance.syncer.queue('onGetMessages', {
  40. id: obj.id,
  41. messages: [{
  42. class: 'color-yellowB',
  43. message: 'quest completed (' + this.name + ')'
  44. }]
  45. }, [obj.serverId]);
  46. obj.syncer.setArray(true, 'quests', 'completeQuests', this.id);
  47. this.obj.instance.eventEmitter.emit('onCompleteQuest', this);
  48. this.rewards.forEach(function (r) {
  49. this.obj.inventory.getItem(r);
  50. }, this);
  51. this.obj.stats.getXp(this.xp || 10, this.obj, this);
  52. },
  53. simplify: function (self) {
  54. var values = {};
  55. for (var p in this) {
  56. var value = this[p];
  57. if ((typeof (value) == 'function') || (p == 'obj'))
  58. continue;
  59. values[p] = value;
  60. }
  61. return values;
  62. }
  63. };
  64. });