地图提交

back_recharge
jiahuiwen 2019-01-16 15:24:01 +08:00
parent c062ebb996
commit f6d8b7322c
14 changed files with 277 additions and 146 deletions

View File

@ -1,18 +0,0 @@
id event groups
int int mut,int#int,2
1 102011 13#8|13#9|14#8|14#9
2 101010 10#5
3 102010 18#5|18#6|19#5|19#6
4 102013 9#1|9#2|10#1|10#2
5 102001 2#3|3#1|3#4
6 101001 4#4|4#5|5#4|5#5|5#7|5#8|6#1|6#2|6#7|6#8|7#1|7#2|18#9|18#10|19#9|19#10|20#6|20#7
7 102012 13#1|13#2|14#1|14#2
8 102004 7#9|7#10|8#3|8#4|8#9|8#10|9#3|9#4|11#2|11#3|12#2|12#3|13#5|13#6|14#5|14#6|15#9|15#10|16#9|16#10
9 102015 9#8|10#8
10 102014 6#4|6#5|7#4|7#5
11 101005 8#6|8#7|9#6|9#7|18#2|18#3|19#2|19#3
12 102016 15#3|16#3
13 101006 3#2
14 101007 2#10
15 101008 17#7
16 101009 12#9

View File

@ -1,14 +0,0 @@
id event groups
int int mut,int#int,2
1 201012 5#3|5#4|6#3|6#4
2 101010 9#8
3 101011 16#7
4 101001 2#6|3#5|3#6|4#8|4#9|5#8|6#7|7#7|8#5|8#6|9#5|9#6|11#4|12#4|14#6|15#6|16#3|16#4|17#3|17#4
5 101002 12#1|12#2|13#1|13#2|18#5|18#6|19#6
6 101003 4#4
7 101004 5#10|6#10
8 101005 7#1|7#2|8#1|8#2|11#8|11#9|12#8|12#9|14#2|14#3|14#9|14#10|15#2|15#3|15#9|15#10|19#4|19#7|19#8|20#3|20#8
9 101006 3#8
10 101007 5#5
11 101008 11#10
12 101009 18#2

View File

@ -1,30 +0,0 @@
Id Style Refresh
int int int
101001 1 2
101002 3 2
101003 5 2
101004 9 2
101005 1 2
101006 6 3
101007 7 3
101008 6 2
101009 6 3
101010 8 2
101011 8 2
101012 4 2
102001 9 2
102002 1 2
102003 1 2
102004 1 2
102005 6 3
102006 6 3
102007 6 3
102008 6 3
102009 6 3
102010 3 1
102011 3 2
102012 3 2
102013 3 1
102014 3 2
102015 2 2
102016 2 2

View File

@ -1,3 +0,0 @@
id length width
int int int
1 10 20

View File

@ -6,14 +6,15 @@ import com.ljsd.jieling.logic.Table;
import java.util.Map; import java.util.Map;
@Table(name = "1.MapConfig") @Table(name = "MapConfig")
public class SCMapConfig implements BaseConfig { public class SCMapConfig implements BaseConfig {
public static Map<Integer, SCMapConfig> sCMapSize; public static Map<Integer, SCMapConfig> sCMapSize;
private int id; private int id;
private String info; private String info;
private int[] size; // 0:行 1列 private int[] size; // 0:行 1列
private int confused; //地图消耗 private int moveConfused; //地图消耗
private String openRule; // 开启条件 private String openRule; // 开启条件
private int energyConfused;
@Override @Override
public void init() throws Exception { public void init() throws Exception {
sCMapSize = STableManager.getConfig(SCMapConfig.class); sCMapSize = STableManager.getConfig(SCMapConfig.class);
@ -31,8 +32,12 @@ public class SCMapConfig implements BaseConfig {
return size; return size;
} }
public int getConfused() { public int getMoveConfused() {
return confused; return moveConfused;
}
public int getEnergyConfused() {
return energyConfused;
} }
public String getOpenRule() { public String getOpenRule() {

View File

@ -5,11 +5,14 @@ import com.ljsd.jieling.logic.Table;
import java.util.Map; import java.util.Map;
@Table(name = "2.MapEventsConfig") @Table(name = "MapEventsConfig")
public class SCMapEvent implements BaseConfig{ public class SCMapEventsConfig implements BaseConfig{
public static Map<Integer, SCMapEvent> scMapEventMap; public static Map<Integer, SCMapEventsConfig> scMapEventMap;
/**
* id
*/
private int id; private int id;
/** /**
* " * "
@ -23,10 +26,14 @@ public class SCMapEvent implements BaseConfig{
* 3 * 3
*/ */
private int refresh; private int refresh;
private int triggerRules;
private boolean isSchedule;
private int exploreValues;
@Override @Override
public void init() throws Exception { public void init() throws Exception {
scMapEventMap = STableManager.getConfig(SCMapEvent.class); scMapEventMap = STableManager.getConfig(SCMapEventsConfig.class);
} }
public int getId() { public int getId() {
@ -40,4 +47,16 @@ public class SCMapEvent implements BaseConfig{
public int getRefresh() { public int getRefresh() {
return refresh; return refresh;
} }
public int getTriggerRules() {
return triggerRules;
}
public boolean isSchedule() {
return isSchedule;
}
public int getExploreValues() {
return exploreValues;
}
} }

View File

@ -0,0 +1,65 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.HashMap;
import java.util.Map;
@Table(name = "MapEventsItemConfig")
public class SCMapEventsItemConfig implements BaseConfig{
public static Map<Integer, SCMapEventsItemConfig> scMapEventsItemConfigMap;
public static Map<Integer, Map<Integer, SCMapEventsItemConfig>> scMapEventsItemConfigs;
private int id;
/**
*"id
*/
private int eventsId;
/**
*
* */
private int sort;
/**
*
*/
private String contents;
/**
*
*/
private String reward;
@Override
public void init() throws Exception {
scMapEventsItemConfigMap = STableManager.getConfig(SCMapEventsItemConfig.class);
scMapEventsItemConfigs = new HashMap<>(scMapEventsItemConfigMap.size());
for (SCMapEventsItemConfig eventsItemConfigEntry : scMapEventsItemConfigMap.values()){
if (!scMapEventsItemConfigs.containsKey(eventsItemConfigEntry.getEventId())) {
scMapEventsItemConfigs.put(eventsItemConfigEntry.getEventId(), new HashMap<>());
}
scMapEventsItemConfigs.get(eventsItemConfigEntry.getEventId()).put(eventsItemConfigEntry.getSort(), eventsItemConfigEntry);
}
}
public int getId() {
return id;
}
public int getEventId() {
return eventsId;
}
public int getSort() {
return sort;
}
public String getContents() {
return contents;
}
public String getReward() {
return reward;
}
}

View File

@ -0,0 +1,11 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.Table;
@Table(name = "MissionEventsConfig")
public class SCMissionEventsConfig implements BaseConfig {
@Override
public void init() throws Exception {
}
}

View File

@ -0,0 +1,11 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.Table;
@Table(name = "MissionEventsItemConfig")
public class SCMissionEventsItemConfig implements BaseConfig {
@Override
public void init() throws Exception {
}
}

View File

@ -1,24 +1,13 @@
package com.ljsd.jieling.handler.map; package com.ljsd.jieling.handler.map;
import com.google.common.collect.Sets; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Set;
public class Cell { public class Cell {
private Set<Integer> eventIds = Sets.newConcurrentHashSet();; private Map<Integer, Integer> eventIds = new ConcurrentHashMap();
private boolean isFinish; public Map<Integer, Integer> getEventIds() {
public Set<Integer> getEventIds() {
return eventIds; return eventIds;
} }
public boolean isFinish() {
return isFinish;
}
public void setFinish(boolean finish) {
isFinish = finish;
}
} }

View File

@ -1,14 +1,39 @@
package com.ljsd.jieling.handler.map; package com.ljsd.jieling.handler.map;
public class EventType { public class EventType {
// 事件点类型 1怪物 2怪物群 3矿 4入口 5出口 6一次性事件 7重复事件 8npc 9地图boss /**
*
* 1 2 3 4 5 6 7 8
*/
public static final int monster = 1; public static final int monster = 1;
public static final int monsters = 2; public static final int mine = 2;
public static final int mine = 3; public static final int enter = 3;
public static final int enter = 4; public static final int exit = 4;
public static final int exit = 5; public static final int continuity = 5;
public static final int disposable = 6; public static final int businessman = 6;
public static final int repeated = 7; public static final int box = 7;
public static final int npc = 8; public static final int obstacle = 8;
public static final int boss = 8;
/**
*
* 1
* 2id#0-11#num
* 3
* 5
* 6
* 7
* 8
* 9buff
* 10
*/
public static final int fight = 1;
public static final int attribute = 2;
public static final int useItem = 3;
// public static final int scout = 4;
public static final int scout = 5;
public static final int leave = 6;
public static final int dialogue = 7;
public static final int jump = 8;
public static final int eatBuff = 9;
// public static final int obstacle = 10;
} }

View File

@ -1,21 +0,0 @@
package com.ljsd.jieling.handler.map;
public class LittleEventType {
/**
* 1
* 2 id#0-11#num
* 3
* 4
* 5
* 6
* 7
*/
public static final int fight = 1;
public static final int attribute = 2;
public static final int item = 3;
public static final int reward = 4;
public static final int scout = 5;
public static final int leave = 6;
public static final int choice = 7;
}

View File

@ -1,5 +1,7 @@
package com.ljsd.jieling.handler.map; package com.ljsd.jieling.handler.map;
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.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;
@ -7,16 +9,12 @@ import com.ljsd.jieling.network.session.ISession;
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.MessageUtil; import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.config.SCMap; import com.ljsd.jieling.config.SCMapEventsConfig;
import com.ljsd.jieling.config.SCMapEvent;
import com.ljsd.jieling.util.ToolsUtil; import com.ljsd.jieling.util.ToolsUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class MapLogic { public class MapLogic {
@ -47,6 +45,16 @@ public class MapLogic {
if (mapManager.getCurMapId() == 0) { if (mapManager.getCurMapId() == 0) {
mapManager = initMap( 1); mapManager = initMap( 1);
user.setMapManager(mapManager); user.setMapManager(mapManager);
} else {
if (mapId > mapManager.getCurMapId()) {
mapManager = initMap(mapManager.getCurMapId());
} else {
mapManager = initMap(mapId);
if (mapManager == null) {
return;
}
}
user.setMapManager(mapManager);
} }
MapInfoProto.MapInfo.MapEnterResponse mapEnterResponse = MapInfoProto.MapInfo.MapEnterResponse MapInfoProto.MapInfo.MapEnterResponse mapEnterResponse = MapInfoProto.MapInfo.MapEnterResponse
.newBuilder() .newBuilder()
@ -56,9 +64,6 @@ public class MapLogic {
private MapManager initMap(int mapId) throws Exception { private MapManager initMap(int mapId) throws Exception {
if (mapId == 0) {
mapId = 1;
}
Map<Integer, SCMap> scMap = SCMap.sCMap.get(mapId); Map<Integer, SCMap> scMap = SCMap.sCMap.get(mapId);
if (scMap == null) { if (scMap == null) {
return null; return null;
@ -71,12 +76,12 @@ public class MapLogic {
for (Map.Entry<Integer, SCMap> entry : scMap.entrySet()) { for (Map.Entry<Integer, SCMap> entry : scMap.entrySet()) {
SCMap scMap1 = entry.getValue(); SCMap scMap1 = entry.getValue();
Cell cellValue = new Cell(); Cell cellValue = new Cell();
cellValue.getEventIds().add(scMap1.getEvent()); cellValue.getEventIds().put(scMap1.getEvent(), 0);
int randomIndex = random.nextInt(scMap1.getGroups().length); int randomIndex = random.nextInt(scMap1.getGroups().length);
int x = scMap1.getGroups()[randomIndex][0]; int x = scMap1.getGroups()[randomIndex][0];
int y = scMap1.getGroups()[randomIndex][1]; int y = scMap1.getGroups()[randomIndex][1];
int xy = ToolsUtil.xy2Pos(x, y); int xy = ToolsUtil.xy2Pos(x, y);
SCMapEvent scMapEvent = SCMapEvent.scMapEventMap.get(scMap1.getEvent()); SCMapEventsConfig scMapEvent = SCMapEventsConfig.scMapEventMap.get(scMap1.getEvent());
if (scMapEvent.getStyle() == EventType.enter) { if (scMapEvent.getStyle() == EventType.enter) {
mapManager.setCurXY(xy); mapManager.setCurXY(xy);
} }
@ -87,37 +92,104 @@ public class MapLogic {
/** /**
* *
* @param uid * @param uid
* @param xy * @param xy
*/ */
public void finishEvent(int uid, int xy) throws Exception { public void updateEvent(int uid, int xy, int bigEventId, int smallEventId, int choice) throws Exception {
// get db User user = UserManager.getUser(uid);
MapManager cMap = null; MapManager mapManager = user.getMapManager();
Cell cell = cMap.getMapInfo().get(xy); Cell cell = mapManager.getMapInfo().get(xy);
if (cell == null) { if (cell == null) {
LOGGER.info("xy is wrong =>{}", xy);
return; return;
} }
if (cell.getEventIds().isEmpty()) { if (cell.getEventIds().isEmpty()) {
LOGGER.info("no event eventId");
return; return;
} }
cMap.setCurXY(xy); mapManager.setCurXY(xy);
cell.setFinish(true); Map<Integer, Integer> eventIds = cell.getEventIds();
SCMapEvent scMapEvent = SCMapEvent.scMapEventMap.get(cell.getEventIds()); if (!eventIds.containsKey(bigEventId)) {
// 如果是出口开启跳转到下个关卡 LOGGER.info("no this event eventId=>{}", bigEventId);
if (scMapEvent.getStyle() == EventType.disposable) { return;
Map<Integer, List<Integer>> crossMapInfos = cMap.getCrossMapInfos(); }
if (!crossMapInfos.containsKey(cMap.getCurMapId())) { int schedule = eventIds.get(bigEventId);
crossMapInfos.put(cMap.getCurMapId(), new ArrayList<>()); if (schedule == -1 || schedule >= smallEventId) {
LOGGER.info("event is finished,bigEventId=>{} smallEventId=>{}", bigEventId, smallEventId);
return;
}
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);
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());
return;
}
String[] eventArr = contents[choice].split("#");
switch (scMapEvent.getStyle()) {
case EventType.monster:{
break;
}
case EventType.continuity:{
switch (Integer.parseInt(eventArr[0])) {
case EventType.fight:{
break;
}
case EventType.attribute:{
break;
}
case EventType.useItem:
case EventType.scout:{
break;
}
case EventType.leave:{
break;
}
case EventType.dialogue:{
break;
}
case EventType.jump:{
break;
}
case EventType.eatBuff:{
break;
} default:{
return;
}
}
break;
} }
crossMapInfos.get(cMap.getCurMapId()).addAll(cell.getEventIds());
} }
if (smallEventId + 1 >= contents.length - 1){
cell.getEventIds().put(bigEventId, -1);
} else {
cell.getEventIds().put(bigEventId, schedule + 1);
}
// 如果是传送门开启跳转到下个关卡
// if (scMapEvent.getStyle() == EventType.exit) {
// Map<Integer, List<Integer>> 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.exit) { if (scMapEvent.getStyle() == EventType.exit) {
initMap(cMap.getCurMapId() + 1); initMap(mapManager.getCurMapId() + 1);
return; return;
} }
cell.setFinish(true);
// save db
} }
} }

View File

@ -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 MapUpdateEventRequestHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.MAP_ENTER_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
}
}