koishi-plugin-smmcat-gensokyo 0.0.36 → 0.0.37

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
@@ -2777,14 +2777,15 @@ ${belowUser.map((item) => {
2777
2777
  }
2778
2778
  }
2779
2779
  userCurrentArea.areaName = newArea.areaName;
2780
+ userCurrentArea.floor = newArea.floor;
2780
2781
  const areaInfo = {
2781
2782
  user: { ...userCurrentArea },
2782
2783
  map: { ...newArea }
2783
2784
  };
2784
2785
  fn && await fn(areaInfo);
2785
- await delay(3e3);
2786
2786
  userCurrentArea.moveing = false;
2787
2787
  GensokyoMap.setLocalStoragePoistionData(session.userId);
2788
+ await delay(3e3);
2788
2789
  return;
2789
2790
  } catch (error) {
2790
2791
  console.log(error);
@@ -2793,6 +2794,75 @@ ${belowUser.map((item) => {
2793
2794
  }
2794
2795
  }
2795
2796
  },
2797
+ /** 用户传送楼层 */
2798
+ async jumpFloor(session, afterFloor, fn) {
2799
+ const userCurrentArea = GensokyoMap.userCurrentLoal[session.userId] || {};
2800
+ const { floor, areaName, moveing } = userCurrentArea;
2801
+ if (moveing) {
2802
+ await session.send("当前移动冷却中,请稍等...");
2803
+ return;
2804
+ }
2805
+ if (!(floor && areaName)) {
2806
+ await session.send("您当前位置有误,请使用(还没写好的指令)脱离卡死...");
2807
+ return;
2808
+ }
2809
+ if (floor == afterFloor) {
2810
+ await session.send("目标层和当前层一致,无需传送!");
2811
+ return;
2812
+ }
2813
+ userCurrentArea.moveing = true;
2814
+ const newFloorMap = GensokyoMap.mapLocalData[afterFloor];
2815
+ if (!newFloorMap) {
2816
+ await session.send("未存在该层,传送失败!");
2817
+ userCurrentArea.moveing = false;
2818
+ return;
2819
+ }
2820
+ const currentArea = Object.keys(newFloorMap).find((areaName2) => newFloorMap[areaName2].type == "传送门" /* 传送门 */);
2821
+ if (!currentArea) {
2822
+ await session.send("目标传送层不存在传送门区域,传送失败...");
2823
+ userCurrentArea.moveing = false;
2824
+ return;
2825
+ }
2826
+ const afterArea = newFloorMap[currentArea];
2827
+ console.log(newFloorMap[currentArea]);
2828
+ if (BattleData.isTeam(session)) {
2829
+ const { userId } = session;
2830
+ const myTeamList = [];
2831
+ Object.keys(BattleData.teamTemp).forEach((_userId) => {
2832
+ if (BattleData.teamTemp[_userId].for == userId && userId !== _userId) {
2833
+ myTeamList.push(_userId);
2834
+ }
2835
+ });
2836
+ const belowUser = myTeamList.filter((teamUserId) => afterArea.needLv > User.userTempData[teamUserId].lv);
2837
+ if (belowUser.length) {
2838
+ await session.send(
2839
+ `移动失败!队伍存在限制进入等级(lv.${afterArea.needLv})玩家,
2840
+ 目前限制进入的玩家:
2841
+ ${belowUser.map((item) => {
2842
+ return `Lv.${User.userTempData[item].lv} ${User.userTempData[item].playName}`;
2843
+ }).join("\n")}`
2844
+ );
2845
+ userCurrentArea.moveing = false;
2846
+ return;
2847
+ }
2848
+ for (const moveTeamUserId of myTeamList) {
2849
+ GensokyoMap.userCurrentLoal[moveTeamUserId].areaName = afterArea.areaName;
2850
+ GensokyoMap.userCurrentLoal[moveTeamUserId].floor = afterArea.floor;
2851
+ GensokyoMap.userCurrentLoal[moveTeamUserId].moveing = false;
2852
+ await GensokyoMap.setLocalStoragePoistionData(moveTeamUserId);
2853
+ }
2854
+ }
2855
+ userCurrentArea.areaName = afterArea.areaName;
2856
+ userCurrentArea.floor = afterArea.floor;
2857
+ const areaInfo = {
2858
+ user: { ...userCurrentArea },
2859
+ map: { ...afterArea }
2860
+ };
2861
+ fn && await fn(areaInfo);
2862
+ userCurrentArea.moveing = false;
2863
+ GensokyoMap.setLocalStoragePoistionData(session.userId);
2864
+ await delay(3e3);
2865
+ },
2796
2866
  /** 查询附近玩家 */
2797
2867
  nearbyPlayersByUserId(userId) {
2798
2868
  const areaData = GensokyoMap.getUserCurrentArea(userId);
@@ -2899,7 +2969,9 @@ function generateMapHTML(mapData, currentAreaName) {
2899
2969
  let html = `
2900
2970
  <style>
2901
2971
  .map-container {
2902
- display: inline-block;
2972
+ display: flex;
2973
+ justify-content: center;
2974
+ align-items: center;
2903
2975
  position: relative;
2904
2976
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
2905
2977
  font-size: 12px;
@@ -2907,7 +2979,7 @@ function generateMapHTML(mapData, currentAreaName) {
2907
2979
  padding: 20px;
2908
2980
  border-radius: 12px;
2909
2981
  min-width: 100vw;
2910
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
2982
+ min-height:100vh;
2911
2983
  }
2912
2984
  .map-table {
2913
2985
  border-collapse: separate;
@@ -3056,46 +3128,7 @@ function generateMapHTML(mapData, currentAreaName) {
3056
3128
  <div class="map-container">
3057
3129
  <svg class="connection-lines" width="${svgWidth}" height="${svgHeight}">
3058
3130
  `;
3059
- for (let r = minRow; r <= maxRow; r++) {
3060
- for (let c = minCol; c <= maxCol; c++) {
3061
- const cell = grid[r]?.[c];
3062
- if (cell) {
3063
- const { connections } = cell;
3064
- const x = (c - minCol) * cellWidth + cellWidth / 2;
3065
- const y = (r - minRow) * cellHeight + cellHeight / 2;
3066
- html += `<circle class="connection-dot" cx="${x}" cy="${y}" r="4" />`;
3067
- if (connections.top) {
3068
- const targetX = x;
3069
- const targetY = y - cellHeight;
3070
- html += `<line class="connection-line connection-line-dotted"
3071
- x1="${x}" y1="${y}"
3072
- x2="${targetX}" y2="${targetY}" />`;
3073
- }
3074
- if (connections.down) {
3075
- const targetX = x;
3076
- const targetY = y + cellHeight;
3077
- html += `<line class="connection-line connection-line-dotted"
3078
- x1="${x}" y1="${y}"
3079
- x2="${targetX}" y2="${targetY}" />`;
3080
- }
3081
- if (connections.left) {
3082
- const targetX = x - cellWidth;
3083
- const targetY = y;
3084
- html += `<line class="connection-line connection-line-dotted"
3085
- x1="${x}" y1="${y}"
3086
- x2="${targetX}" y2="${targetY}" />`;
3087
- }
3088
- if (connections.right) {
3089
- const targetX = x + cellWidth;
3090
- const targetY = y;
3091
- html += `<line class="connection-line connection-line-dotted"
3092
- x1="${x}" y1="${y}"
3093
- x2="${targetX}" y2="${targetY}" />`;
3094
- }
3095
- }
3096
- }
3097
- }
3098
- html += `</svg><table class="map-table">`;
3131
+ html += `<table class="map-table">`;
3099
3132
  for (let r = minRow; r <= maxRow; r++) {
3100
3133
  html += "<tr>";
3101
3134
  for (let c = minCol; c <= maxCol; c++) {
@@ -3476,6 +3509,15 @@ function apply(ctx, config) {
3476
3509
  ctx.command("幻想乡/打怪逃跑").action(async ({ session }) => {
3477
3510
  await Queue.add(async () => await BattleData.battleEscape(session));
3478
3511
  });
3512
+ ctx.command("幻想乡/传送 <floor:posint>").action(async ({ session }, floor) => {
3513
+ if (GensokyoMap.getUserCurrentArea(session.userId).type !== "传送门" /* 传送门 */) {
3514
+ return "该区域未存在传送门建筑,传送失败!";
3515
+ }
3516
+ GensokyoMap.jumpFloor(session, floor, async (val) => {
3517
+ await session.send(`传送到${floor}层成功!`);
3518
+ await session.send(GensokyoMap.userAreaTextFormat(val.user.playName, val));
3519
+ });
3520
+ });
3479
3521
  }
3480
3522
  __name(apply, "apply");
3481
3523
  // Annotate the CommonJS export names for ESM import in node:
package/lib/map.d.ts CHANGED
@@ -98,6 +98,8 @@ export declare const GensokyoMap: {
98
98
  setLocalStoragePoistionData(userId: string): Promise<void>;
99
99
  /** 用户移动 */
100
100
  move(session: Session, type: MoveType, fn?: (area: AreaCallbackData) => Promise<void>): Promise<void>;
101
+ /** 用户传送楼层 */
102
+ jumpFloor(session: Session, afterFloor: number, fn?: (area: AreaCallbackData) => Promise<void>): Promise<void>;
101
103
  /** 查询附近玩家 */
102
104
  nearbyPlayersByUserId(userId: string): {
103
105
  userId: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-smmcat-gensokyo",
3
3
  "description": "名为《幻想乡》的文字冒险游戏",
4
- "version": "0.0.36",
4
+ "version": "0.0.37",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [