Merge branch 'master' of 60.1.1.230:backend/jieling_server

back_recharge
wangyuan 2019-01-22 09:55:06 +08:00
commit ee902be8ea
7 changed files with 108 additions and 31 deletions

View File

@ -20,8 +20,8 @@ public class SCMapEventsItemConfig implements BaseConfig{
private int eventsId; private int eventsId;
/** /**
* *
* */ */
private int sort; private int order;
/** /**
* *
*/ */
@ -31,6 +31,16 @@ public class SCMapEventsItemConfig implements BaseConfig{
*/ */
private String reward; private String reward;
/**
*
*/
private String jump;
/**
*
*/
private String openRules;
@Override @Override
public void init() throws Exception { public void init() throws Exception {
scMapEventsItemConfigMap = STableManager.getConfig(SCMapEventsItemConfig.class); scMapEventsItemConfigMap = STableManager.getConfig(SCMapEventsItemConfig.class);
@ -39,7 +49,7 @@ public class SCMapEventsItemConfig implements BaseConfig{
if (!scMapEventsItemConfigs.containsKey(eventsItemConfigEntry.getEventId())) { if (!scMapEventsItemConfigs.containsKey(eventsItemConfigEntry.getEventId())) {
scMapEventsItemConfigs.put(eventsItemConfigEntry.getEventId(), new HashMap<>()); scMapEventsItemConfigs.put(eventsItemConfigEntry.getEventId(), new HashMap<>());
} }
scMapEventsItemConfigs.get(eventsItemConfigEntry.getEventId()).put(eventsItemConfigEntry.getSort(), eventsItemConfigEntry); scMapEventsItemConfigs.get(eventsItemConfigEntry.getEventId()).put(eventsItemConfigEntry.getOrder(), eventsItemConfigEntry);
} }
} }
@ -51,10 +61,6 @@ public class SCMapEventsItemConfig implements BaseConfig{
return eventsId; return eventsId;
} }
public int getSort() {
return sort;
}
public String getContents() { public String getContents() {
return contents; return contents;
} }
@ -62,4 +68,20 @@ public class SCMapEventsItemConfig implements BaseConfig{
public String getReward() { public String getReward() {
return reward; return reward;
} }
public int getEventsId() {
return eventsId;
}
public int getOrder() {
return order;
}
public String getJump() {
return jump;
}
public String getOpenRules() {
return openRules;
}
} }

View File

