地图刷新
parent
ca1f5d5021
commit
f62eda7bda
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
|
@ -9,6 +10,7 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
|
|||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.CBean2Proto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -37,9 +39,18 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
userId, token,msgId,msgIndex,getPlayerInfoRequest.getNum(),getPlayerInfoRequest.getStr());
|
||||
|
||||
User user = UserManager.getUser(userId);
|
||||
// 需要隔天刷新的字段统一在这里处理
|
||||
if (TimeUtils.isOverTime(0, user.getLoginTime())) {
|
||||
user.setLoginTime(TimeUtils.now());
|
||||
// 地图刷新
|
||||
MapLogic.getInstance().refreshMapInfo(user);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
CommonProto.Player player = CBean2Proto.getPlayer(userId, user.getPlayerInfoManager(), user.getMapManager().getMaxMapId(), user.getMapManager().getCurMapId());
|
||||
|
||||
PlayerInfoProto.GetPlayerInfoResponse getPlayerInfoResponse
|
||||
= PlayerInfoProto.GetPlayerInfoResponse.newBuilder()
|
||||
.setPlayer(player)
|
||||
|
|
|
@ -1,14 +1,28 @@
|
|||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class CrossMapCell {
|
||||
|
||||
// missionId 存在某个地图的任务
|
||||
private Set<Integer> missionIds = new HashSet<>();
|
||||
// 每日刷新
|
||||
private Set<Integer> dayRefreshs = new HashSet<>();
|
||||
// 一次性事件
|
||||
private Set<Integer> permanents = new HashSet<>();
|
||||
|
||||
public Set<Integer> getMissionIds() {
|
||||
return missionIds;
|
||||
}
|
||||
|
||||
public Set<Integer> getDayRefreshs() {
|
||||
return dayRefreshs;
|
||||
}
|
||||
|
||||
public Set<Integer> getPermanents() {
|
||||
return permanents;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,6 +146,7 @@ public class MapLogic {
|
|||
}
|
||||
}
|
||||
}
|
||||
CrossMapCell crossMapCell = user.getMapManager().getCrossMapInfos().get(mapManager.getCurMapId());
|
||||
for (Map.Entry<Integer, SCMap> entry : scMap.entrySet()) {
|
||||
SCMap scMap1 = entry.getValue();
|
||||
if (scMap1.getIsMustAppear() == 1) {
|
||||
|
@ -168,6 +169,12 @@ public class MapLogic {
|
|||
LOGGER.info("====initMap()====mapPointConfig == null======>{}", scMap1.getEvent());
|
||||
continue;
|
||||
}
|
||||
if (crossMapCell != null && crossMapCell.getDayRefreshs().contains(mapPointConfig.getId())) {
|
||||
continue;
|
||||
}
|
||||
if (crossMapCell != null && crossMapCell.getPermanents().contains(mapPointConfig.getId())) {
|
||||
continue;
|
||||
}
|
||||
for (Mission mission : missions) {
|
||||
if (mission.getMapPoints().containsKey(mapPointConfig.getId())) {
|
||||
for (Map.Entry<Integer, Cell> missionEntry : mission.getMissionInfos().entrySet()) {
|
||||
|
@ -557,4 +564,15 @@ public class MapLogic {
|
|||
.build();
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 隔天刷新
|
||||
* @param user
|
||||
*/
|
||||
public void refreshMapInfo(User user) {
|
||||
Map<Integer, CrossMapCell> crossMapInfos = user.getMapManager().getCrossMapInfos();
|
||||
for (CrossMapCell crossMapCell : crossMapInfos.values()) {
|
||||
crossMapCell.getDayRefreshs().clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package com.ljsd.jieling.handler.map.behavior;
|
||||
|
||||
import com.ljsd.jieling.config.MapPointConfig;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.handler.map.Cell;
|
||||
import com.ljsd.jieling.handler.map.CrossMapCell;
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.handler.map.MapManager;
|
||||
import com.ljsd.jieling.handler.mission.CheckMissionReturn;
|
||||
|
@ -30,7 +32,8 @@ public class BehaviorUtil {
|
|||
* @throws Exception
|
||||
*/
|
||||
public static void distoryPoint(User user, int needDistoryPointId) throws Exception {
|
||||
Map<Integer, Cell> mapInfo = user.getMapManager().getMapInfo();
|
||||
MapManager mapManager = user.getMapManager();
|
||||
Map<Integer, Cell> mapInfo = mapManager.getMapInfo();
|
||||
Set<Integer> needDelete = new HashSet<>();
|
||||
for (Map.Entry<Integer, Cell> entry : mapInfo.entrySet()) {
|
||||
if (entry.getValue().getPointId() == needDistoryPointId) {
|
||||
|
@ -40,7 +43,27 @@ public class BehaviorUtil {
|
|||
for (Integer xy : needDelete) {
|
||||
mapInfo.remove(xy);
|
||||
}
|
||||
user.getMapManager().setMapInfo(mapInfo);
|
||||
mapManager.setMapInfo(mapInfo);
|
||||
|
||||
MapPointConfig mapPointConfig = MapPointConfig.getScMapEventMap().get(needDistoryPointId);
|
||||
/**
|
||||
* 事件点的刷新规则
|
||||
* 1 每日刷新
|
||||
* 2 探索刷新(不用处理)
|
||||
* 3 一次性
|
||||
*/
|
||||
if (mapPointConfig.getRefresh() == 1 || mapPointConfig.getRefresh() == 3) {
|
||||
CrossMapCell crossMapCell = mapManager.getCrossMapInfos().get(mapManager.getCurMapId());
|
||||
if (crossMapCell == null) {
|
||||
crossMapCell = new CrossMapCell();
|
||||
}
|
||||
if (mapPointConfig.getRefresh() == 1) {
|
||||
crossMapCell.getDayRefreshs().add(needDistoryPointId);
|
||||
}
|
||||
if (mapPointConfig.getRefresh() == 3) {
|
||||
crossMapCell.getPermanents().add(needDistoryPointId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.ljsd.jieling.db.mongo.MongoKey;
|
|||
import com.ljsd.jieling.handler.map.MapManager;
|
||||
import com.ljsd.jieling.handler.mission.MissionManager;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
|
||||
public class User {
|
||||
|
||||
|
@ -12,6 +13,8 @@ public class User {
|
|||
|
||||
private String id;
|
||||
|
||||
private long loginTime;
|
||||
|
||||
private PlayerManager playerManager;
|
||||
|
||||
private ItemManager itemManager;
|
||||
|
@ -41,6 +44,7 @@ public class User {
|
|||
|
||||
public User(int uid){
|
||||
this.id = Integer.toString(uid);
|
||||
this.loginTime = TimeUtils.now();
|
||||
this.playerManager = new PlayerManager();
|
||||
this.itemManager = new ItemManager();
|
||||
this.heroManager = new HeroManager();
|
||||
|
@ -146,4 +150,12 @@ public class User {
|
|||
public WorkShopController getWorkShopController() {
|
||||
return workShopController;
|
||||
}
|
||||
|
||||
public long getLoginTime() {
|
||||
return loginTime;
|
||||
}
|
||||
|
||||
public void setLoginTime(long loginTime) {
|
||||
this.loginTime = loginTime;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue