miduo_server/tablemanager/src/main/java/config/SGMMaster.java

76 lines
1.7 KiB
Java
Raw Normal View History

2022-09-14 16:01:44 +08:00
package config;
import manager.STableManager;
import manager.Table;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Table(name ="GMMaster")
public class SGMMaster implements BaseConfig {
private int id;
private int type;
private int[][] price;
private int[][] unlock;
private int packID;
private static Map<Integer, List<SGMMaster>> typeMap = new HashMap<>();
2022-09-14 16:37:19 +08:00
private static Map<Integer, SGMMaster> pickMap = new HashMap<>();
2022-09-14 16:37:19 +08:00
2022-09-14 16:01:44 +08:00
@Override
public void init() throws Exception {
Map<Integer, SGMMaster> config = STableManager.getConfig(SGMMaster.class);
2022-09-14 16:37:19 +08:00
Map<Integer, List<SGMMaster>> map1 = new HashMap<>();
Map<Integer, SGMMaster> map2 = new HashMap<>();
2022-09-14 16:01:44 +08:00
for (SGMMaster master : config.values()) {
2022-09-14 16:37:19 +08:00
List<SGMMaster> list = map1.get(master.getType());
2022-09-14 16:01:44 +08:00
if (list == null){
List<SGMMaster> masters = config.values().stream().filter(v -> v.getType() == master.getType()).collect(Collectors.toList());
2022-09-14 16:37:19 +08:00
map1.put(master.getType(), masters);
2022-09-14 16:01:44 +08:00
}
2022-09-14 16:37:19 +08:00
map2.put(master.getPackID(), master);
2022-09-14 16:01:44 +08:00
}
typeMap.clear();
2022-09-14 16:37:19 +08:00
typeMap = map1;
pickMap.clear();
pickMap = map2;
2022-09-14 16:01:44 +08:00
}
public static Map<Integer, List<SGMMaster>> getTypeMap() {
return typeMap;
}
public static Map<Integer, SGMMaster> getPickMap() {
return pickMap;
2022-09-14 16:37:19 +08:00
}
2022-09-14 16:01:44 +08:00
public int getId() {
return id;
}
public int getType() {
return type;
}
public int[][] getPrice() {
return price;
}
public int[][] getUnlock() {
return unlock;
}
public int getPackID() {
return packID;
}
}