|
@@ -0,0 +1,79 @@
|
|
|
+/*
|
|
|
+ * 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.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.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author 唐斌
|
|
|
+ * @date 2023-07-30
|
|
|
+ * @description: 装备属性实现类
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class EquipService {
|
|
|
+ final MongoTemplate mongoTemplate;
|
|
|
+ final EquipRepository equipRepository;
|
|
|
+
|
|
|
+ public Equip ofEquip(long id) {
|
|
|
+
|
|
|
+ return mongoTemplate.findById(id, Equip.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Optional<Equip> getById(long primaryKey) {
|
|
|
+ return equipRepository.findById(primaryKey);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void save(Equip equip) {
|
|
|
+ mongoTemplate.save(equip);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void initEquipData() {
|
|
|
+ // 初始化一些英雄数配置,后期将移到 excel 中做。
|
|
|
+
|
|
|
+ Equip equip = new Equip();
|
|
|
+ equip.setId(1000000L);
|
|
|
+ equip.setName("青铜甲");
|
|
|
+
|
|
|
+ BasicEquipProperty basicEquipProperty = getInitBasicEquipProperty();
|
|
|
+ equip.setBasicEquipProperty(basicEquipProperty);
|
|
|
+
|
|
|
+ mongoTemplate.save(equip);
|
|
|
+ }
|
|
|
+
|
|
|
+ private BasicEquipProperty getInitBasicEquipProperty() {
|
|
|
+ BasicEquipProperty basicEquipProperty = new BasicEquipProperty();
|
|
|
+ basicEquipProperty.setConstitution(1000);
|
|
|
+ basicEquipProperty.setMagicPower(120);
|
|
|
+ basicEquipProperty.setPower(110);
|
|
|
+ basicEquipProperty.setEndurance(200);
|
|
|
+ basicEquipProperty.setAgile(20);
|
|
|
+ return basicEquipProperty;
|
|
|
+ }
|
|
|
+}
|