公会战
parent
689a227324
commit
7797b5bfff
|
|
@ -2,6 +2,7 @@ package com.ljsd.jieling.config;
|
|||
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.Table;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -30,7 +31,13 @@ public class SGuildSetting implements BaseConfig {
|
|||
|
||||
private int[] guildWarOpenTime;
|
||||
|
||||
private int[] prepareTime;
|
||||
private int[][] prepareTime;
|
||||
|
||||
private int[][] matchTime;
|
||||
|
||||
private int[][] battleTime;
|
||||
|
||||
private int[][] settleTime;
|
||||
|
||||
private int[] starNum;
|
||||
|
||||
|
|
@ -58,6 +65,7 @@ public class SGuildSetting implements BaseConfig {
|
|||
@Override
|
||||
public void init() throws Exception {
|
||||
sGuildSetting = STableManager.getConfig(SGuildSetting.class).get(1);
|
||||
GuildFightLogic.familyFightStatus();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -106,7 +114,7 @@ public class SGuildSetting implements BaseConfig {
|
|||
return guildWarOpenTime;
|
||||
}
|
||||
|
||||
public int[] getPrepareTime() {
|
||||
public int[][] getPrepareTime() {
|
||||
return prepareTime;
|
||||
}
|
||||
|
||||
|
|
@ -149,4 +157,16 @@ public class SGuildSetting implements BaseConfig {
|
|||
public float getExpansionScore() {
|
||||
return expansionScore;
|
||||
}
|
||||
|
||||
public int[][] getBattleTime() {
|
||||
return battleTime;
|
||||
}
|
||||
|
||||
public int[][] getMatchTime() {
|
||||
return matchTime;
|
||||
}
|
||||
|
||||
public int[][] getSettleTime() {
|
||||
return settleTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -26,12 +26,10 @@ import com.ljsd.jieling.util.MathUtils;
|
|||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
import org.luaj.vm2.ast.Str;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -42,31 +40,10 @@ public class GuildFightLogic {
|
|||
*/
|
||||
private static int status;
|
||||
private static boolean startMatching;
|
||||
private static int startFightTime;
|
||||
private static int roundStartTime;
|
||||
private static int roundEndTime;
|
||||
|
||||
|
||||
static{
|
||||
int hour = TimeUtils.getHourOfDay();
|
||||
switch (hour){
|
||||
case FamilyRound.FAMILY_FIGHT_START:
|
||||
status = 1;
|
||||
break;
|
||||
case FamilyRound.FAMILY_FIGHT_DEFEND_END:
|
||||
status = 2;
|
||||
break;
|
||||
case FamilyRound.FAMILY_FIGHT_MATCHING_END:
|
||||
status =3;
|
||||
break;
|
||||
case FamilyRound.FAMILY_FIGHT_ATTACK_END:
|
||||
status = 4;
|
||||
break;
|
||||
case FamilyRound.FAMILY_FIGHT_END:
|
||||
status = 0;
|
||||
break;
|
||||
default:
|
||||
status = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
|
@ -530,30 +507,6 @@ public class GuildFightLogic {
|
|||
*/
|
||||
public static void getFamilyFightRoundInfo(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
int startFightTime;
|
||||
int roundStartTime = 0;
|
||||
int roundEndTime = 0;
|
||||
int hour = TimeUtils.getHourOfDay();
|
||||
//活动开启时间
|
||||
if (hour < FamilyRound.FAMILY_FIGHT_END) {
|
||||
startFightTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_START) / 1000);
|
||||
} else {
|
||||
startFightTime = (int) ((TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_START) + TimeUtils.DAY) / 1000);
|
||||
}
|
||||
//阶段以及时间段
|
||||
if (hour >= FamilyRound.FAMILY_FIGHT_START && hour < FamilyRound.FAMILY_FIGHT_DEFEND_END) {
|
||||
roundStartTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_START) / 1000);
|
||||
roundEndTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_DEFEND_END) / 1000);
|
||||
} else if (hour >= FamilyRound.FAMILY_FIGHT_DEFEND_END && hour < FamilyRound.FAMILY_FIGHT_MATCHING_END) {
|
||||
roundStartTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_DEFEND_END) / 1000);
|
||||
roundEndTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_MATCHING_END) / 1000);
|
||||
} else if (hour >= FamilyRound.FAMILY_FIGHT_MATCHING_END && hour < FamilyRound.FAMILY_FIGHT_ATTACK_END) {
|
||||
roundStartTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_MATCHING_END) / 1000);
|
||||
roundEndTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_ATTACK_END) / 1000);
|
||||
} else if (hour >= FamilyRound.FAMILY_FIGHT_ATTACK_END && hour < FamilyRound.FAMILY_FIGHT_END) {
|
||||
roundStartTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_ATTACK_END) / 1000);
|
||||
roundEndTime = (int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_END) / 1000);
|
||||
}
|
||||
int enemyFamily = getEnemyFamily(UserManager.getUser(session.getUid()).getPlayerInfoManager().getGuildId());
|
||||
Integer attackCount = redisUtil.getMapEntry(RedisKey.FAMILY_FIGHT_ATTACK_COUNT,"",session.getId(),Integer.class);
|
||||
if(attackCount==null){
|
||||
|
|
@ -573,10 +526,9 @@ public class GuildFightLogic {
|
|||
}else{
|
||||
if(!startMatching){
|
||||
response.setType(-1);
|
||||
response.setRoundEndTime((int) (TimeUtils.getAppointTime(FamilyRound.FAMILY_FIGHT_END) / 1000));
|
||||
response.setRoundEndTime((int) (TimeUtils.getAppointTime(SGuildSetting.sGuildSetting.getSettleTime()[1][0],SGuildSetting.sGuildSetting.getSettleTime()[1][1]) / 1000));
|
||||
}
|
||||
}
|
||||
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), response.build(), true);
|
||||
}
|
||||
|
||||
|
|
@ -590,30 +542,71 @@ public class GuildFightLogic {
|
|||
familyFightMatching();
|
||||
startMatching = false;
|
||||
}
|
||||
SGuildSetting sGuildSetting = SGuildSetting.sGuildSetting;
|
||||
int hour = TimeUtils.getHourOfDay();
|
||||
if (status == 0 && hour == FamilyRound.FAMILY_FIGHT_START) {
|
||||
LOGGER.info("阶段变为布防");
|
||||
status = 1;
|
||||
} else if (status == 1 && hour == FamilyRound.FAMILY_FIGHT_DEFEND_END) {
|
||||
status = 2;
|
||||
LOGGER.info("阶段变为匹配");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int minute = calendar.get(Calendar.MINUTE);
|
||||
//活动开启时间判断
|
||||
int startAllTime;
|
||||
if (hour < sGuildSetting.getPrepareTime()[0][0]) {
|
||||
startAllTime = (int) (TimeUtils.getAppointTime(sGuildSetting.getPrepareTime()[0][0],sGuildSetting.getPrepareTime()[0][1]) / 1000);
|
||||
} else if(hour==sGuildSetting.getPrepareTime()[0][0]&&minute<sGuildSetting.getPrepareTime()[0][1]){
|
||||
startAllTime = (int) (TimeUtils.getAppointTime(sGuildSetting.getPrepareTime()[0][0],sGuildSetting.getPrepareTime()[0][1]) / 1000);
|
||||
}else{
|
||||
startAllTime = (int) ((TimeUtils.getAppointTime(sGuildSetting.getPrepareTime()[0][0],sGuildSetting.getPrepareTime()[0][1]) + TimeUtils.DAY) / 1000);
|
||||
}
|
||||
if(startFightTime!=startAllTime){
|
||||
startFightTime=startAllTime;
|
||||
}
|
||||
//阶段判断
|
||||
int[][] timeRound;
|
||||
if(flagTimeRound(sGuildSetting.getPrepareTime(),hour,minute)){
|
||||
timeRound = sGuildSetting.getPrepareTime();
|
||||
if(status==0){
|
||||
LOGGER.info("阶段变为布防");
|
||||
status = 1;
|
||||
}
|
||||
}else if(flagTimeRound(sGuildSetting.getMatchTime(),hour,minute)){
|
||||
timeRound = sGuildSetting.getMatchTime();
|
||||
if(status==1){
|
||||
status = 2;
|
||||
LOGGER.info("阶段变为匹配");
|
||||
}
|
||||
startMatching = true;
|
||||
} else if (status == 2 && hour == FamilyRound.FAMILY_FIGHT_MATCHING_END) {
|
||||
status = 3;
|
||||
LOGGER.info("阶段变为进攻");
|
||||
|
||||
} else if (status == 3 && hour == FamilyRound.FAMILY_FIGHT_ATTACK_END) {
|
||||
accountFamilyFightResult();
|
||||
MongoUtil.getLjsdMongoTemplate().lastUpdate();
|
||||
status = 4;
|
||||
LOGGER.info("阶段变为结算");
|
||||
} else if (status == 4 && hour == FamilyRound.FAMILY_FIGHT_END) {
|
||||
status = 0;
|
||||
LOGGER.info("阶段变为等待");
|
||||
} else if (hour >= FamilyRound.FAMILY_FIGHT_END || hour < FamilyRound.FAMILY_FIGHT_START) {
|
||||
status = 0;
|
||||
removeMatchingInfo();
|
||||
}else if(flagTimeRound(sGuildSetting.getBattleTime(),hour,minute)){
|
||||
timeRound = sGuildSetting.getBattleTime();
|
||||
if(status == 2){
|
||||
status = 3;
|
||||
LOGGER.info("阶段变为进攻");
|
||||
}
|
||||
}else if(flagTimeRound(sGuildSetting.getSettleTime(),hour,minute)){
|
||||
timeRound = sGuildSetting.getSettleTime();
|
||||
if(status==3){
|
||||
accountFamilyFightResult();
|
||||
MongoUtil.getLjsdMongoTemplate().lastUpdate();
|
||||
status = 4;
|
||||
LOGGER.info("阶段变为结算");
|
||||
}
|
||||
}else{
|
||||
if(status==4){
|
||||
status = 0;
|
||||
LOGGER.info("阶段变为等待");
|
||||
removeMatchingInfo();
|
||||
}
|
||||
startMatching = true;
|
||||
timeRound =null;
|
||||
}
|
||||
int startTime = 0;
|
||||
int endTime = 0;
|
||||
if(timeRound!=null){
|
||||
startTime = (int) (TimeUtils.getAppointTime(timeRound[0][0], timeRound[0][1]) / 1000);
|
||||
endTime = (int) (TimeUtils.getAppointTime(timeRound[1][0], timeRound[1][1]) / 1000);
|
||||
}
|
||||
if(roundStartTime!=startTime){
|
||||
roundStartTime = startTime;
|
||||
}
|
||||
if(roundEndTime!=endTime){
|
||||
roundEndTime = endTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -664,9 +657,14 @@ public class GuildFightLogic {
|
|||
}
|
||||
}
|
||||
//清除布防信息
|
||||
GuilidManager.guildInfoMap.get(index).removeAllDefendInfo();
|
||||
GuilidManager.guildInfoMap.get(Integer.valueOf(index)).removeAllDefendInfo();
|
||||
}
|
||||
redisUtil.del(matchingKey,attackCountKey,extraStar,expKey,totalStar);
|
||||
redisUtil.del(matchingKey);
|
||||
redisUtil.del(attackCountKey);
|
||||
redisUtil.del(extraStar);
|
||||
redisUtil.del(expKey);
|
||||
redisUtil.del(totalStar);
|
||||
|
||||
}
|
||||
/**
|
||||
* 公会战结算(Redis中数据同到mongo)
|
||||
|
|
@ -882,5 +880,16 @@ public class GuildFightLogic {
|
|||
return totalStar;
|
||||
}
|
||||
|
||||
|
||||
private static boolean flagTimeRound(int[][] times,int hour,int minute){
|
||||
if(hour<times[0][0]||hour>times[1][0]){
|
||||
return false;
|
||||
}
|
||||
if(hour==times[0][0]&&minute<times[0][1]){
|
||||
return false;
|
||||
}
|
||||
if(hour==times[1][0]&&minute>=times[1][1]){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue