爬塔副本初版

back_recharge
jiahuiwen 2019-06-25 12:06:41 +08:00
parent 8ad8890274
commit f4e77f9ada
19 changed files with 346 additions and 49 deletions

View File

@ -0,0 +1,108 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.Map;
/**
*
*/
@Table(name = "TrialConfig")
public class STrialConfig implements BaseConfig {
public static Map<Integer, STrialConfig> sTrialConfigMap;
@Override
public void init() throws Exception {
sTrialConfigMap = STableManager.getConfig(STrialConfig.class);
}
/**
*
*/
private int id;
/**
* id
*/
private int mapId;
/**
*
*/
private int isSaveFloor;
/**
*
*/
private int[] reward;
/**
* "#id
* 1
* 2"
*/
private int[][] randomMonsterType;
/**
*
*/
private int[] monsterCount;
/**
* "#
* 1boss
* 2
* 3
* 4"
*/
private int[][] randomBossType;
/**
* MapPointid
*/
private int[] randomMapPointId;
/**
*
*/
private int normalEnergy;
/**
*
*/
private int eliteEnergy;
public int getId() {
return id;
}
public int getMapId() {
return mapId;
}
public int getIsSaveFloor() {
return isSaveFloor;
}
public int[] getReward() {
return reward;
}
public int[][] getRandomMonsterType() {
return randomMonsterType;
}
public int[] getMonsterCount() {
return monsterCount;
}
public int[][] getRandomBossType() {
return randomBossType;
}
public int getNormalEnergy() {
return normalEnergy;
}
public int getEliteEnergy() {
return eliteEnergy;
}
public int[] getRandomMapPointId() {
return randomMapPointId;
}
}

View File

@ -0,0 +1,37 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
@Table(name = "TrialSetting")
public class STrialSetting implements BaseConfig{
public static STrialSetting sTrialSetting;
@Override
public void init() throws Exception {
sTrialSetting = STableManager.getConfig(STrialSetting.class).get(1);
}
private int id;
/**
*
*/
private int dailyReset;
/**
*
*/
private int rebornTimes;
public int getId() {
return id;
}
public int getDailyReset() {
return dailyReset;
}
public int getRebornTimes() {
return rebornTimes;
}
}

View File

