Commit a35233c6bf15892238d8948aca89b4dea8307af8
1 parent
147ef2ce
保底和回馈
Showing
4 changed files
with
70 additions
and
5 deletions
Show diff stats
src/GlobalVar.lua
src/ProtocolCode.lua
@@ -76,6 +76,7 @@ actionCodes = { | @@ -76,6 +76,7 @@ actionCodes = { | ||
76 | Hero_createHeroRandomRpc = 218, | 76 | Hero_createHeroRandomRpc = 218, |
77 | Hero_getResetRewardRpc = 219, | 77 | Hero_getResetRewardRpc = 219, |
78 | Hero_drawHeroRpc = 220, | 78 | Hero_drawHeroRpc = 220, |
79 | + Hero_repayHeroRpc = 221, | ||
79 | 80 | ||
80 | Hang_startRpc = 251, | 81 | Hang_startRpc = 251, |
81 | Hang_checkRpc = 252, | 82 | Hang_checkRpc = 252, |
src/actions/HeroAction.lua
@@ -743,9 +743,12 @@ function _M.drawHeroRpc(agent, data) | @@ -743,9 +743,12 @@ function _M.drawHeroRpc(agent, data) | ||
743 | local resultPool = {} | 743 | local resultPool = {} |
744 | 744 | ||
745 | local fillPoolFunc = { | 745 | local fillPoolFunc = { |
746 | - unitRate = function() | 746 | + unitRate = function(fixRare, fixCamp, fixJob) |
747 | local condition = {"rare", "camp", "job"} | 747 | local condition = {"rare", "camp", "job"} |
748 | local values = randomDrawCondition(csvdb["build_unitCsv"][pool], condition) | 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 | fillDrawPool(pool, resultPool, function(itemData) | 752 | fillDrawPool(pool, resultPool, function(itemData) |
750 | if itemData.type ~= ItemType.Hero then return end | 753 | if itemData.type ~= ItemType.Hero then return end |
751 | local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] | 754 | local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] |
@@ -756,9 +759,12 @@ function _M.drawHeroRpc(agent, data) | @@ -756,9 +759,12 @@ function _M.drawHeroRpc(agent, data) | ||
756 | return true | 759 | return true |
757 | end) | 760 | end) |
758 | end, | 761 | end, |
759 | - fragmentRate = function() | 762 | + fragmentRate = function(fixRare, fixCamp, fixJob) |
760 | local condition = {"rare", "camp", "job"} | 763 | local condition = {"rare", "camp", "job"} |
761 | local values = randomDrawCondition(csvdb["build_fragmentCsv"][pool], condition) | 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 | fillDrawPool(pool, resultPool, function(itemData) | 768 | fillDrawPool(pool, resultPool, function(itemData) |
763 | if itemData.type ~= ItemType.HeroFragment then return end | 769 | if itemData.type ~= ItemType.HeroFragment then return end |
764 | local heroData = csvdb["unitCsv"][itemData.id] | 770 | local heroData = csvdb["unitCsv"][itemData.id] |
@@ -778,16 +784,29 @@ function _M.drawHeroRpc(agent, data) | @@ -778,16 +784,29 @@ function _M.drawHeroRpc(agent, data) | ||
778 | } | 784 | } |
779 | 785 | ||
780 | role:costItems(cost) | 786 | role:costItems(cost) |
787 | + local floorHeroCount = role:getProperty("floorHero")[pool] or 0 | ||
781 | 788 | ||
782 | local ssrCount = 0 | 789 | local ssrCount = 0 |
783 | local reward = {} | 790 | local reward = {} |
784 | for i = 1, drawCount[drawType] do | 791 | for i = 1, drawCount[drawType] do |
792 | + floorHeroCount = floorHeroCount + 1 | ||
785 | 793 | ||
786 | resultPool = {} | 794 | resultPool = {} |
795 | + local isFloorBack = globalCsv.draw_floor_back_counts[pool] and floorHeroCount >= globalCsv.draw_floor_back_counts[pool] | ||
787 | while not next(resultPool) do | 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 | if not fillPoolFunc[rateTypes[rateType]] then return 4 end | 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 | end | 810 | end |
792 | 811 | ||
793 | local idx = math.randWeight(resultPool, 3) | 812 | local idx = math.randWeight(resultPool, 3) |
@@ -796,6 +815,7 @@ function _M.drawHeroRpc(agent, data) | @@ -796,6 +815,7 @@ function _M.drawHeroRpc(agent, data) | ||
796 | 815 | ||
797 | if itemData.type == ItemType.Hero and itemData.quality == 4 then | 816 | if itemData.type == ItemType.Hero and itemData.quality == 4 then |
798 | ssrCount = ssrCount + 1 | 817 | ssrCount = ssrCount + 1 |
818 | + floorHeroCount = 0 | ||
799 | end | 819 | end |
800 | 820 | ||
801 | if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then | 821 | if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then |
@@ -810,12 +830,51 @@ function _M.drawHeroRpc(agent, data) | @@ -810,12 +830,51 @@ function _M.drawHeroRpc(agent, data) | ||
810 | end | 830 | end |
811 | end | 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 | role:checkTaskEnter("DrawHero", {pool = pool, count = drawCount[drawType]}) | 843 | role:checkTaskEnter("DrawHero", {pool = pool, count = drawCount[drawType]}) |
814 | if ssrCount > 0 then | 844 | if ssrCount > 0 then |
815 | role:checkTaskEnter("DrawSSR", {count = ssrCount}) | 845 | role:checkTaskEnter("DrawSSR", {count = ssrCount}) |
816 | end | 846 | end |
847 | + | ||
817 | SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 | 848 | SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 |
818 | return true | 849 | return true |
819 | end | 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 | return _M | 880 | return _M |
822 | \ No newline at end of file | 881 | \ No newline at end of file |
src/models/Role.lua
@@ -116,6 +116,9 @@ Role.schema = { | @@ -116,6 +116,9 @@ Role.schema = { | ||
116 | rmbC = {"number", 0}, -- 人民币重置额 | 116 | rmbC = {"number", 0}, -- 人民币重置额 |
117 | 117 | ||
118 | emailSync = {"number", 0}, -- 已经同步到的邮件Id | 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,6 +270,8 @@ function Role:data() | ||
267 | dinerS = self:getProperty("dinerS"), | 270 | dinerS = self:getProperty("dinerS"), |
268 | 271 | ||
269 | rmbC = self:getProperty("rmbC"), | 272 | rmbC = self:getProperty("rmbC"), |
273 | + repayHero = self:getProperty("repayHero"), | ||
274 | + floorHero = self:getProperty("floorHero"), | ||
270 | } | 275 | } |
271 | end | 276 | end |
272 | 277 |