Commit 89d80ae8 by 李进峰

repair null pointer question!

parent b76cae13
...@@ -23,14 +23,14 @@ public class GameEnv implements Serializable{ ...@@ -23,14 +23,14 @@ public class GameEnv implements Serializable{
// 角色快速查找数据 // 角色快速查找数据
public Map<String, NpcClass> npcClassesMap = new HashMap<String, NpcClass>(); public Map<String, NpcClass> npcClassesMap = new HashMap<String, NpcClass>();
public Map<String, NpcInstance> npcInstancesMap = new HashMap<String, NpcInstance>(); public Map<String, NpcInstance> npcInstancesMap = new HashMap<String, NpcInstance>();
// 玩家跟随的角色列表 // 玩家跟随的角色列表
public Map<String, NpcInstance> followNpcesMap = new HashMap<String, NpcInstance>(); public Map<String, NpcInstance> followNpcesMap = new HashMap<String, NpcInstance>();
// 物品快速查找数据 // 物品快速查找数据
public Map<String, GoodsClass> goodsClassesMap = new HashMap<String, GoodsClass>(); public Map<String, GoodsClass> goodsClassesMap = new HashMap<String, GoodsClass>();
public Map<String, GoodsInstance> goodsInstancesMap = new HashMap<String, GoodsInstance>(); public Map<String, GoodsInstance> goodsInstancesMap = new HashMap<String, GoodsInstance>();
// 全局变量快速查找数据 // 全局变量快速查找数据
public Map<String, String> globalAttrsMap = new HashMap<String, String>(); public Map<String, String> globalAttrsMap = new HashMap<String, String>();
// 地点相关快速查找数据 // 地点相关快速查找数据
...@@ -39,16 +39,16 @@ public class GameEnv implements Serializable{ ...@@ -39,16 +39,16 @@ public class GameEnv implements Serializable{
public Map<String, Place> placeLinkDirectGoesMap = new HashMap<String, Place>(); public Map<String, Place> placeLinkDirectGoesMap = new HashMap<String, Place>();
// goGlag=2 任意可达到 // goGlag=2 任意可达到
public Map<String, Place> placeNoLinkDirectGoesMap = new HashMap<String, Place>(); public Map<String, Place> placeNoLinkDirectGoesMap = new HashMap<String, Place>();
// 二维联通地图 // 二维联通地图
public byte[][] mapUnitMatrix; public byte[][] mapUnitMatrix;
// 联通图助手 // 联通图助手
public Map<String, Integer> placeNameIndexMap = new HashMap<String, Integer>(); public Map<String, Integer> placeNameIndexMap = new HashMap<String, Integer>();
public Map<Integer, String> indexPlaceNameMap = new HashMap<Integer, String>(); public Map<Integer, String> indexPlaceNameMap = new HashMap<Integer, String>();
// 数据别名集合 // 数据别名集合
public Map<String, Nickname> nicknamesMap = new HashMap<String, Nickname>(); public Map<String, Nickname> nicknamesMap = new HashMap<String, Nickname>();
// 获取别名的助手,帮助创建 // 获取别名的助手,帮助创建
private Nickname getNicknameUtil(String nickname) { private Nickname getNicknameUtil(String nickname) {
Nickname nicknameObject = this.nicknamesMap.get(nickname); Nickname nicknameObject = this.nicknamesMap.get(nickname);
...@@ -58,17 +58,17 @@ public class GameEnv implements Serializable{ ...@@ -58,17 +58,17 @@ public class GameEnv implements Serializable{
this.nicknamesMap.put(nickname, nicknameObject); this.nicknamesMap.put(nickname, nicknameObject);
return nicknameObject; return nicknameObject;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public GameEnv(String botName) throws Exception { public GameEnv(String botName) throws Exception {
// 从数据库获取环境数据的json字符串 // 从数据库获取环境数据的json字符串
String jsonString = DBUtil.queryEnvJsonByBotName(botName); String jsonString = DBUtil.queryEnvJsonByBotName(botName);
// 从文件中获取json字符串 // 从文件中获取json字符串
// String jsonString = Util.getJsonString("./data/195.json"); // String jsonString = Util.getJsonString("./data/195.json");
// System.out.println(jsonString); // System.out.println(jsonString);
Map<String, Object> gameProjectMap = JSON.parseObject(jsonString); Map<String, Object> gameProjectMap = JSON.parseObject(jsonString);
if(gameProjectMap!=null && !gameProjectMap.isEmpty()) { if(gameProjectMap!=null && !gameProjectMap.isEmpty()) {
// 地图数据处理 // 地图数据处理
...@@ -88,10 +88,10 @@ public class GameEnv implements Serializable{ ...@@ -88,10 +88,10 @@ public class GameEnv implements Serializable{
this.placeNameIndexMap.put(placeName, new Integer(i)); this.placeNameIndexMap.put(placeName, new Integer(i));
this.indexPlaceNameMap.put(new Integer(i), placeName); this.indexPlaceNameMap.put(new Integer(i), placeName);
} }
// 定义的单位矩阵 // 定义的单位矩阵
this.mapUnitMatrix = new byte[this.placesMap.size()][this.placesMap.size()]; this.mapUnitMatrix = new byte[this.placesMap.size()][this.placesMap.size()];
// 可去地点、别名、图的数据完善 // 可去地点、别名、图的数据完善
for(String placeName:placeTmpMap.keySet()) { for(String placeName:placeTmpMap.keySet()) {
Map<String,Object> placeMap = (Map<String,Object>)placeTmpMap.get(placeName); Map<String,Object> placeMap = (Map<String,Object>)placeTmpMap.get(placeName);
...@@ -111,6 +111,7 @@ public class GameEnv implements Serializable{ ...@@ -111,6 +111,7 @@ public class GameEnv implements Serializable{
// 别名 // 别名
List<String> nicknames = (List<String>)placeMap.get("nicknames"); List<String> nicknames = (List<String>)placeMap.get("nicknames");
for(int i=0; i<nicknames.size(); i++) { for(int i=0; i<nicknames.size(); i++) {
System.out.println(nicknames.get(i));
Nickname nickname = this.getNicknameUtil(nicknames.get(i)); Nickname nickname = this.getNicknameUtil(nicknames.get(i));
Map<String,Place> nicknamePlaceMap = nickname.getPlaceMap(); Map<String,Place> nicknamePlaceMap = nickname.getPlaceMap();
nicknamePlaceMap.put(place.getName(), place); nicknamePlaceMap.put(place.getName(), place);
...@@ -118,7 +119,7 @@ public class GameEnv implements Serializable{ ...@@ -118,7 +119,7 @@ public class GameEnv implements Serializable{
place.setNickname(nicknames); place.setNickname(nicknames);
place.setName(placeName); place.setName(placeName);
} }
// 格式化图显示结构 // 格式化图显示结构
System.out.println("\n\n"); System.out.println("\n\n");
System.out.print("\t\t"); System.out.print("\t\t");
...@@ -134,7 +135,7 @@ public class GameEnv implements Serializable{ ...@@ -134,7 +135,7 @@ public class GameEnv implements Serializable{
System.out.print("\n\n"); System.out.print("\n\n");
} }
} }
/*************************************** 角色 **********************************/ /*************************************** 角色 **********************************/
Map<String, Object> npcDataTmpMap = (Map<String, Object>)gameProjectMap.get("npc"); Map<String, Object> npcDataTmpMap = (Map<String, Object>)gameProjectMap.get("npc");
// 角色类 // 角色类
...@@ -154,7 +155,7 @@ public class GameEnv implements Serializable{ ...@@ -154,7 +155,7 @@ public class GameEnv implements Serializable{
Map<String, String> npcInstanceAttr = (Map<String, String>)npcInstanceTmpMap.get(npcInstanceName); Map<String, String> npcInstanceAttr = (Map<String, String>)npcInstanceTmpMap.get(npcInstanceName);
NpcInstance npcInstance = new NpcInstance(); NpcInstance npcInstance = new NpcInstance();
npcInstance.setName(npcInstanceName); npcInstance.setName(npcInstanceName);
// 角色类 // 角色类
NpcClass npcClass = this.npcClassesMap.get(npcInstanceAttr.get("className")); NpcClass npcClass = this.npcClassesMap.get(npcInstanceAttr.get("className"));
npcInstance.setNpcClass(npcClass); npcInstance.setNpcClass(npcClass);
...@@ -167,7 +168,7 @@ public class GameEnv implements Serializable{ ...@@ -167,7 +168,7 @@ public class GameEnv implements Serializable{
Map<String, NpcInstance> npcInstancesPlaceMap = place.getNpcInstances(); Map<String, NpcInstance> npcInstancesPlaceMap = place.getNpcInstances();
npcInstancesPlaceMap.put(npcInstanceName, npcInstance); npcInstancesPlaceMap.put(npcInstanceName, npcInstance);
npcInstance.setPlace(place); npcInstance.setPlace(place);
// 别名 // 别名
List<String> nicknames = (List<String>)((Map<String, Object>)npcInstanceTmpMap.get(npcInstanceName)).get("nicknames"); List<String> nicknames = (List<String>)((Map<String, Object>)npcInstanceTmpMap.get(npcInstanceName)).get("nicknames");
for(int i=0; i<nicknames.size(); i++) { for(int i=0; i<nicknames.size(); i++) {
...@@ -183,8 +184,8 @@ public class GameEnv implements Serializable{ ...@@ -183,8 +184,8 @@ public class GameEnv implements Serializable{
npcInstance.setAttrs((Map<String, String>)npcInstanceAttr); npcInstance.setAttrs((Map<String, String>)npcInstanceAttr);
this.npcInstancesMap.put(npcInstanceName, npcInstance); this.npcInstancesMap.put(npcInstanceName, npcInstance);
} }
/************************************* 物品 **********************************/ /************************************* 物品 **********************************/
Map<String, Object> goodsDataTmpMap = (Map<String,Object>)gameProjectMap.get("goods"); Map<String, Object> goodsDataTmpMap = (Map<String,Object>)gameProjectMap.get("goods");
// 物品类 // 物品类
...@@ -198,14 +199,14 @@ public class GameEnv implements Serializable{ ...@@ -198,14 +199,14 @@ public class GameEnv implements Serializable{
goodsClass.setAttrs(goodsClassAttr); goodsClass.setAttrs(goodsClassAttr);
this.goodsClassesMap.put(goodsClassName, goodsClass); this.goodsClassesMap.put(goodsClassName, goodsClass);
} }
// 物品实例 // 物品实例
Map<String, Object> goodsInstanceTmpMap = (Map<String, Object>)goodsDataTmpMap.get("instance"); Map<String, Object> goodsInstanceTmpMap = (Map<String, Object>)goodsDataTmpMap.get("instance");
for(String goodsInstanceName:goodsInstanceTmpMap.keySet()){ for(String goodsInstanceName:goodsInstanceTmpMap.keySet()){
Map<String, String> goodsInstanceAttr = (Map<String, String>)goodsInstanceTmpMap.get(goodsInstanceName); Map<String, String> goodsInstanceAttr = (Map<String, String>)goodsInstanceTmpMap.get(goodsInstanceName);
GoodsInstance goodsInstance = new GoodsInstance(); GoodsInstance goodsInstance = new GoodsInstance();
goodsInstance.setName(goodsInstanceName); goodsInstance.setName(goodsInstanceName);
// 物品类 // 物品类
GoodsClass goodsClass = this.goodsClassesMap.get(goodsInstanceAttr.get("className")); GoodsClass goodsClass = this.goodsClassesMap.get(goodsInstanceAttr.get("className"));
goodsInstance.setGoodsClass(goodsClass); goodsInstance.setGoodsClass(goodsClass);
...@@ -218,7 +219,7 @@ public class GameEnv implements Serializable{ ...@@ -218,7 +219,7 @@ public class GameEnv implements Serializable{
Map<String, GoodsInstance> goodsInstancesPlaceMap = place.getGoodsInstances(); Map<String, GoodsInstance> goodsInstancesPlaceMap = place.getGoodsInstances();
goodsInstancesPlaceMap.put(goodsInstanceName, goodsInstance); goodsInstancesPlaceMap.put(goodsInstanceName, goodsInstance);
goodsInstance.setPlace(place); goodsInstance.setPlace(place);
// 别名 // 别名
List<String> nicknames = (List<String>)(((Map<String, Object>)goodsInstanceTmpMap.get(goodsInstanceName)).get("nicknames")); List<String> nicknames = (List<String>)(((Map<String, Object>)goodsInstanceTmpMap.get(goodsInstanceName)).get("nicknames"));
for(int i=0; i<nicknames.size(); i++) { for(int i=0; i<nicknames.size(); i++) {
...@@ -242,7 +243,7 @@ public class GameEnv implements Serializable{ ...@@ -242,7 +243,7 @@ public class GameEnv implements Serializable{
goodsInstance.setAttrs((Map<String, String>)goodsInstanceAttr); goodsInstance.setAttrs((Map<String, String>)goodsInstanceAttr);
this.goodsInstancesMap.put(goodsInstanceName, goodsInstance); this.goodsInstancesMap.put(goodsInstanceName, goodsInstance);
} }
// 全局变量 // 全局变量
this.globalAttrsMap = (Map<String,String>)gameProjectMap.get("globalAttr"); this.globalAttrsMap = (Map<String,String>)gameProjectMap.get("globalAttr");
} }
...@@ -423,24 +424,24 @@ public class GameEnv implements Serializable{ ...@@ -423,24 +424,24 @@ public class GameEnv implements Serializable{
if(place == null) { if(place == null) {
return new Integer(5); return new Integer(5);
} }
// 地点名称相同 // 地点名称相同
if(placeA.equals(placeB)) { if(placeA.equals(placeB)) {
return 0; return 0;
} }
// 地点名和地点别名相同 // 地点名和地点别名相同
if(this.queryNickname(placeB, "place").indexOf(placeA) != -1) { if(this.queryNickname(placeB, "place").indexOf(placeA) != -1) {
return 0; return 0;
} }
// 任意可达 // 任意可达
for(String placeName : this.placeNoLinkDirectGoesMap.keySet()) { for(String placeName : this.placeNoLinkDirectGoesMap.keySet()) {
if(placeName.equals(placeB) || this.queryNickname(placeB, "place").indexOf(placeName) != -1) { if(placeName.equals(placeB) || this.queryNickname(placeB, "place").indexOf(placeName) != -1) {
return 4; return 4;
} }
} }
// 相邻可以去的地点 // 相邻可以去的地点
int x = this.placeNameIndexMap.get(placeA); int x = this.placeNameIndexMap.get(placeA);
for(int y=0; y<this.mapUnitMatrix[x].length; y++) { for(int y=0; y<this.mapUnitMatrix[x].length; y++) {
...@@ -451,7 +452,7 @@ public class GameEnv implements Serializable{ ...@@ -451,7 +452,7 @@ public class GameEnv implements Serializable{
} }
} }
} }
// 联通不相邻可直达 // 联通不相邻可直达
for(String placeName:this.placeLinkDirectGoesMap.keySet()) { for(String placeName:this.placeLinkDirectGoesMap.keySet()) {
if(placeName.equals(placeB) || this.queryNickname(placeB, "place").indexOf(placeName) != -1) { if(placeName.equals(placeB) || this.queryNickname(placeB, "place").indexOf(placeName) != -1) {
...@@ -461,7 +462,7 @@ public class GameEnv implements Serializable{ ...@@ -461,7 +462,7 @@ public class GameEnv implements Serializable{
} }
} }
} }
// 联通不相邻不可以直达 // 联通不相邻不可以直达
for(String placeName:this.placesMap.keySet()) { for(String placeName:this.placesMap.keySet()) {
if(!this.placeLinkDirectGoesMap.keySet().contains(placeName) && !this.placeNoLinkDirectGoesMap.keySet().contains(placeName)) { if(!this.placeLinkDirectGoesMap.keySet().contains(placeName) && !this.placeNoLinkDirectGoesMap.keySet().contains(placeName)) {
...@@ -473,7 +474,7 @@ public class GameEnv implements Serializable{ ...@@ -473,7 +474,7 @@ public class GameEnv implements Serializable{
} }
} }
} }
// 既不相邻,也不能到达 // 既不相邻,也不能到达
return new Integer(5); return new Integer(5);
} }
...@@ -516,7 +517,7 @@ public class GameEnv implements Serializable{ ...@@ -516,7 +517,7 @@ public class GameEnv implements Serializable{
} }
return null; return null;
} }
// 通过别名查询当前地点最近的npc // 通过别名查询当前地点最近的npc
public String getNpcNameByNickname(String curPlaceName, String nickname) { public String getNpcNameByNickname(String curPlaceName, String nickname) {
// 寻找两层 // 寻找两层
...@@ -535,7 +536,7 @@ public class GameEnv implements Serializable{ ...@@ -535,7 +536,7 @@ public class GameEnv implements Serializable{
} }
return nickname; return nickname;
} }
// 通过别名查询当前地点最近的物品 // 通过别名查询当前地点最近的物品
public String getGoodsNameByNickname(String curPlaceName, String nickname) { public String getGoodsNameByNickname(String curPlaceName, String nickname) {
// 寻找两层 // 寻找两层
...@@ -554,7 +555,7 @@ public class GameEnv implements Serializable{ ...@@ -554,7 +555,7 @@ public class GameEnv implements Serializable{
} }
return nickname; return nickname;
} }
/*********************************通过npc获取物品列表**********************************/ /*********************************通过npc获取物品列表**********************************/
// 通过npcName获取所有物品名称列表 // 通过npcName获取所有物品名称列表
public List<String> queryGoodsByNpcName(String npcName){ public List<String> queryGoodsByNpcName(String npcName){
...@@ -601,7 +602,7 @@ public class GameEnv implements Serializable{ ...@@ -601,7 +602,7 @@ public class GameEnv implements Serializable{
return null; return null;
} }
} }
// 查询指定物品的属性值 // 查询指定物品的属性值
public String queryGoodsAttrByGoodsName(String str1, String str2){ public String queryGoodsAttrByGoodsName(String str1, String str2){
GoodsInstance goodsInstance = this.findGoodsInstanceByNameOrNickname(str1); GoodsInstance goodsInstance = this.findGoodsInstanceByNameOrNickname(str1);
...@@ -643,7 +644,7 @@ public class GameEnv implements Serializable{ ...@@ -643,7 +644,7 @@ public class GameEnv implements Serializable{
public String queryGoodsSiteByGoodsName(String goodsName) { public String queryGoodsSiteByGoodsName(String goodsName) {
return this.goodsInstancesMap.get(goodsName).getPlace().getName(); return this.goodsInstancesMap.get(goodsName).getPlace().getName();
} }
/**************************************npc*****************************************/ /**************************************npc*****************************************/
// 通过地点和类查询所有的NPC实例 // 通过地点和类查询所有的NPC实例
public List<String> queryNpcByClassAndSite(String site, String className){ public List<String> queryNpcByClassAndSite(String site, String className){
...@@ -657,7 +658,7 @@ public class GameEnv implements Serializable{ ...@@ -657,7 +658,7 @@ public class GameEnv implements Serializable{
} }
} }
} }
return npcNames; return npcNames;
} }
// 查询指定的NPC // 查询指定的NPC
...@@ -714,69 +715,78 @@ public class GameEnv implements Serializable{ ...@@ -714,69 +715,78 @@ public class GameEnv implements Serializable{
String[] names = name.split("_"); String[] names = name.split("_");
if(names.length == 4){ if(names.length == 4){
if(names[0].equals("goods")){ if(names[0].equals("goods")){
Map<String, GoodsInstance> goodsInstancesByClass = this.goodsClassesMap.get(names[1]).getGoodsInstances(); if(this.goodsClassesMap.get(names[1])!=null) {
GoodsInstance goodsInstance = this.goodsInstancesMap.get(names[2]); Map<String, GoodsInstance> goodsInstancesByClass = this.goodsClassesMap.get(names[1]).getGoodsInstances();
if(goodsInstancesByClass.get(goodsInstance.getName())!=null) { GoodsInstance goodsInstance = this.goodsInstancesMap.get(names[2]);
Map<String, String> goodsInstanceAttrsMap = goodsInstance.getAttrs(); if(goodsInstancesByClass.get(goodsInstance.getName())!=null) {
if(names[3].equals("所在地点")) { Map<String, String> goodsInstanceAttrsMap = goodsInstance.getAttrs();
Place placeOrigin = goodsInstance.getPlace(); if(names[3].equals("所在地点")) {
Map<String, GoodsInstance> goodsInstancesMap = placeOrigin.getGoodsInstances(); Place placeOrigin = goodsInstance.getPlace();
goodsInstancesMap.remove(goodsInstance.getName()); Map<String, GoodsInstance> goodsInstancesMap = placeOrigin.getGoodsInstances();
Place place= this.placesMap.get(value); goodsInstancesMap.remove(goodsInstance.getName());
goodsInstance.setPlace(place); Place place= this.placesMap.get(value);
goodsInstancesMap = place.getGoodsInstances(); goodsInstance.setPlace(place);
goodsInstancesMap.put(goodsInstance.getName(), goodsInstance); goodsInstancesMap = place.getGoodsInstances();
return true; goodsInstancesMap.put(goodsInstance.getName(), goodsInstance);
}else if(names[3].equals("所属角色")) { return true;
NpcInstance npcInstance= goodsInstance.getNpcInstance(); }else if(names[3].equals("所属角色")) {
if(npcInstance != null) { NpcInstance npcInstance= goodsInstance.getNpcInstance();
Map<String, GoodsInstance> goodsInstancesMap = npcInstance.getGoodsInstances(); if(npcInstance != null) {
goodsInstancesMap.remove(goodsInstance.getName()); Map<String, GoodsInstance> goodsInstancesMap = npcInstance.getGoodsInstances();
} goodsInstancesMap.remove(goodsInstance.getName());
npcInstance = this.npcInstancesMap.get(value); }
goodsInstance.setNpcInstance(npcInstance); npcInstance = this.npcInstancesMap.get(value);
Map<String,GoodsInstance> goodsInstances = npcInstance.getGoodsInstances(); goodsInstance.setNpcInstance(npcInstance);
goodsInstances.put(goodsInstance.getName(), goodsInstance); Map<String,GoodsInstance> goodsInstances = npcInstance.getGoodsInstances();
npcInstance.setGoodsInstances(goodsInstances); goodsInstances.put(goodsInstance.getName(), goodsInstance);
return true; npcInstance.setGoodsInstances(goodsInstances);
}else { return true;
goodsInstanceAttrsMap.put(names[3], value); }else {
return true; goodsInstanceAttrsMap.put(names[3], value);
} return true;
}
}else {
return false;
}
}else { }else {
return false; return false;
} }
}else if(names[0].equals("npc")) { }else if(names[0].equals("npc")) {
NpcInstance npcInstance = this.npcInstancesMap.get(names[2]); NpcInstance npcInstance = this.npcInstancesMap.get(names[2]);
if(npcInstance.getNpcClass().getName().equals(names[1])) { if(npcInstance!=null) {
Map<String, String> npcInstanceAttrMap = npcInstance.getAttrs(); if(npcInstance.getNpcClass().getName().equals(names[1])) {
if(names[3].equals("跟随玩家")) { Map<String, String> npcInstanceAttrMap = npcInstance.getAttrs();
if(value.equals("是")) { if(names[3].equals("跟随玩家")) {
this.followNpcesMap.put(npcInstance.getName(), npcInstance); if(value.equals("是")) {
}else if(value.equals("否")) { this.followNpcesMap.put(npcInstance.getName(), npcInstance);
this.followNpcesMap.remove(npcInstance.getName()); }else if(value.equals("否")) {
}else { this.followNpcesMap.remove(npcInstance.getName());
return true; }else {
} return true;
}else if(names[3].equals("所在地点")) { }
Place placeOrigin = npcInstance.getPlace(); }else if(names[3].equals("所在地点")) {
Map<String, NpcInstance> npcInstancesMap = placeOrigin.getNpcInstances(); Place placeOrigin = npcInstance.getPlace();
npcInstancesMap.remove(npcInstance.getName()); Map<String, NpcInstance> npcInstancesMap = placeOrigin.getNpcInstances();
Place place= this.placesMap.get(value); npcInstancesMap.remove(npcInstance.getName());
npcInstance.setPlace(place); Place place= this.placesMap.get(value);
npcInstancesMap = place.getNpcInstances(); npcInstance.setPlace(place);
npcInstancesMap.put(npcInstance.getName(), npcInstance); npcInstancesMap = place.getNpcInstances();
// 更新跟随的NPC物品的位置 npcInstancesMap.put(npcInstance.getName(), npcInstance);
return true; // 更新跟随的NPC物品的位置
}else { return true;
npcInstanceAttrMap.put(names[3], value); }else {
return true; npcInstanceAttrMap.put(names[3], value);
} return true;
}
}else {
return false;
}
}else { }else {
return false; return false;
} }
}else if(names.length == 3 && names[0].equals("place")) { }else if(names.length == 3 && names[0].equals("place")) {
Place place = this.placesMap.get(names[1]); Place place = this.placesMap.get(names[1]);
if(place!=null) {
if(names[2].equals("到达条件")) { if(names[2].equals("到达条件")) {
place.setGoFlag(Integer.parseInt(value)); place.setGoFlag(Integer.parseInt(value));
if(place.getGoFlag().equals(1)) { if(place.getGoFlag().equals(1)) {
...@@ -812,6 +822,9 @@ public class GameEnv implements Serializable{ ...@@ -812,6 +822,9 @@ public class GameEnv implements Serializable{
}else { }else {
return false; return false;
} }
}else {
return false;
}
}else if(names[0].equals("globalVariable")) { }else if(names[0].equals("globalVariable")) {
this.globalAttrsMap.put(names[1], value); this.globalAttrsMap.put(names[1], value);
} }
...@@ -840,6 +853,9 @@ public class GameEnv implements Serializable{ ...@@ -840,6 +853,9 @@ public class GameEnv implements Serializable{
} }
// 查询玩家 // 查询玩家
public String queryPlayerName() { public String queryPlayerName() {
return this.npcClassesMap.get("玩家").getNpcInstances().get(0).getName(); for(String name:this.npcClassesMap.get("玩家").getNpcInstances().keySet()) {
return name;
}
return "";
} }
} }
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