back_recharge
parent
96c9a573b8
commit
5fa0f5b0f4
|
@ -57,7 +57,10 @@ public class MongoUpdateCache {
|
|||
valueDBObj.append(request.fullKey, ljsdMongoTemplate.convertToMongoType(request.value));
|
||||
request.mongoBase.set_save(false);
|
||||
}
|
||||
dbobj.append("$set", valueDBObj);
|
||||
if (!valueDBObj.isEmpty()) {
|
||||
dbobj.append("$set", valueDBObj);
|
||||
}
|
||||
|
||||
if (!removedbobj.isEmpty()) {
|
||||
dbobj.append("$unset", removedbobj);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class SCHero implements BaseConfig{
|
|||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
sCHero = STableManager.getConfig(SCHero.class);
|
||||
// sCHero = STableManager.getConfig(SCHero.class);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.ljsd.jieling.logic.Table;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name = "1.Map")
|
||||
@Table(name = "Map")
|
||||
public class SCMap implements BaseConfig {
|
||||
public static Map<Integer, Map<Integer, SCMap>> sCMap;
|
||||
private int id;
|
||||
|
|
|
@ -3,16 +3,17 @@ package com.ljsd.jieling.handler.map;
|
|||
public class EventType {
|
||||
/**
|
||||
* 大事件点类型
|
||||
* 1怪物 2矿 3出生点 4出口 5连续事件 6行脚商人 7宝箱 8阻挡点
|
||||
* 1怪物 2矿 3传送门 4连续事件 5行脚商人 6宝箱 7阻挡点 8事件区域全部出事件
|
||||
*/
|
||||
public static final int enter = 0;
|
||||
public static final int monster = 1;
|
||||
public static final int mine = 2;
|
||||
public static final int enter = 3;
|
||||
public static final int exit = 4;
|
||||
public static final int continuity = 5;
|
||||
public static final int businessman = 6;
|
||||
public static final int box = 7;
|
||||
public static final int obstacle = 8;
|
||||
public static final int portal = 3;
|
||||
public static final int continuity = 4;
|
||||
public static final int businessman = 5;
|
||||
public static final int box = 6;
|
||||
public static final int hinder = 7;
|
||||
public static final int allEvents = 8;
|
||||
|
||||
/**
|
||||
* 小事件类型
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.config.SCMap;
|
||||
import com.ljsd.jieling.config.SCMapEventsItemConfig;
|
||||
import com.ljsd.jieling.logic.dao.MapManager;
|
||||
import com.ljsd.jieling.logic.dao.User;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
|
@ -20,7 +22,9 @@ public class MapLogic {
|
|||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MapLogic.class);
|
||||
|
||||
private MapLogic(){}
|
||||
private MapLogic() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单例
|
||||
*
|
||||
|
@ -36,42 +40,63 @@ public class MapLogic {
|
|||
|
||||
/**
|
||||
* 进地图
|
||||
*
|
||||
* @param mapId
|
||||
*/
|
||||
public void enterMap(ISession iSession, int mapId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
public void enterMap(ISession iSession, int mapId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
if (mapManager.getCurMapId() == 0) {
|
||||
mapManager = initMap( 1);
|
||||
user.getPlayerInfoManager().setMapId(101);
|
||||
mapManager.setCurMapId(101);
|
||||
initMap(mapManager);
|
||||
user.setMapManager(mapManager);
|
||||
} else {
|
||||
if (mapId > mapManager.getCurMapId()) {
|
||||
mapManager = initMap(mapManager.getCurMapId());
|
||||
} else {
|
||||
mapManager = initMap(mapId);
|
||||
if (mapManager == null) {
|
||||
return;
|
||||
}
|
||||
Map<Integer, SCMap> scMap = SCMap.sCMap.get(mapId);
|
||||
if (scMap == null) {
|
||||
return;
|
||||
}
|
||||
if (mapId > mapManager.getCurMapId()) {
|
||||
return;
|
||||
}
|
||||
if (mapId != mapManager.getCurMapId()) {
|
||||
initMap(mapManager);
|
||||
user.setMapManager(mapManager);
|
||||
}
|
||||
user.setMapManager(mapManager);
|
||||
}
|
||||
MapInfoProto.MapInfo.MapEnterResponse mapEnterResponse = MapInfoProto.MapInfo.MapEnterResponse
|
||||
List<CommonProto.Common.Cell> cells = new ArrayList<>(mapManager.getMapInfo().size());
|
||||
for (Map.Entry<Integer, Cell> entry : mapManager.getMapInfo().entrySet()) {
|
||||
List<CommonProto.Common.CellEvent> cellEvents = new ArrayList<>();
|
||||
Cell cell = entry.getValue();
|
||||
for (Map.Entry<Integer, Integer> cellEntry : cell.getEventIds().entrySet()) {
|
||||
CommonProto.Common.CellEvent cellEvent = CommonProto.Common.CellEvent
|
||||
.newBuilder()
|
||||
.setEventId(cellEntry.getKey())
|
||||
.setState(cellEntry.getValue())
|
||||
.build();
|
||||
cellEvents.add(cellEvent);
|
||||
}
|
||||
CommonProto.Common.Cell cellProto = CommonProto.Common.Cell
|
||||
.newBuilder()
|
||||
.setCellId(entry.getKey())
|
||||
.addAllCellEvents(cellEvents)
|
||||
.build();
|
||||
cells.add(cellProto);
|
||||
}
|
||||
MapInfoProto.MapInfo.MapEnterResponse mapEnterResponse = MapInfoProto.MapInfo.MapEnterResponse
|
||||
.newBuilder()
|
||||
.addAllMapList(cells)
|
||||
.setCurXY(mapManager.getCurXY())
|
||||
.build();
|
||||
MessageUtil.sendMessage(iSession, 1, messageType.getNumber(), mapEnterResponse, true);
|
||||
}
|
||||
|
||||
|
||||
private MapManager initMap(int mapId) throws Exception {
|
||||
Map<Integer, SCMap> scMap = SCMap.sCMap.get(mapId);
|
||||
if (scMap == null) {
|
||||
return null;
|
||||
}
|
||||
MapManager mapManager = new MapManager();
|
||||
mapManager.setCurMapId(mapId);
|
||||
Map<Integer, Cell> mapInfo = mapManager.getMapInfo();
|
||||
mapInfo.clear();
|
||||
private void initMap(MapManager mapManager) throws Exception {
|
||||
Map<Integer, SCMap> scMap = SCMap.sCMap.get(mapManager.getCurMapId());
|
||||
Map<Integer, Cell> newMap = new HashMap<>();
|
||||
Map<Integer, Cell> spicelMap = new HashMap<>();
|
||||
Random random = new Random();
|
||||
for (Map.Entry<Integer, SCMap> entry : scMap.entrySet()) {
|
||||
SCMap scMap1 = entry.getValue();
|
||||
|
@ -85,18 +110,24 @@ public class MapLogic {
|
|||
if (scMapEvent.getStyle() == EventType.enter) {
|
||||
mapManager.setCurXY(xy);
|
||||
}
|
||||
mapInfo.put(xy, cellValue);
|
||||
if (scMapEvent.getStyle() == EventType.allEvents) {
|
||||
spicelMap.put(xy, cellValue);
|
||||
} else {
|
||||
newMap.put(xy, cellValue);
|
||||
}
|
||||
}
|
||||
return mapManager;
|
||||
mapManager.setMapInfo(newMap);
|
||||
mapManager.setTypeEight(spicelMap);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新事件点
|
||||
*
|
||||
* @param uid
|
||||
* @param xy
|
||||
*/
|
||||
public void updateEvent(int uid, int xy, int bigEventId, int smallEventId, int choice) throws Exception {
|
||||
public void updateEvent(int uid, int xy, int bigEventId, int smallEventId, int choice) throws Exception {
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
Cell cell = mapManager.getMapInfo().get(xy);
|
||||
|
@ -122,57 +153,58 @@ public class MapLogic {
|
|||
SCMapEventsConfig scMapEvent = SCMapEventsConfig.scMapEventMap.get(bigEventId);
|
||||
SCMapEventsItemConfig scMapEventsItemConfig = SCMapEventsItemConfig.scMapEventsItemConfigs.get(bigEventId).get(smallEventId);
|
||||
if (scMapEventsItemConfig == null) {
|
||||
LOGGER.info("no scMapEventsItemConfig bigEventId=>{} smallEventId=>{}",bigEventId, smallEventId);
|
||||
LOGGER.info("no scMapEventsItemConfig bigEventId=>{} smallEventId=>{}", bigEventId, smallEventId);
|
||||
return;
|
||||
}
|
||||
String[] contents = scMapEventsItemConfig.getContents().split("\\|");
|
||||
if (choice < contents.length - 1 || contents.length - 1 < choice) {
|
||||
LOGGER.info("no this choice =>{} scMapEventsItemConfig.getContents()=>{}",choice, scMapEventsItemConfig.getContents());
|
||||
LOGGER.info("no this choice =>{} scMapEventsItemConfig.getContents()=>{}", choice, scMapEventsItemConfig.getContents());
|
||||
return;
|
||||
}
|
||||
String[] eventArr = contents[choice].split("#");
|
||||
switch (scMapEvent.getStyle()) {
|
||||
case EventType.monster:{
|
||||
case EventType.monster: {
|
||||
break;
|
||||
}
|
||||
case EventType.continuity:{
|
||||
case EventType.continuity: {
|
||||
switch (Integer.parseInt(eventArr[0])) {
|
||||
case EventType.fight:{
|
||||
case EventType.fight: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.attribute:{
|
||||
case EventType.attribute: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.useItem:
|
||||
case EventType.scout:{
|
||||
case EventType.scout: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.leave:{
|
||||
case EventType.leave: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.dialogue:{
|
||||
case EventType.dialogue: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.jump:{
|
||||
case EventType.jump: {
|
||||
|
||||
break;
|
||||
}
|
||||
case EventType.eatBuff:{
|
||||
case EventType.eatBuff: {
|
||||
|
||||
break;
|
||||
} default:{
|
||||
}
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (smallEventId + 1 >= contents.length - 1){
|
||||
if (smallEventId + 1 >= contents.length - 1) {
|
||||
cell.getEventIds().put(bigEventId, -1);
|
||||
} else {
|
||||
cell.getEventIds().put(bigEventId, schedule + 1);
|
||||
|
@ -186,8 +218,8 @@ public class MapLogic {
|
|||
// }
|
||||
// crossMapInfos.get(cMap.getCurMapId()).addAll(cell.getEventIds());
|
||||
// }
|
||||
if (scMapEvent.getStyle() == EventType.exit) {
|
||||
initMap(mapManager.getCurMapId() + 1);
|
||||
if (scMapEvent.getStyle() == EventType.portal) {
|
||||
user.getPlayerInfoManager().setMapId(user.getPlayerInfoManager().getMapId() + 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ import com.ljsd.jieling.network.session.ISession;
|
|||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
//@Component
|
||||
public class MapUpdateEventRequestHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.MAP_ENTER_REQUEST;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -159,7 +159,7 @@ public class STableManager {
|
|||
lineNum++;
|
||||
}
|
||||
map.put(i, mapConf);
|
||||
tableName = tableName.substring(0, 5);
|
||||
tableName = tableName.substring(0, 3);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ public class MapManager extends MongoBase {
|
|||
|
||||
private Map<Integer, Cell> mapInfo = new ConcurrentHashMap<>();
|
||||
|
||||
private Map<Integer, Cell> typeEight = new ConcurrentHashMap<>();
|
||||
|
||||
private Map<Integer, List<Integer>> crossMapInfos = new ConcurrentHashMap<>();
|
||||
|
||||
public Map<Integer, Cell> getMapInfo() {
|
||||
|
@ -33,7 +35,7 @@ public class MapManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void setCurMapId(int curMapId) throws Exception {
|
||||
updateString("curMapId", curXY);
|
||||
updateString("curMapId", curMapId);
|
||||
this.curMapId = curMapId;
|
||||
}
|
||||
|
||||
|
@ -47,13 +49,26 @@ public class MapManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void addOrUpdateCell(int key, Cell cell) throws Exception {
|
||||
updateString(getMongoKey() + ".mapInfo." + key, mapInfo);
|
||||
updateString( "mapInfo." + key, cell);
|
||||
this.mapInfo.put(key, cell);
|
||||
}
|
||||
|
||||
public void removeCell(int key) {
|
||||
removeString(getMongoKey() + ".mapInfo." + key);
|
||||
this.mapInfo.remove(key);
|
||||
public void setMapInfo(Map<Integer, Cell> mapInfo) throws Exception {
|
||||
updateString( "mapInfo", mapInfo);
|
||||
this.mapInfo = mapInfo;
|
||||
}
|
||||
|
||||
public void removeAllCell() {
|
||||
removeString("mapInfo");
|
||||
this.mapInfo.clear();
|
||||
}
|
||||
|
||||
public Map<Integer, Cell> getTypeEight() {
|
||||
return typeEight;
|
||||
}
|
||||
|
||||
public void setTypeEight(Map<Integer, Cell> typeEight) throws Exception {
|
||||
updateString( "typeEight", typeEight);
|
||||
this.typeEight = typeEight;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ public class PlayerManager extends MongoBase {
|
|||
|
||||
private int chargeGem;
|
||||
|
||||
private int mapId;
|
||||
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
|
@ -104,4 +106,13 @@ public class PlayerManager extends MongoBase {
|
|||
updateString("chargeGem", chargeGem);
|
||||
this.chargeGem = chargeGem;
|
||||
}
|
||||
|
||||
public int getMapId() {
|
||||
return mapId;
|
||||
}
|
||||
|
||||
public void setMapId(int mapId) throws Exception {
|
||||
updateString("mapId", mapId);
|
||||
this.mapId = mapId;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue