Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
21eeee56c8
File diff suppressed because it is too large
Load Diff
|
@ -241,6 +241,8 @@ public class RedisKey {
|
|||
|
||||
public final static String ACTIVITY_GIFT_LIMIT = "ACTIVITY_GIFT_LIMIT"; //活动礼包个数限制
|
||||
|
||||
public final static String CAR_CHALLENEG_SB = "CAR_CHALLENEG_SB"; //车迟玩法挑战记录
|
||||
|
||||
|
||||
|
||||
public static Set<String> familyKey = new HashSet<>();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
|
@ -69,6 +70,11 @@ public class FastChallengeHandler extends BaseHandler<FightInfoProto.FastFightCh
|
|||
|
||||
}break;
|
||||
case 2:{
|
||||
Integer mapValue = RedisUtil.getInstence().getMapValue(RedisKey.CAR_CHALLENEG_SB, String.valueOf(uid), String.valueOf(challeageId), Integer.class);
|
||||
if(mapValue!=null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE);
|
||||
}
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.CAR_CHALLENEG_SB, String.valueOf(uid), String.valueOf(challeageId), 1);
|
||||
PVPFightEvent pvpFightEvent = new PVPFightEvent(uid,GlobalsDef.CAR_DELAY_TEAM, battleRound,"", GameFightType.CarPersonChallenge,challeageId,GlobalsDef.CAR_DELAY_TEAM);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pvpFightEvent);
|
||||
int fight = fightResult.getCheckResult()[0];
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
|
@ -10,16 +11,21 @@ import com.ljsd.jieling.logic.dao.UserManager;
|
|||
import com.ljsd.jieling.logic.dao.root.GuildCache;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||
import com.ljsd.jieling.logic.rank.RankEnum;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.Family;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SWorldBossSetting;
|
||||
import manager.STableManager;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class GetCarChallengeListHandler extends BaseHandler {
|
||||
|
@ -36,10 +42,10 @@ public class GetCarChallengeListHandler extends BaseHandler {
|
|||
if(guildId == 0){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
Long myRank = RedisUtil.getInstence().getZSetreverseRank(RedisKey.CAR_DEALY_RANK, "", String.valueOf(uid));
|
||||
int myRank = RedisUtil.getInstence().getZSetreverseRank(RedisKey.CAR_DEALY_RANK, "", String.valueOf(uid)).intValue();
|
||||
int[] matchSection = STableManager.getConfig(SWorldBossSetting.class).get(1).getMatchSection();
|
||||
int matchNums = matchSection[0] + matchSection[1];
|
||||
Set<ZSetOperations.TypedTuple<String>> infos = new LinkedHashSet<>(matchNums);
|
||||
Set<ZsetTypedTupleWithRank> infos = new LinkedHashSet<>(matchNums);
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||
Set<Integer> members = new HashSet<>();
|
||||
guildInfo.getMembers().values().forEach(integers ->members.addAll(integers));
|
||||
|
@ -47,30 +53,91 @@ public class GetCarChallengeListHandler extends BaseHandler {
|
|||
int zsetSize = RedisUtil.getInstence().getZsetSize(key);
|
||||
if(myRank == -1){
|
||||
int start = zsetSize - matchNums;
|
||||
int end=-1;
|
||||
while (start>=0 && infos.size()<matchNums){
|
||||
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CAR_DEALY_RANK, "", start, end);
|
||||
for(ZSetOperations.TypedTuple<String> item : zsetreverseRangeWithScores){
|
||||
if(!members.contains(Integer.parseInt(item.getValue()))){
|
||||
zsetreverseRangeWithScores.add(item);
|
||||
}
|
||||
}
|
||||
end=start;
|
||||
start-=matchNums;
|
||||
if(start<0){
|
||||
start=0;
|
||||
}
|
||||
int end=-1;
|
||||
process(start,end,members,matchNums,infos);
|
||||
}else{
|
||||
//取前面
|
||||
/* int start = (int) (myRank - matchSection[0]);
|
||||
while (start>0 && infos.size()<matchNums){
|
||||
end=start+matchNums;
|
||||
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CAR_DEALY_RANK, "", start, end);
|
||||
zsetreverseRangeWithScores.forEach(item->{
|
||||
if(!members.contains(Integer.parseInt(item.getValue()))){
|
||||
zsetreverseRangeWithScores.add(item);
|
||||
}
|
||||
});
|
||||
int topStart = myRank - matchSection[0];
|
||||
if(topStart<0){
|
||||
topStart=0;
|
||||
}
|
||||
RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CAR_DEALY_RANK, "", myRank - matchSection[0], myRank+5);*/
|
||||
int topEnd = myRank;
|
||||
process(topStart,topEnd,members,matchNums,infos);
|
||||
int downStart = myRank;
|
||||
if(downStart<0){
|
||||
downStart=0;
|
||||
}
|
||||
int downEnd = myRank+matchSection[1];
|
||||
process(downStart,downEnd,members,matchNums,infos);
|
||||
}
|
||||
int myscore = 0;
|
||||
if(myRank!=-1){
|
||||
myscore = RedisUtil.getInstence().getZSetScore(RedisKey.CAR_DEALY_RANK, "", String.valueOf(uid)).intValue();
|
||||
}
|
||||
Family.GetCarChallenegListResponse.Builder builder = Family.GetCarChallenegListResponse.newBuilder().setMyRank(myRank).setMyScore(myscore);
|
||||
Map<Integer, Integer> records = RedisUtil.getInstence().getMapValues(RedisKey.CAR_CHALLENEG_SB, String.valueOf(uid), Integer.class, Integer.class);
|
||||
for(ZsetTypedTupleWithRank typedTupleWithRankitem: infos){
|
||||
ZSetOperations.TypedTuple<String> item = typedTupleWithRankitem.getItem();
|
||||
int challenegUid = Integer.parseInt(item.getValue());
|
||||
int rank = typedTupleWithRankitem.getRank();
|
||||
CommonProto.TeamOneInfo.Builder userTeamOneInfo = PlayerLogic.getInstance().getUserTeamOneInfo(challenegUid, GlobalsDef.CAR_DELAY_TEAM);
|
||||
User challenegeUser = UserManager.getUser(challenegUid);
|
||||
int challengeGuildId = challenegeUser.getPlayerInfoManager().getGuildId();
|
||||
Family.CarChallengeItem.Builder builder1 = Family.CarChallengeItem.newBuilder()
|
||||
.setUid(challenegUid)
|
||||
.setUserName(challenegeUser.getPlayerInfoManager().getNickName())
|
||||
.setScore(item.getScore().intValue())
|
||||
.setForce(0)
|
||||
.setTeamInfo(userTeamOneInfo)
|
||||
.setHadChallenge(records.containsKey(challenegUid)?1:0)
|
||||
.setRank(rank);
|
||||
if(challengeGuildId!=0){
|
||||
GuildInfo challenegeGuildInfo = GuilidManager.guildInfoMap.get(challenegeUser.getPlayerInfoManager().getGuildId());
|
||||
builder1.setGuildName(challenegeGuildInfo.getName());
|
||||
}
|
||||
builder.addCarChallengeItem(builder1);
|
||||
}
|
||||
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.GET_CAR_CHALLENEG_LIST_RESPONSE_VALUE,builder.build(),true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void process(int start,int end,Set<Integer> members,int matchNums, Set<ZsetTypedTupleWithRank> infos){
|
||||
while (start>=0 && infos.size()<matchNums){
|
||||
int rank=start+1;
|
||||
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CAR_DEALY_RANK, "", start, end);
|
||||
for(ZSetOperations.TypedTuple<String> item : zsetreverseRangeWithScores){
|
||||
if(!members.contains(Integer.parseInt(item.getValue()))){
|
||||
infos.add(new ZsetTypedTupleWithRank(item,rank++));
|
||||
}
|
||||
}
|
||||
end=start;
|
||||
start-=matchNums;
|
||||
if(end<=0){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class ZsetTypedTupleWithRank{
|
||||
ZSetOperations.TypedTuple<String> item;
|
||||
int rank;
|
||||
|
||||
public ZsetTypedTupleWithRank(ZSetOperations.TypedTuple<String> item, int rank) {
|
||||
this.item = item;
|
||||
this.rank = rank;
|
||||
}
|
||||
|
||||
public ZSetOperations.TypedTuple<String> getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public int getRank() {
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1228,19 +1228,18 @@ public class GuildFightLogic {
|
|||
public static Family.CarDelayProgressIndication carDelayProgressIndication;
|
||||
|
||||
public static void minuteCheckForCarFight() throws Exception {
|
||||
int carProgressTmp =carProgress;
|
||||
int id =-1;
|
||||
TimeControllerOfFunction timeControllerOfFunction = GlobalDataManaager.getInstance().getTimeControllerOfFunctionByFunctinoType(FunctionIdEnum.Car_Delay);
|
||||
if (null == timeControllerOfFunction) {
|
||||
carProgress = -1;
|
||||
carDelayProgressIndication= Family.CarDelayProgressIndication.newBuilder().setProgress(carProgress).build();
|
||||
return;
|
||||
}
|
||||
int times = timeControllerOfFunction.getTimes();
|
||||
long startTime = timeControllerOfFunction.getStartTime();
|
||||
|
||||
int size = STableManager.getConfig(SWorldBossConfig.class).size();
|
||||
int id = times%size;
|
||||
if(id == 0){
|
||||
id = size;
|
||||
}else{
|
||||
int times = timeControllerOfFunction.getTimes();
|
||||
int size = STableManager.getConfig(SWorldBossConfig.class).size();
|
||||
id = times%size;
|
||||
if(id == 0){
|
||||
id = size;
|
||||
}
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
SWorldBossSetting sWorldBossSetting = STableManager.getConfig(SWorldBossSetting.class).get(1);
|
||||
|
@ -1249,7 +1248,6 @@ public class GuildFightLogic {
|
|||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
int minute = calendar.get(Calendar.MINUTE);
|
||||
int endTime = 0;
|
||||
int carProgressTmp =carProgress;
|
||||
int sourceCompare = hour*100 + minute;
|
||||
int battleCompareStart =battleTime[0][0]*100 + battleTime[0][1];
|
||||
int battleCompaeEnd =battleTime[1][0]*100 + battleTime[1][1];
|
||||
|
@ -1276,14 +1274,17 @@ public class GuildFightLogic {
|
|||
calendar.set(calendar.SECOND,0);
|
||||
endTime = (int)(calendar.getTimeInMillis()/1000);
|
||||
|
||||
}else if(sourceCompare>=battleCompaeEnd && sourceCompare<=grapCompareStart){
|
||||
carProgressTmp = 2;
|
||||
}else{
|
||||
carProgressTmp = -1;
|
||||
}
|
||||
if(carProgressTmp!=carProgress){
|
||||
int battleStartTime = 0;
|
||||
int grapStartTime = 0;
|
||||
Calendar instance = Calendar.getInstance();
|
||||
instance.setTimeInMillis(startTime);
|
||||
if(sourceCompare>grapCompaeEnd){
|
||||
calendar.setTimeInMillis(calendar.getTimeInMillis() + 24*3600*1000L);
|
||||
}
|
||||
calendar.set(calendar.HOUR_OF_DAY,grabTime[0][0]);
|
||||
calendar.set(calendar.MINUTE,grabTime[0][1]);
|
||||
calendar.set(calendar.SECOND,0);
|
||||
|
@ -1295,7 +1296,6 @@ public class GuildFightLogic {
|
|||
calendar.set(calendar.SECOND,0);
|
||||
|
||||
battleStartTime = (int)(calendar.getTimeInMillis()/1000);
|
||||
|
||||
carProgress = carProgressTmp;
|
||||
carDelayProgressIndication= Family.CarDelayProgressIndication.newBuilder().setBossIndexId(id).setProgress(carProgress).setEndTime(endTime).
|
||||
setBattleStartTime(battleStartTime).setGrabStartTime(grapStartTime).
|
||||
|
|
Loading…
Reference in New Issue