koishi-plugin-smmcat-gensokyo 0.0.9 → 0.0.10
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 +72 -40
- package/lib/users.d.ts +2 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -267,50 +267,57 @@ var GensokyoMap = {
|
|
|
267
267
|
},
|
|
268
268
|
/** 用户移动 */
|
|
269
269
|
async move(session, type, fn) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
270
|
+
try {
|
|
271
|
+
const userCurrentArea = GensokyoMap.userCurrentLoal[session.userId] || {};
|
|
272
|
+
const { floor, areaName, moveing } = userCurrentArea;
|
|
273
|
+
if (moveing) {
|
|
274
|
+
await session.send("当前移动冷却中,请稍等...");
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
if (!(floor && areaName)) {
|
|
278
|
+
await session.send("您当前位置有误,请使用(还没写好的指令)脱离卡死...");
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
userCurrentArea.moveing = true;
|
|
282
|
+
const nowPosition = GensokyoMap.mapLocalData[floor][areaName];
|
|
283
|
+
if (!nowPosition[type]) {
|
|
284
|
+
await session.send("抱歉,此路不通!");
|
|
285
|
+
userCurrentArea.moveing = false;
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
const newArea = GensokyoMap.mapLocalData[floor][nowPosition[type]];
|
|
289
|
+
if (!newArea) {
|
|
290
|
+
await session.send("进入失败,地图中不存在 " + nowPosition[type] + " 这个区域。");
|
|
291
|
+
userCurrentArea.moveing = false;
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (newArea.type == "禁用" /* 禁用 */) {
|
|
295
|
+
await session.send(`该区域暂时未开放...`);
|
|
296
|
+
userCurrentArea.moveing = false;
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (newArea.needLv > 1) {
|
|
300
|
+
await session.send(`当前区域由于您的等级未达到最低要求,暂时无法进入。
|
|
300
301
|
需要等级:${newArea.needLv}级`);
|
|
302
|
+
userCurrentArea.moveing = false;
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
userCurrentArea.areaName = newArea.areaName;
|
|
306
|
+
const areaInfo = {
|
|
307
|
+
user: { ...userCurrentArea },
|
|
308
|
+
map: { ...newArea }
|
|
309
|
+
};
|
|
310
|
+
fn && await fn(areaInfo);
|
|
311
|
+
await delay(3e3);
|
|
301
312
|
userCurrentArea.moveing = false;
|
|
313
|
+
GensokyoMap.setLocalStoragePoistionData(session.userId);
|
|
302
314
|
return;
|
|
315
|
+
} catch (error) {
|
|
316
|
+
console.log(error);
|
|
317
|
+
if (GensokyoMap.userCurrentLoal?.[session.userId]) {
|
|
318
|
+
GensokyoMap.userCurrentLoal[session.userId].moveing = false;
|
|
319
|
+
}
|
|
303
320
|
}
|
|
304
|
-
userCurrentArea.areaName = newArea.areaName;
|
|
305
|
-
const areaInfo = {
|
|
306
|
-
user: { ...userCurrentArea },
|
|
307
|
-
map: { ...newArea }
|
|
308
|
-
};
|
|
309
|
-
fn && await fn(areaInfo);
|
|
310
|
-
await delay(3e3);
|
|
311
|
-
userCurrentArea.moveing = false;
|
|
312
|
-
GensokyoMap.setLocalStoragePoistionData(session.userId);
|
|
313
|
-
return;
|
|
314
321
|
},
|
|
315
322
|
/** 查询附近玩家 */
|
|
316
323
|
nearbyPlayersByUserId(userId) {
|
|
@@ -643,6 +650,10 @@ ${Object.keys(UserOccDict).map((i) => `【${i}】:${UserOccDict[i].info}`).join(
|
|
|
643
650
|
fn && await fn(upTemp);
|
|
644
651
|
}
|
|
645
652
|
await User.setDatabaseUserAttribute(userId);
|
|
653
|
+
},
|
|
654
|
+
/** 目标是否死亡 */
|
|
655
|
+
isDie(userId) {
|
|
656
|
+
return User.userTempData[userId]?.hp <= 0;
|
|
646
657
|
}
|
|
647
658
|
};
|
|
648
659
|
|
|
@@ -1503,6 +1514,9 @@ function apply(ctx, config) {
|
|
|
1503
1514
|
await session.send("您正在战斗中,无法移动!");
|
|
1504
1515
|
return;
|
|
1505
1516
|
}
|
|
1517
|
+
if (User.isDie(session.userId)) {
|
|
1518
|
+
return `你已经阵亡,请发送 /补给 进行治疗。`;
|
|
1519
|
+
}
|
|
1506
1520
|
GensokyoMap.move(session, "top" /* 上 */, async (val) => {
|
|
1507
1521
|
await session.send(GensokyoMap.userAreaTextFormat(userData.playName, val));
|
|
1508
1522
|
if (val.map.type == "冒险区" /* 冒险区 */ && val.map.monster?.length) {
|
|
@@ -1523,6 +1537,9 @@ function apply(ctx, config) {
|
|
|
1523
1537
|
await session.send("您正在战斗中,无法移动!");
|
|
1524
1538
|
return;
|
|
1525
1539
|
}
|
|
1540
|
+
if (User.isDie(session.userId)) {
|
|
1541
|
+
return `你已经阵亡,请发送 /补给 进行治疗。`;
|
|
1542
|
+
}
|
|
1526
1543
|
GensokyoMap.move(session, "down" /* 下 */, async (val) => {
|
|
1527
1544
|
await session.send(GensokyoMap.userAreaTextFormat(userData.playName, val));
|
|
1528
1545
|
if (val.map.type == "冒险区" /* 冒险区 */ && val.map.monster?.length) {
|
|
@@ -1543,6 +1560,9 @@ function apply(ctx, config) {
|
|
|
1543
1560
|
await session.send("您正在战斗中,无法移动!");
|
|
1544
1561
|
return;
|
|
1545
1562
|
}
|
|
1563
|
+
if (User.isDie(session.userId)) {
|
|
1564
|
+
return `你已经阵亡,请发送 /补给 进行治疗。`;
|
|
1565
|
+
}
|
|
1546
1566
|
GensokyoMap.move(session, "left" /* 左 */, async (val) => {
|
|
1547
1567
|
await session.send(GensokyoMap.userAreaTextFormat(userData.playName, val));
|
|
1548
1568
|
if (val.map.type == "冒险区" /* 冒险区 */ && val.map.monster?.length) {
|
|
@@ -1563,6 +1583,9 @@ function apply(ctx, config) {
|
|
|
1563
1583
|
await session.send("您正在战斗中,无法移动!");
|
|
1564
1584
|
return;
|
|
1565
1585
|
}
|
|
1586
|
+
if (User.isDie(session.userId)) {
|
|
1587
|
+
return `你已经阵亡,请发送 /补给 进行治疗。`;
|
|
1588
|
+
}
|
|
1566
1589
|
GensokyoMap.move(session, "right" /* 右 */, async (val) => {
|
|
1567
1590
|
await session.send(GensokyoMap.userAreaTextFormat(userData.playName, val));
|
|
1568
1591
|
if (val.map.type == "冒险区" /* 冒险区 */ && val.map.monster?.length) {
|
|
@@ -1606,6 +1629,9 @@ function apply(ctx, config) {
|
|
|
1606
1629
|
const userData = await User.getUserAttribute(session);
|
|
1607
1630
|
if (!userData) return;
|
|
1608
1631
|
GensokyoMap.initUserPoistion(session, userData);
|
|
1632
|
+
if (User.isDie(session.userId)) {
|
|
1633
|
+
return `你已经阵亡,请发送 /补给 进行治疗。`;
|
|
1634
|
+
}
|
|
1609
1635
|
const areaInfo = GensokyoMap.getUserCurrentArea(session.userId);
|
|
1610
1636
|
if (goal) {
|
|
1611
1637
|
if (!areaInfo.monster?.map((i) => i.name).includes(goal)) {
|
|
@@ -1632,6 +1658,9 @@ function apply(ctx, config) {
|
|
|
1632
1658
|
const userData = await User.getUserAttribute(session);
|
|
1633
1659
|
if (!userData) return;
|
|
1634
1660
|
GensokyoMap.initUserPoistion(session, userData);
|
|
1661
|
+
if (User.isDie(session.userId)) {
|
|
1662
|
+
return `你已经阵亡,请发送 /补给 进行治疗。`;
|
|
1663
|
+
}
|
|
1635
1664
|
if (!goal) {
|
|
1636
1665
|
await session.send("请选择PK目标!");
|
|
1637
1666
|
return;
|
|
@@ -1642,6 +1671,9 @@ function apply(ctx, config) {
|
|
|
1642
1671
|
await session.send(`PK失败,当前区域未存在【${goal}】玩家`);
|
|
1643
1672
|
return;
|
|
1644
1673
|
}
|
|
1674
|
+
if (User.isDie(exist.userId)) {
|
|
1675
|
+
return `目标已经阵亡,请更换PK目标对象...`;
|
|
1676
|
+
}
|
|
1645
1677
|
if (BattleData.isTeamByUserId(exist.userId)) {
|
|
1646
1678
|
const teamItem = BattleData.teamListByUser(exist.userId);
|
|
1647
1679
|
await session.send(`对方有组队,您将扮演攻击方与对方队伍进行战斗。`);
|
package/lib/users.d.ts
CHANGED