四灵试炼添加注释

back_recharge
duhui 2021-01-26 11:18:18 +08:00
parent 8394061f97
commit fa39c7eb9b
2 changed files with 87 additions and 52 deletions

View File

@ -64,7 +64,7 @@ public enum FunctionIdEnum {
Car_Delay(73,new CarDelayFunction()), Car_Delay(73,new CarDelayFunction()),
Situation_challenge(74,null), Situation_challenge(74,null),
Multiple_Arena(82,null), Multiple_Arena(82,null),
Four_Challenge(84,null) Four_Challenge(83,null,MessageTypeProto.MessageType.FOUR_CHALLENGE_DO_REQUEST_VALUE)
; ;
private int functionType; private int functionType;

View File

@ -8,7 +8,6 @@ import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.FightDispatcher; import com.ljsd.jieling.logic.fight.FightDispatcher;
import com.ljsd.jieling.logic.fight.FightUtil;
import com.ljsd.jieling.logic.fight.GameFightType; import com.ljsd.jieling.logic.fight.GameFightType;
import com.ljsd.jieling.logic.fight.PVEFightEvent; import com.ljsd.jieling.logic.fight.PVEFightEvent;
import com.ljsd.jieling.logic.fight.result.FightResult; import com.ljsd.jieling.logic.fight.result.FightResult;
@ -29,39 +28,51 @@ import java.util.List;
/** /**
* @author lvxinran * @author lvxinran
* @author hj
* @date 2020/12/16 * @date 2020/12/16
* @discribe * @discribe
*/ */
public class FourChallengeLogic { public class FourChallengeLogic {
public static FourChallengeLogic getInstance() { public static FourChallengeLogic getInstance() {
return FourChallengeLogic.Instance.instance; return FourChallengeLogic.Instance.instance;
} }
/**
* 01
* 0111
*/
public int[] status; public int[] status;
/**
*
*/
public final int[][] config; public final int[][] config;
public static class Instance { public static class Instance {
public final static FourChallengeLogic instance = new FourChallengeLogic(STableManager.getConfig(SCampTowerSetting.class).get(1).getCampOpenDay()); public final static FourChallengeLogic instance = new FourChallengeLogic(STableManager.getConfig(SCampTowerSetting.class).get(1).getCampOpenDay());
} }
private FourChallengeLogic(int[][] config) { private FourChallengeLogic(int[][] config) {
this.config = config; this.config = config;
} }
/**
*
*/
public void check() { public void check() {
// 只检测一次
if (TimeUtils.getHourOfDay() != 0 && status != null) { if (TimeUtils.getHourOfDay() != 0 && status != null) {
return; return;
} }
// 空初始化长度为4
if(status==null) status = new int[4]; if (status == null) {
status = new int[4];
}
for (int[] statusConfig : config) { for (int[] statusConfig : config) {
for (int i = 1; i < statusConfig.length; i++) { for (int i = 1; i < statusConfig.length; i++) {
if(TimeUtils.getDayOfWeek(TimeUtils.now())==statusConfig[i]){ // 判断当前周几
if (TimeUtils.getDayOfWeek() == statusConfig[i]) {
status[statusConfig[0] - 1] = 1; status[statusConfig[0] - 1] = 1;
break; break;
} }
@ -70,16 +81,26 @@ public class FourChallengeLogic {
} }
/**
*
* @param session
* @throws Exception
*/
public void fourChallengeGetInfo(ISession session) throws Exception { public void fourChallengeGetInfo(ISession session) throws Exception {
User user = UserManager.getUser(session.getUid()); User user = UserManager.getUser(session.getUid());
// 玩家当前层数
int[] fourChallenge = user.getPlayerInfoManager().getFourChallenge(); int[] fourChallenge = user.getPlayerInfoManager().getFourChallenge();
// 剩余挑战次数
int[] remainTimes = user.getPlayerInfoManager().getFourChallengeRemainTimes(); int[] remainTimes = user.getPlayerInfoManager().getFourChallengeRemainTimes();
PlayerInfoProto.FourChallengeGetInfoResponse.Builder builder = PlayerInfoProto.FourChallengeGetInfoResponse.newBuilder(); PlayerInfoProto.FourChallengeGetInfoResponse.Builder builder = PlayerInfoProto.FourChallengeGetInfoResponse.newBuilder();
for (int i = 0; i < fourChallenge.length; i++) { for (int i = 0; i < fourChallenge.length; i++) {
CommonProto.FourChallengeInfo.Builder info = CommonProto.FourChallengeInfo.newBuilder().setType(i+1).setCurrentFloor(fourChallenge[i]).setRemainTimes(remainTimes[i]).setOverTime(status[i]); CommonProto.FourChallengeInfo.Builder info = CommonProto.FourChallengeInfo.newBuilder()
.setType(i + 1)
.setCurrentFloor(fourChallenge[i])
.setRemainTimes(remainTimes[i])
.setOverTime(status[i]);
builder.addInfo(info.build()); builder.addInfo(info.build());
} }
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.FOUR_CHALLENGE_GET_INFO_RESPONSE_VALUE, builder.build(), true); MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.FOUR_CHALLENGE_GET_INFO_RESPONSE_VALUE, builder.build(), true);
@ -87,32 +108,40 @@ public class FourChallengeLogic {
/** /**
* *
*
* @param session * @param session
* @param challengeId * @param challengeId
* @param type * @param type
*/ */
public void fourChallengeDo(ISession session, int challengeId, int type) throws Exception { public void fourChallengeDo(ISession session, int challengeId, int type) throws Exception {
User user = UserManager.getUser(session.getUid()); User user = UserManager.getUser(session.getUid());
// 当前层数
int[] fourChallenge = user.getPlayerInfoManager().getFourChallenge(); int[] fourChallenge = user.getPlayerInfoManager().getFourChallenge();
// 剩余挑战次数
int[] fourChallengeRemainTimes = user.getPlayerInfoManager().getFourChallengeRemainTimes(); int[] fourChallengeRemainTimes = user.getPlayerInfoManager().getFourChallengeRemainTimes();
SCampTowerConfig sCampTowerConfig = STableManager.getConfig(SCampTowerConfig.class).get(challengeId); SCampTowerConfig sCampTowerConfig = STableManager.getConfig(SCampTowerConfig.class).get(challengeId);
// 特权
int[][] flashTimesPrice = STableManager.getConfig(SCampTowerSetting.class).get(1).getFlashTimesPrice(); int[][] flashTimesPrice = STableManager.getConfig(SCampTowerSetting.class).get(1).getFlashTimesPrice();
if (sCampTowerConfig == null) { if (sCampTowerConfig == null) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"配置表错误");
} }
// 层数
int floorId = sCampTowerConfig.getFloorId(); int floorId = sCampTowerConfig.getFloorId();
// 上阵英雄类型
int campId = sCampTowerConfig.getCampId(); int campId = sCampTowerConfig.getCampId();
// 玩家当前层数
int currentFloor = fourChallenge[campId - 1]; int currentFloor = fourChallenge[campId - 1];
PlayerInfoProto.FourChallengeDoResponse.Builder response = PlayerInfoProto.FourChallengeDoResponse.newBuilder(); PlayerInfoProto.FourChallengeDoResponse.Builder response = PlayerInfoProto.FourChallengeDoResponse.newBuilder();
CommonProto.Drop.Builder drop = null; CommonProto.Drop.Builder drop = null;
if (type == 0) { if (type == 0) {
//挑战 //挑战
if (floorId != currentFloor + 1) { if (floorId != currentFloor + 1) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"挑战层数错误");
} }
if (fourChallengeRemainTimes[campId - 1] < 1) { if (fourChallengeRemainTimes[campId - 1] < 1) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"挑战次数不足");
} }
int[] teams = STableManager.getConfig(SCampTowerSetting.class).get(1).getFormation(); int[] teams = STableManager.getConfig(SCampTowerSetting.class).get(1).getFormation();
int teamId = teams[campId - 1]; int teamId = teams[campId - 1];
@ -120,12 +149,12 @@ public class FourChallengeLogic {
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId); List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
if (teamPosHeroInfos == null || teamPosHeroInfos.size() == 0) { if (teamPosHeroInfos == null || teamPosHeroInfos.size() == 0) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"挑战编队为空");
} }
for (TeamPosHeroInfo info : teamPosHeroInfos) { for (TeamPosHeroInfo info : teamPosHeroInfos) {
Hero hero = user.getHeroManager().getHero(info.getHeroId()); Hero hero = user.getHeroManager().getHero(info.getHeroId());
if (SCHero.getsCHero().get(hero.getTemplateId()).getPropertyName() != sCampTowerConfig.getCampId()) { if (SCHero.getsCHero().get(hero.getTemplateId()).getPropertyName() != sCampTowerConfig.getCampId()) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"挑战编队英雄类型有误");
} }
} }
@ -134,7 +163,9 @@ public class FourChallengeLogic {
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent); FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
int[] checkResult = fightResult.getCheckResult(); int[] checkResult = fightResult.getCheckResult();
response.setFightData(fightResult.getFightData()); response.setFightData(fightResult.getFightData());
if (checkResult[0] == 1) { if (checkResult[0] == 1) {
// 挑战成功,获得道具,更新层数,更新次数
drop = ItemUtil.drop(user, sCampTowerConfig.getFirstReward(), BIReason.FOUR_CHALLENGE_FIRST); drop = ItemUtil.drop(user, sCampTowerConfig.getFirstReward(), BIReason.FOUR_CHALLENGE_FIRST);
user.getPlayerInfoManager().updateFourChallengeByIndex(campId - 1, currentFloor + 1); user.getPlayerInfoManager().updateFourChallengeByIndex(campId - 1, currentFloor + 1);
user.getPlayerInfoManager().setFourChallengeRemainTimes(campId - 1, fourChallengeRemainTimes[campId - 1] + 1); user.getPlayerInfoManager().setFourChallengeRemainTimes(campId - 1, fourChallengeRemainTimes[campId - 1] + 1);
@ -143,27 +174,31 @@ public class FourChallengeLogic {
} else if (type == 1) { } else if (type == 1) {
//扫荡 //扫荡
if (floorId != currentFloor) { if (floorId != currentFloor) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"扫荡层数错误");
} }
// 获取特权和消耗
int[] privilege = flashTimesPrice[campId - 1]; int[] privilege = flashTimesPrice[campId - 1];
PlayerLogic.getInstance().checkAndUpdate(user, privilege[0], 1); PlayerLogic.getInstance().checkAndUpdate(user, privilege[0], 1);
drop = ItemUtil.drop(user, sCampTowerConfig.getCommonReward(), BIReason.FOUR_CHALLENGE_SWEEP); drop = ItemUtil.drop(user, sCampTowerConfig.getCommonReward(), BIReason.FOUR_CHALLENGE_SWEEP);
} else { } else {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"非挑战或扫荡,功能错误");
} }
response.setDrop(drop); response.setDrop(drop);
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.FOUR_CHALLENGE_DO_RESPONSE_VALUE, response.build(), true); MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.FOUR_CHALLENGE_DO_RESPONSE_VALUE, response.build(), true);
} }
/**
*
* @param user
*/
public void firstGetTimes(User user) { public void firstGetTimes(User user) {
int campOpenDay = STableManager.getConfig(SCampTowerSetting.class).get(1).getHelpMaxTimes(); int campOpenDay = STableManager.getConfig(SCampTowerSetting.class).get(1).getHelpMaxTimes();
for (int i = 0; i < status.length; i++) { for (int i = 0; i < status.length; i++) {
if (status[i]==0) continue; if (status[i] == 0){continue;}
user.getPlayerInfoManager().updateFourChallengeByIndex(i, campOpenDay); user.getPlayerInfoManager().updateFourChallengeByIndex(i, campOpenDay);