From 815cfcd3c483c5cafb321ff791e0bee42fa966c8 Mon Sep 17 00:00:00 2001 From: jiahuiwen <1024696487@qq.com> Date: Mon, 28 Jan 2019 18:54:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/server/EventPointConfig.txt | 62 +++++----- conf/server/MapPointConfig.txt | 10 +- conf/server/OptionAddCondition.txt | 2 +- conf/server/OptionConfig.txt | 79 +++++++++---- .../ljsd/jieling/handler/map/MapLogic.java | 109 ++++++++++-------- 5 files changed, 162 insertions(+), 100 deletions(-) diff --git a/conf/server/EventPointConfig.txt b/conf/server/EventPointConfig.txt index 4fac5c114..a4675d3ef 100644 --- a/conf/server/EventPointConfig.txt +++ b/conf/server/EventPointConfig.txt @@ -30,30 +30,38 @@ int mut,int#int,1 101028 101033 101029 101034 101030 101035 -101029 101036#101037 -101030 101036#101037 -101031 101036#101037 -101032 101036#101037 -101033 101036#101037 -101034 null -101035 null -101036 null -101037 null -101038 null -101039 null -101040 null -101041 null -101042 null -101043 null -101044 null -101045 null -101046 null -101047 null -101048 null -101049 null -101050 null -101051 null -101052 null -101053 null -101054 null -101055 null +101031 101036 +101032 101037#101038 +101033 101039#101040 +101034 101041#101042 +101035 101043#101044 +101036 101045#101046 +101037 101047 +101038 101048 +101039 101049#101050 +101040 101051 +101041 101052 +101042 101053 +101043 101054 +101044 101055 +101045 101056 +101046 101057 +101047 101058 +101048 101059 +101049 101060 +101050 101061 +101051 101062 +101052 101063 +101053 101064 +101054 101065 +101055 101066 +101056 101067 +101057 101068 +101058 101069 +101059 101070 +101060 101071 +101061 101072 +101062 101073 +101063 101074 +101064 101075 +101065 101076 diff --git a/conf/server/MapPointConfig.txt b/conf/server/MapPointConfig.txt index 7ae798cd7..6d7a6b984 100644 --- a/conf/server/MapPointConfig.txt +++ b/conf/server/MapPointConfig.txt @@ -7,11 +7,11 @@ int int int int int int 101005 3 2 1 0 101005 101006 4 2 1 0 101006 101007 5 3 1 0 101007 -101008 5 4 1 0 101029 -101009 5 3 1 0 101030 -101010 5 3 1 0 101031 -101011 5 3 1 0 101032 -101012 5 3 1 0 101033 +101008 5 4 1 0 101032 +101009 5 3 1 0 101007 +101010 5 3 1 0 101007 +101011 5 3 1 0 101065 +101012 5 3 1 0 101065 101013 8 2 1 0 0 102001 1 2 1 0 0 102002 1 2 1 0 0 diff --git a/conf/server/OptionAddCondition.txt b/conf/server/OptionAddCondition.txt index 8a431404c..08165635a 100644 --- a/conf/server/OptionAddCondition.txt +++ b/conf/server/OptionAddCondition.txt @@ -1,7 +1,7 @@ Id Type Values int int mut,int#int,2 1 2 1503#1 -2 1 101008 +2 1 101008#101031 0 0 null 0 0 null 0 0 null diff --git a/conf/server/OptionConfig.txt b/conf/server/OptionConfig.txt index 76db8408a..bdd216836 100644 --- a/conf/server/OptionConfig.txt +++ b/conf/server/OptionConfig.txt @@ -1,10 +1,10 @@ Id AddConditionID BehaviorType BehaviorTypeValues Reward JumpType JumpTypeValues int int int mut,int#int,2 mut,int#int,2 int mut,int#int,2 -101001 1 2 1503#1 null 4 null +101001 1 2 1503#1 null 5 null 101002 0 0 null null 4 null -101003 0 0 null null 5 null +101003 0 5 0 null 4 null 101004 0 0 null null 4 null -101005 0 0 null null 6 102 +101005 0 5 102 null 4 null 101006 0 0 null null 4 null 101007 0 0 null null 1 101008 101008 0 0 null null 4 null @@ -17,23 +17,62 @@ int int int mut,int#int,2 mut,int#int,2 int mut,int#int,2 101015 0 0 null null 1 101013 101016 0 0 null null 4 null 101017 0 0 null null 1 101014 -101018 0 0 null null 3 101015#101028|2 +101018 0 0 null null 3 101015#101031|1#2 101019 0 0 null null 4 null 101020 0 0 null null 3 101016 -101021 0 0 null null 3 101017 -101022 0 0 null null 3 101018 -101023 0 0 null null 3 101019 -101024 0 0 null null 3 101020 -101025 0 0 null null 3 101021 -101026 0 0 null null 3 101022 -101027 0 0 null null 3 101023 +101021 0 0 null null 1 101017 +101022 0 0 null null 1 101018 +101023 0 0 null null 1 101019 +101024 0 0 null null 1 101020 +101025 0 0 null null 1 101021 +101026 0 0 null null 1 101022 +101027 0 0 null null 1 101023 101028 0 0 null null 1 101024 -101029 0 0 null null 3 101025 -101030 0 0 null null 3 101026 -101031 0 0 null null 3 101027 -101032 0 0 null null 3 101028 -101033 0 0 null null 3 101029 -101034 0 0 null null 3 101030 -101035 0 0 null null 5 null -101036 1 2 1503#1 null 4 null -101037 0 0 null null 4 null +101029 0 0 null null 1 101025 +101030 0 0 null null 1 101026 +101031 0 0 null null 1 101027 +101032 0 0 null null 1 101028 +101033 0 0 null null 1 101029 +101034 0 0 null null 1 101030 +101035 0 5 0 null 5 null +101036 0 0 null null 4 null +101037 0 0 null null 1 101033 +101038 0 0 null null 4 null +101039 0 0 null null 1 101034 +101040 0 0 null null 4 null +101041 0 0 null null 1 101035 +101042 0 0 null null 4 null +101043 0 0 null null 1 101036 +101044 0 0 null null 4 null +101045 0 0 null null 1 101037 +101046 0 0 null null 4 null +101047 0 0 null null 1 101038 +101048 0 0 null null 1 101039 +101049 0 0 null null 1 101040 +101050 0 0 null null 4 null +101051 0 0 null null 1 101041 +101052 0 0 null null 1 101042 +101053 0 0 null null 1 101043 +101054 0 0 null null 1 101044 +101055 0 0 null null 1 101045 +101056 0 0 null null 1 101046 +101057 0 0 null null 1 101047 +101058 0 0 null null 1 101048 +101059 0 0 null null 1 101049 +101060 0 0 null null 1 101050 +101061 0 0 null null 1 101051 +101062 0 0 null null 1 101052 +101063 0 0 null null 1 101053 +101064 0 0 null null 1 101054 +101065 0 0 null null 1 101055 +101066 0 0 null null 1 101056 +101067 0 0 null null 1 101057 +101068 0 0 null null 1 101058 +101069 0 0 null null 1 101059 +101070 0 0 null null 1 101060 +101071 0 0 null null 6 101061 +101072 0 0 null null 1 101062 +101073 0 0 null null 1 101063 +101074 0 0 null null 1 101064 +101075 0 0 null null 6 101061 +101076 0 0 null null 4 null diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java index 30dd42a8c..137d9f4a5 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java @@ -1,9 +1,6 @@ package com.ljsd.jieling.handler.map; -import com.ljsd.jieling.config.SCMap; -import com.ljsd.jieling.config.MapPointConfig; -import com.ljsd.jieling.config.SEventPointConfig; -import com.ljsd.jieling.config.SOptionConfig; +import com.ljsd.jieling.config.*; import com.ljsd.jieling.core.GlobalsDef; import com.ljsd.jieling.db.redis.RedisKey; import com.ljsd.jieling.db.redis.RedisUtil; @@ -88,6 +85,9 @@ public class MapLogic { List cells = new ArrayList<>(mapManager.getMapInfo().size()); for (Map.Entry entry : mapManager.getMapInfo().entrySet()) { Cell cell = entry.getValue(); + if (cell.getEventId() == -1) { + continue; + } CommonProto.Cell cellProto = CommonProto.Cell .newBuilder() .setCellId(entry.getKey()) @@ -240,7 +240,7 @@ public class MapLogic { } int bigEventId = cell.getEventId(); if (eventId != bigEventId) { - LOGGER.info("eventId != bigEventId =>{} {}", eventId, bigEventId); + LOGGER.info("eventId != bigEventId =>{} {}, xy=>{}", eventId, bigEventId, mapManager.getCurXY()); MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); return; } @@ -251,6 +251,11 @@ public class MapLogic { return; } int[] option = sEventPointConfig.getOption(); + if (option == null) { + LOGGER.info("option == null sEventPointConfig.getId()=>{}", sEventPointConfig.getId()); + MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); + return; + } boolean can = false; for (int i = 0; i < option.length; i++) { if (option[i] == optionId) { @@ -293,20 +298,6 @@ public class MapLogic { isSuccess = true; break; } -// case EventType.attribute: { -// Set heroes = mapManager.getHeroes(); -// for (String heroId : heroes) { -// Hero hero = user.getHeroManager().getHero(heroId); -// if (hero == null || hero.getCurHp() == 0) { -// continue; -// } -// float hp = HeroLogic.getInstance().calHeroAttribute(hero, GlobalsDef.HP_TYPE); -// -//// eventArr[1] -// } -// isSuccess = true; -// break; -// } case EventType.leave: { int randomInt = MathUtils.randomInt(100) + 1; if (randomInt <= behaviorTypeValues[0][0]) { @@ -319,7 +310,9 @@ public class MapLogic { break; } case EventType.jump: { - + isSuccess = true; + mapManager.setCurMapId(behaviorTypeValues[0][0]); + initMap(mapManager); break; } default: { @@ -332,7 +325,9 @@ public class MapLogic { int[][] jumpTypeValues = sOptionConfig.getJumpTypeValues(); switch (jumpType) { // 1 无条件跳转,对应事件点 - case 1:{ + // 6 无条件跳转地图id + case 1: + case 6:{ nextPoint = jumpTypeValues[0][0]; break; } @@ -348,19 +343,43 @@ public class MapLogic { } // 3 条件跳转 1001#1002|0(0或1为和)#条件id#条件id case 3:{ + SOptionAddCondition sOptionAddConditions = SOptionAddCondition.sOptionAddConditionMap.get(jumpTypeValues[1][1]); + if (sOptionAddConditions == null) { + LOGGER.info("sOptionAddConditions == null jumpTypeValues[1][1]=>{}", jumpTypeValues[1][1]); + MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); + return; + } + // 1 完成事件点,即进度100% + if (sOptionAddConditions.getType() == 1) { + int doneEvent = sOptionAddConditions.getValues()[0][0]; + for (Cell cell1 : mapManager.getMapInfo().values()) { + if (cell.getEventId() == doneEvent) { + if (cell1.getPointId() >= sOptionAddConditions.getValues()[0][1]) { + nextPoint = jumpTypeValues[0][0]; + } + break; + } + } + // 2 物品数量 + } else if (sOptionAddConditions.getType() == 2) { + + } else { + // 3 角色属性 + + } + if (nextPoint == 0) { + nextPoint = jumpTypeValues[0][1]; + } break; } // 4 不跳转,关闭界面 case 4:{ - nextPoint = -1; + nextPoint = cell.getEventId(); break; } - // 5 返回主城 + // 5 不跳转,销毁地图点 -1 case 5:{ - break; - } - // 6 无条件跳转地图id - case 6:{ + nextPoint = -1; break; } default:{ @@ -368,27 +387,20 @@ public class MapLogic { } } MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse = MapInfoProto.EventUpdateResponse.newBuilder(); - cell.setEventId(nextPoint); - mapManager.addOrUpdateCell(mapManager.getCurXY(), cell); - int[][] reward = sOptionConfig.getReward(); - List rewards = new ArrayList<>(); - if (reward != null && reward.length > 0) { -// ItemUtil.drop() - Map itemMap = new HashMap<>(); -// ItemUtil.addItem(user, itemMap); + if (behaviorType != EventType.jump) { + cell.setEventId(nextPoint); + mapManager.addOrUpdateCell(mapManager.getCurXY(), cell); + } + int[][] reward = sOptionConfig.getReward(); + CommonProto.Drop.Builder dropBuilder = null; + if (reward != null && reward.length > 0) { + Map itemMap = new HashMap<>(); + dropBuilder = CommonProto.Drop.newBuilder(); + for (int i = 0; i < reward.length; i++) { + itemMap.put(reward[i][0], reward[i][1]); + } + ItemUtil.addItem(user, itemMap, dropBuilder); } - // 如果是传送门开启跳转到下个关卡 -// if (scMapEvent.getStyle() == EventType.exit) { -// Map> crossMapInfos = cMap.getCrossMapInfos(); -// if (!crossMapInfos.containsKey(cMap.getCurMapId())) { -// crossMapInfos.put(cMap.getCurMapId(), new ArrayList<>()); -// } -// crossMapInfos.get(cMap.getCurMapId()).addAll(cell.getEventIds()); -// } -// if (scMapEvent.getStyle() == EventType.portal) { -// user.getPlayerInfoManager().setMapId(user.getPlayerInfoManager().getMapId() + 1); -// return; -// } List eventBehaviorValuesList = new ArrayList<>(); for (int i = 0; i < sOptionConfig.getBehaviorTypeValues().length; i++) { CommonProto.EventBehaviorValues.Builder eventBehaviorValues = CommonProto.EventBehaviorValues @@ -405,6 +417,9 @@ public class MapLogic { .build(); eventUpdateResponse.setEventBehaviorCommon(eventBehaviorCommon); eventUpdateResponse.setEventId(cell.getEventId()); + if (dropBuilder != null) { + eventUpdateResponse.setDrop(dropBuilder); + } LOGGER.info("updateEvent success xy=>{}, getPointId=>{} eventId={}", mapManager.getCurXY(), cell.getPointId(), cell.getEventId()); MessageUtil.sendMessage(session, 1, messageType.getNumber(), eventUpdateResponse.build(), true); }