Commit 9232edb0813c42ecff6c6e818cab72ec72190d38

Authored by zhouhaihai
2 parents 1a17dd0f aec0d74f

Merge branch 'develop' into qa

config/develop.lua
@@ -2,7 +2,7 @@ include("basic.lua") @@ -2,7 +2,7 @@ include("basic.lua")
2 2
3 logd = 0 -- 是否开启日志 3 logd = 0 -- 是否开启日志
4 thread = 4 4 thread = 4
5 -codeurl = "106.13.60.20:9090" 5 +codeurl = "192.168.8.223:9090"
6 servId = 1 6 servId = 1
7 7
8 max_client = 64 8 max_client = 64
@@ -2,6 +2,7 @@ XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18" @@ -2,6 +2,7 @@ XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18"
2 RESET_TIME = 0 2 RESET_TIME = 0
3 3
4 START_RESET_TIME_BASE = 1584316800 -- 0时区 4 START_RESET_TIME_BASE = 1584316800 -- 0时区
  5 +DAY_SEC = 86400
5 TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", START_RESET_TIME_BASE))) / 3600) -- 本地时区 6 TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", START_RESET_TIME_BASE))) / 3600) -- 本地时区
6 7
7 START_RESET_TIME = START_RESET_TIME_BASE - TIME_ZONE * 3600 8 START_RESET_TIME = START_RESET_TIME_BASE - TIME_ZONE * 3600
@@ -128,6 +129,7 @@ ItemId = { @@ -128,6 +129,7 @@ ItemId = {
128 TimeReset = { 129 TimeReset = {
129 CrossDay = 1, --通用跨天 130 CrossDay = 1, --通用跨天
130 CrossWeek = 2, --通用跨周 131 CrossWeek = 2, --通用跨周
  132 + CrossMonth = 1, --通用跨月 索引使用跨天,在回调方法中判断是否跨越 跨月的前置条件是跨天
131 DinerRank = 1, -- 餐厅排行榜 133 DinerRank = 1, -- 餐厅排行榜
132 PvpRank = 2, -- pvp排行榜 134 PvpRank = 2, -- pvp排行榜
133 PvpHight = 11, --高级竞技场 135 PvpHight = 11, --高级竞技场
@@ -259,3 +261,41 @@ RedPointTags = { @@ -259,3 +261,41 @@ RedPointTags = {
259 PvpCR = 1, 261 PvpCR = 1,
260 PvpHR = 2, 262 PvpHR = 2,
261 } 263 }
  264 +
  265 +RefreshType = {
  266 + RefreshType_Daily = 1, -- 日刷新
  267 + RefreshType_Weekly = 2, -- 周刷新
  268 + RefreshType_Monthly = 3, -- 月刷新
  269 +}
  270 +
  271 +CardType = {
  272 + NormalMonthCard = 1, --普通月卡
  273 + SuperMonthCard = 2, --超级月卡
  274 + PrivilegeCard = 3, --特权卡
  275 + GrowFund = 4, --成长助力
  276 + BattleCard = 5, --赛季卡
  277 +}
  278 +
  279 +HeroQuality = {
  280 + N = 1,
  281 + R = 2,
  282 + SR = 3,
  283 + SSR = 4,
  284 +}
  285 +
  286 +MailId = {
  287 + MonthCard = 201,
  288 + SuperMonthCard = 202,
  289 + MonthCardEx = 203,
  290 + SuperMonthCardEx = 204,
  291 + BattleCardAward = 210,
  292 +
  293 + ActDrawCard = 231,
  294 + ActOpenBox = 232,
  295 + ActAdvDraw = 233,
  296 + ActSellFood = 234,
  297 + ActDrawCardReward = 221,
  298 + ActOpenBoxReward = 222,
  299 + ActAdvDrawReward = 223,
  300 + ActSellFoodReward = 224,
  301 +}
src/ProtocolCode.lua
@@ -6,6 +6,7 @@ actionCodes = { @@ -6,6 +6,7 @@ actionCodes = {
6 Sys_innerErrorMsg = 4, 6 Sys_innerErrorMsg = 4,
7 Sys_commonNotice = 5, 7 Sys_commonNotice = 5,
8 Sys_maintainNotice = 6, 8 Sys_maintainNotice = 6,
  9 + Sys_customNotice = 7,
9 10
10 Gm_clientRequest = 20, 11 Gm_clientRequest = 20,
11 Gm_receiveResponse = 21, 12 Gm_receiveResponse = 21,
@@ -87,6 +88,7 @@ actionCodes = { @@ -87,6 +88,7 @@ actionCodes = {
87 Hero_getResetRewardRpc = 219, 88 Hero_getResetRewardRpc = 219,
88 Hero_drawHeroRpc = 220, 89 Hero_drawHeroRpc = 220,
89 Hero_repayHeroRpc = 221, 90 Hero_repayHeroRpc = 221,
  91 + Hero_unlockPoolRpc = 222,
90 92
91 Hang_startRpc = 251, 93 Hang_startRpc = 251,
92 Hang_checkRpc = 252, 94 Hang_checkRpc = 252,
@@ -182,6 +184,11 @@ actionCodes = { @@ -182,6 +184,11 @@ actionCodes = {
182 Store_ayncPurchaseRpc = 555, 184 Store_ayncPurchaseRpc = 555,
183 Store_myCardRechargeRpc = 556, 185 Store_myCardRechargeRpc = 556,
184 Store_iosRechargeRpc = 557, 186 Store_iosRechargeRpc = 557,
  187 + Store_shopBuyRpc = 558,
  188 + Store_updateproperty = 559,
  189 + Store_getFreeChestRpc = 560,
  190 + Store_getGrowFundRewardRpc = 561, --成长助力奖励
  191 + Store_getBattlePassRewardRpc = 562, --赛季卡奖励
185 192
186 193
187 Email_listRpc = 600, 194 Email_listRpc = 600,
@@ -11,6 +11,7 @@ R_RUNEIDS = "role:%d:runeIds" -- 玩家拥有符文自增id @@ -11,6 +11,7 @@ R_RUNEIDS = "role:%d:runeIds" -- 玩家拥有符文自增id
11 R_RUNE = "role:%d:rune:%d" -- 符文详细信息 11 R_RUNE = "role:%d:rune:%d" -- 符文详细信息
12 R_EMAIL = "role:%d:emailIds" --邮件列表 12 R_EMAIL = "role:%d:emailIds" --邮件列表
13 R_EMAIL_ITEM = "email:%d:%d" --邮件 13 R_EMAIL_ITEM = "email:%d:%d" --邮件
  14 +R_STORE = "role:%d:store" -- 商店
14 15
15 16
16 -- rank 17 -- rank
src/actions/ActivityAction.lua
@@ -32,9 +32,9 @@ function _M.sudokuRpc(agent, data) @@ -32,9 +32,9 @@ function _M.sudokuRpc(agent, data)
32 if (sudoku.task[phase][id] or 0) < curData.con1 then return 2 end 32 if (sudoku.task[phase][id] or 0) < curData.con1 then return 2 end
33 33
34 sudoku.task[phase][id] = -1 34 sudoku.task[phase][id] = -1
35 - local task = role:award(curData.reward, {log = {desc = "sudoku", int1 = id, int2 = phase}}) -- 任务奖励 35 + local task, tchange = role:award(curData.reward, {log = {desc = "sudoku", int1 = id, int2 = phase}}) -- 任务奖励
36 36
37 - local reward = {} 37 + local reward, rchange = {}
38 local rId = {} 38 local rId = {}
39 for pid, pdata in pairs(csvdb["guide_sudoku_rewardCsv"][phase] or {}) do 39 for pid, pdata in pairs(csvdb["guide_sudoku_rewardCsv"][phase] or {}) do
40 local pos = pdata.pos:toArray(true, "=") 40 local pos = pdata.pos:toArray(true, "=")
@@ -60,14 +60,14 @@ function _M.sudokuRpc(agent, data) @@ -60,14 +60,14 @@ function _M.sudokuRpc(agent, data)
60 if not next(reward) then 60 if not next(reward) then
61 reward = nil 61 reward = nil
62 else 62 else
63 - reward = role:award(reward, {log = {desc = "sudokuR", int1 = id, int2 = phase}}) 63 + reward, rchange = role:award(reward, {log = {desc = "sudokuR", int1 = id, int2 = phase}})
64 end 64 end
65 65
66 role:updateProperty({field = "sudoku", value = sudoku}) 66 role:updateProperty({field = "sudoku", value = sudoku})
67 67
68 role:log("act_action", {desc = "sudoku", int1 = id, int2 = phase}) 68 role:log("act_action", {desc = "sudoku", int1 = id, int2 = phase})
69 69
70 - SendPacket(actionCodes.Activity_sudokuRpc, MsgPack.pack({task = task, reward = reward, rId = rId})) 70 + SendPacket(actionCodes.Activity_sudokuRpc, MsgPack.pack({task = role:packReward(task, tchange), reward = role:packReward(reward, rchange), rId = rId}))
71 return true 71 return true
72 end 72 end
73 73
@@ -90,7 +90,7 @@ function _M.sudokuRewardRpc(agent, data) @@ -90,7 +90,7 @@ function _M.sudokuRewardRpc(agent, data)
90 end 90 end
91 end 91 end
92 92
93 - local reward = role:award(globalCsv.guide_sudoku_reward[phase], {log = {desc = "sudokuRP", int1 = phase}}) 93 + local reward, change = role:award(globalCsv.guide_sudoku_reward[phase], {log = {desc = "sudokuRP", int1 = phase}})
94 94
95 sudoku[-1] = phase + 1 95 sudoku[-1] = phase + 1
96 sudoku.task[phase] = nil 96 sudoku.task[phase] = nil
@@ -100,7 +100,7 @@ function _M.sudokuRewardRpc(agent, data) @@ -100,7 +100,7 @@ function _M.sudokuRewardRpc(agent, data)
100 end 100 end
101 role:updateProperty({field = "sudoku", value = sudoku}) 101 role:updateProperty({field = "sudoku", value = sudoku})
102 102
103 - SendPacket(actionCodes.Activity_sudokuRewardRpc, MsgPack.pack(reward)) 103 + SendPacket(actionCodes.Activity_sudokuRewardRpc, MsgPack.pack(role:packReward(reward, change)))
104 return true 104 return true
105 end 105 end
106 106
@@ -125,10 +125,10 @@ function _M.signRpc(agent, data) @@ -125,10 +125,10 @@ function _M.signRpc(agent, data)
125 end 125 end
126 signs[curDay] = yearMonth 126 signs[curDay] = yearMonth
127 127
128 - local reward = role:award(monthData[curDay].item, {log = {desc = "sign", int1 = yearMonth, int2 = curDay}}) 128 + local reward, change = role:award(monthData[curDay].item, {log = {desc = "sign", int1 = yearMonth, int2 = curDay}})
129 role:changeUpdates({{type = "sign", field = curDay, value = yearMonth}}) 129 role:changeUpdates({{type = "sign", field = curDay, value = yearMonth}})
130 130
131 - SendPacket(actionCodes.Activity_signRpc, MsgPack.pack(reward)) 131 + SendPacket(actionCodes.Activity_signRpc, MsgPack.pack(role:packReward(reward, change)))
132 return true 132 return true
133 end 133 end
134 134
@@ -138,7 +138,7 @@ function _M.actSignRpc(agent, data) @@ -138,7 +138,7 @@ function _M.actSignRpc(agent, data)
138 if not role.activity:isOpen("Sign") then return 1 end 138 if not role.activity:isOpen("Sign") then return 1 end
139 139
140 local curData = role.activity:getActData("Sign") 140 local curData = role.activity:getActData("Sign")
141 - local reward = {} 141 + local reward, change = {}
142 for day, csvData in ipairs(csvdb["new_signInCsv"]) do 142 for day, csvData in ipairs(csvdb["new_signInCsv"]) do
143 if day <= (curData[0] or 0) then 143 if day <= (curData[0] or 0) then
144 if not curData[day] then 144 if not curData[day] then
@@ -154,9 +154,9 @@ function _M.actSignRpc(agent, data) @@ -154,9 +154,9 @@ function _M.actSignRpc(agent, data)
154 end 154 end
155 if next(reward) then 155 if next(reward) then
156 role.activity:updateActData("Sign", curData) 156 role.activity:updateActData("Sign", curData)
157 - reward = role:award(reward, {log = {desc = "actSign"}}) 157 + reward, change = role:award(reward, {log = {desc = "actSign"}})
158 end 158 end
159 - SendPacket(actionCodes.Activity_actSignRpc, MsgPack.pack(reward)) 159 + SendPacket(actionCodes.Activity_actSignRpc, MsgPack.pack(role:packReward(reward, change)))
160 return true 160 return true
161 end 161 end
162 162
src/actions/AdvAction.lua
@@ -187,23 +187,23 @@ function _M.startHangRpc(agent, data) @@ -187,23 +187,23 @@ function _M.startHangRpc(agent, data)
187 local format = msg.format --编队 187 local format = msg.format --编队
188 188
189 local chapterData = csvdb["adv_chapterCsv"][chapterId] 189 local chapterData = csvdb["adv_chapterCsv"][chapterId]
190 - if not chapterData then return end  
191 - if chapterData.idleReward == "" then return end --没有奖励 没有挂机 190 + if not chapterData then return 1 end
  191 + if chapterData.idleReward == "" then return 2 end --没有奖励 没有挂机
192 192
193 local advHang = role:getProperty("advHang") 193 local advHang = role:getProperty("advHang")
194 - if advHang[chapterId] then return end --正在挂机 194 + if advHang[chapterId] then return 3 end --正在挂机
195 195
196 - if role:getAdvData():isRunning() and role:getAdvData().chapterId == chapterId then return end 196 + if role:getAdvData():isRunning() and role:getAdvData().chapterId == chapterId then return 4 end
197 197
198 - if AdvCommon.isEndless(chapterId) then return end -- 无尽没有代理 198 + if AdvCommon.isEndless(chapterId) then return 5 end -- 无尽没有代理
199 199
200 local advRelay = role:getProperty("advRelay") 200 local advRelay = role:getProperty("advRelay")
201 - if not next(advRelay[chapterId] or {}) then return end -- 没有开放 201 + if not next(advRelay[chapterId] or {}) then return 6 end -- 没有开放
202 202
203 203
204 - if not role:checkAdvCount(chapterData.limitlevel) then return end -- 是否有体力 204 + if not role:checkAdvCount(chapterData.limitlevel) then return 7 end -- 是否有体力
205 205
206 - if not checkFormat(role, format, role:getAdvData():isRunning()) then return end --编队是否正确 206 + if not checkFormat(role, format, role:getAdvData():isRunning()) then return 8 end --编队是否正确
207 207
208 local player = {} 208 local player = {}
209 local attrs = role:getTeamBattleInfo(format).heros 209 local attrs = role:getTeamBattleInfo(format).heros
@@ -220,7 +220,7 @@ function _M.startHangRpc(agent, data) @@ -220,7 +220,7 @@ function _M.startHangRpc(agent, data)
220 + 0.226 * player["hit"] 220 + 0.226 * player["hit"]
221 + 0.26 * player["miss"] 221 + 0.26 * player["miss"]
222 222
223 - if battleV < chapterData.idleValue then return end -- 战斗力是否满足 223 + if battleV < chapterData.idleValue then return 9 end -- 战斗力是否满足
224 224
225 local info = {} 225 local info = {}
226 info.format = {} 226 info.format = {}
@@ -290,7 +290,7 @@ function _M.endHangRpc(agent, data) @@ -290,7 +290,7 @@ function _M.endHangRpc(agent, data)
290 local chapterData = csvdb["adv_chapterCsv"][chapterId] 290 local chapterData = csvdb["adv_chapterCsv"][chapterId]
291 if not chapterData then return end 291 if not chapterData then return end
292 292
293 - local reward, isFull 293 + local reward, isFull, change
294 if skynet.timex() >= info.time then 294 if skynet.timex() >= info.time then
295 -- 英雄加成 295 -- 英雄加成
296 local idleUnit = chapterData.idleUnit:toNumMap() 296 local idleUnit = chapterData.idleUnit:toNumMap()
@@ -321,7 +321,7 @@ function _M.endHangRpc(agent, data) @@ -321,7 +321,7 @@ function _M.endHangRpc(agent, data)
321 for itemId, count in pairs(idleReward) do 321 for itemId, count in pairs(idleReward) do
322 idleReward[itemId] = math.floor(count * (maxCampsite.idleValue + upUnit) / 100) 322 idleReward[itemId] = math.floor(count * (maxCampsite.idleValue + upUnit) / 100)
323 end 323 end
324 - reward = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}}) 324 + reward, change = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}})
325 else 325 else
326 if cancel then 326 if cancel then
327 role:changeAdvCount(-chapterData.limitlevel) 327 role:changeAdvCount(-chapterData.limitlevel)
@@ -339,7 +339,7 @@ function _M.endHangRpc(agent, data) @@ -339,7 +339,7 @@ function _M.endHangRpc(agent, data)
339 339
340 role:log("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0}) 340 role:log("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0})
341 341
342 - SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, isFull = isFull})) 342 + SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull}))
343 return true 343 return true
344 end 344 end
345 345
@@ -381,9 +381,9 @@ function _M.finishTaskRpc(agent, data) @@ -381,9 +381,9 @@ function _M.finishTaskRpc(agent, data)
381 if not isCanContinue(role) then return end 381 if not isCanContinue(role) then return end
382 local adv = role:getAdvData() 382 local adv = role:getAdvData()
383 local taskId = msg.taskId -- -1 则是主线任务 383 local taskId = msg.taskId -- -1 则是主线任务
384 - local status, reward 384 + local status, reward, change
385 if taskId == -1 then 385 if taskId == -1 then
386 - status, reward = adv:finishMTask() 386 + status, reward, change = adv:finishMTask()
387 else 387 else
388 status, reward = adv:finishTask(taskId) 388 status, reward = adv:finishTask(taskId)
389 adv:checkAchievement(adv.AchievType.TaskLayer, 1, taskId) 389 adv:checkAchievement(adv.AchievType.TaskLayer, 1, taskId)
@@ -395,7 +395,7 @@ function _M.finishTaskRpc(agent, data) @@ -395,7 +395,7 @@ function _M.finishTaskRpc(agent, data)
395 395
396 adv:log({desc = "finishTask", int1 = taskId}) 396 adv:log({desc = "finishTask", int1 = taskId})
397 397
398 - SendPacket(actionCodes.Adv_finishTaskRpc, MsgPack.pack({reward = reward})) 398 + SendPacket(actionCodes.Adv_finishTaskRpc, MsgPack.pack(role:packReward(reward, change)))
399 return true 399 return true
400 end 400 end
401 401
@@ -749,11 +749,11 @@ function _M.repayWheelSurfRpc(agent, data) @@ -749,11 +749,11 @@ function _M.repayWheelSurfRpc(agent, data)
749 advDrawB[ptype] = advDrawB[ptype] - globalCsv.adv_draw_back_cond 749 advDrawB[ptype] = advDrawB[ptype] - globalCsv.adv_draw_back_cond
750 role:updateProperty({field = "advDrawB", value = advDrawB}) 750 role:updateProperty({field = "advDrawB", value = advDrawB})
751 local gift = drawData["pool3"]:randWeight(true) 751 local gift = drawData["pool3"]:randWeight(true)
752 - local reward = {[gift[1]] = gift[2]}  
753 - reward = role:award(reward, {log = {desc = "advRepayWheelSurf", int1 = ptype}}) 752 + local reward, change = {[gift[1]] = gift[2]}
  753 + reward, change = role:award(reward, {log = {desc = "advRepayWheelSurf", int1 = ptype}})
