十绝阵提交
parent
8abd2af09c
commit
d9696552ff
|
@ -239,6 +239,15 @@ public class RedisKey {
|
|||
|
||||
public final static String ACTIVITY_GIFT_LIMIT = "ACTIVITY_GIFT_LIMIT"; //活动礼包个数限制
|
||||
|
||||
public static final String DEATH_PATH_EVERY_PERSON_RANK = "DEATH_PATH_EVERY_PERSON_RANK";
|
||||
|
||||
public static final String DEATH_PATH_EVERY_GUILD_RANK = "DEATH_PATH_EVERY_GUILD_RANK";
|
||||
|
||||
public static final String DEATH_PATH_CHALLENGE_COUNT = "DEATH_PATH_CHALLENGE_COUNT";
|
||||
|
||||
public static final String DEATH_PATH_TOTAL_PERSON_RANK = "DEATH_PATH_TOTAL_PERSON_RANK";
|
||||
|
||||
public static final String DEATH_PATH_TOTAL_GUILD_RANK = "DEATH_PATH_TOTAL_GUILD_RANK";
|
||||
|
||||
|
||||
public static Set<String> familyKey = new HashSet<>();
|
||||
|
|
|
@ -930,6 +930,9 @@ public class RedisUtil {
|
|||
}
|
||||
|
||||
public void incrementZsetScore(String type,String key, String value, int changeScore){
|
||||
incrementZsetScore(type,key,value,(double)(changeScore));
|
||||
}
|
||||
public void incrementZsetScore(String type,String key, String value, double changeScore){
|
||||
String rkey = getKey(type, key);
|
||||
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
||||
try {
|
||||
|
@ -944,6 +947,7 @@ public class RedisUtil {
|
|||
|
||||
|
||||
|
||||
|
||||
public void removeZSetRangeByRank(String key,int start,int end){
|
||||
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
||||
try {
|
||||
|
|
|
@ -127,6 +127,8 @@ public interface BIReason {
|
|||
|
||||
int RESET_GUILD_SKILL = 71;//重置工会技能
|
||||
|
||||
int DEATH_PATH_CHALLENGE = 72;//十绝阵挑战奖励
|
||||
|
||||
|
||||
|
||||
int ADVENTURE_UPLEVEL_CONSUME = 1000;//秘境升级
|
||||
|
|
|
@ -19,7 +19,6 @@ public class RankHandler extends BaseHandler<PlayerInfoProto.RankRequest> {
|
|||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, PlayerInfoProto.RankRequest proto) throws Exception {
|
||||
// MapLogic.getInstance().getTowerRank(iSession,proto.getType(),MessageTypeProto.MessageType.GET_ONE_RANK_RESPONSE);
|
||||
RankLogic.getInstance().getRank(iSession,proto.getType(),proto.getActiviteId(),MessageTypeProto.MessageType.GET_ONE_RANK_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler.family.deathPath;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.DeathPathLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.Family;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/5/7
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class DeathPathChallengeHandler extends BaseHandler<Family.ChallengeDeathPathRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.DEATH_PATH_CHALLENGE_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, Family.ChallengeDeathPathRequest proto) throws Exception {
|
||||
DeathPathLogic.getInstance().challenge(iSession,proto.getPathId(), MessageTypeProto.MessageType.DEATH_PATH_CHALLENGE_RESPONSE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler.family.deathPath;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.DeathPathLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/5/7
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class GetDeathPathInfoHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.DEATH_PATH_INFO_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
DeathPathLogic.getInstance().getBaseInfo(iSession, MessageTypeProto.MessageType.DEATH_PATH_INFO_RESPONSE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.ljsd.jieling.handler.family.deathPath;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.DeathPathLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/5/7
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class GetDeathPathStatusHandler extends BaseHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.DEATH_PATH_GET_STATUS_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
DeathPathLogic.getInstance().getStatus(iSession,MessageTypeProto.MessageType.DEATH_PATH_GET_STATUS_RESPONSE);
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ public class GuildMyInfo extends MongoBase {
|
|||
private long preMoveTimestamp; //上次更新时间
|
||||
private int maxBossHurt; //工会boss最高伤害
|
||||
private int lastHurt; //上一次伤害
|
||||
private Map<Integer,Integer> deathMaxDamage = new HashMap<>();
|
||||
|
||||
private Map<Integer,Integer> guildSkill = new HashMap<>(4);
|
||||
public void clearOfLevelGuild(){
|
||||
|
@ -135,4 +136,14 @@ public class GuildMyInfo extends MongoBase {
|
|||
guildSkill.remove(type);
|
||||
updateString("guildSkill",guildSkill);
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getDeathMaxDamage() {
|
||||
return deathMaxDamage;
|
||||
}
|
||||
|
||||
public void setDeathMaxDamage(int pathId, int damage) {
|
||||
deathMaxDamage.put(pathId,damage);
|
||||
updateString("deathMaxDamage",deathMaxDamage);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,270 @@
|
|||
package com.ljsd.jieling.logic.family;
|
||||
|
||||
import com.ljsd.common.mogodb.util.BlockingUniqueQueue;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.logic.dao.GuildMyInfo;
|
||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
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.rank.RankContext;
|
||||
import com.ljsd.jieling.logic.rank.RankEnum;
|
||||
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
|
||||
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.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
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.TimeUtils;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/5/6
|
||||
* @discribe 十绝阵相关
|
||||
*/
|
||||
public class DeathPathLogic {
|
||||
private DeathPathLogic(){
|
||||
|
||||
}
|
||||
|
||||
private int[] guildWarOpenTime;
|
||||
|
||||
private int[][] guildWarTime;
|
||||
|
||||
private int overTime;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DeathPathLogic.class);
|
||||
|
||||
private Thread taskExecutor = null;
|
||||
|
||||
private BlockingQueue<DeathPathTask> tasks = new BlockingUniqueQueue<>();
|
||||
|
||||
public static class DeathPathLogicInstance {
|
||||
public final static DeathPathLogic instance = new DeathPathLogic();
|
||||
}
|
||||
|
||||
public static DeathPathLogic getInstance() {
|
||||
return DeathPathLogic.DeathPathLogicInstance.instance;
|
||||
}
|
||||
|
||||
private int status = 0;
|
||||
|
||||
/**
|
||||
* 检查是否在开启状态
|
||||
*/
|
||||
public void statusCheck(){
|
||||
if(guildWarOpenTime==null){
|
||||
guildWarOpenTime = SGuildSetting.sGuildSetting.getGuildWarOpenTime();
|
||||
}
|
||||
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;
|
||||
}
|
||||
}else if(guildWarOpenTime[0]==1){
|
||||
result = true;
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
if(result&&isOpen()){
|
||||
if(taskExecutor==null){
|
||||
taskExecutor = new DeathPathExecutor(tasks);
|
||||
taskExecutor.start();
|
||||
}
|
||||
status = 1;
|
||||
}else {
|
||||
status = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isOpen(){
|
||||
int hourOfDay = TimeUtils.getHourOfDay();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int minute = calendar.get(Calendar.MINUTE);
|
||||
if(hourOfDay<=guildWarTime[0][0]&&minute<guildWarTime[0][1]){
|
||||
if(overTime!=0)
|
||||
overTime=0;
|
||||
return false;
|
||||
}
|
||||
if(hourOfDay>=guildWarTime[1][0]&&minute>guildWarTime[1][1]){
|
||||
if(overTime!=0)
|
||||
overTime=0;
|
||||
return false;
|
||||
}
|
||||
if(overTime==0){
|
||||
overTime = (int)(TimeUtils.getAppointTime(guildWarTime[1][0],guildWarTime[1][1])/1000);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态
|
||||
* @param session
|
||||
* @param messageType
|
||||
*/
|
||||
public void getStatus(ISession session, MessageTypeProto.MessageType messageType){
|
||||
Family.GetDeathPathStatusResponse response = Family.GetDeathPathStatusResponse.newBuilder().setStatus(status).build();
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取十绝阵内部信息
|
||||
* @param session
|
||||
* @param messageType
|
||||
*/
|
||||
public void getBaseInfo(ISession session,MessageTypeProto.MessageType messageType){
|
||||
int uid = session.getUid();
|
||||
String count = (String) RedisUtil.getInstence().get(RedisKey.getKey(RedisKey.DEATH_PATH_CHALLENGE_COUNT, String.valueOf(uid), false));
|
||||
int challengeCount = count==null?0:Integer.parseInt(count);
|
||||
Family.GetDeathPathInfoResponse.Builder response = Family.GetDeathPathInfoResponse.newBuilder().setOverTime(overTime)
|
||||
.setChallengeCount(challengeCount);
|
||||
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getType());
|
||||
for(int i = 1 ;i<=10;i++){
|
||||
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getRedisKey(), String.valueOf(i), 0, 0);
|
||||
Iterator<ZSetOperations.TypedTuple<String>> iterator = zSetReverseRangeWithScores.iterator();
|
||||
if(!iterator.hasNext()){
|
||||
continue;
|
||||
}
|
||||
ZSetOperations.TypedTuple<String> next = iterator.next();
|
||||
int guildId = Integer.valueOf(next.getValue());
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||
Family.DeathPathInfo info = Family.DeathPathInfo.newBuilder().setGuildName(guildInfo.getName()).setPathId(i).build();
|
||||
response.addInfos(info);
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 挑战十绝阵
|
||||
* @param session
|
||||
* @param pathId
|
||||
* @param messageType
|
||||
*/
|
||||
public void challenge(ISession session, int pathId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
SGuildWarConfig config = STableManager.getConfig(SGuildWarConfig.class).get(pathId);
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), GlobalsDef.FORMATION_NORMAL, 1000, "", GameFightType.DeathPathChallenge, config.getMonsterId(), 3);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
||||
int damage = fightResult.getCheckResult()[1];
|
||||
CommonProto.FightData fightData = CommonProto.FightData.newBuilder()
|
||||
.setFightMaxTime(1000)
|
||||
.setFightSeed(fightResult.getSeed())
|
||||
.setHeroFightInfos(fightResult.getFightTeamInfo())
|
||||
.addAllMonsterList(fightResult.getMonsterTeamList())
|
||||
.build();
|
||||
//更新排行榜数据
|
||||
tasks.offer(new DeathPathTask(uid,guildId,damage,pathId));
|
||||
//挑战次数记录
|
||||
RedisUtil.getInstence().increment(RedisKey.getKey(RedisKey.DEATH_PATH_CHALLENGE_COUNT,String.valueOf(uid),false));
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, config.getReward(), BIReason.DEATH_PATH_CHALLENGE);
|
||||
Map<Integer, Integer> deathMaxDamage = user.getGuildMyInfo().getDeathMaxDamage();
|
||||
int maxDamage = deathMaxDamage.getOrDefault(pathId, 0);
|
||||
Family.ChallengeDeathPathResponse response = Family.ChallengeDeathPathResponse.newBuilder().setDamage(damage).setFightData(fightData).setDrop(drop).setHistoryMax(maxDamage).build();
|
||||
if(!deathMaxDamage.containsKey(pathId)||deathMaxDamage.get(pathId)<damage){
|
||||
user.getGuildMyInfo().setDeathMaxDamage(pathId,damage);
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response,true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
class DeathPathExecutor extends Thread{
|
||||
|
||||
|
||||
public DeathPathExecutor(BlockingQueue<DeathPathTask> blockingQueue) {
|
||||
this.blockingQueue = blockingQueue;
|
||||
}
|
||||
|
||||
private BlockingQueue<DeathPathTask> blockingQueue;
|
||||
@Override
|
||||
public void run() {
|
||||
while(true){
|
||||
try {
|
||||
DeathPathTask task= blockingQueue.take();
|
||||
taskDoExecute(task);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void taskDoExecute(DeathPathTask task){
|
||||
//操作每个关的公会数据
|
||||
task.setDamage(2000000000);
|
||||
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getType());
|
||||
|
||||
AbstractRank personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_PERSON_RANK.getType());
|
||||
|
||||
|
||||
//操作总的个人伤害
|
||||
AbstractRank personTotalRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_PERSON_RANK.getType());
|
||||
personTotalRank.addRank(task.getUid(),"",task.getDamage());
|
||||
//操作总的工会伤害
|
||||
AbstractRank guildTotalRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_GUILD_RANK.getType());
|
||||
|
||||
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
|
||||
int firstGuildId;
|
||||
Iterator<ZSetOperations.TypedTuple<String>> iterator = zSetReverseRangeWithScores.iterator();
|
||||
if(!iterator.hasNext()){
|
||||
guildTotalRank.addRank(task.getGuildId(),"",task.getDamage(),1);
|
||||
//操作每个关的个人数据
|
||||
if(personRank.getScoreById(task.getUid(),String.valueOf(task.getPathId()))==-1){
|
||||
guildRank.addRank(task.getGuildId(),String.valueOf(task.getPathId()),task.getDamage(),1);
|
||||
}else{
|
||||
guildRank.addRank(task.getGuildId(),String.valueOf(task.getPathId()),task.getDamage());
|
||||
}
|
||||
personRank.addRank(task.getUid(),String.valueOf(task.getPathId()),task.getDamage());
|
||||
}else{
|
||||
ZSetOperations.TypedTuple<String> next = iterator.next();
|
||||
firstGuildId = Integer.valueOf(next.getValue());
|
||||
//判断改阵排行榜中是否有我打过的信息,没有加个人数
|
||||
if(personRank.getScoreById(task.getUid(),String.valueOf(task.getPathId()))==-1){
|
||||
guildRank.addRank(task.getGuildId(),String.valueOf(task.getPathId()),task.getDamage(),1);
|
||||
}else{
|
||||
guildRank.addRank(task.getGuildId(),String.valueOf(task.getPathId()),task.getDamage());
|
||||
}
|
||||
personRank.addRank(task.getUid(),String.valueOf(task.getPathId()),task.getDamage());
|
||||
Set<ZSetOperations.TypedTuple<String>> currScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
|
||||
Iterator<ZSetOperations.TypedTuple<String>> currIterator = currScores.iterator();
|
||||
ZSetOperations.TypedTuple<String> currNext = currIterator.next();
|
||||
int currFirstGuildId = Integer.valueOf(currNext.getValue());
|
||||
if(currFirstGuildId==firstGuildId){
|
||||
guildTotalRank.addRank(task.getGuildId(),"",task.getDamage());
|
||||
}else{
|
||||
guildTotalRank.addRank(currFirstGuildId,"",task.getDamage(),1);
|
||||
guildTotalRank.addRank(firstGuildId,"",task.getDamage(),-1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.ljsd.jieling.logic.family;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/5/7
|
||||
* @discribe 十绝阵更新任务
|
||||
*/
|
||||
public class DeathPathTask {
|
||||
private int uid;
|
||||
|
||||
private int guildId;
|
||||
|
||||
private int damage;
|
||||
|
||||
private int pathId;
|
||||
|
||||
public DeathPathTask(int uid, int guildId, int damage, int pathId) {
|
||||
this.uid = uid;
|
||||
this.guildId = guildId;
|
||||
this.damage = damage;
|
||||
this.pathId = pathId;
|
||||
}
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public int getGuildId() {
|
||||
return guildId;
|
||||
}
|
||||
|
||||
public void setGuildId(int guildId) {
|
||||
this.guildId = guildId;
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public void setDamage(int damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public int getPathId() {
|
||||
return pathId;
|
||||
}
|
||||
|
||||
public void setPathId(int pathId) {
|
||||
this.pathId = pathId;
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ import com.ljsd.jieling.logic.fight.eventhandler.PVPFightHandler;
|
|||
* BloodyFight(7), // 血战
|
||||
* MonterFight(8), // 兽潮
|
||||
* DailyChallenge(9), //每日挑战
|
||||
* 十绝阵
|
||||
*/
|
||||
public enum GameFightType {
|
||||
StoryFight(FightType.StoryFight,new DefaultOfRedisCacheFightHandler(), RedisKey.LEVE_DIFFICULTY_FIGHT),
|
||||
|
@ -41,7 +42,8 @@ public enum GameFightType {
|
|||
GuildFight(FightType.GuildFight,new PVPFightHandler(),null),
|
||||
|
||||
GuildBossFight(FightType.GuildBossFight,new DefaultOfRedisCacheFightHandler(),RedisKey.GUILD_MONSTER_FIGHT),
|
||||
DailyChallenge(FightType.StoryFight,new DefaultWithoutHandFightHandler(),null)
|
||||
DailyChallenge(FightType.StoryFight,new DefaultWithoutHandFightHandler(),null),
|
||||
DeathPathChallenge(FightType.StoryFight,new DefaultWithoutHandFightHandler(),null)
|
||||
|
||||
;
|
||||
|
||||
|
|
|
@ -22,8 +22,11 @@ public enum RankEnum {
|
|||
RANDOM_CARD_PERFECT_RANK(11,RedisKey.RANDOM_CARD_PERFECT_RANK,RandomCardPerfectRank::new),//param1:时间 param2:英雄tempId param3:uid
|
||||
GUILD_BOSS_RANK(12,RedisKey.GUILD_BOSS_RANK,GuildBossRank::new),//param1:时间 param2:英雄tempId param3:uid
|
||||
GUILD_RED_PACKAGE_RANK(13,RedisKey.GUILD_RED_PACKAGE_RANK,GuildRedPackageRank::new),//param1:红包总价格 param2:无 param3:无
|
||||
DEATH_PATH_EVERY_PERSON_RANK(15,RedisKey.DEATH_PATH_EVERY_PERSON_RANK,DeathPathEveryPersonRank::new),//param1:当前阵玩家伤害 param2:无 param3:无
|
||||
DEATH_PATH_EVERY_GUILD_RANK(16,RedisKey.DEATH_PATH_EVERY_GUILD_RANK, DeathPathEveryGuildRank::new),//param1:当前阵公会伤害 param2:当前工会挑战人数 param3:无
|
||||
DEATH_PATH_TOTAL_PERSON_RANK(17,RedisKey.DEATH_PATH_TOTAL_PERSON_RANK,DeathPathTotalPersonRank::new),//param1:玩家总伤害 param2:无 param3:无
|
||||
DEATH_PATH_TOTAL_GUILD_RANK(18,RedisKey.DEATH_PATH_TOTAL_GUILD_RANK,DeathPathTotalGuildRank::new);//param1:工会总伤害 param2:无 param3:无
|
||||
|
||||
;
|
||||
private int type;
|
||||
private String redisKey;
|
||||
private BiFunction<Integer,String,AbstractRank> rankFunction;
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package com.ljsd.jieling.logic.rank.rankImpl;
|
||||
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
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
|
||||
* @date 2020/5/7
|
||||
* @discribe
|
||||
*/
|
||||
public class DeathPathEveryGuildRank extends AbstractRank {
|
||||
public DeathPathEveryGuildRank(int type, String redisKey) {
|
||||
super(type, redisKey);
|
||||
}
|
||||
|
||||
protected void getOptional(int index, ZSetOperations.TypedTuple<String> data, PlayerInfoProto.RankResponse.Builder builder) {
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(Integer.parseInt(data.getValue()));
|
||||
CommonProto.RankInfo.Builder everyRankInfo = CommonProto.RankInfo.newBuilder()
|
||||
.setRank(index)
|
||||
.setParam1(getParam1(data.getScore()))
|
||||
.setParam2(getParam2(data.getScore()))
|
||||
.setParam3(getParam3(data.getScore()));
|
||||
CommonProto.UserRank.Builder everyRank = CommonProto.UserRank.newBuilder()
|
||||
.setUid(guildInfo.getId())
|
||||
.setGuildName(guildInfo.getName())
|
||||
.setRankInfo(everyRankInfo);
|
||||
builder.addRanks(everyRank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getDataByScore(Double score) {
|
||||
return new int[]{(int)(score/1000),(int)(score%1000)};
|
||||
}
|
||||
|
||||
public double getScore(double... data) {
|
||||
long result = (long) (data[0]*1000);
|
||||
if(data.length>1){
|
||||
result+=data[1];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public void addRank(int uid,String rkey,double... data){
|
||||
RedisUtil.getInstence().incrementZsetScore(redisKey,rkey,String.valueOf(uid), getScore(data));
|
||||
}
|
||||
@Override
|
||||
protected void getMyInfo(User user, String rkey, PlayerInfoProto.RankResponse.Builder allUserResponse){
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
int myRank= RedisUtil.getInstence().getZSetreverseRank(redisKey,rkey,Integer.toString(guildId)).intValue();
|
||||
Double zSetScore = RedisUtil.getInstence().getZSetScore(redisKey, rkey, Integer.toString(guildId));
|
||||
CommonProto.RankInfo towerRankInfo = CommonProto.RankInfo.newBuilder()
|
||||
.setRank(myRank)
|
||||
.setParam1(getParam1(zSetScore))
|
||||
.setParam2(getParam2(zSetScore)).build();
|
||||
allUserResponse.setMyRankInfo(towerRankInfo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.ljsd.jieling.logic.rank.rankImpl;
|
||||
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/5/7
|
||||
* @discribe
|
||||
*/
|
||||
public class DeathPathEveryPersonRank extends AbstractRank {
|
||||
|
||||
public DeathPathEveryPersonRank(int type, String redisKey) {
|
||||
super(type, redisKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getDataByScore(Double score) {
|
||||
return new int[]{score.intValue()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getScore(double... data) {
|
||||
return data[0];
|
||||
}
|
||||
|
||||
public void addRank(int uid,String rkey,double... data){
|
||||
RedisUtil.getInstence().incrementZsetScore(redisKey,rkey,String.valueOf(uid), Double.valueOf(getScore(data)).intValue());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.ljsd.jieling.logic.rank.rankImpl;
|
||||
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
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
|
||||
* @date 2020/5/8
|
||||
* @discribe
|
||||
*/
|
||||
public class DeathPathTotalGuildRank extends AbstractRank{
|
||||
public DeathPathTotalGuildRank(int type, String redisKey) {
|
||||
super(type, redisKey);
|
||||
}
|
||||
|
||||
@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))));
|
||||
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))));
|
||||
if(data.length>1){
|
||||
decimal = decimal.add(new BigDecimal(data[1]));
|
||||
}
|
||||
return decimal.doubleValue();
|
||||
}
|
||||
|
||||
protected void getOptional(int index, ZSetOperations.TypedTuple<String> data, PlayerInfoProto.RankResponse.Builder builder) throws Exception {
|
||||
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(Integer.parseInt(data.getValue()));
|
||||
CommonProto.RankInfo.Builder everyRankInfo = CommonProto.RankInfo.newBuilder()
|
||||
.setRank(index)
|
||||
.setParam1(getParam1(data.getScore()))
|
||||
.setParam2(getParam2(data.getScore()))
|
||||
.setParam3(getParam3(data.getScore()));
|
||||
CommonProto.UserRank.Builder everyRank = CommonProto.UserRank.newBuilder()
|
||||
.setUid(guildInfo.getId())
|
||||
.setGuildName(guildInfo.getName())
|
||||
.setRankInfo(everyRankInfo);
|
||||
builder.addRanks(everyRank);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void getMyInfo(User user, String rkey, PlayerInfoProto.RankResponse.Builder allUserResponse) {
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
int myRank= RedisUtil.getInstence().getZSetreverseRank(redisKey,rkey,Integer.toString(guildId)).intValue();
|
||||
Double zSetScore = RedisUtil.getInstence().getZSetScore(redisKey, rkey, Integer.toString(guildId));
|
||||
CommonProto.RankInfo towerRankInfo = CommonProto.RankInfo.newBuilder()
|
||||
.setRank(myRank)
|
||||
.setParam1(getParam1(zSetScore))
|
||||
.setParam2(getParam2(zSetScore)).build();
|
||||
allUserResponse.setMyRankInfo(towerRankInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRank(int uid, String rkey, double... data) {
|
||||
RedisUtil.getInstence().incrementZsetScore(redisKey,rkey,String.valueOf(uid), getScore(data));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.ljsd.jieling.logic.rank.rankImpl;
|
||||
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/5/8
|
||||
* @discribe 十绝阵个人总排行
|
||||
*/
|
||||
public class DeathPathTotalPersonRank extends AbstractRank {
|
||||
|
||||
public DeathPathTotalPersonRank(int type, String redisKey) {
|
||||
super(type, redisKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getDataByScore(Double score) {
|
||||
return new int[]{score.intValue()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getScore(double... data) {
|
||||
return data[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRank(int uid, String rkey, double... data) {
|
||||
RedisUtil.getInstence().incrementZsetScore(redisKey,rkey,String.valueOf(uid), getScore(data));
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ import com.ljsd.jieling.logic.arena.ArenaLogic;
|
|||
import com.ljsd.jieling.logic.championship.ChampionshipLogic;
|
||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
import com.ljsd.jieling.logic.family.DeathPathLogic;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
import com.ljsd.jieling.logic.fight.CombatLogic;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
|
@ -78,7 +79,7 @@ public class MinuteTask extends Thread {
|
|||
CoreLogic.getInstance().checkCoreCdk();
|
||||
BuyGoodsLogic.minuteCheckReharge();
|
||||
RedisUtil.getInstence().set(RedisKey.ONLINE_NUM+RedisKey.Delimiter_colon+GameApplication.serverId, String.valueOf(OnlineUserManager.sessionMap.entrySet().size()));
|
||||
|
||||
DeathPathLogic.getInstance().statusCheck();
|
||||
LOGGER.info("MinuteTask end...");
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("e",e);
|
||||
|
|
|
@ -28,6 +28,8 @@ public class SGuildSetting implements BaseConfig {
|
|||
|
||||
private int[] guildWarOpenTime;
|
||||
|
||||
private int[][] guildWarTime;
|
||||
|
||||
private int[][] prepareTime;
|
||||
|
||||
private int[][] matchTime;
|
||||
|
@ -219,4 +221,8 @@ public class SGuildSetting implements BaseConfig {
|
|||
public int[] getGiveLikeReward() {
|
||||
return giveLikeReward;
|
||||
}
|
||||
|
||||
public int[][] getGuildWarTime() {
|
||||
return guildWarTime;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="GuildWarConfig")
|
||||
public class SGuildWarConfig implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int monsterId;
|
||||
|
||||
private int[][] reward;
|
||||
|
||||
private int maxHealth;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getMonsterId() {
|
||||
return monsterId;
|
||||
}
|
||||
|
||||
public int[][] getReward() {
|
||||
return reward;
|
||||
}
|
||||
|
||||
public int getMaxHealth() {
|
||||
return maxHealth;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue