fight opti
parent
26309eb920
commit
ad4a55b2ce
|
|
@ -1226,7 +1226,7 @@ public class MapLogic {
|
|||
|
||||
SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(user.getMapManager().getCurMapId());
|
||||
int mostTime = sChallengeConfig.getMostTime();
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(uid, mapManager.getTeamId(), mostTime, "", FightType.MapExploreFight, groupId, 3);
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(uid, mapManager.getTeamId(), mostTime, "", GameFightType.MapFastFight, groupId, 3);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
||||
int[] checkResult = fightResult.getCheckResult();
|
||||
|
||||
|
|
@ -1435,7 +1435,6 @@ public class MapLogic {
|
|||
User user = UserManager.getUser(uid);
|
||||
String key = RedisKey.getKey(RedisKey.FIGHT, Integer.toString(uid), false);
|
||||
Map<Object, Object> valueMap = RedisUtil.getInstence().hmget(key);
|
||||
RedisUtil.getInstence().del(key);
|
||||
if (valueMap == null || valueMap.isEmpty()) {
|
||||
LOGGER.info("endFight() uid=>{} not start fight", uid);
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("此战斗已结算过"));
|
||||
|
|
@ -1460,8 +1459,10 @@ public class MapLogic {
|
|||
int monsterGroupId=0;
|
||||
SMonsterGroup sMonsterGroup=null;
|
||||
if(dropout ==0){
|
||||
monsterGroupId = Integer.parseInt((String) valueMap.get(RedisKey.FIGHT_GROUPID));
|
||||
sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(monsterGroupId);
|
||||
int mostTime = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getMostTime();
|
||||
FightEvent fightEvent = new FightEvent(uid, -1, mostTime,frames, FightType.MapExploreFight);
|
||||
FightEvent fightEvent = new FightEvent(uid, -1, mostTime,frames, GameFightType.MapEndFight);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(fightEvent);
|
||||
//校验结果码 1:胜利
|
||||
checkResult = fightResult.getCheckResult();
|
||||
|
|
@ -1962,8 +1963,7 @@ public class MapLogic {
|
|||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getFindSuddenlyBossMapId());
|
||||
FightEvent fightEvent = new FightEvent(uid, -1, sChallengeConfig.getMostTime(),frames, FightType.MapExploreFight);
|
||||
fightEvent.setExtraParm(RedisKey.SUDDLENLY_FIGHT);
|
||||
FightEvent fightEvent = new FightEvent(uid, -1, sChallengeConfig.getMostTime(),frames,GameFightType.EndSuddlenlyFight);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(fightEvent);
|
||||
//校验结果码 1:胜利
|
||||
int[] checkResult = fightResult.getCheckResult();
|
||||
|
|
@ -2088,17 +2088,8 @@ public class MapLogic {
|
|||
LOGGER.info("endFight() uid=>{} fightId=>{},checkFightId={}", uid, fightId, checkFightId);
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
String key = RedisKey.getKey(RedisKey.LEVE_DIFFICULTY_FIGHT, Integer.toString(user.getId()), false);
|
||||
Map<Object, Object> valueMap = RedisUtil.getInstence().hmget(key);
|
||||
RedisUtil.getInstence().del(key,fightKey);
|
||||
if (valueMap == null || valueMap.isEmpty()) {
|
||||
LOGGER.info("endFight() uid=>{} not start fight", uid);
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("此战斗已结算过 !"));
|
||||
}
|
||||
|
||||
|
||||
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
|
||||
FightEvent fightEvent = new FightEvent(uid, -1, sMainLevelConfig.getRankTime(),frames, FightType.StoryFight);
|
||||
FightEvent fightEvent = new FightEvent(uid, -1, sMainLevelConfig.getRankTime(),frames, GameFightType.StoryFight);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(fightEvent);
|
||||
//校验结果码 1:胜利
|
||||
int resultCode = fightResult.getCheckResult()[0];
|
||||
|
|
@ -2305,7 +2296,7 @@ public class MapLogic {
|
|||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
|
||||
FightEvent fightEvent = new FightEvent(uid, -1, sFloodConfig.getBattleTime(),frames, FightType.MapExploreFight);
|
||||
FightEvent fightEvent = new FightEvent(uid, -1, sFloodConfig.getBattleTime(),frames, GameFightType.EndMonsterAttackFight);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(fightEvent);
|
||||
//校验结果码 1:胜利
|
||||
int[] checkResult = fightResult.getCheckResult();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.handler.map.behavior;
|
||||
|
||||
import com.googlecode.protobuf.format.JsonFormat;
|
||||
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
|
||||
import com.ljsd.jieling.util.CBean2Proto;
|
||||
import config.MapPointConfig;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
|
|
@ -243,6 +244,46 @@ public class BehaviorUtil {
|
|||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取FightUnitInfo
|
||||
* @param user
|
||||
* @param teamId
|
||||
* @param attackBloodMap 血量百分比
|
||||
* @return
|
||||
*/
|
||||
public static CommonProto.FightTeamInfo getFightTeamInfo(User user, int teamId, Map<String, Integer> attackBloodMap) {
|
||||
user.getTeamPosManager().setCurTeamPosId(teamId);
|
||||
List<CommonProto.FightUnitInfo> heroFightInfos = new ArrayList<>();
|
||||
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
|
||||
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) {
|
||||
Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId());
|
||||
if (hero == null) {
|
||||
continue;
|
||||
}
|
||||
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, teamId);
|
||||
if(attackBloodMap.containsKey(teamPosHeroInfo.getHeroId())){
|
||||
heroAttributeMap.put(HeroAttributeEnum.CurHP.getPropertyId(),heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId())-attackBloodMap.get(teamPosHeroInfo.getHeroId())*heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId())/100);
|
||||
}
|
||||
StringBuilder skillSb = new StringBuilder();
|
||||
StringBuilder propertySb = new StringBuilder();
|
||||
String heroSkill = HeroLogic.getInstance().getHeroSkills(user,hero,skillSb).toString();
|
||||
String property = HeroLogic.getInstance().getHeroPropertyBuilder(propertySb, hero, heroAttributeMap).toString();
|
||||
CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo
|
||||
.newBuilder()
|
||||
.setUnitId(Integer.toString(hero.getTemplateId()))
|
||||
.setUnitSkillIds(heroSkill.substring(0,heroSkill.length()-1))
|
||||
.setProperty(property.substring(0, property.length()-1))
|
||||
.build();
|
||||
heroFightInfos.add(heroFightInfo);
|
||||
}
|
||||
return CommonProto.FightTeamInfo.
|
||||
newBuilder()
|
||||
.addAllFightUnitList(heroFightInfos)
|
||||
.setTeamSkillList(HeroLogic.getInstance().getPokenmonSkills(user,teamId))
|
||||
.setTeamPassiveList(HeroLogic.getInstance().getPokenmonPassiveSkills(user,teamId))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommonProto.FightTeamInfo getRobotFightTeamInfo(SArenaRobotConfig sArenaRobotConfig) {
|
||||
List<CommonProto.FightUnitInfo> heroFightInfos = new ArrayList<>();
|
||||
Map<Integer,Integer> heroStarsMap = sArenaRobotConfig.getStarOfHeroMap();
|
||||
|
|
|
|||
|
|
@ -17,10 +17,7 @@ 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.FightDispatcher;
|
||||
import com.ljsd.jieling.logic.fight.FightType;
|
||||
import com.ljsd.jieling.logic.fight.PVEFightEvent;
|
||||
import com.ljsd.jieling.logic.fight.*;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
|
|
@ -91,7 +88,7 @@ public class QuickStartMonsterFighter extends BaseHandler<FightInfoProto.QuickSt
|
|||
user.getUserMissionManager().onGameEvent(user, GameEvent.MONSTER_ATTACK_PLAY);
|
||||
int groupId = sFloodConfig.getMonster();
|
||||
int mostTime = sFloodConfig.getBattleTime();
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(uid,teamId, mostTime, "", FightType.MonterFight, groupId, 3);
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(uid,teamId, mostTime, "", GameFightType.MonterFight, groupId, 3);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
||||
int[] checkResult = fightResult.getCheckResult();
|
||||
|
||||
|
|
@ -127,7 +124,7 @@ public class QuickStartMonsterFighter extends BaseHandler<FightInfoProto.QuickSt
|
|||
FightInfoProto.QuickStartMonsterFightResponse builder = FightInfoProto.QuickStartMonsterFightResponse.newBuilder()
|
||||
.setResult(resultCode)
|
||||
.setEnventDrop(drop)
|
||||
// .setFightData(fightDataBuild)
|
||||
.setFightData(fightDataBuild)
|
||||
.build();
|
||||
|
||||
user.getMapManager().setLastMonsterAttack(fightId + 1);
|
||||
|
|
|
|||
|
|
@ -21,10 +21,7 @@ import com.ljsd.jieling.logic.activity.event.ArenaChallengeEvent;
|
|||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.CheckFight;
|
||||
import com.ljsd.jieling.logic.fight.FightDispatcher;
|
||||
import com.ljsd.jieling.logic.fight.FightType;
|
||||
import com.ljsd.jieling.logic.fight.PVPFightEvent;
|
||||
import com.ljsd.jieling.logic.fight.*;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
|
|
@ -270,8 +267,8 @@ public class ArenaLogic {
|
|||
|
||||
|
||||
|
||||
public static int getFightResultByPersonToPerson(User mine, int myteamId, User defUser, int defTeamId, ArenaRecord arenaRecord, ArenaInfoProto.ArenaChallengeResponse.Builder builder){
|
||||
PVPFightEvent pvpFightEvent = new PVPFightEvent(mine.getId(),myteamId,SArenaSetting.getSArenaSetting().getMostTime(),"", FightType.ArenaFight,defUser.getId(),defTeamId);
|
||||
public static int getFightResultByPersonToPerson(User mine, int myteamId, User defUser, int defTeamId, ArenaRecord arenaRecord, ArenaInfoProto.ArenaChallengeResponse.Builder builder) throws Exception {
|
||||
PVPFightEvent pvpFightEvent = new PVPFightEvent(mine.getId(),myteamId,SArenaSetting.getSArenaSetting().getMostTime(),"", GameFightType.ArenaPersonFight,defUser.getId(),defTeamId);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pvpFightEvent);
|
||||
CommonProto.FightTeamInfo fightTeamInfo =fightResult.getFightTeamInfo();
|
||||
CommonProto.FightTeamInfo deffightTeamInfo = fightResult.getDefFightTeamInfo();
|
||||
|
|
@ -297,8 +294,8 @@ public class ArenaLogic {
|
|||
|
||||
|
||||
|
||||
public int getFightResultByPersonToRobot(User mine, int myteamId, int challengeUid,ArenaInfoProto.ArenaChallengeResponse.Builder builder){
|
||||
PVPFightEvent pvpFightEvent = new PVPFightEvent(mine.getId(),myteamId,SArenaSetting.getSArenaSetting().getMostTime(),"", FightType.ArenaFight,challengeUid,-1);
|
||||
public int getFightResultByPersonToRobot(User mine, int myteamId, int challengeUid,ArenaInfoProto.ArenaChallengeResponse.Builder builder) throws Exception {
|
||||
PVPFightEvent pvpFightEvent = new PVPFightEvent(mine.getId(),myteamId,SArenaSetting.getSArenaSetting().getMostTime(),"", GameFightType.ArenaRobotFight,challengeUid,-1);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pvpFightEvent);
|
||||
CommonProto.FightTeamInfo fightTeamInfo =fightResult.getFightTeamInfo();
|
||||
CommonProto.FightTeamInfo deffightTeamInfo = fightResult.getDefFightTeamInfo();
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import com.ljsd.jieling.logic.dao.*;
|
|||
import com.ljsd.jieling.logic.dao.root.GuildCache;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
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.fight.*;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
|
|
@ -427,58 +427,13 @@ public class GuildFightLogic {
|
|||
aliveHero++;
|
||||
}
|
||||
}
|
||||
//防守血量处理
|
||||
CommonProto.FightTeamInfo fightDefendTeamInfo = BloodLogic.getInstance().fightDataMakeUp(defendInfo.getHeroSkills(),heroAttribute,defendInfo.getPokenmonSkills());
|
||||
//攻击者血量处理
|
||||
CommonProto.FightTeamInfo fightAttackTeamInfo = null;
|
||||
List<CommonProto.FightUnitInfo> heroAttackFightInfos = new ArrayList<>();
|
||||
Map<String, String> attackBloodMap = redisUtil.getMapValues(RedisKey.FAMILY_ATTACK_BLOOD, String.valueOf(userAttack.getId()), String.class, String.class);
|
||||
List<TeamPosHeroInfo> teamAttack = userAttack.getTeamPosManager().getTeamPosForHero().get(502);
|
||||
if(attackBloodMap!=null&&attackBloodMap.size()>0){
|
||||
for(TeamPosHeroInfo teamHero: teamAttack){
|
||||
Hero hero = userAttack.getHeroManager().getHero(teamHero.getHeroId());
|
||||
if (hero == null) {
|
||||
continue;
|
||||
}
|
||||
StringBuilder skillSb = new StringBuilder();
|
||||
StringBuilder propertySb = new StringBuilder();
|
||||
String heroSkill = HeroLogic.getInstance().getHeroSkills(userAttack, hero, skillSb).toString();
|
||||
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(userAttack, hero, false, 502);
|
||||
for(Map.Entry<String,String> blood:attackBloodMap.entrySet()){
|
||||
if(teamHero.getHeroId().equals(blood.getKey())){
|
||||
heroAttributeMap.put(HeroAttributeEnum.CurHP.getPropertyId(),heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId())-Integer.parseInt(blood.getValue())*heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId())/100);
|
||||
break;
|
||||
}
|
||||
}
|
||||
String property = HeroLogic.getInstance().getHeroPropertyBuilder(propertySb, hero, heroAttributeMap).toString();
|
||||
CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo
|
||||
.newBuilder()
|
||||
.setUnitId(Integer.toString(hero.getTemplateId()))
|
||||
.setUnitSkillIds(heroSkill.substring(0, heroSkill.length() - 1))
|
||||
.setProperty(property.substring(0, property.length() - 1))
|
||||
.build();
|
||||
heroAttackFightInfos.add(heroFightInfo);
|
||||
}
|
||||
CommonProto.FightTeamInfo.Builder fightAttackTeamInfoBuilder = CommonProto.FightTeamInfo.newBuilder().addAllFightUnitList(heroAttackFightInfos)
|
||||
.setTeamSkillList(HeroLogic.getInstance().getPokenmonSkills(userAttack, 1)).setTeamPassiveList(HeroLogic.getInstance().getPokenmonPassiveSkills(userAttack,1));
|
||||
fightAttackTeamInfo = fightAttackTeamInfoBuilder.build();
|
||||
}else{
|
||||
fightAttackTeamInfo = BehaviorUtil.getFightTeamInfo(userAttack,502,true);
|
||||
}
|
||||
Map<String, Integer> attackBloodMap = redisUtil.getMapValues(RedisKey.FAMILY_ATTACK_BLOOD, String.valueOf(userAttack.getId()), String.class, Integer.class);
|
||||
PVPFightEvent pvpFightEvent = new PVPFightEvent(userAttack.getId(),502, SGuildSetting.sGuildSetting.getWarTime(),"", GameFightType.GuildFight,defendUid,-1);
|
||||
pvpFightEvent.setAttackBloodMap(attackBloodMap);
|
||||
pvpFightEvent.setDefFightSnapData(new DefFightSnapData(defendInfo.getHeroAttribute(),defendInfo.getHeroSkills(),defendInfo.getPokenmonSkills()));
|
||||
FightResult dispatcher = FightDispatcher.dispatcher(pvpFightEvent);
|
||||
int[] fightResult = dispatcher.getCheckResult();
|
||||
|
||||
LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(fightAttackTeamInfo, fightDefendTeamInfo);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData("");
|
||||
int seed = (int) (System.currentTimeMillis() / 1000);
|
||||
CommonProto.FightData fightData = CommonProto.FightData.newBuilder()
|
||||
.setFightMaxTime(SGuildSetting.sGuildSetting.getWarTime())
|
||||
.setFightSeed(seed)
|
||||
.setHeroFightInfos(fightAttackTeamInfo)
|
||||
.addMonsterList(fightDefendTeamInfo)
|
||||
.build();
|
||||
int[] fightResult = CheckFight.getInstance().checkFight(seed, SGuildSetting.sGuildSetting.getWarTime(), getFightData, getOptionData, FightType.GuildFight);
|
||||
for (int i = 0; i < fightResult.length; i++) {
|
||||
System.out.println(fightResult[i]);
|
||||
}
|
||||
int aliveCount = 0;
|
||||
|
||||
// 战斗之后数据处理
|
||||
|
|
@ -495,8 +450,8 @@ public class GuildFightLogic {
|
|||
defendInfo.setHeroAttribute(BloodLogic.getInstance().afterBattleRecord(heroAttribute,fightResult));
|
||||
//获得星数
|
||||
int getStar;
|
||||
List<TeamPosHeroInfo> teamAttack = userAttack.getTeamPosManager().getTeamPosForHero().get(502);
|
||||
if (fightResult[0] == 1) {
|
||||
|
||||
getStar = defendInfo.getStarCount();
|
||||
defendInfo.setStarCount(0);
|
||||
int indexAttack =2;
|
||||
|
|
@ -540,6 +495,12 @@ public class GuildFightLogic {
|
|||
haveGotStar = 0;
|
||||
}
|
||||
redisUtil.putMapEntry(RedisKey.FAMILY_FIGHT_CAL_STAR,String.valueOf(attackGuildId),String.valueOf(defendInfo.getBuildId()),haveGotStar+getStar);
|
||||
CommonProto.FightData fightData = CommonProto.FightData.newBuilder()
|
||||
.setFightMaxTime(SGuildSetting.sGuildSetting.getWarTime())
|
||||
.setFightSeed(dispatcher.getSeed())
|
||||
.setHeroFightInfos(dispatcher.getFightTeamInfo())
|
||||
.addMonsterList(dispatcher.getDefFightTeamInfo())
|
||||
.build();
|
||||
Family.FamilyFightAttackResponse response = Family.FamilyFightAttackResponse.newBuilder().setResult(fightResult[0]).setStarCount(getStar).setData(fightData).build();
|
||||
userAttack.getUserMissionManager().onGameEvent(userAttack, GameEvent.FAMILY_FIGHT_ATTACK);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), response, true);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.FamilyHeroInfo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DefFightSnapData {
|
||||
private Map<String, FamilyHeroInfo> heroAttribute;
|
||||
private Map<String, String> heroSkills = new HashMap<>();
|
||||
private String pokenmonSkills;
|
||||
|
||||
|
||||
public DefFightSnapData(Map<String, FamilyHeroInfo> heroAttribute, Map<String, String> heroSkills, String pokenmonSkills) {
|
||||
this.heroAttribute = heroAttribute;
|
||||
this.heroSkills = heroSkills;
|
||||
this.pokenmonSkills = pokenmonSkills;
|
||||
}
|
||||
|
||||
public Map<String, FamilyHeroInfo> getHeroAttribute() {
|
||||
return heroAttribute;
|
||||
}
|
||||
|
||||
public Map<String, String> getHeroSkills() {
|
||||
return heroSkills;
|
||||
}
|
||||
|
||||
public String getPokenmonSkills() {
|
||||
return pokenmonSkills;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,9 +4,8 @@ import com.ljsd.jieling.logic.fight.result.FightResult;
|
|||
|
||||
|
||||
public class FightDispatcher {
|
||||
|
||||
|
||||
public static FightResult dispatcher(FightEvent fightEvent){
|
||||
return null;
|
||||
public static FightResult dispatcher(FightEvent fightEvent) throws Exception {
|
||||
GameFightType fightType = fightEvent.getFightType();
|
||||
return fightType.getFightEventProcesor().process(fightEvent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class FightEvent {
|
||||
private int attackUid;
|
||||
private int teamId;
|
||||
private int mostTime;
|
||||
private String frames;
|
||||
private FightType fightType;
|
||||
private String extraParm;
|
||||
private GameFightType fightType;
|
||||
private Map<String, Integer> attackBloodMap;
|
||||
|
||||
public FightEvent(int attackUid, int teamId,int mostTime,String frams, FightType fightType) {
|
||||
public FightEvent(int attackUid, int teamId,int mostTime,String frams, GameFightType fightType) {
|
||||
this.attackUid = attackUid;
|
||||
this.teamId = teamId;
|
||||
this.fightType = fightType;
|
||||
|
|
@ -16,12 +18,12 @@ public class FightEvent {
|
|||
this.frames = frams;
|
||||
}
|
||||
|
||||
public String getExtraParm() {
|
||||
return extraParm;
|
||||
public Map<String, Integer> getAttackBloodMap() {
|
||||
return attackBloodMap;
|
||||
}
|
||||
|
||||
public void setExtraParm(String extraParm) {
|
||||
this.extraParm = extraParm;
|
||||
public void setAttackBloodMap(Map<String, Integer> attackBloodMap) {
|
||||
this.attackBloodMap = attackBloodMap;
|
||||
}
|
||||
|
||||
public int getAttackUid() {
|
||||
|
|
@ -32,7 +34,7 @@ public class FightEvent {
|
|||
return teamId;
|
||||
}
|
||||
|
||||
public FightType getFightType() {
|
||||
public GameFightType getFightType() {
|
||||
return fightType;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ 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.blood.BloodLogic;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
|
|
@ -23,15 +24,19 @@ import java.util.Map;
|
|||
|
||||
public class FightUtil {
|
||||
|
||||
public static Map<FightType,String> redisTypeOfFightType = new HashMap<>();
|
||||
static {
|
||||
redisTypeOfFightType.put(FightType.StoryFight,RedisKey.LEVE_DIFFICULTY_FIGHT);
|
||||
public static CommonProto.FightTeamInfo makePersonFightData(User player,int teamId,Map<String, Integer> attackBloodMap){
|
||||
if(attackBloodMap ==null || attackBloodMap.isEmpty()){
|
||||
return BehaviorUtil.getFightTeamInfo(player,teamId,true);
|
||||
}
|
||||
return BehaviorUtil.getFightTeamInfo(player,teamId,attackBloodMap);
|
||||
}
|
||||
|
||||
public static CommonProto.FightTeamInfo makePersonFightData(User player,int teamId){
|
||||
return BehaviorUtil.getFightTeamInfo(player,teamId,true);
|
||||
public static CommonProto.FightTeamInfo makeFightWithSnapData(DefFightSnapData defFightSnapData){
|
||||
return BloodLogic.getInstance().fightDataMakeUp(defFightSnapData.getHeroSkills(),defFightSnapData.getHeroAttribute(),defFightSnapData.getPokenmonSkills());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Map<Integer, List<CommonProto.FightUnitInfo>> makeMonsterGroup(int bossGroupId,Map<Integer,List<Integer>> hps){
|
||||
return MonsterUtil.getMonsterByGroup(bossGroupId,hps);
|
||||
}
|
||||
|
|
@ -63,12 +68,12 @@ public class FightUtil {
|
|||
public static FightResult getFightForPVE(FightEvent fightEvent){
|
||||
PVEFightEvent pveFightEvent = (PVEFightEvent)fightEvent;
|
||||
User userInMem = UserManager.getUserInMem(pveFightEvent.getAttackUid());
|
||||
CommonProto.FightTeamInfo fightTeamInfo = makePersonFightData(userInMem, pveFightEvent.getTeamId());
|
||||
CommonProto.FightTeamInfo fightTeamInfo = makePersonFightData(userInMem, pveFightEvent.getTeamId(),pveFightEvent.getAttackBloodMap());
|
||||
int fightSeed =getFightSeed();
|
||||
List<CommonProto.FightTeamInfo> monsterfightTeamInfos = makeMonsterFightData(pveFightEvent.getMonsterGroupId(), pveFightEvent.getNums());
|
||||
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterfightTeamInfos);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData(fightEvent.getFrames());
|
||||
int[] fightResult = CheckFight.getInstance().checkFight(fightSeed, fightEvent.getMostTime(), getFightData, getOptionData, fightEvent.getFightType());
|
||||
int[] fightResult = CheckFight.getInstance().checkFight(fightSeed, fightEvent.getMostTime(), getFightData, getOptionData, fightEvent.getFightType().getFightType());
|
||||
|
||||
FightResult.Builder builder = FightResult.newBuilder();
|
||||
builder.setCheckResult(fightResult);
|
||||
|
|
@ -78,26 +83,43 @@ public class FightUtil {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
public static FightResult getFightForPVP(FightEvent fightEvent){
|
||||
PVPFightEvent pvpFightEvent = (PVPFightEvent)fightEvent;
|
||||
User userInMem = UserManager.getUserInMem(pvpFightEvent.getAttackUid());
|
||||
CommonProto.FightTeamInfo fightTeamInfo = makePersonFightData(userInMem, pvpFightEvent.getTeamId(),pvpFightEvent.getAttackBloodMap());
|
||||
int fightSeed =getFightSeed();
|
||||
CommonProto.FightTeamInfo deffightTeamInfo = null;
|
||||
if(pvpFightEvent.getDefFightSnapData()!=null){
|
||||
deffightTeamInfo = makeFightWithSnapData(pvpFightEvent.getDefFightSnapData());
|
||||
}else{
|
||||
if(fightEvent.getFightType() == GameFightType.ArenaPersonFight){
|
||||
User defInMem = UserManager.getUserInMem(pvpFightEvent.getDefUid());
|
||||
deffightTeamInfo = makePersonFightData(defInMem, pvpFightEvent.getDefTeamId(),null);
|
||||
}else{
|
||||
deffightTeamInfo = makeRobotFightData(pvpFightEvent.getDefUid());
|
||||
}
|
||||
|
||||
}
|
||||
LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData(fightEvent.getFrames());
|
||||
int[] fightResult = CheckFight.getInstance().checkFight(fightSeed, fightEvent.getMostTime(), getFightData, getOptionData, fightEvent.getFightType().getFightType());
|
||||
|
||||
public void mergeFightData(){
|
||||
/* LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
|
||||
|
||||
LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo);*/
|
||||
FightResult.Builder builder = FightResult.newBuilder();
|
||||
builder.setCheckResult(fightResult);
|
||||
builder.setSeed(fightSeed);
|
||||
builder.setFightTeamInfo(fightTeamInfo);
|
||||
builder.setDefFightTeamInfo(deffightTeamInfo);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
public static int[] getFightFromRedis(FightEvent fightEvent) throws Exception {
|
||||
FightType fightType = fightEvent.getFightType();
|
||||
GameFightType fightType = fightEvent.getFightType();
|
||||
int playerId = fightEvent.getAttackUid();
|
||||
String frames = fightEvent.getFrames();
|
||||
int fightTime = fightEvent.getMostTime();
|
||||
String extraParm = fightEvent.getExtraParm();
|
||||
String fightTypeOfRedis = FightUtil.redisTypeOfFightType.get(fightType);
|
||||
if(!StringUtil.isEmpty(extraParm)){
|
||||
fightTypeOfRedis = extraParm;
|
||||
}
|
||||
String key = RedisKey.getKey(fightTypeOfRedis, Integer.toString(playerId), false);
|
||||
|
||||
String key = RedisKey.getKey(fightType.getFightTypeOfRedis(), Integer.toString(playerId), false);
|
||||
Map<Object, Object> valueMap = RedisUtil.getInstence().
|
||||
hmget(key);
|
||||
if (valueMap == null || valueMap.isEmpty()) {
|
||||
|
|
@ -111,7 +133,7 @@ public class FightUtil {
|
|||
List<CommonProto.FightTeamInfo> monsterTeamList = BehaviorUtil.getFightTeamInfos(valueMap);
|
||||
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData(frames);
|
||||
return CheckFight.getInstance().checkFight(seed,fightTime, getFightData, getOptionData,fightType);
|
||||
return CheckFight.getInstance().checkFight(seed,fightTime, getFightData, getOptionData,fightType.getFightType());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.logic.fight.eventhandler.DefaultOfRedisCacheFightHandler;
|
||||
import com.ljsd.jieling.logic.fight.eventhandler.DefaultWithoutHandFightHandler;
|
||||
import com.ljsd.jieling.logic.fight.eventhandler.IFightEventProcesor;
|
||||
import com.ljsd.jieling.logic.fight.eventhandler.PVPFightHandler;
|
||||
|
||||
|
||||
/**
|
||||
* StoryFight(1), //故事副本
|
||||
* MapExploreFight(2), // 地图探索
|
||||
* ArenaFight(3), //竞技场
|
||||
* InvasionBossFight(4),//秘境boss
|
||||
* AdventureLock(5), // 解锁秘境
|
||||
* GuildFight(6), // 公会站
|
||||
* BloodyFight(7), // 血战
|
||||
* MonterFight(8), // 兽潮
|
||||
*/
|
||||
public enum GameFightType {
|
||||
StoryFight(FightType.StoryFight,new DefaultOfRedisCacheFightHandler(), 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),
|
||||
|
||||
ArenaPersonFight(FightType.ArenaFight,new PVPFightHandler(),null),
|
||||
ArenaRobotFight(FightType.ArenaFight,new PVPFightHandler(),null),
|
||||
|
||||
MonterFight(FightType.MonterFight,new DefaultWithoutHandFightHandler(),null),
|
||||
|
||||
GuildFight(FightType.GuildFight,new PVPFightHandler(),null),
|
||||
|
||||
;
|
||||
|
||||
|
||||
private FightType fightType;
|
||||
private IFightEventProcesor fightEventProcesor;
|
||||
private String fightTypeOfRedis;
|
||||
|
||||
|
||||
GameFightType(FightType fightType, IFightEventProcesor fightEventProcesor,String fightTypeOfRedis) {
|
||||
this.fightType = fightType;
|
||||
this.fightEventProcesor = fightEventProcesor;
|
||||
this.fightTypeOfRedis = fightTypeOfRedis;
|
||||
}
|
||||
|
||||
public FightType getFightType() {
|
||||
return fightType;
|
||||
}
|
||||
|
||||
public IFightEventProcesor getFightEventProcesor() {
|
||||
return fightEventProcesor;
|
||||
}
|
||||
|
||||
public String getFightTypeOfRedis() {
|
||||
return fightTypeOfRedis;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ public class PVEFightEvent extends FightEvent{
|
|||
private int monsterGroupId;
|
||||
private int nums;
|
||||
|
||||
public PVEFightEvent(int attackUid, int teamId, int mostTime,String frams, FightType fightType, int monsterGroupId, int nums) {
|
||||
public PVEFightEvent(int attackUid, int teamId, int mostTime,String frams, GameFightType fightType, int monsterGroupId, int nums) {
|
||||
super(attackUid, teamId, mostTime,frams, fightType);
|
||||
this.monsterGroupId = monsterGroupId;
|
||||
this.nums = nums;
|
||||
|
|
|
|||
|
|
@ -4,10 +4,28 @@ public class PVPFightEvent extends FightEvent {
|
|||
private int defUid;
|
||||
private int defTeamId;
|
||||
|
||||
//对手快照
|
||||
private DefFightSnapData defFightSnapData;
|
||||
|
||||
public PVPFightEvent(int attackUid, int teamId, int mostTime, String frams, FightType fightType, int defUid, int defTeamId) {
|
||||
public PVPFightEvent(int attackUid, int teamId, int mostTime, String frams, GameFightType fightType, int defUid, int defTeamId) {
|
||||
super(attackUid, teamId, mostTime, frams, fightType);
|
||||
this.defUid = defUid;
|
||||
this.defTeamId = defTeamId;
|
||||
}
|
||||
|
||||
public int getDefUid() {
|
||||
return defUid;
|
||||
}
|
||||
|
||||
public int getDefTeamId() {
|
||||
return defTeamId;
|
||||
}
|
||||
|
||||
public DefFightSnapData getDefFightSnapData() {
|
||||
return defFightSnapData;
|
||||
}
|
||||
|
||||
public void setDefFightSnapData(DefFightSnapData defFightSnapData) {
|
||||
this.defFightSnapData = defFightSnapData;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ public class DefaultOfRedisCacheFightHandler implements IFightEventProcesor {
|
|||
|
||||
@Override
|
||||
public FightResult process(FightEvent fightEvent) throws Exception {
|
||||
System.out.println(this);
|
||||
int[] fightResult = FightUtil.getFightFromRedis(fightEvent);
|
||||
return FightResult.newBuilder().setCheckResult(fightResult).build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package com.ljsd.jieling.logic.fight.eventhandler;
|
||||
|
||||
import com.ljsd.jieling.logic.fight.FightEvent;
|
||||
import com.ljsd.jieling.logic.fight.FightUtil;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
|
||||
public class PVPFightHandler implements IFightEventProcesor{
|
||||
@Override
|
||||
public FightResult process(FightEvent fightEvent) throws Exception {
|
||||
return FightUtil.getFightForPVP(fightEvent);
|
||||
}
|
||||
}
|
||||
|
|
@ -35,6 +35,8 @@ public class SLotterySetting implements BaseConfig {
|
|||
|
||||
private int[][] tenTimesMustGetBox;
|
||||
|
||||
private int activityId;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
|
|
|||
Loading…
Reference in New Issue