package processing; import entity.World; import java.util.ArrayList; import java.util.List; import java.util.Map; public class WorldController { public static String worldOperation(World world, String varName, String varValue, Map currentInfoPoint, MaphistoryInfoPoint){ String moduleName = "", valuePair[] = varValue.split(":", 2), returnStr=""; String namePair[] = varName.split("_"); boolean operationFlag = true; if (varName.startsWith("NPC_")) moduleName = "NPC"; else if(varName.startsWith("items")) moduleName = "items"; if(varName.startsWith("item_")) { switch (valuePair[0]) { case "addGoodsBase": operationFlag = world.addGoodsBase(namePair[1], namePair[2], valuePair[1]); break; case "deleteGoods": operationFlag = world.deleteGoods(namePair[1], namePair[2]); break; case "queryGoodsIntro": returnStr = world.queryGoodsIntro(varName, historyInfoPoint.get("site")); break; case "queryAttrByGoodsName": String subValuePair[] = currentInfoPoint.get(valuePair[1])[0].split(":", 2); returnStr = world.queryAttrByGoodsName(subValuePair[0], subValuePair[1], historyInfoPoint.get("site")); break; case "queryAllAttrByGoodsName": List attrs = world.queryAllAttrByGoodsName(varName, historyInfoPoint.get("site")); break; case "updateAttrByGoodsName": operationFlag = world.updateAttrByGoodsName(namePair[1], namePair[2], namePair[3], valuePair[1]); break; case "addAttrByGoodsName": operationFlag = world.addAttrByGoodsName(namePair[1], namePair[2], namePair[3], valuePair[1]); break; case "deleteAttrByGoodsName": operationFlag = world.deleteAttrByGoodsName(namePair[1], namePair[2], namePair[3]); break; default: } }else if(varName.startsWith("NPC")) { switch(valuePair[0]){ case "addNpc": operationFlag = world.addNpc(namePair[1], namePair[2], valuePair[1]); break; case "deleteNpc": operationFlag = world.deleteNpc(namePair[1], namePair[2]); break; case "queryNpcIntro": //operationFlag = world.queryNpcIntro(valuePair[1], namePair[2]); break; case "queryAttrByNPCName": String subValuePair[] = currentInfoPoint.get(valuePair[1])[0].split(":", 2); subValuePair[1] = subValuePair[1].replace("哪里", "location"); returnStr = world.queryAttrByNPCName(subValuePair[0], subValuePair[1], historyInfoPoint.get("site")); break; case "updateLocationByNPCName": operationFlag = world.updateLocationByNPCName(namePair[1], namePair[2], namePair[3], ""); break; case "addAttrByNPCName": operationFlag = world.addAttrByNPCName(namePair[1], namePair[2], namePair[3], valuePair[1]); break; case "deleteAttrByNPCName": operationFlag = world.deleteAttrByNPCName(namePair[1], namePair[2], namePair[3]); break; default: } }else if (varName.startsWith("map")){ List sites = new ArrayList<>(); switch(valuePair[0]){ case "queryAroundAllBySite": sites = world.queryAroundAllBySite(historyInfoPoint.get("site")); break; case "queryAroundNpcBySite": sites = world.queryAroundNpcBySite(historyInfoPoint.get("site")); break; case "queryAroundGoodsBySite": sites = world.queryAroundGoodsBySite(historyInfoPoint.get("site")); break; case "queryCanGoBySite": sites = world.queryCanGoBySite(historyInfoPoint.get("site")); break; case "queryPathBySite": sites = world.queryPathBySite(historyInfoPoint.get("site"), valuePair[1]); break; } for(String site: sites){ returnStr += site; } } return returnStr; } }