关卡降低战力

master_otnew
PC-202302260912\Administrator 2023-12-05 14:00:24 +08:00
parent e98e3ea8d1
commit fb8428d254
10 changed files with 348 additions and 137 deletions

View File

@ -92,25 +92,14 @@ public class RedisKey {
public static final String SUDDLENLY_FIGHT = "SUDDLENLY_FIGHT";
public static final String CHALLENGE_MONSTER_ATTACK = "CHALLENGE_MONSTER_ATTACK";
public static final String CHALLENGE_EXPEDITION_INFO = "CHALLENGE_EXPEDITION_INFO";
public static final String ARENA_RRECORD = "ARENA_RRECORD";
public static final String ADVENTRUEN_BOSS_OWN = "ADVENTRUEN_BOSS_OWN";
public static final String ADVENTRUEN_BOSS_INFO = "ADVENTRUEN_BOSS_INFO";
public static final String ADVENTRUEN_BOSS_HURT_DETAIL = "ADVENTRUEN_BOSS_HURT_DETAIL";
public static final String ADVENTRUEN_BOSS_CHALLENGE_LOCK_KEY = "ADVENTRUEN_BOSS_CHALLENGE_LOCK_KEY";
public static final String CHAT_WORD_MSG_ID = ":ChatWordMsgId:";
public static final String CHAT_SYS_MSG_ID = ":ChatSysMsgId:";
public static final String CHAT_GUILD_MSG_ID = ":ChatGuildMsgId:";
public static final String CHAT_CROSS_MSG_ID = "ChatCrossMsgId:";
public static final String CUser_Chat = ":CUser_Chat:";
@ -393,7 +382,8 @@ public class RedisKey {
public static final String LUOFU_TITLE_REWARD_MARK = "LUOFU_TITLE_REWARD_MARK";// 罗浮称号奖励标记
public static final String First_Recharge = "First_Recharge";// 首充标记
public static final String GEM_DRAW_COUNT_DAY = "GEM_DRAW_COUNT_DAY";// 命格抽卡次数每日
public static final String TRAINING_HERO_RECORD = "TRAINING_HERO_RECORD";// 特训英雄记录
public static final String FIGHT_FAILD_TIME = "FIGHT_FAILD_TIME";//战斗失败时间记录mapKeyFightType类的数字
//进程排行 合区统一
public static Set<String> newAreaCacChe = new HashSet<>();

View File

@ -1336,7 +1336,7 @@ public class RedisUtil {
}
// 保存需要清理的key
saveRemoveKeyHandler(result);
LOGGER.info("获取rediskey{}-{}-{}",type,key,judge);
// LOGGER.info("获取rediskey{}-{}-{}",type,key,judge);
return result;
}

View File

@ -35,13 +35,13 @@ public class FightEndRequestHandler extends BaseHandler {
case 3:
MapLogic.getInstance().endSuddlenlyFight(iSession, frames, MessageTypeProto.MessageType.FIGHT_END_RESPONSE);
break;
case 5:
case 5://心魔
MapLogic.getInstance().endMonsterAttackFight(iSession, frames,MessageTypeProto.MessageType.FIGHT_END_RESPONSE);
break;
case 6://主线
MapLogic.getInstance().endMainLevelFight(iSession, frames, fightEndRequest.getFightId(), MessageTypeProto.MessageType.FIGHT_END_RESPONSE);
break;
case 7:
case 7://公会副本
GuildFightLogic.endBossFight(iSession,frames,MessageTypeProto.MessageType.FIGHT_END_RESPONSE);
break;
default:

View File

@ -1538,7 +1538,9 @@ public class MapLogic {
}
//挑战精英怪
/**
*
*/
public void startSuddlenlyFight(ISession session, int teamId, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
@ -1549,7 +1551,7 @@ public class MapLogic {
return;
}
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
if (teamPosHeroInfos == null || teamPosHeroInfos.size() == 0) {
if (teamPosHeroInfos == null || teamPosHeroInfos.isEmpty()) {
LOGGER.info("startLevelDifficultyFight==> uid={},fightId={},teamId={}", uid, suddenlyBoss, teamId);
throw new ErrorCodeException(ErrorCode.newDefineCode("阵容有误!!"));
}
@ -1559,6 +1561,9 @@ public class MapLogic {
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightStartResponse.build(), true);
}
/**
*
*/
public void endSuddlenlyFight(ISession session, String frames, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
@ -1581,16 +1586,10 @@ public class MapLogic {
}
MessageUtil.sendMessage(session, 1, messageType.getNumber(), builderResponse.build(), true);
}
/**
*
*
* @param iSession
* @param msgId
*/
public void getAllLevelDifficultyInfos(ISession iSession, int msgId) throws Exception {
int uid = iSession.getUid();
@ -1603,6 +1602,14 @@ public class MapLogic {
MessageUtil.sendMessage(iSession, 1, msgId, builder.build(), true);
}
/**
* 线
* @param user
* @param fightId
* @param teamId
* @return
* @throws Exception
*/
public boolean checkMainFight(User user, int fightId, int teamId) throws Exception {
MainLevelManager mainLevelManager = user.getMainLevelManager();
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
@ -1688,6 +1695,50 @@ public class MapLogic {
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightStartResponse.build(), true);
}
/**
* 线
*/
public void endMainLevelFight(ISession session, String frames, int fightId, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
String fightKey = RedisKey.getKey(RedisKey.LEVE_DIFFICULTY_INFO, String.valueOf(uid));
String fightInfos = (String) RedisUtil.getInstence().get(fightKey);
if (StringUtil.isEmpty(fightInfos)) {
LOGGER.info("endFight() uid=>{} fightKey={},fightId={} fightInfos == null", uid, fightKey, fightId);
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
String[] split = fightInfos.split("#");
int checkFightId = Integer.parseInt(split[0]);
if (fightId != checkFightId) {
LOGGER.info("endFight() uid=>{} fightId=>{},checkFightId={}", uid, fightId, checkFightId);
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
LOGGER.info("关卡战斗end{}{}", uid, fightInfos);
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
FightResult fightResult = null;
if (sMainLevelConfig.getPlotId() == 0) {
FightEvent fightEvent = new FightEvent(uid, -1, sMainLevelConfig.getRankTime(), frames, GameFightType.StoryFight);
fightResult = FightDispatcher.dispatcher(fightEvent);
}
//校验结果码 1胜利
if (fightResult != null) {
if (fightResult.getResult() == -1) {
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
} else if (fightResult.getResult() == 0) {
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true);
return;
}
}
FightInfoProto.FightEndResponse.Builder fightEndResponse = FightInfoProto.FightEndResponse.newBuilder();
CommonProto.Drop.Builder drop = mainFightWinHandler(session, fightId);
fightEndResponse.setEnventDrop(drop);
fightEndResponse.setResult(fightResult == null ? 1 : fightResult.getResult());
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true);
}
/**
* 线redis
*/
public void mainFightOfRedis(int uid, int fightId, int teamId){
String fightInfo = fightId + "#" + teamId;
String key = RedisKey.getKey(RedisKey.LEVE_DIFFICULTY_INFO, String.valueOf(uid));
@ -1695,6 +1746,26 @@ public class MapLogic {
LOGGER.info("关卡战斗start{}{}", uid, fightInfo);
}
/**
* 线
*/
public CommonProto.Drop.Builder mainFightWinHandler(ISession session, int fightId) throws Exception {
User user = UserManager.getUser(session.getUid());
// 关卡信息
openNextMainLevel(session, user, fightId);
// 排行榜
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
RankContext.getRankEnum(RankEnum.MAIN_LEVEL_RANK.getType()).addRank(user.getId(), "", sMainLevelConfig.getVirtureId(), user.getPlayerInfoManager().getMaxForce());
// 推送
MainLevelManager mainLevelManager = user.getMainLevelManager();
FightInfoProto.MainLevelFightUpdateIndication build = FightInfoProto.MainLevelFightUpdateIndication.newBuilder().setState(mainLevelManager.getState()).setFightId(mainLevelManager.getFightId()).build();
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.MAIN_LEVEL_FIGHT_UPDATE_INDICATION_VALUE, build, true);
// 打点,现在不用
ReportUtil.onReportEvent(user, ReportEventEnum.PASS_STAGE.getType(), String.valueOf(fightId), "", sMainLevelConfig.getReward(), new Date());
// 奖励道具
return ItemUtil.dropToPrivilege(user, sMainLevelConfig.getReward(), BIReason.LEVELDIFFICULTY_FIGHT_REWARD);
}
/**
*
* 0
@ -1705,11 +1776,6 @@ public class MapLogic {
* 55-10
* 65-10
* 7
*
* @param user
* @param openRule
* @return
* @throws Exception
*/
private boolean checkFigthLevelOpen(User user, int[][] openRule) throws Exception {
boolean isOpen = true;
@ -1793,68 +1859,6 @@ public class MapLogic {
return isOpen;
}
/**
* 线
* @param session
* @param fightId
* @return
* @throws Exception
*/
public CommonProto.Drop.Builder mainFightWinHandler(ISession session, int fightId) throws Exception {
User user = UserManager.getUser(session.getUid());
// 关卡信息
openNextMainLevel(session, user, fightId);
// 排行榜
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
RankContext.getRankEnum(RankEnum.MAIN_LEVEL_RANK.getType()).addRank(user.getId(), "", sMainLevelConfig.getVirtureId(), user.getPlayerInfoManager().getMaxForce());
// 推送
MainLevelManager mainLevelManager = user.getMainLevelManager();
FightInfoProto.MainLevelFightUpdateIndication build = FightInfoProto.MainLevelFightUpdateIndication.newBuilder().setState(mainLevelManager.getState()).setFightId(mainLevelManager.getFightId()).build();
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.MAIN_LEVEL_FIGHT_UPDATE_INDICATION_VALUE, build, true);
// 打点,现在不用
ReportUtil.onReportEvent(user, ReportEventEnum.PASS_STAGE.getType(), String.valueOf(fightId), "", sMainLevelConfig.getReward(), new Date());
// 奖励道具
return ItemUtil.dropToPrivilege(user, sMainLevelConfig.getReward(), BIReason.LEVELDIFFICULTY_FIGHT_REWARD);
}
public void endMainLevelFight(ISession session, String frames, int fightId, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
String fightKey = RedisKey.getKey(RedisKey.LEVE_DIFFICULTY_INFO, String.valueOf(uid));
String fightInfos = (String) RedisUtil.getInstence().get(fightKey);
if (StringUtil.isEmpty(fightInfos)) {
LOGGER.info("endFight() uid=>{} fightKey={},fightId={} fightInfos == null", uid, fightKey, fightId);
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
String[] split = fightInfos.split("#");
int checkFightId = Integer.parseInt(split[0]);
if (fightId != checkFightId) {
LOGGER.info("endFight() uid=>{} fightId=>{},checkFightId={}", uid, fightId, checkFightId);
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
LOGGER.info("关卡战斗end{}{}", uid, fightInfos);
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
FightResult fightResult = null;
if (sMainLevelConfig.getPlotId() == 0) {
FightEvent fightEvent = new FightEvent(uid, -1, sMainLevelConfig.getRankTime(), frames, GameFightType.StoryFight);
fightResult = FightDispatcher.dispatcher(fightEvent);
}
//校验结果码 1胜利
if (fightResult != null) {
if (fightResult.getResult() == -1) {
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
} else if (fightResult.getResult() == 0) {
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true);
return;
}
}
FightInfoProto.FightEndResponse.Builder fightEndResponse = FightInfoProto.FightEndResponse.newBuilder();
CommonProto.Drop.Builder drop = mainFightWinHandler(session, fightId);
fightEndResponse.setEnventDrop(drop);
fightEndResponse.setResult(fightResult == null ? 1 : fightResult.getResult());
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true);
}
public void openNextMainLevel(ISession session, User user, int fightId) throws Exception {
int level = user.getPlayerInfoManager().getLevel();
int state = 1;
@ -1902,17 +1906,14 @@ public class MapLogic {
/**
*
*
* @param session
* @param fightId
*
*/
public void startMonsterAttackFight(ISession session, int fightId, int teamId, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
if (user.getMapManager().getLastMonsterAttack() != fightId) {
LOGGER.info("endFight() uid=>{} fightId=>{} SLevelDifficultyConfig == null", uid, fightId, teamId);
LOGGER.info("endFight() uid=>{} fightId=>{} teamId={} SLevelDifficultyConfig == null", uid, fightId, teamId);
throw new ErrorCodeException(ErrorCode.newDefineCode("fightId 有误"));
}
SFloodConfig sFloodConfig = STableManager.getConfig(SFloodConfig.class).get(fightId);
@ -1921,7 +1922,7 @@ public class MapLogic {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
if (teamPosHeroInfos == null || teamPosHeroInfos.size() == 0) {
if (teamPosHeroInfos == null || teamPosHeroInfos.isEmpty()) {
LOGGER.info("startLevelDifficultyFight==> uid={},fightId={},teamId={}", uid, fightId, teamId);
throw new ErrorCodeException(ErrorCode.newDefineCode("阵容有误!!"));
}
@ -1936,12 +1937,11 @@ public class MapLogic {
BehaviorUtil.getLevelDifficultyifficuFightInfo(user, FightType.MonterFight, sFloodConfig.getMonster(), teamId, sFloodConfig.getBattleTime(), fightStartResponse, RedisKey.CHALLENGE_MONSTER_ATTACK);
user.getUserMissionManager().onGameEvent(user, GameEvent.ONE_MISSION_TYPE_CONSUME,MissionType.JOIN_MONSTER_ATTACK_TIMES);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightStartResponse.build(), true);
// ReportUtil.onReportEvent(user,ReportEventEnum.COMPLETE_XINMO.getType(),fightId,sFloodConfig.getMonster(),MonsterUtil.getMonsterForce(new int[]{sFloodConfig.getMonster()}),"");
}
/**
*
*
*/
public void endMonsterAttackFight(ISession session, String frames, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
@ -1949,7 +1949,7 @@ public class MapLogic {
String fightKey = RedisKey.getKey(RedisKey.CHALLENGE_MONSTER_INFO, String.valueOf(uid));
String fightInfos = (String) RedisUtil.getInstence().get(fightKey);
if (fightInfos == null || fightInfos.isEmpty()) {
LOGGER.info("endFight() uid=>{} fightKey={},fightId={} fightInfos == null", uid, fightKey);
LOGGER.info("endFight() uid=>{} fightKey={} fightInfos == null", uid, fightKey);
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
RedisUtil.getInstence().del(fightKey);

View File

@ -18,6 +18,7 @@ import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.FightRecordLogic;
import com.ljsd.jieling.logic.fight.FightUtil;
import com.ljsd.jieling.logic.fight.eventhandler.MainLineOrInnerDemonFightHandler;
import com.ljsd.jieling.logic.help.HelpHero;
import com.ljsd.jieling.logic.help.HelpHeroLogic;
import com.ljsd.jieling.logic.hero.HeroLogic;
@ -339,7 +340,6 @@ public class BehaviorUtil {
/**
*
* @param user
*/
public static void destoryCurPoint(User user) throws Exception {
MapManager mapManager = user.getMapManager();
@ -353,8 +353,6 @@ public class BehaviorUtil {
/**
* eventId
* @param user
* @throws Exception
*/
public static void changeOtherPoint(User user, int pointId, int eventId) throws Exception {
Map<Integer, Cell> mapInfo = user.getMapManager().getMapInfo();
@ -366,12 +364,16 @@ public class BehaviorUtil {
}
}
/**
*
*/
public static void getLevelDifficultyifficuFightInfo(User user,FightType fightType,int groupId,int teamId, int maxTime,FightInfoProto.FightStartResponse.Builder fightStartRespons,String fightKey) {
CommonProto.FightData.Builder fightData = CommonProto.FightData.newBuilder();
CommonProto.FightTeamInfo fightTeamInfo = getFightTeamInfo(user, teamId,true);
fightData.setHeroFightInfos(fightTeamInfo);
//monster
Map<Integer, List<CommonProto.FightUnitInfo>> monsterByGroup = MonsterUtil.getMonsterByGroup(groupId);
Map<Integer, List<CommonProto.FightUnitInfo>> monsterByGroup = MainLineOrInnerDemonFightHandler.getMonsterByGroup(user.getId(), groupId, fightType.getType());
List<CommonProto.FightUnitInfo> monsterPokemonByGroup = MonsterUtil.getMonsterPokemonByGroup(groupId);
List<CommonProto.FightTeamInfo> monsterGroupList = getFightTeamInfos(monsterByGroup,monsterPokemonByGroup,0);
List<CommonProto.FightTeamInfo> monsterGroupList1 = getFightTeamInfos(monsterByGroup,monsterPokemonByGroup,1);
@ -387,16 +389,16 @@ public class BehaviorUtil {
fightStartRespons.setFightData(fightData);
// 记录战报
FightRecordLogic.getInstance().addRecordMap(user,fightData.build());
// FightRecordLogic.getInstance().addRecordMap(user,fightData.build());
String key = RedisKey.getKey(fightKey,Integer.toString(user.getId()));
Map<String,Object> fightInfo = new HashMap<>();
fightInfo.put(RedisKey.FIGHT_HEROES, JsonFormat.printToString(fightTeamInfo));
fightInfo.put(RedisKey.FIGHT_MONSTERS_1, JsonFormat.printToString(monsterGroupList.get(0)));
if (monsterGroupList1.size() != 0){
if (!monsterGroupList1.isEmpty()){
fightInfo.put(RedisKey.FIGHT_MONSTERS_2, JsonFormat.printToString(monsterGroupList1.get(0)));
}
if (monsterGroupList2.size() != 0){
if (!monsterGroupList2.isEmpty()){
fightInfo.put(RedisKey.FIGHT_MONSTERS_3, JsonFormat.printToString(monsterGroupList2.get(0)));
}
fightInfo.put(RedisKey.FIGHT_SEED,Integer.toString(seed));
@ -423,29 +425,25 @@ public class BehaviorUtil {
/**
*
* @param valueMap
* @return
* @throws JsonFormat.ParseException
*/
public static List<CommonProto.FightTeamInfo> getFightTeamInfos(Map<Object, Object> valueMap) throws JsonFormat.ParseException {
List<CommonProto.FightTeamInfo> monsterTeamList = new ArrayList<>();
CommonProto.FightTeamInfo.Builder monsterBuilder = CommonProto.FightTeamInfo.newBuilder();
JsonFormat.merge((String)valueMap.get(RedisKey.FIGHT_MONSTERS_1), monsterBuilder);
CommonProto.FightTeamInfo monsterTeam = monsterBuilder.build();
monsterTeamList.add(monsterTeam);
monsterTeamList.add(monsterBuilder.build());
String info = (String)valueMap.get(RedisKey.FIGHT_MONSTERS_2);
if (info !=null){
if (info != null){
CommonProto.FightTeamInfo.Builder monsterBuilder1 = CommonProto.FightTeamInfo.newBuilder();
JsonFormat.merge(info, monsterBuilder1);
CommonProto.FightTeamInfo monsterTeam1 = monsterBuilder1.build();
monsterTeamList.add(monsterTeam1);
monsterTeamList.add(monsterBuilder1.build());
}
String info1 = (String)valueMap.get(RedisKey.FIGHT_MONSTERS_3);
if (info1!= null){
if (info1 != null){
CommonProto.FightTeamInfo.Builder monsterBuilder2 = CommonProto.FightTeamInfo.newBuilder();
JsonFormat.merge(info1, monsterBuilder2);
CommonProto.FightTeamInfo monsterTeam2 = monsterBuilder2.build();
monsterTeamList.add(monsterTeam2);
monsterTeamList.add(monsterBuilder2.build());
}
return monsterTeamList;
}

View File

@ -18,13 +18,13 @@ import com.ljsd.jieling.logic.fight.eventhandler.*;
*
*/
public enum GameFightType {
StoryFight(FightType.StoryFight,new DefaultOfRedisCacheFightHandler(), RedisKey.LEVE_DIFFICULTY_FIGHT),
StoryFight(FightType.StoryFight,new MainLineOrInnerDemonFightHandler(), RedisKey.LEVE_DIFFICULTY_FIGHT),
MapFastFight(FightType.MapExploreFight,new DefaultWithoutHandFightHandler(),null),
MapEndFight(FightType.MapExploreFight,new DefaultOfRedisCacheFightHandler(),RedisKey.FIGHT),
EndSuddlenlyFight(FightType.MapExploreFight,new DefaultOfRedisCacheFightHandler(),RedisKey.SUDDLENLY_FIGHT),
EndMonsterAttackFight(FightType.MapExploreFight,new DefaultOfRedisCacheFightHandler(),RedisKey.CHALLENGE_MONSTER_ATTACK),
EndMonsterAttackFight(FightType.MapExploreFight,new MainLineOrInnerDemonFightHandler(),RedisKey.CHALLENGE_MONSTER_ATTACK),
ArenaPersonFight(FightType.ArenaFight,new PVPFightHandler(),null),
ArenaRobotFight(FightType.ArenaFight,new PVPFightHandler(),null),

View File

@ -16,7 +16,6 @@ import org.luaj.vm2.LuaValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rpc.protocols.CommonProto;
import util.TimeUtils;
import java.util.ArrayList;
import java.util.HashMap;
@ -32,7 +31,7 @@ public class DuoduiTowerFightHandler implements IFightEventProcesor {
@Override
public FightResult process(FightEvent fightEvent) throws Exception {
long now = TimeUtils.now();
// long now = TimeUtils.now();
PVEFightEvent pveFightEvent = (PVEFightEvent)fightEvent;
User user = UserManager.getUserNotCache(pveFightEvent.getAttackUid());
if (user == null){
@ -65,8 +64,6 @@ public class DuoduiTowerFightHandler implements IFightEventProcesor {
/**
*
* @param indexId
* @return
*/
private static List<CommonProto.FightTeamInfo> makeMonsterFightData(int indexId){
SDuoDuiTower tower = SDuoDuiTower.towerMap.get(indexId);
@ -83,8 +80,6 @@ public class DuoduiTowerFightHandler implements IFightEventProcesor {
/**
*
* @param tower
* @return
*/
public static Map<Integer, List<CommonProto.FightUnitInfo>> getMonsterByRounds(SDuoDuiTower tower){
List<CommonProto.FightUnitInfo> monsterMap = new ArrayList<>();

View File

@ -0,0 +1,155 @@
package com.ljsd.jieling.logic.fight.eventhandler;
import com.googlecode.protobuf.format.JsonFormat;
import com.ljsd.fight.CheckFight;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
import com.ljsd.jieling.logic.fight.FightEvent;
import com.ljsd.jieling.logic.fight.FightUtil;
import com.ljsd.jieling.logic.fight.GameFightType;
import com.ljsd.jieling.logic.fight.result.FightResult;
import com.ljsd.jieling.util.CBean2Proto;
import com.ljsd.jieling.util.FightDataUtil;
import config.SMonsterConfig;
import config.SMonsterGroup;
import config.SSpecialConfig;
import manager.STableManager;
import org.luaj.vm2.LuaValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rpc.protocols.CommonProto;
import util.TimeUtils;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* 线
*/
public class MainLineOrInnerDemonFightHandler implements IFightEventProcesor {
private static final Logger LOGGER = LoggerFactory.getLogger(DuoduiTowerFightHandler.class);
@Override
public FightResult process(FightEvent fightEvent) throws Exception {
GameFightType fightType = fightEvent.getFightType();
int playerId = fightEvent.getAttackUid();
int fightTime = fightEvent.getMostTime();
String key = RedisKey.getKey(fightType.getFightTypeOfRedis(), Integer.toString(playerId));
Map<Object, Object> valueMap = RedisUtil.getInstence().hmget(key);
if (valueMap == null || valueMap.isEmpty()) {
throw new ErrorCodeException(ErrorCode.newDefineCode("此战斗已结算过 !"));
}
RedisUtil.getInstence().del(key);
int seed = Integer.parseInt((String) valueMap.get(RedisKey.FIGHT_SEED));
CommonProto.FightTeamInfo.Builder builder = CommonProto.FightTeamInfo.newBuilder();
JsonFormat.merge((String) valueMap.get(RedisKey.FIGHT_HEROES), builder);
CommonProto.FightTeamInfo fightTeamInfo = builder.build();
List<CommonProto.FightTeamInfo> monsterTeamList = BehaviorUtil.getFightTeamInfos(valueMap);
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
LuaValue getOptionData = FightDataUtil.getOptionData(String.valueOf(playerId));
FightResult.Builder fightResult = FightResult.newBuilder();
long[] fightResultInfo = CheckFight.getInstance().checkFight(seed, fightTime, getFightData, getOptionData, fightType.getFightType());
fightResult.setCheckResult(fightResultInfo);
String fightId = FightUtil.getFightId(playerId, fightType);
CommonProto.FightData fightData = CommonProto.FightData.newBuilder()
.setFightType(fightType.getFightType().getType())
.setHeroFightInfos(fightTeamInfo)
.addAllMonsterList(monsterTeamList)
.setFightSeed(seed)
.setFightMaxTime(fightTime)
.setFightId(fightId)
.build();
fightResult.setFightData(fightData);
FightResult result = fightResult.build();
if (result.getResult() == 1){
// 成功清除时间
setFailTime(playerId, fightType.getFightType().getType(), 0);
}else {
// 失败记录时间
setFailTime(playerId, fightType.getFightType().getType(), TimeUtils.nowInt());
}
return result;
}
/**
* 0
*/
public static int getFailTime(int uid, int type){
// redis记录key
String keyNew = RedisUtil.getInstence().getKeyNew(RedisKey.FIGHT_FAILD_TIME, String.valueOf(type));
// 首次失败时间
return Optional.ofNullable(RedisUtil.getInstence().getmapvalue(keyNew, String.valueOf(uid), Integer.class)).orElse(0);
}
/**
* 0
*/
public static void setFailTime(int uid, int type, int time){
int failTime = getFailTime(uid, type);
if (failTime != 0){
return;
}
// redis记录key
String keyNew = RedisUtil.getInstence().getKeyNew(RedisKey.FIGHT_FAILD_TIME, String.valueOf(type));
// 首次失败时间
RedisUtil.getInstence().putmap(keyNew, String.valueOf(uid), time);
}
/**
*
*/
public static double getDownNum(int uid, int type){
// 耗时(分)/ 减少比例
int[] timeDowns = SSpecialConfig.getIntegerArrayValue("Level_Time_Down");
// 最大减少比例
int maxDown = SSpecialConfig.getIntegerValue("Level_Time_Maxdown");
// 失败时间
int failTime = getFailTime(uid, type);
// 按照分钟计算减免系数
int minutesTime = failTime / 1000 / timeDowns[0];
// 万分比
double downTime = 1 - (Math.min(minutesTime * timeDowns[1], maxDown) / 10000d);
LOGGER.info("关卡挑战战力降低日志uid{},类型:{},系数:{}",uid, type, downTime);
return downTime;
}
/**
*
*/
public static Map<Integer, List<CommonProto.FightUnitInfo>> getMonsterByGroup(int uid, int groupId, int type){
SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(groupId);
Map<Integer, List<CommonProto.FightUnitInfo>> map = new ConcurrentHashMap<>();
if(sMonsterGroup==null){
LOGGER.info("{}怪物组为空",groupId);
return map;
}
int[][] groupIds = sMonsterGroup.getContents();
for (int i = 0; i < groupIds.length; i++) {
int[] monsterIds = groupIds[i];
List<CommonProto.FightUnitInfo> monsterList = new CopyOnWriteArrayList<>();
int position = 1;
for (int monsterId : monsterIds) {
if(monsterId !=0 ){
SMonsterConfig sMonsterConfig = STableManager.getConfig(SMonsterConfig.class).get(monsterId);
CommonProto.FightUnitInfo.Builder monster = CBean2Proto.getMonster(sMonsterConfig, sMonsterConfig.getHp(), uid, type);
monster.setPosition(position++);
monsterList.add(monster.build());
}else{
position++;
}
}
map.put(i,monsterList);
}
return map;
}
}

View File

@ -15,6 +15,7 @@ import com.ljsd.jieling.logic.dao.cross.CSPlayer;
import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.CombatLogic;
import com.ljsd.jieling.logic.fight.eventhandler.MainLineOrInnerDemonFightHandler;
import com.ljsd.jieling.logic.help.HelpHero;
import com.ljsd.jieling.logic.help.HelpHeroLogic;
import com.ljsd.jieling.logic.help.HelpTypeEnum;
@ -496,6 +497,22 @@ public class CBean2Proto {
.build();
}
public static CommonProto.FightUnitInfo.Builder getMonster(SMonsterConfig sMonsterConfig, SHardStage nodeConfig) {
CommonProto.FightUnitInfo.Builder monster = getMonster(sMonsterConfig, sMonsterConfig.getHp());
StringBuilder skillIds = new StringBuilder(monster.getUnitSkillIds());
if(nodeConfig.getHardStageBuff() != 0){
SHardStageBuff buff = SHardStageBuff.getConfigMap().get(nodeConfig.getHardStageBuff());
if(buff.getType()==1 || buff.getType()==3){
skillIds.append(buff.getPassiveSkillLogic()).append("#");
}
}
monster.setUnitSkillIds(skillIds.toString());
return monster;
}
/**
*
*/
public static CommonProto.FightUnitInfo.Builder getMonster(SMonsterConfig sMonsterConfig, long curHp) {
StringBuilder monsterPropertyList = new StringBuilder();
StringBuilder monsterSkillList = new StringBuilder(); //火风水地光暗
@ -555,19 +572,78 @@ public class CBean2Proto {
return monsterBuilder;
}
public static CommonProto.FightUnitInfo.Builder getMonster(SMonsterConfig sMonsterConfig, SHardStage nodeConfig) {
CommonProto.FightUnitInfo.Builder monster = getMonster(sMonsterConfig, sMonsterConfig.getHp());
StringBuilder skillIds = new StringBuilder(monster.getUnitSkillIds());
if(nodeConfig.getHardStageBuff() != 0){
SHardStageBuff buff = SHardStageBuff.getConfigMap().get(nodeConfig.getHardStageBuff());
if(buff.getType()==1 || buff.getType()==3){
skillIds.append(buff.getPassiveSkillLogic()).append("#");
/**
* 线
*/
public static CommonProto.FightUnitInfo.Builder getMonster(SMonsterConfig sMonsterConfig, long curHp, int uid, int type) {
StringBuilder monsterPropertyList = new StringBuilder();
StringBuilder monsterSkillList = new StringBuilder(); //火风水地光暗
float[] damageReduceFactor = sMonsterConfig.getElementDamageReduceFactor();
monsterPropertyList.append(sMonsterConfig.getLevel()).append("#"); //等级
monsterPropertyList.append(curHp).append("#"); //生命
// 减免系数
double downNum = MainLineOrInnerDemonFightHandler.getDownNum(uid, type);
// 只减免前这四项
monsterPropertyList.append(Math.round(sMonsterConfig.getHp() * downNum)).append("#"); //最大生命
monsterPropertyList.append(Math.round(sMonsterConfig.getAttack() * downNum)).append("#");//攻击力
monsterPropertyList.append(Math.round(sMonsterConfig.getPhysicalDefence() * downNum)).append("#"); //护甲
monsterPropertyList.append(Math.round(sMonsterConfig.getMagicDefence() * downNum)).append("#"); //魔抗
monsterPropertyList.append(sMonsterConfig.getSpeed()).append("#"); //速度
monsterPropertyList.append(sMonsterConfig.getDamageBocusFactor()).append("#"); //伤害加成系数
monsterPropertyList.append(sMonsterConfig.getDamageReduceFactor()).append("#"); //伤害减免系数
monsterPropertyList.append(sMonsterConfig.getHit()).append("#"); //命中率
monsterPropertyList.append(sMonsterConfig.getDodge()).append("#"); //闪避率
monsterPropertyList.append(sMonsterConfig.getCritFactor()).append("#"); //暴击率
monsterPropertyList.append(sMonsterConfig.getCritDamageFactor()).append("#"); //暴击伤害系数
monsterPropertyList.append(sMonsterConfig.getAntiCritDamageFactor()).append("#"); //抗暴率系数
monsterPropertyList.append(sMonsterConfig.getTreatFacter()).append("#"); //治疗加成系数
monsterPropertyList.append(sMonsterConfig.getCureFacter()).append("#"); //受到治疗加成系数
monsterPropertyList.append(sMonsterConfig.getDifferDemonsBocusFactor()).append("#"); //异妖伤害加成系数
monsterPropertyList.append(sMonsterConfig.getDifferDemonsReduceFactor()).append("#"); //异妖伤害减免系数
monsterPropertyList.append(damageReduceFactor[0]).append("#"); //火系伤害减免系数
monsterPropertyList.append(damageReduceFactor[1]).append("#"); //冰系伤害减免系数
monsterPropertyList.append(damageReduceFactor[2]).append("#"); //雷系伤害减免系数
monsterPropertyList.append(damageReduceFactor[3]).append("#"); //风系伤害减免系数
monsterPropertyList.append(damageReduceFactor[4]).append("#"); //地系伤害减免系数
monsterPropertyList.append(damageReduceFactor[5]).append("#"); //暗系伤害减免系数
monsterPropertyList.append(sMonsterConfig.getElementDamageBonusFactor()); //属性值加成
if (sMonsterConfig.getSkillList()!=null){
for (Integer i : sMonsterConfig.getSkillList()){
monsterSkillList.append(i).append("#");
}
}
monster.setUnitSkillIds(skillIds.toString());
return monster;
if (sMonsterConfig.getPassiveSkillList()!=null && sMonsterConfig.getPassiveSkillList().length >0){
int length = monsterSkillList.length();
while(2-length>0){
monsterSkillList.append(0).append("#");
length++;
}
for (Integer i : sMonsterConfig.getPassiveSkillList()){
if(i==0){
continue;
}
monsterSkillList.append(i).append("#");
}
}
CommonProto.FightUnitInfo.Builder monsterBuilder = CommonProto.FightUnitInfo.newBuilder();
monsterBuilder.setProperty(monsterPropertyList.toString());
monsterBuilder.setUnitSkillIds(monsterSkillList.toString());
monsterBuilder.setUnitId(String.valueOf(sMonsterConfig.getId()));
monsterBuilder.setSkinId(sMonsterConfig.getSkinId());
monsterBuilder.setStar(sMonsterConfig.getStar());
monsterBuilder.setPropertyId(sMonsterConfig.getPropertyName());
return monsterBuilder;
}
/**
*
* @param tower
* @param indexId
* @return
*/
@SuppressWarnings("StringBufferReplaceableByString")
public static CommonProto.FightUnitInfo.Builder getMonster(SDuoDuiTower tower, int indexId) {
StringBuilder monsterPropertyList = new StringBuilder();//火风水地光暗

View File

@ -66,7 +66,6 @@ public class MonsterUtil {
}else{
position++;
}
}
}else{
int position=1;
@ -76,7 +75,6 @@ public class MonsterUtil {
}else{
position++;
}
}
}
map.put(i,monsterList);
@ -88,7 +86,6 @@ public class MonsterUtil {
SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(nodeConfig.getMonsterGroup());
int[][] groupIds = sMonsterGroup.getContents();
Map<Integer, List<CommonProto.FightUnitInfo>> map = new ConcurrentHashMap<>();
Map<Integer, CommonProto.FightUnitInfo.Builder> monsterMap =STableManager.getFigureConfig(MapStaticConfig.class).getMonsterMap();
for (int i = 0; i < groupIds.length; i++) {
int[] monsterIds = groupIds[i];
List<CommonProto.FightUnitInfo> monsterList = new ArrayList<>();