兽潮快速战斗
parent
6f1972e902
commit
0758d2da32
|
@ -304,7 +304,7 @@ public class HandlerLogicThread extends Thread{
|
||||||
int type = sGlobalSystemConfig.getOpenRules()[0];
|
int type = sGlobalSystemConfig.getOpenRules()[0];
|
||||||
int condition = sGlobalSystemConfig.getOpenRules()[1];
|
int condition = sGlobalSystemConfig.getOpenRules()[1];
|
||||||
if (type ==1){
|
if (type ==1){
|
||||||
if (mainLevelManager.getFightId()>condition) {
|
if (mainLevelManager.getFightId()<condition) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else if(type == 2){
|
}else if(type == 2){
|
||||||
|
|
|
@ -2319,7 +2319,7 @@ public class MapLogic {
|
||||||
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
|
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
|
||||||
LuaValue getOptionData = FightDataUtil.getOptionData(frames);
|
LuaValue getOptionData = FightDataUtil.getOptionData(frames);
|
||||||
|
|
||||||
int[] checkResult = CheckFight.getInstance().checkFight(seed, sFloodConfig.getBattleTime(), getFightData, getOptionData,FightType.MapExploreFight);
|
int[] checkResult = CheckFight.getInstance().checkFight(seed, sFloodConfig.getBattleTime(), getFightData, getOptionData,FightType.MonterFight);
|
||||||
|
|
||||||
//校验结果码 1:胜利
|
//校验结果码 1:胜利
|
||||||
int resultCode = checkResult[0];
|
int resultCode = checkResult[0];
|
||||||
|
|
|
@ -0,0 +1,142 @@
|
||||||
|
package com.ljsd.jieling.handler.monsterAttack;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.config.SFloodConfig;
|
||||||
|
import com.ljsd.jieling.db.redis.RedisKey;
|
||||||
|
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||||
|
import com.ljsd.jieling.exception.LogicException;
|
||||||
|
import com.ljsd.jieling.globals.BIReason;
|
||||||
|
import com.ljsd.jieling.globals.Global;
|
||||||
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
|
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||||
|
import com.ljsd.jieling.ktbeans.KTGameType;
|
||||||
|
import com.ljsd.jieling.ktbeans.KtEventUtils;
|
||||||
|
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
||||||
|
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
|
||||||
|
import com.ljsd.jieling.logic.dao.UserManager;
|
||||||
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
|
import com.ljsd.jieling.logic.fight.CheckFight;
|
||||||
|
import com.ljsd.jieling.logic.fight.FightType;
|
||||||
|
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.protocols.CommonProto;
|
||||||
|
import com.ljsd.jieling.protocols.FightInfoProto;
|
||||||
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
|
import com.ljsd.jieling.util.FightDataUtil;
|
||||||
|
import com.ljsd.jieling.util.ItemUtil;
|
||||||
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
|
import com.ljsd.jieling.util.MonsterUtil;
|
||||||
|
import org.luaj.vm2.LuaValue;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: 兽潮快速战斗
|
||||||
|
* Author: zsx
|
||||||
|
* CreateDate: 2019/10/8 14:05
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class QuickStartMonsterFighter extends BaseHandler<FightInfoProto.QuickStartMonsterFightRequest> {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(QuickStartMonsterFighter.class);
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.QUICK_START_MONSTERFIGHTER_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processWithProto(ISession iSession, FightInfoProto.QuickStartMonsterFightRequest proto) throws Exception {
|
||||||
|
|
||||||
|
int fightId = proto.getFightId();
|
||||||
|
int teamId = proto.getTeamId();
|
||||||
|
int uid = iSession.getUid();
|
||||||
|
User user = UserManager.getUser(uid);
|
||||||
|
if(user.getMapManager().getLastMonsterAttack()!=fightId){
|
||||||
|
LOGGER.info("endFight() uid=>{} fightId=>{} oldfightId=>{} SLevelDifficultyConfig == null", uid, fightId, user.getMapManager().getLastMonsterAttack(),teamId);
|
||||||
|
MessageUtil.sendErrorResponse(iSession, 0,MessageTypeProto.MessageType.QUICK_START_MONSTERFIGHTER_REPONSE_VALUE , "fightId 有误");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SFloodConfig sFloodConfig =SFloodConfig.getsFloodConfigMap().get(fightId);
|
||||||
|
if (sFloodConfig == null) {
|
||||||
|
LOGGER.info("endFight() uid=>{} fightId=>{} SLevelDifficultyConfig == null", uid, fightId);
|
||||||
|
MessageUtil.sendErrorResponse(iSession, 0, MessageTypeProto.MessageType.QUICK_START_MONSTERFIGHTER_REPONSE_VALUE, "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int[][] cost = new int[1][];
|
||||||
|
int[] temp = new int[2];
|
||||||
|
temp[0] = Global.DROP;
|
||||||
|
temp[1] = 1;
|
||||||
|
cost[0] = temp;
|
||||||
|
boolean flag = ItemUtil.fightItemCost(user, cost);
|
||||||
|
if (!flag) {
|
||||||
|
MessageUtil.sendErrorResponse(iSession, 0, MessageTypeProto.MessageType.QUICK_START_MONSTERFIGHTER_REPONSE_VALUE, "道具不足");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
|
||||||
|
if (teamPosHeroInfos == null || teamPosHeroInfos.size() == 0) {
|
||||||
|
LOGGER.info("startLevelDifficultyFight==> uid={},fightId={},teamId={}", uid, fightId, teamId);
|
||||||
|
MessageUtil.sendErrorResponse(iSession, 0, MessageTypeProto.MessageType.QUICK_START_MONSTERFIGHTER_REPONSE_VALUE, "阵容有误!!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
KtEventUtils.onKtEvent(user, ParamEventBean.UserGameType, KTGameType.CHALLENGE_MONSTERATTACK.getIndex(), fightId);
|
||||||
|
user.getUserMissionManager().onGameEvent(user, GameEvent.MONSTER_ATTACK_PLAY);
|
||||||
|
|
||||||
|
|
||||||
|
int groupId = sFloodConfig.getMonster();
|
||||||
|
CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(user, teamId, true);
|
||||||
|
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 mostTime = sFloodConfig.getBattleTime();
|
||||||
|
|
||||||
|
int[] checkResult = CheckFight.getInstance().checkFight(seed, mostTime, getFightData, getOptionData, FightType.MonterFight);
|
||||||
|
|
||||||
|
//校验结果码 1:胜利
|
||||||
|
int resultCode = checkResult[0];
|
||||||
|
if (resultCode == -1) {
|
||||||
|
ItemUtil.itemCost(user,cost, BIReason.MONSTERATTACK_CONSUME, fightId);
|
||||||
|
MessageUtil.sendErrorResponse(iSession, 0, MessageTypeProto.MessageType.QUICK_START_MONSTERFIGHTER_REPONSE_VALUE, "战斗异常!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resultCode == 0) {
|
||||||
|
ItemUtil.itemCost(user,cost, BIReason.MONSTERATTACK_CONSUME, fightId);
|
||||||
|
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
|
||||||
|
FightInfoProto.QuickStartMonsterFightResponse builder = FightInfoProto.QuickStartMonsterFightResponse.newBuilder()
|
||||||
|
.setResult(resultCode)
|
||||||
|
.setEnventDrop(dropBuilder)
|
||||||
|
.build();
|
||||||
|
MessageUtil.sendMessage(iSession, 1,MessageTypeProto.MessageType.QUICK_START_MONSTERFIGHTER_REPONSE_VALUE, builder, true);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
//排行榜
|
||||||
|
String rankKey = RedisKey.getKey(RedisKey.MONSTER_ATTACK_RANK,"", false);
|
||||||
|
RedisUtil.getInstence().zsetAddOneOffsetByTime(rankKey, String.valueOf(user.getId()), fightId);
|
||||||
|
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sFloodConfig.getReward(), BIReason.MONSTERATTACK_REWARD);
|
||||||
|
|
||||||
|
FightInfoProto.QuickStartMonsterFightResponse builder = FightInfoProto.QuickStartMonsterFightResponse.newBuilder()
|
||||||
|
.setResult(resultCode)
|
||||||
|
.setEnventDrop(drop)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
user.getMapManager().setLastMonsterAttack(fightId + 1);
|
||||||
|
user.getUserMissionManager().onGameEvent(user,GameEvent.MONSTER_ATTACK_LEVEL);
|
||||||
|
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.QUICK_START_MONSTERFIGHTER_REPONSE_VALUE, builder, true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ public enum FightType {
|
||||||
AdventureLock(5), // 解锁秘境
|
AdventureLock(5), // 解锁秘境
|
||||||
GuildFight(6), // 公会站
|
GuildFight(6), // 公会站
|
||||||
BloodyFight(7), // 血战
|
BloodyFight(7), // 血战
|
||||||
|
MonterFight(8), // 兽潮
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in New Issue