山河社稷

back_recharge
xuexinpeng 2021-05-13 14:39:44 +08:00
parent 8ab1fafc40
commit 885e0112ad
16 changed files with 577 additions and 204 deletions

View File

@ -0,0 +1,84 @@
local HardStage = {
__count = 38,
__indexs = {1.83},
__values = {-420,10,31,13,2,5,3,31,12,19,2,20,2,25,4,16,13,21,30,1,8,6,78,67,1.83,112,110,89,85,29567,-5000.4,1001,1.73,3962,-5000.61,70000,1.73},
__exVals = {49,nil,'x_xiaoyaoyou_ditu_longzi','x_xiaoyaoyou_ditu_huangzi','x_xiaoyaoyou_ditu_luzi','x_xiaoyaoyou_ditu_hezi','x_xiaoyaoyou_ditu_shengzi','x_xiaoyaoyou_ditu_buzi','x_xiaoyaoyou_ditu_dizi','x_xiaoyaoyou_ditu_xuezi','x_xiaoyaoyou_ditu_jingzi','x_xiaoyaoyou_ditu_xianzi','地图名称1','地图名称2','地图名称3','地图名称4','地图名称5','地图名称6','地图名称7','地图名称8','地图名称9','地图名称10','地图名称11','地图名称12','地图名称13','地图名称14','地图名称15','地图名称16','地图名称17','地图名称18','地图名称19','地图名称2-1','地图名称2-2','地图名称2-3','地图名称2-4','地图名称2-5','地图名称2-6','地图名称2-7','地图名称2-8','地图名称2-9','地图名称2-10','地图名称2-11','地图名称2-12','地图名称2-13','地图名称2-14','地图名称2-15','地图名称2-16','地图名称2-17','地图名称2-18','地图名称2-19'},
__fields = {
'Id',
'Chapter',
'Section',
'Picture ',
'Name',
'LevelPointPosition',
'Repeat ',
'NextLevel',
'LevelLimit',
'Star ',
'MonsterGroup',
'HardStageBuff',
'RecommendFightAbility',
'PassReward',
'StageType',
'HighestStar',
'ConditionValue',
'Reward1'
},
__defaults = {
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
25,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil
},
__refs = {
{26,.81,1,.81},
{26,1.81,-18,1.81},
{166,1.9,-9,2.1,2.1,1.7},
{176,1.73},
{{{1},{66,-1,-1,-1,-3,-37,-3,-6,2,-5,-7,6,8,1,47,14.31,-8,5.1,5.4}},{{2},{13,-4,-2,-1,-1,-2,-2,1,6,4,5,4,1,-7,-2,14.31,-3,5.1,5.4}}},
{26,-1,1,2.1,4.1,8.1,2.1,0,19.81},
{25,1.73},
{50,.3,2,2.1,4.1,.2,-34,.81},
nil,
{72,1.73},
{26,1.01,-10,2.1,2.1,1.4},
{69,-2,3,2.1,-2,41,-40,2.1,41,10.5,4.3,1,9.8,8.1,2.1},
{{{1},{127,1.73}}},
{26,1,-1,2,-2,4.1,8.1,4.2,0,19.81},
{28,-3,3,2.1,4.1,8.1,2.1,0,19.81},
{{{1},{26,.91},{-2.9,3,-2.8}},{{2},{27,.91},{-2.9,3,-2.8}},{{3},{28,.91},{-2.9,3,-2.8}}},
{{{1},{129,-2.9,-18,-2.9},{-2.9,3,-2.8}},{{2},{131,-2.9,-18,-2.9},{-2.9,3,-2.8}},{{3},{133,-2.9,-18,-2.9},{-2.9,3,-2.8}}}
},
__refPoss = {
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil
},
}
return HardStage

View File

@ -0,0 +1,28 @@
local HardStageCondition = {
__count = 11,
__indexs = {1.11},
__values = {0,1.11,49989,950003},
__exVals = {11,'通过关卡','2回合内通过关卡','上阵N个神将通过关卡','5回合内造成50000伤害','使用指定佛系神将5个','存活5个人','不上阵输出神将通过关卡','不上阵佛系神将通过关卡','佩戴普贤菩萨魂印通过关卡','不使用灵兽通过关卡','全部上阵输出职业神将通过关卡'},
__fields = {
'Id',
'ConditionType',
'ConditionValue',
'Describe'
},
__defaults = {
nil,
nil,
nil
},
__refs = {
{2,1.01},
{{{1},{2,1.2,2,-3,3,-4,1,11,-13,1}},{{2},{13,-7},{4,1}}},
{15,1.01}
},
__refPoss = {
nil,
nil,
nil
},
}
return HardStageCondition

File diff suppressed because one or more lines are too long

View File

@ -190,6 +190,8 @@ ConfigName = {
ArroGantFly = "ArroGantFly",
ComposeActivity = "ComposeActivity",
ComposeBook = "ComposeBook",
HardStage ="HardStage",
HardStageCondition="HardStageCondition",
}
require "Modules/Battle/Framework/GameDataBase"

View File

