Merge remote-tracking branch 'origin/luofu' into bt/duodui

# Conflicts:
#	serverlogic/src/main/java/com/ljsd/jieling/logic/sevenworld/SevenWorldLogic.java
duhui 2023-04-17 00:25:59 +08:00
commit 91448be2d0
20 changed files with 654 additions and 497 deletions

View File

@ -1475,8 +1475,7 @@ public class TimeUtils {
public static int getDayOfWeekBytime(long time) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time);
int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
return week;
return calendar.get(Calendar.DAY_OF_WEEK) - 1;
}
/**

View File

@ -150,8 +150,9 @@ public class FightDataUtil {
for(int i=2;i<length;i++){
int passivityId = Integer.parseInt(unitSkill[i]);
SPassiveSkillLogicConfig sPassiveSkillLogicConfig = SPassiveSkillLogicConfig.getConfig(passivityId);
if(sPassiveSkillLogicConfig.getCoverID()!=0)
if(sPassiveSkillLogicConfig.getCoverID()!=0){
tempSet.add(sPassiveSkillLogicConfig.getCoverID());
}
}
for(int i=2;i<length;i++){
LuaValue detail = new LuaTable();

View File

@ -31,24 +31,6 @@ public class CarDelayFunction implements FunctionManager {
@Override
public void startAction(TimeControllerOfFunction timeControllerOfFunction) throws Exception {
String backName = "backup";
AbstractRank personRank = RankContext.getRankEnum(RankEnum.CAR_DEALY_RANK.getType());
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.CAR_DEALY_GUILD_RANK.getType());
String key = RedisUtil.getInstence().getKey(personRank.getRedisKey(), "");
String guildKey = RedisUtil.getInstence().getKey(guildRank.getRedisKey(), "");
String crossKey = RedisUtil.getInstence().getKey(personRank.getCrossRedisKey(), "",false);
String crossGuildKey = RedisUtil.getInstence().getKey(guildRank.getCrossRedisKey(), "",false);
String carPeopleNum = RedisUtil.getInstence().getKey(RedisKey.CAR_DEALY_GUILD_FIGHT_PEOPLE_NUM,"");
String[] delKeys = {key,guildKey,crossKey,crossGuildKey,carPeopleNum};
RedisUtil.getInstence().rename(60*60*16, backName, delKeys);
// String userLevelGuild = RedisUtil.getInstence().getKey(RedisKey.USER_LEVEL_GUILD_INFO, "");
// delKeys.add(userLevelGuild);
LOGGER.error("车迟斗法备份排行榜:{}",Arrays.asList(delKeys));
MongoUtil.getLjsdMongoTemplate().lastUpdate();
}
@Override
@ -88,9 +70,12 @@ public class CarDelayFunction implements FunctionManager {
// 个人
String personTitle = SErrorCodeEerverConfig.getI18NMessage("family_fight_rank_personreward_title");
int nowTime = TimeUtils.nowInt();
int i = 0;
for(ZSetOperations.TypedTuple<String> rankInfo : personRangeWithScores){
i++;
int uid = Integer.parseInt(rankInfo.getValue());
long score = rankInfo.getScore().longValue();
LOGGER.info("车迟斗法发奖个人排行奖励uid{}rank{}score:{}",uid,i,score);
String rewardByRank = personRewardConfigTreeMap.floorEntry(score).getValue();
String personContent = SErrorCodeEerverConfig.getI18NMessageNeedConvert("family_fight_rank_personreward_txt",new Object[]{score},new int[]{0},"#");
MailLogic.getInstance().sendMailToRedis(uid,personTitle,personContent,rewardByRank,nowTime, Global.MAIL_EFFECTIVE_TIME);
@ -98,14 +83,17 @@ public class CarDelayFunction implements FunctionManager {
MongoUtil.getLjsdMongoTemplate().lastUpdate();
// 工会
i = 0;
String guildTitle = SErrorCodeEerverConfig.getI18NMessage("family_fight_rank_familyreward_title");
for(ZSetOperations.TypedTuple<String> rankInfo : guildRangeWithScores){
i++;
int guildId = Integer.parseInt(rankInfo.getValue());
GuildInfo guildInfo = GuilidManager.getGuildInfo(guildId);
if(guildInfo==null){
continue;
}
long score = rankInfo.getScore().longValue();
LOGGER.info("车迟斗法发奖公会排行奖励guildId{}rank{}score:{}",guildId,i,score);
String rewardByRank = guildRewardConfigTreeMap.floorEntry(score).getValue();
guildInfo.clearCarFightSb();
GuilidManager.saveOrUpdateGuildInfo(guildInfo);
@ -116,7 +104,15 @@ public class CarDelayFunction implements FunctionManager {
}
}
}
// 删除排行榜
String personKey = RedisUtil.getInstence().getKey(personRank.getRedisKey(), "");
String guildKey = RedisUtil.getInstence().getKey(guildRank.getRedisKey(), "");
String crossPersonKey = RedisUtil.getInstence().getKey(personRank.getCrossRedisKey(), "",false);
String crossGuildKey = RedisUtil.getInstence().getKey(guildRank.getCrossRedisKey(), "",false);
String carPeopleNum = RedisUtil.getInstence().getKey(RedisKey.CAR_DEALY_GUILD_FIGHT_PEOPLE_NUM,"");
LOGGER.info("车迟斗法清空排行榜==================={}{}{}{}{}",personKey,guildKey,crossPersonKey,crossGuildKey,carPeopleNum);
RedisUtil.getInstence().del(personKey,guildKey,crossPersonKey,crossGuildKey,carPeopleNum);
MongoUtil.getLjsdMongoTemplate().lastUpdate();
// RedisUtil.getInstence().del(lockKey);
}
}

View File

@ -3,13 +3,25 @@ package com.ljsd.jieling.core.function;
import com.ljsd.jieling.core.FunctionManager;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.logic.GlobleSystemLogic;
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
import com.ljsd.jieling.logic.dao.TimeControllerOfFunction;
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.logic.rank.RankContext;
import com.ljsd.jieling.logic.rank.RankEnum;
import com.ljsd.jieling.logic.sevenworld.SevenWorldLogic;
import config.SErrorCodeEerverConfig;
import config.SQijieRanking;
import manager.STableManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.ZSetOperations;
import util.StringUtil;
import util.TimeUtils;
import java.util.Map;
import java.util.Set;
/**
* @author lvxinran
@ -22,15 +34,57 @@ public class SevenWorldFunction implements FunctionManager {
@Override
public void closeAction(){
int crossGroup = GlobleSystemLogic.crossGroup;
String lockKey = "SEVEN_WORLD_RESET_LOCK" + RedisKey.Delimiter_colon + crossGroup;
boolean lock = RedisUtil.getInstence().lock(lockKey, TimeUtils.ONE_MINUTE*5);
if (!lock) {
//没有拿到锁直接返回
LOGGER.error("七界试炼,重置排行榜退出, key{} 跨服分组 ={},锁状态:{},未获取到锁",lockKey, crossGroup, lock);
return;
}
RedisUtil.getInstence().expire2(lockKey,TimeUtils.ONE_MINUTE*5);
LOGGER.info("七界试炼活动结束,开始发奖...");
// 排行榜
String crossRedisKey = RankContext.getRankEnum(RankEnum.CROSS_SEVEN_WORLD_RANK.getType()).getCrossRedisKey();
Set<ZSetOperations.TypedTuple<String>> range = RedisUtil.getInstence().getZsetreverseRangeWithScores(crossRedisKey,"",0,-1,false);
// 排名
int rank = 0;
for (ZSetOperations.TypedTuple<String> tuple : range) {
rank++;
int uid = Integer.parseInt(tuple.getValue());
CSPlayer player = CrossServiceLogic.getPlayerByRedis(uid);
if (player == null){
LOGGER.error("七界发奖玩家缓存找不到uid{},排名:{}",uid,rank);
continue;
}
// 清除道具标记
// SevenWorldLogic.setClearMark(uid);
if (TimeUtils.now() > (player.getOffLineTime()+TimeUtils.WEEK)){
LOGGER.error("七界发奖玩家登陆时间超过七天uid{},排名:{},最后登陆时间:{},当前时间:{}",uid,rank,TimeUtils.getTimeStamp2(player.getOffLineTime()),TimeUtils.nowStr());
continue;
}
String title = SErrorCodeEerverConfig.getI18NMessage("Qijie_mail_title");
String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("Qijie_mail_txt", new Object[]{rank},new int[0],"#");
// 排行奖励
Map<Integer, SQijieRanking> config = STableManager.getConfig(SQijieRanking.class);
for (SQijieRanking value : config.values()) {
// 排名区间
if (rank >= value.getMinRank() && rank <= value.getMaxRank()){
// 发邮件奖励
String reward = StringUtil.parseArrayToString(value.getRankingReward());
MailLogic.getInstance().sendMailToRedis(uid,title,content,reward,TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
LOGGER.info("七界试炼发奖uid{},排名:{},奖励:{},",uid,rank,reward);
break;
}
}
}
LOGGER.info("七界试炼发奖结束,开始清除排行榜...");
String key = RedisUtil.getInstence().getKey2(crossRedisKey, "");
RedisUtil.getInstence().del(key);
LOGGER.info("七界试炼重置结束,清理排行榜...{}",key);
}
@Override
public void startAction(TimeControllerOfFunction timeControllerOfFunction) {
// 清除排行榜信息
String crossRedisKey = RankContext.getRankEnum(RankEnum.CROSS_SEVEN_WORLD_RANK.getType()).getCrossRedisKey();
String key = RedisUtil.getInstence().getKey(crossRedisKey, "",false);
RedisUtil.getInstence().del(key);
SevenWorldLogic.setEnd(false);
LOGGER.info("七界试炼活动开始,清理排行榜...{}:{}",key,SevenWorldLogic.isEnd());
}
}

View File

@ -464,6 +464,10 @@ public class RedisKey {
*
*/
public static final String SEVEN_WORLD_INTEGRAL_RANK = "SEVEN_WORLD_INTEGRAL_RANK";
/**
*
*/
public static final String SEVEN_WORLD_MARK = "SEVEN_WORLD_MARK";
/**
*
@ -482,6 +486,9 @@ public class RedisKey {
// 邮件奖励
public static final String MAIL_REWARD_MARK = "MAIL_REWARD_MARK";
// 罗浮称号奖励标记
public static final String LUOFU_TITLE_REWARD_MARK = "LUOFU_TITLE_REWARD_MARK";
public static Set<String> newAreaCacChe = new HashSet<>();//进程排行 合区统一
public static Set<String> rankCacChe = new HashSet<>();

View File

@ -119,6 +119,27 @@ public class RedisUtil {
}
}
/**
*
*
* @param key
*
* @param time
* ()
* @return
*/
public boolean expire2(String key, long time) {
try {
if (time > 0) {
redisTemplate.expire(key, time, TimeUnit.MILLISECONDS);
}
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
/**
* key
@ -187,7 +208,7 @@ public class RedisUtil {
// 重命名
redisTemplate.rename(oldName,newName);
// 设置过期时间
expire(newName,time);
expire2(newName,time);
}
}
}
@ -212,7 +233,7 @@ public class RedisUtil {
// 重命名
redisTemplate.rename(oldName,newName);
// 设置过期时间
expire(newName,time);
expire2(newName,time);
}
}
return;
@ -1322,7 +1343,7 @@ public class RedisUtil {
}
}
public <T> void putMapEntry(String key,String mapKey, T value){
public <T> void putMapEntry2(String key,String mapKey, T value){
for (int i = 0; i < MAX_TRY_TIMES; i++) {
try {
redisTemplate.opsForHash().put(key,mapKey,gson.toJson(value));
@ -1379,7 +1400,7 @@ public class RedisUtil {
return null;
}
public <T> T getMapValue(String key, String mapKey, Class<T> clazz) {
public <T> T getMapValue2(String key, String mapKey, Class<T> clazz) {
for (int i = 0; i < MAX_TRY_TIMES; i++) {
try {
String valueStr = (String) redisTemplate.opsForHash().get(key, mapKey);
@ -1514,6 +1535,10 @@ public class RedisUtil {
return getKey(type,key,true);
}
public String getKey2(String type,String key){
return getKey(type,key,false);
}
/**
* key
* @param type

View File

@ -3,6 +3,7 @@ package com.ljsd.jieling.globals;
public interface Global {
int EXECUTION = 1;//行动力id
int STAMINA = 2; // 体力id
int TALISMAN = 3;//成长护符
int HEROSTORY_TICKET = 28; //精英入场券
int GENERALSTORY_TICKET = 27; //普通入场券
int INVASIONBOSS_TICKET = 44; //外敌挑战券
@ -17,7 +18,7 @@ public interface Global {
int TREASURE_SCORE = 68;//孙龙宝藏积分
int DAILY_TASK_REMOVE_ITEM = 30;//日常任务道具
int MISSING_ROOM_ITEM = 79;
int MISSING_ROOM_ITEM = 79;//寻龙钰
int SEND_CARD_COUNT = 20; // 每页发送卡牌个数
int SEND_ITEM_COUNT = 200; // 每页发送道具个数
int SEND_EQUIP_COUNT = 20; // 每页发送装备个数

View File

@ -4,18 +4,16 @@ import com.ljsd.jieling.logic.GlobalDataManaager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.util.InnerMessageUtil;
import com.ljsd.jieling.util.MessageUtil;
import rpc.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
import rpc.protocols.MessageTypeProto;
import rpc.protocols.PlayerInfoProto;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.LongStream;
@Component
public class ServerZeroHandler extends BaseHandler {
@ -29,8 +27,9 @@ public class ServerZeroHandler extends BaseHandler {
User user = UserManager.getUser(session.getUid());
List<Integer> array = new ArrayList<>();
array.add(session.getUid());
InnerMessageUtil.broadcastWithRandom(user1 -> GlobalDataManaager.flushGoodsTimes(user1),array,3,5);
InnerMessageUtil.broadcastWithRandom(GlobalDataManaager::flushGoodsTimes, array,3,5);
user.getUserMissionManager().onGameEvent(user, GameEvent.LOGIN_GAME,0);
LOGGER.info("零点,{}触发了零点功能结算功能",session.getUid());
GlobalDataManaager.checkNeedReFlush(session, UserManager.getUser(session.getUid()), PlayerInfoProto.FivePlayerUpdateIndication.newBuilder());
// int indicationIndex = session.getIndicationIndex();

View File

@ -74,9 +74,9 @@ public class GetWorldArenaInfoRequestHandler extends BaseHandler<WorldProto.GetW
Set<ZSetOperations.TypedTuple<String>> rankByKey = rank.getRankByKey(String.valueOf(crossGroup), 0, 20);
//处理第一次在休战期开启
if(rankByKey.size()<1){
builder.setStage(1);
builder.setStage(ArenaLogic.NORMAL_STATE);
}else{
builder.setStage(ArenaLogic.getInstance().getState());
builder.setStage(ArenaLogic.getState());
}
if (diff > setting.getRestTime()[0] && diff < setting.getRestTime()[1]) {

View File

@ -5,8 +5,6 @@ import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
import com.ljsd.jieling.core.FunctionIdEnum;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.db.mongo.MongoKey;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.handler.mission.Mission;
@ -18,8 +16,8 @@ import com.ljsd.jieling.logic.dao.PlayerManager;
import com.ljsd.jieling.logic.dao.TimeControllerOfFunction;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.player.PlayerLogic;
import util.MathUtils;
import manager.STableManager;
import util.MathUtils;
import util.TimeUtils;
import java.util.*;
@ -315,7 +313,7 @@ public class MapManager extends MongoBase {
int addValue = (updateTime - lastUpdateEnergyTime) / 60 / energyRecoverSpeed[1] * energyRecoverSpeed[0];
if (addValue != 0) {
int curEnergy = MathUtils.setBetweenWithMax(itemNum + addValue, 0, playerInfoManager.getMaxStamina());
item.setItemNum(curEnergy > playerInfoManager.getMaxStamina() ? playerInfoManager.getMaxStamina() : curEnergy);
item.setItemNum(Math.min(curEnergy, playerInfoManager.getMaxStamina()));
KtEventUtils.onKtEvent(user, ParamEventBean.UserItemEvent, BIReason.TIME_REWARD,GlobalsDef.addReason,item.getItemId(),addValue,item.getItemNum());
}
}

View File

@ -441,6 +441,8 @@ public class GlobalDataManaager implements IManager {
RidingSwardLogic.getInstance().zeroClearRidingSwardByUser(user);
// 公会援助
GuildLogic.getInstance().guildHelpDayHandler(user);
// 罗浮称号
ArenaLogic.getInstance().takeTitleReward(user);
WeekCardLogic.getInstance().weekCardInfoIndication(user,0,0);
ChallengeLogic.getInstance().ChallengeInfoIndication(session);

View File

@ -75,7 +75,7 @@ public class RidingSwardActivity extends AbstractActivity{
MailLogic.getInstance().sendMail(user.getId(),title,content,reward,TimeUtils.nowInt(),Global.MAIL_EFFECTIVE_TIME);
}
// 删除key
RedisUtil.getInstence().rename(TimeUtils.ONE_DAY*3/1000,RedisUtil.getInstence().getKey(RedisKey.RIDING_SWARD_RECORD, String.valueOf(user.getId())));
RedisUtil.getInstence().rename(TimeUtils.ONE_DAY*3,RedisUtil.getInstence().getKey(RedisKey.RIDING_SWARD_RECORD, String.valueOf(user.getId())));
}
}
}

View File

@ -34,10 +34,10 @@ public class AddItemHandler implements IEventHandler{
int lv = PlayerLogic.getInstance().getGodPrivilegeLv(user);
String key = RedisKey.GOD_LEVEL_UP_TIME + ":" + GameApplication.serverId + ":" + lv;
String uid = String.valueOf(user.getId());
UserGodLvVo userGodLvVo = RedisUtil.getInstence().getMapValue(key, uid, UserGodLvVo.class);
UserGodLvVo userGodLvVo = RedisUtil.getInstence().getMapValue2(key, uid, UserGodLvVo.class);
if (userGodLvVo == null){
userGodLvVo = new UserGodLvVo(user);
RedisUtil.getInstence().putMapEntry(key, uid, userGodLvVo);
RedisUtil.getInstence().putMapEntry2(key, uid, userGodLvVo);
}
}
}

View File

@ -78,15 +78,18 @@ public class MailLogic {
}
// 有限时间不为0并且当前时间大于 发送时间+有效时间
if (cMail.getEffectiveTime() != 0 && nowTime > (cMail.getEffectiveTime() + cMail.getSendTime())){
LOGGER.error("邮件删除,过期了,邮件信息:{},当前时间:{}", cMail,nowTime);
removeIds.add(cMail.getId());
continue;
}
String mailItem = cMail.getMailItem();
if(mailItem != null && mailItem.contains("null")){
LOGGER.error("邮件删除,邮件道具为空,邮件信息:{}", cMail);
removeIds.add(cMail.getId());
continue;
}
if(cMail.getNoUseDeleteTime()!=0&&cMail.getNoUseDeleteTime()<TimeUtils.now()){
LOGGER.error("邮件删除,邮件删除时间到,邮件信息:{},当前时间:{}", cMail,nowTime);
removeIds.add(cMail.getId());
continue;
}
@ -360,13 +363,16 @@ public class MailLogic {
Mail mail = new Mail(uid,title,content,reward,sendTime, mailEffectiveTime,"system",Global.MAIL_TYPE_SYS);
String key = RedisKey.MAIL_REWARD_MARK + RedisKey.Delimiter_colon + uid;
String timeKey = String.valueOf(TimeUtils.now());
RedisUtil.getInstence().putMapEntry(key,timeKey,mail);
RedisUtil.getInstence().putMapEntry2(key,timeKey,mail);
// 有新邮件就增加30天的有效时间
RedisUtil.getInstence().expire(key,60*60*24*30);
LOGGER.info("redis邮件标记key:{}, time:{}, mail{}",key,timeKey,mail);
}
//发送邮件
public void sendSpecialMail(int uid, String title, String content, String reward, int sendTime, int mailEffectiveTime,int isTop ,int markType) throws Exception {
/**
*
*/
public void sendSpecialMail(int uid, String title, String content, String reward, int sendTime, int mailEffectiveTime,int isTop ,int markType) {
try {
User user = UserManager.getUser(uid);
Mail mail = new Mail(uid,title,content,reward,sendTime, mailEffectiveTime,"system",Global.MAIL_TYPE_SYS,isTop,markType);

View File

@ -397,28 +397,23 @@ public class PlayerLogic {
for(Map.Entry<Integer,VipInfo> vipInfoItem : vipInfo.entrySet()){
privilegeList.add(CommonProto.Privilege.newBuilder()
.setId(vipInfoItem.getKey())
. setUsedTimes(vipInfoItem.getValue().getCount())
.setUsedTimes(vipInfoItem.getValue().getCount())
.setEffectTime(vipInfoItem.getValue().getEffectTime())
.build());
}
fBuilder.setHadTakeDailyBox(playerInfoManager.getHadTakeDailyBoxVip())
.addAllPrivilege(privilegeList);
fBuilder.setHadTakeDailyBox(playerInfoManager.getHadTakeDailyBoxVip()).addAllPrivilege(privilegeList);
}
}
public Set<CommonProto.Privilege> getPrivilege(User user, Collection<Integer> collection) {
Map<Integer, VipInfo> vipInfo = user.getPlayerInfoManager().getVipInfo();
Set<CommonProto.Privilege> collect = vipInfo.entrySet().stream()
return vipInfo.entrySet().stream()
.filter(integerVipInfoEntry -> collection.contains(integerVipInfoEntry.getKey()))
.map(integerVipInfoEntry -> CommonProto.Privilege.newBuilder()
.setId(integerVipInfoEntry.getKey())
.setUsedTimes(integerVipInfoEntry.getValue().getCount())
.setEffectTime(integerVipInfoEntry.getValue().getEffectTime())
.build()).collect(Collectors.toSet());
return collect;
}
public void sendVipDailyOrLevlUpReward(User user, int vipLevel,int reson) throws Exception {

View File

@ -2,27 +2,23 @@ package com.ljsd.jieling.logic.sevenworld;
import com.ljsd.GameApplication;
import com.ljsd.jieling.core.FunctionIdEnum;
import com.ljsd.jieling.core.HandlerLogicThread;
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.ktbeans.ReportEventEnum;
import com.ljsd.jieling.ktbeans.ReportUtil;
import com.ljsd.jieling.logic.GlobleSystemLogic;
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
import com.ljsd.jieling.logic.dao.Hero;
import com.ljsd.jieling.logic.dao.TeamEnum;
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.FightDispatcher;
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.item.ItemLogic;
import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.mission.MissionType;
import com.ljsd.jieling.logic.player.PlayerLogic;
@ -37,7 +33,6 @@ import config.*;
import manager.STableManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Component;
import rpc.protocols.CommonProto;
import rpc.protocols.MessageTypeProto;
@ -69,14 +64,6 @@ public class SevenWorldLogic {
private static boolean end = false;
public static boolean isEnd() {
return end;
}
public static void setEnd(boolean end) {
SevenWorldLogic.end = end;
}
/**
*
* @param user
@ -344,27 +331,31 @@ public class SevenWorldLogic {
int[][] jieLingReward = stage.getJielingReward();
// 奖励的拼接字符串
StringBuilder rewardStr = new StringBuilder();
// 七界积分特殊处理
int integralId = 1241;
int integralNum = 0;
for (int[] reward : jieLingReward) {
// 向上取整积分
int ceil = (int) Math.ceil(reward[1] * (buff / 10000));
// 排行榜积分
if (reward[0] == 1241) {
if (isEnd()) {
// 规定时间不获得积分
continue;
}
int rewardNum = reward[1] + ceil;
if (reward[0] == integralId) {
// 排行榜添加积分
addRank(user.getId(),reward[1] + ceil);
LOGGER.info("七界得分uid{}score{} qieji{}",user.getId(),reward[1] + ceil, stage);
addRank(user.getId(), rewardNum);
LOGGER.info("七界得分uid{}score{} qieji{}",user.getId(), rewardNum, stage);
integralNum+=rewardNum;
continue;
}
rewardStr.append(reward[0]).append("#").append(reward[1] + ceil).append("|");
rewardStr.append(reward[0]).append("#").append(rewardNum).append("|");
}
// 1241,七界积分不如背包,只展示用
CommonProto.Item.Builder item = CommonProto.Item.newBuilder().setItemId(integralId).setItemNum(integralNum);
drop.addItemlist(item);
// string转int二维数组
int[][] rewardMap = StringUtil.parseFiledInt2(rewardStr.substring(0, rewardStr.length() - 1));
ItemUtil.drop(user,rewardMap,drop,BIReason.SEVEN_WORLD_CHALLENGE);
// 七界秘宝积分,没有加成
ItemUtil.drop(user,new int[][]{stage.getTreasureIntegral()},drop,BIReason.SEVEN_WORLD_CHALLENGE);
// 数数埋点
List<String> dropResult = new ArrayList<>();
ReportUtil.dropToString(drop,dropResult);
@ -381,11 +372,27 @@ public class SevenWorldLogic {
rankEnum.addRank(uid,"",score);
}
public static void setMark(int uid,int score){
AbstractRank rankEnum = RankContext.getRankEnum(RankEnum.CROSS_SEVEN_WORLD_RANK.getType());
rankEnum.addRank(uid,"",score);
}
/**
*
*/
// public static void setClearMark(int uid){
// String key2 = RedisUtil.getInstence().getKey2(RedisKey.SEVEN_WORLD_MARK, String.valueOf(uid));
// RedisUtil.getInstence().set(key2,"1");
// LOGGER.info("七界发奖后添加清理标记uid{}key{}",uid,key2);
// }
/**
*
*/
// public static void getClearMark(int uid){
// String key2 = RedisUtil.getInstence().getKey2(RedisKey.SEVEN_WORLD_MARK, String.valueOf(uid));
// if (key2 == null){
// return;
// }
// ItemLogic.getInstance().functionEndClearItem(uid, FunctionIdEnum.CrossSevenWorld.getFunctionType(), BIReason.SEVEN_WORLD_FUNCTION_END);
// LOGGER.info("七界发奖后首次获取信息清理道具uid{}",uid);
// RedisUtil.getInstence().remove(key2);
// }
/**
*
@ -439,64 +446,93 @@ public class SevenWorldLogic {
return map;
}
/**
*
*/
public void sendRankReward(){
if (isTime()){
LOGGER.info("七界试炼活动结束,开始发奖...{{}}",isEnd());
SevenWorldLogic.setEnd(true);
// 排行榜
String crossRedisKey = RankContext.getRankEnum(RankEnum.CROSS_SEVEN_WORLD_RANK.getType()).getCrossRedisKey();
Set<ZSetOperations.TypedTuple<String>> range = RedisUtil.getInstence().getZsetreverseRangeWithScores(crossRedisKey,"",0,-1,false);
// 排名
int rank = 0;
for (ZSetOperations.TypedTuple<String> tuple : range) {
rank++;
int uid = Integer.parseInt(tuple.getValue());
CSPlayer player = CrossServiceLogic.getPlayerByRedis(uid);
if (player == null){
LOGGER.error("七界发奖玩家缓存找不到uid{},排名:{}",uid,rank);
continue;
}
if (TimeUtils.now() > (player.getOffLineTime()+TimeUtils.WEEK)){
LOGGER.error("七界发奖玩家登陆时间超过七天uid{},排名:{},最后登陆时间:{},当前时间:{}",uid,rank,TimeUtils.getTimeStamp2(player.getOffLineTime()),TimeUtils.nowStr());
continue;
}
User user = UserManager.getUserNotCache(uid);
if (user == null){
continue;
}
String title = SErrorCodeEerverConfig.getI18NMessage("Qijie_mail_title");
String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("Qijie_mail_txt", new Object[]{rank},new int[0],"#");
// 排行奖励
Map<Integer, SQijieRanking> config = STableManager.getConfig(SQijieRanking.class);
for (SQijieRanking value : config.values()) {
// 排名区间
if (rank >= value.getMinRank() && rank <= value.getMaxRank()){
// 发邮件奖励
String reward = StringUtil.parseArrayToString(value.getRankingReward());
MailLogic.getInstance().sendMail(user.getId(),title,content,reward,TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
// 清除道具
ItemLogic.getInstance().functionEndClearItem(user.getId(),FunctionIdEnum.CrossSevenWorld.getFunctionType(),BIReason.SEVEN_WORLD_FUNCTION_END);
LOGGER.info("七界结束发送邮件并删除道具uid{},奖励:{},",user.getId(),reward);
break;
}
}
}
LOGGER.info("七界试炼活动结束,发奖完成...{{}}",isEnd());
}
}
/**
* 2330
*/
private boolean isTime(){
int week = TimeUtils.getDayOfWeek();
int hour = TimeUtils.getHourOfDay();
int minute = TimeUtils.getMiunte();
// LOGGER.info("当前时间week:{},hour:{},minute:{},result:{}",week,hour,minute,b);
return week == 7 && hour == 23 && minute == 30;
}
// public static void setEnd(int value){
// RedisUtil redisUtil = RedisUtil.getInstence();
// String key = redisUtil.getKey2(RedisKey.SEVEN_WORLD_MARK, String.valueOf(GlobleSystemLogic.crossGroup));
// redisUtil.set(key,String.valueOf(value));
// }
//
// public static int getEnd(){
// RedisUtil redisUtil = RedisUtil.getInstence();
// String key = redisUtil.getKey2(RedisKey.SEVEN_WORLD_MARK, String.valueOf(GlobleSystemLogic.crossGroup));
// Object obj = redisUtil.get(key);
// if (obj == null){
// obj = 0;
// }
// return (int)obj;
// }
//
// /**
// * 每周末的2400分重置排行榜积分
// */
// public void overSevenWorld(){
// int week = TimeUtils.getDayOfWeek();
// int hour = TimeUtils.getHourOfDay();
// int minute = TimeUtils.getMiunte();
// // 发奖时间
// boolean sendRewardTime = week == 7 && hour == 23 && minute == 30;
// if (sendRewardTime){
// LOGGER.info("七界试炼活动结束,开始发奖...{{}}", getEnd());
// SevenWorldLogic.setEnd(1);
// // 排行榜
// String crossRedisKey = RankContext.getRankEnum(RankEnum.CROSS_SEVEN_WORLD_RANK.getType()).getCrossRedisKey();
// Set<ZSetOperations.TypedTuple<String>> range = RedisUtil.getInstence().getZsetreverseRangeWithScores(crossRedisKey,"",0,-1,false);
// // 排名
// int rank = 0;
// for (ZSetOperations.TypedTuple<String> tuple : range) {
// rank++;
// int uid = Integer.parseInt(tuple.getValue());
// CSPlayer player = CrossServiceLogic.getPlayerByRedis(uid);
// if (player == null){
// LOGGER.error("七界发奖玩家缓存找不到uid{},排名:{}",uid,rank);
// continue;
// }
// if (TimeUtils.now() > (player.getOffLineTime()+TimeUtils.WEEK)){
// LOGGER.error("七界发奖玩家登陆时间超过七天uid{},排名:{},最后登陆时间:{},当前时间:{}",uid,rank,TimeUtils.getTimeStamp2(player.getOffLineTime()),TimeUtils.nowStr());
// continue;
// }
// User user = UserManager.getUserNotCache(uid);
// if (user == null){
// continue;
// }
// String title = SErrorCodeEerverConfig.getI18NMessage("Qijie_mail_title");
// String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("Qijie_mail_txt", new Object[]{rank},new int[0],"#");
// // 排行奖励
// Map<Integer, SQijieRanking> config = STableManager.getConfig(SQijieRanking.class);
// for (SQijieRanking value : config.values()) {
// // 排名区间
// if (rank >= value.getMinRank() && rank <= value.getMaxRank()){
// // 发邮件奖励
// String reward = StringUtil.parseArrayToString(value.getRankingReward());
// MailLogic.getInstance().sendMail(user.getId(),title,content,reward,TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
// // 清除道具
// ItemLogic.getInstance().functionEndClearItem(user.getId(),FunctionIdEnum.CrossSevenWorld.getFunctionType(),BIReason.SEVEN_WORLD_FUNCTION_END);
// LOGGER.info("七界结束发送邮件并删除道具uid{},奖励:{},",user.getId(),reward);
// break;
// }
// }
// }
// LOGGER.info("七界试炼活动结束,发奖完成...{{}}", getEnd());
// }
//
// // 重置排行榜时间
// boolean resetTime = week == 1 && hour == 0 && minute == 0;
// if (resetTime){
// int crossGroup = GlobleSystemLogic.crossGroup;
// String lockKey = "SEVEN_WORLD_RESET_LOCK" + RedisKey.Delimiter_colon + crossGroup;
// boolean lock = RedisUtil.getInstence().lock(lockKey, TimeUtils.ONE_SECOND * 60);
// if (!lock) {
// //没有拿到锁直接返回
// LOGGER.error("七界试炼,重置排行榜退出, key{} 跨服分组 ={},锁状态:{},未获取到锁",lockKey, crossGroup, lock);
// return;
// }
// // 清除排行榜信息
// String crossRedisKey = RankContext.getRankEnum(RankEnum.CROSS_SEVEN_WORLD_RANK.getType()).getCrossRedisKey();
// String key = RedisUtil.getInstence().getKey(crossRedisKey, "",false);
// RedisUtil.getInstence().del(key);
// SevenWorldLogic.setEnd(0);
// LOGGER.info("七界试炼重置结束,清理排行榜...{}:{}",key,SevenWorldLogic.getEnd());
// }
// }
}

View File

@ -14,42 +14,37 @@ import com.ljsd.jieling.logic.GlobleSystemLogic;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.SituationLogic;
import com.ljsd.jieling.logic.activity.ActivityLogic;
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
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.arena.CrossLingmaiLogic;
import com.ljsd.jieling.logic.arena.CrossYuxulundaoLogic;
import com.ljsd.jieling.logic.dao.GuildMyInfo;
import com.ljsd.jieling.logic.dao.GuilidManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.explorerMap.ExplorerMapLogic;
import com.ljsd.jieling.logic.family.CrossDeathPathLogic;
import com.ljsd.jieling.logic.family.DeathPathLogic;
import com.ljsd.jieling.logic.family.GuildFightLogic;
import com.ljsd.jieling.logic.family.GuildLogic;
import com.ljsd.jieling.logic.help.HelpHeroLogic;
import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.logic.question.QuestionLogic;
import com.ljsd.jieling.logic.rank.CrossRankManager;
import com.ljsd.jieling.logic.rank.RankLogic;
import com.ljsd.jieling.logic.sevenworld.SevenWorldLogic;
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
import com.ljsd.jieling.logic.store.StoreLogic;
import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.thread.ThreadManager;
import com.ljsd.jieling.util.AyyncWorker;
import com.ljsd.jieling.util.MessageUtil;
import manager.STableManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import util.TimeUtils;
import java.util.*;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
public class MinuteTask extends Thread {
private static final Logger LOGGER = LoggerFactory.getLogger(MinuteTask.class);
@ -109,12 +104,6 @@ public class MinuteTask extends Thread {
LOGGER.error("Exception::=>{}",e.toString());
}
try {
SevenWorldLogic.getInstance().sendRankReward();
}catch (Exception e){
e.printStackTrace();
LOGGER.error("七界Exception::=>{}",e.toString());
}
try {
// 跨服分组
everyMondayZeroClockTask();
@ -183,7 +172,7 @@ public class MinuteTask extends Thread {
}
try {
ArenaLogic.getInstance().worldSendReward();
ArenaLogic.getInstance().checkState();
}catch (Exception e){
e.printStackTrace();
LOGGER.error("Exception::=>{}",e.toString());

View File

@ -79,14 +79,13 @@ public class CBean2Proto {
if(itemNum == -1){
itemNum = item.getItemNum();
}
CommonProto.Item itemProto = CommonProto.Item
return CommonProto.Item
.newBuilder()
.setItemId(item.getItemId())
.setItemNum(itemNum)
.setEndingTime(item.getEndingTime())
.setNextFlushTime(item.getEndingTime() + getRecoverSpeedByItem(item.getItemId()))
.build();
return itemProto;
}
/**

View File

@ -1917,18 +1917,18 @@ public class ItemUtil {
*
* @param user
* @param reason
* @param itemType
* @param itemId
* @param sourceNum
* @return
*/
public static long privilegeAdd(User user,int reason,int itemType,long sourceNum){
public static long privilegeAdd(User user,int reason,int itemId,long sourceNum){
// 基础奖励,挂机
if(reason == BIReason.ADVENTURE_BASE_REWARD){
sourceNum = baseReward(user, itemType, sourceNum);
sourceNum = baseReward(user, itemId, sourceNum);
}
// 随机奖励,挂机
if(reason == BIReason.ADVENTURE_RANDOM_REWARDD){
sourceNum = randomReward(user, itemType, sourceNum);
sourceNum = randomReward(user, itemId, sourceNum);
}
return sourceNum;
}
@ -1945,6 +1945,8 @@ public class ItemUtil {
case Global.EXP:
sourceNum = parseTheValueByPrivilegeMap(user,sourceNum,VipPrivilegeType.ADVENTURE_EXP_REWARD);
break;
case Global.GOLD:
case Global.TALISMAN:
case Global.MISSING_ROOM_ITEM:
sourceNum = parseTheValueByPrivilegeMap(user,sourceNum, VipPrivilegeType.ADVENTURE_BASE_REWARD);
break;