From c012389b87ceea0d918afe4b0b99569dfe058fb2 Mon Sep 17 00:00:00 2001 From: lvxinran Date: Tue, 9 Jun 2020 05:59:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E7=82=BC=E5=89=AF=E6=9C=AC=E7=A6=8F?= =?UTF-8?q?=E5=88=A9=E5=B1=82=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ljsd/jieling/handler/map/EventType.java | 1 + .../ljsd/jieling/handler/map/MapLogic.java | 342 +++--------------- .../handler/map/behavior/FiftyBehavior.java | 32 ++ .../map/behavior/FourtyTwoBehavior.java | 35 +- .../mapHandler/MapTowerCallChiefRequest.java | 2 +- .../jieling/handler/map/mapType/TowerMap.java | 133 +++++-- .../src/main/java/config/STrialConfig.java | 6 + .../main/java/config/STrialwelfareConfig.java | 69 ++++ 8 files changed, 278 insertions(+), 342 deletions(-) create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/FiftyBehavior.java create mode 100644 tablemanager/src/main/java/config/STrialwelfareConfig.java diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/EventType.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/EventType.java index 9b4212724..b9890ce66 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/EventType.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/EventType.java @@ -111,6 +111,7 @@ public class EventType { public static final int fourtySeven = 47; public static final int fourtyEight = 48; public static final int fourtyNine = 49; + public static final int fifty = 50; public static final int updatePonintEvent = 1; public static final int fightEvent = 2; diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java index 899485d17..6c784ab4f 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java @@ -2139,79 +2139,6 @@ public class MapLogic { RankContext.getRankEnum(RankEnum.MAIN_LEVEL_RANK.getType()).addRank(uid,"",sMainLevelConfig.getVirtureId(),user.getPlayerInfoManager().getMaxForce()); } -// public void getMainLevelRankInfo(ISession session) throws Exception { -// int rankEndLine = SSpecialConfig.getIntegerValue(SSpecialConfig.Level_RankingShowNum); -// int rank =1; -// Set> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.MAINLEVEL_RANK, "", 0, rankEndLine-1); -// FightInfoProto.MainLevelRankInfoResponse.Builder builder = FightInfoProto.MainLevelRankInfoResponse.newBuilder(); -// List mainLevelRankInfoList = new ArrayList<>(rankEndLine); -// for (ZSetOperations.TypedTuple item : arenaRankInfo) { -// String value = item.getValue(); -// int score = item.getScore().intValue(); -// int uidTmp = Integer.parseInt(value); -// User userTmp = UserManager.getUser(uidTmp, true); -// if (null == userTmp) { -// continue; -// } -// PlayerManager playerInfoManager = userTmp.getPlayerInfoManager(); -// mainLevelRankInfoList.add(CommonProto.MainLevelRankInfo.newBuilder() -// .setUid(uidTmp) -// .setLevel(playerInfoManager.getLevel()) -// .setName(playerInfoManager.getNickName()) -// .setFightId(SMainLevelConfig.sMainLevelConfigByVirtureIdMap.get(score).getVirtureId()) -// .setHead(playerInfoManager.getHead()) -// .setRank(rank++) -// .setTotalForce(userTmp.getPlayerInfoManager().getMaxForce()) -// .setHeadFrame(playerInfoManager.getHeadFrame())); -//// } -// Collections.sort(mainLevelRankInfoList, new Comparator() { -// @Override -// public int compare(CommonProto.MainLevelRankInfo.Builder o1, CommonProto.MainLevelRankInfo.Builder o2) { -// if(o1.getFightId()==o2.getFightId()){ -// if(o1.getTotalForce()>o2.getTotalForce() && o1.getRank()>o2.getRank()){ -// int rank = o1.getRank(); -// o1.setRank(o2.getRank()); -// o2.setRank(rank); -// } -// } -// return o1.getRank()-o2.getRank(); -// } -// }); -//// rank =1; -// int myRank =-1; -// int uid = session.getUid(); -// for(CommonProto.MainLevelRankInfo.Builder builder1 : mainLevelRankInfoList){ -// builder1.setRank(rank++); -// builder1.setFightId(SMainLevelConfig.sMainLevelConfigByVirtureIdMap.get(builder1.getFightId()).getId()); -// builder.addMainLevelRankInfo(builder1.build()); -// if(builder1.getUid() == uid){ -// myRank = builder1.getRank(); -// } -// } -// -// int score = RedisUtil.getInstence().getZSetScore(RedisKey.MAINLEVEL_RANK,"", Integer.toString(uid)).intValue(); -// if(score == -1){ -// score = 1011; -// }else{ -// if(myRank==-1){ -// myRank= RedisUtil.getInstence().getZSetreverseRank(RedisKey.MAINLEVEL_RANK,"",Integer.toString(uid)).intValue(); -// } -// score= SMainLevelConfig.sMainLevelConfigByVirtureIdMap.get(score).getId(); -// } -// User user = UserManager.getUser(uid); -// PlayerManager playerInfoManager = user.getPlayerInfoManager(); -// builder.setMyMainLevelRankInfo(CommonProto.MainLevelRankInfo.newBuilder() -// .setUid(uid) -// .setLevel(playerInfoManager.getLevel()) -// .setName(playerInfoManager.getNickName()) -// .setFightId(score) -// .setHead(playerInfoManager.getHead()) -// .setRank(myRank) -// .setTotalForce(playerInfoManager.getMaxForce()) -// .setHeadFrame(playerInfoManager.getHeadFrame()).build()); -// MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.MAIN_LEVEL_GET_RANK_RESPONSE_VALUE,builder.build(),true); -// -// } public void openNextMainLevel(User user,int fightId) throws Exception { int level = user.getPlayerInfoManager().getLevel(); @@ -2385,215 +2312,6 @@ public class MapLogic { } } - -// /** -// * 初始化爬塔副本 -// * @param mapManager -// * @param user -// * @return -// * @throws Exception -// */ -// public String initTrialMap(MapManager mapManager, User user) throws Exception { -// -// STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(mapManager.getTrialInfo().getFloor()); -// if(mapManager.getTrialInfo().getFloor()>1&&mapManager.getMapIntoFlag()==0){ -// for(int i = 1 ; i {} sTrialConfig == null =>{} ", user.getId(), mapManager.getTrialInfo().getFloor()); -// return ""; -// } -// SChallengeMapConfig scMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(sTrialConfig.getMapId()); -// if (scMapConfig == null) { -// LOGGER.info("initTrialMap() uid=>{} sChallengeConfig == null =>{} ", user.getId(), sTrialConfig.getMapId()); -// return "该地图不存在"; -// } -// Map newMap = new HashMap<>(); -// Random random = new Random(); -// Map scMap = SCMap.sCMap.get(sTrialConfig.getMapId()); -// Map cellMap1 = new HashMap<>(sTrialConfig.getMonsterCount()[0]); -// Map cellMap2 = new HashMap<>(sTrialConfig.getMonsterCount()[1]); -// -// /* if(mapManager.getTowerStartTime()!=0){ -// mapManager.setCurrTowerTime((TimeUtils.now()-mapManager.getTowerStartTime())/1000); -// }*/ -// mapManager.setTowerStartTime(TimeUtils.now()); -// -// for (Map.Entry entry : scMap.entrySet()) { -// SCMap scMap1 = entry.getValue(); -// // 必出现的事件点 -// if (scMap1.getIsMustAppear() == 1) { -// for (int i = 0; i < scMap1.getGroups().length; i++) { -// int x = scMap1.getGroups()[i][0]; -// int y = scMap1.getGroups()[i][1]; -// int xy = CellUtil.xy2Pos(x, y); -// MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(scMap1.getEvent()); -// Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId()); -// newMap.put(xy, cellValue); -// } -// continue; -// } -// if (scMap1.getEvent() == 1) { -// int i = 0; -// while (cellMap1.size() < sTrialConfig.getMonsterCount()[0]) { -// i++; -// if (i >= 10000) { -// break; -// } -// int randomIndex = random.nextInt(scMap1.getGroups().length); -// int x = scMap1.getGroups()[randomIndex][0]; -// int y = scMap1.getGroups()[randomIndex][1]; -// int xy = CellUtil.xy2Pos(x, y); -// MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(sTrialConfig.getRandomMonsterType()[0][1]); -// if (mapPointConfig == null) { -// LOGGER.info("====initTrialMap()====mapPointConfig == null======>{}", scMap1.getEvent()); -// continue; -// } -// Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId()); -// cellMap1.put(xy, cellValue); -// } -// } else if (scMap1.getEvent() == 2) { -// int i = 0; -// while (cellMap2.size() < sTrialConfig.getMonsterCount()[1]) { -// i++; -// if (i >= 10000) { -// break; -// } -// int randomIndex = random.nextInt(scMap1.getGroups().length); -// int x = scMap1.getGroups()[randomIndex][0]; -// int y = scMap1.getGroups()[randomIndex][1]; -// int xy = CellUtil.xy2Pos(x, y); -// MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(sTrialConfig.getRandomMonsterType()[1][1]); -// if (mapPointConfig == null) { -// LOGGER.info("====initTrialMap()====mapPointConfig == null======>{}", scMap1.getEvent()); -// continue; -// } -// Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId()); -// cellMap2.put(xy, cellValue); -// } -// } else { -// // 随机出现的事件点 -// int randomIndex = random.nextInt(scMap1.getGroups().length); -// int x = scMap1.getGroups()[randomIndex][0]; -// int y = scMap1.getGroups()[randomIndex][1]; -// int xy = CellUtil.xy2Pos(x, y); -// MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(scMap1.getEvent()); -// if (mapPointConfig == null) { -// LOGGER.info("====initTrialMap()====mapPointConfig == null======>{}", scMap1.getEvent()); -// continue; -// } -// Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId()); -// newMap.put(xy, cellValue); -// } -// newMap.putAll(cellMap1); -// newMap.putAll(cellMap2); -// } -// SChallengeMapConfig challengeMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(sTrialConfig.getMapId()); -// int xy = CellUtil.xy2Pos(challengeMapConfig.getPosition()[0], challengeMapConfig.getPosition()[1]); -// mapManager.setCurXY(xy); -// mapManager.setMapInfo(newMap); -// mapManager.setTrialEnergy(0); -//// mapManager.setHeroAllAttributeMap(mapManager.getHeroAllAttributeMap()); -// if(mapManager.getTowerUnusedBuffer()==null){ -// mapManager.setTowerUnusedBuffer(new HashMap<>()); -// } -// return ""; -// } - - /** - * 召唤首领 - * - * @param session - * @param messageType - */ - public void callChief(ISession session, MessageTypeProto.MessageType messageType) throws Exception { -// LOGGER.info("进入召唤boss"); - int uid = session.getUid(); - User user = UserManager.getUser(uid); - MapManager mapManager = user.getMapManager(); - if(mapManager.getTrialInfo().getEnergy()<100){ - throw new ErrorCodeException(ErrorCode.newDefineCode("精气值不足!!")); - } - int currTower = mapManager.getTrialInfo().getFloor(); - STrialConfig config = STrialConfig.sTrialConfigMap.get(currTower); - - int type = 1; - - - int[][] bossType = config.getRandomBossType(); - - type = MathUtils.randomFromWeight(bossType); -// if(mapManager.getTrialInfo().getFloor()%5!=0){ -// type = 3; -// } - LOGGER.info("trigger!!!!!!!!!!!!!!!!!-------->{},{}",CellUtil.pos2XY(mapManager.getCurXY())[0],CellUtil.pos2XY(mapManager.getCurXY())[1]); - int[][][] pointId = config.getRandomMapPointId(); - int mapId = config.getMapId(); - SChallengeMapConfig challengeMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(mapId); - int[] mapSize = challengeMapConfig.getSize(); -// LOGGER.info("width:{},height:{},当前:{}==={}",String.valueOf(mapSize[0]),String.valueOf(mapSize[1]),CellUtil.pos2XY(mapManager.getCurXY())[0],CellUtil.pos2XY(mapManager.getCurXY())[1]); - Set xySet = CellUtil.getSurroundPos(mapSize[0],mapSize[1],mapManager.getCurXY()); - LOGGER.info(xySet.toString()); - Map mapInfo = mapManager.getMapInfo(); - clearNormalMonster(user); - Iterator it = xySet.iterator(); - - Map pointConfig = MapPointConfig.scMapEventMap; - while (it.hasNext()){ - Integer n = it.next(); -// LOGGER.info("遍历{},{}",CellUtil.pos2XY(n)[0],CellUtil.pos2XY(n)[1]); - for(Map.Entry cellEntry:mapInfo.entrySet()){ - if(cellEntry.getKey().equals(n)) { - if (pointConfig.get(cellEntry.getValue().getPointId()).getStyle() != 0) { - it.remove(); - break; - } - } - } - } -// LOGGER.info("怪物可出现格子数量{}",String.valueOf(xySet.size())); -// int random = MathUtils.randomInt(xySet.size()); -// LOGGER.info("random"+String.valueOf(random)); - int i = 0; -// int xyResult = 0; -// for(Integer xy:xySet){ -//// LOGGER.info("怪物位置:{},{}",String.valueOf(CellUtil.pos2XY(xy)[0]),String.valueOf(CellUtil.pos2XY(xy)[1])); -// if(random==i){ -// xyResult = xy; -// break; -// } -// i++; -// } - //更改成固定boss位置 - int[] bossPosition = STrialSetting.sTrialSetting.getBossPosition(); - mapManager.setBossType(type); - mapManager.setBossXY(CellUtil.xy2Pos(bossPosition[0],bossPosition[1])); - int randomPoint = MathUtils.randomFromWeight(pointId[type-1]); -// LOGGER.info("随机事件id:==>{}",randomPoint); - MapInfoProto.MapTowerCallChiefResponse.Builder response = MapInfoProto.MapTowerCallChiefResponse.newBuilder(); - Cell cell = BehaviorUtil.addBehaviorInfo(user,randomPoint,mapManager,mapManager.getCurMapId(),bossPosition[0],bossPosition[1],false); - CommonProto.Cell protoCell =CBean2Proto.getCell(cell); - response.setType(type); - mapManager.setTrialEnergy(-1); - response.setMonsterInfo(protoCell); - - MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true); - } - /** * 使用炸弹` * @@ -2655,7 +2373,6 @@ public class MapLogic { } public void clearNormalMonster(User user) throws Exception { - MapManager mapManager = user.getMapManager(); LOGGER.info("删除当前地图小怪!!"); Map configMap = MapPointConfig.scMapEventMap; Set destoryCell = new HashSet<>(); @@ -3363,6 +3080,13 @@ public class MapLogic { mapManager.updateTrailHeroInfo(heroInfo); MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true); } + + /** + * 获取宝箱 + * @param session + * @param messageType + * @throws Exception + */ public void trialGetBox(ISession session, MessageTypeProto.MessageType messageType) throws Exception { User user = UserManager.getUser(session.getUid()); MapManager mapManager = user.getMapManager(); @@ -3371,24 +3095,46 @@ public class MapLogic { //是否在试炼副本中 if(map instanceof TowerMap){ int curXY = mapManager.getCurXY(); - STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(mapManager.getTrialInfo().getFloor()); - for(int i = 0 ; i10000){ + STrialwelfareConfig welfareConfig = STrialwelfareConfig.sTrialwelfareConfigMap.get(floor % 10000); + drop = getBoxReward(welfareConfig.getBoxPosition(),welfareConfig.getBoxReward(),user,curXY); + }else{ + STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(floor); + drop = getBoxReward(sTrialConfig.getBoxPosition(),sTrialConfig.getBoxReward(),user,curXY); } } MapInfoProto.GetTrialBoxRewardResponse response = MapInfoProto.GetTrialBoxRewardResponse.newBuilder().setBoxDrop(drop).build(); MessageUtil.sendMessage(session,1,messageType.getNumber(),response,true); } + + /** + * 内部调用,根据不同层数进行获取宝箱 + * @param boxPosition + * @param boxReward + * @param user + * @param curXY + * @return + * @throws Exception + */ + private CommonProto.Drop.Builder getBoxReward(int[][] boxPosition,int[][][] boxReward,User user,int curXY) throws Exception { + MapManager mapManager = user.getMapManager(); + CommonProto.Drop.Builder drop= null; + for(int i = 0 ; i= maxTower) { - mapManager.setTrialFloor(trialInfo.getFloor() + 1); - LOGGER.info("当前层为{},最大层为{}", trialInfo.getFloor(), maxTower); + int floor = trialInfo.getFloor(); + //奖励层处理 + if(floor>10000){ + floor = floor%10000; + } + //---- + if (challengeConfig.getType() == 2 && floor >= maxTower) { + mapManager.setTrialFloor(floor + 1); + LOGGER.info("当前层为{},最大层为{}", floor, maxTower); return false; } - LOGGER.info("当前层为{},进入下一层", trialInfo.getFloor()); + LOGGER.info("当前层为{},进入下一层", floor); MapLogic.getInstance().clearNormalMonster(user); mapManager.removeBoss(); long time = TimeUtils.now() - mapManager.getTowerStartTime(); mapManager.setCurrTowerTime(time); LOGGER.info("上层使用时间{}", time); //判断通关最高层是否需要替换 - if(trialInfo.getFloor()> trialInfo.getHighestTower()){ - trialInfo.setHighestTower(trialInfo.getFloor()); + if(floor > trialInfo.getHighestTower()){ + trialInfo.setHighestTower(floor); AbstractRank towerRank = RankContext.getRankEnum(RankEnum.TOWER_RANK.getType()); - if(towerRank.getScore(trialInfo.getFloor(),(int)(time/1000))>towerRank.getScoreById(user.getId(),"")){ - towerRank.addRank(user.getId(),"", trialInfo.getFloor(),(int)(time/1000)); + if(towerRank.getScore(floor,(int)(time/1000))>towerRank.getScoreById(user.getId(),"")){ + towerRank.addRank(user.getId(),"", floor,(int)(time/1000)); } } - user.getUserMissionManager().onGameEvent(user, GameEvent.COPY_TOWER_LEVEL, trialInfo.getFloor()); - mapManager.setTrialFloor(trialInfo.getFloor() + 1); -// if(mapManager.getTower()==6){ -// mapManager.setTower(50); -// } + user.getUserMissionManager().onGameEvent(user, GameEvent.COPY_TOWER_LEVEL, floor); + mapManager.setTrialFloor(floor + 1); mapManager.setTrialEnergy(0); - -// mapManager.setStartExporeTime(0); mapManager.setMapIntoFlag(2); -// STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(trialInfo.getFloor()); -// mapManager.setCurMapId(sTrialConfig.getMapId()); -// mapManager.updateTrialMapInfo(mapManager.getMapInfo()); -// MapLogic.getInstance().getMap(user).initMap(mapManager, user); return true; } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/mapHandler/MapTowerCallChiefRequest.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/mapHandler/MapTowerCallChiefRequest.java index a112c40e6..abca38d4b 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/mapHandler/MapTowerCallChiefRequest.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/mapHandler/MapTowerCallChiefRequest.java @@ -16,6 +16,6 @@ public class MapTowerCallChiefRequest extends BaseHandler { @Override public void process(ISession iSession, PacketNetData netData) throws Exception { - MapLogic.getInstance().callChief(iSession, MessageTypeProto.MessageType.MAP_TOWER_CALL_CHIEF_RESPONSE); +// MapLogic.getInstance().callChief(iSession, MessageTypeProto.MessageType.MAP_TOWER_CALL_CHIEF_RESPONSE); } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/mapType/TowerMap.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/mapType/TowerMap.java index 94c636f6a..38d927783 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/mapType/TowerMap.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/mapType/TowerMap.java @@ -25,9 +25,11 @@ import com.ljsd.jieling.logic.fight.result.FightResult; import com.ljsd.jieling.logic.hero.HeroAttributeEnum; import com.ljsd.jieling.logic.mission.GameEvent; import com.ljsd.jieling.logic.store.StoreLogic; +import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.protocols.CommonProto; import com.ljsd.jieling.protocols.FightInfoProto; import com.ljsd.jieling.protocols.MapInfoProto; +import com.ljsd.jieling.protocols.MessageTypeProto; import com.ljsd.jieling.util.*; import config.*; import manager.STableManager; @@ -90,9 +92,11 @@ public class TowerMap extends AbstractMap { MapManager mapManager = UserManager.getUser(uid).getMapManager(); TrialInfo trialInfo = mapManager.getTrialInfo(); int curFloor = trialInfo.getFloor(); - STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(curFloor); - if(sTrialConfig.getMapId()!=mapId){ - throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + if(curFloor<10000){ + STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(curFloor); + if(sTrialConfig.getMapId()!=mapId){ + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + } } if(!trialInfo.getMapInfo().isEmpty()&&mapManager.getCurMapId()==0){ mapManager.setMapInfo(trialInfo.getMapInfo()); @@ -162,7 +166,7 @@ public class TowerMap extends AbstractMap { Cell cell = mapManager.getMapInfo().get(mapManager.getTriggerXY()); int[][] randomMonsterType = sTrialConfig.getRandomMonsterType(); if(cell.getCellId()!=mapManager.getBossXY()){ - if(mapManager.getTrialInfo().getEnergy()!=-1){ + if(mapManager.getTrialInfo().getEnergy()>=0){ if (randomMonsterType[0][1] == cell.getPointId()) { mapManager.setTrialEnergy(mapManager.getTrialInfo().getEnergy() + sTrialConfig.getNormalEnergy()); } else { @@ -177,26 +181,35 @@ public class TowerMap extends AbstractMap { mapManager.setMapInfo(trialMapInfo); return; } - STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(mapManager.getTrialInfo().getFloor()); -// if(mapManager.getTrialInfo().getFloor()>1&&mapManager.getMapIntoFlag()==0){ -// for(int i = 1 ; i 10000){ + int realFloor = floor%10000; + Map welfareMap = STableManager.getConfig(STrialwelfareConfig.class); + STrialwelfareConfig useConfig = null; + for(STrialwelfareConfig config :welfareMap.values()){ + int[] section = config.getSection(); + if(realFloor>section[0]&&realFloor<=section[1]){ + useConfig = config; + break; + } + } + Map newMap = new HashMap<>(); + if(useConfig!=null&&useConfig.getBoxPosition()!=null){ + for(int[] position:useConfig.getBoxPosition()){ + int cellXY = CellUtil.xy2Pos(position[0], position[1]); + Cell cell = new Cell(cellXY,0,STrialSetting.sTrialSetting.getBoxPointId()); + newMap.put(cellXY,cell); + } + } + //生成普通传送门 + Cell transport = createTransport(floor); + newMap.put(transport.getCellId(),transport); + mapManager.setMapInfo(newMap); + return; + } + STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(floor); if (sTrialConfig == null) { - LOGGER.info("initTrialMap() uid=>{} sTrialConfig == null =>{} ", user.getId(), mapManager.getTrialInfo().getFloor()); + LOGGER.info("initTrialMap() uid=>{} sTrialConfig == null =>{} ", user.getId(), floor); return; } SChallengeMapConfig scMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(sTrialConfig.getMapId()); @@ -356,8 +369,13 @@ public class TowerMap extends AbstractMap { if(trialInfo.getEnergy()==-1){ //生成传送门 createCell = createTransport(trialInfo.getFloor()); + mapManager.setTrialEnergy(-2); } updateEnergy(user); + if(trialInfo.getEnergy()>=100){ + //如果大于100则生成boss点 + createCell=callChief(user); + } remainHp = checkResult[2]; } BehaviorUtil.destoryApointXY(user, destoryXY); @@ -392,10 +410,11 @@ public class TowerMap extends AbstractMap { // LOGGER.info("endFight() uid=>{} sMonsterGroup.getRewardgroup()=>{} misson=>{} eventDrop=>{}, missionDrop=>{}", uid, sMonsterGroup.getRewardgroup(), fastFightResponse.getMission(), fastFightResponse.getEnventDrop(), fastFightResponse.getMissionDrop()); } + //根据层数判断生成传送门 private Cell createTransport(int floor){ int transportPoint; //是否为5层整数倍 - if(floor%2==0){ + if(floor%2==0&&floor<10000){ //如果是则进行随机 int[] treasureProbability = STrialSetting.sTrialSetting.getTreasureProbability(); int[] transportPointId= STrialSetting.sTrialSetting.getTransportPoint(); @@ -411,4 +430,70 @@ public class TowerMap extends AbstractMap { LOGGER.info("生成传送门信息:{}",createCell.toString()); return createCell; } + + private Cell callChief(User user) throws Exception { + MapManager mapManager = user.getMapManager(); +// LOGGER.info("进入召唤boss"); + if(mapManager.getTrialInfo().getEnergy()<100){ + throw new ErrorCodeException(ErrorCode.newDefineCode("精气值不足!!")); + } + int currTower = mapManager.getTrialInfo().getFloor(); + STrialConfig config = STrialConfig.sTrialConfigMap.get(currTower); + + int type = 1; + + + int[][] bossType = config.getRandomBossType(); + + type = MathUtils.randomFromWeight(bossType); +// if(mapManager.getTrialInfo().getFloor()%5!=0){ +// type = 3; +// } + LOGGER.info("trigger!!!!!!!!!!!!!!!!!-------->{},{}",CellUtil.pos2XY(mapManager.getCurXY())[0],CellUtil.pos2XY(mapManager.getCurXY())[1]); + int[][][] pointId = config.getRandomMapPointId(); + int mapId = config.getMapId(); + SChallengeMapConfig challengeMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(mapId); + int[] mapSize = challengeMapConfig.getSize(); +// LOGGER.info("width:{},height:{},当前:{}==={}",String.valueOf(mapSize[0]),String.valueOf(mapSize[1]),CellUtil.pos2XY(mapManager.getCurXY())[0],CellUtil.pos2XY(mapManager.getCurXY())[1]); + Set xySet = CellUtil.getSurroundPos(mapSize[0],mapSize[1],mapManager.getCurXY()); + LOGGER.info(xySet.toString()); + Map mapInfo = mapManager.getMapInfo(); + MapLogic.getInstance().clearNormalMonster(user); + Iterator it = xySet.iterator(); + + Map pointConfig = MapPointConfig.scMapEventMap; + while (it.hasNext()){ + Integer n = it.next(); +// LOGGER.info("遍历{},{}",CellUtil.pos2XY(n)[0],CellUtil.pos2XY(n)[1]); + for(Map.Entry cellEntry:mapInfo.entrySet()){ + if(cellEntry.getKey().equals(n)) { + if (pointConfig.get(cellEntry.getValue().getPointId()).getStyle() != 0) { + it.remove(); + break; + } + } + } + } +// LOGGER.info("怪物可出现格子数量{}",String.valueOf(xySet.size())); +// int random = MathUtils.randomInt(xySet.size()); +// LOGGER.info("random"+String.valueOf(random)); +// int xyResult = 0; +// for(Integer xy:xySet){ +//// LOGGER.info("怪物位置:{},{}",String.valueOf(CellUtil.pos2XY(xy)[0]),String.valueOf(CellUtil.pos2XY(xy)[1])); +// if(random==i){ +// xyResult = xy; +// break; +// } +// i++; +// } + //更改成固定boss位置 + int[] bossPosition = STrialSetting.sTrialSetting.getBossPosition(); + mapManager.setBossType(type); + mapManager.setBossXY(CellUtil.xy2Pos(bossPosition[0],bossPosition[1])); + mapManager.setTrialEnergy(-1); + int randomPoint = MathUtils.randomFromWeight(pointId[type-1]); +// LOGGER.info("随机事件id:==>{}",randomPoint); + Cell cell = BehaviorUtil.addBehaviorInfo(user, randomPoint, mapManager, mapManager.getCurMapId(), bossPosition[0], bossPosition[1], false); + return cell; + } } diff --git a/tablemanager/src/main/java/config/STrialConfig.java b/tablemanager/src/main/java/config/STrialConfig.java index 91541095a..ca12dbc8b 100644 --- a/tablemanager/src/main/java/config/STrialConfig.java +++ b/tablemanager/src/main/java/config/STrialConfig.java @@ -64,6 +64,8 @@ public class STrialConfig implements BaseConfig { private int eliteEnergy; private int[][] randomStore; + + private int[] monsterPoint; /** * 最高层 */ @@ -128,4 +130,8 @@ public class STrialConfig implements BaseConfig { public int[][] getBoxPosition() { return boxPosition; } + + public int[] getMonsterPoint() { + return monsterPoint; + } } diff --git a/tablemanager/src/main/java/config/STrialwelfareConfig.java b/tablemanager/src/main/java/config/STrialwelfareConfig.java new file mode 100644 index 000000000..817d54508 --- /dev/null +++ b/tablemanager/src/main/java/config/STrialwelfareConfig.java @@ -0,0 +1,69 @@ +package config; + +import manager.STableManager; +import manager.Table; + +import java.util.HashMap; +import java.util.Map; + +@Table(name ="TrialwelfareConfig") +public class STrialwelfareConfig implements BaseConfig { + + private int id; + + private int[] section; + + private int mapId; + + private int[][] randomMonsterType; + + private int[] monsterCount; + + private int[][][] boxReward; + + private int[][] boxPosition; + + public static Map sTrialwelfareConfigMap = new HashMap<>(); + + @Override + public void init() throws Exception { + Map config = STableManager.getConfig(STrialwelfareConfig.class); + for(STrialwelfareConfig value:config.values()){ + int[] section = value.getSection(); + for(int i = section[0];i <= section[1];i++){ + sTrialwelfareConfigMap.put(i,value); + } + } + } + + + public int getId() { + return id; + } + + public int[] getSection() { + return section; + } + + public int getMapId() { + return mapId; + } + + public int[][] getRandomMonsterType() { + return randomMonsterType; + } + + public int[] getMonsterCount() { + return monsterCount; + } + + public int[][][] getBoxReward() { + return boxReward; + } + + public int[][] getBoxPosition() { + return boxPosition; + } + + +} \ No newline at end of file