地图探索度
parent
2b06b9ace0
commit
fb403ea174
|
@ -56,8 +56,8 @@ public class MongoUpdateCache {
|
|||
}
|
||||
|
||||
public boolean checkOverride(String key1,String key2){
|
||||
String[] fullKeyArray = key1.split(".");
|
||||
String[] key1Array = key2.split(".");
|
||||
String[] fullKeyArray = key1.split("\\.");
|
||||
String[] key1Array = key2.split("\\.");
|
||||
if(fullKeyArray.length == key1Array.length && !fullKeyArray[fullKeyArray.length -1].equals(key1Array[key1Array.length -1])){
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -78,4 +78,9 @@ public class EventType {
|
|||
public static final int openAppointMission = 26;
|
||||
public static final int openNotDoMission = 27;
|
||||
|
||||
|
||||
public static final int updateEvent = 1;
|
||||
public static final int fightEvent = 2;
|
||||
public static final int shopEvent = 3;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
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 GetMapAccoumpHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GET_ALL_MAP_ACCOMPLISH_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
MapLogic.getInstance().getMapMisionDetail(iSession);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import com.ljsd.jieling.handler.map.behavior.BaseBehavior;
|
|||
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||
import com.ljsd.jieling.handler.mission.Mission;
|
||||
import com.ljsd.jieling.logic.dao.Hero;
|
||||
import com.ljsd.jieling.logic.dao.MailManager;
|
||||
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
@ -102,9 +103,11 @@ public class MapLogic {
|
|||
} else {
|
||||
Map<Integer, SCMap> scMap = SCMap.sCMap.get(mapId);
|
||||
if (scMap == null) {
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
if (mapId > mapManager.getCurMapId()) {
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(mapId);
|
||||
|
@ -226,6 +229,7 @@ public class MapLogic {
|
|||
}
|
||||
mapManager.setMapInfo(newMap);
|
||||
mapManager.setTypeEight(spicelMap);
|
||||
initMapMission(mapManager);
|
||||
}
|
||||
|
||||
|
||||
|
@ -364,6 +368,7 @@ public class MapLogic {
|
|||
return;
|
||||
}
|
||||
mapManager.setTotalStep(mapManager.getTotalStep() - mapPointConfig.getConfused());
|
||||
updateMapMission(mapManager,EventType.updateEvent,MapMissionType.CONSUME_ACTION_POWER_EVENT.getMissionTypeValue(),mapPointConfig.getConfused());
|
||||
}
|
||||
int behaviorType = sOptionConfig.getBehaviorType();
|
||||
int[][] behaviorTypeValues = sOptionConfig.getBehaviorTypeValues();
|
||||
|
@ -466,6 +471,7 @@ public class MapLogic {
|
|||
}
|
||||
// LOGGER.info("updateEvent =====>success<====== xy=>{}, getPointId=>{} eventId={}, mission=>{}, nextEventId=>{}, eventBehaviorCommon=>{}", mapManager.getCurXY(), cell == null ? 0 : cell.getPointId(),
|
||||
// cell == null ? 0 : cell.getEventId(), eventUpdateResponse.getMissionList(), nextEventId, eventBehaviorCommon);
|
||||
updateMapMission(mapManager,EventType.updateEvent,eventId,0);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), eventUpdateResponse.build(), true);
|
||||
}
|
||||
|
||||
|
@ -602,13 +608,15 @@ public class MapLogic {
|
|||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
MapMission mapMission = mapManager.getAllMissionProgress().get(mapManager.getCurMapId());
|
||||
if (mapManager.getMapInfo() == null) {
|
||||
LOGGER.info("mapManager.getMapInfo() == null");
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
MapInfoProto.MapOutResponse build = MapInfoProto.MapOutResponse.newBuilder().setMapAccomplishInfo(CBean2Proto.getMapAccomplishInfo(mapManager.getAllMissionProgress().get(mapManager.getCurMapId()))).build();
|
||||
resetMapInfo(user, true);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), build, true);
|
||||
}
|
||||
|
||||
public void resetMapInfo(User user, boolean needTemporaryItem) throws Exception {
|
||||
|
@ -725,10 +733,10 @@ public class MapLogic {
|
|||
int[] checkResult = CheckFight.getInstance().checkFight(seed, getFightData, getOptionData);
|
||||
//校验结果码 1:胜利
|
||||
int resultCode = checkResult[0];
|
||||
if (resultCode !=1){
|
||||
/* if (resultCode !=1){
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "战斗失败");
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
int teamId = user.getMapManager().getTeamId();
|
||||
List<TeamPosHeroInfo> team = user.getTeamPosManager().getTeamPosForHero().get(teamId);
|
||||
|
@ -748,6 +756,7 @@ public class MapLogic {
|
|||
.setDrop(drop)
|
||||
.addAllRemainHpList(remainHp)
|
||||
.build();
|
||||
updateMapMission(user.getMapManager(),EventType.fightEvent,0,monsterGroupId);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse, true);
|
||||
|
||||
|
||||
|
@ -763,4 +772,187 @@ public class MapLogic {
|
|||
crossMapCell.getDayRefreshs().clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void initMapMission( MapManager mapManager){
|
||||
int mapId = mapManager.getCurMapId();
|
||||
if(mapManager.getAllMissionProgress().containsKey(mapId)){
|
||||
return;
|
||||
}
|
||||
List<SAccomplishmentConfig> sAccomplishmentConfigs = SAccomplishmentConfig.getsAccomplishmentConfigByMapId(mapId);
|
||||
|
||||
Map<Integer,Integer> missionProgress = new HashMap<>();
|
||||
for(SAccomplishmentConfig sAccomplishmentConfig : sAccomplishmentConfigs){
|
||||
int id = sAccomplishmentConfig.getId();
|
||||
missionProgress.put(id,0);
|
||||
}
|
||||
MapMission mapMission = new MapMission(mapId,missionProgress);
|
||||
mapManager.addMapMission(mapMission);
|
||||
}
|
||||
|
||||
|
||||
public void updateMapMission(MapManager mapManager,int eventType,int eventId,int bossIdOrItemId){
|
||||
int mapId = mapManager.getCurMapId();
|
||||
MapMission mapMission = mapManager.getAllMissionProgress().get(mapId);
|
||||
int addScore=0;
|
||||
Map<Integer, Integer> allMissionProgress = mapMission.getAllMissionProgress();
|
||||
boolean needUpdate = false;
|
||||
for(Map.Entry<Integer,Integer> missionItem : allMissionProgress.entrySet()){
|
||||
Integer missionId = missionItem.getKey();
|
||||
Integer missionValue = missionItem.getValue();
|
||||
SAccomplishmentConfig sAccomplishmentConfig = SAccomplishmentConfig.getsAccomplishmentConfigByIdMap(missionId);
|
||||
int score = sAccomplishmentConfig.getScore();
|
||||
int logic = sAccomplishmentConfig.getLogic();
|
||||
int[] values = sAccomplishmentConfig.getValues();
|
||||
int targetEventId = values[0];
|
||||
int targetEventValue = values[1];
|
||||
if(logic == MapMissionType.FINISH_EVEVNT.getMissionTypeValue()){
|
||||
if(targetEventId == eventId){
|
||||
if(missionValue<targetEventValue){
|
||||
allMissionProgress.put(missionId,missionValue+1);
|
||||
needUpdate = true;
|
||||
if(missionValue+1 == targetEventValue){
|
||||
addScore+=score;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//updateEvent optionalConfig获取
|
||||
if(eventType == EventType.updateEvent){
|
||||
if(logic == eventId){
|
||||
if(missionValue<targetEventValue){
|
||||
allMissionProgress.put(missionId,missionValue+bossIdOrItemId);
|
||||
needUpdate = true;
|
||||
if(missionValue+bossIdOrItemId == targetEventValue){
|
||||
addScore+=score;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(logic == MapMissionType.DIGGER_EVENT.getMissionTypeValue()){
|
||||
MapPointConfig mapPointConfig = MapPointConfig.getScMapEventMap().get(eventId);
|
||||
if(mapPointConfig!=null&&mapPointConfig.getStyle() == 2){
|
||||
if(missionValue<targetEventValue){
|
||||
allMissionProgress.put(missionId,missionValue+1);
|
||||
needUpdate = true;
|
||||
if(missionValue+1 == targetEventValue){
|
||||
addScore+=score;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//todo 战斗结束处理
|
||||
if(eventType == EventType.fightEvent){
|
||||
if(logic == MapMissionType.KILL_BOSS.getMissionTypeValue()){
|
||||
if(targetEventId == bossIdOrItemId){
|
||||
if(missionValue<targetEventValue){
|
||||
allMissionProgress.put(missionId,missionValue+1);
|
||||
needUpdate = true;
|
||||
if(missionValue+1 == targetEventValue){
|
||||
addScore+=score;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(logic == MapMissionType.VICTORY_EVENT.getMissionTypeValue()){
|
||||
if(missionValue<targetEventValue){
|
||||
allMissionProgress.put(missionId,missionValue+1);
|
||||
needUpdate = true;
|
||||
if(missionValue+1 == targetEventValue){
|
||||
addScore+=score;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//todo 行脚商人 在地图商店买东西需要特殊处理
|
||||
if(eventType == EventType.shopEvent){
|
||||
if(logic == MapMissionType.BUY_GOODS_ID_EVENT.getMissionTypeValue()){
|
||||
if(targetEventId == eventId && bossIdOrItemId == targetEventValue && missionValue==0 ){
|
||||
allMissionProgress.put(missionId,1);
|
||||
addScore+=score;
|
||||
}
|
||||
}
|
||||
|
||||
if(logic == MapMissionType.BUY_GOODS_TYPE_EVENT.getMissionTypeValue()){
|
||||
if(targetEventId == eventId && missionValue==0 ){
|
||||
SItem sItem = SItem.getsItemMap().get(bossIdOrItemId);
|
||||
if(sItem.getItemType() == targetEventValue){
|
||||
allMissionProgress.put(missionId,1);
|
||||
needUpdate = true;
|
||||
addScore+=score;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//todo 开宝箱
|
||||
if(logic == MapMissionType.OPEN_BOX.getMissionTypeValue()){
|
||||
if(missionValue<targetEventValue){
|
||||
allMissionProgress.put(missionId,missionValue+1);
|
||||
needUpdate = true;
|
||||
if(missionValue+1 == targetEventValue){
|
||||
addScore+=score;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(addScore!=0){
|
||||
mapMission.setTotalWeight(mapMission.getTotalWeight()+addScore);
|
||||
}
|
||||
if(needUpdate){
|
||||
mapMission.setAllMissionProgress(allMissionProgress);
|
||||
}
|
||||
}
|
||||
|
||||
public void getMapMisionDetail(ISession session) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
Map<Integer, MapMission> allMapMissionProgress = mapManager.getAllMissionProgress();
|
||||
if(allMapMissionProgress == null || allMapMissionProgress.isEmpty()){
|
||||
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.GET_ALL_MAP_ACCOMPLISH_RESPONSE_VALUE,"");
|
||||
return;
|
||||
}
|
||||
List<CommonProto.MapAccomplishInfo> mapAccomplishInfos = new ArrayList<>(allMapMissionProgress.size());
|
||||
for(MapMission mapMission : allMapMissionProgress.values()){
|
||||
mapAccomplishInfos.add( CBean2Proto.getMapAccomplishInfo(mapMission));
|
||||
}
|
||||
|
||||
MapInfoProto.GetMapAccomplishResponse build = MapInfoProto.GetMapAccomplishResponse.newBuilder().addAllMapAccomplishInfo(mapAccomplishInfos).build();
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_ALL_MAP_ACCOMPLISH_RESPONSE_VALUE,build,true);
|
||||
}
|
||||
|
||||
|
||||
public void takeMissionBoxReward(ISession session,int mapId,int boxWeight) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
MapMission mapMission = mapManager.getAllMissionProgress().get(mapId);
|
||||
if(mapMission == null ){
|
||||
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.TAKE_MAP_MISSION_BOX_RESPONSE_VALUE,"");
|
||||
return;
|
||||
}
|
||||
SAccomplishmentBox sAccomplishmentBox = SAccomplishmentBox.getsAccomplishmentBoxByMapId(mapId);
|
||||
int totalWeight = mapMission.getTotalWeight();
|
||||
Integer rewaedGroupId = sAccomplishmentBox.getBoxMap().get(boxWeight);
|
||||
if(rewaedGroupId == null || totalWeight < boxWeight ){
|
||||
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.TAKE_MAP_MISSION_BOX_RESPONSE_VALUE,"");
|
||||
return;
|
||||
}
|
||||
if(mapMission.getHadTakeRewardIds().contains(boxWeight)){
|
||||
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.TAKE_MAP_MISSION_BOX_RESPONSE_VALUE,"hadTaked");
|
||||
return;
|
||||
}
|
||||
mapMission.getHadTakeRewardIds().add(boxWeight);
|
||||
mapMission.setHadTakeRewardIds(mapMission.getHadTakeRewardIds());
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, new int[]{rewaedGroupId}, 1.0f, 0);
|
||||
MapInfoProto.TakeMapBoxResponse build = MapInfoProto.TakeMapBoxResponse.newBuilder().setDrop(drop).build();
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.TAKE_MAP_MISSION_BOX_RESPONSE_VALUE,build,true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,9 @@ package com.ljsd.jieling.handler.map;
|
|||
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.config.SAccomplishmentConfig;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import org.springframework.data.mongodb.core.mapping.Field;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -35,6 +37,8 @@ public class MapManager extends MongoBase {
|
|||
|
||||
private List<FoodBuffer> foodBuffers = new ArrayList();
|
||||
|
||||
private Map<Integer, MapMission> allMissionProgress = new ConcurrentHashMap<>();
|
||||
|
||||
public MapManager() {
|
||||
this.setRootCollection(User._COLLECTION_NAME);
|
||||
}
|
||||
|
@ -188,4 +192,14 @@ public class MapManager extends MongoBase {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public Map<Integer, MapMission> getAllMissionProgress() {
|
||||
return allMissionProgress;
|
||||
}
|
||||
|
||||
public void addMapMission(MapMission mapMission) {
|
||||
mapMission.init(this.getRootId(),getMongoKey() + ".allMissionProgress." + mapMission.getMapId());
|
||||
updateString( "allMissionProgress." + mapMission.getMapId(), mapMission);
|
||||
allMissionProgress.put(mapMission.getMapId(),mapMission);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class MapMission extends MongoBase {
|
||||
|
||||
private int mapId;
|
||||
|
||||
private Map<Integer,Integer> allMissionProgress;
|
||||
|
||||
private Set<Integer> hadTakeRewardIds;
|
||||
|
||||
private int totalWeight;
|
||||
|
||||
public int getMapId() {
|
||||
return mapId;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getAllMissionProgress() {
|
||||
return allMissionProgress;
|
||||
}
|
||||
|
||||
public MapMission(){}
|
||||
|
||||
public MapMission(int mapId, Map<Integer, Integer> missionProgress) {
|
||||
this.setRootCollection(User._COLLECTION_NAME);
|
||||
this.mapId = mapId;
|
||||
this.allMissionProgress = missionProgress;
|
||||
this.hadTakeRewardIds = new HashSet<>();
|
||||
}
|
||||
|
||||
|
||||
public void setMapId(int mapId) {
|
||||
this.mapId = mapId;
|
||||
}
|
||||
|
||||
public void setAllMissionProgress(Map<Integer, Integer> allMissionProgress) {
|
||||
updateString("allMissionProgress",allMissionProgress);
|
||||
this.allMissionProgress = allMissionProgress;
|
||||
}
|
||||
|
||||
public Set<Integer> getHadTakeRewardIds() {
|
||||
return hadTakeRewardIds;
|
||||
}
|
||||
|
||||
public void setTotalWeight(int totalWeight) {
|
||||
updateString("totalWeight",totalWeight);
|
||||
this.totalWeight = totalWeight;
|
||||
}
|
||||
|
||||
public int getTotalWeight() {
|
||||
return totalWeight;
|
||||
}
|
||||
|
||||
public void setHadTakeRewardIds(Set<Integer> hadTakeRewardIds) {
|
||||
updateString("hadTakeRewardIds",hadTakeRewardIds);
|
||||
this.hadTakeRewardIds = hadTakeRewardIds;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
public enum MapMissionType {
|
||||
FINISH_EVEVNT(1), //完成事件点
|
||||
KILL_BOSS(2), //击杀boss多少次
|
||||
VICTORY_EVENT(3), //本次地图获得战斗胜利次数
|
||||
BUY_GOODS_ID_EVENT(4), //在本图行脚商人购买某物
|
||||
DIGGER_EVENT(5), //本地图采矿都少次
|
||||
COLLECT_GOODS_ID_EVENT(6), //在收集商人那边兑换出来物品
|
||||
CONSUME_ACTION_POWER_EVENT(7), //在本次地图内消耗多少行动力
|
||||
OPEN_BOX(8), //在本次地图内消耗多少行动力
|
||||
BUY_GOODS_TYPE_EVENT(9); //在本图行脚商人购买某类物品
|
||||
|
||||
private int missionType;
|
||||
|
||||
MapMissionType(int missionType) {
|
||||
this.missionType = missionType;
|
||||
}
|
||||
|
||||
public int getMissionTypeValue() {
|
||||
return missionType;
|
||||
}
|
||||
|
||||
public static MapMissionType getMissionTypeById(int missionId) {
|
||||
MapMissionType[] values = MapMissionType.values();
|
||||
for(MapMissionType missionType : values){
|
||||
if(missionType.getMissionTypeValue() == missionId){
|
||||
return missionType;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TakeMapBoxRewardHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.TAKE_MAP_MISSION_BOX_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
byte[] bytes = netData.parseClientProtoNetData();
|
||||
MapInfoProto.TakeMapBoxRequest takeMapBoxRequest = MapInfoProto.TakeMapBoxRequest.parseFrom(bytes);
|
||||
int boxWeight = takeMapBoxRequest.getBoxWeight();
|
||||
int mapId = takeMapBoxRequest.getMapId();
|
||||
MapLogic.getInstance().takeMissionBoxReward(iSession,mapId,boxWeight);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.db.mongo.MongoKey;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
|
||||
|
@ -13,6 +12,8 @@ public class AdventureManager extends MongoBase {
|
|||
private Map<Integer,AdventureStateInfo> adventureStateInfoMap;
|
||||
private Map<Integer,Integer> allowTimeMap;
|
||||
|
||||
private long updateTime;
|
||||
|
||||
public AdventureManager(){
|
||||
this.setRootCollection(User._COLLECTION_NAME);
|
||||
adventureStateInfoMap = new HashMap<>();
|
||||
|
@ -30,7 +31,7 @@ public class AdventureManager extends MongoBase {
|
|||
public void clearStation(int position){
|
||||
AdventureStateInfo adventureStateInfo = adventureStateInfoMap.get(position);
|
||||
if (adventureStateInfo!=null){
|
||||
removeString("adventureStateInfoMap." + position);
|
||||
removeString(getMongoKey() +".adventureStateInfoMap." + position);
|
||||
adventureStateInfoMap.remove(position);
|
||||
}
|
||||
|
||||
|
@ -49,6 +50,20 @@ public class AdventureManager extends MongoBase {
|
|||
allowTimeMap.put(position,allowTime);
|
||||
}
|
||||
|
||||
public void setUpdateTime(long updateTime) {
|
||||
updateString("updateTime.",updateTime);
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public void setAllowTimeMap(Map<Integer, Integer> allowTimeMap) {
|
||||
updateString("allowTimeMap.",allowTimeMap);
|
||||
this.allowTimeMap = allowTimeMap;
|
||||
}
|
||||
|
||||
public long getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getAllowTimeMap() {
|
||||
return allowTimeMap;
|
||||
}
|
||||
|
|
|
@ -117,6 +117,7 @@ public class CombatLogic {
|
|||
public void getAdventureStateInfo(ISession session) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
flushAdventureTime(user);
|
||||
AdventureManager adventureManager = user.getAdventureManager();
|
||||
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
|
||||
List<CommonProto.AdventureStateInfo> result = new ArrayList<>();
|
||||
|
@ -208,11 +209,33 @@ public class CombatLogic {
|
|||
}
|
||||
|
||||
adventureManager.station(new AdventureStateInfo(position,heroIds,(int)(System.currentTimeMillis()/1000),hourDuration,totalForce,myRecommendHeroSize),allowTime);
|
||||
if(adventureManager.getUpdateTime() == 0){
|
||||
adventureManager.setUpdateTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
//发送成功
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,null,true);
|
||||
}
|
||||
|
||||
private void flushAdventureTime( User user ){
|
||||
AdventureManager adventureManager = user.getAdventureManager();
|
||||
long updateTime = adventureManager.getUpdateTime();
|
||||
if(updateTime ==0 || TimeUtils.isSameDayWithNow(updateTime)){
|
||||
return;
|
||||
}
|
||||
int vipLevel = user.getPlayerInfoManager().getVipLevel();
|
||||
int allowTime = SVipLevelConfig.getsVipLevelConfigMap().get(vipLevel).getPrivilegeMap().get(1);
|
||||
Map<Integer, Integer> allowTimeMap = adventureManager.getAllowTimeMap();
|
||||
if(allowTimeMap!=null && !allowTimeMap.isEmpty()){
|
||||
Map<Integer,Integer> result = new HashMap<>();
|
||||
for(Integer position : allowTimeMap.keySet()){
|
||||
result.put(position,allowTime);
|
||||
}
|
||||
adventureManager.setUpdateTime(System.currentTimeMillis());
|
||||
adventureManager.setAllowTimeMap(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void clearStation(ISession session,int position) throws Exception {
|
||||
int uid = session.getUid();
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.ljsd.jieling.util;
|
|||
import com.ljsd.jieling.config.SGameSetting;
|
||||
import com.ljsd.jieling.config.SMonsterConfig;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.handler.map.MapMission;
|
||||
import com.ljsd.jieling.handler.map.TemporaryItems;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
|
@ -84,9 +85,12 @@ public class CBean2Proto {
|
|||
if(adventureStateInfo!=null){
|
||||
int startTime = adventureStateInfo.getStartTime();
|
||||
int now = (int)(System.currentTimeMillis()/1000);
|
||||
int hourDuration = adventureStateInfo.getHourDuration();
|
||||
int remainTime = startTime + hourDuration*60*60 - now;
|
||||
remainTime = remainTime<0?0:remainTime;
|
||||
builder.addAllHeroIdList(adventureStateInfo.getHeroIds())
|
||||
.setHourDuration(adventureStateInfo.getHourDuration())
|
||||
.setRemainTime((now - startTime ));
|
||||
.setHourDuration(hourDuration)
|
||||
.setRemainTime(remainTime);
|
||||
}
|
||||
return builder.build();
|
||||
|
||||
|
@ -187,4 +191,20 @@ public class CBean2Proto {
|
|||
monsterBuilder.setUnitId(String.valueOf(sMonsterConfig.getId()));
|
||||
return monsterBuilder.build();
|
||||
}
|
||||
|
||||
public static CommonProto.MapAccomplishInfo getMapAccomplishInfo(MapMission mapMission){
|
||||
int totalWeight = mapMission.getTotalWeight();
|
||||
Map<Integer, Integer> allMissionProgress = mapMission.getAllMissionProgress();
|
||||
List<CommonProto.ExploreDetail> exploreDetailList = new ArrayList<>();
|
||||
for(Map.Entry<Integer,Integer> missionItem : allMissionProgress.entrySet()){
|
||||
exploreDetailList.add(CommonProto.ExploreDetail.newBuilder().setId(missionItem.getKey())
|
||||
.setProgress(missionItem.getValue())
|
||||
.build());
|
||||
}
|
||||
int mapId = mapMission.getMapId();
|
||||
return CommonProto.MapAccomplishInfo.newBuilder() .setMapId(mapId)
|
||||
.addAllExploreDetail(exploreDetailList)
|
||||
.setTotalWeight(totalWeight)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue