四灵试炼提交

back_recharge
lvxinran 2020-12-27 19:05:39 +08:00
parent 58b3f69aac
commit 8394061f97
10 changed files with 393 additions and 0 deletions

View File

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

View File

@ -161,6 +161,9 @@ public interface BIReason {
int ARENA_WIN_REWARD = 92;//竞技场胜利奖励
int ARENA_LOSE_REWARD = 93;//竞技场失败奖励
int FOUR_CHALLENGE_FIRST = 94;//四灵试炼首通
int FOUR_CHALLENGE_SWEEP = 95;//四灵试炼扫荡
int ADVENTURE_UPLEVEL_CONSUME = 1000;//秘境升级
int SECRETBOX_CONSUME = 1001;//秘盒抽卡

View File

@ -0,0 +1,27 @@
package com.ljsd.jieling.handler.fourChallenge;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import org.springframework.stereotype.Component;
/**
* @author lvxinran
* @date 2020/12/26
* @discribe
*/
@Component
public class FourChallengeDoHandler extends BaseHandler<PlayerInfoProto.FourChallengeDoRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.FOUR_CHALLENGE_DO_REQUEST;
}
@Override
public void processWithProto(ISession iSession, PlayerInfoProto.FourChallengeDoRequest proto) throws Exception {
FourChallengeLogic.getInstance().fourChallengeDo(iSession,proto.getChallengeId(),proto.getType());
}
}

View File

@ -0,0 +1,28 @@
package com.ljsd.jieling.handler.fourChallenge;
import com.google.protobuf.GeneratedMessage;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
/**
* @author lvxinran
* @date 2020/12/16
* @discribe
*/
@Component
public class FourChallengeGetInfoHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.FOUR_CHALLENGE_GET_INFO_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
FourChallengeLogic.getInstance().fourChallengeGetInfo(iSession);
}
}

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
import com.ljsd.jieling.core.FunctionIdEnum;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.core.VipPrivilegeType;
import com.ljsd.jieling.exception.ErrorCode;
@ -11,6 +12,8 @@ import com.ljsd.jieling.logic.activity.event.ActivityStateChangeEvent;
import com.ljsd.jieling.logic.activity.event.IEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.event.UserLevelEvent;
import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic;
import com.ljsd.jieling.logic.dao.TimeControllerOfFunction;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.expedition.ExpeditionLogic;
@ -75,6 +78,9 @@ public class UserLevelEventHandler implements IEventHandler,IPrivilegeChange{
return;
}
for(SGlobalSystemConfig sGlobalSystemConfig : sGlobalSystemConfigs){
if(sGlobalSystemConfig.getId()== FunctionIdEnum.Four_Challenge.getFunctionType()){
FourChallengeLogic.getInstance().firstGetTimes(user);
}
int[][] openGifts = sGlobalSystemConfig.getOpenGifts();
if(openGifts!=null && openGifts.length>0){
ItemUtil.drop(user,openGifts, BIReason.SYSTERM_OPEN_REWARD);

View File

@ -0,0 +1,173 @@
package com.ljsd.jieling.logic.activity.fourChallenge;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.logic.dao.Hero;
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;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import config.SCHero;
import config.SCampTowerConfig;
import config.SCampTowerSetting;
import manager.STableManager;
import util.TimeUtils;
import java.util.List;
/**
* @author lvxinran
* @date 2020/12/16
* @discribe
*/
public class FourChallengeLogic {
public static FourChallengeLogic getInstance() {
return FourChallengeLogic.Instance.instance;
}
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){
this.config = config;
}
public void check(){
if(TimeUtils.getHourOfDay()!=0&&status!=null){
return;
}
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;
break;
}
}
}
}
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]);
builder.addInfo(info.build());
}
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 {
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);
}
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(floorId!=currentFloor+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);
}
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);
}
}
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){
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);
}
}else if(type==1){
//扫荡
if(floorId!=currentFloor){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
int[] privilege = flashTimesPrice[campId - 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);
}
response.setDrop(drop);
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.FOUR_CHALLENGE_DO_RESPONSE_VALUE,response.build(),true);
}
public void firstGetTimes(User user){
int campOpenDay = STableManager.getConfig(SCampTowerSetting.class).get(1).getHelpMaxTimes();
for(int i = 0 ; i <status.length;i++){
if (status[i]==0) continue;
user.getPlayerInfoManager().updateFourChallengeByIndex(i,campOpenDay);
}
}
}

