Task 【ID1005460】 【玩法需求】猎妖之路

back_recharge
zhangshanxue 2020-02-09 19:48:55 +08:00
parent 8d640e290b
commit 4769cadda1
44 changed files with 1911 additions and 107 deletions

View File

@ -11,6 +11,7 @@ public enum FightType {
MonterFight(8), // 兽潮
TOPFight(9), // 巅峰赛
GuildBossFight(10), // 工会boss
EXPEDITION(11), // 远征
;

View File

@ -215,6 +215,10 @@ public class MathUtils {
* @return
*/
public static int[] randomFromWeightWithTaking(int[][] array,int count){
if(array.length<count){
throw new IllegalArgumentException(array.length+"<"+count);
}
if(count==1){
return new int[]{randomFromWeight(array)};
}
@ -283,4 +287,35 @@ public class MathUtils {
return b;
}
public static List<Integer> combineList(int start,int end){
List<Integer> list = new ArrayList<>();
while (start<=end){
list.add(start);
start++;
}
Collections.shuffle(list);
return list;
}
/**
*
*/
public static List<Integer> average(int sum, int split) {
List<Integer> result = new ArrayList<>();
if (split == 0) {
LOGGER.error("randomForOneArray::IllegalArgumentException");
return result;
}
int remain = sum % split;
int out = split - remain;
int item = (sum+out) / split;
for (int i = 0; i < split; i++) {
int innerItem = i == 0 ? item-out : item;
result.add(innerItem);
}
return result;
}
}

View File

@ -35,6 +35,7 @@ public class CommonStaticConfig extends AbstractClassStaticConfig {
public Map<Integer, List<int[]>> matrixforGroupInfo;
public static Map<Integer, Map<Integer,Integer>> type2lay2weight;
@Override
public void registConfigs(Set<String> registConfigs) {
registConfigs.add(SGameSetting.class.getAnnotation(Table.class).name());
@ -44,6 +45,7 @@ public class CommonStaticConfig extends AbstractClassStaticConfig {
registConfigs.add(SWorkShopSetting.class.getAnnotation(Table.class).name());
registConfigs.add(SWorkShopSetting.class.getAnnotation(Table.class).name());
registConfigs.add(SChampionshipSetting.class.getAnnotation(Table.class).name());
registConfigs.add(SExpeditionFloorConfig.class.getAnnotation(Table.class).name());
}
@Override
@ -188,7 +190,22 @@ public class CommonStaticConfig extends AbstractClassStaticConfig {
LOGGER.error("SWorkShopTechnology init fail",e);
}
try {
type2lay2weight= new HashMap<>();
Map<Integer, SExpeditionFloorConfig> config = STableManager.getConfig(SExpeditionFloorConfig.class);
config.forEach((integer, sExpeditionFloorConfig) -> {
int layid = sExpeditionFloorConfig.getId();
int[][] randomNode = sExpeditionFloorConfig.getRandomNode();
for (int[] aRandomNode : randomNode) {
Map<Integer, Integer> orDefault = type2lay2weight.getOrDefault(aRandomNode[0], new HashMap<>());
orDefault.put(layid, aRandomNode[1]);
type2lay2weight.put(aRandomNode[0], orDefault);
}
});
} catch (Exception e) {
LOGGER.error("SWorkShopTechnology init fail",e);
}
}

View File

@ -0,0 +1,39 @@
package com.ljsd.jieling.config.clazzStaticCfg;
import config.SExpeditionFloorConfig;
import manager.AbstractClassStaticConfig;
import manager.STableManager;
import manager.Table;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Description: des
* Author: zsx
* CreateDate: 2020/1/9 11:08
*/
public class PlayStaticConfig extends AbstractClassStaticConfig {
private static Map<Integer,int[][]> expeditioonRewardBoxMap;
@Override
public void registConfigs(Set<String> registConfigs) {
registConfigs.add(SExpeditionFloorConfig.class.getAnnotation(Table.class).name());
}
@Override
public void figureConfigs() {
expeditioonRewardBoxMap= new HashMap<>();
Map<Integer, SExpeditionFloorConfig> sExpeditionFloorConfigMap = STableManager.getConfig(SExpeditionFloorConfig.class);
for(SExpeditionFloorConfig sExpeditionFloorConfig : sExpeditionFloorConfigMap.values()){
if(sExpeditionFloorConfig.getTreasureBox().length!=0){
expeditioonRewardBoxMap.put(sExpeditionFloorConfig.getId(),sExpeditionFloorConfig.getTreasureBox());
}
}
}
public static Map<Integer, int[][]> getExpeditioonRewardBoxMap() {
return expeditioonRewardBoxMap;
}
}

View File

@ -82,7 +82,8 @@ public interface GlobalsDef {
int ARENA_PLAYER_TYPE=1;
//队伍
int TEAM_ARENA_DEFENSE =101;
int TEAM_ARENA_DEFENSE =101;//竞技场防御编队
int TEAM_ARENA_ATTACH =201;//竞技场进攻编队
int BLOODY_TEAM =701; //血战队伍
int CHAMPION_ATTACK_TEAM =801; //
int GUILD_BOSS_TEAM =901; //工会boss队伍

View File

@ -40,6 +40,6 @@ public interface VipPrivilegeType {
int GUILD_BOSS_CHALLENGE_TIMES = 37; //公会boss挑战次数
int UNLOCK_GUILD_BOSS_SWEEP = 1002; //公会boss扫荡
int EXPEDITION_RELIVE = 1003; //猎妖之路免费复活次数
}

View File

@ -93,6 +93,7 @@ public class RedisKey {
public static final String GUILD_MONSTER_FIGHT = "GUILD_MONSTER_FIGHT";
public static final String SUDDLENLY_FIGHT = "SUDDLENLY_FIGHT";
public static final String CHALLENGE_MONSTER_ATTACK = "CHALLENGE_MONSTER_ATTACK";
public static final String CHALLENGE_EXPEDITION_INFO = "CHALLENGE_EXPEDITION_INFO";
@ -125,6 +126,7 @@ public class RedisKey {
public static final String TOWER_RANK = "TOWER_RANK";
public static final String FORCE_RANK = "FORCE_RANK";
public static final String AREDEF_TEAM_FORCE_RANK = "AREDEF_TEAM_FORCE_RANK";
public static final String EXPERT_RANK = "EXPERT_RANK";
public static final String MAIN_LEVEL_RANK = "MAIN_LEVEL_RANK";

View File

@ -867,6 +867,20 @@ public class RedisUtil {
}
public Set<ZSetOperations.TypedTuple<String>> rangeByScoreWithScores(String type,String key, double start, double end){
String rkey = getKey(type, key);
for (int i = 0; i < MAX_TRY_TIMES; i++) {
try {
return redisTemplate.opsForZSet().reverseRangeByScoreWithScores(rkey, start, end);
} catch (Exception e) {
TimeUtils.sleep(FAILED_SLEEP);
}
}
return null;
}
public Long getZSetreverseRank(String type,String key, String value){
String rkey = getKey(type,key);
for (int i = 0; i < MAX_TRY_TIMES; i++) {

View File

@ -104,7 +104,7 @@ public interface BIReason {
int GUILD_BOSS_FIGHT_REWARD = 61;//工会boss奖励
int EXPEDITION_BOX_REWARD = 63;//猎妖之路宝箱奖励
int EXPEDITION_DROP_REWARD = 64;//猎妖之路奖励
int CHAMPIONM_EXCHANGE_REWARD = 1050;//巅峰赛兑换奖励

View File

@ -0,0 +1,211 @@
package com.ljsd.jieling.handler.Expedition;
import com.ljsd.fight.CheckFight;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.expedition.ExpeditionLogic;
import com.ljsd.jieling.logic.fight.DefFightSnapData;
import com.ljsd.jieling.logic.fight.FightUtil;
import com.ljsd.jieling.logic.fight.GameFightType;
import com.ljsd.jieling.logic.fight.PVPFightEvent;
import com.ljsd.jieling.logic.fight.result.FightResult;
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
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.Expedition;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.FightDataUtil;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import config.SExpeditionFloorConfig;
import config.SExpeditionHolyConfig;
import config.SExpeditionSetting;
import manager.STableManager;
import org.luaj.vm2.LuaValue;
import java.util.*;
/**
* Description:
* Author: zsx
* CreateDate: 2020/1/9 11:26
*/
public class EndExpeditionBattleRequest extends BaseHandler<Expedition.EndExpeditionBattleRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.EXPEDITION_END_BATTLE_REQUEST;
}
@Override
public void processWithProto(ISession session, Expedition.EndExpeditionBattleRequest proto) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
int proNodeId = proto.getNodeId();
String key = RedisKey.getKey(RedisKey.CHALLENGE_EXPEDITION_INFO, String.valueOf(session.getUid()), false);
String fightInfos = (String) RedisUtil.getInstence().get(key);
if (fightInfos == null || fightInfos.isEmpty()) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
String[] split = fightInfos.split("#");
if(split.length!=3){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
int nodeId = Integer.parseInt(split[0]);
int seed = Integer.parseInt(split[1]);
int teamId = Integer.parseInt(split[2]);
//check node
if (proNodeId != nodeId) {
throw new ErrorCodeException(ErrorCode.newDefineCode("结算失败"));
}
if (!user.getExpeditionManager().getExpeditionNodeInfos().containsKey(nodeId)) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点不存在"));
}
ExpeditionNodeInfo nodeInfo = user.getExpeditionManager().getExpeditionNodeInfos().get(nodeId);
if (!ExpeditionLogic.isBattleNode(nodeInfo.getType())) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点类型不符" + nodeInfo.getType()));
}
if (nodeInfo.getState() != ExpeditionLogic.NODESTATE_NOT_PASS) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点状态不正确" + nodeInfo.getState()));
}
//fight result
SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1);
if (sExpeditionSetting == null) {
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
int maxTime = sExpeditionSetting.getFightTime();
CommonProto.FightTeamInfo fightTeamInfo = FightUtil.makePersonFightDataWithDouble(user,teamId,user.getExpeditionManager().getHeroHP());
SnapFightInfo deffightInfo = nodeInfo.getSnapFightInfo();
//TODO 添加被动技能
ExpeditionManager expeditionManager = user.getExpeditionManager();
Set<SExpeditionHolyConfig> expeditionHolyConfigs = ExpeditionLogic.getFirstRankHoly(expeditionManager);
StringBuilder passiveSkillResult = new StringBuilder();
if(deffightInfo.getPassiveSkills().length()!=0){
passiveSkillResult.append("|");
}
for (SExpeditionHolyConfig config:expeditionHolyConfigs) {
passiveSkillResult.append(String.valueOf(config.getPassiveSkillId())).append("|");
}
String holySkill = passiveSkillResult.length()!=0?passiveSkillResult.substring(0,passiveSkillResult.length()-1):"";
CommonProto.FightTeamInfo deffightTeamInfo = FightUtil.makeFightBySnapDataWithDouble(new DefFightSnapData(deffightInfo.getHeroAttribute(),deffightInfo.getHeroSkills(),deffightInfo.getPokenmonSkills(),deffightInfo.getPassiveSkills()+holySkill),nodeInfo.getBossHP());
LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo);
LuaValue getOptionData = FightDataUtil.getOptionData("");
int[] checkResult = CheckFight.getInstance().checkFight(seed, maxTime, getFightData, getOptionData, GameFightType.Expediton.getFightType());
int resultCode = checkResult[0];
if (resultCode == -1) {
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
}
List<Integer> remainHp = new ArrayList<>(5);
for (int i = 2; i < checkResult.length; i++) {
if (checkResult[i] <= 0) {
remainHp.add(0);
} else {
remainHp.add(checkResult[i]);
}
}
//更新节点状态 节点
final int oldlay = nodeInfo.getLay();
Set<CommonProto.ExpeditionNodeInfo> nodeInfos = new HashSet<>();
user.getExpeditionManager().getExpeditionNodeInfos().forEach((s, nodeInfo1) -> {
if (nodeInfo1.getLay() != oldlay) {
return;
}
CommonProto.ExpeditionNodeInfo.Builder build = CommonProto.ExpeditionNodeInfo.newBuilder()
.setSortId(nodeInfo1.getSortId())
.setState(nodeInfo1.getState());
if (nodeInfo1.getSortId() == nodeId) {
build.setBossTeaminfo(ExpeditionLogic.getExpeditionTeamInfoProto(nodeInfo1));
}else {
return;
}
nodeInfos.add(build.build());
});
Set<String> ids = new HashSet<>();
if (resultCode != 1) {
// 更新队伍血量
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) {
Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId());
if (hero == null) {
continue;
}
user.getExpeditionManager().getHeroHPWithChange().put(hero.getId(), 0d);
ids.add(hero.getId());
}
//节点血量更新
nodeInfo.getSnapFightInfo().getHeroAttribute().forEach((s, familyHeroInfo) ->
nodeInfo.getBossHP().put(s, (double) remainHp.remove(0) / (double) familyHeroInfo.getAttribute().get(HeroAttributeEnum.CurHP.getPropertyId()))
);
//更新节点
Expedition.ExpeditionNodeInfoIndication.Builder builder = Expedition.ExpeditionNodeInfoIndication.newBuilder();
builder.addAllNodeInfo(nodeInfos);
builder.addAllHeroInfo(ExpeditionLogic.getInstance().getAllHeroInfo(user,ids));
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.EXPEDITION_NOINFO_INDICATION_VALUE, builder.build(), true);
Expedition.EndExpeditionBattleResponse.Builder response = Expedition.EndExpeditionBattleResponse.newBuilder();
response.setResult(resultCode);
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.EXPEDITION_END_BATTLE_RESONSE_VALUE, response.build(), true);
System.out.print( response.build());
return;
} else {
//节点血量更新
nodeInfo.getSnapFightInfo().getHeroAttribute().forEach((s, familyHeroInfo) ->
nodeInfo.getBossHP().put(s, 0d)
);
// 更新队伍血量
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) {
Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId());
if (hero == null) {
continue;
}
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, teamId);
user.getExpeditionManager().getHeroHPWithChange().put(teamPosHeroInfo.getHeroId(), (double) remainHp.remove(0) / (double) heroAttributeMap.get(HeroAttributeEnum.CurHP.getPropertyId()));
ids.add(hero.getId());
}
nodeInfo.setState(ExpeditionLogic.NODESTATE_NOT_GET);
}
//更新节点
Expedition.ExpeditionNodeInfoIndication.Builder builder = Expedition.ExpeditionNodeInfoIndication.newBuilder();
builder.addAllNodeInfo(nodeInfos);
builder.addAllHeroInfo(ExpeditionLogic.getInstance().getAllHeroInfo(user,ids));
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.EXPEDITION_NOINFO_INDICATION_VALUE, builder.build(), true);
//drop
SExpeditionFloorConfig sExpeditionFloorConfig = STableManager.getConfig(SExpeditionFloorConfig.class).get(oldlay);
if (sExpeditionFloorConfig == null) {
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sExpeditionFloorConfig.getReward(), BIReason.EXPEDITION_DROP_REWARD);
Expedition.EndExpeditionBattleResponse.Builder response = Expedition.EndExpeditionBattleResponse.newBuilder();
response.setResult(resultCode);
response.setDrop(drop);
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.EXPEDITION_END_BATTLE_RESONSE_VALUE, response.build(), true);
}
}

