地图修改
parent
9b40fd7e62
commit
51ae768167
|
@ -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() {
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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<Integer, SMapPointConfig> sMapPointConfigMap;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
sMapPointConfigMap = STableManager.getConfig(SMapPointConfig.class);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<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);
|
||||
|
@ -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<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;
|
||||
}
|
||||
}
|
||||
|
@ -181,97 +223,110 @@ public class MapLogic {
|
|||
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(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<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.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<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.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<CommonProto.Item> rewards = new ArrayList<>();
|
||||
if (reward != null && reward.length > 0) {
|
||||
// ItemUtil.drop()
|
||||
Map<Integer, Integer> itemMap = new HashMap<>();
|
||||
// ItemUtil.addItem(user, itemMap);
|
||||
}
|
||||
|
|
|
@ -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<Equip> 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);
|
||||
|
|
|
@ -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<String, Integer> heroHps;
|
||||
private Set<String> heroes;
|
||||
|
||||
private Map<Integer, Cell> mapInfo;
|
||||
|
||||
|
@ -74,12 +75,12 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue