koishi-plugin-ggcevo-game 1.3.53 → 1.3.54

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.
Files changed (2) hide show
  1. package/lib/index.js +113 -124
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -193,7 +193,7 @@ function apply(ctx, config) {
193
193
  lastPK: "timestamp",
194
194
  enable: {
195
195
  type: "boolean",
196
- initial: true
196
+ initial: false
197
197
  // 默认开启
198
198
  },
199
199
  lastToggle: "timestamp"
@@ -3075,56 +3075,39 @@ ${discountDetails.join("\n▸ ")}`;
3075
3075
  for (const key in weaponConfig) {
3076
3076
  weaponConfigById[weaponConfig[key].id] = weaponConfig[key];
3077
3077
  }
3078
- async function calculateTotalPower(handle, baseRank) {
3079
- const weapons = await ctx.database.get("ggcevo_equipment", { handle });
3080
- const careers = await ctx.database.get("ggcevo_careers", { handle });
3081
- const career = careers.length ? careers[0].career : null;
3078
+ async function calculateTotalPower(handle) {
3079
+ const [rankData] = await ctx.database.get("ggcevo_rank", {
3080
+ handle,
3081
+ rankseason: config.rankseason
3082
+ });
3083
+ const baseRank = rankData?.rank || 0;
3082
3084
  let total = baseRank;
3085
+ const [careerData] = await ctx.database.get("ggcevo_careers", { handle });
3086
+ const career = careerData?.career;
3083
3087
  if (career) {
3084
- if (career === "联盟新兵") {
3085
- total += 1e3;
3086
- } else if (career === "辛迪加炮灰新兵") {
3087
- total += 2e3;
3088
- } else if ([
3089
- "深空矿工",
3090
- "医疗专家",
3091
- "情报副官",
3092
- "总工程师",
3093
- "舰长",
3094
- "机械化专家"
3095
- ].includes(career)) {
3096
- total += 2500;
3097
- } else if ([
3098
- "清洁工",
3099
- "辛迪加财务经理",
3100
- "计算机专家",
3101
- "指挥官",
3102
- "装甲兵",
3103
- "破坏者",
3104
- "征募官"
3105
- ].includes(career)) {
3106
- total += 3e3;
3107
- } else if ([
3108
- "警卫员下士",
3109
- "警卫长",
3110
- "武器中士"
3111
- ].includes(career)) {
3112
- total += 3500;
3113
- } else if ([
3114
- "能量武器专家",
3115
- "枪手",
3116
- "猩红杀手",
3117
- "纵火狂"
3118
- ].includes(career)) {
3119
- total += 4e3;
3120
- }
3088
+ if (career === "联盟新兵") total += 1e3;
3089
+ else if (career === "辛迪加炮灰新兵") total += 2e3;
3090
+ else if (["深空矿工", "医疗专家", "情报副官", "总工程师", "舰长", "机械化专家"].includes(career)) total += 2500;
3091
+ else if (["清洁工", "辛迪加财务经理", "计算机专家", "指挥官", "装甲兵", "破坏者", "征募官"].includes(career)) total += 3e3;
3092
+ else if (["警卫员下士", "警卫长", "武器中士"].includes(career)) total += 3500;
3093
+ else if (["能量武器专家", "枪手", "猩红杀手", "纵火狂"].includes(career)) total += 4e3;
3121
3094
  }
3095
+ const weapons = await ctx.database.get("ggcevo_equipment", { handle });
3122
3096
  for (const { weaponId, level, installedMods } of weapons) {
3123
3097
  const weapon = weaponConfigById[weaponId];
3124
3098
  if (!weapon) continue;
3125
3099
  total += weapon.damage * 100;
3126
- total += level * 1e3;
3127
- total += (installedMods?.length || 0) * 2e3;
3100
+ total += level * (level + 1) / 2 * 1e3;
3101
+ for (const modName of installedMods || []) {
3102
+ const mod = modConfig[modName];
3103
+ if (mod) {
3104
+ if (mod.isExclusive) {
3105
+ total += 4e3;
3106
+ } else {
3107
+ total += 2e3;
3108
+ }
3109
+ }
3110
+ }
3128
3111
  }
3129
3112
  return total;
3130
3113
  }
@@ -4510,12 +4493,42 @@ ${items.join("、")}
4510
4493
  ctx.database.get("ggcevo_rank", { handle: initiatorHandle, rankseason: config.rankseason }),
4511
4494
  ctx.database.get("ggcevo_rank", { handle: targetHandle, rankseason: config.rankseason })
4512
4495
  ]);
4513
- const initiatorRank = initiatorData[0]?.rank || 0;
4514
- const targetRank = targetData[0]?.rank || 0;
4515
- const initiatorPower = await calculateTotalPower(initiatorHandle, initiatorRank);
4516
- const targetPower = await calculateTotalPower(targetHandle, targetRank);
4496
+ const initiatorPower = await calculateTotalPower(initiatorHandle);
4497
+ const targetPower = await calculateTotalPower(targetHandle);
4517
4498
  const initiatorRankname = initiatorData[0]?.name || session.username;
4518
4499
  const targetRankname = targetData[0]?.name || (targetUsername.name || targetUsername.user.name);
4500
+ const [initiatorCareer] = await ctx.database.get("ggcevo_careers", {
4501
+ handle: initiatorHandle
4502
+ });
4503
+ const [targetCareer] = await ctx.database.get("ggcevo_careers", {
4504
+ handle: targetHandle
4505
+ });
4506
+ const validGroups = /* @__PURE__ */ new Set(["人类联盟", "辛迪加海盗"]);
4507
+ if (!initiatorCareer?.group || !validGroups.has(initiatorCareer.group)) {
4508
+ return "❌ 您尚未加入人类联盟或辛迪加海盗,不能参与PK";
4509
+ }
4510
+ if (!targetCareer?.group || !validGroups.has(targetCareer.group)) {
4511
+ return "❌ 对方尚未加入人类联盟或辛迪加海盗,不能参与PK";
4512
+ }
4513
+ if (targetCareer.group === "人类联盟") {
4514
+ let joinDate;
4515
+ if (typeof targetCareer.date === "string") {
4516
+ joinDate = convertUTCtoChinaTime(new Date(targetCareer.date));
4517
+ } else if (typeof targetCareer.date === "number") {
4518
+ joinDate = convertUTCtoChinaTime(new Date(targetCareer.date));
4519
+ } else {
4520
+ joinDate = convertUTCtoChinaTime(targetCareer.date);
4521
+ }
4522
+ if (isNaN(joinDate.getTime())) {
4523
+ return "❌ 对方阵营加入阵营日期无效";
4524
+ }
4525
+ const now2 = convertUTCtoChinaTime(/* @__PURE__ */ new Date());
4526
+ const timeDiff = now2.getTime() - joinDate.getTime();
4527
+ const diffInDays = Math.floor(timeDiff / (1e3 * 60 * 60 * 24));
4528
+ if (diffInDays < 30) {
4529
+ return `🛡️ 该玩家是人类联盟成员,尚在30天保护期内(剩余${30 - diffInDays}天),无法挑战`;
4530
+ }
4531
+ }
4519
4532
  let initiatorPK = {
4520
4533
  handle: initiatorHandle,
4521
4534
  name: initiatorRankname,
@@ -4524,7 +4537,7 @@ ${items.join("、")}
4524
4537
  todayCount: 0,
4525
4538
  lastPK: /* @__PURE__ */ new Date(0),
4526
4539
  // 明确初始化 lastPK
4527
- enable: true,
4540
+ enable: false,
4528
4541
  // 新增默认值
4529
4542
  lastToggle: /* @__PURE__ */ new Date(0)
4530
4543
  // 新增默认值
@@ -4536,7 +4549,7 @@ ${items.join("、")}
4536
4549
  wins: 0,
4537
4550
  todayCount: 0,
4538
4551
  lastPK: /* @__PURE__ */ new Date(0),
4539
- enable: true,
4552
+ enable: false,
4540
4553
  // 新增默认值
4541
4554
  lastToggle: /* @__PURE__ */ new Date(0)
4542
4555
  // 新增默认值
@@ -4547,17 +4560,28 @@ ${items.join("、")}
4547
4560
  const [dbTarget] = await ctx.database.get("ggcevo_pk", { handle: targetHandle });
4548
4561
  if (dbTarget) Object.assign(targetPK, dbTarget);
4549
4562
  });
4550
- const [initiatorCareer] = await ctx.database.get("ggcevo_careers", {
4551
- handle: initiatorHandle
4552
- });
4553
- const [targetCareer] = await ctx.database.get("ggcevo_careers", {
4554
- handle: targetHandle
4555
- });
4556
- if (!initiatorPK.enable) {
4557
- return "您已关闭PK功能,无法发起挑战。";
4558
- }
4559
- if (!targetPK.enable) {
4560
- return "对方已关闭PK功能,无法接受挑战。";
4563
+ if (initiatorCareer.group === "人类联盟" && !initiatorPK.enable) {
4564
+ let joinDate;
4565
+ if (typeof initiatorCareer.date === "string") joinDate = convertUTCtoChinaTime(new Date(initiatorCareer.date));
4566
+ else if (typeof initiatorCareer.date === "number") joinDate = convertUTCtoChinaTime(new Date(initiatorCareer.date));
4567
+ else joinDate = convertUTCtoChinaTime(initiatorCareer.date);
4568
+ if (!isNaN(joinDate.getTime())) {
4569
+ const now2 = convertUTCtoChinaTime(/* @__PURE__ */ new Date());
4570
+ const timeDiff = now2.getTime() - joinDate.getTime();
4571
+ const remainingDays = 30 - Math.floor(timeDiff / (1e3 * 60 * 60 * 24));
4572
+ if (remainingDays > 0) {
4573
+ await session.send(`⚠️ 您的人类联盟保护期剩余 ${remainingDays} 天,发起PK将永久失去保护期!请确认是否继续?
4574
+ 回复"是"继续PK,或"取消"退出`);
4575
+ const confirm = await session.prompt(3e4);
4576
+ if (confirm !== "是") return "已取消PK操作,保护期仍有效";
4577
+ }
4578
+ }
4579
+ initiatorPK.enable = true;
4580
+ initiatorPK.lastToggle = /* @__PURE__ */ new Date();
4581
+ await ctx.database.set("ggcevo_pk", initiatorHandle, {
4582
+ enable: true,
4583
+ lastToggle: /* @__PURE__ */ new Date()
4584
+ });
4561
4585
  }
4562
4586
  const now = convertUTCtoChinaTime(/* @__PURE__ */ new Date());
4563
4587
  if (!isSameDate(convertUTCtoChinaTime(initiatorPK.lastPK), now)) {
@@ -4607,12 +4631,15 @@ ${items.join("、")}
4607
4631
  hasMP3 = mp3Item && mp3Item.quantity > 0;
4608
4632
  }
4609
4633
  const powerDiff = initiatorPower - targetPower;
4610
- let winRate = 50 + powerDiff / 50 * 0.1;
4634
+ let winRate = 50 + powerDiff / 100 * 0.1;
4611
4635
  winRate = Math.min(Math.max(winRate, 5), 95);
4612
4636
  const randInt = Math.floor(Math.random() * 1e4);
4613
4637
  const winRateInt = Math.floor(winRate * 100);
4614
4638
  const isWin = randInt < winRateInt;
4615
4639
  let stealPercentage = getRandomInt(1, 5);
4640
+ if (targetCareer.group === "人类联盟" && isWin) {
4641
+ stealPercentage = 1;
4642
+ }
4616
4643
  let goldTransfer = Math.floor(
4617
4644
  (isWin ? targetGold : initiatorGold) * stealPercentage / 100
4618
4645
  );
@@ -4699,7 +4726,7 @@ ${items.join("、")}
4699
4726
  }
4700
4727
  });
4701
4728
  const result = [
4702
- `⚔️【对战结果】${isWin ? "胜利" : "失败"}${mp3Effect ? " (MP3减免)" : ""}`,
4729
+ `⚔️【对战结果】${isWin ? "胜利" : "失败"}`,
4703
4730
  `🏅 挑战者:${initiatorRankname}(战斗力 ${initiatorPower})`,
4704
4731
  ` 👨‍💼 职业:${initiatorCareer?.career || "无"}`,
4705
4732
  // 显示职业
@@ -4709,6 +4736,9 @@ ${items.join("、")}
4709
4736
  `📊 胜率预测:${winRate.toFixed(1)}%`,
4710
4737
  `🎰 金币变动:${stealPercentage}%`
4711
4738
  ];
4739
+ if (targetCareer.group === "人类联盟" && isWin) {
4740
+ result.push(`🛡️ 人类联盟保护:应战者失败仅损失1%金币`);
4741
+ }
4712
4742
  if (computerExpertProtection) {
4713
4743
  result.push(`💻 计算机专家职业加成:被动PK失败不损失金币`);
4714
4744
  } else if (isWin) {
@@ -4765,54 +4795,6 @@ ${items.join("、")}
4765
4795
  pageNum < totalPages ? `输入 pk榜 ${pageNum + 1} 查看下一页` : "已是最后一页"
4766
4796
  ].join("\n");
4767
4797
  });
4768
- ctx.command("ggcevo/切换pk", "切换玩家对战状态").alias("切换pk状态").action(async ({ session }) => {
4769
- const [profile] = await ctx.database.get("sc2arcade_player", { userId: session.userId });
4770
- if (!profile) return "🔒 需要先绑定游戏句柄";
4771
- const handle = `${profile.regionId}-S2-${profile.realmId}-${profile.profileId}`;
4772
- const [pkRecord] = await ctx.database.get("ggcevo_pk", { handle }) || [null];
4773
- const currentState = pkRecord?.enable ?? true;
4774
- const lastToggle = pkRecord?.lastToggle ?? /* @__PURE__ */ new Date(0);
4775
- if (!pkRecord) {
4776
- await ctx.database.create("ggcevo_pk", {
4777
- handle,
4778
- total: 0,
4779
- wins: 0,
4780
- todayCount: 0,
4781
- lastPK: /* @__PURE__ */ new Date(0),
4782
- enable: true,
4783
- // 默认初始状态为开启
4784
- lastToggle: /* @__PURE__ */ new Date(0)
4785
- });
4786
- }
4787
- const now = convertUTCtoChinaTime(/* @__PURE__ */ new Date());
4788
- const lastToggleTime = convertUTCtoChinaTime(lastToggle);
4789
- const diffDays = Math.floor((now.getTime() - lastToggleTime.getTime()) / (1e3 * 3600 * 24));
4790
- const [careers] = await ctx.database.get("ggcevo_careers", { handle });
4791
- if (careers?.group === "辛迪加海盗") return "您已经加入了辛迪加海盗阵营,无法切换PK状态!";
4792
- if (diffDays < 3 && lastToggleTime.getTime() !== 0) {
4793
- const remaining = 3 - diffDays;
4794
- return `状态切换冷却中,${remaining}天后再试(下次可切换时间:${new Date(lastToggle.getTime() + 3 * 864e5).toLocaleDateString("zh-CN")})。`;
4795
- }
4796
- const action = currentState ? "关闭" : "开启";
4797
- await session.send(`您当前的PK状态为【${currentState ? "开启" : "关闭"}】,确认要${action}吗?(请在30秒内回复“是”确认)`);
4798
- const confirm = await session.prompt(3e4);
4799
- if (confirm !== "是") return "已取消操作。";
4800
- await ctx.database.upsert("ggcevo_pk", [{
4801
- handle,
4802
- enable: !currentState,
4803
- lastToggle: /* @__PURE__ */ new Date(),
4804
- // 保持其他字段不变
4805
- total: pkRecord?.total || 0,
4806
- wins: pkRecord?.wins || 0,
4807
- todayCount: pkRecord?.todayCount || 0,
4808
- lastPK: pkRecord?.lastPK || /* @__PURE__ */ new Date(0)
4809
- }], ["handle"]);
4810
- return `PK状态已${!currentState ? "开启" : "关闭"},下次可切换时间:${new Date(Date.now() + 3 * 864e5).toLocaleDateString("zh-CN", {
4811
- year: "numeric",
4812
- month: "2-digit",
4813
- day: "2-digit"
4814
- })}`;
4815
- });
4816
4798
  ctx.command("ggcevo/武器库 [type]").usage("输入“武器库”查看类型,或“武器库 类型”查看详细武器信息").action(async ({ session }, type) => {
4817
4799
  const [profile] = await ctx.database.get("sc2arcade_player", { userId: session.userId });
4818
4800
  if (!profile) return "⚠️ 需要先绑定游戏句柄";
@@ -5153,11 +5135,19 @@ ${validTypes.join("、")}`;
5153
5135
  const processModInstallation = /* @__PURE__ */ __name(async () => {
5154
5136
  const modInfo = modConfig[mod];
5155
5137
  if (!modInfo) return "无效模块名称。";
5138
+ if (!weapon || !weaponConfig[weapon]?.id) {
5139
+ const validWeapons = Object.keys(weaponConfig).filter((k) => weaponConfig[k].id);
5140
+ return `❌ 无效武器名称。可选武器:${validWeapons.join("、")}`;
5141
+ }
5142
+ const weaponId = weaponConfig[weapon].id;
5156
5143
  const [equipment] = await ctx.database.get("ggcevo_equipment", {
5157
5144
  handle,
5158
- weaponId: weaponConfig[weapon].id
5145
+ weaponId
5146
+ // 使用已验证的weaponId
5159
5147
  });
5160
- if (!equipment) return "您尚未获得该武器。";
5148
+ if (!equipment) {
5149
+ return `❌ 尚未获得【${weapon}】或武器名称错误`;
5150
+ }
5161
5151
  if (modInfo.isExclusive) {
5162
5152
  if (modInfo.exclusiveTo !== weapon) return `❌ 该模块只能安装在${modInfo.exclusiveTo}上。`;
5163
5153
  const hasExclusive = equipment.installedMods.some((m) => modConfig[m]?.isExclusive);
@@ -5971,9 +5961,9 @@ ${scatterEffectMessages.map((m) => `▸ ${m}`).join("\n")}`
5971
5961
  try {
5972
5962
  if (faction === "人类联盟") {
5973
5963
  if (userCoins < 1e3) {
5974
- return `加入人类联盟需要1000金币,你当前拥有${userCoins}金币`;
5964
+ return `加入人类联盟需要1000金币,您当前拥有${userCoins}金币`;
5975
5965
  }
5976
- await session.send(`请问你确定要缴纳1000金币加入人类联盟吗?(请在30秒内输入“是”确定加入)`);
5966
+ await session.send(`请问您确定要缴纳1000金币加入人类联盟吗?(请在30秒内输入“是”确定加入)`);
5977
5967
  const cost = await session.prompt(3e4);
5978
5968
  if (cost !== "是") return "已取消加入。";
5979
5969
  await ctx.database.upsert("ggcevo_sign", [{
@@ -5990,12 +5980,9 @@ ${scatterEffectMessages.map((m) => `▸ ${m}`).join("\n")}`
5990
5980
  } else if (faction === "辛迪加海盗") {
5991
5981
  const [pkData] = await ctx.database.get("ggcevo_pk", { handle });
5992
5982
  if (userCoins < 2e3) {
5993
- return `加入辛迪加海盗需要缴纳2000金币并且永久开启PK功能,你当前拥有${userCoins}金币`;
5994
- }
5995
- if (pkData && !pkData?.enable) {
5996
- return "当前PK功能未开启,无法加入辛迪加海盗。";
5983
+ return `加入辛迪加海盗需要缴纳2000金币,您当前拥有${userCoins}金币`;
5997
5984
  }
5998
- await session.send(`请问你确定要缴纳2000金币并且永久开启PK功能加入辛迪加海盗吗?(请在30秒内输入“是”确定加入)`);
5985
+ await session.send(`请问您确定要缴纳2000金币加入辛迪加海盗吗?(请在30秒内输入“是”确定加入)`);
5999
5986
  const cost = await session.prompt(3e4);
6000
5987
  if (cost !== "是") return "已取消加入。";
6001
5988
  await ctx.database.upsert("ggcevo_sign", [{
@@ -6089,8 +6076,7 @@ ${scatterEffectMessages.map((m) => `▸ ${m}`).join("\n")}`
6089
6076
  }
6090
6077
  await ctx.database.upsert("ggcevo_careers", [{
6091
6078
  handle,
6092
- career: profession,
6093
- date: /* @__PURE__ */ new Date()
6079
+ career: profession
6094
6080
  }], ["handle"]);
6095
6081
  return `${careerData.group === "辛迪加海盗" ? `花费${targetProfession.costredcrystal}红晶` : `花费${targetProfession.costcoins}金币`}转职成功!当前职业:${profession}`;
6096
6082
  } catch (err) {
@@ -6110,14 +6096,17 @@ ${scatterEffectMessages.map((m) => `▸ ${m}`).join("\n")}`
6110
6096
  const config2 = careerData.group === "辛迪加海盗" ? syndicatePirateConfig : spaceStationCrewConfig;
6111
6097
  const profession = config2.find((p) => p.professionName === careerData.career);
6112
6098
  const effectDisplay = profession?.effect || "暂无特殊效果";
6113
- const joinDate = new Date(careerData.date);
6099
+ const joinDate = convertUTCtoChinaTime(new Date(careerData.date));
6114
6100
  const formattedDate = `${joinDate.getFullYear()}年${joinDate.getMonth() + 1}月${joinDate.getDate()}日`;
6101
+ const powerValue = await calculateTotalPower(handle);
6115
6102
  const infoCard = [
6116
6103
  `🎮 游戏句柄:${handle}`,
6104
+ `⚔️ 当前战力:${powerValue}`,
6105
+ // 新增战力显示行
6117
6106
  `🎯 当前阵营:${careerData.group}`,
6118
6107
  `👔 当前职业:${careerData.career}`,
6119
6108
  `✨ 职业效果:${effectDisplay}`,
6120
- `🗓️ 就职时间:${formattedDate}`
6109
+ `🗓️ 加入时间:${formattedDate}`
6121
6110
  ];
6122
6111
  if (careerData.group === "人类联盟") {
6123
6112
  const techEntries = await ctx.database.get("ggcevo_tech", { handle });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ggcevo-game",
3
3
  "description": "《星际争霸2》咕咕虫-evolved地图的专属游戏助手插件,集成天梯排行、抽奖系统、签到福利、兑换商城等丰富功能。",
4
- "version": "1.3.53",
4
+ "version": "1.3.54",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [