Просмотр исходного кода

删除装备里面用于测试自建的物品类

toby 1 год назад
Родитель
Сommit
793bda71b8

+ 1 - 2
logic/equip-logic/src/main/java/com/iohao/mmo/equip/action/EquipTemplateAction.java

@@ -56,8 +56,7 @@ public class EquipTemplateAction {
     }
 
     /**
-     * TODO 根据装备库列表随机出新的装备,
-     * 实际这里应该传入怪物id,根据怪物-物品-掉率的绑定关系去随机出掉落物品,暂时还没有怪物,先这样处理
+     * 根据装备库列表随机出新的装备,
      *
      * @param flowContext flowContext
      * @param stringValve 装备库itemIds(xxx-xxx)

+ 0 - 2
logic/equip-logic/src/main/java/com/iohao/mmo/equip/entity/Equip.java

@@ -46,8 +46,6 @@ public class Equip {
     int attrTotal;
     /** 未分配属性点 */
     int undistributedAttr;
-    /** 所属物品 */
-    Goods goods;
     /** 部位(0帽子,1衣服,2武器,3手镯,4裤子,5鞋子) */
     int position;
     /** 要求等级 */

+ 3 - 3
logic/equip-logic/src/main/java/com/iohao/mmo/equip/entity/GoodsGarbage.java → logic/equip-logic/src/main/java/com/iohao/mmo/equip/entity/EquipGarbage.java

@@ -14,17 +14,17 @@ import org.springframework.data.mongodb.core.mapping.Document;
 @Data
 @Document
 @FieldDefaults(level = AccessLevel.PRIVATE)
