koishi-plugin-smmcat-gensokyo 0.0.34 → 0.0.36

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 +106 -43
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -31,10 +31,10 @@ var import_koishi2 = require("koishi");
31
31
  // src/data/benchmark.ts
32
32
  var monsterBenchmark = {
33
33
  10: {
34
- hp: 1.4,
35
- maxHp: 1.4,
36
- mp: 1.2,
37
- maxMp: 1.2,
34
+ hp: 1.2,
35
+ maxHp: 1.2,
36
+ mp: 1.1,
37
+ maxMp: 1.1,
38
38
  atk: 1.2,
39
39
  def: 1.1,
40
40
  chr: 1.1,
@@ -44,8 +44,8 @@ var monsterBenchmark = {
44
44
  speed: 1.05
45
45
  },
46
46
  20: {
47
- hp: 1.35,
48
- maxHp: 1.35,
47
+ hp: 1.1,
48
+ maxHp: 1.1,
49
49
  mp: 1.1,
50
50
  maxMp: 1.1,
51
51
  atk: 1.1,
@@ -57,8 +57,8 @@ var monsterBenchmark = {
57
57
  speed: 1.05
58
58
  },
59
59
  40: {
60
- hp: 1.2,
61
- maxHp: 1.2,
60
+ hp: 1.08,
61
+ maxHp: 1.08,
62
62
  mp: 1.05,
63
63
  maxMp: 1.05,
64
64
  atk: 1.1,
@@ -72,7 +72,7 @@ var monsterBenchmark = {
72
72
  };
73
73
  var userBenchmark = {
74
74
  10: {
75
- maxExp: 2,
75
+ maxExp: 1.5,
76
76
  maxHp: 1.2,
77
77
  maxMp: 1.1,
78
78
  atk: 1.12,
@@ -84,7 +84,7 @@ var userBenchmark = {
84
84
  speed: 1.05
85
85
  },
86
86
  20: {
87
- maxExp: 1.8,
87
+ maxExp: 1.3,
88
88
  maxHp: 1.15,
89
89
  maxMp: 1.1,
90
90
  atk: 1.1,
@@ -96,7 +96,7 @@ var userBenchmark = {
96
96
  speed: 1.05
97
97
  },
98
98
  40: {
99
- maxExp: 1.5,
99
+ maxExp: 1.1,
100
100
  maxHp: 1.1,
101
101
  maxMp: 1.05,
102
102
  atk: 1.1,
@@ -356,27 +356,48 @@ var Monster = {
356
356
  getMonsterAttributeData(monsterName, lv) {
357
357
  const monster = Monster.monsterTempData[monsterName];
358
358
  if (!monster) return null;
359
- const temp = { lv };
359
+ const temp = { lv, ...monster };
360
360
  const lvScope = Object.keys(monsterBenchmark).reverse().find((item) => Number(item) < lv) || 10;
361
361
  const useBenchmark = monsterBenchmark[lvScope];
362
362
  console.log(useBenchmark);
363
- Object.keys(monster).forEach((i) => {
364
- temp[i] = monster[i];
365
- if (useBenchmark[i]) {
366
- const upVal = Math.floor(temp[i] * (useBenchmark[i] - 1) * (lv - 1));
367
- if (upVal > 0) {
368
- temp[i] += upVal;
369
- } else {
370
- switch (i) {
371
- case "hit":
372
- temp[i] += 20 * (lv - 1);
373
- break;
374
- default:
375
- break;
376
- }
363
+ if (lv <= 1) {
364
+ return temp;
365
+ }
366
+ const levelStages = [
367
+ { maxLevel: 10, benchmark: monsterBenchmark[10] },
368
+ { maxLevel: 20, benchmark: monsterBenchmark[20] },
369
+ { maxLevel: Infinity, benchmark: monsterBenchmark[40] }
370
+ ];
371
+ for (let level = 2; level <= lv; level++) {
372
+ let currentBenchmark = null;
373
+ for (const stage of levelStages) {
374
+ if (level <= stage.maxLevel) {
375
+ currentBenchmark = stage.benchmark;
376
+ break;
377
377
  }
378
378
  }
379
- });
379
+ if (!currentBenchmark) continue;
380
+ temp.maxHp *= currentBenchmark.maxHp;
381
+ temp.maxMp *= currentBenchmark.maxMp;
382
+ temp.atk *= currentBenchmark.atk;
383
+ temp.def *= currentBenchmark.def;
384
+ temp.chr *= currentBenchmark.chr;
385
+ temp.evasion *= currentBenchmark.evasion;
386
+ temp.hit *= currentBenchmark.hit;
387
+ temp.ghd *= currentBenchmark.ghd;
388
+ temp.speed *= currentBenchmark.speed;
389
+ }
390
+ temp.hp = Math.floor(temp.maxHp);
391
+ temp.mp = Math.floor(temp.maxMp);
392
+ temp.maxHp = Math.floor(temp.maxHp);
393
+ temp.maxMp = Math.floor(temp.maxMp);
394
+ temp.atk = Math.floor(temp.atk);
395
+ temp.def = Math.floor(temp.def);
396
+ temp.chr = Math.floor(temp.chr);
397
+ temp.evasion = Math.floor(temp.evasion);
398
+ temp.hit = Math.floor(temp.hit);
399
+ temp.ghd = Math.floor(temp.ghd);
400
+ temp.speed = Math.round(temp.speed);
380
401
  return temp;
381
402
  },
382
403
  /** 格式化怪物属性数据 */
@@ -405,13 +426,16 @@ var random = /* @__PURE__ */ __name((min, max) => {
405
426
  return Math.floor(Math.random() * (max - min + 1)) + min;
406
427
  }, "random");
407
428
  var generateHealthDisplay = /* @__PURE__ */ __name((current, total) => {
408
- const ratio = current / total;
409
429
  const displayLength = 10;
410
- const filledLength = Math.floor(ratio * displayLength);
430
+ const filledChar = "■";
431
+ const unfilledChar = "□";
432
+ const clampedCurrent = Math.max(0, Math.min(current, total));
433
+ const ratio = clampedCurrent / total;
434
+ const filledLength = Math.max(0, Math.min(Math.floor(ratio * displayLength), displayLength));
411
435
  const unfilledLength = displayLength - filledLength;
412
- const filled = "■".repeat(filledLength);
413
- const unfilled = "□".repeat(unfilledLength);
414
- return filled + unfilled;
436
+ const filled = filledChar.repeat(filledLength);
437
+ const unfilled = unfilledChar.repeat(unfilledLength);
438
+ return `${filled}${unfilled}`;
415
439
  }, "generateHealthDisplay");
416
440
  var getFreeList = /* @__PURE__ */ __name((arr) => {
417
441
  let arrAdd = [...arr];
@@ -1976,19 +2000,58 @@ var User = {
1976
2000
  userId: UserDict.userId
1977
2001
  };
1978
2002
  const lv = UserData.lv;
1979
- const temp = {};
1980
- const lvScope = Object.keys(userBenchmark).reverse().find((item) => Number(item) < lv) || 10;
1981
- const useBenchmark = userBenchmark[lvScope];
1982
- Object.keys(UserData).forEach((i) => {
1983
- temp[i] = UserData[i];
1984
- if (useBenchmark[i]) {
1985
- if (i == "maxExp") {
1986
- temp[i] = Math.floor(100 * useBenchmark[i] * (lv - 1)) || 100;
1987
- } else {
1988
- temp[i] += Math.floor(temp[i] * (useBenchmark[i] - 1) * (lv - 1));
2003
+ const temp = {
2004
+ ...UserData,
2005
+ maxExp: UserData.maxExp,
2006
+ maxHp: UserData.maxHp,
2007
+ maxMp: UserData.maxMp,
2008
+ maxPp: UserData.maxPp || 100,
2009
+ // 添加默认值
2010
+ type: UserDict.type,
2011
+ // 添加职业类型
2012
+ csr: UserData.csr || 0
2013
+ // 添加暴击抵抗
2014
+ };
2015
+ if (lv <= 1) {
2016
+ return temp;
2017
+ }
2018
+ const levelStages = [
2019
+ { maxLevel: 10, benchmark: userBenchmark[10] },
2020
+ { maxLevel: 20, benchmark: userBenchmark[20] },
2021
+ { maxLevel: Infinity, benchmark: userBenchmark[40] }
2022
+ ];
2023
+ for (let level = 2; level <= lv; level++) {
2024
+ let currentBenchmark = null;
2025
+ for (const stage of levelStages) {
2026
+ if (level <= stage.maxLevel) {
2027
+ currentBenchmark = stage.benchmark;
2028
+ break;
1989
2029
  }
1990
2030
  }
1991
- });
2031
+ if (!currentBenchmark) continue;
2032
+ temp.maxExp *= currentBenchmark.maxExp;
2033
+ temp.maxHp *= currentBenchmark.maxHp;
2034
+ temp.maxMp *= currentBenchmark.maxMp;
2035
+ temp.atk *= currentBenchmark.atk;
2036
+ temp.def *= currentBenchmark.def;
2037
+ temp.chr *= currentBenchmark.chr;
2038
+ temp.evasion *= currentBenchmark.evasion;
2039
+ temp.hit *= currentBenchmark.hit;
2040
+ temp.ghd *= currentBenchmark.ghd;
2041
+ temp.speed *= currentBenchmark.speed;
2042
+ }
2043
+ temp.hp = Math.min(temp.hp, temp.maxHp);
2044
+ temp.mp = Math.min(temp.mp, temp.maxMp);
2045
+ temp.maxExp = Math.floor(temp.maxExp);
2046
+ temp.maxHp = Math.floor(temp.maxHp);
2047
+ temp.maxMp = Math.floor(temp.maxMp);
2048
+ temp.atk = Math.floor(temp.atk);
2049
+ temp.def = Math.floor(temp.def);
2050
+ temp.chr = Math.floor(temp.chr);
2051
+ temp.evasion = Math.floor(temp.evasion);
2052
+ temp.hit = Math.floor(temp.hit);
2053
+ temp.ghd = Math.floor(temp.ghd);
2054
+ temp.speed = Math.round(temp.speed);
1992
2055
  return temp;
1993
2056
  },
1994
2057
  /** 通过 userId 获取角色属性 */
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.36",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [