Commit 452d614647f603c22834b7c3d2be9a0409619383

Authored by gaofengduan
1 parent ca232abd

fix diner task

src/GlobalVar.lua
... ... @@ -111,8 +111,8 @@ AdvScoreType = {
111 111 }
112 112  
113 113 DinerTask = {
114   - UseMaterial = 1,
115   - AddDish = 2,
116   - SellDish = 3,
117   - DishWithGold = 4,
  114 + SellDish = 1,
  115 + DishWithGold = 2,
  116 + UseMaterial = 3,
  117 + AddDish = 4,
118 118 }
119 119 \ No newline at end of file
... ...
src/actions/DinerAction.lua
... ... @@ -53,8 +53,8 @@ function _M.addSellRpc( agent, data )
53 53 role.dinerData:updateSell(slot)
54 54  
55 55 local dirty = false
56   - for type, value in pairs(cost) do
57   - if role.dinerData:checkDinerTask(DinerTask.UseMaterial, value, type, nil, true) then
  56 + for id, value in pairs(cost) do
  57 + if role.dinerData:checkDinerTask(DinerTask.UseMaterial, value, id, nil, true) then
58 58 dirty = true
59 59 end
60 60 end
... ... @@ -345,16 +345,16 @@ function _M.updateTaskRpc( agent, data )
345 345 orders[index].status = 0
346 346 orders[index].lock = 0
347 347 elseif cmd == 2 then
348   - if order.status ~= 2 then
  348 + if order.status ~= 1 then
349 349 return 32
350 350 end
351   - if order.n <= taskData.value then
  351 + if order.n < taskData.value then
352 352 return 6
353 353 end
354 354 for typ, count in pairs(taskData.reward:toNumMap()) do
355 355 role:addItem({itemId = typ, count = count})
356 356 end
357   - orders[index] = nil
  357 + table.remove(orders,index)
358 358 else
359 359 return 33
360 360 end
... ...
1   -Subproject commit 9f5e58a4fe6e6d10741caad1078a25f014a45de8
  1 +Subproject commit dcdc185e5426a77fad2c43030897edab06d45468
... ...
src/models/Diner.lua
... ... @@ -45,7 +45,7 @@ function Diner:refreshDailyData(notify)
45 45 end
46 46  
47 47 -- 特殊订单
48   - local orders = {}
  48 + local orders = json.decode(self:getProperty("order"))
49 49 -- 等级由订单板等级决定
50 50 local taskLevel = self:getProperty("buildL"):getv(5, 1)
51 51 local taskData = csvdb["diner_questCsv"][taskLevel]
... ... @@ -55,8 +55,14 @@ function Diner:refreshDailyData(notify)
55 55 for n = 1, 6 do
56 56 local index = math.randWeight(taskPool, "chance")
57 57 local data = taskPool[index]
58   - table.insert(orders, {lv = taskLevel, id = data.id, n = 0, lock = 0,status = 0})
59   - table.remove(taskPool, index)
  58 + local order = orders[n]
  59 + if order then
  60 + if order.lock == 0 then
  61 + orders[n] = {lv = taskLevel, id = data.id, n = 0, lock = 0,status = 0}
  62 + end
  63 + else
  64 + orders[n] = {lv = taskLevel, id = data.id, n = 0, lock = 0,status = 0}
  65 + end
60 66 end
61 67 end
62 68 end
... ... @@ -91,15 +97,15 @@ function Diner:notifyUpdateProperty(field, newValue, oldValue)
91 97 SendPacket(actionCodes.Diner_updateProperty, MsgPack.pack(datas))
92 98 end
93 99  
94   -function Diner:checkDinerTask(type, count, param1, param2, notNotify)
  100 +function Diner:checkDinerTask(typ, count, param1, param2, notNotify)
95 101 local orders = json.decode(self:getProperty("order"))
96 102 local dirty = false
97   - for _, order in ipairs(orders) do
  103 + for k, order in ipairs(orders) do
98 104 local taskSet = csvdb["diner_questCsv"][order.lv]
99 105 if taskSet and taskSet[order.id] then
100 106 local data = taskSet[order.id]
101   - if data.type == type and data.condition1 == param1 and order.status == 1 then
102   - data.n = data.n + count
  107 + if data.type == typ and data.condition1 == param1 and order.status == 1 then
  108 + orders[k].n = orders[k].n + count
103 109 dirty = true
104 110 end
105 111 end
... ...