Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

71 lignes
1.2 KiB

  1. module.exports = {
  2. type: 'prophecies',
  3. list: [],
  4. init: function (blueprint) {
  5. (blueprint.list || []).forEach(function (p) {
  6. let template = null;
  7. try {
  8. template = require('../config/prophecies/' + p);
  9. } catch (e) {}
  10. if (!template)
  11. return;
  12. else if (this.list.some(l => (l.type === p)))
  13. return;
  14. let prophecy = extend({}, template);
  15. prophecy.obj = this.obj;
  16. prophecy.init();
  17. this.list.push(prophecy);
  18. }, this);
  19. delete blueprint.list;
  20. },
  21. hasProphecy: function (type) {
  22. return this.list.some(l => (l.type === type));
  23. },
  24. transfer: function () {
  25. let transferList = this.list;
  26. this.list = [];
  27. this.init({
  28. list: transferList
  29. });
  30. },
  31. fireEvent: function (event, args) {
  32. let list = this.list;
  33. let lLen = list.length;
  34. for (let i = 0; i < lLen; i++) {
  35. let l = list[i];
  36. let events = l.events;
  37. if (!events)
  38. continue;
  39. let callback = events[event];
  40. if (!callback)
  41. continue;
  42. callback.apply(l, args);
  43. }
  44. },
  45. simplify: function (self) {
  46. let e = {
  47. type: 'prophecies'
  48. };
  49. if ((this.list.length > 0) && (this.list[0].simplify))
  50. e.list = this.list.map(p => p.simplify());
  51. else
  52. e.list = this.list;
  53. return e;
  54. }
  55. };