View File

@ -0,0 +1,36 @@
package com.ljsd.jieling.handler.Expedition;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.ExpeditionManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.expedition.ExpeditionLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.Expedition;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import com.ljsd.jieling.util.MessageUtil;
/**
* Description:
* Author: zsx
* CreateDate: 2020/1/9 11:26
*/
public class GetExpeditionRequestHandler extends BaseHandler<PlayerInfoProto.GetExpertInfoRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.EXPEDITION_GET_EXPEDITION_REQUEST;
}
@Override
public void processWithProto(ISession iSession, PlayerInfoProto.GetExpertInfoRequest proto) throws Exception {
User user = UserManager.getUser(iSession.getUid());
ExpeditionManager manager = user.getExpeditionManager();
Expedition.GetExpeditionResponse.Builder builder = Expedition.GetExpeditionResponse.newBuilder();
builder.addAllLay(manager.getRewardBox());
builder.addAllHeroInfo(ExpeditionLogic.getInstance().getAllHeroInfo(user));
builder.addAllNodeInfo(ExpeditionLogic.getInstance().getNodeInfo(user));
builder.addAllEquipIds(ExpeditionLogic.getInstance().getEquipnfo(user));
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.EXPEDITION_GET_EXPEDITION_RESONSE_VALUE, builder.build(), true);
}
}

View File

@ -0,0 +1,72 @@
package com.ljsd.jieling.handler.Expedition;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.ExpeditionNodeInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.expedition.ExpeditionLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Expedition;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.MessageUtil;
import config.SExpeditionSetting;
import manager.STableManager;
import java.util.HashSet;
import java.util.Set;
/**
* Description:
* Author: zsx
* CreateDate: 2020/1/9 11:26
*/
public class ReCoverExpeditionHeroRequestHandler extends BaseHandler<Expedition.ReCoverExpeditionHeroRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.EXPEDITION_RECOVER_HERO_REQUEST;
}
@Override
public void processWithProto(ISession iSession, Expedition.ReCoverExpeditionHeroRequest proto) throws Exception {
User user = UserManager.getUser(iSession.getUid());
int nodeId = proto.getNodeId();
if (!user.getExpeditionManager().getExpeditionNodeInfos().containsKey(nodeId)) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点不存在"));
}
ExpeditionNodeInfo nodeInfo = user.getExpeditionManager().getExpeditionNodeInfos().get(nodeId);
if (ExpeditionLogic.NODETYPE_RECOVER != nodeInfo.getType()) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点类型不符"));
}
if (nodeInfo.getState() != ExpeditionLogic.NODESTATE_NOT_PASS) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点状态不正确"));
}
//updata node
Set<CommonProto.ExpeditionNodeInfo> nodeInfos = ExpeditionLogic.openLay(user,nodeInfo.getLay(),nodeId);
//更新节点
Expedition.ExpeditionNodeInfoIndication.Builder builder = Expedition.ExpeditionNodeInfoIndication.newBuilder();
builder.addAllNodeInfo(nodeInfos);
MessageUtil.sendIndicationMessage(iSession, 1, MessageTypeProto.MessageType.EXPEDITION_NOINFO_INDICATION_VALUE, builder.build(), true);
Set<CommonProto.ExpeditionSimpleHeroInfo> set = new HashSet<>();
user.getExpeditionManager().getHeroHPWithChange().forEach((s, aDouble) -> {
if(aDouble==0d){
return;
}
int reCoverHp = STableManager.getConfig(SExpeditionSetting.class).get(1).getRegeneratePercent();
double reCoverPer = reCoverHp/10000d;
double add = aDouble+reCoverPer>1?1:(aDouble+reCoverPer);
user.getExpeditionManager().getHeroHPWithChange().put(s,add);
set.add(CommonProto.ExpeditionSimpleHeroInfo.newBuilder().setHeroId(s).setRemainHp(add).build());
});
Expedition.ReCoverExpeditionHeroResponse.Builder build = Expedition.ReCoverExpeditionHeroResponse.newBuilder().addAllHeroInfo(set);
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.EXPEDITION_RECOVER_HERO_RESONSE_VALUE, build.build(), true);
}
}

View File

@ -0,0 +1,102 @@
package com.ljsd.jieling.handler.Expedition;
import com.ljsd.jieling.core.VipPrivilegeType;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.ExpeditionNodeInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.expedition.ExpeditionLogic;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Expedition;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.MessageUtil;
import config.SExpeditionSetting;
import manager.STableManager;
import java.util.HashSet;
import java.util.Set;
/**
* Description:
* Author: zsx
* CreateDate: 2020/1/9 11:26
*/
public class ReliveExpeditionHeroRequest extends BaseHandler<Expedition.ReliveExpeditionHeroRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.EXPEDITION_RELIVE_HERO_REQUEST;
}
@Override
public void processWithProto(ISession iSession, Expedition.ReliveExpeditionHeroRequest proto) throws Exception {
User user = UserManager.getUser(iSession.getUid());
int nodeId = proto.getNodeId();
String heroId = proto.getHeroId();
if (nodeId == -1) {
//使用道具复活
//check 道具
boolean check = PlayerLogic.getInstance().check(user, VipPrivilegeType.EXPEDITION_RELIVE, 1);
if(!check){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
PlayerLogic.getInstance().checkAndUpdate(user, VipPrivilegeType.EXPEDITION_RELIVE, 1);
relive(user,heroId);
//更新节点
Expedition.ExpeditionNodeInfoIndication.Builder builder = Expedition.ExpeditionNodeInfoIndication.newBuilder();
HashSet<String> heroSet = new HashSet<>();
heroSet.add(heroId);
builder.addAllHeroInfo(ExpeditionLogic.getInstance().getAllHeroInfo(user,heroSet));
MessageUtil.sendIndicationMessage(iSession, 1, MessageTypeProto.MessageType.EXPEDITION_NOINFO_INDICATION_VALUE, builder.build(), true);
} else {
if (!user.getExpeditionManager().getExpeditionNodeInfos().containsKey(nodeId)) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点不存在"));
}
ExpeditionNodeInfo nodeInfo = user.getExpeditionManager().getExpeditionNodeInfos().get(nodeId);
if (ExpeditionLogic.NODETYPE_RELIVE != nodeInfo.getType()) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点类型不符"+nodeInfo.getType()));
}
if (nodeInfo.getState() != ExpeditionLogic.NODESTATE_NOT_PASS) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点状态不正确"+nodeInfo.getState()));
}
//updata node
Set<CommonProto.ExpeditionNodeInfo> nodeInfos = ExpeditionLogic.openLay(user,nodeInfo.getLay(),nodeId);
relive(user,heroId);
//更新节点
Expedition.ExpeditionNodeInfoIndication.Builder builder = Expedition.ExpeditionNodeInfoIndication.newBuilder();
builder.addAllNodeInfo(nodeInfos);
HashSet<String> heroSet = new HashSet<>();
heroSet.add(heroId);
builder.addAllHeroInfo(ExpeditionLogic.getInstance().getAllHeroInfo(user,heroSet));
MessageUtil.sendIndicationMessage(iSession, 1, MessageTypeProto.MessageType.EXPEDITION_NOINFO_INDICATION_VALUE, builder.build(), true);
}
Expedition.ReliveExpeditionHeroResponse build = Expedition.ReliveExpeditionHeroResponse.newBuilder()
.setHeroInfo(CommonProto.ExpeditionSimpleHeroInfo.newBuilder().setHeroId(heroId).setRemainHp(1d).build()).build();
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.EXPEDITION_RELIVE_HERO_RESONSE_VALUE, build, true);
}
private void relive(User user,String heroId)throws Exception{
int reCoverHp = STableManager.getConfig(SExpeditionSetting.class).get(1).getRevive()[1];
double reCoverPer = reCoverHp/10000d;
if(null != heroId||!heroId.isEmpty()){
if (user.getExpeditionManager().getHeroHP().getOrDefault(heroId, 0d) == 0) {
user.getExpeditionManager().getHeroHPWithChange().put(heroId, reCoverPer);
} else {
throw new ErrorCodeException(ErrorCode.newDefineCode("英雄复活失败 英雄还存活"));
}
}
}
}

