巅峰赛临时提交
parent
ca17f5d39d
commit
c654004bc8
|
@ -1,7 +1,8 @@
|
||||||
package com.ljsd.jieling.logic.arena;
|
package com.ljsd.jieling.logic.arena;
|
||||||
|
|
||||||
|
|
||||||
|
import com.ljsd.fight.CheckFight;
|
||||||
|
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
||||||
import com.ljsd.jieling.core.GlobalsDef;
|
import com.ljsd.jieling.core.GlobalsDef;
|
||||||
import com.ljsd.jieling.core.VipPrivilegeType;
|
import com.ljsd.jieling.core.VipPrivilegeType;
|
||||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||||
|
@ -18,6 +19,7 @@ import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
||||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
import com.ljsd.jieling.logic.activity.event.ArenaChallengeEvent;
|
import com.ljsd.jieling.logic.activity.event.ArenaChallengeEvent;
|
||||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||||
|
import com.ljsd.jieling.logic.championship.ChampionshipLogic;
|
||||||
import com.ljsd.jieling.logic.dao.*;
|
import com.ljsd.jieling.logic.dao.*;
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
import com.ljsd.jieling.logic.fight.*;
|
import com.ljsd.jieling.logic.fight.*;
|
||||||
|
@ -36,6 +38,7 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
import com.ljsd.jieling.util.*;
|
import com.ljsd.jieling.util.*;
|
||||||
import config.*;
|
import config.*;
|
||||||
import manager.STableManager;
|
import manager.STableManager;
|
||||||
|
import org.luaj.vm2.LuaValue;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.redis.core.ZSetOperations;
|
import org.springframework.data.redis.core.ZSetOperations;
|
||||||
|
@ -48,8 +51,8 @@ import java.util.*;
|
||||||
public class ArenaLogic {
|
public class ArenaLogic {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ArenaLogic.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ArenaLogic.class);
|
||||||
|
|
||||||
private ArenaLogic(){}
|
private ArenaLogic() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class Instance {
|
public static class Instance {
|
||||||
|
@ -127,7 +130,6 @@ public class ArenaLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setMyArenaEnemys(int uid, User user) {
|
public void setMyArenaEnemys(int uid, User user) {
|
||||||
int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK, Integer.toString(curSeason), Integer.toString(uid)).intValue();
|
int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK, Integer.toString(curSeason), Integer.toString(uid)).intValue();
|
||||||
if (score == -1) {
|
if (score == -1) {
|
||||||
|
@ -159,8 +161,6 @@ public class ArenaLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static int getFightResultByPersonToPerson(User mine, int myteamId, User defUser, int defTeamId, ArenaRecord arenaRecord, ArenaInfoProto.ArenaChallengeResponse.Builder builder) throws Exception {
|
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);
|
PVPFightEvent pvpFightEvent = new PVPFightEvent(mine.getId(), myteamId, SArenaSetting.getSArenaSetting().getMostTime(), "", GameFightType.ArenaPersonFight, defUser.getId(), defTeamId);
|
||||||
int myforce = HeroLogic.getInstance().calTeamTotalForce(mine, GlobalsDef.TEAM_ARENA_DEFENSE, false);
|
int myforce = HeroLogic.getInstance().calTeamTotalForce(mine, GlobalsDef.TEAM_ARENA_DEFENSE, false);
|
||||||
|
@ -188,7 +188,6 @@ public class ArenaLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int getFightResultByPersonToRobot(User mine, int myteamId, int challengeUid, ArenaInfoProto.ArenaChallengeResponse.Builder builder) throws Exception {
|
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);
|
PVPFightEvent pvpFightEvent = new PVPFightEvent(mine.getId(), myteamId, SArenaSetting.getSArenaSetting().getMostTime(), "", GameFightType.ArenaRobotFight, challengeUid, -1);
|
||||||
int myforce = HeroLogic.getInstance().calTeamTotalForce(mine, GlobalsDef.TEAM_ARENA_DEFENSE, false);
|
int myforce = HeroLogic.getInstance().calTeamTotalForce(mine, GlobalsDef.TEAM_ARENA_DEFENSE, false);
|
||||||
|
@ -398,20 +397,16 @@ public class ArenaLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Sa: 实际胜负值, 胜 = 1 负=0
|
||||||
Sa: 实际胜负值, 胜 = 1 负=0
|
* <p>
|
||||||
|
* Ra: A选手比赛前的分 Rb: B选手比赛前的分数
|
||||||
Ra: A选手比赛前的分 Rb: B选手比赛前的分数
|
* R'a: A选手比赛完的分数 R'b: B选手比赛完的分数
|
||||||
R'a: A选手比赛完的分数 R'b: B选手比赛完的分数
|
* <p>
|
||||||
|
* Ea:EA = 1/(1+10^[(Rb-Ra)/400])
|
||||||
Ea:EA = 1/(1+10^[(Rb-Ra)/400])
|
* Eb: EB = 1/(1+10^[(Ra-Rb)/400])
|
||||||
Eb: EB = 1/(1+10^[(Ra-Rb)/400])
|
* R'a = Ra + K(Sa-Ea)
|
||||||
R'a = Ra + K(Sa-Ea)
|
* R'b = Rb + K(Sb-Eb)
|
||||||
R'b = Rb + K(Sb-Eb)
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public int calScore(int myScore, int defScore, int result) {
|
public int calScore(int myScore, int defScore, int result) {
|
||||||
SArenaSetting sArenaSetting = SArenaSetting.getSArenaSetting();
|
SArenaSetting sArenaSetting = SArenaSetting.getSArenaSetting();
|
||||||
|
@ -437,6 +432,111 @@ public class ArenaLogic {
|
||||||
}
|
}
|
||||||
byte[] fightData = arenaRecord.getFightData();
|
byte[] fightData = arenaRecord.getFightData();
|
||||||
CommonProto.FightData fightDataProto = CommonProto.FightData.parseFrom(fightData);
|
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);
|
||||||
FightInfoProto.FightRePlayResponse build = FightInfoProto.FightRePlayResponse.newBuilder().setFightData(fightDataProto).build();
|
FightInfoProto.FightRePlayResponse build = FightInfoProto.FightRePlayResponse.newBuilder().setFightData(fightDataProto).build();
|
||||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.VIEW_FIGHTREPLAY_RESPONSE_VALUE, build, true);
|
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.VIEW_FIGHTREPLAY_RESPONSE_VALUE, build, true);
|
||||||
}
|
}
|
||||||
|
@ -444,6 +544,7 @@ public class ArenaLogic {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送结算奖励
|
* 发送结算奖励
|
||||||
|
*
|
||||||
* @param type
|
* @param type
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@ -553,5 +654,4 @@ public class ArenaLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue