mystery_box

This commit is contained in:
puxuan 2025-06-10 23:36:41 +08:00
parent 3409aa046d
commit 30fcf69843
4 changed files with 39 additions and 14 deletions

View File

@ -671,8 +671,8 @@ local chapter = {
},
["mystery_box"]={
0,
5000,
5000,
10000,
10000,
0
},
["mystery_box_reward"]={
@ -2360,7 +2360,7 @@ local chapter = {
["mystery_box"]={
5000,
0,
0,
10000,
5000
},
["mystery_box_reward"]={

View File

@ -1931,4 +1931,13 @@ function GFunc.formatPlayerFormationInfo(info)
return formation
end
function GFunc.randomDrop(dropList)
local weightArr = {}
for i, v in ipairs(dropList) do
weightArr[i] = v.weight
end
local idx = GFunc.getRandomIndex(weightArr)
return dropList[idx]
end
return GFunc

View File

@ -390,10 +390,18 @@ function BattleBaseController:getInitBoard()
local config = self:getChapterConfig()[self.chapterId]
local boardCfg = self:getBoardConfig()
for _, boardId in ipairs(config.board) do
for idx, boardId in ipairs(config.board) do
local cfg = boardCfg[boardId]
if cfg then
table.insert(self.boradList, {board = GFunc.getTable(cfg.board), mysteryBoard = GFunc.getTable(cfg.mystery_box_board), gridEdge = GFunc.getTable(cfg.grid_edge)})
local tab = {
board = GFunc.getTable(cfg.board),
mysteryBoard = GFunc.getTable(cfg.mystery_box_board),
gridEdge = GFunc.getTable(cfg.grid_edge)
}
if config.mystery_box and config.mystery_box[idx] and math.random(1, BattleConst.DEFAULT_FACTOR) <= config.mystery_box[idx] then
self.mysteryBoxIndexMap[idx] = GFunc.randomDrop(config.mystery_box_reward)
end
table.insert(self.boradList, tab)
table.insert(self.fixedRandomGrid, GFunc.getTable(cfg.control_element))
end
end

View File

@ -21,21 +21,29 @@ function BattleControllerStage:getInitBoard()
local config = self:getChapterConfig()[self.chapterId]
local boardCfg = self:getBoardConfig()
for _, boardId in ipairs(config.board) do
for idx, boardId in ipairs(config.board) do
local cfg = boardCfg[boardId]
if cfg then
table.insert(self.boradList, {board = GFunc.getTable(cfg.board), mysteryBoard = GFunc.getTable(cfg.mystery_box_board), gridEdge = GFunc.getTable(cfg.grid_edge)})
local tab = {
board = GFunc.getTable(cfg.board),
mysteryBoard = GFunc.getTable(cfg.mystery_box_board),
gridEdge = GFunc.getTable(cfg.grid_edge)
}
if config.mystery_box and config.mystery_box_reward and config.mystery_box[idx] and math.random(1, GConst.BattleConst.DEFAULT_FACTOR) <= config.mystery_box[idx] then
self.mysteryBoxIndexMap[idx] = GFunc.randomDrop(config.mystery_box_reward)
end
table.insert(self.boradList, tab)
table.insert(self.fixedRandomGrid, GFunc.getTable(cfg.control_element))
end
end
if config.mystery_box and config.mystery_box_reward then
for i, index in ipairs(config.mystery_box) do
if not DataManager.ChapterData:getChapterMysteryBoxIsGot(self.chapterId, i) then
self.mysteryBoxIndexMap[index] = config.mystery_box_reward[i]
end
end
end
-- if config.mystery_box and config.mystery_box_reward then
-- for i, index in ipairs(config.mystery_box) do
-- if not DataManager.ChapterData:getChapterMysteryBoxIsGot(self.chapterId, i) then
-- self.mysteryBoxIndexMap[index] = config.mystery_box_reward[i]
-- end
-- end
-- end
end
return self.boradList, self.fixedRandomGrid, self.mysteryBoxIndexMap