koishi-plugin-toram 0.3.4 → 0.3.6

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 CHANGED
Binary file
package/lib/index.js CHANGED
@@ -9,7 +9,7 @@ exports.Config = koishi_1.Schema.object({
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
+ 料理_最低返回数量要求: koishi_1.Schema.number().default(15)
13
13
  });
14
14
  async function apply(ctx, config) {
15
15
  ctx.model.extend('toram_boss', {
@@ -27,7 +27,8 @@ async function apply(ctx, config) {
27
27
  id: 'number',
28
28
  name: 'string',
29
29
  type: 'string',
30
- level: 'number'
30
+ level: 'number',
31
+ effect: 'string'
31
32
  }, {
32
33
  primary: 'id'
33
34
  });
@@ -38,6 +39,13 @@ async function apply(ctx, config) {
38
39
  }, {
39
40
  primary: 'id'
40
41
  });
42
+ ctx.model.extend('toram_dishes_effect', {
43
+ id: 'number',
44
+ type: 'string',
45
+ effect: 'string'
46
+ }, {
47
+ primary: 'id'
48
+ });
41
49
  ctx.model.extend('toram_team', {
42
50
  id: 'string',
43
51
  form: 'number',
@@ -49,140 +57,159 @@ async function apply(ctx, config) {
49
57
  primary: 'id'
50
58
  });
51
59
  let n;
60
+ let i;
52
61
  let x;
62
+ let xx;
53
63
  let text;
54
64
  let 等级差倍率 = [11, 11, 11, 11, 11, 10, 9, 7, 3];
55
65
  let 时间戳增加对应 = {
56
66
  '上午': 12 * 60 * 60 * 1000,
57
67
  '下午': 18 * 60 * 60 * 1000,
58
68
  };
69
+ ctx.middleware(async (session, next) => {
70
+ let { elements, messageId, userId, content } = session;
71
+ let isAt = {};
72
+ for (const element of elements) {
73
+ if (element.type == "at") {
74
+ if (element.attrs.id == config.机器人qq) {
75
+ return '魔法书现有功能:\n①升级 等级数:查询该等级升级头目\n②天气预报:查看本次大更新的覆盖内容\n③料理 料理名称 [料理等级]:查询高级料理名单(结果通常用拼音排序)\n④料理 玩家名称:查询该玩家的料理信息';
76
+ }
77
+ }
78
+ }
79
+ return next();
80
+ });
81
+ ctx.middleware((session, next) => {
82
+ if (session.content === '天气预报') {
83
+ return '【托拉姆物语3.24大更一览-哔哩哔哩】 https://b23.tv/cWX9yjU';
84
+ }
85
+ else {
86
+ return next;
87
+ }
88
+ });
59
89
  ctx.command('料理 <料理种类> <料理等级>').action(async ({ session }, ...args) => {
60
90
  {
61
- let 料理名称 = args[0], 等级筛选 = args[1];
62
- if (料理名称 == undefined) {
63
- return '如果你要查询料理,请输入"料理 料理种类 [料理等级]"来进行查询哦';
91
+ let DishesName = args[0], DishesLevelChoice = args[1];
92
+ if (DishesName == undefined) {
93
+ return '如果你要查询料理,请输入"料理 料理种类 [料理等级]"或"料理 玩家名称"来进行查询哦';
64
94
  }
65
- const rows1 = await ctx.database.get('toram_dishes_name', { name: [料理名称] });
66
- const 料理类型 = rows1[0]?.type || '不存在';
67
- if (料理类型 == '不存在') {
68
- return '这是能吃的吗?';
95
+ const GetDishesType = await ctx.database.get('toram_dishes_name', { name: [DishesName] });
96
+ const DishesType = GetDishesType[0]?.type || 'none';
97
+ if (DishesType == 'none') {
98
+ const OnesName = DishesName;
99
+ const GetOnesDishes = await ctx.database.get('toram_dishes', { name: [OnesName] });
100
+ n = GetOnesDishes.length;
101
+ if (n != 0) {
102
+ GetOnesDishes.sort(function (a, b) {
103
+ let alv = a.level;
104
+ let blv = b.level;
105
+ return b - a;
106
+ });
107
+ let OnesDishes = GetOnesDishes.map((Dishes) => {
108
+ return `${Dishes?.type}(${Dishes?.effect}${Dishes?.level}级)`;
109
+ }).join(',');
110
+ text = OnesName + '的料理信息如下:\n' + OnesDishes;
111
+ return text;
112
+ }
113
+ return '还没有记录有这个人制作的料理呢——';
69
114
  }
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) => {
115
+ const DishesEffectArr = await ctx.database.get('toram_dishes_effect', { type: [DishesType] });
116
+ const DishesEffect = DishesEffectArr[0]?.effect;
117
+ if (DishesLevelChoice == undefined) {
118
+ let Level10Dishes, Level9Dishes, Level8Dishes;
119
+ const GetLevel10Dishes = await ctx.database.get('toram_dishes', { $and: [{ type: [DishesType] }, { level: [10] }] });
120
+ if (GetLevel10Dishes.length != 0) {
121
+ Level10Dishes = GetLevel10Dishes.map((player) => {
77
122
  return `${player?.name}`;
78
123
  })
79
124
  .sort(function compareFunction(item1, item2) {
80
125
  return item1.localeCompare(item2);
81
126
  });
82
127
  }
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) => {
128
+ const GetLevel9Dishes = await ctx.database.get('toram_dishes', { $and: [{ type: [DishesType] }, { level: [9] }] });
129
+ if (GetLevel9Dishes.length != 0 && GetLevel10Dishes.length < config.料理_最低返回数量要求) {
130
+ Level9Dishes = GetLevel9Dishes.map((player) => {
86
131
  return `${player?.name}`;
87
132
  })
88
133
  .sort(function compareFunction(item1, item2) {
89
134
  return item1.localeCompare(item2);
90
135
  });
91
136
  }
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) {
137
+ if (GetLevel10Dishes.length == 0 && GetLevel9Dishes.length == 0) {
138
+ let GetAllLevelDishes = await ctx.database.get('toram_dishes', { type: [DishesType] });
139
+ if (GetAllLevelDishes.length != 0) {
140
+ GetAllLevelDishes.sort(function (a, b) {
96
141
  let alv = a.level;
97
142
  let blv = b.level;
98
143
  return b - a;
99
144
  });
100
- const 八级以下料理信息结果 = rows4.map((player) => {
145
+ const LevelUnder8Dishes = GetAllLevelDishes.map((player) => {
101
146
  return `${player?.name}(${player?.level}级)`;
102
- })
103
- .sort(function compareFunction(item1, item2) {
104
- return item1.localeCompare(item2);
105
147
  });
106
- text = 料理类型;
107
- if (料理类型 != 料理名称) {
108
- text += '(' + 料理名称 + ')';
109
- }
110
- text += '名单如下:\n' + 八级以下料理信息结果;
148
+ text = DishesType + '(' + DishesEffect + ')名单如下:\n' + LevelUnder8Dishes;
111
149
  text = text.replace(/,/g, ',');
112
150
  return text;
113
151
  }
114
152
  return '还没有记录有这种料理呢——';
115
153
  }
116
- text = 料理类型;
117
- if (料理类型 != 料理名称) {
118
- text += '(' + 料理名称 + ')';
154
+ text = DishesType + '(' + DishesEffect + ')名单如下:';
155
+ if (GetLevel10Dishes.length != 0) {
156
+ text += '\n10级:\n' + Level10Dishes;
119
157
  }
120
- text += '名单如下:';
121
- if (rows2.length != 0) {
122
- text += '\n10级:\n' + 十级料理信息结果;
158
+ if (GetLevel9Dishes.length != 0 && GetLevel10Dishes.length < config.料理_最低返回数量要求) {
159
+ text += '\n9级:\n' + Level9Dishes;
123
160
  }
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) => {
161
+ if (GetLevel10Dishes.length + GetLevel9Dishes.length < config.料理_最低返回数量要求 && GetLevel10Dishes.length + GetLevel9Dishes.length > 0) {
162
+ const GetLevel8Dishes = await ctx.database.get('toram_dishes', { $and: [{ type: [DishesType] }, { level: [8] }] });
163
+ if (GetLevel8Dishes.length != 0) {
164
+ Level8Dishes = GetLevel8Dishes.map((player) => {
131
165
  return `${player?.name}`;
132
166
  })
133
167
  .sort();
134
- text += '\n8级:\n' + 八级料理信息结果;
168
+ text += '\n8级:\n' + Level8Dishes;
135
169
  }
136
170
  }
137
171
  text = text.replace(/,/g, ',');
138
172
  return text;
139
173
  }
140
- if (isNaN(Number(等级筛选)) || Number.isInteger(Number(等级筛选)) == false || 等级筛选 <= 0 || 等级筛选 > 10) {
174
+ if (isNaN(Number(DishesLevelChoice)) || Number.isInteger(Number(DishesLevelChoice)) == false || DishesLevelChoice <= 0 || DishesLevelChoice > 10) {
141
175
  return '找不到!怎么想都找不到吧!';
142
176
  }
143
- let 目标等级料理信息结果;
144
- const rows2 = await ctx.database.get('toram_dishes', { $and: [{ type: [料理类型] }, { level: [等级筛选] }] });
177
+ let LevelChoiceDishes;
178
+ const rows2 = await ctx.database.get('toram_dishes', { $and: [{ type: [DishesType] }, { level: [DishesLevelChoice] }] });
145
179
  if (rows2.length != 0) {
146
- 目标等级料理信息结果 = rows2.map((player) => {
180
+ LevelChoiceDishes = rows2.map((player) => {
147
181
  return `${player?.name}`;
148
182
  })
149
183
  .sort(function compareFunction(item1, item2) {
150
184
  return item1.localeCompare(item2);
151
185
  });
152
- text = 料理类型;
153
- if (料理类型 != 料理名称) {
154
- text += '(' + 料理名称 + ')';
155
- }
156
- text += 等级筛选 + '级名单如下:\n' + 目标等级料理信息结果;
186
+ text = DishesType + '(' + DishesEffect + ')' + DishesLevelChoice + '级名单如下:\n' + LevelChoiceDishes;
157
187
  text = text.replace(/,/g, ',');
158
188
  return text;
159
189
  }
160
190
  return '还没有记录有这个等级的这种料理呢——';
161
191
  }
162
192
  });
163
- ctx.command('升级 <等级数>').action(async ({ session }, 等级) => {
193
+ ctx.command('升级 <等级数>').action(async ({ session }, PlayerLevel) => {
164
194
  {
165
- const 经验 = Math.floor(等级 ** 4 / 40) + 等级 * 2;
166
- if (等级 != undefined) {
167
- if (isNaN(Number(等级)) || Number.isInteger(Number(等级)) == false || 等级 <= 0 || 等级 >= config.版本等级) {
195
+ const LevelUpExp = Math.floor(PlayerLevel ** 4 / 40) + PlayerLevel * 2;
196
+ if (PlayerLevel != undefined) {
197
+ if (isNaN(Number(PlayerLevel)) || Number.isInteger(Number(PlayerLevel)) == false || PlayerLevel <= 0 || PlayerLevel >= config.版本等级) {
168
198
  return '没救了,别练了,埋了罢【无慈悲】';
169
199
  }
170
- ;
171
- if (等级 < 38) {
172
- return 等级 + '级升级所需经验为' + 经验 + '\n亲亲,建议去尼山砍柴哦?';
200
+ if (PlayerLevel < 38) {
201
+ return PlayerLevel + '级升级所需经验为' + LevelUpExp + '\n亲亲,建议去尼山砍柴哦?';
173
202
  }
174
- ;
175
- if (等级 < 55) {
176
- return 等级 + '级升级所需经验为' + 经验 + '\n去女帝陵墓打只因骨龙吧~';
203
+ if (PlayerLevel < 55) {
204
+ return PlayerLevel + '级升级所需经验为' + LevelUpExp + '\n去女帝陵墓打只因骨龙吧~';
177
205
  }
178
- ;
179
- if (等级 >= 55) {
180
- const rows1 = await ctx.database.get('toram_boss', { level: { $gte: 等级 - 8, $lte: Math.min(等级 + 8, config.版本等级 + 3) } });
206
+ if (PlayerLevel >= 55) {
207
+ const rows1 = await ctx.database.get('toram_boss', { level: { $gte: PlayerLevel - 8, $lte: Math.min(PlayerLevel + 8, config.版本等级 + 3) } });
181
208
  const 等级符合定点王 = rows1.filter(row => row.type === '定点王');
182
209
  n = 等级符合定点王.length - 1;
183
- text = 等级 + '级升级所需经验为' + 经验 + '\n\n定点王:\n';
210
+ text = PlayerLevel + '级升级所需经验为' + LevelUpExp + '\n\n定点王:\n';
184
211
  const 等级符合定点王经验 = 等级符合定点王.map((boss) => {
185
- x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
212
+ x = 等级差倍率[Math.abs(PlayerLevel - boss.level)] || 0;
186
213
  return boss.baseEXP * x;
187
214
  });
188
215
  const 经验最大定点王索引 = 等级符合定点王经验.map((exp, i) => [exp, i])
@@ -191,7 +218,7 @@ async function apply(ctx, config) {
191
218
  .map(([, i]) => i);
192
219
  const 定点王信息结果 = 经验最大定点王索引.map(index => {
193
220
  const boss = 等级符合定点王[index];
194
- x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
221
+ x = 等级差倍率[Math.abs(PlayerLevel - boss.level)] || 0;
195
222
  return `${boss?.name} 等级${boss?.level} ${boss?.map} 经验值${boss?.baseEXP * x} ${boss?.element}属性`;
196
223
  }).join('\n');
197
224
  text += 定点王信息结果;
@@ -199,7 +226,7 @@ async function apply(ctx, config) {
199
226
  n = 等级符合野王.length - 1;
200
227
  text += '\n\n野王:\n';
201
228
  const 等级符合野王经验 = 等级符合野王.map((boss) => {
202
- x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
229
+ x = 等级差倍率[Math.abs(PlayerLevel - boss.level)] || 0;
203
230
  return boss.baseEXP * x;
204
231
  });
205
232
  const 经验最大野王索引 = 等级符合野王经验.map((exp, i) => [exp, i])
@@ -208,7 +235,7 @@ async function apply(ctx, config) {
208
235
  .map(([, i]) => i);
209
236
  const 野王信息结果 = 经验最大野王索引.map(index => {
210
237
  const boss = 等级符合野王[index];
211
- x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
238
+ x = 等级差倍率[Math.abs(PlayerLevel - boss.level)] || 0;
212
239
  return `${boss?.name} 等级${boss?.level} ${boss?.map} 经验值${boss?.baseEXP * x} ${boss?.element}属性`;
213
240
  }).join('\n');
214
241
  text += 野王信息结果;
@@ -300,25 +327,5 @@ async function apply(ctx, config) {
300
327
  return '你没有正在进行的组队';
301
328
  }
302
329
  });
303
- ctx.middleware(async (session, next) => {
304
- let { elements, messageId, userId, content } = session;
305
- let isAt = {};
306
- for (const element of elements) {
307
- if (element.type == "at") {
308
- if (element.attrs.id == config.机器人qq) {
309
- return '魔法书现有功能:\n①升级 等级数:查询该等级升级头目\n②天气预报:查看本次大更新的覆盖内容\n③料理 料理名称 [料理等级]:查询高级料理名单';
310
- }
311
- }
312
- }
313
- return next();
314
- });
315
- ctx.middleware((session, next) => {
316
- if (session.content === '天气预报') {
317
- return '【托拉姆物语3.24大更一览-哔哩哔哩】 https://b23.tv/cWX9yjU';
318
- }
319
- else {
320
- return next;
321
- }
322
- });
323
330
  }
324
331
  exports.apply = apply;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-toram",
3
3
  "description": "托拉姆物语小工具",
4
- "version": "0.3.4",
4
+ "version": "0.3.6",
5
5
  "contributors": [
6
6
  "青灯 <1874053520@qq.com>"
7
7
  ],
package/readme.md CHANGED
@@ -10,6 +10,18 @@ QQ:1874053520
10
10
 
11
11
  ————————————
12
12
 
13
+ 0.3.6
14
+
15
+ 料理查询功能优化【需要更新数据表】
16
+
17
+ ————————————
18
+
19
+ 0.3.5
20
+
21
+ 料理查询支持输入玩家昵称【需要数据表toram_dishes_effect】
22
+
23
+ ————————————
24
+
13
25
  0.3.4
14
26
 
15
27
  料理查询功能优化