加载静态数据表

back_recharge
gaojie 2019-01-09 17:52:01 +08:00
parent 1409e0292f
commit 270ba601d9
7 changed files with 61 additions and 50 deletions

View File

@ -48,6 +48,7 @@ public class GameApplication {
ServerConfiguration serverConfiguration = configurableApplicationContext.getBean(ServerConfiguration.class);
serverProperties = serverConfiguration.getServerProperties();
serverId = serverProperties.getId();
LOGGER.info("ServerProperties ->{},coreIp=>{}", serverProperties.toString());
//注册消息处理方法
ProtocolsManager protocolsManager = ProtocolsManager.getInstance();
// protocolsManager.initContext();

View File

@ -6,7 +6,7 @@ import com.ljsd.jieling.logic.Table;
import java.util.Map;
@Table(name = "s_c_map")
@Table(name = "1.Map")
public class SCMap implements BaseConfig {
public static Map<Integer, Map<Integer, SCMap>> sCMap;
private int id;

View File

@ -0,0 +1,41 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.Map;
@Table(name = "1.MapConfig")
public class SCMapConfig implements BaseConfig {
public static Map<Integer, SCMapConfig> sCMapSize;
private int id;
private String info;
private int[] size; // 0:行 1列
private int confused; //地图消耗
private String openRule; // 开启条件
@Override
public void init() throws Exception {
sCMapSize = STableManager.getConfig(SCMapConfig.class);
}
public int getId() {
return id;
}
public String getInfo() {
return info;
}
public int[] getSize() {
return size;
}
public int getConfused() {
return confused;
}
public String getOpenRule() {
return openRule;
}
}

View File

@ -5,7 +5,7 @@ import com.ljsd.jieling.logic.Table;
import java.util.Map;
@Table(name = "s_c_map_event")
@Table(name = "2.MapEventsConfig")
public class SCMapEvent implements BaseConfig{
public static Map<Integer, SCMapEvent> scMapEventMap;

View File

@ -1,45 +0,0 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.HashMap;
import java.util.Map;
@Table(name = "s_c_map_size")
public class SCMapSize implements BaseConfig {
public Map<Integer, SCMapSize> sCMapSize;
public Map<Integer, SCMapSize> sCardMapSizeById;
private int id;
private int length;
private int width;
@Override
public void init() throws Exception {
sCMapSize = STableManager.getConfig(SCMapSize.class);
sCardMapSizeById = new HashMap<>();
for (Map.Entry<Integer, SCMapSize> entry : sCMapSize.entrySet()) {
sCardMapSizeById.put(entry.getValue().getId(), entry.getValue());
}
}
public int getId() {
return id;
}
public Map<Integer, SCMapSize> getsCMapSize() {
return sCMapSize;
}
public Map<Integer, SCMapSize> getsCardMapSizeById() {
return sCardMapSizeById;
}
public int getLength() {
return length;
}
public int getWidth() {
return width;
}
}

View File

@ -16,6 +16,8 @@ public class ServerProperties {
private int isLAN;
private String openTime;
public int getId() {
return id;
}
@ -48,6 +50,14 @@ public class ServerProperties {
this.isLAN = isLAN;
}
public String getOpenTime() {
return openTime;
}
public void setOpenTime(String openTime) {
this.openTime = openTime;
}
@Override
public String toString() {
return "ServerProperties{" +
@ -55,6 +65,7 @@ public class ServerProperties {
", plat='" + plat + '\'' +
", channel='" + channel + '\'' +
", isLAN=" + isLAN +
", openTime=" + openTime +
'}';
}
}

View File

@ -92,6 +92,9 @@ public class STableManager {
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
LOGGER.info("initMap:{}", clazz.getSimpleName());
while ((line = bufferedReader.readLine()) != null) {
if (line.isEmpty()){
continue;
}
T obj = clazz.newInstance();
String[] prarms = line.split("\\t");
switch (lineNum) {
@ -124,7 +127,7 @@ public class STableManager {
int mapType = 101;
for (int i = 101; i < 1000; i++) {
Map<Integer, T> mapConf = new HashMap<>();
tableName = tableName + i;
tableName = tableName + "_"+ i;
String path = SysUtil.getPath("conf", "server", tableName + ".txt");
File file = new File(path);
if (!file.exists()) {
@ -156,7 +159,7 @@ public class STableManager {
lineNum++;
}
map.put(i, mapConf);
tableName = tableName.substring(0, 7);
tableName = tableName.substring(0, 5);
}
return map;
}