Commit 017a65e9 by 周君强

推理项目更新

parent d4c7ebca
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<component name="JavacSettings"> <component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE"> <option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="InferenceGame" options="-parameters" /> <module name="InferenceGame" options="-parameters" />
<module name="InferenceGame_1.0.1" options="-parameters" />
</option> </option>
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<option value="$PROJECT_DIR$/pom.xml" /> <option value="$PROJECT_DIR$/pom.xml" />
</list> </list>
</option> </option>
<option name="workspaceImportForciblyTurnedOn" value="true" />
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
......
...@@ -2,6 +2,7 @@ package com.qiwu.inference.common; ...@@ -2,6 +2,7 @@ package com.qiwu.inference.common;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference; 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.PersistenceUtil;
import com.qiwu.inference.common.utils.SpeechUtil; import com.qiwu.inference.common.utils.SpeechUtil;
import com.qiwu.inference.dao.*; import com.qiwu.inference.dao.*;
...@@ -25,6 +26,8 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -25,6 +26,8 @@ import java.util.concurrent.ConcurrentHashMap;
public class InitSysServlet implements InitializingBean { public class InitSysServlet implements InitializingBean {
Logger log = LoggerFactory.getLogger(InitSysServlet.class); Logger log = LoggerFactory.getLogger(InitSysServlet.class);
@Value("${offlineTime}")
private String offlineTime;
@Value("${userFilePath}") @Value("${userFilePath}")
private String userFilePath; private String userFilePath;
@Value("${configFilePath}") @Value("${configFilePath}")
...@@ -56,6 +59,19 @@ public class InitSysServlet implements InitializingBean { ...@@ -56,6 +59,19 @@ public class InitSysServlet implements InitializingBean {
Map<String, List<Person>> gateInfoMap = JSON.parseObject(gateInfo, new TypeReference<Map<String, List<Person>>>(){}); Map<String, List<Person>> gateInfoMap = JSON.parseObject(gateInfo, new TypeReference<Map<String, List<Person>>>(){});
TimingAcquisition.gateInfoMap.putAll(gateInfoMap); TimingAcquisition.gateInfoMap.putAll(gateInfoMap);
log.info("关卡数据缓存完成"); log.info("关卡数据缓存完成");
//--------------------------缓存关卡NPC数据---------------------
log.info("开始缓存关卡NPC数据");
Map<String, Map<Integer, Person>> gatePersonMap = new ConcurrentHashMap<>();
for (Map.Entry<String, List<Person>> entry : gateInfoMap.entrySet()) {
List<Person> personList = entry.getValue();
Map<Integer, Person> personMap = new ConcurrentHashMap<>();
for (Person person : personList) {
personMap.put(person.getId(), person);
}
gatePersonMap.put(entry.getKey(), personMap);
}
TimingAcquisition.gatePersonMap.putAll(gatePersonMap);
log.info("关卡NPC数据缓存完成");
for (Map.Entry<String, List<Person>> entry : gateInfoMap.entrySet()) { for (Map.Entry<String, List<Person>> entry : gateInfoMap.entrySet()) {
String gateNo = entry.getKey(); String gateNo = entry.getKey();
...@@ -69,29 +85,6 @@ public class InitSysServlet implements InitializingBean { ...@@ -69,29 +85,6 @@ public class InitSysServlet implements InitializingBean {
log.info("关卡攻略数据缓存完成"); log.info("关卡攻略数据缓存完成");
} }
//--------------------------加载玩家数据----------------------
log.info("开始加载玩家数据");
//从yml配置文件中取出存放玩家数据的地址
File file = new File(userFilePath);
File[] files = file.listFiles();
if (files == null) {
log.info("路径" + userFilePath+ "下没有文件");
return;
}
Map<String, Player> 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<Player>(){});
String fileName = f.getName().replace(".json", "");
playerMap.put(fileName, player);
TimingAcquisition.playerMap.putAll(playerMap);
}
}
log.info("玩家数据缓存完成");
//--------------------加载话术----------------- //--------------------加载话术-----------------
TimingAcquisition.speechLoading(speechFilePath); TimingAcquisition.speechLoading(speechFilePath);
//--------------------加载闲聊话术的excel表---------------- //--------------------加载闲聊话术的excel表----------------
...@@ -124,6 +117,18 @@ public class InitSysServlet implements InitializingBean { ...@@ -124,6 +117,18 @@ public class InitSysServlet implements InitializingBean {
TimingAcquisition.personSpeechMap.putAll(personSpeechMap); TimingAcquisition.personSpeechMap.putAll(personSpeechMap);
log.info("人物见面话术加载完成"); log.info("人物见面话术加载完成");
//--------------------加载操作提示话术的excel表----------------
log.info("加载操作提示话术");
Map<Integer, OperateSpeech> operateSpeechMap = SpeechUtil.getOperateSpeechModel(speechFilePath);
TimingAcquisition.operateSpeechMap.putAll(operateSpeechMap);
log.info("操作提示话术加载完成");
//--------------------加载线索前因话术的excel表----------------
// log.info("加载线索前因话术");
// Map<Integer, List<PreReasonSpeech>> preReasonSpeechMap = SpeechUtil.getPreReasonSpeechModel(speechFilePath);
// TimingAcquisition.preReasonSpeechMap.putAll(preReasonSpeechMap);
// log.info("线索前因话术加载完成");
//-----------------缓存场所信息------------------ //-----------------缓存场所信息------------------
Map<String, Location> locationMap = new ConcurrentHashMap<>(); Map<String, Location> locationMap = new ConcurrentHashMap<>();
...@@ -187,5 +192,35 @@ public class InitSysServlet implements InitializingBean { ...@@ -187,5 +192,35 @@ public class InitSysServlet implements InitializingBean {
} }
TimingAcquisition.endGoalMap.putAll(endGoalMap); TimingAcquisition.endGoalMap.putAll(endGoalMap);
log.info("结局目标配置信息缓存完成"); log.info("结局目标配置信息缓存完成");
//--------------------------加载玩家数据----------------------
log.info("开始加载玩家数据");
//从yml配置文件中取出存放玩家数据的地址
File file = new File(userFilePath);
File[] files = file.listFiles();
if (files == null) {
log.info("路径" + userFilePath+ "下没有文件");
return;
}
Map<String, Player> 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<Player>(){});
String fileName = f.getName().replace(".json", "");
playerMap.put(fileName, player);
TimingAcquisition.playerMap.putAll(playerMap);
TimingAcquisition.uidList.add(fileName); //保存所有玩家的uid
//存放玩家与关卡数据
Map<String, String> sidGateNoMap = new ConcurrentHashMap<>();
sidGateNoMap.put(fileName, player.getGateNo());
TimingAcquisition.uidGateNoMap.putAll(sidGateNoMap);
//该玩家以唯一标识加入全局缓存,用于玩家离线判断
String uniqueUid = fileName + "%#%online%#%";
CacheUtil.put(uniqueUid, "", Long.parseLong(offlineTime));
}
}
log.info("玩家数据缓存完成");
} }
} }
...@@ -22,6 +22,10 @@ public class TimingAcquisition { ...@@ -22,6 +22,10 @@ public class TimingAcquisition {
*/ */
public volatile static Map<String, List<Person>> gateInfoMap = new ConcurrentHashMap<>(); public volatile static Map<String, List<Person>> gateInfoMap = new ConcurrentHashMap<>();
/** /**
* 关卡信息,Map<gateNo, Map<Integer, Person>>
*/
public volatile static Map<String, Map<Integer, Person>> gatePersonMap = new ConcurrentHashMap<>();
/**
* 关卡攻略信息,Map<关卡编号, List<攻略任务>> * 关卡攻略信息,Map<关卡编号, List<攻略任务>>
*/ */
public volatile static Map<String, List<BarrierTaskKeyDto>> barrierTaskKeyMap = new ConcurrentHashMap<>(); public volatile static Map<String, List<BarrierTaskKeyDto>> barrierTaskKeyMap = new ConcurrentHashMap<>();
...@@ -33,6 +37,10 @@ public class TimingAcquisition { ...@@ -33,6 +37,10 @@ public class TimingAcquisition {
* 玩家信息,Map<sid, Player> * 玩家信息,Map<sid, Player>
*/ */
public volatile static Map<String, Player> playerMap = new ConcurrentHashMap<>(); public volatile static Map<String, Player> playerMap = new ConcurrentHashMap<>();
/**
* 所有在线玩家的uid数组。用于是否加载玩家数据的判断
*/
public volatile static List<String> uidList = new ArrayList<>();
/** /**
* 场所配置信息 * 场所配置信息
...@@ -99,6 +107,14 @@ public class TimingAcquisition { ...@@ -99,6 +107,14 @@ public class TimingAcquisition {
* 人物见面话术,Map<人物名称, List<话术配置>> * 人物见面话术,Map<人物名称, List<话术配置>>
*/ */
public volatile static Map<String, List<PersonSpeech>> personSpeechMap = new ConcurrentHashMap<>(); public volatile static Map<String, List<PersonSpeech>> personSpeechMap = new ConcurrentHashMap<>();
/**
* 操作提示话术,Map<人物名称, List<话术配置>>
*/
public volatile static Map<Integer, OperateSpeech> operateSpeechMap = new ConcurrentHashMap<>();
/**
* 线索前因话术,Map<人物名称, List<话术配置>>
*/
public volatile static Map<Integer, List<PreReasonSpeech>> preReasonSpeechMap = new ConcurrentHashMap<>();
/** /**
* 通过yaml文件加载所有话术到缓存中 * 通过yaml文件加载所有话术到缓存中
......
...@@ -20,8 +20,12 @@ import java.util.concurrent.TimeUnit; ...@@ -20,8 +20,12 @@ import java.util.concurrent.TimeUnit;
@EnableAsync @EnableAsync
@Component @Component
public class ExpireThread implements Runnable{ public class ExpireThread implements Runnable{
//动态词组更新秘钥
public static String userFilePath;
@Value("${userFilePath}") @Value("${userFilePath}")
private String userFilePath; public void setUserFilePath(String userFilePath) {
ExpireThread.userFilePath = userFilePath;
}
@Override @Override
public void run() { public void run() {
...@@ -54,10 +58,9 @@ public class ExpireThread implements Runnable{ ...@@ -54,10 +58,9 @@ public class ExpireThread implements Runnable{
//修改下线时间 //修改下线时间
player.setOfflineTime(DateUtil.getCurrentTime()); player.setOfflineTime(DateUtil.getCurrentTime());
//--------------持久化该园丁信息--------------- //--------------持久化该园丁信息---------------
Map<String, Player> playerMap = new ConcurrentHashMap<>(); PersistenceUtil.saveDataToFile(userFilePath, uid, JSON.toJSONString(player));
playerMap.put(uid, TimingAcquisition.playerMap.get(uid)); //-----------------清除该玩家的数据缓存-----------------
String playerStr = JSON.toJSONString(playerMap); TimingAcquisition.playerMap.remove(uid);
PersistenceUtil.saveDataToFile(userFilePath, uid, playerStr);
} }
//清除过期缓存 //清除过期缓存
CacheGlobal.concurrentMap.remove(key); CacheGlobal.concurrentMap.remove(key);
......
...@@ -22,7 +22,7 @@ public class CacheUtil { ...@@ -22,7 +22,7 @@ public class CacheUtil {
MyCache myCache = CacheGlobal.concurrentMap.get(key); MyCache myCache = CacheGlobal.concurrentMap.get(key);
myCache.setHitCount(myCache.getHitCount() + 1); myCache.setHitCount(myCache.getHitCount() + 1);
myCache.setLastTime(System.currentTimeMillis()); myCache.setLastTime(System.currentTimeMillis());
myCache.setExpireTime(System.currentTimeMillis()); myCache.setExpireTime(expire);
myCache.setValue(value); myCache.setValue(value);
} else { } else {
MyCache myCache = new MyCache(); MyCache myCache = new MyCache();
......
...@@ -90,10 +90,13 @@ public class DataTrimUtil { ...@@ -90,10 +90,13 @@ public class DataTrimUtil {
"]"; "]";
//需要给玩家提示任务线索 //需要给玩家提示任务线索
// if (TimingAcquisition.playerMap.get(uid).isTipFlag()) { // if (TimingAcquisition.playerMap.get(uid).isTipFlag()) {
// //搭档名称
// String partnerName = TimingAcquisition.systemConfigMap.get("partnerName").getValue();
// String addText = PlayerUtil.getClueFromTaskKey(uid); // String addText = PlayerUtil.getClueFromTaskKey(uid);
// addText = SpeechUtil.addHeader(addText, partnerName);
// if (!StringUtils.isEmpty(addText)) { // if (!StringUtils.isEmpty(addText)) {
// TimingAcquisition.playerMap.get(uid).setTipFlag(false); // TimingAcquisition.playerMap.get(uid).setTipFlag(false);
// data.getVars().set反馈文本(data.getVars().get反馈文本() + "【寒烟@正常】" + addText); // data.getVars().set反馈文本(data.getVars().get反馈文本() + addText);
// } // }
// } // }
log.info(feedContent); log.info(feedContent);
......
...@@ -102,6 +102,35 @@ public class PersistenceUtil { ...@@ -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格式 * 将话术转成map格式
* @param * @param
* @return Map<String, Map<String, List<String>>> * @return Map<String, Map<String, List<String>>>
...@@ -117,4 +146,36 @@ public class PersistenceUtil { ...@@ -117,4 +146,36 @@ public class PersistenceUtil {
} }
return speechMap; 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;
}
} }
...@@ -59,10 +59,18 @@ public class CommonController { ...@@ -59,10 +59,18 @@ public class CommonController {
CommonResult<ResultVarsResponse> result = null; CommonResult<ResultVarsResponse> result = null;
String uid = commonRequest.getUid(); String uid = commonRequest.getUid();
boolean login = false; boolean login = false;
//玩家第一次登录 //玩家已经存在
if (StringUtils.isEmpty(TimingAcquisition.playerMap.get(uid))) { if (TimingAcquisition.uidList.contains(uid)) {
loginService.login(uid); //玩家已经下线,重新加载
login = true; 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); OperationRequest operationReq = RequestConversionUtil.request2Operation(commonRequest);
...@@ -86,7 +94,7 @@ public class CommonController { ...@@ -86,7 +94,7 @@ public class CommonController {
if ("闲聊".equals(operateName)) { if ("闲聊".equals(operateName)) {
int chatTimes = TimingAcquisition.playerMap.get(uid).getChatTimes(); int chatTimes = TimingAcquisition.playerMap.get(uid).getChatTimes();
int times = Integer.parseInt(TimingAcquisition.systemConfigMap.get("chatTimes").getValue()); int times = Integer.parseInt(TimingAcquisition.systemConfigMap.get("chatTimes").getValue());
if (chatTimes > times) { if (chatTimes >= times - 1) {
TimingAcquisition.playerMap.get(uid).setChatTimes(0); TimingAcquisition.playerMap.get(uid).setChatTimes(0);
} else { } else {
TimingAcquisition.playerMap.get(uid).setChatTimes(TimingAcquisition.playerMap.get(uid).getChatTimes() + 1); TimingAcquisition.playerMap.get(uid).setChatTimes(TimingAcquisition.playerMap.get(uid).getChatTimes() + 1);
......
...@@ -19,7 +19,7 @@ public class BehaviourDto implements Serializable { ...@@ -19,7 +19,7 @@ public class BehaviourDto implements Serializable {
/** /**
* 行为名称 * 行为名称
*/ */
private String name; // private String name;
/** /**
* 行为id * 行为id
*/ */
...@@ -27,7 +27,7 @@ public class BehaviourDto implements Serializable { ...@@ -27,7 +27,7 @@ public class BehaviourDto implements Serializable {
/** /**
* 行为描述 * 行为描述
*/ */
private String description; // private String description;
/** /**
* 主体 * 主体
*/ */
...@@ -35,7 +35,7 @@ public class BehaviourDto implements Serializable { ...@@ -35,7 +35,7 @@ public class BehaviourDto implements Serializable {
/** /**
* 主体名称 * 主体名称
*/ */
private String subjectName; // private String subjectName;
/** /**
* 客体 * 客体
*/ */
...@@ -43,6 +43,6 @@ public class BehaviourDto implements Serializable { ...@@ -43,6 +43,6 @@ public class BehaviourDto implements Serializable {
/** /**
* 客体名称 * 客体名称
*/ */
private String objectName; // private String objectName;
} }
...@@ -38,7 +38,7 @@ public class ClueDto implements Serializable { ...@@ -38,7 +38,7 @@ public class ClueDto implements Serializable {
/** /**
* 描述 * 描述
*/ */
private String description; // private String description;
/** /**
* 类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9: 关键线索 * 类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9: 关键线索
*/ */
...@@ -54,7 +54,7 @@ public class ClueDto implements Serializable { ...@@ -54,7 +54,7 @@ public class ClueDto implements Serializable {
/** /**
* 线索模板 * 线索模板
*/ */
private String clueTemplate; // private String clueTemplate;
/** /**
* 信任度 * 信任度
...@@ -69,7 +69,7 @@ public class ClueDto implements Serializable { ...@@ -69,7 +69,7 @@ public class ClueDto implements Serializable {
/** /**
* 线索来源 * 线索来源
*/ */
private List<Integer> sourceIdList; // private List<Integer> sourceIdList;
@Override @Override
......
...@@ -31,7 +31,7 @@ public class DemandTaskDto implements Serializable { ...@@ -31,7 +31,7 @@ public class DemandTaskDto implements Serializable {
/** /**
* 描述 * 描述
*/ */
private String description; // private String description;
/** /**
* 主体 * 主体
...@@ -102,7 +102,7 @@ public class DemandTaskDto implements Serializable { ...@@ -102,7 +102,7 @@ public class DemandTaskDto implements Serializable {
/** /**
* 完成反馈 * 完成反馈
*/ */
private String completionFeedback; // private String completionFeedback;
/** /**
* 有效次数 * 有效次数
*/ */
...@@ -124,10 +124,20 @@ public class DemandTaskDto implements Serializable { ...@@ -124,10 +124,20 @@ public class DemandTaskDto implements Serializable {
private int infoLevel; private int infoLevel;
/** /**
* 任务标签 1普通任务 2关键任务 3目标任 * 任务标签 1普通任务 2关键任务 3目标任务
*/ */
private int taskLabel; private int taskLabel;
/**
* 自动触发: 0-不自动触发,1-自动触发
*/
private int isAuto;
/**
* 声望值
*/
private int reputation;
@Override @Override
......
...@@ -27,11 +27,11 @@ public class DispositionDto implements Serializable { ...@@ -27,11 +27,11 @@ public class DispositionDto implements Serializable {
/** /**
* 性格名称 * 性格名称
*/ */
private String name; // private String name;
/** /**
* 性格描述 * 性格描述
*/ */
private String description; // private String description;
/** /**
* 类型 * 类型
*/ */
......
...@@ -5,6 +5,7 @@ import lombok.Setter; ...@@ -5,6 +5,7 @@ import lombok.Setter;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map;
@Getter @Getter
......
...@@ -2,7 +2,23 @@ package com.qiwu.inference.dto; ...@@ -2,7 +2,23 @@ package com.qiwu.inference.dto;
import lombok.Data; import lombok.Data;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Data @Data
public class PersonInfoDto { public class PersonInfoDto {
/**
* 人物编号
*/
private Integer id;
/**
* 人物掌握的线索, Map<线索id, 线索来源>
*/
private Map<Integer, List<Integer>> clueSourceMap = new ConcurrentHashMap<>();
/**
* 人物的需求任务, Map<任务id, 线索开关>
*/
private Map<Integer, Integer> demandTaskSwitchMap = new ConcurrentHashMap<>();
} }
...@@ -63,11 +63,15 @@ public class Player { ...@@ -63,11 +63,15 @@ public class Player {
/** /**
* 人物集合 * 人物集合
*/ */
private Map<Integer,Person> personMap = new HashMap<>(); private Map<Integer, PersonInfoDto> personInfoMap = new HashMap<>();
/** /**
* 人物的姓名和编号转换 map * 人物的姓名和编号转换 map
*/ */
private Map<String,Integer> name2IdMap = new HashMap<>(); private Map<String, Integer> name2IdMap = new HashMap<>();
/**
* 人物的编号和姓名转换 map
*/
private Map<Integer, String> id2NameMap = new HashMap<>();
/** /**
* 当前关卡的货币 * 当前关卡的货币
...@@ -90,7 +94,7 @@ public class Player { ...@@ -90,7 +94,7 @@ public class Player {
/** /**
* 已获得人物线索: Map<人物id, Map<线索类型id, List<线索>>。没有线索则仅仅对话过 * 已获得人物线索: Map<人物id, Map<线索类型id, List<线索>>。没有线索则仅仅对话过
*/ */
private Map<Integer,Map<Integer,List<ClueDto>>> clueMap = new HashMap<>(); private Map<Integer, Map<Integer,List<ClueDto>>> clueMap = new HashMap<>();
/** /**
* 场所表 * 场所表
...@@ -100,12 +104,12 @@ public class Player { ...@@ -100,12 +104,12 @@ public class Player {
/** /**
* 线索集合表 * 线索集合表
*/ */
private List<ClueDto> clues = new ArrayList<>(); // private List<ClueDto> clues = new ArrayList<>();
/** /**
* 已完成任务集合表: Map<人物id, Map<任务id, 任务状态>> * 已完成任务集合表: Map<人物id, Map<任务id, 任务状态>>
*/ */
private Map<Integer,Map<Integer,Integer>> taskMap = new HashMap<>(); private Map<Integer, Map<Integer,Integer>> taskMap = new HashMap<>();
/** /**
* 已完成任务个数 * 已完成任务个数
...@@ -127,6 +131,21 @@ public class Player { ...@@ -127,6 +131,21 @@ public class Player {
*/ */
private int chatTimes = 0; private int chatTimes = 0;
/**
* 记录玩家操作提示的序号
*/
private int operateTextNum = 1;
/**
* 记录玩家询问操作的每个操作对应线索的序号
*/
private Map<String, Integer> askAndNumMap = new HashMap<>();
/**
* 声望值
*/
private int reputation = 0;
// public Player(){ // public Player(){
// //初始化推理游戏人物 // //初始化推理游戏人物
// List<String> keys = new ArrayList<>(TimingAcquisition.gateInfoMap.keySet()); // List<String> keys = new ArrayList<>(TimingAcquisition.gateInfoMap.keySet());
......
...@@ -20,12 +20,12 @@ public class RelationDto implements Serializable { ...@@ -20,12 +20,12 @@ public class RelationDto implements Serializable {
/** /**
* 关系名称 * 关系名称
*/ */
private String name; // private String name;
/** /**
* 关系描述 * 关系描述
*/ */
private String description; // private String description;
/** /**
* 类型 * 类型
......
...@@ -15,8 +15,8 @@ public class ChatSpeech implements Serializable { ...@@ -15,8 +15,8 @@ public class ChatSpeech implements Serializable {
@ApiModelProperty("身份") @ApiModelProperty("身份")
private String identity; private String identity;
@ApiModelProperty("人物ID") @ApiModelProperty("人物名称")
private Integer personId; private String personName;
@ApiModelProperty("性别") @ApiModelProperty("性别")
private String gender; private String gender;
...@@ -33,8 +33,11 @@ public class ChatSpeech implements Serializable { ...@@ -33,8 +33,11 @@ public class ChatSpeech implements Serializable {
@ApiModelProperty("任务状态") @ApiModelProperty("任务状态")
private String taskStatus; private String taskStatus;
@ApiModelProperty("关系") @ApiModelProperty("信任值")
private String degree; private String trust;
@ApiModelProperty("威慑度")
private String deterrence;
@ApiModelProperty("文本内容") @ApiModelProperty("文本内容")
private String answer; private String answer;
......
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;
}
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;
}
...@@ -35,20 +35,33 @@ public class ChatServiceImpl implements ChatService { ...@@ -35,20 +35,33 @@ public class ChatServiceImpl implements ChatService {
String methodId = operationReq.getMethodId(); //方法编号 String methodId = operationReq.getMethodId(); //方法编号
Player player = TimingAcquisition.playerMap.get(uid); Player player = TimingAcquisition.playerMap.get(uid);
//对话人的信息 //对话人的信息
Person current = player.getPersonMap().get(player.getPersonId()); Person current = PlayerUtil.getPersonMap(uid).get(player.getPersonId());
//搭档名称
String partnerName = TimingAcquisition.systemConfigMap.get("partnerName").getValue();
//获取对应话术 //获取对应话术
String text = SpeechUtil.getChatSpeech(uid, current, methodId); String text = SpeechUtil.getChatSpeech(uid, current, methodId);
text = SpeechUtil.addHeader(text, current.getName()); text = SpeechUtil.addHeader(text, current.getName());
//闲聊连续对话次数超过指定次数,任务白名单中有该人已解锁或无需解锁的任务则进行提示 //闲聊连续对话次数超过指定次数,任务白名单中有该人已解锁或无需解锁的任务则进行提示
int chatTimes = Integer.parseInt(TimingAcquisition.systemConfigMap.get("chatTimes").getValue()); int chatTimes = Integer.parseInt(TimingAcquisition.systemConfigMap.get("chatTimes").getValue());
if (player.getChatTimes() >= chatTimes) { if (player.getChatTimes() >= chatTimes - 1) {
//找到白名单内该人的任务中已解锁或无需解锁的任务 //找到白名单内该人的任务中已解锁或无需解锁的任务
String addText = PlayerUtil.getTipInChat(uid, current); String addText = PlayerUtil.getTipInChat(uid, current);
if (!StringUtils.isEmpty(addText)) { if (!StringUtils.isEmpty(addText)) {
addText = "【寒烟@正常】" + addText; addText = SpeechUtil.addHeader(addText, partnerName);
text += addText; 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反馈ID(600101);
resultResponse.set反馈文本(text); resultResponse.set反馈文本(text);
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
......
...@@ -52,6 +52,8 @@ public class CommonService { ...@@ -52,6 +52,8 @@ public class CommonService {
case "1028": case "1028":
case "1029": case "1029":
return playerService.askPrompt(request); return playerService.askPrompt(request);
case "1030":
return playerService.askFinalClue(request);
case "2001": case "2001":
case "2003": case "2003":
case "2002": case "2002":
...@@ -93,6 +95,7 @@ public class CommonService { ...@@ -93,6 +95,7 @@ public class CommonService {
case "2039": case "2039":
case "2040": case "2040":
case "2041": case "2041":
case "2042":
case "2101": case "2101":
case "2102": case "2102":
case "2104": case "2104":
...@@ -100,6 +103,13 @@ public class CommonService { ...@@ -100,6 +103,13 @@ public class CommonService {
case "2107": case "2107":
case "2108": case "2108":
case "2109": case "2109":
case "2043":
case "204301":
case "204302":
case "204303":
case "204304":
case "204305":
case "2044":
return playerService.performTask(request); return playerService.performTask(request);
} }
return null; return null;
......
...@@ -9,4 +9,6 @@ public interface LoginService { ...@@ -9,4 +9,6 @@ public interface LoginService {
CommonResult<ResultVarsResponse> login(String uid); CommonResult<ResultVarsResponse> login(String uid);
CommonResult<ResultVarsResponse> startGame(OperationRequest operationReq); CommonResult<ResultVarsResponse> startGame(OperationRequest operationReq);
CommonResult<ResultVarsResponse> loadPlayerData(String uid);
} }
...@@ -54,6 +54,13 @@ public interface PlayerService { ...@@ -54,6 +54,13 @@ public interface PlayerService {
public CommonResult<ResultVarsResponse> askPrompt(OperationRequest request); public CommonResult<ResultVarsResponse> askPrompt(OperationRequest request);
/** /**
* 询问最终线索
* @param request
* @return
*/
public CommonResult<ResultVarsResponse> askFinalClue(OperationRequest request);
/**
* 执行任务 * 执行任务
* @param request * @param request
* @return * @return
......
This source diff could not be displayed because it is too large. You can view the blob instead.
server:
port: 60019
serlvet:
context-type:/inference
#设置当前服务名
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/inference_brick?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
username: root
password: dgKNTmt2iLHNjEQajkDEZkq8
type: com.alibaba.druid.pool.DruidDataSource
druid:
initial-size: 5
min-idle: 5
max-active: 20
max-wait: 60000
#配置间隔多久才进行一次检测,检测需要关闭的空闲连接
time-between-eviction-runs-millis: 20000
#配置一个连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
#对话过期时间
expireTime: 180000
#玩家无操作时长,默认下线
offlineTime: 180000
speechFilePath: /home/jiaoyou/projects/inferenceBrick/speech/
configFilePath: /home/jiaoyou/projects/inferenceBrick/config/
userFilePath: /home/jiaoyou/projects/inferenceBrick/user/
spring: spring:
profiles: profiles:
active: pro active: dev
\ No newline at end of file \ No newline at end of file
...@@ -10,7 +10,7 @@ aside: ...@@ -10,7 +10,7 @@ aside:
400103: 400103:
- 【旁白@正常】不知道您说的这个地方在哪呢。 - 【旁白@正常】不知道您说的这个地方在哪呢。
400104: 400104:
- 【旁白@正常】这个地方没有你要找的人。 - 【旁白@正常】没有这个地方,换其他地方试试吧,您可以说:我可以去哪里。
400105: 400105:
- 【旁白@正常】你想要去哪里呢?目前已知场所有:【1】。 - 【旁白@正常】你想要去哪里呢?目前已知场所有:【1】。
#4002: 开启对话 #4002: 开启对话
...@@ -19,7 +19,7 @@ aside: ...@@ -19,7 +19,7 @@ aside:
400202: 400202:
- 【旁白@正常】【1】不在这里,现在前往【2】并跟他打招呼好吗? - 【旁白@正常】【1】不在这里,现在前往【2】并跟他打招呼好吗?
400203: 400203:
- 【旁白@正常】没有找到这个人。 - 【旁白@正常】暂时不知道这个人在哪里,你另外找个人吧。
400204: 400204:
- 【旁白@正常】【1】还不知道在什么地方,去打听打听他在哪吧。 - 【旁白@正常】【1】还不知道在什么地方,去打听打听他在哪吧。
#4003: 重试关卡 #4003: 重试关卡
......
...@@ -31,7 +31,7 @@ aside: ...@@ -31,7 +31,7 @@ aside:
300501: 300501:
- 【旁白@正常】您当前已知线索【1】条,请问想要查看关于人物的线索还是不同类型的线索呢? - 【旁白@正常】您当前已知线索【1】条,请问想要查看关于人物的线索还是不同类型的线索呢?
30050101: 30050101:
- 【旁白@正常】您当前还没有获得任何线索,我能给您提供点建议。 - 您当前还没有获得任何线索,我能给您提供点建议。
300502: 300502:
- 【旁白@正常】当前已知人物【1】名:【2】,想要知道哪个人物的相关线索呢?说出他的名称即可。 - 【旁白@正常】当前已知人物【1】名:【2】,想要知道哪个人物的相关线索呢?说出他的名称即可。
30050201: 30050201:
...@@ -39,7 +39,7 @@ aside: ...@@ -39,7 +39,7 @@ aside:
300503: 300503:
- 【旁白@正常】当前已知【1】,想要知晓哪个类型线索呢? - 【旁白@正常】当前已知【1】,想要知晓哪个类型线索呢?
30050301: 30050301:
- 【旁白@正常】您当前还没有收集到线索,我能给您提供点建议。 - 您当前还没有收集到线索,我能给您提供点建议。
300504: 300504:
- 【旁白@正常】【1】已知线索【2】条,其中【3】,想要了解【1】的哪种线索呢? - 【旁白@正常】【1】已知线索【2】条,其中【3】,想要了解【1】的哪种线索呢?
30050401: 30050401:
...@@ -62,17 +62,19 @@ aside: ...@@ -62,17 +62,19 @@ aside:
- 【旁白@正常】您想看什么类型的线索呢? - 【旁白@正常】您想看什么类型的线索呢?
30050605: 30050605:
- 【旁白@正常】没有这种类型的线索哦。 - 【旁白@正常】没有这种类型的线索哦。
30050606:
- 【旁白@正常】【1】的【2】线索共【3】条,第【4】条:【5】
#3006: 询问谁和谁有某个关系 #3006: 询问谁和谁有某个关系
300601: 300601:
- 【旁白@正常】您当前排名积分为:【1】。 - 【旁白@正常】您当前排名积分为:【1】。
#3101: 询问某人的模糊处理操作 #3101: 询问某人的模糊处理操作
310101: 310101:
- 【寒烟@正常】您还没告诉要看谁的呢。 - 【人物名称@正常】您还没告诉要看谁的呢。
310102: 310102:
- 【寒烟@正常】没有您说的这个人哦。 - 【人物名称@正常】没有您说的这个人哦。
310103: 310103:
- 【寒烟@正常】【1】,年龄【2】,性别【3】,身份【4】,其他信息不详。 - 【人物名称@正常】【1】,年龄【2】,性别【3】,身份【4】,其他信息不详。
310104: 310104:
- 【寒烟@正常】【1】,年龄【2】,性别【3】,身份【4】,【5】对你的信任度为:【6】、威慑度为:【7】。 - 【人物名称@正常】【1】,年龄【2】,性别【3】,身份【4】,【5】对你的信任度为:【6】、威慑度为:【7】。
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment