跨服灵脉秘境
parent
d4daed3d65
commit
dc98b314ae
|
@ -66,13 +66,17 @@ public class CrossLingmaiSecretAreaInfoHandler extends BaseHandler<ArenaInfoProt
|
|||
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();
|
||||
//lingMaiMap.values().stream().anyMatch(n -> n.getUid() == uid).
|
||||
if (SLodeConfig.lodeConfig.get(id) != null) {
|
||||
page = SLodeConfig.lodeConfig.get(id).getPageNo();
|
||||
} else {
|
||||
//找到第一个未被占领的灵脉
|
||||
//找到第一个未被占领的灵脉 所在的页
|
||||
for (Map.Entry<Integer, SLodeConfig> configEntry : SLodeConfig.lodeConfig.entrySet()) {
|
||||
if(configEntry.getValue().getGroup() != group){
|
||||
continue;
|
||||
}
|
||||
if (!lingMaiMap.containsKey(configEntry.getKey())) {
|
||||
page = SLodeConfig.lodeConfig.get(configEntry.getValue().getPageNo()).getPageNo();
|
||||
page = SLodeConfig.lodeConfig.get(configEntry.getKey()).getPageNo();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.ljsd.GameApplication;
|
|||
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;
|
||||
|
@ -14,18 +13,18 @@ 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 config.SMServerLodeSetting;
|
||||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -39,51 +38,11 @@ public class CrossLingmaiLogic {
|
|||
public CrossLingmaiLogic() {
|
||||
}
|
||||
|
||||
public static class Instance {
|
||||
public final static CrossLingmaiLogic instance = new CrossLingmaiLogic();
|
||||
|
||||
}
|
||||
public static CrossLingmaiLogic getInstance() {
|
||||
return CrossLingmaiLogic.Instance.instance;
|
||||
}
|
||||
|
||||
|
||||
//功能是否开启 关闭、休战 、战斗
|
||||
public void functionIsOpen(int [] result){
|
||||
SMServerLodeSetting setting = SMServerLodeSetting.lodeConfig.get(1);
|
||||
int[][]restTime = setting.getRestTime();
|
||||
int[][]battleTime = setting.getBattleTime();
|
||||
long mondayZeroTime = TimeUtils.getWeekZero(1);
|
||||
//休战期
|
||||
for(int [] everyTime:restTime){
|
||||
if(TimeUtils.now()>=mondayZeroTime+everyTime[0]*1000 && TimeUtils.now()<=mondayZeroTime+everyTime[1]*1000){
|
||||
result[0]=2;
|
||||
result[1]=(int)(mondayZeroTime/1000)+everyTime[1];
|
||||
return;
|
||||
}
|
||||
}
|
||||
//抢夺期
|
||||
for(int [] everyTime:battleTime){
|
||||
if(TimeUtils.now()>mondayZeroTime+everyTime[0]*1000 && TimeUtils.now()<mondayZeroTime+everyTime[1]*1000){
|
||||
result[0]=1;
|
||||
result[1]=(int)(mondayZeroTime/1000)+everyTime[1];
|
||||
return;
|
||||
}
|
||||
}
|
||||
result[0]=0;
|
||||
result[1]=0;
|
||||
}
|
||||
|
||||
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){
|
||||
public static LingMaiSecretArea getLingaMaiData(int id, int uid, User user) {
|
||||
LingMaiSecretArea lingMaiSecretArea = new LingMaiSecretArea();
|
||||
lingMaiSecretArea.setId(id);
|
||||
lingMaiSecretArea.setUid(uid);
|
||||
|
@ -94,79 +53,134 @@ public class CrossLingmaiLogic {
|
|||
return lingMaiSecretArea;
|
||||
}
|
||||
|
||||
public static void updateLingmaiData(Map<String, LingMaiSecretArea> lingMaiMap,int crossGroup,int group){
|
||||
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{
|
||||
for (Map.Entry<String, LingMaiSecretArea> map : lingMaiMap.entrySet()) {
|
||||
try {
|
||||
User user = UserManager.getUser(map.getValue().getUid());
|
||||
if(user!=null){
|
||||
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;
|
||||
if (config != null) {
|
||||
int occupyTime = (int) map.getValue().getGetAwardTimeOrOccupyTime();
|
||||
int difVal = (nowTime - occupyTime) / 60 >= 10 ? 10 : (nowTime - occupyTime) / 60;
|
||||
//difVal =1 ;
|
||||
map.getValue().setOccupyTime(map.getValue().getOccupyTime()+difVal);
|
||||
map.getValue().setOccupyTime(map.getValue().getOccupyTime() + difVal);
|
||||
map.getValue().setGetAwardTimeOrOccupyTime(TimeUtils.nowInt());
|
||||
LOGGER.error("玩家"+map.getValue().getUid()+"获得"+difVal);
|
||||
LOGGER.error("玩家" + map.getValue().getUid() + "获得" + difVal);
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.CROSS_LINGMAISECRET_INFO,
|
||||
crossGroup + RedisKey.Delimiter_colon + group, map.getKey(),map.getValue());
|
||||
crossGroup + RedisKey.Delimiter_colon + group, map.getKey(), map.getValue());
|
||||
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_LINGMAI_RANK_PERSON.getType());
|
||||
int score =map.getValue().getOccupyTime()*config.getRewardList()[0][1]+map.getValue().getScore1();
|
||||
double test =rank.getScoreById(user.getId(),crossGroup + RedisKey.Delimiter_colon + group);
|
||||
LOGGER.error("之前是:"+test +"之后是:"+score);
|
||||
rank.addRank(user.getId(), String.valueOf(crossGroup)+RedisKey.Delimiter_colon + group, score);
|
||||
int score = map.getValue().getOccupyTime() * config.getRewardList()[0][1] + map.getValue().getScore1();
|
||||
double test = rank.getScoreById(user.getId(), crossGroup + RedisKey.Delimiter_colon + group);
|
||||
LOGGER.error("之前是:" + test + "之后是:" + score);
|
||||
rank.addRank(user.getId(), String.valueOf(crossGroup) + RedisKey.Delimiter_colon + group, score);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//功能是否开启 0未开启 1抢夺 2休战
|
||||
public void functionIsOpen(int[] result) {
|
||||
SMServerLodeSetting setting = SMServerLodeSetting.lodeConfig.get(1);
|
||||
int[][] restTime = setting.getRestTime();
|
||||
int[][] battleTime = setting.getBattleTime();
|
||||
long mondayZeroTime = TimeUtils.getWeekZero(1);
|
||||
//休战期
|
||||
for (int[] everyTime : restTime) {
|
||||
if (TimeUtils.now() >= mondayZeroTime + everyTime[0] * 1000 && TimeUtils.now() <= mondayZeroTime + everyTime[1] * 1000) {
|
||||
result[0] = 2;
|
||||
result[1] = (int) (mondayZeroTime / 1000) + everyTime[1];
|
||||
return;
|
||||
}
|
||||
}
|
||||
//抢夺期
|
||||
for (int[] everyTime : battleTime) {
|
||||
if (TimeUtils.now() > mondayZeroTime + everyTime[0] * 1000 && TimeUtils.now() < mondayZeroTime + everyTime[1] * 1000) {
|
||||
result[0] = 1;
|
||||
result[1] = (int) (mondayZeroTime / 1000) + everyTime[1];
|
||||
return;
|
||||
}
|
||||
}
|
||||
result[0] = 0;
|
||||
result[1] = 0;
|
||||
}
|
||||
|
||||
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 void sendOccypyReward(){
|
||||
public void sendOccypyReward() {
|
||||
//周二 四 六 日开放 9点-21点
|
||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
if (crossGroup == -1){
|
||||
if (crossGroup == -1) {
|
||||
return;
|
||||
}
|
||||
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);
|
||||
updateLingmaiData(lingMaiMap1, crossGroup, 1);
|
||||
updateLingmaiData(lingMaiMap2, crossGroup, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 结算奖励
|
||||
*/
|
||||
public void sendMailReward(){
|
||||
public void sendMailReward() {
|
||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
if (crossGroup == -1){
|
||||
if (crossGroup == -1) {
|
||||
return;
|
||||
}
|
||||
String rkey1 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAI_RANK_PERSON, Integer.toString(crossGroup)+ RedisKey.Delimiter_colon +"1");
|
||||
String rkey2 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAI_RANK_PERSON, Integer.toString(crossGroup)+ RedisKey.Delimiter_colon +"2");
|
||||
String rkey1 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAI_RANK_PERSON, Integer.toString(crossGroup) + RedisKey.Delimiter_colon + "1");
|
||||
String rkey2 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAI_RANK_PERSON, Integer.toString(crossGroup) + RedisKey.Delimiter_colon + "2");
|
||||
Set<String> arenaRank1 = RedisUtil.getInstence().getReverseZset(rkey1, 0, -1);
|
||||
Set<String> arenaRank2= RedisUtil.getInstence().getReverseZset(rkey2, 0, -1);
|
||||
Set<String> arenaRank2 = RedisUtil.getInstence().getReverseZset(rkey2, 0, -1);
|
||||
sendMailReward(arenaRank1);
|
||||
sendMailReward(arenaRank2);
|
||||
RedisUtil.getInstence().del(rkey1);
|
||||
RedisUtil.getInstence().del(rkey2);
|
||||
}
|
||||
|
||||
public void sendMailReward(Set<String> arenaRank){
|
||||
public void initData(){
|
||||
//初始化数据
|
||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
if (crossGroup == -1) {
|
||||
return;
|
||||
}
|
||||
String rkey1 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAI_RANK_PERSON, Integer.toString(crossGroup) + RedisKey.Delimiter_colon + "1");
|
||||
String rkey2 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAI_RANK_PERSON, Integer.toString(crossGroup) + RedisKey.Delimiter_colon + "2");
|
||||
RedisUtil.getInstence().del(rkey1);
|
||||
RedisUtil.getInstence().del(rkey2);
|
||||
String inf1 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAISECRET_INFO, Integer.toString(crossGroup) + RedisKey.Delimiter_colon + "1");
|
||||
String inf2 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAISECRET_INFO, Integer.toString(crossGroup) + RedisKey.Delimiter_colon + "2");
|
||||
RedisUtil.getInstence().del(inf1);
|
||||
RedisUtil.getInstence().del(inf2);
|
||||
}
|
||||
|
||||
public void sendMailReward(Set<String> arenaRank) {
|
||||
List<Integer> arenaRankfilt = arenaRank.stream().mapToInt(n -> Integer.parseInt(n)).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],"#");
|
||||
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) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Instance {
|
||||
public final static CrossLingmaiLogic instance = new CrossLingmaiLogic();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -325,9 +325,11 @@ public class MinuteTask extends Thread {
|
|||
}
|
||||
//结算每日排行奖励
|
||||
if(hour ==21 && minute==0){
|
||||
//删除数据 TODO
|
||||
CrossLingmaiLogic.getInstance().sendMailReward();
|
||||
}
|
||||
if(hour == 9&& minute==0){
|
||||
CrossLingmaiLogic.getInstance().initData();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue