cccc9c70
zhouhaihai
商城
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
local _M = {}
function _M.rechargeRpc(agent , data)
local role = agent.role
local msg = MsgPack.unpack(data)
local id = msg.id
local dataSet = csvdb["shop_rechargeCsv"][id]
if not dataSet then return end
local diamondCount
if dataSet.type == 0 then -- 钻石
local rechargeF = role:getProperty("rechargeF")
diamondCount = dataSet.diamond + dataSet.diamondExtra
if not rechargeF[id] then
diamondCount = diamondCount + dataSet.diamondFirst
rechargeF[id] = 1
role:updateProperty({field = "rechargeF", value = rechargeF})
end
|
3133cb76
zhouhaihai
日志
|
18
|
role:gainDiamond({count = diamondCount, isRecharge = true, log = {desc = "recharge", int1 = id}})
|
cccc9c70
zhouhaihai
商城
|
19
20
21
22
23
24
25
26
27
28
29
30
|
elseif dataSet.type == 1 then --月卡
return
elseif dataSet.type == 2 then -- 赛季通行证
return
else
return
end
-- 累充
local rmb = dataSet.rmb
role:updateProperty({field = "rmbC", delta = rmb})
|
3133cb76
zhouhaihai
日志
|
31
32
|
role:log("role_action", {desc = "recharge", int1 = id})
|
cccc9c70
zhouhaihai
商城
|
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
|
SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({diamond = diamondCount}))
return true
end
function _M.dailyBuyRpc(agent , data)
local role = agent.role
local msg = MsgPack.unpack(data)
local id = msg.id
local count = msg.count or 1
local dataSet = csvdb["shop_diamondCsv"][id]
if not dataSet then return 1 end
local dailySDC = role.dailyData:getProperty("dailySDC")
if math.illegalNum(count, 1, (dataSet.limit == 0 and math.huge or dataSet.limit - (dailySDC[id] or 0))) then return 1 end
local cost = dataSet.cost
if dataSet.type == 0 then
local dailySDD = role.dailyData:getProperty("dailySDD")
if dailySDD[id] then -- 折扣
cost = math.ceil(cost * (1 - dataSet.disount / 100))
end
elseif dataSet.type == 1 then
else
return 3
end
|
b216676d
zhouhaihai
log
|
62
|
if not role:costDiamond({count = cost * count, log = {desc = "dailyShop", int1 = id, int2 = count}}) then
|
cccc9c70
zhouhaihai
商城
|
63
64
65
66
67
68
69
|
return 4
end
if dataSet.limit ~= 0 then
dailySDC[id] = (dailySDC[id] or 0) + count
role.dailyData:updateProperty({field = "dailySDC", value = dailySDC})
end
|
3133cb76
zhouhaihai
日志
|
70
71
72
|
local reward = role:award(dataSet.gift, {log = {desc = "dailyShop", int1 = id, int2 = count}})
role:log("role_action", {desc = "dailyShop", int1 = id, int2 = count})
|
cccc9c70
zhouhaihai
商城
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
SendPacket(actionCodes.Store_dailyBuyRpc, MsgPack.pack({reward = reward}))
return true
end
function _M.dinerBuyRpc(agent , data)
local role = agent.role
local msg = MsgPack.unpack(data)
local id = msg.id
local count = msg.count or 1
local dataSet = csvdb["shop_dinerCsv"][id]
if not dataSet then return end
local dinerS = role:getProperty("dinerS")
if math.illegalNum(count, 1, (dataSet.limit == 0 and math.huge or dataSet.limit - (dinerS[id] or 0))) then return 1 end
local cost = {[ItemId.DinerCoin] = dataSet.cost}
if not role:checkItemEnough(cost) then return end
if dataSet.limit ~= 0 then
dinerS[id] = (dinerS[id] or 0) + count
role:updateProperty({field = "dinerS", value = dinerS})
end
|
3133cb76
zhouhaihai
日志
|
99
|
role:costItems(cost, {log = {desc = "dinerShop", int1 = id, int2 = count}})
|
cccc9c70
zhouhaihai
商城
|
100
101
102
103
104
|
local gift = {}
for _id, _count in pairs(dataSet.gift:toNumMap()) do
gift[_id] = _count * count
end
|
3133cb76
zhouhaihai
日志
|
105
106
107
|
local reward = role:award(gift, {log = {desc = "dinerShop", int1 = id, int2 = count}})
role:log("role_action", {desc = "dinerShop", int1 = id, int2 = count})
|
cccc9c70
zhouhaihai
商城
|
108
109
110
111
112
113
|
SendPacket(actionCodes.Store_dinerBuyRpc, MsgPack.pack({reward = reward}))
return true
end
return _M
|