View File

@ -0,0 +1,112 @@
package com.ljsd.jieling.handler.Expedition;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.ExpeditionNodeInfo;
import com.ljsd.jieling.logic.dao.SnapFightInfo;
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.expedition.ExpeditionLogic;
import com.ljsd.jieling.logic.fight.DefFightSnapData;
import com.ljsd.jieling.logic.fight.FightUtil;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Expedition;
import com.ljsd.jieling.protocols.FightInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.MessageUtil;
import config.SExpeditionSetting;
import manager.STableManager;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Description:
* Author: zsx
* CreateDate: 2020/1/9 11:26
*/
public class StartExpeditionBattleRequest extends BaseHandler<Expedition.StartExpeditionBattleRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.EXPEDITION_START_BATTLE_REQUEST;
}
@Override
public void processWithProto(ISession iSession, Expedition.StartExpeditionBattleRequest proto) throws Exception {
User user = UserManager.getUser(iSession.getUid());
int nodeId = proto.getNodeId();
int teamId = proto.getTeamId();
//cfg check
if (!user.getExpeditionManager().getExpeditionNodeInfos().containsKey(nodeId)) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点不存在"));
}
ExpeditionNodeInfo nodeInfo = user.getExpeditionManager().getExpeditionNodeInfos().get(nodeId);
if (!ExpeditionLogic.isBattleNode(nodeInfo.getType())) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点类型不符"+nodeInfo.getType()));
}
if (nodeInfo.getState() != ExpeditionLogic.NODESTATE_NOT_PASS) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点状态不正确"+nodeInfo.getState()));
}
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
if (teamPosHeroInfos == null || teamPosHeroInfos.size() == 0) {
throw new ErrorCodeException(ErrorCode.newDefineCode("阵容有误!!"));
}
SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1);
if(sExpeditionSetting==null){
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
int maxTime = sExpeditionSetting.getFightTime();
User inMem = UserManager.getUserInMem(iSession.getUid());
//更新节点
Set<CommonProto.ExpeditionNodeInfo> nodeInfos = new HashSet<>();
user.getExpeditionManager().getExpeditionNodeInfos().forEach((s, nodeInfo1) -> {
if (nodeInfo1.getLay() != nodeInfo.getLay()) {
return;
}
CommonProto.ExpeditionNodeInfo.Builder build = CommonProto.ExpeditionNodeInfo.newBuilder()
.setSortId(nodeInfo1.getSortId())
.setState(nodeInfo1.getState());
if (nodeInfo1.getSortId() != nodeId) {
nodeInfo1.setState(ExpeditionLogic.NODESTATE_CLOSE);
}else {
return;
}
nodeInfos.add(build.build());
});
//更新节点
Expedition.ExpeditionNodeInfoIndication.Builder builder = Expedition.ExpeditionNodeInfoIndication.newBuilder();
builder.addAllNodeInfo(nodeInfos);
MessageUtil.sendIndicationMessage(iSession, 1, MessageTypeProto.MessageType.EXPEDITION_NOINFO_INDICATION_VALUE, builder.build(), true);
//notify client
CommonProto.FightTeamInfo fightTeamInfo = FightUtil.makePersonFightDataWithDouble(inMem,teamId,user.getExpeditionManager().getHeroHP());
SnapFightInfo deffightInfo = nodeInfo.getSnapFightInfo();
CommonProto.FightTeamInfo deffightTeamInfo = FightUtil.makeFightBySnapDataWithDouble(new DefFightSnapData(deffightInfo.getHeroAttribute(),deffightInfo.getHeroSkills(),deffightInfo.getPokenmonSkills(),deffightInfo.getPassiveSkills()),nodeInfo.getBossHP());
int seed = (int)(System.currentTimeMillis()/1000);
String fightInfo = nodeId + "#" +seed+ "#" + teamId;
String key = RedisKey.getKey(RedisKey.CHALLENGE_EXPEDITION_INFO, String.valueOf(iSession.getUid()), false);
RedisUtil.getInstence().set(key, fightInfo, -1);
FightInfoProto.FightStartResponse.Builder fightStartResponse = FightInfoProto.FightStartResponse.newBuilder();
fightStartResponse.setFightData(CommonProto.FightData.newBuilder()
.setFightMaxTime(maxTime)
.setFightSeed(seed)
.setHeroFightInfos(fightTeamInfo)
.addMonsterList(deffightTeamInfo)
.build());
MessageUtil.sendMessage(iSession, 1,MessageTypeProto.MessageType.EXPEDITION_START_BATTLE_RESONSE_VALUE, fightStartResponse.build(), true);
}
}

View File

@ -0,0 +1,89 @@
package com.ljsd.jieling.handler.Expedition;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.ExpeditionItem;
import com.ljsd.jieling.logic.dao.ExpeditionManager;
import com.ljsd.jieling.logic.dao.ExpeditionNodeInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.expedition.ExpeditionLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Expedition;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.MessageUtil;
import config.SExpeditionHolyConfig;
import manager.STableManager;
import java.util.Map;
import java.util.Set;
/**
* Description: des
* Author: zsx
* CreateDate: 2020/1/9 11:27
*/
public class TakeHolyEquipRequest extends BaseHandler<Expedition.TakeHolyEquipRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.EXPEDITION_TAKE_HOLY_EQUIP_REQUEST;
}
@Override
public void processWithProto(ISession iSession, Expedition.TakeHolyEquipRequest proto) throws Exception {
User user = UserManager.getUser(iSession.getUid());
int nodeId = proto.getNodeId();
int itemId = proto.getType();
//cfg check
if (!user.getExpeditionManager().getExpeditionNodeInfos().containsKey(nodeId)) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点不存在"));
}
ExpeditionNodeInfo nodeInfo = user.getExpeditionManager().getExpeditionNodeInfos().get(nodeId);
if (!ExpeditionLogic.isBattleNode( nodeInfo.getType())) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点类型不符"+nodeInfo.getType()));
}
if (nodeInfo.getState() != ExpeditionLogic.NODESTATE_NOT_GET) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点状态不正确"+nodeInfo.getState()));
}
SExpeditionHolyConfig sExpeditionHolyConfig = STableManager.getConfig(SExpeditionHolyConfig.class).get(itemId);
if(sExpeditionHolyConfig==null){
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
//updata node
Set<CommonProto.ExpeditionNodeInfo> nodeInfos = ExpeditionLogic.openLay(user,nodeInfo.getLay(),nodeId);
//更新背包
ExpeditionItem expeditionItem = new ExpeditionItem(iSession.getUid(), itemId);
ExpeditionManager expeditionManager = user.getExpeditionManager();
expeditionManager.addPropertyItems(expeditionItem);
//更新effectitem 参与计算
if(expeditionManager.getEffectItems().size()==0){
ExpeditionLogic.getFirstRankHoly(expeditionManager);
}
Map<Integer,SExpeditionHolyConfig> effectItems = expeditionManager.getEffectItems();
SExpeditionHolyConfig orDefault = effectItems.getOrDefault(sExpeditionHolyConfig.geteffect(), null);
if(null!=orDefault&&sExpeditionHolyConfig.gettype()>orDefault.gettype()){
effectItems.put(sExpeditionHolyConfig.geteffect(),sExpeditionHolyConfig);
}
//notify client
Expedition.ExpeditionEquipIndication.Builder indication = Expedition.ExpeditionEquipIndication.newBuilder();
indication.addEquipIds(CommonProto.ExpeditionEquip.newBuilder().setId(expeditionItem.getId()).setEquiptId(expeditionItem.getEquipId()).build());
MessageUtil.sendIndicationMessage(iSession, 1, MessageTypeProto.MessageType.EXPEDITION_HOLY_BAG_INDICATION_VALUE, indication.build(), true);
Expedition.ExpeditionNodeInfoIndication.Builder builder = Expedition.ExpeditionNodeInfoIndication.newBuilder();
builder.addAllNodeInfo(nodeInfos);
MessageUtil.sendIndicationMessage(iSession, 1, MessageTypeProto.MessageType.EXPEDITION_NOINFO_INDICATION_VALUE, builder.build(), true);
Expedition.TakeHolyEquipResponse.Builder build = Expedition.TakeHolyEquipResponse.newBuilder().setEquipId(expeditionItem.getId());
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.EXPEDITION_TAKE_HOLY_EQUIP_RESONSE_VALUE, build.build(), true);
}
}

View File

@ -1,44 +1,56 @@
package com.ljsd.jieling.handler.Expedition;
import com.ljsd.jieling.config.clazzStaticCfg.PlayStaticConfig;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.PlayerManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Expedition;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import java.util.Map;
/**
* Description: des
* Description:
* Author: zsx
* CreateDate: 2020/1/7 16:23
*/
public class TakeLayRewardHandler extends BaseHandler<Expedition.TakeExpeditionBoxRewardRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return null;
return MessageTypeProto.MessageType.EXPEDITION_TAKE_BOXREWARD_REQUEST;
}
@Override
public void processWithProto(ISession iSession, Expedition.TakeExpeditionBoxRewardRequest proto) throws Exception {
User user = UserManager.getUser(iSession.getUid());
int lay = proto.getLay();
//check condition
if(user.getExpeditionManager().getLay()<=lay){
throw new ErrorCodeException(ErrorCode.newDefineCode("条件未达成"));
}
//TODO cfg check
//up miss
// int[][] reward ;
// CommonProto.Drop.Builder drop = ItemUtil.drop(user, reward, BIReason.TAKE_ACTIVITY_REWARD);
//
//
//
// PlayerInfoProto.TakeActivityRewardResponse build = PlayerInfoProto.TakeActivityRewardResponse.newBuilder().setDrop(drop).build();
// MessageUtil.sendMessage(iSession, 1, rewardResponseValue, build, true);
//check cfg
Map<Integer,int[][]> boxMap = PlayStaticConfig.getExpeditioonRewardBoxMap();
if(null ==boxMap||!boxMap.containsKey(lay)){
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
if(user.getExpeditionManager().getRewardBox().contains(lay)){
throw new ErrorCodeException(ErrorCode.newDefineCode("已领取"));
}
user.getExpeditionManager().addRewardBox(lay);
//drop
int[][] reward = boxMap.get(lay);
CommonProto.Drop.Builder drop = ItemUtil.drop(user, reward, BIReason.EXPEDITION_BOX_REWARD);
//notify
Expedition.TakeExpeditionBoxRewardResponse builder = Expedition.TakeExpeditionBoxRewardResponse.newBuilder().setDrop(drop).build();
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.EXPEDITION_TAKE_BOXREWARD_RESONSE_VALUE, builder, true);
}
}

View File

