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,47 +313,46 @@ function _M.gachakonRpc(agent, data) | ||
| 313 | local actCfg = csvdb["activity_capsuleToysCsv"][actid] | 313 | local actCfg = csvdb["activity_capsuleToysCsv"][actid] |
| 314 | if not actCfg then return 3 end | 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 | local gachakonInfo = role.activity:getActData("Gachakon") or {} | 316 | local gachakonInfo = role.activity:getActData("Gachakon") or {} |
| 323 | - local tmpCfg = clone(actCfg) | ||
| 324 | local award = {} | 317 | local award = {} |
| 325 | local remain = 0 | 318 | local remain = 0 |
| 326 | - local reset = false | ||
| 327 | for i = 1, count do | 319 | for i = 1, count do |
| 328 | - local flag = 0 | 320 | + local tmpCfg = clone(actCfg) |
| 321 | + remain = 0 | ||
| 322 | + print("-----------------, ", i) | ||
| 329 | for id, cfg in pairs(tmpCfg) do | 323 | for id, cfg in pairs(tmpCfg) do |
| 330 | local num = gachakonInfo[id] or 0 | 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 | if cfg.weight > 0 then | 327 | if cfg.weight > 0 then |
| 334 | - flag = 1 | 328 | + remain = remain + num |
| 335 | end | 329 | end |
| 330 | + print("num ".. num, id, cfg.weight, cfg.amount) | ||
| 336 | end | 331 | end |
| 337 | - if flag == 0 then | ||
| 338 | - reset = true | 332 | + if remain == 0 then |
| 339 | break | 333 | break |
| 340 | end | 334 | end |
| 341 | local id = math.randWeight(tmpCfg, "weight") | 335 | local id = math.randWeight(tmpCfg, "weight") |
| 336 | + if not id then return 4 end | ||
| 342 | gachakonInfo[id] = (gachakonInfo[id] or 0) + 1 | 337 | gachakonInfo[id] = (gachakonInfo[id] or 0) + 1 |
| 343 | local curAward = tmpCfg[id].award:toNumMap() | 338 | local curAward = tmpCfg[id].award:toNumMap() |
| 344 | for k, v in pairs(curAward) do | 339 | for k, v in pairs(curAward) do |
| 345 | award[k] = (award[k] or 0) + v | 340 | award[k] = (award[k] or 0) + v |
| 346 | end | 341 | end |
| 347 | - remain = remain + 1 | ||
| 348 | end | 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 | role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) | 350 | role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) |
| 353 | 351 | ||
| 354 | local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) | 352 | local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) |
| 355 | - if reset then | 353 | + if remain <= count then |
| 356 | gachakonInfo = {} | 354 | gachakonInfo = {} |
| 355 | + print("hahaha") | ||
| 357 | end | 356 | end |
| 358 | role.activity:updateActData("Gachakon", gachakonInfo) | 357 | role.activity:updateActData("Gachakon", gachakonInfo) |
| 359 | 358 |
src/models/Activity.lua
| @@ -71,6 +71,11 @@ function Activity:data() | @@ -71,6 +71,11 @@ function Activity:data() | ||
| 71 | act12 = self:getProperty("act12"), | 71 | act12 = self:getProperty("act12"), |
| 72 | act13 = self:getProperty("act13"), | 72 | act13 = self:getProperty("act13"), |
| 73 | act14 = self:getProperty("act14"), | 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 | end | 80 | end |
| 76 | 81 | ||
| @@ -607,7 +612,7 @@ function Activity:recycleActItem(actId) | @@ -607,7 +612,7 @@ function Activity:recycleActItem(actId) | ||
| 607 | if not actCfg then return end | 612 | if not actCfg then return end |
| 608 | local gift = {} | 613 | local gift = {} |
| 609 | local costs = {} | 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 | local fromId, toId, toNum = arr[1], arr[2], arr[3] | 616 | local fromId, toId, toNum = arr[1], arr[2], arr[3] |
| 612 | local itemCount = role:getItemCount(fromId) | 617 | local itemCount = role:getItemCount(fromId) |
| 613 | if itemCount > 0 then | 618 | if itemCount > 0 then |