山河社稷

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", ArroGantFly = "ArroGantFly",
ComposeActivity = "ComposeActivity", ComposeActivity = "ComposeActivity",
ComposeBook = "ComposeBook", ComposeBook = "ComposeBook",
HardStage ="HardStage",
HardStageCondition="HardStageCondition",
} }
require "Modules/Battle/Framework/GameDataBase" 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)) role:AddBuff(Buff.Create(role, BuffName.PropertyChange,round, BattlePropList[p1],v1, ct))
end end
end,nil,nil,role) end,nil,nil,role)
end, end,
-- 敌方单位被击杀自身释放[a]技能,释放的技能类型为[b]。 -- 敌方单位被击杀自身释放[a]技能,释放的技能类型为[b]。
-- a[int] b[int] -- a[int] b[int]
@ -6781,7 +6782,7 @@ local passivityList = {
end, end,
--英雄[a],附加的[b]种类[c]类型buff,持续时间改变[d][e]回合 --英雄[a],附加的[b]种类[c]类型buff,持续时间改变[d][e]回合
--a[int],b[int buff类型],c[int type类型],d[int 改变类型],e[int] --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 id = args[1]
local tp1 = args[2] local tp1 = args[2]
local tp2 = args[3] local tp2 = args[3]
@ -6835,7 +6836,7 @@ local passivityList = {
end, end,
-- 根据生命百分比添加被动 血量百分比[a],被动id[b],...(后面没有的不配) -- 根据生命百分比添加被动 血量百分比[a],被动id[b],...(后面没有的不配)
-- a[float],b[int],c[float],d[int],e[float],f[int],g[float],h[int] -- 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={} local passTable={}
for i = 1, #args do for i = 1, #args do
if i%2==0 then if i%2==0 then
@ -6860,5 +6861,15 @@ local passivityList = {
end end
role.Event:AddEvent(BattleEventName.RoleBeDamaged, onRoleBeDamaged,nil,nil,role) role.Event:AddEvent(BattleEventName.RoleBeDamaged, onRoleBeDamaged,nil,nil,role)
end, 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 return passivityList

View File

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

View File

@ -1,3 +1,5 @@
require("Modules.Battle.Logic.HardStageCondition")
require("Modules.Battle.Logic.HardStageEventManager")
BattleLogic = {} BattleLogic = {}
local floor = math.floor local floor = math.floor
local min = math.min local min = math.min
@ -22,6 +24,9 @@ local userData
local allHeroDamage=0 local allHeroDamage=0
--所有怪的伤害和治疗 --所有怪的伤害和治疗
local allEnemyDamage=0 local allEnemyDamage=0
--关卡星级记录
local levelStarRecord
local hardStageId =0
--是否开启战斗日志 --是否开启战斗日志
BattleLogic.IsOpenBattleRecord = false BattleLogic.IsOpenBattleRecord = false
--逻辑帧频 --逻辑帧频
@ -44,23 +49,19 @@ function BattleLogic.Init(data, _userData, maxRound)
if BattleLogic.IsOpenBattleRecord then if BattleLogic.IsOpenBattleRecord then
record = {} record = {}
end end
levelStarRecord={}
fightData = data fightData = data
userData = _userData userData = _userData
hardStageId=data.nodeId
BattleLogic.CurOrder = 0 BattleLogic.CurOrder = 0
BattleLogic.TotalOrder = #data.enemyData BattleLogic.TotalOrder = #data.enemyData
BattleLogic.Clear() BattleLogic.Clear()
curFrame = 0 curFrame = 0
CurRound = 0 CurRound = 0
MaxRound = maxRound or 20 MaxRound = maxRound or 20
allHeroDamage= 0 allHeroDamage= 0
allEnemyDamage= 0 allEnemyDamage= 0
_IsDebug = false _IsDebug = false
BattleLogic.Event:ClearEvent() BattleLogic.Event:ClearEvent()
BattleLogic.BuffMgr:Init() BattleLogic.BuffMgr:Init()
BattleLogic.IsEnd = false BattleLogic.IsEnd = false
@ -73,7 +74,7 @@ function BattleLogic.Init(data, _userData, maxRound)
SkillManager.Init() SkillManager.Init()
OutDataManager.Init(fightData) OutDataManager.Init(fightData)
PassiveManager.Init() PassiveManager.Init()
HardStageEventManager.Init()
-- 监听英雄受到治疗 -- 监听英雄受到治疗
BattleLogic.Event:AddEvent(BattleEventName.RoleBeTreated,function (castRole, realTreat, treat) BattleLogic.Event:AddEvent(BattleEventName.RoleBeTreated,function (castRole, realTreat, treat)
--巅峰争霸赛和切磋超时改为只判断总伤害,不再判断总治疗 --巅峰争霸赛和切磋超时改为只判断总伤害,不再判断总治疗
@ -93,6 +94,7 @@ function BattleLogic.Init(data, _userData, maxRound)
allEnemyDamage=allEnemyDamage+damage allEnemyDamage=allEnemyDamage+damage
end end
end) end)
end end
@ -101,6 +103,15 @@ function BattleLogic.GetAllDamage()
return allHeroDamage, allEnemyDamage return allHeroDamage, allEnemyDamage
end end
--获取我方灵兽数据
function BattleLogic.GetPlayerMonsterData()
return fightData.playerData.monsterList
end
--获取精英副本星级记录
function BattleLogic.GetHardLevelStarRecord()
return levelStarRecord
end
-- 检测先手阵营 -- 检测先手阵营
function BattleLogic.CheckFirstCamp() function BattleLogic.CheckFirstCamp()
@ -439,13 +450,28 @@ function BattleLogic.BattleEnd(result)
BattleLogic.IsEnd = true BattleLogic.IsEnd = true
BattleLogic.Result = result BattleLogic.Result = result
BattleLogic.Event:DispatchEvent(BattleEventName.BattleEnd, 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) BattleLogic.LogResult(result)
-- 战斗日志写入 -- 战斗日志写入
if not BattleLogic.GetIsDebug() then if not BattleLogic.GetIsDebug() then
BattleLogManager.WriteLogToFile() BattleLogManager.WriteLogToFile()
end end
HardStageEventManager.ClearEvent()
end 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 v1.0.25
1、选择单个对位目标修改 1、选择单个对位目标修改
v1.0.24 v1.0.24

View File

@ -23,6 +23,6 @@ public class HardStageInfoRequestHandler extends BaseHandler<PlayerInfoProto.Har
CommonProto.HardStageInfo.Builder info = HardStageLogic.getInfo(user); CommonProto.HardStageInfo.Builder info = HardStageLogic.getInfo(user);
PlayerInfoProto.HardStageResponse.Builder response = PlayerInfoProto.HardStageResponse.newBuilder(); PlayerInfoProto.HardStageResponse.Builder response = PlayerInfoProto.HardStageResponse.newBuilder();
response.setInfo(info); response.setInfo(info);
MessageUtil.sendMessage(iSession, 1,MessageTypeProto.MessageType.HARD_STAGE_INFO_RESPONSE.getNumber(), response.build(), true); MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.HARD_STAGE_INFO_RESPONSE.getNumber(), response.build(), true);
} }
} }

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.fight.result.FightResult;
import com.ljsd.jieling.logic.hardStage.HardStageChapter; import com.ljsd.jieling.logic.hardStage.HardStageChapter;
import com.ljsd.jieling.logic.hardStage.HardStageLogic; 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.network.session.ISession;
import com.ljsd.jieling.util.FightDataUtil; import com.ljsd.jieling.util.FightDataUtil;
import com.ljsd.jieling.util.MessageUtil; import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.MonsterUtil; import com.ljsd.jieling.util.MonsterUtil;
import config.SHardStage; import config.SHardStage;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
import org.luaj.vm2.lib.jse.JseMathLib;
import rpc.protocols.*; import rpc.protocols.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -44,60 +46,70 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
List<CommonProto.Drop.Builder> dropList = new ArrayList<>(); List<CommonProto.Drop.Builder> dropList = new ArrayList<>();
SHardStage nodeConfig = SHardStage.getConfigMap().get(nodeId); SHardStage nodeConfig = SHardStage.getConfigMap().get(nodeId);
Map<Integer, HardStageChapter> chapterMap = user.getHardStageManager().getChapterMap(user); Map<Integer, HardStageChapter> chapterMap = user.getHardStageManager().getChapterMap(user);
if(!chapterMap.containsKey(nodeConfig.getChapter()) || chapterMap.get(nodeConfig.getChapter()).getNode(nodeId) == null){ if (!chapterMap.containsKey(nodeConfig.getChapter()) || chapterMap.get(nodeConfig.getChapter()).getNode(nodeId) == null) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点不存在或未开启")); throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点不存在或未开启"));
} }
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId); List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
PlayerInfoProto.HardStageFightResponse.Builder fightStartResponse = PlayerInfoProto.HardStageFightResponse.newBuilder();
if (teamPosHeroInfos == null || teamPosHeroInfos.size() == 0) { if (teamPosHeroInfos == null || teamPosHeroInfos.size() == 0) {
throw new ErrorCodeException(ErrorCode.newDefineCode("阵容有误!!")); throw new ErrorCodeException(ErrorCode.newDefineCode("阵容有误!!"));
} }
if(nodeConfig.getStageType() == 2){//直接发奖励 CommonProto.FightTeamInfo fightTeamInfo = HardStageLogic.getFightTeamInfo(user, teamId, nodeConfig);
HardStageLogic.passNode(iSession,nodeConfig,0,dropList); //直接发奖励
return; if (nodeConfig.getStageType() == 2) {
} Map<Integer, HardStageChapter> chapt = user.getHardStageManager().getChapterMap(user);
int seed = (int)(System.currentTimeMillis()/1000); HardStageNode node = chapt.get(nodeConfig.getChapter()).getNode(nodeConfig.getId());
CommonProto.FightTeamInfo fightTeamInfo = HardStageLogic.getFightTeamInfo(user,teamId,nodeConfig); node.setHasPass(true);
Map<Integer, List<CommonProto.FightUnitInfo>> monsterfightTeamInfos = MonsterUtil.getHardStageMonsterByGroup(nodeConfig); dropList.addAll(HardStageLogic.getFirstRewards(user, nodeConfig));
List<CommonProto.FightUnitInfo> monsterPokemonByGroup = MonsterUtil.getMonsterPokemonByGroup(nodeConfig.getMonsterGroup()); } else if (nodeConfig.getStageType() == 1 || nodeConfig.getStageType() == 3) {
List<CommonProto.FightTeamInfo> monsterGroupList = BehaviorUtil.getFightTeamInfos(monsterfightTeamInfos,monsterPokemonByGroup, Global.MONSTER_1); //战斗后发奖励
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[][] 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);
}
if (resultCode == 1) {//通过
HardStageLogic.passNode(iSession, nodeConfig, resultNum, 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);
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]; String fightId = FightUtil.getFightId(user.getId(), FightType.HardStage.getType());
if (resultCode == -1) { CommonProto.FightData fightData = CommonProto.FightData.newBuilder()
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION); .setFightType(FightType.HardStage.getType())
} .setHeroFightInfos(fightTeamInfo)
int resultNum = (int)fightResult[1][1]+(int)fightResult[1][3]+(int)fightResult[1][5]; .addAllMonsterList(monsterGroupList)
if(resultCode == 1){//通过 .setFightSeed(seed)
HardStageLogic.passNode(iSession,nodeConfig,resultNum,dropList); .setFightMaxTime(20)
}else{ .setFightId(fightId)
HardStageLogic.passNode(iSession,nodeConfig,0,dropList); .build();
fightStartResponse.setFightData(fightData);
FightRecordLogic.getInstance().addRecordMap(user, fightData);
} }
for (CommonProto.Drop.Builder drop : 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())
.setHeroFightInfos(fightTeamInfo)
.addAllMonsterList(monsterGroupList)
.setFightSeed(seed)
.setFightMaxTime(20)
.setFightId(fightId)
.build();
fightStartResponse.setFightData(fightData);
for(CommonProto.Drop.Builder drop : dropList){
fightStartResponse.addDrop(drop); fightStartResponse.addDrop(drop);
} }
FightRecordLogic.getInstance().addRecordMap(user,fightData); MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.HARD_STAGE_FIGHT_START_RESPONSE.getNumber(), fightStartResponse.build(), true);
//更新消息
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

@ -15,69 +15,80 @@ public class HardStageManager extends MongoBase {
private int curChapter; private int curChapter;
private int curNode; private int curNode;
private Map<Integer, HardStageChapter> chapterMap ;//山河玩家信息 private Map<Integer, HardStageChapter> chapterMap;//山河玩家信息
public HardStageManager(){ public HardStageManager() {
} }
public Map<Integer, HardStageChapter> getChapterMap(User user) throws Exception{
if(null == chapterMap ||chapterMap.size()<1){ public Map<Integer, HardStageChapter> getChapterMap(User user) throws Exception {
if (null == chapterMap || chapterMap.size() < 1) {
Map<Integer, HardStageChapter> map = initChapterMap(user); Map<Integer, HardStageChapter> map = initChapterMap(user);
chapterMap = map; chapterMap = map;
} }
return chapterMap; return chapterMap;
} }
private Map<Integer, HardStageChapter> initChapterMap(User user) throws Exception{ private Map<Integer, HardStageChapter> initChapterMap(User user) throws Exception {
Map<Integer, HardStageChapter> map = new HashMap<>(); Map<Integer, HardStageChapter> map = new HashMap<>();
SHardStage nodeOne = SHardStage.getConfigMap().get(1);//第一个节点 SHardStage nodeOne = SHardStage.getConfigMap().get(1);//第一个节点
if(user.getPlayerInfoManager().getLevel()<nodeOne.getLevelLimit()){ if (user.getPlayerInfoManager().getLevel() < nodeOne.getLevelLimit()) {
return map; return map;
} }
HardStageNode node = initNode(nodeOne); //初始化第一章第一节
HardStageChapter chapter = initChapter(nodeOne.getChapter()); HardStageChapter chapter = initChapter(nodeOne.getChapter());
chapter.init(this.getRootId(), getMongoKey() + ".chapterMap." + chapter.getChapterId()); HardStageNode node = initNode(nodeOne, chapter.getChapterId());
updateString("chapterMap." + chapter.getChapterId(), chapter); //chapter.init(this.getRootId(), getMongoKey() + ".chapterMap." + chapter.getChapterId());
chapter.addNodeList(node); chapter.addNodeList(node);
setCurNode(node.getId()); setCurNode(node.getId());
map.put(chapter.getChapterId(),chapter); map.put(chapter.getChapterId(), chapter);
setCurChapter(chapter.getChapterId()); setCurChapter(chapter.getChapterId());
updateString("chapterMap." + chapter.getChapterId(), chapter);
return map; return map;
} }
private HardStageNode initNode(SHardStage config){ private HardStageNode initNode(SHardStage config, int chapterId) {
HardStageNode node = new HardStageNode(); HardStageNode node = new HardStageNode();
//node.init(this.getRootId(),getMongoKey()+".chapterMap."+chapterId+".nodeList");
node.setId(config.getId()); node.setId(config.getId());
node.setType(config.getStageType()); node.setType(config.getStageType());
if(node.getType() == 1){ if (node.getType() == 1) {
node.getRewardMap().put(config.getReward1()[0],Boolean.FALSE); node.getRewardMap().put(config.getReward1()[0], Boolean.FALSE);
node.getRewardMap().put(config.getReward1()[1],Boolean.FALSE); node.getRewardMap().put(config.getReward1()[1], Boolean.FALSE);
node.getRewardMap().put(config.getReward1()[2],Boolean.FALSE); node.getRewardMap().put(config.getReward1()[2], Boolean.FALSE);
} }
setCurNode(config.getId());
return node; return node;
} }
private HardStageChapter initChapter(int chapterId){ private HardStageChapter initChapter(int chapterId) {
HardStageChapter chapter = new HardStageChapter(); HardStageChapter chapter = new HardStageChapter();
chapter.setChapterId(chapterId); chapter.setChapterId(chapterId);
chapter.init(this.getRootId(), getMongoKey() + ".chapterMap." + chapter.getChapterId());
List<SHardStageReward> reward = SHardStageReward.getChapterConfigMap().get(chapterId); List<SHardStageReward> reward = SHardStageReward.getChapterConfigMap().get(chapterId);
for(SHardStageReward config : reward){ for (SHardStageReward config : reward) {
chapter.getRewardMap().put(config.getStarReward(),Boolean.FALSE); chapter.getRewardMap().put(config.getStarReward(), Boolean.FALSE);
chapter.updateRewardMap(); chapter.updateRewardMap();
} }
setCurChapter(chapterId);
return chapter; return chapter;
} }
/** /**
* *
*
* @param config * @param config
*/ */
public void openNewNode(User user,SHardStage config){ public void openNewNode(User user, SHardStage config) {
if(user.getPlayerInfoManager().getLevel()<config.getLevelLimit()){ if (user.getPlayerInfoManager().getLevel() < config.getLevelLimit()) {
return; return;
} }
HardStageChapter chapter ; 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()); chapter = chapterMap.get(config.getChapter());
HardStageNode node = initNode(config); HardStageNode node = initNode(config);
chapter.addNodeList(node); chapter.addNodeList(node);
@ -91,8 +102,8 @@ public class HardStageManager extends MongoBase {
setCurNode(node.getId()); setCurNode(node.getId());
chapterMap.put(config.getChapter(),chapter); chapterMap.put(config.getChapter(),chapter);
setCurChapter(chapter.getChapterId()); setCurChapter(chapter.getChapterId());
} }*/
updateString("chapterMap." + chapter.getChapterId(), chapterMap); updateString("chapterMap." + chapter.getChapterId(), chapterMap.get(chapter.getChapterId()));
} }
public int getCurChapter() { public int getCurChapter() {
@ -101,7 +112,7 @@ public class HardStageManager extends MongoBase {
public void setCurChapter(int curChapter) { public void setCurChapter(int curChapter) {
this.curChapter = curChapter; this.curChapter = curChapter;
updateString("curChapter" ,curChapter); updateString("curChapter", curChapter);
} }
public int getCurNode() { public int getCurNode() {
@ -110,6 +121,6 @@ public class HardStageManager extends MongoBase {
public void setCurNode(int curNode) { public void setCurNode(int curNode) {
this.curNode = curNode; this.curNode = curNode;
updateString("curNode" ,curNode); updateString("curNode", curNode);
} }
} }

View File

@ -15,7 +15,7 @@ public class HardStageChapter extends MongoBase {
private int stars; private int stars;
private Map<Integer,Boolean> rewardMap = new HashMap<>(); private Map<Integer, Boolean> rewardMap = new HashMap<>();
public int getChapterId() { public int getChapterId() {
return chapterId; return chapterId;
@ -31,8 +31,8 @@ public class HardStageChapter extends MongoBase {
public void addNodeList(HardStageNode node) { public void addNodeList(HardStageNode node) {
this.nodeList.add(node); this.nodeList.add(node);
node.init(this.getRootId(), getMongoKey() + ".nodeList." + node.getId()); //node.init(this.getRootId(), getMongoKey() + ".nodeList." + node.getId());
updateString("nodeList" ,nodeList); updateString("nodeList", nodeList);
} }
public int getStars() { public int getStars() {
@ -41,7 +41,7 @@ public class HardStageChapter extends MongoBase {
public void addStars(int stars) { public void addStars(int stars) {
this.stars += stars; this.stars += stars;
updateString("stars" , this.stars); updateString("stars", this.stars);
} }
public Map<Integer, Boolean> getRewardMap() { public Map<Integer, Boolean> getRewardMap() {
@ -49,12 +49,12 @@ public class HardStageChapter extends MongoBase {
} }
public void updateRewardMap() { public void updateRewardMap() {
updateString("rewardMap" , this.rewardMap); updateString("rewardMap", this.rewardMap);
} }
public HardStageNode getNode(int id){ public HardStageNode getNode(int id) {
for(HardStageNode node : nodeList){ for (HardStageNode node : nodeList) {
if(node.getId() == id){ if (node.getId() == id) {
return node; return node;
} }
} }

View File

@ -33,24 +33,25 @@ public class HardStageLogic {
/** /**
* *
*/ */
public static CommonProto.HardStageInfo.Builder getInfo(User user) throws Exception{ public static CommonProto.HardStageInfo.Builder getInfo(User user) throws Exception {
Map<Integer, HardStageChapter> map = user.getHardStageManager().getChapterMap(user); Map<Integer, HardStageChapter> map = user.getHardStageManager().getChapterMap(user);
CommonProto.HardStageInfo.Builder builder = CommonProto.HardStageInfo.newBuilder(); CommonProto.HardStageInfo.Builder builder = CommonProto.HardStageInfo.newBuilder();
for(Map.Entry<Integer,HardStageChapter> entry : map.entrySet()){ for (Map.Entry<Integer, HardStageChapter> entry : map.entrySet()) {
CommonProto.HardStageChapter.Builder chapterBuilder = CommonProto.HardStageChapter.newBuilder(); CommonProto.HardStageChapter.Builder chapterBuilder = CommonProto.HardStageChapter.newBuilder();
for(HardStageNode node : entry.getValue().getNodeList()){ for (HardStageNode node : entry.getValue().getNodeList()) {
CommonProto.HardStageNode.Builder nodeBuilder = CommonProto.HardStageNode.newBuilder(); CommonProto.HardStageNode.Builder nodeBuilder = CommonProto.HardStageNode.newBuilder();
nodeBuilder.setNodeId(node.getId()); nodeBuilder.setNodeId(node.getId());
nodeBuilder.setType(node.getType()); nodeBuilder.setType(node.getType());
nodeBuilder.setState(node.getState()); nodeBuilder.setState(node.getState());
nodeBuilder.setIsFirst(node.isHasPass());
chapterBuilder.addNode(nodeBuilder); chapterBuilder.addNode(nodeBuilder);
} }
chapterBuilder.setChapterId(entry.getKey()); chapterBuilder.setChapterId(entry.getKey());
chapterBuilder.setStars(entry.getValue().getStars()); chapterBuilder.setStars(entry.getValue().getStars());
for(Map.Entry<Integer,Boolean> entry1 : entry.getValue().getRewardMap().entrySet()){ for (Map.Entry<Integer, Boolean> entry1 : entry.getValue().getRewardMap().entrySet()) {
CommonProto.HardStageChapterReward.Builder rewardBuilder = CommonProto.HardStageChapterReward.newBuilder(); CommonProto.HardStageChapterReward.Builder rewardBuilder = CommonProto.HardStageChapterReward.newBuilder();
rewardBuilder.setId(entry1.getKey()); rewardBuilder.setId(entry1.getKey());
rewardBuilder.setState(entry1.getValue()?1:0); rewardBuilder.setState(entry1.getValue() ? 1 : 0);
} }
builder.addChapter(chapterBuilder); builder.addChapter(chapterBuilder);
} }
@ -60,57 +61,57 @@ public class HardStageLogic {
/** /**
* *
*/ */
public static void fight(ISession session, int teamId, int nodeId){ public static void fight(ISession session, int teamId, int nodeId) {
} }
/** /**
* *
*/ */
public static void getChapterReward(User user,SHardStageReward rewardStage,List<CommonProto.Drop.Builder> list) throws Exception{ public static void getChapterReward(User user, SHardStageReward rewardStage, List<CommonProto.Drop.Builder> list) throws Exception {
HardStageChapter chapter = user.getHardStageManager().getChapterMap(user).get(rewardStage.getChapter()); HardStageChapter chapter = user.getHardStageManager().getChapterMap(user).get(rewardStage.getChapter());
if(chapter.getStars() < rewardStage.getStar()){ if (chapter.getStars() < rewardStage.getStar()) {
LOGGER.error("章节星星数量不足"); LOGGER.error("章节星星数量不足");
return; return;
} }
if(!chapter.getRewardMap().get(rewardStage.getStarReward())){ if (!chapter.getRewardMap().get(rewardStage.getStarReward())) {
chapter.getRewardMap().put(rewardStage.getStarReward(),true); chapter.getRewardMap().put(rewardStage.getStarReward(), true);
chapter.updateRewardMap(); chapter.updateRewardMap();
list.add(getReward(user,rewardStage.getStarReward())); list.add(getReward(user, rewardStage.getStarReward()));
} }
} }
/** /**
* *
*/ */
public static void getHSReport(){ public static void getHSReport() {
} }
/** /**
* *
*/ */
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; int addStar = 0;
SHardStage config = SHardStage.getConfigMap().get(node.getId()); SHardStage config = SHardStage.getConfigMap().get(node.getId());
if(num>>2 == 1){//第一星 if (num[0] == 1) {//第一星
int rewardId = config.getReward1()[0]; int rewardId = config.getReward1()[0];
if(addDropAndStar(node,dropList,rewardId,user)){ if (addDropAndStar(node, dropList, rewardId, user)) {
node.setState(node.getState()+4); node.setState(node.getState() + 4);
addStar++; addStar += 4;
} }
} }
if((num&2) == 2){//第二星 if (num[1] == 1) {//第二星
int rewardId = config.getReward1()[1]; int rewardId = config.getReward1()[1];
if(addDropAndStar(node,dropList,rewardId,user)){ if (addDropAndStar(node, dropList, rewardId, user)) {
node.setState(node.getState()+2); node.setState(node.getState() + 2);
addStar++; addStar += 2;
} }
} }
if(num<<2 == 1){//第三星 if (num[2] == 1) {//第三星
int rewardId = config.getReward1()[2]; int rewardId = config.getReward1()[2];
if(addDropAndStar(node,dropList,rewardId,user)){ if (addDropAndStar(node, dropList, rewardId, user)) {
node.setState(node.getState()+1); node.setState(node.getState() + 1);
addStar++; addStar++;
} }
} }
@ -121,7 +122,7 @@ public class HardStageLogic {
/** /**
* teamfight * teamfight
*/ */
public static CommonProto.FightTeamInfo getFightTeamInfo(User user, int teamId,SHardStage nodeConfig) { public static CommonProto.FightTeamInfo getFightTeamInfo(User user, int teamId, SHardStage nodeConfig) {
user.getTeamPosManager().setCurTeamPosId(teamId); user.getTeamPosManager().setCurTeamPosId(teamId);
List<CommonProto.FightUnitInfo> heroFightInfos = new ArrayList<>(); List<CommonProto.FightUnitInfo> heroFightInfos = new ArrayList<>();
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId); List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
@ -135,21 +136,21 @@ public class HardStageLogic {
Map<Integer, Long> heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, teamId); Map<Integer, Long> heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, teamId);
StringBuilder skillSb = new StringBuilder(); StringBuilder skillSb = new StringBuilder();
StringBuilder propertySb = new StringBuilder(); StringBuilder propertySb = new StringBuilder();
HeroLogic.getInstance().getHeroSkills(user,hero,skillSb); HeroLogic.getInstance().getHeroSkills(user, hero, skillSb);
if(nodeConfig.getHardStageBuff() != 0){ if (nodeConfig.getHardStageBuff() != 0) {
SHardStageBuff buff = SHardStageBuff.getConfigMap().get(nodeConfig.getHardStageBuff()); SHardStageBuff buff = SHardStageBuff.getConfigMap().get(nodeConfig.getHardStageBuff());
if(buff.getType()==2 || buff.getType()==3){ if (buff.getType() == 2 || buff.getType() == 3) {
skillSb.append(buff.getPassiveSkillLogic()).append("#"); skillSb.append(buff.getPassiveSkillLogic()).append("#");
} }
} }
String property = HeroLogic.getInstance().getHeroPropertyBuilder(propertySb, hero.getTemplateId(),hero.getLevel(user.getHeroManager()), heroAttributeMap).toString(); String property = HeroLogic.getInstance().getHeroPropertyBuilder(propertySb, hero.getTemplateId(), hero.getLevel(user.getHeroManager()), heroAttributeMap).toString();
CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo
.newBuilder() .newBuilder()
.setUnitId(Integer.toString(hero.getTemplateId())) .setUnitId(Integer.toString(hero.getTemplateId()))
.setUnitSkillIds(skillSb.substring(0,skillSb.length()-1)) .setUnitSkillIds(skillSb.substring(0, skillSb.length() - 1))
.setProperty(property.substring(0, property.length()-1)) .setProperty(property.substring(0, property.length() - 1))
.setPosition(teamPosHeroInfo.getPosition()) .setPosition(teamPosHeroInfo.getPosition())
.setStar(hero.getStar()) .setStar(hero.getStar())
.setSkinId(hero.getSkin()) .setSkinId(hero.getSkin())
@ -165,46 +166,55 @@ public class HardStageLogic {
.addAllFightUnitList(heroFightInfos) .addAllFightUnitList(heroFightInfos)
.addAllPokemonUnitList(HeroLogic.getInstance().getPokemonSkills(user)) .addAllPokemonUnitList(HeroLogic.getInstance().getPokemonSkills(user))
.setTeamPassiveList(pokenmonPassiveSkills) .setTeamPassiveList(pokenmonPassiveSkills)
.setSpecialPassive(SpecialForTeamBuildEnum.toParm(teamId,user)) .setSpecialPassive(SpecialForTeamBuildEnum.toParm(teamId, user))
.build(); .build();
} }
/** /**
* *
*/ */
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()); User user = UserManager.getUser(iSession.getUid());
if(user == null){
return;
}
Map<Integer, HardStageChapter> chapterMap = user.getHardStageManager().getChapterMap(user); Map<Integer, HardStageChapter> chapterMap = user.getHardStageManager().getChapterMap(user);
HardStageNode node = chapterMap.get(nodeConfig.getChapter()).getNode(nodeConfig.getId()); HardStageNode node = chapterMap.get(nodeConfig.getChapter()).getNode(nodeConfig.getId());
if(node.getType() == 1){//大节点 if (node.getType() == 1) {//大节点
int star = passReward(user,node,resultNum,dropList); int star = passReward(user, node, resultNum, dropList);//星级通关奖励
chapterMap.get(nodeConfig.getChapter()).addStars(star); chapterMap.get(nodeConfig.getChapter()).addStars(star);
if(!node.isHasPass()){ if (!node.isHasPass()) {
node.setHasPass(true); 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{ } else {
if(node.isHasPass()){ if (node.isHasPass()) {
return; return;
} }
node.setHasPass(true); //node.setHasPass(true);
dropList.addAll(getFirstRewards(user,nodeConfig)); //dropList.addAll(getFirstRewards(user,nodeConfig));
} }
List<SHardStage> openList = SHardStage.getPreList(nodeConfig.getId()); /* List<SHardStage> openList = SHardStage.getPreList(nodeConfig.getId());
for(SHardStage stage : openList){ for(SHardStage stage : openList){
user.getHardStageManager().openNewNode(user,stage); user.getHardStageManager().openNewNode(user,stage);
} }*/
sendHardStageIndication(user); sendHardStageIndication(user);
} }
/** /**
* *
*/ */
public static List<CommonProto.Drop.Builder> getFirstRewards(User user,SHardStage nodeConfig) throws Exception{ public static List<CommonProto.Drop.Builder> getFirstRewards(User user, SHardStage nodeConfig) throws Exception {
List<CommonProto.Drop.Builder> dropList = new ArrayList<>(); List<CommonProto.Drop.Builder> dropList = new ArrayList<>();
for(int rewardId : nodeConfig.getPassReward()){ for (int rewardId : nodeConfig.getPassReward()) {
dropList.add(getReward(user,rewardId)); dropList.add(getReward(user, rewardId));
} }
return dropList; return dropList;
} }
@ -212,18 +222,18 @@ public class HardStageLogic {
/** /**
* *
*/ */
public static CommonProto.Drop.Builder getReward(User user,int rewardId) throws Exception{ public static CommonProto.Drop.Builder getReward(User user, int rewardId) throws Exception {
SRewardGroup rewardGroup = SRewardGroup.getsRewardItemMap().get(rewardId); SRewardGroup rewardGroup = SRewardGroup.getsRewardItemMap().get(rewardId);
ItemMap itemObj = new ItemMap(); //ItemMap itemObj = new ItemMap();
int[] dropList = rewardGroup.getRewardItem(); int[] dropList = rewardGroup.getRewardItem();
CommonProto.Drop.Builder drop = ItemUtil.drop(user, dropList,1,0, BIReason.HARD_STAGE_GET); CommonProto.Drop.Builder drop = ItemUtil.drop(user, dropList, 1, 0, BIReason.HARD_STAGE_GET);
return drop; return drop;
} }
private static boolean addDropAndStar(HardStageNode node,List<CommonProto.Drop.Builder> dropList,int rewardId,User user) throws Exception{ 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)); dropList.add(getReward(user, rewardId));
node.getRewardMap().put(rewardId,true); node.getRewardMap().put(rewardId, true);
node.updateRewardMap(); node.updateRewardMap();
return true; return true;
} }
@ -235,22 +245,22 @@ public class HardStageLogic {
PlayerInfoProto.HardStageResponse.Builder response = PlayerInfoProto.HardStageResponse.newBuilder(); PlayerInfoProto.HardStageResponse.Builder response = PlayerInfoProto.HardStageResponse.newBuilder();
response.setInfo(info); response.setInfo(info);
ISession session = OnlineUserManager.getSessionByUid(user.getId()); ISession session = OnlineUserManager.getSessionByUid(user.getId());
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.HARD_STAGE_INFO_RESPONSE.getNumber(),response.build(),true); MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.HARD_STAGE_INFO_RESPONSE.getNumber(), response.build(), true);
} }
/** /**
* *
*/ */
public static void refreshInfoByLevel(User user) throws Exception{ public static void refreshInfoByLevel(User user) throws Exception {
int curNodeId = user.getHardStageManager().getCurNode(); int curNodeId = user.getHardStageManager().getCurNode();
if(curNodeId == 0){ if (curNodeId == 0) {
user.getHardStageManager().getChapterMap(user); user.getHardStageManager().getChapterMap(user);
}else{ } else {
SHardStage nodeConfig = SHardStage.getConfigMap().get(curNodeId); /*SHardStage nodeConfig = SHardStage.getConfigMap().get(curNodeId);
List<SHardStage> openList = SHardStage.getPreList(nodeConfig.getId()); List<SHardStage> openList = SHardStage.getPreList(nodeConfig.getId());
for(SHardStage stage : openList){ for(SHardStage stage : openList){
user.getHardStageManager().openNewNode(user,stage); user.getHardStageManager().openNewNode(user,stage);
} }*/
} }
sendHardStageIndication(user); sendHardStageIndication(user);
} }

View File

@ -8,122 +8,123 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Table(name ="HardStage") @Table(name = "HardStage")
public class SHardStage implements BaseConfig { public class SHardStage implements BaseConfig {
private int id; private int id;
private int chapter; private int chapter;
private int section; private int section;
private String picture ; private String picture;
private int repeat ; private int repeat;
private int nextLevel; private int nextLevel;
private int levelLimit; private int levelLimit;
private int star ; private int star;
private int monsterGroup; private int monsterGroup;
private int hardStageBuff; private int hardStageBuff;
private int recommendFightAbility; private int recommendFightAbility;
private int[] passReward; private int[] passReward;
private int stageType; private int stageType;
private int[] conditionValue; private int[] conditionValue;
private int[] reward1; private int[] reward1;
private static Map<Integer,SHardStage> configMap ; private static Map<Integer, SHardStage> configMap;
private static Map<Integer, List<SHardStage>> preConfigMap; private static Map<Integer, List<SHardStage>> preConfigMap;
@Override @Override
public void init() throws Exception { public void init() throws Exception {
Map<Integer, SHardStage> tempConfig = STableManager.getConfig(SHardStage.class); Map<Integer, SHardStage> tempConfig = STableManager.getConfig(SHardStage.class);
Map<Integer, List<SHardStage>> tempPreConfigMap = new HashMap<>(); Map<Integer, List<SHardStage>> tempPreConfigMap = new HashMap<>();
for(SHardStage stage : tempConfig.values()){ for (SHardStage stage : tempConfig.values()) {
if(stage.getNextLevel() > 0){ if (stage.getNextLevel() > 0) {
if(tempPreConfigMap.containsKey(stage.getNextLevel())){ if (tempPreConfigMap.containsKey(stage.getNextLevel())) {
tempPreConfigMap.get(stage.getNextLevel()).add(stage); tempPreConfigMap.get(stage.getNextLevel()).add(stage);
}else{ } else {
List<SHardStage> list = new ArrayList<>(); List<SHardStage> list = new ArrayList<>();
list.add(stage); list.add(stage);
tempPreConfigMap.put(stage.getNextLevel(),list); tempPreConfigMap.put(stage.getNextLevel(), list);
} }
} }
} }
if(null == configMap){ if (null == configMap) {
configMap = tempConfig; configMap = tempConfig;
preConfigMap = tempPreConfigMap; preConfigMap = tempPreConfigMap;
} }
} }
public int getId() { public int getId() {
return id; return id;
} }
public int getChapter() { public int getChapter() {
return chapter; return chapter;
} }
public int getSection() { public int getSection() {
return section; return section;
} }
public String getPicture () { public String getPicture() {
return picture ; return picture;
} }
public int getRepeat () { public int getRepeat() {
return repeat ; return repeat;
} }
public int getNextLevel() { public int getStar() {
return star;
}
public int getNextLevel() {
return nextLevel; return nextLevel;
} }
public int getLevelLimit() { public int getLevelLimit() {
return levelLimit; return levelLimit;
} }
public int getStar () {
return star ;
}
public int getMonsterGroup() { public int getMonsterGroup() {
return monsterGroup; return monsterGroup;
} }
public int getHardStageBuff() { public int getHardStageBuff() {
return hardStageBuff; return hardStageBuff;
} }
public int getRecommendFightAbility() { public int getRecommendFightAbility() {
return recommendFightAbility; return recommendFightAbility;
} }
public int[] getPassReward() { public int[] getPassReward() {
return passReward; return passReward;
} }
public int getStageType() { public int getStageType() {
return stageType; return stageType;
} }
public int[] getConditionValue() { public int[] getConditionValue() {
return conditionValue; return conditionValue;
} }
public int[] getReward1() { public int[] getReward1() {
return reward1; return reward1;
} }
@ -135,7 +136,7 @@ public class SHardStage implements BaseConfig {
return preConfigMap; return preConfigMap;
} }
public static List<SHardStage> getPreList(int id){ public static List<SHardStage> getPreList(int id) {
return preConfigMap.get(id); return preConfigMap.get(id);
} }
} }