@ -1,9 +1,6 @@
package com.ljsd.jieling.handler.map;
import com.ljsd.jieling.logic.dao.Equip;
import com.ljsd.jieling.logic.dao.EspecialEquip;
import com.ljsd.jieling.logic.dao.Item;
import com.ljsd.jieling.logic.dao.SoulEquip;
import com.ljsd.jieling.logic.dao.*;
import java.util.HashMap;
import java.util.HashSet;
@ -20,4 +17,5 @@ public class TemporaryItems {
public Set<SoulEquip> soulEquips = new HashSet<>();
}

View File

@ -284,7 +284,52 @@ public class BehaviorUtil {
.build();
}
/**
* FightUnitInfo
* @param user
* @param teamId
* @param attackBloodMap
* @return
*/
public static CommonProto.FightTeamInfo getFightTeamInfoWithDouble(User user, int teamId, Map<String, Double> attackBloodMap) {
user.getTeamPosManager().setCurTeamPosId(teamId);
List<CommonProto.FightUnitInfo> heroFightInfos = new ArrayList<>();
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) {
Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId());
if (hero == null) {
continue;
}
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, teamId);
if(attackBloodMap.containsKey(teamPosHeroInfo.getHeroId())){
heroAttributeMap.put(HeroAttributeEnum.CurHP.getPropertyId(),(int)(attackBloodMap.getOrDefault(teamPosHeroInfo.getHeroId(),1d)*heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId())));
}
StringBuilder skillSb = new StringBuilder();
StringBuilder propertySb = new StringBuilder();
String heroSkill = HeroLogic.getInstance().getHeroSkills(user,hero,skillSb).toString();
String property = HeroLogic.getInstance().getHeroPropertyBuilder(propertySb, hero, heroAttributeMap).toString();
CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo
.newBuilder()
.setUnitId(Integer.toString(hero.getTemplateId()))
.setUnitSkillIds(heroSkill.substring(0,heroSkill.length()-1))
.setProperty(property.substring(0, property.length()-1))
.build();
heroFightInfos.add(heroFightInfo);
}
return CommonProto.FightTeamInfo.
newBuilder()
.addAllFightUnitList(heroFightInfos)
.setTeamSkillList(HeroLogic.getInstance().getPokenmonSkills(user,teamId))
.setTeamPassiveList(HeroLogic.getInstance().getPokenmonPassiveSkills(user,teamId))
.build();
}
public static CommonProto.FightTeamInfo getRobotFightTeamInfo(SArenaRobotConfig sArenaRobotConfig) {
return getRobotFightTeamInfo(sArenaRobotConfig,null);
}
public static CommonProto.FightTeamInfo getRobotFightTeamInfo(SArenaRobotConfig sArenaRobotConfig,Map<String,Double> remainHp) {
List<CommonProto.FightUnitInfo> heroFightInfos = new ArrayList<>();
Map<Integer,Integer> heroStarsMap = sArenaRobotConfig.getStarOfHeroMap();
for(Map.Entry<Integer,Integer> item : heroStarsMap.entrySet()){
@ -295,7 +340,17 @@ public class BehaviorUtil {
SCHero scHero = SCHero.getsCHero().get(heroTid);
List<Integer> skillIds = scHero.getSkillListByStar(heroStar);
String heroSkill = HeroLogic.getInstance().getRobotHeroSkills(skillIds,skillSb).toString();
String property = HeroLogic.getInstance().getRobotHeroProperty(sArenaRobotConfig,scHero,propertySb).toString();
int[] differDemonsId = sArenaRobotConfig.getDifferDemonsId();
int differDemonsLv = sArenaRobotConfig.getDifferDemonsLv();
int robotLevel = sArenaRobotConfig.getRoleLv();
Map<Integer, Integer> robotHeroAttribute =HeroLogic.getInstance(). calRobotHeroAttribute(scHero, robotLevel, sArenaRobotConfig.getBreakId(), differDemonsId, differDemonsLv,false);
if(remainHp.containsKey(heroTid.toString())){
robotHeroAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(),(int)(remainHp.getOrDefault(heroTid.toString(),1d)*robotHeroAttribute.get(HeroAttributeEnum.Hp.getPropertyId())));
}
String property = HeroLogic.getInstance().getRobotHeroProperty(sArenaRobotConfig,scHero,propertySb,robotHeroAttribute).toString();
CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo
.newBuilder()
.setUnitId(Integer.toString(heroTid))

View File

@ -9,16 +9,21 @@ import com.ljsd.jieling.protocols.PlayerInfoProto;
import org.springframework.stereotype.Component;
@Component
public class UserForceChangeHandler extends BaseHandler {
public class UserForceChangeHandler extends BaseHandler<PlayerInfoProto.UserForceChangeRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.USER_FORCE_CHANGE_REQUEST;
}
// @Override
// public void process(ISession iSession, PacketNetData netData) throws Exception {
// byte[] bytes = netData.parseClientProtoNetData();
// PlayerInfoProto.UserForceChangeRequest userForceChangeRequest = PlayerInfoProto.UserForceChangeRequest.parseFrom(bytes);
//
// }
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
byte[] bytes = netData.parseClientProtoNetData();
PlayerInfoProto.UserForceChangeRequest userForceChangeRequest = PlayerInfoProto.UserForceChangeRequest.parseFrom(bytes);
public void processWithProto(ISession iSession, PlayerInfoProto.UserForceChangeRequest userForceChangeRequest) throws Exception {
PlayerLogic.getInstance().userforceChange(iSession,userForceChangeRequest.getTeamId());
}
}

View File

@ -0,0 +1,41 @@
package com.ljsd.jieling.kefu;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.logic.dao.ExpeditionNodeInfo;
import com.ljsd.jieling.logic.dao.Hero;
import com.ljsd.jieling.logic.dao.SnapFightInfo;
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.expedition.ExpeditionLogic;
import com.ljsd.jieling.logic.fight.DefFightSnapData;
import com.ljsd.jieling.logic.fight.FightUtil;
import com.ljsd.jieling.logic.fight.GameFightType;
import com.ljsd.jieling.logic.fight.PVPFightEvent;
import com.ljsd.jieling.logic.fight.result.FightResult;
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Expedition;
import com.ljsd.jieling.util.ItemUtil;
import config.SExpeditionFloorConfig;
import config.SExpeditionSetting;
import manager.STableManager;
import java.util.*;
/**
* Description: 线
* Author: zsx .//reset 10041063
* CreateDate: 2019/9/26 11:48
*/
public class Cmd_reset extends GmRoleAbstract {
@Override
public boolean exec(String[] args) throws Exception {
ExpeditionLogic.getInstance().flushUserdataEveryDay(getUser());
return true;
}
}

View File

@ -369,7 +369,7 @@ public class ArenaLogic {
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ARENA_RANDOM_ENEMY_RESPONSE_VALUE,build,true);
}
public Set<Integer> randomRobot(int userSscore,int nums){
public static Set<Integer> randomRobot(int userSscore,int nums){
Set<Integer> robotIds = new HashSet<>(5);
Map<Integer, SArenaRobotSetting> config = STableManager.getConfig(SArenaRobotSetting.class);
for(SArenaRobotSetting sArenaRobotSetting : config.values()){

View File

@ -97,11 +97,19 @@ public class BloodLogic {
* @param heroInfo
* @return
*/
public CommonProto.FightTeamInfo fightDataMakeUp(Map<String ,String> heroSkills ,Map<String, FamilyHeroInfo> heroInfo,String pokmanSkill){
public CommonProto.FightTeamInfo fightDataMakeUp(Map<String ,String> heroSkills ,Map<String, FamilyHeroInfo> heroInfo,String pokmanSkill,String passiveSkill){
return fightDataMakeUp(heroSkills, heroInfo, pokmanSkill, passiveSkill,null);
}
public CommonProto.FightTeamInfo fightDataMakeUp(Map<String ,String> heroSkills ,Map<String, FamilyHeroInfo> heroInfo,String pokmanSkill,String passiveSkill,Map<String,Double> remainHp){
List<CommonProto.FightUnitInfo> heroDefendFightInfos = new ArrayList<>();
for (Map.Entry<String, FamilyHeroInfo> entry : heroInfo.entrySet()) {
StringBuilder propertySb = new StringBuilder();
String heroSkill = heroSkills.get(entry.getKey());
Map<Integer, Integer> heroAttributeMap = entry.getValue().getAttribute();
if(remainHp!=null&&remainHp.containsKey(entry.getKey())){
heroAttributeMap.put(HeroAttributeEnum.CurHP.getPropertyId(),(int)(remainHp.getOrDefault(entry.getKey(),1d)*heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId())));
}
String property = HeroLogic.getInstance().getHeroPropertyBuilder(propertySb, entry.getValue(), entry.getValue().getAttribute()).toString();
CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo
.newBuilder()
@ -115,9 +123,12 @@ public class BloodLogic {
newBuilder()
.addAllFightUnitList(heroDefendFightInfos)
.setTeamSkillList(pokmanSkill)
.setTeamPassiveList(passiveSkill)
.build();
}
/**
*
* @param session

View File

@ -51,8 +51,8 @@ public class ChampionshipLogic {
private static int roundTimes; //比赛进行第几轮
private static int endTime;
private static int endTime;
private static Map<Integer,GameFightType> gameFightTypeMap = new HashMap<>();
static {
gameFightTypeMap.put(0,GameFightType.TOPArenaPersonFight);
@ -692,7 +692,6 @@ public class ChampionshipLogic {
snapOneFightInfo(defUid,memberInfoMap);
long id =FightDispatcher.getFIghtId();
EndFightProcessor endFightProcessor = new AreFightPro();
((AreFightPro) endFightProcessor).setArenaRecord(arenaRecord);
@ -703,13 +702,13 @@ public class ChampionshipLogic {
MemberInfo defMemberInfo = memberInfoMap.get(defUid);
if(defMemberInfo.getType() == 0){
FamilyFightInfo fightInfo = defMemberInfo.getFightInfo();
pvpFightEvent.setDefFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(),fightInfo.getHeroSkills(),fightInfo.getPokenmonSkills()));
pvpFightEvent.setDefFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(),fightInfo.getHeroSkills(),fightInfo.getPokenmonSkills(),fightInfo.getPassiveSkills()));
}
if(attackMemberInfo.getType() == 0){
FamilyFightInfo fightInfo = attackMemberInfo.getFightInfo();
pvpFightEvent.setAttackFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(),fightInfo.getHeroSkills(),fightInfo.getPokenmonSkills()));
}
pvpFightEvent.setAttackFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(),fightInfo.getHeroSkills(),fightInfo.getPokenmonSkills(),fightInfo.getPassiveSkills()));
}
FightDispatcher.dispatcherAsync(pvpFightEvent,id);
}
@ -746,6 +745,8 @@ public class ChampionshipLogic {
}
String pokenmonSkills = HeroLogic.getInstance().getPokenmonSkills(user, snapTeamId);
fightInfo.setPokenmonSkills(pokenmonSkills);
String pokenmonPassiveSkills = HeroLogic.getInstance().getPokenmonPassiveSkills(user, snapTeamId);
fightInfo.setPassiveSkills(pokenmonPassiveSkills);
List<TeamPosForPokenInfo> teamPosForPokenInfos = user.getTeamPosManager().getTeamPosForPoken().get(snapTeamId);
if(teamPosForPokenInfos!=null){
List<Integer> pokens = new ArrayList<>();

View File

@ -0,0 +1,21 @@
package com.ljsd.jieling.logic.dao;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.util.KeyGenUtils;
import com.ljsd.jieling.util.UUIDEnum;
/**
*
*/
public class ExpeditionItem extends PropertyItem {
public ExpeditionItem(int uid, int expeditionTid) {
super();
super.setId(KeyGenUtils.produceIdByModule(UUIDEnum.EXPEDITION, uid));
super.setEquipId(expeditionTid);
}
public ExpeditionItem() {
this.setRootCollection(User._COLLECTION_NAME);
}
}

View File

@ -1,6 +1,8 @@
package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import config.SExpeditionHolyConfig;
import org.springframework.data.annotation.Transient;
import java.util.*;
@ -11,17 +13,30 @@ import java.util.*;
*/
public class ExpeditionManager extends MongoBase {
private Map<Integer,Double> heroHP = new HashMap<>();//英雄血量
private Map<Integer,ExpeditionNodeInfo> expeditionNodeInfos = new HashMap<>();
private int lay=1;//当前层数
private Map<String, Double> heroHP = new HashMap<>();//英雄血量
private Map<Integer, ExpeditionNodeInfo> expeditionNodeInfos = new HashMap<>();
private Set<Integer> rewardBox = new HashSet<>();
private int lay = 1;//当前层数
private int forceSnap;//战力快照
private Set<ExpeditionItem> propertyItems = new HashSet<>();
@Transient
private Map<Integer, SExpeditionHolyConfig> effectItems = new HashMap<>();//圣物叠加 不入库
public void putExpeditionNodeInfos(Integer key,ExpeditionNodeInfo nodeInfo) {
this.expeditionNodeInfos.put(key,nodeInfo);
updateString("ExpeditionNodeInfo." + key, nodeInfo);
public void putExpeditionNodeInfos(Integer key, ExpeditionNodeInfo nodeInfo) {
this.expeditionNodeInfos.put(nodeInfo.getSortId(), nodeInfo);
nodeInfo.init(this.getRootId(), getMongoKey() + ".expeditionNodeInfos." + nodeInfo.getSortId());
updateString("expeditionNodeInfos." + nodeInfo.getSortId(), nodeInfo);
}
public void setExpeditionNodeInfos(Map<Integer, ExpeditionNodeInfo> expeditionNodeInfos) {
this.expeditionNodeInfos = expeditionNodeInfos;
public void clearExpeditionNodeInfos() {
this.expeditionNodeInfos.forEach((integer, nodeInfo) ->
removeString(getMongoKey() + ".expeditionNodeInfos." + integer)
);
this.expeditionNodeInfos.clear();
}
public Map<Integer, ExpeditionNodeInfo> getExpeditionNodeInfos() {
return expeditionNodeInfos;
}
public int getLay() {
@ -29,14 +44,61 @@ public class ExpeditionManager extends MongoBase {
}
public void setLay(int lay) {
updateString("lay", lay);
this.lay = lay;
}
public Map<Integer, Double> getHeroHP() {
public Map<String, Double> getHeroHP() {
return heroHP;
}
public void setHeroHP(Map<Integer, Double> heroHP) {
this.heroHP = heroHP;
public Map<String, Double> getHeroHPWithChange() {
updateString("heroHP", heroHP);
return heroHP;
}
public void clearRewardBox() {
rewardBox.clear();
updateString("rewardBox", rewardBox);
}
public Set<Integer> getRewardBox() {
return rewardBox;
}
public void addRewardBox(int lay) {
updateString("rewardBox", rewardBox);
rewardBox.add(lay);
}
public Set<ExpeditionItem> getPropertyItems() {
return propertyItems;
}
public void addPropertyItems(ExpeditionItem expeditionItem) {
this.propertyItems.add(expeditionItem);
updateString("propertyItems", this.propertyItems);
}
public void clearPropertyItems() {
this.propertyItems.clear();
updateString("propertyItems", this.propertyItems);
}
public int getForceSnap() {
return forceSnap;
}
public void setForceSnap(int forceSnap) {
updateString("forceSnap", forceSnap);
this.forceSnap = forceSnap;
}
public Map<Integer, SExpeditionHolyConfig> getEffectItems() {
return effectItems;
}
}

View File

@ -1,21 +1,25 @@
package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Description: des
* Author: zsx
* CreateDate: 2020/1/7 14:49
*/
public class ExpeditionNodeInfo {
public class ExpeditionNodeInfo extends MongoBase {
private int sortId;//节点id
private int lay;//节点层数
private int type;//节点类型
private int bossinfo;
private int state;//节点状态//0未开启 1未通过 2未领取圣物 3已完成
private Map<Integer,Double> bossHP = new HashMap<>();//怪物血量
private Map<String,Double> bossHP = new HashMap<>();//怪物血量
private Set<Integer> holyEquipId = new HashSet<>();//节点圣物
private SnapFightInfo snapFightInfo;
public int getSortId() {
return sortId;
@ -23,6 +27,7 @@ public class ExpeditionNodeInfo {
public void setSortId(int sortId) {
this.sortId = sortId;
updateString("sortId",sortId);
}
public int getLay() {
@ -30,6 +35,7 @@ public class ExpeditionNodeInfo {
}
public void setLay(int lay) {
updateString("lay",lay);
this.lay = lay;
}
@ -38,16 +44,10 @@ public class ExpeditionNodeInfo {
}
public void setType(int type) {
updateString("type",type);
this.type = type;
}
public int getBossinfo() {
return bossinfo;
}
public void setBossinfo(int bossinfo) {
this.bossinfo = bossinfo;
}
public int getState() {
return state;
@ -55,13 +55,34 @@ public class ExpeditionNodeInfo {
public void setState(int state) {
this.state = state;
updateString("state",state);
}
public Map<Integer, Double> getBossHP() {
public Map<String, Double> getBossHP() {
updateString("bossHP",bossHP);
return bossHP;
}
public void setBossHP(Map<Integer, Double> bossHP) {
public void setBossHP(Map<String, Double> bossHP) {
this.bossHP = bossHP;
updateString("bossHP",bossHP);
}
public Set<Integer> getHolyEquipId() {
return holyEquipId;
}
public void setHolyEquipId(Set<Integer> holyEquipId) {
updateString("holyEquipId",holyEquipId);
this.holyEquipId = holyEquipId;
}
public SnapFightInfo getSnapFightInfo() {
return snapFightInfo;
}
public void setSnapFightInfo(SnapFightInfo snapFightInfo) {
this.snapFightInfo = snapFightInfo;
updateString("snapFightInfo",snapFightInfo);
}
}

View File

@ -14,6 +14,7 @@ public class FamilyFightInfo {
private int force;
private Map<String, String> heroSkills = new HashMap<>();
private String pokenmonSkills;
private String passiveSkills;
private List<Integer> pokenmonIds = new ArrayList<>();
public Map<String, FamilyHeroInfo> getHeroAttribute() {
return heroAttribute;
@ -89,4 +90,12 @@ public class FamilyFightInfo {
public void setPokenmonIds(List<Integer> pokenmonIds) {
this.pokenmonIds = pokenmonIds;
}
public String getPassiveSkills() {
return passiveSkills;
}
public void setPassiveSkills(String passiveSkills) {
this.passiveSkills = passiveSkills;
}
}

View File

@ -500,6 +500,7 @@ public class PlayerManager extends MongoBase {
}
public void setPhoneBindInfo(PhoneBindInfo phoneBindInfo) {
phoneBindInfo.init(this.getRootId(), getMongoKey()+".phoneBindInfo");
updateString("phoneBindInfo",phoneBindInfo);
this.phoneBindInfo = phoneBindInfo;
}

View File

@ -0,0 +1,76 @@
package com.ljsd.jieling.logic.dao;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class SnapFightInfo {
private Map<String, FamilyHeroInfo> heroAttribute;
private int uid;
private int force;
private Map<String, String> heroSkills = new HashMap<>();
private String pokenmonSkills;
private String passiveSkills;
private List<Integer> pokenmonIds = new ArrayList<>();
public Map<String, FamilyHeroInfo> getHeroAttribute() {
return heroAttribute;
}
public int getUid() {
return uid;
}
public void setHeroAttribute(Map<String, FamilyHeroInfo> heroAttribute) {
this.heroAttribute = heroAttribute;
}
public void setUid(int uid) {
this.uid = uid;
}
public int getForce() {
return force;
}
public void setForce(int force) {
this.force = force;
}
public void updateHeroSkill(String heroId, String skills){
heroSkills.put(heroId,skills);
}
public Map<String, String> getHeroSkills() {
return heroSkills;
}
public void setHeroSkills(Map<String, String> heroSkills) {
this.heroSkills = heroSkills;
}
public String getPokenmonSkills() {
return pokenmonSkills;
}
public void setPokenmonSkills(String pokenmonSkills) {
this.pokenmonSkills = pokenmonSkills;
}
public List<Integer> getPokenmonIds() {
return pokenmonIds;
}
public void setPokenmonIds(List<Integer> pokenmonIds) {
this.pokenmonIds = pokenmonIds;
}
public String getPassiveSkills() {
return passiveSkills;
}
public void setPassiveSkills(String passiveSkills) {
this.passiveSkills = passiveSkills;
}
}

View File

@ -0,0 +1,49 @@
package com.ljsd.jieling.logic.dao;
import java.util.Map;
public class SnapHeroInfo {
private int templeteId;
private int level;
private int star;
private Map<Integer,Integer> attribute;
public int getTempleteId() {
return templeteId;
}
public int getLevel() {
return level;
}
public int getStar() {
return star;
}
public Map<Integer, Integer> getAttribute() {
return attribute;
}
public void setTempleteId(int templeteId) {
this.templeteId = templeteId;
}
public void setLevel(int level) {
this.level = level;
}
public void setAttribute(Map<Integer, Integer> attribute) {
this.attribute = attribute;
}
public SnapHeroInfo(int templeteId, int level, int star, Map<Integer, Integer> attribute) {
this.templeteId = templeteId;
this.level = level;
this.attribute = attribute;
this.star = star;
}
public SnapHeroInfo() {
}
}

View File

@ -1,14 +1,31 @@
package com.ljsd.jieling.logic.expedition;
import com.ljsd.jieling.logic.activity.IEventHandler;
import com.ljsd.jieling.logic.dao.ExpeditionManager;
import com.ljsd.jieling.logic.dao.ExpeditionNodeInfo;
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
import com.ljsd.jieling.config.clazzStaticCfg.PlayStaticConfig;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.logic.arena.ArenaLogic;
import com.ljsd.jieling.logic.blood.BloodLogic;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.util.ItemUtil;
import config.*;
import manager.STableManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.ZSetOperations;
import util.MathUtils;
import util.TimeUtils;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
* Description:
@ -18,10 +35,23 @@ import java.util.Map;
public class ExpeditionLogic {
private static final Logger LOGGER = LoggerFactory.getLogger(ExpeditionLogic.class);
public static final int NODESTATE_CLOSE = 0;//0未开启
public static final int NODESTATE_NOT_PASS = 1;//1未通过
public static final int NODESTATE_NOT_GET = 2;//2未领取圣物
public static final int NODESTATE_PASS = 3;//已完成
public static final int NODESTATE_OVER_PASS = 4;//已完成
private ExpeditionLogic(){
public static final int NODETYPE_ADVANCE = 1;//精英节点
public static final int NODETYPE_BOSS = 2;//首领节点
public static final int NODETYPE_RELIVE = 3;//复活节点
public static final int NODETYPE_RECOVER = 4;//回复节点
public static final int NODETYPE_NORMAL = 5;//普通节点
private ExpeditionLogic() {
}
public static class Instance {
public final static ExpeditionLogic instance = new ExpeditionLogic();
}
@ -31,22 +61,461 @@ public class ExpeditionLogic {
}
//每日重置
public void flushUserdataEveryDay(User user){
Map<Integer, ExpeditionNodeInfo> expeditionNodeInfoMap = new HashMap<>();
//TODO
ExpeditionManager manager = new ExpeditionManager();
manager.setExpeditionNodeInfos(expeditionNodeInfoMap);
public void flushUserdataEveryDay(User user) throws Exception {
ExpeditionManager manager = user.getExpeditionManager();
manager.setForceSnap(user.getPlayerInfoManager().getMaxForce());
takeAllReward(user);
manager.clearExpeditionNodeInfos();
manager.setLay(1);
manager.clearRewardBox();
manager.clearPropertyItems();
manager.getHeroHPWithChange().clear();
reSetNode(user);
}
private void takeAllReward(User user)throws Exception {
//check cfg
Map<Integer,int[][]> boxMap = PlayStaticConfig.getExpeditioonRewardBoxMap();
List<int[][]> itemArrs = new LinkedList<>();
for (Map.Entry<Integer,int[][]> entry:boxMap.entrySet() ) {
if(user.getExpeditionManager().getRewardBox().contains(entry.getKey())){//已领取
continue;
}
if(user.getExpeditionManager().getLay()<=entry.getKey()){//条件未达成
continue;
}
itemArrs.add(entry.getValue());
}
if (itemArrs.size() == 0)
return;
String mailReward = ItemUtil.getMailReward(itemArrs);
int nowTime = (int) (TimeUtils.now() / 1000);
//TODO title content 走配置
MailLogic.getInstance().sendMail(user.getId(), "title", "content", mailReward, nowTime, Global.MAIL_EFFECTIVE_TIME);
}
/**
*
*
*/
private void openLay(){
public static Set<CommonProto.ExpeditionNodeInfo> openLay(User user, int curryLay, int passNode) {
final int oldlay = curryLay;
final int newlay = oldlay + 1;
//updata node
Set<CommonProto.ExpeditionNodeInfo> nodeInfos = new HashSet<>();
user.getExpeditionManager().getExpeditionNodeInfos().forEach((s, nodeInfo1) -> {
if (newlay != nodeInfo1.getLay() && nodeInfo1.getLay() != oldlay) {
return;
}
int state = nodeInfo1.getLay() == oldlay ? (nodeInfo1.getSortId() == passNode ? ExpeditionLogic.NODESTATE_PASS : ExpeditionLogic.NODESTATE_OVER_PASS) : ExpeditionLogic.NODESTATE_NOT_PASS;
nodeInfo1.setState(state);
nodeInfos.add(CommonProto.ExpeditionNodeInfo.newBuilder()
.setSortId(nodeInfo1.getSortId())
.setState(state)
.build());
});
//updata lay
user.getExpeditionManager().setLay(newlay);
return nodeInfos;
}
/**
*
*/
public Set<CommonProto.ExpeditionSimpleHeroInfo> getAllHeroInfo(User user) {
return getAllHeroInfo(user, new HashSet<>());
}
public Set<CommonProto.ExpeditionSimpleHeroInfo> getAllHeroInfo(User user, Set<String> set) {
Map<String, Hero> heroMap = user.getHeroManager().getHeroMap();
//生成新英雄的血量信息
Map<String, Double> heroHP = user.getExpeditionManager().getHeroHPWithChange();
for (Map.Entry<String, Hero> entry : heroMap.entrySet()) {
if (!heroHP.keySet().contains(entry.getKey())) {
heroHP.put(entry.getKey(), 1d);
}
}
//移除已经删除的hero
Set<String> removeId = heroHP.keySet().stream().filter(k -> !heroMap.keySet().contains(k)).collect(Collectors.toSet());
removeId.forEach(heroHP::remove);
Set<CommonProto.ExpeditionSimpleHeroInfo> heroInfoSet = new HashSet<>();
for (Map.Entry<String, Double> entry : heroHP.entrySet()) {
if (set.size() != 0 && !set.contains(entry.getKey())) {
continue;
}
CommonProto.ExpeditionSimpleHeroInfo simpleHeroInfo = CommonProto.ExpeditionSimpleHeroInfo.newBuilder().setHeroId(entry.getKey()).setRemainHp(entry.getValue()).build();
heroInfoSet.add(simpleHeroInfo);
}
return heroInfoSet;
}
public Set<CommonProto.ExpeditionNodeInfo> getNodeInfo(User user) throws Exception {
Set<CommonProto.ExpeditionNodeInfo> nodeInfos = new HashSet<>();
Map<Integer, ExpeditionNodeInfo> expeditionNodeInfos = user.getExpeditionManager().getExpeditionNodeInfos();
if (expeditionNodeInfos.size() == 0) {
reSetNode(user);
}
expeditionNodeInfos.values().forEach(nodeInfo ->
nodeInfos.add(CommonProto.ExpeditionNodeInfo.newBuilder()
.setSortId(nodeInfo.getSortId())
.setLay(nodeInfo.getLay())
.setState(nodeInfo.getState())
.setType(nodeInfo.getType())
.addAllHolyEquipID(nodeInfo.getHolyEquipId())
.setBossTeaminfo(getExpeditionTeamInfoProto(nodeInfo))
.build())
);
return nodeInfos;
}
public Set<CommonProto.ExpeditionEquip> getEquipnfo(User user) {
Set<CommonProto.ExpeditionEquip> equips = new HashSet<>();
Set<ExpeditionItem> propertyItems = user.getExpeditionManager().getPropertyItems();
propertyItems.forEach(expeditionItem ->
equips.add(CommonProto.ExpeditionEquip.newBuilder()
.setEquiptId(expeditionItem.getEquipId())
.setId(expeditionItem.getId())
.build())
);
return equips;
}
private void reSetNode(User user) throws Exception {
Set<ExpeditionNodeInfo> nodeSets = createNodeSet();
//存储并设置英雄快照
nodeSets.forEach(nodeInfo -> {
int sortId = nodeInfo.getSortId();
try {
//生成节点boss信息
int size = STableManager.getConfig(SExpeditionFloorConfig.class).size();
//战力基准值=maxforce*0.8+1/15(max-min)*lay
SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1);
if (sExpeditionSetting == null) {
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
int minFoce = sExpeditionSetting.getMatchForce()[0];
int manFoce = sExpeditionSetting.getMatchForce()[1];
int standerFoce = (int) (user.getExpeditionManager().getForceSnap() * (minFoce / 10000f) + nodeInfo.getLay() / size * (manFoce - minFoce) / 10000f);
int randomForce = (int) (standerFoce * ((sExpeditionSetting.getMatchForceRange()[0] + (int) (Math.random() * (sExpeditionSetting.getMatchForceRange()[1] - sExpeditionSetting.getMatchForceRange()[0]))) / 10000f));
Set<ZSetOperations.TypedTuple<String>> typedTuples = RedisUtil.getInstence().rangeByScoreWithScores(RedisKey.AREDEF_TEAM_FORCE_RANK, "", 0, randomForce);
if (typedTuples.size() == 0) {
//战力没有获取到 从机器人中选
Set<Integer> set = ArenaLogic.randomRobot(SArenaSetting.getSArenaSetting().getScore(), 1);
if (set.size() == 0) {
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
int robotId = set.iterator().next();
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(robotId);
snapOneFightInfo(nodeInfo, sArenaRobotConfig);
} else {
String serarchIdFromRank = typedTuples.iterator().next().getValue();
snapOneFightInfo(user, nodeInfo, Integer.valueOf(serarchIdFromRank));
}
} catch (Exception e) {
e.printStackTrace();
}
user.getExpeditionManager().putExpeditionNodeInfos(sortId, nodeInfo);
});
}
/**
* type id state
*/
private Set<ExpeditionNodeInfo> createNodeSet() throws Exception {
Map<Integer, SExpeditionFloorConfig> config = STableManager.getConfig(SExpeditionFloorConfig.class);
int totalIndex = 1;
Set<ExpeditionNodeInfo> nodeSets = new HashSet<>();
Map<Integer,Set<Integer>> map = new HashMap<>();
for (Map.Entry<Integer, Map<Integer,Integer>> integerMapMap :CommonStaticConfig.type2lay2weight.entrySet()){
int type = integerMapMap.getKey();
int lay = ranndomFromWeight(integerMapMap.getValue());
Set<Integer> value = map.getOrDefault(lay,new HashSet<>());
value.add(type);
map.put(lay,value);
}
for (SExpeditionFloorConfig sExpeditionFloorConfig : config.values()) {
int lay = sExpeditionFloorConfig.getId();
//必出节点 生成本层id
List<Integer> indexList = MathUtils.combineList(totalIndex, totalIndex + sExpeditionFloorConfig.getNode() - 1);
if (indexList.size() <= 0) {
continue;
}
//生成随机节点
if(map.containsKey(lay)){
for (Integer itemType:map.get(lay)) {
ExpeditionNodeInfo nodeInfo = getNode(sExpeditionFloorConfig, itemType);
nodeInfo.setLay(lay);
if (lay == 1) {
nodeInfo.setState(NODESTATE_NOT_PASS);
}
nodeInfo.setSortId(indexList.remove(0));
nodeSets.add(nodeInfo);
totalIndex++;
if (indexList.size() == 0) {
break;
}
}
}
if (indexList.size() == 0) {
continue;
}
//生成必出节点id state
for (int i = 0; i < sExpeditionFloorConfig.getNodeType().length; i++) {
int[] typeArr = sExpeditionFloorConfig.getNodeType()[i];
if (typeArr.length != 2) {
continue;
}
Set<ExpeditionNodeInfo> tempnode = getNode(sExpeditionFloorConfig, typeArr[0], typeArr[1]);
tempnode.forEach(nodeInfo -> {
nodeInfo.setLay(lay);
if (lay == 1) {
nodeInfo.setState(NODESTATE_NOT_PASS);
}
nodeInfo.setSortId(indexList.remove(0));
});
nodeSets.addAll(tempnode);
totalIndex += tempnode.size();
if (indexList.size() == 0) {
break;
}
}
if (indexList.size() == 0) {
continue;
}
//生成剩余节点
for (Integer anIndexList : indexList) {
//TODO 概率走配置
int type = NODETYPE_NORMAL;
if (Math.random() <= 0.3d) {
type = NODETYPE_ADVANCE;
}
ExpeditionNodeInfo nodeInfo = getNode(sExpeditionFloorConfig, type);
nodeInfo.setLay(lay);
if (lay == 1) {
nodeInfo.setState(NODESTATE_NOT_PASS);
}
nodeInfo.setSortId(anIndexList);
nodeSets.add(nodeInfo);
totalIndex++;
}
}
return nodeSets;
}
private ExpeditionNodeInfo getNode(SExpeditionFloorConfig cfg, int type) throws Exception {
return getNode(cfg, type, 1).iterator().next();
}
private Set<ExpeditionNodeInfo> getNode(SExpeditionFloorConfig cfg, int type, int num) throws Exception {
Set<ExpeditionNodeInfo> nodeSets = new HashSet<>();
for (int i = 0; i < num; i++) {
ExpeditionNodeInfo nodeInfo = new ExpeditionNodeInfo();
nodeInfo.setType(type);
//生成圣物 設置
if (type == NODETYPE_ADVANCE || type == NODETYPE_BOSS || type == NODETYPE_NORMAL) {
if (cfg.getHolyProbability().length < 3) {
throw new ErrorCodeException(ErrorCode.newDefineCode("随机库配错"));
}
int[] ints = MathUtils.randomFromWeightWithTaking(cfg.getHolyProbability(), 3);
Set<Integer> staffsSet = new HashSet<>();
Arrays.stream(ints).forEach(staffsSet::add);
nodeInfo.setHolyEquipId(staffsSet);
}
nodeInfo.setState(NODESTATE_CLOSE);
nodeSets.add(nodeInfo);
}
return nodeSets;
}
/**
*
*/
private void snapOneFightInfo(ExpeditionNodeInfo nodeInfo, SArenaRobotConfig sArenaRobotConfig) {
if (!isBattleNode(nodeInfo.getType())) {
return;
}
SnapFightInfo fightInfo = new SnapFightInfo();
int force = sArenaRobotConfig.getTotalForce();
System.out.println(sArenaRobotConfig.getId() + "::" + force + "\r\n");
Map<String, FamilyHeroInfo> heroAllAttribute = new HashMap<>();
Map<Integer, Integer> heroStarsMap = sArenaRobotConfig.getStarOfHeroMap();
Map<String, Double> bossHP = new HashMap<>();
for (Map.Entry<Integer, Integer> item : heroStarsMap.entrySet()) {
StringBuilder skillSb = new StringBuilder();
Integer heroTid = item.getKey();
Integer heroStar = item.getValue();
SCHero scHero = SCHero.getsCHero().get(heroTid);
List<Integer> skillIds = scHero.getSkillListByStar(heroStar);
String heroSkill = HeroLogic.getInstance().getRobotHeroSkills(skillIds, skillSb).toString();
fightInfo.updateHeroSkill(heroTid.toString(), heroSkill.substring(0, heroSkill.length() - 1));
bossHP.put(heroTid.toString(), 1d);
int[] differDemonsId = sArenaRobotConfig.getDifferDemonsId();
int differDemonsLv = sArenaRobotConfig.getDifferDemonsLv();
int robotLevel = sArenaRobotConfig.getRoleLv();
Map<Integer, Integer> robotHeroAttribute = HeroLogic.getInstance().calRobotHeroAttribute(scHero, robotLevel, sArenaRobotConfig.getBreakId(), differDemonsId, differDemonsLv, false);
heroAllAttribute.put(heroTid.toString(), new FamilyHeroInfo(heroTid, robotLevel, heroStar, robotHeroAttribute));
// String property = HeroLogic.getInstance().getRobotHeroProperty(sArenaRobotConfig,scHero,propertySb,robotHeroAttribute).toString();
}
fightInfo.setHeroAttribute(heroAllAttribute);
fightInfo.setForce(force);
fightInfo.setUid(sArenaRobotConfig.getId());
nodeInfo.setBossHP(bossHP);
fightInfo.setPokenmonSkills("");
fightInfo.setPassiveSkills("");
nodeInfo.setSnapFightInfo(fightInfo);
}
private void snapOneFightInfo(User self, ExpeditionNodeInfo nodeInfo, int defid) throws Exception {
int snapTeamId = GlobalsDef.TEAM_ARENA_DEFENSE;
if (!isBattleNode(nodeInfo.getType())) {
return;
}
User user = UserManager.getUser(defid);
SnapFightInfo fightInfo = new SnapFightInfo();
//血量处理buff处理
int force = HeroLogic.getInstance().calTeamTotalForce(user, snapTeamId, false);
Map<String, FamilyHeroInfo> heroAllAttribute = BloodLogic.getInstance().battleRecord(user, snapTeamId, null);
fightInfo.setHeroAttribute(heroAllAttribute);
fightInfo.setForce(force);
fightInfo.setUid(self.getId());
List<TeamPosHeroInfo> teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(snapTeamId);
if (teamPosHeroInfoList == null || teamPosHeroInfoList.size() < 1) {
teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(1);
}
Map<String, Hero> heroMap = user.getHeroManager().getHeroMap();
Map<String, Double> bossHP = new HashMap<>();
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfoList) {
String heroId = teamPosHeroInfo.getHeroId();
bossHP.put(heroId, 1d);
Hero hero = heroMap.get(heroId);
StringBuilder skillSb = new StringBuilder();
String heroSkill = HeroLogic.getInstance().getHeroSkills(user, hero, skillSb).toString();
fightInfo.updateHeroSkill(heroId, heroSkill.substring(0, heroSkill.length() - 1));
}
nodeInfo.setBossHP(bossHP);
String pokenmonSkills = HeroLogic.getInstance().getPokenmonSkills(user, snapTeamId);
fightInfo.setPokenmonSkills(pokenmonSkills);
String pokenmonPassiveSkills = HeroLogic.getInstance().getPokenmonPassiveSkills(user, snapTeamId);
fightInfo.setPassiveSkills(pokenmonPassiveSkills);
List<TeamPosForPokenInfo> teamPosForPokenInfos = user.getTeamPosManager().getTeamPosForPoken().get(snapTeamId);
if (teamPosForPokenInfos != null) {
List<Integer> pokens = new ArrayList<>();
for (TeamPosForPokenInfo teamPosForPokenInfo : teamPosForPokenInfos) {
pokens.add(teamPosForPokenInfo.getPokenId());
}
fightInfo.setPokenmonIds(pokens);
}
nodeInfo.setSnapFightInfo(fightInfo);
}
public static boolean isBattleNode(int type) {
return type == NODETYPE_ADVANCE || type == NODETYPE_BOSS || type == NODETYPE_NORMAL;
}
public static CommonProto.ExpeditionTeamInfo getExpeditionTeamInfoProto(ExpeditionNodeInfo nodeInfo) {
Map<String, Double> heroHP = nodeInfo.getBossHP();
SnapFightInfo fightInfo = nodeInfo.getSnapFightInfo();
CommonProto.ExpeditionTeamInfo.Builder builder = CommonProto.ExpeditionTeamInfo.newBuilder();
if (!isBattleNode(nodeInfo.getType())) {
return builder.build();
}
if (null == fightInfo) {
LOGGER.error("节点" + nodeInfo.getSortId() + "信息错误");
return builder.build();
}
builder.setTotalForce(fightInfo.getForce());
List<CommonProto.ExpeditionSimpleBossInfo> builders = new LinkedList<>();
fightInfo.getHeroAttribute().forEach((s, familyHeroInfo) -> {
CommonProto.ExpeditionSimpleBossInfo.Builder builder1 = CommonProto.ExpeditionSimpleBossInfo.newBuilder();
builder1.setHeroTid(familyHeroInfo.getTempleteId());
builder1.setLevel(familyHeroInfo.getLevel());
builder1.setStar(familyHeroInfo.getStar());
builder1.setRemainHp(heroHP.get(s));
builders.add(builder1.build());
});
builder.addAllHero(builders);
builder.addAllPokemonInfos(fightInfo.getPokenmonIds());
return builder.build();
}
private int ranndomFromWeight(Map<Integer, Integer> weight) {
int amount;
int result = 0;
IntSummaryStatistics collect = weight.values().stream().collect(Collectors.summarizingInt(value -> value));
amount = (int) collect.getSum();
int rate = MathUtils.randomInt(amount);
amount = 0;
for (Map.Entry<Integer, Integer> integerIntegerMap : weight.entrySet()) {
amount += integerIntegerMap.getValue();
if (rate < amount) {
result = integerIntegerMap.getKey();
break;
}
}
return result;
}
/**
* @return
*/
public static Set<SExpeditionHolyConfig> getFirstRankHoly(ExpeditionManager expeditionManager) {
Map<Integer,SExpeditionHolyConfig> effectItems = expeditionManager.getEffectItems();
Map<Integer, SExpeditionHolyConfig> config = STableManager.getConfig(SExpeditionHolyConfig.class);
if (effectItems.size() == 0) {
//全量计算
Set<ExpeditionItem> propertyItems = expeditionManager.getPropertyItems();
for (ExpeditionItem item : propertyItems){
int id = item.getEquipId();
SExpeditionHolyConfig sExpeditionHolyConfig = config.get(id);
if (null ==sExpeditionHolyConfig ) {
LOGGER.error("圣物配置不存在id="+id);
continue;
}
SExpeditionHolyConfig orDefault = effectItems.getOrDefault(sExpeditionHolyConfig.geteffect(), null);
if(null!=orDefault&&sExpeditionHolyConfig.gettype()<=orDefault.gettype()){
continue;
}
effectItems.put(sExpeditionHolyConfig.geteffect(),sExpeditionHolyConfig);
}
}
return new HashSet<>(effectItems.values());
}
}

View File

@ -351,6 +351,8 @@ public class GuildFightLogic {
}
String pokenmonSkills = HeroLogic.getInstance().getPokenmonSkills(user, 501);
fightInfo.setPokenmonSkills(pokenmonSkills);
String pokenmonPassiveSkills = HeroLogic.getInstance().getPokenmonPassiveSkills(user, 501);
fightInfo.setPassiveSkills(pokenmonPassiveSkills);
redisUtil.putMapEntry(RedisKey.FAMILY_FIGHT, String.valueOf(guildInfo.getId()), String.valueOf(entry.getKey()), fightInfo);
familyTotalStar+=fightInfo.getStarCount();
}
@ -446,7 +448,7 @@ public class GuildFightLogic {
Map<String, Integer> attackBloodMap = redisUtil.getMapValues(RedisKey.FAMILY_ATTACK_BLOOD, String.valueOf(userAttack.getId()), String.class, Integer.class);
PVPFightEvent pvpFightEvent = new PVPFightEvent(userAttack.getId(),502, SGuildSetting.sGuildSetting.getWarTime(),"", GameFightType.GuildFight,defendUid,-1);
pvpFightEvent.setAttackBloodMap(attackBloodMap);
pvpFightEvent.setDefFightSnapData(new DefFightSnapData(defendInfo.getHeroAttribute(),defendInfo.getHeroSkills(),defendInfo.getPokenmonSkills()));
pvpFightEvent.setDefFightSnapData(new DefFightSnapData(defendInfo.getHeroAttribute(),defendInfo.getHeroSkills(),defendInfo.getPokenmonSkills(),defendInfo.getPassiveSkills()));
FightResult dispatcher = FightDispatcher.dispatcher(pvpFightEvent);
int[] fightResult = dispatcher.getCheckResult();

View File

@ -9,12 +9,14 @@ public class DefFightSnapData {
private Map<String, FamilyHeroInfo> heroAttribute;
private Map<String, String> heroSkills = new HashMap<>();
private String pokenmonSkills;
private String passiveSkills;
public DefFightSnapData(Map<String, FamilyHeroInfo> heroAttribute, Map<String, String> heroSkills, String pokenmonSkills) {
public DefFightSnapData(Map<String, FamilyHeroInfo> heroAttribute, Map<String, String> heroSkills, String pokenmonSkills, String passiveSkills) {
this.heroAttribute = heroAttribute;
this.heroSkills = heroSkills;
this.pokenmonSkills = pokenmonSkills;
this.passiveSkills = passiveSkills;
}
public Map<String, FamilyHeroInfo> getHeroAttribute() {
@ -28,4 +30,12 @@ public class DefFightSnapData {
public String getPokenmonSkills() {
return pokenmonSkills;
}
public String getPassiveSkills() {
return passiveSkills;
}
public void setPassiveSkills(String passiveSkills) {
this.passiveSkills = passiveSkills;
}
}

View File

@ -30,8 +30,20 @@ public class FightUtil {
return BehaviorUtil.getFightTeamInfo(player,teamId,attackBloodMap);
}
public static CommonProto.FightTeamInfo makePersonFightDataWithDouble(User player,int teamId,Map<String, Double> attackBloodMap){
if(attackBloodMap ==null || attackBloodMap.isEmpty()){
return BehaviorUtil.getFightTeamInfo(player,teamId,true);
}
return BehaviorUtil.getFightTeamInfoWithDouble(player,teamId,attackBloodMap);
}
public static CommonProto.FightTeamInfo makeFightWithSnapData(DefFightSnapData defFightSnapData){
return BloodLogic.getInstance().fightDataMakeUp(defFightSnapData.getHeroSkills(),defFightSnapData.getHeroAttribute(),defFightSnapData.getPokenmonSkills());
return BloodLogic.getInstance().fightDataMakeUp(defFightSnapData.getHeroSkills(),defFightSnapData.getHeroAttribute(),defFightSnapData.getPokenmonSkills(),defFightSnapData.getPassiveSkills());
}
public static CommonProto.FightTeamInfo makeFightBySnapDataWithDouble(DefFightSnapData defFightSnapData,Map<String, Double> attackBloodMap){
return BloodLogic.getInstance().fightDataMakeUp(defFightSnapData.getHeroSkills(),defFightSnapData.getHeroAttribute(),defFightSnapData.getPokenmonSkills(),defFightSnapData.getPassiveSkills(),attackBloodMap);
}
@ -82,9 +94,9 @@ public class FightUtil {
return builder.build();
}
public static FightResult getFightForPVP(FightEvent fightEvent){
public static FightResult getFightForPVP(FightEvent fightEvent,int seed){
int fightSeed =seed;
PVPFightEvent pvpFightEvent = (PVPFightEvent)fightEvent;
int fightSeed =getFightSeed();
CommonProto.FightTeamInfo fightTeamInfo = null;
CommonProto.FightTeamInfo deffightTeamInfo = null;
if(pvpFightEvent.getAttackFightSnapData()!=null){
@ -127,6 +139,11 @@ public class FightUtil {
return builder.build();
}
public static FightResult getFightForPVP(FightEvent fightEvent){
int fightSeed =getFightSeed();
return getFightForPVP(fightEvent,fightSeed);
}
public static FightResult getFightFromRedis(FightEvent fightEvent) throws Exception {
GameFightType fightType = fightEvent.getFightType();

View File

@ -29,6 +29,7 @@ public enum GameFightType {
ArenaPersonFight(FightType.ArenaFight,new PVPFightHandler(),null),
ArenaRobotFight(FightType.ArenaFight,new PVPFightHandler(),null),
Expediton(FightType.EXPEDITION,new PVPFightHandler(),null),
TOPArenaPersonFight(FightType.TOPFight,new PVPFightHandler(),null),
TOPArenaRobotFight(FightType.TOPFight,new PVPFightHandler(),null),

View File

@ -1,7 +1,10 @@
package com.ljsd.jieling.logic.fight.result;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.protocols.CommonProto;
import java.util.ArrayList;
import java.util.List;
public class FightResult {
@ -89,6 +92,19 @@ public class FightResult {
public int[] getCheckResult() {
return checkResult;
}
public List<Integer> getRemainHp()throws Exception{
//result check
List<Integer> remainHp = new ArrayList<>(5);
for (int i = 2; i < checkResult.length; i++) {
if (checkResult[i] <= 0) {
remainHp.add(0);
} else {
remainHp.add(checkResult[i]);
}
}
return remainHp;
}
public CommonProto.FightData getFightData() {
return fightData;

View File

@ -1062,12 +1062,9 @@ public class HeroLogic{
return sb;
}
public StringBuilder getRobotHeroProperty(SArenaRobotConfig sArenaRobotConfig,SCHero scHero, StringBuilder sb){
public StringBuilder getRobotHeroProperty(SArenaRobotConfig sArenaRobotConfig,SCHero scHero, StringBuilder sb,Map<Integer, Integer> robotHeroAttribute){
int[] differDemonsId = sArenaRobotConfig.getDifferDemonsId();
int differDemonsLv = sArenaRobotConfig.getDifferDemonsLv();
int robotLevel = sArenaRobotConfig.getRoleLv();
Map<Integer, Integer> robotHeroAttribute = calRobotHeroAttribute(scHero, robotLevel, sArenaRobotConfig.getBreakId(), differDemonsId, differDemonsLv,false);
sb.append(robotLevel).append(DIVISION);
List<Integer> templatePropetyIds = transTemplateByHeroPropertyName.get(scHero.getPropertyName());
for(Integer templatePropetyId:templatePropetyIds){
@ -1458,7 +1455,7 @@ public class HeroLogic{
Integer propertyId = item.getKey();
float propertyValue = item.getValue();
if(propertyId == HeroAttributeEnum.EquipForce.getPropertyId()){
LOGGER.info("the equipScore={}",propertyValue);
// LOGGER.info("the equipScore={}",propertyValue);
continue;
}
SPropertyConfig sPropertyConfig = SPropertyConfig.getsPropertyConfigByPID(propertyId);

View File

@ -262,13 +262,18 @@ public class PlayerLogic {
int teamForce = HeroLogic.getInstance().calTeamTotalForce(user, teamId, false);
if(user.getPlayerInfoManager().getMaxForce() < teamForce){
user.getPlayerInfoManager().setMaxForce(teamForce);
// String key = RedisKey.getKey(RedisKey.FORCE_RANK, "", false);
// RedisUtil.getInstence().zsetAddOne(key, String.valueOf(user.getId()), teamForce);
Poster.getPoster().dispatchEvent(new UserForceChangeEvent(uid,teamForce));
user.getUserMissionManager().onGameEvent(user,GameEvent.USER_FORCE_CHANGE);
ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.FORCERANK,teamForce);
ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.FORCESTANDARD,teamForce);
}
if(teamId == 101){
//更新竞技场防御编队战力
String key = RedisKey.getKey(RedisKey.AREDEF_TEAM_FORCE_RANK, "", false);
RedisUtil.getInstence().zsetAddOne(key, String.valueOf(user.getId()), teamForce);
}
}
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.USER_FORCE_CHANGE_RESPONSE_VALUE,null,true);

View File

@ -80,6 +80,9 @@ public class ProtocolsManager implements ProtocolsAbstract {
private void addHandler(BaseHandler handler) {
if(null==handler.getMessageCode()){
return;
}
handlers.put(handler.getMessageCode().getNumber(), handler);
}
@ -88,6 +91,7 @@ public class ProtocolsManager implements ProtocolsAbstract {
public void processMessage(PacketNetData packetNetData) {
BaseHandler baseHandler = handlers.get(packetNetData.getMsgId());
if (baseHandler == null) {
//检查一下 是否有getMessageCode()返回null
LOGGER.info("request unknow commond : " + packetNetData.getMsgId());
return;
} else {

View File

@ -9,7 +9,8 @@ public enum UUIDEnum {
GUILDLOG(5),
ESPECIAL_EQUIP(6),
SOUL_EQUIP(7),//魂印
CDK(8)//cdk
CDK(8),//cdk
EXPEDITION(9)//圣物
;
private int value;

View File

@ -0,0 +1,65 @@
package config;
import manager.STableManager;
import manager.Table;
import java.util.HashMap;
import java.util.Map;
@Table(name ="ExpeditionFloorConfig")
public class SExpeditionFloorConfig implements BaseConfig {
private int id;
private int node;
private int[][] nodeType;
private int[][] randomNode;
private int[][] holyProbability;
private int[][] reward;
private int[][] treasureBox;
@Override
public void init() throws Exception {
}
public int getId() {
return id;
}
public int getNode() {
return node;
}
public int[][] getNodeType() {
return nodeType;
}
public int[][] getHolyProbability() {
return holyProbability;
}
public int[][] getReward() {
return reward;
}
public int[][] getTreasureBox() {
return treasureBox;
}
public int[][] getRandomNode() {
return randomNode;
}
public void setRandomNode(int[][] randomNode) {
this.randomNode = randomNode;
}
}

View File

@ -0,0 +1,55 @@
package config;
import manager.STableManager;
import manager.Table;
import java.util.Map;
@Table(name ="ExpeditionHolyConfig")
public class SExpeditionHolyConfig implements BaseConfig {
private int id;
private int type;
private int effect;
private int weight;
private int passiveSkillId;
private int forceType;
@Override
public void init() throws Exception {
}
public int getId() {
return id;
}
public int gettype() {
return type;
}
public int geteffect() {
return effect;
}
public int getWeight() {
return weight;
}
public int getPassiveSkillId() {
return passiveSkillId;
}
public int getForceType() {
return forceType;
}
}

View File

@ -0,0 +1,73 @@
package config;
import manager.STableManager;
import manager.Table;
import java.util.Map;
@Table(name ="ExpeditionSetting")
public class SExpeditionSetting implements BaseConfig {
private int id;
private int reviveRefresh;
private int[] revive;
private int holyCount;
private int regeneratePercent;
private int[] matchForce;
private int[] matchForceRange;
private int[][] powerfulForce;
private int fightTime;
@Override
public void init() throws Exception {
}
public int getId() {
return id;
}
public int getReviveRefresh() {
return reviveRefresh;
}
public int[] getRevive() {
return revive;
}
public int getHolyCount() {
return holyCount;
}
public int getRegeneratePercent() {
return regeneratePercent;
}
public int[] getMatchForce() {
return matchForce;
}
public int[] getMatchForceRange() {
return matchForceRange;
}
public int[][] getPowerfulForce() {
return powerfulForce;
}
public int getFightTime() {
return fightTime;
}
}

View File

@ -2,6 +2,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
/**
@ -11,31 +12,26 @@ import java.util.List;
*/
public class BIUtil {
public static void main(String[] args) {
outBIReasonFile("serverlogic\\src\\main\\java\\com\\ljsd\\jieling\\globals\\BIReason.java","conf\\BIoutput.txt");
System.out.print(randomForOneArray(23,8).toString());
}
public static void outBIReasonFile(String in,String out){
StringBuffer buf = new StringBuffer();
Path path = Paths.get(in);
try {
List<String> lines = Files.readAllLines(path);
lines.forEach(str -> buf.append(str));
} catch (IOException e) {
e.printStackTrace();
/**
*
*/
public static List<Integer> randomForOneArray(int sum, int split) {
List<Integer> result = new ArrayList<>();
if (split == 0) {
return result;
}
String replace = buf.toString().replace("}", "").replace(" ","");
String[] split = replace.split("=");
StringBuilder content = new StringBuilder();
for(String s:split){
String[] reason= s.split("int")[0].split(";//");
if(reason.length<2){
continue;
}
content.append(reason[0]).append("\t").append(reason[1].replaceAll(" ","")).append("\n");
}
try {
Files.write(Paths.get(out), content.toString().getBytes());
} catch (IOException e) {
e.printStackTrace();
int remain = sum % split;
int out = split - remain;
int item = (sum+out) / split;
for (int i = 0; i < split; i++) {
int innerItem = i == 0 ? item-out : item;
result.add(innerItem);
}
return result;
}
}