koishi-plugin-smmcat-gensokyo 0.0.34 → 0.0.35

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.
Files changed (2) hide show
  1. package/lib/index.js +8 -5
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -405,13 +405,16 @@ var random = /* @__PURE__ */ __name((min, max) => {
405
405
  return Math.floor(Math.random() * (max - min + 1)) + min;
406
406
  }, "random");
407
407
  var generateHealthDisplay = /* @__PURE__ */ __name((current, total) => {
408
- const ratio = current / total;
409
408
  const displayLength = 10;
410
- const filledLength = Math.floor(ratio * displayLength);
409
+ const filledChar = "■";
410
+ const unfilledChar = "□";
411
+ const clampedCurrent = Math.max(0, Math.min(current, total));
412
+ const ratio = clampedCurrent / total;
413
+ const filledLength = Math.max(0, Math.min(Math.floor(ratio * displayLength), displayLength));
411
414
  const unfilledLength = displayLength - filledLength;
412
- const filled = "■".repeat(filledLength);
413
- const unfilled = "□".repeat(unfilledLength);
414
- return filled + unfilled;
415
+ const filled = filledChar.repeat(filledLength);
416
+ const unfilled = unfilledChar.repeat(unfilledLength);
417
+ return `${filled}${unfilled} (${current}/${total})`;
415
418
  }, "generateHealthDisplay");
416
419
  var getFreeList = /* @__PURE__ */ __name((arr) => {
417
420
  let arrAdd = [...arr];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-smmcat-gensokyo",
3
3
  "description": "名为《幻想乡》的文字冒险游戏",
4
- "version": "0.0.34",
4
+ "version": "0.0.35",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [