Commit 1a0b3c5612b598aa5650742345a470bf9db47fc1
1 parent
71a18948
抽卡保底,切换定向卡池
Showing
9 changed files
with
229 additions
and
15 deletions
Show diff stats
src/GlobalVar.lua
src/ProtocolCode.lua
src/actions/GmAction.lua
| ... | ... | @@ -515,8 +515,9 @@ end |
| 515 | 515 | table.insert(helpDes, {"测试", "test", ""}) |
| 516 | 516 | function _M.test(role, pms) |
| 517 | 517 | local id = tonum(pms.pm1, 0) |
| 518 | - local a = require("actions.StoreAction") | |
| 519 | - a.getGrowFundRewardRpc({role=role}, MsgPack.pack({id=id})) | |
| 518 | + --local hero = require ("actions.HeroAction") | |
| 519 | + --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) | |
| 520 | + role.storeData:resetStoreReored(id) | |
| 520 | 521 | return "成功" |
| 521 | 522 | end |
| 522 | 523 | |
| ... | ... | @@ -525,12 +526,4 @@ function _M.ayncPurchase(role, params) |
| 525 | 526 | return role:handlePurchase(params) or "" |
| 526 | 527 | end |
| 527 | 528 | |
| 528 | -function _M.test(role, params) | |
| 529 | - local id = tonum(params.pm1, 0) | |
| 530 | - local store = require ("actions.StoreAction") | |
| 531 | - store.shopBuyRpc({role = role}, MsgPack.pack({id = id})) | |
| 532 | - return "成功" | |
| 533 | -end | |
| 534 | - | |
| 535 | - | |
| 536 | 529 | return _M |
| 537 | 530 | \ No newline at end of file | ... | ... |
src/actions/HeroAction.lua
| ... | ... | @@ -681,9 +681,7 @@ function _M.getResetRewardRpc(agent, data) |
| 681 | 681 | return true |
| 682 | 682 | end |
| 683 | 683 | |
| 684 | - | |
| 685 | - | |
| 686 | -function _M.drawHeroRpc(agent, data) | |
| 684 | +function _M.unuse_drawHeroRpc(agent, data) | |
| 687 | 685 | local role = agent.role |
| 688 | 686 | local msg = MsgPack.unpack(data) |
| 689 | 687 | |
| ... | ... | @@ -921,6 +919,153 @@ function _M.drawHeroRpc(agent, data) |
| 921 | 919 | return true |
| 922 | 920 | end |
| 923 | 921 | |
| 922 | +function _M.drawHeroRpc(agent, data) | |
| 923 | + local role = agent.role | |
| 924 | + local msg = MsgPack.unpack(data) | |
| 925 | + | |
| 926 | + if not role:isFuncUnlock(FuncUnlock.GetHero) then return end | |
| 927 | + local btype = msg.pool -- 1 2 3 卡池类型 | |
| 928 | + local subType = msg.subType or 1-- 定向卡池需要传 子类型 | |
| 929 | + local drawType = msg.type -- 1 单抽 2 十连 | |
| 930 | + local guide = msg.guide -- 是否是引导抽的 | |
| 931 | + if btype ~= 1 then | |
| 932 | + subType = 1 | |
| 933 | + end | |
| 934 | + | |
| 935 | + local buildTypeData = csvdb["build_typeCsv"][btype] | |
| 936 | + if not buildTypeData then return 1 end | |
| 937 | + | |
| 938 | + local drawCount = {1, 10} -- 抽取次数 | |
| 939 | + if not drawCount[drawType] then return 2 end | |
| 940 | + | |
| 941 | + -- 计算抽卡消耗品 | |
| 942 | + local cost = {} | |
| 943 | + local lastCount = drawCount[drawType] | |
| 944 | + for _, costType in ipairs({"draw_card", "draw_coin"}) do | |
| 945 | + if buildTypeData[costType] ~= "" then | |
| 946 | + local curCost = buildTypeData[costType]:toArray(true, "=") | |
| 947 | + local hadCount = role:getItemCount(curCost[1]) | |
| 948 | + local curCount = math.floor(hadCount / curCost[2]) | |
| 949 | + if curCount >= lastCount then | |
| 950 | + cost[curCost[1]] = curCost[2] * lastCount | |
| 951 | + lastCount = 0 | |
| 952 | + break | |
| 953 | + elseif curCount > 0 then | |
| 954 | + cost[curCost[1]] = curCost[2] * curCount | |
| 955 | + lastCount = lastCount - curCount | |
| 956 | + end | |
| 957 | + end | |
| 958 | + end | |
| 959 | + if lastCount > 0 then -- 钱不够 | |
| 960 | + return 3 | |
| 961 | + end | |
| 962 | + | |
| 963 | + -- 抽取的池子 | |
| 964 | + local poolMap = buildTypeData["pool"]:toNumMap() | |
| 965 | + local poolId = poolMap[subType] | |
| 966 | + if not poolId then return end | |
| 967 | + | |
| 968 | + --判断定向卡池是否开启 | |
| 969 | + if btype == 1 then | |
| 970 | + if not role:isTimeResetOpen(TimeReset["DrawType" .. subType]) then | |
| 971 | + local unlockPool = role.dailyData:getProperty("unlockPool") | |
| 972 | + if not unlockPool[subType] then | |
| 973 | + return 1 | |
| 974 | + end | |
| 975 | + end | |
| 976 | + end | |
| 977 | + | |
| 978 | + --TODO 活动覆盖 | |
| 979 | + | |
| 980 | + local unitPool = csvdb["build_unitCsv"][poolId] | |
| 981 | + if not unitPool then return 4 end | |
| 982 | + | |
| 983 | + -- 开始抽 | |
| 984 | + local resultPool = {} | |
| 985 | + local function fillDrawPool() | |
| 986 | + local condition = {"rare", "camp"} | |
| 987 | + local values = {} | |
| 988 | + | |
| 989 | + for idx, field in ipairs(condition) do | |
| 990 | + if not values[idx] then | |
| 991 | + local lpool = {} | |
| 992 | + local curIdx = 1 | |
| 993 | + while unitPool[field .. "_" .. curIdx] do | |
| 994 | + lpool[curIdx] = {unitPool[field .. "_" .. curIdx]} | |
| 995 | + curIdx = curIdx + 1 | |
| 996 | + end | |
| 997 | + | |
| 998 | + if next(lpool) then | |
| 999 | + values[idx] = math.randWeight(lpool, 1) | |
| 1000 | + end | |
| 1001 | + end | |
| 1002 | + end | |
| 1003 | + | |
| 1004 | + for itemId, oneData in pairs(csvdb["build_poolCsv"]) do | |
| 1005 | + if oneData["pool_" .. poolId] and oneData["pool_" .. poolId] ~= "" then | |
| 1006 | + local itemData = csvdb["itemCsv"][itemId] | |
| 1007 | + while itemData do | |
| 1008 | + if itemData.type ~= ItemType.Hero then break end | |
| 1009 | + local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] | |
| 1010 | + if not heroData then break end | |
| 1011 | + local ok = true | |
| 1012 | + for idx, field in ipairs(condition) do | |
| 1013 | + if heroData[field] ~= values[idx] then ok = false break end | |
| 1014 | + end | |
| 1015 | + if not ok then break end | |
| 1016 | + if oneData["pool_" .. poolId] > 0 then | |
| 1017 | + resultPool[itemId] = {oneData["pool_" .. poolId]} -- itemId, count, 概率 | |
| 1018 | + end | |
| 1019 | + break | |
| 1020 | + end | |
| 1021 | + end | |
| 1022 | + end | |
| 1023 | + end | |
| 1024 | + | |
| 1025 | + role:costItems(cost, {log = {desc = "drawHero", short1 = btype, int1 = poolId}}) | |
| 1026 | + | |
| 1027 | + local ssrCount = 0 | |
| 1028 | + local reward = {} | |
| 1029 | + for i = 1, drawCount[drawType] do | |
| 1030 | + resultPool = {} | |
| 1031 | + while not next(resultPool) do | |
| 1032 | + fillDrawPool() | |
| 1033 | + end | |
| 1034 | + | |
| 1035 | + -- 引导必送 613 丝路德 | |
| 1036 | + local itemId = guide and 613 or math.randWeight(resultPool, 1) | |
| 1037 | + local itemData = csvdb["itemCsv"][itemId] | |
| 1038 | + if itemData.quality == HeroQuality.SSR then | |
| 1039 | + ssrCount = ssrCount + 1 | |
| 1040 | + end | |
| 1041 | + | |
| 1042 | + if role:isHaveHero(itemData.id - ItemStartId.Hero) then | |
| 1043 | + local fragId = itemData.id - ItemStartId.Hero | |
| 1044 | + local heroData = csvdb["unitCsv"][fragId] | |
| 1045 | + local count = globalCsv.draw_unit_tofragment[heroData.rare] | |
| 1046 | + role:award({[fragId] = count}, {log = {desc = "drawHero", short1 = btype, int1 = poolId}}) | |
| 1047 | + table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1}) | |
| 1048 | + else | |
| 1049 | + role:award({[itemId] = 1}, {log = {desc = "drawHero", short1 = btype, int1 = poolId}}) | |
| 1050 | + table.insert(reward, {id = itemId, count = 1}) | |
| 1051 | + end | |
| 1052 | + end | |
| 1053 | + | |
| 1054 | + if btype == 1 or btype == 2 then | |
| 1055 | + local repayHero = role:getProperty("repayHero") or 0 | |
| 1056 | + repayHero = repayHero + drawCount[drawType] | |
| 1057 | + role:updateProperty({field = "repayHero", value = repayHero}) | |
| 1058 | + end | |
| 1059 | + | |
| 1060 | + role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) | |
| 1061 | + if ssrCount > 0 then | |
| 1062 | + role:checkTaskEnter("DrawSSR", {count = ssrCount}) | |
| 1063 | + end | |
| 1064 | + role:log("hero_action", {desc = "drawHero", short1 = btype, int1 = drawCount[drawType], int2 = poolId}) | |
| 1065 | + SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 | |
| 1066 | + return true | |
| 1067 | +end | |
| 1068 | + | |
| 924 | 1069 | function _M.repayHeroRpc(agent, data) |
| 925 | 1070 | local role = agent.role |
| 926 | 1071 | |
| ... | ... | @@ -950,4 +1095,36 @@ function _M.repayHeroRpc(agent, data) |
| 950 | 1095 | return true |
| 951 | 1096 | end |
| 952 | 1097 | |
| 1098 | +function _M.unlockPoolRpc(agent, data) | |
| 1099 | + local role = agent.role | |
| 1100 | + local msg = MsgPack.unpack(data) | |
| 1101 | + | |
| 1102 | + if not role:isFuncUnlock(FuncUnlock.GetHero) then return end | |
| 1103 | + local type = msg.type -- 指定定向卡池需要类型 1, 2, 3 | |
| 1104 | + local needCost = true | |
| 1105 | + --当前开启的类型不用解锁 | |
| 1106 | + if role:isTimeResetOpen(TimeReset["DrawType" .. type]) then | |
| 1107 | + needCost = false | |
| 1108 | + end | |
| 1109 | + --已经解锁的不需要重复解锁 | |
| 1110 | + local unlockPool = role.dailyData:getProperty("unlockPool") | |
| 1111 | + if unlockPool[type] then | |
| 1112 | + needCost = false | |
| 1113 | + end | |
| 1114 | + | |
| 1115 | + if needCost then | |
| 1116 | + if not role:costDiamond({count = 300, log = {desc = "unlockPool", short1 = type}}) then | |
| 1117 | + return | |
| 1118 | + end | |
| 1119 | + end | |
| 1120 | + | |
| 1121 | + unlockPool[type] = 1 | |
| 1122 | + role.dailyData:updateProperty({field="unlockPool", value = unlockPool}) | |
| 1123 | + role.dailyData:updateProperty({field="curPool", value = type}) | |
| 1124 | + | |
| 1125 | + role:log("hero_action", {desc = "unlockPool", short1=type}) | |
| 1126 | + SendPacket(actionCodes.Hero_unlockPoolRpc, MsgPack.pack({})) | |
| 1127 | + return true | |
| 1128 | +end | |
| 1129 | + | |
| 953 | 1130 | return _M |
| 954 | 1131 | \ No newline at end of file | ... | ... |
src/actions/RoleAction.lua
| ... | ... | @@ -663,7 +663,8 @@ function _M.taskRpc(agent, data) |
| 663 | 663 | { type = roleField[taskType], field = "a", value = active}, |
| 664 | 664 | }) |
| 665 | 665 | |
| 666 | - role:updateProperty({field = "battlePoint", role:getProperty("battlePoint") + 100}) | |
| 666 | + local oldVal = role:getProperty("battlePoint") or 0 | |
| 667 | + role:updateProperty({field = "battlePoint", value = oldVal + taskData.active}) | |
| 667 | 668 | |
| 668 | 669 | SendPacket(actionCodes.Role_taskRpc, MsgPack.pack(role:packReward(reward, change))) |
| 669 | 670 | return true | ... | ... |
src/actions/StoreAction.lua
| ... | ... | @@ -387,6 +387,11 @@ function _M.getBattlePassRewardRpc(agent, data) |
| 387 | 387 | return 1 |
| 388 | 388 | end |
| 389 | 389 | |
| 390 | + if role:getProperty("battlePoint") < config.condition then | |
| 391 | + skynet.error(string.format("user do not have enough battle point, user_id:%d", role:getProperty("id"))) | |
| 392 | + return 1 | |
| 393 | + end | |
| 394 | + | |
| 390 | 395 | local gift = "" |
| 391 | 396 | if freeFlag == "0" then |
| 392 | 397 | gift = config.giftFree | ... | ... |
src/models/Daily.lua
| ... | ... | @@ -26,7 +26,8 @@ Daily.schema = { |
| 26 | 26 | advSupRe = {"number", 0}, -- 冒险支援效果刷新次数 |
| 27 | 27 | goldBuyT = {"number", 0}, -- 金币购买次数 |
| 28 | 28 | |
| 29 | - unlockPool = {"table", {}} -- 解锁的属性卡池 | |
| 29 | + unlockPool = {"table", {}}, -- 解锁的属性卡池 | |
| 30 | + curPool = {"number", 0}, -- 属性卡池当前索引 | |
| 30 | 31 | } |
| 31 | 32 | |
| 32 | 33 | function Daily:updateProperty(params) |
| ... | ... | @@ -99,6 +100,8 @@ function Daily:data() |
| 99 | 100 | dailySDD = self:getProperty("dailySDD"), |
| 100 | 101 | advSupRe = self:getProperty("advSupRe"), |
| 101 | 102 | goldBuyT = self:getProperty("goldBuyT"), |
| 103 | + unlockPool = self:getProperty("unlockPool"), | |
| 104 | + curPool = self:getProperty("curPool"), | |
| 102 | 105 | } |
| 103 | 106 | end |
| 104 | 107 | ... | ... |
src/models/RoleTimeReset.lua
| ... | ... | @@ -66,6 +66,10 @@ function Role:updateTimeReset(now, notify) |
| 66 | 66 | ResetFunc[funcName](self, notify, response, now) |
| 67 | 67 | resetMode[funcName] = true |
| 68 | 68 | end |
| 69 | + if needResetId[resetId] then | |
| 70 | + -- 充值商城购买记录 | |
| 71 | + self.storeData:resetStoreReored(resetId) | |
| 72 | + end | |
| 69 | 73 | end |
| 70 | 74 | |
| 71 | 75 | for resetId, round in pairs(needResetId) do | ... | ... |
src/models/Store.lua
| ... | ... | @@ -194,6 +194,29 @@ function Store:notifyUpdateProperty(field, newValue, oldValue) |
| 194 | 194 | SendPacket(actionCodes.Store_updateproperty, MsgPack.pack(datas)) |
| 195 | 195 | end |
| 196 | 196 | |
| 197 | +function Store:resetStoreReored(resetId) | |
| 198 | + local payRecord = self:getProperty("payR") or {} | |
| 199 | + local buyRecord = self:getProperty("buyR") or {} | |
| 200 | + for k, v in pairs(payRecord) do | |
| 201 | + local config = csvdb["shop_rechargeCsv"][k] | |
| 202 | + if config then | |
| 203 | + if config.resetTime == resetId then | |
| 204 | + payRecord[k] = nil | |
| 205 | + end | |
| 206 | + end | |
| 207 | + end | |
| 208 | + self:updateProperty({field = "payR", value = payRecord}) | |
| 209 | + for k, v in pairs(buyRecord) do | |
| 210 | + local config = csvdb["shop_normalCsv"][k] | |
| 211 | + if config then | |
| 212 | + if config.resetTime == resetId then | |
| 213 | + buyRecord[k] = nil | |
| 214 | + end | |
| 215 | + end | |
| 216 | + end | |
| 217 | + self:updateProperty({field = "buyR", value = buyRecord}) | |
| 218 | +end | |
| 219 | + | |
| 197 | 220 | function Store:data() |
| 198 | 221 | return { |
| 199 | 222 | buyR = self:getProperty("buyR"), | ... | ... |