血战排行榜
parent
f823388c75
commit
8129e8cb2c
|
@ -154,6 +154,8 @@ public class RedisKey {
|
|||
|
||||
public static final String SESSION_OFFLINE = "SESSION_OFFLINE";
|
||||
|
||||
public static final String PLAYER_INFO_CACHE = "PLAYER_INFO_CACHE";
|
||||
|
||||
//问卷调查
|
||||
public static final String QUESTION_FROMBACK = "QUESTION_FROMBACK";
|
||||
public static final String BLOODY_RANK = "BLOODY_RANK";
|
||||
|
|
|
@ -964,7 +964,10 @@ public class RedisUtil {
|
|||
|
||||
|
||||
public String getKey(String type,String key){
|
||||
if(RedisKey.BLOODY_RANK.equals(key)){
|
||||
if(RedisKey.BLOODY_RANK.equals(type)){
|
||||
return type + RedisKey.Delimiter_colon + key;
|
||||
}
|
||||
if(RedisKey.PLAYER_INFO_CACHE.equals(type)){
|
||||
return type + RedisKey.Delimiter_colon + key;
|
||||
}
|
||||
return GameApplication.serverId + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.logic.blood.BloodLogic;
|
||||
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;
|
||||
|
||||
@Component
|
||||
public class BloodRankHandler extends BaseHandler{
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.BLOOD_RANK_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
BloodLogic.getInstance().getBloodRank(iSession, MessageTypeProto.MessageType.BLOOD_RANK_RESPONSE);
|
||||
}
|
||||
}
|
|
@ -129,6 +129,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
CommonProto.EndlessInfo.Builder endless = CommonProto.EndlessInfo.newBuilder();
|
||||
endless.setMapId(MapLogic.getEndlessMapId());
|
||||
endless.setWorldLevel(MongoUtil.getInstence().getMyMongoTemplate().findById(1, ServerConfig.class).getWorldLevel());
|
||||
endless.setBloodScore(RedisUtil.getInstence().getZSetScore(RedisKey.BLOODY_RANK,Integer.toString(1), Integer.toString(userId)).intValue());
|
||||
PlayerInfoProto.GetPlayerInfoResponse getPlayerInfoResponse
|
||||
= PlayerInfoProto.GetPlayerInfoResponse.newBuilder()
|
||||
.setPlayer(player)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.logic.blood;
|
||||
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
|
@ -8,9 +9,14 @@ import com.ljsd.jieling.logic.fight.CombatLogic;
|
|||
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.logic.item.ItemLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.RoomProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
@ -99,4 +105,30 @@ public class BloodLogic {
|
|||
return fightDefendTeamInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取血战排行榜
|
||||
* @param session
|
||||
* @param messageType
|
||||
*/
|
||||
public void getBloodRank(ISession session, MessageTypeProto.MessageType messageType){
|
||||
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.BLOODY_RANK, "1", 0, 100);
|
||||
Map<Integer, PlayerInfoCache> playerInfoCacheMap = RedisUtil.getInstence().getMapValues(RedisKey.PLAYER_INFO_CACHE, "", Integer.class, PlayerInfoCache.class);
|
||||
int rank = 0;
|
||||
RoomProto.BloodRankResponse.Builder response = RoomProto.BloodRankResponse.newBuilder();
|
||||
for(ZSetOperations.TypedTuple<String> blood:zsetreverseRangeWithScores){
|
||||
rank++;
|
||||
PlayerInfoCache cache = playerInfoCacheMap.get(Integer.parseInt(blood.getValue()));
|
||||
CommonProto.BloodPersonInfo info = CommonProto.BloodPersonInfo.newBuilder()
|
||||
.setHead(cache.getHead())
|
||||
.setId(Integer.parseInt(blood.getValue()))
|
||||
.setHeadFrame(cache.getHeadFrame())
|
||||
.setLevel(cache.getLevel())
|
||||
.setServerId(cache.getServerId())
|
||||
.setScore(blood.getScore().intValue())
|
||||
.setRank(rank).build();
|
||||
response.addInfos(info);
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
public class PlayerInfoCache {
|
||||
private int serverId;
|
||||
private String name;
|
||||
private String head;
|
||||
private int headFrame;
|
||||
private int level;
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getHead() {
|
||||
return head;
|
||||
}
|
||||
|
||||
public int getHeadFrame() {
|
||||
return headFrame;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setHead(String head) {
|
||||
this.head = head;
|
||||
}
|
||||
|
||||
public void setHeadFrame(int headFrame) {
|
||||
this.headFrame = headFrame;
|
||||
}
|
||||
|
||||
public void setServerId(int serverId) {
|
||||
this.serverId = serverId;
|
||||
}
|
||||
|
||||
public int getServerId() {
|
||||
return serverId;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
}
|
|
@ -84,6 +84,7 @@ public class UserManager {
|
|||
playerManager.setMaxForce(force);
|
||||
PlayerLogic.getInstance().vipflushEveryDay(user,null);
|
||||
ActivityLogic.getInstance().newPlayerOpenActivityMission(user);
|
||||
PlayerLogic.getInstance().playerInfoUpdate(user);
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.USER_LEVELUP,0,1);
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.DAILY_REFRESH,0);
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.BEGINNER);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.logic.player;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.config.*;
|
||||
import com.ljsd.jieling.core.VipPrivilegeType;
|
||||
import com.ljsd.jieling.dataReport.reportBeans_37.ChatContentType;
|
||||
|
@ -149,7 +150,7 @@ public class PlayerLogic {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
playerInfoUpdate(user);
|
||||
MessageUtil.sendMessage(iSession,1,msgId,null,true);
|
||||
}
|
||||
|
||||
|
@ -355,6 +356,7 @@ public class PlayerLogic {
|
|||
return;
|
||||
}
|
||||
user.getPlayerInfoManager().setHeadFrame(frameId);
|
||||
playerInfoUpdate(user);
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
|
||||
}
|
||||
|
||||
|
@ -509,4 +511,18 @@ public class PlayerLogic {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户基础信息修改同步到redis
|
||||
*/
|
||||
public void playerInfoUpdate(User user){
|
||||
PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
||||
PlayerInfoCache cache = new PlayerInfoCache();
|
||||
cache.setHead(playerInfoManager.getHead());
|
||||
cache.setHeadFrame(playerInfoManager.getHeadFrame());
|
||||
cache.setName(playerInfoManager.getNickName());
|
||||
cache.setLevel(playerInfoManager.getLevel());
|
||||
cache.setServerId(GameApplication.serverId);
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.PLAYER_INFO_CACHE,"",String.valueOf(user.getId()),cache);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue