diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index c3ba8e2..54f2b92 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -8,12 +8,14 @@
+
\ No newline at end of file
diff --git a/src/main/java/com/qiwu/inference/common/InitSysServlet.java b/src/main/java/com/qiwu/inference/common/InitSysServlet.java
index 6d1dc71..e43bffd 100644
--- a/src/main/java/com/qiwu/inference/common/InitSysServlet.java
+++ b/src/main/java/com/qiwu/inference/common/InitSysServlet.java
@@ -2,6 +2,7 @@ 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.PersistenceUtil;
import com.qiwu.inference.common.utils.SpeechUtil;
import com.qiwu.inference.dao.*;
@@ -25,6 +26,8 @@ import java.util.concurrent.ConcurrentHashMap;
public class InitSysServlet implements InitializingBean {
Logger log = LoggerFactory.getLogger(InitSysServlet.class);
+ @Value("${offlineTime}")
+ private String offlineTime;
@Value("${userFilePath}")
private String userFilePath;
@Value("${configFilePath}")
@@ -69,29 +72,6 @@ public class InitSysServlet implements InitializingBean {
log.info("关卡攻略数据缓存完成");
}
-
- //--------------------------加载玩家数据----------------------
- 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);
- }
- }
- log.info("玩家数据缓存完成");
-
//--------------------加载话术-----------------
TimingAcquisition.speechLoading(speechFilePath);
//--------------------加载闲聊话术的excel表----------------
@@ -124,6 +104,18 @@ public class InitSysServlet implements InitializingBean {
TimingAcquisition.personSpeechMap.putAll(personSpeechMap);
log.info("人物见面话术加载完成");
+ //--------------------加载操作提示话术的excel表----------------
+ log.info("加载操作提示话术");
+ Map operateSpeechMap = SpeechUtil.getOperateSpeechModel(speechFilePath);
+ TimingAcquisition.operateSpeechMap.putAll(operateSpeechMap);
+ log.info("操作提示话术加载完成");
+
+ //--------------------加载线索前因话术的excel表----------------
+// log.info("加载线索前因话术");
+// Map> preReasonSpeechMap = SpeechUtil.getPreReasonSpeechModel(speechFilePath);
+// TimingAcquisition.preReasonSpeechMap.putAll(preReasonSpeechMap);
+// log.info("线索前因话术加载完成");
+
//-----------------缓存场所信息------------------
Map locationMap = new ConcurrentHashMap<>();
@@ -180,12 +172,38 @@ public class InitSysServlet implements InitializingBean {
log.info("系统配置信息缓存完成");
//-----------------缓存结局目标配置信息------------------
- Map endGoalMap = new ConcurrentHashMap<>();
- List endGoalList = endGoalMapper.findAll();
- for (EndGoal endGoal : endGoalList) {
- endGoalMap.put(endGoal.getId(), endGoal);
+// 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("开始加载玩家数据");
+ //从yml配置文件中取出存放玩家数据的地址
+ File file = new File(userFilePath);
+ File[] files = file.listFiles();
+ if (files == null) {
+ log.info("路径" + userFilePath+ "下没有文件");
+ return;
}
- TimingAcquisition.endGoalMap.putAll(endGoalMap);
- log.info("结局目标配置信息缓存完成");
+// 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);
+ TimingAcquisition.uidList.add(fileName); //保存所有玩家的uid
+ //该玩家以唯一标识加入全局缓存,用于玩家离线判断
+ String uniqueUid = fileName + "%#%online%#%";
+ CacheUtil.put(uniqueUid, "", Long.parseLong(offlineTime));
+ }
+ }
+ 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..39ee9ac 100644
--- a/src/main/java/com/qiwu/inference/common/TimingAcquisition.java
+++ b/src/main/java/com/qiwu/inference/common/TimingAcquisition.java
@@ -33,6 +33,10 @@ public class TimingAcquisition {
* 玩家信息,Map
*/
public volatile static Map playerMap = new ConcurrentHashMap<>();
+ /**
+ * 所有在线玩家的uid数组。用于是否加载玩家数据的判断
+ */
+ public volatile static List uidList = new ArrayList<>();
/**
* 场所配置信息
@@ -99,6 +103,14 @@ public class TimingAcquisition {
* 人物见面话术,Map<人物名称, List<话术配置>>
*/
public volatile static Map> personSpeechMap = new ConcurrentHashMap<>();
+ /**
+ * 操作提示话术,Map<人物名称, List<话术配置>>
+ */
+ public volatile static Map operateSpeechMap = new ConcurrentHashMap<>();
+ /**
+ * 线索前因话术,Map<人物名称, List<话术配置>>
+ */
+ public volatile static Map> preReasonSpeechMap = new ConcurrentHashMap<>();
/**
* 通过yaml文件加载所有话术到缓存中
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..0478b22 100644
--- a/src/main/java/com/qiwu/inference/common/cache/ExpireThread.java
+++ b/src/main/java/com/qiwu/inference/common/cache/ExpireThread.java
@@ -9,6 +9,7 @@ import com.qiwu.inference.dto.Player;
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;
@@ -20,8 +21,12 @@ import java.util.concurrent.TimeUnit;
@EnableAsync
@Component
public class ExpireThread implements Runnable{
+ //动态词组更新秘钥
+ public static String userFilePath;
@Value("${userFilePath}")
- private String userFilePath;
+ public void setUserFilePath(String userFilePath) {
+ ExpireThread.userFilePath = userFilePath;
+ }
@Override
public void run() {
@@ -49,15 +54,16 @@ public class ExpireThread implements Runnable{
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)) {
+ //更新玩家为离线状态
+ player.setStatus(Constants.OFFLINE);
+ //修改下线时间
+ player.setOfflineTime(DateUtil.getCurrentTime());
+ //--------------持久化该园丁信息---------------
+ PersistenceUtil.saveDataToFile(userFilePath, uid, JSON.toJSONString(player));
+ //-----------------清除该玩家的数据缓存-----------------
+ TimingAcquisition.playerMap.remove(uid);
+ }
}
//清除过期缓存
CacheGlobal.concurrentMap.remove(key);
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/DataTrimUtil.java b/src/main/java/com/qiwu/inference/common/utils/DataTrimUtil.java
index f37ba3a..b360703 100644
--- a/src/main/java/com/qiwu/inference/common/utils/DataTrimUtil.java
+++ b/src/main/java/com/qiwu/inference/common/utils/DataTrimUtil.java
@@ -90,10 +90,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/PersistenceUtil.java b/src/main/java/com/qiwu/inference/common/utils/PersistenceUtil.java
index b8b7902..3e4490e 100644
--- a/src/main/java/com/qiwu/inference/common/utils/PersistenceUtil.java
+++ b/src/main/java/com/qiwu/inference/common/utils/PersistenceUtil.java
@@ -102,6 +102,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 +146,36 @@ public class PersistenceUtil {
}
return speechMap;
}
+
+ /**
+ * 读取玩家json文件的数据
+ * @param path json文件路径
+ * @param uid
+ * @return 字符串
+ */
+ public static String loadPlayerData(String path, String uid) {
+ BufferedReader reader = null;
+ String fileName = uid + ".json";
+ String 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;
+ }
}
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..1600f89 100644
--- a/src/main/java/com/qiwu/inference/common/utils/PlayerUtil.java
+++ b/src/main/java/com/qiwu/inference/common/utils/PlayerUtil.java
@@ -2,15 +2,24 @@ package com.qiwu.inference.common.utils;
import com.qiwu.inference.common.Constants;
import com.qiwu.inference.common.TimingAcquisition;
+import com.qiwu.inference.common.cache.ExpireThread;
import com.qiwu.inference.dto.*;
import com.qiwu.inference.pojo.Location;
+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;
+@Component
public class PlayerUtil {
+ public static String expireTime;
+ @Value("${expireTime}")
+ public void setExpireTime(String expireTime) {
+ PlayerUtil.expireTime = expireTime;
+ }
/**
* 通过角色身份找到对应的人物名称
* @param name
@@ -74,6 +83,52 @@ public class PlayerUtil {
}
/**
+ * 判断是否符合阈值需求
+ * @param demandTask
+ * @param subject
+ * @return
+ */
+ public static boolean checkThreshold(DemandTaskDto demandTask, Person subject){
+ boolean flag = false;
+ //任务无需解锁或者任务已解锁
+ if (demandTask.getClueSwitch() != 1) {
+ 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 demandTask
+ * @param subject
+ * @return
+ */
+ public static boolean checkThresholdNoSwitch(DemandTaskDto demandTask, Person 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;
+ }
+
+ /**
* 获取玩家关卡中人物所在的所有场所
*/
public static List getLocationByUid(String uid) {
@@ -326,6 +381,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 = TimingAcquisition.playerMap.get(uid).getPersonMap().get(currentId);
+ Person subject = TimingAcquisition.playerMap.get(uid).getPersonMap().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 +511,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;
}
}
@@ -428,6 +541,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) {
@@ -498,16 +656,32 @@ public class PlayerUtil {
}
}
}
- 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)) {
+ //线索对应任务解锁
+ List demandTaskObjectList = TimingAcquisition.playerMap.get(uid).getPersonMap().get(objectId).getDemandTasks();
+ //客体身上该任务解锁
+ for (DemandTaskDto demandTask : demandTaskObjectList) {
+ if (demandTask.getDemandTaskId() == Integer.parseInt(postTaskId)) {
+ //需解锁任务
+ if (demandTask.getClueSwitch() == 1) {
+ demandTask.setClueSwitch(2);
+ }
+ }
+ }
}
+ } else {
+ //线索对应他人的任务解锁
List demandTaskObjectList = TimingAcquisition.playerMap.get(uid).getPersonMap().get(objectId).getDemandTasks();
//客体身上该任务解锁
for (DemandTaskDto demandTask : demandTaskObjectList) {
- if (demandTask.getDemandTaskId() == Integer.parseInt(postTaskId)) {
+ if (demandTask.getClueId() == clue.getClueId()) {
//需解锁任务
if (demandTask.getClueSwitch() == 1) {
demandTask.setClueSwitch(2);
@@ -657,15 +831,62 @@ 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> taskMapCopy = new HashMap<>();
+ Map personMapCopy = new HashMap<>();
+ Map name2IdMapCopy = new HashMap<>();
+ Map id2NameMapCopy = new HashMap<>();
+ for (Person person : personCopyList) {
+ taskMapCopy.put(person.getId(), new HashMap<>());
+ personMapCopy.put(person.getId(), person);
+ name2IdMapCopy.put(person.getName(), person.getId());
+ id2NameMapCopy.put(person.getId(), person.getName());
+ }
+ player.setTaskMap(taskMapCopy);
+ player.setPersonMap(personMapCopy);
+ player.setName2IdMap(name2IdMapCopy);
+ player.setId2NameMap(id2NameMapCopy);
+ //给玩家分配场所和对话人物
+ Map> locationPersonMap = new HashMap<>();
+ Map personMap = player.getPersonMap();
+ 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(locationPersonMap);
+ player.setLocationMap(locationMap);
+ player.setCurrency(3000.0);
+ player.setPoint(0);
+ player.setClueMap(new HashMap<>());
+ player.setFinishedTaskNum(0);
+ player.setTipFlag(false);
+ player.setOperateTextNum(1);
+ player.setAskAndNumMap(new HashMap<>());
+ player.setFinished(0);
}
/**
@@ -693,6 +914,7 @@ public class PlayerUtil {
/**
* 生成场所表
+ * @param locationPersonMap
*/
public static Map makeLocationMap(Map> locationPersonMap) {
Map locationInfoMap = new HashMap<>();
@@ -741,6 +963,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
@@ -755,6 +994,8 @@ public class PlayerUtil {
/**
* 查找有前置任务的任务
+ * @param uid
+ * @param personIdList
*/
public static List getDemandTaskHavePre(String uid, List personIdList) {
List postTaskStatusList = new ArrayList<>();
@@ -784,6 +1025,31 @@ public class PlayerUtil {
taskStatusMap.put(demandTask.getDemandTaskId(), taskStatus);
}
}
+ //该任务为自动触发任务
+ if (demandTask.getIsAuto() == 1) {
+// String[] condition1 = demandTask.getCondition1().split("\\|");
+ //任务为71000自动完成
+ 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);
+ }
+ }
+ }
}
if (taskStatusMap.size() != 0) {
postTask.setTaskStatusMap(taskStatusMap);
@@ -795,6 +1061,8 @@ public class PlayerUtil {
/**
* 查找单个人有前置任务的任务
+ * @param uid
+ * @param personId
*/
public static List getDemandTaskHavePre(String uid, Integer personId) {
List postTaskStatusList = new ArrayList<>();
@@ -820,6 +1088,31 @@ public class PlayerUtil {
taskStatusMap.put(demandTask.getDemandTaskId(), taskStatus);
}
}
+ //该任务为自动触发任务
+ if (demandTask.getIsAuto() == 1) {
+// String[] condition1 = demandTask.getCondition1().split("\\|");
+ //任务为71000自动完成
+ 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);
+ }
+ }
+ }
}
if (taskStatusMap.size() != 0) {
postTask.setTaskStatusMap(taskStatusMap);
@@ -830,6 +1123,9 @@ public class PlayerUtil {
/**
* 判断任务是否已经完成,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);
@@ -841,54 +1137,126 @@ public class PlayerUtil {
/**
* 后置任务的提示按优先级查找
+ * @param uid
+ * @param postTaskList
*/
public static PostTaskRecordDto getPostTask(String uid, List postTaskList) {
PostTaskRecordDto postTaskRecord = new PostTaskRecordDto();
List postTaskRecordList = new ArrayList<>();
- //遍历每个人
+ Integer currentId = TimingAcquisition.playerMap.get(uid).getPersonId();
+ Person current = TimingAcquisition.playerMap.get(uid).getPersonMap().get(currentId);
+ //遍历每个任务
for (PostTaskDto postTask : postTaskList) {
Map taskStatusMap = postTask.getTaskStatusMap();
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); //前置任务已完成且是自己发布
+ } else {
+ postTaskRecord.setLevel(2); //前置任务已完成且不是自己发布
+ }
+ return postTaskRecord;
+ }
+ }
+ }
+ }
+ //2.任务自动触发的情况
+ if (!StringUtils.isEmpty(demandTask)) {
+ //任务是自动触发
+ if (demandTask.getIsAuto() == 1) {
+ //判断是否达到阈值
+ boolean flag = checkThresholdNoSwitch(demandTask, current);
+ if (flag) {
+ //任务已解锁或者无需解锁
+ if (demandTask.getClueSwitch() != 1) {
+ 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); //任务为自动触发完成
+ } else {
+ //任务为本人发布
+ boolean selfSign = checkTaskSelf(uid, postTask.getPersonId(), demandTask.getClueId());
+ if (!selfSign) {
+ postTaskRecordCopy.setLevel(4); //任务为自动发布
+ } else {
+ postTaskRecordCopy.setLevel(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); //任务为自动触发完成
+ } else {
+ //任务为本人发布
+ boolean selfSign = checkTaskSelf(uid, postTask.getPersonId(), demandTask.getClueId());
+ if (!selfSign) {
+ postTaskRecordCopy.setLevel(4); //任务为自动发布
+ } else {
+ postTaskRecordCopy.setLevel(5); //任务为本人发布
+ }
+ }
+ postTaskRecordList.add(postTaskRecordCopy);
+ }
}
- return postTaskRecord;
}
}
}
- //前置任务为本人发布
+ //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.setPostTaskId(postTaskId); //后置任务
+ postTaskRecordCopy.setPreTaskId(taskStatus.getTaskId()); //前置任务
postTaskRecordCopy.setStatus(taskStatus.getStatus());
- postTaskRecordCopy.setLevel(3); //任务为本人发布
+ postTaskRecordCopy.setLevel(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;
}
@@ -955,7 +1323,8 @@ public class PlayerUtil {
Integer subjectId = barrierTaskKey.getSubject();
ClueDto clue = getClueById(uid, subjectId, clueId);
if (!StringUtils.isEmpty(clue)) {
- return clue.getClueTemplate() + "这条线索可能对你比较重要。";
+ String text = TimingAcquisition.clueMap.get(clueId).getClueTemplate();
+ return text + "这条线索可能对你比较重要。";
}
}
}
@@ -965,6 +1334,8 @@ public class PlayerUtil {
/**
* 找到白名单内该人的任务中已解锁或无需解锁的任务对应的提示
+ * @param uid
+ * @param person
*/
public static String getTipInChat(String uid, Person person) {
List demandTaskList = person.getDemandTasks();
@@ -977,7 +1348,6 @@ public class PlayerUtil {
Integer trustDegree = person.getTrustDegree();
//威慑度
Integer deterrenceDegree = person.getDeterrenceDegree();
- String text = "";
for (DemandTaskDto demandTask : demandTaskList) {
//判断这个任务是否在白名单内
for (BarrierTaskKeyDto barrierTaskKey : barrierTaskKeyList) {
@@ -990,7 +1360,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 +1382,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;
+ }
+ }
}
}
}
@@ -1014,19 +1416,27 @@ public class PlayerUtil {
List clueList = person.getClues();
for (BarrierTaskKeyDto barrierTaskKey : barrierTaskKeyList) {
List clueIdList = getClueByTaskId(player.getPersonMap().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,13 +1446,17 @@ public class PlayerUtil {
}
}
if (count > 0) {
- return "我们走吧,这人暂时问不出更重要的消息了,去先找别人问问吧。";
+ //获取对应话术
+ return SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 103201);
}
- return "算了吧,估计这个人问不出什么东西来。去问问其他人吧。";
+ return "算了吧,估计这个人问不出什么东西来。我们去问问其他人吧。";
}
/**
* 通过线索id找到挂线索的人物
+ * @param uid
+ * @param clueId
+ * @param subjectId
*/
public static List getPersonIdByClueId(String uid, Integer clueId, Integer subjectId) {
List personIdList = new ArrayList<>();
@@ -1063,6 +1477,8 @@ public class PlayerUtil {
/**
* 找到NPC身上的某个任务对应的所有线索
+ * @param person
+ * @param demandTaskId
*/
public static List getClueByTaskId(Person person, Integer demandTaskId) {
List clueIdList = new ArrayList<>();
@@ -1089,6 +1505,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,6 +1517,8 @@ public class PlayerUtil {
/**
* 扣除玩家的货币
+ * @param uid
+ * @param num
*/
public static void updateMoneyNum(String uid, int num) {
int money = TimingAcquisition.playerMap.get(uid).getCurrency().intValue();
@@ -1110,6 +1531,8 @@ public class PlayerUtil {
/**
* 增加玩家的货币
+ * @param uid
+ * @param num
*/
public static void addMoneyNum(String uid, int num) {
int money = TimingAcquisition.playerMap.get(uid).getCurrency().intValue();
@@ -1137,6 +1560,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 +1578,140 @@ 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 uid
+ * @param subjectId
+ * @param demandTaskId
+ */
+ public static void taskFinished(String uid, Integer subjectId, Integer demandTaskId) {
+ Player player = TimingAcquisition.playerMap.get(uid);
+ //已完成任务
+ Map map = player.getTaskMap().get(subjectId);
+ DemandTaskDto demandTask = getDemandTaskInfo(uid, subjectId, demandTaskId);
+ //3.信任阈值提升
+ if (!StringUtils.isEmpty(demandTask)) {
+ int num = 0;
+ if (!StringUtils.isEmpty(map.get(demandTaskId))) {
+ num = map.get(demandTaskId);
+ }
+ //前置任务完成
+ map.put(demandTaskId, num + 1);
+ //更新威慑度
+ addThreshold(player.getPersonMap().get(subjectId), demandTask);
+ String condition2 = demandTask.getCondition2();
+ if (!StringUtils.isEmpty(condition2)) {
+ int value = Integer.parseInt(condition2);
+ //扣除货币
+ if (value > 0) {
+ updateMoneyNum(uid, value);
+ }
+ }
+ String completionReward = demandTask.getCompletionReward();
+ //发放奖励
+ if (!StringUtils.isEmpty(completionReward)) {
+ int reward = Integer.parseInt(completionReward);
+ addMoneyNum(uid, reward);
+ }
+ }
+ }
+
+ /**
+ * 自动触发的任务自动完成
+ * @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 = TimingAcquisition.playerMap.get(uid).getPersonMap().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(demandTaskDto, subject);
+ 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;
+ }
}
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..d4287f4 100644
--- a/src/main/java/com/qiwu/inference/common/utils/SpeechUtil.java
+++ b/src/main/java/com/qiwu/inference/common/utils/SpeechUtil.java
@@ -2,9 +2,12 @@ package com.qiwu.inference.common.utils;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
+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;
@@ -12,7 +15,13 @@ 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
@@ -279,13 +288,14 @@ public class SpeechUtil {
ExcelReader reader = ExcelUtil.getReader(new File(chatPath));
reader.addHeaderAlias("意图反馈", "methodId");
reader.addHeaderAlias("身份", "identity");
- reader.addHeaderAlias("人物ID", "personId");
+ reader.addHeaderAlias("人物名称", "personName");
reader.addHeaderAlias("性别", "gender");
reader.addHeaderAlias("年龄段", "age");
reader.addHeaderAlias("性格A", "dispositionIds");
reader.addHeaderAlias("行为", "behaviour");
reader.addHeaderAlias("任务状态", "taskStatus");
- reader.addHeaderAlias("关系", "degree");
+ reader.addHeaderAlias("信任值", "trust");
+ reader.addHeaderAlias("威慑度", "deterrence");
reader.addHeaderAlias("文本内容", "answer");
reader.addHeaderAlias("通用标签", "flag");
List chatList = reader.readAll(ChatSpeech.class);
@@ -355,6 +365,7 @@ public class SpeechUtil {
reader.addHeaderAlias("进行中任务完成提醒", "doingFinishedAnswer");
reader.addHeaderAlias("未进行中任务完成提醒", "noDoingFinishedAnswer");
reader.addHeaderAlias("完成对话文本", "answer");
+ reader.addHeaderAlias("任务操作提醒文本", "replyAnswer");
reader.addHeaderAlias("通用标签", "flag");
List taskSpeechList = reader.readAll(TaskSpeech.class);
reader.close();
@@ -423,6 +434,58 @@ public class SpeechUtil {
}
/**
+ * 加载操作提示的话术
+ */
+ public static Map getOperateSpeechModel(String speechFilePath) {
+ String operateSpeechPath = speechFilePath + "operate.xlsx";
+ ExcelReader reader = ExcelUtil.getReader(new File(operateSpeechPath));
+ reader.addHeaderAlias("ID", "id");
+ reader.addHeaderAlias("操作提示文本", "answer");
+ List operateSpeechList = reader.readAll(OperateSpeech.class);
+ reader.close();
+ Map operateSpeechMap = new ConcurrentHashMap<>();
+ for (OperateSpeech operateSpeech : operateSpeechList) {
+ operateSpeechMap.put(operateSpeech.getId(), operateSpeech);
+ }
+ return operateSpeechMap;
+ }
+
+ /**
+ * 加载任务成功的话术
+ */
+ public static Map> getPreReasonSpeechModel(String speechFilePath) {
+ String preReasonSpeechPath = speechFilePath + "pre_reason.xlsx";
+ ExcelReader reader = ExcelUtil.getReader(new File(preReasonSpeechPath));
+ reader.addHeaderAlias("任务ID", "demandTaskId");
+ reader.addHeaderAlias("线索ID", "clueId");
+ reader.addHeaderAlias("任务名称", "taskName");
+ reader.addHeaderAlias("自身身份", "identity");
+ reader.addHeaderAlias("对方身份", "identitySide");
+ reader.addHeaderAlias("性别", "gender");
+ reader.addHeaderAlias("人物名称", "personName");
+ reader.addHeaderAlias("年龄段", "age");
+ reader.addHeaderAlias("性格A", "dispositionIds");
+ reader.addHeaderAlias("关系", "relation");
+ reader.addHeaderAlias("行为", "behaviour");
+ reader.addHeaderAlias("第三方描述", "answer");
+ reader.addHeaderAlias("自身描述", "answerSelf");
+ reader.addHeaderAlias("通用标签", "flag");
+ List preReasonSpeechList = reader.readAll(PreReasonSpeech.class);
+ reader.close();
+ 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
@@ -452,6 +515,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 +554,24 @@ public class SpeechUtil {
continue;
}
}
+ //符合信任值
+ if (!StringUtils.isEmpty(chatSpeech.getTrust())) {
+ String[] trustRange = chatSpeech.getTrust().split("\\|");
+ if(NumberUtil.inNumRange(person.getTrustDegree(),"["+trustRange[0]+","+trustRange[1]+"]")) {
+ count++;
+ } else {
+ continue;
+ }
+ }
+ //符合威慑度
+ if (!StringUtils.isEmpty(chatSpeech.getDeterrence())) {
+ String[] deterrenceRange = chatSpeech.getDeterrence().split("\\|");
+ if(NumberUtil.inNumRange(person.getDeterrenceDegree(),"["+deterrenceRange[0]+","+deterrenceRange[1]+"]")) {
+ count++;
+ } else {
+ continue;
+ }
+ }
countMap.put(i, count);
}
int max = 0;
@@ -514,12 +603,162 @@ public class SpeechUtil {
text = chatList.get(num).getAnswer();
}
} else {
+ List indexList = new ArrayList<>();
+ for (Map.Entry entry : countMap.entrySet()) {
+ if (max == entry.getValue()) {
+ indexList.add(entry.getKey());
+ }
+ }
+ int random = getRandomNum(0, indexList.size());
+ index = indexList.get(random);
//获取对应话术
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())) {
+ //----------------是否解锁任务-------------
+ PlayerUtil.unlockTask(uid, person, clue);
+ Person subject = TimingAcquisition.playerMap.get(uid).getPersonMap().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])) {
+ 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;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ 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);
+ }
+
/**
* 获取线索成功的话术
@@ -533,6 +772,7 @@ public class SpeechUtil {
Map> successClueSpeechMap = TimingAcquisition.successClueSpeechMap;
List clueSpeechList = successClueSpeechMap.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 +830,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 +838,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();
}
@@ -618,43 +860,47 @@ 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", "");
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());
+ Map> successClueSpeechMap = TimingAcquisition.successClueSpeechMap;
+ List clueSpeechList = successClueSpeechMap.get(clue.getClueId());
String gender = person.getGender() == 1 ? "男" : "女";
- for (int i = 1; i < taskSpeechList.size(); i++) {
- TaskSpeech taskSpeech = taskSpeechList.get(i);
+ 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 +908,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,66 +934,157 @@ 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 = (TimingAcquisition.playerMap.get(uid).getPersonMap().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("A")) {
+ text = text.replace("A", TimingAcquisition.getNameByPersonId(uid, clue.getSubject()));
}
- 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("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", "");
+ return text;
+ }
+
+ /**
+ * 获取线索成功的话术
+ * @param uid
+ * @param person
+ * @param clue
+ */
+ public static String getClueWithPreSpeech(String uid, Person person, ClueDto clue) {
+ String text = "";
+ Map countMap = new HashMap<>();
+ Map> successClueSpeechMap = TimingAcquisition.successClueSpeechMap;
+ List clueSpeechList = successClueSpeechMap.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;
+ //符合身份
+ if (!StringUtils.isEmpty(clueSpeech.getIdentity())) {
+ if (person.getIdentityName().equals(clueSpeech.getIdentity())) {
+ count++;
+ } else {
+ continue;
+ }
+ }
+ //符合性别
+ if (!StringUtils.isEmpty(clueSpeech.getGender())) {
+ if (gender.equals(clueSpeech.getGender())) {
+ count++;
+ } else {
+ continue;
+ }
+ }
+ //符合年龄
+ if (!StringUtils.isEmpty(clueSpeech.getAge())) {
+ String[] ageRange = clueSpeech.getAge().split("\\|");
+ if(NumberUtil.inNumRange(person.getAge(),"["+ageRange[0]+","+ageRange[1]+"]")) {
+ count++;
+ } else {
+ continue;
+ }
+ }
+ //符合性格
+ if (!StringUtils.isEmpty(clueSpeech.getDispositionIds())) {
+ String[] dispositionIds = clueSpeech.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) {
+ //获取对应话术
+ if (!person.getId().equals(clue.getSubject())) {
+ text = clueSpeechList.get(0).getAnswer();
+ text = SpeechUtil.addHeader(text, currentName);
+ } else {
+ text = clueSpeechList.get(0).getAnswerSelf();
+ }
+ } else {
+ //获取对应话术
+ if (!person.getId().equals(clue.getSubject())) {
+ text = clueSpeechList.get(index).getAnswer();
+ text = SpeechUtil.addHeader(text, currentName);
+ } else {
+ text = clueSpeechList.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 = (TimingAcquisition.playerMap.get(uid).getPersonMap().get(clue.getSubject()).getGender() == 1) ? "他" : "她";
+ text = text.replace("【第三人称】", call);
}
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", "");
return text;
}
/**
- * 获取前后置任务成功的话术
+ * 获取任务成功的话术
* @param uid
* @param person
* @param demandTask
*/
- public static String getPreSuccessTaskSpeech(String uid, Person person, DemandTaskDto demandTask, int level) {
+ public static String getSuccessTaskSpeech(String uid, Person person, DemandTaskDto demandTask) {
String text = "";
Map countMap = new HashMap<>();
Map> successTaskSpeechMap = TimingAcquisition.successTaskSpeechMap;
List taskSpeechList = successTaskSpeechMap.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;
@@ -801,51 +1138,13 @@ 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();
- }
+ text = taskSpeechList.get(0).getAnswer();
} 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();
- }
+ text = taskSpeechList.get(index).getAnswer();
}
- text = addHeader(text, person.getName());
//话术中配置数据替换
if (text.contains("【A】")) {
text = text.replace("【A】", TimingAcquisition.getNameByPersonId(uid, demandTask.getSubject()));
@@ -857,9 +1156,9 @@ public class SpeechUtil {
String call = (TimingAcquisition.playerMap.get(uid).getPersonMap().get(demandTask.getSubject()).getGender() == 1) ? "他" : "她";
text = text.replace("【第三人称】", call);
}
- if (text.contains("【条件2】")) {
+ if (text.contains("【消费货币】")) {
if (!StringUtils.isEmpty(demandTask.getCondition2())) {
- text = text.replace("【条件2】", demandTask.getCondition2());
+ text = text.replace("【消费货币】", demandTask.getCondition2());
}
}
if (text.contains("【奖励】")) {
@@ -876,8 +1175,300 @@ public class SpeechUtil {
if (text.contains("B")) {
text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject()));
}
- text += addText;
- text = text.replace("\n", "");
+ //补充信任值和威慑度增减的回复
+ String addText = "【旁白@正常】【1】对你的信任达到【2】,对你的畏惧达到【3】。";
+ addText = speechReplaceNum(addText, person.getName(), String.valueOf(person.getTrustDegree() - 50), String.valueOf(person.getDeterrenceDegree() - 50));
+// if (!StringUtils.isEmpty(demandTask.getCompletionReward())) {
+// if (!"0".equals(demandTask.getCompletionReward())) {
+// addText += "你获得" + demandTask.getCompletionReward() + "文酬劳。";
+// }
+// }
+ text += addText;
+ text = text.replace("\n", "");
+ 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<>();
+ Map> successTaskSpeechMap = TimingAcquisition.successTaskSpeechMap;
+ List taskSpeechList = successTaskSpeechMap.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 = (TimingAcquisition.playerMap.get(uid).getPersonMap().get(demandTask.getSubject()).getGender() == 1) ? "他" : "她";
+ text = text.replace("【第三人称】", call);
+ }
+ if (text.contains("【消费货币】")) {
+ if (!StringUtils.isEmpty(demandTask.getCondition2())) {
+ text = text.replace("【消费货币】", 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()));
+ }
+ if (text.contains("B")) {
+ text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject()));
+ }
+ 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 gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号
+ String unique = uid + gateNo; //用户uid和关卡编号组成唯一标识
+ //保存上轮数据
+ CacheUtil.put(unique, reply, Long.parseLong(expireTime));
+ return text;
+ }
+
+ /**
+ * 获取前后置任务成功的话术。level: 1-是进行中任务完成提醒;2-未进行中任务完成提醒;3-进行中任务询问.其中1和2会加上完成对话文本
+ * @param uid
+ * @param person
+ * @param demandTask
+ */
+ public static String getPreSuccessTaskSpeech(String uid, Person person, DemandTaskDto demandTask, int level) {
+ String text = "";
+ Map countMap = new HashMap<>();
+ Map> successTaskSpeechMap = TimingAcquisition.successTaskSpeechMap;
+ List taskSpeechList = successTaskSpeechMap.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();
+ }
+ } 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 == 1) {
+ if (!StringUtils.isEmpty(taskSpeechList.get(index).getDoingFinishedAnswer())) {
+ text = addHeader(text, person.getName());
+ }
+ //补充信任值和威慑度增减的回复
+ addText = "【旁白@正常】【1】对你的信任达到【2】,对你的畏惧达到【3】。";
+ addText = speechReplaceNum(addText, person.getName(), String.valueOf(person.getTrustDegree() - 50), String.valueOf(person.getDeterrenceDegree() - 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(person.getTrustDegree() - 50), String.valueOf(person.getDeterrenceDegree() - 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 (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 = (TimingAcquisition.playerMap.get(uid).getPersonMap().get(demandTask.getSubject()).getGender() == 1) ? "他" : "她";
+ text = text.replace("【第三人称】", call);
+ }
+ if (text.contains("【消费货币】")) {
+ if (!StringUtils.isEmpty(demandTask.getCondition2())) {
+ text = text.replace("【消费货币】", 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()));
+ }
+ if (text.contains("B")) {
+ text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject()));
+ }
+ text = text.replace("\n", "");
return text;
}
@@ -892,6 +1483,57 @@ public class SpeechUtil {
String text = "";
Map> tipSpeechMap = TimingAcquisition.tipSpeechMap;
List tipSpeechList = tipSpeechMap.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("【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));
+ }
+ }
+ text = text.replace("\n", "");
+ String[] result = text.split("\\|");
+ Integer i = getRandomNum(0, result.length);
+ text = result[i];
+ return text;
+ }
+
+ /**
+ * 获取自身任务线索提示的话术,用于二次回复
+ * @param uid
+ * @param demandTask
+ * @param personId
+ * @param source
+ */
+ public static String getTipReplySpeech(String uid, DemandTaskDto demandTask, Integer personId, int source, ReplyDto reply) {
+ String text = "";
+ Map> tipSpeechMap = TimingAcquisition.tipSpeechMap;
+ List tipSpeechList = tipSpeechMap.get(demandTask.getDemandTaskId());
+ if (StringUtils.isEmpty(tipSpeechList)) {
+ return text;
+ }
//当前能做的任务线索
if (source == 1) {
//获取对应话术
@@ -920,6 +1562,18 @@ public class SpeechUtil {
}
}
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 gateNo = TimingAcquisition.playerMap.get(uid).getGateNo(); //关卡编号
+ String unique = uid + gateNo; //用户uid和关卡编号组成唯一标识
+ //保存上轮数据
+ CacheUtil.put(unique, reply, Long.parseLong(expireTime));
return text;
}
@@ -933,6 +1587,9 @@ public class SpeechUtil {
String text = "";
Map> tipSpeechMap = TimingAcquisition.tipSpeechMap;
List tipSpeechList = tipSpeechMap.get(barrierTaskKey.getDemandTaskId());
+ if (StringUtils.isEmpty(tipSpeechList)) {
+ return text;
+ }
//他人能解锁任务的线索
//获取对应话术
text = tipSpeechList.get(0).getOtherClue();
@@ -946,6 +1603,9 @@ public class SpeechUtil {
}
}
text = text.replace("\n", "");
+ String[] result = text.split("\\|");
+ Integer i = getRandomNum(0, result.length);
+ text = result[i];
return text;
}
@@ -964,6 +1624,344 @@ public class SpeechUtil {
} else {
text = "【人物名称@正常】" + TimingAcquisition.personSpeechMap.get(name).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 = TimingAcquisition.playerMap.get(uid).getPersonMap().get(personId).getName();
+ //判断该人物是否是第一次见面
+ boolean isFirstMeet = PlayerUtil.isFirstMeet(uid, locationId, personId);
+ if (isFirstMeet) {
+ text = "【旁白@正常】" + TimingAcquisition.personSpeechMap.get(name).get(0).getDescription();
+// String personText = "【人物名称@正常】" + TimingAcquisition.personSpeechMap.get(name).get(0).getFirstAnswer();
+// text = asideText + 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();
+ Map operateSpeechMap = TimingAcquisition.operateSpeechMap;
+ 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 = (TimingAcquisition.playerMap.get(uid).getPersonMap().get(demandTask.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()));
+ }
+ if (text.contains("B")) {
+ text = text.replace("B", TimingAcquisition.getNameByPersonId(uid, demandTask.getObject()));
+ }
+ if (text.contains("【信任值】")) {
+ text = text.replace("【信任值】", String.valueOf(person.getTrustDegree() - 50));
+ }
+ if (text.contains("【威慑度】")) {
+ text = text.replace("【威慑度】", String.valueOf(person.getDeterrenceDegree() - 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 partnerName = TimingAcquisition.systemConfigMap.get("partnerName").getValue();
+ String 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);
+ //开场白
+// 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;
+ }
+
+ /**
+ * 获取线索成功的话术
+ * @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 = TimingAcquisition.playerMap.get(uid).getPersonMap().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 = (TimingAcquisition.playerMap.get(uid).getPersonMap().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/controller/CommonController.java b/src/main/java/com/qiwu/inference/controller/CommonController.java
index 1cca389..bffe091 100644
--- a/src/main/java/com/qiwu/inference/controller/CommonController.java
+++ b/src/main/java/com/qiwu/inference/controller/CommonController.java
@@ -3,8 +3,11 @@ 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.RequestConversionUtil;
+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.ResultResponse;
@@ -59,10 +62,18 @@ public class CommonController {
CommonResult result = null;
String uid = commonRequest.getUid();
boolean login = false;
- //玩家第一次登录
- if (StringUtils.isEmpty(TimingAcquisition.playerMap.get(uid))) {
- loginService.login(uid);
- login = true;
+ //玩家已经存在
+ if (TimingAcquisition.uidList.contains(uid)) {
+ //玩家已经下线,重新加载
+ if (StringUtils.isEmpty(TimingAcquisition.playerMap.get(uid))) {
+ loginService.loadPlayerData(uid);
+ }
+ } else {
+ //玩家第一次登录
+ if (StringUtils.isEmpty(TimingAcquisition.playerMap.get(uid))) {
+ loginService.login(uid);
+ login = true;
+ }
}
//请求参数转换
OperationRequest operationReq = RequestConversionUtil.request2Operation(commonRequest);
@@ -86,7 +97,7 @@ public class CommonController {
if ("闲聊".equals(operateName)) {
int chatTimes = TimingAcquisition.playerMap.get(uid).getChatTimes();
int times = Integer.parseInt(TimingAcquisition.systemConfigMap.get("chatTimes").getValue());
- if (chatTimes > times) {
+ if (chatTimes >= times - 1) {
TimingAcquisition.playerMap.get(uid).setChatTimes(0);
} else {
TimingAcquisition.playerMap.get(uid).setChatTimes(TimingAcquisition.playerMap.get(uid).getChatTimes() + 1);
@@ -94,6 +105,15 @@ public class CommonController {
} else {
TimingAcquisition.playerMap.get(uid).setChatTimes(0);
}
+ //判断上一轮玩家任务数据是否清空
+ if (!"二次回复".equals(operateName)) {
+ String unique = uid + TimingAcquisition.playerMap.get(uid).getGateNo();
+ ReplyDto reply = (ReplyDto) CacheUtil.get(unique);
+ if (!StringUtils.isEmpty(reply)) {
+ //清除任务数据
+ CacheGlobal.concurrentMap.remove(unique);
+ }
+ }
switch (operateName) {
case "开始游戏":
result = loginService.startGame(operationReq);
@@ -107,6 +127,9 @@ public class CommonController {
case "查看操作":
result = checkService.check(operationReq);
break;
+ case "二次回复":
+ result = checkService.secondAnswer(operationReq);
+ break;
case "关卡操作":
result = barrierService.operate(operationReq);
break;
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/DemandTaskDto.java b/src/main/java/com/qiwu/inference/dto/DemandTaskDto.java
index 2bd785a..0cd36b8 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;
/**
* 主体
@@ -102,7 +102,7 @@ public class DemandTaskDto implements Serializable {
/**
* 完成反馈
*/
- private String completionFeedback;
+// private String completionFeedback;
/**
* 有效次数
*/
@@ -124,10 +124,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/Player.java b/src/main/java/com/qiwu/inference/dto/Player.java
index 211e196..37de6f2 100755
--- a/src/main/java/com/qiwu/inference/dto/Player.java
+++ b/src/main/java/com/qiwu/inference/dto/Player.java
@@ -68,6 +68,10 @@ public class Player {
* 人物的姓名和编号转换 map
*/
private Map name2IdMap = new HashMap<>();
+ /**
+ * 人物的编号和姓名转换 map
+ */
+ private Map id2NameMap = new HashMap<>();
/**
* 当前关卡的货币
@@ -127,6 +131,21 @@ public class Player {
*/
private int chatTimes = 0;
+ /**
+ * 记录玩家操作提示的序号
+ */
+ private int operateTextNum = 1;
+
+ /**
+ * 记录玩家询问操作的每个操作对应线索的序号
+ */
+ private Map askAndNumMap = new HashMap<>();
+
+ /**
+ * 声望值
+ */
+ private int reputation = 0;
+
// public Player(){
// //初始化推理游戏人物
// List keys = new ArrayList<>(TimingAcquisition.gateInfoMap.keySet());
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..2d6bf42
--- /dev/null
+++ b/src/main/java/com/qiwu/inference/dto/ReplyDto.java
@@ -0,0 +1,27 @@
+package com.qiwu.inference.dto;
+
+import lombok.Data;
+
+@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;
+}
diff --git a/src/main/java/com/qiwu/inference/pojo/ChatSpeech.java b/src/main/java/com/qiwu/inference/pojo/ChatSpeech.java
index bd4ed20..dec9dcb 100644
--- a/src/main/java/com/qiwu/inference/pojo/ChatSpeech.java
+++ b/src/main/java/com/qiwu/inference/pojo/ChatSpeech.java
@@ -15,8 +15,8 @@ public class ChatSpeech implements Serializable {
@ApiModelProperty("身份")
private String identity;
- @ApiModelProperty("人物ID")
- private Integer personId;
+ @ApiModelProperty("人物名称")
+ private String personName;
@ApiModelProperty("性别")
private String gender;
@@ -33,8 +33,11 @@ public class ChatSpeech implements Serializable {
@ApiModelProperty("任务状态")
private String taskStatus;
- @ApiModelProperty("关系")
- private String degree;
+ @ApiModelProperty("信任值")
+ private String trust;
+
+ @ApiModelProperty("威慑度")
+ private String deterrence;
@ApiModelProperty("文本内容")
private String answer;
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..f90ebf1
--- /dev/null
+++ b/src/main/java/com/qiwu/inference/pojo/OperateSpeech.java
@@ -0,0 +1,17 @@
+package com.qiwu.inference.pojo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class OperateSpeech implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("ID")
+ private Integer id;
+
+ @ApiModelProperty("操作提示文本")
+ 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..d6e1a45
--- /dev/null
+++ b/src/main/java/com/qiwu/inference/pojo/PreReasonSpeech.java
@@ -0,0 +1,53 @@
+package com.qiwu.inference.pojo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class PreReasonSpeech implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("线索ID")
+ private Integer demandTaskId;
+
+ @ApiModelProperty("任务ID")
+ private Integer clueId;
+
+ @ApiModelProperty("任务名称")
+ private String taskName;
+
+ @ApiModelProperty("自身身份")
+ private Integer identity;
+
+ @ApiModelProperty("对方身份")
+ private Integer identitySide;
+
+ @ApiModelProperty("性别")
+ private String gender;
+
+ @ApiModelProperty("人物名称")
+ private Integer personName;
+
+ @ApiModelProperty("年龄段")
+ private String age;
+
+ @ApiModelProperty("性格A")
+ private Integer dispositionId;
+
+ @ApiModelProperty("关系")
+ private Integer relation;
+
+ @ApiModelProperty("行为")
+ private Integer behaviour;
+
+ @ApiModelProperty("第三方描述")
+ private String answer;
+
+ @ApiModelProperty("自身描述")
+ private String answerSelf;
+
+ @ApiModelProperty("通用标签")
+ private Integer flag;
+}
diff --git a/src/main/java/com/qiwu/inference/pojo/TaskSpeech.java b/src/main/java/com/qiwu/inference/pojo/TaskSpeech.java
index 58dd45a..67585f5 100644
--- a/src/main/java/com/qiwu/inference/pojo/TaskSpeech.java
+++ b/src/main/java/com/qiwu/inference/pojo/TaskSpeech.java
@@ -48,6 +48,9 @@ public class TaskSpeech implements Serializable {
@ApiModelProperty("完成对话文本")
private String answer;
+ @ApiModelProperty("任务操作提醒文本")
+ private String replyAnswer;
+
@ApiModelProperty("通用标签")
private Integer flag;
}
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..db18465 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
@@ -8,10 +8,7 @@ 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.dto.*;
import com.qiwu.inference.dto.request.OperationRequest;
import com.qiwu.inference.dto.response.ResultResponse;
import com.qiwu.inference.dto.response.ResultVarsResponse;
@@ -47,17 +44,18 @@ 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(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);
//场所移动
if ("4001".equals(methodId)) {
//离开,或者没有说明去哪和找谁
@@ -66,7 +64,7 @@ public class BarrierServiceImpl implements BarrierService {
//获取对应话术
String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400105);
text = SpeechUtil.speechReplaceNum(text, locationText);
- resultResponse.set反馈ID(400105);
+ resultResponse.set反馈ID(400109);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
return CommonResult.success(resultVarsResponse);
@@ -75,6 +73,161 @@ public class BarrierServiceImpl implements BarrierService {
if (!StringUtils.isEmpty(subjectId)) {
//获取人物所在场所
locationId = player.getPersonMap().get(subjectId).getLocation();
+ String subjectName = PlayerUtil.getNameByPersonId(uid, subjectId);
+ //获取对应话术
+ String text = SpeechUtil.getPersonFirstSpeech(uid, locationId, subjectId); //第一次见面时的话术
+// if (!StringUtils.isEmpty(text) && !"".equals(text)) {
+// text = SpeechUtil.replaceHeader(text, subjectName);
+// }
+ //更新场所和人物
+ player.setLocation(locationId);
+ player.setPersonId(subjectId);
+ //查找这个人物所有的后置任务和自动触发的任务
+ 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);
+ //更新该NPC见面次数
+ PlayerUtil.updateMeetTimes(uid, locationId, subjectId);
+ //任务自动完成
+ Map> taskMap = player.getTaskMap();
+ Map map = taskMap.get(subjectId);
+ map.put(postTaskRecord.getPostTaskId(), 1);
+ DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, postTaskRecord.getPostTaskId());
+ if (!StringUtils.isEmpty(demandTask)) {
+ PlayerUtil.addThreshold(player.getPersonMap().get(subjectId), demandTask);
+ 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) {
+ Integer preTaskId = postTaskRecord.getPreTaskId(); //前置
+ Integer postTaskId = postTaskRecord.getPostTaskId();; //后置
+ DemandTaskDto demandTaskPost = PlayerUtil.getDemandTaskInfo(uid, subjectId, postTaskId);
+ //找到后置任务
+ if (!StringUtils.isEmpty(demandTaskPost)) {
+ ClueDto clue = PlayerUtil.getClueById(uid, subjectId, demandTaskPost.getClueId());
+ if (!StringUtils.isEmpty(clue)) {
+ String clueText = SpeechUtil.getSuccessClueSpeech(uid, player.getPersonMap().get(subjectId), clue);
+ text += clueText;
+ }
+ //后置任务自动完成
+ PlayerUtil.taskFinished(uid, subjectId, postTaskId);
+ String postText = SpeechUtil.getSuccessTaskSpeech(uid, player.getPersonMap().get(subjectId), demandTaskPost);
+ //有配置前置任务
+ if (preTaskId != 0) {
+ //后置任务的客体
+ Integer objectId = demandTaskPost.getObject();
+ DemandTaskDto demandTaskPre = PlayerUtil.getDemandTaskInfo(uid, objectId, preTaskId);
+ if (!StringUtils.isEmpty(demandTaskPre)) {
+ //前置任务自动完成
+ PlayerUtil.taskFinished(uid, objectId, preTaskId);
+ String preText = SpeechUtil.getSuccessTaskSpeech(uid, player.getPersonMap().get(objectId), demandTaskPre);
+ text += preText;
+ }
+ }
+ text += postText;
+ }
+ //----------------记录见过的人--------------
+ PlayerUtil.recordClue(uid, subjectId);
+ //更新该NPC见面次数
+ PlayerUtil.updateMeetTimes(uid, locationId, subjectId);
+ resultResponse.set反馈ID(400107);
+ resultResponse.set反馈文本(text);
+ resultVarsResponse.setVars(resultResponse);
+ return CommonResult.success(resultVarsResponse);
+ }
+ //任务为自动触发仅提供线索
+ if (postTaskRecord.getLevel() == 4) {
+ Integer postTaskId = postTaskRecord.getPostTaskId();; //后置
+ //找到后置任务
+ DemandTaskDto demandTaskPost = PlayerUtil.getDemandTaskInfo(uid, subjectId, postTaskId);
+ if (!StringUtils.isEmpty(demandTaskPost)) {
+ //后置任务解锁
+ if (demandTaskPost.getClueSwitch() == 1) {
+ demandTaskPost.setClueSwitch(2);
+ }
+ ClueDto clue = PlayerUtil.getClueById(uid, subjectId, demandTaskPost.getClueId());
+ if (!StringUtils.isEmpty(clue)) {
+ //----------------记录线索--------------
+ PlayerUtil.recordClue(uid, player.getPersonId(), subjectId, clue.getType(), clue);
+ //----------------是否解锁任务-------------
+// PlayerUtil.unlockTask(uid, player.getPersonMap().get(subjectId), clue);
+ //前置任务解锁
+ if (postTaskRecord.getPreTaskId() != 0) {
+ DemandTaskDto demandTaskPre = PlayerUtil.getDemandTaskInfo(uid, demandTaskPost.getObject(), postTaskRecord.getPreTaskId());
+ if (!StringUtils.isEmpty(demandTaskPre)) {
+ demandTaskPre.setClueSwitch(2);
+ }
+ }
+ String postText = SpeechUtil.getSuccessClueSpeech(uid, player.getPersonMap().get(subjectId), clue);
+ text += postText;
+ //记录本轮的任务数据,用于下轮的二次回复
+ String unique = uid + player.getGateNo();
+ ReplyDto reply = new ReplyDto();
+ reply.setSubjectId(subjectId);
+ reply.setDemandTaskId(postTaskRecord.getPostTaskId());
+ reply.setType(2); //直接操作提醒
+ CacheUtil.put(unique, reply, Long.parseLong(expireTime));
+ }
+ }
+ //----------------记录见过的人--------------
+ PlayerUtil.recordClue(uid, subjectId);
+ //更新该NPC见面次数
+ PlayerUtil.updateMeetTimes(uid, locationId, subjectId);
+ resultResponse.set反馈ID(400108);
+ resultResponse.set反馈文本(text);
+ resultVarsResponse.setVars(resultResponse);
+ return CommonResult.success(resultVarsResponse);
+ }
+ //任务是本人发布的
+ if (postTaskRecord.getLevel() == 5) {
+ subjectId = postTaskRecord.getPersonId();
+ //获取后置任务对应的信息
+ DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, postTaskRecord.getPostTaskId());
+ if (!StringUtils.isEmpty(demandTask)) {
+ text += SpeechUtil.getPreSuccessTaskSpeech(uid, player.getPersonMap().get(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); //执行任务
+ CacheUtil.put(unique, reply, Long.parseLong(expireTime));
+ }
+ }
+ //----------------记录见过的人--------------
+ PlayerUtil.recordClue(uid, subjectId);
+ //更新该NPC见面次数
+ PlayerUtil.updateMeetTimes(uid, locationId, subjectId);
+ resultResponse.set反馈ID(400107);
+ resultResponse.set反馈文本(text);
+ resultVarsResponse.setVars(resultResponse);
+ return CommonResult.success(resultVarsResponse);
+ }
+ }
+ }
} else {
//玩家提供的场所不存在
if (Constants.NON_STR.equals(locationId)) {
@@ -101,29 +254,35 @@ public class BarrierServiceImpl implements BarrierService {
PostTaskRecordDto postTaskRecord = PlayerUtil.getPostTask(uid, postTaskList);
//存在优先级高的任务
if (!StringUtils.isEmpty(postTaskRecord)) {
+ subjectId = postTaskRecord.getPersonId();
+ String subjectName = PlayerUtil.getNameByPersonId(uid, subjectId);
+ //获取对应话术
+ String text = SpeechUtil.getPersonFirstSpeech(uid, locationId, subjectId); //第一次见面时的话术
+// if (!StringUtils.isEmpty(text)) {
+// text = SpeechUtil.replaceHeader(text, subjectName);
+// }
+ //更新场所和人物
+ player.setLocation(locationId);
+ player.setPersonId(subjectId);
//前置任务已完成
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);
+ 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);
+ text += SpeechUtil.getPreSuccessTaskSpeech(uid, player.getPersonMap().get(subjectId), demandTask, 2);
resultResponse.set反馈ID(400106);
}
resultResponse.set反馈文本(text);
@@ -131,15 +290,102 @@ public class BarrierServiceImpl implements BarrierService {
return CommonResult.success(resultVarsResponse);
}
}
- //任务是本人发布的
+ //任务为自动触发且自动完成
if (postTaskRecord.getLevel() == 3) {
- subjectId = postTaskRecord.getPersonId();
- player.setLocation(locationId);
- player.setPersonId(subjectId);
+ Integer preTaskId = postTaskRecord.getPreTaskId(); //前置
+ Integer postTaskId = postTaskRecord.getPostTaskId();; //后置
+ DemandTaskDto demandTaskPost = PlayerUtil.getDemandTaskInfo(uid, subjectId, postTaskId);
+ //找到后置任务
+ if (!StringUtils.isEmpty(demandTaskPost)) {
+ ClueDto clue = PlayerUtil.getClueById(uid, subjectId, demandTaskPost.getClueId());
+ if (!StringUtils.isEmpty(clue)) {
+ String clueText = SpeechUtil.getSuccessClueSpeech(uid, player.getPersonMap().get(subjectId), clue);
+ text += clueText;
+ }
+ //后置任务自动完成
+ PlayerUtil.taskFinished(uid, subjectId, postTaskId);
+ String postText = SpeechUtil.getSuccessTaskSpeech(uid, player.getPersonMap().get(subjectId), demandTaskPost);
+ //有配置前置任务
+ if (preTaskId != 0) {
+ //后置任务的客体
+ Integer objectId = demandTaskPost.getObject();
+ DemandTaskDto demandTaskPre = PlayerUtil.getDemandTaskInfo(uid, objectId, preTaskId);
+ if (!StringUtils.isEmpty(demandTaskPre)) {
+ //前置任务自动完成
+ PlayerUtil.taskFinished(uid, objectId, preTaskId);
+ String preText = SpeechUtil.getSuccessTaskSpeech(uid, player.getPersonMap().get(objectId), demandTaskPre);
+ text += preText;
+ }
+ }
+ text += postText;
+ }
+ //----------------记录见过的人--------------
+ PlayerUtil.recordClue(uid, subjectId);
+ //更新该NPC见面次数
+ PlayerUtil.updateMeetTimes(uid, locationId, subjectId);
+ resultResponse.set反馈ID(400107);
+ resultResponse.set反馈文本(text);
+ resultVarsResponse.setVars(resultResponse);
+ return CommonResult.success(resultVarsResponse);
+ }
+ //任务为自动触发仅提供线索
+ if (postTaskRecord.getLevel() == 4) {
+ Integer postTaskId = postTaskRecord.getPostTaskId();; //后置
+ //找到后置任务
+ DemandTaskDto demandTaskPost = PlayerUtil.getDemandTaskInfo(uid, subjectId, postTaskId);
+ if (!StringUtils.isEmpty(demandTaskPost)) {
+ //后置任务解锁
+ if (demandTaskPost.getClueSwitch() == 1) {
+ demandTaskPost.setClueSwitch(2);
+ }
+ ClueDto clue = PlayerUtil.getClueById(uid, subjectId, demandTaskPost.getClueId());
+ if (!StringUtils.isEmpty(clue)) {
+ //----------------记录线索--------------
+ PlayerUtil.recordClue(uid, player.getPersonId(), subjectId, clue.getType(), clue);
+ //----------------是否解锁任务-------------
+// PlayerUtil.unlockTask(uid, player.getPersonMap().get(subjectId), clue);
+ //前置任务解锁
+ if (postTaskRecord.getPreTaskId() != 0) {
+ DemandTaskDto demandTaskPre = PlayerUtil.getDemandTaskInfo(uid, demandTaskPost.getObject(), postTaskRecord.getPreTaskId());
+ if (!StringUtils.isEmpty(demandTaskPre)) {
+ demandTaskPre.setClueSwitch(2);
+ }
+ }
+ String postText = SpeechUtil.getSuccessClueSpeech(uid, player.getPersonMap().get(subjectId), clue);
+ text += postText;
+ //记录本轮的任务数据,用于下轮的二次回复
+ String unique = uid + player.getGateNo();
+ ReplyDto reply = new ReplyDto();
+ reply.setSubjectId(subjectId);
+ reply.setDemandTaskId(postTaskRecord.getPostTaskId());
+ reply.setType(2); //直接操作提醒
+ CacheUtil.put(unique, reply, Long.parseLong(expireTime));
+ }
+ }
+ //----------------记录见过的人--------------
+ PlayerUtil.recordClue(uid, subjectId);
+ //更新该NPC见面次数
+ PlayerUtil.updateMeetTimes(uid, locationId, subjectId);
+ resultResponse.set反馈ID(400108);
+ resultResponse.set反馈文本(text);
+ resultVarsResponse.setVars(resultResponse);
+ return CommonResult.success(resultVarsResponse);
+ }
+ //任务是本人发布的
+ if (postTaskRecord.getLevel() == 5) {
DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, postTaskRecord.getPostTaskId());
- String text = "";
if (!StringUtils.isEmpty(demandTask)) {
- text = SpeechUtil.getPreSuccessTaskSpeech(uid, player.getPersonMap().get(subjectId), demandTask, 3);
+ text += SpeechUtil.getPreSuccessTaskSpeech(uid, player.getPersonMap().get(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); //执行任务
+ CacheUtil.put(unique, reply, Long.parseLong(expireTime));
+ }
}
//----------------记录见过的人--------------
PlayerUtil.recordClue(uid, subjectId);
@@ -152,7 +398,6 @@ public class BarrierServiceImpl implements BarrierService {
}
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())) {
@@ -167,10 +412,11 @@ public class BarrierServiceImpl implements BarrierService {
player.setPersonId(subjectId);
//----------------记录见过的人--------------
PlayerUtil.recordClue(uid, subjectId);
+ String subjectName = PlayerUtil.getNameByPersonId(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) ? "他" : "她";
//获取对应话术
@@ -181,8 +427,17 @@ public class BarrierServiceImpl implements BarrierService {
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))) {
//获取对应话术
@@ -202,6 +457,8 @@ public class BarrierServiceImpl implements BarrierService {
resultVarsResponse.setVars(resultResponse);
return CommonResult.success(resultVarsResponse);
}
+ //获取人物所在场所
+ locationId = player.getPersonMap().get(subjectId).getLocation();
//查找所有这个人物的后置任务情况
List postTaskList = PlayerUtil.getDemandTaskHavePre(uid, subjectId);
if (postTaskList.size() != 0) {
@@ -209,29 +466,36 @@ public class BarrierServiceImpl implements BarrierService {
PostTaskRecordDto postTaskRecord = PlayerUtil.getPostTask(uid, postTaskList);
//存在优先级高的任务
if (!StringUtils.isEmpty(postTaskRecord)) {
+ subjectId = postTaskRecord.getPersonId();
+ //获取对应话术
+ String text = SpeechUtil.getPersonFirstSpeech(uid, locationId, subjectId); //第一次见面时的话术
+// if (!StringUtils.isEmpty(text)) {
+// text = SpeechUtil.replaceHeader(text, subjectName);
+// }
+ //更新场所和人物
+ player.setLocation(locationId);
+ player.setPersonId(subjectId);
//前置任务已完成
if (postTaskRecord.getLevel() == 1 || postTaskRecord.getLevel() == 2) {
- subjectId = postTaskRecord.getPersonId();
//----------------记录见过的人--------------
PlayerUtil.recordClue(uid, subjectId);
+ //更新该NPC见面次数
+ PlayerUtil.updateMeetTimes(uid, locationId, 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);
+ 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);
+ text += SpeechUtil.getPreSuccessTaskSpeech(uid, player.getPersonMap().get(subjectId), demandTask, 2);
resultResponse.set反馈ID(400106);
}
resultResponse.set反馈文本(text);
@@ -239,18 +503,108 @@ public class BarrierServiceImpl implements BarrierService {
return CommonResult.success(resultVarsResponse);
}
}
- //任务是本人发布的
+ //任务为自动触发且自动完成
if (postTaskRecord.getLevel() == 3) {
+ Integer preTaskId = postTaskRecord.getPreTaskId(); //前置
+ Integer postTaskId = postTaskRecord.getPostTaskId();; //后置
+ DemandTaskDto demandTaskPost = PlayerUtil.getDemandTaskInfo(uid, subjectId, postTaskId);
+ //找到后置任务
+ if (!StringUtils.isEmpty(demandTaskPost)) {
+ ClueDto clue = PlayerUtil.getClueById(uid, subjectId, demandTaskPost.getClueId());
+ if (!StringUtils.isEmpty(clue)) {
+ String clueText = SpeechUtil.getSuccessClueSpeech(uid, player.getPersonMap().get(subjectId), clue);
+ text += clueText;
+ }
+ //前置任务自动完成
+ PlayerUtil.taskFinished(uid, subjectId, postTaskId);
+ String postText = SpeechUtil.getSuccessTaskSpeech(uid, player.getPersonMap().get(subjectId), demandTaskPost);
+ //有配置前置任务
+ if (preTaskId != 0) {
+ //后置任务的客体
+ Integer objectId = demandTaskPost.getObject();
+ DemandTaskDto demandTaskPre = PlayerUtil.getDemandTaskInfo(uid, objectId, preTaskId);
+ if (!StringUtils.isEmpty(demandTaskPre)) {
+ //前置任务自动完成
+ PlayerUtil.taskFinished(uid, objectId, preTaskId);
+ String preText = SpeechUtil.getSuccessTaskSpeech(uid, player.getPersonMap().get(objectId), demandTaskPre);
+ text += preText;
+ }
+ }
+ text += postText;
+ }
+ //----------------记录见过的人--------------
+ PlayerUtil.recordClue(uid, subjectId);
+ //更新该NPC见面次数
+ PlayerUtil.updateMeetTimes(uid, locationId, subjectId);
+ resultResponse.set反馈ID(400107);
+ resultResponse.set反馈文本(text);
+ resultVarsResponse.setVars(resultResponse);
+ return CommonResult.success(resultVarsResponse);
+ }
+ //任务为自动触发仅提供线索
+ if (postTaskRecord.getLevel() == 4) {
+ Integer postTaskId = postTaskRecord.getPostTaskId();; //后置
+ //找到后置任务
+ DemandTaskDto demandTaskPost = PlayerUtil.getDemandTaskInfo(uid, subjectId, postTaskId);
+ if (!StringUtils.isEmpty(demandTaskPost)) {
+ //后置任务解锁
+ if (demandTaskPost.getClueSwitch() == 1) {
+ demandTaskPost.setClueSwitch(2);
+ }
+ ClueDto clue = PlayerUtil.getClueById(uid, subjectId, demandTaskPost.getClueId());
+ if (!StringUtils.isEmpty(clue)) {
+ //----------------记录线索--------------
+ PlayerUtil.recordClue(uid, player.getPersonId(), subjectId, clue.getType(), clue);
+ //----------------是否解锁任务-------------
+// PlayerUtil.unlockTask(uid, player.getPersonMap().get(subjectId), clue);
+ //前置任务解锁
+ if (postTaskRecord.getPreTaskId() != 0) {
+ DemandTaskDto demandTaskPre = PlayerUtil.getDemandTaskInfo(uid, demandTaskPost.getObject(), postTaskRecord.getPreTaskId());
+ if (!StringUtils.isEmpty(demandTaskPre)) {
+ demandTaskPre.setClueSwitch(2);
+ }
+ }
+ String postText = SpeechUtil.getSuccessClueSpeech(uid, player.getPersonMap().get(subjectId), clue);
+ text += postText;
+ //记录本轮的任务数据,用于下轮的二次回复
+ String unique = uid + player.getGateNo();
+ ReplyDto reply = new ReplyDto();
+ reply.setSubjectId(subjectId);
+ reply.setDemandTaskId(postTaskRecord.getPostTaskId());
+ reply.setType(2); //直接操作提醒
+ CacheUtil.put(unique, reply, Long.parseLong(expireTime));
+ }
+ }
+ //----------------记录见过的人--------------
+ PlayerUtil.recordClue(uid, subjectId);
+ //更新该NPC见面次数
+ PlayerUtil.updateMeetTimes(uid, locationId, subjectId);
+ resultResponse.set反馈ID(400108);
+ resultResponse.set反馈文本(text);
+ resultVarsResponse.setVars(resultResponse);
+ return CommonResult.success(resultVarsResponse);
+ }
+ //任务是本人发布的
+ if (postTaskRecord.getLevel() == 5) {
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);
+ text += SpeechUtil.getPreSuccessTaskSpeech(uid, player.getPersonMap().get(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); //执行任务
+ CacheUtil.put(unique, reply, Long.parseLong(expireTime));
+ }
}
//----------------记录见过的人--------------
PlayerUtil.recordClue(uid, subjectId);
+ //更新该NPC见面次数
+ PlayerUtil.updateMeetTimes(uid, locationId, subjectId);
resultResponse.set反馈ID(400107);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
@@ -258,8 +612,6 @@ public class BarrierServiceImpl implements BarrierService {
}
}
}
- //获取人物所在场所
- locationId = player.getPersonMap().get(subjectId).getLocation();
//跟玩家在同一场所
if (player.getLocation().equals(locationId)) {
player.setPersonId(subjectId);
@@ -281,6 +633,10 @@ 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);
@@ -294,6 +650,10 @@ 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());
@@ -320,6 +680,9 @@ public class BarrierServiceImpl implements BarrierService {
PlayerUtil.resetPlayer(uid);
//获取对应话术
String text = SpeechUtil.getBarrierSpeech(Constants.SPEECH_ASIDE, 400302);
+ //获取开场白话术
+ String prologueText = SpeechUtil.getPrologueSpeech(uid, player.getGateNo());
+ text += prologueText;
resultResponse.set反馈ID(400302);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
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..793f7bd 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
@@ -36,19 +36,32 @@ public class ChatServiceImpl implements ChatService {
Player player = TimingAcquisition.playerMap.get(uid);
//对话人的信息
Person current = player.getPersonMap().get(player.getPersonId());
+ //搭档名称
+ String partnerName = TimingAcquisition.systemConfigMap.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) {
+ if (player.getChatTimes() >= chatTimes - 1) {
//找到白名单内该人的任务中已解锁或无需解锁的任务
String addText = PlayerUtil.getTipInChat(uid, current);
if (!StringUtils.isEmpty(addText)) {
- addText = "【寒烟@正常】" + addText;
+ 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..3ce8d6c 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,6 @@ import com.qiwu.inference.dto.response.ResultVarsResponse;
public interface CheckService {
CommonResult check(OperationRequest operationReq);
+
+ CommonResult secondAnswer(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..93fff39 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;
@@ -22,6 +23,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import static com.qiwu.inference.common.utils.PlayerUtil.addThreshold;
+
@Service
public class CheckServiceImpl implements CheckService {
private Logger log = LoggerFactory.getLogger(CheckServiceImpl.class);
@@ -30,6 +33,9 @@ public class CheckServiceImpl implements CheckService {
@Value("${expireTime}")
private String expireTime;
+ @Autowired
+ private ChatServiceImpl chatService;
+
@Override
public CommonResult check(OperationRequest operationReq) {
ResultVarsResponse resultVarsResponse = new ResultVarsResponse();
@@ -179,7 +185,7 @@ public class CheckServiceImpl implements CheckService {
String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300102);
text = SpeechUtil.speechReplaceNum(text, subjectName, person.getAge().toString(),
(person.getGender() == 1) ? "男" : "女", call,
- person.getTrustDegree().toString(), person.getDeterrenceDegree().toString());
+ String.valueOf(person.getTrustDegree() - 50), String.valueOf(person.getDeterrenceDegree() - 50));
resultResponse.set反馈ID(300102);
resultResponse.set反馈文本(text);
resultResponse.set后台附加返回("查看人物列表2");
@@ -244,7 +250,7 @@ public class CheckServiceImpl implements CheckService {
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);
}
@@ -297,6 +303,9 @@ public class CheckServiceImpl implements CheckService {
text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300501);
} else {
text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050101);
+ //搭档名称
+ String partnerName = TimingAcquisition.systemConfigMap.get("partnerName").getValue();
+ text = SpeechUtil.addHeader(text, partnerName);
}
text = SpeechUtil.speechReplaceNum(text, String.valueOf(clueSize));
resultResponse.set反馈ID(300501);
@@ -363,7 +372,9 @@ public class CheckServiceImpl implements CheckService {
if (clueNumMap.size() == 0) {
//获取对应话术
String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050301);
- text = SpeechUtil.speechReplaceNum(text, clueText.toString());
+ //搭档名称
+ String partnerName = TimingAcquisition.systemConfigMap.get("partnerName").getValue();
+ text = SpeechUtil.addHeader(text, partnerName);
resultResponse.set反馈ID(30050301);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
@@ -538,9 +549,19 @@ public class CheckServiceImpl implements CheckService {
int index = lastReq.getIndex();
String subjectName = TimingAcquisition.getNameByPersonId(uid, lastReq.getSubjectId());
//获取对应话术
- String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300506);
+ String text = "";
+ if (clueList.size() > 1) {
+ if (index < clueList.size() - 1) {
+ text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300506);
+ } else {
+ text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050607);
+ }
+ } else {
+ text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050606);
+ }
+ String addText = SpeechUtil.getSuccessClueOtherSpeech(uid, player.getPersonMap().get(subjectId), clueList.get(index));
text = SpeechUtil.speechReplaceNum(text, subjectName, TimingAcquisition.clueTypeMap.get(lastReq.getClueTypeId()),
- String.valueOf(clueList.size()), String.valueOf(index + 1), clueList.get(index).getClueTemplate());
+ String.valueOf(clueList.size()), String.valueOf(index + 1), addText);
//保存本轮对话
index = (index + 1) % clueList.size();
operationReq.setSubjectId(lastReq.getSubjectId());
@@ -624,9 +645,15 @@ public class CheckServiceImpl implements CheckService {
List clueList = player.getClueMap().get(subjectId).get(clueTypeId);
int index = 0;
//获取对应话术
- String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300506);
+ String text = "";
+ if (clueList.size() > 1) {
+ text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 300506);
+ } else {
+ text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 30050606);
+ }
+ String addText = SpeechUtil.getSuccessClueOtherSpeech(uid, player.getPersonMap().get(subjectId), clueList.get(index));
text = SpeechUtil.speechReplaceNum(text, subjectName, TimingAcquisition.clueTypeMap.get(clueTypeId),
- String.valueOf(clueList.size()), String.valueOf(index + 1), clueList.get(index).getClueTemplate());
+ String.valueOf(clueList.size()), String.valueOf(index + 1), addText);
//保存本轮对话
index = (index + 1) % clueList.size();
operationReq.setSubjectId(subjectId);
@@ -643,10 +670,17 @@ public class CheckServiceImpl implements CheckService {
}
//查看某人的模糊操作
if ("3101".equals(methodId)) {
+ //询问对象为对话人
+ if(StringUtils.isEmpty(subjectId)){
+ subjectId = player.getPersonId();
+ }
+ //搭档名称
+ String partnerName = TimingAcquisition.systemConfigMap.get("partnerName").getValue();
//没有提供人物名称
if (StringUtils.isEmpty(subjectId)) {
//获取对应话术
String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 310101);
+ text = SpeechUtil.replaceHeader(text, partnerName);
resultResponse.set反馈ID(310101);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
@@ -656,6 +690,7 @@ public class CheckServiceImpl implements CheckService {
if (subjectId == Constants.REQ_NON) {
//获取对应话术
String text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 310102);
+ text = SpeechUtil.replaceHeader(text, partnerName);
resultResponse.set反馈ID(310102);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
@@ -688,6 +723,7 @@ public class CheckServiceImpl implements CheckService {
if (!personList.contains(subjectId)) {
//获取对应话术
String text = SpeechUtil.getCheckSpeech(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);
@@ -698,9 +734,10 @@ public class CheckServiceImpl implements CheckService {
String call = (subject.getGender() == 1) ? "他" : "她";
//获取对应话术
String text = SpeechUtil.getCheckSpeech(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(subject.getTrustDegree() - 50), String.valueOf(subject.getDeterrenceDegree() - 50));
resultResponse.set反馈ID(310104);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
@@ -714,4 +751,169 @@ public class CheckServiceImpl implements CheckService {
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 = player.getPersonMap().get(player.getPersonId());
+ Integer subjectId = reply.getSubjectId();
+ Integer demandTaskId = reply.getDemandTaskId();
+ int type = reply.getType(); //响应方式
+ //找到对应任务
+ DemandTaskDto demandTask = PlayerUtil.getDemandTaskById(uid, subjectId, demandTaskId);
+ Person subject = player.getPersonMap().get(subjectId);
+ //走闲聊
+ 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]) - 68002);
+ //条件判断
+ // 1. 判断是否符合阈值需求
+ boolean flag = PlayerUtil.checkThreshold(demandTask, subject);
+ //不符合阈值需求
+ if (!flag) {
+ int feedBackId = Integer.parseInt(method + "04");
+ log.info(uid + "二次回复的反馈id:" + feedBackId);
+ //获取对应话术
+ text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 210204);
+ 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);
+ }
+ 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()) {
+ int feedBackId = Integer.parseInt(method + "02");
+ log.info(uid + "二次回复的反馈id:" + feedBackId);
+ //获取对应话术
+ text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 210202);
+ 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);
+ }
+ Map objectMap = taskMap.get(objectId);
+ if (objectMap.containsKey(Integer.parseInt(demandTask.getPostTask()))) {
+ int feedBackId = Integer.parseInt(method + "01");
+ log.info(uid + "二次回复的反馈id:" + feedBackId);
+ subjectMap.put(demandTask.getDemandTaskId(), num + 1);
+ addThreshold(subject, demandTask);
+ //增加声望值
+ PlayerUtil.updateReputation(player, demandTask.getReputation());
+ //获取对应话术
+ text = SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask);
+ resultResponse.set反馈ID(feedBackId);
+ resultResponse.set反馈文本(text);
+ resultVarsResponse.setVars(resultResponse);
+ return CommonResult.success(resultVarsResponse);
+ }
+ //符合阈值需求,前置任务没有完成
+ int feedBackId = Integer.parseInt(method + "03");
+ log.info(uid + "二次回复的反馈id:" + feedBackId);
+ //获取对应话术
+ text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 210203);
+ text = SpeechUtil.replaceHeader(text, subject.getName());
+ resultResponse.set反馈ID(feedBackId);
+ 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()))) {
+ int feedBackId = Integer.parseInt(method + "01");
+ log.info(uid + "二次回复的反馈id:" + feedBackId);
+ subjectMap.put(demandTask.getDemandTaskId(), 1);
+ addThreshold(subject, demandTask);
+ //增加声望值
+ PlayerUtil.updateReputation(player, demandTask.getReputation());
+ //清除缓存
+ CacheGlobal.concurrentMap.remove(unique);
+ //获取对应话术
+ text = SpeechUtil.getSuccessTaskSpeech(uid, subject, demandTask);
+ resultResponse.set反馈ID(feedBackId);
+ resultResponse.set反馈文本(text);
+ resultVarsResponse.setVars(resultResponse);
+ return CommonResult.success(resultVarsResponse);
+ }
+ }
+ //符合阈值需求,前置任务没有完成
+ int feedBackId = Integer.parseInt(method + "03");
+ log.info(uid + "二次回复的反馈id:" + feedBackId);
+ //获取对应话术
+ text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 210203);
+ 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);
+ }
+ }
+ }
+ //自身线索提示对应文本
+ if (type == 4) {
+ text = SpeechUtil.getTipReplySpeech(uid, demandTask, 0, 2, reply);
+ }
+ }
+ //否定
+ if ("002".equals(methodId)) {
+ text = SpeechUtil.getCheckSpeech(Constants.SPEECH_ASIDE, 3007);
+ }
+ resultResponse.set反馈ID(300001);
+ resultResponse.set反馈文本(text);
+ 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..427c2d9 100644
--- a/src/main/java/com/qiwu/inference/service/common/CommonService.java
+++ b/src/main/java/com/qiwu/inference/service/common/CommonService.java
@@ -52,6 +52,8 @@ public class CommonService {
case "1028":
case "1029":
return playerService.askPrompt(request);
+ case "1030":
+ return playerService.askFinalClue(request);
case "2001":
case "2003":
case "2002":
@@ -93,6 +95,7 @@ public class CommonService {
case "2039":
case "2040":
case "2041":
+ case "2042":
case "2101":
case "2102":
case "2104":
@@ -100,6 +103,13 @@ public class CommonService {
case "2107":
case "2108":
case "2109":
+ case "2043":
+ case "204301":
+ case "204302":
+ case "204303":
+ case "204304":
+ case "204305":
+ case "2044":
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..860433c 100644
--- a/src/main/java/com/qiwu/inference/service/login/LoginService.java
+++ b/src/main/java/com/qiwu/inference/service/login/LoginService.java
@@ -9,4 +9,6 @@ public interface LoginService {
CommonResult login(String uid);
CommonResult startGame(OperationRequest operationReq);
+
+ CommonResult loadPlayerData(String uid);
}
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..0901aa5 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
@@ -2,6 +2,7 @@ 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;
@@ -22,6 +23,8 @@ import java.util.concurrent.ConcurrentHashMap;
@Service
public class LoginServiceImpl implements LoginService {
+ @Value("${offlineTime}")
+ private String offlineTime;
//从yml配置文件中取出对话过期时间
@Value("${expireTime}")
private String expireTime;
@@ -49,14 +52,17 @@ public class LoginServiceImpl implements LoginService {
Map> taskMapCopy = new HashMap<>();
Map personMapCopy = new HashMap<>();
Map name2IdMapCopy = new HashMap<>();
+ Map id2NameMapCopy = new HashMap<>();
for (Person person : personCopyList) {
taskMapCopy.put(person.getId(), new HashMap<>());
personMapCopy.put(person.getId(), person);
name2IdMapCopy.put(person.getName(), person.getId());
+ id2NameMapCopy.put(person.getId(), person.getName());
}
player.setTaskMap(taskMapCopy);
player.setPersonMap(personMapCopy);
player.setName2IdMap(name2IdMapCopy);
+ player.setId2NameMap(id2NameMapCopy);
//给玩家分配场所和对话人物
Map> locationPersonMap = new HashMap<>();
Map personMap = player.getPersonMap();
@@ -95,6 +101,12 @@ public class LoginServiceImpl implements LoginService {
PersistenceUtil.saveDataToFile(userFilePath, uid, playerStr);
sidGateNoMap.put(uid, player.getGateNo());
TimingAcquisition.uidGateNoMap.putAll(sidGateNoMap);
+ //保存所有玩家的uid
+ TimingAcquisition.uidList.add(uid);
+
+ //该玩家以唯一标识加入全局缓存,用于玩家离线判断
+ String uniqueUid = uid + "%#%online%#%";
+ CacheUtil.put(uniqueUid, "", Long.parseLong(offlineTime));
resultResponse.set反馈ID(100000);
resultResponse.set反馈文本("登录成功");
@@ -108,7 +120,6 @@ public class LoginServiceImpl implements LoginService {
ResultResponse resultResponse = new ResultResponse();
String uid = operationReq.getUid();
- String text = "";
Player player = TimingAcquisition.playerMap.get(uid);
//数据重置
if (player.getFinished() == 1) {
@@ -122,15 +133,17 @@ public class LoginServiceImpl implements LoginService {
Map> taskMapCopy = new HashMap<>();
Map personMapCopy = new HashMap<>();
Map name2IdMapCopy = new HashMap<>();
+ Map id2NameMapCopy = new HashMap<>();
for (Person person : personCopyList) {
taskMapCopy.put(person.getId(), new HashMap<>());
personMapCopy.put(person.getId(), person);
name2IdMapCopy.put(person.getName(), person.getId());
+ id2NameMapCopy.put(person.getId(), person.getName());
}
player.setTaskMap(taskMapCopy);
player.setPersonMap(personMapCopy);
player.setName2IdMap(name2IdMapCopy);
- player.setCurrency(3000.0);
+ player.setId2NameMap(id2NameMapCopy);
//给玩家分配场所和对话人物
Map> locationPersonMap = new HashMap<>();
Map personMap = player.getPersonMap();
@@ -161,29 +174,42 @@ public class LoginServiceImpl implements LoginService {
//生成场所表,包含场所隐藏状态和必现场所
Map locationMap = PlayerUtil.makeLocationMap(locationPersonMap);
player.setLocationMap(locationMap);
+ player.setCurrency(3000.0);
+ player.setPoint(0);
+ player.setClueMap(new HashMap<>());
+ player.setFinishedTaskNum(0);
+ player.setTipFlag(false);
+ player.setOperateTextNum(1);
+ player.setAskAndNumMap(new HashMap<>());
+ player.setFinished(0);
}
//关卡编号
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 text = SpeechUtil.getPrologueSpeech(uid, gateNo);
resultResponse.set反馈ID(100009);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
return CommonResult.success(resultVarsResponse);
}
+
+ @Override
+ public CommonResult loadPlayerData(String uid) {
+ ResultVarsResponse resultVarsResponse = new ResultVarsResponse();
+ ResultResponse resultResponse = new ResultResponse();
+
+ String playStr = PersistenceUtil.loadPlayerData(userFilePath, uid);
+ 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));
+
+ resultResponse.set反馈ID(100010);
+ resultResponse.set反馈文本(uid + "的数据加载完成");
+ 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..66e9d39 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
@@ -6,10 +6,7 @@ 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.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;
@@ -19,10 +16,7 @@ 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;
@@ -128,22 +122,28 @@ public class PlayerServiceImpl implements PlayerService {
//判断是否为指定性格类型的线索
clueList = PlayerUtil.checkClueType(clueList, type);
if (clueList.size() == 0) {
+ String text = "";
//获取对应话术
- String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100103);
+ if (!"2".equals(type)) {
+ text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 100103);
+ } else {
+ text = SpeechUtil.getAskSpeech(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));
//获取对应话术
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);
@@ -197,7 +197,8 @@ 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);
@@ -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));
//获取对应话术
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,14 +253,15 @@ 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());
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);
@@ -311,19 +313,23 @@ 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));
//获取对应话术
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);
@@ -367,7 +373,8 @@ 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, relationName);
@@ -381,19 +388,22 @@ 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));
//获取对应话术
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);
@@ -465,14 +475,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));
//获取对应话术
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);
@@ -524,14 +534,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);
@@ -618,14 +628,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));
//获取对应话术
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);
@@ -669,14 +679,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));
//获取对应话术
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);
@@ -734,14 +744,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));
//获取对应话术
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);
@@ -787,7 +797,8 @@ 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, behaviourName);
@@ -801,14 +812,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));
//获取对应话术
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);
@@ -861,7 +872,8 @@ 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, behaviourName);
@@ -875,14 +887,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));
//获取对应话术
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);
@@ -935,11 +947,19 @@ public class PlayerServiceImpl implements PlayerService {
//查找符合条件的任务
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(Constants.SPEECH_PERSON, 101506);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ resultResponse.set反馈ID(101506);
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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);
@@ -967,22 +987,67 @@ 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(Constants.SPEECH_PERSON, 101505);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ text = SpeechUtil.speechReplaceNum(text, current.getName());
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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);
+ //----------------记录线索--------------
+ PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue);
+ //----------------是否解锁任务-------------
+ PlayerUtil.unlockTask(uid, subject, 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,11 +1056,30 @@ 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(Constants.SPEECH_PERSON, 101605);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ resultResponse.set反馈ID(101605);
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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(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);
@@ -1011,14 +1095,59 @@ 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(Constants.SPEECH_PERSON, 101606);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ text = SpeechUtil.speechReplaceNum(text, current.getName());
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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);
+ //----------------记录线索--------------
+ PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue);
+ //----------------是否解锁任务-------------
+ PlayerUtil.unlockTask(uid, subject, 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);
@@ -1043,6 +1172,17 @@ public class PlayerServiceImpl implements PlayerService {
resultVarsResponse.setVars(resultResponse);
return CommonResult.success(resultVarsResponse);
}
+ //过滤掉已经完成的任务对应的线索
+ clueList = PlayerUtil.getUndoClueList(uid, subject, clueList);
+ if(clueList.size() == 0){
+ //获取对应话术
+ String text = SpeechUtil.getAskSpeech(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);
if(clueList.size() == 0){
@@ -1054,7 +1194,8 @@ 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 = PlayerUtil.getCluesIsType(current, clueList, 1);
@@ -1068,14 +1209,59 @@ 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(Constants.SPEECH_PERSON, 101505);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ text = SpeechUtil.speechReplaceNum(text, current.getName());
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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);
+ //----------------记录线索--------------
+ PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue);
+ //----------------是否解锁任务-------------
+ PlayerUtil.unlockTask(uid, subject, 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);
@@ -1092,11 +1278,30 @@ 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(Constants.SPEECH_PERSON, 101806);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ resultResponse.set反馈ID(101806);
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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(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);
@@ -1112,7 +1317,8 @@ 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 = PlayerUtil.getCluesIsType(current, clueList, 3);
@@ -1126,14 +1332,59 @@ 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(Constants.SPEECH_PERSON, 101606);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ text = SpeechUtil.speechReplaceNum(text, current.getName());
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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);
+ //----------------记录线索--------------
+ PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue);
+ //----------------是否解锁任务-------------
+ PlayerUtil.unlockTask(uid, subject, 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,11 +1393,30 @@ 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(Constants.SPEECH_PERSON, 101905);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ resultResponse.set反馈ID(101905);
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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(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);
@@ -1162,14 +1432,59 @@ 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(Constants.SPEECH_PERSON, 101505);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ text = SpeechUtil.speechReplaceNum(text, current.getName());
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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);
+ //----------------记录线索--------------
+ PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue);
+ //----------------是否解锁任务-------------
+ PlayerUtil.unlockTask(uid, subject, 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,11 +1493,30 @@ 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(Constants.SPEECH_PERSON, 102005);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ resultResponse.set反馈ID(102005);
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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(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);
@@ -1198,14 +1532,59 @@ 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(Constants.SPEECH_PERSON, 101606);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ text = SpeechUtil.speechReplaceNum(text, current.getName());
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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);
+ //----------------记录线索--------------
+ PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue);
+ //----------------是否解锁任务-------------
+ PlayerUtil.unlockTask(uid, subject, 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);
@@ -1223,11 +1602,30 @@ 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(Constants.SPEECH_PERSON, 102106);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ resultResponse.set反馈ID(102106);
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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(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);
@@ -1243,7 +1641,8 @@ 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 = PlayerUtil.getCluesIsType(current, clueList, 2);
@@ -1257,14 +1656,59 @@ 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(Constants.SPEECH_PERSON, 101505);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ text = SpeechUtil.speechReplaceNum(text, current.getName());
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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);
+ //----------------记录线索--------------
+ PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue);
+ //----------------是否解锁任务-------------
+ PlayerUtil.unlockTask(uid, subject, 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);
@@ -1281,11 +1725,30 @@ 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(Constants.SPEECH_PERSON, 102206);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ resultResponse.set反馈ID(102206);
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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(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);
@@ -1301,7 +1764,8 @@ 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 = PlayerUtil.getCluesIsType(current, clueList, 4);
@@ -1315,14 +1779,59 @@ 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(Constants.SPEECH_PERSON, 101606);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ text = SpeechUtil.speechReplaceNum(text, current.getName());
+ } else {
+ //获取对应话术
+ text = SpeechUtil.getAskSpeech(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);
+ //----------------记录线索--------------
+ PlayerUtil.recordClue(uid, current.getId(), subjectId, clue.getType(), clue);
+ //----------------是否解锁任务-------------
+ PlayerUtil.unlockTask(uid, subject, 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);
@@ -1415,14 +1924,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));
//获取对应话术
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);
@@ -1469,7 +1978,8 @@ 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, identityName);
@@ -1483,14 +1993,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));
//获取对应话术
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);
@@ -1545,8 +2055,19 @@ public class PlayerServiceImpl implements PlayerService {
}
Integer subjectId = player.getName2IdMap().get(subjectName);
Person subject =player.getPersonMap().get(subjectId);
- //查找符合条件的线索
- List clueList = findClues(current, subject, 2);
+ //如果询问对象问本人
+ if (subjectId.equals(player.getPersonId())) {
+ //获取对应话术
+ String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102504);
+ text = SpeechUtil.replaceHeader(text, current.getName());
+ text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.locationMap.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);
@@ -1568,14 +2089,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(102501);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
@@ -1623,7 +2144,8 @@ 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,locationName);
@@ -1637,14 +2159,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);
@@ -1671,6 +2193,8 @@ public class PlayerServiceImpl implements PlayerService {
//当前对话的人物
Person current = player.getPersonMap().get(player.getPersonId());
request.setOperate(Constants.OPERATE_ASK);
+ //搭档名称
+ String partnerName = TimingAcquisition.systemConfigMap.get("partnerName").getValue();
if("1027".equals(methodId)){
//当前玩家上一轮的请求信息
OperationRequest lastReq = (OperationRequest) CacheUtil.get(uid);
@@ -1687,7 +2211,7 @@ public class PlayerServiceImpl implements PlayerService {
CacheUtil.put(uid, request, Long.parseLong(expireTime));
//获取对应话术
String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102701);
- text = SpeechUtil.replaceHeader(text, "寒烟");
+ text = SpeechUtil.replaceHeader(text, partnerName);
text = SpeechUtil.speechReplaceNum(text, objectName);
resultResponse.set反馈ID(102701);
resultResponse.set反馈文本(text);
@@ -1700,7 +2224,7 @@ public class PlayerServiceImpl implements PlayerService {
if (personIdList.size() == 0) {
//获取对应话术
String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102702);
- text = SpeechUtil.replaceHeader(text, "寒烟");
+ text = SpeechUtil.replaceHeader(text, partnerName);
resultResponse.set反馈ID(102702);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
@@ -1715,7 +2239,7 @@ public class PlayerServiceImpl implements PlayerService {
CacheUtil.put(uid, request, Long.parseLong(expireTime));
//获取对应话术
String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102701);
- text = SpeechUtil.replaceHeader(text, "寒烟");
+ text = SpeechUtil.replaceHeader(text, partnerName);
text = SpeechUtil.speechReplaceNum(text, objectName);
resultResponse.set反馈ID(102701);
resultResponse.set反馈文本(text);
@@ -1736,8 +2260,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);
}
@@ -1746,7 +2271,7 @@ public class PlayerServiceImpl implements PlayerService {
if ("1029".equals(methodId)) {
//获取对应话术
String text = SpeechUtil.getAskSpeech(Constants.SPEECH_PERSON, 102901);
- text = SpeechUtil.replaceHeader(text, "寒烟");
+ text = SpeechUtil.replaceHeader(text, partnerName);
text = SpeechUtil.speechReplaceNum(text, TimingAcquisition.locationMap.get(player.getLocation()).getName());
resultResponse.set反馈ID(102901);
resultResponse.set反馈文本(text);
@@ -1756,7 +2281,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 = player.getPersonMap().get(player.getPersonId());
+ //询问对象为对话人
+ if(StringUtils.isEmpty(subjectName)){
+ subjectName = current.getName();
+ }
+ Integer subjectId = player.getName2IdMap().get(subjectName);
+ //该关卡没有这个人物
+ if(StringUtils.isEmpty(subjectId)){
+ //获取对应话术
+ String text = SpeechUtil.getAskSpeech(Constants.SPEECH_ASIDE, 100008);
+ resultResponse.set反馈ID(100008);
+ resultResponse.set反馈文本(text);
+ resultVarsResponse.setVars(resultResponse);
+ return CommonResult.success(resultVarsResponse);
+ }
+ Person subject = player.getPersonMap().get(subjectId);
+ //询问最终线索
+ if ("1030".equals(methodId)) {
+ //查找符合条件的任务
+ List clueList = PlayerUtil.getClueByConditionTaskId(uid, subjectId, taskConditionId);
+ if(clueList.size() == 0){
+ //获取对应话术
+ String text = SpeechUtil.getAskSpeech(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(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, subject, 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(Constants.SPEECH_PERSON, 103003);
+ text = SpeechUtil.addHeader(text, current.getName());
+ resultResponse.set反馈ID(103003);
+ resultResponse.set反馈文本(text);
+ resultVarsResponse.setVars(resultResponse);
+ return CommonResult.success(resultVarsResponse);
+ }
/**
@@ -1781,16 +2386,20 @@ public class PlayerServiceImpl implements PlayerService {
String call = (gender == 1) ? "他" : "她";
//货币配置名称
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)){
+ //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");
+
+ //1.无后置任务,不能重复扣钱
+ if (methodIdList.contains(methodId)) {
if(!StringUtils.isEmpty(subject)){
List demandTaskList = subject.getDemandTasks();
for (DemandTaskDto demandTask : demandTaskList) {
@@ -1804,87 +2413,111 @@ public class PlayerServiceImpl implements PlayerService {
if (!StringUtils.isEmpty(condition2)) {
value = Integer.parseInt(condition2);
if (player.getCurrency() < value) {
+ int feedBackId = Integer.parseInt(methodId + "04");
//获取对应话术
- String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_ASIDE, 200104);
+ String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, feedBackId);
text = SpeechUtil.replaceHeader(text, subject.getName());
- text = SpeechUtil.speechReplaceNum(text, String.valueOf(value), moneyName);
- resultResponse.set反馈ID(200104);
+ text = SpeechUtil.speechReplaceValue(sid, text, subject, demandTask);
+ resultResponse.set反馈ID(feedBackId);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
return CommonResult.success(resultVarsResponse);
}
}
- // 2. 判断是否符合阈值需求
+ // 2. 判断是否符合阈值需求
boolean flag = checkThreshold(demandTask, subject);
//不符合阈值需求
if (!flag) {
+ int feedBackId = Integer.parseInt(methodId + "03");
//获取对应话术
- String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200105);
+ String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, feedBackId);
text = SpeechUtil.replaceHeader(text, subject.getName());
- resultResponse.set反馈ID(200105);
+ text = SpeechUtil.speechReplaceValue(sid, 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);
- 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));
-
+ }
+ //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])) {
+ int feedBackId = Integer.parseInt(methodId + "02");
//获取对应话术
- String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask);
- resultResponse.set反馈ID(200101);
+ String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, feedBackId);
+ text = SpeechUtil.replaceHeader(text, subject.getName());
+ text = SpeechUtil.speechReplaceValue(sid, text, subject, demandTask);
+ resultResponse.set反馈ID(feedBackId);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
return CommonResult.success(resultVarsResponse);
}
- // 3.信任阈值提升
- map.put(demandTask.getDemandTaskId(), 1);
+ //扣除货币
+ if (value > 0) {
+ PlayerUtil.updateMoneyNum(sid, value);
+ }
+ if (demandTask.getTaskLabel() == 3) {
+ //最终任务完成
+ player.setFinished(1);
+ }
+ int feedBackId = Integer.parseInt(methodId + "01");
+ //任务完成
+ map.put(demandTask.getDemandTaskId(), num + 1);
+ //3.信任阈值提升
addThreshold(subject, demandTask);
-
-// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player));
+ //增加声望值
+ PlayerUtil.updateReputation(player, demandTask.getReputation());
+ //ThreadLocalUtil.add(sid,player);
+// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player));
//获取对应话术
String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask);
- resultResponse.set反馈ID(200101);
+ resultResponse.set反馈ID(feedBackId);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
return CommonResult.success(resultVarsResponse);
}
+ //扣除货币
+ if (value > 0) {
+ PlayerUtil.updateMoneyNum(sid, value);
+ }
+ if (demandTask.getTaskLabel() == 3) {
+ //最终任务完成
+ player.setFinished(1);
+ }
+ int feedBackId = Integer.parseInt(methodId + "01");
+ //任务完成
+ map.put(demandTask.getDemandTaskId(), 1);
+ // 3.信任阈值提升
+ addThreshold(subject, demandTask);
+ //增加声望值
+ PlayerUtil.updateReputation(player, demandTask.getReputation());
+ //获取对应话术
+ String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask);
+ resultResponse.set反馈ID(feedBackId);
+ resultResponse.set反馈文本(text);
+ resultVarsResponse.setVars(resultResponse);
+ return CommonResult.success(resultVarsResponse);
}
}
}
}
- //玩家没有挂相关任务
+ int feedBackId = Integer.parseInt(methodId + "05");
//获取对应话术
- String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200106);
+ String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, feedBackId);
text = SpeechUtil.replaceHeader(text, subject.getName());
- resultResponse.set反馈ID(200106);
+ resultResponse.set反馈ID(feedBackId);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
return CommonResult.success(resultVarsResponse);
}
- }else if("2002".equals(methodId)){
+ }
+
+ //2.无后置任务,且能重复扣钱
+ if (methodIdCostList.contains(methodId)) {
if(!StringUtils.isEmpty(subject)){
List demandTaskList = subject.getDemandTasks();
for (DemandTaskDto demandTask : demandTaskList) {
@@ -1892,16 +2525,33 @@ public class PlayerServiceImpl implements PlayerService {
String[] condition1 = demandTask.getCondition1().split("\\|");
if (taskConditionId.equals(condition1[0]) && demandTask.getClueSwitch() != 1) {
//条件判断
- // 1. 判断是否符合阈值需求
+ // 1. 判断是否满足货币消费条件
+ String condition2 = demandTask.getCondition2();
+ int value = 0;
+ if (!StringUtils.isEmpty(condition2)) {
+ value = Integer.parseInt(condition2);
+ if (player.getCurrency() < value) {
+ int feedBackId = Integer.parseInt(methodId + "04");
+ //获取对应话术
+ String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, feedBackId);
+ text = SpeechUtil.replaceHeader(text, subject.getName());
+ text = SpeechUtil.speechReplaceValue(sid, text, subject, demandTask);
+ resultResponse.set反馈ID(feedBackId);
+ resultResponse.set反馈文本(text);
+ resultVarsResponse.setVars(resultResponse);
+ return CommonResult.success(resultVarsResponse);
+ }
+ }
+ // 2. 判断是否符合阈值需求
boolean flag = checkThreshold(demandTask, subject);
//不符合阈值需求
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(Constants.SPEECH_PERSON, feedBackId);
text = SpeechUtil.replaceHeader(text, subject.getName());
- resultResponse.set反馈ID(200203);
+ text = SpeechUtil.speechReplaceValue(sid, text, subject, demandTask);
+ resultResponse.set反馈ID(feedBackId);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
return CommonResult.success(resultVarsResponse);
@@ -1909,37 +2559,49 @@ public class PlayerServiceImpl implements PlayerService {
//2.符合阈值需求,判断是否已达次数上限
Map> taskMap = player.getTaskMap();
if (taskMap.containsKey(subjectId)) {
+ //扣除货币
+ if (value > 0) {
+ 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])) {
- //符合阈值需求,已达次数上限
+ int feedBackId = Integer.parseInt(methodId + "02");
//获取对应话术
- String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200202);
+ String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, feedBackId);
text = SpeechUtil.replaceHeader(text, subject.getName());
- resultResponse.set反馈ID(200202);
+ text = SpeechUtil.speechReplaceValue(sid, text, subject, demandTask);
+ 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(), num + 1);
addThreshold(subject, demandTask);
+ //增加声望值
+ PlayerUtil.updateReputation(player, demandTask.getReputation());
//ThreadLocalUtil.add(sid,player);
// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player));
//获取对应话术
String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask);
- resultResponse.set反馈ID(200201);
+ 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);
+ //增加声望值
+ PlayerUtil.updateReputation(player, demandTask.getReputation());
//获取对应话术
String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask);
- resultResponse.set反馈ID(200201);
+ resultResponse.set反馈ID(feedBackId);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
return CommonResult.success(resultVarsResponse);
@@ -1947,15 +2609,19 @@ public class PlayerServiceImpl implements PlayerService {
}
}
}
+ int feedBackId = Integer.parseInt(methodId + "05");
//获取对应话术
- String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200204);
+ String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, feedBackId);
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)){
+ }
+
+ //3.有前置任务
+ if (methodIdWithPreList.contains(methodId)) {
if(!StringUtils.isEmpty(subject)){
List demandTaskList = subject.getDemandTasks();
for (DemandTaskDto demandTask : demandTaskList) {
@@ -1963,3088 +2629,192 @@ public class PlayerServiceImpl implements PlayerService {
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, 200303);
- text = SpeechUtil.replaceHeader(text, subject.getName());
- text = SpeechUtil.speechReplaceNum(text, String.valueOf(value));
- resultResponse.set反馈ID(200303);
- resultResponse.set反馈文本(text);
- resultVarsResponse.setVars(resultResponse);
- return CommonResult.success(resultVarsResponse);
- }
- }
- // 2. 判断是否符合阈值需求
+ // 1. 判断是否符合阈值需求
boolean flag = checkThreshold(demandTask, subject);
//不符合阈值需求
if (!flag) {
+ int feedBackId = Integer.parseInt(methodId + "04");
//获取对应话术
- String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200304);
+ String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, feedBackId);
text = SpeechUtil.replaceHeader(text, subject.getName());
- resultResponse.set反馈ID(200304);
+ text = SpeechUtil.speechReplaceValue(sid, 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);
+ }
+ 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()) {
+ int feedBackId = Integer.parseInt(methodId + "02");
+ //获取对应话术
+ String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, feedBackId);
+ text = SpeechUtil.replaceHeader(text, subject.getName());
+ text = SpeechUtil.speechReplaceValue(sid, text, subject, demandTask);
+ 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);
addThreshold(subject, demandTask);
- //ThreadLocalUtil.add(sid,player);
-// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player));
+ //增加声望值
+ PlayerUtil.updateReputation(player, demandTask.getReputation());
//获取对应话术
String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask);
- resultResponse.set反馈ID(200301);
+ resultResponse.set反馈ID(feedBackId);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
return CommonResult.success(resultVarsResponse);
}
- // 3.信任阈值提升
- map.put(demandTask.getDemandTaskId(), 1);
+ //符合阈值需求,前置任务没有完成
+ int feedBackId = Integer.parseInt(methodId + "03");
+ //获取对应话术
+ String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, feedBackId);
+ text = SpeechUtil.replaceHeader(text, subject.getName());
+ resultResponse.set反馈ID(feedBackId);
+ 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()))) {
+ int feedBackId = Integer.parseInt(methodId + "01");
+ subjectMap.put(demandTask.getDemandTaskId(), 1);
addThreshold(subject, demandTask);
-// PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player));
+ //增加声望值
+ PlayerUtil.updateReputation(player, demandTask.getReputation());
//获取对应话术
String text = SpeechUtil.getSuccessTaskSpeech(sid, subject, demandTask);
- text = SpeechUtil.speechReplaceNum(text, subject.getName());
- resultResponse.set反馈ID(200301);
+ resultResponse.set反馈ID(feedBackId);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
return CommonResult.success(resultVarsResponse);
}
+ //符合阈值需求,前置任务没有完成
+ int feedBackId = Integer.parseInt(methodId + "03");
+ //获取对应话术
+ String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, feedBackId);
+ text = SpeechUtil.replaceHeader(text, subject.getName());
+ text = SpeechUtil.speechReplaceValue(sid, text, subject, demandTask);
+ resultResponse.set反馈ID(feedBackId);
+ resultResponse.set反馈文本(text);
+ resultVarsResponse.setVars(resultResponse);
+ return CommonResult.success(resultVarsResponse);
}
}
}
}
+ int feedBackId = Integer.parseInt(methodId + "05");
//获取对应话术
- String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, 200305);
+ String text = SpeechUtil.getTaskSpeech(Constants.SPEECH_PERSON, feedBackId);
text = SpeechUtil.replaceHeader(text, subject.getName());
- resultResponse.set反馈ID(200305);
+ resultResponse.set反馈ID(feedBackId);
resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse);
return CommonResult.success(resultVarsResponse);
}
- }else if("2004".equals(methodId)){
+ }
+
+ //4.任务成功操作拆分的任务
+ if (methodIdSplitList.contains(methodId)) {
if(!StringUtils.isEmpty(subject)){
- List demandTaskList = subject.getDemandTasks();
- for (DemandTaskDto demandTask : demandTaskList) {
- if (subjectId.equals(demandTask.getSubject())) {
+ 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);
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.符合阈值需求,判断是否已达次数上限
- 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, 200402);
- text = SpeechUtil.replaceHeader(text, subject.getName());
- resultResponse.set反馈ID(200402);
- 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(200401);
- 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