754 role:log("adv_action", {desc = "advRepayWheelSurf", int1 = ptype}) 754 role:log("adv_action", {desc = "advRepayWheelSurf", int1 = ptype})
755 755
756 - SendPacket(actionCodes.Adv_repayWheelSurfRpc, MsgPack.pack({reward = reward})) 756 + SendPacket(actionCodes.Adv_repayWheelSurfRpc, MsgPack.pack(role:packReward(reward, change)))
757 return true 757 return true
758 end 758 end
759 759
@@ -766,17 +766,17 @@ function _M.finishAchievRpc(agent, data) @@ -766,17 +766,17 @@ function _M.finishAchievRpc(agent, data)
766 766
767 local adv = role:getAdvData() 767 local adv = role:getAdvData()
768 768
769 - local status, reward 769 + local status, reward, change
770 if ctype == 1 then 770 if ctype == 1 then
771 - status, reward = adv:finishAchievement(chapterId, taskId) 771 + status, reward, change = adv:finishAchievement(chapterId, taskId)
772 elseif ctype == 2 then 772 elseif ctype == 2 then
773 - status, reward = adv:getAchievementReward(chapterId, taskId) 773 + status, reward, change = adv:getAchievementReward(chapterId, taskId)
774 end 774 end
775 if not status then return end 775 if not status then return end
776 adv:updateAchievement() 776 adv:updateAchievement()
777 role:log("adv_action", {desc = "finishAchiev", short1 = ctype, int1 = chapterId, int2 = taskId}) 777 role:log("adv_action", {desc = "finishAchiev", short1 = ctype, int1 = chapterId, int2 = taskId})
778 778
779 - SendPacket(actionCodes.Adv_finishAchievRpc, MsgPack.pack({reward = reward})) 779 + SendPacket(actionCodes.Adv_finishAchievRpc, MsgPack.pack(role:packReward(reward, change)))
780 return true 780 return true
781 end 781 end
782 782
src/actions/CarAction.lua
@@ -150,7 +150,7 @@ function _M.saleEquipRpc(agent, data ) @@ -150,7 +150,7 @@ function _M.saleEquipRpc(agent, data )
150 local own = role:getEquipCount(typ,lv) 150 local own = role:getEquipCount(typ,lv)
151 if math.illegalNum(count, 1, own) then return end 151 if math.illegalNum(count, 1, own) then return end
152 end 152 end
153 - local reward = {} 153 + local reward, change = {}
154 local allCount = 0 154 local allCount = 0
155 for id, count in pairs(backs) do 155 for id, count in pairs(backs) do
156 allCount = allCount + count 156 allCount = allCount + count
@@ -165,11 +165,11 @@ function _M.saleEquipRpc(agent, data ) @@ -165,11 +165,11 @@ function _M.saleEquipRpc(agent, data )
165 end 165 end
166 end 166 end
167 role:checkTaskEnter("SaleEquip", {count = allCount}) 167 role:checkTaskEnter("SaleEquip", {count = allCount})
168 - reward = role:award(reward, {log = {desc = "saleEquip"}}) 168 + reward, change = role:award(reward, {log = {desc = "saleEquip"}})
169 169
170 role:log("role_action", {desc = "saleEquip", int1 = allCount}) 170 role:log("role_action", {desc = "saleEquip", int1 = allCount})
171 171
172 - SendPacket(actionCodes.Car_saleEquipRpc, MsgPack.pack({reward = reward})) 172 + SendPacket(actionCodes.Car_saleEquipRpc, MsgPack.pack(role:packReward(reward, change)))
173 return true 173 return true
174 end 174 end
175 175
@@ -179,7 +179,7 @@ function _M.saleRuneRpc(agent, data ) @@ -179,7 +179,7 @@ function _M.saleRuneRpc(agent, data )
179 local backs = msg.backs 179 local backs = msg.backs
180 if not backs then return end 180 if not backs then return end
181 181
182 - local reward = {} 182 + local reward, change = {}
183 local count = 0 183 local count = 0
184 for _, uid in pairs(backs) do 184 for _, uid in pairs(backs) do
185 count = count + 1 185 count = count + 1
@@ -196,9 +196,9 @@ function _M.saleRuneRpc(agent, data ) @@ -196,9 +196,9 @@ function _M.saleRuneRpc(agent, data )
196 196
197 role:delRunes(backs, {log = {desc = "saleRune"}}) 197 role:delRunes(backs, {log = {desc = "saleRune"}})
198 role:checkTaskEnter("DecoRune", {count = count}) 198 role:checkTaskEnter("DecoRune", {count = count})
199 - reward = role:award(reward, {log = {desc = "saleRune"}}) 199 + reward, change = role:award(reward, {log = {desc = "saleRune"}})
200 200
201 - SendPacket(actionCodes.Car_saleRuneRpc, MsgPack.pack({reward = reward})) 201 + SendPacket(actionCodes.Car_saleRuneRpc, MsgPack.pack(role:packReward(reward, change)))
202 return true 202 return true
203 end 203 end
204 204
src/actions/DinerAction.lua
@@ -141,19 +141,19 @@ function _M.removeSellRpc( agent, data ) @@ -141,19 +141,19 @@ function _M.removeSellRpc( agent, data )
141 end 141 end
142 142
143 role.dinerData:updateSell(slot) 143 role.dinerData:updateSell(slot)
144 - local reward = {} 144 + local reward, change = {}
145 local cost = dishData.material:toNumMap() 145 local cost = dishData.material:toNumMap()
146 for k, n in pairs(cost) do 146 for k, n in pairs(cost) do
147 local sum = n*sell.count 147 local sum = n*sell.count
148 reward[k] = sum 148 reward[k] = sum
149 end 149 end
150 - reward = role:award(reward, {log = {desc = "removeSell"}}) 150 + reward, change = role:award(reward, {log = {desc = "removeSell"}})
151 sells[slot].count = 0 151 sells[slot].count = 0
152 152
153 role:log("diner_action", {desc = "removeSell", int1 = dish}) 153 role:log("diner_action", {desc = "removeSell", int1 = dish})
154 154
155 role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) 155 role.dinerData:updateProperty({field = "sells", value = json.encode(sells)})
156 - SendPacket(actionCodes.Diner_removeSellRpc, MsgPack.pack({reward = reward})) 156 + SendPacket(actionCodes.Diner_removeSellRpc, MsgPack.pack({reward = reward, change = change}))
157 return true 157 return true
158 end 158 end
159 159
@@ -195,7 +195,7 @@ function _M.getSellRewardRpc( agent, data ) @@ -195,7 +195,7 @@ function _M.getSellRewardRpc( agent, data )
195 role:checkTaskEnter("FoodSellGold", {count = v}) 195 role:checkTaskEnter("FoodSellGold", {count = v})
196 end 196 end
197 end 197 end
198 - role:award(gift, {log = {desc = "dinerSell"}}) 198 + local reward, change = role:award(gift, {log = {desc = "dinerSell"}})
199 199
200 200
201 role.dinerData:popularAdd(popular) 201 role.dinerData:popularAdd(popular)
@@ -206,7 +206,7 @@ function _M.getSellRewardRpc( agent, data ) @@ -206,7 +206,7 @@ function _M.getSellRewardRpc( agent, data )
206 206
207 role:log("diner_action", {desc = "sell"}) 207 role:log("diner_action", {desc = "sell"})
208 208
209 - SendPacket(actionCodes.Diner_getSellRewardRpc, MsgPack.pack({reward = reward})) 209 + SendPacket(actionCodes.Diner_getSellRewardRpc, MsgPack.pack({reward = reward, change = change}))
210 return true 210 return true
211 end 211 end
212 212
@@ -261,12 +261,20 @@ function _M.expediteSellRpc( agent, data ) @@ -261,12 +261,20 @@ function _M.expediteSellRpc( agent, data )
261 role.dinerData:setProperty("expedite",count+1) 261 role.dinerData:setProperty("expedite",count+1)
262 role.dinerData:notifyUpdateProperty("expedite", count+1) 262 role.dinerData:notifyUpdateProperty("expedite", count+1)
263 local gift = reward:toNumMap() 263 local gift = reward:toNumMap()
  264 +
  265 + -- 特权卡获取加速获得额外道具
  266 + local coef = role.storeData:getProduceItemSpeedCoef()
264 for k, v in pairs(gift) do 267 for k, v in pairs(gift) do
  268 + if coef > 1 then
  269 + v = math.floor(v * coef)
  270 + gift[k] = v
  271 + end
265 if k == ItemId.Gold then 272 if k == ItemId.Gold then
266 role:checkTaskEnter("FoodSellGold", {count = v}) 273 role:checkTaskEnter("FoodSellGold", {count = v})
267 end 274 end
268 end 275 end
269 - role:award(gift, {log = {desc = "dinerSell"}}) 276 + local change
  277 + reward, change = role:award(gift, {log = {desc = "dinerSell"}})
270 278
271 279
272 role.dinerData:popularAdd(popular) 280 role.dinerData:popularAdd(popular)
@@ -278,7 +286,7 @@ function _M.expediteSellRpc( agent, data ) @@ -278,7 +286,7 @@ function _M.expediteSellRpc( agent, data )
278 286
279 role:log("diner_action", {desc = "sellQ"}) 287 role:log("diner_action", {desc = "sellQ"})
280 288
281 - SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward,popular = popular})) 289 + SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward, change = change, popular = popular}))
282 return true 290 return true
283 end 291 end
284 292
@@ -493,7 +501,7 @@ function _M.updateTaskRpc( agent, data ) @@ -493,7 +501,7 @@ function _M.updateTaskRpc( agent, data )
493 return 5 501 return 5
494 end 502 end
495 503
496 - 504 + local reward, change
497 if cmd == 0 then 505 if cmd == 0 then
498 if order.status ~= 0 then 506 if order.status ~= 0 then
499 return 30 507 return 30
@@ -522,7 +530,7 @@ function _M.updateTaskRpc( agent, data ) @@ -522,7 +530,7 @@ function _M.updateTaskRpc( agent, data )
522 end 530 end
523 role:log("diner_action", {desc = "finishTask", int1 = order.id}) 531 role:log("diner_action", {desc = "finishTask", int1 = order.id})
524 532
525 - role:award(taskData.reward, {log = {desc = "dinerFinishTask", int1 = order.id}}) 533 + reward, change = role:award(taskData.reward, {log = {desc = "dinerFinishTask", int1 = order.id}})
526 table.remove(orders,index) 534 table.remove(orders,index)
527 role:checkTaskEnter("OverOderTask", {rarity = taskSet.rarity}) 535 role:checkTaskEnter("OverOderTask", {rarity = taskSet.rarity})
528 else 536 else
@@ -530,7 +538,7 @@ function _M.updateTaskRpc( agent, data ) @@ -530,7 +538,7 @@ function _M.updateTaskRpc( agent, data )
530 end 538 end
531 539
532 role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) 540 role.dinerData:updateProperty({field = "order", value = json.encode(orders)})
533 - SendPacket(actionCodes.Diner_updateTaskRpc, '') 541 + SendPacket(actionCodes.Diner_updateTaskRpc, MsgPack.pack({reward = reward, change = change}))
534 return true 542 return true
535 end 543 end
536 544
@@ -681,12 +689,12 @@ function _M.getGreenhouseRpc( agent, data ) @@ -681,12 +689,12 @@ function _M.getGreenhouseRpc( agent, data )
681 end 689 end
682 end 690 end
683 role.dinerData:updateProperty({field = "gfood", value = gfood}) 691 role.dinerData:updateProperty({field = "gfood", value = gfood})
684 - local reward = role:award(reward, {log = {desc = "greenHourse", int1 = level}}) 692 + local reward, change = role:award(reward, {log = {desc = "greenHourse", int1 = level}})
685 role:checkTaskEnter("FoodMGet") 693 role:checkTaskEnter("FoodMGet")
686 694
687 role:log("diner_action", {desc = "greenHourse"}) 695 role:log("diner_action", {desc = "greenHourse"})
688 696
689 - SendPacket(actionCodes.Diner_getGreenhouseRpc, MsgPack.pack({reward = reward})) 697 + SendPacket(actionCodes.Diner_getGreenhouseRpc, MsgPack.pack({reward = reward, change = change}))
690 return true 698 return true
691 end 699 end
692 700
@@ -798,7 +806,7 @@ function _M.entrustRpc(agent , data) @@ -798,7 +806,7 @@ function _M.entrustRpc(agent , data)
798 local entrustId = entrust[1] 806 local entrustId = entrust[1]
799 if not entrustId then return end 807 if not entrustId then return end
800 808
801 - local reward 809 + local reward, change
802 if ctype == 1 then -- 完成 810 if ctype == 1 then -- 完成
803 local curData = csvdb["diner_missionCsv"][entrustId] 811 local curData = csvdb["diner_missionCsv"][entrustId]
804 if not curData then return end 812 if not curData then return end
@@ -813,7 +821,7 @@ function _M.entrustRpc(agent , data) @@ -813,7 +821,7 @@ function _M.entrustRpc(agent , data)
813 return 821 return
814 end 822 end
815 823
816 - reward = role:award(curData.reward, {log = {desc = "dinerEntrus", int1 = entrustId}}) 824 + reward, change = role:award(curData.reward, {log = {desc = "dinerEntrus", int1 = entrustId}})
817 table.remove(entrust, 1) 825 table.remove(entrust, 1)
818 elseif ctype == 2 then -- 放弃 826 elseif ctype == 2 then -- 放弃
819 table.remove(entrust, 1) 827 table.remove(entrust, 1)
@@ -824,7 +832,7 @@ function _M.entrustRpc(agent , data) @@ -824,7 +832,7 @@ function _M.entrustRpc(agent , data)
824 832
825 role:log("diner_action", {desc = "entrus", short1 = ctype, int1 = entrustId}) 833 role:log("diner_action", {desc = "entrus", short1 = ctype, int1 = entrustId})
826 834
827 - SendPacket(actionCodes.Diner_entrustRpc, MsgPack.pack({reward = reward})) 835 + SendPacket(actionCodes.Diner_entrustRpc, MsgPack.pack({reward = reward, change = change}))
828 return true 836 return true
829 end 837 end
830 838
@@ -845,12 +853,12 @@ function _M.collectRpc(agent , data) @@ -845,12 +853,12 @@ function _M.collectRpc(agent , data)
845 for slot, _ in pairs(sells) do 853 for slot, _ in pairs(sells) do
846 role.dinerData:updateSell(slot) 854 role.dinerData:updateSell(slot)
847 end 855 end
848 - local reward = role:award(customerData.reward, {log = {desc = "dinerCollect", int1 = id}}) 856 + local reward, change = role:award(customerData.reward, {log = {desc = "dinerCollect", int1 = id}})
849 customer[id] = 1 857 customer[id] = 1
850 role.dinerData:updateProperty({field = "customer", value = customer}) -- 解锁了 858 role.dinerData:updateProperty({field = "customer", value = customer}) -- 解锁了
851 role:log("diner_action", {desc = "collect", int1 = id}) 859 role:log("diner_action", {desc = "collect", int1 = id})
852 860
853 - SendPacket(actionCodes.Diner_collectRpc, MsgPack.pack({reward = reward})) 861 + SendPacket(actionCodes.Diner_collectRpc, MsgPack.pack({reward = reward, change = change}))
854 return true 862 return true
855 end 863 end
856 864
@@ -874,13 +882,13 @@ function _M.comboRewardRpc(agent , data) @@ -874,13 +882,13 @@ function _M.comboRewardRpc(agent , data)
874 end 882 end
875 883
876 comboStatus[id] = 1 884 comboStatus[id] = 1
877 - local reward = role:award(comboData.reward, {log = {desc = "dinerCombo", int1 = id}}) 885 + local reward, change = role:award(comboData.reward, {log = {desc = "dinerCombo", int1 = id}})
878 886
879 role.dinerData:updateProperty({field = "comboStatus", value = comboStatus}) -- 解锁了 887 role.dinerData:updateProperty({field = "comboStatus", value = comboStatus}) -- 解锁了
880 888
881 role:log("diner_action", {desc = "combo", int1 = id}) 889 role:log("diner_action", {desc = "combo", int1 = id})
882 890
883 - SendPacket(actionCodes.Diner_comboRewardRpc, MsgPack.pack({reward = reward})) 891 + SendPacket(actionCodes.Diner_comboRewardRpc, MsgPack.pack({reward = reward, change = change}))
884 return true 892 return true
885 end 893 end
886 894
src/actions/EmailAction.lua
@@ -86,7 +86,7 @@ function _M.drawAllAttachRpc(agent, data) @@ -86,7 +86,7 @@ function _M.drawAllAttachRpc(agent, data)
86 local role = agent.role 86 local role = agent.role
87 local roleId = role:getProperty("id") 87 local roleId = role:getProperty("id")
88 88
89 - local reward = {} 89 + local reward, change = {}
90 local ids = {} 90 local ids = {}
91 91
92 local emails = loadEmails(roleId) 92 local emails = loadEmails(roleId)
@@ -95,19 +95,18 @@ function _M.drawAllAttachRpc(agent, data) @@ -95,19 +95,18 @@ function _M.drawAllAttachRpc(agent, data)
95 local attachments = getEmailAttachments(email) 95 local attachments = getEmailAttachments(email)
96 if attachments ~= "" then 96 if attachments ~= "" then
97 local emailId = email:getProperty("id") 97 local emailId = email:getProperty("id")
98 - local items = role:award(attachments, {log = {desc = "draw_attach", int1 = emailId, key1 = email:getProperty("title")}})  
99 ids[emailId] = 1 98 ids[emailId] = 1
100 red:hset(string.format(R_EMAIL_ITEM, roleId, emailId), "status", 2) 99 red:hset(string.format(R_EMAIL_ITEM, roleId, emailId), "status", 2)
101 role:log("mail_action", {desc = "draw_attach", int1 = emailId, key1 = email:getProperty("title"), key2 = attachments}) 100 role:log("mail_action", {desc = "draw_attach", int1 = emailId, key1 = email:getProperty("title"), key2 = attachments})
102 101
103 - for key, v in pairs(items) do 102 + for key, v in pairs(attachments:toNumMap()) do
104 reward[key] = (reward[key] or 0) + v 103 reward[key] = (reward[key] or 0) + v
105 end 104 end
106 end 105 end
107 end 106 end
108 end) 107 end)
109 -  
110 - SendPacket(actionCodes.Email_drawAllAttachRpc, MsgPack.pack({ids = ids, reward = reward})) 108 + reward, change = role:award(reward, {log = {desc = "draw_attach"}})
  109 + SendPacket(actionCodes.Email_drawAllAttachRpc, MsgPack.pack({ids = ids, reward = reward, change = change}))
