package config; import manager.STableManager; import manager.Table; import java.util.*; @Table(name ="WishActivityPool") public class SWishActivityPool implements BaseConfig { private int id; private int[] itemId; private int getRate; private int camp; public static Map> weight = new TreeMap<>(); public static Map map = new HashMap<>(); @Override public void init() throws Exception { Map config = STableManager.getConfig(SWishActivityPool.class); List allCamp = new ArrayList<>(10); Map> mapTemp = new HashMap<>(); config.values().forEach(v->{ map.put(v.getId(),v); //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()); } }); //把0权重的放进去 allCamp.forEach(i->mapTemp.forEach((k,v)->v.put(i,map.get(i).getGetRate()))); weight = mapTemp; } public int getId() { return id; } public int[] getItemId() { return itemId; } public int getGetRate() { return getRate; } public int getCamp() { return camp; } }