Commit a35233c6bf15892238d8948aca89b4dea8307af8

Authored by zhouhaihai
1 parent 147ef2ce

保底和回馈

src/GlobalVar.lua
... ... @@ -172,4 +172,4 @@ SettingStatus = {
172 172 },
173 173 }
174 174  
175   -EMAIL_LIMIT = 50 --邮件最大数量
  175 +EMAIL_LIMIT = 20 --邮件最大数量
... ...
src/ProtocolCode.lua
... ... @@ -76,6 +76,7 @@ actionCodes = {
76 76 Hero_createHeroRandomRpc = 218,
77 77 Hero_getResetRewardRpc = 219,
78 78 Hero_drawHeroRpc = 220,
  79 + Hero_repayHeroRpc = 221,
79 80  
80 81 Hang_startRpc = 251,
81 82 Hang_checkRpc = 252,
... ...
src/actions/HeroAction.lua
... ... @@ -743,9 +743,12 @@ function _M.drawHeroRpc(agent, data)
743 743 local resultPool = {}
744 744  
745 745 local fillPoolFunc = {
746   - unitRate = function()
  746 + unitRate = function(fixRare, fixCamp, fixJob)
747 747 local condition = {"rare", "camp", "job"}
748 748 local values = randomDrawCondition(csvdb["build_unitCsv"][pool], condition)
  749 + values[1] = fixRare or values[1]
  750 + values[2] = fixCamp or values[2]
  751 + values[3] = fixJob or values[3]
749 752 fillDrawPool(pool, resultPool, function(itemData)
750 753 if itemData.type ~= ItemType.Hero then return end
751 754 local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero]
... ... @@ -756,9 +759,12 @@ function _M.drawHeroRpc(agent, data)
756 759 return true
757 760 end)
758 761 end,
759   - fragmentRate = function()
  762 + fragmentRate = function(fixRare, fixCamp, fixJob)
760 763 local condition = {"rare", "camp", "job"}
761 764 local values = randomDrawCondition(csvdb["build_fragmentCsv"][pool], condition)
  765 + values[1] = fixRare or values[1]
  766 + values[2] = fixCamp or values[2]
  767 + values[3] = fixJob or values[3]
762 768 fillDrawPool(pool, resultPool, function(itemData)
763 769 if itemData.type ~= ItemType.HeroFragment then return end
764 770 local heroData = csvdb["unitCsv"][itemData.id]
... ... @@ -778,16 +784,29 @@ function _M.drawHeroRpc(agent, data)
778 784 }
779 785  
780 786 role:costItems(cost)
  787 + local floorHeroCount = role:getProperty("floorHero")[pool] or 0
781 788  
782 789 local ssrCount = 0
783 790 local reward = {}
784 791 for i = 1, drawCount[drawType] do
  792 + floorHeroCount = floorHeroCount + 1
785 793  
786 794 resultPool = {}
  795 + local isFloorBack = globalCsv.draw_floor_back_counts[pool] and floorHeroCount >= globalCsv.draw_floor_back_counts[pool]
787 796 while not next(resultPool) do
788   - local rateType = math.randWeight(typePool, 1)
  797 + local rateType
  798 +
  799 + if isFloorBack then
  800 + rateType = 1 --保底英雄
  801 + else
  802 + rateType = math.randWeight(typePool, 1)
  803 + end
789 804 if not fillPoolFunc[rateTypes[rateType]] then return 4 end
790   - fillPoolFunc[rateTypes[rateType]]()
  805 + if isFloorBack then
  806 + fillPoolFunc[rateTypes[rateType]](4) -- 保底
  807 + else
  808 + fillPoolFunc[rateTypes[rateType]]()
  809 + end
791 810 end
792 811  
793 812 local idx = math.randWeight(resultPool, 3)
... ... @@ -796,6 +815,7 @@ function _M.drawHeroRpc(agent, data)
796 815  
797 816 if itemData.type == ItemType.Hero and itemData.quality == 4 then
798 817 ssrCount = ssrCount + 1
  818 + floorHeroCount = 0
799 819 end
800 820  
801 821 if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then
... ... @@ -810,12 +830,51 @@ function _M.drawHeroRpc(agent, data)
810 830 end
811 831 end
812 832  
  833 + if globalCsv.draw_floor_back_counts[pool] then
  834 + local floorHero = role:getProperty("floorHero")
  835 + floorHero[pool] = floorHeroCount
  836 + role:updateProperty({field = "floorHero", value = floorHero})
  837 + end
  838 +
  839 + local repayHero = role:getProperty("repayHero")
  840 + repayHero = math.min(globalCsv.draw_super_repay_count, repayHero + drawCount[drawType])
  841 + role:updateProperty({field = "repayHero", value = repayHero})
  842 +
813 843 role:checkTaskEnter("DrawHero", {pool = pool, count = drawCount[drawType]})
814 844 if ssrCount > 0 then
815 845 role:checkTaskEnter("DrawSSR", {count = ssrCount})
816 846 end
  847 +
817 848 SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组
818 849 return true
819 850 end
820 851  
  852 +function _M.repayHeroRpc(agent, data)
  853 + local role = agent.role
  854 +
  855 + local repayHero = role:getProperty("repayHero")
  856 + if repayHero < globalCsv.draw_super_repay_count then
  857 + return
  858 + end
  859 +
  860 + role:updateProperty({field = "repayHero", value = 0})
  861 + local id = math.randWeight(csvdb["build_giftCsv"], "pool_1")
  862 +
  863 + local reward = {}
  864 + local itemData = csvdb["itemCsv"][id]
  865 + if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then
  866 + local fragId = itemData.id - ItemStartId.Hero
  867 + local heroData = csvdb["unitCsv"][fragId]
  868 + local count = globalCsv.draw_unit_tofragment[heroData.rare]
  869 + role:award({[fragId] = count})
  870 + reward = {id = fragId, count = count, from = id, fcount = 1}
  871 + else
  872 + role:award({[id] = 1})
  873 + reward = {id = id, count = 1}
  874 + end
  875 +
  876 + SendPacket(actionCodes.Hero_repayHeroRpc, MsgPack.pack({reward = reward}))
  877 + return true
  878 +end
  879 +
821 880 return _M
822 881 \ No newline at end of file
... ...
src/models/Role.lua
... ... @@ -116,6 +116,9 @@ Role.schema = {
116 116 rmbC = {"number", 0}, -- 人民币重置额
117 117  
118 118 emailSync = {"number", 0}, -- 已经同步到的邮件Id
  119 +
  120 + repayHero = {"number", 0}, -- 超级招募 回馈
  121 + floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count}
119 122 }
120 123  
121 124  
... ... @@ -267,6 +270,8 @@ function Role:data()
267 270 dinerS = self:getProperty("dinerS"),
268 271  
269 272 rmbC = self:getProperty("rmbC"),
  273 + repayHero = self:getProperty("repayHero"),
  274 + floorHero = self:getProperty("floorHero"),
270 275 }
271 276 end
272 277  
... ...