跨服灵妙秘境

xuexinpeng 2021-11-17 16:35:43 +08:00
parent 676dce9bf8
commit e7e12c7228
12 changed files with 320 additions and 71 deletions

View File

@ -6,9 +6,9 @@ import java.util.List;
public class ArenaRecord {
private String id;
private String id;//灵脉秘境id
private int type; // 1 人机对战 2 : 真人对战 3:机机对战
private int type; // 玉虚1:人机对战 2:真人对战 3:机机对战 灵脉秘境 0:占领灵脉 1:被抢夺灵脉
private int attackId; //进攻者
@ -34,7 +34,7 @@ public class ArenaRecord {
private int head;
private String userName;
private String userName; //灵脉秘境 对方玩家名字
private int headFrame;//头像框
@ -60,6 +60,8 @@ public class ArenaRecord {
private int practiceLevel;
private int occurTime;
public ArenaRecord() {
}
@ -278,4 +280,12 @@ public class ArenaRecord {
public void setYxldDefScoreChange(int yxldDefScoreChange) {
this.yxldDefScoreChange = yxldDefScoreChange;
}
public int getOccurTime() {
return occurTime;
}
public void setOccurTime(int occurTime) {
this.occurTime = occurTime;
}
}

View File

@ -6,6 +6,9 @@ public class LingMaiSecretArea {
private String serverName;
private String name;
private long getAwardTimeOrOccupyTime;//得到奖励的时间或者占领的灵脉的时间
//当日总积分 = score1+基础收益*occupyTime
private int score1;//当前结算分 被人打下去后 这个分才会有值
private int occupyTime;//占领的时长 以分钟为单位
public int getId() {
return id;
@ -46,4 +49,21 @@ public class LingMaiSecretArea {
public void setGetAwardTimeOrOccupyTime(long getAwardTimeOrOccupyTime) {
this.getAwardTimeOrOccupyTime = getAwardTimeOrOccupyTime;
}
public int getScore1() {
return score1;
}
public void setScore1(int score1) {
this.score1 = score1;
}
public int getOccupyTime() {
return occupyTime;
}
public void setOccupyTime(int occupyTime) {
this.occupyTime = occupyTime;
}
}

View File

@ -365,6 +365,10 @@ public class RedisKey {
//跨服 灵脉秘境
public static final String CROSS_LINGMAISECRET_INFO= "CROSS_LINGMAISECRET_INFO";//灵脉所有的占领信息
public static final String CROSS_LINGMAISECRET_RECORD = "CROSS_LINGMAISECRET_RECORD";//灵脉记录
public static final String CROSS_LINGMAI_RANK_PERSON = "CROSS_LINGMAI_RANK_PERSON";//灵脉积分排行
public static Set<String> familyKey = new HashSet<>();
/**

View File

@ -1,6 +1,8 @@
package com.ljsd.jieling.handler.crossServer;
import com.google.gson.Gson;
import com.ljsd.GameApplication;
import com.ljsd.fight.ArenaRecord;
import com.ljsd.fight.FightType;
import com.ljsd.fight.LingMaiSecretArea;
import com.ljsd.jieling.db.redis.RedisKey;
@ -10,6 +12,7 @@ import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.gtw.GetWorldArenaChallengeRequestHandler;
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.arena.CrossLingmaiLogic;
import com.ljsd.jieling.logic.dao.ArenaManager;
@ -24,6 +27,9 @@ 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.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.network.session.ISession;
import com.ljsd.jieling.thrift.idl.CrossArenaManager;
import com.ljsd.jieling.util.MessageUtil;
@ -62,6 +68,19 @@ public class CrossLingmaiSecretAreaBattleHandler extends BaseHandler<ArenaInfoPr
int group = SMServerLodeSetting.getGroupByLevel(arenaManager.getCrossLingmaiFirstLevel());
//CROSS_LINGMAISECRET_INFO:跨服分组:分组
Map<String, LingMaiSecretArea> lingMaiMap = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + group, String.class, LingMaiSecretArea.class);
int myLingmaiId = CrossLingmaiLogic.getInstance().getLingmaiIdOccupy(uid,lingMaiMap);
if(myLingmaiId >= id){
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.CrossLingmaiSecretAreaResponse.getNumber(), res.build(), true);
return;
}
//跨服灵脉锁
RedisUtil redisUtil = RedisUtil.getInstence();
boolean lock = redisUtil.lock("SERVER_LINGMAI_LOCK"+ RedisKey.Delimiter_colon +crossGroup + RedisKey.Delimiter_colon + group, TimeUtils.ONE_MILLSECOND*500 );
if(!lock){
//没有拿到锁直接返回
LOGGER.info("跨服灵脉,跨服分组 ={},灵脉分组 ={},未获取到锁",crossGroup,group);
return;
}
if (!lingMaiMap.containsKey(String.valueOf(id))) {
//没人占领 攻击机器人 pve
SLodeConfig config = SLodeConfig.lodeConfig.get(id);
@ -70,14 +89,13 @@ public class CrossLingmaiSecretAreaBattleHandler extends BaseHandler<ArenaInfoPr
}
PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), TeamEnum.CROSS_LING_MAI_SECRET_AREA.getTeamId(), 20, "", GameFightType.CrossLingMaiSecretFight, config.getGuard(), 3);
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
//response.setFightData(fightResult.getFightData());
CommonProto.FightData fightData = CommonProto.FightData.newBuilder()
.setFightMaxTime(20)
.setFightSeed(fightResult.getSeed())
.setHeroFightInfos(fightResult.getFightTeamInfo())
.addAllMonsterList(fightResult.getMonsterTeamList())
.setFightType(FightType.CrossLingMaiSecretFight.getType())
.setFightId(FightUtil.getFightId(user.getId(), FightType.TaSuiLingXiao.getType()))
.setFightId(FightUtil.getFightId(user.getId(), FightType.CrossLingMaiSecretFight.getType()))
.build();
res.setFightData(fightData);
if(fightResult.getResult()==-1){
@ -123,11 +141,72 @@ public class CrossLingmaiSecretAreaBattleHandler extends BaseHandler<ArenaInfoPr
int result = (int) fightResult.getCheckResult()[0];
res.setFightData(build);
if(result == 1){
//赢了 易主
//赢了 我有灵脉 我没灵脉
//积分收益结算
LingMaiSecretArea oldOwner = lingMaiMap.get(String.valueOf(id));//上一个占领者
int second =(TimeUtils.nowInt()-oldOwner.getOccupyTime())/60>10?10:(TimeUtils.nowInt()-oldOwner.getOccupyTime());
int score =oldOwner.getScore1()+1* second;
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_LINGMAI_RANK_PERSON.getType());
rank.addRank(user.getId(), String.valueOf(crossGroup)+RedisKey.Delimiter_colon + group, score);
if(myLingmaiId !=0) {
//本人已有灵脉结算
LingMaiSecretArea myLingmai = lingMaiMap.get(String.valueOf(myLingmaiId));//上一个占领者
second =(TimeUtils.nowInt()-myLingmai.getOccupyTime())/60>10?10:(TimeUtils.nowInt()-myLingmai.getOccupyTime());
score =myLingmai.getScore1()+1* second;
rank = RankContext.getRankEnum(RankEnum.CROSS_LINGMAI_RANK_PERSON.getType());
rank.addRank(user.getId(), String.valueOf(crossGroup)+RedisKey.Delimiter_colon + group, score);
//两边都计算分 置换
oldOwner.setScore1(score);
RedisUtil.getInstence().putMapEntry(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + group, String.valueOf(myLingmaiId),oldOwner);
}
//易主
LingMaiSecretArea lingMaiSecretArea = CrossLingmaiLogic.getLingaMaiData(id,uid,user);
RedisUtil.getInstence().putMapEntry(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + group, String.valueOf(id),lingMaiSecretArea);
}
//挑战记录
//挑战者记录
String key1 = RedisKey.getKey(RedisKey.CROSS_LINGMAISECRET_RECORD, String.valueOf(user.getId()), false);
long defLenth = redisUtil.lGetListSize(key1);
if (defLenth > 20) {
redisUtil.lPop(key1);
}
ArenaRecord arenaRecord = new ArenaRecord();
arenaRecord.setType(0);
arenaRecord.setUserName(csPlayer.getName());
arenaRecord.setId(String.valueOf(id));
arenaRecord.setPracticeLevel(csPlayer.getPracticeLevel());
//arenaRecord.setPracticeLevel(user.getHeroManager().getPracticeLevel());//修行等级 TODO
arenaRecord.setCreateTime(TimeUtils.nowInt());
String defarenaRecordJson = new Gson().toJson(arenaRecord);
redisUtil.lSet(key1, defarenaRecordJson);
//被挑战者记录
String key2 = RedisKey.getKey(RedisKey.CROSS_LINGMAISECRET_RECORD, String.valueOf(defUid), false);
long defLenth2 = redisUtil.lGetListSize(key2);
if (defLenth2 > 20) {
redisUtil.lPop(key2);
}
ArenaRecord arenaRecordDef = new ArenaRecord();
arenaRecordDef.setType(1);
arenaRecordDef.setUserName(user.getPlayerInfoManager().getNickName());
arenaRecordDef.setId(String.valueOf(id));
arenaRecordDef.setPracticeLevel(user.getHeroManager().getPracticeLevel());
//arenaRecord.setPracticeLevel(user.getHeroManager().getPracticeLevel());//修行等级 TODO
arenaRecordDef.setCreateTime(TimeUtils.nowInt());
String defarenaRecordJsonDef = new Gson().toJson(arenaRecordDef);
redisUtil.lSet(key2, defarenaRecordJsonDef);
//被抢占 给在线的被抢占玩家发红点
ISession sess= OnlineUserManager.sessionMap.get(defUid);
if(sess!=null){
ArenaInfoProto.CrossLingmaiIndicationResponse indication = ArenaInfoProto.CrossLingmaiIndicationResponse.newBuilder().build();
MessageUtil.sendIndicationMessage(sess, 1, MessageTypeProto.MessageType.CrossLingmaiIndicationResponse_VALUE, indication, true);
}
}else{
//输记录
}
//释放分布式锁
redisUtil.del("SERVER_LINGMAI_LOCK"+ RedisKey.Delimiter_colon +crossGroup + RedisKey.Delimiter_colon + group);
}
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.CrossLingmaiSecretAreaResponse.getNumber(), res.build(), true);
}

View File

@ -5,10 +5,12 @@ import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.GlobleSystemLogic;
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
import com.ljsd.jieling.logic.arena.CrossYuxulundaoLogic;
import com.ljsd.jieling.logic.championship.ChampionshipLogic;
import com.ljsd.jieling.logic.dao.ArenaManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
import com.ljsd.jieling.logic.dao.root.GuildCache;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.network.session.ISession;
@ -35,9 +37,6 @@ public class CrossLingmaiSecretAreaInfoHandler extends BaseHandler<ArenaInfoProt
@Override
public void processWithProto(ISession session, ArenaInfoProto.CrossLingmaiSecretAreaInfoRequest request) throws Exception{
//ChampionshipLogic.MemberInfo memberInfo = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_JOIN, "", Integer.toString(uid), ChampionshipLogic.MemberInfo.cl
//ChampionshipLogic.MemberInfo memberInfo = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_JOIN, "", Integer.toString(uid), ChampionshipLogic.MemberInfo.class);
int uid = session.getUid();
User user = UserManager.getUser(uid);
if (user == null) {
@ -58,38 +57,62 @@ public class CrossLingmaiSecretAreaInfoHandler extends BaseHandler<ArenaInfoProt
}
int group = SMServerLodeSetting.getGroupByLevel(arenaManager.getCrossLingmaiFirstLevel());
int page = request.getPage();
//CROSS_LINGMAISECRET_INFO:跨服分组:分组
Map<String, LingMaiSecretArea> lingMaiMap = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup+RedisKey.Delimiter_colon+group, String.class, LingMaiSecretArea.class);
if(page == 0){
int id = lingMaiMap.values().stream().filter(n->n.getUid()==uid).mapToInt(n->n.getId()).sum();
if(SLodeConfig.lodeConfig.get(id)!=null){
page = SLodeConfig.lodeConfig.get(id).getPageNo();
}else {
//找到第一个未被占领的灵脉
for(Map.Entry<Integer, SLodeConfig> configEntry:SLodeConfig.lodeConfig.entrySet()){
if(!lingMaiMap.containsKey(configEntry.getKey())){
page = SLodeConfig.lodeConfig.get(configEntry.getValue().getPageNo()).getPageNo();
break;
}
}
}
}
List<SLodeConfig> pageConfig= SLodeConfig.getByGroupAndPageNo(group,page);
if(pageConfig==null){
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.CrossLingmaiSecretAreaInfoResponse.getNumber(), res.build(), true);
return;
}
int myOccupyId = 0;
int myOccupyTime = 0;
//CROSS_LINGMAISECRET_INFO:跨服分组:分组
Map<String, LingMaiSecretArea> lingMaiMap = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup+RedisKey.Delimiter_colon+group, String.class, LingMaiSecretArea.class);
//自己相关的
List<LingMaiSecretArea> matchMyInfoList = lingMaiMap.values().stream().filter(n->n.getUid()==uid).collect(Collectors.toList());
if(matchMyInfoList!=null&&matchMyInfoList.size()>0){
myOccupyId = matchMyInfoList.get(0).getId();
myOccupyTime = (int)matchMyInfoList.get(0).getGetAwardTimeOrOccupyTime();
}
//当前页面数据
for(SLodeConfig config:pageConfig){
if(lingMaiMap.containsKey(config.getId())){
CommonProto.LingMaiSecret lingMaiSecret =CommonProto.LingMaiSecret.newBuilder().
setGetAwardTimeOrOccupyTime((int)lingMaiMap.get(config.getId()).getGetAwardTimeOrOccupyTime()).
setId(lingMaiMap.get(config.getId()).getId()).
setUid(lingMaiMap.get(config.getId()).getUid()).
setServerName(lingMaiMap.get(config.getId()).getServerName()).
setUserName(lingMaiMap.get(config.getId()).getName()).build();
res.addRecordData(lingMaiSecret);
if(lingMaiMap.containsKey(String.valueOf(config.getId()))){
CSPlayer csPlayer = CrossServiceLogic.getPlayerByRedis(lingMaiMap.get(String.valueOf(config.getId())).getUid());
CommonProto.ArenaPersonInfo lingMaiSecret = CommonProto.ArenaPersonInfo.newBuilder()
.setUid(lingMaiMap.get(String.valueOf(config.getId())).getUid())
.setLevel(csPlayer.getLevel())
.setName(csPlayer.getName())
.setServername(lingMaiMap.get(String.valueOf(config.getId())).getServerName())
.setTotalForce(csPlayer.getMaxFore()) //.setTotalForce(crossArenaManager.getTotalForce())
.setUserTitle(csPlayer.getUserTitle())
.setUserMount(csPlayer.getUserMount())
.setGender(csPlayer.getSex())
.setUserSkin(csPlayer.getSkin())
.setPracticeLevel(csPlayer.getPracticeLevel())
.setScore(csPlayer.getCrossYuxulundaoNewScore())
.setHead(csPlayer.getHead())
.setHeadFrame(csPlayer.getHeadFrame())
.setLingmaiId(lingMaiMap.get(String.valueOf(config.getId())).getId())
.build();
res.addLingmaiData(lingMaiSecret);
}else{
//没人占领 给机器人数据
CommonProto.LingMaiSecret lingMaiSecret =CommonProto.LingMaiSecret.newBuilder().setId(config.getId()).build();
res.addRecordData(lingMaiSecret);
CommonProto.ArenaPersonInfo lingMaiSecret = CommonProto.ArenaPersonInfo.newBuilder().setLingmaiId(config.getId()).build();
res.addLingmaiData(lingMaiSecret);
}
}
res.setMyOccupyId(myOccupyId);

View File

@ -1,10 +1,21 @@
package com.ljsd.jieling.handler.crossServer;
import com.google.gson.Gson;
import com.ljsd.fight.ArenaRecord;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.util.MessageUtil;
import rpc.protocols.ArenaInfoProto;
import rpc.protocols.CommonProto;
import rpc.protocols.MessageTypeProto;
import java.util.Collections;
import java.util.List;
public class CrossLingmaiSecretAreaRecordHandler extends BaseHandler<ArenaInfoProto.CrossLingmaiSecretAreaRecordRequest> {
@ -15,9 +26,25 @@ public class CrossLingmaiSecretAreaRecordHandler extends BaseHandler<ArenaInfoPr
@Override
public void processWithProto(ISession session, ArenaInfoProto.CrossLingmaiSecretAreaRecordRequest request) throws Exception{
int uid = session.getUid();
User user = UserManager.getUser(uid);
if (user == null) {
return;
}
ArenaInfoProto.CrossLingmaiSecretAreaRecordResponse.Builder builder = ArenaInfoProto.CrossLingmaiSecretAreaRecordResponse.newBuilder();
RedisUtil redisUtil = RedisUtil.getInstence();
List<String> list = redisUtil.lGet(RedisKey.CROSS_LINGMAISECRET_RECORD, String.valueOf(uid), 0, -1);
Collections.reverse(list);
if (list != null){
for(String s:list){
ArenaRecord arenaRecord = new Gson().fromJson(s, ArenaRecord.class);
CommonProto.LingMaiSecretRecord record = CommonProto.LingMaiSecretRecord.newBuilder().setType(arenaRecord.getType())
.setUserName(user.getPlayerInfoManager().getNickName())
.setDefName(arenaRecord.getUserName()).setLingMaiId(Integer.parseInt(arenaRecord.getId()))
.setTime(arenaRecord.getOccurTime()).setPracticeLevel(arenaRecord.getPracticeLevel()).build();
builder.addRecordData(record);
}
}
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.CrossLingmaiSecretAreaRecordResponse.getNumber(), builder.build(), true);
}
}

View File

@ -5,19 +5,26 @@ import com.ljsd.fight.LingMaiSecretArea;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.globals.BIReason;
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.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
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.rank.rankImpl.AbstractRank;
import com.ljsd.jieling.util.ItemUtil;
import config.SErrorCodeEerverConfig;
import config.SLodeConfig;
import config.SLodeRankReward;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import util.StringUtil;
import util.TimeUtils;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
*
@ -39,10 +46,19 @@ public class CrossLingmaiLogic {
}
public int getLingmaiIdOccupy(int uid, Map<String, LingMaiSecretArea> lingMaiMap){
for (Map.Entry<String, LingMaiSecretArea> data :lingMaiMap.entrySet()){
if(data.getValue().getUid()==uid){
return Integer.parseInt(data.getKey());
}
}
return 0;
}
public static LingMaiSecretArea getLingaMaiData(int id, int uid, User user){
LingMaiSecretArea lingMaiSecretArea = new LingMaiSecretArea();
lingMaiSecretArea.setId(id);
lingMaiSecretArea.setId(uid);
lingMaiSecretArea.setUid(uid);
String serverName = CrossServiceLogic.simplifyServerName(GameApplication.serverId);
lingMaiSecretArea.setServerName(serverName);
lingMaiSecretArea.setName(user.getPlayerInfoManager().getNickName());
@ -50,47 +66,74 @@ public class CrossLingmaiLogic {
return lingMaiSecretArea;
}
public static void updateLingmaiData(Map<String, LingMaiSecretArea> lingMaiMap,int crossGroup,int group){
int nowTime = TimeUtils.nowInt();
for(Map.Entry<String, LingMaiSecretArea> map:lingMaiMap.entrySet()){
try{
User user = UserManager.getUser(map.getValue().getUid());
if(user!=null){
SLodeConfig config = SLodeConfig.lodeConfig.get(map.getValue().getId());
if(config!=null){
int occupyTime = (int) map.getValue().getGetAwardTimeOrOccupyTime();
int difVal = (nowTime-occupyTime)/60>=10?10:(nowTime-occupyTime)/60;
map.getValue().setOccupyTime(map.getValue().getOccupyTime()+difVal);
map.getValue().setGetAwardTimeOrOccupyTime(TimeUtils.nowInt());
RedisUtil.getInstence().putMapEntry(RedisKey.CROSS_LINGMAISECRET_INFO,
crossGroup + RedisKey.Delimiter_colon + group, map.getKey(),map.getValue());
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_LINGMAI_RANK_PERSON.getType());
int score =map.getValue().getOccupyTime()*1+map.getValue().getScore1();//TODO 乘以每分钟收益
rank.addRank(user.getId(), String.valueOf(crossGroup)+RedisKey.Delimiter_colon + group, score);
}
}
}catch (Exception e){
e.printStackTrace();
}
}
}
/**
*
*/
public void sendOccypyReward(){
//周二 四 六 日开放 9点-21点
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
if (crossGroup == -1){
return;
}
Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
int w = calendar.get(Calendar.DAY_OF_WEEK) - 1;
if(w==0 || w ==2|| w==4 || w == 6){
if(hour>9&&hour<21){
Map<String, LingMaiSecretArea> lingMaiMap1 = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + 1, String.class, LingMaiSecretArea.class);
Map<String, LingMaiSecretArea> lingMaiMap2 = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + 2, String.class, LingMaiSecretArea.class);
Map<String, LingMaiSecretArea> lingMaiMap = new HashMap<String, LingMaiSecretArea>();
lingMaiMap.putAll(lingMaiMap1);
lingMaiMap.putAll(lingMaiMap2);
int nowTime = TimeUtils.nowInt();
for(Map.Entry<String, LingMaiSecretArea> map:lingMaiMap.entrySet()){
try{
User user = UserManager.getUser(map.getValue().getUid());
if(user!=null){
SLodeConfig config = SLodeConfig.lodeConfig.get(map.getValue().getId());
if(config!=null){
int occupyTime = (int) map.getValue().getGetAwardTimeOrOccupyTime();
int difVal = (nowTime-occupyTime)/60>10?10:(nowTime-occupyTime)/60;
for(int i=0;i<difVal;i++){
ItemUtil.drop(user,config.getRewardList(), BIReason.GM_REWARD);
}
map.getValue().setGetAwardTimeOrOccupyTime(TimeUtils.nowInt());
}
}
}catch (Exception e){
e.printStackTrace();
}
}
}
Map<String, LingMaiSecretArea> lingMaiMap1 = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + 1, String.class, LingMaiSecretArea.class);
Map<String, LingMaiSecretArea> lingMaiMap2 = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + 2, String.class, LingMaiSecretArea.class);
updateLingmaiData(lingMaiMap1,crossGroup,1);
updateLingmaiData(lingMaiMap2,crossGroup,2);
}
/**
*
*/
public void sendMailReward(){
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
if (crossGroup == -1){
return;
}
String rkey1 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAI_RANK_PERSON, Integer.toString(crossGroup)+"1");
String rkey2 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAI_RANK_PERSON, Integer.toString(crossGroup)+"2");
Set<String> arenaRank1 = RedisUtil.getInstence().getReverseZset(rkey1, 0, -1);
Set<String> arenaRank2= RedisUtil.getInstence().getReverseZset(rkey2, 0, -1);
sendMailReward(arenaRank1);
sendMailReward(arenaRank2);
}
public void sendMailReward(Set<String> arenaRank){
List<Integer> arenaRankfilt = arenaRank.stream().mapToInt(n -> Integer.parseInt(n)).filter(n -> n > 1000).boxed().collect(Collectors.toList());
String title = SErrorCodeEerverConfig.getI18NMessage("LingmaiReward_mail_title");
for(int i=0;i<arenaRankfilt.size();i++){
SLodeRankReward config = SLodeRankReward.getIdByScore(i+1);
try{
String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("LingmaiReward_mail_txt",new Object[]{(i + 1)},new int[0],"#");
MailLogic.getInstance().sendMail(arenaRankfilt.get(i), title, content,
StringUtil.parseArrayToString(config.getSeasonReward()), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
}catch (Exception e) {
e.printStackTrace();
}
}
}
}

View File

@ -50,7 +50,7 @@ public enum GameFightType {
CrossYuxulundaoFight(FightType.CrossYuxulundaoFight,new PVPFightHandler(),null),
FourChallenge(FightType.FourChallenge,new DefaultWithoutHandFightHandler(),null),
SevenWorld(FightType.QIJIE_FIGHT,new SevenWorldFightHandler(),null),
CrossLingMaiSecretFight(FightType.CrossLingMaiSecretFight,new PVPFightHandler(),null),
CrossLingMaiSecretFight(FightType.CrossLingMaiSecretFight,new DefaultWithoutHandFightHandler(),null),
;

View File

@ -59,6 +59,8 @@ public enum RankEnum {
CROSS_YUXULUNDAO_RANK(37,RedisKey.CROSS_YUXULUNDAO_RANK,CrossYuXuLunDaoRank::new,true),//跨服玉虚论道
CROSS_SEVEN_WORLD_RANK(39,RedisKey.SEVEN_WORLD_INTEGRAL_RANK,CrossRank::new,true),//跨服七届试炼
CROSS_YUXULUNDAO_RANK_PERSON(40,RedisKey.CROSS_YUXULUNDAO_RANK_PERSON,CrossYuXuLunDaoPersonRank::new,true),//跨服玉虚论道真人排行榜
CROSS_LINGMAI_RANK_PERSON(41,RedisKey.CROSS_LINGMAI_RANK_PERSON,CrossLingmaiSecretRank::new,true),//跨服灵脉秘境积分排行榜
;
private int type;

View File

@ -0,0 +1,18 @@
package com.ljsd.jieling.logic.rank.rankImpl;
public class CrossLingmaiSecretRank extends AbstractRank {
public CrossLingmaiSecretRank(int type, String redisKey) {
super(type, redisKey);
}
@Override
public long[] getDataByScore(Double score) {
return new long[0];
}
@Override
public double getScore(double... data) {
return 0;
}
}

View File

@ -312,9 +312,24 @@ public class MinuteTask extends Thread {
Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
int mod = minute%10;
if(mod ==0 ){
CrossLingmaiLogic.getInstance().sendOccypyReward();
int w = calendar.get(Calendar.DAY_OF_WEEK) - 1;
//周二 四 六 日开放 9点-21点
if(w==0 || w ==2|| w==4 || w == 6){
//占领奖励
if(hour>9&&hour<21){
int mod = minute%10;
if(mod ==0 ){
CrossLingmaiLogic.getInstance().sendOccypyReward();
}
}
//结算每日排行奖励
if(hour ==21 && minute==0){
//删除数据
CrossLingmaiLogic.getInstance().sendOccypyReward();
}
}
}
}

View File

@ -18,12 +18,20 @@ public class SLodeRankReward implements BaseConfig {
private int[][] titleReward;
public static Map<Integer, SLodeRankReward> lodeRankReward;
@Override
public void init() throws Exception {
lodeRankReward = STableManager.getConfig(SLodeRankReward.class);
}
public static SLodeRankReward getIdByScore(int rank){
for(SLodeRankReward config: lodeRankReward.values()){
if(rank>=config.getMinRank()&& rank<= config.getMaxRank()){
return config;
}
}
return null;
}
public int getId() {
return id;