koishi-plugin-xxck-1 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/index.d.ts CHANGED
@@ -9,6 +9,8 @@ export interface PluginConfig {
9
9
  exchangeVaporPerDraw: number;
10
10
  eventExchangePrice6: number;
11
11
  eventExchangePrice7: number;
12
+ collectionPart1Pattern: string;
13
+ collectionPart2Pattern: string;
12
14
  normalStar7Threshold: number;
13
15
  normalStar6Threshold: number;
14
16
  normalStar6Prob: number;
@@ -23,6 +25,8 @@ export declare const Config: Schema<Schemastery.ObjectS<{
23
25
  exchangeVaporPerDraw: Schema<number, number>;
24
26
  eventExchangePrice6: Schema<number, number>;
25
27
  eventExchangePrice7: Schema<number, number>;
28
+ collectionPart1Pattern: Schema<string, string>;
29
+ collectionPart2Pattern: Schema<string, string>;
26
30
  normalStar7Threshold: Schema<number, number>;
27
31
  normalStar6Threshold: Schema<number, number>;
28
32
  normalStar6Prob: Schema<number, number>;
@@ -36,6 +40,8 @@ export declare const Config: Schema<Schemastery.ObjectS<{
36
40
  exchangeVaporPerDraw: Schema<number, number>;
37
41
  eventExchangePrice6: Schema<number, number>;
38
42
  eventExchangePrice7: Schema<number, number>;
43
+ collectionPart1Pattern: Schema<string, string>;
44
+ collectionPart2Pattern: Schema<string, string>;
39
45
  normalStar7Threshold: Schema<number, number>;
40
46
  normalStar6Threshold: Schema<number, number>;
41
47
  normalStar6Prob: Schema<number, number>;
package/lib/index.js CHANGED
@@ -43,7 +43,7 @@ var zh_CN_default = {
43
43
  "command.wwc.help.shop": "店铺:查看今日可升格卡片 | 指令:WWC店铺 | 说明:每日随机刷新3个7星卡,全服限购",
44
44
  "command.wwc.help.upgrade": "升格:兑换店铺卡片 | 指令:WWC升格 [卡片编号...] | 说明:消耗热带扰动,重复卡片自动升级",
45
45
  "command.wwc.help.exchange": "兑换:水汽换普通抽数 | 指令:WWC兑换 [次数] | 说明:100水汽=1抽,每日上限80抽,单次1-40",
46
- "command.wwc.help.collection": "收藏:查看卡片收藏进度 | 指令:WWC收藏 | 说明:生成收藏进度图片,含普通+限定卡",
46
+ "command.wwc.help.collection": "收藏:查看卡片收藏进度 | 指令:WWC收藏(全部分类);WWC收藏1 / WWC收藏2 / WWC收藏3 为拆分版(分类正则可在插件配置项 collectionPart1Pattern / collectionPart2Pattern 中定义,收藏3 = 两者都不匹配的类别)| 说明:含普通+限定卡",
47
47
  "command.wwc.help.ranking": "排名:查看全服收藏排行 | 指令:WWC排名1/WWC排行1 | 说明:显示前20名+自身排名,按收藏数排序",
48
48
  "command.wwc.help.eventStatus": "限时状态:查看开放的限时卡池 | 指令:WWC限时状态 | 说明:显示期数/名称/星级/开放时间",
49
49
  "command.wwc.help.eventDraw": "限时抽卡:参与限时卡池 | 指令:WWC限时抽卡 [期数] [次数] | 说明:1-20连,消耗限时抽数,无期限数匹配唯一开放池",
@@ -142,6 +142,9 @@ var zh_CN_default = {
142
142
  "image.shop.footerTip": "每日刷新卡片,全服限购5次",
143
143
  "image.shop.cmdTemplate": "WWC升格 {cid}",
144
144
  "image.collection.title": "{showName} 的卡片收藏图鉴(含限定卡)",
145
+ "image.collection.title1": "{showName} 的卡片收藏图鉴1(分类规则见配置项)",
146
+ "image.collection.title2": "{showName} 的卡片收藏图鉴2(分类规则见配置项)",
147
+ "image.collection.title3": "{showName} 的卡片收藏图鉴3(其他类别)",
145
148
  "image.collection.totalProgress": "总收藏进度:{collected}/{total}({rate}%)",
146
149
  "image.collection.emptyText": "暂无任何卡片收藏,快去抽卡解锁图鉴吧!",
147
150
  "image.collection.cateTitleFormat": "【{cate}】",
@@ -172,6 +175,8 @@ var Config = import_koishi.Schema.object({
172
175
  exchangeVaporPerDraw: import_koishi.Schema.number().description("普通兑换每抽消耗的水汽量(默认100)").default(100).min(0).max(1e4),
173
176
  eventExchangePrice6: import_koishi.Schema.number().description("限时卡池6星兑换每抽消耗的水汽量(默认300)").default(300).min(1).max(1e4),
174
177
  eventExchangePrice7: import_koishi.Schema.number().description("限时卡池7星兑换每抽消耗的水汽量(默认450)").default(450).min(1).max(1e4),
178
+ collectionPart1Pattern: import_koishi.Schema.string().description('WWC收藏1的分类正则:类别名匹配此正则的归入收藏图1(默认匹配"纯数字且≥2000")').default("^([2-9]\\d{3}|\\d{5,})$").role("textarea"),
179
+ collectionPart2Pattern: import_koishi.Schema.string().description('WWC收藏2的分类正则:类别名匹配此正则的归入收藏图2(默认匹配"纯数字且<2000");两个正则都不匹配的类别归入WWC收藏3').default("^(\\d{1,3}|1\\d{3})$").role("textarea"),
175
180
  normalStar7Threshold: import_koishi.Schema.number().description("普通卡池7星保底抽数(默认1500)").default(1500).min(1).max(1e4),
176
181
  normalStar6Threshold: import_koishi.Schema.number().description("普通卡池6星保底抽数(默认300)").default(300).min(1).max(1e4),
177
182
  normalStar6Prob: import_koishi.Schema.number().description("普通卡池6星保底抽出6星概率百分比(减去为抽出7星概率)").default(90).min(0).max(100),
@@ -1157,8 +1162,27 @@ ${session.text("tip.exchange.info", {
1157
1162
  ctx.logger.info(`[普通兑换抽数] 玩家${qq}兑换成功:获得${exchange_num}抽,今日剩余${leftToday}抽`);
1158
1163
  }
1159
1164
  __name(_do_exchange, "_do_exchange");
1160
- async function _do_collection(ctx, session) {
1161
- ctx.logger.info("收到指令:WWC收藏(含限定卡+灰色占位)");
1165
+ var DEFAULT_COLLECTION_PART1_PATTERN = "^([2-9]\\d{3}|\\d{5,})$";
1166
+ var DEFAULT_COLLECTION_PART2_PATTERN = "^(\\d{1,3}|1\\d{3})$";
1167
+ function compileCollectionPatterns(ctx, part1, part2) {
1168
+ const compile = /* @__PURE__ */ __name((pattern, fallback, label) => {
1169
+ const source = (pattern ?? "").trim() || fallback;
1170
+ try {
1171
+ return new RegExp(source);
1172
+ } catch (e) {
1173
+ ctx.logger.warn(`收藏图${label}分类正则无效(${source}),已回退默认规则`);
1174
+ return new RegExp(fallback);
1175
+ }
1176
+ }, "compile");
1177
+ return {
1178
+ part1: compile(part1, DEFAULT_COLLECTION_PART1_PATTERN, "1"),
1179
+ part2: compile(part2, DEFAULT_COLLECTION_PART2_PATTERN, "2")
1180
+ };
1181
+ }
1182
+ __name(compileCollectionPatterns, "compileCollectionPatterns");
1183
+ async function _do_collection(ctx, session, part, patterns) {
1184
+ const partPatterns = patterns ?? compileCollectionPatterns(ctx);
1185
+ ctx.logger.info(`收到指令:WWC收藏${part ?? ""}(含限定卡+灰色占位)`);
1162
1186
  try {
1163
1187
  const qq = await getUnifiedQQ(ctx, session);
1164
1188
  const user = await ctx.database.get("gacha_user", { qq });
@@ -1194,11 +1218,19 @@ async function _do_collection(ctx, session) {
1194
1218
  }
1195
1219
  });
1196
1220
  const allCards = Array.from(allCardMap.values());
1197
- const totalAll = allCards.length;
1198
- const totalCollected = allCards.filter((c) => userCardIds.has(c.id)).length;
1221
+ const isTargetCategory = /* @__PURE__ */ __name((cate) => {
1222
+ if (!part) return true;
1223
+ const c = cate || "";
1224
+ if (part === 1) return partPatterns.part1.test(c);
1225
+ if (part === 2) return partPatterns.part2.test(c);
1226
+ return !partPatterns.part1.test(c) && !partPatterns.part2.test(c);
1227
+ }, "isTargetCategory");
1228
+ const partCards = allCards.filter((c) => isTargetCategory(c.category));
1229
+ const totalAll = partCards.length;
1230
+ const totalCollected = partCards.filter((c) => userCardIds.has(c.id)).length;
1199
1231
  const totalRate = totalAll > 0 ? (totalCollected / totalAll * 100).toFixed(1) : "0.0";
1200
1232
  const categoryGroup = {};
1201
- allCards.forEach((card) => {
1233
+ partCards.forEach((card) => {
1202
1234
  const cate = card.category || "未分类";
1203
1235
  if (!categoryGroup[cate]) categoryGroup[cate] = [];
1204
1236
  categoryGroup[cate].push({
@@ -1208,7 +1240,8 @@ async function _do_collection(ctx, session) {
1208
1240
  });
1209
1241
  });
1210
1242
  const categories = Object.keys(categoryGroup).sort();
1211
- const titleText = session.text("image.collection.title", { showName: show_name });
1243
+ const titleKey = part === 1 ? "image.collection.title1" : part === 2 ? "image.collection.title2" : part === 3 ? "image.collection.title3" : "image.collection.title";
1244
+ const titleText = session.text(titleKey, { showName: show_name });
1212
1245
  const totalText = session.text("image.collection.totalProgress", {
1213
1246
  collected: totalCollected,
1214
1247
  total: totalAll,
@@ -1686,13 +1719,6 @@ async function _do_event_draw(ctx, session, data, event6Threshold, event7Thresho
1686
1719
  };
1687
1720
  await ctx.database.upsert("gacha_user_event_pity", [updatePityData]);
1688
1721
  ctx.logger.info(`[限时保底记录更新] ${showName}(${qq}) 卡池${code},累计抽数:${newPityCount},已获得:${currentPity.hasGot}`);
1689
- for (const card of highStarCards) {
1690
- await session.send(build_msg(session, session.text("draw.broadcast.title")));
1691
- await new Promise((r) => setTimeout(r, 3e3));
1692
- const starText = get_star_symbol(card.card_star);
1693
- session.text("draw.broadcast.getCard", { name: showName, star: starText, id: card.card_id, cardName: card.card_name });
1694
- await new Promise((r) => setTimeout(r, 1e3));
1695
- }
1696
1722
  let msg = session.text("tip.draw.complete", { name: showName }) + "\n";
1697
1723
  drawResult.forEach((card) => {
1698
1724
  const starSymbol = get_star_symbol(card.card_star);
@@ -2038,11 +2064,27 @@ async function apply(ctx, config) {
2038
2064
  const num = Number.isInteger(Number(count)) && Number(count) >= 1 && Number(count) <= 40 ? Number(count) : 1;
2039
2065
  await _do_exchange(ctx, session, num, config.dailyExchangeLimit, config.exchangeVaporPerDraw);
2040
2066
  });
2067
+ const collectionPatterns = compileCollectionPatterns(ctx, config.collectionPart1Pattern, config.collectionPart2Pattern);
2041
2068
  ctx.command("WWC收藏", "查看卡片收藏进度,含限定卡,生成可视化收藏图").alias("wwc收藏").alias("WWC收集进度").action(async (argv) => {
2042
2069
  if (!argv.session) return;
2043
2070
  const session = argv.session;
2044
2071
  await _do_collection(ctx, session);
2045
2072
  });
2073
+ ctx.command("WWC收藏1", "查看卡片收藏进度1(分类正则见配置项 collectionPart1Pattern),含限定卡,生成可视化收藏图").alias("wwc收藏1").action(async (argv) => {
2074
+ if (!argv.session) return;
2075
+ const session = argv.session;
2076
+ await _do_collection(ctx, session, 1, collectionPatterns);
2077
+ });
2078
+ ctx.command("WWC收藏2", "查看卡片收藏进度2(分类正则见配置项 collectionPart2Pattern),含限定卡,生成可视化收藏图").alias("wwc收藏2").action(async (argv) => {
2079
+ if (!argv.session) return;
2080
+ const session = argv.session;
2081
+ await _do_collection(ctx, session, 2, collectionPatterns);
2082
+ });
2083
+ ctx.command("WWC收藏3", "查看卡片收藏进度3(不匹配收藏1/2正则的类别),含限定卡,生成可视化收藏图").alias("wwc收藏3").action(async (argv) => {
2084
+ if (!argv.session) return;
2085
+ const session = argv.session;
2086
+ await _do_collection(ctx, session, 3, collectionPatterns);
2087
+ });
2046
2088
  ctx.command("WWC排名1", "查看全服收藏排行,显示前20名+自身排名,生成可视化排行图").alias("wwc排名1").alias("WWC排行1").alias("WWC榜单").action(async (argv) => {
2047
2089
  if (!argv.session) return;
2048
2090
  const session = argv.session;
@@ -93,6 +93,9 @@ declare const _default: {
93
93
  "image.shop.footerTip": string;
94
94
  "image.shop.cmdTemplate": string;
95
95
  "image.collection.title": string;
96
+ "image.collection.title1": string;
97
+ "image.collection.title2": string;
98
+ "image.collection.title3": string;
96
99
  "image.collection.totalProgress": string;
97
100
  "image.collection.emptyText": string;
98
101
  "image.collection.cateTitleFormat": string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-xxck-1",
3
3
  "description": "抽卡系统|完整指令说明见readme|建议使用skia-canvas",
4
- "version": "0.3.2",
4
+ "version": "0.3.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [