From 86584add105b9ece1c83719508c73028a99e4d07 Mon Sep 17 00:00:00 2001 From: liuzujun <307836273@qq.com> Date: Fri, 4 Dec 2020 18:20:57 +0800 Subject: [PATCH] 新手卡池,心愿单卡池 --- src/ProtocolCode.lua | 1 + src/actions/HeroAction.lua | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------- src/csvdata | 2 +- src/models/Role.lua | 4 +++- 4 files changed, 72 insertions(+), 15 deletions(-) diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index 9da72f8..5f9e0d0 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -101,6 +101,7 @@ actionCodes = { Hero_changeCrown = 223, Hero_drawHeroExtraRewardNtf = 224, Hero_itemComposeRpc = 225, + Hero_setWishPoolRpc = 226, Hang_startRpc = 251, Hang_checkRpc = 252, diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index eaf70cd..2a66d22 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -716,11 +716,14 @@ function _M.drawHeroRpc(agent, data) local msg = MsgPack.unpack(data) if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end - local btype = msg.pool -- 1 2 3 卡池类型 + local btype = msg.pool -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池 local subType = msg.subType or 1-- 定向卡池需要传 子类型 local drawType = msg.type -- 1 单抽 2 十连 if btype ~= 1 then subType = 1 + if btype == 4 and role:getProperty("newerDraw") >= 10 then + subType = 2 + end end if btype == 1 then @@ -741,23 +744,32 @@ function _M.drawHeroRpc(agent, data) -- 计算抽卡消耗品 local cost = {} - local lastCount = drawCount[drawType] - for _, costType in ipairs({"draw_card", "draw_coin"}) do + if buildTypeData["draw_coin_1"] == "" then + return 11 + end + local diamondCost = buildTypeData["draw_coin_1"]:toArray(true, "=") + + local isEnough = true + for _, costType in ipairs({"draw_card_"}) do + costType = costType..drawCount[drawType] if buildTypeData[costType] ~= "" then local curCost = buildTypeData[costType]:toArray(true, "=") local hadCount = role:getItemCount(curCost[1]) - local curCount = math.floor(hadCount / curCost[2]) - if curCount >= lastCount then - cost[curCost[1]] = curCost[2] * lastCount - lastCount = 0 + if hadCount >= curCost[2] then + cost[curCost[1]] = curCost[2] break - elseif curCount > 0 then - cost[curCost[1]] = curCost[2] * curCount - lastCount = lastCount - curCount + else + cost[curCost[1]] = hadCount + diamondCost[2] = (curCost[2] - hadCount) * diamondCost[2] + if not role:checkItemEnough({[diamondCost[1]]=diamondCost[2]}) then + isEnough = false + break + end + cost[diamondCost[1]] = diamondCost[2] end end end - if lastCount > 0 then -- 钱不够 + if isEnough == false then -- 钱不够 return 4 end @@ -820,6 +832,9 @@ function _M.drawHeroRpc(agent, data) --print(poolId, rand_v, weight, up_pool, values[1]) if rand_v < weight and up_pool then up_pool = up_pool:toArray(true, "=") + if btype == 5 then -- 爱心卡池,使用玩家设置的备选池子 + up_pool = role:getProperty("wishPool") + end for k, v in ipairs(up_pool) do resultPool[v] = {1} end @@ -885,8 +900,14 @@ function _M.drawHeroRpc(agent, data) end end - if itemData.quality >= HeroQuality.SR then - floorHeroCount = 0 + if btype == 4 and role:getProperty("newerDraw") == 0 then -- 新手卡池 + if itemData.quality == HeroQuality.SSR then + floorHeroCount = 0 + end + else + if itemData.quality >= HeroQuality.SR then + floorHeroCount = 0 + end end if role:isHaveHero(itemData.id - ItemStartId.Hero) then @@ -909,6 +930,11 @@ function _M.drawHeroRpc(agent, data) role:setProperty("floorHero", floorHero) end + if btype == 4 then + local newCount = role:getProperty("newerDraw") + role:updateProperty({field="newerDraw", value = newCount + drawCount[drawType]}) + end + role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) if ssrCount > 0 then role:checkTaskEnter("DrawSSR", {count = ssrCount}) @@ -1074,4 +1100,32 @@ function _M.itemComposeRpc(agent, data) return true end +function _M.setWishPoolRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + + local heros = msg.heros + if #heros > 3 then return 1 end + + for _, heroId in pairs(heros) do + local cfg = csvdb["build_poolCsv"][heroId] + if not cfg then return 2 end + + local buildTypeData = csvdb["build_typeCsv"][5] + if not buildTypeData then return 3 end + local poolMap = buildTypeData["pool"]:toNumMap() + local poolId = poolMap[1] + if not poolId then return 4 end + + if cfg["pool_"..poolId] == 0 then + return 5 + end + end + + role:updateProperty({field="wishPool", value = heros}) + + SendPacket(actionCodes.Hero_setWishPoolRpc, "") + return true +end + return _M diff --git a/src/csvdata b/src/csvdata index 7ddcf85..897a3e0 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 7ddcf852c731685bc3aa13e4f0bf7d7a86b45b65 +Subproject commit 897a3e0e4afa8217614a9ecf199d54b0ca641bab diff --git a/src/models/Role.lua b/src/models/Role.lua index 6d84ecd..212a16f 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -167,7 +167,8 @@ Role.schema = { repayMaxC = {"number", 0}, -- 招募保底英雄领取次数 100一次 floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} - newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr + newerDraw = {"number", 0}, -- 新手池子抽卡次数 + wishPool = {"table", {}}, -- 心愿池子 sudoku = {"table", {}}, -- 九宫格 {[-1] = 1, task = {[1] = {}, [2] = {}}}} -- [-1] 阶段 如果为 -1 关闭(都做完了), task 当前阶段任务进度, reward 连串奖励领取情况 sign = {"table", {}}, -- 签到记录 {[1] = 20181029} @@ -394,6 +395,7 @@ function Role:data() repayHero = self:getProperty("repayHero"), newerDraw = self:getProperty("newerDraw"), floorHero = self:getProperty("floorHero"), + wishPool = self:getProperty("wishPool"), sudoku = self:getProperty("sudoku"), sign = self:getProperty("sign"), -- libgit2 0.21.2