Prechádzať zdrojové kódy

:whale:
新增错误码
增加地图逻辑服
玩家进入指定地图
玩家移动

渔民小镇 1 rok pred
rodič
commit
2f729db45f
49 zmenil súbory, kde vykonal 1704 pridanie a 103 odobranie
  1. 46 0
      common/common-core/src/main/java/com/iohao/mmo/common/config/GameCode.java
  2. 2 1
      common/common-core/src/main/java/com/iohao/mmo/common/core/flow/MyAttachment.java
  3. 16 5
      common/common-core/src/main/java/com/iohao/mmo/common/core/flow/MyFlowContext.java
  4. 23 4
      common/common-core/src/main/java/com/iohao/mmo/common/logic/server/LogicServerKit.java
  5. 13 0
      logic/a-logic-common/pom.xml
  6. 1 1
      logic/a-logic-common/src/main/resources/logback-spring.xml
  7. 8 0
      logic/all-logic/pom.xml
  8. 31 0
      logic/all-logic/src/main/java/com/iohao/mmo/common/provide/cmd/AllLogicEmpty.java
  9. 2 1
      logic/login-logic/pom.xml
  10. 1 2
      logic/login-logic/src/main/java/com/iohao/mmo/login/LoginLogicServer.java
  11. 20 4
      logic/login-logic/src/main/java/com/iohao/mmo/login/action/LoginAction.java
  12. 38 0
      logic/map-logic/.gitignore
  13. 43 0
      logic/map-logic/pom.xml
  14. 61 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/MapLogicServer.java
  15. 134 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/action/MapAction.java
  16. 47 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/mapper/MapMapper.java
  17. 45 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/room/Location.java
  18. 37 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/room/MapPlayer.java
  19. 46 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/room/MapRoom.java
  20. 73 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/room/MapRoomRegions.java
  21. 112 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/room/flow/MapFlow.java
  22. 41 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/room/flow/MapRoomCreateCustom.java
  23. 34 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/room/flow/MapRoomEnterCustom.java
  24. 45 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/room/flow/MapRoomGameStartCustom.java
  25. 36 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/room/flow/MapRoomPlayerCreateCustom.java
  26. 38 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/room/flow/MapRoomRuleInfo.java
  27. 45 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/room/flow/MapRoomRuleInfoCustom.java
  28. 38 0
      logic/map-logic/src/main/java/com/iohao/mmo/map/send/MapSend.java
  29. 2 1
      logic/person-logic/pom.xml
  30. 1 2
      logic/person-logic/src/main/java/com/iohao/mmo/person/PersonLogicServer.java
  31. 1 1
      logic/person-logic/src/main/java/com/iohao/mmo/person/mapper/PersonMapper.java
  32. 1 1
      logic/person-logic/src/test/java/com/iohao/mmo/person/entity/PersonTest.java
  33. 12 0
      one-application/src/main/java/com/iohao/mmo/OneApplication.java
  34. 115 0
      one-application/src/main/resources/logback-spring.xml
  35. 4 0
      one-client/src/main/java/com/iohao/mmo/client/CommonClient.java
  36. 80 77
      pom.xml
  37. 12 0
      provide/all-provide/pom.xml
  38. 31 0
      provide/all-provide/src/main/java/com/iohao/mmo/common/provide/cmd/AllProvideEmpty.java
  39. 1 0
      provide/common-provide/src/main/java/com/iohao/mmo/common/provide/cmd/CmdModule.java
  40. 1 1
      provide/login-provide/src/main/java/com/iohao/mmo/login/client/LoginInputCommandRegion.java
  41. 2 2
      provide/login-provide/src/main/java/com/iohao/mmo/login/proto/UserInfo.java
  42. 38 0
      provide/map-provide/.gitignore
  43. 28 0
      provide/map-provide/pom.xml
  44. 93 0
      provide/map-provide/src/main/java/com/iohao/mmo/map/client/MapInputCommandRegion.java
  45. 38 0
      provide/map-provide/src/main/java/com/iohao/mmo/map/cmd/MapCmd.java
  46. 42 0
      provide/map-provide/src/main/java/com/iohao/mmo/map/proto/EnterMapMessage.java
  47. 38 0
      provide/map-provide/src/main/java/com/iohao/mmo/map/proto/EnterMapReq.java
  48. 48 0
      provide/map-provide/src/main/java/com/iohao/mmo/map/proto/LocationMessage.java
  49. 40 0
      provide/map-provide/src/main/java/com/iohao/mmo/map/proto/MapPlayerMessage.java

+ 46 - 0
common/common-core/src/main/java/com/iohao/mmo/common/config/GameCode.java

@@ -0,0 +1,46 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.common.config;
+
+import com.iohao.game.action.skeleton.core.exception.MsgExceptionInfo;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.experimental.FieldDefaults;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@Getter
+@FieldDefaults(level = AccessLevel.PRIVATE)
+public enum GameCode implements MsgExceptionInfo {
+
+    /** 地图不存在 */
+    MAP_NOT_EXIST(-1, "地图不存在");
+
+    /** 消息码 */
+    final int code;
+    /** 消息模板 */
+    final String msg;
+
+    GameCode(int code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+}

+ 2 - 1
common/common-core/src/main/java/com/iohao/mmo/common/core/flow/MyAttachment.java

@@ -22,7 +22,6 @@ import com.baidu.bjf.remoting.protobuf.annotation.ProtobufClass;
 import com.iohao.game.core.common.client.Attachment;
 import lombok.AccessLevel;
 import lombok.Getter;
-import lombok.Setter;
 import lombok.experimental.FieldDefaults;
 
 /**
@@ -39,4 +38,6 @@ public class MyAttachment implements Attachment {
 
     /** mongoDB 的用户唯一 id */
     String objectId;
+    /** 昵称 */
+    String nickname;
 }

+ 16 - 5
common/common-core/src/main/java/com/iohao/mmo/common/core/flow/MyFlowContext.java

@@ -20,10 +20,6 @@ package com.iohao.mmo.common.core.flow;
 
 import com.iohao.game.action.skeleton.core.flow.FlowContext;
 import com.iohao.game.common.kit.ArrayKit;
-import lombok.AccessLevel;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.experimental.FieldDefaults;
 
 import java.util.Objects;
 
