Commit 86584add105b9ece1c83719508c73028a99e4d07
1 parent
f2bebfc4
新手卡池,心愿单卡池
Showing
4 changed files
with
72 additions
and
15 deletions
Show diff stats
src/ProtocolCode.lua
| @@ -101,6 +101,7 @@ actionCodes = { | @@ -101,6 +101,7 @@ actionCodes = { | ||
| 101 | Hero_changeCrown = 223, | 101 | Hero_changeCrown = 223, |
| 102 | Hero_drawHeroExtraRewardNtf = 224, | 102 | Hero_drawHeroExtraRewardNtf = 224, |
| 103 | Hero_itemComposeRpc = 225, | 103 | Hero_itemComposeRpc = 225, |
| 104 | + Hero_setWishPoolRpc = 226, | ||
| 104 | 105 | ||
| 105 | Hang_startRpc = 251, | 106 | Hang_startRpc = 251, |
| 106 | Hang_checkRpc = 252, | 107 | Hang_checkRpc = 252, |
src/actions/HeroAction.lua
| @@ -716,11 +716,14 @@ function _M.drawHeroRpc(agent, data) | @@ -716,11 +716,14 @@ function _M.drawHeroRpc(agent, data) | ||
| 716 | local msg = MsgPack.unpack(data) | 716 | local msg = MsgPack.unpack(data) |
| 717 | 717 | ||
| 718 | if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end | 718 | if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end |
| 719 | - local btype = msg.pool -- 1 2 3 卡池类型 | 719 | + local btype = msg.pool -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池 |
| 720 | local subType = msg.subType or 1-- 定向卡池需要传 子类型 | 720 | local subType = msg.subType or 1-- 定向卡池需要传 子类型 |
| 721 | local drawType = msg.type -- 1 单抽 2 十连 | 721 | local drawType = msg.type -- 1 单抽 2 十连 |
| 722 | if btype ~= 1 then | 722 | if btype ~= 1 then |
| 723 | subType = 1 | 723 | subType = 1 |
| 724 | + if btype == 4 and role:getProperty("newerDraw") >= 10 then | ||
| 725 | + subType = 2 | ||
| 726 | + end | ||
| 724 | end | 727 | end |
| 725 | 728 | ||
| 726 | if btype == 1 then | 729 | if btype == 1 then |
| @@ -741,23 +744,32 @@ function _M.drawHeroRpc(agent, data) | @@ -741,23 +744,32 @@ function _M.drawHeroRpc(agent, data) | ||
| 741 | 744 | ||
| 742 | -- 计算抽卡消耗品 | 745 | -- 计算抽卡消耗品 |
| 743 | local cost = {} | 746 | local cost = {} |
| 744 | - local lastCount = drawCount[drawType] | ||
| 745 | - for _, costType in ipairs({"draw_card", "draw_coin"}) do | 747 | + if buildTypeData["draw_coin_1"] == "" then |
| 748 | + return 11 | ||
| 749 | + end | ||
| 750 | + local diamondCost = buildTypeData["draw_coin_1"]:toArray(true, "=") | ||
| 751 | + | ||
| 752 | + local isEnough = true | ||
| 753 | + for _, costType in ipairs({"draw_card_"}) do | ||
| 754 | + costType = costType..drawCount[drawType] | ||
| 746 | if buildTypeData[costType] ~= "" then | 755 | if buildTypeData[costType] ~= "" then |
| 747 | local curCost = buildTypeData[costType]:toArray(true, "=") | 756 | local curCost = buildTypeData[costType]:toArray(true, "=") |
| 748 | local hadCount = role:getItemCount(curCost[1]) | 757 | local hadCount = role:getItemCount(curCost[1]) |
| 749 | - local curCount = math.floor(hadCount / curCost[2]) | ||
| 750 | - if curCount >= lastCount then | ||
| 751 | - cost[curCost[1]] = curCost[2] * lastCount | ||
| 752 | - lastCount = 0 | 758 | + if hadCount >= curCost[2] then |
| 759 | + cost[curCost[1]] = curCost[2] | ||
| 753 | break | 760 | break |
| 754 | - elseif curCount > 0 then | ||
| 755 | - cost[curCost[1]] = curCost[2] * curCount | ||
| 756 | - lastCount = lastCount - curCount | 761 | + else |
| 762 | + cost[curCost[1]] = hadCount | ||
| 763 | + diamondCost[2] = (curCost[2] - hadCount) * diamondCost[2] | ||
| 764 | + if not role:checkItemEnough({[diamondCost[1]]=diamondCost[2]}) then | ||
| 765 | + isEnough = false | ||
| 766 | + break | ||
| 767 | + end | ||
| 768 | + cost[diamondCost[1]] = diamondCost[2] | ||
| 757 | end | 769 | end |
| 758 | end | 770 | end |
| 759 | end | 771 | end |
| 760 | - if lastCount > 0 then -- 钱不够 | 772 | + if isEnough == false then -- 钱不够 |
| 761 | return 4 | 773 | return 4 |
| 762 | end | 774 | end |
| 763 | 775 | ||
| @@ -820,6 +832,9 @@ function _M.drawHeroRpc(agent, data) | @@ -820,6 +832,9 @@ function _M.drawHeroRpc(agent, data) | ||
| 820 | --print(poolId, rand_v, weight, up_pool, values[1]) | 832 | --print(poolId, rand_v, weight, up_pool, values[1]) |
| 821 | if rand_v < weight and up_pool then | 833 | if rand_v < weight and up_pool then |
| 822 | up_pool = up_pool:toArray(true, "=") | 834 | up_pool = up_pool:toArray(true, "=") |
| 835 | + if btype == 5 then -- 爱心卡池,使用玩家设置的备选池子 | ||
| 836 | + up_pool = role:getProperty("wishPool") | ||
| 837 | + end | ||
| 823 | for k, v in ipairs(up_pool) do | 838 | for k, v in ipairs(up_pool) do |
| 824 | resultPool[v] = {1} | 839 | resultPool[v] = {1} |
| 825 | end | 840 | end |
| @@ -885,8 +900,14 @@ function _M.drawHeroRpc(agent, data) | @@ -885,8 +900,14 @@ function _M.drawHeroRpc(agent, data) | ||
| 885 | end | 900 | end |
| 886 | end | 901 | end |
| 887 | 902 | ||
| 888 | - if itemData.quality >= HeroQuality.SR then | ||
| 889 | - floorHeroCount = 0 | 903 | + if btype == 4 and role:getProperty("newerDraw") == 0 then -- 新手卡池 |
| 904 | + if itemData.quality == HeroQuality.SSR then | ||
| 905 | + floorHeroCount = 0 | ||
| 906 | + end | ||
| 907 | + else | ||
| 908 | + if itemData.quality >= HeroQuality.SR then | ||
| 909 | + floorHeroCount = 0 | ||
| 910 | + end | ||
| 890 | end | 911 | end |
| 891 | 912 | ||
| 892 | if role:isHaveHero(itemData.id - ItemStartId.Hero) then | 913 | if role:isHaveHero(itemData.id - ItemStartId.Hero) then |
| @@ -909,6 +930,11 @@ function _M.drawHeroRpc(agent, data) | @@ -909,6 +930,11 @@ function _M.drawHeroRpc(agent, data) | ||
| 909 | role:setProperty("floorHero", floorHero) | 930 | role:setProperty("floorHero", floorHero) |
| 910 | end | 931 | end |
| 911 | 932 | ||
| 933 | + if btype == 4 then | ||
| 934 | + local newCount = role:getProperty("newerDraw") | ||
| 935 | + role:updateProperty({field="newerDraw", value = newCount + drawCount[drawType]}) | ||
| 936 | + end | ||
| 937 | + | ||
| 912 | role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) | 938 | role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) |
| 913 | if ssrCount > 0 then | 939 | if ssrCount > 0 then |
| 914 | role:checkTaskEnter("DrawSSR", {count = ssrCount}) | 940 | role:checkTaskEnter("DrawSSR", {count = ssrCount}) |
| @@ -1074,4 +1100,32 @@ function _M.itemComposeRpc(agent, data) | @@ -1074,4 +1100,32 @@ function _M.itemComposeRpc(agent, data) | ||
| 1074 | return true | 1100 | return true |
| 1075 | end | 1101 | end |
| 1076 | 1102 | ||
| 1103 | +function _M.setWishPoolRpc(agent, data) | ||
| 1104 | + local role = agent.role | ||
| 1105 | + local msg = MsgPack.unpack(data) | ||
| 1106 | + | ||
| 1107 | + local heros = msg.heros | ||
| 1108 | + if #heros > 3 then return 1 end | ||
| 1109 | + | ||
| 1110 | + for _, heroId in pairs(heros) do | ||
| 1111 | + local cfg = csvdb["build_poolCsv"][heroId] | ||
| 1112 | + if not cfg then return 2 end | ||
| 1113 | + | ||
| 1114 | + local buildTypeData = csvdb["build_typeCsv"][5] | ||
| 1115 | + if not buildTypeData then return 3 end | ||
| 1116 | + local poolMap = buildTypeData["pool"]:toNumMap() | ||
| 1117 | + local poolId = poolMap[1] | ||
| 1118 | + if not poolId then return 4 end | ||
| 1119 | + | ||
| 1120 | + if cfg["pool_"..poolId] == 0 then | ||
| 1121 | + return 5 | ||
| 1122 | + end | ||
| 1123 | + end | ||
| 1124 | + | ||
| 1125 | + role:updateProperty({field="wishPool", value = heros}) | ||
| 1126 | + | ||
| 1127 | + SendPacket(actionCodes.Hero_setWishPoolRpc, "") | ||
| 1128 | + return true | ||
| 1129 | +end | ||
| 1130 | + | ||
| 1077 | return _M | 1131 | return _M |
src/models/Role.lua
| @@ -167,7 +167,8 @@ Role.schema = { | @@ -167,7 +167,8 @@ Role.schema = { | ||
| 167 | repayMaxC = {"number", 0}, -- 招募保底英雄领取次数 100一次 | 167 | repayMaxC = {"number", 0}, -- 招募保底英雄领取次数 100一次 |
| 168 | floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} | 168 | floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} |
| 169 | ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} | 169 | ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} |
| 170 | - newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr | 170 | + newerDraw = {"number", 0}, -- 新手池子抽卡次数 |
| 171 | + wishPool = {"table", {}}, -- 心愿池子 | ||
| 171 | 172 | ||
| 172 | sudoku = {"table", {}}, -- 九宫格 {[-1] = 1, task = {[1] = {}, [2] = {}}}} -- [-1] 阶段 如果为 -1 关闭(都做完了), task 当前阶段任务进度, reward 连串奖励领取情况 | 173 | sudoku = {"table", {}}, -- 九宫格 {[-1] = 1, task = {[1] = {}, [2] = {}}}} -- [-1] 阶段 如果为 -1 关闭(都做完了), task 当前阶段任务进度, reward 连串奖励领取情况 |
| 173 | sign = {"table", {}}, -- 签到记录 {[1] = 20181029} | 174 | sign = {"table", {}}, -- 签到记录 {[1] = 20181029} |
| @@ -394,6 +395,7 @@ function Role:data() | @@ -394,6 +395,7 @@ function Role:data() | ||
| 394 | repayHero = self:getProperty("repayHero"), | 395 | repayHero = self:getProperty("repayHero"), |
| 395 | newerDraw = self:getProperty("newerDraw"), | 396 | newerDraw = self:getProperty("newerDraw"), |
| 396 | floorHero = self:getProperty("floorHero"), | 397 | floorHero = self:getProperty("floorHero"), |
| 398 | + wishPool = self:getProperty("wishPool"), | ||
| 397 | 399 | ||
| 398 | sudoku = self:getProperty("sudoku"), | 400 | sudoku = self:getProperty("sudoku"), |
| 399 | sign = self:getProperty("sign"), | 401 | sign = self:getProperty("sign"), |