koishi-plugin-smmcat-gensokyo 0.0.31 → 0.0.33
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/battle.d.ts +4 -0
- package/lib/index.js +38 -3
- package/package.json +1 -1
package/lib/battle.d.ts
CHANGED
|
@@ -177,6 +177,10 @@ export declare const BattleData: {
|
|
|
177
177
|
};
|
|
178
178
|
/** 清理战场 */
|
|
179
179
|
clearBattleData(session: Session): void;
|
|
180
|
+
/** 打怪逃跑 */
|
|
181
|
+
battleEscape(session: Session): Promise<void>;
|
|
182
|
+
/** 同步状态 */
|
|
183
|
+
aynchronize(agent: BattleAttribute): void;
|
|
180
184
|
play(session: Session, atkType: string, select?: string): Promise<void>;
|
|
181
185
|
/** 结算奖励 */
|
|
182
186
|
settlement(tempData: {
|
package/lib/index.js
CHANGED
|
@@ -1304,6 +1304,38 @@ MP:${item.mp}/${item.maxMp + item.gain.maxMp}`);
|
|
|
1304
1304
|
}
|
|
1305
1305
|
});
|
|
1306
1306
|
},
|
|
1307
|
+
/** 打怪逃跑 */
|
|
1308
|
+
async battleEscape(session) {
|
|
1309
|
+
const currentBattle = BattleData.lastPlay[session.userId];
|
|
1310
|
+
if (currentBattle.isPK) {
|
|
1311
|
+
await session.send(`与玩家PK中途不能逃跑啊!`);
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
if (currentBattle.goal.some((item) => item.selfType == "BOSS" /* BOSS */)) {
|
|
1315
|
+
await session.send(`与BOSS对战的中途不能逃跑啊!`);
|
|
1316
|
+
return;
|
|
1317
|
+
}
|
|
1318
|
+
const allAgentList = [...currentBattle.goal, ...currentBattle.self];
|
|
1319
|
+
const losePrice = random(5, 10);
|
|
1320
|
+
const isTeam = BattleData.isTeam(session);
|
|
1321
|
+
for (const agent of allAgentList) {
|
|
1322
|
+
if (agent.type == "玩家") {
|
|
1323
|
+
BattleData.aynchronize(agent);
|
|
1324
|
+
await User.lostMonetary(agent.userId, losePrice);
|
|
1325
|
+
await User.setDatabaseUserAttribute(agent.userId);
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
BattleData.clearBattleData(session);
|
|
1329
|
+
await session.send(isTeam ? `队伍在战斗中逃跑了,逃跑中均失去${losePrice}货币...` : `您在战斗中逃跑了。逃跑途中失去${losePrice}货币...`);
|
|
1330
|
+
},
|
|
1331
|
+
/** 同步状态 */
|
|
1332
|
+
aynchronize(agent) {
|
|
1333
|
+
User.userTempData[agent.userId].hp = agent.hp > 0 ? agent.hp : 0;
|
|
1334
|
+
User.userTempData[agent.userId].mp = agent.mp;
|
|
1335
|
+
if (User.userTempData[agent.userId].hp <= 0) {
|
|
1336
|
+
User.userTempData[agent.userId].isDie = true;
|
|
1337
|
+
}
|
|
1338
|
+
},
|
|
1307
1339
|
async play(session, atkType, select) {
|
|
1308
1340
|
if (!BattleData.isBattle(session)) {
|
|
1309
1341
|
await session.send("您并没有任何参与战斗。");
|
|
@@ -2033,7 +2065,7 @@ ${Object.keys(UserOccDict).map((i) => `【${i}】:${UserOccDict[i].info}`).join(
|
|
|
2033
2065
|
name: afterData.playName,
|
|
2034
2066
|
lv: afterData.lv,
|
|
2035
2067
|
maxHp: afterData.maxHp - beforData.maxHp,
|
|
2036
|
-
maxMp: afterData.maxMp
|
|
2068
|
+
maxMp: afterData.maxMp - beforData.maxMp,
|
|
2037
2069
|
atk: afterData.atk - beforData.atk,
|
|
2038
2070
|
def: afterData.def - beforData.def
|
|
2039
2071
|
};
|
|
@@ -2624,7 +2656,7 @@ var GensokyoMap = {
|
|
|
2624
2656
|
const { userId } = session;
|
|
2625
2657
|
const myTeamList = [];
|
|
2626
2658
|
Object.keys(BattleData.teamTemp).forEach((_userId) => {
|
|
2627
|
-
if (BattleData.teamTemp[
|
|
2659
|
+
if (BattleData.teamTemp[_userId].for == userId && userId !== _userId) {
|
|
2628
2660
|
myTeamList.push(_userId);
|
|
2629
2661
|
}
|
|
2630
2662
|
});
|
|
@@ -2701,7 +2733,7 @@ ${belowUser.map((item) => {
|
|
|
2701
2733
|
[!]存在商店:${data.map.shopName}` : "") + (data.map.npc ? `
|
|
2702
2734
|
[!]存在npc:${data.map.npc.join("、")}` : "") + (data.map.monster ? `
|
|
2703
2735
|
[!]存在野怪:${data.map.monster.map((i) => `lv.${i.lv} ${i.name}`).join("、")}` : "") + (liveUser.length ? `
|
|
2704
|
-
[!]区域玩家:${liveUser.length > 3 ? liveUser.slice(0, 3).join("、") + `...等${liveUser.length}
|
|
2736
|
+
[!]区域玩家:${liveUser.length > 3 ? liveUser.slice(0, 3).join("、") + `...等${liveUser.length}名玩家` : liveUser.join("、")}` : "");
|
|
2705
2737
|
return str + mapInfo;
|
|
2706
2738
|
}
|
|
2707
2739
|
};
|
|
@@ -3343,6 +3375,9 @@ function apply(ctx, config) {
|
|
|
3343
3375
|
console.log(html);
|
|
3344
3376
|
await session.send(await ctx.puppeteer.render(html));
|
|
3345
3377
|
});
|
|
3378
|
+
ctx.command("幻想乡/打怪逃跑").action(async ({ session }) => {
|
|
3379
|
+
await BattleData.battleEscape(session);
|
|
3380
|
+
});
|
|
3346
3381
|
}
|
|
3347
3382
|
__name(apply, "apply");
|
|
3348
3383
|
// Annotate the CommonJS export names for ESM import in node:
|