Browse Source

银月:返回客户端装备简明化

tangbin 1 year ago
parent
commit
311deb38c1

BIN
doc/EquipEntry.xlsx


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

@@ -75,5 +75,11 @@
             <artifactId>fastjson2</artifactId>
             <version>2.0.38</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-text</artifactId>
+            <version>1.8</version>
+        </dependency>
     </dependencies>
 </project>

+ 4 - 3
logic/equip-logic/src/main/java/com/iohao/mmo/equip/action/EquipTemplateAction.java

@@ -9,6 +9,7 @@ import com.iohao.mmo.equip.entity.EquipTemplate;
 import com.iohao.mmo.equip.mapper.EquipMapper;
 import com.iohao.mmo.equip.mapper.EquipTemplateMapper;
 import com.iohao.mmo.equip.proto.EquipMessage;
+import com.iohao.mmo.equip.proto.EquipShowMessage;
 import com.iohao.mmo.equip.proto.EquipTemplateMessage;
 import com.iohao.mmo.equip.service.EquipTemplateService;
 import jakarta.annotation.Resource;
@@ -48,11 +49,11 @@ public class EquipTemplateAction {
      * @param itemTypeIds 装备库itemTypeIds
      */
     @ActionMethod(EquipCmd.randomEquip)
-    public List<EquipMessage> randomEquip(FlowContext flowContext, List<String> itemTypeIds) {
+    public List<EquipShowMessage> randomEquip(FlowContext flowContext, List<String> itemTypeIds) {
         long userId = flowContext.getUserId();
-        List<EquipMessage> equipMessageList = equipTemplateService.randomEquipBatch(itemTypeIds,userId)
+        List<EquipShowMessage> equipMessageList = equipTemplateService.randomEquipBatch(itemTypeIds,userId)
                 .stream()
-                .map(EquipMapper.ME::convert)
+                .map(EquipMapper.ME::convertShowMessage)
                 .toList();;
         return equipMessageList;
     }

+ 1 - 1
logic/equip-logic/src/main/java/com/iohao/mmo/equip/entity/EquipEntryProperty.java

@@ -43,7 +43,7 @@ public class EquipEntryProperty {
     int levelMin;
     /** 等级最大值 */
     int levelMax;
-    /** 属性计算方式(1装备加,2装备增加百分比,3全身增加百分比) */
+    /** 属性计算方式(1装备加,2装备减,3装备增加百分比,4装备减少百分比,5全身增加百分比,6全身减少百分比) */
     int countType;
     /** 显示方式(1原值显示,2小数转百分比) */
     int showType;

+ 57 - 8
logic/equip-logic/src/main/java/com/iohao/mmo/equip/mapper/EquipMapper.java

@@ -18,16 +18,19 @@
  */
 package com.iohao.mmo.equip.mapper;
 
-import com.iohao.mmo.equip.entity.EquipPropertyElse;
-import com.iohao.mmo.equip.entity.Equip;
-import com.iohao.mmo.equip.entity.EquipTemplate;
-import com.iohao.mmo.equip.proto.ElseEquipPropertyMessage;
-import com.iohao.mmo.equip.proto.EquipMessage;
-import com.iohao.mmo.equip.proto.EquipTemplateMessage;
+import com.iohao.game.common.kit.CollKit;
+import com.iohao.mmo.equip.entity.*;
+import com.iohao.mmo.equip.proto.*;
+import org.apache.commons.text.StringSubstitutor;
 import org.mapstruct.Mapper;
 import org.mapstruct.Mapping;
+import org.mapstruct.Named;
 import org.mapstruct.factory.Mappers;
-import java.util.List;
+
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * @author 唐斌
@@ -40,10 +43,56 @@ public interface EquipMapper {
     @Mapping(source = "id", target = "id")
     EquipMessage convert(Equip equip);
 
+    @Mapping(target = "equipPropertyList",
+            expression = "java(convertEquipProperty(equip.getEquipPropertyFixedList(), equip.getEquipPropertyRandomList()))")
+    EquipShowMessage convertShowMessage(Equip equip);
+
     List<EquipMessage> convert(List<Equip> equipList);
 
     Equip convert(EquipMessage equipMessage);
 
     EquipTemplateMessage convert(EquipTemplate equipTemplate);
-    ElseEquipPropertyMessage convert(EquipPropertyElse elseEquipProperty);
+
+    @Named("convertEquipProperty")
+    default List<EquipEntryShowMessage> convertEquipProperty(List<EquipEntry> equipPropertyFixedList,List<EquipEntry> equipPropertyRandomList) {
+        return Stream.of(toEquipEntryMsgList(equipPropertyFixedList),
+                        toEquipEntryMsgList(equipPropertyRandomList))
+                .flatMap(Collection::stream)
+                .collect(Collectors.toList());
+    }
+    private List<EquipEntryShowMessage> toEquipEntryMsgList(List<EquipEntry> equipPropertyList){
+        List<EquipEntryShowMessage> newEquipPropertyList = new ArrayList<>();
+        equipPropertyList.forEach(equipPropertyFixed -> {
+            EquipEntryShowMessage equipEntryShowMessage = new EquipEntryShowMessage();
+            //获取词条描述中的参数
+            Map<String,String> valuesMap = getDescription(equipPropertyFixed.getEntryPropertyList());
+            StringSubstitutor sub = new StringSubstitutor(valuesMap);
+            equipEntryShowMessage.description = "【"+ equipPropertyFixed.getName() +"】" + sub.replace(equipPropertyFixed.getDescription());
+            newEquipPropertyList.add(equipEntryShowMessage);
+        });
+        return newEquipPropertyList;
+    }
+
+    /**
+     * 获取词条描述中的参数
+     * @param entryPropertyList 词条属性列表
+     * @return
+     */
+    private Map<String,String> getDescription(List<EquipEntryProperty> entryPropertyList){
+        Map<String,String> valuesMap = new HashMap<>();
+        for(int i=0;i<entryPropertyList.size();i++){
+            //显示的数值符号
+            String countTypeChar = switch (entryPropertyList.get(i).getCountType()) {
+                case 1, 3, 5 -> "+";
+                case 2, 4, 6 -> "-";
+                default -> "";
+            };
+            //显示的数值
+            String showVal = entryPropertyList.get(i).getShowType()==1?
+                    entryPropertyList.get(i).getPropertyValue().toString():
+                    entryPropertyList.get(i).getPropertyValue().toString()+"%";
+            valuesMap.put("val" + (i+1), countTypeChar + showVal);
+        }
+        return valuesMap;
+    }
 }

+ 1 - 1
one-client/src/main/java/com/iohao/mmo/client/input/EquipInputCommandRegion.java

@@ -136,7 +136,7 @@ public class EquipInputCommandRegion extends AbstractInputCommandRegion {
         };
 
         ofCommand(EquipCmd.randomEquip).callback(ByteValueList.class, result -> {
-            List<EquipMessage> value = result.toList(EquipMessage.class);
+            List<EquipShowMessage> value = result.toList(EquipShowMessage.class);
             log.info("装备列表信息 : {}", JsonKit.toJsonString(value));
         }).setDescription("根据装备库列表批量随机新的装备").setInputRequestData(inputRequestData);
 

+ 1 - 1
provide/equip-provide/src/main/java/com/iohao/mmo/equip/proto/EquipEntryPropertyMessage.java

@@ -39,7 +39,7 @@ public class EquipEntryPropertyMessage {
     int levelMin;
     /** 等级最大值 */
     int levelMax;
-    /** 属性计算方式(1装备加,2装备增加百分比,3全身增加百分比) */
+    /** 属性计算方式(1装备加,2装备减,3装备增加百分比,4装备减少百分比,5全身增加百分比,6全身减少百分比) */
     int countType;
     /** 显示方式(1原值显示,2小数转百分比) */
     int showType;

+ 40 - 0
provide/equip-provide/src/main/java/com/iohao/mmo/equip/proto/EquipEntryShowMessage.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.equip.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-30
+ * @description:
+ */
+@ToString
+@ProtobufClass
+@FieldDefaults(level = AccessLevel.PUBLIC)
+public class EquipEntryShowMessage {
+
+    /** 描述:【名称】说明文字 +x */
+    String description;
+}

+ 57 - 0
provide/equip-provide/src/main/java/com/iohao/mmo/equip/proto/EquipShowMessage.java

@@ -0,0 +1,57 @@
+/*
+ * 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.equip.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-30
+ * @description:
+ */
+@ToString
+@ProtobufClass
+@FieldDefaults(level = AccessLevel.PUBLIC)
+public class EquipShowMessage {
+    /** 装备id */
+    String id;
+    /** 部位(wuqi武器,maozi帽子,yifu衣服,kuzi裤子,xiezi鞋子,huwan护腕,xianglain项链,shouzhuo手镯,jiezhi戒指,yaopei腰佩) */
+    String position;
+    /** 要求等级 */
+    int level;
+    /** 品质 white白色,yellow黄色,green绿色,blue蓝色,red红色,purple紫色,ghost鬼装*/
+    String quality;
+    /** 耐久度 */
+    int durability;
+    /** 当前耐久度 */
+    int nowDurability;
+    /** 基础属性鉴定次数 */
+    int identifyBasicCount;
+    /** 词条属性鉴定次数 */
+    int identifyEntryCount;
+    /** 装备基础属性 */
+    EquipPropertyBasicMessage equipPropertyBasic;
+    /** 装备词条属性 */
+    List<EquipEntryShowMessage> equipPropertyList;
+}