加载静态数据表
parent
1409e0292f
commit
270ba601d9
|
@ -48,6 +48,7 @@ public class GameApplication {
|
||||||
ServerConfiguration serverConfiguration = configurableApplicationContext.getBean(ServerConfiguration.class);
|
ServerConfiguration serverConfiguration = configurableApplicationContext.getBean(ServerConfiguration.class);
|
||||||
serverProperties = serverConfiguration.getServerProperties();
|
serverProperties = serverConfiguration.getServerProperties();
|
||||||
serverId = serverProperties.getId();
|
serverId = serverProperties.getId();
|
||||||
|
LOGGER.info("ServerProperties ->{},coreIp=>{}", serverProperties.toString());
|
||||||
//注册消息处理方法
|
//注册消息处理方法
|
||||||
ProtocolsManager protocolsManager = ProtocolsManager.getInstance();
|
ProtocolsManager protocolsManager = ProtocolsManager.getInstance();
|
||||||
// protocolsManager.initContext();
|
// protocolsManager.initContext();
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.ljsd.jieling.logic.Table;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Table(name = "s_c_map")
|
@Table(name = "1.Map")
|
||||||
public class SCMap implements BaseConfig {
|
public class SCMap implements BaseConfig {
|
||||||
public static Map<Integer, Map<Integer, SCMap>> sCMap;
|
public static Map<Integer, Map<Integer, SCMap>> sCMap;
|
||||||
private int id;
|
private int id;
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import com.ljsd.jieling.logic.Table;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Table(name = "s_c_map_event")
|
@Table(name = "2.MapEventsConfig")
|
||||||
public class SCMapEvent implements BaseConfig{
|
public class SCMapEvent implements BaseConfig{
|
||||||
|
|
||||||
public static Map<Integer, SCMapEvent> scMapEventMap;
|
public static Map<Integer, SCMapEvent> scMapEventMap;
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,6 +16,8 @@ public class ServerProperties {
|
||||||
|
|
||||||
private int isLAN;
|
private int isLAN;
|
||||||
|
|
||||||
|
private String openTime;
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +50,14 @@ public class ServerProperties {
|
||||||
this.isLAN = isLAN;
|
this.isLAN = isLAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getOpenTime() {
|
||||||
|
return openTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpenTime(String openTime) {
|
||||||
|
this.openTime = openTime;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ServerProperties{" +
|
return "ServerProperties{" +
|
||||||
|
@ -55,6 +65,7 @@ public class ServerProperties {
|
||||||
", plat='" + plat + '\'' +
|
", plat='" + plat + '\'' +
|
||||||
", channel='" + channel + '\'' +
|
", channel='" + channel + '\'' +
|
||||||
", isLAN=" + isLAN +
|
", isLAN=" + isLAN +
|
||||||
|
", openTime=" + openTime +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,6 +92,9 @@ public class STableManager {
|
||||||
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
|
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
|
||||||
LOGGER.info("initMap:{}", clazz.getSimpleName());
|
LOGGER.info("initMap:{}", clazz.getSimpleName());
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
|
if (line.isEmpty()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
T obj = clazz.newInstance();
|
T obj = clazz.newInstance();
|
||||||
String[] prarms = line.split("\\t");
|
String[] prarms = line.split("\\t");
|
||||||
switch (lineNum) {
|
switch (lineNum) {
|
||||||
|
@ -124,7 +127,7 @@ public class STableManager {
|
||||||
int mapType = 101;
|
int mapType = 101;
|
||||||
for (int i = 101; i < 1000; i++) {
|
for (int i = 101; i < 1000; i++) {
|
||||||
Map<Integer, T> mapConf = new HashMap<>();
|
Map<Integer, T> mapConf = new HashMap<>();
|
||||||
tableName = tableName + i;
|
tableName = tableName + "_"+ i;
|
||||||
String path = SysUtil.getPath("conf", "server", tableName + ".txt");
|
String path = SysUtil.getPath("conf", "server", tableName + ".txt");
|
||||||
File file = new File(path);
|
File file = new File(path);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
|
@ -156,7 +159,7 @@ public class STableManager {
|
||||||
lineNum++;
|
lineNum++;
|
||||||
}
|
}
|
||||||
map.put(i, mapConf);
|
map.put(i, mapConf);
|
||||||
tableName = tableName.substring(0, 7);
|
tableName = tableName.substring(0, 5);
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +168,7 @@ public class STableManager {
|
||||||
* 处理参数
|
* 处理参数
|
||||||
*/
|
*/
|
||||||
private static <T> void dealParams(Class<T> clazz, Map<Integer, T> map, List<String> key, List<String> type, T obj, String[] prarms) throws NoSuchFieldException, IllegalAccessException {
|
private static <T> void dealParams(Class<T> clazz, Map<Integer, T> map, List<String> key, List<String> type, T obj, String[] prarms) throws NoSuchFieldException, IllegalAccessException {
|
||||||
int id = Integer.parseInt(prarms[0]);
|
int id = Integer.parseInt(prarms[0]);
|
||||||
for (int i = 0; i < prarms.length; i++) {
|
for (int i = 0; i < prarms.length; i++) {
|
||||||
try {
|
try {
|
||||||
Field field = clazz.getDeclaredField(key.get(i));
|
Field field = clazz.getDeclaredField(key.get(i));
|
||||||
|
|
Loading…
Reference in New Issue