111 return true 110 return true
112 end 111 end
113 112
@@ -125,9 +124,9 @@ function _M.drawAttachRpc(agent, data) @@ -125,9 +124,9 @@ function _M.drawAttachRpc(agent, data)
125 local attachments = getEmailAttachments(email) 124 local attachments = getEmailAttachments(email)
126 if attachments == "" then return end 125 if attachments == "" then return end
127 126
128 - local reward = role:award(attachments, {log = {desc = "draw_attach", int1 = emailId, key1 = email:getProperty("title")}}) 127 + local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = emailId, key1 = email:getProperty("title")}})
129 redisproxy:hset(rds, "status", 2) -- 领取标记 128 redisproxy:hset(rds, "status", 2) -- 领取标记
130 - SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward})) 129 + SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change}))
131 130
132 role:log("mail_action", {desc = "draw_attach", int1 = id, key1 = email:getProperty("title"), key2 = attachments}) 131 role:log("mail_action", {desc = "draw_attach", int1 = id, key1 = email:getProperty("title"), key2 = attachments})
133 return true 132 return true
src/actions/GmAction.lua
@@ -512,11 +512,17 @@ function _M.helpRpc(agent, data) @@ -512,11 +512,17 @@ function _M.helpRpc(agent, data)
512 return true 512 return true
513 end 513 end
514 514
  515 +function _M.test(role, pms)
  516 + local id = tonum(pms.pm1, 0)
  517 + --local hero = require ("actions.HeroAction")
  518 + --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id}))
  519 + role.storeData:onBattleCardReset()
  520 + return "成功"
  521 +end
  522 +
515 -- 充值回调 523 -- 充值回调
516 function _M.ayncPurchase(role, params) 524 function _M.ayncPurchase(role, params)
517 return role:handlePurchase(params) or "" 525 return role:handlePurchase(params) or ""
518 end 526 end
519 527
520 -  
521 -  
522 return _M 528 return _M
523 \ No newline at end of file 529 \ No newline at end of file
src/actions/HangAction.lua
@@ -25,13 +25,23 @@ local function checkReward(role) @@ -25,13 +25,23 @@ local function checkReward(role)
25 local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) 25 local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0)
26 local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0) 26 local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0)
27 27
28 - local coinCount = math.max(0, math.floor((nowCoinTime - hangInfo.coinTime) / globalCsv.idle_money_produce_cd))  
29 - hangInfo.coinTime = hangInfo.coinTime + coinCount * globalCsv.idle_money_produce_cd 28 + -- 此次挂机,其中翻倍时长占多少
  29 + local doubleTime = role.activity:getActHangDoubleTime(hangInfo.coinTime, nowCoinTime)
  30 + local normalTime = nowCoinTime - hangInfo.coinTime - doubleTime
30 31
31 - local itemCount = math.max(0, math.floor((nowItemTime - hangInfo.itemTime) / globalCsv.idle_item_produce_cd))  
32 - hangInfo.itemTime = hangInfo.itemTime + itemCount * globalCsv.idle_item_produce_cd 32 + local coinCount = math.max(0, math.floor((normalTime) / globalCsv.idle_money_produce_cd))
  33 + local coinDoubleCount = math.max(0, math.floor((doubleTime) / globalCsv.idle_money_produce_cd)) * 2
  34 + hangInfo.coinTime = nowCoinTime
  35 +
  36 + doubleTime = role.activity:getActHangDoubleTime(hangInfo.itemTime, nowitemTime)
  37 + normalTime = nowItemTime - hangInfo.coinTime - doubleTime
  38 + local itemCount = math.max(0, math.floor((normalTime) / globalCsv.idle_item_produce_cd))
  39 + local itemDoubleCount = math.max(0, math.floor((doubleTime) / globalCsv.idle_item_produce_cd))
  40 + itemCount = itemCount + itemDoubleCount
  41 + hangInfo.itemTime = nowItemTime
33 42
34 local items = role:getProperty("hangBag") 43 local items = role:getProperty("hangBag")
  44 + coinCount = coinCount + coinDoubleCount
35 items[ItemId.Gold] = (items[ItemId.Gold] or 0) + coinCount * carbonData.money 45 items[ItemId.Gold] = (items[ItemId.Gold] or 0) + coinCount * carbonData.money
36 items[ItemId.Exp] = (items[ItemId.Exp] or 0) + coinCount * carbonData.exp 46 items[ItemId.Exp] = (items[ItemId.Exp] or 0) + coinCount * carbonData.exp
37 items[ItemId.PlayerExp] = (items[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp 47 items[ItemId.PlayerExp] = (items[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp
@@ -48,7 +58,10 @@ local function checkReward(role) @@ -48,7 +58,10 @@ local function checkReward(role)
48 curIC = curIC + count 58 curIC = curIC + count
49 end 59 end
50 end 60 end
51 - local selfFC = role:getProperty("hangBagLimit") --再加上月卡的栏位 TODO 61 +
  62 + -- 特权卡挂机额外栏位
  63 + local privExtraCnt = role.storeData:getHangSlotExtraCount()
  64 + local selfFC = role:getProperty("hangBagLimit") + privExtraCnt
52 local selfIC = selfFC * globalCsv.idle_field_limit 65 local selfIC = selfFC * globalCsv.idle_field_limit
53 66
54 local function randomItem() 67 local function randomItem()
@@ -187,7 +200,8 @@ function _M.endBattleRpc(agent, data) @@ -187,7 +200,8 @@ function _M.endBattleRpc(agent, data)
187 local msg = MsgPack.unpack(data) 200 local msg = MsgPack.unpack(data)
188 local hangInfo = role:getProperty("hangInfo") 201 local hangInfo = role:getProperty("hangInfo")
189 if not msg.key or msg.key ~= _BattleKey then 202 if not msg.key or msg.key ~= _BattleKey then
190 - return 1 203 + SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1}))
  204 + return true
191 end 205 end
192 local carbonId = msg.carbonId 206 local carbonId = msg.carbonId
193 local carbonData = csvdb["idle_battleCsv"][carbonId] 207 local carbonData = csvdb["idle_battleCsv"][carbonId]
@@ -203,7 +217,7 @@ function _M.endBattleRpc(agent, data) @@ -203,7 +217,7 @@ function _M.endBattleRpc(agent, data)
203 if role:checkHangPass(carbonId) then 217 if role:checkHangPass(carbonId) then
204 return 4 218 return 4
205 end 219 end
206 - local reward 220 + local reward, change
207 if msg.starNum and msg.starNum > 0 then --win 221 if msg.starNum and msg.starNum > 0 then --win
208 role:hangFinish(carbonId) 222 role:hangFinish(carbonId)
209 if carbonData.main ~= 1 then 223 if carbonData.main ~= 1 then
@@ -217,7 +231,7 @@ function _M.endBattleRpc(agent, data) @@ -217,7 +231,7 @@ function _M.endBattleRpc(agent, data)
217 for itemId, count in pairs(carbonData.item_clear:toNumMap()) do 231 for itemId, count in pairs(carbonData.item_clear:toNumMap()) do
218 reward[itemId] = count 232 reward[itemId] = count
219 end 233 end
220 - reward = role:award(reward, {log = {desc = "hangBattle", int1 = carbonId}}) 234 + reward, change = role:award(reward, {log = {desc = "hangBattle", int1 = carbonId}})
221 235
222 role:checkTaskEnter("HangPass", {id = carbonId}) 236 role:checkTaskEnter("HangPass", {id = carbonId})
223 end 237 end
@@ -229,6 +243,7 @@ function _M.endBattleRpc(agent, data) @@ -229,6 +243,7 @@ function _M.endBattleRpc(agent, data)
229 SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({ 243 SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({
230 starNum = msg.starNum, 244 starNum = msg.starNum,
231 reward = reward, 245 reward = reward,
  246 + change = change,
232 })) 247 }))
233 return true 248 return true
234 end 249 end
@@ -276,7 +291,7 @@ function _M.getRewardRpc(agent , data) @@ -276,7 +291,7 @@ function _M.getRewardRpc(agent , data)
276 checkReward(role) 291 checkReward(role)
277 local items = role:getProperty("hangBag") 292 local items = role:getProperty("hangBag")
278 if not next(items) then return end 293 if not next(items) then return end
279 - local reward = role:award(items, {log = {desc = "hangReward"}}) 294 + local reward, change = role:award(items, {log = {desc = "hangReward"}})
280 table.clear(items) 295 table.clear(items)
281 local hangInfo = role:getProperty("hangInfo") 296 local hangInfo = role:getProperty("hangInfo")
282 local nowTime = skynet.timex() 297 local nowTime = skynet.timex()
@@ -291,7 +306,8 @@ function _M.getRewardRpc(agent , data) @@ -291,7 +306,8 @@ function _M.getRewardRpc(agent , data)
291 role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) 306 role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
292 end 307 end
293 SendPacket(actionCodes.Hang_getRewardRpc, MsgPack.pack({ 308 SendPacket(actionCodes.Hang_getRewardRpc, MsgPack.pack({
294 - reward = reward 309 + reward = reward,
  310 + change = change
295 })) 311 }))
296 return true 312 return true
297 end 313 end
@@ -389,13 +405,23 @@ function _M.quickRpc(agent , data) @@ -389,13 +405,23 @@ function _M.quickRpc(agent , data)
389 reward[cur[1]] = (reward[cur[1]] or 0) + cur[2] 405 reward[cur[1]] = (reward[cur[1]] or 0) + cur[2]
390 end 406 end
391 407
392 - reward = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) 408 + -- 特权卡获取加速获得额外道具
  409 + local coef = role.storeData:getProduceItemSpeedCoef()
  410 + if coef > 1 then
  411 + for k, cnt in pairs(reward) do
  412 + reward[k] = math.floor(cnt * coef)
  413 + end
  414 + end
  415 +
  416 + local change
  417 + reward, change = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}})
393 if reward[ItemId.Gold] then 418 if reward[ItemId.Gold] then
394 role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) 419 role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
395 end 420 end
396 role:checkTaskEnter("HangQuick") 421 role:checkTaskEnter("HangQuick")
397 SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({ 422 SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({
398 - reward = reward 423 + reward = reward,
  424 + change = change
399 })) 425 }))
400 return true 426 return true
401 end 427 end
@@ -494,10 +520,13 @@ function _M.endBonusBattleRpc(agent, data) @@ -494,10 +520,13 @@ function _M.endBonusBattleRpc(agent, data)
494 local starNum = msg.starNum 520 local starNum = msg.starNum
495 if not role.__bonusBattleCache then return 1 end 521 if not role.__bonusBattleCache then return 1 end
496 522
497 - if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then return 2 end 523 + if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then
  524 + SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1}))
  525 + return true
  526 + end
498 local bonusData = csvdb["bonus_battleCsv"][id] 527 local bonusData = csvdb["bonus_battleCsv"][id]
499 528
500 - local reward 529 + local reward, change
501 if starNum and starNum > 0 then 530 if starNum and starNum > 0 then
502 -- 胜利扣除次数 531 -- 胜利扣除次数
503 local bonusC = role.dailyData:getProperty("bonusC") 532 local bonusC = role.dailyData:getProperty("bonusC")
@@ -511,7 +540,7 @@ function _M.endBonusBattleRpc(agent, data) @@ -511,7 +540,7 @@ function _M.endBonusBattleRpc(agent, data)
511 if chance[1] ~= 0 then 540 if chance[1] ~= 0 then
512 reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] 541 reward[chance[1]] = (reward[chance[1]] or 0) + chance[2]
513 end 542 end
514 - reward = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) 543 + reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}})
515 role:checkTaskEnter("BonusPass", {id = id}) 544 role:checkTaskEnter("BonusPass", {id = id})
516 end 545 end
517 546
@@ -519,7 +548,9 @@ function _M.endBonusBattleRpc(agent, data) @@ -519,7 +548,9 @@ function _M.endBonusBattleRpc(agent, data)
519 548
520 SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({ 549 SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({
521 starNum = starNum, 550 starNum = starNum,
522 - reward = reward})) 551 + reward = reward,
  552 + change = change
  553 + }))
523 return true 554 return true
524 end 555 end
525 556
@@ -534,12 +565,12 @@ function _M.hangGiftRpc(agent, data) @@ -534,12 +565,12 @@ function _M.hangGiftRpc(agent, data)
534 local hangGift = role:getProperty("hangGift") 565 local hangGift = role:getProperty("hangGift")
535 if hangGift[id] then return 2 end 566 if hangGift[id] then return 2 end
536 567
537 - local reward = role:award(carbonData.item_clear_special, {log = {desc = "hangGift", int1 = id}}) 568 + local reward, change = role:award(carbonData.item_clear_special, {log = {desc = "hangGift", int1 = id}})
538 role:log("hang_action", {desc = "hangGift", int1 = id}) 569 role:log("hang_action", {desc = "hangGift", int1 = id})
539 570
540 role:changeUpdates({{type = "hangGift", field = id, value = 1}}) 571 role:changeUpdates({{type = "hangGift", field = id, value = 1}})
541 572
542 - SendPacket(actionCodes.Hang_hangGiftRpc, MsgPack.pack(reward)) 573 + SendPacket(actionCodes.Hang_hangGiftRpc, MsgPack.pack({reward = reward, change = change}))
543 return true 574 return true
544 end 575 end
545 576
@@ -577,9 +608,9 @@ function _M.chatLineRpc(agent, data) @@ -577,9 +608,9 @@ function _M.chatLineRpc(agent, data)
577 chatline[id] = skynet.timex() 608 chatline[id] = skynet.timex()
578 role:updateProperty({field = "chatline", value = chatline}) 609 role:updateProperty({field = "chatline", value = chatline})
579 610
580 - local reward = role:award(idleData.chatline_reward, {log = {desc = "chatline", int1 = id}}) 611 + local reward, change = role:award(idleData.chatline_reward, {log = {desc = "chatline", int1 = id}})
581 612
582 - SendPacket(actionCodes.Hang_chatLineRpc, MsgPack.pack(reward)) 613 + SendPacket(actionCodes.Hang_chatLineRpc, MsgPack.pack({reward = reward, change = change}))
583 return true 614 return true
584 end 615 end
585 616
src/actions/HeroAction.lua
@@ -600,15 +600,12 @@ function _M.createHeroRandomRpc(agent, data) @@ -600,15 +600,12 @@ function _M.createHeroRandomRpc(agent, data)
600 600
601 local temp = randomData.gift1:randWeight(true) 601 local temp = randomData.gift1:randWeight(true)
602 if not temp or not next(temp) then return end 602 if not temp or not next(temp) then return end
603 - local reward = {}  
604 - if role:isHaveHero(temp[1]) then  
605 - reward = {[temp[1]] = cost}  
606 - else  
607 - reward = {[temp[1] + ItemStartId.Hero] = 1}  
608 - end 603 +
609 role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) 604 role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}})
610 - reward = role:award(reward, {log = {desc = "createHeroRandom"}})  
611 - SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack({reward = reward})) 605 + local reward, change = role:award({[temp[1] + ItemStartId.Hero] = 1}, {log = {desc = "createHeroRandom"}})
  606 +
  607 +
  608 + SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change)))
612 return true 609 return true
613 end 610 end
614 611
@@ -677,15 +674,14 @@ function _M.getResetRewardRpc(agent, data) @@ -677,15 +674,14 @@ function _M.getResetRewardRpc(agent, data)
677 for itemId, count in pairs(reward) do 674 for itemId, count in pairs(reward) do
678 reward[itemId] = math.floor(count * globalCsv.unit_back_discount) 675 reward[itemId] = math.floor(count * globalCsv.unit_back_discount)
679 end 676 end
680 - reward = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}}) 677 + local change
  678 + reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}})
681 679
682 - SendPacket(actionCodes.Hero_getResetRewardRpc, MsgPack.pack({reward = reward})) 680 + SendPacket(actionCodes.Hero_getResetRewardRpc, MsgPack.pack(role:packReward(reward, change)))
683 return true 681 return true
684 end 682 end
685 683
686 -  
687 -  
688 -function _M.drawHeroRpc(agent, data) 684 +function _M.unuse_drawHeroRpc(agent, data)
689 local role = agent.role 685 local role = agent.role
690 local msg = MsgPack.unpack(data) 686 local msg = MsgPack.unpack(data)
691 687
@@ -846,8 +842,8 @@ function _M.drawHeroRpc(agent, data) @@ -846,8 +842,8 @@ function _M.drawHeroRpc(agent, data)
846 local isNewerSSR = btype == 4 and (newerHadSSR == 0 and newerDrawCount >= globalCsv.draw_newer[1]) or false 842 local isNewerSSR = btype == 4 and (newerHadSSR == 0 and newerDrawCount >= globalCsv.draw_newer[1]) or false
847 843
848 local ssrUp = 0 844 local ssrUp = 0
849 - if draw_ssr_up_count_rate then  
850 - ssrUp = math.min(math.floor(ssrUpCount / draw_ssr_up_count_rate[1]) * draw_ssr_up_count_rate[2], draw_ssr_up_count_rate[3]) / 100 845 + if draw_ssr_up_count_rate and ssrUpCount > draw_ssr_up_count_rate[1] then
  846 + ssrUp = math.min((ssrUpCount - draw_ssr_up_count_rate[1]) * draw_ssr_up_count_rate[2], draw_ssr_up_count_rate[3]) / 100
851 end 847 end
852 while not next(resultPool) do 848 while not next(resultPool) do
853 if isNewerSSR then 849 if isNewerSSR then
@@ -892,13 +888,13 @@ function _M.drawHeroRpc(agent, data) @@ -892,13 +888,13 @@ function _M.drawHeroRpc(agent, data)
892 888
893 if draw_floor_back_counts then 889 if draw_floor_back_counts then
894 local floorHero = role:getProperty("floorHero") 890 local floorHero = role:getProperty("floorHero")
895 - floorHero[pool] = floorHeroCount 891 + floorHero[btype] = floorHeroCount
896 role:setProperty("floorHero", floorHero) 892 role:setProperty("floorHero", floorHero)
897 end 893 end
898 894
899 if draw_ssr_up_count_rate then 895 if draw_ssr_up_count_rate then
900 local ssrUp = role:getProperty("ssrUp") 896 local ssrUp = role:getProperty("ssrUp")
901 - ssrUp[pool] = ssrUpCount 897 + ssrUp[btype] = ssrUpCount
902 role:setProperty("ssrUp", ssrUp) 898 role:setProperty("ssrUp", ssrUp)
903 end 899 end
904 900
@@ -923,32 +919,213 @@ function _M.drawHeroRpc(agent, data) @@ -923,32 +919,213 @@ function _M.drawHeroRpc(agent, data)
923 return true 919 return true
924 end 920 end
925 921
926 --- function _M.repayHeroRpc(agent, data)  
927 --- local role = agent.role 922 +function _M.drawHeroRpc(agent, data)
  923 + local role = agent.role
  924 + local msg = MsgPack.unpack(data)
928 925
929 --- local repayHero = role:getProperty("repayHero")  
930 --- if repayHero < globalCsv.draw_super_repay_count then  
931 --- return  
932 --- end 926 + if not role:isFuncUnlock(FuncUnlock.GetHero) then return end
  927 + local btype = msg.pool -- 1 2 3 卡池类型
  928 + local subType = msg.subType or 1-- 定向卡池需要传 子类型
  929 + local drawType = msg.type -- 1 单抽 2 十连
  930 + local guide = msg.guide -- 是否是引导抽的
  931 + if btype ~= 1 then
  932 + subType = 1
  933 + end
  934 +
  935 + local buildTypeData = csvdb["build_typeCsv"][btype]
  936 + if not buildTypeData then return 1 end