@ -1973,29 +1973,14 @@ public class MapLogic {
return;
}
// 判断次数
if (mapManager.getFightCount() >= 5) {
if (mapManager.getFightCount() >= STrialSetting.sTrialSetting.getRebornTimes()) {
LOGGER.info("enterTowerCopy() uid=>{} teamId =>{} ", uid, teamId);
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
return;
}
int tower = mapManager.getTower();
Map<Integer, SCMap> scMap = SCMap.sCMap.get(tower);
if (scMap == null) {
LOGGER.info("enterTowerCopy() uid=>{} scMap == null =>{} ", uid, tower);
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
return;
}
SChallengeMapConfig scMapConfig = SChallengeMapConfig.integerSChallengeMapConfigMap.get(tower);
if (scMapConfig == null) {
LOGGER.info("enterTowerCopy() uid=>{} sChallengeConfig == null =>{} ", uid, tower);
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "该地图不存在");
return;
}
SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(tower);
if (sChallengeConfig == null) {
LOGGER.info("enterTowerCopy() uid=>{} sChallengeConfig == null =>{} ", uid, tower);
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "该地图不存在");
return;
if (tower == 0) {
mapManager.setTower(1);
}
String error = initTeamInfo(teamId, uid, user, mapManager);
if (!error.isEmpty()) {
@ -2003,17 +1988,13 @@ public class MapLogic {
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
return;
}
initTrialMap(mapManager, user);
user.setMapManager(mapManager);
List<CommonProto.Cell> cells = new ArrayList<>(mapManager.getMapInfo().size());
for (Map.Entry<Integer, Cell> entry : mapManager.getMapInfo().entrySet()) {
cellToProto(cells, entry);
}
MapInfoProto.MapEnterResponse.Builder mapEnterResponse = MapInfoProto.MapEnterResponse.newBuilder();
for (Map.Entry<Integer, Integer> buffEntry : mapManager.getFoodBufferMap().entrySet()) {
if (buffEntry.getValue() <= 0) {
continue;
@ -2021,9 +2002,6 @@ public class MapLogic {
CommonProto.FoodBuffer foodBuffer = CBean2Proto.getFoodBuffer(buffEntry.getKey(), buffEntry.getValue());
mapEnterResponse.addFoodBuffers(foodBuffer);
}
if (mapManager.getMission() != null) {
mapEnterResponse.setMissions(getMission(mapManager.getMission()));
}
mapEnterResponse.setDieCount(mapManager.getDieCount());
mapEnterResponse.addAllMapList(cells);
mapEnterResponse.setCurXY(mapManager.getCurXY());
@ -2031,17 +2009,6 @@ public class MapLogic {
if (mapManager.getTemporaryItems() != null) {
mapEnterResponse.setTemporaryItems(CBean2Proto.getDrop(mapManager.getTemporaryItems()));
}
MapMission mapMissionProgres = mapManager.getMapMissionProgres();
if (mapMissionProgres != null) {
Map<Integer, Integer> allMissionProgress = mapMissionProgres.getAllMissionProgress();
List<CommonProto.ExploreDetail> exploreDetailList = new ArrayList<>(allMissionProgress.size());
for (Map.Entry<Integer, Integer> item : allMissionProgress.entrySet()) {
exploreDetailList.add(CommonProto.ExploreDetail.newBuilder().setId(item.getKey()).setProgress(item.getValue()).build());
}
mapEnterResponse.addAllExploreDetail(exploreDetailList);
}else{
LOGGER.error("the curmap={}",mapManager.getCurMapId());
}
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
Map<String, Map<Integer, Integer>> heroAllAttributeMap = mapManager.getHeroAllAttributeMap();
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) {
@ -2061,6 +2028,89 @@ public class MapLogic {
}
public String initTrialMap(MapManager mapManager, User user) throws Exception {
STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(mapManager.getTower());
if (sTrialConfig == null) {
LOGGER.info("initTrialMap() uid=>{} sTrialConfig == null =>{} ", user.getId(), mapManager.getTower());
return "";
}
SChallengeMapConfig scMapConfig = SChallengeMapConfig.integerSChallengeMapConfigMap.get(sTrialConfig.getMapId());
if (scMapConfig == null) {
LOGGER.info("initTrialMap() uid=>{} sChallengeConfig == null =>{} ", user.getId(), sTrialConfig.getMapId());
return "该地图不存在";
}
Map<Integer, Cell> newMap = new HashMap<>();
Random random = new Random();
Map<Integer, SCMap> scMap = SCMap.sCMap.get(sTrialConfig.getMapId());
Map<Integer, Cell> cellMap1 = new HashMap<>(sTrialConfig.getMonsterCount()[0]);
Map<Integer, Cell> cellMap2 = new HashMap<>(sTrialConfig.getMonsterCount()[1]);
for (Map.Entry<Integer, SCMap> 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]) {
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);
Cell cellValue = new Cell(xy, scMap1.getEvent(), scMap1.getEvent());
cellMap1.put(xy, cellValue);
i++;
if (i >= 1000) {
break;
}
}
} else if (scMap1.getEvent() == 2) {
int i = 0;
while (cellMap2.size() < sTrialConfig.getMonsterCount()[1]) {
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);
Cell cellValue = new Cell(xy, scMap1.getEvent(), scMap1.getEvent());
cellMap2.put(xy, cellValue);
i++;
if (i >= 1000) {
break;
}
}
} 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 = SChallengeMapConfig.integerSChallengeMapConfigMap.get(sTrialConfig.getMapId());
int xy = CellUtil.xy2Pos(challengeMapConfig.getPosition()[0], challengeMapConfig.getPosition()[1]);
mapManager.setCurXY(xy);
mapManager.setMapInfo(newMap);
return "";
}
/**
*
*

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.handler.map;
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MapInfoProto;

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.handler.map;
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.FightInfoProto;

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.handler.map;
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MapInfoProto;

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.handler.map;
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MapInfoProto;
@ -22,5 +23,8 @@ public class MapEnterRequestHandler extends BaseHandler{
MapInfoProto.MapEnterRequest mapEnterRequest = MapInfoProto.MapEnterRequest.parseFrom(message);
int teamId = mapEnterRequest.getTeamId();
MapLogic.getInstance().enterMap(iSession, mapEnterRequest.getMapId(), teamId, MessageTypeProto.MessageType.MAP_ENTER_RESPONSE);
MapLogic.getInstance().enterTowerCopy(iSession, 1, MessageTypeProto.MessageType.MAP_ENTER_RESPONSE );
}
}

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.handler.map;
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.handler.map;
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MapInfoProto;

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.handler.map;
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MapInfoProto;

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.handler.map;
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.handler.map;
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MapInfoProto;

View File

@ -0,0 +1,21 @@
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class MapTowerCallChiefRequest extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.MAP_TOWER_CALL_CHIEF_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
MapLogic.getInstance().callChief(iSession, MessageTypeProto.MessageType.MAP_TOWER_CALL_CHIEF_RESPONSE);
}
}

View File

@ -0,0 +1,25 @@
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MapInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class MapTowerEnterRequestHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.MAP_TOWER_ENTER_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
byte[] message = netData.parseClientProtoNetData();
MapInfoProto.MapTowerEnterRequest mapTowerEnterRequest = MapInfoProto.MapTowerEnterRequest.parseFrom(message);
int teamId = mapTowerEnterRequest.getTeamId();
MapLogic.getInstance().enterTowerCopy(iSession, teamId, MessageTypeProto.MessageType.MAP_TOWER_ENTER_RESPONSE);
}
}

View File

@ -0,0 +1,20 @@
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class MapTowerOutRequest extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.MAP_TOWER_OUT_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
}
}

View File

@ -0,0 +1,21 @@
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class MapTowerResetRequestHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.MAP_TOWER_RESET_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
MapLogic.getInstance().outTowerCopy(iSession, MessageTypeProto.MessageType.MAP_TOWER_RESET_RESPONSE);
}
}

View File

@ -1,7 +1,8 @@
package com.ljsd.jieling.handler.map;
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MapInfoProto;

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.handler.map;
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.netty.cocdex.PacketNetData;

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.handler.map;
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.SweepLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.FightInfoProto;