Merge branch 'master' of 60.1.1.230:backend/jieling_server

back_recharge
wangyuan 2019-04-19 14:24:40 +08:00
commit ebbd6dfb8e
6 changed files with 257 additions and 37 deletions

View File

@ -705,10 +705,10 @@ public class RedisUtil {
}
}
public Set<String> getZset(String key,double min,double max){
public Set<String> getZset(String key,long min,long max){
for (int i = 0; i < MAX_TRY_TIMES; i++) {
try {
return redisTemplate.opsForZSet().rangeByScore(key, min, max);
return redisTemplate.opsForZSet().reverseRange(key, min, max);
} catch (Exception e) {
TimeUtils.sleep(FAILED_SLEEP);
}

View File

@ -94,32 +94,7 @@ public class GMRequestHandler extends BaseHandler{
}
break;
case GlobalGm.OPEN_MAP:
// SChallengeMapConfig scMapConfig = SChallengeMapConfig.integerSChallengeMapConfigMap.get(100 + prarm1);
// Set<Integer> missionIds = new HashSet<>();
// MapManager mapManager = cUser.getMapManager();
// if (scMapConfig != null) {
// for (int i = 1; i <= prarm1; i++) {
// int mapId = 100 + i;
// SCMapConfig crossMap = SCMapConfig.getsCMapSize().get(mapId);
// if (crossMap.getOpenRule() != null && crossMap.getOpenRule().length > 0) {
// missionIds.add(crossMap.getOpenRule()[0]);
// }
// initFininshMapMission(mapManager,mapId);
// }
// }
// cUser.getPlayerInfoManager().setMapId(scMapConfig.getId());
// SCMapConfig crossMap = SCMapConfig.getsCMapSize().get(scMapConfig.getId() + 1);
// if (crossMap == null || crossMap.getOpenRule().length == 0) {
// return;
// }
// Map<Integer, Mission> doingMissions = cUser.getMissionManager().getDoingMissions();
// for (Integer key : doingMissions.keySet()) {
// cUser.getMissionManager().removeDoingMissions(key);
// }
// Mission mission = new Mission();
// mission.setMissionId(crossMap.getOpenRule()[0]);
// mission.setMissionStep(0);
// cUser.getMissionManager().updateOneDoingMissions(crossMap.getOpenRule()[0], mission);
MapLogic.getInstance().gmCrossFight(uid, prarm1);
break;
case GlobalGm.ONE_KEY_ITEM_OR_HERO:{
//道具

View File

@ -0,0 +1,23 @@
package com.ljsd.jieling.handler.map;
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.MapInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class MapBuyFightCountRequestHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.MAP_BUY_FIGHT_COUNT_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
byte[] message = netData.parseClientProtoNetData();
MapInfoProto.MapBuyFightCountRequest mapBuyFightCountRequest = MapInfoProto.MapBuyFightCountRequest.parseFrom(message);
MapLogic.getInstance().buyFightCount(iSession, mapBuyFightCountRequest.getBuyCount(), MessageTypeProto.MessageType.MAP_SWEEP_RESPONSE);
}
}

View File

@ -0,0 +1,20 @@
package com.ljsd.jieling.handler.map;
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 MapFastFightRequestHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.MAP_FAST_FIGHT_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
MapLogic.getInstance().fastFight(iSession, MessageTypeProto.MessageType.MAP_FAST_FIGHT_RESPONSE);
}
}

View File

