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

106 lines
3.7 KiB
Java
Raw Normal View History

package config;
import manager.STableManager;
import manager.Table;
import java.util.HashMap;
import java.util.Map;
@Table(name ="DifferDemonsComonpentsConfig")
public class SDifferDemonsComonpentsConfig implements BaseConfig {
private int id;
private int comonpentsId;
private int stage;
private int[][] cost;
private int[][] baseAttribute;
private int[][] extraAdd;
private Map<Integer,Map<Integer,Integer>> extraAddMap;
private static Map<Integer,Map<Integer,SDifferDemonsComonpentsConfig>> sDifferDemonsComonpentsConfig;
@Override
public void init() throws Exception {
Map<Integer,Map<Integer,SDifferDemonsComonpentsConfig>> sDifferDemonsComonpentsConfigTmp = new HashMap<>();
Map<Integer,Map<Integer,Map<Integer,Integer>>> extraAddMapTmp = new HashMap<>();
Map<Integer, SDifferDemonsComonpentsConfig> config = STableManager.getConfig(SDifferDemonsComonpentsConfig.class);
for(SDifferDemonsComonpentsConfig sDifferDemonsComonpentsConfig : config.values()){
int comonpentsId = sDifferDemonsComonpentsConfig.getComonpentsId();
int stage = sDifferDemonsComonpentsConfig.getStage();
if(!sDifferDemonsComonpentsConfigTmp.containsKey(comonpentsId)){
sDifferDemonsComonpentsConfigTmp.put(comonpentsId,new HashMap<>());
extraAddMapTmp.put(comonpentsId,new HashMap<>());
}
int[][] extraAdd = sDifferDemonsComonpentsConfig.getExtraAdd();
2019-10-29 14:56:37 +08:00
Map<Integer, Map<Integer, Integer>> extraMapTmpInfo = extraAddMapTmp.get(comonpentsId);
HashMap<Integer, Map<Integer, Integer>> extraCopyMapHashMap = new HashMap<>(extraMapTmpInfo);
if(extraAdd!=null&&extraAdd.length>0){
for(int [] extraItem : extraAdd){
int profession = extraItem[0];
int propertyId = extraItem[1];
int propertyValue = extraItem[2];
if(!extraMapTmpInfo.containsKey(profession)){
extraMapTmpInfo.put(profession,new HashMap<>());
}
2019-10-29 14:56:37 +08:00
if(extraMapTmpInfo.get(profession).containsKey(propertyId)){
propertyValue+=extraMapTmpInfo.get(profession).get(propertyId);
}
extraCopyMapHashMap.put(profession,new HashMap<>());
extraMapTmpInfo.put(profession,new HashMap<>());
extraCopyMapHashMap.get(profession).put(propertyId,propertyValue);
extraMapTmpInfo.get(profession).put(propertyId,propertyValue);
2019-10-29 14:56:37 +08:00
}
}
2019-10-29 14:56:37 +08:00
sDifferDemonsComonpentsConfig.setExtraAddMap(extraCopyMapHashMap);
sDifferDemonsComonpentsConfigTmp.get(comonpentsId).put(stage,sDifferDemonsComonpentsConfig);
}
sDifferDemonsComonpentsConfig = sDifferDemonsComonpentsConfigTmp;
}
public static Map<Integer,SDifferDemonsComonpentsConfig> getsDifferDemonsComonpentsConfigMap(int comonpentId) {
return sDifferDemonsComonpentsConfig.get(comonpentId);
}
public int getId() {
return id;
}
public int getComonpentsId() {
return comonpentsId;
}
public int getStage() {
return stage;
}
public int[][] getCost() {
return cost;
}
public int[][] getBaseAttribute() {
return baseAttribute;
}
public int[][] getExtraAdd() {
return extraAdd;
}
public Map<Integer, Map<Integer, Integer>> getExtraAddMap() {
return extraAddMap;
}
public void setExtraAddMap(Map<Integer, Map<Integer, Integer>> extraAddMap) {
this.extraAddMap = extraAddMap;
}
}