Explorar el Código

:whale: 物品配置

渔民小镇 hace 1 año
padre
commit
2b0da2be97
Se han modificado 24 ficheros con 376 adiciones y 211 borrados
  1. 0 6
      logic/all-logic/pom.xml
  2. 2 2
      logic/bag-logic/src/main/java/com/iohao/mmo/bag/action/BagAction.java
  3. 54 0
      logic/bag-logic/src/main/java/com/iohao/mmo/bag/action/ItemAction.java
  4. 17 0
      logic/bag-logic/src/main/java/com/iohao/mmo/bag/config/ItemCommandLineRunner.java
  5. 7 30
      logic/bag-logic/src/main/java/com/iohao/mmo/bag/mapper/ItemMapper.java
  6. 63 0
      logic/bag-logic/src/main/java/com/iohao/mmo/bag/mapper/UseItemMapper.java
  7. 5 2
      logic/bag-logic/src/main/java/com/iohao/mmo/bag/region/ItemConfigRegion.java
  8. 2 2
      logic/bag-logic/src/main/java/com/iohao/mmo/bag/region/internal/DefaultUseProcess.java
  9. 2 2
      logic/bag-logic/src/main/java/com/iohao/mmo/bag/region/internal/equip/BuildEquipUseProcess.java
  10. 0 38
      logic/item-logic/.gitignore
  11. 0 34
      logic/item-logic/pom.xml
  12. 4 0
      one-client/src/main/java/com/iohao/mmo/client/CommonClient.java
  13. 0 2
      pom.xml
  14. 0 6
      provide/all-provide/pom.xml
  15. 3 3
      provide/bag-provide/src/main/java/com/iohao/mmo/bag/ItemIdConst.java
  16. 20 10
      provide/bag-provide/src/main/java/com/iohao/mmo/bag/client/BagInputCommandRegion.java
  17. 54 0
      provide/bag-provide/src/main/java/com/iohao/mmo/bag/client/ItemInputCommandRegion.java
  18. 30 0
      provide/bag-provide/src/main/java/com/iohao/mmo/bag/client/ext/ClientBagAttr.java
  19. 52 0
      provide/bag-provide/src/main/java/com/iohao/mmo/bag/client/ext/ItemMessageMap.java
  20. 4 9
      provide/bag-provide/src/main/java/com/iohao/mmo/bag/cmd/ItemCmd.java
  21. 42 0
      provide/bag-provide/src/main/java/com/iohao/mmo/bag/proto/ItemMessage.java
  22. 15 0
      provide/common-provide/src/main/java/com/iohao/mmo/common/provide/kit/JsonKit.java
  23. 0 38
      provide/item-provide/.gitignore
  24. 0 27
      provide/item-provide/pom.xml

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

@@ -43,12 +43,6 @@
             <version>${project.parent.version}</version>
         </dependency>
 
-        <dependency>
-            <groupId>com.iohao.mmo</groupId>
-            <artifactId>item-logic</artifactId>
-            <version>${project.parent.version}</version>
-        </dependency>
-
         <dependency>
             <groupId>com.iohao.mmo</groupId>
             <artifactId>bag-logic</artifactId>

+ 2 - 2
logic/bag-logic/src/main/java/com/iohao/mmo/bag/action/BagAction.java

@@ -26,7 +26,7 @@ import com.iohao.mmo.bag.cmd.BagCmd;
 import com.iohao.mmo.bag.entity.Bag;
 import com.iohao.mmo.bag.entity.BagItem;
 import com.iohao.mmo.bag.mapper.BagMapper;
-import com.iohao.mmo.bag.mapper.ItemMapper;
+import com.iohao.mmo.bag.mapper.UseItemMapper;
 import com.iohao.mmo.bag.pojo.UsePOJO;
 import com.iohao.mmo.bag.proto.BagItemMessage;
 import com.iohao.mmo.bag.proto.BagMessage;