@@ -32,7 +28,7 @@ import java.util.Objects;
  * @date 2023-07-24
  */
 public class MyFlowContext extends FlowContext {
-    public MyAttachment attachment;
+    private MyAttachment attachment;
 
     /**
      * mongoDB 的用户唯一 id
@@ -49,6 +45,21 @@ public class MyFlowContext extends FlowContext {
         return attachment.objectId;
     }
 
+    public String getNickname() {
+        initAttachment();
+
+        if (attachment == null) {
+            return null;
+        }
+
+        return attachment.nickname;
+    }
+
+    public MyAttachment getAttachment() {
+        initAttachment();
+        return attachment;
+    }
+
     private void initAttachment() {
         if (Objects.isNull(attachment)) {
 

+ 23 - 4
common/common-core/src/main/java/com/iohao/mmo/common/logic/server/LogicServerKit.java

@@ -18,9 +18,14 @@
  */
 package com.iohao.mmo.common.logic.server;
 
+import com.iohao.game.action.skeleton.core.BarSkeletonBuilder;
+import com.iohao.game.action.skeleton.core.BarSkeletonBuilderParamConfig;
+import com.iohao.game.action.skeleton.kit.LogicServerCreateKit;
 import com.iohao.game.bolt.broker.core.client.BrokerClient;
 import com.iohao.game.bolt.broker.core.client.BrokerClientBuilder;
 import com.iohao.game.bolt.broker.core.common.processor.hook.ClientProcessorHooks;
+import com.iohao.mmo.common.config.GameCode;
+import com.iohao.mmo.common.core.flow.MyFlowContext;
 import com.iohao.mmo.common.processor.hook.MyRequestMessageClientProcessorHook;
 import lombok.experimental.UtilityClass;
 
@@ -30,10 +35,18 @@ import lombok.experimental.UtilityClass;
  */
 @UtilityClass
 public class LogicServerKit {
-    public ClientProcessorHooks ofClientProcessorHooks() {
-        ClientProcessorHooks hooks = new ClientProcessorHooks();
-        hooks.setRequestMessageClientProcessorHook(new MyRequestMessageClientProcessorHook());
-        return hooks;
+    public BarSkeletonBuilder createBuilder(Class<?> actionControllerClass) {
+        // 业务框架构建器 配置
+        var config = new BarSkeletonBuilderParamConfig()
+                // 扫描 action 类所在包
+                .scanActionPackage(actionControllerClass)
+                // 错误码-用于文档的生成
+                .addErrorCode(GameCode.values());
+
+        BarSkeletonBuilder builder = LogicServerCreateKit.createBuilder(config);
+        // 使用自定义 FlowContext
+        builder.setFlowContextFactory(MyFlowContext::new);
+        return builder;
     }
 
     public BrokerClientBuilder newBrokerClientBuilder() {
@@ -41,4 +54,10 @@ public class LogicServerKit {
         return BrokerClient.newBuilder()
                 .clientProcessorHooks(hooks);
     }
+
+    private ClientProcessorHooks ofClientProcessorHooks() {
+        ClientProcessorHooks hooks = new ClientProcessorHooks();
+        hooks.setRequestMessageClientProcessorHook(new MyRequestMessageClientProcessorHook());
+        return hooks;
+    }
 }

+ 13 - 0
logic/a-logic-common/pom.xml

@@ -27,6 +27,12 @@
             <version>${project.parent.version}</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.iohao.game</groupId>
+            <artifactId>light-domain-event</artifactId>
+            <version>${ioGame.version}</version>
+        </dependency>
+
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-mongodb</artifactId>
@@ -52,5 +58,12 @@
             <version>${javafaker.version}</version>
         </dependency>
 
+        <!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 -->
+        <dependency>
+            <groupId>com.alibaba.fastjson2</groupId>
+            <artifactId>fastjson2</artifactId>
+            <version>${fastjson2.version}</version>
+        </dependency>
+
     </dependencies>
 </project>

+ 1 - 1
logic/a-logic-common/src/main/resources/logback-spring.xml

@@ -99,7 +99,7 @@
     </appender>
 
     <!-- 为某个包下的所有类的指定Appender 这里也可以指定类名称例如:com.aa.bb.ClassName -->
-    <logger name="com.iohao.mmo" additivity="false">
+    <logger name="com.iohao" additivity="false">
         <level value="${log.root.level}"/>
         <appender-ref ref="stdout"/>
         <appender-ref ref="file.async"/><!-- 即com.iohao.game包下级别为 ${log.root.level}的才会使用file.async来打印 -->

+ 8 - 0
logic/all-logic/pom.xml

@@ -31,6 +31,14 @@
             <version>${project.parent.version}</version>
         </dependency>
 
+
+        <dependency>
+            <groupId>com.iohao.mmo</groupId>
+            <artifactId>map-logic</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+
+
     </dependencies>
 
 </project>

+ 31 - 0
logic/all-logic/src/main/java/com/iohao/mmo/common/provide/cmd/AllLogicEmpty.java

@@ -0,0 +1,31 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.common.provide.cmd;
+
+/**
+ * 模块 cmd
+ *
+ * @author 渔民小镇
+ * @date 2023-07-21
+ */
+public interface AllLogicEmpty {
+    int loginCmd = 1;
+    int personCmd = 2;
+    int mapCmd = 3;
+}

+ 2 - 1
logic/login-logic/pom.xml

@@ -19,10 +19,11 @@
     </properties>
 
     <dependencies>
+        <!-- 游戏逻辑服通用模块 -->
         <dependency>
             <groupId>com.iohao.mmo</groupId>
             <artifactId>a-logic-common</artifactId>
-            <version>1.0-SNAPSHOT</version>
+            <version>${project.parent.version}</version>
         </dependency>
 
         <dependency>

+ 1 - 2
logic/login-logic/src/main/java/com/iohao/mmo/login/LoginLogicServer.java

@@ -20,7 +20,6 @@ package com.iohao.mmo.login;
 
 import com.iohao.game.action.skeleton.core.BarSkeleton;
 import com.iohao.game.action.skeleton.core.BarSkeletonBuilder;
-import com.iohao.game.action.skeleton.kit.LogicServerCreateKit;
 import com.iohao.game.bolt.broker.client.AbstractBrokerClientStartup;
 import com.iohao.game.bolt.broker.core.client.BrokerClientBuilder;
 import com.iohao.mmo.common.logic.server.LogicServerKit;
@@ -34,7 +33,7 @@ public class LoginLogicServer extends AbstractBrokerClientStartup {
     @Override
     public BarSkeleton createBarSkeleton() {
         // 业务框架构建器
-        BarSkeletonBuilder builder = LogicServerCreateKit
+        BarSkeletonBuilder builder = LogicServerKit
                 .createBuilder(LoginAction.class);
 
         return builder.build();

+ 20 - 4
logic/login-logic/src/main/java/com/iohao/mmo/login/action/LoginAction.java

@@ -23,8 +23,10 @@ import com.github.javafaker.Name;
 import com.iohao.game.action.skeleton.annotation.ActionController;
 import com.iohao.game.action.skeleton.annotation.ActionMethod;
 import com.iohao.game.action.skeleton.core.flow.FlowContext;
+import com.iohao.game.bolt.broker.client.kit.ExternalCommunicationKit;
 import com.iohao.game.bolt.broker.client.kit.UserIdSettingKit;
 import com.iohao.mmo.common.annotation.IoThread;
+import com.iohao.mmo.common.core.flow.MyAttachment;
 import com.iohao.mmo.login.cmd.LoginCmd;
 import com.iohao.mmo.login.proto.LoginVerify;
 import com.iohao.mmo.login.proto.UserInfo;
@@ -59,10 +61,6 @@ public class LoginAction {
          */
         long userId = Long.parseLong(loginVerify.jwt);
 
-        UserInfo userInfo = new UserInfo();
-        userInfo.id = userId;
-        userInfo.name = name.lastName() + name.firstName();
-
         // channel 中设置用户的真实 userId;
         boolean success = UserIdSettingKit.settingUserId(flowContext, userId);
 
@@ -70,6 +68,24 @@ public class LoginAction {
             log.error("登录失败");
         }
 
+        MyAttachment myAttachment = settingAttachment(userId, flowContext);
+
+        UserInfo userInfo = new UserInfo();
+        userInfo.id = userId;
+        userInfo.nickname = myAttachment.nickname;
+
         return userInfo;
     }
+
+    private MyAttachment settingAttachment(long userId, FlowContext flowContext) {
+        // 创建自定义的元附加信息对象
+        MyAttachment myAttachment = new MyAttachment();
+        myAttachment.userId = userId;
+        myAttachment.nickname = name.lastName() + name.firstName();
+
+        // 设置元信息 ----- 关键代码
+        ExternalCommunicationKit.setAttachment(myAttachment, flowContext);
+
+        return myAttachment;
+    }
 }

+ 38 - 0
logic/map-logic/.gitignore

@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store

+ 43 - 0
logic/map-logic/pom.xml

@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.iohao.mmo</groupId>
+        <artifactId>game</artifactId>
+        <version>1.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>map-logic</artifactId>
+
+    <properties>
+        <maven.compiler.source>17</maven.compiler.source>
+        <maven.compiler.target>17</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <!-- 游戏逻辑服通用模块 -->
+        <dependency>
+            <groupId>com.iohao.mmo</groupId>
+            <artifactId>a-logic-common</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.iohao.mmo</groupId>
+            <artifactId>map-provide</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.iohao.game</groupId>
+            <artifactId>light-game-room</artifactId>
+            <version>${ioGame.version}</version>
+        </dependency>
+
+
+    </dependencies>
+</project>

+ 61 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/MapLogicServer.java

@@ -0,0 +1,61 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map;
+
+import com.iohao.game.action.skeleton.core.BarSkeleton;
+import com.iohao.game.action.skeleton.core.BarSkeletonBuilder;
+import com.iohao.game.action.skeleton.core.doc.ActionSendDoc;
+import com.iohao.game.bolt.broker.client.AbstractBrokerClientStartup;
+import com.iohao.game.bolt.broker.core.client.BrokerClientBuilder;
+import com.iohao.mmo.common.logic.server.LogicServerKit;
+import com.iohao.mmo.map.action.MapAction;
+import com.iohao.mmo.map.cmd.MapCmd;
+import com.iohao.mmo.map.proto.LocationMessage;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+public class MapLogicServer extends AbstractBrokerClientStartup {
+    @Override
+    public BarSkeleton createBarSkeleton() {
+        // 业务框架构建器
+        BarSkeletonBuilder builder = LogicServerKit
+                .createBuilder(MapAction.class);
+
+        extractedSendDco(builder);
+
+        return builder.build();
+    }
+
+    @Override
+    public BrokerClientBuilder createBrokerClientBuilder() {
+        BrokerClientBuilder builder = LogicServerKit.newBrokerClientBuilder();
+        builder.appName("地图逻辑服");
+        return builder;
+    }
+
+    private static void extractedSendDco(BarSkeletonBuilder builder) {
+        ActionSendDoc actionSendDoc;
+        actionSendDoc = new ActionSendDoc(MapCmd.getCmdInfo(MapCmd.move),
+                LocationMessage.class, "玩家移动");
+
+        builder.addActionSendDoc(actionSendDoc);
+    }
+}

+ 134 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/action/MapAction.java

@@ -0,0 +1,134 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.action;
+
+import com.iohao.game.action.skeleton.annotation.ActionController;
+import com.iohao.game.action.skeleton.annotation.ActionMethod;
+import com.iohao.game.action.skeleton.core.exception.ActionErrorEnum;
+import com.iohao.game.action.skeleton.core.flow.FlowContext;
+import com.iohao.game.widget.light.room.RoomService;
+import com.iohao.mmo.common.config.GameCode;
+import com.iohao.mmo.common.core.flow.MyFlowContext;
+import com.iohao.mmo.map.cmd.MapCmd;
+import com.iohao.mmo.map.mapper.MapMapper;
+import com.iohao.mmo.map.proto.EnterMapMessage;
+import com.iohao.mmo.map.proto.EnterMapReq;
+import com.iohao.mmo.map.proto.LocationMessage;
+import com.iohao.mmo.map.room.Location;
+import com.iohao.mmo.map.room.MapPlayer;
+import com.iohao.mmo.map.room.MapRoom;
+import com.iohao.mmo.map.room.MapRoomRegions;
+import com.iohao.mmo.map.room.flow.MapFlow;
+import jakarta.annotation.PostConstruct;
+import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.util.Collection;
+import java.util.Objects;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@Slf4j
+@Component
+@ActionController(MapCmd.cmd)
+public class MapAction {
+
+    @Resource
+    MapRoomRegions mapRoomRegions;
+    RoomService roomService;
+    MapFlow mapFlow;
+
+    @PostConstruct
+    private void init() {
+        this.roomService = mapRoomRegions.getRoomService();
+        this.mapFlow = mapRoomRegions.getMapFlow();
+    }
+
+    /**
+     * 玩家进入地图
+     *
+     * @param enterMapReq 进入地图
+     * @param flowContext flowContext
+     * @return 地图信息
+     */
+    @ActionMethod(MapCmd.enterMap)
+    public EnterMapMessage enterMap(EnterMapReq enterMapReq, MyFlowContext flowContext) {
+        long mapId = enterMapReq.mapId;
+        GameCode.MAP_NOT_EXIST.assertTrueThrows(mapId != 1);
+
+        MapRoom room = roomService.getRoom(mapId);
+        GameCode.MAP_NOT_EXIST.assertNonNull(room);
+
+        long userId = flowContext.getUserId();
+        MapPlayer player = room.getPlayerById(userId);
+
+        if (Objects.isNull(player)) {
+            Location location = new Location();
+            location.setPlayerId(userId);
+
+            String nickname = flowContext.getNickname();
+
+            player = mapFlow.createPlayer();
+            player.setId(userId);
+            player.setNickname(nickname);
+            player.setLocation(location);
+
+            roomService.addPlayer(room, player);
+        }
+
+        EnterMapMessage enterMapMessage = new EnterMapMessage();
+        Collection<MapPlayer> players = room.listPlayer();
+        enterMapMessage.playerList = MapMapper.ME.convertList(players);
+
+        return enterMapMessage;
+    }
+
+    /**
+     * 玩家在地图内移动
+     *
+     * @param locationMessage 玩家位置移动
+     * @param flowContext     flowContext
+     */
+    @ActionMethod(MapCmd.move)
+    public void move(LocationMessage locationMessage, FlowContext flowContext) {
+        /*
+         * 为了方便演示与新手理解,这里暂时做成实时移动。
+         *
+         * 后续版本改为定时更新玩家位置.
+         */
+
+        long userId = flowContext.getUserId();
+        locationMessage.playerId = userId;
+
+        MapRoom room = this.roomService.getRoomByUserId(userId);
+
+        MapPlayer player = room.getPlayerById(userId);
+        ActionErrorEnum.dataNotExist.assertNonNull(player);
+
+        // 更新最后一次移动的位置信息
+        Location location = player.getLocation();
+        MapMapper.ME.to(locationMessage, location);
+
+        // 地图内广播玩家移动
+        room.broadcast(flowContext, locationMessage);
+    }
+}

+ 47 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/mapper/MapMapper.java

@@ -0,0 +1,47 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.mapper;
+
+import com.iohao.mmo.map.proto.LocationMessage;
+import com.iohao.mmo.map.proto.MapPlayerMessage;
+import com.iohao.mmo.map.room.Location;
+import com.iohao.mmo.map.room.MapPlayer;
+import org.mapstruct.Mapper;
+import org.mapstruct.MappingTarget;
+import org.mapstruct.factory.Mappers;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@Mapper
+public interface MapMapper {
+    MapMapper ME = Mappers.getMapper(MapMapper.class);
+
+    void to(LocationMessage locationMessage, @MappingTarget Location location);
+
+    LocationMessage convert(Location location);
+
+    MapPlayerMessage convert(MapPlayer tankPlayerEntity);
+
+    List<MapPlayerMessage> convertList(Collection<MapPlayer> players);
+}

+ 45 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/room/Location.java

@@ -0,0 +1,45 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.room;
+
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.FieldDefaults;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@Getter
+@Setter
+@FieldDefaults(level = AccessLevel.PRIVATE)
+public class Location {
+    /** x 轴 */
+    int x;
+    /** y 轴 */
+    int y;
+
+    /** 方向 H */
+    int directionH;
+    /** 方向 V */
+    int directionV;
+    /** 玩家 id */
+    long playerId;
+}

+ 37 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/room/MapPlayer.java

@@ -0,0 +1,37 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.room;
+
+import com.iohao.game.widget.light.room.AbstractPlayer;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.FieldDefaults;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@Getter
+@Setter
+@FieldDefaults(level = AccessLevel.PRIVATE)
+public class MapPlayer extends AbstractPlayer {
+    String nickname;
+    Location location;
+}

+ 46 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/room/MapRoom.java

@@ -0,0 +1,46 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.room;
+
+import com.iohao.game.action.skeleton.core.flow.FlowContext;
+import com.iohao.game.widget.light.room.AbstractFlowContextSend;
+import com.iohao.game.widget.light.room.AbstractRoom;
+import com.iohao.mmo.map.send.MapSend;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.FieldDefaults;
+
+/**
+ * 地图
+ *
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@Getter
+@Setter
+@FieldDefaults(level = AccessLevel.PRIVATE)
+public class MapRoom extends AbstractRoom {
+
+    @Override
+    @SuppressWarnings("unchecked")
+    protected <T extends AbstractFlowContextSend> T createSend(FlowContext flowContext) {
+        return (T) new MapSend(flowContext);
+    }
+}

+ 73 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/room/MapRoomRegions.java

@@ -0,0 +1,73 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.room;
+
+import com.iohao.game.widget.light.room.AbstractRoom;
+import com.iohao.game.widget.light.room.CreateRoomInfo;
+import com.iohao.game.widget.light.room.RoomService;
+import com.iohao.game.widget.light.room.RuleInfo;
+import com.iohao.mmo.map.room.flow.*;
+import lombok.Getter;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@Component
+public class MapRoomRegions {
+    @Getter
+    MapFlow mapFlow = new MapFlow();
+    @Getter
+    RoomService roomService = new RoomService();
+
+    public MapRoomRegions() {
+        initMapFlow();
+    }
+
+    private void initMapFlow() {
+        mapFlow
+                // 游戏规则
+                .setRoomRuleInfoCustom(new MapRoomRuleInfoCustom())
+                // 游戏开始
+                .setRoomGameStartCustom(new MapRoomGameStartCustom())
+                // 创建玩家
+                .setRoomPlayerCreateCustom(new MapRoomPlayerCreateCustom())
+                // 房间创建
+                .setRoomCreateCustom(new MapRoomCreateCustom())
+                // 进入房间
+                .setRoomEnterCustom(new MapRoomEnterCustom());
+
+        // 创建一个地图
+        long mapId = 1;
+        createMapRoom(mapId);
+    }
+
+    private void createMapRoom(long mapId) {
+        RuleInfo ruleInfo = mapFlow.getRuleInfo(String.valueOf(mapId));
+
+        CreateRoomInfo createRoomInfo = new CreateRoomInfo();
+        createRoomInfo.setRuleInfo(ruleInfo);
+
+        AbstractRoom room = mapFlow.createRoom(createRoomInfo);
+        roomService.addRoom(room);
+    }
+
+
+}

+ 112 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/room/flow/MapFlow.java

@@ -0,0 +1,112 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.room.flow;
+
+import com.iohao.game.action.skeleton.core.exception.MsgException;
+import com.iohao.game.widget.light.room.AbstractPlayer;
+import com.iohao.game.widget.light.room.AbstractRoom;
+import com.iohao.game.widget.light.room.CreateRoomInfo;
+import com.iohao.game.widget.light.room.RuleInfo;
+import com.iohao.game.widget.light.room.flow.*;
+import lombok.AccessLevel;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+import lombok.experimental.FieldDefaults;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@Setter
+@Accessors(chain = true)
+@FieldDefaults(level = AccessLevel.PRIVATE)
+public class MapFlow {
+    /** 游戏规则 */
+    RoomRuleInfoCustom roomRuleInfoCustom;
+    /** 游戏开始 */
+    RoomGameStartCustom roomGameStartCustom;
+    /** 创建玩家 */
+    RoomPlayerCreateCustom roomPlayerCreateCustom;
+    /** 房间创建 */
+    RoomCreateCustom roomCreateCustom;
+    /** 进入房间 */
+    RoomEnterCustom roomEnterCustom;
+
+    /**
+     * 游戏开始
+     *
+     * @param abstractRoom room
+     * @return true 游戏开始
+     */
+    public boolean startGame(AbstractRoom abstractRoom) {
+        boolean startBefore = this.roomGameStartCustom.startBefore(abstractRoom);
+
+        if (startBefore) {
+            this.roomGameStartCustom.startAfter(abstractRoom);
+        }
+
+        return startBefore;
+    }
+
+    /**
+     * 创建房间, 子类只需要关心 ruleInfo (房间配置, 规则信息)
+     * <p>
+     * 根据 创建游戏规则
+     *
+     * @param createRoomInfo 创建房间信息
+     * @param <T>            AbstractRoom
+     * @return 房间
+     */
+    public <T extends AbstractRoom> T createRoom(CreateRoomInfo createRoomInfo) {
+        return this.roomCreateCustom.createRoom(createRoomInfo);
+    }
+
+    /**
+     * 构建房间内的玩家
+     *
+     * @param <T> AbstractPlayer
+     * @return 玩家
+     */
+    public <T extends AbstractPlayer> T createPlayer() {
+        return this.roomPlayerCreateCustom.createPlayer();
+    }
+
+    /**
+     * 进入房间
+     *
+     * @param userId        玩家 id
+     * @param abstractRoom  玩家所在房间
+     * @param roomEnterInfo 进入房间请求信息
+     * @return enter Response
+     */
+    public RoomEnterInfo enterRoom(long userId, AbstractRoom abstractRoom, RoomEnterInfo roomEnterInfo) {
+        return this.roomEnterCustom.enterRoom(userId, abstractRoom, roomEnterInfo);
+    }
+
+    /**
+     * 获取子游戏规则信息
+     *
+     * @param ruleInfoJson 游戏规则 - json
+     * @return 规则信息
+     * @throws MsgException e
+     */
+    public RuleInfo getRuleInfo(String ruleInfoJson) throws MsgException {
+        return this.roomRuleInfoCustom.getRuleInfo(ruleInfoJson);
+    }
+}

+ 41 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/room/flow/MapRoomCreateCustom.java

@@ -0,0 +1,41 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.room.flow;
+
+import com.iohao.game.widget.light.room.AbstractRoom;
+import com.iohao.game.widget.light.room.CreateRoomInfo;
+import com.iohao.game.widget.light.room.flow.RoomCreateCustom;
+import com.iohao.mmo.map.room.MapRoom;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+public class MapRoomCreateCustom implements RoomCreateCustom {
+    @Override
+    @SuppressWarnings("unchecked")
+    public AbstractRoom createRoom(CreateRoomInfo createRoomInfo) {
+        MapRoomRuleInfo ruleInfo = (MapRoomRuleInfo) createRoomInfo.getRuleInfo();
+        long mapId = ruleInfo.getMapId();
+
+        MapRoom room = new MapRoom();
+        room.setRoomId(mapId);
+        return room;
+    }
+}

+ 34 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/room/flow/MapRoomEnterCustom.java

@@ -0,0 +1,34 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.room.flow;
+
+import com.iohao.game.widget.light.room.AbstractRoom;
+import com.iohao.game.widget.light.room.flow.RoomEnterCustom;
+import com.iohao.game.widget.light.room.flow.RoomEnterInfo;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+public class MapRoomEnterCustom implements RoomEnterCustom {
+    @Override
+    public RoomEnterInfo enterRoom(long userId, AbstractRoom abstractRoom, RoomEnterInfo roomEnterInfo) {
+        return null;
+    }
+}

+ 45 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/room/flow/MapRoomGameStartCustom.java

@@ -0,0 +1,45 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.room.flow;
+
+import com.iohao.game.widget.light.room.AbstractRoom;
+import com.iohao.game.widget.light.room.flow.RoomGameStartCustom;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.FieldDefaults;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@Getter
+@Setter
+@FieldDefaults(level = AccessLevel.PRIVATE)
+public class MapRoomGameStartCustom implements RoomGameStartCustom {
+    @Override
+    public boolean startBefore(AbstractRoom abstractRoom) {
+        return false;
+    }
+
+    @Override
+    public void startAfter(AbstractRoom abstractRoom) {
+
+    }
+}

+ 36 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/room/flow/MapRoomPlayerCreateCustom.java

@@ -0,0 +1,36 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.room.flow;
+
+import com.iohao.game.widget.light.room.flow.RoomPlayerCreateCustom;
+import com.iohao.mmo.map.room.MapPlayer;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+public class MapRoomPlayerCreateCustom implements RoomPlayerCreateCustom {
+    @Override
+    @SuppressWarnings("unchecked")
+    public MapPlayer createPlayer() {
+        MapPlayer player = new MapPlayer();
+
+        return player;
+    }
+}

+ 38 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/room/flow/MapRoomRuleInfo.java

@@ -0,0 +1,38 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.room.flow;
+
+import com.iohao.game.widget.light.room.RuleInfo;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.FieldDefaults;
+
+import java.io.Serializable;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@Getter
+@Setter
+@FieldDefaults(level = AccessLevel.PRIVATE)
+public class MapRoomRuleInfo implements RuleInfo, Serializable {
+    long mapId;
+}

+ 45 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/room/flow/MapRoomRuleInfoCustom.java

@@ -0,0 +1,45 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.room.flow;
+
+import com.iohao.game.action.skeleton.core.exception.MsgException;
+import com.iohao.game.widget.light.room.CommonRuleInfo;
+import com.iohao.game.widget.light.room.RuleInfo;
+import com.iohao.game.widget.light.room.flow.RoomRuleInfoCustom;
+
+/**
+ * 地图房间规则
+ *
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+public class MapRoomRuleInfoCustom implements RoomRuleInfoCustom {
+    static final CommonRuleInfo commonRuleInfo = new CommonRuleInfo();
+
+    @Override
+    public RuleInfo getRuleInfo(String ruleInfoJson) throws MsgException {
+        // 暂时简单处理
+        long mapId = Long.parseLong(ruleInfoJson);
+        // 暂时没什么特殊规则,不做 json 解析,使用默认的空规则
+        MapRoomRuleInfo ruleInfo = new MapRoomRuleInfo();
+        ruleInfo.setMapId(mapId);
+
+        return ruleInfo;
+    }
+}

+ 38 - 0
logic/map-logic/src/main/java/com/iohao/mmo/map/send/MapSend.java

@@ -0,0 +1,38 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.send;
+
+import com.iohao.game.action.skeleton.core.flow.FlowContext;
+import com.iohao.game.widget.light.room.AbstractFlowContextSend;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+public class MapSend extends AbstractFlowContextSend {
+
+    public MapSend(FlowContext flowContext) {
+        super(flowContext);
+    }
+
+    @Override
+    public void send() {
+        this.execute();
+    }
+}

+ 2 - 1
logic/person-logic/pom.xml

@@ -19,10 +19,11 @@
     </properties>
 
     <dependencies>
+        <!-- 游戏逻辑服通用模块 -->
         <dependency>
             <groupId>com.iohao.mmo</groupId>
             <artifactId>a-logic-common</artifactId>
-            <version>1.0-SNAPSHOT</version>
+            <version>${project.parent.version}</version>
         </dependency>
 
         <dependency>

+ 1 - 2
logic/person-logic/src/main/java/com/iohao/mmo/person/PersonLogicServer.java

@@ -20,7 +20,6 @@ package com.iohao.mmo.person;
 
 import com.iohao.game.action.skeleton.core.BarSkeleton;
 import com.iohao.game.action.skeleton.core.BarSkeletonBuilder;
-import com.iohao.game.action.skeleton.kit.LogicServerCreateKit;
 import com.iohao.game.bolt.broker.client.AbstractBrokerClientStartup;
 import com.iohao.game.bolt.broker.core.client.BrokerClientBuilder;
 import com.iohao.mmo.common.logic.server.LogicServerKit;
@@ -34,7 +33,7 @@ public class PersonLogicServer extends AbstractBrokerClientStartup {
     @Override
     public BarSkeleton createBarSkeleton() {
         // 业务框架构建器
-        BarSkeletonBuilder builder = LogicServerCreateKit
+        BarSkeletonBuilder builder = LogicServerKit
                 .createBuilder(PersonAction.class);
 
         return builder.build();

+ 1 - 1
logic/person-logic/src/main/java/com/iohao/mmo/person/service/PersonMapper.java → logic/person-logic/src/main/java/com/iohao/mmo/person/mapper/PersonMapper.java

@@ -16,7 +16,7 @@
  * You should have received a copy of the GNU Affero General Public License
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
-package com.iohao.mmo.person.service;
+package com.iohao.mmo.person.mapper;
 
 import com.iohao.mmo.person.entity.BasicsProperty;
 import com.iohao.mmo.person.entity.Person;

+ 1 - 1
logic/person-logic/src/test/java/com/iohao/mmo/person/entity/PersonTest.java

@@ -27,7 +27,7 @@ public class PersonTest {
         Hero firstHero = heroService.getFirstHero();
         log.info("firstHero : {}", firstHero);
     }
-    
+
     @Test
     void testPerson() {
         long userId = 1;

+ 12 - 0
one-application/src/main/java/com/iohao/mmo/OneApplication.java

@@ -18,6 +18,7 @@
  */
 package com.iohao.mmo;
 
+import com.iohao.game.action.skeleton.ext.spring.ActionFactoryBeanForSpring;
 import com.iohao.game.bolt.broker.client.AbstractBrokerClientStartup;
 import com.iohao.game.bolt.broker.server.BrokerServer;
 import com.iohao.game.external.core.ExternalServer;
@@ -26,10 +27,12 @@ import com.iohao.game.external.core.netty.simple.NettyRunOne;
 import com.iohao.mmo.broker.MyBrokerServer;
 import com.iohao.mmo.external.MyExternalServer;
 import com.iohao.mmo.login.LoginLogicServer;
+import com.iohao.mmo.map.MapLogicServer;
 import com.iohao.mmo.person.PersonLogicServer;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
 
 import java.util.List;
 
@@ -67,6 +70,7 @@ public class OneApplication {
     private static List<AbstractBrokerClientStartup> listLogic() {
         LoginLogicServer loginLogicServer = new LoginLogicServer();
         PersonLogicServer personLogicServer = new PersonLogicServer();
+        MapLogicServer mapLogicServer = new MapLogicServer();
 
         // 游戏逻辑服列表
         return List.of(
@@ -74,6 +78,14 @@ public class OneApplication {
                 loginLogicServer
                 // 人物
                 , personLogicServer
+                // 地图
+                , mapLogicServer
         );
     }
+
+    @Bean
+    public ActionFactoryBeanForSpring actionFactoryBean() {
+        // 将业务框架交给 spring 管理
+        return ActionFactoryBeanForSpring.me();
+    }
 }

+ 115 - 0
one-application/src/main/resources/logback-spring.xml

@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true">
+
+    <!-- 日志级别 -->
+    <property name="log.root.level" value="INFO"/>
+    <!-- 其他日志级别 -->
+    <property name="log.other.level" value="DEBUG"/>
+    <!-- 模块名称, 影响日志配置名,日志文件名 -->
+    <property name="log.moduleName" value="game"/>
+    <!--日志文件的保存路径,首先查找系统属性-Dlog.dir,如果存在就使用其;否则,在当前目录下创建名为logs目录做日志存放的目录 -->
+    <property name="log.base" value="${log.dir:-logs}/${log.moduleName}"/>
+    <!-- 日志文件大小,超过这个大小将被压缩 -->
+    <property name="log.max.size" value="100MB"/>
+
+    <!-- 彩色日志 -->
+    <property name="log.pattern"
+              value="%d{HH:mm:ss} %green([%thread]) %highlight(%-5level) %cyan(%logger{50}) %green(\(%file:%line\)) - %msg%n"/>
+
+    <!--控制台输出 -->
+    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
+            <!--            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{50}) - %highlight(%msg) %n</pattern>-->
+            <pattern>${log.pattern}</pattern>
+            <charset>utf8</charset>
+        </encoder>
+    </appender>
+
+    <!-- 用来保存输出所有级别的日志 -->
+    <appender name="file.all" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <File>${log.base}/${log.moduleName}.log</File><!-- 设置日志不超过${log.max.size}时的保存路径,注意如果
+            是web项目会保存到Tomcat的bin目录 下 -->
+        <!-- 滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件。 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <FileNamePattern>${log.base}/archive/${log.moduleName}_all_%d{yyyy-MM-dd}.%i.log.zip</FileNamePattern>
+            <!-- 文件输出日志 (文件大小策略进行文件输出,超过指定大小对文件备份) -->
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>${log.max.size}</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <!-- 日志输出的文件的格式 -->
+        <layout class="ch.qos.logback.classic.PatternLayout">
+            <pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level[%thread]%logger{80}.%method:%L -%msg%n</pattern>
+        </layout>
+    </appender>
+
+    <!-- 这也是用来保存输出所有级别的日志 -->
+    <appender name="file.all.other" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <File>${log.base}/${log.moduleName}_other.log</File>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <FileNamePattern>${log.base}/archive/${log.moduleName}_other_%d{yyyy-MM-dd}.%i.log.zip
+            </FileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>${log.max.size}</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <layout class="ch.qos.logback.classic.PatternLayout">
+            <pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] %logger{56}.%method:%L -%msg%n</pattern>
+        </layout>
+    </appender>
+
+    <!-- 只用保存输出error级别的日志 -->
+    <appender name="file.error" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <File>${log.base}/${log.moduleName}_err.log</File>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <FileNamePattern>${log.base}/archive/${log.moduleName}_err_%d{yyyy-MM-dd}.%i.log.zip
+            </FileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>${log.max.size}</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <layout class="ch.qos.logback.classic.PatternLayout">
+            <pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] %logger{56}.%method:%L - %msg%n</pattern>
+        </layout>
+        <!-- 下面为配置只输出error级别的日志 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>ERROR</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
+    <!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
+    <!-- 添加附加的appender,最多只能添加一个 -->
+    <appender name="file.async" class="ch.qos.logback.classic.AsyncAppender">
+        <discardingThreshold>0</discardingThreshold>
+        <queueSize>256</queueSize>
+        <includeCallerData>true</includeCallerData>
+        <appender-ref ref="file.all"/>
+    </appender>
+
+      <!-- 使用异步来记录其他信息-->
+    <appender name="file.async.other" class="ch.qos.logback.classic.AsyncAppender">
+        <discardingThreshold>0</discardingThreshold>
+        <queueSize>256</queueSize>
+        <includeCallerData>true</includeCallerData>
+        <appender-ref ref="file.all.other"/>
+    </appender>
+
+    <!-- 为某个包下的所有类的指定Appender 这里也可以指定类名称例如:com.aa.bb.ClassName -->
+    <logger name="com.iohao" additivity="false">
+        <level value="${log.root.level}"/>
+        <appender-ref ref="stdout"/>
+        <appender-ref ref="file.async"/><!-- 即com.iohao.game包下级别为 ${log.root.level}的才会使用file.async来打印 -->
+        <appender-ref ref="file.error"/>
+    </logger>
+
+    <!-- root将级别为${log.root.level}及大于${log.root.level}的日志信息交给已经配置好的名为“Console”的appender处理,“Console”appender将信息打印到Console,其它同理 -->
+    <root level="${log.root.level}">
+        <appender-ref ref="stdout"/> <!--  标识这个appender将会添加到这个logger -->
+        <appender-ref ref="file.async.other"/>
+        <appender-ref ref="file.error"/>
+    </root>
+</configuration>

+ 4 - 0
one-client/src/main/java/com/iohao/mmo/client/CommonClient.java

@@ -23,6 +23,7 @@ import com.iohao.game.external.client.join.ClientRunOne;
 import com.iohao.game.external.client.user.ClientUser;
 import com.iohao.game.external.client.user.DefaultClientUser;
 import com.iohao.mmo.login.client.LoginInputCommandRegion;
+import com.iohao.mmo.map.client.MapInputCommandRegion;
 
 import java.util.List;
 
@@ -33,10 +34,13 @@ import java.util.List;
 public class CommonClient {
     private static List<InputCommandRegion> listInputCommandRegion() {
         LoginInputCommandRegion loginInputCommandRegion = new LoginInputCommandRegion();
+        MapInputCommandRegion mapInputCommandRegion = new MapInputCommandRegion();
         // 模拟请求数据
         return List.of(
                 // 登录
                 loginInputCommandRegion
+                // 地图
+                , mapInputCommandRegion
         );
     }
 

+ 80 - 77
pom.xml

@@ -35,6 +35,8 @@
         <module>provide/login-provide</module>
         <module>logic/person-logic</module>
         <module>provide/person-provide</module>
+        <module>logic/map-logic</module>
+        <module>provide/map-provide</module>
 
     </modules>
 
@@ -69,6 +71,7 @@
         <junit.version>4.13.2</junit.version>
         <!-- 演示用的假数据 https://mvnrepository.com/artifact/com.github.javafaker/javafaker -->
         <javafaker.version>1.0.2</javafaker.version>
+        <fastjson2.version>2.0.37</fastjson2.version>
     </properties>
 
     <dependencies>
@@ -78,87 +81,87 @@
             <optional>true</optional>
         </dependency>
     </dependencies>
-<!--    <build>-->
-<!--        <plugins>-->
-<!--            &lt;!&ndash; https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-clean-plugin &ndash;&gt;-->
-<!--            <plugin>-->
-<!--                <groupId>org.apache.maven.plugins</groupId>-->
-<!--                <artifactId>maven-clean-plugin</artifactId>-->
-<!--                <version>3.1.0</version>-->
-<!--            </plugin>-->
+    <build>
+        <plugins>
+            <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-clean-plugin -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-clean-plugin</artifactId>
+                <version>3.1.0</version>
+            </plugin>
 
-<!--            &lt;!&ndash;-->
-<!--            编译插件-->
-<!--            mvn compile-->
-<!--            To compile your test sources, you'll do:-->
-<!--            mvn test-compile-->
-<!--            &ndash;&gt;-->
-<!--            <plugin>-->
-<!--                <groupId>org.apache.maven.plugins</groupId>-->
-<!--                <artifactId>maven-compiler-plugin</artifactId>-->
-<!--                <version>3.8.1</version>-->
-<!--                <configuration>-->
-<!--                    <compilerVersion>${java.version}</compilerVersion>-->
-<!--                    <source>${java.version}</source>-->
-<!--                    <target>${java.version}</target>-->
-<!--                    &lt;!&ndash; maven 3.6.2及之后加上编译参数,可以让我们在运行期获取方法参数名称。 &ndash;&gt;-->
-<!--                    <parameters>true</parameters>-->
-<!--                    <skip>true</skip>-->
-<!--                    &lt;!&ndash; JDK9+ with module-info.java &ndash;&gt;-->
-<!--                    <annotationProcessorPaths>-->
-<!--                        &lt;!&ndash; 实体映射工具 &ndash;&gt;-->
-<!--                        <path>-->
-<!--                            <groupId>org.mapstruct</groupId>-->
-<!--                            <artifactId>mapstruct-processor</artifactId>-->
-<!--                            <version>${org.mapstruct.version}</version>-->
-<!--                        </path>-->
+            <!--
+            编译插件
+            mvn compile
+            To compile your test sources, you'll do:
+            mvn test-compile
+            -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.1</version>
+                <configuration>
+                    <compilerVersion>${java.version}</compilerVersion>
+                    <source>${java.version}</source>
+                    <target>${java.version}</target>
+                    <!-- maven 3.6.2及之后加上编译参数,可以让我们在运行期获取方法参数名称。 -->
+                    <parameters>true</parameters>
+                    <skip>true</skip>
+                    <!-- JDK9+ with module-info.java -->
+                    <annotationProcessorPaths>
+                        <!-- 实体映射工具 -->
+                        <path>
+                            <groupId>org.mapstruct</groupId>
+                            <artifactId>mapstruct-processor</artifactId>
+                            <version>${org.mapstruct.version}</version>
+                        </path>
 
-<!--                        &lt;!&ndash; lombok 消除冗长的 Java 代码 &ndash;&gt;-->
-<!--                        <path>-->
-<!--                            <groupId>org.projectlombok</groupId>-->
-<!--                            <artifactId>lombok</artifactId>-->
-<!--                            <version>${lombok.version}</version>-->
-<!--                        </path>-->
-<!--                        &lt;!&ndash; additional annotation processor required as of Lombok 1.18.16 &ndash;&gt;-->
-<!--                        &lt;!&ndash; mapStruct 支持 lombok &ndash;&gt;-->
-<!--                        <path>-->
-<!--                            <groupId>org.projectlombok</groupId>-->
-<!--                            <artifactId>lombok-mapstruct-binding</artifactId>-->
-<!--                            <version>0.2.0</version>-->
-<!--                        </path>-->
-<!--                    </annotationProcessorPaths>-->
-<!--                </configuration>-->
-<!--            </plugin>-->
+                        <!-- lombok 消除冗长的 Java 代码 -->
+                        <path>
+                            <groupId>org.projectlombok</groupId>
+                            <artifactId>lombok</artifactId>
+                            <version>${lombok.version}</version>
+                        </path>
+                        <!-- additional annotation processor required as of Lombok 1.18.16 -->
+                        <!-- mapStruct 支持 lombok -->
+                        <path>
+                            <groupId>org.projectlombok</groupId>
+                            <artifactId>lombok-mapstruct-binding</artifactId>
+                            <version>0.2.0</version>
+                        </path>
+                    </annotationProcessorPaths>
+                </configuration>
+            </plugin>
 
-<!--            &lt;!&ndash; 打包时跳过单元测试 https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin &ndash;&gt;-->
-<!--            <plugin>-->
-<!--                <groupId>org.apache.maven.plugins</groupId>-->
-<!--                <artifactId>maven-surefire-plugin</artifactId>-->
-<!--                <version>3.0.0-M5</version>-->
-<!--                <configuration>-->
-<!--                    <skipTests>true</skipTests>-->
-<!--                </configuration>-->
-<!--            </plugin>-->
+            <!-- 打包时跳过单元测试 https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>3.0.0-M5</version>
+                <configuration>
+                    <skipTests>true</skipTests>
+                </configuration>
+            </plugin>
 
-<!--            &lt;!&ndash; 打包源码 https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-source-plugin &ndash;&gt;-->
-<!--            <plugin>-->
-<!--                <groupId>org.apache.maven.plugins</groupId>-->
-<!--                <artifactId>maven-source-plugin</artifactId>-->
-<!--                <version>3.2.1</version>-->
-<!--                <configuration>-->
-<!--                    <attach>true</attach>-->
-<!--                </configuration>-->
-<!--                <executions>-->
-<!--                    <execution>-->
-<!--                        <phase>compile</phase>-->
-<!--                        <goals>-->
-<!--                            <goal>jar</goal>-->
-<!--                        </goals>-->
-<!--                    </execution>-->
-<!--                </executions>-->
-<!--            </plugin>-->
+            <!-- 打包源码 https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-source-plugin -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>3.2.1</version>
+                <configuration>
+                    <attach>true</attach>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>compile</phase>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
 
-<!--        </plugins>-->
-<!--    </build>-->
+        </plugins>
+    </build>
 
 </project>

+ 12 - 0
provide/all-provide/pom.xml

@@ -30,6 +30,18 @@
             <artifactId>login-provide</artifactId>
             <version>${project.parent.version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.iohao.mmo</groupId>
+            <artifactId>person-provide</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.iohao.mmo</groupId>
+            <artifactId>map-provide</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
     </dependencies>
 
 </project>

+ 31 - 0
provide/all-provide/src/main/java/com/iohao/mmo/common/provide/cmd/AllProvideEmpty.java

@@ -0,0 +1,31 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.common.provide.cmd;
+
+/**
+ * 模块 cmd
+ *
+ * @author 渔民小镇
+ * @date 2023-07-21
+ */
+public interface AllProvideEmpty {
+    int loginCmd = 1;
+    int personCmd = 2;
+    int mapCmd = 3;
+}

+ 1 - 0
provide/common-provide/src/main/java/com/iohao/mmo/common/provide/cmd/CmdModule.java

@@ -27,4 +27,5 @@ package com.iohao.mmo.common.provide.cmd;
 public interface CmdModule {
     int loginCmd = 1;
     int personCmd = 2;
+    int mapCmd = 3;
 }

+ 1 - 1
provide/login-provide/src/main/java/com/iohao/mmo/login/client/LoginInputCommandRegion.java

@@ -55,7 +55,7 @@ public class LoginInputCommandRegion extends AbstractInputCommandRegion {
             UserInfo userInfo = result.getValue();
             log.info("登录成功 : {}", userInfo);
             clientUser.setUserId(userInfo.id);
-            clientUser.setNickname(userInfo.name);
+            clientUser.setNickname(userInfo.nickname);
         }).setDescription("登录").setInputRequestData(inputRequestData);
 
         InternalKit.newTimeout(task -> {

+ 2 - 2
provide/login-provide/src/main/java/com/iohao/mmo/login/proto/UserInfo.java

@@ -33,6 +33,6 @@ import lombok.experimental.FieldDefaults;
 public class UserInfo {
     /** id */
     long id;
-    /** 用户名 */
-    String name;
+    /** 昵称 */
+    String nickname;
 }

+ 38 - 0
provide/map-provide/.gitignore

@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store

+ 28 - 0
provide/map-provide/pom.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.iohao.mmo</groupId>
+        <artifactId>game</artifactId>
+        <version>1.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>map-provide</artifactId>
+
+    <properties>
+        <maven.compiler.source>17</maven.compiler.source>
+        <maven.compiler.target>17</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.iohao.mmo</groupId>
+            <artifactId>common-provide</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+    </dependencies>
+</project>

+ 93 - 0
provide/map-provide/src/main/java/com/iohao/mmo/map/client/MapInputCommandRegion.java

@@ -0,0 +1,93 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.client;
+
+import com.iohao.game.common.kit.InternalKit;
+import com.iohao.game.external.client.AbstractInputCommandRegion;
+import com.iohao.game.external.client.command.InputRequestData;
+import com.iohao.game.external.client.kit.ScannerKit;
+import com.iohao.mmo.map.cmd.MapCmd;
+import com.iohao.mmo.map.proto.EnterMapMessage;
+import com.iohao.mmo.map.proto.EnterMapReq;
+import com.iohao.mmo.map.proto.LocationMessage;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@Slf4j
+public class MapInputCommandRegion extends AbstractInputCommandRegion {
+    @Override
+    public void initInputCommand() {
+        this.inputCommandCreate.cmd = MapCmd.cmd;
+
+        request();
+        listen();
+
+        InternalKit.newTimeout(task -> {
+            // N 秒后自动进入地图
+            // 请求参数
+            EnterMapReq enterMapReq = new EnterMapReq();
+            // 进入地图,根据地图 id
+            enterMapReq.mapId = 1;
+            ofRequestCommand(MapCmd.enterMap).request(enterMapReq);
+        }, 2, TimeUnit.SECONDS);
+    }
+
+    private void request() {
+        // 动态请求参数
+        InputRequestData inputRequestData = () -> {
+            ScannerKit.log(() -> log.info("请输入需要到达的地图 mapId"));
+            long mapId = ScannerKit.nextLong(1);
+
+            // 请求参数
+            EnterMapReq enterMapReq = new EnterMapReq();
+            // 进入地图,根据地图 id
+            enterMapReq.mapId = mapId;
+
+            return enterMapReq;
+        };
+
+        ofCommand(MapCmd.enterMap).callback(EnterMapMessage.class, result -> {
+            EnterMapMessage userInfo = result.getValue();
+            log.info("enterMapRoom : {}", userInfo);
+        }).setDescription("进入地图").setInputRequestData(inputRequestData);
+
+        // 动态请求参数
+        inputRequestData = () -> {
+            // 请求参数
+            LocationMessage locationMessage = new LocationMessage();
+            locationMessage.x = 100;
+
+            return locationMessage;
+        };
+
+        ofCommand(MapCmd.move).callback(LocationMessage.class, result -> {
+            LocationMessage value = result.getValue();
+            log.info("r玩家移动 : {}", value);
+        }).setDescription("玩家移动").setInputRequestData(inputRequestData);
+    }
+
+    private void listen() {
+
+    }
+}

+ 38 - 0
provide/map-provide/src/main/java/com/iohao/mmo/map/cmd/MapCmd.java

@@ -0,0 +1,38 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.cmd;
+
+import com.iohao.game.action.skeleton.core.CmdInfo;
+import com.iohao.mmo.common.provide.cmd.CmdModule;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+public interface MapCmd {
+    int cmd = CmdModule.mapCmd;
+    /** 进入地图 */
+    int enterMap = 1;
+    /** 移动 */
+    int move = 2;
+
+    static CmdInfo getCmdInfo(int subCmd) {
+        return CmdInfo.getCmdInfo(cmd, subCmd);
+    }
+}

+ 42 - 0
provide/map-provide/src/main/java/com/iohao/mmo/map/proto/EnterMapMessage.java

@@ -0,0 +1,42 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.proto;
+
+import com.baidu.bjf.remoting.protobuf.annotation.ProtobufClass;
+import lombok.AccessLevel;
+import lombok.ToString;
+import lombok.experimental.FieldDefaults;
+
+import java.util.List;
+
+/**
+ * 地图信息
+ *
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@ToString
+@ProtobufClass
+@FieldDefaults(level = AccessLevel.PUBLIC)
+public class EnterMapMessage {
+    /** 地图 id */
+    long mapId;
+    /** 地图上的玩家列表 */
+    List<MapPlayerMessage> playerList;
+}

+ 38 - 0
provide/map-provide/src/main/java/com/iohao/mmo/map/proto/EnterMapReq.java

@@ -0,0 +1,38 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.proto;
+
+import com.baidu.bjf.remoting.protobuf.annotation.ProtobufClass;
+import lombok.AccessLevel;
+import lombok.ToString;
+import lombok.experimental.FieldDefaults;
+
+/**
+ * 进入地图
+ *
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@ToString
+@ProtobufClass
+@FieldDefaults(level = AccessLevel.PUBLIC)
+public class EnterMapReq {
+    /** 地图 id */
+    long mapId;
+}

+ 48 - 0
provide/map-provide/src/main/java/com/iohao/mmo/map/proto/LocationMessage.java

@@ -0,0 +1,48 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.proto;
+
+import com.baidu.bjf.remoting.protobuf.annotation.ProtobufClass;
+import lombok.AccessLevel;
+import lombok.ToString;
+import lombok.experimental.FieldDefaults;
+
+/**
+ * 地图位置相关
+ *
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@ToString
+@ProtobufClass
+@FieldDefaults(level = AccessLevel.PUBLIC)
+public class LocationMessage {
+    /** x 轴 */
+    int x;
+    /** y 轴 */
+    int y;
+
+    /** 方向 H */
+    int directionH;
+    /** 方向 V */
+    int directionV;
+
+    /** 玩家 id */
+    long playerId;
+}

+ 40 - 0
provide/map-provide/src/main/java/com/iohao/mmo/map/proto/MapPlayerMessage.java

@@ -0,0 +1,40 @@
+/*
+ * ioGame
+ * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
+ * # iohao.com . 渔民小镇
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+package com.iohao.mmo.map.proto;
+
+import com.baidu.bjf.remoting.protobuf.annotation.ProtobufClass;
+import lombok.AccessLevel;
+import lombok.ToString;
+import lombok.experimental.FieldDefaults;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-07-27
+ */
+@ToString
+@ProtobufClass
+@FieldDefaults(level = AccessLevel.PUBLIC)
+public class MapPlayerMessage {
+    /** 玩家id */
+    long id;
+    /** nickname */
+    String nickname;
+    /** 所在地图位置 */
+    LocationMessage location;
+}