@ -755,6 +755,167 @@ public class MapLogic {
}
}
/**
*
* @param session
* @param messageType
*/
public void fastFight(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
MapManager mapManager = user.getMapManager();
if (mapManager.getMapInfo() == null) {
LOGGER.info("fastFight mapManager.getMapInfo() == null");
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
return;
}
if (mapManager.getCanMoveTime() > 0) {
long leftTime = mapManager.getCanMoveTime() - TimeUtils.now();
if (leftTime > 0) {
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "英雄 " + (leftTime / 1000) + " 秒后复活");
return;
}
}
Cell cell = mapManager.getMapInfo().get(mapManager.getTriggerXY());
if (cell == null) {
cell = mapManager.getMapInfo().get(mapManager.getCurXY());
if (cell == null) {
LOGGER.info("cell == null xy is wrong =>{} triggerXY=>{}", mapManager.getCurXY(), mapManager.getTriggerXY());
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
return;
}
}
int bigEventId = cell.getEventId();
SEventPointConfig sEventPointConfig = SEventPointConfig.sEventPointConfigMap.get(bigEventId);
if (sEventPointConfig == null) {
LOGGER.info("sEventPointConfig == null");
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
return;
}
String fightReadyKey = RedisKey.getKey(RedisKey.FIGHT_READY, Integer.toString(uid), false);
String fightReady = (String) RedisUtil.getInstence().get(fightReadyKey);
int groupId, destoryXY = 0;
String missionId = "0", destroyId = "0", nextEventId = "0";
if (fightReady != null) {
String[] split = fightReady.split("#");
RedisUtil.getInstence().del(fightReadyKey);
groupId = Integer.parseInt(split[0]);
if (split.length > 1) {
missionId = split[1];
}
if (split.length > 2) {
destroyId = split[2];
}
if (split.length > 3) {
nextEventId = split[3];
}
} else {
int[] option = sEventPointConfig.getOption();
if (option == null) {
LOGGER.info("option == null sEventPointConfig.getId()=>{}", sEventPointConfig.getId());
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
return;
}
groupId = option[0];
destoryXY = mapManager.getTriggerXY();
}
CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(user, mapManager.getTeamId());
Map<Integer, List<CommonProto.FightUnitInfo>> monsterByGroup = MonsterUtil.getMonsterByGroup(groupId);
List<CommonProto.FightTeamInfo> monsterTeamList = new ArrayList<>(3);
List<CommonProto.FightTeamInfo> monsterGroupList = BehaviorUtil.getFightTeamInfos(groupId,monsterByGroup, Global.MONSTER_1);
monsterTeamList.addAll(monsterGroupList);
List<CommonProto.FightTeamInfo> monsterGroupList1 = BehaviorUtil.getFightTeamInfos(groupId,monsterByGroup, Global.MONSTER_2);
monsterTeamList.addAll(monsterGroupList1);
List<CommonProto.FightTeamInfo> monsterGroupList2 = BehaviorUtil.getFightTeamInfos(groupId,monsterByGroup, Global.MONSTER_3);
monsterTeamList.addAll(monsterGroupList2);
//设置战斗随机种子
int seed = (int)(System.currentTimeMillis()/1000);
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
LuaValue getOptionData = FightDataUtil.getOptionData("");
int[] checkResult = CheckFight.getInstance().checkFight(seed, getFightData, getOptionData);
List<Integer> remainHp = new ArrayList<>(5);
for (int i = 1; i < checkResult.length; i++) {
remainHp.add(checkResult[i]);
}
//校验结果码 1胜利
int resultCode = checkResult[0];
if (resultCode == -1) {
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "战斗异常!");
return;
} else if (resultCode == 0) {
// 失败需要等待n秒后复活所有英雄
int dieCount = user.getMapManager().getDieCount();
dieCount++;
user.getMapManager().setDieCount(dieCount);
SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(user.getMapManager().getCurMapId());
int[] reviveTime = sChallengeConfig.getReviveTime();
long time = (long) (MathUtils.calABX(dieCount, reviveTime) * 1000);
user.getMapManager().setCanMoveTime(TimeUtils.now() + time);
int leftTime = getLeftTime(user);
remainHp.clear();
if (leftTime <= (int) (time / 1000)) {
resetMapInfo(user, false);
} else {
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(mapManager.getTeamId());
for (TeamPosHeroInfo heroInfo : teamPosHeroInfos) {
Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId());
if (hero == null) {
continue;
}
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroFinalAttribute(user, hero);
hero.setCurHp(heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId()));
hero.setSpeed(heroAttributeMap.get(HeroAttributeEnum.Speed.getPropertyId()));
remainHp.add((int) hero.getCurHp());
}
}
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
FightInfoProto.FightEndResponse fightEndResponse = FightInfoProto.FightEndResponse
.newBuilder()
.setResult(resultCode)
.setEnventDrop(dropBuilder)
.addAllRemainHpList(remainHp)
.build();
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse, true);
return;
}
int teamId = mapManager.getTeamId();
List<TeamPosHeroInfo> team = user.getTeamPosManager().getTeamPosForHero().get(teamId);
for (TeamPosHeroInfo teamPosHeroInfo : team){
Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId());
hero.setCurHp(checkResult[teamPosHeroInfo.getPosition()]);
}
CommonProto.Drop.Builder drop = ItemUtil.drop(user, new int[0], 1, 1);
FightInfoProto.FastFightResponse.Builder fastFightResponse = FightInfoProto.FastFightResponse.newBuilder();
fastFightResponse.setEnventDrop(drop.build());
fastFightResponse.setResult(resultCode);
fastFightResponse.addAllRemainHpList(remainHp);
fastFightResponse.build();
if (!missionId.isEmpty()) {
MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse = MapInfoProto.EventUpdateResponse.newBuilder();
BehaviorUtil.updateMission(user, Integer.parseInt(missionId), eventUpdateResponse);
fastFightResponse.setMission(eventUpdateResponse.getMission());
if (eventUpdateResponse.getDrop() != null) {
fastFightResponse.setMissionDrop(eventUpdateResponse.getDrop());
}
}
if (!destroyId.isEmpty()) {
BehaviorUtil.destoryPoint(user, mapManager.getCurMapId(), Integer.parseInt(destroyId));
}
if (destoryXY != 0) {
BehaviorUtil.destoryApointXY(user, destoryXY);
}
if (!nextEventId.isEmpty()) {
int triggerXY = mapManager.getTriggerXY();
cell.setEventId(Integer.parseInt(nextEventId));
mapManager.addOrUpdateCell(triggerXY, cell);
updateMapMission(mapManager,EventType.updateEvent,cell.getEventId(),0);
}
// LOGGER.info("endFight() uid=>{},nextEventId=>{}", uid, nextEventId);
updateMapMission(mapManager,EventType.fightEvent,0, 1);
// LOGGER.info("endFight() uid=>{} sMonsterGroup.getRewardgroup()=>{} misson=>{} eventDrop=>{}, missionDrop=>{}", uid, sMonsterGroup.getRewardgroup(), fastFightResponse.getMission(), fastFightResponse.getEnventDrop(), fastFightResponse.getMissionDrop());
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fastFightResponse.build(), true);
}
/**
*
* @param session
@ -1279,13 +1440,15 @@ public class MapLogic {
int uid = session.getUid();
User user = UserManager.getUser(uid);
MapManager mapManager = user.getMapManager();
SChallengeSetting sChallengeSetting = SChallengeSetting.challengeSetting;
if (mapManager.getBuyFightCount() + buyCount > sChallengeSetting.getLimit()) {
LOGGER.info("buyFightCount over max count: {}", (mapManager.getBuyFightCount() + buyCount));
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
// TODO 购买上限
// SVipLevelConfig sVipLevelConfig = SVipLevelConfig.getsVipLevelConfigMap().get(user.getPlayerInfoManager().getVipLevel());
// if (mapManager.getBuyFightCount() + buyCount > sChallengeSetting.getLimit()) {
// LOGGER.info("buyFightCount over max count: {}", (mapManager.getBuyFightCount() + buyCount));
// MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
// return;
// }
int needGem = 0;
SChallengeSetting sChallengeSetting = SChallengeSetting.challengeSetting;
for (int i = 1; i < buyCount; i++) {
mapManager.setBuyFightCount(mapManager.getBuyFightCount() + 1);
needGem += MathUtils.calABX(mapManager.getBuyFightCount(), sChallengeSetting.getCost());
@ -1297,6 +1460,8 @@ public class MapLogic {
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
int dayFightCount = mapManager.getDayFightCount();
mapManager.setDayFightCount(dayFightCount - buyCount < 0 ? 0 : dayFightCount - buyCount);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true);
}
@ -1307,7 +1472,7 @@ public class MapLogic {
* @param messageType
*/
public void sweep(ISession session, int mapId, int count, MessageTypeProto.MessageType messageType) throws Exception {
if (count <= 0 || count>= 100) {
if (count <= 0 || count >= 100) {
count = 1;
}
int uid = session.getUid();
@ -1326,7 +1491,7 @@ public class MapLogic {
}
SChallengeSetting sChallengeSetting = SChallengeSetting.challengeSetting;
if (mapManager.getDayFightCount() + count > sChallengeSetting.getLimit()) {
LOGGER.info("sweep over max count: {}", (mapManager.getBuyFightCount() + count));
LOGGER.info("sweep over max count: {}", (mapManager.getDayFightCount() + count));
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
@ -1377,6 +1542,16 @@ public class MapLogic {
}
MapInfoProto.getAllLevelDifficultyInfosResponse.Builder builder = MapInfoProto.getAllLevelDifficultyInfosResponse.newBuilder();
builder.addAllLevelDifficultyInfos(levelDifficultyInfos);
Map<Integer, CrossInfo> crossInfoMap = user.getMapManager().getCrossInfoMap();
for (Map.Entry<Integer, CrossInfo> entry : crossInfoMap.entrySet()) {
CommonProto.MapInfo mapInfo = CommonProto.MapInfo
.newBuilder()
.setMapId(entry.getKey())
.setLeastTime(entry.getValue().getLeastTime())
.addAllStars(entry.getValue().getStars())
.build();
builder.addMapInfos(mapInfo);
}
MessageUtil.sendMessage(iSession,1, msgId,builder.build(),true);
}
@ -1627,4 +1802,31 @@ public class MapLogic {
}
}
public void gmCrossFight (int uid, int arrayMapId) throws Exception {
User user = UserManager.getUser(uid);
if (user == null || user.getMapManager() == null) {
return;
}
MapManager mapManager = user.getMapManager();
Map<Integer, CrossInfo> crossInfoMap = mapManager.getCrossInfoMap();
for (int i = 100; i <= arrayMapId; i++) {
SChallengeMapConfig sChallengeMapConfig = SChallengeMapConfig.integerSChallengeMapConfigMap.get(i);
if (sChallengeMapConfig == null) {
continue;
}
CrossInfo crossInfo = crossInfoMap.get(i);
if (crossInfo == null) {
crossInfo = new CrossInfo();
}
crossInfo.getStars().add(STAR_1);
crossInfo.getStars().add(STAR_2);
crossInfo.getStars().add(STAR_3);
crossInfoMap.put(i, crossInfo);
mapManager.updateCrossInfoMap(i, crossInfo);
}
}
}

View File

@ -142,7 +142,7 @@ public class BehaviorUtil {
* @param teamId
* @return
*/
private static CommonProto.FightTeamInfo getFightTeamInfo(User user, int teamId) {
public static CommonProto.FightTeamInfo getFightTeamInfo(User user, int teamId) {
List<CommonProto.FightUnitInfo> heroFightInfos = new ArrayList<>();
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) {