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

85 lines
2.6 KiB
Java

package config;
import manager.STableManager;
import manager.Table;
import java.util.HashMap;
import java.util.Map;
@Table(name="EndlessDifficulty")
public class SEndlessDifficulty implements BaseConfig{
private int id;
private int[] worldLevel;
private int[] monsterId;
private int[] rewardId;
private int mapPool;
public static Map<Integer, Map<Integer,Integer>> mapDifficult= new HashMap<>();
public static Map<Integer,Map<Integer,Integer>> mapMonsterDifficult = new HashMap<>();
public static Map<Integer,Map<Integer,Integer>> mapRewardDifficult = new HashMap<>();
@Override
public void init() throws Exception {
Map<Integer, SEndlessDifficulty> configMap = STableManager.getConfig(SEndlessDifficulty.class);
Map<Integer, Map<Integer,Integer>> mapDifficultTemp = new HashMap<>();
Map<Integer, Map<Integer,Integer>> mapMonsterDifficultTemp = new HashMap<>();
Map<Integer, Map<Integer,Integer>> mapRewardDifficultTemp = new HashMap<>();
for(Map.Entry<Integer, SEndlessDifficulty> entry:configMap.entrySet()){
int mapPool = entry.getValue().getMapPool();
if(!mapDifficultTemp.containsKey(mapPool)){
mapDifficultTemp.put(mapPool,new HashMap<>());
}
int[] worldLevel = entry.getValue().getWorldLevel();
for(int i = worldLevel[0];i<worldLevel[1];i++){
if(i ==0){
Map<Integer,Integer> monsterMap = new HashMap<>();
Map<Integer,Integer> rewardMap = new HashMap<>();
for(int j=0;j<entry.getValue().getMonsterId().length;j++){
monsterMap.put(entry.getValue().getMonsterId()[j],j);
}
for(int j=0;j<entry.getValue().getRewardId().length;j++){
rewardMap.put(entry.getValue().getRewardId()[j],j);
}
mapMonsterDifficultTemp.put(mapPool,monsterMap);
mapRewardDifficultTemp.put(mapPool,rewardMap);
}
mapDifficultTemp.get(mapPool).put(i,entry.getKey());
}
}
mapDifficult = mapDifficultTemp;
mapMonsterDifficult = mapMonsterDifficultTemp;
mapRewardDifficult = mapRewardDifficultTemp;
}
public int getId() {
return id;
}
public int[] getWorldLevel() {
return worldLevel;
}
public int[] getMonsterId() {
return monsterId;
}
public int[] getRewardId() {
return rewardId;
}
public int getMapPool() {
return mapPool;
}
}