Commit b8b1c164bffb27002e0eef51a6a2b59591396c69
1 parent
9b59590a
扭蛋活动,万能碎片bug
Showing
7 changed files
with
54 additions
and
17 deletions
Show diff stats
src/actions/ActivityAction.lua
| @@ -268,7 +268,7 @@ function _M.exchangeRpc(agent, data) | @@ -268,7 +268,7 @@ function _M.exchangeRpc(agent, data) | ||
| 268 | local msg = MsgPack.unpack(data) | 268 | local msg = MsgPack.unpack(data) |
| 269 | local actid = msg.actid | 269 | local actid = msg.actid |
| 270 | local id = msg.id | 270 | local id = msg.id |
| 271 | - if not role.activity:isOpen("Exchange") then return 1 end | 271 | + if not role.activity:isOpenById(actid) then return 1 end |
| 272 | 272 | ||
| 273 | local exchangeCfg = csvdb["activity_exchangeCsv"][actid] | 273 | local exchangeCfg = csvdb["activity_exchangeCsv"][actid] |
| 274 | if not exchangeCfg then return 2 end | 274 | if not exchangeCfg then return 2 end |
| @@ -295,4 +295,36 @@ function _M.exchangeRpc(agent, data) | @@ -295,4 +295,36 @@ function _M.exchangeRpc(agent, data) | ||
| 295 | return true | 295 | return true |
| 296 | end | 296 | end |
| 297 | 297 | ||
| 298 | +function _M.gachakonRpc(agent, data) | ||
| 299 | + local role = agent.role | ||
| 300 | + local msg = MsgPack.unpack(data) | ||
| 301 | + local actid = msg.actid | ||
| 302 | + if not role.activity:isOpenById(actid) then return 1 end | ||
| 303 | + | ||
| 304 | + local actCfg = csvdb["activity_capsuleToysCsv"][actid] | ||
| 305 | + if not actCfg then return 2 end | ||
| 306 | + | ||
| 307 | + local gachakonInfo = role.activity:getActData("Gachakon") or {} | ||
| 308 | + local tmpCfg = clone(actCfg) | ||
| 309 | + local flag = 0 | ||
| 310 | + for id, cfg in pairs(tmpCfg) do | ||
| 311 | + local num = gachakonInfo[id] or 0 | ||
| 312 | + cfg.amount = cfg.amount >= num and cfg.amount - num or 0 | ||
| 313 | + cfg.weight = cfg.weight * cfg.amount | ||
| 314 | + if cfg.weight > 0 then | ||
| 315 | + flag = 1 | ||
| 316 | + end | ||
| 317 | + end | ||
| 318 | + if flag == 0 then return 3 end | ||
| 319 | + | ||
| 320 | + local id = math.randWeight(tmpCfg, "weight") | ||
| 321 | + local reward, change = role:award(tmpCfg[id].award, {log = {desc = "actGachakon", int1 = actid, int2 = id}}) | ||
| 322 | + | ||
| 323 | + gachakonInfo[id] = (gachakonInfo[id] or 0) + 1 | ||
| 324 | + role.activity:updateActData("Gachakon", gachakonInfo) | ||
| 325 | + | ||
| 326 | + SendPacket(actionCodes.Activity_gachakonRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 327 | + return true | ||
| 328 | +end | ||
| 329 | + | ||
| 298 | return _M | 330 | return _M |
| 299 | \ No newline at end of file | 331 | \ No newline at end of file |
src/actions/EmailAction.lua
| @@ -121,7 +121,7 @@ function _M.drawAttachRpc(agent, data) | @@ -121,7 +121,7 @@ function _M.drawAttachRpc(agent, data) | ||
| 121 | local attachments = getEmailAttachments(email) | 121 | local attachments = getEmailAttachments(email) |
| 122 | if attachments == "" then return end | 122 | if attachments == "" then return end |
| 123 | 123 | ||
| 124 | - local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = emailId}}) | 124 | + local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = id}}) |
| 125 | email:setProperty("status", 2) | 125 | email:setProperty("status", 2) |
| 126 | email:log(role, 2) | 126 | email:log(role, 2) |
| 127 | SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change})) | 127 | SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change})) |
src/actions/GmAction.lua
| @@ -534,7 +534,7 @@ function _M.test(role, pms) | @@ -534,7 +534,7 @@ function _M.test(role, pms) | ||
| 534 | --local hero = require ("actions.HeroAction") | 534 | --local hero = require ("actions.HeroAction") |
| 535 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) | 535 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) |
| 536 | 536 | ||
| 537 | - role:sendMail(13, nil, "1=2", {111}) | 537 | + --role:sendMail(13, nil, "1=2", {111}) |
| 538 | return "成功" | 538 | return "成功" |
| 539 | end | 539 | end |
| 540 | 540 |
src/actions/HeroAction.lua
| @@ -585,16 +585,16 @@ function _M.createHeroRandomRpc(agent, data) | @@ -585,16 +585,16 @@ function _M.createHeroRandomRpc(agent, data) | ||
| 585 | local itemData = csvdb["itemCsv"][itemId] | 585 | local itemData = csvdb["itemCsv"][itemId] |
| 586 | if not itemData or itemData.type ~= ItemType.HeroFCommon then return end | 586 | if not itemData or itemData.type ~= ItemType.HeroFCommon then return end |
| 587 | local cost = globalCsv.unit_fragment_cost[itemData.quality] | 587 | local cost = globalCsv.unit_fragment_cost[itemData.quality] |
| 588 | - if not cost or role:getItemCount(itemId) < cost then return end | 588 | + if not cost or role:getItemCount(itemId) < cost then return 1 end |
| 589 | 589 | ||
| 590 | local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] | 590 | local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] |
| 591 | - if not randomData then return end | 591 | + if not randomData then return 2 end |
| 592 | 592 | ||
| 593 | local temp = randomData.gift1:randWeight(true) | 593 | local temp = randomData.gift1:randWeight(true) |
| 594 | - if not temp or not next(temp) then return end | 594 | + if not temp or not next(temp) then return 3 end |
| 595 | 595 | ||
| 596 | role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) | 596 | role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) |
| 597 | - local reward, change = role:award({[temp[1] + ItemStartId.Hero] = 1}, {log = {desc = "createHeroRandom"}}) | 597 | + local reward, change = role:award({[temp[1]] = 1}, {log = {desc = "createHeroRandom"}}) |
| 598 | 598 | ||
| 599 | 599 | ||
| 600 | SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change))) | 600 | SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change))) |
src/actions/StoreAction.lua
| @@ -401,15 +401,16 @@ function _M.getTotalRechargeAwardRpc(agent, data) | @@ -401,15 +401,16 @@ function _M.getTotalRechargeAwardRpc(agent, data) | ||
| 401 | local role = agent.role | 401 | local role = agent.role |
| 402 | local msg = MsgPack.unpack(data) | 402 | local msg = MsgPack.unpack(data) |
| 403 | local index = msg.index -- 领取的索引id | 403 | local index = msg.index -- 领取的索引id |
| 404 | + local totalTwd = role:getProperty("twdC") | ||
| 404 | local totalRechargeRecord = role.storeData:getProperty("totalRR") | 405 | local totalRechargeRecord = role.storeData:getProperty("totalRR") |
| 405 | local flag = string.char(string.getbit(totalRechargeRecord, index)) | 406 | local flag = string.char(string.getbit(totalRechargeRecord, index)) |
| 406 | - if flag == "1" then | ||
| 407 | - return 1 | ||
| 408 | - end | ||
| 409 | - totalRechargeRecord = string.setbit(totalRechargeRecord, index) | ||
| 410 | - role.storeData:updateProperty({field = "totalRR", value = totalRechargeRecord}) | 407 | + if flag == "1" then return 1 end |
| 411 | local cfg = csvdb["Csv"][index] | 408 | local cfg = csvdb["Csv"][index] |
| 412 | if not cfg then return 2 end | 409 | if not cfg then return 2 end |
| 410 | + if cfg.condition > totalTwd then return 3 end | ||
| 411 | + | ||
| 412 | + totalRechargeRecord = string.setbit(totalRechargeRecord, index) | ||
| 413 | + role.storeData:updateProperty({field = "totalRR", value = totalRechargeRecord}) | ||
| 413 | 414 | ||
| 414 | local reward, _ = role:award(cfg.reward, {log = {desc = "totalRecharge", int1 = index}}) | 415 | local reward, _ = role:award(cfg.reward, {log = {desc = "totalRecharge", int1 = index}}) |
| 415 | SendPacket(actionCodes.Store_getTotalRechargeAwardRpc, MsgPack.pack({reward = reward})) | 416 | SendPacket(actionCodes.Store_getTotalRechargeAwardRpc, MsgPack.pack({reward = reward})) |
src/models/Activity.lua
| @@ -54,10 +54,10 @@ Activity.schema = { | @@ -54,10 +54,10 @@ Activity.schema = { | ||
| 54 | act13 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励 | 54 | act13 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励 |
| 55 | act14 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励 | 55 | act14 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励 |
| 56 | 56 | ||
| 57 | - act20 = {"table", {}, true}, -- {id=兑换数量} | ||
| 58 | - act21 = {"table", {}}, -- {id=抽取的数量} | ||
| 59 | - act22 = {"table", {}}, -- {id=关卡星数, totalDmg=Boss总伤害} | ||
| 60 | - act23 = {"table", {}}, -- {挂机信息} | 57 | + act17 = {"table", {}}, -- {id=关卡星数, totalDmg=Boss总伤害} |
| 58 | + act18 = {"table", {}, true}, -- {id=兑换数量} | ||
| 59 | + act19 = {"table", {}}, -- {挂机信息} | ||
| 60 | + act20 = {"table", {}}, -- {id=扭蛋抽出数量} | ||
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | function Activity:data() | 63 | function Activity:data() |
| @@ -148,6 +148,10 @@ function Activity:isOpen(activityType) | @@ -148,6 +148,10 @@ function Activity:isOpen(activityType) | ||
| 148 | return false | 148 | return false |
| 149 | end | 149 | end |
| 150 | 150 | ||
| 151 | +function Activity:isOpneById(id) | ||
| 152 | + return self._isOpen[id] | ||
| 153 | +end | ||
| 154 | + | ||
| 151 | function Activity:getActData(actType) | 155 | function Activity:getActData(actType) |
| 152 | actType = checkActivityType(actType) | 156 | actType = checkActivityType(actType) |
| 153 | return self:getProperty("act" .. actType) | 157 | return self:getProperty("act" .. actType) |