back_recharge
wangyuan 2019-05-24 13:39:04 +08:00
parent 536a5e02f2
commit 5d0c9224b8
8 changed files with 72 additions and 16 deletions

View File

@ -0,0 +1,4 @@
package com.ljsd.jieling.globals;
public class GlobalPrivilegeType {
}

View File

@ -32,6 +32,9 @@ public class GetAllMailHandler extends BaseHandler {
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={}",
userId, token,msgId,msgIndex);
List<CommonProto.Mail> allUserMail = MailLogic.getInstance().getAllUserMail(userId);
if(allUserMail.size()>10){
allUserMail = allUserMail.subList(0, 10);
}
PlayerInfoProto.GetAllMailInfoResponse getPlayerInfoResponse = PlayerInfoProto.GetAllMailInfoResponse.newBuilder()
.addAllMialList(allUserMail)
.build();

View File

@ -4,6 +4,7 @@ import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.logic.activity.ActivityLogic;
import com.ljsd.jieling.logic.activity.ActivityType;
import com.ljsd.jieling.logic.arena.ArenaLogic;
import com.ljsd.jieling.logic.dao.PlayerManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.store.StoreLogic;
@ -47,8 +48,9 @@ public class GetPlayerInfoHandler extends BaseHandler{
userId, token,msgId,msgIndex,getPlayerInfoRequest.getNum(),getPlayerInfoRequest.getStr());
User user = UserManager.getUser(userId);
PlayerManager playerInfoManager = user.getPlayerInfoManager();
// 需要隔天刷新的字段统一在这里处理
if (TimeUtils.isOverTime(5, user.getPlayerInfoManager().getLoginTime())) {
if (TimeUtils.isOverTime(5,playerInfoManager.getLoginTime())) {
MapLogic.getInstance().resetDayInfo(user);
//活动刷新
ActivityLogic.getInstance().flushEveryDay(user);
@ -58,20 +60,29 @@ public class GetPlayerInfoHandler extends BaseHandler{
ArenaLogic.getInstance().flushFreeUseTimes(user);
}
user.getPlayerInfoManager().setLoginTime(TimeUtils.now());
Map<Integer, Integer> guidePoints = user.getPlayerInfoManager().getGuidePoints();
playerInfoManager.setLoginTime(TimeUtils.now());
Map<Integer, Integer> guidePoints = playerInfoManager.getGuidePoints();
Map<Integer, Integer> vipInfo = playerInfoManager.getVipInfo();
List<CommonProto.NewPlayerGuidePoint> list = new ArrayList<>();
List<CommonProto.Privilege> privilegeList = new ArrayList<>();
for(Map.Entry<Integer,Integer> guideItem : guidePoints.entrySet()){
list.add(CommonProto.NewPlayerGuidePoint.newBuilder()
.setType(guideItem.getKey())
. setId(guideItem.getValue())
.build());
}
for(Map.Entry<Integer,Integer> vipInfoItem : vipInfo.entrySet()){
privilegeList.add(CommonProto.Privilege.newBuilder()
.setId(vipInfoItem.getKey())
. setUseeTimes(vipInfoItem.getValue())
.build());
}
CommonProto.Player player = CBean2Proto.getPlayer(userId, user.getPlayerInfoManager(), user.getPlayerInfoManager().getMapId(), user.getMapManager().getCurMapId(),user.getMapManager());
PlayerInfoProto.GetPlayerInfoResponse getPlayerInfoResponse
= PlayerInfoProto.GetPlayerInfoResponse.newBuilder()
.setPlayer(player)
.addAllNewPlayerGuidePoint(list)
.addAllPrivilege(privilegeList)
.build();
try {
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_PLAYERINFO_RESPONSE_VALUE, getPlayerInfoResponse, true);

View File

@ -2,8 +2,10 @@ package com.ljsd.jieling.logic.arena;
import com.ljsd.common.mogodb.LjsdMongoTemplate;
import com.ljsd.jieling.config.*;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.globals.Global;
@ -567,6 +569,7 @@ public class ArenaLogic {
break;
}
MailLogic.getInstance().sendMail(Integer.parseInt(user.getId()),title,content,rewardByRank,nowTime, Global.MAIL_EFFECTIVE_TIME);
MongoUtil.getInstence().lastUpdate();
}
}

View File

@ -25,6 +25,7 @@ public class AdventureBoss {
this.remainHps = remainHp;
this.bossGroupId = bossGroupId;
this.arenaLevel = arenaLevel;
this.arenaId = arenaId;
}

View File

@ -47,6 +47,8 @@ public class PlayerManager extends MongoBase {
private Map<Integer,Integer> guidePoints = new HashMap<>();
private Map<Integer,Integer> vipInfo = new HashMap<>();
public PlayerManager(){
this.setRootCollection(User._COLLECTION_NAME);
}
@ -202,4 +204,12 @@ public class PlayerManager extends MongoBase {
updateString("loginTime", loginTime);
this.loginTime = loginTime;
}
public Map<Integer, Integer> getVipInfo() {
return vipInfo;
}
public void updateVipInfo(int vipLevel){
}
}

View File

@ -148,6 +148,7 @@ public class CombatLogic {
boolean need = false;
if(StringUtil.isEmpty(adventureStateInfo.getBossId())){
if(now-adventureStateInfo.getStartTime()>nextFlushTime){
remainTime=0;
needRandom = true;
}
}else{
@ -162,6 +163,7 @@ public class CombatLogic {
int bossGroupId = randomInvasionBoss(uid, adventureStateInfo.getPosition());
if(bossGroupId>0){
nextFlushTime+=remainTime;
remainTime =sAdventureConfig.getInvasionBossHolding();
need=true;
}
}
@ -209,6 +211,11 @@ public class CombatLogic {
}
}else{
if(remainTime>0){
AdventureBoss adventureBoss = RedisUtil.getInstence().getMapEntry(RedisKey.ADVENTRUEN_BOSS_INFO, "", adventureStateInfo.getBossId(), AdventureBoss.class);
if(adventureBoss == null){
needRandom = true;
remainTime=0;
}
need= true;
}
if(remainTime+nextFlushTime<0){
@ -336,7 +343,6 @@ public class CombatLogic {
private Map<Integer,CommonProto.Drop> getAdventureReward(User user, int position) throws Exception {
AdventureManager adventureManager = user.getAdventureManager();
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
int now = (int)(System.currentTimeMillis()/1000);
SGameSetting gameSetting = SGameSetting.getGameSetting();
@ -384,7 +390,6 @@ public class CombatLogic {
private Map<Integer,CommonProto.Drop> getAdventureFastReward(User user,int timeDuration) throws Exception {
AdventureManager adventureManager = user.getAdventureManager();
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
int now = (int)(System.currentTimeMillis()/1000);
SGameSetting gameSetting = SGameSetting.getGameSetting();
int adventureRefresh = gameSetting.getAdventureRefresh();
int times = timeDuration / adventureRefresh;
@ -428,6 +433,7 @@ public class CombatLogic {
FightInfoProto.AdventureBossInfoResponse.Builder builder = FightInfoProto.AdventureBossInfoResponse.newBuilder();
Map<String, Integer> myHurtInfo = RedisUtil.getInstence().getMapValues(RedisKey.ADVENTRUEN_BOSS_OWN, Integer.toString(uid), String.class, Integer.class);
int now = (int)(TimeUtils.now()/1000);
int count = 0;
if(myHurtInfo!=null&&!myHurtInfo.isEmpty()){
List<Object> kes = new ArrayList<>(myHurtInfo.keySet());
List<AdventureBoss> adventureBosseInfo = RedisUtil.getInstence().getMapEntrys(RedisKey.ADVENTRUEN_BOSS_INFO, "", kes, AdventureBoss.class);
@ -436,6 +442,9 @@ public class CombatLogic {
if(adventureBoss == null){
continue;
}
if(count>10){
break;
}
String bossId = adventureBoss.getBossId();
int arenaId = adventureBoss.getArenaId();
int findTime = adventureBoss.getFindTime();
@ -447,6 +456,7 @@ public class CombatLogic {
removeAdventureBosseInfo.add(bossId);
continue;
}
count++;
User findUsser = UserManager.getUser(findUserId);
builder.addAdventureBossInfo(CommonProto.AdventureBossInfo.newBuilder()
.setArenaId(adventureBoss.getArenaId())
@ -457,6 +467,7 @@ public class CombatLogic {
.setMyHurt(myHurtInfo.get(bossId))
.setRemainTime(remainTime)
.setTotalHp(adventureBoss.getTotalHp())
.setArenaLevel(adventureBoss.getArenaLevel())
.setBossRemainlHp(adventureBoss.getRemainHp())
.build());
myHurtInfo.remove(bossId);
@ -507,8 +518,7 @@ public class CombatLogic {
}
AdventureBoss adventureBoss = new AdventureBoss(bossId,bossGroupID,arenaID,levle,uid,now,totalHp,hps);
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_INFO,"",bossId,adventureBoss);
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_OWN,"",bossId,0);
broadAdventureBoss(adventureBoss,user.getPlayerInfoManager().getNickName());
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_OWN,Integer.toString(uid),bossId,0);
}
adventureStateInfo.setBossId(bossId);
adventureStateInfo.setBossGroupId(bossGroupID);
@ -543,6 +553,8 @@ public class CombatLogic {
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_BOSS_SHARE_RESPONSE_VALUE,"data wrong");
return;
}
User user = UserManager.getUser(session.getUid());
broadAdventureBoss(adventureBoss,user.getPlayerInfoManager().getNickName());
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_BOSS_SHARE_RESPONSE_VALUE,null,true);
}
@ -557,10 +569,10 @@ public class CombatLogic {
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_BOSS_CHALLENGE_RESPONSE_VALUE,"");
return;
}
if(dayChallengeTimes + fightTimes > adventureInvasionBossTimes){
/* if(dayChallengeTimes + fightTimes > adventureInvasionBossTimes){
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_BOSS_CHALLENGE_RESPONSE_VALUE,"over fight");
return;
}
}*/
AdventureBoss adventureBoss = RedisUtil.getInstence().getMapEntry(RedisKey.ADVENTRUEN_BOSS_INFO, "", bossId, AdventureBoss.class);
if(adventureBoss == null){
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_BOSS_CHALLENGE_RESPONSE_VALUE,"boss had killed");
@ -596,6 +608,7 @@ public class CombatLogic {
fightResult = checkResult[0];
//发送击杀boss奖励和发现者奖励
if(fightResult == 1){
i = i+1;
sendRewardOfBossKilled(adventureBoss.getFindUserId(),uid,bossGroupId,adventureBoss.getArenaId(),adventureBoss.getArenaLevel());
RedisUtil.getInstence().removeMapEntrys(RedisKey.ADVENTRUEN_BOSS_INFO,"",bossId);
break;
@ -605,7 +618,7 @@ public class CombatLogic {
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_INFO,"",Integer.toString(uid),adventureBoss);
RedisUtil.getInstence().incrementZsetScore(RedisKey.ADVENTRUEN_BOSS_RANK,"",Integer.toString(uid),totalHurt);
FightInfoProto.AdventurenBossChallengeResponse build = builder.setHurtNums(totalHurt)
.setFightResult(totalHurt)
.setFightResult(fightResult)
.setConsumeFightTimes(i)
.build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_BOSS_CHALLENGE_RESPONSE_VALUE,build,true);
@ -661,6 +674,12 @@ public class CombatLogic {
if (page == 0) {
page = 1;
}
int myuid = session.getUid();
/* Map<Integer, AdventureStateInfo> adventureStateInfoMap = UserManager.getUser(myuid).getAdventureManager().getAdventureStateInfoMap();
for(AdventureStateInfo adventureStateInfo : adventureStateInfoMap.values()){
randomInvasionBoss(myuid, adventureStateInfo.getPosition());
}*/
int start = (page - 1) * 20, end = page * 20 - 1;
List<CommonProto.AdventureRankItemInfo> adventureRankItemInfos = new ArrayList<>(20);
Set<ZSetOperations.TypedTuple<String>> adventureBossRankInfo= RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ADVENTRUEN_BOSS_RANK,"", start, end);
@ -671,15 +690,15 @@ public class CombatLogic {
User user = UserManager.getUser(uid);
adventureRankItemInfos.add(CBean2Proto.getAdventureRankItemInfo(uid,user,score,++start));
}
int uid = session.getUid();
int score = RedisUtil.getInstence().getZSetScore(RedisKey.ADVENTRUEN_BOSS_RANK,"", Integer.toString(uid)).intValue();
int score = RedisUtil.getInstence().getZSetScore(RedisKey.ADVENTRUEN_BOSS_RANK,"", Integer.toString(myuid)).intValue();
int myRank =-1;
if(score == -1){
score = 0;
}else{
myRank= RedisUtil.getInstence().getZSetreverseRank(RedisKey.ADVENTRUEN_BOSS_RANK,"",Integer.toString(uid)).intValue();
myRank= RedisUtil.getInstence().getZSetreverseRank(RedisKey.ADVENTRUEN_BOSS_RANK,"",Integer.toString(myuid)).intValue();
}
User user = UserManager.getUser(uid);
User user = UserManager.getUser(myuid);
CommonProto.AdventureRankItemInfo myinfo = CBean2Proto.getAdventureRankItemInfo(session.getUid(), user, score, myRank);
FightInfoProto.AdventurnRankResponse build = FightInfoProto.AdventurnRankResponse.newBuilder().addAllAdventureRankItemInfo(adventureRankItemInfos).setMyInfo(myinfo).build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_BOSS_RANK_RESPONSE_VALUE,build,true);

View File

@ -162,6 +162,11 @@ public class WorkShopLogic {
//装备打造
if(type == GlobalsDef.WORK_CREATE_TYPE){
SWorkShopEquipmentConfig sWorkShopEquipmentConfig = SWorkShopEquipmentConfig.getsWorkShopEquipmentConfigMap().get(functionId);
if(sWorkShopEquipmentConfig == null){
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ACTIVITE_WORKSHOP_RESPONSE_VALUE,"参数有误");
LOGGER.info("the function id ={} is null",functionId);
return;
}
if(!checkForActiveUseBlue(user,sWorkShopEquipmentConfig.getOpenRules())){
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ACTIVITE_WORKSHOP_RESPONSE_VALUE,"参数有误");
return;
@ -325,11 +330,11 @@ public class WorkShopLogic {
return;
}
SWorkShopRebuildConfig sWorkShopRebuildConfig = SWorkShopRebuildConfig.getsWorkShopRebuildConfigByQulity(sEquipConfig.getQuality());
int addExp = sWorkShopRebuildConfig.getExp();
user.getWorkShopController().addWorkShopExp(addExp);
Equip clone = (Equip)equip.clone();
clone.rebuildEquip(user.getWorkShopController().getWorkShopLevel());
equipManager.setUnDetermined(clone);
int addExp = sWorkShopRebuildConfig.getExp();
user.getWorkShopController().addWorkShopExp(addExp);
PlayerInfoProto.WorkShopRebuildRespoonse build = PlayerInfoProto.WorkShopRebuildRespoonse.newBuilder().setEquip(CBean2Proto.getEquipProto(clone)).build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WORKSHOP_REBUILD_RESPONSE_VALUE,build,true);
}