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

60 lines
1.4 KiB
Java
Raw Normal View History

2021-05-25 18:05:56 +08:00
package config;
import manager.STableManager;
import manager.Table;
2021-07-02 18:22:35 +08:00
import java.util.*;
2021-05-25 18:05:56 +08:00
@Table(name ="WishActivityPool")
public class SWishActivityPool implements BaseConfig {
private int id;
private int[] itemId;
private int getRate;
2021-07-02 18:22:35 +08:00
private int camp;
public static Map<Integer,Map<Integer,Integer>> weight = new TreeMap<>();
2021-05-25 18:05:56 +08:00
public static Map<Integer,SWishActivityPool> map = new HashMap<>();
@Override
public void init() throws Exception {
Map<Integer, SWishActivityPool> config = STableManager.getConfig(SWishActivityPool.class);
2021-07-02 18:22:35 +08:00
List<Integer> allCamp = new ArrayList<>(10);
Map<Integer,Map<Integer,Integer>> mapTemp = new HashMap<>();
2021-05-25 18:05:56 +08:00
config.values().forEach(v->{
map.put(v.getId(),v);
2021-07-02 18:22:35 +08:00
//weight修改成只有当前卡池和对应权重
if(v.getCamp()!=0){
mapTemp.putIfAbsent(v.getCamp(),new HashMap<>());
mapTemp.get(v.getCamp()).put(v.getId(),v.getGetRate());
}else{
allCamp.add(v.getId());
}
2021-05-25 18:05:56 +08:00
});
2021-07-02 18:27:01 +08:00
//把通用系的的放进去
2021-07-02 18:22:35 +08:00
allCamp.forEach(i->mapTemp.forEach((k,v)->v.put(i,map.get(i).getGetRate())));
2021-07-02 18:27:01 +08:00
//最后再赋值
2021-07-02 18:25:31 +08:00
weight = mapTemp;
2021-05-25 18:05:56 +08:00
}
public int getId() {
return id;
}
public int[] getItemId() {
return itemId;
}
public int getGetRate() {
return getRate;
}
2021-07-02 18:22:35 +08:00
public int getCamp() {
return camp;
}
2021-05-25 18:05:56 +08:00
}