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.
 
 
 

72 lines
1.5 KiB

  1. define([
  2. 'js/system/events',
  3. 'js/system/client',
  4. 'html!ui/templates/death/template',
  5. 'css!ui/templates/death/styles'
  6. ], function (
  7. events,
  8. client,
  9. template,
  10. styles
  11. ) {
  12. return {
  13. tpl: template,
  14. modal: true,
  15. centered: true,
  16. postRender: function () {
  17. this.onEvent('onDeath', this.onDeath.bind(this));
  18. this.onEvent('onPermadeath', this.onPermadeath.bind(this));
  19. this.find('.btn-logout').on('click', this.onLogout.bind(this));
  20. this.find('.btn-respawn').on('click', this.onRespawn.bind(this));
  21. },
  22. onLogout: function () {
  23. $('.uiOptions').data('ui').charSelect();
  24. },
  25. onRespawn: function () {
  26. events.emit('onHideOverlay', this.el);
  27. this.hide();
  28. client.request({
  29. cpn: 'player',
  30. method: 'performAction',
  31. data: {
  32. cpn: 'stats',
  33. method: 'respawn'
  34. }
  35. });
  36. },
  37. doShow: function () {
  38. this.show();
  39. events.emit('onShowOverlay', this.el);
  40. },
  41. onDeath: function (event) {
  42. if (!event.source)
  43. this.find('.msg').html('you are dead');
  44. else
  45. this.find('.msg').html('you were killed by [ <div class="inner">' + event.source + '</div> ]');
  46. this.find('.penalty')
  47. .html('you lost ' + event.xpLoss + ' experience')
  48. .show();
  49. if (!event.xpLoss)
  50. this.find('.penalty').hide();
  51. this.el.removeClass('permadeath');
  52. this.doShow();
  53. },
  54. onPermadeath: function (event) {
  55. this.find('.msg').html('you were killed by [ <div class="inner">' + event.source + '</div> ]');
  56. this.el.addClass('permadeath');
  57. this.doShow();
  58. }
  59. };
  60. });