koishi-plugin-toram 0.4.3 → 0.4.4
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/data/dishes.json +8 -1
- package/lib/index.js +211 -214
- package/package.json +6 -1
- package/readme.md +6 -0
package/lib/data/dishes.json
CHANGED
|
@@ -663,7 +663,7 @@
|
|
|
663
663
|
],
|
|
664
664
|
[
|
|
665
665
|
89,
|
|
666
|
-
"
|
|
666
|
+
"月夜纱",
|
|
667
667
|
"梅干饭团",
|
|
668
668
|
9,
|
|
669
669
|
"智力"
|
|
@@ -3467,6 +3467,13 @@
|
|
|
3467
3467
|
"巧克力蛋糕",
|
|
3468
3468
|
8,
|
|
3469
3469
|
"物理屏障"
|
|
3470
|
+
],
|
|
3471
|
+
[
|
|
3472
|
+
490,
|
|
3473
|
+
"紫袖红弦",
|
|
3474
|
+
"玛格丽特披萨",
|
|
3475
|
+
9,
|
|
3476
|
+
"武器物理攻击"
|
|
3470
3477
|
]
|
|
3471
3478
|
]
|
|
3472
3479
|
}
|
package/lib/index.js
CHANGED
|
@@ -52,10 +52,25 @@ async function apply(ctx, config) {
|
|
|
52
52
|
}, {
|
|
53
53
|
primary: 'id'
|
|
54
54
|
});
|
|
55
|
+
const databasesToUpsert = [
|
|
56
|
+
{ tableName: 'toram_boss',
|
|
57
|
+
fileName: './data/boss',
|
|
58
|
+
version: '0.4.0-alpha.1' },
|
|
59
|
+
{ tableName: 'toram_dishes',
|
|
60
|
+
fileName: './data/dishes',
|
|
61
|
+
version: '0.4.4' },
|
|
62
|
+
{ tableName: 'toram_dishes_name',
|
|
63
|
+
fileName: './data/dishes_name',
|
|
64
|
+
version: '0.4.0-alpha.1' },
|
|
65
|
+
{ tableName: 'toram_dishes_effect',
|
|
66
|
+
fileName: './data/dishes_effect',
|
|
67
|
+
version: '0.4.0-alpha.1' }
|
|
68
|
+
];
|
|
69
|
+
const PlayerExpRate = [11, 11, 11, 11, 11, 10, 9, 7, 3];
|
|
70
|
+
const NumberReplace = { '一': '1', '二': '2', '三': '3', '四': '4', '五': '5', '六': '6', '七': '7', '八': '8', '九': '9', '十': '10' };
|
|
55
71
|
let n;
|
|
56
72
|
let x;
|
|
57
73
|
let text;
|
|
58
|
-
let PlayerExpRate = [11, 11, 11, 11, 11, 10, 9, 7, 3];
|
|
59
74
|
const DishesPlayerNotFind = [
|
|
60
75
|
'魔导书里还没有这个人的料理记录哦?去找青灯让她加一下吧~',
|
|
61
76
|
'如果你确定输入了正确的玩家昵称,那大概是还没有收录这个人的料理吧【缩缩】',
|
|
@@ -86,7 +101,7 @@ async function apply(ctx, config) {
|
|
|
86
101
|
for (const element of elements) {
|
|
87
102
|
if (element.type == "at") {
|
|
88
103
|
if (element.attrs.id == config.机器人qq) {
|
|
89
|
-
return '魔导书现有功能:\n①升级
|
|
104
|
+
return '魔导书现有功能:\n①升级 等级:查询该等级升级头目\n②天气预报:查看本次大更新的覆盖内容\n③料理 料理名称 [料理等级]:查询高级料理名单(结果通常用拼音排序)\n④料理 玩家名称:查询该玩家的料理信息';
|
|
90
105
|
}
|
|
91
106
|
}
|
|
92
107
|
}
|
|
@@ -99,241 +114,223 @@ async function apply(ctx, config) {
|
|
|
99
114
|
return next();
|
|
100
115
|
});
|
|
101
116
|
ctx.command('料理 <料理种类> <料理等级>').action(async ({ session }, ...args) => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
text = OnesName + '的料理信息如下:\n' + OnesDishes;
|
|
123
|
-
return text;
|
|
124
|
-
}
|
|
125
|
-
return DishesPlayerNotFind[Math.floor(Math.random() * DishesPlayerNotFind.length)];
|
|
126
|
-
}
|
|
127
|
-
const DishesEffectArr = await ctx.database.get('toram_dishes_effect', { type: DishesType });
|
|
128
|
-
const DishesEffect = DishesEffectArr[0]?.effect;
|
|
129
|
-
if (DishesLevelChoice == undefined) {
|
|
130
|
-
let Level10Dishes, Level9Dishes, Level8Dishes;
|
|
131
|
-
const GetLevel10Dishes = await ctx.database.get('toram_dishes', { $and: [{ type: DishesType }, { level: 10 }] });
|
|
132
|
-
if (GetLevel10Dishes.length != 0) {
|
|
133
|
-
Level10Dishes = GetLevel10Dishes.map((player) => {
|
|
134
|
-
return `${player?.name}`;
|
|
135
|
-
})
|
|
136
|
-
.sort(function compareFunction(item1, item2) {
|
|
137
|
-
return item1.localeCompare(item2);
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
const GetLevel9Dishes = await ctx.database.get('toram_dishes', { $and: [{ type: DishesType }, { level: 9 }] });
|
|
141
|
-
if (GetLevel9Dishes.length != 0 && GetLevel10Dishes.length < config.料理_最低返回数量要求) {
|
|
142
|
-
Level9Dishes = GetLevel9Dishes.map((player) => {
|
|
143
|
-
return `${player?.name}`;
|
|
144
|
-
})
|
|
145
|
-
.sort(function compareFunction(item1, item2) {
|
|
146
|
-
return item1.localeCompare(item2);
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
if (GetLevel10Dishes.length == 0 && GetLevel9Dishes.length == 0) {
|
|
150
|
-
let GetAllLevelDishes = await ctx.database.get('toram_dishes', { type: DishesType });
|
|
151
|
-
if (GetAllLevelDishes.length != 0) {
|
|
152
|
-
GetAllLevelDishes.sort(function (a, b) {
|
|
153
|
-
let alv = a.level;
|
|
154
|
-
let blv = b.level;
|
|
155
|
-
return b - a;
|
|
156
|
-
});
|
|
157
|
-
const LevelUnder8Dishes = GetAllLevelDishes.map((player) => {
|
|
158
|
-
return `${player?.name}(${player?.level}级)`;
|
|
159
|
-
});
|
|
160
|
-
text = DishesType + '(' + DishesEffect + ')名单如下:\n' + LevelUnder8Dishes;
|
|
161
|
-
text = text.replace(/,/g, ',');
|
|
162
|
-
return text;
|
|
163
|
-
}
|
|
164
|
-
return DishesNotFind[Math.floor(Math.random() * DishesNotFind.length)];
|
|
165
|
-
}
|
|
166
|
-
text = DishesType + '(' + DishesEffect + ')名单如下:';
|
|
167
|
-
if (GetLevel10Dishes.length != 0) {
|
|
168
|
-
text += '\n10级:\n' + Level10Dishes;
|
|
169
|
-
}
|
|
170
|
-
if (GetLevel9Dishes.length != 0 && GetLevel10Dishes.length < config.料理_最低返回数量要求) {
|
|
171
|
-
text += '\n9级:\n' + Level9Dishes;
|
|
172
|
-
}
|
|
173
|
-
if (GetLevel10Dishes.length + GetLevel9Dishes.length < config.料理_最低返回数量要求 && GetLevel10Dishes.length + GetLevel9Dishes.length > 0) {
|
|
174
|
-
const GetLevel8Dishes = await ctx.database.get('toram_dishes', { $and: [{ type: DishesType }, { level: 8 }] });
|
|
175
|
-
if (GetLevel8Dishes.length != 0) {
|
|
176
|
-
Level8Dishes = GetLevel8Dishes.map((player) => {
|
|
177
|
-
return `${player?.name}`;
|
|
178
|
-
})
|
|
179
|
-
.sort();
|
|
180
|
-
text += '\n8级:\n' + Level8Dishes;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
text = text.replace(/,/g, ',');
|
|
117
|
+
let DishesName = args[0], DishesLevelChoice = args[1];
|
|
118
|
+
if (DishesName == undefined) {
|
|
119
|
+
return '如果你要查询料理,请输入"料理 料理种类 [料理等级]"或"料理 玩家名称"来进行查询哦?\n如:料理';
|
|
120
|
+
}
|
|
121
|
+
const GetDishesType = await ctx.database.get('toram_dishes_name', { name: DishesName });
|
|
122
|
+
const DishesType = GetDishesType[0]?.type || 'none';
|
|
123
|
+
if (DishesType == 'none') {
|
|
124
|
+
const OnesName = DishesName;
|
|
125
|
+
const GetOnesDishes = await ctx.database.get('toram_dishes', { name: OnesName });
|
|
126
|
+
n = GetOnesDishes.length;
|
|
127
|
+
if (n != 0) {
|
|
128
|
+
GetOnesDishes.sort(function (a, b) {
|
|
129
|
+
let alv = a.level;
|
|
130
|
+
let blv = b.level;
|
|
131
|
+
return b - a;
|
|
132
|
+
});
|
|
133
|
+
let OnesDishes = GetOnesDishes.map((Dishes) => {
|
|
134
|
+
return `${Dishes?.type}(${Dishes?.effect}${Dishes?.level}级)`;
|
|
135
|
+
}).join(',');
|
|
136
|
+
text = OnesName + '的料理信息如下:\n' + OnesDishes;
|
|
184
137
|
return text;
|
|
185
138
|
}
|
|
186
|
-
|
|
187
|
-
|
|
139
|
+
return DishesPlayerNotFind[Math.floor(Math.random() * DishesPlayerNotFind.length)];
|
|
140
|
+
}
|
|
141
|
+
const DishesEffectArr = await ctx.database.get('toram_dishes_effect', { type: DishesType });
|
|
142
|
+
const DishesEffect = DishesEffectArr[0]?.effect;
|
|
143
|
+
if (DishesLevelChoice == undefined) {
|
|
144
|
+
let Level10Dishes, Level9Dishes, Level8Dishes;
|
|
145
|
+
const GetLevel10Dishes = await ctx.database.get('toram_dishes', { $and: [{ type: DishesType }, { level: 10 }] });
|
|
146
|
+
if (GetLevel10Dishes.length != 0) {
|
|
147
|
+
Level10Dishes = GetLevel10Dishes.map((player) => {
|
|
148
|
+
return `${player?.name}`;
|
|
149
|
+
})
|
|
150
|
+
.sort(function compareFunction(item1, item2) {
|
|
151
|
+
return item1.localeCompare(item2);
|
|
152
|
+
});
|
|
188
153
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
LevelChoiceDishes = rows2.map((player) => {
|
|
154
|
+
const GetLevel9Dishes = await ctx.database.get('toram_dishes', { $and: [{ type: DishesType }, { level: 9 }] });
|
|
155
|
+
if (GetLevel9Dishes.length != 0 && GetLevel10Dishes.length < config.料理_最低返回数量要求) {
|
|
156
|
+
Level9Dishes = GetLevel9Dishes.map((player) => {
|
|
193
157
|
return `${player?.name}`;
|
|
194
158
|
})
|
|
195
159
|
.sort(function compareFunction(item1, item2) {
|
|
196
160
|
return item1.localeCompare(item2);
|
|
197
161
|
});
|
|
198
|
-
text = DishesType + '(' + DishesEffect + ')' + DishesLevelChoice + '级名单如下:\n' + LevelChoiceDishes;
|
|
199
|
-
text = text.replace(/,/g, ',');
|
|
200
|
-
return text;
|
|
201
162
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (isNaN(Number(PlayerLevel)) || Number.isInteger(Number(PlayerLevel)) == false || PlayerLevel <= 0 || PlayerLevel >= config.版本等级) {
|
|
210
|
-
return UpgradeLevelError[Math.floor(Math.random() * UpgradeLevelError.length)];
|
|
211
|
-
}
|
|
212
|
-
if (PlayerLevel < 38) {
|
|
213
|
-
return PlayerLevel + '级升级所需经验为' + LevelUpExp + '\n亲亲,建议去尼山砍柴哦?';
|
|
214
|
-
}
|
|
215
|
-
if (PlayerLevel < 55) {
|
|
216
|
-
return PlayerLevel + '级升级所需经验为' + LevelUpExp + '\n去女帝陵墓打只因骨龙吧~';
|
|
217
|
-
}
|
|
218
|
-
if (PlayerLevel >= 55) {
|
|
219
|
-
const FitLevelBoss = await ctx.database.get('toram_boss', { level: { $gte: PlayerLevel - 8, $lte: Math.min(PlayerLevel + 8, config.版本等级 + 3) } });
|
|
220
|
-
const FitLevelFixedBoss = FitLevelBoss.filter(row => row.type === '定点王');
|
|
221
|
-
n = FitLevelFixedBoss.length - 1;
|
|
222
|
-
text = PlayerLevel + '级升级所需经验为' + LevelUpExp + '\n\n定点王:\n';
|
|
223
|
-
const FitLevelFixedBossExp = FitLevelFixedBoss.map((boss) => {
|
|
224
|
-
x = PlayerExpRate[Math.abs(PlayerLevel - boss.level)] || 0;
|
|
225
|
-
return boss.baseEXP * x;
|
|
163
|
+
if (GetLevel10Dishes.length == 0 && GetLevel9Dishes.length == 0) {
|
|
164
|
+
let GetAllLevelDishes = await ctx.database.get('toram_dishes', { type: DishesType });
|
|
165
|
+
if (GetAllLevelDishes.length != 0) {
|
|
166
|
+
GetAllLevelDishes.sort(function (a, b) {
|
|
167
|
+
let alv = a.level;
|
|
168
|
+
let blv = b.level;
|
|
169
|
+
return b - a;
|
|
226
170
|
});
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
.slice(0, Math.min(n + 1, config.升级_定点王数量))
|
|
230
|
-
.map(([, i]) => i);
|
|
231
|
-
const FixedBoss = MaxExpFixedBossIndex.map(index => {
|
|
232
|
-
const boss = FitLevelFixedBoss[index];
|
|
233
|
-
x = PlayerExpRate[Math.abs(PlayerLevel - boss.level)] || 0;
|
|
234
|
-
return `${boss?.name} 等级${boss?.level} ${boss?.map} 经验值${boss?.baseEXP * x} ${boss?.element}属性`;
|
|
235
|
-
}).join('\n');
|
|
236
|
-
text += FixedBoss;
|
|
237
|
-
const FitLevelWildBoss = FitLevelBoss.filter(row => row.type === '野王');
|
|
238
|
-
n = FitLevelWildBoss.length - 1;
|
|
239
|
-
text += '\n\n野王:\n';
|
|
240
|
-
const FitLevelFixedWildBossExp = FitLevelWildBoss.map((boss) => {
|
|
241
|
-
x = PlayerExpRate[Math.abs(PlayerLevel - boss.level)] || 0;
|
|
242
|
-
return boss.baseEXP * x;
|
|
171
|
+
const LevelUnder8Dishes = GetAllLevelDishes.map((player) => {
|
|
172
|
+
return `${player?.name}(${player?.level}级)`;
|
|
243
173
|
});
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
.slice(0, Math.min(n + 1, config.升级_野王数量))
|
|
247
|
-
.map(([, i]) => i);
|
|
248
|
-
const WildBoss = MaxExpFixedWildBossIndex.map(index => {
|
|
249
|
-
const boss = FitLevelWildBoss[index];
|
|
250
|
-
x = PlayerExpRate[Math.abs(PlayerLevel - boss?.level)] || 0;
|
|
251
|
-
return `${boss?.name} 等级${boss?.level} ${boss?.map} 经验值${boss?.baseEXP * x} ${boss?.element}属性`;
|
|
252
|
-
}).join('\n');
|
|
253
|
-
text += WildBoss;
|
|
174
|
+
text = DishesType + '(' + DishesEffect + ')名单如下:\n' + LevelUnder8Dishes;
|
|
175
|
+
text = text.replace(/,/g, ',');
|
|
254
176
|
return text;
|
|
255
177
|
}
|
|
178
|
+
return DishesNotFind[Math.floor(Math.random() * DishesNotFind.length)];
|
|
179
|
+
}
|
|
180
|
+
text = DishesType + '(' + DishesEffect + ')名单如下:';
|
|
181
|
+
if (GetLevel10Dishes.length != 0) {
|
|
182
|
+
text += '\n10级:\n' + Level10Dishes;
|
|
256
183
|
}
|
|
257
|
-
|
|
258
|
-
|
|
184
|
+
if (GetLevel9Dishes.length != 0 && GetLevel10Dishes.length < config.料理_最低返回数量要求) {
|
|
185
|
+
text += '\n9级:\n' + Level9Dishes;
|
|
186
|
+
}
|
|
187
|
+
if (GetLevel10Dishes.length + GetLevel9Dishes.length < config.料理_最低返回数量要求 && GetLevel10Dishes.length + GetLevel9Dishes.length > 0) {
|
|
188
|
+
const GetLevel8Dishes = await ctx.database.get('toram_dishes', { $and: [{ type: DishesType }, { level: 8 }] });
|
|
189
|
+
if (GetLevel8Dishes.length != 0) {
|
|
190
|
+
Level8Dishes = GetLevel8Dishes.map((player) => {
|
|
191
|
+
return `${player?.name}`;
|
|
192
|
+
})
|
|
193
|
+
.sort();
|
|
194
|
+
text += '\n8级:\n' + Level8Dishes;
|
|
195
|
+
}
|
|
259
196
|
}
|
|
197
|
+
text = text.replace(/,/g, ',');
|
|
198
|
+
return text;
|
|
199
|
+
}
|
|
200
|
+
if (/^([1-9]|10|一|二|三|四|五|六|七|八|九|十)级?$/.test(DishesLevelChoice) == false) {
|
|
201
|
+
return DishesLevelError[Math.floor(Math.random() * DishesLevelError.length)];
|
|
202
|
+
}
|
|
203
|
+
if (/级$/.test(DishesLevelChoice) == true) {
|
|
204
|
+
DishesLevelChoice = DishesLevelChoice.replace(/级/g, "");
|
|
205
|
+
}
|
|
206
|
+
if (/^([1-9]|10)$/.test(DishesLevelChoice) == false) {
|
|
207
|
+
DishesLevelChoice = (NumberReplace[DishesLevelChoice]);
|
|
208
|
+
}
|
|
209
|
+
let LevelChoiceDishes;
|
|
210
|
+
const rows2 = await ctx.database.get('toram_dishes', { $and: [{ type: DishesType }, { level: DishesLevelChoice }] });
|
|
211
|
+
if (rows2.length != 0) {
|
|
212
|
+
LevelChoiceDishes = rows2.map((player) => {
|
|
213
|
+
return `${player?.name}`;
|
|
214
|
+
})
|
|
215
|
+
.sort(function compareFunction(item1, item2) {
|
|
216
|
+
return item1.localeCompare(item2);
|
|
217
|
+
});
|
|
218
|
+
text = DishesType + '(' + DishesEffect + ')' + DishesLevelChoice + '级名单如下:\n' + LevelChoiceDishes;
|
|
219
|
+
text = text.replace(/,/g, ',');
|
|
220
|
+
return text;
|
|
221
|
+
}
|
|
222
|
+
return DishesLevelNotFind[Math.floor(Math.random() * DishesLevelNotFind.length)];
|
|
223
|
+
});
|
|
224
|
+
ctx.command('升级 <等级数>').action(async ({ session }, PlayerLevel) => {
|
|
225
|
+
if (PlayerLevel == undefined) {
|
|
226
|
+
return '如果你要查询升级头目,请输入"升级 等级数"来进行查询哦';
|
|
227
|
+
}
|
|
228
|
+
if (/级$/.test(PlayerLevel) == true) {
|
|
229
|
+
PlayerLevel = PlayerLevel.replace(/级/g, "");
|
|
230
|
+
}
|
|
231
|
+
if (isNaN(Number(PlayerLevel)) || Number.isInteger(Number(PlayerLevel)) == false || PlayerLevel <= 0 || PlayerLevel >= config.版本等级) {
|
|
232
|
+
return UpgradeLevelError[Math.floor(Math.random() * UpgradeLevelError.length)];
|
|
233
|
+
}
|
|
234
|
+
const LevelUpExp = Math.floor(PlayerLevel ** 4 / 40) + PlayerLevel * 2;
|
|
235
|
+
if (PlayerLevel < 38) {
|
|
236
|
+
return PlayerLevel + '级升级所需经验为' + LevelUpExp + '\n亲亲,建议去尼山砍柴哦?';
|
|
237
|
+
}
|
|
238
|
+
if (PlayerLevel < 55) {
|
|
239
|
+
return PlayerLevel + '级升级所需经验为' + LevelUpExp + '\n去女帝陵墓打只因骨龙吧~';
|
|
240
|
+
}
|
|
241
|
+
if (PlayerLevel >= 55) {
|
|
242
|
+
const FitLevelBoss = await ctx.database.get('toram_boss', { level: { $gte: PlayerLevel - 8, $lte: Math.min(PlayerLevel + 8, config.版本等级 + 3) } });
|
|
243
|
+
const FitLevelFixedBoss = FitLevelBoss.filter(row => row.type === '定点王');
|
|
244
|
+
n = FitLevelFixedBoss.length - 1;
|
|
245
|
+
text = PlayerLevel + '级升级所需经验为' + LevelUpExp + '\n\n定点王:\n';
|
|
246
|
+
const FitLevelFixedBossExp = FitLevelFixedBoss.map((boss) => {
|
|
247
|
+
x = PlayerExpRate[Math.abs(PlayerLevel - boss.level)] || 0;
|
|
248
|
+
return boss.baseEXP * x;
|
|
249
|
+
});
|
|
250
|
+
const MaxExpFixedBossIndex = FitLevelFixedBossExp.map((exp, i) => [exp, i])
|
|
251
|
+
.sort(([a], [b]) => b - a)
|
|
252
|
+
.slice(0, Math.min(n + 1, config.升级_定点王数量))
|
|
253
|
+
.map(([, i]) => i);
|
|
254
|
+
const FixedBoss = MaxExpFixedBossIndex.map(index => {
|
|
255
|
+
const boss = FitLevelFixedBoss[index];
|
|
256
|
+
x = PlayerExpRate[Math.abs(PlayerLevel - boss.level)] || 0;
|
|
257
|
+
return `${boss?.name} 等级${boss?.level} ${boss?.map} 经验值${boss?.baseEXP * x} ${boss?.element}属性`;
|
|
258
|
+
}).join('\n');
|
|
259
|
+
text += FixedBoss;
|
|
260
|
+
const FitLevelWildBoss = FitLevelBoss.filter(row => row.type === '野王');
|
|
261
|
+
n = FitLevelWildBoss.length - 1;
|
|
262
|
+
text += '\n\n野王:\n';
|
|
263
|
+
const FitLevelFixedWildBossExp = FitLevelWildBoss.map((boss) => {
|
|
264
|
+
x = PlayerExpRate[Math.abs(PlayerLevel - boss.level)] || 0;
|
|
265
|
+
return boss.baseEXP * x;
|
|
266
|
+
});
|
|
267
|
+
const MaxExpFixedWildBossIndex = FitLevelFixedWildBossExp.map((exp, i) => [exp, i])
|
|
268
|
+
.sort(([a], [b]) => b - a)
|
|
269
|
+
.slice(0, Math.min(n + 1, config.升级_野王数量))
|
|
270
|
+
.map(([, i]) => i);
|
|
271
|
+
const WildBoss = MaxExpFixedWildBossIndex.map(index => {
|
|
272
|
+
const boss = FitLevelWildBoss[index];
|
|
273
|
+
x = PlayerExpRate[Math.abs(PlayerLevel - boss?.level)] || 0;
|
|
274
|
+
return `${boss?.name} 等级${boss?.level} ${boss?.map} 经验值${boss?.baseEXP * x} ${boss?.element}属性`;
|
|
275
|
+
}).join('\n');
|
|
276
|
+
text += WildBoss;
|
|
277
|
+
return text;
|
|
260
278
|
}
|
|
261
279
|
});
|
|
262
280
|
ctx.command('数据文件写入').action(async ({ session }, ...args) => {
|
|
263
|
-
{
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
281
|
+
try {
|
|
282
|
+
let x = 0;
|
|
283
|
+
for (const database of databasesToUpsert) {
|
|
284
|
+
const { tableName, fileName, version } = database;
|
|
285
|
+
const ver = await ctx.database.get('toram_data_version', { database: tableName });
|
|
286
|
+
if (ver[0]?.version !== version) {
|
|
287
|
+
const json = require(fileName);
|
|
288
|
+
const data = json.rows;
|
|
289
|
+
session.send(`正在写入数据表【${tableName}】...`);
|
|
290
|
+
for (const row of data) {
|
|
291
|
+
if (tableName == 'toram_boss') {
|
|
292
|
+
await ctx.database.upsert('toram_boss', [
|
|
293
|
+
{ id: row[0], name: row[1], level: row[2], map: row[3], baseEXP: row[4], element: row[5], type: row[6] }
|
|
294
|
+
]);
|
|
295
|
+
}
|
|
296
|
+
if (tableName == 'toram_dishes') {
|
|
297
|
+
await ctx.database.upsert('toram_dishes', [
|
|
298
|
+
{ id: row[0], name: row[1], type: row[2], level: row[3], effect: row[4] }
|
|
299
|
+
]);
|
|
300
|
+
}
|
|
301
|
+
if (tableName == 'toram_dishes_name') {
|
|
302
|
+
await ctx.database.upsert('toram_dishes_name', [
|
|
303
|
+
{ id: row[0], name: row[1], type: row[2] }
|
|
304
|
+
]);
|
|
305
|
+
}
|
|
306
|
+
if (tableName == 'toram_dishes_effect') {
|
|
307
|
+
await ctx.database.upsert('toram_dishes_effect', [
|
|
308
|
+
{ id: row[0], type: row[1], effect: row[2] }
|
|
309
|
+
]);
|
|
310
|
+
}
|
|
275
311
|
}
|
|
276
|
-
await ctx.database.upsert('toram_data_version', [{
|
|
277
|
-
x++;
|
|
312
|
+
await ctx.database.upsert('toram_data_version', [{ database: tableName, version: version }], 'database');
|
|
278
313
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
x++;
|
|
291
|
-
}
|
|
292
|
-
const ver_dishes_name = await ctx.database.get('toram_data_version', 3);
|
|
293
|
-
if (ver_dishes_name[0]?.version != '0.4.0-alpha.1') {
|
|
294
|
-
session.send('正在写入数据表【toram_dishes_name】,当前进度3/4……');
|
|
295
|
-
const json_dishes_name = require('./data/dishes_name');
|
|
296
|
-
const data_dishes_name = json_dishes_name.rows;
|
|
297
|
-
for (const dishes_name of data_dishes_name) {
|
|
298
|
-
await ctx.database.upsert('toram_dishes_name', [
|
|
299
|
-
{ id: dishes_name[0], name: dishes_name[1], type: dishes_name[2] }
|
|
300
|
-
]);
|
|
301
|
-
}
|
|
302
|
-
await ctx.database.upsert('toram_data_version', [{ id: 3, database: 'toram_dishes_name', version: '0.4.0-alpha.1' }]);
|
|
303
|
-
x++;
|
|
314
|
+
x++;
|
|
315
|
+
}
|
|
316
|
+
if (x === 0) {
|
|
317
|
+
return '当前无需更新数据呢~';
|
|
318
|
+
}
|
|
319
|
+
return '数据写入完毕!';
|
|
320
|
+
}
|
|
321
|
+
catch (err) {
|
|
322
|
+
if (err.code === 'MODULE_NOT_FOUND') {
|
|
323
|
+
if (err.message.includes('/boss')) {
|
|
324
|
+
return '写入中断……未在data文件夹里找到文件boss.json';
|
|
304
325
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
session.send('正在写入数据表【toram_dishes_effect】,当前进度4/4……');
|
|
308
|
-
const json_dishes_effect = require('./data/dishes_effect');
|
|
309
|
-
const data_dishes_effect = json_dishes_effect.rows;
|
|
310
|
-
for (const dishes_effect of data_dishes_effect) {
|
|
311
|
-
await ctx.database.upsert('toram_dishes_effect', [
|
|
312
|
-
{ id: dishes_effect[0], type: dishes_effect[1], effect: dishes_effect[2] }
|
|
313
|
-
]);
|
|
314
|
-
}
|
|
315
|
-
await ctx.database.upsert('toram_data_version', [{ id: 4, database: 'toram_dishes_effect', version: '0.4.0-alpha.1' }]);
|
|
316
|
-
x++;
|
|
326
|
+
if (err.message.includes('/dishes_name')) {
|
|
327
|
+
return '写入中断……未在data文件夹里找到文件dishes_name.json';
|
|
317
328
|
}
|
|
318
|
-
if (
|
|
319
|
-
return '
|
|
329
|
+
if (err.message.includes('/dishes_effect')) {
|
|
330
|
+
return '写入中断……未在data文件夹里找到文件dishes_effect.json';
|
|
320
331
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
catch (err) {
|
|
324
|
-
if (err.code === 'MODULE_NOT_FOUND') {
|
|
325
|
-
if (err.message.includes('/boss')) {
|
|
326
|
-
return '写入中断……未在data文件夹里找到文件boss.json';
|
|
327
|
-
}
|
|
328
|
-
if (err.message.includes('/dishes_name')) {
|
|
329
|
-
return '写入中断……未在data文件夹里找到文件dishes_name.json';
|
|
330
|
-
}
|
|
331
|
-
if (err.message.includes('/dishes_effect')) {
|
|
332
|
-
return '写入中断……未在data文件夹里找到文件dishes_effect.json';
|
|
333
|
-
}
|
|
334
|
-
if (err.message.includes('/dishes')) {
|
|
335
|
-
return '写入中断……未在data文件夹里找到文件dishes.json';
|
|
336
|
-
}
|
|
332
|
+
if (err.message.includes('/dishes')) {
|
|
333
|
+
return '写入中断……未在data文件夹里找到文件dishes.json';
|
|
337
334
|
}
|
|
338
335
|
}
|
|
339
336
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-toram",
|
|
3
3
|
"description": "托拉姆物语小工具",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.4",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"青灯 <1874053520@qq.com>"
|
|
7
7
|
],
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"keywords": [
|
|
18
18
|
"gametool"
|
|
19
19
|
],
|
|
20
|
+
"service": {
|
|
21
|
+
"required": [
|
|
22
|
+
"database"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
20
25
|
"peerDependencies": {
|
|
21
26
|
"koishi": "^4.11.9"
|
|
22
27
|
}
|