koishi-plugin-toram 0.3.2 → 0.3.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/.toram.db ADDED
Binary file
package/lib/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface Config {
6
6
  升级_定点王数量: number;
7
7
  升级_野王数量: number;
8
8
  组队_未来天数: number;
9
+ 料理_最低返回数量要求: number;
9
10
  }
10
11
  export declare const Config: Schema<Config>;
11
12
  export declare function apply(ctx: any, config: Config): Promise<void>;
package/lib/index.js CHANGED
@@ -5,10 +5,11 @@ const koishi_1 = require("koishi");
5
5
  exports.name = 'toram';
6
6
  exports.Config = koishi_1.Schema.object({
7
7
  机器人qq: koishi_1.Schema.string().default('229968046'),
8
- 版本等级: koishi_1.Schema.number().default(240),
8
+ 版本等级: koishi_1.Schema.number().default(245),
9
9
  升级_定点王数量: koishi_1.Schema.number().default(6),
10
10
  升级_野王数量: koishi_1.Schema.number().default(4),
11
11
  组队_未来天数: koishi_1.Schema.number().default(7),
12
+ 料理_最低返回数量要求: koishi_1.Schema.number().default(15),
12
13
  });
13
14
  async function apply(ctx, config) {
14
15
  ctx.model.extend('toram_boss', {
@@ -22,6 +23,21 @@ async function apply(ctx, config) {
22
23
  }, {
23
24
  primary: 'id'
24
25
  });
26
+ ctx.model.extend('toram_dishes', {
27
+ id: 'number',
28
+ name: 'string',
29
+ type: 'string',
30
+ level: 'number'
31
+ }, {
32
+ primary: 'id'
33
+ });
34
+ ctx.model.extend('toram_dishes_name', {
35
+ id: 'number',
36
+ name: 'string',
37
+ type: 'string'
38
+ }, {
39
+ primary: 'id'
40
+ });
25
41
  ctx.model.extend('toram_team', {
26
42
  id: 'string',
27
43
  form: 'number',
@@ -40,6 +56,170 @@ async function apply(ctx, config) {
40
56
  '上午': 12 * 60 * 60 * 1000,
41
57
  '下午': 18 * 60 * 60 * 1000,
42
58
  };
59
+ ctx.command('料理 <料理种类> <料理等级>').action(async ({ session }, ...args) => {
60
+ {
61
+ let 料理名称 = args[0], 等级筛选 = args[1];
62
+ if (料理名称 == undefined) {
63
+ return '如果你要查询料理,请输入"料理 料理种类 [料理等级]"来进行查询哦';
64
+ }
65
+ const rows1 = await ctx.database.get('toram_dishes_name', { name: [料理名称] });
66
+ const 料理类型 = rows1[0]?.type || '不存在';
67
+ if (料理类型 == '不存在') {
68
+ return '这是能吃的吗?';
69
+ }
70
+ if (等级筛选 == undefined) {
71
+ let 十级料理信息结果;
72
+ let 九级料理信息结果;
73
+ let 八级料理信息结果;
74
+ const rows2 = await ctx.database.get('toram_dishes', { $and: [{ type: [料理类型] }, { level: [10] }] });
75
+ if (rows2.length != 0) {
76
+ 十级料理信息结果 = rows2.map((player) => {
77
+ return `${player?.name}`;
78
+ })
79
+ .sort(function compareFunction(item1, item2) {
80
+ return item1.localeCompare(item2);
81
+ });
82
+ }
83
+ const rows3 = await ctx.database.get('toram_dishes', { $and: [{ type: [料理类型] }, { level: [9] }] });
84
+ if (rows3.length != 0 && rows2.length < config.料理_最低返回数量要求) {
85
+ 九级料理信息结果 = rows3.map((player) => {
86
+ return `${player?.name}`;
87
+ })
88
+ .sort(function compareFunction(item1, item2) {
89
+ return item1.localeCompare(item2);
90
+ });
91
+ }
92
+ if (rows2.length == 0 && rows3.length == 0) {
93
+ let rows4 = await ctx.database.get('toram_dishes', { type: [料理类型] });
94
+ if (rows4.length != 0) {
95
+ rows4.sort(function (a, b) {
96
+ let alv = a.level;
97
+ let blv = b.level;
98
+ return b - a;
99
+ });
100
+ const 八级以下料理信息结果 = rows4.map((player) => {
101
+ return `${player?.name}(${player?.level}级)`;
102
+ })
103
+ .sort(function compareFunction(item1, item2) {
104
+ return item1.localeCompare(item2);
105
+ });
106
+ text = 料理类型;
107
+ if (料理类型 != 料理名称) {
108
+ text += '(' + 料理名称 + ')';
109
+ }
110
+ text += '名单如下:\n' + 八级以下料理信息结果;
111
+ text = text.replace(/,/g, ',');
112
+ return text;
113
+ }
114
+ return '还没有记录有这种料理呢——';
115
+ }
116
+ text = 料理类型;
117
+ if (料理类型 != 料理名称) {
118
+ text += '(' + 料理名称 + ')';
119
+ }
120
+ text += '名单如下:';
121
+ if (rows2.length != 0) {
122
+ text += '\n10级:\n' + 十级料理信息结果;
123
+ }
124
+ if (rows3.length != 0 && rows2.length < config.料理_最低返回数量要求) {
125
+ text += '\n9级:\n' + 九级料理信息结果;
126
+ }
127
+ if (rows2.length + rows3.length < config.料理_最低返回数量要求 && rows2.length + rows3.length > 0) {
128
+ const rows5 = await ctx.database.get('toram_dishes', { $and: [{ type: [料理类型] }, { level: [8] }] });
129
+ if (rows5.length != 0) {
130
+ 八级料理信息结果 = rows5.map((player) => {
131
+ return `${player?.name}`;
132
+ })
133
+ .sort();
134
+ text += '\n8级:\n' + 八级料理信息结果;
135
+ }
136
+ }
137
+ text = text.replace(/,/g, ',');
138
+ return text;
139
+ }
140
+ if (isNaN(Number(等级筛选)) || Number.isInteger(Number(等级筛选)) == false || 等级筛选 <= 0 || 等级筛选 > 10) {
141
+ return '找不到!怎么想都找不到吧!';
142
+ }
143
+ let 目标等级料理信息结果;
144
+ const rows2 = await ctx.database.get('toram_dishes', { $and: [{ type: [料理类型] }, { level: [等级筛选] }] });
145
+ if (rows2.length != 0) {
146
+ 目标等级料理信息结果 = rows2.map((player) => {
147
+ return `${player?.name}`;
148
+ })
149
+ .sort(function compareFunction(item1, item2) {
150
+ return item1.localeCompare(item2);
151
+ });
152
+ text = 料理类型;
153
+ if (料理类型 != 料理名称) {
154
+ text += '(' + 料理名称 + ')';
155
+ }
156
+ text += 等级筛选 + '级名单如下:\n' + 目标等级料理信息结果;
157
+ text = text.replace(/,/g, ',');
158
+ return text;
159
+ }
160
+ return '还没有记录有这个等级的这种料理呢——';
161
+ }
162
+ });
163
+ ctx.command('升级 <等级数>').action(async ({ session }, 等级) => {
164
+ {
165
+ const 经验 = Math.floor(等级 ** 4 / 40) + 等级 * 2;
166
+ if (等级 != undefined) {
167
+ if (isNaN(Number(等级)) || Number.isInteger(Number(等级)) == false || 等级 <= 0 || 等级 >= config.版本等级) {
168
+ return '没救了,别练了,埋了罢【无慈悲】';
169
+ }
170
+ ;
171
+ if (等级 < 38) {
172
+ return 等级 + '级升级所需经验为' + 经验 + '\n亲亲,建议去尼山砍柴哦?';
173
+ }
174
+ ;
175
+ if (等级 < 55) {
176
+ return 等级 + '级升级所需经验为' + 经验 + '\n去女帝陵墓打只因骨龙吧~';
177
+ }
178
+ ;
179
+ if (等级 >= 55) {
180
+ const rows1 = await ctx.database.get('toram_boss', { level: { $gte: 等级 - 8, $lte: Math.min(等级 + 8, config.版本等级 + 3) } });
181
+ const 等级符合定点王 = rows1.filter(row => row.type === '定点王');
182
+ n = 等级符合定点王.length - 1;
183
+ text = 等级 + '级升级所需经验为' + 经验 + '\n\n定点王:\n';
184
+ const 等级符合定点王经验 = 等级符合定点王.map((boss) => {
185
+ x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
186
+ return boss.baseEXP * x;
187
+ });
188
+ const 经验最大定点王索引 = 等级符合定点王经验.map((exp, i) => [exp, i])
189
+ .sort(([a], [b]) => b - a)
190
+ .slice(0, Math.min(n + 1, config.升级_定点王数量))
191
+ .map(([, i]) => i);
192
+ const 定点王信息结果 = 经验最大定点王索引.map(index => {
193
+ const boss = 等级符合定点王[index];
194
+ x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
195
+ return `${boss?.name} 等级${boss?.level} ${boss?.map} 经验值${boss?.baseEXP * x} ${boss?.element}属性`;
196
+ }).join('\n');
197
+ text += 定点王信息结果;
198
+ const 等级符合野王 = rows1.filter(row => row.type === '野王');
199
+ n = 等级符合野王.length - 1;
200
+ text += '\n\n野王:\n';
201
+ const 等级符合野王经验 = 等级符合野王.map((boss) => {
202
+ x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
203
+ return boss.baseEXP * x;
204
+ });
205
+ const 经验最大野王索引 = 等级符合野王经验.map((exp, i) => [exp, i])
206
+ .sort(([a], [b]) => b - a)
207
+ .slice(0, Math.min(n + 1, config.升级_野王数量))
208
+ .map(([, i]) => i);
209
+ const 野王信息结果 = 经验最大野王索引.map(index => {
210
+ const boss = 等级符合野王[index];
211
+ x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
212
+ return `${boss?.name} 等级${boss?.level} ${boss?.map} 经验值${boss?.baseEXP * x} ${boss?.element}属性`;
213
+ }).join('\n');
214
+ text += 野王信息结果;
215
+ return text;
216
+ }
217
+ }
218
+ else {
219
+ return '如果你要查询升级头目,请输入"升级 等级数"来进行查询哦';
220
+ }
221
+ }
222
+ });
43
223
  ctx.command('组队 <截止时间> <求组内容>').action(async ({ session }, ...args) => {
44
224
  const { userId, guildId } = session;
45
225
  const 当前时间date = new Date();
@@ -120,77 +300,13 @@ async function apply(ctx, config) {
120
300
  return '你没有正在进行的组队';
121
301
  }
122
302
  });
123
- ctx.command('升级 <等级数>').action(async ({ session }, 等级) => {
124
- {
125
- if (等级 != undefined) {
126
- if (isNaN(Number(等级)) || Number.isInteger(Number(等级)) == false || 等级 <= 0 || 等级 >= config.版本等级) {
127
- return '没救了,别练了,埋了罢【无慈悲】';
128
- }
129
- ;
130
- if (等级 < 38) {
131
- const 回复语句数组 = [
132
- '亲亲,建议去尼山砍柴哦?',
133
- '可怜的孩子,快去恰尼木嘞——'
134
- ];
135
- n = 回复语句数组.length;
136
- return 回复语句数组[Math.ceil(Math.random() * n)];
137
- }
138
- ;
139
- if (等级 < 55) {
140
- return '去女帝陵墓打只因骨龙吧~';
141
- }
142
- ;
143
- if (等级 >= 55) {
144
- const rows1 = await ctx.database.get('toram_boss', { level: { $gte: 等级 - 8, $lte: Math.min(等级 + 8, config.版本等级 + 3) } });
145
- const 等级符合定点王 = rows1.filter(row => row.type === '定点王');
146
- n = 等级符合定点王.length - 1;
147
- text = '定点王:\n';
148
- const 等级符合定点王经验 = 等级符合定点王.map((boss) => {
149
- x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
150
- return boss.baseEXP * x;
151
- });
152
- const 经验最大定点王索引 = 等级符合定点王经验.map((exp, i) => [exp, i])
153
- .sort(([a], [b]) => b - a)
154
- .slice(0, Math.min(n + 1, config.升级_定点王数量))
155
- .map(([, i]) => i);
156
- const 定点王信息结果 = 经验最大定点王索引.map(index => {
157
- const boss = 等级符合定点王[index];
158
- x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
159
- return `${boss?.name} 等级${boss?.level} ${boss?.map} 经验值${boss?.baseEXP * x} ${boss?.element}属性`;
160
- }).join('\n');
161
- text += 定点王信息结果;
162
- const 等级符合野王 = rows1.filter(row => row.type === '野王');
163
- n = 等级符合野王.length - 1;
164
- text += '\n\n野王:\n';
165
- const 等级符合野王经验 = 等级符合野王.map((boss) => {
166
- x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
167
- return boss.baseEXP * x;
168
- });
169
- const 经验最大野王索引 = 等级符合野王经验.map((exp, i) => [exp, i])
170
- .sort(([a], [b]) => b - a)
171
- .slice(0, Math.min(n + 1, config.升级_野王数量))
172
- .map(([, i]) => i);
173
- const 野王信息结果 = 经验最大野王索引.map(index => {
174
- const boss = 等级符合野王[index];
175
- x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
176
- return `${boss?.name} 等级${boss?.level} ${boss?.map} 经验值${boss?.baseEXP * x} ${boss?.element}属性`;
177
- }).join('\n');
178
- text += 野王信息结果;
179
- return text;
180
- }
181
- }
182
- else {
183
- return '如果你要查询升级头目,请输入"升级 等级数"来进行查询哦';
184
- }
185
- }
186
- });
187
303
  ctx.middleware(async (session, next) => {
188
304
  let { elements, messageId, userId, content } = session;
189
305
  let isAt = {};
190
306
  for (const element of elements) {
191
307
  if (element.type == "at") {
192
308
  if (element.attrs.id == config.机器人qq) {
193
- return '魔法书现有功能:\n①升级 等级数:查询该等级升级头目\n②天气预报:查看本次大更新的覆盖内容\n③组队 时间/截止时间 求组内容:发布组队信息到组队大厅\n④组队大厅 页码数:查看组队大厅\n⑤取消组队:取消自己正在发布的组队';
309
+ return '魔法书现有功能:\n①升级 等级数:查询该等级升级头目\n②天气预报:查看本次大更新的覆盖内容\n③料理 料理名称 [料理等级]:查询高级料理名单';
194
310
  }
195
311
  }
196
312
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-toram",
3
3
  "description": "托拉姆物语小工具",
4
- "version": "0.3.2",
4
+ "version": "0.3.4",
5
5
  "contributors": [
6
6
  "青灯 <1874053520@qq.com>"
7
7
  ],
package/readme.md CHANGED
@@ -3,10 +3,29 @@
3
3
  [![npm](https://img.shields.io/npm/v/koishi-plugin-toram?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-toram)
4
4
 
5
5
  基于koishi制作的托拉姆物语qq机器人插件
6
- code的lib文件夹里附带运行所需数据表,用sqlstudio打开.toram.db和.koishi.db,在.koishi.db中删去.toram.db中有的表并将.toram.db中的表复制到.koishi.db
7
- .koishi.db一般在Users下的\AppData\Roaming\Koishi\Desktop\data\instances\default
6
+
7
+ 由于技术力原因,运行所需数据表暂存在lib文件夹里(.toram.db),需要手动导入
8
+
9
+ QQ:1874053520
10
+
11
+ ————————————
12
+
13
+ 0.3.4
14
+
15
+ 料理查询功能优化
16
+
17
+ ————————————
18
+
19
+ 0.3.3
20
+
21
+ 新增料理查询功能【需要数据表toram_dishes及toram_dishes_name】
22
+
23
+ ————————————
8
24
 
9
25
  0.3.2
26
+
10
27
  本插件当前具有以下功能:
28
+
11
29
  1.升级查询【需要数据表toram_boss】
30
+
12
31
  2.组队大厅相关