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.
 
 
 

80 line
1.6 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.performRespawn.bind(this));
  21. },
  22. onLogout: function () {
  23. $('.uiMainMenu').data('ui').charSelect();
  24. },
  25. performRespawn: function () {
  26. events.emit('onHideOverlay', this.el);
  27. this.hide(true);
  28. client.request({
  29. cpn: 'player',
  30. method: 'performAction',
  31. data: {
  32. cpn: 'stats',
  33. method: 'respawn'
  34. }
  35. });
  36. },
  37. hide: function (force) {
  38. if (!force)
  39. return;
  40. this.shown = false;
  41. this.el.hide();
  42. },
  43. doShow: function () {
  44. this.show();
  45. events.emit('onShowOverlay', this.el);
  46. },
  47. onDeath: function (eventObj) {
  48. if (!eventObj.source)
  49. this.find('.msg').html('you are dead');
  50. else
  51. this.find('.msg').html('you were killed by [ <div class="inner">' + eventObj.source + '</div> ]');
  52. this.find('.penalty')
  53. .html('you lost ' + eventObj.xpLoss + ' experience')
  54. .show();
  55. if (!eventObj.xpLoss)
  56. this.find('.penalty').hide();
  57. this.el.removeClass('permadeath');
  58. this.doShow();
  59. },
  60. onPermadeath: function (eventObj) {
  61. this.find('.msg').html('you were killed by [ <div class="inner">' + eventObj.source + '</div> ]');
  62. this.el.addClass('permadeath');
  63. this.doShow();
  64. }
  65. };
  66. });