koishi-plugin-toram 0.3.3 → 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 CHANGED
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', {
@@ -55,60 +56,108 @@ async function apply(ctx, config) {
55
56
  '上午': 12 * 60 * 60 * 1000,
56
57
  '下午': 18 * 60 * 60 * 1000,
57
58
  };
58
- ctx.command('料理 <料理种类>').action(async ({ session }, ...args) => {
59
+ ctx.command('料理 <料理种类> <料理等级>').action(async ({ session }, ...args) => {
59
60
  {
60
61
  let 料理名称 = args[0], 等级筛选 = args[1];
61
62
  if (料理名称 == undefined) {
62
- return '如果你要查询高级料理,请输入"料理 料理种类"来进行查询哦';
63
+ return '如果你要查询料理,请输入"料理 料理种类 [料理等级]"来进行查询哦';
63
64
  }
64
65
  const rows1 = await ctx.database.get('toram_dishes_name', { name: [料理名称] });
65
66
  const 料理类型 = rows1[0]?.type || '不存在';
66
67
  if (料理类型 == '不存在') {
67
68
  return '这是能吃的吗?';
68
69
  }
69
- let 十级料理信息结果;
70
- let 九级料理信息结果;
71
- const rows2 = await ctx.database.get('toram_dishes', { $and: [{ type: [料理类型] }, { level: [10] }] });
72
- if (rows2.length != 0) {
73
- 十级料理信息结果 = rows2.map((player) => {
74
- return `${player?.name}`;
75
- })
76
- .sort();
77
- }
78
- const rows3 = await ctx.database.get('toram_dishes', { $and: [{ type: [料理类型] }, { level: [9] }] });
79
- if (rows3.length != 0) {
80
- 九级料理信息结果 = rows3.map((player) => {
81
- return `${player?.name}`;
82
- })
83
- .sort();
84
- }
85
- if (rows2.length == 0 && rows3.length == 0) {
86
- let rows4 = await ctx.database.get('toram_dishes', { type: [料理类型] });
87
- if (rows4.length != 0) {
88
- rows4.sort(function (a, b) {
89
- let alv = a.level;
90
- let blv = b.level;
91
- return b - a;
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);
92
81
  });
93
- const 八级以下料理信息结果 = rows4.map((player) => {
94
- return `${player?.name}(${player?.level})`;
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}`;
95
87
  })
96
- .sort();
97
- text = 料理类型 + '(' + 料理名称 + ')名单如下:\n' + 八级以下料理信息结果;
98
- text = text.replace(/,/g, ',');
99
- return text;
88
+ .sort(function compareFunction(item1, item2) {
89
+ return item1.localeCompare(item2);
90
+ });
100
91
  }
101
- return '还没有记录有这种料理呢——';
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;
102
139
  }
103
- text = 料理类型 + '(' + 料理名称 + ')名单如下:';
104
- if (rows2.length != 0) {
105
- text += '\n10级:\n' + 十级料理信息结果;
140
+ if (isNaN(Number(等级筛选)) || Number.isInteger(Number(等级筛选)) == false || 等级筛选 <= 0 || 等级筛选 > 10) {
141
+ return '找不到!怎么想都找不到吧!';
106
142
  }
107
- if (rows3.length != 0) {
108
- text += '\n9级:\n' + 九级料理信息结果;
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;
109
159
  }
110
- text = text.replace(/,/g, '');
111
- return text;
160
+ return '还没有记录有这个等级的这种料理呢——';
112
161
  }
113
162
  });
114
163
  ctx.command('升级 <等级数>').action(async ({ session }, 等级) => {
@@ -131,7 +180,7 @@ async function apply(ctx, config) {
131
180
  const rows1 = await ctx.database.get('toram_boss', { level: { $gte: 等级 - 8, $lte: Math.min(等级 + 8, config.版本等级 + 3) } });
132
181
  const 等级符合定点王 = rows1.filter(row => row.type === '定点王');
133
182
  n = 等级符合定点王.length - 1;
134
- text = 等级 + '级升级所需经验为' + 经验 + '\n定点王:\n';
183
+ text = 等级 + '级升级所需经验为' + 经验 + '\n\n定点王:\n';
135
184
  const 等级符合定点王经验 = 等级符合定点王.map((boss) => {
136
185
  x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
137
186
  return boss.baseEXP * x;
@@ -148,7 +197,7 @@ async function apply(ctx, config) {
148
197
  text += 定点王信息结果;
149
198
  const 等级符合野王 = rows1.filter(row => row.type === '野王');
150
199
  n = 等级符合野王.length - 1;
151
- text += '\n野王:\n';
200
+ text += '\n\n野王:\n';
152
201
  const 等级符合野王经验 = 等级符合野王.map((boss) => {
153
202
  x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
154
203
  return boss.baseEXP * x;
@@ -257,7 +306,7 @@ async function apply(ctx, config) {
257
306
  for (const element of elements) {
258
307
  if (element.type == "at") {
259
308
  if (element.attrs.id == config.机器人qq) {
260
- return '魔法书现有功能:\n①升级 等级数:查询该等级升级头目\n②天气预报:查看本次大更新的覆盖内容\n③料理 料理名称:查询高级料理名单';
309
+ return '魔法书现有功能:\n①升级 等级数:查询该等级升级头目\n②天气预报:查看本次大更新的覆盖内容\n③料理 料理名称 [料理等级]:查询高级料理名单';
261
310
  }
262
311
  }
263
312
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-toram",
3
3
  "description": "托拉姆物语小工具",
4
- "version": "0.3.3",
4
+ "version": "0.3.4",
5
5
  "contributors": [
6
6
  "青灯 <1874053520@qq.com>"
7
7
  ],
package/readme.md CHANGED
@@ -4,13 +4,21 @@
4
4
 
5
5
  基于koishi制作的托拉姆物语qq机器人插件
6
6
 
7
- 由于技术力原因,使用请联系QQ1874053520获取运行所需数据表
7
+ 由于技术力原因,运行所需数据表暂存在lib文件夹里(.toram.db),需要手动导入
8
+
9
+ QQ:1874053520
10
+
11
+ ————————————
12
+
13
+ 0.3.4
14
+
15
+ 料理查询功能优化
8
16
 
9
17
  ————————————
10
18
 
11
19
  0.3.3
12
20
 
13
- 新增料理查询功能
21
+ 新增料理查询功能【需要数据表toram_dishes及toram_dishes_name】
14
22
 
15
23
  ————————————
16
24