AttributeBase.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. Object.defineProperty(i, "__esModule", {value: !0}), (i.AttributeBase = i.AttributeGroppKey = void 0);
  5. e = t("CostumeConst");
  6. ((t = i.AttributeGroppKey || (i.AttributeGroppKey = {}))[(t.BASE = 0)] = "BASE"), (t[(t.BUFF = 1)] = "BUFF");
  7. const h = {[e.CostumeAbilityType.doublebase]: e.CostumeAbilityType.base};
  8. i.AttributeBase = class {
  9. constructor() {
  10. (this.finalAttr = null),
  11. (this.attrGroups = null),
  12. (this.attrBites = null),
  13. (this.isNeedReCal = !1),
  14. this.reset();
  15. }
  16. addAttrBute(t, e) {
  17. (this.isNeedReCal = !0), (this.attrBites[t] = e);
  18. }
  19. removeAttrBute(t) {
  20. (this.isNeedReCal = !0), delete this.attrBites[t];
  21. }
  22. getAttrBute(t) {
  23. return this.attrBites[t];
  24. }
  25. addAttrDict(t, e) {
  26. (this.isNeedReCal = !0), (this.attrGroups[t] = e);
  27. }
  28. getAttrDict(t) {
  29. return this.attrGroups[t];
  30. }
  31. removeAttrDict(t) {
  32. (this.isNeedReCal = !0), delete this.attrGroups[t];
  33. }
  34. addAttrValue(t, e, i) {
  35. (this.isNeedReCal = !0), this.attrGroups[t] ? (this.attrGroups[t][e] = i) : (this.attrGroups[t] = {[e]: i});
  36. }
  37. removeAttrValue(t, e) {
  38. (this.isNeedReCal = !0), this.attrGroups[t] && delete this.attrGroups[t][e];
  39. }
  40. toString() {
  41. return `\u653b\u51fb:${this.finalAttr.ap}, \u6218\u529b:${this.finalAttr.power}, HP:${this.finalAttr.hp}, \u66b4\u51fb\u7387:${this.finalAttr.crit}, \u95ea\u907f\u7387:${this.finalAttr.dodge}`;
  42. }
  43. claFinishAttr() {
  44. const i = (this.finalAttr = Object.create(null));
  45. for (const e in this.attrGroups) {
  46. var s,
  47. o = this.attrGroups[e];
  48. for (s in o) {
  49. let t = o[s],
  50. e = i[s];
  51. null == e && (e = 0), (i[s] = e + t);
  52. }
  53. }
  54. for (const r in this.attrBites) {
  55. var a,
  56. n = this.attrBites[r].finalAttr;
  57. for (a in n) {
  58. let t = n[a],
  59. e = i[a];
  60. null == e && (e = 0), (i[a] = e + t);
  61. }
  62. }
  63. for (const l in i) {
  64. var t = h[l];
  65. t && i[t] && ((i[t] = (i[t] * i[l]) / 100), delete i[l]);
  66. }
  67. }
  68. reset() {
  69. (this.finalAttr = Object.create(null)),
  70. (this.attrGroups = Object.create(null)),
  71. (this.attrBites = Object.create(null));
  72. }
  73. };