933 937
934 --- role:updateProperty({field = "repayHero", value = 0})  
935 --- local id = math.randWeight(csvdb["build_giftCsv"], "pool_1")  
936 -  
937 --- local reward = {}  
938 --- local itemData = csvdb["itemCsv"][id]  
939 --- if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then  
940 --- local fragId = itemData.id - ItemStartId.Hero  
941 --- local heroData = csvdb["unitCsv"][fragId]  
942 --- local count = globalCsv.draw_unit_tofragment[heroData.rare]  
943 --- role:award({[fragId] = count}, {log = {desc = "heroRepay"}})  
944 --- reward = {id = fragId, count = count, from = id, fcount = 1}  
945 --- else  
946 --- role:award({[id] = 1}, {log = {desc = "heroRepay"}})  
947 --- reward = {id = id, count = 1}  
948 --- end  
949 --- role:log("hero_action", {desc = "heroRepay"})  
950 --- SendPacket(actionCodes.Hero_repayHeroRpc, MsgPack.pack({reward = reward}))  
951 --- return true  
952 --- end 938 + local drawCount = {1, 10} -- 抽取次数
  939 + if not drawCount[drawType] then return 2 end
  940 +
  941 + -- 计算抽卡消耗品
  942 + local cost = {}
  943 + local lastCount = drawCount[drawType]
  944 + for _, costType in ipairs({"draw_card", "draw_coin"}) do
  945 + if buildTypeData[costType] ~= "" then
  946 + local curCost = buildTypeData[costType]:toArray(true, "=")
  947 + local hadCount = role:getItemCount(curCost[1])
  948 + local curCount = math.floor(hadCount / curCost[2])
  949 + if curCount >= lastCount then
  950 + cost[curCost[1]] = curCost[2] * lastCount
  951 + lastCount = 0
  952 + break
  953 + elseif curCount > 0 then
  954 + cost[curCost[1]] = curCost[2] * curCount
  955 + lastCount = lastCount - curCount
  956 + end
  957 + end
  958 + end
  959 + if lastCount > 0 then -- 钱不够
  960 + return 3
  961 + end
  962 +
  963 + -- 抽取的池子
  964 + local poolMap = buildTypeData["pool"]:toNumMap()
  965 + local poolId = poolMap[subType]
  966 + if not poolId then return end
  967 +
  968 + --判断定向卡池是否开启
  969 + if btype == 1 then
  970 + if not role:isTimeResetOpen(TimeReset["DrawType" .. subType]) then
  971 + local unlockPool = role.dailyData:getProperty("unlockPool")
  972 + if not unlockPool[subType] then
  973 + return 1
  974 + end
  975 + end
  976 + end
  977 +
  978 + --TODO 活动覆盖
  979 +
  980 + local unitPool = csvdb["build_unitCsv"][poolId]
  981 + if not unitPool then return 4 end
  982 +
  983 + -- 开始抽
  984 + local resultPool = {}
  985 + local function fillDrawPool()
  986 + local condition = {"rare", "camp"}
  987 + local values = {}
  988 +
  989 + for idx, field in ipairs(condition) do
  990 + if not values[idx] then
  991 + local lpool = {}
  992 + local curIdx = 1
  993 + while unitPool[field .. "_" .. curIdx] do
  994 + lpool[curIdx] = {unitPool[field .. "_" .. curIdx]}
  995 + curIdx = curIdx + 1
  996 + end
  997 +
  998 + if next(lpool) then
  999 + values[idx] = math.randWeight(lpool, 1)
  1000 + end
  1001 + end
  1002 + end
  1003 +
  1004 + for itemId, oneData in pairs(csvdb["build_poolCsv"]) do
  1005 + if oneData["pool_" .. poolId] and oneData["pool_" .. poolId] ~= "" then
  1006 + local itemData = csvdb["itemCsv"][itemId]
  1007 + while itemData do
  1008 + if itemData.type ~= ItemType.Hero then break end
  1009 + local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero]
  1010 + if not heroData then break end
  1011 + local ok = true
  1012 + for idx, field in ipairs(condition) do
  1013 + if heroData[field] ~= values[idx] then ok = false break end
  1014 + end
  1015 + if not ok then break end
  1016 + if oneData["pool_" .. poolId] > 0 then
  1017 + resultPool[itemId] = {oneData["pool_" .. poolId]} -- itemId, count, 概率
  1018 + end
  1019 + break
  1020 + end
  1021 + end
  1022 + end
  1023 + end
  1024 +
  1025 + role:costItems(cost, {log = {desc = "drawHero", short1 = btype, int1 = poolId}})
  1026 +
  1027 + local ssrCount = 0
  1028 + local reward = {}
  1029 + for i = 1, drawCount[drawType] do
  1030 + resultPool = {}
  1031 + while not next(resultPool) do
  1032 + fillDrawPool()
  1033 + end
  1034 +
  1035 + -- 引导必送 613 丝路德
  1036 + local itemId = guide and 613 or math.randWeight(resultPool, 1)
  1037 + local itemData = csvdb["itemCsv"][itemId]
  1038 + if itemData.quality == HeroQuality.SSR then
  1039 + ssrCount = ssrCount + 1
  1040 + end
  1041 +
  1042 + if role:isHaveHero(itemData.id - ItemStartId.Hero) then
  1043 + local fragId = itemData.id - ItemStartId.Hero
  1044 + local heroData = csvdb["unitCsv"][fragId]
  1045 + local count = globalCsv.draw_unit_tofragment[heroData.rare]
  1046 + role:award({[fragId] = count}, {log = {desc = "drawHero", short1 = btype, int1 = poolId}})
  1047 + table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1})
  1048 + else
  1049 + role:award({[itemId] = 1}, {log = {desc = "drawHero", short1 = btype, int1 = poolId}})
  1050 + table.insert(reward, {id = itemId, count = 1})
  1051 + end
  1052 + end
  1053 +
  1054 + if btype == 1 or btype == 2 then
  1055 + local repayHero = role:getProperty("repayHero") or 0
  1056 + repayHero = repayHero + drawCount[drawType]
  1057 + role:updateProperty({field = "repayHero", value = repayHero})
  1058 + end
  1059 +
  1060 + role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]})
  1061 + if ssrCount > 0 then
  1062 + role:checkTaskEnter("DrawSSR", {count = ssrCount})
  1063 + end
  1064 + role:log("hero_action", {desc = "drawHero", short1 = btype, int1 = drawCount[drawType], int2 = poolId})
  1065 + SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组
  1066 + return true
  1067 +end
  1068 +
  1069 +function _M.repayHeroRpc(agent, data)
  1070 + local role = agent.role
  1071 +
  1072 + local repayHero = role:getProperty("repayHero")
  1073 + local cnt = globalCsv.draw_times_to_get_ssr or 100
  1074 + if repayHero < cnt then
  1075 + return
  1076 + end
  1077 + local result = repayHero - cnt
  1078 +
  1079 + role:updateProperty({field = "repayHero", value = result})
  1080 + local id = math.randWeight(csvdb["build_giftCsv"], "pool_1")
  1081 +
  1082 + local reward = {}
  1083 + local itemData = csvdb["itemCsv"][id]
  1084 + if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then
  1085 + local fragId = itemData.id - ItemStartId.Hero
  1086 + local heroData = csvdb["unitCsv"][fragId]
  1087 + local count = globalCsv.draw_unit_tofragment[heroData.rare]
  1088 + role:award({[fragId] = count}, {log = {desc = "heroRepay"}})
  1089 + reward = {id = fragId, count = count, from = id, fcount = 1}
  1090 + else
  1091 + role:award({[id] = 1}, {log = {desc = "heroRepay"}})
  1092 + reward = {id = id, count = 1}
  1093 + end
  1094 + role:log("hero_action", {desc = "heroRepay", int1=result})
  1095 + SendPacket(actionCodes.Hero_repayHeroRpc, MsgPack.pack({reward = reward}))
  1096 + return true
  1097 +end
  1098 +
  1099 +function _M.unlockPoolRpc(agent, data)
  1100 + local role = agent.role
  1101 + local msg = MsgPack.unpack(data)
  1102 +
  1103 + if not role:isFuncUnlock(FuncUnlock.GetHero) then return end
  1104 + local type = msg.type -- 指定定向卡池需要类型 1, 2, 3
  1105 + local needCost = true
  1106 + --当前开启的类型不用解锁
  1107 + if role:isTimeResetOpen(TimeReset["DrawType" .. type]) then
  1108 + needCost = false
  1109 + end
  1110 + --已经解锁的不需要重复解锁
  1111 + local unlockPool = role.dailyData:getProperty("unlockPool")
  1112 + if unlockPool[type] then
  1113 + needCost = false
  1114 + end
  1115 +
  1116 + if needCost then
  1117 + if not role:costDiamond({count = globalCsv.draw_unlock_pool_diamond or 300, log = {desc = "unlockPool", short1 = type}}) then
  1118 + return
  1119 + end
  1120 + end
  1121 +
  1122 + unlockPool[type] = 1
  1123 + role.dailyData:updateProperty({field="unlockPool", value = unlockPool})
  1124 + role.dailyData:updateProperty({field="curPool", value = type})
  1125 +
  1126 + role:log("hero_action", {desc = "unlockPool", short1=type})
  1127 + SendPacket(actionCodes.Hero_unlockPoolRpc, MsgPack.pack({}))
  1128 + return true
  1129 +end
953 1130
954 return _M 1131 return _M
955 \ No newline at end of file 1132 \ No newline at end of file
src/actions/HttpAction.lua
@@ -148,13 +148,32 @@ function _M.gm_action(query) @@ -148,13 +148,32 @@ function _M.gm_action(query)
148 end 148 end
149 149
150 function _M.broadcast(query) 150 function _M.broadcast(query)
151 - local bin = MsgPack.pack({body = query.content})  
152 - local codes = {  
153 - ["common"] = actionCodes.Sys_commonNotice,  
154 - ["maintain"] = actionCodes.Sys_maintainNotice, 151 + local msg = {}
  152 + local handle = {
  153 + ["common"] = {
  154 + code = actionCodes.Sys_commonNotice,
  155 + exec = function()
  156 + msg["body"] = query.content
  157 + end
  158 + },
  159 + ["maintain"] = {
  160 + code = actionCodes.Sys_maintainNotice,
  161 + exec = function()
  162 + msg["body"] = query.content
  163 + end
  164 + },
  165 + ["custom"] = {
  166 + code = actionCodes.Sys_customNotice,
  167 + exec = function()
  168 + msg["title"] = query.title
  169 + msg["body"] = query.content
  170 + msg["logout"] = query.logout
  171 + end
  172 + }
155 } 173 }
156 - if not codes[query.cmd] then return "错误" end  
157 - mcast_util.pub_world(codes[query.cmd], bin) 174 + if not handle[query.cmd] then return "错误" end
  175 + handle[query.cmd].exec()
  176 + mcast_util.pub_world(handle[query.cmd].code, MsgPack.pack(msg))
158 return "广播成功" 177 return "广播成功"
159 end 178 end
160 179
src/actions/PvpAction.lua
@@ -311,7 +311,8 @@ function _M.endBattleRpc(agent, data) @@ -311,7 +311,8 @@ function _M.endBattleRpc(agent, data)
311 local msg = MsgPack.unpack(data) 311 local msg = MsgPack.unpack(data)
312 312
313 if not msg.key or not _pvpStartBattleCacheC or msg.key ~= _pvpStartBattleCacheC.key then 313 if not msg.key or not _pvpStartBattleCacheC or msg.key ~= _pvpStartBattleCacheC.key then
314 - return 1 314 + SendPacket(actionCodes.Pvp_endBattleRpc, MsgPack.pack({errorCode = 1}))
  315 + return true
315 end 316 end
316 317
317 if not msg.idx or msg.idx ~= _pvpStartBattleCacheC.idx then 318 if not msg.idx or msg.idx ~= _pvpStartBattleCacheC.idx then
@@ -334,7 +335,7 @@ function _M.endBattleRpc(agent, data) @@ -334,7 +335,7 @@ function _M.endBattleRpc(agent, data)
334 if not match then return end 335 if not match then return end
335 336
336 local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true) 337 local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true)
337 - local reward = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}}) 338 + local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}})
338 local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin) 339 local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin)
339 340
340 _pvpBattleInfoCacheC = {} --重新发阵容了 没毛病 341 _pvpBattleInfoCacheC = {} --重新发阵容了 没毛病
@@ -349,12 +350,13 @@ function _M.endBattleRpc(agent, data) @@ -349,12 +350,13 @@ function _M.endBattleRpc(agent, data)
349 ["time"] = now, 350 ["time"] = now,
350 } 351 }
351 local status, body = httpc.get(remoteUrl, "/applyvideo?" .. httpGetFormatData(params), {}, {}) 352 local status, body = httpc.get(remoteUrl, "/applyvideo?" .. httpGetFormatData(params), {}, {})
352 - local video = nil 353 + local video, headers = nil, nil
353 if tonumber(status) == 200 then 354 if tonumber(status) == 200 then
354 local result = json.decode(body) 355 local result = json.decode(body)
355 video = result.name 356 video = result.name
  357 + headers = result.headers
356 else 358 else
357 - skynet.error("applyvideo", "error", status, body, content) 359 + skynet.error("applyvideo", "error", status, body)
358 end 360 end
359 361
360 -- 加入战斗记录 362 -- 加入战斗记录
@@ -394,6 +396,7 @@ function _M.endBattleRpc(agent, data) @@ -394,6 +396,7 @@ function _M.endBattleRpc(agent, data)
394 396
395 SendPacket(actionCodes.Pvp_endBattleRpc, MsgPack.pack({ 397 SendPacket(actionCodes.Pvp_endBattleRpc, MsgPack.pack({
396 reward = reward, 398 reward = reward,
  399 + change = change,
397 myScore = myScore, 400 myScore = myScore,
398 matchScore = matchScore, 401 matchScore = matchScore,
399 oldmyScore = oldmyScore, 402 oldmyScore = oldmyScore,
@@ -401,6 +404,7 @@ function _M.endBattleRpc(agent, data) @@ -401,6 +404,7 @@ function _M.endBattleRpc(agent, data)
401 myRank = myRank, 404 myRank = myRank,
402 oldMyRank = oldMyRank, 405 oldMyRank = oldMyRank,
403 video = video, 406 video = video,
  407 + headers = headers,
404 })) 408 }))
405 return true 409 return true
406 end 410 end
@@ -536,7 +540,8 @@ function _M.endBattleHRpc(agent, data) @@ -536,7 +540,8 @@ function _M.endBattleHRpc(agent, data)
536 local msg = MsgPack.unpack(data) 540 local msg = MsgPack.unpack(data)
537 541
538 if not msg.key or not _pvpStartBattleCacheH or msg.key ~= _pvpStartBattleCacheH.key then 542 if not msg.key or not _pvpStartBattleCacheH or msg.key ~= _pvpStartBattleCacheH.key then
539 - return 1 543 + SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({errorCode = 1}))
  544 + return true
540 end 545 end
541 546
542 if not msg.idx or msg.idx ~= _pvpStartBattleCacheH.idx then 547 if not msg.idx or msg.idx ~= _pvpStartBattleCacheH.idx then
@@ -565,12 +570,13 @@ function _M.endBattleHRpc(agent, data) @@ -565,12 +570,13 @@ function _M.endBattleHRpc(agent, data)
565 ["time"] = now, 570 ["time"] = now,
566 } 571 }
567 local status, body = httpc.get(remoteUrl, "/applyvideo?" .. httpGetFormatData(params), {}, {}) 572 local status, body = httpc.get(remoteUrl, "/applyvideo?" .. httpGetFormatData(params), {}, {})
568 - local video = nil 573 + local video, headers = nil, nil
569 if tonumber(status) == 200 then 574 if tonumber(status) == 200 then
570 local result = json.decode(body) 575 local result = json.decode(body)
571 video = result.name 576 video = result.name
  577 + headers = result.headers
572 else 578 else
573 - skynet.error("applyvideo", "error", status, body, content) 579 + skynet.error("applyvideo", "error", status, body)
574 end 580 end
575 581
576 table.insert(_pvpStartBattleCacheH.result, { 582 table.insert(_pvpStartBattleCacheH.result, {
@@ -611,13 +617,14 @@ function _M.endBattleHRpc(agent, data) @@ -611,13 +617,14 @@ function _M.endBattleHRpc(agent, data)
611 key = key, --战斗校验 key 617 key = key, --战斗校验 key
612 round = round, -- 战斗场数索引 618 round = round, -- 战斗场数索引
613 video = video, -- 返回让客户端上传录像 619 video = video, -- 返回让客户端上传录像
  620 + headers = headers,
614 })) 621 }))
615 return true 622 return true
616 end 623 end
617 624
618 -- 战斗结束了发奖 625 -- 战斗结束了发奖
619 local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true) 626 local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true)
620 - local reward = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleH"}}) 627 + local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleH"}})
621 local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, 0, 0 628 local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, 0, 0
622 if role:isTimeResetOpen(TimeReset.PvpHight) then 629 if role:isTimeResetOpen(TimeReset.PvpHight) then
623 myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin) 630 myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin)
@@ -690,6 +697,7 @@ function _M.endBattleHRpc(agent, data) @@ -690,6 +697,7 @@ function _M.endBattleHRpc(agent, data)
690 697
691 SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({ 698 SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({
692 reward = reward, 699 reward = reward,
  700 + change = change,
693 myScore = myScore, 701 myScore = myScore,
694 matchScore = matchScore, 702 matchScore = matchScore,
695 oldmyScore = oldmyScore, 703 oldmyScore = oldmyScore,
@@ -833,10 +841,10 @@ function _M.highDivisionGiftRpc(agent, data) @@ -833,10 +841,10 @@ function _M.highDivisionGiftRpc(agent, data)
833 pvpHGift = {}, 841 pvpHGift = {},
834 }) 842 })
835 843
836 - local reward = role:award(newReward, {log = {desc = "pvpDivisionH"}}) 844 + local reward, change = role:award(newReward, {log = {desc = "pvpDivisionH"}})
837 role:log("pvp_action", {desc = "pvpDivisionH"}) 845 role:log("pvp_action", {desc = "pvpDivisionH"})
838 846
839 - SendPacket(actionCodes.Pvp_highDivisionGiftRpc, MsgPack.pack({reward = reward})) 847 + SendPacket(actionCodes.Pvp_highDivisionGiftRpc, MsgPack.pack(role:packReward(reward, change)))
840 return true 848 return true
841 end 849 end
842 850
@@ -867,11 +875,11 @@ function _M.shopBuyRpc(agent, data) @@ -867,11 +875,11 @@ function _M.shopBuyRpc(agent, data)
867 for id, c in pairs(gift) do 875 for id, c in pairs(gift) do
868 gift[id] = c * count 876 gift[id] = c * count
869 end 877 end
870 - local reward = role:award(gift, {log = {desc = "pvpShop", int1 = id, int2 = count}}) 878 + local reward, change = role:award(gift, {log = {desc = "pvpShop", int1 = id, int2 = count}})
871 879
872 role:log("pvp_action", {desc = "pvpShop", int1 = id, int2 = count}) 880 role:log("pvp_action", {desc = "pvpShop", int1 = id, int2 = count})
873 881
874 - SendPacket(actionCodes.Pvp_shopBuyRpc, MsgPack.pack({reward = reward})) 882 + SendPacket(actionCodes.Pvp_shopBuyRpc, MsgPack.pack(role:packReward(reward, change)))
875 return true 883 return true
876 end 884 end
877 885
src/actions/RoleAction.lua
@@ -95,7 +95,6 @@ function _M.loginRpc( agent, data ) @@ -95,7 +95,6 @@ function _M.loginRpc( agent, data )
95 role:load() 95 role:load()
96 role:loadAll() 96 role:loadAll()
97 role:startActionUcode() 97 role:startActionUcode()
98 - role:setProperty("ltime", now)  
99 else 98 else
100 role:reloadWhenLogin() 99 role:reloadWhenLogin()
101 end 100 end
@@ -128,8 +127,10 @@ function _M.loginRpc( agent, data ) @@ -128,8 +127,10 @@ function _M.loginRpc( agent, data )
128 127
129 redisproxy:zadd(FRIEND_RECOMMEND, now, roleId) 128 redisproxy:zadd(FRIEND_RECOMMEND, now, roleId)
130 129
131 - for _, name in ipairs({"dailyData", "dinerData", "activity"}) do 130 + for _, name in ipairs({"dailyData", "dinerData", "activity", "storeData"}) do
132 response[name] = role[name]:data() 131 response[name] = role[name]:data()
  132 + --print("["..name.."]")
  133 + --dump(response[name])
