koishi-plugin-ggcevo-game 1.2.29 → 1.2.31
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 +1 -0
- package/lib/index.js +147 -19
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -125,6 +125,7 @@ function apply(ctx, config) {
|
|
|
125
125
|
// 胜场
|
|
126
126
|
matches: "unsigned",
|
|
127
127
|
// 比赛次数
|
|
128
|
+
rankseason: "string",
|
|
128
129
|
Blacklist: {
|
|
129
130
|
type: "boolean",
|
|
130
131
|
initial: false
|
|
@@ -601,7 +602,12 @@ function apply(ctx, config) {
|
|
|
601
602
|
"🥈先行者赛季亚军勋章": { id: 102, type: "勋章", description: "" },
|
|
602
603
|
"🥉先行者赛季季军勋章": { id: 103, type: "勋章", description: "" },
|
|
603
604
|
"🏅先行者赛季前十勋章": { id: 104, type: "勋章", description: "" },
|
|
604
|
-
"🎖先行者赛季前二十勋章": { id: 105, type: "勋章", description: "" }
|
|
605
|
+
"🎖先行者赛季前二十勋章": { id: 105, type: "勋章", description: "" },
|
|
606
|
+
"🥇S1赛季冠军勋章": { id: 106, type: "勋章", description: "" },
|
|
607
|
+
"🥈S1赛季亚军勋章": { id: 107, type: "勋章", description: "" },
|
|
608
|
+
"🥉S1赛季季军勋章": { id: 108, type: "勋章", description: "" },
|
|
609
|
+
"🏅S1赛季前十勋章": { id: 109, type: "勋章", description: "" },
|
|
610
|
+
"🎖S1赛季前二十勋章": { id: 110, type: "勋章", description: "" }
|
|
605
611
|
};
|
|
606
612
|
const itemConfig = {
|
|
607
613
|
"拾荒者": { quality: "t3", type: "皮肤", cost: 3, isLimited: false },
|
|
@@ -1307,7 +1313,8 @@ ${itemDetails.join("\n")}`;
|
|
|
1307
1313
|
name: record.profile.name,
|
|
1308
1314
|
rank: record.decision === "win" ? (ggcrank?.rank || 0) + 150 : (ggcrank?.rank || 0) - 50,
|
|
1309
1315
|
wins: (ggcrank?.wins || 0) + (record.decision === "win" ? 1 : 0),
|
|
1310
|
-
matches: (ggcrank?.matches || 0) + 1
|
|
1316
|
+
matches: (ggcrank?.matches || 0) + 1,
|
|
1317
|
+
rankseason: config.rankseason
|
|
1311
1318
|
}]);
|
|
1312
1319
|
}
|
|
1313
1320
|
nextCursor = response.page?.next || null;
|
|
@@ -1367,7 +1374,8 @@ ${itemDetails.join("\n")}`;
|
|
|
1367
1374
|
name: record.profile.name,
|
|
1368
1375
|
rank: record.decision === "win" ? (ggcrank?.rank || 0) + 150 : (ggcrank?.rank || 0) - 50,
|
|
1369
1376
|
wins: (ggcrank?.wins || 0) + (record.decision === "win" ? 1 : 0),
|
|
1370
|
-
matches: (ggcrank?.matches || 0) + 1
|
|
1377
|
+
matches: (ggcrank?.matches || 0) + 1,
|
|
1378
|
+
rankseason: config.rankseason
|
|
1371
1379
|
}]);
|
|
1372
1380
|
}
|
|
1373
1381
|
nextCursor = response.page?.next || null;
|
|
@@ -1378,7 +1386,7 @@ ${itemDetails.join("\n")}`;
|
|
|
1378
1386
|
lastdate: new Date(currentMaxDate.toISOString())
|
|
1379
1387
|
});
|
|
1380
1388
|
}
|
|
1381
|
-
return "✅
|
|
1389
|
+
return "✅ 胜点榜数据手动同步成功!";
|
|
1382
1390
|
} catch (err) {
|
|
1383
1391
|
console.error("错误:", err);
|
|
1384
1392
|
return "服务器繁忙,请稍后尝试。";
|
|
@@ -1389,8 +1397,8 @@ ${itemDetails.join("\n")}`;
|
|
|
1389
1397
|
if (pageNum < 1) return "请输入有效的页码。";
|
|
1390
1398
|
const offset = (pageNum - 1) * 10;
|
|
1391
1399
|
const [records, total] = await Promise.all([
|
|
1392
|
-
ctx.database.select("ggcevo_rank").where({ Blacklist: false }).orderBy("rank", "desc").limit(10).offset(offset).execute(),
|
|
1393
|
-
ctx.database.select("ggcevo_rank").where({ Blacklist: false }).execute((row) => import_koishi.$.count(row.handle))
|
|
1400
|
+
ctx.database.select("ggcevo_rank").where({ Blacklist: false, rankseason: config.rankseason }).orderBy("rank", "desc").limit(10).offset(offset).execute(),
|
|
1401
|
+
ctx.database.select("ggcevo_rank").where({ Blacklist: false, rankseason: config.rankseason }).execute((row) => import_koishi.$.count(row.handle))
|
|
1394
1402
|
]);
|
|
1395
1403
|
const totalPages = Math.ceil(total / 10);
|
|
1396
1404
|
if (pageNum > totalPages) return `最多有 ${totalPages} 页`;
|
|
@@ -1406,7 +1414,7 @@ ${itemDetails.join("\n")}`;
|
|
|
1406
1414
|
(item, index) => `${offset + index + 1}. ${item.displayName} | 积分: ${item.rank} | 胜率: ${item.matches === 0 ? "0.00%" : (item.wins / item.matches * 100).toFixed(2) + "%"}`
|
|
1407
1415
|
).join("\n");
|
|
1408
1416
|
return [
|
|
1409
|
-
`🏆 咕咕胜点榜 ${config.rankseason}
|
|
1417
|
+
`🏆 咕咕胜点榜 ${config.rankseason}赛季`,
|
|
1410
1418
|
`数据最新同步时间: ${lastdate.toLocaleString("zh-CN", {
|
|
1411
1419
|
timeZone: "Asia/Shanghai",
|
|
1412
1420
|
year: "numeric",
|
|
@@ -1423,6 +1431,126 @@ ${itemDetails.join("\n")}`;
|
|
|
1423
1431
|
pageNum < totalPages ? `输入“胜点榜 ${pageNum + 1}”查看下一页` : "已是最后一页"
|
|
1424
1432
|
].join("\n");
|
|
1425
1433
|
});
|
|
1434
|
+
ctx.command("ggcevo/赛季结算", "进行赛季结算并发放奖励", { authority: 3 }).action(async ({ session }) => {
|
|
1435
|
+
await session.send(`确定要进行赛季结算吗?(请在30秒内回复“是”确认)`);
|
|
1436
|
+
const confirm = await session.prompt(3e4);
|
|
1437
|
+
if (confirm !== "是") return "已取消操作。";
|
|
1438
|
+
const currentSeason = config.rankseason;
|
|
1439
|
+
const requiredMedals = {
|
|
1440
|
+
champion: `🥇${currentSeason}赛季冠军勋章`,
|
|
1441
|
+
runnerUp: `🥈${currentSeason}赛季亚军勋章`,
|
|
1442
|
+
thirdPlace: `🥉${currentSeason}赛季季军勋章`,
|
|
1443
|
+
top10: `🏅${currentSeason}赛季前十勋章`,
|
|
1444
|
+
top20: `🎖${currentSeason}赛季前二十勋章`
|
|
1445
|
+
};
|
|
1446
|
+
const missing = Object.values(requiredMedals).filter((name2) => !initDefaultItems[name2]);
|
|
1447
|
+
if (missing.length > 0) return `缺少勋章配置:${missing.join(",")}`;
|
|
1448
|
+
const rankedPlayers = await ctx.database.get("ggcevo_rank", {
|
|
1449
|
+
Blacklist: false,
|
|
1450
|
+
rankseason: currentSeason
|
|
1451
|
+
}, {
|
|
1452
|
+
sort: { rank: "desc" },
|
|
1453
|
+
limit: 20
|
|
1454
|
+
});
|
|
1455
|
+
let report = `=== ${currentSeason}赛季结算报告 ===
|
|
1456
|
+
|
|
1457
|
+
`;
|
|
1458
|
+
const rewardDetails = [];
|
|
1459
|
+
let positiveCount = 0;
|
|
1460
|
+
let negativeCount = 0;
|
|
1461
|
+
for (const [index, player] of rankedPlayers.entries()) {
|
|
1462
|
+
const rank = index + 1;
|
|
1463
|
+
const { coins, gold } = getRewardByRank(index + 1);
|
|
1464
|
+
const [backpack] = await ctx.database.get("ggcevo_backpack", {
|
|
1465
|
+
handle: player.handle,
|
|
1466
|
+
itemId: 1
|
|
1467
|
+
});
|
|
1468
|
+
await ctx.database.upsert("ggcevo_backpack", [{
|
|
1469
|
+
handle: player.handle,
|
|
1470
|
+
itemId: 1,
|
|
1471
|
+
quantity: (backpack?.quantity || 0) + coins
|
|
1472
|
+
}], ["handle", "itemId"]);
|
|
1473
|
+
const [signData] = await ctx.database.get("ggcevo_sign", { handle: player.handle });
|
|
1474
|
+
await ctx.database.upsert("ggcevo_sign", [{
|
|
1475
|
+
handle: player.handle,
|
|
1476
|
+
totalRewards: (signData?.totalRewards || 0) + gold
|
|
1477
|
+
}], ["handle"]);
|
|
1478
|
+
const medalType = getMedalType(index + 1);
|
|
1479
|
+
const medalName = requiredMedals[medalType];
|
|
1480
|
+
const medalId = initDefaultItems[medalName].id;
|
|
1481
|
+
if (rank <= 3) {
|
|
1482
|
+
rewardDetails.push(`✦ 第${rank}名:${coins}枚咕咕币 + ${gold}枚金币 + ${requiredMedals[medalType]}`);
|
|
1483
|
+
}
|
|
1484
|
+
const [medalData] = await ctx.database.get("ggcevo_backpack", {
|
|
1485
|
+
handle: player.handle,
|
|
1486
|
+
itemId: medalId
|
|
1487
|
+
});
|
|
1488
|
+
await ctx.database.upsert("ggcevo_backpack", [{
|
|
1489
|
+
handle: player.handle,
|
|
1490
|
+
itemId: medalId,
|
|
1491
|
+
quantity: (medalData?.quantity || 0) + 1
|
|
1492
|
+
}], ["handle", "itemId"]);
|
|
1493
|
+
}
|
|
1494
|
+
report += "🏆 精英奖励详情:\n";
|
|
1495
|
+
report += rewardDetails.join("\n") + "\n";
|
|
1496
|
+
report += `✦ 第4-10名:60枚咕咕币 + 750枚金币 + ${requiredMedals.top10}
|
|
1497
|
+
`;
|
|
1498
|
+
report += `✦ 第11-20名:40枚咕咕币 + 500枚金币 + ${requiredMedals.top20}
|
|
1499
|
+
|
|
1500
|
+
`;
|
|
1501
|
+
const otherPlayers = await ctx.database.get("ggcevo_rank", {
|
|
1502
|
+
Blacklist: false,
|
|
1503
|
+
rankseason: currentSeason,
|
|
1504
|
+
handle: { $nin: rankedPlayers.map((p) => p.handle) },
|
|
1505
|
+
rank: { $ne: 0 }
|
|
1506
|
+
});
|
|
1507
|
+
for (const player of otherPlayers) {
|
|
1508
|
+
if (player.rank > 0) positiveCount++;
|
|
1509
|
+
if (player.rank < 0) negativeCount++;
|
|
1510
|
+
const gold = player.rank > 0 ? 250 : 100;
|
|
1511
|
+
const [signData] = await ctx.database.get("ggcevo_sign", { handle: player.handle });
|
|
1512
|
+
await ctx.database.upsert("ggcevo_sign", [{
|
|
1513
|
+
handle: player.handle,
|
|
1514
|
+
totalRewards: (signData?.totalRewards || 0) + gold
|
|
1515
|
+
}], ["handle"]);
|
|
1516
|
+
}
|
|
1517
|
+
report += "🎉 参与奖励发放:\n";
|
|
1518
|
+
report += `✦ 积极玩家(分数>0):${positiveCount}人,每人获得250枚金币
|
|
1519
|
+
`;
|
|
1520
|
+
report += `✦ 奋斗玩家(分数<0):${negativeCount}人,每人获得100枚金币
|
|
1521
|
+
|
|
1522
|
+
`;
|
|
1523
|
+
report += `✅ 总计发放:
|
|
1524
|
+
`;
|
|
1525
|
+
report += `- 赛季奖励:${rankedPlayers.length}人
|
|
1526
|
+
`;
|
|
1527
|
+
report += `- 参与奖励:${otherPlayers.length}人`;
|
|
1528
|
+
await session.send(report);
|
|
1529
|
+
return `${currentSeason}赛季结算数据已更新!`;
|
|
1530
|
+
function getRewardByRank(rank) {
|
|
1531
|
+
return [
|
|
1532
|
+
{ coins: 100, gold: 2e3 },
|
|
1533
|
+
// 第1名
|
|
1534
|
+
{ coins: 90, gold: 1500 },
|
|
1535
|
+
// 第2名
|
|
1536
|
+
{ coins: 80, gold: 1e3 },
|
|
1537
|
+
// 第3名
|
|
1538
|
+
...Array(7).fill({ coins: 60, gold: 750 }),
|
|
1539
|
+
//4-10
|
|
1540
|
+
...Array(10).fill({ coins: 40, gold: 500 })
|
|
1541
|
+
//11-20
|
|
1542
|
+
][rank - 1] || { coins: 0, gold: 0 };
|
|
1543
|
+
}
|
|
1544
|
+
__name(getRewardByRank, "getRewardByRank");
|
|
1545
|
+
function getMedalType(rank) {
|
|
1546
|
+
if (rank === 1) return "champion";
|
|
1547
|
+
if (rank === 2) return "runnerUp";
|
|
1548
|
+
if (rank === 3) return "thirdPlace";
|
|
1549
|
+
if (rank <= 10) return "top10";
|
|
1550
|
+
return "top20";
|
|
1551
|
+
}
|
|
1552
|
+
__name(getMedalType, "getMedalType");
|
|
1553
|
+
});
|
|
1426
1554
|
ctx.command("ggcevo/排名 [player]", "查询个人排名").alias("rank").usage("输入“排名”查看自己的排名信息").action(async (argv, player) => {
|
|
1427
1555
|
const session = argv.session;
|
|
1428
1556
|
if (!player) {
|
|
@@ -1443,7 +1571,7 @@ ${itemDetails.join("\n")}`;
|
|
|
1443
1571
|
) + 1;
|
|
1444
1572
|
const isSafe = await checkSensitiveWord(user.name);
|
|
1445
1573
|
const displayName = isSafe ? user.name : (user.name[0] || "") + "***";
|
|
1446
|
-
return `🎮 您的咕咕胜点榜排名信息
|
|
1574
|
+
return `🎮 您的咕咕胜点榜排名信息
|
|
1447
1575
|
------------------------------
|
|
1448
1576
|
昵称:${displayName}
|
|
1449
1577
|
句柄:${user.handle}
|
|
@@ -1476,7 +1604,7 @@ ${itemDetails.join("\n")}`;
|
|
|
1476
1604
|
) + 1;
|
|
1477
1605
|
const isSafe = await checkSensitiveWord(user.name);
|
|
1478
1606
|
const displayName = isSafe ? user.name : (user.name[0] || "") + "***";
|
|
1479
|
-
return `🎮 对方的咕咕胜点榜排名信息
|
|
1607
|
+
return `🎮 对方的咕咕胜点榜排名信息
|
|
1480
1608
|
------------------------------
|
|
1481
1609
|
昵称:${displayName}
|
|
1482
1610
|
句柄:${user.handle}
|
|
@@ -2177,7 +2305,7 @@ ${achievementList.join("\n")}`;
|
|
|
2177
2305
|
const action = currentState ? "关闭" : "开启";
|
|
2178
2306
|
await session.send(`您当前的PK状态为【${currentState ? "开启" : "关闭"}】,确认要${action}吗?(请在30秒内回复“是”确认)`);
|
|
2179
2307
|
const confirm = await session.prompt(3e4);
|
|
2180
|
-
if (confirm !== "是") return "
|
|
2308
|
+
if (confirm !== "是") return "已取消操作。";
|
|
2181
2309
|
await ctx.database.upsert("ggcevo_pk", [{
|
|
2182
2310
|
handle,
|
|
2183
2311
|
enable: !currentState,
|
|
@@ -2348,7 +2476,7 @@ ${validTypes.join("、")}`;
|
|
|
2348
2476
|
});
|
|
2349
2477
|
return `已成功装备 ${weapon}!`;
|
|
2350
2478
|
});
|
|
2351
|
-
ctx.command("ggcevo/升级 <weapon>", "升级武器伤害").alias("升级武器").action(async ({ session }, weapon) => {
|
|
2479
|
+
ctx.command("ggcevo/升级 <weapon>", "升级武器伤害").alias("升级武器", "武器升级").action(async ({ session }, weapon) => {
|
|
2352
2480
|
const [profile] = await ctx.database.get("sc2arcade_player", { userId: session.userId });
|
|
2353
2481
|
if (!profile) return "您暂未绑定句柄。";
|
|
2354
2482
|
const handle = `${profile.regionId}-S2-${profile.realmId}-${profile.profileId}`;
|
|
@@ -2357,7 +2485,7 @@ ${validTypes.join("、")}`;
|
|
|
2357
2485
|
handle,
|
|
2358
2486
|
weaponId: weaponConfig[weapon]?.id
|
|
2359
2487
|
});
|
|
2360
|
-
if (!weapon) return "
|
|
2488
|
+
if (!weapon) return "请输入“升级 武器名称”来升级你想要的武器。";
|
|
2361
2489
|
if (!equipment) return "尚未获得该武器。";
|
|
2362
2490
|
if (equipment.level >= 6) return "该武器已达最大升级等级。";
|
|
2363
2491
|
const activeWish = await ctx.database.get("ggcevo_Wish_Record", {
|
|
@@ -2404,7 +2532,7 @@ ${validTypes.join("、")}`;
|
|
|
2404
2532
|
return `${message}
|
|
2405
2533
|
当前等级:${newLevel},伤害:${baseDamage},可用改装槽:${slots}个。`;
|
|
2406
2534
|
});
|
|
2407
|
-
ctx.command("ggcevo/改装 <weapon> [mod]", "安装武器模块").alias("改装武器").action(async ({ session }, weapon, mod) => {
|
|
2535
|
+
ctx.command("ggcevo/改装 <weapon> [mod]", "安装武器模块").alias("改装武器", "改造", "改造武器").action(async ({ session }, weapon, mod) => {
|
|
2408
2536
|
const isValidWeapon = weapon && weaponConfig[weapon]?.id !== void 0;
|
|
2409
2537
|
const generateModList = /* @__PURE__ */ __name(() => {
|
|
2410
2538
|
if (!isValidWeapon) {
|
|
@@ -2422,7 +2550,7 @@ ${validTypes.join("、")}`;
|
|
|
2422
2550
|
if (!mod || !modConfig[mod]) {
|
|
2423
2551
|
return [
|
|
2424
2552
|
isValidWeapon ? `🛠️ ${weapon} 专属模块 🛠️` : "🛠️ 通用武器模块 🛠️",
|
|
2425
|
-
isValidWeapon ? `使用「改装 ${weapon}
|
|
2553
|
+
isValidWeapon ? `使用「改装 ${weapon} 模块名称」安装专属模块` : weapon ? "※ 无效武器名称,请使用「改装 武器名称 模块名称」安装模块" : "※ 输入「改装 武器名称」查询专属模块\n※ 安装模块:「改装 武器名称 模块名称」",
|
|
2426
2554
|
"====================",
|
|
2427
2555
|
generateModList()
|
|
2428
2556
|
].join("\n\n");
|
|
@@ -2608,11 +2736,11 @@ ${validTypes.join("、")}`;
|
|
|
2608
2736
|
const key = record.handle;
|
|
2609
2737
|
rewardMap.set(key, {
|
|
2610
2738
|
guguCoins: (rewardMap.get(key)?.guguCoins || 0) + 5,
|
|
2611
|
-
gold: (rewardMap.get(key)?.gold || 0) +
|
|
2739
|
+
gold: (rewardMap.get(key)?.gold || 0) + 250,
|
|
2612
2740
|
playerName: record.playerName
|
|
2613
2741
|
});
|
|
2614
2742
|
});
|
|
2615
|
-
rewardMessages.push(`其他参与者各获得: 5 咕咕币 +
|
|
2743
|
+
rewardMessages.push(`其他参与者各获得: 5 咕咕币 + 250 金币`);
|
|
2616
2744
|
}
|
|
2617
2745
|
const doubleRewardPlayers = /* @__PURE__ */ new Map();
|
|
2618
2746
|
for (const record of damageRecords) {
|
|
@@ -2838,7 +2966,7 @@ ${validTypes.join("、")}`;
|
|
|
2838
2966
|
}
|
|
2839
2967
|
return result.join("\n");
|
|
2840
2968
|
});
|
|
2841
|
-
ctx.command("ggcevo/祈愿").action(async (argv) => {
|
|
2969
|
+
ctx.command("ggcevo/祈愿").alias("祈福", "祈祷").action(async (argv) => {
|
|
2842
2970
|
const session = argv.session;
|
|
2843
2971
|
const [profile] = await ctx.database.get("sc2arcade_player", { userId: session.userId });
|
|
2844
2972
|
if (!profile) return "您暂未绑定句柄。";
|
|
@@ -2868,8 +2996,8 @@ ${validTypes.join("、")}`;
|
|
|
2868
2996
|
hour: "2-digit",
|
|
2869
2997
|
minute: "2-digit"
|
|
2870
2998
|
});
|
|
2871
|
-
return
|
|
2872
|
-
|
|
2999
|
+
return `🕒 祈愿冷却中,下次可祈愿时间:${endTime2}
|
|
3000
|
+
当前祈愿效果:【${currentEffect.name}】${currentEffect.effect}`;
|
|
2873
3001
|
}
|
|
2874
3002
|
let newGold = sign.totalRewards - 50;
|
|
2875
3003
|
const isRare = Math.random() < 0.05;
|