View File

@ -126,6 +126,10 @@ public class PlayerManager extends MongoBase {
private Map<Integer,Integer> situationPass = new HashMap<>();
private int[] fourChallenge = new int[4];
private int[] fourChallengeRemainTimes = new int[4];
public PlayerManager(){
this.setRootCollection(User._COLLECTION_NAME);
@ -821,4 +825,23 @@ public class PlayerManager extends MongoBase {
this.lastDeviceId = lastDeviceId;
updateString("lastDeviceId",lastDeviceId);
}
public int[] getFourChallenge() {
return fourChallenge;
}
public void updateFourChallengeByIndex(int index,int value) {
fourChallenge[index] = value;
updateString("fourChallenge",fourChallenge);
}
public int[] getFourChallengeRemainTimes() {
return fourChallengeRemainTimes;
}
public void setFourChallengeRemainTimes(int index,int value) {
fourChallengeRemainTimes[index] = value;
updateString("fourChallengeRemainTimes",fourChallengeRemainTimes);
}
}

View File

@ -23,6 +23,7 @@ import com.ljsd.jieling.logic.SituationLogic;
import com.ljsd.jieling.logic.activity.ActivityLogic;
import com.ljsd.jieling.logic.activity.event.MinuteTaskEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic;
import com.ljsd.jieling.logic.arena.ArenaLogic;
import com.ljsd.jieling.logic.dao.GuildMyInfo;
import com.ljsd.jieling.logic.dao.GuilidManager;
@ -83,6 +84,12 @@ public class MinuteTask extends Thread {
}catch (Exception e){
LOGGER.error("Exception::=>{}",e.toString());
}
try {
FourChallengeLogic.getInstance().check();
}catch (Exception e){
LOGGER.error("Exception::=>{}",e.toString());
}
try {
everyZeroTask();

View File

@ -0,0 +1,55 @@
package config;
import manager.STableManager;
import manager.Table;
import java.util.Map;
@Table(name ="CampTowerConfig")
public class SCampTowerConfig implements BaseConfig {
private int id;
private int floorId;
private int campId;
private int monster;
private int[][] firstReward;
private int[][] commonReward;
@Override
public void init() throws Exception {
}
public int getId() {
return id;
}
public int getFloorId() {
return floorId;
}
public int getCampId() {
return campId;
}
public int getMonster() {
return monster;
}
public int[][] getFirstReward() {
return firstReward;
}
public int[][] getCommonReward() {
return commonReward;
}
}

View File

@ -0,0 +1,70 @@
package config;
import manager.STableManager;
import manager.Table;
import java.util.Map;
@Table(name ="CampTowerSetting")
public class SCampTowerSetting implements BaseConfig {
private int id;
private int timesAddPerDay;
private int timesStoreMax;
private int[][] campOpenDay;
private int[][] flashTimesPrice;
private int helpFightMax;
private int[] helpReward;
private int helpMaxTimes;
private int[] formation;
@Override
public void init() throws Exception {
}
public int getId() {
return id;
}
public int getTimesAddPerDay() {
return timesAddPerDay;
}
public int getTimesStoreMax() {
return timesStoreMax;
}
public int[][] getCampOpenDay() {
return campOpenDay;
}
public int getHelpFightMax() {
return helpFightMax;
}
public int[] getHelpReward() {
return helpReward;
}
public int getHelpMaxTimes() {
return helpMaxTimes;
}
public int[][] getFlashTimesPrice() {
return flashTimesPrice;
}
public int[] getFormation() {
return formation;
}
}