133 end 134 end
134 135
135 response.role = role:data() 136 response.role = role:data()
@@ -408,9 +409,9 @@ function _M.saleItemRpc(agent, data) @@ -408,9 +409,9 @@ function _M.saleItemRpc(agent, data)
408 end 409 end
409 410
410 role:costItems(backs, {log = {desc = "saleItem"}}) 411 role:costItems(backs, {log = {desc = "saleItem"}})
411 - local reward = role:award(reward, {log = {desc = "saleItem"}}) 412 + local reward, change = role:award(reward, {log = {desc = "saleItem"}})
412 role:checkTaskEnter("DecoFrag", {count = fragCount}) 413 role:checkTaskEnter("DecoFrag", {count = fragCount})
413 - SendPacket(actionCodes.Role_saleItemRpc, MsgPack.pack({reward = reward})) 414 + SendPacket(actionCodes.Role_saleItemRpc, MsgPack.pack(role:packReward(reward, change)))
414 return true 415 return true
415 end 416 end
416 417
@@ -447,9 +448,10 @@ function _M.openItemRpc(agent, data) @@ -447,9 +448,10 @@ function _M.openItemRpc(agent, data)
447 reward[0] = nil 448 reward[0] = nil
448 449
449 role:costItems({[itemId] = count}, {log = {desc = "openItem"}}) 450 role:costItems({[itemId] = count}, {log = {desc = "openItem"}})
450 - reward = role:award(reward, {log = {desc = "openItem", int1 = itemId, int2 = count}}) 451 + local change
  452 + reward, change = role:award(reward, {log = {desc = "openItem", int1 = itemId, int2 = count}})
451 453
452 - SendPacket(actionCodes.Role_openItemRpc, MsgPack.pack({reward = reward})) 454 + SendPacket(actionCodes.Role_openItemRpc, MsgPack.pack(role:packReward(reward, change)))
453 return true 455 return true
454 end 456 end
455 457
@@ -458,10 +460,15 @@ function _M.openTimeBoxRpc(agent, data) @@ -458,10 +460,15 @@ function _M.openTimeBoxRpc(agent, data)
458 local msg = MsgPack.unpack(data) 460 local msg = MsgPack.unpack(data)
459 local oper = msg.oper -- 操作 1 - 2 461 local oper = msg.oper -- 操作 1 - 2
460 local slot = msg.slot -- 位置 1 - 6 462 local slot = msg.slot -- 位置 1 - 6
461 - if math.illegalNum(slot, 1, role:getFuncLv(FuncOpenType.TimeBoxSlot)) then return end 463 +
  464 + -- 特权卡时间箱额外栏位
  465 + local privExtraCnt = role.storeData:getTimeBoxSlotExtraCount()
  466 + if oper == 1 then
  467 + if math.illegalNum(slot, 1, role:getFuncLv(FuncOpenType.TimeBoxSlot) + privExtraCnt) then return end
  468 + end
462 469
463 local boxL = role:getProperty("boxL") 470 local boxL = role:getProperty("boxL")
464 - local reward = {} 471 + local reward, change = {}
465 if oper == 1 then -- 打开 472 if oper == 1 then -- 打开
466 local itemId = msg.itemId 473 local itemId = msg.itemId
467 if role:getItemCount(itemId) < 1 then return end 474 if role:getItemCount(itemId) < 1 then return end
@@ -509,15 +516,15 @@ function _M.openTimeBoxRpc(agent, data) @@ -509,15 +516,15 @@ function _M.openTimeBoxRpc(agent, data)
509 reward[0] = nil 516 reward[0] = nil
510 517
511 boxL[slot] = nil 518 boxL[slot] = nil
512 - reward = role:award(reward, {log = {desc = "openTimeBox", int1 = boxId}})  
513 - role:checkTaskEnter("OpenBox", {id = boxId}) 519 + reward, change = role:award(reward, {log = {desc = "openTimeBox", int1 = boxId}})
  520 + role:checkTaskEnter("OpenBox", {id = boxId, count=1})
514 else 521 else
515 return 522 return
516 end 523 end
517 524
518 role:setProperty("boxL") --刷新 525 role:setProperty("boxL") --刷新
519 role:changeUpdates({{type = "boxL", field = slot, value = boxL[slot], isOnlyToC = true}}) -- 通知客户端 526 role:changeUpdates({{type = "boxL", field = slot, value = boxL[slot], isOnlyToC = true}}) -- 通知客户端
520 - SendPacket(actionCodes.Role_openTimeBoxRpc, MsgPack.pack({reward = reward})) 527 + SendPacket(actionCodes.Role_openTimeBoxRpc, MsgPack.pack(role:packReward(reward, change)))
521 return true 528 return true
522 end 529 end
523 530
@@ -568,9 +575,10 @@ function _M.openSpeedUpBoxRpc(agent, data) @@ -568,9 +575,10 @@ function _M.openSpeedUpBoxRpc(agent, data)
568 end 575 end
569 576
570 role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) 577 role:costItems({[id] = count}, {log = {desc = "speedUpBox"}})
571 - reward = role:award(reward, {log = {desc = "speedUpBox"}, int1 = id, int2 = count}) 578 + local change
  579 + reward, change = role:award(reward, {log = {desc = "speedUpBox"}, int1 = id, int2 = count})
572 580
573 - SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack({reward = reward})) 581 + SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack(role:packReward(reward, change)))
574 return true 582 return true
575 end 583 end
576 584
@@ -596,8 +604,8 @@ function _M.storyBookRewardRpc(agent, data) @@ -596,8 +604,8 @@ function _M.storyBookRewardRpc(agent, data)
596 storyStatus[storyId] = storyStatus[storyId] or {} 604 storyStatus[storyId] = storyStatus[storyId] or {}
597 storyStatus[storyId].s = -1 605 storyStatus[storyId].s = -1
598 role:changeUpdates({{ type = "storyB", field = storyId, value = storyStatus[storyId] }}) 606 role:changeUpdates({{ type = "storyB", field = storyId, value = storyStatus[storyId] }})
599 - local reward = role:award(storyBookData.gift, {log = {desc = "storybookReward", int1 = storyId}})  
600 - SendPacket(actionCodes.Role_storyBookRewardRpc, MsgPack.pack({reward = reward})) 607 + local reward, change = role:award(storyBookData.gift, {log = {desc = "storybookReward", int1 = storyId}})
  608 + SendPacket(actionCodes.Role_storyBookRewardRpc, MsgPack.pack(role:packReward(reward, change)))
601 return true 609 return true
602 end 610 end
603 611
@@ -633,7 +641,7 @@ function _M.taskRpc(agent, data) @@ -633,7 +641,7 @@ function _M.taskRpc(agent, data)
633 641
634 if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end 642 if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end
635 643
636 - local taskType = msg.type -- 1 日常 2 周 644 + local taskType = msg.type -- 1 日常 2 周
637 local taskId = msg.id --任务id 645 local taskId = msg.id --任务id
638 local roleField = {"dTask", "wTask"} 646 local roleField = {"dTask", "wTask"}
639 if not roleField[taskType] then return 1 end 647 if not roleField[taskType] then return 1 end
@@ -648,15 +656,18 @@ function _M.taskRpc(agent, data) @@ -648,15 +656,18 @@ function _M.taskRpc(agent, data)
648 return 3 656 return 3
649 end 657 end
650 658
651 - local reward = role:award(taskData.reward, {log = {desc = "finishTask", int1 = taskType, int2 = taskId}}) 659 + local reward, change = role:award(taskData.reward, {log = {desc = "finishTask", int1 = taskType, int2 = taskId}})
652 local active = (taskStatus["a"] or 0) + taskData.active 660 local active = (taskStatus["a"] or 0) + taskData.active
653 661
654 role:changeUpdates({ 662 role:changeUpdates({
655 { type = roleField[taskType], field = {"t", taskId}, value = -1 }, 663 { type = roleField[taskType], field = {"t", taskId}, value = -1 },
656 - { type = roleField[taskType], field = "a", value = active} 664 + { type = roleField[taskType], field = "a", value = active},
657 }) 665 })
658 666
659 - SendPacket(actionCodes.Role_taskRpc, MsgPack.pack({reward = reward})) 667 + local oldVal = role:getProperty("battlePoint") or 0
  668 + role:updateProperty({field = "battlePoint", value = oldVal + taskData.active})
  669 +
  670 + SendPacket(actionCodes.Role_taskRpc, MsgPack.pack(role:packReward(reward, change)))
660 return true 671 return true
661 end 672 end
662 673
@@ -681,12 +692,12 @@ function _M.taskActiveRpc(agent, data) @@ -681,12 +692,12 @@ function _M.taskActiveRpc(agent, data)
681 return 692 return
682 end 693 end
683 694
684 - local reward = role:award(taskData.reward, {log = {desc = "taskActive", int1 = taskType, int2 = taskId}}) 695 + local reward, change = role:award(taskData.reward, {log = {desc = "taskActive", int1 = taskType, int2 = taskId}})
685 role:changeUpdates({ 696 role:changeUpdates({
686 { type = roleField[taskType], field = {"at", taskId}, value = -1 } 697 { type = roleField[taskType], field = {"at", taskId}, value = -1 }
687 }) 698 })
688 699
689 - SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack({reward = reward})) 700 + SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack(role:packReward(reward, change)))
690 return true 701 return true
691 end 702 end
692 703
@@ -712,7 +723,7 @@ function _M.achiveRpc(agent, data) @@ -712,7 +723,7 @@ function _M.achiveRpc(agent, data)
712 return 3 723 return 3
713 end 724 end
714 725
715 - local reward = role:award(achiveTask.reward, {log = {desc = "finishAchive", int1 = taskId}}) 726 + local reward, change = role:award(achiveTask.reward, {log = {desc = "finishAchive", int1 = taskId}})
716 role:changeUpdates({ 727 role:changeUpdates({
717 { type = "achiveV", field = taskId, value = skynet.timex() } 728 { type = "achiveV", field = taskId, value = skynet.timex() }
718 }) 729 })
@@ -745,7 +756,7 @@ function _M.achiveRpc(agent, data) @@ -745,7 +756,7 @@ function _M.achiveRpc(agent, data)
745 end 756 end
746 end 757 end
747 758
748 - SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack({reward = reward})) 759 + SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack(role:packReward(reward, change)))
749 return true 760 return true
750 end 761 end
751 762
@@ -921,11 +932,12 @@ function _M.drawCodeRpc(agent, data) @@ -921,11 +932,12 @@ function _M.drawCodeRpc(agent, data)
921 if ret == 0 then 932 if ret == 0 then
922 local giftId = tonumber(result.giftId) 933 local giftId = tonumber(result.giftId)
923 role:setProperty("codeStr", codestr:setv(giftId, 1)) 934 role:setProperty("codeStr", codestr:setv(giftId, 1))
924 - local reward = role:award(result.gift, {log = {desc = "drawCode", key1 = code, int1 = giftId}}) 935 + local reward, change = role:award(result.gift, {log = {desc = "drawCode", key1 = code, int1 = giftId}})
925 936
926 SendPacket(actionCodes.Role_drawCodeRpc, MsgPack.pack({ 937 SendPacket(actionCodes.Role_drawCodeRpc, MsgPack.pack({
927 result = ret, 938 result = ret,
928 reward = reward, 939 reward = reward,
  940 + change = change,
929 })) 941 }))
930 return true 942 return true
931 end 943 end
@@ -1044,10 +1056,12 @@ function _M.goldBuyRpc(agent, data) @@ -1044,10 +1056,12 @@ function _M.goldBuyRpc(agent, data)
1044 if goldC == 0 then 1056 if goldC == 0 then
1045 return 3 1057 return 3
1046 end 1058 end
  1059 + local coef = role.storeData:getGearExchangeCoef()
  1060 + goldC = goldC * coef
1047 role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1}) 1061 role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1})
1048 role:costItems({[ItemId.Diamond] = costD}, {log = {desc = "goldBuy"}}) 1062 role:costItems({[ItemId.Diamond] = costD}, {log = {desc = "goldBuy"}})
1049 - local reward = role:award({[ItemId.Gold] = goldC}, {log = {desc = "goldBuy"}})  
1050 - SendPacket(actionCodes.Role_goldBuyRpc, MsgPack.pack({reward = reward})) 1063 + local reward, change = role:award({[ItemId.Gold] = math.floor(goldC)}, {log = {desc = "goldBuy"}})
  1064 + SendPacket(actionCodes.Role_goldBuyRpc, MsgPack.pack(role:packReward(reward, change)))
1051 return true 1065 return true
1052 end 1066 end
1053 1067
src/actions/StoreAction.lua
@@ -254,4 +254,169 @@ function _M.dinerBuyRpc(agent , data) @@ -254,4 +254,169 @@ function _M.dinerBuyRpc(agent , data)
254 return true 254 return true
255 end 255 end
256 256
  257 +function _M.shopBuyRpc(agent , data)
  258 + local role = agent.role
  259 + local msg = MsgPack.unpack(data)
  260 + local id = msg.id
  261 + local count = msg.count or 1
  262 +
  263 + local dataSet = csvdb["shop_normalCsv"][id]
  264 + if not dataSet then return end
  265 +
  266 + local buyRecord = role.storeData:getProperty("buyR")
  267 + if math.illegalNum(count, 1, (dataSet.limit == 0 and math.huge or dataSet.limit - (buyRecord[id] or 0))) then
  268 + skynet.error(string.format("shop buy over limit, user_id:%d, goods_id:%d", role:getProperty("id"), id))
  269 + return 1
  270 + end
  271 +
  272 + local cost = {[dataSet.icon] = dataSet.cost * count}
  273 +
  274 + local desc = "unknown"
  275 + if dataSet.shop == 1 then -- 普通商店
  276 + desc = "dailyShop"
  277 + local dailySDD = role.dailyData:getProperty("dailySDD")
  278 + if dailySDD[id] then -- 折扣
  279 + cost = math.ceil(dataSet.cost * (1 - dataSet.disount / 100))
  280 + end
  281 + elseif dataSet.shop == 2 then -- 美食商店
  282 + desc = "dinerShop"
  283 + elseif dataSet.shop == 3 then -- 竞技场商店
  284 + desc = "pvpShop"
  285 + end
  286 +
  287 + if not role:checkItemEnough(cost) then return end
  288 +
  289 + if dataSet.limit ~= 0 then
  290 + buyRecord[id] = (buyRecord[id] or 0) + count
  291 + role.storeData:updateProperty({field = "buyR", value = buyRecord})
  292 + end
  293 + role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count}})
  294 +
  295 + local gift = {}
  296 + for _id, _count in pairs(dataSet.gift:toNumMap()) do
  297 + gift[_id] = _count * count
  298 + end
  299 + local reward = role:award(gift, {log = {desc = desc, int1 = id, int2 = count}})
  300 +
  301 + if dataSet.shop == 1 then
  302 + role:checkTaskEnter("ShopAll", {count = count})
  303 + end
  304 + role:log("role_action", {desc = desc, int1 = id, int2 = count})
  305 +
  306 + SendPacket(actionCodes.Store_shopBuyRpc, MsgPack.pack({reward = reward}))
  307 + return true
  308 +end
  309 +
  310 +function _M.getFreeChestRpc(agent, data)
  311 + local role = agent.role
  312 + local msg = MsgPack.unpack(data)
  313 + local id = msg.id
  314 +
  315 + local config = csvdb["shop_rechargeCsv"][id]
  316 + if not config then return end
  317 +
  318 + local rechargeRecord = role.storeData:getProperty("payR")
  319 + local getCount = (rechargeRecord[id] or 0)
  320 + if getCount >= config.limit then
  321 + return 1
  322 + end
  323 + local reward, _ = role:award(config.itemFirst, {log = {desc = "freeGift", int1 = id}})
  324 +
  325 + rechargeRecord[id] = getCount + 1
  326 + role.storeData:updateProperty({field = "payR", value = rechargeRecord})
  327 +
  328 + SendPacket(actionCodes.Store_getFreeChestRpc, MsgPack.pack({reward = reward}))
  329 + return true
  330 +end
  331 +
  332 +function _M.getGrowFundRewardRpc(agent, data)
  333 + local role = agent.role
  334 + local msg = MsgPack.unpack(data)
  335 + local id = msg.id
  336 +
  337 + local config = csvdb["reward_newbeeCsv"][id]
  338 + if not config then return end
  339 +
  340 + local growFundFlag = role.storeData:getProperty("growFund")
  341 + local growFundRecord = role.storeData:getProperty("growFundR")
  342 +
  343 + if growFundFlag == 0 then
  344 + skynet.error("user do not buy grow fund")
  345 + return 1
  346 + end
  347 +
  348 + if not role:checkHangPass(config.condition) then
  349 + skynet.error(string.format("user do not finish hang pass, user_id:%d", role:getProperty("id")))
  350 + return 1
  351 + end
  352 +
  353 + local b = string.getbit(growFundRecord, id)
  354 + if string.char(b) == "1" then
  355 + return 1
  356 + end
  357 +
  358 + growFundRecord = string.setbit(growFundRecord, id)
  359 + role.storeData:updateProperty({field = "growFundR", value = growFundRecord})
  360 +
  361 + local gift = config.giftFree .. " " .. config.giftLimit
  362 + local reward, _ = role:award(gift, {log = {desc = "grownFund", int1 = id}})
  363 +
  364 + SendPacket(actionCodes.Store_getGrowFundRewardRpc, MsgPack.pack({reward = reward}))
  365 + return true
  366 +end
  367 +
  368 +function _M.getBattlePassRewardRpc(agent, data)
  369 + local role = agent.role
  370 + local msg = MsgPack.unpack(data)
  371 + local id = msg.id
  372 +
  373 + local config = csvdb["reward_battlepassCsv"][id]
  374 + if not config then return end
  375 +
  376 + local timeNow = skynet.timex()
  377 + local battleCardFlag = role.storeData:getProperty("battleCard")
  378 + local battleCardFreeRecord = role.storeData:getProperty("battleFR")
  379 + local battleCardLimitRecord = role.storeData:getProperty("battleLR")
  380 +
  381 + local freeFlag = string.char(string.getbit(battleCardFreeRecord, id))
  382 + local limitFlag = string.char(string.getbit(battleCardLimitRecord, id))
  383 +
  384 + if freeFlag == "1" and limitFlag == "1" then
  385 + skynet.error("user already get battle pass reward")
  386 + return 1
  387 + end
  388 +
  389 + if battleCardFlag == 1 and limitFlag == "1" then
  390 + return 1
  391 + end
  392 +
  393 + if role:getProperty("battlePoint") < config.point then
  394 + skynet.error(string.format("user do not have enough battle point, user_id:%d", role:getProperty("id")))
  395 + return 1
  396 + end
  397 +
  398 + local gift = ""
  399 + if freeFlag == "0" then
  400 + gift = config.giftFree
  401 +
  402 + battleCardFreeRecord = string.setbit(battleCardFreeRecord, id)
  403 + role.storeData:updateProperty({field = "battleFR", value = battleCardFreeRecord})
  404 + end
  405 +
  406 + if battleCardFlag == 1 and limitFlag == "0" then
  407 + if gift ~= "" then
  408 + gift = gift .. " "
  409 + end
  410 + gift = gift .. config.giftLimit
  411 +
  412 + battleCardLimitRecord = string.setbit(battleCardLimitRecord, id)
  413 + role.storeData:updateProperty({field = "battleLR", value = battleCardLimitRecord})
  414 + end
  415 +
  416 + local reward, _ = role:award(gift, {log = {desc = "battleCard", int1 = id}})
  417 +
  418 + SendPacket(actionCodes.Store_getBattlePassRewardRpc, MsgPack.pack({reward = reward}))
  419 + return true
  420 +end
  421 +
257 return _M 422 return _M
258 \ No newline at end of file 423 \ No newline at end of file
src/actions/TowerAction.lua
@@ -90,21 +90,24 @@ function _M.endBattleRpc(agent, data) @@ -90,21 +90,24 @@ function _M.endBattleRpc(agent, data)
90 local passTime = msg.passTime 90 local passTime = msg.passTime
91 91
92 local towerInfo = role:getProperty("towerInfo") 92 local towerInfo = role:getProperty("towerInfo")
93 - if towerInfo.l ~= id or not towerInfo.k or towerInfo.k ~= key then return 1 end 93 + if towerInfo.l ~= id or not towerInfo.k or towerInfo.k ~= key then
  94 + SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({errorCode = 1}))
  95 + return true
  96 + end
94 local curTower = csvdb["tower_battleCsv"][id] 97 local curTower = csvdb["tower_battleCsv"][id]
95 if not curTower then return 2 end 98 if not curTower then return 2 end
96 99
97 local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) 100 local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t)
98 101
99 102
100 - local reward 103 + local reward, change
101 if msg.starNum and msg.starNum > 0 then --win 104 if msg.starNum and msg.starNum > 0 then --win
102 curCount = math.min(curCount + 1, globalCsv.tower_count_limit) -- 返还次数 105 curCount = math.min(curCount + 1, globalCsv.tower_count_limit) -- 返还次数
103 --排行榜 106 --排行榜
104 role:setTowerRank(towerInfo.l) 107 role:setTowerRank(towerInfo.l)
105 108
106 towerInfo.l = towerInfo.l + 1 109 towerInfo.l = towerInfo.l + 1
107 - reward = role:award(curTower.reward, {log = {desc = "towerBattle", int1 = id}}) 110 + reward, change = role:award(curTower.reward, {log = {desc = "towerBattle", int1 = id}})
108 role:checkTaskEnter("TowerPass", {level = towerInfo.l - 1}) 111 role:checkTaskEnter("TowerPass", {level = towerInfo.l - 1})
109 end 112 end
110 113
@@ -115,7 +118,7 @@ function _M.endBattleRpc(agent, data) @@ -115,7 +118,7 @@ function _M.endBattleRpc(agent, data)
115 118
116 role:log("tower_action", {desc = "endBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id}) 119 role:log("tower_action", {desc = "endBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id})
117 120
118 - SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({reward = reward})) 121 + SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({reward = reward, change = change}))
119 return true 122 return true
120 end 123 end
121 124
@@ -778,7 +778,7 @@ function Adv:over(success, rewardRatio, overType) @@ -778,7 +778,7 @@ function Adv:over(success, rewardRatio, overType)
778 778
779 local backAdvCount 779 local backAdvCount
780 if not self:isEndless() then 780 if not self:isEndless() then
781 - backAdvCount = chapterData.limitlevel - self.level 781 + backAdvCount = math.floor((chapterData.limitlevel - self.level) / globalCsv.adv_daily_count_back_radio) * globalCsv.adv_daily_count_back_radio
782 self.owner:changeAdvCount(-backAdvCount) 782 self.owner:changeAdvCount(-backAdvCount)
783 end 783 end
784 784
@@ -1897,16 +1897,16 @@ function Adv:enemyDead(enemy, escape) @@ -1897,16 +1897,16 @@ function Adv:enemyDead(enemy, escape)
1897 self:checkAchievement(Adv.AchievType.Kill, 1, enemyId) 1897 self:checkAchievement(Adv.AchievType.Kill, 1, enemyId)
1898 self:checkAchievement(Adv.AchievType.KillHadBuff, 1, enemy) 1898 self:checkAchievement(Adv.AchievType.KillHadBuff, 1, enemy)
1899 1899
1900 - self:checkAchievement(Adv.TaskType.KillWithBuff, 1)  
1901 - self:checkAchievement(Adv.TaskType.KillNoBuff, 1) 1900 + self:checkAchievement(Adv.AchievType.KillWithBuff, 1)
  1901 + self:checkAchievement(Adv.AchievType.KillNoBuff, 1)
1902 self:checkAchievement(Adv.AchievType.KillWithMWeapon, 1) 1902 self:checkAchievement(Adv.AchievType.KillWithMWeapon, 1)
1903 self:checkAchievement(Adv.AchievType.KillWithAMWeapon, 1) 1903 self:checkAchievement(Adv.AchievType.KillWithAMWeapon, 1)
1904 1904
1905 if monsterData.type == 2 then 1905 if monsterData.type == 2 then
1906 self:checkTask(Adv.TaskType.KillBoss, 1, enemyId) 1906 self:checkTask(Adv.TaskType.KillBoss, 1, enemyId)
1907 - self:checkAchievement(Adv.TaskType.KillBoss, 1, enemyId)  
1908 - self:checkAchievement(Adv.TaskType.KillBossWithBuff, 1)  
1909 - self:checkAchievement(Adv.TaskType.KillBossNoBuff, 1) 1907 + self:checkAchievement(Adv.AchievType.KillBoss, 1, enemyId)
  1908 + self:checkAchievement(Adv.AchievType.KillBossWithBuff, 1)
  1909 + self:checkAchievement(Adv.AchievType.KillBossNoBuff, 1)
1910 self:checkAchievement(Adv.AchievType.KillBossWithMWeapon, 1) 1910 self:checkAchievement(Adv.AchievType.KillBossWithMWeapon, 1)
1911 self:checkAchievement(Adv.AchievType.KillBossWithAMWeapon, 1) 1911 self:checkAchievement(Adv.AchievType.KillBossWithAMWeapon, 1)
1912 elseif monsterData.type == 3 then 1912 elseif monsterData.type == 3 then
src/adv/AdvBattle.lua
@@ -332,6 +332,15 @@ function Battle:afterRound() @@ -332,6 +332,15 @@ function Battle:afterRound()
332 for i = #self.builds[mapIdx], 1, -1 do 332 for i = #self.builds[mapIdx], 1, -1 do
333 if self.builds[mapIdx][i].isDead then 333 if self.builds[mapIdx][i].isDead then
334 local build = table.remove(self.builds[mapIdx], i) 334 local build = table.remove(self.builds[mapIdx], i)
  335 +
  336 + local room = self.adv:getCurMap().rooms[build.roomId]
  337 + if room then
  338 + local block = room.blocks[build.blockId]
  339 + if block then
  340 + block:clear()
  341 + self.adv:backBlockChange(build.roomId, build.blockId)
  342 + end
  343 + end
335 build:clear() 344 build:clear()
336 end 345 end
337 end 346 end
src/adv/AdvMap.lua
@@ -256,7 +256,7 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack) @@ -256,7 +256,7 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack)
256 256
257 if status then 257 if status then
258 if isPlayer then 258 if isPlayer then
259 - self.adv.battle.player:triggerPassive(Passive.OPEN_BLOCK) 259 + self.adv.battle:triggerPassive(Passive.OPEN_BLOCK)
260 self.adv.owner:checkTaskEnter("AdvOpenBlock") 260 self.adv.owner:checkTaskEnter("AdvOpenBlock")
261 261
262 -- 潜行检查 262 -- 潜行检查
src/adv/AdvTask.lua
@@ -183,12 +183,12 @@ function AdvTask.bind(Adv) @@ -183,12 +183,12 @@ function AdvTask.bind(Adv)
183 183
184 -- 完成主线任务 184 -- 完成主线任务
185 function Adv:finishMTask() 185 function Adv:finishMTask()
186 - local ok, reward 186 + local ok, reward, change
187 if self.advMTask.status == -1 then --已完成带领取 187 if self.advMTask.status == -1 then --已完成带领取
188 local mainTaskData = csvdb["adv_questCsv"][self.advMTask.id] 188 local mainTaskData = csvdb["adv_questCsv"][self.advMTask.id]
189 if not mainTaskData then return end 189 if not mainTaskData then return end
190 if mainTaskData.reward == 1 then 190 if mainTaskData.reward == 1 then
191 - reward = self.owner:award(mainTaskData.rewardValue, {log = {desc = "advMainTask", int1 = self.advMTask.id}}) 191 + reward, change = self.owner:award(mainTaskData.rewardValue, {log = {desc = "advMainTask", int1 = self.advMTask.id}})
192 end 192 end
193 self.advMTask.id = self.advMTask.id + 1 193 self.advMTask.id = self.advMTask.id + 1
194 self.advMTask.status = 0 194 self.advMTask.status = 0
@@ -204,7 +204,7 @@ function AdvTask.bind(Adv) @@ -204,7 +204,7 @@ function AdvTask.bind(Adv)
204 ok = true 204 ok = true
205 advTaskChange.m = true 205 advTaskChange.m = true
206 end 206 end
207 - return ok, reward 207 + return ok, reward, change
208 end 208 end
209 209
210 function Adv:updateTask(notNotify) 210 function Adv:updateTask(notNotify)
@@ -388,7 +388,7 @@ function AdvTask.bind(Adv) @@ -388,7 +388,7 @@ function AdvTask.bind(Adv)
388 local achievData = (csvdb["adv_achievementCsv"][chapterId] or {})[taskId] 388 local achievData = (csvdb["adv_achievementCsv"][chapterId] or {})[taskId]
389 local status = (self.owner:getProperty(achievField)[chapterId] or {})[taskId] or -1 389 local status = (self.owner:getProperty(achievField)[chapterId] or {})[taskId] or -1
390 390
391 - local reward = {} 391 + local reward, change = {}
392 if status >= achievData.value1 then 392 if status >= achievData.value1 then
393 insertChange(self, chapterId, taskId, -1) 393 insertChange(self, chapterId, taskId, -1)
394 local count = (self.owner:getProperty(achievField)[chapterId] or {})[-1] or 0 394 local count = (self.owner:getProperty(achievField)[chapterId] or {})[-1] or 0
@@ -396,8 +396,8 @@ function AdvTask.bind(Adv) @@ -396,8 +396,8 @@ function AdvTask.bind(Adv)
396 insertChange(self, chapterId, -1, count) 396 insertChange(self, chapterId, -1, count)
397 397
398 -- 发放奖励 398 -- 发放奖励
399 - reward = self.owner:award(achievData.reward, {log = {desc = "advAchiev", int1 = chapterId, int2 = taskId}})  
400 - return true, reward 399 + reward, change = self.owner:award(achievData.reward, {log = {desc = "advAchiev", int1 = chapterId, int2 = taskId}})
  400 + return true, reward, change
401 end 401 end
402 end 402 end
403 403
@@ -408,9 +408,9 @@ function AdvTask.bind(Adv) @@ -408,9 +408,9 @@ function AdvTask.bind(Adv)
408 local status = ((self.owner:getProperty(achievField)[chapterId] or {})["pts"] or {})[taskId] or 0 408 local status = ((self.owner:getProperty(achievField)[chapterId] or {})["pts"] or {})[taskId] or 0
409 if status == -1 or count < achievData.pt then return end 409 if status == -1 or count < achievData.pt then return end
410 410
411 - local reward = self.owner:award(achievData.reward, {log = {desc = "advAchievReward", int1 = chapterId, int2 = taskId}}) 411 + local reward, change = self.owner:award(achievData.reward, {log = {desc = "advAchievReward", int1 = chapterId, int2 = taskId}})
412 insertChange(self, chapterId, taskId, -1, true) 412 insertChange(self, chapterId, taskId, -1, true)
413 - return true, reward 413 + return true, reward, change
414 end 414 end
415 415
416 function Adv:updateAchievement(notNotify) 416 function Adv:updateAchievement(notNotify)
1 -Subproject commit bc23b59073a7200db7f84316fa049019f5495796 1 +Subproject commit f52151f947b019976eac7ef15ec914bf7d552d64
src/models/Activity.lua
@@ -3,6 +3,11 @@ local string_format = string.format @@ -3,6 +3,11 @@ local string_format = string.format
3 3
4 Activity.ActivityType = { 4 Activity.ActivityType = {
5 Sign = 1, -- 签到 5 Sign = 1, -- 签到
  6 + DoubleDrop = 2, -- 双倍掉落
  7 + DrawHero = 3, --抽卡周
  8 + FoodSell = 4, --贩卖周
  9 + OpenBox = 5, --拆解周
  10 + AdvDraw = 6, --拾荒抽周
6 } 11 }
7 12
8 13
@@ -23,13 +28,23 @@ end @@ -23,13 +28,23 @@ end
23 28
24 Activity.schema = { 29 Activity.schema = {
25 actime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time} 30 actime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time}
  31 + round = {"table", {}}, -- 记录活动到了第几轮 {id = roundnum}
26 act1 = {"table", {}}, -- {0 = day, 1= -1, 2 = -1} == 签到活动 32 act1 = {"table", {}}, -- {0 = day, 1= -1, 2 = -1} == 签到活动
  33 + act3 = {"table", {}}, -- {0 = 抽卡次数, 1=1, 2=1} 抽卡周活动 1表示领取过该档位的奖励
  34 + act4 = {"table", {}}, -- {0 = 贩卖数量, 1=1, 2=1} 贩卖周活动 1表示领取过该档位的奖励
  35 + act5 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励
  36 + act6 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励
27 } 37 }
28 38
29 function Activity:data() 39 function Activity:data()
30 return { 40 return {
31 actime = self:getProperty("actime"), 41 actime = self:getProperty("actime"),
  42 + round = self:getProperty("round"),
32 act1 = self:getProperty("act1"), 43 act1 = self:getProperty("act1"),
  44 + act3 = self:getProperty("act3"),
  45 + act4 = self:getProperty("act4"),
  46 + act5 = self:getProperty("act5"),
  47 + act6 = self:getProperty("act6"),
33 } 48 }
34 end 49 end
35 50
@@ -162,6 +177,133 @@ activityFunc[Activity.ActivityType.Sign] = { @@ -162,6 +177,133 @@ activityFunc[Activity.ActivityType.Sign] = {
162 end, 177 end,
163 } 178 }
164 179
  180 +--loop1:累计料理贩卖N次
  181 +--loop2:累计招募N次
  182 +--loop3:累计资助N次
  183 +--loop4:时钟箱拆解N个
  184 +function Activity:checkWeeklyAct(actType, notify, count)
  185 + local actInfoMap = {
  186 + [Activity.ActivityType.DrawHero] = {mailId = MailId.ActDrawCardReward, table = "activity_loop2Csv"},
  187 + [Activity.ActivityType.AdvDraw] = {mailId = MailId.ActAdvDrawReward, table = "activity_loop3Csv"},
  188 + [Activity.ActivityType.OpenBox] = {mailId = MailId.ActOpenBoxReward, table = "activity_loop4Csv"},
  189 + [Activity.ActivityType.FoodSell] = {mailId = MailId.ActSellFoodReward, table = "activity_loop1Csv"}
  190 + }
  191 + local info = actInfoMap[actType]
  192 + if not info then return end
  193 +
  194 + local curData = self:getActData(actType)
  195 + local roundData = self:getProperty("round")
  196 + local curRound = roundData[actType] or 0
  197 + local ctrlData = csvdb["activity_ctrlCsv"][actType]
  198 + if not ctrlData then return end
  199 + if curRound >= ctrlData.condition then
  200 + return
  201 + end
  202 + curData[0] = (curData[0] or 0) + count
  203 + local totalCnt = 0
  204 + local finishCnt = 0
  205 + local maxCondition = 0
  206 + for k, cfg in pairs(csvdb[info.table] or {}) do
  207 + totalCnt = totalCnt + 1
  208 + if maxCondition < cfg.condition1 then
  209 + maxCondition = cfg.condition1
  210 + end
  211 + if not curData[cfg.id] and curData[0] >= cfg.condition1 then
  212 + if info.mailId then
  213 + self.owner:sendMail(info.mailId, nil, cfg.reward, {cfg.condition1})
  214 + curData[cfg.id] = 1
  215 + end
  216 + end
  217 + if curData[cfg.id] then
  218 + finishCnt = finishCnt + 1
  219 + end
  220 + end
  221 + if totalCnt == finishCnt then
  222 + roundData[actType] = curRound + 1
  223 + for k,v in pairs(curData) do
  224 + if k == 0 then
  225 + curData[k] = curData[0] >= maxCondition and curData[0] - maxCondition or 0
  226 + else
  227 + curData[k] = nil
  228 + end
  229 + end
  230 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  231 + end
  232 + self:updateActData(actType, curData, not notify)
  233 +end
  234 +
  235 +-- 抽卡周
  236 +activityFunc[Activity.ActivityType.DrawHero] = {
  237 + ["check"] = function(self, actType, notify, count) -- 检查
  238 + self:checkWeeklyAct(actType, notify, count)
  239 + end,
  240 + ["init"] = function(self, actType, isCrossDay, notify)
  241 + local roundData = self:getProperty("round")
  242 + roundData[actType] = 0
  243 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  244 + end,
  245 + -- ["close"] = function(self, actType, notify)
  246 + -- end,
  247 + ["crossDay"] = function(self, actType, notify)
  248 + print("cross day draw card")
  249 + self.owner:sendMail(MailId.ActDrawCard)
  250 + end,
  251 +}
  252 +
  253 +-- 售卖周
  254 +activityFunc[Activity.ActivityType.FoodSell] = {
  255 + ["check"] = function(self, actType, notify, count) -- 检查
  256 + self:checkWeeklyAct(actType, notify, count)
  257 + end,
  258 + ["init"] = function(self, actType, isCrossDay, notify)
  259 + local roundData = self:getProperty("round")
  260 + roundData[actType] = 0
  261 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  262 + end,
  263 + -- ["close"] = function(self, actType, notify)
  264 + -- end,
  265 + ["crossDay"] = function(self, actType, notify)
  266 + print("cross day sell food")
  267 + self.owner:sendMail(MailId.ActSellFood)
  268 + end,
  269 +}
  270 +
  271 +-- 拾荒周
  272 +activityFunc[Activity.ActivityType.AdvDraw] = {
  273 + ["check"] = function(self, actType, notify, count) -- 检查
  274 + self:checkWeeklyAct(actType, notify, count)
  275 + end,
  276 + ["init"] = function(self, actType, isCrossDay, notify)
  277 + local roundData = self:getProperty("round")
  278 + roundData[actType] = 0
  279 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  280 + end,
  281 + -- ["close"] = function(self, actType, notify)
  282 + -- end,
  283 + ["crossDay"] = function(self, actType, notify)
  284 + print("cross day act adv cost")
  285 + self.owner:sendMail(MailId.ActAdvDraw)
  286 + end,
  287 +}
  288 +
  289 +-- 拆解周
  290 +activityFunc[Activity.ActivityType.OpenBox] = {
  291 + ["check"] = function(self, actType, notify, count) -- 检查
  292 + self:checkWeeklyAct(actType, notify, count)
  293 + end,
  294 + ["init"] = function(self, actType, isCrossDay, notify)
  295 + local roundData = self:getProperty("round")
  296 + roundData[actType] = 0
  297 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  298 + end,
  299 + -- ["close"] = function(self, actType, notify)
  300 + -- end,
  301 + ["crossDay"] = function(self, actType, notify)
  302 + print("cross day open box")
  303 + self.owner:sendMail(MailId.ActOpenBox)
  304 + end,
  305 +}
  306 +
165 function Activity:initActivity(actType, isCrossDay, notify) 307 function Activity:initActivity(actType, isCrossDay, notify)
166 if activityFunc[actType] and activityFunc[actType]['close'] then 308 if activityFunc[actType] and activityFunc[actType]['close'] then
167 activityFunc[actType]["init"](self, actType, isCrossDay, notify) 309 activityFunc[actType]["init"](self, actType, isCrossDay, notify)
@@ -172,7 +314,9 @@ function Activity:closeActivity(actType, notify, notUpdateAct) @@ -172,7 +314,9 @@ function Activity:closeActivity(actType, notify, notUpdateAct)
172 if activityFunc[actType] and activityFunc[actType]['close'] then 314 if activityFunc[actType] and activityFunc[actType]['close'] then
173 activityFunc[actType]["close"](self, actType, notify) 315 activityFunc[actType]["close"](self, actType, notify)
174 end 316 end
175 - self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct) 317 + if Activity.schema["act".. actType] then
  318 + self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct)
  319 + end
176 end 320 end
177 321
178 function Activity:refreshDailyData(notify) 322 function Activity:refreshDailyData(notify)
@@ -193,5 +337,23 @@ function Activity:checkActivity(notNotify, activityType, ...) @@ -193,5 +337,23 @@ function Activity:checkActivity(notNotify, activityType, ...)
193 end 337 end
194 end 338 end
195 339
  340 +-- 获取此次挂机掉落翻倍时长
  341 +function Activity:getActHangDoubleTime(lastTs, nowTs)
  342 + local type = "DoubleDrop"
  343 + local actId = checkActivityType(type)
  344 + local isOpen = self:isOpen(type)
  345 + local openTs = self:getProperty("actime")[actId] or 0
  346 + local timeNow = skynet.timex()
  347 + lastTs = math.max(lastTs, openTs)
  348 + if isOpen then
  349 + if nowTs > openTs then
  350 + return nowTs - lastTs
  351 + else
  352 + return 0
  353 + end
  354 + end
  355 + return 0
  356 +end
  357 +
196 358
197 -return Activity  
198 \ No newline at end of file 359 \ No newline at end of file
  360 +return Activity
src/models/Daily.lua
@@ -25,6 +25,9 @@ Daily.schema = { @@ -25,6 +25,9 @@ Daily.schema = {
25 25
26 advSupRe = {"number", 0}, -- 冒险支援效果刷新次数 26 advSupRe = {"number", 0}, -- 冒险支援效果刷新次数
27 goldBuyT = {"number", 0}, -- 金币购买次数 27 goldBuyT = {"number", 0}, -- 金币购买次数
  28 +
  29 + unlockPool = {"table", {}}, -- 解锁的属性卡池
  30 + curPool = {"number", 0}, -- 属性卡池当前索引
28 } 31 }
29 32
30 function Daily:updateProperty(params) 33 function Daily:updateProperty(params)
@@ -63,8 +66,8 @@ function Daily:refreshDailyData(notify) @@ -63,8 +66,8 @@ function Daily:refreshDailyData(notify)
63 -- 每日折扣搞一下 66 -- 每日折扣搞一下
64 local dailySDD = {} 67 local dailySDD = {}
65 local sddPool = {} 68 local sddPool = {}
66 - for id, data in pairs(csvdb["shop_diamondCsv"]) do  
67 - if data.disount ~= 0 then 69 + for id, data in pairs(csvdb["shop_normalCsv"]) do
  70 + if data.shop == 1 and data.disount ~= 0 then
68 table.insert(sddPool, id) 71 table.insert(sddPool, id)
69 end 72 end
70 end 73 end
@@ -97,6 +100,8 @@ function Daily:data() @@ -97,6 +100,8 @@ function Daily:data()
97 dailySDD = self:getProperty("dailySDD"), 100 dailySDD = self:getProperty("dailySDD"),
98 advSupRe = self:getProperty("advSupRe"), 101 advSupRe = self:getProperty("advSupRe"),
99 goldBuyT = self:getProperty("goldBuyT"), 102 goldBuyT = self:getProperty("goldBuyT"),
  103 + unlockPool = self:getProperty("unlockPool"),
  104 + curPool = self:getProperty("curPool"),
100 } 105 }
101 end 106 end
102 107
src/models/Role.lua
@@ -20,12 +20,14 @@ function Role:ctor( properties ) @@ -20,12 +20,14 @@ function Role:ctor( properties )
20 Role.super.ctor(self, properties) 20 Role.super.ctor(self, properties)
21 self.ignoreHeartbeat = false 21 self.ignoreHeartbeat = false
22 self.dailyData = nil 22 self.dailyData = nil
  23 + self.storeData = nil
23 self.heros = {} 24 self.heros = {}
24 self.runeBag = {} 25 self.runeBag = {}
25 self.advData = nil 26 self.advData = nil
26 self.activity = nil 27 self.activity = nil
27 self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节 28 self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节
28 self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳 29 self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳
  30 + self.sendMailFlag = false --发送邮件标识
29 end 31 end
30 32
31 Role.schema = { 33 Role.schema = {
@@ -140,12 +142,13 @@ Role.schema = { @@ -140,12 +142,13 @@ Role.schema = {
140 142
141 rechargeF = {"table", {}}, -- 是否首次充值某一项 -- —{[id] = 1} -- 不存在就是没有充值过 143 rechargeF = {"table", {}}, -- 是否首次充值某一项 -- —{[id] = 1} -- 不存在就是没有充值过
142 dinerS = {"table", {}}, -- 美食币商城 购买记录 {[id] = count} 144 dinerS = {"table", {}}, -- 美食币商城 购买记录 {[id] = count}
  145 + battlePoint = {"number", 0}, -- 赛季卡使用的活跃点
143 146
144 rmbC = {"number", 0}, -- 人民币重置额 147 rmbC = {"number", 0}, -- 人民币重置额
145 148
146 emailSync = {"number", 0}, -- 已经同步到的邮件Id 149 emailSync = {"number", 0}, -- 已经同步到的邮件Id
147 150
148 - -- repayHero = {"number", 0}, -- 超级招募 回馈 151 + repayHero = {"number", 0}, -- 招募次数 (除去友情招募)
149 floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} 152 floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count}
150 ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} 153 ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count}
151 newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr 154 newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr
@@ -360,9 +363,10 @@ function Role:data() @@ -360,9 +363,10 @@ function Role:data()
360 363
361 rechargeF = self:getProperty("rechargeF"), 364 rechargeF = self:getProperty("rechargeF"),
362 dinerS = self:getProperty("dinerS"), 365 dinerS = self:getProperty("dinerS"),
  366 + battlePoint = self:getProperty("battlePoint"),
363 367
364 rmbC = self:getProperty("rmbC"), 368 rmbC = self:getProperty("rmbC"),
365 - -- repayHero = self:getProperty("repayHero"), 369 + repayHero = self:getProperty("repayHero"),
366 newerDraw = self:getProperty("newerDraw"), 370 newerDraw = self:getProperty("newerDraw"),
367 floorHero = self:getProperty("floorHero"), 371 floorHero = self:getProperty("floorHero"),
368 372
src/models/RolePlugin.lua
@@ -11,6 +11,7 @@ function RolePlugin.bind(Role) @@ -11,6 +11,7 @@ function RolePlugin.bind(Role)
11 self:loadHeros() 11 self:loadHeros()
12 self:loadDiner() 12 self:loadDiner()
13 self:loadActivity() 13 self:loadActivity()
  14 + self:loadStoreInfo()
14 end 15 end
15 16
16 function Role:reloadWhenLogin() 17 function Role:reloadWhenLogin()
@@ -67,9 +68,16 @@ function RolePlugin.bind(Role) @@ -67,9 +68,16 @@ function RolePlugin.bind(Role)
67 local itemTypeAward = { 68 local itemTypeAward = {
68 [ItemType.Hero] = function() 69 [ItemType.Hero] = function()
69 pms.type = itemId - ItemStartId.Hero 70 pms.type = itemId - ItemStartId.Hero
70 - for _= 1, count do  
71 - self:addHero(pms) 71 + local status = self:addHero(pms)
  72 + local gcount = 1
  73 + if not status then
  74 + gcount = 0
  75 + end
  76 + if count - gcount > 0 then
  77 + local heroData = csvdb["unitCsv"][pms.type]
  78 + change[pms.type] = (change[pms.type] or 0) + (count - gcount) * globalCsv.draw_unit_tofragment[heroData.rare]
72 end 79 end
  80 + count = gcount
73 end, 81 end,
74 [ItemType.EquipBase] = function() 82 [ItemType.EquipBase] = function()
75 local typ = math.floor((itemId-7000)/100) 83 local typ = math.floor((itemId-7000)/100)
@@ -105,7 +113,7 @@ function RolePlugin.bind(Role) @@ -105,7 +113,7 @@ function RolePlugin.bind(Role)
105 end 113 end
106 end 114 end
107 115
108 - return count, change -- count 刷新实际发放的奖励个数 change 物品实际奖励与当前id 不符 就发生转换 而不实际发奖 116 + return count, change -- count 实际发放的奖励个数 change 物品实际奖励与当前id 不符 就发生转换 而不实际发奖
109 end 117 end
110 118
111 119
@@ -122,24 +130,31 @@ function RolePlugin.bind(Role) @@ -122,24 +130,31 @@ function RolePlugin.bind(Role)
122 end 130 end
123 local reward, allChange = {}, {} 131 local reward, allChange = {}, {}
124 132
125 - for itemId, count in pairs(tgift) do  
126 - local count, change = _award(self, itemId, count, params) 133 + for itemId, rcount in pairs(tgift) do
  134 + local count, change = _award(self, itemId, rcount, params)
  135 + if count > 0 then
  136 + reward[itemId] = (reward[itemId] or 0) + count
  137 + end
127 if next(change) then 138 if next(change) then
128 - local cr, cc = self:award(change, params) -- 内部转换忽略  
129 - for _id, _ct in pairs(cr) do  
130 - reward[_id] = (reward[_id] or 0) + _ct  
131 - end  
132 - table.insert(allChange, {form = {[itemId] = count}, to = cr})  
133 - else  
134 - if count > 0 then  
135 - reward[itemId] = (reward[itemId] or 0) + count 139 + local cr, _ = self:award(change, params) -- 内部转换忽略 防止死循环
  140 + if next(cr) then
  141 + for _id, _ct in pairs(cr) do
  142 + reward[_id] = (reward[_id] or 0) + _ct
  143 + end
  144 + table.insert(allChange, {form = {[itemId] = rcount - count}, to = cr})
136 end 145 end
137 end 146 end
138 end 147 end
139 - 148 + if not next(allChange) then allChange = nil end
140 return reward, allChange --实际获得的奖励 和 最高级奖励转化过程 149 return reward, allChange --实际获得的奖励 和 最高级奖励转化过程
141 end 150 end
142 151
  152 +
  153 + function Role:packReward(reward, change)
  154 + if not reward then return nil end
  155 + return {reward = reward, change = change}
  156 + end
  157 +
143 function Role:awardExpireItem(expireTime, gift, params) 158 function Role:awardExpireItem(expireTime, gift, params)
144 if expireTime <= skynet.timex() then 159 if expireTime <= skynet.timex() then
145 return 160 return
@@ -529,6 +544,18 @@ function RolePlugin.bind(Role) @@ -529,6 +544,18 @@ function RolePlugin.bind(Role)
529 -- 放role 里面了 544 -- 放role 里面了
530 end 545 end
531 546
  547 + function Role:loadStoreInfo()
  548 + local roleId = self:getProperty("id")
  549 + local dataKey = string.format(R_STORE, roleId)
  550 + self.storeData = require("models.Store").new({key = dataKey})
  551 + self.storeData.owner = self
  552 + if not redisproxy:exists(dataKey) then
  553 + self.storeData:create()
  554 + else
  555 + self.storeData:load()
  556 + end
  557 + end
  558 +
532 function Role:addEquip(equipType, equipLv, count, pms) 559 function Role:addEquip(equipType, equipLv, count, pms)
533 pms = pms or {} 560 pms = pms or {}
534 if count ~= count then return end 561 if count ~= count then return end
@@ -863,10 +890,9 @@ function RolePlugin.bind(Role) @@ -863,10 +890,9 @@ function RolePlugin.bind(Role)
863 if count > 0 then 890 if count > 0 then
864 count = math.max(count - add, 0) 891 count = math.max(count - add, 0)
865 end 892 end
866 -  
867 self:updateProperties({ 893 self:updateProperties({
868 advC = count + change, 894 advC = count + change,
869 - advCT = ctime, 895 + advCT = nextTime,
870 }) 896 })
871 end 897 end
872 898
@@ -1317,9 +1343,13 @@ function RolePlugin.bind(Role) @@ -1317,9 +1343,13 @@ function RolePlugin.bind(Role)
1317 self:checkNewEvent(now) 1343 self:checkNewEvent(now)
1318 end 1344 end
1319 1345
1320 - local function breath(sec) 1346 + local function breath(sec, name)
1321 local last_breath = 0 1347 local last_breath = 0
1322 - return function (now) 1348 + return function (now, role)
  1349 + if name == "email" and role.sendMailFlag then
  1350 + last_breath = now + sec
  1351 + return true
  1352 + end
1323 if now >= last_breath then 1353 if now >= last_breath then
1324 last_breath = now + sec 1354 last_breath = now + sec
1325 return true 1355 return true
@@ -1328,8 +1358,8 @@ function RolePlugin.bind(Role) @@ -1328,8 +1358,8 @@ function RolePlugin.bind(Role)
1328 end 1358 end
1329 end 1359 end
1330 local breathes = { 1360 local breathes = {
1331 - ["email"] = breath(120), -- email  
1332 - ["pvphg"] = breath(300), -- 高级竞技场 奖励满的红点 1361 + ["email"] = breath(120, "email"), -- email
  1362 + ["pvphg"] = breath(300, "pvphg"), -- 高级竞技场 奖励满的红点
1333 } 1363 }
1334 function Role:checkNewEvent(now) 1364 function Role:checkNewEvent(now)
1335 if now - self:getProperty("ltime") < 5 then 1365 if now - self:getProperty("ltime") < 5 then
@@ -1370,6 +1400,8 @@ function RolePlugin.bind(Role) @@ -1370,6 +1400,8 @@ function RolePlugin.bind(Role)
1370 red:hget(string.format(R_EMAIL_ITEM, roleId, id), "status") 1400 red:hget(string.format(R_EMAIL_ITEM, roleId, id), "status")
1371 end 1401 end
1372 end) 1402 end)
  1403 +
  1404 + self.SendMailFlag = false
1373 for index, id in ipairs(emailIds) do 1405 for index, id in ipairs(emailIds) do
1374 if tonumber(redret[index]) == 0 then 1406 if tonumber(redret[index]) == 0 then
1375 return true 1407 return true
@@ -1394,7 +1426,7 @@ function RolePlugin.bind(Role) @@ -1394,7 +1426,7 @@ function RolePlugin.bind(Role)
1394 1426
1395 local events = {} 1427 local events = {}
1396 for name, breath in pairs(breathes) do 1428 for name, breath in pairs(breathes) do
1397 - if breath(now) and checks[name] then 1429 + if breath(now, self) and checks[name] then
1398 local status = checks[name]() 1430 local status = checks[name]()
1399 if status then 1431 if status then
1400 if status == true then 1432 if status == true then
@@ -1487,7 +1519,7 @@ function RolePlugin.bind(Role) @@ -1487,7 +1519,7 @@ function RolePlugin.bind(Role)
1487 return 1519 return
1488 end 1520 end
1489 1521
1490 - local diamond = self:recharge({ 1522 + local reward = self:recharge({
1491 id = orderObject:getProperty("rechargeId"), 1523 id = orderObject:getProperty("rechargeId"),
1492 transactionId = params.transactionId, 1524 transactionId = params.transactionId,
1493 pay_time = params.pay_time, 1525 pay_time = params.pay_time,
@@ -1498,7 +1530,7 @@ function RolePlugin.bind(Role) @@ -1498,7 +1530,7 @@ function RolePlugin.bind(Role)
1498 1530
1499 redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr) 1531 redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr)
1500 SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr, 1532 SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr,
1501 - result = "success", diamond = diamond})) 1533 + result = "success", reward = reward}))
1502 1534
1503 return orderObject:getProperty("rechargeId") 1535 return orderObject:getProperty("rechargeId")
1504 end 1536 end
@@ -1512,8 +1544,13 @@ function RolePlugin.bind(Role) @@ -1512,8 +1544,13 @@ function RolePlugin.bind(Role)
1512 return 1544 return
1513 end 1545 end
1514 1546
  1547 + if not self.storeData:checkRechargeRecord(rechargeData.limit, id) then
  1548 + return 1
  1549 + end
  1550 +
1515 local diamondCount = 0 1551 local diamondCount = 0
1516 - if rechargeData.type == 0 then -- 钻石 1552 + local reward = {}
  1553 + if rechargeData.shop == 1 then -- 钻石
