Merge branch 'master' of 60.1.1.230:backend/jieling_server

back_recharge
wangyuan 2019-03-29 15:48:11 +08:00
commit 45ccd2f782
8 changed files with 81 additions and 13 deletions

View File

@ -66,6 +66,12 @@ public class RedisKey {
*/
public static final String NEED_DESORY_XY = "NEED_DESORY_XY";
/**
* eventId
* sub_key
*/
public static final String NEXT_EVENT_ID = "NEXT_EVENT_ID";
/**
*
*/

View File

@ -5,4 +5,5 @@ public interface GlobalGm {
int ADD_CARD = 2; //添加卡牌
int SEND_MAIIL = 3;// 发送邮件
int HERO_STAR = 4;// 添加指定星级英雄
int OPEN_MAP = 5; // 开启到指定关卡
}

View File

@ -2,6 +2,7 @@ package com.ljsd.jieling.handler.GameGM;
import com.ljsd.jieling.config.SCHero;
import com.ljsd.jieling.config.SCHeroRankUpConfig;
import com.ljsd.jieling.config.SCMapConfig;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.globals.Global;
@ -48,7 +49,7 @@ public class GMRequestHandler extends BaseHandler{
int prarm1 = 0, prarm2 = 0;
if (gmCommandType == 0){
prarm1 = Integer.parseInt(commandArray[1]);
}else if (gmCommandType == 1 || gmCommandType ==2 || gmCommandType ==3 || gmCommandType ==4){
}else {
prarm1 = Integer.parseInt(commandArray[1]);
prarm2 = Integer.parseInt(commandArray[2]);
}
@ -80,9 +81,21 @@ public class GMRequestHandler extends BaseHandler{
hero.setLevel(scHeroRankUpConfig.getLimitLevel());
hero.setBreakId(scHeroRankUpConfig.getId());
}
break;
case GlobalGm.OPEN_MAP:
SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(100 + prarm1);
if (scMapConfig != null) {
for (int i = 0; i <= prarm1; i++) {
int mapId = 100 + prarm1;
SCMapConfig crossMap = SCMapConfig.getsCMapSize().get(mapId);
cUser.getPlayerInfoManager().setMapId(mapId);
if (crossMap.getOpenRule() != null && crossMap.getOpenRule().length > 0) {
cUser.getMissionManager().getFinishMissions().add(crossMap.getOpenRule()[0]);
}
}
}
// giveItem(cUser,prarm1,prarm2);
break;
default:
break;
}

View File

@ -212,6 +212,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) {
for (int i = 0; i < scMap1.getGroups().length; i++) {
int x = scMap1.getGroups()[i][0];
@ -223,6 +224,7 @@ public class MapLogic {
}
continue;
}
// 随机出现的事件点
int randomIndex = random.nextInt(scMap1.getGroups().length);
int x = scMap1.getGroups()[randomIndex][0];
int y = scMap1.getGroups()[randomIndex][1];
@ -233,6 +235,7 @@ public class MapLogic {
continue;
}
int initialEventId = mapPointConfig.getInitialEventId();
// 每天刷新的事件点
if (crossMapCell != null && crossMapCell.getDayRefreshs().containsKey(mapPointConfig.getId())) {
int eventId = crossMapCell.getDayRefreshs().get(mapPointConfig.getId());
if (eventId == -1) {
@ -241,6 +244,7 @@ public class MapLogic {
initialEventId = eventId;
}
}
// 一次性事件点
if (crossMapCell != null && crossMapCell.getPermanents().containsKey(mapPointConfig.getId())) {
int eventId = crossMapCell.getPermanents().get(mapPointConfig.getId());
if (eventId == -1) {
@ -249,6 +253,7 @@ public class MapLogic {
initialEventId = eventId;
}
}
// 任务触发的事件点
for (Mission mission : missions) {
if (mission.getMapPoints().containsKey(mapPointConfig.getId())) {
for (Map.Entry<Integer, Cell> missionEntry : mission.getMissionInfos().entrySet()) {
@ -256,7 +261,6 @@ public class MapLogic {
}
Cell cellValue = new Cell(xy, mission.getMapPoints().get(mapPointConfig.getId()), mapPointConfig.getId());
newMap.put(xy, cellValue);
break;
}
}
Cell cellValue = new Cell(xy, initialEventId, mapPointConfig.getId());
@ -512,8 +516,12 @@ public class MapLogic {
cell = mapManager.getMapInfo().get(mapManager.getCurXY());
}
// 战斗事件处理需要放到战斗胜利
if (behaviorType == EventType.fight || behaviorType == EventType.fightAndDestroyPoint ) {
BehaviorUtil.addFightReady(user.getId(), nextEventId);
}
// 检测该事件点是否已被销毁
if (cell != null && nextEventId != 0) {
else if (cell != null && nextEventId != 0) {
cell.setEventId(nextEventId);
mapManager.addOrUpdateCell(mapManager.getCurXY(), cell);
}
@ -549,8 +557,8 @@ public class MapLogic {
if (dropBuilder != null) {
eventUpdateResponse.setDrop(dropBuilder);
}
LOGGER.info("updateEvent =====>success<====== xy=>{}, getPointId=>{} eventId={}, mission=>{}, nextEventId=>{}, eventBehaviorCommon=>{} {} sOptionConfig.getReward()=>{}", mapManager.getCurXY(), cell == null ? 0 : cell.getPointId(),
cell == null ? 0 : cell.getEventId(), eventUpdateResponse.getMissionList(), nextEventId, eventBehaviorCommon,eventUpdateResponse.getDrop(), sOptionConfig.getReward());
// LOGGER.info("updateEvent =====>success<====== xy=>{}, getPointId=>{} eventId={}, mission=>{}, nextEventId=>{}, eventBehaviorCommon=>{} {} sOptionConfig.getReward()=>{}", mapManager.getCurXY(), cell == null ? 0 : cell.getPointId(),
// cell == null ? 0 : cell.getEventId(), eventUpdateResponse.getMissionList(), nextEventId, eventBehaviorCommon,eventUpdateResponse.getDrop(), sOptionConfig.getReward());
saveRefreshInfo(pointId, mapManager, mapPointConfig, nextEventId);
updateMapMission(mapManager,EventType.updateEvent,cell == null ? 0 : cell.getEventId(),0);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), eventUpdateResponse.build(), true);
@ -796,7 +804,7 @@ public class MapLogic {
String fightReadyKey = RedisKey.getKey(RedisKey.FIGHT_READY, Integer.toString(uid), false);
String fightReady = (String) RedisUtil.getInstence().get(fightReadyKey);
int groupId, destoryXY = 0;
String missionId = "0", destroyId = "0";
String missionId = "0", destroyId = "0", nextEventId = "0";
if (fightReady != null) {
String[] split = fightReady.split("#");
RedisUtil.getInstence().del(fightReadyKey);
@ -807,6 +815,9 @@ public class MapLogic {
if (split.length > 2) {
destroyId = split[2];
}
if (split.length > 3) {
nextEventId = split[3];
}
} else {
int[] option = sEventPointConfig.getOption();
if (option == null) {
@ -818,7 +829,7 @@ public class MapLogic {
destoryXY = mapManager.getTriggerXY();
}
FightInfoProto.FightStartResponse.Builder fightStartResponse = FightInfoProto.FightStartResponse.newBuilder();
BehaviorUtil.getFightInfo(user, groupId, fightStartResponse, missionId, destroyId, destoryXY);
BehaviorUtil.getFightInfo(user, groupId, fightStartResponse, missionId, destroyId, destoryXY, nextEventId);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightStartResponse.build(), true);
}
@ -904,6 +915,7 @@ public class MapLogic {
int missionId = Integer.parseInt((String)valueMap.get(RedisKey.NEED_MISSION_ID));
int destoryId = Integer.parseInt((String)valueMap.get(RedisKey.NEED_DESORY_ID));
int destoryXY = Integer.parseInt((String)valueMap.get(RedisKey.NEED_DESORY_XY));
int nextEventId = Integer.parseInt((String)valueMap.get(RedisKey.NEXT_EVENT_ID));
if (missionId != 0) {
MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse = MapInfoProto.EventUpdateResponse.newBuilder();
BehaviorUtil.updateMission(user, missionId, eventUpdateResponse);
@ -915,8 +927,16 @@ public class MapLogic {
if (destoryXY != 0) {
BehaviorUtil.distoryApointXY(user, destoryXY);
}
if (nextEventId != 0) {
int triggerXY = user.getMapManager().getTriggerXY();
Cell cell = user.getMapManager().getMapInfo().get(triggerXY);
if (cell != null) {
cell.setEventId(nextEventId);
user.getMapManager().addOrUpdateCell(triggerXY, cell);
}
}
updateMapMission(user.getMapManager(),EventType.fightEvent,0,monsterGroupId);
LOGGER.info("endFight() uid=>{} sMonsterGroup.getRewardgroup()=>{} drop=>{}", uid, sMonsterGroup.getRewardgroup(), fightEndResponse.getDrop());
// LOGGER.info("endFight() uid=>{} sMonsterGroup.getRewardgroup()=>{} drop=>{}", uid, sMonsterGroup.getRewardgroup(), fightEndResponse.getDrop());
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true);
}

View File

@ -2,9 +2,12 @@ package com.ljsd.jieling.handler.map.behavior;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.protocols.MapInfoProto;
import org.slf4j.LoggerFactory;
public abstract class BaseBehavior {
protected static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(BaseBehavior.class);
public abstract int getBehaviorType();
public abstract boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception;

View File

@ -87,6 +87,13 @@ public class BehaviorUtil {
RedisUtil.getInstence().set(key, readyInfo, RedisKey.EXPIRE_TIME);
}
public static void addFightReady(String uid, int nextEventId) {
String key = RedisKey.getKey(RedisKey.FIGHT_READY, uid, false);
String readyInfo = (String) RedisUtil.getInstence().get(key);
readyInfo = readyInfo + "#" + nextEventId;
RedisUtil.getInstence().set(key, readyInfo, RedisKey.EXPIRE_TIME);
}
/**
*
* @param user
@ -94,7 +101,8 @@ public class BehaviorUtil {
* @param fightStartRespons
* @throws Exception
*/
public static void getFightInfo(User user, int groupId, FightInfoProto.FightStartResponse.Builder fightStartRespons, String missionId, String destoryId, int destoryXY) throws Exception {
public static void getFightInfo(User user, int groupId, FightInfoProto.FightStartResponse.Builder fightStartRespons, String missionId,
String destoryId, int destoryXY, String nextEventId) throws Exception {
MapManager mapManager = user.getMapManager();
int teamId = mapManager.getTeamId();
@ -153,6 +161,7 @@ public class BehaviorUtil {
fightInfo.put(RedisKey.NEED_MISSION_ID, missionId);
fightInfo.put(RedisKey.NEED_DESORY_ID, destoryId);
fightInfo.put(RedisKey.NEED_DESORY_XY, Integer.toString(destoryXY));
fightInfo.put(RedisKey.NEXT_EVENT_ID, nextEventId);
RedisUtil.getInstence().hmset(key, fightInfo, RedisKey.EXPIRE_TIME);

View File

@ -14,7 +14,8 @@ public class FightBehavior extends BaseBehavior {
@Override
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
BehaviorUtil.fightReady(user.getId(), Integer.toString(behaviorTypeValues[0][0]));
String readyInfo = Integer.toString(behaviorTypeValues[0][0]) + "#" + 0 + "#" + 0;
BehaviorUtil.fightReady(user.getId(), readyInfo);
return true;
}
}

View File

@ -2,12 +2,16 @@ package com.ljsd.jieling.handler.map.behavior;
import com.ljsd.jieling.config.MapPointConfig;
import com.ljsd.jieling.handler.map.Cell;
import com.ljsd.jieling.handler.map.CrossMapCell;
import com.ljsd.jieling.handler.map.EventType;
import com.ljsd.jieling.handler.mission.Mission;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.protocols.MapInfoProto;
import com.ljsd.jieling.util.CellUtil;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class MonitorMissionAndDestroyPointBehavior extends BaseBehavior {
@Override
@ -21,7 +25,9 @@ public class MonitorMissionAndDestroyPointBehavior extends BaseBehavior {
BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse);
// 销毁事件点
BehaviorUtil.distoryPoint(user, behaviorTypeValues[0][1]);
// 开新事件
// 开新事件 新事件需要和任务绑定
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
Mission mission = doingMissions.get(behaviorTypeValues[0][0]);
if (user.getMapManager().getCurMapId() == behaviorTypeValues[1][0]) {
for (int i = 1; i < behaviorTypeValues.length; i++) {
int x = behaviorTypeValues[i][1];
@ -30,6 +36,15 @@ public class MonitorMissionAndDestroyPointBehavior extends BaseBehavior {
MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(behaviorTypeValues[i][3]);
Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
user.getMapManager().addOrUpdateCell(xy, cellValue);
if (mission != null) {
mission.updateMissionInfos(xy, cellValue);
mission.updateMapPoints(cellValue.getPointId(), cellValue.getEventId());
CrossMapCell crossMapCell = user.getMapManager().getCrossMapInfos().get(user.getMapManager().getCurMapId());
if (crossMapCell == null) {
crossMapCell = new CrossMapCell();
}
crossMapCell.getMissionIds().add(behaviorTypeValues[0][0]);
}
}
}
return true;