Commit 007af97ec4c962bca4887c5f3eec00b54853b595

Authored by zhouhaihai
1 parent 9bf57456

item_random 结构更改

src/actions/AdvAction.lua
... ... @@ -562,33 +562,33 @@ function _M.endBattleRpc(agent, data)
562 562 return true
563 563 end
564 564  
565   -function _M.workshopRpc(agent, data)
566   - local role = agent.role
567   - local msg = MsgPack.unpack(data)
568   -
569   - local id = msg.id
570   - local count = msg.count or 1
571   - local mergeData = csvdb["adv_mergeCsv"][id]
572   - if not mergeData then return 1 end
573   -
574   - if not role:isFuncOpen(FuncOpenType.AdvWS) or role:getFuncLv(FuncOpenType.AdvWS) < mergeData.unlock then return 2 end
575   -
576   - local advWs = role.dailyData:getProperty("advWs")
577   - if math.illegalNum(count, 1, mergeData.limit - (advWs[id] or 0)) then return 3 end
578   -
579   - local cost = mergeData.formula:toNumMap()
580   - for k, v in pairs(cost) do
581   - cost[k] = v * count
582   - end
583   - if not role:checkItemEnough(cost) then return 4 end
584   -
585   - role:costItems(cost)
586   - advWs[id] = (advWs[id] or 0) + count
587   - role.dailyData:updateProperty({field = "advWs", value = advWs})
588   - local reward = role:award({[id] = count})
589   - SendPacket(actionCodes.Adv_workshopRpc, MsgPack.pack({reward = reward}))
590   - return true
591   -end
  565 +-- function _M.workshopRpc(agent, data)
  566 +-- local role = agent.role
  567 +-- local msg = MsgPack.unpack(data)
  568 +
  569 +-- local id = msg.id
  570 +-- local count = msg.count or 1
  571 +-- local mergeData = csvdb["adv_mergeCsv"][id]
  572 +-- if not mergeData then return 1 end
  573 +
  574 +-- if not role:isFuncOpen(FuncOpenType.AdvWS) or role:getFuncLv(FuncOpenType.AdvWS) < mergeData.unlock then return 2 end
  575 +
  576 +-- local advWs = role.dailyData:getProperty("advWs")
  577 +-- if math.illegalNum(count, 1, mergeData.limit - (advWs[id] or 0)) then return 3 end
  578 +
  579 +-- local cost = mergeData.formula:toNumMap()
  580 +-- for k, v in pairs(cost) do
  581 +-- cost[k] = v * count
  582 +-- end
  583 +-- if not role:checkItemEnough(cost) then return 4 end
  584 +
  585 +-- role:costItems(cost)
  586 +-- advWs[id] = (advWs[id] or 0) + count
  587 +-- role.dailyData:updateProperty({field = "advWs", value = advWs})
  588 +-- local reward = role:award({[id] = count})
  589 +-- SendPacket(actionCodes.Adv_workshopRpc, MsgPack.pack({reward = reward}))
  590 +-- return true
  591 +-- end
592 592  
593 593 function _M.wheelSurfRpc(agent, data)
594 594 local role = agent.role
... ...
src/actions/HeroAction.lua
... ... @@ -594,7 +594,7 @@ function _M.createHeroRandomRpc(agent, data)
594 594 local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)]
595 595 if not randomData then return end
596 596  
597   - local temp = randomData.random_gift:randWeight(true)
  597 + local temp = randomData.gift1:randWeight(true)