@ -6761,6 +6761,7 @@ local passivityList = {
role:AddBuff(Buff.Create(role, BuffName.PropertyChange,round, BattlePropList[p1],v1, ct))
end
end,nil,nil,role)
end,
-- 敌方单位被击杀自身释放[a]技能,释放的技能类型为[b]。
-- a[int] b[int]
@ -6781,7 +6782,7 @@ local passivityList = {
end,
--英雄[a],附加的[b]种类[c]类型buff,持续时间改变[d][e]回合
--a[int],b[int buff类型],c[int type类型],d[int 改变类型],e[int]
[306] = function(role, args)
[306] = function(role, args,id,judge)
local id = args[1]
local tp1 = args[2]
local tp2 = args[3]
@ -6835,7 +6836,7 @@ local passivityList = {
end,
-- 根据生命百分比添加被动 血量百分比[a],被动id[b],...(后面没有的不配)
-- a[float],b[int],c[float],d[int],e[float],f[int],g[float],h[int]
[313] = function(role, args)
[313] = function(role, args,id,judge)
local passTable={}
for i = 1, #args do
if i%2==0 then
@ -6860,5 +6861,15 @@ local passivityList = {
end
role.Event:AddEvent(BattleEventName.RoleBeDamaged, onRoleBeDamaged,nil,nil,role)
end,
-- 普通攻击不会回复怒气
-- a[float]
[314] = function(role, args,id,judge)
role.isNormalAttackAddRage=false
end,
-- 禁止治疗
-- a[float]
[315] = function(role, args,id,judge)
role.ctrl_noheal=true
end,
}
return passivityList

View File

@ -3,11 +3,11 @@ local this = BattleLogManager
local isEditor = AppConst and AppConst.Platform == "EDITOR"
local isMobile = AppConst and (AppConst.Platform == "ANDROID" or AppConst.Platform == "IOS")
local isDebug = false
local isDebug = true
function LogBattle(str)
if isDebug then
if isEditor then
LogGreen(str)
--LogGreen(str)
else
print(str)
end
@ -114,6 +114,7 @@ function this.Log(...)
if #this.logList > 100 then
this.WriteLogToFile()
end
LogBattle(log)
end

View File

@ -1,3 +1,5 @@
require("Modules.Battle.Logic.HardStageCondition")
require("Modules.Battle.Logic.HardStageEventManager")
BattleLogic = {}
local floor = math.floor
local min = math.min
@ -22,6 +24,9 @@ local userData
local allHeroDamage=0
--所有怪的伤害和治疗
local allEnemyDamage=0
--关卡星级记录
local levelStarRecord
local hardStageId =0
--是否开启战斗日志
BattleLogic.IsOpenBattleRecord = false
--逻辑帧频
@ -44,23 +49,19 @@ function BattleLogic.Init(data, _userData, maxRound)
if BattleLogic.IsOpenBattleRecord then
record = {}
end
levelStarRecord={}
fightData = data
userData = _userData
hardStageId=data.nodeId
BattleLogic.CurOrder = 0
BattleLogic.TotalOrder = #data.enemyData
BattleLogic.Clear()
curFrame = 0
CurRound = 0
MaxRound = maxRound or 20
allHeroDamage= 0
allEnemyDamage= 0
_IsDebug = false
BattleLogic.Event:ClearEvent()
BattleLogic.BuffMgr:Init()
BattleLogic.IsEnd = false
@ -73,7 +74,7 @@ function BattleLogic.Init(data, _userData, maxRound)
SkillManager.Init()
OutDataManager.Init(fightData)
PassiveManager.Init()
HardStageEventManager.Init()
-- 监听英雄受到治疗
BattleLogic.Event:AddEvent(BattleEventName.RoleBeTreated,function (castRole, realTreat, treat)
--巅峰争霸赛和切磋超时改为只判断总伤害,不再判断总治疗
@ -94,6 +95,7 @@ function BattleLogic.Init(data, _userData, maxRound)
end
end)
end
-- 获取双方所有血量
@ -101,6 +103,15 @@ function BattleLogic.GetAllDamage()
return allHeroDamage, allEnemyDamage
end
--获取我方灵兽数据
function BattleLogic.GetPlayerMonsterData()
return fightData.playerData.monsterList
end
--获取精英副本星级记录
function BattleLogic.GetHardLevelStarRecord()
return levelStarRecord
end
-- 检测先手阵营
function BattleLogic.CheckFirstCamp()
@ -439,6 +450,20 @@ function BattleLogic.BattleEnd(result)
BattleLogic.IsEnd = true
BattleLogic.Result = result
BattleLogic.Event:DispatchEvent(BattleEventName.BattleEnd, result)
if hardStageId and hardStageId~=0 then
--获取精英副本 星级信息
local hardStageConfig=ConfigManager.GetConfigData(ConfigName.HardStage,hardStageId)
if hardStageConfig then
if hardStageConfig.ConditionValue then
for i = 1, #hardStageConfig.ConditionValue do
local harConfig = ConfigManager.GetConfigData(ConfigName.HardStageCondition,hardStageConfig.ConditionValue[i])
local v1=HardStageCondition.CheckCondition(harConfig.ConditionType,harConfig.ConditionValue)
table.insert(levelStarRecord,hardStageConfig.ConditionValue[i])
table.insert(levelStarRecord,v1)
end
end
end
end
-- 打印结果
BattleLogic.LogResult(result)
@ -446,6 +471,7 @@ function BattleLogic.BattleEnd(result)
if not BattleLogic.GetIsDebug() then
BattleLogManager.WriteLogToFile()
end
HardStageEventManager.ClearEvent()
end
-- 打印战斗结果

View File

@ -0,0 +1,131 @@
HardStageCondition = {}
local this = HardStageCondition
local _ConditionConfig = {
--通过关卡
[1]=function(condition)
if BattleLogic.Result==1 then
return 1
end
return 0
end,
--[a]回合内通过关卡
[2]=function(condition)
local v1 = condition[1]
local round,maxRound=BattleLogic.GetCurRound()
if round<=v1 then
return 1
end
return 0
end,
--上阵[a]个神将通过关卡
[3]=function(condition)
local v1 = condition[1]
local list = RoleManager.Query(function(v) return v.camp == 0 end)
if BattleUtil.LengthOfTable(list)<=v1 then
return 1
end
return 0
end,
--[a]回合内造成[b]伤害
[4]=function(condition)
local v1 = condition[1]
local v2 = condition[2]
local record=HardStageEventManager.GetRoundDamageRecord()
if record then
for key, value in pairs(record) do
if key<=v1 and value[2]>=v2 then
return 1
end
end
end
return 0
end,
--使用指定[a]系神将[b]名
[5]=function(condition)
local v1 = condition[1]
local v2 = condition[2]
local list = RoleManager.Query(function(v) return v.camp == 0 and v.element==v1 end)
if BattleUtil.LengthOfTable(list)>=v2 then
return 1
end
return 0
end,
--存活[a]名
[6]=function(condition)
local v1 = condition[1]
local list = RoleManager.Query(function(v) return v.camp == 0 and not v:IsDead() end)
if BattleUtil.LengthOfTable(list)>=v1 then
return 1
end
return 0
end,
--不上阵[a]职能神将通过关卡
[7]=function(condition)
local v1 = condition[1]
local list = RoleManager.Query(function(v) return v.camp == 0 and v.professionId==v1 end)
if BattleUtil.LengthOfTable(list)==0 then
return 1
end
return 0
end,
--不上阵[a]阵营神将通过关卡
[8]=function(condition)
local v1 = condition[1]
local list = RoleManager.Query(function(v) return v.camp == 0 and v.element==v1 end)
if BattleUtil.LengthOfTable(list)==0 then
return 1
end
return 0
end,
--佩戴xxxid被动通过关卡
[9]=function(condition)
local v1 = condition[1]
local list = RoleManager.Query(function(v) return v.camp == 0 end)
if not list or #list==0 then
return 0
end
for i = 1, #list do
local isHave=list[i]:CheckHavePassive(v1)
if isHave then
return 1
end
end
return 0
end,
--不使用灵兽通过关卡
[10]=function(condition)
local v1 = condition[1]
local data=BattleLogic.GetPlayerMonsterData()
if data and BattleUtil.LengthOfTable(data)>v1 then
return 0
end
return 1
end,
--全部上阵[a]职业神将通过关卡
[11]=function(condition)
local v1 = condition[1]
local list = RoleManager.Query(function(v) return v.camp == 0 and v.professionId~=v1 end)
if BattleUtil.LengthOfTable(list)==0 then
return 1
end
return 0
end,
}
-- 条件检测
function HardStageCondition.CheckCondition(type,condition)
--LogError("*************".. type.." "..condition)
if not condition then
return true
end
-- local v1 = condition[1]
-- local v2 = condition[2]
-- local v3 = condition[3]
return _ConditionConfig[type](condition)
end
return HardStageCondition

View File

@ -0,0 +1,43 @@
HardStageEventManager = {}
local this = HardStageEventManager
local CurRound
--记录的回合数
local recordRound=1
local roundDamage=0
--记录的回合伤害
local recordRoundDamage
function this.Init()
recordRound=1
roundDamage=0
recordRoundDamage={}
BattleLogic.Event:AddEvent(BattleEventName.RecordDamage,this.OnRecordDamage)
end
function this.ClearEvent()
BattleLogic.Event:RemoveEvent(BattleEventName.RecordDamage,this.OnRecordDamage)
end
--记录伤害
function this.OnRecordDamage(atkRole,defRole,damage)
if not atkRole or atkRole.camp==1 then
return
end
local curRound,maxRound=BattleLogic.GetCurRound()
CurRound=curRound
--如果进入下一回合,记录上一回合的伤害
if CurRound==recordRound+1 then
table.insert(recordRoundDamage,{recordRound,roundDamage})
recordRound=CurRound
end
roundDamage=roundDamage+damage
end
--获取回合伤害记录
function this.GetRoundDamageRecord()
--如果一回合就结束战斗了,就直接把记录的回合数伤害加进去
if CurRound==1 then
table.insert(recordRoundDamage,{recordRound,roundDamage})
end
return recordRoundDamage
end
return HardStageEventManager

View File

@ -1,3 +1,16 @@
v1.0.31
1. 添加精英副本相关战斗逻辑
v1.0.30
1. 同步客户端被动表lua文件
v1.0.29
1、新增客户端数据文件客户端数据解析文件
1、被动新增 313用于动态从表数据里面抓取被动数据
v1.0.28
1、BattleMain添加测试接口
v1.0.27
1、清除轮转方法防止收到上一局战斗的影响
v1.0.26
1、合并海外战斗内容
v1.0.25
1、选择单个对位目标修改
v1.0.24

View File

@ -17,12 +17,14 @@ import com.ljsd.jieling.logic.fight.FightUtil;
import com.ljsd.jieling.logic.fight.result.FightResult;
import com.ljsd.jieling.logic.hardStage.HardStageChapter;
import com.ljsd.jieling.logic.hardStage.HardStageLogic;
import com.ljsd.jieling.logic.hardStage.HardStageNode;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.util.FightDataUtil;
import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.MonsterUtil;
import config.SHardStage;
import org.luaj.vm2.LuaValue;
import org.luaj.vm2.lib.jse.JseMathLib;
import rpc.protocols.*;
import java.util.ArrayList;
@ -48,41 +50,45 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点不存在或未开启"));
}
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
PlayerInfoProto.HardStageFightResponse.Builder fightStartResponse = PlayerInfoProto.HardStageFightResponse.newBuilder();
if (teamPosHeroInfos == null || teamPosHeroInfos.size() == 0) {
throw new ErrorCodeException(ErrorCode.newDefineCode("阵容有误!!"));
}
if(nodeConfig.getStageType() == 2){//直接发奖励
HardStageLogic.passNode(iSession,nodeConfig,0,dropList);
return;
}
int seed = (int)(System.currentTimeMillis()/1000);
CommonProto.FightTeamInfo fightTeamInfo = HardStageLogic.getFightTeamInfo(user, teamId, nodeConfig);
//直接发奖励
if (nodeConfig.getStageType() == 2) {
Map<Integer, HardStageChapter> chapt = user.getHardStageManager().getChapterMap(user);
HardStageNode node = chapt.get(nodeConfig.getChapter()).getNode(nodeConfig.getId());
node.setHasPass(true);
dropList.addAll(HardStageLogic.getFirstRewards(user, nodeConfig));
} else if (nodeConfig.getStageType() == 1 || nodeConfig.getStageType() == 3) {
//战斗后发奖励
int seed = (int) (System.currentTimeMillis() / 1000);
Map<Integer, List<CommonProto.FightUnitInfo>> monsterfightTeamInfos = MonsterUtil.getHardStageMonsterByGroup(nodeConfig);
List<CommonProto.FightUnitInfo> monsterPokemonByGroup = MonsterUtil.getMonsterPokemonByGroup(nodeConfig.getMonsterGroup());
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().checkHardStageFight(seed, 20, getFightData, getOptionData, FightType.HardStage);
int resultCode = (int) fightResult[0][0];
long[][] fight = CheckFight.getInstance().checkHardStageFight(seed, 20, getFightData, getOptionData, FightType.HardStage);
int[] resultNum = new int[3];
resultNum[0] = (int) fight[1][1];
resultNum[1] = (int) fight[1][3];
resultNum[2] = (int) fight[1][5];
System.err.print("0:" + resultNum[0] + "1:" + resultNum[1] + "2:" + resultNum[2]);
int resultCode = (int) fight[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, resultNum, dropList);
}else{
HardStageLogic.passNode(iSession,nodeConfig,0,dropList);
}
//战斗回放
String fightInfo = nodeId + "#" + seed + "#" + teamId;
String key = RedisKey.getKey(RedisKey.HARD_STAGE_BATTLE, String.valueOf(iSession.getUid()), false);
RedisUtil.getInstence().set(key, fightInfo, -1);
PlayerInfoProto.HardStageFightResponse.Builder fightStartResponse = PlayerInfoProto.HardStageFightResponse.newBuilder();
String fightId = FightUtil.getFightId(user.getId(), FightType.HardStage.getType());
CommonProto.FightData fightData = CommonProto.FightData.newBuilder()
.setFightType(FightType.HardStage.getType())
@ -93,11 +99,17 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
.setFightId(fightId)
.build();
fightStartResponse.setFightData(fightData);
FightRecordLogic.getInstance().addRecordMap(user, fightData);
}
for (CommonProto.Drop.Builder drop : dropList) {
fightStartResponse.addDrop(drop);
}
FightRecordLogic.getInstance().addRecordMap(user,fightData);
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.HARD_STAGE_FIGHT_START_RESPONSE.getNumber(), fightStartResponse.build(), true);
//更新消息
CommonProto.HardStageInfo.Builder info = HardStageLogic.getInfo(user);
PlayerInfoProto.HardStageResponse.Builder response = PlayerInfoProto.HardStageResponse.newBuilder();
response.setInfo(info);
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.HARD_STAGE_INFO_RESPONSE.getNumber(), response.build(), true);
}
}

