十绝阵 时间 阶段修改

lvxinran 2020-05-15 00:07:41 +08:00
parent 26b0aff262
commit 633cf81ee6
6 changed files with 140 additions and 44 deletions

View File

@ -7,6 +7,7 @@ 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.logic.OnlineUserManager;
import com.ljsd.jieling.logic.dao.GuilidManager;
import com.ljsd.jieling.logic.dao.UserManager;
@ -16,6 +17,7 @@ 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.mail.MailLogic;
import com.ljsd.jieling.logic.rank.RankContext;
import com.ljsd.jieling.logic.rank.RankEnum;
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
@ -25,12 +27,14 @@ import com.ljsd.jieling.protocols.Family;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import config.SErrorCodeEerverConfig;
import config.SGuildSetting;
import config.SGuildWarConfig;
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.Calendar;
@ -75,62 +79,104 @@ public class DeathPathLogic {
*
*/
public void statusCheck(){
Runnable runnable = this::doCheck;
runnable.run();
}
private void doCheck(){
if(guildWarOpenTime==null){
guildWarOpenTime = SGuildSetting.sGuildSetting.getGuildWarOpenTime();
guildWarOpenTime = new int[8];
int[] setting = SGuildSetting.sGuildSetting.getGuildWarOpenTime();
if(setting[0]==2){
for(int i = 1;i<setting.length;i++){
guildWarOpenTime[setting[i]]= 1;
if(setting[i]!=7){
guildWarOpenTime[setting[i]+1]= -1;
}else{
guildWarOpenTime[1] = -1;
}
}
} else {
for(int i = 0 ; i<guildWarOpenTime.length;i++){
guildWarOpenTime[i] = 1;
}
}
}
if(guildWarTime==null){
guildWarTime = SGuildSetting.sGuildSetting.getGuildWarTime();
}
boolean result = false;
if(guildWarOpenTime[0]==2){
int dayOfWeek = TimeUtils.getDayOfWeek();
for(int i = 1;i<guildWarOpenTime.length;i++){
if(guildWarOpenTime[i]!=dayOfWeek){
continue;
}
result = true;
break;
}
}else if(guildWarOpenTime[0]==1){
result = true;
}else{
return;
}
if(result) {
Runnable runnable = this::isOpen;
runnable.run();
}
}
// boolean result = false;
// if(guildWarOpenTime[0]==2){
// for(int i = 1;i<guildWarOpenTime.length;i++){
// if(guildWarOpenTime[i]!=dayOfWeek){
// continue;
// }
// result = true;
// break;
// }
// }else if(guildWarOpenTime[0]==1){
// result = true;
// }else{
// return;
// }
isOpen();
}
private void isOpen(){
int hourOfDay = TimeUtils.getHourOfDay();
Calendar calendar = Calendar.getInstance();
int minute = calendar.get(Calendar.MINUTE);
int tempTime = hourOfDay*100+minute;
int currStatus = 0;
for(int i = 0;i<guildWarTime.length-1;i++){
int tempSmall = guildWarTime[i][0]*100+guildWarTime[i][1];
int tempBig = guildWarTime[i+1][0]*100+guildWarTime[i+1][1];
int dayOfWeek = TimeUtils.getDayOfWeek();
int currStatus=0;
int dayStats = guildWarOpenTime[dayOfWeek];
//当前时间与表配置时间判断 获得 currStatus
if(dayStats==-1){
//领奖阶段
currStatus = 2;
}else if (dayStats==1){
Calendar calendar = Calendar.getInstance();
int hourOfDay = TimeUtils.getHourOfDay();
int minute = calendar.get(Calendar.MINUTE);
int tempTime = hourOfDay*100+minute;
if(guildWarTime.length!=2){
return;
}
int tempSmall = guildWarTime[0][0]*100+guildWarTime[0][1];
int tempBig = guildWarTime[1][0]*100+guildWarTime[1][1];
if(tempTime>=tempSmall&&tempTime<tempBig){
currStatus = i+1;
break;
currStatus = 1;
}else if(tempTime>=tempBig){
currStatus = 2;
}
}
// currStatus与服务器当前status比较如果不同认为状态修改
if(currStatus!=status){
status = currStatus;
overTime = (int)(TimeUtils.getAppointTime(guildWarTime[status][0],guildWarTime[status][1])/1000);
if(status==1){
overTime = (int)(TimeUtils.getAppointTime(guildWarTime[status][0],guildWarTime[status][1])/1000);
}
if(status==1){
if (taskExecutor == null) {
taskExecutor = new DeathPathExecutor(tasks);
taskExecutor.start();
}
}
if(status==0){
try {
deleteDeathPathInfo();
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("状态修改-------");
//阶段信息改变发送推送
for(Map.Entry<Integer, ISession> sessionEntry:OnlineUserManager.sessionMap.entrySet()) {
Family.DeathPathStatusChangeIndication indication = Family.DeathPathStatusChangeIndication.newBuilder().setStatus(status).build();
MessageUtil.sendIndicationMessage(sessionEntry.getValue(),1, MessageTypeProto.MessageType.DEATH_PATH_STATUS_CHANGE_INDICATION.getNumber(),indication,true);
}
}
System.out.println("status="+status);
}
/**
@ -178,10 +224,14 @@ public class DeathPathLogic {
* @param messageType
*/
public void challenge(ISession session, int pathId, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
String count = RedisUtil.getInstence().get(RedisKey.DEATH_PATH_CHALLENGE_COUNT, String.valueOf(uid),String.class);
if(!StringUtil.isEmpty(count)&&Integer.parseInt(count)>=SGuildSetting.sGuildSetting.getChallengeMaxTime()){
throw new ErrorCodeException(ErrorCode.REFRESH_WHEL_TIME_NOT);
}
if(status!=1){
throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN);
}
int uid = session.getUid();
User user = UserManager.getUser(uid);
int guildId = user.getPlayerInfoManager().getGuildId();
SGuildWarConfig config = STableManager.getConfig(SGuildWarConfig.class).get(pathId);
@ -232,6 +282,7 @@ public class DeathPathLogic {
private void taskDoExecute(DeathPathTask task){
//公会总进攻人数
// task.setDamage(20000000);
DeathChallengeCount countInfo = RedisUtil.getInstence().get(RedisKey.DEATH_PAHT_TOTAL_CHALLENGE_COUNT, String.valueOf(task.getGuildId()), DeathChallengeCount.class);
if (countInfo==null){
countInfo = new DeathChallengeCount();
@ -273,7 +324,7 @@ public class DeathPathLogic {
guildTotalRank.addRank(task.getGuildId(),"",task.getDamage());
}else{
guildTotalRank.addRank(currFirstGuildId,"",task.getDamage(),1);
guildTotalRank.addRank(firstGuildId,"",task.getDamage(),-1);
guildTotalRank.addRank(firstGuildId,"",0,-1);
}
}
@ -343,6 +394,49 @@ public class DeathPathLogic {
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
}
//清除排行信息
private void deleteDeathPathInfo() throws Exception {
//todo 邮件自动发奖
RedisUtil redisUtil = RedisUtil.getInstence();
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_GUILD_RANK.getType());
AbstractRank personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_PERSON_RANK.getType());
Set<ZSetOperations.TypedTuple<String>> guildRankSet = guildRank.getRankByKey("", 0, -1);
Set<ZSetOperations.TypedTuple<String>> personRankSet = personRank.getRankByKey("", 0, -1);
if(guildRankSet.isEmpty()&&personRankSet.isEmpty()){
return;
}
String[] removeGuildKey = new String[guildRankSet.size()];
String[] removePersonKey = new String[personRankSet.size()];
int index = 0;
for(ZSetOperations.TypedTuple<String> item:guildRankSet){
removeGuildKey[index] = RedisKey.getKey(RedisKey.DEATH_PAHT_TOTAL_CHALLENGE_COUNT, item.getValue(),false);
index++;
}
index = 0;
for(ZSetOperations.TypedTuple<String> item:personRankSet){
removePersonKey[index] = RedisKey.getKey(RedisKey.DEATH_PATH_CHALLENGE_COUNT, item.getValue(),false);
index++;
}
String mailTitle = SErrorCodeEerverConfig.getI18NMessage("guildwar_reward_title");
String mailContent = SErrorCodeEerverConfig.getI18NMessage("guildwar_reward_txt");
for(String key:removeGuildKey){
DeathChallengeCount reward = redisUtil.getObject(key, DeathChallengeCount.class);
if(reward!=null&&reward.getUserReward().size()!=0){
Map<Integer, DeathReward> userReward = reward.getUserReward();
for(Map.Entry<Integer, DeathReward> rewardEntry:userReward.entrySet()){
if(rewardEntry.getValue().getPosition()==0){
MailLogic.getInstance().sendMail(rewardEntry.getKey(),mailTitle,mailContent,"16#100",TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
}
}
}
}
redisUtil.del(removeGuildKey);
redisUtil.del(removePersonKey);
for(int i = 1; i <=10;i++){
redisUtil.del(RedisKey.getKey(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getRedisKey(),String.valueOf(i),false));
redisUtil.del(RedisKey.getKey(RankEnum.DEATH_PATH_EVERY_PERSON_RANK.getRedisKey(),String.valueOf(i),false));
}
redisUtil.del(RedisKey.getKey(guildRank.getRedisKey(),"",false));
redisUtil.del(RedisKey.getKey(personRank.getRedisKey(),"",false));
}
}

View File

@ -51,10 +51,7 @@ public class GuildLogic {
};
public void flushEveryDay(User user, PlayerInfoProto.FivePlayerUpdateIndication.Builder fBuilder)throws Exception {
int guildId = user.getPlayerInfoManager().getGuildId();
if(guildId != 0){
takeAllReward(user);
}
takeAllReward(user);
user.getGuildMyInfo().setFetetype(0);
user.getGuildMyInfo().clearHadTakeReward();

View File

@ -43,7 +43,7 @@ public enum GameFightType {
GuildBossFight(FightType.GuildBossFight,new DefaultOfRedisCacheFightHandler(),RedisKey.GUILD_MONSTER_FIGHT),
DailyChallenge(FightType.StoryFight,new DefaultWithoutHandFightHandler(),null),
DeathPathChallenge(FightType.StoryFight,new DefaultWithoutHandFightHandler(),null),
DeathPathChallenge(FightType.CarBossFight,new DefaultWithoutHandFightHandler(),null),
CarBossChallenge(FightType.CarBossFight,new DefaultWithoutHandFightHandler(),null),
CarPersonChallenge(FightType.CarBossFight,new PVPFightHandler(),null),

View File

@ -8,7 +8,6 @@ import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import org.springframework.data.redis.core.ZSetOperations;
import java.math.BigDecimal;
/**
* @author lvxinran

View File

@ -24,14 +24,14 @@ public class DeathPathTotalGuildRank extends AbstractRank{
@Override
public int[] getDataByScore(Double score) {
BigDecimal bigDecimal = new BigDecimal(score.toString()).subtract(new BigDecimal(score.intValue())).multiply(new BigDecimal(String.valueOf(Math.pow(10,8))));
BigDecimal bigDecimal = new BigDecimal(score.toString()).subtract(new BigDecimal(score.intValue())).multiply(new BigDecimal(String.valueOf(Math.pow(10,15))));
return new int[]{bigDecimal.intValue(),score.intValue()};
}
@Override
public double getScore(double... data) {
BigDecimal decimal = null;
decimal = new BigDecimal(String.valueOf(data[0])).divide(new BigDecimal(String.valueOf(Math.pow(10,8))));
decimal = new BigDecimal(String.valueOf(data[0])).divide(new BigDecimal(String.valueOf(Math.pow(10,15))));
if(data.length>1){
decimal = decimal.add(new BigDecimal(data[1]));
}

View File

@ -76,6 +76,8 @@ public class SGuildSetting implements BaseConfig {
private int[] giveLikeReward;
private int challengeMaxTime;
public static SGuildSetting sGuildSetting;
@ -225,4 +227,8 @@ public class SGuildSetting implements BaseConfig {
public int[][] getGuildWarTime() {
return guildWarTime;
}
public int getChallengeMaxTime() {
return challengeMaxTime;
}
}