Merge branch 'master' of 60.1.1.230:backend/jieling_server

# Conflicts:
#	serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java
back_recharge
wangyuan 2019-01-28 11:21:09 +08:00
commit 4d80dba09f
22 changed files with 841 additions and 374 deletions

View File

@ -0,0 +1,59 @@
Id Option
int mut,int#int,1
101001 10101
101002 10102
101003 10104
101004 101001#101002
101005 101003#101004
101006 101005#101006
101007 101007#101008
101008 101009#101010
101009 101011#101012
101010 101013
101011 101014
101012 101015#101016
101013 101017
101014 101018#101019
101015 101020
101016 101021
101017 101022
101018 101023
101019 101024
101020 101025
101021 101026
101022 101027
101023 101028
101024 101029
101025 101030
101026 101031
101027 101032
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

View File

@ -0,0 +1,148 @@
Id Style Refresh TriggerRules ExploreValues InitialEventId
int int int int int int
101001 1 2 1 0 101001
101002 1 2 1 0 101002
101003 1 2 1 0 101003
101004 2 3 1 0 101004
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
101013 8 2 1 0 0
102001 1 2 1 0 0
102002 1 2 1 0 0
102003 1 2 1 0 0
102004 1 2 1 0 0
102005 2 2 1 0 0
102006 2 2 1 0 0
102007 2 1 1 0 0
102008 2 2 1 0 0
102009 2 1 1 0 0
102010 3 2 1 0 0
102011 5 3 1 0 0
102012 5 3 1 0 0
102013 5 3 1 0 0
102014 5 3 1 0 0
102015 5 3 1 0 0
103001 1 2 1 0 0
103002 1 2 1 0 0
103003 1 2 1 0 0
103004 2 2 1 0 0
103005 2 1 1 0 0
103006 2 2 1 0 0
103007 2 1 1 0 0
103008 2 1 1 0 0
103009 2 2 1 0 0
103010 3 2 1 0 0
103011 4 2 1 0 0
103012 5 3 1 0 0
103013 5 3 1 0 0
103014 5 3 1 0 0
103015 5 3 1 0 0
103016 5 3 1 0 0
103017 5 3 1 0 0
103018 5 3 1 0 0
103019 5 3 1 0 0
103020 5 3 1 0 0
103021 5 3 1 0 0
103022 5 3 1 0 0
103023 8 2 1 0 0
104001 1 2 1 0 0
104002 1 2 1 0 0
104003 1 2 1 0 0
104004 2 2 1 0 0
104005 2 1 1 0 0
104006 2 2 1 0 0
104007 2 1 1 0 0
104008 2 1 1 0 0
104009 2 2 1 0 0
104010 2 2 1 0 0
104011 2 2 1 0 0
104012 3 2 1 0 0
104013 5 3 1 0 0
104014 5 3 1 0 0
104015 5 3 1 0 0
104016 5 3 1 0 0
104017 5 3 1 0 0
104018 5 3 1 0 0
104019 8 2 1 0 0
105001 1 2 1 0 0
105002 1 2 1 0 0
105003 1 2 1 0 0
105004 2 2 1 0 0
105005 2 1 1 0 0
105006 2 2 1 0 0
105007 2 1 1 0 0
105008 2 1 1 0 0
105009 2 2 1 0 0
105010 2 2 1 0 0
105011 2 2 1 0 0
105012 2 1 1 0 0
105013 3 2 1 0 0
105014 5 3 1 0 0
105015 5 3 1 0 0
105016 5 3 1 0 0
105017 5 3 1 0 0
105018 5 3 1 0 0
105019 5 3 1 0 0
105020 5 3 1 0 0
105021 4 2 1 0 0
105022 8 2 1 0 0
106001 1 2 1 0 0
106002 1 2 1 0 0
106003 2 2 1 0 0
106004 2 1 1 0 0
106005 2 2 1 0 0
106006 3 2 1 0 0
106007 5 3 1 0 0
106008 5 3 1 0 0
106009 5 3 1 0 0
106010 5 3 1 0 0
106011 5 3 1 0 0
106012 5 3 1 0 0
106013 8 2 1 0 0
107001 1 2 1 0 0
107002 1 2 1 0 0
107003 2 2 1 0 0
107004 2 1 1 0 0
107005 2 2 1 0 0
107006 2 2 1 0 0
107007 2 1 1 0 0
107008 2 2 1 0 0
107009 3 2 1 0 0
107010 5 3 1 0 0
107011 5 3 1 0 0
107012 5 3 1 0 0
107013 5 3 1 0 0
107014 5 3 1 0 0
107015 5 3 1 0 0
107016 5 3 1 0 0
107017 5 3 1 0 0
107018 5 3 1 0 0
107019 5 3 1 0 0
107020 5 3 1 0 0
107021 5 3 1 0 0
107022 5 3 1 0 0
107023 8 2 1 0 0
108001 1 2 1 0 0
108002 1 2 1 0 0
108003 1 2 1 0 0
108004 2 2 1 0 0
108005 2 1 1 0 0
108006 2 2 1 0 0
108007 2 2 1 0 0
108008 2 1 1 0 0
108009 2 2 1 0 0
108010 2 2 1 0 0
108011 3 2 1 0 0
108012 4 2 1 0 0
108013 5 3 1 0 0
108014 5 3 1 0 0
108015 5 3 1 0 0
108016 5 3 1 0 0
108017 5 3 1 0 0
108018 8 2 1 0 0

