koishi-plugin-smmcat-gensokyo 0.0.9 → 0.0.11

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 CHANGED
@@ -267,50 +267,57 @@ var GensokyoMap = {
267
267
  },
268
268
  /** 用户移动 */
269
269
  async move(session, type, fn) {
270
- const userCurrentArea = GensokyoMap.userCurrentLoal[session.userId] || {};
271
- const { floor, areaName, moveing } = userCurrentArea;
272
- if (moveing) {
273
- await session.send("当前移动冷却中,请稍等...");
274
- return;
275
- }
276
- if (!(floor && areaName)) {
277
- await session.send("您当前位置有误,请使用(还没写好的指令)脱离卡死...");
278
- return;
279
- }
280
- userCurrentArea.moveing = true;
281
- const nowPosition = GensokyoMap.mapLocalData[floor][areaName];
282
- if (!nowPosition[type]) {
283
- await session.send("抱歉,此路不通!");
284
- userCurrentArea.moveing = false;
285
- return;
286
- }
287
- const newArea = GensokyoMap.mapLocalData[floor][nowPosition[type]];
288
- if (!newArea) {
289
- await session.send("进入失败,地图中不存在 " + nowPosition[type] + " 这个区域。");
290
- userCurrentArea.moveing = false;
291
- return;
292
- }
293
- if (newArea.type == "禁用" /* 禁用 */) {
294
- await session.send(`该区域暂时未开放...`);
295
- userCurrentArea.moveing = false;
296
- return;
297
- }
298
- if (newArea.needLv > 1) {
299
- await session.send(`当前区域由于您的等级未达到最低要求,暂时无法进入。
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) {
@@ -489,9 +496,9 @@ var User = {
489
496
  maxMp: 1.1,
490
497
  atk: 1.12,
491
498
  def: 1.1,
492
- chr: 1.1,
493
- evasion: 1.1,
494
- hit: 1.1,
499
+ chr: 1.08,
500
+ evasion: 1.08,
501
+ hit: 1.08,
495
502
  ghd: 1,
496
503
  speed: 1.05
497
504
  },
@@ -501,9 +508,9 @@ var User = {
501
508
  maxMp: 1.1,
502
509
  atk: 1.1,
503
510
  def: 1.1,
504
- chr: 1.1,
505
- evasion: 1.1,
506
- hit: 1.08,
511
+ chr: 1.04,
512
+ evasion: 1.04,
513
+ hit: 1.04,
507
514
  ghd: 1,
508
515
  speed: 1.05
509
516
  },
@@ -513,9 +520,9 @@ var User = {
513
520
  maxMp: 1.05,
514
521
  atk: 1.1,
515
522
  def: 1.05,
516
- chr: 1.05,
517
- evasion: 1.05,
518
- hit: 1.05,
523
+ chr: 1.03,
524
+ evasion: 1.03,
525
+ hit: 1.03,
519
526
  ghd: 1.05,
520
527
  speed: 1.05
521
528
  }
@@ -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
 
@@ -760,8 +771,8 @@ var Monster = {
760
771
  atk: 1.2,
761
772
  def: 1.1,
762
773
  chr: 1.1,
763
- evasion: 1.2,
764
- hit: 1.2,
774
+ evasion: 1.1,
775
+ hit: 1.1,
765
776
  ghd: 1,
766
777
  speed: 1.05
767
778
  },
@@ -772,9 +783,9 @@ var Monster = {
772
783
  maxMp: 1.1,
773
784
  atk: 1.1,
774
785
  def: 1.1,
775
- chr: 1.1,
776
- evasion: 1.1,
777
- hit: 1.1,
786
+ chr: 1.08,
787
+ evasion: 1.08,
788
+ hit: 1.08,
778
789
  ghd: 1,
779
790
  speed: 1.05
780
791
  },
@@ -1251,17 +1262,13 @@ MP:${item.mp}/${item.maxMp + item.gain.maxMp}`);
1251
1262
  },
1252
1263
  /** 清理战场 */
1253
1264
  clearBattleData(session) {
1254
- if (BattleData.isTeam(session)) {
1255
- const currentBattle = BattleData.lastPlay[session.userId];
1256
- const allAgentList = [...currentBattle.goal, ...currentBattle.self].sort((a, b) => b.speed - a.speed);
1257
- allAgentList.forEach((item) => {
1258
- if (item.type == "玩家") {
1259
- delete BattleData.lastPlay[item.userId];
1260
- }
1261
- });
1262
- } else {
1263
- delete BattleData.lastPlay[session.userId];
1264
- }
1265
+ const currentBattle = BattleData.lastPlay[session.userId];
1266
+ const allAgentList = [...currentBattle.goal, ...currentBattle.self];
1267
+ allAgentList.forEach((item) => {
1268
+ if (item.type == "玩家") {
1269
+ delete BattleData.lastPlay[item.userId];
1270
+ }
1271
+ });
1265
1272
  },
1266
1273
  async play(session, atkType, select) {
1267
1274
  if (!BattleData.isBattle(session)) {
@@ -1360,6 +1367,7 @@ MP:${item.mp}/${item.maxMp + item.gain.maxMp}`);
1360
1367
  },
1361
1368
  /** 结算奖励 */
1362
1369
  async settlement(tempData, overInfo, session) {
1370
+ const allList = [...tempData.self, ...tempData.goal].filter((item) => item.type == "玩家");
1363
1371
  const selfList = tempData.self.filter((item) => item.type == "玩家");
1364
1372
  const goalList = tempData.goal.filter((item) => item.type == "玩家");
1365
1373
  const msg = /* @__PURE__ */ __name(async (val) => {
@@ -1377,15 +1385,19 @@ MP:${item.mp}/${item.maxMp + item.gain.maxMp}`);
1377
1385
  if (tempData.isPK) {
1378
1386
  if (overInfo.win == "self") {
1379
1387
  await session.send("攻击方获得20EXP");
1380
- for (const agent of selfList) {
1388
+ for (const agent of allList) {
1381
1389
  aynchronize(agent);
1382
- await User.giveExp(agent.userId, 20, async (val) => await msg(val));
1390
+ if (agent.for == "self") {
1391
+ await User.giveExp(agent.userId, 20, async (val) => await msg(val));
1392
+ }
1383
1393
  }
1384
1394
  } else if (overInfo.win == "goal") {
1385
1395
  await session.send("防御方获得20EXP");
1386
- for (const agent of goalList) {
1396
+ for (const agent of allList) {
1387
1397
  aynchronize(agent);
1388
- await User.giveExp(agent.userId, 20, async (val) => await msg(val));
1398
+ if (agent.for == "goal") {
1399
+ await User.giveExp(agent.userId, 20, async (val) => await msg(val));
1400
+ }
1389
1401
  }
1390
1402
  }
1391
1403
  } else {
@@ -1394,13 +1406,15 @@ MP:${item.mp}/${item.maxMp + item.gain.maxMp}`);
1394
1406
  monsterName.forEach((item) => {
1395
1407
  const monster = Monster.monsterTempData[item.name];
1396
1408
  if (monster) {
1397
- val += monster.giveExp + monster.giveExp * (item.lv - 1) * 0.2;
1409
+ val += Math.floor(monster.giveExp + monster.giveExp * (item.lv - 1) * 0.2);
1398
1410
  }
1399
1411
  });
1400
1412
  for (const agent of selfList) {
1401
1413
  aynchronize(agent);
1402
- await session.send(`小队获得${val}EXP`);
1403
- await User.giveExp(agent.userId, val, async (val2) => await msg(val2));
1414
+ if (overInfo.win == "self") {
1415
+ await session.send(`小队获得${val}EXP`);
1416
+ await User.giveExp(agent.userId, val, async (val2) => await msg(val2));
1417
+ }
1404
1418
  }
1405
1419
  }
1406
1420
  }
@@ -1503,6 +1517,9 @@ function apply(ctx, config) {
1503
1517
  await session.send("您正在战斗中,无法移动!");
1504
1518
  return;
1505
1519
  }
1520
+ if (User.isDie(session.userId)) {
1521
+ return `你已经阵亡,请发送 /补给 进行治疗。`;
1522
+ }
1506
1523
  GensokyoMap.move(session, "top" /* 上 */, async (val) => {
1507
1524
  await session.send(GensokyoMap.userAreaTextFormat(userData.playName, val));
1508
1525
  if (val.map.type == "冒险区" /* 冒险区 */ && val.map.monster?.length) {
@@ -1523,6 +1540,9 @@ function apply(ctx, config) {
1523
1540
  await session.send("您正在战斗中,无法移动!");
1524
1541
  return;
1525
1542
  }
1543
+ if (User.isDie(session.userId)) {
1544
+ return `你已经阵亡,请发送 /补给 进行治疗。`;
1545
+ }
1526
1546
  GensokyoMap.move(session, "down" /* 下 */, async (val) => {
1527
1547
  await session.send(GensokyoMap.userAreaTextFormat(userData.playName, val));
1528
1548
  if (val.map.type == "冒险区" /* 冒险区 */ && val.map.monster?.length) {
@@ -1543,6 +1563,9 @@ function apply(ctx, config) {
1543
1563
  await session.send("您正在战斗中,无法移动!");
1544
1564
  return;
1545
1565
  }
1566
+ if (User.isDie(session.userId)) {
1567
+ return `你已经阵亡,请发送 /补给 进行治疗。`;
1568
+ }
1546
1569
  GensokyoMap.move(session, "left" /* 左 */, async (val) => {
1547
1570
  await session.send(GensokyoMap.userAreaTextFormat(userData.playName, val));
1548
1571
  if (val.map.type == "冒险区" /* 冒险区 */ && val.map.monster?.length) {
@@ -1563,6 +1586,9 @@ function apply(ctx, config) {
1563
1586
  await session.send("您正在战斗中,无法移动!");
1564
1587
  return;
1565
1588
  }
1589
+ if (User.isDie(session.userId)) {
1590
+ return `你已经阵亡,请发送 /补给 进行治疗。`;
1591
+ }
1566
1592
  GensokyoMap.move(session, "right" /* 右 */, async (val) => {
1567
1593
  await session.send(GensokyoMap.userAreaTextFormat(userData.playName, val));
1568
1594
  if (val.map.type == "冒险区" /* 冒险区 */ && val.map.monster?.length) {
@@ -1606,6 +1632,9 @@ function apply(ctx, config) {
1606
1632
  const userData = await User.getUserAttribute(session);
1607
1633
  if (!userData) return;
1608
1634
  GensokyoMap.initUserPoistion(session, userData);
1635
+ if (User.isDie(session.userId)) {
1636
+ return `你已经阵亡,请发送 /补给 进行治疗。`;
1637
+ }
1609
1638
  const areaInfo = GensokyoMap.getUserCurrentArea(session.userId);
1610
1639
  if (goal) {
1611
1640
  if (!areaInfo.monster?.map((i) => i.name).includes(goal)) {
@@ -1632,6 +1661,9 @@ function apply(ctx, config) {
1632
1661
  const userData = await User.getUserAttribute(session);
1633
1662
  if (!userData) return;
1634
1663
  GensokyoMap.initUserPoistion(session, userData);
1664
+ if (User.isDie(session.userId)) {
1665
+ return `你已经阵亡,请发送 /补给 进行治疗。`;
1666
+ }
1635
1667
  if (!goal) {
1636
1668
  await session.send("请选择PK目标!");
1637
1669
  return;
@@ -1642,6 +1674,9 @@ function apply(ctx, config) {
1642
1674
  await session.send(`PK失败,当前区域未存在【${goal}】玩家`);
1643
1675
  return;
1644
1676
  }
1677
+ if (User.isDie(exist.userId)) {
1678
+ return `目标已经阵亡,请更换PK目标对象...`;
1679
+ }
1645
1680
  if (BattleData.isTeamByUserId(exist.userId)) {
1646
1681
  const teamItem = BattleData.teamListByUser(exist.userId);
1647
1682
  await session.send(`对方有组队,您将扮演攻击方与对方队伍进行战斗。`);
@@ -1667,7 +1702,7 @@ function apply(ctx, config) {
1667
1702
  }
1668
1703
  const useTime = Date.now() - temp[session.userId];
1669
1704
  if (useTime < 36e4) {
1670
- return `请等待下一个补给时间!剩余${Math.floor(useTime / 6e4)}分钟。`;
1705
+ return `请等待下一个补给时间!剩余${Math.floor(36e4 - useTime / 6e4)}分钟。`;
1671
1706
  }
1672
1707
  temp[session.userId] = Date.now();
1673
1708
  const { maxHp, maxMp, playName } = User.getUserAttributeByUserId(session.userId);
package/lib/users.d.ts CHANGED
@@ -126,5 +126,7 @@ export declare const User: {
126
126
  lv: number;
127
127
  name: string;
128
128
  }) => Promise<void>): Promise<void>;
129
+ /** 目标是否死亡 */
130
+ isDie(userId: string): boolean;
129
131
  };
130
132
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-smmcat-gensokyo",
3
3
  "description": "名为《幻想乡》的文字冒险游戏",
4
- "version": "0.0.9",
4
+ "version": "0.0.11",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [