四灵试炼添加注释

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()),
Situation_challenge(74,null),
Multiple_Arena(82,null),
Four_Challenge(84,null)
Four_Challenge(83,null,MessageTypeProto.MessageType.FOUR_CHALLENGE_DO_REQUEST_VALUE)
;
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.root.User;
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.PVEFightEvent;
import com.ljsd.jieling.logic.fight.result.FightResult;
@ -29,40 +28,52 @@ import java.util.List;
/**
* @author lvxinran
* @author hj
* @date 2020/12/16
* @discribe
*/
public class FourChallengeLogic {
public static FourChallengeLogic getInstance() {
return FourChallengeLogic.Instance.instance;
}
public int[] status ;
/**
* 01
* 0111
*/
public int[] status;
/**
*
*/
public final int[][] config;
public static class Instance {
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;
}
public void check(){
if(TimeUtils.getHourOfDay()!=0&&status!=null){
/**
*
*/
public void check() {
// 只检测一次
if (TimeUtils.getHourOfDay() != 0 && status != null) {
return;
}
// 空初始化长度为4
if (status == null) {
status = new int[4];
}
if(status==null) status = new int[4];
for(int[] statusConfig:config){
for(int i = 1 ;i<statusConfig.length;i++){
if(TimeUtils.getDayOfWeek(TimeUtils.now())==statusConfig[i]){
status[statusConfig[0]-1] = 1;
for (int[] statusConfig : config) {
for (int i = 1; i < statusConfig.length; i++) {
// 判断当前周几
if (TimeUtils.getDayOfWeek() == statusConfig[i]) {
status[statusConfig[0] - 1] = 1;
break;
}
}
@ -70,102 +81,126 @@ public class FourChallengeLogic {
}
/**
*
* @param session
* @throws Exception
*/
public void fourChallengeGetInfo(ISession session) throws Exception {
User user = UserManager.getUser(session.getUid());
// 玩家当前层数
int[] fourChallenge = user.getPlayerInfoManager().getFourChallenge();
// 剩余挑战次数
int[] remainTimes = user.getPlayerInfoManager().getFourChallengeRemainTimes();
PlayerInfoProto.FourChallengeGetInfoResponse.Builder builder = PlayerInfoProto.FourChallengeGetInfoResponse.newBuilder();
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]);
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]);
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);
}
/**
*
*
* @param session
* @param challengeId
* @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());
// 当前层数
int[] fourChallenge = user.getPlayerInfoManager().getFourChallenge();
// 剩余挑战次数
int[] fourChallengeRemainTimes = user.getPlayerInfoManager().getFourChallengeRemainTimes();
SCampTowerConfig sCampTowerConfig = STableManager.getConfig(SCampTowerConfig.class).get(challengeId);
// 特权
int[][] flashTimesPrice = STableManager.getConfig(SCampTowerSetting.class).get(1).getFlashTimesPrice();
if(sCampTowerConfig==null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
if (sCampTowerConfig == null) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"配置表错误");
}
// 层数
int floorId = sCampTowerConfig.getFloorId();
// 上阵英雄类型
int campId = sCampTowerConfig.getCampId();
// 玩家当前层数
int currentFloor = fourChallenge[campId - 1];
PlayerInfoProto.FourChallengeDoResponse.Builder response = PlayerInfoProto.FourChallengeDoResponse.newBuilder();
CommonProto.Drop.Builder drop = null;
if(type==0){
if (type == 0) {
//挑战
if(floorId!=currentFloor+1){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
if (floorId != currentFloor + 1) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"挑战层数错误");
}
if(fourChallengeRemainTimes[campId - 1]<1){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
if (fourChallengeRemainTimes[campId - 1] < 1) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"挑战次数不足");
}
int[] teams = STableManager.getConfig(SCampTowerSetting.class).get(1).getFormation();
int teamId = teams[campId - 1];
//编队检测
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
if(teamPosHeroInfos==null||teamPosHeroInfos.size()==0){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
if (teamPosHeroInfos == null || teamPosHeroInfos.size() == 0) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"挑战编队为空");
}
for(TeamPosHeroInfo info:teamPosHeroInfos){
for (TeamPosHeroInfo info : teamPosHeroInfos) {
Hero hero = user.getHeroManager().getHero(info.getHeroId());
if(SCHero.getsCHero().get(hero.getTemplateId()).getPropertyName()!=sCampTowerConfig.getCampId()){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
if (SCHero.getsCHero().get(hero.getTemplateId()).getPropertyName() != sCampTowerConfig.getCampId()) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"挑战编队英雄类型有误");
}
}
PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(),teamId,20, "",GameFightType.DailyChallenge,sCampTowerConfig.getMonster(),3);
PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), teamId, 20, "", GameFightType.DailyChallenge, sCampTowerConfig.getMonster(), 3);
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
int[] checkResult = fightResult.getCheckResult();
response.setFightData(fightResult.getFightData());
if(checkResult[0]==1){
if (checkResult[0] == 1) {
// 挑战成功,获得道具,更新层数,更新次数
drop = ItemUtil.drop(user, sCampTowerConfig.getFirstReward(), BIReason.FOUR_CHALLENGE_FIRST);
user.getPlayerInfoManager().updateFourChallengeByIndex(campId-1,currentFloor+1);
user.getPlayerInfoManager().setFourChallengeRemainTimes(campId-1,fourChallengeRemainTimes[campId - 1]+1);
user.getPlayerInfoManager().updateFourChallengeByIndex(campId - 1, currentFloor + 1);
user.getPlayerInfoManager().setFourChallengeRemainTimes(campId - 1, fourChallengeRemainTimes[campId - 1] + 1);
}
}else if(type==1){
} else if (type == 1) {
//扫荡
if(floorId!=currentFloor){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
if (floorId != currentFloor) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"扫荡层数错误");
}
// 获取特权和消耗
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);
}else{
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
} else {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"非挑战或扫荡,功能错误");
}
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);
}
public void firstGetTimes(User user){
/**
*
* @param user
*/
public void firstGetTimes(User user) {
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);
}
}