查看历史记录

back_recharge 11.04online
zhangshanxue 2020-11-06 14:38:34 +08:00
parent 44852b0601
commit 7a42112a9c
1 changed files with 150 additions and 0 deletions

View File

@ -0,0 +1,150 @@
package com.ljsd.jieling.kefu;
import com.ljsd.fight.CheckFight;
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
import com.ljsd.jieling.core.GlobalsDef;
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.logic.championship.ChampionshipLogic;
import com.ljsd.jieling.logic.dao.ArenaRecord;
import com.ljsd.jieling.logic.dao.FamilyFightInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.*;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.util.FightDataUtil;
import config.SArenaRobotConfig;
import manager.STableManager;
import org.luaj.vm2.LuaValue;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Description:
* Author: zsx
* CreateDate: 2019/9/26 11:48
*/
public class Cmd_review_gm extends GmAbstract {
@Override
public boolean exec(String[] args) throws Exception {
// for (int i = 0; i <150 ; i++) {
// String key = RedisKey.getKey(RedisKey.FORCE_RANK, "", false);
// RedisUtil.getInstence().zsetAddOne(key, String.valueOf(10000+i), 10000+i);
// }
if (args.length != 1) {
return false;
}
String fightID = args[0];
ArenaRecord arenaRecord = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_ARENA_RECORD,"", fightID, ArenaRecord.class);
if(arenaRecord == null){
throw new ErrorCodeException(ErrorCode.newDefineCode("arena_rrecord null"));
}
byte[] fightData = arenaRecord.getFightData();
CommonProto.FightData fightDataProto = CommonProto.FightData.parseFrom(fightData);
LuaValue getFightData;
int snapTeamId = GlobalsDef.CHAMPION_ATTACK_TEAM;
RedisUtil.getInstence().del(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_FIGHT, ""));
int warTime = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getWarTime();
Map<Integer, ChampionshipLogic.MemberInfo> memberInfoMap = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_JOIN, "", Integer.class, ChampionshipLogic.MemberInfo.class);
int attackId = arenaRecord.getAttackId();
int defUid = arenaRecord.getDefUid();
ChampionshipLogic.snapOneFightInfo(attackId, memberInfoMap);
ChampionshipLogic.snapOneFightInfo(defUid, memberInfoMap);
long id = FightDispatcher.getFIghtId();
EndFightProcessor endFightProcessor = new AreFightPro();
((AreFightPro) endFightProcessor).setArenaRecord(arenaRecord);
FightDispatcher.getMap().put(id, endFightProcessor);
Map<Integer, GameFightType> gameFightTypeMap = new HashMap<>();
gameFightTypeMap.put(0, GameFightType.TOPArenaPersonFight);
gameFightTypeMap.put(1, GameFightType.TOPArenaRobotFight);
gameFightTypeMap.put(2, GameFightType.TOPArena2RobotFight);
PVPFightEvent pvpFightEvent = new PVPFightEvent(attackId, snapTeamId, warTime, "", gameFightTypeMap.get(arenaRecord.getType()), defUid, snapTeamId);
ChampionshipLogic.MemberInfo attackMemberInfo = memberInfoMap.get(attackId);
ChampionshipLogic.MemberInfo defMemberInfo = memberInfoMap.get(defUid);
int minForce = 0;
int defForce = 0;
if (defMemberInfo.getType() == 0) {
FamilyFightInfo fightInfo = defMemberInfo.getFightInfo();
pvpFightEvent.setDefFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(), fightInfo.getHeroSkills(), fightInfo.getPokenmonSkills(), fightInfo.getPassiveSkills(), defUid));
defForce = fightInfo.getForce();
} else {
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(defUid);
if (sArenaRobotConfig != null) {
defForce = sArenaRobotConfig.getTotalForce();
}
}
if (attackMemberInfo.getType() == 0) {
FamilyFightInfo fightInfo = attackMemberInfo.getFightInfo();
pvpFightEvent.setAttackFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(), fightInfo.getHeroSkills(), fightInfo.getPokenmonSkills(), fightInfo.getPassiveSkills(), attackId));
minForce = fightInfo.getForce();
} else {
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(attackId);
if (sArenaRobotConfig != null) {
minForce = sArenaRobotConfig.getTotalForce();
}
}
if (minForce > defForce) {
if (arenaRecord.getTurn() == 2) {
pvpFightEvent.setRever(true);
}
} else {
if (arenaRecord.getTurn() == 1 || arenaRecord.getTurn() == 3) {
pvpFightEvent.setRever(true);
}
}
CommonProto.FightTeamInfo fightTeamInfo = null;
CommonProto.FightTeamInfo deffightTeamInfo = null;
if(pvpFightEvent.getAttackFightSnapData()!=null){
fightTeamInfo = FightUtil.makeFightWithSnapData(pvpFightEvent.getAttackFightSnapData());
}
if(pvpFightEvent.getDefFightSnapData()!=null){
deffightTeamInfo = FightUtil.makeFightWithSnapData(pvpFightEvent.getDefFightSnapData());
} else{
if(pvpFightEvent.getFightType() == GameFightType.ArenaPersonFight ||pvpFightEvent.getFightType() == GameFightType.CarPersonChallenge ){
User defInMem = UserManager.getUserInMem(pvpFightEvent.getDefUid());
deffightTeamInfo = FightUtil.makePersonFightData(defInMem, pvpFightEvent.getDefTeamId(),null,null);
}else{
deffightTeamInfo =FightUtil. makeRobotFightData(pvpFightEvent.getDefUid());
}
}
if(fightTeamInfo==null){
if( pvpFightEvent.getFightType()!=GameFightType.TOPArena2RobotFight){
if( SArenaRobotConfig.getsArenaRobotConfigById(pvpFightEvent.getAttackUid()) !=null){
fightTeamInfo =FightUtil. makeRobotFightData(pvpFightEvent.getAttackUid());
}else{
User userInMem = UserManager.getUserInMem(pvpFightEvent.getAttackUid());
fightTeamInfo = FightUtil.makePersonFightData(userInMem, pvpFightEvent.getTeamId(),pvpFightEvent.getAttackBloodMap(),null);
}
}else{
fightTeamInfo = FightUtil.makeRobotFightData(pvpFightEvent.getAttackUid());
}
}
if (pvpFightEvent.isRever()) {
deffightTeamInfo = CommonProto.FightTeamInfo.newBuilder().mergeFrom(deffightTeamInfo).setFirstCamp(1).build();
getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo, true);//对方先手
} else {
getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo);
}
LuaValue getOptionData = FightDataUtil.getOptionData(pvpFightEvent.getAttackUid() + "");
int[] fightResult = CheckFight.getInstance().checkFight(fightDataProto.getFightSeed(), pvpFightEvent.getMostTime(), getFightData, getOptionData, pvpFightEvent.getFightType().getFightType());
String string = Arrays.toString(fightResult);
LOGGER.error("__________________________"+fightResult[0]+":::"+string);
System.out.println("string = " + string);
return true;
}
}