爬塔副本
parent
587c317dc4
commit
6a806eca6d
|
@ -158,10 +158,13 @@ public class MapLogic {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//todo 更新地圖次數
|
||||
mapManager.setCurMapId(mapId);
|
||||
initMap(mapManager, user);
|
||||
if (type == 2) {
|
||||
initTrialMap(mapManager, user);
|
||||
} else {
|
||||
initMap(mapManager, user);
|
||||
}
|
||||
user.setMapManager(mapManager);
|
||||
} else if (mapManager.getCurMapId() != mapId) {
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "地图错误,应进入" + mapManager.getCurMapId());
|
||||
|
@ -969,11 +972,21 @@ public class MapLogic {
|
|||
BaseBehavior baseBehavior = baseBehaviorMap.get(10);
|
||||
baseBehavior.afterFastFight(user, groupId, fastFightResponse);
|
||||
}
|
||||
|
||||
fastFightResponse.setEnventDrop(drop.build());
|
||||
fastFightResponse.setResult(resultCode);
|
||||
fastFightResponse.addAllRemainHpList(remainHp);
|
||||
fastFightResponse.build();
|
||||
if (sChallengeConfig.getType() == 2) {
|
||||
STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(mapManager.getTower());
|
||||
int[][] randomMonsterType = sTrialConfig.getRandomMonsterType();
|
||||
if (randomMonsterType[0][1] == cell.getPointId()) {
|
||||
mapManager.setEssenceValue(mapManager.getEssenceValue() + sTrialConfig.getNormalEnergy());
|
||||
} else {
|
||||
mapManager.setEssenceValue(mapManager.getEssenceValue() + sTrialConfig.getEliteEnergy());
|
||||
}
|
||||
}
|
||||
|
||||
fastFightResponse.setEssenceValue(mapManager.getEssenceValue());
|
||||
// LOGGER.info("endFight() uid=>{},nextEventId=>{}", uid, nextEventId);
|
||||
MapMissionManager.updateMapMission(mapManager, EventType.fightEvent, groupId, groupId);
|
||||
// LOGGER.info("endFight() uid=>{} sMonsterGroup.getRewardgroup()=>{} misson=>{} eventDrop=>{}, missionDrop=>{}", uid, sMonsterGroup.getRewardgroup(), fastFightResponse.getMission(), fastFightResponse.getEnventDrop(), fastFightResponse.getMissionDrop());
|
||||
|
@ -1176,9 +1189,8 @@ public class MapLogic {
|
|||
if (monsterGroupId == mapManager.getSuddenlyBoss()) {
|
||||
mapManager.findSuddenlyBoss(0, 0);
|
||||
}
|
||||
fightEndResponse.setEssenceValue(mapManager.getEssenceValue());
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1505,6 +1517,7 @@ public class MapLogic {
|
|||
.setResetCount(mapManager.getResetCount())
|
||||
.setHighestTower(mapManager.getHighestTower())
|
||||
.addAllTowerShopInfos(towerShopInfos)
|
||||
.setEssenceValue(mapManager.getEssenceValue())
|
||||
.build();
|
||||
builder.setTowerCopyInfo(towerCopyInfo);
|
||||
MessageUtil.sendMessage(iSession, 1, msgId, builder.build(), true);
|
||||
|
@ -1886,80 +1899,12 @@ public class MapLogic {
|
|||
|
||||
|
||||
/**
|
||||
* 试炼副本 爬塔
|
||||
* 初始化爬塔副本
|
||||
* @param mapManager
|
||||
* @param user
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public void enterTowerCopy(ISession iSession, int teamId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
if (teamId == 0) {
|
||||
LOGGER.info("enterTowerCopy() uid=>{} teamId =>{} ", uid, teamId);
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
// 判断次数
|
||||
if (mapManager.getFightCount() >= STrialSetting.sTrialSetting.getRebornTimes()) {
|
||||
LOGGER.info("enterTowerCopy() uid=>{} teamId =>{} ", uid, teamId);
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
if (mapManager.getCurMapId() > 0) {
|
||||
LOGGER.info("enterTowerCopy() uid=>{} mapManager.getCurMapId() > 0 =>{} ", uid, mapManager.getCurMapId());
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
int tower = mapManager.getTower();
|
||||
if (tower == 0) {
|
||||
mapManager.setTower(1);
|
||||
}
|
||||
String error = initTeamInfo(teamId, uid, user, mapManager);
|
||||
if (!error.isEmpty()) {
|
||||
LOGGER.info("enterTowerCopy() uid=>{} error =>{} ", uid, error);
|
||||
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.MapTowerEnterResponse.Builder mapEnterResponse = MapInfoProto.MapTowerEnterResponse.newBuilder();
|
||||
for (Map.Entry<Integer, Integer> buffEntry : mapManager.getFoodBufferMap().entrySet()) {
|
||||
if (buffEntry.getValue() <= 0) {
|
||||
continue;
|
||||
}
|
||||
CommonProto.FoodBuffer foodBuffer = CBean2Proto.getFoodBuffer(buffEntry.getKey(), buffEntry.getValue());
|
||||
mapEnterResponse.addFoodBuffers(foodBuffer);
|
||||
}
|
||||
mapEnterResponse.setFightCount(mapManager.getFightCount());
|
||||
mapEnterResponse.addAllMapList(cells);
|
||||
mapEnterResponse.setCurXY(mapManager.getCurXY());
|
||||
mapEnterResponse.setEssenceValue(mapManager.getEssenceValue());
|
||||
mapEnterResponse.addAllWakeCells(mapManager.getWalkCells() == null ? new ArrayList<>() : mapManager.getWalkCells());
|
||||
mapEnterResponse.setLeftTime(getTowerLeftTime(user, false));
|
||||
if (mapManager.getTemporaryItems() != null) {
|
||||
mapEnterResponse.setTemporaryItems(CBean2Proto.getDrop(mapManager.getTemporaryItems()));
|
||||
}
|
||||
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
|
||||
Map<String, Map<Integer, Integer>> heroAllAttributeMap = mapManager.getHeroAllAttributeMap();
|
||||
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) {
|
||||
Map<Integer, Integer> map = heroAllAttributeMap.get(teamPosHeroInfo.getHeroId());
|
||||
if (map == null) {
|
||||
continue;
|
||||
}
|
||||
MapInfoProto.HeroInfo heroInfo = MapInfoProto.HeroInfo.newBuilder()
|
||||
.setHeroId(teamPosHeroInfo.getHeroId())
|
||||
.setHeroHp(map.get(HeroAttributeEnum.CurHP.getPropertyId()) == null ? 0 : map.get(HeroAttributeEnum.CurHP.getPropertyId()))
|
||||
.setHeroMaxHp(map.get(HeroAttributeEnum.Hp.getPropertyId()) == null ? 0 : map.get(HeroAttributeEnum.Hp.getPropertyId()))
|
||||
.build();
|
||||
mapEnterResponse.addHeroInfos(heroInfo);
|
||||
}
|
||||
LOGGER.info("enterTowerCopy() uid=>{} mapId =>{}", uid, mapManager.getTower());
|
||||
MessageUtil.sendMessage(iSession, 1, messageType.getNumber(), mapEnterResponse.build(), true);
|
||||
}
|
||||
|
||||
|
||||
public String initTrialMap(MapManager mapManager, User user) throws Exception {
|
||||
STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(mapManager.getTower());
|
||||
if (sTrialConfig == null) {
|
||||
|
@ -1993,30 +1938,40 @@ public class MapLogic {
|
|||
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);
|
||||
Cell cellValue = new Cell(xy, scMap1.getEvent(), scMap1.getEvent());
|
||||
cellMap1.put(xy, cellValue);
|
||||
i++;
|
||||
if (i >= 1000) {
|
||||
break;
|
||||
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);
|
||||
Cell cellValue = new Cell(xy, scMap1.getEvent(), scMap1.getEvent());
|
||||
cellMap2.put(xy, cellValue);
|
||||
i++;
|
||||
if (i >= 1000) {
|
||||
break;
|
||||
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());
|
||||
cellMap2.put(xy, cellValue);
|
||||
}
|
||||
} else {
|
||||
// 随机出现的事件点
|
||||
|
@ -2039,27 +1994,10 @@ public class MapLogic {
|
|||
int xy = CellUtil.xy2Pos(challengeMapConfig.getPosition()[0], challengeMapConfig.getPosition()[1]);
|
||||
mapManager.setCurXY(xy);
|
||||
mapManager.setMapInfo(newMap);
|
||||
mapManager.setEssenceValue(0);
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始战斗
|
||||
* @param session
|
||||
* @param messageType
|
||||
*/
|
||||
public void towerStartFight(ISession session, MessageTypeProto.MessageType messageType) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束战斗
|
||||
* @param session
|
||||
* @param messageType
|
||||
*/
|
||||
public void towerEndFight(ISession session, String frames, MessageTypeProto.MessageType messageType) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 召唤首领
|
||||
*
|
||||
|
@ -2080,25 +2018,6 @@ public class MapLogic {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 离开爬塔副本
|
||||
* @param iSession
|
||||
* @param messageType
|
||||
*/
|
||||
public void outTowerCopy(ISession iSession, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
mapManager.setEssenceValue(0);
|
||||
resetMapInfo(user, true);
|
||||
MapInfoProto.MapTowerResetResponse mapTowerResetResponse = MapInfoProto.MapTowerResetResponse
|
||||
.newBuilder()
|
||||
.setResetCount(mapManager.getResetCount())
|
||||
.setTower(1)
|
||||
.build();
|
||||
MessageUtil.sendMessage(iSession, 1, messageType.getNumber(), mapTowerResetResponse, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置爬塔副本
|
||||
* @param iSession
|
||||
|
|
|
@ -75,7 +75,7 @@ public class MapManager extends MongoBase {
|
|||
private int starReward;
|
||||
|
||||
// 爬塔副本当前层数
|
||||
private int tower;
|
||||
private int tower = 1;
|
||||
// 爬塔副本战斗次数
|
||||
private int fightCount;
|
||||
// 爬塔副本重置次数
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package com.ljsd.jieling.handler.map.behavior;
|
||||
|
||||
import com.ljsd.jieling.config.MapPointConfig;
|
||||
import com.ljsd.jieling.config.SChallengeConfig;
|
||||
import com.ljsd.jieling.config.STrialConfig;
|
||||
import com.ljsd.jieling.handler.map.Cell;
|
||||
import com.ljsd.jieling.handler.map.EventType;
|
||||
import com.ljsd.jieling.handler.map.MapManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.protocols.FightInfoProto;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
|
@ -21,6 +26,19 @@ public class FightBehavior extends BaseBehavior {
|
|||
|
||||
@Override
|
||||
public boolean afterFight(User user, int[][] behaviorTypeValues, FightInfoProto.FightEndResponse.Builder fightEndResponse) throws Exception {
|
||||
MapManager mapManager = user.getMapManager();
|
||||
SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId());
|
||||
if (sChallengeConfig.getType() == 2) {
|
||||
int triggerXY = mapManager.getTriggerXY();
|
||||
Cell cell = mapManager.getMapInfo().get(triggerXY);
|
||||
STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(mapManager.getTower());
|
||||
int[][] randomMonsterType = sTrialConfig.getRandomMonsterType();
|
||||
if (randomMonsterType[0][1] == cell.getPointId()) {
|
||||
mapManager.setEssenceValue(mapManager.getEssenceValue() + sTrialConfig.getNormalEnergy());
|
||||
} else {
|
||||
mapManager.setEssenceValue(mapManager.getEssenceValue() + sTrialConfig.getEliteEnergy());
|
||||
}
|
||||
}
|
||||
BehaviorUtil.destoryCurPoint(user);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
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 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 {
|
||||
MapLogic.getInstance().outTowerCopy(iSession, MessageTypeProto.MessageType.MAP_TOWER_OUT_RESPONSE);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue