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.
 
 
 

96 lines
2.1 KiB

  1. define([
  2. ], function (
  3. ) {
  4. return {
  5. accounts: {
  6. waffle: {
  7. level: 10,
  8. messageStyle: 'color-cyan',
  9. messagePrefix: '(dev) ',
  10. items: [{
  11. type: 'key',
  12. name: 'Key to the world',
  13. sprite: [12, 0],
  14. keyId: 'world'
  15. }],
  16. skins: [
  17. '1.1', '1.2', '1.3', '1.4', '1.5'
  18. ]
  19. }
  20. },
  21. onBeforePlayerEnterGame: function (obj, blueprint) {
  22. var account = obj.account;
  23. var config = this.accounts[account] || {};
  24. if (config.items) {
  25. var blueprintInventory = blueprint.components.find(c => (c.type == 'inventory'));
  26. if (!blueprintInventory) {
  27. blueprint.components.push({
  28. type: 'inventory',
  29. items: []
  30. });
  31. return;
  32. } else if (!blueprintInventory.items)
  33. blueprintInventory.items = [];
  34. var items = blueprintInventory.items;
  35. config.items.forEach(function (item) {
  36. var hasItem = items.find(i => (i.name == item.name));
  37. if (hasItem)
  38. return;
  39. items.push(item);
  40. }, this);
  41. }
  42. },
  43. getRoleLevel: function (player) {
  44. var account = player.account;
  45. var level = this.accounts[account] ? this.accounts[account].level : 0;
  46. return level;
  47. },
  48. isRoleLevel: function (player, requireLevel, message) {
  49. var account = player.account;
  50. var level = this.accounts[account] ? this.accounts[account].level : 0;
  51. var success = (level >= requireLevel);
  52. if ((!success) && (message))
  53. this.sendMessage(player, message);
  54. return success;
  55. },
  56. getRoleMessageStyle: function (player) {
  57. var account = player.account;
  58. return this.accounts[account] ? this.accounts[account].messageStyle : null;
  59. },
  60. getRoleMessagePrefix: function (player) {
  61. var account = player.account;
  62. return this.accounts[account] ? this.accounts[account].messagePrefix : null;
  63. },
  64. getSkins: function (account) {
  65. return this.accounts[account] ? this.accounts[account].skins : [];
  66. },
  67. sendMessage: function (player, msg) {
  68. msg = 'Only certain roles can ' + msg + ' at the moment';
  69. player.instance.syncer.queue('onGetMessages', {
  70. id: player.id,
  71. messages: {
  72. class: 'color-green',
  73. message: msg
  74. }
  75. }, [player.serverId]);
  76. }
  77. };
  78. });