战斗修改
parent
60db6c0005
commit
04c60c2ac9
|
@ -15,6 +15,11 @@ public class RedisKey {
|
|||
*/
|
||||
public static final String USER_SERVER_INFO = "JL_USER_SERVER_INFO";
|
||||
|
||||
/**
|
||||
* 战斗准备
|
||||
*/
|
||||
public static final String FIGHT_READY = "FIGHT_READY";
|
||||
|
||||
/**
|
||||
* 战斗缓存
|
||||
*/
|
||||
|
|
|
@ -653,14 +653,23 @@ public class MapLogic {
|
|||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
int[] option = sEventPointConfig.getOption();
|
||||
if (option == null) {
|
||||
LOGGER.info("option == null sEventPointConfig.getId()=>{}", sEventPointConfig.getId());
|
||||
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;
|
||||
if (fightReady != null) {
|
||||
RedisUtil.getInstence().del(fightReadyKey);
|
||||
groupId = Integer.parseInt(fightReady);
|
||||
} 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];
|
||||
}
|
||||
FightInfoProto.FightStartResponse.Builder fightStartResponse = FightInfoProto.FightStartResponse.newBuilder();
|
||||
// BehaviorUtil.getFightInfo(user, option[0], fightStartResponse);
|
||||
BehaviorUtil.getFightInfo(user, groupId, fightStartResponse);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightStartResponse.build(), true);
|
||||
}
|
||||
|
||||
|
@ -673,7 +682,6 @@ public class MapLogic {
|
|||
public void endFight(ISession session, String frames, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
|
||||
String key = RedisKey.getKey(RedisKey.FIGHT, user.getId() , false);
|
||||
Map<Object , Object> valueMap = RedisUtil.getInstence().hmget(key);
|
||||
if (valueMap == null || valueMap.isEmpty()) {
|
||||
|
|
|
@ -3,7 +3,6 @@ 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.FightInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.ljsd.jieling.logic.dao.root.User;
|
|||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
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.CBean2Proto;
|
||||
|
@ -74,19 +75,26 @@ public class BehaviorUtil {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static void fightReady(String uid, int groupId) {
|
||||
String key = RedisKey.getKey(RedisKey.FIGHT_READY, uid, false);
|
||||
RedisUtil.getInstence().set(key, Integer.toString(groupId), RedisKey.EXPIRE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取战斗数据
|
||||
* @param user
|
||||
* @param groupId
|
||||
* @param eventUpdateResponse
|
||||
* @param fightStartRespons
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void getFightInfo(User user, int groupId, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
public static void getFightInfo(User user, int groupId, FightInfoProto.FightStartResponse.Builder fightStartRespons) throws Exception {
|
||||
MapManager mapManager = user.getMapManager();
|
||||
|
||||
int teamId = mapManager.getTeamId();
|
||||
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
|
||||
List<CommonProto.FightUnitInfo> heroFightInfos = new ArrayList<>();
|
||||
CommonProto.FightData.Builder fightData = CommonProto.FightData.newBuilder();
|
||||
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) {
|
||||
Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId());
|
||||
if (hero == null || hero.getCurHp() == 0) {
|
||||
|
@ -107,7 +115,7 @@ public class BehaviorUtil {
|
|||
.addAllFightUnitList(heroFightInfos)
|
||||
.setTeamSkillList(HeroLogic.getInstance().getPokenmonSkills(user,teamId))
|
||||
.build();
|
||||
eventUpdateResponse.setHeroFightInfos(fightTeamInfo);
|
||||
fightData.setHeroFightInfos(fightTeamInfo);
|
||||
|
||||
//monster
|
||||
List<CommonProto.FightUnitInfo> monsterByGroup = MonsterUtil.getMonsterByGroup(groupId);
|
||||
|
@ -119,11 +127,13 @@ public class BehaviorUtil {
|
|||
.setTeamSkillList(monsterTeamSkill)
|
||||
.build();
|
||||
monsterGroupList.add(monsterTeamInfo);
|
||||
eventUpdateResponse.addAllMonsterList(monsterGroupList);
|
||||
fightData.addAllMonsterList(monsterGroupList);
|
||||
|
||||
//设置战斗随机种子
|
||||
int seed = (int)(System.currentTimeMillis()/1000);
|
||||
eventUpdateResponse.setFightSeed(seed);
|
||||
fightData.setFightSeed(seed);
|
||||
fightStartRespons.setFightData(fightData);
|
||||
|
||||
String key = RedisKey.getKey(RedisKey.FIGHT, user.getId(), false);
|
||||
Map<String,Object> fightInfo = new HashMap<>();
|
||||
|
||||
|
@ -134,8 +144,8 @@ public class BehaviorUtil {
|
|||
RedisUtil.getInstence().hmset(key, fightInfo, RedisKey.EXPIRE_TIME);
|
||||
|
||||
|
||||
ISession session = OnlineUserManager.getSessionByUid(Integer.parseInt(user.getId()));
|
||||
MapLogic.getInstance().endFight(session,"", MessageTypeProto.MessageType.FIGHT_END_RESPONSE);
|
||||
// ISession session = OnlineUserManager.getSessionByUid(Integer.parseInt(user.getId()));
|
||||
// MapLogic.getInstance().endFight(session,"", MessageTypeProto.MessageType.FIGHT_END_RESPONSE);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ public class FightAndDestroyPointBehavior extends BaseBehavior {
|
|||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse);
|
||||
BehaviorUtil.getFightInfo(user, behaviorTypeValues[0][1], eventUpdateResponse);
|
||||
BehaviorUtil.fightReady(user.getId(), behaviorTypeValues[0][1]);
|
||||
BehaviorUtil.distoryPoint(user, behaviorTypeValues[0][2]);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class FightBehavior extends BaseBehavior {
|
|||
|
||||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
BehaviorUtil.getFightInfo(user, behaviorTypeValues[0][0], eventUpdateResponse);
|
||||
BehaviorUtil.fightReady(user.getId(), behaviorTypeValues[0][0]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue