package config; import manager.STableManager; import manager.Table; import rpc.protocols.CommonProto; import java.util.*; @Table(name ="ArenaRobotConfig") public class SArenaRobotConfig implements BaseConfig { private int id; private String robotName; private int robotScore; private int robotLevel; private int[] roleId; private int[] roleId2; private int[] roleId3; private List heroList; private List heroList2; private List heroList3; private int roleLv; private int[] differDemonsId; private int differDemonsLv; private int poolId; private int totalForce; private int yxldTotalForce; private int yxldTotalForce1; private int yxldTotalForce2; private int yxldTotalForce3; private int breakId; private int starBreakId; private Map starOfHeroMap; private Map heroMapList; private Map heroMapList2; private Map heroMapList3; private static Map> sArenaRobotConfigByPoolMap; private static Map sArenaRobotConfigMap; private int msScroe; @Override public void init() throws Exception { Map> result = new HashMap<>(); Map config = STableManager.getConfig(SArenaRobotConfig.class); for(SArenaRobotConfig sArenaRobotConfig : config.values()){ int poolId = sArenaRobotConfig.getPoolId(); if(!result.containsKey(poolId)){ result.put(poolId,new ArrayList<>()); } int[] roleId = sArenaRobotConfig.getRoleId(); List heroListTmp = new ArrayList<>(roleId.length); for(int heroId : roleId){ heroListTmp.add(heroId); } //玉虚论道第二个队伍 int[] roleId2 = sArenaRobotConfig.getRoleId2(); List heroListTmp2 = new ArrayList<>(roleId.length); for(int heroId : roleId2){ heroListTmp2.add(heroId); } //第三个队伍 int[] roleId3 = sArenaRobotConfig.getRoleId3(); List heroListTmp3 = new ArrayList<>(roleId.length); for(int heroId : roleId3){ heroListTmp3.add(heroId); } sArenaRobotConfig.setHeroList(heroListTmp); sArenaRobotConfig.setHeroList2(heroListTmp2); sArenaRobotConfig.setHeroList3(heroListTmp3); result.get(poolId).add(sArenaRobotConfig); } sArenaRobotConfigByPoolMap = result; sArenaRobotConfigMap = config; } /** * 根据玉虚积分取机器人 * @param start * @param end * @param count * @return */ public static List getSArenaRobotConfigsByRangeAndCount( int start,int end,int count) { List robotIdList = new ArrayList(); for (SArenaRobotConfig config:sArenaRobotConfigMap.values()) { if(config.getMsScroe() >= start && config.getMsScroe()<= end ){ robotIdList.add(config.getId()); } } Collections.shuffle(robotIdList); if(robotIdList.size() >= count){ return robotIdList.subList(0,count); }else{ return robotIdList; } } public static Map getsArenaRobotConfigMap() { return sArenaRobotConfigMap; } public static SArenaRobotConfig getsArenaRobotConfigById(int id) { return sArenaRobotConfigMap.get(id); } public int getId() { return id; } public String getRobotName() { return robotName; } public int getRobotScore() { return robotScore; } private int[] getRoleId() { return roleId; } public int[] getRoleId2() { return roleId2; } public int[] getRoleId3() { return roleId3; } public int getRoleLv() { return roleLv; } public int[] getDifferDemonsId() { return differDemonsId; } public int getDifferDemonsLv() { return differDemonsLv; } public int getPoolId() { return poolId; } public List getHeroList() { return heroList; } public void setHeroList(List heroList) { this.heroList = heroList; } public int getTotalForce() { return totalForce; } public void setTotalForce(int totalForce) { this.totalForce = totalForce; } public int getRobotLevel() { return robotLevel; } public Map getHeroMapList() { return heroMapList; } public void setHeroMapList(Map heroMapList) { this.heroMapList = heroMapList; } public Map getHeroMapList2() { return heroMapList2; } public void setHeroMapList2(Map heroMapList2) { this.heroMapList2 = heroMapList2; } public Map getHeroMapList3() { return heroMapList3; } public void setHeroMapList3(Map heroMapList3) { this.heroMapList3 = heroMapList3; } public List getHeroList2() { return heroList2; } public void setHeroList2(List heroList2) { this.heroList2 = heroList2; } public List getHeroList3() { return heroList3; } public void setHeroList3(List heroList3) { this.heroList3 = heroList3; } public int getMsScroe() { return msScroe; } public int getYxldTotalForce() { return yxldTotalForce; } public void setYxldTotalForce(int yxldTotalForce) { this.yxldTotalForce = yxldTotalForce; } public int getYxldTotalForce1() { return yxldTotalForce1; } public void setYxldTotalForce1(int yxldTotalForce1) { this.yxldTotalForce1 = yxldTotalForce1; } public int getYxldTotalForce2() { return yxldTotalForce2; } public void setYxldTotalForce2(int yxldTotalForce2) { this.yxldTotalForce2 = yxldTotalForce2; } public int getYxldTotalForce3() { return yxldTotalForce3; } public void setYxldTotalForce3(int yxldTotalForce3) { this.yxldTotalForce3 = yxldTotalForce3; } public static List getSArenaRobotConfigsByPool( int poolId) { return sArenaRobotConfigByPoolMap.get(poolId); } }