小兵功能四版,挂机空奖励处理,异常处理

master_dev
grimm 2024-03-19 17:49:33 +08:00
parent 9766c5ccc7
commit 956c1a0603
10 changed files with 82 additions and 74 deletions

View File

@ -37,8 +37,6 @@ public class LoopQueue<T> {
this.diffTime = diffTime;
}
//添加一个新的元素到循环队列中
public synchronized void push(T obj,long messageId) {
this.queueList[writeIndex%maxlen].setObj(obj,messageId);

View File

@ -4,6 +4,7 @@ import com.ljsd.GameApplication;
import com.ljsd.jieling.core.function.FunctionContext;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.exception.ErrorTableException;
import com.ljsd.jieling.exception.ErrorUtil;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.GlobleSystemLogic;
@ -13,13 +14,13 @@ import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.network.session.ISession;
import rpc.protocols.MessageTypeProto;
import com.ljsd.jieling.util.AyyncWorker;
import com.ljsd.jieling.util.MessageUtil;
import config.SGlobalSystemConfig;
import manager.STableManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rpc.protocols.MessageTypeProto;
import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue;
@ -114,8 +115,8 @@ public class HandlerLogicThread extends Thread{
try {
transaction.callback();
//内部codeErr统一处理
if(e instanceof ErrorCodeException){
int errCode = ErrorUtil.getExceptionErrorCodeValue(e);
if(e instanceof ErrorCodeException || e instanceof ErrorTableException){
int errCode = ErrorUtil.getExceptionErrorCode(e);
LOGGER.error("An unusual ErrorCodeException occurred for the user={} errCode={} e={}",
session.getUid(), errCode, e);
if (errCode <= 0) {

View File

@ -1,9 +1,6 @@
package com.ljsd.jieling.exception;
import java.util.HashSet;
import java.util.Set;
/**
* Description:
* a
@ -22,7 +19,6 @@ import java.util.Set;
*/
public enum ErrorCode implements IErrorCode {
SYS_ERROR_CODE(-100, "系统错误"),
RELOGIN_CODE(-101, "重复登陆"),
KICK_USER_CODE(-102, "踢用户下线"),
@ -189,18 +185,17 @@ public enum ErrorCode implements IErrorCode {
RECHARGE_NUM_NOT(157,"充值金额不足"),
BEFORE_CONDITION_NOT(158,"前置条件不足"),
ACCOUNT_ERROR(-104,"帐号异常,被封号"),
;
private static final Set<Integer> CodeSet = new HashSet<>();
static {
for (ErrorCode errorCode : ErrorCode.values()) {
if (errorCode.code() > 0 && CodeSet.contains(errorCode.code())) {
System.out.print("err errcode repeat");
}
CodeSet.add(errorCode.code());
}
}
// private static final Set<Integer> CodeSet = new HashSet<>();
//
// static {
// for (ErrorCode errorCode : ErrorCode.values()) {
// if (errorCode.code() > 0 && CodeSet.contains(errorCode.code())) {
// System.out.print("err errcode repeat");
// }
// CodeSet.add(errorCode.code());
// }
// }
//系统错误
public static final int sysErrorCode = -100;

View File

@ -10,25 +10,21 @@ public class ErrorUtil {
public ErrorUtil() {
}
private static ErrorCode getExceptionErrorCode(Throwable e) {
if (e == null) {
return ErrorCode.UNKNOWN;
} else {
public static int getExceptionErrorCode(Throwable e) {
int code = ErrorCode.UNKNOWN.code();
if (e != null){
Throwable t = e;
ErrorCode r = ErrorCode.UNKNOWN;
do {
if (t instanceof ErrorCodeException) {
r = ((ErrorCodeException) t).getCode();
code = ((ErrorCodeException) t).getCode().code();
}
else if (t instanceof ErrorTableException){
code = ((ErrorTableException) t).getCode();
}
t = t.getCause();
} while (t != null);
return r;
}
}
public static int getExceptionErrorCodeValue(Throwable e) {
return getExceptionErrorCode(e).code();
return code;
}
public static String getExceptionMessage(Throwable e) {
@ -40,7 +36,7 @@ public class ErrorUtil {
do {
if (!(t instanceof ErrorCodeException)) {
builder.append(t.getClass().getSimpleName()).append(":").append(t.getMessage()).append(" ");
} else if (t.getMessage() != null && t.getMessage().length() > 0) {
} else if (t.getMessage() != null && !t.getMessage().isEmpty()) {
builder.append(t.getMessage()).append(" ");
}
t = t.getCause();
@ -58,7 +54,11 @@ public class ErrorUtil {
} else {
StringBuilder builder = new StringBuilder();
if(e instanceof ErrorCodeException){
builder.append(e.toString());
builder.append(e);
builder.append(System.getProperty("line.separator"));
}
else if (e instanceof ErrorTableException){
builder.append(e);
builder.append(System.getProperty("line.separator"));
}
Throwable t = e;

View File

@ -1680,7 +1680,7 @@ public class MapLogic {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
KtEventUtils.onKtEvent(user,ParamEventBean.UserGameType,KTGameType.STORY.getIndex(),fightId);
// KtEventUtils.onKtEvent(user,ParamEventBean.UserGameType,KTGameType.STORY.getIndex(),fightId);
user.getTeamPosManager().setCurTeamPosId(teamId);
mainFightOfRedis(uid,fightId,teamId);

View File

@ -168,12 +168,12 @@ public class GmActivityLogic implements IEventHandler {
GmMission gmMission = gmActivity.getMissionMap().getOrDefault(arbMission.getId(), new GmMission());
// 已领取
if (gmMission.getState() == 1){
LOGGER.error("默认返利档位已领取userid{}, 活动id{} 档位id{}", user.getId(),gmActivity.getId(),gmMission.getId());
// LOGGER.error("默认返利档位已领取userid{}, 活动id{} 档位id{}", user.getId(),gmActivity.getId(),gmMission.getId());
continue;
}
// 不能领
if (num < arbMission.getRechargeNum()){
LOGGER.error("默认返利金额不足userid{}, 活动id{} 金额:{}-{}", user.getId(),gmActivity.getId(),num,arbMission.getRechargeNum());
// LOGGER.error("默认返利金额不足userid{}, 活动id{} 金额:{}-{}", user.getId(),gmActivity.getId(),num,arbMission.getRechargeNum());
continue;
}
// 发邮件
@ -197,19 +197,19 @@ public class GmActivityLogic implements IEventHandler {
int num = gmActivity.getValue() + (int) price;
// do-while循环重置奖励后再次验证
boolean verify;
LOGGER.info("单日累充第一步userid{}, 活动id{} 金额:{}", user.getId(),gmActivity.getId(),num);
// LOGGER.info("单日累充第一步userid{}, 活动id{} 金额:{}", user.getId(),gmActivity.getId(),num);
do {
verify = false;
for (ARBMission arbMission : gmMissionList) {
GmMission gmMission = gmActivity.getMissionMap().getOrDefault(arbMission.getId(), new GmMission());
// 已领取
if (gmMission.getState() == 1){
LOGGER.error("单日累充档位已领取userid{}, 活动id{} 档位id{}", user.getId(),gmActivity.getId(),gmMission.getId());
// LOGGER.error("单日累充档位已领取userid{}, 活动id{} 档位id{}", user.getId(),gmActivity.getId(),gmMission.getId());
continue;
}
// 不能领
if (num < arbMission.getRechargeNum()){
LOGGER.error("单日累充金额不足userid{}, 活动id{} 金额:{}-{}", user.getId(),gmActivity.getId(),num,arbMission.getRechargeNum());
// LOGGER.error("单日累充金额不足userid{}, 活动id{} 金额:{}-{}", user.getId(),gmActivity.getId(),num,arbMission.getRechargeNum());
continue;
}
// 发邮件
@ -248,12 +248,12 @@ public class GmActivityLogic implements IEventHandler {
GmMission gmMission = gmActivity.getMissionMap().getOrDefault(arbMission.getId(), new GmMission());
// 已领取
if (gmMission.getState() == 1){
LOGGER.error("单笔充值奖励档位已领取userid{}, 活动id{} 档位id{}", user.getId(),gmActivity.getId(),gmMission.getId());
// LOGGER.error("单笔充值奖励档位已领取userid{}, 活动id{} 档位id{}", user.getId(),gmActivity.getId(),gmMission.getId());
continue;
}
// 不能领
if (price != arbMission.getRechargeNum()){
LOGGER.error("单笔充值奖励金额对比失败userid{}, 活动id{} 金额:{}-{}", user.getId(),gmActivity.getId(),price,arbMission.getRechargeNum());
// LOGGER.error("单笔充值奖励金额对比失败userid{}, 活动id{} 金额:{}-{}", user.getId(),gmActivity.getId(),price,arbMission.getRechargeNum());
continue;
}
// 发邮件
@ -274,7 +274,7 @@ public class GmActivityLogic implements IEventHandler {
private void getRewardToMonsterCurrencyBack(User user, GmActivity gmActivity, double price) throws Exception {
Map<String, ARBMission> missionMap = findAllGmMissionMap(gmActivity.getId());
if (missionMap == null || missionMap.isEmpty()) {
LOGGER.error("妖晶返利活动详细档位信息未配置userid{}, 活动id{}", user.getId(), gmActivity.getId());
// LOGGER.error("妖晶返利活动详细档位信息未配置userid{}, 活动id{}", user.getId(), gmActivity.getId());
return;
}
// 档位排序
@ -288,7 +288,7 @@ public class GmActivityLogic implements IEventHandler {
// 最低要求
int limit = arbMissions.get(0).getBeforeNum();
if (sumMoney < limit || sumMoney <= 0) {
LOGGER.error("妖晶返利活动充值金额不足最低领取调解userid{},活动id{},当前累充金额:{},最低条件:{}", user.getId(), gmActivity.getId(), sumMoney, limit);
// LOGGER.error("妖晶返利活动充值金额不足最低领取调解userid{},活动id{},当前累充金额:{},最低条件:{}", user.getId(), gmActivity.getId(), sumMoney, limit);
return;
}
// 首次计算标记

View File

@ -3,7 +3,6 @@ package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.globals.GlobalItemType;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.CombatLogic;
import config.SItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -60,6 +59,11 @@ public class EquipManager extends MongoBase {
updateString("equipMap." + equip.getId(), equip);
}
public void updateEquip(PropertyItem equip){
equipMap.put(equip.getId(),equip);
updateString("equipMap", equipMap);
}
public void removeEquip(String equipId){
if (!equipMap.containsKey(equipId)){
return;
@ -132,6 +136,7 @@ public class EquipManager extends MongoBase {
PropertyItem faxiang = getEquip(key);
if (faxiang != null){
faxiang.setHeroId(heroId);
updateEquip(faxiang);
}
}

View File

@ -277,16 +277,20 @@ public class SoldierLogic {
long round = (stageConfig.getHp() / attack) + 1;
// 每回合耗时
int attackTime = SSpecialConfig.getIntegerValue("Soldiers_Attack_Time");
if (attackTime * round < stageConfig.getTime()){
throw new ErrorTableException(161);//战斗失败
}
// 更新关卡id和挂机时间
mainLevelManager.setSoldierLayerId(stageConfig.getNextId());
mainLevelManager.putSoldierState(stageConfig.getId(), TimeUtils.nowInt());
// 通关奖励
CommonProto.Drop.Builder drop = ItemUtil.drop(user, stageConfig.getReward(), BIReason.SOLDIER_MIAN_LEVEL_REWARD, 0);
MapInfoProto.SoldierFightCheckResponse.Builder builder = MapInfoProto.SoldierFightCheckResponse.newBuilder().setDrop(drop);
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ReplaceSoldierResponse_VALUE, builder.build(), true);
MapInfoProto.SoldierFightCheckResponse.Builder builder = MapInfoProto.SoldierFightCheckResponse.newBuilder();
if (attackTime * round > stageConfig.getTime()){
builder.setResult(0);//战斗失败
}else {
// 更新关卡id和挂机时间
mainLevelManager.setSoldierLayerId(stageConfig.getNextId());
mainLevelManager.putSoldierState(stageConfig.getId(), TimeUtils.nowInt());
// 通关奖励
CommonProto.Drop.Builder drop = ItemUtil.drop(user, stageConfig.getReward(), BIReason.SOLDIER_MIAN_LEVEL_REWARD, 0);
builder.setDrop(drop);
builder.setResult(1);
}
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.SoldierFightCheckResponse_VALUE, builder.build(), true);
}
}

View File

@ -1051,37 +1051,39 @@ public class CBean2Proto {
PlayerInfoProto.GetMainLevelInfoResponse.Builder builder = PlayerInfoProto.GetMainLevelInfoResponse.newBuilder()
.setFightId(mainLevelManager.getFightId())
.setState(state)
.setDuration(duration);
.setDuration(duration)
.setSoldierLayerId(mainLevelManager.getSoldierLayerId())
.setSoldierStartTime(mainLevelManager.getSoldierRestartTime());
Map<Integer, HashSet<String>> bossIds = mainLevelManager.getBossIds();
boolean update =false;
boolean update = false;
Map<String, Integer> myHurtInfo = new HashMap<>(1);
if(!bossIds.isEmpty()){
myHurtInfo=RedisUtil.getInstence().old_getmapvalue_toclass(RedisKey.ADVENTRUEN_BOSS_OWN, Integer.toString(user.getId()), String.class, Integer.class);
}
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(mainLevelManager.getFightId());
for(Map.Entry<Integer, HashSet<String>> item : bossIds.entrySet()){
Set<String> value = item.getValue();
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(mainLevelManager.getFightId());
Set<String> removeCache = new HashSet<>();
for(String bossId : value){
AdventureBoss adventureBoss = RedisUtil.getInstence().old_getmapvalue(RedisKey.ADVENTRUEN_BOSS_INFO, "", bossId, AdventureBoss.class);
if(adventureBoss != null){
int findBossTime = adventureBoss.getFindTime();
int remainTime =sMainLevelConfig.getInvasionBossHolding()-(now - findBossTime);
if(remainTime>0){
builder.addAdventureBossInfo(CommonProto.AdventureBossInfo.newBuilder()
.setArenaId(adventureBoss.getArenaId())
.setFindUid(adventureBoss.getFindUserId())
.setFindName(user.getPlayerInfoManager().getNickName())
.setBossId(bossId)
.setBossGroupId(adventureBoss.getBossGroupId())
.setMyHurt(myHurtInfo.get(bossId))
.setLevelTime(remainTime+now)
.setTotalHp(adventureBoss.getTotalHp())
.setArenaLevel(adventureBoss.getArenaLevel())
.setBossRemainlHp(adventureBoss.getRemainHp())
.build()
);
int remainTime = sMainLevelConfig.getInvasionBossHolding()-(now - findBossTime);
if(remainTime > 0){
CommonProto.AdventureBossInfo build = CommonProto.AdventureBossInfo.newBuilder()
.setArenaId(adventureBoss.getArenaId())
.setFindUid(adventureBoss.getFindUserId())
.setFindName(user.getPlayerInfoManager().getNickName())
.setBossId(bossId)
.setBossGroupId(adventureBoss.getBossGroupId())
.setMyHurt(myHurtInfo.get(bossId))
.setLevelTime(remainTime + now)
.setTotalHp(adventureBoss.getTotalHp())
.setArenaLevel(adventureBoss.getArenaLevel())
.setBossRemainlHp(adventureBoss.getRemainHp())
.build();
builder.addAdventureBossInfo(build);
}else{
removeCache.add(bossId);
}
@ -1091,7 +1093,7 @@ public class CBean2Proto {
}
if(!removeCache.isEmpty()){
value.removeAll(removeCache);
update =true;
update = true;
}
}
if(update){

View File

@ -314,6 +314,9 @@ public class ItemUtil {
public static void combineRewardByMainLineNotCycle(User user, boolean fiexdOrRandom, List<int[][]> groupList, ItemMap itemObj, int reason) throws ErrorCodeException{
for (int[][] list : groupList) {
int[] groups = list[0];
if (groups == null){
continue;
}
int time = list[1][0];
combineReward(user, fiexdOrRandom, groups, time, itemObj);
}