View File

@ -20,6 +20,7 @@ public class HardStageManager extends MongoBase {
public HardStageManager() {
}
public Map<Integer, HardStageChapter> getChapterMap(User user) throws Exception {
if (null == chapterMap || chapterMap.size() < 1) {
Map<Integer, HardStageChapter> map = initChapterMap(user);
@ -34,19 +35,22 @@ public class HardStageManager extends MongoBase {
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);
HardStageNode node = initNode(nodeOne, chapter.getChapterId());
//chapter.init(this.getRootId(), getMongoKey() + ".chapterMap." + chapter.getChapterId());
chapter.addNodeList(node);
setCurNode(node.getId());
map.put(chapter.getChapterId(), chapter);
setCurChapter(chapter.getChapterId());
updateString("chapterMap." + chapter.getChapterId(), chapter);
return map;
}
private HardStageNode initNode(SHardStage config){
private HardStageNode initNode(SHardStage config, int chapterId) {
HardStageNode node = new HardStageNode();
//node.init(this.getRootId(),getMongoKey()+".chapterMap."+chapterId+".nodeList");
node.setId(config.getId());
node.setType(config.getStageType());
if (node.getType() == 1) {
@ -54,22 +58,26 @@ public class HardStageManager extends MongoBase {
node.getRewardMap().put(config.getReward1()[1], Boolean.FALSE);
node.getRewardMap().put(config.getReward1()[2], Boolean.FALSE);
}
setCurNode(config.getId());
return node;
}
private HardStageChapter initChapter(int chapterId) {
HardStageChapter chapter = new HardStageChapter();
chapter.setChapterId(chapterId);
chapter.init(this.getRootId(), getMongoKey() + ".chapterMap." + chapter.getChapterId());
List<SHardStageReward> reward = SHardStageReward.getChapterConfigMap().get(chapterId);
for (SHardStageReward config : reward) {
chapter.getRewardMap().put(config.getStarReward(), Boolean.FALSE);
chapter.updateRewardMap();
}
setCurChapter(chapterId);
return chapter;
}
/**
*
*
* @param config
*/
public void openNewNode(User user, SHardStage config) {
@ -77,7 +85,10 @@ public class HardStageManager extends MongoBase {
return;
}
HardStageChapter chapter;
if(chapterMap.containsKey(config.getChapter())){
chapter = chapterMap.computeIfAbsent(config.getChapter(), k -> initChapter(config.getChapter()));
HardStageNode node = initNode(config, chapter.getChapterId());
chapter.addNodeList(node);
/*if(chapterMap.containsKey(config.getChapter())){
chapter = chapterMap.get(config.getChapter());
HardStageNode node = initNode(config);
chapter.addNodeList(node);
@ -91,8 +102,8 @@ public class HardStageManager extends MongoBase {
setCurNode(node.getId());
chapterMap.put(config.getChapter(),chapter);
setCurChapter(chapter.getChapterId());
}
updateString("chapterMap." + chapter.getChapterId(), chapterMap);
}*/
updateString("chapterMap." + chapter.getChapterId(), chapterMap.get(chapter.getChapterId()));
}
public int getCurChapter() {

View File

@ -31,7 +31,7 @@ public class HardStageChapter extends MongoBase {
public void addNodeList(HardStageNode node) {
this.nodeList.add(node);
node.init(this.getRootId(), getMongoKey() + ".nodeList." + node.getId());
//node.init(this.getRootId(), getMongoKey() + ".nodeList." + node.getId());
updateString("nodeList", nodeList);
}

View File

@ -43,6 +43,7 @@ public class HardStageLogic {
nodeBuilder.setNodeId(node.getId());
nodeBuilder.setType(node.getType());
nodeBuilder.setState(node.getState());
nodeBuilder.setIsFirst(node.isHasPass());
chapterBuilder.addNode(nodeBuilder);
}
chapterBuilder.setChapterId(entry.getKey());
@ -90,24 +91,24 @@ public class HardStageLogic {
/**
*
*/
public static int passReward(User user,HardStageNode node,int num,List<CommonProto.Drop.Builder> dropList) throws Exception{
public static int passReward(User user, HardStageNode node, int[] num, List<CommonProto.Drop.Builder> dropList) throws Exception {
int addStar = 0;
SHardStage config = SHardStage.getConfigMap().get(node.getId());
if(num>>2 == 1){//第一星
if (num[0] == 1) {//第一星
int rewardId = config.getReward1()[0];
if (addDropAndStar(node, dropList, rewardId, user)) {
node.setState(node.getState() + 4);
addStar++;
addStar += 4;
}
}
if((num&2) == 2){//第二星
if (num[1] == 1) {//第二星
int rewardId = config.getReward1()[1];
if (addDropAndStar(node, dropList, rewardId, user)) {
node.setState(node.getState() + 2);
addStar++;
addStar += 2;
}
}
if(num<<2 == 1){//第三星
if (num[2] == 1) {//第三星
int rewardId = config.getReward1()[2];
if (addDropAndStar(node, dropList, rewardId, user)) {
node.setState(node.getState() + 1);
@ -172,29 +173,38 @@ public class HardStageLogic {
/**
*
*/
public static void passNode(ISession iSession, SHardStage nodeConfig, int resultNum,List<CommonProto.Drop.Builder> dropList) throws Exception{
public static void passNode(ISession iSession, SHardStage nodeConfig, int[] resultNum, List<CommonProto.Drop.Builder> dropList) throws Exception {
User user = UserManager.getUser(iSession.getUid());
if(user == null){
return;
}
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);
int star = passReward(user, node, resultNum, dropList);//星级通关奖励
chapterMap.get(nodeConfig.getChapter()).addStars(star);
if (!node.isHasPass()) {
node.setHasPass(true);
dropList.addAll(getFirstRewards(user,nodeConfig));
dropList.addAll(getFirstRewards(user, nodeConfig));//关卡通过奖励
//SHardStage nextNodeConfig = SHardStage.getConfigMap().get(nodeConfig.getNextLevel());
SHardStage.getPreList(nodeConfig.getId()).stream().forEach(n -> {
if (n != null) {
user.getHardStageManager().openNewNode(user, n);
}
});
}
} else {
if (node.isHasPass()) {
return;
}
node.setHasPass(true);
dropList.addAll(getFirstRewards(user,nodeConfig));
//node.setHasPass(true);
//dropList.addAll(getFirstRewards(user,nodeConfig));
}
List<SHardStage> openList = SHardStage.getPreList(nodeConfig.getId());
/* List<SHardStage> openList = SHardStage.getPreList(nodeConfig.getId());
for(SHardStage stage : openList){
user.getHardStageManager().openNewNode(user,stage);
}
}*/
sendHardStageIndication(user);
}
@ -214,14 +224,14 @@ public class HardStageLogic {
*/
public static CommonProto.Drop.Builder getReward(User user, int rewardId) throws Exception {
SRewardGroup rewardGroup = SRewardGroup.getsRewardItemMap().get(rewardId);
ItemMap itemObj = new ItemMap();
//ItemMap itemObj = new ItemMap();
int[] dropList = rewardGroup.getRewardItem();
CommonProto.Drop.Builder drop = ItemUtil.drop(user, dropList, 1, 0, BIReason.HARD_STAGE_GET);
return drop;
}
private static boolean addDropAndStar(HardStageNode node, List<CommonProto.Drop.Builder> dropList, int rewardId, User user) throws Exception {
if(!node.getRewardMap().get(rewardId)){
if (node.getRewardMap().get(rewardId)) {
dropList.add(getReward(user, rewardId));
node.getRewardMap().put(rewardId, true);
node.updateRewardMap();
@ -246,11 +256,11 @@ public class HardStageLogic {
if (curNodeId == 0) {
user.getHardStageManager().getChapterMap(user);
} else {
SHardStage nodeConfig = SHardStage.getConfigMap().get(curNodeId);
/*SHardStage nodeConfig = SHardStage.getConfigMap().get(curNodeId);
List<SHardStage> openList = SHardStage.getPreList(nodeConfig.getId());
for(SHardStage stage : openList){
user.getHardStageManager().openNewNode(user,stage);
}
}*/
}
sendHardStageIndication(user);
}

View File

@ -87,6 +87,10 @@ public class SHardStage implements BaseConfig {
return repeat;
}
public int getStar() {
return star;
}
public int getNextLevel() {
return nextLevel;
}
@ -95,9 +99,6 @@ public class SHardStage implements BaseConfig {
return levelLimit;
}
public int getStar () {
return star ;
}
public int getMonsterGroup() {
return monsterGroup;