From c9096bbd4eefe0f7ff2243637ab392866b6b918e Mon Sep 17 00:00:00 2001 From: zhoujunqiang Date: Sat, 24 Sep 2022 13:23:58 +0800 Subject: [PATCH] 1.反馈问题修复 --- src/main/java/com/qiwuai/garden/common/Constants.java | 4 ++++ src/main/java/com/qiwuai/garden/common/TimingAcquisition.java | 19 ++++++++++++++++--- src/main/java/com/qiwuai/garden/common/utils/TypeConvertUtil.java | 2 +- src/main/java/com/qiwuai/garden/controller/CommonController.java | 8 +++++++- src/main/java/com/qiwuai/garden/service/backPackService/impl/BackPackServiceImpl.java | 14 +++++++++----- src/main/java/com/qiwuai/garden/service/petService/PetService.java | 12 ++++++++++++ src/main/java/com/qiwuai/garden/service/petService/impl/PetServiceImpl.java | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- src/main/java/com/qiwuai/garden/service/plantService/impl/PlantServiceImpl.java | 8 ++++---- src/main/java/com/qiwuai/garden/service/socialService/impl/SocialServiceImpl.java | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------- src/main/resources/speech/gardener.yaml | 6 +++--- src/main/resources/speech/pet.yaml | 21 +++++++++++++++------ src/main/resources/speech/social.yaml | 2 ++ 12 files changed, 222 insertions(+), 61 deletions(-) diff --git a/src/main/java/com/qiwuai/garden/common/Constants.java b/src/main/java/com/qiwuai/garden/common/Constants.java index 93b7bc5..0d1bce0 100644 --- a/src/main/java/com/qiwuai/garden/common/Constants.java +++ b/src/main/java/com/qiwuai/garden/common/Constants.java @@ -209,6 +209,10 @@ public class Constants { */ public static final Integer ADD_FRIEND_CHECK = 5009; /** + * 好友留言 + */ + public static final Integer LEAVE_MESSAGE = 5011; + /** * 查看留言 */ public static final Integer READ_MESSAGE = 5012; diff --git a/src/main/java/com/qiwuai/garden/common/TimingAcquisition.java b/src/main/java/com/qiwuai/garden/common/TimingAcquisition.java index 6c42144..3e643d7 100644 --- a/src/main/java/com/qiwuai/garden/common/TimingAcquisition.java +++ b/src/main/java/com/qiwuai/garden/common/TimingAcquisition.java @@ -214,6 +214,7 @@ public class TimingAcquisition { * 通过json文件加载所有用户数据到缓存中 */ public static void loading() { + log.info("-----------开始加载玩家数据----------------"); //从yml配置文件中取出存放玩家数据的地址 String userFilePath = YamlUtil.getValueByKey("userFilePath"); File file = new File(userFilePath); @@ -226,13 +227,14 @@ public class TimingAcquisition { if (f.isFile()) { String s = PersistenceUtil.getDataFromFile(String.valueOf(f)); //JSON转map对象 - log.info("取出的数据:" + s); +// log.info("取出的数据:" + s); Map gardener = JSON.parseObject(s, new TypeReference>(){}); - log.info("从文件中取出玩家的缓存数据:" + gardener); +// log.info("从文件中取出玩家的缓存数据:" + gardener); gardenerMap.putAll(gardener); } } - log.info("内存中所有玩家的缓存数据:" + gardenerMap ); + log.info("-----------玩家数据加载完成----------------"); +// log.info("内存中所有玩家的缓存数据:" + gardenerMap ); //加载话术 speechLoading(); //加载配置文件region.json @@ -645,6 +647,17 @@ public class TimingAcquisition { NurseryPojo nursery = entry.getValue(); if (nurseryType.equals(nursery.getName())) { return nursery.getId(); + } else { //在别名里找 + //所有该植物的别名 + String alias = nursery.getAlias(); + if (!StringUtils.isEmpty(alias)) { + if (!Constants.NON_STR.equals(alias)) { + List aliasList = Arrays.asList(alias.split("\\|")); + if (aliasList.contains(nurseryType)) { + return nursery.getId(); + } + } + } } } return Constants.REQ_NON; diff --git a/src/main/java/com/qiwuai/garden/common/utils/TypeConvertUtil.java b/src/main/java/com/qiwuai/garden/common/utils/TypeConvertUtil.java index ef8de05..acb6ae6 100644 --- a/src/main/java/com/qiwuai/garden/common/utils/TypeConvertUtil.java +++ b/src/main/java/com/qiwuai/garden/common/utils/TypeConvertUtil.java @@ -79,7 +79,7 @@ public class TypeConvertUtil { * @return Integer */ public static Integer change2Integer(String param) { - String[] all = new String[]{"都", "统统", "全数", "所有", "全", "全部", "全都", "一起"}; + String[] all = new String[]{"都", "统统", "全数", "所有", "全", "全部", "全都", "一起", "批量"}; String[] first = new String[]{"首个", "首位", "最前面", "开头", "首发", "起首"}; String[] middle = new String[]{"中间"}; String[] last = new String[]{"最后", "末位", "末尾", "最后面"}; diff --git a/src/main/java/com/qiwuai/garden/controller/CommonController.java b/src/main/java/com/qiwuai/garden/controller/CommonController.java index c5489f8..d708703 100644 --- a/src/main/java/com/qiwuai/garden/controller/CommonController.java +++ b/src/main/java/com/qiwuai/garden/controller/CommonController.java @@ -331,6 +331,12 @@ public class CommonController { case "发放花圃宠物指令": result = petServiceProxy.addNurseryPet(operationReq); break; + case "查看新来宠物": + result = petServiceProxy.checkNewPets(operationReq); + break; + case "升级宠物": + result = petServiceProxy.updatePet(operationReq); + break; case "购买指令": result = marketServiceProxy.buyCheck(operationReq); break; @@ -713,7 +719,7 @@ public class CommonController { case "查询货币说明": result = helpServiceProxy.moneyExplainCheck(operationReq); break; - case "建议指令": + case "询问建议": result = adviseServiceProxy.adviseWithout(operationReq); break; case "种植建议指令": diff --git a/src/main/java/com/qiwuai/garden/service/backPackService/impl/BackPackServiceImpl.java b/src/main/java/com/qiwuai/garden/service/backPackService/impl/BackPackServiceImpl.java index ee21c7e..b0308ae 100644 --- a/src/main/java/com/qiwuai/garden/service/backPackService/impl/BackPackServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/backPackService/impl/BackPackServiceImpl.java @@ -337,16 +337,20 @@ public class BackPackServiceImpl implements BackPackService { itemBags.put(itemTypeId, itemBag); } ItemDto item = itemBags.get(itemTypeId).getItems(itemId); + String description = ""; + if (!StringUtils.isEmpty(itemConfig.getDescription())) { + description = "," + itemConfig.getDescription(); + } //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "search_item_info"); if (StringUtils.isEmpty(item)) { if (!StringUtils.isEmpty(plant)) { text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "search_item_info_fruit_none"); - text = SpeechUtil.speechReplaceNum(text, itemConfig.getName(), itemConfig.getDescription(), plant.getName()); + text = SpeechUtil.speechReplaceNum(text, itemConfig.getName(), description, plant.getName()); text += SpeechUtil.getGardenerSpeech(gender, "search_item_info_fruit_none"); } else { text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "search_item_info_item_none"); - text = SpeechUtil.speechReplaceNum(text, itemConfig.getName(), itemConfig.getDescription()); + text = SpeechUtil.speechReplaceNum(text, itemConfig.getName(), description); text += SpeechUtil.getGardenerSpeech(gender, "search_item_info_item_none"); } text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); @@ -363,11 +367,11 @@ public class BackPackServiceImpl implements BackPackService { if (item.getItemNum() == 0) { if (!StringUtils.isEmpty(plant)) { text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "search_item_info_fruit_none"); - text = SpeechUtil.speechReplaceNum(text, itemConfig.getName(), itemConfig.getDescription(), plant.getName()); + text = SpeechUtil.speechReplaceNum(text, itemConfig.getName(), description, plant.getName()); text += SpeechUtil.getGardenerSpeech(gender, "search_item_info_fruit_none"); } else { text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "search_item_info_item_none"); - text = SpeechUtil.speechReplaceNum(text, itemConfig.getName(), itemConfig.getDescription()); + text = SpeechUtil.speechReplaceNum(text, itemConfig.getName(), description); text += SpeechUtil.getGardenerSpeech(gender, "search_item_info_item_none"); } text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); @@ -381,7 +385,7 @@ public class BackPackServiceImpl implements BackPackService { commonResponse.setData(resultVarsResponse); return commonResponse; } - text = SpeechUtil.speechReplaceNum(text, itemConfig.getName(), itemConfig.getDescription(), item.getItemNum().toString()); + text = SpeechUtil.speechReplaceNum(text, itemConfig.getName(), description, item.getItemNum().toString()); log.info(uid + "检索到物品信息:" + itemConfig.getName() + "有" + item.getItemNum() + "个"); commonResponse.setCode(1); commonResponse.setMsg("成功"); diff --git a/src/main/java/com/qiwuai/garden/service/petService/PetService.java b/src/main/java/com/qiwuai/garden/service/petService/PetService.java index 0cc81bb..f044e6f 100644 --- a/src/main/java/com/qiwuai/garden/service/petService/PetService.java +++ b/src/main/java/com/qiwuai/garden/service/petService/PetService.java @@ -106,4 +106,16 @@ public interface PetService { * @return CommonResponse */ CommonResponse addNurseryPet(OperationRequest operationReq); + /** + * 查看新来宠物 + * @param operationReq + * @return CommonResponse + */ + CommonResponse checkNewPets(OperationRequest operationReq); + /** + * 升级宠物 + * @param operationReq + * @return CommonResponse + */ + CommonResponse updatePet(OperationRequest operationReq); } diff --git a/src/main/java/com/qiwuai/garden/service/petService/impl/PetServiceImpl.java b/src/main/java/com/qiwuai/garden/service/petService/impl/PetServiceImpl.java index 15e471f..39a10cb 100644 --- a/src/main/java/com/qiwuai/garden/service/petService/impl/PetServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/petService/impl/PetServiceImpl.java @@ -41,6 +41,7 @@ public class PetServiceImpl implements PetService { ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); log.info(uid + "开始查询宠物信息"); //园丁性别 @@ -106,19 +107,23 @@ public class PetServiceImpl implements PetService { } } } + String description = ""; + if (!StringUtils.isEmpty(petConfig.getDescription())) { + description = "," + petConfig.getDescription(); + } //获取对应话术 String text = ""; //1.有且仅有一只该宠物在花圃中 if (nurseryPetCount == 1 && petCount == 0) { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_view_nursery_one"); - text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), petConfig.getDescription(), nurseryNumList.get(0)); + text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), description, nurseryNumList.get(0)); text += SpeechUtil.getPetSpeech(gender, "pet_view_nursery"); resultResponse.set反馈ID(300101); } //2.有且仅有一只该宠物在宠物栏中 if (nurseryPetCount == 0 && petCount == 1) { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_view_field_one"); - text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), petConfig.getDescription()); + text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), description); text += SpeechUtil.getPetSpeech(gender, "pet_view_field"); text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(300102); @@ -142,7 +147,7 @@ public class PetServiceImpl implements PetService { //4.仅宠物栏有多只该宠物 if (nurseryPetCount == 0 && petCount > 1) { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_view_field_more"); - text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), petConfig.getDescription(), String.valueOf(petCount)); + text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), description, String.valueOf(petCount)); text += SpeechUtil.getPetSpeech(gender, "pet_view_field"); text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(300104); @@ -158,7 +163,7 @@ public class PetServiceImpl implements PetService { nurseryNumText.deleteCharAt(nurseryNumText.length() - 1); } text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_view_both"); - text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), petConfig.getDescription(), + text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), description, String.valueOf(petCount), String.valueOf(nurseryPetCount), nurseryNumText.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_view_field"); text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); @@ -172,7 +177,7 @@ public class PetServiceImpl implements PetService { } nurseryNumText.deleteCharAt(nurseryNumText.length() - 1); text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_view_nursery_more"); - text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), petConfig.getDescription(), String.valueOf(nurseryPetCount), nurseryNumText.toString()); + text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), description, String.valueOf(nurseryPetCount), nurseryNumText.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_view_nursery"); resultResponse.set反馈ID(300106); } @@ -190,9 +195,9 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); - Integer petId = operationReq.getPetId(); Integer nurseryNum = operationReq.getNurseryNum(); //当前玩家上一轮的请求信息 @@ -411,9 +416,9 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); - Integer petId = operationReq.getPetId(); Integer nurseryNum = operationReq.getNurseryNum(); //园丁性别 @@ -617,6 +622,7 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); log.info(uid + "开始移动宠物"); @@ -770,6 +776,7 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); Integer petId = operationReq.getPetId(); //宠物id @@ -917,7 +924,7 @@ public class PetServiceImpl implements PetService { //花圃中没有宠物 if (StringUtils.isEmpty(nurseryInfo.getPetField())) { //获取对应话术 - String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_delete_fail_no_pet"); + String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_delete_fail_nursery_no_pet"); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300406); @@ -970,6 +977,7 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); log.info(uid + "开始删除宠物"); @@ -1065,6 +1073,7 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); log.info(uid + "开始取消删除宠物"); @@ -1127,6 +1136,7 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); log.info(uid + "开始宠物换位"); @@ -1503,6 +1513,7 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); log.info(uid + "开始宠物互换位置"); @@ -1721,6 +1732,7 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); log.info(uid + "开始查看宠物栏情况"); @@ -1805,6 +1817,7 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); log.info(uid + "开始查看花圃宠物数量详情"); @@ -1850,6 +1863,7 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); log.info(uid + "开始查看所有宠物的情况"); @@ -1932,6 +1946,7 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); Integer nurseryNum = operationReq.getNurseryNum(); @@ -2035,6 +2050,7 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); //玩家称呼 @@ -2059,9 +2075,13 @@ public class PetServiceImpl implements PetService { attributeText.append(TimingAcquisition.attributeMap.get(Integer.valueOf(attributeId)).getAttribute()).append("、"); } attributeText.deleteCharAt(attributeText.length() - 1); + String description = ""; + if (!StringUtils.isEmpty(pet.getDescription())) { + description = "," + pet.getDescription(); + } //获取对应话术 String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_check_by_num_sure"); - text = SpeechUtil.speechReplaceNum(text, pet.getName(), pet.getDescription(), attributeText.toString(), pet.getHp().toString(), pet.getFc().toString()); + text = SpeechUtil.speechReplaceNum(text, pet.getName(), description, attributeText.toString(), pet.getHp().toString(), pet.getFc().toString()); text += SpeechUtil.getPetSpeech(gender, "pet_check_by_num_sure"); text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); @@ -2078,6 +2098,7 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); Integer nurseryNum = null; @@ -2109,6 +2130,7 @@ public class PetServiceImpl implements PetService { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); String uid = operationReq.getUid(); Integer nurseryPos = operationReq.getNurseryPos(); @@ -2245,4 +2267,72 @@ public class PetServiceImpl implements PetService { return commonResponse; } + @Override + public CommonResponse checkNewPets(OperationRequest operationReq) { + CommonResponse commonResponse = new CommonResponse(); + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); + + String uid = operationReq.getUid(); + Map nurseryInfoMap = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos(); + StringBuilder petText = new StringBuilder(); + int count = 0; + for (Map.Entry entry : nurseryInfoMap.entrySet()) { + NurseryInfoDto nurseryInfo = entry.getValue(); + if (!StringUtils.isEmpty(nurseryInfo.getPetField())) { + //新来宠物,还未查看 + if (nurseryInfo.getPetCheck() == Constants.PET_UNCHECK) { + count++; +// nurseryInfo.setPetCheck(Constants.PET_CHECK); + petText.append(entry.getKey()).append("号{花圃称呼}").append("来了只"). + append(TimingAcquisition.petConfigMap.get(nurseryInfo.getPetField()).getName()).append("、"); + } + } + } + if (count == 0) { + //获取对应话术 + String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "nursery_pet_check_no_new_pet"); + resultResponse.set反馈ID(301005); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + if (petText.length() != 0) { + petText.deleteCharAt(petText.length() - 1); + } + //获取对应话术 + String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "nursery_pet_check_new_pet"); + text = SpeechUtil.speechReplaceNum(text, String.valueOf(count), petText.toString()); + resultResponse.set反馈ID(301006); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + + @Override + public CommonResponse updatePet(OperationRequest operationReq) { + CommonResponse commonResponse = new CommonResponse(); + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + resultResponse.set玩家当前位置(""); + + String uid = operationReq.getUid(); + //获取对应话术 + String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "upgrade_pet"); + resultResponse.set反馈ID(301007); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + } diff --git a/src/main/java/com/qiwuai/garden/service/plantService/impl/PlantServiceImpl.java b/src/main/java/com/qiwuai/garden/service/plantService/impl/PlantServiceImpl.java index 3176ead..ba97ba0 100644 --- a/src/main/java/com/qiwuai/garden/service/plantService/impl/PlantServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/plantService/impl/PlantServiceImpl.java @@ -438,7 +438,7 @@ public class PlantServiceImpl implements PlantService { //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_fail_seed_none"); text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.itemConfigMap.get(plant.getFruitId()).getName()); - text += SpeechUtil.getPlantSpeech(gender, "plant_fail_seed_none"); + text += SpeechUtil.getPlantSpeech(gender, "plant_fail_seed"); text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -461,7 +461,7 @@ public class PlantServiceImpl implements PlantService { //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_fail_seed_none"); text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.itemConfigMap.get(plant.getFruitId()).getName()); - text += SpeechUtil.getPlantSpeech(gender, "plant_fail_seed_none"); + text += SpeechUtil.getPlantSpeech(gender, "plant_fail_seed"); text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -1722,7 +1722,7 @@ public class PlantServiceImpl implements PlantService { List dropItems = nurseryInfo.getDropItems(); if (!StringUtils.isEmpty(dropItems)) { if (dropItems.size() != 0){ - feedText.append(",").append("额外收获了"); + feedText.append(",额外收获了"); for (ItemDto item : dropItems) { if (item.getItemNum() != 0) { feedText.append(item.getItemNum()).append("个").append(itemConfigMap.get(item.getItemId()).getName()).append("、"); @@ -2097,7 +2097,7 @@ public class PlantServiceImpl implements PlantService { //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); //如果花圃已置空,则直接返回 - if (!StringUtils.isEmpty(nurseryInfo.getPlantId())) { + if (StringUtils.isEmpty(nurseryInfo.getPlantId())) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "clear_plant_fail_plant"); text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); diff --git a/src/main/java/com/qiwuai/garden/service/socialService/impl/SocialServiceImpl.java b/src/main/java/com/qiwuai/garden/service/socialService/impl/SocialServiceImpl.java index b25e4f7..21541af 100644 --- a/src/main/java/com/qiwuai/garden/service/socialService/impl/SocialServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/socialService/impl/SocialServiceImpl.java @@ -369,9 +369,9 @@ public class SocialServiceImpl implements SocialService { friendAddressList.add(friend.getAddress()); } playerList.removeIf(friendAddressList::contains); - //去除玩家本人 - playerList.removeIf(location::contains); } + //去除玩家本人 + playerList.removeIf(location::contains); //随机取一个本地区非好友的玩家 int randomNum = RandomDropUtil.getRandomNum(0, playerList.size()); String address = playerList.get(randomNum); @@ -2418,7 +2418,7 @@ public class SocialServiceImpl implements SocialService { String address = (curAddress == null) ? lastAddress : curAddress; String name = (curName == null) ? lastName : curName; Integer nurseryNum = (curNurseryNum == null) ? lastNurseryNum : curNurseryNum; - String person = (name == null) ? address : name; +// String person = (name == null) ? address : name; if (StringUtils.isEmpty(address) && StringUtils.isEmpty(name)) { log.info(uid + "未提供玩家地址"); //获取对应话术 @@ -2448,7 +2448,7 @@ public class SocialServiceImpl implements SocialService { return commonResponse; } GardenerDto gardener = TimingAcquisition.gardenerMap.get(uid); - log.info(uid + "玩家开始偷取" + person + "的花圃" + nurseryNum); + log.info(uid + "玩家开始偷取" + address + "的花圃" + nurseryNum); //bot端需要该标识来识别当前位置非本地 resultResponse.set玩家当前位置("非本人"); //保存玩家这轮的请求信息,用于下一步操作 @@ -2462,11 +2462,11 @@ public class SocialServiceImpl implements SocialService { //对方是好友,不能偷菜 List addressList = friendList.stream().map(FriendDto::getAddress).collect(Collectors.toList()); List nameList = friendList.stream().map(FriendDto::getName).collect(Collectors.toList()); - if (addressList.contains(person) || nameList.contains(person)) { - log.info(uid + "偷取对象是好友:" + person + ",无法偷取"); + if (addressList.contains(address) || nameList.contains(name)) { + log.info(uid + "偷取对象是好友:" + address + ",无法偷取"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_friend"); - text = SpeechUtil.speechReplaceNum(text, person); + text = SpeechUtil.speechReplaceNum(text, address); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500612); @@ -2914,7 +2914,7 @@ public class SocialServiceImpl implements SocialService { } String address = curAddress == null ? lastAddress : curAddress; String name = curName == null ? lastName : curName; - String person = (name == null) ? address : name; +// String person = (name == null) ? address : name; if (StringUtils.isEmpty(address) && StringUtils.isEmpty(name)) { //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "steal_fail_no_address"); @@ -2938,11 +2938,11 @@ public class SocialServiceImpl implements SocialService { //对方是好友,不能偷菜 List addressList = friendList.stream().map(FriendDto::getAddress).collect(Collectors.toList()); List nameList = friendList.stream().map(FriendDto::getName).collect(Collectors.toList()); - if (addressList.contains(person) || nameList.contains(person)) { - log.info(uid + "偷取对象是好友:" + person + ",无法偷取"); + if (addressList.contains(address) || nameList.contains(name)) { + log.info(uid + "偷取对象是好友:" + address + ",无法偷取"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_friend"); - text = SpeechUtil.speechReplaceNum(text, person); + text = SpeechUtil.speechReplaceNum(text, address); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500612); @@ -3031,7 +3031,7 @@ public class SocialServiceImpl implements SocialService { } //随机取对方的一个花圃编号 Integer nurseryNum = nurseryNumList.get(RandomDropUtil.getRandomNum(0, nurseryNumList.size())); - log.info(uid + "开始偷取" + person + "的花圃" + nurseryNum); + log.info(uid + "开始偷取" + address + "的花圃" + nurseryNum); //对方当前花圃信息 NurseryInfoDto nurseryInfo = TimingAcquisition.gardenerMap.get(uidSide).getGarden().getNurseryInfos().get(nurseryNum); //保存玩家这轮的请求信息,用于下一步操作 @@ -3267,7 +3267,7 @@ public class SocialServiceImpl implements SocialService { } GardenerDto gardener = TimingAcquisition.gardenerMap.get(uid); //通过玩家地址查看好友列表 - FriendDto friend = new FriendDto(); + FriendDto friend = null; String finalAddress = curAddress; if (!StringUtils.isEmpty(gardener.getFriendList())) { friend = gardener.getFriendList().stream().filter(friendDto -> finalAddress.equals(friendDto.getAddress())).findAny().orElse(null); @@ -3380,7 +3380,7 @@ public class SocialServiceImpl implements SocialService { // } GardenerDto gardener = TimingAcquisition.gardenerMap.get(uid); //通过玩家地址查看好友列表 - FriendDto friend = new FriendDto(); + FriendDto friend = null; if (!StringUtils.isEmpty(gardener.getFriendList())) { friend = gardener.getFriendList().stream().filter(friendDto -> address.equals(friendDto.getAddress())).findAny().orElse(null); } @@ -5838,12 +5838,15 @@ public class SocialServiceImpl implements SocialService { //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (!StringUtils.isEmpty(lastReq)) { - address = (address == null) ? lastReq.getAddress() : address; //对方的玩家地址 - message = (message == null) ? lastReq.getMessage() : message; //留言内容 + if (!StringUtils.isEmpty(lastReq.getAddress())) { + address = (address == null) ? lastReq.getAddress() : address; //对方的玩家地址 + message = (message == null) ? lastReq.getMessage() : message; //留言内容 + } } //保存玩家这轮的请求信息,用于下一步操作 operationReq.setAddress(address); operationReq.setMessage(message); + operationReq.setOperationLabel(Constants.LEAVE_MESSAGE); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); @@ -5939,7 +5942,7 @@ public class SocialServiceImpl implements SocialService { return commonResponse; } //通过玩家地址查看好友列表 - FriendDto friend = new FriendDto(); + FriendDto friend = null; String finalAddress = address; if (!StringUtils.isEmpty(gardener.getFriendList())) { friend = gardener.getFriendList().stream().filter(friendDto -> finalAddress.equals(friendDto.getAddress())).findAny().orElse(null); @@ -5950,6 +5953,7 @@ public class SocialServiceImpl implements SocialService { //保存玩家这轮的请求信息,用于下一步操作 operationReq.setAddress(null); operationReq.setMessage(message); + operationReq.setOperationLabel(Constants.LEAVE_MESSAGE); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "leave_message_fail_not_friend"); @@ -5985,6 +5989,7 @@ public class SocialServiceImpl implements SocialService { //保存玩家这轮的请求信息,用于下一步操作 operationReq.setAddress(address); operationReq.setMessage(null); + operationReq.setOperationLabel(Constants.LEAVE_MESSAGE); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "leave_message_fail_sensitive_words"); @@ -6020,15 +6025,27 @@ public class SocialServiceImpl implements SocialService { String uid = operationReq.getUid(); //本人uid //玩家称呼 CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); + String address = null; + String message = null; //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); - if (StringUtils.isEmpty(lastReq)) { + if (!StringUtils.isEmpty(lastReq)) { + if (!Constants.LEAVE_MESSAGE.equals(lastReq.getOperationLabel())) { + address = lastReq.getAddress(); //好友的玩家地址 + message = lastReq.getMessage(); //好友留言 + } + } + if (StringUtils.isEmpty(address) || StringUtils.isEmpty(message)) { + //获取对应话术 + String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "leave_message_fail_no_pre"); commonResponse.setCode(1); - commonResponse.setMsg("失败,对话已结束"); - return commonResponse; + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(501111); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; } - String address = lastReq.getAddress(); //好友的玩家地址 - String message = lastReq.getMessage(); //好友留言 //好友uid String place = TypeConvertUtil.extractChinese(address); String friendUid = TimingAcquisition.addressMap.get(place).get(address).getUid(); //对方uid @@ -6116,11 +6133,13 @@ public class SocialServiceImpl implements SocialService { GardenerDto gardener = TimingAcquisition.gardenerMap.get(uid); //玩家所有好友 List friends = gardener.getFriendList(); - //找到所有好友的玩家地址 - for (String friendUid : friendUidList) { - FriendDto friend = friends.stream().filter(friendDto -> friendUid.equals(friendDto.getUid())).findAny().orElse(null); - if (!StringUtils.isEmpty(friend)) { - addressList.add(friend.getAddress()); + if (!StringUtils.isEmpty(friends)) { + //找到所有好友的玩家地址 + for (String friendUid : friendUidList) { + FriendDto friend = friends.stream().filter(friendDto -> friendUid.equals(friendDto.getUid())).findAny().orElse(null); + if (!StringUtils.isEmpty(friend)) { + addressList.add(friend.getAddress()); + } } } //没有好友留言 @@ -6877,8 +6896,10 @@ public class SocialServiceImpl implements SocialService { //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (!StringUtils.isEmpty(lastReq)) { - addressSide = (addressSide == null) ? lastReq.getAddress() : addressSide; - nurseryNum = (nurseryNum == null) ? lastReq.getNurseryNum() : nurseryNum; + if (!StringUtils.isEmpty(lastReq.getAddress())) { + addressSide = (addressSide == null) ? lastReq.getAddress() : addressSide; + nurseryNum = (nurseryNum == null) ? lastReq.getNurseryNum() : nurseryNum; + } } log.info(uid + "查看对方" + addressSide + "花圃" + nurseryNum + "的宠物"); //园丁性别 diff --git a/src/main/resources/speech/gardener.yaml b/src/main/resources/speech/gardener.yaml index da3b271..81df3cd 100644 --- a/src/main/resources/speech/gardener.yaml +++ b/src/main/resources/speech/gardener.yaml @@ -107,11 +107,11 @@ aside: - 【旁白@正常】目前拥有的【1】数量为【2】。 #检索物品 search_item_info: - - 【旁白@正常】【1】,【2】,背包里目前拥有【3】个。 + - 【旁白@正常】【1】【2】,背包里目前拥有【3】个。 search_item_info_fruit_none: - - 【旁白@正常】【1】,【2】,目前背包里还没有。可以通过种植【3】在收获果实的时候获得。 + - 【旁白@正常】【1】【2】,目前背包里还没有。可以通过种植【3】在收获果实的时候获得。 search_item_info_item_none: - - 【旁白@正常】【1】,【2】,目前背包里还没有。可以在商店购买获得。 + - 【旁白@正常】【1】【2】,目前背包里还没有。可以在商店购买获得。 search_item_info_no_exist: - 【旁白@正常】该物品不存在。 diff --git a/src/main/resources/speech/pet.yaml b/src/main/resources/speech/pet.yaml index 6b1785f..33ac342 100644 --- a/src/main/resources/speech/pet.yaml +++ b/src/main/resources/speech/pet.yaml @@ -2,15 +2,15 @@ aside: #宠物查询 pet_view_nursery_one: - - 【旁白@正常】已为你查询,【1】,【2】,目前该宠物正养在【3】号{花圃称呼}中。 + - 【旁白@正常】已为你查询,【1】【2】,目前该宠物正养在【3】号{花圃称呼}中。 pet_view_field_one: - - 【旁白@正常】已为你查询,【1】,【2】,目前该宠物正在宠物栏里。 + - 【旁白@正常】已为你查询,【1】【2】,目前该宠物正在宠物栏里。 pet_view_nursery_more: - - 【旁白@正常】已为你查询,【1】,【2】,目前有【3】只,该宠物正养在【4】中。 + - 【旁白@正常】已为你查询,【1】【2】,目前有【3】只,该宠物正养在【4】中。 pet_view_field_more: - - 【旁白@正常】已为你查询,【1】,【2】,目前有【3】只,该宠物正在宠物栏里。 + - 【旁白@正常】已为你查询,【1】【2】,目前有【3】只,该宠物正在宠物栏里。 pet_view_both: - - 【旁白@正常】已为你查询,【1】,【2】,目前有【3】只该宠物正在宠物栏里,有【4】只该宠物正养在【5】中。 + - 【旁白@正常】已为你查询,【1】【2】,目前有【3】只该宠物正在宠物栏里,有【4】只该宠物正养在【5】中。 pet_view_no_pet: - 【旁白@正常】已为你查询,{花圃称呼}、宠物栏内没有该宠物。我们还没有这个宠物,可以通过种植【1】,以一定几率获得 pet_view_no_exist: @@ -63,6 +63,8 @@ aside: - 【旁白@正常】对应位置不是该宠物。 pet_delete_fail_no_pet: - 【旁白@正常】未查询到该宠物,无法赶走。 + pet_delete_fail_nursery_no_pet: + - 【旁白@正常】{花圃称呼}中还没有宠物,无法赶走。 pet_delete_success: - 【旁白@正常】我知道了,现在为你赶走【1】。 - 【旁白@正常】好的,现在为您赶走【1】。 @@ -111,6 +113,10 @@ aside: #查看花圃宠物状况 nursery_pet_check: - 【旁白@正常】花园目前有宠物的{花圃称呼}一共有【1】块,【2】块{花圃称呼}空闲可放置宠物。 + nursery_pet_check_new_pet: + - 【旁白@正常】你{花圃称呼}中的植物成熟后共吸引来【1】只宠物,【2】。 + nursery_pet_check_no_new_pet: + - 【旁白@正常】当前你的{花圃称呼}这次还没有新来宠物。 #宠物总览查询 pet_overview_both: - 【旁白@正常】你当前拥有【1】只宠物。宠物栏中有【2】只宠物,其中【3】。{花圃称呼}中有【4】只宠物,其中【5】。 @@ -130,9 +136,12 @@ aside: pet_check_by_num_fail_no_pet: - 【旁白@正常】【1】号{花圃称呼}中没有宠物,可以将宠物栏中的宠物放置到这个{花圃称呼}中,或是等待植物成熟后看看有没有宠物被吸引过来。 pet_check_by_num_sure: - - 【旁白@正常】【1】、【2】,【3】属性,生命值【4】,攻击值【5】。 + - 【旁白@正常】【1】【2】,【3】属性,生命值【4】,攻击值【5】。 pet_check_by_num_cancel: - 【旁白@正常】好的。已为你取消查看【1】号{花圃称呼}的宠物。 + #升级宠物 + upgrade_pet: + - 【旁白@正常】宠物不支持升级。可以去看看有哪些宠物。 diff --git a/src/main/resources/speech/social.yaml b/src/main/resources/speech/social.yaml index 49b4d12..5da2c68 100644 --- a/src/main/resources/speech/social.yaml +++ b/src/main/resources/speech/social.yaml @@ -184,6 +184,8 @@ aside: - 【旁白@正常】还需冷却【1】秒后可以接着留言。 leave_message_fail_sensitive_words: - 【旁白@正常】留言包含敏感词汇,本次留言失败,要继续留言吗? + leave_message_fail_no_pre: + - 【旁白@正常】你还未说留言信息,暂时无法留言,请先开始留言。 leave_message_success: - 【旁白@正常】留言已完成。 leave_message_fail_not_friend: -- libgit2 0.27.1