koishi-plugin-toram 0.5.0 → 0.5.1
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/terminology.json +51 -0
- package/lib/data/terminology_name.json +131 -0
- package/lib/index.js +166 -59
- package/package.json +1 -1
- package/readme.md +8 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "table",
|
|
3
|
+
"database": null,
|
|
4
|
+
"name": "toram_terminology",
|
|
5
|
+
"withoutRowId": true,
|
|
6
|
+
"ddl": "CREATE TABLE toram_terminology (id undefined, type TEXT DEFAULT '', website TEXT DEFAULT '', PRIMARY KEY (id));",
|
|
7
|
+
"columns": [
|
|
8
|
+
{
|
|
9
|
+
"name": "id",
|
|
10
|
+
"type": "undefined"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "type",
|
|
14
|
+
"type": "TEXT",
|
|
15
|
+
"constraints": [
|
|
16
|
+
{
|
|
17
|
+
"type": "DEFAULT",
|
|
18
|
+
"definition": "DEFAULT ''"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "website",
|
|
24
|
+
"type": "TEXT",
|
|
25
|
+
"constraints": [
|
|
26
|
+
{
|
|
27
|
+
"type": "DEFAULT",
|
|
28
|
+
"definition": "DEFAULT ''"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"constraints": [
|
|
34
|
+
{
|
|
35
|
+
"type": "PRIMARY KEY",
|
|
36
|
+
"definition": "PRIMARY KEY (id)"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"rows": [
|
|
40
|
+
[
|
|
41
|
+
1,
|
|
42
|
+
"伤害惯性",
|
|
43
|
+
"伤害惯性:https:\/\/www.taptap.cn\/moment\/15230278003851618"
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
2,
|
|
47
|
+
"地图宝箱",
|
|
48
|
+
"地图宝箱:https:\/\/www.taptap.cn\/moment\/15203645561769970"
|
|
49
|
+
]
|
|
50
|
+
]
|
|
51
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "table",
|
|
3
|
+
"database": null,
|
|
4
|
+
"name": "toram_terminology_name",
|
|
5
|
+
"withoutRowId": true,
|
|
6
|
+
"ddl": "CREATE TABLE toram_terminology_name (id undefined, name TEXT DEFAULT '', type TEXT DEFAULT '', PRIMARY KEY (id));",
|
|
7
|
+
"columns": [
|
|
8
|
+
{
|
|
9
|
+
"name": "id",
|
|
10
|
+
"type": "undefined"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "name",
|
|
14
|
+
"type": "TEXT",
|
|
15
|
+
"constraints": [
|
|
16
|
+
{
|
|
17
|
+
"type": "DEFAULT",
|
|
18
|
+
"definition": "DEFAULT ''"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "type",
|
|
24
|
+
"type": "TEXT",
|
|
25
|
+
"constraints": [
|
|
26
|
+
{
|
|
27
|
+
"type": "DEFAULT",
|
|
28
|
+
"definition": "DEFAULT ''"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"constraints": [
|
|
34
|
+
{
|
|
35
|
+
"type": "PRIMARY KEY",
|
|
36
|
+
"definition": "PRIMARY KEY (id)"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"rows": [
|
|
40
|
+
[
|
|
41
|
+
1,
|
|
42
|
+
"叠伤",
|
|
43
|
+
"伤害惯性"
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
2,
|
|
47
|
+
"叠伤机制",
|
|
48
|
+
"伤害惯性"
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
3,
|
|
52
|
+
"惯性",
|
|
53
|
+
"伤害惯性"
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
7,
|
|
57
|
+
"伤害惯性机制",
|
|
58
|
+
"伤害惯性"
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
6,
|
|
62
|
+
"伤害惯性",
|
|
63
|
+
"伤害惯性"
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
5,
|
|
67
|
+
"叠伤惯性",
|
|
68
|
+
"伤害惯性"
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
4,
|
|
72
|
+
"惯性机制",
|
|
73
|
+
"伤害惯性"
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
8,
|
|
77
|
+
"叠伤惯性机制",
|
|
78
|
+
"伤害惯性"
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
18,
|
|
82
|
+
"组队开箱子",
|
|
83
|
+
"地图宝箱"
|
|
84
|
+
],
|
|
85
|
+
[
|
|
86
|
+
17,
|
|
87
|
+
"开箱子",
|
|
88
|
+
"地图宝箱"
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
16,
|
|
92
|
+
"组队开箱",
|
|
93
|
+
"地图宝箱"
|
|
94
|
+
],
|
|
95
|
+
[
|
|
96
|
+
15,
|
|
97
|
+
"地图箱子",
|
|
98
|
+
"地图宝箱"
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
14,
|
|
102
|
+
"野外秘宝",
|
|
103
|
+
"地图宝箱"
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
13,
|
|
107
|
+
"野外宝箱",
|
|
108
|
+
"地图宝箱"
|
|
109
|
+
],
|
|
110
|
+
[
|
|
111
|
+
12,
|
|
112
|
+
"野外箱子",
|
|
113
|
+
"地图宝箱"
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
11,
|
|
117
|
+
"地图秘宝",
|
|
118
|
+
"地图宝箱"
|
|
119
|
+
],
|
|
120
|
+
[
|
|
121
|
+
10,
|
|
122
|
+
"地图宝箱",
|
|
123
|
+
"地图宝箱"
|
|
124
|
+
],
|
|
125
|
+
[
|
|
126
|
+
9,
|
|
127
|
+
"开箱",
|
|
128
|
+
"地图宝箱"
|
|
129
|
+
]
|
|
130
|
+
]
|
|
131
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -4,13 +4,14 @@ exports.apply = exports.Config = exports.name = void 0;
|
|
|
4
4
|
const koishi_1 = require("koishi");
|
|
5
5
|
exports.name = 'toram';
|
|
6
6
|
exports.Config = koishi_1.Schema.object({
|
|
7
|
-
机器人qq: koishi_1.Schema.string().default('
|
|
8
|
-
版本等级: koishi_1.Schema.number().default(245),
|
|
9
|
-
升级_定点王数量: koishi_1.Schema.number().default(6),
|
|
10
|
-
升级_野王数量: koishi_1.Schema.number().default(4),
|
|
11
|
-
料理_最低返回数量要求: koishi_1.Schema.number().default(15)
|
|
7
|
+
机器人qq: koishi_1.Schema.string().default('0').description('机器人的使用的QQ号'),
|
|
8
|
+
版本等级: koishi_1.Schema.number().default(245).description('当前游戏等级版本'),
|
|
9
|
+
升级_定点王数量: koishi_1.Schema.number().default(6).description('使用升级指令时返回的定点王数量'),
|
|
10
|
+
升级_野王数量: koishi_1.Schema.number().default(4).description('使用升级指令时返回的野王数量'),
|
|
11
|
+
料理_最低返回数量要求: koishi_1.Schema.number().default(15).description('使用料理指令且不指定等级时最少返回的玩家昵称数量(如果数据库数量满足)')
|
|
12
12
|
});
|
|
13
13
|
async function apply(ctx, config) {
|
|
14
|
+
// 头目信息数据库
|
|
14
15
|
ctx.model.extend('toram_boss', {
|
|
15
16
|
id: 'number',
|
|
16
17
|
name: 'string',
|
|
@@ -22,6 +23,7 @@ async function apply(ctx, config) {
|
|
|
22
23
|
}, {
|
|
23
24
|
primary: 'id'
|
|
24
25
|
});
|
|
26
|
+
// 玩家料理信息数据库
|
|
25
27
|
ctx.model.extend('toram_dishes', {
|
|
26
28
|
id: 'number',
|
|
27
29
|
name: 'string',
|
|
@@ -31,6 +33,7 @@ async function apply(ctx, config) {
|
|
|
31
33
|
}, {
|
|
32
34
|
primary: 'id'
|
|
33
35
|
});
|
|
36
|
+
// 料理简写数据库
|
|
34
37
|
ctx.model.extend('toram_dishes_name', {
|
|
35
38
|
id: 'number',
|
|
36
39
|
name: 'string',
|
|
@@ -38,6 +41,23 @@ async function apply(ctx, config) {
|
|
|
38
41
|
}, {
|
|
39
42
|
primary: 'id'
|
|
40
43
|
});
|
|
44
|
+
// 术语信息数据库
|
|
45
|
+
ctx.model.extend('toram_terminology', {
|
|
46
|
+
id: 'number',
|
|
47
|
+
type: 'string',
|
|
48
|
+
website: 'string'
|
|
49
|
+
}, {
|
|
50
|
+
primary: 'id'
|
|
51
|
+
});
|
|
52
|
+
// 术语简写数据库
|
|
53
|
+
ctx.model.extend('toram_terminology_name', {
|
|
54
|
+
id: 'number',
|
|
55
|
+
name: 'string',
|
|
56
|
+
type: 'string'
|
|
57
|
+
}, {
|
|
58
|
+
primary: 'id'
|
|
59
|
+
});
|
|
60
|
+
// 数据库版本数据库
|
|
41
61
|
ctx.model.extend('toram_data_version', {
|
|
42
62
|
id: 'number',
|
|
43
63
|
database: 'string',
|
|
@@ -45,47 +65,69 @@ async function apply(ctx, config) {
|
|
|
45
65
|
}, {
|
|
46
66
|
primary: 'id'
|
|
47
67
|
});
|
|
68
|
+
// 本次更新对应数据库版本
|
|
48
69
|
const databasesToUpsert = [
|
|
49
70
|
{ tableName: 'toram_boss',
|
|
50
71
|
fileName: './data/boss',
|
|
51
|
-
version: '0.5.
|
|
72
|
+
version: '0.5.1' },
|
|
52
73
|
{ tableName: 'toram_dishes',
|
|
53
74
|
fileName: './data/dishes',
|
|
54
|
-
version: '0.5.
|
|
75
|
+
version: '0.5.1' },
|
|
55
76
|
{ tableName: 'toram_dishes_name',
|
|
56
77
|
fileName: './data/dishes_name',
|
|
57
|
-
version: '0.5.
|
|
78
|
+
version: '0.5.1' },
|
|
79
|
+
{ tableName: 'toram_terminology',
|
|
80
|
+
fileName: './data/terminology',
|
|
81
|
+
version: '0.5.1' },
|
|
82
|
+
{ tableName: 'toram_terminology_name',
|
|
83
|
+
fileName: './data/terminology_name',
|
|
84
|
+
version: '0.5.1' }
|
|
58
85
|
];
|
|
86
|
+
// 玩家等级差经验倍率
|
|
59
87
|
const PlayerExpRate = [11, 11, 11, 11, 11, 10, 9, 7, 3];
|
|
88
|
+
// 玩家料理信息数据库
|
|
60
89
|
const NumberReplace = { '一': '1', '二': '2', '三': '3', '四': '4', '五': '5', '六': '6', '七': '7', '八': '8', '九': '9', '十': '10' };
|
|
90
|
+
// 随手用到的变量
|
|
61
91
|
let n;
|
|
62
92
|
let x;
|
|
63
93
|
let text;
|
|
94
|
+
// 查不到玩家料理信息回复
|
|
64
95
|
const DishesPlayerNotFind = [
|
|
65
96
|
'魔导书里还没有这个人的料理记录哦?去找青灯让她加一下吧~',
|
|
66
97
|
'如果你确定输入了正确的玩家昵称,那大概是还没有收录这个人的料理吧【缩缩】',
|
|
67
|
-
'【翻翻】嗯……已查阅
|
|
98
|
+
'【翻翻】嗯……已查阅507条料理记录,找到符合的记录0条【合上书本】'
|
|
68
99
|
];
|
|
100
|
+
// 查不到某种料理信息回复
|
|
69
101
|
const DishesNotFind = [
|
|
70
102
|
'居然!青灯现在还没发现有人做这个料理!怎么回事呢~',
|
|
71
|
-
'【翻翻】嗯……已查阅
|
|
103
|
+
'【翻翻】嗯……已查阅507条料理记录,找到符合的记录0条【合上书本】',
|
|
72
104
|
'好像还没有人做这种料理呢……你要不要考虑一下?w'
|
|
73
105
|
];
|
|
106
|
+
// 查询料理的指定等级参数错误回复
|
|
74
107
|
const DishesLevelError = [
|
|
75
108
|
'找不到!怎么想都找不到吧!',
|
|
76
109
|
'啊?这是我能吃的吗?',
|
|
77
110
|
'魔导书很担心你的精神状态——'
|
|
78
111
|
];
|
|
112
|
+
// 查不到指定等级某种料理信息回复
|
|
79
113
|
const DishesLevelNotFind = [
|
|
80
|
-
'【翻翻】嗯……已查阅
|
|
114
|
+
'【翻翻】嗯……已查阅507条料理记录,找到符合的记录0条【合上书本】',
|
|
81
115
|
'冷门料理或者等级较低的热门料理是不太会主动收录的哦?想加的话要去找青灯呢~',
|
|
82
116
|
'魔导书还没有记录有这个等级的这种料理呢——'
|
|
83
117
|
];
|
|
118
|
+
// 升级指令等级参数错误回复
|
|
84
119
|
const UpgradeLevelError = [
|
|
85
120
|
'没救了,别练了,埋了罢【无慈悲】',
|
|
86
121
|
'魔导书很担心你的精神状态——',
|
|
87
122
|
'不可以调戏魔导书!'
|
|
88
123
|
];
|
|
124
|
+
// 查不到某种游戏术语信息回复
|
|
125
|
+
const TerminologyNotFind = [
|
|
126
|
+
'如果你确定输入了正确的术语名,那大概是青灯偷懒还没做,嗯!',
|
|
127
|
+
'居然!青灯没有收录这个游戏术语!怎么回事呢~',
|
|
128
|
+
'虽然但是,魔导书里没有这个游戏术语的记录呢——'
|
|
129
|
+
];
|
|
130
|
+
// 料理对应效果列表
|
|
89
131
|
const DishesEffect = {
|
|
90
132
|
'炖牛肉': '仇恨值增加', '奶油炖菜': '仇恨值减少',
|
|
91
133
|
'黄金炒饭': '体力值上限', '烩炒饭': '魔法值上限',
|
|
@@ -100,34 +142,109 @@ async function apply(ctx, config) {
|
|
|
100
142
|
'蜂蜜吐司': '光属性抗性', '布丁吐司': '土属性抗性', '香草吐司': '无属性抗性', '香蒜吐司': '暗属性抗性', '鲔鱼吐司': '水属性抗性', '煎蛋吐司': '火属性抗性', '起司吐司': '风属性抗性',
|
|
101
143
|
'奶油培根意大利面': '对光属性伤害', '青酱意大利面': '对地属性伤害', '香蒜辣椒意大利面': '对无属性伤害', '墨鱼意大利面': '对暗属性伤害', '蛤蜊意大利面': '对水属性伤害', '肉酱意大利面': '对火属性伤害', '那不勒斯意大利面': '对风属性伤害'
|
|
102
144
|
};
|
|
145
|
+
// 更新数据库指令
|
|
146
|
+
ctx.command('数据文件写入').action(async ({ session }, ...args) => {
|
|
147
|
+
try {
|
|
148
|
+
let x = 0;
|
|
149
|
+
// 检查现有数据库版本,不相符则进行更新
|
|
150
|
+
for (const database of databasesToUpsert) {
|
|
151
|
+
const { tableName, fileName, version } = database;
|
|
152
|
+
const ver = await ctx.database.get('toram_data_version', { database: tableName });
|
|
153
|
+
if (ver[0]?.version !== version) {
|
|
154
|
+
const json = require(fileName);
|
|
155
|
+
const data = json.rows;
|
|
156
|
+
session.send(`正在写入数据表【${tableName}】...`);
|
|
157
|
+
for (const row of data) {
|
|
158
|
+
if (tableName == 'toram_boss') {
|
|
159
|
+
await ctx.database.upsert('toram_boss', [
|
|
160
|
+
{ id: row[0], name: row[1], level: row[2], map: row[3], baseEXP: row[4], element: row[5], type: row[6] }
|
|
161
|
+
]);
|
|
162
|
+
}
|
|
163
|
+
if (tableName == 'toram_dishes') {
|
|
164
|
+
await ctx.database.upsert('toram_dishes', [
|
|
165
|
+
{ id: row[0], name: row[1], type: row[2], level: row[3], effect: row[4] }
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
168
|
+
if (tableName == 'toram_dishes_name') {
|
|
169
|
+
await ctx.database.upsert('toram_dishes_name', [
|
|
170
|
+
{ id: row[0], name: row[1], type: row[2] }
|
|
171
|
+
]);
|
|
172
|
+
}
|
|
173
|
+
if (tableName == 'toram_terminology') {
|
|
174
|
+
await ctx.database.upsert('toram_terminology', [
|
|
175
|
+
{ id: row[0], type: row[1], website: row[2] }
|
|
176
|
+
]);
|
|
177
|
+
}
|
|
178
|
+
if (tableName == 'toram_terminology_name') {
|
|
179
|
+
await ctx.database.upsert('toram_terminology_name', [
|
|
180
|
+
{ id: row[0], name: row[1], type: row[2] }
|
|
181
|
+
]);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
await ctx.database.upsert('toram_data_version', [{ database: tableName, version: version }], 'database');
|
|
185
|
+
}
|
|
186
|
+
x++;
|
|
187
|
+
}
|
|
188
|
+
if (x === 0) {
|
|
189
|
+
return '当前无需更新数据呢~';
|
|
190
|
+
}
|
|
191
|
+
return '数据写入完毕!';
|
|
192
|
+
}
|
|
193
|
+
// 错误提示
|
|
194
|
+
catch (err) {
|
|
195
|
+
if (err.code === 'MODULE_NOT_FOUND') {
|
|
196
|
+
if (err.message.includes('/boss')) {
|
|
197
|
+
return '写入中断……未在data文件夹里找到文件boss.json';
|
|
198
|
+
}
|
|
199
|
+
if (err.message.includes('/dishes_name')) {
|
|
200
|
+
return '写入中断……未在data文件夹里找到文件dishes_name.json';
|
|
201
|
+
}
|
|
202
|
+
if (err.message.includes('/dishes')) {
|
|
203
|
+
return '写入中断……未在data文件夹里找到文件dishes.json';
|
|
204
|
+
}
|
|
205
|
+
if (err.message.includes('/terminology')) {
|
|
206
|
+
return '写入中断……未在data文件夹里找到文件terminology.json';
|
|
207
|
+
}
|
|
208
|
+
if (err.message.includes('/terminology_name')) {
|
|
209
|
+
return '写入中断……未在data文件夹里找到文件terminology_name.json';
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
// 被@时
|
|
103
215
|
ctx.middleware(async (session, next) => {
|
|
104
216
|
let { elements } = session;
|
|
105
217
|
for (const element of elements) {
|
|
106
218
|
if (element.type == "at") {
|
|
107
219
|
if (element.attrs.id == config.机器人qq) {
|
|
108
|
-
return '魔导书现有功能:\n①升级 等级:查询该等级升级头目\n②天气预报:查看本次大更新的覆盖内容\n③料理 料理名称 [料理等级]:查询高级料理名单(结果通常用拼音排序)\n④料理
|
|
220
|
+
return '魔导书现有功能:\n①升级 等级:查询该等级升级头目\n②天气预报:查看本次大更新的覆盖内容\n③料理 料理名称 [料理等级]:查询高级料理名单(结果通常用拼音排序)\n④料理 玩家名称:查询该玩家的料理信息\n⑤游戏术语 [术语名称]:查询游戏术语';
|
|
109
221
|
}
|
|
110
222
|
}
|
|
111
223
|
}
|
|
112
224
|
return next();
|
|
113
225
|
});
|
|
226
|
+
// 未来更新信息-天气预报
|
|
114
227
|
ctx.middleware(async (session, next) => {
|
|
115
228
|
if (session.content === '天气预报') {
|
|
116
229
|
return '【托拉姆物语3.24大更一览-哔哩哔哩】 https://b23.tv/cWX9yjU';
|
|
117
230
|
}
|
|
118
231
|
return next();
|
|
119
232
|
});
|
|
233
|
+
// 料理指令
|
|
120
234
|
ctx.command('料理 <料理种类> <料理等级>').action(async ({ session }, ...args) => {
|
|
121
235
|
let DishesName = args[0], DishesLevelChoice = args[1];
|
|
236
|
+
// 没有参数
|
|
122
237
|
if (DishesName == undefined) {
|
|
123
238
|
return '如果你要查询料理,请输入"料理 料理种类 [料理等级]"或"料理 玩家名称"来进行查询哦?';
|
|
124
239
|
}
|
|
125
240
|
const GetDishesType = await ctx.database.get('toram_dishes_name', { name: DishesName });
|
|
126
241
|
const DishesType = GetDishesType[0]?.type || 'none';
|
|
242
|
+
// 判断参数是否为料理简写 否 将参数设为玩家昵称
|
|
127
243
|
if (DishesType == 'none') {
|
|
128
244
|
const OnesName = DishesName;
|
|
129
245
|
const GetOnesDishes = await ctx.database.get('toram_dishes', { name: OnesName });
|
|
130
246
|
n = GetOnesDishes.length;
|
|
247
|
+
// 判断玩家昵称名下是否有料理 是 返回信息
|
|
131
248
|
if (n != 0) {
|
|
132
249
|
GetOnesDishes.sort(function (a, b) {
|
|
133
250
|
let alv = a.level;
|
|
@@ -140,11 +257,14 @@ async function apply(ctx, config) {
|
|
|
140
257
|
text = OnesName + '的料理信息如下:\n' + OnesDishes;
|
|
141
258
|
return text;
|
|
142
259
|
}
|
|
260
|
+
// 判断玩家昵称名下是否有料理 否 报错提示
|
|
143
261
|
return DishesPlayerNotFind[Math.floor(Math.random() * DishesPlayerNotFind.length)];
|
|
144
262
|
}
|
|
263
|
+
// 判断参数是否为料理简写 是 检查是否存在指定等级 否 开始返回列表
|
|
145
264
|
if (DishesLevelChoice == undefined) {
|
|
146
265
|
let Level10Dishes, Level9Dishes, Level8Dishes;
|
|
147
266
|
const GetLevel10Dishes = await ctx.database.get('toram_dishes', { $and: [{ type: DishesType }, { level: 10 }] });
|
|
267
|
+
// 存在10级料理时,返回10级列表
|
|
148
268
|
if (GetLevel10Dishes.length != 0) {
|
|
149
269
|
Level10Dishes = GetLevel10Dishes.map((player) => {
|
|
150
270
|
return `${player?.name}`;
|
|
@@ -154,6 +274,7 @@ async function apply(ctx, config) {
|
|
|
154
274
|
});
|
|
155
275
|
}
|
|
156
276
|
const GetLevel9Dishes = await ctx.database.get('toram_dishes', { $and: [{ type: DishesType }, { level: 9 }] });
|
|
277
|
+
// 当10级料理人数不足最低返回数量要求时,追加9级列表
|
|
157
278
|
if (GetLevel9Dishes.length != 0 && GetLevel10Dishes.length < config.料理_最低返回数量要求) {
|
|
158
279
|
Level9Dishes = GetLevel9Dishes.map((player) => {
|
|
159
280
|
return `${player?.name}`;
|
|
@@ -162,6 +283,7 @@ async function apply(ctx, config) {
|
|
|
162
283
|
return item1.localeCompare(item2);
|
|
163
284
|
});
|
|
164
285
|
}
|
|
286
|
+
// 当不存在9级或以上料理时,返回全部列表
|
|
165
287
|
if (GetLevel10Dishes.length == 0 && GetLevel9Dishes.length == 0) {
|
|
166
288
|
let GetAllLevelDishes = await ctx.database.get('toram_dishes', { type: DishesType });
|
|
167
289
|
if (GetAllLevelDishes.length != 0) {
|
|
@@ -177,8 +299,10 @@ async function apply(ctx, config) {
|
|
|
177
299
|
text = text.replace(/,/g, ',');
|
|
178
300
|
return text;
|
|
179
301
|
}
|
|
302
|
+
// 不存在这种料理时,提示错误
|
|
180
303
|
return DishesNotFind[Math.floor(Math.random() * DishesNotFind.length)];
|
|
181
304
|
}
|
|
305
|
+
// 返回部分
|
|
182
306
|
text = DishesType + '(' + DishesEffect[DishesType] + ')名单如下:';
|
|
183
307
|
if (GetLevel10Dishes.length != 0) {
|
|
184
308
|
text += '\n10级:\n' + Level10Dishes;
|
|
@@ -199,6 +323,7 @@ async function apply(ctx, config) {
|
|
|
199
323
|
text = text.replace(/,/g, ',');
|
|
200
324
|
return text;
|
|
201
325
|
}
|
|
326
|
+
// 检查是否存在指定等级 是 开始查询指定等级列表
|
|
202
327
|
if (/^([1-9]|10|一|二|三|四|五|六|七|八|九|十)级?$/.test(DishesLevelChoice) == false) {
|
|
203
328
|
return DishesLevelError[Math.floor(Math.random() * DishesLevelError.length)];
|
|
204
329
|
}
|
|
@@ -221,12 +346,16 @@ async function apply(ctx, config) {
|
|
|
221
346
|
text = text.replace(/,/g, ',');
|
|
222
347
|
return text;
|
|
223
348
|
}
|
|
349
|
+
// 不存在指定等级的指定料理时,提示错误
|
|
224
350
|
return DishesLevelNotFind[Math.floor(Math.random() * DishesLevelNotFind.length)];
|
|
225
351
|
});
|
|
352
|
+
// 升级指令
|
|
226
353
|
ctx.command('升级 <等级数>').action(async ({ session }, PlayerLevel) => {
|
|
354
|
+
// 检查是否存在参数 否 提示错误
|
|
227
355
|
if (PlayerLevel == undefined) {
|
|
228
356
|
return '如果你要查询升级头目,请输入"升级 等级数"来进行查询哦';
|
|
229
357
|
}
|
|
358
|
+
// 检查是否存在参数 是 进行检查参数
|
|
230
359
|
if (/级$/.test(PlayerLevel) == true) {
|
|
231
360
|
PlayerLevel = PlayerLevel.replace(/级/g, "");
|
|
232
361
|
}
|
|
@@ -234,6 +363,7 @@ async function apply(ctx, config) {
|
|
|
234
363
|
return UpgradeLevelError[Math.floor(Math.random() * UpgradeLevelError.length)];
|
|
235
364
|
}
|
|
236
365
|
const LevelUpExp = Math.floor(PlayerLevel ** 4 / 40) + PlayerLevel * 2;
|
|
366
|
+
// 判断等级是否过低
|
|
237
367
|
if (PlayerLevel < 38) {
|
|
238
368
|
return PlayerLevel + '级升级所需经验为' + LevelUpExp + '\n亲亲,建议去尼山砍柴哦?';
|
|
239
369
|
}
|
|
@@ -242,6 +372,7 @@ async function apply(ctx, config) {
|
|
|
242
372
|
}
|
|
243
373
|
if (PlayerLevel >= 55) {
|
|
244
374
|
const FitLevelBoss = await ctx.database.get('toram_boss', { level: { $gte: PlayerLevel - 8, $lte: Math.min(PlayerLevel + 8, config.版本等级 + 3) } });
|
|
375
|
+
// 获取接近等级的定点王信息
|
|
245
376
|
const FitLevelFixedBoss = FitLevelBoss.filter(row => row.type === '定点王');
|
|
246
377
|
n = FitLevelFixedBoss.length - 1;
|
|
247
378
|
text = PlayerLevel + '级升级所需经验为' + LevelUpExp + '\n\n定点王:\n';
|
|
@@ -259,6 +390,7 @@ async function apply(ctx, config) {
|
|
|
259
390
|
return `${boss?.name} 等级${boss?.level} ${boss?.map} 经验值${boss?.baseEXP * x} ${boss?.element}属性`;
|
|
260
391
|
}).join('\n');
|
|
261
392
|
text += FixedBoss;
|
|
393
|
+
// 获取接近等级的野王信息
|
|
262
394
|
const FitLevelWildBoss = FitLevelBoss.filter(row => row.type === '野王');
|
|
263
395
|
n = FitLevelWildBoss.length - 1;
|
|
264
396
|
text += '\n\n野王:\n';
|
|
@@ -279,55 +411,30 @@ async function apply(ctx, config) {
|
|
|
279
411
|
return text;
|
|
280
412
|
}
|
|
281
413
|
});
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
]);
|
|
297
|
-
}
|
|
298
|
-
if (tableName == 'toram_dishes') {
|
|
299
|
-
await ctx.database.upsert('toram_dishes', [
|
|
300
|
-
{ id: row[0], name: row[1], type: row[2], level: row[3], effect: row[4] }
|
|
301
|
-
]);
|
|
302
|
-
}
|
|
303
|
-
if (tableName == 'toram_dishes_name') {
|
|
304
|
-
await ctx.database.upsert('toram_dishes_name', [
|
|
305
|
-
{ id: row[0], name: row[1], type: row[2] }
|
|
306
|
-
]);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
await ctx.database.upsert('toram_data_version', [{ database: tableName, version: version }], 'database');
|
|
310
|
-
}
|
|
311
|
-
x++;
|
|
312
|
-
}
|
|
313
|
-
if (x === 0) {
|
|
314
|
-
return '当前无需更新数据呢~';
|
|
315
|
-
}
|
|
316
|
-
return '数据写入完毕!';
|
|
414
|
+
// 游戏术语指令
|
|
415
|
+
ctx.command('游戏术语 <术语名>').action(async ({ session }, ...args) => {
|
|
416
|
+
let TerminologyName = args[0];
|
|
417
|
+
// 没有参数,返回查询列表
|
|
418
|
+
if (TerminologyName == undefined) {
|
|
419
|
+
const GetTerminologyList = await ctx.database.get('toram_terminology', { id: { $gte: 1, $lte: 100 } });
|
|
420
|
+
const TerminologyList = GetTerminologyList.map((Terminology) => {
|
|
421
|
+
return `${Terminology?.name}`;
|
|
422
|
+
})
|
|
423
|
+
.sort(function compareFunction(item1, item2) {
|
|
424
|
+
return item1.localeCompare(item2);
|
|
425
|
+
});
|
|
426
|
+
text = '当前可查询的游戏术语如下:\n' + TerminologyList;
|
|
427
|
+
return text;
|
|
317
428
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if (err.message.includes('/dishes_name')) {
|
|
324
|
-
return '写入中断……未在data文件夹里找到文件dishes_name.json';
|
|
325
|
-
}
|
|
326
|
-
if (err.message.includes('/dishes')) {
|
|
327
|
-
return '写入中断……未在data文件夹里找到文件dishes.json';
|
|
328
|
-
}
|
|
329
|
-
}
|
|
429
|
+
const GetTerminologyType = await ctx.database.get('toram_terminology_name', { name: TerminologyName });
|
|
430
|
+
const TerminologyType = GetTerminologyType[0]?.type || 'none';
|
|
431
|
+
// 判断是否未查询到术语
|
|
432
|
+
if (TerminologyType == 'none') {
|
|
433
|
+
return TerminologyNotFind[Math.floor(Math.random() * TerminologyNotFind.length)];
|
|
330
434
|
}
|
|
435
|
+
const GetTerminology = await ctx.database.get('toram_terminology', { type: TerminologyType });
|
|
436
|
+
const Terminology = GetTerminology[0];
|
|
437
|
+
return Terminology.website;
|
|
331
438
|
});
|
|
332
439
|
}
|
|
333
440
|
exports.apply = apply;
|
package/package.json
CHANGED
package/readme.md
CHANGED