koishi-plugin-smmcat-gensokyo 0.0.35 → 0.0.37
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/lib/index.js +184 -82
- package/lib/map.d.ts +2 -0
- 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.
|
|
35
|
-
maxHp: 1.
|
|
36
|
-
mp: 1.
|
|
37
|
-
maxMp: 1.
|
|
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.
|
|
48
|
-
maxHp: 1.
|
|
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.
|
|
61
|
-
maxHp: 1.
|
|
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:
|
|
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.
|
|
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.
|
|
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
|
-
|
|
364
|
-
temp
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
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
|
/** 格式化怪物属性数据 */
|
|
@@ -414,7 +435,7 @@ var generateHealthDisplay = /* @__PURE__ */ __name((current, total) => {
|
|
|
414
435
|
const unfilledLength = displayLength - filledLength;
|
|
415
436
|
const filled = filledChar.repeat(filledLength);
|
|
416
437
|
const unfilled = unfilledChar.repeat(unfilledLength);
|
|
417
|
-
return `${filled}${unfilled}
|
|
438
|
+
return `${filled}${unfilled}`;
|
|
418
439
|
}, "generateHealthDisplay");
|
|
419
440
|
var getFreeList = /* @__PURE__ */ __name((arr) => {
|
|
420
441
|
let arrAdd = [...arr];
|
|
@@ -1979,19 +2000,58 @@ var User = {
|
|
|
1979
2000
|
userId: UserDict.userId
|
|
1980
2001
|
};
|
|
1981
2002
|
const lv = UserData.lv;
|
|
1982
|
-
const temp = {
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
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;
|
|
1992
2029
|
}
|
|
1993
2030
|
}
|
|
1994
|
-
|
|
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);
|
|
1995
2055
|
return temp;
|
|
1996
2056
|
},
|
|
1997
2057
|
/** 通过 userId 获取角色属性 */
|
|
@@ -2717,14 +2777,15 @@ ${belowUser.map((item) => {
|
|
|
2717
2777
|
}
|
|
2718
2778
|
}
|
|
2719
2779
|
userCurrentArea.areaName = newArea.areaName;
|
|
2780
|
+
userCurrentArea.floor = newArea.floor;
|
|
2720
2781
|
const areaInfo = {
|
|
2721
2782
|
user: { ...userCurrentArea },
|
|
2722
2783
|
map: { ...newArea }
|
|
2723
2784
|
};
|
|
2724
2785
|
fn && await fn(areaInfo);
|
|
2725
|
-
await delay(3e3);
|
|
2726
2786
|
userCurrentArea.moveing = false;
|
|
2727
2787
|
GensokyoMap.setLocalStoragePoistionData(session.userId);
|
|
2788
|
+
await delay(3e3);
|
|
2728
2789
|
return;
|
|
2729
2790
|
} catch (error) {
|
|
2730
2791
|
console.log(error);
|
|
@@ -2733,6 +2794,75 @@ ${belowUser.map((item) => {
|
|
|
2733
2794
|
}
|
|
2734
2795
|
}
|
|
2735
2796
|
},
|
|
2797
|
+
/** 用户传送楼层 */
|
|
2798
|
+
async jumpFloor(session, afterFloor, fn) {
|
|
2799
|
+
const userCurrentArea = GensokyoMap.userCurrentLoal[session.userId] || {};
|
|
2800
|
+
const { floor, areaName, moveing } = userCurrentArea;
|
|
2801
|
+
if (moveing) {
|
|
2802
|
+
await session.send("当前移动冷却中,请稍等...");
|
|
2803
|
+
return;
|
|
2804
|
+
}
|
|
2805
|
+
if (!(floor && areaName)) {
|
|
2806
|
+
await session.send("您当前位置有误,请使用(还没写好的指令)脱离卡死...");
|
|
2807
|
+
return;
|
|
2808
|
+
}
|
|
2809
|
+
if (floor == afterFloor) {
|
|
2810
|
+
await session.send("目标层和当前层一致,无需传送!");
|
|
2811
|
+
return;
|
|
2812
|
+
}
|
|
2813
|
+
userCurrentArea.moveing = true;
|
|
2814
|
+
const newFloorMap = GensokyoMap.mapLocalData[afterFloor];
|
|
2815
|
+
if (!newFloorMap) {
|
|
2816
|
+
await session.send("未存在该层,传送失败!");
|
|
2817
|
+
userCurrentArea.moveing = false;
|
|
2818
|
+
return;
|
|
2819
|
+
}
|
|
2820
|
+
const currentArea = Object.keys(newFloorMap).find((areaName2) => newFloorMap[areaName2].type == "传送门" /* 传送门 */);
|
|
2821
|
+
if (!currentArea) {
|
|
2822
|
+
await session.send("目标传送层不存在传送门区域,传送失败...");
|
|
2823
|
+
userCurrentArea.moveing = false;
|
|
2824
|
+
return;
|
|
2825
|
+
}
|
|
2826
|
+
const afterArea = newFloorMap[currentArea];
|
|
2827
|
+
console.log(newFloorMap[currentArea]);
|
|
2828
|
+
if (BattleData.isTeam(session)) {
|
|
2829
|
+
const { userId } = session;
|
|
2830
|
+
const myTeamList = [];
|
|
2831
|
+
Object.keys(BattleData.teamTemp).forEach((_userId) => {
|
|
2832
|
+
if (BattleData.teamTemp[_userId].for == userId && userId !== _userId) {
|
|
2833
|
+
myTeamList.push(_userId);
|
|
2834
|
+
}
|
|
2835
|
+
});
|
|
2836
|
+
const belowUser = myTeamList.filter((teamUserId) => afterArea.needLv > User.userTempData[teamUserId].lv);
|
|
2837
|
+
if (belowUser.length) {
|
|
2838
|
+
await session.send(
|
|
2839
|
+
`移动失败!队伍存在限制进入等级(lv.${afterArea.needLv})玩家,
|
|
2840
|
+
目前限制进入的玩家:
|
|
2841
|
+
${belowUser.map((item) => {
|
|
2842
|
+
return `Lv.${User.userTempData[item].lv} ${User.userTempData[item].playName}`;
|
|
2843
|
+
}).join("\n")}`
|
|
2844
|
+
);
|
|
2845
|
+
userCurrentArea.moveing = false;
|
|
2846
|
+
return;
|
|
2847
|
+
}
|
|
2848
|
+
for (const moveTeamUserId of myTeamList) {
|
|
2849
|
+
GensokyoMap.userCurrentLoal[moveTeamUserId].areaName = afterArea.areaName;
|
|
2850
|
+
GensokyoMap.userCurrentLoal[moveTeamUserId].floor = afterArea.floor;
|
|
2851
|
+
GensokyoMap.userCurrentLoal[moveTeamUserId].moveing = false;
|
|
2852
|
+
await GensokyoMap.setLocalStoragePoistionData(moveTeamUserId);
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
userCurrentArea.areaName = afterArea.areaName;
|
|
2856
|
+
userCurrentArea.floor = afterArea.floor;
|
|
2857
|
+
const areaInfo = {
|
|
2858
|
+
user: { ...userCurrentArea },
|
|
2859
|
+
map: { ...afterArea }
|
|
2860
|
+
};
|
|
2861
|
+
fn && await fn(areaInfo);
|
|
2862
|
+
userCurrentArea.moveing = false;
|
|
2863
|
+
GensokyoMap.setLocalStoragePoistionData(session.userId);
|
|
2864
|
+
await delay(3e3);
|
|
2865
|
+
},
|
|
2736
2866
|
/** 查询附近玩家 */
|
|
2737
2867
|
nearbyPlayersByUserId(userId) {
|
|
2738
2868
|
const areaData = GensokyoMap.getUserCurrentArea(userId);
|
|
@@ -2839,7 +2969,9 @@ function generateMapHTML(mapData, currentAreaName) {
|
|
|
2839
2969
|
let html = `
|
|
2840
2970
|
<style>
|
|
2841
2971
|
.map-container {
|
|
2842
|
-
|
|
2972
|
+
display: flex;
|
|
2973
|
+
justify-content: center;
|
|
2974
|
+
align-items: center;
|
|
2843
2975
|
position: relative;
|
|
2844
2976
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
2845
2977
|
font-size: 12px;
|
|
@@ -2847,7 +2979,7 @@ function generateMapHTML(mapData, currentAreaName) {
|
|
|
2847
2979
|
padding: 20px;
|
|
2848
2980
|
border-radius: 12px;
|
|
2849
2981
|
min-width: 100vw;
|
|
2850
|
-
|
|
2982
|
+
min-height:100vh;
|
|
2851
2983
|
}
|
|
2852
2984
|
.map-table {
|
|
2853
2985
|
border-collapse: separate;
|
|
@@ -2996,46 +3128,7 @@ function generateMapHTML(mapData, currentAreaName) {
|
|
|
2996
3128
|
<div class="map-container">
|
|
2997
3129
|
<svg class="connection-lines" width="${svgWidth}" height="${svgHeight}">
|
|
2998
3130
|
`;
|
|
2999
|
-
|
|
3000
|
-
for (let c = minCol; c <= maxCol; c++) {
|
|
3001
|
-
const cell = grid[r]?.[c];
|
|
3002
|
-
if (cell) {
|
|
3003
|
-
const { connections } = cell;
|
|
3004
|
-
const x = (c - minCol) * cellWidth + cellWidth / 2;
|
|
3005
|
-
const y = (r - minRow) * cellHeight + cellHeight / 2;
|
|
3006
|
-
html += `<circle class="connection-dot" cx="${x}" cy="${y}" r="4" />`;
|
|
3007
|
-
if (connections.top) {
|
|
3008
|
-
const targetX = x;
|
|
3009
|
-
const targetY = y - cellHeight;
|
|
3010
|
-
html += `<line class="connection-line connection-line-dotted"
|
|
3011
|
-
x1="${x}" y1="${y}"
|
|
3012
|
-
x2="${targetX}" y2="${targetY}" />`;
|
|
3013
|
-
}
|
|
3014
|
-
if (connections.down) {
|
|
3015
|
-
const targetX = x;
|
|
3016
|
-
const targetY = y + cellHeight;
|
|
3017
|
-
html += `<line class="connection-line connection-line-dotted"
|
|
3018
|
-
x1="${x}" y1="${y}"
|
|
3019
|
-
x2="${targetX}" y2="${targetY}" />`;
|
|
3020
|
-
}
|
|
3021
|
-
if (connections.left) {
|
|
3022
|
-
const targetX = x - cellWidth;
|
|
3023
|
-
const targetY = y;
|
|
3024
|
-
html += `<line class="connection-line connection-line-dotted"
|
|
3025
|
-
x1="${x}" y1="${y}"
|
|
3026
|
-
x2="${targetX}" y2="${targetY}" />`;
|
|
3027
|
-
}
|
|
3028
|
-
if (connections.right) {
|
|
3029
|
-
const targetX = x + cellWidth;
|
|
3030
|
-
const targetY = y;
|
|
3031
|
-
html += `<line class="connection-line connection-line-dotted"
|
|
3032
|
-
x1="${x}" y1="${y}"
|
|
3033
|
-
x2="${targetX}" y2="${targetY}" />`;
|
|
3034
|
-
}
|
|
3035
|
-
}
|
|
3036
|
-
}
|
|
3037
|
-
}
|
|
3038
|
-
html += `</svg><table class="map-table">`;
|
|
3131
|
+
html += `<table class="map-table">`;
|
|
3039
3132
|
for (let r = minRow; r <= maxRow; r++) {
|
|
3040
3133
|
html += "<tr>";
|
|
3041
3134
|
for (let c = minCol; c <= maxCol; c++) {
|
|
@@ -3416,6 +3509,15 @@ function apply(ctx, config) {
|
|
|
3416
3509
|
ctx.command("幻想乡/打怪逃跑").action(async ({ session }) => {
|
|
3417
3510
|
await Queue.add(async () => await BattleData.battleEscape(session));
|
|
3418
3511
|
});
|
|
3512
|
+
ctx.command("幻想乡/传送 <floor:posint>").action(async ({ session }, floor) => {
|
|
3513
|
+
if (GensokyoMap.getUserCurrentArea(session.userId).type !== "传送门" /* 传送门 */) {
|
|
3514
|
+
return "该区域未存在传送门建筑,传送失败!";
|
|
3515
|
+
}
|
|
3516
|
+
GensokyoMap.jumpFloor(session, floor, async (val) => {
|
|
3517
|
+
await session.send(`传送到${floor}层成功!`);
|
|
3518
|
+
await session.send(GensokyoMap.userAreaTextFormat(val.user.playName, val));
|
|
3519
|
+
});
|
|
3520
|
+
});
|
|
3419
3521
|
}
|
|
3420
3522
|
__name(apply, "apply");
|
|
3421
3523
|
// Annotate the CommonJS export names for ESM import in node:
|
package/lib/map.d.ts
CHANGED
|
@@ -98,6 +98,8 @@ export declare const GensokyoMap: {
|
|
|
98
98
|
setLocalStoragePoistionData(userId: string): Promise<void>;
|
|
99
99
|
/** 用户移动 */
|
|
100
100
|
move(session: Session, type: MoveType, fn?: (area: AreaCallbackData) => Promise<void>): Promise<void>;
|
|
101
|
+
/** 用户传送楼层 */
|
|
102
|
+
jumpFloor(session: Session, afterFloor: number, fn?: (area: AreaCallbackData) => Promise<void>): Promise<void>;
|
|
101
103
|
/** 查询附近玩家 */
|
|
102
104
|
nearbyPlayersByUserId(userId: string): {
|
|
103
105
|
userId: string;
|