Browse Source

装备优化半成品

tangbin 1 year ago
parent
commit
158b53363c

+ 43 - 0
logic/equip-logic/src/main/java/com/iohao/mmo/equip/action/DictionaryAction.java

@@ -0,0 +1,43 @@
+package com.iohao.mmo.equip.action;
+
+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.action.skeleton.protocol.wrapper.StringValue;
+import com.iohao.mmo.equip.cmd.EquipCmd;
+import com.iohao.mmo.equip.entity.Dictionary;
+import com.iohao.mmo.equip.entity.Equip;
+import com.iohao.mmo.equip.mapper.EquipMapper;
+import com.iohao.mmo.equip.proto.DictionaryMessage;
+import com.iohao.mmo.equip.proto.EquipMessage;
+import com.iohao.mmo.equip.service.DictionaryService;
+import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author 唐斌
+ * @date 2023-07-30
+ * @description: 装备属性类
+ */
+@Slf4j
+@Component
+@ActionController(EquipCmd.cmd)
+public class DictionaryAction {
+
+    @Resource
+    DictionaryService dictionaryService;
+
+    /**
+     * 更新字典
+     *
+     * @param flowContext flowContext
+     */
+    @ActionMethod(EquipCmd.initEquip)
+    public void internalInitEquip(FlowContext flowContext, DictionaryMessage dictionaryMessage) {
+        long userId = flowContext.getUserId();
+        // 初始化装备数据,暂时放这
+//        equipService.initEquipData();
+    }
+
+}

+ 0 - 1
logic/equip-logic/src/main/java/com/iohao/mmo/equip/action/EquipAction.java

@@ -8,7 +8,6 @@ import com.iohao.mmo.equip.cmd.EquipCmd;
 import com.iohao.mmo.equip.entity.Equip;
 import com.iohao.mmo.equip.mapper.EquipMapper;
 import com.iohao.mmo.equip.proto.EquipMessage;
-import com.iohao.mmo.equip.proto.OfEquipReq;
 import com.iohao.mmo.equip.service.EquipService;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;

+ 44 - 0
logic/equip-logic/src/main/java/com/iohao/mmo/equip/entity/DictData.java

@@ -0,0 +1,44 @@
+/*
+ * 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.entity;
+
+import lombok.AccessLevel;
+import lombok.Data;
+import lombok.experimental.FieldDefaults;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+/**
+ * 数据字典值
+ * @author 唐斌
+ * @date 2023-07-26
+ */
+@Data
+@Document
+@FieldDefaults(level = AccessLevel.PRIVATE)
+public class DictData {
+    /** 字典标签 */
+    String dictLabel;
+    /** 字典值 */
+    String dictValue;
+    /** 备注 */
+    String remark;
+    /** 排序 */
+    int sort;
+}

+ 46 - 0
logic/equip-logic/src/main/java/com/iohao/mmo/equip/entity/Dictionary.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.equip.entity;
+
+import lombok.AccessLevel;
+import lombok.Data;
+import lombok.experimental.FieldDefaults;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.util.List;
+
+/**
+ * 数据字典
+ * @author 唐斌
+ * @date 2023-07-26
+ */
+@Data
+@Document
+@FieldDefaults(level = AccessLevel.PRIVATE)
+public class Dictionary {
+    @Id
+    String id;
+    /** 字典类型 */
+    String dictType;
+    /** 字典名称 */
+    String dictName;
+    /** 字典值 */
+    List<DictData> dictDataList;
+}

+ 43 - 0
logic/equip-logic/src/main/java/com/iohao/mmo/equip/entity/EquipRandomRule.java

@@ -0,0 +1,43 @@
+/*
+ * 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.entity;
+
+import lombok.AccessLevel;
+import lombok.Data;
+import lombok.experimental.FieldDefaults;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+/**
+ * @author 唐斌
+ * @date 2023-07-26
+ */
+@Data
+@Document
+@FieldDefaults(level = AccessLevel.PRIVATE)
+public class EquipRandomRule {
+    /** 装备品质序号 */
+    int qualitySort;
+    /** 装备品质名称 */
+    int qualityName;
+    /** 自定义属性随机范围最小值:(随机值-最小范围)/(最大范围-最小范围) */
+    double min;
+    /** 自定义属性随机范围最大值:(随机值-最小范围)/(最大范围-最小范围) */
+    double max;
+}

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

