koishi-plugin-ggcevo-game 1.6.59 → 1.6.60
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.js +142 -52
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -5515,6 +5515,13 @@ var ggcevoUpdates = [
|
|
|
5515
5515
|
- 修改铝热炸弹的机制,现在无法直接击杀异形
|
|
5516
5516
|
- 削弱了燃烧机制,现在每一层额外造成1点伤害(上限依旧是100点)
|
|
5517
5517
|
`.trim()
|
|
5518
|
+
},
|
|
5519
|
+
{
|
|
5520
|
+
version: "1.6.60",
|
|
5521
|
+
time: "2025-08-4",
|
|
5522
|
+
content: `
|
|
5523
|
+
- 新增兑换资源,1张兑换券可以兑换20张资源兑换券
|
|
5524
|
+
`.trim()
|
|
5518
5525
|
}
|
|
5519
5526
|
];
|
|
5520
5527
|
function compareVersions(a, b) {
|
|
@@ -12718,7 +12725,7 @@ ${validBossNames.join("、")}`;
|
|
|
12718
12725
|
return "⚠️ 竞猜提交失败,请重试";
|
|
12719
12726
|
}
|
|
12720
12727
|
});
|
|
12721
|
-
ctx.command("ggcevo/兑换资源 [name] [amount]").usage('输入"兑换资源"
|
|
12728
|
+
ctx.command("ggcevo/兑换资源 [name] [amount]").alias("兑换").usage('输入"兑换资源"查看可兑换物品列表\n输入"兑换资源 物品名称 [数量]"进行兑换').action(async ({ session }, name2, amount) => {
|
|
12722
12729
|
const Curfew = fixedCurfewCheck(session, config);
|
|
12723
12730
|
if (!Curfew) return "⛔ 宵禁时段 (18:00-24:00) 禁止在群聊中使用咕咕之战指令。\n请添加C.O.R.E为好友使用私聊指令,好友验证信息为【咕咕之战】。";
|
|
12724
12731
|
const [profile] = await ctx.database.get("sc2arcade_player", { userId: session.userId });
|
|
@@ -12727,71 +12734,154 @@ ${validBossNames.join("、")}`;
|
|
|
12727
12734
|
if ((await ctx.database.get("ggcevo_blacklist", { handle })).length) {
|
|
12728
12735
|
return "⛔ 您已被列入黑名单。";
|
|
12729
12736
|
}
|
|
12730
|
-
const
|
|
12731
|
-
|
|
12732
|
-
"
|
|
12737
|
+
const exchangeItems = {
|
|
12738
|
+
// === 特殊资源兑换 ===
|
|
12739
|
+
"金币": {
|
|
12740
|
+
type: "resource",
|
|
12741
|
+
costItemId: 8,
|
|
12742
|
+
costAmount: 1,
|
|
12743
|
+
valuePerCoupon: 100,
|
|
12744
|
+
currencyField: "totalRewards",
|
|
12745
|
+
table: "ggcevo_sign",
|
|
12746
|
+
display: "1张资源兑换券 → 100金币"
|
|
12747
|
+
},
|
|
12748
|
+
"红晶": {
|
|
12749
|
+
type: "resource",
|
|
12750
|
+
costItemId: 8,
|
|
12751
|
+
costAmount: 1,
|
|
12752
|
+
valuePerCoupon: 1,
|
|
12753
|
+
currencyField: "redcrystal",
|
|
12754
|
+
table: "ggcevo_careers",
|
|
12755
|
+
display: "1张资源兑换券 → 1红晶",
|
|
12756
|
+
preCheck: /* @__PURE__ */ __name(async () => {
|
|
12757
|
+
const [career] = await ctx.database.get("ggcevo_careers", { handle });
|
|
12758
|
+
if (!career || career.group !== "辛迪加海盗") {
|
|
12759
|
+
return `⚠️ 兑换失败:仅限【辛迪加海盗】组织成员兑换,您当前属于【${career?.group || "无"}】`;
|
|
12760
|
+
}
|
|
12761
|
+
return null;
|
|
12762
|
+
}, "preCheck")
|
|
12763
|
+
},
|
|
12764
|
+
// === 物品兑换 ===
|
|
12765
|
+
"资源兑换券": {
|
|
12766
|
+
type: "item",
|
|
12767
|
+
costItemId: 2,
|
|
12768
|
+
// 消耗:ItemID=2 (兑换券)
|
|
12769
|
+
costAmount: 1,
|
|
12770
|
+
// 每张兑换券消耗数量
|
|
12771
|
+
gainItemId: 8,
|
|
12772
|
+
// 获得:ItemID=8 (资源兑换券)
|
|
12773
|
+
gainAmount: 20,
|
|
12774
|
+
// 获得数量
|
|
12775
|
+
display: "1张兑换券 → 20张资源兑换券"
|
|
12776
|
+
}
|
|
12777
|
+
// 可在此继续添加其他物品兑换...
|
|
12733
12778
|
};
|
|
12734
12779
|
if (!name2) {
|
|
12735
|
-
const [
|
|
12736
|
-
|
|
12737
|
-
itemId: 8
|
|
12738
|
-
});
|
|
12780
|
+
const [resourceCoupon] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 8 });
|
|
12781
|
+
const [exchangeCoupon] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 2 });
|
|
12739
12782
|
return [
|
|
12740
|
-
"
|
|
12783
|
+
"🛒 资源兑换商店 🛒",
|
|
12741
12784
|
'使用 "兑换资源 物品名称 数量" 进行兑换',
|
|
12742
|
-
`您当前持有: ${coupon?.quantity || 0}张资源兑换券`,
|
|
12743
12785
|
"====================",
|
|
12744
|
-
|
|
12786
|
+
`🪙 资源兑换券: ${resourceCoupon?.quantity || 0}张`,
|
|
12787
|
+
`🎟️ 兑换券: ${exchangeCoupon?.quantity || 0}张`,
|
|
12745
12788
|
"====================",
|
|
12746
|
-
|
|
12789
|
+
...Object.entries(exchangeItems).map(([itemName, config2]) => {
|
|
12790
|
+
return `▸ ${itemName}: ${config2.display}`;
|
|
12791
|
+
}),
|
|
12792
|
+
"====================",
|
|
12793
|
+
"输入示例:",
|
|
12794
|
+
'"兑换资源 金币 5" → 兑换500金币(消耗5张资源券)',
|
|
12795
|
+
'"兑换资源 资源兑换券 2" → 兑换40张资源券(消耗2张兑换券)'
|
|
12747
12796
|
].join("\n");
|
|
12748
12797
|
}
|
|
12749
|
-
const
|
|
12750
|
-
if (!
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
return `⚠️ 兑换红晶失败:仅限【辛迪加海盗】组织成员兑换,您当前属于【${career?.group || "无"}】`;
|
|
12755
|
-
}
|
|
12756
|
-
}
|
|
12757
|
-
const exchangeAmount = parseInt(amount) || 1;
|
|
12758
|
-
if (exchangeAmount <= 0 || exchangeAmount > 100) return "⚠️ 兑换数量需在1-100之间";
|
|
12759
|
-
const [couponItem] = await ctx.database.get("ggcevo_backpack", {
|
|
12760
|
-
handle,
|
|
12761
|
-
itemId: 8
|
|
12762
|
-
});
|
|
12763
|
-
const couponCount = couponItem?.quantity || 0;
|
|
12764
|
-
if (couponCount < exchangeAmount) {
|
|
12765
|
-
return `⚠️ 兑换券不足,需要${exchangeAmount}张,当前持有:${couponCount}张`;
|
|
12766
|
-
}
|
|
12767
|
-
const gainAmount = itemconfig.valuePerCoupon * exchangeAmount;
|
|
12798
|
+
const itemConfig2 = exchangeItems[name2];
|
|
12799
|
+
if (!itemConfig2) return `⚠️ 无效物品名称,可用选项:${Object.keys(exchangeItems).join("、")}`;
|
|
12800
|
+
let exchangeCount = parseInt(amount) || 1;
|
|
12801
|
+
if (exchangeCount <= 0) return "⚠️ 兑换数量必须大于0";
|
|
12802
|
+
if (exchangeCount > 100) return "⚠️ 单次最多兑换100次";
|
|
12768
12803
|
try {
|
|
12769
|
-
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12804
|
+
if (itemConfig2.type === "resource") {
|
|
12805
|
+
if (itemConfig2.preCheck) {
|
|
12806
|
+
const checkResult = await itemConfig2.preCheck();
|
|
12807
|
+
if (checkResult) return checkResult;
|
|
12808
|
+
}
|
|
12809
|
+
const [costItem] = await ctx.database.get("ggcevo_backpack", {
|
|
12810
|
+
handle,
|
|
12811
|
+
itemId: itemConfig2.costItemId
|
|
12812
|
+
});
|
|
12813
|
+
const requiredCoupons = exchangeCount * itemConfig2.costAmount;
|
|
12814
|
+
const heldCoupons = costItem?.quantity || 0;
|
|
12815
|
+
if (heldCoupons < requiredCoupons) {
|
|
12816
|
+
return `⚠️ ${name2}不足,需要${requiredCoupons}张资源兑换券,当前持有:${heldCoupons}张`;
|
|
12817
|
+
}
|
|
12818
|
+
const gainAmount = itemConfig2.valuePerCoupon * exchangeCount;
|
|
12819
|
+
await ctx.database.withTransaction(async () => {
|
|
12777
12820
|
await ctx.database.set(
|
|
12778
|
-
|
|
12779
|
-
{ handle },
|
|
12780
|
-
{
|
|
12821
|
+
"ggcevo_backpack",
|
|
12822
|
+
{ handle, itemId: itemConfig2.costItemId },
|
|
12823
|
+
{ quantity: heldCoupons - requiredCoupons }
|
|
12781
12824
|
);
|
|
12782
|
-
|
|
12783
|
-
|
|
12825
|
+
const [record] = await ctx.database.get(itemConfig2.table, { handle });
|
|
12826
|
+
if (record) {
|
|
12827
|
+
await ctx.database.set(
|
|
12828
|
+
itemConfig2.table,
|
|
12829
|
+
{ handle },
|
|
12830
|
+
{ [itemConfig2.currencyField]: record[itemConfig2.currencyField] + gainAmount }
|
|
12831
|
+
);
|
|
12832
|
+
} else {
|
|
12833
|
+
await ctx.database.create(itemConfig2.table, {
|
|
12834
|
+
handle,
|
|
12835
|
+
userId: session.userId,
|
|
12836
|
+
[itemConfig2.currencyField]: gainAmount,
|
|
12837
|
+
...itemConfig2.table === "ggcevo_sign" ? { lastSign: /* @__PURE__ */ new Date() } : {}
|
|
12838
|
+
});
|
|
12839
|
+
}
|
|
12840
|
+
});
|
|
12841
|
+
return `🎉 兑换成功!使用${requiredCoupons}张资源券兑换了${gainAmount}${name2}`;
|
|
12842
|
+
} else if (itemConfig2.type === "item") {
|
|
12843
|
+
const [costItem] = await ctx.database.get("ggcevo_backpack", {
|
|
12844
|
+
handle,
|
|
12845
|
+
itemId: itemConfig2.costItemId
|
|
12846
|
+
});
|
|
12847
|
+
const requiredQuantity = exchangeCount * itemConfig2.costAmount;
|
|
12848
|
+
const heldQuantity = costItem?.quantity || 0;
|
|
12849
|
+
if (heldQuantity < requiredQuantity) {
|
|
12850
|
+
const requiredName = itemConfig2.costItemId === 2 ? "兑换券" : "物品";
|
|
12851
|
+
return `⚠️ ${name2}不足,需要${requiredQuantity}张${requiredName},当前持有:${heldQuantity}张`;
|
|
12852
|
+
}
|
|
12853
|
+
const gainQuantity = exchangeCount * itemConfig2.gainAmount;
|
|
12854
|
+
await ctx.database.withTransaction(async () => {
|
|
12855
|
+
await ctx.database.set(
|
|
12856
|
+
"ggcevo_backpack",
|
|
12857
|
+
{ handle, itemId: itemConfig2.costItemId },
|
|
12858
|
+
{ quantity: heldQuantity - requiredQuantity }
|
|
12859
|
+
);
|
|
12860
|
+
const [targetItem] = await ctx.database.get("ggcevo_backpack", {
|
|
12784
12861
|
handle,
|
|
12785
|
-
|
|
12786
|
-
[itemconfig.currencyField]: gainAmount,
|
|
12787
|
-
...itemconfig.table === "ggcevo_sign" ? { lastSign: /* @__PURE__ */ new Date() } : {}
|
|
12862
|
+
itemId: itemConfig2.gainItemId
|
|
12788
12863
|
});
|
|
12789
|
-
|
|
12790
|
-
|
|
12791
|
-
|
|
12864
|
+
if (targetItem) {
|
|
12865
|
+
await ctx.database.set(
|
|
12866
|
+
"ggcevo_backpack",
|
|
12867
|
+
{ handle, itemId: itemConfig2.gainItemId },
|
|
12868
|
+
{ quantity: targetItem.quantity + gainQuantity }
|
|
12869
|
+
);
|
|
12870
|
+
} else {
|
|
12871
|
+
await ctx.database.create("ggcevo_backpack", {
|
|
12872
|
+
handle,
|
|
12873
|
+
itemId: itemConfig2.gainItemId,
|
|
12874
|
+
quantity: gainQuantity
|
|
12875
|
+
});
|
|
12876
|
+
}
|
|
12877
|
+
});
|
|
12878
|
+
const costName = itemConfig2.costItemId === 2 ? "兑换券" : "物品";
|
|
12879
|
+
return `🔄 兑换成功!使用${requiredQuantity}张${costName}兑换了${gainQuantity}张${name2}`;
|
|
12880
|
+
}
|
|
12881
|
+
return "⚠️ 未知的兑换类型";
|
|
12792
12882
|
} catch (error) {
|
|
12793
|
-
console.error("
|
|
12794
|
-
return "⚠️
|
|
12883
|
+
console.error("兑换失败:", error);
|
|
12884
|
+
return "⚠️ 兑换过程中出错,请稍后再试";
|
|
12795
12885
|
}
|
|
12796
12886
|
});
|
|
12797
12887
|
ctx.command("ggcevo/签到奖励").action(({}) => {
|