规范代码
parent
efc3368d0a
commit
9e3f87cbd0
|
@ -19,8 +19,6 @@ 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.hero.HeroLogic;
|
||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||
import com.ljsd.jieling.logic.mission.MissionType;
|
||||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.thrift.idl.CrossArenaManager;
|
||||
|
|
|
@ -1,31 +1,12 @@
|
|||
package com.ljsd.jieling.handler.map.mapHandler;
|
||||
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.TeamEnum;
|
||||
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.logic.arena.ChallengeLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SChallengeStage;
|
||||
import manager.STableManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/4/24
|
||||
|
@ -41,155 +22,6 @@ public class ChallengeHandler extends BaseHandler<PlayerInfoProto.ChallengeReque
|
|||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, PlayerInfoProto.ChallengeRequest proto) throws Exception {
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
PlayerInfoProto.ChallengeResponse.Builder builder = PlayerInfoProto.ChallengeResponse.newBuilder();
|
||||
int type = proto.getType(); //1无尽 2宝物
|
||||
int model = proto.getModel(); //1为挑战 2为扫荡
|
||||
int id = proto.getId();
|
||||
SChallengeStage sChallengeConfig = STableManager.getConfig(SChallengeStage.class).get(id);
|
||||
if (sChallengeConfig == null) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
int endlessNewReplicaLexel = user.getPlayerInfoManager().getEndlessNewReplica();
|
||||
int treasureReplicaLexel = user.getPlayerInfoManager().getTreasureReplica();
|
||||
/*
|
||||
首次通关 给 保底 +总奖励 +通关奖励
|
||||
扫荡 = 保底 +总奖励
|
||||
没打过 保底+总奖励*奖励百分比
|
||||
*/
|
||||
if (model == 2) {
|
||||
//掃蕩
|
||||
//次數
|
||||
boolean consume = PlayerLogic.getInstance().checkAndUpdate(user, sChallengeConfig.getPivilegeID()[1], 1);
|
||||
if (!consume) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
if (type == 1) {
|
||||
if (endlessNewReplicaLexel > id) {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
|
||||
return;
|
||||
}
|
||||
} else if (type == 2) {
|
||||
if (treasureReplicaLexel > id) {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//扫荡 = 保底 +总奖励
|
||||
Map<Integer, Integer> comDropMap = new HashMap<>();
|
||||
for (int[] fix : sChallengeConfig.getFixedReward()) {
|
||||
if (comDropMap.containsKey(fix[0])) {
|
||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
||||
} else {
|
||||
comDropMap.put(fix[0], fix[1]);
|
||||
}
|
||||
}
|
||||
for (int[] fix : sChallengeConfig.getPassReward()) {
|
||||
if (comDropMap.containsKey(fix[0])) {
|
||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
||||
} else {
|
||||
comDropMap.put(fix[0], fix[1]);
|
||||
}
|
||||
}
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, comDropMap.entrySet().stream().map(n ->
|
||||
new int[]{n.getKey(), n.getValue()}).toArray(int[][]::new), BIReason.EXPLORE_MAP_COST_RETURN);
|
||||
builder.setDrop(drop);
|
||||
} else {
|
||||
GameFightType fightType = GameFightType.EndlessNewTeam;
|
||||
if (type == 1) {
|
||||
fightType = GameFightType.EndlessNewTeam;
|
||||
if (sChallengeConfig.getNextLevel() != endlessNewReplicaLexel) {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
|
||||
return;
|
||||
} else {
|
||||
user.getPlayerInfoManager().setEndlessNewReplica(id);
|
||||
}
|
||||
} else if (type == 2) {
|
||||
fightType = GameFightType.TreasureTeam;
|
||||
if (sChallengeConfig.getNextLevel() != treasureReplicaLexel) {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
|
||||
return;
|
||||
} else {
|
||||
user.getPlayerInfoManager().setTreasureReplica(id);
|
||||
}
|
||||
}
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), TeamEnum.FORMATION_NORMAL.getTeamId(), 1000, "",
|
||||
fightType, sChallengeConfig.getMonsterGroup(), 3);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
||||
Map<Integer, Integer> comDropMap = new HashMap<>();
|
||||
for (int[] fix : sChallengeConfig.getFixedReward()) {
|
||||
if (comDropMap.containsKey(fix[0])) {
|
||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
||||
} else {
|
||||
comDropMap.put(fix[0], fix[1]);
|
||||
}
|
||||
}
|
||||
|
||||
//首次通关 给 保底 +总奖励 +通关奖励
|
||||
if ((int) fightResult.getCheckResult()[0] == 1) {
|
||||
//赢了
|
||||
for (int[] fix : sChallengeConfig.getPassReward()) {
|
||||
if (comDropMap.containsKey(fix[0])) {
|
||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
||||
} else {
|
||||
comDropMap.put(fix[0], fix[1]);
|
||||
}
|
||||
}
|
||||
for (int[] fix : sChallengeConfig.getVictoryReward()) {
|
||||
if (comDropMap.containsKey(fix[0])) {
|
||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
||||
} else {
|
||||
comDropMap.put(fix[0], fix[1]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//没打过 保底+总奖励*奖励百分比
|
||||
//输了
|
||||
int[][] reward1 = sChallengeConfig.getReward1();
|
||||
int ratio = 0;
|
||||
if (type == 1) {//无尽副本 血量
|
||||
long leaveHp = fightResult.getCheckResult()[2] + fightResult.getCheckResult()[3] + fightResult.getCheckResult()[4]
|
||||
+ fightResult.getCheckResult()[5] + fightResult.getCheckResult()[6];
|
||||
for (int[] percent : reward1) {
|
||||
if (percent[0] > leaveHp) {
|
||||
break;
|
||||
}
|
||||
ratio = percent[1];
|
||||
}
|
||||
} else if (type == 2) {//回合数
|
||||
long times = fightResult.getCheckResult()[1];//回合数
|
||||
for (int[] percent : reward1) {
|
||||
if (percent[0] > times) {
|
||||
break;
|
||||
}
|
||||
ratio = percent[1];
|
||||
}
|
||||
}
|
||||
LOGGER.info("challengeHandler ====>id:{},ratio:{}", sChallengeConfig.getId(), ratio);
|
||||
for (int[] fix : sChallengeConfig.getPassReward()) {
|
||||
if (comDropMap.containsKey(fix[0])) {
|
||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + (int) (fix[1] * (ratio / 10000)));
|
||||
} else {
|
||||
comDropMap.put(fix[0], (int) (fix[1] * (ratio / 10000)));
|
||||
}
|
||||
}
|
||||
}
|
||||
CommonProto.FightData fightData = CommonProto.FightData.newBuilder()
|
||||
.setFightMaxTime(20)
|
||||
.setFightSeed(fightResult.getSeed())
|
||||
.setHeroFightInfos(fightResult.getFightTeamInfo())
|
||||
.addAllMonsterList(fightResult.getMonsterTeamList())
|
||||
.setFightType(fightType.getFightType().getType())
|
||||
.setFightId(FightUtil.getFightId(user.getId(), fightType))
|
||||
.build();
|
||||
builder.setFightData(fightData);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, comDropMap.entrySet().stream().map(n ->
|
||||
new int[]{n.getKey(), n.getValue()}).toArray(int[][]::new), BIReason.EXPLORE_MAP_COST_RETURN);
|
||||
builder.setDrop(drop);
|
||||
}
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
|
||||
ChallengeLogic.getInstance().ChallengeHandler(iSession, proto);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,122 +1,144 @@
|
|||
package com.ljsd.jieling.logic.arena;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.fight.ArenaRecord;
|
||||
import com.ljsd.fight.FightType;
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.SArenaRobotStaticConfig;
|
||||
import com.ljsd.jieling.core.FunctionIdEnum;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.core.VipPrivilegeType;
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
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.globals.BIReason;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
|
||||
import com.ljsd.jieling.logic.dao.TeamEnum;
|
||||
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.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.hero.HeroLogic;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||
import com.ljsd.jieling.logic.mission.event.MissionEventDistributor;
|
||||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||
import com.ljsd.jieling.logic.rank.RankContext;
|
||||
import com.ljsd.jieling.logic.rank.RankEnum;
|
||||
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
|
||||
import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent;
|
||||
import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.thrift.idl.CrossArenaManager;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.*;
|
||||
import config.SChallengeStage;
|
||||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import rpc.protocols.*;
|
||||
import util.MathUtils;
|
||||
import util.StringUtil;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChallengeLogic {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ChallengeLogic.class);
|
||||
|
||||
private ChallengeLogic(){}
|
||||
|
||||
public static class Instance {
|
||||
public final static ChallengeLogic instance = new ChallengeLogic();
|
||||
}
|
||||
|
||||
public static ChallengeLogic getInstance() {
|
||||
return ChallengeLogic.Instance.instance;
|
||||
}
|
||||
/**
|
||||
* 是否开启,0:未开,1:开启
|
||||
* 例子 0,1
|
||||
*/
|
||||
public static int[] status = new int[2];
|
||||
/**
|
||||
* 策划表配置,开启时间
|
||||
*/
|
||||
//public final int[][] config;
|
||||
|
||||
/*public static class Instance {
|
||||
public final static FourChallengeLogic instance = new FourChallengeLogic(STableManager.getConfig(SCampTowerSetting.class).get(1).getCampOpenDay());
|
||||
private ChallengeLogic() {
|
||||
}
|
||||
|
||||
private FourChallengeLogic(int[][] config) {
|
||||
this.config = config;
|
||||
}*/
|
||||
public static ChallengeLogic getInstance() {
|
||||
return ChallengeLogic.Instance.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 首次通关
|
||||
*/
|
||||
public static final int FIRST = 1;
|
||||
/**
|
||||
* 最低战力
|
||||
*/
|
||||
public static final int MINI = 2;
|
||||
public static boolean limit(int level, int id) {
|
||||
if (level > id) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 四灵试炼标志
|
||||
*/
|
||||
public static final String fc = "fc";
|
||||
public static Map<Integer, Integer> dropMap(SChallengeStage sChallengeConfig, int model, int type, int win, long[] result) {
|
||||
/*
|
||||
model //1为挑战 2为扫荡
|
||||
win // 1赢 0输
|
||||
首次通关 给 保底 +总奖励 +通关奖励
|
||||
扫荡 = 保底 +总奖励
|
||||
没打过 保底+总奖励*奖励百分比
|
||||
*/
|
||||
Map<Integer, Integer> comDropMap = new HashMap<>();
|
||||
//保底奖励
|
||||
for (int[] fix : sChallengeConfig.getFixedReward()) {
|
||||
if (comDropMap.containsKey(fix[0])) {
|
||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
||||
} else {
|
||||
comDropMap.put(fix[0], fix[1]);
|
||||
}
|
||||
}
|
||||
//总奖励
|
||||
if (model == 2 || (model == 1 && win == 1)) {
|
||||
//扫荡
|
||||
for (int[] fix : sChallengeConfig.getPassReward()) {
|
||||
if (comDropMap.containsKey(fix[0])) {
|
||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
||||
} else {
|
||||
comDropMap.put(fix[0], fix[1]);
|
||||
}
|
||||
}
|
||||
} else if (model == 1 && win == 1) {
|
||||
//打过
|
||||
for (int[] fix : sChallengeConfig.getVictoryReward()) {
|
||||
if (comDropMap.containsKey(fix[0])) {
|
||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
||||
} else {
|
||||
comDropMap.put(fix[0], fix[1]);
|
||||
}
|
||||
}
|
||||
} else if (model == 1 && win == 0) {
|
||||
//没打过
|
||||
int[][] reward1 = sChallengeConfig.getReward1();
|
||||
int ratio = 0;
|
||||
if (type == 1) {//无尽副本 血量
|
||||
long leaveHp = result[2] + result[3] + result[4]
|
||||
+ result[5] + result[6];
|
||||
for (int[] percent : reward1) {
|
||||
if (percent[0] > leaveHp) {
|
||||
break;
|
||||
}
|
||||
ratio = percent[1];
|
||||
}
|
||||
} else if (type == 2) {//回合数
|
||||
long times = result[1];//回合数
|
||||
for (int[] percent : reward1) {
|
||||
if (percent[0] > times) {
|
||||
break;
|
||||
}
|
||||
ratio = percent[1];
|
||||
}
|
||||
}
|
||||
LOGGER.info("challengeHandler ====>id:{},ratio:{}", sChallengeConfig.getId(), ratio);
|
||||
for (int[] fix : sChallengeConfig.getPassReward()) {
|
||||
if (comDropMap.containsKey(fix[0])) {
|
||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + (int) (fix[1] * (ratio / 10000)));
|
||||
} else {
|
||||
comDropMap.put(fix[0], (int) (fix[1] * (ratio / 10000)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return comDropMap;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测开启状态
|
||||
*/
|
||||
public void check() {
|
||||
|
||||
status[0] = 0;
|
||||
status[1] = 0;
|
||||
//无尽副本星期1、3、5、7开启
|
||||
//宝物副本星期2、4、6、7开启
|
||||
int [][] config = {{1,3,5,7},{2,4,6,7}};
|
||||
public void check() {
|
||||
status[0] = 0;
|
||||
status[1] = 0;
|
||||
//无尽副本星期1、3、5、7开启
|
||||
//宝物副本星期2、4、6、7开启
|
||||
int[][] config = {{1, 3, 5, 7}, {2, 4, 6, 7}};
|
||||
//status = new int[2];
|
||||
for(int i = 0; i < config.length; i++){
|
||||
for(int j = 0; j < config[i].length; j++){
|
||||
// 判断当前周几
|
||||
if (TimeUtils.getDayOfWeek() == config[i][j]) {
|
||||
status[i] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < config.length; i++) {
|
||||
for (int j = 0; j < config[i].length; j++) {
|
||||
// 判断当前周几
|
||||
if (TimeUtils.getDayOfWeek() == config[i][j]) {
|
||||
status[i] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ChallengeInfoIndication(ISession session) throws Exception {
|
||||
|
@ -126,12 +148,106 @@ public class ChallengeLogic {
|
|||
for (int i = 1; i <= 2; i++) {
|
||||
CommonProto.ChallengeInfo.Builder info = CommonProto.ChallengeInfo.newBuilder()
|
||||
.setType(i)
|
||||
.setOverTime(status[i-1])
|
||||
.setCurrentFloor(i== 1? user.getPlayerInfoManager().getEndlessNewReplica():user.getPlayerInfoManager().getTreasureReplica());
|
||||
.setOverTime(status[i - 1])
|
||||
.setCurrentFloor(i == 1 ? user.getPlayerInfoManager().getEndlessNewReplica() : user.getPlayerInfoManager().getTreasureReplica());
|
||||
builder.addInfo(info.build());
|
||||
}
|
||||
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.CHALLENGE_INFO_INDICATION_VALUE, builder.build(), true);
|
||||
|
||||
}
|
||||
|
||||
public void ChallengeHandler(ISession iSession, PlayerInfoProto.ChallengeRequest proto) throws Exception {
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
PlayerInfoProto.ChallengeResponse.Builder builder = PlayerInfoProto.ChallengeResponse.newBuilder();
|
||||
int type = proto.getType(); //1无尽 2宝物
|
||||
int model = proto.getModel(); //1为挑战 2为扫荡
|
||||
int id = proto.getId();
|
||||
SChallengeStage sChallengeConfig = STableManager.getConfig(SChallengeStage.class).get(id);
|
||||
if (sChallengeConfig == null) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
int endlessNewReplicaLexel = user.getPlayerInfoManager().getEndlessNewReplica();
|
||||
int treasureReplicaLexel = user.getPlayerInfoManager().getTreasureReplica();
|
||||
Map<Integer, Integer> comDropMap = new HashMap<>();
|
||||
if (model == 2) {
|
||||
//扫荡
|
||||
boolean consume = PlayerLogic.getInstance().checkAndUpdate(user, sChallengeConfig.getPivilegeID()[1], 1);
|
||||
if (!consume) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
//限制
|
||||
switch (type) {
|
||||
case 1:
|
||||
if (!limit(endlessNewReplicaLexel, id)) {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (!limit(treasureReplicaLexel, id)) {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
//扫荡 = 保底 +总奖励
|
||||
comDropMap = dropMap(sChallengeConfig, model, type, 1, null);
|
||||
;
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, comDropMap.entrySet().stream().map(n ->
|
||||
new int[]{n.getKey(), n.getValue()}).toArray(int[][]::new), BIReason.EXPLORE_MAP_COST_RETURN);
|
||||
builder.setDrop(drop);
|
||||
} else {
|
||||
GameFightType fightType = GameFightType.EndlessNewTeam;
|
||||
if (type == 1) {
|
||||
fightType = GameFightType.EndlessNewTeam;
|
||||
if (sChallengeConfig.getNextLevel() < endlessNewReplicaLexel) {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
|
||||
return;
|
||||
}
|
||||
} else if (type == 2) {
|
||||
fightType = GameFightType.TreasureTeam;
|
||||
if (sChallengeConfig.getNextLevel() < treasureReplicaLexel) {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), TeamEnum.FORMATION_NORMAL.getTeamId(), 1000, "",
|
||||
fightType, sChallengeConfig.getMonsterGroup(), 3);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
||||
|
||||
//首次通关 给 保底 +总奖励 +通关奖励
|
||||
if ((int) fightResult.getCheckResult()[0] == 1) {
|
||||
//赢了
|
||||
if (type == 1) {
|
||||
user.getPlayerInfoManager().setEndlessNewReplica(id);
|
||||
} else if (type == 2) {
|
||||
user.getPlayerInfoManager().setTreasureReplica(id);
|
||||
}
|
||||
comDropMap = dropMap(sChallengeConfig, model, type, 1, fightResult.getCheckResult());
|
||||
} else {
|
||||
//没打过 //输了 保底+总奖励*奖励百分比
|
||||
comDropMap = dropMap(sChallengeConfig, model, type, 0, fightResult.getCheckResult());
|
||||
}
|
||||
CommonProto.FightData fightData = CommonProto.FightData.newBuilder()
|
||||
.setFightMaxTime(20)
|
||||
.setFightSeed(fightResult.getSeed())
|
||||
.setHeroFightInfos(fightResult.getFightTeamInfo())
|
||||
.addAllMonsterList(fightResult.getMonsterTeamList())
|
||||
.setFightType(fightType.getFightType().getType())
|
||||
.setFightId(FightUtil.getFightId(user.getId(), fightType))
|
||||
.build();
|
||||
builder.setFightData(fightData);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, comDropMap.entrySet().stream().map(n ->
|
||||
new int[]{n.getKey(), n.getValue()}).toArray(int[][]::new), BIReason.EXPLORE_MAP_COST_RETURN);
|
||||
builder.setDrop(drop);
|
||||
}
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
|
||||
}
|
||||
|
||||
public static class Instance {
|
||||
public final static ChallengeLogic instance = new ChallengeLogic();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue