bnstooltips 1.19.2 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -325,52 +325,62 @@ function getMoneyObj(money) {
325
325
  Silver: silver
326
326
  };
327
327
  }
328
- function GetSkillMasteryValue(points, isCd) {
328
+ function GetSkillMasteryValue(points, arcaneInfo) {
329
329
  if (points <= 0)
330
330
  return 0;
331
- return isCd ? GetSkillMasteryCdValueForPoints(points) : GetSkillMasteryValueForPoints(points);
331
+ return arcaneInfo.IsCooldown ? GetSkillMasteryCdValueForPoints(points, arcaneInfo.CooldownBreakpoints) : GetSkillMasteryValueForPoints(points, arcaneInfo.DamageSections);
332
332
  }
333
- function GetSkillMasteryCdValueForPoints(points) {
334
- var value = 0;
335
- if (points >= 4) {
336
- value += 1;
337
- }
338
- if (points >= 12) {
339
- value += 2;
340
- }
341
- if (points >= 24) {
342
- value += 2;
333
+ /**
334
+ * Calculates the cooldown reduction value based on skill mastery points and defined breakpoints.
335
+ *
336
+ * @param mastery - The total skill mastery points.
337
+ * @param cooldownBreakpoints - An object mapping breakpoints to their corresponding cooldown reduction values.
338
+ * @returns The total cooldown reduction value.
339
+ */
340
+ function GetSkillMasteryCdValueForPoints(mastery, cooldownBreakpoints) {
341
+ var value = 0; // Accumulator for the total cooldown reduction value
342
+ // Convert the object keys (breakpoints) to an array of numbers and sort them in ascending order
343
+ var sortedBreakpoints = Object.keys(cooldownBreakpoints)
344
+ .map(Number) // Convert string keys to numbers
345
+ .sort(function (a, b) { return a - b; }); // Sort breakpoints in ascending order
346
+ // Iterate over the sorted breakpoints
347
+ for (var _i = 0, sortedBreakpoints_1 = sortedBreakpoints; _i < sortedBreakpoints_1.length; _i++) {
348
+ var breakpoint = sortedBreakpoints_1[_i];
349
+ if (mastery >= breakpoint) {
350
+ // Add the cooldown reduction value for this breakpoint (converted from milliseconds to seconds)
351
+ value += cooldownBreakpoints[breakpoint] / 1000;
352
+ }
343
353
  }
344
- return 0 - value;
354
+ return value; // Return the total cooldown reduction value
345
355
  }
346
- function GetSkillMasteryValueForPoints(points) {
347
- var value = 0;
348
- if (points > 0) {
349
- var firstRange = Math.min(points, 15);
350
- value += firstRange * 1.9;
351
- points -= firstRange;
352
- }
353
- if (points > 0) {
354
- var secondRange = Math.min(points, 35 - 15);
355
- value += secondRange * 1.5;
356
- points -= secondRange;
357
- }
358
- if (points > 0) {
359
- var thirdRange = Math.min(points, 100 - 35);
360
- value += thirdRange * 1.1;
361
- points -= thirdRange;
362
- }
363
- if (points > 0) {
364
- var fourthRange = Math.min(points, 165 - 100);
365
- value += fourthRange * 0.7;
366
- points -= fourthRange;
367
- }
368
- if (points > 0) {
369
- var fifthRange = Math.min(points, 1000 - 165);
370
- value += fifthRange * 0.3;
371
- points -= fifthRange;
356
+ /**
357
+ * Calculates the total skill bonus based on mastery points and the given damage sections.
358
+ *
359
+ * @param mastery - The total mastery points.
360
+ * @param damageSections - An object defining breakpoints and corresponding multipliers.
361
+ * @returns The total bonus percentage.
362
+ */
363
+ function GetSkillMasteryValueForPoints(mastery, damageSections) {
364
+ var bonus = 0; // Stores the accumulated bonus percentage
365
+ var previousLimit = 0; // Keeps track of the previous breakpoint
366
+ // Iterate over the damageSections object, sorted by its keys (breakpoints)
367
+ for (var _i = 0, _a = Object.entries(damageSections); _i < _a.length; _i++) {
368
+ var _b = _a[_i], limitStr = _b[0], multiplier = _b[1];
369
+ var limit = parseInt(limitStr, 10); // Convert the key (string) to a number
370
+ if (mastery > previousLimit) {
371
+ // Calculate how many points fall within this range
372
+ var pointsInRange = Math.min(mastery - previousLimit, limit - previousLimit);
373
+ // Multiply points by the corresponding multiplier (converted to percentage)
374
+ bonus += pointsInRange * (multiplier / 10);
375
+ }
376
+ // Update the previous limit for the next iteration
377
+ previousLimit = limit;
378
+ // Stop iterating if mastery has been fully allocated
379
+ if (mastery <= limit) {
380
+ break;
381
+ }
372
382
  }
373
- return value;
383
+ return bonus;
374
384
  }
375
385
 
376
386
  //----------------------
@@ -8893,7 +8903,7 @@ function SkillConditions(_a) {
8893
8903
  }
8894
8904
 
8895
8905
  function SkillTooltip(_a) {
8896
- var data = _a.data, _b = _a.debug, debug = _b === void 0 ? false : _b, _c = _a.masteryPoints, masteryPoints = _c === void 0 ? 0 : _c, _d = _a.masteryIsCooldown, masteryIsCooldown = _d === void 0 ? false : _d;
8906
+ var data = _a.data, _b = _a.debug, debug = _b === void 0 ? false : _b, _c = _a.masteryPoints, masteryPoints = _c === void 0 ? 0 : _c;
8897
8907
  var skill = data;
8898
8908
  var tooltipBaseProps = {
8899
8909
  title: skill.Name,
@@ -8913,7 +8923,7 @@ function SkillTooltip(_a) {
8913
8923
  //bottomPart
8914
8924
  AddSubTexts(tooltipBaseProps.subInfoGroups, skill);
8915
8925
  AddBreakValue(tooltipBaseProps.subInfoGroups, skill);
8916
- AddSkillMastery(tooltipBaseProps.subInfoGroups, masteryPoints, masteryIsCooldown);
8926
+ AddSkillMastery(tooltipBaseProps.subInfoGroups, masteryPoints, skill.ArcaneInfo);
8917
8927
  AddPvpModifiers(tooltipBaseProps.subInfoGroups, skill);
8918
8928
  AddBoundaries(tooltipBaseProps.subInfoGroups, skill);
8919
8929
  AddConditions(tooltipBaseProps.subInfoGroups, skill);
@@ -8965,10 +8975,10 @@ function AddBreakValue(subInfoGroups, skill) {
8965
8975
  });
8966
8976
  }
8967
8977
  }
8968
- function AddSkillMastery(subInfoGroups, masteryPoints, masteryIsCooldown) {
8969
- if (masteryPoints == null || masteryPoints == 0)
8978
+ function AddSkillMastery(subInfoGroups, masteryPoints, arcaneInfo) {
8979
+ if (masteryPoints == null || masteryPoints == 0 || arcaneInfo == null)
8970
8980
  return;
8971
- var masteryValue = GetSkillMasteryValue(masteryPoints, masteryIsCooldown);
8981
+ var masteryValue = GetSkillMasteryValue(masteryPoints, arcaneInfo);
8972
8982
  if (masteryValue == null || masteryValue == 0)
8973
8983
  return;
8974
8984
  var formattedMasteryValue = Number.isInteger(masteryValue) ? masteryValue.toString() : masteryValue.toFixed(2).replace(',', '.');
@@ -8980,7 +8990,7 @@ function AddSkillMastery(subInfoGroups, masteryPoints, masteryIsCooldown) {
8980
8990
  React__default["default"].createElement("span", { className: "tooltipArg", style: { fontSize: "14px" } }, "Skill Grandmaster"),
8981
8991
  React__default["default"].createElement("div", { className: "arcanemark" }),
8982
8992
  React__default["default"].createElement("span", { className: "tooltipArg", style: { fontSize: "14px" } }, masteryPoints)),
8983
- !masteryIsCooldown ?
8993
+ !arcaneInfo.IsCooldown ?
8984
8994
  React__default["default"].createElement("div", null,
8985
8995
  "Damage increase:\u00A0",
8986
8996
  React__default["default"].createElement("span", { className: "tooltipArg" },
@@ -9203,9 +9213,9 @@ var css_248z$5 = ".TooltipBase_bns_upgradeRed_color {\n color: #FF2818;\n}\n\n.
9203
9213
  styleInject(css_248z$5);
9204
9214
 
9205
9215
  var SkillTooltipWrapper = function (_a) {
9206
- var data = _a.data, children = _a.children, _b = _a.interactive, interactive = _b === void 0 ? false : _b, _c = _a.placement, placement = _c === void 0 ? "right" : _c, _d = _a.followCursor, followCursor$1 = _d === void 0 ? false : _d, _e = _a.trigger, trigger = _e === void 0 ? "mouseenter focus" : _e, _f = _a.showArrow, showArrow = _f === void 0 ? true : _f, _g = _a.debug, debug = _g === void 0 ? false : _g, _h = _a.masteryPoints, masteryPoints = _h === void 0 ? 0 : _h, _j = _a.masteryIsCooldown, masteryIsCooldown = _j === void 0 ? false : _j;
9216
+ var data = _a.data, children = _a.children, _b = _a.interactive, interactive = _b === void 0 ? false : _b, _c = _a.placement, placement = _c === void 0 ? "right" : _c, _d = _a.followCursor, followCursor$1 = _d === void 0 ? false : _d, _e = _a.trigger, trigger = _e === void 0 ? "mouseenter focus" : _e, _f = _a.showArrow, showArrow = _f === void 0 ? true : _f, _g = _a.debug, debug = _g === void 0 ? false : _g, _h = _a.masteryPoints, masteryPoints = _h === void 0 ? 0 : _h;
9207
9217
  var spanRef = React.useRef(null);
9208
- var _k = React.useState(null), childRef = _k[0], setChildRef = _k[1];
9218
+ var _j = React.useState(null), childRef = _j[0], setChildRef = _j[1];
9209
9219
  /**
9210
9220
  * Mount the temporary span element.
9211
9221
  * retrieve and store the target element's reference.
@@ -9218,7 +9228,7 @@ var SkillTooltipWrapper = function (_a) {
9218
9228
  }, []);
9219
9229
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
9220
9230
  children,
9221
- childRef ? (React__default["default"].createElement(Tippy, { arrow: showArrow, trigger: trigger, plugins: [followCursor], followCursor: followCursor$1 && (!interactive && !debug), appendTo: document.body, placement: placement, animation: "fade", interactive: interactive || debug, content: React__default["default"].createElement(SkillTooltip, { data: data, debug: debug, masteryPoints: masteryPoints, masteryIsCooldown: masteryIsCooldown }), theme: "grade" + 4, reference: childRef })) : (React__default["default"].createElement("span", { "data-testid": "TooltipWrapper", ref: spanRef, style: { display: "none" } }))));
9231
+ childRef ? (React__default["default"].createElement(Tippy, { arrow: showArrow, trigger: trigger, plugins: [followCursor], followCursor: followCursor$1 && (!interactive && !debug), appendTo: document.body, placement: placement, animation: "fade", interactive: interactive || debug, content: React__default["default"].createElement(SkillTooltip, { data: data, debug: debug, masteryPoints: masteryPoints }), theme: "grade" + 4, reference: childRef })) : (React__default["default"].createElement("span", { "data-testid": "TooltipWrapper", ref: spanRef, style: { display: "none" } }))));
9222
9232
  };
9223
9233
 
9224
9234
  exports.ServerRegion = void 0;