Commit 7c3dbe6d49e6108eaa2991cc50cb8ac8971111b8

Authored by zhangqijia
1 parent 639bbdff

feat: 一番赏 扭蛋机信息-增加roleProgress字段,标识抽取进度。

Showing 1 changed file with 30 additions and 16 deletions   Show diff stats
src/models/Capsule.lua
... ... @@ -621,24 +621,25 @@ function Capsule:checkIncentive(roleId, name, now)
621 621 end
622 622  
623 623 local count = math.floor(amount / incentive["amount"]["np"])
624   - local tmpCount = count * incentive["amount"]["np"]
625   - notify["amount"] = {name = name, roleId= roleId, good_id = "amount", typ = RewardType.INCENTIVE, award = incentive["amount"]["award"], amount = count, quality = 2, create_time= now}
626   -
627   - --填充v.calculated 字段,标识已经用于每x抽的计算中。
628   - for _, v in pairs(roleRecord) do
629   - if tmpCount <= 0 then break end
630   -
631   - v.calculated = v.calculated or 0
632   - if v.calculated ~= v.amount then
633   - if tmpCount <= v.amount then
634   - v.calculated = tmpCount
635   - tmpCount = 0
636   - else
637   - v.calculated = v.amount
638   - tmpCount = tmpCount - v.amount
  624 + if count > 0 then
  625 + local tmpCount = count * incentive["amount"]["np"]
  626 + notify["amount"] = {name = name, roleId= roleId, good_id = "amount", typ = RewardType.INCENTIVE, award = incentive["amount"]["award"], amount = count, quality = 2, create_time= now}
  627 +
  628 + --填充v.calculated 字段,标识已经用于每x抽的计算中。
  629 + for _, v in pairs(roleRecord) do
  630 + if tmpCount <= 0 then break end
  631 +
  632 + v.calculated = v.calculated or 0
  633 + if v.calculated ~= v.amount then
  634 + if tmpCount <= v.amount then
  635 + v.calculated = tmpCount
  636 + tmpCount = 0
  637 + else
  638 + v.calculated = v.amount
  639 + tmpCount = tmpCount - v.amount
  640 + end
639 641 end
640 642 end
641   -
642 643 end
643 644 end
644 645  
... ... @@ -917,6 +918,18 @@ function Capsule:clearSpecialNty(roleId, good_ids)
917 918 self:setProperty("specialsRecord", specialsRecord)
918 919 end
919 920  
  921 +function Capsule:getRoleProgress(roleId)
  922 + local recordByRole = self:getProperty("recordByRole") or {}
  923 + local roleRecord = recordByRole[roleId] or {}
  924 + local amount = 0
  925 + for _, v in pairs(roleRecord) do
  926 + v.calculated = v.calculated or 0
  927 + if v.calculated ~= v.amount then
  928 + amount = amount + (v.amount - v.calculated)
  929 + end
  930 + end
  931 + return amount
  932 +end
920 933  
921 934 function Capsule:data(roleId)
922 935 return {
... ... @@ -933,6 +946,7 @@ function Capsule:data(roleId)
933 946 specials = self:getProperty("specials"),
934 947 incentive = self:getProperty("incentive"),
935 948 specialsRecord= self:getProperty("specialsRecord"),
  949 + roleProgress = self:getRoleProgress(roleId),
936 950 }
937 951 end
938 952  
... ...