koishi-plugin-ggcevo-game 1.0.19 → 1.0.20
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 +47 -11
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1501,10 +1501,26 @@ ${achievementList.join("\n")}`;
|
|
|
1501
1501
|
const initiatorHandle = `${profile.regionId}-S2-${profile.realmId}-${profile.profileId}`;
|
|
1502
1502
|
const targetHandle = `${targetprofile.regionId}-S2-${targetprofile.realmId}-${targetprofile.profileId}`;
|
|
1503
1503
|
if (initiatorHandle === targetHandle) return "不能挑战自己哦~";
|
|
1504
|
-
let initiatorPK
|
|
1504
|
+
let initiatorPK = {
|
|
1505
|
+
handle: initiatorHandle,
|
|
1506
|
+
total: 0,
|
|
1507
|
+
wins: 0,
|
|
1508
|
+
todayCount: 0,
|
|
1509
|
+
lastPK: /* @__PURE__ */ new Date(0)
|
|
1510
|
+
// 明确初始化 lastPK
|
|
1511
|
+
};
|
|
1512
|
+
let targetPK = {
|
|
1513
|
+
handle: targetHandle,
|
|
1514
|
+
total: 0,
|
|
1515
|
+
wins: 0,
|
|
1516
|
+
todayCount: 0,
|
|
1517
|
+
lastPK: /* @__PURE__ */ new Date(0)
|
|
1518
|
+
};
|
|
1505
1519
|
await ctx.database.withTransaction(async () => {
|
|
1506
|
-
[
|
|
1507
|
-
|
|
1520
|
+
const [dbInitiator] = await ctx.database.get("ggcevo_pk", { handle: initiatorHandle });
|
|
1521
|
+
if (dbInitiator) Object.assign(initiatorPK, dbInitiator);
|
|
1522
|
+
const [dbTarget] = await ctx.database.get("ggcevo_pk", { handle: targetHandle });
|
|
1523
|
+
if (dbTarget) Object.assign(targetPK, dbTarget);
|
|
1508
1524
|
});
|
|
1509
1525
|
const now = convertUTCtoChinaTime(/* @__PURE__ */ new Date());
|
|
1510
1526
|
if (!isSameDate(convertUTCtoChinaTime(initiatorPK.lastPK), now)) {
|
|
@@ -1517,6 +1533,12 @@ ${achievementList.join("\n")}`;
|
|
|
1517
1533
|
ctx.database.get("ggcevo_rank", initiatorHandle),
|
|
1518
1534
|
ctx.database.get("ggcevo_rank", targetHandle)
|
|
1519
1535
|
]);
|
|
1536
|
+
if (!initiatorData[0]?.rank) {
|
|
1537
|
+
return "发起者尚未有积分数据,无法发起挑战";
|
|
1538
|
+
}
|
|
1539
|
+
if (!targetData[0]?.rank) {
|
|
1540
|
+
return "对方尚未有积分数据,无法接受挑战";
|
|
1541
|
+
}
|
|
1520
1542
|
const [initiatorSign, targetSign] = await Promise.all([
|
|
1521
1543
|
ctx.database.get("ggcevo_sign", initiatorHandle),
|
|
1522
1544
|
ctx.database.get("ggcevo_sign", targetHandle)
|
|
@@ -1537,13 +1559,27 @@ ${achievementList.join("\n")}`;
|
|
|
1537
1559
|
return `${isWin ? "对方" : "你"}的金币不足以完成交易`;
|
|
1538
1560
|
}
|
|
1539
1561
|
await ctx.database.withTransaction(async () => {
|
|
1540
|
-
await ctx.database.upsert("ggcevo_pk", [
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1562
|
+
await ctx.database.upsert("ggcevo_pk", [
|
|
1563
|
+
// 发起者记录
|
|
1564
|
+
{
|
|
1565
|
+
handle: initiatorHandle,
|
|
1566
|
+
total: initiatorPK.total + 1,
|
|
1567
|
+
wins: isWin ? initiatorPK.wins + 1 : initiatorPK.wins,
|
|
1568
|
+
todayCount: initiatorPK.todayCount + 1,
|
|
1569
|
+
lastPK: /* @__PURE__ */ new Date()
|
|
1570
|
+
},
|
|
1571
|
+
// 应战者记录(新增部分)
|
|
1572
|
+
{
|
|
1573
|
+
handle: targetHandle,
|
|
1574
|
+
total: targetPK.total + 1,
|
|
1575
|
+
wins: !isWin ? targetPK.wins + 1 : targetPK.wins,
|
|
1576
|
+
// 应战者胜利时增加
|
|
1577
|
+
todayCount: targetPK.todayCount,
|
|
1578
|
+
// 不消耗应战者次数
|
|
1579
|
+
lastPK: /* @__PURE__ */ new Date()
|
|
1580
|
+
// 更新最后参与时间
|
|
1581
|
+
}
|
|
1582
|
+
]);
|
|
1547
1583
|
if (isWin) {
|
|
1548
1584
|
await ctx.database.set("ggcevo_sign", targetHandle, { totalRewards: targetGold - goldTransfer });
|
|
1549
1585
|
await ctx.database.set("ggcevo_sign", initiatorHandle, { totalRewards: initiatorGold + goldTransfer });
|
|
@@ -1559,7 +1595,7 @@ ${achievementList.join("\n")}`;
|
|
|
1559
1595
|
`📊 胜率预测:${winRate.toFixed(1)}%`,
|
|
1560
1596
|
`🎰 金币变动:${stealPercentage}%`
|
|
1561
1597
|
];
|
|
1562
|
-
isWin ? result.push(
|
|
1598
|
+
isWin ? result.push(`💰您获得 ${goldTransfer}`, `💸 对方损失 ${goldTransfer}`) : result.push(`💸您损失 ${goldTransfer}`, `💰 对方获得 ${goldTransfer}`);
|
|
1563
1599
|
result.push(`📅 剩余挑战次数:${config.dailyPKLimit - (initiatorPK.todayCount + 1)}`);
|
|
1564
1600
|
return result.join("\n");
|
|
1565
1601
|
} catch (error) {
|