Commit 1c467728 by 周君强

新增

1.宠物查询; 2.宠物移动; 3.宠物删除部分代码; 调整: 1.给bot的传参调整
parent 259afa75
...@@ -82,4 +82,9 @@ public class Constants { ...@@ -82,4 +82,9 @@ public class Constants {
* 宠物已查看 * 宠物已查看
*/ */
public static final int PET_CHECK = 1; public static final int PET_CHECK = 1;
/**
* 请求的名称不存在
*/
public static final int REQ_NON = -1;
} }
...@@ -49,10 +49,6 @@ public class TimingAcquisition { ...@@ -49,10 +49,6 @@ public class TimingAcquisition {
*/ */
public volatile static Map<String, GardenDto> gardenMap = new ConcurrentHashMap<>(); public volatile static Map<String, GardenDto> gardenMap = new ConcurrentHashMap<>();
/** /**
* 所有玩家的花圃统一管理(uid, NurseryDto),便于植物生长
*/
public volatile static Map<String, NurseryInfoDto> NurseryInfoMap = new ConcurrentHashMap<>();
/**
* 植物生长周期信息 * 植物生长周期信息
*/ */
public volatile static Map<Integer, Map<Integer, PlantPeriodDto>> periodMap = new ConcurrentHashMap<>(); public volatile static Map<Integer, Map<Integer, PlantPeriodDto>> periodMap = new ConcurrentHashMap<>();
...@@ -192,7 +188,7 @@ public class TimingAcquisition { ...@@ -192,7 +188,7 @@ public class TimingAcquisition {
nurseryInfo.setId(1); nurseryInfo.setId(1);
nurseryInfo.setStatus(0); nurseryInfo.setStatus(0);
nurseryInfo.setPlantId(1); nurseryInfo.setPlantId(1);
nurseryInfo.setNumber(10); nurseryInfo.set反馈ID(10);
nurseryInfo.setSeedingTime(DateUtil.getCurrentTime()); nurseryInfo.setSeedingTime(DateUtil.getCurrentTime());
nurseryInfo.setPetField(1); nurseryInfo.setPetField(1);
nurseryInfo.setCreateTime(DateUtil.getCurrentTime()); nurseryInfo.setCreateTime(DateUtil.getCurrentTime());
...@@ -304,4 +300,112 @@ public class TimingAcquisition { ...@@ -304,4 +300,112 @@ public class TimingAcquisition {
return null; return null;
} }
/**
* 根据花圃编号获取花圃配置信息
* @param nurseryName
* @return NurseryPojo
*/
public static NurseryPojo getNurseryByName(String nurseryName) {
Iterator<Map.Entry<Integer, NurseryPojo>> iterator = nurseryConfigMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Integer, NurseryPojo> entry = iterator.next();
NurseryPojo nursery = entry.getValue();
if (nurseryName.equals(nursery.getName())) {
return nursery;
}
}
return null;
}
/**
* 根据花圃类型名称获取花圃类型id
* @param nurseryType
* @return Integer
*/
public static Integer getNurseryIdByName(String nurseryType) {
Iterator<Map.Entry<Integer, NurseryPojo>> iterator = nurseryConfigMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Integer, NurseryPojo> entry = iterator.next();
NurseryPojo nursery = entry.getValue();
if (nurseryType.equals(nursery.getName())) {
return nursery.getId();
}
}
return null;
}
/**
* 根据植物名称获取植物id
* @param plantName
* @return Integer
*/
public static Integer getPlantIdByName(String plantName) {
Iterator<Map.Entry<Integer, PlantPojo>> iterator = plantMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Integer, PlantPojo> entry = iterator.next();
PlantPojo plant = entry.getValue();
if (plantName.equals(plant.getName())) {
return plant.getId();
}
}
return null;
}
/**
* 根据物品名称获取物品信息
* @param itemName
* @return Integer
*/
public static ItemPojo getItemByName(String itemName) {
Iterator<Map.Entry<Integer, ItemPojo>> iterator = itemConfigMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Integer, ItemPojo> entry = iterator.next();
ItemPojo item = entry.getValue();
if (itemName.equals(item.getName())) {
return item;
}
}
return null;
}
/**
* 根据物品名称获取物品id
* @param itemName
* @return Integer
*/
public static Integer getItemIdByName(String itemName) {
Iterator<Map.Entry<Integer, ItemPojo>> iterator = itemConfigMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Integer, ItemPojo> entry = iterator.next();
ItemPojo item = entry.getValue();
if (itemName.equals(item.getName())) {
return item.getId();
}
}
return null;
}
/**
* 根据宠物名称获取物宠物id
* @param petName
* @return Integer
*/
public static Integer getPetIdByName(String petName) {
Iterator<Map.Entry<Integer, PetPojo>> iterator = petConfigMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Integer, PetPojo> entry = iterator.next();
PetPojo pet = entry.getValue();
if (petName.equals(pet.getName())) {
return pet.getId();
}
}
return -1;
}
} }
...@@ -12,7 +12,7 @@ public class CacheUtil { ...@@ -12,7 +12,7 @@ public class CacheUtil {
* @param value * @param value
* @param expire * @param expire
*/ */
public void put(String key, Object value, long expire) { public static void put(String key, Object value, long expire) {
if (StringUtils.isEmpty(key)) { if (StringUtils.isEmpty(key)) {
return; return;
} }
...@@ -37,7 +37,7 @@ public class CacheUtil { ...@@ -37,7 +37,7 @@ public class CacheUtil {
* 获取缓存 * 获取缓存
* @param key * @param key
*/ */
public Object get(String key) { public static Object get(String key) {
if (StringUtils.isEmpty(key)) { if (StringUtils.isEmpty(key)) {
return null; return null;
} }
......
...@@ -53,6 +53,8 @@ public class PlantGrowSchedule { ...@@ -53,6 +53,8 @@ public class PlantGrowSchedule {
log.info("该花圃未种植!"); log.info("该花圃未种植!");
continue; continue;
} }
//未成熟的植物进入生长判断
if (nurseryInfo.getStatus() != 5) {
//花圃配置信息 //花圃配置信息
NurseryPojo nurseryConfig = TimingAcquisition.nurseryConfigMap.get(nurseryInfo.getId()); NurseryPojo nurseryConfig = TimingAcquisition.nurseryConfigMap.get(nurseryInfo.getId());
//植物生长周期信息 //植物生长周期信息
...@@ -99,7 +101,7 @@ public class PlantGrowSchedule { ...@@ -99,7 +101,7 @@ public class PlantGrowSchedule {
nurseryInfo.setStatus(Constants.PLANT_MATURE); nurseryInfo.setStatus(Constants.PLANT_MATURE);
log.info("植物" + nurseryInfo.getPlantId() + "进入成熟期"); log.info("植物" + nurseryInfo.getPlantId() + "进入成熟期");
ItemDto fruit= new ItemDto(); ItemDto fruit = new ItemDto();
//产生的果实数量,不同等级的花圃能提供不同的收获加成 //产生的果实数量,不同等级的花圃能提供不同的收获加成
//花圃中植物能产生的果实数量 //花圃中植物能产生的果实数量
Integer fruitNum = TimingAcquisition.plantMap.get(nurseryInfo.getPlantId()).getFruitNum() * nurseryInfo.getNumber(); Integer fruitNum = TimingAcquisition.plantMap.get(nurseryInfo.getPlantId()).getFruitNum() * nurseryInfo.getNumber();
...@@ -115,6 +117,7 @@ public class PlantGrowSchedule { ...@@ -115,6 +117,7 @@ public class PlantGrowSchedule {
} }
} }
} }
}
log.info("所有植物现阶段生长完成!"); log.info("所有植物现阶段生长完成!");
} }
} }
package com.qiwuai.garden.common.utils;
import com.qiwuai.garden.common.Constants;
import com.qiwuai.garden.common.TimingAcquisition;
import com.qiwuai.garden.dto.base.CommonRequest;
import com.qiwuai.garden.dto.request.CallRequest;
import com.qiwuai.garden.dto.request.OperationRequest;
import com.qiwuai.garden.pojo.ItemPojo;
import com.qiwuai.garden.pojo.NurseryPojo;
import com.qiwuai.garden.pojo.PetPojo;
import com.qiwuai.garden.pojo.PlantPojo;
import org.springframework.util.StringUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RequestConversionUtil {
/**
* 将请求的中文转成系统数据
* @param
* @
*/
public static OperationRequest request2Operation(CommonRequest commonRequest) {
OperationRequest operationRequest = new OperationRequest();
CallRequest callRequest = commonRequest.getVars();
operationRequest.setUid(commonRequest.getUid());
//存在花圃编号
String nurseryNum = callRequest.get花圃编号();
if (!StringUtils.isEmpty(nurseryNum)) {
String regEx="[^0-9]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(nurseryNum);
if (!"".equals(m.replaceAll("").trim())) {
operationRequest.setNurseryNum(Integer.valueOf(m.replaceAll("").trim()));
} else {
operationRequest.setNurseryNum(Constants.REQ_NON);
}
}
//存在花圃位置
String nurseryPos = callRequest.get宠物位置();
if (!StringUtils.isEmpty(nurseryPos)) {
String regEx="[^0-9]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(nurseryPos);
if (!"".equals(m.replaceAll("").trim())) {
operationRequest.setNurseryPos(Integer.valueOf(m.replaceAll("").trim()));
} else {
operationRequest.setNurseryPos(Constants.REQ_NON);
}
}
//存在花圃类型
String nurseryName = callRequest.get花圃类型();
if (!StringUtils.isEmpty(nurseryName)) {
Integer nurseryId = TimingAcquisition.getNurseryIdByName(nurseryName);
if (!StringUtils.isEmpty(nurseryId)) {
operationRequest.setNurseryId(nurseryId);
}
}
//存在植物名称
String plantName = callRequest.get植物名称();
if (!StringUtils.isEmpty(plantName)) {
Integer plantId = TimingAcquisition.getPlantIdByName(plantName);
if (!StringUtils.isEmpty(plantId)) {
operationRequest.setPlantId(plantId);
}
}
//存在物品名称
String itemName = callRequest.get物品名称();
if (!StringUtils.isEmpty(itemName)) {
ItemPojo item = TimingAcquisition.getItemByName(itemName);
if (!StringUtils.isEmpty(item)) {
operationRequest.setItemId(item.getId());
operationRequest.setItemTypeId(item.getItemTypeId());
}
}
//存在宠物名称
String petName = callRequest.get宠物名称();
if (!StringUtils.isEmpty(petName)) {
Integer petId = TimingAcquisition.getPetIdByName(petName);
if (!StringUtils.isEmpty(petId)) {
operationRequest.setPetId(petId);
}
}
return operationRequest;
}
}
...@@ -37,7 +37,7 @@ public class TypeConvertUtil { ...@@ -37,7 +37,7 @@ public class TypeConvertUtil {
String[] itemIdNum = s.split("/"); String[] itemIdNum = s.split("/");
PlantDto plantDto = new PlantDto(); PlantDto plantDto = new PlantDto();
plantDto.setPlantId(Integer.valueOf(itemIdNum[0])); plantDto.setPlantId(Integer.valueOf(itemIdNum[0]));
plantDto.setNumber(Integer.valueOf(itemIdNum[1])); plantDto.set反馈ID(Integer.valueOf(itemIdNum[1]));
plantDtoList.add(plantDto); plantDtoList.add(plantDto);
} }
return plantDtoList; return plantDtoList;
......
package com.qiwuai.garden.common.utils;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
@Data
public class YamlUtil {
@Value("${expire.time}")
public String expireTime;
}
package com.qiwuai.garden.controller; package com.qiwuai.garden.controller;
import com.qiwuai.garden.common.utils.RequestConversionUtil;
import com.qiwuai.garden.dto.base.CommonRequest; import com.qiwuai.garden.dto.base.CommonRequest;
import com.qiwuai.garden.dto.base.CommonResponse; import com.qiwuai.garden.dto.base.CommonResponse;
import com.qiwuai.garden.dto.base.ResultResponse; import com.qiwuai.garden.dto.base.ResultResponse;
import com.qiwuai.garden.dto.request.CallRequest;
import com.qiwuai.garden.dto.request.OperationRequest;
import com.qiwuai.garden.service.backPackService.BackPackService;
import com.qiwuai.garden.service.gardenerService.GardenerService; import com.qiwuai.garden.service.gardenerService.GardenerService;
import com.qiwuai.garden.service.nurseryService.NurseryService;
import com.qiwuai.garden.service.petService.PetService;
import com.qiwuai.garden.service.plantService.PlantService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -15,10 +22,36 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -15,10 +22,36 @@ import org.springframework.web.bind.annotation.RestController;
public class CommonController { public class CommonController {
@Autowired @Autowired
private GardenerService gardenerService; private GardenerService gardenerService;
@Autowired
private NurseryService nurseryService;
@Autowired
private PlantService plantService;
@Autowired
private BackPackService backPackService;
@Autowired
private PetService petService;
@PostMapping(value = "/call", produces = "application/json;charset=UTF-8") @PostMapping(value = "/call", produces = "application/json;charset=UTF-8")
public CommonResponse createGardener(@RequestBody CommonRequest commonReqDto) { public CommonResponse createGardener(@RequestBody CommonRequest commonRequest) {
OperationRequest operationReq = RequestConversionUtil.request2Operation(commonRequest);
return null; CommonResponse result = new CommonResponse();
switch (commonRequest.getVars().get操作名()) {
case "种植":
result = plantService.seed(operationReq);
break;
case "检查种植":
result = plantService.checkNursery(operationReq);
break;
case "查询花圃状态":
result = nurseryService.checkNurseryByNum(operationReq);
break;
case "查看宠物":
result = petService.petView(operationReq);
break;
case "宠物移动指令":
result = petService.petMove(operationReq);
break;
}
return result;
} }
} }
...@@ -10,6 +10,7 @@ import com.qiwuai.garden.dto.response.ApiResponse; ...@@ -10,6 +10,7 @@ import com.qiwuai.garden.dto.response.ApiResponse;
import com.qiwuai.garden.service.backPackService.BackPackService; import com.qiwuai.garden.service.backPackService.BackPackService;
import com.qiwuai.garden.service.gardenerService.GardenerService; import com.qiwuai.garden.service.gardenerService.GardenerService;
import com.qiwuai.garden.service.nurseryService.NurseryService; import com.qiwuai.garden.service.nurseryService.NurseryService;
import com.qiwuai.garden.service.petService.PetService;
import com.qiwuai.garden.service.plantService.PlantService; import com.qiwuai.garden.service.plantService.PlantService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -25,6 +26,8 @@ public class GardenerController { ...@@ -25,6 +26,8 @@ public class GardenerController {
private PlantService plantService; private PlantService plantService;
@Autowired @Autowired
private BackPackService backPackService; private BackPackService backPackService;
@Autowired
private PetService petService;
@PostMapping(value = "/create", produces = "application/json;charset=UTF-8") @PostMapping(value = "/create", produces = "application/json;charset=UTF-8")
public ApiResponse<GardenerDto> createGardener(@RequestBody GardenerRequest gardenerRequest) { public ApiResponse<GardenerDto> createGardener(@RequestBody GardenerRequest gardenerRequest) {
...@@ -80,6 +83,12 @@ public class GardenerController { ...@@ -80,6 +83,12 @@ public class GardenerController {
return goods; return goods;
} }
@PostMapping(value = "/cancelResetSkill", produces = "application/json;charset=UTF-8")
public CommonResponse cancelResetSkill(@RequestBody OperationRequest operationReq) {
CommonResponse goods = gardenerService.cancelResetSkill(operationReq);
return goods;
}
@PostMapping(value = "/searchRenameCondition", produces = "application/json;charset=UTF-8") @PostMapping(value = "/searchRenameCondition", produces = "application/json;charset=UTF-8")
public CommonResponse searchRenameCondition(@RequestBody OperationRequest operationReq) { public CommonResponse searchRenameCondition(@RequestBody OperationRequest operationReq) {
CommonResponse goods = gardenerService.searchRenameCondition(operationReq); CommonResponse goods = gardenerService.searchRenameCondition(operationReq);
...@@ -212,6 +221,12 @@ public class GardenerController { ...@@ -212,6 +221,12 @@ public class GardenerController {
return result; return result;
} }
@PostMapping(value = "/petView", produces = "application/json;charset=UTF-8")
public CommonResponse petView(@RequestBody OperationRequest operationReq) {
CommonResponse result = petService.petView(operationReq);
return result;
}
@GetMapping("/steal") @GetMapping("/steal")
public String steal() { public String steal() {
System.out.println("去偷菜了"); System.out.println("去偷菜了");
......
...@@ -8,7 +8,7 @@ import java.util.Map; ...@@ -8,7 +8,7 @@ import java.util.Map;
@Data @Data
public class NurseryInfoDto { public class NurseryInfoDto {
/** /**
* 花圃编号 * 花圃类型id
*/ */
private Integer id; private Integer id;
/** /**
......
...@@ -7,9 +7,13 @@ public class ResultResponse { ...@@ -7,9 +7,13 @@ public class ResultResponse {
/** /**
* 反馈ID即编号 * 反馈ID即编号
*/ */
private int number; private int 反馈ID;
/** /**
* 反馈文本 * 反馈文本
*/ */
private String Text; private String 反馈文本;
/**
* 后台附加返回,bot二次确认需要的参数
*/
private String 后台附加返回;
} }
...@@ -5,15 +5,35 @@ import lombok.Data; ...@@ -5,15 +5,35 @@ import lombok.Data;
@Data @Data
public class CallRequest { public class CallRequest {
/** /**
* 源对象 * 操作指令:查看,种植,收取,取消,选择,重置,升级,更名,移动,删除,排序,购买,出售等
*/ */
private String 源对象; private String 操作名;
/** /**
* 操作指令:查看,种植,收取,取消,选择,重置,升级,更名,移动,删除,排序,购买,出售 * 植物名称
*/ */
private String 操作; private String 植物名称;
/** /**
* 目标对象 * 花圃编号
*/ */
private String 目标对象; private String 花圃编号;
/**
* 宠物当前位置
*/
private String 宠物位置;
/**
* 花圃升级等级
*/
private String 升级等级;
/**
* 花圃类型
*/
private String 花圃类型;
/**
* 宠物名称
*/
private String 宠物名称;
/**
* 物品名称
*/
private String 物品名称;
} }
...@@ -29,13 +29,13 @@ public class OperationRequest { ...@@ -29,13 +29,13 @@ public class OperationRequest {
*/ */
private Integer nurseryNum; private Integer nurseryNum;
/** /**
* 当前花圃id * 花圃位置,即花圃编号
*/ */
private Integer nurseryId; private Integer nurseryPos;
/** /**
* 目标花圃id * 花圃类型id
*/ */
private Integer targetNurseryId; private Integer nurseryId;
/** /**
* 植物id-由植物名称或者果实获取 * 植物id-由植物名称或者果实获取
*/ */
...@@ -44,5 +44,9 @@ public class OperationRequest { ...@@ -44,5 +44,9 @@ public class OperationRequest {
* 技能id * 技能id
*/ */
private Integer skillId; private Integer skillId;
/**
* 查看的宠物id
*/
private Integer petId;
} }
...@@ -7,7 +7,7 @@ import java.math.BigDecimal; ...@@ -7,7 +7,7 @@ import java.math.BigDecimal;
@Data @Data
public class NurseryPojo { public class NurseryPojo {
/** /**
* 苗圃编号 * 花圃类型id
*/ */
private Integer id; private Integer id;
/** /**
......
...@@ -74,8 +74,8 @@ public class BackPackServiceImpl implements BackPackService { ...@@ -74,8 +74,8 @@ public class BackPackServiceImpl implements BackPackService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100401); resultResponse.set反馈ID(100401);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -98,8 +98,8 @@ public class BackPackServiceImpl implements BackPackService { ...@@ -98,8 +98,8 @@ public class BackPackServiceImpl implements BackPackService {
if (!itemTypeIdSet.contains(itemTypeId)) { if (!itemTypeIdSet.contains(itemTypeId)) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100403); resultResponse.set反馈ID(100403);
resultResponse.setText("物品种类不存在"); resultResponse.set反馈文本("物品种类不存在");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -116,8 +116,8 @@ public class BackPackServiceImpl implements BackPackService { ...@@ -116,8 +116,8 @@ public class BackPackServiceImpl implements BackPackService {
text.append("还没有哦,先去收集一些吧"); text.append("还没有哦,先去收集一些吧");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100404); resultResponse.set反馈ID(100404);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -138,8 +138,8 @@ public class BackPackServiceImpl implements BackPackService { ...@@ -138,8 +138,8 @@ public class BackPackServiceImpl implements BackPackService {
log.info("物品详情查询结果:" + text.toString()); log.info("物品详情查询结果:" + text.toString());
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100402); resultResponse.set反馈ID(100402);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -167,8 +167,8 @@ public class BackPackServiceImpl implements BackPackService { ...@@ -167,8 +167,8 @@ public class BackPackServiceImpl implements BackPackService {
log.info("货币查询结果:" + text.toString()); log.info("货币查询结果:" + text.toString());
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100501); resultResponse.set反馈ID(100501);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -214,8 +214,8 @@ public class BackPackServiceImpl implements BackPackService { ...@@ -214,8 +214,8 @@ public class BackPackServiceImpl implements BackPackService {
log.info("物品信息检索结果:" + text.toString()); log.info("物品信息检索结果:" + text.toString());
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100601); resultResponse.set反馈ID(100601);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -225,8 +225,8 @@ public class BackPackServiceImpl implements BackPackService { ...@@ -225,8 +225,8 @@ public class BackPackServiceImpl implements BackPackService {
log.info("物品信息检索结果:" + text.toString()); log.info("物品信息检索结果:" + text.toString());
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100601); resultResponse.set反馈ID(100601);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
......
...@@ -33,7 +33,7 @@ public interface GardenerService { ...@@ -33,7 +33,7 @@ public interface GardenerService {
*/ */
CommonResponse searchSkillInfo(OperationRequest operationReq); CommonResponse searchSkillInfo(OperationRequest operationReq);
/** /**
* 查看当前等级可选择的所有技能信息 * 查看当前等级可选择的所有技能信息,取消使用技能
* @param operationReq * @param operationReq
* @return CommonResponse * @return CommonResponse
*/ */
...@@ -45,13 +45,13 @@ public interface GardenerService { ...@@ -45,13 +45,13 @@ public interface GardenerService {
*/ */
CommonResponse learnSkill(OperationRequest operationReq); CommonResponse learnSkill(OperationRequest operationReq);
/** /**
* 查询重置园丁技能的开销 * 查询重置园丁技能的开销,重置园丁
* @param operationReq * @param operationReq
* @return CommonResponse * @return CommonResponse
*/ */
CommonResponse resetSkillCost(OperationRequest operationReq); CommonResponse resetSkillCost(OperationRequest operationReq);
/** /**
* 重置园丁技能 * 重置园丁技能,确认重置
* @param operationReq * @param operationReq
* @return CommonResponse * @return CommonResponse
*/ */
...@@ -63,6 +63,12 @@ public interface GardenerService { ...@@ -63,6 +63,12 @@ public interface GardenerService {
*/ */
CommonResponse searchSkillBeforeLearn(OperationRequest operationReq); CommonResponse searchSkillBeforeLearn(OperationRequest operationReq);
/** /**
* 取消重置技能
* @param operationReq
* @return CommonResponse
*/
CommonResponse cancelResetSkill(OperationRequest operationReq);
/**
* 园丁更名 * 园丁更名
* @param operationReq * @param operationReq
* @return CommonResponse * @return CommonResponse
......
...@@ -2,10 +2,13 @@ package com.qiwuai.garden.service.gardenerService.impl; ...@@ -2,10 +2,13 @@ package com.qiwuai.garden.service.gardenerService.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.qiwuai.garden.common.Constants; import com.qiwuai.garden.common.Constants;
import com.qiwuai.garden.common.cache.CacheGlobal;
import com.qiwuai.garden.common.cache.CacheUtil;
import com.qiwuai.garden.common.utils.DateUtil; import com.qiwuai.garden.common.utils.DateUtil;
import com.qiwuai.garden.common.utils.PersistenceUtil; import com.qiwuai.garden.common.utils.PersistenceUtil;
import com.qiwuai.garden.common.TimingAcquisition; import com.qiwuai.garden.common.TimingAcquisition;
import com.qiwuai.garden.common.utils.TypeConvertUtil; import com.qiwuai.garden.common.utils.TypeConvertUtil;
import com.qiwuai.garden.common.utils.YamlUtil;
import com.qiwuai.garden.dao.GardenerLevelMapper; import com.qiwuai.garden.dao.GardenerLevelMapper;
import com.qiwuai.garden.dao.GardenerMapper; import com.qiwuai.garden.dao.GardenerMapper;
import com.qiwuai.garden.dao.ItemTypeMapper; import com.qiwuai.garden.dao.ItemTypeMapper;
...@@ -36,6 +39,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -36,6 +39,8 @@ public class GardenerServiceImpl implements GardenerService {
@Autowired @Autowired
private GardenerMapper gardenerMapper; private GardenerMapper gardenerMapper;
@Autowired
private YamlUtil yamlUtil;
@Override @Override
public ApiResponse<GardenerDto> create(GardenerRequest gardenerRequest) { public ApiResponse<GardenerDto> create(GardenerRequest gardenerRequest) {
...@@ -176,8 +181,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -176,8 +181,8 @@ public class GardenerServiceImpl implements GardenerService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200101); resultResponse.set反馈ID(200101);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -200,8 +205,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -200,8 +205,8 @@ public class GardenerServiceImpl implements GardenerService {
if ((gardenerInfo.getLevel() + 1) > GardenerLVMax) { //已经达到最大等级 if ((gardenerInfo.getLevel() + 1) > GardenerLVMax) { //已经达到最大等级
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200105); resultResponse.set反馈ID(200105);
resultResponse.setText("我已经达到最大等级了"); resultResponse.set反馈文本("我已经达到最大等级了");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -289,8 +294,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -289,8 +294,8 @@ public class GardenerServiceImpl implements GardenerService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(number); resultResponse.set反馈ID(number);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -303,7 +308,10 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -303,7 +308,10 @@ public class GardenerServiceImpl implements GardenerService {
ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse();
ResultResponse resultResponse = new ResultResponse(); ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid();
Integer skillId = operationReq.getSkillId(); Integer skillId = operationReq.getSkillId();
//保存玩家这轮的请求信息,保留三分钟
CacheUtil.put(uid, operationReq, Long.parseLong(yamlUtil.getExpireTime()));
//获取技能配置信息 //获取技能配置信息
GardenerSkillPojo gardenerSkill = TimingAcquisition.gardenerSkillMap.get(skillId); GardenerSkillPojo gardenerSkill = TimingAcquisition.gardenerSkillMap.get(skillId);
...@@ -323,8 +331,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -323,8 +331,8 @@ public class GardenerServiceImpl implements GardenerService {
log.info("技能信息:" + gardenerSkill); log.info("技能信息:" + gardenerSkill);
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200105); resultResponse.set反馈ID(200105);
resultResponse.setText(gardenerSkill.getName() + "," + description + ",确定选择这个技能吗?"); resultResponse.set反馈文本(gardenerSkill.getName() + "," + description + ",确定选择这个技能吗?");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -358,8 +366,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -358,8 +366,8 @@ public class GardenerServiceImpl implements GardenerService {
log.info("当前等级的所有技能信息:" + Arrays.toString(skillIdList)); log.info("当前等级的所有技能信息:" + Arrays.toString(skillIdList));
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200105); resultResponse.set反馈ID(200105);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -373,7 +381,15 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -373,7 +381,15 @@ public class GardenerServiceImpl implements GardenerService {
ResultResponse resultResponse = new ResultResponse(); ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid(); String uid = operationReq.getUid();
Integer skillId = operationReq.getSkillId(); //当前玩家上一轮的请求信息,存活时间为三分钟
OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid);
if (StringUtils.isEmpty(lastReq)) {
commonResponse.setCode(0);
commonResponse.setMsg("失败,对话超时");
return commonResponse;
}
//需要学习的技能
Integer skillId = lastReq.getSkillId();
//园丁基本信息 //园丁基本信息
GardenerInfoDto gardenerInfo = TimingAcquisition.gardenerMap.get(uid).getGardenerInfo(); GardenerInfoDto gardenerInfo = TimingAcquisition.gardenerMap.get(uid).getGardenerInfo();
...@@ -387,8 +403,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -387,8 +403,8 @@ public class GardenerServiceImpl implements GardenerService {
log.info("我已经有" + gardenerSkillMap.get(skillId).getName() + "的技能了"); log.info("我已经有" + gardenerSkillMap.get(skillId).getName() + "的技能了");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200108); resultResponse.set反馈ID(200108);
resultResponse.setText("我已经有" + gardenerSkillMap.get(skillId).getName() + "的技能了"); resultResponse.set反馈文本("我已经有" + gardenerSkillMap.get(skillId).getName() + "的技能了");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -405,8 +421,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -405,8 +421,8 @@ public class GardenerServiceImpl implements GardenerService {
log.info("园丁学习后的技能:" + gardenerSkills); log.info("园丁学习后的技能:" + gardenerSkills);
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200106); resultResponse.set反馈ID(200106);
resultResponse.setText("我已经学习了" + gardenerSkillMap.get(skillId).getName() + ",能力大幅提升"); resultResponse.set反馈文本("我已经学习了" + gardenerSkillMap.get(skillId).getName() + ",能力大幅提升");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -447,8 +463,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -447,8 +463,8 @@ public class GardenerServiceImpl implements GardenerService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200201); resultResponse.set反馈ID(200201);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -468,8 +484,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -468,8 +484,8 @@ public class GardenerServiceImpl implements GardenerService {
if (gardenerInfo.getSkills().size() == 0) { if (gardenerInfo.getSkills().size() == 0) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200202); resultResponse.set反馈ID(200202);
resultResponse.setText("技能已重置过了,现在需要重新选择一次技能"); resultResponse.set反馈文本("技能已重置过了,现在需要重新选择一次技能");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -500,8 +516,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -500,8 +516,8 @@ public class GardenerServiceImpl implements GardenerService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200203); resultResponse.set反馈ID(200203);
resultResponse.setText(moneyConfig.getName() + "不足,无法重新选择技能"); resultResponse.set反馈文本(moneyConfig.getName() + "不足,无法重新选择技能");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -516,8 +532,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -516,8 +532,8 @@ public class GardenerServiceImpl implements GardenerService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200202); resultResponse.set反馈ID(200202);
resultResponse.setText("技能学习已重置,现在需要重新选择一次技能"); resultResponse.set反馈文本("技能学习已重置,现在需要重新选择一次技能");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -555,8 +571,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -555,8 +571,8 @@ public class GardenerServiceImpl implements GardenerService {
log.info("所有技能已学习完毕"); log.info("所有技能已学习完毕");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200205); resultResponse.set反馈ID(200205);
resultResponse.setText("所有技能已学习完毕"); resultResponse.set反馈文本("所有技能已学习完毕");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -576,8 +592,30 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -576,8 +592,30 @@ public class GardenerServiceImpl implements GardenerService {
log.info(text.toString()); log.info(text.toString());
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200202); resultResponse.set反馈ID(200202);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
@Override
public CommonResponse cancelResetSkill(OperationRequest operationReq) {
log.info("开始依次查询哪些等级还未学习技能");
CommonResponse commonResponse = new CommonResponse();
ResultVarsResponse resultVarsResponse = new ResultVarsResponse();
ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid();
//清除本轮对话缓存数据
CacheGlobal.concurrentMap.remove(uid);
log.info("好的,现在先不要重新学习技能了");
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(200204);
resultResponse.set反馈文本("好的,现在先不要重新学习技能了");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -592,6 +630,18 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -592,6 +630,18 @@ public class GardenerServiceImpl implements GardenerService {
String uid = operationReq.getUid(); String uid = operationReq.getUid();
String rename = operationReq.getRename(); String rename = operationReq.getRename();
if (StringUtils.isEmpty(rename)) {
log.info("没有名称,修改不了");
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(200301);
resultResponse.set反馈文本("要给我改名吗?换个什么名字好呢?");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//保存玩家这轮的请求信息,保留三分钟
CacheUtil.put(uid, operationReq, Long.parseLong(yamlUtil.getExpireTime()));
//更名所需费用 //更名所需费用
String renameCost = TimingAcquisition.systemConfigMap.get("rename_cost").getValue(); String renameCost = TimingAcquisition.systemConfigMap.get("rename_cost").getValue();
...@@ -618,8 +668,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -618,8 +668,8 @@ public class GardenerServiceImpl implements GardenerService {
log.info(text.toString()); log.info(text.toString());
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200302); resultResponse.set反馈ID(200302);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -633,17 +683,15 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -633,17 +683,15 @@ public class GardenerServiceImpl implements GardenerService {
ResultResponse resultResponse = new ResultResponse(); ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid(); String uid = operationReq.getUid();
String rename = operationReq.getRename(); //当前玩家上一轮的请求信息,存活时间为三分钟
if (StringUtils.isEmpty(rename)) { OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid);
log.info("没有名称,修改不了"); if (StringUtils.isEmpty(lastReq)) {
commonResponse.setCode(1); commonResponse.setCode(0);
commonResponse.setMsg("成功"); commonResponse.setMsg("失败,对话超时");
resultResponse.setNumber(200301);
resultResponse.setText("要给我改名吗?换个什么名字好呢?");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
} }
//需要更改的名字
String rename = lastReq.getRename();
//园丁基本信息 //园丁基本信息
GardenerInfoDto gardenerInfo = TimingAcquisition.gardenerMap.get(uid).getGardenerInfo(); GardenerInfoDto gardenerInfo = TimingAcquisition.gardenerMap.get(uid).getGardenerInfo();
...@@ -652,8 +700,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -652,8 +700,8 @@ public class GardenerServiceImpl implements GardenerService {
log.info("园丁已经修改名字了"); log.info("园丁已经修改名字了");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200305); resultResponse.set反馈ID(200305);
resultResponse.setText("园丁已经修改名字了"); resultResponse.set反馈文本("园丁已经修改名字了");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -681,8 +729,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -681,8 +729,8 @@ public class GardenerServiceImpl implements GardenerService {
log.info(itemConfigMap.get(item.getItemId()).getName() + "不太够,再去挣点钱吧"); log.info(itemConfigMap.get(item.getItemId()).getName() + "不太够,再去挣点钱吧");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200304); resultResponse.set反馈ID(200304);
resultResponse.setText(itemConfigMap.get(item.getItemId()).getName() + "不太够,再去挣点钱吧"); resultResponse.set反馈文本(itemConfigMap.get(item.getItemId()).getName() + "不太够,再去挣点钱吧");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -698,8 +746,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -698,8 +746,8 @@ public class GardenerServiceImpl implements GardenerService {
log.info("还没有" + itemConfigMap.get(item.getItemId()).getName() + ",先去收集一些吧"); log.info("还没有" + itemConfigMap.get(item.getItemId()).getName() + ",先去收集一些吧");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200304); resultResponse.set反馈ID(200304);
resultResponse.setText("还没有" + itemConfigMap.get(item.getItemId()).getName() + ",先去收集一些吧"); resultResponse.set反馈文本("还没有" + itemConfigMap.get(item.getItemId()).getName() + ",先去收集一些吧");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -709,8 +757,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -709,8 +757,8 @@ public class GardenerServiceImpl implements GardenerService {
log.info(itemConfigMap.get(item.getItemId()).getName() + "不太够,再去收集点吧"); log.info(itemConfigMap.get(item.getItemId()).getName() + "不太够,再去收集点吧");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200304); resultResponse.set反馈ID(200304);
resultResponse.setText(itemConfigMap.get(item.getItemId()).getName() + "不太够,再去收集点吧"); resultResponse.set反馈文本(itemConfigMap.get(item.getItemId()).getName() + "不太够,再去收集点吧");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -725,8 +773,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -725,8 +773,8 @@ public class GardenerServiceImpl implements GardenerService {
log.info("改名成功,当前名称为:" + gardenerInfo.getName()); log.info("改名成功,当前名称为:" + gardenerInfo.getName());
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(200303); resultResponse.set反馈ID(200303);
resultResponse.setText("好的,我以后就叫" + gardenerInfo.getName() + "了"); resultResponse.set反馈文本("好的,我以后就叫" + gardenerInfo.getName() + "了");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -799,8 +847,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -799,8 +847,8 @@ public class GardenerServiceImpl implements GardenerService {
} else { } else {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100102); resultResponse.set反馈ID(100102);
resultResponse.setText("失败,货币不足"); resultResponse.set反馈文本("失败,货币不足");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -808,8 +856,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -808,8 +856,8 @@ public class GardenerServiceImpl implements GardenerService {
} else { //不存在该物品 } else { //不存在该物品
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100102); resultResponse.set反馈ID(100102);
resultResponse.setText("失败,商店没有该商品"); resultResponse.set反馈文本("失败,商店没有该商品");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -823,8 +871,8 @@ public class GardenerServiceImpl implements GardenerService { ...@@ -823,8 +871,8 @@ public class GardenerServiceImpl implements GardenerService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100102); resultResponse.set反馈ID(100102);
resultResponse.setText("购买成功"); resultResponse.set反馈文本("购买成功");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
......
...@@ -2,8 +2,10 @@ package com.qiwuai.garden.service.nurseryService.impl; ...@@ -2,8 +2,10 @@ package com.qiwuai.garden.service.nurseryService.impl;
import com.qiwuai.garden.common.Constants; import com.qiwuai.garden.common.Constants;
import com.qiwuai.garden.common.TimingAcquisition; import com.qiwuai.garden.common.TimingAcquisition;
import com.qiwuai.garden.common.cache.CacheUtil;
import com.qiwuai.garden.common.utils.DateUtil; import com.qiwuai.garden.common.utils.DateUtil;
import com.qiwuai.garden.common.utils.TypeConvertUtil; import com.qiwuai.garden.common.utils.TypeConvertUtil;
import com.qiwuai.garden.common.utils.YamlUtil;
import com.qiwuai.garden.dao.NurseryMapper; import com.qiwuai.garden.dao.NurseryMapper;
import com.qiwuai.garden.dto.*; import com.qiwuai.garden.dto.*;
import com.qiwuai.garden.dto.base.CommonResponse; import com.qiwuai.garden.dto.base.CommonResponse;
...@@ -30,6 +32,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -30,6 +32,8 @@ public class NurseryServiceImpl implements NurseryService {
@Autowired @Autowired
private NurseryMapper nurseryMapper; private NurseryMapper nurseryMapper;
@Autowired
private YamlUtil yamlUtil;
@Override @Override
public List<NurseryPojo> findAll() { public List<NurseryPojo> findAll() {
...@@ -83,8 +87,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -83,8 +87,8 @@ public class NurseryServiceImpl implements NurseryService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100301); resultResponse.set反馈ID(100301);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -159,8 +163,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -159,8 +163,8 @@ public class NurseryServiceImpl implements NurseryService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100603); resultResponse.set反馈ID(100603);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -185,8 +189,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -185,8 +189,8 @@ public class NurseryServiceImpl implements NurseryService {
if (nurseryInfo.getUsable() != Constants.NURSERY_USABLE) { if (nurseryInfo.getUsable() != Constants.NURSERY_USABLE) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100602); resultResponse.set反馈ID(100602);
resultResponse.setText("花圃" + nurseryNum + "尚未开启"); resultResponse.set反馈文本("花圃" + nurseryNum + "尚未开启");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -194,8 +198,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -194,8 +198,8 @@ public class NurseryServiceImpl implements NurseryService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100603); resultResponse.set反馈ID(100603);
resultResponse.setText("花圃" + nurseryNum + "目前" + nursery.getLevel() + "级,类型为:" + nursery.getName()); resultResponse.set反馈文本("花圃" + nurseryNum + "目前" + nursery.getLevel() + "级,类型为:" + nursery.getName());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -210,13 +214,15 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -210,13 +214,15 @@ public class NurseryServiceImpl implements NurseryService {
String uid = operationReq.getUid(); String uid = operationReq.getUid();
Integer nurseryNum = operationReq.getNurseryNum(); Integer nurseryNum = operationReq.getNurseryNum();
//保存玩家这轮的请求信息,保留三分钟
CacheUtil.put(uid, operationReq, Long.parseLong(yamlUtil.getExpireTime()));
//判断花圃未开启时直接返回 //判断花圃未开启时直接返回
if (StringUtils.isEmpty(nurseryNum)) { if (StringUtils.isEmpty(nurseryNum)) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100603); resultResponse.set反馈ID(100603);
resultResponse.setText("升级哪个花圃呢?"); resultResponse.set反馈文本("升级哪个花圃呢?");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -233,8 +239,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -233,8 +239,8 @@ public class NurseryServiceImpl implements NurseryService {
if (nurseryInfo.getUsable() != Constants.NURSERY_USABLE) { if (nurseryInfo.getUsable() != Constants.NURSERY_USABLE) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100602); resultResponse.set反馈ID(100602);
resultResponse.setText(nurseryConfigMap.get(nurseryId).getName() + "尚未开启,无法升级"); resultResponse.set反馈文本(nurseryConfigMap.get(nurseryId).getName() + "尚未开启,无法升级");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -256,8 +262,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -256,8 +262,8 @@ public class NurseryServiceImpl implements NurseryService {
text.append(",升级为哪种类型的花圃呢?"); text.append(",升级为哪种类型的花圃呢?");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100601); resultResponse.set反馈ID(100601);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -282,8 +288,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -282,8 +288,8 @@ public class NurseryServiceImpl implements NurseryService {
if (StringUtils.isEmpty(nursery)) { if (StringUtils.isEmpty(nursery)) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100607); resultResponse.set反馈ID(100607);
resultResponse.setText("花圃类型不存在,请重新查询"); resultResponse.set反馈文本("花圃类型不存在,请重新查询");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -310,8 +316,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -310,8 +316,8 @@ public class NurseryServiceImpl implements NurseryService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100601); resultResponse.set反馈ID(100601);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -325,10 +331,17 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -325,10 +331,17 @@ public class NurseryServiceImpl implements NurseryService {
ResultResponse resultResponse = new ResultResponse(); ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid(); String uid = operationReq.getUid();
//当前花圃编号 //当前玩家上一轮的请求信息,存活时间为三分钟
Integer nurseryNum = operationReq.getNurseryNum(); OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid);
if (StringUtils.isEmpty(lastReq)) {
commonResponse.setCode(0);
commonResponse.setMsg("失败,对话超时");
return commonResponse;
}
//需要升级的花圃
Integer nurseryNum = lastReq.getNurseryNum();
//花圃升级目标 //花圃升级目标
Integer targetNurseryId = operationReq.getTargetNurseryId(); Integer targetNurseryId = operationReq.getNurseryId();
//当前花圃信息 //当前花圃信息
NurseryInfoDto nurseryInfo = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos().get(nurseryNum); NurseryInfoDto nurseryInfo = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos().get(nurseryNum);
...@@ -344,8 +357,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -344,8 +357,8 @@ public class NurseryServiceImpl implements NurseryService {
if (nurseryInfo.getUsable() != Constants.NURSERY_USABLE) { if (nurseryInfo.getUsable() != Constants.NURSERY_USABLE) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100602); resultResponse.set反馈ID(100602);
resultResponse.setText("花圃" + nurseryNum + "尚未开启,无法升级"); resultResponse.set反馈文本("花圃" + nurseryNum + "尚未开启,无法升级");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -355,8 +368,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -355,8 +368,8 @@ public class NurseryServiceImpl implements NurseryService {
log.info("已经升级过了哦"); log.info("已经升级过了哦");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100602); resultResponse.set反馈ID(100602);
resultResponse.setText("已经升级过了哦"); resultResponse.set反馈文本("已经升级过了哦");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -367,8 +380,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -367,8 +380,8 @@ public class NurseryServiceImpl implements NurseryService {
if (StringUtils.isEmpty(plantMap)) { if (StringUtils.isEmpty(plantMap)) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100605); resultResponse.set反馈ID(100605);
resultResponse.setText("花圃还未种植过,开始种你喜欢的吧!"); resultResponse.set反馈文本("花圃还未种植过,开始种你喜欢的吧!");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -384,8 +397,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -384,8 +397,8 @@ public class NurseryServiceImpl implements NurseryService {
if (StringUtils.isEmpty(planted)) { if (StringUtils.isEmpty(planted)) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100605); resultResponse.set反馈ID(100605);
resultResponse.setText("花圃还没有种植过" + plantPojoMap.get(plant.getPlantId()).getName()); resultResponse.set反馈文本("花圃还没有种植过" + plantPojoMap.get(plant.getPlantId()).getName());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -393,9 +406,9 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -393,9 +406,9 @@ public class NurseryServiceImpl implements NurseryService {
if (planted.getNumber() < plant.getNumber()) { if (planted.getNumber() < plant.getNumber()) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100605); resultResponse.set反馈ID(100605);
int sub = plant.getNumber() - planted.getNumber(); int sub = plant.getNumber() - planted.getNumber();
resultResponse.setText("花圃升级需要种植" + plantPojoMap.get(plant.getPlantId()).getName() + plant.getNumber() + resultResponse.set反馈文本("花圃升级需要种植" + plantPojoMap.get(plant.getPlantId()).getName() + plant.getNumber() +
"次,目前次数不足,还差" + sub + "次,先去多种种" + plantPojoMap.get(plant.getPlantId()).getName() + "吧!"); "次,目前次数不足,还差" + sub + "次,先去多种种" + plantPojoMap.get(plant.getPlantId()).getName() + "吧!");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
...@@ -422,8 +435,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -422,8 +435,8 @@ public class NurseryServiceImpl implements NurseryService {
if (StringUtils.isEmpty(material)) { if (StringUtils.isEmpty(material)) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100606); resultResponse.set反馈ID(100606);
resultResponse.setText("背包中还没有" + itemConfigMap.get(item.getItemId()).getName() + ",先去收集吧!"); resultResponse.set反馈文本("背包中还没有" + itemConfigMap.get(item.getItemId()).getName() + ",先去收集吧!");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -431,8 +444,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -431,8 +444,8 @@ public class NurseryServiceImpl implements NurseryService {
if (material.getItemNum() < item.getItemNum()) { if (material.getItemNum() < item.getItemNum()) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100606); resultResponse.set反馈ID(100606);
resultResponse.setText("升级需要消耗" + itemConfigMap.get(item.getItemId()).getName() + item.getItemNum() resultResponse.set反馈文本("升级需要消耗" + itemConfigMap.get(item.getItemId()).getName() + item.getItemNum()
+ "个,我们没有足够的" + itemConfigMap.get(item.getItemId()).getName() + item.getItemNum() + ",先去收集一点吧!"); + "个,我们没有足够的" + itemConfigMap.get(item.getItemId()).getName() + item.getItemNum() + ",先去收集一点吧!");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
...@@ -444,8 +457,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -444,8 +457,8 @@ public class NurseryServiceImpl implements NurseryService {
if (money.getItemNum() < targetNursery.getCost()) { if (money.getItemNum() < targetNursery.getCost()) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100606); resultResponse.set反馈ID(100606);
resultResponse.setText("升级需要消耗货币" + targetNursery.getCost() + "个,我们没有足够的" + itemConfigMap.get(Constants.MONEY).getName() + ",先去收集一点吧!"); resultResponse.set反馈文本("升级需要消耗货币" + targetNursery.getCost() + "个,我们没有足够的" + itemConfigMap.get(Constants.MONEY).getName() + ",先去收集一点吧!");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -467,8 +480,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -467,8 +480,8 @@ public class NurseryServiceImpl implements NurseryService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100601); resultResponse.set反馈ID(100601);
resultResponse.setText(nursery.getName() + "已经升级为" + targetNursery.getName()); resultResponse.set反馈文本(nursery.getName() + "已经升级为" + targetNursery.getName());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -488,14 +501,14 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -488,14 +501,14 @@ public class NurseryServiceImpl implements NurseryService {
//玩家花圃现有花圃总数量 //玩家花圃现有花圃总数量
int nurseryCount = nurseryInfoMap.size();; int nurseryCount = nurseryInfoMap.size();;
//园丁可拥有的花圃上限 //园丁可拥有的花圃上限
int nurseryMax = TimingAcquisition.gardenerMap.get(uid).getGarden().getMaxNumber(); int nurseryMax = TimingAcquisition.gardenerLevelMap.get(TimingAcquisition.gardenerMap.get(uid).getGardenerInfo().getLevel()).getNurseryNumMax();
//开启花圃数量已达到上限 //开启花圃数量已达到上限
if (nurseryCount == nurseryMax) { if (nurseryCount == nurseryMax) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100802); resultResponse.set反馈ID(100802);
resultResponse.setText("花圃数量已达上限,无法开启新花圃"); resultResponse.set反馈文本("花圃数量已达上限,无法开启新花圃");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -512,8 +525,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -512,8 +525,8 @@ public class NurseryServiceImpl implements NurseryService {
if (money.getItemNum() < nurseryReclaimMap.get(nurseryCount - 1).getCost()) { if (money.getItemNum() < nurseryReclaimMap.get(nurseryCount - 1).getCost()) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100803); resultResponse.set反馈ID(100803);
resultResponse.setText("您的游戏货币不足,无法开启新花圃"); resultResponse.set反馈文本("您的游戏货币不足,无法开启新花圃");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -530,8 +543,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -530,8 +543,8 @@ public class NurseryServiceImpl implements NurseryService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100803); resultResponse.set反馈ID(100803);
resultResponse.setText("已开启新的花圃,花圃编号:" + (nurseryCount + 1)); resultResponse.set反馈文本("已开启新的花圃,花圃编号:" + (nurseryCount + 1));
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -566,8 +579,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -566,8 +579,8 @@ public class NurseryServiceImpl implements NurseryService {
if (count == nurseryInfoMap.size()) { if (count == nurseryInfoMap.size()) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100705); resultResponse.set反馈ID(100705);
resultResponse.setText("没有可重置的花圃"); resultResponse.set反馈文本("没有可重置的花圃");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -577,8 +590,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -577,8 +590,8 @@ public class NurseryServiceImpl implements NurseryService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100706); resultResponse.set反馈ID(100706);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -593,6 +606,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -593,6 +606,8 @@ public class NurseryServiceImpl implements NurseryService {
String uid = operationReq.getUid(); String uid = operationReq.getUid();
Integer nurseryNum = operationReq.getNurseryNum(); Integer nurseryNum = operationReq.getNurseryNum();
//保存玩家这轮的请求信息,保留三分钟
CacheUtil.put(uid, operationReq, Long.parseLong(yamlUtil.getExpireTime()));
StringBuilder text = new StringBuilder(); StringBuilder text = new StringBuilder();
//玩家花圃信息 //玩家花圃信息
...@@ -611,8 +626,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -611,8 +626,8 @@ public class NurseryServiceImpl implements NurseryService {
if (nurseryInfo.getStatus() == Constants.PLANT_NO) { if (nurseryInfo.getStatus() == Constants.PLANT_NO) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100701); resultResponse.set反馈ID(100701);
resultResponse.setText("确定重置花圃" + nurseryNum + "号吗?需要花费" + resetCost + "个" + moneyConfig.getName()); resultResponse.set反馈文本("确定重置花圃" + nurseryNum + "号吗?需要花费" + resetCost + "个" + moneyConfig.getName());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -620,8 +635,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -620,8 +635,8 @@ public class NurseryServiceImpl implements NurseryService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100702); resultResponse.set反馈ID(100702);
resultResponse.setText("花圃" + nurseryNum + "号当前正在种植" + plant.getName() + ",重置花圃会清除正在种植的植物,确定重置" + resultResponse.set反馈文本("花圃" + nurseryNum + "号当前正在种植" + plant.getName() + ",重置花圃会清除正在种植的植物,确定重置" +
"花圃" + nurseryNum + "号吗?需要花费" + resetCost + "个" + moneyConfig.getName()); "花圃" + nurseryNum + "号吗?需要花费" + resetCost + "个" + moneyConfig.getName());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
...@@ -637,12 +652,20 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -637,12 +652,20 @@ public class NurseryServiceImpl implements NurseryService {
ResultResponse resultResponse = new ResultResponse(); ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid(); String uid = operationReq.getUid();
Integer nurseryNum = operationReq.getNurseryNum(); //当前玩家上一轮的请求信息,存活时间为三分钟
OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid);
if (StringUtils.isEmpty(lastReq)) {
commonResponse.setCode(0);
commonResponse.setMsg("失败,对话超时");
return commonResponse;
}
//需要重置的花圃
Integer nurseryNum = lastReq.getNurseryNum();
if (StringUtils.isEmpty(nurseryNum)) { if (StringUtils.isEmpty(nurseryNum)) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100705); resultResponse.set反馈ID(100705);
resultResponse.setText("需要重置哪个花圃呢?"); resultResponse.set反馈文本("需要重置哪个花圃呢?");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -654,8 +677,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -654,8 +677,8 @@ public class NurseryServiceImpl implements NurseryService {
if (nurseryInfo.getId() == Constants.NURSERY_INIT_ID) { if (nurseryInfo.getId() == Constants.NURSERY_INIT_ID) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100706); resultResponse.set反馈ID(100706);
resultResponse.setText("花圃已经重置过了哦"); resultResponse.set反馈文本("花圃已经重置过了哦");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -680,8 +703,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -680,8 +703,8 @@ public class NurseryServiceImpl implements NurseryService {
if (money.getItemNum() < resetCost) { if (money.getItemNum() < resetCost) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100703); resultResponse.set反馈ID(100703);
resultResponse.setText(moneyConfig.getName() + "不够,赚点钱再来重置吧?"); resultResponse.set反馈文本(moneyConfig.getName() + "不够,赚点钱再来重置吧?");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -706,8 +729,8 @@ public class NurseryServiceImpl implements NurseryService { ...@@ -706,8 +729,8 @@ public class NurseryServiceImpl implements NurseryService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100701); resultResponse.set反馈ID(100701);
resultResponse.setText("货币充足,已重置" + moneyConfig.getName() + ",要重新给这个花圃升级吗?还是要种点什么?"); resultResponse.set反馈文本("货币充足,已重置" + moneyConfig.getName() + ",要重新给这个花圃升级吗?还是要种点什么?");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
......
package com.qiwuai.garden.service.petService; package com.qiwuai.garden.service.petService;
import com.qiwuai.garden.dto.base.CommonResponse;
import com.qiwuai.garden.dto.request.OperationRequest;
public interface PetService { public interface PetService {
/** /**
* 宠物栏位查看 * 宠物栏位查看
* @param * @param
* @param * @param
*/ */
void petView(); CommonResponse petView(OperationRequest operationReq);
/** /**
* 宠物栏位移动 * 宠物移动
* @param * @param
* @param * @param
*/ */
void petMove(); CommonResponse petMove(OperationRequest operationReq);
/** /**
* 宠物栏位放生 * 宠物删除
* @param * @param
* @param * @param
*/ */
void petRelease(); CommonResponse petDelete(OperationRequest operationReq);
} }
package com.qiwuai.garden.service.petService.impl; package com.qiwuai.garden.service.petService.impl;
import com.qiwuai.garden.common.Constants;
import com.qiwuai.garden.common.TimingAcquisition;
import com.qiwuai.garden.dto.NurseryInfoDto;
import com.qiwuai.garden.dto.base.CommonResponse;
import com.qiwuai.garden.dto.base.ResultResponse;
import com.qiwuai.garden.dto.base.ResultVarsResponse;
import com.qiwuai.garden.dto.request.OperationRequest;
import com.qiwuai.garden.pojo.PetPojo;
import com.qiwuai.garden.pojo.PlantPojo;
import com.qiwuai.garden.service.petService.PetService; import com.qiwuai.garden.service.petService.PetService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service @Service
public class PetServiceImpl implements PetService { public class PetServiceImpl implements PetService {
private Logger log = LoggerFactory.getLogger(PetServiceImpl.class);
@Override @Override
public void petView() { public CommonResponse petView(OperationRequest operationReq) {
CommonResponse commonResponse = new CommonResponse();
ResultVarsResponse resultVarsResponse = new ResultVarsResponse();
ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid();
Integer petId = operationReq.getPetId();
if (StringUtils.isEmpty(petId)) {
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈文本("您还没告诉我宠物名字呢");
resultResponse.set反馈ID(300107);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
if (petId == Constants.REQ_NON) {
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈文本("没有您要找的宠物哦,不妨问问宠物都有哪些吧");
resultResponse.set反馈ID(300107);
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
log.info(uid + "开始查询宠物信息");
StringBuilder text = new StringBuilder();
//获取玩家所有花圃信息
Map<Integer, NurseryInfoDto> nurseryInfoMap = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos();
//获取玩家的宠物栏位
List<Integer> petList = TimingAcquisition.gardenerMap.get(uid).getPetFields();
//当前宠物配置信息
PetPojo petConfig = TimingAcquisition.petConfigMap.get(petId);
//植物配置信息
Map<Integer, PlantPojo> plantMap = TimingAcquisition.plantMap;
text.append(petConfig.getName()).append(",").append(petConfig.getDescription()).append(",");
int nurseryPetCount = 0; //花圃中宠物数量统计
int petCount = 0; //宠物栏中宠物数量统计
//花圃编号
List<String> nurseryNumList = new ArrayList<>();
//判断花圃中是否存在宠物
Iterator<Map.Entry<Integer, NurseryInfoDto>> iterator = nurseryInfoMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Integer, NurseryInfoDto> entry = iterator.next();
NurseryInfoDto nurseryInfo = entry.getValue();
if (petId.equals(nurseryInfo.getPetField())) {
nurseryPetCount++;
nurseryNumList.add(entry.getKey().toString());
}
}
//统计宠物栏中宠物的数量
if (!StringUtils.isEmpty(petList)) {
for (Integer id : petList) {
if (id.equals(petId)) {
petCount++;
}
}
}
//有且仅有一只该宠物在花圃中
if (nurseryPetCount == 1 && petCount == 0) {
text.append("现在在花圃").append(nurseryNumList.get(0)).append("中愉快的玩耍");
resultResponse.set反馈ID(300101);
}
//有且仅有一只该宠物在宠物栏中
if (nurseryPetCount == 0 && petCount == 1) {
text.append("现在在宠物栏中看家护院");
resultResponse.set反馈ID(300102);
}
//花圃和宠物栏中均没有该宠物
if (nurseryPetCount == 0 && petCount == 0) {
//宠物获取方式
StringBuilder plantNames = new StringBuilder();
String plantIds = petConfig.getFavoritePlantId();
String[] plantIdList = plantIds.split(",");
for (String plantId : plantIdList) {
plantNames.append(plantMap.get(Integer.parseInt(plantId)).getName()).append("、");
}
text.deleteCharAt(text.length() - 1);
text.append("我们还没有这个宠物,可以通过种植").append(plantNames).append(",以一定几率获得");
}
//仅宠物栏有多只该宠物
if (nurseryPetCount == 0 && petCount > 1) {
text.append("有").append(petCount).append("只在宠物栏中看家护院");
resultResponse.set反馈ID(300104);
}
//花圃和宠物栏均有该宠物
if (nurseryPetCount >= 1 && petCount >= 1) {
text.append("有").append(petCount).append("只在宠物栏中看家护院");
text.append("有").append(nurseryPetCount).append(",只在花圃");
String s = String.join("、", nurseryNumList);
text.append(s).append("中愉快的玩耍");
resultResponse.set反馈ID(300105);
}
//仅花圃有多只该宠物
if (nurseryPetCount > 1 && petCount == 0) {
text.append("有").append(nurseryPetCount).append("只在花圃");
String s = String.join("、", nurseryNumList);
text.append(s).append("中愉快的玩耍");
resultResponse.set反馈ID(300106);
}
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
} }
@Override @Override
public void petMove() { public CommonResponse petMove(OperationRequest operationReq) {
CommonResponse commonResponse = new CommonResponse();
ResultVarsResponse resultVarsResponse = new ResultVarsResponse();
ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid();
Integer petId = operationReq.getPetId();
Integer nurseryNum = operationReq.getNurseryNum();
Integer nurseryPos = operationReq.getNurseryPos();
PetPojo petConfig = new PetPojo();
log.info(uid + "开始移动宠物");
//有花圃编号,但格式不符合规范
if (!StringUtils.isEmpty(nurseryNum)) {
if (nurseryNum.equals(Constants.REQ_NON)) {
commonResponse.setCode(0);
commonResponse.setMsg("失败,请检查传参");
return commonResponse;
}
}
//有花圃位置,但格式不符合规范
if (!StringUtils.isEmpty(nurseryPos)) {
if (nurseryPos.equals(Constants.REQ_NON)) {
commonResponse.setCode(0);
commonResponse.setMsg("失败,请检查传参");
return commonResponse;
}
}
//获取玩家所有花圃信息
Map<Integer, NurseryInfoDto> nurseryInfoMap = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos();
//获取玩家的宠物栏位
List<Integer> petList = TimingAcquisition.gardenerMap.get(uid).getPetFields();
//当前宠物配置信息
if (!StringUtils.isEmpty(petId)) {
petConfig = TimingAcquisition.petConfigMap.get(petId);
}
//宠物栏为空时,初始化宠物栏
if (StringUtils.isEmpty(petList)) {
petList = new ArrayList<>();
TimingAcquisition.gardenerMap.get(uid).setPetFields(petList);
petList = TimingAcquisition.gardenerMap.get(uid).getPetFields();
}
//宠物从宠物栏位移动到花圃
if (!StringUtils.isEmpty(nurseryNum) && StringUtils.isEmpty(nurseryPos)) {
//宠物栏中宠物不存在
if (!petList.contains(petId)) {
log.info("宠物栏中还没有" + petConfig.getName());
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(300307);
resultResponse.set反馈文本("宠物栏中还没有" + petConfig.getName());
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//花圃中没有宠物,可移动
if (StringUtils.isEmpty(nurseryInfoMap.get(nurseryNum).getPetField())) {
//花圃增加宠物
nurseryInfoMap.get(nurseryNum).setPetField(petId);
//宠物栏减少一只宠物,采用迭代器安全性更高
Iterator<Integer> iterator = petList.iterator();
while (iterator.hasNext()) {
Integer pet = iterator.next();
if (petId.equals(pet)) {
iterator.remove();
break;
}
}
resultResponse.set反馈ID(300301);
resultResponse.set反馈文本(petConfig.getName() + "已经移动至花圃,它很高兴");
log.info(petConfig.getName() + "已经移动至花圃,它很高兴");
} else { //花圃中已有宠物,不可移动
resultResponse.set反馈ID(300302);
resultResponse.set反馈文本("无法移动,这个花圃里已经有宠物了");
}
}
//宠物从花圃移动到宠物栏位
if (StringUtils.isEmpty(nurseryNum) && StringUtils.isEmpty(nurseryPos)) {
List<Integer> petIdList = nurseryInfoMap.values().stream().map(NurseryInfoDto::getPetField).collect(Collectors.toList());
//花圃中宠物不存在
if (!petIdList.contains(petId)) {
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(300308);
resultResponse.set反馈文本("花圃中还没有" + petConfig.getName());
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//园丁宠物栏存放上限
int petNumMax = TimingAcquisition.gardenerLevelMap.get(TimingAcquisition.gardenerMap.get(uid).getGardenerInfo().getLevel()).getPetNumMax();
//宠物栏未满,可移动
if (petList.size() < petNumMax) {
petList.add(petId);
for (NurseryInfoDto nurseryInfo : nurseryInfoMap.values()) {
if (petId.equals(nurseryInfo.getPetField())) {
nurseryInfo.setPetField(null);
break;
}
}
resultResponse.set反馈ID(300303);
resultResponse.set反馈文本(petConfig.getName() + "已经回到宠物栏了,它会好好看家");
} else { //宠物栏已满
resultResponse.set反馈ID(300304);
resultResponse.set反馈文本("无法移动,宠物栏已经满了,想办法留个位置出来吧");
}
}
//宠物从花圃nurseryPos移动到另一花圃nurseryNum中
if (!StringUtils.isEmpty(nurseryNum) && !StringUtils.isEmpty(nurseryPos)) {
//花圃中没有宠物
if (StringUtils.isEmpty(nurseryInfoMap.get(nurseryPos).getPetField())) {
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(300308);
resultResponse.set反馈文本("花圃" + nurseryPos + "中还没有宠物哦");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//花圃中宠物不存在要移动的宠物
if (!StringUtils.isEmpty(petId)) {
if (!petId.equals(nurseryInfoMap.get(nurseryPos).getPetField())) {
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(300309);
resultResponse.set反馈文本("花圃" + nurseryPos + "中的宠物不是" + petConfig.getName() + "哦");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
}
//花圃中没有宠物,可移动
if (StringUtils.isEmpty(nurseryInfoMap.get(nurseryNum).getPetField())) {
//取出宠物位置中的宠物id
Integer id = nurseryInfoMap.get(nurseryPos).getPetField();
//移动到花圃中
nurseryInfoMap.get(nurseryNum).setPetField(id);
nurseryInfoMap.get(nurseryPos).setPetField(null);
resultResponse.set反馈ID(300305);
resultResponse.set反馈文本(TimingAcquisition.petConfigMap.get(id).getName() + "已经移动至花圃" + nurseryNum + ",它很高兴");
} else { //花圃中已有宠物,不可移动
resultResponse.set反馈ID(300306);
resultResponse.set反馈文本("无法移动,这个花圃里已经有宠物了");
}
}
log.info(uid + "宠物移动操作结束");
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
} }
@Override @Override
public void petRelease() { public CommonResponse petDelete(OperationRequest operationReq) {
CommonResponse commonResponse = new CommonResponse();
ResultVarsResponse resultVarsResponse = new ResultVarsResponse();
ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid();
Integer petId = operationReq.getPetId(); //宠物id
Integer nurseryNum = operationReq.getNurseryNum(); //花圃编号
//获取玩家所有花圃信息
Map<Integer, NurseryInfoDto> nurseryInfoMap = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos();
//获取玩家的宠物栏位
List<Integer> petList = TimingAcquisition.gardenerMap.get(uid).getPetFields();
//宠物栏为空时,初始化宠物栏
if (StringUtils.isEmpty(petList)) {
petList = new ArrayList<>();
TimingAcquisition.gardenerMap.get(uid).setPetFields(petList);
petList = TimingAcquisition.gardenerMap.get(uid).getPetFields();
}
//有指明宠物
if (!StringUtils.isEmpty(petId)) {
if (petId.equals(Constants.REQ_NON)) {
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(300405);
resultResponse.set反馈文本("没有找到该宠物哦");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
}
//删除指定宠物,优先删除花圃中的宠物
if (!StringUtils.isEmpty(petId) && StringUtils.isEmpty(nurseryNum)) {
//宠物在花圃中
List<Integer> petIdList = nurseryInfoMap.values().stream().map(NurseryInfoDto::getPetField).collect(Collectors.toList());
PetPojo petConfig = TimingAcquisition.petConfigMap.get(petId); //宠物信息
if (petIdList.contains(petId)) { //宠物在花圃中
for (Map.Entry<Integer, NurseryInfoDto> entry : nurseryInfoMap.entrySet()) {
NurseryInfoDto nurseryInfo = entry.getValue();
if (petId.equals(nurseryInfo.getPetField())) {
resultResponse.set反馈ID(300401);
resultResponse.set反馈文本(petConfig.getName() + "在花圃" + entry.getKey() + "中玩耍,确定要让它离开吗?");
resultResponse.set后台附加返回("宠物删除回复1");
break;
}
}
} else { //宠物在宠物栏中
for (Integer pet : petList) {
if (petId.equals(pet)) {
resultResponse.set反馈ID(300401);
resultResponse.set反馈文本(petConfig.getName() + "在宠物栏中看家护院,确定要让它离开吗?");
resultResponse.set后台附加返回("宠物删除回复1");
break;
}
}
}
if (!petIdList.contains(petId) && !petList.contains(petId)) {
resultResponse.set反馈ID(300402);
resultResponse.set反馈文本("没有这个宠物");
}
}
//删除指定花圃中的宠物
if (!StringUtils.isEmpty(nurseryNum)) {
NurseryInfoDto nurseryInfo = nurseryInfoMap.get(nurseryNum);
//玩家还没有该花圃编号
if (StringUtils.isEmpty(nurseryInfo)) {
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultResponse.set反馈ID(300405);
resultResponse.set反馈文本("花圃" + nurseryNum + "目前还没有哦");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
}
//有指明宠物名称时,判断花圃中的宠物名称是否跟指明的一样
}
commonResponse.setCode(1);
commonResponse.setMsg("成功");
resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);
return commonResponse;
} }
} }
...@@ -3,9 +3,12 @@ package com.qiwuai.garden.service.plantService.impl; ...@@ -3,9 +3,12 @@ package com.qiwuai.garden.service.plantService.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.qiwuai.garden.common.Constants; import com.qiwuai.garden.common.Constants;
import com.qiwuai.garden.common.TimingAcquisition; import com.qiwuai.garden.common.TimingAcquisition;
import com.qiwuai.garden.common.cache.CacheUtil;
import com.qiwuai.garden.common.cache.MyCache;
import com.qiwuai.garden.common.utils.DateUtil; import com.qiwuai.garden.common.utils.DateUtil;
import com.qiwuai.garden.common.utils.PersistenceUtil; import com.qiwuai.garden.common.utils.PersistenceUtil;
import com.qiwuai.garden.common.utils.TypeConvertUtil; import com.qiwuai.garden.common.utils.TypeConvertUtil;
import com.qiwuai.garden.common.utils.YamlUtil;
import com.qiwuai.garden.dao.PlantAttributeMapper; import com.qiwuai.garden.dao.PlantAttributeMapper;
import com.qiwuai.garden.dao.PlantMapper; import com.qiwuai.garden.dao.PlantMapper;
import com.qiwuai.garden.dao.PlantPeriodMapper; import com.qiwuai.garden.dao.PlantPeriodMapper;
...@@ -42,6 +45,9 @@ public class PlantServiceImpl implements PlantService { ...@@ -42,6 +45,9 @@ public class PlantServiceImpl implements PlantService {
@Autowired @Autowired
private PlantAttributeMapper plantAttributeMapper; private PlantAttributeMapper plantAttributeMapper;
@Autowired
private YamlUtil yamlUtil;
public List<PlantPojo> plantSearch() { public List<PlantPojo> plantSearch() {
List<PlantPojo> plantList = plantMapper.searchAll(); List<PlantPojo> plantList = plantMapper.searchAll();
return plantList; return plantList;
...@@ -93,8 +99,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -93,8 +99,8 @@ public class PlantServiceImpl implements PlantService {
log.info("种植失败,花圃不存在"); log.info("种植失败,花圃不存在");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100101); resultResponse.set反馈ID(100101);
resultResponse.setText("花圃不存在哦"); resultResponse.set反馈文本("花圃不存在哦");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -114,8 +120,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -114,8 +120,8 @@ public class PlantServiceImpl implements PlantService {
log.info("背包中没有该种子"); log.info("背包中没有该种子");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100102); resultResponse.set反馈ID(100102);
resultResponse.setText("背包中没有" + itemPojo.getName() + "哦"); resultResponse.set反馈文本("背包中没有" + itemPojo.getName() + "哦");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -125,8 +131,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -125,8 +131,8 @@ public class PlantServiceImpl implements PlantService {
log.info("种植失败,花圃已种满"); log.info("种植失败,花圃已种满");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100104); resultResponse.set反馈ID(100104);
resultResponse.setText("这里已经种满了,找个空地来种吧!"); resultResponse.set反馈文本("这里已经种满了,找个空地来种吧!");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -138,8 +144,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -138,8 +144,8 @@ public class PlantServiceImpl implements PlantService {
log.info("种植失败,种子数量不够"); log.info("种植失败,种子数量不够");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100103); resultResponse.set反馈ID(100103);
resultResponse.setText("种子数量没法种满花圃,收集足够多的种子吧!"); resultResponse.set反馈文本("种子数量没法种满花圃,收集足够多的种子吧!");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -150,8 +156,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -150,8 +156,8 @@ public class PlantServiceImpl implements PlantService {
log.info("种植失败,花圃等级不够"); log.info("种植失败,花圃等级不够");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100105); resultResponse.set反馈ID(100105);
resultResponse.setText("花圃等级不足,先升级你的花圃吧!"); resultResponse.set反馈文本("花圃等级不足,先升级你的花圃吧!");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -171,8 +177,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -171,8 +177,8 @@ public class PlantServiceImpl implements PlantService {
text.append("上种植"); text.append("上种植");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100106); resultResponse.set反馈ID(100106);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -189,8 +195,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -189,8 +195,8 @@ public class PlantServiceImpl implements PlantService {
log.info("种植失败,园丁没有种植该植物的技能"); log.info("种植失败,园丁没有种植该植物的技能");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100111); resultResponse.set反馈ID(100111);
resultResponse.setText("需要园丁学习" + skillInfo.getName() + "才可种植" + plant.getName()); resultResponse.set反馈文本("需要园丁学习" + skillInfo.getName() + "才可种植" + plant.getName());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -209,8 +215,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -209,8 +215,8 @@ public class PlantServiceImpl implements PlantService {
log.info("种植失败,花园中没有" + plantName); log.info("种植失败,花园中没有" + plantName);
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100108); resultResponse.set反馈ID(100108);
resultResponse.setText("需要在其他花圃中种植" + plantName + "才能种植" + plant.getName()); resultResponse.set反馈文本("需要在其他花圃中种植" + plantName + "才能种植" + plant.getName());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -226,8 +232,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -226,8 +232,8 @@ public class PlantServiceImpl implements PlantService {
log.info("种植失败,花圃中没有指定宠物" + petName); log.info("种植失败,花圃中没有指定宠物" + petName);
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100109); resultResponse.set反馈ID(100109);
resultResponse.setText("种植" + plant.getName() + "需要有" + petName + "在花圃中陪伴,现在无法种植"); resultResponse.set反馈文本("种植" + plant.getName() + "需要有" + petName + "在花圃中陪伴,现在无法种植");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -254,8 +260,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -254,8 +260,8 @@ public class PlantServiceImpl implements PlantService {
log.info("种植失败,背包没有" + item.getItemId() + "的材料"); log.info("种植失败,背包没有" + item.getItemId() + "的材料");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100114); resultResponse.set反馈ID(100114);
resultResponse.setText("背包没有" + materialName + "的材料"); resultResponse.set反馈文本("背包没有" + materialName + "的材料");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -266,8 +272,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -266,8 +272,8 @@ public class PlantServiceImpl implements PlantService {
log.info("种植失败,背包中" + item.getItemId() + "的材料数量不足"); log.info("种植失败,背包中" + item.getItemId() + "的材料数量不足");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100107); resultResponse.set反馈ID(100107);
resultResponse.setText(materialName + "不够" + "需要消耗" + item.getItemNum() + "个才能种植" + plant.getName()); resultResponse.set反馈文本(materialName + "不够" + "需要消耗" + item.getItemNum() + "个才能种植" + plant.getName());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -286,7 +292,7 @@ public class PlantServiceImpl implements PlantService { ...@@ -286,7 +292,7 @@ public class PlantServiceImpl implements PlantService {
PlantDto plantNew = new PlantDto(); PlantDto plantNew = new PlantDto();
nurseryInfo.setPlantId(plantId); nurseryInfo.setPlantId(plantId);
Integer plantNumber = nurseryConfig.getCapacity()/plant.getOccupyArea(); Integer plantNumber = nurseryConfig.getCapacity()/plant.getOccupyArea();
nurseryInfo.setNumber(plantNumber); nurseryInfo.set反馈ID(plantNumber);
nurseryInfo.setSeedingTime(DateUtil.getCurrentTime()); nurseryInfo.setSeedingTime(DateUtil.getCurrentTime());
nurseryInfo.setStatus(Constants.PLANT_SEEDING); //花圃为播种期 nurseryInfo.setStatus(Constants.PLANT_SEEDING); //花圃为播种期
nurseryInfo.setFruitTimes(plant.getFruitTimes()); //结果次数重置为当前植物的结果次数 nurseryInfo.setFruitTimes(plant.getFruitTimes()); //结果次数重置为当前植物的结果次数
...@@ -304,8 +310,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -304,8 +310,8 @@ public class PlantServiceImpl implements PlantService {
String nurseryName = TimingAcquisition.nurseryConfigMap.get(nurseryInfo.getId()).getName(); String nurseryName = TimingAcquisition.nurseryConfigMap.get(nurseryInfo.getId()).getName();
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100102); resultResponse.set反馈ID(100102);
resultResponse.setText("已经在" + nurseryName + "上播种了" + plant.getName() + ",后面就交给我来照看吧!"); resultResponse.set反馈文本("已经在" + nurseryName + "上播种了" + plant.getName() + ",后面就交给我来照看吧!");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -355,8 +361,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -355,8 +361,8 @@ public class PlantServiceImpl implements PlantService {
if (!plantIdList.contains(plantId)) { if (!plantIdList.contains(plantId)) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100203); resultResponse.set反馈ID(100203);
resultResponse.setText("您还没有种植" + plantConfigMap.get(plantId).getName()); resultResponse.set反馈文本("您还没有种植" + plantConfigMap.get(plantId).getName());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -381,8 +387,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -381,8 +387,8 @@ public class PlantServiceImpl implements PlantService {
if (fruitList.size() == 0) { if (fruitList.size() == 0) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100202); resultResponse.set反馈ID(100202);
resultResponse.setText(plantConfigMap.get(plantId).getName() + "尚未成熟,请耐心等待"); resultResponse.set反馈文本(plantConfigMap.get(plantId).getName() + "尚未成熟,请耐心等待");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -405,8 +411,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -405,8 +411,8 @@ public class PlantServiceImpl implements PlantService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100201); resultResponse.set反馈ID(100201);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -419,8 +425,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -419,8 +425,8 @@ public class PlantServiceImpl implements PlantService {
if (nurseryInfo.getUsable() == Constants.NURSERY_UNUSABLE) { if (nurseryInfo.getUsable() == Constants.NURSERY_UNUSABLE) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100207); resultResponse.set反馈ID(100207);
resultResponse.setText(nurseryConfigMap.get(nurseryId).getName() + "尚未开启"); resultResponse.set反馈文本(nurseryConfigMap.get(nurseryId).getName() + "尚未开启");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -429,8 +435,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -429,8 +435,8 @@ public class PlantServiceImpl implements PlantService {
if (nurseryInfo.getStatus() == Constants.PLANT_NO) { if (nurseryInfo.getStatus() == Constants.PLANT_NO) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100206); resultResponse.set反馈ID(100206);
resultResponse.setText(nurseryConfigMap.get(nurseryId).getName() + "中还没有种植植物,种点什么吧"); resultResponse.set反馈文本(nurseryConfigMap.get(nurseryId).getName() + "中还没有种植植物,种点什么吧");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -439,8 +445,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -439,8 +445,8 @@ public class PlantServiceImpl implements PlantService {
if (nurseryInfo.getStatus() != Constants.PLANT_MATURE) { if (nurseryInfo.getStatus() != Constants.PLANT_MATURE) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100205); resultResponse.set反馈ID(100205);
resultResponse.setText(nurseryConfigMap.get(nurseryId).getName() + "中的植物尚未成熟,请耐心等待"); resultResponse.set反馈文本(nurseryConfigMap.get(nurseryId).getName() + "中的植物尚未成熟,请耐心等待");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -465,8 +471,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -465,8 +471,8 @@ public class PlantServiceImpl implements PlantService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100201); resultResponse.set反馈ID(100201);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -499,8 +505,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -499,8 +505,8 @@ public class PlantServiceImpl implements PlantService {
if (fruitList.size() == 0) { if (fruitList.size() == 0) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100209); resultResponse.set反馈ID(100209);
resultResponse.setText("目前还没有成熟的植物,请耐心等待"); resultResponse.set反馈文本("目前还没有成熟的植物,请耐心等待");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -509,8 +515,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -509,8 +515,8 @@ public class PlantServiceImpl implements PlantService {
if (count == nurseryInfoMap.size()) { if (count == nurseryInfoMap.size()) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100210); resultResponse.set反馈ID(100210);
resultResponse.setText("还没有种"); resultResponse.set反馈文本("还没有种");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -533,8 +539,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -533,8 +539,8 @@ public class PlantServiceImpl implements PlantService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100208); resultResponse.set反馈ID(100208);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);; commonResponse.setData(resultVarsResponse);;
return commonResponse; return commonResponse;
...@@ -546,8 +552,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -546,8 +552,8 @@ public class PlantServiceImpl implements PlantService {
if (nurseryInfo.getUsable() == Constants.NURSERY_UNUSABLE) { if (nurseryInfo.getUsable() == Constants.NURSERY_UNUSABLE) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100207); resultResponse.set反馈ID(100207);
resultResponse.setText(nurseryConfigMap.get(nurseryId).getName() + "尚未开启"); resultResponse.set反馈文本(nurseryConfigMap.get(nurseryId).getName() + "尚未开启");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -557,8 +563,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -557,8 +563,8 @@ public class PlantServiceImpl implements PlantService {
if (nurseryInfo.getStatus() == Constants.PLANT_NO) { if (nurseryInfo.getStatus() == Constants.PLANT_NO) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100206); resultResponse.set反馈ID(100206);
resultResponse.setText(nurseryConfigMap.get(nurseryId).getName() + "中还没有种植植物,种点什么吧"); resultResponse.set反馈文本(nurseryConfigMap.get(nurseryId).getName() + "中还没有种植植物,种点什么吧");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -567,8 +573,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -567,8 +573,8 @@ public class PlantServiceImpl implements PlantService {
if (!plantId.equals(nurseryInfo.getPlantId())) { if (!plantId.equals(nurseryInfo.getPlantId())) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100203); resultResponse.set反馈ID(100203);
resultResponse.setText(nurseryConfigMap.get(nurseryId).getName() + "没有种植" + plantConfig.getName()); resultResponse.set反馈文本(nurseryConfigMap.get(nurseryId).getName() + "没有种植" + plantConfig.getName());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse);; commonResponse.setData(resultVarsResponse);;
return commonResponse; return commonResponse;
...@@ -577,8 +583,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -577,8 +583,8 @@ public class PlantServiceImpl implements PlantService {
if (nurseryInfo.getStatus() != Constants.PLANT_MATURE) { if (nurseryInfo.getStatus() != Constants.PLANT_MATURE) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100205); resultResponse.set反馈ID(100205);
resultResponse.setText(nurseryConfigMap.get(nurseryId).getName() + "中的植物尚未成熟,请耐心等待"); resultResponse.set反馈文本(nurseryConfigMap.get(nurseryId).getName() + "中的植物尚未成熟,请耐心等待");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -603,8 +609,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -603,8 +609,8 @@ public class PlantServiceImpl implements PlantService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100211); resultResponse.set反馈ID(100211);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -620,6 +626,9 @@ public class PlantServiceImpl implements PlantService { ...@@ -620,6 +626,9 @@ public class PlantServiceImpl implements PlantService {
String uid = operationReq.getUid(); String uid = operationReq.getUid();
Integer nurseryNum = operationReq.getNurseryNum(); Integer nurseryNum = operationReq.getNurseryNum();
//保存玩家这轮的请求信息,保留三分钟
CacheUtil.put(uid, operationReq, Long.parseLong(yamlUtil.getExpireTime()));
//获取该玩家的对应花圃 //获取该玩家的对应花圃
NurseryInfoDto nurseryInfo = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos().get(nurseryNum); NurseryInfoDto nurseryInfo = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos().get(nurseryNum);
//该花圃配置信息 //该花圃配置信息
...@@ -631,8 +640,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -631,8 +640,8 @@ public class PlantServiceImpl implements PlantService {
if (StringUtils.isEmpty(nurseryInfo.getPlantId()) || nurseryInfo.getStatus() == Constants.PLANT_NO) { if (StringUtils.isEmpty(nurseryInfo.getPlantId()) || nurseryInfo.getStatus() == Constants.PLANT_NO) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100502); resultResponse.set反馈ID(100502);
resultResponse.setText(nurseryConfig.getName() + "已经是空地了,种点什么吧!"); resultResponse.set反馈文本(nurseryConfig.getName() + "已经是空地了,种点什么吧!");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -642,8 +651,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -642,8 +651,8 @@ public class PlantServiceImpl implements PlantService {
if (nurseryInfo.getStatus() != Constants.PLANT_MATURE) { if (nurseryInfo.getStatus() != Constants.PLANT_MATURE) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100501); resultResponse.set反馈ID(100501);
resultResponse.setText("清除" + nurseryConfig.getName() + "上的植物将其变为空地,确定吗?需要消费" + clearCost.getValue()); resultResponse.set反馈文本("清除" + nurseryConfig.getName() + "上的植物将其变为空地,确定吗?需要消费" + clearCost.getValue());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -652,8 +661,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -652,8 +661,8 @@ public class PlantServiceImpl implements PlantService {
//花圃中的植物已成熟 //花圃中的植物已成熟
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100503); resultResponse.set反馈ID(100503);
resultResponse.setText(nurseryConfig.getName() + "的植物已成熟,可以先收取果实再铲除,确定吗?需要消费" + clearCost.getValue()); resultResponse.set反馈文本(nurseryConfig.getName() + "的植物已成熟,可以先收取果实再铲除,确定吗?需要消费" + clearCost.getValue());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -667,7 +676,15 @@ public class PlantServiceImpl implements PlantService { ...@@ -667,7 +676,15 @@ public class PlantServiceImpl implements PlantService {
ResultResponse resultResponse = new ResultResponse(); ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid(); String uid = operationReq.getUid();
Integer nurseryNum = operationReq.getNurseryNum(); //当前玩家上一轮的请求信息,存活时间为三分钟
OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid);
if (StringUtils.isEmpty(lastReq)) {
commonResponse.setCode(0);
commonResponse.setMsg("失败,对话超时");
return commonResponse;
}
//需要取消种植的花圃
Integer nurseryNum = lastReq.getNurseryNum();
//获取该玩家的对应花圃 //获取该玩家的对应花圃
NurseryInfoDto nurseryInfo = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos().get(nurseryNum); NurseryInfoDto nurseryInfo = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos().get(nurseryNum);
...@@ -677,8 +694,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -677,8 +694,8 @@ public class PlantServiceImpl implements PlantService {
if (nurseryInfo.getStatus() == Constants.PLANT_NO) { if (nurseryInfo.getStatus() == Constants.PLANT_NO) {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100505); resultResponse.set反馈ID(100505);
resultResponse.setText(nurseryConfig.getName() + "现在是空地了,种点什么吧!"); resultResponse.set反馈文本(nurseryConfig.getName() + "现在是空地了,种点什么吧!");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -694,8 +711,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -694,8 +711,8 @@ public class PlantServiceImpl implements PlantService {
if (money < Integer.parseInt(clearCost.getValue())) { //背包的货币不够 if (money < Integer.parseInt(clearCost.getValue())) { //背包的货币不够
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100506); resultResponse.set反馈ID(100506);
resultResponse.setText("背包中的货币不够,铲除植物失败"); resultResponse.set反馈文本("背包中的货币不够,铲除植物失败");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -706,7 +723,7 @@ public class PlantServiceImpl implements PlantService { ...@@ -706,7 +723,7 @@ public class PlantServiceImpl implements PlantService {
nurseryInfo.setStatus(0); nurseryInfo.setStatus(0);
nurseryInfo.setPlantId(null); nurseryInfo.setPlantId(null);
nurseryInfo.setSeedingTime(null); nurseryInfo.setSeedingTime(null);
nurseryInfo.setNumber(0); nurseryInfo.set反馈ID(0);
nurseryInfo.setFruitTimes(0); nurseryInfo.setFruitTimes(0);
nurseryInfo.setHarvestFruit(null); nurseryInfo.setHarvestFruit(null);
nurseryInfo.setDropItems(null); nurseryInfo.setDropItems(null);
...@@ -716,8 +733,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -716,8 +733,8 @@ public class PlantServiceImpl implements PlantService {
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100505); resultResponse.set反馈ID(100505);
resultResponse.setText(nurseryConfig.getName() + "现在是空地了,种点什么吧!"); resultResponse.set反馈文本(nurseryConfig.getName() + "现在是空地了,种点什么吧!");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -731,7 +748,14 @@ public class PlantServiceImpl implements PlantService { ...@@ -731,7 +748,14 @@ public class PlantServiceImpl implements PlantService {
ResultResponse resultResponse = new ResultResponse(); ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid(); String uid = operationReq.getUid();
Integer nurseryNum = operationReq.getNurseryNum(); //出去玩家上一轮的请求信息,存活时间为三分钟
OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid);
if (StringUtils.isEmpty(lastReq)) {
commonResponse.setCode(0);
commonResponse.setMsg("失败,对话超时");
return commonResponse;
}
Integer nurseryNum = lastReq.getNurseryNum();
//花圃配置信息 //花圃配置信息
Map<Integer, NurseryPojo> nurseryConfigMap = TimingAcquisition.nurseryConfigMap; Map<Integer, NurseryPojo> nurseryConfigMap = TimingAcquisition.nurseryConfigMap;
...@@ -747,8 +771,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -747,8 +771,8 @@ public class PlantServiceImpl implements PlantService {
log.info(nurseryConfigMap.get(nurseryId).getName() + "现在是空地"); log.info(nurseryConfigMap.get(nurseryId).getName() + "现在是空地");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100504); resultResponse.set反馈ID(100504);
resultResponse.setText(nurseryConfigMap.get(nurseryId).getName() + "现在是空地,种点什么吧"); resultResponse.set反馈文本(nurseryConfigMap.get(nurseryId).getName() + "现在是空地,种点什么吧");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -760,8 +784,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -760,8 +784,8 @@ public class PlantServiceImpl implements PlantService {
log.info(nurseryConfigMap.get(nurseryId).getName() + "的植物尚未成熟,请稍后收取"); log.info(nurseryConfigMap.get(nurseryId).getName() + "的植物尚未成熟,请稍后收取");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100507); resultResponse.set反馈ID(100507);
resultResponse.setText(nurseryConfigMap.get(nurseryId).getName() + "的植物尚未成熟,请稍后收取"); resultResponse.set反馈文本(nurseryConfigMap.get(nurseryId).getName() + "的植物尚未成熟,请稍后收取");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -786,8 +810,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -786,8 +810,8 @@ public class PlantServiceImpl implements PlantService {
text.append(",背包中的货币不够,铲除植物失败"); text.append(",背包中的货币不够,铲除植物失败");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100506); resultResponse.set反馈ID(100506);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -796,8 +820,8 @@ public class PlantServiceImpl implements PlantService { ...@@ -796,8 +820,8 @@ public class PlantServiceImpl implements PlantService {
text.append(",").append(nurseryConfigMap.get(nurseryId).getName()).append("的果实已收取,并且清除了植物,现在是空地,种点什么吧"); text.append(",").append(nurseryConfigMap.get(nurseryId).getName()).append("的果实已收取,并且清除了植物,现在是空地,种点什么吧");
commonResponse.setCode(1); commonResponse.setCode(1);
commonResponse.setMsg("成功"); commonResponse.setMsg("成功");
resultResponse.setNumber(100504); resultResponse.set反馈ID(100504);
resultResponse.setText(text.toString()); resultResponse.set反馈文本(text.toString());
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
commonResponse.setData(resultVarsResponse); commonResponse.setData(resultVarsResponse);
return commonResponse; return commonResponse;
...@@ -929,7 +953,7 @@ public class PlantServiceImpl implements PlantService { ...@@ -929,7 +953,7 @@ public class PlantServiceImpl implements PlantService {
plantMap = new ConcurrentHashMap<>(); plantMap = new ConcurrentHashMap<>();
PlantDto plantDto = new PlantDto(); PlantDto plantDto = new PlantDto();
plantDto.setPlantId(nurseryInfo.getPlantId()); plantDto.setPlantId(nurseryInfo.getPlantId());
plantDto.setNumber(1); plantDto.set反馈ID(1);
plantMap.put(plantDto.getPlantId(), plantDto); plantMap.put(plantDto.getPlantId(), plantDto);
nurseryInfo.setPlantIdTimes(plantMap); nurseryInfo.setPlantIdTimes(plantMap);
} else { } else {
...@@ -937,10 +961,10 @@ public class PlantServiceImpl implements PlantService { ...@@ -937,10 +961,10 @@ public class PlantServiceImpl implements PlantService {
if (StringUtils.isEmpty(plant)) { if (StringUtils.isEmpty(plant)) {
plant = new PlantDto(); plant = new PlantDto();
plant.setPlantId(nurseryInfo.getPlantId()); plant.setPlantId(nurseryInfo.getPlantId());
plant.setNumber(1); plant.set反馈ID(1);
plantMap.put(plant.getPlantId(), plant); plantMap.put(plant.getPlantId(), plant);
} else { } else {
plant.setNumber(plant.getNumber() + 1); plant.set反馈ID(plant.getNumber() + 1);
} }
} }
} }
...@@ -1070,7 +1094,7 @@ public class PlantServiceImpl implements PlantService { ...@@ -1070,7 +1094,7 @@ public class PlantServiceImpl implements PlantService {
nurseryInfo.setStatus(Constants.PLANT_NO); nurseryInfo.setStatus(Constants.PLANT_NO);
nurseryInfo.setPlantId(null); nurseryInfo.setPlantId(null);
nurseryInfo.setSeedingTime(null); nurseryInfo.setSeedingTime(null);
nurseryInfo.setNumber(0); nurseryInfo.set反馈ID(0);
nurseryInfo.setFruitTimes(0); nurseryInfo.setFruitTimes(0);
nurseryInfo.setUpdateTime(DateUtil.getCurrentTime()); nurseryInfo.setUpdateTime(DateUtil.getCurrentTime());
} else { //花圃转为空置状态,花圃数据初始化 } else { //花圃转为空置状态,花圃数据初始化
...@@ -1085,7 +1109,7 @@ public class PlantServiceImpl implements PlantService { ...@@ -1085,7 +1109,7 @@ public class PlantServiceImpl implements PlantService {
plantMap = new ConcurrentHashMap<>(); plantMap = new ConcurrentHashMap<>();
PlantDto plantDto = new PlantDto(); PlantDto plantDto = new PlantDto();
plantDto.setPlantId(nurseryInfo.getPlantId()); plantDto.setPlantId(nurseryInfo.getPlantId());
plantDto.setNumber(1); plantDto.set反馈ID(1);
plantMap.put(plantDto.getPlantId(), plantDto); plantMap.put(plantDto.getPlantId(), plantDto);
nurseryInfo.setPlantIdTimes(plantMap); nurseryInfo.setPlantIdTimes(plantMap);
} else { } else {
...@@ -1093,10 +1117,10 @@ public class PlantServiceImpl implements PlantService { ...@@ -1093,10 +1117,10 @@ public class PlantServiceImpl implements PlantService {
if (StringUtils.isEmpty(plant)) { if (StringUtils.isEmpty(plant)) {
plant = new PlantDto(); plant = new PlantDto();
plant.setPlantId(nurseryInfo.getPlantId()); plant.setPlantId(nurseryInfo.getPlantId());
plant.setNumber(1); plant.set反馈ID(1);
plantMap.put(plant.getPlantId(), plant); plantMap.put(plant.getPlantId(), plant);
} else { } else {
plant.setNumber(plant.getNumber() + 1); plant.set反馈ID(plant.getNumber() + 1);
} }
} }
} }
......
...@@ -44,3 +44,7 @@ eureka: ...@@ -44,3 +44,7 @@ eureka:
register-with-eureka: false register-with-eureka: false
#是否检索注册中心信息 #是否检索注册中心信息
fetch-registry: false fetch-registry: false
expire:
time: 180000
\ No newline at end of file
...@@ -44,3 +44,7 @@ eureka: ...@@ -44,3 +44,7 @@ eureka:
register-with-eureka: false register-with-eureka: false
#是否检索注册中心信息 #是否检索注册中心信息
fetch-registry: false fetch-registry: false
expire:
time: 180000
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment