Commit 4864d579d05defc7e204e01be240adf00f0803b3
1 parent
0cca9748
领取任务,锁定任务,获得特殊任务
Showing
4 changed files
with
113 additions
and
7 deletions
Show diff stats
src/GlobalVar.lua
| ... | ... | @@ -42,7 +42,7 @@ ItemType = { |
| 42 | 42 | Cuisine = 11, -- 料理(用于增加好感度、贩卖获得金币) |
| 43 | 43 | LunchBox = 12, -- 便当盒(料理合成,冒险系统消耗道具) |
| 44 | 44 | TimeBox = 13, -- 时间箱(开启需要时间,随机产出道具) |
| 45 | - AdvItem = 14 -- 冒险道具 | |
| 45 | + AdvItem = 14, -- 冒险道具 | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | -- 物品起始id |
| ... | ... | @@ -60,8 +60,8 @@ ItemId = { |
| 60 | 60 | EquipUp = 11, -- 装备升级材料 |
| 61 | 61 | DinerCoin = 12, --后勤物资 |
| 62 | 62 | LoveUp = 14, --好感度提升道具 |
| 63 | + DinerSpTask = 20, -- 餐厅任务采购券 | |
| 63 | 64 | LoveBreak = 21, --好感度突破道具 |
| 64 | - BoxKey = 20, -- 开箱钥匙 | |
| 65 | 65 | PvpKey = 22, -- 开箱钥匙 |
| 66 | 66 | LunchFragment = 23, |
| 67 | 67 | HeroFC = {700, 701, 702, 703}, -- 通用角色碎片 | ... | ... |
src/ProtocolCode.lua
src/actions/DinerAction.lua
| ... | ... | @@ -282,4 +282,107 @@ function _M.skillUpRpc( agent, data ) |
| 282 | 282 | return true |
| 283 | 283 | end |
| 284 | 284 | |
| 285 | +function _M.lockTaskRpc( agent, data ) | |
| 286 | + local role = agent.role | |
| 287 | + local msg = MsgPack.unpack(data) | |
| 288 | + local index = msg.index | |
| 289 | + | |
| 290 | + if math.illegalNum(index, 1, 7) then | |
| 291 | + return 1 | |
| 292 | + end | |
| 293 | + local orders = json.decode(role.dinerData:getProperty("order")) | |
| 294 | + local order = orders[index] | |
| 295 | + if not order then | |
| 296 | + return 2 | |
| 297 | + end | |
| 298 | + if order.lock ~= 0 then | |
| 299 | + return 3 | |
| 300 | + end | |
| 301 | + | |
| 302 | + order.lock = 1 | |
| 303 | + role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) | |
| 304 | + SendPacket(actionCodes.Diner_lockTaskRpc, '') | |
| 305 | + return true | |
| 306 | +end | |
| 307 | + | |
| 308 | +function _M.finishTaskRpc( agent, data ) | |
| 309 | + local role = agent.role | |
| 310 | + local msg = MsgPack.unpack(data) | |
| 311 | + local index = msg.index | |
| 312 | + | |
| 313 | + if math.illegalNum(index, 1, 7) then | |
| 314 | + return 1 | |
| 315 | + end | |
| 316 | + local orders = json.decode(role.dinerData:getProperty("order")) | |
| 317 | + local order = orders[index] | |
| 318 | + if not order then | |
| 319 | + return 2 | |
| 320 | + end | |
| 321 | + if order.lock == 2 then | |
| 322 | + return 3 | |
| 323 | + end | |
| 324 | + local taskSet = csvdb["diner_questCsv"][order.lv] | |
| 325 | + if not taskSet then | |
| 326 | + return 4 | |
| 327 | + end | |
| 328 | + local taskData = taskSet[order.id] | |
| 329 | + if not taskData then | |
| 330 | + return 5 | |
| 331 | + end | |
| 332 | + if order.n <= taskData.value then | |
| 333 | + return 6 | |
| 334 | + end | |
| 335 | + | |
| 336 | + order.lock = 2 | |
| 337 | + role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) | |
| 338 | + for type, count in pairs(taskData.reward:toNumMap()) do | |
| 339 | + role:addItem({itemId = type, count = count}) | |
| 340 | + end | |
| 341 | + | |
| 342 | + SendPacket(actionCodes.Diner_finishTaskRpc, '') | |
| 343 | + return true | |
| 344 | +end | |
| 345 | + | |
| 346 | +function _M.getSpecialTaskRpc( agent, data ) | |
| 347 | + local role = agent.role | |
| 348 | + local msg = MsgPack.unpack(data) | |
| 349 | + | |
| 350 | + local cost = {[DinerSpTask] = 1} | |
| 351 | + if not role:checkItemEnough(cost) then | |
| 352 | + return 1 | |
| 353 | + end | |
| 354 | + | |
| 355 | + local orders = json.decode(role.dinerData:getProperty("order")) | |
| 356 | + if #orders > 6 then | |
| 357 | + return 2 | |
| 358 | + end | |
| 359 | + | |
| 360 | + local taskLevel = role.dinerData:getProperty("buildL"):getv(5, 1) | |
| 361 | + local taskData = csvdb["diner_questCsv"][taskLevel] | |
| 362 | + if not taskData then | |
| 363 | + return 3 | |
| 364 | + end | |
| 365 | + local taskPool = {} | |
| 366 | + for _, data in pairs(taskData) do | |
| 367 | + if data.rarity >= 3 then | |
| 368 | + table.inser(taskPool, data) | |
| 369 | + end | |
| 370 | + end | |
| 371 | + if #taskPool == 0 then | |
| 372 | + return 4 | |
| 373 | + end | |
| 374 | + | |
| 375 | + role:costItems(cost) | |
| 376 | + | |
| 377 | + local index = math.randWeight(taskPool, "chance") | |
| 378 | + local data = taskPool[index] | |
| 379 | + | |
| 380 | + table.insert(orders, {lv = taskLevel, id = data.id, n = 0, lock = 0}) | |
| 381 | + role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) | |
| 382 | + | |
| 383 | + SendPacket(actionCodes.Diner_getSpecialTaskRpc, '') | |
| 384 | + return true | |
| 385 | +end | |
| 386 | + | |
| 387 | + | |
| 285 | 388 | return _M |
| 286 | 389 | \ No newline at end of file | ... | ... |
src/models/Diner.lua
| ... | ... | @@ -94,11 +94,11 @@ end |
| 94 | 94 | function Diner:checkDinerTask(type, count, param1, param2, notNotify) |
| 95 | 95 | local orders = json.decode(self:getProperty("order")) |
| 96 | 96 | local dirty = false |
| 97 | - for _, task in ipairs(orders) do | |
| 98 | - local taskSet = csvdb["diner_questCsv"][task.lv] | |
| 99 | - if taskSet and taskSet[task.id] then | |
| 100 | - local data = taskSet[task.id] | |
| 101 | - if data.type == type and data.condition1 == param1 and task.lock > 0 then | |
| 97 | + for _, order in ipairs(orders) do | |
| 98 | + local taskSet = csvdb["diner_questCsv"][order.lv] | |
| 99 | + if taskSet and taskSet[order.id] then | |
| 100 | + local data = taskSet[order.id] | |
| 101 | + if data.type == type and data.condition1 == param1 and order.lock > 0 then | |
| 102 | 102 | data.n = data.n + count |
| 103 | 103 | dirty = true |
| 104 | 104 | end | ... | ... |