diff --git a/src/main/java/com/qiwuai/garden/common/Constants.java b/src/main/java/com/qiwuai/garden/common/Constants.java index 0d68c82..b187429 100644 --- a/src/main/java/com/qiwuai/garden/common/Constants.java +++ b/src/main/java/com/qiwuai/garden/common/Constants.java @@ -193,13 +193,21 @@ public class Constants { */ public static final Integer ADD_FRIEND_CHECK = 5009; /** + * 查看留言 + */ + public static final Integer READ_MESSAGE = 5012; + /** * 查看帮助简报 */ public static final Integer CHECK_HELP_REPORT = 5013; /** - * 查看偷菜简报 + * 查看防守简报 */ public static final Integer CHECK_STEAL_REPORT = 5014; + /** + * 消息推送 + */ + public static final Integer CHECK_NOTICE = 5018; /** @@ -238,6 +246,81 @@ public class Constants { /** + * ----------------------------技能ID---------------------- + * 初级种植 + */ + public static final int PRIMARY_PLANT = 1001; + /** + * 初级驯养 + */ + public static final int PRIMARY_TRAIN = 1002; + /** + * 园地维护 + */ + public static final int GARDEN_CARE = 1003; + /** + * 护栏加固 + */ + public static final int GARDEN_DEFEND = 1004; + /** + * 中级种植 + */ + public static final int INTER_PLANT = 1005; + /** + * 中级驯养 + */ + public static final int INTER_TRAIN = 1006; + /** + * 高效养护 + */ + public static final int HIGH_EFF_CARE = 1007; + /** + * 战斗训练 + */ + public static final int FIGHT_TRAIN = 1008; + /** + * 催生术 + */ + public static final int SPEED_UP_PLANT = 1009; + /** + * 勇气训练 + */ + public static final int BRAVE_TRAIN = 1010; + /** + * 高级种植 + */ + public static final int HIGH_PLANT = 1011; + /** + * 高级驯养 + */ + public static final int HIGH_TRAIN = 1012; + /** + * 花圃维护 + */ + public static final int NURSERY_CARE = 1013; + /** + * 高效克制 + */ + public static final int HIGH_EFF_RESTRAIN = 1014; + /** + * 收集专家 + */ + public static final int COLLECT_EXPERT = 1015; + /** + * 高效防护 + */ + public static final int HIGH_EFF_DEFEND = 1016; + /** + * 植物之心 + */ + public static final int PLANT_HEART = 1017; + /** + * 宠物之心 + */ + public static final int PET_HEART = 1018; + + + /** * 帮助标记:0-未帮助 */ public static final int HELP_NO_SIGN = 0; diff --git a/src/main/java/com/qiwuai/garden/common/ProxyFactory.java b/src/main/java/com/qiwuai/garden/common/ProxyFactory.java index e0ff9bc..d00d133 100644 --- a/src/main/java/com/qiwuai/garden/common/ProxyFactory.java +++ b/src/main/java/com/qiwuai/garden/common/ProxyFactory.java @@ -68,6 +68,21 @@ public class ProxyFactory { Integer moneyNum = TimingAcquisition.gardenerMap.get(request.getUid()).getBackPack().getItemBags() .get(Constants.ITEM_TYPE_MONEY).getItems(moneyId).getItemNum(); commonResponse.getData().getVars().set玩家金币数量(moneyNum); + //------------是否有宠物---------- + int petCount = TimingAcquisition.getPetNum(request.getUid()); + if (petCount > 0) { + commonResponse.getData().getVars().set是否有宠物("是"); + } + //------------是否有植物---------- + boolean plantExist = TimingAcquisition.havaNurseryPlant(request.getUid()); + if (plantExist) { + commonResponse.getData().getVars().set是否有植物("是"); + } + //------------是否开启日常任务---------- + boolean dailyTaskExist = TimingAcquisition.havaDailyTask(request.getUid()); + if (dailyTaskExist) { + commonResponse.getData().getVars().set是否开启日常任务("是"); + } String feedContent = "后台返回参数 = [" + "code:" + commonResponse.getCode() + ", msg:" + commonResponse.getMsg() + @@ -80,6 +95,9 @@ public class ProxyFactory { ", 消息提醒:" + commonResponse.getData().getVars().get消息提醒() + ", 任务完成:" + commonResponse.getData().getVars().get任务完成() + ", 玩家金币数量:" + commonResponse.getData().getVars().get玩家金币数量() + + ", 是否有宠物:" + commonResponse.getData().getVars().get是否有宠物() + + ", 是否有植物:" + commonResponse.getData().getVars().get是否有植物() + + ", 是否开启日常任务:" + commonResponse.getData().getVars().get是否开启日常任务() + "]"; //玩家有新消息提示 log.info(feedContent); diff --git a/src/main/java/com/qiwuai/garden/common/TimingAcquisition.java b/src/main/java/com/qiwuai/garden/common/TimingAcquisition.java index 241837d..2652a32 100644 --- a/src/main/java/com/qiwuai/garden/common/TimingAcquisition.java +++ b/src/main/java/com/qiwuai/garden/common/TimingAcquisition.java @@ -12,6 +12,7 @@ import com.qiwuai.garden.dto.base.ResultVarsResponse; import com.qiwuai.garden.dto.request.OperationRequest; import com.qiwuai.garden.pojo.*; import com.qiwuai.garden.service.plantService.PlantService; +import com.sun.java.swing.plaf.windows.WindowsTextAreaUI; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -351,14 +352,14 @@ public class TimingAcquisition { playerList.addAll(regionPlayerList); } String address = String.join("+", playerList); - HttpUtil.doPut("玩家地址", address); + HttpUtil.doPut("项目词组玩家地址", address); } //更新植物名称的动态词组 if (plantMap.size() != 0) { //所有植物名称 List plantNameList = plantMap.values().stream().map(PlantPojo::getName).collect(Collectors.toList()); String plantNames = String.join("+", plantNameList); - HttpUtil.doPut("植物名称", plantNames); + HttpUtil.doPut("项目词组植物名称", plantNames); } //更新果实名称的动态词组 if (itemConfigMap.size() != 0) { @@ -371,63 +372,69 @@ public class TimingAcquisition { } } String fruitNames = String.join("+", fruitNameList); - HttpUtil.doPut("果实名称", fruitNames); + HttpUtil.doPut("项目词组果实名称", fruitNames); } //更新宠物名称的动态词组 if (petConfigMap.size() != 0) { //所有宠物名称 List petNameList = petConfigMap.values().stream().map(PetPojo::getName).collect(Collectors.toList()); String petNames = String.join("+", petNameList); - HttpUtil.doPut("宠物名称", petNames); + HttpUtil.doPut("项目词组宠物名称", petNames); } - //更新物品名称的动态词组 + //更新材料名称的动态词组 if (petConfigMap.size() != 0) { - //所有物品名称 - List itemNameList = itemConfigMap.values().stream().map(ItemPojo::getName).collect(Collectors.toList()); - String itemNames = String.join("+", itemNameList); - HttpUtil.doPut("物品名称", itemNames); + //所有材料名称 + List materialNameList = new ArrayList<>(); + for (Map.Entry entry : itemConfigMap.entrySet()) { + ItemPojo item = entry.getValue(); + if (item.getItemTypeId() == Constants.ITEM_TYPE_MATERIAL) { + materialNameList.add(item.getName()); + } + } + String materialNames = String.join("+", materialNameList); + HttpUtil.doPut("项目词组物品名称", materialNames); } //更新物品种类的动态词组 if (itemTypeMap.size() != 0) { //所有物品种类 List itemTypeList = itemTypeMap.values().stream().map(ItemTypePojo::getDescription).collect(Collectors.toList()); String itemTypes = String.join("+", itemTypeList); - HttpUtil.doPut("物品种类", itemTypes); + HttpUtil.doPut("项目词组物品种类", itemTypes); } //更新地区的动态词组 if (regionIPMap.size() != 0) { //所有地区 List placeList = new ArrayList<>(regionIPMap.keySet()); String places = String.join("+", placeList); - HttpUtil.doPut("地区", places); + HttpUtil.doPut("项目词组地区", places); } //更新花圃类型的动态词组 if (nurseryConfigMap.size() != 0) { //所有花圃类型 List nurseryNameList = nurseryConfigMap.values().stream().map(NurseryPojo::getName).collect(Collectors.toList()); String nurseryNames = String.join("+", nurseryNameList); - HttpUtil.doPut("花圃类型", nurseryNames); + HttpUtil.doPut("项目词组花圃类型", nurseryNames); } //更新技能名称的动态词组 if (gardenerSkillMap.size() != 0) { //所有技能名称 List skillNameList = gardenerSkillMap.values().stream().map(GardenerSkillPojo::getName).collect(Collectors.toList()); String skillNames = String.join("+", skillNameList); - HttpUtil.doPut("技能名称", skillNames); + HttpUtil.doPut("项目词组技能名称", skillNames); } //更新玩家称呼的动态词组 if (gardenerSkillMap.size() != 0) { //所有玩家称呼 List callNameList = callNameMap.values().stream().map(CallNamePojo::getName).collect(Collectors.toList()); String callNames = String.join("+", callNameList); - HttpUtil.doPut("玩家称呼", callNames); + HttpUtil.doPut("项目词组玩家称呼", callNames); } // //更新园丁名称的动态词组 // if (gardenerSkillMap.size() != 0) { // //所有园丁名称 // List nameList = friendList.stream().map(FriendDto::getName).collect(Collectors.toList()); // String skillNames = String.join("+", skillNameList); -// HttpUtil.doPut("园丁名称", skillNames); +// HttpUtil.doPut("项目词组园丁名称", skillNames); // } } @@ -524,6 +531,17 @@ public class TimingAcquisition { PlantPojo plant = entry.getValue(); if (plantName.equals(plant.getName())) { return plant.getId(); + } else { //在别名里找 + //所有该植物的别名 + String alias = plant.getAlias(); + if (!StringUtils.isEmpty(alias)) { + if (!Constants.NON_STR.equals(alias)) { + List aliasList = Arrays.asList(alias.split("\\|")); + if (aliasList.contains(plantName)) { + return plant.getId(); + } + } + } } } return Constants.REQ_NON; @@ -558,8 +576,20 @@ public class TimingAcquisition { while (iterator.hasNext()) { Map.Entry entry = iterator.next(); ItemPojo item = entry.getValue(); + //先在名称里找 if (itemName.equals(item.getName())) { return item; + } else { //在别名里找 + //所有物品别名 + String alias = item.getAlias(); + if (!StringUtils.isEmpty(alias)) { + if (!Constants.NON_STR.equals(alias)) { + List aliasList = Arrays.asList(alias.split("\\|")); + if (aliasList.contains(itemName)) { + return item; + } + } + } } } return null; @@ -638,6 +668,8 @@ public class TimingAcquisition { Map goodsMap = new ConcurrentHashMap<>(goodsLevelMap); //园丁性别 String gender = getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //保存根据查找条件找到的物品id集合,用于下一步的翻页操作 List itemIdList = new ArrayList<>(); //1.玩家提供了花圃类型 @@ -709,6 +741,7 @@ public class TimingAcquisition { String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "goods_check_fail_type_no_goods"); text = SpeechUtil.speechReplaceNum(text, itemTypeMap.get(itemTypeId).getDescription()); text += SpeechUtil.getMarketSpeech(gender, "goods_check_fail_type_no_goods"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(400305); @@ -768,8 +801,9 @@ public class TimingAcquisition { feedText.deleteCharAt(feedText.length() - 1); //获取对应话术 text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "goods_check_type_success"); - text = SpeechUtil.speechReplaceNum(text, itemLevelName, itemAttribute, itemType, feedText.toString()); + text = SpeechUtil.speechReplaceNum(text, itemLevelName, itemAttribute, itemType, String.valueOf(size), feedText.toString()); text += SpeechUtil.getMarketSpeech(gender, "goods_check_type_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); } commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -794,6 +828,17 @@ public class TimingAcquisition { PetPojo pet = entry.getValue(); if (petName.equals(pet.getName())) { return pet.getId(); + } else { //在别名里找 + //所有该动物的别名 + String alias = pet.getAlias(); + if (!StringUtils.isEmpty(alias)) { + if (!Constants.NON_STR.equals(alias)) { + List aliasList = Arrays.asList(alias.split("\\|")); + if (aliasList.contains(petName)) { + return pet.getId(); + } + } + } } } return Constants.REQ_NON; @@ -865,6 +910,8 @@ public class TimingAcquisition { Map taskFinishMap = gardenerMap.get(uid).getTaskFinishMap(); //园丁性别 String gender = getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); TaskResultDto taskResult = new TaskResultDto(); //返回结果 String taskName = ""; //任务名称 TaskPojo curTask = new TaskPojo(); @@ -901,16 +948,30 @@ public class TimingAcquisition { String result = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, "update_task_finished"); result = SpeechUtil.speechReplaceNum(result, taskName); result += SpeechUtil.getTaskSpeech(gender, "update_task_finished"); + result = SpeechUtil.speechReplaceNum(result, callName.getName(), callName.getSubName()); taskResult.setTaskId(curTask.getId()); taskResult.setResultText(result); taskResult.setFinished(false); } //已完成所有升级任务 - if (count == taskIdList.length) { + if (count >= taskIdList.length) { + //新手引导的园丁等级1升级到2时不提示 + if (level == 1) { + log.info(uid + "的任务:" + taskName + "已经达成"); + String result = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, "update_task_finished"); + result = SpeechUtil.speechReplaceNum(result, taskName); + result += SpeechUtil.getTaskSpeech(gender, "update_task_finished"); + result = SpeechUtil.speechReplaceNum(result, callName.getName(), callName.getSubName()); + taskResult.setTaskId(curTask.getId()); + taskResult.setResultText(result); + taskResult.setFinished(false); + return taskResult; + } log.info(uid + "的任务:" + taskName + "已完成,园丁升级条件已满足"); String result = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, "update_task_level_finished"); result = SpeechUtil.speechReplaceNum(result, taskName); result += SpeechUtil.getTaskSpeech(gender, "update_task_level_finished"); + result = SpeechUtil.speechReplaceNum(result, callName.getName(), callName.getSubName()); taskResult.setTaskId(curTask.getId()); taskResult.setResultText(result); taskResult.setFinished(true); @@ -945,6 +1006,8 @@ public class TimingAcquisition { } //园丁性别 String gender = getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); String taskName = ""; //任务名称 String result = ""; //该每日任务还未标记完成 @@ -970,6 +1033,7 @@ public class TimingAcquisition { result = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, "daily_task_finished"); result = SpeechUtil.speechReplaceNum(result, taskName, feedText.toString()); result += SpeechUtil.getTaskSpeech(gender, "daily_task_finished"); + result = SpeechUtil.speechReplaceNum(result, callName.getName(), callName.getSubName()); taskResult.setTaskId(task.getId()); taskResult.setResultText(result); taskResult.setFinished(true); @@ -1002,6 +1066,7 @@ public class TimingAcquisition { result += SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, "daily_task_all_finished"); result = SpeechUtil.speechReplaceNum(result, dailyTaskName, dailyFeedText.toString()); result += SpeechUtil.getTaskSpeech(gender, "daily_task_all_finished"); + result = SpeechUtil.speechReplaceNum(result, callName.getName(), callName.getSubName()); taskResult.setTaskId(dailyTask.getId()); taskResult.setResultText(result); taskResult.setFinished(true); @@ -1139,7 +1204,7 @@ public class TimingAcquisition { } /** - * 随机选择一个陌生人,优先本地区查找,本地区没有再找其他地区的陌生人 + * 随机选择一个有成熟植物的陌生人,优先本地区查找,本地区没有再找其他地区的陌生人 * @param uid * @return String */ @@ -1151,6 +1216,8 @@ public class TimingAcquisition { //当前玩家所有好友 List friendList = gardenerMap.get(uid).getFriendList(); List friendAddressList = new ArrayList<>(); + List maturePlantPlayerList = new ArrayList<>(); //有成熟植物的玩家 + String placeSide = place; //取出该地区所有非好友玩家 if (!StringUtils.isEmpty(friendList)) { for (FriendDto friend : friendList) { @@ -1158,28 +1225,57 @@ public class TimingAcquisition { } //去除该地区的好友 playerList.removeIf(friendAddressList::contains); - //去除玩家本人 - playerList.removeIf(location::contains); } - //本地区没有找到陌生人,去其他地区查找 - if (playerList.size() == 0) { + //去除玩家本人 + playerList.removeIf(location::contains); + //去除掉没有成熟植物的陌生人玩家 + if (playerList.size() != 0) { + for (String address : playerList) { + String uidSide = TimingAcquisition.addressMap.get(placeSide).get(address).getUid(); //对方uid + //玩家没有成熟的植物 + if (havaNurseryMaturePlant(uidSide)) { + maturePlantPlayerList.add(address); + } + } + } + //本地区没有找到有成熟植物的陌生人,去其他地区查找 + if (maturePlantPlayerList.size() == 0) { + List regionList = regionIPMap.values().stream().map(RegionPojo::getPlace).collect(Collectors.toList()); + List regionCloneList = new ArrayList<>(); + Collections.copy(regionCloneList, regionList); + regionCloneList.removeIf(place::contains); //去除本地区 + int regionCount = regionCloneList.size(); + int count = 0; //循环查找其他其他,知道找到有陌生人为止 do { - List regionList = regionIPMap.values().stream().map(RegionPojo::getPlace).collect(Collectors.toList()); - List regionCloneList = new ArrayList<>(); - Collections.copy(regionCloneList, regionList); - regionCloneList.removeIf(place::contains); //取出本地区 + count++; int random = RandomDropUtil.getRandomNum(0, regionCloneList.size()); - String placeSide = regionCloneList.get(random); + placeSide = regionCloneList.get(random); //选中地区的所有玩家 playerList = new ArrayList<>(addressMap.get(placeSide).keySet()); //去除该地区的好友 playerList.removeIf(friendAddressList::contains); - } while (playerList.size() == 0); + //去除掉没有成熟植物的陌生人玩家 + if (playerList.size() != 0) { + for (String address : playerList) { + String uidSide = TimingAcquisition.addressMap.get(placeSide).get(address).getUid(); //对方uid + //玩家没有成熟的植物 + if (havaNurseryMaturePlant(uidSide)) { + maturePlantPlayerList.add(address); + } + } + } + if (count >= regionCount) { + break; + } + } while (maturePlantPlayerList.size() == 0); + } + if (maturePlantPlayerList.size() == 0) { + return null; } //随机取一个本地区非好友的玩家 - int randomNum = RandomDropUtil.getRandomNum(0, playerList.size()); - return playerList.get(randomNum); + int randomNum = RandomDropUtil.getRandomNum(0, maturePlantPlayerList.size()); + return maturePlantPlayerList.get(randomNum); } /** @@ -1358,6 +1454,9 @@ public class TimingAcquisition { * @return String */ public static String findLastAddress(String uid, String address) { + if (StringUtils.isEmpty(address)) { + return null; + } //该玩家的地址 String location = gardenerMap.get(uid).getLocation(); String result = null; @@ -1392,6 +1491,9 @@ public class TimingAcquisition { * @return String */ public static String findNextAddress(String uid, String address) { + if (StringUtils.isEmpty(address)) { + return null; + } //该玩家的地址 String location = gardenerMap.get(uid).getLocation(); String result = null; @@ -1490,9 +1592,319 @@ public class TimingAcquisition { * @return CallNamePojo */ public static CallNamePojo getCallNameByUid(String uid) { - //园丁性别 + //玩家称呼id Integer callNameId = gardenerMap.get(uid).getGardenerInfo().getCallNameId(); - //找到对应的称呼id + //找到对应的称呼信息 return callNameMap.get(callNameId); } + + /** + * 根据玩家性别找到可选择的玩家称呼 + * @param uid + * @return CallNamePojo + */ + public static String getCallNameByGender(String uid) { + //园丁性别 + Integer gender = gardenerMap.get(uid).getGardenerInfo().getGender(); + //找到对应的称呼id + List callNamePojoList = callNameMap.values().stream().filter(callNamePojo -> gender.equals(callNamePojo.getGender())).collect(Collectors.toList()); + List callNameList = callNamePojoList.stream().map(CallNamePojo::getName).collect(Collectors.toList()); + return String.join("、", callNameList); + } + + /** + * 判断玩家是否有植物的花圃 + * @param uid + * @return boolean + */ + public static boolean havaNurseryPlant(String uid) { + //玩家所有花圃 + Map nurseryMap = gardenerMap.get(uid).getGarden().getNurseryInfos(); + for (Map.Entry entry : nurseryMap.entrySet()) { + NurseryInfoDto nurseryInfo = entry.getValue(); + if (!StringUtils.isEmpty(nurseryInfo.getPlantId())) { + return true; + } + } + return false; + } + + /** + * 判断玩家是否有成熟植物的花圃 + * @param uid + * @return boolean + */ + public static boolean havaNurseryMaturePlant(String uid) { + //玩家所有花圃 + Map nurseryMap = gardenerMap.get(uid).getGarden().getNurseryInfos(); + for (Map.Entry entry : nurseryMap.entrySet()) { + NurseryInfoDto nurseryInfo = entry.getValue(); + //花圃中有种植植物 + if (!StringUtils.isEmpty(nurseryInfo.getPlantId())) { + if (!StringUtils.isEmpty(nurseryInfo.getPlantTime())) { + //植物已成熟 + if (DateUtil.getCurrentTime().compareTo(nurseryInfo.getPlantTime().getMatureTime()) > 0) { + return true; + } + } + } + } + return false; + } + + /** + * 查询玩家是否有日常任务 + * @param uid + * @return boolean + */ + public static boolean havaDailyTask(String uid) { + //玩家所有花圃 + Map dailyTaskFinishMap = gardenerMap.get(uid).getDailyTaskFinishMap(); + if (StringUtils.isEmpty(dailyTaskFinishMap)) { + return false; + } + if (dailyTaskFinishMap.size() == 0) { + return false; + } + return true; + } + + /** + * 获取玩家累计的花圃增产加成值 + * @param uid + * @return BigDecimal + */ + public static BigDecimal getAddProduction(String uid) { + BigDecimal addPro = new BigDecimal(0); + //玩家各等级对应的技能 + Map skills = gardenerMap.get(uid).getGardenerInfo().getSkills(); + if (StringUtils.isEmpty(skills)) { + return addPro; + } + if (skills.size() == 0) { + return addPro; + } + for (Map.Entry entry : skills.entrySet()) { + GardenerSkillDto skill = entry.getValue(); + //初级种植 + if (skill.getId().equals(Constants.PRIMARY_PLANT)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + //中级种植 + if (skill.getId().equals(Constants.INTER_PLANT)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + //高效养护 + if (skill.getId().equals(Constants.HIGH_EFF_CARE)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + //高级种植 + if (skill.getId().equals(Constants.HIGH_PLANT)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + //花圃维护 + if (skill.getId().equals(Constants.NURSERY_CARE)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeB()); + } + //植物之心 + if (skill.getId().equals(Constants.PLANT_HEART)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeB()); + } + } + return addPro; + } + + /** + * 获取玩家累计的植物成熟时间减少加成值 + * @param uid + * @return BigDecimal + */ + public static BigDecimal getSpeedPlantMature(String uid) { + BigDecimal addPro = new BigDecimal(0); + //玩家各等级对应的技能 + Map skills = gardenerMap.get(uid).getGardenerInfo().getSkills(); + if (StringUtils.isEmpty(skills)) { + return addPro; + } + if (skills.size() == 0) { + return addPro; + } + for (Map.Entry entry : skills.entrySet()) { + GardenerSkillDto skill = entry.getValue(); + //催生术 + if (skill.getId().equals(Constants.SPEED_UP_PLANT)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + //植物之心 + if (skill.getId().equals(Constants.PLANT_HEART)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + } + return addPro; + } + + /** + * 获取玩家累计的增加花圃容量加成值 + * @param uid + * @return BigDecimal + */ + public static BigDecimal getAddNurseryCapacity(String uid) { + BigDecimal addPro = new BigDecimal(0); + //玩家各等级对应的技能 + Map skills = gardenerMap.get(uid).getGardenerInfo().getSkills(); + if (StringUtils.isEmpty(skills)) { + return addPro; + } + if (skills.size() == 0) { + return addPro; + } + for (Map.Entry entry : skills.entrySet()) { + GardenerSkillDto skill = entry.getValue(); + //园地维护 + if (skill.getId().equals(Constants.GARDEN_CARE)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + //花圃维护 + if (skill.getId().equals(Constants.NURSERY_CARE)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + //植物之心 + if (skill.getId().equals(Constants.PLANT_HEART)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeC()); + } + } + return addPro; + } + + /** + * 获取玩家累计的宠物生命加成值 + * @param uid + * @return BigDecimal + */ + public static BigDecimal getAddPetHP(String uid) { + BigDecimal addPro = new BigDecimal(0); + //玩家各等级对应的技能 + Map skills = gardenerMap.get(uid).getGardenerInfo().getSkills(); + if (StringUtils.isEmpty(skills)) { + return addPro; + } + if (skills.size() == 0) { + return addPro; + } + for (Map.Entry entry : skills.entrySet()) { + GardenerSkillDto skill = entry.getValue(); + //初级驯养 + if (skill.getId().equals(Constants.PRIMARY_TRAIN)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + //中级驯养 + if (skill.getId().equals(Constants.INTER_TRAIN)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + //战斗训练 + if (skill.getId().equals(Constants.FIGHT_TRAIN)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + //高级驯养 + if (skill.getId().equals(Constants.HIGH_TRAIN)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + //宠物之心 + if (skill.getId().equals(Constants.PET_HEART)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + } + return addPro; + } + + /** + * 获取玩家累计的宠物攻击力加成值 + * @param uid + * @return BigDecimal + */ + public static BigDecimal getAddPetFC(String uid) { + BigDecimal addPro = new BigDecimal(0); + //玩家各等级对应的技能 + Map skills = gardenerMap.get(uid).getGardenerInfo().getSkills(); + if (StringUtils.isEmpty(skills)) { + return addPro; + } + if (skills.size() == 0) { + return addPro; + } + for (Map.Entry entry : skills.entrySet()) { + GardenerSkillDto skill = entry.getValue(); + //战斗训练 + if (skill.getId().equals(Constants.FIGHT_TRAIN)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeB()); + } + //勇气训练 + if (skill.getId().equals(Constants.BRAVE_TRAIN)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + //高效克制 + if (skill.getId().equals(Constants.HIGH_EFF_RESTRAIN)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + //宠物之心 + if (skill.getId().equals(Constants.PET_HEART)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeB()); + } + } + return addPro; + } + + /** + * 获取玩家累计的宠物防御力加成值 + * @param uid + * @return BigDecimal + */ + public static BigDecimal getAddPetDEF(String uid) { + BigDecimal addPro = new BigDecimal(0); + //玩家各等级对应的技能 + Map skills = gardenerMap.get(uid).getGardenerInfo().getSkills(); + if (StringUtils.isEmpty(skills)) { + return addPro; + } + if (skills.size() == 0) { + return addPro; + } + for (Map.Entry entry : skills.entrySet()) { + GardenerSkillDto skill = entry.getValue(); + //护栏加固 + if (skill.getId().equals(Constants.GARDEN_DEFEND)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + //高效防护 + if (skill.getId().equals(Constants.HIGH_EFF_DEFEND)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeA()); + } + } + return addPro; + } + + /** + * 获取玩家累计的宠物回血加成值 + * @param uid + * @return BigDecimal + */ + public static BigDecimal getAddPetLife(String uid) { + BigDecimal addPro = new BigDecimal(0); + //玩家各等级对应的技能 + Map skills = gardenerMap.get(uid).getGardenerInfo().getSkills(); + if (StringUtils.isEmpty(skills)) { + return addPro; + } + if (skills.size() == 0) { + return addPro; + } + for (Map.Entry entry : skills.entrySet()) { + GardenerSkillDto skill = entry.getValue(); + //宠物之心 + if (skill.getId().equals(Constants.PET_HEART)) { + addPro = addPro.add(gardenerSkillMap.get(skill.getId()).getTypeC()); + } + } + return addPro; + } } diff --git a/src/main/java/com/qiwuai/garden/common/schedule/ScheduleTask.java b/src/main/java/com/qiwuai/garden/common/schedule/ScheduleTask.java index 78be1ed..1777097 100644 --- a/src/main/java/com/qiwuai/garden/common/schedule/ScheduleTask.java +++ b/src/main/java/com/qiwuai/garden/common/schedule/ScheduleTask.java @@ -109,7 +109,7 @@ public class ScheduleTask { if (StringUtils.isEmpty(pet.getFeedCost())) { return; } - if (Constants.NON.equals(Integer.valueOf(pet.getFeedCost()))) { + if (Constants.NON_STR.equals(pet.getFeedCost())) { return; } //宠物投喂消耗物品和数量 diff --git a/src/main/java/com/qiwuai/garden/common/utils/HttpUtil.java b/src/main/java/com/qiwuai/garden/common/utils/HttpUtil.java index 28ef27b..9243d94 100644 --- a/src/main/java/com/qiwuai/garden/common/utils/HttpUtil.java +++ b/src/main/java/com/qiwuai/garden/common/utils/HttpUtil.java @@ -27,12 +27,12 @@ public class HttpUtil { String authorization = DigestUtils.md5Hex(appSecret + ":" + timestamp); //设置请求体 PhraseRequest phraseRequest = new PhraseRequest(); - phraseRequest.setWorkName("秘密花园"); + phraseRequest.setWorkName("追梦花园"); phraseRequest.setPhraseName(phraseName); phraseRequest.setPhraseContent(phraseContent); JSONObject object = new JSONObject(); - object.put("workName", "秘密花园"); + object.put("workName", "追梦花园"); object.put("phraseName", phraseName); object.put("phraseContent", phraseContent); //设置请求头 diff --git a/src/main/java/com/qiwuai/garden/common/utils/RandomDropUtil.java b/src/main/java/com/qiwuai/garden/common/utils/RandomDropUtil.java index a28ddf7..586ebe2 100644 --- a/src/main/java/com/qiwuai/garden/common/utils/RandomDropUtil.java +++ b/src/main/java/com/qiwuai/garden/common/utils/RandomDropUtil.java @@ -2,10 +2,7 @@ package com.qiwuai.garden.common.utils; import com.qiwuai.garden.common.Constants; import com.qiwuai.garden.common.TimingAcquisition; -import com.qiwuai.garden.dto.DropItemNumDto; -import com.qiwuai.garden.dto.GardenerDto; -import com.qiwuai.garden.dto.ItemDto; -import com.qiwuai.garden.dto.NurseryInfoDto; +import com.qiwuai.garden.dto.*; import com.qiwuai.garden.pojo.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -155,7 +152,7 @@ public class RandomDropUtil { return harvestItems; } //掉落物品id集合 - if (pet.getDropItems().equals(String.valueOf(Constants.NON))) { + if (Constants.NON_STR.equals(pet.getDropItems())) { return harvestItems; } String[] dropItemList = pet.getDropItems().split("\\|"); @@ -193,7 +190,7 @@ public class RandomDropUtil { return harvestItems; } //掉落物品id集合 - if (pet.getDropItems().equals(String.valueOf(Constants.NON))) { + if (Constants.NON_STR.equals(pet.getDropItems())) { return harvestItems; } String[] dropItemList = pet.getDropItems().split("\\|"); @@ -229,18 +226,26 @@ public class RandomDropUtil { NurseryPojo nurseryConfig = TimingAcquisition.nurseryConfigMap.get(nurseryInfo.getId()); //所有掉落汇总 List dropItemsTotal = new ArrayList<>(); + //玩家所有技能 + Map skills = TimingAcquisition.gardenerMap.get(uid).getGardenerInfo().getSkills(); //产生的果实数量,不同等级的花圃能提供不同的收获加成,并一定几率掉落物品 - //花圃中植物能产生的果实数量 + //花圃中一棵植物能产生的果实数量 int fruitNum = TimingAcquisition.plantMap.get(nurseryInfo.getPlantId()).getFruitNum(); fruit.setItemId(TimingAcquisition.plantMap.get(nurseryInfo.getPlantId()).getFruitId()); - fruit.setItemNum(0); + //累计收获加成比例 + BigDecimal totalPro = BigDecimal.valueOf(0); PlantPojo plant = TimingAcquisition.plantMap.get(nurseryInfo.getPlantId()); + //花圃中已种植的植物个数 + int plantCount = nurseryInfo.getNumber(); + //----------------花圃收获加成------------------- + totalPro = totalPro.add(nurseryConfig.getAddHarvest()); + //----------------------技能的收获加成--------------------- + totalPro = totalPro.add(TimingAcquisition.getAddProduction(uid)); + Integer totalNum = totalPro.add(new BigDecimal(1)).multiply(new BigDecimal(fruitNum * plantCount)).intValue(); + //果实数量累加 + fruit.setItemNum(totalNum); //遍历当前花圃中的所有植物 - for (int i = 0; i < nurseryInfo.getNumber(); i++) { - //花圃收获加成 - Integer totalNum = nurseryConfig.getAddHarvest().add(new BigDecimal(1)).multiply(new BigDecimal(fruitNum)).intValue(); - //果实数量累加 - fruit.setItemNum(fruit.getItemNum() + totalNum); + for (int i = 0; i < plantCount; i++) { List plantDropItems = plantDropItem(plant); //将植物掉落的果实合并到fruit中 for (int j = 0; j < plantDropItems.size(); j++) { @@ -288,7 +293,7 @@ public class RandomDropUtil { PetPojo petPojo = entry.getValue(); //宠物喜欢的植物 if (!StringUtils.isEmpty(petPojo.getFavoritePlantId())) { - if (Constants.NON.toString().equals(petPojo.getFavoritePlantId())) { + if (Constants.NON_STR.equals(petPojo.getFavoritePlantId())) { List favorPlantIdList = Arrays.asList(petPojo.getFavoritePlantId().split("\\|")); if (favorPlantIdList.contains(nurseryInfo.getPlantId().toString())) { //统计有概率出现的宠物 diff --git a/src/main/java/com/qiwuai/garden/common/utils/RequestConversionUtil.java b/src/main/java/com/qiwuai/garden/common/utils/RequestConversionUtil.java index f635320..bba1e63 100644 --- a/src/main/java/com/qiwuai/garden/common/utils/RequestConversionUtil.java +++ b/src/main/java/com/qiwuai/garden/common/utils/RequestConversionUtil.java @@ -6,6 +6,7 @@ import com.qiwuai.garden.dto.GardenerDto; 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.AttributePojo; import com.qiwuai.garden.pojo.ItemPojo; import com.qiwuai.garden.pojo.PlantPojo; import com.qiwuai.garden.service.gardenerService.GardenerService; @@ -16,6 +17,7 @@ import org.springframework.util.StringUtils; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; public class RequestConversionUtil { Logger log = LoggerFactory.getLogger(RequestConversionUtil.class); @@ -238,6 +240,15 @@ public class RequestConversionUtil { //-----------------存在物品属性------------------ String itemAttribute = callRequest.get物品属性(); if (!StringUtils.isEmpty(itemAttribute)) { + char[] attribute = itemAttribute.toCharArray(); + //所有属性 + List attributeNameList = TimingAcquisition.attributeMap.values().stream().map(AttributePojo::getAttribute).collect(Collectors.toList()); + for (char a : attribute) { + if (attributeNameList.contains(String.valueOf(a))) { + itemAttribute = String.valueOf(a); + break; + } + } Integer itemAttributeId = TimingAcquisition.getItemAttributeIdByName(itemAttribute); if (!StringUtils.isEmpty(itemAttributeId)) { operationRequest.setItemAttributeId(itemAttributeId); @@ -406,6 +417,17 @@ public class RequestConversionUtil { } operationRequest.setOfflineDays(number); } + //-----------存在消息序号-------------- + String noticeNum = callRequest.get消息序号(); + if (!StringUtils.isEmpty(noticeNum)) { + //找到中文数字对应的阿拉伯数字 + Integer number = TypeConvertUtil.change2Integer(noticeNum); + //中文中不包含中文数字时,提取阿拉伯数字 + if (number == 0) { + number = TypeConvertUtil.extractNum(noticeNum); + } + operationRequest.setNoticeNum(number); + } //---------存在任务类型:1-养成任务,2-日常任务---------- String taskType = callRequest.get任务类型(); if (!StringUtils.isEmpty(taskType)) { diff --git a/src/main/java/com/qiwuai/garden/controller/CommonController.java b/src/main/java/com/qiwuai/garden/controller/CommonController.java index e854a36..53480a9 100644 --- a/src/main/java/com/qiwuai/garden/controller/CommonController.java +++ b/src/main/java/com/qiwuai/garden/controller/CommonController.java @@ -76,8 +76,21 @@ public class CommonController { @PostMapping(value = "/call", produces = "application/json;charset=UTF-8") public CommonResponse startGame(@RequestBody CommonRequest commonRequest) throws ParseException { log.info(commonRequest.getUid() + "当前操作的原始请求参数:" + commonRequest.getVars()); - OperationRequest operationReq = RequestConversionUtil.request2Operation(commonRequest); CommonResponse result = new CommonResponse(); + //玩家没有提供uid + if (StringUtils.isEmpty(commonRequest.getUid())) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + log.info("未提供uid,无法创建用户"); + result.setCode(1); + result.setMsg("成功"); + resultResponse.set反馈ID(100003); + resultResponse.set反馈文本("未提供uid,无法创建用户"); + resultVarsResponse.setVars(resultResponse); + result.setData(resultVarsResponse); + return result; + } + OperationRequest operationReq = RequestConversionUtil.request2Operation(commonRequest); String operateName = commonRequest.getVars().get操作名(); log.info(operationReq.getUid() + "开始执行操作:【" + operateName + "】, 请求参数:" + operationReq); //操作名为null @@ -304,6 +317,9 @@ public class CommonController { case "取消出售指令": result = marketServiceProxy.sellCancel(operationReq); break; + case "出售宠物指令": + result = marketServiceProxy.sellPetCheck(operationReq); + break; case "统一出售指令": result = marketServiceProxy.sellAllCheck(operationReq); break; @@ -316,9 +332,15 @@ public class CommonController { case "确认取消指令": result = marketServiceProxy.cancel(operationReq); break; + case "打开商店指令": + result = marketServiceProxy.openShop(operationReq); + break; case "查询商品指令": result = marketServiceProxy.goodsCheck(operationReq); break; + case "退出商店指令": + result = marketServiceProxy.quitShop(operationReq); + break; case "拜访陌生人": case "拜访好友": result = socialServiceProxy.visitStrangerCheck(operationReq); //拜访好友的方法跟拜访陌生人一样 diff --git a/src/main/java/com/qiwuai/garden/dto/base/ResultResponse.java b/src/main/java/com/qiwuai/garden/dto/base/ResultResponse.java index 2448de1..975c743 100644 --- a/src/main/java/com/qiwuai/garden/dto/base/ResultResponse.java +++ b/src/main/java/com/qiwuai/garden/dto/base/ResultResponse.java @@ -1,5 +1,6 @@ package com.qiwuai.garden.dto.base; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; @Data @@ -43,11 +44,25 @@ public class ResultResponse { /** * 玩家称呼,bot话题模块需要该变量 */ - private String 玩家称呼; + @JsonProperty("GB_玩家称呼") + private String GB_玩家称呼; /** * 玩家第二人称称呼,bot话题模块需要该变量 */ - private String 玩家第二人称称呼; + @JsonProperty("GB_玩家第二人称称呼") + private String GB_玩家第二人称称呼; + /** + * 是否有宠物,bot话题模块需要该变量 + */ + private String 是否有宠物 = "否"; + /** + * 是否有植物,bot话题模块需要该变量 + */ + private String 是否有植物 = "否"; + /** + * 是否开启日常任务,bot话题模块需要该变量 + */ + private String 是否开启日常任务 = "否"; /***************************用于清空bot端保留的变量***********************************/ /** diff --git a/src/main/java/com/qiwuai/garden/dto/request/CallRequest.java b/src/main/java/com/qiwuai/garden/dto/request/CallRequest.java index 91fe1b5..f681435 100644 --- a/src/main/java/com/qiwuai/garden/dto/request/CallRequest.java +++ b/src/main/java/com/qiwuai/garden/dto/request/CallRequest.java @@ -58,6 +58,7 @@ public class CallRequest { /** * 玩家称呼 */ + @JsonProperty(value = "GB_玩家称呼") private String 玩家称呼; /** * 所属地区 @@ -140,6 +141,10 @@ public class CallRequest { */ private String 离线时长; /** + * 消息序号 + */ + private String 消息序号; + /** * 任务类型 */ private String 任务类型; diff --git a/src/main/java/com/qiwuai/garden/dto/request/OperationRequest.java b/src/main/java/com/qiwuai/garden/dto/request/OperationRequest.java index 6566047..13e83c9 100644 --- a/src/main/java/com/qiwuai/garden/dto/request/OperationRequest.java +++ b/src/main/java/com/qiwuai/garden/dto/request/OperationRequest.java @@ -159,6 +159,10 @@ public class OperationRequest { */ private Integer offlineDays; /** + * 消息序号 + */ + private Integer noticeNum; + /** * 任务类型 */ private Integer taskType; diff --git a/src/main/java/com/qiwuai/garden/pojo/ItemPojo.java b/src/main/java/com/qiwuai/garden/pojo/ItemPojo.java index 859741c..36fb140 100644 --- a/src/main/java/com/qiwuai/garden/pojo/ItemPojo.java +++ b/src/main/java/com/qiwuai/garden/pojo/ItemPojo.java @@ -13,6 +13,10 @@ public class ItemPojo { */ private String name; /** + * 物品别名 + */ + private String alias; + /** * 物品描述 */ private String description; diff --git a/src/main/java/com/qiwuai/garden/pojo/PetPojo.java b/src/main/java/com/qiwuai/garden/pojo/PetPojo.java index a6bd4f5..a71880d 100644 --- a/src/main/java/com/qiwuai/garden/pojo/PetPojo.java +++ b/src/main/java/com/qiwuai/garden/pojo/PetPojo.java @@ -15,6 +15,10 @@ public class PetPojo { */ private String name; /** + * 宠物别名 + */ + private String alias; + /** * 种类id:1-虫,2-灵兽,3-飞禽,4-精灵等 */ private Integer typeId; diff --git a/src/main/java/com/qiwuai/garden/pojo/PlantPojo.java b/src/main/java/com/qiwuai/garden/pojo/PlantPojo.java index 8a7d7cf..47d98b8 100644 --- a/src/main/java/com/qiwuai/garden/pojo/PlantPojo.java +++ b/src/main/java/com/qiwuai/garden/pojo/PlantPojo.java @@ -15,6 +15,10 @@ public class PlantPojo { */ private String name; /** + * 植物别名 + */ + private String alias; + /** * 植物描述 */ private String description; 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 18dcc21..fa95e4b 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 @@ -1,18 +1,18 @@ package com.qiwuai.garden.service.backPackService.impl; +import com.alibaba.fastjson.JSON; import com.qiwuai.garden.common.Constants; import com.qiwuai.garden.common.TimingAcquisition; +import com.qiwuai.garden.common.utils.PersistenceUtil; import com.qiwuai.garden.common.utils.SpeechUtil; +import com.qiwuai.garden.dto.GardenerDto; import com.qiwuai.garden.dto.ItemBagDto; import com.qiwuai.garden.dto.ItemDto; 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.ItemPojo; -import com.qiwuai.garden.pojo.ItemTypePojo; -import com.qiwuai.garden.pojo.PlantPojo; -import com.qiwuai.garden.pojo.QuantityRangePojo; +import com.qiwuai.garden.pojo.*; import com.qiwuai.garden.service.backPackService.BackPackService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,6 +92,8 @@ public class BackPackServiceImpl implements BackPackService { log.info(uid + "开始根据物品种类查看背包详情"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //物品种类 List itemTypeList = TimingAcquisition.itemTypeMap.values().stream().map(ItemTypePojo::getDescription).collect(Collectors.toList()); String itemTypes = String.join("、", itemTypeList); @@ -101,6 +103,7 @@ public class BackPackServiceImpl implements BackPackService { String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "view_back_pack_item_fail_no_type"); text = SpeechUtil.speechReplaceNum(text, itemTypes); text += SpeechUtil.getGardenerSpeech(gender, "view_back_pack_item_fail_no_type"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200403); @@ -118,6 +121,7 @@ public class BackPackServiceImpl implements BackPackService { String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "view_back_pack_item_fail_not_exist"); text = SpeechUtil.speechReplaceNum(text, itemTypes); text += SpeechUtil.getGardenerSpeech(gender, "view_back_pack_item_fail_not_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200404); @@ -194,6 +198,7 @@ public class BackPackServiceImpl implements BackPackService { text += SpeechUtil.getGardenerSpeech(gender, "view_back_pack_item_few"); resultResponse.set后台附加返回("查看背包回复2"); } + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); log.info("物品详情查询结果:" + feedText.toString()); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -222,6 +227,8 @@ public class BackPackServiceImpl implements BackPackService { ItemDto money = itemBags.get(Constants.ITEM_TYPE_MONEY).getItems(moneyId); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //数量范围配置信息 Map quantityRangeMap = TimingAcquisition.quantityRangeMap; //保存货币数量范围 @@ -249,7 +256,7 @@ public class BackPackServiceImpl implements BackPackService { } else { //背包货币数量少的情况,园丁的回答 text += SpeechUtil.getGardenerSpeech(gender, "view_money_few"); } - + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); log.info("货币查询结果:" + money.getItemNum()); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -272,11 +279,14 @@ public class BackPackServiceImpl implements BackPackService { log.info(uid + "开始检索物品信息"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家没提供物品名称 if (StringUtils.isEmpty(itemId)) { log.info(uid + "玩家没提供查看的物品名称"); //获取对应话术 String text = SpeechUtil.getGardenerSpeech(gender, "search_item_info_no_item"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200603); @@ -292,6 +302,7 @@ public class BackPackServiceImpl implements BackPackService { //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "search_item_info_no_exist"); text += SpeechUtil.getGardenerSpeech(gender, "search_item_info_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200604); @@ -323,6 +334,7 @@ public class BackPackServiceImpl implements BackPackService { text = SpeechUtil.speechReplaceNum(text, itemConfig.getName(), itemConfig.getDescription()); text += SpeechUtil.getGardenerSpeech(gender, "search_item_info_item_none"); } + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); log.info(uid + "没有检索到物品信息:" + itemConfig.getName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -373,6 +385,12 @@ public class BackPackServiceImpl implements BackPackService { //给玩家扣除物品 TimingAcquisition.addAwardItem(uid, awardItemList); } + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); + commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200901); diff --git a/src/main/java/com/qiwuai/garden/service/gardenerService/impl/GardenerServiceImpl.java b/src/main/java/com/qiwuai/garden/service/gardenerService/impl/GardenerServiceImpl.java index 4002587..09dc789 100644 --- a/src/main/java/com/qiwuai/garden/service/gardenerService/impl/GardenerServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/gardenerService/impl/GardenerServiceImpl.java @@ -380,7 +380,7 @@ public class GardenerServiceImpl implements GardenerService { commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100002); - resultResponse.set反馈文本("园丁性别已改为" + ((gender == 2) ? "男生" : "女生")); + resultResponse.set反馈文本("园丁性别已改为" + ((gender == 1) ? "男生" : "女生")); resultVarsResponse.setVars(resultResponse); commonResponse.setData(resultVarsResponse); return commonResponse; @@ -399,15 +399,21 @@ public class GardenerServiceImpl implements GardenerService { //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); log.info(uid + "开始更改玩家称呼" + gardenerInfo.getCallNameId() + "为" + callNameId); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); + //该玩家可选择的称呼 + String callNameText = TimingAcquisition.getCallNameByGender(uid); //玩家未提供称呼 if (StringUtils.isEmpty(callNameId)) { log.info(uid + "未提供玩家称呼,无法更改称呼"); //获取对应话术 - String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "gardener_call_name_change_fail_null"); + String text = SpeechUtil.getGardenerSpeech(gender, "gardener_call_name_change_fail_null"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName(), gardenerInfo.getName(), callNameText); commonResponse.setCode(1); commonResponse.setMsg("成功"); - resultResponse.set反馈ID(1000104); + resultResponse.set反馈ID(200901); resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("更改称呼回复1"); resultVarsResponse.setVars(resultResponse); commonResponse.setData(resultVarsResponse); return commonResponse; @@ -417,9 +423,10 @@ public class GardenerServiceImpl implements GardenerService { log.info(uid + "提供的玩家称呼不存在"); //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "gardener_call_name_change_fail_not_exist"); + text = SpeechUtil.speechReplaceNum(text, callNameText); commonResponse.setCode(1); commonResponse.setMsg("成功"); - resultResponse.set反馈ID(1000105); + resultResponse.set反馈ID(200902); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); commonResponse.setData(resultVarsResponse); @@ -428,15 +435,15 @@ public class GardenerServiceImpl implements GardenerService { CallNamePojo callNamePojo = TimingAcquisition.callNameMap.get(callNameId); assert callNamePojo != null; //获取对应话术 - String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "gardener_call_name_change_success"); - text = SpeechUtil.speechReplaceNum(text, callNamePojo.getName(), callNamePojo.getSubName()); + String text = SpeechUtil.getGardenerSpeech(gender, "gardener_call_name_change_success"); + text = SpeechUtil.speechReplaceNum(text, callNamePojo.getName(), callName.getSubName()); gardenerInfo.setCallNameId(callNameId); commonResponse.setCode(1); commonResponse.setMsg("成功"); - resultResponse.set反馈ID(1000103); + resultResponse.set反馈ID(200903); resultResponse.set反馈文本(text); - resultResponse.set玩家称呼(callNamePojo.getName()); - resultResponse.set玩家第二人称称呼(callNamePojo.getSubName()); + resultResponse.setGB_玩家称呼(callNamePojo.getName()); + resultResponse.setGB_玩家第二人称称呼(callNamePojo.getSubName()); resultVarsResponse.setVars(resultResponse); commonResponse.setData(resultVarsResponse); return commonResponse; @@ -478,12 +485,15 @@ public class GardenerServiceImpl implements GardenerService { GardenerInfoDto gardenerInfo = TimingAcquisition.gardenerMap.get(uid).getGardenerInfo(); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //园丁等级上限 int GardenerLVMax = Integer.parseInt(TimingAcquisition.systemConfigMap.get("gardener_level_max").getValue()); if ((gardenerInfo.getLevel() + 1) > GardenerLVMax) { //已经达到最大等级 //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "gardener_upgrade_fail_had"); text += SpeechUtil.getGardenerSpeech(gender, "gardener_upgrade_fail_had"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200108); @@ -539,6 +549,7 @@ public class GardenerServiceImpl implements GardenerService { String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "gardener_upgrade_check"); text = SpeechUtil.speechReplaceNum(text, gardenerInfo.getLevel().toString(), feedText.toString()); text += SpeechUtil.getGardenerSpeech(gender, "gardener_upgrade_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200101); @@ -560,6 +571,8 @@ public class GardenerServiceImpl implements GardenerService { log.info(uid + "开始升级园丁等级"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //园丁等级上限 int GardenerLVMax = Integer.parseInt(TimingAcquisition.systemConfigMap.get("gardener_level_max").getValue()); //园丁基本信息 @@ -568,6 +581,7 @@ public class GardenerServiceImpl implements GardenerService { //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "gardener_upgrade_fail_had"); text += SpeechUtil.getGardenerSpeech(gender, "gardener_upgrade_fail_had"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200109); @@ -613,6 +627,7 @@ public class GardenerServiceImpl implements GardenerService { text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "gardener_upgrade_fail_task"); text = SpeechUtil.speechReplaceNum(text, feedText.toString()); text += SpeechUtil.getGardenerSpeech(gender, "gardener_upgrade_fail_task"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); number = 200102; resultResponse.set后台附加返回("升级园丁回复5"); } else { //满足升级条件 @@ -632,6 +647,7 @@ public class GardenerServiceImpl implements GardenerService { text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "gardener_upgrade_fail"); text = SpeechUtil.speechReplaceNum(text, itemConfigMap.get(item.getItemId()).getName()); text += SpeechUtil.getGardenerSpeech(gender, "gardener_upgrade_fail"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set后台附加返回("升级园丁回复2"); break; } @@ -642,6 +658,7 @@ public class GardenerServiceImpl implements GardenerService { text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "gardener_upgrade_fail"); text = SpeechUtil.speechReplaceNum(text, itemConfigMap.get(item.getItemId()).getName()); text += SpeechUtil.getGardenerSpeech(gender, "gardener_upgrade_fail"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set后台附加返回("升级园丁回复2"); break; } @@ -700,18 +717,24 @@ public class GardenerServiceImpl implements GardenerService { //将玩家当前可学习的技能保存到缓存的list中 List skillIds = Stream.of(skillIdList).map(Integer::valueOf).collect(Collectors.toList()); operationReq.setList(skillIds); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "gardener_upgrade_success"); text = SpeechUtil.speechReplaceNum(text, feedText.toString()); text += SpeechUtil.getGardenerSpeech(gender, "gardener_upgrade_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set后台附加返回("升级园丁回复3"); //---------------------新手引导的园丁升级至2任务完成------------------------ - if ("完成10010".equals(noviceGuide) && gardenerInfo.getLevel() == 2) { - resultResponse.set任务完成("10011"); - log.info(uid + "新手引导的园丁升级任务10011已完成"); - } +// if ("完成10010".equals(noviceGuide) && gardenerInfo.getLevel() == 2) { +// resultResponse.set任务完成("10011"); +// log.info(uid + "新手引导的园丁升级任务10011已完成"); +// } //---------------------新手引导的园丁升级至3任务完成------------------------ - if ("完成10018".equals(noviceGuide) && gardenerInfo.getLevel() == 3) { + if ("完成10018".equals(noviceGuide) && gardenerInfo.getLevel() >= 3) { resultResponse.set任务完成("10019"); log.info(uid + "新手引导的园丁升级任务10019已完成"); } @@ -746,9 +769,12 @@ public class GardenerServiceImpl implements GardenerService { } //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "gardener_upgrade_cancel"); text += SpeechUtil.getGardenerSpeech(gender, "gardener_upgrade_cancel"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200110); @@ -804,6 +830,8 @@ public class GardenerServiceImpl implements GardenerService { Integer skillId = operationReq.getSkillId(); Integer rank = operationReq.getRank(); //玩家说的序号 log.info(uid + "开始查看技能信息,技能id:" + skillId + ",或者序号:" + rank); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); //园丁已学习了技能的当前最大等级 @@ -871,6 +899,7 @@ public class GardenerServiceImpl implements GardenerService { String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "learn_skill_fail_no_skill"); text = SpeechUtil.speechReplaceNum(text, feedText.toString()); text += SpeechUtil.getGardenerSpeech(gender, "learn_skill_fail_no_skill"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200111); @@ -887,6 +916,7 @@ public class GardenerServiceImpl implements GardenerService { String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "learn_skill_fail_no_exist"); text = SpeechUtil.speechReplaceNum(text, feedText.toString()); text += SpeechUtil.getGardenerSpeech(gender, "learn_skill_fail_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200112); @@ -965,6 +995,7 @@ public class GardenerServiceImpl implements GardenerService { String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "learn_skill_check"); text = SpeechUtil.speechReplaceNum(text, gardenerSkill.getName(), description); text += SpeechUtil.getGardenerSpeech(gender, "learn_skill_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200105); @@ -983,6 +1014,8 @@ public class GardenerServiceImpl implements GardenerService { String uid = operationReq.getUid(); log.info(uid + "园丁开始学习新技能"); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { @@ -1036,6 +1069,7 @@ public class GardenerServiceImpl implements GardenerService { String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "learn_skill_fail_not_allow"); text = SpeechUtil.speechReplaceNum(text, feedText.toString()); text += SpeechUtil.getGardenerSpeech(gender, "learn_skill_fail_not_allow"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200114); @@ -1056,10 +1090,16 @@ public class GardenerServiceImpl implements GardenerService { gardenerSkills.put(level, newSkill); gardenerInfo.setSkills(gardenerSkills); log.info("园丁学习到的技能id:" + skillId); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "learn_skill_success"); text = SpeechUtil.speechReplaceNum(text, gardenerSkillMap.get(skillId).getName()); text += SpeechUtil.getGardenerSpeech(gender, "learn_skill_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); //针对已经重置技能的情况,玩家还有等级没有学习技能则接着学习 int[] maxLevel = {0}; //需要形参影响实参 ResultResponse result = searchSkillBeforeLearn(uid, maxLevel); @@ -1089,10 +1129,16 @@ public class GardenerServiceImpl implements GardenerService { gardenerSkills.put(level, newSkill); gardenerInfo.setSkills(gardenerSkills); log.info("园丁学习到的技能id:" + skillId); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "learn_skill_success"); text = SpeechUtil.speechReplaceNum(text, gardenerSkillMap.get(skillId).getName()); text += SpeechUtil.getGardenerSpeech(gender, "learn_skill_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); //针对已经重置技能的情况,玩家还有等级没有学习技能则接着学习 int[] maxLevel = {0}; //需要形参影响实参 ResultResponse result = searchSkillBeforeLearn(uid, maxLevel); @@ -1122,6 +1168,7 @@ public class GardenerServiceImpl implements GardenerService { String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "learn_skill_fail_had"); text = SpeechUtil.speechReplaceNum(text, feedText.toString()); text += SpeechUtil.getGardenerSpeech(gender, "learn_skill_fail_had"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); //清除缓存,本轮对话结束 // CacheGlobal.concurrentMap.remove(uid); commonResponse.setCode(1); @@ -1139,9 +1186,15 @@ public class GardenerServiceImpl implements GardenerService { newSkill.setName(gardenerSkillMap.get(skillId).getName()); gardenerSkills.put(level, newSkill); //获取对应话术 + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "learn_skill_success"); text = SpeechUtil.speechReplaceNum(text, gardenerSkillMap.get(skillId).getName()); text += SpeechUtil.getGardenerSpeech(gender, "learn_skill_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); //针对已经重置技能的情况,玩家还有等级没有学习技能则接着学习 int[] maxLevel = {0}; //需要形参影响实参 ResultResponse result = searchSkillBeforeLearn(uid, maxLevel); @@ -1173,6 +1226,8 @@ public class GardenerServiceImpl implements GardenerService { String uid = operationReq.getUid(); log.info(uid + "开始查看当前等级的所有技能信息"); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { @@ -1200,6 +1255,7 @@ public class GardenerServiceImpl implements GardenerService { String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "learn_skill_cancel"); text = SpeechUtil.speechReplaceNum(text, feedText.toString()); text += SpeechUtil.getGardenerSpeech(gender, "learn_skill_cancel"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); //保存玩家这轮的请求信息,用于下一步的操作 operationReq.setLevel(level); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); @@ -1232,6 +1288,8 @@ public class GardenerServiceImpl implements GardenerService { int resetMax = Integer.parseInt(skillResetMax.getValue()); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //超过重置次数上限,统一按上限次数的费用计算 if ((skillResetTimes + 1) > resetMax) { skillResetTimes = resetMax - 1; @@ -1245,8 +1303,7 @@ public class GardenerServiceImpl implements GardenerService { String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "reset_skill_check"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(skillResetCost), moneyConfig.getName()); text += SpeechUtil.getGardenerSpeech(gender, "reset_skill_check"); - log.info(text); - + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200201); @@ -1267,6 +1324,8 @@ public class GardenerServiceImpl implements GardenerService { log.info(uid + "开始重置园丁技能"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //园丁基本信息 GardenerInfoDto gardenerInfo = TimingAcquisition.gardenerMap.get(uid).getGardenerInfo(); //园丁等级 @@ -1276,6 +1335,7 @@ public class GardenerServiceImpl implements GardenerService { //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "reset_skill_fail_level"); text += SpeechUtil.getGardenerSpeech(gender, "reset_skill_fail_level"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200205); @@ -1284,11 +1344,24 @@ public class GardenerServiceImpl implements GardenerService { commonResponse.setData(resultVarsResponse); return commonResponse; } + //玩家没有技能 + if (StringUtils.isEmpty(gardenerInfo.getSkills())) { + //获取对应话术 + String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "reset_skill_fail_null"); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(200206); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } //已重置过技能 if (gardenerInfo.getSkills().size() == 0) { //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "reset_skill_fail_had"); text += SpeechUtil.getGardenerSpeech(gender, "reset_skill_fail_had"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200202); @@ -1323,7 +1396,7 @@ public class GardenerServiceImpl implements GardenerService { //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "reset_skill_fail_money"); text += SpeechUtil.getGardenerSpeech(gender, "reset_skill_fail_money"); - text = SpeechUtil.speechReplaceNum(text, moneyConfig.getName()); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName(), moneyConfig.getName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200203); @@ -1355,10 +1428,16 @@ public class GardenerServiceImpl implements GardenerService { feedText.deleteCharAt(feedText.length() - 1); //技能重置花费信息 ItemPojo moneyConfig = TimingAcquisition.itemConfigMap.get(moneyId); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "reset_skill_success"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(skillResetCost), moneyConfig.getName(), feedText.toString()); text += SpeechUtil.getGardenerSpeech(gender, "reset_skill_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); //保存玩家这轮的请求信息,用于下一步的操作 log.info(uid + "重置技能后的下一等级为" + level); //将玩家当前可学习的技能保存到缓存的list中 @@ -1387,9 +1466,12 @@ public class GardenerServiceImpl implements GardenerService { log.info(uid + "开始依次查询哪些等级还未学习技能"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "reset_skill_cancel"); text += SpeechUtil.getGardenerSpeech(gender, "reset_skill_cancel"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); //清除本轮对话缓存数据 CacheGlobal.concurrentMap.remove(uid); @@ -1418,18 +1500,17 @@ public class GardenerServiceImpl implements GardenerService { Map gardenerSkillMap = TimingAcquisition.gardenerSkillMap; //园丁现有技能 Map gardenerSkills = gardenerInfo.getSkills(); - //找出现有技能中对应的最大等级 - int maxLevel; - if (gardenerSkills.size() == 0) { //没有技能,则从1开始 - maxLevel = 1; - } else { //有技能则从等级最大值开始(最小为2) - Set keySet = gardenerSkills.keySet(); - Object[] obj = keySet.toArray(); - Arrays.sort(obj); - maxLevel = Integer.parseInt(obj[obj.length - 1].toString()); + int maxLevel = 1; + //玩家还没有技能 + if (!StringUtils.isEmpty(gardenerSkills)) { + if (gardenerSkills.size() != 0) { //有技能则从等级最大值开始(最小为2) + Set keySet = gardenerSkills.keySet(); + Object[] obj = keySet.toArray(); + Arrays.sort(obj); + maxLevel = Integer.parseInt(obj[obj.length - 1].toString()); + } } - //技能的等级要小于等于园丁的等级,大于则已学习完毕 if ((maxLevel + 1) > gardenerInfo.getLevel()) { log.info("所有技能已学习完毕"); @@ -1469,10 +1550,19 @@ public class GardenerServiceImpl implements GardenerService { log.info(uid + "开始查询园丁更名所需条件"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); + String renameMin = TimingAcquisition.systemConfigMap.get("rename_min").getValue(); + String renameMax = TimingAcquisition.systemConfigMap.get("rename_max").getValue(); if (StringUtils.isEmpty(rename)) { - log.info("没有名称,修改不了"); + log.info(uid+ "没有提供名称,修改不了"); + //园丁名称 + String gardenerName = TimingAcquisition.gardenerMap.get(uid).getGardenerInfo().getName(); //获取对应话术 - String text = SpeechUtil.getGardenerSpeech(gender, "rename_fail_no_name"); + String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "rename_fail_no_name"); + text = SpeechUtil.speechReplaceNum(text, gardenerName, renameMin, renameMax); + text += SpeechUtil.getGardenerSpeech(gender, "rename_fail_no_name"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200301); @@ -1482,6 +1572,21 @@ public class GardenerServiceImpl implements GardenerService { commonResponse.setData(resultVarsResponse); return commonResponse; } + //园丁名称字数不在限制范围内 + if (rename.length() < Integer.parseInt(renameMin) || rename.length() > Integer.parseInt(renameMax)) { + log.info(uid + "提供的园丁名称:" + rename + "不在限制长度" + renameMin + "到" + renameMax + "内"); + //获取对应话术 + String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "rename_fail_over"); + text = SpeechUtil.speechReplaceNum(text, renameMin, renameMax); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(200307); + resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("更改园丁姓名回复1"); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } //更名所需费用 String renameCost = TimingAcquisition.systemConfigMap.get("rename_cost").getValue(); List renameCostItem = TypeConvertUtil.itemString2List(renameCost); @@ -1511,13 +1616,15 @@ public class GardenerServiceImpl implements GardenerService { if (renameFreeTimes > 0) { //获取对应话术 text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "rename_check_first_free"); + text = SpeechUtil.speechReplaceNum(text, rename); text += SpeechUtil.getGardenerSpeech(gender, "rename_check_first_free"); } else { //获取对应话术 text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "rename_check"); - text = SpeechUtil.speechReplaceNum(text, feedText.toString()); + text = SpeechUtil.speechReplaceNum(text, rename, feedText.toString()); text += SpeechUtil.getGardenerSpeech(gender, "rename_check"); } + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); log.info(uid + "更名需要花费" + feedText.toString()); commonResponse.setCode(1); @@ -1549,6 +1656,8 @@ public class GardenerServiceImpl implements GardenerService { String rename = lastReq.getName(); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //园丁基本信息 GardenerInfoDto gardenerInfo = TimingAcquisition.gardenerMap.get(uid).getGardenerInfo(); log.info("园丁当前名称:" + gardenerInfo.getName() + ",更名为:" + rename); @@ -1558,6 +1667,7 @@ public class GardenerServiceImpl implements GardenerService { //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "rename_fail_had"); text += SpeechUtil.getGardenerSpeech(gender, "rename_fail_had"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200305); @@ -1598,6 +1708,7 @@ public class GardenerServiceImpl implements GardenerService { String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "rename_fail"); text = SpeechUtil.speechReplaceNum(text, itemConfig.getName()); text += SpeechUtil.getGardenerSpeech(gender, "rename_fail"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200304); @@ -1619,6 +1730,7 @@ public class GardenerServiceImpl implements GardenerService { String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "rename_fail"); text = SpeechUtil.speechReplaceNum(text, itemConfig.getName()); text += SpeechUtil.getGardenerSpeech(gender, "rename_fail"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200304); @@ -1634,6 +1746,7 @@ public class GardenerServiceImpl implements GardenerService { String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "rename_fail"); text = SpeechUtil.speechReplaceNum(text, itemConfig.getName()); text += SpeechUtil.getGardenerSpeech(gender, "rename_fail"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200304); @@ -1649,10 +1762,15 @@ public class GardenerServiceImpl implements GardenerService { } //玩家的园丁名称修改 gardenerInfo.setName(rename); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "rename_success"); text += SpeechUtil.getGardenerSpeech(gender, "rename_success"); - text = SpeechUtil.speechReplaceNum(text, gardenerInfo.getName()); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName(), gardenerInfo.getName()); //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); @@ -1682,9 +1800,12 @@ public class GardenerServiceImpl implements GardenerService { } //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //获取对应话术 String text = SpeechUtil.getGardenerSpeech(Constants.SPEECH_ASIDE, "rename_cancel"); text += SpeechUtil.getGardenerSpeech(gender, "rename_cancel"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(200306); diff --git a/src/main/java/com/qiwuai/garden/service/helpService/impl/HelpServiceImpl.java b/src/main/java/com/qiwuai/garden/service/helpService/impl/HelpServiceImpl.java index 8b955c7..064d400 100644 --- a/src/main/java/com/qiwuai/garden/service/helpService/impl/HelpServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/helpService/impl/HelpServiceImpl.java @@ -461,8 +461,13 @@ public class HelpServiceImpl implements HelpService { ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); + String uid = operationReq.getUid(); + Integer level = TimingAcquisition.gardenerMap.get(uid).getGardenerInfo().getLevel(); + //玩家当前等级的花圃数量上限 + Integer nurseryNumMax = TimingAcquisition.gardenerLevelMap.get(level).getNurseryNumMax(); //获取对应话术 String text = SpeechUtil.getHelpSpeech(Constants.SPEECH_ASIDE, "nursery_num_check"); + text = SpeechUtil.speechReplaceNum(text, nurseryNumMax.toString()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(800301); @@ -1393,13 +1398,12 @@ public class HelpServiceImpl implements HelpService { String favoritePlantIds = TimingAcquisition.petConfigMap.get(petId).getFavoritePlantId(); String[] favoritePlantIdList = favoritePlantIds.split("\\|"); for (String plantId : favoritePlantIdList) { - PlantPojo plant = TimingAcquisition.plantMap.get(Integer.valueOf(plantId)); plantText.append(TimingAcquisition.plantMap.get(Integer.valueOf(plantId)).getName()).append("、"); } - plantText.append(plantText.length() - 1); + plantText.deleteCharAt(plantText.length() - 1); //获取对应话术 String text = SpeechUtil.getHelpSpeech(Constants.SPEECH_ASIDE, "pet_get_by_name_check"); - text = SpeechUtil.speechReplaceNum(text, plantText.toString()); + text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.petConfigMap.get(petId).getName(), plantText.toString()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(801302); diff --git a/src/main/java/com/qiwuai/garden/service/marketService/MarketService.java b/src/main/java/com/qiwuai/garden/service/marketService/MarketService.java index 59bac67..c58e913 100644 --- a/src/main/java/com/qiwuai/garden/service/marketService/MarketService.java +++ b/src/main/java/com/qiwuai/garden/service/marketService/MarketService.java @@ -41,6 +41,12 @@ public interface MarketService { */ CommonResponse sellCancel(OperationRequest operationReq); /** + * 出售宠物指令 + * @param operationReq + * @return CommonResponse + */ + CommonResponse sellPetCheck(OperationRequest operationReq); + /** * 统一出售指令 * @param operationReq * @return CommonResponse @@ -65,9 +71,21 @@ public interface MarketService { */ CommonResponse cancel(OperationRequest operationReq); /** + * 打开商店指令 + * @param operationReq + * @return CommonResponse + */ + CommonResponse openShop(OperationRequest operationReq); + /** * 查询商品指令 * @param operationReq * @return CommonResponse */ CommonResponse goodsCheck(OperationRequest operationReq); + /** + * 退出商店指令 + * @param operationReq + * @return CommonResponse + */ + CommonResponse quitShop(OperationRequest operationReq); } diff --git a/src/main/java/com/qiwuai/garden/service/marketService/impl/MarketServiceImpl.java b/src/main/java/com/qiwuai/garden/service/marketService/impl/MarketServiceImpl.java index 0c21cbd..1942a86 100644 --- a/src/main/java/com/qiwuai/garden/service/marketService/impl/MarketServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/marketService/impl/MarketServiceImpl.java @@ -1,13 +1,12 @@ package com.qiwuai.garden.service.marketService.impl; +import com.alibaba.fastjson.JSON; import com.qiwuai.garden.common.Constants; import com.qiwuai.garden.common.TimingAcquisition; import com.qiwuai.garden.common.cache.CacheGlobal; import com.qiwuai.garden.common.cache.CacheUtil; import com.qiwuai.garden.common.utils.*; -import com.qiwuai.garden.dto.GardenerInfoDto; -import com.qiwuai.garden.dto.ItemBagDto; -import com.qiwuai.garden.dto.ItemDto; +import com.qiwuai.garden.dto.*; import com.qiwuai.garden.dto.base.CommonResponse; import com.qiwuai.garden.dto.base.ResultResponse; import com.qiwuai.garden.dto.base.ResultVarsResponse; @@ -283,6 +282,7 @@ public class MarketServiceImpl implements MarketService { //获取对应话术 String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "buy_check_fail_no_num"); text += SpeechUtil.getMarketSpeech(gender, "buy_check_fail_no_num"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(400106); @@ -299,20 +299,20 @@ public class MarketServiceImpl implements MarketService { ItemPojo moneyConfig = TimingAcquisition.itemConfigMap.get(moneyId); //获取背包中的所有袋子 Map itemBags = TimingAcquisition.gardenerMap.get(uid).getBackPack().getItemBags(); - ItemBagDto itemBag = new ItemBagDto(); //定义背包里的袋子 List packPackItemIds = new ArrayList<>(); //根据种类id取出背包里的钱 ItemDto moneyBag = itemBags.get(moneyConfig.getItemTypeId()).getItems(moneyId); Integer money = moneyBag.getItemNum(); - //根据用户购买物品类型id找到类型袋中所有物品 - itemBag = itemBags.get(itemTypeId); - if (!itemBag.getItemBag().isEmpty()) { - Map items = itemBag.getItemBag(); - packPackItemIds = new ArrayList<>(items.keySet()); - log.info("背包现有的物品id:" + packPackItemIds); + //获取玩家的背包 + BackPackDto backPack = TimingAcquisition.gardenerMap.get(uid).getBackPack(); + //背包中对应种类的袋子 + ItemBagDto itemBag = TimingAcquisition.gardenerMap.get(uid).getBackPack().getItemBags().get(itemTypeId); + //背包中没有该种类,则新增袋子 + if (StringUtils.isEmpty(itemBag)) { + itemBag = new ItemBagDto(); //定义背包里新的袋子 + backPack.add(itemTypeId, itemBag); + itemBag = backPack.getItemBags().get(itemTypeId); } - //根据用户购买物品类型id找到类型袋中所有物品 - itemBag = itemBags.get(itemTypeId); int price = 0; //获取商品配置信息 Map goodsConfigMap = TimingAcquisition.goodsConfigMap; @@ -327,28 +327,17 @@ public class MarketServiceImpl implements MarketService { //玩家货币数量充足 if (money >= price) { ItemDto item = new ItemDto(); - //背包对应物品袋子中是否为空 - if (!itemBags.isEmpty()) { - //背包袋子中是否已有该物品,有则增加该物品数量 - if (packPackItemIds.contains(itemId)) { - log.info("增加背包中" + itemId + "的数量"); - item = itemBag.getItemBag().get(itemId); - item.setItemNum(item.getItemNum() + number); - log.info("数量增加完成"); - } else { //没有则新增物品 - log.info("背包中新增物品:" + itemId); - item.setItemId(itemId); - item.setItemNum(number); - itemBag.add(itemId, item); - log.info("背包新增物品完成"); - } - } else { //背包袋子为空时新增该物品 - log.info("背包中新增物品:" + itemId); + //获取袋里的该物品 + ItemDto itemPacket = itemBag.getItems(itemId); + //没有该物品,则新增 + if (StringUtils.isEmpty(itemPacket)) { item.setItemId(itemId); item.setItemNum(number); itemBag.add(itemId, item); - log.info("背包新增物品完成"); + } else { //有则新增数量 + itemPacket.setItemNum(itemPacket.getItemNum() + number); } + log.info("背包中新增物品:" + itemPacket); //钱袋扣除货币数量 moneyBag.setItemNum(money - price); TimingAcquisition.gardenerMap.get(uid).getBackPack().setUpdateTime(DateUtil.getCurrentTime()); //背包信息改变,记录更新时间 @@ -387,6 +376,11 @@ public class MarketServiceImpl implements MarketService { //物品配置信息 ItemPojo itemConfig = TimingAcquisition.itemConfigMap.get(itemId); log.info(uid + "购买商品完成"); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "buy_success"); text = SpeechUtil.speechReplaceNum(text, number.toString(), itemConfig.getName()); @@ -460,11 +454,14 @@ public class MarketServiceImpl implements MarketService { CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家没有提供物品名称 if (StringUtils.isEmpty(itemId)) { log.info(uid + "玩家没提供出售的物品名称"); //获取对应话术 String text = SpeechUtil.getMarketSpeech(gender, "sell_check_item_no_name"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(400205); @@ -480,6 +477,7 @@ public class MarketServiceImpl implements MarketService { //获取对应话术 String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "sell_check_fail_no_exist"); text += SpeechUtil.getMarketSpeech(gender, "sell_check_fail_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(400210); @@ -608,6 +606,8 @@ public class MarketServiceImpl implements MarketService { String uid = operationReq.getUid(); String noviceGuide = operationReq.getNoviceGuide(); //新手引导已经进行到的步骤 log.info(uid + "开始出售物品"); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { @@ -653,10 +653,16 @@ public class MarketServiceImpl implements MarketService { } //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "sell_success"); text = SpeechUtil.speechReplaceNum(text, number.toString(), itemConfig.getName(), String.valueOf(price), TimingAcquisition.itemConfigMap.get(moneyId).getName()); text += SpeechUtil.getMarketSpeech(gender, "sell_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(400203); @@ -682,9 +688,12 @@ public class MarketServiceImpl implements MarketService { } //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //获取对应话术 String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "sell_cancel"); text += SpeechUtil.getMarketSpeech(gender, "sell_cancel"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(400204); @@ -696,6 +705,30 @@ public class MarketServiceImpl implements MarketService { } @Override + public CommonResponse sellPetCheck(OperationRequest operationReq) { + CommonResponse commonResponse = new CommonResponse(); + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + log.info(uid + "开始查询出售宠物操作"); + //园丁性别 +// String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 +// CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); + //获取对应话术 + String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "sell_pet_check"); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(400207); + resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("出售物品回复3"); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + + @Override public CommonResponse sellAllCheck(OperationRequest operationReq) { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); @@ -776,6 +809,8 @@ public class MarketServiceImpl implements MarketService { String uid = operationReq.getUid(); String noviceGuide = operationReq.getNoviceGuide(); //新手引导已经进行到的步骤 + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { @@ -830,10 +865,16 @@ public class MarketServiceImpl implements MarketService { //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "sell_all_success"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(price), moneyConfig.getName()); text += SpeechUtil.getMarketSpeech(gender, "sell_all_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(400209); @@ -893,6 +934,26 @@ public class MarketServiceImpl implements MarketService { } @Override + public CommonResponse openShop(OperationRequest operationReq) { + CommonResponse commonResponse = new CommonResponse(); + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + log.info(uid + "打开商店"); + //获取对应话术 + String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "goods_check_fail_no_name"); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(400307); + resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("查看商品回复1"); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + + @Override public CommonResponse goodsCheck(OperationRequest operationReq) { CommonResponse commonResponse = new CommonResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); @@ -907,6 +968,8 @@ public class MarketServiceImpl implements MarketService { log.info(uid + "开始查看商品,物品等级:" + itemLevel + ", 物品属性id:" + itemAttributeId + ",物品类型id:" + itemTypeId + ",物品id:" + itemId + ",植物id:" + plantId); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //货币配置信息 Integer moneyId = Integer.parseInt(TimingAcquisition.systemConfigMap.get("money").getValue()); ItemPojo moneyConfig = TimingAcquisition.itemConfigMap.get(moneyId); @@ -937,6 +1000,7 @@ public class MarketServiceImpl implements MarketService { //获取对应话术 String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "goods_check_fail_item_no_exist"); text += SpeechUtil.getMarketSpeech(gender, "goods_check_fail_item_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(400306); @@ -992,6 +1056,7 @@ public class MarketServiceImpl implements MarketService { //获取对应话术 String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "goods_check_fail_item_no_exist"); text += SpeechUtil.getMarketSpeech(gender, "goods_check_fail_item_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(400306); @@ -1023,6 +1088,7 @@ public class MarketServiceImpl implements MarketService { } text = SpeechUtil.speechReplaceNum(text, goodsName, goodsDescription, feedText.toString()); text += SpeechUtil.getMarketSpeech(gender, "goods_check_item_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); //保存玩家这轮的请求信息,用于下一步的操作 operationReq.setItemId(itemId); operationReq.setOperationLabel(Constants.CHECK_GOODS); @@ -1043,6 +1109,7 @@ public class MarketServiceImpl implements MarketService { //获取对应话术 String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "goods_check_fail_item_no_exist"); text += SpeechUtil.getMarketSpeech(gender, "goods_check_fail_item_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(400306); @@ -1072,6 +1139,7 @@ public class MarketServiceImpl implements MarketService { //获取对应话术 String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "goods_check_fail_item_no_exist"); text += SpeechUtil.getMarketSpeech(gender, "goods_check_fail_item_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(400306); @@ -1103,6 +1171,7 @@ public class MarketServiceImpl implements MarketService { } text = SpeechUtil.speechReplaceNum(text, goodsName, goodsDescription, feedText.toString()); text += SpeechUtil.getMarketSpeech(gender, "goods_check_item_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); //保存玩家这轮的请求信息,用于下一步的操作 operationReq.setItemId(itemId); operationReq.setOperationLabel(Constants.CHECK_GOODS); @@ -1176,8 +1245,9 @@ public class MarketServiceImpl implements MarketService { } //获取对应话术 String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "goods_check_type_success"); - text = SpeechUtil.speechReplaceNum(text, itemLevelName, itemAttribute, itemType, feedText.toString()); + text = SpeechUtil.speechReplaceNum(text, itemLevelName, itemAttribute, itemType, String.valueOf(size), feedText.toString()); text += SpeechUtil.getMarketSpeech(gender, "goods_check_type_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(400302); @@ -1205,4 +1275,23 @@ public class MarketServiceImpl implements MarketService { //3.玩家指定了物品种类、物品属性、物品等级中的一个及以上 return TimingAcquisition.getItemInfoByCondition(uid, goodsLevelMap, itemTypeId, itemAttributeId, itemLevel, expireTime); } + + @Override + public CommonResponse quitShop(OperationRequest operationReq) { + CommonResponse commonResponse = new CommonResponse(); + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + //清除缓存,本轮对话结束 + CacheGlobal.concurrentMap.remove(uid); + + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(400308); + resultResponse.set反馈文本("好的,欢迎下次光临!"); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } } diff --git a/src/main/java/com/qiwuai/garden/service/nurseryService/impl/NurseryServiceImpl.java b/src/main/java/com/qiwuai/garden/service/nurseryService/impl/NurseryServiceImpl.java index 833d782..1e3820b 100644 --- a/src/main/java/com/qiwuai/garden/service/nurseryService/impl/NurseryServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/nurseryService/impl/NurseryServiceImpl.java @@ -1,5 +1,6 @@ package com.qiwuai.garden.service.nurseryService.impl; +import com.alibaba.fastjson.JSON; import com.qiwuai.garden.common.Constants; import com.qiwuai.garden.common.TimingAcquisition; import com.qiwuai.garden.common.cache.CacheGlobal; @@ -52,11 +53,14 @@ public class NurseryServiceImpl implements NurseryService { int level = TimingAcquisition.gardenerMap.get(uid).getGardenerInfo().getLevel(); Integer nurseryMax = TimingAcquisition.gardenerLevelMap.get(level).getNurseryNumMax(); //园丁性别 -// String gender = TimingAcquisition.getGardenerGender(uid); + String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_amount_check"); text = SpeechUtil.speechReplaceNum(text, nurseryNumText, String.valueOf(nurseryAmount), String.valueOf(level), nurseryMax.toString()); - text = SpeechUtil.speechReplaceNum(text, "nursery_amount_check"); + text += SpeechUtil.getPlantSpeech(gender, "nursery_amount_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100901); @@ -75,10 +79,14 @@ public class NurseryServiceImpl implements NurseryService { String uid = operationReq.getUid(); Integer nurseryNum = operationReq.getNurseryNum(); log.info(uid + "查看指定花圃的总览信息,花圃编号:" + nurseryNum); + //玩家本地操作,清除bot在别人家的标识 + resultResponse.set玩家当前位置(""); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); //玩家的所有花圃 String nurseryNumText = TimingAcquisition.getAllNurseryNum(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家没提供花圃编号 if (StringUtils.isEmpty(nurseryNum)) { log.info(uid + "玩家没提供花圃编号"); @@ -86,6 +94,7 @@ public class NurseryServiceImpl implements NurseryService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "check_nursery_fail_no_num"); text = SpeechUtil.speechReplaceNum(text, nurseryNumText); text += SpeechUtil.getPlantSpeech(gender, "check_nursery_fail_no_num"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(101007); @@ -150,29 +159,25 @@ public class NurseryServiceImpl implements NurseryService { if (DateUtil.getCurrentTime().compareTo(nurseryInfo.getPlantTime().getBloomingTime()) > 0) { //获取对应话术 plantStatusText = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_all_mature"); - plantStatusText = SpeechUtil.speechReplaceNum(plantStatusText, nurseryNum.toString()); nurseryInfo.setStatus(Constants.PLANT_MATURE); //花圃中植物状态改为成熟期 } else if (DateUtil.getCurrentTime().compareTo(nurseryInfo.getPlantTime().getGrowingTime()) > 0) { //获取对应话术 plantStatusText = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_all_blooming"); - plantStatusText = SpeechUtil.speechReplaceNum(plantStatusText, nurseryNum.toString(), plant.getName()); nurseryInfo.setStatus(Constants.PLANT_BLOOMING); //花圃中植物状态改为开花期 } else if (DateUtil.getCurrentTime().compareTo(nurseryInfo.getPlantTime().getSowingTime()) > 0) { //获取对应话术 plantStatusText = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_all_growing"); - plantStatusText = SpeechUtil.speechReplaceNum(plantStatusText, nurseryNum.toString()); nurseryInfo.setStatus(Constants.PLANT_GROWING); //花圃中植物状态改为成长期 } else if (DateUtil.getCurrentTime().compareTo(nurseryInfo.getPlantTime().getSeedingTime()) > 0) { //获取对应话术 plantStatusText = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_all_sowing"); - plantStatusText = SpeechUtil.speechReplaceNum(plantStatusText, nurseryNum.toString()); nurseryInfo.setStatus(Constants.PLANT_SOWING); //花圃中植物状态改为幼苗期 } else { //获取对应话术 plantStatusText = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_all_seeding"); - plantStatusText = SpeechUtil.speechReplaceNum(plantStatusText, nurseryNum.toString()); } - plantStatusText = "花圃" + plantStatusText; + plantStatusText = SpeechUtil.speechReplaceNum(plantStatusText, TimingAcquisition.plantMap.get(nurseryInfo.getPlantId()).getName()); + plantStatusText = "花圃" + nurseryNum + plantStatusText; } PetPojo pet = null; if (!StringUtils.isEmpty(nurseryInfo.getPetField())) { @@ -188,27 +193,32 @@ public class NurseryServiceImpl implements NurseryService { addText = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "check_nursery_info_have_plant_pet"); addText = SpeechUtil.speechReplaceNum(addText, plant.getName(), plantStatusText, pet.getName()); text += addText; - text += SpeechUtil.getPlantSpeech(gender, "check_nursery_info_have_plant_pet"); resultResponse.set反馈ID(101001); } //2.有植物没宠物 if (!StringUtils.isEmpty(plant) && StringUtils.isEmpty(pet)) { addText = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "check_nursery_info_have_plant_no_pet"); addText = SpeechUtil.speechReplaceNum(addText, plant.getName(), plantStatusText); + text += addText; + text += SpeechUtil.getPlantSpeech(gender, "check_nursery_info_have_plant_no_pet"); resultResponse.set反馈ID(101002); } //3.没有植物有宠物 if (StringUtils.isEmpty(plant) && !StringUtils.isEmpty(pet)) { addText = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "check_nursery_info_no_plant_have_pet"); addText = SpeechUtil.speechReplaceNum(addText, pet.getName()); + text += addText; + text += SpeechUtil.getPlantSpeech(gender, "check_nursery_info_no_plant_have_pet"); resultResponse.set反馈ID(101003); } //4.没有植物也没有宠物 if (StringUtils.isEmpty(plant) && StringUtils.isEmpty(pet)) { addText = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "check_nursery_info_no_plant_no_pet"); + text += addText; + text += SpeechUtil.getPlantSpeech(gender, "check_nursery_info_no_plant_no_pet"); resultResponse.set反馈ID(101004); } -// //有新来的宠物 + //有新来的宠物 if (nurseryInfo.getPetCheck() == Constants.PET_UNCHECK && !StringUtils.isEmpty(nurseryInfo.getPetField())) { nurseryInfo.setPetCheck(Constants.PET_CHECK); } @@ -291,6 +301,8 @@ public class NurseryServiceImpl implements NurseryService { } //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); StringBuilder feedText = new StringBuilder(); if (seedingNumList.size() != 0) { StringBuilder nurseryNumText = new StringBuilder(); @@ -352,10 +364,13 @@ public class NurseryServiceImpl implements NurseryService { } else { //花圃中有植物时 //花圃中有植物时,旁白的回复 feedText.deleteCharAt(feedText.length() - 1); - text = feedText.toString(); + text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_all_check"); + text = SpeechUtil.speechReplaceNum(text, feedText.toString()); + text = SpeechUtil.speechReplaceNum(text, "植物"); //花圃中有植物时,园丁的回复 gardenerText = SpeechUtil.getPlantSpeech(gender, "nursery_status"); } + gardenerText = SpeechUtil.speechReplaceNum(gardenerText, callName.getName(), callName.getSubName()); //有新宠物到来时 if (nurseryNumList.size() > 0) { StringBuilder addText = new StringBuilder(); @@ -370,6 +385,7 @@ public class NurseryServiceImpl implements NurseryService { petText = SpeechUtil.speechReplaceNum(petText, addText.toString(), String.valueOf(nurseryNumList.size())); //有宠物时,园丁的回复 nurseryPetText = SpeechUtil.getPlantSpeech(gender, "nursery_pet"); + nurseryPetText = SpeechUtil.speechReplaceNum(nurseryPetText, callName.getName(), callName.getSubName()); resultResponse.set后台附加返回("查看花圃状态回复1"); } //分别整合园丁和旁白的回复 @@ -409,13 +425,18 @@ public class NurseryServiceImpl implements NurseryService { String uid = operationReq.getUid(); Integer nurseryNum = operationReq.getNurseryNum(); log.info(uid + "开始查询当前花圃等级,花圃编号:" + nurseryNum); + //玩家本地操作,清除bot在别人家的标识 + resultResponse.set玩家当前位置(""); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //花圃编号为空 if (StringUtils.isEmpty(nurseryNum)) { log.info(uid + "玩家没有提供花圃编号" + nurseryNum); //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "nursery_fail_no_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100402); @@ -432,6 +453,7 @@ public class NurseryServiceImpl implements NurseryService { log.info(uid + "不存在花圃编号" + nurseryNum); //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "nursery_fail_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100403); @@ -446,6 +468,7 @@ public class NurseryServiceImpl implements NurseryService { if (nurseryInfo.getUsable() != Constants.NURSERY_USABLE) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "nursery_level_fail_usable"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100404); @@ -458,6 +481,7 @@ public class NurseryServiceImpl implements NurseryService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_level"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString(), nursery.getLevel().toString(), nursery.getName()); text += SpeechUtil.getPlantSpeech(gender, "nursery_level"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100401); @@ -476,15 +500,20 @@ public class NurseryServiceImpl implements NurseryService { String uid = operationReq.getUid(); Integer nurseryNum = operationReq.getNurseryNum(); log.info(uid + "开始查询当前花圃升级可选择的花圃类型,花圃编号:" + nurseryNum); + //玩家本地操作,清除bot在别人家的标识 + resultResponse.set玩家当前位置(""); //保存当前操作标识 operationReq.setOperationLabel(Constants.NURSERY_UPGRADE); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家未提供花圃 if (StringUtils.isEmpty(nurseryNum)) { log.info(uid + "未提供花圃编号"); //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "nursery_upgrade_fail_no_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100603); @@ -535,6 +564,7 @@ public class NurseryServiceImpl implements NurseryService { if (nurseryInfo.getUsable() != Constants.NURSERY_USABLE) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "nursery_upgrade_fail_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100602); @@ -581,10 +611,12 @@ public class NurseryServiceImpl implements NurseryService { text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "search_nursery_to_type"); text = SpeechUtil.speechReplaceNum(text, feedText.toString()); text += SpeechUtil.getPlantSpeech(gender, "search_nursery_to_type"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); } else { //获取对应话术 text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_upgrade_fail_no_type"); text += SpeechUtil.getPlantSpeech(gender, "nursery_upgrade_fail_no_type"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); } //玩家可选择的花圃类型只有一个,则直接到第二步 if (nurseryIdList.size() == 1) { @@ -617,7 +649,7 @@ public class NurseryServiceImpl implements NurseryService { text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "search_upgrade_condition"); text = SpeechUtil.speechReplaceNum(text, nursery.getName(), addext.toString()); text += SpeechUtil.getPlantSpeech(gender, "search_upgrade_condition"); - + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100601); @@ -650,6 +682,8 @@ public class NurseryServiceImpl implements NurseryService { Integer rank = operationReq.getRank(); //玩家说的序号 String uid = operationReq.getUid(); log.info(uid + "开始查询选择的花圃类型升级需要满足的条件,花圃类型id:" + nurseryId + ",或者序号:" + rank); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { @@ -664,6 +698,7 @@ public class NurseryServiceImpl implements NurseryService { log.info(uid + "玩家没提供花圃类型"); //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "search_upgrade_condition_fail_no_type"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100610); @@ -676,8 +711,9 @@ public class NurseryServiceImpl implements NurseryService { if (nurseryId == Constants.REQ_NON) { log.info(uid + "玩家提供的花圃类型不存在 "); //获取对应话术 - String text = SpeechUtil.getPlantSpeech(gender, "search_upgrade_condition_fail_not_exist"); + String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "search_upgrade_condition_fail_not_exist"); text += SpeechUtil.getPlantSpeech(gender, "search_upgrade_condition_fail_not_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100610); @@ -759,6 +795,7 @@ public class NurseryServiceImpl implements NurseryService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_upgrade_fail_type"); text = SpeechUtil.speechReplaceNum(text, addText.toString()); text += SpeechUtil.getPlantSpeech(gender, "nursery_upgrade_fail_type"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100607); @@ -798,6 +835,7 @@ public class NurseryServiceImpl implements NurseryService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "search_upgrade_condition"); text = SpeechUtil.speechReplaceNum(text, nursery.getName(), feedText.toString()); text += SpeechUtil.getPlantSpeech(gender, "search_upgrade_condition"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -818,6 +856,8 @@ public class NurseryServiceImpl implements NurseryService { String uid = operationReq.getUid(); String noviceGuide = operationReq.getNoviceGuide(); //新手引导已经进行到的步骤 log.info(uid + "开始升级花圃"); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { @@ -861,6 +901,7 @@ public class NurseryServiceImpl implements NurseryService { if (nurseryInfo.getUsable() != Constants.NURSERY_USABLE) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "nursery_upgrade_fail_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100602); @@ -875,6 +916,7 @@ public class NurseryServiceImpl implements NurseryService { log.info("已经升级过了哦"); //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "nursery_upgrade_succeed"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100603); @@ -889,6 +931,7 @@ public class NurseryServiceImpl implements NurseryService { if (StringUtils.isEmpty(plantMap)) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "nursery_upgrade_fail_planted"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100605); @@ -911,6 +954,7 @@ public class NurseryServiceImpl implements NurseryService { text = SpeechUtil.speechReplaceNum(text, plantPojoMap.get(plant.getPlantId()).getName(), plant.getNumber().toString(), "0", plant.getNumber().toString()); text += SpeechUtil.getPlantSpeech(gender, "nursery_upgrade_fail_planted"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100605); @@ -928,6 +972,7 @@ public class NurseryServiceImpl implements NurseryService { text = SpeechUtil.speechReplaceNum(text, plantPojoMap.get(plant.getPlantId()).getName(), plant.getNumber().toString(), planted.getNumber().toString(), Integer.toString(sub)); text += SpeechUtil.getPlantSpeech(gender, "nursery_upgrade_fail_planted"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100605); @@ -977,7 +1022,7 @@ public class NurseryServiceImpl implements NurseryService { item.getItemNum().toString()); text += SpeechUtil.getPlantSpeech(gender, "nursery_upgrade_fail_material"); } - text = SpeechUtil.speechReplaceNum(text, itemConfigMap.get(item.getItemId()).getName()); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName(), itemConfigMap.get(item.getItemId()).getName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100606); @@ -1003,7 +1048,7 @@ public class NurseryServiceImpl implements NurseryService { item.getItemNum().toString() , itemConfigMap.get(item.getItemId()).getName()); text += SpeechUtil.getPlantSpeech(gender, "nursery_upgrade_fail_material"); } - text = SpeechUtil.speechReplaceNum(text, itemConfigMap.get(item.getItemId()).getName()); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName(), itemConfigMap.get(item.getItemId()).getName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100606); @@ -1030,17 +1075,23 @@ public class NurseryServiceImpl implements NurseryService { } log.info(uid + "的花圃已升级至目标花圃类型:" + targetNurseryId); //---------------------新手引导的升级花圃至等级2任务完成------------------------ - if ("完成10011".equals(noviceGuide) && targetNursery.getLevel() == 2) { + if ("完成10011".equals(noviceGuide) && targetNursery.getLevel() >= 2) { resultResponse.set任务完成("10012"); log.info(uid + "新手引导的升级花圃任务10012已完成"); } //---------------------新手引导的升级花圃至等级3任务完成------------------------ - if ("完成10019".equals(noviceGuide) && targetNursery.getLevel() == 3) { + if ("完成10019".equals(noviceGuide) && targetNursery.getLevel() >= 3) { resultResponse.set任务完成("10020"); log.info(uid + "新手引导的升级花圃任务10020已完成"); } + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "nursery_upgrade_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); @@ -1099,11 +1150,14 @@ public class NurseryServiceImpl implements NurseryService { int nurseryMax = TimingAcquisition.gardenerLevelMap.get(TimingAcquisition.gardenerMap.get(uid).getGardenerInfo().getLevel()).getNurseryNumMax(); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //开启花圃数量已达到上限 if (nurseryCount >= nurseryMax) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_reclaim_fail_num"); text += SpeechUtil.getPlantSpeech(gender, "nursery_reclaim_fail_num"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100802); @@ -1127,7 +1181,7 @@ public class NurseryServiceImpl implements NurseryService { //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_reclaim_fail_money"); text += SpeechUtil.getPlantSpeech(gender, "nursery_reclaim_fail_money"); - text = SpeechUtil.speechReplaceNum(text, moneyName); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName(), moneyName); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100803); @@ -1140,7 +1194,7 @@ public class NurseryServiceImpl implements NurseryService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_reclaim_check"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(nurseryCount + 1), nurseryReclaimMap.get(nurseryCount - 1).getCost().toString(), moneyName); text += SpeechUtil.getPlantSpeech(gender, "nursery_reclaim_check"); - text = SpeechUtil.speechReplaceNum(text, moneyName); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName(), moneyName); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100801); @@ -1168,11 +1222,14 @@ public class NurseryServiceImpl implements NurseryService { int nurseryMax = TimingAcquisition.gardenerLevelMap.get(TimingAcquisition.gardenerMap.get(uid).getGardenerInfo().getLevel()).getNurseryNumMax(); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //开启花圃数量已达到上限 if (nurseryCount >= nurseryMax) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_reclaim_fail_num"); text += SpeechUtil.getPlantSpeech(gender, "nursery_reclaim_fail_num"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100802); @@ -1196,7 +1253,7 @@ public class NurseryServiceImpl implements NurseryService { //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_reclaim_fail_money"); text += SpeechUtil.getPlantSpeech(gender, "nursery_reclaim_fail_money"); - text = SpeechUtil.speechReplaceNum(text, moneyName); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName(), moneyName); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100803); @@ -1224,10 +1281,16 @@ public class NurseryServiceImpl implements NurseryService { taskCountMap.put(Constants.RECLAIM_NURSERY_EVENT, taskCountMap.get(Constants.RECLAIM_NURSERY_EVENT) + 1); //------------------------园丁升级任务事件[开启花圃]是否完成------------------------ TaskResultDto updateTaskResult = TimingAcquisition.checkUpdateTask(uid, Constants.RECLAIM_NURSERY_EVENT); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_reclaim_success"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(nurseryCount + 1)); text += SpeechUtil.getPlantSpeech(gender, "nursery_reclaim_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); text += updateTaskResult.getResultText(); //养成任务事件[开启花圃]完成提醒 commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -1238,7 +1301,7 @@ public class NurseryServiceImpl implements NurseryService { resultResponse.set后台附加返回2("查看任务1"); } //-----------------------新手引导开启第4个花圃任务完成。默认两个已开启------------------------- - if ((nurseryCount + 1) == 4 && "完成10020".equals(noviceGuide)) { + if ((nurseryCount + 1) >= 4 && "完成10020".equals(noviceGuide)) { resultResponse.set任务完成("10021"); } resultVarsResponse.setVars(resultResponse); @@ -1324,13 +1387,15 @@ public class NurseryServiceImpl implements NurseryService { log.info(uid + "查询重置花圃" + nurseryNum +"所需条件"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); + int num = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos().size(); //没有提供花圃编号 if (StringUtils.isEmpty(nurseryNum)) { log.info(uid + "玩家没提供花圃编号"); - int num = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos().size(); //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "nursery_reset_fail_no_nursery"); - text = SpeechUtil.speechReplaceNum(text, String.valueOf(num)); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName(), String.valueOf(num)); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100704); @@ -1345,6 +1410,7 @@ public class NurseryServiceImpl implements NurseryService { //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_reset_fail_no_nursery"); text += SpeechUtil.getPlantSpeech(gender, "nursery_reset_fail_no_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName(), String.valueOf(num)); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100705); @@ -1357,6 +1423,7 @@ public class NurseryServiceImpl implements NurseryService { if (nurseryNum > TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos().size()) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "nursery_reset_fail_nursery_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100707); @@ -1383,6 +1450,7 @@ public class NurseryServiceImpl implements NurseryService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_reset_check"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(resetCost), moneyConfig.getName()); text += SpeechUtil.getPlantSpeech(gender, "nursery_reset_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100701); @@ -1400,6 +1468,7 @@ public class NurseryServiceImpl implements NurseryService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_reset_check_mature"); text = SpeechUtil.speechReplaceNum(text, plant.getName(), String.valueOf(resetCost), moneyConfig.getName()); text += SpeechUtil.getPlantSpeech(gender, "nursery_reset_check_mature"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100702); @@ -1432,12 +1501,15 @@ public class NurseryServiceImpl implements NurseryService { log.info(uid + "玩家重置的花圃编号:" + nurseryNum); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家花圃信息 NurseryInfoDto nurseryInfo = TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos().get(nurseryNum); //花圃已经是初始类型 if (nurseryInfo.getId() == Constants.NURSERY_INIT_ID) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "nursery_reset_succeed"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100706); @@ -1470,6 +1542,7 @@ public class NurseryServiceImpl implements NurseryService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_reset_fail_money"); text = SpeechUtil.speechReplaceNum(text, moneyConfig.getName(), money.getItemNum().toString(), String.valueOf(resetCost)); text += SpeechUtil.getPlantSpeech(gender, "nursery_reset_fail_money"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName(), moneyConfig.getName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100703); @@ -1497,15 +1570,22 @@ public class NurseryServiceImpl implements NurseryService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_reset_success_have_plant"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(resetCost), moneyConfig.getName()); text += SpeechUtil.getPlantSpeech(gender, "nursery_reset_success_have_plant"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); //花圃中没有种植植物 if (nurseryInfo.getStatus() == Constants.PLANT_NO || StringUtils.isEmpty(nurseryInfo.getPlantId())) { //获取对应话术 text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "nursery_reset_success_no_plant"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString()); text += SpeechUtil.getPlantSpeech(gender, "nursery_reset_success_no_plant"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); } //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); commonResponse.setCode(1); commonResponse.setMsg("成功"); 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 5cdb0a3..15919db 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 @@ -1,19 +1,19 @@ package com.qiwuai.garden.service.petService.impl; +import com.alibaba.fastjson.JSON; import com.qiwuai.garden.common.Constants; import com.qiwuai.garden.common.FeedbackID; import com.qiwuai.garden.common.TimingAcquisition; import com.qiwuai.garden.common.cache.CacheGlobal; import com.qiwuai.garden.common.cache.CacheUtil; -import com.qiwuai.garden.common.utils.RandomDropUtil; -import com.qiwuai.garden.common.utils.SpeechUtil; -import com.qiwuai.garden.common.utils.TypeConvertUtil; -import com.qiwuai.garden.common.utils.YamlUtil; +import com.qiwuai.garden.common.utils.*; +import com.qiwuai.garden.dto.GardenerDto; 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.CallNamePojo; import com.qiwuai.garden.pojo.PetPojo; import com.qiwuai.garden.pojo.PlantPojo; import com.qiwuai.garden.pojo.QuantityRangePojo; @@ -25,6 +25,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @Service @@ -44,12 +45,15 @@ public class PetServiceImpl implements PetService { log.info(uid + "开始查询宠物信息"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); Integer petId = operationReq.getPetId(); //未提供宠物名称 if (StringUtils.isEmpty(petId)) { log.info(uid + "未提供宠物名称"); //获取对应话术 String text = SpeechUtil.getPetSpeech(gender, "pet_view_no_name"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈文本(text); @@ -65,6 +69,7 @@ public class PetServiceImpl implements PetService { //获取对应话术 String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_view_no_exist"); text += SpeechUtil.getPetSpeech(gender, "pet_view_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈文本(text); @@ -115,6 +120,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_view_field_one"); text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), petConfig.getDescription()); text += SpeechUtil.getPetSpeech(gender, "pet_view_field"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(300102); } //3.花圃和宠物栏中均没有该宠物 @@ -130,6 +136,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_view_no_pet"); text = SpeechUtil.speechReplaceNum(text, plantNames.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_view_no_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(300103); } //4.仅宠物栏有多只该宠物 @@ -137,6 +144,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_view_field_more"); text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), petConfig.getDescription(), String.valueOf(petCount)); text += SpeechUtil.getPetSpeech(gender, "pet_view_field"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(300104); } //5.花圃和宠物栏均有该宠物 @@ -149,6 +157,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), petConfig.getDescription(), String.valueOf(petCount), String.valueOf(nurseryPetCount), nurseryNumText.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_view_field"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(300105); } //6.仅花圃有多只该宠物 @@ -199,10 +208,13 @@ public class PetServiceImpl implements PetService { log.info(uid + "开始移动宠物id" + petId + "至花圃" + nurseryNum); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); if (StringUtils.isEmpty(petId)) { log.info(uid + "的花圃没有提供宠物名称"); //获取对应话术 String text = SpeechUtil.getPetSpeech(gender, "pet_move_fail_no_pet_name"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300313); @@ -231,6 +243,7 @@ public class PetServiceImpl implements PetService { log.info(uid + "未提供花圃编号"); //获取对应话术 String text = SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_no_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300314); @@ -246,6 +259,7 @@ public class PetServiceImpl implements PetService { //获取对应话术 String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_fail_wrong_num"); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_wrong_num"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300307); @@ -266,6 +280,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_fail_pos_over"); text = SpeechUtil.speechReplaceNum(text, allNurseryText); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_pos_over"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300316); @@ -283,6 +298,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_fail_have_this_pet"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString(), petConfig.getName()); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_have_this_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300309); @@ -295,6 +311,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_fail_pet"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300302); @@ -338,6 +355,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_fail_no_pet"); text = SpeechUtil.speechReplaceNum(text, petConfig.getName()); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_no_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300310); @@ -365,10 +383,16 @@ public class PetServiceImpl implements PetService { } //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_success"); text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), nurseryNum.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300301); @@ -390,6 +414,8 @@ public class PetServiceImpl implements PetService { Integer nurseryNum = operationReq.getNurseryNum(); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //获取玩家的宠物栏位 List petList = TimingAcquisition.gardenerMap.get(uid).getPetFields(); //园丁宠物栏存放上限 @@ -399,7 +425,9 @@ public class PetServiceImpl implements PetService { log.info(uid + "的宠物栏已满"); //获取对应话术 String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_field_fail_pet"); + text = SpeechUtil.speechReplaceNum(text, String.valueOf(petNumMax)); text += SpeechUtil.getPetSpeech(gender, "pet_move_field_fail_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300304); @@ -464,6 +492,7 @@ public class PetServiceImpl implements PetService { //获取对应话术 String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_field_fail_no_pet"); text += SpeechUtil.getPetSpeech(gender, "pet_move_field_fail_no_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300320); @@ -506,6 +535,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_field_fail_no_pet"); text = SpeechUtil.speechReplaceNum(text, petConfig.getName()); text += SpeechUtil.getPetSpeech(gender, "pet_move_field_fail_no_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300311); @@ -521,6 +551,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_field_fail_no_exist"); text = SpeechUtil.speechReplaceNum(text, petConfig.getName()); text += SpeechUtil.getPetSpeech(gender, "pet_move_field_fail_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300312); @@ -554,6 +585,11 @@ public class PetServiceImpl implements PetService { //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); log.info(uid + "花圃中的宠物移动宠物栏结束"); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_field_success"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString(), petConfig.getName()); @@ -562,6 +598,7 @@ public class PetServiceImpl implements PetService { sb.append(text).insert(strPos + 1, addText); text = sb.toString(); text += SpeechUtil.getPetSpeech(gender, "pet_move_field_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300303); @@ -585,12 +622,15 @@ public class PetServiceImpl implements PetService { Integer nurseryNumPos = operationReq.getNurseryNumPos(); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //有花圃位置,但格式不符合规范 if (!StringUtils.isEmpty(nurseryPos)) { if (nurseryPos.equals(Constants.REQ_NON)) { //获取对应话术 String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_fail_wrong_pos"); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_wrong_pos"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300308); @@ -629,6 +669,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_fail_pos_over"); text = SpeechUtil.speechReplaceNum(text, allNurseryText); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_pos_over"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300316); @@ -645,6 +686,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_fail_pet"); text = SpeechUtil.speechReplaceNum(text, nurseryNumPos.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300306); @@ -660,6 +702,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_fail_none"); text = SpeechUtil.speechReplaceNum(text, nurseryPos.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300317); @@ -676,6 +719,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_fail_no_exist"); text = SpeechUtil.speechReplaceNum(text, nurseryPos.toString(), petConfig.getName()); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300318); @@ -698,10 +742,16 @@ public class PetServiceImpl implements PetService { //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); log.info(uid + "在花圃间移动宠物的操作结束"); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_success"); text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.petConfigMap.get(id).getName(), nurseryNumPos.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(300305); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -734,11 +784,14 @@ public class PetServiceImpl implements PetService { } //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //宠物和花圃均没有指明 if (StringUtils.isEmpty(petId) && StringUtils.isEmpty(nurseryNum)) { log.info(uid + "未提供花圃编号和宠物名称"); //获取对应话术 String text = SpeechUtil.getPetSpeech(gender, "pet_delete_fail_no_pet_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300409); @@ -785,6 +838,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_delete_check_nursery"); text = SpeechUtil.speechReplaceNum(text, petConfig.getName(), entry.getKey().toString()); text += SpeechUtil.getPetSpeech(gender, "pet_delete_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300401); @@ -802,6 +856,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_delete_check_field"); text = SpeechUtil.speechReplaceNum(text, petConfig.getName()); text += SpeechUtil.getPetSpeech(gender, "pet_delete_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -832,6 +887,7 @@ public class PetServiceImpl implements PetService { if (nurseryNum.equals(Constants.REQ_NON)) { //获取对应话术 String text = SpeechUtil.getPetSpeech(gender, "pet_delete_fail_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300410); @@ -845,6 +901,7 @@ public class PetServiceImpl implements PetService { if (StringUtils.isEmpty(nurseryInfo)) { //获取对应话术 String text = SpeechUtil.getPetSpeech(gender, "pet_delete_fail_no_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300411); @@ -893,6 +950,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_delete_check_nursery"); text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.petConfigMap.get(id).getName(), nurseryNum.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_delete_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300405); @@ -911,7 +969,8 @@ public class PetServiceImpl implements PetService { String uid = operationReq.getUid(); log.info(uid + "开始删除宠物"); - + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { @@ -921,7 +980,7 @@ public class PetServiceImpl implements PetService { } //判断当前操作为上一轮的下一步 if (lastReq.getOperationLabel() != Constants.PET_DELETE) { - commonResponse.setCode(0); + commonResponse.setCode(1); commonResponse.setMsg("失败,本次操作不是这轮对话的"); return commonResponse; } @@ -960,6 +1019,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_delete_success"); text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.petConfigMap.get(petId).getName()); text += SpeechUtil.getPetSpeech(gender, "pet_delete_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(300403); } //指明花圃编号时,删除花圃中的宠物 @@ -976,11 +1036,17 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_delete_success"); text = SpeechUtil.speechReplaceNum(text, petName); text += SpeechUtil.getPetSpeech(gender, "pet_delete_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(300407); } //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); log.info(uid + "删除宠物完成"); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -998,6 +1064,8 @@ public class PetServiceImpl implements PetService { String uid = operationReq.getUid(); log.info(uid + "开始取消删除宠物"); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { @@ -1023,6 +1091,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_delete_cancel"); text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.petConfigMap.get(petId).getName()); text += SpeechUtil.getPetSpeech(gender, "pet_delete_cancel"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(300404); } //指明了花圃编号 @@ -1034,6 +1103,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_delete_cancel"); text = SpeechUtil.speechReplaceNum(text, petName); text += SpeechUtil.getPetSpeech(gender, "pet_delete_cancel"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(300408); } //清除缓存,本轮对话结束 @@ -1068,12 +1138,15 @@ public class PetServiceImpl implements PetService { Integer petId = operationReq.getPetId(); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); String text = ""; //玩家未提供操作信息 if (StringUtils.isEmpty(petId) && StringUtils.isEmpty(petPos) && StringUtils.isEmpty(petPos1) && StringUtils.isEmpty(petPos2)) { log.info(uid + "玩家未提供操作信息"); //获取对应话术 text = SpeechUtil.getPetSpeech(gender, "pet_set_position_fail_no_data"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈文本(text); @@ -1116,6 +1189,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_set_position_fail_no_pos"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(petList.size()), String.valueOf(petNumMax)); text += SpeechUtil.getPetSpeech(gender, "pet_set_position_fail_no_pos"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈文本(text); @@ -1134,6 +1208,7 @@ public class PetServiceImpl implements PetService { CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 text = SpeechUtil.getPetSpeech(gender, "pet_set_position_fail_wrong_pos"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈文本(text); @@ -1164,6 +1239,7 @@ public class PetServiceImpl implements PetService { CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 text = SpeechUtil.getPetSpeech(gender, "pet_set_position_fail_no_name"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈文本(text); @@ -1182,6 +1258,7 @@ public class PetServiceImpl implements PetService { CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 text = SpeechUtil.getPetSpeech(gender, "pet_set_position_fail_wrong_name"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈文本(text); @@ -1222,6 +1299,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.speechReplaceNum(text, String.valueOf(pos + 1), petConfig.getName(), petPos.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_set_position_pet_success"); } + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); } else { //宠物已在宠物栏指定位置,无需移动 if (pos == petPos - 1) { @@ -1238,6 +1316,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.speechReplaceNum(text, String.valueOf(pos + 1), petConfig.getName(), petPos.toString()); } text += SpeechUtil.getPetSpeech(gender, "pet_set_position_pet_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); } } resultResponse.set反馈ID(300501); @@ -1250,6 +1329,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_set_position_pet_fail_full"); text = SpeechUtil.speechReplaceNum(text, petConfig.getName()); text += SpeechUtil.getPetSpeech(gender, "pet_set_position_pet_fail_full"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300503); @@ -1296,6 +1376,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.speechReplaceNum(text, String.valueOf(petList.size()), petConfig.getName()); text += SpeechUtil.getPetSpeech(gender, "pet_set_position_pet_success"); } + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(300501); } } @@ -1305,6 +1386,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_set_position_pet_fail_no_pet"); text = SpeechUtil.speechReplaceNum(text, petConfig.getName()); text += SpeechUtil.getPetSpeech(gender, "pet_set_position_pet_fail_no_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300502); @@ -1322,6 +1404,7 @@ public class PetServiceImpl implements PetService { log.info(uid + "提供的位置信息不存在"); //获取对应话术 text = SpeechUtil.getPetSpeech(gender, "pet_set_position_fail_wrong_pos"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈文本(text); @@ -1361,6 +1444,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_set_position_field_fail"); text = SpeechUtil.speechReplaceNum(text, Integer.toString(petPos1)); text += SpeechUtil.getPetSpeech(gender, "pet_set_position_field_fail"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300505); @@ -1390,10 +1474,17 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.speechReplaceNum(text, Integer.toString(petPos1), petConfig.getName(), Integer.toString(petPos2)); text += SpeechUtil.getPetSpeech(gender, "pet_set_position_field_success"); } + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(300504); } //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); + log.info(uid + "宠物换位完成"); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -1415,11 +1506,13 @@ public class PetServiceImpl implements PetService { String petPos2Req = operationReq.getPetPos2(); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家未提供操作信息 if (StringUtils.isEmpty(petPos1Req) || StringUtils.isEmpty(petPos2Req)) { log.info(uid + "玩家提供的位置不全"); //获取对应话术 String text = SpeechUtil.getPetSpeech(gender, "pet_switch_fail_no_pos"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈文本(text); @@ -1443,6 +1536,7 @@ public class PetServiceImpl implements PetService { //获取对应话术 String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_switch_fail_same_set_only_one"); text += SpeechUtil.getPetSpeech(gender, "pet_switch_fail_same_set_only_one"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300516); @@ -1503,9 +1597,10 @@ public class PetServiceImpl implements PetService { petPos2 = RandomDropUtil.getRandomNum(0, petList.size()); //随机到的花圃编号跟petPos1一样,调整 if (petPos1 == petPos2) { - petPos2 = petPos1 + 1; if (petPos1 == petList.size()) { - petPos2 = RandomDropUtil.getRandomNum(1, petList.size() - 1); + petPos2 = petPos1 - 1; + } else { + petPos2 = petPos1 + 1; } } } @@ -1517,6 +1612,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_switch_fail_over"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(petNumMax)); text += SpeechUtil.getPetSpeech(gender, "pet_switch_fail_over"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300513); @@ -1532,6 +1628,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_switch_fail_no_pet"); text = SpeechUtil.speechReplaceNum(text, Integer.toString(petPos1)); text += SpeechUtil.getPetSpeech(gender, "pet_switch_fail_no_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300507); @@ -1547,6 +1644,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_switch_fail_set_error"); text = SpeechUtil.speechReplaceNum(text, petPos1Req); text += SpeechUtil.getPetSpeech(gender, "pet_switch_fail_set_error"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300514); @@ -1562,6 +1660,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_switch_fail_set_error"); text = SpeechUtil.speechReplaceNum(text, petPos2Req); text += SpeechUtil.getPetSpeech(gender, "pet_switch_fail_set_error"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300514); @@ -1576,6 +1675,7 @@ public class PetServiceImpl implements PetService { //获取对应话术 String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_switch_fail_same_set"); text += SpeechUtil.getPetSpeech(gender, "pet_switch_fail_same_set"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300515); @@ -1592,11 +1692,17 @@ public class PetServiceImpl implements PetService { //两位置上的宠物互换位置 Collections.swap(petList, petPos1 - 1, petPos2 - 1); - log.info(uid + "宠物互换位置完成"); + log.info(uid + "宠物栏的宠物互换位置完成"); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_switch_success"); text = SpeechUtil.speechReplaceNum(text, Integer.toString(petPos1), petPos1Name, Integer.toString(petPos2), petPos2Name); text += SpeechUtil.getPetSpeech(gender, "pet_switch_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300506); @@ -1624,12 +1730,18 @@ public class PetServiceImpl implements PetService { } //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); + //园丁宠物栏存放上限 + int petNumMax = TimingAcquisition.gardenerLevelMap.get(TimingAcquisition.gardenerMap.get(uid).getGardenerInfo().getLevel()).getPetNumMax(); //宠物栏中还没有宠物 if (petList.size() == 0) { log.info(uid + "的宠物栏没有宠物"); //获取对应话术 String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_check_fail_no_pet"); + text = SpeechUtil.speechReplaceNum(text, String.valueOf(petNumMax)); text += SpeechUtil.getPetSpeech(gender, "pet_check_fail_no_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300602); @@ -1639,8 +1751,6 @@ public class PetServiceImpl implements PetService { return commonResponse; } StringBuilder feedText = new StringBuilder(); - //园丁宠物栏存放上限 - int petNumMax = TimingAcquisition.gardenerLevelMap.get(TimingAcquisition.gardenerMap.get(uid).getGardenerInfo().getLevel()).getPetNumMax(); //宠物配置信息 Map petConfigMap = TimingAcquisition.petConfigMap; //遍历宠物栏 @@ -1675,6 +1785,7 @@ public class PetServiceImpl implements PetService { } else { //宠物栏宠物数量少的情况,园丁的回答 text += SpeechUtil.getPetSpeech(gender, "pet_check_few"); } + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); log.info(uid + "查看的宠物栏情况:" + feedText.toString()); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -1704,6 +1815,8 @@ public class PetServiceImpl implements PetService { } //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //获取对应话术 String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "nursery_pet_check"); //花圃均有宠物 @@ -1717,6 +1830,7 @@ public class PetServiceImpl implements PetService { text += SpeechUtil.getPetSpeech(gender, "nursery_pet_check_free"); resultResponse.set后台附加返回("查看花圃宠物状况回复1"); } + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); log.info(uid + "查看花圃宠物数量详情完成"); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -1766,6 +1880,8 @@ public class PetServiceImpl implements PetService { } //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); String text = ""; //1.宠物栏和花圃都有宠物 if (fieldPetCount > 0 && nurseryPetCount > 0) { @@ -1790,6 +1906,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.speechReplaceNum(text, String.valueOf(total), String.valueOf(nurseryPetCount), nurseryPetText.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_overview_only_nursery"); } + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300801); @@ -1810,6 +1927,8 @@ public class PetServiceImpl implements PetService { log.info(uid + "查看花圃" + nurseryNum + "的宠物"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家目前有的花圃编号 String nurseryNumText = TimingAcquisition.getAllNurseryNum(uid); //没有提供花圃编号 @@ -1818,6 +1937,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_check_by_num_fail_no_num"); text = SpeechUtil.speechReplaceNum(text, nurseryNumText); text += SpeechUtil.getPetSpeech(gender, "pet_check_by_num_fail_no_num"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300901); @@ -1833,6 +1953,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_check_by_num_fail_wrong_num"); text = SpeechUtil.speechReplaceNum(text, nurseryNumText); text += SpeechUtil.getPetSpeech(gender, "pet_check_by_num_fail_wrong_num"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300902); @@ -1849,6 +1970,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "pet_check_by_num_fail_wrong_num"); text = SpeechUtil.speechReplaceNum(text, nurseryNumText); text += SpeechUtil.getSocialSpeech(gender, "pet_check_by_num_fail_wrong_num"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300902); @@ -1867,6 +1989,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_check_by_num_fail_no_pet"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_check_by_num_fail_no_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300903); @@ -1885,6 +2008,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_check_by_num"); text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.petConfigMap.get(petId).getName(), nurseryNum.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_check_by_num"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300904); @@ -1902,6 +2026,8 @@ public class PetServiceImpl implements PetService { ResultResponse resultResponse = new ResultResponse(); String uid = operationReq.getUid(); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { @@ -1926,6 +2052,7 @@ public class PetServiceImpl implements PetService { 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.getPetSpeech(gender, "pet_check_by_num_sure"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(300905); @@ -1978,12 +2105,15 @@ public class PetServiceImpl implements PetService { log.info(uid + "开始交换花圃" + nurseryPos + "中的宠物和花圃" + nurseryNumPos + "的宠物"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //有花圃位置,但格式不符合规范 if (!StringUtils.isEmpty(nurseryPos)) { if (nurseryPos.equals(Constants.REQ_NON)) { //获取对应话术 String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_fail_wrong_pos"); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_wrong_pos"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(301003); @@ -2004,6 +2134,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_fail_pos_over"); text = SpeechUtil.speechReplaceNum(text, allNurseryText); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_pos_over"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(301004); @@ -2020,6 +2151,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_switch_fail_none"); text = SpeechUtil.speechReplaceNum(text, nurseryPos.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(301002); @@ -2035,6 +2167,7 @@ public class PetServiceImpl implements PetService { String text = SpeechUtil.getPetSpeech(Constants.SPEECH_ASIDE, "pet_move_nursery_switch_fail_none"); text = SpeechUtil.speechReplaceNum(text, nurseryNumPos.toString()); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_fail_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(301002); @@ -2066,6 +2199,7 @@ public class PetServiceImpl implements PetService { text = SpeechUtil.speechReplaceNum(text, nurseryPos.toString(), TimingAcquisition.petConfigMap.get(id).getName(), nurseryNumPos.toString(), TimingAcquisition.petConfigMap.get(numId).getName()); text += SpeechUtil.getPetSpeech(gender, "pet_move_nursery_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(301001); commonResponse.setCode(1); commonResponse.setMsg("成功"); 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 7b8ce63..1c669bf 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 @@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; +import java.math.BigDecimal; import java.text.ParseException; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -90,6 +91,8 @@ public class PlantServiceImpl implements PlantService { Integer nurseryNum = operationReq.getNurseryNum(); //花圃编号 log.info(uid + "开始检查播种条件"); log.info(uid + "玩家的请求信息,植物id:" + plantId + ",花圃编号:" + nurseryNum); + //玩家本地操作,清除bot在别人家的标识 + resultResponse.set玩家当前位置(""); //保存本轮操作的标识 operationReq.setOperationLabel(Constants.PLANT_SEED); //园丁性别 @@ -227,10 +230,27 @@ public class PlantServiceImpl implements PlantService { operationReq.setNurseryNum(null); operationReq.setPlantId(plantId); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); - //获取对应话术 - String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_fail_planted"); - text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.plantMap.get(nurseryInfo.getPlantId()).getName()); + //空闲的花圃 + List nurseryList = new ArrayList<>(); + for (Map.Entry entry : TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos().entrySet()) { + NurseryInfoDto nurseryInfoDto = entry.getValue(); + if (nurseryInfoDto.getStatus() == 0) { + nurseryList.add(String.valueOf(entry.getKey())); + } + } + String text = ""; + if (nurseryList.size() > 0) { + String nurseryText = String.join("、", nurseryList); + //获取对应话术 + text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_fail_planted_hava_free"); + text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.plantMap.get(nurseryInfo.getPlantId()).getName(), nurseryText); + } else { + //获取对应话术 + text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_fail_planted_no_free"); + text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.plantMap.get(nurseryInfo.getPlantId()).getName()); + } text += SpeechUtil.getPlantSpeech(gender, "plant_fail_planted"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100104); @@ -327,6 +347,7 @@ public class PlantServiceImpl implements PlantService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_fail_seed"); text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.itemConfigMap.get(plant.getFruitId()).getName()); text += SpeechUtil.getPlantSpeech(gender, "plant_fail_seed"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100118); @@ -367,7 +388,7 @@ public class PlantServiceImpl implements PlantService { //从背包中取出对应果实id ItemDto fruitItem = TimingAcquisition.gardenerMap.get(uid).getBackPack().getItemBags().get(fruitType).getItems(plant.getFruitId()); Integer level = TimingAcquisition.gardenerMap.get(uid).getGardenerInfo().getLevel(); - //园丁等级不足以种植该植物 + //1.园丁等级不足以种植该植物 if (plant.getGardenerLevel() > level) { log.info(uid + "种植失败,园丁等级" + level + "还足以种植:" + TimingAcquisition.plantMap.get(plantId).getName() + ",需要等级:" + plant.getGardenerLevel()); //保存玩家这轮的请求信息 @@ -388,7 +409,7 @@ public class PlantServiceImpl implements PlantService { commonResponse.setData(resultVarsResponse); return commonResponse; } - //背包中没植物对应的果实 + //2.背包中没植物对应的果实 if (StringUtils.isEmpty(fruitItem)) { log.info(uid + "背包中没有" + TimingAcquisition.plantMap.get(plantId).getName() + "对应的果实:" + TimingAcquisition.itemConfigMap.get(plant.getFruitId()).getName()); //保存玩家这轮的请求信息 @@ -409,30 +430,7 @@ public class PlantServiceImpl implements PlantService { commonResponse.setData(resultVarsResponse); return commonResponse; } - //背包中种子数量是否满足种满整个花圃 - //需要的果实数量 - int fruitNum = (int) (((double)nurseryConfig.getCapacity() / plant.getOccupyArea()) * plant.getFruitSeedNum()); - if (fruitItem.getItemNum() < fruitNum) { - //保存玩家这轮的请求信息 - operationReq.setNurseryNum(nurseryNum); - operationReq.setPlantId(null); - CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); - log.info(uid + "背包中的" + TimingAcquisition.itemConfigMap.get(plant.getFruitId()).getName() + "只有" + fruitItem.getItemNum() + "个" + ",需要" + fruitNum + "个"); - //获取对应话术 - String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_fail_seed"); - text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.itemConfigMap.get(plant.getFruitId()).getName(), fruitItem.getItemNum().toString(), String.valueOf(fruitNum)); - text += SpeechUtil.getPlantSpeech(gender, "plant_fail_seed"); - log.info("种植失败,果实数量不够"); - commonResponse.setCode(1); - commonResponse.setMsg("成功"); - resultResponse.set反馈ID(100103); - resultResponse.set反馈文本(text); - resultResponse.set后台附加返回("种植植物回复3"); - resultVarsResponse.setVars(resultResponse); - commonResponse.setData(resultVarsResponse); - return commonResponse; - } - //花圃等级是否满足种子种植条件,种子对应植物的所需花圃等级要小于等于种植花圃的等级 + //3.花圃等级是否满足果实种植条件,果实对应植物的所需花圃等级要小于等于种植花圃的等级 if (plant.getNurseryLevel() > nurseryConfig.getLevel()) { log.info(uid + "种植失败,需达到花圃等级" + plant.getNurseryLevel() + ",目前花圃等级" + nurseryConfig.getLevel()); //保存玩家这轮的请求信息 @@ -453,34 +451,36 @@ public class PlantServiceImpl implements PlantService { commonResponse.setData(resultVarsResponse); return commonResponse; } - //花圃类型是否满足种植条件 - if (!StringUtils.isEmpty(plant.getNurseryId()) && !Constants.NON.equals(Integer.parseInt(plant.getNurseryId()))) { //有配置花圃多个花圃类型 - List nurseryIdList = Arrays.asList(plant.getNurseryId().split("\\|")); - if (!nurseryIdList.contains(nurseryInfo.getId().toString())) { - //清除缓存,本轮对话结束 - CacheGlobal.concurrentMap.remove(uid); - StringBuilder feedText = new StringBuilder(); - for (String nurseryId : nurseryIdList) { - feedText.append(TimingAcquisition.nurseryConfigMap.get(Integer.parseInt(nurseryId)).getName()).append("、"); + //4.花圃类型是否满足种植条件 + if (!StringUtils.isEmpty(plant.getNurseryId())) { //有配置花圃多个花圃类型 + if (!Constants.NON_STR.equals(plant.getNurseryId())) { + List nurseryIdList = Arrays.asList(plant.getNurseryId().split("\\|")); + if (!nurseryIdList.contains(nurseryInfo.getId().toString())) { + //清除缓存,本轮对话结束 + CacheGlobal.concurrentMap.remove(uid); + StringBuilder feedText = new StringBuilder(); + for (String nurseryId : nurseryIdList) { + feedText.append(TimingAcquisition.nurseryConfigMap.get(Integer.parseInt(nurseryId)).getName()).append("、"); + } + feedText.deleteCharAt(feedText.length() - 1); + log.info(uid + "提供的" + TimingAcquisition.plantMap.get(plantId).getName() + "只能种植在" + feedText); + //获取对应话术 + String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_fail_nursery_type"); + text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.plantMap.get(plantId).getName(), feedText.toString()); + text += SpeechUtil.getPlantSpeech(gender, "plant_fail_nursery_type"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(100106); + resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("种植植物回复6"); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; } - feedText.deleteCharAt(feedText.length() - 1); - log.info(uid + "提供的" + TimingAcquisition.plantMap.get(plantId).getName() + "只能种植在" + feedText); - //获取对应话术 - String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_fail_nursery_type"); - text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.plantMap.get(plantId).getName(), feedText.toString()); - text += SpeechUtil.getPlantSpeech(gender, "plant_fail_nursery_type"); - text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); - commonResponse.setCode(1); - commonResponse.setMsg("成功"); - resultResponse.set反馈ID(100106); - resultResponse.set反馈文本(text); - resultResponse.set后台附加返回("种植植物回复6"); - resultVarsResponse.setVars(resultResponse); - commonResponse.setData(resultVarsResponse); - return commonResponse; } } - //园丁技能是否满足种植条件 + //5.园丁技能是否满足种植条件 if (!StringUtils.isEmpty(plant.getGardenerSkillId()) && !Constants.NON.equals(plant.getGardenerSkillId())) { Map gardenerSkillMap = TimingAcquisition.gardenerMap.get(uid).getGardenerInfo().getSkills(); List skillIdList = gardenerSkillMap.values().stream().map(GardenerSkillDto::getId).collect(Collectors.toList()); @@ -505,12 +505,38 @@ public class PlantServiceImpl implements PlantService { return commonResponse; } } - - //花园中是否有伴生植物即必须植物 + //6.背包中种子数量是否满足种满整个花圃 + //--------------------玩家技能的花圃容量加成------------- + BigDecimal addCapacityPro = TimingAcquisition.getAddNurseryCapacity(uid); + double nurseryCapacity = addCapacityPro.add(new BigDecimal(1)).multiply(new BigDecimal(nurseryConfig.getCapacity())).doubleValue(); + //需要的果实数量 + int fruitNum = (int) ((nurseryCapacity / plant.getOccupyArea()) * plant.getFruitSeedNum()); + if (fruitItem.getItemNum() < fruitNum) { + //保存玩家这轮的请求信息 + operationReq.setNurseryNum(nurseryNum); + operationReq.setPlantId(null); + CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); + log.info(uid + "背包中的" + TimingAcquisition.itemConfigMap.get(plant.getFruitId()).getName() + "只有" + fruitItem.getItemNum() + "个" + ",需要" + fruitNum + "个"); + //获取对应话术 + String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_fail_seed"); + text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.itemConfigMap.get(plant.getFruitId()).getName(), fruitItem.getItemNum().toString(), String.valueOf(fruitNum)); + text += SpeechUtil.getPlantSpeech(gender, "plant_fail_seed"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); + log.info("种植失败,果实数量不够"); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(100103); + resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("种植植物回复3"); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + //7.花园中是否有伴生植物即必须植物 //种植所需植物 String nearPlantIds = plant.getNearPlantIds(); if (!StringUtils.isEmpty(nearPlantIds)) { - if (!nearPlantIds.equals(Constants.NON.toString())) { + if (!Constants.NON_STR.equals(nearPlantIds)) { String[] nearPlantIdList = nearPlantIds.split("\\|"); //花园中已有植物 log.info("花园中的现有花圃信息:" + TimingAcquisition.gardenerMap.get(uid).getGarden().getNurseryInfos()); @@ -540,8 +566,7 @@ public class PlantServiceImpl implements PlantService { } } } - - //花圃中是否有指定宠物 + //8.花圃中是否有指定宠物 Integer petId = plant.getPetId(); if (!StringUtils.isEmpty(petId) && !Constants.NON.equals(petId)) { Integer nurseryPetId = nurseryInfo.getPetField(); @@ -554,6 +579,7 @@ public class PlantServiceImpl implements PlantService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_fail_pet"); text = SpeechUtil.speechReplaceNum(text, plant.getName(), petName); text += SpeechUtil.getPlantSpeech(gender, "plant_fail_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100109); @@ -564,8 +590,7 @@ public class PlantServiceImpl implements PlantService { return commonResponse; } } - - //背包是否有果实种植时所需材料数量 + //9.背包是否有果实种植时所需材料数量 //获取植物配置信息中的所需材料 String costItemNums = plant.getCostItemNums(); //植物有配置所需消耗材料 @@ -655,6 +680,7 @@ public class PlantServiceImpl implements PlantService { ResultResponse resultResponse = new ResultResponse(); String uid = operationReq.getUid(); + String noviceGuide = operationReq.getNoviceGuide(); //新手引导已经进行到的步骤 log.info(uid + "开始二次确认种植"); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); @@ -707,25 +733,28 @@ public class PlantServiceImpl implements PlantService { //到此说明已满足所有种植条件,可以种植后需消耗物品,将背包中对应物品减少数量 //获取植物配置信息中消耗的所需物品 String costItemNums = plant.getCostItemNums(); - if (!StringUtils.isEmpty(costItemNums) && !Constants.NON.equals(Integer.parseInt(costItemNums))) { - log.info("消耗物品前背包的所有物品:" + TimingAcquisition.gardenerMap.get(uid).getBackPack()); - List itemDtoList = TypeConvertUtil.itemString2List(costItemNums); - for (ItemDto item : itemDtoList) { - //物品对应种类 - Integer itemType = TimingAcquisition.itemConfigMap.get(item.getItemId()).getItemTypeId(); - //背包中对应种类的袋子 - ItemBagDto itemBag = TimingAcquisition.gardenerMap.get(uid).getBackPack().getItemBags().get(itemType); - //获取袋里的该物品 - ItemDto itemPacket = itemBag.getItems(item.getItemId()); - itemPacket.setItemNum(itemPacket.getItemNum() - item.getItemNum()); - } - log.info("消耗物品后背包的所有物品:" + TimingAcquisition.gardenerMap.get(uid).getBackPack()); + if (!StringUtils.isEmpty(costItemNums)) { + if (!Constants.NON_STR.equals(costItemNums)) { + log.info("种植需要消耗物品:" + costItemNums); + List itemDtoList = TypeConvertUtil.itemString2List(costItemNums); + for (ItemDto item : itemDtoList) { + //物品对应种类 + Integer itemType = TimingAcquisition.itemConfigMap.get(item.getItemId()).getItemTypeId(); + //背包中对应种类的袋子 + ItemBagDto itemBag = TimingAcquisition.gardenerMap.get(uid).getBackPack().getItemBags().get(itemType); + //获取袋里的该物品 + ItemDto itemPacket = itemBag.getItems(item.getItemId()); + itemPacket.setItemNum(itemPacket.getItemNum() - item.getItemNum()); + } + } } + //--------------------玩家技能的花圃容量加成------------- + BigDecimal addCapacityPro = TimingAcquisition.getAddNurseryCapacity(uid); + double nurseryCapacity = addCapacityPro.add(new BigDecimal(1)).multiply(new BigDecimal(nurseryConfig.getCapacity())).doubleValue(); //背包减少相应果实数量 //从背包中取出对应果实id ItemDto fruitItem = TimingAcquisition.gardenerMap.get(uid).getBackPack().getItemBags().get(Constants.ITEM_TYPE_FRUIT).getItems(plant.getFruitId()); - fruitItem.setItemNum(fruitItem.getItemNum() - (nurseryConfig.getCapacity()/plant.getOccupyArea()) * plant.getFruitSeedNum()); - + fruitItem.setItemNum((int) (fruitItem.getItemNum() - (nurseryCapacity/plant.getOccupyArea()) * plant.getFruitSeedNum())); log.info("开始种植:" + plant.getName()); //对应花圃中增加植物 nurseryInfo.setPlantId(plantId); @@ -734,16 +763,18 @@ public class PlantServiceImpl implements PlantService { nurseryInfo.setSeedingTime(DateUtil.getCurrentTime()); nurseryInfo.setStatus(Constants.PLANT_SEEDING); //花圃为播种期 nurseryInfo.setFruitTimes(plant.getFruitTimes()); //结果次数重置为当前植物的结果次数 - + //--------------------玩家的技能植物成熟时间缩短加成-------------- + BigDecimal speedPlantMaturePro = TimingAcquisition.getSpeedPlantMature(uid); + double speedMaturePro = new BigDecimal(1).subtract(speedPlantMaturePro).doubleValue(); //防守方的攻击力减少 //植物生长周期信息 Map periodTempMap = TimingAcquisition.periodMap.get(nurseryInfo.getPlantId()); //记录植物所有生长期的所需时间 PlantTimeDto plantTime = new PlantTimeDto(); - plantTime.setSeedingTime(DateUtil.addTime(nurseryInfo.getSeedingTime(), (int) periodTempMap.get(Constants.PLANT_SEEDING).getEndTime())); - plantTime.setSowingTime(DateUtil.addTime(nurseryInfo.getSeedingTime(), (int) periodTempMap.get(Constants.PLANT_SOWING).getEndTime())); - plantTime.setGrowingTime(DateUtil.addTime(nurseryInfo.getSeedingTime(), (int) periodTempMap.get(Constants.PLANT_GROWING).getEndTime())); - plantTime.setBloomingTime(DateUtil.addTime(nurseryInfo.getSeedingTime(), (int) periodTempMap.get(Constants.PLANT_BLOOMING).getEndTime())); - plantTime.setMatureTime(DateUtil.addTime(nurseryInfo.getSeedingTime(), (int) periodTempMap.get(Constants.PLANT_MATURE).getEndTime())); + plantTime.setSeedingTime(DateUtil.addTime(nurseryInfo.getSeedingTime(), (int) (periodTempMap.get(Constants.PLANT_SEEDING).getEndTime() * speedMaturePro))); + plantTime.setSowingTime(DateUtil.addTime(nurseryInfo.getSeedingTime(), (int) (periodTempMap.get(Constants.PLANT_SOWING).getEndTime() * speedMaturePro))); + plantTime.setGrowingTime(DateUtil.addTime(nurseryInfo.getSeedingTime(), (int) (periodTempMap.get(Constants.PLANT_GROWING).getEndTime() * speedMaturePro))); + plantTime.setBloomingTime(DateUtil.addTime(nurseryInfo.getSeedingTime(), (int) (periodTempMap.get(Constants.PLANT_BLOOMING).getEndTime() * speedMaturePro))); + plantTime.setMatureTime(DateUtil.addTime(nurseryInfo.getSeedingTime(), (int) (periodTempMap.get(Constants.PLANT_MATURE).getEndTime() * speedMaturePro))); nurseryInfo.setPlantTime(plantTime); @@ -769,10 +800,10 @@ public class PlantServiceImpl implements PlantService { TaskResultDto dailyTaskResult = TimingAcquisition.checkDailyTask(uid, Constants.SEEDING_EVENT); //持久化该园丁信息 -// Map gardenerMap = new ConcurrentHashMap<>(); -// gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); -// String gardener = JSON.toJSONString(gardenerMap); -// PersistenceUtil.saveDataToFile(uid, gardener); + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); @@ -780,6 +811,16 @@ public class PlantServiceImpl implements PlantService { String gender = TimingAcquisition.getGardenerGender(uid); //玩家称呼 CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); + //新手引导的第4次种植果实任务完成 + Integer seedingTimes = TimingAcquisition.gardenerMap.get(uid).getTaskCountMap().get(Constants.SEEDING_EVENT); + log.info(uid + "目前的GB_新手引导步骤:" + noviceGuide); + if (seedingTimes >= 4 && "完成10013".equals(noviceGuide)) { + String guideFourthSeedPlan = TimingAcquisition.systemConfigMap.get("guide_fourth_seed_plant").getValue(); + ItemDto guideFourthSeedPlanNum = TypeConvertUtil.itemString2List(guideFourthSeedPlan).get(0); + if (plantId.equals(guideFourthSeedPlanNum.getItemId())) { + resultResponse.set任务完成("10014"); + } + } //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_success"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString(), plant.getName()); @@ -823,10 +864,13 @@ public class PlantServiceImpl implements PlantService { PlantPojo plant = TimingAcquisition.plantMap.get(plantId); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "plant_cancel"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString().equals("0") ? "" : nurseryNum.toString(), (plant == null) ? "" : plant.getName()); text += SpeechUtil.getPlantSpeech(gender, "plant_cancel"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -846,6 +890,8 @@ public class PlantServiceImpl implements PlantService { String uid = operationReq.getUid(); Integer nurseryNum = operationReq.getNurseryNum(); Integer plantId = operationReq.getPlantId(); + //玩家本地操作,清除bot在别人家的标识 + resultResponse.set玩家当前位置(""); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (!StringUtils.isEmpty(lastReq)) { @@ -973,7 +1019,7 @@ public class PlantServiceImpl implements PlantService { String costItemNums = TimingAcquisition.plantMap.get(plantId).getCostItemNums(); //植物有配置所需消耗材料 if (!StringUtils.isEmpty(costItemNums)) { - if (!Constants.NON.equals(Integer.parseInt(costItemNums))) { + if (!Constants.NON_STR.equals(costItemNums)) { List itemDtoList = TypeConvertUtil.itemString2List(costItemNums); //此次批量种植所需要材料能满足种几个花圃 for (ItemDto item : itemDtoList) { @@ -1010,7 +1056,7 @@ public class PlantServiceImpl implements PlantService { successNumText.deleteCharAt(successNumText.length() - 1); //所需果实和材料 if (!StringUtils.isEmpty(costItemNums)) { - if (!Constants.NON.equals(Integer.parseInt(costItemNums))) { + if (!Constants.NON_STR.equals(costItemNums)) { List itemDtoList = TypeConvertUtil.itemString2List(costItemNums); //此次批量种植所需要材料 for (ItemDto item : itemDtoList) { @@ -1051,7 +1097,7 @@ public class PlantServiceImpl implements PlantService { //所需果实和材料 StringBuilder itemCostText = new StringBuilder(); //所需材料总数 if (!StringUtils.isEmpty(costItemNums)) { - if (!Constants.NON.equals(Integer.parseInt(costItemNums))) { + if (!Constants.NON_STR.equals(costItemNums)) { List itemDtoList = TypeConvertUtil.itemString2List(costItemNums); //此次批量种植所需要材料 for (ItemDto item : itemDtoList) { @@ -1137,23 +1183,30 @@ public class PlantServiceImpl implements PlantService { //---------------------------玩家播种日常任务次数累计一次-------------------------- Map dailyTaskCountMap = TimingAcquisition.gardenerMap.get(uid).getDailyTaskCountMap(); if (!StringUtils.isEmpty(dailyTaskCountMap)) { - dailyTaskCountMap.put(Constants.SEEDING_EVENT, dailyTaskCountMap.get(Constants.SEEDING_EVENT) + 1); + if (!StringUtils.isEmpty(dailyTaskCountMap.get(Constants.SEEDING_EVENT))) { + dailyTaskCountMap.put(Constants.SEEDING_EVENT, dailyTaskCountMap.get(Constants.SEEDING_EVENT) + 1); + } + if (!StringUtils.isEmpty(dailyTaskCountMap.get(Constants.DAILY_TASK_EVENT))) { + dailyTaskCountMap.put(Constants.DAILY_TASK_EVENT, dailyTaskCountMap.get(Constants.DAILY_TASK_EVENT) + 1); + } } } - //取出背包中的材料 - ItemBagDto materialBag = TimingAcquisition.gardenerMap.get(uid).getBackPack().getItemBags().get(Constants.ITEM_TYPE_MATERIAL); - Map materialMap = materialBag.getItemBag(); - log.info("消耗材料前背包的材料:" + materialMap); //所有花圃种植完后需消耗材料,将背包中对应材料减少数量 //获取植物配置信息中的所需材料 String costItemNums = plant.getCostItemNums(); - if (!StringUtils.isEmpty(costItemNums) && !Constants.NON.equals(Integer.parseInt(costItemNums))) { - List itemDtoList = TypeConvertUtil.itemString2List(costItemNums); - for (ItemDto item : itemDtoList) { - ItemDto material = materialMap.get(item.getItemId()); - material.setItemNum(material.getItemNum() - item.getItemNum() * nurseryNumList.size()); + log.info("种植需要消耗材料:" + costItemNums); + if (!StringUtils.isEmpty(costItemNums)) { + if (!Constants.NON_STR.equals(costItemNums)) { + List itemDtoList = TypeConvertUtil.itemString2List(costItemNums); + for (ItemDto item : itemDtoList) { + Integer itemType = TimingAcquisition.itemConfigMap.get(item.getItemId()).getItemTypeId(); + //背包中对应种类的袋子 + ItemBagDto itemBag = TimingAcquisition.gardenerMap.get(uid).getBackPack().getItemBags().get(itemType); + //消耗物品 + ItemDto itemPacket = itemBag.getItems(item.getItemId()); + itemPacket.setItemNum(itemPacket.getItemNum() - item.getItemNum() * nurseryNumList.size()); + } } - log.info("消耗材料后背包的材料:" + materialMap); } //背包减少相应果实数量 //从背包中取出对应果实id @@ -1229,7 +1282,6 @@ public class PlantServiceImpl implements PlantService { //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "batch_seed_cancel"); text = SpeechUtil.speechReplaceNum(text, nurseryNumText.toString(), (plant == null) ? "" : plant.getName()); - text += SpeechUtil.getPlantSpeech(gender, "batch_seed_cancel"); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(101109); @@ -1256,6 +1308,8 @@ public class PlantServiceImpl implements PlantService { String noviceGuide = operationReq.getNoviceGuide(); //新手引导已经进行到的步骤 log.info(uid + "开始收获果实"); log.info(uid + "玩家的请求信息,植物id:" + plantId + ",花圃编号:" + nurseryNum); + //玩家本地操作,清除bot在别人家的标识 + resultResponse.set玩家当前位置(""); //清除上轮对话缓存 CacheGlobal.concurrentMap.remove(uid); //获取该玩家的所有花圃 @@ -1300,6 +1354,7 @@ public class PlantServiceImpl implements PlantService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "harvest_fail_plant"); text = SpeechUtil.speechReplaceNum(text, plantConfigMap.get(plantId).getName()); text += SpeechUtil.getPlantSpeech(gender, "harvest_fail_plant"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100203); @@ -1341,6 +1396,7 @@ public class PlantServiceImpl implements PlantService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "harvest_fail_mature"); text = SpeechUtil.speechReplaceNum(text, plantConfigMap.get(plantId).getName()); text += SpeechUtil.getPlantSpeech(gender, "harvest_fail_mature"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100202); @@ -1412,7 +1468,7 @@ public class PlantServiceImpl implements PlantService { } //获取玩家所有花圃编号 String nurseryNumText = TimingAcquisition.getAllNurseryNum(uid); - //2.仅指定花圃id的情况下-“收取花圃的果子” + //2.仅指定花圃编号的情况下-“收取花圃的果子” if (StringUtils.isEmpty(plantId) && !StringUtils.isEmpty(nurseryNum)) { //花圃编号不存在 if (nurseryNum == Constants.REQ_NON) { @@ -1450,6 +1506,7 @@ public class PlantServiceImpl implements PlantService { if (nurseryInfo.getUsable() == Constants.NURSERY_UNUSABLE) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "harvest_fail_usable"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100207); @@ -1463,6 +1520,7 @@ public class PlantServiceImpl implements PlantService { if (nurseryInfo.getStatus() == Constants.PLANT_NO) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "harvest_fail_plant_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100206); @@ -1489,6 +1547,7 @@ public class PlantServiceImpl implements PlantService { if (nurseryInfo.getStatus() != Constants.PLANT_MATURE) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "harvest_fail_mature_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100205); @@ -1519,11 +1578,12 @@ public class PlantServiceImpl implements PlantService { if (addText.length() > 0) { addText.deleteCharAt(addText.length() - 1); feedText.append("额外触发收获了").append(addText); - } else { - feedText.deleteCharAt(feedText.length() - 1); } } } + if (feedText.length() != 0) { + feedText.deleteCharAt(feedText.length() - 1); + } harvestedNurseryMap.put(nurseryNum, nurseryInfo); log.info("收获:" + feedText); //---------------------------更新玩家数据-------------------------- @@ -1532,6 +1592,11 @@ public class PlantServiceImpl implements PlantService { TaskResultDto updateTaskResult = TimingAcquisition.checkUpdateTask(uid, Constants.HARVEST_EVENT); //------------------------日常任务事件[收获]是否完成------------------------ TaskResultDto dailyTaskResult = TimingAcquisition.checkDailyTask(uid, Constants.HARVEST_EVENT); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "harvest_with_num_success"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString(), feedText.toString()); @@ -1599,16 +1664,17 @@ public class PlantServiceImpl implements PlantService { ItemDto itemDto = nurseryInfo.getHarvestFruit(); feedText.append(itemDto.getItemNum()).append("个").append(itemConfigMap.get(itemDto.getItemId()).getName()); List dropItems = nurseryInfo.getDropItems(); - if (!StringUtils.isEmpty(dropItems) && dropItems.size() != 0) { - feedText.append(",").append("额外收获了"); - for (ItemDto item : dropItems) { - if (item.getItemNum() != 0) { - feedText.append(item.getItemNum()).append("个").append(itemConfigMap.get(item.getItemId()).getName()).append("、"); + if (!StringUtils.isEmpty(dropItems)) { + if (dropItems.size() != 0){ + feedText.append(",").append("额外收获了"); + for (ItemDto item : dropItems) { + if (item.getItemNum() != 0) { + feedText.append(item.getItemNum()).append("个").append(itemConfigMap.get(item.getItemId()).getName()).append("、"); + } } + feedText.deleteCharAt(feedText.length() - 1); } - feedText.deleteCharAt(feedText.length() - 1); } - feedText.append("。"); //收集所有果实 fruitList.add(nurseryInfo.getHarvestFruit()); //收集所有掉落物品 @@ -1618,13 +1684,11 @@ public class PlantServiceImpl implements PlantService { harvestedNurseryMap.put(entry.getKey(), nurseryInfo); } } - if (feedText.length() != 0) { - feedText.deleteCharAt(feedText.length() - 1); - } //所有花圃均未种植 if (count == nurseryInfoMap.size()) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "harvest_fail_plant_all"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100210); @@ -1637,6 +1701,7 @@ public class PlantServiceImpl implements PlantService { if (fruitList.size() == 0) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "harvest_fail_mature_all"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100209); @@ -1677,7 +1742,7 @@ public class PlantServiceImpl implements PlantService { } //-------------------新手引导的获得宠物任务完成。累计宠物数量达到6只---------- int petNum = TimingAcquisition.getPetNum(uid); - if (petNum == 6 && "完成10021".equals(noviceGuide)) { + if (petNum >= 6 && "完成10021".equals(noviceGuide)) { log.info(uid + "完成任务1002"); resultResponse.set任务完成("10022"); } @@ -1698,6 +1763,7 @@ public class PlantServiceImpl implements PlantService { if (nurseryInfo.getUsable() == Constants.NURSERY_UNUSABLE) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "harvest_fail_usable"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100207); @@ -1712,6 +1778,7 @@ public class PlantServiceImpl implements PlantService { if (nurseryInfo.getStatus() == Constants.PLANT_NO) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "harvest_fail_plant_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100206); @@ -1725,6 +1792,7 @@ public class PlantServiceImpl implements PlantService { if (!plantId.equals(nurseryInfo.getPlantId())) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "harvest_fail_plant"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100203); @@ -1750,6 +1818,7 @@ public class PlantServiceImpl implements PlantService { if (nurseryInfo.getStatus() != Constants.PLANT_MATURE) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "harvest_fail_mature_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100205); @@ -1763,16 +1832,18 @@ public class PlantServiceImpl implements PlantService { fruitList.add(nurseryInfo.getHarvestFruit()); StringBuilder feedText = new StringBuilder(); feedText.append(nurseryInfo.getHarvestFruit().getItemNum()). - append("个").append(itemConfigMap.get(nurseryInfo.getHarvestFruit().getItemId()).getName()).append(","); + append("个").append(itemConfigMap.get(nurseryInfo.getHarvestFruit().getItemId()).getName()); List dropItems = nurseryInfo.getDropItems(); if (!StringUtils.isEmpty(dropItems)) { - feedText.append("额外触发收获了"); - for (ItemDto item : dropItems) { - if (item.getItemNum() != 0) { - feedText.append(item.getItemNum()).append("个").append(itemConfigMap.get(item.getItemId()).getName()).append("、"); + if (dropItems.size() != 0) { + feedText.append(",额外触发收获了"); + for (ItemDto item : dropItems) { + if (item.getItemNum() != 0) { + feedText.append(item.getItemNum()).append("个").append(itemConfigMap.get(item.getItemId()).getName()).append("、"); + } } + feedText.deleteCharAt(feedText.length() - 1); } - feedText.deleteCharAt(feedText.length() - 1); } log.info("收获:" + feedText); harvestedNurseryMap.put(nurseryNum, nurseryInfo); @@ -1831,13 +1902,18 @@ public class PlantServiceImpl implements PlantService { Integer nurseryNum = operationReq.getNurseryNum(); log.info(uid + "开始检查待铲除花圃种植情况"); log.info(uid + "玩家请求信息, 花圃编号:" + nurseryNum); + //玩家本地操作,清除bot在别人家的标识 + resultResponse.set玩家当前位置(""); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //没有提供花圃编号 if (StringUtils.isEmpty(nurseryNum)) { log.info(uid + "玩家没提供花圃编号"); //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "clear_plant_fail_no_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100506); @@ -1885,6 +1961,7 @@ public class PlantServiceImpl implements PlantService { if (StringUtils.isEmpty(nurseryInfo.getPlantId()) || nurseryInfo.getStatus() == Constants.PLANT_NO) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "clear_plant_fail_plant"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100502); @@ -1903,7 +1980,7 @@ public class PlantServiceImpl implements PlantService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "clear_plant_check"); text = SpeechUtil.speechReplaceNum(text, clearCost.getValue(), nurseryNum.toString()); text += SpeechUtil.getPlantSpeech(gender, "clear_plant_check"); - + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100501); @@ -1938,6 +2015,8 @@ public class PlantServiceImpl implements PlantService { String uid = operationReq.getUid(); log.info(uid + "开始铲除植物"); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { @@ -1959,6 +2038,7 @@ public class PlantServiceImpl implements PlantService { if (nurseryInfo.getStatus() == Constants.PLANT_NO) { //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "clear_plant_fail_plant"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100505); @@ -1983,6 +2063,7 @@ public class PlantServiceImpl implements PlantService { if (money < Integer.parseInt(clearCost.getValue())) { //背包的货币不够 //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "clear_plant_fail_money"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName(), TimingAcquisition.itemConfigMap.get(moneyId).getName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100507); @@ -2004,11 +2085,16 @@ public class PlantServiceImpl implements PlantService { log.info(uid + "玩家的花圃" + nurseryConfig.getName() + "已经变为空地"); log.info(uid + "玩家的" + nurseryConfig.getName() + "信息:" + nurseryInfo); - + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "clear_plant_success"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString()); text += SpeechUtil.getPlantSpeech(gender, "clear_plant_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); @@ -2031,6 +2117,10 @@ public class PlantServiceImpl implements PlantService { String uid = operationReq.getUid(); String noviceGuide = operationReq.getNoviceGuide(); //新手引导已进行到的步骤 log.info(uid + "开始收取花圃的果实后铲除植物"); + //玩家本地操作,清除bot在别人家的标识 + resultResponse.set玩家当前位置(""); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //出去玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { @@ -2055,6 +2145,7 @@ public class PlantServiceImpl implements PlantService { log.info(nurseryConfigMap.get(nurseryId).getName() + "现在是空地"); //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "clear_plant_fail_plant"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100504); @@ -2070,6 +2161,7 @@ public class PlantServiceImpl implements PlantService { log.info(nurseryConfigMap.get(nurseryId).getName() + "的植物尚未成熟,请稍后收取"); //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "harvest_fail_mature_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100508); @@ -2102,8 +2194,11 @@ public class PlantServiceImpl implements PlantService { //玩家货币不够,铲除植物失败 if (result == 0) { feedText.append(",背包中的货币不够,铲除植物失败"); + //货币id + Integer moneyId = Integer.parseInt(TimingAcquisition.systemConfigMap.get("money").getValue()); //获取对应话术 String text = SpeechUtil.getPlantSpeech(gender, "clear_plant_fail_money"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName(), TimingAcquisition.itemConfigMap.get(moneyId).getName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100507); @@ -2114,10 +2209,16 @@ public class PlantServiceImpl implements PlantService { } //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "harvest_success"); text = SpeechUtil.speechReplaceNum(text, feedText.toString()); text += SpeechUtil.getPlantSpeech(gender, "clear_after_harvest"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); //新手引导第一次收取果实任务完成 Integer harvestTimes = TimingAcquisition.gardenerMap.get(uid).getTaskCountMap().get(Constants.HARVEST_EVENT); if (harvestTimes >= 1 && "完成10005".equals(noviceGuide)) { @@ -2128,7 +2229,7 @@ public class PlantServiceImpl implements PlantService { } //-------------------新手引导的获得宠物任务完成。累计宠物数量达到6只---------- int petNum = TimingAcquisition.getPetNum(uid); - if (petNum == 6 && "完成10021".equals(noviceGuide)) { + if (petNum >= 6 && "完成10021".equals(noviceGuide)) { resultResponse.set任务完成("10022"); } commonResponse.setCode(1); @@ -2164,9 +2265,12 @@ public class PlantServiceImpl implements PlantService { } //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //获取对应话术 String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "clear_plant_cancel"); text += SpeechUtil.getPlantSpeech(gender, "clear_plant_cancel"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100509); @@ -2185,8 +2289,12 @@ public class PlantServiceImpl implements PlantService { String uid = operationReq.getUid(); Integer nurseryNum = operationReq.getNurseryNum(); //花圃编号 Integer plantId = operationReq.getPlantId(); //植物名称 + //玩家本地操作,清除bot在别人家的标识 + resultResponse.set玩家当前位置(""); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家目前的所有花圃 String nurseryText = TimingAcquisition.getAllNurseryNum(uid); //--------------------玩家未提供花圃编号------------------- @@ -2195,6 +2303,7 @@ public class PlantServiceImpl implements PlantService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "check_plant_mature_time_fail_no_num"); text = SpeechUtil.speechReplaceNum(text, nurseryText); text += SpeechUtil.getPlantSpeech(gender, "check_plant_mature_time_fail_no_num"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(101204); @@ -2206,6 +2315,7 @@ public class PlantServiceImpl implements PlantService { } //--------------------提供了花圃编号-------------------- if (!StringUtils.isEmpty(nurseryNum) && StringUtils.isEmpty(plantId)) { + resultResponse.set后台附加返回("查看植物成熟时间回复3"); if (nurseryNum == Constants.REQ_NON) { log.info(uid + "提供的花圃编号不存在"); //获取对应话术 @@ -2313,6 +2423,7 @@ public class PlantServiceImpl implements PlantService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "check_plant_mature_time_success"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString(), plantName); text += SpeechUtil.getPlantSpeech(gender, "check_plant_mature_time_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(101202); @@ -2327,6 +2438,7 @@ public class PlantServiceImpl implements PlantService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "check_plant_mature_time_fail_no_mature"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString(), plantName, subTime, DateUtil.changeForm(nurseryInfo.getPlantTime().getMatureTime())); text += SpeechUtil.getPlantSpeech(gender, "check_plant_mature_time_fail_no_mature"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100201); @@ -2388,6 +2500,7 @@ public class PlantServiceImpl implements PlantService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "check_plant_mature_time_success"); text = SpeechUtil.speechReplaceNum(text, nurseryNumList.get(0).toString(), plantName); text += SpeechUtil.getPlantSpeech(gender, "check_plant_mature_time_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(101202); @@ -2402,10 +2515,12 @@ public class PlantServiceImpl implements PlantService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "check_plant_mature_time_fail_no_mature"); text = SpeechUtil.speechReplaceNum(text, nurseryNumList.get(0).toString(), plantName, subTime, DateUtil.changeForm(nurseryInfo.getPlantTime().getMatureTime())); text += SpeechUtil.getPlantSpeech(gender, "check_plant_mature_time_fail_no_mature"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100201); resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("查看植物成熟时间回复3"); resultVarsResponse.setVars(resultResponse); commonResponse.setData(resultVarsResponse); return commonResponse; @@ -2500,6 +2615,7 @@ public class PlantServiceImpl implements PlantService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "check_plant_mature_time_success"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString(), plantName); text += SpeechUtil.getPlantSpeech(gender, "check_plant_mature_time_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(101202); @@ -2530,6 +2646,7 @@ public class PlantServiceImpl implements PlantService { String text = SpeechUtil.getPlantSpeech(Constants.SPEECH_ASIDE, "check_plant_mature_time_fail_no_mature"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString(), plantName, subTime, DateUtil.changeForm(nurseryInfo.getPlantTime().getMatureTime())); text += SpeechUtil.getPlantSpeech(gender, "check_plant_mature_time_fail_no_mature"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(100201); 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 6134abf..1d1eafb 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 @@ -14,11 +14,14 @@ import com.qiwuai.garden.dto.base.ResultVarsResponse; import com.qiwuai.garden.dto.request.OperationRequest; import com.qiwuai.garden.pojo.*; import com.qiwuai.garden.service.socialService.SocialService; +import com.qiwuai.garden.service.taskService.impl.TaskServiceImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; +import java.math.BigDecimal; import java.text.ParseException; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -30,6 +33,8 @@ public class SocialServiceImpl implements SocialService { Logger log = LoggerFactory.getLogger(SocialServiceImpl.class); //从yml配置文件中取出对话过期时间 String expireTime = YamlUtil.getValueByKey("expireTime"); + @Autowired + private TaskServiceImpl taskServiceImpl; @Override public CommonResponse visitStrangerCheck(OperationRequest operationReq) { @@ -45,10 +50,13 @@ public class SocialServiceImpl implements SocialService { resultResponse.set玩家当前位置("非本人"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家未提供访问的玩家地址 if (StringUtils.isEmpty(address) && StringUtils.isEmpty(name)) { //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "visit_stranger_check_fail_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500106); @@ -61,6 +69,7 @@ public class SocialServiceImpl implements SocialService { if (TimingAcquisition.gardenerMap.get(uid).getLocation().equals(address) || TimingAcquisition.gardenerMap.get(uid).getGardenerInfo().getName().equals(name)) { //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "visit_stranger_check_fail_self"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500107); @@ -113,6 +122,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "visit_stranger_check_fail_no_exist"); text = SpeechUtil.speechReplaceNum(text, nearestAddress); text += SpeechUtil.getSocialSpeech(gender, "visit_stranger_check_fail_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500108); @@ -126,6 +136,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "visit_stranger_check_fail_no_exist"); text = SpeechUtil.speechReplaceNum(text, nearestAddress); text += SpeechUtil.getSocialSpeech(gender, "visit_stranger_check_fail_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500108); @@ -212,6 +223,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "visit_friend_check"); text = SpeechUtil.speechReplaceNum(text, address); text += SpeechUtil.getSocialSpeech(gender, "visit_friend_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500301); @@ -252,8 +264,10 @@ public class SocialServiceImpl implements SocialService { //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (!StringUtils.isEmpty(lastReq)) { - address = lastReq.getAddress(); - name = lastReq.getName(); + if (!StringUtils.isEmpty(lastReq.getAddress())) { + address = lastReq.getAddress(); + name = lastReq.getName(); + } } else { commonResponse.setCode(1); commonResponse.setMsg("失败,对话已结束"); @@ -273,10 +287,13 @@ public class SocialServiceImpl implements SocialService { TimingAcquisition.costMoney(uid, crossRegionCost); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "visit_stranger_cross"); text = SpeechUtil.speechReplaceNum(text, person); text += SpeechUtil.getSocialSpeech(gender, "visit_stranger_cross"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500103); @@ -310,10 +327,13 @@ public class SocialServiceImpl implements SocialService { CacheGlobal.concurrentMap.remove(uid); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "visit_stranger_cancel"); text = SpeechUtil.speechReplaceNum(text, person); text += SpeechUtil.getSocialSpeech(gender, "visit_stranger_cancel"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500104); @@ -359,6 +379,8 @@ public class SocialServiceImpl implements SocialService { CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "visit_stranger_random"); text = SpeechUtil.speechReplaceNum(text, address); @@ -368,6 +390,7 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "新手引导的拜访陌生人任务10015已完成"); } else { text += SpeechUtil.getSocialSpeech(gender, "visit_stranger_random"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set后台附加返回("是否添加好友"); } commonResponse.setCode(1); @@ -485,8 +508,10 @@ public class SocialServiceImpl implements SocialService { //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (!StringUtils.isEmpty(lastReq)) { - lastAddress = lastReq.getAddress(); //对方的玩家地址 - lastName = lastReq.getName(); //对方园丁名称 + if (!StringUtils.isEmpty(lastReq.getAddress())) { + lastAddress = lastReq.getAddress(); //对方的玩家地址 + lastName = lastReq.getName(); //对方园丁名称 + } } String address = curAddress == null ? lastAddress : curAddress; String name = curName == null ? lastName : curName; @@ -497,10 +522,13 @@ public class SocialServiceImpl implements SocialService { } //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家未提供对方的玩家地址 if (StringUtils.isEmpty(address) && StringUtils.isEmpty(name)) { //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "add_friend_ask_fail_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500207); @@ -515,6 +543,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "add_friend_ask_fail_self"); text += SpeechUtil.getSocialSpeech(gender, "add_friend_ask_fail_self"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500213); @@ -533,6 +562,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "add_friend_ask_fail_full"); text += SpeechUtil.getSocialSpeech(gender, "add_friend_ask_fail_full"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); //根据情况返回反馈ID @@ -554,6 +584,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "add_friend_ask_fail_exist"); text = SpeechUtil.speechReplaceNum(text, person); text += SpeechUtil.getSocialSpeech(gender, "add_friend_ask_fail_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); //根据情况返回反馈ID @@ -608,6 +639,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "add_friend_ask_fail_not_exist"); text += SpeechUtil.getSocialSpeech(gender, "add_friend_ask_fail_not_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500212); @@ -650,6 +682,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "add_friend_ask_fail_had"); text = SpeechUtil.speechReplaceNum(text, person); text += SpeechUtil.getSocialSpeech(gender, "add_friend_ask_fail_had"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); //根据情况返回反馈ID @@ -703,15 +736,22 @@ public class SocialServiceImpl implements SocialService { resultResponse.set任务完成("10016"); log.info(uid + "新手引导的申请好友任务10016已完成"); } - if (Constants.VISIT_STRANGER.equals(lastReq.getOperationLabel())) { - //保存玩家这轮的请求信息,用于下一步操作 - operationReq.setAddress(address); - operationReq.setOperationLabel(Constants.ADD_FRIEND); - CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); - } else { - //清除缓存,本轮对话结束 - CacheGlobal.concurrentMap.remove(uid); + if (!StringUtils.isEmpty(lastReq)) { + if (Constants.VISIT_STRANGER.equals(lastReq.getOperationLabel())) { + //保存玩家这轮的请求信息,用于下一步操作 + operationReq.setAddress(address); + operationReq.setOperationLabel(Constants.ADD_FRIEND); + CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); + } else { + //清除缓存,本轮对话结束 + CacheGlobal.concurrentMap.remove(uid); + } } + //---------------------持久化对方的信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(friendUid, TimingAcquisition.gardenerMap.get(friendUid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(friendUid, gardener); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "add_friend_ask"); text = SpeechUtil.speechReplaceNum(text, person); @@ -738,6 +778,8 @@ public class SocialServiceImpl implements SocialService { String uid = operationReq.getUid(); //本人uid //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家收到的好友申请 Map addFriendAskMap = TimingAcquisition.gardenerMap.get(uid).getAddFriendAskMap(); //没有好友申请 @@ -745,6 +787,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "add_friend_check_fail_none"); text += SpeechUtil.getSocialSpeech(gender, "add_friend_check_fail_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500904); @@ -758,6 +801,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "add_friend_check_fail_none"); text += SpeechUtil.getSocialSpeech(gender, "add_friend_check_fail_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500904); @@ -778,6 +822,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "add_friend_check"); text = SpeechUtil.speechReplaceNum(text, address); text += SpeechUtil.getSocialSpeech(gender, "add_friend_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500903); @@ -799,10 +844,13 @@ public class SocialServiceImpl implements SocialService { String address = operationReq.getAddress(); //玩家地址 //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家未提供园丁名称或玩家地址 if (StringUtils.isEmpty(name) && StringUtils.isEmpty(address)) { //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "add_friend_check_by_name_fail_no_name"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500907); @@ -820,6 +868,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "add_friend_check_by_name_fail"); text = SpeechUtil.speechReplaceNum(text, feedText); text += SpeechUtil.getSocialSpeech(gender, "add_friend_check_by_name_fail"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500906); @@ -840,6 +889,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "add_friend_check_by_name"); text = SpeechUtil.speechReplaceNum(text, name); text += SpeechUtil.getSocialSpeech(gender, "add_friend_check_by_name"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500905); @@ -862,6 +912,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "add_friend_check_by_name"); text = SpeechUtil.speechReplaceNum(text, address); text += SpeechUtil.getSocialSpeech(gender, "add_friend_check_by_name"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500905); @@ -876,6 +927,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "add_friend_check_by_name_fail"); text = SpeechUtil.speechReplaceNum(text, feedText); text += SpeechUtil.getSocialSpeech(gender, "add_friend_check_by_name_fail"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500906); @@ -905,6 +957,8 @@ public class SocialServiceImpl implements SocialService { GardenerDto gardener = TimingAcquisition.gardenerMap.get(uid); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家收到的好友申请 Map addFriendAskMap = gardener.getAddFriendAskMap(); //1.玩家提供了园丁名称 @@ -955,12 +1009,12 @@ public class SocialServiceImpl implements SocialService { } //删除玩家的这个好友申请 gardener.getAddFriendAskMap().remove(addressTmp); - //--------------持久化该园丁信息--------------- + //--------------持久化该玩家信息--------------- Map gardenerMap = new ConcurrentHashMap<>(); gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); String gardenerStr = JSON.toJSONString(gardenerMap); PersistenceUtil.saveDataToFile(uid, gardenerStr); - //--------------持久化对方园丁信息------------- + //--------------持久化对方信息------------- Map gardenerMapSide = new ConcurrentHashMap<>(); gardenerMapSide.put(uidSide, TimingAcquisition.gardenerMap.get(uidSide)); String gardenerStrSide = JSON.toJSONString(gardenerMapSide); @@ -1045,6 +1099,7 @@ public class SocialServiceImpl implements SocialService { resultResponse.set后台附加返回("是否接受好友申请"); //bot端需要根据这个判断 } text += SpeechUtil.getSocialSpeech(gender, "add_friend_request_agree"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500901); @@ -1134,6 +1189,8 @@ public class SocialServiceImpl implements SocialService { Integer plantStatus = operationReq.getPlantStatus(); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家的所有好友 List friendList = TimingAcquisition.gardenerMap.get(uid).getFriendList(); //玩家还没有好友 @@ -1141,6 +1198,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "visit_friend_fail"); text += SpeechUtil.getSocialSpeech(gender, "visit_friend_fail"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500305); @@ -1190,6 +1248,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "visit_friend_fail"); text += SpeechUtil.getSocialSpeech(gender, "visit_friend_fail"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500305); @@ -1255,6 +1314,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "visit_friend_check"); text = SpeechUtil.speechReplaceNum(text, randomAddress); text += SpeechUtil.getSocialSpeech(gender, "visit_friend_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500303); @@ -1277,6 +1337,8 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "玩家开始随机访问好友"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家的所有好友 List friendList = TimingAcquisition.gardenerMap.get(uid).getFriendList(); //玩家还没有好友 @@ -1284,6 +1346,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "visit_friend_fail"); text += SpeechUtil.getSocialSpeech(gender, "visit_friend_fail"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500305); @@ -1297,6 +1360,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "visit_friend_fail"); text += SpeechUtil.getSocialSpeech(gender, "visit_friend_fail"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500305); @@ -1363,6 +1427,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "visit_friend_check"); text = SpeechUtil.speechReplaceNum(text, randomAddress); text += SpeechUtil.getSocialSpeech(gender, "visit_friend_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500304); @@ -1385,6 +1450,8 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "玩家开始删除好友检查"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家的所有好友 List friendList = TimingAcquisition.gardenerMap.get(uid).getFriendList(); //玩家还没有好友 @@ -1392,6 +1459,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "delete_friend_fail_none"); text += SpeechUtil.getSocialSpeech(gender, "delete_friend_fail_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500403); @@ -1404,6 +1472,7 @@ public class SocialServiceImpl implements SocialService { if (StringUtils.isEmpty(address) && StringUtils.isEmpty(name)) { //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "delete_friend_fail_no_name"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500405); @@ -1422,6 +1491,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "delete_friend_fail_none"); text = SpeechUtil.speechReplaceNum(text, person); text += SpeechUtil.getSocialSpeech(gender, "delete_friend_fail_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500403); @@ -1436,6 +1506,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "delete_friend_check"); text = SpeechUtil.speechReplaceNum(text, person); text += SpeechUtil.getSocialSpeech(gender, "delete_friend_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500401); @@ -1456,6 +1527,8 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "玩家开始删除好友"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { @@ -1504,10 +1577,16 @@ public class SocialServiceImpl implements SocialService { //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); String person = (name == null) ? address : name; + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardenerStr = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardenerStr); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "delete_friend_success"); text = SpeechUtil.speechReplaceNum(text, person); text += SpeechUtil.getSocialSpeech(gender, "delete_friend_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500402); @@ -1663,8 +1742,10 @@ public class SocialServiceImpl implements SocialService { //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (!StringUtils.isEmpty(lastReq)) { - lastAddress = lastReq.getAddress(); //对方的玩家地址 - lastName = lastReq.getName(); //对方园丁名称 + if (!StringUtils.isEmpty(lastReq.getAddress())) { + lastAddress = lastReq.getAddress(); //对方的玩家地址 + lastName = lastReq.getName(); //对方园丁名称 + } } String address = curAddress == null ? lastAddress : curAddress; String name = curName == null ? lastName : curName; @@ -1676,14 +1757,18 @@ public class SocialServiceImpl implements SocialService { } //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家未提供花圃编号或者园丁名称 if (StringUtils.isEmpty(address)) { //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "garden_check_fail_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500507); resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("询问玩家地址 "); resultVarsResponse.setVars(resultResponse); commonResponse.setData(resultVarsResponse); return commonResponse; @@ -1705,7 +1790,7 @@ public class SocialServiceImpl implements SocialService { String place = TypeConvertUtil.extractChinese(address); //对方所在地区 String uidSide = TimingAcquisition.addressMap.get(place).get(address).getUid(); //对方uid //判断对方是否为好友 - String answer = "要来偷菜吗"; + String answer = "要去攻打吗"; List friendList = TimingAcquisition.gardenerMap.get(uid).getFriendList(); //玩家好友列表 if (!StringUtils.isEmpty(friendList)) { //对方已经是好友 @@ -1727,7 +1812,7 @@ public class SocialServiceImpl implements SocialService { for (Map.Entry entry : nurseryInfoMap.entrySet()) { NurseryInfoDto nurseryInfo = entry.getValue(); //触发植物成熟判断 - if (nurseryInfo.getStatus() != Constants.PLANT_NO) { //已经种植了植物 + if (!StringUtils.isEmpty(nurseryInfo.getPlantId()) && !StringUtils.isEmpty(nurseryInfo.getPlantTime())) { //已经种植了植物 count++; if (DateUtil.getCurrentTime().compareTo(nurseryInfo.getPlantTime().getBloomingTime()) > 0) { //当前时间大于开花期的最后时间,即进入成熟期 nurseryInfo.setStatus(Constants.PLANT_MATURE); //花圃中植物状态改为已成熟 @@ -1754,10 +1839,17 @@ public class SocialServiceImpl implements SocialService { feedText.append("花圃").append(num).append("、"); } feedText.deleteCharAt(feedText.length() - 1); - //获取对应话术 - String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "garden_check_all_mature"); - text = SpeechUtil.speechReplaceNum(text, String.valueOf(nurseryInfoMap.size()), String.valueOf(nurseryInfoMap.size() - nurseryMatureList.size()), - feedText.toString()); + String text = ""; + if (nurseryInfoMap.size() == nurseryMatureList.size()) { + //获取对应话术 + text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "garden_check_all_mature"); + text = SpeechUtil.speechReplaceNum(text, String.valueOf(nurseryInfoMap.size()), feedText.toString()); + } else { + //获取对应话术 + text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "garden_check_part_mature"); + text = SpeechUtil.speechReplaceNum(text, String.valueOf(nurseryInfoMap.size()), String.valueOf(nurseryInfoMap.size() - nurseryMatureList.size()), + feedText.toString()); + } commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500501); @@ -1775,6 +1867,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "garden_check_fail_no_exist"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString()); text += SpeechUtil.getSocialSpeech(gender, "garden_check_fail_no_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500506); @@ -1812,6 +1905,7 @@ public class SocialServiceImpl implements SocialService { text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "garden_check_no_plant"); text = SpeechUtil.speechReplaceNum(text, feedText); text += SpeechUtil.getSocialSpeech(gender, "garden_check_no_plant"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500505); @@ -1833,7 +1927,7 @@ public class SocialServiceImpl implements SocialService { text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "garden_check_mature"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString(), plantConfig.getName(), feedText, answer); feedId = 500503; - if (answer.equals("要来偷菜吗")) { + if (answer.equals("要去攻打吗")) { resultResponse.set后台附加返回("是否偷菜"); } else { resultResponse.set后台附加返回("是否帮助好友"); @@ -1878,10 +1972,13 @@ public class SocialServiceImpl implements SocialService { CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家未提供花圃编号 if (StringUtils.isEmpty(nurseryNum)) { //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "set_earn_rate_fail_no_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500805); @@ -1897,6 +1994,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "set_earn_rate_fail_not_exist"); text = SpeechUtil.speechReplaceNum(text,""); text += SpeechUtil.getSocialSpeech(gender, "set_earn_rate_fail_not_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500807); @@ -1913,6 +2011,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "set_earn_rate_fail_not_exist"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString()); text += SpeechUtil.getSocialSpeech(gender, "set_earn_rate_fail_not_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500807); @@ -1958,6 +2057,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "set_earn_rate_fail_over"); text = SpeechUtil.speechReplaceNum(text, earnRateRangeList[0], earnRateRangeList[1]); text += SpeechUtil.getSocialSpeech(gender, "set_earn_rate_fail_over"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500803); @@ -1973,6 +2073,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "set_earn_rate_check"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString(), earnRate.toString(), earnRateRangeList[0], earnRateRangeList[1]); text += SpeechUtil.getSocialSpeech(gender, "set_earn_rate_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500801); @@ -2010,6 +2111,11 @@ public class SocialServiceImpl implements SocialService { text += SpeechUtil.getSocialSpeech(gender, "set_earn_rate_success"); //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -2037,10 +2143,13 @@ public class SocialServiceImpl implements SocialService { } //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "set_earn_rate_cancel"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString().equals("0") ? "" : nurseryNum.toString()); text += SpeechUtil.getSocialSpeech(gender, "set_earn_rate_cancel"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500808); @@ -2066,10 +2175,40 @@ public class SocialServiceImpl implements SocialService { Integer lastNurseryNum = null; //玩家上一轮的对方花圃编号 //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //记录本轮操作 operationReq.setOperationLabel(Constants.STEAL_OTHER); //bot端需要该标识来识别当前位置非本地 resultResponse.set玩家当前位置("非本人"); + List petFields = TimingAcquisition.gardenerMap.get(uid).getPetFields(); + //玩家宠物栏没有宠物 + if (StringUtils.isEmpty(petFields)) { + log.info(uid + "的宠物栏没有宠物,暂时无法攻打他人的花圃"); + //获取对应话术 + String text = SpeechUtil.getSocialSpeech(gender, "steal_fail_no_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(500619); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + if (petFields.size() == 0) { + log.info(uid + "的宠物栏没有宠物,暂时无法攻打他人的花圃"); + //获取对应话术 + String text = SpeechUtil.getSocialSpeech(gender, "steal_fail_no_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(500619); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } //玩家直接通过园丁名称或玩家地址访问,跨区则跳转到【反馈ID:500102】处 //通过园丁名称找到对应的玩家地址 if (!StringUtils.isEmpty(curName)) { @@ -2094,6 +2233,7 @@ public class SocialServiceImpl implements SocialService { //玩家地址为随机 if ("随机".equals(curAddress)) { curAddress = TimingAcquisition.findStrangerRandom(uid); + log.info(uid + "偷菜时,随机到的玩家地址:" + curAddress); } //判断提供的玩家地址是否存在 if (!TimingAcquisition.checkAddress(curAddress) && !"付费".equals(curAddress)) { @@ -2118,6 +2258,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_self"); text += SpeechUtil.getSocialSpeech(gender, "steal_fail_self"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500611); @@ -2186,9 +2327,11 @@ public class SocialServiceImpl implements SocialService { //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (!StringUtils.isEmpty(lastReq)) { - lastAddress = lastReq.getAddress(); //对方的玩家地址 - lastName = lastReq.getName(); //对方园丁名称 - lastNurseryNum = lastReq.getNurseryNum(); //对方的花圃编号 + if (!StringUtils.isEmpty(lastReq.getAddress())) { + lastAddress = lastReq.getAddress(); //对方的玩家地址 + lastName = lastReq.getName(); //对方园丁名称 + lastNurseryNum = lastReq.getNurseryNum(); //对方的花圃编号 + } } String address = (curAddress == null) ? lastAddress : curAddress; String name = (curName == null) ? lastName : curName; @@ -2198,6 +2341,7 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "未提供玩家地址"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "steal_fail_no_address"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500609); @@ -2229,21 +2373,25 @@ public class SocialServiceImpl implements SocialService { CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //查看玩家自己的好友列表 List friendList = gardener.getFriendList(); - //对方是好友,不能偷菜 - 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 + ",无法偷取"); - //获取对应话术 - String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_friend"); - text = SpeechUtil.speechReplaceNum(text, person); - commonResponse.setCode(1); - commonResponse.setMsg("成功"); - resultResponse.set反馈ID(500612); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - commonResponse.setData(resultVarsResponse); - return commonResponse; + if (!StringUtils.isEmpty(friendList)) { + if (friendList.size() != 0) { + //对方是好友,不能偷菜 + 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 + ",无法偷取"); + //获取对应话术 + String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_friend"); + text = SpeechUtil.speechReplaceNum(text, person); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(500612); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + } } //1.玩家未提供花圃编号 if (StringUtils.isEmpty(nurseryNum)) { @@ -2251,6 +2399,7 @@ public class SocialServiceImpl implements SocialService { CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "steal_fail_no_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500606); @@ -2266,6 +2415,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_not_exist"); text = SpeechUtil.speechReplaceNum(text, address); text += SpeechUtil.getSocialSpeech(gender, "steal_fail_not_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500607); @@ -2287,6 +2437,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_not_exist"); text = SpeechUtil.speechReplaceNum(text, address); text += SpeechUtil.getSocialSpeech(gender, "steal_fail_not_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500607); @@ -2340,6 +2491,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_no_times"); text += SpeechUtil.getSocialSpeech(gender, "steal_fail_no_times"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500605); @@ -2362,6 +2514,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_had"); text = SpeechUtil.speechReplaceNum(text, address); text += SpeechUtil.getSocialSpeech(gender, "steal_fail_had"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500604); @@ -2373,7 +2526,22 @@ public class SocialServiceImpl implements SocialService { } } //8.对方该花圃还未种植 - if (nurseryInfo.getStatus() == Constants.PLANT_NO) { + if (StringUtils.isEmpty(nurseryInfo.getPlantId())) { + log.info(uid + "偷菜失败,花圃" + nurseryNum + "还未种植"); + //获取对应话术 + String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_no_plant"); + text = SpeechUtil.speechReplaceNum(text, address, nurseryNum.toString()); + text += SpeechUtil.getSocialSpeech(gender, "steal_fail_no_plant"); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(500603); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + //8.对方该花圃还未种植 + if (Constants.NON.equals(nurseryInfo.getPlantId())) { log.info(uid + "偷菜失败,花圃" + nurseryNum + "还未种植"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_no_plant"); @@ -2434,16 +2602,6 @@ public class SocialServiceImpl implements SocialService { resultResponse.set任务完成("10017"); log.info(uid + "新手引导的偷菜任务10017已完成"); } - //--------------持久化该园丁信息--------------- - Map gardenerMap = new ConcurrentHashMap<>(); - gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); - String gardenerStr = JSON.toJSONString(gardenerMap); - PersistenceUtil.saveDataToFile(uid, gardenerStr); - //--------------持久化对方园丁信息------------- - Map gardenerMapSide = new ConcurrentHashMap<>(); - gardenerMapSide.put(uidSide, TimingAcquisition.gardenerMap.get(uidSide)); - String gardenerStrSide = JSON.toJSONString(gardenerMapSide); - PersistenceUtil.saveDataToFile(uidSide, gardenerStrSide); //保存玩家这轮的请求信息,用于下一步的操作,即查看战斗简报 operationReq.setAddress(address); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); @@ -2453,6 +2611,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_fight"); text = SpeechUtil.speechReplaceNum(text, address, nurseryNum.toString()); text += SpeechUtil.getSocialSpeech(gender, "steal_fail_fight"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500602); @@ -2472,6 +2631,17 @@ public class SocialServiceImpl implements SocialService { //------------------------日常任务事件[偷菜成功]是否完成------------------------ TaskResultDto dailyTaskResult = TimingAcquisition.checkDailyTask(uid, Constants.HELP_EVENT); log.info(uid + "偷菜获得的物品有:" + feedText); + //--------------持久化该园丁信息--------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardenerStr = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardenerStr); + //--------------持久化对方园丁信息------------- + Map gardenerMapSide = new ConcurrentHashMap<>(); + gardenerMapSide.put(uidSide, TimingAcquisition.gardenerMap.get(uidSide)); + String gardenerStrSide = JSON.toJSONString(gardenerMapSide); + PersistenceUtil.saveDataToFile(uidSide, gardenerStrSide); + String text = ""; if (feedText.length() == 0 ) { //获取对应话术 @@ -2480,9 +2650,10 @@ public class SocialServiceImpl implements SocialService { } else { //获取对应话术 text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_success"); - text = SpeechUtil.speechReplaceNum(address, text, nurseryNum.toString(), feedText.toString()); + text = SpeechUtil.speechReplaceNum(text, address, nurseryNum.toString(), feedText.toString()); } text += SpeechUtil.getSocialSpeech(gender, "steal_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); text += updateTaskResult.getResultText(); //养成任务事件[偷菜成功]完成提醒 text += dailyTaskResult.getResultText(); //日常任务事件[偷菜成功]完成提醒 commonResponse.setCode(1); @@ -2513,10 +2684,40 @@ public class SocialServiceImpl implements SocialService { String lastName = null; //玩家上一轮的对方园丁名称 //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //记录本轮操作 operationReq.setOperationLabel(Constants.STEAL_OTHER); //bot端需要该标识来识别当前位置非本地 resultResponse.set玩家当前位置("非本人"); + List petFields = TimingAcquisition.gardenerMap.get(uid).getPetFields(); + //玩家宠物栏没有宠物 + if (StringUtils.isEmpty(petFields)) { + log.info(uid + "的宠物栏没有宠物,暂时无法攻打他人的花圃"); + //获取对应话术 + String text = SpeechUtil.getSocialSpeech(gender, "steal_fail_no_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(500620); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + if (petFields.size() == 0) { + log.info(uid + "的宠物栏没有宠物,暂时无法攻打他人的花圃"); + //获取对应话术 + String text = SpeechUtil.getSocialSpeech(gender, "steal_fail_no_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(500620); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } //玩家直接通过园丁名称或玩家地址访问,跨区则跳转到【反馈ID:500102】处 //通过园丁名称找到对应的玩家地址 if (!StringUtils.isEmpty(curName)) { @@ -2539,6 +2740,7 @@ public class SocialServiceImpl implements SocialService { //玩家地址为随机 if ("随机".equals(curAddress)) { curAddress = TimingAcquisition.findStrangerRandom(uid); + log.info(uid + "随机偷菜时,随机到的玩家地址:" + curAddress); } //判断提供的玩家地址是否存在 if (!TimingAcquisition.checkAddress(curAddress) && !"付费".equals(curAddress)) { @@ -2563,6 +2765,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_self"); text += SpeechUtil.getSocialSpeech(gender, "steal_fail_self"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500616); @@ -2630,8 +2833,10 @@ public class SocialServiceImpl implements SocialService { //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (!StringUtils.isEmpty(lastReq)) { - lastAddress = lastReq.getAddress(); //对方的玩家地址 - lastName = lastReq.getName(); //对方园丁名称 + if (!StringUtils.isEmpty(lastReq.getAddress())) { + lastAddress = lastReq.getAddress(); //对方的玩家地址 + lastName = lastReq.getName(); //对方园丁名称 + } } String address = curAddress == null ? lastAddress : curAddress; String name = curName == null ? lastName : curName; @@ -2639,6 +2844,7 @@ public class SocialServiceImpl implements SocialService { if (StringUtils.isEmpty(address) && StringUtils.isEmpty(name)) { //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "steal_fail_no_address"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500609); @@ -2653,21 +2859,25 @@ public class SocialServiceImpl implements SocialService { } //查看玩家自己的好友列表 List friendList = TimingAcquisition.gardenerMap.get(uid).getFriendList(); - //对方是好友,不能偷菜 - 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 + ",无法偷取"); - //获取对应话术 - String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_friend"); - text = SpeechUtil.speechReplaceNum(text, person); - commonResponse.setCode(1); - commonResponse.setMsg("成功"); - resultResponse.set反馈ID(500612); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - commonResponse.setData(resultVarsResponse); - return commonResponse; + if (!StringUtils.isEmpty(friendList)) { + if (friendList.size() != 0) { + //对方是好友,不能偷菜 + 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 + ",无法偷取"); + //获取对应话术 + String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_friend"); + text = SpeechUtil.speechReplaceNum(text, person); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(500612); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + } } String place = TypeConvertUtil.extractChinese(address); //对方所在地区 String uidSide = TimingAcquisition.addressMap.get(place).get(address).getUid(); //对方uid @@ -2679,6 +2889,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_no_times"); text += SpeechUtil.getSocialSpeech(gender, "steal_fail_no_times"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500605); @@ -2701,6 +2912,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_had"); text = SpeechUtil.speechReplaceNum(text, address); text += SpeechUtil.getSocialSpeech(gender, "steal_fail_had"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500604); @@ -2716,10 +2928,12 @@ public class SocialServiceImpl implements SocialService { for (Map.Entry entry : TimingAcquisition.gardenerMap.get(uidSide).getGarden().getNurseryInfos().entrySet()) { NurseryInfoDto nurseryInfoDto = entry.getValue(); //花圃中有种植植物 - if (!StringUtils.isEmpty(nurseryInfoDto.getPlantTime())) { - //植物已成熟 - if (DateUtil.getCurrentTime().compareTo(nurseryInfoDto.getPlantTime().getMatureTime()) > 0) { - nurseryNumList.add(entry.getKey()); + if (!StringUtils.isEmpty(nurseryInfoDto.getPlantId())) { + if (!StringUtils.isEmpty(nurseryInfoDto.getPlantTime())) { + //植物已成熟 + if (DateUtil.getCurrentTime().compareTo(nurseryInfoDto.getPlantTime().getMatureTime()) > 0) { + nurseryNumList.add(entry.getKey()); + } } } } @@ -2813,16 +3027,6 @@ public class SocialServiceImpl implements SocialService { resultResponse.set任务完成("10017"); log.info(uid + "新手引导的偷菜任务10017已完成"); } - //--------------持久化该园丁信息--------------- - Map gardenerMap = new ConcurrentHashMap<>(); - gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); - String gardenerStr = JSON.toJSONString(gardenerMap); - PersistenceUtil.saveDataToFile(uid, gardenerStr); - //--------------持久化对方园丁信息------------- - Map gardenerMapSide = new ConcurrentHashMap<>(); - gardenerMapSide.put(uidSide, TimingAcquisition.gardenerMap.get(uidSide)); - String gardenerStrSide = JSON.toJSONString(gardenerMapSide); - PersistenceUtil.saveDataToFile(uidSide, gardenerStrSide); //保存玩家这轮的请求信息,用于下一步的操作,即查看战斗简报 operationReq.setAddress(address); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); @@ -2832,6 +3036,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_fail_fight"); text = SpeechUtil.speechReplaceNum(text, address, nurseryNum.toString()); text += SpeechUtil.getSocialSpeech(gender, "steal_fail_fight"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500607); @@ -2850,10 +3055,21 @@ public class SocialServiceImpl implements SocialService { TaskResultDto updateTaskResult = TimingAcquisition.checkUpdateTask(uid, Constants.STEAL_SUCCESS_EVENT); //------------------------日常任务事件[偷菜成功]是否完成------------------------ TaskResultDto dailyTaskResult = TimingAcquisition.checkDailyTask(uid, Constants.HELP_EVENT); + //--------------持久化该园丁信息--------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardenerStr = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardenerStr); + //--------------持久化对方园丁信息------------- + Map gardenerMapSide = new ConcurrentHashMap<>(); + gardenerMapSide.put(uidSide, TimingAcquisition.gardenerMap.get(uidSide)); + String gardenerStrSide = JSON.toJSONString(gardenerMapSide); + PersistenceUtil.saveDataToFile(uidSide, gardenerStrSide); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_success"); text = SpeechUtil.speechReplaceNum(text, address, nurseryNum.toString(), feedText.toString()); text += SpeechUtil.getSocialSpeech(gender, "steal_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); text += updateTaskResult.getResultText(); //养成任务事件[偷菜成功]完成提醒 text += dailyTaskResult.getResultText(); //日常任务事件[偷菜成功]完成提醒 commonResponse.setCode(1); @@ -2884,8 +3100,11 @@ public class SocialServiceImpl implements SocialService { String lastAddress = null; //玩家上一轮保存的对方玩家地址 String lastName = null; //玩家上一轮的对方园丁名称 Integer lastNurseryNum = null; //玩家上一轮的好友花圃编号 + operationReq.setOperationLabel(Constants.HELP_FRIEND); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //bot端需要该标识来识别当前位置非本地 resultResponse.set玩家当前位置("非本人"); //玩家直接通过园丁名称或玩家地址访问,跨区则跳转到【反馈ID:500102】处 @@ -3018,7 +3237,6 @@ public class SocialServiceImpl implements SocialService { operationReq.setAddress(curAddress); operationReq.setName(curName); operationReq.setNurseryNum(curNurseryNum); - operationReq.setOperationLabel(Constants.HELP_FRIEND); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "help_cross_cost"); @@ -3037,9 +3255,11 @@ public class SocialServiceImpl implements SocialService { //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (!StringUtils.isEmpty(lastReq)) { - lastAddress = lastReq.getAddress(); //对方的玩家地址 - lastName = lastReq.getName(); //对方园丁名称 - lastNurseryNum = lastReq.getNurseryNum(); //对方花圃编号 + if (!StringUtils.isEmpty(lastReq.getAddress())) { + lastAddress = lastReq.getAddress(); //对方的玩家地址 + lastName = lastReq.getName(); //对方园丁名称 + lastNurseryNum = lastReq.getNurseryNum(); //对方花圃编号 + } } String address = curAddress == null ? lastAddress : curAddress; String name = curName == null ? lastName : curName; @@ -3048,6 +3268,7 @@ public class SocialServiceImpl implements SocialService { if (StringUtils.isEmpty(address) && StringUtils.isEmpty(name)) { //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "help_friend_fail_no_address"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500712); @@ -3084,6 +3305,20 @@ public class SocialServiceImpl implements SocialService { } //对方还不是好友 if (StringUtils.isEmpty(friend)) { + log.info(uid + "帮助的对象:" + address + "还不是好友"); + //获取对应话术 + String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "help_friend_fail_not_friend"); + text = SpeechUtil.speechReplaceNum(text, person); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(500709); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + if (StringUtils.isEmpty(friend.getAddress())) { + log.info(uid + "帮助的对象:" + address + "还不是好友"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "help_friend_fail_not_friend"); text = SpeechUtil.speechReplaceNum(text, person); @@ -3102,6 +3337,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "help_friend_fail_no_help_times"); text += SpeechUtil.getSocialSpeech(gender, "help_friend_fail_no_help_times"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500710); @@ -3110,10 +3346,11 @@ public class SocialServiceImpl implements SocialService { commonResponse.setData(resultVarsResponse); return commonResponse; } + String nowTime = DateUtil.getCurrentTime(); //当前时间 try { //该好友今天还未帮助过 if (!StringUtils.isEmpty(friend.getHelpTime())) { - if (DateUtil.compare(friend.getHelpTime(), DateUtil.getCurrentTime()) < 0 && Constants.HELP_HAVE_SIGN == friend.getHelpTag()) { + if (DateUtil.compare(friend.getHelpTime(), nowTime) < 0 && Constants.HELP_HAVE_SIGN == friend.getHelpTag()) { //该好友标记为未帮助 friend.setHelpTag(Constants.HELP_NO_SIGN); friend.setHelpTime(null); @@ -3127,6 +3364,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "help_friend_fail_no_times"); text += SpeechUtil.getSocialSpeech(gender, "help_friend_fail_no_times"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500702); @@ -3149,9 +3387,9 @@ public class SocialServiceImpl implements SocialService { for(Map.Entry entry : nurseryInfoMapSide.entrySet()) { NurseryInfoDto nurseryInfoDto = entry.getValue(); //植物成熟 - if (!StringUtils.isEmpty(nurseryInfoDto.getPlantTime())) { - if (DateUtil.getCurrentTime().compareTo(nurseryInfoDto.getPlantTime().getBloomingTime()) > 0) { - nurseryNumList.add(nurseryInfoDto.getId()); + if (!StringUtils.isEmpty(nurseryInfoDto.getPlantTime()) && !StringUtils.isEmpty(nurseryInfoDto.getPlantId())) { + if (nowTime.compareTo(nurseryInfoDto.getPlantTime().getBloomingTime()) > 0) { + nurseryNumList.add(entry.getKey()); } } } @@ -3160,6 +3398,7 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "帮助失败,所有植物尚未成熟,无法帮助好友收取"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "help_friend_fail_all_no_mature"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500703); @@ -3173,14 +3412,15 @@ public class SocialServiceImpl implements SocialService { sign = true; } //好友当前花圃信息 - NurseryInfoDto nurseryInfoSIde = nurseryInfoMapSide.get(nurseryNum); + NurseryInfoDto nurseryInfoSide = nurseryInfoMapSide.get(nurseryNum); //好友没有这样花圃编号 - if (StringUtils.isEmpty(nurseryInfoSIde)) { + if (StringUtils.isEmpty(nurseryInfoSide)) { log.info(uid + "帮助失败,不存在花圃" + nurseryNum); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "help_friend_fail_no_nursery"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString()); text += SpeechUtil.getSocialSpeech(gender, "help_friend_fail_no_nursery"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500711); @@ -3192,12 +3432,13 @@ public class SocialServiceImpl implements SocialService { String result = ""; try { //玩家可在好友的该花圃操作,好友该花圃空闲则先上锁 - if (Constants.NURSERY_FREE.equals(nurseryInfoSIde.getLock())) { - nurseryInfoSIde.setLock(Constants.NURSERY_BUSY); + if (Constants.NURSERY_FREE.equals(nurseryInfoSide.getLock())) { + nurseryInfoSide.setLock(Constants.NURSERY_BUSY); } else { //5.该花圃忙碌,偷菜失败 - log.info(uid + "帮助失败,当前花圃" + nurseryInfoSIde + "已有人在操作"); + log.info(uid + "帮助失败,当前花圃" + nurseryInfoSide + "已有人在操作"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "help_friend_fail_no_plant"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500707); @@ -3207,10 +3448,11 @@ public class SocialServiceImpl implements SocialService { return commonResponse; } //好友花圃未种植或者花圃未开放 - if (nurseryInfoSIde.getStatus() == Constants.PLANT_NO || nurseryInfoSIde.getUsable() == Constants.NURSERY_UNUSABLE) { + if (StringUtils.isEmpty(nurseryInfoSide.getPlantId()) || nurseryInfoSide.getUsable() == Constants.NURSERY_UNUSABLE) { log.info(uid + "帮助失败,花圃" + nurseryNum + "还未种植或者未开启"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "help_friend_fail_no_plant"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(500707); @@ -3220,7 +3462,7 @@ public class SocialServiceImpl implements SocialService { return commonResponse; } //好友该花圃的植物还未成熟 - if (DateUtil.getCurrentTime().compareTo(nurseryInfoSIde.getPlantTime().getBloomingTime()) <= 0) { + if (nowTime.compareTo(nurseryInfoSide.getPlantTime().getBloomingTime()) <= 0) { log.info(uid + "帮助失败,花圃" + nurseryNum + "的植物还未成熟"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "help_friend_fail_no_mature"); @@ -3232,15 +3474,15 @@ public class SocialServiceImpl implements SocialService { commonResponse.setData(resultVarsResponse); return commonResponse; } - NurseryInfoDto nurseryInfoSide = gardenerSide.getGarden().getNurseryInfos().get(nurseryNum); + NurseryInfoDto nurseryInfoSideTmp = gardenerSide.getGarden().getNurseryInfos().get(nurseryNum); //好友花圃的植物成熟掉落 - RandomDropUtil.plantMature(uidSide, nurseryInfoSide); + RandomDropUtil.plantMature(uidSide, nurseryInfoSideTmp); //------------------------帮助好友后,被帮助方和帮助方数据更新,返回结果为帮助方的获得---------------------------- result = updateAfterHelp(uid, uidSide, nurseryNum); } catch (Exception e) { e.printStackTrace(); } finally { - nurseryInfoSIde.setLock(Constants.NURSERY_FREE); + nurseryInfoSide.setLock(Constants.NURSERY_FREE); } //--------------对方帮助简报提醒次数加1------------ Integer count = TimingAcquisition.gardenerMap.get(uidSide).getNotice().get(Constants.HELP_REPORT_NOTICE); @@ -3253,16 +3495,6 @@ public class SocialServiceImpl implements SocialService { resultResponse.set任务完成("10018"); log.info(uid + "新手引导的帮助好友任务10018已完成"); } - //--------------持久化该园丁信息--------------- - Map gardenerMap = new ConcurrentHashMap<>(); - gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); - String gardenerStr = JSON.toJSONString(gardenerMap); - PersistenceUtil.saveDataToFile(uid, gardenerStr); - //--------------持久化对方园丁信息------------- - Map gardenerMapSide = new ConcurrentHashMap<>(); - gardenerMapSide.put(uidSide, TimingAcquisition.gardenerMap.get(uidSide)); - String gardenerStrSide = JSON.toJSONString(gardenerMapSide); - PersistenceUtil.saveDataToFile(uidSide, gardenerStrSide); //帮助成功,今日帮助次数加1 gardener.setHelpTimes(gardener.getHelpTimes() + 1); //-----------------------------------帮助方帮助任务次数累计一次-------------------------- @@ -3284,11 +3516,22 @@ public class SocialServiceImpl implements SocialService { TaskResultDto dailyTaskResult = TimingAcquisition.checkDailyTask(uid, Constants.HELP_EVENT); //该好友标记为已帮助 friend.setHelpTag(Constants.HELP_HAVE_SIGN); - friend.setHelpTime(DateUtil.getCurrentTime()); + friend.setHelpTime(nowTime); + //--------------持久化该园丁信息--------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardenerStr = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardenerStr); + //--------------持久化对方园丁信息------------- + Map gardenerMapSide = new ConcurrentHashMap<>(); + gardenerMapSide.put(uidSide, TimingAcquisition.gardenerMap.get(uidSide)); + String gardenerStrSide = JSON.toJSONString(gardenerMapSide); + PersistenceUtil.saveDataToFile(uidSide, gardenerStrSide); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "help_friend_success"); text = SpeechUtil.speechReplaceNum(text, gardenerSide.getLocation(), nurseryNum.toString(), result); text += SpeechUtil.getSocialSpeech(gender, "help_friend_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); text += updateTaskResult.getResultText(); //养成任务事件[帮助好友]完成提醒 text += dailyTaskResult.getResultText(); //日常任务事件[帮助好友]完成提醒 commonResponse.setCode(1); @@ -3340,6 +3583,8 @@ public class SocialServiceImpl implements SocialService { //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); String reportName = operationReq.getReportName(); //简报名称 + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); log.info(uid + "查看简报:" + reportName); //玩家提供的简报名称为空 if (StringUtils.isEmpty(reportName)) { @@ -3482,6 +3727,7 @@ public class SocialServiceImpl implements SocialService { text = SpeechUtil.speechReplaceNum(text, helpReport.getFriendAddress(), harvestTime, helpReport.getNurseryNum().toString(), plantName, harvestItemsText.toString(), getItemsText.toString()); text += SpeechUtil.getSocialSpeech(gender, "help_report_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501303); @@ -3492,17 +3738,18 @@ public class SocialServiceImpl implements SocialService { return commonResponse; } //----------------------查看的是偷菜简报时------------------------- - if ("偷菜简报".equals(reportPre) || "偷菜".equals(reportPre)) { + if ("防守简报".equals(reportPre) || "防守".equals(reportPre)) { //所有偷菜简报 // List allStealReportList = gardener.getStealReportList(); //-------------------获取uid的所有偷菜简报------------------- - String stealReports = PersistenceUtil.getReportFromFile(uid, "偷菜简报"); + String stealReports = PersistenceUtil.getReportFromFile(uid, "防守简报"); List allStealReportList = JSON.parseObject(stealReports, new TypeReference>(){}); if (StringUtils.isEmpty(allStealReportList)) { log.info(uid + "偷菜简报为空"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_report_check_fail_no_name"); text += SpeechUtil.getSocialSpeech(gender, "steal_report_check_fail_no_name"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501403); @@ -3517,6 +3764,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_report_check_fail_no_name"); text += SpeechUtil.getSocialSpeech(gender, "steal_report_check_fail_no_name"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501403); @@ -3560,6 +3808,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "steal_report_check_fail_no_name"); text += SpeechUtil.getSocialSpeech(gender, "steal_report_check_fail_no_name"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501403); @@ -3608,6 +3857,7 @@ public class SocialServiceImpl implements SocialService { if (Constants.DEFEND_SUCCESS.equals(stealReport.getFightResult())) { text = SpeechUtil.speechReplaceNum(text, stealTime, stealReport.getStrangeAddress()); text += SpeechUtil.getSocialSpeech(gender, "steal_report_fail_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(501405); resultResponse.set后台附加返回("播报2"); } else { @@ -3628,6 +3878,7 @@ public class SocialServiceImpl implements SocialService { resultResponse.set反馈ID(501404); resultResponse.set后台附加返回("播报1"); } + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈文本(text); @@ -3659,6 +3910,8 @@ public class SocialServiceImpl implements SocialService { String reportName = operationReq.getReportName(); //简报名称 Integer reportNum = operationReq.getReportNum(); //简报序号 log.info(uid + "查看帮助简报,简报名称:" + reportName + ",简报序号:" + reportNum); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //所有帮助简报 // List allHelpReportList = gardener.getHelpReportList(); //-------------------获取uid的所有帮助简报------------------- @@ -3721,6 +3974,7 @@ public class SocialServiceImpl implements SocialService { String helpReportNames = String.join( "、", helpReportNameList); //保存玩家这轮的请求信息,用于下一步的操作 operationReq.setStrList(helpReportNameList); + operationReq.setOperationLabel(Constants.CHECK_HELP_REPORT); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 if (allHelpReportList.size() == 1) { @@ -3745,7 +3999,9 @@ public class SocialServiceImpl implements SocialService { //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (!StringUtils.isEmpty(lastReq)) { - helpReportNames = lastReq.getStrList(); + if (Constants.CHECK_HELP_REPORT.equals(lastReq.getOperationLabel())) { + helpReportNames = lastReq.getStrList(); + } } // List helpReportList = gardener.getHelpReportList().stream().filter(helpReportDto -> Constants.READ_NO.equals(helpReportDto.getRead())).collect(Collectors.toList()); //2.玩家提供了简报序号 @@ -3867,6 +4123,7 @@ public class SocialServiceImpl implements SocialService { text = SpeechUtil.speechReplaceNum(text, helpReport.getFriendAddress(), harvestTime, helpReport.getNurseryNum().toString(), plantName, harvestItemsText.toString(), getItemsText.toString()); text += SpeechUtil.getSocialSpeech(gender, "help_report_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501303); @@ -3890,15 +4147,18 @@ public class SocialServiceImpl implements SocialService { String reportName = operationReq.getReportName(); //简报名称 Integer reportNum = operationReq.getReportNum(); //简报序号 log.info(uid + "查看偷菜简报,简报名称:" + reportName + ",简报序号:" + reportNum); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //所有未读偷菜简报 // List allStealReportList = gardener.getStealReportList(); //-------------------获取uid的所有偷菜简报------------------- - String stealReports = PersistenceUtil.getReportFromFile(uid, "偷菜简报"); + String stealReports = PersistenceUtil.getReportFromFile(uid, "防守简报"); List allStealReportList = JSON.parseObject(stealReports, new TypeReference>(){}); if (StringUtils.isEmpty(allStealReportList)) { log.info(uid + "偷菜简报为空"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "steal_report_check_fail_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501401); @@ -3911,6 +4171,7 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "偷菜简报为空"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "steal_report_check_fail_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501401); @@ -3952,6 +4213,7 @@ public class SocialServiceImpl implements SocialService { String stealReportNames = String.join( "、", stealReportNameList); //保存玩家这轮的请求信息,用于下一步的操作 operationReq.setStrList(stealReportNameList); + operationReq.setOperationLabel(Constants.CHECK_STEAL_REPORT); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 if (allStealReportList.size() == 1) { @@ -3976,7 +4238,9 @@ public class SocialServiceImpl implements SocialService { //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (!StringUtils.isEmpty(lastReq)) { - stealReportNames = lastReq.getStrList(); + if (Constants.CHECK_STEAL_REPORT.equals(lastReq.getOperationLabel())) { + stealReportNames = lastReq.getStrList(); + } } // List stealReportList = gardener.getStealReportList().stream().filter(stealReportDto -> Constants.READ_NO.equals(stealReportDto.getRead())).collect(Collectors.toList()); //玩家提供了简报序号 @@ -4086,6 +4350,7 @@ public class SocialServiceImpl implements SocialService { if (Constants.DEFEND_SUCCESS.equals(stealReport.getFightResult())) { text = SpeechUtil.speechReplaceNum(text, stealTime, stealReport.getStrangeAddress()); text += SpeechUtil.getSocialSpeech(gender, "steal_report_fail_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); resultResponse.set反馈ID(501405); resultResponse.set后台附加返回("播报2"); } else { @@ -4102,6 +4367,7 @@ public class SocialServiceImpl implements SocialService { resultResponse.set反馈ID(501404); resultResponse.set后台附加返回("播报1"); } + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈文本(text); @@ -4120,6 +4386,8 @@ public class SocialServiceImpl implements SocialService { GardenerDto gardener = TimingAcquisition.gardenerMap.get(uid); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { @@ -4186,13 +4454,17 @@ public class SocialServiceImpl implements SocialService { for (Integer petId : stealReport.getPetList()) { petText.append(TimingAcquisition.petConfigMap.get(petId).getName()).append("、"); } - petText.deleteCharAt(petText.length() - 1).append(","); + if (petText.length() != 0) { + petText.deleteCharAt(petText.length() - 1).append(","); + } } if (!StringUtils.isEmpty(stealReport.getPetSideList())) { for (Integer petId : stealReport.getPetSideList()) { petSideText.append(TimingAcquisition.petConfigMap.get(petId).getName()).append("、"); } - petSideText.deleteCharAt(petSideText.length() - 1).append(","); + if (petSideText.length() != 0) { + petSideText.deleteCharAt(petSideText.length() - 1).append(","); + } } //保存玩家这轮的请求信息,用于下一步的操作 operationReq.setReportName(reportName); @@ -4204,12 +4476,16 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "fight_detail_check"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(stealReport.getPetList().size()), petText.toString(), String.valueOf(stealReport.getPetSideList().size()), petSideText.toString(), String.valueOf(stealReport.getRoundFightMap().size()), result); - text += SpeechUtil.getSocialSpeech(gender, "fight_detail_check"); + //玩家宠物栏没有宠物,对方不战而胜 + if (stealReport.getPetList().size() != 0) { + text += SpeechUtil.getSocialSpeech(gender, "fight_detail_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); + resultResponse.set后台附加返回("播报1"); + } commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501401); resultResponse.set反馈文本(text); - resultResponse.set后台附加返回("播报1"); resultVarsResponse.setVars(resultResponse); commonResponse.setData(resultVarsResponse); return commonResponse; @@ -4227,6 +4503,8 @@ public class SocialServiceImpl implements SocialService { GardenerDto gardener = TimingAcquisition.gardenerMap.get(uid); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (!StringUtils.isEmpty(lastReq)) { @@ -4273,6 +4551,7 @@ public class SocialServiceImpl implements SocialService { } String place = TypeConvertUtil.extractChinese(address); //对方所在地区 String uidSide = TimingAcquisition.addressMap.get(place).get(address).getUid(); //对方uid + log.info(uid + "查看跟uid:" + uidSide + "的宠物战斗详情"); String report = PersistenceUtil.getReportFromFileByName(uidSide, reportName); StealReportDto stealReport = JSON.parseObject(report, new TypeReference(){}); //对应偷菜简报名称不存在 @@ -4296,13 +4575,17 @@ public class SocialServiceImpl implements SocialService { for (Integer petId : stealReport.getPetSideList()) { petText.append(TimingAcquisition.petConfigMap.get(petId).getName()).append("、"); } - petText.deleteCharAt(petText.length() - 1).append(","); + if (petText.length() != 0) { + petText.deleteCharAt(petText.length() - 1).append(","); + } } if (!StringUtils.isEmpty(stealReport.getPetList())) { for (Integer petId : stealReport.getPetList()) { petSideText.append(TimingAcquisition.petConfigMap.get(petId).getName()).append("、"); } - petSideText.deleteCharAt(petSideText.length() - 1).append(","); + if (petSideText.length() != 0) { + petSideText.deleteCharAt(petSideText.length() - 1).append(","); + } } //保存玩家这轮的请求信息,用于下一步的操作 operationReq.setAddress(address); @@ -4315,12 +4598,16 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "fight_detail_check"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(stealReport.getPetSideList().size()), petText.toString(), String.valueOf(stealReport.getPetList().size()), petSideText.toString(), String.valueOf(stealReport.getRoundFightMap().size()), result); - text += SpeechUtil.getSocialSpeech(gender, "fight_detail_check"); + //对方玩家宠物栏没有宠物,我方不战而胜 + if (stealReport.getPetList().size() != 0) { + text += SpeechUtil.getSocialSpeech(gender, "fight_detail_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); + resultResponse.set后台附加返回("获取战斗轮次"); + } commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501401); resultResponse.set反馈文本(text); - resultResponse.set后台附加返回("获取战斗轮次"); resultVarsResponse.setVars(resultResponse); commonResponse.setData(resultVarsResponse); return commonResponse; @@ -4461,11 +4748,11 @@ public class SocialServiceImpl implements SocialService { petAttributeNamesSide.deleteCharAt(petAttributeNamesSide.length() - 1); fightDetail.append("第").append(fightRound).append("轮战斗,"); //开始记录挑战方的战斗 - fightDetail.append("我方第").append(petFightDetail.getPetPos() + 1).append("位").append(pet.getName()).append("、").append(rarityMap.get(pet.getRarityId()).getDescription()). - append("、").append(petAttributeNames). + fightDetail.append("我方第").append(petFightDetail.getPetPos() + 1).append("位").append(pet.getName()).append("、稀有度:").append(rarityMap.get(pet.getRarityId()).getDescription()). + append("、属性:").append(petAttributeNames). append(" 对阵 "). - append("对方第").append(petFightDetail.getPetPosSide() + 1).append("位").append(petSide.getName()).append("、").append(rarityMap.get(petSide.getRarityId()).getDescription()). - append("、").append(petAttributeNamesSide).append(","); + append("对方第").append(petFightDetail.getPetPosSide() + 1).append("位").append(petSide.getName()).append("、稀有度:").append(rarityMap.get(petSide.getRarityId()).getDescription()). + append("、属性:").append(petAttributeNamesSide).append(","); fightDetail.append("本轮一共进行了").append(petFightDetail.getRound()).append("回合,"); //开始记录挑战方回合制的战斗 fightDetail.append("我方").append(pet.getName()); @@ -4732,13 +5019,13 @@ public class SocialServiceImpl implements SocialService { //所有的偷菜简报 // List stealReportList = gardener.getStealReportList(); //-------------------获取uid的所有偷菜简报------------------- - String stealReports = PersistenceUtil.getReportFromFile(uid, "偷菜简报"); + String stealReports = PersistenceUtil.getReportFromFile(uid, "防守简报"); List stealReportList = JSON.parseObject(stealReports, new TypeReference>(){}); //玩家有偷菜简报 if (!StringUtils.isEmpty(stealReportList)) { if (stealReportList.size() != 0) { //删除所有对应状态的偷菜简报 - PersistenceUtil.deleteReportByStatus(uid, "偷菜简报", reportStatus); + PersistenceUtil.deleteReportByStatus(uid, "防守简报", reportStatus); // stealReportList.removeIf(stealReportDto -> reportStatus.equals(stealReportDto.getRead())); } } @@ -4829,10 +5116,10 @@ public class SocialServiceImpl implements SocialService { } } //----------------------删除的是偷菜简报时------------------------- - if ("偷菜简报".equals(reportPre) || "偷菜".equals(reportPre)) { + if ("防守简报".equals(reportPre) || "防守".equals(reportPre)) { // List stealReportList = gardener.getStealReportList(); //-------------------获取uid的所有偷菜简报------------------- - String stealReports = PersistenceUtil.getReportFromFile(uid, "偷菜简报"); + String stealReports = PersistenceUtil.getReportFromFile(uid, "防守简报"); List stealReportList = JSON.parseObject(stealReports, new TypeReference>(){}); //玩家还没有偷菜简报 if (StringUtils.isEmpty(stealReportList)) { @@ -5050,7 +5337,7 @@ public class SocialServiceImpl implements SocialService { Integer reportNum = operationReq.getReportNum(); //简报序号 String reportName = operationReq.getReportName(); //简报名称 //-------------------获取uid的所有偷菜简报------------------- - String stealReports = PersistenceUtil.getReportFromFile(uid, "偷菜简报"); + String stealReports = PersistenceUtil.getReportFromFile(uid, "防守简报"); List stealReportList = JSON.parseObject(stealReports, new TypeReference>(){}); // List stealReportList = TimingAcquisition.gardenerMap.get(uid).getStealReportList(); if (StringUtils.isEmpty(stealReportList)) { @@ -5237,16 +5524,84 @@ public class SocialServiceImpl implements SocialService { ResultResponse resultResponse = new ResultResponse(); String uid = operationReq.getUid(); //本人uid + Integer noticeNum = operationReq.getNoticeNum(); //消息序号 String savaAddReturn = operationReq.getSavaAddReturn(); //保存附加返回 //获取玩家的所有消息提醒 Map notice = TimingAcquisition.gardenerMap.get(uid).getNotice(); StringBuilder noticeText = new StringBuilder(); log.info(uid + "开始查看提醒消息"); + //当前玩家上一轮的请求信息 + OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); + if (!StringUtils.isEmpty(lastReq)) { + if (Constants.CHECK_NOTICE.equals(lastReq.getOperationLabel())) { + //玩家提供了消息序号 + if (!StringUtils.isEmpty(noticeNum)) { + int noticeCount = lastReq.getStrList().size(); + //消息序号不存在 + if (noticeNum == Constants.REQ_NON) { + //获取对应话术 + String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "check_notice_fail_wrong_num"); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(501807); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + //首个 + if (noticeNum == Constants.REQ_FIRST) { + noticeNum = 1; + } + //中间 + if (noticeNum == Constants.REQ_MIDDLE) { + noticeNum = noticeCount / 2 + 1; + } + //最后 + if (noticeNum == Constants.REQ_LAST) { + noticeNum = noticeCount; + } + //随机 + if (noticeNum == Constants.REQ_RANDOM) { + noticeNum = RandomDropUtil.getRandomNum(1, noticeCount); + } + String noticeName = lastReq.getStrList().get(noticeNum - 1); + //查看好友申请 + if (Constants.ADD_FRIEND_NOTICE.equals(noticeName)) { + //跳转到“查看好友申请” + return addFriendCheck(operationReq); + } + //查看好友留言 + if (Constants.MESSAGE_NOTICE.equals(noticeName)) { + //跳转到“检查留言” + return checkMessage(operationReq); + } + //查看偷菜简报 + if (Constants.STEAL_REPORT_NOTICE.equals(noticeName)) { + //跳转到“查看偷菜简报” + return checkStealReport(operationReq); + } + //查看帮助简报 + if (Constants.HELP_REPORT_NOTICE.equals(noticeName)) { + //跳转到“查看帮助简报” + return checkHelpReport(operationReq); + } + //查看任务 + if (Constants.TASK_NOTICE.equals(noticeName)) { + //跳转到“查询任务” + return taskServiceImpl.checkTask(operationReq); + } + } + } + } int count = 0; //统计有几种消息提醒 + //收集所有消息提醒类型 + List noticeList = new ArrayList<>(); //遍历所有消息提示,统计各类消息提醒次数 for (Map.Entry entry : notice.entrySet()) { if (entry.getValue() > 0) { count++; + noticeList.add(entry.getKey()); //好友申请提示个数 if (Constants.ADD_FRIEND_NOTICE.equals(entry.getKey())) { //获取对应话术 @@ -5324,12 +5679,21 @@ public class SocialServiceImpl implements SocialService { return commonResponse; } noticeText.deleteCharAt(noticeText.length() - 1); + //---------------------持久化该园丁信息-------------------------- + Map gardenerMap = new ConcurrentHashMap<>(); + gardenerMap.put(uid, TimingAcquisition.gardenerMap.get(uid)); + String gardener = JSON.toJSONString(gardenerMap); + PersistenceUtil.saveDataToFile(uid, gardener); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "check_notice"); text = SpeechUtil.speechReplaceNum(text, noticeText.toString()); commonResponse.setCode(1); commonResponse.setMsg("成功"); if (count > 1) { + //保存玩家这轮的请求信息,用于下一步的操作 + operationReq.setStrList(noticeList); + operationReq.setOperationLabel(Constants.CHECK_NOTICE); + CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); resultResponse.set反馈ID(501806); resultResponse.set消息推送附加返回("消息推送6"); } @@ -5360,6 +5724,8 @@ public class SocialServiceImpl implements SocialService { CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家信息 GardenerDto gardener = TimingAcquisition.gardenerMap.get(uid); //留言时间还未冷却完毕 @@ -5392,6 +5758,7 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "未提供好友地址"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "leave_message_fail_no_address"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501103); @@ -5406,6 +5773,7 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "提供的玩家地址为本人地址"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "leave_message_fail_self"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501109); @@ -5437,6 +5805,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "leave_message_fail_not_exist"); text = SpeechUtil.speechReplaceNum(text, address); text += SpeechUtil.getSocialSpeech(gender, "leave_message_fail_not_exist"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501110); @@ -5462,6 +5831,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "leave_message_fail_not_friend"); text += SpeechUtil.getSocialSpeech(gender, "leave_message_fail_not_friend"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501104); @@ -5525,6 +5895,8 @@ public class SocialServiceImpl implements SocialService { ResultResponse resultResponse = new ResultResponse(); String uid = operationReq.getUid(); //本人uid + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { @@ -5562,6 +5934,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "leave_message_success"); text += SpeechUtil.getSocialSpeech(gender, "leave_message_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501107); @@ -5640,6 +6013,7 @@ public class SocialServiceImpl implements SocialService { } //保存玩家这轮的请求信息,用于下一步操作 operationReq.setStrList(friendUidList); + operationReq.setOperationLabel(Constants.READ_MESSAGE); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "check_message"); @@ -5663,6 +6037,8 @@ public class SocialServiceImpl implements SocialService { String uid = operationReq.getUid(); Integer messageNum = operationReq.getMessageNum(); //留言序号 String address = operationReq.getAddress(); //好友的玩家地址 + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); List friendUidList = new ArrayList<>(); Map messageMap = new HashMap<>(); String messageContent = ""; @@ -5675,7 +6051,9 @@ public class SocialServiceImpl implements SocialService { //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (!StringUtils.isEmpty(lastReq)) { - friendUidList = lastReq.getStrList(); + if (Constants.READ_MESSAGE.equals(lastReq.getOperationLabel())) { + friendUidList = lastReq.getStrList(); + } } //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); @@ -5692,6 +6070,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "read_message_fail_none"); text = SpeechUtil.speechReplaceNum(text, address); text += SpeechUtil.getSocialSpeech(gender, "read_message_fail_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501208); @@ -5758,6 +6137,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "read_message_fail_none"); text = SpeechUtil.speechReplaceNum(text, address); text += SpeechUtil.getSocialSpeech(gender, "read_message_fail_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501208); @@ -5783,6 +6163,7 @@ public class SocialServiceImpl implements SocialService { operationReq.setStrList(friendUidList); operationReq.setAddress(address); operationReq.setMessageContent(messageContent); + operationReq.setOperationLabel(Constants.READ_MESSAGE); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "read_message_pre"); @@ -5942,6 +6323,8 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "查看好友数量"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //好友数量上限 int friendNumMax = Integer.parseInt(TimingAcquisition.systemConfigMap.get("friend_num_max").getValue()); List friendList = TimingAcquisition.gardenerMap.get(uid).getFriendList(); @@ -5951,6 +6334,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "all_friend_num_check_none"); text = SpeechUtil.speechReplaceNum(text, Integer.toString(friendNumMax)); text += SpeechUtil.getSocialSpeech(gender, "all_friend_num_check_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501901); @@ -5965,6 +6349,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "all_friend_num_check_none"); text = SpeechUtil.speechReplaceNum(text, Integer.toString(friendNumMax)); text += SpeechUtil.getSocialSpeech(gender, "all_friend_num_check_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501901); @@ -5979,6 +6364,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "all_friend_num_check"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(friendList.size()), Integer.toString(friendNumMax), String.valueOf(friendNumMax - friendList.size())); text += SpeechUtil.getSocialSpeech(gender, "all_friend_num_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501902); @@ -5991,6 +6377,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "all_friend_num_check_max"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(friendList.size()), Integer.toString(friendNumMax)); text += SpeechUtil.getSocialSpeech(gender, "all_friend_num_check_max"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501903); @@ -6010,6 +6397,8 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "查看好友数量"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //好友数量上限 int friendNumMax = Integer.parseInt(TimingAcquisition.systemConfigMap.get("friend_num_max").getValue()); List friendList = TimingAcquisition.gardenerMap.get(uid).getFriendList(); @@ -6019,6 +6408,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "all_friend_num_check_none"); text = SpeechUtil.speechReplaceNum(text, Integer.toString(friendNumMax)); text += SpeechUtil.getSocialSpeech(gender, "all_friend_num_check_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501901); @@ -6033,6 +6423,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "all_friend_num_check_none"); text = SpeechUtil.speechReplaceNum(text, Integer.toString(friendNumMax)); text += SpeechUtil.getSocialSpeech(gender, "all_friend_num_check_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501901); @@ -6052,6 +6443,7 @@ public class SocialServiceImpl implements SocialService { //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "online_friend_num_check_none"); text += SpeechUtil.getSocialSpeech(gender, "online_friend_num_check_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501904); @@ -6064,6 +6456,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "online_friend_num_check"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(onlineCount), String.valueOf(friendList.size() - onlineCount)); text += SpeechUtil.getSocialSpeech(gender, "online_friend_num_check"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501905); @@ -6083,6 +6476,8 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "查看好友数量"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //好友数量上限 int friendNumMax = Integer.parseInt(TimingAcquisition.systemConfigMap.get("friend_num_max").getValue()); List friendList = TimingAcquisition.gardenerMap.get(uid).getFriendList(); @@ -6092,6 +6487,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "all_friend_num_check_none"); text = SpeechUtil.speechReplaceNum(text, Integer.toString(friendNumMax)); text += SpeechUtil.getSocialSpeech(gender, "all_friend_num_check_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501901); @@ -6106,6 +6502,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "all_friend_num_check_none"); text = SpeechUtil.speechReplaceNum(text, Integer.toString(friendNumMax)); text += SpeechUtil.getSocialSpeech(gender, "all_friend_num_check_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501901); @@ -6114,16 +6511,18 @@ public class SocialServiceImpl implements SocialService { commonResponse.setData(resultVarsResponse); return commonResponse; } - //所有好友名称 + //所有好友的uid List friendUidList = friendList.stream().map(FriendDto::getUid).collect(Collectors.toList()); - StringBuilder friendNames = new StringBuilder(); + StringBuilder friendAddressText = new StringBuilder(); for (String friendUid : friendUidList) { - friendNames.append(TimingAcquisition.gardenerMap.get(friendUid).getGardenerInfo().getName()).append("、"); + friendAddressText.append(TimingAcquisition.gardenerMap.get(friendUid).getLocation()).append("、"); + } + if (friendAddressText.length() != 0) { + friendAddressText.deleteCharAt(friendAddressText.length() - 1); } - friendNames.deleteCharAt(friendNames.length() - 1); //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "friend_check"); - text = SpeechUtil.speechReplaceNum(text, String.valueOf(friendList.size()), friendNames.toString()); + text = SpeechUtil.speechReplaceNum(text, String.valueOf(friendList.size()), friendAddressText.toString()); text += SpeechUtil.getSocialSpeech(gender, "friend_check"); commonResponse.setCode(1); commonResponse.setMsg("成功"); @@ -6145,6 +6544,8 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "查看离线超过" + offlineDays + "天的好友"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //好友数量上限 int friendNumMax = Integer.parseInt(TimingAcquisition.systemConfigMap.get("friend_num_max").getValue()); List friendList = TimingAcquisition.gardenerMap.get(uid).getFriendList(); @@ -6154,6 +6555,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "all_friend_num_check_none"); text = SpeechUtil.speechReplaceNum(text, Integer.toString(friendNumMax)); text += SpeechUtil.getSocialSpeech(gender, "all_friend_num_check_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501901); @@ -6168,6 +6570,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "all_friend_num_check_none"); text = SpeechUtil.speechReplaceNum(text, Integer.toString(friendNumMax)); text += SpeechUtil.getSocialSpeech(gender, "all_friend_num_check_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501901); @@ -6193,6 +6596,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "offline_friend_num_check_none"); text = SpeechUtil.speechReplaceNum(text, offlineDays.toString()); text += SpeechUtil.getSocialSpeech(gender, "offline_friend_num_check_none"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501909); @@ -6225,6 +6629,8 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "开始返回自己花园"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //清除bot端的玩家当前位置,让其回到自己花园 resultResponse.set玩家当前位置(""); //当前玩家上一轮的请求信息 @@ -6233,6 +6639,7 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "不在拜访状态"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "back_home_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(502202); @@ -6246,6 +6653,7 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "不在拜访状态"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "back_home_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(502202); @@ -6259,6 +6667,7 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "已回到自己花园"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "back_home_success"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(502201); @@ -6280,12 +6689,28 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "查询他人花圃数量"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); if (StringUtils.isEmpty(lastReq)) { log.info(uid + "不在拜访状态,无法查看对方的花圃数量"); //获取对应话术 String text = SpeechUtil.getSocialSpeech(gender, "check_nursery_amount_side_fail"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(502102); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + if (StringUtils.isEmpty(lastReq.getAddress())) { + log.info(uid + "不在拜访状态,无法查看对方的花圃数量"); + //获取对应话术 + String text = SpeechUtil.getSocialSpeech(gender, "check_nursery_amount_side_fail"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(502102); @@ -6333,6 +6758,8 @@ public class SocialServiceImpl implements SocialService { log.info(uid + "查看对方" + addressSide + "花圃" + nurseryNum + "的宠物"); //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //没有提供对方的玩家地址 if (StringUtils.isEmpty(addressSide)) { log.info(uid + "玩家没提供对方的玩家地址"); @@ -6341,6 +6768,7 @@ public class SocialServiceImpl implements SocialService { CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "nursery_pet_side_check_fail_no_address"); text += SpeechUtil.getSocialSpeech(gender, "nursery_pet_side_check_fail_no_address"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(502201); @@ -6383,6 +6811,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "nursery_pet_side_check_fail_no_num"); text = SpeechUtil.speechReplaceNum(text, nurseryNumText); text += SpeechUtil.getSocialSpeech(gender, "nursery_pet_side_check_fail_no_num"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(502203); @@ -6402,6 +6831,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "nursery_pet_side_check_fail_wrong_num"); text = SpeechUtil.speechReplaceNum(text, nurseryNumText); text += SpeechUtil.getSocialSpeech(gender, "nursery_pet_side_check_fail_wrong_num"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(502204); @@ -6422,6 +6852,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "nursery_pet_side_check_fail_wrong_num"); text = SpeechUtil.speechReplaceNum(text, nurseryNumText); text += SpeechUtil.getSocialSpeech(gender, "nursery_pet_side_check_fail_wrong_num"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(502204); @@ -6444,6 +6875,7 @@ public class SocialServiceImpl implements SocialService { String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "nursery_pet_side_check_fail_no_pet"); text = SpeechUtil.speechReplaceNum(text, nurseryNum.toString()); text += SpeechUtil.getSocialSpeech(gender, "nursery_pet_side_check_fail_no_pet"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(502205); @@ -6514,14 +6946,14 @@ public class SocialServiceImpl implements SocialService { if (i < petFieldSides.size() && j >= petFields.size()) { result = Constants.DEFEND_SUCCESS; //开始记录挑战方回合制的战斗 - fightResultText.append("我方宠物防守成功,对方偷菜失败"); + fightResultText.append("我方宠物防守成功,对方攻打失败"); break; } //防守方的宠物全部阵亡,并且挑战方还有宠物,则挑战成功 if (i >= petFieldSides.size() && j < petFields.size()) { result = Constants.DEFEND_FAIL; //开始记录挑战方回合制的战斗 - fightResultText.append("我方宠物防守失败,对方偷菜成功"); + fightResultText.append("我方宠物防守失败,对方攻打成功"); gameOver = true; break; } @@ -6529,7 +6961,7 @@ public class SocialServiceImpl implements SocialService { if (i >= petFieldSides.size()) { result = Constants.DEFEND_SUCCESS; //开始记录挑战方回合制的战斗 - fightResultText.append("我方宠物对战平局,对方偷菜失败"); + fightResultText.append("我方宠物对战平局,对方攻打失败"); break; } //宠物属性攻击方克制防守方时攻击方倍数 @@ -6543,6 +6975,34 @@ public class SocialServiceImpl implements SocialService { PetPojo petSide = petConfigMap.get(petFieldSides.get(i)); //挑战方对应位置的宠物 PetPojo pet = petConfigMap.get(petFields.get(j)); + //--------------------防守方的技能生命值加成------------- + BigDecimal addHPProSide = TimingAcquisition.getAddPetHP(uidSide); + Integer petSideAddHp = addHPProSide.add(new BigDecimal(1)).multiply(new BigDecimal(petSide.getHp())).intValue(); + petSide.setHp(petSideAddHp); + //--------------------攻击方的技能生命值加成-------------- + BigDecimal addHPPro = TimingAcquisition.getAddPetHP(uid); + Integer petAddHp = addHPPro.add(new BigDecimal(1)).multiply(new BigDecimal(pet.getHp())).intValue(); + pet.setHp(petAddHp); + //--------------------防守方的技能攻击力加成------------- + BigDecimal addFCProSide = TimingAcquisition.getAddPetFC(uidSide); + Integer petSideAddFC = addFCProSide.add(new BigDecimal(1)).multiply(new BigDecimal(petSide.getFc())).intValue(); + petSide.setHp(petSideAddFC); + //--------------------攻击方的技能攻击力加成-------------- + BigDecimal addFCPro = TimingAcquisition.getAddPetFC(uid); + Integer petAddFc = addFCPro.add(new BigDecimal(1)).multiply(new BigDecimal(pet.getFc())).intValue(); + pet.setHp(petAddFc); + //--------------------防守方的技能防御力加成------------- + BigDecimal addDEFProSide = TimingAcquisition.getAddPetDEF(uidSide); + Integer petDEF = new BigDecimal(1).subtract(addDEFProSide).multiply(new BigDecimal(pet.getFc())).intValue(); //攻击方的攻击力减少 + pet.setFc(petDEF); + //--------------------攻击方的技能防御力加成-------------- + BigDecimal addDEFPro = TimingAcquisition.getAddPetDEF(uid); + Integer petSideDEF = new BigDecimal(1).subtract(addDEFPro).multiply(new BigDecimal(petSide.getFc())).intValue(); //防守方的攻击力减少 + petSide.setFc(petSideDEF); + //--------------------防守方的技能回血加成------------- + BigDecimal addLifeProSide = TimingAcquisition.getAddPetLife(uidSide); + //--------------------攻击方的技能回血加成-------------- + BigDecimal addLifePro = TimingAcquisition.getAddPetLife(uid); //双方宠物开始战斗 //攻击方宠物属性 String[] petAttributes = pet.getAttributeIds().split("\\|"); @@ -6597,6 +7057,9 @@ public class SocialServiceImpl implements SocialService { } //防守方的宠物生命值减少 petSide.setHp((int) (petSide.getHp() - pet.getFc() * t2 * attackFcTimes)); + //防守方胜利后回血自身生命上限的addLifeProSide + Integer petSideAddLife = addLifeProSide.add(new BigDecimal(1)).multiply(new BigDecimal(petConfigMap.get(petSide.getId()).getHp())).intValue(); + petSide.setHp(petSideAddLife); } else if (t1 < t2) { //挑战方能承受更多攻击次数,即能赢 i++; //防守方战败,换下一位宠物战斗 win = 1; @@ -6606,6 +7069,9 @@ public class SocialServiceImpl implements SocialService { } //挑战方的宠物生命值减少 petSide.setHp((int) (pet.getHp() - petSide.getFc() * t1 * defendFcTimes)); + //挑战方胜利后回血自身生命上限的addLifePro + Integer petAddLife = addLifePro.add(new BigDecimal(1)).multiply(new BigDecimal(petConfigMap.get(pet.getId()).getHp())).intValue(); + petSide.setHp(petAddLife); } else { //双方宠物均阵亡,都换下一位 i++; j++; @@ -6655,14 +7121,14 @@ public class SocialServiceImpl implements SocialService { //物品配置信息 Map itemConfigMap = TimingAcquisition.itemConfigMap; //-------------------获取uidSide的所有偷菜简报------------------- - String stealReports = PersistenceUtil.getReportFromFile(uidSide, "偷菜简报"); + String stealReports = PersistenceUtil.getReportFromFile(uidSide, "防守简报"); List stealReportDtoList = JSON.parseObject(stealReports, new TypeReference>(){}); //防守方的偷菜简报为空,添加后退出 if (StringUtils.isEmpty(stealReportDtoList)) { //防守方生成偷菜简报 StealReportDto stealReport = new StealReportDto(); stealReport.setRead(Constants.READ_NO); - stealReport.setName("偷菜简报1"); + stealReport.setName("防守简报1"); stealReport.setStrangeAddress(gardener.getLocation()); stealReport.setStealTime(nowTime); stealReport.setNurseryNum(nurseryNum); @@ -6699,7 +7165,7 @@ public class SocialServiceImpl implements SocialService { PersistenceUtil.checkStealReportFromFile(uidSide); //-------------------将偷菜简报保存到json文件中---------------------------- String stealReportStr = JSON.toJSONString(stealReport); - PersistenceUtil.saveReportToFile(uidSide, "偷菜简报1", stealReportStr); + PersistenceUtil.saveReportToFile(uidSide, "防守简报1", stealReportStr); //更新偷菜简报编号 gardenerSide.setStealReportNum(1); //挑战方记录和对方的战斗情况 @@ -6707,7 +7173,7 @@ public class SocialServiceImpl implements SocialService { stranger.setAddress(gardenerSide.getLocation()); stranger.setName(gardenerSide.getGardenerInfo().getName()); stranger.setStealColdStartTime(DateUtil.getCurrentTime()); - stranger.setStealReportName("偷菜简报1"); + stranger.setStealReportName("防守简报1"); if (StringUtils.isEmpty(gardener.getStrangerMap())) { Map strangerMap = new HashMap<>(); strangerMap.put(stranger.getAddress(), stranger); @@ -6731,7 +7197,7 @@ public class SocialServiceImpl implements SocialService { gardenerSide.setStealReportNum(number); //防守方生成偷菜简报 StealReportDto stealReport = new StealReportDto(); - stealReport.setName("偷菜简报" + number); + stealReport.setName("防守简报" + number); stealReport.setStrangeAddress(gardener.getLocation()); stealReport.setStealTime(nowTime); stealReport.setNurseryNum(nurseryNum); @@ -6766,14 +7232,14 @@ public class SocialServiceImpl implements SocialService { } //------------------------------将偷菜简报保存到json文件中------------------------- String stealReportStr = JSON.toJSONString(stealReport); - PersistenceUtil.saveReportToFile(uidSide, "偷菜简报" + number, stealReportStr); + PersistenceUtil.saveReportToFile(uidSide, "防守简报" + number, stealReportStr); // gardenerSide.getStealReportList().add(stealReport); //挑战方记录和对方的战斗情况 StrangerDto stranger = new StrangerDto(); stranger.setAddress(gardenerSide.getLocation()); stranger.setName(gardenerSide.getGardenerInfo().getName()); stranger.setStealColdStartTime(DateUtil.getCurrentTime()); - stranger.setStealReportName("偷菜简报" + number); + stranger.setStealReportName("防守简报" + number); if (StringUtils.isEmpty(gardener.getStrangerMap())) { Map strangerMap = new HashMap<>(); strangerMap.put(stranger.getAddress(), stranger); @@ -6907,7 +7373,7 @@ public class SocialServiceImpl implements SocialService { BackPackDto backPackSide = TimingAcquisition.gardenerMap.get(uidSide).getBackPack(); //好友得到的果实放入好友掉落物品中 dropItemsSide.add(fruitSide); - //好友背包的物品袋新增掉落物品 + //------------------好友背包的物品袋新增掉落物品------------------- for (ItemDto item : dropItemsSide) { //物品对应种类 Integer itemType = itemConfigMap.get(item.getItemId()).getItemTypeId(); @@ -6955,8 +7421,9 @@ public class SocialServiceImpl implements SocialService { //获取帮助方的背包 BackPackDto backPack = TimingAcquisition.gardenerMap.get(uid).getBackPack(); result.append(fruit.getItemNum()).append("个").append(itemConfigMap.get(fruit.getItemId()).getName()).append("、"); //有问题 + result.deleteCharAt(result.length() - 1); if (dropItems.size() != 0) { - result.append("额外收取了"); + result.append(",额外掉落了"); for (ItemDto item : dropItems) { result.append(item.getItemNum()).append("个").append(itemConfigMap.get(item.getItemId()).getName()).append("、"); } diff --git a/src/main/java/com/qiwuai/garden/service/taskService/impl/TaskServiceImpl.java b/src/main/java/com/qiwuai/garden/service/taskService/impl/TaskServiceImpl.java index e583ece..f675d32 100644 --- a/src/main/java/com/qiwuai/garden/service/taskService/impl/TaskServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/taskService/impl/TaskServiceImpl.java @@ -11,6 +11,7 @@ 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.CallNamePojo; import com.qiwuai.garden.pojo.TaskPojo; import com.qiwuai.garden.pojo.TaskTypePojo; import com.qiwuai.garden.service.taskService.TaskService; @@ -40,6 +41,8 @@ public class TaskServiceImpl implements TaskService { Integer taskTypeId = operationReq.getTaskType(); //任务类型id //园丁性别 String gender = TimingAcquisition.getGardenerGender(uid); + //玩家称呼 + CallNamePojo callName = TimingAcquisition.getCallNameByUid(uid); //玩家未提供任务类型 if (StringUtils.isEmpty(taskTypeId)) { StringBuilder typeText = new StringBuilder(); @@ -52,6 +55,7 @@ public class TaskServiceImpl implements TaskService { String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, "check_task_fail_no_name"); text = SpeechUtil.speechReplaceNum(text, typeText.toString()); text += SpeechUtil.getTaskSpeech(gender, "check_task_fail_no_name"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(600105); @@ -96,6 +100,7 @@ public class TaskServiceImpl implements TaskService { String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, "check_update_task_status_unfinished"); text = SpeechUtil.speechReplaceNum(text, String.valueOf(level + 1), taskText.toString()); text += SpeechUtil.getTaskSpeech(gender, "check_update_task_status_unfinished"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(600101); @@ -107,6 +112,7 @@ public class TaskServiceImpl implements TaskService { //1.2 升级任务已完成 String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, "check_update_task_status_finished"); text += SpeechUtil.getTaskSpeech(gender, "check_update_task_status_finished"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(600102); @@ -172,6 +178,7 @@ public class TaskServiceImpl implements TaskService { text = SpeechUtil.speechReplaceNum(text, taskName.toString(), taskText.toString()); } text += SpeechUtil.getTaskSpeech(gender, "check_update_task_status_unfinished"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(600103); @@ -183,6 +190,7 @@ public class TaskServiceImpl implements TaskService { //2.2 所有日常任务已完成 String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, "check_daily_task_status_finished"); text += SpeechUtil.getTaskSpeech(gender, "check_daily_task_status_finished"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(600104); diff --git a/src/main/resources/application-uat.yml b/src/main/resources/application-uat.yml index b2d47a2..971f811 100644 --- a/src/main/resources/application-uat.yml +++ b/src/main/resources/application-uat.yml @@ -66,4 +66,4 @@ reportFilePath: /home/secretGarden/report/ #动态词组更新秘钥 appSecret: nnPGsrbMriXdrRNISQeb #动态词组更新链接 -updatePhraseUrl: http://hw-gz25.heyqiwu.cn:8082/out/phrase \ No newline at end of file +updatePhraseUrl: http://hw-gz24.heyqiwu.cn:8082/out/phrase \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index caf4dfc..f2b90d5 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,3 +1,3 @@ spring: profiles: - active: dev \ No newline at end of file + active: uat \ No newline at end of file diff --git a/src/main/resources/com/qiwuai/garden/dao/ItemMapper.xml b/src/main/resources/com/qiwuai/garden/dao/ItemMapper.xml index f931b34..a262018 100644 --- a/src/main/resources/com/qiwuai/garden/dao/ItemMapper.xml +++ b/src/main/resources/com/qiwuai/garden/dao/ItemMapper.xml @@ -6,7 +6,7 @@ diff --git a/src/main/resources/com/qiwuai/garden/dao/PetMapper.xml b/src/main/resources/com/qiwuai/garden/dao/PetMapper.xml index ba9cd25..9fd1d53 100644 --- a/src/main/resources/com/qiwuai/garden/dao/PetMapper.xml +++ b/src/main/resources/com/qiwuai/garden/dao/PetMapper.xml @@ -6,7 +6,7 @@