From 7898054adde56e4b217841a70cfc52e482426f96 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Tue, 20 Aug 2019 17:34:49 +0800 Subject: [PATCH] 新随机订单 --- src/actions/DinerAction.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index d8f7994..5155795 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -455,11 +455,12 @@ function _M.refreshTaskRpc( agent, data ) local orders = json.decode(role.dinerData:getProperty("order")) local hadTask = {} - local needCount = globalCsv.diner_task_count + local needCount = 0 for idx, temp in pairs(orders) do - if temp.lock ~= 0 and temp.status ~= 0 then + if temp.lock ~= 0 or temp.status ~= 0 then hadTask[temp.id] = 1 - needCount = needCount - 1 + else + needCount = needCount + 1 end end @@ -489,9 +490,9 @@ function _M.refreshTaskRpc( agent, data ) role:costItems(cost) - for idx = 1, globalCsv.diner_task_count do - local order = orders[idx] - if not order or (order.lock == 0 and order.status == 0) then + + for idx, order in ipairs(orders) do + if (order.lock == 0 and order.status == 0) then if needCount > 0 then local index = math.randWeight(pool, "chance") local data = pool[index] -- libgit2 0.21.2