1517 local rechargeF = self:getProperty("rechargeF") 1554 local rechargeF = self:getProperty("rechargeF")
1518 diamondCount = rechargeData.diamond + rechargeData.diamondExtra 1555 diamondCount = rechargeData.diamond + rechargeData.diamondExtra
1519 if not rechargeF[id] then 1556 if not rechargeF[id] then
@@ -1522,21 +1559,45 @@ function RolePlugin.bind(Role) @@ -1522,21 +1559,45 @@ function RolePlugin.bind(Role)
1522 self:updateProperty({field = "rechargeF", value = rechargeF}) 1559 self:updateProperty({field = "rechargeF", value = rechargeF})
1523 end 1560 end
1524 self:gainDiamond({count = diamondCount, isRecharge = true, log = {desc = "recharge", int1 = id}}) 1561 self:gainDiamond({count = diamondCount, isRecharge = true, log = {desc = "recharge", int1 = id}})
1525 - elseif rechargeData.type == 1 then --月卡  
1526 - return  
1527 - elseif rechargeData.type == 2 then -- 赛季通行证  
1528 - return 1562 + elseif rechargeData.shop == 2 then --通行证商店
  1563 + reward, _ = self:award(rechargeData.itemFirst, {log = {desc = "recharge", int1 = id}})
  1564 + self.storeData:onBuyCard(rechargeData.type, rechargeData.time)
  1565 + elseif rechargeData.shop == 3 then -- 礼包商店
  1566 + reward, _ = self:award(rechargeData.itemFirst, {log = {desc = "recharge", int1 = id}})
1529 else 1567 else
  1568 + skynet.error("invalid recharge shop type " .. id)
1530 return 1569 return
1531 end 1570 end
1532 1571
  1572 + if diamondCount > 0 then
  1573 + reward[ItemId.Diamond] = (reward[ItemId.Diamond] or 0) + diamondCount
  1574 + end
  1575 +
1533 -- 累充 1576 -- 累充
1534 local rmb = rechargeData.rmb 1577 local rmb = rechargeData.rmb
1535 self:updateProperty({field = "rmbC", delta = rmb}) 1578 self:updateProperty({field = "rmbC", delta = rmb})
1536 1579
1537 self:log("role_action", {desc = "recharge", int1 = id, int2 = rmb, key1 = params.transactionId, key2 = params.order, long1 = params.pay_time}) 1580 self:log("role_action", {desc = "recharge", int1 = id, int2 = rmb, key1 = params.transactionId, key2 = params.order, long1 = params.pay_time})
1538 1581
1539 - return diamondCount 1582 + return reward
  1583 + end
  1584 +
  1585 + --直接给玩家发送邮件,立即推送小红点
  1586 + function Role:sendMail(mailId, createTime, reward, contentPms)
  1587 + local tgift = {}
  1588 + if type(reward) == "string" then
  1589 + for _, one in pairs(reward:toTableArray(true)) do
  1590 + tgift[one[1]] = (tgift[one[1]] or 0) + one[2]
  1591 + end
  1592 + else
  1593 + tgift = reward or {}
  1594 + end
  1595 + local gift = ""
  1596 + for k, v in pairs(tgift) do
  1597 + gift = gift .. k.."="..v.." "
  1598 + end
  1599 + redisproxy:insertEmail({roleId = self:getProperty("id"), emailId = mailId, createtime = createTime, attachments = gift, contentPms = contentPms})
  1600 + self.sendMailFlag = true
1540 end 1601 end
1541 1602
1542 end 1603 end
src/models/RoleTask.lua
@@ -205,10 +205,14 @@ local SudokuListener = { @@ -205,10 +205,14 @@ local SudokuListener = {
205 } 205 }
206 } 206 }
207 207
  208 +local Activity = require("models.Activity")
208 local ActivityListener = { 209 local ActivityListener = {
209 func = "checkActivityTask", 210 func = "checkActivityTask",
210 - listener = {  
211 - 211 + listen = {
  212 + [TaskType.DrawHero] = {{Activity.ActivityType.DrawHero, f("count")}},
  213 + [TaskType.FoodSell] = {{Activity.ActivityType.FoodSell, f("count")}},
  214 + [TaskType.AdvDraw] = {{Activity.ActivityType.AdvDraw, f("count")}},
  215 + [TaskType.OpenBox] = {{Activity.ActivityType.OpenBox, f("count")}},
212 } 216 }
213 } 217 }
214 218
src/models/RoleTimeReset.lua
@@ -10,6 +10,7 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response, now) @@ -10,6 +10,7 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response, now)
10 self.dailyData:refreshDailyData(notify) 10 self.dailyData:refreshDailyData(notify)
11 self.dinerData:refreshDailyData(notify) 11 self.dinerData:refreshDailyData(notify)
12 self.activity:refreshDailyData(notify) 12 self.activity:refreshDailyData(notify)
  13 + self.storeData:onCrossDay()
13 14
14 self:setProperty("dTask", {}) 15 self:setProperty("dTask", {})
15 self:advRandomSupportEffect(not notify) 16 self:advRandomSupportEffect(not notify)
@@ -29,6 +30,14 @@ ResetFunc[&quot;CrossWeek&quot;] = function(self, notify, response) @@ -29,6 +30,14 @@ ResetFunc[&quot;CrossWeek&quot;] = function(self, notify, response)
29 response.dinerS = {} 30 response.dinerS = {}
30 end 31 end
31 32
  33 +ResetFunc["CrossMonth"] = function(self, notify, response)
  34 + local ltime = self:getProperty("ltime")
  35 + if isCrossMonth(ltime, skynet.timex()) then
  36 + print("cross month")
  37 + self.storeData:resetStoreReored(3) --商店跨月重置 time_reset表关联id
  38 + end
  39 +end
  40 +
32 41
33 ResetFunc["DinerRank"] = function(self, notify, response) 42 ResetFunc["DinerRank"] = function(self, notify, response)
34 self.dinerData:rankResetData(notify) 43 self.dinerData:rankResetData(notify)
@@ -51,9 +60,11 @@ function Role:updateTimeReset(now, notify) @@ -51,9 +60,11 @@ function Role:updateTimeReset(now, notify)
51 60
52 local needResetId = {} 61 local needResetId = {}
53 for resetId, resetData in pairs(csvdb["time_resetCsv"]) do 62 for resetId, resetData in pairs(csvdb["time_resetCsv"]) do
54 - local curRound = math.floor((passTime - resetData.start) / resetData.interval)  
55 - if not timeReset[resetId] or curRound ~= timeReset[resetId] then  
56 - needResetId[resetId] = curRound 63 + if resetData.interval > 0 then
  64 + local curRound = math.floor((passTime - resetData.start) / resetData.interval)
  65 + if not timeReset[resetId] or curRound ~= timeReset[resetId] then
  66 + needResetId[resetId] = curRound
  67 + end
57 end 68 end
58 end 69 end
59 if not next(needResetId) then return end 70 if not next(needResetId) then return end
@@ -66,13 +77,19 @@ function Role:updateTimeReset(now, notify) @@ -66,13 +77,19 @@ function Role:updateTimeReset(now, notify)
66 ResetFunc[funcName](self, notify, response, now) 77 ResetFunc[funcName](self, notify, response, now)
67 resetMode[funcName] = true 78 resetMode[funcName] = true
68 end 79 end
  80 + if needResetId[resetId] then
  81 + -- 充值商城购买记录
  82 + self.storeData:resetStoreReored(resetId)
  83 + end
69 end 84 end
70 85
71 for resetId, round in pairs(needResetId) do 86 for resetId, round in pairs(needResetId) do
72 timeReset[resetId] = round 87 timeReset[resetId] = round
73 end 88 end
74 - self:setProperty("timeReset", timeReset) 89 + self:setProperties({timeReset = timeReset, ltime = now})
  90 +
75 response.timeReset = timeReset 91 response.timeReset = timeReset
  92 + response.ltime = ltime
76 93
77 if notify then 94 if notify then
78 self:notifyUpdateProperties(response) 95 self:notifyUpdateProperties(response)
src/models/Store.lua 0 → 100644
@@ -0,0 +1,285 @@ @@ -0,0 +1,285 @@
  1 +-- 商店数据
  2 +
  3 +local Store = class("Store", require("shared.ModelBase"))
  4 +
  5 +function Store:ctor(properties)
  6 + Store.super.ctor(self, properties)
  7 +end
  8 +
  9 +Store.schema = {
  10 + buyR = {"table", {}}, -- 购买商品记录 {id=count}
  11 + payR = {"table", {}}, -- 充值记录 {id=count}
  12 + growFund = {"number", 0}, -- 成长基金
  13 + growFundR = {"string", ""}, -- 成长基金领取记录
  14 + monthCardEx = {"number", 0}, -- 月卡过期时间戳
  15 + smonthCardEx = {"number", 0}, -- 超级月卡过期时间戳
  16 + battleCard = {"number", 0}, -- 赛季卡
  17 + battleFR = {"string", ""}, -- 免费赛季卡领取记录
  18 + battleLR = {"string", ""}, -- 付费赛季卡领取记录
  19 + limitTPack = {"table", {}}, -- 限时礼包 {id=expire_ts}
  20 + privCardEx = {"number", 0}, -- 特权卡过期时间戳
  21 + getMailT1 = {"number",0}, -- 上次发送月卡福利邮件的时间
  22 + getMailT2 = {"number",0}, -- 上次发送超级月卡福利邮件的时间
  23 +}
  24 +
  25 +function Store:updateProperty(params)
  26 + params = params or {}
  27 + if not self.schema[params.field] then
  28 + return
  29 + end
  30 + local oldValue = self:getProperty(params.field)
  31 + if params.value then
  32 + self:setProperty(params.field, params.value)
  33 + elseif params.delta then
  34 + self:incrProperty(params.field, params.delta)
  35 + else
  36 + return
  37 + end
  38 + local newValue = self:getProperty(params.field)
  39 + if not params.notNotify then
  40 + self:notifyUpdateProperty(params.field, newValue, oldValue)
  41 + end
  42 +end
  43 +
  44 +function Store:onCrossDay()
  45 + self:sendMonthCardEmail()
  46 + self:deleteExpireLimitGoods()
  47 +end
  48 +
  49 +-- 删除过期商品
  50 +function Store:deleteExpireLimitGoods()
  51 + local timeNow = skynet.timex()
  52 + local limitGoodsList = self:getProperty("limitTPack")
  53 + for k, v in pairs(limitGoodsList) do
  54 + if timeNow > v then
  55 + limitGoodsList[k] = nil
  56 + end
  57 + end
  58 +end
  59 +
  60 +-- 发送月卡邮件
  61 +function Store:sendMonthCardEmail()
  62 + local timeNow = skynet.timex()
  63 + local tabs = {{ex="monthCardEx", t="getMailT1", mail=MailId.MonthCard, alert=MailId.MonthCardEx},
  64 + {ex="smonthCardEx", t="getMailT2", mail=MailId.SuperMonthCard, alert=MailId.SuperMonthCardEx}}
  65 + for _, v in ipairs(tabs) do
  66 + local ex = self:getProperty(v.ex)
  67 + local ts = self:getProperty(v.t) or 0
  68 + local mailId = v.mail
  69 + local alertId = v.alert
  70 + local alertTs = dayLater(ex) - DAY_SEC
  71 + if ex > timeNow then
  72 + local cnt = 0
  73 + if ts == 0 then
  74 + cnt = 1
  75 + else
  76 + local diff = dayLater(timeNow) - dayLater(ts)
  77 + diff = diff < 0 and 0 or diff
  78 + diff = diff > 31 and 31 or diff
  79 + cnt = diff
  80 + end
  81 + for i = cnt - 1, 0, -1 do
  82 + local createTs = timeNow - i * DAY_SEC
  83 + self.owner:sendMail(mailId, createTs)
  84 + -- 过期头一天发提醒邮件
  85 + if dayLater(createTs) == alertTs then
  86 + self.owner:sendMail(alertId, createTs)
  87 + end
  88 + end
  89 + if cnt > 0 then
  90 + self:updateProperty({field=v.t, value=timeNow})
  91 + end
  92 + end
  93 + end
  94 +end
  95 +
  96 +function Store:isMonthCardExpire()
  97 + local timeNow = skynet.timex()
  98 + local ts = self:getProperty("monthCardEx")
  99 + return ts < timeNow
  100 +end
  101 +
  102 +function Store:isSuperMonthCardExpire()
  103 + local timeNow = skynet.timex()
  104 + local ts = self:getProperty("smonthCardEx")
  105 + return ts < timeNow
  106 +end
  107 +
  108 +function Store:isPrivCardExpire()
  109 + local timeNow = skynet.timex()
  110 + local ts = self:getProperty("privCardEx")
  111 + return ts < timeNow
  112 +end
  113 +
  114 +-- 挂机栏位 特权卡额外个数
  115 +function Store:getHangSlotExtraCount()
  116 + if self:isPrivCardExpire() then
  117 + return 0
  118 + end
  119 +
  120 + return globalCsv.shop_priv_card_hang_slot_cnt or 4
  121 +end
  122 +
  123 +-- 探索加速/餐厅加速 特权卡系数
  124 +function Store:getProduceItemSpeedCoef()
  125 + if self:isPrivCardExpire() then
  126 + return 1
  127 + end
  128 + local coef = (globalCsv.shop_priv_card_produce_coef or 25)/ 100
  129 + return 1 + coef
  130 +end
  131 +
  132 +-- 拆解室栏位 特权卡额外个数
  133 +function Store:getTimeBoxSlotExtraCount()
  134 + if self:isPrivCardExpire() then
  135 + return 0
  136 + end
  137 +
  138 + return globalCsv.shop_priv_time_box_slot_cnt or 3
  139 +end
  140 +
  141 +-- 齿轮兑换 特权卡系数
  142 +function Store:getGearExchangeCoef()
  143 + if self:isPrivCardExpire() then
  144 + return 1
  145 + end
  146 +
  147 + local coef = (globalCsv.shop_priv_exchange_gear_coef or 50)/ 100
  148 + return 1 + coef
  149 +end
  150 +
  151 +-- 购买通行证
  152 +function Store:onBuyCard(type, duration)
  153 + local timeNow = skynet.timex()
  154 + if type == CardType.NormalMonthCard then
  155 + if self:isMonthCardExpire() then
  156 + self:updateProperty({field = "monthCardEx", value = timeNow + duration})
  157 + else
  158 + self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration})
  159 + end
  160 + self:sendMonthCardEmail()
  161 + elseif type == CardType.SuperMonthCard then
  162 + if self:isSuperMonthCardExpire() then
  163 + self:updateProperty({field = "smonthCardEx", value = timeNow + duration})
  164 + else
  165 + self:updateProperty({field = "smonthCardEx", value = self:getProperty("smonthCardEx") + duration})
  166 + end
  167 + self:sendMonthCardEmail()
  168 + elseif type == CardType.PrivilegeCard then
  169 + if self:isPrivCardExpire() then
  170 + self:updateProperty({field = "privCardEx", value = timeNow + duration})
  171 + else
  172 + self:updateProperty({field = "privCardEx", value = self:getProperty("privCardEx") + duration})
  173 + end
  174 + elseif type == CardType.GrowFund then
  175 + self:updateProperty({field = "growFund", value = 1})
  176 + elseif type == CardType.BattleCard then
  177 + self:updateProperty({field = "battleCard", value = 1})
  178 + end
  179 +end
  180 +
  181 +--检测购买是否超过限制数量
  182 +function Store:checkRechargeRecord(limit, id)
  183 + local rechargeRecord = self:getProperty("payR")
  184 + if limit ~= 0 and limit <= (rechargeRecord[id] or 0) then
  185 + skynet.error(string.format("recharge id:%d count over limit, user id:%d", id, self.owner:getProperty("id")))
  186 + return false
  187 + end
  188 + rechargeRecord[id] = (rechargeRecord[id] or 0) + 1
  189 + self:updateProperty({field = "payR", value = rechargeRecord})
  190 + return true
  191 +end
  192 +
  193 +function Store:notifyUpdateProperty(field, newValue, oldValue)
  194 + local datas = {
  195 + key = field,
  196 + newValue = newValue,
  197 + oldValue = oldValue,
  198 + }
  199 + SendPacket(actionCodes.Store_updateproperty, MsgPack.pack(datas))
  200 +end
  201 +
  202 +-- 赛季卡重置 需要把未能领取的奖励通过邮件发送
  203 +function Store:onBattleCardReset()
  204 + local gift = {}
  205 + local function concatGift(data)
  206 + for key, v in pairs(data:toNumMap()) do
  207 + gift[key] = (gift[key] or 0) + v
  208 + end
  209 + end
  210 + local battleCardFlag = self:getProperty("battleCard")
  211 + local battleCardFreeRecord = self:getProperty("battleFR")
  212 + local battleCardLimitRecord = self:getProperty("battleLR")
  213 + local battlePoint = self.owner:getProperty("battlePoint")
  214 +
  215 + for id, config in pairs(csvdb["reward_battlepassCsv"]) do
  216 + if config then
  217 + local freeFlag = string.char(string.getbit(battleCardFreeRecord, id))
  218 + local limitFlag = string.char(string.getbit(battleCardLimitRecord, id))
  219 +
  220 + if battlePoint < config.point then
  221 + break
  222 + end
  223 + if freeFlag == "0" then
  224 + concatGift(config.giftFree)
  225 + end
  226 + if limitFlag == "0" and battleCardFlag == 1 then
  227 + concatGift(config.giftLimit)
  228 + end
  229 + end
  230 + end
  231 + self.owner:sendMail(MailId.BattleCardAward, nil, gift)
  232 + -- 计算剩余奖励
  233 + self:updateProperty({field = "battleCard", value=0})
  234 + self:updateProperty({field = "battleFR", value=""})
  235 + self:updateProperty({field = "battleLR", value=""})
  236 + self.owner:updateProperty({field = "battlePoint", value=0})
  237 +end
  238 +
  239 +-- 重置购买记录
  240 +function Store:resetStoreReored(resetId)
  241 + local payRecord = self:getProperty("payR") or {}
  242 + local buyRecord = self:getProperty("buyR") or {}
  243 + for k, v in pairs(payRecord) do
  244 + local config = csvdb["shop_rechargeCsv"][k]
  245 + if config then
  246 + if config.resetTime == resetId then
  247 + payRecord[k] = nil
  248 + --通行证商店
  249 + if config.shop == 2 then
  250 + if config.type == CardType.BattleCard then
  251 + self:onBattleCardReset()
  252 + end
  253 + end
  254 + end
  255 + end
  256 + end
  257 + self:updateProperty({field = "payR", value = payRecord})
  258 + for k, v in pairs(buyRecord) do
  259 + local config = csvdb["shop_normalCsv"][k]
  260 + if config then
  261 + if config.resetTime == resetId then
  262 + buyRecord[k] = nil
  263 + end
  264 + end
  265 + end
  266 + self:updateProperty({field = "buyR", value = buyRecord})
  267 +end
  268 +
  269 +function Store:data()
  270 + return {
  271 + buyR = self:getProperty("buyR"),
  272 + payR = self:getProperty("payR"),
  273 + growFund = self:getProperty("growFund"),
  274 + growFundR = self:getProperty("growFundR"),
  275 + monthCardEx = self:getProperty("monthCardEx"),
  276 + smonthCardEx = self:getProperty("smonthCardEx"),
  277 + battleCard = self:getProperty("battleCard"),
  278 + battleFR = self:getProperty("battleFR"),
  279 + battleLR = self:getProperty("battleLR"),
  280 + limitTPack = self:getProperty("limitTPack"),
  281 + privCardEx = self:getProperty("privCardEx"),
  282 + }
  283 +end
  284 +
  285 +return Store
0 \ No newline at end of file 286 \ No newline at end of file