diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..92880fa --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 2bc6cd5..f4f3cca 100644 --- a/pom.xml +++ b/pom.xml @@ -122,6 +122,16 @@ poi-ooxml 4.1.2 + + com.opencsv + opencsv + 4.6 + + + org.springframework.boot + spring-boot-starter-data-redis + 2.6.5 + diff --git a/src/main/java/com/qiwu/inference/InferenceApplication.java b/src/main/java/com/qiwu/inference/InferenceApplication.java index 9b015a7..60581d8 100644 --- a/src/main/java/com/qiwu/inference/InferenceApplication.java +++ b/src/main/java/com/qiwu/inference/InferenceApplication.java @@ -1,7 +1,6 @@ package com.qiwu.inference; import com.qiwu.inference.common.cache.ExpireThread; -import com.qiwu.inference.common.cache.TaskTipsThread; import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/src/main/java/com/qiwu/inference/common/Constants.java b/src/main/java/com/qiwu/inference/common/Constants.java index 6b43a61..680901a 100644 --- a/src/main/java/com/qiwu/inference/common/Constants.java +++ b/src/main/java/com/qiwu/inference/common/Constants.java @@ -103,8 +103,34 @@ public class Constants { */ public static final String OPERATE_ASK = "询问操作"; + + + /** + * 查看地址操作标签 + */ + public static final int CHECK_LOCATION = 3004; + /** * 线索-关系类型-5 */ public static final Integer RELATION_TYPE = 5; + + + /** + * 物品类型-伙伴 + */ + public static final Integer ITEM_PARTNER = 1; + /** + * 物品类型-道具 + */ + public static final Integer ITEM_PROPS = 2; + /** + * 物品类型-普通物品 + */ + public static final Integer ITEM_NOR = 3; + + /** + * 结束文本标识 + */ + public static final String END_TEXT = "►打开:当前作品:已完成当前推理作品哈喽◄"; } diff --git a/src/main/java/com/qiwu/inference/common/InitSysServlet.java b/src/main/java/com/qiwu/inference/common/InitSysServlet.java index 6d1dc71..c0de016 100644 --- a/src/main/java/com/qiwu/inference/common/InitSysServlet.java +++ b/src/main/java/com/qiwu/inference/common/InitSysServlet.java @@ -2,12 +2,15 @@ package com.qiwu.inference.common; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; +import com.qiwu.inference.common.utils.CacheUtil; +import com.qiwu.inference.common.utils.MD5Util; import com.qiwu.inference.common.utils.PersistenceUtil; import com.qiwu.inference.common.utils.SpeechUtil; import com.qiwu.inference.dao.*; import com.qiwu.inference.dto.BarrierTaskKeyDto; import com.qiwu.inference.dto.Person; import com.qiwu.inference.dto.Player; +import com.qiwu.inference.dto.ReputationDto; import com.qiwu.inference.pojo.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -15,22 +18,26 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; import java.io.File; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.PriorityBlockingQueue; @Component public class InitSysServlet implements InitializingBean { Logger log = LoggerFactory.getLogger(InitSysServlet.class); + @Value("${offlineTime}") + private String offlineTime; @Value("${userFilePath}") private String userFilePath; @Value("${configFilePath}") private String configFilePath; - @Value("${speechFilePath}") - private String speechFilePath; + @Value("${dataFilePath}") + private String dataFilePath; @Autowired private SystemConfigMapper systemConfigMapper; @@ -52,140 +59,69 @@ public class InitSysServlet implements InitializingBean { public void afterPropertiesSet() throws Exception { //--------------------------缓存关卡数据--------------------- log.info("开始缓存关卡数据"); - String gateInfo = PersistenceUtil.getConfigFromFile(configFilePath, "results.json"); - Map> gateInfoMap = JSON.parseObject(gateInfo, new TypeReference>>(){}); - TimingAcquisition.gateInfoMap.putAll(gateInfoMap); + PersistenceUtil.getDataFromFile(configFilePath); log.info("关卡数据缓存完成"); + Map> gateInfoMap = TimingAcquisition.gateInfoMap; + //--------------------------缓存关卡NPC数据--------------------- + log.info("开始缓存关卡NPC数据"); + Map> gatePersonMap = new ConcurrentHashMap<>(); for (Map.Entry> entry : gateInfoMap.entrySet()) { - String gateNo = entry.getKey(); - //-------------------------缓存关卡攻略数据--------------------- - log.info("开始缓存关卡攻略数据"); - String barrierTaskKey = PersistenceUtil.getConfigFromFile(configFilePath, "results_final_task.json"); - List barrierTaskKeyList = JSON.parseObject(barrierTaskKey, new TypeReference>(){}); - Map> barrierTaskKeyMap = new ConcurrentHashMap<>(); - barrierTaskKeyMap.put(gateNo, barrierTaskKeyList); - TimingAcquisition.barrierTaskKeyMap.putAll(barrierTaskKeyMap); - log.info("关卡攻略数据缓存完成"); + List personList = entry.getValue(); + Map personMap = new ConcurrentHashMap<>(); + for (Person person : personList) { + personMap.put(person.getId(), person); + } + gatePersonMap.put(entry.getKey(), personMap); } + TimingAcquisition.gatePersonMap.putAll(gatePersonMap); + log.info("关卡NPC数据缓存完成"); + + //--------------------加载配置目录下的所有话术---------------- + PersistenceUtil.getSpeechFromFile(configFilePath); + //-----------------缓存系列的配置信息------------------ + PersistenceUtil.getConfigFromFile(configFilePath); //--------------------------加载玩家数据---------------------- log.info("开始加载玩家数据"); //从yml配置文件中取出存放玩家数据的地址 File file = new File(userFilePath); - File[] files = file.listFiles(); - if (files == null) { - log.info("路径" + userFilePath+ "下没有文件"); - return; - } - Map playerMap = new ConcurrentHashMap<>(); - for (File f : files) { - if (f.isFile()) { - String s = PersistenceUtil.getDataFromFile(String.valueOf(f)); - //JSON转map对象 - Player player = JSON.parseObject(s, new TypeReference(){}); - String fileName = f.getName().replace(".json", ""); - playerMap.put(fileName, player); - TimingAcquisition.playerMap.putAll(playerMap); + //一级目录 + File[] file1List = file.listFiles(); + if (!StringUtils.isEmpty(file1List)) { + for (File file1 : file1List) { + //二级目录 + File[] file2List = file1.listFiles(); + if (!StringUtils.isEmpty(file2List)) { + for (File file2 : file2List) { + //三级目录 + File[] file3List = file2.listFiles(); + if (!StringUtils.isEmpty(file3List)) { + for (File file3 : file3List) { + //四级目录 + File[] file4List = file3.listFiles(); + if (!StringUtils.isEmpty(file4List)) { + for (File file4 : file4List) { + //用户uid目录 + String uid = file4.getName(); + //保存所有玩家的uid + TimingAcquisition.uidList.add(uid); + //加载系列声望 +// PersistenceUtil.loadSeriesReputation(uid, file4.getAbsolutePath()); + } + } + } + } + } + } } } log.info("玩家数据缓存完成"); - //--------------------加载话术----------------- - TimingAcquisition.speechLoading(speechFilePath); - //--------------------加载闲聊话术的excel表---------------- - log.info("加载闲聊话术"); - Map> chatSpeechMap = SpeechUtil.getChatSpeechModel(speechFilePath); - TimingAcquisition.chatSpeechMap.putAll(chatSpeechMap); - log.info("闲聊话术加载完成"); - - //--------------------加载线索成功话术的excel表---------------- - log.info("加载线索成功话术"); - Map> clueSpeechMap = SpeechUtil.getClueSpeechModel(speechFilePath); - TimingAcquisition.successClueSpeechMap.putAll(clueSpeechMap); - log.info("线索成功话术加载完成"); - - //--------------------加载任务成功话术的excel表---------------- - log.info("加载任务成功话术"); - Map> taskSpeechMap = SpeechUtil.getTaskSpeechModel(speechFilePath); - TimingAcquisition.successTaskSpeechMap.putAll(taskSpeechMap); - log.info("任务成功话术加载完成"); - - //--------------------加载任务成功话术的excel表---------------- - log.info("加载任务提示话术"); - Map> tipSpeechMap = SpeechUtil.getTipSpeechModel(speechFilePath); - TimingAcquisition.tipSpeechMap.putAll(tipSpeechMap); - log.info("任务提示话术加载完成"); - - //--------------------加载人物见面话术的excel表---------------- - log.info("加载人物见面话术"); - Map> personSpeechMap = SpeechUtil.getPersonSpeechModel(speechFilePath); - TimingAcquisition.personSpeechMap.putAll(personSpeechMap); - log.info("人物见面话术加载完成"); - - - //-----------------缓存场所信息------------------ - Map locationMap = new ConcurrentHashMap<>(); - List locationList = locationMapper.findAll(); - for (Location location : locationList) { - locationMap.put(location.getId().toString(), location); - } - TimingAcquisition.locationMap.putAll(locationMap); - log.info("场所配置信息缓存完成"); - - //-----------------缓存线索信息------------------ - Map clueMap = new ConcurrentHashMap<>(); - List clueList = clueMapper.findAll(); - for (Clue clue : clueList) { - clueMap.put(clue.getId(), clue); - } - TimingAcquisition.clueMap.putAll(clueMap); - log.info("线索配置信息缓存完成"); - - //-----------------缓存线索类型信息------------------ - Map clueTypeMap = new ConcurrentHashMap<>(); - List clueTypeList = clueMapper.getTypeInfo(); - for (ClueType clueType : clueTypeList) { - clueTypeMap.put(clueType.getId(), clueType.getName()); - } - TimingAcquisition.clueTypeMap.putAll(clueTypeMap); - log.info("线索类型配置信息缓存完成"); - - //-----------------缓存需求任务配置信息------------------ - Map demandTaskMap = new ConcurrentHashMap<>(); - List demandTaskList = demandTaskMapper.findAll(); - for (DemandTask demandTask : demandTaskList) { - demandTaskMap.put(demandTask.getId(), demandTask); - } - TimingAcquisition.demandTaskMap.putAll(demandTaskMap); - log.info("需求任务配置信息缓存完成"); - - //-----------------缓存性格信息------------------ - Map dispositionMap = new ConcurrentHashMap<>(); - List dispositionList = dispositionMapper.findAll(); - for (Disposition disposition : dispositionList) { - dispositionMap.put(disposition.getId(), disposition); - } - TimingAcquisition.dispositionMap.putAll(dispositionMap); - log.info("性格配置信息缓存完成"); - - //-----------------缓存系统配置信息------------------ - Map systemConfigMap = new ConcurrentHashMap<>(); - List systemConfigList = systemConfigMapper.findAll(); - for (SystemConfigPojo systemConfig : systemConfigList) { - systemConfigMap.put(systemConfig.getName(), systemConfig); - } - TimingAcquisition.systemConfigMap.putAll(systemConfigMap); - log.info("系统配置信息缓存完成"); - - //-----------------缓存结局目标配置信息------------------ - Map endGoalMap = new ConcurrentHashMap<>(); - List endGoalList = endGoalMapper.findAll(); - for (EndGoal endGoal : endGoalList) { - endGoalMap.put(endGoal.getId(), endGoal); - } - TimingAcquisition.endGoalMap.putAll(endGoalMap); - log.info("结局目标配置信息缓存完成"); + //--------------------------加载系列玩家数据---------------------- +// log.info("开始加载玩家系列数据"); +// PersistenceUtil.loadSeriesPlayer(dataFilePath); +// log.info("玩家系列数据加载完成"); } } diff --git a/src/main/java/com/qiwu/inference/common/TimingAcquisition.java b/src/main/java/com/qiwu/inference/common/TimingAcquisition.java index 8e15c08..24b3a01 100644 --- a/src/main/java/com/qiwu/inference/common/TimingAcquisition.java +++ b/src/main/java/com/qiwu/inference/common/TimingAcquisition.java @@ -1,9 +1,7 @@ package com.qiwu.inference.common; import com.qiwu.inference.common.utils.PersistenceUtil; -import com.qiwu.inference.dto.BarrierTaskKeyDto; -import com.qiwu.inference.dto.Person; -import com.qiwu.inference.dto.Player; +import com.qiwu.inference.dto.*; import com.qiwu.inference.pojo.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -12,16 +10,21 @@ import org.springframework.util.StringUtils; import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.PriorityBlockingQueue; @Component public class TimingAcquisition { static Logger log = LoggerFactory.getLogger(TimingAcquisition.class); /** - * 关卡信息,Map> + * 关卡信息,Map<关卡编号, List> */ public volatile static Map> gateInfoMap = new ConcurrentHashMap<>(); /** + * 关卡信息,Map<关卡编号, Map> + */ + public volatile static Map> gatePersonMap = new ConcurrentHashMap<>(); + /** * 关卡攻略信息,Map<关卡编号, List<攻略任务>> */ public volatile static Map> barrierTaskKeyMap = new ConcurrentHashMap<>(); @@ -33,78 +36,209 @@ public class TimingAcquisition { * 玩家信息,Map */ public volatile static Map playerMap = new ConcurrentHashMap<>(); + /** + * 所有在线玩家的uid数组。用于是否加载玩家数据的判断 + */ + public volatile static List uidList = new ArrayList<>(); + /** + * 系列名和关卡编号的对应关系 + */ + public volatile static Map> seriesGateNosMap = new ConcurrentHashMap<>(); + /** + * 关卡名称和关卡编号对应关系 + */ + public volatile static Map gateNameToNoMap = new ConcurrentHashMap<>(); + /** + * 玩家在系列里的用户数据,Map<系列, Map> + */ + public volatile static Map> seriesPlayerMap = new ConcurrentHashMap<>(); + /** + * 玩家在关卡里的总声望值,Map<关卡编号, Map> + */ + public volatile static Map> gateNoUidReputationMap = new ConcurrentHashMap<>(); + /** + * 系列里总声望值降序排列,Map<系列, 声望> + */ + public volatile static Map> seriesReputationQueueMap = new ConcurrentHashMap<>(); + /** + * 系列里总声望值降序排列,Map<关卡编号, 声望> + */ + public volatile static Map> gateNoReputationQueueMap = new ConcurrentHashMap<>(); + + + /** + * 场所配置信息,Map<系列名称, Map> + */ + public volatile static Map> seriesLocationMap = new ConcurrentHashMap<>(); + /** + * 线索配置信息,Map<系列名称, Map> + */ + public volatile static Map> seriesClueMap = new ConcurrentHashMap<>(); + /** + * 线索类型配置信息,Map<系列名称, Map> + */ + public volatile static Map> seriesClueTypeMap = new ConcurrentHashMap<>(); + /** + * 性格配置信息,Map<系列名称, Map> + */ + public volatile static Map> seriesDispositionMap = new ConcurrentHashMap<>(); + /** + * 系统配置信息,Map<系列名称, Map> + */ + public volatile static Map> seriesSystemConfigMap = new ConcurrentHashMap<>(); + /** + * 任务条件配置信息,Map<系列名称, Map> + */ + public volatile static Map> seriesTaskConditionMap = new ConcurrentHashMap<>(); + /** + * 伙伴物品配置信息,Map<系列名称, Map> + */ + public volatile static Map> seriesPartnerItemMap = new ConcurrentHashMap<>(); + /** + * 背包数量配置信息,Map<系列名称, Map<物品类型, Map<序号, BackpackNum>>> + */ + public volatile static Map>> seriesBackpackNumMap = new ConcurrentHashMap<>(); + /** + * 伙伴NPC信息,Map<系列名称, Map> + */ + public volatile static Map> seriesPersonMap = new ConcurrentHashMap<>(); + + /** + * 所有系列的询问模块话术,Map<系列名称, Map<意图, List<话术配置>>> + */ + public volatile static Map>>> seriesAskSpeechMap = new ConcurrentHashMap<>(); + /** + * 关卡的询问模块话术,Map<关卡编号, Map<意图, List<话术配置>>> + */ + public volatile static Map>>> gateNoAskSpeechMap = new ConcurrentHashMap<>(); /** - * 场所配置信息 + * 所有系列的任务模块话术,Map<系列名称, Map<意图, List<话术配置>>> */ - public volatile static Map locationMap = new ConcurrentHashMap<>(); + public volatile static Map>>> seriesTaskSpeechMap = new ConcurrentHashMap<>(); /** - * 线索配置信息 + * 关卡的询问模块话术,Map<关卡编号, Map<意图, List<话术配置>>> */ - public volatile static Map clueMap = new ConcurrentHashMap<>(); + public volatile static Map>>> gateNoTaskSpeechMap = new ConcurrentHashMap<>(); /** - * 线索类型配置信息 + * 所有系列的查看模块话术,Map<系列名称, Map<意图, List<话术配置>>> */ - public volatile static Map clueTypeMap = new ConcurrentHashMap<>(); + public volatile static Map>>> seriesCheckSpeechMap = new ConcurrentHashMap<>(); /** - * 需求任务配置信息 + * 关卡的查看模块话术,Map<关卡编号, Map<意图, List<话术配置>>> */ - public volatile static Map demandTaskMap = new ConcurrentHashMap<>(); + public volatile static Map>>> gateNoCheckSpeechMap = new ConcurrentHashMap<>(); /** - * 性格配置信息 + * 所有系列的查看模块话术,Map<系列名称, Map<意图, List<话术配置>>> */ - public volatile static Map dispositionMap = new ConcurrentHashMap<>(); + public volatile static Map>>> seriesBarrierSpeechMap = new ConcurrentHashMap<>(); /** - * 系统配置信息 + * 关卡的查看模块话术,Map<关卡编号, Map<意图, List<话术配置>>> */ - public volatile static Map systemConfigMap = new ConcurrentHashMap<>(); + public volatile static Map>>> gateNoBarrierSpeechMap = new ConcurrentHashMap<>(); /** - * 结局目标配置信息 + * 所有系列的查看模块话术,Map<系列名称, Map<意图, List<话术配置>>> */ - public volatile static Map endGoalMap = new ConcurrentHashMap<>(); + public volatile static Map>>> seriesPartnerItemSpeechMap = new ConcurrentHashMap<>(); + /** + * 关卡的查看模块话术,Map<关卡编号, Map<意图, List<话术配置>>> + */ + public volatile static Map>>> gateNoPartnerItemSpeechMap = new ConcurrentHashMap<>(); + + /** + * 所有系列的闲聊模块话术,Map<系列名称, Map<意图, List<话术配置>>> + */ + public volatile static Map>> seriesChatSpeechMap = new ConcurrentHashMap<>(); + /** + * 关卡的闲聊模块话术,Map<关卡编号, Map<意图, List<话术配置>>> + */ + public volatile static Map>> gateNoChatSpeechMap = new ConcurrentHashMap<>(); + /** + * 所有系列的线索成功话术,Map<系列名称, Map<意图, List<话术配置>>> + */ + public volatile static Map>> seriesSuccessClueSpeechMap = new ConcurrentHashMap<>(); + /** + * 关卡的线索成功话术,Map<关卡编号, Map<意图, List<话术配置>>> + */ + public volatile static Map>> gateNoSuccessClueSpeechMap = new ConcurrentHashMap<>(); + /** + * 所有系列的任务成功话术,Map<系列名称, Map<意图, List<话术配置>>> + */ + public volatile static Map>> seriesSuccessTaskSpeechMap = new ConcurrentHashMap<>(); /** - * 询问模块话术 + * 关卡的任务成功话术,Map<关卡编号, Map<意图, List<话术配置>>> */ - public volatile static Map>> askSpeechMap = new ConcurrentHashMap<>(); + public volatile static Map>> gateNoSuccessTaskSpeechMap = new ConcurrentHashMap<>(); /** - * 任务模块话术 + * 所有系列的任务提示话术,Map<系列名称, Map<意图, List<话术配置>>> */ - public volatile static Map>> taskSpeechMap = new ConcurrentHashMap<>(); + public volatile static Map>> seriesTipSpeechMap = new ConcurrentHashMap<>(); /** - * 查看模块话术 + * 关卡的任务提示话术,Map<关卡编号, Map<意图, List<话术配置>>> */ - public volatile static Map>> checkSpeechMap = new ConcurrentHashMap<>(); + public volatile static Map>> gateNoTipSpeechMap = new ConcurrentHashMap<>(); /** - * 查看模块话术 + * 所有系列的人物见面话术,Map<系列名称, Map<意图, List<话术配置>>> */ - public volatile static Map>> barrierSpeechMap = new ConcurrentHashMap<>(); + public volatile static Map>> seriesPersonSpeechMap = new ConcurrentHashMap<>(); /** - * 闲聊模块话术,Map<意图, List<话术配置>> + * 关卡的人物见面话术,Map<关卡编号, Map<意图, List<话术配置>>> */ - public volatile static Map> chatSpeechMap = new ConcurrentHashMap<>(); + public volatile static Map>> gateNoPersonSpeechMap = new ConcurrentHashMap<>(); /** - * 线索成功话术,Map<线索id, List<话术配置>> + * 所有系列的操作提示话术,Map<系列名称, Map<意图, 话术配置>> */ - public volatile static Map> successClueSpeechMap = new ConcurrentHashMap<>(); + public volatile static Map> seriesOperateSpeechMap = new ConcurrentHashMap<>(); /** - * 任务成功话术,Map<任务id, List<话术配置>> + * 关卡的操作提示话术,Map<关卡编号, Map<意图, 话术配置>> */ - public volatile static Map> successTaskSpeechMap = new ConcurrentHashMap<>(); + public volatile static Map> gateNoOperateSpeechMap = new ConcurrentHashMap<>(); /** - * 任务提示话术,Map<任务id, List<话术配置>> + * 所有系列的操作提示话术,Map<系列名称, Map<意图, 话术配置>> */ - public volatile static Map> tipSpeechMap = new ConcurrentHashMap<>(); + public volatile static Map> seriesTaskExceptionSpeechMap = new ConcurrentHashMap<>(); /** - * 人物见面话术,Map<人物名称, List<话术配置>> + * 关卡的任务异常话术,Map<关卡编号, Map<意图, List<话术配置>>> */ - public volatile static Map> personSpeechMap = new ConcurrentHashMap<>(); + public volatile static Map> gateNoTaskExceptionSpeechMap = new ConcurrentHashMap<>(); + /** + * 线索前因话术,Map<人物名称, List<话术配置>> + */ + public volatile static Map> preReasonSpeechMap = new ConcurrentHashMap<>(); + + /** + * 通过yaml文件加载所有话术到系列中 + */ + public static void speechLoading(String seriesName, String speechFilePath) { + log.info("---------开始加载话术到系列中---------"); + Map>> askSpeech = new HashMap<>(); + Map>> taskSpeech = new HashMap<>(); + Map>> checkSpeech = new HashMap<>(); + Map>> barrierSpeech = new HashMap<>(); + Map>> partnerItemSpeech = new HashMap<>(); + try { + askSpeech = PersistenceUtil.loadSpeechToMap(speechFilePath,"ask.yaml"); + taskSpeech = PersistenceUtil.loadSpeechToMap(speechFilePath,"task.yaml"); + checkSpeech = PersistenceUtil.loadSpeechToMap(speechFilePath,"check.yaml"); + barrierSpeech = PersistenceUtil.loadSpeechToMap(speechFilePath,"barrier.yaml"); + partnerItemSpeech = PersistenceUtil.loadSpeechToMap(speechFilePath,"partnerItem.yaml"); + } catch (Exception e) { + e.printStackTrace(); + } + seriesAskSpeechMap.put(seriesName, askSpeech); + seriesTaskSpeechMap.put(seriesName, taskSpeech); + seriesCheckSpeechMap.put(seriesName, checkSpeech); + seriesBarrierSpeechMap.put(seriesName, barrierSpeech); + seriesPartnerItemSpeechMap.put(seriesName, partnerItemSpeech); + log.info("---------加载话术到系列的操作完成---------"); + } /** - * 通过yaml文件加载所有话术到缓存中 + * 通过yaml文件加载所有话术到关卡中 */ - public static void speechLoading(String speechFilePath) { - log.info("---------开始加载话术到缓存中---------"); + public static void speechLoadingToGate(String gateNo, String speechFilePath) { + log.info("---------开始加载话术到关卡中---------"); Map>> askSpeech = new HashMap<>(); Map>> taskSpeech = new HashMap<>(); Map>> checkSpeech = new HashMap<>(); @@ -117,19 +251,20 @@ public class TimingAcquisition { } catch (Exception e) { e.printStackTrace(); } - //JSON转map对象 - askSpeechMap.putAll(askSpeech); - taskSpeechMap.putAll(taskSpeech); - checkSpeechMap.putAll(checkSpeech); - barrierSpeechMap.putAll(barrierSpeech); + gateNoAskSpeechMap.put(gateNo, askSpeech); + gateNoTaskSpeechMap.put(gateNo, taskSpeech); + gateNoCheckSpeechMap.put(gateNo, checkSpeech); + gateNoBarrierSpeechMap.put(gateNo, barrierSpeech); - log.info("---------加载话术到缓存的操作完成---------"); + log.info("---------加载话术到关卡的操作完成---------"); } /** * 通过线索类型获取对应id */ - public static Integer getClueTypeIdByName(String name) { + public static Integer getClueTypeIdByName(String uid, String name) { + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); //系列名称 + Map clueTypeMap = seriesClueTypeMap.get(seriesName); for (Map.Entry entry : clueTypeMap.entrySet()) { if (name.equals(entry.getValue())) { return entry.getKey(); @@ -141,7 +276,9 @@ public class TimingAcquisition { /** * 通过场所名称获取对应id */ - public static String getLocationIdByName(String name) { + public static String getLocationIdByName(String uid, String name) { + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); //系列名称 + Map locationMap = seriesLocationMap.get(seriesName); for (Map.Entry entry : locationMap.entrySet()) { if (name.equals(entry.getValue().getName())) { return entry.getKey(); diff --git a/src/main/java/com/qiwu/inference/common/cache/ExpireThread.java b/src/main/java/com/qiwu/inference/common/cache/ExpireThread.java index f1a30d3..4d4d77d 100644 --- a/src/main/java/com/qiwu/inference/common/cache/ExpireThread.java +++ b/src/main/java/com/qiwu/inference/common/cache/ExpireThread.java @@ -3,15 +3,20 @@ package com.qiwu.inference.common.cache; import com.alibaba.fastjson.JSON; import com.qiwu.inference.common.Constants; import com.qiwu.inference.common.TimingAcquisition; -import com.qiwu.inference.common.utils.DateUtil; -import com.qiwu.inference.common.utils.PersistenceUtil; +import com.qiwu.inference.common.utils.*; import com.qiwu.inference.dto.Player; +import com.qiwu.inference.dto.response.CallResponse; +import com.qiwu.inference.factory.RemoteCallFactory; +import lombok.SneakyThrows; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; +import java.io.IOException; import java.util.concurrent.TimeUnit; /** @@ -20,8 +25,22 @@ import java.util.concurrent.TimeUnit; @EnableAsync @Component public class ExpireThread implements Runnable{ + Logger log = LoggerFactory.getLogger(ExpireThread.class); + //用户数据路径 + public static String userFilePath; @Value("${userFilePath}") - private String userFilePath; + public void setUserFilePath(String userFilePath) { + ExpireThread.userFilePath = userFilePath; + } + //redis的key过期时间 + public static String redisExpireTime; + @Value("${redisExpireTime}") + public void setRedisExpireTime(String redisExpireTime) { + ExpireThread.redisExpireTime = redisExpireTime; + } + + @Autowired + private RedisUtil redisUtil; @Override public void run() { @@ -38,26 +57,47 @@ public class ExpireThread implements Runnable{ /** * 清除全局缓存对象中过期缓存 */ - public void expireCache() { + public void expireCache() throws IOException { for (String key : CacheGlobal.concurrentMap.keySet()) { MyCache myCache = CacheGlobal.concurrentMap.get(key); long timeoutTime = System.currentTimeMillis() - myCache.getWriteTime(); + //未过期 if (timeoutTime < myCache.getExpireTime()) { + //---redis中该用户的汇总信息续期--- + if (key.contains("%#%online%#%")) { + String uid = key.replace("%#%online%#%", ""); + Player player = TimingAcquisition.playerMap.get(uid); + if (!StringUtils.isEmpty(player)) { + String series = player.getSeries(); + String k = series + "::"+ uid; + redisUtil = SpringContextUtil.getApplicationContext().getBean(RedisUtil.class); + //玩家该系列的汇总数据过期,延长时间 + if (!redisUtil.keyIsExists(k)) { + //该用户续期 + redisUtil.renewalStr(k, Long.parseLong(redisExpireTime), TimeUnit.MILLISECONDS); + } + } + } continue; } //规定时间内玩家无操作默认下线 if (key.contains("%#%online%#%")) { String uid = key.replace("%#%online%#%", ""); Player player = TimingAcquisition.playerMap.get(uid); - //更新玩家为离线状态 - player.setStatus(Constants.OFFLINE); - //修改下线时间 - player.setOfflineTime(DateUtil.getCurrentTime()); - //--------------持久化该园丁信息--------------- - Map playerMap = new ConcurrentHashMap<>(); - playerMap.put(uid, TimingAcquisition.playerMap.get(uid)); - String playerStr = JSON.toJSONString(playerMap); - PersistenceUtil.saveDataToFile(userFilePath, uid, playerStr); + if (!StringUtils.isEmpty(player)) { + if (player.getStatus() == Constants.ONLINE) { + String initMoney = TimingAcquisition.seriesSystemConfigMap.get(player.getSeries()).get("init_money").getValue(); + if (StringUtils.isEmpty(initMoney)) { + String series = player.getSeries(); + if (!StringUtils.isEmpty(TimingAcquisition.seriesPlayerMap.get(series))) { + //-----------存入redis缓存中------------- + redisUtil.setStr(series + "::"+ uid, JSON.toJSONString(TimingAcquisition.seriesPlayerMap.get(series).get(uid))); + RemoteCallFactory.getInstance().updateItems(uid, "gardenSys"); + } + } + } + PlayerUtil.offLine(uid); + } } //清除过期缓存 CacheGlobal.concurrentMap.remove(key); diff --git a/src/main/java/com/qiwu/inference/common/cache/TaskTipsThread.java b/src/main/java/com/qiwu/inference/common/cache/TaskTipsThread.java index bfe0b53..236150b 100644 --- a/src/main/java/com/qiwu/inference/common/cache/TaskTipsThread.java +++ b/src/main/java/com/qiwu/inference/common/cache/TaskTipsThread.java @@ -37,9 +37,10 @@ public class TaskTipsThread implements Runnable{ public void checkTaskTips() throws ParseException { Map playerMap = TimingAcquisition.playerMap; String nowTime = DateUtil.getCurrentTime(); - String tipTime = TimingAcquisition.systemConfigMap.get("tipTime").getValue(); for (Map.Entry entry : playerMap.entrySet()) { Player player = entry.getValue(); + String seriesName = player.getSeries(); //系列名称 + String tipTime = TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("tipTime").getValue(); //在线玩家 if (player.getStatus().equals(Constants.ONLINE)) { //上次提示时间已超过规定时间 diff --git a/src/main/java/com/qiwu/inference/common/config/RedisConfig.java b/src/main/java/com/qiwu/inference/common/config/RedisConfig.java new file mode 100644 index 0000000..fc7a987 --- /dev/null +++ b/src/main/java/com/qiwu/inference/common/config/RedisConfig.java @@ -0,0 +1,50 @@ +package com.qiwu.inference.common.config; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator; +import org.springframework.cache.annotation.CachingConfigurerSupport; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + + +@Configuration +public class RedisConfig extends CachingConfigurerSupport { + + @Bean + public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) { + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setConnectionFactory(redisConnectionFactory); + Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class); + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance , + ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY); + jackson2JsonRedisSerializer.setObjectMapper(om); + StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); + // key采用String的序列化方式 + redisTemplate.setKeySerializer(stringRedisSerializer); + // hash的key也采用String的序列化方式 + redisTemplate.setHashKeySerializer(stringRedisSerializer); + // value序列化方式采用jackson + redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); + // hash的value序列化方式采用jackson + redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer); + redisTemplate.afterPropertiesSet(); + return redisTemplate; + } + @Bean + public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory){ + StringRedisTemplate stringRedisTemplate = new StringRedisTemplate(); + stringRedisTemplate.setConnectionFactory(redisConnectionFactory); + return stringRedisTemplate; + } +} diff --git a/src/main/java/com/qiwu/inference/common/config/ThreadPoolConfig.java b/src/main/java/com/qiwu/inference/common/config/ThreadPoolConfig.java new file mode 100644 index 0000000..0da2479 --- /dev/null +++ b/src/main/java/com/qiwu/inference/common/config/ThreadPoolConfig.java @@ -0,0 +1,48 @@ +package com.qiwu.inference.common.config; + +import jodd.util.concurrent.ThreadFactoryBuilder; +import org.jetbrains.annotations.NotNull; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableAsync; + +import java.util.concurrent.*; + +@Configuration +@EnableAsync +public class ThreadPoolConfig { + @Bean(value = "threadPoolInstance") + public Executor myThreadPool() { + //核心线程数 + int corePoolSize = 5; + //最大线程数 + int maxPoolSize = 7; + //设置工作队列大小 + int queueCapacity = 1000; + //最大存活时间 + long keepAliveTime = 30; + //设置线程名称前缀 + String threadNamePrefix = "threadPool-->"; + //设置自定义拒绝策略 + RejectedExecutionHandler rejectedExecutionHandler = new RejectedExecutionHandler() { + @Override + public void rejectedExecution(Runnable runnable, ThreadPoolExecutor threadPoolExecutor) { + throw new RuntimeException("线程数已超过最大线程数"); + } + }; + //自定义线程工厂 + ThreadFactory threadFactory = new ThreadFactory() { + private int i = 1; + @Override + public Thread newThread(@NotNull Runnable runnable) { + Thread thread = new Thread(runnable); + thread.setName(threadNamePrefix + i); + i++; + return thread; + } + }; + //初始化线程 + return new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, + TimeUnit.SECONDS, new LinkedBlockingQueue<>(queueCapacity), threadFactory, rejectedExecutionHandler); + } +} diff --git a/src/main/java/com/qiwu/inference/common/utils/CacheUtil.java b/src/main/java/com/qiwu/inference/common/utils/CacheUtil.java index a08a739..58c0b0e 100644 --- a/src/main/java/com/qiwu/inference/common/utils/CacheUtil.java +++ b/src/main/java/com/qiwu/inference/common/utils/CacheUtil.java @@ -22,7 +22,7 @@ public class CacheUtil { MyCache myCache = CacheGlobal.concurrentMap.get(key); myCache.setHitCount(myCache.getHitCount() + 1); myCache.setLastTime(System.currentTimeMillis()); - myCache.setExpireTime(System.currentTimeMillis()); + myCache.setExpireTime(expire); myCache.setValue(value); } else { MyCache myCache = new MyCache(); diff --git a/src/main/java/com/qiwu/inference/common/utils/ConfigDataUtil.java b/src/main/java/com/qiwu/inference/common/utils/ConfigDataUtil.java new file mode 100644 index 0000000..adb2985 --- /dev/null +++ b/src/main/java/com/qiwu/inference/common/utils/ConfigDataUtil.java @@ -0,0 +1,345 @@ +package com.qiwu.inference.common.utils; + +import com.qiwu.inference.common.Constants; +import com.qiwu.inference.common.TimingAcquisition; +import com.qiwu.inference.dto.ItemDto; +import com.qiwu.inference.dto.ItemNumDto; +import com.qiwu.inference.dto.PartnerItemDto; +import com.qiwu.inference.dto.PlayerSeriesDto; +import com.qiwu.inference.pojo.BackpackNum; +import com.qiwu.inference.pojo.PartnerItem; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import java.util.*; + +@Component +public class ConfigDataUtil { + /** + * 人数上限增加的下一声望值 + */ + public static BackpackNum getNextPartnerNum(String uid) { + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + //当前伙伴数量上限 + int partnerNumMax = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getPartnerItemMap().get(Constants.ITEM_PARTNER).getMax(); + Map partnerNumMap = TimingAcquisition.seriesBackpackNumMap.get(seriesName).get(Constants.ITEM_PARTNER); + for (Map.Entry entry : partnerNumMap.entrySet()) { + BackpackNum partnerNum = entry.getValue(); + if (partnerNum.getMax() > partnerNumMax) { + return partnerNum; + } + } + return null; + } + + /** + * 当前声望值对应的伙伴人数上限。返回-1表示不用更新 + */ + public static int getPartnerNumMax(String uid) { + int result = -1; + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + PlayerSeriesDto playerSeries = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid); + //玩家当前人数上限 + if (StringUtils.isEmpty(playerSeries.getPartnerItemMap().get(Constants.ITEM_PARTNER))) { + PartnerItemDto partnerItemDto =new PartnerItemDto(); + int max = TimingAcquisition.seriesBackpackNumMap.get(seriesName).get(Constants.ITEM_PARTNER).get(1).getMax(); + partnerItemDto.setMax(max); + partnerItemDto.setItemInfoMap(new HashMap<>()); + playerSeries.getPartnerItemMap().put(Constants.ITEM_PARTNER, partnerItemDto); + } + int partnerNumMax = playerSeries.getPartnerItemMap().get(Constants.ITEM_PARTNER).getMax(); + //玩家当前声望值 + Integer reputation = playerSeries.getTotalReputation().getReputation(); + int id = 0; + //伙伴人数上限配置 + Map partnerNumMap = TimingAcquisition.seriesBackpackNumMap.get(seriesName).get(Constants.ITEM_PARTNER); + for (Map.Entry entry : partnerNumMap.entrySet()) { + BackpackNum partnerNum = entry.getValue(); + if (partnerNum.getMax().equals(partnerNumMax)) { + id = entry.getKey(); + break; + } + } + if (id == partnerNumMap.size()) { + return result; + } + if (partnerNumMap.get(id + 1).getReputation() > reputation) { + return result; + } + return partnerNumMap.get(id + 1).getMax(); + } + + /** + * 背包道具上限增加的下一声望值 + */ + public static BackpackNum getNextItemNum(String uid) { + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + //当前道具数量上限 + int itemNumMax = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getPartnerItemMap().get(Constants.ITEM_PROPS).getMax(); + Map propNumMap = TimingAcquisition.seriesBackpackNumMap.get(seriesName).get(Constants.ITEM_PROPS); + for (Map.Entry entry : propNumMap.entrySet()) { + BackpackNum propNum = entry.getValue(); + if (propNum.getMax() > itemNumMax) { + return propNum; + } + } + return null; + } + + /** + * 当前声望值对应的背包道具数量上限。返回-1表示不用更新 + */ + public static int getItemNumMax(String uid) { + int result = -1; + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + PlayerSeriesDto playerSeries = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid); + //玩家当前人数上限 + if (StringUtils.isEmpty(playerSeries.getPartnerItemMap().get(Constants.ITEM_PROPS))) { + PartnerItemDto partnerItemDto = new PartnerItemDto(); + int max = TimingAcquisition.seriesBackpackNumMap.get(seriesName).get(Constants.ITEM_PROPS).get(1).getMax(); + partnerItemDto.setMax(max); + partnerItemDto.setItemInfoMap(new HashMap<>()); + playerSeries.getPartnerItemMap().put(Constants.ITEM_PROPS, partnerItemDto); + } + //玩家当前背包道具上限 + int itemNumMax = playerSeries.getPartnerItemMap().get(Constants.ITEM_PROPS).getMax(); + //玩家当前声望值 + Integer reputation = playerSeries.getTotalReputation().getReputation(); + int id = 0; + //背包上限配置 + Map propNumMap = TimingAcquisition.seriesBackpackNumMap.get(seriesName).get(Constants.ITEM_PROPS); + for (Map.Entry entry : propNumMap.entrySet()) { + BackpackNum propNum = entry.getValue(); + if (propNum.getMax().equals(itemNumMax)) { + id = entry.getKey(); + break; + } + } + if (id == propNumMap.size()) { + return result; + } + if (propNumMap.get(id + 1).getReputation() > reputation) { + return result; + } + result = propNumMap.get(id + 1).getMax(); + return result; + } + + /** + * 根据NPC名称找到对应伙伴ID + * @param uid + * @param name + */ + public static Integer getPartnerItemIdByName(String uid, String name) { + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + Map partnerMap = TimingAcquisition.seriesPartnerItemMap.get(seriesName); + for (Map.Entry entry : partnerMap.entrySet()) { + if (name.equals(entry.getValue().getName())) { + return entry.getValue().getId(); + } + } + return Constants.REQ_NON; + } + + /** + * 获取伙伴的名称 + */ + public static String getPartnerItemName(String uid, Integer partnerItemId) { + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + return TimingAcquisition.seriesPartnerItemMap.get(seriesName).get(partnerItemId).getName(); + } + + /** + * 获取已加入伙伴的名称 + */ + public static String getPartnerNames(String uid) { + StringBuilder result = new StringBuilder(); + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + if (StringUtils.isEmpty(TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getPartnerItemMap().get(Constants.ITEM_PARTNER))) { + return result.toString(); + } + Map partnerNumMap = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getPartnerItemMap(). + get(Constants.ITEM_PARTNER).getItemInfoMap(); + for (Map.Entry entry : partnerNumMap.entrySet()) { + result.append(getPartnerItemName(uid, entry.getKey())).append("、"); + } + if (result.length() != 0) { + result.deleteCharAt(result.length() - 1); + } + return result.toString(); + } + + /** + * 掉落物品是否已拥有 + */ + public static Boolean checkItemExist(String uid, Integer partnerItemId) { + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + //伙伴物品配置数据 + PartnerItem partnerItem = TimingAcquisition.seriesPartnerItemMap.get(seriesName).get(partnerItemId); + //物品类型 + int type = partnerItem.getType(); + //系列的玩家汇总数据 + Map partnerItemMap = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getPartnerItemMap(); + //没有这类物品 + if (StringUtils.isEmpty(partnerItemMap.get(type))) { + return false; + } + int max = partnerItemMap.get(type).getMax(); + Map itemInfoMap = partnerItemMap.get(type).getItemInfoMap(); + //对应的包已满 + if (itemInfoMap.size() >= max) { + return false; + } + //已有该物品 + if (!StringUtils.isEmpty(itemInfoMap.get(partnerItemId))) { + //伙伴和道具有且仅有一个 + if (type == Constants.ITEM_PARTNER || type == Constants.ITEM_PROPS) { + return false; + } + } + return true; + } + + /** + * 根据概率掉落获得 + */ + public static Boolean getPartnerItemByPro(String uid, Integer partnerItemId) { + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + //伙伴物品配置数据 + PartnerItem partnerItem = TimingAcquisition.seriesPartnerItemMap.get(seriesName).get(partnerItemId); + //掉落概率 + Double prob = partnerItem.getProbability(); + Random random = new Random(); + double randomProb = random.nextDouble(); + if (randomProb <= prob) { + return true; + } + return false; + } + + /** + * 伙伴/物品掉落 + */ + public static Map getDropItems(String uid, String drops) { + Map result = new HashMap<>(); + String[] dropList = drops.split(";"); + for (String drop : dropList) { + String[] dropNum = drop.split("\\|"); + //--------------背包中还没有该物品--------------- + if (!checkItemExist(uid, Integer.valueOf(dropNum[0]))) { + //是否掉落该物品 + if (getPartnerItemByPro(uid, Integer.valueOf(dropNum[0]))) { + result.put(Integer.valueOf(dropNum[0]), Integer.valueOf(dropNum[1])); + } + } + } + return result; + } + + /** + * 获取关卡已有的物品 + * @param uid + * @param items + * @return + */ + public static Map getItemMap(String uid, List items) { + Map partnerItemMap = new HashMap<>(); + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + Map partnerItemPojoMap = TimingAcquisition.seriesPartnerItemMap.get(seriesName); + if (items.size() > 0) { + //遍历所有物品 + for (ItemDto item : items) { + //关卡有该物品 + if (!StringUtils.isEmpty(partnerItemPojoMap.get(item.getItemId()))) { + Integer type = partnerItemPojoMap.get(item.getItemId()).getType(); + //物品类型数量上限 + int itemNumMax = TimingAcquisition.seriesBackpackNumMap.get(seriesName).get(type).get(1).getMax(); + //还没有这类物品 + if (StringUtils.isEmpty(partnerItemMap.get(type))) { + PartnerItemDto partnerItem = new PartnerItemDto(); + Map itemInfoMap = new HashMap<>(); + ItemNumDto itemNumDto = new ItemNumDto(); + partnerItem.setMax(itemNumMax); + itemNumDto.setId(item.getItemId()); + itemNumDto.setNum(item.getItemNum()); + itemInfoMap.put(item.getItemId(), itemNumDto); + partnerItem.setItemInfoMap(itemInfoMap); + partnerItemMap.put(type, partnerItem); + continue; + } + if (partnerItemMap.get(type).getItemInfoMap().size() >= itemNumMax) { + continue; + } + ItemNumDto itemNumDto = new ItemNumDto(); + itemNumDto.setId(item.getItemId()); + itemNumDto.setNum(item.getItemNum()); + partnerItemMap.get(type).getItemInfoMap().put(item.getItemId(), itemNumDto); + } + } + } + return partnerItemMap; + } + + /** + * 关卡同步背包物品的数据 + */ + public static void synItems(String uid, List itemList) { + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + Map partnerItemPojoMap = TimingAcquisition.seriesPartnerItemMap.get(seriesName); + Map partnerItemMap = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getPartnerItemMap(); + if (itemList.size() != 0) { + for (ItemDto item : itemList) { + PartnerItem partnerItemPojo = partnerItemPojoMap.get(item.getItemId()); + //关卡中没有该物品 + if (StringUtils.isEmpty(partnerItemPojo)) { + continue; + } + Integer type = partnerItemPojo.getType(); + PartnerItemDto partnerItem = partnerItemMap.get(type); + //背包中没有这类物品 + if (StringUtils.isEmpty(partnerItem)) { + PartnerItemDto partnerItemNew = new PartnerItemDto(); + Map itemInfoMap = new HashMap<>(); + ItemNumDto itemNumDto = new ItemNumDto(); + //物品类型数量初始上限 + int itemNumMax = TimingAcquisition.seriesBackpackNumMap.get(seriesName).get(type).get(1).getMax(); + partnerItemNew.setMax(itemNumMax); + itemNumDto.setId(item.getItemId()); + itemNumDto.setNum(item.getItemNum()); + itemInfoMap.put(item.getItemId(), itemNumDto); + partnerItemNew.setItemInfoMap(itemInfoMap); + continue; + } + //该类物品的上限 + int numMax = partnerItem.getMax(); + Map itemInfoMap = partnerItem.getItemInfoMap(); + //该类物品已达到上限 + if (itemInfoMap.size() >= numMax) { + continue; + } + //还没有该物品 + if (StringUtils.isEmpty(itemInfoMap.get(item.getItemId()))) { + ItemNumDto itemNumDto = new ItemNumDto(); + itemNumDto.setId(item.getItemId()); + itemNumDto.setNum(item.getItemNum()); + itemInfoMap.put(item.getItemId(), itemNumDto); + continue; + } + ItemNumDto itemNum = itemInfoMap.get(item.getItemId()); + //物品数量变动,更新数据 + if (!itemNum.getNum().equals(item.getItemNum())) { + itemNum.setNum(item.getItemNum()); + } + } + } + } +} diff --git a/src/main/java/com/qiwu/inference/common/utils/CsvUtil.java b/src/main/java/com/qiwu/inference/common/utils/CsvUtil.java new file mode 100644 index 0000000..654a23e --- /dev/null +++ b/src/main/java/com/qiwu/inference/common/utils/CsvUtil.java @@ -0,0 +1,40 @@ +package com.qiwu.inference.common.utils; + +import com.opencsv.CSVReader; +import com.opencsv.bean.CsvToBeanBuilder; +import com.opencsv.bean.CsvToBeanFilter; +import com.opencsv.bean.HeaderColumnNameMappingStrategy; +import org.springframework.util.StringUtils; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.List; + +public class CsvUtil { + public List read(String filePath, Class clazz) { + try { + CSVReader reader = new CSVReader(new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8)); + HeaderColumnNameMappingStrategy mapper = new HeaderColumnNameMappingStrategy<>(); + mapper.setType(clazz); + return new CsvToBeanBuilder(reader) + .withMappingStrategy(mapper) + .withIgnoreLeadingWhiteSpace(true) + .withFilter(new MyFilter()) + .build() + .parse(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + System.out.printf("csv文件: {%s} 读取异常%n", filePath); + } + return null; + } + + private static class MyFilter implements CsvToBeanFilter { + public boolean allowLine(String[] line) { + String id = line[0]; + return !StringUtils.isEmpty(id) && !id.equals(""); + } + } +} diff --git a/src/main/java/com/qiwu/inference/common/utils/DataTrimUtil.java b/src/main/java/com/qiwu/inference/common/utils/DataTrimUtil.java index f37ba3a..87eb544 100644 --- a/src/main/java/com/qiwu/inference/common/utils/DataTrimUtil.java +++ b/src/main/java/com/qiwu/inference/common/utils/DataTrimUtil.java @@ -79,7 +79,22 @@ public class DataTrimUtil { if (StringUtils.isEmpty(data.getVars().get后台附加返回2())) { data.getVars().set后台附加返回2("无效返回"); } - + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + //搭档名称 + String partnerName = TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("partnerName").getValue(); + //替换话术词汇 + String text = data.getVars().get反馈文本(); + if (!StringUtils.isEmpty(text)) { + //替换话术的【搭档名称@正常】 + if (text.contains("【搭档名称@正常】")) { + text = text.replace("【搭档名称@正常】", "【" + partnerName + "@正常】"); + } + //替换话术的【搭档名称】 + if (text.contains("【搭档名称】")) { + text = text.replace("【搭档名称】", partnerName); + } + data.getVars().set反馈文本(text); + } String feedContent = "后台返回参数 = [" + "code:" + result.getCode() + ", msg:" + result.getMessage() + @@ -90,10 +105,13 @@ public class DataTrimUtil { "]"; //需要给玩家提示任务线索 // if (TimingAcquisition.playerMap.get(uid).isTipFlag()) { +// //搭档名称 +// String partnerName = TimingAcquisition.systemConfigMap.get("partnerName").getValue(); // String addText = PlayerUtil.getClueFromTaskKey(uid); +// addText = SpeechUtil.addHeader(addText, partnerName); // if (!StringUtils.isEmpty(addText)) { // TimingAcquisition.playerMap.get(uid).setTipFlag(false); -// data.getVars().set反馈文本(data.getVars().get反馈文本() + "【寒烟@正常】" + addText); +// data.getVars().set反馈文本(data.getVars().get反馈文本() + addText); // } // } log.info(feedContent); diff --git a/src/main/java/com/qiwu/inference/common/utils/FileUtil.java b/src/main/java/com/qiwu/inference/common/utils/FileUtil.java index c7138c1..ae1a9a9 100755 --- a/src/main/java/com/qiwu/inference/common/utils/FileUtil.java +++ b/src/main/java/com/qiwu/inference/common/utils/FileUtil.java @@ -1,36 +1,163 @@ package com.qiwu.inference.common.utils; -import java.io.File; -import java.io.InputStream; +import com.qiwu.inference.pojo.*; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; public class FileUtil { + /** + * 加载系列的场所表 + */ + public static Map getLocationModel(String filePath) { + String locationPath = filePath + "location.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List locationList = csvUtil.read(locationPath, Location.class); + Map locationMap = new ConcurrentHashMap<>(); + for (Location location : locationList) { + locationMap.put(location.getId().toString(), location); + } + return locationMap; + } + /** + * 加载系列的线索表 + */ + public static Map getClueModel(String filePath) { + String cluePath = filePath + "clue.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List clueList = csvUtil.read(cluePath, Clue.class); + Map clueMap = new ConcurrentHashMap<>(); + for (Clue clue : clueList) { + clueMap.put(clue.getId(), clue); + } + return clueMap; + } - public static InputStream getResourcesFileInputStream(String fileName) { - return Thread.currentThread().getContextClassLoader().getResourceAsStream("" + fileName); + /** + * 加载系列的线索表 + */ + public static Map getClueTypeModel(String filePath) { + String clueTypePath = filePath + "clueType.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List clueTypeList = csvUtil.read(clueTypePath, ClueType.class); + Map clueTypeMap = new ConcurrentHashMap<>(); + for (ClueType clueType : clueTypeList) { + clueTypeMap.put(clueType.getId(), clueType.getName()); + } + return clueTypeMap; } - public static String getPath() { - return FileUtil.class.getResource("/").getPath(); + /** + * 加载系列的性格表 + */ + public static Map getDispositionModel(String filePath) { + String dispositionPath = filePath + "disposition.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List dispositionList = csvUtil.read(dispositionPath, Disposition.class); + Map dispositionMap = new ConcurrentHashMap<>(); + for (Disposition disposition : dispositionList) { + dispositionMap.put(disposition.getId(), disposition); + } + return dispositionMap; } - public static File createNewFile(String pathName) { - File file = new File(getPath() + pathName); - if (file.exists()) { - file.delete(); - } else { - if (!file.getParentFile().exists()) { - file.getParentFile().mkdirs(); - } + /** + * 加载系列的系统配置表 + */ + public static Map getSystemConfigModel(String filePath) { + String systemConfigPath = filePath + "systemConfig.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List systemConfigList = csvUtil.read(systemConfigPath, SystemConfigPojo.class); + Map systemConfigMap = new ConcurrentHashMap<>(); + for (SystemConfigPojo systemConfig : systemConfigList) { + systemConfigMap.put(systemConfig.getName(), systemConfig); } - return file; + return systemConfigMap; } - public static File readFile(String pathName) { - return new File(getPath() + pathName); + /** + * 加载任务条件和操作id,以及类型对应表 + */ + public static Map getTaskConditionModel(String filePath) { + String taskConditionPath = filePath + "taskCondition.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List taskConditionList = csvUtil.read(taskConditionPath, TaskConditionPojo.class); + Map taskConditionMap = new ConcurrentHashMap<>(); + for (TaskConditionPojo taskCondition : taskConditionList) { + taskConditionMap.put(taskCondition.getId(), taskCondition); + } + return taskConditionMap; + } + + /** + * 加载伙伴配置表 + */ + public static Map getPartnerItemModel(String filePath) { + String partnerItemPath = filePath + "partnerItem.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List partnerItemList = csvUtil.read(partnerItemPath, PartnerItem.class); + Map partnerItemMap = new ConcurrentHashMap<>(); + for (PartnerItem partnerItem : partnerItemList) { + partnerItemMap.put(partnerItem.getId(), partnerItem); + } + return partnerItemMap; } - public static File readUserHomeFile(String pathName) { - return new File(System.getProperty("user.home") + File.separator + pathName); + /** + * 加载伙伴人数上限表 + */ + public static Map getPartnerNumModel(String filePath) { + String partnerNumPath = filePath + "partnerNum.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List partnerNumList = csvUtil.read(partnerNumPath, BackpackNum.class); + Map partnerNumMap = new ConcurrentHashMap<>(); + for (BackpackNum partnerNum : partnerNumList) { + partnerNumMap.put(partnerNum.getId(), partnerNum); + } + return partnerNumMap; + } + + /** + * 加载背包数量上限表 + */ + public static Map getBackpackNumModel(String filePath) { + String propNumPath = filePath + "propNum.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List propNumList = csvUtil.read(propNumPath, BackpackNum.class); + Map propNumMap = new ConcurrentHashMap<>(); + for (BackpackNum propNum : propNumList) { + propNumMap.put(propNum.getId(), propNum); + } + return propNumMap; + } + + /** + * 加载普通数量上限表 + */ + public static Map getItemNumModel(String filePath) { + String itemNumPath = filePath + "itemNum.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List itemNumList = csvUtil.read(itemNumPath, BackpackNum.class); + Map itemNumMap = new ConcurrentHashMap<>(); + for (BackpackNum itemNum : itemNumList) { + itemNumMap.put(itemNum.getId(), itemNum); + } + return itemNumMap; + } + + /** + * 加载NPC配置表 + */ + public static Map getPersonModel(String filePath) { + String personPath = filePath + "person.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List personList = csvUtil.read(personPath, PersonPojo.class); + Map personMap = new ConcurrentHashMap<>(); + for (PersonPojo person : personList) { + personMap.put(person.getId(), person); + } + return personMap; } } diff --git a/src/main/java/com/qiwu/inference/common/utils/MD5Util.java b/src/main/java/com/qiwu/inference/common/utils/MD5Util.java new file mode 100644 index 0000000..606d3b7 --- /dev/null +++ b/src/main/java/com/qiwu/inference/common/utils/MD5Util.java @@ -0,0 +1,74 @@ +package com.qiwu.inference.common.utils; + +import com.qiwu.inference.common.cache.ExpireThread; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +@Component +public class MD5Util { + //玩家数据路径 + public static String userFilePath; + @Value("${userFilePath}") + public void setUserFilePath(String userFilePath) { + MD5Util.userFilePath = userFilePath; + } + + //玩家系列汇总数据路径 + public static String dataFilePath; + @Value("${dataFilePath}") + public void setDataFilePath(String dataFilePath) { + MD5Util.dataFilePath = dataFilePath; + } + /** + * 使用md5进行加密 + */ + public static String md5(String text) { + byte[] secretBytes = null; + try { + secretBytes = MessageDigest.getInstance("md5").digest(text.getBytes()); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException("没有md5的算法"); + } + StringBuilder sb = new StringBuilder(40); + for(byte x:secretBytes) { + if((x & 0xff)>>4 == 0) { + sb.append("0").append(Integer.toHexString(x & 0xff)); + } else { + sb.append(Integer.toHexString(x & 0xff)); + } + } + return sb.toString(); + } + + /** + * 将uid转成对应的路径 + */ + public static String changeToPath(String uid, String seriesName) { + //创建玩家数据路径 + String md5 = md5(uid); + String front = md5.substring(0,2); + String second = md5.substring(2, 4); + String three = md5.substring(4, 6); + return userFilePath + "/" + front + "/" + second+ "/" + three+ "/" + uid + "/" + seriesName + "/"; + } + + /** + * 将uid转成系列汇总数据的路径 + */ + public static String changeToDataPath(String uid, String seriesName) { + //创建玩家数据路径 + String md5 = md5(uid); + String front = md5.substring(0,2); + String second = md5.substring(2, 4); + String three = md5.substring(4, 6); + return dataFilePath+ "/" + seriesName + "/" + front + "/" + second+ "/" + three+ "/"; + } + + public static void main(String[] args) { + String uid = "Test12321211123"; + System.out.println("路径是:" + changeToPath(uid, "测试")); + } +} diff --git a/src/main/java/com/qiwu/inference/common/utils/PersistenceUtil.java b/src/main/java/com/qiwu/inference/common/utils/PersistenceUtil.java index b8b7902..44aaf26 100644 --- a/src/main/java/com/qiwu/inference/common/utils/PersistenceUtil.java +++ b/src/main/java/com/qiwu/inference/common/utils/PersistenceUtil.java @@ -1,14 +1,26 @@ package com.qiwu.inference.common.utils; -import org.springframework.beans.factory.annotation.Value; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.qiwu.inference.common.Constants; +import com.qiwu.inference.common.TimingAcquisition; +import com.qiwu.inference.dto.*; +import com.qiwu.inference.pojo.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.StringUtils; import org.yaml.snakeyaml.Yaml; import java.io.*; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.PriorityBlockingQueue; public class PersistenceUtil { + static Logger log = LoggerFactory.getLogger(PersistenceUtil.class); /** * 保存玩家数据到json文件 * @param fileName @@ -16,45 +28,143 @@ public class PersistenceUtil { * @return void */ public static void saveDataToFile(String path, String fileName, String data) { - BufferedWriter writer = null; - File file = new File(path + fileName + ".json"); + FileWriter fw = null; + File file = new File(path); if (!file.exists()) { try { - file.createNewFile(); + file.mkdirs(); } catch (Exception e) { e.printStackTrace(); } } try { - writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, false), "UTF-8")); - writer.write(data); + fw = new FileWriter(path + "/" + fileName + ".json", false); + fw.write(data); } catch (Exception e) { e.printStackTrace(); } finally { try { - if (writer != null) { - writer.close(); + if (fw != null) { + fw.close(); } } catch (Exception e) { e.printStackTrace(); } } } + /** - * 从json文件中读取玩家数据 + * 从配置文件夹的关卡中读取关卡数据和关卡话术 * @param filePath * @return String */ - public static String getDataFromFile(String filePath) { + public static void getDataFromFile(String filePath) { BufferedReader reader = null; - String lastStr = ""; + File file = new File(filePath); try { - FileInputStream fileInputStream = new FileInputStream(filePath); - InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); - reader = new BufferedReader(inputStreamReader); - String stringTmp = null; - while ((stringTmp = reader.readLine()) != null) { - lastStr += stringTmp; + if (file.exists()) { + File[] fileList = file.listFiles(); + if (!StringUtils.isEmpty(fileList)) { + if (fileList.length != 0) { + //遍历所有系列名称 + for (File series : fileList) { + String seriesName = series.getName(); //系列名称 + String gateFilePath = series.getAbsolutePath() + "/关卡数据/"; //关卡数据路径 + File gateFile = new File(gateFilePath); //关卡数据目录下的所有关卡 + File[] gateNosList = gateFile.listFiles(); //所有关卡目录 + List gateNoList = new ArrayList<>(); //记录该系列所有的关卡编号 + if (!StringUtils.isEmpty(gateNosList)) { + //遍历系列下的所有目录 + for (File value : gateNosList) { + String gateName = value.getName(); //关卡名称 + StringBuilder result = new StringBuilder(); + FileInputStream fileInputStream = new FileInputStream(value.getAbsolutePath() + "/data/results.json"); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + reader = new BufferedReader(inputStreamReader); + String stringTmp = null; + while ((stringTmp = reader.readLine()) != null) { + result.append(stringTmp); + } + Map> gateInfoMap = JSON.parseObject(result.toString(), new TypeReference>>(){}); + TimingAcquisition.gateInfoMap.putAll(gateInfoMap); + //-------------------------缓存关卡攻略数据--------------------- + String gateNo = null; + for (Map.Entry> entry : gateInfoMap.entrySet()) { + gateNo = entry.getKey(); + } + gateNoList.add(gateNo); + //缓存关卡名称和编号的对应关系 + TimingAcquisition.gateNameToNoMap.put(gateName, gateNo); + log.info("开始缓存关卡攻略数据"); + String barrierTaskKey = getConfigFromFile(value.getAbsolutePath() + "/data/", "results_final_task.json"); + List barrierTaskKeyList = JSON.parseObject(barrierTaskKey, new TypeReference>(){}); + Map> barrierTaskKeyMap = new ConcurrentHashMap<>(); + barrierTaskKeyMap.put(gateNo, barrierTaskKeyList); + TimingAcquisition.barrierTaskKeyMap.putAll(barrierTaskKeyMap); + log.info("关卡攻略数据缓存完成"); + + String speechFilePath = value.getAbsolutePath() + "/speech/"; + File speechFile = new File(speechFilePath); + if (speechFile.exists()) { + File[] speechFileList = speechFile.listFiles(); //所有配置的话术 + if (!StringUtils.isEmpty(speechFileList)) { + if (speechFileList.length != 0) { + //--------------------加载后台配置的话术到关卡中----------------- + TimingAcquisition.speechLoadingToGate(gateNo, speechFilePath); + //--------------------加载闲聊话术到关卡中---------------- + log.info("加载闲聊话术到关卡中"); + Map> chatSpeechMap = SpeechUtil.getChatSpeechModel(speechFilePath); + TimingAcquisition.gateNoChatSpeechMap.put(gateNo, chatSpeechMap); + log.info("闲聊话术加载到关卡中完成"); + + //--------------------加载线索成功话术到关卡中---------------- + log.info("加载线索成功话术到关卡中"); + Map> clueSpeechMap = SpeechUtil.getClueSpeechModel(speechFilePath); + TimingAcquisition.gateNoSuccessClueSpeechMap.put(gateNo, clueSpeechMap); + log.info("线索成功话术加载到关卡中完成"); + + //--------------------加载任务成功话术到关卡中---------------- + log.info("加载任务成功话术到关卡中"); + Map> taskSpeechMap = SpeechUtil.getTaskSpeechModel(speechFilePath); + TimingAcquisition.gateNoSuccessTaskSpeechMap.put(gateNo, taskSpeechMap); + log.info("任务成功话术加载到关卡中完成"); + + //--------------------加载任务成功话术到关卡中---------------- + log.info("加载任务提示话术到关卡中"); + Map> tipSpeechMap = SpeechUtil.getTipSpeechModel(speechFilePath); + TimingAcquisition.gateNoTipSpeechMap.put(gateNo, tipSpeechMap); + log.info("任务提示话术加载到关卡中完成"); + + //--------------------加载人物见面话术到关卡中---------------- + log.info("加载人物见面话术到关卡中"); + Map> personSpeechMap = SpeechUtil.getPersonSpeechModel(speechFilePath); + TimingAcquisition.gateNoPersonSpeechMap.put(gateNo, personSpeechMap); + log.info("人物见面话术加载到关卡中完成"); + + //--------------------加载操作提示话术到关卡中---------------- + log.info("加载操作提示话术到关卡中"); + Map operateSpeechMap = SpeechUtil.getOperateSpeechModel(speechFilePath); + TimingAcquisition.gateNoOperateSpeechMap.put(gateNo, operateSpeechMap); + log.info("操作提示话术加载到关卡中完成"); + + //--------------------加载任务异常话术到关卡中---------------- + log.info("加载任务异常话术到关卡中"); + Map taskExceptionSpeechMap = SpeechUtil.getTaskExceptionSpeechModel(speechFilePath); + TimingAcquisition.gateNoTaskExceptionSpeechMap.put(gateNo, taskExceptionSpeechMap); + log.info("任务异常话术加载到关卡中完成"); + } + } + } + } + } + log.info("开始缓存系列名和关卡编号对应关系"); + Map> seriesGateNosMap = new ConcurrentHashMap<>(); + seriesGateNosMap.put(seriesName, gateNoList); + TimingAcquisition.seriesGateNosMap.putAll(seriesGateNosMap); + log.info("系列名和关卡编号对应关系完成"); + } + } + } } } catch (Exception e) { e.printStackTrace(); @@ -67,7 +177,162 @@ public class PersistenceUtil { e.printStackTrace(); } } - return lastStr; + } + + /** + * 从配置文件的系列话术中加载话术表到系列中 + * @param filePath + * @return String + */ + public static void getSpeechFromFile(String filePath) { + File file = new File(filePath); + try { + if (file.exists()) { + File[] fileList = file.listFiles(); + if (!StringUtils.isEmpty(fileList)) { + if (fileList.length != 0) { + //遍历所有系列名称 + for (File series : fileList) { + String seriesName = series.getName(); //系列名称 + String speechFilePath = series.getAbsolutePath() + "/speech/"; + //--------------------加载后台配置的话术----------------- + TimingAcquisition.speechLoading(seriesName, speechFilePath); + //--------------------加载闲聊话术的csv表---------------- + log.info("加载闲聊话术到系列"); + Map> chatSpeechMap = SpeechUtil.getChatSpeechModel(speechFilePath); + TimingAcquisition.seriesChatSpeechMap.put(seriesName, chatSpeechMap); + log.info("闲聊话术加载到系列完成"); + + //--------------------加载线索成功话术的csv表---------------- + log.info("加载线索成功话术到系列"); + Map> clueSpeechMap = SpeechUtil.getClueSpeechModel(speechFilePath); + TimingAcquisition.seriesSuccessClueSpeechMap.put(seriesName, clueSpeechMap); + log.info("线索成功话术加载到系列完成"); + + //--------------------加载任务成功话术的csv表---------------- + log.info("加载任务成功话术到系列"); + Map> taskSpeechMap = SpeechUtil.getTaskSpeechModel(speechFilePath); + TimingAcquisition.seriesSuccessTaskSpeechMap.put(seriesName, taskSpeechMap); + log.info("任务成功话术加载到系列完成"); + + //--------------------加载任务成功话术的csv表---------------- + log.info("加载任务提示话术到系列"); + Map> tipSpeechMap = SpeechUtil.getTipSpeechModel(speechFilePath); + TimingAcquisition.seriesTipSpeechMap.put(seriesName, tipSpeechMap); + log.info("任务提示话术加载到系列完成"); + + //--------------------加载人物见面话术的csv表---------------- + log.info("加载人物见面话术到系列"); + Map> personSpeechMap = SpeechUtil.getPersonSpeechModel(speechFilePath); + TimingAcquisition.seriesPersonSpeechMap.put(seriesName, personSpeechMap); + log.info("人物见面话术加载到系列完成"); + + //--------------------加载操作提示话术的csv表---------------- + log.info("加载操作提示话术到系列"); + Map operateSpeechMap = SpeechUtil.getOperateSpeechModel(speechFilePath); + TimingAcquisition.seriesOperateSpeechMap.put(seriesName, operateSpeechMap); + log.info("操作提示话术加载到系列完成"); + + //--------------------加载任务异常话术的csv表---------------- + log.info("加载任务异常话术到系列"); + Map taskExceptionSpeechMap = SpeechUtil.getTaskExceptionSpeechModel(speechFilePath); + TimingAcquisition.seriesTaskExceptionSpeechMap.put(seriesName, taskExceptionSpeechMap); + log.info("任务异常话术加载到系列中完成"); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 从配置文件的系列配置中加载配置表到系列中 + * @param filePath + * @return String + */ + public static void getConfigFromFile(String filePath) { + File file = new File(filePath); + try { + if (file.exists()) { + File[] fileList = file.listFiles(); + if (!StringUtils.isEmpty(fileList)) { + if (fileList.length != 0) { + //遍历所有系列名称 + for (File series : fileList) { + String seriesName = series.getName(); //系列名称 + String configFilePath = series.getAbsolutePath() + "/config/"; + //--------------------加载场所表到系列中---------------- + log.info("加载场所表到系列:" + seriesName); + Map locationMap = FileUtil.getLocationModel(configFilePath); + TimingAcquisition.seriesLocationMap.put(seriesName, locationMap); + log.info("场所表加载到系列完成"); + + //--------------------加载线索表到系列中---------------- + log.info("加载线索表到系列:" + seriesName); + Map clueMap = FileUtil.getClueModel(configFilePath); + TimingAcquisition.seriesClueMap.put(seriesName, clueMap); + log.info("线索表加载到系列完成"); + + //--------------------加载线索类型表到系列中---------------- + log.info("加载线索类型表到系列:" + seriesName); + Map clueTypeMap = FileUtil.getClueTypeModel(configFilePath); + TimingAcquisition.seriesClueTypeMap.put(seriesName, clueTypeMap); + log.info("线索类型表加载到系列完成"); + + //--------------------加载性格表到系列中---------------- + log.info("加载性格表到系列:" + seriesName); + Map dispositionMap = FileUtil.getDispositionModel(configFilePath); + TimingAcquisition.seriesDispositionMap.put(seriesName, dispositionMap); + log.info("性格表加载到系列完成"); + + //--------------------加载系统配置表到系列中---------------- + log.info("加载系统配置表到系列:" + seriesName); + Map systemConfigMap = FileUtil.getSystemConfigModel(configFilePath); + TimingAcquisition.seriesSystemConfigMap.put(seriesName, systemConfigMap); + log.info("系统配置表加载到系列完成"); + + //--------------------加载任务条件表到系列中---------------- + log.info("加载任务条件表到系列:" + seriesName); + Map taskConditionMap = FileUtil.getTaskConditionModel(configFilePath); + TimingAcquisition.seriesTaskConditionMap.put(seriesName, taskConditionMap); + log.info("任务条件表加载到系列完成"); + + //--------------------加载伙伴配置表到系列中---------------- + log.info("加载伙伴配置表到系列:" + seriesName); + Map partnerItemMap = FileUtil.getPartnerItemModel(configFilePath); + TimingAcquisition.seriesPartnerItemMap.put(seriesName, partnerItemMap); + log.info("伙伴配置表加载到系列完成"); + + Map> result = new HashMap<>(); + //--------------------加载伙伴人数上限表到系列中---------------- + log.info("加载伙伴人数上限表到系列:" + seriesName); + Map partnerNumMap = FileUtil.getPartnerNumModel(configFilePath); + result.put(Constants.ITEM_PARTNER, partnerNumMap); + //--------------------加载背包数量上限表到系列中---------------- + log.info("加载道具数量上限表到系列:" + seriesName); + Map propNumMap = FileUtil.getBackpackNumModel(configFilePath); + result.put(Constants.ITEM_PROPS, propNumMap); + //--------------------加载普通物品数量上限表到系列中---------------- + log.info("加载普通物品数量上限表到系列:" + seriesName); + Map itemNumMap = FileUtil.getItemNumModel(configFilePath); + result.put(Constants.ITEM_NOR, itemNumMap); + TimingAcquisition.seriesBackpackNumMap.put(seriesName, result); + log.info("背包数量上限表加载到系列完成"); + + //--------------------加载NPC配置表到系列中---------------- + log.info("加载NPC配置表到系列:" + seriesName); + Map personMap = FileUtil.getPersonModel(configFilePath); + TimingAcquisition.seriesPersonMap.put(seriesName, personMap); + log.info("NPC配置表加载到系列完成"); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } } /** @@ -102,6 +367,35 @@ public class PersistenceUtil { } /** + * 读取json文件数据 + * @param path json文件路径 + * @param fileName + * @return 字符串 + */ + public static String readJson(String path, String fileName) { + String jsonPath = path + fileName; + File jsonFile = new File(jsonPath); + try { + FileReader fileReader = new FileReader(jsonFile); + BufferedReader reader = new BufferedReader(fileReader); + StringBuilder sb = new StringBuilder(); + while (true) { + int ch = reader.read(); + if (ch != -1) { + sb.append((char) ch); + } else { + break; + } + } + fileReader.close(); + reader.close(); + return sb.toString(); + } catch (IOException e) { + return ""; + } + } + + /** * 将话术转成map格式 * @param * @return Map>> @@ -117,4 +411,154 @@ public class PersistenceUtil { } return speechMap; } + + /** + * 读取玩家json文件的数据 + * @param path json文件路径 + * @param gateNo + * @return 字符串 + */ + public static String loadPlayerData(String path, String gateNo) { + BufferedReader reader = null; + String fileName = gateNo + ".json"; + String lastStr = ""; + File file = new File(path + fileName); + if (!file.exists()) { + return lastStr; + } + try { + FileInputStream fileInputStream = new FileInputStream(path + fileName); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + reader = new BufferedReader(inputStreamReader); + String stringTmp = null; + while ((stringTmp = reader.readLine()) != null) { + lastStr += stringTmp; + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (reader != null) { + reader.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return lastStr; + } + + /** + * 读取json文件的数据 + * @param path json文件路径 + * @param fileName + * @return 字符串 + */ + public static String readJsonFile(String path, String fileName) { + BufferedReader reader = null; + String lastStr = ""; + File file = new File(path + "/" + fileName); + if (!file.exists()) { + return lastStr; + } + try { + FileInputStream fileInputStream = new FileInputStream(path + "/" + fileName); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + reader = new BufferedReader(inputStreamReader); + String stringTmp = null; + while ((stringTmp = reader.readLine()) != null) { + lastStr += stringTmp; + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (reader != null) { + reader.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return lastStr; + } + + /** + * 加载玩家所有关卡的声望值 + */ + public static void loadSeriesReputation(String uid, String filePath) { + File file = new File(filePath); + ReputationDto reputation = new ReputationDto(); + try { + if (file.exists()) { + File[] fileList = file.listFiles(); //玩家的所有系列 + if (!StringUtils.isEmpty(fileList)) { + if (fileList.length != 0) { + //遍历所有系列 + for (File series : fileList) { + String seriesName = series.getName(); //系列名称 + String playerFilePath = series.getAbsolutePath(); + File[] gateNoList = series.listFiles(); //玩家该系列的所有关卡 + if (!StringUtils.isEmpty(gateNoList)) { + if (gateNoList.length != 0) { + int count = 0; //统计声望值 + reputation.setUid(uid); + //遍历系列下的所有关卡 + for (File gate : gateNoList) { + String gateNo = gate.getName(); //关卡编号 + String playerStr = readJsonFile(playerFilePath, gateNo); + Player player = JSON.parseObject(playerStr, new TypeReference(){}); + reputation.setReputation(player.getReputation()); + //更新关卡排行榜 + PlayerUtil.updateGateNoReputation(player, reputation); + count += player.getReputation(); + } + reputation.setReputation(count); + //更新关卡排行榜 + PlayerUtil.updateSeriesReputation(uid, seriesName, reputation); + } + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 加载玩家系列数据 + */ + public static void loadSeriesPlayer(String uid, String seriesName) { + String dataPath = MD5Util.changeToDataPath(uid, seriesName); + Map> seriesReputationQueueMap = TimingAcquisition.seriesReputationQueueMap; + //取出存放玩家系列数据 + String playerSeriesStr = readJsonFile(dataPath, uid + ".json"); + if (!StringUtils.isEmpty(playerSeriesStr)) { + PlayerSeriesDto playerSeries = JSON.parseObject(playerSeriesStr, new TypeReference(){}); + //还没有该玩家的系列汇总数据 + if (StringUtils.isEmpty(TimingAcquisition.seriesPlayerMap.get(seriesName))) { + Map playerSeriesMap = new HashMap<>(); + playerSeriesMap.put(uid, playerSeries); + TimingAcquisition.seriesPlayerMap.put(seriesName, playerSeriesMap); + } else { + if (StringUtils.isEmpty(TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid))) { + TimingAcquisition.seriesPlayerMap.get(seriesName).put(uid, playerSeries); + } + } + //更新系列排行榜 + if (!StringUtils.isEmpty(playerSeries)) { + if (StringUtils.isEmpty(seriesReputationQueueMap.get(seriesName))) { + //新增系列排行榜 + PriorityBlockingQueue seriesReputationQueue = new PriorityBlockingQueue<>(); + seriesReputationQueue.add(playerSeries.getTotalReputation()); + seriesReputationQueueMap.put(seriesName, seriesReputationQueue); + } else { + //更新系列排行榜中用户的旧声望 + seriesReputationQueueMap.get(seriesName).add(playerSeries.getTotalReputation()); + } + } + } + } } diff --git a/src/main/java/com/qiwu/inference/common/utils/PlayerUtil.java b/src/main/java/com/qiwu/inference/common/utils/PlayerUtil.java index 00aa571..ab2a0e3 100644 --- a/src/main/java/com/qiwu/inference/common/utils/PlayerUtil.java +++ b/src/main/java/com/qiwu/inference/common/utils/PlayerUtil.java @@ -1,22 +1,78 @@ package com.qiwu.inference.common.utils; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; import com.qiwu.inference.common.Constants; import com.qiwu.inference.common.TimingAcquisition; +import com.qiwu.inference.common.api.CommonResult; import com.qiwu.inference.dto.*; +import com.qiwu.inference.dto.request.OperationRequest; +import com.qiwu.inference.dto.response.CallResponse; +import com.qiwu.inference.dto.response.ResultResponse; +import com.qiwu.inference.dto.response.ResultVarsResponse; +import com.qiwu.inference.factory.RemoteCallFactory; import com.qiwu.inference.pojo.Location; +import com.qiwu.inference.pojo.PartnerItem; +import com.qiwu.inference.service.remote.impl.RemoteGardenImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; import java.io.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.PriorityBlockingQueue; +@Component public class PlayerUtil { + static Logger log = LoggerFactory.getLogger(PlayerUtil.class); + + public static String expireTime; + @Value("${expireTime}") + public void setExpireTime(String expireTime) { + PlayerUtil.expireTime = expireTime; + } + public static String dataFilePath; + @Value("${dataFilePath}") + public void setDataFilePath(String dataFilePath) { + PlayerUtil.dataFilePath = dataFilePath; + } + + private static RemoteGardenImpl remoteGardenService; + @Autowired + public void setRemoteGardenService(RemoteGardenImpl remoteGardenService) { + PlayerUtil.remoteGardenService = remoteGardenService; + } + + private static RedisUtil redisUtil; + @Autowired + public void setRedisUtil(RedisUtil redisUtil) { + PlayerUtil.redisUtil = redisUtil; + } + + /** + * 通过玩家当前关卡拿到NPC数据 + */ + public static Map getPersonMap(String uid) { + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); + return TimingAcquisition.gatePersonMap.get(gateNo); + } + /** + * 通过玩家当前关卡拿到指定NPC数据 + */ + public static Person getPerson(String uid, Integer personId) { + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); + return TimingAcquisition.gatePersonMap.get(gateNo).get(personId); + } /** * 通过角色身份找到对应的人物名称 * @param name */ public static String getName(String uid, String name) { - Map personMap = TimingAcquisition.playerMap.get(uid).getPersonMap(); + Map personMap = getPersonMap(uid); for (Map.Entry entry : personMap.entrySet()) { Person person = entry.getValue(); //name为身份或人物名称 @@ -74,11 +130,151 @@ public class PlayerUtil { } /** + * 判断是否符合阈值需求 + * @param uid + * @param demandTask + * @param subject + * @return + */ + public static boolean checkThreshold(String uid, DemandTaskDto demandTask, PersonInfoDto subject){ + boolean flag = false; + boolean trustFlag = false; + boolean deterrenceFlag = false; + List allowTask = Arrays.asList(-2, -1, 0, 2, 5); + Map demandTaskSwitchMap = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(subject.getId()).getDemandTaskSwitchMap(); + //1.任务无需解锁或者任务已解锁 + if (allowTask.contains(demandTaskSwitchMap.get(demandTask.getDemandTaskId()))) { + //2.配置了任务条件id + if (demandTask.getConditionTaskId() != 0) { + //2.1已完成配置的任务条件id + if (checkTaskFinished(uid, demandTask.getConditionTaskId()) == 1) { + //配置了时间阈值 + if (!StringUtils.isEmpty(demandTask.getTimeThreshold())) { + //时间阈值有范围 + if (!"0|0".equals(demandTask.getTimeThreshold()) && !"0".equals(demandTask.getTimeThreshold())) { + int initTime = TimingAcquisition.playerMap.get(uid).getInitTime(); + String[] timeThresholds = demandTask.getTimeThreshold().split("\\|"); + boolean timeFlag = NumberUtil.inNumRange(initTime,"["+timeThresholds[0]+","+timeThresholds[1]+"]"); + //满足阈值条件 + if (timeFlag) { + //3.满足阈值 + if(demandTask.getTrustStart() >=0 && demandTask.getTrustEnd() > 0) { + trustFlag = NumberUtil.inNumRange(subject.getTrustDegree(),"["+demandTask.getTrustStart()+","+demandTask.getTrustEnd()+"]"); + } + if(demandTask.getDeterrenceStart() >= 0 && demandTask.getDeterrenceEnd() > 0) { + deterrenceFlag = NumberUtil.inNumRange(subject.getDeterrenceDegree(),"["+demandTask.getDeterrenceStart()+","+demandTask.getDeterrenceEnd()+"]"); + } + } + } else { //时间阈值没有配置范围 + //3.满足阈值 + if(demandTask.getTrustStart() >=0 && demandTask.getTrustEnd() > 0) { + trustFlag = NumberUtil.inNumRange(subject.getTrustDegree(),"["+demandTask.getTrustStart()+","+demandTask.getTrustEnd()+"]"); + } + if(demandTask.getDeterrenceStart() >= 0 && demandTask.getDeterrenceEnd() > 0) { + deterrenceFlag = NumberUtil.inNumRange(subject.getDeterrenceDegree(),"["+demandTask.getDeterrenceStart()+","+demandTask.getDeterrenceEnd()+"]"); + } + } + } else { //没有配置时间阈值 + //3.满足阈值 + if(demandTask.getTrustStart() >=0 && demandTask.getTrustEnd() > 0) { + trustFlag = NumberUtil.inNumRange(subject.getTrustDegree(),"["+demandTask.getTrustStart()+","+demandTask.getTrustEnd()+"]"); + } + if(demandTask.getDeterrenceStart() >= 0 && demandTask.getDeterrenceEnd() > 0) { + deterrenceFlag = NumberUtil.inNumRange(subject.getDeterrenceDegree(),"["+demandTask.getDeterrenceStart()+","+demandTask.getDeterrenceEnd()+"]"); + } + } + } + } else { //没有配置任务条件id + //配置了时间阈值 + if (!StringUtils.isEmpty(demandTask.getTimeThreshold())) { + if (!"0|0".equals(demandTask.getTimeThreshold()) && !"0".equals(demandTask.getTimeThreshold())) { + int initTime = TimingAcquisition.playerMap.get(uid).getInitTime(); + String[] timeThresholds = demandTask.getTimeThreshold().split("\\|"); + boolean timeFlag = NumberUtil.inNumRange(initTime, "[" + timeThresholds[0] + "," + timeThresholds[1] + "]"); + //满足阈值条件 + if (timeFlag) { + //3.满足阈值 + if (demandTask.getTrustStart() >= 0 && demandTask.getTrustEnd() > 0) { + trustFlag = NumberUtil.inNumRange(subject.getTrustDegree(), "[" + demandTask.getTrustStart() + "," + demandTask.getTrustEnd() + "]"); + } + if (demandTask.getDeterrenceStart() >= 0 && demandTask.getDeterrenceEnd() > 0) { + deterrenceFlag = NumberUtil.inNumRange(subject.getDeterrenceDegree(), "[" + demandTask.getDeterrenceStart() + "," + demandTask.getDeterrenceEnd() + "]"); + } + } + } else { //时间阈值没有配置范围 + //3.满足阈值 + if(demandTask.getTrustStart() >=0 && demandTask.getTrustEnd() > 0) { + trustFlag = NumberUtil.inNumRange(subject.getTrustDegree(),"["+demandTask.getTrustStart()+","+demandTask.getTrustEnd()+"]"); + } + if(demandTask.getDeterrenceStart() >= 0 && demandTask.getDeterrenceEnd() > 0) { + deterrenceFlag = NumberUtil.inNumRange(subject.getDeterrenceDegree(),"["+demandTask.getDeterrenceStart()+","+demandTask.getDeterrenceEnd()+"]"); + } + } + } else { //没有配置时间阈值 + //3.满足阈值 + if(demandTask.getTrustStart() >=0 && demandTask.getTrustEnd() > 0) { + trustFlag = NumberUtil.inNumRange(subject.getTrustDegree(),"["+demandTask.getTrustStart()+","+demandTask.getTrustEnd()+"]"); + } + if(demandTask.getDeterrenceStart() >= 0 && demandTask.getDeterrenceEnd() > 0) { + deterrenceFlag = NumberUtil.inNumRange(subject.getDeterrenceDegree(),"["+demandTask.getDeterrenceStart()+","+demandTask.getDeterrenceEnd()+"]"); + } + } + } + flag = trustFlag || deterrenceFlag; + } + return flag; + } + + /** + * 判断是否符合阈值需求,不判断是否解锁 + * @param demandTask + * @param subject + * @return + */ + public static boolean checkThresholdNoSwitch(DemandTaskDto demandTask, PersonInfoDto subject){ + boolean flag = false; + //任务无需解锁或者任务已解锁 + if(demandTask.getTrustStart() >=0 && demandTask.getTrustEnd() > 0) { + if(NumberUtil.inNumRange(subject.getTrustDegree(),"["+demandTask.getTrustStart()+","+demandTask.getTrustEnd()+"]")) { + flag = true; + } + } + if(demandTask.getDeterrenceStart() >= 0 && demandTask.getDeterrenceEnd() > 0) { + if(NumberUtil.inNumRange(subject.getDeterrenceDegree(),"["+demandTask.getDeterrenceStart()+","+demandTask.getDeterrenceEnd()+"]")) { + flag = true; + } + } + return flag; + } + + /** + * 判断是否符合阈值需求 + * @param person + * @param clueList + * @return + */ + public static List checkThresholdTalk(PersonInfoDto person, List clueList){ + List result = new ArrayList<>(); + for (int i= 0;i= clue.getTrustDegree()||person.getDeterrenceDegree() >= clue.getThreaten()){ + flag = true; + } + if(flag){ //符合阈值要求 + result.add(clue); + } + } + return result; + } + + /** * 获取玩家关卡中人物所在的所有场所 */ public static List getLocationByUid(String uid) { List locationList = new ArrayList<>(); - Map personMap = TimingAcquisition.playerMap.get(uid).getPersonMap(); + Map personMap = getPersonMap(uid); for (Map.Entry entry : personMap.entrySet()) { Person person = entry.getValue(); if (!StringUtils.isEmpty(person.getLocation())) { @@ -106,10 +302,12 @@ public class PlayerUtil { */ public static String getLocations(String uid) { StringBuilder text = new StringBuilder(); + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); //系列名称 Map locationMap = TimingAcquisition.playerMap.get(uid).getLocationMap(); for (Map.Entry entry : locationMap.entrySet()) { - if (!"1".equals(entry.getValue().getIsHidden())) { - text.append(TimingAcquisition.locationMap.get(entry.getKey()).getName()).append("、"); + //场所未隐藏 + if (!Constants.IS_HIDDEN.equals(entry.getValue().getIsHidden())) { + text.append(TimingAcquisition.seriesLocationMap.get(seriesName).get(entry.getKey()).getName()).append("、"); } } if (text.length() != 0) { @@ -119,6 +317,21 @@ public class PlayerUtil { } /** + * 获取玩家关卡中已知的所有场所 + */ + public static List getLocationIdsByUid(String uid) { + List locationList = new ArrayList<>(); + Map locationMap = TimingAcquisition.playerMap.get(uid).getLocationMap(); + for (Map.Entry entry : locationMap.entrySet()) { + //场所未隐藏 + if (!Constants.IS_HIDDEN.equals(entry.getValue().getIsHidden())) { + locationList.add(entry.getKey()); + } + } + return locationList; + } + + /** * 通过场所id找到场所的所有人物 */ public static List getPersonsByLocationId(String uid, String locationId) { @@ -138,13 +351,14 @@ public class PlayerUtil { */ public static List getRelativePersonIds(String uid, Integer personId) { List personIdList = new ArrayList<>(); + Map personMap = getPersonMap(uid); //指定人物拥有的关系 - List relations = TimingAcquisition.playerMap.get(uid).getPersonMap().get(personId).getRelations(); - List clues = TimingAcquisition.playerMap.get(uid).getPersonMap().get(personId).getClues(); + List relations = personMap.get(personId).getRelations(); + List clues = personMap.get(personId).getClues(); //信任值 - Integer trustDegree = TimingAcquisition.playerMap.get(uid).getPersonMap().get(personId).getTrustDegree(); + Integer trustDegree = personMap.get(personId).getTrustDegree(); //威慑度 - Integer deterrenceDegree = TimingAcquisition.playerMap.get(uid).getPersonMap().get(personId).getDeterrenceDegree(); + Integer deterrenceDegree = personMap.get(personId).getDeterrenceDegree(); int max = trustDegree; //遍历所有关系 for (RelationDto relation : relations) { @@ -169,37 +383,49 @@ public class PlayerUtil { * 记录玩家已获得线索 */ public static void recordClue(String uid, Integer sourceId, Integer personId, Integer clueTypeId, ClueDto clue) { - Map>> clueMap = TimingAcquisition.playerMap.get(uid).getClueMap(); - Map> clueListMap = new ConcurrentHashMap<>(); - List clueList = new ArrayList<>(); + Map>> clueMap = TimingAcquisition.playerMap.get(uid).getClueMap(); + Map> clueListMap = new ConcurrentHashMap<>(); + List clueList = new ArrayList<>(); //线索来源的人物id List sourceIdList = new ArrayList<>(); sourceIdList.add(sourceId); + //记录线索信息 + ClueInfoDto clueInfo = new ClueInfoDto(); + clueInfo.setId(clue.getId()); + clueInfo.setClueId(clue.getClueId()); + clueInfo.setSubject(clue.getSubject()); + clueInfo.setObject(clue.getObject()); + clueInfo.setType(clue.getType()); //玩家还没有收集此人的线索 if (StringUtils.isEmpty(clueMap.get(personId))) { - clue.setSourceIdList(sourceIdList); - clueList.add(clue); + Map> clueSourceMap = new ConcurrentHashMap<>(); + clueSourceMap.put(clue.getClueId(), sourceIdList); + TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(personId).setClueSourceMap(clueSourceMap); + clueList.add(clueInfo); clueListMap.put(clueTypeId, clueList); clueMap.put(personId, clueListMap); return; } //玩家还没有收集到此人这类的线索 if (StringUtils.isEmpty(clueMap.get(personId).get(clueTypeId))) { - clue.setSourceIdList(sourceIdList); - clueList.add(clue); + Map> clueSourceMap = new ConcurrentHashMap<>(); + clueSourceMap.put(clue.getClueId(), sourceIdList); + TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(personId).setClueSourceMap(clueSourceMap); + clueList.add(clueInfo); clueListMap.put(clueTypeId, clueList); clueMap.get(personId).putAll(clueListMap); return; } //玩家还没有收集到这条线索 - List clues = clueMap.get(personId).get(clueTypeId); + List clues = clueMap.get(personId).get(clueTypeId); boolean have = false; - for (ClueDto c : clues) { + for (ClueInfoDto c : clues) { if (c.getClueId() == clue.getClueId()) { + List sourceIds = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(personId).getClueSourceMap().get(c.getClueId()); //找到了同样的线索,则新增来源 //不为同一个人 - if (!c.getSourceIdList().contains(sourceId)) { - c.getSourceIdList().add(sourceId); + if (!sourceIds.contains(sourceId)) { + sourceIds.add(sourceId); } have = true; break; @@ -207,8 +433,8 @@ public class PlayerUtil { } //没有找到则新增一条线索 if (!have) { - clue.setSourceIdList(sourceIdList); - clues.add(clue); + TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(personId).getClueSourceMap().put(clue.getClueId(), sourceIdList); + clues.add(clueInfo); } } @@ -216,7 +442,7 @@ public class PlayerUtil { * 记录玩家已获得线索 */ public static void recordClue(String uid, Integer personId) { - Map>> clueMap = TimingAcquisition.playerMap.get(uid).getClueMap(); + Map>> clueMap = TimingAcquisition.playerMap.get(uid).getClueMap(); //玩家见过这个人 if (!StringUtils.isEmpty(clueMap.get(personId))) { return; @@ -229,20 +455,21 @@ public class PlayerUtil { * @param clueList * @param type */ - public static List checkClueType(List clueList, String type) { + public static List checkClueType(String uid, List clueList, String type) { List result = new ArrayList<>(); + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); //系列名称 for (ClueDto clueDto : clueList) { //关联的性格id - Integer associatedId = TimingAcquisition.clueMap.get(clueDto.getClueId()).getAssociatedId(); + Integer associatedId = TimingAcquisition.seriesClueMap.get(seriesName).get(clueDto.getClueId()).getAssociatedId(); if ("1".equals(type) || "3".equals(type)) { List typeList = new ArrayList<>(); typeList.add("1"); typeList.add("3"); - if (typeList.contains(TimingAcquisition.dispositionMap.get(associatedId).getType())) { + if (typeList.contains(TimingAcquisition.seriesDispositionMap.get(seriesName).get(associatedId).getType())) { result.add(clueDto); } } else { - if (type.equals(TimingAcquisition.dispositionMap.get(associatedId).getType())) { + if (type.equals(TimingAcquisition.seriesDispositionMap.get(seriesName).get(associatedId).getType())) { result.add(clueDto); } } @@ -308,7 +535,7 @@ public class PlayerUtil { public static List getClueByTypeAndTaskId(String uid, Integer personId, String taskId) { List result = new ArrayList<>(); Integer currentId = TimingAcquisition.playerMap.get(uid).getPersonId(); - Person current = TimingAcquisition.playerMap.get(uid).getPersonMap().get(currentId); + Person current = getPersonMap(uid).get(currentId); if(!StringUtils.isEmpty(current)){ //通过任务条件id找到玩家需求任务集合 List demandTaskList = findDemandsByTaskId(current, personId, taskId); @@ -326,6 +553,64 @@ public class PlayerUtil { } /** + * 找到当前NPC身上,关于指定人物对应任务条件id的线索 + * @param uid + * @param subjectId + * @param conditionTaskId + */ + public static List getClueByConditionTaskId(String uid, Integer subjectId, String conditionTaskId) { + List result = new ArrayList<>(); + Integer currentId = TimingAcquisition.playerMap.get(uid).getPersonId(); + Person current = getPersonMap(uid).get(currentId); + Person subject = getPersonMap(uid).get(subjectId); + if(!StringUtils.isEmpty(current)){ + //通过任务条件id找到玩家需求任务集合 + List demandTaskList = findDemandsByTaskId(subject, subjectId, conditionTaskId); + for (DemandTaskDto demandTask : demandTaskList) { + //找到对应的任务线索id + Integer clueId = demandTask.getClueId(); + //找到对应线索 + ClueDto clue = getClueById(uid, currentId, clueId); + if (!StringUtils.isEmpty(clue)) { + result.add(clue); + } + } + } + return result; + } + + /** + * 找到对应类型且达到阈值的线索 + */ + public static List getCluesByType(Person person, int clueType, int infoLevel) { + List result = new ArrayList<>(); + List clueList = person.getClues(); + if (clueType == 0) { + for (ClueDto clue : clueList) { + //线索大于等于指定层级 + if (clue.getInfoLevel() >= infoLevel) { + if (person.getTrustDegree() >= clue.getTrustDegree() || person.getDeterrenceDegree() >= clue.getThreaten()) { + result.add(clue); + } + } + } + } else { + for (ClueDto clue : clueList) { + //为指定类型 + if (clue.getType() == clueType) { + //线索大于等于指定层级 + if (clue.getInfoLevel() >= infoLevel) { + if (person.getTrustDegree() >= clue.getTrustDegree() || person.getDeterrenceDegree() >= clue.getThreaten()) { + result.add(clue); + } + } + } + } + } + return result; + } + + /** * 查询符合条件的任务 * @param person * @param taskTarget 1 信任度提升 2 信任度降低 3 威慑度提升 4 威慑度降低 @@ -398,13 +683,13 @@ public class PlayerUtil { /** * 通过线索id找到对应线索 - * @param current + * @param person * @param clueId */ - public static ClueDto getClueById(Person current, Integer clueId) { - List clueList = current.getClues(); + public static ClueDto getClueById(Person person, Integer clueId, Integer type) { + List clueList = person.getClues(); for (ClueDto clue : clueList) { - if (clueId.equals(clue.getClueId())) { + if (clueId.equals(clue.getClueId()) && type.equals(clue.getType())) { return clue; } } @@ -418,7 +703,7 @@ public class PlayerUtil { * @param clueId */ public static ClueDto getClueById(String uid, Integer personId, Integer clueId) { - List clueList = TimingAcquisition.playerMap.get(uid).getPersonMap().get(personId).getClues(); + List clueList = getPersonMap(uid).get(personId).getClues(); for (ClueDto clue : clueList) { if (clueId.equals(clue.getClueId())) { return clue; @@ -428,6 +713,51 @@ public class PlayerUtil { } /** + * 通过线索id在主体身上找到对应线索 + * @param person + * @param demandTaskDto + */ + public static ClueDto getPreClueById(Person person, DemandTaskDto demandTaskDto) { + List demandTaskList = person.getDemandTasks(); + List clueList = new ArrayList<>(); + if (!StringUtils.isEmpty(demandTaskDto)) { + for (DemandTaskDto demandTask : demandTaskList) { + if (demandTask.getDemandTaskId() == demandTaskDto.getDemandTaskId() + && demandTask.getSubject() == demandTaskDto.getSubject()) { + ClueDto clue = getClueById(person, demandTask.getClueId(), demandTask.getType()); + if (!StringUtils.isEmpty(clue)) { + clueList.add(clue); + } + } + } + } + if (clueList.size() > 1) { + for (ClueDto clue : clueList) { + if (clue.getType() != 6) { + return clue; + } + } + } + if (clueList.size() == 1) { + return clueList.get(0); + } + return null; + } + + /** + * 通过线索id找到需求任务 + */ + public static DemandTaskDto getDemandTaskByClueId(Person person, ClueDto clue) { + List demandTaskList = person.getDemandTasks(); + for (DemandTaskDto demandTask : demandTaskList) { + if (clue.getClueId() == demandTask.getClueId() && clue.getSubject() == demandTask.getSubject()) { + return demandTask; + } + } + return null; + } + + /** * 通过线索id找到需求任务 */ public static DemandTaskDto getDemandTaskByClueId(Person person, Integer clueId) { @@ -468,7 +798,7 @@ public class PlayerUtil { * 通过任务id找到对应的任务 */ public static DemandTaskDto getDemandTaskById(String uid, Integer personId, Integer taskId) { - List demandTaskList = TimingAcquisition.playerMap.get(uid).getPersonMap().get(personId).getDemandTasks(); + List demandTaskList = getPerson(uid, personId).getDemandTasks(); for (DemandTaskDto demandTask:demandTaskList) { if (demandTask.getDemandTaskId() == taskId && demandTask.getType() == 6 && demandTask.getSubject() == personId) { return demandTask; @@ -480,37 +810,63 @@ public class PlayerUtil { /** * 根据线索找到对应任务,判断任务是否需要解锁,需要则改为解锁状态 */ - public static void unlockTask(String uid, Person person, ClueDto clue) { - List demandTaskList = person.getDemandTasks(); + public static void unlockTask(String uid, PersonInfoDto person, ClueDto clue) { + Map demandTaskSwitchMap = person.getDemandTaskSwitchMap(); String postTaskId = null; //本人身上该任务解锁 - for (DemandTaskDto demandTask : demandTaskList) { - if (demandTask.getClueId() == clue.getClueId() && demandTask.getType() == clue.getType()) { - //需解锁任务 - if (demandTask.getClueSwitch() == 1) { - demandTask.setClueSwitch(2); - postTaskId = demandTask.getPostTask(); - for (DemandTaskDto task : demandTaskList) { - if (task.getDemandTaskId() == demandTask.getDemandTaskId()) { - task.setClueSwitch(2); + for (Map.Entry entry: demandTaskSwitchMap.entrySet()) { + DemandTaskDto demandTask = getDemandTaskById(uid, person.getId(), entry.getKey()); + if (!StringUtils.isEmpty(demandTask)) { + if (demandTask.getClueId() == clue.getClueId() && demandTask.getType() == clue.getType()) { + //需解锁任务 + if (entry.getValue() == 1) { + entry.setValue(2); + postTaskId = demandTask.getPostTask(); + //有相同任务id的也解锁 + for (Map.Entry e : demandTaskSwitchMap.entrySet()) { + if (e.getKey() == demandTask.getDemandTaskId()) { + e.setValue(2); + } } } } } } - if (!StringUtils.isEmpty(postTaskId)) { - //线索对应人物解锁 - int objectId = clue.getSubject(); - if (person.getId() == clue.getSubject()) { - objectId = clue.getObject(); + int objectId = clue.getSubject(); + if (person.getId() == clue.getSubject()) { + objectId = clue.getObject(); + } + //线索主体为当前对话人时,解锁对应的任务 + if (person.getId().equals(clue.getSubject())) { + //解锁后置任务 + if (!StringUtils.isEmpty(postTaskId)) { + //线索对应任务解锁 + Map demandTaskSwitchObjectMap = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(objectId).getDemandTaskSwitchMap(); + //客体身上该任务解锁 + for (Map.Entry entry: demandTaskSwitchObjectMap.entrySet()) { + DemandTaskDto demandTask = getDemandTaskById(uid, person.getId(), entry.getKey()); + if (!StringUtils.isEmpty(demandTask)) { + if (demandTask.getDemandTaskId() == Integer.parseInt(postTaskId)) { + //需解锁任务 + if (entry.getValue() == 1) { + entry.setValue(2); + } + } + } + } } - List demandTaskObjectList = TimingAcquisition.playerMap.get(uid).getPersonMap().get(objectId).getDemandTasks(); + } else { + //线索对应他人的任务解锁 + Map demandTaskSwitchObjectMap = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(objectId).getDemandTaskSwitchMap(); //客体身上该任务解锁 - for (DemandTaskDto demandTask : demandTaskObjectList) { - if (demandTask.getDemandTaskId() == Integer.parseInt(postTaskId)) { - //需解锁任务 - if (demandTask.getClueSwitch() == 1) { - demandTask.setClueSwitch(2); + for (Map.Entry entry: demandTaskSwitchObjectMap.entrySet()) { + DemandTaskDto demandTask = getDemandTaskById(uid, person.getId(), entry.getKey()); + if (!StringUtils.isEmpty(demandTask)) { + if (demandTask.getClueId() == clue.getClueId()) { + //需解锁任务 + if (entry.getValue() == 1) { + entry.setValue(2); + } } } } @@ -521,14 +877,15 @@ public class PlayerUtil { * 根据线索找到对应任务,判断任务是否需要解锁,需要则改为解锁状态 */ public static void unlockTask(String uid, ClueDto clue) { - Map personMap = TimingAcquisition.playerMap.get(uid).getPersonMap(); - for (Map.Entry entry : personMap.entrySet()) { - Person person = entry.getValue(); + Map personInfoMap = TimingAcquisition.playerMap.get(uid).getPersonInfoMap(); + for (Map.Entry entry : personInfoMap.entrySet()) { + Person person = getPerson(uid, entry.getKey()); DemandTaskDto demandTask = getDemandTaskByClueId(person, clue.getClueId()); if (!StringUtils.isEmpty(demandTask)) { + Integer clueSwitch = entry.getValue().getDemandTaskSwitchMap().get(demandTask.getDemandTaskId()); //需解锁任务 - if (demandTask.getClueSwitch() == 1) { - demandTask.setClueSwitch(2); + if (clueSwitch == 1) { + clueSwitch = 2; } } } @@ -544,9 +901,9 @@ public class PlayerUtil { List result = new ArrayList<>(); Integer talkPersonId = TimingAcquisition.playerMap.get(uid).getPersonId(); //信任值 - Integer trustDegree = TimingAcquisition.playerMap.get(uid).getPersonMap().get(talkPersonId).getTrustDegree(); + Integer trustDegree = getPerson(uid, talkPersonId).getTrustDegree(); //威慑度 - Integer deterrenceDegree = TimingAcquisition.playerMap.get(uid).getPersonMap().get(talkPersonId).getDeterrenceDegree(); + Integer deterrenceDegree = getPerson(uid, talkPersonId).getDeterrenceDegree(); for (ClueDto clue : clueList) { if (trustDegree >= clue.getTrustDegree() || deterrenceDegree >= clue.getThreaten()) { result.add(clue); @@ -630,7 +987,7 @@ public class PlayerUtil { * @param subject * @param demandTask */ - public static void addThreshold(Person subject, DemandTaskDto demandTask) { + public static void addThreshold(PersonInfoDto subject, DemandTaskDto demandTask) { if(demandTask.getTrustDegree() != 0) { if(subject.getTrustDegree() <= 100) { if((subject.getTrustDegree() + demandTask.getTrustDegree() ) > 100) { @@ -657,15 +1014,81 @@ public class PlayerUtil { */ public static void resetPlayer(String uid) { Player player = TimingAcquisition.playerMap.get(uid); - player.setClueMap(new HashMap<>()); - player.setTaskMap(new HashMap<>()); - player.setCurrency(0.0); - player.setPoint(0); - for (Map.Entry entry : player.getPersonMap().entrySet()) { + //初始化推理游戏人物 + List personsCopy = TimingAcquisition.gateInfoMap.get(player.getGateNo()); + //深拷贝list + List personCopyList = PlayerUtil.deepCopyList(personsCopy); + Map> taskMap = new HashMap<>(); + Map personInfoMap = new HashMap<>(); + Map name2IdMap = new HashMap<>(); + Map id2NameMap = new HashMap<>(); + for (Person person : personCopyList) { + taskMap.put(person.getId(), new HashMap<>()); + name2IdMap.put(person.getName(), person.getId()); + id2NameMap.put(person.getId(), person.getName()); + //NPC相关数据 + PersonInfoDto personInfo = new PersonInfoDto(); + Map> clueSourceMap = new ConcurrentHashMap<>(); + Map demandTaskSwitchMap = new ConcurrentHashMap<>(); + personInfo.setId(person.getId()); + List clueList = person.getClues(); + for (ClueDto clue : clueList) { + clueSourceMap.put(clue.getClueId(), new ArrayList<>()); + } + List demandTaskList = person.getDemandTasks(); + for (DemandTaskDto demandTask : demandTaskList) { + demandTaskSwitchMap.put(demandTask.getDemandTaskId(), demandTask.getClueSwitch()); + } + personInfo.setClueSourceMap(clueSourceMap); + personInfo.setDemandTaskSwitchMap(demandTaskSwitchMap); + personInfoMap.put(person.getId(), personInfo); + } + player.setTaskMap(taskMap); + player.setPersonInfoMap(personInfoMap); + player.setName2IdMap(name2IdMap); + player.setId2NameMap(id2NameMap); + //给玩家分配场所和对话人物 + Map> locationPersonMap = new HashMap<>(); + Map personMap = getPersonMap(uid); + for (Map.Entry entry : personMap.entrySet()) { Person person = entry.getValue(); - person.setTrustDegree(0); - person.setDeterrenceDegree(0); + if (!StringUtils.isEmpty(person.getLocation())) { + //没有当前场所 + if (StringUtils.isEmpty(locationPersonMap.get(person.getLocation()))) { + List personList = new ArrayList<>(); + personList.add(entry.getKey()); + locationPersonMap.put(person.getLocation(), personList); + } + //有当前场所,但是没有这个人 + List persons = locationPersonMap.get(person.getLocation()); + if (!persons.contains(entry.getKey())) { + persons.add(entry.getKey()); + } + } } + List locationList = new ArrayList<>(locationPersonMap.keySet()); + int index = RandomUtil.randomInt(locationList.size()); + String locationId = locationList.get(index); + player.setLocation(locationId); + //随机分配人物 + List personList = locationPersonMap.get(locationId); + int num = RandomUtil.randomInt(personList.size()); + player.setPersonId(personList.get(num)); + //生成场所表,包含场所隐藏状态和必现场所 + Map locationMap = PlayerUtil.makeLocationMap(uid, locationPersonMap, player.getSeries()); + player.setLocationMap(locationMap); + //玩家当前关卡已经消耗的货币值 +// double currency = player.getCurrency(); +// //玩家系列汇总的货币值 +// int money = TimingAcquisition.seriesPlayerMap.get(player.getSeries()).get(uid).getMoney(); +// player.setCurrency((double) money + currency); + player.setPoint(0); + player.setClueMap(new HashMap<>()); + player.setFinishedTaskNum(0); + player.setTipFlag(false); + player.setOperateTextNum(1); + player.setAskAndNumMap(new HashMap<>()); + player.setFinished(0); } /** @@ -675,7 +1098,7 @@ public class PlayerUtil { Player player = TimingAcquisition.playerMap.get(uid); player.setClueMap(new HashMap<>()); player.setTaskMap(new HashMap<>()); - player.setCurrency(0.0); +// player.setCurrency(0.0); player.setPoint(0); } @@ -693,10 +1116,11 @@ public class PlayerUtil { /** * 生成场所表 + * @param locationPersonMap */ - public static Map makeLocationMap(Map> locationPersonMap) { + public static Map makeLocationMap(String uid, Map> locationPersonMap, String seriesName) { Map locationInfoMap = new HashMap<>(); - Map locationMap = TimingAcquisition.locationMap; + Map locationMap = TimingAcquisition.seriesLocationMap.get(seriesName); //遍历所有场所,找到所有已知和必现场所 for (Map.Entry entry : locationMap.entrySet()) { LocationInfoDto locationInfo = new LocationInfoDto(); @@ -729,11 +1153,11 @@ public class PlayerUtil { * @param clueMap * @param personId */ - public static boolean checkLocationClue(Map>> clueMap, Integer personId) { - Map> personClueMap = clueMap.get(personId); + public static boolean checkLocationClue(Map>> clueMap, Integer personId) { + Map> personClueMap = clueMap.get(personId); //有这个人的线索 if (!StringUtils.isEmpty(personClueMap)) { - List clueList = personClueMap.get(2); + List clueList = personClueMap.get(2); //有这个人场所线索 return !StringUtils.isEmpty(clueList); } @@ -741,6 +1165,23 @@ public class PlayerUtil { } /** + * 判断玩家是否已经见过某个人 + * @param locationMap + * @param personId + */ + public static boolean checkHaveMeet(Map locationMap, String locationId, Integer personId) { + //指定场所已有的人物见面次数 + Map personInfoMap = locationMap.get(locationId).getPersonInfoMap(); + if (!StringUtils.isEmpty(personInfoMap.get(personId))) { + int meetTimes = personInfoMap.get(personId); + if (meetTimes > 0) { + return true; + } + } + return false; + } + + /** * 解锁场所 * @param locationMap * @param locationId @@ -749,17 +1190,20 @@ public class PlayerUtil { //场所未解锁 String isHidden = locationMap.get(locationId).getIsHidden(); if ("1".equals(isHidden)) { - locationMap.get(locationId).setIsHidden("1"); + locationMap.get(locationId).setIsHidden("0"); } } /** * 查找有前置任务的任务 + * @param uid + * @param personIdList */ public static List getDemandTaskHavePre(String uid, List personIdList) { List postTaskStatusList = new ArrayList<>(); //所有人物 - Map personMap = TimingAcquisition.playerMap.get(uid).getPersonMap(); + Map personMap = getPersonMap(uid); + List allowTask = Arrays.asList(-1, 0, 2, 5); //遍历所有人物 for (Integer personId : personIdList) { //该人物身上挂的任务 @@ -769,19 +1213,52 @@ public class PlayerUtil { Map taskStatusMap = new HashMap<>(); //判断任务是否有前置任务 for (DemandTaskDto demandTask : demandTasks) { - //该任务有前置任务,则为后置任务 - if (!StringUtils.isEmpty(demandTask.getPostTask())) { - //判断后置任务是否已经完成 - int flag = checkTaskStatus(uid, personId, demandTask.getDemandTaskId()); - //未完成 - if (flag == 0) { - TaskStatusDto taskStatus = new TaskStatusDto(); - //判断前置任务是否已经完成 - Integer postTaskId = Integer.valueOf(demandTask.getPostTask()); - int finished = checkTaskStatus(uid, demandTask.getObject(), postTaskId); - taskStatus.setTaskId(postTaskId); - taskStatus.setStatus(finished); - taskStatusMap.put(demandTask.getDemandTaskId(), taskStatus); + PersonInfoDto personInfo = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(personId); + //判断是否符合阈值需求 + boolean conditionFlag = checkThreshold(uid, demandTask, personInfo); + //满足阈值条件 + if (conditionFlag) { + //该任务有前置任务,则为后置任务 + if (!StringUtils.isEmpty(demandTask.getPostTask())) { + //判断后置任务是否已经完成 + int flag = checkTaskStatus(uid, personId, demandTask.getDemandTaskId()); + //未完成 + if (flag == 0) { + TaskStatusDto taskStatus = new TaskStatusDto(); + //判断前置任务是否已经完成 + Integer postTaskId = Integer.valueOf(demandTask.getPostTask()); + int finished = checkTaskStatus(uid, demandTask.getObject(), postTaskId); + taskStatus.setTaskId(postTaskId); + taskStatus.setStatus(finished); + taskStatusMap.put(demandTask.getDemandTaskId(), taskStatus); + } + } + //该任务为自动触发任务 + if (demandTask.getIsAuto() == 1) { + Map demandTaskSwitchMap = personInfo.getDemandTaskSwitchMap(); + if (allowTask.contains(demandTaskSwitchMap.get(demandTask.getDemandTaskId()))) { + //存在任务 + if (StringUtils.isEmpty(taskStatusMap.get(demandTask.getDemandTaskId()))) { + //判断任务是否完成 + int flag = checkTaskStatus(uid, personId, demandTask.getDemandTaskId()); + //未完成 + if (flag == 0) { + TaskStatusDto taskStatus = new TaskStatusDto(); + if (!StringUtils.isEmpty(demandTask.getPostTask())) { + //判断前置任务是否已经完成 + Integer postTaskId = Integer.valueOf(demandTask.getPostTask()); + //前置任务的完成情况 + int finished = checkTaskStatus(uid, demandTask.getObject(), postTaskId); + taskStatus.setTaskId(postTaskId); + taskStatus.setStatus(finished); + } else { + taskStatus.setTaskId(0); + taskStatus.setStatus(0); + } + taskStatusMap.put(demandTask.getDemandTaskId(), taskStatus); + } + } + } } } } @@ -795,29 +1272,66 @@ public class PlayerUtil { /** * 查找单个人有前置任务的任务 + * @param uid + * @param personId */ public static List getDemandTaskHavePre(String uid, Integer personId) { List postTaskStatusList = new ArrayList<>(); //该人物身上挂的任务 - List demandTasks = TimingAcquisition.playerMap.get(uid).getPersonMap().get(personId).getDemandTasks(); + List demandTasks = getPerson(uid, personId).getDemandTasks(); PostTaskDto postTask = new PostTaskDto(); postTask.setPersonId(personId); + //保存前后置任务对应关系的map Map taskStatusMap = new HashMap<>(); + List allowTask = Arrays.asList(-1, 0, 2, 5); //判断任务是否有前置任务 for (DemandTaskDto demandTask : demandTasks) { - //该任务有前置任务,则为后置任务 - if (!StringUtils.isEmpty(demandTask.getPostTask())) { - //判断后置任务是否已经完成 - int flag = checkTaskStatus(uid, personId, demandTask.getDemandTaskId()); - //未完成 - if (flag == 0) { - TaskStatusDto taskStatus = new TaskStatusDto(); - //判断前置任务是否已经完成 - Integer postTaskId = Integer.valueOf(demandTask.getPostTask()); - int finished = checkTaskStatus(uid, demandTask.getObject(), postTaskId); - taskStatus.setTaskId(postTaskId); - taskStatus.setStatus(finished); - taskStatusMap.put(demandTask.getDemandTaskId(), taskStatus); + PersonInfoDto personInfo = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(personId); + //判断是否符合阈值需求 + boolean conditionFlag = checkThreshold(uid, demandTask, personInfo); + //满足阈值条件 + if (conditionFlag) { + //该任务有前置任务,则为后置任务 + if (!StringUtils.isEmpty(demandTask.getPostTask())) { + //判断后置任务是否已经完成 + int flag = checkTaskStatus(uid, personId, demandTask.getDemandTaskId()); + //未完成 + if (flag == 0) { + TaskStatusDto taskStatus = new TaskStatusDto(); + //判断前置任务是否已经完成 + Integer postTaskId = Integer.valueOf(demandTask.getPostTask()); + int finished = checkTaskStatus(uid, demandTask.getObject(), postTaskId); + taskStatus.setTaskId(postTaskId); + taskStatus.setStatus(finished); + taskStatusMap.put(demandTask.getDemandTaskId(), taskStatus); + } + } + //该任务为自动触发任务 + if (demandTask.getIsAuto() == 1) { + Map demandTaskSwitchMap = personInfo.getDemandTaskSwitchMap(); + if (allowTask.contains(demandTaskSwitchMap.get(demandTask.getDemandTaskId()))) { + //存在任务 + if (StringUtils.isEmpty(taskStatusMap.get(demandTask.getDemandTaskId()))) { + //判断任务是否完成 + int flag = checkTaskStatus(uid, personId, demandTask.getDemandTaskId()); + //未完成 + if (flag == 0) { + TaskStatusDto taskStatus = new TaskStatusDto(); + if (!StringUtils.isEmpty(demandTask.getPostTask())) { + //判断前置任务是否已经完成 + Integer postTaskId = Integer.valueOf(demandTask.getPostTask()); + //前置任务的完成情况 + int finished = checkTaskStatus(uid, demandTask.getObject(), postTaskId); + taskStatus.setTaskId(postTaskId); + taskStatus.setStatus(finished); + } else { + taskStatus.setTaskId(0); + taskStatus.setStatus(0); + } + taskStatusMap.put(demandTask.getDemandTaskId(), taskStatus); + } + } + } } } } @@ -829,9 +1343,12 @@ public class PlayerUtil { } /** - * 判断任务是否已经完成,0-未完成,1-已完成 - */ - public static int checkTaskStatus(String uid, Integer personId, Integer taskId) { + * 判断某人的任务是否已经完成,0-未完成,1-已完成 + * @param uid + * @param personId + * @param taskId + */ + public static int checkTaskStatus(String uid, Integer personId, Integer taskId) { Map taskStatusMap = TimingAcquisition.playerMap.get(uid).getTaskMap().get(personId); if (!StringUtils.isEmpty(taskStatusMap.get(taskId))) { return 1; @@ -840,55 +1357,177 @@ public class PlayerUtil { } /** - * 后置任务的提示按优先级查找 + * 判断任务是否已经完成,0-未完成,1-已完成 + * @param uid + * @param taskId + */ + public static int checkTaskFinished(String uid, Integer taskId) { + Map> taskStatusMap = TimingAcquisition.playerMap.get(uid).getTaskMap(); + for (Map.Entry> entry : taskStatusMap.entrySet()) { + if (!StringUtils.isEmpty(entry.getValue().get(taskId))) { + return 1; + } + } + return 0; + } + + /** + * 后置任务的提示按优先级查找,返回目前优先级最高 + * @param uid + * @param postTaskList */ public static PostTaskRecordDto getPostTask(String uid, List postTaskList) { PostTaskRecordDto postTaskRecord = new PostTaskRecordDto(); List postTaskRecordList = new ArrayList<>(); - //遍历每个人 + //允许选择的任务类型 + List allowTask = Arrays.asList(-2, -1, 0, 2, 5); + //遍历每个任务 for (PostTaskDto postTask : postTaskList) { Map taskStatusMap = postTask.getTaskStatusMap(); + PersonInfoDto talk = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(postTask.getPersonId()); for (Map.Entry entry : taskStatusMap.entrySet()) { - Integer postTaskId = entry.getKey(); - TaskStatusDto taskStatus = entry.getValue(); + Integer postTaskId = entry.getKey(); //后置任务id + TaskStatusDto taskStatus = entry.getValue(); //前置任务id及其状态 + //通过人物的后置任务id找到任务信息 DemandTaskDto demandTask = getDemandTaskInfo(uid, postTask.getPersonId(), postTaskId); - //有前置任务已完成 - if (taskStatus.getStatus() == 1) { - if (!StringUtils.isEmpty(demandTask)) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - //任务条件为“70043” - if ("70043".equals(condition1[0])) { - postTaskRecord.setPersonId(postTask.getPersonId()); - postTaskRecord.setPostTaskId(postTaskId); - postTaskRecord.setPreTaskId(taskStatus.getTaskId()); - postTaskRecord.setStatus(taskStatus.getStatus()); - boolean flag = checkTaskSelf(uid, postTask.getPersonId(), demandTask.getClueId()); - if (flag) { - postTaskRecord.setLevel(1); //前置任务已完成且是自己发布 - } else { - postTaskRecord.setLevel(2); //前置任务已完成且不是自己发布 + //是前后置任务 + if (!StringUtils.isEmpty(taskStatus)) { + //1.有前置任务已完成 + if (taskStatus.getStatus() == 1) { + if (!StringUtils.isEmpty(demandTask)) { + String[] condition1 = demandTask.getCondition1().split("\\|"); + //任务条件为“70043” + if ("70043".equals(condition1[0])) { + postTaskRecord.setPersonId(postTask.getPersonId()); + postTaskRecord.setPostTaskId(postTaskId); //后置任务 + postTaskRecord.setPreTaskId(taskStatus.getTaskId()); //前置任务 + postTaskRecord.setStatus(taskStatus.getStatus()); + //任务是否为自己发布 + boolean flag = checkTaskSelf(uid, postTask.getPersonId(), demandTask.getClueId()); + if (flag) { + postTaskRecord.setLevel(1); //1.前置任务已完成且是自己发布 + } else { + postTaskRecord.setLevel(2); //2.前置任务已完成且不是自己发布 + } + return postTaskRecord; } - return postTaskRecord; } } + //前置任务为自动触发的 +// if (taskStatus.getStatus() == 0 && taskStatus.getTaskId() != 0) { +// DemandTaskDto demandTaskPre = getDemandTaskInfo(uid, postTask.getPersonId(), taskStatus.getTaskId()); +// if (!StringUtils.isEmpty(demandTaskPre)) { +// //前置任务为自动触发 +// if (demandTaskPre.getIsAuto() == 1) { +// //前置任务已启动或能直接执行 +// int clueSwitch = talk.getDemandTaskSwitchMap().get(demandTaskPre.getDemandTaskId()); +// if (allowTask.contains(clueSwitch)) { +// String[] condition1 = demandTaskPre.getCondition1().split("\\|"); +// PostTaskRecordDto postTaskRecordCopy = new PostTaskRecordDto(); +// postTaskRecordCopy.setPersonId(demandTaskPre.getSubject()); +// postTaskRecordCopy.setPostTaskId(taskStatus.getTaskId()); //后置任务 +// postTaskRecordCopy.setPreTaskId(0); //前置任务 +// postTaskRecordCopy.setStatus(taskStatus.getStatus()); +// //任务是否为71000自动完成 +// if ("71000".equals(condition1[0])) { +// postTaskRecordCopy.setLevel(3); //3.任务为自动触发完成 +// } else { +// //任务为本人发布 +// boolean selfSign = checkTaskSelf(uid, postTask.getPersonId(), demandTask.getClueId()); +// if (!selfSign) { +// postTaskRecordCopy.setLevel(4); //4.任务为自动发布 +// } else { +// postTaskRecordCopy.setLevel(5); //5.任务为本人发布 +// } +// } +// postTaskRecordList.add(postTaskRecordCopy); +// } +// } +// } +// } } - //前置任务为本人发布 + //2.任务自动触发的情况 if (!StringUtils.isEmpty(demandTask)) { - boolean flag = checkTaskSelf(uid, postTask.getPersonId(), demandTask.getClueId()); - if (flag) { - PostTaskRecordDto postTaskRecordCopy = new PostTaskRecordDto(); - postTaskRecordCopy.setPersonId(postTask.getPersonId()); - postTaskRecordCopy.setPostTaskId(postTaskId); - postTaskRecordCopy.setPreTaskId(taskStatus.getTaskId()); - postTaskRecordCopy.setStatus(taskStatus.getStatus()); - postTaskRecordCopy.setLevel(3); //任务为本人发布 - postTaskRecordList.add(postTaskRecordCopy); + //任务是自动触发 + if (demandTask.getIsAuto() == 1) { + //判断是否达到阈值 + boolean flag = checkThresholdNoSwitch(demandTask, talk); + if (flag) { + //任务已启动或能直接执行 + int clueSwitch = talk.getDemandTaskSwitchMap().get(demandTask.getDemandTaskId()); + if (allowTask.contains(clueSwitch)) { + String[] condition1 = demandTask.getCondition1().split("\\|"); + PostTaskRecordDto postTaskRecordCopy = new PostTaskRecordDto(); + postTaskRecordCopy.setPersonId(postTask.getPersonId()); + postTaskRecordCopy.setPostTaskId(postTaskId); //后置任务 + postTaskRecordCopy.setPreTaskId(taskStatus.getTaskId()); //前置任务 + postTaskRecordCopy.setStatus(taskStatus.getStatus()); + //任务是否为71000自动完成 + if ("71000".equals(condition1[0])) { + postTaskRecordCopy.setLevel(3); //3.任务为自动触发完成 + } else { + //任务为本人发布 + boolean selfSign = checkTaskSelf(uid, postTask.getPersonId(), demandTask.getClueId()); + if (!selfSign) { + postTaskRecordCopy.setLevel(4); //4.任务为自动发布 + } else { + postTaskRecordCopy.setLevel(5); //5.任务为本人发布 + } + } + postTaskRecordList.add(postTaskRecordCopy); + } else { //主要任务(后置任务)还未解锁 + //主要任务有配置前置任务 + if (!StringUtils.isEmpty(demandTask.getPostTask())) { + String[] condition1 = demandTask.getCondition1().split("\\|"); + PostTaskRecordDto postTaskRecordCopy = new PostTaskRecordDto(); + postTaskRecordCopy.setPersonId(postTask.getPersonId()); + postTaskRecordCopy.setPostTaskId(postTaskId); //后置任务 + postTaskRecordCopy.setPreTaskId(taskStatus.getTaskId()); //前置任务 + postTaskRecordCopy.setStatus(taskStatus.getStatus()); + //任务是否为71000自动完成 + if ("71000".equals(condition1[0])) { + postTaskRecordCopy.setLevel(3); //3.任务为自动触发完成 + } else { + //任务为本人发布 + boolean selfSign = checkTaskSelf(uid, postTask.getPersonId(), demandTask.getClueId()); + if (!selfSign) { + postTaskRecordCopy.setLevel(4); //4.任务为自动发布 + } else { + postTaskRecordCopy.setLevel(5); //5.任务为本人发布 + } + } + postTaskRecordList.add(postTaskRecordCopy); + } + } + } } } +// //3.前置任务为本人发布 +// if (!StringUtils.isEmpty(demandTask)) { +// boolean flag = checkTaskSelf(uid, postTask.getPersonId(), demandTask.getClueId()); +// if (flag) { +// PostTaskRecordDto postTaskRecordCopy = new PostTaskRecordDto(); +// postTaskRecordCopy.setPersonId(postTask.getPersonId()); +// postTaskRecordCopy.setPostTaskId(postTaskId); //后置任务 +// postTaskRecordCopy.setPreTaskId(taskStatus.getTaskId()); //前置任务 +// postTaskRecordCopy.setStatus(taskStatus.getStatus()); +// postTaskRecordCopy.setLevel(5); //5.任务为本人发布 +// postTaskRecordList.add(postTaskRecordCopy); +// } +// } } } + //找到优先级最高的任务 if (postTaskRecordList.size() != 0) { - return postTaskRecordList.get(0); + int min = 5; + int index = 0; + for (int i = 0; i < postTaskRecordList.size(); i++) { + if (postTaskRecordList.get(i).getLevel() <= min) { + min = postTaskRecordList.get(i).getLevel(); + index = i; + } + } + return postTaskRecordList.get(index); } return null; } @@ -900,7 +1539,7 @@ public class PlayerUtil { * @param taskId */ public static DemandTaskDto getDemandTaskInfo(String uid, Integer personId, Integer taskId) { - List demandTasks = TimingAcquisition.playerMap.get(uid).getPersonMap().get(personId).getDemandTasks(); + List demandTasks = getPerson(uid, personId).getDemandTasks(); for (DemandTaskDto demandTask : demandTasks) { if (demandTask.getDemandTaskId() == taskId) { return demandTask; @@ -916,16 +1555,17 @@ public class PlayerUtil { * @param clueId */ public static boolean checkTaskSelf(String uid, Integer personId, Integer clueId) { - Map>> clueMap = TimingAcquisition.playerMap.get(uid).getClueMap(); + Map>> clueMap = TimingAcquisition.playerMap.get(uid).getClueMap(); //有收集到线索 if (clueMap.size() != 0) { //有收集到这个人的线索 - Map> clueTypeMap = clueMap.get(personId); + Map> clueTypeMap = clueMap.get(personId); if (!StringUtils.isEmpty(clueTypeMap)) { - for (Map.Entry> entry : clueTypeMap.entrySet()) { - List clueList = entry.getValue(); - for (ClueDto clue : clueList) { - if (clue.getClueId() == clueId && clue.getSourceIdList().contains(personId)) { + for (Map.Entry> entry : clueTypeMap.entrySet()) { + List clueList = entry.getValue(); + for (ClueInfoDto clue : clueList) { + List sourceIdList = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(personId).getClueSourceMap().get(clue.getClueId()); + if (clue.getClueId() == clueId && sourceIdList.contains(personId)) { return true; } } @@ -955,7 +1595,8 @@ public class PlayerUtil { Integer subjectId = barrierTaskKey.getSubject(); ClueDto clue = getClueById(uid, subjectId, clueId); if (!StringUtils.isEmpty(clue)) { - return clue.getClueTemplate() + "这条线索可能对你比较重要。"; + String text = SpeechUtil.getSuccessClueOtherSpeech(uid, PlayerUtil.getPersonMap(uid).get(subjectId), clue); + return text + "这条线索可能对你比较重要。"; } } } @@ -965,6 +1606,8 @@ public class PlayerUtil { /** * 找到白名单内该人的任务中已解锁或无需解锁的任务对应的提示 + * @param uid + * @param person */ public static String getTipInChat(String uid, Person person) { List demandTaskList = person.getDemandTasks(); @@ -977,7 +1620,6 @@ public class PlayerUtil { Integer trustDegree = person.getTrustDegree(); //威慑度 Integer deterrenceDegree = person.getDeterrenceDegree(); - String text = ""; for (DemandTaskDto demandTask : demandTaskList) { //判断这个任务是否在白名单内 for (BarrierTaskKeyDto barrierTaskKey : barrierTaskKeyList) { @@ -990,7 +1632,19 @@ public class PlayerUtil { //未完成 if (taskStatus == 0) { if (trustDegree >= demandTask.getTrustStart() || deterrenceDegree >= demandTask.getDeterrenceStart()) { - return SpeechUtil.getTipSpeech(uid, demandTask, 0, 1); + String text = SpeechUtil.getTipSpeech(uid, demandTask, 0, 1); + String[] condition1 = demandTask.getCondition1().split("\\|"); + //排除自动触发、70043、71000和没有配置任务文本的情况 + if (!StringUtils.isEmpty(text) && demandTask.getIsAuto() != 1 && !"70043".equals(condition1[0]) && !"71000".equals(condition1[0])) { + //记录本轮的任务数据,用于下轮的二次回复 + String unique = uid + player.getGateNo(); + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(person.getId()); + reply.setDemandTaskId(demandTask.getDemandTaskId()); + reply.setType(2); //直接操作提醒 + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + } + return text; } } } else { //任务需要解锁,找到能解锁任务的线索 @@ -1000,8 +1654,28 @@ public class PlayerUtil { if (personIdList.contains(person.getId())) { ClueDto clue = getClueById(uid, person.getId(), demandTask.getClueId()); if (!StringUtils.isEmpty(clue)) { - if (trustDegree >= clue.getTrustDegree() || deterrenceDegree >= clue.getThreaten()) { - return SpeechUtil.getTipSpeech(uid, demandTask, 0, 2); + //该任务已解锁或无需解锁 + if (demandTask.getClueSwitch() != 1) { + //任务是否已经完成 + int taskStatus = checkTaskStatus(uid, person.getId(), demandTask.getDemandTaskId()); + //未完成 + if (taskStatus == 0) { + if (trustDegree >= clue.getTrustDegree() || deterrenceDegree >= clue.getThreaten()) { + String text = SpeechUtil.getTipSpeech(uid, demandTask, 0, 2); + String[] condition1 = demandTask.getCondition1().split("\\|"); + //排除自动触发、70043、71000和没有配置任务文本的情况 + if (!StringUtils.isEmpty(text) && demandTask.getIsAuto() != 1 && !"70043".equals(condition1[0]) && !"71000".equals(condition1[0])) { + //记录本轮的任务数据,用于下轮的二次回复 + String unique = uid + player.getGateNo(); + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(person.getId()); + reply.setDemandTaskId(demandTask.getDemandTaskId()); + reply.setType(4); //自身线索提示 + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + } + return text; + } + } } } } @@ -1013,20 +1687,28 @@ public class PlayerUtil { //该NPC身上有其他人的线索且在白名单 List clueList = person.getClues(); for (BarrierTaskKeyDto barrierTaskKey : barrierTaskKeyList) { - List clueIdList = getClueByTaskId(player.getPersonMap().get(barrierTaskKey.getSubject()), barrierTaskKey.getDemandTaskId()); + List clueIdList = getClueByTaskId(getPersonMap(uid).get(barrierTaskKey.getSubject()), barrierTaskKey.getDemandTaskId()); + DemandTaskDto demandTask = getDemandTaskInfo(uid, barrierTaskKey.getSubject(), barrierTaskKey.getDemandTaskId()); for (ClueDto clue : clueList) { - if (clueIdList.contains(clue.getClueId()) && clue.getSubject() == barrierTaskKey.getSubject()) { + //排除当前对话人的线索 + if (clueIdList.contains(clue.getClueId()) && clue.getSubject() == barrierTaskKey.getSubject() && player.getPersonId() != clue.getSubject()) { //任务是否已经完成 // int taskStatus = checkTaskStatus(uid, barrierTaskKey.getSubject(), barrierTaskKey.getDemandTaskId()); //任务是否已经解锁 - DemandTaskDto demandTask = getDemandTaskInfo(uid, barrierTaskKey.getSubject(), barrierTaskKey.getDemandTaskId()); - //未解锁 if (!StringUtils.isEmpty(demandTask)) { - //未完成 - if (demandTask.getClueSwitch() == 1) { + //未解锁 + if (demandTask.getClueSwitch() != 1) { if (trustDegree >= clue.getTrustDegree() || deterrenceDegree >= clue.getThreaten()) { //----------------记录线索-------------- recordClue(uid, person.getId(), barrierTaskKey.getSubject(), clue.getType(), clue); + //记录本轮的任务数据,用于下轮的二次回复 + String unique = uid + player.getGateNo(); + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(barrierTaskKey.getSubject()); + reply.setObjectId(person.getId()); + reply.setDemandTaskId(demandTask.getDemandTaskId()); + reply.setType(1); //闲聊 + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); return SpeechUtil.getTipSpeech(uid, barrierTaskKey, person.getId()); } } @@ -1036,17 +1718,21 @@ public class PlayerUtil { } } if (count > 0) { - return "我们走吧,这人暂时问不出更重要的消息了,去先找别人问问吧。"; + //获取对应话术 + return SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 103201); } return "算了吧,估计这个人问不出什么东西来。去问问其他人吧。"; } /** * 通过线索id找到挂线索的人物 + * @param uid + * @param clueId + * @param subjectId */ public static List getPersonIdByClueId(String uid, Integer clueId, Integer subjectId) { List personIdList = new ArrayList<>(); - Map personMap = TimingAcquisition.playerMap.get(uid).getPersonMap(); + Map personMap = getPersonMap(uid); for (Map.Entry entry : personMap.entrySet()) { Person person = entry.getValue(); List clueList = person.getClues(); @@ -1063,6 +1749,8 @@ public class PlayerUtil { /** * 找到NPC身上的某个任务对应的所有线索 + * @param person + * @param demandTaskId */ public static List getClueByTaskId(Person person, Integer demandTaskId) { List clueIdList = new ArrayList<>(); @@ -1089,6 +1777,9 @@ public class PlayerUtil { /** * 更新玩家跟人物的见面次数 + * @param uid + * @param locationId + * @param personId */ public static void updateMeetTimes(String uid, String locationId, Integer personId) { Map personInfoMap = TimingAcquisition.playerMap.get(uid).getLocationMap().get(locationId).getPersonInfoMap(); @@ -1098,22 +1789,37 @@ public class PlayerUtil { /** * 扣除玩家的货币 + * @param uid + * @param num */ public static void updateMoneyNum(String uid, int num) { - int money = TimingAcquisition.playerMap.get(uid).getCurrency().intValue(); + //当前关卡消耗货币数量 +// int currency = TimingAcquisition.playerMap.get(uid).getCurrency().intValue(); + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + int money = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getMoney(); if (money > num) { - TimingAcquisition.playerMap.get(uid).setCurrency((double) (money - num)); + TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).setMoney(money - num); + //累计当前关卡已消耗货币数量 +// TimingAcquisition.playerMap.get(uid).setCurrency((double) (currency + num)); } else { - TimingAcquisition.playerMap.get(uid).setCurrency((double) (0)); + TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).setMoney(0); + //累计当前关卡已消耗货币数量 +// TimingAcquisition.playerMap.get(uid).setCurrency((double) (currency + currency)); } } /** * 增加玩家的货币 + * @param uid + * @param num */ public static void addMoneyNum(String uid, int num) { - int money = TimingAcquisition.playerMap.get(uid).getCurrency().intValue(); - TimingAcquisition.playerMap.get(uid).setCurrency((double) (money + num)); + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + int money = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getMoney(); + TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).setMoney(money + num); + //累计当前关卡已消耗货币数量 +// int currency = TimingAcquisition.playerMap.get(uid).getCurrency().intValue(); +// TimingAcquisition.playerMap.get(uid).setCurrency((double) (currency - num)); } /** @@ -1137,6 +1843,9 @@ public class PlayerUtil { /** * 过滤到已经完成任务对应的线索 + * @param uid + * @param person + * @param clueList */ public static List getUndoClueList(String uid, Person person, List clueList) { List result = new ArrayList<>(); @@ -1152,4 +1861,1091 @@ public class PlayerUtil { } return result; } + + /** + * 取出询问操作的方法编号对应的线索序号 + */ + public static int getNumByMethodId(String uid, String methodId, int size) { + Map askAndNumMap = TimingAcquisition.playerMap.get(uid).getAskAndNumMap(); + int result = 0; + //还没有对用询问操作方法编号的序号 + if (StringUtils.isEmpty(askAndNumMap.get(methodId))) { + askAndNumMap.put(methodId, 0); + } else { + result = askAndNumMap.get(methodId); + if (result >= size - 1) { + result = 0; + } else { + result += 1; + } + askAndNumMap.put(methodId, result); + } + return result; + } + + /** + * 更新声望值 + * @param player + * @param num + */ + public static void updateReputation(Player player, int num) { + //声望值 + int fame = player.getReputation(); + int result = fame + num; + if (result <= 0) { + player.setReputation(0); + } else { + player.setReputation(result); + } + } + + /** + * 更新时间值 + * @param player + * @param num + */ + public static void updateInitTime(Player player, int num) { + if (num != 0) { + //初始时间值 + int initTime = player.getInitTime(); + int result = initTime - num; + if (result <= 0) { + player.setInitTime(0); + } else { + player.setInitTime(result); + } + } + } + /** + * 更新生命状态 + */ + public static void updateLifeState(PersonInfoDto personInfo, int lifeState) { + if (lifeState != 0) { + if (personInfo.getLifeState() != lifeState) { + personInfo.setLifeState(lifeState); + } + } + } + + /** + * 任务完成,数据更新 + * @param uid + * @param subjectId + * @param demandTaskId + */ + public static void taskFinished(String uid, Integer subjectId, Integer demandTaskId) { + Player player = TimingAcquisition.playerMap.get(uid); + //已完成任务的map + Map map = player.getTaskMap().get(subjectId); + DemandTaskDto demandTask = getDemandTaskInfo(uid, subjectId, demandTaskId); + //任务存在 + if (!StringUtils.isEmpty(demandTask)) { + int num = 0; + if (!StringUtils.isEmpty(map.get(demandTaskId))) { + num = map.get(demandTaskId); + } + //1.任务完成 + map.put(demandTaskId, num + 1); + //2.更新信任值和威慑度 + addThreshold(player.getPersonInfoMap().get(subjectId), demandTask); + String cost = demandTask.getCost(); + if (!StringUtils.isEmpty(cost)) { + String[] costs = cost.split("\\|"); + int value = Integer.parseInt(costs[0]); + //3.扣除货币 + if (value > 0) { + updateMoneyNum(uid, value); + } + } + String completionReward = demandTask.getCompletionReward(); + //4.发放奖励 + if (!StringUtils.isEmpty(completionReward)) { + int reward = Integer.parseInt(completionReward); + addMoneyNum(uid, reward); + } + //5.增加声望值 + updateReputation(player, demandTask.getReputation()); + //6.更新时间值 + updateInitTime(player, demandTask.getCostTime()); + //7.更新生命状态 + updateLifeState(player.getPersonInfoMap().get(subjectId), demandTask.getLifeState()); + } + } + + /** + * 自动触发的任务自动完成 + * @param uid + * @param person + * @param clue + */ + public static String taskAutoFinish(String uid, Person person, ClueDto clue) { + String result = ""; + String taskText = ""; + if (!StringUtils.isEmpty(clue)) { + //线索类型为任务线索 + if (clue.getType() == 6) { + Person subject = getPersonMap(uid).get(clue.getSubject()); + PersonInfoDto talk = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(clue.getSubject()); + DemandTaskDto demandTaskDto = PlayerUtil.getDemandTaskByClueId(subject, clue); + Integer subjectId = person.getId(); + if (!StringUtils.isEmpty(demandTaskDto)) { + //判断任务是否已经完成 + int isFinished = PlayerUtil.checkTaskStatus(uid, subjectId, demandTaskDto.getDemandTaskId()); + //未完成 + if (isFinished == 0) { + if (demandTaskDto.getIsAuto() == 1) { + String condition1 = demandTaskDto.getCondition1(); + String[] taskIdTimes = condition1.split("\\|"); + //自动完成 + if ("71000".equals(taskIdTimes[0])) { + //达到阈值 + boolean flag = checkThreshold(uid, demandTaskDto, talk); + if (flag) { + Integer preTaskId = demandTaskDto.getDemandTaskId(); //后置 + DemandTaskDto demandTaskPre = getDemandTaskInfo(uid, subjectId, preTaskId); + //找到后置任务 + if (!StringUtils.isEmpty(demandTaskPre)) { + //后置任务自动完成 + taskFinished(uid, subjectId, preTaskId); + String preText = SpeechUtil.getSuccessTaskSpeech(uid, person, demandTaskPre); + //有配置前置任务 + if (!StringUtils.isEmpty(demandTaskDto.getPostTask())) { + Integer postTaskId = Integer.valueOf(demandTaskDto.getPostTask());; //前置 + //后置任务的主体 + Integer objectId = demandTaskPre.getObject(); + DemandTaskDto demandTaskPost = getDemandTaskInfo(uid, objectId, postTaskId); + if (!StringUtils.isEmpty(demandTaskPost)) { + //前置任务自动完成 + taskFinished(uid, objectId, postTaskId); + String postText = SpeechUtil.getSuccessTaskSpeech(uid, person, demandTaskPost); + taskText += postText; + } + } + taskText += preText; + } + } + } + } + } + } + } + result = result + taskText; + } + return result; + } + + /** + * 通过关卡名称找到对应的系列名称 + * @param gateName + */ + public static String getSeriesNameByGateName(String gateName) { + String gateNo = TimingAcquisition.gateNameToNoMap.get(gateName); + Map> seriesGateNosMap = TimingAcquisition.seriesGateNosMap; + for (Map.Entry> entry : seriesGateNosMap.entrySet()) { + List gateNoList = entry.getValue(); + if (gateNoList.contains(gateNo)) { + return entry.getKey(); + } + } + return null; + } + + + /** + * 更新关卡排行榜 + * @param player + * @param reputation + */ + public static void updateGateNoReputation(Player player, ReputationDto reputation) { + String uid = player.getUid(); + String gateNo = player.getGateNo(); //关卡编号 + Map> gateNoUidReputationMap = TimingAcquisition.gateNoUidReputationMap; + Map> gateNoReputationQueueMap = TimingAcquisition.gateNoReputationQueueMap; + //关卡中已存在用户 + if (!StringUtils.isEmpty(gateNoUidReputationMap.get(gateNo))) { + ReputationDto reputationOld = gateNoUidReputationMap.get(gateNo).get(uid); + //关卡中有该用户的声望 + if (!StringUtils.isEmpty(reputationOld)) { + //该用户的声望已更新 + if (!reputation.equals(reputationOld)) { + //更新关卡中该用户的声望 + gateNoUidReputationMap.get(gateNo).put(uid, reputation); + //更新关卡排行榜中用户的旧声望 + gateNoReputationQueueMap.get(gateNo).add(reputation); + gateNoReputationQueueMap.get(gateNo).remove(reputationOld); + } + } else { + //新增关卡中该用户的声望 + gateNoUidReputationMap.get(gateNo).put(uid, reputation); + //新增关卡排行榜中用户的声望 + gateNoReputationQueueMap.get(gateNo).add(reputation); + } + } else { + //新增关卡和声望 + Map reputationMap = new HashMap<>(); + reputationMap.put(uid, reputation); + gateNoUidReputationMap.put(gateNo, reputationMap); + //新增关卡排行榜 + PriorityBlockingQueue gateNoReputationQueue = new PriorityBlockingQueue<>(); + gateNoReputationQueue.add(reputation); + gateNoReputationQueueMap.put(gateNo, gateNoReputationQueue); + } + } + + /** + * 更新系列排行榜 + * @param uid + * @param seriesName + * @param reputation + */ + public static void updateSeriesReputation(String uid, String seriesName, ReputationDto reputation) { + Map> seriesPlayerMap = TimingAcquisition.seriesPlayerMap; + Map> seriesReputationQueueMap = TimingAcquisition.seriesReputationQueueMap; + //不存在该系列 + if (StringUtils.isEmpty(seriesReputationQueueMap.get(seriesName))) { + PlayerSeriesDto playerSeries = new PlayerSeriesDto(); + ReputationDto totalReputation = new ReputationDto(); + totalReputation.setUid(uid); + totalReputation.setReputation(reputation.getReputation()); + playerSeries.setTotalReputation(totalReputation); + //新增系列排行榜 + PriorityBlockingQueue seriesReputationQueue = new PriorityBlockingQueue<>(); + seriesReputationQueue.add(reputation); + seriesReputationQueueMap.put(seriesName, seriesReputationQueue); + } else { + //该系列不存在该用户 + ReputationDto reputationOld = seriesPlayerMap.get(seriesName).get(uid).getTotalReputation(); + //累计声望值 + reputation.setReputation(reputation.getReputation() + reputationOld.getReputation()); + //更新系列中该用户 + seriesPlayerMap.get(seriesName).get(uid).setTotalReputation(reputation); + //更新系列排行榜中用户的旧声望 + seriesReputationQueueMap.get(seriesName).add(reputation); + seriesReputationQueueMap.get(seriesName).remove(reputationOld); + } + } + + /** + * 任务按优先级自动完成任务或自动触发 + * @param uid + * @param postTaskRecord + */ + public static ResultVarsResponse taskDoByLevel(String uid, PostTaskRecordDto postTaskRecord) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + Player player = TimingAcquisition.playerMap.get(uid); + Integer subjectId = postTaskRecord.getPersonId(); + String text = ""; + //前置任务已完成 + if (postTaskRecord.getLevel() == 1 || postTaskRecord.getLevel() == 2) { + DemandTaskDto demandTask = getDemandTaskById(uid, subjectId, postTaskRecord.getPostTaskId()); + if (!StringUtils.isEmpty(demandTask)) { + //任务自动完成 + taskFinished(uid, subjectId, postTaskRecord.getPostTaskId()); + if (postTaskRecord.getLevel() == 1) { + //获取对应话术 + text = SpeechUtil.getPreSuccessTaskSpeech(uid, getPerson(uid, subjectId), demandTask, 1); + resultResponse.set反馈ID(400106); + } + if (postTaskRecord.getLevel() == 2) { + //获取对应话术 + text = SpeechUtil.getPreSuccessTaskSpeech(uid, getPerson(uid, subjectId), demandTask, 2); + resultResponse.set反馈ID(400107); + } + //记录本轮的任务数据,用于下轮的二次回复 + String unique = uid + player.getGateNo(); + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(subjectId); + reply.setDemandTaskId(postTaskRecord.getPostTaskId()); + reply.setType(2); //直接操作提醒 + String[] condition = demandTask.getCondition1().split("\\|"); + //任务会掉落物或人 + if ("72000".equals(condition[0])) { + Map dropMap = ConfigDataUtil.getDropItems(uid, demandTask.getDropItems()); + if (dropMap.isEmpty()) { + text = ""; + } else { + reply.setIdNumMap(dropMap); + } + } + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + //任务链下一个任务的对应回复 + CommonResult result = PlayerUtil.getNextTaskAnswer(uid, subjectId, demandTask.getDemandTaskId()); + if (!StringUtils.isEmpty(result.getMessage())) { + text += result.getMessage(); + //任务链下一任务启动 + PlayerUtil.startTaskOnNext(uid, demandTask.getDemandTaskId()); + DemandTaskDto nextDemandTask = result.getData(); + //存在任务链下一个 + if (!StringUtils.isEmpty(nextDemandTask)) { + //返回下一个任务对应的后台附加返回给bot端 + String[] condition1 = nextDemandTask.getCondition1().split("\\|"); + Integer methodId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition1[0])).getMethodId(); + resultResponse.set后台附加返回(methodId.toString()); + } + } + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTask.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); + } + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return resultVarsResponse; + } + } + //任务为自动触发且自动完成 + if (postTaskRecord.getLevel() == 3) { + Integer preTaskId = postTaskRecord.getPreTaskId(); //前置 + Integer postTaskId = postTaskRecord.getPostTaskId();; //后置 + DemandTaskDto demandTaskPost = getDemandTaskInfo(uid, subjectId, postTaskId); + //找到后置任务 + if (!StringUtils.isEmpty(demandTaskPost)) { + ClueDto clue = getClueById(uid, subjectId, demandTaskPost.getClueId()); + if (!StringUtils.isEmpty(clue)) { + //任务线索文本 +// text = SpeechUtil.getSuccessClueSpeech(uid, getPerson(uid, subjectId), clue); + //任务启动文本 + text = SpeechUtil.getPreSuccessTaskSpeech(uid, getPerson(uid, subjectId), demandTaskPost, 4); + } + //后置任务自动完成 + taskFinished(uid, subjectId, postTaskId); + String postText = SpeechUtil.getSuccessTaskSpeech(uid, getPerson(uid, subjectId), demandTaskPost); + //有配置前置任务 + if (preTaskId != 0) { + //后置任务的客体 + Integer objectId = demandTaskPost.getObject(); + DemandTaskDto demandTaskPre = getDemandTaskInfo(uid, objectId, preTaskId); + if (!StringUtils.isEmpty(demandTaskPre)) { + //前置任务自动完成 + taskFinished(uid, objectId, preTaskId); + String preText = SpeechUtil.getSuccessTaskSpeech(uid, getPerson(uid, objectId), demandTaskPre); + text += preText; + } + } + text += postText; + //任务链下一个任务的对应回复 + CommonResult result = PlayerUtil.getNextTaskAnswer(uid, subjectId, postTaskId); + if (!StringUtils.isEmpty(result.getMessage())) { + text += result.getMessage(); + //任务链下一任务启动 + PlayerUtil.startTaskOnNext(uid, postTaskId); + DemandTaskDto nextDemandTask = result.getData(); + //存在任务链下一个 + if (!StringUtils.isEmpty(nextDemandTask)) { + //返回下一个任务对应的后台附加返回给bot端 + String[] condition = nextDemandTask.getCondition1().split("\\|"); + Integer methodId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition[0])).getMethodId(); + resultResponse.set后台附加返回(methodId.toString()); + } + } + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTaskPost.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); + } + } + resultResponse.set反馈ID(400108); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return resultVarsResponse; + } + //任务为自动触发仅提供线索 + if (postTaskRecord.getLevel() == 4) { + List allowTask = Arrays.asList(-1, 0, 2); + Integer postTaskId = postTaskRecord.getPostTaskId();; //后置 + //找到后置任务 + DemandTaskDto demandTaskPost = getDemandTaskInfo(uid, subjectId, postTaskId); + //存在后置任务 + if (!StringUtils.isEmpty(demandTaskPost)) { + Map demandTaskSwitchMap = player.getPersonInfoMap().get(subjectId).getDemandTaskSwitchMap(); + //后置任务解锁 + if (allowTask.contains(demandTaskSwitchMap.get(postTaskId))) { + demandTaskSwitchMap.put(postTaskId, 5); + } + ClueDto clue = getClueById(uid, subjectId, demandTaskPost.getClueId()); + if (!StringUtils.isEmpty(clue)) { + //----------------记录线索-------------- + recordClue(uid, player.getPersonId(), subjectId, clue.getType(), clue); + //----------------是否解锁任务------------- +// PlayerUtil.unlockTask(uid, player.getPersonMap().get(subjectId), clue); + //前置任务解锁 + if (postTaskRecord.getPreTaskId() != 0) { + Map demandTaskSwitchPreMap = player.getPersonInfoMap().get(demandTaskPost.getObject()).getDemandTaskSwitchMap(); + DemandTaskDto demandTaskPre = getDemandTaskInfo(uid, demandTaskPost.getObject(), postTaskRecord.getPreTaskId()); + if (!StringUtils.isEmpty(demandTaskPre)) { + if (demandTaskSwitchPreMap.get(postTaskRecord.getPreTaskId()) == 1) { + demandTaskSwitchPreMap.put(postTaskRecord.getPreTaskId(), 2); + } else { + if (allowTask.contains(demandTaskSwitchPreMap.get(postTaskRecord.getPreTaskId()))) { + demandTaskSwitchPreMap.put(postTaskRecord.getPreTaskId(), 5); + } + } + } + } + //任务线索 +// text = SpeechUtil.getSuccessClueSpeech(uid, getPerson(uid, subjectId), clue); + //任务启动文本 + text = SpeechUtil.getPreSuccessTaskSpeech(uid, getPerson(uid, subjectId), demandTaskPost, 4); + String[] condition = demandTaskPost.getCondition1().split("\\|"); + //记录本轮的任务数据,用于下轮的二次回复 + String unique = uid + player.getGateNo(); + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(subjectId); + reply.setDemandTaskId(postTaskRecord.getPostTaskId()); + reply.setType(2); //直接操作提醒 + //任务会掉落物或人 + if ("72000".equals(condition[0])) { + Map dropMap = ConfigDataUtil.getDropItems(uid, demandTaskPost.getDropItems()); + if (dropMap.isEmpty()) { + text = ""; + } else { + reply.setIdNumMap(dropMap); + } + } + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + //返回任务对应的后台附加返回给bot端 + Integer methodId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition[0])).getMethodId(); + resultResponse.set后台附加返回(methodId.toString()); + } + } + resultResponse.set反馈ID(400109); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return resultVarsResponse; + } + //任务是本人发布的 + if (postTaskRecord.getLevel() == 5) { + //获取对应的后置任务 + DemandTaskDto demandTask = getDemandTaskById(uid, subjectId, postTaskRecord.getPostTaskId()); + if (!StringUtils.isEmpty(demandTask)) { + text = SpeechUtil.getPreSuccessTaskSpeech(uid, getPerson(uid, subjectId), demandTask, 3); + String[] condition1 = demandTask.getCondition1().split("\\|"); + if (!"70043".equals(condition1[0]) && !"71000".equals(condition1[0])) { + //记录本轮的任务数据,用于下轮的二次回复 + String unique = uid + player.getGateNo(); + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(subjectId); + reply.setDemandTaskId(postTaskRecord.getPostTaskId()); + reply.setType(3); //执行任务 + //任务会掉落物或人 + if ("72000".equals(condition1[0])) { + Map dropMap = ConfigDataUtil.getDropItems(uid, demandTask.getDropItems()); + if (dropMap.isEmpty()) { + text = ""; + } else { + reply.setIdNumMap(dropMap); + } + } + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + //返回对应的后台附加返回给bot端 + String[] condition = demandTask.getCondition1().split("\\|"); + Integer methodId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition[0])).getMethodId(); + resultResponse.set后台附加返回(methodId.toString()); + } + } + resultResponse.set反馈ID(400110); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return resultVarsResponse; + } + resultResponse.set反馈ID(400111); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return resultVarsResponse; + } + + /** + * 判断任务是否为某主任务的副任务,同时满足对应主任务的任务条件id为“71001”。返回人物id和主任务的id + */ + public static Map checkTaskIsSub(String uid, Integer personId, Integer demandTaskId) { + Map personIdTaskIdMap = new HashMap<>(); + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map personMap = TimingAcquisition.gatePersonMap.get(gateNo); + //遍历所有关卡人物 + for (Map.Entry entry : personMap.entrySet()) { + //该人物身上挂的任务 + List demandTaskList = getPerson(uid, entry.getKey()).getDemandTasks(); + //判断该任务是否为前置任务的主任务 + for (DemandTaskDto demandTask : demandTaskList) { + //有前置任务 + if (!StringUtils.isEmpty(demandTask.getPostTask())) { + if (demandTask.getPostTask().equals(demandTaskId.toString()) && personId == demandTask.getObject()) { + int result; //存在主任务,但不是“71001”,不自动完成 + String[] condition1 = demandTask.getCondition1().split("\\|"); + if ("71001".equals(condition1[0])) { + result = demandTask.getDemandTaskId(); + personIdTaskIdMap.put(entry.getKey(), result); + } + break; + } + } + } + } + return personIdTaskIdMap; + } + + /** + * 找到对应时间范围内的所有任务 + * @param uid + * @param personId + */ + public static List getDemandTaskIdsByInitTime(String uid, Integer personId) { + List result = new ArrayList<>(); + //玩家的剩余时间 + int initTime = TimingAcquisition.playerMap.get(uid).getInitTime(); + List demandTaskList = getPerson(uid, personId).getDemandTasks(); + for (DemandTaskDto demandTask : demandTaskList) { + //配置了时间阈值 + if (!StringUtils.isEmpty(demandTask.getTimeThreshold())) { + if (!"0|0".equals(demandTask.getTimeThreshold()) && !"0".equals(demandTask.getTimeThreshold())) { + String[] timeThresholds = demandTask.getTimeThreshold().split("\\|"); + boolean timeFlag = NumberUtil.inNumRange(initTime,"["+timeThresholds[0]+","+timeThresholds[1]+"]"); + if (timeFlag) { + result.add(demandTask.getDemandTaskId()); + } + } + } + } + return result; + } + + /** + * 找到任务所在任务链的下个任务id。任务可以在不同NPC的身上 + * @param uid + * @param taskId + */ + public static Map> getNextTaskIdByTask(String uid, Integer taskId) { + Map> result = new HashMap<>(); + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map personMap = TimingAcquisition.gatePersonMap.get(gateNo); + for (Map.Entry entry : personMap.entrySet()) { + List nextTaskIds = new ArrayList<>(); + List demandTaskList = getPerson(uid, entry.getKey()).getDemandTasks(); + for (DemandTaskDto demandTask : demandTaskList) { + //配置了开启任务条件id + if (!StringUtils.isEmpty(demandTask.getConditionTaskId())) { + if (demandTask.getConditionTaskId() == taskId) { + nextTaskIds.add(demandTask.getDemandTaskId()); + } + } + } + if (nextTaskIds.size() != 0) { + result.put(entry.getKey(), nextTaskIds); + } + } + return result; + } + + /** + * 找到NPC身上指定任务的任务链 + * @param uid + * @param personId + * @param taskId + */ + public static List getNextTaskOnPerson(String uid, Integer personId, Integer taskId) { + List result = new ArrayList<>(); + int taskIdTmp = taskId; + List demandTaskList = getPerson(uid, personId).getDemandTasks(); + for (DemandTaskDto demandTask : demandTaskList) { + //配置了开启任务条件id + if (!StringUtils.isEmpty(demandTask.getConditionTaskId())) { + if (demandTask.getConditionTaskId() == taskIdTmp) { + taskIdTmp = demandTask.getDemandTaskId(); + result.add(taskIdTmp); + } + } + } + return result; + } + + /** + * 找到NPC身上的任务链,某任务id的下一个任务对应的返回 + * @param uid + * @param personId + * @param taskId + */ + public static CommonResult getNextTaskAnswer(String uid, Integer personId, Integer taskId) { + StringBuilder text = new StringBuilder(); + DemandTaskDto result = null; + //任务NPC + PersonInfoDto subject = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(personId); + //找到NPC身上该任务id的任务链 + List nextTaskIdList = getNextTaskOnPerson(uid, personId, taskId); + int taskIdTmp = taskId; + for (Integer nextId : nextTaskIdList) { + DemandTaskDto demandTask = getDemandTaskInfo(uid, personId, nextId); + if (StringUtils.isEmpty(demandTask)) { + continue; + } + //没有配置开启任务条件id + if (StringUtils.isEmpty(demandTask.getConditionTaskId())) { + continue; + } + //配置了开启任务条件id + if (demandTask.getConditionTaskId() != taskIdTmp || demandTask.getIsAuto() != 1) { + continue; + } + //配置了开启任务条件id + //判断是否符合阈值需求 + boolean flag = checkThreshold(uid, demandTask, subject); + //不符合阈值需求 + if (!flag) { + continue; + } + String[] condition1 = demandTask.getCondition1().split("\\|"); + if ("71000".equals(condition1[0])) { + //任务自动完成 + taskFinished(uid, personId, demandTask.getDemandTaskId()); + //可以重复扣钱 + if (!StringUtils.isEmpty(demandTask.getCost())) { + String[] costList = demandTask.getCost().split("\\|"); + int value = Integer.parseInt(costList[0]); + int costFlag = Integer.parseInt(costList[1]); + if (costFlag == 0) { + //扣除货币 + if (value > 0) { + PlayerUtil.updateMoneyNum(uid, value); + } + } + } + //返回任务完成文本 + text.append(SpeechUtil.getPreSuccessTaskSpeech(uid, getPerson(uid, personId), demandTask, 4)); + //返回任务完成文本 + text.append(SpeechUtil.getSuccessTaskSpeech(uid, getPerson(uid, personId), demandTask)); + } else { + //返回任务启动文本 + text.append(SpeechUtil.getPreSuccessTaskSpeech(uid, getPerson(uid, personId), demandTask, 4)); + if (!StringUtils.isEmpty(demandTask.getPostTask())) { + Map> taskMap = TimingAcquisition.playerMap.get(uid).getTaskMap(); + //2.符合阈值需求,判断是否完成副任务 + if (!taskMap.containsKey(demandTask.getObject())) { + continue; + } + Map objectMap = taskMap.get(demandTask.getObject()); + if (!objectMap.containsKey(Integer.valueOf(demandTask.getPostTask()))) { + continue; + } + } + result = demandTask; + //记录本轮的任务数据,用于下轮的二次回复 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); + String unique = uid + gateNo; + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(personId); + reply.setDemandTaskId(demandTask.getDemandTaskId()); + reply.setType(2); //直接操作提醒 + //任务会掉落物或人 + if ("72000".equals(condition1[0])) { + Map dropMap = ConfigDataUtil.getDropItems(uid, demandTask.getDropItems()); + if (dropMap.isEmpty()) { + text = new StringBuilder(); + } else { + reply.setIdNumMap(dropMap); + } + } + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + break; + } + taskIdTmp = demandTask.getDemandTaskId(); + } + return CommonResult.success(result, text.toString()); + } + + /** + * 启动任务链的下一任务 + */ + public static void startTaskOnNext(String uid, Integer taskId) { + Map> nextTaskIdList = getNextTaskIdByTask(uid, taskId); + Player player = TimingAcquisition.playerMap.get(uid); + if (nextTaskIdList.size() != 0) { + Map personInfoMap = player.getPersonInfoMap(); + for (Map.Entry> entry : nextTaskIdList.entrySet()) { + Map demandTaskSwitchMap = personInfoMap.get(entry.getKey()).getDemandTaskSwitchMap(); + for (Integer next : entry.getValue()) { + //任务解锁 + if (demandTaskSwitchMap.get(next) == 1) { + demandTaskSwitchMap.put(next, 2); + } else { + demandTaskSwitchMap.put(next, 5); + } + //找到后置任务 + DemandTaskDto demandTaskPost = getDemandTaskInfo(uid, entry.getKey(), next); + if (!StringUtils.isEmpty(demandTaskPost)) { + ClueDto clue = getClueById(uid, demandTaskPost.getSubject(), demandTaskPost.getClueId()); + if (!StringUtils.isEmpty(clue)) { + //----------------记录线索-------------- + recordClue(uid, player.getPersonId(), demandTaskPost.getSubject(), clue.getType(), clue); + } + //前置任务解锁 + if (!StringUtils.isEmpty(demandTaskPost.getPostTask())) { + DemandTaskDto demandTaskPre = getDemandTaskInfo(uid, demandTaskPost.getObject(), Integer.valueOf(demandTaskPost.getPostTask())); + if (!StringUtils.isEmpty(demandTaskPre)) { + Map demandTaskSwitchPreMap = personInfoMap.get(demandTaskPre.getSubject()).getDemandTaskSwitchMap(); + if (demandTaskSwitchPreMap.get(demandTaskPre.getDemandTaskId()) == 1) { + demandTaskSwitchPreMap.put(demandTaskPre.getDemandTaskId(), 2); + } else { + demandTaskSwitchPreMap.put(demandTaskPre.getDemandTaskId(), 5); + } + ClueDto cluePre = getClueById(uid, demandTaskPre.getSubject(), demandTaskPre.getClueId()); + if (!StringUtils.isEmpty(cluePre)) { + //----------------记录线索-------------- + recordClue(uid, player.getPersonId(), demandTaskPre.getSubject(), cluePre.getType(), cluePre); + } + } + } + } + } + } + } + } + + /** + * 更新任务的线索开关即任务状态 + * @param uid + * @param personId + * @param taskId + * @param status + */ + public static void updateTaskStatus(String uid, Integer personId, Integer taskId, Integer status) { + Map demandTaskSwitchMap = TimingAcquisition.playerMap.get(uid).getPersonInfoMap(). + get(personId).getDemandTaskSwitchMap(); + demandTaskSwitchMap.put(taskId, status); + } + + /** + * 开始游戏时,找到进行中任务的对应提示 + * @param uid + * @param personId + */ + public static String getDoingTaskAnswer(String uid, Integer personId) { + String result = ""; + Map demandTaskSwitchMap = TimingAcquisition.playerMap.get(uid).getPersonInfoMap(). + get(personId).getDemandTaskSwitchMap(); + for (Map.Entry entry : demandTaskSwitchMap.entrySet()) { + if (entry.getValue() == 5) { + int finishFlag = checkTaskStatus(uid, personId, entry.getKey()); + if (finishFlag == 0) { + //任务启动文本 + DemandTaskDto demandTask = getDemandTaskById(uid, personId, entry.getKey()); + result = SpeechUtil.getPreSuccessTaskSpeech(uid, getPerson(uid, personId), demandTask, 4); + } + } + } + return result; + } + + /** + * 初始化系列中玩家的汇总数据 + */ + public static void initSeriesPlayer(String uid, String seriesName) { + ReputationDto reputation = new ReputationDto(); + reputation.setUid(uid); + Map> seriesPlayerMap = TimingAcquisition.seriesPlayerMap; + //不存在该系列 + if (StringUtils.isEmpty(seriesPlayerMap.get(seriesName))) { + //新增系列和声望 + Map playerSeriesDtoMap = new HashMap<>(); + PlayerSeriesDto playerSeries = new PlayerSeriesDto(); + playerSeries.setTotalReputation(reputation); + //初始货币值 + String initMoney = TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("init_money").getValue(); + if (StringUtils.isEmpty(initMoney)) { + //远程获取货币数量进行同步 + CallResponse callMoney = remoteGardenService.getMoney(uid); + initMoney = callMoney.getData(); + //获取物品进行同步 + CallResponse callItems = remoteGardenService.getItems(uid); + List itemList = JSON.parseObject(callItems.getData(), new TypeReference>(){}); + Map partnerItemMap = ConfigDataUtil.getItemMap(uid, itemList); + playerSeries.setPartnerItemMap(partnerItemMap); + } + playerSeries.setMoney(Integer.parseInt(initMoney)); + playerSeriesDtoMap.put(uid, playerSeries); + seriesPlayerMap.put(seriesName, playerSeriesDtoMap); + } else { + //不存在该用户 + if (StringUtils.isEmpty(seriesPlayerMap.get(seriesName).get(uid))) { + //新增系列中该用户 + PlayerSeriesDto playerSeries = new PlayerSeriesDto(); + playerSeries.setTotalReputation(reputation); + //初始货币值 + String initMoney = TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("init_money").getValue(); + if (StringUtils.isEmpty(initMoney)) { + //远程获取货币数量进行同步 + CallResponse callMoney = remoteGardenService.getMoney(uid); + initMoney = callMoney.getData(); + //获取物品进行同步 + CallResponse callItems = remoteGardenService.getItems(uid); + List itemList = JSON.parseObject(callItems.getData(), new TypeReference>(){}); + Map partnerItemMap = ConfigDataUtil.getItemMap(uid, itemList); + playerSeries.setPartnerItemMap(partnerItemMap); + } + playerSeries.setMoney(Integer.parseInt(initMoney)); + seriesPlayerMap.get(seriesName).put(uid, playerSeries); + } + } + } + + /** + * NPC加入伙伴队列 + * @param uid + * @param partnerId + */ + public static void joinPartner(String uid, Integer partnerId) { + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + PartnerItemDto partners = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getPartnerItemMap().get(Constants.ITEM_PARTNER); + Map partnerMap = partners.getItemInfoMap(); + ItemNumDto partnerNum = new ItemNumDto(); + partnerNum.setId(partnerId); + partnerNum.setTimes(TimingAcquisition.seriesPartnerItemMap.get(seriesName).get(partnerId).getHelpTimes()); + partnerMap.put(partnerId, partnerNum); + } + + /** + * 过滤掉系列中已有的伙伴NPC + */ + public static List filterPerson(String uid, List personList) { + List result = new ArrayList<>(); + //已有该玩家 + if (StringUtils.isEmpty(TimingAcquisition.playerMap.get(uid))) { + return personList; + } + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + Map partnerInfoMap = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getPartnerItemMap(). + get(Constants.ITEM_PARTNER).getItemInfoMap(); + //该系列已有伙伴 + if (partnerInfoMap.size() == 0) { + return personList; + } + List joinPersonIdList = new ArrayList<>(); + Map partnerMap = TimingAcquisition.seriesPartnerItemMap.get(seriesName); + for (Map.Entry entry : partnerInfoMap.entrySet()) { + joinPersonIdList.add(partnerMap.get(entry.getKey()).getId()); + } + for (Person person : personList) { + //伙伴已在NPC中 + if (joinPersonIdList.contains(person.getPersonId())) { + continue; + } + result.add(person); + } + return result; + } + + /** + * 获取已有伙伴信息 + */ + public static ItemNumDto getPartnerNumById(String uid, Integer partnerId) { + Player player = TimingAcquisition.playerMap.get(uid); + Map partnerNumMap = TimingAcquisition.seriesPlayerMap.get(player.getSeries()).get(uid). + getPartnerItemMap().get(Constants.ITEM_PARTNER).getItemInfoMap(); + for (Map.Entry entry : partnerNumMap.entrySet()) { + if (partnerId.equals(entry.getKey())) { + return entry.getValue(); + } + } + return null; + } + + /** + * 获取已有物品信息 + */ + public static ItemNumDto getItemNumById(String uid, Integer itemId) { + Player player = TimingAcquisition.playerMap.get(uid); + Map itemNumMap = TimingAcquisition.seriesPlayerMap.get(player.getSeries()).get(uid). + getPartnerItemMap().get(Constants.ITEM_PARTNER).getItemInfoMap(); + for (Map.Entry entry : itemNumMap.entrySet()) { + if (itemId.equals(entry.getKey())) { + return entry.getValue(); + } + } + return null; + } + + /** + * 删除指定物品 + */ + public static boolean removePartnerItemById(String uid, Integer partnerItemId) { + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + //伙伴物品配置数据 + PartnerItem partnerItem = TimingAcquisition.seriesPartnerItemMap.get(seriesName).get(partnerItemId); + int type = partnerItem.getType(); + //系列的玩家汇总数据 + Map partnerItemMap = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getPartnerItemMap(); + //没有伙伴或物品的类型,不用删除 + if (StringUtils.isEmpty(partnerItemMap.get(type))) { + return true; + } + Map itemInfoMap = partnerItemMap.get(type).getItemInfoMap(); + //没有没有该物品 + if (StringUtils.isEmpty(itemInfoMap.get(partnerItemId))) { + return true; + } + //删除伙伴或物品 + itemInfoMap.remove(partnerItemId); + return true; + } + + /** + * 通关完成后,数据更新并结算 + */ + public static void clearanceUpdate(String uid) { + log.info(uid + "成功通关,开始更新数据"); + Player player = TimingAcquisition.playerMap.get(uid); + //系列名称 + String seriesName = player.getSeries(); + //最终任务完成 + player.setFinished(1); + //通过次数累计1次 + int clearanceNum = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getClearanceNum(); + TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).setClearanceNum(clearanceNum + 1); + //更新货币数量 +// int totalMoney = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getMoney(); +// Double money = player.getCurrency(); +// TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).setMoney(totalMoney + money.intValue()); + //更新系列和关卡中玩家的排名 + ReputationDto reputationDto = new ReputationDto(); + reputationDto.setUid(player.getUid()); + reputationDto.setReputation(player.getReputation()); + //更新关卡排行榜 + updateGateNoReputation(player, reputationDto); + //更新系列排行榜 + updateSeriesReputation(uid, seriesName, reputationDto); + //判断伙伴人数上限和背包上限是否更新 + updateSeriesPlayerMax(uid); + //持久化玩家数据 + String seriesPlayerStr = JSON.toJSONString(TimingAcquisition.seriesPlayerMap); + PersistenceUtil.saveDataToFile(dataFilePath, "seriesPlayer", seriesPlayerStr); + log.info(uid + "通关后更新数据完成"); + try { + //-----------存入redis缓存中------------- + redisUtil.setStr(seriesName + "::"+ uid, JSON.toJSONString(TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid))); + RemoteCallFactory.getInstance().updateItems(uid, "gardenSys"); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * 更新伙伴人数上限和背包上限 + */ + public static void updateSeriesPlayerMax(String uid) { + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + //下一声望对应的伙伴数量上限 + int nextPartnerNumMax = ConfigDataUtil.getPartnerNumMax(uid); + if (nextPartnerNumMax > 0) { + TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getPartnerItemMap().get(Constants.ITEM_PARTNER).setMax(nextPartnerNumMax); + } + //下一声望对应的背包道具数量上限 + int nextItemNumMax = ConfigDataUtil.getItemNumMax(uid); + if (nextItemNumMax > 0) { + TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getPartnerItemMap().get(Constants.ITEM_PROPS).setMax(nextItemNumMax); + } + } + + /** + * 获取副任务对应主任务的主体名称 + */ + public static String getSubjectNameByPreTaskId(String uid, Integer personId, Integer preTaskId) { + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map personMap = TimingAcquisition.gatePersonMap.get(gateNo); + //遍历所有关卡人物 + for (Map.Entry entry : personMap.entrySet()) { + //过滤本人 + if (personId.equals(entry.getKey())) { + continue; + } + //该人物身上挂的任务 + List demandTaskList = getPerson(uid, entry.getKey()).getDemandTasks(); + //判断该任务是否为前置任务的主任务 + for (DemandTaskDto demandTask : demandTaskList) { + //有前置任务 + if (!StringUtils.isEmpty(demandTask.getPostTask())) { + if (demandTask.getPostTask().equals(preTaskId.toString()) && personId == demandTask.getObject()) { + return getNameByPersonId(uid, demandTask.getSubject()); + } + } + } + } + return ""; + } + + /** + * 玩家下线 + */ + public static void offLine(String uid) { + Player player = TimingAcquisition.playerMap.get(uid); + //更新玩家为离线状态 + player.setStatus(Constants.OFFLINE); + //修改下线时间 + player.setOfflineTime(DateUtil.getCurrentTime()); + //创建玩家数据路径 + String path = MD5Util.changeToPath(uid, player.getSeries()); + //--------------持久化该玩家信息--------------- + PersistenceUtil.saveDataToFile(path, player.getGateNo(), JSON.toJSONString(player)); + //-----------------清除该玩家的数据缓存----------------- + TimingAcquisition.playerMap.remove(uid); + //--------------持久化该玩家系列汇总的数据--------------- + String dataPath = MD5Util.changeToDataPath(uid, player.getSeries()); + PersistenceUtil.saveDataToFile(dataPath, uid, JSON.toJSONString(TimingAcquisition.seriesPlayerMap.get(player.getSeries()).get(uid))); + //-----------------清除该玩家系列汇总的数据----------------- + TimingAcquisition.seriesPlayerMap.get(player.getSeries()).remove(uid); + } + + /** + * NPC死亡的判断。-1:死亡,其他值表示活着 + */ + public static int checkPersonLife(String uid, String operateName, OperationRequest operationReq) { + Integer personId = operationReq.getSubjectId(); + String locationId = operationReq.getLocationId(); + Player player = TimingAcquisition.playerMap.get(uid); + //去找人的操作 + if ("关卡操作".equals(operateName)) { + String methodId = operationReq.getMethodId(); + List moveOperateList = Arrays.asList("4001", "4002"); + //找人 + if (moveOperateList.contains(methodId)) { + //根据人名找 + if (!StringUtils.isEmpty(personId)) { + if (player.getPersonInfoMap().get(personId).getLifeState() == 1) { + String personName = player.getId2NameMap().get(personId); + log.info(operationReq.getUid() + "对话的" + personName + "已经死亡"); + return -1; + } + } + //根据场所找 + if (!StringUtils.isEmpty(locationId)) { + //找到场所里的人 + List personIdList = getPersonsByLocationId(uid, locationId); + List pidIdList = new ArrayList<>(); + if (!StringUtils.isEmpty(personIdList)) { + for (Integer pid : personIdList) { + if (player.getPersonInfoMap().get(pid).getLifeState() != 1) { + pidIdList.add(pid); + } + } + if (pidIdList.size() == 0) { + String personName = player.getId2NameMap().get(personId); + log.info(operationReq.getUid() + "对话的" + personName + "已经死亡"); + return -1; + } else { + return 0; + } + } + } + } + } + Integer currentId = player.getPersonId(); + if (player.getPersonInfoMap().get(currentId).getLifeState() == 1) { + String personName = player.getId2NameMap().get(currentId); + log.info(operationReq.getUid() + "对话的" + personName + "已经死亡"); + return -1; + } + return 0; + } } diff --git a/src/main/java/com/qiwu/inference/common/utils/RedisUtil.java b/src/main/java/com/qiwu/inference/common/utils/RedisUtil.java new file mode 100644 index 0000000..8d1d143 --- /dev/null +++ b/src/main/java/com/qiwu/inference/common/utils/RedisUtil.java @@ -0,0 +1,70 @@ +package com.qiwu.inference.common.utils; + +import com.alibaba.fastjson.JSON; +import com.qiwu.inference.common.TimingAcquisition; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import java.util.concurrent.TimeUnit; + +@Component +public class RedisUtil { + @Value("${redisExpireTime}") + private String redisExpireTime; + + @Autowired + private RedisTemplate redisTemplate; + + public void setStr(String key, String value) { + //存入redis缓存中,设置过期时间 + redisTemplate.opsForValue().set(key, value, Long.parseLong(redisExpireTime), TimeUnit.MILLISECONDS); + } + + public String getStr(String key) { + //存redis缓存中根据key取出value + return (String) redisTemplate.opsForValue().get(key); + } + + public void setHash(String key, String hk, String hv) { + //存入redis缓存中 + redisTemplate.opsForHash().put(key, hk, hv); + //设置过期时间 + redisTemplate.opsForHash().getOperations().expire(key, Long.parseLong(redisExpireTime), TimeUnit.MILLISECONDS); + } + + public String getHash(String key, String hk) { + //存入redis缓存中 + return (String) redisTemplate.opsForHash().get(key, hk); + } + + public void delHash(String key, String hk) { + redisTemplate.opsForHash().delete(key, hk); + } + + //判断key是否存在 + public boolean keyIsExists(String key) { + return Boolean.TRUE.equals(redisTemplate.hasKey(key)); + } + + //key续期 + public void renewalStr(String key, long times, TimeUnit timeUnit) { + if (!StringUtils.isEmpty(getStr(key))) { + //设置过期时间 + redisTemplate.opsForValue().getOperations().expire(key, times, timeUnit); + } + } + + //key续期 + public void renewalHash(String key, String hk, long times, TimeUnit timeUnit) { + if (!StringUtils.isEmpty(getHash(key, hk))) { + //设置过期时间 + redisTemplate.opsForHash().getOperations().expire(key, times, timeUnit); + } + } +} diff --git a/src/main/java/com/qiwu/inference/common/utils/RequestConversionUtil.java b/src/main/java/com/qiwu/inference/common/utils/RequestConversionUtil.java index 72bc67a..e6de29f 100644 --- a/src/main/java/com/qiwu/inference/common/utils/RequestConversionUtil.java +++ b/src/main/java/com/qiwu/inference/common/utils/RequestConversionUtil.java @@ -1,5 +1,6 @@ package com.qiwu.inference.common.utils; +import com.qiwu.inference.common.Constants; import com.qiwu.inference.common.TimingAcquisition; import com.qiwu.inference.dto.request.CallRequest; import com.qiwu.inference.dto.request.CommonRequest; @@ -18,12 +19,23 @@ public class RequestConversionUtil { public static OperationRequest request2Operation(CommonRequest commonRequest) { OperationRequest operationRequest = new OperationRequest(); CallRequest callRequest = commonRequest.getVars(); - operationRequest.setUid(commonRequest.getUid()); + String uid = commonRequest.getUid(); + operationRequest.setUid(uid); + //---------------------存在"系列名称"----------------------- + String series = callRequest.get系列名称(); + if (!StringUtils.isEmpty(series)) { + operationRequest.setSeries(series.trim()); + } + //---------------------存在"关卡名称"----------------------- + String gateName = callRequest.get关卡名称(); + if (!StringUtils.isEmpty(gateName)) { + operationRequest.setGateName(gateName.trim()); + } //---------------------存在"方法编号"----------------------- String methodId = callRequest.get方法编号(); if (!StringUtils.isEmpty(methodId)) { - operationRequest.setMethodId(methodId); + operationRequest.setMethodId(methodId.trim()); } //---------------------存在"人物名称1"----------------------- String subjectName = callRequest.get人物名称1(); @@ -63,56 +75,73 @@ public class RequestConversionUtil { //---------------------存在"性格类型"----------------------- String dispositionType = callRequest.get性格类型(); if (!StringUtils.isEmpty(dispositionType)) { - operationRequest.setDispositionType(dispositionType); + operationRequest.setDispositionType(dispositionType.trim()); } //---------------------存在"性格名称"----------------------- String dispositionName = callRequest.get性格名称(); if (!StringUtils.isEmpty(dispositionName)) { - operationRequest.setDispositionName(dispositionName); + operationRequest.setDispositionName(dispositionName.trim()); } //---------------------存在"关系名称"----------------------- String relationName = callRequest.get关系名称(); if (!StringUtils.isEmpty(relationName)) { - operationRequest.setRelationName(relationName); + operationRequest.setRelationName(relationName.trim()); } //---------------------存在"行为名称"----------------------- String behaviourName = callRequest.get行为名称(); if (!StringUtils.isEmpty(behaviourName)) { - operationRequest.setBehaviourName(behaviourName); + operationRequest.setBehaviourName(behaviourName.trim()); } //---------------------存在"任务名称"----------------------- String taskName = callRequest.get任务名称(); if (!StringUtils.isEmpty(taskName)) { - operationRequest.setTaskName(taskName); + operationRequest.setTaskName(taskName.trim()); } //---------------------存在"身份名称"----------------------- String identityName = callRequest.get身份名称(); if (!StringUtils.isEmpty(identityName)) { - operationRequest.setIdentityName(identityName); + operationRequest.setIdentityName(identityName.trim()); } //---------------------存在"场所名称"----------------------- String locationName = callRequest.get场所名称(); if (!StringUtils.isEmpty(locationName)) { - String locationId = TimingAcquisition.getLocationIdByName(locationName); - operationRequest.setLocationName(locationName); - operationRequest.setLocationId(locationId); + Integer num = TypeConvertUtil.change2Integer(locationName); + if (num == 0) { + //中文中不包含中文数字时,提取阿拉伯数字 + num = TypeConvertUtil.extractNum(locationName); + if (num != Constants.REQ_NON) { + operationRequest.setLocationId(num.toString()); + } else { + String locationId = TimingAcquisition.getLocationIdByName(uid, locationName); + operationRequest.setLocationName(locationName); + operationRequest.setLocationId(locationId); + } + } else { + operationRequest.setLocationId(num.toString()); + } } //---------------------存在"人物名称ID"----------------------- String subjectId = callRequest.get人物名称ID(); if (!StringUtils.isEmpty(subjectId)) { - operationRequest.setSubjectId(Integer.valueOf(subjectId)); + operationRequest.setSubjectId(Integer.valueOf(subjectId.trim())); } //---------------------存在"任务条件"----------------------- String taskConditionId = callRequest.get任务条件(); if (!StringUtils.isEmpty(taskConditionId)) { - operationRequest.setTaskConditionId(taskConditionId); + operationRequest.setTaskConditionId(taskConditionId.trim()); } //---------------------存在"线索类型"----------------------- String clueType = callRequest.get线索类型(); if (!StringUtils.isEmpty(clueType)) { - Integer clueTypeId = TimingAcquisition.getClueTypeIdByName(clueType); + Integer clueTypeId = TimingAcquisition.getClueTypeIdByName(uid, clueType); operationRequest.setClueTypeId(clueTypeId); } + //---------------------存在"道具名称"----------------------- + String partnerItem = callRequest.get伙伴物品名称(); + if (!StringUtils.isEmpty(partnerItem)) { + Integer partnerItemId = ConfigDataUtil.getPartnerItemIdByName(uid, partnerItem.trim()); + operationRequest.setPartnerItemId(partnerItemId); + } return operationRequest; } } diff --git a/src/main/java/com/qiwu/inference/common/utils/SpeechUtil.java b/src/main/java/com/qiwu/inference/common/utils/SpeechUtil.java index 12759dc..d7fd449 100644 --- a/src/main/java/com/qiwu/inference/common/utils/SpeechUtil.java +++ b/src/main/java/com/qiwu/inference/common/utils/SpeechUtil.java @@ -2,17 +2,30 @@ package com.qiwu.inference.common.utils; import cn.hutool.poi.excel.ExcelReader; import cn.hutool.poi.excel.ExcelUtil; +import com.opencsv.CSVReader; +import com.opencsv.CSVReaderBuilder; +import com.qiwu.inference.common.Constants; import com.qiwu.inference.common.TimingAcquisition; import com.qiwu.inference.dto.*; import com.qiwu.inference.pojo.*; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; -import java.io.File; +import java.io.*; +import java.nio.charset.Charset; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; +@Component public class SpeechUtil { + public static String expireTime; + @Value("${expireTime}") + public void setExpireTime(String expireTime) { + SpeechUtil.expireTime = expireTime; + } + /** * 取指定范围内的随机数 * @param num1 @@ -29,13 +42,22 @@ public class SpeechUtil { } /** * 从询问模块话术获取话术 + * * @param uid * @param someone * @param feedText * @return String */ - public static String getAskSpeech(String someone, Integer feedText) { + public static String getAskSpeech(String uid, String someone, Integer feedText) { String result = ""; - List speech = TimingAcquisition.askSpeechMap.get(someone).get(feedText); + List speech; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map>> askSpeechMap = TimingAcquisition.gateNoAskSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(askSpeechMap)) { + speech = askSpeechMap.get(someone).get(feedText); + } else { + speech = TimingAcquisition.seriesAskSpeechMap.get(series).get(someone).get(feedText); + } Integer i = getRandomNum(0, speech.size()); result = speech.get(i); return result; @@ -43,13 +65,45 @@ public class SpeechUtil { /** * 从任务模块话术获取话术 + * @param uid + * @param someone + * @param feedText + * @return String + */ + public static String getTaskSpeech(String uid, String someone, Integer feedText) { + String result = ""; + List speech; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map>> askSpeechMap = TimingAcquisition.gateNoTaskSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(askSpeechMap)) { + speech = askSpeechMap.get(someone).get(feedText); + } else { + speech = TimingAcquisition.seriesTaskSpeechMap.get(series).get(someone).get(feedText); + } + Integer i = getRandomNum(0, speech.size()); + result = speech.get(i); + return result; + } + + /** + * 从查看模块话术获取话术 + * @param uid * @param someone * @param feedText * @return String */ - public static String getTaskSpeech(String someone, Integer feedText) { + public static String getCheckSpeech(String uid, String someone, Integer feedText) { String result = ""; - List speech = TimingAcquisition.taskSpeechMap.get(someone).get(feedText); + List speech; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map>> askSpeechMap = TimingAcquisition.gateNoCheckSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(askSpeechMap)) { + speech = askSpeechMap.get(someone).get(feedText); + } else { + speech = TimingAcquisition.seriesCheckSpeechMap.get(series).get(someone).get(feedText); + } Integer i = getRandomNum(0, speech.size()); result = speech.get(i); return result; @@ -57,13 +111,22 @@ public class SpeechUtil { /** * 从查看模块话术获取话术 + * @param uid * @param someone * @param feedText * @return String */ - public static String getCheckSpeech(String someone, Integer feedText) { + public static String getBarrierSpeech(String uid, String someone, Integer feedText) { String result = ""; - List speech = TimingAcquisition.checkSpeechMap.get(someone).get(feedText); + List speech; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map>> askSpeechMap = TimingAcquisition.gateNoBarrierSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(askSpeechMap)) { + speech = askSpeechMap.get(someone).get(feedText); + } else { + speech = TimingAcquisition.seriesBarrierSpeechMap.get(series).get(someone).get(feedText); + } Integer i = getRandomNum(0, speech.size()); result = speech.get(i); return result; @@ -71,13 +134,22 @@ public class SpeechUtil { /** * 从查看模块话术获取话术 + * @param uid * @param someone * @param feedText * @return String */ - public static String getBarrierSpeech(String someone, Integer feedText) { + public static String getPartnerItemSpeech(String uid, String someone, Integer feedText) { String result = ""; - List speech = TimingAcquisition.barrierSpeechMap.get(someone).get(feedText); + List speech; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map>> askSpeechMap = TimingAcquisition.gateNoPartnerItemSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(askSpeechMap)) { + speech = askSpeechMap.get(someone).get(feedText); + } else { + speech = TimingAcquisition.seriesPartnerItemSpeechMap.get(series).get(someone).get(feedText); + } Integer i = getRandomNum(0, speech.size()); result = speech.get(i); return result; @@ -229,10 +301,10 @@ public class SpeechUtil { /** * 获取线索配置表中的话术 */ - public static String getSpeechFromClue(String uid, Integer taskId) { - DemandTask demandTask = TimingAcquisition.demandTaskMap.get(taskId); - return null; - } +// public static String getSpeechFromClue(String uid, Integer taskId) { +// DemandTask demandTask = TimingAcquisition.demandTaskMap.get(taskId); +// return null; +// } /** * 删除话术的开头“【旁白@正常】” @@ -258,7 +330,16 @@ public class SpeechUtil { * @return String */ public static String replaceHeader(String text, String name) { - return text.replaceAll("【人物名称", "【" + name); + if (text.contains("【A】")) { + text = text.replaceAll("【A】", name);; + } + if (text.contains("【A")) { + text = text.replaceAll("【A", "【" + name);; + } + if (text.contains("【人物名称")) { + text = text.replaceAll("【人物名称", "【" + name);; + } + return text; } /** @@ -274,22 +355,10 @@ public class SpeechUtil { /** * 加载闲聊话术 */ - public static Map> getChatSpeechModel(String speechFilePath) { - String chatPath = speechFilePath + "chat.xlsx"; - ExcelReader reader = ExcelUtil.getReader(new File(chatPath)); - reader.addHeaderAlias("意图反馈", "methodId"); - reader.addHeaderAlias("身份", "identity"); - reader.addHeaderAlias("人物ID", "personId"); - reader.addHeaderAlias("性别", "gender"); - reader.addHeaderAlias("年龄段", "age"); - reader.addHeaderAlias("性格A", "dispositionIds"); - reader.addHeaderAlias("行为", "behaviour"); - reader.addHeaderAlias("任务状态", "taskStatus"); - reader.addHeaderAlias("关系", "degree"); - reader.addHeaderAlias("文本内容", "answer"); - reader.addHeaderAlias("通用标签", "flag"); - List chatList = reader.readAll(ChatSpeech.class); - reader.close(); + public static Map> getChatSpeechModel(String speechFilePath) throws IOException { + String chatPath = speechFilePath + "chat.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List chatList = csvUtil.read(chatPath, ChatSpeech.class); Map> chatSpeechMap = new ConcurrentHashMap<>(); for (ChatSpeech chat : chatList) { if (StringUtils.isEmpty(chatSpeechMap.get(chat.getMethodId()))) { @@ -307,22 +376,9 @@ public class SpeechUtil { * 加载线索成功的话术 */ public static Map> getClueSpeechModel(String speechFilePath) { - String clueSpeechPath = speechFilePath + "clue_success.xlsx"; - ExcelReader reader = ExcelUtil.getReader(new File(clueSpeechPath)); - reader.addHeaderAlias("线索ID", "clueId"); - reader.addHeaderAlias("任务名称", "taskName"); - reader.addHeaderAlias("身份1", "identity"); - reader.addHeaderAlias("性别", "gender"); - reader.addHeaderAlias("人物ID", "personId"); - reader.addHeaderAlias("年龄段", "age"); - reader.addHeaderAlias("性格A", "dispositionIds"); - reader.addHeaderAlias("行为", "behaviour"); - reader.addHeaderAlias("任务状态", "status"); - reader.addHeaderAlias("线索文本", "answer"); - reader.addHeaderAlias("自身线索文本", "answerSelf"); - reader.addHeaderAlias("通用标签", "flag"); - List clueSpeechList = reader.readAll(ClueSpeech.class); - reader.close(); + String clueSpeechPath = speechFilePath + "clue_success.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List clueSpeechList = csvUtil.read(clueSpeechPath, ClueSpeech.class); Map> clueSpeechMap = new ConcurrentHashMap<>(); for (ClueSpeech clueSpeech : clueSpeechList) { if (StringUtils.isEmpty(clueSpeechMap.get(clueSpeech.getClueId()))) { @@ -340,24 +396,9 @@ public class SpeechUtil { * 加载任务成功的话术 */ public static Map> getTaskSpeechModel(String speechFilePath) { - String taskSpeechPath = speechFilePath + "task_success.xlsx"; - ExcelReader reader = ExcelUtil.getReader(new File(taskSpeechPath)); - reader.addHeaderAlias("线索ID", "demandTaskId"); - reader.addHeaderAlias("任务名称", "taskName"); - reader.addHeaderAlias("身份1", "identity"); - reader.addHeaderAlias("性别", "gender"); - reader.addHeaderAlias("人物ID", "personId"); - reader.addHeaderAlias("年龄段", "age"); - reader.addHeaderAlias("性格A", "dispositionIds"); - reader.addHeaderAlias("行为", "behaviour"); - reader.addHeaderAlias("任务状态", "status"); - reader.addHeaderAlias("进行中任务询问", "doingAsk"); - reader.addHeaderAlias("进行中任务完成提醒", "doingFinishedAnswer"); - reader.addHeaderAlias("未进行中任务完成提醒", "noDoingFinishedAnswer"); - reader.addHeaderAlias("完成对话文本", "answer"); - reader.addHeaderAlias("通用标签", "flag"); - List taskSpeechList = reader.readAll(TaskSpeech.class); - reader.close(); + String taskSpeechPath = speechFilePath + "task_success.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List taskSpeechList = csvUtil.read(taskSpeechPath, TaskSpeech.class); Map> taskSpeechMap = new ConcurrentHashMap<>(); for (TaskSpeech taskSpeech : taskSpeechList) { if (StringUtils.isEmpty(taskSpeechMap.get(taskSpeech.getDemandTaskId()))) { @@ -375,15 +416,9 @@ public class SpeechUtil { * 加载人物见面成功的话术 */ public static Map> getPersonSpeechModel(String speechFilePath) { - String personSpeechPath = speechFilePath + "person.xlsx"; - ExcelReader reader = ExcelUtil.getReader(new File(personSpeechPath)); - reader.addHeaderAlias("ID", "personId"); - reader.addHeaderAlias("人物名称", "name"); - reader.addHeaderAlias("人物描述", "description"); - reader.addHeaderAlias("首次回复", "firstAnswer"); - reader.addHeaderAlias("回复", "answer"); - List personSpeechList = reader.readAll(PersonSpeech.class); - reader.close(); + String personSpeechPath = speechFilePath + "person.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List personSpeechList = csvUtil.read(personSpeechPath, PersonSpeech.class); Map> personSpeechMap = new ConcurrentHashMap<>(); for (PersonSpeech personSpeech : personSpeechList) { if (StringUtils.isEmpty(personSpeechMap.get(personSpeech.getName()))) { @@ -401,14 +436,9 @@ public class SpeechUtil { * 加载任务提示的话术 */ public static Map> getTipSpeechModel(String speechFilePath) { - String tipSpeechPath = speechFilePath + "tip.xlsx"; - ExcelReader reader = ExcelUtil.getReader(new File(tipSpeechPath)); - reader.addHeaderAlias("ID", "demandTaskId"); - reader.addHeaderAlias("关于自身线索的指引", "selfClue"); - reader.addHeaderAlias("关于他人线索的指引", "otherClue"); - reader.addHeaderAlias("关于任务的指引", "taskClue"); - List tipSpeechList = reader.readAll(TipSpeech.class); - reader.close(); + String tipSpeechPath = speechFilePath + "tip.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List tipSpeechList = csvUtil.read(tipSpeechPath, TipSpeech.class); Map> tipSpeechMap = new ConcurrentHashMap<>(); for (TipSpeech tipSpeech : tipSpeechList) { if (StringUtils.isEmpty(tipSpeechMap.get(tipSpeech.getDemandTaskId()))) { @@ -423,6 +453,54 @@ public class SpeechUtil { } /** + * 加载操作提示的话术 + */ + public static Map getOperateSpeechModel(String speechFilePath) { + String operateSpeechPath = speechFilePath + "operate.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List operateSpeechList = csvUtil.read(operateSpeechPath, OperateSpeech.class); + Map operateSpeechMap = new ConcurrentHashMap<>(); + for (OperateSpeech operateSpeech : operateSpeechList) { + operateSpeechMap.put(operateSpeech.getId(), operateSpeech); + } + return operateSpeechMap; + } + + /** + * 加载任务异常的话术 + */ + public static Map getTaskExceptionSpeechModel(String speechFilePath) { + String taskExceptionSpeechPath = speechFilePath + "task_exception.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List taskExceptionSpeechList = csvUtil.read(taskExceptionSpeechPath, TaskExceptionSpeech.class); + Map taskExceptionSpeechMap = new ConcurrentHashMap<>(); + for (TaskExceptionSpeech taskExceptionSpeech : taskExceptionSpeechList) { + taskExceptionSpeechMap.put(taskExceptionSpeech.getId(), taskExceptionSpeech); + } + return taskExceptionSpeechMap; + } + + /** + * 加载原因的话术 + */ + public static Map> getPreReasonSpeechModel(String speechFilePath) { + String preReasonSpeechPath = speechFilePath + "pre_reason.csv"; + CsvUtil csvUtil = new CsvUtil<>(); + List preReasonSpeechList = csvUtil.read(preReasonSpeechPath, PreReasonSpeech.class); + Map> preReasonSpeechMap = new ConcurrentHashMap<>(); + for (PreReasonSpeech preReasonSpeech : preReasonSpeechList) { + if (StringUtils.isEmpty(preReasonSpeechMap.get(preReasonSpeech.getClueId()))) { + List preReasonSpeeches = new ArrayList<>(); + preReasonSpeeches.add(preReasonSpeech); + preReasonSpeechMap.put(preReasonSpeech.getClueId(), preReasonSpeeches); + } else { + preReasonSpeechMap.get(preReasonSpeech.getClueId()).add(preReasonSpeech); + } + } + return preReasonSpeechMap; + } + + /** * 获取闲聊的话术 * @param uid * @param person @@ -431,8 +509,18 @@ public class SpeechUtil { public static String getChatSpeech(String uid, Person person, String methodId) { String text = ""; Map countMap = new HashMap<>(); - List chatList = TimingAcquisition.chatSpeechMap.get(Integer.valueOf(methodId)); + List chatList = new ArrayList<>(); + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map> chatSpeechMap = TimingAcquisition.gateNoChatSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(chatSpeechMap)) { + chatList = chatSpeechMap.get(Integer.valueOf(methodId)); + } else { + chatList = TimingAcquisition.seriesChatSpeechMap.get(series).get(Integer.valueOf(methodId)); + } String gender = person.getGender() == 1 ? "男" : "女"; + //当前对话人 + PersonInfoDto talk = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(person.getId()); boolean flag = false; //有条件标记 int num = 0; for (int i = 0; i < chatList.size(); i++) { @@ -452,6 +540,14 @@ public class SpeechUtil { continue; } } + //符合人物名称 + if (!StringUtils.isEmpty(chatSpeech.getPersonName())) { + if (person.getName().equals(chatSpeech.getPersonName())) { + count++; + } else { + continue; + } + } //符合性别 if (!StringUtils.isEmpty(chatSpeech.getGender())) { if (gender.equals(chatSpeech.getGender())) { @@ -483,6 +579,33 @@ public class SpeechUtil { continue; } } + //符合信任值 + if (!StringUtils.isEmpty(chatSpeech.getTrust())) { + String[] trustRange = chatSpeech.getTrust().split("\\|"); + if(NumberUtil.inNumRange(talk.getTrustDegree(),"["+trustRange[0]+","+trustRange[1]+"]")) { + count++; + } else { + continue; + } + } + //符合威慑度 + if (!StringUtils.isEmpty(chatSpeech.getDeterrence())) { + String[] deterrenceRange = chatSpeech.getDeterrence().split("\\|"); + if(NumberUtil.inNumRange(talk.getDeterrenceDegree(),"["+deterrenceRange[0]+","+deterrenceRange[1]+"]")) { + count++; + } else { + continue; + } + } + //符合时间范围 + if (!StringUtils.isEmpty(chatSpeech.getTime())) { + String[] timeRange = chatSpeech.getTime().split("\\|"); + if(NumberUtil.inNumRange(TimingAcquisition.playerMap.get(uid).getInitTime(),"["+timeRange[0]+","+timeRange[1]+"]")) { + count++; + } else { + continue; + } + } countMap.put(i, count); } int max = 0; @@ -498,7 +621,12 @@ public class SpeechUtil { //有配置但是没有找到对应的话术 if (!flag) { //没有对应话术时,采用笼统的回复 - List normalChatList = TimingAcquisition.chatSpeechMap.get(9002); + List normalChatList = new ArrayList<>(); + if (!StringUtils.isEmpty(chatSpeechMap)) { + normalChatList = chatSpeechMap.get(9002); + } else { + normalChatList = TimingAcquisition.seriesChatSpeechMap.get(series).get(9002); + } for (ChatSpeech speech : normalChatList) { //符合身份 if (!StringUtils.isEmpty(speech.getIdentity())) { @@ -517,9 +645,156 @@ public class SpeechUtil { //获取对应话术 text = chatList.get(index).getAnswer(); } + text = text.replace("\n", ""); + String[] result = text.split("\\|"); +// int i = getRandomNum(0, result.length); + int i = PlayerUtil.getNumByMethodId(uid, methodId, result.length); + text = result[i]; + //操作为9001的模糊闲聊操作,则提示相应的线索 + if ("9001".equals(methodId)) { + //线索提示文本 + ClueDto clue = getClueTextByTypeLevel(uid, person, text); +// while (StringUtils.isEmpty(clue)) { +// int random = getRandomNum(0, result.length); +// text = result[random]; +// clue = getClueTextByTypeLevel(person, text); +// } + if (StringUtils.isEmpty(clue)) { + String textCopy = null; + for (String s : result) { + textCopy = s; + clue = getClueTextByTypeLevel(uid, person, textCopy); + if (!StringUtils.isEmpty(clue)) { + text = textCopy; + break; + } + } + } + String taskText = ""; + String addText = ""; + if (!StringUtils.isEmpty(clue)) { +// if (clue.getType() == 6) { +// DemandTaskDto demandTaskDto = PlayerUtil.getDemandTaskByClueId(person, clue); +// ClueDto preClue = PlayerUtil.getPreClueById(person, demandTaskDto); +// //获取对应话术 +// if (!StringUtils.isEmpty(preClue) && !StringUtils.isEmpty(demandTaskDto)) { +// preText = SpeechUtil.getPreReasonSpeech(uid, person, preClue, demandTaskDto.getDemandTaskId()); +// if (!StringUtils.isEmpty(preText)) { +// preText = SpeechUtil.addHeader(preText, person.getName()); +// } +// } +// } + //找到了对应的线索 + addText = getSuccessClueSpeech(uid, person, clue); + Integer currentId = TimingAcquisition.playerMap.get(uid).getPersonId(); +// String currentName = TimingAcquisition.getNameByPersonId(uid, currentId); +// if (currentId.equals(clue.getSubject()) || currentId.equals(clue.getObject())) { +// addText = addText.replace("【" + currentName + "@正常" + "】", "【人物名称@正常】"); +// addText = addText.replace("据说", "").replace("听说", "").replace(currentName, "我"); +// addText = replaceHeader(addText, currentName); +// } + if (clue.getType() == 6) { + //自身的任务线索 + if (currentId.equals(clue.getSubject())) { + Person subject = PlayerUtil.getPersonMap(uid).get(clue.getSubject()); + DemandTaskDto demandTaskDto = PlayerUtil.getDemandTaskByClueId(subject, clue); + Integer subjectId = person.getId(); + //----------------是否解锁任务------------- + PlayerUtil.unlockTask(uid, TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(subjectId), clue); + if (!StringUtils.isEmpty(demandTaskDto)) { + //判断后置任务是否已经完成 + int isFinished = PlayerUtil.checkTaskStatus(uid, subjectId, demandTaskDto.getDemandTaskId()); + //未完成 + if (isFinished == 0) { + if (demandTaskDto.getIsAuto() == 1) { + String condition1 = demandTaskDto.getCondition1(); + String[] taskIdTimes = condition1.split("\\|"); + if ("71000".equals(taskIdTimes[0])) { + Integer preTaskId = demandTaskDto.getDemandTaskId(); //后置 + DemandTaskDto demandTaskPre = PlayerUtil.getDemandTaskInfo(uid, subjectId, preTaskId); + //找到前置任务 + if (!StringUtils.isEmpty(demandTaskPre)) { + //后置任务自动完成 + PlayerUtil.taskFinished(uid, subjectId, preTaskId); + String preText = SpeechUtil.getSuccessTaskSpeech(uid, person, demandTaskPre); + //有配置前置任务 + if (!StringUtils.isEmpty(demandTaskDto.getPostTask())) { + Integer postTaskId = Integer.valueOf(demandTaskDto.getPostTask());; //前置 + //后置任务的主体 + Integer objectId = demandTaskPre.getObject(); + DemandTaskDto demandTaskPost = PlayerUtil.getDemandTaskInfo(uid, objectId, postTaskId); + if (!StringUtils.isEmpty(demandTaskPost)) { + //前置任务自动完成 + PlayerUtil.taskFinished(uid, objectId, postTaskId); + String postText = SpeechUtil.getSuccessTaskSpeech(uid, person, demandTaskPost); + taskText += postText; + } + } + taskText += preText; + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTaskDto.getTaskLabel() == 3 || TimingAcquisition.playerMap.get(uid).getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); + } + } + } + } + } + } + } + } + addText = addText + taskText; + } + if (text.contains("<")) { + int start = text.indexOf("<"); + text = text.substring(0, start); + } + text += addText; + } return text; } + /** + * 根据话术里的线索类型和层级过滤 + */ + public static ClueDto getClueTextByTypeLevel(String uid, Person person, String text) { + //话术中没有配置需要返回线索提示 + if (!text.contains("<")) { + return null; + } + //配置了需要返回线索提示 + int start = text.indexOf("<"); + int end = text.indexOf(">"); + String typeLevel = text.substring(start + 1, end); + String[] typeAndLevel = typeLevel.split("&"); + int type = Integer.parseInt(typeAndLevel[0]); + int level = Integer.parseInt(typeAndLevel[1]); + List clueList = PlayerUtil.getCluesByType(person, type, level); + //过滤掉已经完成的任务对应的线索 + clueList = PlayerUtil.getUndoClueList(uid, person, clueList); + Integer currentId = TimingAcquisition.playerMap.get(uid).getPersonId(); + List clueCopyList = new ArrayList<>(); + for (ClueDto clue : clueList) { + //过滤掉自身线索 + if (!currentId.equals(clue.getSubject())) { + if (!StringUtils.isEmpty(clue.getObject())) { + if (!currentId.equals(clue.getObject())) { + clueCopyList.add(clue); + } + } else { + clueCopyList.add(clue); + } + } + } + //没有找到对应的线索 + if (clueCopyList.size() == 0) { + return null; + } + int index = RandomUtil.randomInt(clueCopyList.size()); + //找到了对应的线索 + return clueCopyList.get(index); + } + /** * 获取线索成功的话术 @@ -530,9 +805,17 @@ public class SpeechUtil { public static String getSuccessClueSpeech(String uid, Person person, ClueDto clue) { String text = ""; Map countMap = new HashMap<>(); - Map> successClueSpeechMap = TimingAcquisition.successClueSpeechMap; - List clueSpeechList = successClueSpeechMap.get(clue.getClueId()); + List clueSpeechList; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map> clueSpeechMap = TimingAcquisition.gateNoSuccessClueSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(clueSpeechMap)) { + clueSpeechList = clueSpeechMap.get(clue.getClueId()); + } else { + clueSpeechList = TimingAcquisition.seriesSuccessClueSpeechMap.get(series).get(clue.getClueId()); + } String gender = person.getGender() == 1 ? "男" : "女"; + String currentName = TimingAcquisition.getNameByPersonId(uid, TimingAcquisition.playerMap.get(uid).getPersonId()); for (int i = 1; i < clueSpeechList.size(); i++) { ClueSpeech clueSpeech = clueSpeechList.get(i); int count = 0; @@ -590,6 +873,7 @@ public class SpeechUtil { //获取对应话术 if (!person.getId().equals(clue.getSubject())) { text = clueSpeechList.get(0).getAnswer(); +// text = SpeechUtil.addHeader(text, currentName); } else { text = clueSpeechList.get(0).getAnswerSelf(); } @@ -597,6 +881,7 @@ public class SpeechUtil { //获取对应话术 if (!person.getId().equals(clue.getSubject())) { text = clueSpeechList.get(index).getAnswer(); +// text = SpeechUtil.addHeader(text, currentName); } else { text = clueSpeechList.get(index).getAnswerSelf(); } @@ -609,7 +894,7 @@ public class SpeechUtil { text = text.replace("【B】", TimingAcquisition.getNameByPersonId(uid, clue.getObject())); } if (text.contains("【第三人称】")) { - String call = (TimingAcquisition.playerMap.get(uid).getPersonMap().get(clue.getSubject()).getGender() == 1) ? "他" : "她"; + String call = (PlayerUtil.getPersonMap(uid).get(clue.getSubject()).getGender() == 1) ? "他" : "她"; text = text.replace("【第三人称】", call); } if (text.contains("A")) { @@ -618,43 +903,59 @@ public class SpeechUtil { if (text.contains("B")) { text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, clue.getObject())); } + String[] result = text.split("\\|"); + Integer i = getRandomNum(0, result.length); + text = result[i]; + text = text.replace("\n", ""); + //如果没有指定说话人,则默认当前对话人 + if (!text.contains("@正常】")) { + text = addHeader(text, person.getName()); + } return text; } /** - * 获取任务成功的话术 + * 获取线索成功的话术 * @param uid * @param person - * @param demandTask + * @param clue */ - public static String getSuccessTaskSpeech(String uid, Person person, DemandTaskDto demandTask) { + public static String getSuccessClueOtherSpeech(String uid, Person person, ClueDto clue) { String text = ""; Map countMap = new HashMap<>(); - Map> successTaskSpeechMap = TimingAcquisition.successTaskSpeechMap; - List taskSpeechList = successTaskSpeechMap.get(demandTask.getDemandTaskId()); + List clueSpeechList; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map> clueSpeechMap = TimingAcquisition.gateNoSuccessClueSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(clueSpeechMap)) { + clueSpeechList = clueSpeechMap.get(clue.getClueId()); + } else { + clueSpeechList = TimingAcquisition.seriesSuccessClueSpeechMap.get(series).get(clue.getClueId()); + } String gender = person.getGender() == 1 ? "男" : "女"; - for (int i = 1; i < taskSpeechList.size(); i++) { - TaskSpeech taskSpeech = taskSpeechList.get(i); + String currentName = TimingAcquisition.getNameByPersonId(uid, TimingAcquisition.playerMap.get(uid).getPersonId()); + for (int i = 1; i < clueSpeechList.size(); i++) { + ClueSpeech clueSpeech = clueSpeechList.get(i); int count = 0; //符合身份 - if (!StringUtils.isEmpty(taskSpeech.getIdentity())) { - if (person.getIdentityName().equals(taskSpeech.getIdentity())) { + if (!StringUtils.isEmpty(clueSpeech.getIdentity())) { + if (person.getIdentityName().equals(clueSpeech.getIdentity())) { count++; } else { continue; } } //符合性别 - if (!StringUtils.isEmpty(taskSpeech.getGender())) { - if (gender.equals(taskSpeech.getGender())) { + if (!StringUtils.isEmpty(clueSpeech.getGender())) { + if (gender.equals(clueSpeech.getGender())) { count++; } else { continue; } } //符合年龄 - if (!StringUtils.isEmpty(taskSpeech.getAge())) { - String[] ageRange = taskSpeech.getAge().split("\\|"); + if (!StringUtils.isEmpty(clueSpeech.getAge())) { + String[] ageRange = clueSpeech.getAge().split("\\|"); if(NumberUtil.inNumRange(person.getAge(),"["+ageRange[0]+","+ageRange[1]+"]")) { count++; } else { @@ -662,8 +963,8 @@ public class SpeechUtil { } } //符合性格 - if (!StringUtils.isEmpty(taskSpeech.getDispositionIds())) { - String[] dispositionIds = taskSpeech.getDispositionIds().split("\\|"); + if (!StringUtils.isEmpty(clueSpeech.getDispositionIds())) { + String[] dispositionIds = clueSpeech.getDispositionIds().split("\\|"); //话术的性格要求 List dispositionIdList = Arrays.stream(dispositionIds).map(Integer::new).collect(Collectors.toList()); //对话人的性格要求 @@ -688,88 +989,81 @@ public class SpeechUtil { } if (max == 0) { //获取对应话术 - text = taskSpeechList.get(0).getAnswer(); + text = clueSpeechList.get(0).getAnswer(); } else { //获取对应话术 - text = taskSpeechList.get(index).getAnswer(); + text = clueSpeechList.get(index).getAnswer(); } //话术中配置数据替换 if (text.contains("【A】")) { - text = text.replace("【A】", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + text = text.replace("【A】", TimingAcquisition.getNameByPersonId(uid, clue.getSubject())); } if (text.contains("【B】")) { - text = text.replace("【B】", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + text = text.replace("【B】", TimingAcquisition.getNameByPersonId(uid, clue.getObject())); } if (text.contains("【第三人称】")) { - String call = (TimingAcquisition.playerMap.get(uid).getPersonMap().get(demandTask.getSubject()).getGender() == 1) ? "他" : "她"; + String call = (PlayerUtil.getPersonMap(uid).get(clue.getSubject()).getGender() == 1) ? "他" : "她"; text = text.replace("【第三人称】", call); } - if (text.contains("【条件2】")) { - if (!StringUtils.isEmpty(demandTask.getCondition2())) { - text = text.replace("【条件2】", demandTask.getCondition2()); - } - } - if (text.contains("【奖励】")) { - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - if (!"0".equals(demandTask.getCompletionReward())) { - PlayerUtil.addMoneyNum(uid, Integer.parseInt(demandTask.getCompletionReward())); - text = text.replace("【奖励】", demandTask.getCompletionReward()); - } - } - } if (text.contains("A")) { - text = text.replace("A", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + text = text.replace("A", TimingAcquisition.getNameByPersonId(uid, clue.getSubject())); } if (text.contains("B")) { - text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, clue.getObject())); } - //补充信任值和威慑度增减的回复 - String addText = "【旁白@正常】【1】对你的信任达到【2】,对你的畏惧达到【3】。"; - addText = speechReplaceNum(addText, person.getName(), String.valueOf(person.getTrustDegree()), String.valueOf(person.getDeterrenceDegree())); -// if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { -// if (!"0".equals(demandTask.getCompletionReward())) { -// addText += "你获得" + demandTask.getCompletionReward() + "文酬劳。"; -// } -// } - text += addText; + String[] result = text.split("\\|"); + Integer i = getRandomNum(0, result.length); + text = result[i]; text = text.replace("\n", ""); + //如果没有指定说话人,则默认当前对话人 + if (!text.contains("@正常】")) { + text = addHeader(text, person.getName()); + } return text; } /** - * 获取前后置任务成功的话术 + * 获取线索成功的话术 * @param uid * @param person - * @param demandTask + * @param clue */ - public static String getPreSuccessTaskSpeech(String uid, Person person, DemandTaskDto demandTask, int level) { + public static String getClueWithPreSpeech(String uid, Person person, ClueDto clue) { String text = ""; Map countMap = new HashMap<>(); - Map> successTaskSpeechMap = TimingAcquisition.successTaskSpeechMap; - List taskSpeechList = successTaskSpeechMap.get(demandTask.getDemandTaskId()); + List clueSpeechList; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map> clueSpeechMap = TimingAcquisition.gateNoSuccessClueSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(clueSpeechMap)) { + clueSpeechList = clueSpeechMap.get(clue.getClueId()); + } else { + clueSpeechList = TimingAcquisition.seriesSuccessClueSpeechMap.get(series).get(clue.getClueId()); + } String gender = person.getGender() == 1 ? "男" : "女"; - for (int i = 1; i < taskSpeechList.size(); i++) { - TaskSpeech taskSpeech = taskSpeechList.get(i); + String currentName = TimingAcquisition.getNameByPersonId(uid, TimingAcquisition.playerMap.get(uid).getPersonId()); + for (int i = 1; i < clueSpeechList.size(); i++) { + ClueSpeech clueSpeech = clueSpeechList.get(i); int count = 0; //符合身份 - if (!StringUtils.isEmpty(taskSpeech.getIdentity())) { - if (person.getIdentityName().equals(taskSpeech.getIdentity())) { + if (!StringUtils.isEmpty(clueSpeech.getIdentity())) { + if (person.getIdentityName().equals(clueSpeech.getIdentity())) { count++; } else { continue; } } //符合性别 - if (!StringUtils.isEmpty(taskSpeech.getGender())) { - if (gender.equals(taskSpeech.getGender())) { + if (!StringUtils.isEmpty(clueSpeech.getGender())) { + if (gender.equals(clueSpeech.getGender())) { count++; } else { continue; } } //符合年龄 - if (!StringUtils.isEmpty(taskSpeech.getAge())) { - String[] ageRange = taskSpeech.getAge().split("\\|"); + if (!StringUtils.isEmpty(clueSpeech.getAge())) { + String[] ageRange = clueSpeech.getAge().split("\\|"); if(NumberUtil.inNumRange(person.getAge(),"["+ageRange[0]+","+ageRange[1]+"]")) { count++; } else { @@ -777,8 +1071,8 @@ public class SpeechUtil { } } //符合性格 - if (!StringUtils.isEmpty(taskSpeech.getDispositionIds())) { - String[] dispositionIds = taskSpeech.getDispositionIds().split("\\|"); + if (!StringUtils.isEmpty(clueSpeech.getDispositionIds())) { + String[] dispositionIds = clueSpeech.getDispositionIds().split("\\|"); //话术的性格要求 List dispositionIdList = Arrays.stream(dispositionIds).map(Integer::new).collect(Collectors.toList()); //对话人的性格要求 @@ -801,116 +1095,657 @@ public class SpeechUtil { index = entry.getKey(); } } - String addText = ""; if (max == 0) { //获取对应话术 - if (level == 1) { - text = taskSpeechList.get(0).getDoingFinishedAnswer(); - text += taskSpeechList.get(0).getAnswer(); - } - if (level == 2) { - text = taskSpeechList.get(0).getNoDoingFinishedAnswer(); - text += taskSpeechList.get(0).getAnswer(); - } - if (level == 3) { - text = taskSpeechList.get(0).getDoingAsk(); + if (!person.getId().equals(clue.getSubject())) { + text = clueSpeechList.get(0).getAnswer(); + text = SpeechUtil.addHeader(text, currentName); + } else { + text = clueSpeechList.get(0).getAnswerSelf(); } } else { //获取对应话术 - if (level == 1) { - text = taskSpeechList.get(index).getDoingFinishedAnswer(); - text += taskSpeechList.get(index).getAnswer(); - //补充信任值和威慑度增减的回复 - addText = "【旁白@正常】【1】对你的信任达到【2】,对你的畏惧达到【3】。"; - addText = speechReplaceNum(addText, person.getName(), String.valueOf(person.getTrustDegree()), String.valueOf(person.getDeterrenceDegree())); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - if (!"0".equals(demandTask.getCompletionReward())) { - addText += "你获得" + demandTask.getCompletionReward() + "文酬劳。"; - } - } - } - if (level == 2) { - text = taskSpeechList.get(index).getNoDoingFinishedAnswer(); - text += taskSpeechList.get(index).getAnswer(); - //补充信任值和威慑度增减的回复 - addText = "【旁白@正常】【1】对你的信任达到【2】,对你的畏惧达到【3】。"; - addText = speechReplaceNum(addText, person.getName(), String.valueOf(person.getTrustDegree()), String.valueOf(person.getDeterrenceDegree())); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - if (!"0".equals(demandTask.getCompletionReward())) { - addText += "你获得" + demandTask.getCompletionReward() + "文酬劳。"; - } - } - } - if (level == 3) { - text = taskSpeechList.get(index).getDoingAsk(); + if (!person.getId().equals(clue.getSubject())) { + text = clueSpeechList.get(index).getAnswer(); + text = SpeechUtil.addHeader(text, currentName); + } else { + text = clueSpeechList.get(index).getAnswerSelf(); } } - text = addHeader(text, person.getName()); //话术中配置数据替换 if (text.contains("【A】")) { - text = text.replace("【A】", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + text = text.replace("【A】", TimingAcquisition.getNameByPersonId(uid, clue.getSubject())); } if (text.contains("【B】")) { - text = text.replace("【B】", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + text = text.replace("【B】", TimingAcquisition.getNameByPersonId(uid, clue.getObject())); } if (text.contains("【第三人称】")) { - String call = (TimingAcquisition.playerMap.get(uid).getPersonMap().get(demandTask.getSubject()).getGender() == 1) ? "他" : "她"; + String call = (PlayerUtil.getPersonMap(uid).get(clue.getSubject()).getGender() == 1) ? "他" : "她"; text = text.replace("【第三人称】", call); } - if (text.contains("【条件2】")) { - if (!StringUtils.isEmpty(demandTask.getCondition2())) { - text = text.replace("【条件2】", demandTask.getCondition2()); - } - } - if (text.contains("【奖励】")) { - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - if (!"0".equals(demandTask.getCompletionReward())) { - PlayerUtil.addMoneyNum(uid, Integer.parseInt(demandTask.getCompletionReward())); - text = text.replace("【奖励】", demandTask.getCompletionReward()); - } - } - } if (text.contains("A")) { - text = text.replace("A", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + text = text.replace("A", TimingAcquisition.getNameByPersonId(uid, clue.getSubject())); } if (text.contains("B")) { - text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, clue.getObject())); } - text += addText; + String[] result = text.split("\\|"); + Integer i = getRandomNum(0, result.length); + text = result[i]; text = text.replace("\n", ""); return text; } /** - * 获取自身任务线索提示的话术 + * 获取任务成功的话术 * @param uid + * @param person * @param demandTask - * @param personId - * @param source */ - public static String getTipSpeech(String uid, DemandTaskDto demandTask, Integer personId, int source) { + public static String getSuccessTaskSpeech(String uid, Person person, DemandTaskDto demandTask) { String text = ""; - Map> tipSpeechMap = TimingAcquisition.tipSpeechMap; - List tipSpeechList = tipSpeechMap.get(demandTask.getDemandTaskId()); - //当前能做的任务线索 - if (source == 1) { - //获取对应话术 - text = tipSpeechList.get(0).getTaskClue(); + Map countMap = new HashMap<>(); + List taskSpeechList; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map> taskSpeechMap = TimingAcquisition.gateNoSuccessTaskSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(taskSpeechMap)) { + taskSpeechList = taskSpeechMap.get(demandTask.getDemandTaskId()); + } else { + taskSpeechList = TimingAcquisition.seriesSuccessTaskSpeechMap.get(series).get(demandTask.getDemandTaskId()); } - //自身能解锁任务的线索 - if (source == 2) { - //获取对应话术 - text = tipSpeechList.get(0).getSelfClue(); + String gender = person.getGender() == 1 ? "男" : "女"; + if (StringUtils.isEmpty(taskSpeechList)) { + return text; } - //他人能解锁任务的线索 - if (source == 3) { - //获取对应话术 + for (int i = 1; i < taskSpeechList.size(); i++) { + TaskSpeech taskSpeech = taskSpeechList.get(i); + int count = 0; + //符合身份 + if (!StringUtils.isEmpty(taskSpeech.getIdentity())) { + if (person.getIdentityName().equals(taskSpeech.getIdentity())) { + count++; + } else { + continue; + } + } + //符合性别 + if (!StringUtils.isEmpty(taskSpeech.getGender())) { + if (gender.equals(taskSpeech.getGender())) { + count++; + } else { + continue; + } + } + //符合年龄 + if (!StringUtils.isEmpty(taskSpeech.getAge())) { + String[] ageRange = taskSpeech.getAge().split("\\|"); + if(NumberUtil.inNumRange(person.getAge(),"["+ageRange[0]+","+ageRange[1]+"]")) { + count++; + } else { + continue; + } + } + //符合性格 + if (!StringUtils.isEmpty(taskSpeech.getDispositionIds())) { + String[] dispositionIds = taskSpeech.getDispositionIds().split("\\|"); + //话术的性格要求 + List dispositionIdList = Arrays.stream(dispositionIds).map(Integer::new).collect(Collectors.toList()); + //对话人的性格要求 + List dispositionPerson = person.getDispositions().stream().map(DispositionDto::getDispositionId).collect(Collectors.toList()); + //所有性格都符合 + if (PlayerUtil.checkSubset(dispositionIdList, dispositionPerson)) { + count++; + } else { + continue; + } + } + countMap.put(i, count); + } + int max = 0; + int index = 0; + //找到命中次数最多的索引 + for (Map.Entry entry : countMap.entrySet()) { + if (entry.getValue() > max) { + max = entry.getValue(); + index = entry.getKey(); + } + } + if (max == 0) { + //获取对应话术 + text = taskSpeechList.get(0).getAnswer(); + } else { + //获取对应话术 + text = taskSpeechList.get(index).getAnswer(); + } + //话术中配置数据替换 + if (text.contains("【A】")) { + text = text.replace("【A】", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + } + if (text.contains("【B】")) { + text = text.replace("【B】", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + } + if (text.contains("【第三人称】")) { + String call = (PlayerUtil.getPersonMap(uid).get(demandTask.getSubject()).getGender() == 1) ? "他" : "她"; + text = text.replace("【第三人称】", call); + } + if (text.contains("【条件2】")) { + if (!StringUtils.isEmpty(demandTask.getCost())) { + String[] cost = demandTask.getCost().split("\\|"); + text = text.replace("【条件2】", cost[0]); + } + } + if (text.contains("【奖励】")) { + if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { + if (!"0".equals(demandTask.getCompletionReward())) { + PlayerUtil.addMoneyNum(uid, Integer.parseInt(demandTask.getCompletionReward())); + text = text.replace("【奖励】", demandTask.getCompletionReward()); + } + } + } + if (text.contains("【消费货币】")) { + if (!StringUtils.isEmpty(demandTask.getCost())) { + String[] cost = demandTask.getCost().split("\\|"); + text = text.replace("【消费货币】", cost[0]); + } + } + if (text.contains("A")) { + text = text.replace("A", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + } + if (text.contains("B")) { + text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + } + int trustDegree = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(person.getId()).getTrustDegree(); + int deterrenceDegree = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(person.getId()).getDeterrenceDegree(); + if (text.contains("【好感度】")) { + text = text.replace("【好感度】", String.valueOf(trustDegree - 50)); + } + if (text.contains("【威慑度】")) { + text = text.replace("【威慑度】", String.valueOf(deterrenceDegree - 50)); + } + if (text.contains("【S】")) { + text = text.replace("【S】", PlayerUtil.getSubjectNameByPreTaskId(uid, demandTask.getSubject(), demandTask.getDemandTaskId())); + } + if (text.contains("【S@正常】")) { + String name = "【" + PlayerUtil.getSubjectNameByPreTaskId(uid, demandTask.getSubject(), demandTask.getDemandTaskId()) + "@正常】"; + text = text.replace("【S@正常】", name); + } + //补充信任值和威慑度增减的回复 +// String addText = "【旁白@正常】【1】对你的信任达到【2】,对你的畏惧达到【3】。"; +// addText = speechReplaceNum(addText, person.getName(), String.valueOf(trustDegree - 50), String.valueOf(deterrenceDegree - 50)); +// if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { +// if (!"0".equals(demandTask.getCompletionReward())) { +// addText += "你获得" + demandTask.getCompletionReward() + "文酬劳。"; +// } +// } +// text += addText; + text = text.replace("\n", ""); + String[] result = text.split("\\|"); + Integer i = getRandomNum(0, result.length); + text = result[i]; + return text; + } + + /** + * 获取任务二次回复的话术 + * @param uid + * @param person + * @param demandTask + */ + public static String getSuccessTaskReplySpeech(String uid, Person person, DemandTaskDto demandTask, ReplyDto reply) { + String text = ""; + Map countMap = new HashMap<>(); + List taskSpeechList; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map> taskSpeechMap = TimingAcquisition.gateNoSuccessTaskSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(taskSpeechMap)) { + taskSpeechList = taskSpeechMap.get(demandTask.getDemandTaskId()); + } else { + taskSpeechList = TimingAcquisition.seriesSuccessTaskSpeechMap.get(series).get(demandTask.getDemandTaskId()); + } + String gender = person.getGender() == 1 ? "男" : "女"; + if (StringUtils.isEmpty(taskSpeechList)) { + return text; + } + for (int i = 1; i < taskSpeechList.size(); i++) { + TaskSpeech taskSpeech = taskSpeechList.get(i); + int count = 0; + //符合身份 + if (!StringUtils.isEmpty(taskSpeech.getIdentity())) { + if (person.getIdentityName().equals(taskSpeech.getIdentity())) { + count++; + } else { + continue; + } + } + //符合性别 + if (!StringUtils.isEmpty(taskSpeech.getGender())) { + if (gender.equals(taskSpeech.getGender())) { + count++; + } else { + continue; + } + } + //符合年龄 + if (!StringUtils.isEmpty(taskSpeech.getAge())) { + String[] ageRange = taskSpeech.getAge().split("\\|"); + if(NumberUtil.inNumRange(person.getAge(),"["+ageRange[0]+","+ageRange[1]+"]")) { + count++; + } else { + continue; + } + } + //符合性格 + if (!StringUtils.isEmpty(taskSpeech.getDispositionIds())) { + String[] dispositionIds = taskSpeech.getDispositionIds().split("\\|"); + //话术的性格要求 + List dispositionIdList = Arrays.stream(dispositionIds).map(Integer::new).collect(Collectors.toList()); + //对话人的性格要求 + List dispositionPerson = person.getDispositions().stream().map(DispositionDto::getDispositionId).collect(Collectors.toList()); + //所有性格都符合 + if (PlayerUtil.checkSubset(dispositionIdList, dispositionPerson)) { + count++; + } else { + continue; + } + } + countMap.put(i, count); + } + int max = 0; + int index = 0; + //找到命中次数最多的索引 + for (Map.Entry entry : countMap.entrySet()) { + if (entry.getValue() > max) { + max = entry.getValue(); + index = entry.getKey(); + } + } + if (max == 0) { + //获取对应话术 + text = taskSpeechList.get(0).getReplyAnswer(); + } else { + //获取对应话术 + text = taskSpeechList.get(index).getReplyAnswer(); + } + //话术中配置数据替换 + if (text.contains("【A】")) { + text = text.replace("【A】", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + } + if (text.contains("【B】")) { + text = text.replace("【B】", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + } + if (text.contains("【第三人称】")) { + String call = (PlayerUtil.getPersonMap(uid).get(demandTask.getSubject()).getGender() == 1) ? "他" : "她"; + text = text.replace("【第三人称】", call); + } + if (text.contains("【消费货币】")) { + if (!StringUtils.isEmpty(demandTask.getCost())) { + String[] cost = demandTask.getCost().split("\\|"); + text = text.replace("【消费货币】", cost[0]); + } + } + if (text.contains("【奖励】")) { + if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { + if (!"0".equals(demandTask.getCompletionReward())) { + PlayerUtil.addMoneyNum(uid, Integer.parseInt(demandTask.getCompletionReward())); + text = text.replace("【奖励】", demandTask.getCompletionReward()); + } + } + } + if (text.contains("【消费货币】")) { + if (!StringUtils.isEmpty(demandTask.getCost())) { + String[] cost = demandTask.getCost().split("\\|"); + text = text.replace("【消费货币】", cost[0]); + } + } + if (text.contains("A")) { + text = text.replace("A", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + } + if (text.contains("B")) { + text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + } + if (text.contains("【S】")) { + text = text.replace("【S】", PlayerUtil.getSubjectNameByPreTaskId(uid, demandTask.getSubject(), demandTask.getDemandTaskId())); + } + if (text.contains("【S@正常】")) { + String name = "【" + PlayerUtil.getSubjectNameByPreTaskId(uid, demandTask.getSubject(), demandTask.getDemandTaskId()) + "@正常】"; + text = text.replace("【S@正常】", name); + } + text = text.replace("\n", ""); + String[] result = text.split("\\|"); + int num = reply.getNum(); + text = result[num]; + if (num < result.length - 1) { + reply.setNum(num + 1); + } else { + reply.setNum(result.length - 1); + } + String unique = uid + gateNo; //用户uid和关卡编号组成唯一标识 + //保存上轮数据 + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + return text; + } + + /** + * 获取前后置任务成功的话术。level: 1-是进行中任务完成提醒;2-未进行中任务完成提醒;3-进行中任务询问.其中1和2会加上完成对话文本; + * 4-是任务启动文本;5-是任务中断或关闭文本 + * @param uid + * @param person + * @param demandTask + */ + public static String getPreSuccessTaskSpeech(String uid, Person person, DemandTaskDto demandTask, int level) { + String text = ""; + Map countMap = new HashMap<>(); + List taskSpeechList; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map> taskSpeechMap = TimingAcquisition.gateNoSuccessTaskSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(taskSpeechMap)) { + taskSpeechList = taskSpeechMap.get(demandTask.getDemandTaskId()); + } else { + taskSpeechList = TimingAcquisition.seriesSuccessTaskSpeechMap.get(series).get(demandTask.getDemandTaskId()); + } + if (StringUtils.isEmpty(taskSpeechList)) { + return text; + } + String gender = person.getGender() == 1 ? "男" : "女"; + for (int i = 1; i < taskSpeechList.size(); i++) { + TaskSpeech taskSpeech = taskSpeechList.get(i); + int count = 0; + //符合身份 + if (!StringUtils.isEmpty(taskSpeech.getIdentity())) { + if (person.getIdentityName().equals(taskSpeech.getIdentity())) { + count++; + } else { + continue; + } + } + //符合性别 + if (!StringUtils.isEmpty(taskSpeech.getGender())) { + if (gender.equals(taskSpeech.getGender())) { + count++; + } else { + continue; + } + } + //符合年龄 + if (!StringUtils.isEmpty(taskSpeech.getAge())) { + String[] ageRange = taskSpeech.getAge().split("\\|"); + if(NumberUtil.inNumRange(person.getAge(),"["+ageRange[0]+","+ageRange[1]+"]")) { + count++; + } else { + continue; + } + } + //符合性格 + if (!StringUtils.isEmpty(taskSpeech.getDispositionIds())) { + String[] dispositionIds = taskSpeech.getDispositionIds().split("\\|"); + //话术的性格要求 + List dispositionIdList = Arrays.stream(dispositionIds).map(Integer::new).collect(Collectors.toList()); + //对话人的性格要求 + List dispositionPerson = person.getDispositions().stream().map(DispositionDto::getDispositionId).collect(Collectors.toList()); + //所有性格都符合 + if (PlayerUtil.checkSubset(dispositionIdList, dispositionPerson)) { + count++; + } else { + continue; + } + } + countMap.put(i, count); + } + int max = 0; + int index = 0; + //找到命中次数最多的索引 + for (Map.Entry entry : countMap.entrySet()) { + if (entry.getValue() > max) { + max = entry.getValue(); + index = entry.getKey(); + } + } + String addText = ""; + if (max == 0) { + //获取对应话术 + if (level == 1) { + text = taskSpeechList.get(0).getDoingFinishedAnswer(); + text += taskSpeechList.get(0).getAnswer(); + } + if (level == 2) { + text = taskSpeechList.get(0).getNoDoingFinishedAnswer(); + text += taskSpeechList.get(0).getAnswer(); + } + if (level == 3) { + text = taskSpeechList.get(0).getDoingAsk(); + } + if (level == 4) { + text = taskSpeechList.get(0).getStartAnswer(); + } + if (level == 5) { + text = taskSpeechList.get(0).getCloseAnswer(); + } + } else { + //获取对应话术 + if (level == 1) { + text = taskSpeechList.get(index).getDoingFinishedAnswer(); + text += taskSpeechList.get(index).getAnswer(); + } + if (level == 2) { + text = taskSpeechList.get(index).getNoDoingFinishedAnswer(); + text += taskSpeechList.get(index).getAnswer(); + } + if (level == 3) { + text = taskSpeechList.get(index).getDoingAsk(); + } + if (level == 4) { + text = taskSpeechList.get(index).getStartAnswer(); + } + if (level == 5) { + text = taskSpeechList.get(index).getCloseAnswer(); + } + } + int trustDegree = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(person.getId()).getTrustDegree(); + int deterrenceDegree = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(person.getId()).getDeterrenceDegree(); + if (text.contains("【好感度】")) { + text = text.replace("【好感度】", String.valueOf(trustDegree - 50)); + } + if (text.contains("【威慑度】")) { + text = text.replace("【威慑度】", String.valueOf(deterrenceDegree - 50)); + } + if (level == 1) { +// if (!StringUtils.isEmpty(taskSpeechList.get(index).getDoingFinishedAnswer())) { +// text = addHeader(text, person.getName()); +// } + //补充信任值和威慑度增减的回复 +// addText = "【旁白@正常】【1】对你的信任达到【2】,对你的畏惧达到【3】。"; +// addText = speechReplaceNum(addText, person.getName(), String.valueOf(trustDegree - 50), String.valueOf(deterrenceDegree - 50)); + if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { + if (!"0".equals(demandTask.getCompletionReward())) { + addText += "你获得" + demandTask.getCompletionReward() + "文酬劳。"; + } + } + text += addText; + } + if (level == 2) { +// if (!StringUtils.isEmpty(taskSpeechList.get(index).getNoDoingFinishedAnswer())) { +// text = addHeader(text, person.getName()); +// } + //补充信任值和威慑度增减的回复 +// addText = "【旁白@正常】【1】对你的信任达到【2】,对你的畏惧达到【3】。"; +// addText = speechReplaceNum(addText, person.getName(), String.valueOf(trustDegree - 50), String.valueOf(deterrenceDegree - 50)); + if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { + if (!"0".equals(demandTask.getCompletionReward())) { + addText += "你获得" + demandTask.getCompletionReward() + "文酬劳。"; + } + } + text += addText; + } + if (level == 3) { +// if (!StringUtils.isEmpty(taskSpeechList.get(index).getDoingAsk())) { +// text = addHeader(text, person.getName()); +// } + } +// if (level == 4) { +// if (!StringUtils.isEmpty(taskSpeechList.get(index).getStartAnswer())) { +// text = addHeader(text, person.getName()); +// } +// } +// if (level == 5) { +// if (!StringUtils.isEmpty(taskSpeechList.get(index).getCloseAnswer())) { +// text = addHeader(text, person.getName()); +// } +// } + //话术中配置数据替换 + if (text.contains("【A】")) { + text = text.replace("【A】", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + } + if (text.contains("【B】")) { + text = text.replace("【B】", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + } + if (text.contains("【第三人称】")) { + String call = (PlayerUtil.getPersonMap(uid).get(demandTask.getSubject()).getGender() == 1) ? "他" : "她"; + text = text.replace("【第三人称】", call); + } + if (text.contains("【条件2】")) { + if (!StringUtils.isEmpty(demandTask.getCost())) { + String[] cost = demandTask.getCost().split("\\|"); + text = text.replace("【条件2】", cost[0]); + } + } + if (text.contains("【奖励】")) { + if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { + if (!"0".equals(demandTask.getCompletionReward())) { + PlayerUtil.addMoneyNum(uid, Integer.parseInt(demandTask.getCompletionReward())); + text = text.replace("【奖励】", demandTask.getCompletionReward()); + } + } + } + if (text.contains("【消费货币】")) { + if (!StringUtils.isEmpty(demandTask.getCost())) { + String[] cost = demandTask.getCost().split("\\|"); + text = text.replace("【消费货币】", cost[0]); + } + } + if (text.contains("A")) { + text = text.replace("A", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + } + if (text.contains("B")) { + text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + } + if (text.contains("【S】")) { + text = text.replace("【S】", PlayerUtil.getSubjectNameByPreTaskId(uid, demandTask.getSubject(), demandTask.getDemandTaskId())); + } + if (text.contains("【S@正常】")) { + String name = "【" + PlayerUtil.getSubjectNameByPreTaskId(uid, demandTask.getSubject(), demandTask.getDemandTaskId()) + "@正常】"; + text = text.replace("【S@正常】", name); + } + text = text.replace("\n", ""); + return text; + } + + /** + * 获取自身任务线索提示的话术 + * @param uid + * @param demandTask + * @param personId + * @param source + */ + public static String getTipSpeech(String uid, DemandTaskDto demandTask, Integer personId, int source) { + String text = ""; + List tipSpeechList; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map> tipSpeechMap = TimingAcquisition.gateNoTipSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(tipSpeechMap)) { + tipSpeechList = tipSpeechMap.get(demandTask.getDemandTaskId()); + } else { + tipSpeechList = TimingAcquisition.seriesTipSpeechMap.get(series).get(demandTask.getDemandTaskId()); + } + if (StringUtils.isEmpty(tipSpeechList)) { + return text; + } + //当前能做的任务线索 + if (source == 1) { + //获取对应话术 + text = tipSpeechList.get(0).getTaskClue(); + } + //自身能解锁任务的线索 + if (source == 2) { + //获取对应话术 + text = tipSpeechList.get(0).getSelfClue(); + } + //他人能解锁任务的线索 + if (source == 3) { + //获取对应话术 + text = tipSpeechList.get(0).getOtherClue(); + } + //话术中配置数据替换 + if (text.contains("【A】")) { + text = text.replace("【A】", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + } + if (text.contains("【A@正常】")) { + text = text.replace("【A@正常】", "【" + TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject()) + "@正常】"); + } + if (text.contains("【B】")) { + text = text.replace("【B】", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + } + if (personId != 0) { + if (text.contains("【C】")) { + text = text.replace("【C】", TimingAcquisition.getNameByPersonId(uid, personId)); + } + if (text.contains("【C@正常】")) { + text = text.replace("【C@正常】", "【" + TimingAcquisition.getNameByPersonId(uid, personId) + "@正常】"); + } + } + text = text.replace("\n", ""); + String[] result = text.split("\\|"); + Integer i = getRandomNum(0, result.length); + text = result[i]; + return text; + } + + /** + * 获取自身任务线索提示的话术,用于二次回复。source指代线索类型 + * @param uid + * @param demandTask + * @param personId + * @param source + */ + public static String getTipReplySpeech(String uid, DemandTaskDto demandTask, Integer personId, int source, ReplyDto reply) { + String text = ""; + List tipSpeechList; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map> tipSpeechMap = TimingAcquisition.gateNoTipSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(tipSpeechMap)) { + tipSpeechList = tipSpeechMap.get(demandTask.getDemandTaskId()); + } else { + tipSpeechList = TimingAcquisition.seriesTipSpeechMap.get(series).get(demandTask.getDemandTaskId()); + } + if (StringUtils.isEmpty(tipSpeechList)) { + return text; + } + //当前能做的任务线索 + if (source == 1) { + //获取对应话术 + text = tipSpeechList.get(0).getTaskClue(); + } + //自身能解锁任务的线索 + if (source == 2) { + //获取对应话术 + text = tipSpeechList.get(0).getSelfClue(); + } + //他人能解锁任务的线索 + if (source == 3) { + //获取对应话术 text = tipSpeechList.get(0).getOtherClue(); } //话术中配置数据替换 if (text.contains("【A】")) { text = text.replace("【A】", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); } + if (text.contains("【A@正常】")) { + text = text.replace("【A@正常】", "【" + TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject()) + "@正常】"); + } if (text.contains("【B】")) { text = text.replace("【B】", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); } @@ -918,8 +1753,23 @@ public class SpeechUtil { if (text.contains("【C】")) { text = text.replace("【C】", TimingAcquisition.getNameByPersonId(uid, personId)); } + if (text.contains("【C@正常】")) { + text = text.replace("【C@正常】", "【" + TimingAcquisition.getNameByPersonId(uid, personId) + "@正常】"); + } } + text = text.replace("\n", ""); + String[] result = text.split("\\|"); + int num = reply.getNum(); + text = result[num]; + if (num < result.length - 1) { + reply.setNum(num + 1); + } else { + reply.setNum(result.length - 1); + } + String unique = uid + gateNo; //用户uid和关卡编号组成唯一标识 + //保存上轮数据 + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); return text; } @@ -931,8 +1781,18 @@ public class SpeechUtil { */ public static String getTipSpeech(String uid, BarrierTaskKeyDto barrierTaskKey, Integer personId) { String text = ""; - Map> tipSpeechMap = TimingAcquisition.tipSpeechMap; - List tipSpeechList = tipSpeechMap.get(barrierTaskKey.getDemandTaskId()); + List tipSpeechList; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map> tipSpeechMap = TimingAcquisition.gateNoTipSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(tipSpeechMap)) { + tipSpeechList = tipSpeechMap.get(barrierTaskKey.getDemandTaskId()); + } else { + tipSpeechList = TimingAcquisition.seriesTipSpeechMap.get(series).get(barrierTaskKey.getDemandTaskId()); + } + if (StringUtils.isEmpty(tipSpeechList)) { + return text; + } //他人能解锁任务的线索 //获取对应话术 text = tipSpeechList.get(0).getOtherClue(); @@ -940,12 +1800,21 @@ public class SpeechUtil { if (text.contains("【A】")) { text = text.replace("【A】", TimingAcquisition.getNameByPersonId(uid, personId)); } + if (text.contains("【A@正常】")) { + text = text.replace("【A@正常】", "【" + TimingAcquisition.getNameByPersonId(uid, personId) + "@正常】"); + } if (personId != 0) { if (text.contains("【C】")) { text = text.replace("【C】", TimingAcquisition.getNameByPersonId(uid, barrierTaskKey.getSubject())); } + if (text.contains("【C@正常】")) { + text = text.replace("【C@正常】", "【" + TimingAcquisition.getNameByPersonId(uid, personId) + "@正常】"); + } } text = text.replace("\n", ""); + String[] result = text.split("\\|"); + Integer i = getRandomNum(0, result.length); + text = result[i]; return text; } @@ -954,16 +1823,469 @@ public class SpeechUtil { */ public static String getPersonSpeech(String uid, String locationId, Integer personId) { String text = ""; - String name = TimingAcquisition.playerMap.get(uid).getPersonMap().get(personId).getName(); + String name = PlayerUtil.getPersonMap(uid).get(personId).getName(); + List personSpeechList; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map> personSpeechMap = TimingAcquisition.gateNoPersonSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(personSpeechMap)) { + personSpeechList = personSpeechMap.get(name); + } else { + personSpeechList = TimingAcquisition.seriesPersonSpeechMap.get(series).get(name); + } //判断该人物是否是第一次见面 boolean isFirstMeet = PlayerUtil.isFirstMeet(uid, locationId, personId); if (isFirstMeet) { - String asideText = "【旁白@正常】" + TimingAcquisition.personSpeechMap.get(name).get(0).getDescription(); - String personText = "【人物名称@正常】" + TimingAcquisition.personSpeechMap.get(name).get(0).getFirstAnswer(); + String asideText = StringUtils.isEmpty(personSpeechList.get(0).getDescription()) ? "" : ("【旁白@正常】" + personSpeechList.get(0).getDescription()); + String personText = StringUtils.isEmpty(personSpeechList.get(0).getFirstAnswer()) ? "" : ("【人物名称@正常】" + personSpeechList.get(0).getFirstAnswer()); text = asideText + personText; } else { - text = "【人物名称@正常】" + TimingAcquisition.personSpeechMap.get(name).get(0).getAnswer(); + text = "【人物名称@正常】" + personSpeechList.get(0).getAnswer(); + } + String[] result = text.split("\\|"); + Integer i = getRandomNum(0, result.length); + text = result[i]; + return text; + } + + /** + * 获取人物见面时的话术 + */ + public static String getPersonFirstSpeech(String uid, String locationId, Integer personId) { + String text = ""; + String name = PlayerUtil.getPersonMap(uid).get(personId).getName(); + List personSpeechList; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map> personSpeechMap = TimingAcquisition.gateNoPersonSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(personSpeechMap)) { + personSpeechList = personSpeechMap.get(name); + } else { + personSpeechList = TimingAcquisition.seriesPersonSpeechMap.get(series).get(name); + } + //判断该人物是否是第一次见面 + boolean isFirstMeet = PlayerUtil.isFirstMeet(uid, locationId, personId); + if (isFirstMeet) { + if (!StringUtils.isEmpty(personSpeechList.get(0).getDescription())) { + text = "【旁白@正常】" + personSpeechList.get(0).getDescription(); + String personText = "【" + name + "@正常】" + personSpeechList.get(0).getFirstAnswer(); + text += personText; + } + } else { + text = ""; + } + String[] result = text.split("\\|"); + Integer i = getRandomNum(0, result.length); + text = result[i]; + return text; + } + + /** + * 获取人物见面时的话术 + */ + public static String getOperateSpeech(Player player) { + Integer index = player.getOperateTextNum(); + Map id2NameMap = player.getId2NameMap(); + String series = player.getSeries(); //系列 + String gateNo = player.getGateNo(); //关卡编号 + Map operateSpeechMap = TimingAcquisition.gateNoOperateSpeechMap.get(gateNo); + if (StringUtils.isEmpty(operateSpeechMap)) { + operateSpeechMap = TimingAcquisition.seriesOperateSpeechMap.get(series); + } + if (!StringUtils.isEmpty(operateSpeechMap.get(index))) { + String text = operateSpeechMap.get(index).getAnswer(); + if (text.contains("【1】")) { + text = text.replace("【1】", id2NameMap.get(1)); + } + if (text.contains("【2】")) { + text = text.replace("【2】", id2NameMap.get(2)); + } + if (text.contains("【3】")) { + text = text.replace("【3】", id2NameMap.get(3)); + } + if (text.contains("【4】")) { + text = text.replace("【4】", id2NameMap.get(4)); + } + if (text.contains("【5】")) { + text = text.replace("【5】", id2NameMap.get(5)); + } + if (text.contains("【6】")) { + text = text.replace("【6】", id2NameMap.get(6)); + } + if (text.contains("【7】")) { + text = text.replace("【7】", id2NameMap.get(7)); + } + if (text.contains("【8】")) { + text = text.replace("【8】", id2NameMap.get(8)); + } + return text; + } else { + return null; + } + } + + /** + * 获取前后置任务成功的话术 + * @param uid + * @param person + * @param demandTask + */ + public static String speechReplaceValue(String uid, String text, Person person, DemandTaskDto demandTask) { + //话术中配置数据替换 + if (text.contains("【A】")) { + text = text.replace("【A】", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + } + if (text.contains("【B】")) { + text = text.replace("【B】", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + } + if (text.contains("【第三人称】")) { + String call = (PlayerUtil.getPersonMap(uid).get(demandTask.getSubject()).getGender() == 1) ? "他" : "她"; + text = text.replace("【第三人称】", call); + } + if (text.contains("【条件2】")) { + if (!StringUtils.isEmpty(demandTask.getCost())) { + String[] cost = demandTask.getCost().split("\\|"); + text = text.replace("【条件2】", cost[0]); + } + } + if (text.contains("【奖励】")) { + if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { + if (!"0".equals(demandTask.getCompletionReward())) { + PlayerUtil.addMoneyNum(uid, Integer.parseInt(demandTask.getCompletionReward())); + text = text.replace("【奖励】", demandTask.getCompletionReward()); + } + } + } + if (text.contains("A")) { + text = text.replace("A", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + } + if (text.contains("B")) { + text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + } + if (text.contains("【信任值】")) { + int trustDegree = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(person.getId()).getTrustDegree(); + text = text.replace("【信任值】", String.valueOf(trustDegree - 50)); + } + if (text.contains("【威慑度】")) { + int deterrenceDegree = TimingAcquisition.playerMap.get(uid).getPersonInfoMap().get(person.getId()).getDeterrenceDegree(); + text = text.replace("【威慑度】", String.valueOf(deterrenceDegree - 50)); + } + text = text.replace("\n", ""); + return text; + } + + /** + * 获取关卡的开场白 + */ + public static String getPrologueSpeech(String uid, String gateNo) { +// int size = TimingAcquisition.barrierTaskKeyMap.get(gateNo).size(); +// Integer demandTaskId = TimingAcquisition.barrierTaskKeyMap.get(gateNo).get(size - 1).getDemandTaskId(); + String text = PlayerUtil.getDoingTaskAnswer(uid, TimingAcquisition.playerMap.get(uid).getPersonId()); + if (StringUtils.isEmpty(text)) { + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); //系列名称 + //搭档名称 + String partnerName = TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("partnerName").getValue(); + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 103102); + text = SpeechUtil.replaceHeader(text, partnerName); + String location = TimingAcquisition.seriesLocationMap.get(seriesName).get(TimingAcquisition.playerMap.get(uid).getLocation()).getName(); + String name = PlayerUtil.getNameByPersonId(uid, TimingAcquisition.playerMap.get(uid).getPersonId()); + text = SpeechUtil.speechReplaceNum(text, location, name); + //人物见面时的回复 + text += SpeechUtil.getPersonSpeech(uid, TimingAcquisition.playerMap.get(uid).getLocation(), TimingAcquisition.playerMap.get(uid).getPersonId()); + text = SpeechUtil.replaceHeader(text, name); + //开场白 +// Map endGoalMap = TimingAcquisition.endGoalMap; +// String text = ""; +// for (Map.Entry entry : endGoalMap.entrySet()) { +// EndGoal endGoal = entry.getValue(); +// List associatedTaskIds = Arrays.asList(endGoal.getAssociatedTaskId().split("\\|")); +// if (associatedTaskIds.contains(demandTaskId.toString())) { +// text = "【旁白@正常】" + endGoal.getName(); +// text += "【旁白@正常】" + endGoal.getDescription(); +// text += SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 103101); +// text += SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 103102); +// text = SpeechUtil.replaceHeader(text, partnerName); +// String location = TimingAcquisition.locationMap.get(TimingAcquisition.playerMap.get(uid).getLocation()).getName(); +// String name = PlayerUtil.getNameByPersonId(uid, TimingAcquisition.playerMap.get(uid).getPersonId()); +// text = SpeechUtil.speechReplaceNum(text, location, name); +// break; +// } +// } + } + return text; + } + + /** + * 获取任务异常反馈的话术 + */ + public static String getTaskExceptionSpeech(String uid, DemandTaskDto demandTask, String num) { + String text = ""; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + String[] condition1 = demandTask.getCondition1().split("\\|"); + Integer feedBackId = Integer.valueOf(condition1[0] + num); + Map taskExceptionSpeechMap = TimingAcquisition.gateNoTaskExceptionSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(taskExceptionSpeechMap)) { + text = taskExceptionSpeechMap.get(feedBackId).getAnswer(); + } else { + text = TimingAcquisition.seriesTaskExceptionSpeechMap.get(series).get(feedBackId).getAnswer(); + } + //话术中配置数据替换 + if (text.contains("A")) { + text = text.replace("A", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + } + if (text.contains("B")) { + text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + } + if (text.contains("【A】")) { + text = text.replace("【A】", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject())); + } + if (text.contains("【B】")) { + text = text.replace("【B】", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject())); + } + if (text.contains("【第三人称】")) { + String call = (PlayerUtil.getPersonMap(uid).get(demandTask.getSubject()).getGender() == 1) ? "他" : "她"; + text = text.replace("【第三人称】", call); + } + if (text.contains("【条件2】")) { + if (!StringUtils.isEmpty(demandTask.getCost())) { + String[] cost = demandTask.getCost().split("\\|"); + text = text.replace("【条件2】", cost[0]); + } + } + if (text.contains("【消费货币】")) { + if (!StringUtils.isEmpty(demandTask.getCost())) { + String[] cost = demandTask.getCost().split("\\|"); + text = text.replace("【消费货币】", cost[0]); + } + } + return text; + } + + /** + * 获取任务异常反馈的话术 + */ + public static String getTaskExceptionSpeech(String uid, String conditionTaskId, String num) { + String text = ""; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Integer feedBackId = Integer.valueOf(conditionTaskId + num); + Map taskExceptionSpeechMap = TimingAcquisition.gateNoTaskExceptionSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(taskExceptionSpeechMap)) { + text = taskExceptionSpeechMap.get(feedBackId).getAnswer(); + } else { + text = TimingAcquisition.seriesTaskExceptionSpeechMap.get(series).get(feedBackId).getAnswer(); + } + return text; + } + + /** + * 获取任务异常反馈的话术 + */ + public static String getTaskExceptionSpeech(String uid, String feedBackId) { + String text = ""; + String series = TimingAcquisition.playerMap.get(uid).getSeries(); //系列 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + Map taskExceptionSpeechMap = TimingAcquisition.gateNoTaskExceptionSpeechMap.get(gateNo); + if (!StringUtils.isEmpty(taskExceptionSpeechMap)) { + text = taskExceptionSpeechMap.get(Integer.valueOf(feedBackId)).getAnswer(); + } else { + text = TimingAcquisition.seriesTaskExceptionSpeechMap.get(series).get(Integer.valueOf(feedBackId)).getAnswer(); + } + return text; + } + + /** + * 获取线索成功的话术 + * @param uid + * @param person + * @param clue + */ + public static String getPreReasonSpeech(String uid, Person person, ClueDto clue, Integer demandTaskId) { + String text = ""; + Map countMap = new HashMap<>(); + Map> preReasonSpeechMap = TimingAcquisition.preReasonSpeechMap; + List preReasonSpeechList = preReasonSpeechMap.get(clue.getClueId()); + //当前对话人 + Integer currentId = TimingAcquisition.playerMap.get(uid).getPersonId(); + if (StringUtils.isEmpty(preReasonSpeechList)) { + return text; + } + String gender = person.getGender() == 1 ? "男" : "女"; + for (int i = 0; i < preReasonSpeechList.size(); i++) { + PreReasonSpeech preReasonSpeech = preReasonSpeechList.get(i); + int count = 0; + if (!preReasonSpeech.getDemandTaskId().equals(demandTaskId)) { + continue; + } + //符合行为 + if (!StringUtils.isEmpty(preReasonSpeech.getBehaviour())) { + Integer behaviour = preReasonSpeech.getBehaviour(); + List behaviourIdList = person.getBehaviours().stream().map(BehaviourDto::getBehaviourId).collect(Collectors.toList()); + if(behaviourIdList.contains(behaviour)) { + count++; + } else { + continue; + } + } + //符合关系 + if (!StringUtils.isEmpty(preReasonSpeech.getRelation())) { + Integer relation = preReasonSpeech.getRelation(); + List relationIdList = person.getRelations().stream().map(RelationDto::getRelationId).collect(Collectors.toList()); + if(relationIdList.contains(relation)) { + count++; + } else { + continue; + } + } + //符合性格 + if (!StringUtils.isEmpty(preReasonSpeech.getDispositionId())) { + //话术的性格要求 + Integer dispositionId = preReasonSpeech.getDispositionId(); + //对话人的性格要求 + List dispositionPerson = person.getDispositions().stream().map(DispositionDto::getDispositionId).collect(Collectors.toList()); + //所有性格都符合 + if (dispositionPerson.contains(dispositionId)) { + count++; + } else { + continue; + } + } + //符合自身身份 + if (!StringUtils.isEmpty(preReasonSpeech.getIdentity())) { + if (person.getIdentityId().equals(preReasonSpeech.getIdentity())) { + count++; + } else { + continue; + } + } + //符合对方身份 + if (!StringUtils.isEmpty(preReasonSpeech.getIdentitySide())) { + if (!StringUtils.isEmpty(clue.getObject())) { + Integer identityIdSide = PlayerUtil.getPersonMap(uid).get(clue.getObject()).getIdentityId(); + if (identityIdSide.equals(preReasonSpeech.getIdentitySide())) { + count++; + } else { + continue; + } + } + } + //符合性别 + if (!StringUtils.isEmpty(preReasonSpeech.getGender())) { + if (gender.equals(preReasonSpeech.getGender())) { + count++; + } else { + continue; + } + } + //符合年龄 + if (!StringUtils.isEmpty(preReasonSpeech.getAge())) { + String[] ageRange = preReasonSpeech.getAge().split("\\|"); + if(NumberUtil.inNumRange(person.getAge(),"["+ageRange[0]+","+ageRange[1]+"]")) { + count++; + } else { + continue; + } + } + countMap.put(i, count); + } + int max = 0; + List indexList = new ArrayList<>(); + //找到命中次数最多的索引 + for (Map.Entry entry : countMap.entrySet()) { + if (entry.getValue() >= max) { + max = entry.getValue(); + indexList.add(entry.getKey()); + } + } + if (max == 0) { + //获取对应话术 + if (!currentId.equals(clue.getSubject())) { + text = preReasonSpeechList.get(0).getAnswer(); + } else { + text = preReasonSpeechList.get(0).getAnswerSelf(); + } + } else { + int index = 0; + //命中次数最多的有多条,按优先级查找(行为 > 关系 > 性格) + if (indexList.size() > 1) { + //记录索引的优先级 + Map indexSortMap = new HashMap<>(); + //遍历所有索引,划分优先级 + for (Integer i : indexList) { + PreReasonSpeech preReasonSpeech = preReasonSpeechList.get(i); + //配置了行为 + if (!StringUtils.isEmpty(preReasonSpeech.getBehaviour())) { + //配置了自身身份 + if (!StringUtils.isEmpty(preReasonSpeech.getIdentity())) { + indexSortMap.put(i, 1); + } + //配置了对方身份 + if (!StringUtils.isEmpty(preReasonSpeech.getIdentitySide())) { + indexSortMap.put(i, 2); + } + } + //配置了关系 + if (!StringUtils.isEmpty(preReasonSpeech.getRelation())) { + //配置了自身身份 + if (!StringUtils.isEmpty(preReasonSpeech.getIdentity())) { + indexSortMap.put(i, 3); + } + //配置了对方身份 + if (!StringUtils.isEmpty(preReasonSpeech.getIdentitySide())) { + indexSortMap.put(i, 4); + } + } + //配置了性格 + if (!StringUtils.isEmpty(preReasonSpeech.getDispositionId())) { + //配置了自身身份 + if (!StringUtils.isEmpty(preReasonSpeech.getIdentity())) { + indexSortMap.put(i, 5); + } + //配置了对方身份 + if (!StringUtils.isEmpty(preReasonSpeech.getIdentitySide())) { + indexSortMap.put(i, 6); + } + } + } + //找出优先级最高的索引 + int min = 6; + for (Map.Entry entry : indexSortMap.entrySet()) { + if (entry.getValue() <= min) { + min = entry.getValue(); + index = entry.getKey(); + } + } + } else { + index = indexList.get(0); + } + //获取对应话术 + if (!currentId.equals(clue.getSubject())) { + text = preReasonSpeechList.get(index).getAnswer(); + } else { + text = preReasonSpeechList.get(index).getAnswerSelf(); + } + } + //话术中配置数据替换 + if (text.contains("【A】")) { + text = text.replace("【A】", TimingAcquisition.getNameByPersonId(uid, clue.getSubject())); + } + if (text.contains("【B】")) { + text = text.replace("【B】", TimingAcquisition.getNameByPersonId(uid, clue.getObject())); + } + if (text.contains("【第三人称】")) { + String call = (PlayerUtil.getPersonMap(uid).get(clue.getSubject()).getGender() == 1) ? "他" : "她"; + text = text.replace("【第三人称】", call); + } + if (text.contains("A")) { + text = text.replace("A", TimingAcquisition.getNameByPersonId(uid, clue.getSubject())); + } + if (text.contains("B")) { + text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, clue.getObject())); } + String[] result = text.split("\\|"); + Integer i = getRandomNum(0, result.length); + text = result[i]; return text; } } diff --git a/src/main/java/com/qiwu/inference/common/utils/TypeConvertUtil.java b/src/main/java/com/qiwu/inference/common/utils/TypeConvertUtil.java index aafeaa3..c54bb4b 100644 --- a/src/main/java/com/qiwu/inference/common/utils/TypeConvertUtil.java +++ b/src/main/java/com/qiwu/inference/common/utils/TypeConvertUtil.java @@ -1,6 +1,7 @@ package com.qiwu.inference.common.utils; import com.qiwu.inference.common.Constants; +import org.apache.poi.ss.formula.functions.T; import org.springframework.util.StringUtils; import java.util.ArrayList; @@ -303,27 +304,29 @@ public class TypeConvertUtil { } /** - * 选择的序号 + * 通过序号找到对应内容 */ - public static Object getNumFromList(List list, Integer num) { - Object result = new Object(); + public static T getNumFromList(List list, Integer num) { //第一个物品 if (num == Constants.REQ_FIRST) { - result = list.get(0); + return list.get(0); } //中间物品 if (num == Constants.REQ_MIDDLE) { - result = list.get(list.size() / 2); + return list.get(list.size() / 2); } //最后一个物品 if (num == Constants.REQ_LAST) { - result = list.get(list.size() - 1); + return list.get(list.size() - 1); } //随机一个物品 if (num == Constants.REQ_RANDOM) { int random = RandomUtil.randomInt(list.size()); - result = list.get(random); + return list.get(random); } - return result; + if (num > 0 && num < list.size()) { + return list.get(num - 1); + } + return null; } } diff --git a/src/main/java/com/qiwu/inference/controller/CommonController.java b/src/main/java/com/qiwu/inference/controller/CommonController.java index 1cca389..d89ffe2 100644 --- a/src/main/java/com/qiwu/inference/controller/CommonController.java +++ b/src/main/java/com/qiwu/inference/controller/CommonController.java @@ -3,10 +3,16 @@ package com.qiwu.inference.controller; import com.qiwu.inference.common.Constants; import com.qiwu.inference.common.TimingAcquisition; import com.qiwu.inference.common.api.CommonResult; +import com.qiwu.inference.common.cache.CacheGlobal; +import com.qiwu.inference.common.utils.CacheUtil; import com.qiwu.inference.common.utils.DataTrimUtil; +import com.qiwu.inference.common.utils.PlayerUtil; import com.qiwu.inference.common.utils.RequestConversionUtil; +import com.qiwu.inference.dto.DemandTaskDto; +import com.qiwu.inference.dto.ReplyDto; import com.qiwu.inference.dto.request.CommonRequest; import com.qiwu.inference.dto.request.OperationRequest; +import com.qiwu.inference.dto.response.CallResponse; import com.qiwu.inference.dto.response.ResultResponse; import com.qiwu.inference.dto.response.ResultVarsResponse; import com.qiwu.inference.service.ask.AskService; @@ -14,6 +20,7 @@ import com.qiwu.inference.service.barrier.BarrierService; import com.qiwu.inference.service.chat.ChatService; import com.qiwu.inference.service.check.CheckService; import com.qiwu.inference.service.login.LoginService; +import com.qiwu.inference.service.partner.PartnerService; import com.qiwu.inference.service.task.TaskService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,6 +33,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.text.ParseException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; @RestController @RequestMapping("/inference") @@ -53,20 +63,38 @@ public class CommonController { @Autowired private ChatService chatService; + @Autowired + private PartnerService partnerService; + @PostMapping(value = "/ask", produces = "application/json;charset=UTF-8") public CommonResult startGame(@RequestBody CommonRequest commonRequest) throws ParseException { - log.info(commonRequest.getUid() + "当前操作的原始请求参数:" + commonRequest.getVars()); + log.info(commonRequest.getUid() + "当前操作的原始请求参数:" + commonRequest.getVars() + ",原始话语:" + commonRequest.getOriginText()); CommonResult result = null; String uid = commonRequest.getUid(); boolean login = false; - //玩家第一次登录 - if (StringUtils.isEmpty(TimingAcquisition.playerMap.get(uid))) { - loginService.login(uid); + //玩家已经存在 + if (TimingAcquisition.uidList.contains(uid)) { + //玩家已经下线,重新加载 + if (StringUtils.isEmpty(TimingAcquisition.playerMap.get(uid))) { + loginService.loadPlayerData(commonRequest); + login = true; + } + } else { + //玩家第一次登录 + if (StringUtils.isEmpty(TimingAcquisition.playerMap.get(uid))) { + loginService.login(commonRequest); + login = true; + } + } + //玩家切换关卡后,保存上一关卡的数据,重新加载关卡数据 + String gateNo = TimingAcquisition.gateNameToNoMap.get(commonRequest.getVars().get关卡名称()); //玩家玩的当前的关卡 + if (!TimingAcquisition.playerMap.get(uid).getGateNo().equals(gateNo)) { + loginService.reloadPlayerData(commonRequest); login = true; } //请求参数转换 OperationRequest operationReq = RequestConversionUtil.request2Operation(commonRequest); - //非新登录玩家,修改在线状态 + //玩家操作后,修改在线状态和延长下线时间 if (!login && !StringUtils.isEmpty(uid)) { DataTrimUtil.AdjustStatus(commonRequest.getUid(), offlineTime); } @@ -76,17 +104,28 @@ public class CommonController { if (StringUtils.isEmpty(operateName)) { log.info(operationReq.getUid() + "未提供操作名,无法操作"); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); - ResultResponse resultResponse = new ResultResponse();; + ResultResponse resultResponse = new ResultResponse(); resultResponse.set反馈ID(100000); resultResponse.set反馈文本("【旁白@正常】你想做什么呢?"); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } + //玩家对话的当前NPC或者要找的NPC已经死亡 + int life = PlayerUtil.checkPersonLife(uid, operateName, operationReq); + if (life < 0) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + resultResponse.set反馈ID(100000); + resultResponse.set反馈文本("【旁白@正常】人不在了,去找其他人吧"); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } //统计玩家闲聊次数 if ("闲聊".equals(operateName)) { int chatTimes = TimingAcquisition.playerMap.get(uid).getChatTimes(); - int times = Integer.parseInt(TimingAcquisition.systemConfigMap.get("chatTimes").getValue()); - if (chatTimes > times) { + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); //系列名称 + int times = Integer.parseInt(TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("chatTimes").getValue()); + if (chatTimes >= times - 1) { TimingAcquisition.playerMap.get(uid).setChatTimes(0); } else { TimingAcquisition.playerMap.get(uid).setChatTimes(TimingAcquisition.playerMap.get(uid).getChatTimes() + 1); @@ -94,9 +133,30 @@ public class CommonController { } else { TimingAcquisition.playerMap.get(uid).setChatTimes(0); } + String unique = uid + gateNo; //用户uid和关卡编号组成唯一标识 + //当前玩家上一轮保存的数据 + ReplyDto reply = (ReplyDto) CacheUtil.get(unique); + //其他操作意图,清除缓存 + if (!StringUtils.isEmpty(reply)) { + Integer subjectId = reply.getSubjectId(); + Integer demandTaskId = reply.getDemandTaskId(); + //找到对应任务 + DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, demandTaskId); + if (!StringUtils.isEmpty(demandTask)) { + //为一次性任务 + int disposableLabel = demandTask.getDisposableLabel(); + if (disposableLabel != 0) { + List allowTask = Arrays.asList("任务同意操作", "任务拒绝操作", "任务中断操作", "伙伴操作"); + if (!allowTask.contains(operateName)) { + CacheGlobal.concurrentMap.remove(unique); + PlayerUtil.updateTaskStatus(uid, subjectId, demandTaskId, 6); + } + } + } + } switch (operateName) { case "开始游戏": - result = loginService.startGame(operationReq); + result = loginService.startGame(commonRequest); break; case "询问操作": result = askService.ask(operationReq); @@ -104,18 +164,39 @@ public class CommonController { case "任务操作": result = taskService.execute(operationReq); break; + case "任务同意操作": + result = taskService.agree(operationReq); + break; + case "任务拒绝操作": + result = taskService.refuse(operationReq); + break; + case "任务中断操作": + result = taskService.interrupt(operationReq); + break; case "查看操作": result = checkService.check(operationReq); break; + case "二次回复": + result = checkService.secondAnswer(operationReq); + break; + case "查看排行榜": + result = checkService.checkRanking(operationReq); + break; case "关卡操作": result = barrierService.operate(operationReq); break; case "取消操作指令": result = barrierService.cancel(operationReq); break; + case "切换场景": + result = barrierService.changePlace(operationReq); + break; case "闲聊": result = chatService.operate(operationReq); break; + case "伙伴操作": + result = partnerService.operate(operationReq); + break; } log.info(uid + "已完成操作:【" + operateName + "】"); return DataTrimUtil.AdjustParams(uid, result); diff --git a/src/main/java/com/qiwu/inference/controller/PlayerController.java b/src/main/java/com/qiwu/inference/controller/PlayerController.java index c2426a6..7fd9f9d 100755 --- a/src/main/java/com/qiwu/inference/controller/PlayerController.java +++ b/src/main/java/com/qiwu/inference/controller/PlayerController.java @@ -8,15 +8,18 @@ import com.qiwu.inference.common.api.CommonResult; import com.qiwu.inference.common.utils.*; import com.qiwu.inference.dto.Player; import com.qiwu.inference.dto.request.OperationRequest; +import com.qiwu.inference.dto.response.ResultResponse; import com.qiwu.inference.dto.response.ResultVarsResponse; import com.qiwu.inference.service.PersonRecordService; import com.qiwu.inference.service.player.PlayerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.List; +import java.util.Map; /** *

@@ -46,74 +49,79 @@ public class PlayerController { int index = RandomUtil.randomInt(gateNoList.size()); Player player = new Player(); player.setGateNo(gateNoList.get(index)); - String sid = UUID.fastUUID().toString(); - player.setSid(sid); - PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //ThreadLocalUtil.add(sid,player); + String uid = UUID.fastUUID().toString(); + player.setUid(uid); + PersistenceUtil.saveDataToFile(userFilePath, uid, JSON.toJSONString(player)); + //ThreadLocalUtil.add(uid,player); return CommonResult.success(player); } - @RequestMapping(value = "/operate", method = RequestMethod.POST) + @RequestMapping(value = "/getPlayerInfo", method = RequestMethod.GET) @ResponseBody - public CommonResult operate(@RequestBody OperationRequest request) throws Exception{ - String methodId = request.getMethodId(); - switch (methodId){ - case "1001": - case "1002": - return playerService.askDisposition(request); - case "1003": - case "1004": - case "1005": - case "1006": - return playerService.askRelation(request); - case "1007": - case "1008": - case "1009": - case "1010": - case "1011": - return playerService.askBehaviour(request); - case "1012": - case "1013": - case "1014": - case "1015": - case "1016": - case "1017": - case "1018": - case "1019": - case "1020": - case "1021": - case "1022": - return playerService.askTask(request); - case "1023": - case "1024": - return playerService.askIdentity(request); - case "1025": - case "1026": - return playerService.askLocation(request); - case "1027": - return playerService.askPrompt(request); - case "2001": - case "2003": - case "2002": - case "2004": - case "2005": - case "2006": - case "2007": - case "2008": - case "2009": - case "2010": - case "2011": - case "2012": - case "2013": - case "2014": - case "2015": - case "2016": - case "2017": - case "2018": - case "2019": - return playerService.performTask(request); + public CommonResult operate(String uid) throws Exception{ + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + Player player = TimingAcquisition.playerMap.get(uid); + //总人数 + int totalNum = TimingAcquisition.uidList.size(); + //在线人数 + int onlineNum = TimingAcquisition.playerMap.size(); + StringBuilder text = new StringBuilder(); + text.append("总人数:").append(totalNum).append("
").append("在线人数:").append(onlineNum).append("
"); + if (!TimingAcquisition.uidList.contains(uid)) { + text.append(uid).append("玩家不存在"); + resultResponse.set反馈ID(100001); + resultResponse.set反馈文本(text.toString()); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + if (StringUtils.isEmpty(player)) { + text.append(uid).append("下线了"); + resultResponse.set反馈ID(100002); + resultResponse.set反馈文本(text.toString()); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + String gateNo = player.getGateNo(); + String gateName = ""; + for (Map.Entry entry : TimingAcquisition.gateNameToNoMap.entrySet()) { + if (entry.getValue().equals(gateNo)) { + gateName = entry.getKey(); + break; + } } - return null; + //当前系列 + text.append("当前系列:").append(player.getSeries()).append("
"); + //当前系列 + text.append("当前关卡:").append(gateName).append("
"); + //上线时间 + text.append("上线时间:").append(player.getOnlineTime()).append("
"); + //上线时间 + text.append("下线时间:").append(player.getOfflineTime()).append("
"); + //所在场所 + text.append("所在场所:").append(player.getLocation()).append("
"); + //当前对话的人物 + text.append("当前对话的人物:").append(player.getId2NameMap().get(player.getPersonId())).append("
"); + //当前系列的货币 +// text.append("当前系列的货币:").append(player.getCurrency()).append("
"); + //声望值 + text.append("声望值:").append(player.getReputation()).append("
"); + //已完成任务个数 + text.append("已完成任务个数:").append(player.getFinishedTaskNum()).append("
"); + //场所表 + text.append("场所表:").append(player.getLocationMap()).append("
"); + //已获得的线索 + text.append("已获得的线索:").append(player.getClueMap()).append("
"); + //所有任务状态 + text.append("任务状态:").append(player.getTaskMap()).append("
"); + //伙伴名称 + String partnerNames = ConfigDataUtil.getPartnerNames(uid); + text.append(partnerNames).append("
"); + resultResponse.set反馈ID(100003); + resultResponse.set反馈文本(text.toString()); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); } } diff --git a/src/main/java/com/qiwu/inference/dto/BehaviourDto.java b/src/main/java/com/qiwu/inference/dto/BehaviourDto.java index cf47b00..ba8a036 100755 --- a/src/main/java/com/qiwu/inference/dto/BehaviourDto.java +++ b/src/main/java/com/qiwu/inference/dto/BehaviourDto.java @@ -19,7 +19,7 @@ public class BehaviourDto implements Serializable { /** * 行为名称 */ - private String name; +// private String name; /** * 行为id */ @@ -27,7 +27,7 @@ public class BehaviourDto implements Serializable { /** * 行为描述 */ - private String description; +// private String description; /** * 主体 */ @@ -35,7 +35,7 @@ public class BehaviourDto implements Serializable { /** * 主体名称 */ - private String subjectName; +// private String subjectName; /** * 客体 */ @@ -43,6 +43,6 @@ public class BehaviourDto implements Serializable { /** * 客体名称 */ - private String objectName; +// private String objectName; } diff --git a/src/main/java/com/qiwu/inference/dto/ClueDto.java b/src/main/java/com/qiwu/inference/dto/ClueDto.java index 2c68351..2ebf013 100755 --- a/src/main/java/com/qiwu/inference/dto/ClueDto.java +++ b/src/main/java/com/qiwu/inference/dto/ClueDto.java @@ -38,7 +38,7 @@ public class ClueDto implements Serializable { /** * 描述 */ - private String description; +// private String description; /** * 类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9: 关键线索 */ @@ -54,7 +54,7 @@ public class ClueDto implements Serializable { /** * 线索模板 */ - private String clueTemplate; +// private String clueTemplate; /** * 信任度 diff --git a/src/main/java/com/qiwu/inference/dto/ClueInfoDto.java b/src/main/java/com/qiwu/inference/dto/ClueInfoDto.java new file mode 100644 index 0000000..4e6e24a --- /dev/null +++ b/src/main/java/com/qiwu/inference/dto/ClueInfoDto.java @@ -0,0 +1,33 @@ +package com.qiwu.inference.dto; + +import lombok.Data; + +import java.util.List; +import java.util.Objects; + +@Data +public class ClueInfoDto { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + private int id; + /** + * 线索id + */ + private int clueId; + /** + * 主体 + */ + private int subject; + /** + * 客体 + */ + private int object; + /** + * 类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9: 关键线索 + */ + private int type; +} diff --git a/src/main/java/com/qiwu/inference/dto/DemandTaskDto.java b/src/main/java/com/qiwu/inference/dto/DemandTaskDto.java index 2bd785a..1b686f7 100755 --- a/src/main/java/com/qiwu/inference/dto/DemandTaskDto.java +++ b/src/main/java/com/qiwu/inference/dto/DemandTaskDto.java @@ -31,7 +31,7 @@ public class DemandTaskDto implements Serializable { /** * 描述 */ - private String description; +// private String description; /** * 主体 @@ -81,9 +81,29 @@ public class DemandTaskDto implements Serializable { private String condition1; /** - * 条件2|次数 + * 消费数量|是否限制此时 */ - private String condition2; + private String cost; + + /** + * 开启条件时间阈值 + */ + private String timeThreshold; + + /** + * 开启条件任务id + */ + private int conditionTaskId; + + /** + * 消耗时间 + */ + private int costTime; + + /** + * 一次性标签 + */ + private int disposableLabel; /** * 信任度增减 @@ -100,9 +120,17 @@ public class DemandTaskDto implements Serializable { */ private String completionReward; /** + * 掉落人物或物品 + */ + private String dropItems; + /** + * NPC生命状态 + */ + private int lifeState; + /** * 完成反馈 */ - private String completionFeedback; +// private String completionFeedback; /** * 有效次数 */ @@ -124,10 +152,20 @@ public class DemandTaskDto implements Serializable { private int infoLevel; /** - * 任务标签 1普通任务 2关键任务 3目标任 + * 任务标签 1普通任务 2关键任务 3目标任务 */ private int taskLabel; + /** + * 自动触发: 0-不自动触发,1-自动触发 + */ + private int isAuto; + + /** + * 声望值 + */ + private int reputation; + @Override diff --git a/src/main/java/com/qiwu/inference/dto/DispositionDto.java b/src/main/java/com/qiwu/inference/dto/DispositionDto.java index aae8494..7560441 100755 --- a/src/main/java/com/qiwu/inference/dto/DispositionDto.java +++ b/src/main/java/com/qiwu/inference/dto/DispositionDto.java @@ -27,11 +27,11 @@ public class DispositionDto implements Serializable { /** * 性格名称 */ - private String name; +// private String name; /** * 性格描述 */ - private String description; +// private String description; /** * 类型 */ diff --git a/src/main/java/com/qiwu/inference/dto/response/DataResponse.java b/src/main/java/com/qiwu/inference/dto/ItemDto.java similarity index 53% rename from src/main/java/com/qiwu/inference/dto/response/DataResponse.java rename to src/main/java/com/qiwu/inference/dto/ItemDto.java index 9967aca..4f7c18a 100644 --- a/src/main/java/com/qiwu/inference/dto/response/DataResponse.java +++ b/src/main/java/com/qiwu/inference/dto/ItemDto.java @@ -1,15 +1,15 @@ -package com.qiwu.inference.dto.response; +package com.qiwu.inference.dto; import lombok.Data; @Data -public class DataResponse { +public class ItemDto { /** - * 消息id + * 物品id */ - public Integer id; + private Integer itemId; /** - * 消息文本 + * 物品个数 */ - public String text; + private Integer itemNum; } diff --git a/src/main/java/com/qiwu/inference/dto/ItemNumDto.java b/src/main/java/com/qiwu/inference/dto/ItemNumDto.java new file mode 100644 index 0000000..be873ad --- /dev/null +++ b/src/main/java/com/qiwu/inference/dto/ItemNumDto.java @@ -0,0 +1,19 @@ +package com.qiwu.inference.dto; + +import lombok.Data; + +@Data +public class ItemNumDto { + /** + * 伙伴物品id + */ + private Integer id; + /** + * 伙伴物品个数 + */ + private Integer num; + /** + * 伙伴物品使用次数。-1:次数已用完,0:不限次数,大于0:次数 + */ + private int times; +} diff --git a/src/main/java/com/qiwu/inference/dto/OperateEnum.java b/src/main/java/com/qiwu/inference/dto/OperateEnum.java new file mode 100644 index 0000000..35a81e0 --- /dev/null +++ b/src/main/java/com/qiwu/inference/dto/OperateEnum.java @@ -0,0 +1,115 @@ +package com.qiwu.inference.dto; + +import java.util.*; + +public enum OperateEnum { + /** + * 询问性格操作 + */ + askDisposition(Arrays.asList("1001", "1002"), "询问性格操作"), + /** + * 询问关系操作 + */ + askRelation(Arrays.asList("1003", "1004", "1005", "1006"), "询问关系操作"), + /** + * 询问行为操作 + */ + askBehaviour(Arrays.asList("1007", "1008", "1009", "1010", "1011"), "询问行为操作"), + /** + * 询问任务操作 + */ + askTask(Arrays.asList("1012", "1013", "1014", "1015", "1016", "1017", "1017", "1019", "1020", "1021", "1022"), "询问任务操作"), + /** + * 询问身份操作 + */ + askIdentity(Arrays.asList("1023", "1024"), "询问身份操作"), + /** + * 询问场所操作 + */ + askLocation(Arrays.asList("1025", "1026"), "询问场所操作"), + /** + * 询问提示操作 + */ + askPrompt(Arrays.asList("1027", "1028", "1029"), "询问提示操作"), + /** + * 询问最终线索操作 + */ + askFinalClue(Collections.singletonList("1030"), "询问最终线索操作"), + /** + * 执行任务操作 + */ + performTask(Arrays.asList("2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", + "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2018", "2019", "2020", "2021", "2022", "2023", + "2024", "2025", "2026", "2027", "2028", "2029", "2030", "2031", "2032", "2033", "2034", "2035", "2036", + "2037", "2038", "2039", "2040", "2041", "2042", "2043", "204301", "204302", "204303", "204304", "204305", + "2044", "2101", "2102", "2104", "2106", "2107", "2108", "2109", + "2045", "2046", "2047", "2048", "2049", "2050", "2051", "2052", "2053", "2054", "2055", "2056", "2057", + "2058", "2059", "2060", "2061", "2062", "2063", + "6002", "6003", "6006", "6013","6032", "6033", "6034", "6035", "6036", + "6037", "6038", "6039", "6040", "6041", "6042", "6043", "6044", "6045", "6046", "6047", "6048", "6049", + "6050", "6051", "6052", "6053", "6054", "6059", "6060", "6061", "6062", "6063", "6064", "6065", "6066", + "6067", "6068", "6069", "6070", "6070", "6071", "6072", "6073", "6074", "6075", "6076", "6077", "6078", + "6079", "6080", "6081", "6082", + "60001", "60002", "60004", "60005", "60006", "60007", "60008", "60009", "60010", "60011", "60012", "60013", + "60014", "60015", "60016", "60017", "60018", "60019", "60020", "60021", "60022", "60023", "60024", "60026", + "60027", "60028", "60029", "60030", "60031", "60032", "60034", "60035", "60037", "60038", "60040", "60042", + "60104", "60045", "60046", "60048", "60050", "60051", "60053", "60054", "60056", "60058", "60059", "60062", + "60063", "60065", "60067", "60068", "60070", "60071", "60073", "60075", "60076", "60078", "60079", "60081", + "60083", "60084", "60086", "60087", "60089", "60091", "60092", "60094", "60095", "60100", "60101", "60102", + "60103", "60105", "61001", "61002", "61003", "61004", "61005"), "执行任务操作"); + + private static final Map operateMap = new HashMap<>(); + + static { + for (OperateEnum operateEnum : OperateEnum.values()) { + operateEnum.methodIds.forEach(val->{ + if (OperateEnum.askDisposition.equals(operateEnum)) { + operateMap.put(val, "askDisposition"); + return; + } + if (OperateEnum.askRelation.equals(operateEnum)) { + operateMap.put(val, "askRelation"); + return; + } + if (OperateEnum.askBehaviour.equals(operateEnum)) { + operateMap.put(val, "askBehaviour"); + return; + } + if (OperateEnum.askTask.equals(operateEnum)) { + operateMap.put(val, "askTask"); + return; + } + if (OperateEnum.askIdentity.equals(operateEnum)) { + operateMap.put(val, "askIdentity"); + return; + } + if (OperateEnum.askLocation.equals(operateEnum)) { + operateMap.put(val, "askLocation"); + return; + } + if (OperateEnum.askPrompt.equals(operateEnum)) { + operateMap.put(val, "askPrompt"); + return; + } + if (OperateEnum.askFinalClue.equals(operateEnum)) { + operateMap.put(val, "askFinalClue"); + return; + } + if (OperateEnum.performTask.equals(operateEnum)) { + operateMap.put(val, "performTask"); + } + }); + } + } + + private final List methodIds; + private String name; + OperateEnum(List methodIds, String name) { + this.methodIds = methodIds; + this.name = name; + } + + public static String getOperateName(String methodId) { + return operateMap.get(methodId); + } +} diff --git a/src/main/java/com/qiwu/inference/dto/PartnerItemDto.java b/src/main/java/com/qiwu/inference/dto/PartnerItemDto.java new file mode 100644 index 0000000..65656a8 --- /dev/null +++ b/src/main/java/com/qiwu/inference/dto/PartnerItemDto.java @@ -0,0 +1,22 @@ +package com.qiwu.inference.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +@Data +public class PartnerItemDto implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 数量上限 + */ + private int max; + + /** + * 背包已有物品 + */ + private Map itemInfoMap = new HashMap<>(); +} diff --git a/src/main/java/com/qiwu/inference/dto/Person.java b/src/main/java/com/qiwu/inference/dto/Person.java index 51eaa45..91aebfa 100755 --- a/src/main/java/com/qiwu/inference/dto/Person.java +++ b/src/main/java/com/qiwu/inference/dto/Person.java @@ -17,6 +17,11 @@ public class Person implements Serializable { private Integer id; /** + * 人物ID + */ + private Integer personId; + + /** * 人物名称 */ private String name; diff --git a/src/main/java/com/qiwu/inference/dto/PersonInfoDto.java b/src/main/java/com/qiwu/inference/dto/PersonInfoDto.java index 84d569f..14e5939 100644 --- a/src/main/java/com/qiwu/inference/dto/PersonInfoDto.java +++ b/src/main/java/com/qiwu/inference/dto/PersonInfoDto.java @@ -2,7 +2,39 @@ package com.qiwu.inference.dto; import lombok.Data; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + @Data public class PersonInfoDto { - + /** + * 人物编号 + */ + private Integer id; + /** + * 人物掌握的线索, Map<线索id, 线索来源>,其中"线索来源"记录的是线索从哪个人物获得 + */ + private Map> clueSourceMap = new ConcurrentHashMap<>(); + /** + * 人物的需求任务, Map<任务id, 线索开关>,其中“线索开关”标记任务状态-2/-1/0/1/2/5 + */ + private Map demandTaskSwitchMap = new ConcurrentHashMap<>(); + /** + * 信任度 + */ + private Integer trustDegree = 50; + /** + * 威胁 + */ + private Integer deterrenceDegree = 50; + /** + * 人物生命状态,0-活着,1-死亡 + */ + private int lifeState = 0; + /** + * 起过作用的伙伴物品id + */ + List partnerItemIdList = new ArrayList<>(); } diff --git a/src/main/java/com/qiwu/inference/dto/Player.java b/src/main/java/com/qiwu/inference/dto/Player.java index 211e196..171d31a 100755 --- a/src/main/java/com/qiwu/inference/dto/Player.java +++ b/src/main/java/com/qiwu/inference/dto/Player.java @@ -1,9 +1,6 @@ package com.qiwu.inference.dto; import com.qiwu.inference.common.Constants; -import com.qiwu.inference.common.TimingAcquisition; -import com.qiwu.inference.common.utils.FastJsonUtil; -import com.qiwu.inference.common.utils.RandomUtil; import lombok.Getter; import lombok.Setter; @@ -11,7 +8,6 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; -import java.math.BigInteger; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -21,21 +17,17 @@ import java.util.Map; public class Player { /** - * 会话id + * 玩家id */ - private String sid; + private String uid; /** - * 关卡编号 - */ - private String gateNo; - /** - * 关卡等级 + * 系列名称 */ - private String level; + private String series; /** - * 当前等级通关总次数 + * 关卡编号 */ - private String total; + private String gateNo; /** * 当前关卡完成状态:0-未完成,1-已完成 */ @@ -63,34 +55,33 @@ public class Player { /** * 人物集合 */ - private Map personMap = new HashMap<>(); + private Map personInfoMap = new HashMap<>(); /** * 人物的姓名和编号转换 map */ private Map name2IdMap = new HashMap<>(); - /** - * 当前关卡的货币 + * 人物的编号和姓名转换 map */ - private Double currency = 3000.0; + private Map id2NameMap = new HashMap<>(); + /** - * 当前关卡的积分 + * 当前关卡已消耗的货币 */ - private Integer point = 0; - + private Double currency; /** - * 总货币 + * 当前关卡声望值 */ - private Double totalCurrency = 0.0; + private int reputation = 0; /** - * 总积分 + * 当前关卡的积分 */ - private Integer totalPoint = 0; + private Integer point = 0; /** * 已获得人物线索: Map<人物id, Map<线索类型id, List<线索>>。没有线索则仅仅对话过 */ - private Map>> clueMap = new HashMap<>(); + private Map>> clueMap = new HashMap<>(); /** * 场所表 @@ -127,6 +118,21 @@ public class Player { */ private int chatTimes = 0; + /** + * 记录玩家操作提示的序号 + */ + private int operateTextNum = 1; + + /** + * 记录玩家询问操作的每个操作对应线索的序号 + */ + private Map askAndNumMap = new HashMap<>(); + + /** + * 初始时间值 + */ + private int initTime; + // public Player(){ // //初始化推理游戏人物 // List keys = new ArrayList<>(TimingAcquisition.gateInfoMap.keySet()); diff --git a/src/main/java/com/qiwu/inference/dto/PlayerSeriesDto.java b/src/main/java/com/qiwu/inference/dto/PlayerSeriesDto.java new file mode 100644 index 0000000..3bd3419 --- /dev/null +++ b/src/main/java/com/qiwu/inference/dto/PlayerSeriesDto.java @@ -0,0 +1,32 @@ +package com.qiwu.inference.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +@Data +public class PlayerSeriesDto implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 关卡等级 + */ + private int level = 1; + /** + * 当前等级通关总次数 + */ + private int clearanceNum = 0; + /** + * 总货币 + */ + private int money; + /** + * 系列总声望值 + */ + private ReputationDto totalReputation; + /** + * Map<物品类型, 物品信息> + */ + private Map partnerItemMap = new HashMap<>(); +} diff --git a/src/main/java/com/qiwu/inference/dto/PostTaskDto.java b/src/main/java/com/qiwu/inference/dto/PostTaskDto.java index 2d22c10..66e75fd 100644 --- a/src/main/java/com/qiwu/inference/dto/PostTaskDto.java +++ b/src/main/java/com/qiwu/inference/dto/PostTaskDto.java @@ -11,7 +11,7 @@ public class PostTaskDto { */ private Integer personId; /** - * 后置任务的前置任务完成情况: Map<后置任务id, Map<前置任务id, 完成状态>> + * 后置任务的前置任务完成情况: Map<后置任务id, 对象{前置任务id, 前置任务完成状态}> */ Map taskStatusMap; } diff --git a/src/main/java/com/qiwu/inference/dto/RelationDto.java b/src/main/java/com/qiwu/inference/dto/RelationDto.java index a2d1e8f..7736523 100755 --- a/src/main/java/com/qiwu/inference/dto/RelationDto.java +++ b/src/main/java/com/qiwu/inference/dto/RelationDto.java @@ -20,12 +20,12 @@ public class RelationDto implements Serializable { /** * 关系名称 */ - private String name; +// private String name; /** * 关系描述 */ - private String description; +// private String description; /** * 类型 diff --git a/src/main/java/com/qiwu/inference/dto/ReplyDto.java b/src/main/java/com/qiwu/inference/dto/ReplyDto.java new file mode 100644 index 0000000..653c609 --- /dev/null +++ b/src/main/java/com/qiwu/inference/dto/ReplyDto.java @@ -0,0 +1,33 @@ +package com.qiwu.inference.dto; + +import lombok.Data; + +import java.util.Map; + +@Data +public class ReplyDto { + /** + * 主体id + */ + private Integer subjectId; + /** + * 客体id + */ + private Integer objectId; + /** + * 任务id + */ + private Integer demandTaskId; + /** + * 响应方式:1-闲聊,2-发布任务,3-执行任务 + */ + private int type; + /** + * 序号,按顺序取对应话术 + */ + private int num = 0; + /** + * 掉落的人或物 + */ + private Map idNumMap; +} diff --git a/src/main/java/com/qiwu/inference/dto/ReputationDto.java b/src/main/java/com/qiwu/inference/dto/ReputationDto.java new file mode 100644 index 0000000..1cf1a40 --- /dev/null +++ b/src/main/java/com/qiwu/inference/dto/ReputationDto.java @@ -0,0 +1,25 @@ +package com.qiwu.inference.dto; + +import lombok.Data; +import org.jetbrains.annotations.NotNull; + +import java.io.Serializable; + +@Data +public class ReputationDto implements Comparable, Serializable { + private static final long serialVersionUID = 1L; + /** + * 玩家uid + */ + private String uid; + /** + * 声望值 + */ + private int reputation = 0; + + @Override + public int compareTo(@NotNull Object o) { + ReputationDto reputationDto = (ReputationDto) o; + return reputationDto.getReputation() - reputation; + } +} diff --git a/src/main/java/com/qiwu/inference/dto/request/CallRequest.java b/src/main/java/com/qiwu/inference/dto/request/CallRequest.java index f60ee11..5bfe9f7 100644 --- a/src/main/java/com/qiwu/inference/dto/request/CallRequest.java +++ b/src/main/java/com/qiwu/inference/dto/request/CallRequest.java @@ -10,6 +10,14 @@ public class CallRequest { */ private String 操作名; /** + * 系列名称 + */ + private String 系列名称; + /** + * 关卡名称 + */ + private String 关卡名称; + /** * 方法编号 */ private String 方法编号; @@ -65,4 +73,8 @@ public class CallRequest { * 线索类型 */ private String 线索类型; + /** + * 伙伴物品名称 + */ + private String 伙伴物品名称; } diff --git a/src/main/java/com/qiwu/inference/dto/request/OperationRequest.java b/src/main/java/com/qiwu/inference/dto/request/OperationRequest.java index ccdae42..23b0155 100644 --- a/src/main/java/com/qiwu/inference/dto/request/OperationRequest.java +++ b/src/main/java/com/qiwu/inference/dto/request/OperationRequest.java @@ -1,6 +1,7 @@ package com.qiwu.inference.dto.request; import com.qiwu.inference.dto.ClueDto; +import com.qiwu.inference.dto.ClueInfoDto; import io.swagger.models.auth.In; import lombok.Data; @@ -13,6 +14,18 @@ public class OperationRequest { */ private String operate; /** + * 操作标签 + */ + private int operateLabel; + /** + * 系列名称 + */ + private String series; + /** + * 关卡名称 + */ + private String gateName; + /** * 方法编号 */ private String methodId; @@ -73,9 +86,13 @@ public class OperationRequest { */ private Integer clueTypeId; /** + * 道具名称,即伙伴物品名称 + */ + private Integer partnerItemId; + /** * 玩家获得某人的线索集合 */ - private List clueList; + private List clueList; /** * 集合待查看的索引 */ @@ -88,4 +105,8 @@ public class OperationRequest { * 序号 */ private Integer num; + /** + * String集合 + */ + private List strList; } diff --git a/src/main/java/com/qiwu/inference/dto/response/InferenceResponse.java b/src/main/java/com/qiwu/inference/dto/response/CallResponse.java similarity index 86% rename from src/main/java/com/qiwu/inference/dto/response/InferenceResponse.java rename to src/main/java/com/qiwu/inference/dto/response/CallResponse.java index 4f24a68..4c30c06 100644 --- a/src/main/java/com/qiwu/inference/dto/response/InferenceResponse.java +++ b/src/main/java/com/qiwu/inference/dto/response/CallResponse.java @@ -5,7 +5,9 @@ import lombok.Data; import java.io.Serializable; @Data -public class InferenceResponse implements Serializable { +public class CallResponse implements Serializable { + private static final long serialVersionUID = 1L; + /** * 返回状态码 */ @@ -17,5 +19,5 @@ public class InferenceResponse implements Serializable { /** * 返回内容 */ - private DataResponse data; + private String data; } diff --git a/src/main/java/com/qiwu/inference/dto/response/ResultResponse.java b/src/main/java/com/qiwu/inference/dto/response/ResultResponse.java index a120ce4..a97cdf9 100644 --- a/src/main/java/com/qiwu/inference/dto/response/ResultResponse.java +++ b/src/main/java/com/qiwu/inference/dto/response/ResultResponse.java @@ -25,4 +25,8 @@ public class ResultResponse { * 保存附加返回 */ private String 保存附加返回; + /** + * 当前对话角色身份 + */ + private String 当前对话角色身份; } diff --git a/src/main/java/com/qiwu/inference/factory/RemoteCallFactory.java b/src/main/java/com/qiwu/inference/factory/RemoteCallFactory.java new file mode 100644 index 0000000..cde4602 --- /dev/null +++ b/src/main/java/com/qiwu/inference/factory/RemoteCallFactory.java @@ -0,0 +1,51 @@ +package com.qiwu.inference.factory; + +import com.qiwu.inference.dto.response.CallResponse; +import com.qiwu.inference.service.remote.RemoteService; +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@Component +public class RemoteCallFactory implements ApplicationContextAware { + /** + * 存储策略 + */ + private final static Map remoteServiceMap = new HashMap<>(); + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + Map serviceMap = applicationContext.getBeansOfType(RemoteService.class); + serviceMap.values().forEach(remoteService -> remoteServiceMap.put(remoteService.getResource(), remoteService)); + } + + private static class createFactorySingleton { + private static final RemoteCallFactory remoteCallFactory = new RemoteCallFactory(); + } + + public static RemoteCallFactory getInstance() { + return createFactorySingleton.remoteCallFactory; + } + + public CallResponse getRemoteResult(String uid, String resource) { + RemoteService remoteService = remoteServiceMap.get(resource); + if (Objects.isNull(remoteService)) { + throw new RuntimeException("远程服务配置异常"); + } + return remoteService.getItems(uid); + } + + public CallResponse updateItems(String uid, String resource) throws IOException { + RemoteService remoteService = remoteServiceMap.get(resource); + if (Objects.isNull(remoteService)) { + throw new RuntimeException("远程服务配置异常"); + } + return remoteService.updateItems(uid); + } +} diff --git a/src/main/java/com/qiwu/inference/pojo/BackpackNum.java b/src/main/java/com/qiwu/inference/pojo/BackpackNum.java new file mode 100644 index 0000000..7a69218 --- /dev/null +++ b/src/main/java/com/qiwu/inference/pojo/BackpackNum.java @@ -0,0 +1,20 @@ +package com.qiwu.inference.pojo; + +import com.opencsv.bean.CsvBindByName; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class BackpackNum implements Serializable { + private static final long serialVersionUID = 1L; + + @CsvBindByName(column = "ID") + private Integer id; + + @CsvBindByName(column = "声望值") + private Integer reputation; + + @CsvBindByName(column = "数量上限") + private Integer max; +} diff --git a/src/main/java/com/qiwu/inference/pojo/ChatSpeech.java b/src/main/java/com/qiwu/inference/pojo/ChatSpeech.java index bd4ed20..08f7567 100644 --- a/src/main/java/com/qiwu/inference/pojo/ChatSpeech.java +++ b/src/main/java/com/qiwu/inference/pojo/ChatSpeech.java @@ -1,5 +1,7 @@ package com.qiwu.inference.pojo; +import com.opencsv.bean.CsvBindAndJoinByName; +import com.opencsv.bean.CsvBindByName; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -9,36 +11,42 @@ import java.io.Serializable; public class ChatSpeech implements Serializable { private static final long serialVersionUID = 1L; - @ApiModelProperty("意图反馈") + @CsvBindByName(column = "意图反馈") private Integer methodId; - @ApiModelProperty("身份") + @CsvBindByName(column = "身份") private String identity; - @ApiModelProperty("人物ID") - private Integer personId; + @CsvBindByName(column = "人物名称") + private String personName; - @ApiModelProperty("性别") + @CsvBindByName(column = "性别") private String gender; - @ApiModelProperty("年龄段") + @CsvBindByName(column = "年龄段") private String age; - @ApiModelProperty("性格A") + @CsvBindByName(column = "性格A") private String dispositionIds; - @ApiModelProperty("行为") + @CsvBindByName(column = "行为") private String behaviour; - @ApiModelProperty("任务状态") + @CsvBindByName(column = "任务状态") private String taskStatus; - @ApiModelProperty("关系") - private String degree; + @CsvBindByName(column = "信任值") + private String trust; - @ApiModelProperty("文本内容") + @CsvBindByName(column = "威慑度") + private String deterrence; + + @CsvBindByName(column = "时间") + private String time; + + @CsvBindByName(column = "文本内容") private String answer; - @ApiModelProperty("通用标签") + @CsvBindByName(column = "通用标签") private String flag; } diff --git a/src/main/java/com/qiwu/inference/pojo/Clue.java b/src/main/java/com/qiwu/inference/pojo/Clue.java index 0b6db3e..5cb3dd7 100755 --- a/src/main/java/com/qiwu/inference/pojo/Clue.java +++ b/src/main/java/com/qiwu/inference/pojo/Clue.java @@ -1,66 +1,50 @@ -package com.qiwu.inference.pojo; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; -import java.util.Date; - -/** - *

- * - *

- * - * @author xingxing.ye - * @since 2022-11-07 - */ -@Getter -@Setter -@ApiModel(value = "Clue对象", description = "") -public class Clue implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("id") - @TableId(value = "id", type = IdType.AUTO) - private Integer id; - - @ApiModelProperty("线索名称") - private String name; - - @ApiModelProperty("描述") - private String description; - - @ApiModelProperty("类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务") - private Integer type; - - @ApiModelProperty("对应的Id") - private Integer associatedId; - - @ApiModelProperty("线索模板") - private String clueTemplate; - - @ApiModelProperty("信息级别") - private Integer infoLevel; - - @ApiModelProperty("信任度") - private Integer trustDegree; - - @ApiModelProperty("威胁") - private Integer threaten; - - @ApiModelProperty("操作1|信任度|威胁") - private Integer operate; - - @ApiModelProperty("创建时间") - private Date createTime; - - @ApiModelProperty("更新时间") - private Date updateTime; - - -} +package com.qiwu.inference.pojo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.opencsv.bean.CsvBindByName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * + *

+ * + * @author xingxing.ye + * @since 2022-11-07 + */ +@Getter +@Setter +@ApiModel(value = "Clue对象", description = "") +public class Clue implements Serializable { + + private static final long serialVersionUID = 1L; + + @CsvBindByName(column = "线索ID") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @CsvBindByName(column = "线索名称") + private String name; + + @CsvBindByName(column = "对应类型") + private Integer type; + + @CsvBindByName(column = "对应ID") + private Integer associatedId; + + @CsvBindByName(column = "信息重要级别") + private Integer infoLevel; + + @CsvBindByName(column = "信任度") + private Integer trustDegree; + + @CsvBindByName(column = "威胁") + private Integer threaten; +} diff --git a/src/main/java/com/qiwu/inference/pojo/ClueSpeech.java b/src/main/java/com/qiwu/inference/pojo/ClueSpeech.java index 7480bd7..ebd108e 100644 --- a/src/main/java/com/qiwu/inference/pojo/ClueSpeech.java +++ b/src/main/java/com/qiwu/inference/pojo/ClueSpeech.java @@ -1,5 +1,6 @@ package com.qiwu.inference.pojo; +import com.opencsv.bean.CsvBindByName; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -9,39 +10,39 @@ import java.io.Serializable; public class ClueSpeech implements Serializable { private static final long serialVersionUID = 1L; - @ApiModelProperty("线索ID") + @CsvBindByName(column = "线索ID") private Integer clueId; - @ApiModelProperty("任务名称") + @CsvBindByName(column = "任务名称") private String taskName; - @ApiModelProperty("身份1") + @CsvBindByName(column = "身份1") private String identity; - @ApiModelProperty("性别") + @CsvBindByName(column = "性别") private String gender; - @ApiModelProperty("人物ID") + @CsvBindByName(column = "人物ID") private Integer personId; - @ApiModelProperty("年龄段") + @CsvBindByName(column = "年龄段") private String age; - @ApiModelProperty("性格A") + @CsvBindByName(column = "性格A") private String dispositionIds; - @ApiModelProperty("行为") + @CsvBindByName(column = "行为") private String behaviour; - @ApiModelProperty("任务状态") + @CsvBindByName(column = "任务状态") private Integer status; - @ApiModelProperty("线索文本") + @CsvBindByName(column = "线索文本") private String answer; - @ApiModelProperty("自身线索文本") + @CsvBindByName(column = "自身线索文本") private String answerSelf; - @ApiModelProperty("通用标签") + @CsvBindByName(column = "通用标签") private Integer flag; } diff --git a/src/main/java/com/qiwu/inference/pojo/ClueType.java b/src/main/java/com/qiwu/inference/pojo/ClueType.java index 4e4071f..208bf68 100644 --- a/src/main/java/com/qiwu/inference/pojo/ClueType.java +++ b/src/main/java/com/qiwu/inference/pojo/ClueType.java @@ -1,10 +1,13 @@ package com.qiwu.inference.pojo; +import com.opencsv.bean.CsvBindByName; import lombok.Data; @Data public class ClueType { + @CsvBindByName(column = "线索类型ID") private Integer id; + @CsvBindByName(column = "类型名称") private String name; } diff --git a/src/main/java/com/qiwu/inference/pojo/Disposition.java b/src/main/java/com/qiwu/inference/pojo/Disposition.java index 646e939..3e5ab87 100755 --- a/src/main/java/com/qiwu/inference/pojo/Disposition.java +++ b/src/main/java/com/qiwu/inference/pojo/Disposition.java @@ -1,76 +1,68 @@ -package com.qiwu.inference.pojo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; -import java.util.Date; - -/** - *

- * - *

- * - * @author xingxing.ye - * @since 2022-11-02 - */ -@Getter -@Setter -@ApiModel(value = "Disposition对象", description = "") -public class Disposition implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("性格id") - private Integer id; - - @ApiModelProperty("性格名称") - private String name; - - @ApiModelProperty("性格描述") - private String description; - - @ApiModelProperty("类型") - private String type; - - @ApiModelProperty("基础权重") - private Integer weight; - - @ApiModelProperty("身份影响权重:") - private String identityWeight; - - @ApiModelProperty("性别影响概率:") - private String genderWeight; - - @ApiModelProperty("年龄影响权重:") - private String ageWeight; - - @ApiModelProperty("好感度初始值:") - private String favorDegree; - - @ApiModelProperty("弱点条件:") - private String weaknessCondition; - - @ApiModelProperty("对应物品|好感度增减:") - private String itemFavorDegree; - - @ApiModelProperty("对应身份|好感度增减:") - private String identityFavorDegree; - - @ApiModelProperty("互斥性格|喜好:") - private String exclusionDisposition; - - @ApiModelProperty("信息重要级别") - private Integer infoLevel; - - - @ApiModelProperty("创建时间") - private Date createTime; - - @ApiModelProperty("更新时间") - private Date updateTime; - - -} +package com.qiwu.inference.pojo; + +import com.opencsv.bean.CsvBindByName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * + *

+ * + * @author xingxing.ye + * @since 2022-11-02 + */ +@Getter +@Setter +@ApiModel(value = "Disposition对象", description = "") +public class Disposition implements Serializable { + + private static final long serialVersionUID = 1L; + + @CsvBindByName(column = "ID") + private Integer id; + + @CsvBindByName(column = "名称") + private String name; + + @CsvBindByName(column = "描述") + private String description; + + @CsvBindByName(column = "类型") + private String type; + +// @CsvBindByName(column = "基础权重") +// private Integer weight; + +// @CsvBindByName(column = "身份影响权重:") +// private String identityWeight; + +// @CsvBindByName(column = "性别影响概率:") +// private String genderWeight; + +// @CsvBindByName(column = "年龄影响权重:") +// private String ageWeight; + +// @CsvBindByName(column = "好感度初始值:") +// private String favorDegree; + +// @CsvBindByName(column = "弱点条件:") +// private String weaknessCondition; + +// @CsvBindByName(column = "对应物品|好感度增减:") +// private String itemFavorDegree; + +// @CsvBindByName(column = "对应身份|好感度增减:") +// private String identityFavorDegree; + +// @CsvBindByName(column = "互斥性格|喜好:") +// private String exclusionDisposition; + + @CsvBindByName(column = "信息级别") + private Integer infoLevel; +} diff --git a/src/main/java/com/qiwu/inference/pojo/Location.java b/src/main/java/com/qiwu/inference/pojo/Location.java index 22435bf..f038eee 100755 --- a/src/main/java/com/qiwu/inference/pojo/Location.java +++ b/src/main/java/com/qiwu/inference/pojo/Location.java @@ -1,5 +1,6 @@ package com.qiwu.inference.pojo; +import com.opencsv.bean.CsvBindByName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; @@ -23,32 +24,21 @@ public class Location implements Serializable { private static final long serialVersionUID = 1L; - @ApiModelProperty("场所id") + @CsvBindByName(column = "ID") private Integer id; - @ApiModelProperty("场所名称") + @CsvBindByName(column = "场所名称") private String name; - @ApiModelProperty("描述") + @CsvBindByName(column = "描述") private String description; - @ApiModelProperty("关键场所") + @CsvBindByName(column = "关键场所") private String keyLocation; - @ApiModelProperty("是否隐藏") + @CsvBindByName(column = "是否隐藏") private String isHidden; - @ApiModelProperty("是否必现") + @CsvBindByName(column = "是否必现") private String isAppear; - - @ApiModelProperty("对应线索模板:") - private String clueTemplate; - - @ApiModelProperty("创建时间") - private Date createTime; - - @ApiModelProperty("更新时间") - private Date updateTime; - - } diff --git a/src/main/java/com/qiwu/inference/pojo/OperateSpeech.java b/src/main/java/com/qiwu/inference/pojo/OperateSpeech.java new file mode 100644 index 0000000..98c14a8 --- /dev/null +++ b/src/main/java/com/qiwu/inference/pojo/OperateSpeech.java @@ -0,0 +1,18 @@ +package com.qiwu.inference.pojo; + +import com.opencsv.bean.CsvBindByName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class OperateSpeech implements Serializable { + private static final long serialVersionUID = 1L; + + @CsvBindByName(column = "ID") + private Integer id; + + @CsvBindByName(column = "操作提示文本") + private String answer; +} diff --git a/src/main/java/com/qiwu/inference/pojo/PartnerItem.java b/src/main/java/com/qiwu/inference/pojo/PartnerItem.java new file mode 100644 index 0000000..6c492bb --- /dev/null +++ b/src/main/java/com/qiwu/inference/pojo/PartnerItem.java @@ -0,0 +1,53 @@ +package com.qiwu.inference.pojo; + +import com.opencsv.bean.CsvBindByName; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class PartnerItem implements Serializable { + private static final long serialVersionUID = 1L; + + @CsvBindByName(column = "ID") + private Integer id; + + @CsvBindByName(column = "名称") + private String name; + + @CsvBindByName(column = "类型") + private Integer type; + + @CsvBindByName(column = "能力描述") + private String abilityDes; + + @CsvBindByName(column = "能力对应人物性格ID") + private String dispositions; + + @CsvBindByName(column = "能力对应人物身份ID") + private String identity; + + @CsvBindByName(column = "信任增减") + private Integer trust; + + @CsvBindByName(column = "威慑增减") + private Integer deterrence; + + @CsvBindByName(column = "对应任务ID") + private Integer taskId; + + @CsvBindByName(column = "使用次数") + private Integer helpTimes; + + @CsvBindByName(column = "获取概率") + private Double probability; + + @CsvBindByName(column = "能力使用文本") + private String answer; + + @CsvBindByName(column = "能力使用最终文本") + private String lastAnswer; + + @CsvBindByName(column = "离队文本") + private String leaveAnswer; +} diff --git a/src/main/java/com/qiwu/inference/pojo/PersonPojo.java b/src/main/java/com/qiwu/inference/pojo/PersonPojo.java new file mode 100644 index 0000000..d5eb6c5 --- /dev/null +++ b/src/main/java/com/qiwu/inference/pojo/PersonPojo.java @@ -0,0 +1,54 @@ +package com.qiwu.inference.pojo; + +import com.qiwu.inference.dto.DispositionDto; +import lombok.Data; + +import java.util.List; + +@Data +public class PersonPojo { + /** + * 人物ID + */ + private Integer id; + + /** + * 人物名称 + */ + private String name; + + /** + * 身份id + */ + private Integer identityId; + + /** + * 身份名称 + */ + private String identityName; + + /** + * 年龄 + */ + private Integer age; + + /** + * 是否为关键人物 1 关键人物 2 普通人物 + */ + private Integer isKey; + + /** + * 性别 + */ + private Integer gender; + + /** + * 所在地 + */ + private String location; + + /** + * 人物拥有的性格 + */ + private List dispositions; +} diff --git a/src/main/java/com/qiwu/inference/pojo/PersonSpeech.java b/src/main/java/com/qiwu/inference/pojo/PersonSpeech.java index 480d59b..1774e9c 100644 --- a/src/main/java/com/qiwu/inference/pojo/PersonSpeech.java +++ b/src/main/java/com/qiwu/inference/pojo/PersonSpeech.java @@ -1,5 +1,6 @@ package com.qiwu.inference.pojo; +import com.opencsv.bean.CsvBindByName; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -9,18 +10,18 @@ import java.io.Serializable; public class PersonSpeech implements Serializable { private static final long serialVersionUID = 1L; - @ApiModelProperty("ID") + @CsvBindByName(column = "ID") private Integer personId; - @ApiModelProperty("人物名称") + @CsvBindByName(column = "人物名称") private String name; - @ApiModelProperty("人物描述") + @CsvBindByName(column = "人物描述") private String description; - @ApiModelProperty("首次回复") + @CsvBindByName(column = "首次回复") private String firstAnswer; - @ApiModelProperty("回复") + @CsvBindByName(column = "回复") private String answer; } diff --git a/src/main/java/com/qiwu/inference/pojo/PreReasonSpeech.java b/src/main/java/com/qiwu/inference/pojo/PreReasonSpeech.java new file mode 100644 index 0000000..d4baf90 --- /dev/null +++ b/src/main/java/com/qiwu/inference/pojo/PreReasonSpeech.java @@ -0,0 +1,54 @@ +package com.qiwu.inference.pojo; + +import com.opencsv.bean.CsvBindByName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class PreReasonSpeech implements Serializable { + private static final long serialVersionUID = 1L; + + @CsvBindByName(column = "线索ID") + private Integer demandTaskId; + + @CsvBindByName(column = "任务ID") + private Integer clueId; + + @CsvBindByName(column = "任务名称") + private String taskName; + + @CsvBindByName(column = "自身身份") + private Integer identity; + + @CsvBindByName(column = "对方身份") + private Integer identitySide; + + @CsvBindByName(column = "性别") + private String gender; + + @CsvBindByName(column = "人物名称") + private Integer personName; + + @CsvBindByName(column = "年龄段") + private String age; + + @CsvBindByName(column = "性格A") + private Integer dispositionId; + + @CsvBindByName(column = "关系") + private Integer relation; + + @CsvBindByName(column = "行为") + private Integer behaviour; + + @CsvBindByName(column = "第三方描述") + private String answer; + + @CsvBindByName(column = "自身描述") + private String answerSelf; + + @CsvBindByName(column = "通用标签") + private Integer flag; +} diff --git a/src/main/java/com/qiwu/inference/pojo/SystemConfigPojo.java b/src/main/java/com/qiwu/inference/pojo/SystemConfigPojo.java index def8145..cb3b407 100644 --- a/src/main/java/com/qiwu/inference/pojo/SystemConfigPojo.java +++ b/src/main/java/com/qiwu/inference/pojo/SystemConfigPojo.java @@ -1,5 +1,6 @@ package com.qiwu.inference.pojo; +import com.opencsv.bean.CsvBindByName; import lombok.Data; @Data @@ -7,25 +8,21 @@ public class SystemConfigPojo { /** * 系统参数名称 */ + @CsvBindByName(column = "名称") private String name; /** * 系统参数值 */ + @CsvBindByName(column = "值") private String value; /** * 参数说明 */ + @CsvBindByName(column = "描述") private String description; /** * 参数状态:0-不可用,1-可用 */ + @CsvBindByName(column = "状态") private Integer status; - /** - * 创建时间 - */ - private String createTime; - /** - * 修改时间 - */ - private String updateTime; } diff --git a/src/main/java/com/qiwu/inference/pojo/TaskConditionPojo.java b/src/main/java/com/qiwu/inference/pojo/TaskConditionPojo.java new file mode 100644 index 0000000..ba6f261 --- /dev/null +++ b/src/main/java/com/qiwu/inference/pojo/TaskConditionPojo.java @@ -0,0 +1,23 @@ +package com.qiwu.inference.pojo; + +import com.opencsv.bean.CsvBindByName; +import lombok.Data; + +@Data +public class TaskConditionPojo { + /** + * 任务条件id + */ + @CsvBindByName(column = "ID") + private Integer id; + /** + * 操作列表ID + */ + @CsvBindByName(column = "操作列表ID") + private Integer methodId; + /** + * 类型 + */ + @CsvBindByName(column = "类型") + private int type; +} diff --git a/src/main/java/com/qiwu/inference/pojo/TaskExceptionSpeech.java b/src/main/java/com/qiwu/inference/pojo/TaskExceptionSpeech.java new file mode 100644 index 0000000..a8f803c --- /dev/null +++ b/src/main/java/com/qiwu/inference/pojo/TaskExceptionSpeech.java @@ -0,0 +1,15 @@ +package com.qiwu.inference.pojo; + +import com.opencsv.bean.CsvBindByName; +import lombok.Data; + +@Data +public class TaskExceptionSpeech { + private static final long serialVersionUID = 1L; + + @CsvBindByName(column = "反馈ID") + private Integer id; + + @CsvBindByName(column = "反馈文本") + private String answer; +} diff --git a/src/main/java/com/qiwu/inference/pojo/TaskSpeech.java b/src/main/java/com/qiwu/inference/pojo/TaskSpeech.java index 58dd45a..02f9d8a 100644 --- a/src/main/java/com/qiwu/inference/pojo/TaskSpeech.java +++ b/src/main/java/com/qiwu/inference/pojo/TaskSpeech.java @@ -1,5 +1,6 @@ package com.qiwu.inference.pojo; +import com.opencsv.bean.CsvBindByName; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -9,45 +10,54 @@ import java.io.Serializable; public class TaskSpeech implements Serializable { private static final long serialVersionUID = 1L; - @ApiModelProperty("线索ID") + @CsvBindByName(column = "线索ID") private Integer demandTaskId; - @ApiModelProperty("任务名称") + @CsvBindByName(column = "任务名称") private String taskName; - @ApiModelProperty("身份1") + @CsvBindByName(column = "身份1") private String identity; - @ApiModelProperty("性别") + @CsvBindByName(column = "性别") private String gender; - @ApiModelProperty("人物ID") + @CsvBindByName(column = "人物ID") private Integer personId; - @ApiModelProperty("年龄段") + @CsvBindByName(column = "年龄段") private String age; - @ApiModelProperty("性格A") + @CsvBindByName(column = "性格A") private String dispositionIds; - @ApiModelProperty("行为") + @CsvBindByName(column = "行为") private String behaviour; - @ApiModelProperty("任务状态") + @CsvBindByName(column = "任务状态") private Integer status; - @ApiModelProperty("进行中任务询问") + @CsvBindByName(column = "进行中任务询问") private String doingAsk; - @ApiModelProperty("进行中任务完成提醒") + @CsvBindByName(column = "进行中任务完成提醒") private String doingFinishedAnswer; - @ApiModelProperty("未进行中任务完成提醒") + @CsvBindByName(column = "未进行中任务完成提醒") private String noDoingFinishedAnswer; - @ApiModelProperty("完成对话文本") + @CsvBindByName(column = "任务启动文本") + private String startAnswer; + + @CsvBindByName(column = "任务操作提醒") + private String replyAnswer; + + @CsvBindByName(column = "完成对话文本") private String answer; - @ApiModelProperty("通用标签") + @CsvBindByName(column = "任务中断/关闭文本") + private String closeAnswer; + + @CsvBindByName(column = "通用标签") private Integer flag; } diff --git a/src/main/java/com/qiwu/inference/pojo/TipSpeech.java b/src/main/java/com/qiwu/inference/pojo/TipSpeech.java index 489b3ae..6b9586b 100644 --- a/src/main/java/com/qiwu/inference/pojo/TipSpeech.java +++ b/src/main/java/com/qiwu/inference/pojo/TipSpeech.java @@ -1,5 +1,6 @@ package com.qiwu.inference.pojo; +import com.opencsv.bean.CsvBindByName; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -9,15 +10,15 @@ import java.io.Serializable; public class TipSpeech implements Serializable { private static final long serialVersionUID = 1L; - @ApiModelProperty("ID") + @CsvBindByName(column = "ID") private Integer demandTaskId; - @ApiModelProperty("关于自身线索的指引") + @CsvBindByName(column = "关于自身线索的指引") private String selfClue; - @ApiModelProperty("关于他人线索的指引") + @CsvBindByName(column = "关于他人线索的指引") private String otherClue; - @ApiModelProperty("关于任务的指引") + @CsvBindByName(column = "关于任务的指引") private String taskClue; } diff --git a/src/main/java/com/qiwu/inference/service/ask/impl/AskServiceImpl.java b/src/main/java/com/qiwu/inference/service/ask/impl/AskServiceImpl.java index a4a8900..5ffe3f9 100644 --- a/src/main/java/com/qiwu/inference/service/ask/impl/AskServiceImpl.java +++ b/src/main/java/com/qiwu/inference/service/ask/impl/AskServiceImpl.java @@ -18,7 +18,7 @@ import org.springframework.util.StringUtils; @Service public class AskServiceImpl implements AskService { - private Logger log = LoggerFactory.getLogger(AskServiceImpl.class); + Logger log = LoggerFactory.getLogger(AskServiceImpl.class); //从yml配置文件中取出对话过期时间 @Value("${expireTime}") diff --git a/src/main/java/com/qiwu/inference/service/barrier/BarrierService.java b/src/main/java/com/qiwu/inference/service/barrier/BarrierService.java index 8d4d01b..024a860 100644 --- a/src/main/java/com/qiwu/inference/service/barrier/BarrierService.java +++ b/src/main/java/com/qiwu/inference/service/barrier/BarrierService.java @@ -8,4 +8,6 @@ public interface BarrierService { CommonResult operate(OperationRequest operationReq); CommonResult cancel(OperationRequest operationReq); + + CommonResult changePlace(OperationRequest operationReq); } diff --git a/src/main/java/com/qiwu/inference/service/barrier/impl/BarrierServiceImpl.java b/src/main/java/com/qiwu/inference/service/barrier/impl/BarrierServiceImpl.java index 174a9fe..1eeb17d 100644 --- a/src/main/java/com/qiwu/inference/service/barrier/impl/BarrierServiceImpl.java +++ b/src/main/java/com/qiwu/inference/service/barrier/impl/BarrierServiceImpl.java @@ -1,20 +1,17 @@ package com.qiwu.inference.service.barrier.impl; +import com.alibaba.fastjson.JSON; import com.qiwu.inference.common.Constants; import com.qiwu.inference.common.TimingAcquisition; import com.qiwu.inference.common.api.CommonResult; import com.qiwu.inference.common.cache.CacheGlobal; -import com.qiwu.inference.common.utils.CacheUtil; -import com.qiwu.inference.common.utils.PlayerUtil; -import com.qiwu.inference.common.utils.RandomUtil; -import com.qiwu.inference.common.utils.SpeechUtil; -import com.qiwu.inference.dto.DemandTaskDto; -import com.qiwu.inference.dto.Player; -import com.qiwu.inference.dto.PostTaskDto; -import com.qiwu.inference.dto.PostTaskRecordDto; +import com.qiwu.inference.common.utils.*; +import com.qiwu.inference.dto.*; import com.qiwu.inference.dto.request.OperationRequest; +import com.qiwu.inference.dto.response.CallResponse; import com.qiwu.inference.dto.response.ResultResponse; import com.qiwu.inference.dto.response.ResultVarsResponse; +import com.qiwu.inference.factory.RemoteCallFactory; import com.qiwu.inference.service.barrier.BarrierService; import com.qiwu.inference.service.common.CommonService; import org.slf4j.Logger; @@ -24,8 +21,10 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; +import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; -import java.util.Map; +import java.util.concurrent.ExecutorService; @Service public class BarrierServiceImpl implements BarrierService { @@ -37,6 +36,10 @@ public class BarrierServiceImpl implements BarrierService { @Autowired private CommonService commonService; + @Resource(name = "threadPoolInstance") + private ExecutorService executorService; + @Autowired + private RedisUtil redisUtil; @Override public CommonResult operate(OperationRequest operationReq) { @@ -47,117 +50,139 @@ public class BarrierServiceImpl implements BarrierService { String methodId = operationReq.getMethodId(); //方法编号 Integer subjectId = operationReq.getSubjectId(); //人物名称1 String locationId = operationReq.getLocationId(); //场所名称 - //当前玩家上一轮的请求信息 - OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); - if (!StringUtils.isEmpty(lastReq)) { - if (Constants.OPERATE_BARRIER.equals(lastReq.getOperate())) { - methodId = (methodId == null) ? lastReq.getMethodId() : methodId; - subjectId = (subjectId == null) ? lastReq.getSubjectId() : subjectId; + if (!StringUtils.isEmpty(subjectId)) { + if (subjectId == Constants.REQ_NON) { + //获取对应话术 + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400203); + resultResponse.set反馈ID(400203); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); } } operationReq.setOperate(Constants.OPERATE_BARRIER); Player player = TimingAcquisition.playerMap.get(uid); - String subjectName = PlayerUtil.getNameByPersonId(uid, subjectId); + String seriesName = player.getSeries(); //系列名称 //场所移动 if ("4001".equals(methodId)) { //离开,或者没有说明去哪和找谁 if (StringUtils.isEmpty(subjectId) && StringUtils.isEmpty(locationId)) { String locationText = PlayerUtil.getLocations(uid); //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400105); + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400105); text = SpeechUtil.speechReplaceNum(text, locationText); resultResponse.set反馈ID(400105); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } + String text = ""; //玩家提供的人物名称 if (!StringUtils.isEmpty(subjectId)) { //获取人物所在场所 - locationId = player.getPersonMap().get(subjectId).getLocation(); + locationId = PlayerUtil.getPerson(uid, subjectId).getLocation(); +// String subjectName = PlayerUtil.getNameByPersonId(uid, subjectId); + //获取对应话术 + text = SpeechUtil.getPersonFirstSpeech(uid, locationId, subjectId); //第一次见面时的话术 +// if (!StringUtils.isEmpty(text) && !"".equals(text)) { +// text = SpeechUtil.replaceHeader(text, subjectName); +// } + //更新场所和人物 + player.setLocation(locationId); + player.setPersonId(subjectId); + //----------------解锁场所------------- + PlayerUtil.unlockLocation(player.getLocationMap(), locationId); +// List personIdList = new ArrayList<>(); +// personIdList.add(subjectId); + //-------------查找这个人物所有的后置任务和自动触发的任务-------------- + List postTaskList = PlayerUtil.getDemandTaskHavePre(uid, subjectId); + if (postTaskList.size() != 0) { + //---------------找到优先级高的任务--------------------- + PostTaskRecordDto postTaskRecord = PlayerUtil.getPostTask(uid, postTaskList); + //存在优先级高的任务 + if (!StringUtils.isEmpty(postTaskRecord)) { + //----------------记录见过的人-------------- + PlayerUtil.recordClue(uid, subjectId); + //更新该NPC见面次数 + PlayerUtil.updateMeetTimes(uid, player.getLocation(), subjectId); + //------------------执行对应的任务操作------------------ + resultVarsResponse = PlayerUtil.taskDoByLevel(uid, postTaskRecord); + text += resultVarsResponse.getVars().get反馈文本(); + resultVarsResponse.getVars().set反馈文本(text); + resultVarsResponse.getVars().set当前对话角色身份(PlayerUtil.getPerson(uid, player.getPersonId()).getIdentityName()); + return CommonResult.success(resultVarsResponse); + } + } } else { //玩家提供的场所不存在 if (Constants.NON_STR.equals(locationId)) { //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400103); + text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400103); resultResponse.set反馈ID(400103); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } + //玩家提供序号的情况 + OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); + if (!StringUtils.isEmpty(lastReq)) { + if (lastReq.getOperateLabel() == Constants.CHECK_LOCATION) { + String locationIdTemp = TypeConvertUtil.getNumFromList(lastReq.getStrList(), Integer.valueOf(locationId)); + if (!StringUtils.isEmpty(locationIdTemp)) { + locationId = locationIdTemp; + //获取对应话术 +// String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400106); +// text = SpeechUtil.speechReplaceNum(text, String.valueOf(lastReq.getStrList().size())); +// resultResponse.set反馈ID(400106); +// resultResponse.set反馈文本(text); +// resultVarsResponse.setVars(resultResponse); +// return CommonResult.success(resultVarsResponse); + } + } + } List personIdList = PlayerUtil.getPersonsByLocationId(uid, locationId); if (StringUtils.isEmpty(personIdList)) { //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400104); + text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400104); resultResponse.set反馈ID(400104); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - //查找所有每个人物的后置任务情况 + //-----------------查找所有每个人物的后置任务和自动触发任务的情况------------------- List postTaskList = PlayerUtil.getDemandTaskHavePre(uid, personIdList); if (postTaskList.size() != 0) { - //找到优先级高的任务 + //-----------------找到优先级高的任务---------------- PostTaskRecordDto postTaskRecord = PlayerUtil.getPostTask(uid, postTaskList); //存在优先级高的任务 if (!StringUtils.isEmpty(postTaskRecord)) { - //前置任务已完成 - if (postTaskRecord.getLevel() == 1 || postTaskRecord.getLevel() == 2) { - subjectId = postTaskRecord.getPersonId(); - //----------------记录见过的人-------------- - PlayerUtil.recordClue(uid, subjectId); - //任务自动完成 - Map> taskMap = player.getTaskMap(); - Map map = taskMap.get(subjectId); - map.put(postTaskRecord.getPostTaskId(), 1); - player.setLocation(locationId); - player.setPersonId(subjectId); - DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, postTaskRecord.getPostTaskId()); - if (!StringUtils.isEmpty(demandTask)) { - PlayerUtil.addThreshold(player.getPersonMap().get(subjectId), demandTask); - String text = ""; - if (postTaskRecord.getLevel() == 1) { - //获取对应话术 - text = SpeechUtil.getPreSuccessTaskSpeech(uid, player.getPersonMap().get(subjectId), demandTask, 1); - resultResponse.set反馈ID(400105); - } - if (postTaskRecord.getLevel() == 2) { - //获取对应话术 - text = SpeechUtil.getPreSuccessTaskSpeech(uid, player.getPersonMap().get(subjectId), demandTask, 2); - resultResponse.set反馈ID(400106); - } - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - //任务是本人发布的 - if (postTaskRecord.getLevel() == 3) { - subjectId = postTaskRecord.getPersonId(); - player.setLocation(locationId); - player.setPersonId(subjectId); - DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, postTaskRecord.getPostTaskId()); - String text = ""; - if (!StringUtils.isEmpty(demandTask)) { - text = SpeechUtil.getPreSuccessTaskSpeech(uid, player.getPersonMap().get(subjectId), demandTask, 3); - } - //----------------记录见过的人-------------- - PlayerUtil.recordClue(uid, subjectId); - resultResponse.set反馈ID(400107); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } + subjectId = postTaskRecord.getPersonId(); + //获取对应话术 + text = SpeechUtil.getPersonFirstSpeech(uid, locationId, subjectId); //第一次见面时的话术 + //更新场所和人物 + player.setLocation(locationId); + player.setPersonId(subjectId); + //----------------解锁场所------------- + PlayerUtil.unlockLocation(player.getLocationMap(), locationId); + //----------------记录见过的人-------------- + PlayerUtil.recordClue(uid, subjectId); + //更新该NPC见面次数 + PlayerUtil.updateMeetTimes(uid, player.getLocation(), subjectId); + //----------------------执行对应的任务操作------------------------ + resultVarsResponse = PlayerUtil.taskDoByLevel(uid, postTaskRecord); + text += resultVarsResponse.getVars().get反馈文本(); + resultVarsResponse.getVars().set反馈文本(text); + resultVarsResponse.getVars().set当前对话角色身份(PlayerUtil.getPerson(uid, player.getPersonId()).getIdentityName()); + return CommonResult.success(resultVarsResponse); } } int index = RandomUtil.randomInt(personIdList.size()); subjectId = personIdList.get(index); - subjectName = PlayerUtil.getNameByPersonId(uid, subjectId); } //场所为隐藏,还未解锁 if (Constants.IS_HIDDEN.equals(player.getLocationMap().get(locationId).getIsHidden())) { //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400102); + text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400102); resultResponse.set反馈ID(400102); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -165,101 +190,83 @@ public class BarrierServiceImpl implements BarrierService { } player.setLocation(locationId); player.setPersonId(subjectId); + String subjectName = PlayerUtil.getNameByPersonId(uid, subjectId); + //获取对应话术 + if (StringUtils.isEmpty(text)) { + text = SpeechUtil.getPersonSpeech(uid, locationId, subjectId); + text = SpeechUtil.replaceHeader(text, subjectName); + } //----------------记录见过的人-------------- PlayerUtil.recordClue(uid, subjectId); - //获取对应话术 - String text = SpeechUtil.getPersonSpeech(uid, locationId, subjectId); - text = SpeechUtil.replaceHeader(text, subjectName); - //更新见面次数 + //更新该NPC见面次数 PlayerUtil.updateMeetTimes(uid, locationId, subjectId); // String call = (player.getPersonMap().get(subjectId).getGender() == 1) ? "他" : "她"; //获取对应话术 -// String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400101); +// String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400101); // text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.locationMap.get(locationId).getName(), subjectName, call); resultResponse.set反馈ID(400101); resultResponse.set反馈文本(text); + resultResponse.set当前对话角色身份(PlayerUtil.getPerson(uid, player.getPersonId()).getIdentityName()); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } + //当前玩家上一轮的请求信息 + OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); + if (!StringUtils.isEmpty(lastReq)) { + if (Constants.OPERATE_BARRIER.equals(lastReq.getOperate())) { + methodId = (methodId == null) ? lastReq.getMethodId() : methodId; + subjectId = (subjectId == null) ? lastReq.getSubjectId() : subjectId; + } + } //直接找人 if ("4002".equals(methodId)) { + String subjectName = PlayerUtil.getNameByPersonId(uid, subjectId); //关卡中没有这个人物 - if (StringUtils.isEmpty(player.getPersonMap().get(subjectId))) { + if (StringUtils.isEmpty(PlayerUtil.getPerson(uid, subjectId))) { //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400203); + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400203); resultResponse.set反馈ID(400203); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } //关卡中有这个人,但场所未知 - if (StringUtils.isEmpty(player.getPersonMap().get(subjectId).getLocation())) { + if (StringUtils.isEmpty(PlayerUtil.getPerson(uid, subjectId).getLocation())) { //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400204); + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400204); text = SpeechUtil.speechReplaceNum(text, subjectName); resultResponse.set反馈ID(400204); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - //查找所有这个人物的后置任务情况 + //获取人物所在场所 + locationId = PlayerUtil.getPerson(uid, subjectId).getLocation(); + //---------------------查找所有这个人物的后置任务和自动触发任务的情况--------------------- List postTaskList = PlayerUtil.getDemandTaskHavePre(uid, subjectId); if (postTaskList.size() != 0) { - //找到优先级高的任务 + //---------------------------找到优先级高的任务---------------------------- PostTaskRecordDto postTaskRecord = PlayerUtil.getPostTask(uid, postTaskList); //存在优先级高的任务 if (!StringUtils.isEmpty(postTaskRecord)) { - //前置任务已完成 - if (postTaskRecord.getLevel() == 1 || postTaskRecord.getLevel() == 2) { - subjectId = postTaskRecord.getPersonId(); - //----------------记录见过的人-------------- - PlayerUtil.recordClue(uid, subjectId); - //任务自动完成 - Map> taskMap = player.getTaskMap(); - Map map = taskMap.get(subjectId); - map.put(postTaskRecord.getPostTaskId(), 1); - player.setLocation(locationId); - player.setPersonId(subjectId); - DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, postTaskRecord.getPostTaskId()); - if (!StringUtils.isEmpty(demandTask)) { - PlayerUtil.addThreshold(player.getPersonMap().get(subjectId), demandTask); - String text = ""; - if (postTaskRecord.getLevel() == 1) { - //获取对应话术 - text = SpeechUtil.getPreSuccessTaskSpeech(uid, player.getPersonMap().get(subjectId), demandTask, 1); - resultResponse.set反馈ID(400105); - } - if (postTaskRecord.getLevel() == 2) { - //获取对应话术 - text = SpeechUtil.getPreSuccessTaskSpeech(uid, player.getPersonMap().get(subjectId), demandTask, 2); - resultResponse.set反馈ID(400106); - } - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - //任务是本人发布的 - if (postTaskRecord.getLevel() == 3) { - subjectId = postTaskRecord.getPersonId(); - player.setLocation(locationId); - player.setPersonId(subjectId); - DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, postTaskRecord.getPostTaskId()); - String text = ""; - if (!StringUtils.isEmpty(demandTask)) { - text = SpeechUtil.getPreSuccessTaskSpeech(uid, player.getPersonMap().get(subjectId), demandTask, 3); - } - //----------------记录见过的人-------------- - PlayerUtil.recordClue(uid, subjectId); - resultResponse.set反馈ID(400107); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } + subjectId = postTaskRecord.getPersonId(); + //获取对应话术 + String text = SpeechUtil.getPersonFirstSpeech(uid, locationId, subjectId); //第一次见面时的话术 + //更新场所和人物 + player.setLocation(locationId); + player.setPersonId(subjectId); + //----------------记录见过的人-------------- + PlayerUtil.recordClue(uid, subjectId); + //更新该NPC见面次数 + PlayerUtil.updateMeetTimes(uid, player.getLocation(), subjectId); + //----------------------执行对应的任务操作--------------------- + resultVarsResponse = PlayerUtil.taskDoByLevel(uid, postTaskRecord); + text += resultVarsResponse.getVars().get反馈文本(); + resultVarsResponse.getVars().set反馈文本(text); + resultVarsResponse.getVars().set当前对话角色身份(PlayerUtil.getPerson(uid, player.getPersonId()).getIdentityName()); + return CommonResult.success(resultVarsResponse); } } - //获取人物所在场所 - locationId = player.getPersonMap().get(subjectId).getLocation(); //跟玩家在同一场所 if (player.getLocation().equals(locationId)) { player.setPersonId(subjectId); @@ -281,9 +288,13 @@ public class BarrierServiceImpl implements BarrierService { //不在同一场所 //判断玩家是否已经获得了该人物的场所线索 boolean flag = PlayerUtil.checkLocationClue(player.getClueMap(), subjectId); + //没有获得该NPC的场所线索,但是去到某个场所见过该NPC,也可以找到该NPC + if (!flag) { + flag = PlayerUtil.checkHaveMeet(player.getLocationMap(), locationId, subjectId); + } if (!flag) { //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400204); + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400204); text = SpeechUtil.speechReplaceNum(text, subjectName); resultResponse.set反馈ID(400205); resultResponse.set反馈文本(text); @@ -294,9 +305,13 @@ public class BarrierServiceImpl implements BarrierService { operationReq.setSubjectId(subjectId); operationReq.setMethodId("4001"); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); + //----------------记录见过的人-------------- +// PlayerUtil.recordClue(uid, subjectId); +// //更新该NPC见面次数 +// PlayerUtil.updateMeetTimes(uid, locationId, subjectId); //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400202); - text = SpeechUtil.speechReplaceNum(text, subjectName, TimingAcquisition.locationMap.get(locationId).getName()); + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400202); + text = SpeechUtil.speechReplaceNum(text, subjectName, TimingAcquisition.seriesLocationMap.get(seriesName).get(locationId).getName()); resultResponse.set反馈ID(400202); resultResponse.set反馈文本(text); resultResponse.set后台附加返回("关卡操作回复1"); @@ -306,8 +321,8 @@ public class BarrierServiceImpl implements BarrierService { //重新开始 if ("400301".equals(methodId)) { //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400301); - text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.systemConfigMap.get("money").getValue()); + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400301); + text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("money").getValue()); resultResponse.set反馈ID(400301); resultResponse.set反馈文本(text); resultResponse.set后台附加返回("重试关卡回复1"); @@ -319,7 +334,10 @@ public class BarrierServiceImpl implements BarrierService { //玩家本关卡的数据重置 PlayerUtil.resetPlayer(uid); //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400302); + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400302); + //获取开场白话术 + String prologueText = SpeechUtil.getPrologueSpeech(uid, player.getGateNo()); + text += prologueText; resultResponse.set反馈ID(400302); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -328,7 +346,7 @@ public class BarrierServiceImpl implements BarrierService { //取消重新开始 if ("400303".equals(methodId)) { //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400303); + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400303); resultResponse.set反馈ID(400303); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -337,9 +355,9 @@ public class BarrierServiceImpl implements BarrierService { //跳过关卡 if ("400401".equals(methodId)) { //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400401); - text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.systemConfigMap.get("money").getValue()); - resultResponse.set反馈ID(400301); + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400401); + text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("money").getValue()); + resultResponse.set反馈ID(400401); resultResponse.set反馈文本(text); resultResponse.set后台附加返回("放弃操作回复1"); resultVarsResponse.setVars(resultResponse); @@ -350,8 +368,8 @@ public class BarrierServiceImpl implements BarrierService { //玩家本关卡的数据重置 PlayerUtil.playerGiveUp(uid); //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400402); - resultResponse.set反馈ID(400302); + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400402); + resultResponse.set反馈ID(400402); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); @@ -359,15 +377,72 @@ public class BarrierServiceImpl implements BarrierService { //取消跳过关卡 if ("400403".equals(methodId)) { //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400403); - resultResponse.set反馈ID(400303); + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400403); + resultResponse.set反馈ID(400403); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //退出当前关卡询问 + if ("400501".equals(methodId)) { + //获取对应话术 + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400501); + resultResponse.set反馈ID(400501); + resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("退出操作回复1"); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //确认退出当前关卡 + if ("400502".equals(methodId)) { + String series = player.getSeries(); + //-----------存入redis缓存中------------- + redisUtil.setStr(series + "::"+ uid, JSON.toJSONString(TimingAcquisition.seriesPlayerMap.get(series).get(uid))); + String initMoney = TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("init_money").getValue(); + if (StringUtils.isEmpty(initMoney)) { + executorService.execute(new Runnable() { + @Override + public void run() { + try { + CallResponse callResponse = RemoteCallFactory.getInstance().updateItems(uid, "gardenSys"); + log.info(uid + "物品更新结果:" + callResponse.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + //获取对应话术 + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400502); + //玩家下线,数据保存 + //更新玩家为离线状态 + player.setStatus(Constants.OFFLINE); + //修改下线时间 + player.setOfflineTime(DateUtil.getCurrentTime()); + //创建玩家数据路径 + String path = MD5Util.changeToPath(uid, player.getSeries()); + //--------------持久化该玩家信息--------------- + PersistenceUtil.saveDataToFile(path, player.getGateNo(), JSON.toJSONString(player)); + //--------------持久化该玩家系列汇总的数据--------------- + String dataPath = MD5Util.changeToDataPath(uid, player.getSeries()); + PersistenceUtil.saveDataToFile(dataPath, uid, JSON.toJSONString(TimingAcquisition.seriesPlayerMap.get(player.getSeries()).get(uid))); + resultResponse.set反馈ID(400502); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //取消退出当前关卡 + if ("400503".equals(methodId)) { + //获取对应话术 + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400503); + resultResponse.set反馈ID(400503); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400101); - resultResponse.set反馈ID(300101); + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400101); + resultResponse.set反馈ID(400101); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); @@ -382,10 +457,34 @@ public class BarrierServiceImpl implements BarrierService { //清除缓存,本轮对话结束 CacheGlobal.concurrentMap.remove(uid); //获取对应话术 - String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400001); + String text = SpeechUtil.getBarrierSpeech(uid, Constants.SPEECH_ASIDE, 400001); resultResponse.set反馈ID(400001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } + + @Override + public CommonResult changePlace(OperationRequest operationReq) { + String uid = operationReq.getUid(); + String locationId = operationReq.getLocationId(); + Integer personId = operationReq.getSubjectId(); + Player player = TimingAcquisition.playerMap.get(uid); + //没有指定场所和人物时 + if (StringUtils.isEmpty(locationId) && StringUtils.isEmpty(personId)) { + operationReq.setMethodId("4002"); + operationReq.setSubjectId(player.getPersonId()); + } else if (!StringUtils.isEmpty(locationId) && StringUtils.isEmpty(personId)) { + //仅指定了场所 + operationReq.setMethodId("4001"); + } else if (StringUtils.isEmpty(locationId) && !StringUtils.isEmpty(personId)) { + //仅指定了人物 + operationReq.setMethodId("4001"); + } else { + //场所和人物均指定了 + operationReq.setMethodId("4002"); + } + return operate(operationReq); + } + } diff --git a/src/main/java/com/qiwu/inference/service/chat/impl/ChatServiceImpl.java b/src/main/java/com/qiwu/inference/service/chat/impl/ChatServiceImpl.java index b5e071f..d621670 100644 --- a/src/main/java/com/qiwu/inference/service/chat/impl/ChatServiceImpl.java +++ b/src/main/java/com/qiwu/inference/service/chat/impl/ChatServiceImpl.java @@ -2,6 +2,7 @@ package com.qiwu.inference.service.chat.impl; import com.qiwu.inference.common.TimingAcquisition; import com.qiwu.inference.common.api.CommonResult; +import com.qiwu.inference.common.utils.MD5Util; import com.qiwu.inference.common.utils.NumberUtil; import com.qiwu.inference.common.utils.PlayerUtil; import com.qiwu.inference.common.utils.SpeechUtil; @@ -35,20 +36,36 @@ public class ChatServiceImpl implements ChatService { String methodId = operationReq.getMethodId(); //方法编号 Player player = TimingAcquisition.playerMap.get(uid); //对话人的信息 - Person current = player.getPersonMap().get(player.getPersonId()); + Person current = PlayerUtil.getPerson(uid, player.getPersonId()); + String seriesName = player.getSeries(); //系列名称 + //搭档名称 + String partnerName = TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("partnerName").getValue(); //获取对应话术 String text = SpeechUtil.getChatSpeech(uid, current, methodId); text = SpeechUtil.addHeader(text, current.getName()); //闲聊连续对话次数超过指定次数,任务白名单中有该人已解锁或无需解锁的任务则进行提示 - int chatTimes = Integer.parseInt(TimingAcquisition.systemConfigMap.get("chatTimes").getValue()); - if (player.getChatTimes() >= chatTimes) { - //找到白名单内该人的任务中已解锁或无需解锁的任务 + int chatTimes = Integer.parseInt(TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("chatTimes").getValue()); + if (player.getChatTimes() >= chatTimes - 1) { +// //找到白名单内该人的任务中已解锁或无需解锁的任务 String addText = PlayerUtil.getTipInChat(uid, current); if (!StringUtils.isEmpty(addText)) { - addText = "【寒烟@正常】" + addText; + if (!addText.contains("@正常】")) { + addText = SpeechUtil.addHeader(addText, partnerName); + } text += addText; } } + //每轮的第一次进行操作提示 + if (player.getChatTimes() == 0) { + //找到操作的提示 + String operateText = SpeechUtil.getOperateSpeech(player); + if (!StringUtils.isEmpty(operateText)) { + operateText = SpeechUtil.addHeader(operateText, partnerName); + text += operateText; + } + //更新玩家操作提示的序号 + player.setOperateTextNum(player.getOperateTextNum() + 1); + } resultResponse.set反馈ID(600101); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); diff --git a/src/main/java/com/qiwu/inference/service/check/CheckService.java b/src/main/java/com/qiwu/inference/service/check/CheckService.java index 8a0930a..c4ba99c 100644 --- a/src/main/java/com/qiwu/inference/service/check/CheckService.java +++ b/src/main/java/com/qiwu/inference/service/check/CheckService.java @@ -6,4 +6,8 @@ import com.qiwu.inference.dto.response.ResultVarsResponse; public interface CheckService { CommonResult check(OperationRequest operationReq); + + CommonResult secondAnswer(OperationRequest operationReq); + + CommonResult checkRanking(OperationRequest operationReq); } diff --git a/src/main/java/com/qiwu/inference/service/check/impl/CheckServiceImpl.java b/src/main/java/com/qiwu/inference/service/check/impl/CheckServiceImpl.java index e1dfc7e..dabf6f2 100644 --- a/src/main/java/com/qiwu/inference/service/check/impl/CheckServiceImpl.java +++ b/src/main/java/com/qiwu/inference/service/check/impl/CheckServiceImpl.java @@ -3,16 +3,17 @@ package com.qiwu.inference.service.check.impl; import com.qiwu.inference.common.Constants; import com.qiwu.inference.common.TimingAcquisition; import com.qiwu.inference.common.api.CommonResult; +import com.qiwu.inference.common.cache.CacheGlobal; import com.qiwu.inference.common.utils.*; -import com.qiwu.inference.dto.ClueDto; -import com.qiwu.inference.dto.Person; -import com.qiwu.inference.dto.Player; +import com.qiwu.inference.dto.*; import com.qiwu.inference.dto.request.OperationRequest; import com.qiwu.inference.dto.response.ResultResponse; import com.qiwu.inference.dto.response.ResultVarsResponse; +import com.qiwu.inference.service.chat.impl.ChatServiceImpl; import com.qiwu.inference.service.check.CheckService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -21,15 +22,21 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.PriorityBlockingQueue; + +import static com.qiwu.inference.common.utils.PlayerUtil.addThreshold; @Service public class CheckServiceImpl implements CheckService { - private Logger log = LoggerFactory.getLogger(CheckServiceImpl.class); + Logger log = LoggerFactory.getLogger(CheckServiceImpl.class); //对话过期时间 @Value("${expireTime}") private String expireTime; + @Autowired + private ChatServiceImpl chatService; + @Override public CommonResult check(OperationRequest operationReq) { ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); @@ -44,7 +51,7 @@ public class CheckServiceImpl implements CheckService { if (!StringUtils.isEmpty(subjectId)) { if(subjectId == Constants.REQ_NON){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100008); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100008); resultResponse.set反馈ID(300008); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -53,13 +60,14 @@ public class CheckServiceImpl implements CheckService { } operationReq.setOperate(Constants.OPERATE_CHECK); Player player = TimingAcquisition.playerMap.get(uid); + String seriesName = player.getSeries(); //系列名称 if ("3001".equals(methodId)) { //玩家已对话过的人物 List personList = new ArrayList<>(player.getClueMap().keySet()); //玩家还没有获得线索 if (personList.size() == 0) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30010101); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30010101); resultResponse.set反馈ID(30010101); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -78,15 +86,15 @@ public class CheckServiceImpl implements CheckService { String text = ""; if (personList.size() == 1) { //人物信息 - Person person = player.getPersonMap().get(personList.get(0)); + Person person = PlayerUtil.getPersonMap(uid).get(personList.get(0)); String call = (person.getGender() == 1) ? "他" : "她"; - text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30010102); + text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30010102); text = SpeechUtil.speechReplaceNum(text, personText.toString(), call); //保存本轮对话 operationReq.setSubjectId(personList.get(0)); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); } else { - text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300101); + text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300101); text = SpeechUtil.speechReplaceNum(text, personText.toString()); } resultResponse.set反馈ID(300101); @@ -112,7 +120,7 @@ public class CheckServiceImpl implements CheckService { //玩家还没有获得线索 if (personList.size() == 0) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30010101); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30010101); resultResponse.set反馈ID(30010101); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -131,15 +139,15 @@ public class CheckServiceImpl implements CheckService { String text = ""; if (personList.size() == 1) { //人物信息 - Person person = player.getPersonMap().get(personList.get(0)); + Person person = PlayerUtil.getPersonMap(uid).get(personList.get(0)); String call = (person.getGender() == 1) ? "他" : "她"; - text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30010102); + text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30010102); text = SpeechUtil.speechReplaceNum(text, personText.toString(), call); //保存本轮对话 operationReq.setSubjectId(subjectId); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); } else { - text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300101); + text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300101); text = SpeechUtil.speechReplaceNum(text, personText.toString()); } resultResponse.set反馈ID(300101); @@ -151,7 +159,7 @@ public class CheckServiceImpl implements CheckService { //人物名称不存在 if (subjectId == Constants.REQ_NON) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300104); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300104); text = SpeechUtil.speechReplaceNum(text, personText.toString()); resultResponse.set反馈ID(300104); resultResponse.set反馈文本(text); @@ -162,7 +170,7 @@ public class CheckServiceImpl implements CheckService { //玩家还没见过这个人 if (!personList.contains(subjectId)) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30010201); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30010201); text = SpeechUtil.speechReplaceNum(text, subjectName); resultResponse.set反馈ID(30010201); resultResponse.set反馈文本(text); @@ -173,13 +181,15 @@ public class CheckServiceImpl implements CheckService { operationReq.setSubjectId(subjectId); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //人物信息 - Person person = player.getPersonMap().get(subjectId); + Person person = PlayerUtil.getPersonMap(uid).get(subjectId); String call = (person.getGender() == 1) ? "他" : "她"; + int trustDegree = player.getPersonInfoMap().get(subjectId).getTrustDegree(); + int deterrenceDegree = player.getPersonInfoMap().get(subjectId).getDeterrenceDegree(); //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300102); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300102); text = SpeechUtil.speechReplaceNum(text, subjectName, person.getAge().toString(), (person.getGender() == 1) ? "男" : "女", call, - person.getTrustDegree().toString(), person.getDeterrenceDegree().toString()); + String.valueOf(trustDegree - 50), String.valueOf(deterrenceDegree - 50)); resultResponse.set反馈ID(300102); resultResponse.set反馈文本(text); resultResponse.set后台附加返回("查看人物列表2"); @@ -191,7 +201,7 @@ public class CheckServiceImpl implements CheckService { //没有人物名称 if (StringUtils.isEmpty(subjectId)) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30010301); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30010301); resultResponse.set反馈ID(30010301); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -199,11 +209,11 @@ public class CheckServiceImpl implements CheckService { } //线索 StringBuilder clueText = new StringBuilder(); - Map> clueMap = player.getClueMap().get(subjectId); + Map> clueMap = player.getClueMap().get(subjectId); //有对话过的人 if (!StringUtils.isEmpty(clueMap)) { - for (Map.Entry> entry : clueMap.entrySet()) { - List clues = entry.getValue(); + for (Map.Entry> entry : clueMap.entrySet()) { + List clues = entry.getValue(); //身份线索 if (entry.getKey() == 1) { clueText.append("身份线索: "); @@ -240,17 +250,17 @@ public class CheckServiceImpl implements CheckService { operationReq.setSubjectId(subjectId); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300103); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300103); text = SpeechUtil.speechReplaceNum(text, PlayerUtil.getNameByPersonId(uid, subjectId), clueText.toString()); resultResponse.set反馈ID(300103); resultResponse.set反馈文本(text); - resultResponse.set后台附加返回("查看线索3"); + resultResponse.set后台附加返回("查看人物列表3"); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } } //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30010302); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30010302); resultResponse.set反馈ID(30010302); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -258,9 +268,10 @@ public class CheckServiceImpl implements CheckService { } //查看货币 if ("3003".equals(methodId)) { + int money = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getMoney(); //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300301); - text = SpeechUtil.speechReplaceNum(text, String.valueOf(player.getCurrency().intValue()), TimingAcquisition.systemConfigMap.get("money").getValue()); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300301); + text = SpeechUtil.speechReplaceNum(text, String.valueOf(money), TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("money").getValue()); resultResponse.set反馈ID(300301); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -268,9 +279,15 @@ public class CheckServiceImpl implements CheckService { } //查看场所 if ("3004".equals(methodId)) { + //获取玩家已知场所 + List locationIdList = PlayerUtil.getLocationIdsByUid(uid); + operationReq.setStrList(locationIdList); + operationReq.setOperateLabel(Constants.CHECK_LOCATION); + CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); + //场所文本 String locationText = PlayerUtil.getLocations(uid); //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300401); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300401); text = SpeechUtil.speechReplaceNum(text, locationText); resultResponse.set反馈ID(300401); resultResponse.set反馈文本(text); @@ -281,11 +298,11 @@ public class CheckServiceImpl implements CheckService { //查看线索 if ("3005".equals(methodId)) { int clueSize = 0; - for (Map.Entry>> entry : player.getClueMap().entrySet()) { - Map> clueMap = entry.getValue(); + for (Map.Entry>> entry : player.getClueMap().entrySet()) { + Map> clueMap = entry.getValue(); //遍历该人物所有类型的线索 if (!StringUtils.isEmpty(clueMap)) { - for (Map.Entry> listEntry : clueMap.entrySet()) { + for (Map.Entry> listEntry : clueMap.entrySet()) { clueSize += listEntry.getValue().size(); } } @@ -294,9 +311,12 @@ public class CheckServiceImpl implements CheckService { String text = ""; //玩家当前还没有获得线索 if (clueSize != 0) { - text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300501); + text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300501); } else { - text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050101); + text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050101); + //搭档名称 + String partnerName = TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("partnerName").getValue(); + text = SpeechUtil.addHeader(text, partnerName); } text = SpeechUtil.speechReplaceNum(text, String.valueOf(clueSize)); resultResponse.set反馈ID(300501); @@ -311,7 +331,7 @@ public class CheckServiceImpl implements CheckService { //当前还没有对话过的人物 if (player.getClueMap().size() == 0) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050201); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050201); text = SpeechUtil.speechReplaceNum(text, String.valueOf(player.getClueMap().size()), clueNumText.toString()); resultResponse.set反馈ID(30050201); resultResponse.set反馈文本(text); @@ -320,13 +340,13 @@ public class CheckServiceImpl implements CheckService { } //有线索人物的人数统计 int count = 0; - for (Map.Entry>> entry : player.getClueMap().entrySet()) { + for (Map.Entry>> entry : player.getClueMap().entrySet()) { int size = 0; - Map> clueMap = entry.getValue(); + Map> clueMap = entry.getValue(); //遍历该人物所有类型的线索 if (!StringUtils.isEmpty(clueMap)) { - clueNumText.append(player.getPersonMap().get(entry.getKey()).getName()).append("有"); - for (Map.Entry> listEntry : clueMap.entrySet()) { + clueNumText.append(PlayerUtil.getPersonMap(uid).get(entry.getKey()).getName()).append("有"); + for (Map.Entry> listEntry : clueMap.entrySet()) { size += listEntry.getValue().size(); count++; } @@ -337,7 +357,7 @@ public class CheckServiceImpl implements CheckService { clueNumText.deleteCharAt(clueNumText.length() - 1); } //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300502); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300502); text = SpeechUtil.speechReplaceNum(text, String.valueOf(count), clueNumText.toString()); resultResponse.set反馈ID(300502); resultResponse.set反馈文本(text); @@ -349,11 +369,11 @@ public class CheckServiceImpl implements CheckService { if ("300503".equals(methodId)) { StringBuilder clueText = new StringBuilder(); Map clueNumMap = new HashMap<>(); - for (Map.Entry>> entry : player.getClueMap().entrySet()) { - Map> clueMap = entry.getValue(); + for (Map.Entry>> entry : player.getClueMap().entrySet()) { + Map> clueMap = entry.getValue(); //遍历该人物所有类型的线索 if (!StringUtils.isEmpty(clueMap)) { - for (Map.Entry> listEntry : clueMap.entrySet()) { + for (Map.Entry> listEntry : clueMap.entrySet()) { int size = (clueNumMap.get(listEntry.getKey()) == null) ? 0 : clueNumMap.get(listEntry.getKey()); clueNumMap.put(listEntry.getKey(), size + listEntry.getValue().size()); } @@ -362,8 +382,10 @@ public class CheckServiceImpl implements CheckService { //玩家没有收集到线索 if (clueNumMap.size() == 0) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050301); - text = SpeechUtil.speechReplaceNum(text, clueText.toString()); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050301); + //搭档名称 + String partnerName = TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("partnerName").getValue(); + text = SpeechUtil.addHeader(text, partnerName); resultResponse.set反馈ID(30050301); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -404,7 +426,7 @@ public class CheckServiceImpl implements CheckService { clueText.deleteCharAt(clueText.length() - 1); } //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300503); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300503); text = SpeechUtil.speechReplaceNum(text, clueText.toString()); resultResponse.set反馈ID(300503); resultResponse.set反馈文本(text); @@ -417,12 +439,12 @@ public class CheckServiceImpl implements CheckService { if ("300504".equals(methodId)) { //线索 StringBuilder clueText = new StringBuilder(); - Map> clueMap = player.getClueMap().get(subjectId); + Map> clueMap = player.getClueMap().get(subjectId); String subjectName = TimingAcquisition.getNameByPersonId(uid, subjectId); //玩家还没有获得任何线索 if (player.getClueMap().size() == 0) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050401); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050401); text = SpeechUtil.speechReplaceNum(text, subjectName); resultResponse.set反馈ID(30050401); resultResponse.set反馈文本(text); @@ -432,7 +454,7 @@ public class CheckServiceImpl implements CheckService { //玩家还没有这个人的线索 if (StringUtils.isEmpty(clueMap)) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050402); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050402); text = SpeechUtil.speechReplaceNum(text, subjectName); resultResponse.set反馈ID(30050402); resultResponse.set反馈文本(text); @@ -441,9 +463,9 @@ public class CheckServiceImpl implements CheckService { } int size = 0; //有对话过的人 - for (Map.Entry> entry : clueMap.entrySet()) { + for (Map.Entry> entry : clueMap.entrySet()) { size += entry.getValue().size(); - List clues = entry.getValue(); + List clues = entry.getValue(); clueText.append(clues.size()).append("条"); //身份线索 if (entry.getKey() == 1) { @@ -479,7 +501,7 @@ public class CheckServiceImpl implements CheckService { operationReq.setSubjectId(subjectId); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300504); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300504); text = SpeechUtil.speechReplaceNum(text, subjectName, String.valueOf(size), clueText.toString()); resultResponse.set反馈ID(300504); resultResponse.set反馈文本(text); @@ -491,12 +513,12 @@ public class CheckServiceImpl implements CheckService { if ("300505".equals(methodId)) { StringBuilder clueText = new StringBuilder(); int size = 0; - for (Map.Entry>> entry : player.getClueMap().entrySet()) { - Map> clueMap = entry.getValue(); + for (Map.Entry>> entry : player.getClueMap().entrySet()) { + Map> clueMap = entry.getValue(); //遍历该人物所有类型的线索 if (!StringUtils.isEmpty(clueMap)) { - clueText.append(player.getPersonMap().get(entry.getKey()).getName()).append("有"); - for (Map.Entry> listEntry : clueMap.entrySet()) { + clueText.append(PlayerUtil.getPersonMap(uid).get(entry.getKey()).getName()).append("有"); + for (Map.Entry> listEntry : clueMap.entrySet()) { if (clueTypeId.equals(listEntry.getKey())) { size += listEntry.getValue().size(); clueText.append(listEntry.getValue().size()).append("条、"); @@ -507,8 +529,8 @@ public class CheckServiceImpl implements CheckService { //玩家还没有对应类型的线索 if (size == 0) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050501); - text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.clueTypeMap.get(clueTypeId)); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050501); + text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.seriesClueTypeMap.get(seriesName).get(clueTypeId)); resultResponse.set反馈ID(30050501); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -521,8 +543,8 @@ public class CheckServiceImpl implements CheckService { operationReq.setClueTypeId(clueTypeId); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300505); - text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.clueTypeMap.get(clueTypeId), String.valueOf(size), clueText.toString()); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300505); + text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.seriesClueTypeMap.get(seriesName).get(clueTypeId), String.valueOf(size), clueText.toString()); resultResponse.set反馈ID(300505); resultResponse.set反馈文本(text); resultResponse.set后台附加返回("查看线索5"); @@ -534,13 +556,26 @@ public class CheckServiceImpl implements CheckService { //玩家查看下一条线索 if (!StringUtils.isEmpty(lastReq)) { if (!StringUtils.isEmpty(lastReq.getClueList())) { - List clueList = lastReq.getClueList(); + List clueList = lastReq.getClueList(); int index = lastReq.getIndex(); String subjectName = TimingAcquisition.getNameByPersonId(uid, lastReq.getSubjectId()); //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300506); - text = SpeechUtil.speechReplaceNum(text, subjectName, TimingAcquisition.clueTypeMap.get(lastReq.getClueTypeId()), - String.valueOf(clueList.size()), String.valueOf(index + 1), clueList.get(index).getClueTemplate()); + String text = ""; + if (clueList.size() > 1) { + if (index < clueList.size() - 1) { + text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300506); + } else { + text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050607); + } + } else { + text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050606); + } + ClueDto clue = PlayerUtil.getClueById(uid, subjectId, clueList.get(index).getClueId()); + if (!StringUtils.isEmpty(clue)) { + String addText = SpeechUtil.getSuccessClueOtherSpeech(uid, PlayerUtil.getPersonMap(uid).get(subjectId), clue); + text = SpeechUtil.speechReplaceNum(text, subjectName, TimingAcquisition.seriesClueTypeMap.get(seriesName).get(lastReq.getClueTypeId()), + String.valueOf(clueList.size()), String.valueOf(index + 1), addText); + } //保存本轮对话 index = (index + 1) % clueList.size(); operationReq.setSubjectId(lastReq.getSubjectId()); @@ -561,7 +596,7 @@ public class CheckServiceImpl implements CheckService { //没有提供人物名称 if (StringUtils.isEmpty(subjectId)) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050602); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050602); resultResponse.set反馈ID(30050602); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -570,7 +605,7 @@ public class CheckServiceImpl implements CheckService { //提供的人物名称不存在 if (subjectId == Constants.REQ_NON) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050603); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050603); resultResponse.set反馈ID(30050603); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -582,7 +617,7 @@ public class CheckServiceImpl implements CheckService { operationReq.setSubjectId(subjectId); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050604); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050604); resultResponse.set反馈ID(30050604); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -594,7 +629,7 @@ public class CheckServiceImpl implements CheckService { operationReq.setSubjectId(subjectId); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050605); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050605); resultResponse.set反馈ID(30050605); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -604,8 +639,8 @@ public class CheckServiceImpl implements CheckService { //还没有收集到这个人的线索 if (StringUtils.isEmpty(player.getClueMap().get(subjectId))) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050601); - text = SpeechUtil.speechReplaceNum(text, subjectName, TimingAcquisition.clueTypeMap.get(clueTypeId)); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050601); + text = SpeechUtil.speechReplaceNum(text, subjectName, TimingAcquisition.seriesClueTypeMap.get(seriesName).get(clueTypeId)); resultResponse.set反馈ID(30050601); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -614,19 +649,28 @@ public class CheckServiceImpl implements CheckService { //还没有收集到这个人该类型的线索 if (StringUtils.isEmpty(player.getClueMap().get(subjectId).get(clueTypeId))) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050601); - text = SpeechUtil.speechReplaceNum(text, subjectName, TimingAcquisition.clueTypeMap.get(clueTypeId)); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050601); + text = SpeechUtil.speechReplaceNum(text, subjectName, TimingAcquisition.seriesClueTypeMap.get(seriesName).get(clueTypeId)); resultResponse.set反馈ID(30050601); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - List clueList = player.getClueMap().get(subjectId).get(clueTypeId); + List clueList = player.getClueMap().get(subjectId).get(clueTypeId); int index = 0; //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300506); - text = SpeechUtil.speechReplaceNum(text, subjectName, TimingAcquisition.clueTypeMap.get(clueTypeId), - String.valueOf(clueList.size()), String.valueOf(index + 1), clueList.get(index).getClueTemplate()); + String text = ""; + if (clueList.size() > 1) { + text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300506); + } else { + text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 30050606); + } + ClueDto clue = PlayerUtil.getClueById(uid, subjectId, clueList.get(index).getClueId()); + if (!StringUtils.isEmpty(clue)) { + String addText = SpeechUtil.getSuccessClueOtherSpeech(uid, PlayerUtil.getPersonMap(uid).get(subjectId), clue); + text = SpeechUtil.speechReplaceNum(text, subjectName, TimingAcquisition.seriesClueTypeMap.get(seriesName).get(clueTypeId), + String.valueOf(clueList.size()), String.valueOf(index + 1), addText); + } //保存本轮对话 index = (index + 1) % clueList.size(); operationReq.setSubjectId(subjectId); @@ -643,10 +687,17 @@ public class CheckServiceImpl implements CheckService { } //查看某人的模糊操作 if ("3101".equals(methodId)) { + //询问对象为对话人 + if(StringUtils.isEmpty(subjectId)){ + subjectId = player.getPersonId(); + } + //搭档名称 + String partnerName = TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("partnerName").getValue(); //没有提供人物名称 if (StringUtils.isEmpty(subjectId)) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 310101); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 310101); + text = SpeechUtil.replaceHeader(text, partnerName); resultResponse.set反馈ID(310101); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -655,14 +706,15 @@ public class CheckServiceImpl implements CheckService { //提供的人物名称不存在 if (subjectId == Constants.REQ_NON) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 310102); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 310102); + text = SpeechUtil.replaceHeader(text, partnerName); resultResponse.set反馈ID(310102); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - Person current = player.getPersonMap().get(player.getPersonId()); - Person subject = player.getPersonMap().get(subjectId); + Person current = PlayerUtil.getPersonMap(uid).get(player.getPersonId()); + Person subject = PlayerUtil.getPersonMap(uid).get(subjectId); //查找符合条件的线索 List clueList = PlayerUtil.findClues(current, subject, 1); //检查是否符合阈值要求 @@ -673,7 +725,7 @@ public class CheckServiceImpl implements CheckService { //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clueList.get(index)); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); text = SpeechUtil.addHeader(text, current.getName()); @@ -687,7 +739,8 @@ public class CheckServiceImpl implements CheckService { //人物未知,则提供基本线信息 if (!personList.contains(subjectId)) { //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 310103); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 310103); + text = SpeechUtil.replaceHeader(text, partnerName); text = SpeechUtil.speechReplaceNum(text, subject.getName(), subject.getAge().toString(), (subject.getGender() == 1) ? "男" : "女", subject.getIdentityName()); resultResponse.set反馈ID(310103); @@ -696,11 +749,14 @@ public class CheckServiceImpl implements CheckService { return CommonResult.success(resultVarsResponse); } else { String call = (subject.getGender() == 1) ? "他" : "她"; + int trustDegree = player.getPersonInfoMap().get(subjectId).getTrustDegree(); + int deterrenceDegree = player.getPersonInfoMap().get(subjectId).getDeterrenceDegree(); //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 310104); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 310104); + text = SpeechUtil.replaceHeader(text, partnerName); text = SpeechUtil.speechReplaceNum(text, subject.getName(), subject.getAge().toString(), (subject.getGender() == 1) ? "男" : "女", subject.getIdentityName(), call, - subject.getTrustDegree().toString(), subject.getDeterrenceDegree().toString()); + String.valueOf(trustDegree - 50), String.valueOf(deterrenceDegree - 50)); resultResponse.set反馈ID(310104); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -708,10 +764,200 @@ public class CheckServiceImpl implements CheckService { } } //获取对应话术 - String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300001); + String text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 300001); + resultResponse.set反馈ID(300001); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + @Override + public CommonResult secondAnswer(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + String methodId = operationReq.getMethodId(); //方法编号 + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + String unique = uid + gateNo; //用户uid和关卡编号组成唯一标识 + Player player = TimingAcquisition.playerMap.get(uid); + String currentName = TimingAcquisition.getNameByPersonId(uid, TimingAcquisition.playerMap.get(uid).getPersonId()); + //当前玩家上一轮保存的数据 + ReplyDto reply = (ReplyDto) CacheUtil.get(unique); + //走闲聊 + if (StringUtils.isEmpty(reply)) { + operationReq.setMethodId("9001"); + return chatService.operate(operationReq); + } + //当前对话的人物配置信息 + Person current = PlayerUtil.getPersonMap(uid).get(player.getPersonId()); + Integer subjectId = reply.getSubjectId(); + Integer demandTaskId = reply.getDemandTaskId(); + int type = reply.getType(); //响应方式 + //找到对应任务 + DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, demandTaskId); + Person subject = PlayerUtil.getPersonMap(uid).get(subjectId); + //当前对话人的数据 + PersonInfoDto talk = player.getPersonInfoMap().get(player.getPersonId()); + //走闲聊 + if (StringUtils.isEmpty(demandTask)) { + operationReq.setMethodId("9001"); + return chatService.operate(operationReq); + } + String text = ""; + //确定 + if ("001".equals(methodId)) { + //闲聊的二次回复提示玩家他人线索 + if (type == 1) { + ClueDto clue = PlayerUtil.getClueById(uid, subjectId, demandTask.getClueId()); + if (!StringUtils.isEmpty(clue)) { + text = SpeechUtil.getSuccessClueOtherSpeech(uid, current, clue); + text = SpeechUtil.addHeader(text, currentName); + //保存上轮数据 + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + } + } + //发布任务后提示对应文本 + if (type == 2) { + text = SpeechUtil.getSuccessTaskReplySpeech(uid, current, demandTask, reply); + } + //询问任务进度,之后执行操作 + if (type == 3) { + if (demandTask.getClueSwitch() != 1) { + String[] condition1 = demandTask.getCondition1().split("\\|"); + log.info(uid + "执行的任务id:" + demandTaskId + ",条件1:" + demandTask.getCondition1()); + String method = String.valueOf(Integer.parseInt(condition1[0])); + //条件判断 + // 1. 判断是否符合阈值需求 + boolean flag = PlayerUtil.checkThreshold(uid, demandTask, talk); + //不符合阈值需求 + if (!flag) { + log.info(uid + "的任务条件id:" + method); + //获取对应话术 + text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 210204); + text = SpeechUtil.replaceHeader(text, subject.getName()); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(210204); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + Map> taskMap = player.getTaskMap(); + //2.符合阈值需求,判断是否完成前置任务 + if (taskMap.containsKey(subjectId)) { + Map subjectMap = taskMap.get(subjectId); + if (subjectMap.containsKey(demandTask.getDemandTaskId())) { + int num = subjectMap.get(demandTask.getDemandTaskId()); + Integer objectId = demandTask.getObject(); + //符合阈值需求,已达次数上限 + if (num >= demandTask.getEffectiveDegree()) { + log.info(uid + "的任务条件id:" + method); + //获取对应话术 + text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 210202); + text = SpeechUtil.replaceHeader(text, subject.getName()); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(210202); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + Map objectMap = taskMap.get(objectId); + if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { + log.info(uid + "的任务条件id:" + method); + subjectMap.put(demandTask.getDemandTaskId(), num + 1); + PlayerUtil.addThreshold(player.getPersonInfoMap().get(subjectId), demandTask); + //增加声望值 + PlayerUtil.updateReputation(player, demandTask.getReputation()); + //获取对应话术 + text = SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask); + resultResponse.set反馈ID(210205); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //符合阈值需求,前置任务没有完成 + log.info(uid + "的任务条件id:" + method); + //获取对应话术 + text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 210203); + text = SpeechUtil.replaceHeader(text, subject.getName()); + resultResponse.set反馈ID(210203); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + Integer objectId = demandTask.getObject(); + Map objectMap = taskMap.get(objectId); + if (!StringUtils.isEmpty(demandTask.getPostTask()) && !StringUtils.isEmpty(objectMap)) { + if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { + log.info(uid + "的任务条件id:" + method); + subjectMap.put(demandTask.getDemandTaskId(), 1); + addThreshold(player.getPersonInfoMap().get(subjectId), demandTask); + //增加声望值 + PlayerUtil.updateReputation(player, demandTask.getReputation()); + //清除缓存 + CacheGlobal.concurrentMap.remove(unique); + //获取对应话术 + text = SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask); + resultResponse.set反馈ID(210201); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + } + //3.符合阈值需求,前置任务没有完成 + log.info(uid + "的任务条件id:" + method); + //获取对应话术 + text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 210203); + text = SpeechUtil.replaceHeader(text, subject.getName()); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(210203); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + } + } + //4.自身线索提示对应文本 + if (type == 4) { + text = SpeechUtil.getTipReplySpeech(uid, demandTask, 0, 2, reply); + } + } + //否定 + if ("002".equals(methodId)) { + text = SpeechUtil.getCheckSpeech(uid, Constants.SPEECH_ASIDE, 3007); + } + //清除缓存 + CacheGlobal.concurrentMap.remove(unique); resultResponse.set反馈ID(300001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } + + @Override + public CommonResult checkRanking(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); + int num = 10; + StringBuilder text = new StringBuilder(); + PriorityBlockingQueue queueTemp = new PriorityBlockingQueue<>(); + PriorityBlockingQueue gateNoReputationQueue = TimingAcquisition.gateNoReputationQueueMap.get(gateNo); + queueTemp.addAll(gateNoReputationQueue); + if (num > queueTemp.size()) { + num = queueTemp.size(); + } + for (int i = 0; i < num; i++) { + text.append("第").append(i+1).append("名").append("是").append(queueTemp.remove().getUid()).append(","); + } + if (text.length() > 0) { + text.deleteCharAt(text.length() - 1); + } + resultResponse.set反馈ID(300001); + resultResponse.set反馈文本(text.toString()); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } } diff --git a/src/main/java/com/qiwu/inference/service/common/CommonService.java b/src/main/java/com/qiwu/inference/service/common/CommonService.java index eda8a57..80bd463 100644 --- a/src/main/java/com/qiwu/inference/service/common/CommonService.java +++ b/src/main/java/com/qiwu/inference/service/common/CommonService.java @@ -1,12 +1,16 @@ package com.qiwu.inference.service.common; import com.qiwu.inference.common.api.CommonResult; +import com.qiwu.inference.dto.OperateEnum; import com.qiwu.inference.dto.request.OperationRequest; import com.qiwu.inference.dto.response.ResultVarsResponse; import com.qiwu.inference.service.player.PlayerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Arrays; +import java.util.List; + @Service public class CommonService { @Autowired @@ -14,92 +18,26 @@ public class CommonService { public CommonResult operate(OperationRequest request) { - String methodId = request.getMethodId();; - switch (methodId){ - case "1001": - case "1002": + String methodId = request.getMethodId(); + String operateName = OperateEnum.getOperateName(methodId); + switch (operateName){ + case "askDisposition": return playerService.askDisposition(request); - case "1003": - case "1004": - case "1005": - case "1006": + case "askRelation": return playerService.askRelation(request); - case "1007": - case "1008": - case "1009": - case "1010": - case "1011": + case "askBehaviour": return playerService.askBehaviour(request); - case "1012": - case "1013": - case "1014": - case "1015": - case "1016": - case "1017": - case "1018": - case "1019": - case "1020": - case "1021": - case "1022": + case "askTask": return playerService.askTask(request); - case "1023": - case "1024": + case "askIdentity": return playerService.askIdentity(request); - case "1025": - case "1026": + case "askLocation": return playerService.askLocation(request); - case "1027": - case "1028": - case "1029": + case "askPrompt": return playerService.askPrompt(request); - case "2001": - case "2003": - case "2002": - case "2004": - case "2005": - case "2006": - case "2007": - case "2008": - case "2009": - case "2010": - case "2011": - case "2012": - case "2013": - case "2014": - case "2015": - case "2016": - case "2017": - case "2018": - case "2019": - case "2020": - case "2021": - case "2022": - case "2023": - case "2024": - case "2025": - case "2026": - case "2027": - case "2028": - case "2029": - case "2030": - case "2031": - case "2032": - case "2033": - case "2034": - case "2035": - case "2036": - case "2037": - case "2038": - case "2039": - case "2040": - case "2041": - case "2101": - case "2102": - case "2104": - case "2106": - case "2107": - case "2108": - case "2109": + case "askFinalClue": + return playerService.askFinalClue(request); + case "performTask": return playerService.performTask(request); } return null; diff --git a/src/main/java/com/qiwu/inference/service/login/LoginService.java b/src/main/java/com/qiwu/inference/service/login/LoginService.java index f7173dd..8bdfff2 100644 --- a/src/main/java/com/qiwu/inference/service/login/LoginService.java +++ b/src/main/java/com/qiwu/inference/service/login/LoginService.java @@ -1,12 +1,17 @@ package com.qiwu.inference.service.login; import com.qiwu.inference.common.api.CommonResult; +import com.qiwu.inference.dto.request.CommonRequest; import com.qiwu.inference.dto.request.OperationRequest; import com.qiwu.inference.dto.response.CommonResponse; import com.qiwu.inference.dto.response.ResultVarsResponse; public interface LoginService { - CommonResult login(String uid); + CommonResult login(CommonRequest commonRequest); - CommonResult startGame(OperationRequest operationReq); + CommonResult startGame(CommonRequest commonRequest); + + CommonResult loadPlayerData(CommonRequest commonRequest); + + CommonResult reloadPlayerData(CommonRequest commonRequest); } diff --git a/src/main/java/com/qiwu/inference/service/login/impl/LoginServiceImpl.java b/src/main/java/com/qiwu/inference/service/login/impl/LoginServiceImpl.java index c7b4f7c..cddabc8 100644 --- a/src/main/java/com/qiwu/inference/service/login/impl/LoginServiceImpl.java +++ b/src/main/java/com/qiwu/inference/service/login/impl/LoginServiceImpl.java @@ -1,18 +1,19 @@ package com.qiwu.inference.service.login.impl; -import cn.hutool.core.lang.UUID; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; import com.qiwu.inference.common.Constants; import com.qiwu.inference.common.TimingAcquisition; import com.qiwu.inference.common.api.CommonResult; import com.qiwu.inference.common.utils.*; -import com.qiwu.inference.dto.LocationInfoDto; -import com.qiwu.inference.dto.Person; -import com.qiwu.inference.dto.Player; -import com.qiwu.inference.dto.request.OperationRequest; +import com.qiwu.inference.dto.*; +import com.qiwu.inference.dto.request.CommonRequest; import com.qiwu.inference.dto.response.*; -import com.qiwu.inference.pojo.EndGoal; import com.qiwu.inference.service.login.LoginService; +import com.qiwu.inference.service.remote.impl.RemoteGardenImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -22,57 +23,100 @@ import java.util.concurrent.ConcurrentHashMap; @Service public class LoginServiceImpl implements LoginService { + Logger log = LoggerFactory.getLogger(LoginServiceImpl.class); + + @Value("${offlineTime}") + private String offlineTime; //从yml配置文件中取出对话过期时间 @Value("${expireTime}") private String expireTime; @Value("${userFilePath}") private String userFilePath; + @Value("${dataFilePath}") + private String dataFilePath; + + @Autowired + private RedisUtil redisUtil; + @Autowired + private RemoteGardenImpl remoteGardenService; @Override - public CommonResult login(String uid) { + public CommonResult login(CommonRequest commonRequest) { ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); //存放玩家数据 - Map sidGateNoMap = new ConcurrentHashMap<>(); + Map uidGateNoMap = new ConcurrentHashMap<>(); String nowTime = DateUtil.getCurrentTime(); Player player = new Player(); - player.setSid(uid); + String uid = commonRequest.getUid(); + String series = commonRequest.getVars().get系列名称(); + String gateName = commonRequest.getVars().get关卡名称(); + player.setUid(uid); player.setStatus(Constants.ONLINE); player.setOnlineTime(nowTime); + player.setSeries(series); //初始化推理游戏人物 - List keys = new ArrayList<>(TimingAcquisition.gateInfoMap.keySet()); - int random = RandomUtil.randomInt(keys.size()); - player.setGateNo(keys.get(random)); - List personsCopy = TimingAcquisition.gateInfoMap.get(keys.get(random)); + List gateNoList = TimingAcquisition.seriesGateNosMap.get(series); +// int random = RandomUtil.randomInt(gateNoList.size()); +// player.setGateNo(gateNoList.get(random)); + //存放玩家uid与关卡编号 +// TimingAcquisition.uidGateNoMap.put(uid, player.getGateNo()); + String gateNo; + if (StringUtils.isEmpty(gateName)) { + int random = RandomUtil.randomInt(gateNoList.size()); + gateNo = gateNoList.get(random); + } else { + gateNo = TimingAcquisition.gateNameToNoMap.get(gateName); + } + player.setGateNo(gateNo); + List personsCopy = TimingAcquisition.gateInfoMap.get(gateNo); //深拷贝list List personCopyList = PlayerUtil.deepCopyList(personsCopy); - Map> taskMapCopy = new HashMap<>(); - Map personMapCopy = new HashMap<>(); - Map name2IdMapCopy = new HashMap<>(); + //过滤掉系列中已加入的伙伴 +// personCopyList = PlayerUtil.filterPerson(uid, personCopyList); + Map> taskMap = new HashMap<>(); + Map personInfoMap = new HashMap<>(); + Map name2IdMap = new HashMap<>(); + Map id2NameMap = new HashMap<>(); for (Person person : personCopyList) { - taskMapCopy.put(person.getId(), new HashMap<>()); - personMapCopy.put(person.getId(), person); - name2IdMapCopy.put(person.getName(), person.getId()); + taskMap.put(person.getId(), new HashMap<>()); + name2IdMap.put(person.getName(), person.getId()); + id2NameMap.put(person.getId(), person.getName()); + //NPC相关数据 + PersonInfoDto personInfo = new PersonInfoDto(); + Map> clueSourceMap = new ConcurrentHashMap<>(); + Map demandTaskSwitchMap = new ConcurrentHashMap<>(); + personInfo.setId(person.getId()); +// List clueList = person.getClues(); +// for (ClueDto clue : clueList) { +// clueSourceMap.put(clue.getClueId(), new ArrayList<>()); +// } + List demandTaskList = person.getDemandTasks(); + for (DemandTaskDto demandTask : demandTaskList) { + demandTaskSwitchMap.put(demandTask.getDemandTaskId(), demandTask.getClueSwitch()); + } + personInfo.setClueSourceMap(clueSourceMap); + personInfo.setDemandTaskSwitchMap(demandTaskSwitchMap); + personInfoMap.put(person.getId(), personInfo); } - player.setTaskMap(taskMapCopy); - player.setPersonMap(personMapCopy); - player.setName2IdMap(name2IdMapCopy); + player.setTaskMap(taskMap); + player.setPersonInfoMap(personInfoMap); + player.setName2IdMap(name2IdMap); + player.setId2NameMap(id2NameMap); //给玩家分配场所和对话人物 Map> locationPersonMap = new HashMap<>(); - Map personMap = player.getPersonMap(); - for (Map.Entry entry : personMap.entrySet()) { - Person person = entry.getValue(); + for (Person person : personCopyList) { if (!StringUtils.isEmpty(person.getLocation())) { //没有当前场所 if (StringUtils.isEmpty(locationPersonMap.get(person.getLocation()))) { List personList = new ArrayList<>(); - personList.add(entry.getKey()); + personList.add(person.getId()); locationPersonMap.put(person.getLocation(), personList); } //有当前场所,但是没有这个人 List persons = locationPersonMap.get(person.getLocation()); - if (!persons.contains(entry.getKey())) { - persons.add(entry.getKey()); + if (!persons.contains(person.getId())) { + persons.add(person.getId()); } } } @@ -85,16 +129,48 @@ public class LoginServiceImpl implements LoginService { int num = RandomUtil.randomInt(personList.size()); player.setPersonId(personList.get(num)); //生成场所表,包含场所隐藏状态和必现场所 - Map locationMap = PlayerUtil.makeLocationMap(locationPersonMap); + Map locationMap = PlayerUtil.makeLocationMap(uid, locationPersonMap, series); player.setLocationMap(locationMap); //记录玩家第一次的任务个数更新时间 player.setNumUpdateTime(nowTime); + //初始货币值 +// player.setCurrency((double)0); + //初始时间值 + String initTime = TimingAcquisition.seriesSystemConfigMap.get(player.getSeries()).get("init_time").getValue(); + player.setInitTime(Integer.parseInt(initTime)); TimingAcquisition.playerMap.put(uid, player); String playerStr = JSON.toJSONString(player); + //创建玩家数据路径 + String path = MD5Util.changeToPath(uid, series); //持久化玩家数据 - PersistenceUtil.saveDataToFile(userFilePath, uid, playerStr); - sidGateNoMap.put(uid, player.getGateNo()); - TimingAcquisition.uidGateNoMap.putAll(sidGateNoMap); + PersistenceUtil.saveDataToFile(path, player.getGateNo(), playerStr); + uidGateNoMap.put(uid, player.getGateNo()); + TimingAcquisition.uidGateNoMap.putAll(uidGateNoMap); + //保存所有玩家的uid + TimingAcquisition.uidList.add(uid); + + //该玩家以唯一标识加入全局缓存,用于玩家离线判断 + String uniqueUid = uid + "%#%online%#%"; + CacheUtil.put(uniqueUid, "", Long.parseLong(offlineTime)); + +// String seriesPlayerStr = JSON.toJSONString(TimingAcquisition.seriesPlayerMap); + //持久化系列的玩家数据 +// PersistenceUtil.saveDataToFile(dataFilePath, "seriesPlayer", seriesPlayerStr); + //-----------------初始化系列中的玩家汇总数据------------ + PlayerUtil.initSeriesPlayer(uid, series); + //--------------持久化该玩家系列汇总的数据--------------- + String dataPath = MD5Util.changeToDataPath(uid, series); + PersistenceUtil.saveDataToFile(dataPath, uid, JSON.toJSONString(TimingAcquisition.seriesPlayerMap.get(series).get(uid))); + //-----------存入redis缓存中------------- + redisUtil.setStr(series + "::"+ uid, JSON.toJSONString(TimingAcquisition.seriesPlayerMap.get(series).get(uid))); + //更新系列和关卡中玩家的排名 + ReputationDto reputation = new ReputationDto(); + reputation.setUid(player.getUid()); + reputation.setReputation(player.getReputation()); + //更新关卡排行榜 + PlayerUtil.updateGateNoReputation(player, reputation); + //更新系列排行榜 + PlayerUtil.updateSeriesReputation(uid, series, reputation); resultResponse.set反馈ID(100000); resultResponse.set反馈文本("登录成功"); @@ -103,37 +179,54 @@ public class LoginServiceImpl implements LoginService { } @Override - public CommonResult startGame(OperationRequest operationReq) { + public CommonResult startGame(CommonRequest commonRequest) { ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); - String uid = operationReq.getUid(); - String text = ""; + String uid = commonRequest.getUid(); Player player = TimingAcquisition.playerMap.get(uid); + String seriesName = player.getSeries(); //数据重置 if (player.getFinished() == 1) { + log.info(uid + "通关过,开始重置数据"); //初始化推理游戏人物 - List keys = new ArrayList<>(TimingAcquisition.gateInfoMap.keySet()); - int random = RandomUtil.randomInt(keys.size()); - player.setGateNo(keys.get(random)); - List personsCopy = TimingAcquisition.gateInfoMap.get(keys.get(random)); + List personsCopy = TimingAcquisition.gateInfoMap.get(player.getGateNo()); //深拷贝list List personCopyList = PlayerUtil.deepCopyList(personsCopy); - Map> taskMapCopy = new HashMap<>(); - Map personMapCopy = new HashMap<>(); - Map name2IdMapCopy = new HashMap<>(); + //过滤掉系列中已加入的伙伴 +// personCopyList = PlayerUtil.filterPerson(uid, personCopyList); + Map> taskMap = new HashMap<>(); + Map personInfoMap = new HashMap<>(); + Map name2IdMap = new HashMap<>(); + Map id2NameMap = new HashMap<>(); for (Person person : personCopyList) { - taskMapCopy.put(person.getId(), new HashMap<>()); - personMapCopy.put(person.getId(), person); - name2IdMapCopy.put(person.getName(), person.getId()); + taskMap.put(person.getId(), new HashMap<>()); + name2IdMap.put(person.getName(), person.getId()); + id2NameMap.put(person.getId(), person.getName()); + //NPC相关数据 + PersonInfoDto personInfo = new PersonInfoDto(); + Map> clueSourceMap = new ConcurrentHashMap<>(); + Map demandTaskSwitchMap = new ConcurrentHashMap<>(); + personInfo.setId(person.getId()); +// List clueList = person.getClues(); +// for (ClueDto clue : clueList) { +// clueSourceMap.put(clue.getClueId(), new ArrayList<>()); +// } + List demandTaskList = person.getDemandTasks(); + for (DemandTaskDto demandTask : demandTaskList) { + demandTaskSwitchMap.put(demandTask.getDemandTaskId(), demandTask.getClueSwitch()); + } + personInfo.setClueSourceMap(clueSourceMap); + personInfo.setDemandTaskSwitchMap(demandTaskSwitchMap); + personInfoMap.put(person.getId(), personInfo); } - player.setTaskMap(taskMapCopy); - player.setPersonMap(personMapCopy); - player.setName2IdMap(name2IdMapCopy); - player.setCurrency(3000.0); + player.setTaskMap(taskMap); + player.setPersonInfoMap(personInfoMap); + player.setName2IdMap(name2IdMap); + player.setId2NameMap(id2NameMap); //给玩家分配场所和对话人物 Map> locationPersonMap = new HashMap<>(); - Map personMap = player.getPersonMap(); + Map personMap = PlayerUtil.getPersonMap(uid); for (Map.Entry entry : personMap.entrySet()) { Person person = entry.getValue(); if (!StringUtils.isEmpty(person.getLocation())) { @@ -158,31 +251,137 @@ public class LoginServiceImpl implements LoginService { List personList = locationPersonMap.get(locationId); int num = RandomUtil.randomInt(personList.size()); player.setPersonId(personList.get(num)); + //初始货币值 +// player.setCurrency((double)0); + //初始时间值 + String initTime = TimingAcquisition.seriesSystemConfigMap.get(player.getSeries()).get("init_time").getValue(); + player.setInitTime(Integer.parseInt(initTime)); //生成场所表,包含场所隐藏状态和必现场所 - Map locationMap = PlayerUtil.makeLocationMap(locationPersonMap); + Map locationMap = PlayerUtil.makeLocationMap(uid, locationPersonMap, player.getSeries()); player.setLocationMap(locationMap); + player.setPoint(0); + player.setClueMap(new HashMap<>()); + player.setFinishedTaskNum(0); + player.setTipFlag(false); + player.setOperateTextNum(1); + player.setAskAndNumMap(new HashMap<>()); + player.setFinished(0); + + String playerStr = JSON.toJSONString(player); + //创建玩家数据路径 + String path = MD5Util.changeToPath(uid, player.getSeries()); + //持久化玩家数据 + PersistenceUtil.saveDataToFile(path, player.getGateNo(), playerStr); + log.info(uid + "的数据重置成功"); + } - //关卡编号 - String gateNo = player.getGateNo(); - int size = TimingAcquisition.barrierTaskKeyMap.get(gateNo).size(); - Integer demandTaskId = TimingAcquisition.barrierTaskKeyMap.get(gateNo).get(size - 1).getDemandTaskId(); - Map endGoalMap = TimingAcquisition.endGoalMap; - for (Map.Entry entry : endGoalMap.entrySet()) { - EndGoal endGoal = entry.getValue(); - List associatedTaskIds = Arrays.asList(endGoal.getAssociatedTaskId().split("\\|")); - if (associatedTaskIds.contains(demandTaskId.toString())) { - text = "【旁白@正常】" + endGoal.getName(); - text += "【旁白@正常】" + endGoal.getDescription(); - text += SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 103001); - text += SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 103002); - String location = TimingAcquisition.locationMap.get(TimingAcquisition.playerMap.get(uid).getLocation()).getName(); - String name = PlayerUtil.getNameByPersonId(uid, TimingAcquisition.playerMap.get(uid).getPersonId()); - text = SpeechUtil.speechReplaceNum(text, location, name); - break; + String initMoney = TimingAcquisition.seriesSystemConfigMap.get(seriesName).get("init_money").getValue(); + if (StringUtils.isEmpty(initMoney)) { + //远程获取货币数量进行同步 + CallResponse callMoney = remoteGardenService.getMoney(uid); + initMoney = callMoney.getData(); + //关卡现有货币数量 + int money = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getMoney(); + if (money != Integer.parseInt(initMoney)) { + TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).setMoney(Integer.parseInt(initMoney)); } + //获取物品进行同步 + CallResponse callItems = remoteGardenService.getItems(uid); + List itemList = JSON.parseObject(callItems.getData(), new TypeReference>(){}); + //同步物品信息 + ConfigDataUtil.synItems(uid, itemList); } + //关卡编号 + String gateNo = player.getGateNo(); + //获取开场白话术 + String text = SpeechUtil.getPrologueSpeech(uid, gateNo); resultResponse.set反馈ID(100009); resultResponse.set反馈文本(text); + resultResponse.set当前对话角色身份(PlayerUtil.getPerson(uid, player.getPersonId()).getIdentityName()); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + @Override + public CommonResult loadPlayerData(CommonRequest commonRequest) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = commonRequest.getUid(); + String seriesName = commonRequest.getVars().get系列名称(); + String gateName = commonRequest.getVars().get关卡名称(); + String gateNo = TimingAcquisition.gateNameToNoMap.get(gateName); + //创建玩家数据路径 + String path = MD5Util.changeToPath(uid, seriesName); + String playStr = PersistenceUtil.loadPlayerData(path, gateNo); + //第一次进入该关卡 + if (StringUtils.isEmpty(playStr)) { + return login(commonRequest); + } + Player player = JSON.parseObject(playStr, new TypeReference(){}); + player.setOnlineTime(DateUtil.getCurrentTime()); + player.setStatus(Constants.ONLINE); + //玩家数据加入缓存 + TimingAcquisition.playerMap.put(uid, player); + //该玩家以唯一标识加入全局缓存,用于玩家离线判断 + String uniqueUid = uid + "%#%online%#%"; + CacheUtil.put(uniqueUid, "", Long.parseLong(offlineTime)); + + //----------------加载该玩家的系列汇总数据----------------- + PersistenceUtil.loadSeriesPlayer(uid, seriesName); + + //-------------------存入redis缓存中------------------ + redisUtil.setStr(seriesName + "::"+ uid, JSON.toJSONString(TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid))); + + resultResponse.set反馈ID(100010); + resultResponse.set反馈文本(uid + "的" + gateName + "数据加载完成"); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + /** + * 换关卡后,重新加载新关卡的数据 + * @param commonRequest + * @return + */ + @Override + public CommonResult reloadPlayerData(CommonRequest commonRequest) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = commonRequest.getUid(); + String gateName = commonRequest.getVars().get关卡名称(); + String gateNo = TimingAcquisition.gateNameToNoMap.get(gateName); + + Player player = TimingAcquisition.playerMap.get(uid); + //更新玩家为离线状态 + player.setStatus(Constants.OFFLINE); + //修改下线时间 + player.setOfflineTime(DateUtil.getCurrentTime()); + //创建玩家数据路径 + String path = MD5Util.changeToPath(uid, player.getSeries()); + //--------------持久化该园丁信息--------------- + PersistenceUtil.saveDataToFile(path, player.getGateNo(), JSON.toJSONString(player)); + //-----------------重新加载该玩家的关卡数据到缓存----------------- + String playStr = PersistenceUtil.loadPlayerData(path, gateNo); + //第一次进入该关卡 + if (StringUtils.isEmpty(playStr)) { + return login(commonRequest); + } + Player playerNew = JSON.parseObject(playStr, new TypeReference(){}); + player.setOnlineTime(DateUtil.getCurrentTime()); + player.setStatus(Constants.ONLINE); + //玩家数据加入缓存 + TimingAcquisition.playerMap.put(uid, playerNew); + //该玩家以唯一标识加入全局缓存,用于玩家离线判断 + String uniqueUid = uid + "%#%online%#%"; + CacheUtil.put(uniqueUid, "", Long.parseLong(offlineTime)); + + //-------------------存入redis缓存中------------------ + redisUtil.setStr(player.getSeries() + "::"+ uid, JSON.toJSONString(TimingAcquisition.seriesPlayerMap.get(player.getSeries()).get(uid))); + + resultResponse.set反馈ID(100010); + resultResponse.set反馈文本(uid + "的" + gateName + "关卡数据加载完成"); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } diff --git a/src/main/java/com/qiwu/inference/service/partner/PartnerService.java b/src/main/java/com/qiwu/inference/service/partner/PartnerService.java new file mode 100644 index 0000000..43bb340 --- /dev/null +++ b/src/main/java/com/qiwu/inference/service/partner/PartnerService.java @@ -0,0 +1,9 @@ +package com.qiwu.inference.service.partner; + +import com.qiwu.inference.common.api.CommonResult; +import com.qiwu.inference.dto.request.OperationRequest; +import com.qiwu.inference.dto.response.ResultVarsResponse; + +public interface PartnerService { + CommonResult operate(OperationRequest operationReq); +} diff --git a/src/main/java/com/qiwu/inference/service/partner/impl/PartnerServiceImpl.java b/src/main/java/com/qiwu/inference/service/partner/impl/PartnerServiceImpl.java new file mode 100644 index 0000000..db0acd5 --- /dev/null +++ b/src/main/java/com/qiwu/inference/service/partner/impl/PartnerServiceImpl.java @@ -0,0 +1,842 @@ +package com.qiwu.inference.service.partner.impl; + +import com.qiwu.inference.common.Constants; +import com.qiwu.inference.common.TimingAcquisition; +import com.qiwu.inference.common.api.CommonResult; +import com.qiwu.inference.common.cache.CacheGlobal; +import com.qiwu.inference.common.utils.CacheUtil; +import com.qiwu.inference.common.utils.ConfigDataUtil; +import com.qiwu.inference.common.utils.PlayerUtil; +import com.qiwu.inference.common.utils.SpeechUtil; +import com.qiwu.inference.dto.*; +import com.qiwu.inference.dto.request.OperationRequest; +import com.qiwu.inference.dto.response.ResultResponse; +import com.qiwu.inference.dto.response.ResultVarsResponse; +import com.qiwu.inference.pojo.BackpackNum; +import com.qiwu.inference.pojo.PartnerItem; +import com.qiwu.inference.service.chat.impl.ChatServiceImpl; +import com.qiwu.inference.service.partner.PartnerService; +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 javax.annotation.PostConstruct; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +@Service +public class PartnerServiceImpl implements PartnerService { + Logger log = LoggerFactory.getLogger(PartnerServiceImpl.class); + + @Autowired + private ChatServiceImpl chatService; + + Map>> operateMap = new HashMap<>(); + + @PostConstruct + private void dispatcher() { + operateMap.put("7001", this::useAbility); + operateMap.put("7002", this::useItem); + operateMap.put("7003", this::disbandPartnerCheck); + operateMap.put("700303", this::disbandPartner); + operateMap.put("7004", this::disbandItemCheck); + operateMap.put("700403", this::disbandItem); + operateMap.put("7005", this::checkPartnerItem); + operateMap.put("7006", this::checkTeam); + operateMap.put("7007", this::checkBackpack); + operateMap.put("700801", this::agreeGain); + operateMap.put("700802", this::agreeGainRefuse); + } + + @Override + public CommonResult operate(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String methodId = operationReq.getMethodId(); + Function> result = operateMap.get(methodId); + if (!StringUtils.isEmpty(result)) { + return result.apply(operationReq); + } + resultResponse.set反馈ID(7000); + resultResponse.set反馈文本("没有指定操作编号"); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + /** + * 7001:伙伴使用能力 + * @param operationReq + * @return + */ + public CommonResult useAbility(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + Integer partnerId = operationReq.getPartnerItemId(); //获取伙伴id + if (StringUtils.isEmpty(partnerId)) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700103); + resultResponse.set反馈ID(700103); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + Player player = TimingAcquisition.playerMap.get(uid); + Integer subjectId = player.getPersonId(); + //当前对话的人物配置信息 + Person currentNPC = PlayerUtil.getPerson(uid, subjectId); + //当前对话人 + PersonInfoDto talk = player.getPersonInfoMap().get(subjectId); + //获取该伙伴的信息 + ItemNumDto partnerInfo = PlayerUtil.getPartnerNumById(uid, partnerId); + //玩家还没有该伙伴 + if (StringUtils.isEmpty(partnerInfo)) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700106); + resultResponse.set反馈ID(700106); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + //伙伴配置数据 + PartnerItem partner = TimingAcquisition.seriesPartnerItemMap.get(seriesName).get(partnerId); + //同一伙伴已对目标NPC使用过一次能力 + if (player.getPersonInfoMap().get(subjectId).getPartnerItemIdList().contains(partnerId)) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700105); + text = SpeechUtil.speechReplaceNum(text, partner.getName()); + resultResponse.set反馈ID(700105); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //能力对应性格 + String dispositions = partner.getDispositions(); + if (!StringUtils.isEmpty(dispositions)) { + List dispositionList = Arrays.stream(dispositions.split("\\|")).map(Integer::new).collect(Collectors.toList()); + //不存在对应的性格 + if (!Collections.disjoint(dispositionList, currentNPC.getDispositions())) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700102); + text = SpeechUtil.speechReplaceNum(text, partner.getName()); + resultResponse.set反馈ID(700102); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + } + //能力对应身份 + String identity = partner.getIdentity(); + if (!StringUtils.isEmpty(identity)) { + List identityList = Arrays.stream(identity.split("\\|")).map(Integer::new).collect(Collectors.toList()); + //不存在对应的身份 + if (!identityList.contains(currentNPC.getIdentityId())) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700102); + text = SpeechUtil.speechReplaceNum(text, partner.getName()); + resultResponse.set反馈ID(700102); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + } + //对NPC使用技能 + //配置了信任值增减 + if (!StringUtils.isEmpty(partner.getTrust())) { + talk.setTrustDegree(talk.getTrustDegree() + partner.getTrust()); + } + //配置了威慑度增减 + if (!StringUtils.isEmpty(partner.getDeterrence())) { + talk.setDeterrenceDegree(talk.getDeterrenceDegree() + partner.getDeterrence()); + } + //配置了任务ID + if (!StringUtils.isEmpty(partner.getTaskId())) { + DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, partner.getTaskId()); + if (!StringUtils.isEmpty(demandTask)) { + //NPC有这个任务则完成 + PlayerUtil.taskFinished(uid, subjectId, partner.getTaskId()); + } + } + //获取对应话术 + String text = ""; + //出手次数减1 + int abilityTimes = partnerInfo.getTimes(); + //还有剩余次数 + if (abilityTimes > 0) { + text = partner.getAnswer(); + abilityTimes--; + if (abilityTimes == 0) { + abilityTimes = -1; + text = partner.getLastAnswer(); + } + partnerInfo.setTimes(abilityTimes); + } + log.info(uid + "伙伴" + partner.getName() + "剩余能力次数:" + abilityTimes); + //次数已用完 + if (abilityTimes == -1) { + //删除该伙伴 + PlayerUtil.removePartnerItemById(uid, partnerId); + //获取对应话术 + text += SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700107); + text = SpeechUtil.speechReplaceNum(text, partner.getName()); + resultResponse.set反馈ID(700107); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //记录该伙伴已经对当前NPC使用功能 + player.getPersonInfoMap().get(subjectId).getPartnerItemIdList().add(partnerId); + resultResponse.set反馈ID(700101); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + /** + * 7002:使用物品 + */ + public CommonResult useItem(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + Integer itemId = operationReq.getPartnerItemId(); //获取物品id + //未提供物品名称 + if (StringUtils.isEmpty(itemId)) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700203); + resultResponse.set反馈ID(700203); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + Player player = TimingAcquisition.playerMap.get(uid); + Integer subjectId = player.getPersonId(); + //当前对话的人物配置信息 + Person currentNPC = PlayerUtil.getPerson(uid, subjectId); + //当前对话人 + PersonInfoDto talk = player.getPersonInfoMap().get(subjectId); + //获取该物品的信息 + ItemNumDto itemInfo = PlayerUtil.getItemNumById(uid, itemId); + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + //物品配置数据 + PartnerItem item = TimingAcquisition.seriesPartnerItemMap.get(seriesName).get(itemId); + //玩家还没有该物品 + if (StringUtils.isEmpty(itemInfo)) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700206); + text = SpeechUtil.speechReplaceNum(text, item.getName()); + resultResponse.set反馈ID(700206); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //同一物品已对目标NPC使用过一次能力 + if (player.getPersonInfoMap().get(subjectId).getPartnerItemIdList().contains(itemId)) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700205); + text = SpeechUtil.speechReplaceNum(text, item.getName()); + resultResponse.set反馈ID(700205); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //能力对应性格 + String dispositions = item.getDispositions(); + if (!StringUtils.isEmpty(dispositions)) { + List dispositionList = Arrays.stream(dispositions.split("\\|")).map(Integer::new).collect(Collectors.toList()); + //不存在对应的性格 + if (!Collections.disjoint(dispositionList, currentNPC.getDispositions())) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700202); + text = SpeechUtil.speechReplaceNum(text, item.getName()); + resultResponse.set反馈ID(700202); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + } + //能力对应身份 + String identity = item.getIdentity(); + if (!StringUtils.isEmpty(identity)) { + List identityList = Arrays.stream(identity.split("\\|")).map(Integer::new).collect(Collectors.toList()); + //不存在对应的身份 + if (!identityList.contains(currentNPC.getIdentityId())) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700202); + text = SpeechUtil.speechReplaceNum(text, item.getName()); + resultResponse.set反馈ID(700202); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + } + //对NPC使用技能 + //配置了信任值增减 + if (!StringUtils.isEmpty(item.getTrust())) { + talk.setTrustDegree(talk.getTrustDegree() + item.getTrust()); + } + //配置了威慑度增减 + if (!StringUtils.isEmpty(item.getDeterrence())) { + talk.setDeterrenceDegree(talk.getDeterrenceDegree() + item.getDeterrence()); + } + //配置了任务ID + if (!StringUtils.isEmpty(item.getTaskId())) { + DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, item.getTaskId()); + if (!StringUtils.isEmpty(demandTask)) { + //NPC有这个任务则完成 + PlayerUtil.taskFinished(uid, subjectId, item.getTaskId()); + } + } + //能力使用文本 + String text = ""; + int abilityTimes = itemInfo.getTimes(); + //还有剩余次数 + if (abilityTimes > 0) { + text = item.getAnswer(); + abilityTimes--; + if (abilityTimes == 0) { + abilityTimes = -1; + text = item.getLastAnswer(); + } + itemInfo.setTimes(abilityTimes); + } + log.info(uid + "物品:" + item.getName() + "剩余次数:" + abilityTimes); + //次数已用完 + if (abilityTimes == -1) { + //删除该物品 + PlayerUtil.removePartnerItemById(uid, itemId); + //获取对应话术 + text += SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700207); + text = SpeechUtil.speechReplaceNum(text, item.getName()); + resultResponse.set反馈ID(700207); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //记录该物品已经对当前NPC使用功能 + player.getPersonInfoMap().get(subjectId).getPartnerItemIdList().add(itemId); + resultResponse.set反馈ID(700201); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + /** + * 7003:遣散伙伴校验 + * @param operationReq + * @return + */ + public CommonResult disbandPartnerCheck(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + Integer partnerId = operationReq.getPartnerItemId(); //获取伙伴id + if (StringUtils.isEmpty(partnerId)) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700305); + resultResponse.set反馈ID(700305); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + if (StringUtils.isEmpty(TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid). + getPartnerItemMap().get(Constants.ITEM_PARTNER))) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700302); + resultResponse.set反馈ID(700302); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + Map partnerInfoMap = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid). + getPartnerItemMap().get(Constants.ITEM_PARTNER).getItemInfoMap(); + List partnerIdList = new ArrayList<>(partnerInfoMap.keySet()); + //没有该伙伴 + if (!partnerIdList.contains(partnerId)) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700302); + resultResponse.set反馈ID(700302); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //伙伴物品配置数据 + PartnerItem partnerItem = TimingAcquisition.seriesPartnerItemMap.get(seriesName).get(partnerId); + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700301); + text = SpeechUtil.speechReplaceNum(text, partnerItem.getName()); + //存在该伙伴,需二次确认删除 + resultResponse.set反馈ID(700301); + resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("遣散伙伴回复1"); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + /** + * 700303:确认遣散伙伴 + * @param operationReq + * @return + */ + public CommonResult disbandPartner(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + Integer partnerId = operationReq.getPartnerItemId(); //获取伙伴id + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + Map partnerInfoMap = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid). + getPartnerItemMap().get(Constants.ITEM_PARTNER).getItemInfoMap(); + //伙伴物品配置数据 + PartnerItem partnerItem = TimingAcquisition.seriesPartnerItemMap.get(seriesName).get(partnerId); + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700303); + text = SpeechUtil.speechReplaceNum(text, partnerItem.getName()); + //存在该伙伴,删除 + partnerInfoMap.remove(partnerId); + resultResponse.set反馈ID(700303); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + /** + * 7004:丢弃物品校验 + * @param operationReq + * @return + */ + public CommonResult disbandItemCheck(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + Integer itemId = operationReq.getPartnerItemId(); //获取物品id + if (StringUtils.isEmpty(itemId)) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700405); + resultResponse.set反馈ID(700405); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + if (StringUtils.isEmpty(TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid). + getPartnerItemMap().get(Constants.ITEM_PROPS))) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700402); + resultResponse.set反馈ID(700402); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + Map itemInfoMap = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid). + getPartnerItemMap().get(Constants.ITEM_PROPS).getItemInfoMap(); + List itemIdList = new ArrayList<>(itemInfoMap.keySet()); + //没有该物品 + if (!itemIdList.contains(itemId)) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700402); + resultResponse.set反馈ID(700402); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //伙伴物品配置数据 + PartnerItem partnerItem = TimingAcquisition.seriesPartnerItemMap.get(seriesName).get(itemId); + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700401); + text = SpeechUtil.speechReplaceNum(text, partnerItem.getName()); + //存在该物品,需二次确认删除 + resultResponse.set反馈ID(700401); + resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("丢弃物品回复1"); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + /** + * 700403:确认丢弃该物品 + * @param operationReq + * @return + */ + public CommonResult disbandItem(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + Integer itemId = operationReq.getPartnerItemId(); //获取伙伴id + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + Map itemInfoMap = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid). + getPartnerItemMap().get(Constants.ITEM_PROPS).getItemInfoMap(); + //伙伴物品配置数据 + PartnerItem partnerItem = TimingAcquisition.seriesPartnerItemMap.get(seriesName).get(itemId); + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700403); + text = SpeechUtil.speechReplaceNum(text, partnerItem.getName()); + //存在该伙伴,删除 + itemInfoMap.remove(itemId); + resultResponse.set反馈ID(700403); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + /** + * 7005:查看指定的伙伴或物品 + * @param operationReq + * @return + */ + public CommonResult checkPartnerItem(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + Integer partnerItemId = operationReq.getPartnerItemId(); //获取伙伴物品id + if (StringUtils.isEmpty(partnerItemId)) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700506); + resultResponse.set反馈ID(700506); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //系列名称 + String seriesName = TimingAcquisition.playerMap.get(uid).getSeries(); + //玩家已有的伙伴和物品 + PartnerItemDto partnerItem = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getPartnerItemMap().get(Constants.ITEM_PARTNER); + //还没有伙伴或物品 + if (StringUtils.isEmpty(partnerItem)) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700502); + resultResponse.set反馈ID(700502); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + Map partnerItemInfoMap = TimingAcquisition.seriesPartnerItemMap.get(seriesName); + //没有指定的伙伴或物品 + if (StringUtils.isEmpty(partnerItemInfoMap.get(partnerItemId))) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700502); + resultResponse.set反馈ID(700502); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //获取对应话术 + String text = ""; + //查看的是伙伴或物品 + if (!StringUtils.isEmpty(partnerItem.getItemInfoMap().get(partnerItemId)) + || !StringUtils.isEmpty(partnerItem.getItemInfoMap().get(partnerItemId))) { + //剩余使用次数 + int times = partnerItem.getItemInfoMap().get(partnerItemId).getTimes(); + if (times != 0) { + text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700501); + text = SpeechUtil.speechReplaceNum(text, partnerItemInfoMap.get(partnerItemId).getName(), + partnerItemInfoMap.get(partnerItemId).getAbilityDes(), String.valueOf(times)); + } else { + text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700503); + text = SpeechUtil.speechReplaceNum(text, partnerItemInfoMap.get(partnerItemId).getName(), partnerItemInfoMap.get(partnerItemId).getAbilityDes()); + } + resultResponse.set反馈ID(700501); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //查看指定的是伙伴 + if (partnerItemInfoMap.get(partnerItemId).getType() == 1) { + text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700504); + resultResponse.set反馈ID(700504); + } else { + text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700505); + resultResponse.set反馈ID(700505); + } + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + /** + * 7006:查看队伍 + * @param operationReq + * @return + */ + public CommonResult checkTeam(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + Player player = TimingAcquisition.playerMap.get(uid); + //系列名称 + String seriesName = player.getSeries(); + PlayerSeriesDto playerSeries = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid); + //还没有伙伴或物品 + if (StringUtils.isEmpty(playerSeries.getPartnerItemMap().get(Constants.ITEM_PARTNER))) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700604); + resultResponse.set反馈ID(700604); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + Map partnerInfoMap = playerSeries.getPartnerItemMap().get(Constants.ITEM_PARTNER).getItemInfoMap(); + //伙伴名称 + StringBuilder partnerNames = new StringBuilder(); + for (Map.Entry entry : partnerInfoMap.entrySet()) { + partnerNames.append(ConfigDataUtil.getPartnerItemName(uid, entry.getKey())).append(","); + } + if (partnerNames.length() > 0) { + partnerNames.deleteCharAt(partnerNames.length() - 1); + } + //当前玩家的伙伴人数上限 + int partnerNumMax = playerSeries.getPartnerItemMap().get(Constants.ITEM_PARTNER).getMax(); + //空位 + int freeSeat = partnerNumMax - partnerInfoMap.size(); + //下一次增加人数上限的配置 + BackpackNum nextPartnerNum = ConfigDataUtil.getNextPartnerNum(uid); + String text = ""; + //已达到最高 + if (StringUtils.isEmpty(nextPartnerNum)) { + //获取对应话术 + text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700603); + text = SpeechUtil.speechReplaceNum(text, String.valueOf(partnerInfoMap.size()), partnerNames.toString(), + String.valueOf(freeSeat)); + resultResponse.set反馈ID(700603); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + if (freeSeat == 0) { + text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700602); + text = SpeechUtil.speechReplaceNum(text, String.valueOf(partnerInfoMap.size()), partnerNames.toString(), + String.valueOf(nextPartnerNum.getReputation()), String.valueOf(nextPartnerNum.getMax())); + resultResponse.set反馈ID(700602); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700601); + text = SpeechUtil.speechReplaceNum(text, String.valueOf(partnerInfoMap.size()), partnerNames.toString(), + String.valueOf(freeSeat), String.valueOf(nextPartnerNum.getReputation()), String.valueOf(nextPartnerNum.getMax())); + resultResponse.set反馈ID(700601); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + /** + * 7007: 查看背包 + * @param operationReq + * @return + */ + public CommonResult checkBackpack(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + Player player = TimingAcquisition.playerMap.get(uid); + //系列名称 + String seriesName = player.getSeries(); + PlayerSeriesDto playerSeries = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid); + //还没有伙伴或物品 + if (StringUtils.isEmpty(playerSeries.getPartnerItemMap().get(Constants.ITEM_PROPS)) + && StringUtils.isEmpty(playerSeries.getPartnerItemMap().get(Constants.ITEM_NOR))) { + //获取对应话术 + String text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700705); + resultResponse.set反馈ID(700705); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + String text = ""; + //遍历道具 + if (!StringUtils.isEmpty(playerSeries.getPartnerItemMap().get(Constants.ITEM_PROPS))) { + //物品名称 + StringBuilder itemNames = new StringBuilder(); + //道具 + Map propsInfoMap = playerSeries.getPartnerItemMap().get(Constants.ITEM_PROPS).getItemInfoMap(); + for (Map.Entry entry : propsInfoMap.entrySet()) { + itemNames.append(ConfigDataUtil.getPartnerItemName(uid, entry.getKey())).append("、"); + } + if (itemNames.length() > 0) { + itemNames.deleteCharAt(itemNames.length() - 1); + //当前玩家的背包道具数量上限 + int itemNumMax = playerSeries.getPartnerItemMap().get(Constants.ITEM_PROPS).getMax(); + //剩余容量 + int freeSeat = itemNumMax - propsInfoMap.size(); + //下一次增加背包上限的配置 + BackpackNum nextBackpackNum = ConfigDataUtil.getNextItemNum(uid); + //已达到最高 + if (StringUtils.isEmpty(nextBackpackNum)) { + //获取对应话术 + text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700703); + text = SpeechUtil.speechReplaceNum(text, String.valueOf(propsInfoMap.size()), itemNames.toString(), + String.valueOf(freeSeat)); + } else { + if (freeSeat == 0) { + text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700702); + text = SpeechUtil.speechReplaceNum(text, String.valueOf(propsInfoMap.size()), itemNames.toString(), + String.valueOf(nextBackpackNum.getReputation()), String.valueOf(nextBackpackNum.getMax())); + } else { + text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700701); + text = SpeechUtil.speechReplaceNum(text, String.valueOf(propsInfoMap.size()), itemNames.toString(), + String.valueOf(freeSeat), String.valueOf(nextBackpackNum.getReputation()), String.valueOf(nextBackpackNum.getMax())); + } + } + } + } + //遍历普通物品 + if (!StringUtils.isEmpty(playerSeries.getPartnerItemMap().get(Constants.ITEM_NOR))) { + //物品名称 + StringBuilder itemNames = new StringBuilder(); + int count = 0; + //普通物品 + Map itemInfoMap = playerSeries.getPartnerItemMap().get(Constants.ITEM_NOR).getItemInfoMap(); + for (Map.Entry entry : itemInfoMap.entrySet()) { + itemNames.append(ConfigDataUtil.getPartnerItemName(uid, entry.getKey())).append(entry.getValue().getNum()).append("个、"); + count += entry.getValue().getNum(); + } + if (itemNames.length() > 0) { + itemNames.deleteCharAt(itemNames.length() - 1); + //获取对应话术 + text += SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700704); + text = SpeechUtil.speechReplaceNum(text, String.valueOf(count), itemNames.toString()); + } + } + if (StringUtils.isEmpty(text)) { + //获取对应话术 + text = SpeechUtil.getPartnerItemSpeech(uid, Constants.SPEECH_ASIDE, 700705); + resultResponse.set反馈ID(700705); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + resultResponse.set反馈ID(700701); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + /** + * 700801:同意获取 + * @param operationReq + * @return + */ + public CommonResult agreeGain(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + Player player = TimingAcquisition.playerMap.get(uid); + String unique = uid + player.getGateNo(); //用户uid和关卡编号组成唯一标识 + //当前玩家上一轮保存的数据 + ReplyDto reply = (ReplyDto) CacheUtil.get(unique); + //走闲聊 + if (StringUtils.isEmpty(reply)) { + operationReq.setMethodId("9001"); + return chatService.operate(operationReq); + } + //掉落的物品或伙伴, + Map idNumMap = reply.getIdNumMap(); + Integer demandTaskId = reply.getDemandTaskId(); + Integer subjectId = reply.getSubjectId(); + //找到对应任务 + DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, demandTaskId); + if (StringUtils.isEmpty(demandTask)) { + operationReq.setMethodId("9001"); + return chatService.operate(operationReq); + } + //系列名称 + String seriesName = player.getSeries(); + //系列的玩家汇总数据 + Map partnerItemMap = TimingAcquisition.seriesPlayerMap.get(seriesName).get(uid).getPartnerItemMap(); + //系列的物品配置数据 + Map partnerItemPojoMap = TimingAcquisition.seriesPartnerItemMap.get(seriesName); + //当前对话的人物 + Person subject = PlayerUtil.getPerson(uid, subjectId); + String text = ""; + //遍历掉落的物品或人物 + for (Map.Entry entry : idNumMap.entrySet()) { + Integer partnerItemId = entry.getKey(); + //该物品的配置信息 + PartnerItem partnerItemPojo = partnerItemPojoMap.get(partnerItemId); + int type = partnerItemPojo.getType(); + //物品类型数量上限 + int itemNumMax = TimingAcquisition.seriesBackpackNumMap.get(seriesName).get(type).get(1).getMax(); + //还没有这类物品 + if (StringUtils.isEmpty(partnerItemMap.get(type))) { + PartnerItemDto partnerItem = new PartnerItemDto(); + Map itemInfoMap = new HashMap<>(); + partnerItem.setMax(itemNumMax); + partnerItem.setItemInfoMap(itemInfoMap); + partnerItemMap.put(type, partnerItem); + } + //根据物品类型取出对应的数据 + Map itemInfoMap = partnerItemMap.get(type).getItemInfoMap(); + //该类物品的容量上限 + itemNumMax = partnerItemMap.get(partnerItemPojo.getType()).getMax(); + //剩余容量 + int freeSeat = itemNumMax - itemInfoMap.size(); + //没有空位 + if (freeSeat == 0) { + //获取对应话术 + continue; + } + ItemNumDto itemInfo = itemInfoMap.get(entry.getKey()); + //队伍或背包中已经存在了 + if (!StringUtils.isEmpty(itemInfo)) { + //普通物品可以增加数量 + if (Constants.ITEM_NOR.equals(partnerItemPojo.getType())) { + itemInfo.setNum(itemInfo.getNum() + entry.getValue()); + } + continue; + } + //新增物品 + ItemNumDto itemInfoDto = new ItemNumDto(); + itemInfoDto.setId(entry.getKey()); + itemInfoDto.setNum(1); + itemInfoDto.setTimes(partnerItemPojo.getHelpTimes()); + itemInfoMap.put(entry.getKey(), itemInfoDto); + text += SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask); + } + resultResponse.set反馈ID(700801); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + /** + * 700801:拒绝加入队伍 + * @param operationReq + * @return + */ + public CommonResult agreeGainRefuse(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + Player player = TimingAcquisition.playerMap.get(uid); + String unique = uid + player.getGateNo(); //用户uid和关卡编号组成唯一标识 + //清除对应缓存 + CacheGlobal.concurrentMap.remove(unique); + resultResponse.set反馈ID(600001); + resultResponse.set反馈文本("好的"); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } +} diff --git a/src/main/java/com/qiwu/inference/service/player/PlayerService.java b/src/main/java/com/qiwu/inference/service/player/PlayerService.java index 944edb1..71f9fab 100755 --- a/src/main/java/com/qiwu/inference/service/player/PlayerService.java +++ b/src/main/java/com/qiwu/inference/service/player/PlayerService.java @@ -54,6 +54,13 @@ public interface PlayerService { public CommonResult askPrompt(OperationRequest request); /** + * 询问最终线索 + * @param request + * @return + */ + public CommonResult askFinalClue(OperationRequest request); + + /** * 执行任务 * @param request * @return diff --git a/src/main/java/com/qiwu/inference/service/player/impl/PlayerServiceImpl.java b/src/main/java/com/qiwu/inference/service/player/impl/PlayerServiceImpl.java index 14cc6f9..aadc92f 100644 --- a/src/main/java/com/qiwu/inference/service/player/impl/PlayerServiceImpl.java +++ b/src/main/java/com/qiwu/inference/service/player/impl/PlayerServiceImpl.java @@ -1,28 +1,20 @@ package com.qiwu.inference.service.player.impl; -import com.alibaba.fastjson.JSON; import com.qiwu.inference.common.Constants; import com.qiwu.inference.common.TimingAcquisition; -import com.qiwu.inference.common.api.CommonData; import com.qiwu.inference.common.api.CommonResult; +import com.qiwu.inference.common.cache.CacheGlobal; import com.qiwu.inference.common.utils.*; -import com.qiwu.inference.dto.ClueDto; -import com.qiwu.inference.dto.DemandTaskDto; -import com.qiwu.inference.dto.Person; -import com.qiwu.inference.dto.Player; +import com.qiwu.inference.dto.*; import com.qiwu.inference.dto.request.OperationRequest; import com.qiwu.inference.dto.response.ResultResponse; import com.qiwu.inference.dto.response.ResultVarsResponse; -import com.qiwu.inference.pojo.Clue; import com.qiwu.inference.service.player.PlayerService; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import static com.qiwu.inference.common.utils.PlayerUtil.addThreshold; @@ -58,15 +50,17 @@ public class PlayerServiceImpl implements PlayerService { Player player = TimingAcquisition.playerMap.get(uid); //当前对话的人物 - Person current = player.getPersonMap().get(player.getPersonId()); + Person current = PlayerUtil.getPerson(uid, player.getPersonId()); //没提供人物名称时 if (StringUtils.isEmpty(subjectName)) { subjectName = current.getName(); } + //当前对话人的数据 + PersonInfoDto talk = player.getPersonInfoMap().get(player.getPersonId()); //该关卡没有这个人物 if(StringUtils.isEmpty(player.getName2IdMap().get(subjectName))){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100008); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100008); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100008); resultResponse.set反馈文本(text); @@ -77,7 +71,7 @@ public class PlayerServiceImpl implements PlayerService { if("1001".equals(methodId)){ if(StringUtils.isEmpty(subjectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); @@ -86,7 +80,7 @@ public class PlayerServiceImpl implements PlayerService { } if(StringUtils.isEmpty(type)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100002); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100002); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100002); resultResponse.set反馈文本(text); @@ -94,12 +88,12 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } Integer personId = player.getName2IdMap().get(subjectName); - Person subject = player.getPersonMap().get(personId); + Person subject = PlayerUtil.getPerson(uid, personId); //查找符合条件的线索 List clueList = findClues(current, subject,3); if (clueList.size() == 0) { //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100103); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100103); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, subjectName); resultResponse.set反馈ID(100103); @@ -108,16 +102,16 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList = checkThreshold(current,clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ String text = ""; //对话本人 if (personId.equals(player.getPersonId())) { //获取对应话术 - text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 10010201); + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 10010201); } else { //获取对应话术 - text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100102); + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100102); } text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100102); @@ -126,24 +120,30 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //判断是否为指定性格类型的线索 - clueList = PlayerUtil.checkClueType(clueList, type); + clueList = PlayerUtil.checkClueType(uid, clueList, type); if (clueList.size() == 0) { + String text = ""; //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100103); + if (!"2".equals(type)) { + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100103); + } else { + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 10010301); + } text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); resultResponse.set反馈ID(10010301); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), personId, clueList.get(index).getType(), clueList.get(index)); //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(personId), clueList.get(index)); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(100101); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -151,7 +151,7 @@ public class PlayerServiceImpl implements PlayerService { }else if("1002".equals(methodId)){ if(StringUtils.isEmpty(subjectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -159,19 +159,19 @@ public class PlayerServiceImpl implements PlayerService { } if(StringUtils.isEmpty(dispositionName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100003); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100003); resultResponse.set反馈ID(100003); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } Integer personId = player.getName2IdMap().get(subjectName); - Person subject =player.getPersonMap().get(personId); + Person subject = PlayerUtil.getPerson(uid, personId); //查找符合条件的线索 List clueList = findClues(current,subject,3); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100204); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100204); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, subjectName); resultResponse.set反馈ID(100204); @@ -180,16 +180,16 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList=checkThreshold(current, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ String text = ""; //对话本人 if (personId.equals(player.getPersonId())) { //获取对应话术 - text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 10020301); + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 10020301); } else { //获取对应话术 - text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100203); + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100203); } text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100203); @@ -197,13 +197,14 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int num = RandomUtil.randomInt(clueList.size()); +// int num = RandomUtil.randomInt(clueList.size()); + int num = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); String context = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(num)); //查找符合条件的线索 clueList = findClues(clueList,dispositionName); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100202); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100202); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, context); resultResponse.set反馈ID(100202); @@ -211,14 +212,14 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), personId, clueList.get(index).getType(), clueList.get(index)); //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(personId), clueList.get(index)); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(100201); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -252,17 +253,19 @@ public class PlayerServiceImpl implements PlayerService { } Player player = TimingAcquisition.playerMap.get(uid); - if (StringUtils.isEmpty(objectName)) { - objectName = subjectName; - subjectName = TimingAcquisition.getTalkName(uid); //当前正在对话的人 - } + //当前对话的人物 - Person current = player.getPersonMap().get(player.getPersonId()); + Person current = PlayerUtil.getPerson(uid, player.getPersonId()); + PersonInfoDto talk = player.getPersonInfoMap().get(player.getPersonId()); if("1003".equals(methodId)){ + if (StringUtils.isEmpty(objectName)) { + objectName = subjectName; + subjectName = TimingAcquisition.getTalkName(uid); //当前正在对话的人 + } if(StringUtils.isEmpty(subjectName) || StringUtils.isEmpty(objectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -270,22 +273,22 @@ public class PlayerServiceImpl implements PlayerService { } Integer subjectId = player.getName2IdMap().get(subjectName); Integer objectId = player.getName2IdMap().get(objectName); - Person subject =player.getPersonMap().get(subjectId); - Person object =player.getPersonMap().get(objectId); + Person subject = PlayerUtil.getPerson(uid, subjectId); + Person object = PlayerUtil.getPerson(uid, objectId); //查找符合条件的线索 List clueList = findClues(current, subject, object,5); if(clueList.size() == 0){ String text = ""; if (subjectId.equals(player.getPersonId())) { - text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 10030301); + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 10030301); text = SpeechUtil.speechReplaceNum(text, objectName); } else if (objectId.equals(player.getPersonId())) { - text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 10030301); + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 10030301); text = SpeechUtil.speechReplaceNum(text, subjectName); } else { //获取对应话术 - text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100303); + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100303); } text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100303); @@ -294,16 +297,16 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList = checkThreshold(current, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ String text = ""; //对话本人 if (subjectId.equals(player.getPersonId()) || objectId.equals(player.getPersonId())) { //获取对应话术 - text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 10030201); + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 10030201); } else { //获取对应话术 - text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100302); + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100302); } text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100302); @@ -311,22 +314,26 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clueList.get(index)); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(100301); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); }else if("1004".equals(methodId)){ + if (StringUtils.isEmpty(objectName)) { + objectName = subjectName; + subjectName = TimingAcquisition.getTalkName(uid); //当前正在对话的人 + } if(StringUtils.isEmpty(subjectName) || StringUtils.isEmpty(objectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -335,7 +342,7 @@ public class PlayerServiceImpl implements PlayerService { if(StringUtils.isEmpty(relationName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100004); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100004); resultResponse.set反馈ID(100004); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -343,13 +350,13 @@ public class PlayerServiceImpl implements PlayerService { } Integer subjectId = player.getName2IdMap().get(subjectName); Integer objectId = player.getName2IdMap().get(objectName); - Person subject =player.getPersonMap().get(subjectId); - Person object =player.getPersonMap().get(objectId); + Person subject = PlayerUtil.getPerson(uid, subjectId); + Person object = PlayerUtil.getPerson(uid, objectId); //查找符合条件的线索 List clueList = findClues(current, subject, object,5); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100404); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100404); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100404); resultResponse.set反馈文本(text); @@ -357,23 +364,24 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList = checkThreshold(current, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100403); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100403); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100403); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int num = RandomUtil.randomInt(clueList.size()); +// int num = RandomUtil.randomInt(clueList.size()); + int num = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); String context = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(num)); //查找符合条件的线索 clueList = findClues(clueList, relationName); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100402); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100402); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, context); resultResponse.set反馈ID(100402); @@ -381,22 +389,25 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clueList.get(index)); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(100401); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); }else if("1005".equals(methodId)){ + if (StringUtils.isEmpty(subjectName)) { + subjectName = TimingAcquisition.getTalkName(uid); //当前正在对话的人 + } if(StringUtils.isEmpty(subjectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -405,20 +416,20 @@ public class PlayerServiceImpl implements PlayerService { if(StringUtils.isEmpty(relationName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100004); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100004); resultResponse.set反馈ID(100004); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } Integer subjectId = player.getName2IdMap().get(subjectName); - Person subject =player.getPersonMap().get(subjectId); + Person subject = PlayerUtil.getPerson(uid, subjectId); //查找符合条件的线索 List clueList = findClues(current,5); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100503); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100503); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, subjectName, relationName); resultResponse.set反馈ID(100503); @@ -427,10 +438,10 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList = checkThreshold(current, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100502); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100502); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100502); resultResponse.set反馈文本(text); @@ -441,7 +452,7 @@ public class PlayerServiceImpl implements PlayerService { clueList=findClues(clueList,relationName); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100503); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100503); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, subjectName, relationName); resultResponse.set反馈ID(100503); @@ -452,12 +463,12 @@ public class PlayerServiceImpl implements PlayerService { StringBuilder builder = new StringBuilder(); for (ClueDto clue : clueList) { if (!StringUtils.isEmpty(clue.getObject())) { - builder.append(player.getPersonMap().get(clue.getObject()).getName()).append("跟").append(subjectName).append("有").append(clue.getClueName()).append("关系。"); + builder.append(PlayerUtil.getPersonMap(uid).get(clue.getObject()).getName()).append("跟").append(subjectName).append("有").append(clue.getClueName()).append("关系。"); } } if(StringUtils.isEmpty(builder.toString())){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100503); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100503); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, subjectName, relationName); resultResponse.set反馈ID(100503); @@ -465,14 +476,14 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clueList.get(index)); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(100501); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -480,20 +491,21 @@ public class PlayerServiceImpl implements PlayerService { }else if("1006".equals(methodId)){ if(StringUtils.isEmpty(relationName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100004); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100004); resultResponse.set反馈ID(100004); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } List clueList = new ArrayList<>(); - for(Integer key : player.getPersonMap().keySet()){ - Person person = player.getPersonMap().get(key); + Map personMap = PlayerUtil.getPersonMap(uid); + for(Integer key : personMap.keySet()){ + Person person = personMap.get(key); clueList.addAll(findClues(person,5)); } if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100603); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100603); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, relationName); resultResponse.set反馈ID(100603); @@ -502,10 +514,10 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList = checkThreshold(current, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100602); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100602); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100602); resultResponse.set反馈文本(text); @@ -516,7 +528,7 @@ public class PlayerServiceImpl implements PlayerService { clueList = findClues(clueList, relationName); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100603); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100603); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, relationName); resultResponse.set反馈ID(100603); @@ -524,14 +536,14 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), clueList.get(index).getSubject(), clueList.get(index).getType(), clueList.get(index)); //----------------是否解锁任务------------- PlayerUtil.unlockTask(uid, clueList.get(index)); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(100601); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -561,7 +573,7 @@ public class PlayerServiceImpl implements PlayerService { Integer subjectId = player.getName2IdMap().get(subjectName); if (StringUtils.isEmpty(subjectId)) { //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100008); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100008); resultResponse.set反馈ID(100008); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -578,28 +590,29 @@ public class PlayerServiceImpl implements PlayerService { } } //当前对话的人物 - Person current = player.getPersonMap().get(player.getPersonId()); + Person current = PlayerUtil.getPerson(uid, player.getPersonId()); //询问当前对话的人 if (StringUtils.isEmpty(subjectName)) { subjectName = current.getName(); } - + //当前对话人 + PersonInfoDto talk = player.getPersonInfoMap().get(player.getPersonId()); if("1007".equals(methodId)){ if(StringUtils.isEmpty(subjectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } Integer subjectId = player.getName2IdMap().get(subjectName); - Person subject =player.getPersonMap().get(subjectId); + Person subject = PlayerUtil.getPerson(uid, subjectId); //查找符合条件的线索 List clueList = findClues(current, subject,4); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100703); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100703); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, subjectName); resultResponse.set反馈ID(100703); @@ -608,24 +621,24 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList = checkThreshold(current, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100702); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100702); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100702); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clueList.get(index)); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(100701); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -636,7 +649,7 @@ public class PlayerServiceImpl implements PlayerService { } if(StringUtils.isEmpty(subjectName)||StringUtils.isEmpty(objectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -644,14 +657,14 @@ public class PlayerServiceImpl implements PlayerService { } Integer subjectId = player.getName2IdMap().get(subjectName); Integer objectId = player.getName2IdMap().get(objectName); - Person subject =player.getPersonMap().get(subjectId); - Person object =player.getPersonMap().get(objectId); + Person subject = PlayerUtil.getPerson(uid, subjectId); + Person object = PlayerUtil.getPerson(uid, objectId); //查找符合条件的线索 List clueList = findClues(current, subject, object,4); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100803); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100803); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100803); resultResponse.set反馈文本(text); @@ -659,24 +672,24 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList = checkThreshold(current, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100802); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100802); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100802); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clueList.get(index)); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(100801); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -684,7 +697,7 @@ public class PlayerServiceImpl implements PlayerService { } else if("1009".equals(methodId)){ if(StringUtils.isEmpty(subjectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -693,18 +706,18 @@ public class PlayerServiceImpl implements PlayerService { if(StringUtils.isEmpty(behaviourName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100005); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100005); resultResponse.set反馈ID(100005); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } Integer subjectId = player.getName2IdMap().get(subjectName); - Person subject =player.getPersonMap().get(subjectId); + Person subject = PlayerUtil.getPerson(uid, subjectId); List clueList = findClues(current, subject,4); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100903); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100903); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, subjectName, behaviourName); resultResponse.set反馈ID(100903); @@ -713,10 +726,10 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList = checkThreshold(current, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100902); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100902); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100902); resultResponse.set反馈文本(text); @@ -726,7 +739,7 @@ public class PlayerServiceImpl implements PlayerService { clueList = findClues(clueList, behaviourName); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100903); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 100903); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, subjectName, behaviourName); resultResponse.set反馈ID(100903); @@ -734,14 +747,14 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clueList.get(index)); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(100901); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -749,7 +762,7 @@ public class PlayerServiceImpl implements PlayerService { }else if("1010".equals(methodId)){ if(StringUtils.isEmpty(subjectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -757,18 +770,18 @@ public class PlayerServiceImpl implements PlayerService { } if(StringUtils.isEmpty(behaviourName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100005); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100005); resultResponse.set反馈ID(100005); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } Integer subjectId = player.getName2IdMap().get(subjectName); - Person subject =player.getPersonMap().get(subjectId); + Person subject = PlayerUtil.getPerson(uid, subjectId); List clueList = findClues(current, subject,4); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101004); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101004); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, subjectName, behaviourName); resultResponse.set反馈ID(101004); @@ -777,23 +790,24 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList = checkThreshold(current, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101003); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101003); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(101003); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int num = RandomUtil.randomInt(clueList.size()); +// int num = RandomUtil.randomInt(clueList.size()); + int num = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); String context = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(num)); //查找符合条件的线索 clueList = findClues(clueList, behaviourName); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101002); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101002); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, context); resultResponse.set反馈ID(101002); @@ -801,14 +815,14 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clueList.get(index)); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(101001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -819,7 +833,7 @@ public class PlayerServiceImpl implements PlayerService { } if(StringUtils.isEmpty(subjectName) || StringUtils.isEmpty(objectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -827,7 +841,7 @@ public class PlayerServiceImpl implements PlayerService { } if(StringUtils.isEmpty(behaviourName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100005); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100005); resultResponse.set反馈ID(100005); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -835,14 +849,14 @@ public class PlayerServiceImpl implements PlayerService { } Integer subjectId = player.getName2IdMap().get(subjectName); Integer objectId = player.getName2IdMap().get(objectName); - Person subject =player.getPersonMap().get(subjectId); - Person object =player.getPersonMap().get(objectId); + Person subject = PlayerUtil.getPerson(uid, subjectId); + Person object = PlayerUtil.getPerson(uid, objectId); //查找符合条件的线索 List clueList = findClues(current,subject,object,4); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101104); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101104); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, behaviourName); resultResponse.set反馈ID(101104); @@ -851,23 +865,24 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList = checkThreshold(current, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101103); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101103); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(101103); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int num = RandomUtil.randomInt(clueList.size()); +// int num = RandomUtil.randomInt(clueList.size()); + int num = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); String context = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(num)); //查找符合条件的线索 clueList = findClues(clueList, behaviourName); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101102); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101102); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, context); resultResponse.set反馈ID(101102); @@ -875,14 +890,14 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clueList.get(index)); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(101101); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -914,7 +929,9 @@ public class PlayerServiceImpl implements PlayerService { Player player = TimingAcquisition.playerMap.get(uid); //当前对话的人物 - Person current = player.getPersonMap().get(player.getPersonId()); + Person current = PlayerUtil.getPerson(uid, player.getPersonId()); + //当前对话人 + PersonInfoDto talk = player.getPersonInfoMap().get(player.getPersonId()); //询问对象为对话人 if(StringUtils.isEmpty(subjectName)){ subjectName = current.getName(); @@ -923,23 +940,31 @@ public class PlayerServiceImpl implements PlayerService { //该关卡没有这个人物 if(StringUtils.isEmpty(subjectId)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100008); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100008); resultResponse.set反馈ID(100008); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - Person subject = player.getPersonMap().get(subjectId); + Person subject = PlayerUtil.getPerson(uid, subjectId); if("1015".equals(methodId)){ //查找符合条件的任务 List clueList = PlayerUtil.getCluesByType(current, subject, 1); if(clueList.size() == 0){ - //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101504); - text = SpeechUtil.replaceHeader(text, current.getName()); - text = SpeechUtil.speechReplaceNum(text, subjectName); - resultResponse.set反馈ID(101504); + String text = ""; + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101506); + text = SpeechUtil.replaceHeader(text, current.getName()); + resultResponse.set反馈ID(101506); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101504); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + resultResponse.set反馈ID(101504); + } resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); @@ -948,7 +973,7 @@ public class PlayerServiceImpl implements PlayerService { clueList = PlayerUtil.getUndoClueList(uid, subject, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101503); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101503); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(101503); resultResponse.set反馈文本(text); @@ -956,10 +981,10 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查线索是否符合阈值要求 - clueList = PlayerUtil.checkTaskThreshold(uid, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101502); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101502); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(101502); resultResponse.set反馈文本(text); @@ -967,22 +992,68 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } // int index = RandomUtil.randomInt(clueList.size()); - int index = 0; - //当前玩家上一轮的请求信息 - Integer num = (Integer) CacheUtil.get(uid + "-" + subjectId); - if (!StringUtils.isEmpty(num)) { - if (num < clueList.size()) { - index = num; + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); + ClueDto clue = clueList.get(index); +// DemandTaskDto demandTaskDto = PlayerUtil.getDemandTaskByClueId(subject, clue); +// ClueDto preClue = PlayerUtil.getPreClueById(subject, demandTaskDto); +// //获取对应话术 +// String preText = ""; +// if (!StringUtils.isEmpty(preClue) && !StringUtils.isEmpty(demandTaskDto)) { +// preText = SpeechUtil.getPreReasonSpeech(uid, subject, preClue, demandTaskDto.getDemandTaskId()); +// if (!StringUtils.isEmpty(preText)) { +// preText = SpeechUtil.addHeader(preText, current.getName()); +// } +// } + String text = ""; + //询问本人 + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101505); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, current.getName()); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101507); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + } + //通过人物和线索找到对应任务 + DemandTaskDto demandTask = PlayerUtil.getDemandTaskByClueId(subject, clue.getClueId()); + if (!StringUtils.isEmpty(demandTask)) { + //任务非自动触发,返回指定线索 + if (demandTask.getIsAuto() != 1) { + text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + //任务启动文本 +// text = SpeechUtil.getPreSuccessTaskSpeech(uid, current, demandTask, 4); + //----------------记录线索-------------- + PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue); + //----------------是否解锁任务------------- + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clue); + //记录本轮的任务数据,用于下轮的二次回复 + String unique = uid + player.getGateNo(); + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(subjectId); + reply.setDemandTaskId(demandTask.getDemandTaskId()); + reply.setType(2); //发布任务 + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); } } - //----------------记录线索-------------- - PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); - //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); - CacheUtil.put(uid + "-" + subjectId, index + 1, 60000); - //获取对应话术 - String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); + //任务为本人发布 +// boolean selfSign = PlayerUtil.checkTaskSelf(uid, subjectId, clue.getClueId()); +// if (selfSign) { +// //通过线索id找主体对象身上的任务 +// DemandTaskDto demandTask = PlayerUtil.getDemandTaskByClueId(subject, clue.getClueId()); +// if (!StringUtils.isEmpty(demandTask)) { +// if (!StringUtils.isEmpty(demandTask.getPostTask())) { +// text = SpeechUtil.getPreSuccessTaskSpeech(uid, player.getPersonMap().get(subjectId), demandTask, 3); +// } +// } +// } + //如果线索关联的任务为自动完成任务,返回任务完成的文本 +// if (subjectId.equals(current.getId())) { +// String addText = PlayerUtil.taskAutoFinish(uid, current, clue); +// text += addText; +// } resultResponse.set反馈ID(101501); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -991,34 +1062,100 @@ public class PlayerServiceImpl implements PlayerService { //查找符合条件的任务 List clueList = PlayerUtil.getCluesByType(current, subject, 3); if(clueList.size() == 0){ + String text = ""; + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101605); + text = SpeechUtil.replaceHeader(text, current.getName()); + resultResponse.set反馈ID(101605); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101603); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + resultResponse.set反馈ID(101603); + } + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //过滤掉已经完成的任务对应的线索 + clueList = PlayerUtil.getUndoClueList(uid, subject, clueList); + if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101603); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101604); text = SpeechUtil.replaceHeader(text, current.getName()); - text = SpeechUtil.speechReplaceNum(text, subjectName); - resultResponse.set反馈ID(101603); + resultResponse.set反馈ID(101604); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } //检查线索是否符合阈值要求 - clueList = PlayerUtil.checkTaskThreshold(uid, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size()==0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101602); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101602); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(101602); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); - //----------------记录线索-------------- - PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); - //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); + ClueDto clue = clueList.get(index); +// DemandTaskDto demandTaskDto = PlayerUtil.getDemandTaskByClueId(subject, clue); +// ClueDto preClue = PlayerUtil.getPreClueById(subject, demandTaskDto); +// //获取对应话术 +// String preText = ""; +// if (!StringUtils.isEmpty(preClue) && !StringUtils.isEmpty(demandTaskDto)) { +// preText = SpeechUtil.getPreReasonSpeech(uid, subject, preClue, demandTaskDto.getDemandTaskId()); +// if (!StringUtils.isEmpty(preText)) { +// preText = SpeechUtil.addHeader(preText, current.getName()); +// } +// } //获取对应话术 - String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); +// String text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + String text = ""; + //询问本人 + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101606); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, current.getName()); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101607); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + } + //通过人物和线索找到对应任务 + DemandTaskDto demandTask = PlayerUtil.getDemandTaskByClueId(subject, clue.getClueId()); + if (!StringUtils.isEmpty(demandTask)) { + //任务非自动触发,返回指定线索 + if (demandTask.getIsAuto() != 1) { + //获取对应话术 + text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + //任务启动文本 +// text = SpeechUtil.getPreSuccessTaskSpeech(uid, current, demandTask, 4); + //----------------记录线索-------------- + PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue); + //----------------是否解锁任务------------- + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clue); + //记录本轮的任务数据,用于下轮的二次回复 + String unique = uid + player.getGateNo(); + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(subjectId); + reply.setDemandTaskId(demandTask.getDemandTaskId()); + reply.setType(2); //发布任务 + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + } + } + //如果线索关联自动完成任务,返回任务完成的文本 +// if (subjectId.equals(current.getId())) { +// String addText = PlayerUtil.taskAutoFinish(uid, current, clue); +// text += addText; +// } resultResponse.set反馈ID(101601); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1026,7 +1163,7 @@ public class PlayerServiceImpl implements PlayerService { }else if("1017".equals(methodId)){ if(StringUtils.isEmpty(subjectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1036,31 +1173,43 @@ public class PlayerServiceImpl implements PlayerService { List clueList = PlayerUtil.getClueByTypeAndTaskId(uid, subjectId, taskConditionId); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101704); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101704); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(101704); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } + //过滤掉已经完成的任务对应的线索 + clueList = PlayerUtil.getUndoClueList(uid, subject, clueList); + if(clueList.size() == 0){ + //获取对应话术 + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101705); + text = SpeechUtil.replaceHeader(text, current.getName()); + resultResponse.set反馈ID(101705); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } //检查线索是否符合阈值要求 - clueList = PlayerUtil.checkTaskThreshold(uid, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101703); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101703); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(101703); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int num = RandomUtil.randomInt(clueList.size()); +// int num = RandomUtil.randomInt(clueList.size()); + int num = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); String context = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(num)); //判断任务是否为提升信任值 clueList = PlayerUtil.getCluesIsType(current, clueList, 1); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101702); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101702); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, context); resultResponse.set反馈ID(101702); @@ -1068,14 +1217,61 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); - //----------------记录线索-------------- - PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); - //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, current, clueList.get(index)); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); + ClueDto clue = clueList.get(index); +// DemandTaskDto demandTaskDto = PlayerUtil.getDemandTaskByClueId(subject, clue); +// ClueDto preClue = PlayerUtil.getPreClueById(subject, demandTaskDto); +// //获取对应话术 +// String preText = ""; +// if (!StringUtils.isEmpty(preClue) && !StringUtils.isEmpty(demandTaskDto)) { +// preText = SpeechUtil.getPreReasonSpeech(uid, subject, preClue, demandTaskDto.getDemandTaskId()); +// if (!StringUtils.isEmpty(preText)) { +// preText = SpeechUtil.addHeader(preText, current.getName()); +// } +// } //获取对应话术 - String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); +// String text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + String text = ""; + //询问本人 + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101505); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, current.getName()); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101507); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + } + //通过人物和线索找到对应任务 + DemandTaskDto demandTask = PlayerUtil.getDemandTaskByClueId(subject, clue.getClueId()); + if (!StringUtils.isEmpty(demandTask)) { + //任务非自动触发,返回指定线索 + if (demandTask.getIsAuto() != 1) { + //获取对应话术 + text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + //任务启动文本 +// text = SpeechUtil.getPreSuccessTaskSpeech(uid, current, demandTask, 4); + //----------------记录线索-------------- + PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue); + //----------------是否解锁任务------------- + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clue); + //记录本轮的任务数据,用于下轮的二次回复 + String unique = uid + player.getGateNo(); + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(subjectId); + reply.setDemandTaskId(demandTask.getDemandTaskId()); + reply.setType(2); //发布任务 + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + } + } + //如果线索关联自动完成任务,返回任务完成的文本 +// if (subjectId.equals(current.getId())) { +// String addText = PlayerUtil.taskAutoFinish(uid, current, clue); +// text += addText; +// } resultResponse.set反馈ID(101701); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1083,7 +1279,7 @@ public class PlayerServiceImpl implements PlayerService { }else if("1018".equals(methodId)){ if(StringUtils.isEmpty(subjectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1092,33 +1288,53 @@ public class PlayerServiceImpl implements PlayerService { //查找符合条件的任务 List clueList = PlayerUtil.getClueByTypeAndTaskId(uid, subjectId, taskConditionId); if(clueList.size() == 0){ + String text = ""; + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101806); + text = SpeechUtil.replaceHeader(text, current.getName()); + resultResponse.set反馈ID(101806); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101804); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + resultResponse.set反馈ID(101804); + } + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //过滤掉已经完成的任务对应的线索 + clueList = PlayerUtil.getUndoClueList(uid, subject, clueList); + if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101804); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101805); text = SpeechUtil.replaceHeader(text, current.getName()); - text = SpeechUtil.speechReplaceNum(text, subjectName); - resultResponse.set反馈ID(101804); + resultResponse.set反馈ID(101805); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } //检查线索是否符合阈值要求 - clueList = PlayerUtil.checkTaskThreshold(uid, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101803); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101803); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(101803); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int num = RandomUtil.randomInt(clueList.size()); +// int num = RandomUtil.randomInt(clueList.size()); + int num = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); String context = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(num)); //判断任务是否为提升信任值 clueList = PlayerUtil.getCluesIsType(current, clueList, 3); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101802); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101802); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, context); resultResponse.set反馈ID(101802); @@ -1126,14 +1342,61 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); - //----------------记录线索-------------- - PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); - //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); + ClueDto clue = clueList.get(index); +// DemandTaskDto demandTaskDto = PlayerUtil.getDemandTaskByClueId(subject, clue); +// ClueDto preClue = PlayerUtil.getPreClueById(subject, demandTaskDto); +// //获取对应话术 +// String preText = ""; +// if (!StringUtils.isEmpty(preClue) && !StringUtils.isEmpty(demandTaskDto)) { +// preText = SpeechUtil.getPreReasonSpeech(uid, subject, preClue, demandTaskDto.getDemandTaskId()); +// if (!StringUtils.isEmpty(preText)) { +// preText = SpeechUtil.addHeader(preText, current.getName()); +// } +// } //获取对应话术 - String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); +// String text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + String text = ""; + //询问本人 + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101606); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, current.getName()); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101607); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + } + //通过人物和线索找到对应任务 + DemandTaskDto demandTask = PlayerUtil.getDemandTaskByClueId(subject, clue.getClueId()); + if (!StringUtils.isEmpty(demandTask)) { + //任务非自动触发,返回指定线索 + if (demandTask.getIsAuto() != 1) { + //获取对应话术 + text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + //任务启动文本 +// text = SpeechUtil.getPreSuccessTaskSpeech(uid, current, demandTask, 4); + //----------------记录线索-------------- + PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue); + //----------------是否解锁任务------------- + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clue); + //记录本轮的任务数据,用于下轮的二次回复 + String unique = uid + player.getGateNo(); + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(subjectId); + reply.setDemandTaskId(demandTask.getDemandTaskId()); + reply.setType(2); //发布任务 + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + } + } + //如果线索关联自动完成任务,返回任务完成的文本 +// if (subjectId.equals(current.getId())) { +// String addText = PlayerUtil.taskAutoFinish(uid, current, clue); +// text += addText; +// } resultResponse.set反馈ID(101801); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1142,34 +1405,100 @@ public class PlayerServiceImpl implements PlayerService { //查找符合条件的任务 List clueList = PlayerUtil.getCluesByType(current, subject, 2); if(clueList.size() == 0){ + String text = ""; + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101905); + text = SpeechUtil.replaceHeader(text, current.getName()); + resultResponse.set反馈ID(101905); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101903); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + resultResponse.set反馈ID(101903); + } + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //过滤掉已经完成的任务对应的线索 + clueList = PlayerUtil.getUndoClueList(uid, subject, clueList); + if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101903); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101904); text = SpeechUtil.replaceHeader(text, current.getName()); - text = SpeechUtil.speechReplaceNum(text, subjectName); - resultResponse.set反馈ID(101903); + resultResponse.set反馈ID(101904); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } //检查线索是否符合阈值要求 - clueList = PlayerUtil.checkTaskThreshold(uid, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 101902); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101902); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(101902); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); - //----------------记录线索-------------- - PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); - //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); + ClueDto clue = clueList.get(index); +// DemandTaskDto demandTaskDto = PlayerUtil.getDemandTaskByClueId(subject, clue); +// ClueDto preClue = PlayerUtil.getPreClueById(subject, demandTaskDto); +// //获取对应话术 +// String preText = ""; +// if (!StringUtils.isEmpty(preClue) && !StringUtils.isEmpty(demandTaskDto)) { +// preText = SpeechUtil.getPreReasonSpeech(uid, subject, preClue, demandTaskDto.getDemandTaskId()); +// if (!StringUtils.isEmpty(preText)) { +// preText = SpeechUtil.addHeader(preText, current.getName()); +// } +// } //获取对应话术 - String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); +// String text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + String text = ""; + //询问本人 + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101505); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, current.getName()); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101507); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + } + //通过人物和线索找到对应任务 + DemandTaskDto demandTask = PlayerUtil.getDemandTaskByClueId(subject, clue.getClueId()); + if (!StringUtils.isEmpty(demandTask)) { + //任务非自动触发,返回指定线索 + if (demandTask.getIsAuto() != 1) { + //获取对应话术 + text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + //任务启动文本 +// text = SpeechUtil.getPreSuccessTaskSpeech(uid, current, demandTask, 4); + //----------------记录线索-------------- + PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue); + //----------------是否解锁任务------------- + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clue); + //记录本轮的任务数据,用于下轮的二次回复 + String unique = uid + player.getGateNo(); + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(subjectId); + reply.setDemandTaskId(demandTask.getDemandTaskId()); + reply.setType(2); //发布任务 + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + } + } + //如果线索关联自动完成任务,返回任务完成的文本 +// if (subjectId.equals(current.getId())) { +// String addText = PlayerUtil.taskAutoFinish(uid, current, clue); +// text += addText; +// } resultResponse.set反馈ID(101901); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1178,34 +1507,100 @@ public class PlayerServiceImpl implements PlayerService { //查找符合条件的任务 List clueList = PlayerUtil.getCluesByType(current, subject, 4); if(clueList.size() == 0){ + String text = ""; + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102005); + text = SpeechUtil.replaceHeader(text, current.getName()); + resultResponse.set反馈ID(102005); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102003); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + resultResponse.set反馈ID(102003); + } + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //过滤掉已经完成的任务对应的线索 + clueList = PlayerUtil.getUndoClueList(uid, subject, clueList); + if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102003); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102004); text = SpeechUtil.replaceHeader(text, current.getName()); - text = SpeechUtil.speechReplaceNum(text, subjectName); - resultResponse.set反馈ID(102003); + resultResponse.set反馈ID(102004); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } //检查线索是否符合阈值要求 - clueList = PlayerUtil.checkTaskThreshold(uid, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102002); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102002); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(102002); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); - //----------------记录线索-------------- - PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); - //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); + ClueDto clue = clueList.get(index); +// DemandTaskDto demandTaskDto = PlayerUtil.getDemandTaskByClueId(subject, clue); +// ClueDto preClue = PlayerUtil.getPreClueById(subject, demandTaskDto); +// //获取对应话术 +// String preText = ""; +// if (!StringUtils.isEmpty(preClue) && !StringUtils.isEmpty(demandTaskDto)) { +// preText = SpeechUtil.getPreReasonSpeech(uid, subject, preClue, demandTaskDto.getDemandTaskId()); +// if (!StringUtils.isEmpty(preText)) { +// preText = SpeechUtil.addHeader(preText, current.getName()); +// } +// } //获取对应话术 - String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); +// String text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + String text = ""; + //询问本人 + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101606); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, current.getName()); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101607); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + } + //通过人物和线索找到对应任务 + DemandTaskDto demandTask = PlayerUtil.getDemandTaskByClueId(subject, clue.getClueId()); + if (!StringUtils.isEmpty(demandTask)) { + //任务非自动触发,返回指定线索 + if (demandTask.getIsAuto() != 1) { + //获取对应话术 + text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + //任务启动文本 +// text = SpeechUtil.getPreSuccessTaskSpeech(uid, current, demandTask, 4); + //----------------记录线索-------------- + PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue); + //----------------是否解锁任务------------- + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clue); + //记录本轮的任务数据,用于下轮的二次回复 + String unique = uid + player.getGateNo(); + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(subjectId); + reply.setDemandTaskId(demandTask.getDemandTaskId()); + reply.setType(2); //发布任务 + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + } + } + //如果线索关联自动完成任务,返回任务完成的文本 +// if (subjectId.equals(current.getId())) { +// String addText = PlayerUtil.taskAutoFinish(uid, current, clue); +// text += addText; +// } resultResponse.set反馈ID(102001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1213,7 +1608,7 @@ public class PlayerServiceImpl implements PlayerService { }else if("1021".equals(methodId)){ if(StringUtils.isEmpty(subjectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); @@ -1223,33 +1618,53 @@ public class PlayerServiceImpl implements PlayerService { //查找符合条件的任务 List clueList = PlayerUtil.getClueByTypeAndTaskId(uid, subjectId, taskConditionId); if(clueList.size() == 0){ + String text = ""; + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102106); + text = SpeechUtil.replaceHeader(text, current.getName()); + resultResponse.set反馈ID(102106); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102104); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + resultResponse.set反馈ID(102104); + } + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //过滤掉已经完成的任务对应的线索 + clueList = PlayerUtil.getUndoClueList(uid, subject, clueList); + if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102104); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102105); text = SpeechUtil.replaceHeader(text, current.getName()); - text = SpeechUtil.speechReplaceNum(text, subjectName); - resultResponse.set反馈ID(102104); + resultResponse.set反馈ID(102105); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } //检查线索是否符合阈值要求 - clueList = PlayerUtil.checkTaskThreshold(uid, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102103); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102103); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(102103); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int num = RandomUtil.randomInt(clueList.size()); +// int num = RandomUtil.randomInt(clueList.size()); + int num = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); String context = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(num)); //判断任务是否为提升信任值 clueList = PlayerUtil.getCluesIsType(current, clueList, 2); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102102); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102102); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, context); resultResponse.set反馈ID(102102); @@ -1257,14 +1672,61 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); - //----------------记录线索-------------- - PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); - //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); + ClueDto clue = clueList.get(index); +// DemandTaskDto demandTaskDto = PlayerUtil.getDemandTaskByClueId(subject, clue); +// ClueDto preClue = PlayerUtil.getPreClueById(subject, demandTaskDto); +// //获取对应话术 +// String preText = ""; +// if (!StringUtils.isEmpty(preClue) && !StringUtils.isEmpty(demandTaskDto)) { +// preText = SpeechUtil.getPreReasonSpeech(uid, subject, preClue, demandTaskDto.getDemandTaskId()); +// if (!StringUtils.isEmpty(preText)) { +// preText = SpeechUtil.addHeader(preText, current.getName()); +// } +// } //获取对应话术 - String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); +// String text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + String text = ""; + //询问本人 + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101505); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, current.getName()); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101507); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + } + //通过人物和线索找到对应任务 + DemandTaskDto demandTask = PlayerUtil.getDemandTaskByClueId(subject, clue.getClueId()); + if (!StringUtils.isEmpty(demandTask)) { + //任务非自动触发,返回指定线索 + if (demandTask.getIsAuto() != 1) { + //获取对应话术 + text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + //任务启动文本 +// text = SpeechUtil.getPreSuccessTaskSpeech(uid, current, demandTask, 4); + //----------------记录线索-------------- + PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue); + //----------------是否解锁任务------------- + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clue); + //记录本轮的任务数据,用于下轮的二次回复 + String unique = uid + player.getGateNo(); + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(subjectId); + reply.setDemandTaskId(demandTask.getDemandTaskId()); + reply.setType(2); //发布任务 + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + } + } + //如果线索关联自动完成任务,返回任务完成的文本 +// if (subjectId.equals(current.getId())) { +// String addText = PlayerUtil.taskAutoFinish(uid, current, clue); +// text += addText; +// } resultResponse.set反馈ID(102101); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1272,7 +1734,7 @@ public class PlayerServiceImpl implements PlayerService { }else if("1022".equals(methodId)){ if(StringUtils.isEmpty(subjectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1281,33 +1743,53 @@ public class PlayerServiceImpl implements PlayerService { //查找符合条件的任务 List clueList = PlayerUtil.getClueByTypeAndTaskId(uid, subjectId, taskConditionId); if(clueList.size() == 0){ + String text = ""; + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102206); + text = SpeechUtil.replaceHeader(text, current.getName()); + resultResponse.set反馈ID(102206); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102204); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + resultResponse.set反馈ID(102204); + } + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //过滤掉已经完成的任务对应的线索 + clueList = PlayerUtil.getUndoClueList(uid, subject, clueList); + if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102204); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102205); text = SpeechUtil.replaceHeader(text, current.getName()); - text = SpeechUtil.speechReplaceNum(text, subjectName); - resultResponse.set反馈ID(102204); + resultResponse.set反馈ID(102205); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } //检查线索是否符合阈值要求 - clueList = PlayerUtil.checkTaskThreshold(uid, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102203); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102203); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(102203); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int num = RandomUtil.randomInt(clueList.size()); +// int num = RandomUtil.randomInt(clueList.size()); + int num = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); String context = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(num)); //判断任务是否为提升信任值 clueList = PlayerUtil.getCluesIsType(current, clueList, 4); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102202); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102202); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, context); resultResponse.set反馈ID(102202); @@ -1315,14 +1797,61 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); - //----------------记录线索-------------- - PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); - //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); + ClueDto clue = clueList.get(index); +// DemandTaskDto demandTaskDto = PlayerUtil.getDemandTaskByClueId(subject, clue); +// ClueDto preClue = PlayerUtil.getPreClueById(subject, demandTaskDto); +// //获取对应话术 +// String preText = ""; +// if (!StringUtils.isEmpty(preClue) && !StringUtils.isEmpty(demandTaskDto)) { +// preText = SpeechUtil.getPreReasonSpeech(uid, subject, preClue, demandTaskDto.getDemandTaskId()); +// if (!StringUtils.isEmpty(preText)) { +// preText = SpeechUtil.addHeader(preText, current.getName()); +// } +// } //获取对应话术 - String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); +// String text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + String text = ""; + //询问本人 + if (subjectName.equals(current.getName())) { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101606); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, current.getName()); + } else { + //获取对应话术 + text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 101607); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, subjectName); + } + //通过人物和线索找到对应任务 + DemandTaskDto demandTask = PlayerUtil.getDemandTaskByClueId(subject, clue.getClueId()); + if (!StringUtils.isEmpty(demandTask)) { + //任务非自动触发,返回指定线索 + if (demandTask.getIsAuto() != 1) { + //获取对应话术 + text = SpeechUtil.getSuccessClueSpeech(uid, current, clue); + //任务启动文本 +// text = SpeechUtil.getPreSuccessTaskSpeech(uid, current, demandTask, 4); + //----------------记录线索-------------- + PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue); + //----------------是否解锁任务------------- + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clue); + //记录本轮的任务数据,用于下轮的二次回复 + String unique = uid + player.getGateNo(); + ReplyDto reply = new ReplyDto(); + reply.setSubjectId(subjectId); + reply.setDemandTaskId(demandTask.getDemandTaskId()); + reply.setType(2); //发布任务 + CacheUtil.put(unique, reply, Long.parseLong(expireTime)); + } + } + //如果线索关联自动完成任务,返回任务完成的文本 +// if (subjectId.equals(current.getId())) { +// String addText = PlayerUtil.taskAutoFinish(uid, current, clue); +// text += addText; +// } resultResponse.set反馈ID(102201); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1351,7 +1880,7 @@ public class PlayerServiceImpl implements PlayerService { Integer subjectId = player.getName2IdMap().get(subjectName); if (StringUtils.isEmpty(subjectId)) { //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100008); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100008); resultResponse.set反馈ID(100008); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1367,16 +1896,17 @@ public class PlayerServiceImpl implements PlayerService { } } //当前对话的人物 - Person current = player.getPersonMap().get(player.getPersonId()); + Person current = PlayerUtil.getPerson(uid, player.getPersonId()); //询问对象为对话人 if(StringUtils.isEmpty(subjectName)){ subjectName = current.getName(); } - + //当前对话人 + PersonInfoDto talk = player.getPersonInfoMap().get(player.getPersonId()); if("1023".equals(methodId)){ if(StringUtils.isEmpty(subjectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1385,18 +1915,18 @@ public class PlayerServiceImpl implements PlayerService { Integer subjectId = player.getName2IdMap().get(subjectName); if(StringUtils.isEmpty(subjectId)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100008); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100008); resultResponse.set反馈ID(100008); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - Person subject =player.getPersonMap().get(subjectId); + Person subject = PlayerUtil.getPerson(uid, subjectId); //查找符合条件的线索 List clueList = findClues(current,subject,1); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102303); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102303); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, subjectName); resultResponse.set反馈ID(102303); @@ -1405,24 +1935,24 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList = checkThreshold(current, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102302); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102302); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(102302); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clueList.get(index)); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(102301); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1430,7 +1960,7 @@ public class PlayerServiceImpl implements PlayerService { }else if("1024".equals(methodId)){ if(StringUtils.isEmpty(subjectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1438,19 +1968,19 @@ public class PlayerServiceImpl implements PlayerService { } if(StringUtils.isEmpty(identityName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100006); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100006); resultResponse.set反馈ID(100006); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } Integer subjectId = player.getName2IdMap().get(subjectName); - Person subject =player.getPersonMap().get(subjectId); + Person subject = PlayerUtil.getPerson(uid, subjectId); //查找符合条件的线索 List clueList = findClues(current, subject,1); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102404); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102404); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, identityName); resultResponse.set反馈ID(102404); @@ -1459,23 +1989,24 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList = checkThreshold(current, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102403); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102403); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(102403); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int num = RandomUtil.randomInt(clueList.size()); +// int num = RandomUtil.randomInt(clueList.size()); + int num = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); String context = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(num)); //查找符合条件的线索 clueList = findClues(clueList, identityName); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102402); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102402); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, context); resultResponse.set反馈ID(102402); @@ -1483,14 +2014,14 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); //----------------是否解锁任务------------- - PlayerUtil.unlockTask(uid, subject, clueList.get(index)); + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clueList.get(index)); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(102401); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1520,7 +2051,7 @@ public class PlayerServiceImpl implements PlayerService { Integer subjectId = player.getName2IdMap().get(subjectName); if (StringUtils.isEmpty(subjectId)) { //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100008); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100008); resultResponse.set反馈ID(100008); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1528,28 +2059,40 @@ public class PlayerServiceImpl implements PlayerService { } } //当前对话的人物 - Person current = player.getPersonMap().get(player.getPersonId()); + Person current = PlayerUtil.getPerson(uid, player.getPersonId()); //询问对象为对话人本身 if (StringUtils.isEmpty(subjectName)) { subjectName = current.getName(); } - + //当前对话人 + PersonInfoDto talk = player.getPersonInfoMap().get(player.getPersonId()); if("1025".equals(methodId)){ if(StringUtils.isEmpty(subjectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } Integer subjectId = player.getName2IdMap().get(subjectName); - Person subject =player.getPersonMap().get(subjectId); + Person subject = PlayerUtil.getPerson(uid, subjectId); + //如果询问对象问本人 + if (subjectId.equals(player.getPersonId())) { + //获取对应话术 + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102504); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.seriesLocationMap.get(player.getSeries()).get(subject.getLocation()).getName()); + resultResponse.set反馈ID(102504); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } //查找符合条件的线索 List clueList = findClues(current, subject, 2); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102503); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102503); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, subjectName); resultResponse.set反馈ID(102503); @@ -1558,24 +2101,24 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList = checkThreshold(current, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102502); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102502); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(102502); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); - //----------------是否解锁场所------------- + //----------------解锁场所------------- PlayerUtil.unlockLocation(player.getLocationMap(), subject.getLocation()); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(102501); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1583,7 +2126,7 @@ public class PlayerServiceImpl implements PlayerService { }else if("1026".equals(methodId)){ if(StringUtils.isEmpty(subjectName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100001); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100001); resultResponse.set反馈ID(100001); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1591,20 +2134,20 @@ public class PlayerServiceImpl implements PlayerService { } if(StringUtils.isEmpty(locationName)){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100007); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100007); resultResponse.set反馈ID(100007); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } Integer subjectId = player.getName2IdMap().get(subjectName); - Person subject =player.getPersonMap().get(subjectId); + Person subject = PlayerUtil.getPerson(uid, subjectId); //查找符合条件的线索 List clueList = findClues(current,subject,2); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102604); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102604); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, subjectName); resultResponse.set反馈ID(102604); @@ -1613,23 +2156,24 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.success(resultVarsResponse); } //检查是否符合阈值要求 - clueList = checkThreshold(current, clueList); + clueList = PlayerUtil.checkThresholdTalk(talk, clueList); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102603); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102603); text = SpeechUtil.replaceHeader(text, current.getName()); resultResponse.set反馈ID(102603); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int num = RandomUtil.randomInt(clueList.size()); +// int num = RandomUtil.randomInt(clueList.size()); + int num = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); String context = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(num)); //查找符合条件的线索 clueList = findClues(clueList,locationName); if(clueList.size() == 0){ //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102602); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102602); text = SpeechUtil.replaceHeader(text, current.getName()); text = SpeechUtil.speechReplaceNum(text, context); resultResponse.set反馈ID(102602); @@ -1637,14 +2181,14 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - int index = RandomUtil.randomInt(clueList.size()); +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); //----------------记录线索-------------- PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); - //----------------是否解锁场所------------- + //----------------解锁场所------------- PlayerUtil.unlockLocation(player.getLocationMap(), subject.getLocation()); //获取对应话术 String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); - text = SpeechUtil.addHeader(text, current.getName()); resultResponse.set反馈ID(102601); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1669,8 +2213,10 @@ public class PlayerServiceImpl implements PlayerService { Player player = TimingAcquisition.playerMap.get(uid); //当前对话的人物 - Person current = player.getPersonMap().get(player.getPersonId()); +// Person current = PlayerUtil.getPerson(uid, player.getPersonId()); request.setOperate(Constants.OPERATE_ASK); + //搭档名称 + String partnerName = TimingAcquisition.seriesSystemConfigMap.get(player.getSeries()).get("partnerName").getValue(); if("1027".equals(methodId)){ //当前玩家上一轮的请求信息 OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); @@ -1686,8 +2232,8 @@ public class PlayerServiceImpl implements PlayerService { request.setIndex(index); CacheUtil.put(uid, request, Long.parseLong(expireTime)); //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102701); - text = SpeechUtil.replaceHeader(text, "寒烟"); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102701); + text = SpeechUtil.replaceHeader(text, partnerName); text = SpeechUtil.speechReplaceNum(text, objectName); resultResponse.set反馈ID(102701); resultResponse.set反馈文本(text); @@ -1699,8 +2245,8 @@ public class PlayerServiceImpl implements PlayerService { List personIdList = PlayerUtil.getRelativePersonIds(uid, player.getPersonId()); if (personIdList.size() == 0) { //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102702); - text = SpeechUtil.replaceHeader(text, "寒烟"); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102702); + text = SpeechUtil.replaceHeader(text, partnerName); resultResponse.set反馈ID(102702); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1714,8 +2260,8 @@ public class PlayerServiceImpl implements PlayerService { request.setIndex(index); CacheUtil.put(uid, request, Long.parseLong(expireTime)); //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102701); - text = SpeechUtil.replaceHeader(text, "寒烟"); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102701); + text = SpeechUtil.replaceHeader(text, partnerName); text = SpeechUtil.speechReplaceNum(text, objectName); resultResponse.set反馈ID(102701); resultResponse.set反馈文本(text); @@ -1736,8 +2282,9 @@ public class PlayerServiceImpl implements PlayerService { TimingAcquisition.playerMap.get(uid).setTipFlag(false); TimingAcquisition.playerMap.get(uid).setNumUpdateTime(DateUtil.getCurrentTime()); TimingAcquisition.playerMap.get(uid).setFinishedTaskNum(num); + addText = SpeechUtil.addHeader(addText, partnerName); resultResponse.set反馈ID(102801); - resultResponse.set反馈文本("【寒烟@正常】" + addText); + resultResponse.set反馈文本(addText); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } @@ -1745,9 +2292,9 @@ public class PlayerServiceImpl implements PlayerService { //询问本人地址 if ("1029".equals(methodId)) { //获取对应话术 - String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102901); - text = SpeechUtil.replaceHeader(text, "寒烟"); - text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.locationMap.get(player.getLocation()).getName()); + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 102901); + text = SpeechUtil.replaceHeader(text, partnerName); + text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.seriesLocationMap.get(player.getSeries()).get(player.getLocation()).getName()); resultResponse.set反馈ID(102901); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -1756,7 +2303,87 @@ public class PlayerServiceImpl implements PlayerService { return CommonResult.failed("询问提示失败!"); } + @Override + public CommonResult askFinalClue(OperationRequest request) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = request.getUid(); + String methodId = request.getMethodId(); + String subjectName = request.getSubjectName(); + String taskConditionId = request.getTaskConditionId(); + + //当前玩家上一轮的请求信息 + OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); + if (!StringUtils.isEmpty(lastReq)) { + if ("她".equals(subjectName) || "他".equals(subjectName) || "它".equals(subjectName)) { + subjectName = lastReq.getSubjectName(); + } + } + Player player = TimingAcquisition.playerMap.get(uid); + //当前对话的人物 + Person current = PlayerUtil.getPerson(uid, player.getPersonId()); + //询问对象为对话人 + if(StringUtils.isEmpty(subjectName)){ + subjectName = current.getName(); + } + Integer subjectId = player.getName2IdMap().get(subjectName); + //该关卡没有这个人物 + if(StringUtils.isEmpty(subjectId)){ + //获取对应话术 + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_ASIDE, 100008); + resultResponse.set反馈ID(100008); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + Person subject = PlayerUtil.getPerson(uid, subjectId); + //询问最终线索 + if ("1030".equals(methodId)) { + //查找符合条件的任务 + List clueList = PlayerUtil.getClueByConditionTaskId(uid, subjectId, taskConditionId); + if(clueList.size() == 0){ + //获取对应话术 + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 103003); + text = SpeechUtil.replaceHeader(text, current.getName()); + resultResponse.set反馈ID(103003); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //检查线索是否符合阈值要求 + clueList = PlayerUtil.checkTaskThreshold(uid, clueList); + if(clueList.size()==0){ + //获取对应话术 + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 103002); + text = SpeechUtil.replaceHeader(text, current.getName()); + resultResponse.set反馈ID(103002); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } +// int index = RandomUtil.randomInt(clueList.size()); + int index = PlayerUtil.getNumByMethodId(uid, methodId, clueList.size()); + //----------------记录线索-------------- + PlayerUtil.recordClue(uid, current.getId(), subjectId, clueList.get(index).getType(), clueList.get(index)); + //----------------是否解锁任务------------- + PlayerUtil.unlockTask(uid, player.getPersonInfoMap().get(subjectId), clueList.get(index)); + //获取对应话术 + String text = SpeechUtil.getSuccessClueSpeech(uid, current, clueList.get(index)); + resultResponse.set反馈ID(103001); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //获取对应话术 + String text = SpeechUtil.getAskSpeech(uid, Constants.SPEECH_PERSON, 103003); + text = SpeechUtil.addHeader(text, current.getName()); + resultResponse.set反馈ID(103003); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } /** @@ -1768,140 +2395,83 @@ public class PlayerServiceImpl implements PlayerService { ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); - String sid = request.getUid(); + String uid = request.getUid(); String methodId = request.getMethodId(); String taskConditionId = request.getTaskConditionId(); - Player player = TimingAcquisition.playerMap.get(sid); + Player player = TimingAcquisition.playerMap.get(uid); Integer subjectId = player.getPersonId(); //当前对话的人物 - Person subject = player.getPersonMap().get(subjectId); + Person subject = PlayerUtil.getPerson(uid, subjectId); + //当前对话人 + PersonInfoDto talk = player.getPersonInfoMap().get(subjectId); //第三人称 - Integer gender = player.getPersonMap().get(subjectId).getGender(); + Integer gender = subject.getGender(); String call = (gender == 1) ? "他" : "她"; + //允许执行的任务类型 + List allowTask = Arrays.asList(-2, 0, 5); //货币配置名称 - String moneyName = TimingAcquisition.systemConfigMap.get("money").getValue(); -// if(StringUtils.isEmpty(taskConditionId)){ -// //获取对应话术 -// String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200001); -// text = SpeechUtil.replaceHeader(text, subject.getName()); -// resultResponse.set反馈ID(200001); -// resultResponse.set反馈文本(text); -// resultVarsResponse.setVars(resultResponse); -// return CommonResult.success(resultVarsResponse); -// } - if("2001".equals(methodId)){ + String moneyName = TimingAcquisition.seriesSystemConfigMap.get(player.getSeries()).get("money").getValue(); + String unique = uid + player.getGateNo(); //用户uid和关卡编号组成唯一标识 +// //1.无后置任务,不能重复扣钱 +// List methodIdList = Arrays.asList("2002", "2003", "2004", "2005", "2006", "2009", +// "2010", "2011", "2013", "2014", "2016", "2017", "2018", "2019", "2020", "2021", "2022", +// "2023", "2024", "2026", "2030","2032", "2034", "2035", "2037", "2042", "2044"); +// //2.无后置任务,且能重复扣钱 +// List methodIdCostList = Arrays.asList("2007", "2008", "2015"); +// //3.有后置任务 +// List methodIdWithPreList = Arrays.asList("2025", "2027", "2028", "2029", "2031", +// "2033", "2036", "2038", "2039", "2040", "2041"); + //4.任务成功操作拆分的任务 + List methodIdSplitList = Arrays.asList("204301", "204302", "204303", "204304", "204305"); + int operateType = 0; + if (!StringUtils.isEmpty(taskConditionId)) { + methodId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(taskConditionId)).getMethodId().toString(); + operateType = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(taskConditionId)).getType(); + } + //1.货币数量判断、阈值判断 + if (operateType == 1) { if(!StringUtils.isEmpty(subject)){ List demandTaskList = subject.getDemandTasks(); for (DemandTaskDto demandTask : demandTaskList) { if (subjectId.equals(demandTask.getSubject())) { String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { + Integer clueSwitch = talk.getDemandTaskSwitchMap().get(demandTask.getDemandTaskId()); + if (condition1[0].equals(taskConditionId) && allowTask.contains(clueSwitch)) { //条件判断 // 1. 判断是否满足货币消费条件 - String condition2 = demandTask.getCondition2(); + String cost = demandTask.getCost(); int value = 0; - if (!StringUtils.isEmpty(condition2)) { - value = Integer.parseInt(condition2); - if (player.getCurrency() < value) { + int costFlag = 1; + if (!StringUtils.isEmpty(cost)) { + String[] costList = cost.split("\\|"); + value = Integer.parseInt(costList[0]); + costFlag = Integer.parseInt(costList[1]); + int money = TimingAcquisition.seriesPlayerMap.get(player.getSeries()).get(uid).getMoney(); + if (money < value) { + int feedBackId = Integer.parseInt(methodId + "04"); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 200104); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "04"); text = SpeechUtil.replaceHeader(text, subject.getName()); - text = SpeechUtil.speechReplaceNum(text, String.valueOf(value), moneyName); - resultResponse.set反馈ID(200104); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - // 2. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200105); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200105); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } else { - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 200102); - String personText = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200102); - text = SpeechUtil.replaceHeader(personText, subject.getName()); - text = SpeechUtil.speechReplaceNum(text, personText, subject.getName()); - resultResponse.set反馈ID(200102); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200101); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200101); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } } - } - } - } - //玩家没有挂相关任务 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200106); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200106); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2002".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); + // 2. 判断是否符合阈值需求 + boolean flag = PlayerUtil.checkThreshold(uid, demandTask, talk); //不符合阈值需求 if (!flag) { + int feedBackId = Integer.parseInt(methodId + "03"); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 200203); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200203); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "03"); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200203); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); @@ -1909,37 +2479,122 @@ public class PlayerServiceImpl implements PlayerService { //2.符合阈值需求,判断是否已达次数上限 Map> taskMap = player.getTaskMap(); if (taskMap.containsKey(subjectId)) { + //可以重复扣钱 + if (costFlag == 0) { + //扣除货币 + if (value > 0) { + PlayerUtil.updateMoneyNum(uid, value); + } + } Map map = taskMap.get(subjectId); if (map.containsKey(demandTask.getDemandTaskId())) { int num = map.get(demandTask.getDemandTaskId()); - if (num >= Integer.parseInt(condition1[1])) { - //符合阈值需求,已达次数上限 + //符合阈值需求,已达次数上限 + if (num >= demandTask.getEffectiveDegree()) { + int feedBackId = Integer.parseInt(methodId + "02"); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200202); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "02"); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200202); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - // 3.信任阈值提升 + int feedBackId = Integer.parseInt(methodId + "01"); + //任务完成 map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - //ThreadLocalUtil.add(sid,player); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); + //信任阈值提升 + PlayerUtil.addThreshold(talk, demandTask); + //增加声望值 + PlayerUtil.updateReputation(player, demandTask.getReputation()); + //更新时间值 + PlayerUtil.updateInitTime(player, demandTask.getCostTime()); + //更新生命状态 + PlayerUtil.updateLifeState(player.getPersonInfoMap().get(subjectId), demandTask.getLifeState()); + //不可以重复扣钱 + if (costFlag == 1) { + //扣除货币 + if (value > 0) { + PlayerUtil.updateMoneyNum(uid, value); + } + } + //ThreadLocalUtil.add(uid,player); +// PersistenceUtil.saveDataToFile(userFilePath, uid, JSON.toJSONString(player)); //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200201); + String text = SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask); + if (!StringUtils.isEmpty(CacheUtil.get(unique))) { + //清除缓存 + CacheGlobal.concurrentMap.remove(unique); + } + //任务链下一个任务的对应回复 + CommonResult result = PlayerUtil.getNextTaskAnswer(uid, subjectId, demandTask.getDemandTaskId()); + if (!StringUtils.isEmpty(result.getMessage())) { + text += result.getMessage(); + //任务链下一任务启动 + PlayerUtil.startTaskOnNext(uid, demandTask.getDemandTaskId()); + DemandTaskDto nextDemandTask = result.getData(); + //存在任务链下一个 + if (!StringUtils.isEmpty(nextDemandTask)) { + //返回下一个任务对应的后台附加返回给bot端 + String[] condition = nextDemandTask.getCondition1().split("\\|"); + Integer methodIdNext = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition[0])).getMethodId(); + resultResponse.set后台附加返回(methodIdNext.toString()); + } + } + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTask.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); + } + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } + int feedBackId = Integer.parseInt(methodId + "01"); // 3.信任阈值提升 map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); + addThreshold(talk, demandTask); + //增加声望值 + PlayerUtil.updateReputation(player, demandTask.getReputation()); + //更新时间值 + PlayerUtil.updateInitTime(player, demandTask.getCostTime()); + //更新生命状态 + PlayerUtil.updateLifeState(player.getPersonInfoMap().get(subjectId), demandTask.getLifeState()); //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200201); + String text = SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask); + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTask.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); + } + if (!StringUtils.isEmpty(CacheUtil.get(unique))) { + //清除缓存 + CacheGlobal.concurrentMap.remove(unique); + } + //任务链下一个任务的对应回复 + CommonResult result = PlayerUtil.getNextTaskAnswer(uid, subjectId, demandTask.getDemandTaskId()); + if (!StringUtils.isEmpty(result.getMessage())) { + text += result.getMessage(); + //任务链下一任务启动 + PlayerUtil.startTaskOnNext(uid, demandTask.getDemandTaskId()); + DemandTaskDto nextDemandTask = result.getData(); + //存在任务链下一个 + if (!StringUtils.isEmpty(nextDemandTask)) { + //返回下一个任务对应的后台附加返回给bot端 + String[] condition = nextDemandTask.getCondition1().split("\\|"); + Integer methodIdNext = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition[0])).getMethodId(); + resultResponse.set后台附加返回(methodIdNext.toString()); + } + } + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTask.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); + } + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); @@ -1947,3375 +2602,613 @@ public class PlayerServiceImpl implements PlayerService { } } } + int feedBackId = Integer.parseInt(methodId + "05"); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200204); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, taskConditionId, "05"); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200204); + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - }else if("2003".equals(methodId)){ + } + + //2.阈值判断、主副任务或者前后置任务 + if (operateType == 2) { if(!StringUtils.isEmpty(subject)){ List demandTaskList = subject.getDemandTasks(); for (DemandTaskDto demandTask : demandTaskList) { if (subjectId.equals(demandTask.getSubject())) { String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { + Integer clueSwitch = talk.getDemandTaskSwitchMap().get(demandTask.getDemandTaskId()); + if (condition1[0].equals(taskConditionId) && allowTask.contains(clueSwitch)) { //条件判断 // 1. 判断是否满足货币消费条件 - String condition2 = demandTask.getCondition2(); + String cost = demandTask.getCost(); int value = 0; - if (!StringUtils.isEmpty(condition2)) { - value = Integer.parseInt(condition2); - if (player.getCurrency() < value) { + int costFlag = 1; + if (!StringUtils.isEmpty(cost)) { + String[] costList = cost.split("\\|"); + value = Integer.parseInt(costList[0]); + costFlag = Integer.parseInt(costList[1]); + int money = TimingAcquisition.seriesPlayerMap.get(player.getSeries()).get(uid).getMoney(); + if (money < value) { + int feedBackId = Integer.parseInt(methodId + "04"); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200303); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "04"); text = SpeechUtil.replaceHeader(text, subject.getName()); - text = SpeechUtil.speechReplaceNum(text, String.valueOf(value)); - resultResponse.set反馈ID(200303); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } } - // 2. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); + // 1. 判断是否符合阈值需求 + boolean flag = PlayerUtil.checkThreshold(uid, demandTask, talk); //不符合阈值需求 if (!flag) { + int feedBackId = Integer.parseInt(methodId + "04"); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200304); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "04"); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200304); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); - } else { - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 200102); - String personText = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200102); - personText = SpeechUtil.replaceHeader(personText, subject.getName()); - text = SpeechUtil.speechReplaceNum(text, subject.getName(), personText); - resultResponse.set反馈ID(200102); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - //ThreadLocalUtil.add(sid,player); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); + } + //判断任务是否为满足条件的副任务,在副任务完成的同时自动完成主任务(主任务配置71001) + Map personIdTaskIdMap = PlayerUtil.checkTaskIsSub(uid, subjectId, demandTask.getDemandTaskId()); + //为副任务,能自动完成主任务 + if (personIdTaskIdMap.size() != 0) { + for (Map.Entry entry : personIdTaskIdMap.entrySet()) { + if (entry.getValue() >= 0) { + int feedBackId = Integer.parseInt(methodId + "01"); + //副任务完成 + PlayerUtil.taskFinished(uid, subjectId, demandTask.getDemandTaskId()); //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200301); + String text = SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask); + //满足条件,能自动完成主任务 + if (entry.getValue() > 0) { + //主任务完成 + PlayerUtil.taskFinished(uid, entry.getKey(), entry.getValue()); + } + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTask.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); + } + if (!StringUtils.isEmpty(CacheUtil.get(unique))) { + //清除缓存 + CacheGlobal.concurrentMap.remove(unique); + } + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - resultResponse.set反馈ID(200301); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200305); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200305); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2004".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否满足货币消费条件 - String condition2 = demandTask.getCondition2(); - int value = 0; - if (!StringUtils.isEmpty(condition2)) { - value = Integer.parseInt(condition2); - if (player.getCurrency() < value) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200403); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - resultResponse.set反馈ID(200403); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); } - } - // 2. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200404); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200404); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } else { - //2.符合阈值需求,判断是否已达次数上限 + } else { //为主任务 Map> taskMap = player.getTaskMap(); + //2.符合阈值需求,判断是否完成副任务 if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); + Map subjectMap = taskMap.get(subjectId); + if (subjectMap.containsKey(demandTask.getDemandTaskId())) { + int num = subjectMap.get(demandTask.getDemandTaskId()); + Integer objectId = demandTask.getObject(); //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { + if (num >= demandTask.getEffectiveDegree()) { + int feedBackId = Integer.parseInt(methodId + "02"); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200402); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "02"); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200402); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); + //该任务没有配置副任务,当作单独任务完成处理 + if (StringUtils.isEmpty(demandTask.getPostTask())) { + int feedBackId = Integer.parseInt(methodId + "01"); + //任务完成 + PlayerUtil.taskFinished(uid, subjectId, demandTask.getDemandTaskId()); + //获取对应话术 + String text = SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask); + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTask.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); + } + if (!StringUtils.isEmpty(CacheUtil.get(unique))) { + //清除缓存 + CacheGlobal.concurrentMap.remove(unique); + } + //任务链下一个任务的对应回复 + CommonResult result = PlayerUtil.getNextTaskAnswer(uid, subjectId, demandTask.getDemandTaskId()); + if (!StringUtils.isEmpty(result.getMessage())) { + text += result.getMessage(); + //任务链下一任务启动 + PlayerUtil.startTaskOnNext(uid, demandTask.getDemandTaskId()); + DemandTaskDto nextDemandTask = result.getData(); + //存在任务链下一个 + if (!StringUtils.isEmpty(nextDemandTask)) { + //返回下一个任务对应的后台附加返回给bot端 + String[] condition = nextDemandTask.getCondition1().split("\\|"); + Integer methodIdNext = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition[0])).getMethodId(); + resultResponse.set后台附加返回(methodIdNext.toString()); + } + } + resultResponse.set反馈ID(feedBackId); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + Map objectMap = taskMap.get(objectId); + if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { + int feedBackId = Integer.parseInt(methodId + "01"); + //任务完成 + subjectMap.put(demandTask.getDemandTaskId(), num + 1); + PlayerUtil.addThreshold(talk, demandTask); + //增加声望值 + PlayerUtil.updateReputation(player, demandTask.getReputation()); + //更新时间值 + PlayerUtil.updateInitTime(player, demandTask.getCostTime()); + //更新生命状态 + PlayerUtil.updateLifeState(player.getPersonInfoMap().get(subjectId), demandTask.getLifeState()); + //可以重复扣钱 + if (costFlag == 0) { + //扣除货币 + if (value > 0) { + PlayerUtil.updateMoneyNum(uid, value); + } + } + //获取对应话术 + String text = SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask); + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTask.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); + } + if (!StringUtils.isEmpty(CacheUtil.get(unique))) { + //清除缓存 + CacheGlobal.concurrentMap.remove(unique); + } + //任务链下一个任务的对应回复 + CommonResult result = PlayerUtil.getNextTaskAnswer(uid, subjectId, demandTask.getDemandTaskId()); + if (!StringUtils.isEmpty(result.getMessage())) { + text += result.getMessage(); + //任务链下一任务启动 + PlayerUtil.startTaskOnNext(uid, demandTask.getDemandTaskId()); + DemandTaskDto nextDemandTask = result.getData(); + //存在任务链下一个 + if (!StringUtils.isEmpty(nextDemandTask)) { + //返回下一个任务对应的后台附加返回给bot端 + String[] condition = nextDemandTask.getCondition1().split("\\|"); + Integer methodIdNext = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition[0])).getMethodId(); + resultResponse.set后台附加返回(methodIdNext.toString()); + } + } + resultResponse.set反馈ID(feedBackId); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //符合阈值需求,副任务没有完成 + int feedBackId = Integer.parseInt(methodId + "03"); //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200401); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "03"); + text = SpeechUtil.replaceHeader(text, subject.getName()); + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200401); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200405); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200405); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2005".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200503); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200503); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200502); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200502); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200501); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200501); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200504); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200504); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2006".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200603); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 200603); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - resultResponse.set反馈ID(200603); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200602); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 200602); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - resultResponse.set反馈ID(200602); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - //ThreadLocalUtil.add(sid,player); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200601); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200601); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200604); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200604); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2007".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否满足货币消费条件 - String condition2 = demandTask.getCondition2(); - int value = 0; - if (!StringUtils.isEmpty(condition2)) { - value = Integer.parseInt(condition2); - if (player.getCurrency() < value) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 200703); - text = SpeechUtil.speechReplaceNum(text, String.valueOf(value)); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200703); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200703); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - // 2. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200704); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200704); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 200702); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200702); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200702); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200701); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200701); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200705); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200705); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2008".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否满足货币消费条件 - String condition2 = demandTask.getCondition2(); - int value = 0; - if (!StringUtils.isEmpty(condition2)) { - value = Integer.parseInt(condition2); - if (player.getCurrency() < value) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 200803); - text = SpeechUtil.speechReplaceNum(text, String.valueOf(value)); - resultResponse.set反馈ID(200803); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - // 2. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 200804); - text = SpeechUtil.speechReplaceNum(text, String.valueOf(value), subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200804); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200804); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String personText = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200802); - personText = SpeechUtil.replaceHeader(personText, subject.getName()); - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 200802); - text = SpeechUtil.speechReplaceNum(text, String.valueOf(value), subject.getName(), personText); - resultResponse.set反馈ID(200802); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200801); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200801); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200805); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200805); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2009".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200903); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200903); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200902); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 200902); - text = SpeechUtil.speechReplaceNum(text, subject.getName(), call); - resultResponse.set反馈ID(200902); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - //玩家数据持久化 -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200901); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - //玩家数据持久化 -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(200901); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200904); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(200904); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2010".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201003); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201003); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - //获得的奖励 - String completionReward = demandTask.getCompletionReward(); - int value = 0; - if (!StringUtils.isEmpty(completionReward)) { - value = Integer.parseInt(completionReward); - } - if (taskMap.containsKey(subjectId)) { - //增加货币 - PlayerUtil.addMoneyNum(sid, value); - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201002); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 201002); - text = SpeechUtil.speechReplaceNum(text, subject.getName(), String.valueOf(value)); - resultResponse.set反馈ID(201002); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - for (DemandTaskDto task : demandTaskList) { - if (task.getDemandTaskId() == demandTask.getDemandTaskId()) { - map.put(demandTask.getDemandTaskId(), num + 1); - } - } - //玩家数据持久化 -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201001); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - for (DemandTaskDto task : demandTaskList) { - if (task.getDemandTaskId() == demandTask.getDemandTaskId()) { - map.put(demandTask.getDemandTaskId(), 1); - } - } -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201001); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201004); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201004); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2011".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201103); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201103); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201102); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201102); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - //------玩家数据持久化------ -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201101); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - //------玩家数据持久化------ -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201101); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201104); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201104); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2012".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = PlayerUtil.findDemandsByTaskId(subject, subjectId, taskConditionId); - int count = 0; - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - count++; - if (count < demandTaskList.size()) { - int taskStatus = PlayerUtil.checkTaskStatus(sid, subjectId, demandTask.getDemandTaskId()); - if (taskStatus == 1) { - continue; - } - } - //条件判断 - // 1. 判断是否满足货币消费条件 - String condition2 = demandTask.getCondition2(); - int value = 0; - if (!StringUtils.isEmpty(condition2)) { - value = Integer.parseInt(condition2); - if (player.getCurrency() < value) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 201203); - resultResponse.set反馈ID(201203); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - // 2. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201204); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201204); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201202); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 201202); - text = SpeechUtil.speechReplaceNum(text, subject.getName(), call); - resultResponse.set反馈ID(201202); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201201); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201201); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201205); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201205); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2013".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否满足货币消费条件 - String condition2 = demandTask.getCondition2(); - int value = 0; - if (!StringUtils.isEmpty(condition2)) { - value = Integer.parseInt(condition2); - if (player.getCurrency() < value) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201303); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text = SpeechUtil.speechReplaceNum(text, String.valueOf(value)); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 201303); - text = SpeechUtil.speechReplaceNum(text, String.valueOf(value)); - resultResponse.set反馈ID(201303); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - // 2. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201304); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201304); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201302); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201302); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201301); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201301); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201305); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201305); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2014".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否满足货币消费条件 - String condition2 = demandTask.getCondition2(); - int value = 0; - if (!StringUtils.isEmpty(condition2)) { - value = Integer.parseInt(condition2); - if (player.getCurrency() < value) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201403); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201403); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - // 2. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201404); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201404); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201402); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201402); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201401); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - //-------玩家数据持久化-------- -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201401); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201405); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201405); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2015".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否满足货币消费条件 - String condition2 = demandTask.getCondition2(); - int value = 0; - if (!StringUtils.isEmpty(condition2)) { - value = Integer.parseInt(condition2); - if (player.getCurrency() < value) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201503); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201503); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - // 2. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201504); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201504); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201502); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 201502); - text = SpeechUtil.speechReplaceNum(text, subject.getName(), call); - resultResponse.set反馈ID(201502); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - //------玩家数据持久化-------- -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201501); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201501); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201505); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201505); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2016".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否满足货币消费条件 - String condition2 = demandTask.getCondition2(); - int value = 0; - if (!StringUtils.isEmpty(condition2)) { - value = Integer.parseInt(condition2); - if (player.getCurrency() < value) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201603); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text = SpeechUtil.speechReplaceNum(text, String.valueOf(value)); - resultResponse.set反馈ID(201603); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - // 2. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201604); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201604); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201602); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201602); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - //------玩家数据持久化------ -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201601); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - //------玩家数据持久化------ -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201601); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201605); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201605); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2017".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201703); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201703); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201702); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201702); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - //------玩家数据持久化------- -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201701); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - //------玩家数据持久化------- -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201701); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201704); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201704); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2018".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201803); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201803); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201802); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201802); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - //-----玩家数据持久化----- -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201801); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - //-----玩家数据持久化----- -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201801); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201804); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201804); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2019".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201903); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201903); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= Integer.parseInt(condition1[1])) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201902); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201902); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - //------玩家数据持久化------- -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201901); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - //------玩家数据持久化------- -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); - //ThreadLocalUtil.add(sid,player); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(201901); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 201904); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(201904); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } else if ("2020".equals(methodId)) { - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202003); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202003); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202002); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202002); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - PlayerUtil.addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //最终任务完成 - player.setFinished(1); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202001); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //最终任务完成 - player.setFinished(1); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202001); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202004); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202004); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } else if ("2021".equals(methodId)) { - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202103); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202103); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202102); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202102); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //最终任务完成 - player.setFinished(1); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202101); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //最终任务完成 - player.setFinished(1); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202101); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202104); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202104); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2022".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202203); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202203); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202202); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202202); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //最终任务完成 - player.setFinished(1); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202201); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //最终任务完成 - player.setFinished(1); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202201); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202204); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202204); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2023".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202303); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202303); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202302); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202302); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //最终任务完成 - player.setFinished(1); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202301); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //最终任务完成 - player.setFinished(1); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202301); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202304); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202304); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2024".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否满足货币消费条件 - String condition2 = demandTask.getCondition2(); - int value = 0; - if (!StringUtils.isEmpty(condition2)) { - value = Integer.parseInt(condition2); - if (player.getCurrency() < value) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202403); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text = SpeechUtil.speechReplaceNum(text, String.valueOf(value)); - resultResponse.set反馈ID(202403); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - // 2. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202404); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202404); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202402); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text = SpeechUtil.speechReplaceNum(text, demandTask.getName()); - resultResponse.set反馈ID(202402); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - double currency = player.getCurrency(); - addThreshold(subject, demandTask); - if (value > 0) { - player.setCurrency(currency - value); - } - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202401); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - double currency = player.getCurrency(); - addThreshold(subject, demandTask); - if (value > 0) { - player.setCurrency(currency - value); - } - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202401); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202405); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202405); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2025".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 202504); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202504); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202504); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Map> taskMap = player.getTaskMap(); - //2.符合阈值需求,判断是否完成后置任务 - if (taskMap.containsKey(subjectId)) { - Map subjectMap = taskMap.get(subjectId); - if (subjectMap.containsKey(demandTask.getDemandTaskId())) { - int num = subjectMap.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202502); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202502); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - if (!StringUtils.isEmpty(demandTask.getPostTask())) { - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202501); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202503); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202503); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202501); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202503); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202503); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202506); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202506); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2026".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 202604); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202604); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202604); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Map> taskMap = player.getTaskMap(); - //2.符合阈值需求,判断是否完成后置任务 - if (taskMap.containsKey(subjectId)) { - Map subjectMap = taskMap.get(subjectId); - if (subjectMap.containsKey(demandTask.getDemandTaskId())) { - int num = subjectMap.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202602); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202602); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - if (!StringUtils.isEmpty(demandTask.getPostTask())) { - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202601); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202603); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202603); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - String[] postTasks = demandTask.getPostTask().split("\\|"); - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - for (String postTask : postTasks) { - if (objectMap.containsKey(Integer.parseInt(postTask))) { - subjectMap.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202601); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202603); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202603); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202605); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202605); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2027".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 202704); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202704); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202704); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } else { - Map> taskMap = player.getTaskMap(); - //2.符合阈值需求,判断是否完成后置任务 - if (taskMap.containsKey(subjectId)) { - Map subjectMap = taskMap.get(subjectId); - if (subjectMap.containsKey(demandTask.getDemandTaskId())) { - int num = subjectMap.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202702); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202702); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - if (!StringUtils.isEmpty(demandTask.getPostTask())) { - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202701); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202703); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202703); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - List list = new ArrayList<>(); - list.add(demandTask); - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202701); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202703); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202703); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202705); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202705); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2028".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 202804); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202804); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202804); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Map> taskMap = player.getTaskMap(); - //2.符合阈值需求,判断是否完成后置任务 - if (taskMap.containsKey(subjectId)) { - Map subjectMap = taskMap.get(subjectId); - if (subjectMap.containsKey(demandTask.getDemandTaskId())) { - int num = subjectMap.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202802); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202802); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - if (!StringUtils.isEmpty(demandTask.getPostTask())) { - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202801); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202803); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202803); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202801); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202803); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202803); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202805); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202805); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2029".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202904); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202904); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Map> taskMap = player.getTaskMap(); - //2.符合阈值需求,判断是否完成后置任务 - if (taskMap.containsKey(subjectId)) { - Map subjectMap = taskMap.get(subjectId); - if (subjectMap.containsKey(demandTask.getDemandTaskId())) { - int num = subjectMap.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202902); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202902); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - if (!StringUtils.isEmpty(demandTask.getPostTask())) { - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202901); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202903); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202903); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(202901); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202903); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202903); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 202905); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(202905); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2030".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203003); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203003); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203002); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203002); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203001); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203001); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203004); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - resultResponse.set反馈ID(203004); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2031".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203104); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203104); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Map> taskMap = player.getTaskMap(); - //2.符合阈值需求,判断是否完成后置任务 - if (taskMap.containsKey(subjectId)) { - Map subjectMap = taskMap.get(subjectId); - if (subjectMap.containsKey(demandTask.getDemandTaskId())) { - int num = subjectMap.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203102); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203102); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203101); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203103); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203103); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203101); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203103); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203103); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203105); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203105); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2032".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203203); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 203203); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - resultResponse.set反馈ID(203203); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203202); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203202); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203201); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203201); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203204); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203204); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2033".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203304); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203304); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Map> taskMap = player.getTaskMap(); - //2.符合阈值需求,判断是否完成后置任务 - if (taskMap.containsKey(subjectId)) { - Map subjectMap = taskMap.get(subjectId); - if (subjectMap.containsKey(demandTask.getDemandTaskId())) { - int num = subjectMap.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203302); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203302); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203301); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203303); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203303); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203301); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203303); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203303); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203305); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203305); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2034".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203403); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text += SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 203403); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - resultResponse.set反馈ID(203403); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203402); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203402); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203401); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203401); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203404); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203404); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2035".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203504); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 203504); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - resultResponse.set反馈ID(203504); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Map> taskMap = player.getTaskMap(); - //2.符合阈值需求,判断是否已达次数上限 - if (taskMap.containsKey(subjectId)) { - Map map =taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - addThreshold(subject, demandTask); - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203502); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text = SpeechUtil.speechReplaceNum(text, subject.getName(), - String.valueOf(subject.getTrustDegree()), String.valueOf(subject.getDeterrenceDegree()), - demandTask.getCompletionReward()); - resultResponse.set反馈ID(203502); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(),num+1); - int trustDegree = subject.getTrustDegree(); - int deterrenceDegree = subject.getDeterrenceDegree(); - double currency = player.getCurrency(); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203501); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(),1); - addThreshold(subject,demandTask); - if(!StringUtils.isEmpty(demandTask.getCompletionReward())){ - player.setCurrency(player.getCurrency()+Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203501); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203505); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203505); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2036".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203604); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203604); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Map> taskMap = player.getTaskMap(); - //2.符合阈值需求,判断是否完成后置任务 - if (taskMap.containsKey(subjectId)) { - Map subjectMap = taskMap.get(subjectId); - if (subjectMap.containsKey(demandTask.getDemandTaskId())) { - int num = subjectMap.get(demandTask.getDemandTaskId()); Integer objectId = demandTask.getObject(); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203602); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text = SpeechUtil.speechReplaceNum(text, subject.getName(), PlayerUtil.getNameByPersonId(sid, objectId), - String.valueOf(subject.getTrustDegree()), String.valueOf(subject.getDeterrenceDegree()), - demandTask.getCompletionReward()); - resultResponse.set反馈ID(203602); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } Map objectMap = taskMap.get(objectId); if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); + int feedBackId = Integer.parseInt(methodId + "01"); + //任务完成 + subjectMap.put(demandTask.getDemandTaskId(), 1); + PlayerUtil.addThreshold(talk, demandTask); + //增加声望值 + PlayerUtil.updateReputation(player, demandTask.getReputation()); + //更新时间值 + PlayerUtil.updateInitTime(player, demandTask.getCostTime()); + //更新生命状态 + PlayerUtil.updateLifeState(player.getPersonInfoMap().get(subjectId), demandTask.getLifeState()); + //可以重复扣钱 + if (costFlag == 0) { + //扣除货币 + if (value > 0) { + PlayerUtil.updateMoneyNum(uid, value); + } } //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203601); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203603); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203603); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203601); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203603); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203603); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203606); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203606); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2037".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203703); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203703); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //2.符合阈值需求,判断是否已达次数上限 - Map> taskMap = player.getTaskMap(); - if (taskMap.containsKey(subjectId)) { - Map map = taskMap.get(subjectId); - if (map.containsKey(demandTask.getDemandTaskId())) { - int num = map.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203702); - text = SpeechUtil.replaceHeader(text, subject.getName()); - text = SpeechUtil.speechReplaceNum(text, subject.getName(), - String.valueOf(subject.getTrustDegree()), String.valueOf(subject.getDeterrenceDegree())); - resultResponse.set反馈ID(203702); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203701); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203701); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - } - } - } - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203705); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203705); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - }else if("2038".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); - for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203804); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203804); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Map> taskMap = player.getTaskMap(); - //2.符合阈值需求,判断是否完成后置任务 - if (taskMap.containsKey(subjectId)) { - Map subjectMap = taskMap.get(subjectId); - if (subjectMap.containsKey(demandTask.getDemandTaskId())) { - int num = subjectMap.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203802); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203802); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); + String text = SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask); + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTask.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203801); + if (!StringUtils.isEmpty(CacheUtil.get(unique))) { + //清除缓存 + CacheGlobal.concurrentMap.remove(unique); + } + //任务链下一个任务的对应回复 + CommonResult result = PlayerUtil.getNextTaskAnswer(uid, subjectId, demandTask.getDemandTaskId()); + if (!StringUtils.isEmpty(result.getMessage())) { + text += result.getMessage(); + //任务链下一任务启动 + PlayerUtil.startTaskOnNext(uid, demandTask.getDemandTaskId()); + DemandTaskDto nextDemandTask = result.getData(); + //存在任务链下一个 + if (!StringUtils.isEmpty(nextDemandTask)) { + //返回下一个任务对应的后台附加返回给bot端 + String[] condition = nextDemandTask.getCondition1().split("\\|"); + Integer methodIdNext = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition[0])).getMethodId(); + resultResponse.set后台附加返回(methodIdNext.toString()); + } + } + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203803); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203803); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); } + //符合阈值需求,副任务没有完成 + int feedBackId = Integer.parseInt(methodId + "03"); //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203801); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "03"); + text = SpeechUtil.replaceHeader(text, subject.getName()); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203803); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203803); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); } } } } + int feedBackId = Integer.parseInt(methodId + "05"); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203805); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, taskConditionId, "05"); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203805); + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - }else if("2039".equals(methodId)){ - if(!StringUtils.isEmpty(subject)){ + } + + //3.任务直接完成 + if (operateType == 3) { + if (!StringUtils.isEmpty(subject)) { List demandTaskList = subject.getDemandTasks(); for (DemandTaskDto demandTask : demandTaskList) { - if (subjectId.equals(demandTask.getSubject())) { - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { - //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203904); + String[] condition1 = demandTask.getCondition1().split("\\|"); + Integer clueSwitch = talk.getDemandTaskSwitchMap().get(demandTask.getDemandTaskId()); + if (condition1[0].equals(taskConditionId) && allowTask.contains(clueSwitch)) { + //任务完成,数据更新 + PlayerUtil.taskFinished(uid, subjectId, demandTask.getDemandTaskId()); + String text = SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask); + if (!StringUtils.isEmpty(CacheUtil.get(unique))) { + //清除缓存 + CacheGlobal.concurrentMap.remove(unique); + } + //任务链下一个任务的对应回复 + CommonResult result = PlayerUtil.getNextTaskAnswer(uid, subjectId, demandTask.getDemandTaskId()); + if (!StringUtils.isEmpty(result.getMessage())) { + text += result.getMessage(); + //任务链下一任务启动 + PlayerUtil.startTaskOnNext(uid, demandTask.getDemandTaskId()); + DemandTaskDto nextDemandTask = result.getData(); + //存在任务链下一个 + if (!StringUtils.isEmpty(nextDemandTask)) { + //返回下一个任务对应的后台附加返回给bot端 + String[] condition = nextDemandTask.getCondition1().split("\\|"); + Integer methodIdNext = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition[0])).getMethodId(); + resultResponse.set后台附加返回(methodIdNext.toString()); + } + } + //判断任务是否为满足条件的副任务,在副任务完成的同时自动完成主任务(主任务配置71001) + Map personIdTaskIdMap = PlayerUtil.checkTaskIsSub(uid, subjectId, demandTask.getDemandTaskId()); + //为副任务,能自动完成主任务 + if (personIdTaskIdMap.size() != 0) { + for (Map.Entry entry : personIdTaskIdMap.entrySet()) { + if (entry.getValue() > 0) { + //主任务完成 + PlayerUtil.taskFinished(uid, entry.getKey(), entry.getValue()); + } + } + } + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTask.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); + } + int feedBackId = Integer.parseInt(methodId + "01"); + resultResponse.set反馈ID(feedBackId); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + } + } + int feedBackId = Integer.parseInt(methodId + "02"); + String text = SpeechUtil.getTaskExceptionSpeech(uid, taskConditionId, "02"); + resultResponse.set反馈ID(feedBackId); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + //4.任务成功操作拆分的任务 + if (methodIdSplitList.contains(methodId)) { + if(!StringUtils.isEmpty(subject)){ + List demandTaskList = PlayerUtil.findDemandsByTaskId(subject, subjectId, taskConditionId); + if (demandTaskList.size() != 0) { + DemandTaskDto demandTask = demandTaskList.get(0); + int feedBackId = Integer.parseInt(methodId); + if (feedBackId == 204301 || feedBackId == 204302) { + resultResponse.set后台附加返回("赌场作弊2"); + Map map = player.getTaskMap().get(subjectId); + if (map.containsKey(demandTask.getDemandTaskId())) { + int num = map.get(demandTask.getDemandTaskId()); + //符合阈值需求,已达次数上限 + if (num >= demandTask.getEffectiveDegree()) { + //获取对应话术 +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 204306); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "06"); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203904); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(204306); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - Map> taskMap = player.getTaskMap(); - //2.符合阈值需求,判断是否完成后置任务 - if (taskMap.containsKey(subjectId)) { - Map subjectMap = taskMap.get(subjectId); - if (subjectMap.containsKey(demandTask.getDemandTaskId())) { - int num = subjectMap.get(demandTask.getDemandTaskId()); - //符合阈值需求,已达次数上限 - if (num >= demandTask.getEffectiveDegree()) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203902); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203902); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203901); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203903); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203903); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(203901); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203903); + } + //任务完成,数据更新 + PlayerUtil.taskFinished(uid, subjectId, demandTask.getDemandTaskId()); + } + if (feedBackId == 204303 || feedBackId == 204304) { + resultResponse.set后台附加返回("赌场作弊3"); + Map map = player.getTaskMap().get(subjectId); + if (map.containsKey(demandTask.getDemandTaskId())) { + int num = map.get(demandTask.getDemandTaskId()); + //符合阈值需求,已达次数上限 + if (num >= demandTask.getEffectiveDegree()) { + //获取对应话术 +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 204306); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "06"); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203903); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(204306); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } } } + if (feedBackId == 204305) { + resultResponse.set后台附加返回("赌场作弊4"); + //获取对应话术 +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 204305); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "05"); + text = SpeechUtil.replaceHeader(text, subject.getName()); + resultResponse.set反馈ID(204305); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + //获取对应话术 +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, methodId.replace("2043", String.valueOf(demandTask.getConditionTaskId()))); + text = SpeechUtil.replaceHeader(text, subject.getName()); + if (feedBackId == 204301 || feedBackId == 204302) { + //获取对应话术 + text += SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask); + } + resultResponse.set反馈ID(feedBackId); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); } //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 203905); + String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 204307); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(203905); + resultResponse.set反馈ID(204307); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - }else if("2040".equals(methodId)){ + } + + //4.任务成功操作拆分的任务 + if ("2043".equals(methodId)) { if(!StringUtils.isEmpty(subject)){ List demandTaskList = subject.getDemandTasks(); for (DemandTaskDto demandTask : demandTaskList) { if (subjectId.equals(demandTask.getSubject())) { String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { + Integer clueSwitch = talk.getDemandTaskSwitchMap().get(demandTask.getDemandTaskId()); + if (condition1[0].equals(taskConditionId) && allowTask.contains(clueSwitch)) { //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); - //不符合阈值需求 - if (!flag) { - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 204004); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(204004); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } + //判断是否已达次数上限 Map> taskMap = player.getTaskMap(); - //2.符合阈值需求,判断是否完成后置任务 if (taskMap.containsKey(subjectId)) { - Map subjectMap = taskMap.get(subjectId); - if (subjectMap.containsKey(demandTask.getDemandTaskId())) { - int num = subjectMap.get(demandTask.getDemandTaskId()); + Map map = taskMap.get(subjectId); + if (map.containsKey(demandTask.getDemandTaskId())) { + int num = map.get(demandTask.getDemandTaskId()); //符合阈值需求,已达次数上限 if (num >= demandTask.getEffectiveDegree()) { + int feedBackId = Integer.parseInt(methodId + "06"); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 204002); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "06"); text = SpeechUtil.replaceHeader(text, subject.getName()); - text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 204002); - text = SpeechUtil.speechReplaceNum(text, subject.getName()); - resultResponse.set反馈ID(204002); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(204001); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - //符合阈值需求,后置任务没有完成 + int feedBackId = Integer.parseInt(methodId + "08"); +// PersistenceUtil.saveDataToFile(userFilePath, uid, JSON.toJSONString(player)); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 204003); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "08"); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(204003); + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("赌场作弊1"); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(204001); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - //符合阈值需求,后置任务没有完成 + int feedBackId = Integer.parseInt(methodId + "08"); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 204003); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "08"); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(204003); + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("赌场作弊1"); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } } } } + int feedBackId = Integer.parseInt(methodId + "07"); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 204005); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, feedBackId); + String text = SpeechUtil.getTaskExceptionSpeech(uid, taskConditionId, "07"); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(204005); + resultResponse.set反馈ID(feedBackId); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - }else if("2041".equals(methodId)){ + } + + if("2012".equals(methodId)){ if(!StringUtils.isEmpty(subject)){ - List demandTaskList = subject.getDemandTasks(); + List demandTaskList = PlayerUtil.findDemandsByTaskId(subject, subjectId, taskConditionId.toString()); + int count = 0; for (DemandTaskDto demandTask : demandTaskList) { if (subjectId.equals(demandTask.getSubject())) { String[] condition1 = demandTask.getCondition1().split("\\|"); - if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) { + Integer clueSwitch = talk.getDemandTaskSwitchMap().get(demandTask.getDemandTaskId()); + if (condition1[0].equals(taskConditionId) && allowTask.contains(clueSwitch)) { + count++; + if (count < demandTaskList.size()) { + int taskStatus = PlayerUtil.checkTaskStatus(uid, subjectId, demandTask.getDemandTaskId()); + if (taskStatus == 1) { + continue; + } + } //条件判断 - // 1. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); + // 1. 判断是否满足货币消费条件 + String cost = demandTask.getCost(); + int value = 0; + if (!StringUtils.isEmpty(cost)) { + String[] costs = cost.split("\\|"); + value = Integer.parseInt(costs[0]); + int money = TimingAcquisition.seriesPlayerMap.get(player.getSeries()).get(uid).getMoney(); + if (money < value) { + //获取对应话术 +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 201204); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "04"); + text = SpeechUtil.replaceHeader(text, subject.getName()); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(201204); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + } + // 2. 判断是否符合阈值需求 + boolean flag = PlayerUtil.checkThreshold(uid, demandTask, talk); //不符合阈值需求 if (!flag) { //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 204104); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 201203); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "03"); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(204104); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(201203); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } + //2.符合阈值需求,判断是否已达次数上限 Map> taskMap = player.getTaskMap(); - //2.符合阈值需求,判断是否完成后置任务 if (taskMap.containsKey(subjectId)) { - Map subjectMap = taskMap.get(subjectId); - if (subjectMap.containsKey(demandTask.getDemandTaskId())) { - int num = subjectMap.get(demandTask.getDemandTaskId()); + //扣除货币 + PlayerUtil.updateMoneyNum(uid, value); + Map map = taskMap.get(subjectId); + if (map.containsKey(demandTask.getDemandTaskId())) { + int num = map.get(demandTask.getDemandTaskId()); //符合阈值需求,已达次数上限 if (num >= demandTask.getEffectiveDegree()) { //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 204102); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 201202); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "02"); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(204102); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); - } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(204101); + text = SpeechUtil.speechReplaceValue(uid, text, subject, demandTask); + resultResponse.set反馈ID(201202); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - //符合阈值需求,后置任务没有完成 + // 3.信任阈值提升 + map.put(demandTask.getDemandTaskId(), num + 1); + PlayerUtil.addThreshold(talk, demandTask); + //增加声望值 + PlayerUtil.updateReputation(player, demandTask.getReputation()); + //更新时间值 + PlayerUtil.updateInitTime(player, demandTask.getCostTime()); + //更新生命状态 + PlayerUtil.updateLifeState(player.getPersonInfoMap().get(subjectId), demandTask.getLifeState()); +// PersistenceUtil.saveDataToFile(userFilePath, uid, JSON.toJSONString(player)); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 204103); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(204103); - resultResponse.set反馈文本(text); - resultVarsResponse.setVars(resultResponse); - return CommonResult.success(resultVarsResponse); - } - Integer objectId = demandTask.getObject(); - Map objectMap = taskMap.get(objectId); - if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) { - subjectMap.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); - if (!StringUtils.isEmpty(demandTask.getCompletionReward())) { - player.setCurrency(player.getCurrency() + Double.parseDouble(demandTask.getCompletionReward())); + String text = SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask); + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTask.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); } - //获取对应话术 - String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask); - resultResponse.set反馈ID(204101); + resultResponse.set反馈ID(201201); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - //符合阈值需求,后置任务没有完成 - //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 204103); - text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(204103); + // 3.信任阈值提升 + map.put(demandTask.getDemandTaskId(), 1); + PlayerUtil.addThreshold(talk, demandTask); + //增加声望值 + PlayerUtil.updateReputation(player, demandTask.getReputation()); + //更新时间值 + PlayerUtil.updateInitTime(player, demandTask.getCostTime()); + //更新生命状态 + PlayerUtil.updateLifeState(player.getPersonInfoMap().get(subjectId), demandTask.getLifeState()); +// PersistenceUtil.saveDataToFile(userFilePath, uid, JSON.toJSONString(player)); + //获取对应话术 + String text = SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask); + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTask.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); + } + resultResponse.set反馈ID(201201); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); @@ -5324,14 +3217,17 @@ public class PlayerServiceImpl implements PlayerService { } } //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 204105); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 201205); + String text = SpeechUtil.getTaskExceptionSpeech(uid, taskConditionId, "05"); text = SpeechUtil.replaceHeader(text, subject.getName()); - resultResponse.set反馈ID(204105); + resultResponse.set反馈ID(201205); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - } else if ("2101".equals(methodId)) { + } + + if ("2101".equals(methodId)) { if(!StringUtils.isEmpty(subject)){ List demandTaskList = subject.getDemandTasks(); for (DemandTaskDto demandTask : demandTaskList) { @@ -5340,13 +3236,16 @@ public class PlayerServiceImpl implements PlayerService { if (taskName.contains("买") || taskName.contains("获赠")) { //条件判断 // 1. 判断是否满足货币消费条件 - String condition2 = demandTask.getCondition2(); + String cost = demandTask.getCost(); int value = 0; - if (!StringUtils.isEmpty(condition2)) { - value = Integer.parseInt(condition2); - if (player.getCurrency() < value) { + if (!StringUtils.isEmpty(cost)) { + String[] costs = cost.split("\\|"); + value = Integer.parseInt(costs[0]); + int money = TimingAcquisition.seriesPlayerMap.get(player.getSeries()).get(uid).getMoney(); + if (money < value) { //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 210103); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 210103); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "02"); text = SpeechUtil.replaceHeader(text, subject.getName()); text = SpeechUtil.speechReplaceNum(text, String.valueOf(value)); resultResponse.set反馈ID(210103); @@ -5356,11 +3255,12 @@ public class PlayerServiceImpl implements PlayerService { } } // 2. 判断是否符合阈值需求 - boolean flag = checkThreshold(demandTask, subject); + boolean flag = PlayerUtil.checkThreshold(uid, demandTask, talk); //不符合阈值需求 if (!flag) { //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 210104); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 210104); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "04"); text = SpeechUtil.replaceHeader(text, subject.getName()); resultResponse.set反馈ID(210104); resultResponse.set反馈文本(text); @@ -5374,10 +3274,10 @@ public class PlayerServiceImpl implements PlayerService { if (map.containsKey(demandTask.getDemandTaskId())) { int num = map.get(demandTask.getDemandTaskId()); //符合阈值需求,已达次数上限 - String[] condition1 = demandTask.getCondition1().split("\\|"); - if (num >= Integer.parseInt(condition1[1])) { + if (num >= demandTask.getEffectiveDegree()) { //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 210102); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 210102); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "02"); text = SpeechUtil.replaceHeader(text, subject.getName()); text = SpeechUtil.speechReplaceNum(text, subject.getName(), text); resultResponse.set反馈ID(210102); @@ -5385,30 +3285,38 @@ public class PlayerServiceImpl implements PlayerService { resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), num + 1); - addThreshold(subject, demandTask); - //ThreadLocalUtil.add(sid,player); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); + //任务完成,数据更新 + PlayerUtil.taskFinished(uid, subjectId, demandTask.getDemandTaskId()); + //ThreadLocalUtil.add(uid,player); +// PersistenceUtil.saveDataToFile(userFilePath, uid, JSON.toJSONString(player)); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 210101); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 210101); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "01"); text = SpeechUtil.replaceHeader(text, subject.getName()); + text = SpeechUtil.speechReplaceNum(text, subject.getName()); + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTask.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); + } resultResponse.set反馈ID(210101); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - //扣除货币 - PlayerUtil.updateMoneyNum(sid, value); - // 3.信任阈值提升 - map.put(demandTask.getDemandTaskId(), 1); - addThreshold(subject, demandTask); -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); + //任务完成,数据更新 + PlayerUtil.taskFinished(uid, subjectId, demandTask.getDemandTaskId()); +// PersistenceUtil.saveDataToFile(userFilePath, uid, JSON.toJSONString(player)); //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 210101); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 210101); + String text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "01"); text = SpeechUtil.replaceHeader(text, subject.getName()); + text = SpeechUtil.speechReplaceNum(text, subject.getName()); + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTask.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); + } resultResponse.set反馈ID(210101); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); @@ -5419,14 +3327,17 @@ public class PlayerServiceImpl implements PlayerService { } } //获取对应话术 - String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 210105); +// String text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 210105); + String text = SpeechUtil.getTaskExceptionSpeech(uid, taskConditionId, "05"); text = SpeechUtil.replaceHeader(text, subject.getName()); resultResponse.set反馈ID(210105); resultResponse.set反馈文本(text); resultVarsResponse.setVars(resultResponse); return CommonResult.success(resultVarsResponse); } - } else if ("2104".equals(methodId)) { + } + + if ("2104".equals(methodId)) { if(!StringUtils.isEmpty(subject)) { List demandTaskList = subject.getDemandTasks(); for (DemandTaskDto demandTask : demandTaskList) { @@ -5434,7 +3345,7 @@ public class PlayerServiceImpl implements PlayerService { String[] condition1 = demandTask.getCondition1().split("\\|"); //催账完成 if ("70031".equals(condition1[0])) { - int taskStatus = PlayerUtil.checkTaskStatus(sid, subjectId, demandTask.getDemandTaskId()); + int taskStatus = PlayerUtil.checkTaskStatus(uid, subjectId, demandTask.getDemandTaskId()); if (taskStatus == 1) { continue; } @@ -5444,7 +3355,7 @@ public class PlayerServiceImpl implements PlayerService { } //催账 if ("70032".equals(condition1[0])) { - int taskStatus = PlayerUtil.checkTaskStatus(sid, subjectId, demandTask.getDemandTaskId()); + int taskStatus = PlayerUtil.checkTaskStatus(uid, subjectId, demandTask.getDemandTaskId()); if (taskStatus == 1) { continue; } @@ -5455,7 +3366,9 @@ public class PlayerServiceImpl implements PlayerService { } } } - } else if ("2106".equals(methodId)) { + } + + if ("2106".equals(methodId)) { if(!StringUtils.isEmpty(subject)) { List demandTaskList = subject.getDemandTasks(); for (DemandTaskDto demandTask : demandTaskList) { @@ -5463,7 +3376,7 @@ public class PlayerServiceImpl implements PlayerService { String[] condition1 = demandTask.getCondition1().split("\\|"); //探听身家 if ("70021".equals(condition1[0])) { - int taskStatus = PlayerUtil.checkTaskStatus(sid, subjectId, demandTask.getDemandTaskId()); + int taskStatus = PlayerUtil.checkTaskStatus(uid, subjectId, demandTask.getDemandTaskId()); if (taskStatus == 0) { request.setMethodId("2019"); request.setTaskConditionId("70021"); @@ -5472,7 +3385,7 @@ public class PlayerServiceImpl implements PlayerService { } //打探肥羊完成 if ("70030".equals(condition1[0])) { - int taskStatus = PlayerUtil.checkTaskStatus(sid, subjectId, demandTask.getDemandTaskId()); + int taskStatus = PlayerUtil.checkTaskStatus(uid, subjectId, demandTask.getDemandTaskId()); if (taskStatus == 0) { request.setMethodId("2028"); request.setTaskConditionId("70030"); @@ -5481,7 +3394,7 @@ public class PlayerServiceImpl implements PlayerService { } //打探隐私完成 if ("70035".equals(condition1[0])) { - int taskStatus = PlayerUtil.checkTaskStatus(sid, subjectId, demandTask.getDemandTaskId()); + int taskStatus = PlayerUtil.checkTaskStatus(uid, subjectId, demandTask.getDemandTaskId()); if (taskStatus == 0) { request.setMethodId("2032"); request.setTaskConditionId("70035"); @@ -5489,7 +3402,7 @@ public class PlayerServiceImpl implements PlayerService { } } //打探隐私完成 - if ("70036".equals(condition1[0])) {int taskStatus = PlayerUtil.checkTaskStatus(sid, subjectId, demandTask.getDemandTaskId()); + if ("70036".equals(condition1[0])) {int taskStatus = PlayerUtil.checkTaskStatus(uid, subjectId, demandTask.getDemandTaskId()); if (taskStatus == 0) { request.setMethodId("2034"); request.setTaskConditionId("70036"); @@ -5499,7 +3412,9 @@ public class PlayerServiceImpl implements PlayerService { } } } - } else if ("2107".equals(methodId)) { + } + + if ("2107".equals(methodId)) { if(!StringUtils.isEmpty(subject)) { List demandTaskList = subject.getDemandTasks(); for (DemandTaskDto demandTask : demandTaskList) { @@ -5507,7 +3422,7 @@ public class PlayerServiceImpl implements PlayerService { String[] condition1 = demandTask.getCondition1().split("\\|"); //证据账本完成 if ("70038".equals(condition1[0])) { - int taskStatus = PlayerUtil.checkTaskStatus(sid, subjectId, demandTask.getDemandTaskId()); + int taskStatus = PlayerUtil.checkTaskStatus(uid, subjectId, demandTask.getDemandTaskId()); if (taskStatus == 1) { continue; } @@ -5517,7 +3432,7 @@ public class PlayerServiceImpl implements PlayerService { } //证据账本 if ("70039".equals(condition1[0])) { - int taskStatus = PlayerUtil.checkTaskStatus(sid, subjectId, demandTask.getDemandTaskId()); + int taskStatus = PlayerUtil.checkTaskStatus(uid, subjectId, demandTask.getDemandTaskId()); if (taskStatus == 1) { continue; } @@ -5529,7 +3444,123 @@ public class PlayerServiceImpl implements PlayerService { } } } -// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player)); + //"我看到"的模糊意图 + if ("61001".equals(methodId)) { + if(!StringUtils.isEmpty(subject)) { + List conditionIdList = Arrays.asList("70038", "70046", "70053", "70063", "70071", "70078", + "70086", "70094"); + List demandTaskList = subject.getDemandTasks(); + for (DemandTaskDto demandTask : demandTaskList) { + if (subjectId.equals(demandTask.getSubject())) { + String[] condition1 = demandTask.getCondition1().split("\\|"); + //请吃饭AB-我看到 + if (conditionIdList.contains(condition1[0])) { + int taskStatus = PlayerUtil.checkTaskStatus(uid, subjectId, demandTask.getDemandTaskId()); + if (taskStatus == 1) { + continue; + } + String operateId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition1[0])).getMethodId().toString(); + request.setMethodId(operateId); + request.setTaskConditionId(condition1[0]); + return performTask(request); + } + } + } + } + } + //"我帮你送"的模糊意图 + if ("61002".equals(methodId)) { + if(!StringUtils.isEmpty(subject)) { + List conditionIdList = Arrays.asList("70018", "70026", "70029"); + List demandTaskList = subject.getDemandTasks(); + for (DemandTaskDto demandTask : demandTaskList) { + if (subjectId.equals(demandTask.getSubject())) { + String[] condition1 = demandTask.getCondition1().split("\\|"); + //包含在模糊意图中 + if (conditionIdList.contains(condition1[0])) { + int taskStatus = PlayerUtil.checkTaskStatus(uid, subjectId, demandTask.getDemandTaskId()); + if (taskStatus == 1) { + continue; + } + String operateId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition1[0])).getMethodId().toString(); + request.setMethodId(operateId); + request.setTaskConditionId(condition1[0]); + return performTask(request); + } + } + } + } + } + //"送到了"的模糊意图 + if ("61003".equals(methodId)) { + if(!StringUtils.isEmpty(subject)) { + List conditionIdList = Arrays.asList("70019", "70027", "70030"); + List demandTaskList = subject.getDemandTasks(); + for (DemandTaskDto demandTask : demandTaskList) { + if (subjectId.equals(demandTask.getSubject())) { + String[] condition1 = demandTask.getCondition1().split("\\|"); + //包含在模糊意图中 + if (conditionIdList.contains(condition1[0])) { + int taskStatus = PlayerUtil.checkTaskStatus(uid, subjectId, demandTask.getDemandTaskId()); + if (taskStatus == 1) { + continue; + } + String operateId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition1[0])).getMethodId().toString(); + request.setMethodId(operateId); + request.setTaskConditionId(condition1[0]); + return performTask(request); + } + } + } + } + } + //"我猜的"的模糊意图 + if ("61004".equals(methodId)) { + if(!StringUtils.isEmpty(subject)) { + List conditionIdList = Arrays.asList("70037", "70062", "70087"); + List demandTaskList = subject.getDemandTasks(); + for (DemandTaskDto demandTask : demandTaskList) { + if (subjectId.equals(demandTask.getSubject())) { + String[] condition1 = demandTask.getCondition1().split("\\|"); + //包含在模糊意图中 + if (conditionIdList.contains(condition1[0])) { + int taskStatus = PlayerUtil.checkTaskStatus(uid, subjectId, demandTask.getDemandTaskId()); + if (taskStatus == 1) { + continue; + } + String operateId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition1[0])).getMethodId().toString(); + request.setMethodId(operateId); + request.setTaskConditionId(condition1[0]); + return performTask(request); + } + } + } + } + } + //"我猜的"的模糊意图 + if ("61005".equals(methodId)) { + if(!StringUtils.isEmpty(subject)) { + List conditionIdList = Arrays.asList("70045", "70062", "70070"); + List demandTaskList = subject.getDemandTasks(); + for (DemandTaskDto demandTask : demandTaskList) { + if (subjectId.equals(demandTask.getSubject())) { + String[] condition1 = demandTask.getCondition1().split("\\|"); + //包含在模糊意图中 + if (conditionIdList.contains(condition1[0])) { + int taskStatus = PlayerUtil.checkTaskStatus(uid, subjectId, demandTask.getDemandTaskId()); + if (taskStatus == 1) { + continue; + } + String operateId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition1[0])).getMethodId().toString(); + request.setMethodId(operateId); + request.setTaskConditionId(condition1[0]); + return performTask(request); + } + } + } + } + } +// PersistenceUtil.saveDataToFile(userFilePath, uid, JSON.toJSONString(player)); return CommonResult.failed("任务执行失败!"); } @@ -5674,16 +3705,12 @@ public class PlayerServiceImpl implements PlayerService { * @param type * @return */ - private List findClues(Person current,Person subject,Integer type){ + private List findClues(Person current, Person subject, Integer type){ List result = new ArrayList<>(); if(!StringUtils.isEmpty(current)){ - List clueList =current.getClues(); - for (int i= 0;i clueList = current.getClues(); + for (ClueDto clue : clueList) { + if (type.equals(clue.getType()) && clue.getSubject() == subject.getId()) { result.add(clue); } } @@ -5705,9 +3732,16 @@ public class PlayerServiceImpl implements PlayerService { for (int i= 0;i=0 && demandTask.getTrustEnd() > 0) { if(NumberUtil.inNumRange(subject.getTrustDegree(),"["+demandTask.getTrustStart()+","+demandTask.getTrustEnd()+"]")) { flag = true; diff --git a/src/main/java/com/qiwu/inference/service/remote/RemoteService.java b/src/main/java/com/qiwu/inference/service/remote/RemoteService.java new file mode 100644 index 0000000..8abdf63 --- /dev/null +++ b/src/main/java/com/qiwu/inference/service/remote/RemoteService.java @@ -0,0 +1,26 @@ +package com.qiwu.inference.service.remote; + +import com.qiwu.inference.dto.response.CallResponse; + +import java.io.IOException; + +public interface RemoteService { + /** + * 获取来源 + */ + String getResource(); + + /** + * 远程调用 + * @param uid + * @return + */ + CallResponse getItems(String uid); + + /** + * 更新玩家物品 + * @param uid + * @return + */ + CallResponse updateItems(String uid) throws IOException; +} diff --git a/src/main/java/com/qiwu/inference/service/remote/impl/RemoteGardenImpl.java b/src/main/java/com/qiwu/inference/service/remote/impl/RemoteGardenImpl.java new file mode 100644 index 0000000..d52be14 --- /dev/null +++ b/src/main/java/com/qiwu/inference/service/remote/impl/RemoteGardenImpl.java @@ -0,0 +1,111 @@ +package com.qiwu.inference.service.remote.impl; + +import com.alibaba.fastjson.JSONObject; +import com.qiwu.inference.dto.response.CallResponse; +import com.qiwu.inference.service.remote.RemoteService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.*; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; +import org.springframework.web.client.RestTemplate; + +import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@Service +public class RemoteGardenImpl implements RemoteService { + Logger log = LoggerFactory.getLogger(RemoteGardenImpl.class); + + @Value("${gardenSysUrl}") + private String gardenSysUrl; + + @Override + public String getResource() { + return "gardenSys"; + } + + /** + * 获取所有物品 + * @param uid + * @return + */ + @Override + public CallResponse getItems(String uid) { + RestTemplate template = new RestTemplate(); + //获取用户关联ID链接 + String relativeUrl = gardenSysUrl + "/player/getItems"; + JSONObject object = new JSONObject(); + object.put("uid", uid); + //设置请求头 + HttpHeaders httpHeaders = new HttpHeaders(); + httpHeaders.set("Content-Type", "application/json;charset=utf-8"); + HttpEntity request = new HttpEntity<>(object, httpHeaders); + ResponseEntity forObject = template.exchange(relativeUrl, HttpMethod.POST, request, CallResponse.class); + log.info(uid + "的物品信息:" + forObject.getBody()); + if (StringUtils.isEmpty(forObject.getBody())) { + return null; + } + if (forObject.getBody().getCode() == 0) { + return null; + } + if (StringUtils.isEmpty(forObject.getBody().getData())) { + return null; + } + // JSON转换 + return forObject.getBody(); + } + + /** + * 获取玩家的货币数量 + */ + public CallResponse getMoney(String uid) { + RestTemplate template = new RestTemplate(); + //获取用户关联ID链接 + String relativeUrl = gardenSysUrl + "/player/getMoney"; + JSONObject object = new JSONObject(); + object.put("uid", uid); + //设置请求头 + HttpHeaders httpHeaders = new HttpHeaders(); + httpHeaders.set("Content-Type", "application/json;charset=utf-8"); + HttpEntity request = new HttpEntity<>(object, httpHeaders); + ResponseEntity forObject = new ResponseEntity<>(new CallResponse(), HttpStatus.ACCEPTED); + try { + forObject = template.exchange(relativeUrl, HttpMethod.POST, request, CallResponse.class); + } catch (Exception e) { + e.printStackTrace(); + log.info("远程请求拒绝连接,远程服务可能没启动"); + } + log.info(uid + "的货币数量:" + forObject.getBody()); + // JSON转换 + return forObject.getBody(); + } + + /** + * 更新玩家物品 + */ + @Override + public CallResponse updateItems(String uid) { + RestTemplate template = new RestTemplate(); + //获取用户关联ID链接 + String relativeUrl = gardenSysUrl + "/player/updateItems"; + JSONObject object = new JSONObject(); + object.put("uid", uid); + //设置请求头 + HttpHeaders httpHeaders = new HttpHeaders(); + httpHeaders.set("Content-Type", "application/json;charset=utf-8"); + HttpEntity request = new HttpEntity<>(object, httpHeaders); + ResponseEntity forObject = new ResponseEntity<>(new CallResponse(), HttpStatus.ACCEPTED); + try { + forObject = template.exchange(relativeUrl, HttpMethod.POST, request, CallResponse.class); + } catch (Exception e) { + e.printStackTrace(); + log.info("远程请求拒绝连接,远程服务可能没启动"); + } + log.info(uid + "同步物品数量结果:" + forObject.getBody()); + //JSON转换 + return forObject.getBody(); + } +} diff --git a/src/main/java/com/qiwu/inference/service/task/TaskService.java b/src/main/java/com/qiwu/inference/service/task/TaskService.java index 6621bc0..5b3b193 100644 --- a/src/main/java/com/qiwu/inference/service/task/TaskService.java +++ b/src/main/java/com/qiwu/inference/service/task/TaskService.java @@ -5,5 +5,28 @@ import com.qiwu.inference.dto.request.OperationRequest; import com.qiwu.inference.dto.response.ResultVarsResponse; public interface TaskService { + /** + * 任务操作 + * @param operationReq + * @return + */ CommonResult execute(OperationRequest operationReq); + /** + * 任务同意操作 + * @param operationReq + * @return + */ + CommonResult agree(OperationRequest operationReq); + /** + * 任务拒绝操作 + * @param operationReq + * @return + */ + CommonResult refuse(OperationRequest operationReq); + /** + * 任务中断操作 + * @param operationReq + * @return + */ + CommonResult interrupt(OperationRequest operationReq); } diff --git a/src/main/java/com/qiwu/inference/service/task/impl/TaskServiceImpl.java b/src/main/java/com/qiwu/inference/service/task/impl/TaskServiceImpl.java index 42ac341..867f244 100644 --- a/src/main/java/com/qiwu/inference/service/task/impl/TaskServiceImpl.java +++ b/src/main/java/com/qiwu/inference/service/task/impl/TaskServiceImpl.java @@ -1,10 +1,17 @@ package com.qiwu.inference.service.task.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.qiwu.inference.common.Constants; +import com.qiwu.inference.common.TimingAcquisition; import com.qiwu.inference.common.api.CommonResult; -import com.qiwu.inference.common.utils.CacheUtil; -import com.qiwu.inference.common.utils.YamlUtil; +import com.qiwu.inference.common.cache.CacheGlobal; +import com.qiwu.inference.common.utils.*; +import com.qiwu.inference.dto.*; import com.qiwu.inference.dto.request.OperationRequest; +import com.qiwu.inference.dto.response.ResultResponse; import com.qiwu.inference.dto.response.ResultVarsResponse; +import com.qiwu.inference.service.chat.impl.ChatServiceImpl; import com.qiwu.inference.service.common.CommonService; import com.qiwu.inference.service.task.TaskService; import org.slf4j.Logger; @@ -14,9 +21,12 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; +import java.util.List; +import java.util.Map; + @Service public class TaskServiceImpl implements TaskService { - private Logger log = LoggerFactory.getLogger(TaskServiceImpl.class); + Logger log = LoggerFactory.getLogger(TaskServiceImpl.class); //从yml配置文件中取出对话过期时间 @Value("${expireTime}") @@ -25,16 +35,298 @@ public class TaskServiceImpl implements TaskService { @Autowired private CommonService commonService; + @Autowired + private ChatServiceImpl chatService; + +// @Autowired +// private RedisUtil redisUtil; + @Override public CommonResult execute(OperationRequest operationReq) { +// String uid = operationReq.getUid(); +// String subjectName = operationReq.getSubjectName(); //A人物名称 +// //当前玩家上一轮的请求信息 +// OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); +// if (!StringUtils.isEmpty(lastReq)) { +// subjectName = (subjectName == null) ? lastReq.getSubjectName() : subjectName; +// } + + return commonService.operate(operationReq); + } + + @Override + public CommonResult agree(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + String uid = operationReq.getUid(); - String subjectName = operationReq.getSubjectName(); //A人物名称 - //当前玩家上一轮的请求信息 - OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid); - if (!StringUtils.isEmpty(lastReq)) { - subjectName = (subjectName == null) ? lastReq.getSubjectName() : subjectName; + String taskConditionId = operationReq.getTaskConditionId(); //任务条件id + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + String unique = uid + gateNo; //用户uid和关卡编号组成唯一标识 + Player player = TimingAcquisition.playerMap.get(uid); + //当前对话人 + PersonInfoDto talk = player.getPersonInfoMap().get(player.getPersonId()); + //当前对话人物的配置信息 + Person current = PlayerUtil.getPerson(uid, player.getPersonId()); + //当前玩家上一轮保存的数据 + ReplyDto reply = (ReplyDto) CacheUtil.get(unique); + //仅测试,可删除 +// PlayerSeriesDto playerSeriesMap = JSON.parseObject(redisUtil.getStr(player.getSeries() + ":" + uid), new TypeReference(){}); +// System.out.println("redis输出:" + playerSeriesMap); + //走闲聊 + if (StringUtils.isEmpty(reply)) { + operationReq.setMethodId("9001"); + return chatService.operate(operationReq); } + Integer subjectId = reply.getSubjectId(); + Integer demandTaskId = reply.getDemandTaskId(); + //找到对应任务 + DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, demandTaskId); + //当前对话人的数据 +// PersonInfoDto talk = player.getPersonInfoMap().get(player.getPersonId()); + String text = ""; + if (!StringUtils.isEmpty(demandTask)) { + String[] condition1 = demandTask.getCondition1().split("\\|"); + //确认意图和上轮任务是一致的 + if (condition1[0].equals(taskConditionId)) { + Integer methodIdTalk = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition1[0])).getMethodId(); + if (!StringUtils.isEmpty(demandTask.getPostTask())) { + int feedBackId = Integer.parseInt(methodIdTalk + "03"); + Map> taskMap = player.getTaskMap(); + //2.符合阈值需求,判断是否完成副任务 + if (!taskMap.containsKey(demandTask.getObject())) { + //获取对应话术 + text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "03"); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceValue(uid, text, current, demandTask); + resultResponse.set反馈ID(feedBackId); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + Map objectMap = taskMap.get(demandTask.getObject()); + if (!objectMap.containsKey(Integer.valueOf(demandTask.getPostTask()))) { + //获取对应话术 + text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "03"); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceValue(uid, text, current, demandTask); + resultResponse.set反馈ID(feedBackId); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + } + // 1. 判断是否满足货币消费条件 + String cost = demandTask.getCost(); + if (!StringUtils.isEmpty(cost)) { + String[] costList = cost.split("\\|"); + int value = Integer.parseInt(costList[0]); + int money = TimingAcquisition.seriesPlayerMap.get(player.getSeries()).get(uid).getMoney(); + if (money < value) { + int feedBackId = Integer.parseInt(methodIdTalk + "04"); + //获取对应话术 + text = SpeechUtil.getTaskExceptionSpeech(uid, demandTask, "04"); + text = SpeechUtil.replaceHeader(text, current.getName()); + text = SpeechUtil.speechReplaceValue(uid, text, current, demandTask); + resultResponse.set反馈ID(feedBackId); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + } + //--------任务完成,更新数据------- + PlayerUtil.taskFinished(uid, subjectId, demandTaskId); + text = SpeechUtil.getSuccessTaskSpeech(uid, current, demandTask); + PlayerUtil.updateTaskStatus(uid, subjectId, demandTaskId, 6); + CacheGlobal.concurrentMap.remove(unique); + //任务链下一个任务的对应回复 + CommonResult result = PlayerUtil.getNextTaskAnswer(uid, subjectId, demandTask.getDemandTaskId()); + if (!StringUtils.isEmpty(result.getMessage())) { + text += result.getMessage(); + //任务链下一任务启动 + PlayerUtil.startTaskOnNext(uid, demandTask.getDemandTaskId()); + DemandTaskDto nextDemandTask = result.getData(); + //存在任务链下一个 + if (!StringUtils.isEmpty(nextDemandTask)) { + //返回下一个任务对应的后台附加返回给bot端 + String[] condition = nextDemandTask.getCondition1().split("\\|"); + Integer methodId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition[0])).getMethodId(); + resultResponse.set后台附加返回(methodId.toString()); + } + } + //任务为最终任务,或者时间值到1或以下,通关 + if (demandTask.getTaskLabel() == 3 || player.getInitTime() <= 1 || text.contains(Constants.END_TEXT)) { + //数据更新与结算 + PlayerUtil.clearanceUpdate(uid); + } + } else { //意图不一致,返回对应文本 + //获取对应话术 + text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 600000); + text = SpeechUtil.replaceHeader(text, current.getName()); + } + } + resultResponse.set反馈ID(600001); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } - return commonService.operate(operationReq); + @Override + public CommonResult refuse(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + String taskConditionId = operationReq.getTaskConditionId(); + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + String unique = uid + gateNo; //用户uid和关卡编号组成唯一标识 + Player player = TimingAcquisition.playerMap.get(uid); + //当前对话人物的配置信息 + Person current = PlayerUtil.getPerson(uid, player.getPersonId()); + //当前玩家上一轮保存的数据 + ReplyDto reply = (ReplyDto) CacheUtil.get(unique); + //走闲聊 + if (StringUtils.isEmpty(reply)) { + operationReq.setMethodId("9001"); + return chatService.operate(operationReq); + } + Integer subjectId = reply.getSubjectId(); + Integer demandTaskId = reply.getDemandTaskId(); + //找到对应任务 + DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, demandTaskId); + //当前对话人的数据 + PersonInfoDto talk = player.getPersonInfoMap().get(player.getPersonId()); + String text = ""; + if (!StringUtils.isEmpty(demandTask)) { + String[] condition1 = demandTask.getCondition1().split("\\|"); + //确认意图和上轮任务是一致的 + if (condition1[0].equals(taskConditionId)) { + //一次性任务标识 + int disposableLabel = demandTask.getDisposableLabel(); + //关闭任务 + if (disposableLabel != 0) { + talk.getDemandTaskSwitchMap().put(demandTaskId, 6); + } + String addText = ""; + //关闭任务后,当作完成,可触发后续剧情 + if (disposableLabel == 2) { + Map map = player.getTaskMap().get(subjectId); + int num = 0; + if (!StringUtils.isEmpty(map.get(demandTaskId))) { + num = map.get(demandTaskId); + } + //1.任务完成 + map.put(demandTaskId, num + 1); + //任务链下一个任务的对应回复 + CommonResult result = PlayerUtil.getNextTaskAnswer(uid, subjectId, demandTask.getDemandTaskId()); + if (!StringUtils.isEmpty(result.getMessage())) { + addText = result.getMessage(); + //任务链下一任务启动 + PlayerUtil.startTaskOnNext(uid, demandTask.getDemandTaskId()); + DemandTaskDto nextDemandTask = result.getData(); + //存在任务链下一个 + if (!StringUtils.isEmpty(nextDemandTask)) { + //返回下一个任务对应的后台附加返回给bot端 + String[] condition = nextDemandTask.getCondition1().split("\\|"); + Integer methodId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition[0])).getMethodId(); + resultResponse.set后台附加返回(methodId.toString()); + } + } + } + //任务挂起或关闭文本 + text = SpeechUtil.getPreSuccessTaskSpeech(uid, current, demandTask, 5); +// text = SpeechUtil.addHeader(text, current.getName()); + text += addText; + Integer methodId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition1[0])).getMethodId(); + resultResponse.set后台附加返回(methodId.toString()); + } else { //意图不一致,返回对应文本 + // 获取对应话术 + text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 600000); + text = SpeechUtil.replaceHeader(text, current.getName()); + } + } + resultResponse.set反馈ID(600002); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); + } + + @Override + public CommonResult interrupt(OperationRequest operationReq) { + ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); + ResultResponse resultResponse = new ResultResponse(); + + String uid = operationReq.getUid(); + String taskConditionId = operationReq.getTaskConditionId(); + String gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号 + String unique = uid + gateNo; //用户uid和关卡编号组成唯一标识 + Player player = TimingAcquisition.playerMap.get(uid); + //当前对话的人物 + Person current = PlayerUtil.getPerson(uid, player.getPersonId()); + //当前玩家上一轮保存的数据 + ReplyDto reply = (ReplyDto) CacheUtil.get(unique); + //走闲聊 + if (StringUtils.isEmpty(reply)) { + operationReq.setMethodId("9001"); + return chatService.operate(operationReq); + } + Integer subjectId = reply.getSubjectId(); + Integer demandTaskId = reply.getDemandTaskId(); + //找到对应任务 + DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, demandTaskId); + //当前对话人的数据 + PersonInfoDto talk = player.getPersonInfoMap().get(player.getPersonId()); + String text = ""; + if (!StringUtils.isEmpty(demandTask)) { + String[] condition1 = demandTask.getCondition1().split("\\|"); + //确认意图和上轮任务是一致的 + if (condition1[0].equals(taskConditionId)) { + //一次性任务标识 + int disposableLabel = demandTask.getDisposableLabel(); + String addText = ""; + //关闭任务后,当作完成,可触发后续剧情 + if (disposableLabel == 2) { + //关闭任务 + talk.getDemandTaskSwitchMap().put(demandTaskId, 6); + //任务当作完成 + Map map = player.getTaskMap().get(subjectId); + int num = 0; + if (!StringUtils.isEmpty(map.get(demandTaskId))) { + num = map.get(demandTaskId); + } + //1.任务完成 + map.put(demandTaskId, num + 1); + //任务链下一个任务的对应回复 + CommonResult result = PlayerUtil.getNextTaskAnswer(uid, subjectId, demandTask.getDemandTaskId()); + if (!StringUtils.isEmpty(result.getMessage())) { + addText = result.getMessage(); + //任务链下一任务启动 + PlayerUtil.startTaskOnNext(uid, demandTask.getDemandTaskId()); + DemandTaskDto nextDemandTask = result.getData(); + //存在任务链下一个 + if (!StringUtils.isEmpty(nextDemandTask)) { + //返回下一个任务对应的后台附加返回给bot端 + String[] condition = nextDemandTask.getCondition1().split("\\|"); + Integer methodId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition[0])).getMethodId(); + resultResponse.set后台附加返回(methodId.toString()); + } + } + } + //任务挂起或关闭文本 + text = SpeechUtil.getPreSuccessTaskSpeech(uid, current, demandTask, 4); +// text = SpeechUtil.addHeader(text, current.getName()); + text += addText; + Integer methodId = TimingAcquisition.seriesTaskConditionMap.get(player.getSeries()).get(Integer.valueOf(condition1[0])).getMethodId(); + resultResponse.set后台附加返回(methodId.toString()); + } else { //意图不一致,返回对应文本 + //获取对应话术 + text = SpeechUtil.getTaskSpeech(uid, Constants.SPEECH_PERSON, 600000); + text = SpeechUtil.replaceHeader(text, current.getName()); + } + } + resultResponse.set反馈ID(600003); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + return CommonResult.success(resultVarsResponse); } } diff --git a/src/main/resources/application-brickPro.yml b/src/main/resources/application-brickPro.yml new file mode 100644 index 0000000..66d5286 --- /dev/null +++ b/src/main/resources/application-brickPro.yml @@ -0,0 +1,35 @@ +server: + port: 60019 + serlvet: + context-type:/inference + +#设置当前服务名 +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/inference_brick?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC + username: root + password: dgKNTmt2iLHNjEQajkDEZkq8 + type: com.alibaba.druid.pool.DruidDataSource + druid: + initial-size: 5 + min-idle: 5 + max-active: 20 + max-wait: 60000 + #配置间隔多久才进行一次检测,检测需要关闭的空闲连接 + time-between-eviction-runs-millis: 20000 + #配置一个连接在池中最小生存的时间 + min-evictable-idle-time-millis: 300000 + +#对话过期时间 +expireTime: 180000 + +#玩家无操作时长,默认下线 +offlineTime: 180000 + +dataFilePath: /home/jiaoyou/projects/inferenceBrick/data/ + +configFilePath: /home/jiaoyou/projects/inferenceBrick/config/ + +userFilePath: /home/jiaoyou/projects/inferenceBrick/user/ + diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index a71f6d2..a6f45f0 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -20,16 +20,34 @@ spring: time-between-eviction-runs-millis: 20000 #配置一个连接在池中最小生存的时间 min-evictable-idle-time-millis: 300000 +#redis配置 + redis: + host: localhost + port: 6379 +# password: dgKNTmt2iLHNjEQajkDEZkq8 + pool: + max-active: 8 + max-wait: -1 + max-idle: 8 + min-idle: 0 + timeout: 5000 #对话过期时间 expireTime: 180000 +#redis的key过期时间 +redisExpireTime: 360000 + #玩家无操作时长,默认下线 offlineTime: 180000 -speechFilePath: /home/inferenceGame/speech/ +dataFilePath: /home/jiaoyou/projects/inferenceGame/data/ + +configFilePath: /home/jiaoyou/projects/inferenceGame/config/ + +userFilePath: /home/jiaoyou/projects/inferenceGame/user/ -configFilePath: /home/inferenceGame/config/ -userFilePath: /home/inferenceGame/user/ +#花仙系统的请求链接 +gardenSysUrl: http://127.0.0.1:8082 diff --git a/src/main/resources/application-pro.yml b/src/main/resources/application-pro.yml index 10a7bd1..4732c5b 100644 --- a/src/main/resources/application-pro.yml +++ b/src/main/resources/application-pro.yml @@ -27,7 +27,7 @@ expireTime: 180000 #玩家无操作时长,默认下线 offlineTime: 180000 -speechFilePath: /home/jiaoyou/projects/inferenceGame/speech/ +dataFilePath: /home/jiaoyou/projects/inferenceGame/data/ configFilePath: /home/jiaoyou/projects/inferenceGame/config/ diff --git a/src/main/resources/application-reflectionPro.yml b/src/main/resources/application-reflectionPro.yml new file mode 100644 index 0000000..0609da4 --- /dev/null +++ b/src/main/resources/application-reflectionPro.yml @@ -0,0 +1,33 @@ +server: + port: 60020 + serlvet: + context-type:/inference + +#设置当前服务名 +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/inference_reflection?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC + username: root + password: dgKNTmt2iLHNjEQajkDEZkq8 + type: com.alibaba.druid.pool.DruidDataSource + druid: + initial-size: 5 + min-idle: 5 + max-active: 20 + max-wait: 60000 + #配置间隔多久才进行一次检测,检测需要关闭的空闲连接 + time-between-eviction-runs-millis: 20000 + #配置一个连接在池中最小生存的时间 + min-evictable-idle-time-millis: 300000 + +#对话过期时间 +expireTime: 180000 + +#玩家无操作时长,默认下线 +offlineTime: 180000 + +configFilePath: /home/jiaoyou/projects/inferenceReflection/config/ + +userFilePath: /home/jiaoyou/projects/inferenceReflection/user/ + diff --git a/src/main/resources/application-totalPro.yml b/src/main/resources/application-totalPro.yml new file mode 100644 index 0000000..8c6139e --- /dev/null +++ b/src/main/resources/application-totalPro.yml @@ -0,0 +1,35 @@ +server: + port: 60021 + serlvet: + context-type:/inference + +#设置当前服务名 +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/inference_reflection?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC + username: root + password: dgKNTmt2iLHNjEQajkDEZkq8 + type: com.alibaba.druid.pool.DruidDataSource + druid: + initial-size: 5 + min-idle: 5 + max-active: 20 + max-wait: 60000 + #配置间隔多久才进行一次检测,检测需要关闭的空闲连接 + time-between-eviction-runs-millis: 20000 + #配置一个连接在池中最小生存的时间 + min-evictable-idle-time-millis: 300000 + +#对话过期时间 +expireTime: 180000 + +#玩家无操作时长,默认下线 +offlineTime: 180000 + +dataFilePath: /home/jiaoyou/projects/inferenceTotal/data/ + +configFilePath: /home/jiaoyou/projects/inferenceTotal/config/ + +userFilePath: /home/jiaoyou/projects/inferenceTotal/user/ + diff --git a/src/main/resources/application-uat.yml b/src/main/resources/application-uat.yml index 10a7bd1..738a27d 100644 --- a/src/main/resources/application-uat.yml +++ b/src/main/resources/application-uat.yml @@ -7,7 +7,7 @@ server: spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/inference_game?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC + url: jdbc:mysql://localhost:3306/inference_reflection?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC username: root password: dgKNTmt2iLHNjEQajkDEZkq8 type: com.alibaba.druid.pool.DruidDataSource @@ -20,16 +20,32 @@ spring: time-between-eviction-runs-millis: 20000 #配置一个连接在池中最小生存的时间 min-evictable-idle-time-millis: 300000 + #redis配置 + redis: + host: localhost + port: 6379 + pool: + max-active: 8 + max-wait: -1 + max-idle: 8 + min-idle: 0 + timeout: 5000 #对话过期时间 expireTime: 180000 +#redis的key过期时间 +redisExpireTime: 360000 + #玩家无操作时长,默认下线 offlineTime: 180000 -speechFilePath: /home/jiaoyou/projects/inferenceGame/speech/ +dataFilePath: /home/jiaoyou/projects/inferenceGame/data/ configFilePath: /home/jiaoyou/projects/inferenceGame/config/ userFilePath: /home/jiaoyou/projects/inferenceGame/user/ +#花仙系统的请求链接 +gardenSysUrl: http://127.0.0.1:60016 + diff --git a/src/main/resources/application-xiuxianPro.yml b/src/main/resources/application-xiuxianPro.yml new file mode 100644 index 0000000..69e8b4b --- /dev/null +++ b/src/main/resources/application-xiuxianPro.yml @@ -0,0 +1,51 @@ +server: + port: 60022 + serlvet: + context-type:/inference + +#设置当前服务名 +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/inference_reflection?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC + username: root + password: dgKNTmt2iLHNjEQajkDEZkq8 + type: com.alibaba.druid.pool.DruidDataSource + druid: + initial-size: 5 + min-idle: 5 + max-active: 20 + max-wait: 60000 + #配置间隔多久才进行一次检测,检测需要关闭的空闲连接 + time-between-eviction-runs-millis: 20000 + #配置一个连接在池中最小生存的时间 + min-evictable-idle-time-millis: 300000 + #redis配置 + redis: + host: localhost + port: 6379 + pool: + max-active: 8 + max-wait: -1 + max-idle: 8 + min-idle: 0 + timeout: 5000 + +#对话过期时间 +expireTime: 180000 + +#玩家无操作时长,默认下线 +offlineTime: 180000 + +#redis的key过期时间 +redisExpireTime: 360000 + +dataFilePath: /home/jiaoyou/projects/inferenceXiuxian/data/ + +configFilePath: /home/jiaoyou/projects/inferenceXiuxian/config/ + +userFilePath: /home/jiaoyou/projects/inferenceXiuxian/user/ + +#花仙系统的请求链接 +gardenSysUrl: http://127.0.0.1:60016 + diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index fc3033b..caf4dfc 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,3 +1,3 @@ spring: profiles: - active: pro \ No newline at end of file + active: dev \ No newline at end of file diff --git a/src/main/resources/speech/ask.yaml b/src/main/resources/speech/ask.yaml index 2baabcb..32fdec9 100755 --- a/src/main/resources/speech/ask.yaml +++ b/src/main/resources/speech/ask.yaml @@ -1,4 +1,4 @@ -#存放路径已改为:/home/inferenceGame/speech/ +#询问话术 aside: 100001: - 【旁白@正常】您还没告诉我想看谁呢。 @@ -20,142 +20,144 @@ aside: 100101: - 【旁白@正常】【1】。 100102: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100103: - 【旁白@正常】不好意思,我不知道 100104: - 【旁白@正常】 100105: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100106: - 【旁白@正常】不好意思,我不知道 #1002: 询问A是否是某个性格 100203: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100204: - 【旁白@正常】不好意思,我不知道 #1003: 询问A和B是什么关系 100302: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100303: - 【旁白@正常】不好意思,我不知道 #1004: 询问A和B是不是某个关系 100403: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100404: - 【旁白@正常】不好意思,我不知道 #1005: 询问和A有某个关系的人是谁 100502: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100503: - 【旁白@正常】不好意思,我不知道 #1006: 询问谁和谁有某个关系 100602: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100603: - 【旁白@正常】不好意思,我不知道 #1007: 询问A有过什么行为 100702: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100703: - 【旁白@正常】不好意思,我不知道 #1008: 询问A和B有什么行为 100802: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100803: - 【旁白@正常】不好意思,我不知道 #1009: 询问A和谁有了某个行为 100902: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100903: - 【旁白@正常】不好意思,我不知道 #1010: 询问A有没有发生过某个行为 101003: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101004: - 【旁白@正常】 #1011: 询问A和B有没有发生过某个行为 101103: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101104: - 【旁白@正常】不好意思,我不知道 #1012: 询问A知道/看见了B和C的什么行为 101202: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101203: - 【旁白@正常】不好意思,我不知道 #1013: 询问A有没有看到B和C发生了某个行为 101303: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101304: - 【旁白@正常】不好意思,我不知道 #1014: 询问A知道什么行为事件 101402: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101403: - - 【旁白@正常】不好意思,我不知道 + - 【旁白@正常】不好意思,我不??道 #1015: 询问A的提升信任度任务 101502: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 + 101503: - 【旁白@正常】不好意思,我不知道 #1016: 询问A的提升威慑度任务 101602: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101603: - 【旁白@正常】不好意思,我不知道 #1017: 询问A是否有某个提升信任度的任务 101702: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101703: - 【旁白@正常】不好意思,我不知道 #1018: 询问A是否有某个提升威慑度的任务 101803: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101804: - 【旁白@正常】不好意思,我不知道 #1019: 询问A降低信任度的任务 101902: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101903: - 【旁白@正常】不好意思,我不知道 #1020: 询问A降低威慑度的任务 102002: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 102003: - 【旁白@正常】不好意思,我不知道 #1021: 询问A是否有某个降低信任度的任务 102103: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 102104: - - 【旁白@正常】不好意思,我不知道 + - 【旁白@正常】不好意思,我不知道。 + #1022: 询问A是否有某个降低威慑度的任务 102203: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 102204: - 【旁白@正常】不好意思,我不知道 #1023: 询问A是什么身份 102301: - 【旁白@正常】【1】。 102302: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 102303: - 【旁白@正常】不好意思,我不知道 #1024: 询问A是不是某个身份 102401: - 【旁白@正常】【1】。 102402: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 102403: - 【旁白@正常】不好意思,我不知道 #1025: 询问A在哪个场所 102502: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 102503: - 【旁白@正常】不好意思,我不知道 #1026: 询问A是不是在某个场所 102603: - - 【旁白@正常】我又不认识你,为什么要告诉你? + - 【旁白@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 102604: - 【旁白@正常】不好意思,我不知道 @@ -169,11 +171,15 @@ person: 100101: - 【人物名称@正常】【1】 100102: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。。 10010201: - - 【人物名称@正常】我又不认识你,为什么要告诉你关于我的事。 + - 【人物名称@正常】这个我不方便回答。也许你可以四处走走看看有没别的消息。 + + 100103: - 【人物名称@正常】不好意思,我不知道【1】的性格。 + 10010301: + - 【人物名称@正常】不好意思,我不知道【1】的爱好。 100104: - 【人物名称@正常】 100105: @@ -184,217 +190,282 @@ person: 100201: - 【人物名称@正常】是的,【1】 100202: - - 【人物名称@正常】不是,【1】 + - 【人物名称@正常】这个嘛。【1】 100203: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。。 10020301: - - 【人物名称@正常】我又不认识你,为什么要告诉你我的事? + - 【人物名称@正常】这个我不方便回答。也许你可以四处走走看看有没别的消息。 + 100204: - 【人物名称@正常】不好意思,我不知道【1】的性格。 #1003: 询问A和B是什么关系 100301: - 【人物名称@正常】【1】 100302: - - 【人物名称@正常】我又不认识你,为什么要告诉你他们的关系? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。。 10030201: - - 【人物名称@正常】我又不认识你,为什么要告诉你我们的关系? + - 【人物名称@正常】这个我不方便回答。也许你可以四处走走看看有没别的消息。? 100303: - 【人物名称@正常】不好意思,我不知道他们的关系。 10030301: - - 【人物名称@正常】【1】吗?我好像不认识这个人啊 + - 【人物名称@正常】你这样问,我也不好回答啊。 #1004: 询问A和B是不是某个关系 100401: - 【人物名称@正常】是的,【1】 100402: - - 【人物名称@正常】不是,【1】 + - 【人物名称@正常】这个嘛。【1】 100403: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100404: - 【人物名称@正常】不好意思,我不知道他们的关系。 #1005: 询问和A有某个关系的人是谁 100501: - 【人物名称@正常】【1】 100502: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100503: - - 【人物名称@正常】不好意思,我不知道【1】【2】是谁。 + - 【人物名称@正常】不好意思,我不知道【1】和谁有【2】关系。 #1006: 询问谁和谁有某个关系 100601: - 【人物名称@正常】【1】 100602: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100603: - 【人物名称@正常】不好意思,我不知道有【1】关系的人。 #1007: 询问A有过什么行为 100701: - 【人物名称@正常】【1】 100702: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100703: - 【人物名称@正常】不好意思,我不知道【1】干过什么。 #1008: 询问A和B有什么行为 100801: - 【人物名称@正常】【1】 100802: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100803: - 【人物名称@正常】不好意思,我不知道他们干过什么。 #1009: 询问A和谁有了某个行为 100901: - 【人物名称@正常】【1】 100902: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 100903: - 【人物名称@正常】不好意思,我不知道【1】和谁【2】了。 #1010: 询问A有没有发生过某个行为 101001: - 【人物名称@正常】是的,【1】 101002: - - 【人物名称@正常】不是,【1】 + - 【人物名称@正常】这个嘛。【1】 101003: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101004: - 【人物名称@正常】不好意思,我不知道【1】有没有【2】过。 #1011: 询问A和B有没有发生过某个行为 101101: - 【人物名称@正常】是的,【1】 101102: - - 【人物名称@正常】不是,【1】 + - 【人物名称@正常】这个嘛。【1】 101103: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101104: - 【人物名称@正常】不好意思,我不知道他们有没有【1】过。 #1012: 询问A知道/看见了B和C的什么行为 101201: - 【人物名称@正常】【1】 101202: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101203: - 【人物名称@正常】不好意思,我不知道。 #1013: 询问A有没有看到B和C发生了某个行为 101301: - 【人物名称@正常】是的,【1】 101302: - - 【人物名称@正常】不是,【1】 + - 【人物名称@正常】这个嘛。【1】 101303: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101304: - 【人物名称@正常】不好意思,我不知道 #1014: 询问A知道什么行为事件 101401: - 【人物名称@正常】【1】 101402: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101403: - 【人物名称@正常】不好意思,我不知道【1】。 #1015: 询问A的提升信任度任务 101501: - 【人物名称@正常】【1】 101502: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101503: - 【人物名称@正常】你想知道的我都已经告诉过你了。 101504: - 【人物名称@正常】不好意思,我不知道【1】想干什么。 + 101505: + - 【人物名称@正常】你可以等下再来找我吗? + 【搭档名称@正常】我们先出去逛逛再回来吧。 + - 【人物名称@正常】我有点累了,你晚点再来好吗? + 【搭档名称@正常】我们先出去逛逛再回来吧。 + - 【人物名称@正常】我有点累了。晚点再来好吗? + 【搭档名称@正常】过会儿再来找【1】吧。 + - 【人物名称@正常】我现在有急事,你可以晚点再来吗? + 【搭档名称@正常】我建议你过会儿再来找【1】吧。 + 101506: + - 【人物名称@正常】没有,我没什么可说的了。 + 101507: + - 【搭档名称@正常】有空可以去找【1】看看吧。 + #1016: 询问A的提升威慑度任务 101601: - 【人物名称@正常】【1】 101602: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101603: - 【人物名称@正常】不好意思,我不知道【1】怕什么。 + 101604: + - 【人物名称@正常】你想知道的我都已经告诉过你了。 + 101605: + - 【人物名称@正常】你问这个是什么用意?小心我报官啊。 + 101606: + - 【人物名称@正常】你可以等下再来找我吗? + 【搭档名称@正常】我们先出去逛逛再回来吧。 + - 【人物名称@正常】我有点累了,你晚点再来好吗? + 【搭档名称@正常】我们先出去逛逛再回来吧。 + - 【人物名称@正常】我有点累了。晚点再来好吗? + 【搭档名称@正常】过会儿再来找【1】吧。 + - 【人物名称@正常】我现在有急事,你可以晚点再来吗? + 【搭档名称@正常】我建议你过会儿再来找【1】吧。 + 101607: + - 【搭档名称@正常】有空可以去找【1】看看吧。 #1017: 询问A是否有某个提升信任度的任务 101701: - 【人物名称@正常】是的,【1】 101702: - - 【人物名称@正常】不是,【1】 + - 【人物名称@正常】这个嘛。【1】 101703: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101704: - 【人物名称@正常】不好意思,我不知道可不可以。 + 101705: + - 【人物名称@正常】你想知道的我都已经告诉过你了。 #1018: 询问A是否有某个提升威慑度的任务 101801: - 【人物名称@正常】是的,【1】 101802: - - 【人物名称@正常】不是,【1】 + - 【人物名称@正常】这个嘛。【1】 101803: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101804: - 【人物名称@正常】不好意思,我不知道这样【1】会不会怕你。 + 101805: + - 【人物名称@正常】你想知道的我都已经告诉过你了。 + 101806: + - 【人物名称@正常】你别没事找事,我可不怕你。 #1019: 询问A降低信任度的任务 101901: - 【人物名称@正常】【1】 101902: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 101903: - 【人物名称@正常】不好意思,我不知道这样【1】会不会不喜欢你。 + 101904: + - 【人物名称@正常】你想知道的我都已经告诉过你了。 + 101905: + - 【人物名称@正常】别这样问我,我们关系还不错吧,又不讨厌你。 #1020: 询问A降低威慑度的任务 102001: - 【人物名称@正常】【1】 102002: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 102003: - 【人物名称@正常】不好意思,我不知道【1】会不会对你改观。 + 102004: + - 【人物名称@正常】你想知道的我都已经告诉过你了。 + 102005: + - 【人物名称@正常】没用的,我们关系暂时就这样了。 #1021: 询问A是否有某个降低信任度的任务 102101: - 【人物名称@正常】是的,【1】 102102: - - 【人物名称@正常】不是,【1】 + - 【人物名称@正常】这个嘛。【1】 102103: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 102104: - 【人物名称@正常】不好意思,我不知道这样【1】会不会不喜欢你。 + 102105: + - 【人物名称@正常】你想知道的我都已经告诉过你了。 + 102106: + - 【人物名称@正常】没有,你人挺好的。 #1022: 询问A是否有某个降低威慑度的任务 102201: - 【人物名称@正常】是的,【1】 102202: - - 【人物名称@正常】不是,【1】 + - 【人物名称@正常】这个嘛。【1】 102203: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 102204: - 【人物名称@正常】不好意思,我不知道能不能让【1】不讨厌你。 + 102205: + - 【人物名称@正常】你想知道的我都已经告诉过你了。 + 102206: + - 【人物名称@正常】我现在暂时还不想理你,别问了。 #1023: 询问A是什么身份 102301: - 【人物名称@正常】【1】 102302: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 102303: - 【人物名称@正常】不好意思,我不知道【1】的身份。 #1024: 询问A是不是某个身份 102401: - 【人物名称@正常】是的,【1】 102402: - - 【人物名称@正常】不是,【1】 + - 【人物名称@正常】这个嘛。【1】 102403: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 102404: - 【人物名称@正常】不好意思,我不知道是不是【1】。 #1025: 询问A在哪个场所 102501: - 【人物名称@正常】【1】 102502: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 102503: - 【人物名称@正常】不好意思,我不知道【1】在哪。 + 102504: + - 【人物名称@正常】我不就在【1】吗。 #1026: 询问A是不是在某个场所 102601: - 【人物名称@正常】是的,【1】 102602: - - 【人物名称@正常】不是,【1】 + - 【人物名称@正常】这个嘛。【1】 102603: - - 【人物名称@正常】我又不认识你,为什么要告诉你? + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 102604: - 【人物名称@正常】不好意思,我不知道【1】在哪。 #1027: 询问提示 102701: - 【人物名称@正常】你可以去问问【1】,他可能知道点什么。 102702: - - 【人物名称@正常】抱歉,爱莫能助。 + - 【人物名称@正常】抱歉,爱莫能助。我们去其他地方看看吧? #1029: 询问玩家所在场所 102901: - - 【人物名称@正常】主人,我们在【1】呀。 - #1030: 搭档说话 - 103001: - - 【寒烟@正常】这个县城里有各色各样的人物,您可以试着从打招呼、送小费开始,到帮助对方解决麻烦,来拉进和对方的关系,或者使用暴力,让对方畏惧于你,以逐步挖掘更深的线索,并最终找出目标。如果一开始没有头绪,少主也可以四处走走,多跟人聊聊天,搜集一下信息。您想去哪里或者找谁,直接说就好。如果发现了任何蛛丝马迹,我会及时提醒少主的。另外,关于人物、地点和关系,如果少主不记得了,也可以随时向我提问。 + - 【人物名称@正常】我们在【1】呀。 + #1030: 询问最终线索 103002: - - 【寒烟@正常】我们现在在【1】,看到【2】了,我们过去打个招呼吧。 + - 【人物名称@正常】关系不足。也许你可以到处走走,看看有没有新的事件发生。 + 103003: + - 【人物名称@正常】不好意思,我不知道这件事。 + #1031: 搭档说话 + 103101: + - 【人物名称@正常】这个县城有各色各样的人物,您可以试着从打招呼、送钱开始,到帮助对方解决麻烦,拉进彼此关系,或者使用暴力,让对方畏惧于你,以逐步挖掘更深的线索,并最终找出目标。如果一开始没有头绪,少爷也可以四处走走,多跟人聊聊天,搜集一下信息,如果发现了任何蛛丝马迹,我会及时提醒少主的。如果不知道去哪里,可以说“我可以去哪里”。另外,关于这里的人物和关系,如果少爷不记得了,也可以随时向我提问。 + 103102: + - 【主持人@正常】你回来了,让我们继续录制这段浪漫的恋爱之旅吧。你可以说“查看场所”看看有哪些地方可以去探索。 + #1032: 搭档说话 + 103201: + - 我们走吧,这人暂时问不出更重要的消息了,去先找别人问问吧。 + - 我们去问问其他人吧,也许会有别的线索呢! + - 感觉从这个人身上得不到什么有用的信息,我们换个人问问吧。 + - 我们去找其他人问问吧,感觉这个人身上没有什么有用的线索。 \ No newline at end of file diff --git a/src/main/resources/speech/barrier.yaml b/src/main/resources/speech/barrier.yaml index 5b5f4e8..f3c0ccc 100644 --- a/src/main/resources/speech/barrier.yaml +++ b/src/main/resources/speech/barrier.yaml @@ -10,9 +10,11 @@ aside: 400103: - 【旁白@正常】不知道您说的这个地方在哪呢。 400104: - - 【旁白@正常】这个地方没有你要找的人。 + - 【旁白@正常】没有这个地方,换其他地方试试吧,您可以说:我可以去哪里。 400105: - 【旁白@正常】你想要去哪里呢?目前已知场所有:【1】。 + 400106: + - 【旁白@正常】序号过大了,目前最多只有【1】哦。 #4002: 开启对话 400201: - 【旁白@正常】【1】当前线索有:【2】,您要详细查看哪一类的线索呢? @@ -36,6 +38,13 @@ aside: - 【旁白@正常】好的,您已放弃挑战本关卡,请重新挑选一个关卡等级进行挑战。 400403: - 【旁白@正常】好的,您将继续挑战本关卡。 + #4005: 退出关卡 + 400501: + - 【旁白@正常】你想要退出土之秘境吗?这样你将错过很多精彩剧情,并无法其他更多获得奖励,请问你确定吗? + 400502: + - 【旁白@正常】好的,您已放弃挑战土之秘境,现在已回到花园,下次若准备妥当可重新挑战。 + 400503: + - 【旁白@正常】好的,您将继续挑战次秘境。 diff --git a/src/main/resources/speech/check.yaml b/src/main/resources/speech/check.yaml old mode 100644 new mode 100755 index 9b90051..c1df0fd --- a/src/main/resources/speech/check.yaml +++ b/src/main/resources/speech/check.yaml @@ -31,7 +31,7 @@ aside: 300501: - 【旁白@正常】您当前已知线索【1】条,请问想要查看关于人物的线索还是不同类型的线索呢? 30050101: - - 【旁白@正常】您当前还没有获得任何线索,我能给您提供点建议。 + - 您当前还没有获得任何线索,我能给您提供点建议。 300502: - 【旁白@正常】当前已知人物【1】名:【2】,想要知道哪个人物的相关线索呢?说出他的名称即可。 30050201: @@ -39,7 +39,7 @@ aside: 300503: - 【旁白@正常】当前已知【1】,想要知晓哪个类型线索呢? 30050301: - - 【旁白@正常】您当前还没有收集到线索,我能给您提供点建议。 + - 您当前还没有收集到线索,我能给您提供点建议。 300504: - 【旁白@正常】【1】已知线索【2】条,其中【3】,想要了解【1】的哪种线索呢? 30050401: @@ -62,17 +62,25 @@ aside: - 【旁白@正常】您想看什么类型的线索呢? 30050605: - 【旁白@正常】没有这种类型的线索哦。 + 30050606: + - 【旁白@正常】【1】的【2】线索共【3】条,第【4】条:【5】 + 30050607: + - 【旁白@正常】【1】的【2】线索共【3】条,第【4】条:【5】要重新查看吗? #3006: 询问谁和谁有某个关系 300601: - 【旁白@正常】您当前排名积分为:【1】。 + #3007: 询问某人的模糊处理操作 + 3007: + - 【搭档名称@正常】那我们下次再说吧。 + - 【搭档名称@正常】嗯嗯,我们下次再说这件事。 #3101: 询问某人的模糊处理操作 310101: - - 【寒烟@正常】您还没告诉要看谁的呢。 + - 【人物名称@正常】您还没告诉要看谁的呢。 310102: - - 【寒烟@正常】没有您说的这个人哦。 + - 【人物名称@正常】没有您说的这个人哦。 310103: - - 【寒烟@正常】【1】,年龄【2】,性别【3】,身份【4】,其他信息不详。 + - 【人物名称@正常】【1】,年龄【2】,性别【3】,身份【4】,其他信息不详。 310104: - - 【寒烟@正常】【1】,年龄【2】,性别【3】,身份【4】,【5】对你的信任度为:【6】、威慑度为:【7】。 + - 【人物名称@正常】【1】,年龄【2】,性别【3】,身份【4】,【5】对你的信任度为:【6】、威慑度为:【7】。 diff --git a/src/main/resources/speech/partnerItem.yaml b/src/main/resources/speech/partnerItem.yaml new file mode 100644 index 0000000..df2545f --- /dev/null +++ b/src/main/resources/speech/partnerItem.yaml @@ -0,0 +1,86 @@ +#伙伴系统话术 +aside: + #使用伙伴能力 + 700102: + - 【旁白@正常】【1】的能力需求条件不满足,无法对他使用能力。 + 700103: + - 【旁白@正常】您要使用谁的能力呢?告诉我一个伙伴名称。 + 700104: + - 【旁白@正常】您要对谁使用能力呢?告诉我一个目标名称。 + 700105: + - 【旁白@正常】【1】已经对他使用过能力了。 + 700106: + - 【旁白@正常】你还没有该伙伴。 + 700107: + - 【旁白@正常】【1】现在帮不了你忙了。 + #使用物品能力 + 700202: + - 【旁白@正常】【1】的能力需求条件不满足,无法对他使用能力。 + 700203: + - 【旁白@正常】您要使用哪个物品的能力呢? + 700204: + - 【旁白@正常】您要对谁使用能力呢?告诉我一个目标名称。 + 700205: + - 【旁白@正常】【1】已经对他使用过能力了。 + 700206: + - 【旁白@正常】你还没有【1】。 + 700207: + - 【旁白@正常】你已经用完了【1】哦。 + #遣散伙伴 + 700301: + - 【旁白@正常】【1】即将离开队伍,离队后无法使用他的能力,确定让他离队吗? + 700302: + - 【旁白@正常】队伍中没有这个人。 + 700303: + - 【旁白@正常】【1】已离开队伍。 + 700304: + - 【旁白@正常】好的。 + 700305: + - 【旁白@正常】你想遣散谁呢? + #丢弃物品 + 700401: + - 【旁白@正常】即将丢弃【1】,丢弃后无法再次使用能力,确定丢弃吗? + 700402: + - 【旁白@正常】背包中没有这个物品。 + 700403: + - 【旁白@正常】已丢弃【1】。 + 700404: + - 【旁白@正常】好的。 + 700405: + - 【旁白@正常】你想丢掉哪个呢? + #查看伙伴/物品 + 700501: + - 【旁白@正常】【1】,【2】,还可以使用【3】次能力。 + 700502: + - 【旁白@正常】找不到你说的这个。 + 700503: + - 【旁白@正常】【1】,【2】。 + 700504: + - 【旁白@正常】这个人还没有成为你的伙伴哦。 + 700505: + - 【旁白@正常】你还没有这个物品哦。 + 700506: + - 【旁白@正常】你要看什么呢? + #查看队伍 + 700601: + - 【旁白@正常】队伍中有【1】名伙伴:【2】。队伍中还有【3】个空位,声望达到【4】可增加位置上限【5】。 + 700602: + - 【旁白@正常】队伍中有【1】名伙伴:【2】。队伍中已经满了,声望达到【3】可增加位置上限【4】。 + 700603: + - 【旁白@正常】队伍中有【1】名伙伴:【2】。队伍中还有【3】个空位。 + 700604: + - 【旁白@正常】队伍中还没有伙伴。 + #查看背包 + 700701: + - 【旁白@正常】背包中有【1】件道具:【2】。背包中还有【3】个空位,声望达到【4】可增加位置上限【5】。 + 700702: + - 【旁白@正常】背包中有【1】件道具:【2】。背包中满了,声望达到【4】可增加位置上限【5】。 + 700703: + - 【旁白@正常】背包中有【1】件道具:【2】。 + 700704: + - 【旁白@正常】背包中有【1】件杂物:【2】。 + 700705: + - 【旁白@正常】背包中还没有物品。 + #加入背包 + 700802: + - 【旁白@正常】已经放不下了。 \ No newline at end of file diff --git a/src/main/resources/speech/task.yaml b/src/main/resources/speech/task.yaml old mode 100644 new mode 100755 index 9c6313a..6141733 --- a/src/main/resources/speech/task.yaml +++ b/src/main/resources/speech/task.yaml @@ -1,4 +1,4 @@ -#存放路径已改为:/home/inferenceGame/speech/ +#存放路径已改为:/home/inferenceGame/speech/ aside: #2001: 饮酒 200101: @@ -99,35 +99,35 @@ aside: #2019: 探听身家 201901: - 【旁白@正常】【1】得意地对你伸出五个手指。 - #2020:解救被绑女孩 + #2020:解救被绑女孩 202001: - 【旁白@正常】 202002: - 【旁白@正常】 202003: - 【旁白@正常】 - #2021:审问罪犯供出老巢 + #2021:审问罪犯供出老巢 202101: - 【旁白@正常】 202102: - 【旁白@正常】 202103: - 【旁白@正常】 - #2022:交出藏宝图 + #2022:交出藏宝图 202201: - 【旁白@正常】 202202: - 【旁白@正常】 202203: - 【旁白@正常】 - #2023:抓捕人犯 + #2023:抓捕人犯 202301: - 【旁白@正常】 202302: - 【旁白@正常】 202303: - 【旁白@正常】 - #2024:抓捕人犯 + #2024:抓捕人犯 202401: - 【旁白@正常】 202402: @@ -136,7 +136,7 @@ aside: - 【旁白@正常】 202404: - 【旁白@正常】 - #2025:购买物品完成 + #2025:购买物品完成 202501: - 【旁白@正常】 202502: @@ -147,7 +147,7 @@ aside: - 【旁白@正常】【1】冷淡地看了你一眼。 202505: - 【旁白@正常】你将【1】转交给【2】,虽然这是假的,但【3】依然对你表示了感激。 - #2026:大夫出诊完成 + #2026:大夫出诊完成 202601: - 【旁白@正常】 202602: @@ -156,7 +156,7 @@ aside: - 【旁白@正常】 202604: - 【旁白@正常】【1】冷淡地看了你一眼。 - #2027:寻回物品完成 + #2027:寻回物品完成 202701: - 【旁白@正常】 202702: @@ -165,7 +165,7 @@ aside: - 【旁白@正常】 202704: - 【旁白@正常】【1】冷淡地看了你一眼。 - #2028:打探肥羊完成 + #2028:打探肥羊完成 202801: - 【旁白@正常】 202802: @@ -174,7 +174,7 @@ aside: - 【旁白@正常】 202804: - 【旁白@正常】【1】冷淡地看了你一眼。 - #2029:催账完成 + #2029:催账完成 202901: - 【旁白@正常】 202902: @@ -183,14 +183,14 @@ aside: - 【旁白@正常】 202904: - 【旁白@正常】 - #2030:催账 + #2030:催账 203001: - 【旁白@正常】 203002: - 【旁白@正常】 203003: - 【旁白@正常】 - #2031:砸场子完成 + #2031:砸场子完成 203101: - 【旁白@正常】 203102: @@ -199,14 +199,14 @@ aside: - 【旁白@正常】 203104: - 【旁白@正常】 - #2032:砸场子 + #2032:砸场子 203201: - 【旁白@正常】 203202: - 【旁白@正常】 203203: - 【旁白@正常】【1】挥拳朝你扑过来,你被打得鼻青脸肿。 - #2033:探听隐私完成 + #2033:探听隐私完成 203301: - 【旁白@正常】 203302: @@ -215,14 +215,14 @@ aside: - 【旁白@正常】 203304: - 【旁白@正常】 - #2034:探听隐私 + #2034:探听隐私 203401: - 【旁白@正常】【1】 203402: - 【旁白@正常】你已经知道他的隐私了。 203403: - 【旁白@正常】【1】挥拳朝你扑过来,你被打得鼻青脸肿。 - #2035:试药 + #2035:试药 203501: - 【旁白@正常】 203502: @@ -231,7 +231,7 @@ aside: - 【旁白@正常】 203504: - 【旁白@正常】【1】不屑地冲你摆摆手。 - #2036:证据账本完成 + #2036:证据账本完成 203601: - 【旁白@正常】 203602: @@ -242,7 +242,7 @@ aside: - 【旁白@正常】 203605: - 【旁白@正常】 - #2037:证据账本 + #2037:证据账本 203701: - 【旁白@正常】 203702: @@ -251,7 +251,7 @@ aside: - 【旁白@正常】 203704: - 【旁白@正常】【1】挥拳朝你扑过来,你被打得鼻青脸肿。 - #2038:证据账本类型2完成 + #2038:证据账本类型2完成 203801: - 【旁白@正常】 203802: @@ -260,7 +260,7 @@ aside: - 【旁白@正常】 203804: - 【旁白@正常】 - #2039:栽赃陷害完成 + #2039:栽赃陷害完成 203901: - 【旁白@正常】 203902: @@ -269,7 +269,7 @@ aside: - 【旁白@正常】 203904: - 【旁白@正常】 - #2040:栽赃陷害类型2完成 + #2040:栽赃陷害类型2完成 204001: - 【旁白@正常】 204002: @@ -278,7 +278,7 @@ aside: - 【旁白@正常】 204004: - 【旁白@正常】 - #2041:栽赃陷害类型2完成 + #2041:栽赃陷害类型2完成 204101: - 【旁白@正常】 204102: @@ -301,8 +301,10 @@ person: - 【人物名称@正常】好酒!嗝儿! 200103: - 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 200104: + - 【人物名称@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 200105: - - 【人物名称@正常】这酒还是算了吧。 + - 【人物名称@正常】凭你我的关系,喝酒还是算了吧。 200106: - 【人物名称@正常】谢谢,我不喝酒。 #2002: 打招呼 @@ -311,31 +313,31 @@ person: 200202: - 【人物名称@正常】又是你啊,有事吗? 200203: - - 【人物名称@正常】找我何事? - 200204: + - 【旁白@正常】【A】淡淡地扫了你一眼,仿佛没听见。【人物名称@正常】找我何事? + 200205: - 【人物名称@正常】不好意思,我很忙。 - #2003: 买古董 + #2003: 卖古董 200301: - 【人物名称@正常】既然出得起价钱,此物便交予你了。 200302: - 【人物名称@正常】罢了。惹不起你。此物便卖给你吧。 200303: - - 【人物名称@正常】【1】文,不能再少了。你身上的钱可不够。 - 200304: - 【人物名称@正常】我们好像不熟吧?抱歉这是我心爱之物,不能随意割爱。 + 200304: + - 【人物名称@正常】【条件2】文,不能再少了。你身上的钱可不够。 200305: - - 【人物名称@正常】抱歉,我这不买这东西。 + - 【人物名称@正常】没有没有,快走快走。 #2004: 买药 200401: - 【人物名称@正常】自无不可。 200402: - 【人物名称@正常】你已经买过金疮药了。此物多买无益。 200403: - - 【人物名称@正常】你身上连【1】文都没有,可不足以买我的药。 - 200404: - 【人物名称@正常】我的药不卖给险恶之人。快走快走。 + 200404: + - 【人物名称@正常】你身上连【条件2】文都没有,可不足以买我的药。 200405: - - 【人物名称@正常】抱歉,我没有药可卖。 + - 【人物名称@正常】没有没有,快走快走。 #2005: 获赠金疮药 200501: - 【人物名称@正常】以你我的交情,还谈什么钱。这份金疮药我送你了。 @@ -343,54 +345,56 @@ person: - 【人物名称@正常】你已经买过金疮药了。此物多买无益。 200503: - 【人物名称@正常】我这金疮药得来不易,以你我的交情,还不足以让我割爱。 - 200504: - - 【人物名称@正常】我没有金疮药,卖不了。 + 200505: + - 【人物名称@正常】没有没有,快走快走。 #2006: 揍人 200601: - 【人物名称@正常】我和你无冤无仇……哎哟!哎哟! 200602: - - 【人物名称@正常】刚刚才被你欺负了一场,怎么又来!哎哟! + - 【人物名称@正常】刚刚才被你欺负了一场,怎么又来!哎哟!【旁白@正常】你狠狠揍了【A】一顿。 200603: - - 【人物名称@正常】呸,凭你的细胳膊细腿也配和我动手?找死。 - 200604: - - 【人物名称@正常】别动手啊,告诉你,打我也没用。 + - 【人物名称@正常】呸,凭你的细胳膊细腿也配和我动手?找死。【旁白@正常】你被【A】狠狠收拾了一顿,被揍得鼻青脸肿。 + 200605: + - 【人物名称@正常】我和你往日无冤,近日无仇,随便动我小心吃官司。 #2007: 请吃饭 200701: - 【人物名称@正常】盛情难却,这次让你破费了。感谢,感谢。 200702: - - 【人物名称@正常】这不是刚吃过没多久吗?您也太客气了。 + - 【旁白@正常】你邀请【A】到酒楼,满满点了一桌子。【人物名称@正常】这不是刚吃过没多久吗?您也太客气了。 200703: - - 【人物名称@正常】怎么,你这是耍我呢? - 200704: - 【人物名称@正常】你的饭菜,我可吃不起。 + 200704: + - 【旁白@正常】最便宜的一桌饭菜也需要【条件2】文,你的钱不够了。【人物名称@正常】怎么,你这是耍我呢? 200705: - 【人物名称@正常】我不饿,你也别请了,请客对我没用。 #2008: 好处费 200801: - 【人物名称@正常】哎哟,这,这多不好意思的。 200802: - - 【人物名称@正常】哎哟,这,这多不好意思的。 + - 【旁白@正常】你偷偷摸出【条件2】文递给【A】。【人物名称@正常】哎哟,这,这多不好意思的。【旁白@正常】【A】不着痕迹地把银子塞进袖子里。因为打赏次数太多,信任度已经无法提升。 + 200803: + - 【旁白@正常】你偷偷摸出【条件2】文递给【A】。【人物名称@正常】哎哟,您的钱我可不敢收,怕烫手。 200804: - - 【人物名称@正常】哎哟,您的钱我可不敢收,怕烫手。 + - 【旁白@正常】打赏一次要【条件2】文,你的钱不够了。 200805: - 【人物名称@正常】我不收礼,没用的,放弃吧。 #2009: 帮挑水 200901: - 【人物名称@正常】这可太感谢你了。 200902: - - 【人物名称@正常】这可太感谢你了。 + - 【人物名称@正常】这可太感谢你了。【旁白@正常】你吭哧吭哧为【A】把水缸挑满。但是挑水这种小事已经无法再提高【第三人称】的信任度。 200903: - 【人物名称@正常】非亲非故的,不敢劳驾你。 - 200904: + 200905: - 【人物名称@正常】家里不缺水,不用你给挑。 #2010: 一起钓鱼 201001: - 【人物名称@正常】正合我意。走! 201002: - - 【人物名称@正常】想不到你兴致这么浓。那我陪你去吧。 + - 【人物名称@正常】想不到你兴致这么浓。那我陪你去吧。【旁白@正常】你陪着【A】又去钓了一场鱼。信任度没有提高。但是你顺手把钓到的小鱼卖了,获利【奖励】文。 201003: - 【人物名称@正常】钓鱼须得三五好友,情投意合才有乐趣。我跟你个陌生人去钓什么鱼! - 201004: + 201005: - 【人物名称@正常】我不钓鱼,你找别人吧。 #2011: 送货 201101: @@ -399,26 +403,28 @@ person: - 【人物名称@正常】你不是已经给过我了吗? 201103: - 【人物名称@正常】我看你面目可憎,这货我是不敢收的。回去换个人给我送吧。 - 201104: + 201105: - 【人物名称@正常】我没有东西要收,你找错人了吧。 #2012: 给钱 201201: - 【人物名称@正常】太客气了太客气了。 201202: - - 【人物名称@正常】太客气了太客气了。 - 201204: + - 【人物名称@正常】太客气了太客气了。【旁白@正常】你多次给【A】送钱,【第三人称】已经习惯成自然,信任度没有提升。 + 201203: - 【人物名称@正常】你这是干什么?非亲非故送人钱财,怕是不安好心。收回去吧。 + 201204: + - 【旁白@正常】你的钱财不足,已经拿不出手了。 201205: - - 【人物名称@正常】我差这么点钱吗,别给我来这套。 + - 【人物名称@正常】我差这么点钱吗,太小看我了吧。 #2013: 邀请医生 201301: - - 【人物名称@正常】医者父母心,我这就陪你走一趟。诊金么,先预付个【1】文吧。 + - 【人物名称@正常】医者父母心,我这就陪你走一趟。诊金么,先预付个【条件2】文吧。 201302: - 【人物名称@正常】医者父母心,陪你出诊倒是无妨。可是此人明明生龙活虎,你是想戏弄于我吗? 201303: - - 【人物名称@正常】医者父母心,我这就陪你走一趟。不过这个诊金么,先预付个【1】文吧。 - 201304: - 【人物名称@正常】话不投机,想要我陪你去却是万万不能。 + 201304: + - 【人物名称@正常】医者父母心,我这就陪你走一趟。不过这个诊金么,先预付个【条件2】文吧。【旁白】很遗憾,你掏不出【条件2】的诊金。 201305: - 【人物名称@正常】不好意思,你另请高明吧。 #2014: 给钱买茶具 @@ -427,20 +433,20 @@ person: 201402: - 【人物名称@正常】不是已经被你买走了吗?没有了没有了。你还来折腾什么? 201403: - - 【人物名称@正常】我这茶具不便宜。你口袋里那几个钱可不够。 - 201404: - 【人物名称@正常】别以为有两个破钱就了不起。这药不卖! + 201404: + - 【人物名称@正常】我这茶具不便宜。你口袋里那几个钱可不够。 201405: - - 【人物名称@正常】我没有茶具这东西,你找别人问问吧。 + - 【人物名称@正常】没有没有,快走快走。 #2015: 开怀畅饮 201501: - 【人物名称@正常】好酒!好酒!劳您破费了,咱们不醉不归! 201502: - - 【人物名称@正常】太,太,太客气了,咱们再,再,再喝。 + - 【人物名称@正常】太,太,太客气了,咱们再,再,再喝。【旁白@正常】:前不久你刚和【A】畅饮过一轮,【第三人称】的酒意未消,再喝也没有效果。 201503: - - 【人物名称@正常】我的酒量不小,你的身上的钱财怕是不够,还是算了吧。 - 201504: - 【人物名称@正常】咱们不熟,这顿酒还是免了吧。 + 201504: + - 【人物名称@正常】我的酒量不小,你的身上的钱财怕是不够,还是算了吧。 201505: - 【人物名称@正常】谢谢啊,我真不喝酒。 #2016: 买回钗子 @@ -449,11 +455,11 @@ person: 201602: - 【人物名称@正常】不是已经把钗子卖给你了吗? 201603: - - 【人物名称@正常】这钗子最少得【1】文钱,你那点钱可不够! - 201604: - 【人物名称@正常】休想。这可是美人儿贴身的钗子,怎么能卖给你。 + 201604: + - 【人物名称@正常】这钗子最少得【条件2】文钱,你那点钱可不够! 201605: - - 【人物名称@正常】别问我,我这真没钗子这样的东西。 + - 【人物名称@正常】我可没有什么钗子。你怕是听错了。 #2017: 抢回钗子 201701: - 【人物名称@正常】别,别动手,钗子在这里。给你给你。 @@ -461,8 +467,8 @@ person: - 【人物名称@正常】我,我不是已经把钗子给你了吗?哪里能给你再变个钗子出来! 201703: - 【人物名称@正常】想得美!想要回钗子,让她自己来跟我说! - 201704: - - 【人物名称@正常】抢没用,我这没有钗子。 + 201705: + - 【人物名称@正常】我可没有什么钗子。你怕是听错了。 #2018: 追回私吞款项 201801: - 【人物名称@正常】别,别动手,有话好好说,钱,钱我这就给你。 @@ -470,8 +476,8 @@ person: - 【人物名称@正常】我,我不是已经把钱给你了吗?你还想做什么?! 201803: - 【人物名称@正常】就凭你?也敢找我追账?知道死字怎么写吗? - 201804: - - 【人物名称@正常】你找我追什么帐,你找其他人吧。 + 201805: + - 【人物名称@正常】欠账?我怎么不记得。 #2019: 探听身家 201901: - 【人物名称@正常】别看我平时低调,悄悄跟你说,我的身家,最少有这个数,嘿嘿。 @@ -479,9 +485,9 @@ person: - 【人物名称@正常】不是跟你说过了吗? 201903: - 【人物名称@正常】你打听这个作什么?无可奉告! - 201904: + 201905: - 【人物名称@正常】我这没什么可问的。 - #2020:解救被绑女孩 + #2020:解救被绑女孩 202001: - 【人物名称@正常】你,你怎么知道的? 【旁白@正常】在你的威吓之下,【1】战战兢兢地打开了地窖,一位柔弱的女子正蜷缩在里面哭泣。 @@ -490,9 +496,9 @@ person: - 【人物名称@正常】你不是已经把人救走了吗,还想干嘛。 202003: - 【人物名称@正常】你在说什么,我完全听不懂! - 202004: + 202005: - 【人物名称@正常】你找错人了吧。 - #2021:审问罪犯供出老巢 + #2021:审问罪犯供出老巢 202101: - 【人物名称@正常】别动手,别动手,我说。 【旁白@正常】在你的威吓之下,【1】老老实实供出了老巢所在。你在一个月黑风高之日前去,起出了大笔金银财宝。 @@ -500,9 +506,9 @@ person: - 【人物名称@正常】我不是告诉你了吗,你已经得到答案。 202103: - 【人物名称@正常】呸,你休想知道。 - 202104: + 202105: - 【人物名称@正常】此事与我无关,不知道你在说什么。 - #2022:交出藏宝图 + #2022:交出藏宝图 202201: - 【人物名称@正常】想不到你居然能打听到如此隐秘之事。 【旁白@正常】【1】趁你不备,掏出匕首向你捅来,却被你灵活闪过。一番争斗后,【1】不是你的对手,被迫交出了藏宝图。你在一个月黑风高的夜晚去挖出了藏宝,从此声名大振,富可敌国。 @@ -510,9 +516,9 @@ person: - 【人物名称@正常】你不是已经破解了藏宝图了吗? 202203: - 【人物名称@正常】我的秘药可不是随便给人用的。告辞! - 202204: + 202205: - 【人物名称@正常】不好意思,我没有这东西。 - #2023:抓捕人犯 + #2023:抓捕人犯 202301: - 【人物名称@正常】我自以为天衣无缝,居然还是被你发现了。天意啊,天意。 【旁白@正常】你和【1】一番惊天动地的大战。你浑身是伤,最终【1】不是你的对手,束手就擒,你成功破获了此案,声名大振,从此仕途一帆风顺,成为一代名捕。 @@ -520,20 +526,20 @@ person: - 【人物名称@正常】我不是已经认罪了吗?你这是想做什么! 202303: - 【人物名称@正常】就凭你,还不足以让我认罪。给我滚! - 202304: + 202305: - 【人物名称@正常】拜托你别乱抓人好不好,别逮谁都像坏人。 - #2024:购买犯人信息 + #2024:购买犯人信息 202401: - 【人物名称@正常】嘿嘿,这还差不多,我告诉你啊,那天我刚好路过,听到一声惨叫,偷偷探头一看,发现【1】满脸鲜血,正在行凶! 202402: - - 【人物名称@正常】不是告诉你了吗,行凶的是【1】。 + - 【人物名称@正常】不是告诉你了吗,行凶的是【A】。 202403: - - 【人物名称@正常】我这消息,最少值【1】文钱,你的钱可不够买我这消息。 - 202404: - 【人物名称@正常】我跟你很熟吗?这钱我可不敢要。 + 202404: + - 【人物名称@正常】我这消息,最少值【条件2】文钱,你的钱可不够买我这消息。 202405: - 【人物名称@正常】抱歉,我没有这消息。 - #2025:购买物品完成 + #2025:购买物品完成 202501: - 【人物名称@正常】且让我看看。这,这正是我所需之物。感激不尽。 【旁白@正常】你将东西转交给【1】,【2】对你深表感激。 @@ -547,7 +553,7 @@ person: - 【人物名称@正常】且让我看看。这,这根本是假货啊!你被人骗了!算了,算了。你辛苦一场,也不容易。这点钱你收下。 202506: - 【人物名称@正常】你找错人了吧,我可没叫你帮我带东西。 - #2026:大夫出诊完成 + #2026:大夫出诊完成 202601: - 【人物名称@正常】大夫刚才已经来过,我感觉好多了。请受我一拜。 【旁白@正常】你与【1】的友好度变为【2】点,威慑度变为【3】点。 @@ -558,8 +564,8 @@ person: 202604: - 【人物名称@正常】大夫虽然来过,但是不是你请回来的我可不确定。 202605: - - 【人物名称@正常】抱歉,我不是大夫。你找错人了。 - #2027:寻回物品完成 + - 【人物名称@正常】抱歉,没有确切病人的消息前我不会出诊。 + #2027:寻回物品完成 202701: - 【人物名称@正常】哎呀,这正是我丢失的。太谢谢你了。 【旁白@正常】你与【1】的友好度变为【2】点,威慑度变为【3】点。 @@ -570,8 +576,8 @@ person: 202704: - 【人物名称@正常】虽然我一直想寻回此物,但是你给的我可不敢收。 202705: - - 【人物名称@正常】我没有让你找东西啊,你问错人了吧。 - #2028:打探肥羊完成 + - 【人物名称@正常】你这是何意,该不是问错人了吧。 + #2028:打探肥羊完成 202801: - 【人物名称@正常】想不到你还挺能干。很好。 【旁白@正常】你与【1】的友好度变为【2】点,威慑度变为【3】点。 @@ -583,7 +589,7 @@ person: - 【人物名称@正常】以我俩的交情,你这话的的真假,可说不准啊。 202805: - 【人物名称@正常】我没有让你去问啊,你搞错了吧。 - #2029:催账完成 + #2029:催账完成 202901: - 【人物名称@正常】你居然帮我把那个老赖的钱收回来了?这是一点点感谢,不成敬意。 【旁白@正常】你帮【1】收回了【2】的欠款,【3】对你满口感谢,并递给你【4】文钱作为谢礼。 @@ -595,8 +601,8 @@ person: 202904: - 【人物名称@正常】无事献殷勤,来历不明的钱我可不敢收。 202905: - - 【人物名称@正常】别人没欠我钱,你问错人啦。 - #2030:催账 + - 【人物名称@正常】你找谁催账了,弄错人了吧。 + #2030:催账 203001: - 【人物名称@正常】我给,我给。别动手。 【旁白@正常】你从【1】手上要到了拖欠的债款。 @@ -604,9 +610,9 @@ person: - 【人物名称@正常】我不是已经给你了吗?难道你想讹诈我? 203003: - 【人物名称@正常】你算老几,敢来找我要钱。 - 203004: - - 【人物名称@正常】别找我,我可没欠任何人钱。 - #2031:砸场子完成 + 203005: + - 【人物名称@正常】什么?欠账?拿出证据来。 + #2031:砸场子完成 203101: - 【人物名称@正常】哈哈哈,太好了。你果然没让我失望。这点钱你收下,就当是辛苦费。 【旁白@正常】你帮【1】大大出了一口气,你与【1】的友好度变为【2】点,威慑度变为【3】点。你获得【4】文作为辛苦费。 @@ -618,7 +624,7 @@ person: - 【人物名称@正常】你自己做下的事情,与我何干。我们很熟吗? 203105: - 【人物名称@正常】没有这事,你看错人了吧。 - #2032:砸场子 + #2032:砸场子 203201: - 【人物名称@正常】你,你欺人太甚!快住手。 【旁白@正常】你无视【1】的阻拦,将眼前一切可以砸的都砸了个稀巴烂。 @@ -627,9 +633,9 @@ person: - 【人物名称@正常】你,你还来做什么,这里还有什么可以砸的吗? 203203: - 【人物名称@正常】就凭你那三脚猫的功夫也敢来找死? - 203204: - - 【人物名称@正常】别乱来,你找错人了。 - #2033:探听隐私完成 + 203205: + - 【人物名称@正常】没凭没据你可别乱来,小心吃官司。 + #2033:探听隐私完成 203301: - 【人物名称@正常】什,什么,竟有此事? 【旁白@正常】【1】大惊失色。 @@ -643,7 +649,7 @@ person: - 【人物名称@正常】只凭你我关系,还不足以让我信任于你。 203305: - 【人物名称@正常】我没有让你去问吧,你搞错了。 - #2034:探听隐私 + #2034:探听隐私 203401: - 【人物名称@正常】莫名其妙。 【旁白@正常】【1】警惕地扫了你一眼,转身离去。你小心翼翼观察了下周围,远远跟在了【2】身后。 @@ -651,66 +657,66 @@ person: 【旁白@正常】你悄悄爬上屋顶,掀开一片瓦片,烛光下,【1】对着镜子,正轻轻把自己的脸皮撕了下来。那居然是一张人皮面具!面具下,是一张陌生的人脸!震惊之下,你赶紧溜下了屋檐。 【旁白@正常】你成功打探到了【1】的隐私!你与【1】的友好度变为【3】点,威慑度变为【4】点。 203402: - - 【人物名称@正常】你已经知道他的隐私了。 + - 【旁白@正常】你已经知道他的隐私了。 203403: - - 【人物名称@正常】就凭你那三脚猫的功夫也敢来找死? - 203404: + - 【人物名称@正常】就凭你那三脚猫的功夫也敢来找死?【旁白@正常】【A】挥拳朝你扑过来,你被打得鼻青脸肿。 + 203405: - 【人物名称@正常】我没什么可说,你找其他人吧。 - #2035:试药 + #2035:试药 203501: - 【人物名称@正常】太好了。我正在找敢试药的人呢。你且来试试。先说好,出问题了可不关我事。 【旁白@正常】你一脸视死如归地接过了那鸽蛋大的药丸,张口就吞了下去。 【旁白@正常】你满面红光,感到浑身充满了力量。 【人物名称@正常】成,成功了??太好了。这是你的报酬。拿了钱,以后有什么头疼胸闷啥的可不许赖我。 【旁白@正常】你勇敢地帮【1】试药成功,你与【1】的友好度变为【2】点,威慑度变为【3】点。你获得【4】文酬劳。 - 203502: + 203510: - 【人物名称@正常】太好了。我正在找敢试药的人呢。你且来试试。先说好,出问题了可不关我事。 【旁白@正常】你一脸视死如归地接过了那鸽蛋大的药丸,张口就吞了下去。 【旁白@正常】你眼前一黑,一头栽倒在地。 【旁白@正常】过了很久,你才悠悠醒过来,感到浑身像散架了一样。 【人物名称@正常】这,这可是你自愿的。不关我事,这点钱拿着,就算我给你的补偿。 - 【旁白@正常】很遗憾,你帮【1】试药失败,你与【1】的友好度变为【2】点,威慑度变为【3】点。你获得【4】文补偿。 - 203503: + 【旁白@正常】很遗憾,你帮【A】试药失败,你与【A】的友好度变为【信任值】点,威慑度变为【威慑度】点。你获得【奖励】文补偿。 + 203502: - 【人物名称@正常】你,你还来做什么,我没有药可以试了,快走快走。 - 203504: + 203503: - 【人物名称@正常】我们很熟吗? 203505: - - 【人物名称@正常】我药都没有,来我这试什么药。 - #2036:证据账本完成 + - 【人物名称@正常】你从哪里得来的小道消息,没有没有。 + #2036:证据账本完成 203601: - 【人物名称@正常】快让我看看。 【旁白@正常】【1】接过账本,翻看几下,大笑起来。 【人物名称@正常】好,好,好,【2】你这次在劫难逃!壮士果然身手不凡。小小心意,还请收下。 【旁白@正常】你与【1】的友好度变为【3】点,威慑度变为【4】点。你获得【5】文酬劳。 - 203602: + 203610: - 【人物名称@正常】快让我看看。 - 【旁白@正常】【1】接过账本,翻看几下,脸色难看起来。 - 【人物名称@正常】此物是假的。看来【2】早有准备。再去也无益。罢了。无论如何,多谢壮士相助,壮士身手不凡,这点心意还请收下。 - 【旁白@正常】你与【1】的友好度变为【3】点,威慑度变为【4】点。你获得【5】文酬劳。 - 203603: + 【旁白@正常】【A】接过账本,翻看几下,脸色难看起来。 + 【人物名称@正常】此物是假的。看来【B】早有准备。再去也无益。罢了。无论如何,多谢壮士相助,壮士身手不凡,这点心意还请收下。 + 【旁白@正常】你与【A】的友好度变为【信任值】点,威慑度变为【威慑度】点。你获得【奖励】文酬劳。 + 203602: - 【人物名称@正常】你不是已经给过我了吗?此事关联甚大,千万不要乱传。 - 203604: + 203603: - 【人物名称@正常】快给我看看!什么,没有?你是在戏弄我吗? - 203605: + 203604: - 【人物名称@正常】只凭你我关系,还不足以让我认定此物真假。 - 203606: + 203605: - 【人物名称@正常】你搞错了吧,我没让你去查这个啊。 - #2037:证据账本 + #2037:证据账本 203701: - 【人物名称@正常】你说什么? 【旁白@正常】你趁【1】不注意,一掌打晕了【2】。然后翻箱倒柜。 【旁白@正常】你成功偷取到了【2】的账本!你与【2】的友好度变为【3】点,威慑度变为【4】点。 - 203702: + 203710: - 【人物名称@正常】你说什么? - 【旁白@正常】你假装离去,趁夜摸进了【1】的密室,翻箱倒柜。 - 【旁白@正常】你成功偷取到了【1】的账本!你与【1】的友好度变为【2】点,威慑度变为【3】点。 + 【旁白@正常】你假装离去,趁夜摸进了【A】的密室,翻箱倒柜。 + 【旁白@正常】你成功偷取到了【A】的账本!你与【A】的友好度变为【信任值】点,威慑度变为【威慑度】点。 + 203702: + - 【旁白@正常】你已经知道他的隐私了。 203703: - - 【人物名称@正常】你已经知道他的隐私了。 - 203704: - 【人物名称@正常】就凭你那三脚猫的功夫也敢来找死? 203705: - - 【人物名称@正常】不好意思,我这没有这东西。 - #2038:证据账本类型2完成 + - 【人物名称@正常】你从哪里得来的小道消息,没有没有。 + #2038:证据账本类型2完成 203801: - 【人物名称@正常】快让我看看。 【旁白@正常】【1】接过账本,翻看几下,大笑起来。 @@ -726,7 +732,7 @@ person: - 【人物名称@正常】凭你我关系,如何才能让我相信这是真的呢? 203805: - 【人物名称@正常】你搞错了,我可没让你帮我找这个。 - #2039:栽赃陷害完成 + #2039:栽赃陷害完成 203901: - 【人物名称@正常】此事当真?好,好,好! 【旁白@正常】【1】不住点头。 @@ -740,7 +746,7 @@ person: - 【人物名称@正常】凭你我关系,如何才能让我相信这是真的呢? 203905: - 【人物名称@正常】什么事?都不知道你在说什么,你找其他人吧。 - #2040:栽赃陷害类型2完成 + #2040:栽赃陷害类型2完成 204001: - 【人物名称@正常】此事当真?好,好,好! 【旁白@正常】【1】不住点头。 @@ -757,7 +763,7 @@ person: - 【人物名称@正常】凭你我关系,如何才能让我相信这是真的呢? 204005: - 【人物名称@正常】什么事?都不知道你在说什么,你找其他人吧。 - #2041:栽赃陷害类型2完成 + #2041:栽赃陷害类型2完成 204101: - 【人物名称@正常】我已知晓此事,辛苦你了。 【旁白@正常】你与【1】的友好度变为【2】点,威慑度变为【3】点。你获得了【4】文辛苦费。 @@ -769,7 +775,66 @@ person: - 【人物名称@正常】凭你我关系,我可不敢相信。 204105: - 【人物名称@正常】不好意思,我很忙。 - #2101:买东西 + #2042:求婚 + 204202: + - 【人物名称@正常】你们不是已经成亲了吗? + 204203: + - 【人物名称@正常】少侠先别急,现在太早了,等破了案再说不迟。 + 204205: + - 【人物名称@正常】公子请自重,现在谈婚论嫁还早了点。 + #2043:赌场作弊 + 204301: + - 【人物名称@正常】哎哟,还真敢压啊。那我就不客气啦! + 【旁白@正常】快速摇晃着骰盅,左右几圈后,猛然盖倒在桌上。【搭档名称】的食指悄无声息地在桌上敲击了两下,然后对你轻轻点了点头。 + 【人物名称@正常】开! + 【旁白@正常】盖盅掀开,里面红艳艳的三个六。 + 【人物名称@正常】不,不可能!这绝对不可能! + 【搭档名称@正常】三个六,一赔一百五!快,给钱! + 204302: + - 【人物名称@正常】哎哟,还真敢压啊。那我就不客气啦! + 【旁白@正常】快速摇晃着骰盅,左右几圈后,猛然盖倒在桌上。【搭档名称】的食指悄无声息地在桌上敲击了两下,然后对你轻轻点了点头。 + 【人物名称@正常】开! + 【旁白@正常】盖盅掀开,里面红艳艳的三个一。 + 【人物名称@正常】不,不可能!这绝对不可能! + 【搭档名称@正常】三个六,一赔一百五!快,给钱! + 204303: + - 【人物名称@正常】哎哟,还真敢压啊。那我就不客气啦! + 【旁白@正常】快速摇晃着骰盅,左右几圈后,猛然盖倒在桌上。【搭档名称】的食指悄无声息地在桌上敲击了两下,然后对你轻轻点了点头。 + 【人物名称@正常】开! + 【旁白@正常】盖盅掀开,里面红艳艳的四五六,大! + 【人物名称@正常】你运气真好!来,一赔一。 + 【搭档名称@正常】少爷,买大小赢得太少啦。不如选个赔率大的,三个六或者三个一吧! + 204304: + - 【人物名称@正常】哎哟,还真敢压啊。那我就不客气啦! + 【旁白@正常】快速摇晃着骰盅,左右几圈后,猛然盖倒在桌上。【搭档名称】的食指悄无声息地在桌上敲击了两下,然后对你轻轻点了点头。 + 【人物名称@正常】开! + 【旁白@正常】骰盅掀开,里面红艳艳的一二三,小! + 【人物名称@正常】你运气真好! + 【搭档名称@正常】少爷,买大小赢得太少啦。不如选个赔率大的,三个六或者三个一吧! + 204305: + - 【人物名称@正常】小子,会不会赌啊,我这赌桌上可没这个赌法!要么压大,要么压小,要么压三个一或者三个六!只能压一样! + 204306: + - 【人物名称@正常】我的公子唉,你上次来赌,就把我输得一无所有了,您可千万别再耍我了! + 204307: + - 【人物名称@正常】赌?多少人赌得倾家荡产,你可别来害我。找别人去吧。 + 204308: + - 【人物名称@正常】三个色子,看点数。四到十点小,十一到十七点大!买大或买小,赔率都是一赔一。 + 【搭档名称@正常】那三点和十八点呢? + 【人物名称@正常】嘿嘿。压中三个一或者三个六的话,一赔一百五!你要有这胆量,大可以试试。不过,只能压一样! + 【旁白@正常】【搭档名称】轻轻将一只手搭在赌桌上。 + 【搭档名称@正常】公子,放心压注,有我在呢。你想要压什么? + #2044:砸场子 + 204401: + - 【人物名称@正常】这……这是……这是那个隐秘之地的腰牌! + 【旁白@正常】【A】大惊失色,快步走上前来,想要接过去细看,又讪讪地缩回了手。 + 【人物名称@正常】在下有眼不识泰山。公子恕罪,恕罪。 + 204402: + - 【人物名称@正常】公子出身不凡,在下如雷贯耳。还请公子把这信物收回吧。 + 204403: + - 【人物名称@正常】恕我眼拙,认不出它的来历。 + 204405: + - 【人物名称@正常】你拿这个给我看什么。 + #2101:买东西 210101: - 【人物名称@正常】既然出得起价钱,就卖给你了。 【旁白@正常】你从【1】手上买下了。 @@ -780,5 +845,736 @@ person: 210104: - 【人物名称@正常】抱歉,不卖给信不过的人。 210105: - - 【人物名称@正常】不好意思,我这不卖东西。 + - 【人物名称@正常】没有没有,快走快走。 + #2102:二次回复 + 210202: + - 【旁白@正常】你已经完成了这个任务。 + 210203: + - 【人物名称@正常】不要骗我,你明明还没有完成。 + 210204: + - 【人物名称@正常】我们之间的交情,好像还没到这地步吧? + + + + + #--------------------------------------------职场------------------------------------------------ + #2051:谴责乱扔垃圾 + 205102: + - 【人物名称@正常】别骂了别骂了,我知道错了,我不是已经道歉过了吗! + 205103: + - 【人物名称@正常】你怎么知道的?不是,我跟你又不熟,轮得到你来说我吗。 + 205105: + - 【人物名称@正常】你是不是搞错了什么,我从来没乱扔过垃圾。 + #2052:谴责抽烟 + 205202: + - 【人物名称@正常】放心,我再抽也不会被你们看到。 + 205203: + - 【人物名称@正常】我抽我的,你管得着吗?我跟你很熟?。 + 205205: + - 【人物名称@正常】你是不是搞错了什么,我不吸烟的。 + #2053:谴责邋遢 + 205302: + - 【人物名称@正常】喂,别鸡蛋里挑骨头了,我不是已经收拾干净了吗。 + 205303: + - 【人物名称@正常】邋遢的是我,跟你有什么关系,又不会传染。 + 205305: + - 【人物名称@正常】你是不是搞错人了,我看起来哪里邋遢了。 + #2054:谴责颜值 + 205402: + - 【人物名称@正常】我都戴上面具了你还想让我怎样。 + 205403: + - 【旁白@正常】【A】左顾右盼,然后转向旁边的同事,假装你说的是其他人。 + 【人物名称@正常】喂,他说你长得丑,是我就不忍了。 + 205405: + - 【人物名称@正常】你这么说就很不礼貌了,我这颜值哪里差了? + #2055:谴责骂人 + 205502: + - 【人物名称@正常】我不是说过了么,我以后不会再骂人了,除非实在忍不住。 + 205503: + - 【人物名称@正常】我没有骂人,老祖宗几千年留下的国粹,你怎么能说是骂人呢。 + 205505: + - 【人物名称@正常】你是不是搞错人了,我从来没骂过人啊。 + #2056:谴责完成 + 205602: + - 【人物名称@正常】你刚才已经告诉过我了。 + 205603: + - 【人物名称@正常】你明明就没有,我看着呢。 + 205604: + - 【人物名称@正常】你说的话我不太相信。 + 205605: + - 【人物名称@正常】我不知道你在说什么,我没有找你帮过忙啊。 + #2057:打探 + 205702: + - 【人物名称@正常】刚才跟你分享的那些,你回去记得要看哦,超有意思的。 + 205703: + - 【人物名称@正常】小帅同学,上班时间就要好好工作,别整这些有的没的。 + 205705: + - 【人物名称@正常】这是秘密,我是不会告诉你的。 + #2058:打探完成 + 205802: + - 【人物名称@正常】你刚才已经告诉过我了。 + 205803: + - 【人物名称@正常】你这打探的都是什么啊,完全不是我想要的,你再去打探一次。 + 205804: + - 【人物名称@正常】不听不听王八念经。 + 205805: + - 【人物名称@正常】你搞错人了吧,我没有想知道这些啊。 + #2059:质问打小报告 + 205902: + - 【人物名称@正常】你还是放过我吧,我下次不会再这样了。 + 205903: + - 【人物名称@正常】没有啊,不是我干的,你有什么证据吗。 + 205905: + - 【人物名称@正常】你搞错人了吧,我没有做过这种事啊。 + #2060:质问甩锅 + 206002: + - 【人物名称@正常】行了我知道错了,我会好好道歉的。 + 206003: + - 【人物名称@正常】你是住海边的吧,管得这么宽。 + 206005: + - 【人物名称@正常】你搞错人了吧,我没有做过这种事啊。 + #2061:质问完成 + 206102: + - 【人物名称@正常】嗯,我知道,但你刚才已经说过一遍了。 + 206103: + - 【人物名称@正常】没有吧,我盯着呢,你明明就没搞定。 + 206104: + - 【人物名称@正常】我觉得你不像个好人,不管你说什么,我是不会信的。 + 206105: + - 【人物名称@正常】你在说什么,我没有委托过这种事啊。 + #2062:买高档耳机 + 206202: + - 【人物名称@正常】【物品名】已经卖断货了哦。 + 206203: + - 【人物名称@正常】抱歉先生,根据您的信用评级,本商场无法为您提供服务。 + 206204: + - 【人物名称@正常】抱歉先生,您身上的钱可能没有带够。 + 206205: + - 【人物名称@正常】要买东西你应该去商场找导购员,不应该找我。 + #2063:买运动手环 + 206302: + - 【人物名称@正常】【物品名】已经卖断货了哦。 + 206303: + - 【人物名称@正常】抱歉先生,根据您的信用评级,本商场无法为您提供服务。 + 206304: + - 【人物名称@正常】抱歉先生,您身上的钱可能没有带够。 + 206305: + - 【人物名称@正常】要买东西你应该去商场找导购员,不应该找我。 + #2064:买巧克力 + 206402: + - 【人物名称@正常】【物品名】已经卖断货了哦。 + 206403: + - 【人物名称@正常】抱歉先生,根据您的信用评级,本商场无法为您提供服务。 + 206404: + - 【人物名称@正常】抱歉先生,您身上的钱可能没有带够。 + 206405: + - 【人物名称@正常】要买东西你应该去商场找导购员,不应该找我。 + #2065:买茶叶 + 206502: + - 【人物名称@正常】【物品名】已经卖断货了哦。 + 206503: + - 【人物名称@正常】抱歉先生,根据您的信用评级,本商场无法为您提供服务。 + 206504: + - 【人物名称@正常】抱歉先生,您身上的钱可能没有带够。 + 206505: + - 【人物名称@正常】要买东西你应该去商场找导购员,不应该找我。 + #2066:买化妆品 + 206602: + - 【人物名称@正常】【物品名】已经卖断货了哦。 + 206603: + - 【人物名称@正常】抱歉先生,根据您的信用评级,本商场无法为您提供服务。 + 206604: + - 【人物名称@正常】抱歉先生,您身上的钱可能没有带够。 + 206605: + - 【人物名称@正常】要买东西你应该去商场找导购员,不应该找我。 + #2067:买玩偶 + 206702: + - 【人物名称@正常】【物品名】已经卖断货了哦。 + 206703: + - 【人物名称@正常】抱歉先生,根据您的信用评级,本商场无法为您提供服务。 + 206704: + - 【人物名称@正常】抱歉先生,您身上的钱可能没有带够。 + 206705: + - 【人物名称@正常】要买东西你应该去商场找导购员,不应该找我。 + #2067:买精致餐具 + 206802: + - 【人物名称@正常】【物品名】已经卖断货了哦。 + 206803: + - 【人物名称@正常】抱歉先生,根据您的信用评级,本商场无法为您提供服务。 + 206804: + - 【人物名称@正常】抱歉先生,您身上的钱可能没有带够。 + 206805: + - 【人物名称@正常】要买东西你应该去商场找导购员,不应该找我。 + #2069:买感冒药 + 206902: + - 【人物名称@正常】【物品名】已经卖断货了哦。 + 206903: + - 【人物名称@正常】抱歉先生,根据您的信用评级,本商场无法为您提供服务。 + 206904: + - 【人物名称@正常】抱歉先生,您身上的钱可能没有带够。 + 206905: + - 【人物名称@正常】要买东西你应该去商场找导购员,不应该找我。 + #2070:买红糖 + 207002: + - 【人物名称@正常】【物品名】已经卖断货了哦。 + 207003: + - 【人物名称@正常】抱歉先生,根据您的信用评级,本商场无法为您提供服务。 + 207004: + - 【人物名称@正常】抱歉先生,您身上的钱可能没有带够。 + 207005: + - 【人物名称@正常】要买东西你应该去商场找导购员,不应该找我。 + #2071:买烟 + 207102: + - 【人物名称@正常】【物品名】已经卖断货了哦。 + 207103: + - 【人物名称@正常】抱歉先生,根据您的信用评级,本商场无法为您提供服务。 + 207104: + - 【人物名称@正常】抱歉先生,您身上的钱可能没有带够。 + 207105: + - 【人物名称@正常】要买东西你应该去商场找导购员,不应该找我。 + #2072:送礼 + 207202: + - 【人物名称@正常】谢谢,我很喜欢。 + 207203: + - 【人物名称@正常】抱歉,我从不贸然收别人礼物。 + 207205: + - 【人物名称@正常】很抱歉,我好像不需要这个,你还是送给其他人吧。 + #2073:恭维 + 207302: + - 【人物名称@正常】好了好了别夸了,你再夸我可要上天了。 + 207303: + - 【人物名称@正常】无事献殷勤,非奸即盗,我跟你又不熟,你说这话到底有什么目的。 + 207305: + - 【人物名称@正常】 + #2074:把柄(偷窃) + 207402: + - 【人物名称@正常】真的,大哥,别说出去,东西我已经还回去了。 + 207403: + - 【人物名称@正常】什么偷东西?你亲眼看见了? + 207405: + - 【人物名称@正常】你是不是搞错了什么?我没有偷过东西。 + #2075:把柄(打游戏) + 207502: + - 【人物名称@正常】大哥,别说出去,我真的会给你打掩护。 + 207503: + - 【人物名称@正常】拜托,大哥我跟你又不熟,你管得着吗。 + 207505: + - 【人物名称@正常】你是不是记错人了?我从来不打游戏的。 + #2076:把柄(做兼职) + 207602: + - 【人物名称@正常】你别说出去,我以后保证不会再犯了。 + 207603: + - 【人物名称@正常】你听谁说的,我不承认。 + 207605: + - 【人物名称@正常】你是不是搞错人了?我从来不做兼职的。 + #2077:把柄(泄密) + 207702: + - 【人物名称@正常】好处费我一会就转给你,千万别说出去。 + 207703: + - 【人物名称@正常】话可不能乱说,小心我告你诽谤。 + 207705: + - 【人物名称@正常】你是不是搞错了什么,我没有做过这种事情。 + #2078:把柄(早退) + 207802: + - 【人物名称@正常】我是不会认错的,你想怎样随便你。 + 207803: + - 【人物名称@正常】不管你怎么说,我是不可能承认的。 + 207805: + - 【人物名称@正常】我从来没早退过啊,你记错人了吧。 + #2079:举报 + 207902: + - 【人物名称@正常】你已经举报过了,不用再举报一遍。 + 207903: + - 【人物名称@正常】我没理解你想要举报什么,你最好先和当事人核对清楚再过来举报。 + 207904: + - 【人物名称@正常】我现在对你还不够信任,举报的事情晚点再说吧。 + #2080:澄清 + 208002: + - 【人物名称@正常】你已经澄清过了,这件事我会处理的。 + 208003: + - 【人物名称@正常】你这么解释没有说服力,我建议你先找当事人当面对峙一下,再来找我汇报。 + 208004: + - 【人物名称@正常】你的风评已经差成这样了,还指望我会相信你? + #2081:澄清 + 208102: + - 【人物名称@正常】你刚才不是说过了吗?难道还有间谍,这不可能吧。 + 208103: + - 【人物名称@正常】真的是这样吗?你要不再确认一下吧,这么大的事要讲证据。 + 208104: + - 【人物名称@正常】我不太相信,总不能你说什么就是什么吧。 + + + #---------------------恋综--------------------- + 600000: + - 【人物名称@正常】你跟我说的不是一回事吧。 + #6001 + 600101: + - 【人物名称@正常】今天‘上午/下午/晚上’跟我去‘场所名称’玩吧 + 【人物名称@正常】太好了,我们走吧 + 600102: + - 【人物名称@正常】好吧,我就在这等你,如果改主意了就回来找我 + 600103: + - 【人物名称@正常】终于决定跟我去【1】玩了吗? + #6002 + 600202: + - 【人物名称@正常】你已经告白过了。 + 600203: + - 【人物名称@正常】暂时还不可以告白哦。 + 600204: + - 【人物名称@正常】现在还没到告白时间。 + 600205: + - 【人物名称@正常】你找错人了吧。 + + + #6003 + 600301: + - 【旁白@正常】售货员收了你的爱心券并递给了你‘物品名称’ + 【人物名称@正常】这是你的‘物品名称’ + 600302: + - 【旁白@正常】你已经买过一次了。 + 600304: + - 【旁白@正常】你的爱心券不足,无法兑换这个礼物 。 + 600303: + - 【旁白@正常】暂时还无法兑换此物品。 + + #6004 + 600402: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 600403: + - 【旁白@正常】你花费【条件2】文请了【B】喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 600404: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 600405: + - 【人物名称@正常】。 + #6005 + 600501: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 600502: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 600503: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 600504: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 600505: + - 【人物名称@正常】喝酒还是算了吧。 + #6006 + 600602: + - 【人物名称@正常】刚才已经夸过了哦。 + 600603: + - 【人物名称@正常】现在说这种话不合适吧。 + 600604: + - 【人物名称@正常】谢谢,但是不必。 + + #6007 + 600701: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 600702: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 600703: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 600704: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 600705: + - 【人物名称@正常】喝酒还是算了吧。 + #6008 + 600802: + - 【人物名称@正常】好啊。 + 600803: + - 【人物名称@正常】这不太合适,有点太急了吧。 + 600804: + - 【人物名称@正常】这不太合适,有点太急了吧。 + #6009 + 600902: + - 【人物名称@正常】求签这种事,一次就好,第二次就不准确了哦。 + 600904: + - 【旁白@正常】您的爱心券好像不太够了。 + 600903: + - 【人物名称@正常】暂时还不行,晚点再来吧。 + #6010 + 601001: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 601002: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 601003: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 601004: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 601005: + - 【人物名称@正常】喝酒还是算了吧。 + #6012 + 601201: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 601202: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 601203: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 601204: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 601205: + - 【人物名称@正常】喝酒还是算了吧。 + + #6014 + 601401: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 601402: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 601403: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 601404: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 601405: + - 【人物名称@正常】喝酒还是算了吧。 + #6015 + 601501: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 601502: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 601503: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 601504: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 601505: + - 【人物名称@正常】喝酒还是算了吧。 + #6016 + 601601: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 601602: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 601603: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 601604: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 601605: + - 【人物名称@正常】喝酒还是算了吧。 + #6017 + 601701: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 601702: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 601703: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 601704: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 601705: + - 【人物名称@正常】喝酒还是算了吧。 + #6018 + 601801: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 601802: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 601803: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 601804: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 601805: + - 【人物名称@正常】喝酒还是算了吧。 + #6019 + 601901: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 21 + 601902: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 601903: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 601904: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 601905: + - 【人物名称@正常】喝酒还是算了吧。 + #6020 + 602001: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 602002: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 602003: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 602004: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 602005: + - 【人物名称@正常】喝酒还是算了吧。 + #6021 + 602101: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 602102: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 602103: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 602104: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 602105: + - 【人物名称@正常】喝酒还是算了吧。 + #6022 + 602201: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 23 + 602202: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 602203: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 602204: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 602205: + - 【人物名称@正常】喝酒还是算了吧。 + #6023 + 602301: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 602302: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 602303: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 602304: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 602305: + - 【人物名称@正常】喝酒还是算了吧。 + #6024 + 602401: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 602402: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 602403: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 602404: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 602405: + - 【人物名称@正常】喝酒还是算了吧。 + #6025 + 602501: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 602502: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 602503: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 602504: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 602505: + - 【人物名称@正常】喝酒还是算了吧。 + #6026 + 602601: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 20 + 602602: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 602603: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 602604: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 602605: + - 【人物名称@正常】喝酒还是算了吧。 + #6027 + 602701: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 602702: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 602703: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 602704: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 602705: + - 【人物名称@正常】喝酒还是算了吧。 + #6028 + 602801: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 602802: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 602803: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 602804: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 602805: + - 【人物名称@正常】喝酒还是算了吧。 + #6029 + 602901: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 602902: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 602903: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 602904: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 602905: + - 【人物名称@正常】喝酒还是算了吧。 + #6030 + 603001: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 603002: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 603003: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 603004: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 603005: + - 【人物名称@正常】喝酒还是算了吧。 + #6031 + 603101: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好……好酒!嗝儿! + 【旁白@正常】你花费【条件2】文请【人物名称@正常】喝了一杯,拉近了交情。你与【人物名称@正常】的友好度改变【信任度增减】点,威慑度改变【威慑度增减】点。 + 603102: + - 【旁白@正常】你请了‘人物名称’喝了一杯酒,他对你的态度变好了一点。 + 【人物名称@正常】好酒!嗝儿! + 【旁白@正常】你又请【人物名称@正常】喝了一杯。可惜刚刚喝过了,信任度没有提升。 + 603103: + - 【旁白@正常】你花费【条件2】文请了‘人物名称’喝了一杯酒,看来他不是很买账。 + 【人物名称@正常】酒逢知己千杯少,话不投机半句多…… + 603104: + - 【旁白@正常】你身上带的钱不太够,喝酒要花费【条件2】文。 + 603105: + - 【人物名称@正常】喝酒还是算了吧。 + 603602: + - 【人物名称@正常】已经画完了。 + 603603: + - 【人物名称@正常】你在说什么? + 603605: + - 【人物名称@正常】你在说什么? + + #6037 + 603702: + - 【人物名称@正常】已经画完了。 + 603703: + - 【人物名称@正常】你在说什么? + 603705: + - 【人物名称@正常】你在说什么? + + + + #6038 + 603801: + 603802: + - 【人物名称@正常】鬼屋已经闭馆了哦,你不是刚从鬼屋出来吗。 + 603803: + - 【人物名称@正常】鬼屋暂不开放。 + 603805: + - 【人物名称@正常】鬼屋暂不对外营业。 + + + + #6039 + 603902: + - 【人物名称@正常】你们不是刚从迷宫出来么,还进去干什么。 + 603903: + - 【人物名称@正常】迷宫咱不开放。 + 603905: + - 【人物名称@正常】迷宫暂时不营业。 + + #6053 + 605302: + - 【人物名称@正常】拍卖已经结束了哦。 + 605303: + - 【人物名称@正常】拍卖尚未开始。 + 605305: + - 【人物名称@正常】你在说什么,这里可没有拍卖。 + + + + #6054 + 605402: + - 【人物名称@正常】你不是才涂过么,还涂什么。 + 605403: + - 【人物名称@正常】这里不可以涂鸦,至少现在不行。 + 605405: + - 【人物名称@正常】这里不准涂鸦。 \ No newline at end of file