Merge branch 'master_test_gn' into master_guild_cross

back_recharge
jiahuiwen 2022-04-21 16:55:53 +08:00
commit 9a48f5e62f
7 changed files with 186 additions and 82 deletions

View File

@ -11,10 +11,7 @@ import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
@ -801,7 +798,6 @@ public class TimeUtils {
*
*1
* @param src
* @param target
* @return
*/
public static boolean isSameWeek7(long src) {
@ -1224,6 +1220,63 @@ public class TimeUtils {
return hour;
}
/**
*
* @param dataBegin
* @param dataEnd
* @param weekDays 160
* @return List
*/
public static int getDayOfWeekWithinDateInterval(String dataBegin, String dataEnd, int weekDays) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List<String> dateResult = new ArrayList<>();
Calendar cal = Calendar.getInstance();
String[] dateInterval = {dataBegin, dataEnd};
Date[] dates = new Date[dateInterval.length];
for (int i = 0; i < dateInterval.length; i++) {
String[] ymd = dateInterval[i].split("[^\\d]+");
cal.set(Integer.parseInt(ymd[0]), Integer.parseInt(ymd[1]) - 1, Integer.parseInt(ymd[2]));
dates[i] = cal.getTime();
}
for (Date date = dates[0]; date.compareTo(dates[1]) <= 0; ) {
cal.setTime(date);
if (cal.get(Calendar.DAY_OF_WEEK) - 1 == weekDays) {
String format = sdf.format(date);
dateResult.add(format);
}
cal.add(Calendar.DATE, 1);
date = cal.getTime();
}
return dateResult.size();
}
/**
* date2date1
*
* @param time1
* @param time2
* @param weekday
* @return
*/
public static int differentDaysToWeekday(long time1, long time2, int weekday) {
// 格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
// 第二天
c.setTimeInMillis(time1);
c.add(Calendar.DATE, 1);
// 转换格式
Date date1 = c.getTime();
Date date2 = new Date(time2);
String format1 = sdf.format(date1);
String format2 = sdf.format(date2);
// 周几
if (weekday == 7){
weekday = 0;
}
return getDayOfWeekWithinDateInterval(format1,format2,weekday);
}
/**
* date2date1
*

View File

@ -453,10 +453,8 @@ public class GlobalDataManaager implements IManager {
PlayerLogic.getInstance().sendTimingMail(user);
user.getGuildMyInfo().setLastHurt(0);
// 距离上次登陆相隔几天
int num = TimeUtils.differentDays(user.getPlayerInfoManager().getLoginTime(), TimeUtils.now());
// 四灵试炼,计算每天次数
FourChallengeLogic.getInstance().addFourChallengeNum(user,num);
FourChallengeLogic.getInstance().addFourChallengeNum(user,user.getPlayerInfoManager().getLoginTime());
// 助战清理
HelpHeroLogic.getInstance().clearHelpInfo(user);
// 七界推送

View File

@ -310,7 +310,17 @@ public class GlobleSystemLogic implements IEventHandler {
return -1;
}
Integer group = RedisUtil.getInstence().getMapValue(RedisKey.SERVER_SPLIT_INFO, "", String.valueOf(GameApplication.serverId), Integer.class);
if (group == null || group <= 0){
// 当本地无跨服id时读取gm的跨服分组开服用
if (group == null){
Integer entry = RedisUtil.getInstence().getMapEntry(RedisKey.CROSS_SERVER_GROUP, "", String.valueOf(GameApplication.serverId), Integer.class);
if (entry != null){
RedisUtil.getInstence().putMapEntry(RedisKey.SERVER_SPLIT_INFO, "", String.valueOf(GameApplication.serverId),entry);
group = entry;
}else {
group = -1;
}
}
if (group <= 0){
return -1;
}
crossGroup = group;

View File

@ -1840,7 +1840,8 @@ public class ActivityLogic implements IEventHandler{
int[] result = new int[]{incs[0],incs[1]};
// 抽奖次数达到必出up次数
if (count >= incs[3]){
// 2022-4-21 策划需求【屏蔽点将台心愿招募】
if (count >= incs[3] && false){
// 次数归0
count = 0;
// 添加奖励
@ -1855,7 +1856,7 @@ public class ActivityLogic implements IEventHandler{
// 根据id获取奖池信息
SWishActivityPool pool = poolMap.get(entry.getKey());
// null意味着是up奖励
if (pool == null){
if (pool == null && false){
count = 0;
reward[i++] = result;
}

View File

@ -6,6 +6,8 @@ import com.ljsd.jieling.handler.map.MapManager;
import com.ljsd.jieling.handler.map.TrialInfo;
import com.ljsd.jieling.jbean.ActivityMission;
import com.ljsd.jieling.jbean.ActivityProgressInfo;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.dao.PlayerManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.mail.MailLogic;
@ -38,28 +40,29 @@ class ExpectRankActivity extends AbstractActivity {
@Override
void updateProgressWithUser(User user, ActivityMission activityMission, int count) {
if(SGlobalActivity.getsGlobalActivityMap().get(id).getType() == 70){
if (SGlobalActivity.getsGlobalActivityMap().get(id).getType() == 70) {
//森罗幻境特殊处理
if(SGlobalActivity.getsGlobalActivityMap().get(id).getOpenRanking()==1){
if (SGlobalActivity.getsGlobalActivityMap().get(id).getOpenRanking() == 1) {
MapManager mapManager = user.getMapManager();
TrialInfo trialInfo = mapManager.getTrialInfo();
//排除神秘关卡
if(trialInfo.getFloor()<10000 && trialInfo.getFloor() > activityMission.getV()){
activityMission.setV(trialInfo.getFloor());
}else if(trialInfo.getFloor()>10000){
activityMission.setV(trialInfo.getFloor()-10000);
int floor = 0 ;
if (trialInfo.getFloor() < 10000 && trialInfo.getFloor() > activityMission.getV()) {
floor = trialInfo.getFloor();
} else if (trialInfo.getFloor() > 10000) {
floor = trialInfo.getFloor() - 10000;
}
RankContext.getRankEnum(RankEnum.EXPERT_RANK.getType()).addRank(user.getId(),String.valueOf(id),activityMission.getV());
}else{
activityMission.setV(count + activityMission.getV());
RankContext.getRankEnum(RankEnum.EXPERT_RANK.getType()).addRank(user.getId(), String.valueOf(id), floor);
} else {
activityMission.setV(count + activityMission.getV());
}
}else {
} else {
activityMission.setV(count + activityMission.getV());
if(SGlobalActivity.getsGlobalActivityMap().get(id).getOpenRanking()==1){
if (SGlobalActivity.getsGlobalActivityMap().get(id).getOpenRanking() == 1) {
// String key = RedisKey.getKey(RedisKey.EXPERT_RANK, String.valueOf(id), false);
// RedisUtil.getInstence().zsetAddOne(key, String.valueOf(user.getId()), activityMission.getV());
RankContext.getRankEnum(RankEnum.EXPERT_RANK.getType()).addRank(user.getId(),String.valueOf(id),activityMission.getV());
RankContext.getRankEnum(RankEnum.EXPERT_RANK.getType()).addRank(user.getId(), String.valueOf(id), activityMission.getV());
}
}
}
@ -100,7 +103,7 @@ class ExpectRankActivity extends AbstractActivity {
User user = UserManager.getUser(session.getUid());
int value = user.getActivityManager().getActivityMissionMap().get(sActivityRewardConfig.getActivityId()).getV();
if (value < values[1][0]) {
// MessageUtil.sendErrorResponse(session, 0, rewardResponseValue, "time not");
// MessageUtil.sendErrorResponse(session, 0, rewardResponseValue, "time not");
return false;
}
return true;
@ -112,28 +115,27 @@ class ExpectRankActivity extends AbstractActivity {
ThreadManager.getScheduledExecutor().execute(this::sendReward);
}
protected void sendReward(){
Thread.currentThread().setName("sendReward-Activity-"+id);
protected void sendReward() {
Thread.currentThread().setName("sendReward-Activity-" + id);
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
if(sGlobalActivity.getOpenRanking()==0){
if (sGlobalActivity.getOpenRanking() == 0) {
return;
}
List<SActivityRankingReward> sActivityRankingReward = SActivityRankingReward.getsActivityRankingRewardMapByActivityId(id);
if(null==sActivityRankingReward) {
if (null == sActivityRankingReward) {
return;
}
int maxRank = 0;
int maxRewardId = 0;
Map<Integer, Integer> rank2miss = new HashMap<>();
for (SActivityRankingReward sActivityRankingReward1 : sActivityRankingReward) {
if(sActivityRankingReward1.getMaxRank()==-1){
maxRank =-1;
if (sActivityRankingReward1.getMaxRank() == -1) {
maxRank = -1;
maxRewardId = sActivityRankingReward1.getId();
continue;
}
if(maxRank!=-1)
{
if (maxRank != -1) {
maxRank = Math.max(maxRank, sActivityRankingReward1.getMaxRank());
}
@ -184,15 +186,15 @@ class ExpectRankActivity extends AbstractActivity {
//checkAndUpdate value
SActivityRankingReward sActivityRankingReward1 = SActivityRankingReward.getsActivityRankingRewardMap().get(missionId);
//sendmail
String title = SErrorCodeEerverConfig.getI18NMessageNeedConvert("expertrank_activity_title", new Object[]{sGlobalActivity.getSesc()},new int[]{1},"#");
String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("expertrank_activity_txt", new Object[]{sGlobalActivity.getSesc(),ranking},new int[]{1,0},"#");
String title = SErrorCodeEerverConfig.getI18NMessageNeedConvert("expertrank_activity_title", new Object[]{sGlobalActivity.getSesc()}, new int[]{1}, "#");
String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("expertrank_activity_txt", new Object[]{sGlobalActivity.getSesc(), ranking}, new int[]{1, 0}, "#");
String mailReward = ItemUtil.getMailReward(sActivityRankingReward1.getRankingReward());
MailLogic.getInstance().sendMail(uid, title, content, mailReward, nowTime, Global.MAIL_EFFECTIVE_TIME);
});
ProtocolsManager.getInstance().updateAyncWorker(ayyncWorker);
rank++;
}catch (Exception e) {
LOGGER.error("id为{}的玩家,{}活动排行奖励没有发成功 e={}",uid,id,e);
} catch (Exception e) {
LOGGER.error("id为{}的玩家,{}活动排行奖励没有发成功 e={}", uid, id, e);
e.printStackTrace();
}
}

View File

@ -67,17 +67,12 @@ public class FourChallengeLogic {
* 0111
*/
public int[] status;
/**
*
*/
public final int[][] config;
public static class Instance {
public final static FourChallengeLogic instance = new FourChallengeLogic(STableManager.getConfig(SCampTowerSetting.class).get(1).getCampOpenDay());
public final static FourChallengeLogic instance = new FourChallengeLogic();
}
private FourChallengeLogic(int[][] config) {
this.config = config;
private FourChallengeLogic() {
}
/**
@ -98,16 +93,18 @@ public class FourChallengeLogic {
*
*/
public void check() {
int[][] config = STableManager.getConfig(SCampTowerSetting.class).get(1).getCampOpenDay();
// 空初始化长度为4
status = new int[4];
int[] state = new int[4];
for (int[] statusConfig : config) {
for (int i = 1; i < statusConfig.length; i++) {
// 判断当前周几
if (TimeUtils.getDayOfWeek() == statusConfig[i]) {
status[statusConfig[0] - 1] = 1;
state[statusConfig[0] - 1] = 1;
}
}
}
status = state;
}
@ -380,42 +377,57 @@ public class FourChallengeLogic {
* @param user
*/
public void firstGetTimes(User user) throws Exception {
if (ifOpenFourChallenge(user) && !user.getPlayerInfoManager().isOpenFourChallenge()){
// 检测一次
if (status == null){ check(); }
// 获取每天增加的天数
int campOpenDay = STableManager.getConfig(SCampTowerSetting.class).get(1).getTimesAddPerDay();
for (int i = 0; i < status.length; i++) {
// 类型未开启
if (status[i] == 0){ continue; }
user.getPlayerInfoManager().addFourChallengeRemainTimes(i, campOpenDay);
}
LOGGER.info("四灵试炼层数刷新,首次开启,玩家:{},层数:{}", user.getId(), Arrays.toString(user.getPlayerInfoManager().getFourChallengeRemainTimes()));
user.getPlayerInfoManager().setOpenFourChallenge(true);
// 推送四灵试炼信息
ISession session = OnlineUserManager.getSessionByUid(user.getId());
if (session != null){
fourChallengeGetInfo(session,false);
// 功能开启了,并且是首次登陆
if (!ifOpenFourChallenge(user) || user.getPlayerInfoManager().isOpenFourChallenge()){
return;
}
// 检测一次
check();
// 获取每天增加的天数
int campOpenDay = STableManager.getConfig(SCampTowerSetting.class).get(1).getTimesAddPerDay();
for (int i = 0; i < status.length; i++) {
// 类型未开启
if (status[i] == 0){
continue;
}
user.getPlayerInfoManager().addFourChallengeRemainTimes(i, campOpenDay);
}
LOGGER.info("四灵试炼层数刷新,首次开启,玩家:{},层数:{}", user.getId(), Arrays.toString(user.getPlayerInfoManager().getFourChallengeRemainTimes()));
user.getPlayerInfoManager().setOpenFourChallenge(true);
// 推送四灵试炼信息
ISession session = OnlineUserManager.getSessionByUid(user.getId());
if (session != null){
fourChallengeGetInfo(session,false);
}
}
/**
*
* @param user
* @param num
* @param time
*/
public void addFourChallengeNum(User user,int num) throws Exception {
public void addFourChallengeNum(User user,long time) throws Exception {
// 四灵试炼活动未开启
if (!ifOpenFourChallenge(user)){ return; }
boolean b = ifOpenFourChallenge(user);
if (!b){
return;
}
// 检测一次
if (status == null){ check(); }
check();
// 获取每天增加的天数
int campOpenDay = STableManager.getConfig(SCampTowerSetting.class).get(1).getTimesAddPerDay();
SCampTowerSetting towerSetting = STableManager.getConfig(SCampTowerSetting.class).get(1);
int campOpenDay = towerSetting.getTimesAddPerDay();
for (int i = 0; i < status.length; i++) {
// 类型未开启
if (status[i] == 0){ continue; }
user.getPlayerInfoManager().addFourChallengeRemainTimes(i, campOpenDay*num);
// 记录天数
int count = 0;
// 开启的星期数第一位是开启阵营要调过从1开始
int[] openDay = towerSetting.getCampOpenDay()[i];
for (int j = 1; j < openDay.length; j++) {
// 中间经过了几次开启时间
count += TimeUtils.differentDaysToWeekday(time,TimeUtils.now(),openDay[j]);
}
user.getPlayerInfoManager().addFourChallengeRemainTimes(i, campOpenDay*count);
}
LOGGER.info("四灵试炼层数刷新,每日登录,玩家:{},层数:{}", user.getId(), Arrays.toString(user.getPlayerInfoManager().getFourChallengeRemainTimes()));
user.getPlayerInfoManager().setOpenFourChallenge(true);

View File

@ -16,6 +16,8 @@ import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import config.SChallengeStage;
import config.SMonsterConfig;
import config.SMonsterGroup;
import manager.STableManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -49,7 +51,7 @@ public class ChallengeLogic {
return true;
}
public static Map<Integer, Integer> dropMap(SChallengeStage sChallengeConfig, int model, int type, int win, long[] result) {
public static Map<Integer, Integer> dropMap(SChallengeStage sChallengeConfig, int model, int type, int win, long[] result,PlayerInfoProto.ChallengeResponse.Builder builder) {
/*
model //1为挑战 2为扫荡
win // 1赢 0输
@ -78,6 +80,7 @@ public class ChallengeLogic {
}
}
LOGGER.info("zong reward");
builder.setPercentReward(10000);
}
if (model == 1 && win == 1) {
//打过
@ -89,20 +92,40 @@ public class ChallengeLogic {
}
}
LOGGER.info("tongguan reward");
builder.setPercentReward(10000);
builder.setLossBloodOrTimes(result[1]);
LOGGER.info("win times 回合数:"+result[1]);
} else if (model == 1 && win == 0) {
//没打过
int[][] reward1 = sChallengeConfig.getReward1();
int ratio = 0;
if (type == 1) {//无尽副本 血量
long leaveHp = result[2] + result[3] + result[4]
if (type == 2) {//无尽副本 血量
SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(sChallengeConfig.getMonsterGroup());
// 获取怪物组
int[][] content = sMonsterGroup.getContents();
double bossBlood = 0.0; //怪物初始化血量
for (int i = 0; i < content.length; i++) {
int[] ints = content[i];
for (int j = 0; j < ints.length; j++) {
if (ints[j] == 0){
continue;
}
SMonsterConfig monsterConfig = STableManager.getConfig(SMonsterConfig.class).get(ints[j]);
bossBlood+=monsterConfig.getHp();
}
}
double leaveHp = result[2] + result[3] + result[4]
+ result[5] + result[6];
double lossBlood = bossBlood - leaveHp;
for (int[] percent : reward1) {
if (percent[0] > leaveHp) {
if (percent[0] > lossBlood) {
break;
}
ratio = percent[1];
}
} else if (type == 2) {//回合数
LOGGER.info("输了 lossBlood:"+lossBlood);
builder.setLossBloodOrTimes((long)lossBlood);
} else if (type == 1) {//回合数
long times = result[1];//回合数
for (int[] percent : reward1) {
if (percent[0] > times) {
@ -110,6 +133,8 @@ public class ChallengeLogic {
}
ratio = percent[1];
}
builder.setLossBloodOrTimes(times);
LOGGER.info("输了 回合数 times :"+times);
}
LOGGER.info("challengeHandler ====>id:{},ratio:{}", sChallengeConfig.getId(), ratio);
for (int[] fix : sChallengeConfig.getPassReward()) {
@ -120,6 +145,7 @@ public class ChallengeLogic {
}
}
LOGGER.info("no pass reward percent");
builder.setPercentReward(ratio);
}
return comDropMap;
@ -167,7 +193,7 @@ public class ChallengeLogic {
return;
}
PlayerInfoProto.ChallengeResponse.Builder builder = PlayerInfoProto.ChallengeResponse.newBuilder();
int type = proto.getType(); //1无尽 2宝物
int type = proto.getType(); //1无尽 2宝物
int model = proto.getModel(); //1为挑战 2为扫荡
int id = proto.getId();
SChallengeStage sChallengeConfig = STableManager.getConfig(SChallengeStage.class).get(id);
@ -185,13 +211,13 @@ public class ChallengeLogic {
if (model == 2) {
//扫荡
switch (type) {
case 1:
case 1: // 回合
if (!limit(endlessNewReplicaLexel, id)) {
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
return;
}
break;
case 2:
case 2:// 血量
if (!limit(treasureReplicaLexel, id)) {
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
return;
@ -199,7 +225,7 @@ public class ChallengeLogic {
break;
}
//扫荡 = 保底 +总奖励
comDropMap = dropMap(sChallengeConfig, model, type, 1, null);
comDropMap = dropMap(sChallengeConfig, model, type, 1, null,builder);
CommonProto.Drop.Builder drop = ItemUtil.drop(user, comDropMap.entrySet().stream().map(n ->
new int[]{n.getKey(), n.getValue()}).toArray(int[][]::new), BIReason.EXPLORE_MAP_COST_RETURN);
builder.setDrop(drop);
@ -230,23 +256,23 @@ public class ChallengeLogic {
} else if (type == 2) {
user.getPlayerInfoManager().setTreasureReplica(id);
}
comDropMap = dropMap(sChallengeConfig, model, type, 1, fightResult.getCheckResult());
comDropMap = dropMap(sChallengeConfig, model, type, 1, fightResult.getCheckResult(),builder);
builder.setResult(1);
} else {
if (type == 1){
if((int) fightResult.getCheckResult()[1]>=20){
//无尽副本回合数超过20 赢
user.getPlayerInfoManager().setEndlessNewReplica(id);
comDropMap = dropMap(sChallengeConfig, model, type, 1, fightResult.getCheckResult());
comDropMap = dropMap(sChallengeConfig, model, type, 1, fightResult.getCheckResult(),builder);
builder.setResult(1);
}else{
//没打过 //输了 保底+总奖励*奖励百分比
comDropMap = dropMap(sChallengeConfig, model, type, 0, fightResult.getCheckResult());
comDropMap = dropMap(sChallengeConfig, model, type, 0, fightResult.getCheckResult(),builder);
builder.setResult(0);
}
}else if(type == 2){
//没打过 //输了 保底+总奖励*奖励百分比
comDropMap = dropMap(sChallengeConfig, model, type, 0, fightResult.getCheckResult());
comDropMap = dropMap(sChallengeConfig, model, type, 0, fightResult.getCheckResult(),builder);
builder.setResult(0);
}
}
@ -262,6 +288,8 @@ public class ChallengeLogic {
CommonProto.Drop.Builder drop = ItemUtil.drop(user, comDropMap.entrySet().stream().map(n ->
new int[]{n.getKey(), n.getValue()}).toArray(int[][]::new), BIReason.EXPLORE_MAP_COST_RETURN);
builder.setDrop(drop);
builder.setType(type);
LOGGER.info("type :"+type);
}
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.CHALLENGE_RESPONSE.getNumber(), builder.build(), true);
}