Commit d51114bda792fceb51bf57ff74eb206159691718

Authored by wangyujie
1 parent 4dc77717

完成需求:每日金币购买

src/ProtocolCode.lua
... ... @@ -42,6 +42,7 @@ actionCodes = {
42 42 Role_openSpeedUpBoxRpc = 128,
43 43 Role_guideRpc = 129,
44 44 Role_getRandomNameRpc = 130,
  45 + Role_goldBuyRpc = 131,
45 46  
46 47 Adv_startAdvRpc = 151,
47 48 Adv_startHangRpc = 152,
... ...
src/actions/RoleAction.lua
... ... @@ -1005,4 +1005,32 @@ function _M.guideRpc(agent, data)
1005 1005 return true
1006 1006 end
1007 1007  
  1008 +function _M.goldBuyRpc(agent, data)
  1009 + local role = agent.role
  1010 + local curT = role.dailyData:getProperty("goldBuyT")
  1011 + local costD = globalCsv.idle_quickMoney_cost[curT]
  1012 + if not costD then
  1013 + return 1
  1014 + end
  1015 + if costD ~= 0 and not role:checkItemEnough({[ItemId.Diamond] = costD}) then
  1016 + return 2
  1017 + end
  1018 + local goldC = 0
  1019 + local hangPass = role:getProperty("hangPass")
  1020 + for i = 1, 3 do
  1021 + if hangPass[i] then
  1022 + local carbonData = csvdb["idle_battleCsv"][hangPass[i]]
  1023 + goldC = math.max(goldC, carbonData.money * globalCsv.idle_quickMoney_effect)
  1024 + end
  1025 + end
  1026 + if goldC == 0 then
  1027 + return 3
  1028 + end
  1029 + role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1})
  1030 + role:costItems({[ItemId.Diamond] = costD}, {log = {desc = "goldBuy"}})
  1031 + local reward = role:award({[ItemId.Gold] = goldC}, {log = {desc = "goldBuy"}})
  1032 + SendPacket(actionCodes.Role_goldBuyRpc, MsgPack.pack({reward = reward}))
  1033 + return true
  1034 +end
  1035 +
1008 1036 return _M
1009 1037 \ No newline at end of file
... ...
src/models/Daily.lua
... ... @@ -24,7 +24,8 @@ Daily.schema = {
24 24 dailySDC = {"table", {}}, -- daily shop diamond count {[id] = count} -- 每日商城购买次数统计
25 25 dailySDD = {"table", {}}, -- daily shop diamond disount {[id] = 1} -- 每日商城折扣统计
26 26  
27   - advSupRe = {"number", 0}, -- 冒险支援效果刷新次数
  27 + advSupRe = {"number", 0}, -- 冒险支援效果刷新次数
  28 + goldBuyT = {"number", 0}, -- 金币购买次数
28 29 }
29 30  
30 31 function Daily:updateProperty(params)
... ... @@ -97,6 +98,7 @@ function Daily:data()
97 98 dailySDC = self:getProperty("dailySDC"),
98 99 dailySDD = self:getProperty("dailySDD"),
99 100 advSupRe = self:getProperty("advSupRe"),
  101 + goldBuyT = self:getProperty("goldBuyT"),
100 102 }
101 103 end
102 104  
... ...