koishi-plugin-ggcevo-game 0.3.23 → 0.4.2

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
@@ -6,6 +6,7 @@ export interface Config {
6
6
  ggcqun: string;
7
7
  signrequire: boolean;
8
8
  autorank: boolean;
9
+ ignoreGlobalLimit: boolean;
9
10
  }
10
11
  export declare const Config: Schema<Config>;
11
12
  export declare const inject: {
@@ -83,6 +84,7 @@ export interface exchange {
83
84
  item: string;
84
85
  type: string;
85
86
  date: Date;
87
+ GlobalLimit: boolean;
86
88
  }
87
89
  export interface adminbenefit {
88
90
  userId: string;
package/lib/index.js CHANGED
@@ -33,7 +33,8 @@ var Config = import_koishi.Schema.object({
33
33
  proxyAgent: import_koishi.Schema.string().description("代理服务器地址"),
34
34
  ggcqun: import_koishi.Schema.string().description("开启咕咕虫排行榜的群组").required(),
35
35
  signrequire: import_koishi.Schema.boolean().description("是否开启签到要求每日一场").default(true),
36
- autorank: import_koishi.Schema.boolean().description("是否开启每小时自动同步rank数据").default(true)
36
+ autorank: import_koishi.Schema.boolean().description("是否开启每小时自动同步rank数据").default(true),
37
+ ignoreGlobalLimit: import_koishi.Schema.boolean().description("是否开启无限制兑换").default(false)
37
38
  });
38
39
  var inject = {
39
40
  required: ["database"]
@@ -135,7 +136,8 @@ function apply(ctx, config) {
135
136
  item: "string",
136
137
  // 兑换物品
137
138
  type: "string",
138
- date: "timestamp"
139
+ date: "timestamp",
140
+ GlobalLimit: "boolean"
139
141
  }, {
140
142
  // 额外配置
141
143
  primary: ["handle", "item"]
@@ -578,7 +580,7 @@ ${itemDetails.join("\n")}`;
578
580
  });
579
581
  ctx.command("ggcevo/领取福利").alias("领取奖励").action(async (argv) => {
580
582
  const session = argv.session;
581
- await session.send("请在30秒内输入活动名称:\n(输入 咕咕币活动 以查看活动列表)");
583
+ await session.send("请在30秒内输入活动名称:");
582
584
  const name2 = await session.prompt(3e4);
583
585
  if (!name2) {
584
586
  return "输入超时,请重新输入指令。";
@@ -599,7 +601,7 @@ ${itemDetails.join("\n")}`;
599
601
  // 新增状态条件
600
602
  });
601
603
  if (!activity) {
602
- return "当前活动未在进行中,请检查活动名称";
604
+ return "当前活动未在进行中,请检查输入 咕咕币活动 查看正在进行中的活动。";
603
605
  }
604
606
  const id = activity.id;
605
607
  const quantity = activity.quantity;
@@ -911,18 +913,22 @@ ID:${activity.id}
911
913
  ------------------------------`;
912
914
  }
913
915
  });
914
- ctx.command("ggcevo/给予咕咕币 <handle> <amount:number>", "增加指定用户的咕咕币", { authority: 3 }).action(async (_, handle, amount) => {
916
+ ctx.command("ggcevo/给予 <handle> <itemId:number> <amount:number>", "增加指定用户的物品", { authority: 3 }).action(async (_, handle, itemId, amount) => {
915
917
  try {
916
- const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 1 });
917
- if (!backpack) {
918
- return "该用户不存在";
918
+ if (!handle || !itemId || !amount) {
919
+ return `请输入正确的指令格式`;
919
920
  }
921
+ const itemIdToNameMap = Object.fromEntries(
922
+ Object.entries(initDefaultItems).map(([name2, item]) => [item.id, name2])
923
+ );
924
+ const itemName = itemIdToNameMap[itemId];
925
+ const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId });
920
926
  await ctx.database.upsert("ggcevo_backpack", [{
921
927
  handle,
922
- itemId: 1,
928
+ itemId,
923
929
  quantity: (backpack?.quantity || 0) + amount
924
- }]);
925
- return `成功为 ${handle} 增加 ${amount} 个咕咕币!`;
930
+ }], ["handle", "itemId"]);
931
+ return `成功为 ${handle} 增加 ${amount} 个${itemName}!`;
926
932
  } catch (err) {
927
933
  console.error("数据库操作失败:", err);
928
934
  return "操作失败,请稍后再试";
@@ -993,9 +999,9 @@ ID:${activity.id}
993
999
  "小黄鸭": { quality: "t3", type: "宠物", cost: 3, quantity: 5 },
994
1000
  "萌萌熊": { quality: "t2", type: "宠物", cost: 4, quantity: 3 },
995
1001
  "荆棘蜥蜴": { quality: "t2", type: "宠物", cost: 4, quantity: 3 },
996
- "爆笑小狗": { quality: "t1", type: "宠物", cost: 5, quantity: 2 },
1002
+ "萌宠小狗": { quality: "t1", type: "宠物", cost: 5, quantity: 2 },
997
1003
  "熔岩蟹": { quality: "t1", type: "宠物", cost: 5, quantity: 2 },
998
- "远古蝗虫": { quality: "t1", type: "宠物", cost: 5, quantity: 2 },
1004
+ "尸甲虫": { quality: "t1", type: "宠物", cost: 5, quantity: 2 },
999
1005
  "绿毛虫": { quality: "t0", type: "宠物", cost: 6, quantity: 1 },
1000
1006
  "妙蛙种子": { quality: "t0", type: "宠物", cost: 6, quantity: 1 },
1001
1007
  "皮卡丘": { quality: "t0", type: "宠物", cost: 6, quantity: 1 },
@@ -1033,8 +1039,8 @@ ${items.join("、")}
1033
1039
  if (!configname) return "无效的物品名称,请重新输入";
1034
1040
  const userRecords = await ctx.database.get("ggcevo_exchange", { handle, item: name2 });
1035
1041
  if (userRecords.length > 0) return "您已经兑换过该物品";
1036
- if (configname.quantity !== void 0) {
1037
- const globalRecords = await ctx.database.get("ggcevo_exchange", { item: name2 });
1042
+ if (configname.quantity !== void 0 && config.ignoreGlobalLimit === false) {
1043
+ const globalRecords = await ctx.database.get("ggcevo_exchange", { item: name2, GlobalLimit: true });
1038
1044
  if (globalRecords.length >= configname.quantity) return "该物品已被兑换尽了";
1039
1045
  }
1040
1046
  const qualityMap = { "t3": 4, "t2": 5, "t1": 6, "t0": 7 };
@@ -1062,6 +1068,7 @@ ${items.join("、")}
1062
1068
  return `${requireMsg}
1063
1069
  当前持有:${coupon?.quantity || 0}个${couponName}`;
1064
1070
  }
1071
+ const isGlobal = config.ignoreGlobalLimit === false;
1065
1072
  await ctx.database.withTransaction(async () => {
1066
1073
  await ctx.database.set(
1067
1074
  "ggcevo_backpack",
@@ -1074,7 +1081,9 @@ ${items.join("、")}
1074
1081
  item: name2,
1075
1082
  type: configname.type,
1076
1083
  // 从配置中获取类型
1077
- date: /* @__PURE__ */ new Date()
1084
+ date: /* @__PURE__ */ new Date(),
1085
+ GlobalLimit: isGlobal
1086
+ // 关键字段设置
1078
1087
  });
1079
1088
  });
1080
1089
  return `兑换成功!消耗 ${cost} 个${couponName}获得【${name2}】`;
@@ -1186,7 +1195,7 @@ ${output}`;
1186
1195
  });
1187
1196
  return `✅ 用户 ${handle} 已被列入黑名单`;
1188
1197
  } catch (error) {
1189
- ctx.logger.error("黑名单操作失败:", error);
1198
+ console.error("黑名单操作失败:", error);
1190
1199
  return "操作失败,请稍后重试。错误详情已记录";
1191
1200
  }
1192
1201
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ggcevo-game",
3
- "description": "星际争霸2游戏大厅地图咕咕虫-evo小游戏",
4
- "version": "0.3.23",
3
+ "description": "星际争霸2游戏大厅咕咕虫-evolved地图专属插件",
4
+ "version": "0.4.2",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
package/readme.md CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/koishi-plugin-ggcevo-game?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-ggcevo-game)
4
4
 
5
-
5
+ 2