Blame view

src/actions/DinerAction.lua 1.29 KB
87cc3a35   zhengshouren   餐厅建筑升级逻辑
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  local ipairs = ipairs
  local table = table
  local math = math
  local redisproxy = redisproxy
  local MsgPack = MsgPack
  
  local _M = {}
  
  function _M.addSellRpc( agent, data )
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  
  	local slot = msg.slot
  	if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then
  		return
  	end
  	if slot > role.dinerData:getMaxSlots() then
  		return
  	end
  	local dish = msg.dish
  	local dishSet = csvdb["diner_dishCsv"][dish]
  	if not dishSet then
  		return
  	end
  	local count = msg.count
  	if math.illegalNum(count, 1, role.dinerData:getMaxDishs()) then
  		return
  	end
  
  end
  
  function _M.getSellRewardRpc( agent, data )
  	
  end
  
  function _M.levelUpRpc( agent, data )
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  
  	local index = msg.index
  	local buildingData = csvdb["diner_buildingCsv"][index]
  	if not buildingData then
  		return
  	end
  
  	local buildL = role.dinerData:getProperty("buildL")
  	local curLevel = buildL:getv(index, 1)
  	if curLevel >= #buildingData then
  		return
  	end
  
  	local cost = buildingData[curLevel].starCost:toNumMap()
  	if not role:checkItemEnough(cost) then
  		return 
  	end
  
  	role:costItems(cost, {})
  	role.dinerData:updateProperty({field = "level", value = buildL:setv(index, curLevel + 1)})
  
  	SendPacket(actionCodes.Diner_levelUpRpc, '')
  	return true
  end
  
  return _M