598 598 if not temp or not next(temp) then return end
599 599 local reward = {}
600 600 if role:isHaveHero(temp[1]) then
... ...
src/actions/RoleAction.lua
... ... @@ -410,24 +410,27 @@ function _M.openItemRpc(agent, data)
410 410 local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)]
411 411 if not randomData or randomData.openTime > 0 then return end
412 412  
413   - local reward = randomData.gift:toNumMap()
414   - for _id, _count in pairs(reward) do
415   - reward[_id] = _count * count
416   - end
417   - if randomData.random_num > 0 and randomData.random_gift ~= "" then
418   - for i = 1, count do
419   - local pool = {}
420   - for _, temp in ipairs(randomData.random_gift:toArray()) do
421   - table.insert(pool, temp:toArray(true, "="))
422   - end
423   - local needCount = math.min(#pool, randomData.random_num)
424   - for j = 1, needCount do
425   - local idx = math.randWeight(pool, 3)
426   - reward[pool[idx][1]] = (reward[pool[idx][1]] or 0) + pool[idx][2]
427   - table.remove(pool, idx)
  413 + local reward = {}
  414 + for _i = 1, count do
  415 + for i = 1, 10 do
  416 + local num = randomData["num" .. i]
  417 + local gift = randomData["gift" .. i]
  418 + if num and gift and num > 0 and gift ~= "" then
  419 + local pool = {}
  420 + for _, temp in ipairs(gift:toArray()) do
  421 + table.insert(pool, temp:toArray(true, "="))
  422 + end
  423 + local needCount = math.min(#pool, num)
  424 + for j = 1, needCount do
  425 + local idx = math.randWeight(pool, 3)
  426 + reward[pool[idx][1]] = (reward[pool[idx][1]] or 0) + pool[idx][2]
  427 + table.remove(pool, idx)
  428 + end
428 429 end
429 430 end
430 431 end
  432 + reward[0] = nil
  433 +
431 434 role:costItems({[itemId] = count})
432 435 reward = role:award(reward)
433 436  
... ... @@ -479,35 +482,38 @@ function _M.openTimeBoxRpc(agent, data)
479 482 local randomData = csvdb["item_randomCsv"][itemData.id]
480 483 reward = randomData.gift:toNumMap() -- 固定奖励
481 484 -- 随机奖励
482   - local randomGift = randomData.random_gift
483   - local randomNum = randomData.random_num
484 485 local gemId = boxL[slot].gem
485   -
486   - if randomNum > 0 and randomGift and randomGift ~= "" then
487   - local selectGift = {}
488   - local pool = {}
489   - for _, temp in ipairs(randomGift:toArray()) do
490   - local set = temp:toArray(true, "=")
491   - if gemId == set[1] then
492   - table.insert(selectGift, set)
493   - else
494   - table.insert(pool, set)
  486 + local reward = {}
  487 + for i = 1, 10 do
  488 + local num = randomData["num" .. i]
  489 + local gift = randomData["gift" .. i]
  490 + if num and gift and num > 0 and gift ~= "" then
  491 + local pool = {}
  492 + local selectGift = {}
  493 + for _, temp in ipairs(gift:toArray()) do
  494 + local set = temp:toArray(true, "=")
  495 + if gemId == set[1] then
  496 + table.insert(selectGift, set)
  497 + else
  498 + table.insert(pool, set)
  499 + end
495 500 end
496   - end
497 501  
498   - if gemId ~= 0 and next(selectGift) then
499   - randomNum = randomNum - 1
500   - local idx = math.randWeight(selectGift, 3)
501   - reward[selectGift[idx][1]] = (reward[selectGift[idx][1]] or 0) + selectGift[idx][2]
502   - end
  502 + if gemId ~= 0 and next(selectGift) then
  503 + num = num - 1
  504 + local idx = math.randWeight(selectGift, 3)
  505 + reward[selectGift[idx][1]] = (reward[selectGift[idx][1]] or 0) + selectGift[idx][2]
  506 + end
503 507  
504   - local needCount = math.min(#pool, randomNum)
505   - for j = 1, needCount do
506   - local idx = math.randWeight(pool, 3)
507   - reward[pool[idx][1]] = (reward[pool[idx][1]] or 0) + pool[idx][2]
508   - table.remove(pool, idx)
  508 + local needCount = math.min(#pool, num)
  509 + for j = 1, needCount do
  510 + local idx = math.randWeight(pool, 3)
  511 + reward[pool[idx][1]] = (reward[pool[idx][1]] or 0) + pool[idx][2]
  512 + table.remove(pool, idx)
  513 + end
509 514 end
510 515 end
  516 + reward[0] = nil
511 517  
512 518 boxL[slot] = nil
513 519 reward = role:award(reward)
... ...