@@ -29,7 +29,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
  * @date 2023-07-26
  */
 @Data
-@Document(collection = "equipTemplate")
+@Document
 @FieldDefaults(level = AccessLevel.PRIVATE)
 public class EquipTemplate {
     @Id

+ 64 - 0
logic/equip-logic/src/main/java/com/iohao/mmo/equip/service/DictionaryService.java

@@ -0,0 +1,64 @@
+/*
+ * 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.service;
+
+import com.iohao.mmo.equip.entity.BasicEquipProperty;
+import com.iohao.mmo.equip.entity.Dictionary;
+import com.iohao.mmo.equip.entity.Equip;
+import com.iohao.mmo.equip.repository.EquipRepository;
+import lombok.AllArgsConstructor;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.data.mongodb.core.query.Update;
+import org.springframework.data.mongodb.core.query.UpdateDefinition;
+import org.springframework.stereotype.Service;
+
+import java.util.Optional;
+
+/**
+ * @author 唐斌
+ * @date 2023-07-30
+ * @description: 装备属性实现类
+ */
+@Service
+@AllArgsConstructor
+public class DictionaryService {
+    final MongoTemplate mongoTemplate;
+    final EquipRepository equipRepository;
+
+    public Equip ofEquip(String id) {
+
+        return  mongoTemplate.findById(id, Equip.class);
+    }
+
+    public void upsert(Dictionary dictionary) {
+
+        // 查询条件,如果数据存在更新
+        Query query = new Query();
+        query.addCriteria(Criteria.where("dictType").is(dictionary.getDictType()));
+
+        // 更新的字段
+        Update update = new Update();
+        update.set("dictName", dictionary.getDictName());
+        update.set("dictDataList", dictionary.getDictDataList());
+        mongoTemplate.upsert(query,update,Dictionary.class);
+    }
+
+}

+ 2 - 0
logic/equip-logic/src/main/java/com/iohao/mmo/equip/service/EquipTemplateService.java

@@ -95,9 +95,11 @@ public class EquipTemplateService {
             //随机出的总属性值
             equip.setAttrTotal(RandomUtils.randomFromInt(equipTemplate.getTotalAttrMin(),equipTemplate.getTotalAttrMax()));
             equip.setQuality(EquipUtils.getEquipQuality(equipTemplate.getTotalAttrMin(),equipTemplate.getTotalAttrMax(),equip.getAttrTotal()));
+            equip.setName(equipTemplate.getGoods().getName());
         }else {
             equip.setAttrTotal(0);
             equip.setQuality(1);
+            equip.setName("未知名称");
         }
         equip.setUndistributedAttr(equip.getAttrTotal());
         equip.setEquipTemplate(equipTemplate);

+ 44 - 0
provide/equip-provide/src/main/java/com/iohao/mmo/equip/proto/DictDataMessage.java

@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+/**
+ * 字典值
+ *
+ * @author 唐斌
+ * @date 2023-07-31
+ */
+@ToString
+@ProtobufClass
+@FieldDefaults(level = AccessLevel.PUBLIC)
+public class DictDataMessage {
+    /** 字典标签 */
+    String dictLabel;
+    /** 字典值 */
+    String dictValue;
+    /** 备注 */
+    String remark;
+    /** 排序 */
+    int sort;
+}

+ 46 - 0
provide/equip-provide/src/main/java/com/iohao/mmo/equip/proto/DictionaryMessage.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.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-31
+ */
+@ToString
+@ProtobufClass
+@FieldDefaults(level = AccessLevel.PUBLIC)
+public class DictionaryMessage {
+    /** 装备 id */
+    String id;
+    /** 字典类型 */
+    String dictType;
+    /** 字典名称 */
+    String dictName;
+    /** 字典值 */
+    List<DictDataMessage> dictDataList;
+}