@@ -139,7 +139,7 @@ public class BagAction {
          * 如气血药,增加气血值;魔法药,增加魔法值;
          * 攻击符、增加临时攻击力;
          */
-        UsePOJO usePOJO = ItemMapper.ME.convert(useMessage);
+        UsePOJO usePOJO = UseItemMapper.ME.convert(useMessage);
 
         // 使用上下文
         UseContext context = new UseContext();

+ 54 - 0
logic/bag-logic/src/main/java/com/iohao/mmo/bag/action/ItemAction.java

@@ -0,0 +1,54 @@
+/*
+ * 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.bag.action;
+
+import com.iohao.game.action.skeleton.annotation.ActionController;
+import com.iohao.game.action.skeleton.annotation.ActionMethod;
+import com.iohao.mmo.bag.cmd.ItemCmd;
+import com.iohao.mmo.bag.entity.ItemConfig;
+import com.iohao.mmo.bag.mapper.ItemMapper;
+import com.iohao.mmo.bag.proto.ItemMessage;
+import com.iohao.mmo.bag.region.ItemConfigRegion;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 物品配置相关
+ *
+ * @author 渔民小镇
+ * @date 2023-08-13
+ */
+@Slf4j
+@Component
+@ActionController(ItemCmd.cmd)
+public class ItemAction {
+    /**
+     * 物品列表
+     *
+     * @return 物品列表
+     */
+    @ActionMethod(ItemCmd.listItem)
+    public List<ItemMessage> listItem() {
+        Collection<ItemConfig> values = ItemConfigRegion.values();
+        return ItemMapper.ME.convert(values);
+    }
+}

+ 17 - 0
logic/bag-logic/src/main/java/com/iohao/mmo/bag/config/ItemCommandLineRunner.java

@@ -71,6 +71,23 @@ public class ItemCommandLineRunner implements CommandLineRunner {
         config.setName("气血药");
         config.setDescription("增加气血值");
 
+        config = new ItemConfig();
+        configList.add(config);
+        config.setItemId(ItemIdConst.equipWeaponBook10);
+        config.setName("10级-武器书");
+        config.setDescription("装备制造书");
+
+        config = new ItemConfig();
+        configList.add(config);
+        config.setItemId(ItemIdConst.iron10);
+        config.setName("10级-铁");
+        config.setDescription("合成装备的精铁");
+
+        config = new ItemConfig();
+        configList.add(config);
+        config.setItemId(ItemIdConst.equipWeapon10);
+        config.setName("10级-飞龙在天");
+        config.setDescription("赵云的私房枪之一,因害怕被张飞拿错,而一直放在房内!");
         // 临时配置
         return configList;
     }

+ 7 - 30
logic/bag-logic/src/main/java/com/iohao/mmo/bag/mapper/ItemMapper.java

@@ -18,46 +18,23 @@
  */
 package com.iohao.mmo.bag.mapper;
 
-import com.iohao.game.common.kit.CollKit;
-import com.iohao.mmo.bag.entity.BagItem;
-import com.iohao.mmo.bag.pojo.UseItemPOJO;
-import com.iohao.mmo.bag.pojo.UsePOJO;
-import com.iohao.mmo.bag.proto.UseItemMessage;
-import com.iohao.mmo.bag.proto.UseMessage;
+import com.iohao.mmo.bag.entity.ItemConfig;
+import com.iohao.mmo.bag.proto.ItemMessage;
 import org.mapstruct.Mapper;
-import org.mapstruct.Mapping;
 import org.mapstruct.factory.Mappers;
 
-import java.util.*;
+import java.util.Collection;
+import java.util.List;
 
 /**
  * @author 渔民小镇
- * @date 2023-08-06
+ * @date 2023-08-12
  */
 @Mapper
 public interface ItemMapper {
     ItemMapper ME = Mappers.getMapper(ItemMapper.class);
 
-    BagItem convert(UseItemPOJO useItem);
+    ItemMessage convert(ItemConfig itemConfig);
 
-    List<BagItem> convertToBagItem(Collection<UseItemPOJO> useItem);
-
-    @Mapping(target = "useItemMap", source = "useItems")
-    UsePOJO convert(UseMessage useMessage);
-
-    UseItemPOJO convert(UseItemMessage useItemMessage);
-
-    default Map<String, UseItemPOJO> convert(List<UseItemMessage> useItems) {
-        if (CollKit.isEmpty(useItems)) {
-            return Collections.emptyMap();
-        }
-
-        Map<String, UseItemPOJO> map = new HashMap<>();
-        for (UseItemMessage useItem : useItems) {
-            UseItemPOJO convert = convert(useItem);
-            map.put(useItem.itemId, convert);
-        }
-
-        return map;
-    }
+    List<ItemMessage> convert(Collection<ItemConfig> itemConfigs);
 }

+ 63 - 0
logic/bag-logic/src/main/java/com/iohao/mmo/bag/mapper/UseItemMapper.java

@@ -0,0 +1,63 @@
+/*
+ * 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.bag.mapper;
+
+import com.iohao.game.common.kit.CollKit;
+import com.iohao.mmo.bag.entity.BagItem;
+import com.iohao.mmo.bag.pojo.UseItemPOJO;
+import com.iohao.mmo.bag.pojo.UsePOJO;
+import com.iohao.mmo.bag.proto.UseItemMessage;
+import com.iohao.mmo.bag.proto.UseMessage;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.factory.Mappers;
+
+import java.util.*;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-08-06
+ */
+@Mapper
+public interface UseItemMapper {
+    UseItemMapper ME = Mappers.getMapper(UseItemMapper.class);
+
+    BagItem convert(UseItemPOJO useItem);
+
+    List<BagItem> convertToBagItem(Collection<UseItemPOJO> useItem);
+
+    @Mapping(target = "useItemMap", source = "useItems")
+    UsePOJO convert(UseMessage useMessage);
+
+    UseItemPOJO convert(UseItemMessage useItemMessage);
+
+    default Map<String, UseItemPOJO> convert(List<UseItemMessage> useItems) {
+        if (CollKit.isEmpty(useItems)) {
+            return Collections.emptyMap();
+        }
+
+        Map<String, UseItemPOJO> map = new HashMap<>();
+        for (UseItemMessage useItem : useItems) {
+            UseItemPOJO convert = convert(useItem);
+            map.put(useItem.itemId, convert);
+        }
+
+        return map;
+    }
+}

+ 5 - 2
logic/bag-logic/src/main/java/com/iohao/mmo/bag/region/ItemConfigRegion.java

@@ -22,6 +22,7 @@ import com.iohao.mmo.bag.entity.ItemConfig;
 import lombok.NonNull;
 import lombok.experimental.UtilityClass;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -32,7 +33,7 @@ import java.util.Map;
 @UtilityClass
 public class ItemConfigRegion {
 
-    public Map<String, ItemConfig> map = new HashMap<>();
+    private final Map<String, ItemConfig> map = new HashMap<>();
 
     public void addItemConfig(@NonNull ItemConfig itemConfig) {
         map.put(itemConfig.getItemId(), itemConfig);
@@ -46,5 +47,7 @@ public class ItemConfigRegion {
         return map.get(itemId);
     }
 
-
+    public Collection<ItemConfig> values() {
+        return map.values();
+    }
 }

+ 2 - 2
logic/bag-logic/src/main/java/com/iohao/mmo/bag/region/internal/DefaultUseProcess.java

@@ -22,7 +22,7 @@ import com.iohao.game.action.skeleton.core.exception.ActionErrorEnum;
 import com.iohao.game.action.skeleton.core.flow.FlowContext;
 import com.iohao.mmo.bag.ItemIdConst;
 import com.iohao.mmo.bag.entity.BagItem;
-import com.iohao.mmo.bag.mapper.ItemMapper;
+import com.iohao.mmo.bag.mapper.UseItemMapper;
 import com.iohao.mmo.bag.pojo.UseItemPOJO;
 import com.iohao.mmo.bag.pojo.UsePOJO;
 import com.iohao.mmo.bag.region.SceneConst;
@@ -71,7 +71,7 @@ public class DefaultUseProcess implements UseProcess {
         UseItemPOJO useItem = usePOJO.getUseItem();
 
         // 减少物品
-        BagItem bagItem = ItemMapper.ME.convert(useItem);
+        BagItem bagItem = UseItemMapper.ME.convert(useItem);
         bagService.decrementItem(bagItem, userId);
 
         /*

+ 2 - 2
logic/bag-logic/src/main/java/com/iohao/mmo/bag/region/internal/equip/BuildEquipUseProcess.java

@@ -22,7 +22,7 @@ import com.iohao.game.action.skeleton.core.exception.ActionErrorEnum;
 import com.iohao.game.action.skeleton.core.flow.FlowContext;
 import com.iohao.game.common.kit.TimeKit;
 import com.iohao.mmo.bag.entity.BagItem;
-import com.iohao.mmo.bag.mapper.ItemMapper;
+import com.iohao.mmo.bag.mapper.UseItemMapper;
 import com.iohao.mmo.bag.pojo.UseItemPOJO;
 import com.iohao.mmo.bag.pojo.UsePOJO;
 import com.iohao.mmo.bag.region.SceneConst;
@@ -72,7 +72,7 @@ public class BuildEquipUseProcess implements UseProcess {
         buildEquipParse.verify();
 
         // 物品数量检测
-        List<BagItem> bagItems = ItemMapper.ME.convertToBagItem(useItemMap.values());
+        List<BagItem> bagItems = UseItemMapper.ME.convertToBagItem(useItemMap.values());
         boolean contains = bagService.contains(bagItems, userId);
         GameCode.quantityNotEnough.assertTrue(contains);
 

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

@@ -1,38 +0,0 @@
-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

+ 0 - 34
logic/item-logic/pom.xml

@@ -1,34 +0,0 @@
-<?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>item-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>item-provide</artifactId>
-            <version>${project.parent.version}</version>
-        </dependency>
-    </dependencies>
-</project>

+ 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.bag.client.BagInputCommandRegion;
+import com.iohao.mmo.bag.client.ItemInputCommandRegion;
 import com.iohao.mmo.level.client.LevelInputCommandRegion;
 import com.iohao.mmo.login.client.LoginInputCommandRegion;
 import com.iohao.mmo.map.client.MapInputCommandRegion;
@@ -55,6 +56,7 @@ public class CommonClient {
         PersonInputCommandRegion personInputCommandRegion = new PersonInputCommandRegion();
         LevelInputCommandRegion levelInputCommandRegion = new LevelInputCommandRegion();
         BagInputCommandRegion bagInputCommandRegion = new BagInputCommandRegion();
+        ItemInputCommandRegion itemInputCommandRegion = new ItemInputCommandRegion();
 
         // 模拟请求数据
         return List.of(
@@ -66,6 +68,8 @@ public class CommonClient {
 //                , personInputCommandRegion
                 // 等级相关
                 , levelInputCommandRegion
+                // 物品
+                , itemInputCommandRegion
                 // 背包
                 , bagInputCommandRegion
         );

+ 0 - 2
pom.xml

@@ -39,8 +39,6 @@
         <module>provide/map-provide</module>
         <module>logic/level-logic</module>
         <module>provide/level-provide</module>
-        <module>logic/item-logic</module>
-        <module>provide/item-provide</module>
         <module>logic/bag-logic</module>
         <module>provide/bag-provide</module>
 

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

@@ -49,12 +49,6 @@
             <version>${project.parent.version}</version>
         </dependency>
 
-        <dependency>
-            <groupId>com.iohao.mmo</groupId>
-            <artifactId>item-provide</artifactId>
-            <version>${project.parent.version}</version>
-        </dependency>
-
         <dependency>
             <groupId>com.iohao.mmo</groupId>
             <artifactId>bag-provide</artifactId>

+ 3 - 3
provide/bag-provide/src/main/java/com/iohao/mmo/bag/ItemIdConst.java

@@ -28,10 +28,10 @@ public interface ItemIdConst {
     String expId = "exp";
     String hpId = "hp";
     /** 装备 - 武器书 - 10 级 */
-    String equipWeaponBook_10 = ItemIdTypeConst.equip + "_weapon_book_10";
+    String equipWeaponBook10 = ItemIdTypeConst.equip + "_weapon_book_10";
     /** 铁 - 10 级 */
-    String iron_10 = ItemIdTypeConst.iron + "_10";
+    String iron10 = ItemIdTypeConst.iron + "_10";
     /** 装备 - 武器 - 10 级 */
-    String equipWeapon_10 = ItemIdTypeConst.equip + "_weapon_10";
+    String equipWeapon10 = ItemIdTypeConst.equip + "_weapon_10";
 
 }

+ 20 - 10
provide/bag-provide/src/main/java/com/iohao/mmo/bag/client/BagInputCommandRegion.java

@@ -18,17 +18,17 @@
  */
 package com.iohao.mmo.bag.client;
 
+import com.alibaba.fastjson2.JSONObject;
 import com.iohao.game.action.skeleton.protocol.wrapper.BoolValue;
 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.game.external.client.kit.SplitParam;
 import com.iohao.mmo.bag.ItemIdConst;
+import com.iohao.mmo.bag.client.ext.ClientBagAttr;
+import com.iohao.mmo.bag.client.ext.ItemMessageMap;
 import com.iohao.mmo.bag.cmd.BagCmd;
-import com.iohao.mmo.bag.proto.BagItemMessage;
-import com.iohao.mmo.bag.proto.BagMessage;
-import com.iohao.mmo.bag.proto.UseItemMessage;
-import com.iohao.mmo.bag.proto.UseMessage;
+import com.iohao.mmo.bag.proto.*;
 import com.iohao.mmo.common.provide.kit.JsonKit;
 import com.iohao.mmo.common.snow.SnowKit;
 import lombok.extern.slf4j.Slf4j;
@@ -57,13 +57,13 @@ public class BagInputCommandRegion extends AbstractInputCommandRegion {
         ofRequestCommand(BagCmd.incrementItem).request(bagItemMessage);
 
         // 添加一些装备制造书材料
-        bagItemMessage = BagInternalHelper.ofBagItemMessage(ItemIdConst.equipWeaponBook_10);
+        bagItemMessage = BagInternalHelper.ofBagItemMessage(ItemIdConst.equipWeaponBook10);
         bagItemMessage.quantity = 1;
         log.info("添加 {} 【装备-武器】制造书材料 {}", bagItemMessage.quantity, bagItemMessage);
         ofRequestCommand(BagCmd.incrementItem).request(bagItemMessage);
 
         // 添加一些装备制造书材料
-        bagItemMessage = BagInternalHelper.ofBagItemMessage(ItemIdConst.iron_10);
+        bagItemMessage = BagInternalHelper.ofBagItemMessage(ItemIdConst.iron10);
         bagItemMessage.quantity = 1;
         log.info("添加 {} 装备-制造材料-铁 {}", bagItemMessage.quantity, bagItemMessage);
         ofRequestCommand(BagCmd.incrementItem).request(bagItemMessage);
@@ -71,8 +71,18 @@ public class BagInputCommandRegion extends AbstractInputCommandRegion {
 
     private void request() {
         ofCommand(BagCmd.bag).callback(BagMessage.class, result -> {
+            ItemMessageMap itemMessageMap = clientUser.option(ClientBagAttr.itemMessageMapAttrOption);
+
             BagMessage value = result.getValue();
-            log.info("{}", JsonKit.toJsonString(value));
+
+            List<JSONObject> list = value.itemMap.values().stream().map(bagItemMessage -> {
+                String itemId = bagItemMessage.itemId;
+                JSONObject bagItemMessageJson = JSONObject.from(bagItemMessage);
+                JSONObject itemMessageJson = itemMessageMap.getItemMessageJSON(itemId);
+                return JsonKit.merge(bagItemMessageJson, itemMessageJson);
+            }).toList();
+
+            log.info("查询玩家背包 {}", JsonKit.toJsonString(list));
         }).setDescription("查询玩家背包");
 
         InputRequestData inputRequestData = () -> {
@@ -161,15 +171,15 @@ public class BagInputCommandRegion extends AbstractInputCommandRegion {
             log.info("格式 [制造书物品id-制造铁物品id]");
         });
 
-        String defaultValue = ItemIdConst.equipWeaponBook_10 + "-" + ItemIdConst.iron_10;
+        String defaultValue = ItemIdConst.equipWeaponBook10 + "-" + ItemIdConst.iron10;
         String inputType = defaultValue;
 //         inputType = ScannerKit.nextLine(defaultValue);
         SplitParam param = new SplitParam(inputType);
 
-        String equipWeaponBook = param.getString(0, ItemIdConst.equipWeaponBook_10);
+        String equipWeaponBook = param.getString(0, ItemIdConst.equipWeaponBook10);
         UseItemMessage useItemMessageEquip = BagInternalHelper.ofUseItemMessage(equipWeaponBook);
 
-        String iron = param.getString(1, ItemIdConst.iron_10);
+        String iron = param.getString(1, ItemIdConst.iron10);
         UseItemMessage useItemMessageIron = BagInternalHelper.ofUseItemMessage(iron);
 
         return List.of(useItemMessageEquip, useItemMessageIron);

+ 54 - 0
provide/bag-provide/src/main/java/com/iohao/mmo/bag/client/ItemInputCommandRegion.java

@@ -0,0 +1,54 @@
+/*
+ * 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.bag.client;
+
+import com.iohao.game.action.skeleton.protocol.wrapper.ByteValueList;
+import com.iohao.game.common.kit.attr.AttrOption;
+import com.iohao.game.external.client.AbstractInputCommandRegion;
+import com.iohao.mmo.bag.client.ext.ClientBagAttr;
+import com.iohao.mmo.bag.client.ext.ItemMessageMap;
+import com.iohao.mmo.bag.cmd.ItemCmd;
+import com.iohao.mmo.bag.proto.ItemMessage;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.List;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-08-13
+ */
+@Slf4j
+public class ItemInputCommandRegion extends AbstractInputCommandRegion {
+    @Override
+    public void initInputCommand() {
+        this.inputCommandCreate.cmd = ItemCmd.cmd;
+
+        ofCommand(ItemCmd.listItem).callback(ByteValueList.class, result -> {
+            List<ItemMessage> list = result.toList(ItemMessage.class);
+            AttrOption<ItemMessageMap> itemMessageMapAttrOption = ClientBagAttr.itemMessageMapAttrOption;
+            ItemMessageMap itemMessageMap = new ItemMessageMap(list);
+            clientUser.option(itemMessageMapAttrOption, itemMessageMap);
+        }).setDescription("物品配置列表");
+    }
+
+    @Override
+    public void loginSuccessCallback() {
+        ofRequestCommand(ItemCmd.listItem).request();
+    }
+}

+ 30 - 0
provide/bag-provide/src/main/java/com/iohao/mmo/bag/client/ext/ClientBagAttr.java

@@ -0,0 +1,30 @@
+/*
+ * 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.bag.client.ext;
+
+import com.iohao.game.common.kit.attr.AttrOption;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-08-13
+ */
+public interface ClientBagAttr {
+    AttrOption<ItemMessageMap> itemMessageMapAttrOption = AttrOption.valueOf("itemMessageMapAttrOption");
+
+}

+ 52 - 0
provide/bag-provide/src/main/java/com/iohao/mmo/bag/client/ext/ItemMessageMap.java

@@ -0,0 +1,52 @@
+/*
+ * 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.bag.client.ext;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.iohao.mmo.bag.proto.ItemMessage;
+import lombok.AccessLevel;
+import lombok.ToString;
+import lombok.experimental.FieldDefaults;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author 渔民小镇
+ * @date 2023-08-13
+ */
+@ToString
+@FieldDefaults(level = AccessLevel.PUBLIC)
+public class ItemMessageMap {
+    final Map<String, ItemMessage> map = new HashMap<>();
+
+    public ItemMessageMap(List<ItemMessage> itemMessageList) {
+        itemMessageList.forEach(itemMessage -> map.put(itemMessage.itemId, itemMessage));
+    }
+
+    public ItemMessage getItemMessage(String itemId) {
+        return map.get(itemId);
+    }
+
+    public JSONObject getItemMessageJSON(String itemId) {
+        ItemMessage itemMessage = getItemMessage(itemId);
+        return JSONObject.from(itemMessage);
+    }
+}

+ 4 - 9
provide/item-provide/src/main/java/com/iohao/mmo/item/cmd/ItemCmd.java → provide/bag-provide/src/main/java/com/iohao/mmo/bag/cmd/ItemCmd.java

@@ -16,21 +16,16 @@
  * 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.item.cmd;
+package com.iohao.mmo.bag.cmd;
 
-import com.iohao.game.action.skeleton.core.CmdInfo;
 import com.iohao.mmo.common.provide.cmd.CmdModule;
 
 /**
  * @author 渔民小镇
- * @date 2023-08-04
+ * @date 2023-08-12
  */
 public interface ItemCmd {
     int cmd = CmdModule.itemCmd;
-    /** 使用物品 */
-    int use = 1;
-
-    static CmdInfo of(int subCmd) {
-        return CmdInfo.of(cmd, subCmd);
-    }
+    /** 物品配置列表 */
+    int listItem = 1;
 }

+ 42 - 0
provide/bag-provide/src/main/java/com/iohao/mmo/bag/proto/ItemMessage.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.bag.proto;
+
+import com.baidu.bjf.remoting.protobuf.annotation.ProtobufClass;
+import lombok.AccessLevel;
+import lombok.ToString;
+import lombok.experimental.FieldDefaults;
+
+/**
+ * 物品信息
+ *
+ * @author 渔民小镇
+ * @date 2023-08-13
+ */
+@ToString
+@ProtobufClass
+@FieldDefaults(level = AccessLevel.PUBLIC)
+public class ItemMessage {
+    /** itemId */
+    String itemId;
+    /** 物品名 */
+    String name;
+    /** 物品描述 */
+    String description;
+}

+ 15 - 0
provide/common-provide/src/main/java/com/iohao/mmo/common/provide/kit/JsonKit.java

@@ -19,9 +19,12 @@
 package com.iohao.mmo.common.provide.kit;
 
 import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONWriter;
 import lombok.experimental.UtilityClass;
 
+import java.util.Objects;
+
 /**
  * @author 渔民小镇
  * @date 2023-08-01
@@ -37,4 +40,16 @@ public class JsonKit {
     public String toJsonString(Object value) {
         return JSON.toJSONString(value, JSONWriter.Feature.PrettyFormat);
     }
+
+    public JSONObject merge(JSONObject... jsonObjects) {
+        JSONObject json = new JSONObject();
+
+        for (JSONObject jsonObject : jsonObjects) {
+            if (Objects.nonNull(jsonObject)) {
+                json.putAll(jsonObject);
+            }
+        }
+
+        return json;
+    }
 }

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

@@ -1,38 +0,0 @@
-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

+ 0 - 27
provide/item-provide/pom.xml

@@ -1,27 +0,0 @@
-<?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>item-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>