From 51ae7681674bb879644700fb03099582ee742d1d Mon Sep 17 00:00:00 2001 From: jiahuiwen <1024696487@qq.com> Date: Fri, 25 Jan 2019 18:19:57 +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 --- ...pEventsConfig.java => MapPointConfig.java} | 24 +- .../jieling/config/SCMapEventsItemConfig.java | 83 ------ .../jieling/config/SMapEventsItemConfig.java | 85 ------ .../ljsd/jieling/config/SMapPointConfig.java | 17 ++ .../jieling/config/SOptionAddCondition.java | 35 +++ .../ljsd/jieling/config/SOptionConfig.java | 59 +++++ .../com/ljsd/jieling/core/GlobalsDef.java | 4 +- .../ljsd/jieling/handler/map/EventType.java | 29 +-- .../ljsd/jieling/handler/map/MapLogic.java | 241 +++++++++++------- .../java/com/ljsd/jieling/logic/dao/Hero.java | 14 +- .../ljsd/jieling/logic/dao/MapManager.java | 13 +- .../ljsd/jieling/logic/hero/HeroLogic.java | 4 +- .../java/com/ljsd/jieling/util/CellUtil.java | 16 +- 13 files changed, 324 insertions(+), 300 deletions(-) rename serverlogic/src/main/java/com/ljsd/jieling/config/{SCMapEventsConfig.java => MapPointConfig.java} (72%) delete mode 100644 serverlogic/src/main/java/com/ljsd/jieling/config/SCMapEventsItemConfig.java delete mode 100644 serverlogic/src/main/java/com/ljsd/jieling/config/SMapEventsItemConfig.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/config/SMapPointConfig.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/config/SOptionAddCondition.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/config/SOptionConfig.java diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SCMapEventsConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/MapPointConfig.java similarity index 72% rename from serverlogic/src/main/java/com/ljsd/jieling/config/SCMapEventsConfig.java rename to serverlogic/src/main/java/com/ljsd/jieling/config/MapPointConfig.java index 45cd2a858..34e7f9e8b 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SCMapEventsConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/MapPointConfig.java @@ -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 scMapEventMap; + public static Map 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 getScMapEventMap() { + public static Map 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() { diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SCMapEventsItemConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SCMapEventsItemConfig.java deleted file mode 100644 index c975d9f70..000000000 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SCMapEventsItemConfig.java +++ /dev/null @@ -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 scMapEventsItemConfigMap; - - public static Map> 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; - } -} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SMapEventsItemConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SMapEventsItemConfig.java deleted file mode 100644 index 99363bf19..000000000 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SMapEventsItemConfig.java +++ /dev/null @@ -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; - } - - -} \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SMapPointConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SMapPointConfig.java new file mode 100644 index 000000000..2c3181d4b --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SMapPointConfig.java @@ -0,0 +1,17 @@ +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 SMapPointConfig implements BaseConfig{ + + public static Map sMapPointConfigMap; + + @Override + public void init() throws Exception { + sMapPointConfigMap = STableManager.getConfig(SMapPointConfig.class); + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SOptionAddCondition.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SOptionAddCondition.java new file mode 100644 index 000000000..fe35e4d31 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SOptionAddCondition.java @@ -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 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; + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SOptionConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SOptionConfig.java new file mode 100644 index 000000000..a0b42fccd --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SOptionConfig.java @@ -0,0 +1,59 @@ +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 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; + + 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; + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java b/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java index 29e52b9d2..b42f01b8a 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java @@ -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; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/EventType.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/EventType.java index e8738ba50..08177e4a6 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/EventType.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/EventType.java @@ -18,23 +18,20 @@ public class EventType { /** * 小事件类型 * 1战斗 - * 2判断属性(属性id#(0,-1,1)#num - * 3消耗物品 - * 5侦察 - * 6离开 - * 7做选择不同跳转文本 - * 8行动到某张地图某坐标点 - * 9吃buff - * 10走进度条 + * 2消耗物品 + * 3侦察 + * 4离开 + * 5行动到某张地图某坐标点 + * 6进度条 + * 7生成新的地图点 + * 8吃buff + * 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; } 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 3afbfd6f9..ab7d6ebab 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,22 +1,21 @@ 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.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 +54,19 @@ public class MapLogic { // if (heroInfosList == null || heroInfosList.isEmpty()) { // return; // } - Map heroes = new HashMap<>(heroInfosList.size()); + Set 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); @@ -111,12 +115,12 @@ 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, scMap1.getEvent(), mapPointConfig.getInitialEventId()); + 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); @@ -129,18 +133,56 @@ public class MapLogic { /** * 战斗开始 */ - public void fightStart(int uid, int bigEventId){ + public List 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 heroes = user.getMapManager().getHeroes(); + List 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 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 heroes = mapManager.getHeroes(); + for (String heroId : heroes) { + Hero hero = user.getHeroManager().getHero(heroId); + hero.setCurHp(0); + } return; } } @@ -181,97 +223,110 @@ public class MapLogic { MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); return; } - Map integerSCMapEventsItemConfigMap = SCMapEventsItemConfig.scMapEventsItemConfigs.get(bigEventId); - if (integerSCMapEventsItemConfigMap == null) { - LOGGER.info("no this event=>{}", bigEventId); + SOptionConfig sOptionConfig = SOptionConfig.sOptionConfigMap.get(choice); + if (sOptionConfig == null) { + LOGGER.info("no this event=>{}", choice); 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(), ""); + int behaviorType = sOptionConfig.getBehaviorType(); + int[][] behaviorTypeValues = sOptionConfig.getBehaviorTypeValues(); + switch (behaviorType) { + case EventType.fight: { +// heroFightInfos = fightStart(uid, bigEventId, user); + isSuccess = true; + break; + } + case EventType.eatBuff: + case EventType.useItem: + case EventType.scout: { + Map useItems = new HashMap<>(); + useItems.put(behaviorTypeValues[0][0], behaviorTypeValues[0][1]); + ItemUtil.useItem(user, useItems); + 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]) { + isSuccess = true; + } + break; + } + case EventType.dialogue: { + + break; + } + case EventType.jump: { + + break; + } + default: { return; } - int[] eventArr = contents[choice - 1]; - switch (eventArr[0]) { - case EventType.fight: { - fightStart(uid, bigEventId); - isSuccess = true; - break; - } - case EventType.attribute: { - Map heroHps = mapManager.getHeroHps(); - for (Map.Entry 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 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.jump: { - - break; - } - default: { - return; - } + 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|0(0或1为和)#条件id#条件id + case 3:{ + break; + } + // 4 不跳转,关闭界面 + case 4:{ + break; + } + // 5 返回主城 + case 5:{ + break; + } + // 6 无条件跳转地图id + case 6:{ + break; + } + default:{ + 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; - } - } - } + cell.setState(nextPoint); mapManager.addOrUpdateCell(xy, cell); - int[][] reward = scMapEventsItemConfig.getReward(); + int[][] reward = sOptionConfig.getReward(); List rewards = new ArrayList<>(); if (reward != null && reward.length > 0) { +// ItemUtil.drop() Map itemMap = new HashMap<>(); // ItemUtil.addItem(user, itemMap); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Hero.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Hero.java index 58134d95b..3cf270736 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Hero.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Hero.java @@ -3,6 +3,8 @@ package com.ljsd.jieling.logic.dao; import com.ljsd.common.mogodb.MongoBase; import com.ljsd.jieling.config.SCHero; 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; @@ -24,6 +26,8 @@ public class Hero extends MongoBase { private List equipList; + private float curHp; + public Hero(){} public Hero(String uid,int heroTid){ @@ -38,7 +42,7 @@ public class Hero extends MongoBase { if(skillIds!=null && skillIds.isEmpty()){ this.skillList.addAll(skillIds); } - + this.curHp = HeroLogic.getInstance().calHeroAttribute(this, GlobalsDef.HP_TYPE); } public void upStar(int upStar) throws Exception { @@ -67,6 +71,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); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/MapManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/MapManager.java index 52b77ff4d..46afbc7b2 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/MapManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/MapManager.java @@ -7,6 +7,7 @@ import com.ljsd.jieling.handler.map.Cell; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -16,7 +17,7 @@ public class MapManager extends MongoBase { private int curXY; - private Map heroHps; + private Set heroes; private Map mapInfo; @@ -74,12 +75,12 @@ public class MapManager extends MongoBase { this.typeEight = typeEight; } - public Map getHeroHps() { - return heroHps; + public Set getHeroes() { + return heroes; } - public void setHeroHps(Map heroHps) throws Exception { - updateString( "heroHps", heroHps); - this.heroHps = heroHps; + public void setHeroes(Set heroes) throws Exception { + updateString( "heroes", heroes); + this.heroes = heroes; } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index dfe36e9b6..2787c5d51 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -369,10 +369,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: diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/CellUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/CellUtil.java index 8f109d7e2..1499fb52a 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/CellUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/CellUtil.java @@ -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 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; + } + + }