View File

@ -1,44 +1,44 @@
id Event Groups
int int mut,int#int,2
1 101013 1#19
2 101013 2#19
3 101013 1#20
4 101013 2#20
5 101013 1#3
6 101013 8#7
7 101013 10#7
8 101013 3#20
9 101013 10#16
10 101013 8#17
11 101013 1#18
12 101002 8#3|9#3|8#4|7#5|7#6
13 101001 2#14|3#14|2#15|3#15
14 101001 7#18|8#18|8#19
15 101002 4#10|4#11
16 101010 2#17
17 101013 9#15
18 101013 10#15
19 101013 8#16
20 101013 9#8
21 101013 10#8
22 101013 2#1
23 101011 8#8
24 101012 7#15
25 101013 1#1
26 101013 3#1
27 101013 4#1
28 101013 5#1
29 101013 1#2
30 101013 2#2
31 101013 3#2
32 101013 4#2
33 101001 4#18|3#19
34 101013 2#3|1#4
35 101013 7#17
36 101013 9#7
37 101013 4#20
38 101013 9#16
39 101013 9#17
1 101007 9#17
2 101013 1#19
3 101013 2#19
4 101013 1#20
5 101013 2#20
6 101013 1#3
7 101013 8#7
8 101013 10#7
9 101013 3#20
10 101013 10#16
11 101013 8#17
12 101013 1#18
13 101002 8#3|9#3|8#4|7#5|7#6
14 101001 2#14|3#14|2#15|3#15
15 101001 7#18|8#18|8#19
16 101002 4#10|4#11
17 101010 2#17
18 101013 9#15
19 101013 10#15
20 101013 8#16
21 101013 9#8
22 101013 10#8
23 101013 2#1
24 101011 8#8
25 101012 7#15
26 101013 1#1
27 101013 3#1
28 101013 4#1
29 101013 5#1
30 101013 1#2
31 101013 2#2
32 101013 3#2
33 101013 4#2
34 101001 4#18|3#19
35 101013 2#3|1#4
36 101013 7#17
37 101013 9#7
38 101013 4#20
39 101013 9#16
40 101008 8#2
41 101009 10#10
42 101004 1#11|2#11|1#12|2#12|5#17|6#17|6#18

View File

@ -0,0 +1,14 @@
Id Type Values
int int mut,int#int,2
1 2 1503#1
2 1 101008
0 0 null
0 0 null
0 0 null
0 0 null
0 0 null
0 0 null
0 0 null
0 0 null
0 0 null
0 0 null

View File

@ -0,0 +1,39 @@
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
101002 0 0 null null 4 null
101003 0 0 null null 5 null
101004 0 0 null null 4 null
101005 0 0 null null 6 102
101006 0 0 null null 4 null
101007 0 0 null null 1 101008
101008 0 0 null null 4 null
101009 0 0 null null 1 101009
101010 0 0 null null 4 null
101011 0 0 null null 1 101010
101012 0 0 null null 4 null
101013 0 0 null null 1 101011
101014 0 0 null null 1 101012
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
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
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

View File

