灵脉还原之前代码
parent
8bf8e2beaa
commit
861fdc6ed8
|
|
@ -1356,7 +1356,7 @@ public class RedisUtil {
|
|||
* 获取key
|
||||
* @param judge true: 老方法 false: 新方法
|
||||
*/
|
||||
private String getKey(String type,String key,boolean judge) {
|
||||
public String getKey(String type,String key,boolean judge) {
|
||||
String result;
|
||||
if (judge) {
|
||||
result = getKeyImpl(type, key);
|
||||
|
|
|
|||
|
|
@ -1,23 +1,26 @@
|
|||
package com.ljsd.jieling.logic.arena;
|
||||
|
||||
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.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 config.SErrorCodeEerverConfig;
|
||||
import config.SLodeConfig;
|
||||
import config.SMServerLodeSetting;
|
||||
import config.SSpecialConfig;
|
||||
import com.ljsd.jieling.logic.rank.RankContext;
|
||||
import com.ljsd.jieling.logic.rank.RankEnum;
|
||||
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
|
||||
import config.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 跨服 灵脉秘境
|
||||
|
|
@ -177,110 +180,110 @@ public class CrossLingmaiLogic {
|
|||
mapValue2.clear();
|
||||
}
|
||||
|
||||
// public static LingMaiSecretArea getLingaMaiData(int id, int uid,int crossGroup,int group) {
|
||||
// //排行榜上有数据 灵脉里没数据 说明被打下去了
|
||||
// AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_LINGMAI_RANK_PERSON.getType());
|
||||
// double disappearScore = rank.getScoreById(uid, crossGroup + RedisKey.Delimiter_colon + group);
|
||||
// LingMaiSecretArea lingMaiSecretArea = new LingMaiSecretArea();
|
||||
// lingMaiSecretArea.setId(id);
|
||||
// lingMaiSecretArea.setUid(uid);
|
||||
// String serverName = CrossServiceLogic.simplifyServerName(GameApplication.serverId);
|
||||
// lingMaiSecretArea.setServerName(serverName);
|
||||
// //lingMaiSecretArea.setName(user.getPlayerInfoManager().getNickName());
|
||||
// lingMaiSecretArea.setGetAwardTimeOrOccupyTime(TimeUtils.nowInt());
|
||||
// lingMaiSecretArea.setBeginOccupyTime(TimeUtils.nowInt());
|
||||
// if(disappearScore>0){
|
||||
// Map<String, LingMaiSecretArea> lingMaiMap = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + group, String.class, LingMaiSecretArea.class);
|
||||
// if(lingMaiMap.values().stream().noneMatch(n->n.getUid()==uid)){
|
||||
// lingMaiSecretArea.setScore1((int) disappearScore);
|
||||
// }
|
||||
// }
|
||||
// return lingMaiSecretArea;
|
||||
// }
|
||||
public static LingMaiSecretArea getLingaMaiData(int id, int uid,int crossGroup,int group) {
|
||||
//排行榜上有数据 灵脉里没数据 说明被打下去了
|
||||
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_LINGMAI_RANK_PERSON.getType());
|
||||
double disappearScore = rank.getScoreById(uid, crossGroup + RedisKey.Delimiter_colon + group);
|
||||
LingMaiSecretArea lingMaiSecretArea = new LingMaiSecretArea();
|
||||
lingMaiSecretArea.setId(id);
|
||||
lingMaiSecretArea.setUid(uid);
|
||||
String serverName = CrossServiceLogic.simplifyServerName(GameApplication.serverId);
|
||||
lingMaiSecretArea.setServerName(serverName);
|
||||
//lingMaiSecretArea.setName(user.getPlayerInfoManager().getNickName());
|
||||
lingMaiSecretArea.setGetAwardTimeOrOccupyTime(TimeUtils.nowInt());
|
||||
lingMaiSecretArea.setBeginOccupyTime(TimeUtils.nowInt());
|
||||
if(disappearScore>0){
|
||||
Map<String, LingMaiSecretArea> lingMaiMap = RedisUtil.getInstence().old_getmapvalue_toclass(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + group, String.class, LingMaiSecretArea.class);
|
||||
if(lingMaiMap.values().stream().noneMatch(n->n.getUid()==uid)){
|
||||
lingMaiSecretArea.setScore1((int) disappearScore);
|
||||
}
|
||||
}
|
||||
return lingMaiSecretArea;
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * 占领奖励 每十分钟发放一次
|
||||
// */
|
||||
// public void sendOccypyReward() {
|
||||
// //周二 四 六 日开放 9点-21点
|
||||
// int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
// 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);
|
||||
// }
|
||||
public void sendOccypyReward() {
|
||||
//周二 四 六 日开放 9点-21点
|
||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
if (crossGroup == -1) {
|
||||
return;
|
||||
}
|
||||
Map<String, LingMaiSecretArea> lingMaiMap1 = RedisUtil.getInstence().old_getmapvalue_toclass(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + 1, String.class, LingMaiSecretArea.class);
|
||||
Map<String, LingMaiSecretArea> lingMaiMap2 = RedisUtil.getInstence().old_getmapvalue_toclass(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + 2, String.class, LingMaiSecretArea.class);
|
||||
updateLingmaiData(lingMaiMap1, crossGroup, 1);
|
||||
updateLingmaiData(lingMaiMap2, crossGroup, 2);
|
||||
}
|
||||
//
|
||||
//
|
||||
// public static void updateLingmaiData(Map<String, LingMaiSecretArea> lingMaiMap, int crossGroup, int group) {
|
||||
// int nowTime = TimeUtils.nowInt();
|
||||
// String groupkey = crossGroup + RedisKey.Delimiter_colon + group;
|
||||
// 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 minute = (nowTime - occupyTime) / 60;
|
||||
// //秒
|
||||
// int second = Math.min((nowTime - occupyTime) % 60, 60);
|
||||
// //difVal =1 ;
|
||||
// LOGGER.error("玩家" + map.getValue().getUid() + "原有秒:"+map.getValue().getOccupyTime()+" 获得秒:" + (minute*60+second));
|
||||
// map.getValue().setOccupyTime(map.getValue().getOccupyTime() + minute*60+second);
|
||||
// map.getValue().setGetAwardTimeOrOccupyTime(nowTime);
|
||||
//
|
||||
// RedisUtil.getInstence().putMapEntry(RedisKey.CROSS_LINGMAISECRET_INFO, groupkey, map.getKey(), map.getValue());
|
||||
// AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_LINGMAI_RANK_PERSON.getType());
|
||||
// LOGGER.error("minute:"+map.getValue().getOccupyTime()+" per:"+(config.getRewardList()[0][1]/60));
|
||||
// long score = (long)map.getValue().getOccupyTime() * config.getRewardList()[0][1]/60 + map.getValue().getScore1();
|
||||
// double test = rank.getScoreById(user.getId(), groupkey);
|
||||
// LOGGER.error("之前是:" + test + "之后是:" + score);
|
||||
// rank.addRank(user.getId(), groupkey, score);
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
public static void updateLingmaiData(Map<String, LingMaiSecretArea> lingMaiMap, int crossGroup, int group) {
|
||||
int nowTime = TimeUtils.nowInt();
|
||||
String groupkey = crossGroup + RedisKey.Delimiter_colon + group;
|
||||
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 minute = (nowTime - occupyTime) / 60;
|
||||
//秒
|
||||
int second = Math.min((nowTime - occupyTime) % 60, 60);
|
||||
//difVal =1 ;
|
||||
LOGGER.error("玩家" + map.getValue().getUid() + "原有秒:"+map.getValue().getOccupyTime()+" 获得秒:" + (minute*60+second));
|
||||
map.getValue().setOccupyTime(map.getValue().getOccupyTime() + minute*60+second);
|
||||
map.getValue().setGetAwardTimeOrOccupyTime(nowTime);
|
||||
|
||||
RedisUtil.getInstence().old_putmap(RedisKey.CROSS_LINGMAISECRET_INFO, groupkey, map.getKey(), map.getValue());
|
||||
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_LINGMAI_RANK_PERSON.getType());
|
||||
LOGGER.error("minute:"+map.getValue().getOccupyTime()+" per:"+(config.getRewardList()[0][1]/60));
|
||||
long score = (long)map.getValue().getOccupyTime() * config.getRewardList()[0][1]/60 + map.getValue().getScore1();
|
||||
double test = rank.getScoreById(user.getId(), groupkey);
|
||||
LOGGER.error("之前是:" + test + "之后是:" + score);
|
||||
rank.addRank(user.getId(), groupkey, score);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * 结算奖励
|
||||
// */
|
||||
// public void sendMailReward() {
|
||||
// int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
// if (crossGroup == -1) {
|
||||
// return;
|
||||
// }
|
||||
// String rkey1 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAI_RANK_PERSON, crossGroup + RedisKey.Delimiter_colon + "1");
|
||||
// String rkey2 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAI_RANK_PERSON, crossGroup + RedisKey.Delimiter_colon + "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() {
|
||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
if (crossGroup == -1) {
|
||||
return;
|
||||
}
|
||||
String rkey1 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAI_RANK_PERSON, crossGroup + RedisKey.Delimiter_colon + "1",false);
|
||||
String rkey2 = RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAI_RANK_PERSON, crossGroup + RedisKey.Delimiter_colon + "2",false);
|
||||
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(Integer::parseInt).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);
|
||||
// if (config == null){
|
||||
// continue;
|
||||
// }
|
||||
// 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();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
public void sendMailReward(Set<String> arenaRank) {
|
||||
List<Integer> arenaRankfilt = arenaRank.stream().mapToInt(Integer::parseInt).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);
|
||||
if (config == null){
|
||||
continue;
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Instance {
|
||||
public final static CrossLingmaiLogic instance = new CrossLingmaiLogic();
|
||||
|
|
|
|||
|
|
@ -295,13 +295,20 @@ public class MinuteTask extends Thread {
|
|||
int minute = calendar.get(Calendar.MINUTE);
|
||||
int w = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
|
||||
//周二 四 六 开放 9点-21点
|
||||
//周二 四 六 开放 9点-20点
|
||||
List<Integer> weekDay = CrossLingmaiLogic.getSendRewardWeekDay();
|
||||
if (weekDay.contains(w)) {
|
||||
//0点清除数据
|
||||
if (hour == 0 && minute == 0) {
|
||||
CrossLingmaiLogic.getInstance().initData();
|
||||
}
|
||||
//每10分钟结算1次奖励
|
||||
if(minute / 10 == 0){
|
||||
CrossLingmaiLogic.getInstance().sendOccypyReward();
|
||||
}
|
||||
if(hour == 20 && minute == 0){
|
||||
CrossLingmaiLogic.getInstance().sendOccypyReward();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue