血量 & 挂机显示离线时间

back_recharge
wangyuan 2019-04-19 14:24:28 +08:00
parent 986c064908
commit 1b39896daf
4 changed files with 32 additions and 1 deletions

View File

@ -957,8 +957,18 @@ public class MapLogic {
}
// LOGGER.info("endFight() uid=>{},nextEventId=>{}", uid, nextEventId);
updateMapMission(mapManager,EventType.fightEvent,0,monsterGroupId);
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(mapManager.getTeamId());
for (TeamPosHeroInfo heroInfo : teamPosHeroInfos) {
int position = heroInfo.getPosition();
Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId());
if (hero == null) {
continue;
}
hero.setCurHp(checkResult[position]);
}
// LOGGER.info("endFight() uid=>{} sMonsterGroup.getRewardgroup()=>{} misson=>{} eventDrop=>{}, missionDrop=>{}", uid, sMonsterGroup.getRewardgroup(), fightEndResponse.getMission(), fightEndResponse.getEnventDrop(), fightEndResponse.getMissionDrop());
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true);
}

View File

@ -41,6 +41,8 @@ public class PlayerManager extends MongoBase {
private int maxStamina ; // 最大体力
private long offLineTime;// 离线时间
private Map<Integer,Integer> guidePoints = new HashMap<>();
public PlayerManager(){
@ -180,4 +182,13 @@ public class PlayerManager extends MongoBase {
public int getMaxStamina() {
return maxStamina;
}
public long getOffLineTime() {
return offLineTime;
}
public void setOffLineTime(long offLineTime) {
updateString("offLineTime", offLineTime);
this.offLineTime = offLineTime;
}
}

View File

@ -36,6 +36,8 @@ public class CombatLogic {
public void getAdventureStateInfo(ISession session) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
PlayerManager playerInfoManager = user.getPlayerInfoManager();
int offLineTime = (int)((System.currentTimeMillis() -playerInfoManager.getOffLineTime())/1000);
AdventureManager adventureManager = user.getAdventureManager();
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
List<CommonProto.AdventureStateInfo> result = new ArrayList<>();
@ -43,7 +45,8 @@ public class CombatLogic {
for(AdventureStateInfo item : adventureStateInfoMap.values()){
result.add(CBean2Proto.getAdventureStateInfo(item,item.getPosition()));
}
FightInfoProto.GetAdventureStateInfoResponse response = FightInfoProto.GetAdventureStateInfoResponse.newBuilder().addAllAdventureStateInfoList(result).setDrop(dropBuilder.build()).build();
FightInfoProto.GetAdventureStateInfoResponse response = FightInfoProto.GetAdventureStateInfoResponse.newBuilder().addAllAdventureStateInfoList(result).setDrop(dropBuilder.build()).setLeveTime(offLineTime).
build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_ADVENTURE_INFO_RESPONSE_VALUE,response,true);
}

View File

@ -8,6 +8,8 @@ import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.netty.handler.GameMessageHandler;
import com.ljsd.jieling.network.session.ISession;
@ -224,13 +226,18 @@ public class ProtocolsManager implements ProtocolsAbstract {
try {
OnlineUserManager.userOffline(session.getUid());
User user = UserManager.getUser(session.getUid());
user.getPlayerInfoManager().setOffLineTime(System.currentTimeMillis());
// 下线处理的逻辑需要添加在这里
} catch (Exception e) {
e.printStackTrace();
} finally {
//保证数据的保存
}
}
}
public boolean kickOldUser(int uid, String uToken, int errorCode, String errorMsg, long requestTime) {
if (GameMessageHandler.currentSessions.size() != 0 && GameMessageHandler.currentSessions.keySet().contains(uid)) {
if (requestTime != 0 && requestTime < GameMessageHandler.currentSessions.get(uid).getUserLoginTime()) {