Commit 98a7786c by 赵国君

快速开始

parent 04bd4be9
package com.qiwu.chatbotbackend.GameEnvironment;
public class Test {
public static void main(String[] args) throws Exception {
GameEnv gameEnv = new GameEnv("7011489633");
// System.out.println(gameEnv.queryNpcAttrByNpcName("武士", "热度"));
System.out.println(gameEnv.queryGlobalAttr("啦啦"));
}
}
......@@ -52,16 +52,17 @@ public class PlotConstructor2 extends ElementConstructor {
}
public void construct(JSONObject jsonObject, UserInfo userinfo) {
Integer startOption = jsonObject.getInteger("startOption");
try {
if(startOption != null && startOption.equals(2)) {
} else {
addGameStartPlot(jsonObject, keywordMap);
}
JSONArray plots = jsonObject.getJSONArray("plots");
String start = (String) jsonObject.get("start"), startCondition;
JSONObject returnMessage = null;
this.plots = plots;
constructAdjList(plots);
......@@ -737,10 +738,7 @@ public class PlotConstructor2 extends ElementConstructor {
jsonStr = jsonStr.replace("startId", gameElements.getString("start"));
jsonStr = jsonStr.replace("site_list", keywordMap.get("site_list").toString());
//System.out.println("JSONSTR ------------------------------\n" + jsonStr);
JSONObject config = JSONObject.parseObject(jsonStr);
gameElements.getJSONArray("plots").addAll(config.getJSONArray("gameStart"));
gameElements.put("start", "start1");
gameElements.put("firstUnknownText", GAME_START_HINT);
......
......@@ -168,9 +168,6 @@ public class GameDesignServlet extends HttpServlet {
jsonList.add(json);
}
helper.batchInsertConfigByBotId(botId, jsonList, idList, categoryMap.get(moduleName2));
constructor.postProcessing(idList, categoryMap.get(moduleName2));
constructor.generateConfigText(idList);
......@@ -189,23 +186,12 @@ public class GameDesignServlet extends HttpServlet {
}
if(returnStatus == 1) {
// ldt = LocalDateTime.now();
// now = ldt.format(dtf);
// timeUsedDetect.append("\n发送post请求预处理:").append(now);
StringReader sr = new StringReader(mergedConfigText.toString());
BufferedReader br = new BufferedReader(sr);
//System.out.println(mergedConfigText.toString());
UserInfoController.buildUserInfo(br, userinfo, true);
context.setAttribute(botAccount, userinfo);
UserInfoController.writeConfigText(botAccount, userinfo);
// ldt = LocalDateTime.now();
// now = ldt.format(dtf);
// timeUsedDetect.append("\n发送post请求前:").append(now);
IntervalStatus generateResult = actionRegenerate(root, gameElements, userinfo, additionalKeywords, exceptRelation, POS, helper);
// ldt = LocalDateTime.now();
// now = ldt.format(dtf);
// timeUsedDetect.append("\n发送post请求后:").append(now);
UserInfoController.writeConfigText(botAccount, userinfo);
if(generateResult.getStatus() != 1){
returnStatus = 0;
......@@ -282,6 +268,7 @@ public class GameDesignServlet extends HttpServlet {
public IntervalStatus actionRegenerate(JSONObject root, JSONObject gameElements, UserInfo userInfo, HashMap<String, HashSet<String>> additionalKeywords, HashSet<String> exceptRelation, StringBuffer POS, SqlHelper helper){
String startCondition, POS2 = "", botName = gameElements.getString("botName");
System.out.println(botName);
Integer startOption = gameElements.getInteger("startOption");
JSONObject returnMessage = null;
EngineUtils engine = null;
IntervalStatus intervalStatus = new IntervalStatus(1, "");
......@@ -290,7 +277,11 @@ public class GameDesignServlet extends HttpServlet {
startCondition = (String)root.get("conditionName");
actionPostData.put("startCondition", "start_options");
actionPostData.put("welcome", String.format(GAME_WELCOME_TEXT, gameElements.getString("botName")));
if(startOption != null && startOption.equals(2)) {
actionPostData.put("welcome", gameElements.getString("plotStartText"));
} else {
actionPostData.put("welcome", String.format(GAME_WELCOME_TEXT, botName));
}
actionPostData.put("relationKeywords", additionalKeywords);
actionPostData.put("botId", gameElements.getInteger("botId"));
......
package com.qiwu.chatbotbackend.servlet;
import com.alibaba.fastjson.JSONObject;
import com.qiwu.chatbotbackend.actiongenerate.DB.EngineUtils;
import com.qiwu.chatbotbackend.entity.Action;
import com.qiwu.chatbotbackend.entity.ChatCache;
import com.qiwu.chatbotbackend.entity.Solution;
......@@ -17,6 +18,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
......@@ -44,11 +46,29 @@ public class GetAnswerServlet extends HttpServlet {
if(tmpStr == null || tmpStr.equals(""))
continue;
tmpStr = tmpStr.replace("qiwu", "我");
//tmpStr = tmpStr.replace("qiwu", "你");
receiveParamters.put(entry.getKey(), tmpStr);
}
}
String botName = receiveParamters.get("bot_name");
/*
EngineUtils engineDBConn = null;
try {
engineDBConn = new EngineUtils();
String nickname = engineDBConn.queryBotNickNameByName(botName);
} catch (SQLException e1) {
e1.printStackTrace();
} finally {
engineDBConn.destroy();
}
Set<Entry<String, String>> entrySet2 = receiveParamters.entrySet();
for(Entry<String, String> entry : entrySet2) {
String value = entry.getValue();
if(value.indexOf("")) {
}
}
*/
Map<String ,String> curInfoPoint = new HashMap<String, String>();
Solution bestMatch = null;
......
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