@ -5,10 +5,10 @@ import com.ljsd.jieling.logic.Table;
import java.util.Map;
@Table(name = "MapEventsConfig")
public class SCMapEventsConfig implements BaseConfig{
@Table(name = "MapPointConfig")
public class MapPointConfig implements BaseConfig{
public static Map<Integer, SCMapEventsConfig> scMapEventMap;
public static Map<Integer, MapPointConfig> scMapEventMap;
/**
* id
*/
@ -32,18 +32,20 @@ public class SCMapEventsConfig implements BaseConfig{
* 2
*/
private int triggerRules;
/**
*
*/
private boolean isSchedule;
/**
*
*/
private int exploreValues;
/**
* id
*/
private int initialEventId;
@Override
public void init() throws Exception {
scMapEventMap = STableManager.getConfig(SCMapEventsConfig.class);
scMapEventMap = STableManager.getConfig(MapPointConfig.class);
}
public int getId() {
@ -58,7 +60,7 @@ public class SCMapEventsConfig implements BaseConfig{
return refresh;
}
public static Map<Integer, SCMapEventsConfig> getScMapEventMap() {
public static Map<Integer, MapPointConfig> getScMapEventMap() {
return scMapEventMap;
}
@ -66,8 +68,8 @@ public class SCMapEventsConfig implements BaseConfig{
return triggerRules;
}
public boolean isSchedule() {
return isSchedule;
public int getInitialEventId() {
return initialEventId;
}
public int getExploreValues() {

View File

@ -1,83 +0,0 @@
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 order;
/**
*
*/
private int[][] contents;
/**
*
*/
private int[][] reward;
/**
*
*/
private int[][] jump;
/**
*
*/
private int[][] openRules;
@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.getEventsId())) {
scMapEventsItemConfigs.put(eventsItemConfigEntry.getEventsId(), new HashMap<>());
}
scMapEventsItemConfigs.get(eventsItemConfigEntry.getEventsId()).put(eventsItemConfigEntry.getOrder(), eventsItemConfigEntry);
}
}
public int getId() {
return id;
}
public int getEventsId() {
return eventsId;
}
public int getOrder() {
return order;
}
public int[][] getContents() {
return contents;
}
public int[][] getReward() {
return reward;
}
public int[][] getJump() {
return jump;
}
public int[][] getOpenRules() {
return openRules;
}
}

View File

@ -0,0 +1,28 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.Map;
@Table(name ="EventPointConfig")
public class SEventPointConfig implements BaseConfig {
public static Map<Integer, SEventPointConfig> sEventPointConfigMap;
private int id;
private int[] option;
@Override
public void init() throws Exception {
sEventPointConfigMap = STableManager.getConfig(SEventPointConfig.class);
}
public int getId() {
return id;
}
public int[] getOption() {
return option;
}
}

View File

@ -1,85 +0,0 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.Map;
@Table(name ="MapEventsItemConfig")
public class SMapEventsItemConfig implements BaseConfig {
private int id;
private int eventsId;
private int order;
private int sort;
private int[][] contents;
private int[][] reward;
private int[][] jump;
private int[][] openRules;
private String unfinishInfo;
private String unfinishOption;
private int[][] unfinishContents;
@Override
public void init() throws Exception {
}
public int getId() {
return id;
}
public int getEventsId() {
return eventsId;
}
public int getOrder() {
return order;
}
public int getSort() {
return sort;
}
public int[][] getContents() {
return contents;
}
public int[][] getReward() {
return reward;
}
public int[][] getJump() {
return jump;
}
public int[][] getOpenRules() {
return openRules;
}
public String getUnfinishInfo() {
return unfinishInfo;
}
public String getUnfinishOption() {
return unfinishOption;
}
public int[][] getUnfinishContents() {
return unfinishContents;
}
}

View File

@ -0,0 +1,35 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.Map;
@Table(name = "OptionAddCondition")
public class SOptionAddCondition implements BaseConfig{
public static Map<Integer, SOptionAddCondition> sOptionAddConditionMap;
@Override
public void init() throws Exception {
sOptionAddConditionMap = STableManager.getConfig(SOptionAddCondition.class);
}
private int id;
private int type;
private int[][] values;
public int getId() {
return id;
}
public int getType() {
return type;
}
public int[][] getValues() {
return values;
}
}

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.Map;
@Table(name = "OptionConfig")
public class SOptionConfig implements BaseConfig{
public static Map<Integer, SOptionConfig> sOptionConfigMap;
@Override
public void init() throws Exception {
sOptionConfigMap = STableManager.getConfig(SOptionConfig.class);
}
private int id;
private int addConditionId;
private int behaviorType;
private int[][] behaviorTypeValues;
private int[][] reward;
private int jumpType;
private int[][] jumpTypeValues;
private int addConditionID;
public int getId() {
return id;
}
public int getAddConditionId() {
return addConditionId;
}
public int getBehaviorType() {
return behaviorType;
}
public int[][] getBehaviorTypeValues() {
return behaviorTypeValues;
}
public int[][] getReward() {
return reward;
}
public int getJumpType() {
return jumpType;
}
public int[][] getJumpTypeValues() {
return jumpTypeValues;
}
public int getAddConditionID() {
return addConditionID;
}
}

View File

@ -9,8 +9,8 @@ public interface GlobalsDef {
//英雄属性
int HP_TYPE =1;
int ATTACK_TYPE =2;
int PhysicalDefence_TYPE =3;
int MagicDefence_TYPE =4;
int PHYSICAL_DEFENCE_TYPE =3;
int MAGIC_DEFENCE_TYPE =4;
int SPEED_TYPE =5;
//

View File

@ -6,17 +6,17 @@ public class Cell extends MongoBase {
private int cellId;
private int eventId;
private int pointId;
private int state;
private int eventId;
public Cell() {
}
public Cell(int cellId, int eventId, int state) {
public Cell(int cellId, int eventId, int pointId) {
this.cellId = cellId;
this.pointId = pointId;
this.eventId = eventId;
this.state = state;
}
public int getCellId() {
@ -27,12 +27,17 @@ public class Cell extends MongoBase {
return eventId;
}
public int getState() {
return state;
public int getPointId() {
return pointId;
}
public void setState(int state) throws Exception {
updateString("state", state);
this.state = state;
public void setPointId(int pointId) throws Exception {
updateString("pointId", pointId);
this.pointId = pointId;
}
public void setEventId(int eventId) throws Exception {
updateString("eventId", eventId);
this.eventId = eventId;
}
}

View File

@ -18,23 +18,20 @@ public class EventType {
/**
*
* 1
* 2id#0-11#num
* 3
* 5
* 6
* 7
* 8
* 9buff
* 10
* 2
* 3
* 4
* 5
* 6
* 7
* 8buff
* 9
*/
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 useItem = 2;
public static final int scout = 3;
public static final int leave = 4;
public static final int jump = 5;
public static final int dialogue = 7;
public static final int jump = 8;
public static final int eatBuff = 9;
// public static final int obstacle = 10;
public static final int eatBuff = 8;
}

View File

@ -8,16 +8,16 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class MapUpdateEventRequestHandler extends BaseHandler {
public class EventUpdateRequestHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.MAP_UDPATE_EVENT_REQUEST;
return MessageTypeProto.MessageType.EVENT_UPDATE_REQUEST;
}
@Override
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.getChoice(), mapEnterRequest.getCellsList(), MessageTypeProto.MessageType.MAP_UDPATE_EVENT_RESPONSE);
MapInfoProto.EventUpdateRequest eventUpdateRequest = MapInfoProto.EventUpdateRequest.parseFrom(message);
MapLogic.getInstance().updateEvent(iSession, eventUpdateRequest.getEventId(), eventUpdateRequest.getOptionId(), MessageTypeProto.MessageType.EVENT_UPDATE_RESPONSE);
}
}

View File

@ -1,22 +1,22 @@
package com.ljsd.jieling.handler.map;
import com.ljsd.jieling.config.SCMap;
import com.ljsd.jieling.config.SCMapEventsConfig;
import com.ljsd.jieling.config.SCMapEventsItemConfig;
import com.ljsd.jieling.config.MapPointConfig;
import com.ljsd.jieling.config.SEventPointConfig;
import com.ljsd.jieling.config.SOptionConfig;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.logic.dao.Hero;
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.logic.hero.HeroLogic;
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.CellUtil;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MathUtils;
import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -55,14 +55,19 @@ public class MapLogic {
// if (heroInfosList == null || heroInfosList.isEmpty()) {
// return;
// }
Map<String, Integer> heroes = new HashMap<>(heroInfosList.size());
Set<String> heroes = new HashSet<>(heroInfosList.size());
for (MapInfoProto.HeroInfo heroInfo : heroInfosList) {
heroes.put(heroInfo.getHeroId(), heroInfo.getHeroHp());
Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId());
if (hero == null) {
return;
}
hero.setCurHp(HeroLogic.getInstance().calHeroAttribute(hero, GlobalsDef.HP_TYPE));
heroes.add(heroInfo.getHeroId());
}
if (heroes.size() != heroInfosList.size()) {
return;
}
mapManager.setHeroHps(heroes);
mapManager.setHeroes(heroes);
user.getPlayerInfoManager().setMapId(101);
mapManager.setCurMapId(101);
initMap(mapManager);
@ -87,7 +92,7 @@ public class MapLogic {
.newBuilder()
.setCellId(entry.getKey())
.setEventId(cell.getEventId())
.setState(cell.getState())
.setPointId(cell.getPointId())
.build();
cells.add(cellProto);
}
@ -111,17 +116,20 @@ public class MapLogic {
int x = scMap1.getGroups()[randomIndex][0];
int y = scMap1.getGroups()[randomIndex][1];
int xy = CellUtil.xy2Pos(x, y);
Cell cellValue = new Cell(xy, scMap1.getEvent(), 0);
SCMapEventsConfig scMapEvent = SCMapEventsConfig.scMapEventMap.get(scMap1.getEvent());
if (scMapEvent.getStyle() == EventType.enter) {
MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(scMap1.getEvent());
Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
if (mapPointConfig.getStyle() == EventType.enter) {
mapManager.setCurXY(xy);
}
if (scMapEvent.getStyle() == EventType.allEvents) {
if (mapPointConfig.getStyle() == EventType.allEvents) {
spicelMap.put(xy, cellValue);
} else {
newMap.put(xy, cellValue);
}
}
if (mapManager.getCurMapId() > mapManager.getMaxMapId()) {
mapManager.setMaxMapId(mapManager.getCurMapId());
}
mapManager.setMapInfo(newMap);
mapManager.setTypeEight(spicelMap);
}
@ -129,33 +137,63 @@ public class MapLogic {
/**
*
*/
public void fightStart(int uid, int bigEventId){
public List<CommonProto.HeroFightInfo> fightStart(int uid, int bigEventId, User user){
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);
Set<String> heroes = user.getMapManager().getHeroes();
List<CommonProto.HeroFightInfo> heroFightInfos = new ArrayList<>(heroes.size());
for (String heroId : heroes) {
Hero hero = user.getHeroManager().getHero(heroId);
if (hero == null || hero.getCurHp() == 0) {
continue;
}
float attack = HeroLogic.getInstance().calHeroAttribute(hero, GlobalsDef.ATTACK_TYPE);
float physicalDefence = HeroLogic.getInstance().calHeroAttribute(hero, GlobalsDef.PHYSICAL_DEFENCE_TYPE);
float magicDefence = HeroLogic.getInstance().calHeroAttribute(hero, GlobalsDef.MAGIC_DEFENCE_TYPE);
float hp = HeroLogic.getInstance().calHeroAttribute(hero, GlobalsDef.HP_TYPE);
float speed = HeroLogic.getInstance().calHeroAttribute(hero, GlobalsDef.HP_TYPE);
CommonProto.Hero heroProto = CBean2Proto.getHero(hero);
CommonProto.HeroFightInfo heroFightInfo = CommonProto.HeroFightInfo
.newBuilder()
.setAttack(attack)
.setPhysicalDefence(physicalDefence)
.setMagicDefence(magicDefence)
.setHp(hp)
.setSpeed(speed)
.setHero(heroProto)
.build();
heroFightInfos.add(heroFightInfo);
}
return heroFightInfos;
}
/**
*
*/
public void fightEnd(int uid) {
public void fightEnd(ISession session, int result, List<MapInfoProto.HeroInfo> heroInfos, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
String key = RedisKey.getKey(RedisKey.FIGHT, Integer.toString(uid), false);
String fightInfo = RedisUtil.getInstence().getAndDelete(key);
if (fightInfo == null || fightInfo.isEmpty()) {
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "未开始战斗");
return;
}
User user = UserManager.getUser(uid);
MapManager mapManager = user.getMapManager();
if (result != 1) {
mapManager.setCurXY(0);
Set<String> heroes = mapManager.getHeroes();
for (String heroId : heroes) {
Hero hero = user.getHeroManager().getHero(heroId);
hero.setCurHp(0);
}
return;
}
}
/**
*
*
* @param session
* @param xy
*/
public void updateEvent(ISession session, int xy, int choice, List<Integer> cells, MessageTypeProto.MessageType messageType) throws Exception {
Set<Integer> cellSet = new HashSet<>(cells);
if (cells.size() != cellSet.size()) {
LOGGER.info("cells has repeated");
public void updateMap(ISession session, int curXY, List<Integer> cells, MessageTypeProto.MessageType messageType) throws Exception {
if (cells.isEmpty()) {
LOGGER.info("cells.isEmpty()");
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
@ -167,111 +205,175 @@ public class MapLogic {
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
Cell cell = mapManager.getMapInfo().get(xy);
Cell cell = mapManager.getMapInfo().get(curXY);
if (cell == null) {
LOGGER.info("xy is wrong =>{}", xy);
LOGGER.info("xy is wrong =>{}", curXY);
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
mapManager.addWalkCells(new HashSet<>(cells));
mapManager.setCurXY(curXY);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true);
}
/**
*
* optionConfig Id
* @param session
* @param optionId
*/
public void updateEvent(ISession session, int eventId, int optionId, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
MapManager mapManager = user.getMapManager();
if (mapManager.getMapInfo() == null) {
LOGGER.info("mapManager.getMapInfo() == null");
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
Cell cell = mapManager.getMapInfo().get(mapManager.getCurXY());
if (cell == null) {
LOGGER.info("cell == null xy is wrong =>{}", mapManager.getCurXY());
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
mapManager.setCurXY(xy);
int bigEventId = cell.getEventId();
int schedule = cell.getState();
if (eventId != bigEventId) {
LOGGER.info("eventId != bigEventId =>{} {}", eventId, bigEventId);
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
SEventPointConfig sEventPointConfig = SEventPointConfig.sEventPointConfigMap.get(eventId);
if (sEventPointConfig == null) {
LOGGER.info("sEventPointConfig == null");
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
int[] option = sEventPointConfig.getOption();
boolean can = false;
for (int i = 0; i < option.length; i++) {
if (option[i] == optionId) {
can = true;
break;
}
}
if (!can) {
LOGGER.info("option =>{} optionId=>{}", option, optionId);
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
int schedule = cell.getPointId();
if (schedule == -1) {
LOGGER.info("event is finished,bigEventId=>{} smallEventId=>{}", bigEventId, -1);
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
Map<Integer, SCMapEventsItemConfig> integerSCMapEventsItemConfigMap = SCMapEventsItemConfig.scMapEventsItemConfigs.get(bigEventId);
if (integerSCMapEventsItemConfigMap == null) {
LOGGER.info("no this event=>{}", bigEventId);
SOptionConfig sOptionConfig = SOptionConfig.sOptionConfigMap.get(optionId);
if (sOptionConfig == null) {
LOGGER.info("sOptionConfig == null=>{}", optionId);
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
SCMapEventsItemConfig scMapEventsItemConfig = integerSCMapEventsItemConfigMap.get(schedule);
if (scMapEventsItemConfig == null) {
LOGGER.info("no scMapEventsItemConfig bigEventId=>{} smallEventId=>{}", bigEventId, schedule);
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
int[][] contents = scMapEventsItemConfig.getContents();
boolean isSuccess = false;
if (contents.length > 0) {
if (choice < 0 || contents.length < choice) {
LOGGER.info("no this choice =>{} scMapEventsItemConfig.getContents()=>{}", choice, scMapEventsItemConfig.getContents());
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
int behaviorType = sOptionConfig.getBehaviorType();
int[][] behaviorTypeValues = sOptionConfig.getBehaviorTypeValues();
switch (behaviorType) {
case EventType.fight: {
// heroFightInfos = fightStart(uid, bigEventId, user);
isSuccess = true;
break;
}
int[] eventArr = contents[choice - 1];
switch (eventArr[0]) {
case EventType.fight: {
fightStart(uid, bigEventId);
case EventType.eatBuff:
case EventType.useItem:
case EventType.scout: {
Map<Integer, Integer> useItems = new HashMap<>();
useItems.put(behaviorTypeValues[0][0], behaviorTypeValues[0][1]);
ItemUtil.useItem(user, useItems);
isSuccess = true;
break;
}
// case EventType.attribute: {
// Set<String> 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]) {
isSuccess = true;
break;
}
case EventType.attribute: {
Map<String, Integer> heroHps = mapManager.getHeroHps();
for (Map.Entry<String, Integer> entry : heroHps.entrySet()) {
if (entry.getValue() == 0) {
continue;
}
Hero hero = user.getHeroManager().getHero(entry.getKey());
// eventArr[1]
}
isSuccess = true;
break;
}
case EventType.eatBuff:
case EventType.useItem:
case EventType.scout: {
Map<Integer, Integer> useItems = new HashMap<>();
useItems.put(eventArr[1], eventArr[2]);
ItemUtil.useItem(user, useItems);
isSuccess = true;
break;
}
case EventType.leave: {
int randomInt = MathUtils.randomInt(100) + 1;
if (randomInt <= eventArr[1]) {
isSuccess = true;
}
break;
}
case EventType.dialogue: {
break;
}
case EventType.dialogue: {
break;
}
case EventType.jump: {
break;
}
case EventType.jump: {
break;
}
default: {
return;
}
break;
}
} else {
isSuccess = true;
}
MapInfoProto.MapUpdateEventResponse.Builder mapUpdateEventResponse = MapInfoProto.MapUpdateEventResponse.newBuilder();
if (!isSuccess) {
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
if (scMapEventsItemConfig.getJump() == null || scMapEventsItemConfig.getJump().length == 0) {
cell.setState(-1);
} else {
int[][] jumps = scMapEventsItemConfig.getJump();
for (int i = 0; i < jumps.length; i++) {
int[] jump = jumps[i];
if (jump[0] == choice) {
cell.setState(jump[1]);
break;
}
default: {
break;
}
}
mapManager.addOrUpdateCell(xy, cell);
int[][] reward = scMapEventsItemConfig.getReward();
int jumpType = sOptionConfig.getJumpType();
int nextPoint = 0;
int[][] jumpTypeValues = sOptionConfig.getJumpTypeValues();
switch (jumpType) {
// 1 无条件跳转,对应事件点
case 1:{
nextPoint = jumpTypeValues[0][0];
break;
}
// 2 权重跳转1001#1002|0.2#0.8
case 2:{
int ranom = MathUtils.randomInt(100) + 1;
if (ranom >= jumpTypeValues[1][0]) {
nextPoint = jumpTypeValues[0][0];
} else {
nextPoint = jumpTypeValues[0][1];
}
break;
}
// 3 条件跳转 1001#1002|00或1为和#条件id#条件id
case 3:{
break;
}
// 4 不跳转,关闭界面
case 4:{
nextPoint = -1;
break;
}
// 5 返回主城
case 5:{
break;
}
// 6 无条件跳转地图id
case 6:{
break;
}
default:{
break;
}
}
MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse = MapInfoProto.EventUpdateResponse.newBuilder();
cell.setEventId(nextPoint);
mapManager.addOrUpdateCell(mapManager.getCurXY(), cell);
int[][] reward = sOptionConfig.getReward();
List<CommonProto.Item> rewards = new ArrayList<>();
if (reward != null && reward.length > 0) {
// ItemUtil.drop()
Map<Integer, Integer> itemMap = new HashMap<>();
// ItemUtil.addItem(user, itemMap);
}
@ -287,11 +389,48 @@ public class MapLogic {
// user.getPlayerInfoManager().setMapId(user.getPlayerInfoManager().getMapId() + 1);
// return;
// }
mapUpdateEventResponse.setCurXY(xy);
mapUpdateEventResponse.setEventSchedule(cell.getState());
mapUpdateEventResponse.addAllItems(rewards);
LOGGER.info("updateEvent success xy=>{}, state=>{}", xy, cell.getState());
MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapUpdateEventResponse.build(), true);
List<CommonProto.EventBehaviorValues> eventBehaviorValuesList = new ArrayList<>();
for (int i = 0; i < sOptionConfig.getBehaviorTypeValues().length; i++) {
CommonProto.EventBehaviorValues.Builder eventBehaviorValues = CommonProto.EventBehaviorValues
.newBuilder();
for (int j = 0; j < sOptionConfig.getBehaviorTypeValues()[i].length; j++) {
eventBehaviorValues.addBehaviorValues(sOptionConfig.getBehaviorTypeValues()[i][j]);
}
eventBehaviorValuesList.add(eventBehaviorValues.build());
}
CommonProto.EventBehaviorCommon eventBehaviorCommon = CommonProto.EventBehaviorCommon
.newBuilder()
.setBehaviorType(sOptionConfig.getBehaviorType())
.addAllEventBehaviorValues(eventBehaviorValuesList)
.build();
eventUpdateResponse.setEventBehaviorCommon(eventBehaviorCommon);
eventUpdateResponse.setEventId(cell.getEventId());
LOGGER.info("updateEvent success xy=>{}, getPointId=>{} eventId={}", mapManager.getCurXY(), cell.getPointId(), cell.getEventId());
MessageUtil.sendMessage(session, 1, messageType.getNumber(), eventUpdateResponse.build(), true);
}
/**
* 退
* @param session
* @param messageType
* @throws Exception
*/
public void outMap(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
MapManager mapManager = user.getMapManager();
if (mapManager.getMapInfo() == null) {
LOGGER.info("mapManager.getMapInfo() == null");
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
mapManager.setMapInfo(new HashMap<>());
mapManager.setHeroes(new HashSet<>());
mapManager.setTypeEight(new HashMap<>());
mapManager.setWalkCells(new HashSet<>());
mapManager.setCurXY(0);
mapManager.setCurMapId(0);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true);
}
}

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

View File

@ -0,0 +1,24 @@
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.MapInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class MapUpdateRequestHandler extends BaseHandler{
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.MAP_UDPATE_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
byte[] message = netData.parseClientProtoNetData();
MapInfoProto.MapUpdateRequest mapEnterRequest = MapInfoProto.MapUpdateRequest.parseFrom(message);
MapLogic.getInstance().updateMap(iSession, mapEnterRequest.getCurXY(), mapEnterRequest.getCellsList(), MessageTypeProto.MessageType.MAP_UDPATE_RESPONSE);
}
}

View File

@ -4,6 +4,8 @@ import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.config.SCHero;
import com.ljsd.jieling.config.SGameSetting;
import com.ljsd.jieling.config.SHeroLevlConfig;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.util.KeyGenUtils;
import com.ljsd.jieling.util.UUIDEnum;
@ -35,6 +37,8 @@ public class Hero extends MongoBase {
private int lastUpdateEnergyTime;
private float curHp;
public Hero(){}
public Hero(String uid,int heroTid){
@ -49,6 +53,7 @@ public class Hero extends MongoBase {
if(skillIds!=null && skillIds.isEmpty()){
this.skillList.addAll(skillIds);
}
this.curHp = HeroLogic.getInstance().calHeroAttribute(this, GlobalsDef.HP_TYPE);
createTime = (int)(System.currentTimeMillis()/1000);
lastUpdateEnergyTime = createTime;
breakId = 0;
@ -81,6 +86,14 @@ public class Hero extends MongoBase {
this.templateId = templateId;
}
public float getCurHp() {
return curHp;
}
public void setCurHp(float curHp) throws Exception {
updateString("curHp",curHp);
this.curHp = curHp;
}
public void setLevel(int level) throws Exception {
updateString("level",level);

View File

@ -5,8 +5,10 @@ package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.handler.map.Cell;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@ -16,12 +18,16 @@ public class MapManager extends MongoBase {
private int curXY;
private Map<String, Integer> heroHps;
private int maxMapId;
private Set<String> heroes;
private Map<Integer, Cell> mapInfo;
private Map<Integer, Cell> typeEight;
private Set<Integer> walkCells;
private Map<Integer, List<Integer>> crossMapInfos = new ConcurrentHashMap<>();
public Map<Integer, Cell> getMapInfo() {
@ -74,12 +80,39 @@ public class MapManager extends MongoBase {
this.typeEight = typeEight;
}
public Map<String, Integer> getHeroHps() {
return heroHps;
public Set<String> getHeroes() {
return heroes;
}
public void setHeroHps(Map<String, Integer> heroHps) throws Exception {
updateString( "heroHps", heroHps);
this.heroHps = heroHps;
public void setHeroes(Set<String> heroes) throws Exception {
updateString( "heroes", heroes);
this.heroes = heroes;
}
public Set<Integer> getWalkCells() {
return walkCells;
}
public void setWalkCells(Set<Integer> walkCells) throws Exception {
updateString( "walkCells", walkCells);
this.walkCells = walkCells;
}
public void addWalkCells(Set<Integer> walkCells) throws Exception {
updateString( "walkCells", walkCells);
if (this.walkCells == null) {
this.walkCells = walkCells;
} else {
this.walkCells.addAll(walkCells);
}
}
public int getMaxMapId() {
return maxMapId;
}
public void setMaxMapId(int maxMapId) throws Exception {
updateString( "maxMapId", maxMapId);
this.maxMapId = maxMapId;
}
}

View File

@ -369,8 +369,8 @@ public class HeroLogic {
Map<Integer,Float> baseValueMap = new HashMap<>();
baseValueMap.put(GlobalsDef.HP_TYPE,getBaseValueByType(scHero,GlobalsDef.HP_TYPE));
baseValueMap.put(GlobalsDef.ATTACK_TYPE,getBaseValueByType(scHero,GlobalsDef.ATTACK_TYPE));
baseValueMap.put(GlobalsDef.PhysicalDefence_TYPE,getBaseValueByType(scHero,GlobalsDef.PhysicalDefence_TYPE));
baseValueMap.put(GlobalsDef.MagicDefence_TYPE,getBaseValueByType(scHero,GlobalsDef.MagicDefence_TYPE));
baseValueMap.put(GlobalsDef.PHYSICAL_DEFENCE_TYPE,getBaseValueByType(scHero,GlobalsDef.PHYSICAL_DEFENCE_TYPE));
baseValueMap.put(GlobalsDef.MAGIC_DEFENCE_TYPE,getBaseValueByType(scHero,GlobalsDef.MAGIC_DEFENCE_TYPE));
baseValueMap.put(GlobalsDef.SPEED_TYPE,getBaseValueByType(scHero,GlobalsDef.SPEED_TYPE));
for(Map.Entry<Integer,Float> item : baseValueMap.entrySet()){
Integer attributeType = item.getKey();
@ -431,10 +431,10 @@ public class HeroLogic {
case GlobalsDef.ATTACK_TYPE:
result = scHero.getAttack();
break;
case GlobalsDef.PhysicalDefence_TYPE:
case GlobalsDef.PHYSICAL_DEFENCE_TYPE:
result = scHero.getPhysicalDefence();
break;
case GlobalsDef.MagicDefence_TYPE:
case GlobalsDef.MAGIC_DEFENCE_TYPE:
result = scHero.getMagicDefence();
break;
case GlobalsDef.SPEED_TYPE:
@ -449,7 +449,7 @@ public class HeroLogic {
//todo 计算英雄战斗力 战斗力 = 生命*0.7 + (护甲 + 魔坑)*5 + 攻击 *10 + (暴击率 + 效果命中率 *5 +(属性攻击率 + 属性防御率)*30
public int calHeoForce(Hero hero){
Map<Integer, Integer> heroAllAttribute = calHeroAllAttribute(hero);
double heroBaseForce = heroAllAttribute.get(GlobalsDef.HP_TYPE) * 0.7 + (heroAllAttribute.get(GlobalsDef.PhysicalDefence_TYPE) + heroAllAttribute.get(GlobalsDef.MagicDefence_TYPE)) * 5 + heroAllAttribute.get(GlobalsDef.ATTACK_TYPE) * 10;
double heroBaseForce = heroAllAttribute.get(GlobalsDef.HP_TYPE) * 0.7 + (heroAllAttribute.get(GlobalsDef.PHYSICAL_DEFENCE_TYPE) + heroAllAttribute.get(GlobalsDef.MAGIC_DEFENCE_TYPE)) * 5 + heroAllAttribute.get(GlobalsDef.ATTACK_TYPE) * 10;
//todo 计算装备加成
float equipAddForce =0.0f;
int result = (int) (heroBaseForce + equipAddForce);

View File

@ -1,6 +1,5 @@
package com.ljsd.jieling.util;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -113,4 +112,19 @@ public class CellUtil {
}
public static boolean isContinuous(int lastXY, List<Integer> cells){
boolean first = false;
if (cells.size() > 0) {
first = checkIsNextCell(lastXY, cells.get(0));
}
for (int i = 1; i < cells.size() - 1; i++) {
boolean other = checkIsNextCell(cells.get(i), cells.get(i + 1));
if (!first && !other) {
return false;
}
}
return true;
}
}