-public class GoodsGarbage {
+public class EquipGarbage {
     private String id;
     private String type;
     private Object data;
     @Indexed
     private String collectedTime;
 
-    public GoodsGarbage() {
+    public EquipGarbage() {
     }
 
-    public GoodsGarbage(String id, String type, Object data, String collectedTime) {
+    public EquipGarbage(String id, String type, Object data, String collectedTime) {
         this.id = id;
         this.type = type;
         this.data = data;

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

@@ -36,8 +36,6 @@ public class EquipTemplate {
     String id;
     /** 物品id */
     String itemId;
-    /** 所属物品 */
-    Goods goods;
     /** 部位(0帽子,1衣服,2武器,3手镯,4裤子,5鞋子) */
     int position;
     /** 要求等级 */

+ 0 - 53
logic/equip-logic/src/main/java/com/iohao/mmo/equip/entity/Goods.java

@@ -1,53 +0,0 @@
-/*
- * 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 Goods {
-    @Id
-    String id;
-    /** 物品名称 */
-    String name;
-    /** 物品描述 */
-    String desc;
-    /** 图标 */
-    String icon;
-    /** 大图 */
-    String image;
-    /** 绑定货币价格 */
-    int bindPrice;
-    /** 非绑定货币价格 */
-    int price;
-    /** 是否可交易 */
-    boolean dealFlag;
-    /** 物品类型:0装备,1药品,2材料,3装备库 */
-    int type;
-}

+ 0 - 57
logic/equip-logic/src/main/java/com/iohao/mmo/equip/enums/EquipQualityEnum.java

@@ -1,57 +0,0 @@
-package com.iohao.mmo.equip.enums;
-
-/**
- * @author 唐斌
- * @date 2023-08-03
- * @description: TODO
- */
-public enum EquipQualityEnum {
-    WHITE(0.1, 1),
-    GREEN(0.3, 2),
-    BLUE(0.5, 3),
-    RED(0.7, 4),
-    PURPLE(0.95, 5),
-    GOLDEN(1.0, 6);
-    // 属性比例
-    private double prop;
-    //装备品质
-    private int quality;
-    // 构造方法
-    private EquipQualityEnum(double prop, int quality) {
-        this.prop = prop;
-        this.quality = quality;
-    }
-    // 通过品质数字拿属性比例
-    public static double getProp(int quality) {
-        for (EquipQualityEnum c : EquipQualityEnum.values()) {
-            if (c.getQuality() == quality) {
-                return c.prop;
-            }
-        }
-        return 0;
-    }
-
-    // 通过属性比例拿品质等级
-    public static int getQuality(double prop) {
-        for (EquipQualityEnum c : EquipQualityEnum.values()) {
-            if (c.getProp() >= prop) {
-                return c.quality;
-            }
-        }
-        return 1;
-    }
-    // get set 方法
-    public double getProp() {
-        return prop;
-    }
-    public void setProp(double prop) {
-        this.prop = prop;
-    }
-    public int getQuality() {
-        return quality;
-    }
-    public void setQuality(int quality) {
-        this.quality = quality;
-    }
-
-}

+ 4 - 4
logic/equip-logic/src/main/java/com/iohao/mmo/equip/listener/EquipEventListener.java

@@ -1,6 +1,6 @@
 package com.iohao.mmo.equip.listener;
 
-import com.iohao.mmo.equip.entity.GoodsGarbage;
+import com.iohao.mmo.equip.entity.EquipGarbage;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener;
@@ -32,7 +32,7 @@ public class EquipEventListener extends AbstractMongoEventListener<Object> {
 
     @Override
     public void onBeforeDelete(BeforeDeleteEvent<Object> event) {
-        Set<String> setString = Stream.of("goods","equip", "equipTemplate")
+        Set<String> setString = Stream.of("equip", "equipTemplate")
                 .collect(Collectors.toUnmodifiableSet());
         if (event.getType() == null || CollectionUtils.isEmpty(event.getDocument())
                 || StringUtils.isBlank(event.getCollectionName()) || !setString.contains(event.getCollectionName())) {
@@ -44,8 +44,8 @@ public class EquipEventListener extends AbstractMongoEventListener<Object> {
             // 在数据删除前,将所有数据迁移至`garbage`集合中
             String type = event.getCollectionName();
             String nowStr = LocalDateTime.now().format(dfDateTime);
-            List<GoodsGarbage> equipGarbageList = objects.stream()
-                    .map(o -> new GoodsGarbage(null, type, o, nowStr))
+            List<EquipGarbage> equipGarbageList = objects.stream()
+                    .map(o -> new EquipGarbage(null, type, o, nowStr))
                     .collect(Collectors.toList());
             mongoTemplate.insertAll(equipGarbageList);
         }

+ 1 - 4
logic/equip-logic/src/main/java/com/iohao/mmo/equip/service/EquipService.java

@@ -21,7 +21,6 @@ package com.iohao.mmo.equip.service;
 import com.iohao.mmo.common.config.GameCode;
 import com.iohao.mmo.equip.entity.ElseEquipProperty;
 import com.iohao.mmo.equip.entity.Equip;
-import com.iohao.mmo.equip.entity.Goods;
 import com.iohao.mmo.equip.utils.RandomUtils;
 import lombok.AllArgsConstructor;
 import org.springframework.data.mongodb.core.MongoTemplate;
@@ -66,9 +65,7 @@ public class EquipService {
         Query query = new Query(new Criteria("itemId").in(idList));
         mongoTemplate.remove(query, Equip.class);
 
-        //删除物品
-        Query goodsQuery = new Query(new Criteria("id").in(idList));
-        mongoTemplate.remove(goodsQuery, Goods.class);
+        //TODO 物品:删除物品
     }
 
     /**

+ 18 - 43
logic/equip-logic/src/main/java/com/iohao/mmo/equip/service/EquipTemplateService.java

@@ -18,6 +18,7 @@
  */
 package com.iohao.mmo.equip.service;
 
+import com.github.javafaker.Faker;
 import com.iohao.mmo.equip.entity.*;
 import com.iohao.mmo.equip.utils.RandomUtils;
 import lombok.AllArgsConstructor;
@@ -29,6 +30,7 @@ import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.stereotype.Service;
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Locale;
 import java.util.Objects;
 
 /**
@@ -40,6 +42,7 @@ import java.util.Objects;
 @AllArgsConstructor
 public class EquipTemplateService {
 
+    final Faker faker = new Faker(Locale.CHINA);
     final MongoTemplate mongoTemplate;
 
     public EquipTemplate findById(String id) {
@@ -53,12 +56,9 @@ public class EquipTemplateService {
         if(StringUtils.isNotBlank(equipTemplate.getId())){
             mongoTemplate.save(equipTemplate);
         }else {
-            //双向存储,便于后期查找
-            Goods goods = equipTemplate.getGoods();
-            goods.setType(3);
-            mongoTemplate.save(goods);
-            equipTemplate.setItemId(goods.getId());
-            equipTemplate.setGoods(goods);
+            //TODO 物品:这里需要调用物品新建方法获得物品的id
+            String itemId = faker.random().hex(24);
+            equipTemplate.setItemId(itemId);
             mongoTemplate.save(equipTemplate);
         }
     }
@@ -66,9 +66,7 @@ public class EquipTemplateService {
     public void delBatch(List<String> idList) {
         Query query = new Query(new Criteria("itemId").in(idList));
         mongoTemplate.remove(query, EquipTemplate.class);
-        //删除物品
-        Query goodsQuery = new Query(new Criteria("id").in(idList));
-        mongoTemplate.remove(goodsQuery, Goods.class);
+        //TODO 物品:删除物品
     }
 
 
@@ -94,18 +92,9 @@ public class EquipTemplateService {
         equipTemplate.setTotalAttrMin(20);
         equipTemplate.setTotalAttrMax(30);
 
-        Goods goods = new Goods();
-        goods.setName("皮甲");
-        goods.setDesc("一件厚重的皮甲");
-        goods.setIcon("https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png");
-        goods.setImage("https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png");
-        goods.setBindPrice(220);
-        goods.setPrice(200);
-        goods.setDealFlag(true);
-        goods.setType(3);
-        mongoTemplate.save(goods);
-        equipTemplate.setItemId(goods.getId());
-        equipTemplate.setGoods(goods);
+        //TODO 物品:这里需要调用物品新建方法获得物品的id
+        String itemId = faker.random().hex(24);
+        equipTemplate.setItemId(itemId);
 
         mongoTemplate.save(equipTemplate);
 
@@ -130,21 +119,10 @@ public class EquipTemplateService {
         equipTemplate2.setTotalAttrMin(16);
         equipTemplate2.setTotalAttrMax(24);
 
-        Goods goods2 = new Goods();
-        goods2.setName("铁剑");
-        goods2.setDesc("一把铁剑,有些锈迹斑斑了");
-        goods2.setIcon("https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png");
-        goods2.setImage("https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png");
-        goods2.setBindPrice(180);
-        goods2.setPrice(160);
-        goods2.setDealFlag(true);
-        goods2.setType(3);
-        mongoTemplate.save(goods2);
-        equipTemplate2.setItemId(goods2.getId());
-        equipTemplate2.setGoods(goods2);
-
+        //TODO 物品:这里需要调用物品新建方法获得物品的id
+        String itemId2 = faker.random().hex(24);
+        equipTemplate2.setItemId(itemId2);
         mongoTemplate.save(equipTemplate2);
-        mongoTemplate.save(goods2);
     }
 
     /**
@@ -185,13 +163,10 @@ public class EquipTemplateService {
         Equip equip = copyTemplate2Equip(equipTemplate,excellentRate);
         equip.setUserId(userId);
         //新建装备对应的物品类
-        Goods goods = equipTemplate.getGoods();
-        goods.setId(null);
-        goods.setType(0);
-        mongoTemplate.save(goods);
+        //TODO 物品:这里需要调用物品新建方法获得物品的id
+        String itemId2 = faker.random().hex(24);
         //对应的物品数据是新建的
-        equip.setItemId(goods.getId());
-        equip.setGoods(goods);
+        equip.setItemId(itemId2);
         mongoTemplate.save(equip);
         return equip;
     }
@@ -202,7 +177,7 @@ public class EquipTemplateService {
         //随机总属性点
         int attrTotal = RandomUtils.randomFromExcellent(equipTemplate.getTotalAttrMin(),equipTemplate.getTotalAttrMax(),excellentFlag);
         return Equip.builder()
-                .name(equipTemplate.getGoods().getName())
+                .name("测试装备名称") //TODO 物品:获取物品的名称
                 .quality(excellentFlag?2:1) //品质
                 .fixedEquipProperty(FixedEquipProperty.randomFixed(equipTemplate.getFixedEquipPropertyMin(),equipTemplate.getFixedEquipPropertyMax())) //装备固定属性
                 .attrTotal(attrTotal)
@@ -214,7 +189,7 @@ public class EquipTemplateService {
                 .fixedEquipPropertyMax(equipTemplate.getFixedEquipPropertyMax())
                 .totalAttrMin(equipTemplate.getTotalAttrMin())
                 .totalAttrMax(equipTemplate.getTotalAttrMax())
-                .equipTemplateId(equipTemplate.getId())
+                .equipTemplateId(equipTemplate.getItemId())
                 .build();
     }
 }

+ 0 - 44
logic/equip-logic/src/main/java/com/iohao/mmo/equip/service/GoodsService.java

@@ -1,44 +0,0 @@
-/*
- * 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.Goods;
-import lombok.AllArgsConstructor;
-import org.springframework.data.mongodb.core.MongoTemplate;
-import org.springframework.stereotype.Service;
-
-/**
- * @author 唐斌
- * @date 2023-07-30
- * @description: 物品类
- */
-@Service
-@AllArgsConstructor
-public class GoodsService {
-    final MongoTemplate mongoTemplate;
-
-    public Goods findById(long id) {
-        return  mongoTemplate.findById(id, Goods.class);
-    }
-
-    public void save(Goods goods) {
-        mongoTemplate.save(goods);
-    }
-
-}

+ 0 - 32
logic/equip-logic/src/main/java/com/iohao/mmo/equip/utils/EquipUtils.java

@@ -1,32 +0,0 @@
-package com.iohao.mmo.equip.utils;
-
-import com.iohao.mmo.equip.enums.EquipQualityEnum;
-import org.springframework.stereotype.Component;
-
-/**
- * @author kioor
- * @ClassName RandomUtils
- * @description: 装备相关工具
- * @date 2023年07月26日
- * @version: 1.0
- */
-@Component
-public class EquipUtils {
-
-    /**
-     * TODO 计算装备品质(暂时还未使用)
-     *
-     * @param randomMin 随机范围下限
-     * @param randomMax 随机范围上限
-     * @param nowVal 当前随机值
-     * @return boolean
-     */
-    public static int getEquipQuality(int randomMin,int randomMax,int nowVal) {
-        if (randomMin >= randomMax){
-            return 1;
-        }
-        double prop = (nowVal-randomMin)*1.00/(randomMax-randomMin);
-        return EquipQualityEnum.getQuality(prop);
-    }
-
-}

+ 0 - 2
provide/equip-provide/src/main/java/com/iohao/mmo/equip/proto/EquipMessage.java

@@ -44,8 +44,6 @@ public class EquipMessage{
     int attrTotal;
     /** 未分配属性点 */
     int undistributedAttr;
-    /** 所属物品 */
-    GoodsMessage goods;
     /** 部位(0帽子,1衣服,2武器,3手镯,4裤子,5鞋子) */
     int position;
     /** 要求等级 */

+ 0 - 2
provide/equip-provide/src/main/java/com/iohao/mmo/equip/proto/EquipTemplateMessage.java

@@ -36,8 +36,6 @@ public class EquipTemplateMessage{
      * id
      */
     String id;
-    /** 所属物品 */
-    GoodsMessage goods;
     /** 部位(0帽子,1衣服,2武器,3手镯,4裤子,5鞋子) */
     int position;
     /** 要求等级 */

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

@@ -1,57 +0,0 @@
-/*
- * 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-30
- * @description:
- */
-@ToString
-@ProtobufClass
-@FieldDefaults(level = AccessLevel.PUBLIC)
-public class GoodsMessage {
-    /**
-     * 物品id
-     */
-    String id;
-    /** 物品名称 */
-    String name;
-    /** 物品描述 */
-    String desc;
-    /** 图标 */
-    String icon;
-    /** 大图 */
-    String image;
-    /** 绑定货币价格 */
-    int bindPrice;
-    /** 非绑定货币价格 */
-    int price;
-    /** 是否可交易 */
-    boolean dealFlag;
-    /** 物品类型:0装备,1药品,2材料,3装备库 */
-    int type;
-    /** 子表主键 */
-    String detailId;
-}