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.
 
 
 

42 regels
592 B

  1. const serializeProps = [
  2. 'sound',
  3. 'defaultMusic',
  4. 'volume',
  5. 'music'
  6. ];
  7. module.exports = {
  8. type: 'sound',
  9. simplified: null,
  10. buildSimplified: function () {
  11. const s = Object.fromEntries(
  12. serializeProps
  13. .map(p => {
  14. if (!this.has(p))
  15. return null;
  16. return [p, this[p]];
  17. })
  18. .filter(p => !!p)
  19. );
  20. s.type = 'sound';
  21. let file = s.sound;
  22. if (!file.includes('server'))
  23. file = 'audio/' + file;
  24. s.sound = file;
  25. this.simplified = s;
  26. },
  27. simplify: function () {
  28. if (!this.simplified)
  29. this.buildSimplified();
  30. return this.simplified;
  31. }
  32. };