Commit 1be743f30686a82821b5e448160fb8362489338b
1 parent
8ca1144f
扭蛋机调试
Showing
2 changed files
with
22 additions
and
18 deletions
Show diff stats
src/actions/ActivityAction.lua
| ... | ... | @@ -313,47 +313,46 @@ function _M.gachakonRpc(agent, data) |
| 313 | 313 | local actCfg = csvdb["activity_capsuleToysCsv"][actid] |
| 314 | 314 | if not actCfg then return 3 end |
| 315 | 315 | |
| 316 | - for k, v in pairs(cost) do | |
| 317 | - cost[k] = v * count | |
| 318 | - end | |
| 319 | - | |
| 320 | - if not role:checkItemEnough(cost) then return 4 end | |
| 321 | - | |
| 322 | 316 | local gachakonInfo = role.activity:getActData("Gachakon") or {} |
| 323 | - local tmpCfg = clone(actCfg) | |
| 324 | 317 | local award = {} |
| 325 | 318 | local remain = 0 |
| 326 | - local reset = false | |
| 327 | 319 | for i = 1, count do |
| 328 | - local flag = 0 | |
| 320 | + local tmpCfg = clone(actCfg) | |
| 321 | + remain = 0 | |
| 322 | + print("-----------------, ", i) | |
| 329 | 323 | for id, cfg in pairs(tmpCfg) do |
| 330 | 324 | local num = gachakonInfo[id] or 0 |
| 331 | - cfg.amount = cfg.amount >= num and cfg.amount - num or 0 | |
| 332 | - cfg.weight = cfg.weight * cfg.amount | |
| 325 | + num = cfg.amount >= num and cfg.amount - num or 0 | |
| 326 | + cfg.weight = cfg.weight * num | |
| 333 | 327 | if cfg.weight > 0 then |
| 334 | - flag = 1 | |
| 328 | + remain = remain + num | |
| 335 | 329 | end |
| 330 | + print("num ".. num, id, cfg.weight, cfg.amount) | |
| 336 | 331 | end |
| 337 | - if flag == 0 then | |
| 338 | - reset = true | |
| 332 | + if remain == 0 then | |
| 339 | 333 | break |
| 340 | 334 | end |
| 341 | 335 | local id = math.randWeight(tmpCfg, "weight") |
| 336 | + if not id then return 4 end | |
| 342 | 337 | gachakonInfo[id] = (gachakonInfo[id] or 0) + 1 |
| 343 | 338 | local curAward = tmpCfg[id].award:toNumMap() |
| 344 | 339 | for k, v in pairs(curAward) do |
| 345 | 340 | award[k] = (award[k] or 0) + v |
| 346 | 341 | end |
| 347 | - remain = remain + 1 | |
| 348 | 342 | end |
| 349 | 343 | |
| 350 | - if count > remain then return 5 end | |
| 344 | + for k, v in pairs(cost) do | |
| 345 | + cost[k] = v * count | |
| 346 | + end | |
| 347 | + | |
| 348 | + if not role:checkItemEnough(cost) then return 5 end | |
| 351 | 349 | |
| 352 | 350 | role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) |
| 353 | 351 | |
| 354 | 352 | local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) |
| 355 | - if reset then | |
| 353 | + if remain <= count then | |
| 356 | 354 | gachakonInfo = {} |
| 355 | + print("hahaha") | |
| 357 | 356 | end |
| 358 | 357 | role.activity:updateActData("Gachakon", gachakonInfo) |
| 359 | 358 | ... | ... |
src/models/Activity.lua
| ... | ... | @@ -71,6 +71,11 @@ function Activity:data() |
| 71 | 71 | act12 = self:getProperty("act12"), |
| 72 | 72 | act13 = self:getProperty("act13"), |
| 73 | 73 | act14 = self:getProperty("act14"), |
| 74 | + | |
| 75 | + act17 = self:getProperty("act17"), | |
| 76 | + act18 = self:getProperty("act18"), | |
| 77 | + act19 = self:getProperty("act19"), | |
| 78 | + act20 = self:getProperty("act20"), | |
| 74 | 79 | } |
| 75 | 80 | end |
| 76 | 81 | |
| ... | ... | @@ -607,7 +612,7 @@ function Activity:recycleActItem(actId) |
| 607 | 612 | if not actCfg then return end |
| 608 | 613 | local gift = {} |
| 609 | 614 | local costs = {} |
| 610 | - for _, arr in ipairs(role:getItemCount(actCfg.recycle):toTableArray(true)) do | |
| 615 | + for _, arr in ipairs(actCfg.recycle:toTableArray(true)) do | |
| 611 | 616 | local fromId, toId, toNum = arr[1], arr[2], arr[3] |
| 612 | 617 | local itemCount = role:getItemCount(fromId) |
| 613 | 618 | if itemCount > 0 then | ... | ... |