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

76 lines
1.7 KiB
Java

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<>();
private static Map<Integer, SGMMaster> pickMap = new HashMap<>();
@Override
public void init() throws Exception {
Map<Integer, SGMMaster> config = STableManager.getConfig(SGMMaster.class);
Map<Integer, List<SGMMaster>> map1 = new HashMap<>();
Map<Integer, SGMMaster> map2 = new HashMap<>();
for (SGMMaster master : config.values()) {
List<SGMMaster> list = map1.get(master.getType());
if (list == null){
List<SGMMaster> masters = config.values().stream().filter(v -> v.getType() == master.getType()).collect(Collectors.toList());
map1.put(master.getType(), masters);
}
map2.put(master.getPackID(), master);
}
typeMap.clear();
typeMap = map1;
pickMap.clear();
pickMap = map2;
}
public static Map<Integer, List<SGMMaster>> getTypeMap() {
return typeMap;
}
public static Map<Integer, SGMMaster> getPickMap() {
return pickMap;
}
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;
}
}