Commit a0b339dbee70438021e8bfc9d62f8a2729abf308

Authored by zhouhaihai
2 parents b8a2c28b 5bd12066

Merge branch 'develop' into tr/cb

# Conflicts:
#	src/actions/HeroAction.lua
#	src/actions/StoreAction.lua
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
@@ -15,3 +15,5 @@ redis_host = "127.0.0.1" @@ -15,3 +15,5 @@ redis_host = "127.0.0.1"
15 redis_port = 6100 15 redis_port = 6100
16 redis_db = 1 16 redis_db = 1
17 redis_auth = nil 17 redis_auth = nil
  18 +
  19 +pay_url = ""
18 \ No newline at end of file 20 \ No newline at end of file
config/server1.lua
@@ -5,4 +5,6 @@ servId = 1 @@ -5,4 +5,6 @@ servId = 1
5 redis_host = "10.235.0.167" 5 redis_host = "10.235.0.167"
6 redis_port = 6379 6 redis_port = 6379
7 redis_db = 1 7 redis_db = 1
8 -redis_auth = "VraDMcdX=Jq!Ess4"  
9 \ No newline at end of file 8 \ No newline at end of file
  9 +redis_auth = "VraDMcdX=Jq!Ess4"
  10 +
  11 +pay_url = "https://13-cb-pub-login-wasteland.komoejoy.com"
10 \ No newline at end of file 12 \ No newline at end of file
config/server2.lua
@@ -5,4 +5,6 @@ servId = 2 @@ -5,4 +5,6 @@ servId = 2
5 redis_host = "10.235.0.167" 5 redis_host = "10.235.0.167"
6 redis_port = 6379 6 redis_port = 6379
7 redis_db = 2 7 redis_db = 2
8 -redis_auth = "VraDMcdX=Jq!Ess4"  
9 \ No newline at end of file 8 \ No newline at end of file
  9 +redis_auth = "VraDMcdX=Jq!Ess4"
  10 +
  11 +pay_url = "https://13-cb-pub-login-wasteland.komoejoy.com"
10 \ No newline at end of file 12 \ No newline at end of file
@@ -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,53 @@ RedPointTags = { @@ -259,3 +261,53 @@ 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 + ActSellFood = 231,
  294 + ActDrawCard = 232,
  295 + ActAdvDraw = 233,
  296 + ActOpenBox = 234,
  297 + ActSellFoodReward = 221,
  298 + ActDrawCardReward = 222,
  299 + ActAdvDrawReward = 223,
  300 + ActOpenBoxReward = 224,
  301 +}
  302 +
  303 +TriggerEventType = {
  304 + HangPass = 1,
  305 + LevelUp = 2,
  306 + TowerPass = 3,
  307 +}
  308 +
  309 +DrawCardType = {
  310 + SpecifyDraw = 1,
  311 + NormalDraw = 2,
  312 + FriendDraw = 3
  313 +}
262 \ No newline at end of file 314 \ No newline at end of file
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,
@@ -43,6 +44,7 @@ actionCodes = { @@ -43,6 +44,7 @@ actionCodes = {
43 Role_guideRpc = 129, 44 Role_guideRpc = 129,
44 Role_getRandomNameRpc = 130, 45 Role_getRandomNameRpc = 130,
45 Role_goldBuyRpc = 131, 46 Role_goldBuyRpc = 131,
  47 + Role_getDownloadCvRewardRpc = 132,
46 48
47 Adv_startAdvRpc = 151, 49 Adv_startAdvRpc = 151,
48 Adv_startHangRpc = 152, 50 Adv_startHangRpc = 152,
@@ -87,6 +89,8 @@ actionCodes = { @@ -87,6 +89,8 @@ actionCodes = {
87 Hero_getResetRewardRpc = 219, 89 Hero_getResetRewardRpc = 219,
88 Hero_drawHeroRpc = 220, 90 Hero_drawHeroRpc = 220,
89 Hero_repayHeroRpc = 221, 91 Hero_repayHeroRpc = 221,
  92 + Hero_unlockPoolRpc = 222,
  93 + Hero_changeCrown = 223,
90 94
91 Hang_startRpc = 251, 95 Hang_startRpc = 251,
92 Hang_checkRpc = 252, 96 Hang_checkRpc = 252,
@@ -182,6 +186,11 @@ actionCodes = { @@ -182,6 +186,11 @@ actionCodes = {
182 Store_ayncPurchaseRpc = 555, 186 Store_ayncPurchaseRpc = 555,
183 Store_myCardRechargeRpc = 556, 187 Store_myCardRechargeRpc = 556,
184 Store_iosRechargeRpc = 557, 188 Store_iosRechargeRpc = 557,
  189 + Store_shopBuyRpc = 558,
  190 + Store_updateproperty = 559,
  191 + Store_getFreeChestRpc = 560,
  192 + Store_getGrowFundRewardRpc = 561, --成长助力奖励
  193 + Store_getBattlePassRewardRpc = 562, --赛季卡奖励
185 194
186 195
187 Email_listRpc = 600, 196 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,18 @@ function _M.sudokuRpc(agent, data) @@ -60,14 +60,18 @@ 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("activity", {
  69 + activity_id = id, -- 活动ID(或活动指定任务的ID)
  70 + activity_type = 0, -- 活动类型,见活动类型枚举表
  71 + activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
  72 + })
69 73
70 - SendPacket(actionCodes.Activity_sudokuRpc, MsgPack.pack({task = task, reward = reward, rId = rId})) 74 + SendPacket(actionCodes.Activity_sudokuRpc, MsgPack.pack({task = role:packReward(task, tchange), reward = role:packReward(reward, rchange), rId = rId}))
71 return true 75 return true
72 end 76 end
73 77
@@ -90,7 +94,7 @@ function _M.sudokuRewardRpc(agent, data) @@ -90,7 +94,7 @@ function _M.sudokuRewardRpc(agent, data)
90 end 94 end
91 end 95 end
92 96
93 - local reward = role:award(globalCsv.guide_sudoku_reward[phase], {log = {desc = "sudokuRP", int1 = phase}}) 97 + local reward, change = role:award(globalCsv.guide_sudoku_reward[phase], {log = {desc = "sudokuRP", int1 = phase}})
94 98
95 sudoku[-1] = phase + 1 99 sudoku[-1] = phase + 1
96 sudoku.task[phase] = nil 100 sudoku.task[phase] = nil
@@ -100,7 +104,13 @@ function _M.sudokuRewardRpc(agent, data) @@ -100,7 +104,13 @@ function _M.sudokuRewardRpc(agent, data)
100 end 104 end
101 role:updateProperty({field = "sudoku", value = sudoku}) 105 role:updateProperty({field = "sudoku", value = sudoku})
102 106
103 - SendPacket(actionCodes.Activity_sudokuRewardRpc, MsgPack.pack(reward)) 107 + role:log("activity", {
  108 + activity_id = 10000 + phase, -- 活动ID(或活动指定任务的ID)
  109 + activity_type = 0, -- 活动类型,见活动类型枚举表
  110 + activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
  111 + })
  112 +
  113 + SendPacket(actionCodes.Activity_sudokuRewardRpc, MsgPack.pack(role:packReward(reward, change)))
104 return true 114 return true
105 end 115 end
106 116
@@ -125,10 +135,10 @@ function _M.signRpc(agent, data) @@ -125,10 +135,10 @@ function _M.signRpc(agent, data)
125 end 135 end
126 signs[curDay] = yearMonth 136 signs[curDay] = yearMonth
127 137
128 - local reward = role:award(monthData[curDay].item, {log = {desc = "sign", int1 = yearMonth, int2 = curDay}}) 138 + local reward, change = role:award(monthData[curDay].item, {log = {desc = "sign", int1 = yearMonth, int2 = curDay}})
129 role:changeUpdates({{type = "sign", field = curDay, value = yearMonth}}) 139 role:changeUpdates({{type = "sign", field = curDay, value = yearMonth}})
130 140
131 - SendPacket(actionCodes.Activity_signRpc, MsgPack.pack(reward)) 141 + SendPacket(actionCodes.Activity_signRpc, MsgPack.pack(role:packReward(reward, change)))
132 return true 142 return true
133 end 143 end
134 144
@@ -138,7 +148,7 @@ function _M.actSignRpc(agent, data) @@ -138,7 +148,7 @@ function _M.actSignRpc(agent, data)
138 if not role.activity:isOpen("Sign") then return 1 end 148 if not role.activity:isOpen("Sign") then return 1 end
139 149
140 local curData = role.activity:getActData("Sign") 150 local curData = role.activity:getActData("Sign")
141 - local reward = {} 151 + local reward, change = {}
142 for day, csvData in ipairs(csvdb["new_signInCsv"]) do 152 for day, csvData in ipairs(csvdb["new_signInCsv"]) do
143 if day <= (curData[0] or 0) then 153 if day <= (curData[0] or 0) then
144 if not curData[day] then 154 if not curData[day] then
@@ -154,9 +164,16 @@ function _M.actSignRpc(agent, data) @@ -154,9 +164,16 @@ function _M.actSignRpc(agent, data)
154 end 164 end
155 if next(reward) then 165 if next(reward) then
156 role.activity:updateActData("Sign", curData) 166 role.activity:updateActData("Sign", curData)
157 - reward = role:award(reward, {log = {desc = "actSign"}}) 167 + reward, change = role:award(reward, {log = {desc = "actSign"}})
158 end 168 end
159 - SendPacket(actionCodes.Activity_actSignRpc, MsgPack.pack(reward)) 169 +
  170 + role:log("activity", {
  171 + activity_id = curData[0], -- 活动ID(或活动指定任务的ID)
  172 + activity_type = role.activity.ActivityType.Sign, -- 活动类型,见活动类型枚举表
  173 + activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
  174 + })
  175 +
  176 + SendPacket(actionCodes.Activity_actSignRpc, MsgPack.pack(role:packReward(reward, change)))
160 return true 177 return true
161 end 178 end
162 179
src/actions/AdvAction.lua
@@ -90,7 +90,7 @@ function _M.startAdvRpc( agent, data ) @@ -90,7 +90,7 @@ function _M.startAdvRpc( agent, data )
90 --上一个关卡结束才可以开始新的关卡 90 --上一个关卡结束才可以开始新的关卡
91 if role:getAdvData():isRunning() then return 8 end 91 if role:getAdvData():isRunning() then return 8 end
92 local advHang = role:getProperty("advHang") 92 local advHang = role:getProperty("advHang")
93 - if advHang[chapterId] then return 9 end --正在挂机 93 + -- if advHang[chapterId] then return 9 end --正在挂机
94 94
95 95
96 local chapterData = csvdb["adv_chapterCsv"][chapterId] 96 local chapterData = csvdb["adv_chapterCsv"][chapterId]
@@ -174,7 +174,6 @@ function _M.startAdvRpc( agent, data ) @@ -174,7 +174,6 @@ function _M.startAdvRpc( agent, data )
174 role:checkTaskEnter("AdvStart", {id = chapterId}) 174 role:checkTaskEnter("AdvStart", {id = chapterId})
175 role:checkTaskEnter("AdvStartSelf", {id = chapterId}) 175 role:checkTaskEnter("AdvStartSelf", {id = chapterId})
176 role:getAdvData():popBackEvents() -- 清一下事件 176 role:getAdvData():popBackEvents() -- 清一下事件
177 - role:getAdvData():log({desc = "start", int1 = supportIdx})  
178 177
179 SendPacket(actionCodes.Adv_startAdvRpc, '') 178 SendPacket(actionCodes.Adv_startAdvRpc, '')
180 return true 179 return true
@@ -184,26 +183,38 @@ function _M.startHangRpc(agent, data) @@ -184,26 +183,38 @@ function _M.startHangRpc(agent, data)
184 local role = agent.role 183 local role = agent.role
185 local msg = MsgPack.unpack(data) 184 local msg = MsgPack.unpack(data)
186 local chapterId = msg.chapterId --关卡id 185 local chapterId = msg.chapterId --关卡id
  186 + local campId = msg.campId or 2 --营地id
187 local format = msg.format --编队 187 local format = msg.format --编队
188 -  
189 - local chapterData = csvdb["adv_chapterCsv"][chapterId]  
190 - if not chapterData then return end  
191 - if chapterData.idleReward == "" then return end --没有奖励 没有挂机 188 + local index = msg.index or 1--时间索引id
  189 +
  190 + local chapterData = csvdb["adv_chapter_campsiteCsv"][chapterId]
  191 + if not chapterData then return 1 end
  192 + local campSiteData = chapterData[campId]
  193 + if not campSiteData then return 1 end
  194 + if campSiteData.idleReward_1 == "" and campSiteData.idleReward_2 == "" then return 2 end --没有奖励 没有挂机
  195 +
  196 + local adv_idle_time = globalCsv.adv_idle_time[index]
  197 + local adv_idle_energy = globalCsv.adv_idle_energy[index]
  198 + local adv_idle_reward_coef = globalCsv.adv_idle_reward[index]
  199 + if not adv_idle_time or not adv_idle_energy or not adv_idle_reward_coef then
  200 + return 2
  201 + end
  202 + adv_idle_time = adv_idle_time * 60
192 203
193 local advHang = role:getProperty("advHang") 204 local advHang = role:getProperty("advHang")
194 - if advHang[chapterId] then return end --正在挂机 205 + if advHang[chapterId] then return 3 end --正在挂机
195 206
196 - if role:getAdvData():isRunning() and role:getAdvData().chapterId == chapterId then return end 207 + -- if role:getAdvData():isRunning() and role:getAdvData().chapterId == chapterId then return 4 end
197 208
198 - if AdvCommon.isEndless(chapterId) then return end -- 无尽没有代理 209 + if AdvCommon.isEndless(chapterId) then return 5 end -- 无尽没有代理
199 210
200 local advRelay = role:getProperty("advRelay") 211 local advRelay = role:getProperty("advRelay")
201 - if not next(advRelay[chapterId] or {}) then return end -- 没有开放 212 + if not next(advRelay[chapterId] or {}) then return 6 end -- 没有开放
202 213
203 214
204 - if not role:checkAdvCount(chapterData.limitlevel) then return end -- 是否有体力 215 + if not role:checkAdvCount(adv_idle_energy) then return 7 end -- 是否有体力
205 216
206 - if not checkFormat(role, format, role:getAdvData():isRunning()) then return end --编队是否正确 217 + if not checkFormat(role, format, role:getAdvData():isRunning()) then return 8 end --编队是否正确
207 218
208 local player = {} 219 local player = {}
209 local attrs = role:getTeamBattleInfo(format).heros 220 local attrs = role:getTeamBattleInfo(format).heros
@@ -220,7 +231,7 @@ function _M.startHangRpc(agent, data) @@ -220,7 +231,7 @@ function _M.startHangRpc(agent, data)
220 + 0.226 * player["hit"] 231 + 0.226 * player["hit"]
221 + 0.26 * player["miss"] 232 + 0.26 * player["miss"]
222 233
223 - if battleV < chapterData.idleValue then return end -- 战斗力是否满足 234 + if battleV < campSiteData.idleValue then return 9 end -- 战斗力是否满足
224 235
225 local info = {} 236 local info = {}
226 info.format = {} 237 info.format = {}
@@ -230,7 +241,9 @@ function _M.startHangRpc(agent, data) @@ -230,7 +241,9 @@ function _M.startHangRpc(agent, data)
230 for slot, heroId in pairs(format.heros) do 241 for slot, heroId in pairs(format.heros) do
231 info.format.heros[slot] = heroId 242 info.format.heros[slot] = heroId
232 end 243 end
233 - info.time = skynet.timex() + chapterData.idleTime --挂机时间 244 + info.time = skynet.timex() + adv_idle_time --挂机时间
  245 + info.campId = campId
  246 + info.index = index
234 247
235 -- 没有在战斗 用team来挂机了 把team清掉 248 -- 没有在战斗 用team来挂机了 把team清掉
236 if not role:getAdvData():isRunning() then 249 if not role:getAdvData():isRunning() then
@@ -239,9 +252,8 @@ function _M.startHangRpc(agent, data) @@ -239,9 +252,8 @@ function _M.startHangRpc(agent, data)
239 252
240 role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) 253 role:changeUpdates({{type = "advHang", field = chapterId, value = info}})
241 254
242 - role:changeAdvCount(chapterData.limitlevel) 255 + role:changeAdvCount(adv_idle_energy)
243 role:checkTaskEnter("AdvStart", {id = chapterId}) 256 role:checkTaskEnter("AdvStart", {id = chapterId})
244 - role:log("adv_action", {desc = "startHang", int1 = chapterId})  
245 257
246 SendPacket(actionCodes.Adv_startHangRpc, '') 258 SendPacket(actionCodes.Adv_startHangRpc, '')
247 return true 259 return true
@@ -257,21 +269,30 @@ function _M.quickHangRpc(agent, data) @@ -257,21 +269,30 @@ function _M.quickHangRpc(agent, data)
257 local info = advHang[chapterId] 269 local info = advHang[chapterId]
258 if not info then return end 270 if not info then return end
259 271
260 - local chapterData = csvdb["adv_chapterCsv"][chapterId] 272 + local index = info.index
  273 + local chapterData = csvdb["adv_chapter_campsiteCsv"][chapterId]
261 if not chapterData then return end 274 if not chapterData then return end
  275 +
  276 + local campSiteData = chapterData[info.campId]
  277 + if not campSiteData then return 1 end
  278 + if campSiteData.idleReward_1 == "" and campSiteData.idleReward_2 == "" then return 2 end --没有奖励 没有挂机
  279 +
  280 + local adv_idle_time = globalCsv.adv_idle_time[index]
  281 + if not adv_idle_time then
  282 + return 2
  283 + end
  284 + adv_idle_time = adv_idle_time * 60
262 285
263 local reward, isFull 286 local reward, isFull
264 if skynet.timex() >= info.time then return end -- 已经完成了 287 if skynet.timex() >= info.time then return end -- 已经完成了
265 288
266 - local cost = math.ceil((info.time - skynet.timex()) / chapterData.idleTime * chapterData.accelerate) 289 + local cost = math.ceil((info.time - skynet.timex()) / 3600 * globalCsv.adv_idle_quicken)
267 290
268 if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return end 291 if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return end
269 role:costItems({[ItemId.Diamond] = cost}, {log = {desc = "advQuickHang", int1 = chapterId}}) 292 role:costItems({[ItemId.Diamond] = cost}, {log = {desc = "advQuickHang", int1 = chapterId}})
270 info.time = 0 293 info.time = 0
271 role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) 294 role:changeUpdates({{type = "advHang", field = chapterId, value = info}})
272 295
273 - role:log("adv_action", {desc = "advQuickHang", int1 = chapterId})  
274 -  
275 SendPacket(actionCodes.Adv_quickHangRpc, '') 296 SendPacket(actionCodes.Adv_quickHangRpc, '')
276 return true 297 return true
277 end 298 end
@@ -287,11 +308,25 @@ function _M.endHangRpc(agent, data) @@ -287,11 +308,25 @@ function _M.endHangRpc(agent, data)
287 local info = advHang[chapterId] 308 local info = advHang[chapterId]
288 if not info then return end 309 if not info then return end
289 310
290 - local chapterData = csvdb["adv_chapterCsv"][chapterId] 311 + local index = info.index or 1
  312 + local chapterData = csvdb["adv_chapter_campsiteCsv"][chapterId]
291 if not chapterData then return end 313 if not chapterData then return end
  314 + local campSiteData = chapterData[info.campId or 2]
  315 + if not campSiteData then return 1 end
  316 + if campSiteData.idleReward_1 == "" and campSiteData.idleReward_2 == "" then return 2 end --没有奖励 没有挂机
  317 +
  318 + local adv_idle_time = globalCsv.adv_idle_time[index]
  319 + local adv_idle_energy = globalCsv.adv_idle_energy[index]
  320 + local adv_idle_reward_coef = globalCsv.adv_idle_reward[index]
  321 + if not adv_idle_time or not adv_idle_energy or not adv_idle_reward_coef then
  322 + return 2
  323 + end
  324 + adv_idle_time = adv_idle_time * 60
292 325
293 - local reward, isFull 326 + local reward, isFull, change
294 if skynet.timex() >= info.time then 327 if skynet.timex() >= info.time then
  328 + -- 最新需求加成取消
  329 + --[[
295 -- 英雄加成 330 -- 英雄加成
296 local idleUnit = chapterData.idleUnit:toNumMap() 331 local idleUnit = chapterData.idleUnit:toNumMap()
297 local upUnit = 0 332 local upUnit = 0
@@ -316,15 +351,17 @@ function _M.endHangRpc(agent, data) @@ -316,15 +351,17 @@ function _M.endHangRpc(agent, data)
316 end 351 end
317 352
318 if not maxCampsite then return end 353 if not maxCampsite then return end
  354 + ]]
  355 + local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2
319 356
320 - local idleReward = chapterData.idleReward:toNumMap() 357 + local idleReward = totalReward:toNumMap()
321 for itemId, count in pairs(idleReward) do 358 for itemId, count in pairs(idleReward) do
322 - idleReward[itemId] = math.floor(count * (maxCampsite.idleValue + upUnit) / 100) 359 + idleReward[itemId] = count * adv_idle_reward_coef
323 end 360 end
324 - reward = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}}) 361 + reward, change = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}})
325 else 362 else
326 if cancel then 363 if cancel then
327 - role:changeAdvCount(-chapterData.limitlevel) 364 + --role:changeAdvCount(-chapterData.limitlevel)
328 -- if role:getProperty("advC") <= 0 then 365 -- if role:getProperty("advC") <= 0 then
329 -- isFull = true 366 -- isFull = true
330 -- else 367 -- else
@@ -337,9 +374,7 @@ function _M.endHangRpc(agent, data) @@ -337,9 +374,7 @@ function _M.endHangRpc(agent, data)
337 374
338 role:changeUpdates({{type = "advHang", field = chapterId, value = nil}}) 375 role:changeUpdates({{type = "advHang", field = chapterId, value = nil}})
339 376
340 - role:log("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0})  
341 -  
342 - SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, isFull = isFull})) 377 + SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull}))
343 return true 378 return true
344 end 379 end
345 380
@@ -360,7 +395,7 @@ function _M.buyAdvCountRpc(agent , data) @@ -360,7 +395,7 @@ function _M.buyAdvCountRpc(agent , data)
360 395
361 396
362 if not role:checkItemEnough(cost) then return end 397 if not role:checkItemEnough(cost) then return end
363 - role:costItems(cost, {log = {desc = "buyAdvCount", short1 = isEl and 1 or 0, int1 = count}}) 398 + role:costItems(cost, {log = {desc = "buyAdvCount", int1 = isEl and 1 or 0, int2 = count}})
364 if isEl then 399 if isEl then
365 role.dailyData:updateProperty({field = "advElC", delta = -count}) 400 role.dailyData:updateProperty({field = "advElC", delta = -count})
366 role.dailyData:updateProperty({field = "advElBC", delta = count}) 401 role.dailyData:updateProperty({field = "advElBC", delta = count})
@@ -368,7 +403,6 @@ function _M.buyAdvCountRpc(agent , data) @@ -368,7 +403,6 @@ function _M.buyAdvCountRpc(agent , data)
368 role:changeAdvCount(-count * globalCsv.adv_daily_buy_num) 403 role:changeAdvCount(-count * globalCsv.adv_daily_buy_num)
369 role.dailyData:updateProperty({field = "advBC", delta = count}) 404 role.dailyData:updateProperty({field = "advBC", delta = count})
370 end 405 end
371 - role:log("adv_action", {desc = "buyAdvCount", short1 = isEl and 1 or 0, int1 = count})  
372 406
373 SendPacket(actionCodes.Adv_buyAdvCountRpc, '') 407 SendPacket(actionCodes.Adv_buyAdvCountRpc, '')
374 return true 408 return true
@@ -381,9 +415,9 @@ function _M.finishTaskRpc(agent, data) @@ -381,9 +415,9 @@ function _M.finishTaskRpc(agent, data)
381 if not isCanContinue(role) then return end 415 if not isCanContinue(role) then return end
382 local adv = role:getAdvData() 416 local adv = role:getAdvData()
383 local taskId = msg.taskId -- -1 则是主线任务 417 local taskId = msg.taskId -- -1 则是主线任务
384 - local status, reward 418 + local status, reward, change
385 if taskId == -1 then 419 if taskId == -1 then
386 - status, reward = adv:finishMTask() 420 + status, reward, change = adv:finishMTask()
387 else 421 else
388 status, reward = adv:finishTask(taskId) 422 status, reward = adv:finishTask(taskId)
389 adv:checkAchievement(adv.AchievType.TaskLayer, 1, taskId) 423 adv:checkAchievement(adv.AchievType.TaskLayer, 1, taskId)
@@ -393,9 +427,7 @@ function _M.finishTaskRpc(agent, data) @@ -393,9 +427,7 @@ function _M.finishTaskRpc(agent, data)
393 if not status then return end 427 if not status then return end
394 role:checkTaskEnter("AdvOverTask", {id = taskId}) 428 role:checkTaskEnter("AdvOverTask", {id = taskId})
395 429
396 - adv:log({desc = "finishTask", int1 = taskId})  
397 -  
398 - SendPacket(actionCodes.Adv_finishTaskRpc, MsgPack.pack({reward = reward})) 430 + SendPacket(actionCodes.Adv_finishTaskRpc, MsgPack.pack(role:packReward(reward, change)))
399 return true 431 return true
400 end 432 end
401 433
@@ -416,8 +448,6 @@ function _M.clickBlockRpc(agent, data) @@ -416,8 +448,6 @@ function _M.clickBlockRpc(agent, data)
416 448
417 if adv:isWaitChooseArtifact() then return returnFail() end 449 if adv:isWaitChooseArtifact() then return returnFail() end
418 450
419 - adv:log({desc = "clickBlock", int1 = msg.roomId, int2 = msg.blockId})  
420 -  
421 local status, errorCode = adv:clickBlock(msg.roomId, msg.blockId, msg) 451 local status, errorCode = adv:clickBlock(msg.roomId, msg.blockId, msg)
422 if not status then return returnFail(errorCode) end 452 if not status then return returnFail(errorCode) end
423 453
@@ -450,8 +480,11 @@ function _M.useItemRpc(agent, data) @@ -450,8 +480,11 @@ function _M.useItemRpc(agent, data)
450 adv:backUse({[itemId] = count}) 480 adv:backUse({[itemId] = count})
451 end 481 end
452 482
  483 + if itemId == 5020 then
  484 + role:finishGuide(53)
  485 + end
  486 +
453 adv:checkAchievement(adv.AchievType.UseItem, count, itemId) 487 adv:checkAchievement(adv.AchievType.UseItem, count, itemId)
454 - adv:log({desc = "useItem", int1 = itemId, int2 = count})  
455 488
456 for i = 1, count do 489 for i = 1, count do
457 adv:doActive(itemData.effect, target) -- target 490 adv:doActive(itemData.effect, target) -- target
@@ -487,7 +520,6 @@ function _M.usePotionRpc(agent, data) @@ -487,7 +520,6 @@ function _M.usePotionRpc(agent, data)
487 local adv = role:getAdvData() 520 local adv = role:getAdvData()
488 if adv:isWaitChooseArtifact() then return end 521 if adv:isWaitChooseArtifact() then return end
489 522
490 - adv:log({desc = "usePotion", int1 = potionId})  
491 523
492 local status = adv:doActive(potionData.effect, target) -- target 524 local status = adv:doActive(potionData.effect, target) -- target
493 if not status then return end 525 if not status then return end
@@ -499,6 +531,8 @@ function _M.usePotionRpc(agent, data) @@ -499,6 +531,8 @@ function _M.usePotionRpc(agent, data)
499 adv:saveDB() 531 adv:saveDB()
500 role:checkTaskEnter("AdvUsePotion") 532 role:checkTaskEnter("AdvUsePotion")
501 533
  534 + role:finishGuide(61)
  535 +
502 SendPacket(actionCodes.Adv_usePotionRpc, MsgPack.pack({events = adv:popBackEvents()})) 536 SendPacket(actionCodes.Adv_usePotionRpc, MsgPack.pack({events = adv:popBackEvents()}))
503 return true 537 return true
504 end 538 end
@@ -539,6 +573,8 @@ function _M.wearArtifactRpc(agent, data) @@ -539,6 +573,8 @@ function _M.wearArtifactRpc(agent, data)
539 if not status then return 3 end 573 if not status then return 3 end
540 adv:saveDB() 574 adv:saveDB()
541 575
  576 + role:finishGuide(55)
  577 +
542 SendPacket(actionCodes.Adv_wearArtifactRpc, '') 578 SendPacket(actionCodes.Adv_wearArtifactRpc, '')
543 return true 579 return true
544 end 580 end
@@ -568,6 +604,7 @@ function _M.upArtifactRpc(agent, data) @@ -568,6 +604,7 @@ function _M.upArtifactRpc(agent, data)
568 else 604 else
569 adv:updateAchievement() 605 adv:updateAchievement()
570 end 606 end
  607 +
571 SendPacket(actionCodes.Adv_upArtifactRpc, '') 608 SendPacket(actionCodes.Adv_upArtifactRpc, '')
572 return true 609 return true
573 end 610 end
@@ -577,9 +614,10 @@ function _M.exitAdvRpc(agent, data) @@ -577,9 +614,10 @@ function _M.exitAdvRpc(agent, data)
577 local role = agent.role 614 local role = agent.role
578 -- local msg = MsgPack.unpack(data) 615 -- local msg = MsgPack.unpack(data)
579 if not isCanContinue(role) then return end 616 if not isCanContinue(role) then return end
580 - 617 + if not role:checkOverGuide(57) then
  618 + role:saveGuide(57,1,true)
  619 + end
581 local adv = role:getAdvData() 620 local adv = role:getAdvData()
582 - adv:log({desc = "exit"})  
583 local status = adv:exit() -- target {roomId = 1, blockId = 1} 选择的目标 621 local status = adv:exit() -- target {roomId = 1, blockId = 1} 选择的目标
584 SendPacket(actionCodes.Adv_exitAdvRpc, MsgPack.pack({events = adv:popBackEvents()})) 622 SendPacket(actionCodes.Adv_exitAdvRpc, MsgPack.pack({events = adv:popBackEvents()}))
585 return true 623 return true
@@ -638,7 +676,19 @@ function _M.endBattleRpc(agent, data) @@ -638,7 +676,19 @@ function _M.endBattleRpc(agent, data)
638 if enemy.monsterId ~= monsterId or enemy.roomId ~= roomId or enemy.blockId ~= blockId then return end 676 if enemy.monsterId ~= monsterId or enemy.roomId ~= roomId or enemy.blockId ~= blockId then return end
639 adv.__battleCache = nil 677 adv.__battleCache = nil
640 678
641 - adv:log({desc = "endBattle"}) 679 + -- 打完野猪怪
  680 + role:finishGuide(52)
  681 + -- 调理剂使用引导(生命药剂)
  682 + if not role:checkOverGuide(61) then
  683 + local potionBag = role:getProperty("potionBag")
  684 + local own = potionBag[10] or 0
  685 + if own > 0 then
  686 + -- 造假
  687 + player.hp = player.hp * 0.8
  688 + role:saveGuide(61,1,true)
  689 + end
  690 + end
  691 +
642 local status = adv:clickBlock(roomId, blockId, {player = player, bySkill = bySkill}) 692 local status = adv:clickBlock(roomId, blockId, {player = player, bySkill = bySkill})
643 693
644 if not status then return end 694 if not status then return end
@@ -720,9 +770,8 @@ function _M.wheelSurfRpc(agent, data) @@ -720,9 +770,8 @@ function _M.wheelSurfRpc(agent, data)
720 table.insert(backReward, gift) 770 table.insert(backReward, gift)
721 end 771 end
722 role:award(reward, {log = {desc = "advWheelSurf", int1 = ptype}}) 772 role:award(reward, {log = {desc = "advWheelSurf", int1 = ptype}})
723 - 773 + role:finishGuide(58)
724 role:checkTaskEnter("AdvDraw", {count = count, ptype = ptype}) 774 role:checkTaskEnter("AdvDraw", {count = count, ptype = ptype})
725 - role:log("adv_action", {desc = "advWheelSurf", int1 = ptype, int2 = count})  
726 775
727 SendPacket(actionCodes.Adv_wheelSurfRpc, MsgPack.pack({reward = backReward})) 776 SendPacket(actionCodes.Adv_wheelSurfRpc, MsgPack.pack({reward = backReward}))
728 return true 777 return true
@@ -749,11 +798,10 @@ function _M.repayWheelSurfRpc(agent, data) @@ -749,11 +798,10 @@ function _M.repayWheelSurfRpc(agent, data)
749 advDrawB[ptype] = advDrawB[ptype] - globalCsv.adv_draw_back_cond 798 advDrawB[ptype] = advDrawB[ptype] - globalCsv.adv_draw_back_cond
750 role:updateProperty({field = "advDrawB", value = advDrawB}) 799 role:updateProperty({field = "advDrawB", value = advDrawB})
751 local gift = drawData["pool3"]:randWeight(true) 800 local gift = drawData["pool3"]:randWeight(true)
752 - local reward = {[gift[1]] = gift[2]}  
753 - reward = role:award(reward, {log = {desc = "advRepayWheelSurf", int1 = ptype}})  
754 - role:log("adv_action", {desc = "advRepayWheelSurf", int1 = ptype}) 801 + local reward, change = {[gift[1]] = gift[2]}
  802 + reward, change = role:award(reward, {log = {desc = "advRepayWheelSurf", int1 = ptype}})
755 803
756 - SendPacket(actionCodes.Adv_repayWheelSurfRpc, MsgPack.pack({reward = reward})) 804 + SendPacket(actionCodes.Adv_repayWheelSurfRpc, MsgPack.pack(role:packReward(reward, change)))
757 return true 805 return true
758 end 806 end
759 807
@@ -766,17 +814,16 @@ function _M.finishAchievRpc(agent, data) @@ -766,17 +814,16 @@ function _M.finishAchievRpc(agent, data)
766 814
767 local adv = role:getAdvData() 815 local adv = role:getAdvData()
768 816
769 - local status, reward 817 + local status, reward, change
770 if ctype == 1 then 818 if ctype == 1 then
771 - status, reward = adv:finishAchievement(chapterId, taskId) 819 + status, reward, change = adv:finishAchievement(chapterId, taskId)
772 elseif ctype == 2 then 820 elseif ctype == 2 then
773 - status, reward = adv:getAchievementReward(chapterId, taskId) 821 + status, reward, change = adv:getAchievementReward(chapterId, taskId)
774 end 822 end
775 if not status then return end 823 if not status then return end
776 adv:updateAchievement() 824 adv:updateAchievement()
777 - role:log("adv_action", {desc = "finishAchiev", short1 = ctype, int1 = chapterId, int2 = taskId})  
778 -  
779 - SendPacket(actionCodes.Adv_finishAchievRpc, MsgPack.pack({reward = reward})) 825 + role:finishGuide(57)
  826 + SendPacket(actionCodes.Adv_finishAchievRpc, MsgPack.pack(role:packReward(reward, change)))
780 return true 827 return true
781 end 828 end
782 829
@@ -831,7 +878,6 @@ function _M.refreshSupportRpc(agent, data) @@ -831,7 +878,6 @@ function _M.refreshSupportRpc(agent, data)
831 end 878 end
832 879
833 role:advRandomSupportEffect() 880 role:advRandomSupportEffect()
834 - role:log("adv_action", {desc = "advSupRe", short1 = cr < al and 0 or 1})  
835 881
836 SendPacket(actionCodes.Adv_refreshSupportRpc, '') 882 SendPacket(actionCodes.Adv_refreshSupportRpc, '')
837 return true 883 return true
src/actions/CarAction.lua
@@ -40,7 +40,13 @@ function _M.makePotionRpc( agent, data ) @@ -40,7 +40,13 @@ function _M.makePotionRpc( agent, data )
40 role:updateProperty({field = "potionBag", value = potionBag}) 40 role:updateProperty({field = "potionBag", value = potionBag})
41 role:checkTaskEnter("PotionMake", {count = count, id = potionId}) 41 role:checkTaskEnter("PotionMake", {count = count, id = potionId})
42 42
43 - role:log("role_action", {desc = "makePotion", int1 = potionId, int2 = count}) 43 + role:log("carriage_cook", {
  44 + item_id = potionId, -- 道具id
  45 + item_level = potionLv, -- 道具等级
  46 + item_type = 0, -- 道具类型,具体见枚举表中道具类型枚举表
  47 + carriage_cook_amount = count, -- 制作总量
  48 + carriage_cook_cost = cost, -- 制作消耗道具,json格式记录,{'itemid1':10,'itemid2':5,…………..}
  49 + })
44 SendPacket(actionCodes.Car_makePotionRpc, MsgPack.pack({potionBag = potionBag})) 50 SendPacket(actionCodes.Car_makePotionRpc, MsgPack.pack({potionBag = potionBag}))
45 return true 51 return true
46 end 52 end
@@ -91,7 +97,14 @@ function _M.equipUpRpc( agent, data ) @@ -91,7 +97,14 @@ function _M.equipUpRpc( agent, data )
91 role:addEquip(typ, nextLv ,count, {log = {desc = "equipUp"}}) 97 role:addEquip(typ, nextLv ,count, {log = {desc = "equipUp"}})
92 role:checkTaskEnter("EquipUp", {count = count}) 98 role:checkTaskEnter("EquipUp", {count = count})
93 99
94 - role:log("role_action", {desc = "equipUp", int1 = id, int2 = count}) 100 + role:log("equip_upgrade", {
  101 + equip_upgrade_part = typ, -- 升级部位,记录部位ID
  102 + equip_id = nextLv, -- 升级后的装备ID
  103 + equip_upgrade_amount = count, -- 升级获取的装备数量
  104 + equip_upgrade_usedid = lv, -- 升级消耗的装备ID
  105 + equip_upgrade_cost = costCount, -- 升级操作消耗装备数量
  106 + equip_upgrade_current = cost, -- 升级消耗的货币类型
  107 + })
95 108
96 SendPacket(actionCodes.Car_equipUpRpc, '') 109 SendPacket(actionCodes.Car_equipUpRpc, '')
97 return true 110 return true
@@ -150,7 +163,7 @@ function _M.saleEquipRpc(agent, data ) @@ -150,7 +163,7 @@ function _M.saleEquipRpc(agent, data )
150 local own = role:getEquipCount(typ,lv) 163 local own = role:getEquipCount(typ,lv)
151 if math.illegalNum(count, 1, own) then return end 164 if math.illegalNum(count, 1, own) then return end
152 end 165 end
153 - local reward = {} 166 + local reward, change = {}
154 local allCount = 0 167 local allCount = 0
155 for id, count in pairs(backs) do 168 for id, count in pairs(backs) do
156 allCount = allCount + count 169 allCount = allCount + count
@@ -165,11 +178,9 @@ function _M.saleEquipRpc(agent, data ) @@ -165,11 +178,9 @@ function _M.saleEquipRpc(agent, data )
165 end 178 end
166 end 179 end
167 role:checkTaskEnter("SaleEquip", {count = allCount}) 180 role:checkTaskEnter("SaleEquip", {count = allCount})
168 - reward = role:award(reward, {log = {desc = "saleEquip"}}) 181 + reward, change = role:award(reward, {log = {desc = "saleEquip"}})
169 182
170 - role:log("role_action", {desc = "saleEquip", int1 = allCount})  
171 -  
172 - SendPacket(actionCodes.Car_saleEquipRpc, MsgPack.pack({reward = reward})) 183 + SendPacket(actionCodes.Car_saleEquipRpc, MsgPack.pack(role:packReward(reward, change)))
173 return true 184 return true
174 end 185 end
175 186
@@ -179,7 +190,7 @@ function _M.saleRuneRpc(agent, data ) @@ -179,7 +190,7 @@ function _M.saleRuneRpc(agent, data )
179 local backs = msg.backs 190 local backs = msg.backs
180 if not backs then return end 191 if not backs then return end
181 192
182 - local reward = {} 193 + local reward, change = {}
183 local count = 0 194 local count = 0
184 for _, uid in pairs(backs) do 195 for _, uid in pairs(backs) do
185 count = count + 1 196 count = count + 1
@@ -196,9 +207,9 @@ function _M.saleRuneRpc(agent, data ) @@ -196,9 +207,9 @@ function _M.saleRuneRpc(agent, data )
196 207
197 role:delRunes(backs, {log = {desc = "saleRune"}}) 208 role:delRunes(backs, {log = {desc = "saleRune"}})
198 role:checkTaskEnter("DecoRune", {count = count}) 209 role:checkTaskEnter("DecoRune", {count = count})
199 - reward = role:award(reward, {log = {desc = "saleRune"}}) 210 + reward, change = role:award(reward, {log = {desc = "saleRune"}})
200 211
201 - SendPacket(actionCodes.Car_saleRuneRpc, MsgPack.pack({reward = reward})) 212 + SendPacket(actionCodes.Car_saleRuneRpc, MsgPack.pack(role:packReward(reward, change)))
202 return true 213 return true
203 end 214 end
204 215
src/actions/DinerAction.lua
@@ -104,8 +104,7 @@ function _M.addSellRpc( agent, data ) @@ -104,8 +104,7 @@ function _M.addSellRpc( agent, data )
104 if change then 104 if change then
105 role.dinerData:updateProperty({field = "customer", value = customer}) 105 role.dinerData:updateProperty({field = "customer", value = customer})
106 end 106 end
107 -  
108 - role:log("diner_action", {desc = "addSell", int1 = dish, int2 = count}) 107 + role:finishGuide(28)
109 108
110 role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) 109 role.dinerData:updateProperty({field = "sells", value = json.encode(sells)})
111 SendPacket(actionCodes.Diner_addSellRpc, "") 110 SendPacket(actionCodes.Diner_addSellRpc, "")
@@ -140,20 +139,27 @@ function _M.removeSellRpc( agent, data ) @@ -140,20 +139,27 @@ function _M.removeSellRpc( agent, data )
140 return 5 139 return 5
141 end 140 end
142 141
143 - role.dinerData:updateSell(slot)  
144 - local reward = {} 142 + local temp = role.dinerData:updateSell(slot)
  143 + local reward, change = {}
145 local cost = dishData.material:toNumMap() 144 local cost = dishData.material:toNumMap()
146 for k, n in pairs(cost) do 145 for k, n in pairs(cost) do
147 local sum = n*sell.count 146 local sum = n*sell.count
148 reward[k] = sum 147 reward[k] = sum
149 end 148 end
150 - reward = role:award(reward, {log = {desc = "removeSell"}}) 149 + reward, change = role:award(reward, {log = {desc = "removeSell"}})
151 sells[slot].count = 0 150 sells[slot].count = 0
152 151
153 - role:log("diner_action", {desc = "removeSell", int1 = dish}) 152 + role:log("restaurant_sale", {
  153 + item_id = dish, -- 售卖物品ID
  154 + restaurant_sale_seat = slot, -- 售卖物品所在位置
  155 + restaurant_sale_time = temp.deltaTime or 0, -- 售卖时长
  156 + restaurant_sale_type = 2, -- 售卖方式,正常售卖:0, 加速:1,移除售卖:2
  157 + restaurant_sale_coin = reward[ItemId.DinerCoin] or 0, -- 售卖获得美食币
  158 + restaurant_sale_gear = reward[ItemId.Gold] or 0, -- 售卖获得齿轮
  159 + })
154 160
155 role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) 161 role.dinerData:updateProperty({field = "sells", value = json.encode(sells)})
156 - SendPacket(actionCodes.Diner_removeSellRpc, MsgPack.pack({reward = reward})) 162 + SendPacket(actionCodes.Diner_removeSellRpc, MsgPack.pack({reward = reward, change = change}))
157 return true 163 return true
158 end 164 end
159 165
@@ -162,8 +168,11 @@ function _M.getSellRewardRpc( agent, data ) @@ -162,8 +168,11 @@ function _M.getSellRewardRpc( agent, data )
162 local dirty = false 168 local dirty = false
163 local reward, popular = "", 0 169 local reward, popular = "", 0
164 local sells = json.decode(role.dinerData:getProperty("sells")) 170 local sells = json.decode(role.dinerData:getProperty("sells"))
  171 +
  172 + local deltaTimes = {}
165 for slot, _ in pairs(sells) do 173 for slot, _ in pairs(sells) do
166 - role.dinerData:updateSell(slot) 174 + local temp = role.dinerData:updateSell(slot)
  175 + deltaTimes[slot] = temp.deltaTime
167 end 176 end
168 sells = json.decode(role.dinerData:getProperty("sells")) 177 sells = json.decode(role.dinerData:getProperty("sells"))
169 for slot, sell in pairs(sells) do 178 for slot, sell in pairs(sells) do
@@ -187,6 +196,15 @@ function _M.getSellRewardRpc( agent, data ) @@ -187,6 +196,15 @@ function _M.getSellRewardRpc( agent, data )
187 end 196 end
188 sells[slot].reward = "" 197 sells[slot].reward = ""
189 sells[slot].popular = 0 198 sells[slot].popular = 0
  199 +
  200 + role:log("restaurant_sale", {
  201 + item_id = sell.dish, -- 售卖物品ID
  202 + restaurant_sale_seat = slot, -- 售卖物品所在位置
  203 + restaurant_sale_time = deltaTimes[slot] or 0, -- 售卖时长
  204 + restaurant_sale_type = 0, -- 售卖方式,正常售卖:0, 加速:1,移除售卖:2
  205 + restaurant_sale_coin = rewards[ItemId.DinerCoin] or 0, -- 售卖获得美食币
  206 + restaurant_sale_gear = rewards[ItemId.Gold] or 0, -- 售卖获得齿轮
  207 + })
190 end 208 end
191 role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) 209 role.dinerData:updateProperty({field = "sells", value = json.encode(sells)})
192 local gift = reward:toNumMap() 210 local gift = reward:toNumMap()
@@ -195,7 +213,7 @@ function _M.getSellRewardRpc( agent, data ) @@ -195,7 +213,7 @@ function _M.getSellRewardRpc( agent, data )
195 role:checkTaskEnter("FoodSellGold", {count = v}) 213 role:checkTaskEnter("FoodSellGold", {count = v})
196 end 214 end
197 end 215 end
198 - role:award(gift, {log = {desc = "dinerSell"}}) 216 + local reward, change = role:award(gift, {log = {desc = "dinerSell"}})
199 217
200 218
201 role.dinerData:popularAdd(popular) 219 role.dinerData:popularAdd(popular)
@@ -204,9 +222,9 @@ function _M.getSellRewardRpc( agent, data ) @@ -204,9 +222,9 @@ function _M.getSellRewardRpc( agent, data )
204 role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) 222 role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order"))
205 end 223 end
206 224
207 - role:log("diner_action", {desc = "sell"})  
208 225
209 - SendPacket(actionCodes.Diner_getSellRewardRpc, MsgPack.pack({reward = reward})) 226 +
  227 + SendPacket(actionCodes.Diner_getSellRewardRpc, MsgPack.pack({reward = reward, change = change}))
210 return true 228 return true
211 end 229 end
212 230
@@ -254,6 +272,15 @@ function _M.expediteSellRpc( agent, data ) @@ -254,6 +272,15 @@ function _M.expediteSellRpc( agent, data )
254 dirty = true 272 dirty = true
255 end 273 end
256 end 274 end
  275 +
  276 + role:log("restaurant_sale", {
  277 + item_id = sell.dish, -- 售卖物品ID
  278 + restaurant_sale_seat = slot, -- 售卖物品所在位置
  279 + restaurant_sale_time = result.deltaTime or 0, -- 售卖时长
  280 + restaurant_sale_type = 1, -- 售卖方式,正常售卖:0, 加速:1,移除售卖:2
  281 + restaurant_sale_coin = rewards[ItemId.DinerCoin] or 0, -- 售卖获得美食币
  282 + restaurant_sale_gear = rewards[ItemId.Gold] or 0, -- 售卖获得齿轮
  283 + })
257 end 284 end
258 end 285 end
259 286
@@ -261,12 +288,20 @@ function _M.expediteSellRpc( agent, data ) @@ -261,12 +288,20 @@ function _M.expediteSellRpc( agent, data )
261 role.dinerData:setProperty("expedite",count+1) 288 role.dinerData:setProperty("expedite",count+1)
262 role.dinerData:notifyUpdateProperty("expedite", count+1) 289 role.dinerData:notifyUpdateProperty("expedite", count+1)
263 local gift = reward:toNumMap() 290 local gift = reward:toNumMap()
  291 +
  292 + -- 特权卡获取加速获得额外道具
  293 + local coef = role.storeData:getProduceItemSpeedCoef()
264 for k, v in pairs(gift) do 294 for k, v in pairs(gift) do
  295 + if coef > 1 then
  296 + v = math.floor(v * coef)
  297 + gift[k] = v
  298 + end
265 if k == ItemId.Gold then 299 if k == ItemId.Gold then
266 role:checkTaskEnter("FoodSellGold", {count = v}) 300 role:checkTaskEnter("FoodSellGold", {count = v})
267 end 301 end
268 end 302 end
269 - role:award(gift, {log = {desc = "dinerSell"}}) 303 + local change
  304 + reward, change = role:award(gift, {log = {desc = "dinerSell"}})
270 305
271 306
272 role.dinerData:popularAdd(popular) 307 role.dinerData:popularAdd(popular)
@@ -276,9 +311,7 @@ function _M.expediteSellRpc( agent, data ) @@ -276,9 +311,7 @@ function _M.expediteSellRpc( agent, data )
276 end 311 end
277 role:checkTaskEnter("FoodSellQuick") 312 role:checkTaskEnter("FoodSellQuick")
278 313
279 - role:log("diner_action", {desc = "sellQ"})  
280 -  
281 - SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward,popular = popular})) 314 + SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward, change = change, popular = popular}))
282 return true 315 return true
283 end 316 end
284 317
@@ -317,7 +350,13 @@ function _M.levelUpRpc( agent, data ) @@ -317,7 +350,13 @@ function _M.levelUpRpc( agent, data )
317 role.dinerData:updateProperty({field = "buildL", value = buildL:setv(index, curLevel + 1)}) 350 role.dinerData:updateProperty({field = "buildL", value = buildL:setv(index, curLevel + 1)})
318 role:checkTaskEnter("DinerLevelUp", {type = index, level = curLevel + 1}) 351 role:checkTaskEnter("DinerLevelUp", {type = index, level = curLevel + 1})
319 352
320 - role:log("diner_action", {desc = "buildUp", int1 = index, int2 = curLevel + 1}) 353 + role:log("restaurant_up", {
  354 + restaurant_up_type = index - 1, --升级部件类型,店面:0, 接客:1, 满意度:2, 宣传:3, 广告:4, 周边:5
  355 + restaurant_up_gear = cost[ItemId.Gold] or 0, --消耗齿轮数量
  356 + restaurant_up_coin = cost[ItemId.DinerCoin] or 0, --花费美食币数量
  357 + restaurant_up_effectbef = curLevel, --升级前加成
  358 + restaurant_up_effect = curLevel + 1, --升级后加成
  359 + })
321 360
322 SendPacket(actionCodes.Diner_levelUpRpc, '') 361 SendPacket(actionCodes.Diner_levelUpRpc, '')
323 return true 362 return true
@@ -399,9 +438,14 @@ function _M.talentUpRpc( agent, data ) @@ -399,9 +438,14 @@ function _M.talentUpRpc( agent, data )
399 -- end 438 -- end
400 439
401 role:checkTaskEnter("DinerTalentUp", {type = talentData.effect:toArray(true,"=")[1], level = dishLevel + 1}) 440 role:checkTaskEnter("DinerTalentUp", {type = talentData.effect:toArray(true,"=")[1], level = dishLevel + 1})
402 -  
403 - role:log("diner_action", {desc = "talentUp", int1 = dish, int2 = dishLevel + 1})  
404 - 441 + role:finishGuide(27)
  442 + role:log("carriage_logistics", {
  443 + carriage_logistics_type = typ, -- 后勤室制作类型ID,变异:0,通常:1,魔法:2
  444 + carriage_logistics_itemid = dish, -- 后勤室升级物品或技能ID
  445 + carriage_logistics_itemlv = dishLevel + 1, -- 升级后物品或技能等级
  446 + carriage_logistics_gear = cost[ItemId.Gold] or 0, -- 后勤室升级花费齿轮数量
  447 + carriage_logistics_coin = cost[ItemId.DinerCoin] or 0, -- 后勤室升级花费美食币数量
  448 + })
405 SendPacket(actionCodes.Diner_talentUpRpc, '') 449 SendPacket(actionCodes.Diner_talentUpRpc, '')
406 return true 450 return true
407 end 451 end
@@ -435,7 +479,6 @@ function _M.skillUpRpc( agent, data ) @@ -435,7 +479,6 @@ function _M.skillUpRpc( agent, data )
435 479
436 role:costItems(cost, {log = {desc = "dinerSkillUp", int1 = skill, int2 = skillLevel + 1}}) 480 role:costItems(cost, {log = {desc = "dinerSkillUp", int1 = skill, int2 = skillLevel + 1}})
437 role.dinerData:updateProperty({field = "skillTree", value = skillTree:setv(skill, skillLevel + 1)}) 481 role.dinerData:updateProperty({field = "skillTree", value = skillTree:setv(skill, skillLevel + 1)})
438 - role:log("diner_action", {desc = "skillUp", int1 = skill, int2 = skillLevel + 1})  
439 482
440 SendPacket(actionCodes.Diner_skillUpRpc, '') 483 SendPacket(actionCodes.Diner_skillUpRpc, '')
441 return true 484 return true
@@ -463,8 +506,6 @@ function _M.lockTaskRpc( agent, data ) @@ -463,8 +506,6 @@ function _M.lockTaskRpc( agent, data )
463 end 506 end
464 role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) 507 role.dinerData:updateProperty({field = "order", value = json.encode(orders)})
465 508
466 - role:log("diner_action", {desc = "lockTask", int1 = order.id})  
467 -  
468 SendPacket(actionCodes.Diner_lockTaskRpc, MsgPack.pack({lock = order.lock})) 509 SendPacket(actionCodes.Diner_lockTaskRpc, MsgPack.pack({lock = order.lock}))
469 return true 510 return true
470 end 511 end
@@ -493,7 +534,7 @@ function _M.updateTaskRpc( agent, data ) @@ -493,7 +534,7 @@ function _M.updateTaskRpc( agent, data )
493 return 5 534 return 5
494 end 535 end
495 536
496 - 537 + local reward, change
497 if cmd == 0 then 538 if cmd == 0 then
498 if order.status ~= 0 then 539 if order.status ~= 0 then
499 return 30 540 return 30
@@ -501,8 +542,6 @@ function _M.updateTaskRpc( agent, data ) @@ -501,8 +542,6 @@ function _M.updateTaskRpc( agent, data )
501 orders[index].status = 1 542 orders[index].status = 1
502 orders[index].lock = 1 543 orders[index].lock = 1
503 544
504 - role:log("diner_action", {desc = "getTask", int1 = order.id})  
505 -  
506 role:checkTaskEnter("GetOderTask", {rarity = taskSet.rarity}) 545 role:checkTaskEnter("GetOderTask", {rarity = taskSet.rarity})
507 elseif cmd == 1 then 546 elseif cmd == 1 then
508 if order.status ~= 1 then 547 if order.status ~= 1 then
@@ -511,8 +550,6 @@ function _M.updateTaskRpc( agent, data ) @@ -511,8 +550,6 @@ function _M.updateTaskRpc( agent, data )
511 orders[index].status = 0 550 orders[index].status = 0
512 orders[index].lock = 0 551 orders[index].lock = 0
513 552
514 - role:log("diner_action", {desc = "deleteTask", int1 = order.id})  
515 -  
516 elseif cmd == 2 then 553 elseif cmd == 2 then
517 if order.status ~= 1 then 554 if order.status ~= 1 then
518 return 32 555 return 32
@@ -520,17 +557,24 @@ function _M.updateTaskRpc( agent, data ) @@ -520,17 +557,24 @@ function _M.updateTaskRpc( agent, data )
520 if order.n < taskData.value then 557 if order.n < taskData.value then
521 return 6 558 return 6
522 end 559 end
523 - role:log("diner_action", {desc = "finishTask", int1 = order.id})  
524 560
525 - role:award(taskData.reward, {log = {desc = "dinerFinishTask", int1 = order.id}}) 561 + reward, change = role:award(taskData.reward, {log = {desc = "dinerFinishTask", int1 = order.id}})
526 table.remove(orders,index) 562 table.remove(orders,index)
527 role:checkTaskEnter("OverOderTask", {rarity = taskSet.rarity}) 563 role:checkTaskEnter("OverOderTask", {rarity = taskSet.rarity})
528 else 564 else
529 return 33 565 return 33
530 end 566 end
531 567
  568 +
  569 + role:log("restaurant_order", {
  570 + restaurant_order_id = order.id, -- 订单任务ID
  571 + restaurant_order_status = cmd, -- 订单任务状态,接受:0, 拒绝:1, 完成:2
  572 + restaurant_order_rwd = reward, -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….}
  573 + restaurant_order_lv = taskSet.rarity, -- 订单品质等级,普通:0, 稀有:1, 顶级:2, 豪华:3
  574 + })
  575 +
532 role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) 576 role.dinerData:updateProperty({field = "order", value = json.encode(orders)})
533 - SendPacket(actionCodes.Diner_updateTaskRpc, '') 577 + SendPacket(actionCodes.Diner_updateTaskRpc, MsgPack.pack({reward = reward, change = change}))
534 return true 578 return true
535 end 579 end
536 580
@@ -603,8 +647,7 @@ function _M.refreshTaskRpc( agent, data ) @@ -603,8 +647,7 @@ function _M.refreshTaskRpc( agent, data )
603 end 647 end
604 end 648 end
605 649
606 - role:log("diner_action", {desc = "reTask"})  
607 - 650 + role:finishGuide(41)
608 role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) 651 role.dinerData:updateProperty({field = "order", value = json.encode(orders)})
609 652
610 SendPacket(actionCodes.Diner_refreshTaskRpc, '') 653 SendPacket(actionCodes.Diner_refreshTaskRpc, '')
@@ -644,8 +687,7 @@ function _M.addWantFoodRpc(agent , data) @@ -644,8 +687,7 @@ function _M.addWantFoodRpc(agent , data)
644 gfood[slot] = {id = itemId, st = skynet.timex()} 687 gfood[slot] = {id = itemId, st = skynet.timex()}
645 end 688 end
646 689
647 - role:log("diner_action", {desc = "wantFood"})  
648 - 690 + role:finishGuide(36)
649 role.dinerData:updateProperty({field = "gfood", value = gfood}) 691 role.dinerData:updateProperty({field = "gfood", value = gfood})
650 692
651 SendPacket(actionCodes.Diner_addWantFoodRpc, '') 693 SendPacket(actionCodes.Diner_addWantFoodRpc, '')
@@ -679,14 +721,21 @@ function _M.getGreenhouseRpc( agent, data ) @@ -679,14 +721,21 @@ function _M.getGreenhouseRpc( agent, data )
679 else 721 else
680 gfood[k].st = st + speed * reward[itemId] 722 gfood[k].st = st + speed * reward[itemId]
681 end 723 end
  724 +
  725 + role:log("restaurant_material", {
  726 + item_id = itemId, -- 获取物品ID
  727 + restaurant_material_start = st, -- 申请获取时间
  728 + restaurant_material_time = endTime2 - st, -- 申请到领取耗时
  729 + restaurant_material_num = reward[itemId], -- 获取物品数量
  730 + })
  731 +
682 end 732 end
683 role.dinerData:updateProperty({field = "gfood", value = gfood}) 733 role.dinerData:updateProperty({field = "gfood", value = gfood})
684 - local reward = role:award(reward, {log = {desc = "greenHourse", int1 = level}}) 734 + local reward, change = role:award(reward, {log = {desc = "greenHourse", int1 = level}})
685 role:checkTaskEnter("FoodMGet") 735 role:checkTaskEnter("FoodMGet")
686 736
687 - role:log("diner_action", {desc = "greenHourse"})  
688 737
689 - SendPacket(actionCodes.Diner_getGreenhouseRpc, MsgPack.pack({reward = reward})) 738 + SendPacket(actionCodes.Diner_getGreenhouseRpc, MsgPack.pack({reward = reward, change = change}))
690 return true 739 return true
691 end 740 end
692 741
@@ -798,7 +847,7 @@ function _M.entrustRpc(agent , data) @@ -798,7 +847,7 @@ function _M.entrustRpc(agent , data)
798 local entrustId = entrust[1] 847 local entrustId = entrust[1]
799 if not entrustId then return end 848 if not entrustId then return end
800 849
801 - local reward 850 + local reward, change
802 if ctype == 1 then -- 完成 851 if ctype == 1 then -- 完成
803 local curData = csvdb["diner_missionCsv"][entrustId] 852 local curData = csvdb["diner_missionCsv"][entrustId]
804 if not curData then return end 853 if not curData then return end
@@ -813,7 +862,7 @@ function _M.entrustRpc(agent , data) @@ -813,7 +862,7 @@ function _M.entrustRpc(agent , data)
813 return 862 return
814 end 863 end
815 864
816 - reward = role:award(curData.reward, {log = {desc = "dinerEntrus", int1 = entrustId}}) 865 + reward, change = role:award(curData.reward, {log = {desc = "dinerEntrus", int1 = entrustId}})
817 table.remove(entrust, 1) 866 table.remove(entrust, 1)
818 elseif ctype == 2 then -- 放弃 867 elseif ctype == 2 then -- 放弃
819 table.remove(entrust, 1) 868 table.remove(entrust, 1)
@@ -822,9 +871,9 @@ function _M.entrustRpc(agent , data) @@ -822,9 +871,9 @@ function _M.entrustRpc(agent , data)
822 end 871 end
823 role.dinerData:updateProperty({field = "entrust", value = entrust}) 872 role.dinerData:updateProperty({field = "entrust", value = entrust})
824 873
825 - role:log("diner_action", {desc = "entrus", short1 = ctype, int1 = entrustId}) 874 + role:finishGuide(26)
826 875
827 - SendPacket(actionCodes.Diner_entrustRpc, MsgPack.pack({reward = reward})) 876 + SendPacket(actionCodes.Diner_entrustRpc, MsgPack.pack({reward = reward, change = change}))
828 return true 877 return true
829 end 878 end
830 879
@@ -845,12 +894,22 @@ function _M.collectRpc(agent , data) @@ -845,12 +894,22 @@ function _M.collectRpc(agent , data)
845 for slot, _ in pairs(sells) do 894 for slot, _ in pairs(sells) do
846 role.dinerData:updateSell(slot) 895 role.dinerData:updateSell(slot)
847 end 896 end
848 - local reward = role:award(customerData.reward, {log = {desc = "dinerCollect", int1 = id}}) 897 + local reward, change = role:award(customerData.reward, {log = {desc = "dinerCollect", int1 = id}})
849 customer[id] = 1 898 customer[id] = 1
850 role.dinerData:updateProperty({field = "customer", value = customer}) -- 解锁了 899 role.dinerData:updateProperty({field = "customer", value = customer}) -- 解锁了
851 - role:log("diner_action", {desc = "collect", int1 = id})  
852 900
853 - SendPacket(actionCodes.Diner_collectRpc, MsgPack.pack({reward = reward})) 901 + local count = 0
  902 + for c_, v in pairs(customer) do
  903 + count = count + 1
  904 + end
  905 +
  906 + role:log("restaurant_collect", {
  907 + restaurant_collect_id = id, -- 图谱收集ID
  908 + restaurant_collect_rwd = reward, -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….}
  909 + restaurant_collect_plan = count, -- 收集进度,即解锁顾客,数字表示
  910 + })
  911 +
  912 + SendPacket(actionCodes.Diner_collectRpc, MsgPack.pack({reward = reward, change = change}))
854 return true 913 return true
855 end 914 end
856 915
@@ -874,13 +933,11 @@ function _M.comboRewardRpc(agent , data) @@ -874,13 +933,11 @@ function _M.comboRewardRpc(agent , data)
874 end 933 end
875 934
876 comboStatus[id] = 1 935 comboStatus[id] = 1
877 - local reward = role:award(comboData.reward, {log = {desc = "dinerCombo", int1 = id}}) 936 + local reward, change = role:award(comboData.reward, {log = {desc = "dinerCombo", int1 = id}})
878 937
879 role.dinerData:updateProperty({field = "comboStatus", value = comboStatus}) -- 解锁了 938 role.dinerData:updateProperty({field = "comboStatus", value = comboStatus}) -- 解锁了
880 939
881 - role:log("diner_action", {desc = "combo", int1 = id})  
882 -  
883 - SendPacket(actionCodes.Diner_comboRewardRpc, MsgPack.pack({reward = reward})) 940 + SendPacket(actionCodes.Diner_comboRewardRpc, MsgPack.pack({reward = reward, change = change}))
884 return true 941 return true
885 end 942 end
886 943
src/actions/EmailAction.lua
@@ -53,7 +53,6 @@ function _M.listRpc(agent, data) @@ -53,7 +53,6 @@ function _M.listRpc(agent, data)
53 content = email.content, 53 content = email.content,
54 attachments = email.attachments 54 attachments = email.attachments
55 }) 55 })
56 - role:log("mail_action", {desc = "get_global", key1 = email.title, key2 = email.attachments})  
57 end 56 end
58 end 57 end
59 end 58 end
@@ -86,28 +85,23 @@ function _M.drawAllAttachRpc(agent, data) @@ -86,28 +85,23 @@ function _M.drawAllAttachRpc(agent, data)
86 local role = agent.role 85 local role = agent.role
87 local roleId = role:getProperty("id") 86 local roleId = role:getProperty("id")
88 87
89 - local reward = {} 88 + local reward, change = {}
90 local ids = {} 89 local ids = {}
91 90
92 local emails = loadEmails(roleId) 91 local emails = loadEmails(roleId)
93 - redisproxy:pipelining(function (red)  
94 - for _, email in ipairs(emails) do  
95 - local attachments = getEmailAttachments(email)  
96 - if attachments ~= "" then  
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  
100 - 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})  
102 -  
103 - for key, v in pairs(items) do  
104 - reward[key] = (reward[key] or 0) + v  
105 - end 92 + for _, email in ipairs(emails) do
  93 + local attachments = getEmailAttachments(email)
  94 + if attachments ~= "" then
  95 + email:setProperty("status", 2)
  96 + email:log(role, 2)
  97 + ids[email:getProperty("id")] = 1
  98 + for key, v in pairs(attachments:toNumMap()) do
  99 + reward[key] = (reward[key] or 0) + v
106 end 100 end
107 end 101 end
108 - end)  
109 -  
110 - SendPacket(actionCodes.Email_drawAllAttachRpc, MsgPack.pack({ids = ids, reward = reward})) 102 + end
  103 + reward, change = role:award(reward, {log = {desc = "draw_attach"}})
  104 + SendPacket(actionCodes.Email_drawAllAttachRpc, MsgPack.pack({ids = ids, reward = reward, change = change}))
111 return true 105 return true
112 end 106 end
113 107
@@ -125,11 +119,11 @@ function _M.drawAttachRpc(agent, data) @@ -125,11 +119,11 @@ function _M.drawAttachRpc(agent, data)
125 local attachments = getEmailAttachments(email) 119 local attachments = getEmailAttachments(email)
126 if attachments == "" then return end 120 if attachments == "" then return end
127 121
128 - local reward = role:award(attachments, {log = {desc = "draw_attach", int1 = emailId, key1 = email:getProperty("title")}})  
129 - redisproxy:hset(rds, "status", 2) -- 领取标记  
130 - SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward})) 122 + local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = emailId}})
  123 + email:setProperty("status", 2)
  124 + email:log(role, 2)
  125 + SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change}))
131 126
132 - role:log("mail_action", {desc = "draw_attach", int1 = id, key1 = email:getProperty("title"), key2 = attachments})  
133 return true 127 return true
134 end 128 end
135 129
@@ -140,11 +134,12 @@ function _M.checkRpc(agent, data) @@ -140,11 +134,12 @@ function _M.checkRpc(agent, data)
140 local msg = MsgPack.unpack(data) 134 local msg = MsgPack.unpack(data)
141 local id = msg.id 135 local id = msg.id
142 136
143 - local rds = string.format(R_EMAIL_ITEM, roleId, id)  
144 - if not redisproxy:exists(rds) then return end 137 + local emailRds = string.format("email:%d:%s", roleId, id)
  138 + local email = require("models.Email").new({key = emailRds})
  139 + if not email:load() then return end
145 140
146 - redisproxy:hset(rds, "status", 1)  
147 - role:log("mail_action", {desc = "check_mail", int1 = id}) 141 + email:setProperty("status", 1)
  142 + email:log(role, 1)
148 143
149 SendPacket(actionCodes.Email_checkRpc, '') 144 SendPacket(actionCodes.Email_checkRpc, '')
150 return true 145 return true
@@ -172,6 +167,7 @@ function _M.delRpc(agent, data) @@ -172,6 +167,7 @@ function _M.delRpc(agent, data)
172 attachments = emailData.attachment 167 attachments = emailData.attachment
173 end 168 end
174 if status == 2 or (status == 1 and attachments:len() == 0) then 169 if status == 2 or (status == 1 and attachments:len() == 0) then
  170 + email:log(role, 3)
175 red:lrem(rds, 0, id) 171 red:lrem(rds, 0, id)
176 red:del(emailRds) 172 red:del(emailRds)
177 result[tonum(id)] = 1 173 result[tonum(id)] = 1
@@ -179,9 +175,6 @@ function _M.delRpc(agent, data) @@ -179,9 +175,6 @@ function _M.delRpc(agent, data)
179 end 175 end
180 end 176 end
181 end) 177 end)
182 - for delId, _ in ipairs(result) do  
183 - role:log("mail_action", {desc = "del_mail", int1 = delId})  
184 - end  
185 SendPacket(actionCodes.Email_delRpc, MsgPack.pack({result = result})) 178 SendPacket(actionCodes.Email_delRpc, MsgPack.pack({result = result}))
186 return true 179 return true
187 end 180 end
src/actions/FriendAction.lua
@@ -111,7 +111,6 @@ function _M.searchRpc(agent, data) @@ -111,7 +111,6 @@ function _M.searchRpc(agent, data)
111 })) 111 }))
112 end 112 end
113 113
114 - role:log("role_action", {desc = "searchFriend"})  
115 SendPacket(actionCodes.Friend_searchRpc, MsgPack.pack({searchList = searchList})) 114 SendPacket(actionCodes.Friend_searchRpc, MsgPack.pack({searchList = searchList}))
116 return true 115 return true
117 end 116 end
@@ -178,8 +177,6 @@ function _M.applyRpc(agent, data) @@ -178,8 +177,6 @@ function _M.applyRpc(agent, data)
178 myInfo.online = true 177 myInfo.online = true
179 myInfo.hadApply = true 178 myInfo.hadApply = true
180 179
181 - role:log("role_action", {desc = "addFriend", int1 = 1})  
182 -  
183 rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({newApply = 1, info = {myInfo}})) -- 通知对方 180 rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({newApply = 1, info = {myInfo}})) -- 通知对方
184 end 181 end
185 182
@@ -217,6 +214,7 @@ local function checkHandleApply(roleId, objectId, needAddNew) @@ -217,6 +214,7 @@ local function checkHandleApply(roleId, objectId, needAddNew)
217 red:sismember(FRIEND_BLACK_KEY:format(objectId), roleId) 214 red:sismember(FRIEND_BLACK_KEY:format(objectId), roleId)
218 red:sismember(FRIEND_BLACK_KEY:format(roleId), objectId) 215 red:sismember(FRIEND_BLACK_KEY:format(roleId), objectId)
219 end) 216 end)
  217 +
220 --自己好友满了 218 --自己好友满了
221 if (redret[1] + needAddNew) >= globalCsv.friendListLimit then 219 if (redret[1] + needAddNew) >= globalCsv.friendListLimit then
222 return 1 220 return 1
@@ -233,6 +231,8 @@ local function checkHandleApply(roleId, objectId, needAddNew) @@ -233,6 +231,8 @@ local function checkHandleApply(roleId, objectId, needAddNew)
233 if redret[4] == 1 then 231 if redret[4] == 1 then
234 return 4 232 return 4
235 end 233 end
  234 +
  235 + return nil, redret[1]
236 end 236 end
237 237
238 function _M.handleApplyRpc(agent, data) 238 function _M.handleApplyRpc(agent, data)
@@ -251,7 +251,8 @@ function _M.handleApplyRpc(agent, data) @@ -251,7 +251,8 @@ function _M.handleApplyRpc(agent, data)
251 if not redisproxy:zscore(FRIEND_APPLY_KEY:format(roleId), objectId) then 251 if not redisproxy:zscore(FRIEND_APPLY_KEY:format(roleId), objectId) then
252 return 252 return
253 end 253 end
254 - result = checkHandleApply(roleId, objectId) 254 + local curCount
  255 + result, curCount = checkHandleApply(roleId, objectId)
255 256
256 if not result then 257 if not result then
257 redisproxy:pipelining(function (red) 258 redisproxy:pipelining(function (red)
@@ -277,8 +278,11 @@ function _M.handleApplyRpc(agent, data) @@ -277,8 +278,11 @@ function _M.handleApplyRpc(agent, data)
277 otherInfo.pGet = redret[2] == 1 and 1 or nil 278 otherInfo.pGet = redret[2] == 1 and 1 or nil
278 SendPacket(actionCodes.Friend_updateProperty, MsgPack.pack({newFriend = 1, info = {otherInfo}})) 279 SendPacket(actionCodes.Friend_updateProperty, MsgPack.pack({newFriend = 1, info = {otherInfo}}))
279 280
280 - role:log("role_action", {desc = "addFriend", int1 = 1})  
281 - 281 + role:log("friend_opt", {
  282 + friend_opt_type = 100, -- 好友操作类型,见枚举表中 好友操作类型枚举表
  283 + friend_roleid = objectId, -- 好友账户下的角色id
  284 + friend_cnt = curCount + 1, -- 操作后好友数量
  285 + })
282 end 286 end
283 287
284 elseif cmd == 0 then -- 不同意 288 elseif cmd == 0 then -- 不同意
@@ -301,7 +305,7 @@ function _M.handleApplyRpc(agent, data) @@ -301,7 +305,7 @@ function _M.handleApplyRpc(agent, data)
301 local needAddInfo = {} 305 local needAddInfo = {}
302 for _, objId in ipairs(allIds) do 306 for _, objId in ipairs(allIds) do
303 objId = tonumber(objId) 307 objId = tonumber(objId)
304 - local cr = checkHandleApply(roleId, objId, #needAdd) 308 + local cr, curCount = checkHandleApply(roleId, objId, #needAdd)
305 if not cr then 309 if not cr then
306 table.insert(needAdd, objId) 310 table.insert(needAdd, objId)
307 table.insert(needAddMy, objId) 311 table.insert(needAddMy, objId)
@@ -312,6 +316,12 @@ function _M.handleApplyRpc(agent, data) @@ -312,6 +316,12 @@ function _M.handleApplyRpc(agent, data)
312 otherInfo.isFriend = true 316 otherInfo.isFriend = true
313 otherInfo.pGet = fpoint[objId] and 1 or nil 317 otherInfo.pGet = fpoint[objId] and 1 or nil
314 table.insert(needAddInfo, otherInfo) 318 table.insert(needAddInfo, otherInfo)
  319 +
  320 + role:log("friend_opt", {
  321 + friend_opt_type = 100, -- 好友操作类型,见枚举表中 好友操作类型枚举表
  322 + friend_roleid = objId, -- 好友账户下的角色id
  323 + friend_cnt = curCount + 1, -- 操作后好友数量
  324 + })
315 end 325 end
316 end 326 end
317 327
@@ -337,8 +347,6 @@ function _M.handleApplyRpc(agent, data) @@ -337,8 +347,6 @@ function _M.handleApplyRpc(agent, data)
337 rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({newFriend = 1, info = {myInfo}})) -- 通知对方 347 rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({newFriend = 1, info = {myInfo}})) -- 通知对方
338 end 348 end
339 if next(needAdd) then 349 if next(needAdd) then
340 - role:log("role_action", {desc = "addFriend", int1 = #needAdd})  
341 -  
342 SendPacket(actionCodes.Friend_updateProperty, MsgPack.pack({newFriend = 1, info = needAddInfo})) 350 SendPacket(actionCodes.Friend_updateProperty, MsgPack.pack({newFriend = 1, info = needAddInfo}))
343 else 351 else
344 result = 1 352 result = 1
@@ -420,6 +428,11 @@ function _M.deleteRpc(agent, data) @@ -420,6 +428,11 @@ function _M.deleteRpc(agent, data)
420 end 428 end
421 rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({deleteFriend = 1, roleId = roleId})) 429 rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({deleteFriend = 1, roleId = roleId}))
422 430
  431 + role:log("friend_opt", {
  432 + friend_opt_type = 200, -- 好友操作类型,见枚举表中 好友操作类型枚举表
  433 + friend_roleid = objectId, -- 好友账户下的角色id
  434 + friend_cnt = 0, -- 操作后好友数量
  435 + })
423 SendPacket(actionCodes.Friend_deleteRpc, MsgPack.pack("")) 436 SendPacket(actionCodes.Friend_deleteRpc, MsgPack.pack(""))
424 return true 437 return true
425 end 438 end
@@ -449,15 +462,18 @@ function _M.blockRpc(agent, data) @@ -449,15 +462,18 @@ function _M.blockRpc(agent, data)
449 red:ZREM(FRIEND_APPLY_KEY:format(objectId), roleId) 462 red:ZREM(FRIEND_APPLY_KEY:format(objectId), roleId)
450 red:sadd(FRIEND_BLACK_KEY:format(roleId), objectId) 463 red:sadd(FRIEND_BLACK_KEY:format(roleId), objectId)
451 end) 464 end)
452 - rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({deleteFriend = 1, roleId = roleId}))  
453 - 465 + rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({deleteFriend = 1, roleId = roleId}))
  466 + role:log("friend_opt", {
  467 + friend_opt_type = 300, -- 好友操作类型,见枚举表中 好友操作类型枚举表
  468 + friend_roleid = objectId, -- 好友账户下的角色id
  469 + friend_cnt = 0, -- 操作后好友数量
  470 + })
454 end 471 end
455 elseif cmd == 2 then 472 elseif cmd == 2 then
456 redisproxy:SREM(FRIEND_BLACK_KEY:format(roleId), objectId) 473 redisproxy:SREM(FRIEND_BLACK_KEY:format(roleId), objectId)
457 else 474 else
458 return 475 return
459 end 476 end
460 -  
461 SendPacket(actionCodes.Friend_blockRpc, MsgPack.pack({result = result})) 477 SendPacket(actionCodes.Friend_blockRpc, MsgPack.pack({result = result}))
462 return true 478 return true
463 end 479 end
@@ -537,8 +553,6 @@ function _M.pointRpc(agent, data) @@ -537,8 +553,6 @@ function _M.pointRpc(agent, data)
537 role.dailyData:updateProperty({field = "giveFP", value = giveP}) 553 role.dailyData:updateProperty({field = "giveFP", value = giveP})
538 role:checkTaskEnter("GiveFriendP", {count = 1}) 554 role:checkTaskEnter("GiveFriendP", {count = 1})
539 rpcRole(objId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({newPoint = 1, roleId = roleId})) 555 rpcRole(objId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({newPoint = 1, roleId = roleId}))
540 -  
541 - role:log("role_action", {desc = "giveFPoint", int1 = 1})  
542 end 556 end
543 elseif cmd == 2 then -- 领取 557 elseif cmd == 2 then -- 领取
544 local objId = msg.roleId 558 local objId = msg.roleId
@@ -558,7 +572,6 @@ function _M.pointRpc(agent, data) @@ -558,7 +572,6 @@ function _M.pointRpc(agent, data)
558 role.dailyData:updateProperty({field = "getFP", value = getP}) 572 role.dailyData:updateProperty({field = "getFP", value = getP})
559 role:checkTaskEnter("GetFriendP", {count = 1}) 573 role:checkTaskEnter("GetFriendP", {count = 1})
560 574
561 - role:log("role_action", {desc = "getFPoint", int1 = 1})  
562 end 575 end
563 elseif cmd == 3 then -- 一键赠送领取 576 elseif cmd == 3 then -- 一键赠送领取
564 -- 赠送 577 -- 赠送
@@ -580,8 +593,6 @@ function _M.pointRpc(agent, data) @@ -580,8 +593,6 @@ function _M.pointRpc(agent, data)
580 role.dailyData:updateProperty({field = "giveFP", value = giveP}) 593 role.dailyData:updateProperty({field = "giveFP", value = giveP})
581 role:checkTaskEnter("GiveFriendP", {count = change}) 594 role:checkTaskEnter("GiveFriendP", {count = change})
582 595
583 - role:log("role_action", {desc = "giveFPoint", int1 = change})  
584 -  
585 else 596 else
586 result = 1 597 result = 1
587 end 598 end
@@ -606,7 +617,6 @@ function _M.pointRpc(agent, data) @@ -606,7 +617,6 @@ function _M.pointRpc(agent, data)
606 reward = role:award({[ItemId.FriendPoint] = getCount}, {log = {desc = "friendPoint"}}) 617 reward = role:award({[ItemId.FriendPoint] = getCount}, {log = {desc = "friendPoint"}})
607 role.dailyData:updateProperty({field = "getFP", value = getP}) 618 role.dailyData:updateProperty({field = "getFP", value = getP})
608 role:checkTaskEnter("GetFriendP", {count = getCount}) 619 role:checkTaskEnter("GetFriendP", {count = getCount})
609 - role:log("role_action", {desc = "getFPoint", int1 = getCount})  
610 else 620 else
611 result = (result or 0) + 2 621 result = (result or 0) + 2
612 end 622 end
src/actions/GmAction.lua
@@ -27,7 +27,6 @@ function _M.ignoreout(role, pms) @@ -27,7 +27,6 @@ function _M.ignoreout(role, pms)
27 else -- 解除 27 else -- 解除
28 role:updateProperty({field = "ignoreMt", value = 0}) 28 role:updateProperty({field = "ignoreMt", value = 0})
29 end 29 end
30 - role:log("gm_action", {desc = "ignoreout", key1 = pms.sender})  
31 return "指令生效" 30 return "指令生效"
32 end 31 end
33 32
@@ -47,17 +46,11 @@ function _M.ban(role, pms) @@ -47,17 +46,11 @@ function _M.ban(role, pms)
47 end) 46 end)
48 end 47 end
49 end 48 end
50 -  
51 - role:log("gm_action", {desc = "ban", int1 = time, int2 = ctype, key1 = pms.sender})  
52 -  
53 return isBan and "解封杀成功" or "封杀成功" 49 return isBan and "解封杀成功" or "封杀成功"
54 end 50 end
55 51
56 function _M.unban(role, pms) 52 function _M.unban(role, pms)
57 role:setBan(0, 0) 53 role:setBan(0, 0)
58 -  
59 - role:log("gm_action", {desc = "unban", key1 = pms.sender})  
60 -  
61 return "解封杀成功" 54 return "解封杀成功"
62 end 55 end
63 56
@@ -70,8 +63,6 @@ function _M.gmmsg(role, pms) @@ -70,8 +63,6 @@ function _M.gmmsg(role, pms)
70 skynet.call(agent.gate_serv, "lua", "forcekick", agent.fd) 63 skynet.call(agent.gate_serv, "lua", "forcekick", agent.fd)
71 end) 64 end)
72 end 65 end
73 - role:log("gm_action", {desc = "gmmsg", text1 = pms.pm1, key1 = pms.sender})  
74 -  
75 return "指令成功" 66 return "指令成功"
76 end 67 end
77 68
@@ -82,8 +73,6 @@ function _M.silent(role, pms) @@ -82,8 +73,6 @@ function _M.silent(role, pms)
82 return "解禁言成功" 73 return "解禁言成功"
83 end 74 end
84 role:updateProperty({field = "silent", value = specTime({hour = 0}, skynet.timex()) + pm1 * 86400}) 75 role:updateProperty({field = "silent", value = specTime({hour = 0}, skynet.timex()) + pm1 * 86400})
85 -  
86 - role:log("gm_action", {desc = "silent", int1 = pms.pm1, key1 = pms.sender})  
87 return "禁言成功" 76 return "禁言成功"
88 end 77 end
89 78
@@ -101,8 +90,6 @@ function _M.hero(role, pms) @@ -101,8 +90,6 @@ function _M.hero(role, pms)
101 if not role:addHero({type = heroType, log = {desc = "gm"}}) then 90 if not role:addHero({type = heroType, log = {desc = "gm"}}) then
102 return "失败" 91 return "失败"
103 end 92 end
104 -  
105 - role:log("gm_action", {desc = "hero", int1 = heroType, key1 = pms.sender})  
106 return "成功" 93 return "成功"
107 end 94 end
108 95
@@ -135,8 +122,6 @@ function _M.herol(role, pms) @@ -135,8 +122,6 @@ function _M.herol(role, pms)
135 hero:updateProperty({field = "level", delta = addLevel}) 122 hero:updateProperty({field = "level", delta = addLevel})
136 role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")}) 123 role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")})
137 124
138 - role:log("gm_action", {desc = "herol", int1 = heroType, int2 = addLevel, key1 = pms.sender})  
139 -  
140 return "成功" 125 return "成功"
141 end 126 end
142 127
@@ -148,8 +133,6 @@ function _M.herola(role, pms) @@ -148,8 +133,6 @@ function _M.herola(role, pms)
148 _M.herol(role, {pm1 = hero:getProperty("type"), pm2 = addLevel}) 133 _M.herol(role, {pm1 = hero:getProperty("type"), pm2 = addLevel})
149 end 134 end
150 135
151 - role:log("gm_action", {desc = "herola", int1 = addLevel, key1 = pms.sender})  
152 -  
153 return "成功" 136 return "成功"
154 end 137 end
155 138
@@ -160,7 +143,6 @@ function _M.equip(role, pms) @@ -160,7 +143,6 @@ function _M.equip(role, pms)
160 local level = tonum(pms.pm2) 143 local level = tonum(pms.pm2)
161 local count = tonum(pms.pm3) 144 local count = tonum(pms.pm3)
162 role:addEquip(typ, level, count, {log = {desc = "gm"}}) 145 role:addEquip(typ, level, count, {log = {desc = "gm"}})
163 - role:log("gm_action", {desc = "equip", int1 = typ, int2 = level, long1 = count, key1 = pms.sender})  
164 return "成功" 146 return "成功"
165 end 147 end
166 148
@@ -169,7 +151,6 @@ function _M.rune(role, pms) @@ -169,7 +151,6 @@ function _M.rune(role, pms)
169 local typ = tonum(pms.pm1) 151 local typ = tonum(pms.pm1)
170 local id = tonum(pms.pm2) 152 local id = tonum(pms.pm2)
171 local result = role:addRune({type = typ,id = id, log = {desc = "gm"}}) 153 local result = role:addRune({type = typ,id = id, log = {desc = "gm"}})
172 - role:log("gm_action", {desc = "rune", int1 = typ, int2 = id, key1 = pms.sender})  
173 154
174 return result 155 return result
175 end 156 end
@@ -190,8 +171,6 @@ function _M.fb(role, pms) -- 直接通关 @@ -190,8 +171,6 @@ function _M.fb(role, pms) -- 直接通关
190 role:hangFinish(carbonId) 171 role:hangFinish(carbonId)
191 addPre(carbonId) 172 addPre(carbonId)
192 173
193 - role:log("gm_action", {desc = "fb", int1 = carbonId, key1 = pms.sender})  
194 -  
195 role:checkTaskEnter("HangPass", {id = carbonId}) 174 role:checkTaskEnter("HangPass", {id = carbonId})
196 return "成功" 175 return "成功"
197 end 176 end
@@ -212,8 +191,6 @@ function _M.fbc(role, pms) -- 直接通关 @@ -212,8 +191,6 @@ function _M.fbc(role, pms) -- 直接通关
212 end 191 end
213 role:updateProperty({field = "hangPass", value = {}}) 192 role:updateProperty({field = "hangPass", value = {}})
214 addPre(carbonId) 193 addPre(carbonId)
215 -  
216 - role:log("gm_action", {desc = "fbc", int1 = carbonId, key1 = pms.sender})  
217 194
218 return "成功" 195 return "成功"
219 end 196 end
@@ -247,8 +224,6 @@ function _M.exp(role, pms) @@ -247,8 +224,6 @@ function _M.exp(role, pms)
247 exp = math.floor(math.max(exp, 0)) 224 exp = math.floor(math.max(exp, 0))
248 role:addPlayExp(exp, {log = {desc = "gm"}}) 225 role:addPlayExp(exp, {log = {desc = "gm"}})
249 226
250 - role:log("gm_action", {desc = "exp", int1 = exp, key1 = pms.sender})  
251 -  
252 return "成功" 227 return "成功"
253 end 228 end
254 229
@@ -305,7 +280,6 @@ function _M.get(role, pms) @@ -305,7 +280,6 @@ function _M.get(role, pms)
305 end 280 end
306 local count = tonum(pms.pm2, 1) 281 local count = tonum(pms.pm2, 1)
307 role:award({[itemId] = count}, {log = {desc = "gm"}}) 282 role:award({[itemId] = count}, {log = {desc = "gm"}})
308 - role:log("gm_action", {desc = "get", int1 = itemId, int2 = count, key1 = pms.sender})  
309 end 283 end
310 return "成功" 284 return "成功"
311 end 285 end
@@ -329,9 +303,6 @@ function _M.advc(role, pms) @@ -329,9 +303,6 @@ function _M.advc(role, pms)
329 advAFWear = {}, 303 advAFWear = {},
330 }, notNotify) 304 }, notNotify)
331 role.advData = nil 305 role.advData = nil
332 -  
333 - role:log("gm_action", {desc = "advc", key1 = pms.sender})  
334 -  
335 return "成功" 306 return "成功"
336 end 307 end
337 308
@@ -340,8 +311,6 @@ function _M.advf(role, pms) @@ -340,8 +311,6 @@ function _M.advf(role, pms)
340 role:updateProperty({field = "advC", value = 0}) 311 role:updateProperty({field = "advC", value = 0})
341 role.dailyData:updateProperty({field = "advElC", value = 0}) 312 role.dailyData:updateProperty({field = "advElC", value = 0})
342 313
343 - role:log("gm_action", {desc = "advf", key1 = pms.sender})  
344 -  
345 return "成功" 314 return "成功"
346 end 315 end
347 316
@@ -361,7 +330,6 @@ function _M.adv(role, pms) @@ -361,7 +330,6 @@ function _M.adv(role, pms)
361 advPass[chapterId] = layer 330 advPass[chapterId] = layer
362 role:updateProperty({field = "advPass", value = advPass}) 331 role:updateProperty({field = "advPass", value = advPass})
363 end 332 end
364 - role:log("gm_action", {desc = "adv", int1 = chapterId, int2 = layer, key1 = pms.sender})  
365 333
366 return "成功" 334 return "成功"
367 end 335 end
@@ -388,7 +356,6 @@ function _M.advt(role, pms) @@ -388,7 +356,6 @@ function _M.advt(role, pms)
388 isEnter = true, 356 isEnter = true,
389 debugMapId = mapId, 357 debugMapId = mapId,
390 }) 358 })
391 - role:log("gm_action", {desc = "advt", int1 = chapterId, int2 = layer, key1 = pms.sender})  
392 return "成功" 359 return "成功"
393 end 360 end
394 361
@@ -397,8 +364,6 @@ function _M.advl(role, pms) @@ -397,8 +364,6 @@ function _M.advl(role, pms)
397 local exp = tonum(pms.pm1) 364 local exp = tonum(pms.pm1)
398 role:addAdvLvExp(math.max(0, exp)) 365 role:addAdvLvExp(math.max(0, exp))
399 366
400 - role:log("gm_action", {desc = "advl", int1 = exp, key1 = pms.sender})  
401 -  
402 return "成功" 367 return "成功"
403 end 368 end
404 369
@@ -412,7 +377,6 @@ function _M.advcl(role, pms) @@ -412,7 +377,6 @@ function _M.advcl(role, pms)
412 end 377 end
413 advData.battle.player:addExp(exp) 378 advData.battle.player:addExp(exp)
414 advData:saveDB() 379 advData:saveDB()
415 - role:log("gm_action", {desc = "advcl", int1 = exp, key1 = pms.sender})  
416 380
417 return "成功" 381 return "成功"
418 end 382 end
@@ -422,7 +386,6 @@ function _M.idlec(role, pms) @@ -422,7 +386,6 @@ function _M.idlec(role, pms)
422 role:updateProperty({field = "hangTeam", value = {}}) 386 role:updateProperty({field = "hangTeam", value = {}})
423 role:updateProperty({field = "hangInfo", value = {}}) 387 role:updateProperty({field = "hangInfo", value = {}})
424 role:updateProperty({field = "hangBag", value = {}}) 388 role:updateProperty({field = "hangBag", value = {}})
425 - role:log("gm_action", {desc = "idlec", key1 = pms.sender})  
426 389
427 role.advData = nil 390 role.advData = nil
428 return "成功" 391 return "成功"
@@ -447,8 +410,6 @@ function _M.advit(role, pms) @@ -447,8 +410,6 @@ function _M.advit(role, pms)
447 local itemId = tonum(pms.pm1) 410 local itemId = tonum(pms.pm1)
448 local count = tonum(pms.pm2) 411 local count = tonum(pms.pm2)
449 reward[itemId] = count 412 reward[itemId] = count
450 -  
451 - role:log("gm_action", {desc = "advit", int1 = itemId, int2 = count, key1 = pms.sender})  
452 end 413 end
453 414
454 415
@@ -464,8 +425,6 @@ function _M.tower(role, pms) @@ -464,8 +425,6 @@ function _M.tower(role, pms)
464 if not csvdb["tower_battleCsv"][level] then return "不存在" end 425 if not csvdb["tower_battleCsv"][level] then return "不存在" end
465 role:updateProperty({field = "towerInfo", value = {c = globalCsv.tower_count_limit, l = level}}) 426 role:updateProperty({field = "towerInfo", value = {c = globalCsv.tower_count_limit, l = level}})
466 427
467 - role:log("gm_action", {desc = "tower", int1 = level, key1 = pms.sender})  
468 -  
469 return "成功" 428 return "成功"
470 end 429 end
471 430
@@ -484,8 +443,6 @@ function _M.email(role, pms) @@ -484,8 +443,6 @@ function _M.email(role, pms)
484 rewardPms = id ~= 0 and reward or nil, 443 rewardPms = id ~= 0 and reward or nil,
485 }) 444 })
486 445
487 - role:log("gm_action", {desc = "email", int1 = id, key1 = pms.sender})  
488 -  
489 return "成功" 446 return "成功"
490 end 447 end
491 448
@@ -503,7 +460,6 @@ function _M.cguide(role, pms) @@ -503,7 +460,6 @@ function _M.cguide(role, pms)
503 role:updateProperty({field = "funcGuide", value = ""}) 460 role:updateProperty({field = "funcGuide", value = ""})
504 end 461 end
505 462
506 - role:log("gm_action", {desc = "cguide", int1 = id, key1 = pms.sender})  
507 return "成功" 463 return "成功"
508 end 464 end
509 465
@@ -512,11 +468,17 @@ function _M.helpRpc(agent, data) @@ -512,11 +468,17 @@ function _M.helpRpc(agent, data)
512 return true 468 return true
513 end 469 end
514 470
  471 +function _M.test(role, pms)
  472 + local id = tonum(pms.pm1, 0)
  473 + --local hero = require ("actions.HeroAction")
  474 + --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id}))
  475 + role.storeData:onBattleCardReset()
  476 + return "成功"
  477 +end
  478 +
515 -- 充值回调 479 -- 充值回调
516 function _M.ayncPurchase(role, params) 480 function _M.ayncPurchase(role, params)
517 return role:handlePurchase(params) or "" 481 return role:handlePurchase(params) or ""
518 end 482 end
519 483
520 -  
521 -  
522 return _M 484 return _M
523 \ No newline at end of file 485 \ No newline at end of file
src/actions/HangAction.lua
@@ -19,22 +19,29 @@ local _M = {} @@ -19,22 +19,29 @@ local _M = {}
19 local function checkReward(role) 19 local function checkReward(role)
20 local hangInfo = role:getProperty("hangInfo") 20 local hangInfo = role:getProperty("hangInfo")
21 if not hangInfo.carbonId or not hangInfo.coinTime or not hangInfo.itemTime then 21 if not hangInfo.carbonId or not hangInfo.coinTime or not hangInfo.itemTime then
22 - return 22 + return false
23 end 23 end
24 local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] 24 local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId]
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
  31 +
  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
30 35
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 36 + normalTime = nowItemTime - hangInfo.itemTime
  37 + local itemCount = math.max(0, math.floor((normalTime) / globalCsv.idle_item_produce_cd))
  38 + hangInfo.itemTime = nowItemTime
33 39
34 local items = role:getProperty("hangBag") 40 local items = role:getProperty("hangBag")
35 - items[ItemId.Gold] = (items[ItemId.Gold] or 0) + coinCount * carbonData.money  
36 - items[ItemId.Exp] = (items[ItemId.Exp] or 0) + coinCount * carbonData.exp  
37 - items[ItemId.PlayerExp] = (items[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp 41 + coinCount = coinCount + coinDoubleCount
  42 + items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * carbonData.money)
  43 + items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * carbonData.exp)
  44 + items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp)
38 45
39 local pool = {} 46 local pool = {}
40 for _, temp in pairs(carbonData.item:toArray()) do 47 for _, temp in pairs(carbonData.item:toArray()) do
@@ -48,7 +55,10 @@ local function checkReward(role) @@ -48,7 +55,10 @@ local function checkReward(role)
48 curIC = curIC + count 55 curIC = curIC + count
49 end 56 end
50 end 57 end
51 - local selfFC = role:getProperty("hangBagLimit") --再加上月卡的栏位 TODO 58 +
  59 + -- 特权卡挂机额外栏位
  60 + local privExtraCnt = role.storeData:getHangSlotExtraCount()
  61 + local selfFC = role:getProperty("hangBagLimit") + privExtraCnt
52 local selfIC = selfFC * globalCsv.idle_field_limit 62 local selfIC = selfFC * globalCsv.idle_field_limit
53 63
54 local function randomItem() 64 local function randomItem()
@@ -58,34 +68,42 @@ local function checkReward(role) @@ -58,34 +68,42 @@ local function checkReward(role)
58 local tempPool = clone(pool) 68 local tempPool = clone(pool)
59 while #tempPool > 0 do 69 while #tempPool > 0 do
60 local idx = math.randWeight(tempPool, 3) 70 local idx = math.randWeight(tempPool, 3)
61 - local cur = pool[idx]  
62 - if (items[cur[1]] and math.ceil((items[cur[1]] + cur[2]) / globalCsv.idle_field_limit) > math.ceil(items[cur[1]] / globalCsv.idle_field_limit))  
63 - or not items[cur[1]] then --要占用新栏位的情况  
64 - local addFC  
65 - if not items[cur[1]] then  
66 - addFC = math.ceil(cur[2] / globalCsv.idle_field_limit)  
67 - else  
68 - local frontC = items[cur[1]] % globalCsv.idle_field_limit  
69 - if frontC == 0 then  
70 - frontC = globalCsv.idle_field_limit  
71 - end  
72 - addFC = math.ceil((cur[2] - (globalCsv.idle_field_limit - frontC)) / globalCsv.idle_field_limit) 71 + local cur = clone(pool[idx])
  72 + if cur[1] ~= 0 then -- 轮空 id
  73 + if cur[1] == ItemId.BreakCost and doubleTime > 0 then
  74 + cur[2] = cur[2] * 2
73 end 75 end
74 - if curFC + addFC <= selfFC then  
75 - curFC = curFC + addFC  
76 - items[cur[1]] = (items[cur[1]] or 0) + cur[2]  
77 - break 76 + if (items[cur[1]] and math.ceil((items[cur[1]] + cur[2]) / globalCsv.idle_field_limit) > math.ceil(items[cur[1]] / globalCsv.idle_field_limit))
  77 + or not items[cur[1]] then --要占用新栏位的情况
  78 + local addFC
  79 + if not items[cur[1]] then
  80 + addFC = math.ceil(cur[2] / globalCsv.idle_field_limit)
  81 + else
  82 + local frontC = items[cur[1]] % globalCsv.idle_field_limit
  83 + if frontC == 0 then
  84 + frontC = globalCsv.idle_field_limit
  85 + end
  86 + addFC = math.ceil((cur[2] - (globalCsv.idle_field_limit - frontC)) / globalCsv.idle_field_limit)
  87 + end
  88 + if curFC + addFC <= selfFC then
  89 + curFC = curFC + addFC
  90 + items[cur[1]] = (items[cur[1]] or 0) + cur[2]
  91 + break
  92 + else
  93 + --加不了,换别的东西
  94 + table.remove(tempPool, idx)
  95 + end
78 else 96 else
79 - --加不了,换别的东西  
80 - table.remove(tempPool, idx) 97 + items[cur[1]] = items[cur[1]] + cur[2]
  98 + break
81 end 99 end
82 else 100 else
83 - items[cur[1]] = items[cur[1]] + cur[2]  
84 break 101 break
85 end 102 end
86 end 103 end
87 curIC = curIC + 1 104 curIC = curIC + 1
88 end 105 end
  106 +
89 for i = 1, itemCount do 107 for i = 1, itemCount do
90 randomItem() 108 randomItem()
91 end 109 end
@@ -93,6 +111,8 @@ local function checkReward(role) @@ -93,6 +111,8 @@ local function checkReward(role)
93 if coinCount > 0 or itemCount > 0 then 111 if coinCount > 0 or itemCount > 0 then
94 return true 112 return true
95 end 113 end
  114 +
  115 + return false
96 end 116 end
97 117
98 --开始一个新的关卡 118 --开始一个新的关卡
@@ -136,7 +156,16 @@ function _M.startRpc( agent, data ) @@ -136,7 +156,16 @@ function _M.startRpc( agent, data )
136 end 156 end
137 role:updateProperty({field = "hangInfo", value = hangInfo}) 157 role:updateProperty({field = "hangInfo", value = hangInfo})
138 158
139 - role:log("hang_action", {desc = "startHang", int1 = carbonId}) 159 + -- 指定当前引导的步骤
  160 + if carbonId == 10101 then
  161 + role:saveGuide(5,11)
  162 + elseif carbonId == 10102 then
  163 + role:saveGuide(8,2)
  164 + elseif carbonId == 10103 then
  165 + role:saveGuide(9,2)
  166 + elseif carbonId == 10220 then
  167 + role:saveGuide(22,1)
  168 + end
140 169
141 SendPacket(actionCodes.Hang_startRpc, '') 170 SendPacket(actionCodes.Hang_startRpc, '')
142 return true 171 return true
@@ -187,9 +216,11 @@ function _M.endBattleRpc(agent, data) @@ -187,9 +216,11 @@ function _M.endBattleRpc(agent, data)
187 local msg = MsgPack.unpack(data) 216 local msg = MsgPack.unpack(data)
188 local hangInfo = role:getProperty("hangInfo") 217 local hangInfo = role:getProperty("hangInfo")
189 if not msg.key or msg.key ~= _BattleKey then 218 if not msg.key or msg.key ~= _BattleKey then
190 - return 1 219 + SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1}))
  220 + return true
191 end 221 end
192 local carbonId = msg.carbonId 222 local carbonId = msg.carbonId
  223 + local isWin = msg.starNum and msg.starNum > 0
193 local carbonData = csvdb["idle_battleCsv"][carbonId] 224 local carbonData = csvdb["idle_battleCsv"][carbonId]
194 if not carbonData then 225 if not carbonData then
195 return 2 226 return 2
@@ -203,8 +234,9 @@ function _M.endBattleRpc(agent, data) @@ -203,8 +234,9 @@ function _M.endBattleRpc(agent, data)
203 if role:checkHangPass(carbonId) then 234 if role:checkHangPass(carbonId) then
204 return 4 235 return 4
205 end 236 end
206 - local reward  
207 - if msg.starNum and msg.starNum > 0 then --win 237 +
  238 + local reward, change
  239 + if isWin then --win
208 role:hangFinish(carbonId) 240 role:hangFinish(carbonId)
209 if carbonData.main ~= 1 then 241 if carbonData.main ~= 1 then
210 hangInfo.bossTime = nil 242 hangInfo.bossTime = nil
@@ -217,18 +249,43 @@ function _M.endBattleRpc(agent, data) @@ -217,18 +249,43 @@ function _M.endBattleRpc(agent, data)
217 for itemId, count in pairs(carbonData.item_clear:toNumMap()) do 249 for itemId, count in pairs(carbonData.item_clear:toNumMap()) do
218 reward[itemId] = count 250 reward[itemId] = count
219 end 251 end
220 - reward = role:award(reward, {log = {desc = "hangBattle", int1 = carbonId}}) 252 + reward, change = role:award(reward, {log = {desc = "hangBattle", int1 = carbonId}})
221 253
222 role:checkTaskEnter("HangPass", {id = carbonId}) 254 role:checkTaskEnter("HangPass", {id = carbonId})
  255 +
  256 + -- 引导
  257 + if carbonId == 10101 then
  258 + role:finishGuide(5)
  259 + elseif carbonId == 10102 then
  260 + role:finishGuide(8)
  261 + elseif carbonId == 10103 then
  262 + role:finishGuide(9)
  263 + elseif carbonId == 10220 then
  264 + role:finishGuide(22)
  265 + end
  266 + for _, guideData in pairs(csvdb["guide_unlockCsv"]) do
  267 + if guideData.type == 3 and guideData.carbonId == carbonId then
  268 + role:saveGuide(guideData.guideId,1,true)
  269 + break
  270 + end
  271 + end
  272 + end
  273 + if hangInfo.carbonId < carbonId then
  274 + hangInfo.carbonId = carbonId
223 end 275 end
224 role:updateProperty({field = "hangInfo", value = hangInfo}) 276 role:updateProperty({field = "hangInfo", value = hangInfo})
225 277
226 - local team = role:getProperty("pvpTC")  
227 - role:log("hang_action", {desc = "hangBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = carbonId, int2 = role:getProperty("hangTBV"), cint1 = role:getHerosCamp(team.heros)}) 278 + role:checkBattle("hang", {
  279 + id = carbonId,
  280 + isWin = isWin,
  281 + info = msg.info,
  282 + reward = reward,
  283 + })
228 284
229 SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({ 285 SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({
230 starNum = msg.starNum, 286 starNum = msg.starNum,
231 reward = reward, 287 reward = reward,
  288 + change = change,
232 })) 289 }))
233 return true 290 return true
234 end 291 end
@@ -276,7 +333,7 @@ function _M.getRewardRpc(agent , data) @@ -276,7 +333,7 @@ function _M.getRewardRpc(agent , data)
276 checkReward(role) 333 checkReward(role)
277 local items = role:getProperty("hangBag") 334 local items = role:getProperty("hangBag")
278 if not next(items) then return end 335 if not next(items) then return end
279 - local reward = role:award(items, {log = {desc = "hangReward"}}) 336 + local reward, change = role:award(items, {log = {desc = "hangReward"}})
280 table.clear(items) 337 table.clear(items)
281 local hangInfo = role:getProperty("hangInfo") 338 local hangInfo = role:getProperty("hangInfo")
282 local nowTime = skynet.timex() 339 local nowTime = skynet.timex()
@@ -290,71 +347,24 @@ function _M.getRewardRpc(agent , data) @@ -290,71 +347,24 @@ function _M.getRewardRpc(agent , data)
290 if reward[ItemId.Gold] then 347 if reward[ItemId.Gold] then
291 role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) 348 role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
292 end 349 end
  350 +
  351 + role:log("residence_reward", {
  352 + mission_threadid = math.floor(hangInfo.carbonId / 10000), --大关卡ID
  353 + mission_id = hangInfo.carbonId, --关卡ID
  354 + mission_type = 100, --关卡类型,见关卡类型枚举表
  355 + residence_reward_type = 0, --领取奖励方式,快速(超前领取)记录为1,正常领取记录为0
  356 + residence_time = 0, --挂机或排名时长
  357 + residence_reward = reward, --获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
  358 + })
  359 +
  360 +
293 SendPacket(actionCodes.Hang_getRewardRpc, MsgPack.pack({ 361 SendPacket(actionCodes.Hang_getRewardRpc, MsgPack.pack({
294 - reward = reward 362 + reward = reward,
  363 + change = change
295 })) 364 }))
296 return true 365 return true
297 end 366 end
298 367
299 --- function _M.getRewardItemRpc(agent , data)  
300 --- local role = agent.role  
301 --- checkReward(role)  
302 --- local items = role:getProperty("hangBag")  
303 --- if not next(items) then return end  
304 -  
305 --- local notNeed = {[ItemId.Gold] = 1, [ItemId.Exp] = 1, [ItemId.PlayerExp] = 1}  
306 --- local reward = {}  
307 --- for itemId , count in pairs(items) do  
308 --- if not notNeed[itemId] then  
309 --- reward[itemId] = count  
310 --- items[itemId] = nil  
311 --- end  
312 --- end  
313 --- if not next(reward) then return end  
314 --- local reward = role:award(reward)  
315 -  
316 --- local hangInfo = role:getProperty("hangInfo")  
317 --- local nowTime = skynet.timex()  
318 --- hangInfo.endItemTime = nowTime + globalCsv.idle_producetime_max  
319 --- hangInfo.itemTime = nowTime  
320 --- role:updateProperty({field = "hangBag", value = items})  
321 --- role:updateProperty({field = "hangInfo", value = hangInfo})  
322 -  
323 --- SendPacket(actionCodes.Hang_getRewardItemRpc, MsgPack.pack({  
324 --- reward = reward  
325 --- }))  
326 --- return true  
327 --- end  
328 -  
329 --- function _M.getRewardCoinRpc(agent , data)  
330 --- local role = agent.role  
331 --- checkReward(role)  
332 --- local items = role:getProperty("hangBag")  
333 --- if not next(items) then return end  
334 -  
335 --- local need = {[ItemId.Gold] = 1, [ItemId.Exp] = 1, [ItemId.PlayerExp] = 1}  
336 --- local reward = {}  
337 --- for itemId , count in pairs(items) do  
338 --- if need[itemId] then  
339 --- reward[itemId] = count  
340 --- items[itemId] = nil  
341 --- end  
342 --- end  
343 --- local reward = role:award(reward)  
344 -  
345 --- local hangInfo = role:getProperty("hangInfo")  
346 --- local nowTime = skynet.timex()  
347 --- hangInfo.endCoinTime = nowTime + globalCsv.idle_producetime_max  
348 --- hangInfo.coinTime = nowTime  
349 --- role:updateProperty({field = "hangBag", value = items})  
350 --- role:updateProperty({field = "hangInfo", value = hangInfo})  
351 -  
352 --- SendPacket(actionCodes.Hang_getRewardCoinRpc, MsgPack.pack({  
353 --- reward = reward  
354 --- }))  
355 --- return true  
356 --- end  
357 -  
358 function _M.quickRpc(agent , data) 368 function _M.quickRpc(agent , data)
359 local role = agent.role 369 local role = agent.role
360 370
@@ -377,8 +387,9 @@ function _M.quickRpc(agent , data) @@ -377,8 +387,9 @@ function _M.quickRpc(agent , data)
377 387
378 local coinCount = math.floor(time / globalCsv.idle_money_produce_cd) 388 local coinCount = math.floor(time / globalCsv.idle_money_produce_cd)
379 local itemCount = math.floor(time / globalCsv.idle_item_produce_cd) 389 local itemCount = math.floor(time / globalCsv.idle_item_produce_cd)
380 - reward[ItemId.Gold] = (reward[ItemId.Gold] or 0) + coinCount * carbonData.money  
381 - reward[ItemId.Exp] = (reward[ItemId.Exp] or 0) + coinCount * carbonData.exp 390 + reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * carbonData.money)
  391 + reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * carbonData.exp)
  392 + reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp)
382 393
383 local pool = {} 394 local pool = {}
384 for _, temp in pairs(carbonData.item:toArray()) do 395 for _, temp in pairs(carbonData.item:toArray()) do
@@ -389,13 +400,34 @@ function _M.quickRpc(agent , data) @@ -389,13 +400,34 @@ function _M.quickRpc(agent , data)
389 reward[cur[1]] = (reward[cur[1]] or 0) + cur[2] 400 reward[cur[1]] = (reward[cur[1]] or 0) + cur[2]
390 end 401 end
391 402
392 - reward = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) 403 + local doubleCoef = role.activity:isOpen("DoubleDrop") and 2 or 1
  404 +
  405 + -- 特权卡获取加速获得额外道具
  406 + local coef = role.storeData:getProduceItemSpeedCoef()
  407 + if coef > 1 then
  408 + for k, cnt in pairs(reward) do
  409 + reward[k] = math.floor(cnt * coef * doubleCoef)
  410 + end
  411 + end
  412 +
  413 + local change
  414 + reward, change = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}})
393 if reward[ItemId.Gold] then 415 if reward[ItemId.Gold] then
394 role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) 416 role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
395 end 417 end
396 role:checkTaskEnter("HangQuick") 418 role:checkTaskEnter("HangQuick")
  419 +
  420 + role:log("residence_reward", {
  421 + mission_threadid = math.floor(hangInfo.carbonId / 10000), --大关卡ID
  422 + mission_id = hangInfo.carbonId, --关卡ID
  423 + mission_type = 100, --关卡类型,见关卡类型枚举表
  424 + residence_reward_type = 1, --领取奖励方式,快速(超前领取)记录为1,正常领取记录为0
  425 + residence_time = time, --挂机或排名时长
  426 + residence_reward = reward, --获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
  427 + })
397 SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({ 428 SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({
398 - reward = reward 429 + reward = reward,
  430 + change = change
399 })) 431 }))
400 return true 432 return true
401 end 433 end
@@ -447,7 +479,7 @@ function _M.buyBonusCountRpc(agent, data) @@ -447,7 +479,7 @@ function _M.buyBonusCountRpc(agent, data)
447 479
448 if not role:checkItemEnough({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}) then return 2 end 480 if not role:checkItemEnough({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}) then return 2 end
449 481
450 - role:costItems({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}, {log = {desc = "buyBonusCount", short1 = btype, int1 = count}}) 482 + role:costItems({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}, {log = {desc = "buyBonusCount", int1 = btype, int2 = count}})
451 bonusC[btype]["b"] = bonusC[btype]["b"] + count 483 bonusC[btype]["b"] = bonusC[btype]["b"] + count
452 bonusC[btype]["c"] = bonusC[btype]["c"] - count 484 bonusC[btype]["c"] = bonusC[btype]["c"] - count
453 485
@@ -494,10 +526,13 @@ function _M.endBonusBattleRpc(agent, data) @@ -494,10 +526,13 @@ function _M.endBonusBattleRpc(agent, data)
494 local starNum = msg.starNum 526 local starNum = msg.starNum
495 if not role.__bonusBattleCache then return 1 end 527 if not role.__bonusBattleCache then return 1 end
496 528
497 - if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then return 2 end 529 + if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then
  530 + SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1}))
  531 + return true
  532 + end
498 local bonusData = csvdb["bonus_battleCsv"][id] 533 local bonusData = csvdb["bonus_battleCsv"][id]
499 534
500 - local reward 535 + local reward, change
501 if starNum and starNum > 0 then 536 if starNum and starNum > 0 then
502 -- 胜利扣除次数 537 -- 胜利扣除次数
503 local bonusC = role.dailyData:getProperty("bonusC") 538 local bonusC = role.dailyData:getProperty("bonusC")
@@ -511,15 +546,21 @@ function _M.endBonusBattleRpc(agent, data) @@ -511,15 +546,21 @@ function _M.endBonusBattleRpc(agent, data)
511 if chance[1] ~= 0 then 546 if chance[1] ~= 0 then
512 reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] 547 reward[chance[1]] = (reward[chance[1]] or 0) + chance[2]
513 end 548 end
514 - reward = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) 549 + reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}})
515 role:checkTaskEnter("BonusPass", {id = id}) 550 role:checkTaskEnter("BonusPass", {id = id})
516 end 551 end
517 552
518 - role:log("hang_action", {desc = "bonusBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id})  
519 - 553 + role:checkBattle("bonus", {
  554 + id = id,
  555 + isWin = starNum and starNum > 0,
  556 + info = msg.info,
  557 + reward = reward,
  558 + })
520 SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({ 559 SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({
521 starNum = starNum, 560 starNum = starNum,
522 - reward = reward})) 561 + reward = reward,
  562 + change = change
  563 + }))
523 return true 564 return true
524 end 565 end
525 566
@@ -534,12 +575,11 @@ function _M.hangGiftRpc(agent, data) @@ -534,12 +575,11 @@ function _M.hangGiftRpc(agent, data)
534 local hangGift = role:getProperty("hangGift") 575 local hangGift = role:getProperty("hangGift")
535 if hangGift[id] then return 2 end 576 if hangGift[id] then return 2 end
536 577
537 - local reward = role:award(carbonData.item_clear_special, {log = {desc = "hangGift", int1 = id}})  
538 - role:log("hang_action", {desc = "hangGift", int1 = id}) 578 + local reward, change = role:award(carbonData.item_clear_special, {log = {desc = "hangGift", int1 = id}})
539 579
540 role:changeUpdates({{type = "hangGift", field = id, value = 1}}) 580 role:changeUpdates({{type = "hangGift", field = id, value = 1}})
541 581
542 - SendPacket(actionCodes.Hang_hangGiftRpc, MsgPack.pack(reward)) 582 + SendPacket(actionCodes.Hang_hangGiftRpc, MsgPack.pack({reward = reward, change = change}))
543 return true 583 return true
544 end 584 end
545 585
@@ -577,9 +617,9 @@ function _M.chatLineRpc(agent, data) @@ -577,9 +617,9 @@ function _M.chatLineRpc(agent, data)
577 chatline[id] = skynet.timex() 617 chatline[id] = skynet.timex()
578 role:updateProperty({field = "chatline", value = chatline}) 618 role:updateProperty({field = "chatline", value = chatline})
579 619
580 - local reward = role:award(idleData.chatline_reward, {log = {desc = "chatline", int1 = id}}) 620 + local reward, change = role:award(idleData.chatline_reward, {log = {desc = "chatline", int1 = id}})
581 621
582 - SendPacket(actionCodes.Hang_chatLineRpc, MsgPack.pack(reward)) 622 + SendPacket(actionCodes.Hang_chatLineRpc, MsgPack.pack({reward = reward, change = change}))
583 return true 623 return true
584 end 624 end
585 625
src/actions/HeroAction.lua
@@ -16,6 +16,18 @@ local table_unpack = table.unpack @@ -16,6 +16,18 @@ local table_unpack = table.unpack
16 16
17 local _M = {} 17 local _M = {}
18 18
  19 +local function getChangeAttrJson(oldAttr, newAttr)
  20 + local change = {}
  21 + for k, v in pairs(newAttr) do
  22 + change[k] = v - oldAttr[k]
  23 + change[k] = math.ceil(change[k])
  24 + if change[k] == 0 then
  25 + change[k] = nil
  26 + end
  27 + end
  28 + return change
  29 +end
  30 +
19 function _M.levelUpRpc( agent, data ) 31 function _M.levelUpRpc( agent, data )
20 local role = agent.role 32 local role = agent.role
21 local msg = MsgPack.unpack(data) 33 local msg = MsgPack.unpack(data)
@@ -28,9 +40,23 @@ function _M.levelUpRpc( agent, data ) @@ -28,9 +40,23 @@ function _M.levelUpRpc( agent, data )
28 local cost = {[ItemId.Exp] = curData.exp, [ItemId.Gold] = curData.gold} 40 local cost = {[ItemId.Exp] = curData.exp, [ItemId.Gold] = curData.gold}
29 if not role:checkItemEnough(cost) then return 3 end 41 if not role:checkItemEnough(cost) then return 3 end
30 role:costItems(cost, {log = {desc = "heroLevelUp", int1 = msg.id, int2 = hero:getProperty("type")}}) 42 role:costItems(cost, {log = {desc = "heroLevelUp", int1 = msg.id, int2 = hero:getProperty("type")}})
  43 +
  44 + local oldAttr = hero:getTotalAttrs()
  45 + local oldBattleV = hero:getProperty("battleV")
31 hero:updateProperty({field = "level", delta = 1}) 46 hero:updateProperty({field = "level", delta = 1})
32 47
33 - hero:log({desc = "levelUp", int1 = hero:getProperty("level")}) 48 + role:log("hero_upgrade", {
  49 + hero_id = hero:getProperty("type"), --英雄ID
  50 + hero_upgrade_cost = cost, -- 英雄升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
  51 + hero_upgrade_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), -- 英雄升级效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..}
  52 + hero_upgrade_type = 0, -- 英雄升级方式,连续升级:1,单击升级:0
  53 + hero_upgrade_score = hero:getProperty("battleV"), -- 英雄升级后评分
  54 + hero_upgrade_scoreget = hero:getProperty("battleV") - oldBattleV, -- 通过英雄升级提升的评分
  55 + })
  56 +
  57 + if hero:getProperty("type") == 103 then
  58 + role:finishGuide(7)
  59 + end
34 60
35 role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")}) 61 role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")})
36 SendPacket(actionCodes.Hero_levelUpRpc, '') 62 SendPacket(actionCodes.Hero_levelUpRpc, '')
@@ -49,9 +75,15 @@ function _M.breakRpc( agent, data ) @@ -49,9 +75,15 @@ function _M.breakRpc( agent, data )
49 local cost = {[ItemId.BreakCost] = curData.cost, [ItemId.Gold] = curData.gold} 75 local cost = {[ItemId.BreakCost] = curData.cost, [ItemId.Gold] = curData.gold}
50 if not role:checkItemEnough(cost) then return 4 end 76 if not role:checkItemEnough(cost) then return 4 end
51 role:costItems(cost, {log = {desc = "heroBreak", int1 = msg.id, int2 = hero:getProperty("type")}}) 77 role:costItems(cost, {log = {desc = "heroBreak", int1 = msg.id, int2 = hero:getProperty("type")}})
  78 + local oldAttr = hero:getTotalAttrs()
52 hero:updateProperty({field = "breakL", delta = 1}) 79 hero:updateProperty({field = "breakL", delta = 1})
53 80
54 - hero:log({desc = "break", int1 = hero:getProperty("breakL")}) 81 + role:log("hero_break", {
  82 + hero_id = hero:getProperty("type"), --英雄ID
  83 + hero_break_cost = cost, -- 英雄突破消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
  84 + hero_break_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), -- 英雄突破效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..}
  85 + hero_break_level = hero:getMaxLevel(), -- 英雄突破后等级上限
  86 + })
55 87
56 SendPacket(actionCodes.Hero_breakRpc, '') 88 SendPacket(actionCodes.Hero_breakRpc, '')
57 return true 89 return true
@@ -74,6 +106,7 @@ function _M.wakeRpc(agent, data) @@ -74,6 +106,7 @@ function _M.wakeRpc(agent, data)
74 106
75 role:costItems(cost, {log = {desc = "heroWake", int1 = msg.id, int2 = hero:getProperty("type")}}) 107 role:costItems(cost, {log = {desc = "heroWake", int1 = msg.id, int2 = hero:getProperty("type")}})
76 108
  109 + local oldAttr = hero:getTotalAttrs()
77 hero:updateProperty({field = "wakeL", delta = 1}) 110 hero:updateProperty({field = "wakeL", delta = 1})
78 111
79 local curLevel = hero:getProperty("wakeL") 112 local curLevel = hero:getProperty("wakeL")
@@ -81,9 +114,14 @@ function _M.wakeRpc(agent, data) @@ -81,9 +114,14 @@ function _M.wakeRpc(agent, data)
81 if curLevel == 4 then -- 解锁cg 114 if curLevel == 4 then -- 解锁cg
82 role:checkTaskEnter("WakeCG", {heroType = typ}) 115 role:checkTaskEnter("WakeCG", {heroType = typ})
83 end 116 end
84 - hero:log({desc = "wake", int1 = hero:getProperty("wakeL")})  
85 117
86 - 118 + role:log("hero_rise", {
  119 + hero_id = typ, --英雄ID
  120 + hero_rise_cost = cost, --英雄觉醒消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
  121 + hero_rise_score = hero:getProperty("battleV"), --英雄觉醒后评分提升
  122 + hero_rise_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), --英雄觉醒效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..}
  123 + })
  124 +
87 SendPacket(actionCodes.Hero_wakeRpc, '') 125 SendPacket(actionCodes.Hero_wakeRpc, '')
88 return true 126 return true
89 end 127 end
@@ -103,7 +141,10 @@ function _M.talentRpc(agent, data) @@ -103,7 +141,10 @@ function _M.talentRpc(agent, data)
103 local curStage = talent:getv(0, 1) 141 local curStage = talent:getv(0, 1)
104 local curData = csvdb["unit_talentCsv"][curStage] 142 local curData = csvdb["unit_talentCsv"][curStage]
105 if not curData then return 4 end 143 if not curData then return 4 end
  144 + local oldSkillLv = hero:getSkillLevel(1)
  145 +
106 146
  147 + local cost = {}
107 if index == 0 then 148 if index == 0 then
108 --是否进阶 149 --是否进阶
109 local max = true 150 local max = true
@@ -131,7 +172,7 @@ function _M.talentRpc(agent, data) @@ -131,7 +172,7 @@ function _M.talentRpc(agent, data)
131 172
132 if talentData.lvRequire > hero:getProperty("level") then return 6 end 173 if talentData.lvRequire > hero:getProperty("level") then return 6 end
133 174
134 - local cost = talentData.money:toNumMap() 175 + cost = talentData.money:toNumMap()
135 local cost2 = talentData.cost:toNumMap() 176 local cost2 = talentData.cost:toNumMap()
136 for k,v in pairs(cost2) do 177 for k,v in pairs(cost2) do
137 cost[globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp][k]] = v 178 cost[globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp][k]] = v
@@ -152,7 +193,12 @@ function _M.talentRpc(agent, data) @@ -152,7 +193,12 @@ function _M.talentRpc(agent, data)
152 193
153 hero:updateProperty({field = "talent", value = talent}) 194 hero:updateProperty({field = "talent", value = talent})
154 195
155 - hero:log({desc = "talent", int1 = index, int2 = talent:getv(index, 0)}) 196 + role:log("hero_talent", {
  197 + hero_id = hero:getProperty("type"), --英雄ID
  198 + hero_talent_cost = cost, -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
  199 + hero_talent_levelbef = oldSkillLv, -- 英雄技能升级前等级
  200 + hero_talent_level = hero:getSkillLevel(1), -- 英雄技能升级后等级
  201 + })
156 202
157 SendPacket(actionCodes.Hero_talentRpc, '') 203 SendPacket(actionCodes.Hero_talentRpc, '')
158 return true 204 return true
@@ -252,6 +298,14 @@ function _M.commentHeroRpc(agent, data) @@ -252,6 +298,14 @@ function _M.commentHeroRpc(agent, data)
252 comment.like = 0 298 comment.like = 0
253 result.comment = comment 299 result.comment = comment
254 role.dailyData:setProperty("commentHero", curStutus:setv(heroType, 1)) 300 role.dailyData:setProperty("commentHero", curStutus:setv(heroType, 1))
  301 +
  302 +
  303 + role:log("hero_note", {
  304 + hero_id = heroType, -- 英雄ID
  305 + hero_note_action = 0, -- 英雄评价界面操作,发布评论:0,点赞:1,反对:2
  306 + hero_note_id = commentId, -- 操作的评价ID
  307 + hero_note_text = content, -- 操作的评价内容
  308 + })
255 end 309 end
256 SendPacket(actionCodes.Hero_commentHeroRpc, MsgPack.pack(result)) 310 SendPacket(actionCodes.Hero_commentHeroRpc, MsgPack.pack(result))
257 return true 311 return true
@@ -322,7 +376,7 @@ function _M.likeCommentRpc(agent, data) @@ -322,7 +376,7 @@ function _M.likeCommentRpc(agent, data)
322 local commentIndex = heroType .. ":" .. commentId 376 local commentIndex = heroType .. ":" .. commentId
323 local commentRoleKey = string.format("comment:%d:like", role:getProperty("id")) 377 local commentRoleKey = string.format("comment:%d:like", role:getProperty("id"))
324 local redret = redisproxy:pipelining(function (red) 378 local redret = redisproxy:pipelining(function (red)
325 - red:hexists(commentKey.commentKey, commentId) 379 + red:hget(commentKey.commentKey, commentId)
326 red:lrem(commentRoleKey, 1, commentIndex) 380 red:lrem(commentRoleKey, 1, commentIndex)
327 red:lpush(commentRoleKey, commentIndex) 381 red:lpush(commentRoleKey, commentIndex)
328 red:ltrim(commentRoleKey, 0, 999) 382 red:ltrim(commentRoleKey, 0, 999)
@@ -330,7 +384,8 @@ function _M.likeCommentRpc(agent, data) @@ -330,7 +384,8 @@ function _M.likeCommentRpc(agent, data)
330 if (tonumber(redret[2]) or 0) > 0 then 384 if (tonumber(redret[2]) or 0) > 0 then
331 result.status = 1 385 result.status = 1
332 else 386 else
333 - if redret[1] == 1 then-- 查不到也返回ture 387 + if redret[1] then-- 查不到也返回ture
  388 + local comment = json.decode(redret[1])
334 local redret2 = redisproxy:pipelining(function (red) 389 local redret2 = redisproxy:pipelining(function (red)
335 red:zrevrange(commentKey.commentRankKey, 0, RankLikeNum - 1) --热门 390 red:zrevrange(commentKey.commentRankKey, 0, RankLikeNum - 1) --热门
336 red:zincrby(commentKey.commentRankKey, add, commentId) 391 red:zincrby(commentKey.commentRankKey, add, commentId)
@@ -356,6 +411,13 @@ function _M.likeCommentRpc(agent, data) @@ -356,6 +411,13 @@ function _M.likeCommentRpc(agent, data)
356 red:lrem(commentKey.commentListKey, 0, tempId) 411 red:lrem(commentKey.commentListKey, 0, tempId)
357 end 412 end
358 end) 413 end)
  414 +
  415 + role:log("hero_note", {
  416 + hero_id = heroType, -- 英雄ID
  417 + hero_note_action = add > 0 and 1 or 2, -- 英雄评价界面操作,发布评论:0,点赞:1,反对:2
  418 + hero_note_id = commentId, -- 操作的评价ID
  419 + hero_note_text = comment.content, -- 操作的评价内容
  420 + })
359 end 421 end
360 end 422 end
361 423
@@ -363,108 +425,6 @@ function _M.likeCommentRpc(agent, data) @@ -363,108 +425,6 @@ function _M.likeCommentRpc(agent, data)
363 return true 425 return true
364 end 426 end
365 427
366 --- function _M.loveItemRpc(agent, data)  
367 --- local role = agent.role  
368 --- local msg = MsgPack.unpack(data)  
369 --- local hero = role.heros[msg.heroId]  
370 --- if not hero then  
371 --- return  
372 --- end  
373 --- local curL = hero:getProperty("loveL")  
374 --- local curExp = hero:getProperty("loveExp")  
375 --- local curType = hero:getProperty("type")  
376 --- local curPlus = csvdb["unit_love_plusCsv"][curType]  
377 --- if not curPlus then  
378 --- return  
379 --- end  
380 --- if curL >= curPlus.limit then  
381 --- SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 1})) --已满级  
382 --- return true  
383 --- end  
384 --- local curEffect = csvdb["unit_love_effectCsv"][curL]  
385 --- if not curEffect then  
386 --- return  
387 --- end  
388 --- if curExp >= curEffect.loveValue and not msg.bBreak then  
389 --- SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 2})) --当前等级经验已满  
390 --- return true  
391 --- end  
392 -  
393 --- if msg.bBreak then  
394 --- local cost = curEffect.cost:toArray(true, "=")  
395 --- if not role:checkItemEnough({[cost[1]] = cost[2]}) then  
396 --- SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 3, itemId = cost[1]})) --物品不足  
397 --- return true  
398 --- end  
399 --- role:costItems({[cost[1]] = cost[2]})  
400 --- local newLevel = curL + 1  
401 --- hero:updateProperty({field = "loveL", value = newLevel})  
402 --- hero:updateProperty({field = "loveExp", value = 0})  
403 -  
404 --- if role:getProperty("loveStatus"):getv(curType, 0) < newLevel then  
405 --- role:changeUpdates({{type = "loveStatus", field = curType, value = newLevel}}) -- 总的  
406 --- end  
407 -  
408 --- role:checkTaskEnter("LoveBreak", {heroType = curType, loveL = newLevel})  
409 -  
410 --- else  
411 --- local delta = globalCsv.unit_love_presentValue[msg.itemId]  
412 --- if not delta then  
413 --- return  
414 --- end  
415 --- if not role:checkItemEnough({[msg.itemId] = 1}) then  
416 --- SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 3, itemId = msg.itemId}))  
417 --- return true  
418 --- end  
419 --- local newExp = curExp + delta  
420 --- if newExp > curEffect.loveValue then  
421 --- newExp = curEffect.loveValue  
422 --- end  
423 --- role:costItems({[msg.itemId] = 1})  
424 --- hero:updateProperty({field = "loveExp", value = newExp})  
425 --- end  
426 --- SendPacket(actionCodes.Hero_loveItemRpc, "")  
427 --- return true  
428 --- end  
429 -  
430 --- function _M.loveTaskRpc(agent, data)  
431 --- local role = agent.role  
432 --- local msg = MsgPack.unpack(data)  
433 --- local hero = role.heros[msg.id]  
434 --- if not hero then return end  
435 -  
436 --- local curL = hero:getProperty("loveL")  
437 --- local curExp = hero:getProperty("loveExp")  
438 --- local curType = hero:getProperty("type")  
439 --- local curPlus = csvdb["unit_love_plusCsv"][curType]  
440 --- if not curPlus or curL >= curPlus.limit then return end  
441 -  
442 --- local curEffect = csvdb["unit_love_effectCsv"][curL]  
443 --- if not curEffect or curExp < curEffect.loveValue then return end  
444 -  
445 --- local lastEffect = csvdb["unit_love_effectCsv"][curL + 1]  
446 --- local newExp = curExp - curEffect.loveValue  
447 --- if lastEffect and curL + 1 < curPlus.limit then  
448 --- if newExp >= lastEffect.loveValue then  
449 --- -- todo 发任务  
450 --- end  
451 --- else  
452 --- newExp = 0  
453 --- end  
454 --- local newLevel = curL + 1  
455 --- hero:updateProperty({field = "loveExp", value = newExp})  
456 --- hero:updateProperty({field = "loveL", value = newLevel})  
457 -  
458 --- if role:getProperty("loveStatus"):getv(curType, 0) < newLevel then  
459 --- role:changeUpdates({{type = "loveStatus", field = curType, value = newLevel}}) -- 总的  
460 --- end  
461 -  
462 --- role:checkTaskEnter("LoveBreak", {heroType = curType, loveL = newLevel})  
463 -  
464 --- SendPacket(actionCodes.Hero_loveTaskRpc, "")  
465 --- return true  
466 --- end  
467 -  
468 function _M.createHeroRpc(agent, data) 428 function _M.createHeroRpc(agent, data)
469 local role = agent.role 429 local role = agent.role
470 local msg = MsgPack.unpack(data) 430 local msg = MsgPack.unpack(data)
@@ -493,6 +453,7 @@ function _M.referEquipsRpc(agent, data) @@ -493,6 +453,7 @@ function _M.referEquipsRpc(agent, data)
493 local hero = role.heros[msg.id] 453 local hero = role.heros[msg.id]
494 if not hero then return 10 end 454 if not hero then return 10 end
495 local equips = msg.equips 455 local equips = msg.equips
  456 + local isAuto = msg.isAuto
496 if not equips or not next(equips) then return 11 end 457 if not equips or not next(equips) then return 11 end
497 458
498 for typ = 1, 4 do -- 4件装备 459 for typ = 1, 4 do -- 4件装备
@@ -502,6 +463,11 @@ function _M.referEquipsRpc(agent, data) @@ -502,6 +463,11 @@ function _M.referEquipsRpc(agent, data)
502 end 463 end
503 end 464 end
504 end 465 end
  466 +
  467 + local oldAttr = hero:getTotalAttrs()
  468 + local oldBattleV = hero:getProperty("battleV")
  469 + local wear = {}
  470 +
505 local curEquip = hero:getProperty("equip") 471 local curEquip = hero:getProperty("equip")
506 for typ = 1, 4 do -- 4件装备 472 for typ = 1, 4 do -- 4件装备
507 if equips[typ] then 473 if equips[typ] then
@@ -512,17 +478,37 @@ function _M.referEquipsRpc(agent, data) @@ -512,17 +478,37 @@ function _M.referEquipsRpc(agent, data)
512 else 478 else
513 role:addEquip(typ, equips[typ], -1, {log = {desc = "refer"}}) -- 穿上 479 role:addEquip(typ, equips[typ], -1, {log = {desc = "refer"}}) -- 穿上
514 curEquip = curEquip:setv(typ, equips[typ]) 480 curEquip = curEquip:setv(typ, equips[typ])
  481 +
  482 + wear[typ] = {id = equips[typ], act = 0}
515 end 483 end
516 484
517 if cur ~= 0 then 485 if cur ~= 0 then
518 role:addEquip(typ, cur, 1, {log = {desc = "refer"}}) -- 脱掉 486 role:addEquip(typ, cur, 1, {log = {desc = "refer"}}) -- 脱掉
  487 +
  488 + wear[typ] = {id = cur, act = 1}
519 end 489 end
520 end 490 end
521 end 491 end
522 end 492 end
  493 +
523 -- 更新角色 494 -- 更新角色
524 hero:updateProperty({field = "equip", value = curEquip}) 495 hero:updateProperty({field = "equip", value = curEquip})
525 496
  497 + role:finishGuide(23)
  498 +
  499 + local curAttr = hero:getTotalAttrs()
  500 + local attrChange = getChangeAttrJson(oldAttr, curAttr)
  501 + for typ, data in pairs(wear) do
  502 + role:log("hero_jewel", {
  503 + hero_id = hero:getProperty("type"), --英雄ID
  504 + equip_id = data.id, --装备ID
  505 + equip_wear_action = data.act, --装备操作类型:装备:0,卸载:1
  506 + equip_wear_part = typ, --装备部位,记录部位ID
  507 + equip_wear_result = curAttr, --装备操作后结果,记录属性变化,json格式记录,{“aa”:1234,"bb":4567}
  508 + equip_wear_change = attrChange, --装备操作变化值,记录属性变化,记录正负值,json格式记录,{“aa”:1234,"bb":-45}
  509 + equip_wear_mode = isAuto and 0 or 1, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1
  510 + })
  511 + end
526 SendPacket(actionCodes.Hero_referEquipsRpc, "") 512 SendPacket(actionCodes.Hero_referEquipsRpc, "")
527 return true 513 return true
528 end 514 end
@@ -559,6 +545,9 @@ function _M.referRunesRpc(agent, data) @@ -559,6 +545,9 @@ function _M.referRunesRpc(agent, data)
559 chero:updateProperty({field = "rune", value = hrunes}) 545 chero:updateProperty({field = "rune", value = hrunes})
560 end 546 end
561 547
  548 + local oldAttr = hero:getTotalAttrs()
  549 + local oldBattleV = hero:getProperty("battleV")
  550 + local wear = {}
562 local curRune = hero:getProperty("rune") 551 local curRune = hero:getProperty("rune")
563 for typ = 1, 6 do 552 for typ = 1, 6 do
564 if runes[typ] then 553 if runes[typ] then
@@ -570,6 +559,7 @@ function _M.referRunesRpc(agent, data) @@ -570,6 +559,7 @@ function _M.referRunesRpc(agent, data)
570 local newRune = role.runeBag[runes[typ]] 559 local newRune = role.runeBag[runes[typ]]
571 newRune:updateProperty({field = "refer",value = hero:getProperty("id")}) 560 newRune:updateProperty({field = "refer",value = hero:getProperty("id")})
572 curRune = curRune:setv(typ, runes[typ]) 561 curRune = curRune:setv(typ, runes[typ])
  562 + wear[runes[typ]] = typ
573 end 563 end
574 564
575 if cur ~= 0 then 565 if cur ~= 0 then
@@ -581,7 +571,22 @@ function _M.referRunesRpc(agent, data) @@ -581,7 +571,22 @@ function _M.referRunesRpc(agent, data)
581 end 571 end
582 end 572 end
583 end 573 end
  574 +
584 hero:updateProperty({field = "rune", value = curRune}) 575 hero:updateProperty({field = "rune", value = curRune})
  576 +
  577 + local attrChange = getChangeAttrJson(oldAttr, hero:getTotalAttrs())
  578 + for runeId, typ in pairs(wear) do
  579 + local ownRune = role.runeBag[runeId]
  580 + role:log("hero_jewel", {
  581 + hero_id = hero:getProperty("type"), -- 英雄ID
  582 + hero_jewel_id = ownRune:getProperty("id"), -- 铭文ID
  583 + hero_jewel_part = typ, -- 铭文装备部位
  584 + hero_jewel_score = hero:getProperty("battleV"), -- 铭文装备后的英雄分值
  585 + hero_jewel_scorebefore = oldBattleV, -- 铭文装备前的英雄分值
  586 + hero_jewel_result = attrChange, -- 铭文装备后效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..}
  587 + })
  588 + end
  589 +
585 SendPacket(actionCodes.Hero_referRunesRpc, "") 590 SendPacket(actionCodes.Hero_referRunesRpc, "")
586 return true 591 return true
587 end 592 end
@@ -600,15 +605,12 @@ function _M.createHeroRandomRpc(agent, data) @@ -600,15 +605,12 @@ function _M.createHeroRandomRpc(agent, data)
600 605
601 local temp = randomData.gift1:randWeight(true) 606 local temp = randomData.gift1:randWeight(true)
602 if not temp or not next(temp) then return end 607 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 608 +
609 role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) 609 role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}})
610 - reward = role:award(reward, {log = {desc = "createHeroRandom"}})  
611 - SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack({reward = reward})) 610 + local reward, change = role:award({[temp[1] + ItemStartId.Hero] = 1}, {log = {desc = "createHeroRandom"}})
  611 +
  612 +
  613 + SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change)))
612 return true 614 return true
613 end 615 end
614 616
@@ -672,27 +674,33 @@ function _M.getResetRewardRpc(agent, data) @@ -672,27 +674,33 @@ function _M.getResetRewardRpc(agent, data)
672 hero:updateProperty({field = "level", value = level}) 674 hero:updateProperty({field = "level", value = level})
673 hero:updateProperty({field = "breakL", value = breakL}) 675 hero:updateProperty({field = "breakL", value = breakL})
674 hero:updateProperty({field = "talent", value = ""}) 676 hero:updateProperty({field = "talent", value = ""})
675 - hero:log({desc = "resetHero"})  
676 677
677 for itemId, count in pairs(reward) do 678 for itemId, count in pairs(reward) do
678 reward[itemId] = math.floor(count * globalCsv.unit_back_discount) 679 reward[itemId] = math.floor(count * globalCsv.unit_back_discount)
679 end 680 end
680 - reward = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}}) 681 + local change
  682 + reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}})
681 683
682 - SendPacket(actionCodes.Hero_getResetRewardRpc, MsgPack.pack({reward = reward})) 684 + role:log("hero_recycle", {
  685 + hero_recycle_list = hero:getProperty("type"), -- 回收的英雄id列表,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
  686 + hero_recycle_reward = reward, -- 回收后获得的奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
  687 + hero_recycle_cnt = 1, -- 总回收英雄量
  688 + })
  689 + SendPacket(actionCodes.Hero_getResetRewardRpc, MsgPack.pack(role:packReward(reward, change)))
683 return true 690 return true
684 end 691 end
685 692
686 -  
687 -  
688 function _M.drawHeroRpc(agent, data) 693 function _M.drawHeroRpc(agent, data)
689 local role = agent.role 694 local role = agent.role
690 local msg = MsgPack.unpack(data) 695 local msg = MsgPack.unpack(data)
691 696
692 if not role:isFuncUnlock(FuncUnlock.GetHero) then return end 697 if not role:isFuncUnlock(FuncUnlock.GetHero) then return end
693 - local btype = msg.pool -- 1 2 3 4 698 + local btype = msg.pool -- 1 2 3 卡池类型
  699 + local subType = msg.subType or 1-- 定向卡池需要传 子类型
694 local drawType = msg.type -- 1 单抽 2 十连 700 local drawType = msg.type -- 1 单抽 2 十连
695 - local guide = msg.guide -- 是否是引导抽的 701 + if btype ~= 1 then
  702 + subType = 1
  703 + end
696 704
697 local buildTypeData = csvdb["build_typeCsv"][btype] 705 local buildTypeData = csvdb["build_typeCsv"][btype]
698 if not buildTypeData then return 1 end 706 if not buildTypeData then return 1 end
@@ -700,12 +708,10 @@ function _M.drawHeroRpc(agent, data) @@ -700,12 +708,10 @@ function _M.drawHeroRpc(agent, data)
700 local drawCount = {1, 10} -- 抽取次数 708 local drawCount = {1, 10} -- 抽取次数
701 if not drawCount[drawType] then return 2 end 709 if not drawCount[drawType] then return 2 end
702 710
703 - local newerDraw  
704 - if btype == 4 then  
705 - newerDraw = role:getProperty("newerDraw")  
706 - if math.illegalNum(globalCsv.draw_newer[2] - (newerDraw[1] or 0), drawCount[drawType], globalCsv.draw_newer[2]) then return 11 end  
707 - end  
708 - 711 + local draw_floor_back_counts = globalCsv.draw_floor_back_counts[btype]
  712 + local floorHeroCount = role:getProperty("floorHero")[btype] or 0
  713 +
  714 + -- 计算抽卡消耗品
709 local cost = {} 715 local cost = {}
710 local lastCount = drawCount[drawType] 716 local lastCount = drawCount[drawType]
711 for _, costType in ipairs({"draw_card", "draw_coin"}) do 717 for _, costType in ipairs({"draw_card", "draw_coin"}) do
@@ -727,44 +733,36 @@ function _M.drawHeroRpc(agent, data) @@ -727,44 +733,36 @@ function _M.drawHeroRpc(agent, data)
727 return 3 733 return 3
728 end 734 end
729 735
730 - -- pool 固定的  
731 - local poolEnum = {  
732 - [1] = {  
733 - [1] = 1,  
734 - [2] = 2,  
735 - [3] = 3,  
736 - },  
737 - [2] = 10,  
738 - [3] = 11,  
739 - [4] = 12,  
740 - }  
741 -  
742 -- 抽取的池子 736 -- 抽取的池子
743 - local pool = poolEnum[btype] 737 + local poolMap = buildTypeData["pool"]:toNumMap()
  738 + local poolId = poolMap[subType]
  739 + if not poolId then return end
  740 +
  741 + --判断定向卡池是否开启
744 if btype == 1 then 742 if btype == 1 then
745 - -- 超级卡池子 每周轮换 有活动覆盖之  
746 - --TODO 活动判断  
747 - if false then  
748 - else  
749 - for idx, poolId in pairs(pool) do  
750 - if role:isTimeResetOpen(TimeReset["DrawType" .. idx]) then  
751 - pool = poolId  
752 - break 743 + if not role:isTimeResetOpen(TimeReset["DrawType" .. subType]) then
  744 + local unlockPool = role.dailyData:getProperty("unlockPool")
  745 + if not unlockPool[subType] then
  746 + return 1
753 end 747 end
754 end 748 end
755 - if type(pool) ~= "number" then  
756 - pool = -1  
757 - end  
758 - end  
759 end 749 end
760 - local unitPool = csvdb["build_unitCsv"][pool] 750 +
  751 + --TODO 活动覆盖
  752 + local actPoolId = role.activity:getActivityPool(btype, subType)
  753 + if actPoolId ~= 0 then
  754 + poolId = actPoolId
  755 + end
  756 +
  757 + local unitPool = csvdb["build_unitCsv"][poolId]
761 if not unitPool then return 4 end 758 if not unitPool then return 4 end
762 759
763 -- 开始抽 760 -- 开始抽
764 local resultPool = {} 761 local resultPool = {}
765 - local function fillDrawPool(fixRare, fixCamp, ssrUp, floorBack) 762 + local function fillDrawPool(isFloorBack)
766 local condition = {"rare", "camp"} 763 local condition = {"rare", "camp"}
767 - local values = {fixRare, fixCamp} 764 + local values = {}
  765 +
768 766
769 for idx, field in ipairs(condition) do 767 for idx, field in ipairs(condition) do
770 if not values[idx] then 768 if not values[idx] then
@@ -775,44 +773,30 @@ function _M.drawHeroRpc(agent, data) @@ -775,44 +773,30 @@ function _M.drawHeroRpc(agent, data)
775 curIdx = curIdx + 1 773 curIdx = curIdx + 1
776 end 774 end
777 775
778 - -- 稀有度 ssr up  
779 - if field == "rare" then  
780 - local all = 0  
781 - for _, weight in pairs(lpool) do  
782 - all = all + weight[1]  
783 - end  
784 - --[[  
785 - SSR概率值:初始概率 + 步长概率  
786 - SR概率值:初始概率 * [ (初始概率+R初始概率) - 步长概率 ] /(初始概率+R初始概率)  
787 - R概率值:初始概率 * [ (初始概率+SR初始概率) - 步长概率 ] /(初始概率+SR初始概率)  
788 - ]]  
789 - local ssrAdd = (ssrUp or 0) * all  
790 - local last = all - lpool[4][1]  
791 - lpool[4][1] = lpool[4][1] + ssrAdd  
792 - lpool[3][1] = lpool[3][1] * (last - ssrAdd) / last  
793 - lpool[2][1] = lpool[2][1] * (last - ssrAdd) / last  
794 - end  
795 -  
796 if next(lpool) then 776 if next(lpool) then
797 values[idx] = math.randWeight(lpool, 1) 777 values[idx] = math.randWeight(lpool, 1)
798 end 778 end
799 end 779 end
800 end 780 end
801 781
802 - for itemId, oneData in pairs(floorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do  
803 - if oneData["pool_" .. pool] and oneData["pool_" .. pool] ~= "" then 782 + for itemId, oneData in pairs(isFloorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do
  783 + local pool_str = "pool_" .. poolId
  784 + if oneData[pool_str] and oneData[pool_str] ~= "" then
804 local itemData = csvdb["itemCsv"][itemId] 785 local itemData = csvdb["itemCsv"][itemId]
805 while itemData do 786 while itemData do
806 if itemData.type ~= ItemType.Hero then break end 787 if itemData.type ~= ItemType.Hero then break end
807 local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] 788 local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero]
808 if not heroData then break end 789 if not heroData then break end
809 local ok = true 790 local ok = true
810 - for idx, field in ipairs(condition) do  
811 - if heroData[field] ~= values[idx] then ok = false break end 791 + -- 保底是全随机,不用比较类型
  792 + if not isFloorBack then
  793 + for idx, field in ipairs(condition) do
  794 + if heroData[field] ~= values[idx] then ok = false break end
  795 + end
812 end 796 end
813 if not ok then break end 797 if not ok then break end
814 - if oneData["pool_" .. pool] > 0 then  
815 - resultPool[itemId] = {oneData["pool_" .. pool]} -- itemId, count, 概率 798 + if oneData[pool_str] > 0 then
  799 + resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率
816 end 800 end
817 break 801 break
818 end 802 end
@@ -820,61 +804,37 @@ function _M.drawHeroRpc(agent, data) @@ -820,61 +804,37 @@ function _M.drawHeroRpc(agent, data)
820 end 804 end
821 end 805 end
822 806
823 - role:costItems(cost, {log = {desc = "drawHero", short1 = btype, int1 = pool}})  
824 -  
825 - local draw_floor_back_counts = globalCsv.draw_floor_back_counts[btype]  
826 - local draw_ssr_up_count_rate = globalCsv.draw_ssr_up_count_rate[btype]  
827 - local floorHeroCount = role:getProperty("floorHero")[btype] or 0  
828 - local ssrUpCount = role:getProperty("ssrUp")[btype] or 0 807 + role:costItems(cost, {log = {desc = "drawHero", int1 = btype, int2 = poolId}})
829 808
830 - local newerDrawCount, newerHadSSR  
831 - if btype == 4 then  
832 - newerDrawCount = newerDraw[1] or 0  
833 - newerHadSSR = newerDraw[2] or 0 809 + local guideHero
  810 + if role:getProperty("newerGuide") == "11=1" then
  811 + guideHero = 613
834 end 812 end
835 813
836 local ssrCount = 0 814 local ssrCount = 0
837 local reward = {} 815 local reward = {}
838 for i = 1, drawCount[drawType] do 816 for i = 1, drawCount[drawType] do
839 floorHeroCount = floorHeroCount + 1 817 floorHeroCount = floorHeroCount + 1
840 - if btype == 4 then  
841 - newerDrawCount = newerDrawCount + 1  
842 - end  
843 -  
844 - resultPool = {}  
845 local isFloorBack = draw_floor_back_counts and floorHeroCount >= draw_floor_back_counts 818 local isFloorBack = draw_floor_back_counts and floorHeroCount >= draw_floor_back_counts
846 - local isNewerSSR = btype == 4 and (newerHadSSR == 0 and newerDrawCount >= globalCsv.draw_newer[1]) or false  
847 -  
848 - local ssrUp = 0  
849 - if draw_ssr_up_count_rate and ssrUpCount > draw_ssr_up_count_rate[1] then  
850 - ssrUp = math.min((ssrUpCount - draw_ssr_up_count_rate[1]) * draw_ssr_up_count_rate[2], draw_ssr_up_count_rate[3]) / 100 819 + resultPool = {}
  820 + fillDrawPool(isFloorBack)
  821 + if not next(resultPool) then
  822 + skynet.error("random pool error, poolId:" .. poolId)
  823 + return
851 end 824 end
852 - while not next(resultPool) do  
853 - if isNewerSSR then  
854 - fillDrawPool(4) -- 新手保底的 ssr  
855 - elseif isFloorBack then  
856 - -- 保底 sr 【郑斌】明确  
857 - -- 保底 sr 改为 池子随机 sr 或者 ssr【郑斌】  
858 - fillDrawPool(nil, nil, nil, true)  
859 - else  
860 - fillDrawPool(nil, nil, ssrUp)  
861 - end 825 +
  826 + local itemId = math.randWeight(resultPool, 1)
  827 + if guideHero then
  828 + itemId = guideHero
  829 + guideHero = nil
862 end 830 end
863 831
864 - -- 引导必送 613 丝路德  
865 - local itemId = (guide and drawType == 1) and 613 or math.randWeight(resultPool, 1)  
866 local itemData = csvdb["itemCsv"][itemId] 832 local itemData = csvdb["itemCsv"][itemId]
867 - if itemData.quality == 4 then 833 + if itemData.quality == HeroQuality.SSR then
868 ssrCount = ssrCount + 1 834 ssrCount = ssrCount + 1
869 - ssrUpCount = 0  
870 - if btype == 4 then  
871 - newerHadSSR = newerHadSSR + 1  
872 - end  
873 - else  
874 - ssrUpCount = ssrUpCount + 1  
875 end 835 end
876 836
877 - if itemData.quality >= 3 then 837 + if itemData.quality >= HeroQuality.SR then
878 floorHeroCount = 0 838 floorHeroCount = 0
879 end 839 end
880 840
@@ -882,10 +842,10 @@ function _M.drawHeroRpc(agent, data) @@ -882,10 +842,10 @@ function _M.drawHeroRpc(agent, data)
882 local fragId = itemData.id - ItemStartId.Hero 842 local fragId = itemData.id - ItemStartId.Hero
883 local heroData = csvdb["unitCsv"][fragId] 843 local heroData = csvdb["unitCsv"][fragId]
884 local count = globalCsv.draw_unit_tofragment[heroData.rare] 844 local count = globalCsv.draw_unit_tofragment[heroData.rare]
885 - role:award({[fragId] = count}, {log = {desc = "drawHero", short1 = btype, int1 = pool}}) 845 + role:award({[fragId] = count}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}})
886 table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1}) 846 table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1})
887 else 847 else
888 - role:award({[itemId] = 1}, {log = {desc = "drawHero", short1 = btype, int1 = pool}}) 848 + role:award({[itemId] = 1}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}})
889 table.insert(reward, {id = itemId, count = 1}) 849 table.insert(reward, {id = itemId, count = 1})
890 end 850 end
891 end 851 end
@@ -896,59 +856,104 @@ function _M.drawHeroRpc(agent, data) @@ -896,59 +856,104 @@ function _M.drawHeroRpc(agent, data)
896 role:setProperty("floorHero", floorHero) 856 role:setProperty("floorHero", floorHero)
897 end 857 end
898 858
899 - if draw_ssr_up_count_rate then  
900 - local ssrUp = role:getProperty("ssrUp")  
901 - ssrUp[btype] = ssrUpCount  
902 - role:setProperty("ssrUp", ssrUp) 859 + if btype == 1 or btype == 2 then
  860 + local repayHero = role:getProperty("repayHero") or 0
  861 + repayHero = repayHero + drawCount[drawType]
  862 + role:updateProperty({field = "repayHero", value = repayHero})
903 end 863 end
904 864
905 - if btype == 4 then  
906 - newerDraw[1] = newerDrawCount  
907 - newerDraw[2] = newerHadSSR  
908 - role:updateProperty({field = "newerDraw", value = newerDraw})  
909 - end  
910 -  
911 - -- if pool == 1 then  
912 - -- local repayHero = role:getProperty("repayHero")  
913 - -- repayHero = math.min(globalCsv.draw_super_repay_count, repayHero + drawCount[drawType])  
914 - -- role:updateProperty({field = "repayHero", value = repayHero})  
915 - -- end  
916 -  
917 role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) 865 role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]})
918 if ssrCount > 0 then 866 if ssrCount > 0 then
919 role:checkTaskEnter("DrawSSR", {count = ssrCount}) 867 role:checkTaskEnter("DrawSSR", {count = ssrCount})
920 end 868 end
921 - role:log("hero_action", {desc = "drawHero", short1 = btype, int1 = drawCount[drawType], int2 = pool}) 869 + role:finishGuide(11)
  870 +
  871 + role:log("gacha", {
  872 + gacha_id = poolId, -- 卡池ID
  873 + gacha_type = btype, -- 卡池类型
  874 + gacha_up = 0, -- 卡池UP角色
  875 + gacha_times = drawCount[drawType], -- 抽卡次数
  876 + gacha_reward = reward, -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
  877 + currency = cost, -- 购买道具消耗的货币
  878 + })
922 SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 879 SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组
923 return true 880 return true
924 end 881 end
925 882
926 --- function _M.repayHeroRpc(agent, data)  
927 --- local role = agent.role  
928 -  
929 --- local repayHero = role:getProperty("repayHero")  
930 --- if repayHero < globalCsv.draw_super_repay_count then  
931 --- return  
932 --- end  
933 -  
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 883 +function _M.repayHeroRpc(agent, data)
  884 + local role = agent.role
  885 +
  886 + local repayHero = role:getProperty("repayHero")
  887 + local cnt = globalCsv.draw_times_to_get_ssr or 100
  888 + if repayHero < cnt then
  889 + return
  890 + end
  891 + local result = repayHero - cnt
  892 +
  893 + role:updateProperty({field = "repayHero", value = result})
  894 + local id = math.randWeight(csvdb["build_giftCsv"], "pool_1")
  895 +
  896 + local reward = {}
  897 + local itemData = csvdb["itemCsv"][id]
  898 + if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then
  899 + local fragId = itemData.id - ItemStartId.Hero
  900 + local heroData = csvdb["unitCsv"][fragId]
  901 + local count = globalCsv.draw_unit_tofragment[heroData.rare]
  902 + role:award({[fragId] = count}, {log = {desc = "heroRepay"}})
  903 + reward = {id = fragId, count = count, from = id, fcount = 1}
  904 + else
  905 + role:award({[id] = 1}, {log = {desc = "heroRepay"}})
  906 + reward = {id = id, count = 1}
  907 + end
  908 + SendPacket(actionCodes.Hero_repayHeroRpc, MsgPack.pack({reward = reward}))
  909 + return true
  910 +end
  911 +
  912 +function _M.unlockPoolRpc(agent, data)
  913 + local role = agent.role
  914 + local msg = MsgPack.unpack(data)
  915 +
  916 + if not role:isFuncUnlock(FuncUnlock.GetHero) then return end
  917 + local type = msg.type -- 指定定向卡池需要类型 1, 2, 3
  918 + local needCost = true
  919 + --当前开启的类型不用解锁
  920 + if role:isTimeResetOpen(TimeReset["DrawType" .. type]) then
  921 + needCost = false
  922 + end
  923 + --已经解锁的不需要重复解锁
  924 + local unlockPool = role.dailyData:getProperty("unlockPool")
  925 + if unlockPool[type] then
  926 + needCost = false
  927 + end
  928 +
  929 + if needCost then
  930 + if not role:costDiamond({count = globalCsv.draw_unlock_pool_diamond or 300, log = {desc = "unlockPool", int1 = type}}) then
  931 + return
  932 + end
  933 + end
  934 +
  935 + unlockPool[type] = 1
  936 + role.dailyData:updateProperty({field="unlockPool", value = unlockPool})
  937 + role.dailyData:updateProperty({field="curPool", value = type})
  938 +
  939 + --role:log("hero_action", {desc = "unlockPool", int1=type})
  940 + SendPacket(actionCodes.Hero_unlockPoolRpc, MsgPack.pack({}))
  941 + return true
  942 +end
  943 +
  944 +function _M.changeCrown(agnet, data)
  945 + local role = agent.role
  946 + local msg = MsgPack.unpack(data)
  947 +
  948 + local heroType = msg.heroType
  949 +
  950 + if not role:isHaveHero(heroType) then return true end
  951 + role:setProperty("crown", heroType)
  952 +
  953 + role:log("hero_show", {
  954 + hero_id = heroType,
  955 + })
  956 + return true
  957 +end
953 958
954 return _M 959 return _M
955 \ No newline at end of file 960 \ 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
@@ -287,7 +287,7 @@ function _M.startBattleRpc(agent, data) @@ -287,7 +287,7 @@ function _M.startBattleRpc(agent, data)
287 if pvpFree >= globalCsv.pvp_battle_free_count then 287 if pvpFree >= globalCsv.pvp_battle_free_count then
288 local cost = {[ItemId.PvpKey] = 1} 288 local cost = {[ItemId.PvpKey] = 1}
289 if not role:checkItemEnough(cost) then return 5 end 289 if not role:checkItemEnough(cost) then return 5 end
290 - role:costItems(cost, {log = {desc = "startPvp", short1 = 1}}) 290 + role:costItems(cost, {log = {desc = "startPvp", int1 = 1}})
291 else 291 else
292 role.dailyData:updateProperty({field = "pvpFree", delta = 1}) 292 role.dailyData:updateProperty({field = "pvpFree", delta = 1})
293 end 293 end
@@ -296,9 +296,6 @@ function _M.startBattleRpc(agent, data) @@ -296,9 +296,6 @@ function _M.startBattleRpc(agent, data)
296 _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge} 296 _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge}
297 297
298 role:checkTaskEnter("PvpBattle") 298 role:checkTaskEnter("PvpBattle")
299 -  
300 -  
301 - role:log("pvp_action", {desc = "startBattle", short1 = 1, int1 = revenge and 1 or 0})  
302 end 299 end
303 300
304 SendPacket(actionCodes.Pvp_startBattleRpc, MsgPack.pack({matchInfo = matchInfo, key = key, result = result, wait = wait})) 301 SendPacket(actionCodes.Pvp_startBattleRpc, MsgPack.pack({matchInfo = matchInfo, key = key, result = result, wait = wait}))
@@ -311,7 +308,8 @@ function _M.endBattleRpc(agent, data) @@ -311,7 +308,8 @@ function _M.endBattleRpc(agent, data)
311 local msg = MsgPack.unpack(data) 308 local msg = MsgPack.unpack(data)
312 309
313 if not msg.key or not _pvpStartBattleCacheC or msg.key ~= _pvpStartBattleCacheC.key then 310 if not msg.key or not _pvpStartBattleCacheC or msg.key ~= _pvpStartBattleCacheC.key then
314 - return 1 311 + SendPacket(actionCodes.Pvp_endBattleRpc, MsgPack.pack({errorCode = 1}))
  312 + return true
315 end 313 end
316 314
317 if not msg.idx or msg.idx ~= _pvpStartBattleCacheC.idx then 315 if not msg.idx or msg.idx ~= _pvpStartBattleCacheC.idx then
@@ -334,14 +332,9 @@ function _M.endBattleRpc(agent, data) @@ -334,14 +332,9 @@ function _M.endBattleRpc(agent, data)
334 if not match then return end 332 if not match then return end
335 333
336 local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true) 334 local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true)
337 - local reward = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}}) 335 + 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) 336 local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin)
339 337
340 - _pvpBattleInfoCacheC = {} --重新发阵容了 没毛病  
341 - _pvpRecordInfoCacheC = {} -- 记录刷新了  
342 - _pvpRecordBattleInfoCacheC = {} -- 取新纪录的时候搞  
343 - _pvpStartBattleCacheC = nil  
344 -  
345 -- 请求上传录像 338 -- 请求上传录像
346 local params = { 339 local params = {
347 ["roleid"] = roleId, 340 ["roleid"] = roleId,
@@ -349,12 +342,13 @@ function _M.endBattleRpc(agent, data) @@ -349,12 +342,13 @@ function _M.endBattleRpc(agent, data)
349 ["time"] = now, 342 ["time"] = now,
350 } 343 }
351 local status, body = httpc.get(remoteUrl, "/applyvideo?" .. httpGetFormatData(params), {}, {}) 344 local status, body = httpc.get(remoteUrl, "/applyvideo?" .. httpGetFormatData(params), {}, {})
352 - local video = nil 345 + local video, headers = nil, nil
353 if tonumber(status) == 200 then 346 if tonumber(status) == 200 then
354 local result = json.decode(body) 347 local result = json.decode(body)
355 video = result.name 348 video = result.name
  349 + headers = result.headers
356 else 350 else
357 - skynet.error("applyvideo", "error", status, body, content) 351 + skynet.error("applyvideo", "error", status, body)
358 end 352 end
359 353
360 -- 加入战斗记录 354 -- 加入战斗记录
@@ -390,10 +384,24 @@ function _M.endBattleRpc(agent, data) @@ -390,10 +384,24 @@ function _M.endBattleRpc(agent, data)
390 role:checkTaskEnter("PvpWin", {score = myScore}) 384 role:checkTaskEnter("PvpWin", {score = myScore})
391 end 385 end
392 386
393 - role:log("pvp_action", {desc = "battleEnd", short1 = 1, int1 = isWin and 1 or 0, int2 = revenge and 1 or 0}) 387 + role:checkBattle("pvpc", {
  388 + isWin = isWin,
  389 + info = msg.info,
  390 + robotId = match.t == 2 and match.id or nil,
  391 + enemy = match.t == 1 and _pvpBattleInfoCacheC[match.id] or nil,
  392 + score = myScore,
  393 + reward = reward,
  394 + rank = myRank,
  395 + })
394 396
  397 + _pvpBattleInfoCacheC = {} --重新发阵容了 没毛病
  398 + _pvpRecordInfoCacheC = {} -- 记录刷新了
  399 + _pvpRecordBattleInfoCacheC = {} -- 取新纪录的时候搞
  400 + _pvpStartBattleCacheC = nil
  401 +
395 SendPacket(actionCodes.Pvp_endBattleRpc, MsgPack.pack({ 402 SendPacket(actionCodes.Pvp_endBattleRpc, MsgPack.pack({
396 reward = reward, 403 reward = reward,
  404 + change = change,
397 myScore = myScore, 405 myScore = myScore,
398 matchScore = matchScore, 406 matchScore = matchScore,
399 oldmyScore = oldmyScore, 407 oldmyScore = oldmyScore,
@@ -401,6 +409,7 @@ function _M.endBattleRpc(agent, data) @@ -401,6 +409,7 @@ function _M.endBattleRpc(agent, data)
401 myRank = myRank, 409 myRank = myRank,
402 oldMyRank = oldMyRank, 410 oldMyRank = oldMyRank,
403 video = video, 411 video = video,
  412 + headers = headers,
404 })) 413 }))
405 return true 414 return true
406 end 415 end
@@ -490,7 +499,7 @@ function _M.startBattleHRpc(agent, data) @@ -490,7 +499,7 @@ function _M.startBattleHRpc(agent, data)
490 if pvpFreeH >= globalCsv.pvp_battle_free_count_high then 499 if pvpFreeH >= globalCsv.pvp_battle_free_count_high then
491 local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost} 500 local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost}
492 if not role:checkItemEnough(cost) then return 5 end 501 if not role:checkItemEnough(cost) then return 5 end
493 - role:costItems(cost, {log = {desc = "startPvp", short1 = 2}}) 502 + role:costItems(cost, {log = {desc = "startPvp", int1 = 2}})
494 else 503 else
495 role.dailyData:updateProperty({field = "pvpFreeH", delta = 1}) 504 role.dailyData:updateProperty({field = "pvpFreeH", delta = 1})
496 end 505 end
@@ -516,8 +525,6 @@ function _M.startBattleHRpc(agent, data) @@ -516,8 +525,6 @@ function _M.startBattleHRpc(agent, data)
516 525
517 role:checkTaskEnter("PvpBattle") 526 role:checkTaskEnter("PvpBattle")
518 527
519 - role:log("pvp_action", {desc = "startBattle", short1 = 2, int1 = revenge and 1 or 0})  
520 -  
521 end 528 end
522 529
523 SendPacket(actionCodes.Pvp_startBattleHRpc, MsgPack.pack({ 530 SendPacket(actionCodes.Pvp_startBattleHRpc, MsgPack.pack({
@@ -536,7 +543,8 @@ function _M.endBattleHRpc(agent, data) @@ -536,7 +543,8 @@ function _M.endBattleHRpc(agent, data)
536 local msg = MsgPack.unpack(data) 543 local msg = MsgPack.unpack(data)
537 544
538 if not msg.key or not _pvpStartBattleCacheH or msg.key ~= _pvpStartBattleCacheH.key then 545 if not msg.key or not _pvpStartBattleCacheH or msg.key ~= _pvpStartBattleCacheH.key then
539 - return 1 546 + SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({errorCode = 1}))
  547 + return true
540 end 548 end
541 549
542 if not msg.idx or msg.idx ~= _pvpStartBattleCacheH.idx then 550 if not msg.idx or msg.idx ~= _pvpStartBattleCacheH.idx then
@@ -565,12 +573,13 @@ function _M.endBattleHRpc(agent, data) @@ -565,12 +573,13 @@ function _M.endBattleHRpc(agent, data)
565 ["time"] = now, 573 ["time"] = now,
566 } 574 }
567 local status, body = httpc.get(remoteUrl, "/applyvideo?" .. httpGetFormatData(params), {}, {}) 575 local status, body = httpc.get(remoteUrl, "/applyvideo?" .. httpGetFormatData(params), {}, {})
568 - local video = nil 576 + local video, headers = nil, nil
569 if tonumber(status) == 200 then 577 if tonumber(status) == 200 then
570 local result = json.decode(body) 578 local result = json.decode(body)
571 video = result.name 579 video = result.name
  580 + headers = result.headers
572 else 581 else
573 - skynet.error("applyvideo", "error", status, body, content) 582 + skynet.error("applyvideo", "error", status, body)
574 end 583 end
575 584
576 table.insert(_pvpStartBattleCacheH.result, { 585 table.insert(_pvpStartBattleCacheH.result, {
@@ -611,13 +620,14 @@ function _M.endBattleHRpc(agent, data) @@ -611,13 +620,14 @@ function _M.endBattleHRpc(agent, data)
611 key = key, --战斗校验 key 620 key = key, --战斗校验 key
612 round = round, -- 战斗场数索引 621 round = round, -- 战斗场数索引
613 video = video, -- 返回让客户端上传录像 622 video = video, -- 返回让客户端上传录像
  623 + headers = headers,
614 })) 624 }))
615 return true 625 return true
616 end 626 end
617 627
618 -- 战斗结束了发奖 628 -- 战斗结束了发奖
619 local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true) 629 local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true)
620 - local reward = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleH"}}) 630 + 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 631 local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, 0, 0
622 if role:isTimeResetOpen(TimeReset.PvpHight) then 632 if role:isTimeResetOpen(TimeReset.PvpHight) then
623 myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin) 633 myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin)
@@ -676,6 +686,17 @@ function _M.endBattleHRpc(agent, data) @@ -676,6 +686,17 @@ function _M.endBattleHRpc(agent, data)
676 end 686 end
677 end) 687 end)
678 688
  689 + role:checkBattle("pvph", {
  690 + isWin = isWin,
  691 + info = msg.info,
  692 + robotId = match.t == 2 and match.id or nil,
  693 + enemy = match.t == 1 and (revenge and _pvpRecordBattleInfoCacheH[match.id] or _pvpBattleInfoCacheH[match.id]) or nil,
  694 + score = myScore,
  695 + reward = reward,
  696 + rank = myRank,
  697 + })
  698 +
  699 +
679 _pvpBattleInfoCacheH = {} --重新发阵容了 没毛病 700 _pvpBattleInfoCacheH = {} --重新发阵容了 没毛病
680 _pvpRecordInfoCacheH = {} -- 记录刷新了 701 _pvpRecordInfoCacheH = {} -- 记录刷新了
681 _pvpRecordBattleInfoCacheH = {} -- 取新纪录的时候搞 702 _pvpRecordBattleInfoCacheH = {} -- 取新纪录的时候搞
@@ -686,10 +707,10 @@ function _M.endBattleHRpc(agent, data) @@ -686,10 +707,10 @@ function _M.endBattleHRpc(agent, data)
686 if isWin then 707 if isWin then
687 role:checkTaskEnter("PvpWin", {score = myScore}) 708 role:checkTaskEnter("PvpWin", {score = myScore})
688 end 709 end
689 - role:log("pvp_action", {desc = "battleEnd", short1 = 2, int1 = isWin and 1 or 0, int2 = revenge and 1 or 0})  
690 - 710 +
691 SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({ 711 SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({
692 reward = reward, 712 reward = reward,
  713 + change = change,
693 myScore = myScore, 714 myScore = myScore,
694 matchScore = matchScore, 715 matchScore = matchScore,
695 oldmyScore = oldmyScore, 716 oldmyScore = oldmyScore,
@@ -833,10 +854,9 @@ function _M.highDivisionGiftRpc(agent, data) @@ -833,10 +854,9 @@ function _M.highDivisionGiftRpc(agent, data)
833 pvpHGift = {}, 854 pvpHGift = {},
834 }) 855 })
835 856
836 - local reward = role:award(newReward, {log = {desc = "pvpDivisionH"}})  
837 - role:log("pvp_action", {desc = "pvpDivisionH"}) 857 + local reward, change = role:award(newReward, {log = {desc = "pvpDivisionH"}})
838 858
839 - SendPacket(actionCodes.Pvp_highDivisionGiftRpc, MsgPack.pack({reward = reward})) 859 + SendPacket(actionCodes.Pvp_highDivisionGiftRpc, MsgPack.pack(role:packReward(reward, change)))
840 return true 860 return true
841 end 861 end
842 862
@@ -867,11 +887,9 @@ function _M.shopBuyRpc(agent, data) @@ -867,11 +887,9 @@ function _M.shopBuyRpc(agent, data)
867 for id, c in pairs(gift) do 887 for id, c in pairs(gift) do
868 gift[id] = c * count 888 gift[id] = c * count
869 end 889 end
870 - local reward = role:award(gift, {log = {desc = "pvpShop", int1 = id, int2 = count}})  
871 -  
872 - role:log("pvp_action", {desc = "pvpShop", int1 = id, int2 = count}) 890 + local reward, change = role:award(gift, {log = {desc = "pvpShop", int1 = id, int2 = count}})
873 891
874 - SendPacket(actionCodes.Pvp_shopBuyRpc, MsgPack.pack({reward = reward})) 892 + SendPacket(actionCodes.Pvp_shopBuyRpc, MsgPack.pack(role:packReward(reward, change)))
875 return true 893 return true
876 end 894 end
877 895
@@ -962,7 +980,6 @@ function _M.crossBetRpc(agent, data) @@ -962,7 +980,6 @@ function _M.crossBetRpc(agent, data)
962 local result, code = role:setCrossServerPvpBet(msg.idx) 980 local result, code = role:setCrossServerPvpBet(msg.idx)
963 if not result then return 10 + code end 981 if not result then return 10 + code end
964 982
965 - role:log("pvp_action", {desc = "crossBet"})  
966 SendPacket(actionCodes.Pvp_crossBetRpc, MsgPack.pack(result)) 983 SendPacket(actionCodes.Pvp_crossBetRpc, MsgPack.pack(result))
967 return true 984 return true
968 end 985 end
src/actions/RoleAction.lua
@@ -95,11 +95,33 @@ function _M.loginRpc( agent, data ) @@ -95,11 +95,33 @@ 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
102 101
  102 +
  103 + role.sysVersion = msg.sysVersion
  104 + role.ip = agent.ip:toArray(false, ":")[1]
  105 + role.clientVersion = msg.clientVersion
  106 + role.network = msg.network
  107 +
  108 + if msg.subId then
  109 + role:setProperty("sid", msg.subId)
  110 + end
  111 +
  112 + if msg.deviceMode then
  113 + local deviceMode = tostring(msg.deviceMode)
  114 + if role:getProperty("dmode") ~= deviceMode then
  115 + role:setProperty("dmode", deviceMode)
  116 + end
  117 + end
  118 + if msg.device then
  119 + local device = tostring(msg.device)
  120 + if role:getProperty("device") ~= device then
  121 + role:setProperty("device", device)
  122 + end
  123 + end
  124 +
103 if not msg.isGMlogin then 125 if not msg.isGMlogin then
104 local banTime = role:getProperty("banTime") 126 local banTime = role:getProperty("banTime")
105 if banTime > now then 127 if banTime > now then
@@ -115,6 +137,20 @@ function _M.loginRpc( agent, data ) @@ -115,6 +137,20 @@ function _M.loginRpc( agent, data )
115 role:setBan(0) 137 role:setBan(0)
116 end 138 end
117 end 139 end
  140 +
  141 + if msg.deviceMode then
  142 + local deviceMode = tostring(msg.deviceMode)
  143 + if role:getProperty("dmode") ~= deviceMode then
  144 + role:setProperty("dmode", deviceMode)
  145 + end
  146 + end
  147 + if msg.device then
  148 + local device = tostring(msg.device)
  149 + if role:getProperty("device") ~= device then
  150 + role:setProperty("device", device)
  151 + end
  152 + end
  153 +
118 SERV_OPEN = redisproxy:hget("autoincrement_set", "server_start") 154 SERV_OPEN = redisproxy:hget("autoincrement_set", "server_start")
119 155
120 role:changeStructVersion() -- 数据结构 版本更新 156 role:changeStructVersion() -- 数据结构 版本更新
@@ -128,8 +164,10 @@ function _M.loginRpc( agent, data ) @@ -128,8 +164,10 @@ function _M.loginRpc( agent, data )
128 164
129 redisproxy:zadd(FRIEND_RECOMMEND, now, roleId) 165 redisproxy:zadd(FRIEND_RECOMMEND, now, roleId)
130 166
131 - for _, name in ipairs({"dailyData", "dinerData", "activity"}) do 167 + for _, name in ipairs({"dailyData", "dinerData", "activity", "storeData"}) do
132 response[name] = role[name]:data() 168 response[name] = role[name]:data()
  169 + --print("["..name.."]")
  170 + --dump(response[name])
133 end 171 end
134 172
135 response.role = role:data() 173 response.role = role:data()
@@ -252,7 +290,7 @@ function _M.loginRpc( agent, data ) @@ -252,7 +290,7 @@ function _M.loginRpc( agent, data )
252 role:savePvpHTeam() 290 role:savePvpHTeam()
253 291
254 local hangPass = role:getProperty("hangPass") 292 local hangPass = role:getProperty("hangPass")
255 - role:log("login", {key1 = agent.ip:toArray(false, ":")[1], int1 = hangPass[1] or 0}) 293 + role:log("onLogin")
256 294
257 return true 295 return true
258 end 296 end
@@ -285,7 +323,8 @@ function _M.createRpc(agent, data) @@ -285,7 +323,8 @@ function _M.createRpc(agent, data)
285 sid = msg.subId or 0, 323 sid = msg.subId or 0,
286 name = roleName, 324 name = roleName,
287 uname = msg.uname or "", 325 uname = msg.uname or "",
288 - device = tostring(msg.device) 326 + device = tostring(msg.device),
  327 + dmode = msg.deviceMode and tostring(msg.deviceMode) or nil
289 }) 328 })
290 329
291 if newRole:create() then 330 if newRole:create() then
@@ -299,11 +338,20 @@ function _M.createRpc(agent, data) @@ -299,11 +338,20 @@ function _M.createRpc(agent, data)
299 return true 338 return true
300 end 339 end
301 newRole:startActionUcode() 340 newRole:startActionUcode()
  341 + newRole.sysVersion = msg.sysVersion
  342 + newRole.ip = agent.ip:toArray(false, ":")[1]
  343 + newRole.clientVersion = msg.clientVersion
  344 + newRole.network = msg.network
  345 +
302 newRole:award(globalCsv.birthItem, {log = {desc = "birth"}, notNotify = true}) 346 newRole:award(globalCsv.birthItem, {log = {desc = "birth"}, notNotify = true})
303 -- 欢迎邮件 347 -- 欢迎邮件
304 redisproxy:insertEmail({roleId = roleId, emailId = 1}) 348 redisproxy:insertEmail({roleId = roleId, emailId = 1})
305 349
306 - newRole:log("create", {key1 = agent.ip:toArray(false, ":")[1]}) 350 + if msg.newuser then
  351 + newRole:log("onCreateAccount")
  352 + end
  353 + newRole:log("onCreateRole")
  354 +
307 355
308 SendPacket(actionCodes.Role_createRpc, MsgPack.pack(response)) 356 SendPacket(actionCodes.Role_createRpc, MsgPack.pack(response))
309 return true 357 return true
@@ -405,12 +453,22 @@ function _M.saleItemRpc(agent, data) @@ -405,12 +453,22 @@ function _M.saleItemRpc(agent, data)
405 end 453 end
406 local sellEffect = itemData.sell_effect:toArray(true, "=") 454 local sellEffect = itemData.sell_effect:toArray(true, "=")
407 reward[sellEffect[1]] = (reward[sellEffect[1]] or 0) + sellEffect[2] * count 455 reward[sellEffect[1]] = (reward[sellEffect[1]] or 0) + sellEffect[2] * count
  456 +
  457 + role:log("carriage_decals", {
  458 + item_id = itemId, --道具id
  459 + item_type = itemData.type, --道具类型,具体见枚举表中道具类型枚举表
  460 + item_level = 0, --道具等级
  461 + item_number = count, --道具变化数量的绝对值
  462 + carriage_decals_rwdid = sellEffect[1], --拆解获得物资ID
  463 + carriage_decals_rwdnum = sellEffect[2] * count, --拆解获得物资数量
  464 + })
408 end 465 end
409 466
410 role:costItems(backs, {log = {desc = "saleItem"}}) 467 role:costItems(backs, {log = {desc = "saleItem"}})
411 - local reward = role:award(reward, {log = {desc = "saleItem"}}) 468 + local reward, change = role:award(reward, {log = {desc = "saleItem"}})
412 role:checkTaskEnter("DecoFrag", {count = fragCount}) 469 role:checkTaskEnter("DecoFrag", {count = fragCount})
413 - SendPacket(actionCodes.Role_saleItemRpc, MsgPack.pack({reward = reward})) 470 +
  471 + SendPacket(actionCodes.Role_saleItemRpc, MsgPack.pack(role:packReward(reward, change)))
414 return true 472 return true
415 end 473 end
416 474
@@ -447,9 +505,10 @@ function _M.openItemRpc(agent, data) @@ -447,9 +505,10 @@ function _M.openItemRpc(agent, data)
447 reward[0] = nil 505 reward[0] = nil
448 506
449 role:costItems({[itemId] = count}, {log = {desc = "openItem"}}) 507 role:costItems({[itemId] = count}, {log = {desc = "openItem"}})
450 - reward = role:award(reward, {log = {desc = "openItem", int1 = itemId, int2 = count}}) 508 + local change
  509 + reward, change = role:award(reward, {log = {desc = "openItem", int1 = itemId, int2 = count}})
451 510
452 - SendPacket(actionCodes.Role_openItemRpc, MsgPack.pack({reward = reward})) 511 + SendPacket(actionCodes.Role_openItemRpc, MsgPack.pack(role:packReward(reward, change)))
453 return true 512 return true
454 end 513 end
455 514
@@ -458,10 +517,15 @@ function _M.openTimeBoxRpc(agent, data) @@ -458,10 +517,15 @@ function _M.openTimeBoxRpc(agent, data)
458 local msg = MsgPack.unpack(data) 517 local msg = MsgPack.unpack(data)
459 local oper = msg.oper -- 操作 1 - 2 518 local oper = msg.oper -- 操作 1 - 2
460 local slot = msg.slot -- 位置 1 - 6 519 local slot = msg.slot -- 位置 1 - 6
461 - if math.illegalNum(slot, 1, role:getFuncLv(FuncOpenType.TimeBoxSlot)) then return end 520 +
  521 + -- 特权卡时间箱额外栏位
  522 + local privExtraCnt = role.storeData:getTimeBoxSlotExtraCount()
  523 + if oper == 1 then
  524 + if math.illegalNum(slot, 1, role:getFuncLv(FuncOpenType.TimeBoxSlot) + privExtraCnt) then return end
  525 + end
462 526
463 local boxL = role:getProperty("boxL") 527 local boxL = role:getProperty("boxL")
464 - local reward = {} 528 + local reward, change = {}
465 if oper == 1 then -- 打开 529 if oper == 1 then -- 打开
466 local itemId = msg.itemId 530 local itemId = msg.itemId
467 if role:getItemCount(itemId) < 1 then return end 531 if role:getItemCount(itemId) < 1 then return end
@@ -476,12 +540,14 @@ function _M.openTimeBoxRpc(agent, data) @@ -476,12 +540,14 @@ function _M.openTimeBoxRpc(agent, data)
476 elseif oper == 2 then -- 领取 540 elseif oper == 2 then -- 领取
477 local quick = msg.quick 541 local quick = msg.quick
478 if not boxL[slot] then return end 542 if not boxL[slot] then return end
  543 + local costKey = 0
  544 + local costTime = skynet.timex() - boxL[slot].time
479 if boxL[slot].time > skynet.timex() then -- 没开完 545 if boxL[slot].time > skynet.timex() then -- 没开完
480 if not quick then return end 546 if not quick then return end
481 local cost_pre = globalCsv.box_timeOpen_diamond:toArray(true, "=") 547 local cost_pre = globalCsv.box_timeOpen_diamond:toArray(true, "=")
482 - local costD = math.ceil((boxL[slot].time - skynet.timex()) / (cost_pre[1] * 60)) * cost_pre[2]  
483 - if not role:checkItemEnough({[ItemId.BoxKey] = costD}) then return end  
484 - role:costItems({[ItemId.BoxKey] = costD}, {log = {desc = "openTimeBox"}}) 548 + local costKey = math.ceil((boxL[slot].time - skynet.timex()) / (cost_pre[1] * 60)) * cost_pre[2]
  549 + if not role:checkItemEnough({[ItemId.BoxKey] = costKey}) then return end
  550 + role:costItems({[ItemId.BoxKey] = costKey}, {log = {desc = "openTimeBox"}})
485 end 551 end
486 local boxId = boxL[slot].id 552 local boxId = boxL[slot].id
487 local itemData = csvdb["itemCsv"][boxId] 553 local itemData = csvdb["itemCsv"][boxId]
@@ -509,15 +575,26 @@ function _M.openTimeBoxRpc(agent, data) @@ -509,15 +575,26 @@ function _M.openTimeBoxRpc(agent, data)
509 reward[0] = nil 575 reward[0] = nil
510 576
511 boxL[slot] = nil 577 boxL[slot] = nil
512 - reward = role:award(reward, {log = {desc = "openTimeBox", int1 = boxId}})  
513 - role:checkTaskEnter("OpenBox", {id = boxId}) 578 + reward, change = role:award(reward, {log = {desc = "openTimeBox", int1 = boxId}})
  579 + role:checkTaskEnter("OpenBox", {id = boxId, count=1})
  580 +
  581 + role:log("carriage_dismantle", {
  582 + item_id = boxId, -- 道具id
  583 + item_type = itemData.type, -- 道具类型,具体见枚举表中道具类型枚举表
  584 + item_level = 0, -- 道具等级
  585 + item_number = 1, -- 道具变化数量的绝对值
  586 + carriage_dismantle_type = quick and 1 or 0, -- 拆解方式,时间到期:0,钥匙开启:1
  587 + carriage_dismantle_time = costTime, -- 拆解耗时,填写实际耗时
  588 + carriage_dismantle_cost = costKey, -- 拆解花费钥匙数量,未使用填写0
  589 + carriage_dismantle_rwd = reward, -- 拆解获得物资,json格式记录,{'itemid1':2,'itemid2':3,…………..}
  590 + })
514 else 591 else
515 return 592 return
516 end 593 end
517 594
518 role:setProperty("boxL") --刷新 595 role:setProperty("boxL") --刷新
519 role:changeUpdates({{type = "boxL", field = slot, value = boxL[slot], isOnlyToC = true}}) -- 通知客户端 596 role:changeUpdates({{type = "boxL", field = slot, value = boxL[slot], isOnlyToC = true}}) -- 通知客户端
520 - SendPacket(actionCodes.Role_openTimeBoxRpc, MsgPack.pack({reward = reward})) 597 + SendPacket(actionCodes.Role_openTimeBoxRpc, MsgPack.pack(role:packReward(reward, change)))
521 return true 598 return true
522 end 599 end
523 600
@@ -568,9 +645,10 @@ function _M.openSpeedUpBoxRpc(agent, data) @@ -568,9 +645,10 @@ function _M.openSpeedUpBoxRpc(agent, data)
568 end 645 end
569 646
570 role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) 647 role:costItems({[id] = count}, {log = {desc = "speedUpBox"}})
571 - reward = role:award(reward, {log = {desc = "speedUpBox"}, int1 = id, int2 = count}) 648 + local change
  649 + reward, change = role:award(reward, {log = {desc = "speedUpBox"}, int1 = id, int2 = count})
572 650
573 - SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack({reward = reward})) 651 + SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack(role:packReward(reward, change)))
574 return true 652 return true
575 end 653 end
576 654
@@ -596,8 +674,17 @@ function _M.storyBookRewardRpc(agent, data) @@ -596,8 +674,17 @@ function _M.storyBookRewardRpc(agent, data)
596 storyStatus[storyId] = storyStatus[storyId] or {} 674 storyStatus[storyId] = storyStatus[storyId] or {}
597 storyStatus[storyId].s = -1 675 storyStatus[storyId].s = -1
598 role:changeUpdates({{ type = "storyB", field = storyId, value = storyStatus[storyId] }}) 676 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})) 677 + local reward, change = role:award(storyBookData.gift, {log = {desc = "storybookReward", int1 = storyId}})
  678 +
  679 + role:log("carriage_decals", {
  680 + carriage_video_type = storyBookData.type, --放映室类型,剧情CG:0, 角色CG:1, 主线剧情:2, 角色剧情:3, 活动剧情:4, 图鉴:5
  681 + carriage_video_id = storyId, --放映室片段ID
  682 + carriage_video_coinid = reward[ItemId.Gold] and ItemId.Gold or 0, --放映奖励货币类型,无奖励则填写0
  683 + carriage_video_coinnum = reward[ItemId.Gold] or 0, --放映奖励货币数量,无奖励则填写0
  684 + carriage_video_item = reward, --放映奖励其他物品数量,json格式记录,{'itemid1':10,'itemid2':5,…………..},无奖励则填写0
  685 + })
  686 +
  687 + SendPacket(actionCodes.Role_storyBookRewardRpc, MsgPack.pack(role:packReward(reward, change)))
601 return true 688 return true
602 end 689 end
603 690
@@ -633,7 +720,7 @@ function _M.taskRpc(agent, data) @@ -633,7 +720,7 @@ function _M.taskRpc(agent, data)
633 720
634 if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end 721 if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end
635 722
636 - local taskType = msg.type -- 1 日常 2 周 723 + local taskType = msg.type -- 1 日常 2 周
637 local taskId = msg.id --任务id 724 local taskId = msg.id --任务id
638 local roleField = {"dTask", "wTask"} 725 local roleField = {"dTask", "wTask"}
639 if not roleField[taskType] then return 1 end 726 if not roleField[taskType] then return 1 end
@@ -648,15 +735,24 @@ function _M.taskRpc(agent, data) @@ -648,15 +735,24 @@ function _M.taskRpc(agent, data)
648 return 3 735 return 3
649 end 736 end
650 737
651 - local reward = role:award(taskData.reward, {log = {desc = "finishTask", int1 = taskType, int2 = taskId}}) 738 + local reward, change = role:award(taskData.reward, {log = {desc = "finishTask", int1 = taskType, int2 = taskId}})
652 local active = (taskStatus["a"] or 0) + taskData.active 739 local active = (taskStatus["a"] or 0) + taskData.active
653 740
654 role:changeUpdates({ 741 role:changeUpdates({
655 { type = roleField[taskType], field = {"t", taskId}, value = -1 }, 742 { type = roleField[taskType], field = {"t", taskId}, value = -1 },
656 - { type = roleField[taskType], field = "a", value = active} 743 + { type = roleField[taskType], field = "a", value = active},
657 }) 744 })
658 745
659 - SendPacket(actionCodes.Role_taskRpc, MsgPack.pack({reward = reward})) 746 + local oldVal = role:getProperty("battlePoint") or 0
  747 + role:updateProperty({field = "battlePoint", value = oldVal + taskData.active})
  748 +
  749 + role:log("task_reward", {
  750 + task_reward_id = taskId, --任务奖励ID
  751 + task_reward_type = taskType, --任务奖励类型,见 任务奖励类型枚举表
  752 + task_reward_detail = reward, --任务奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
  753 + })
  754 +
  755 + SendPacket(actionCodes.Role_taskRpc, MsgPack.pack(role:packReward(reward, change)))
660 return true 756 return true
661 end 757 end
662 758
@@ -681,12 +777,12 @@ function _M.taskActiveRpc(agent, data) @@ -681,12 +777,12 @@ function _M.taskActiveRpc(agent, data)
681 return 777 return
682 end 778 end
683 779
684 - local reward = role:award(taskData.reward, {log = {desc = "taskActive", int1 = taskType, int2 = taskId}}) 780 + local reward, change = role:award(taskData.reward, {log = {desc = "taskActive", int1 = taskType, int2 = taskId}})
685 role:changeUpdates({ 781 role:changeUpdates({
686 { type = roleField[taskType], field = {"at", taskId}, value = -1 } 782 { type = roleField[taskType], field = {"at", taskId}, value = -1 }
687 }) 783 })
688 784
689 - SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack({reward = reward})) 785 + SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack(role:packReward(reward, change)))
690 return true 786 return true
691 end 787 end
692 788
@@ -712,7 +808,7 @@ function _M.achiveRpc(agent, data) @@ -712,7 +808,7 @@ function _M.achiveRpc(agent, data)
712 return 3 808 return 3
713 end 809 end
714 810
715 - local reward = role:award(achiveTask.reward, {log = {desc = "finishAchive", int1 = taskId}}) 811 + local reward, change = role:award(achiveTask.reward, {log = {desc = "finishAchive", int1 = taskId}})
716 role:changeUpdates({ 812 role:changeUpdates({
717 { type = "achiveV", field = taskId, value = skynet.timex() } 813 { type = "achiveV", field = taskId, value = skynet.timex() }
718 }) 814 })
@@ -745,7 +841,13 @@ function _M.achiveRpc(agent, data) @@ -745,7 +841,13 @@ function _M.achiveRpc(agent, data)
745 end 841 end
746 end 842 end
747 843
748 - SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack({reward = reward})) 844 + role:log("achievement", {
  845 + achievement_id = taskId, -- 成就id
  846 + achievement_type = achiveTask.type, -- 成就类型,具体枚举表中成就类型枚举表
  847 + achievement_reward = reward, -- 达成成就奖励,json格式记录,{"itemid1":123,"itemid2":12,……….}
  848 + })
  849 +
  850 + SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack(role:packReward(reward, change)))
749 return true 851 return true
750 end 852 end
751 853
@@ -863,6 +965,13 @@ function _M.chatRpc(agent, data) @@ -863,6 +965,13 @@ function _M.chatRpc(agent, data)
863 if not result then 965 if not result then
864 check[cmd]() 966 check[cmd]()
865 end 967 end
  968 +
  969 + role:log("communication", {
  970 + publish_type = cmd, --发言类型,1,世界 2私聊
  971 + publish_status = 0, --发送状态,发送成功:0,发送失败:1,被屏蔽:2,其他:3
  972 + publish_receive_roleid = msg.roleId, --接收者角色ID
  973 + publish_text = content, --发言内容
  974 + })
866 SendPacket(actionCodes.Role_chatRpc, MsgPack.pack({result = result, waitTime = waitTime})) 975 SendPacket(actionCodes.Role_chatRpc, MsgPack.pack({result = result, waitTime = waitTime}))
867 return true 976 return true
868 end 977 end
@@ -891,8 +1000,6 @@ function _M.changeSettingRpc(agent, data) @@ -891,8 +1000,6 @@ function _M.changeSettingRpc(agent, data)
891 setting[id] = status 1000 setting[id] = status
892 role:updateProperty({field = "setting", value = setting}) 1001 role:updateProperty({field = "setting", value = setting})
893 1002
894 - role:log("role_action", {desc = "changeSetting", int1 = id, int2 = status})  
895 -  
896 SendPacket(actionCodes.Role_changeSettingRpc, '') 1003 SendPacket(actionCodes.Role_changeSettingRpc, '')
897 return true 1004 return true
898 end 1005 end
@@ -921,11 +1028,19 @@ function _M.drawCodeRpc(agent, data) @@ -921,11 +1028,19 @@ function _M.drawCodeRpc(agent, data)
921 if ret == 0 then 1028 if ret == 0 then
922 local giftId = tonumber(result.giftId) 1029 local giftId = tonumber(result.giftId)
923 role:setProperty("codeStr", codestr:setv(giftId, 1)) 1030 role:setProperty("codeStr", codestr:setv(giftId, 1))
924 - local reward = role:award(result.gift, {log = {desc = "drawCode", key1 = code, int1 = giftId}}) 1031 + local reward, change = role:award(result.gift, {log = {desc = "drawCode", int1 = giftId}})
925 1032
  1033 + role:log("get_gift", {
  1034 + gift_id = giftId, -- 礼包ID
  1035 + gift_key = code, -- 礼包key
  1036 + gift_reward = reward, -- 礼包奖励,json格式记录,{"itemid1":123,"itemid2":12,……….}
  1037 + gift_name = "", -- 礼包名称
  1038 + gift_reason = 0, -- 礼包发放原因,见发放原因枚举表
  1039 + })
926 SendPacket(actionCodes.Role_drawCodeRpc, MsgPack.pack({ 1040 SendPacket(actionCodes.Role_drawCodeRpc, MsgPack.pack({
927 result = ret, 1041 result = ret,
928 reward = reward, 1042 reward = reward,
  1043 + change = change,
929 })) 1044 }))
930 return true 1045 return true
931 end 1046 end
@@ -976,17 +1091,15 @@ function _M.guideRpc(agent, data) @@ -976,17 +1091,15 @@ function _M.guideRpc(agent, data)
976 local cmdType = msg.cmdType 1091 local cmdType = msg.cmdType
977 1092
978 local funcGuide = role:getProperty("funcGuide") 1093 local funcGuide = role:getProperty("funcGuide")
979 - local newerGuide = role:getProperty("newerGuide")  
980 if cmdType == 1 then 1094 if cmdType == 1 then
981 -- 新手引导 1095 -- 新手引导
982 local master = msg.master or -1 1096 local master = msg.master or -1
983 local slave = msg.slave or -1 1097 local slave = msg.slave or -1
984 if master < 0 or slave < 0 then return end 1098 if master < 0 or slave < 0 then return end
985 - newerGuide = string.format("%d=%d",master,slave)  
986 - role:updateProperty({field = "newerGuide", value = newerGuide})  
987 - role:log("guide", {desc = "guide_new",int1 = master*1000+slave}) 1099 +
  1100 + role:saveGuide(master, slave)
988 elseif cmdType == 2 then 1101 elseif cmdType == 2 then
989 - -- 系统引导 1102 + -- 系统引导(玩家可选择是否进行)
990 if not msg.skip then return end 1103 if not msg.skip then return end
991 local new = math.min(funcGuide:getv(0, 0), msg.skip) 1104 local new = math.min(funcGuide:getv(0, 0), msg.skip)
992 if new < 0 then 1105 if new < 0 then
@@ -997,15 +1110,23 @@ function _M.guideRpc(agent, data) @@ -997,15 +1110,23 @@ function _M.guideRpc(agent, data)
997 1110
998 if msg.funcType then 1111 if msg.funcType then
999 funcGuide = funcGuide:setv(msg.funcType, 1) 1112 funcGuide = funcGuide:setv(msg.funcType, 1)
1000 - role:log("guide", {desc = "guide_sys", int1 = msg.funcType}) 1113 + role:log("onGuidePoint", {guild_type = 2, guild_id = msg.funcType, guild_point = 0, guild_pass = 0})
1001 end 1114 end
1002 role:updateProperty({field = "funcGuide", value = funcGuide}) 1115 role:updateProperty({field = "funcGuide", value = funcGuide})
1003 elseif cmdType == 3 then 1116 elseif cmdType == 3 then
1004 - -- 弱引导 1117 + -- 系统引导(强制进行)
  1118 + if msg.funcType and csvdb["guide_unlockCsv"][msg.funcType] then
  1119 + role:saveGuide(csvdb["guide_unlockCsv"][msg.funcType].guideId,1)
  1120 + funcGuide = funcGuide:setv(msg.funcType, 1)
  1121 + role:updateProperty({field = "funcGuide", value = funcGuide})
  1122 + role:log("onGuidePoint", {guild_type = 1, guild_id = msg.funcType, guild_point = 0, guild_pass = 0})
  1123 + end
  1124 + elseif cmdType == 4 then
  1125 + -- 弹出一个tips(进入功能界面也许要自动弹说明,value要区分1、2)
1005 if msg.funcType then 1126 if msg.funcType then
1006 local value = msg.value or 1 1127 local value = msg.value or 1
1007 for _, funcIdx in pairs(msg.funcType:toArray(true,"=")) do 1128 for _, funcIdx in pairs(msg.funcType:toArray(true,"=")) do
1008 - role:log("guide", {desc = "guide_weak", int1 = funcIdx}) 1129 + role:log("onGuidePoint", {guild_type = 3, guild_id = funcIdx, guild_point = 0, guild_pass = 0})
1009 funcGuide = funcGuide:setv(funcIdx, value) 1130 funcGuide = funcGuide:setv(funcIdx, value)
1010 end 1131 end
1011 role:updateProperty({field = "funcGuide", value = funcGuide}) 1132 role:updateProperty({field = "funcGuide", value = funcGuide})
@@ -1044,10 +1165,25 @@ function _M.goldBuyRpc(agent, data) @@ -1044,10 +1165,25 @@ function _M.goldBuyRpc(agent, data)
1044 if goldC == 0 then 1165 if goldC == 0 then
1045 return 3 1166 return 3
1046 end 1167 end
  1168 + local coef = role.storeData:getGearExchangeCoef()
  1169 + goldC = goldC * coef
1047 role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1}) 1170 role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1})
1048 role:costItems({[ItemId.Diamond] = costD}, {log = {desc = "goldBuy"}}) 1171 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})) 1172 + local reward, change = role:award({[ItemId.Gold] = math.floor(goldC)}, {log = {desc = "goldBuy"}})
  1173 + SendPacket(actionCodes.Role_goldBuyRpc, MsgPack.pack(role:packReward(reward, change)))
  1174 + return true
  1175 +end
  1176 +
  1177 +function _M.getDownloadCvRewardRpc(agent, data)
  1178 + local role = agent.role
  1179 + local flag = role:getProperty("downCvR") or 0
  1180 + if flag ~= 0 then
  1181 + return 1
  1182 + end
  1183 + local r = globalCsv.role_download_cv_reward
  1184 + local reward, change = role:award(r, {log = {desc = "downloadCv"}})
  1185 + role:updateProperty({field="downCvR", value=1})
  1186 + SendPacket(actionCodes.Role_getDownloadCvRewardRpc, MsgPack.pack(role:packReward(reward, change)))
1051 return true 1187 return true
1052 end 1188 end
1053 1189
src/actions/StoreAction.lua
@@ -2,6 +2,7 @@ local _M = {} @@ -2,6 +2,7 @@ local _M = {}
2 2
3 local serverId = tonumber(skynet.getenv("servId")) 3 local serverId = tonumber(skynet.getenv("servId"))
4 local md5 = require "md5" 4 local md5 = require "md5"
  5 +local pay_url = skynet.getenv("pay_url") or ""
5 6
6 local function makeOrder(roleId, rechargeId) 7 local function makeOrder(roleId, rechargeId)
7 local orderId = redisproxy:hincrby("autoincrement_set", "order", 1) 8 local orderId = redisproxy:hincrby("autoincrement_set", "order", 1)
@@ -31,6 +32,7 @@ function _M.rechargeRpc(agent , data) @@ -31,6 +32,7 @@ function _M.rechargeRpc(agent , data)
31 local partnerOrderId = makeOrder(roleId, id) 32 local partnerOrderId = makeOrder(roleId, id)
32 SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId })) 33 SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId }))
33 34
  35 +
34 -- 测试的 直接发奖励了 36 -- 测试的 直接发奖励了
35 skynet.timeout(10, function () 37 skynet.timeout(10, function ()
36 role:handlePurchase({ 38 role:handlePurchase({
@@ -84,7 +86,7 @@ function _M.googleRechargeRpc(agent, data) @@ -84,7 +86,7 @@ function _M.googleRechargeRpc(agent, data)
84 money = dataSet.rmb * 100, 86 money = dataSet.rmb * 100,
85 game_money = dataSet.diamond, 87 game_money = dataSet.diamond,
86 product_id = dataSet.productId, 88 product_id = dataSet.productId,
87 - notify_url = "http://test-pub-all-wasteland.komoejoy.com/pay/google" 89 + notify_url = pay_url .. "/pay/google"
88 } 90 }
89 local sign = signPms(need, secret_key) 91 local sign = signPms(need, secret_key)
90 92
@@ -110,7 +112,7 @@ function _M.myCardRechargeRpc(agent, data) @@ -110,7 +112,7 @@ function _M.myCardRechargeRpc(agent, data)
110 out_trade_no = partnerOrderId, 112 out_trade_no = partnerOrderId,
111 money = dataSet.rmb * 100, 113 money = dataSet.rmb * 100,
112 game_money = dataSet.diamond, 114 game_money = dataSet.diamond,
113 - notify_url = "http://test-pub-all-wasteland.komoejoy.com/pay/mycard" 115 + notify_url = pay_url .. "/pay/mycard"
114 } 116 }
115 local sign = signPms(need, secret_key) 117 local sign = signPms(need, secret_key)
116 118
@@ -137,7 +139,7 @@ function _M.iosRechargeRpc(agent, data) @@ -137,7 +139,7 @@ function _M.iosRechargeRpc(agent, data)
137 money = dataSet.rmb * 100, 139 money = dataSet.rmb * 100,
138 game_money = dataSet.diamond, 140 game_money = dataSet.diamond,
139 product_id = dataSet.iap_product_id, 141 product_id = dataSet.iap_product_id,
140 - notify_url = "http://test-pub-all-wasteland.komoejoy.com/pay/ios" 142 + notify_url = pay_url .. "/pay/ios"
141 } 143 }
142 local sign = signPms(need, secret_key) 144 local sign = signPms(need, secret_key)
143 145
@@ -164,6 +166,22 @@ function _M.purchaseOrderResult(agent, data) @@ -164,6 +166,22 @@ function _M.purchaseOrderResult(agent, data)
164 166
165 if msg.status == "success" then 167 if msg.status == "success" then
166 orderObject:setProperty("transactionId", msg.platformOrder or "") 168 orderObject:setProperty("transactionId", msg.platformOrder or "")
  169 + local rechargeId = orderObject:getProperty("rechargeId")
  170 + local dataSet = csvdb["shop_rechargeCsv"][rechargeId]
  171 +
  172 + role:log("setOrder", {
  173 + order_status = 100, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他"
  174 + item_id = rechargeId, -- 道具id
  175 + item_type = dataSet.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表
  176 + item_name = dataSet.title, -- 购买的道具名
  177 + item_number = 1, -- 购买的道具数量
  178 + item_level = 1, -- 购买的道具等级
  179 + order_cost = dataSet.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee'
  180 + order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范
  181 + order_type = self.getProperty("rmbC") > 0 and 0 or 1, -- 订单类型,首充记录为1,否则为0
  182 + order_id = msg.platformOrder, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no'
  183 + })
  184 +
167 return true 185 return true
168 end 186 end
169 187
@@ -178,79 +196,184 @@ function _M.purchaseOrderResult(agent, data) @@ -178,79 +196,184 @@ function _M.purchaseOrderResult(agent, data)
178 end 196 end
179 197
180 198
181 -function _M.dailyBuyRpc(agent , data) 199 +function _M.shopBuyRpc(agent , data)
182 local role = agent.role 200 local role = agent.role
183 local msg = MsgPack.unpack(data) 201 local msg = MsgPack.unpack(data)
184 local id = msg.id 202 local id = msg.id
185 local count = msg.count or 1 203 local count = msg.count or 1
186 204
187 - local dataSet = csvdb["shop_diamondCsv"][id]  
188 - if not dataSet then return 1 end  
189 -  
190 - local dailySDC = role.dailyData:getProperty("dailySDC")  
191 -  
192 - if math.illegalNum(count, 1, (dataSet.limit == 0 and math.huge or dataSet.limit - (dailySDC[id] or 0))) then return 1 end 205 + local dataSet = csvdb["shop_normalCsv"][id]
  206 + if not dataSet then return end
193 207
194 - local cost = dataSet.cost 208 + if dataSet.unlock ~= "" then
  209 + if not role:checkHangPass(tonumber(config.unlock)) then
  210 + skynet.error(string.format("shopBuyRpc,user do not finish hang pass, user_id:%d", role:getProperty("id")))
  211 + return 1
  212 + end
  213 + end
195 214
196 - local dailySDD = role.dailyData:getProperty("dailySDD")  
197 - if dailySDD[id] then -- 折扣  
198 - cost = math.ceil(cost * (1 - dataSet.disount / 100)) 215 + local buyRecord = role.storeData:getProperty("buyR")
  216 + if math.illegalNum(count, 1, (dataSet.limit == 0 and math.huge or dataSet.limit - (buyRecord[id] or 0))) then
  217 + skynet.error(string.format("shop buy over limit, user_id:%d, goods_id:%d", role:getProperty("id"), id))
  218 + return 1
199 end 219 end
200 220
201 - if not role:costDiamond({count = cost * count, log = {desc = "dailyShop", int1 = id, int2 = count}}) then  
202 - return 4 221 + local cost = {[dataSet.icon] = dataSet.cost * count}
  222 +
  223 + local desc = "unknown"
  224 + if dataSet.shop == 1 then -- 普通商店
  225 + desc = "dailyShop"
  226 + local dailySDD = role.dailyData:getProperty("dailySDD")
  227 + if dailySDD[id] then -- 折扣
  228 + cost = math.ceil(dataSet.cost * (1 - dataSet.disount / 100))
  229 + end
  230 + elseif dataSet.shop == 2 then -- 美食商店
  231 + desc = "dinerShop"
  232 + elseif dataSet.shop == 3 then -- 竞技场商店
  233 + desc = "pvpShop"
203 end 234 end
204 235
  236 + if not role:checkItemEnough(cost) then return end
  237 +
205 if dataSet.limit ~= 0 then 238 if dataSet.limit ~= 0 then
206 - dailySDC[id] = (dailySDC[id] or 0) + count  
207 - role.dailyData:updateProperty({field = "dailySDC", value = dailySDC}) 239 + buyRecord[id] = (buyRecord[id] or 0) + count
  240 + role.storeData:updateProperty({field = "buyR", value = buyRecord})
208 end 241 end
  242 + role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count}})
  243 +
209 local gift = {} 244 local gift = {}
210 - for itemId, count_ in pairs(dataSet.gift:toNumMap()) do  
211 - gift[itemId] = count_ * count 245 + for _id, _count in pairs(dataSet.gift:toNumMap()) do
  246 + gift[_id] = _count * count
  247 + end
  248 + local reward = role:award(gift, {log = {desc = desc, int1 = id, int2 = count}})
  249 +
  250 + if dataSet.shop == 1 then
  251 + role:checkTaskEnter("ShopAll", {count = count})
212 end 252 end
213 - local reward = role:award(gift, {log = {desc = "dailyShop", int1 = id, int2 = count}})  
214 - role:checkTaskEnter("ShopAll", {count = count}) 253 + local costId, costCount = next(cost)
  254 +
  255 + role:log("shop_purchase", {
  256 + item_id = id, -- 道具id
  257 + item_type = 0, -- 道具类型,具体见枚举表中道具类型枚举表
  258 + item_level = 0, -- 道具等级
  259 + item_cnt = count, -- 购买数量技术
  260 + currency_type = costId or 0, -- 购买道具消耗的货币类型,记录货币ID
  261 + shop_purchase_current = costCount or 0, -- 购买道具消耗的货币数量
  262 + shop_id = dataSet.shop, -- 商店ID
  263 + })
  264 + SendPacket(actionCodes.Store_shopBuyRpc, MsgPack.pack({reward = reward}))
  265 + return true
  266 +end
  267 +
  268 +function _M.getFreeChestRpc(agent, data)
  269 + local role = agent.role
  270 + local msg = MsgPack.unpack(data)
  271 + local id = msg.id
215 272
216 - role:log("role_action", {desc = "dailyShop", int1 = id, int2 = count}) 273 + local config = csvdb["shop_rechargeCsv"][id]
  274 + if not config then return end
217 275
218 - SendPacket(actionCodes.Store_dailyBuyRpc, MsgPack.pack({reward = reward})) 276 + local rechargeRecord = role.storeData:getProperty("payR")
  277 + local getCount = (rechargeRecord[id] or 0)
  278 + if getCount >= config.limit then
  279 + return 1
  280 + end
  281 + local reward, _ = role:award(config.itemFirst, {log = {desc = "freeGift", int1 = id}})
  282 +
  283 + rechargeRecord[id] = getCount + 1
  284 + role.storeData:updateProperty({field = "payR", value = rechargeRecord})
  285 +
  286 + SendPacket(actionCodes.Store_getFreeChestRpc, MsgPack.pack({reward = reward}))
219 return true 287 return true
220 end 288 end
221 289
  290 +function _M.getGrowFundRewardRpc(agent, data)
  291 + local role = agent.role
  292 + local msg = MsgPack.unpack(data)
  293 + local id = msg.id
  294 +
  295 + local config = csvdb["reward_newbeeCsv"][id]
  296 + if not config then return end
  297 +
  298 + local growFundFlag = role.storeData:getProperty("growFund")
  299 + local growFundRecord = role.storeData:getProperty("growFundR")
  300 +
  301 + if growFundFlag == 0 then
  302 + skynet.error("user do not buy grow fund")
  303 + return 1
  304 + end
  305 +
  306 + if not role:checkHangPass(config.condition) then
  307 + skynet.error(string.format("user do not finish hang pass, user_id:%d", role:getProperty("id")))
  308 + return 1
  309 + end
  310 +
  311 + local b = string.getbit(growFundRecord, id)
  312 + if string.char(b) == "1" then
  313 + return 1
  314 + end
  315 +
  316 + growFundRecord = string.setbit(growFundRecord, id)
  317 + role.storeData:updateProperty({field = "growFundR", value = growFundRecord})
222 318
223 -function _M.dinerBuyRpc(agent , data) 319 + local gift = config.giftFree .. " " .. config.giftLimit
  320 + local reward, _ = role:award(gift, {log = {desc = "grownFund", int1 = id}})
  321 +
  322 + SendPacket(actionCodes.Store_getGrowFundRewardRpc, MsgPack.pack({reward = reward}))
  323 + return true
  324 +end
  325 +
  326 +function _M.getBattlePassRewardRpc(agent, data)
224 local role = agent.role 327 local role = agent.role
225 local msg = MsgPack.unpack(data) 328 local msg = MsgPack.unpack(data)
226 local id = msg.id 329 local id = msg.id
227 - local count = msg.count or 1  
228 330
229 - local dataSet = csvdb["shop_dinerCsv"][id]  
230 - if not dataSet then return end 331 + local config = csvdb["reward_battlepassCsv"][id]
  332 + if not config then return end
231 333
232 - local dinerS = role:getProperty("dinerS")  
233 - if math.illegalNum(count, 1, (dataSet.limit == 0 and math.huge or dataSet.limit - (dinerS[id] or 0))) then return 1 end 334 + local timeNow = skynet.timex()
  335 + local battleCardFlag = role.storeData:getProperty("battleCard")
  336 + local battleCardFreeRecord = role.storeData:getProperty("battleFR")
  337 + local battleCardLimitRecord = role.storeData:getProperty("battleLR")
234 338
235 - local cost = {[ItemId.DinerCoin] = dataSet.cost * count}  
236 - if not role:checkItemEnough(cost) then return end 339 + local freeFlag = string.char(string.getbit(battleCardFreeRecord, id))
  340 + local limitFlag = string.char(string.getbit(battleCardLimitRecord, id))
237 341
238 - if dataSet.limit ~= 0 then  
239 - dinerS[id] = (dinerS[id] or 0) + count  
240 - role:updateProperty({field = "dinerS", value = dinerS}) 342 + if freeFlag == "1" and limitFlag == "1" then
  343 + skynet.error("user already get battle pass reward")
  344 + return 1
241 end 345 end
242 346
243 - role:costItems(cost, {log = {desc = "dinerShop", int1 = id, int2 = count}}) 347 + if battleCardFlag == 1 and limitFlag == "1" then
  348 + return 1
  349 + end
244 350
245 - local gift = {}  
246 - for _id, _count in pairs(dataSet.gift:toNumMap()) do  
247 - gift[_id] = _count * count 351 + if role:getProperty("battlePoint") < config.point then
  352 + skynet.error(string.format("user do not have enough battle point, user_id:%d", role:getProperty("id")))
  353 + return 1
  354 + end
  355 +
  356 + local gift = ""
  357 + if freeFlag == "0" then
  358 + gift = config.giftFree
  359 +
  360 + battleCardFreeRecord = string.setbit(battleCardFreeRecord, id)
  361 + role.storeData:updateProperty({field = "battleFR", value = battleCardFreeRecord})
  362 + end
  363 +
  364 + if battleCardFlag == 1 and limitFlag == "0" then
  365 + if gift ~= "" then
  366 + gift = gift .. " "
  367 + end
  368 + gift = gift .. config.giftLimit
  369 +
  370 + battleCardLimitRecord = string.setbit(battleCardLimitRecord, id)
  371 + role.storeData:updateProperty({field = "battleLR", value = battleCardLimitRecord})
248 end 372 end
249 - local reward = role:award(gift, {log = {desc = "dinerShop", int1 = id, int2 = count}})  
250 373
251 - role:log("role_action", {desc = "dinerShop", int1 = id, int2 = count}) 374 + local reward, _ = role:award(gift, {log = {desc = "battleCard", int1 = id}})
252 375
253 - SendPacket(actionCodes.Store_dinerBuyRpc, MsgPack.pack({reward = reward})) 376 + SendPacket(actionCodes.Store_getBattlePassRewardRpc, MsgPack.pack({reward = reward}))
254 return true 377 return true
255 end 378 end
256 379
src/actions/TowerAction.lua
@@ -76,8 +76,6 @@ function _M.startBattleRpc(agent, data) @@ -76,8 +76,6 @@ function _M.startBattleRpc(agent, data)
76 role:updateProperty({field = "towerInfo", value = towerInfo}) 76 role:updateProperty({field = "towerInfo", value = towerInfo})
77 role:checkTaskEnter("TowerBattle", {level = towerInfo.l}) 77 role:checkTaskEnter("TowerBattle", {level = towerInfo.l})
78 78
79 - role:log("tower_action", {desc = "startBattle", int1 = id})  
80 -  
81 SendPacket(actionCodes.Tower_startBattleRpc, '') 79 SendPacket(actionCodes.Tower_startBattleRpc, '')
82 return true 80 return true
83 end 81 end
@@ -90,21 +88,24 @@ function _M.endBattleRpc(agent, data) @@ -90,21 +88,24 @@ function _M.endBattleRpc(agent, data)
90 local passTime = msg.passTime 88 local passTime = msg.passTime
91 89
92 local towerInfo = role:getProperty("towerInfo") 90 local towerInfo = role:getProperty("towerInfo")
93 - if towerInfo.l ~= id or not towerInfo.k or towerInfo.k ~= key then return 1 end 91 + if towerInfo.l ~= id or not towerInfo.k or towerInfo.k ~= key then
  92 + SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({errorCode = 1}))
  93 + return true
  94 + end
94 local curTower = csvdb["tower_battleCsv"][id] 95 local curTower = csvdb["tower_battleCsv"][id]
95 if not curTower then return 2 end 96 if not curTower then return 2 end
96 97
97 local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) 98 local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t)
98 99
99 100
100 - local reward 101 + local reward, change
101 if msg.starNum and msg.starNum > 0 then --win 102 if msg.starNum and msg.starNum > 0 then --win
102 curCount = math.min(curCount + 1, globalCsv.tower_count_limit) -- 返还次数 103 curCount = math.min(curCount + 1, globalCsv.tower_count_limit) -- 返还次数
103 --排行榜 104 --排行榜
104 role:setTowerRank(towerInfo.l) 105 role:setTowerRank(towerInfo.l)
105 106
106 towerInfo.l = towerInfo.l + 1 107 towerInfo.l = towerInfo.l + 1
107 - reward = role:award(curTower.reward, {log = {desc = "towerBattle", int1 = id}}) 108 + reward, change = role:award(curTower.reward, {log = {desc = "towerBattle", int1 = id}})
108 role:checkTaskEnter("TowerPass", {level = towerInfo.l - 1}) 109 role:checkTaskEnter("TowerPass", {level = towerInfo.l - 1})
109 end 110 end
110 111
@@ -113,9 +114,22 @@ function _M.endBattleRpc(agent, data) @@ -113,9 +114,22 @@ function _M.endBattleRpc(agent, data)
113 towerInfo.k = nil 114 towerInfo.k = nil
114 role:updateProperty({field = "towerInfo", value = towerInfo}) 115 role:updateProperty({field = "towerInfo", value = towerInfo})
115 116
116 - role:log("tower_action", {desc = "endBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id})  
117 117
118 - SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({reward = reward})) 118 + local rank = redisproxy:ZREVRANK(RANK_TOWER, role:getProperty("id"))
  119 + if not rank then
  120 + rank = -1
  121 + else
  122 + rank = rank + 1
  123 + end
  124 + role:checkBattle("tower", {
  125 + id = id,
  126 + isWin = msg.starNum and msg.starNum > 0,
  127 + info = msg.info,
  128 + reward = reward,
  129 + rank = rank,
  130 + })
  131 +
  132 + SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({reward = reward, change = change}))
119 return true 133 return true
120 end 134 end
121 135
@@ -137,7 +151,6 @@ function _M.bugCountRpc(agent, data) @@ -137,7 +151,6 @@ function _M.bugCountRpc(agent, data)
137 towerInfo.c = curCount 151 towerInfo.c = curCount
138 towerInfo.t = nextTime 152 towerInfo.t = nextTime
139 role:updateProperty({field = "towerInfo", value = towerInfo}) 153 role:updateProperty({field = "towerInfo", value = towerInfo})
140 - role:log("tower_action", {desc = "bugCount"})  
141 154
142 SendPacket(actionCodes.Tower_bugCountRpc, '') 155 SendPacket(actionCodes.Tower_bugCountRpc, '')
143 return true 156 return true
@@ -24,17 +24,6 @@ function Adv:ctor(owner) @@ -24,17 +24,6 @@ function Adv:ctor(owner)
24 self:initByInfo(self.owner:getProperty("advInfo")) 24 self:initByInfo(self.owner:getProperty("advInfo"))
25 end 25 end
26 26
27 -function Adv:log(contents)  
28 - contents = contents or {}  
29 - if contents["cint1"] or contents["cint2"] or contents["cint3"] then  
30 - print("advLog error log have cint1 or cint2 or cint3 ", debug.traceback())  
31 - end  
32 - contents["cint1"] = self.chapterId  
33 - contents["cint2"] = self.level  
34 -  
35 - self.owner:log("adv_action", contents)  
36 -end  
37 -  
38 --初始化adv 信息 27 --初始化adv 信息
39 function Adv:initByInfo(advInfo) 28 function Adv:initByInfo(advInfo)
40 if not next(advInfo) then return end --还没有 开始新地图 29 if not next(advInfo) then return end --还没有 开始新地图
@@ -509,18 +498,18 @@ function Adv:awardArtifact(id, params) @@ -509,18 +498,18 @@ function Adv:awardArtifact(id, params)
509 self:checkAchievement(Adv.AchievType.GetMWeapon, 1, id) 498 self:checkAchievement(Adv.AchievType.GetMWeapon, 1, id)
510 499
511 500
512 - if params.log then  
513 - local log = clone(params.log)  
514 - if log["cint1"] or log["cint2"] or log["cint3"] then  
515 - print("awardArtifact error log have cint1 or cint2 or cint3 ", debug.traceback())  
516 - end  
517 - log["cint1"] = self.chapterId  
518 - log["cint2"] = self.level  
519 - log["cint3"] = id  
520 - self.owner:log("in_artifact", log)  
521 - else  
522 - print("awardArtifact no log ", debug.traceback())  
523 - end 501 + -- if params.log then
  502 + -- local log = clone(params.log)
  503 + -- if log["cint1"] or log["cint2"] or log["cint3"] then
  504 + -- print("awardArtifact error log have cint1 or cint2 or cint3 ", debug.traceback())
  505 + -- end
  506 + -- log["cint1"] = self.chapterId
  507 + -- log["cint2"] = self.level
  508 + -- log["cint3"] = id
  509 + -- self.owner:log("in_artifact", log)
  510 + -- else
  511 + -- print("awardArtifact no log ", debug.traceback())
  512 + -- end
524 if not params.isChoose then 513 if not params.isChoose then
525 self:pushBackEvent(AdvBackEventType.Artifact, {id = id}) 514 self:pushBackEvent(AdvBackEventType.Artifact, {id = id})
526 end 515 end
@@ -609,7 +598,6 @@ function Adv:wearArtifact(slot, id) @@ -609,7 +598,6 @@ function Adv:wearArtifact(slot, id)
609 else 598 else
610 id = nil 599 id = nil
611 end 600 end
612 - self:log({desc = "wearArtifact", int1 = id})  
613 601
614 self.owner:changeUpdates({{type = "advAFWear", field = slot, value = id}}) 602 self.owner:changeUpdates({{type = "advAFWear", field = slot, value = id}})
615 return true 603 return true
@@ -668,9 +656,6 @@ function Adv:artifactLevelUp(id, level) @@ -668,9 +656,6 @@ function Adv:artifactLevelUp(id, level)
668 end 656 end
669 if newLv == advAFGet[id] then return end 657 if newLv == advAFGet[id] then return end
670 658
671 - self:log({desc = "artifactLevelUp", int1 = id, int2 = level})  
672 -  
673 -  
674 local status = 0 659 local status = 0
675 if curWear[id] then -- 穿着呢 660 if curWear[id] then -- 穿着呢
676 local oldData = csvdb["adv_artifactCsv"][id][advAFGet[id]] 661 local oldData = csvdb["adv_artifactCsv"][id][advAFGet[id]]
@@ -715,8 +700,6 @@ function Adv:chooseArtifact(index) @@ -715,8 +700,6 @@ function Adv:chooseArtifact(index)
715 if not self.waitArtifact or not self.waitArtifact[index] then return end 700 if not self.waitArtifact or not self.waitArtifact[index] then return end
716 self:award({[self.waitArtifact[index]] = 1}, {log = {desc = "chooseArtifact"}, isChoose = true}) 701 self:award({[self.waitArtifact[index]] = 1}, {log = {desc = "chooseArtifact"}, isChoose = true})
717 702
718 - self:log({desc = "chooseArtifact", int1 = self.waitArtifact[index]})  
719 -  
720 self.waitArtifact = nil 703 self.waitArtifact = nil
721 704
722 -- 支援效果继续选择 705 -- 支援效果继续选择
@@ -778,7 +761,7 @@ function Adv:over(success, rewardRatio, overType) @@ -778,7 +761,7 @@ function Adv:over(success, rewardRatio, overType)
778 761
779 local backAdvCount 762 local backAdvCount
780 if not self:isEndless() then 763 if not self:isEndless() then
781 - backAdvCount = chapterData.limitlevel - self.level 764 + backAdvCount = math.floor((chapterData.limitlevel - self.level) / globalCsv.adv_daily_count_back_radio) * globalCsv.adv_daily_count_back_radio
782 self.owner:changeAdvCount(-backAdvCount) 765 self.owner:changeAdvCount(-backAdvCount)
783 end 766 end
784 767
@@ -809,8 +792,6 @@ function Adv:over(success, rewardRatio, overType) @@ -809,8 +792,6 @@ function Adv:over(success, rewardRatio, overType)
809 end 792 end
810 self:clearAdvUnlockCache() 793 self:clearAdvUnlockCache()
811 794
812 - self:log({desc = "over", short1 = success and 1 or 0, int1 = overType})  
813 -  
814 local chapterId = self.chapterId 795 local chapterId = self.chapterId
815 self:clear() 796 self:clear()
816 self.owner:checkTaskEnter("AdvScore", {score = score}) 797 self.owner:checkTaskEnter("AdvScore", {score = score})
@@ -903,6 +884,9 @@ function Adv:award(gift, params) @@ -903,6 +884,9 @@ function Adv:award(gift, params)
903 884
904 if csvdb["adv_artifactCsv"][itemId] then -- 获得神器 885 if csvdb["adv_artifactCsv"][itemId] then -- 获得神器
905 self:awardArtifact(itemId, params) 886 self:awardArtifact(itemId, params)
  887 + if not self.owner:checkOverGuide(55) then
  888 + self.owner:saveGuide(55,1,true)
  889 + end
906 else 890 else
907 if nums <= 0 then 891 if nums <= 0 then
908 items = items:delk(itemId) 892 items = items:delk(itemId)
@@ -911,23 +895,23 @@ function Adv:award(gift, params) @@ -911,23 +895,23 @@ function Adv:award(gift, params)
911 items = items:setv(itemId, nums) 895 items = items:setv(itemId, nums)
912 end 896 end
913 897
914 - if params.log then  
915 - local log = clone(params.log)  
916 - if log["cint1"] or log["cint2"] or log["cint3"] or log["long1"] then  
917 - print("addAdvItem error log have cint1 or cint2 or cint3 ", debug.traceback())  
918 - end  
919 - log["cint1"] = itemId  
920 - log["cint2"] = math.abs(count)  
921 - log["cint3"] = self.chapterId  
922 - log["long1"] = self.level  
923 - if count >= 0 then  
924 - self.owner:log("in_adv", log)  
925 - else  
926 - self.owner:log("out_adv", log)  
927 - end  
928 - else  
929 - print("addAdvItem no log ", debug.traceback())  
930 - end 898 + -- if params.log then
  899 + -- local log = clone(params.log)
  900 + -- if log["cint1"] or log["cint2"] or log["cint3"] or log["long1"] then
  901 + -- print("addAdvItem error log have cint1 or cint2 or cint3 ", debug.traceback())
  902 + -- end
  903 + -- log["cint1"] = itemId
  904 + -- log["cint2"] = math.abs(count)
  905 + -- log["cint3"] = self.chapterId
  906 + -- log["long1"] = self.level
  907 + -- if count >= 0 then
  908 + -- self.owner:log("in_adv", log)
  909 + -- else
  910 + -- self.owner:log("out_adv", log)
  911 + -- end
  912 + -- else
  913 + -- print("addAdvItem no log ", debug.traceback())
  914 + -- end
931 end 915 end
932 end 916 end
933 if items ~= oldItems then 917 if items ~= oldItems then
@@ -1021,7 +1005,6 @@ local function clickOut(self, room, block, params, isExit) @@ -1021,7 +1005,6 @@ local function clickOut(self, room, block, params, isExit)
1021 isRelay = true, 1005 isRelay = true,
1022 }) 1006 })
1023 else 1007 else
1024 - self:log({desc = "pass"})  
1025 self:initByChapter({ 1008 self:initByChapter({
1026 chapterId = self.chapterId, 1009 chapterId = self.chapterId,
1027 level = self.level + 1, 1010 level = self.level + 1,
@@ -1357,6 +1340,10 @@ local function clickDrop(self, room, block, params) @@ -1357,6 +1340,10 @@ local function clickDrop(self, room, block, params)
1357 1340
1358 local reward = self:award({[block.event.item[1]] = block.event.item[2]}, {log = {desc = "clickDrop"}}) 1341 local reward = self:award({[block.event.item[1]] = block.event.item[2]}, {log = {desc = "clickDrop"}})
1359 -- local reward = self:award({[5801] = 1}) 1342 -- local reward = self:award({[5801] = 1})
  1343 + -- 获取绷带的引导
  1344 + if block.event.item[1] == 5020 and not self.owner:checkOverGuide(53,2) then
  1345 + self.owner:saveGuide(53,2)
  1346 + end
1360 block:clear() 1347 block:clear()
1361 self:backReward(reward, {roomId = room.roomId, blockId = block.blockId}) 1348 self:backReward(reward, {roomId = room.roomId, blockId = block.blockId})
1362 return true 1349 return true
@@ -1897,16 +1884,16 @@ function Adv:enemyDead(enemy, escape) @@ -1897,16 +1884,16 @@ function Adv:enemyDead(enemy, escape)
1897 self:checkAchievement(Adv.AchievType.Kill, 1, enemyId) 1884 self:checkAchievement(Adv.AchievType.Kill, 1, enemyId)
1898 self:checkAchievement(Adv.AchievType.KillHadBuff, 1, enemy) 1885 self:checkAchievement(Adv.AchievType.KillHadBuff, 1, enemy)
1899 1886
1900 - self:checkAchievement(Adv.TaskType.KillWithBuff, 1)  
1901 - self:checkAchievement(Adv.TaskType.KillNoBuff, 1) 1887 + self:checkAchievement(Adv.AchievType.KillWithBuff, 1)
  1888 + self:checkAchievement(Adv.AchievType.KillNoBuff, 1)
1902 self:checkAchievement(Adv.AchievType.KillWithMWeapon, 1) 1889 self:checkAchievement(Adv.AchievType.KillWithMWeapon, 1)
1903 self:checkAchievement(Adv.AchievType.KillWithAMWeapon, 1) 1890 self:checkAchievement(Adv.AchievType.KillWithAMWeapon, 1)
1904 1891
1905 if monsterData.type == 2 then 1892 if monsterData.type == 2 then
1906 self:checkTask(Adv.TaskType.KillBoss, 1, enemyId) 1893 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) 1894 + self:checkAchievement(Adv.AchievType.KillBoss, 1, enemyId)
  1895 + self:checkAchievement(Adv.AchievType.KillBossWithBuff, 1)
  1896 + self:checkAchievement(Adv.AchievType.KillBossNoBuff, 1)
1910 self:checkAchievement(Adv.AchievType.KillBossWithMWeapon, 1) 1897 self:checkAchievement(Adv.AchievType.KillBossWithMWeapon, 1)
1911 self:checkAchievement(Adv.AchievType.KillBossWithAMWeapon, 1) 1898 self:checkAchievement(Adv.AchievType.KillBossWithAMWeapon, 1)
1912 elseif monsterData.type == 3 then 1899 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/AdvPassive.lua
@@ -300,8 +300,8 @@ function Passive:canEffect(effType, effValue) @@ -300,8 +300,8 @@ function Passive:canEffect(effType, effValue)
300 return 300 return
301 end 301 end
302 --禁用被动技 302 --禁用被动技
303 - local count, bc = self.owner:getDisablePassiveCount()  
304 - if bc > 0 and (count == 0 or self.owner:getPassiveIdx(self) <= count) then 303 + local count = self.owner:getDisablePassiveCount()
  304 + if count and (count == 0 or self.owner:getPassiveIdx(self) <= count) then
305 return 305 return
306 end 306 end
307 return true 307 return true
@@ -466,7 +466,8 @@ function Passive:effect8(dropId) @@ -466,7 +466,8 @@ function Passive:effect8(dropId)
466 skynet.error(string.format("CSVDATA Error adv_map_passive %s effect 8 not id %s in event_drop", self.id, dropId)) 466 skynet.error(string.format("CSVDATA Error adv_map_passive %s effect 8 not id %s in event_drop", self.id, dropId))
467 end 467 end
468 local item = dropData["range"]:randWeight(true) 468 local item = dropData["range"]:randWeight(true)
469 - self.owner.battle.adv:award({[item[1]] = item[2]}, {log = {desc = "passive", int1 = self.id}}) 469 + self.owner.battle.adv:backReward(self.owner.battle.adv:award({[item[1]] = item[2]}, {log = {desc = "passive", int1 = self.id}}), {roomId = self.owner.roomId, blockId = self.owner.blockId})
  470 +
470 end 471 end
471 472
472 --9=直接获得item(可在结算触发时使用) 473 --9=直接获得item(可在结算触发时使用)
@@ -480,7 +481,7 @@ function Passive:effect9(itemId, triggerPms, ratio, max) @@ -480,7 +481,7 @@ function Passive:effect9(itemId, triggerPms, ratio, max)
480 return 481 return
481 end 482 end
482 if not cond then return end 483 if not cond then return end
483 - self.owner.battle.adv:award({[itemId] = math.floor(math.max(0, math.min(max, cond / ratio)))}, {log = {desc = "passive", int1 = self.id}}) 484 + self.owner.battle.adv:backReward(self.owner.battle.adv:award({[itemId] = math.floor(math.max(0, math.min(max, cond / ratio)))}, {log = {desc = "passive", int1 = self.id}}), {roomId = self.owner.roomId, blockId = self.owner.blockId})
484 end 485 end
485 486
486 --10=战斗额外掉落次数 487 --10=战斗额外掉落次数
@@ -520,5 +521,17 @@ function Passive:effect13(eventType, triggerPms, eventId, count) @@ -520,5 +521,17 @@ function Passive:effect13(eventType, triggerPms, eventId, count)
520 end 521 end
521 end 522 end
522 523
  524 +--14=给所有场上怪物增加buff 《 限定 怪 id》 除了自己
  525 +function Passive:effect14(value, triggerPms, enemyId)
  526 + local aims = self.owner.battle.player:getTeam(2)
  527 + for k , aim in pairs(aims) do
  528 + if aim ~= self.owner then
  529 + if not enemyId or enemyId == 0 or aim.monsterId == enemyId then
  530 + aim:addBuff(value, self.owner)
  531 + end
  532 + end
  533 + end
  534 +end
  535 +
523 536
524 return Passive 537 return Passive
525 \ No newline at end of file 538 \ No newline at end of file
src/adv/AdvPlayer.lua
@@ -122,14 +122,16 @@ function BaseObject:getPassiveIdx(passive) @@ -122,14 +122,16 @@ function BaseObject:getPassiveIdx(passive)
122 end 122 end
123 123
124 function BaseObject:getDisablePassiveCount() 124 function BaseObject:getDisablePassiveCount()
125 - local count, bc = 0, 0 125 + local count
126 for _, buff in ipairs(self.buffs) do 126 for _, buff in ipairs(self.buffs) do
127 if not buff.isDel and buff:getType() == Buff.DISABLE_BUFF then 127 if not buff.isDel and buff:getType() == Buff.DISABLE_BUFF then
128 - count = count + buff:effect()  
129 - bc = bc + 1 128 + if buff:effect() == 0 then
  129 + return 0
  130 + end
  131 + count = (count or 0) + buff:effect()
130 end 132 end
131 end 133 end
132 - return count, bc 134 + return count
133 end 135 end
134 136
135 function BaseObject:addBuff(buffId, releaser) 137 function BaseObject:addBuff(buffId, releaser)
@@ -208,6 +210,9 @@ function BaseObject:hadBuffById(bId) @@ -208,6 +210,9 @@ function BaseObject:hadBuffById(bId)
208 end 210 end
209 end 211 end
210 212
  213 +function BaseObject:reSetSpMax()
  214 +end
  215 +
211 216
212 -- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类 217 -- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类
213 function BaseObject:getCommonBuffEffect(bType, otherCond) 218 function BaseObject:getCommonBuffEffect(bType, otherCond)
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)
@@ -365,7 +365,6 @@ function AdvTask.bind(Adv) @@ -365,7 +365,6 @@ function AdvTask.bind(Adv)
365 else 365 else
366 if (status or -1) >= data.value1 then 366 if (status or -1) >= data.value1 then
367 status = -1 367 status = -1
368 - self.owner:log("adv_action", {desc = "finishAchiev", short1 = 1, int1 = self.chapterId, int2 = taskId})  
369 end 368 end
370 if status and status ~= oldStatus then 369 if status and status ~= oldStatus then
371 insertChange(self, self.chapterId, taskId, status) 370 insertChange(self, self.chapterId, taskId, status)
@@ -388,7 +387,7 @@ function AdvTask.bind(Adv) @@ -388,7 +387,7 @@ function AdvTask.bind(Adv)
388 local achievData = (csvdb["adv_achievementCsv"][chapterId] or {})[taskId] 387 local achievData = (csvdb["adv_achievementCsv"][chapterId] or {})[taskId]
389 local status = (self.owner:getProperty(achievField)[chapterId] or {})[taskId] or -1 388 local status = (self.owner:getProperty(achievField)[chapterId] or {})[taskId] or -1
390 389
391 - local reward = {} 390 + local reward, change = {}
392 if status >= achievData.value1 then 391 if status >= achievData.value1 then
393 insertChange(self, chapterId, taskId, -1) 392 insertChange(self, chapterId, taskId, -1)
394 local count = (self.owner:getProperty(achievField)[chapterId] or {})[-1] or 0 393 local count = (self.owner:getProperty(achievField)[chapterId] or {})[-1] or 0
@@ -396,8 +395,8 @@ function AdvTask.bind(Adv) @@ -396,8 +395,8 @@ function AdvTask.bind(Adv)
396 insertChange(self, chapterId, -1, count) 395 insertChange(self, chapterId, -1, count)
397 396
398 -- 发放奖励 397 -- 发放奖励
399 - reward = self.owner:award(achievData.reward, {log = {desc = "advAchiev", int1 = chapterId, int2 = taskId}})  
400 - return true, reward 398 + reward, change = self.owner:award(achievData.reward, {log = {desc = "advAchiev", int1 = chapterId, int2 = taskId}})
  399 + return true, reward, change
401 end 400 end
402 end 401 end
403 402
@@ -408,9 +407,9 @@ function AdvTask.bind(Adv) @@ -408,9 +407,9 @@ function AdvTask.bind(Adv)
408 local status = ((self.owner:getProperty(achievField)[chapterId] or {})["pts"] or {})[taskId] or 0 407 local status = ((self.owner:getProperty(achievField)[chapterId] or {})["pts"] or {})[taskId] or 0
409 if status == -1 or count < achievData.pt then return end 408 if status == -1 or count < achievData.pt then return end
410 409
411 - local reward = self.owner:award(achievData.reward, {log = {desc = "advAchievReward", int1 = chapterId, int2 = taskId}}) 410 + local reward, change = self.owner:award(achievData.reward, {log = {desc = "advAchievReward", int1 = chapterId, int2 = taskId}})
412 insertChange(self, chapterId, taskId, -1, true) 411 insertChange(self, chapterId, taskId, -1, true)
413 - return true, reward 412 + return true, reward, change
414 end 413 end
415 414
416 function Adv:updateAchievement(notNotify) 415 function Adv:updateAchievement(notNotify)
@@ -282,7 +282,7 @@ function CMD.close() @@ -282,7 +282,7 @@ function CMD.close()
282 mcast_util.usub_union() 282 mcast_util.usub_union()
283 local role = agentInfo.role 283 local role = agentInfo.role
284 if not role then return end 284 if not role then return end
285 - role:log("logout", {int1 = skynet.timex()-role:getProperty("ltime")}) 285 + role:log("onLogout", {logtime = skynet.timex()-role:getProperty("ltime")})
286 role:onOfflineEvent() 286 role:onOfflineEvent()
287 end 287 end
288 288
1 -Subproject commit bc23b59073a7200db7f84316fa049019f5495796 1 +Subproject commit b026265df3a1755bad4a83630d7457b790232b3e
src/models/Activity.lua
@@ -3,6 +3,13 @@ local string_format = string.format @@ -3,6 +3,13 @@ local string_format = string.format
3 3
4 Activity.ActivityType = { 4 Activity.ActivityType = {
5 Sign = 1, -- 签到 5 Sign = 1, -- 签到
  6 + DoubleDrop = 2, -- 双倍掉落
  7 + FoodSell = 3, --贩卖周 料理
  8 + DrawHero = 4, --抽卡周 招募
  9 + AdvDraw = 5, --拾荒抽周 资助
  10 + OpenBox = 6, --拆解周 时钟箱
  11 +
  12 + SsrUpPoolChange = 10, -- 特定英雄活动,切卡池
6 } 13 }
7 14
8 15
@@ -23,13 +30,23 @@ end @@ -23,13 +30,23 @@ end
23 30
24 Activity.schema = { 31 Activity.schema = {
25 actime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time} 32 actime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time}
  33 + round = {"table", {}}, -- 记录活动到了第几轮 {id = roundnum}
26 act1 = {"table", {}}, -- {0 = day, 1= -1, 2 = -1} == 签到活动 34 act1 = {"table", {}}, -- {0 = day, 1= -1, 2 = -1} == 签到活动
  35 + act3 = {"table", {}}, -- {0 = 抽卡次数, 1=1, 2=1} 抽卡周活动 1表示领取过该档位的奖励
  36 + act4 = {"table", {}}, -- {0 = 贩卖数量, 1=1, 2=1} 贩卖周活动 1表示领取过该档位的奖励
  37 + act5 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励
  38 + act6 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励
27 } 39 }
28 40
29 function Activity:data() 41 function Activity:data()
30 return { 42 return {
31 actime = self:getProperty("actime"), 43 actime = self:getProperty("actime"),
  44 + round = self:getProperty("round"),
32 act1 = self:getProperty("act1"), 45 act1 = self:getProperty("act1"),
  46 + act3 = self:getProperty("act3"),
  47 + act4 = self:getProperty("act4"),
  48 + act5 = self:getProperty("act5"),
  49 + act6 = self:getProperty("act6"),
33 } 50 }
34 end 51 end
35 52
@@ -162,6 +179,142 @@ activityFunc[Activity.ActivityType.Sign] = { @@ -162,6 +179,142 @@ activityFunc[Activity.ActivityType.Sign] = {
162 end, 179 end,
163 } 180 }
164 181
  182 +--loop1:累计料理贩卖N次
  183 +--loop2:累计招募N次
  184 +--loop3:累计资助N次
  185 +--loop4:时钟箱拆解N个
  186 +function Activity:checkWeeklyAct(actType, notify, count, pool)
  187 + local actInfoMap = {
  188 + [Activity.ActivityType.DrawHero] = {mailId = MailId.ActDrawCardReward, table = "activity_loop2Csv"},
  189 + [Activity.ActivityType.AdvDraw] = {mailId = MailId.ActAdvDrawReward, table = "activity_loop3Csv"},
  190 + [Activity.ActivityType.OpenBox] = {mailId = MailId.ActOpenBoxReward, table = "activity_loop4Csv"},
  191 + [Activity.ActivityType.FoodSell] = {mailId = MailId.ActSellFoodReward, table = "activity_loop1Csv"}
  192 + }
  193 + if actType == Activity.ActivityType.DrawHero and pool == DrawCardType.FriendDraw then
  194 + return
  195 + end
  196 + local info = actInfoMap[actType]
  197 + if not info then return end
  198 +
  199 + local curData = self:getActData(actType)
  200 + local roundData = self:getProperty("round")
  201 + local curRound = roundData[actType] or 0
  202 + local ctrlData = csvdb["activity_ctrlCsv"][actType]
  203 + if not ctrlData then return end
  204 + if curRound >= ctrlData.condition then
  205 + return
  206 + end
  207 + curData[0] = (curData[0] or 0) + count
  208 + local totalCnt = 0
  209 + local finishCnt = 0
  210 + local maxCondition = 0
  211 + for k, cfg in pairs(csvdb[info.table] or {}) do
  212 + totalCnt = totalCnt + 1
  213 + if maxCondition < cfg.condition1 then
  214 + maxCondition = cfg.condition1
  215 + end
  216 + if not curData[cfg.id] and curData[0] >= cfg.condition1 then
  217 + if info.mailId then
  218 +
  219 + self.owner:log("activity", {
  220 + activity_id = cfg.id, -- 活动ID(或活动指定任务的ID)
  221 + activity_type = actType, -- 活动类型,见活动类型枚举表
  222 + activity_reward = cfg.reward:toNumMap(), -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
  223 + })
  224 +
  225 + self.owner:sendMail(info.mailId, nil, cfg.reward, {cfg.condition1})
  226 + curData[cfg.id] = 1
  227 + end
  228 + end
  229 + if curData[cfg.id] then
  230 + finishCnt = finishCnt + 1
  231 + end
  232 + end
  233 + if totalCnt == finishCnt then
  234 + roundData[actType] = curRound + 1
  235 + for k,v in pairs(curData) do
  236 + if k == 0 then
  237 + curData[k] = curData[0] >= maxCondition and curData[0] - maxCondition or 0
  238 + else
  239 + curData[k] = nil
  240 + end
  241 + end
  242 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  243 + end
  244 + self:updateActData(actType, curData, not notify)
  245 +end
  246 +
  247 +-- 抽卡周
  248 +activityFunc[Activity.ActivityType.DrawHero] = {
  249 + ["check"] = function(self, actType, notify, count, pool) -- 检查
  250 + self:checkWeeklyAct(actType, notify, count, pool)
  251 + end,
  252 + ["init"] = function(self, actType, isCrossDay, notify)
  253 + local roundData = self:getProperty("round")
  254 + roundData[actType] = 0
  255 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  256 + end,
  257 + -- ["close"] = function(self, actType, notify)
  258 + -- end,
  259 + ["crossDay"] = function(self, actType, notify)
  260 + print("cross day draw card")
  261 + self.owner:sendMail(MailId.ActDrawCard)
  262 + end,
  263 +}
  264 +
  265 +-- 售卖周
  266 +activityFunc[Activity.ActivityType.FoodSell] = {
  267 + ["check"] = function(self, actType, notify, count) -- 检查
  268 + self:checkWeeklyAct(actType, notify, count)
  269 + end,
  270 + ["init"] = function(self, actType, isCrossDay, notify)
  271 + local roundData = self:getProperty("round")
  272 + roundData[actType] = 0
  273 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  274 + end,
  275 + -- ["close"] = function(self, actType, notify)
  276 + -- end,
  277 + ["crossDay"] = function(self, actType, notify)
  278 + print("cross day sell food")
  279 + self.owner:sendMail(MailId.ActSellFood)
  280 + end,
  281 +}
  282 +
  283 +-- 拾荒周
  284 +activityFunc[Activity.ActivityType.AdvDraw] = {
  285 + ["check"] = function(self, actType, notify, count) -- 检查
  286 + self:checkWeeklyAct(actType, notify, count)
  287 + end,
  288 + ["init"] = function(self, actType, isCrossDay, notify)
  289 + local roundData = self:getProperty("round")
  290 + roundData[actType] = 0
  291 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  292 + end,
  293 + -- ["close"] = function(self, actType, notify)
  294 + -- end,
  295 + ["crossDay"] = function(self, actType, notify)
  296 + self.owner:sendMail(MailId.ActAdvDraw)
  297 + end,
  298 +}
  299 +
  300 +-- 拆解周
  301 +activityFunc[Activity.ActivityType.OpenBox] = {
  302 + ["check"] = function(self, actType, notify, count) -- 检查
  303 + self:checkWeeklyAct(actType, notify, count)
  304 + end,
  305 + ["init"] = function(self, actType, isCrossDay, notify)
  306 + local roundData = self:getProperty("round")
  307 + roundData[actType] = 0
  308 + self:updateProperty({field = "round", value = roundData, notNotify = not notify})
  309 + end,
  310 + -- ["close"] = function(self, actType, notify)
  311 + -- end,
  312 + ["crossDay"] = function(self, actType, notify)
  313 + print("cross day open box")
  314 + self.owner:sendMail(MailId.ActOpenBox)
  315 + end,
  316 +}
  317 +
165 function Activity:initActivity(actType, isCrossDay, notify) 318 function Activity:initActivity(actType, isCrossDay, notify)
166 if activityFunc[actType] and activityFunc[actType]['close'] then 319 if activityFunc[actType] and activityFunc[actType]['close'] then
167 activityFunc[actType]["init"](self, actType, isCrossDay, notify) 320 activityFunc[actType]["init"](self, actType, isCrossDay, notify)
@@ -172,7 +325,9 @@ function Activity:closeActivity(actType, notify, notUpdateAct) @@ -172,7 +325,9 @@ function Activity:closeActivity(actType, notify, notUpdateAct)
172 if activityFunc[actType] and activityFunc[actType]['close'] then 325 if activityFunc[actType] and activityFunc[actType]['close'] then
173 activityFunc[actType]["close"](self, actType, notify) 326 activityFunc[actType]["close"](self, actType, notify)
174 end 327 end
175 - self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct) 328 + if Activity.schema["act".. actType] then
  329 + self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct)
  330 + end
176 end 331 end
177 332
178 function Activity:refreshDailyData(notify) 333 function Activity:refreshDailyData(notify)
@@ -193,5 +348,41 @@ function Activity:checkActivity(notNotify, activityType, ...) @@ -193,5 +348,41 @@ function Activity:checkActivity(notNotify, activityType, ...)
193 end 348 end
194 end 349 end
195 350
  351 +-- 获取此次挂机掉落翻倍时长
  352 +function Activity:getActHangDoubleTime(lastTs, nowTs)
  353 + local type = "DoubleDrop"
  354 + local actId = checkActivityType(type)
  355 + local isOpen = self:isOpen(type)
  356 + local openTs = self:getProperty("actime")[actId] or 0
  357 + local timeNow = skynet.timex()
  358 + lastTs = math.max(lastTs, openTs)
  359 + if isOpen then
  360 + if nowTs > openTs and nowTs > lastTs then
  361 + return nowTs - lastTs
  362 + else
  363 + return 0
  364 + end
  365 + end
  366 + return 0
  367 +end
  368 +
  369 +-- 获取活动卡池id
  370 +function Activity:getActivityPool(mainType, subType)
  371 + if not self:isOpen(Activity.ActivityType.SsrUpPoolChange) then
  372 + return 0
  373 + end
  374 + local actData = csvdb["activity_ctrlCsv"][Activity.ActivityType.SsrUpPoolChange]
  375 + if not actData then return 0 end
  376 +
  377 + local poolMap = actData.condition2:toMap(true, "=")
  378 + local key = mainType .. "_" .. subType
  379 + for k, v in pairs(poolMap) do
  380 + if k == key then
  381 + return v
  382 + end
  383 + end
  384 + return 0
  385 +end
  386 +
196 387
197 -return Activity  
198 \ No newline at end of file 388 \ No newline at end of file
  389 +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/Diner.lua
@@ -70,12 +70,10 @@ function Diner:refreshDailyData(notify) @@ -70,12 +70,10 @@ function Diner:refreshDailyData(notify)
70 end 70 end
71 end 71 end
72 72
73 - local guide = self.owner:getProperty("newerGuide")  
74 - local master, slave = string.match(guide,"(%d+)=(%d+)")  
75 - if self.owner:getProperty("funcGuide"):getv(51,0) == 0 or tonumber(master) <= 26 then 73 + if self.owner:getProperty("funcGuide"):getv(51,0) == 0 or (not self.owner:checkOverGuide(27) and self.owner:checkOverGuide(25)) then
76 entrust[1] = 1001 74 entrust[1] = 1001
77 entrust[2] = 1 75 entrust[2] = 1
78 - elseif tonumber(master) <= 29 then 76 + elseif not self.owner:checkOverGuide(29,4) and self.owner:checkOverGuide(29) then
79 local temp = entrust[1] 77 local temp = entrust[1]
80 entrust[1] = 1 78 entrust[1] = 1
81 entrust[2] = temp 79 entrust[2] = temp
@@ -306,6 +304,7 @@ function Diner:expediteSell(slot) @@ -306,6 +304,7 @@ function Diner:expediteSell(slot)
306 lastCount = lastCount, 304 lastCount = lastCount,
307 reward = reward, 305 reward = reward,
308 popular = popular, 306 popular = popular,
  307 + deltaTime = deltaTime,
309 } 308 }
310 end 309 end
311 310
src/models/Email.lua
@@ -18,6 +18,23 @@ Email.schema = { @@ -18,6 +18,23 @@ Email.schema = {
18 rewardPms = {"table", {}}, 18 rewardPms = {"table", {}},
19 } 19 }
20 20
  21 +function Email:log(role, action)
  22 + role:log("onMail", {
  23 + mail_action_type = action, -- 操作(1=收,2=领,3=删)
  24 + mail_receivetime = self:getProperty("createtime"), -- 收件时间
  25 + mail_textid = self:getProperty("emailId"), -- 邮件文本ID
  26 + mial_title = self:getProperty("title"), -- 邮件标题参数
  27 + mail_content = json.encode(self:getProperty("contentPms")), -- 邮件内容参数
  28 + mail_attach = self:getProperty("attachments"), -- 邮件附件
  29 + mail_reason = self:getProperty("stitle"), -- 原因
  30 + mail_readstatus = self:getProperty("status") >= 1 and 1 or 0, -- 邮件读取状态
  31 + mail_attachstatus = self:getProperty("status") >= 2 and 1 or 0, -- 邮件附件状态
  32 + mail_timeout = 0, -- 邮件超时时间
  33 + mail_friend_id = 0, -- 收件方账号id
  34 + mail_friend_roleid = 0, -- 收件方角色id
  35 + })
  36 +end
  37 +
21 function Email:data() 38 function Email:data()
22 local emailId = self:getProperty("emailId") 39 local emailId = self:getProperty("emailId")
23 local title = self:getProperty("title") 40 local title = self:getProperty("title")
src/models/Role.lua
@@ -7,6 +7,7 @@ local RoleTask = import(&quot;.RoleTask&quot;) --角色任务 @@ -7,6 +7,7 @@ local RoleTask = import(&quot;.RoleTask&quot;) --角色任务
7 local RoleChangeStruct = import(".RoleChangeStruct") --角色数据额结构更改 7 local RoleChangeStruct = import(".RoleChangeStruct") --角色数据额结构更改
8 local RolePvp = import(".RolePvp") -- pvp 8 local RolePvp = import(".RolePvp") -- pvp
9 local RoleCross = import(".RoleCross") -- 跨服务请求相关 9 local RoleCross = import(".RoleCross") -- 跨服务请求相关
  10 +local RoleBattle = import(".RoleBattle") -- 跨服务请求相关
10 11
11 RoleLog.bind(Role) 12 RoleLog.bind(Role)
12 RolePlugin.bind(Role) 13 RolePlugin.bind(Role)
@@ -15,17 +16,20 @@ RoleTask.bind(Role) @@ -15,17 +16,20 @@ RoleTask.bind(Role)
15 RoleChangeStruct.bind(Role) 16 RoleChangeStruct.bind(Role)
16 RolePvp.bind(Role) 17 RolePvp.bind(Role)
17 RoleCross.bind(Role) 18 RoleCross.bind(Role)
  19 +RoleBattle.bind(Role)
18 20
19 function Role:ctor( properties ) 21 function Role:ctor( properties )
20 Role.super.ctor(self, properties) 22 Role.super.ctor(self, properties)
21 self.ignoreHeartbeat = false 23 self.ignoreHeartbeat = false
22 self.dailyData = nil 24 self.dailyData = nil
  25 + self.storeData = nil
23 self.heros = {} 26 self.heros = {}
24 self.runeBag = {} 27 self.runeBag = {}
25 self.advData = nil 28 self.advData = nil
26 self.activity = nil 29 self.activity = nil
27 self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节 30 self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节
28 self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳 31 self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳
  32 + self.sendMailFlag = false --发送邮件标识
29 end 33 end
30 34
31 Role.schema = { 35 Role.schema = {
@@ -36,6 +40,8 @@ Role.schema = { @@ -36,6 +40,8 @@ Role.schema = {
36 headId = {"number", globalCsv.defaultHead}, 40 headId = {"number", globalCsv.defaultHead},
37 sid = {"number", 0}, 41 sid = {"number", 0},
38 device = {"string", ""}, 42 device = {"string", ""},
  43 + dmode = {"string", ""},
  44 + lday = {"number", 0},
39 banTime = {"number", 0}, 45 banTime = {"number", 0},
40 banType = {"number", 0}, 46 banType = {"number", 0},
41 heartWarning = {"number", 0}, 47 heartWarning = {"number", 0},
@@ -140,12 +146,13 @@ Role.schema = { @@ -140,12 +146,13 @@ Role.schema = {
140 146
141 rechargeF = {"table", {}}, -- 是否首次充值某一项 -- —{[id] = 1} -- 不存在就是没有充值过 147 rechargeF = {"table", {}}, -- 是否首次充值某一项 -- —{[id] = 1} -- 不存在就是没有充值过
142 dinerS = {"table", {}}, -- 美食币商城 购买记录 {[id] = count} 148 dinerS = {"table", {}}, -- 美食币商城 购买记录 {[id] = count}
  149 + battlePoint = {"number", 0}, -- 赛季卡使用的活跃点
143 150
144 rmbC = {"number", 0}, -- 人民币重置额 151 rmbC = {"number", 0}, -- 人民币重置额
145 152
146 emailSync = {"number", 0}, -- 已经同步到的邮件Id 153 emailSync = {"number", 0}, -- 已经同步到的邮件Id
147 154
148 - -- repayHero = {"number", 0}, -- 超级招募 回馈 155 + repayHero = {"number", 0}, -- 招募次数 (除去友情招募)
149 floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} 156 floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count}
150 ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} 157 ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count}
151 newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr 158 newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr
@@ -156,6 +163,8 @@ Role.schema = { @@ -156,6 +163,8 @@ Role.schema = {
156 redp = {"table", {}}, -- 待消除红点 -- 通常打开对应界面就消除的红点 红点消除的方法 在对应的协议中使用 {tag = pms } 163 redp = {"table", {}}, -- 待消除红点 -- 通常打开对应界面就消除的红点 红点消除的方法 在对应的协议中使用 {tag = pms }
157 164
158 chatline = {"table", {}}, -- 奖励发放 id=时间 165 chatline = {"table", {}}, -- 奖励发放 id=时间
  166 +
  167 + downCvR = {"number", 0}, -- 下载cv扩展包奖励
159 } 168 }
160 169
161 170
@@ -360,9 +369,10 @@ function Role:data() @@ -360,9 +369,10 @@ function Role:data()
360 369
361 rechargeF = self:getProperty("rechargeF"), 370 rechargeF = self:getProperty("rechargeF"),
362 dinerS = self:getProperty("dinerS"), 371 dinerS = self:getProperty("dinerS"),
  372 + battlePoint = self:getProperty("battlePoint"),
363 373
364 rmbC = self:getProperty("rmbC"), 374 rmbC = self:getProperty("rmbC"),
365 - -- repayHero = self:getProperty("repayHero"), 375 + repayHero = self:getProperty("repayHero"),
366 newerDraw = self:getProperty("newerDraw"), 376 newerDraw = self:getProperty("newerDraw"),
367 floorHero = self:getProperty("floorHero"), 377 floorHero = self:getProperty("floorHero"),
368 378
src/models/RoleBattle.lua 0 → 100644
@@ -0,0 +1,185 @@ @@ -0,0 +1,185 @@
  1 +local RoleBattle = {}
  2 +
  3 +--[[
  4 + 100 剧情关卡类
  5 + 200 非剧情类普通关卡
  6 + 300 每日任务类、日常本类
  7 + 400 资源获取类关卡
  8 + 500 PVP关卡
  9 + 1000 活动期间限定类关卡
  10 + 2000 其他
  11 +]]
  12 +
  13 +local BattleType = {
  14 + hang = 100,
  15 + tower = 200,
  16 + bonus = 300,
  17 + pvpc = 500,
  18 + pvph = 501,
  19 +}
  20 +
  21 +RoleBattle.bind = function (Role)
  22 +
  23 +
  24 +-- TODO 检查战斗是否作弊
  25 +local function checkBattleCheat()
  26 +
  27 +end
  28 +
  29 +
  30 +
  31 +function Role:checkBattle(battleType, params)
  32 + local clientInfo = params.info or {}
  33 +
  34 + if not BattleType[battleType] then
  35 + print(string.format("NO find battleType: %s", battleType))
  36 + return
  37 + end
  38 +
  39 + local selflist = {}
  40 + local heroscore = 0
  41 + local teamskill = {}
  42 + local enemylist = {}
  43 +
  44 + local fixData = {
  45 + hang = function()
  46 + for slot, hero in pairs(self:getProperty("hangTS")) do
  47 + selflist[slot] = hero.type
  48 + end
  49 + heroscore = self:getProperty("hangTBV")
  50 + for slot , one in pairs(self:getProperty("hangTB").supports) do
  51 + teamskill[one[1]] = one[2]
  52 + end
  53 + local carbonData = csvdb["idle_battleCsv"][params.id]
  54 + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"]
  55 + for slot, one in pairs(monsterData[1]) do
  56 + enemylist[#enemylist + 1] = one["unitType"]
  57 + end
  58 + end,
  59 + tower = function()
  60 + local towerF = self:getProperty("towerF")
  61 + for slot, hero in pairs(self:getTeamHerosInfo(towerF.heros)) do
  62 + selflist[slot] = hero.type
  63 + end
  64 + heroscore = self:getTeamBattleValue(towerF.heros)
  65 + for slot , one in pairs(self:getTeamBattleInfo(towerF).supports) do
  66 + teamskill[one[1]] = one[2]
  67 + end
  68 + local carbonData = csvdb["tower_battleCsv"][params.id]
  69 + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"]
  70 + for slot, one in pairs(monsterData[1]) do
  71 + enemylist[#enemylist + 1] = one["unitType"]
  72 + end
  73 + end,
  74 + bonus = function()
  75 + local bTeam = self:getProperty("bTeam")
  76 + for slot, hero in pairs(self:getTeamHerosInfo(bTeam.heros)) do
  77 + selflist[slot] = hero.type
  78 + end
  79 + heroscore = self:getTeamBattleValue(bTeam.heros)
  80 + for slot , one in pairs(self:getTeamBattleInfo(bTeam).supports) do
  81 + teamskill[one[1]] = one[2]
  82 + end
  83 + local carbonData = csvdb["tower_battleCsv"][params.id]
  84 + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"]
  85 + for slot, one in pairs(monsterData[1]) do
  86 + enemylist[#enemylist + 1] = one["unitType"]
  87 + end
  88 + end,
  89 + pvpc = function()
  90 + for slot, hero in pairs(self:getProperty("pvpTSC")) do
  91 + selflist[slot] = hero.type
  92 + end
  93 + heroscore = self:getProperty("pvpTBVC")
  94 + for slot , one in pairs(self:getProperty("pvpTBC").supports) do
  95 + teamskill[one[1]] = one[2]
  96 + end
  97 + if params.robotId then
  98 + local carbonData = csvdb["pvp_robotCsv"][params.robotId]
  99 + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"]
  100 + for slot, one in pairs(monsterData[1]) do
  101 + enemylist[#enemylist + 1] = one["unitType"]
  102 + end
  103 + else
  104 + for slot, one in pairs((params.enemy or {})["heros"] or {}) do
  105 + enemylist[slot] = one["type"]
  106 + end
  107 + end
  108 + end,
  109 + pvph = function()
  110 + for idx, team in pairs(self:getProperty("pvpTSH")) do
  111 + selflist[idx] = selflist[idx] or {}
  112 + for slot, hero in pairs(team) do
  113 + selflist[idx][slot] = hero.type
  114 + end
  115 + end
  116 + for _, one in pairs(self:getProperty("pvpTBVH")) do
  117 + heroscore = heroscore + one
  118 + end
  119 + for idx, team in pairs(self:getProperty("pvpTBH")) do
  120 + for slot , one in pairs(team.supports) do
  121 + teamskill[one[1]] = one[2]
  122 + end
  123 + end
  124 +
  125 + if params.robotId then
  126 + local carbonData = csvdb["pvp_robot_groupCsv"][params.robotId]
  127 + for idx = 1, 3 do
  128 + enemylist[idx] = enemylist[idx] or {}
  129 + local monsterData = csvdb[carbonData["monster" .. idx]:match("/([^/]*)$") .. "Csv"]
  130 + for slot, one in pairs(monsterData[1]) do
  131 + enemylist[idx][#enemylist + 1] = one["unitType"]
  132 + end
  133 + end
  134 + else
  135 + for idx, team in pairs(params.enemy or {}) do
  136 + enemylist[idx] = enemylist[idx] or {}
  137 + for slot, one in pairs(team["heros"] or {}) do
  138 + enemylist[idx][slot] = one["type"]
  139 + end
  140 + end
  141 + end
  142 + end
  143 + }
  144 +
  145 + if fixData[battleType] then
  146 + fixData[battleType]()
  147 + end
  148 +
  149 + -- robotId = match.t == 2 and match.id or nil,
  150 + -- enemy = match.t == 1 and (revenge and _pvpRecordBattleInfoCacheH[match.id] or _pvpBattleInfoCacheH[match.id]) or nil,
  151 + -- score = myScore,
  152 + -- reward = reward,
  153 + self:log("mission", {
  154 + mission_threadid = battleType == "hang" and math.floor((params.id % 100) / 100) or 0, -- 大关卡ID
  155 + mission_id = params.id or 0, -- 关卡ID
  156 + mission_type = BattleType[battleType], -- 关卡类型,见关卡类型枚举表
  157 + mission_herolist = selflist, -- 英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]]
  158 + mission_heroscore = heroscore, -- 编队总评分
  159 + mission_enemylist = enemylist, -- 地方英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]]
  160 + mission_damage = clientInfo.damage or {}, -- 英雄输出值。示例:{'heroid1':1000,'heroid2':2000,………..}
  161 + mission_ultskill = clientInfo.ultskill or {}, -- 大招使用情况。示例:{'heroid1':1000,'heroid2':2000,………..}
  162 + mission_reward = params.reward or {}, -- 获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
  163 + mission_starttime = clientInfo.start or 0, -- 战斗开始时间,格式 unixtime 秒级
  164 + mission_roundtime = clientInfo.atime or 0, -- 对局时长(秒)
  165 + mission_result = params.isWin and 1 or 2, -- 战斗结果(0-无效,1-胜利,2-失败)
  166 + mission_star = 0, -- 战斗完成星数,无星级的话填写0
  167 + mission_restriction = 0, -- 周期内参与限制(0表示没有上限)
  168 + mission_difficulty = 0, -- 关卡困难度,无难度区分的话填写0
  169 + mission_strength = 1, -- 消耗的体力或次数
  170 + mission_score = params.score or 0, -- 本局分数,PVP玩法记录为对战后积分,无得分的填0
  171 + mission_cleartype = 1, -- 1正常通关;2代理拾荒
  172 + mission_rank = params.rank, -- 对战后排名,适用于PVP玩法和电波塔,其他玩法留空
  173 + misson_monsterkill = clientInfo.kill or {}, -- 击杀怪物ID和数量,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
  174 + misson_teamskill = teamskill, -- 编队支援技能和技能等级情况,json格式记录,{"teamskill1":1,"teamskill2":2,………..}
  175 + })
  176 +end
  177 +
  178 +
  179 +
  180 +
  181 +
  182 +end
  183 +
  184 +
  185 +return RoleBattle
0 \ No newline at end of file 186 \ No newline at end of file
src/models/RoleLog.lua
  1 +local server_id = (skynet.getenv("serverType") or "localtest") .. "_" .. skynet.getenv("servId")
1 2
2 --- logType  
3 -local LogType = {  
4 - create = "common",  
5 - login = "common",  
6 - logout = "common",  
7 - guide = "common", 3 +--[[
  4 + 100 购买/兑换行为
  5 + 200 交易行为(与其他玩家)
  6 + 300 通过关卡产出或消耗
  7 + 400 通过任务产出或消耗
  8 + 500 通过公会产出或消耗
  9 + 600 通过成就产出或消耗
  10 + 700 通过邮件产出或消耗
  11 + 1000 其他行为
  12 +--]]
  13 +local ItemReason = {
  14 + recharge = 100,
  15 + advWheelSurf = 101, -- 资助
  16 + advRepayWheelSurf = 102, -- 资助回馈
  17 + saleEquip = 103, -- 卖装备
  18 + saleRune = 104, -- 卖铭文
  19 + drawHero = 105, -- 抽卡
  20 + pvpShop = 106, -- pvp商店
  21 + saleItem = 107, -- 售卖道具
  22 + openItem = 108, -- 打开箱子
  23 + openTimeBox = 109, -- 打开时间箱
  24 + speedUpBox = 110, -- 速度箱
  25 + dailyShop = 111, -- 每日商城
  26 + dinershop = 112, -- 餐厅商店
  27 + goldBuy = 113, -- 购买金币
  28 + buyAdvCount = 114, -- 购买冒险次数
  29 + advReSupport = 115, -- 刷新拾荒支援技
  30 + advQuickHang = 116, -- 冒险快速挂机
  31 + makePotion = 117, -- 制造药剂
  32 + equipUp = 118, -- 装备升级
  33 + runeUp = 119, -- 符文升级
  34 + talentUp = 120, -- 天赋升级
  35 + buyBonusCount = 121, -- 购买奖励副本次数
  36 + bagField = 122, -- 背包栏位
  37 + buyPvpKey = 123, -- 购买pvp钥匙
  38 + startPvp = 124, -- 开始pvp
  39 + unlockStory = 125, -- 解锁剧情
  40 + towerCount = 126, -- 电波塔次数
  41 +
  42 +
  43 + advHang = 301, -- 拾荒挂机
  44 + hangBattle = 302, -- 挂机战斗
  45 + hangReward = 303, -- 挂机奖励
  46 + quickHang = 304, -- 快速挂机
  47 + bonusBattle = 305, -- 奖励副本
  48 + hangGift = 306, -- 奖励关卡奖励
  49 + pvpBattleC = 307, -- pvp战斗普通
  50 + pvpBattleH = 308, -- pvp战斗高级
  51 + pvpDivisionH = 309, -- pvp高级段位奖励
  52 + towerBattle = 310, -- 电波塔战斗
  53 + advOver = 311, -- 冒险结算
  54 + advUnlock = 312, -- 拾荒解锁
8 55
9 - in_item = "common",  
10 - out_item = "common",  
11 - in_diamond = "common",  
12 - out_diamond = "common",  
13 - in_hero = "common",  
14 - out_hero = "common",  
15 - in_equip = "common",  
16 - out_equip = "common",  
17 - in_rune = "common",  
18 - out_rune = "common",  
19 - player_exp = "common",  
20 - func_open = "common",  
21 - in_adv = "common",  
22 - out_adv = "common",  
23 - in_artifact = "common",  
24 -  
25 - mail_action = "common",  
26 - role_action = "common",  
27 - hang_action = "common",  
28 - hero_action = "common",  
29 - adv_action = "common",  
30 - rune_action = "common",  
31 - pvp_action = "common",  
32 - diner_action = "common",  
33 - tower_action = "common",  
34 - gm_action = "common",  
35 - act_action = "common", 56 + dinerFinishTask = 401, -- 餐厅完成任务
  57 + storybookReward = 402, -- 剧情奖励
  58 + finishTask = 403, -- 任务
  59 + taskActive = 404, -- 完成活跃任务
  60 + advMainTask = 405, -- 拾荒主线
  61 +
  62 + finishAchive = 601, -- 完成成就
  63 + advAchiev = 602, -- 拾荒成就
  64 + advAchievReward = 603, -- 拾慌成就奖励
  65 +
  66 + draw_attach = 701, -- 邮件奖励
  67 +
  68 + gm = 1000, -- 获取途径:GM
  69 +
  70 + -- 活动
  71 + sudoku = 1001, -- 九宫格
  72 + sudokuR = 1002, -- 九宫格连线奖励
  73 + sudokuRP = 1003, -- 九宫格阶段奖励
  74 + sign = 1004, -- 签到
  75 + friendPoint = 1005, -- 友情
  76 + birth = 1006, -- 出生奖励
  77 + actSign = 1007, -- 活动签到
  78 +
  79 + -- 餐厅
  80 + greenHourse = 1101, -- 食材获得
  81 + dinerEntrus = 1102, -- 餐厅委托
  82 + dinerCollect = 1103, -- 餐厅小人收集
  83 + dinerCombo = 1104, -- 小人组合
  84 + dinerSkillUp = 1105, -- 餐厅技能升级
  85 + dinerReTask = 1106, -- 餐厅刷新任务
  86 + addSell = 1107, -- 餐厅贩卖
  87 + dinerBuildUp = 1108, -- 建筑升级
  88 + removeSell = 1109, -- 移除售卖
  89 + dinerSell = 1110, -- 餐饮售卖
  90 +
  91 + -- 英雄
  92 + heroLevelUp = 1201, -- 英雄升级
  93 + heroBreak = 1202, -- 英雄突破
  94 + heroWake = 1203, -- 英雄觉醒
  95 + heroTalent = 1204, -- 英雄天赋
  96 + createHero = 1205, -- 碎片合成
  97 + createHeroRandom = 1206, -- 随机合成
  98 + resetHero = 1207, -- 重置养成
  99 + unlockPool = 1208, -- 解锁英雄定向抽卡池
36 } 100 }
37 101
38 --- 如要修改 要提前修改 _template mapping -- 对应 mapping 为 gamelog-*  
39 -local Mapping = {  
40 - -- 预留一些数据格式 担心integer 范围不够用 将 通用的int* 全部换为long  
41 - common = {  
42 - desc = "keyword",--索引的短字符串  
43 - ucode = "keyword",--关联日志对应ucode  
44 - key1 = "keyword", --可索引的短字符串  
45 - key2 = "keyword", --可索引的短字符串  
46 - -- 几乎不用的长文本  
47 - text1 = "text", --长字符串不索引的类型  
48 - -- 五个不同类型的数字 基本上满足数量要求 尽量从低到高用  
49 - short1 = "short",  
50 - int1 = "long",  
51 - int2 = "long",  
52 - long1 = "long",  
53 - float1 = "float",  
54 -  
55 - -- 底层使用的 一些参数  
56 - cint1 = "long",  
57 - cint2 = "long",  
58 - cint3 = "long",  
59 - } 102 +
  103 +--[[
  104 +100 教学
  105 +200 主线
  106 +300 日常
  107 +400 周常
  108 +500 联盟
  109 +1000 限时任务
  110 +2000 其他
  111 +--]]
  112 +local TaskType = {
  113 +
60 } 114 }
61 115
62 --- 所有的日志都包括的部分 role 里面的信息 -- mapping 信息在 gamelog-role  
63 -local commonRoleField = {  
64 - name = "keyword",  
65 - id = "integer",  
66 - uid = "keyword",  
67 - sid = "short",  
68 - device = "keyword",  
69 - ctime = "integer",  
70 - ltime = "integer",  
71 - level = "short",  
72 - rmbC = "integer", 116 +
  117 +local MethodType = {
  118 + onCreateAccount = {}, -- 创建游戏账号
  119 + onCreateRole = {}, -- 创建游戏角色
  120 + onLogin = {}, -- 玩家登录
  121 + onLogout = { -- 登出
  122 + logtime = true, --登录时长
  123 + },
  124 + setLevel = { -- 设置等级
  125 + level_before = true, -- 变动前的等级,可以跳级
  126 + level_changemain = true, -- 等级变动原因,副本通关:mission,领取奖励:reward
  127 + level_changedetail = true, -- 等级变动原因明细,副本通关则记录关卡ID,领取奖励则记录奖励ID
  128 + level_reward = "json", -- 等级变动奖励,json格式记录,{道具ID1:道具数量,道具ID2:道具数量}
  129 + },
  130 + onGuidePoint = { --游戏引导
  131 + guild_type = true, --引导类型,新手引导:0,系统引导:1,弱引导:2
  132 + guild_id = true, --节点ID
  133 + guild_point = true, --步骤ID
  134 + guild_pass = true, --正常操作:0,自动播放:1,跳过:2
  135 + },
  136 + setOrder = { --玩家订单记录
  137 + order_status = true, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他"
  138 + item_id = true, -- 道具id
  139 + item_type = true, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表
  140 + item_name = true, -- 购买的道具名
  141 + item_number = true, -- 购买的道具数量
  142 + item_level = true, -- 购买的道具等级
  143 + order_cost = true, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee'
  144 + order_currency = true, -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范
  145 + order_type = true, -- 订单类型,首充记录为1,否则为0
  146 + order_id = true, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no'
  147 + },
  148 + onMail = { --玩家邮件操作
  149 + mail_action_type = true, -- 操作(1=收,2=领,3=删)
  150 + mail_receivetime = true, -- 收件时间
  151 + mail_textid = true, -- 邮件文本ID
  152 + mial_title = true, -- 邮件标题参数
  153 + mail_content = true, -- 邮件内容参数
  154 + mail_attach = true, -- 邮件附件
  155 + mail_reason = true, -- 原因
  156 + mail_readstatus = true, -- 邮件读取状态
  157 + mail_attachstatus = true, -- 邮件附件状态
  158 + mail_timeout = true, -- 邮件超时时间
  159 + mail_friend_id = true, -- 收件方账号id
  160 + mail_friend_roleid = true, -- 收件方角色id
  161 + },
  162 + onItems = { --道具流通
  163 + item_id = true, -- 道具id
  164 + item_sequenceid = "ucode", -- 道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一个礼包多个物品等情形
  165 + item_type = true, -- 道具类型,具体见枚举表中道具类型枚举表
  166 + item_level = true, -- 道具等级
  167 + item_number = true, -- 道具变化数量的绝对值
  168 + action_type = true, -- 变化类型(玩家获取:1,玩家消耗:0)
  169 + item_before = true, -- 道具变化前的数量
  170 + item_after = true, -- 道具变化后的数量
  171 + item_reason = true, -- 道具流动一级原因,如抽卡、装备强化、副本掉落,可参考道具动作类型枚举表
  172 + item_subreason = true, -- 道具流动二级原因,抽卡:卡池ID,装备强化:装备ID,副本掉落:副本ID
  173 + item_other = true, -- 其他(可包含阶数,强化等级,随机属性)
  174 + },
  175 + mission = { --玩家副本完成情况
  176 + mission_threadid = true, -- 大关卡ID
  177 + mission_id = true, -- 关卡ID
  178 + mission_type = true, -- 关卡类型,见关卡类型枚举表
  179 + mission_sequenceid = "ucode", -- 本次对战ID,用于关联一次动作产生多条不同类型的日志
  180 + mission_herolist = "json", -- 英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]]
  181 + mission_heroscore = true, -- 编队总评分
  182 + mission_enemylist = "json", -- 地方英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]]
  183 + mission_damage = "json", -- 英雄输出值。示例:{'heroid1':1000,'heroid2':2000,………..}
  184 + mission_ultskill = "json", -- 大招使用情况。示例:{'heroid1':1000,'heroid2':2000,………..}
  185 + mission_reward = "json", -- 获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
  186 + mission_starttime = true, -- 战斗开始时间,格式 unixtime 秒级
  187 + mission_roundtime = true, -- 对局时长(秒)
  188 + mission_result = true, -- 战斗结果(0-无效,1-胜利,2-失败)
  189 + mission_star = true, -- 战斗完成星数,无星级的话填写0
  190 + mission_restriction = true, -- 周期内参与限制(0表示没有上限)
  191 + mission_difficulty = true, -- 关卡困难度,无难度区分的话填写0
  192 + mission_strength = true, -- 消耗的体力或次数
  193 + mission_score = true, -- 本局分数,PVP玩法记录为对战后积分,无得分的填0
  194 + mission_cleartype = true, -- 1正常通关;2代理拾荒
  195 + mission_rank = true, -- 对战后排名,适用于PVP玩法和电波塔,其他玩法留空
  196 + misson_monsterkill = "json", -- 击杀怪物ID和数量,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
  197 + misson_teamskill = "json", -- 编队支援技能和技能等级情况,json格式记录,{"teamskill1":1,"teamskill2":2,………..}
  198 + misson_teambond = "json", -- 编队羁绊和羁绊等级,json格式记录,{"bondid1":1,"bondid2":2,………..}
  199 + },
  200 + residence_reward = { --玩家挂机或排名奖励
  201 + mission_threadid = true, --大关卡ID
  202 + mission_id = true, --关卡ID
  203 + mission_type = true, --关卡类型,见关卡类型枚举表
  204 + residence_reward_type = true, --领取奖励方式,快速(超前领取)记录为1,正常领取记录为0
  205 + residence_time = true, --挂机或排名时长
  206 + residence_reward = "json", --获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
  207 + },
  208 + hero_rise = { --英雄觉醒
  209 + hero_id = true, --英雄ID
  210 + hero_rise_cost = "json", --英雄觉醒消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
  211 + hero_rise_score = true, --英雄觉醒后评分提升
  212 + hero_rise_result = "json", --英雄觉醒效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..}
  213 + },
  214 + hero_upgrade = { --英雄升级
  215 + hero_id = true, -- 英雄ID
  216 + hero_upgrade_cost = "json", -- 英雄升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
  217 + hero_upgrade_result = "json", -- 英雄升级效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..}
  218 + hero_upgrade_type = true, -- 英雄升级方式,连续升级:1,单击升级:0
  219 + hero_upgrade_score = true, -- 英雄升级后评分
  220 + hero_upgrade_scoreget = true, -- 通过英雄升级提升的评分
  221 + },
  222 + hero_break = { --英雄突破
  223 + hero_id = true, -- 英雄ID
  224 + hero_break_cost = "json", -- 英雄突破消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
  225 + hero_break_result = "json", -- 英雄突破效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..}
  226 + hero_break_level = true, -- 英雄突破后等级上限
  227 + },
  228 + hero_talent = { --英雄天赋升级
  229 + hero_id = true, -- 英雄ID
  230 + hero_talent_cost = "json", -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
  231 + hero_talent_levelbef = true, -- 英雄技能升级前等级
  232 + hero_talent_level = true, -- 英雄技能升级后等级
  233 + },
  234 + hero_jewel = { --英雄铭文
  235 + hero_id = true, -- 英雄ID
  236 + hero_jewel_sequence = "ucode", -- 铭文装备编号,用以关联一次装备时产生的多条日志
  237 + hero_jewel_id = true, -- 铭文ID
  238 + hero_jewel_part = true, -- 铭文装备部位
  239 + hero_jewel_score = true, -- 铭文装备后的英雄分值
  240 + hero_jewel_scorebefore = true, -- 铭文装备前的英雄分值
  241 + hero_jewel_result = "json", -- 铭文装备后效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..}
  242 + },
  243 + hero_note = { --英雄评价
  244 + hero_id = true, -- 英雄ID
  245 + hero_note_action = true, -- 英雄评价界面操作,发布评论:0,点赞:1,反对:2
  246 + hero_note_id = true, -- 操作的评价ID
  247 + hero_note_text = true, -- 操作的评价内容
  248 + },
  249 + hero_show = { --展示英雄
  250 + hero_id = true, -- 英雄ID
  251 + },
  252 + hero_recycle = { --英雄回收
  253 + hero_recycle_list = "json", -- 回收的英雄id列表,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
  254 + hero_recycle_reward = "json", -- 回收后获得的奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
  255 + hero_recycle_cnt = true, -- 总回收英雄量
  256 + },
  257 + gacha = { --英雄招募
  258 + gacha_id = true, -- 卡池ID
  259 + gacha_type = true, -- 卡池类型
  260 + gacha_up = true, -- 卡池UP角色
  261 + gacha_times = true, -- 抽卡次数
  262 + gacha_reward = "json", -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
  263 + currency = "json", -- 消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
  264 + },
  265 + equip_wear = { --装备穿戴与卸载
  266 + hero_id = true, --英雄ID
  267 + equip_id = true, --装备ID
  268 + equip_wear_action = true, --装备操作类型:装备:0,卸载:1
  269 + equip_wear_part = true, --装备部位,记录部位ID
  270 + equip_wear_result = "json", --装备操作后结果,记录属性变化,json格式记录,{“aa”:1234,"bb":4567}
  271 + equip_wear_change = "json", --装备操作变化值,记录属性变化,记录正负值,json格式记录,{“aa”:1234,"bb":-45}
  272 + equip_wear_mode = true, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1
  273 + equip_wear_seqid = "ucode", --自动穿戴时记录的系列ID,用以关联一次性装备时候产生的多条记录
  274 + },
  275 + equip_upgrade = { --装备升级
  276 + equip_upgrade_part = true, -- 升级部位,记录部位ID
  277 + equip_id = true, -- 升级后的装备ID
  278 + equip_upgrade_amount = true, -- 升级获取的装备数量
  279 + equip_upgrade_usedid = true, -- 升级消耗的装备ID
  280 + equip_upgrade_cost = true, -- 升级操作消耗装备数量
  281 + equip_upgrade_current = true, -- 升级操作消耗货币数量
  282 + },
  283 + carriage_dismantle = { --物资拆解
  284 + item_id = true, -- 道具id
  285 + item_sequenceid = "ucode", -- 道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一个礼包多个物品等情形
  286 + item_type = true, -- 道具类型,具体见枚举表中道具类型枚举表
  287 + item_level = true, -- 道具等级
  288 + item_number = true, -- 道具变化数量的绝对值
  289 + carriage_dismantle_type = true, -- 拆解方式,时间到期:0,钥匙开启:1
  290 + carriage_dismantle_time = true, -- 拆解耗时,填写实际耗时
  291 + carriage_dismantle_cost = true, -- 拆解花费钥匙数量,未使用填写0
  292 + carriage_dismantle_rwd = "json", -- 拆解获得物资,json格式记录,{'itemid1':2,'itemid2':3,…………..}
  293 + },
  294 + carriage_logistics = { --后勤室
  295 + carriage_logistics_type = true, -- 后勤室制作类型ID,变异:0,通常:1,魔法:2
  296 + carriage_logistics_itemid = true, -- 后勤室升级物品或技能ID
  297 + carriage_logistics_itemlv = true, -- 升级后物品或技能等级
  298 + carriage_logistics_gear = true, -- 后勤室升级花费齿轮数量
  299 + carriage_logistics_coin = true, -- 后勤室升级花费美食币数量
  300 + },
  301 + carriage_decals = { --贴纸拆解
  302 + item_id = true, --道具id
  303 + item_sequenceid = "ucode", --道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一个礼包多个物品等情形
  304 + item_type = true, --道具类型,具体见枚举表中道具类型枚举表
  305 + item_level = true, --道具等级
  306 + item_number = true, --道具变化数量的绝对值
  307 + carriage_decals_rwdid = true, --拆解获得物资ID
  308 + carriage_decals_rwdnum = true, --拆解获得物资数量
  309 + },
  310 + carriage_video = { --放映室
  311 + carriage_video_type = true, --放映室类型,剧情CG:0, 角色CG:1, 主线剧情:2, 角色剧情:3, 活动剧情:4, 图鉴:5
  312 + carriage_video_id = true, --放映室片段ID
  313 + carriage_video_coinid = true, --放映奖励货币类型,无奖励则填写0
  314 + carriage_video_coinnum = true, --放映奖励货币数量,无奖励则填写0
  315 + carriage_video_item = "json", --放映奖励其他物品数量,json格式记录,{'itemid1':10,'itemid2':5,…………..},无奖励则填写0
  316 + },
  317 + carriage_cook = { --调理室
  318 + item_id = true, -- 道具id
  319 + item_level = true, -- 道具等级
  320 + item_type = true, -- 道具类型,具体见枚举表中道具类型枚举表
  321 + carriage_cook_amount = true, -- 制作总量
  322 + carriage_cook_cost = "json", -- 制作消耗道具,json格式记录,{'itemid1':10,'itemid2':5,…………..}
  323 + },
  324 + activity = { --活动或指南奖励
  325 + activity_id = true, -- 活动ID(或活动指定任务的ID)
  326 + activity_type = true, -- 活动类型,见活动类型枚举表
  327 + activity_reward = "json", -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
  328 + },
  329 + task_reward = { --任务奖励
  330 + task_reward_id = true, --任务奖励ID
  331 + task_reward_type = true, --任务奖励类型,见 任务奖励类型枚举表
  332 + task_reward_detail = "json", --任务奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
  333 + },
  334 + shop_purchase = { --商店购买行为
  335 + item_id = true, -- 道具id
  336 + item_sequenceid = "ucode", -- 道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一个购买礼包多个物品等情形
  337 + item_type = true, -- 道具类型,具体见枚举表中道具类型枚举表
  338 + item_level = true, -- 道具等级
  339 + item_cnt = true, -- 购买数量技术
  340 + currency_type = true, -- 购买道具消耗的货币类型,记录货币ID
  341 + shop_purchase_current = true, -- 购买道具消耗的货币数量
  342 + shop_id = true, -- 商店ID
  343 + },
  344 + --[[
  345 + 100 添加好友
  346 + 200 删除好友
  347 + 300 屏蔽/拉黑
  348 + 1000 其他
  349 + --]]
  350 + friend_opt = { --好友操作
  351 + friend_opt_type = true, -- 好友操作类型,见枚举表中 好友操作类型枚举表
  352 + friend_accountid = true, -- 好友账户id
  353 + friend_roleid = true, -- 好友账户下的角色id
  354 + friend_cnt = true, -- 操作后好友数量
  355 + },
  356 + communication = { --玩家发言
  357 + publish_type = true, --发言类型,全部:0,公告:1,世界:2,联盟:3,私聊:4
  358 + publish_status = true, --发送状态,发送成功:0,发送失败:1,被屏蔽:2,其他:3
  359 + publish_receive_roleid = true, --接收者角色ID
  360 + publish_text = true, --发言内容
  361 + },
  362 + restaurant_up = { --摊位升级
  363 + restaurant_up_type = true, --升级部件类型,店面:0, 接客:1, 满意度:2, 宣传:3, 广告:4, 周边:5
  364 + restaurant_up_gear = true, --消耗齿轮数量
  365 + restaurant_up_coin = true, --花费美食币数量
  366 + restaurant_up_effectbef = true, --升级前加成
  367 + restaurant_up_effect = true, --升级后加成
  368 + },
  369 + restaurant_sale = { --摊位售卖
  370 + item_id = true, -- 售卖物品ID
  371 + restaurant_sale_seat = true, -- 售卖物品所在位置
  372 + restaurant_sale_time = true, -- 售卖时长
  373 + restaurant_sale_type = true, -- 售卖方式,正常售卖:0, 加速:1,移除售卖:2
  374 + restaurant_sale_coin = true, -- 售卖获得美食币
  375 + restaurant_sale_gear = true, -- 售卖获得齿轮
  376 + },
  377 + restaurant_material = { --食材获取
  378 + item_id = true, -- 获取物品ID
  379 + restaurant_material_seqid = "ucode", -- 道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一次获取两件道具情况
  380 + restaurant_material_start = true, -- 申请获取时间
  381 + restaurant_material_time = true, -- 申请到领取耗时
  382 + restaurant_material_num = true, -- 获取物品数量
  383 + },
  384 + restaurant_order = { --订单任务
  385 + restaurant_order_id = true, -- 订单任务ID
  386 + restaurant_order_status = true, -- 订单任务状态,接受:0, 拒绝:1, 完成:2
  387 + restaurant_order_rwd = "json", -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….}
  388 + restaurant_order_lv = true, -- 订单品质等级,普通:0, 稀有:1, 顶级:2, 豪华:3
  389 + },
  390 + restaurant_collect = { --餐厅顾客图谱
  391 + restaurant_collect_id = true, -- 图谱收集ID
  392 + restaurant_collect_rwd = "json", -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….}
  393 + restaurant_collect_plan = true, -- 收集进度,即解锁顾客,数字表示
  394 + },
  395 + achievement = { --成就达成
  396 + achievement_id = true, -- 成就id
  397 + achievement_type = true, -- 成就类型,具体枚举表中成就类型枚举表
  398 + achievement_reward = "json", -- 达成成就奖励,json格式记录,{"itemid1":123,"itemid2":12,……….}
  399 + },
  400 + get_gift = { --礼包兑换
  401 + gift_id = true, -- 礼包ID
  402 + gift_key = true, -- 礼包key
  403 + gift_reward = "json", -- 礼包奖励,json格式记录,{"itemid1":123,"itemid2":12,……….}
  404 + gift_name = true, -- 礼包名称
  405 + gift_reason = true, -- 礼包发放原因,见发放原因枚举表
  406 + },
73 } 407 }
74 408
75 local function printError(info) 409 local function printError(info)
@@ -77,138 +411,119 @@ local function printError(info) @@ -77,138 +411,119 @@ local function printError(info)
77 print(debug.traceback()) 411 print(debug.traceback())
78 end 412 end
79 413
80 -local function checkType(logType, field, value, ctype)  
81 - local typecheckfunc = {  
82 - keyword = function()  
83 - --长度不超过256  
84 - if type(value) ~= "string" then  
85 - value = tostring(value)  
86 - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [keyword], value : %s", logType, field, value))  
87 - else  
88 - if #value > 256 then  
89 - printError(string.format("LOG ERROR: logType [%s] field [%s] [keyword] type to long. value : %s", logType, field, value))  
90 - end  
91 - end  
92 - return value  
93 - end,  
94 - text = function()  
95 - if type(value) ~= "string" then  
96 - value = tostring(value)  
97 - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [text], value : %s", logType, field, value))  
98 - end  
99 - return value  
100 - end,  
101 - integer = function()  
102 - if type(value) ~= "number" then  
103 - value = tonumber(value)  
104 - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [integer], value : %s", logType, field, value))  
105 - end  
106 - if value then  
107 - if math.type(value) ~= "integer" then  
108 - local oldValue = value  
109 - value = math.floor(value)  
110 - if value ~= oldValue then  
111 - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [integer], is float, value : %s", logType, field, value))  
112 - end  
113 - end  
114 - if -2147483648 > value or value > 2147483647 then  
115 - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [integer], too big, value : %s", logType, field, value))  
116 - value = nil  
117 - end  
118 - end  
119 - return value  
120 - end,  
121 - short = function()  
122 - if type(value) ~= "number" then  
123 - value = tonumber(value)  
124 - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [short], value : %s", logType, field, value))  
125 - end  
126 - if value then  
127 - if math.type(value) ~= "integer" then  
128 - local oldValue = value  
129 - value = math.floor(value)  
130 - if value ~= oldValue then  
131 - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [short], is float, value : %s", logType, field, value))  
132 - end  
133 - end 414 +local function jsonEncode(tab)
  415 + local newTab = {}
  416 + for k , v in pairs(tab) do
  417 + newTab[tostring(k)] = v
  418 + end
  419 + return json.encode(newTab)
  420 +end
134 421
135 - if -32768 > value or value > 32768 then  
136 - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [short], too big, value : %s", logType, field, value))  
137 - value = nil  
138 - end  
139 - end  
140 - return value  
141 - end,  
142 - long = function()  
143 - if type(value) ~= "number" then  
144 - value = tonumber(value)  
145 - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [long], value : %s", logType, field, value))  
146 - end  
147 - if value then  
148 - if math.type(value) ~= "integer" then  
149 - local oldValue = value  
150 - value = math.floor(value)  
151 - if type(value) ~= "integer" then  
152 - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [long], too big, value : %s", logType, field, value))  
153 - value = nil  
154 - elseif value ~= oldValue then  
155 - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [long], is float, value : %s", logType, field, value))  
156 - end  
157 - end  
158 - end  
159 - return value  
160 - end,  
161 - float = function()  
162 - if type(value) ~= "number" then  
163 - value = tonumber(value)  
164 - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [float], value : %s", logType, field, value))  
165 - end  
166 - return value  
167 - end,  
168 - } 422 +local function isIos(self)
  423 + local sid = self:getProperty("sid")
  424 + return sid == 2
  425 +end
169 426
170 - if typecheckfunc[ctype] then  
171 - return typecheckfunc[ctype]()  
172 - else  
173 - printError(string.format("LOG ERROR: logType [%s] field [%s] have a new type [%s] need add check.", logType, field, ctype))  
174 - return nil 427 +local appid, sdkId
  428 +local function getBaseLog(self)
  429 + local uid = self:getProperty("uid")
  430 + if not appid then
  431 + appid, sdkId = string.match(uid, "(.*)_(.*)")
  432 + if not appid then
  433 + sdkId = uid
  434 + appid = 0
  435 + end
175 end 436 end
  437 + local log = {
  438 + server_id = server_id,
  439 + timestamp = skynet.timex(),
  440 + app_id = appid,
  441 + plat_id = isIos(self) and 0 or 1,
  442 + sdk_uid = sdkId,
  443 + account_id = uid,
  444 + role_id = self:getProperty("id"),
  445 + role_name = self:getProperty("name"),
  446 + level = self:getProperty("level"),
  447 + vip = 0,
  448 + device_id = self:getProperty("device"),
  449 + device_model = self:getProperty("dmode"),
  450 + version = "v2.0.1",
  451 + client_version = self.clientVersion or "1.0.0",
  452 + sys_version = self.sysVersion or "unknow",
  453 + ip = self.ip or "0.0.0.0",
  454 + network = self.network or "unknow",
  455 + record_date = os.date("%Y%m%d"),
  456 + }
  457 + return log
176 end 458 end
177 459
  460 +
  461 +
178 local RoleLog = {} 462 local RoleLog = {}
179 function RoleLog.bind(Role) 463 function RoleLog.bind(Role)
180 function Role:log(logType, contents) 464 function Role:log(logType, contents)
181 contents = contents or {} 465 contents = contents or {}
182 - local _logType = LogType[logType]  
183 - if not _logType then  
184 - printError(string.format("LOG ERROR: new logType [%s] need Add Maping.", logType)) 466 + local schema = MethodType[logType]
  467 + if not schema then
  468 + printError(string.format("LOG ERROR: new logType [%s].", logType))
185 return 469 return
186 end 470 end
187 - local doc = {}  
188 - for field, ctype in pairs(commonRoleField) do  
189 - if contents[field] then  
190 - printError(string.format("LOG ERROR: logType [%s] had field [%s] overwrite default.", logType, field))  
191 - end  
192 - doc[field] = checkType("commonRoleField", field, self:getProperty(field), ctype)  
193 - end  
194 -  
195 - local mapping = Mapping[_logType]  
196 - if mapping["ucode"] and not contents["ucode"] then  
197 - contents["ucode"] = self:getActionUcode()  
198 - end 471 + local doc = getBaseLog(self)
199 472
  473 + doc["method"] = logType
200 for field, value in pairs(contents) do 474 for field, value in pairs(contents) do
201 - local ftype = mapping[field]  
202 - if ftype then  
203 - doc[field] = checkType(logType, field, value, ftype) 475 + if not schema[field] then
  476 + printError(string.format("LOG ERROR: logType [%s] have new field [%s], call.", logType, field))
204 else 477 else
205 - printError(string.format("LOG ERROR: logType [%s] have new field [%s] no type in mapping.", logType, field)) 478 + if schema[field] == 'json' then
  479 + value = jsonEncode(value)
  480 + end
  481 + doc[field] = value
  482 + end
  483 + end
  484 +
  485 + for field, tag in pairs(schema) do
  486 + if not contents[field] then
  487 + if tag == "ucode" then
  488 + contents[field] = self:getActionUcode()
  489 + else
  490 + printError(string.format("LOG ERROR: logType [%s] lose field [%s].", logType, field))
  491 + end
206 end 492 end
207 end 493 end
208 if not logd then return end 494 if not logd then return end
209 - pcall(skynet.send, logd, "lua", "log", logType, doc, _logType) 495 + pcall(skynet.send, logd, "lua", "log", doc)
  496 + end
  497 +
  498 + function Role:logItems(itemId, before, after, log)
  499 + if not log then
  500 + print("logItems no log ", debug.traceback())
  501 + end
  502 + local reason = log.desc
  503 + local subreason = log.int1 or 0
  504 + local other = log.int2 or 0
  505 +
  506 + local reasonType = ItemReason[reason]
  507 + if not reasonType then
  508 + printError(string.format("LOG ERROR: onItems no reasonType [%s].", reason))
  509 + end
  510 + local itemData = csvdb["itemCsv"][itemId]
  511 + if not itemData then return end
  512 + self:log("onItems", {
  513 + item_id = itemId, -- 道具id
  514 + item_type = itemData.type, -- 道具类型,具体见枚举表中道具类型枚举表
  515 + item_level = 0, -- 道具等级
  516 + item_number = math.abs(after - before), -- 道具变化数量的绝对值
  517 + action_type = after - before > 0 and 1 or 0, -- 变化类型(玩家获取:1,玩家消耗:0)
  518 + item_before = before, -- 道具变化前的数量
  519 + item_after = after, -- 道具变化后的数量
  520 + item_reason = reasonType, -- 道具流动一级原因,如抽卡、装备强化、副本掉落,可参考道具动作类型枚举表
  521 + item_subreason = subreason, -- 道具流动二级原因,抽卡:卡池ID,装备强化:装备ID,副本掉落:副本ID
  522 + item_other = other, -- 其他(可包含阶数,强化等级,随机属性)
  523 + })
210 end 524 end
211 525
  526 +
212 function Role:startActionUcode() 527 function Role:startActionUcode()
213 if not self._uniqueCount then 528 if not self._uniqueCount then
214 self._uniqueCount = 0 529 self._uniqueCount = 0
@@ -225,7 +540,8 @@ function RoleLog.bind(Role) @@ -225,7 +540,8 @@ function RoleLog.bind(Role)
225 540
226 function Role:getActionUcode() 541 function Role:getActionUcode()
227 return self._actionUcode 542 return self._actionUcode
228 - end 543 + end
  544 +
229 545
230 end 546 end
231 return RoleLog 547 return RoleLog
232 \ No newline at end of file 548 \ No newline at end of file
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()
@@ -144,10 +145,16 @@ function RolePlugin.bind(Role) @@ -144,10 +145,16 @@ function RolePlugin.bind(Role)
144 end 145 end
145 end 146 end
146 end 147 end
147 - 148 + if not next(allChange) then allChange = nil end
148 return reward, allChange --实际获得的奖励 和 最高级奖励转化过程 149 return reward, allChange --实际获得的奖励 和 最高级奖励转化过程
149 end 150 end
150 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 +
151 function Role:awardExpireItem(expireTime, gift, params) 158 function Role:awardExpireItem(expireTime, gift, params)
152 if expireTime <= skynet.timex() then 159 if expireTime <= skynet.timex() then
153 return 160 return
@@ -200,6 +207,7 @@ function RolePlugin.bind(Role) @@ -200,6 +207,7 @@ function RolePlugin.bind(Role)
200 207
201 function Role:addPlayExp(addExp, params) 208 function Role:addPlayExp(addExp, params)
202 local level = self:getProperty("level") 209 local level = self:getProperty("level")
  210 + local oldLevel = level
203 if not csvdb["player_expCsv"][level + 1] then 211 if not csvdb["player_expCsv"][level + 1] then
204 return 212 return
205 end 213 end
@@ -210,24 +218,24 @@ function RolePlugin.bind(Role) @@ -210,24 +218,24 @@ function RolePlugin.bind(Role)
210 if csvdb["player_expCsv"][level + 1] then -- 有下一级 218 if csvdb["player_expCsv"][level + 1] then -- 有下一级
211 newExp = newExp - csvdb["player_expCsv"][level].exp 219 newExp = newExp - csvdb["player_expCsv"][level].exp
212 level = level + 1 220 level = level + 1
  221 + self:checkTaskEnter("RoleLevelUp", {level = level})
213 else 222 else
214 newExp = csvdb["player_expCsv"][level].exp - 1 -- 没有下一级了 经验溢出太多 扣除 223 newExp = csvdb["player_expCsv"][level].exp - 1 -- 没有下一级了 经验溢出太多 扣除
215 end 224 end
216 end 225 end
217 -  
218 - if params.log then  
219 - local log = clone(params.log)  
220 - if log["cint1"] or log["cint2"] then  
221 - print("addPlayExp error log have cint1 or cint2 or cint3", debug.traceback()) 226 + if level > oldLevel then
  227 + if params.log then
  228 + local log = params.log
  229 + self:log("setLevel", {
  230 + level_before = oldLevel,
  231 + level_changemain = log.desc,
  232 + level_changedetail = log.sub,
  233 + level_reward = {},
  234 + })
  235 + else
  236 + print("addPlayExp no log ", debug.traceback())
222 end 237 end
223 -  
224 - log["cint1"] = addExp  
225 - log["cint2"] = newExp  
226 - log["cint3"] = level  
227 -  
228 - self:log("player_exp", log)  
229 - else  
230 - print("addPlayExp no log ", debug.traceback()) 238 +
231 end 239 end
232 240
233 self:updateProperties({level = level, exp = newExp}) 241 self:updateProperties({level = level, exp = newExp})
@@ -250,21 +258,7 @@ function RolePlugin.bind(Role) @@ -250,21 +258,7 @@ function RolePlugin.bind(Role)
250 items = items:incrv(params.itemId, params.count) 258 items = items:incrv(params.itemId, params.count)
251 end 259 end
252 260
253 - if params.log then  
254 - local log = clone(params.log)  
255 - if log["cint1"] or log["cint2"] then  
256 - print("addItem error log have cint1 or cint2 ", debug.traceback())  
257 - end  
258 - log["cint1"] = params.itemId  
259 - log["cint2"] = math.abs(params.count)  
260 - if params.count <= 0 then  
261 - self:log("out_item", log)  
262 - else  
263 - self:log("in_item", log)  
264 - end  
265 - else  
266 - print("addItem no log ", debug.traceback())  
267 - end 261 + self:logItems(params.itemId, origin, nums, params.log)
268 262
269 self:setProperty("items", items) 263 self:setProperty("items", items)
270 if not params.notNotify then 264 if not params.notNotify then
@@ -334,22 +328,12 @@ function RolePlugin.bind(Role) @@ -334,22 +328,12 @@ function RolePlugin.bind(Role)
334 self:incrProperty("diamond", count) 328 self:incrProperty("diamond", count)
335 end 329 end
336 330
337 - if params.log then  
338 - local log = clone(params.log)  
339 - if log["cint1"] or log["cint2"] or log["cint3"] then  
340 - print("costDiamond error log have cint1 or cint2 or cint3 ", debug.traceback())  
341 - end  
342 - log["cint1"] = origin  
343 - log["cint2"] = count  
344 - self:log("in_diamond", log)  
345 - else  
346 - print("gainDiamond no log ", debug.traceback())  
347 - end  
348 - 331 + self:logItems(ItemId.Diamond, origin, count, params.log)
349 self:notifyUpdateProperty("diamond", self:getAllDiamond()) 332 self:notifyUpdateProperty("diamond", self:getAllDiamond())
350 return true 333 return true
351 end 334 end
352 335
  336 +
353 function Role:costDiamond(params) 337 function Role:costDiamond(params)
354 if not params or type(params) ~= "table" then return false end 338 if not params or type(params) ~= "table" then return false end
355 local count = tonum(params.count) 339 local count = tonum(params.count)
@@ -382,17 +366,8 @@ function RolePlugin.bind(Role) @@ -382,17 +366,8 @@ function RolePlugin.bind(Role)
382 self:incrProperty(costFirst[2], -last) 366 self:incrProperty(costFirst[2], -last)
383 end 367 end
384 368
385 - if params.log then  
386 - local log = clone(params.log)  
387 - if log["cint1"] or log["cint2"] or log["cint3"] then  
388 - print("costDiamond error log have cint1 or cint2 or cint3 ", debug.traceback())  
389 - end  
390 - log["cint1"] = origin  
391 - log["cint2"] = count  
392 - self:log("out_diamond", log)  
393 - else  
394 - print("costDiamond no log ", debug.traceback())  
395 - end 369 +
  370 + self:logItems(ItemId.Diamond, origin, count, params.log)
396 371
397 self:notifyUpdateProperty("diamond", self:getAllDiamond()) 372 self:notifyUpdateProperty("diamond", self:getAllDiamond())
398 return true 373 return true
@@ -428,17 +403,9 @@ function RolePlugin.bind(Role) @@ -428,17 +403,9 @@ function RolePlugin.bind(Role)
428 local bin = MsgPack.pack(heroResponse) 403 local bin = MsgPack.pack(heroResponse)
429 SendPacket(actionCodes.Hero_loadInfos, bin) 404 SendPacket(actionCodes.Hero_loadInfos, bin)
430 end 405 end
431 - if params.log then  
432 - local log = clone(params.log)  
433 - if log["cint1"] or log["cint2"] or log["cint3"] then  
434 - print("addHero error log have cint1 or cint2 or cint3 ", debug.traceback())  
435 - end  
436 - log["cint1"] = heroId  
437 - log["cint2"] = heroType  
438 - self:log("in_hero", log)  
439 - else  
440 - print("addHero no log ", debug.traceback())  
441 - end 406 +
  407 + self:logItems(heroType + ItemStartId.Hero, 0, 1, params.log)
  408 +
442 return true, newHero 409 return true, newHero
443 end 410 end
444 411
@@ -451,33 +418,6 @@ function RolePlugin.bind(Role) @@ -451,33 +418,6 @@ function RolePlugin.bind(Role)
451 end 418 end
452 end 419 end
453 420
454 - function Role:delHero(heroId, params)  
455 - params = params or {}  
456 - local roleId = self:getProperty('id')  
457 - local hero = self.heros[heroId]  
458 - local heroType = hero:getProperty("type")  
459 - if not hero then return end  
460 -  
461 - self.heros[heroId] = nil  
462 - redisproxy:pipelining(function (red)  
463 - red:del(string.format(R_HERO, roleId, heroId))  
464 - red:srem(string.format(R_HEROS, roleId), heroId)  
465 - end)  
466 -  
467 - if params.log then  
468 - local log = clone(params.log)  
469 - if log["cint1"] or log["cint2"] or log["cint3"] then  
470 - print("delHero error log have cint1 or cint2 or cint3 ", debug.traceback())  
471 - end  
472 - log["cint1"] = heroId  
473 - log["cint2"] = heroType  
474 - self:log("out_hero", log)  
475 - else  
476 - print("delHero no log ", debug.traceback())  
477 - end  
478 -  
479 - SendPacket(actionCodes.Hero_loadInfos, MsgPack.pack({{id = heroId, bDel = true}}))  
480 - end  
481 421
482 function Role:loadHeros() 422 function Role:loadHeros()
483 local roleId = self:getProperty("id") 423 local roleId = self:getProperty("id")
@@ -537,6 +477,18 @@ function RolePlugin.bind(Role) @@ -537,6 +477,18 @@ function RolePlugin.bind(Role)
537 -- 放role 里面了 477 -- 放role 里面了
538 end 478 end
539 479
  480 + function Role:loadStoreInfo()
  481 + local roleId = self:getProperty("id")
  482 + local dataKey = string.format(R_STORE, roleId)
  483 + self.storeData = require("models.Store").new({key = dataKey})
  484 + self.storeData.owner = self
  485 + if not redisproxy:exists(dataKey) then
  486 + self.storeData:create()
  487 + else
  488 + self.storeData:load()
  489 + end
  490 + end
  491 +
540 function Role:addEquip(equipType, equipLv, count, pms) 492 function Role:addEquip(equipType, equipLv, count, pms)
541 pms = pms or {} 493 pms = pms or {}
542 if count ~= count then return end 494 if count ~= count then return end
@@ -544,7 +496,8 @@ function RolePlugin.bind(Role) @@ -544,7 +496,8 @@ function RolePlugin.bind(Role)
544 if not equipCsv then return end 496 if not equipCsv then return end
545 local equips = self:getProperty("equips") 497 local equips = self:getProperty("equips")
546 local curTypeEquips = equips[equipType] or {} 498 local curTypeEquips = equips[equipType] or {}
547 - local curCount = (curTypeEquips[equipLv] or 0) + count 499 + local oldCount = curTypeEquips[equipLv] or 0
  500 + local curCount = oldCount + count
548 501
549 -- 是否足够上层判断 502 -- 是否足够上层判断
550 if curCount < 0 then 503 if curCount < 0 then
@@ -562,22 +515,7 @@ function RolePlugin.bind(Role) @@ -562,22 +515,7 @@ function RolePlugin.bind(Role)
562 515
563 self:setProperty("equips", equips) 516 self:setProperty("equips", equips)
564 517
565 - if pms.log then  
566 - local log = clone(pms.log)  
567 - if log["cint1"] or log["cint2"] or log["cint3"] then  
568 - print("addEquip error log have cint1 or cint2 or cint3 ", debug.traceback())  
569 - end  
570 - log["cint1"] = equipType  
571 - log["cint2"] = equipLv  
572 - log["cint3"] = math.abs(count)  
573 - if count < 0 then  
574 - self:log("out_equip", log)  
575 - else  
576 - self:log("in_equip", log)  
577 - end  
578 - else  
579 - print("addEquip no log ", debug.traceback())  
580 - end 518 + self:logItems(equipCsv.id, oldCount, curCount, pms.log)
581 519
582 if not pms.notNotify then 520 if not pms.notNotify then
583 self:changeUpdates({{type = "equips", field = {equipType, equipLv}, value = curCount, isOnlyToC = true}}) -- 通知客户端 521 self:changeUpdates({{type = "equips", field = {equipType, equipLv}, value = curCount, isOnlyToC = true}}) -- 通知客户端
@@ -637,20 +575,7 @@ function RolePlugin.bind(Role) @@ -637,20 +575,7 @@ function RolePlugin.bind(Role)
637 end 575 end
638 self:checkTaskEnter("AddRune", {id = params.id, type = params.type, rarity = data.rarity}, params.notNotify) 576 self:checkTaskEnter("AddRune", {id = params.id, type = params.type, rarity = data.rarity}, params.notNotify)
639 577
640 - if params.log then  
641 - local log = clone(params.log)  
642 - if log["cint1"] or log["cint2"] or log["cint3"] then  
643 - print("addRune error log have cint1 or cint2 or cint3 ", debug.traceback())  
644 - end  
645 -  
646 - log["cint1"] = runeUid  
647 - log["cint2"] = params.type  
648 - log["cint3"] = params.id  
649 -  
650 - self:log("in_rune", log)  
651 - else  
652 - print("addRune no log ", debug.traceback())  
653 - end 578 + self:logItems(params.id, 0, 1, params.log)
654 579
655 return 0, newRune 580 return 0, newRune
656 else 581 else
@@ -666,20 +591,7 @@ function RolePlugin.bind(Role) @@ -666,20 +591,7 @@ function RolePlugin.bind(Role)
666 local rune = self.runeBag[runeId] 591 local rune = self.runeBag[runeId]
667 if rune and rune:getProperty("refer") == 0 then 592 if rune and rune:getProperty("refer") == 0 then
668 593
669 - if params.log then  
670 - local log = clone(params.log)  
671 - if log["cint1"] or log["cint2"] or log["cint3"] then  
672 - print("delRunes error log have cint1 or cint2 or cint3 ", debug.traceback())  
673 - end  
674 -  
675 - log["cint1"] = runeId  
676 - log["cint2"] = rune:getProperty("type")  
677 - log["cint3"] = rune:getProperty("id")  
678 -  
679 - self:log("out_rune", log)  
680 - else  
681 - print("delRunes no log ", debug.traceback())  
682 - end 594 + self:logItems(rune:getProperty("id"), 1, 0, params.log)
683 595
684 self.runeBag[runeId] = nil 596 self.runeBag[runeId] = nil
685 table.insert(bDel, runeId) 597 table.insert(bDel, runeId)
@@ -925,19 +837,7 @@ function RolePlugin.bind(Role) @@ -925,19 +837,7 @@ function RolePlugin.bind(Role)
925 837
926 count = count or 1 838 count = count or 1
927 839
928 - if params.log then  
929 - local log = clone(params.log)  
930 - if log["cint1"] or log["cint2"] or log["cint3"] then  
931 - print("funcOpen error log have cint1 or cint2 or cint3 ", debug.traceback())  
932 - end  
933 -  
934 - log["cint1"] = func  
935 - log["cint2"] = count  
936 -  
937 - self:log("func_open", log)  
938 - else  
939 - print("funcOpen no log ", debug.traceback())  
940 - end 840 + self:logItems(func, 0, count, params.log)
941 841
942 if csvdb["itemCsv"][func] and csvdb["itemCsv"][func].type == ItemType.FuncOpen then 842 if csvdb["itemCsv"][func] and csvdb["itemCsv"][func].type == ItemType.FuncOpen then
943 local unlockData = csvdb["unlockCsv"][func] 843 local unlockData = csvdb["unlockCsv"][func]
@@ -1324,9 +1224,13 @@ function RolePlugin.bind(Role) @@ -1324,9 +1224,13 @@ function RolePlugin.bind(Role)
1324 self:checkNewEvent(now) 1224 self:checkNewEvent(now)
1325 end 1225 end
1326 1226
1327 - local function breath(sec) 1227 + local function breath(sec, name)
1328 local last_breath = 0 1228 local last_breath = 0
1329 - return function (now) 1229 + return function (now, role)
  1230 + if name == "email" and role.sendMailFlag then
  1231 + last_breath = now + sec
  1232 + return true
  1233 + end
1330 if now >= last_breath then 1234 if now >= last_breath then
1331 last_breath = now + sec 1235 last_breath = now + sec
1332 return true 1236 return true
@@ -1335,8 +1239,8 @@ function RolePlugin.bind(Role) @@ -1335,8 +1239,8 @@ function RolePlugin.bind(Role)
1335 end 1239 end
1336 end 1240 end
1337 local breathes = { 1241 local breathes = {
1338 - ["email"] = breath(120), -- email  
1339 - ["pvphg"] = breath(300), -- 高级竞技场 奖励满的红点 1242 + ["email"] = breath(120, "email"), -- email
  1243 + ["pvphg"] = breath(300, "pvphg"), -- 高级竞技场 奖励满的红点
1340 } 1244 }
1341 function Role:checkNewEvent(now) 1245 function Role:checkNewEvent(now)
1342 if now - self:getProperty("ltime") < 5 then 1246 if now - self:getProperty("ltime") < 5 then
@@ -1377,6 +1281,8 @@ function RolePlugin.bind(Role) @@ -1377,6 +1281,8 @@ function RolePlugin.bind(Role)
1377 red:hget(string.format(R_EMAIL_ITEM, roleId, id), "status") 1281 red:hget(string.format(R_EMAIL_ITEM, roleId, id), "status")
1378 end 1282 end
1379 end) 1283 end)
  1284 +
  1285 + self.SendMailFlag = false
1380 for index, id in ipairs(emailIds) do 1286 for index, id in ipairs(emailIds) do
1381 if tonumber(redret[index]) == 0 then 1287 if tonumber(redret[index]) == 0 then
1382 return true 1288 return true
@@ -1401,7 +1307,7 @@ function RolePlugin.bind(Role) @@ -1401,7 +1307,7 @@ function RolePlugin.bind(Role)
1401 1307
1402 local events = {} 1308 local events = {}
1403 for name, breath in pairs(breathes) do 1309 for name, breath in pairs(breathes) do
1404 - if breath(now) and checks[name] then 1310 + if breath(now, self) and checks[name] then
1405 local status = checks[name]() 1311 local status = checks[name]()
1406 if status then 1312 if status then
1407 if status == true then 1313 if status == true then
@@ -1442,15 +1348,6 @@ function RolePlugin.bind(Role) @@ -1442,15 +1348,6 @@ function RolePlugin.bind(Role)
1442 return RANK_ADV[idx] 1348 return RANK_ADV[idx]
1443 end 1349 end
1444 1350
1445 - -- 是否需要进行引导  
1446 - function Role:checkOverGuide(guideId)  
1447 - local funcGuide = self:getProperty("funcGuide")  
1448 - if funcGuide:getv(guideId, 0) > 0 then  
1449 - return true  
1450 - end  
1451 - return false  
1452 - end  
1453 -  
1454 -- 消除指定tag 红点 1351 -- 消除指定tag 红点
1455 function Role:clearRedPTag(tag) 1352 function Role:clearRedPTag(tag)
1456 local redp = self:getProperty("redp") 1353 local redp = self:getProperty("redp")
@@ -1485,8 +1382,8 @@ function RolePlugin.bind(Role) @@ -1485,8 +1382,8 @@ function RolePlugin.bind(Role)
1485 SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ result = "handled" })) 1382 SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ result = "handled" }))
1486 return 1383 return
1487 end 1384 end
1488 -  
1489 - local rechargeData = csvdb["shop_rechargeCsv"][orderObject:getProperty("rechargeId")] 1385 + local rechargeId = orderObject:getProperty("rechargeId")
  1386 + local rechargeData = csvdb["shop_rechargeCsv"][rechargeId]
1490 if rechargeData.rmb ~= tonumber(params.amount) then 1387 if rechargeData.rmb ~= tonumber(params.amount) then
1491 skynet.error(string.format("fake order: %s, roleId: %d, order: %s, rmb %s, get %s", 1388 skynet.error(string.format("fake order: %s, roleId: %d, order: %s, rmb %s, get %s",
1492 params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount 1389 params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount
@@ -1494,18 +1391,36 @@ function RolePlugin.bind(Role) @@ -1494,18 +1391,36 @@ function RolePlugin.bind(Role)
1494 return 1391 return
1495 end 1392 end
1496 1393
1497 - local diamond = self:recharge({  
1498 - id = orderObject:getProperty("rechargeId"),  
1499 - transactionId = params.transactionId,  
1500 - pay_time = params.pay_time,  
1501 - order = partnerOrderStr 1394 + local order_type = self:getProperty("rmbC") > 0 and 0 or 1
  1395 + local status, reward = self:recharge({
  1396 + id = rechargeId
1502 }) 1397 })
1503 orderObject:setProperty("finishTime", skynet.time()) 1398 orderObject:setProperty("finishTime", skynet.time())
1504 orderObject:setProperty("status", "finish") 1399 orderObject:setProperty("status", "finish")
1505 1400
1506 redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr) 1401 redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr)
  1402 +
  1403 + if not status then
  1404 + status = 200
  1405 + else
  1406 + status = 1000 + status
  1407 + end
  1408 + self:log("setOrder", {
  1409 + order_status = status, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他"
  1410 + item_id = rechargeId, -- 道具id
  1411 + item_type = rechargeData.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表
  1412 + item_name = rechargeData.title, -- 购买的道具名
  1413 + item_number = 1, -- 购买的道具数量
  1414 + item_level = 1, -- 购买的道具等级
  1415 + order_cost = rechargeData.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee'
  1416 + order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范
  1417 + order_type = order_type, -- 订单类型,首充记录为1,否则为0
  1418 + order_id = params.transactionId, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no'
  1419 + })
  1420 + if status ~= 200 then return end
  1421 +
1507 SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr, 1422 SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr,
1508 - result = "success", diamond = diamond})) 1423 + result = "success", reward = reward}))
1509 1424
1510 return orderObject:getProperty("rechargeId") 1425 return orderObject:getProperty("rechargeId")
1511 end 1426 end
@@ -1516,11 +1431,16 @@ function RolePlugin.bind(Role) @@ -1516,11 +1431,16 @@ function RolePlugin.bind(Role)
1516 local rechargeData = csvdb["shop_rechargeCsv"][id] 1431 local rechargeData = csvdb["shop_rechargeCsv"][id]
1517 if not rechargeData then 1432 if not rechargeData then
1518 skynet.error("recharge id not exist", id) 1433 skynet.error("recharge id not exist", id)
1519 - return 1434 + return 1
  1435 + end
  1436 +
  1437 + if not self.storeData:checkRechargeRecord(rechargeData.limit, id) then
  1438 + return 2
1520 end 1439 end
1521 1440
1522 local diamondCount = 0 1441 local diamondCount = 0
1523 - if rechargeData.type == 0 then -- 钻石 1442 + local reward = {}
  1443 + if rechargeData.shop == 1 then -- 钻石
1524 local rechargeF = self:getProperty("rechargeF") 1444 local rechargeF = self:getProperty("rechargeF")
1525 diamondCount = rechargeData.diamond + rechargeData.diamondExtra 1445 diamondCount = rechargeData.diamond + rechargeData.diamondExtra
1526 if not rechargeF[id] then 1446 if not rechargeF[id] then
@@ -1529,23 +1449,89 @@ function RolePlugin.bind(Role) @@ -1529,23 +1449,89 @@ function RolePlugin.bind(Role)
1529 self:updateProperty({field = "rechargeF", value = rechargeF}) 1449 self:updateProperty({field = "rechargeF", value = rechargeF})
1530 end 1450 end
1531 self:gainDiamond({count = diamondCount, isRecharge = true, log = {desc = "recharge", int1 = id}}) 1451 self:gainDiamond({count = diamondCount, isRecharge = true, log = {desc = "recharge", int1 = id}})
1532 - elseif rechargeData.type == 1 then --月卡  
1533 - return  
1534 - elseif rechargeData.type == 2 then -- 赛季通行证  
1535 - return 1452 + elseif rechargeData.shop == 2 then --通行证商店
  1453 + reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}})
  1454 + self.storeData:onBuyCard(rechargeData.type, rechargeData.time)
  1455 + elseif rechargeData.shop == 3 then -- 礼包商店
  1456 + reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}})
1536 else 1457 else
1537 - return 1458 + skynet.error("invalid recharge shop type " .. id)
  1459 + return 3
  1460 + end
  1461 +
  1462 + if diamondCount > 0 then
  1463 + reward[ItemId.Diamond] = (reward[ItemId.Diamond] or 0) + diamondCount
1538 end 1464 end
1539 1465
1540 -- 累充 1466 -- 累充
1541 local rmb = rechargeData.rmb 1467 local rmb = rechargeData.rmb
1542 self:updateProperty({field = "rmbC", delta = rmb}) 1468 self:updateProperty({field = "rmbC", delta = rmb})
1543 -  
1544 - self:log("role_action", {desc = "recharge", int1 = id, int2 = rmb, key1 = params.transactionId, key2 = params.order, long1 = params.pay_time})  
1545 1469
1546 - return diamondCount 1470 + return nil, reward
  1471 + end
  1472 +
  1473 + --直接给玩家发送邮件,立即推送小红点
  1474 + function Role:sendMail(mailId, createTime, reward, contentPms)
  1475 + local tgift = {}
  1476 + if type(reward) == "string" then
  1477 + for _, one in pairs(reward:toTableArray(true)) do
  1478 + tgift[one[1]] = (tgift[one[1]] or 0) + one[2]
  1479 + end
  1480 + else
  1481 + tgift = reward or {}
  1482 + end
  1483 + local gift = ""
  1484 + for k, v in pairs(tgift) do
  1485 + gift = gift .. k.."="..v.." "
  1486 + end
  1487 + redisproxy:insertEmail({roleId = self:getProperty("id"), emailId = mailId, createtime = createTime, attachments = gift, contentPms = contentPms})
  1488 + self.sendMailFlag = true
  1489 + end
  1490 +
  1491 + -- 是否需要进行引导
  1492 + function Role:checkOverGuide(guideId,slave)
  1493 + local funcGuide = self:getProperty("funcGuide")
  1494 + if funcGuide:getv(guideId * 1000 + (slave or 0), 0) > 0 then
  1495 + return true
  1496 + end
  1497 + return false
  1498 + end
  1499 +
  1500 + -- 保存引导步骤
  1501 + function Role:saveGuide(master,slave,force)
  1502 + local newerGuide = self:getProperty("newerGuide")
  1503 + local guide = newerGuide:toArray(true,"=")
  1504 + local sMaster, sSlave = guide[1], guide[2]
  1505 +
  1506 + if not force and master < sMaster then return end
  1507 + if not force and master <= sMaster and slave < sSlave then return end
  1508 +
  1509 + local funcGuide = self:getProperty("funcGuide")
  1510 + funcGuide = funcGuide:setv(master * 1000 + slave, 1)
  1511 + if funcGuide:getv(master * 1000,0) == 0 then
  1512 + funcGuide = funcGuide:setv(master * 1000, 1)
  1513 + end
  1514 + self:updateProperty({field = "funcGuide", value = funcGuide})
  1515 + self:log("onGuidePoint", {guild_type = 0, guild_id = master, guild_point = slave, guild_pass = 0})
  1516 +
  1517 + newerGuide = string.format("%d=%d",master,slave)
  1518 + self:updateProperty({field = "newerGuide", value = newerGuide})
1547 end 1519 end
1548 1520
  1521 + -- 引导大步骤结束
  1522 + function Role:finishGuide(master)
  1523 + local newerGuide = self:getProperty("newerGuide")
  1524 + local guide = newerGuide:toArray(true,"=")
  1525 + if guide[1] > master then return end
  1526 +
  1527 + local guideCsv = csvdb["guide_mainCsv"]
  1528 + local lastStep = guideCsv[master][#guideCsv[master]]
  1529 + if guideCsv[master + 1] then
  1530 + self:updateProperty({field = "newerGuide", value = string.format("%d=%d",master + 1,1)})
  1531 + else
  1532 + self:updateProperty({field = "newerGuide", value = "9999=1"})
  1533 + end
  1534 + end
1549 end 1535 end
1550 1536
1551 return RolePlugin 1537 return RolePlugin
1552 \ No newline at end of file 1538 \ No newline at end of file
src/models/RolePvp.lua
@@ -500,7 +500,7 @@ function Role:setCrossServerPvpBet(idx) @@ -500,7 +500,7 @@ function Role:setCrossServerPvpBet(idx)
500 local ok, result = pcall(skynet.call, pvpd, "lua", "setBet", idx, self:getProperty("id"), costNum) 500 local ok, result = pcall(skynet.call, pvpd, "lua", "setBet", idx, self:getProperty("id"), costNum)
501 if ok then 501 if ok then
502 if result then 502 if result then
503 - self:costItems(cost, {log = {desc = "crossPvpBet", short1 = day}}) 503 + self:costItems(cost, {log = {desc = "crossPvpBet", int1 = day}})
504 pvpBet[day] = {idx, cost[ItemId.Gold]} 504 pvpBet[day] = {idx, cost[ItemId.Gold]}
505 self:setProperty("pvpBet", pvpBet) 505 self:setProperty("pvpBet", pvpBet)
506 end 506 end
src/models/RoleTask.lua
@@ -76,6 +76,9 @@ local TaskType = { @@ -76,6 +76,9 @@ local TaskType = {
76 AddFriend = 802, -- 加入一个好友 - count 76 AddFriend = 802, -- 加入一个好友 - count
77 GetFriendP = 803, -- 获得友情点 - count 77 GetFriendP = 803, -- 获得友情点 - count
78 78
  79 + -- 角色相关
  80 + RoleLevelUp = 901, -- 角色升级 - curlevel
  81 +
79 --功能未实现 todo 82 --功能未实现 todo
80 AdvShop = 1002, -- 冒险商城 83 AdvShop = 1002, -- 冒险商城
81 UnionBoss = 1004, -- 工会boss 84 UnionBoss = 1004, -- 工会boss
@@ -205,10 +208,23 @@ local SudokuListener = { @@ -205,10 +208,23 @@ local SudokuListener = {
205 } 208 }
206 } 209 }
207 210
  211 +local Activity = require("models.Activity")
208 local ActivityListener = { 212 local ActivityListener = {
209 func = "checkActivityTask", 213 func = "checkActivityTask",
210 - listener = { 214 + listen = {
  215 + [TaskType.DrawHero] = {{Activity.ActivityType.DrawHero, f("count"), f("pool")}},
  216 + [TaskType.FoodSell] = {{Activity.ActivityType.FoodSell, f("count")}},
  217 + [TaskType.AdvDraw] = {{Activity.ActivityType.AdvDraw, f("count")}},
  218 + [TaskType.OpenBox] = {{Activity.ActivityType.OpenBox, f("count")}},
  219 + }
  220 +}
211 221
  222 +local StoreListener = {
  223 + func = "checkStoreTask",
  224 + listen = {
  225 + [TaskType.HangPass] = {{TriggerEventType.HangPass, f("id")}},
  226 + [TaskType.RoleLevelUp] = {{TriggerEventType.LevelUp, f("level")}},
  227 + [TaskType.TowerPass] = {{TriggerEventType.TowerPass, f("level")}},
212 } 228 }
213 } 229 }
214 230
@@ -219,6 +235,7 @@ local TaskListeners = { @@ -219,6 +235,7 @@ local TaskListeners = {
219 AchievListener, 235 AchievListener,
220 SudokuListener, 236 SudokuListener,
221 ActivityListener, 237 ActivityListener,
  238 + StoreListener,
222 } 239 }
223 240
224 local RoleTask = {} 241 local RoleTask = {}
@@ -529,6 +546,10 @@ function RoleTask.bind(Role) @@ -529,6 +546,10 @@ function RoleTask.bind(Role)
529 self.activity:checkActivity(notNotify, activityType, ...) 546 self.activity:checkActivity(notNotify, activityType, ...)
530 end 547 end
531 548
  549 + function Role:checkStoreTask(notNotify, triggerType, param)
  550 + self.storeData:OnTriggerLimitTimePack(triggerType, param)
  551 + end
  552 +
532 end 553 end
533 554
534 return RoleTask 555 return RoleTask
535 \ No newline at end of file 556 \ No newline at end of file
src/models/RoleTimeReset.lua
@@ -10,8 +10,10 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response, now) @@ -10,8 +10,10 @@ 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", {})
  16 + self:incrProperty("lday", 1)
15 self:advRandomSupportEffect(not notify) 17 self:advRandomSupportEffect(not notify)
16 18
17 self:checkExpireItem(not notify) 19 self:checkExpireItem(not notify)
@@ -29,6 +31,14 @@ ResetFunc[&quot;CrossWeek&quot;] = function(self, notify, response) @@ -29,6 +31,14 @@ ResetFunc[&quot;CrossWeek&quot;] = function(self, notify, response)
29 response.dinerS = {} 31 response.dinerS = {}
30 end 32 end
31 33
  34 +ResetFunc["CrossMonth"] = function(self, notify, response)
  35 + local ltime = self:getProperty("ltime")
  36 + if isCrossMonth(ltime, skynet.timex()) then
  37 + print("cross month")
  38 + self.storeData:resetStoreReored(3) --商店跨月重置 time_reset表关联id
  39 + end
  40 +end
  41 +
32 42
33 ResetFunc["DinerRank"] = function(self, notify, response) 43 ResetFunc["DinerRank"] = function(self, notify, response)
34 self.dinerData:rankResetData(notify) 44 self.dinerData:rankResetData(notify)
@@ -51,9 +61,11 @@ function Role:updateTimeReset(now, notify) @@ -51,9 +61,11 @@ function Role:updateTimeReset(now, notify)
51 61
52 local needResetId = {} 62 local needResetId = {}
53 for resetId, resetData in pairs(csvdb["time_resetCsv"]) do 63 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 64 + if resetData.interval > 0 then
  65 + local curRound = math.floor((passTime - resetData.start) / resetData.interval)
  66 + if not timeReset[resetId] or curRound ~= timeReset[resetId] then
  67 + needResetId[resetId] = curRound
  68 + end
57 end 69 end
58 end 70 end
59 if not next(needResetId) then return end 71 if not next(needResetId) then return end
@@ -66,13 +78,19 @@ function Role:updateTimeReset(now, notify) @@ -66,13 +78,19 @@ function Role:updateTimeReset(now, notify)
66 ResetFunc[funcName](self, notify, response, now) 78 ResetFunc[funcName](self, notify, response, now)
67 resetMode[funcName] = true 79 resetMode[funcName] = true
68 end 80 end
  81 + if needResetId[resetId] then
  82 + -- 充值商城购买记录
  83 + self.storeData:resetStoreReored(resetId)
  84 + end
69 end 85 end
70 86
71 for resetId, round in pairs(needResetId) do 87 for resetId, round in pairs(needResetId) do
72 timeReset[resetId] = round 88 timeReset[resetId] = round
73 end 89 end
74 - self:setProperty("timeReset", timeReset) 90 + self:setProperties({timeReset = timeReset, ltime = now})
  91 +
75 response.timeReset = timeReset 92 response.timeReset = timeReset
  93 + response.ltime = ltime
76 94
77 if notify then 95 if notify then
78 self:notifyUpdateProperties(response) 96 self:notifyUpdateProperties(response)
src/models/Store.lua 0 → 100644
@@ -0,0 +1,349 @@ @@ -0,0 +1,349 @@
  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 + packTrigger = {"table", {}} -- 礼包触发记录 {关卡难度1={id, 通关关卡数,升级数,爬塔层数}, ...}
  24 +}
  25 +
  26 +function Store:updateProperty(params)
  27 + params = params or {}
  28 + if not self.schema[params.field] then
  29 + return
  30 + end
  31 + local oldValue = self:getProperty(params.field)
  32 + if params.value then
  33 + self:setProperty(params.field, params.value)
  34 + elseif params.delta then
  35 + self:incrProperty(params.field, params.delta)
  36 + else
  37 + return
  38 + end
  39 + local newValue = self:getProperty(params.field)
  40 + if not params.notNotify then
  41 + self:notifyUpdateProperty(params.field, newValue, oldValue)
  42 + end
  43 +end
  44 +
  45 +function Store:onCrossDay()
  46 + self:sendMonthCardEmail()
  47 + self:deleteExpireLimitGoods()
  48 +end
  49 +
  50 +-- 删除过期商品
  51 +function Store:deleteExpireLimitGoods()
  52 + local timeNow = skynet.timex()
  53 + local limitGoodsList = self:getProperty("limitTPack")
  54 + for k, v in pairs(limitGoodsList) do
  55 + if timeNow > v then
  56 + limitGoodsList[k] = nil
  57 + end
  58 + end
  59 +end
  60 +
  61 +-- 发送月卡邮件
  62 +function Store:sendMonthCardEmail()
  63 + local timeNow = skynet.timex()
  64 + local tabs = {{ex="monthCardEx", t="getMailT1", mail=MailId.MonthCard, alert=MailId.MonthCardEx},
  65 + {ex="smonthCardEx", t="getMailT2", mail=MailId.SuperMonthCard, alert=MailId.SuperMonthCardEx}}
  66 + for _, v in ipairs(tabs) do
  67 + local ex = self:getProperty(v.ex)
  68 + local ts = self:getProperty(v.t) or 0
  69 + local mailId = v.mail
  70 + local alertId = v.alert
  71 + local alertTs = dayLater(ex) - DAY_SEC
  72 + if ex > timeNow then
  73 + local cnt = 0
  74 + if ts == 0 then
  75 + cnt = 1
  76 + else
  77 + local diff = math.floor((dayLater(timeNow) - dayLater(ts))/DAY_SEC)
  78 + diff = diff < 0 and 0 or diff
  79 + diff = diff > 31 and 31 or diff
  80 + cnt = diff
  81 + end
  82 + for i = cnt - 1, 0, -1 do
  83 + local createTs = timeNow - i * DAY_SEC
  84 + self.owner:sendMail(mailId, createTs)
  85 + -- 过期头一天发提醒邮件
  86 + if dayLater(createTs) == alertTs then
  87 + self.owner:sendMail(alertId, createTs)
  88 + end
  89 + end
  90 + if cnt > 0 then
  91 + self:updateProperty({field=v.t, value=timeNow})
  92 + end
  93 + end
  94 + end
  95 +end
  96 +
  97 +function Store:isMonthCardExpire()
  98 + local timeNow = skynet.timex()
  99 + local ts = self:getProperty("monthCardEx")
  100 + return ts < timeNow
  101 +end
  102 +
  103 +function Store:isSuperMonthCardExpire()
  104 + local timeNow = skynet.timex()
  105 + local ts = self:getProperty("smonthCardEx")
  106 + return ts < timeNow
  107 +end
  108 +
  109 +function Store:isPrivCardExpire()
  110 + local timeNow = skynet.timex()
  111 + local ts = self:getProperty("privCardEx")
  112 + return ts < timeNow
  113 +end
  114 +
  115 +-- 挂机栏位 特权卡额外个数
  116 +function Store:getHangSlotExtraCount()
  117 + if self:isPrivCardExpire() then
  118 + return 0
  119 + end
  120 +
  121 + return globalCsv.shop_priv_card_hang_slot_cnt or 4
  122 +end
  123 +
  124 +-- 探索加速/餐厅加速 特权卡系数
  125 +function Store:getProduceItemSpeedCoef()
  126 + if self:isPrivCardExpire() then
  127 + return 1
  128 + end
  129 + local coef = (globalCsv.shop_priv_card_produce_coef or 25)/ 100
  130 + return 1 + coef
  131 +end
  132 +
  133 +-- 拆解室栏位 特权卡额外个数
  134 +function Store:getTimeBoxSlotExtraCount()
  135 + if self:isPrivCardExpire() then
  136 + return 0
  137 + end
  138 +
  139 + return globalCsv.shop_priv_time_box_slot_cnt or 3
  140 +end
  141 +
  142 +-- 齿轮兑换 特权卡系数
  143 +function Store:getGearExchangeCoef()
  144 + if self:isPrivCardExpire() then
  145 + return 1
  146 + end
  147 +
  148 + local coef = (globalCsv.shop_priv_exchange_gear_coef or 50)/ 100
  149 + return 1 + coef
  150 +end
  151 +
  152 +-- 购买通行证
  153 +function Store:onBuyCard(type, duration)
  154 + local timeNow = skynet.timex()
  155 + if type == CardType.NormalMonthCard then
  156 + if self:isMonthCardExpire() then
  157 + self:updateProperty({field = "monthCardEx", value = timeNow + duration})
  158 + else
  159 + self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration})
  160 + end
  161 + self:sendMonthCardEmail()
  162 + elseif type == CardType.SuperMonthCard then
  163 + if self:isSuperMonthCardExpire() then
  164 + self:updateProperty({field = "smonthCardEx", value = timeNow + duration})
  165 + else
  166 + self:updateProperty({field = "smonthCardEx", value = self:getProperty("smonthCardEx") + duration})
  167 + end
  168 + self:sendMonthCardEmail()
  169 + elseif type == CardType.PrivilegeCard then
  170 + if self:isPrivCardExpire() then
  171 + self:updateProperty({field = "privCardEx", value = timeNow + duration})
  172 + else
  173 + self:updateProperty({field = "privCardEx", value = self:getProperty("privCardEx") + duration})
  174 + end
  175 + elseif type == CardType.GrowFund then
  176 + self:updateProperty({field = "growFund", value = 1})
  177 + elseif type == CardType.BattleCard then
  178 + self:updateProperty({field = "battleCard", value = 1})
  179 + end
  180 +end
  181 +
  182 +--检测购买是否超过限制数量
  183 +function Store:checkRechargeRecord(limit, id)
  184 + local rechargeRecord = self:getProperty("payR")
  185 + if limit ~= 0 and limit <= (rechargeRecord[id] or 0) then
  186 + skynet.error(string.format("recharge id:%d count over limit, user id:%d", id, self.owner:getProperty("id")))
  187 + return false
  188 + end
  189 + rechargeRecord[id] = (rechargeRecord[id] or 0) + 1
  190 + self:updateProperty({field = "payR", value = rechargeRecord})
  191 + return true
  192 +end
  193 +
  194 +function Store:notifyUpdateProperty(field, newValue, oldValue)
  195 + local datas = {
  196 + key = field,
  197 + newValue = newValue,
  198 + oldValue = oldValue,
  199 + }
  200 + SendPacket(actionCodes.Store_updateproperty, MsgPack.pack(datas))
  201 +end
  202 +
  203 +-- 赛季卡重置 需要把未能领取的奖励通过邮件发送
  204 +function Store:onBattleCardReset()
  205 + local gift = {}
  206 + local function concatGift(data)
  207 + for key, v in pairs(data:toNumMap()) do
  208 + gift[key] = (gift[key] or 0) + v
  209 + end
  210 + end
  211 + local battleCardFlag = self:getProperty("battleCard")
  212 + local battleCardFreeRecord = self:getProperty("battleFR")
  213 + local battleCardLimitRecord = self:getProperty("battleLR")
  214 + local battlePoint = self.owner:getProperty("battlePoint")
  215 +
  216 + for id, config in pairs(csvdb["reward_battlepassCsv"]) do
  217 + if config then
  218 + local freeFlag = string.char(string.getbit(battleCardFreeRecord, id))
  219 + local limitFlag = string.char(string.getbit(battleCardLimitRecord, id))
  220 +
  221 + if battlePoint < config.point then
  222 + break
  223 + end
  224 + if freeFlag == "0" then
  225 + concatGift(config.giftFree)
  226 + end
  227 + if limitFlag == "0" and battleCardFlag == 1 then
  228 + concatGift(config.giftLimit)
  229 + end
  230 + end
  231 + end
  232 + self.owner:sendMail(MailId.BattleCardAward, nil, gift)
  233 + -- 计算剩余奖励
  234 + self:updateProperty({field = "battleCard", value=0})
  235 + self:updateProperty({field = "battleFR", value=""})
  236 + self:updateProperty({field = "battleLR", value=""})
  237 + self.owner:updateProperty({field = "battlePoint", value=0})
  238 +end
  239 +
  240 +-- 重置购买记录
  241 +function Store:resetStoreReored(resetId)
  242 + local payRecord = self:getProperty("payR") or {}
  243 + local buyRecord = self:getProperty("buyR") or {}
  244 + for k, v in pairs(payRecord) do
  245 + local config = csvdb["shop_rechargeCsv"][k]
  246 + if config then
  247 + if config.resetTime == resetId then
  248 + payRecord[k] = nil
  249 + --通行证商店
  250 + if config.shop == 2 then
  251 + if config.type == CardType.BattleCard then
  252 + self:onBattleCardReset()
  253 + end
  254 + end
  255 + end
  256 + end
  257 + end
  258 + self:updateProperty({field = "payR", value = payRecord})
  259 + for k, v in pairs(buyRecord) do
  260 + local config = csvdb["shop_normalCsv"][k]
  261 + if config then
  262 + if config.resetTime == resetId then
  263 + buyRecord[k] = nil
  264 + end
  265 + end
  266 + end
  267 + self:updateProperty({field = "buyR", value = buyRecord})
  268 +end
  269 +
  270 +--触发限时礼包
  271 +function Store:OnTriggerLimitTimePack(eventType, param)
  272 + local limitPack = self:getProperty("limitTPack")
  273 + local timeNow = skynet.timex()
  274 + local find = false
  275 + -- 有未过期的限时礼包不再推送
  276 + for k, v in pairs(limitPack) do
  277 + if v > timeNow then
  278 + find = true
  279 + break
  280 + end
  281 + end
  282 + if find == true then
  283 + return
  284 + end
  285 + limitPack = {}
  286 + local hangPass = self.owner:getProperty("hangPass")
  287 + local triggerRecord = self:getProperty("packTrigger")
  288 + local result = {}
  289 + local maxDiff = 0
  290 + -- 取满足限时礼包关卡要求的对应数据
  291 + for diff, maxCarbonId in pairs(hangPass) do
  292 + for id, cfg in pairs(csvdb["shop_packCsv"]) do
  293 + local range = cfg.showRange:toArray(true, "=")
  294 + local beginRange = range[1] or 0
  295 + local endRange = range[2] or 0
  296 + if maxCarbonId > beginRange and maxCarbonId <= endRange and cfg.type == eventType then
  297 + result[diff] = cfg
  298 + maxDiff = math.max(maxDiff, diff)
  299 + break
  300 + end
  301 + end
  302 + end
  303 + local shopGoodsId = 0
  304 + for diff, cfg in pairs(result) do
  305 + if diff == maxDiff then
  306 + local record = triggerRecord[diff] or {}
  307 + if (record[0] or 0) ~= cfg.id and next(record) then
  308 + record = {}
  309 + end
  310 + record[0] = cfg.id
  311 + record[eventType] = (record[eventType] or 0) + 1
  312 + if record[eventType] > 0 and record[eventType] % 10 == 0 then
  313 + local pool = cfg.packId:toArray(true, "=")
  314 + local idx = math.random(1, #pool)
  315 + shopGoodsId = pool[idx]
  316 + end
  317 + triggerRecord[diff] = record
  318 + end
  319 + end
  320 + if shopGoodsId ~= 0 then
  321 + local rechargeCfg = csvdb["shop_rechargeCsv"][shopGoodsId]
  322 + if rechargeCfg then
  323 + limitPack[rechargeCfg.id] = timeNow + rechargeCfg.time
  324 + self:updateProperty({field = "limitTPack", value = limitPack})
  325 + end
  326 + end
  327 + if next(result) then
  328 + self:updateProperty({field = "packTrigger", value = triggerRecord})
  329 + end
  330 +end
  331 +
  332 +function Store:data()
  333 + return {
  334 + buyR = self:getProperty("buyR"),
  335 + payR = self:getProperty("payR"),
  336 + growFund = self:getProperty("growFund"),
  337 + growFundR = self:getProperty("growFundR"),
  338 + monthCardEx = self:getProperty("monthCardEx"),
  339 + smonthCardEx = self:getProperty("smonthCardEx"),
  340 + battleCard = self:getProperty("battleCard"),
  341 + battleFR = self:getProperty("battleFR"),
  342 + battleLR = self:getProperty("battleLR"),
  343 + limitTPack = self:getProperty("limitTPack"),
  344 + privCardEx = self:getProperty("privCardEx"),
  345 + packTrigger = self:getProperty("packTrigger")
  346 + }
  347 +end
  348 +
  349 +return Store
0 \ No newline at end of file 350 \ No newline at end of file
src/services/agent_ctrl.lua
@@ -128,7 +128,7 @@ function _M:check_agent_status() @@ -128,7 +128,7 @@ function _M:check_agent_status()
128 next_log_time = now + 60 128 next_log_time = now + 60
129 local count = table_nums(self.u2f) 129 local count = table_nums(self.u2f)
130 datacenter.set("onlineCount", count) 130 datacenter.set("onlineCount", count)
131 - pcall(skynet.send, logd, "lua", "log", "online", {count = count}, "online") 131 + -- pcall(skynet.send, logd, "lua", "log", "online", {count = count}, "online")
132 end 132 end
133 end 133 end
134 134
src/services/logd.lua
@@ -55,38 +55,11 @@ skynet.register_protocol { @@ -55,38 +55,11 @@ skynet.register_protocol {
55 end 55 end
56 } 56 }
57 57
58 -  
59 -  
60 --- 日志 index 不包含 日期的 index_suffix  
61 -local IndexNoDate = {  
62 - online = true,  
63 -}  
64 --- 不走 role log 的日志都要自行注意 mapping 设置【重要】  
65 --- index_suffix index 后缀 默认为 common  
66 -function CMD.log(logType, doc, index_suffix)  
67 - index_suffix = index_suffix or "common"  
68 - if index_suffix == "common" then  
69 - doc["@type"] = logType  
70 - else  
71 - if logType ~= index_suffix then -- 定制后缀 不一定有type 不相等时才有type  
72 - doc["@type"] = logType  
73 - end  
74 - end  
75 -  
76 - local now = skynet.timex()  
77 - doc["timestamp"] = now  
78 - doc["timestamp_f"] = os.date("%Y-%m-%d %H:%M:%S", now)  
79 - doc["server"] = serverId  
80 -  
81 - -- 自己加好 index  
82 - if IndexNoDate[index_suffix] then  
83 - doc["@index"] = string.format("gamelog-%s", index_suffix)  
84 - else  
85 - doc["@index"] = string.format("gamelog-%s-%s", os.date("%Y%m%d", now), index_suffix)  
86 - end 58 +function CMD.log(doc)
87 if not socketdriver.send(log_fd, json.encode(doc) .. "\n") then 59 if not socketdriver.send(log_fd, json.encode(doc) .. "\n") then
88 if not connecting then 60 if not connecting then
89 CMD.open() -- 连一下试试 61 CMD.open() -- 连一下试试
  62 + socketdriver.send(log_fd, json.encode(doc) .. "\n")
90 end 63 end
91 end 64 end
92 end 65 end
src/utils/StringUtil.lua
@@ -13,7 +13,7 @@ local strh = require &quot;strh&quot; @@ -13,7 +13,7 @@ local strh = require &quot;strh&quot;
13 function string.setv(str, k, v, delimiter) 13 function string.setv(str, k, v, delimiter)
14 delimiter = delimiter or " " 14 delimiter = delimiter or " "
15 -- 若存在则替换,若无则append 15 -- 若存在则替换,若无则append
16 - return strh.modify(str, {[tonumber(k)]=tonumber(v)}, false, delimiter) 16 + return strh.modify(str, {[tonumber(k)]=math.floor(tonumber(v))}, false, delimiter)
17 end 17 end
18 18
19 function string.msetv(str, vs, delimiter) 19 function string.msetv(str, vs, delimiter)
@@ -24,7 +24,7 @@ end @@ -24,7 +24,7 @@ end
24 24
25 function string.incrv(str, k, delta, delimiter) 25 function string.incrv(str, k, delta, delimiter)
26 delimiter = delimiter or " " 26 delimiter = delimiter or " "
27 - return strh.modify(str, {[tonumber(k)]=tonumber(delta)}, true, delimiter) 27 + return strh.modify(str, {[tonumber(k)]=math.floor(tonumber(delta))}, true, delimiter)
28 end 28 end
29 29
30 function string.mincrv(str, ds, delimiter) 30 function string.mincrv(str, ds, delimiter)
@@ -331,4 +331,20 @@ function string.setbit(str, pos, yes) @@ -331,4 +331,20 @@ function string.setbit(str, pos, yes)
331 else 331 else
332 return str:sub(1, pos-1) .. yes .. str:sub(pos+1, -1) 332 return str:sub(1, pos-1) .. yes .. str:sub(pos+1, -1)
333 end 333 end
  334 +end
  335 +
  336 +--[[
  337 +from: 1=2 3=4
  338 +to: {["1"]="2" or 2,["3"]="4" or 4}
  339 +]]
  340 +function string.toMap(str, tonum, sep)
  341 + local str_vec = string.split(str, " ")
  342 + local tab = {}
  343 + for _, v in pairs(str_vec) do
  344 + local vec = string.split(v, sep)
  345 + if #vec == 2 then
  346 + tab[vec[1]] = tonum and tonumber(vec[2]) or vec[2]
  347 + end
  348 + end
  349 + return tab
334 end 350 end
335 \ No newline at end of file 351 \ No newline at end of file