山河社稷图
parent
ea4d1e03d6
commit
f561f686e9
|
|
@ -121,6 +121,43 @@ public class CheckFight {
|
|||
return resultCache;
|
||||
}
|
||||
|
||||
public long[][] checkHardStageFight(int seed,int maxTime, LuaValue fightData, LuaValue optionData,FightType fightType){
|
||||
LuaValue transCoderObj = this.getTransCoderObj();
|
||||
long[][] resultX = new long[2][];
|
||||
LuaValue func = transCoderObj.get(LuaValue.valueOf("Execute"));
|
||||
LuaValue args = new LuaTable();
|
||||
args.set("seed",seed);
|
||||
//todo type
|
||||
args.set("type",fightType.getType());
|
||||
args.set("maxRound",maxTime);
|
||||
LuaValue result = func.call( args,fightData,optionData);
|
||||
int status = result.get("result").toint();
|
||||
int duration = result.get("duration").toint();
|
||||
long[] starRecord = new long[6];
|
||||
for(int x = 1; x <= result.get("starRecord").length() ; x++){
|
||||
long s = result.get("starRecord").rawget(x).tolong();
|
||||
starRecord[x-1] = s;
|
||||
}
|
||||
|
||||
long[] resultCache = new long[8];//对方阵容走配置 Todo 后面结构走配置
|
||||
resultCache[0]= (long) status;
|
||||
resultCache[1]= (long) duration;
|
||||
LOGGER.info(" lua check test fight result : "+ status);
|
||||
for (int i = 1; i <= result.length(); i++) {
|
||||
long tolong = result.rawget(i).tolong();
|
||||
if(tolong>0){
|
||||
resultCache[i+1]= Math.min((long) Integer.MAX_VALUE,tolong);
|
||||
}else {
|
||||
resultCache[i+1]= Math.max((long) Integer.MIN_VALUE,tolong);
|
||||
}
|
||||
resultCache[i+1] = (long) result.rawget(i).toint();
|
||||
LOGGER.info(i+" --> 单位剩余血量 : "+ resultCache[i+1]);
|
||||
}
|
||||
resultX[0] = resultCache;
|
||||
resultX[1] = starRecord;
|
||||
return resultX;
|
||||
}
|
||||
|
||||
public LuaValue getTransCoderObj(){
|
||||
LuaValue transCoderObj = localTransCoderObj.get();
|
||||
if(transCoderObj == null||localVersion.get()!=hotFixVersion.get()){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package com.ljsd.jieling.handler.hardStage;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.hardStage.HardStageLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SHardStageReward;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GetHardStageChapterRewardHandler extends BaseHandler<PlayerInfoProto.GetHardStageChapterReward> {
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.HARD_STAGE_CHAPTER_REWARD_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, PlayerInfoProto.GetHardStageChapterReward proto) throws Exception {
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
int chapter = proto.getChapterId();
|
||||
int rewardId = proto.getRewradId();
|
||||
List<SHardStageReward> rewardStageList = SHardStageReward.getChapterConfigMap().get(chapter);
|
||||
List<CommonProto.Drop.Builder> dropList = new ArrayList<>();
|
||||
for(SHardStageReward rewardStage : rewardStageList){
|
||||
if(rewardStage.getId() == rewardId){
|
||||
HardStageLogic.getChapterReward(user,rewardStage,dropList);
|
||||
}
|
||||
}
|
||||
PlayerInfoProto.GetHardStageChapterRewardResponse.Builder response = PlayerInfoProto.GetHardStageChapterRewardResponse.newBuilder();
|
||||
for(CommonProto.Drop.Builder drop : dropList){
|
||||
response.addDrop(drop);
|
||||
}
|
||||
MessageUtil.sendMessage(iSession, 1,MessageTypeProto.MessageType.HARD_STAGE_CHAPTER_REWARD_RESPONSE.getNumber(), response.build(), true);
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
|
|||
int teamId = proto.getTeamId();
|
||||
List<CommonProto.Drop.Builder> dropList = new ArrayList<>();
|
||||
SHardStage nodeConfig = SHardStage.getConfigMap().get(nodeId);
|
||||
Map<Integer, HardStageChapter> chapterMap = user.getHardStageManager().getChapterMap();
|
||||
Map<Integer, HardStageChapter> chapterMap = user.getHardStageManager().getChapterMap(user);
|
||||
if(!chapterMap.containsKey(nodeConfig.getChapter()) || chapterMap.get(nodeConfig.getChapter()).getNode(nodeId) == null){
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点不存在或未开启"));
|
||||
}
|
||||
|
|
@ -62,16 +62,17 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
|
|||
List<CommonProto.FightTeamInfo> monsterGroupList = BehaviorUtil.getFightTeamInfos(monsterfightTeamInfos,monsterPokemonByGroup, Global.MONSTER_1);
|
||||
|
||||
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterGroupList);
|
||||
getFightData.set("nodeId",nodeId);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData(user.getId()+"");
|
||||
long[] fightResult = CheckFight.getInstance().checkFight(seed, 20, getFightData, getOptionData, FightType.HardStage);
|
||||
long[][] fightResult = CheckFight.getInstance().checkHardStageFight(seed, 20, getFightData, getOptionData, FightType.HardStage);
|
||||
|
||||
int resultCode = (int) fightResult[0];
|
||||
int resultCode = (int) fightResult[0][0];
|
||||
if (resultCode == -1) {
|
||||
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
|
||||
}
|
||||
|
||||
int resultNum = (int)fightResult[1][1]+(int)fightResult[1][3]+(int)fightResult[1][5];
|
||||
if(resultCode == 1){//通过
|
||||
HardStageLogic.passNode(iSession,nodeConfig,0,dropList);
|
||||
HardStageLogic.passNode(iSession,nodeConfig,resultNum,dropList);
|
||||
}else{
|
||||
HardStageLogic.passNode(iSession,nodeConfig,0,dropList);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ 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.CombatLogic;
|
||||
import com.ljsd.jieling.logic.hardStage.HardStageLogic;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.ToolsUtil;
|
||||
import config.*;
|
||||
|
|
@ -52,7 +53,7 @@ public class UserLevelEventHandler implements IEventHandler,IPrivilegeChange{
|
|||
|
||||
}
|
||||
ExpeditionLogic.openTreasure(user,2,level);
|
||||
|
||||
HardStageLogic.refreshInfoByLevel(user);
|
||||
List<SGlobalActivity> sGlobalActivities = SGlobalActivity.sGlobalActivityMapByOpenRules.getOrDefault(2,new ArrayList<>(0));
|
||||
for(SGlobalActivity sGlobalActivity : sGlobalActivities){
|
||||
int[] openRules = sGlobalActivity.getOpenRules();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.hardStage.HardStageChapter;
|
||||
import com.ljsd.jieling.logic.hardStage.HardStageNode;
|
||||
import config.SHardStage;
|
||||
|
|
@ -11,27 +12,36 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
public class HardStageManager extends MongoBase {
|
||||
private int curChapter;
|
||||
private int curNode;
|
||||
|
||||
private Map<Integer, HardStageChapter> chapterMap ;//山河玩家信息
|
||||
|
||||
|
||||
public Map<Integer, HardStageChapter> getChapterMap() {
|
||||
if(null == chapterMap){
|
||||
Map<Integer, HardStageChapter> map = initChapterMap();
|
||||
public HardStageManager(){
|
||||
}
|
||||
public Map<Integer, HardStageChapter> getChapterMap(User user) throws Exception{
|
||||
if(null == chapterMap ||chapterMap.size()<1){
|
||||
Map<Integer, HardStageChapter> map = initChapterMap(user);
|
||||
chapterMap = map;
|
||||
}
|
||||
return chapterMap;
|
||||
}
|
||||
|
||||
private Map<Integer, HardStageChapter> initChapterMap(){
|
||||
private Map<Integer, HardStageChapter> initChapterMap(User user) throws Exception{
|
||||
Map<Integer, HardStageChapter> map = new HashMap<>();
|
||||
SHardStage nodeOne = SHardStage.getConfigMap().get(1);//第一个节点
|
||||
if(user.getPlayerInfoManager().getLevel()<nodeOne.getLevelLimit()){
|
||||
return map;
|
||||
}
|
||||
HardStageNode node = initNode(nodeOne);
|
||||
HardStageChapter chapter = initChapter(nodeOne.getChapter());
|
||||
chapter.init(this.getRootId(), getMongoKey() + ".chapterMap." + chapter.getChapterId());
|
||||
updateString("chapterMap." + chapter.getChapterId(), chapter);
|
||||
chapter.addNodeList(node);
|
||||
setCurNode(node.getId());
|
||||
map.put(chapter.getChapterId(),chapter);
|
||||
setCurChapter(chapter.getChapterId());
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
@ -62,22 +72,44 @@ public class HardStageManager extends MongoBase {
|
|||
* 满足条件开启新节点
|
||||
* @param config
|
||||
*/
|
||||
public void openNewNode(SHardStage config){
|
||||
public void openNewNode(User user,SHardStage config){
|
||||
if(user.getPlayerInfoManager().getLevel()<config.getLevelLimit()){
|
||||
return;
|
||||
}
|
||||
HardStageChapter chapter ;
|
||||
if(chapterMap.containsKey(config.getChapter())){
|
||||
chapter = chapterMap.get(config.getChapter());
|
||||
HardStageNode node = initNode(config);
|
||||
chapter.addNodeList(node);
|
||||
setCurNode(node.getId());
|
||||
}else{
|
||||
chapter = initChapter(config.getChapter());
|
||||
chapter.init(this.getRootId(), getMongoKey() + ".chapterMap." + chapter.getChapterId());
|
||||
updateString("chapterMap." + chapter.getChapterId(), chapter);
|
||||
updateString("chapterMap." + chapter.getChapterId(), chapterMap);
|
||||
HardStageNode node = initNode(config);
|
||||
chapter.addNodeList(node);
|
||||
setCurNode(node.getId());
|
||||
chapterMap.put(config.getChapter(),chapter);
|
||||
setCurChapter(chapter.getChapterId());
|
||||
}
|
||||
updateString("chapterMap." + chapter.getChapterId(), chapter);
|
||||
updateString("chapterMap." + chapter.getChapterId(), chapterMap);
|
||||
}
|
||||
|
||||
public int getCurChapter() {
|
||||
return curChapter;
|
||||
}
|
||||
|
||||
public void setCurChapter(int curChapter) {
|
||||
this.curChapter = curChapter;
|
||||
updateString("curChapter" ,curChapter);
|
||||
}
|
||||
|
||||
public int getCurNode() {
|
||||
return curNode;
|
||||
}
|
||||
|
||||
public void setCurNode(int curNode) {
|
||||
this.curNode = curNode;
|
||||
updateString("curNode" ,curNode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.logic.hardStage;
|
||||
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.dao.Hero;
|
||||
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
|
|
@ -10,10 +11,13 @@ import com.ljsd.jieling.logic.hero.HeroLogic;
|
|||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.ItemMap;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -29,8 +33,8 @@ public class HardStageLogic {
|
|||
/**
|
||||
* 获取山河社稷图信息
|
||||
*/
|
||||
public static CommonProto.HardStageInfo.Builder getInfo(User user){
|
||||
Map<Integer, HardStageChapter> map = user.getHardStageManager().getChapterMap();
|
||||
public static CommonProto.HardStageInfo.Builder getInfo(User user) throws Exception{
|
||||
Map<Integer, HardStageChapter> map = user.getHardStageManager().getChapterMap(user);
|
||||
CommonProto.HardStageInfo.Builder builder = CommonProto.HardStageInfo.newBuilder();
|
||||
for(Map.Entry<Integer,HardStageChapter> entry : map.entrySet()){
|
||||
CommonProto.HardStageChapter.Builder chapterBuilder = CommonProto.HardStageChapter.newBuilder();
|
||||
|
|
@ -63,8 +67,17 @@ public class HardStageLogic {
|
|||
/**
|
||||
* 领取章节奖励
|
||||
*/
|
||||
public static void getChapterReward(){
|
||||
|
||||
public static void getChapterReward(User user,SHardStageReward rewardStage,List<CommonProto.Drop.Builder> list) throws Exception{
|
||||
HardStageChapter chapter = user.getHardStageManager().getChapterMap(user).get(rewardStage.getChapter());
|
||||
if(chapter.getStars() < rewardStage.getStar()){
|
||||
LOGGER.error("章节星星数量不足");
|
||||
return;
|
||||
}
|
||||
if(!chapter.getRewardMap().get(rewardStage.getStarReward())){
|
||||
chapter.getRewardMap().put(rewardStage.getStarReward(),true);
|
||||
chapter.updateRewardMap();
|
||||
list.add(getReward(user,rewardStage.getStarReward()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -126,7 +139,9 @@ public class HardStageLogic {
|
|||
|
||||
if(nodeConfig.getHardStageBuff() != 0){
|
||||
SHardStageBuff buff = SHardStageBuff.getConfigMap().get(nodeConfig.getHardStageBuff());
|
||||
skillSb.append(buff.getPassiveSkillLogic()).append("#");
|
||||
if(buff.getType()==2 || buff.getType()==3){
|
||||
skillSb.append(buff.getPassiveSkillLogic()).append("#");
|
||||
}
|
||||
}
|
||||
|
||||
String property = HeroLogic.getInstance().getHeroPropertyBuilder(propertySb, hero.getTemplateId(),hero.getLevel(user.getHeroManager()), heroAttributeMap).toString();
|
||||
|
|
@ -159,7 +174,7 @@ public class HardStageLogic {
|
|||
*/
|
||||
public static void passNode(ISession iSession, SHardStage nodeConfig, int resultNum,List<CommonProto.Drop.Builder> dropList) throws Exception{
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
Map<Integer, HardStageChapter> chapterMap = user.getHardStageManager().getChapterMap();
|
||||
Map<Integer, HardStageChapter> chapterMap = user.getHardStageManager().getChapterMap(user);
|
||||
HardStageNode node = chapterMap.get(nodeConfig.getChapter()).getNode(nodeConfig.getId());
|
||||
if(node.getType() == 1){//大节点
|
||||
int star = passReward(user,node,resultNum,dropList);
|
||||
|
|
@ -178,9 +193,9 @@ public class HardStageLogic {
|
|||
|
||||
List<SHardStage> openList = SHardStage.getPreList(nodeConfig.getId());
|
||||
for(SHardStage stage : openList){
|
||||
user.getHardStageManager().openNewNode(stage);
|
||||
user.getHardStageManager().openNewNode(user,stage);
|
||||
}
|
||||
|
||||
sendHardStageIndication(user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -215,4 +230,28 @@ public class HardStageLogic {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void sendHardStageIndication(User user) throws Exception {
|
||||
CommonProto.HardStageInfo.Builder info = getInfo(user);
|
||||
PlayerInfoProto.HardStageResponse.Builder response = PlayerInfoProto.HardStageResponse.newBuilder();
|
||||
response.setInfo(info);
|
||||
ISession session = OnlineUserManager.getSessionByUid(user.getId());
|
||||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.HARD_STAGE_INFO_RESPONSE.getNumber(),response.build(),true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级刷新
|
||||
*/
|
||||
public static void refreshInfoByLevel(User user) throws Exception{
|
||||
int curNodeId = user.getHardStageManager().getCurNode();
|
||||
if(curNodeId == 0){
|
||||
user.getHardStageManager().getChapterMap(user);
|
||||
}else{
|
||||
SHardStage nodeConfig = SHardStage.getConfigMap().get(curNodeId);
|
||||
List<SHardStage> openList = SHardStage.getPreList(nodeConfig.getId());
|
||||
for(SHardStage stage : openList){
|
||||
user.getHardStageManager().openNewNode(user,stage);
|
||||
}
|
||||
}
|
||||
sendHardStageIndication(user);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -442,7 +442,9 @@ public class CBean2Proto {
|
|||
|
||||
if(nodeConfig.getHardStageBuff() != 0){
|
||||
SHardStageBuff buff = SHardStageBuff.getConfigMap().get(nodeConfig.getHardStageBuff());
|
||||
monsterSkillList.append(buff.getPassiveSkillLogic()).append("#");
|
||||
if(buff.getType()==1 || buff.getType()==3){
|
||||
monsterSkillList.append(buff.getPassiveSkillLogic()).append("#");
|
||||
}
|
||||
}
|
||||
|
||||
CommonProto.FightUnitInfo.Builder monsterBuilder = CommonProto.FightUnitInfo.newBuilder();
|
||||
|
|
|
|||
Loading…
Reference in New Issue