@ -8,12 +8,21 @@ public class RedisKey {
public static final String TOKEN = "JL_TOKEN"; public static final String TOKEN = "JL_TOKEN";
public static final String UNDERLINE_LINE = "_";
/** /**
* *
*/ */
public static final String USER_SERVER_INFO = "JL_USER_SERVER_INFO"; public static final String USER_SERVER_INFO = "JL_USER_SERVER_INFO";
/**
*
*/
public static final String FIGHT = "FIGHT";
/**
*
*/
public static final int EXPIRE_TIME = 3600 * 24;
public static String getKey(String type, String key, boolean withServerId) { public static String getKey(String type, String key, boolean withServerId) {

View File

@ -113,6 +113,12 @@ public class RedisUtil {
return key == null ? null : redisTemplate.opsForValue().get(key); return key == null ? null : redisTemplate.opsForValue().get(key);
} }
public String getAndDelete(String key) {
String value = redisTemplate.opsForValue().get(key);
del(key);
return value;
}
/** /**
* *
* *

View File

@ -0,0 +1,18 @@
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;
public class MapFightEndRequestHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.FIGHT_END_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
}
}

View File

@ -3,6 +3,8 @@ package com.ljsd.jieling.handler.map;
import com.ljsd.jieling.config.SCMap; import com.ljsd.jieling.config.SCMap;
import com.ljsd.jieling.config.SCMapEventsConfig; import com.ljsd.jieling.config.SCMapEventsConfig;
import com.ljsd.jieling.config.SCMapEventsItemConfig; import com.ljsd.jieling.config.SCMapEventsItemConfig;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.logic.dao.MapManager; import com.ljsd.jieling.logic.dao.MapManager;
import com.ljsd.jieling.logic.dao.User; import com.ljsd.jieling.logic.dao.User;
import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.logic.dao.UserManager;
@ -11,8 +13,8 @@ import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.MapInfoProto; import com.ljsd.jieling.protocols.MapInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto; import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.CellUtil; import com.ljsd.jieling.util.CellUtil;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil; import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.ToolsUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -123,28 +125,33 @@ public class MapLogic {
/** /**
* *
*/ */
public void fightStart(ISession session, int bigEventId){ public void fightStart(int uid, int bigEventId){
String key = RedisKey.getKey(RedisKey.FIGHT, Integer.toString(uid) + RedisKey.UNDERLINE_LINE + Integer.toString(bigEventId), false);
RedisUtil.getInstence().set(key, Integer.toString(uid), RedisKey.EXPIRE_TIME);
} }
/** /**
* *
*/ */
public void fightEnd(ISession session, int bigEventId){ public void fightEnd(int uid) {
String key = RedisKey.getKey(RedisKey.FIGHT, Integer.toString(uid), false);
String fightInfo = RedisUtil.getInstence().getAndDelete(key);
if (fightInfo == null || fightInfo.isEmpty()) {
return;
}
} }
/** /**
* 使buff * 使buff
*/ */
public void useItem(ISession session, int bigEventId){ public void useItem(int uid){
} }
/** /**
* *
*/ */
public void leave(ISession session, int bigEventId){ public void leave(int uid){
} }
@ -157,7 +164,7 @@ public class MapLogic {
* @param session * @param session
* @param xy * @param xy
*/ */
public void updateEvent(ISession session, int xy, int bigEventId, int choice, List<Integer> cells) throws Exception { public void updateEvent(ISession session, int xy, int bigEventId, int choice, List<Integer> cells, MessageTypeProto.MessageType messageType) throws Exception {
Set<Integer> cellSet = new HashSet<>(cells); Set<Integer> cellSet = new HashSet<>(cells);
if (cells.size() != cellSet.size()) { if (cells.size() != cellSet.size()) {
LOGGER.info("cells has repeated"); LOGGER.info("cells has repeated");
@ -200,16 +207,19 @@ public class MapLogic {
String[] eventArr = contents[choice].split("#"); String[] eventArr = contents[choice].split("#");
switch (Integer.parseInt(eventArr[0])) { switch (Integer.parseInt(eventArr[0])) {
case EventType.fight: { case EventType.fight: {
fightStart(session, bigEventId); fightStart(uid, bigEventId);
break; break;
} }
case EventType.attribute: { case EventType.attribute: {
break; break;
} }
case EventType.eatBuff:
case EventType.useItem: case EventType.useItem:
case EventType.scout: { case EventType.scout: {
Map<Integer, Integer> useItems = new HashMap<>();
useItems.put(Integer.parseInt(eventArr[1]), Integer.parseInt(eventArr[2]));
ItemUtil.useItem(user, useItems);
break; break;
} }
case EventType.leave: { case EventType.leave: {
@ -224,20 +234,27 @@ public class MapLogic {
break; break;
} }
case EventType.eatBuff: {
break;
}
default: { default: {
return; return;
} }
} }
if (schedule + 1 >= contents.length - 1) { if (scMapEventsItemConfig.getJump() == null || scMapEventsItemConfig.getJump().isEmpty()) {
cell.getEventIds().put(bigEventId, -1);
} else {
cell.getEventIds().put(bigEventId, schedule + 1); cell.getEventIds().put(bigEventId, schedule + 1);
} else {
String[] jumps = scMapEventsItemConfig.getJump().split("\\|");
for (int i = 0; i < jumps.length; i++) {
String[] jump = jumps[i].split("#");
if (Integer.parseInt(jump[0]) == choice - 1) {
cell.getEventIds().put(bigEventId, Integer.parseInt(jump[1]));
break;
}
}
}
String reward = scMapEventsItemConfig.getReward();
if (reward != null && !reward.isEmpty()) {
Map<Integer, Integer> itemMap = new HashMap<>();
// ItemUtil.addItem(user, itemMap);
} }
// 如果是传送门开启跳转到下个关卡 // 如果是传送门开启跳转到下个关卡
// if (scMapEvent.getStyle() == EventType.exit) { // if (scMapEvent.getStyle() == EventType.exit) {
// Map<Integer, List<Integer>> crossMapInfos = cMap.getCrossMapInfos(); // Map<Integer, List<Integer>> crossMapInfos = cMap.getCrossMapInfos();

View File

@ -3,18 +3,21 @@ package com.ljsd.jieling.handler.map;
import com.ljsd.jieling.handler.BaseHandler; import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.netty.cocdex.PacketNetData; import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MapInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto; import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
//@Component @Component
public class MapUpdateEventRequestHandler extends BaseHandler { public class MapUpdateEventRequestHandler extends BaseHandler {
@Override @Override
public MessageTypeProto.MessageType getMessageCode() { public MessageTypeProto.MessageType getMessageCode() {
return null; return MessageTypeProto.MessageType.MAP_UDPATE_EVENT_REQUEST;
} }
@Override @Override
public void process(ISession iSession, PacketNetData netData) throws Exception { public void process(ISession iSession, PacketNetData netData) throws Exception {
byte[] message = netData.parseClientProtoNetData();
MapInfoProto.MapUpdateEventRequest mapEnterRequest = MapInfoProto.MapUpdateEventRequest.parseFrom(message);
MapLogic.getInstance().updateEvent(iSession, mapEnterRequest.getCurXY(), mapEnterRequest.getBigEventId(), mapEnterRequest.getChoice(), mapEnterRequest.getCellsList(), MessageTypeProto.MessageType.MAP_UDPATE_EVENT_RESPONSE);
} }
} }

View File

@ -16,9 +16,11 @@ public class MapManager extends MongoBase {
private int curXY; private int curXY;
private Map<Integer, Cell> mapInfo = new ConcurrentHashMap<>(); private Map<String, Integer> heroHps;
private Map<Integer, Cell> typeEight = new ConcurrentHashMap<>(); private Map<Integer, Cell> mapInfo;
private Map<Integer, Cell> typeEight;
private Map<Integer, List<Integer>> crossMapInfos = new ConcurrentHashMap<>(); private Map<Integer, List<Integer>> crossMapInfos = new ConcurrentHashMap<>();