diff --git a/src/main/java/com/qiwu/chatbotbackend/processing/WorldController.java b/src/main/java/com/qiwu/chatbotbackend/processing/WorldController.java index 82fac71..b49999a 100644 --- a/src/main/java/com/qiwu/chatbotbackend/processing/WorldController.java +++ b/src/main/java/com/qiwu/chatbotbackend/processing/WorldController.java @@ -23,7 +23,7 @@ public class WorldController { public String worldOperation(GameEnv gameEnv, String varName, String varValue, Map currentInfoPoint, MaphistoryInfoPoint){ String moduleName = "", valuePair[] = varValue.split(":", 2), returnStr="", owner; - String namePair[] = varName.split("_"); + String namePair[] = varName.split("_"), dontFound = "", nothingFound; boolean operationFlag = true; List textList = null; String subValuePair[] = null; @@ -31,11 +31,26 @@ public class WorldController { logWriter.record(String.format("---------------------key:%s, value:%s", varName, varValue), 0); + if(userInfo.varInitialMap.get("DONT_FOUND") != null){ + dontFound = userInfo.varInitialMap.get("DONT_FOUND"); + }else{ + dontFound = DONT_FOUND; + } + + if(userInfo.varInitialMap.get("NOTHING_FOUND") != null){ + nothingFound = userInfo.varInitialMap.get("NOTHING_FOUND"); + }else{ + nothingFound = DONT_FOUND; + } + + String location = "", value = ""; if(valuePair[0].startsWith("query")){ //查询专用 String itemName = ""; String currentLocation; + + if(varName.startsWith("goods_")) { currentLocation = historyInfoPoint.get("site"); switch (valuePair[0]) { @@ -48,7 +63,7 @@ public class WorldController { itemName = currentInfoPoint.get(valuePair[1]).split(":", 2)[1]; returnStr = gameEnv.queryGoodsIntroByGoodsName(itemName); if(returnStr == null ) - returnStr = DONT_FOUND; + returnStr = dontFound; else{ returnStr = format.replace(ITEM_NAME_SLOT, itemName).replace(ATTR_VALUE_SLOT, returnStr); } @@ -60,7 +75,7 @@ public class WorldController { value = gameEnv.queryGoodsAttrByGoodsName(subValuePair[0], subValuePair[1]); if(returnStr == null) { - returnStr = DONT_FOUND; + returnStr = dontFound; }else{ returnStr = userInfo.varInitialMap.get("GET_ITEM_ATTR").replace(ITEM_NAME_SLOT, subValuePair[0]).replace(ATTR_NAME_SLOT, subValuePair[1]).replace(ATTR_VALUE_SLOT, value); @@ -69,7 +84,7 @@ public class WorldController { case "queryAllAttrByGoodsName": textList = gameEnv.queryGoodsAllAttrByGoodsName(varName); if(textList == null || textList.size() == 0) - returnStr = DONT_FOUND; + returnStr = dontFound; else { for (String site : textList) returnStr += "、" + site; @@ -79,7 +94,7 @@ public class WorldController { case "queryAroundGoodsByClassName": textList = gameEnv.queryGoodsByClassAndSite(namePair[1], historyInfoPoint.get("site")); if(textList == null || textList.size() == 0) - returnStr = DONT_FOUND; + returnStr = dontFound; else { for (String site : textList) returnStr += "、" + site; @@ -97,7 +112,7 @@ public class WorldController { } else if(returnStr.equals("是")){ location = gameEnv.queryGoodsAttrByGoodsName(itemName, "location"); if(location == null){ - returnStr = DONT_FOUND; + returnStr = dontFound; }else{ owner = gameEnv.queryGoodsAttrByGoodsName(itemName, "owner"); //logWriter.record(ItemName + "-owner:" + owner, 0); @@ -124,7 +139,7 @@ public class WorldController { String player = gameEnv.queryPlayerName(); textList = gameEnv.queryGoodsByNpcName(player); if(textList == null || textList.size() == 0) - returnStr = NOTHING_FOUND; + returnStr = nothingFound; else { for (String site : textList) returnStr += "、" + site; @@ -140,11 +155,11 @@ public class WorldController { itemName = currentInfoPoint.get(valuePair[1]).split(":")[1]; returnStr = gameEnv.queryGoodsAttrByGoodsName(itemName, "可被询问"); if(returnStr == null || returnStr.equals("否")){ - returnStr = DONT_FOUND; + returnStr = dontFound; } else if(returnStr.equals("是")){ location = gameEnv.queryGoodsAttrByGoodsName(itemName, "location"); if(location == null){ - returnStr = DONT_FOUND; + returnStr = dontFound; }else{ returnStr = userInfo.varInitialMap.get("FIND_ITEM_WAY").replace(ITEM_NAME_SLOT, itemName).replace(SITE_SLOT, location); } @@ -165,7 +180,7 @@ public class WorldController { NPCName = currentInfoPoint.get(valuePair[1]).split(":", 2)[1]; returnStr = gameEnv.queryNpcIntroByNpcName(NPCName); if(returnStr == null ) - returnStr = DONT_FOUND; + returnStr = dontFound; else{ returnStr = format.replace(NPC_NAME_SLOT, NPCName).replace(ATTR_VALUE_SLOT, returnStr); } @@ -178,7 +193,7 @@ public class WorldController { subValuePair[0] = subValuePair[0].replace("哪里", "location"); value = gameEnv.queryNpcAttrByNpcName(subValuePair[0], subValuePair[1]); if(value == null) { - returnStr = DONT_FOUND; + returnStr = dontFound; }else{ returnStr = userInfo.varInitialMap.get("GET_NPC_ATTR").replace(NPC_NAME_SLOT, subValuePair[0]).replace(ATTR_NAME_SLOT, subValuePair[1]).replace(ATTR_VALUE_SLOT, value); @@ -191,7 +206,7 @@ public class WorldController { location = gameEnv.queryNpcAttrByNpcName(valuePair[1], "location"); if(location == null){ - returnStr = DONT_FOUND; + returnStr = dontFound; }else{ returnStr = location; } @@ -205,13 +220,13 @@ public class WorldController { System.out.println(NPCName); returnStr = gameEnv.queryNpcAttrByNpcName(NPCName, "可被询问"); if(returnStr == null || returnStr.equals("否")){ - returnStr = DONT_FOUND; + returnStr = dontFound; } else if(returnStr.equals("是")){ location = gameEnv.queryNpcAttrByNpcName(NPCName, "location"); if(location == null){ - returnStr = DONT_FOUND; + returnStr = dontFound; }else{ returnStr = userInfo.varInitialMap.get("FIND_NPC_LOCATION").replace(NPC_NAME_SLOT, NPCName).replace(SITE_SLOT2, location); } @@ -224,11 +239,11 @@ public class WorldController { NPCName = currentInfoPoint.get(valuePair[1]).split(":")[1]; returnStr = gameEnv.queryNpcAttrByNpcName(NPCName, "可被询问"); if(returnStr == null || returnStr.equals("否")){ - returnStr = DONT_FOUND; + returnStr = dontFound; } else if(returnStr.equals("是")){ location = gameEnv.queryNpcAttrByNpcName(NPCName, "location"); if(location == null){ - returnStr = DONT_FOUND; + returnStr = dontFound; }else{ returnStr = userInfo.varInitialMap.get("FIND_NPC_WAY").replace(NPC_NAME_SLOT, NPCName).replace(SITE_SLOT2, location); } @@ -264,7 +279,7 @@ public class WorldController { sites = gameEnv.queryAroundAllBySite(historyInfoPoint.get("site")); if(sites == null || sites.size() == 0) - returnStr = NOTHING_FOUND; + returnStr = nothingFound; else { StringBuffer text = new StringBuffer(); @@ -282,7 +297,7 @@ public class WorldController { sites = gameEnv.queryAroundNpcBySite(historyInfoPoint.get("site")); if(sites == null || sites.size() == 0) - returnStr = NOTHING_FOUND; + returnStr = nothingFound; else { StringBuffer text = new StringBuffer(); @@ -300,7 +315,7 @@ public class WorldController { sites = gameEnv.queryAroundGoodsBySite(historyInfoPoint.get("site")); if(sites == null || sites.size() == 0) - returnStr = NOTHING_FOUND; + returnStr = nothingFound; else { if(sites.size() > 0) { StringBuffer text = new StringBuffer(); @@ -414,7 +429,7 @@ public class WorldController { sites = gameEnv.queryAroundNpcBySite(historyInfoPoint.get("site")); if(sites == null || sites.size() == 0) - returnStr = NOTHING_FOUND; + returnStr = nothingFound; else { StringBuffer text = new StringBuffer(); @@ -453,7 +468,7 @@ public class WorldController { sites = gameEnv.queryAroundGoodsBySite(destination); if(sites == null || sites.size() == 0) - returnStr = NOTHING_FOUND; + returnStr = nothingFound; else { if(sites.size() > 0) { StringBuffer text = new StringBuffer(); @@ -474,7 +489,7 @@ public class WorldController { destination = currentInfoPoint.get(valuePair[1]).split(":")[0]; sites = gameEnv.queryAroundNpcBySite(destination); if(sites == null || sites.size() == 0) - returnStr = NOTHING_FOUND; + returnStr = nothingFound; else { StringBuffer text = new StringBuffer(); @@ -497,7 +512,7 @@ public class WorldController { sites = gameEnv.queryAroundAllBySite(destination); if(sites == null || sites.size() == 0) - returnStr = NOTHING_FOUND; + returnStr = nothingFound; else { StringBuffer text = new StringBuffer();