挑战副本
parent
a325ba0451
commit
efc3368d0a
|
|
@ -4,7 +4,6 @@ import com.ljsd.jieling.exception.ErrorCode;
|
||||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||||
import com.ljsd.jieling.globals.BIReason;
|
import com.ljsd.jieling.globals.BIReason;
|
||||||
import com.ljsd.jieling.handler.BaseHandler;
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
import com.ljsd.jieling.handler.map.MapLogic;
|
|
||||||
import com.ljsd.jieling.logic.dao.TeamEnum;
|
import com.ljsd.jieling.logic.dao.TeamEnum;
|
||||||
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;
|
||||||
|
|
@ -18,8 +17,6 @@ import com.ljsd.jieling.network.session.ISession;
|
||||||
import com.ljsd.jieling.util.ItemUtil;
|
import com.ljsd.jieling.util.ItemUtil;
|
||||||
import com.ljsd.jieling.util.MessageUtil;
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
import config.SChallengeStage;
|
import config.SChallengeStage;
|
||||||
import config.SDailyChallengeConfig;
|
|
||||||
import config.SLotterySetting;
|
|
||||||
import manager.STableManager;
|
import manager.STableManager;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import rpc.protocols.CommonProto;
|
import rpc.protocols.CommonProto;
|
||||||
|
|
@ -44,27 +41,18 @@ public class ChallengeHandler extends BaseHandler<PlayerInfoProto.ChallengeReque
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processWithProto(ISession iSession, PlayerInfoProto.ChallengeRequest proto) throws Exception {
|
public void processWithProto(ISession iSession, PlayerInfoProto.ChallengeRequest proto) throws Exception {
|
||||||
//MapLogic.getInstance().dailyChallenge(iSession,proto.getType(),proto.getId(), MessageTypeProto.MessageType.CHALLENGE_RESPONSE);
|
|
||||||
User user = UserManager.getUser(iSession.getUid());
|
User user = UserManager.getUser(iSession.getUid());
|
||||||
if(user == null){
|
if (user == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlayerInfoProto.ChallengeResponse.Builder builder = PlayerInfoProto.ChallengeResponse.newBuilder();
|
PlayerInfoProto.ChallengeResponse.Builder builder = PlayerInfoProto.ChallengeResponse.newBuilder();
|
||||||
int type = proto.getType(); //1无尽 2宝物
|
int type = proto.getType(); //1无尽 2宝物
|
||||||
int model = proto.getModel(); //1为挑战 2为扫荡
|
int model = proto.getModel(); //1为挑战 2为扫荡
|
||||||
int id = proto.getId();
|
int id = proto.getId();
|
||||||
Map<Integer, SLotterySetting> config = STableManager.getConfig(SLotterySetting.class);
|
|
||||||
|
|
||||||
SChallengeStage sChallengeConfig = STableManager.getConfig(SChallengeStage.class).get(id);
|
SChallengeStage sChallengeConfig = STableManager.getConfig(SChallengeStage.class).get(id);
|
||||||
SChallengeStage lastChange = STableManager.getConfig(SChallengeStage.class).get(id - 1);
|
|
||||||
if (sChallengeConfig == null) {
|
if (sChallengeConfig == null) {
|
||||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||||
}
|
}
|
||||||
//次數
|
|
||||||
/*boolean consume = PlayerLogic.getInstance().checkAndUpdate(user, sChallengeConfig.getPivilegeID()[1], 1);
|
|
||||||
if (!consume) {
|
|
||||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
|
||||||
}*/
|
|
||||||
int endlessNewReplicaLexel = user.getPlayerInfoManager().getEndlessNewReplica();
|
int endlessNewReplicaLexel = user.getPlayerInfoManager().getEndlessNewReplica();
|
||||||
int treasureReplicaLexel = user.getPlayerInfoManager().getTreasureReplica();
|
int treasureReplicaLexel = user.getPlayerInfoManager().getTreasureReplica();
|
||||||
/*
|
/*
|
||||||
|
|
@ -72,29 +60,34 @@ public class ChallengeHandler extends BaseHandler<PlayerInfoProto.ChallengeReque
|
||||||
扫荡 = 保底 +总奖励
|
扫荡 = 保底 +总奖励
|
||||||
没打过 保底+总奖励*奖励百分比
|
没打过 保底+总奖励*奖励百分比
|
||||||
*/
|
*/
|
||||||
if(model == 2){
|
if (model == 2) {
|
||||||
//掃蕩
|
//掃蕩
|
||||||
if(type ==1){
|
//次數
|
||||||
if(endlessNewReplicaLexel>id){
|
boolean consume = PlayerLogic.getInstance().checkAndUpdate(user, sChallengeConfig.getPivilegeID()[1], 1);
|
||||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.ExplorerMapEventResponse.getNumber(), builder.build(), true);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}else if(type == 2){
|
} else if (type == 2) {
|
||||||
if(treasureReplicaLexel>id){
|
if (treasureReplicaLexel > id) {
|
||||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.ExplorerMapEventResponse.getNumber(), builder.build(), true);
|
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//扫荡 = 保底 +总奖励
|
//扫荡 = 保底 +总奖励
|
||||||
Map<Integer, Integer> comDropMap = new HashMap<>();
|
Map<Integer, Integer> comDropMap = new HashMap<>();
|
||||||
/*for(int [] fix : sChallengeConfig.getFixedReward()){
|
for (int[] fix : sChallengeConfig.getFixedReward()) {
|
||||||
if (comDropMap.containsKey(fix[0])) {
|
if (comDropMap.containsKey(fix[0])) {
|
||||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
||||||
} else {
|
} else {
|
||||||
comDropMap.put(fix[0], fix[1]);
|
comDropMap.put(fix[0], fix[1]);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
for(int [] fix : sChallengeConfig.getPassReward()){
|
for (int[] fix : sChallengeConfig.getPassReward()) {
|
||||||
if (comDropMap.containsKey(fix[0])) {
|
if (comDropMap.containsKey(fix[0])) {
|
||||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -104,63 +97,83 @@ public class ChallengeHandler extends BaseHandler<PlayerInfoProto.ChallengeReque
|
||||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, comDropMap.entrySet().stream().map(n ->
|
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);
|
new int[]{n.getKey(), n.getValue()}).toArray(int[][]::new), BIReason.EXPLORE_MAP_COST_RETURN);
|
||||||
builder.setDrop(drop);
|
builder.setDrop(drop);
|
||||||
}else{
|
} else {
|
||||||
GameFightType fightType = GameFightType.EndlessNewTeam;
|
GameFightType fightType = GameFightType.EndlessNewTeam;
|
||||||
if(type ==1){
|
if (type == 1) {
|
||||||
fightType = GameFightType.EndlessNewTeam;
|
fightType = GameFightType.EndlessNewTeam;
|
||||||
if(sChallengeConfig.getNextLevel()!=endlessNewReplicaLexel){
|
if (sChallengeConfig.getNextLevel() != endlessNewReplicaLexel) {
|
||||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.ExplorerMapEventResponse.getNumber(), builder.build(), true);
|
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
|
||||||
return;
|
return;
|
||||||
}else{
|
} else {
|
||||||
user.getPlayerInfoManager().setEndlessNewReplica(id);
|
user.getPlayerInfoManager().setEndlessNewReplica(id);
|
||||||
}
|
}
|
||||||
}else if(type == 2){
|
} else if (type == 2) {
|
||||||
fightType = GameFightType.TreasureTeam;
|
fightType = GameFightType.TreasureTeam;
|
||||||
if(sChallengeConfig.getNextLevel()!= treasureReplicaLexel){
|
if (sChallengeConfig.getNextLevel() != treasureReplicaLexel) {
|
||||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.ExplorerMapEventResponse.getNumber(), builder.build(), true);
|
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
|
||||||
return;
|
return;
|
||||||
}else{
|
} else {
|
||||||
user.getPlayerInfoManager().setTreasureReplica(id);
|
user.getPlayerInfoManager().setTreasureReplica(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), TeamEnum.FORMATION_NORMAL.getTeamId(), 1000, "",
|
PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), TeamEnum.FORMATION_NORMAL.getTeamId(), 1000, "",
|
||||||
fightType, 810020, 3);
|
fightType, sChallengeConfig.getMonsterGroup(), 3);
|
||||||
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
||||||
Map<Integer, Integer> comDropMap = new HashMap<>();
|
Map<Integer, Integer> comDropMap = new HashMap<>();
|
||||||
/*for(int [] fix : sChallengeConfig.getFixedReward()){
|
for (int[] fix : sChallengeConfig.getFixedReward()) {
|
||||||
if (comDropMap.containsKey(fix[0])) {
|
if (comDropMap.containsKey(fix[0])) {
|
||||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
||||||
} else {
|
} else {
|
||||||
comDropMap.put(fix[0], fix[1]);
|
comDropMap.put(fix[0], fix[1]);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
//首次通关 给 保底 +总奖励 +通关奖励
|
//首次通关 给 保底 +总奖励 +通关奖励
|
||||||
if ((int) fightResult.getCheckResult()[0] == 1){
|
if ((int) fightResult.getCheckResult()[0] == 1) {
|
||||||
//赢了
|
//赢了
|
||||||
for(int [] fix : sChallengeConfig.getPassReward()){
|
for (int[] fix : sChallengeConfig.getPassReward()) {
|
||||||
if (comDropMap.containsKey(fix[0])) {
|
if (comDropMap.containsKey(fix[0])) {
|
||||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
||||||
} else {
|
} else {
|
||||||
comDropMap.put(fix[0], fix[1]);
|
comDropMap.put(fix[0], fix[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int [] fix : sChallengeConfig.getVictoryReward()){
|
for (int[] fix : sChallengeConfig.getVictoryReward()) {
|
||||||
if (comDropMap.containsKey(fix[0])) {
|
if (comDropMap.containsKey(fix[0])) {
|
||||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
comDropMap.put(fix[0], comDropMap.get(fix[0]) + fix[1]);
|
||||||
} else {
|
} else {
|
||||||
comDropMap.put(fix[0], fix[1]);
|
comDropMap.put(fix[0], fix[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
}else{
|
|
||||||
//没打过 保底+总奖励*奖励百分比
|
//没打过 保底+总奖励*奖励百分比
|
||||||
//输了
|
//输了
|
||||||
for(int [] fix : sChallengeConfig.getPassReward()){
|
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])) {
|
if (comDropMap.containsKey(fix[0])) {
|
||||||
comDropMap.put(fix[0], comDropMap.get(fix[0]) + (int)(fix[1]*0.5));
|
comDropMap.put(fix[0], comDropMap.get(fix[0]) + (int) (fix[1] * (ratio / 10000)));
|
||||||
} else {
|
} else {
|
||||||
comDropMap.put(fix[0], (int)(fix[1]*0.5));
|
comDropMap.put(fix[0], (int) (fix[1] * (ratio / 10000)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -177,6 +190,6 @@ public class ChallengeHandler extends BaseHandler<PlayerInfoProto.ChallengeReque
|
||||||
new int[]{n.getKey(), n.getValue()}).toArray(int[][]::new), BIReason.EXPLORE_MAP_COST_RETURN);
|
new int[]{n.getKey(), n.getValue()}).toArray(int[][]::new), BIReason.EXPLORE_MAP_COST_RETURN);
|
||||||
builder.setDrop(drop);
|
builder.setDrop(drop);
|
||||||
}
|
}
|
||||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.ExplorerMapEventResponse.getNumber(), builder.build(), true);
|
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,11 @@
|
||||||
package com.ljsd.jieling.handler.map.mapHandler;
|
package com.ljsd.jieling.handler.map.mapHandler;
|
||||||
|
|
||||||
import com.ljsd.jieling.exception.ErrorCode;
|
|
||||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
|
||||||
import com.ljsd.jieling.handler.BaseHandler;
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
import com.ljsd.jieling.handler.map.MapLogic;
|
|
||||||
import com.ljsd.jieling.logic.arena.ChallengeLogic;
|
import com.ljsd.jieling.logic.arena.ChallengeLogic;
|
||||||
import com.ljsd.jieling.logic.dao.TeamEnum;
|
|
||||||
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.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.network.session.ISession;
|
||||||
import com.ljsd.jieling.util.MessageUtil;
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
import config.SChallengeStage;
|
|
||||||
import manager.STableManager;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import rpc.protocols.CommonProto;
|
import rpc.protocols.CommonProto;
|
||||||
import rpc.protocols.MessageTypeProto;
|
import rpc.protocols.MessageTypeProto;
|
||||||
|
|
@ -40,7 +28,7 @@ public class ChallengeInfoHandler extends BaseHandler<PlayerInfoProto.ChallengeI
|
||||||
public void processWithProto(ISession iSession, PlayerInfoProto.ChallengeInfoRequest proto) throws Exception {
|
public void processWithProto(ISession iSession, PlayerInfoProto.ChallengeInfoRequest proto) throws Exception {
|
||||||
|
|
||||||
User user = UserManager.getUser(iSession.getUid());
|
User user = UserManager.getUser(iSession.getUid());
|
||||||
if(user == null){
|
if (user == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlayerInfoProto.ChallengeInfoResponse.Builder builder = PlayerInfoProto.ChallengeInfoResponse.newBuilder();
|
PlayerInfoProto.ChallengeInfoResponse.Builder builder = PlayerInfoProto.ChallengeInfoResponse.newBuilder();
|
||||||
|
|
@ -48,8 +36,8 @@ public class ChallengeInfoHandler extends BaseHandler<PlayerInfoProto.ChallengeI
|
||||||
for (int i = 1; i <= 2; i++) {
|
for (int i = 1; i <= 2; i++) {
|
||||||
CommonProto.ChallengeInfo.Builder info = CommonProto.ChallengeInfo.newBuilder()
|
CommonProto.ChallengeInfo.Builder info = CommonProto.ChallengeInfo.newBuilder()
|
||||||
.setType(i)
|
.setType(i)
|
||||||
.setOverTime(ChallengeLogic.status[i-1])
|
.setOverTime(ChallengeLogic.status[i - 1])
|
||||||
.setCurrentFloor(i== 1? user.getPlayerInfoManager().getEndlessNewReplica():user.getPlayerInfoManager().getTreasureReplica());
|
.setCurrentFloor(i == 1 ? user.getPlayerInfoManager().getEndlessNewReplica() : user.getPlayerInfoManager().getTreasureReplica());
|
||||||
builder.addInfo(info.build());
|
builder.addInfo(info.build());
|
||||||
}
|
}
|
||||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_INFO_RESPONSE.getNumber(), builder.build(), true);
|
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_INFO_RESPONSE.getNumber(), builder.build(), true);
|
||||||
|
|
|
||||||
|
|
@ -101,9 +101,12 @@ public class ChallengeLogic {
|
||||||
* 检测开启状态
|
* 检测开启状态
|
||||||
*/
|
*/
|
||||||
public void check() {
|
public void check() {
|
||||||
status[0] = 1;
|
|
||||||
status[1] = 1;
|
status[0] = 0;
|
||||||
/* int [][] config = {{1,3,5,7},{2,4,6,7}};
|
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];
|
//status = new int[2];
|
||||||
for(int i = 0; i < config.length; i++){
|
for(int i = 0; i < config.length; i++){
|
||||||
for(int j = 0; j < config[i].length; j++){
|
for(int j = 0; j < config[i].length; j++){
|
||||||
|
|
@ -113,7 +116,7 @@ public class ChallengeLogic {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChallengeInfoIndication(ISession session) throws Exception {
|
public void ChallengeInfoIndication(ISession session) throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,6 @@ public class SChallengeStage implements BaseConfig {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
Map<Integer, SChallengeStage> config = STableManager.getConfig(SChallengeStage.class);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue