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.
 
 
 

67 lines
1.4 KiB

  1. define([
  2. 'js/system/events',
  3. 'html!ui/templates/tooltipInfo/template',
  4. 'css!ui/templates/tooltipInfo/styles'
  5. ], function (
  6. events,
  7. template,
  8. styles
  9. ) {
  10. return {
  11. tpl: template,
  12. lastHp: null,
  13. lastHpMax: null,
  14. mob: null,
  15. postRender: function () {
  16. this.onEvent('onMobHover', this.onMobHover.bind(this));
  17. this.hide();
  18. },
  19. onMobHover: function (mob) {
  20. this.mob = mob;
  21. if (!mob) {
  22. this.el.hide();
  23. return;
  24. }
  25. let values = mob.stats.values;
  26. this.lastHp = values.hp;
  27. this.lastHpMax = values.hpMax;
  28. let html = mob.name + ' (' + mob.stats.values.level + ')';
  29. if (mob.stats.values.level - 5 >= window.player.stats.values.level)
  30. html = '<font class="color-red">' + html + '</font>';
  31. if (mob.aggro) {
  32. //TODO: Figure this out some other wayh since factions interact in different ways now
  33. if (mob.aggro.faction === 'hostile')
  34. html += '<br />aggressive';
  35. }
  36. html += '<br />hp: ' + Math.floor(mob.stats.values.hp) + '/' + Math.floor(mob.stats.values.hpMax);
  37. this.el.show();
  38. this.el.html(html);
  39. },
  40. update: function () {
  41. let mob = this.mob;
  42. if (!mob)
  43. return;
  44. if (mob.destroyed) {
  45. this.mob = null;
  46. this.el.hide();
  47. } else {
  48. let values = mob.stats.values;
  49. if (values.hp !== this.lastHp)
  50. this.onMobHover(mob);
  51. else if (values.hpMax !== this.lastHpMax)
  52. this.onMobHover(mob);
  53. }
  54. }
  55. };
  56. });