Commit 88c6759abfb9bc03f064db5894a7086987d37986
Merge branch 'develop' into tr/publish
# Conflicts: # src/actions/HeroAction.lua
Showing
40 changed files
with
2554 additions
and
1205 deletions
Show diff stats
config/develop.lua
src/GlobalVar.lua
| ... | ... | @@ -2,6 +2,7 @@ XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18" |
| 2 | 2 | RESET_TIME = 0 |
| 3 | 3 | |
| 4 | 4 | START_RESET_TIME_BASE = 1584316800 -- 0时区 |
| 5 | +DAY_SEC = 86400 | |
| 5 | 6 | TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", START_RESET_TIME_BASE))) / 3600) -- 本地时区 |
| 6 | 7 | |
| 7 | 8 | START_RESET_TIME = START_RESET_TIME_BASE - TIME_ZONE * 3600 |
| ... | ... | @@ -128,6 +129,7 @@ ItemId = { |
| 128 | 129 | TimeReset = { |
| 129 | 130 | CrossDay = 1, --通用跨天 |
| 130 | 131 | CrossWeek = 2, --通用跨周 |
| 132 | + CrossMonth = 1, --通用跨月 索引使用跨天,在回调方法中判断是否跨越 跨月的前置条件是跨天 | |
| 131 | 133 | DinerRank = 1, -- 餐厅排行榜 |
| 132 | 134 | PvpRank = 2, -- pvp排行榜 |
| 133 | 135 | PvpHight = 11, --高级竞技场 |
| ... | ... | @@ -259,3 +261,53 @@ RedPointTags = { |
| 259 | 261 | PvpCR = 1, |
| 260 | 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 | 314 | \ No newline at end of file | ... | ... |
src/ProtocolCode.lua
| ... | ... | @@ -6,6 +6,7 @@ actionCodes = { |
| 6 | 6 | Sys_innerErrorMsg = 4, |
| 7 | 7 | Sys_commonNotice = 5, |
| 8 | 8 | Sys_maintainNotice = 6, |
| 9 | + Sys_customNotice = 7, | |
| 9 | 10 | |
| 10 | 11 | Gm_clientRequest = 20, |
| 11 | 12 | Gm_receiveResponse = 21, |
| ... | ... | @@ -43,6 +44,7 @@ actionCodes = { |
| 43 | 44 | Role_guideRpc = 129, |
| 44 | 45 | Role_getRandomNameRpc = 130, |
| 45 | 46 | Role_goldBuyRpc = 131, |
| 47 | + Role_getDownloadCvRewardRpc = 132, | |
| 46 | 48 | |
| 47 | 49 | Adv_startAdvRpc = 151, |
| 48 | 50 | Adv_startHangRpc = 152, |
| ... | ... | @@ -87,6 +89,7 @@ actionCodes = { |
| 87 | 89 | Hero_getResetRewardRpc = 219, |
| 88 | 90 | Hero_drawHeroRpc = 220, |
| 89 | 91 | Hero_repayHeroRpc = 221, |
| 92 | + Hero_unlockPoolRpc = 222, | |
| 90 | 93 | |
| 91 | 94 | Hang_startRpc = 251, |
| 92 | 95 | Hang_checkRpc = 252, |
| ... | ... | @@ -182,6 +185,11 @@ actionCodes = { |
| 182 | 185 | Store_ayncPurchaseRpc = 555, |
| 183 | 186 | Store_myCardRechargeRpc = 556, |
| 184 | 187 | Store_iosRechargeRpc = 557, |
| 188 | + Store_shopBuyRpc = 558, | |
| 189 | + Store_updateproperty = 559, | |
| 190 | + Store_getFreeChestRpc = 560, | |
| 191 | + Store_getGrowFundRewardRpc = 561, --成长助力奖励 | |
| 192 | + Store_getBattlePassRewardRpc = 562, --赛季卡奖励 | |
| 185 | 193 | |
| 186 | 194 | |
| 187 | 195 | Email_listRpc = 600, | ... | ... |
src/RedisKeys.lua
src/actions/ActivityAction.lua
| ... | ... | @@ -32,9 +32,9 @@ function _M.sudokuRpc(agent, data) |
| 32 | 32 | if (sudoku.task[phase][id] or 0) < curData.con1 then return 2 end |
| 33 | 33 | |
| 34 | 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 | 38 | local rId = {} |
| 39 | 39 | for pid, pdata in pairs(csvdb["guide_sudoku_rewardCsv"][phase] or {}) do |
| 40 | 40 | local pos = pdata.pos:toArray(true, "=") |
| ... | ... | @@ -60,14 +60,18 @@ function _M.sudokuRpc(agent, data) |
| 60 | 60 | if not next(reward) then |
| 61 | 61 | reward = nil |
| 62 | 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 | 64 | end |
| 65 | 65 | |
| 66 | 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 | 75 | return true |
| 72 | 76 | end |
| 73 | 77 | |
| ... | ... | @@ -90,7 +94,7 @@ function _M.sudokuRewardRpc(agent, data) |
| 90 | 94 | end |
| 91 | 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 | 99 | sudoku[-1] = phase + 1 |
| 96 | 100 | sudoku.task[phase] = nil |
| ... | ... | @@ -100,7 +104,13 @@ function _M.sudokuRewardRpc(agent, data) |
| 100 | 104 | end |
| 101 | 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 | 114 | return true |
| 105 | 115 | end |
| 106 | 116 | |
| ... | ... | @@ -125,10 +135,10 @@ function _M.signRpc(agent, data) |
| 125 | 135 | end |
| 126 | 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 | 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 | 142 | return true |
| 133 | 143 | end |
| 134 | 144 | |
| ... | ... | @@ -138,7 +148,7 @@ function _M.actSignRpc(agent, data) |
| 138 | 148 | if not role.activity:isOpen("Sign") then return 1 end |
| 139 | 149 | |
| 140 | 150 | local curData = role.activity:getActData("Sign") |
| 141 | - local reward = {} | |
| 151 | + local reward, change = {} | |
| 142 | 152 | for day, csvData in ipairs(csvdb["new_signInCsv"]) do |
| 143 | 153 | if day <= (curData[0] or 0) then |
| 144 | 154 | if not curData[day] then |
| ... | ... | @@ -154,9 +164,16 @@ function _M.actSignRpc(agent, data) |
| 154 | 164 | end |
| 155 | 165 | if next(reward) then |
| 156 | 166 | role.activity:updateActData("Sign", curData) |
| 157 | - reward = role:award(reward, {log = {desc = "actSign"}}) | |
| 167 | + reward, change = role:award(reward, {log = {desc = "actSign"}}) | |
| 158 | 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 | 177 | return true |
| 161 | 178 | end |
| 162 | 179 | ... | ... |
src/actions/AdvAction.lua
| ... | ... | @@ -90,7 +90,7 @@ function _M.startAdvRpc( agent, data ) |
| 90 | 90 | --上一个关卡结束才可以开始新的关卡 |
| 91 | 91 | if role:getAdvData():isRunning() then return 8 end |
| 92 | 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 | 96 | local chapterData = csvdb["adv_chapterCsv"][chapterId] |
| ... | ... | @@ -174,7 +174,6 @@ function _M.startAdvRpc( agent, data ) |
| 174 | 174 | role:checkTaskEnter("AdvStart", {id = chapterId}) |
| 175 | 175 | role:checkTaskEnter("AdvStartSelf", {id = chapterId}) |
| 176 | 176 | role:getAdvData():popBackEvents() -- 清一下事件 |
| 177 | - role:getAdvData():log({desc = "start", int1 = supportIdx}) | |
| 178 | 177 | |
| 179 | 178 | SendPacket(actionCodes.Adv_startAdvRpc, '') |
| 180 | 179 | return true |
| ... | ... | @@ -184,26 +183,38 @@ function _M.startHangRpc(agent, data) |
| 184 | 183 | local role = agent.role |
| 185 | 184 | local msg = MsgPack.unpack(data) |
| 186 | 185 | local chapterId = msg.chapterId --关卡id |
| 186 | + local campId = msg.campId or 2 --营地id | |
| 187 | 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 | 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 | 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 | 219 | local player = {} |
| 209 | 220 | local attrs = role:getTeamBattleInfo(format).heros |
| ... | ... | @@ -220,7 +231,7 @@ function _M.startHangRpc(agent, data) |
| 220 | 231 | + 0.226 * player["hit"] |
| 221 | 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 | 236 | local info = {} |
| 226 | 237 | info.format = {} |
| ... | ... | @@ -230,7 +241,9 @@ function _M.startHangRpc(agent, data) |
| 230 | 241 | for slot, heroId in pairs(format.heros) do |
| 231 | 242 | info.format.heros[slot] = heroId |
| 232 | 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 | 248 | -- 没有在战斗 用team来挂机了 把team清掉 |
| 236 | 249 | if not role:getAdvData():isRunning() then |
| ... | ... | @@ -239,9 +252,8 @@ function _M.startHangRpc(agent, data) |
| 239 | 252 | |
| 240 | 253 | role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) |
| 241 | 254 | |
| 242 | - role:changeAdvCount(chapterData.limitlevel) | |
| 255 | + role:changeAdvCount(adv_idle_energy) | |
| 243 | 256 | role:checkTaskEnter("AdvStart", {id = chapterId}) |
| 244 | - role:log("adv_action", {desc = "startHang", int1 = chapterId}) | |
| 245 | 257 | |
| 246 | 258 | SendPacket(actionCodes.Adv_startHangRpc, '') |
| 247 | 259 | return true |
| ... | ... | @@ -257,21 +269,30 @@ function _M.quickHangRpc(agent, data) |
| 257 | 269 | local info = advHang[chapterId] |
| 258 | 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 | 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 | 286 | local reward, isFull |
| 264 | 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 | 291 | if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return end |
| 269 | 292 | role:costItems({[ItemId.Diamond] = cost}, {log = {desc = "advQuickHang", int1 = chapterId}}) |
| 270 | 293 | info.time = 0 |
| 271 | 294 | role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) |
| 272 | 295 | |
| 273 | - role:log("adv_action", {desc = "advQuickHang", int1 = chapterId}) | |
| 274 | - | |
| 275 | 296 | SendPacket(actionCodes.Adv_quickHangRpc, '') |
| 276 | 297 | return true |
| 277 | 298 | end |
| ... | ... | @@ -287,11 +308,25 @@ function _M.endHangRpc(agent, data) |
| 287 | 308 | local info = advHang[chapterId] |
| 288 | 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 | 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 | 327 | if skynet.timex() >= info.time then |
| 328 | + -- 最新需求加成取消 | |
| 329 | + --[[ | |
| 295 | 330 | -- 英雄加成 |
| 296 | 331 | local idleUnit = chapterData.idleUnit:toNumMap() |
| 297 | 332 | local upUnit = 0 |
| ... | ... | @@ -316,15 +351,17 @@ function _M.endHangRpc(agent, data) |
| 316 | 351 | end |
| 317 | 352 | |
| 318 | 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 | 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 | 360 | end |
| 324 | - reward = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}}) | |
| 361 | + reward, change = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}}) | |
| 325 | 362 | else |
| 326 | 363 | if cancel then |
| 327 | - role:changeAdvCount(-chapterData.limitlevel) | |
| 364 | + --role:changeAdvCount(-chapterData.limitlevel) | |
| 328 | 365 | -- if role:getProperty("advC") <= 0 then |
| 329 | 366 | -- isFull = true |
| 330 | 367 | -- else |
| ... | ... | @@ -337,9 +374,7 @@ function _M.endHangRpc(agent, data) |
| 337 | 374 | |
| 338 | 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 | 378 | return true |
| 344 | 379 | end |
| 345 | 380 | |
| ... | ... | @@ -360,7 +395,7 @@ function _M.buyAdvCountRpc(agent , data) |
| 360 | 395 | |
| 361 | 396 | |
| 362 | 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 | 399 | if isEl then |
| 365 | 400 | role.dailyData:updateProperty({field = "advElC", delta = -count}) |
| 366 | 401 | role.dailyData:updateProperty({field = "advElBC", delta = count}) |
| ... | ... | @@ -368,7 +403,6 @@ function _M.buyAdvCountRpc(agent , data) |
| 368 | 403 | role:changeAdvCount(-count * globalCsv.adv_daily_buy_num) |
| 369 | 404 | role.dailyData:updateProperty({field = "advBC", delta = count}) |
| 370 | 405 | end |
| 371 | - role:log("adv_action", {desc = "buyAdvCount", short1 = isEl and 1 or 0, int1 = count}) | |
| 372 | 406 | |
| 373 | 407 | SendPacket(actionCodes.Adv_buyAdvCountRpc, '') |
| 374 | 408 | return true |
| ... | ... | @@ -381,9 +415,9 @@ function _M.finishTaskRpc(agent, data) |
| 381 | 415 | if not isCanContinue(role) then return end |
| 382 | 416 | local adv = role:getAdvData() |
| 383 | 417 | local taskId = msg.taskId -- -1 则是主线任务 |
| 384 | - local status, reward | |
| 418 | + local status, reward, change | |
| 385 | 419 | if taskId == -1 then |
| 386 | - status, reward = adv:finishMTask() | |
| 420 | + status, reward, change = adv:finishMTask() | |
| 387 | 421 | else |
| 388 | 422 | status, reward = adv:finishTask(taskId) |
| 389 | 423 | adv:checkAchievement(adv.AchievType.TaskLayer, 1, taskId) |
| ... | ... | @@ -393,9 +427,7 @@ function _M.finishTaskRpc(agent, data) |
| 393 | 427 | if not status then return end |
| 394 | 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 | 431 | return true |
| 400 | 432 | end |
| 401 | 433 | |
| ... | ... | @@ -416,8 +448,6 @@ function _M.clickBlockRpc(agent, data) |
| 416 | 448 | |
| 417 | 449 | if adv:isWaitChooseArtifact() then return returnFail() end |
| 418 | 450 | |
| 419 | - adv:log({desc = "clickBlock", int1 = msg.roomId, int2 = msg.blockId}) | |
| 420 | - | |
| 421 | 451 | local status, errorCode = adv:clickBlock(msg.roomId, msg.blockId, msg) |
| 422 | 452 | if not status then return returnFail(errorCode) end |
| 423 | 453 | |
| ... | ... | @@ -450,8 +480,11 @@ function _M.useItemRpc(agent, data) |
| 450 | 480 | adv:backUse({[itemId] = count}) |
| 451 | 481 | end |
| 452 | 482 | |
| 483 | + if itemId == 5020 then | |
| 484 | + role:finishGuide(53) | |
| 485 | + end | |
| 486 | + | |
| 453 | 487 | adv:checkAchievement(adv.AchievType.UseItem, count, itemId) |
| 454 | - adv:log({desc = "useItem", int1 = itemId, int2 = count}) | |
| 455 | 488 | |
| 456 | 489 | for i = 1, count do |
| 457 | 490 | adv:doActive(itemData.effect, target) -- target |
| ... | ... | @@ -487,7 +520,6 @@ function _M.usePotionRpc(agent, data) |
| 487 | 520 | local adv = role:getAdvData() |
| 488 | 521 | if adv:isWaitChooseArtifact() then return end |
| 489 | 522 | |
| 490 | - adv:log({desc = "usePotion", int1 = potionId}) | |
| 491 | 523 | |
| 492 | 524 | local status = adv:doActive(potionData.effect, target) -- target |
| 493 | 525 | if not status then return end |
| ... | ... | @@ -499,6 +531,8 @@ function _M.usePotionRpc(agent, data) |
| 499 | 531 | adv:saveDB() |
| 500 | 532 | role:checkTaskEnter("AdvUsePotion") |
| 501 | 533 | |
| 534 | + role:finishGuide(61) | |
| 535 | + | |
| 502 | 536 | SendPacket(actionCodes.Adv_usePotionRpc, MsgPack.pack({events = adv:popBackEvents()})) |
| 503 | 537 | return true |
| 504 | 538 | end |
| ... | ... | @@ -539,6 +573,8 @@ function _M.wearArtifactRpc(agent, data) |
| 539 | 573 | if not status then return 3 end |
| 540 | 574 | adv:saveDB() |
| 541 | 575 | |
| 576 | + role:finishGuide(55) | |
| 577 | + | |
| 542 | 578 | SendPacket(actionCodes.Adv_wearArtifactRpc, '') |
| 543 | 579 | return true |
| 544 | 580 | end |
| ... | ... | @@ -568,6 +604,7 @@ function _M.upArtifactRpc(agent, data) |
| 568 | 604 | else |
| 569 | 605 | adv:updateAchievement() |
| 570 | 606 | end |
| 607 | + | |
| 571 | 608 | SendPacket(actionCodes.Adv_upArtifactRpc, '') |
| 572 | 609 | return true |
| 573 | 610 | end |
| ... | ... | @@ -577,9 +614,10 @@ function _M.exitAdvRpc(agent, data) |
| 577 | 614 | local role = agent.role |
| 578 | 615 | -- local msg = MsgPack.unpack(data) |
| 579 | 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 | 620 | local adv = role:getAdvData() |
| 582 | - adv:log({desc = "exit"}) | |
| 583 | 621 | local status = adv:exit() -- target {roomId = 1, blockId = 1} 选择的目标 |
| 584 | 622 | SendPacket(actionCodes.Adv_exitAdvRpc, MsgPack.pack({events = adv:popBackEvents()})) |
| 585 | 623 | return true |
| ... | ... | @@ -638,7 +676,19 @@ function _M.endBattleRpc(agent, data) |
| 638 | 676 | if enemy.monsterId ~= monsterId or enemy.roomId ~= roomId or enemy.blockId ~= blockId then return end |
| 639 | 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 | 692 | local status = adv:clickBlock(roomId, blockId, {player = player, bySkill = bySkill}) |
| 643 | 693 | |
| 644 | 694 | if not status then return end |
| ... | ... | @@ -720,9 +770,8 @@ function _M.wheelSurfRpc(agent, data) |
| 720 | 770 | table.insert(backReward, gift) |
| 721 | 771 | end |
| 722 | 772 | role:award(reward, {log = {desc = "advWheelSurf", int1 = ptype}}) |
| 723 | - | |
| 773 | + role:finishGuide(58) | |
| 724 | 774 | role:checkTaskEnter("AdvDraw", {count = count, ptype = ptype}) |
| 725 | - role:log("adv_action", {desc = "advWheelSurf", int1 = ptype, int2 = count}) | |
| 726 | 775 | |
| 727 | 776 | SendPacket(actionCodes.Adv_wheelSurfRpc, MsgPack.pack({reward = backReward})) |
| 728 | 777 | return true |
| ... | ... | @@ -749,11 +798,10 @@ function _M.repayWheelSurfRpc(agent, data) |
| 749 | 798 | advDrawB[ptype] = advDrawB[ptype] - globalCsv.adv_draw_back_cond |
| 750 | 799 | role:updateProperty({field = "advDrawB", value = advDrawB}) |
| 751 | 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 | 805 | return true |
| 758 | 806 | end |
| 759 | 807 | |
| ... | ... | @@ -766,17 +814,16 @@ function _M.finishAchievRpc(agent, data) |
| 766 | 814 | |
| 767 | 815 | local adv = role:getAdvData() |
| 768 | 816 | |
| 769 | - local status, reward | |
| 817 | + local status, reward, change | |
| 770 | 818 | if ctype == 1 then |
| 771 | - status, reward = adv:finishAchievement(chapterId, taskId) | |
| 819 | + status, reward, change = adv:finishAchievement(chapterId, taskId) | |
| 772 | 820 | elseif ctype == 2 then |
| 773 | - status, reward = adv:getAchievementReward(chapterId, taskId) | |
| 821 | + status, reward, change = adv:getAchievementReward(chapterId, taskId) | |
| 774 | 822 | end |
| 775 | 823 | if not status then return end |
| 776 | 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 | 827 | return true |
| 781 | 828 | end |
| 782 | 829 | |
| ... | ... | @@ -831,7 +878,6 @@ function _M.refreshSupportRpc(agent, data) |
| 831 | 878 | end |
| 832 | 879 | |
| 833 | 880 | role:advRandomSupportEffect() |
| 834 | - role:log("adv_action", {desc = "advSupRe", short1 = cr < al and 0 or 1}) | |
| 835 | 881 | |
| 836 | 882 | SendPacket(actionCodes.Adv_refreshSupportRpc, '') |
| 837 | 883 | return true | ... | ... |
src/actions/CarAction.lua
| ... | ... | @@ -40,7 +40,13 @@ function _M.makePotionRpc( agent, data ) |
| 40 | 40 | role:updateProperty({field = "potionBag", value = potionBag}) |
| 41 | 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 | 50 | SendPacket(actionCodes.Car_makePotionRpc, MsgPack.pack({potionBag = potionBag})) |
| 45 | 51 | return true |
| 46 | 52 | end |
| ... | ... | @@ -91,7 +97,14 @@ function _M.equipUpRpc( agent, data ) |
| 91 | 97 | role:addEquip(typ, nextLv ,count, {log = {desc = "equipUp"}}) |
| 92 | 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 | 109 | SendPacket(actionCodes.Car_equipUpRpc, '') |
| 97 | 110 | return true |
| ... | ... | @@ -150,7 +163,7 @@ function _M.saleEquipRpc(agent, data ) |
| 150 | 163 | local own = role:getEquipCount(typ,lv) |
| 151 | 164 | if math.illegalNum(count, 1, own) then return end |
| 152 | 165 | end |
| 153 | - local reward = {} | |
| 166 | + local reward, change = {} | |
| 154 | 167 | local allCount = 0 |
| 155 | 168 | for id, count in pairs(backs) do |
| 156 | 169 | allCount = allCount + count |
| ... | ... | @@ -165,11 +178,9 @@ function _M.saleEquipRpc(agent, data ) |
| 165 | 178 | end |
| 166 | 179 | end |
| 167 | 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 | 184 | return true |
| 174 | 185 | end |
| 175 | 186 | |
| ... | ... | @@ -179,7 +190,7 @@ function _M.saleRuneRpc(agent, data ) |
| 179 | 190 | local backs = msg.backs |
| 180 | 191 | if not backs then return end |
| 181 | 192 | |
| 182 | - local reward = {} | |
| 193 | + local reward, change = {} | |
| 183 | 194 | local count = 0 |
| 184 | 195 | for _, uid in pairs(backs) do |
| 185 | 196 | count = count + 1 |
| ... | ... | @@ -196,9 +207,9 @@ function _M.saleRuneRpc(agent, data ) |
| 196 | 207 | |
| 197 | 208 | role:delRunes(backs, {log = {desc = "saleRune"}}) |
| 198 | 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 | 213 | return true |
| 203 | 214 | end |
| 204 | 215 | ... | ... |
src/actions/DinerAction.lua
| ... | ... | @@ -104,8 +104,7 @@ function _M.addSellRpc( agent, data ) |
| 104 | 104 | if change then |
| 105 | 105 | role.dinerData:updateProperty({field = "customer", value = customer}) |
| 106 | 106 | end |
| 107 | - | |
| 108 | - role:log("diner_action", {desc = "addSell", int1 = dish, int2 = count}) | |
| 107 | + role:finishGuide(28) | |
| 109 | 108 | |
| 110 | 109 | role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) |
| 111 | 110 | SendPacket(actionCodes.Diner_addSellRpc, "") |
| ... | ... | @@ -140,20 +139,27 @@ function _M.removeSellRpc( agent, data ) |
| 140 | 139 | return 5 |
| 141 | 140 | end |
| 142 | 141 | |
| 143 | - role.dinerData:updateSell(slot) | |
| 144 | - local reward = {} | |
| 142 | + local temp = role.dinerData:updateSell(slot) | |
| 143 | + local reward, change = {} | |
| 145 | 144 | local cost = dishData.material:toNumMap() |
| 146 | 145 | for k, n in pairs(cost) do |
| 147 | 146 | local sum = n*sell.count |
| 148 | 147 | reward[k] = sum |
| 149 | 148 | end |
| 150 | - reward = role:award(reward, {log = {desc = "removeSell"}}) | |
| 149 | + reward, change = role:award(reward, {log = {desc = "removeSell"}}) | |
| 151 | 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 | 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 | 163 | return true |
| 158 | 164 | end |
| 159 | 165 | |
| ... | ... | @@ -162,8 +168,11 @@ function _M.getSellRewardRpc( agent, data ) |
| 162 | 168 | local dirty = false |
| 163 | 169 | local reward, popular = "", 0 |
| 164 | 170 | local sells = json.decode(role.dinerData:getProperty("sells")) |
| 171 | + | |
| 172 | + local deltaTimes = {} | |
| 165 | 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 | 176 | end |
| 168 | 177 | sells = json.decode(role.dinerData:getProperty("sells")) |
| 169 | 178 | for slot, sell in pairs(sells) do |
| ... | ... | @@ -187,6 +196,15 @@ function _M.getSellRewardRpc( agent, data ) |
| 187 | 196 | end |
| 188 | 197 | sells[slot].reward = "" |
| 189 | 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 | 208 | end |
| 191 | 209 | role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) |
| 192 | 210 | local gift = reward:toNumMap() |
| ... | ... | @@ -195,7 +213,7 @@ function _M.getSellRewardRpc( agent, data ) |
| 195 | 213 | role:checkTaskEnter("FoodSellGold", {count = v}) |
| 196 | 214 | end |
| 197 | 215 | end |
| 198 | - role:award(gift, {log = {desc = "dinerSell"}}) | |
| 216 | + local reward, change = role:award(gift, {log = {desc = "dinerSell"}}) | |
| 199 | 217 | |
| 200 | 218 | |
| 201 | 219 | role.dinerData:popularAdd(popular) |
| ... | ... | @@ -204,9 +222,9 @@ function _M.getSellRewardRpc( agent, data ) |
| 204 | 222 | role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) |
| 205 | 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 | 228 | return true |
| 211 | 229 | end |
| 212 | 230 | |
| ... | ... | @@ -254,6 +272,15 @@ function _M.expediteSellRpc( agent, data ) |
| 254 | 272 | dirty = true |
| 255 | 273 | end |
| 256 | 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 | 284 | end |
| 258 | 285 | end |
| 259 | 286 | |
| ... | ... | @@ -261,12 +288,20 @@ function _M.expediteSellRpc( agent, data ) |
| 261 | 288 | role.dinerData:setProperty("expedite",count+1) |
| 262 | 289 | role.dinerData:notifyUpdateProperty("expedite", count+1) |
| 263 | 290 | local gift = reward:toNumMap() |
| 291 | + | |
| 292 | + -- 特权卡获取加速获得额外道具 | |
| 293 | + local coef = role.storeData:getProduceItemSpeedCoef() | |
| 264 | 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 | 299 | if k == ItemId.Gold then |
| 266 | 300 | role:checkTaskEnter("FoodSellGold", {count = v}) |
| 267 | 301 | end |
| 268 | 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 | 307 | role.dinerData:popularAdd(popular) |
| ... | ... | @@ -276,9 +311,7 @@ function _M.expediteSellRpc( agent, data ) |
| 276 | 311 | end |
| 277 | 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 | 315 | return true |
| 283 | 316 | end |
| 284 | 317 | |
| ... | ... | @@ -317,7 +350,13 @@ function _M.levelUpRpc( agent, data ) |
| 317 | 350 | role.dinerData:updateProperty({field = "buildL", value = buildL:setv(index, curLevel + 1)}) |
| 318 | 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 | 361 | SendPacket(actionCodes.Diner_levelUpRpc, '') |
| 323 | 362 | return true |
| ... | ... | @@ -399,9 +438,14 @@ function _M.talentUpRpc( agent, data ) |
| 399 | 438 | -- end |
| 400 | 439 | |
| 401 | 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 | 449 | SendPacket(actionCodes.Diner_talentUpRpc, '') |
| 406 | 450 | return true |
| 407 | 451 | end |
| ... | ... | @@ -435,7 +479,6 @@ function _M.skillUpRpc( agent, data ) |
| 435 | 479 | |
| 436 | 480 | role:costItems(cost, {log = {desc = "dinerSkillUp", int1 = skill, int2 = skillLevel + 1}}) |
| 437 | 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 | 483 | SendPacket(actionCodes.Diner_skillUpRpc, '') |
| 441 | 484 | return true |
| ... | ... | @@ -463,8 +506,6 @@ function _M.lockTaskRpc( agent, data ) |
| 463 | 506 | end |
| 464 | 507 | role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) |
| 465 | 508 | |
| 466 | - role:log("diner_action", {desc = "lockTask", int1 = order.id}) | |
| 467 | - | |
| 468 | 509 | SendPacket(actionCodes.Diner_lockTaskRpc, MsgPack.pack({lock = order.lock})) |
| 469 | 510 | return true |
| 470 | 511 | end |
| ... | ... | @@ -493,7 +534,7 @@ function _M.updateTaskRpc( agent, data ) |
| 493 | 534 | return 5 |
| 494 | 535 | end |
| 495 | 536 | |
| 496 | - | |
| 537 | + local reward, change | |
| 497 | 538 | if cmd == 0 then |
| 498 | 539 | if order.status ~= 0 then |
| 499 | 540 | return 30 |
| ... | ... | @@ -501,8 +542,6 @@ function _M.updateTaskRpc( agent, data ) |
| 501 | 542 | orders[index].status = 1 |
| 502 | 543 | orders[index].lock = 1 |
| 503 | 544 | |
| 504 | - role:log("diner_action", {desc = "getTask", int1 = order.id}) | |
| 505 | - | |
| 506 | 545 | role:checkTaskEnter("GetOderTask", {rarity = taskSet.rarity}) |
| 507 | 546 | elseif cmd == 1 then |
| 508 | 547 | if order.status ~= 1 then |
| ... | ... | @@ -511,8 +550,6 @@ function _M.updateTaskRpc( agent, data ) |
| 511 | 550 | orders[index].status = 0 |
| 512 | 551 | orders[index].lock = 0 |
| 513 | 552 | |
| 514 | - role:log("diner_action", {desc = "deleteTask", int1 = order.id}) | |
| 515 | - | |
| 516 | 553 | elseif cmd == 2 then |
| 517 | 554 | if order.status ~= 1 then |
| 518 | 555 | return 32 |
| ... | ... | @@ -520,17 +557,24 @@ function _M.updateTaskRpc( agent, data ) |
| 520 | 557 | if order.n < taskData.value then |
| 521 | 558 | return 6 |
| 522 | 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 | 562 | table.remove(orders,index) |
| 527 | 563 | role:checkTaskEnter("OverOderTask", {rarity = taskSet.rarity}) |
| 528 | 564 | else |
| 529 | 565 | return 33 |
| 530 | 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 | 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 | 578 | return true |
| 535 | 579 | end |
| 536 | 580 | |
| ... | ... | @@ -603,8 +647,7 @@ function _M.refreshTaskRpc( agent, data ) |
| 603 | 647 | end |
| 604 | 648 | end |
| 605 | 649 | |
| 606 | - role:log("diner_action", {desc = "reTask"}) | |
| 607 | - | |
| 650 | + role:finishGuide(41) | |
| 608 | 651 | role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) |
| 609 | 652 | |
| 610 | 653 | SendPacket(actionCodes.Diner_refreshTaskRpc, '') |
| ... | ... | @@ -644,8 +687,7 @@ function _M.addWantFoodRpc(agent , data) |
| 644 | 687 | gfood[slot] = {id = itemId, st = skynet.timex()} |
| 645 | 688 | end |
| 646 | 689 | |
| 647 | - role:log("diner_action", {desc = "wantFood"}) | |
| 648 | - | |
| 690 | + role:finishGuide(36) | |
| 649 | 691 | role.dinerData:updateProperty({field = "gfood", value = gfood}) |
| 650 | 692 | |
| 651 | 693 | SendPacket(actionCodes.Diner_addWantFoodRpc, '') |
| ... | ... | @@ -679,14 +721,21 @@ function _M.getGreenhouseRpc( agent, data ) |
| 679 | 721 | else |
| 680 | 722 | gfood[k].st = st + speed * reward[itemId] |
| 681 | 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 | 732 | end |
| 683 | 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 | 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 | 739 | return true |
| 691 | 740 | end |
| 692 | 741 | |
| ... | ... | @@ -798,7 +847,7 @@ function _M.entrustRpc(agent , data) |
| 798 | 847 | local entrustId = entrust[1] |
| 799 | 848 | if not entrustId then return end |
| 800 | 849 | |
| 801 | - local reward | |
| 850 | + local reward, change | |
| 802 | 851 | if ctype == 1 then -- 完成 |
| 803 | 852 | local curData = csvdb["diner_missionCsv"][entrustId] |
| 804 | 853 | if not curData then return end |
| ... | ... | @@ -813,7 +862,7 @@ function _M.entrustRpc(agent , data) |
| 813 | 862 | return |
| 814 | 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 | 866 | table.remove(entrust, 1) |
| 818 | 867 | elseif ctype == 2 then -- 放弃 |
| 819 | 868 | table.remove(entrust, 1) |
| ... | ... | @@ -822,9 +871,9 @@ function _M.entrustRpc(agent , data) |
| 822 | 871 | end |
| 823 | 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 | 877 | return true |
| 829 | 878 | end |
| 830 | 879 | |
| ... | ... | @@ -845,12 +894,22 @@ function _M.collectRpc(agent , data) |
| 845 | 894 | for slot, _ in pairs(sells) do |
| 846 | 895 | role.dinerData:updateSell(slot) |
| 847 | 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 | 898 | customer[id] = 1 |
| 850 | 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 | 913 | return true |
| 855 | 914 | end |
| 856 | 915 | |
| ... | ... | @@ -874,13 +933,11 @@ function _M.comboRewardRpc(agent , data) |
| 874 | 933 | end |
| 875 | 934 | |
| 876 | 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 | 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 | 941 | return true |
| 885 | 942 | end |
| 886 | 943 | ... | ... |
src/actions/EmailAction.lua
| ... | ... | @@ -53,7 +53,6 @@ function _M.listRpc(agent, data) |
| 53 | 53 | content = email.content, |
| 54 | 54 | attachments = email.attachments |
| 55 | 55 | }) |
| 56 | - role:log("mail_action", {desc = "get_global", key1 = email.title, key2 = email.attachments}) | |
| 57 | 56 | end |
| 58 | 57 | end |
| 59 | 58 | end |
| ... | ... | @@ -86,28 +85,23 @@ function _M.drawAllAttachRpc(agent, data) |
| 86 | 85 | local role = agent.role |
| 87 | 86 | local roleId = role:getProperty("id") |
| 88 | 87 | |
| 89 | - local reward = {} | |
| 88 | + local reward, change = {} | |
| 90 | 89 | local ids = {} |
| 91 | 90 | |
| 92 | 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 | 100 | end |
| 107 | 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 | 105 | return true |
| 112 | 106 | end |
| 113 | 107 | |
| ... | ... | @@ -125,11 +119,11 @@ function _M.drawAttachRpc(agent, data) |
| 125 | 119 | local attachments = getEmailAttachments(email) |
| 126 | 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 | 127 | return true |
| 134 | 128 | end |
| 135 | 129 | |
| ... | ... | @@ -140,11 +134,12 @@ function _M.checkRpc(agent, data) |
| 140 | 134 | local msg = MsgPack.unpack(data) |
| 141 | 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 | 144 | SendPacket(actionCodes.Email_checkRpc, '') |
| 150 | 145 | return true |
| ... | ... | @@ -172,6 +167,7 @@ function _M.delRpc(agent, data) |
| 172 | 167 | attachments = emailData.attachment |
| 173 | 168 | end |
| 174 | 169 | if status == 2 or (status == 1 and attachments:len() == 0) then |
| 170 | + email:log(role, 3) | |
| 175 | 171 | red:lrem(rds, 0, id) |
| 176 | 172 | red:del(emailRds) |
| 177 | 173 | result[tonum(id)] = 1 |
| ... | ... | @@ -179,9 +175,6 @@ function _M.delRpc(agent, data) |
| 179 | 175 | end |
| 180 | 176 | end |
| 181 | 177 | end) |
| 182 | - for delId, _ in ipairs(result) do | |
| 183 | - role:log("mail_action", {desc = "del_mail", int1 = delId}) | |
| 184 | - end | |
| 185 | 178 | SendPacket(actionCodes.Email_delRpc, MsgPack.pack({result = result})) |
| 186 | 179 | return true |
| 187 | 180 | end | ... | ... |
src/actions/FriendAction.lua
| ... | ... | @@ -111,7 +111,6 @@ function _M.searchRpc(agent, data) |
| 111 | 111 | })) |
| 112 | 112 | end |
| 113 | 113 | |
| 114 | - role:log("role_action", {desc = "searchFriend"}) | |
| 115 | 114 | SendPacket(actionCodes.Friend_searchRpc, MsgPack.pack({searchList = searchList})) |
| 116 | 115 | return true |
| 117 | 116 | end |
| ... | ... | @@ -178,8 +177,6 @@ function _M.applyRpc(agent, data) |
| 178 | 177 | myInfo.online = true |
| 179 | 178 | myInfo.hadApply = true |
| 180 | 179 | |
| 181 | - role:log("role_action", {desc = "addFriend", int1 = 1}) | |
| 182 | - | |
| 183 | 180 | rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({newApply = 1, info = {myInfo}})) -- 通知对方 |
| 184 | 181 | end |
| 185 | 182 | |
| ... | ... | @@ -217,6 +214,7 @@ local function checkHandleApply(roleId, objectId, needAddNew) |
| 217 | 214 | red:sismember(FRIEND_BLACK_KEY:format(objectId), roleId) |
| 218 | 215 | red:sismember(FRIEND_BLACK_KEY:format(roleId), objectId) |
| 219 | 216 | end) |
| 217 | + | |
| 220 | 218 | --自己好友满了 |
| 221 | 219 | if (redret[1] + needAddNew) >= globalCsv.friendListLimit then |
| 222 | 220 | return 1 |
| ... | ... | @@ -233,6 +231,8 @@ local function checkHandleApply(roleId, objectId, needAddNew) |
| 233 | 231 | if redret[4] == 1 then |
| 234 | 232 | return 4 |
| 235 | 233 | end |
| 234 | + | |
| 235 | + return nil, redret[1] | |
| 236 | 236 | end |
| 237 | 237 | |
| 238 | 238 | function _M.handleApplyRpc(agent, data) |
| ... | ... | @@ -251,7 +251,8 @@ function _M.handleApplyRpc(agent, data) |
| 251 | 251 | if not redisproxy:zscore(FRIEND_APPLY_KEY:format(roleId), objectId) then |
| 252 | 252 | return |
| 253 | 253 | end |
| 254 | - result = checkHandleApply(roleId, objectId) | |
| 254 | + local curCount | |
| 255 | + result, curCount = checkHandleApply(roleId, objectId) | |
| 255 | 256 | |
| 256 | 257 | if not result then |
| 257 | 258 | redisproxy:pipelining(function (red) |
| ... | ... | @@ -277,8 +278,11 @@ function _M.handleApplyRpc(agent, data) |
| 277 | 278 | otherInfo.pGet = redret[2] == 1 and 1 or nil |
| 278 | 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 | 286 | end |
| 283 | 287 | |
| 284 | 288 | elseif cmd == 0 then -- 不同意 |
| ... | ... | @@ -301,7 +305,7 @@ function _M.handleApplyRpc(agent, data) |
| 301 | 305 | local needAddInfo = {} |
| 302 | 306 | for _, objId in ipairs(allIds) do |
| 303 | 307 | objId = tonumber(objId) |
| 304 | - local cr = checkHandleApply(roleId, objId, #needAdd) | |
| 308 | + local cr, curCount = checkHandleApply(roleId, objId, #needAdd) | |
| 305 | 309 | if not cr then |
| 306 | 310 | table.insert(needAdd, objId) |
| 307 | 311 | table.insert(needAddMy, objId) |
| ... | ... | @@ -312,6 +316,12 @@ function _M.handleApplyRpc(agent, data) |
| 312 | 316 | otherInfo.isFriend = true |
| 313 | 317 | otherInfo.pGet = fpoint[objId] and 1 or nil |
| 314 | 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 | 325 | end |
| 316 | 326 | end |
| 317 | 327 | |
| ... | ... | @@ -337,8 +347,6 @@ function _M.handleApplyRpc(agent, data) |
| 337 | 347 | rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({newFriend = 1, info = {myInfo}})) -- 通知对方 |
| 338 | 348 | end |
| 339 | 349 | if next(needAdd) then |
| 340 | - role:log("role_action", {desc = "addFriend", int1 = #needAdd}) | |
| 341 | - | |
| 342 | 350 | SendPacket(actionCodes.Friend_updateProperty, MsgPack.pack({newFriend = 1, info = needAddInfo})) |
| 343 | 351 | else |
| 344 | 352 | result = 1 |
| ... | ... | @@ -420,6 +428,11 @@ function _M.deleteRpc(agent, data) |
| 420 | 428 | end |
| 421 | 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 | 436 | SendPacket(actionCodes.Friend_deleteRpc, MsgPack.pack("")) |
| 424 | 437 | return true |
| 425 | 438 | end |
| ... | ... | @@ -449,15 +462,18 @@ function _M.blockRpc(agent, data) |
| 449 | 462 | red:ZREM(FRIEND_APPLY_KEY:format(objectId), roleId) |
| 450 | 463 | red:sadd(FRIEND_BLACK_KEY:format(roleId), objectId) |
| 451 | 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 | 471 | end |
| 455 | 472 | elseif cmd == 2 then |
| 456 | 473 | redisproxy:SREM(FRIEND_BLACK_KEY:format(roleId), objectId) |
| 457 | 474 | else |
| 458 | 475 | return |
| 459 | 476 | end |
| 460 | - | |
| 461 | 477 | SendPacket(actionCodes.Friend_blockRpc, MsgPack.pack({result = result})) |
| 462 | 478 | return true |
| 463 | 479 | end |
| ... | ... | @@ -537,8 +553,6 @@ function _M.pointRpc(agent, data) |
| 537 | 553 | role.dailyData:updateProperty({field = "giveFP", value = giveP}) |
| 538 | 554 | role:checkTaskEnter("GiveFriendP", {count = 1}) |
| 539 | 555 | rpcRole(objId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({newPoint = 1, roleId = roleId})) |
| 540 | - | |
| 541 | - role:log("role_action", {desc = "giveFPoint", int1 = 1}) | |
| 542 | 556 | end |
| 543 | 557 | elseif cmd == 2 then -- 领取 |
| 544 | 558 | local objId = msg.roleId |
| ... | ... | @@ -558,7 +572,6 @@ function _M.pointRpc(agent, data) |
| 558 | 572 | role.dailyData:updateProperty({field = "getFP", value = getP}) |
| 559 | 573 | role:checkTaskEnter("GetFriendP", {count = 1}) |
| 560 | 574 | |
| 561 | - role:log("role_action", {desc = "getFPoint", int1 = 1}) | |
| 562 | 575 | end |
| 563 | 576 | elseif cmd == 3 then -- 一键赠送领取 |
| 564 | 577 | -- 赠送 |
| ... | ... | @@ -580,8 +593,6 @@ function _M.pointRpc(agent, data) |
| 580 | 593 | role.dailyData:updateProperty({field = "giveFP", value = giveP}) |
| 581 | 594 | role:checkTaskEnter("GiveFriendP", {count = change}) |
| 582 | 595 | |
| 583 | - role:log("role_action", {desc = "giveFPoint", int1 = change}) | |
| 584 | - | |
| 585 | 596 | else |
| 586 | 597 | result = 1 |
| 587 | 598 | end |
| ... | ... | @@ -606,7 +617,6 @@ function _M.pointRpc(agent, data) |
| 606 | 617 | reward = role:award({[ItemId.FriendPoint] = getCount}, {log = {desc = "friendPoint"}}) |
| 607 | 618 | role.dailyData:updateProperty({field = "getFP", value = getP}) |
| 608 | 619 | role:checkTaskEnter("GetFriendP", {count = getCount}) |
| 609 | - role:log("role_action", {desc = "getFPoint", int1 = getCount}) | |
| 610 | 620 | else |
| 611 | 621 | result = (result or 0) + 2 |
| 612 | 622 | end | ... | ... |
src/actions/GmAction.lua
| ... | ... | @@ -27,7 +27,6 @@ function _M.ignoreout(role, pms) |
| 27 | 27 | else -- 解除 |
| 28 | 28 | role:updateProperty({field = "ignoreMt", value = 0}) |
| 29 | 29 | end |
| 30 | - role:log("gm_action", {desc = "ignoreout", key1 = pms.sender}) | |
| 31 | 30 | return "指令生效" |
| 32 | 31 | end |
| 33 | 32 | |
| ... | ... | @@ -47,17 +46,11 @@ function _M.ban(role, pms) |
| 47 | 46 | end) |
| 48 | 47 | end |
| 49 | 48 | end |
| 50 | - | |
| 51 | - role:log("gm_action", {desc = "ban", int1 = time, int2 = ctype, key1 = pms.sender}) | |
| 52 | - | |
| 53 | 49 | return isBan and "解封杀成功" or "封杀成功" |
| 54 | 50 | end |
| 55 | 51 | |
| 56 | 52 | function _M.unban(role, pms) |
| 57 | 53 | role:setBan(0, 0) |
| 58 | - | |
| 59 | - role:log("gm_action", {desc = "unban", key1 = pms.sender}) | |
| 60 | - | |
| 61 | 54 | return "解封杀成功" |
| 62 | 55 | end |
| 63 | 56 | |
| ... | ... | @@ -70,8 +63,6 @@ function _M.gmmsg(role, pms) |
| 70 | 63 | skynet.call(agent.gate_serv, "lua", "forcekick", agent.fd) |
| 71 | 64 | end) |
| 72 | 65 | end |
| 73 | - role:log("gm_action", {desc = "gmmsg", text1 = pms.pm1, key1 = pms.sender}) | |
| 74 | - | |
| 75 | 66 | return "指令成功" |
| 76 | 67 | end |
| 77 | 68 | |
| ... | ... | @@ -82,8 +73,6 @@ function _M.silent(role, pms) |
| 82 | 73 | return "解禁言成功" |
| 83 | 74 | end |
| 84 | 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 | 76 | return "禁言成功" |
| 88 | 77 | end |
| 89 | 78 | |
| ... | ... | @@ -101,8 +90,6 @@ function _M.hero(role, pms) |
| 101 | 90 | if not role:addHero({type = heroType, log = {desc = "gm"}}) then |
| 102 | 91 | return "失败" |
| 103 | 92 | end |
| 104 | - | |
| 105 | - role:log("gm_action", {desc = "hero", int1 = heroType, key1 = pms.sender}) | |
| 106 | 93 | return "成功" |
| 107 | 94 | end |
| 108 | 95 | |
| ... | ... | @@ -135,8 +122,6 @@ function _M.herol(role, pms) |
| 135 | 122 | hero:updateProperty({field = "level", delta = addLevel}) |
| 136 | 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 | 125 | return "成功" |
| 141 | 126 | end |
| 142 | 127 | |
| ... | ... | @@ -148,8 +133,6 @@ function _M.herola(role, pms) |
| 148 | 133 | _M.herol(role, {pm1 = hero:getProperty("type"), pm2 = addLevel}) |
| 149 | 134 | end |
| 150 | 135 | |
| 151 | - role:log("gm_action", {desc = "herola", int1 = addLevel, key1 = pms.sender}) | |
| 152 | - | |
| 153 | 136 | return "成功" |
| 154 | 137 | end |
| 155 | 138 | |
| ... | ... | @@ -160,7 +143,6 @@ function _M.equip(role, pms) |
| 160 | 143 | local level = tonum(pms.pm2) |
| 161 | 144 | local count = tonum(pms.pm3) |
| 162 | 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 | 146 | return "成功" |
| 165 | 147 | end |
| 166 | 148 | |
| ... | ... | @@ -169,7 +151,6 @@ function _M.rune(role, pms) |
| 169 | 151 | local typ = tonum(pms.pm1) |
| 170 | 152 | local id = tonum(pms.pm2) |
| 171 | 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 | 155 | return result |
| 175 | 156 | end |
| ... | ... | @@ -190,8 +171,6 @@ function _M.fb(role, pms) -- 直接通关 |
| 190 | 171 | role:hangFinish(carbonId) |
| 191 | 172 | addPre(carbonId) |
| 192 | 173 | |
| 193 | - role:log("gm_action", {desc = "fb", int1 = carbonId, key1 = pms.sender}) | |
| 194 | - | |
| 195 | 174 | role:checkTaskEnter("HangPass", {id = carbonId}) |
| 196 | 175 | return "成功" |
| 197 | 176 | end |
| ... | ... | @@ -212,8 +191,6 @@ function _M.fbc(role, pms) -- 直接通关 |
| 212 | 191 | end |
| 213 | 192 | role:updateProperty({field = "hangPass", value = {}}) |
| 214 | 193 | addPre(carbonId) |
| 215 | - | |
| 216 | - role:log("gm_action", {desc = "fbc", int1 = carbonId, key1 = pms.sender}) | |
| 217 | 194 | |
| 218 | 195 | return "成功" |
| 219 | 196 | end |
| ... | ... | @@ -247,8 +224,6 @@ function _M.exp(role, pms) |
| 247 | 224 | exp = math.floor(math.max(exp, 0)) |
| 248 | 225 | role:addPlayExp(exp, {log = {desc = "gm"}}) |
| 249 | 226 | |
| 250 | - role:log("gm_action", {desc = "exp", int1 = exp, key1 = pms.sender}) | |
| 251 | - | |
| 252 | 227 | return "成功" |
| 253 | 228 | end |
| 254 | 229 | |
| ... | ... | @@ -305,7 +280,6 @@ function _M.get(role, pms) |
| 305 | 280 | end |
| 306 | 281 | local count = tonum(pms.pm2, 1) |
| 307 | 282 | role:award({[itemId] = count}, {log = {desc = "gm"}}) |
| 308 | - role:log("gm_action", {desc = "get", int1 = itemId, int2 = count, key1 = pms.sender}) | |
| 309 | 283 | end |
| 310 | 284 | return "成功" |
| 311 | 285 | end |
| ... | ... | @@ -329,9 +303,6 @@ function _M.advc(role, pms) |
| 329 | 303 | advAFWear = {}, |
| 330 | 304 | }, notNotify) |
| 331 | 305 | role.advData = nil |
| 332 | - | |
| 333 | - role:log("gm_action", {desc = "advc", key1 = pms.sender}) | |
| 334 | - | |
| 335 | 306 | return "成功" |
| 336 | 307 | end |
| 337 | 308 | |
| ... | ... | @@ -340,8 +311,6 @@ function _M.advf(role, pms) |
| 340 | 311 | role:updateProperty({field = "advC", value = 0}) |
| 341 | 312 | role.dailyData:updateProperty({field = "advElC", value = 0}) |
| 342 | 313 | |
| 343 | - role:log("gm_action", {desc = "advf", key1 = pms.sender}) | |
| 344 | - | |
| 345 | 314 | return "成功" |
| 346 | 315 | end |
| 347 | 316 | |
| ... | ... | @@ -361,7 +330,6 @@ function _M.adv(role, pms) |
| 361 | 330 | advPass[chapterId] = layer |
| 362 | 331 | role:updateProperty({field = "advPass", value = advPass}) |
| 363 | 332 | end |
| 364 | - role:log("gm_action", {desc = "adv", int1 = chapterId, int2 = layer, key1 = pms.sender}) | |
| 365 | 333 | |
| 366 | 334 | return "成功" |
| 367 | 335 | end |
| ... | ... | @@ -388,7 +356,6 @@ function _M.advt(role, pms) |
| 388 | 356 | isEnter = true, |
| 389 | 357 | debugMapId = mapId, |
| 390 | 358 | }) |
| 391 | - role:log("gm_action", {desc = "advt", int1 = chapterId, int2 = layer, key1 = pms.sender}) | |
| 392 | 359 | return "成功" |
| 393 | 360 | end |
| 394 | 361 | |
| ... | ... | @@ -397,8 +364,6 @@ function _M.advl(role, pms) |
| 397 | 364 | local exp = tonum(pms.pm1) |
| 398 | 365 | role:addAdvLvExp(math.max(0, exp)) |
| 399 | 366 | |
| 400 | - role:log("gm_action", {desc = "advl", int1 = exp, key1 = pms.sender}) | |
| 401 | - | |
| 402 | 367 | return "成功" |
| 403 | 368 | end |
| 404 | 369 | |
| ... | ... | @@ -412,7 +377,6 @@ function _M.advcl(role, pms) |
| 412 | 377 | end |
| 413 | 378 | advData.battle.player:addExp(exp) |
| 414 | 379 | advData:saveDB() |
| 415 | - role:log("gm_action", {desc = "advcl", int1 = exp, key1 = pms.sender}) | |
| 416 | 380 | |
| 417 | 381 | return "成功" |
| 418 | 382 | end |
| ... | ... | @@ -422,7 +386,6 @@ function _M.idlec(role, pms) |
| 422 | 386 | role:updateProperty({field = "hangTeam", value = {}}) |
| 423 | 387 | role:updateProperty({field = "hangInfo", value = {}}) |
| 424 | 388 | role:updateProperty({field = "hangBag", value = {}}) |
| 425 | - role:log("gm_action", {desc = "idlec", key1 = pms.sender}) | |
| 426 | 389 | |
| 427 | 390 | role.advData = nil |
| 428 | 391 | return "成功" |
| ... | ... | @@ -447,8 +410,6 @@ function _M.advit(role, pms) |
| 447 | 410 | local itemId = tonum(pms.pm1) |
| 448 | 411 | local count = tonum(pms.pm2) |
| 449 | 412 | reward[itemId] = count |
| 450 | - | |
| 451 | - role:log("gm_action", {desc = "advit", int1 = itemId, int2 = count, key1 = pms.sender}) | |
| 452 | 413 | end |
| 453 | 414 | |
| 454 | 415 | |
| ... | ... | @@ -464,8 +425,6 @@ function _M.tower(role, pms) |
| 464 | 425 | if not csvdb["tower_battleCsv"][level] then return "不存在" end |
| 465 | 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 | 428 | return "成功" |
| 470 | 429 | end |
| 471 | 430 | |
| ... | ... | @@ -484,8 +443,6 @@ function _M.email(role, pms) |
| 484 | 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 | 446 | return "成功" |
| 490 | 447 | end |
| 491 | 448 | |
| ... | ... | @@ -503,7 +460,6 @@ function _M.cguide(role, pms) |
| 503 | 460 | role:updateProperty({field = "funcGuide", value = ""}) |
| 504 | 461 | end |
| 505 | 462 | |
| 506 | - role:log("gm_action", {desc = "cguide", int1 = id, key1 = pms.sender}) | |
| 507 | 463 | return "成功" |
| 508 | 464 | end |
| 509 | 465 | |
| ... | ... | @@ -512,11 +468,17 @@ function _M.helpRpc(agent, data) |
| 512 | 468 | return true |
| 513 | 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 | 480 | function _M.ayncPurchase(role, params) |
| 517 | 481 | return role:handlePurchase(params) or "" |
| 518 | 482 | end |
| 519 | 483 | |
| 520 | - | |
| 521 | - | |
| 522 | 484 | return _M |
| 523 | 485 | \ No newline at end of file | ... | ... |
src/actions/HangAction.lua
| ... | ... | @@ -19,22 +19,29 @@ local _M = {} |
| 19 | 19 | local function checkReward(role) |
| 20 | 20 | local hangInfo = role:getProperty("hangInfo") |
| 21 | 21 | if not hangInfo.carbonId or not hangInfo.coinTime or not hangInfo.itemTime then |
| 22 | - return | |
| 22 | + return false | |
| 23 | 23 | end |
| 24 | 24 | local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] |
| 25 | 25 | local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) |
| 26 | 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 | 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 | 46 | local pool = {} |
| 40 | 47 | for _, temp in pairs(carbonData.item:toArray()) do |
| ... | ... | @@ -48,7 +55,10 @@ local function checkReward(role) |
| 48 | 55 | curIC = curIC + count |
| 49 | 56 | end |
| 50 | 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 | 62 | local selfIC = selfFC * globalCsv.idle_field_limit |
| 53 | 63 | |
| 54 | 64 | local function randomItem() |
| ... | ... | @@ -58,34 +68,42 @@ local function checkReward(role) |
| 58 | 68 | local tempPool = clone(pool) |
| 59 | 69 | while #tempPool > 0 do |
| 60 | 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 | 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 | 96 | else |
| 79 | - --加不了,换别的东西 | |
| 80 | - table.remove(tempPool, idx) | |
| 97 | + items[cur[1]] = items[cur[1]] + cur[2] | |
| 98 | + break | |
| 81 | 99 | end |
| 82 | 100 | else |
| 83 | - items[cur[1]] = items[cur[1]] + cur[2] | |
| 84 | 101 | break |
| 85 | 102 | end |
| 86 | 103 | end |
| 87 | 104 | curIC = curIC + 1 |
| 88 | 105 | end |
| 106 | + | |
| 89 | 107 | for i = 1, itemCount do |
| 90 | 108 | randomItem() |
| 91 | 109 | end |
| ... | ... | @@ -93,6 +111,8 @@ local function checkReward(role) |
| 93 | 111 | if coinCount > 0 or itemCount > 0 then |
| 94 | 112 | return true |
| 95 | 113 | end |
| 114 | + | |
| 115 | + return false | |
| 96 | 116 | end |
| 97 | 117 | |
| 98 | 118 | --开始一个新的关卡 |
| ... | ... | @@ -136,8 +156,6 @@ function _M.startRpc( agent, data ) |
| 136 | 156 | end |
| 137 | 157 | role:updateProperty({field = "hangInfo", value = hangInfo}) |
| 138 | 158 | |
| 139 | - role:log("hang_action", {desc = "startHang", int1 = carbonId}) | |
| 140 | - | |
| 141 | 159 | SendPacket(actionCodes.Hang_startRpc, '') |
| 142 | 160 | return true |
| 143 | 161 | end |
| ... | ... | @@ -187,7 +205,8 @@ function _M.endBattleRpc(agent, data) |
| 187 | 205 | local msg = MsgPack.unpack(data) |
| 188 | 206 | local hangInfo = role:getProperty("hangInfo") |
| 189 | 207 | if not msg.key or msg.key ~= _BattleKey then |
| 190 | - return 1 | |
| 208 | + SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1})) | |
| 209 | + return true | |
| 191 | 210 | end |
| 192 | 211 | local carbonId = msg.carbonId |
| 193 | 212 | local carbonData = csvdb["idle_battleCsv"][carbonId] |
| ... | ... | @@ -203,7 +222,7 @@ function _M.endBattleRpc(agent, data) |
| 203 | 222 | if role:checkHangPass(carbonId) then |
| 204 | 223 | return 4 |
| 205 | 224 | end |
| 206 | - local reward | |
| 225 | + local reward, change | |
| 207 | 226 | if msg.starNum and msg.starNum > 0 then --win |
| 208 | 227 | role:hangFinish(carbonId) |
| 209 | 228 | if carbonData.main ~= 1 then |
| ... | ... | @@ -217,18 +236,38 @@ function _M.endBattleRpc(agent, data) |
| 217 | 236 | for itemId, count in pairs(carbonData.item_clear:toNumMap()) do |
| 218 | 237 | reward[itemId] = count |
| 219 | 238 | end |
| 220 | - reward = role:award(reward, {log = {desc = "hangBattle", int1 = carbonId}}) | |
| 239 | + reward, change = role:award(reward, {log = {desc = "hangBattle", int1 = carbonId}}) | |
| 221 | 240 | |
| 222 | 241 | role:checkTaskEnter("HangPass", {id = carbonId}) |
| 223 | 242 | end |
| 243 | + if hangInfo.carbonId < carbonId then | |
| 244 | + hangInfo.carbonId = carbonId | |
| 245 | + end | |
| 224 | 246 | role:updateProperty({field = "hangInfo", value = hangInfo}) |
| 225 | 247 | |
| 226 | 248 | 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)}) | |
| 249 | + | |
| 250 | + -- 引导 | |
| 251 | + if carbonId == 10101 then | |
| 252 | + role:finishGuide(5) | |
| 253 | + elseif carbonId == 10102 then | |
| 254 | + role:finishGuide(8) | |
| 255 | + elseif carbonId == 10103 then | |
| 256 | + role:finishGuide(9) | |
| 257 | + elseif carbonId == 10220 then | |
| 258 | + role:finishGuide(22) | |
| 259 | + end | |
| 260 | + for _, guideData in pairs(csvdb["guide_unlockCsv"]) do | |
| 261 | + if guideData.type == 3 and guideData.carbonId == carbonId then | |
| 262 | + role:saveGuide(guideData.guideId,1,true) | |
| 263 | + break | |
| 264 | + end | |
| 265 | + end | |
| 228 | 266 | |
| 229 | 267 | SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({ |
| 230 | 268 | starNum = msg.starNum, |
| 231 | 269 | reward = reward, |
| 270 | + change = change, | |
| 232 | 271 | })) |
| 233 | 272 | return true |
| 234 | 273 | end |
| ... | ... | @@ -276,7 +315,7 @@ function _M.getRewardRpc(agent , data) |
| 276 | 315 | checkReward(role) |
| 277 | 316 | local items = role:getProperty("hangBag") |
| 278 | 317 | if not next(items) then return end |
| 279 | - local reward = role:award(items, {log = {desc = "hangReward"}}) | |
| 318 | + local reward, change = role:award(items, {log = {desc = "hangReward"}}) | |
| 280 | 319 | table.clear(items) |
| 281 | 320 | local hangInfo = role:getProperty("hangInfo") |
| 282 | 321 | local nowTime = skynet.timex() |
| ... | ... | @@ -290,71 +329,24 @@ function _M.getRewardRpc(agent , data) |
| 290 | 329 | if reward[ItemId.Gold] then |
| 291 | 330 | role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) |
| 292 | 331 | end |
| 332 | + | |
| 333 | + role:log("residence_reward", { | |
| 334 | + mission_threadid = math.floor(hangInfo.carbonId / 10000), --大关卡ID | |
| 335 | + mission_id = hangInfo.carbonId, --关卡ID | |
| 336 | + mission_type = 100, --关卡类型,见关卡类型枚举表 | |
| 337 | + residence_reward_type = 0, --领取奖励方式,快速(超前领取)记录为1,正常领取记录为0 | |
| 338 | + residence_time = 0, --挂机或排名时长 | |
| 339 | + residence_reward = reward, --获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} | |
| 340 | + }) | |
| 341 | + | |
| 342 | + | |
| 293 | 343 | SendPacket(actionCodes.Hang_getRewardRpc, MsgPack.pack({ |
| 294 | - reward = reward | |
| 344 | + reward = reward, | |
| 345 | + change = change | |
| 295 | 346 | })) |
| 296 | 347 | return true |
| 297 | 348 | end |
| 298 | 349 | |
| 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 | 350 | function _M.quickRpc(agent , data) |
| 359 | 351 | local role = agent.role |
| 360 | 352 | |
| ... | ... | @@ -377,8 +369,9 @@ function _M.quickRpc(agent , data) |
| 377 | 369 | |
| 378 | 370 | local coinCount = math.floor(time / globalCsv.idle_money_produce_cd) |
| 379 | 371 | 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 | |
| 372 | + reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * carbonData.money) | |
| 373 | + reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * carbonData.exp) | |
| 374 | + reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp) | |
| 382 | 375 | |
| 383 | 376 | local pool = {} |
| 384 | 377 | for _, temp in pairs(carbonData.item:toArray()) do |
| ... | ... | @@ -389,13 +382,34 @@ function _M.quickRpc(agent , data) |
| 389 | 382 | reward[cur[1]] = (reward[cur[1]] or 0) + cur[2] |
| 390 | 383 | end |
| 391 | 384 | |
| 392 | - reward = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) | |
| 385 | + local doubleCoef = role.activity:isOpen("DoubleDrop") and 2 or 1 | |
| 386 | + | |
| 387 | + -- 特权卡获取加速获得额外道具 | |
| 388 | + local coef = role.storeData:getProduceItemSpeedCoef() | |
| 389 | + if coef > 1 then | |
| 390 | + for k, cnt in pairs(reward) do | |
| 391 | + reward[k] = math.floor(cnt * coef * doubleCoef) | |
| 392 | + end | |
| 393 | + end | |
| 394 | + | |
| 395 | + local change | |
| 396 | + reward, change = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) | |
| 393 | 397 | if reward[ItemId.Gold] then |
| 394 | 398 | role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) |
| 395 | 399 | end |
| 396 | 400 | role:checkTaskEnter("HangQuick") |
| 401 | + | |
| 402 | + role:log("residence_reward", { | |
| 403 | + mission_threadid = math.floor(hangInfo.carbonId / 10000), --大关卡ID | |
| 404 | + mission_id = hangInfo.carbonId, --关卡ID | |
| 405 | + mission_type = 100, --关卡类型,见关卡类型枚举表 | |
| 406 | + residence_reward_type = 1, --领取奖励方式,快速(超前领取)记录为1,正常领取记录为0 | |
| 407 | + residence_time = time, --挂机或排名时长 | |
| 408 | + residence_reward = reward, --获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} | |
| 409 | + }) | |
| 397 | 410 | SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({ |
| 398 | - reward = reward | |
| 411 | + reward = reward, | |
| 412 | + change = change | |
| 399 | 413 | })) |
| 400 | 414 | return true |
| 401 | 415 | end |
| ... | ... | @@ -447,7 +461,7 @@ function _M.buyBonusCountRpc(agent, data) |
| 447 | 461 | |
| 448 | 462 | if not role:checkItemEnough({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}) then return 2 end |
| 449 | 463 | |
| 450 | - role:costItems({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}, {log = {desc = "buyBonusCount", short1 = btype, int1 = count}}) | |
| 464 | + role:costItems({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}, {log = {desc = "buyBonusCount", int1 = btype, int2 = count}}) | |
| 451 | 465 | bonusC[btype]["b"] = bonusC[btype]["b"] + count |
| 452 | 466 | bonusC[btype]["c"] = bonusC[btype]["c"] - count |
| 453 | 467 | |
| ... | ... | @@ -494,10 +508,13 @@ function _M.endBonusBattleRpc(agent, data) |
| 494 | 508 | local starNum = msg.starNum |
| 495 | 509 | if not role.__bonusBattleCache then return 1 end |
| 496 | 510 | |
| 497 | - if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then return 2 end | |
| 511 | + if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then | |
| 512 | + SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1})) | |
| 513 | + return true | |
| 514 | + end | |
| 498 | 515 | local bonusData = csvdb["bonus_battleCsv"][id] |
| 499 | 516 | |
| 500 | - local reward | |
| 517 | + local reward, change | |
| 501 | 518 | if starNum and starNum > 0 then |
| 502 | 519 | -- 胜利扣除次数 |
| 503 | 520 | local bonusC = role.dailyData:getProperty("bonusC") |
| ... | ... | @@ -511,15 +528,15 @@ function _M.endBonusBattleRpc(agent, data) |
| 511 | 528 | if chance[1] ~= 0 then |
| 512 | 529 | reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] |
| 513 | 530 | end |
| 514 | - reward = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) | |
| 531 | + reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) | |
| 515 | 532 | role:checkTaskEnter("BonusPass", {id = id}) |
| 516 | 533 | end |
| 517 | 534 | |
| 518 | - role:log("hang_action", {desc = "bonusBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id}) | |
| 519 | - | |
| 520 | 535 | SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({ |
| 521 | 536 | starNum = starNum, |
| 522 | - reward = reward})) | |
| 537 | + reward = reward, | |
| 538 | + change = change | |
| 539 | + })) | |
| 523 | 540 | return true |
| 524 | 541 | end |
| 525 | 542 | |
| ... | ... | @@ -534,12 +551,11 @@ function _M.hangGiftRpc(agent, data) |
| 534 | 551 | local hangGift = role:getProperty("hangGift") |
| 535 | 552 | if hangGift[id] then return 2 end |
| 536 | 553 | |
| 537 | - local reward = role:award(carbonData.item_clear_special, {log = {desc = "hangGift", int1 = id}}) | |
| 538 | - role:log("hang_action", {desc = "hangGift", int1 = id}) | |
| 554 | + local reward, change = role:award(carbonData.item_clear_special, {log = {desc = "hangGift", int1 = id}}) | |
| 539 | 555 | |
| 540 | 556 | role:changeUpdates({{type = "hangGift", field = id, value = 1}}) |
| 541 | 557 | |
| 542 | - SendPacket(actionCodes.Hang_hangGiftRpc, MsgPack.pack(reward)) | |
| 558 | + SendPacket(actionCodes.Hang_hangGiftRpc, MsgPack.pack({reward = reward, change = change})) | |
| 543 | 559 | return true |
| 544 | 560 | end |
| 545 | 561 | |
| ... | ... | @@ -577,9 +593,9 @@ function _M.chatLineRpc(agent, data) |
| 577 | 593 | chatline[id] = skynet.timex() |
| 578 | 594 | role:updateProperty({field = "chatline", value = chatline}) |
| 579 | 595 | |
| 580 | - local reward = role:award(idleData.chatline_reward, {log = {desc = "chatline", int1 = id}}) | |
| 596 | + local reward, change = role:award(idleData.chatline_reward, {log = {desc = "chatline", int1 = id}}) | |
| 581 | 597 | |
| 582 | - SendPacket(actionCodes.Hang_chatLineRpc, MsgPack.pack(reward)) | |
| 598 | + SendPacket(actionCodes.Hang_chatLineRpc, MsgPack.pack({reward = reward, change = change})) | |
| 583 | 599 | return true |
| 584 | 600 | end |
| 585 | 601 | ... | ... |
src/actions/HeroAction.lua
| ... | ... | @@ -16,6 +16,18 @@ local table_unpack = table.unpack |
| 16 | 16 | |
| 17 | 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 | 31 | function _M.levelUpRpc( agent, data ) |
| 20 | 32 | local role = agent.role |
| 21 | 33 | local msg = MsgPack.unpack(data) |
| ... | ... | @@ -28,9 +40,23 @@ function _M.levelUpRpc( agent, data ) |
| 28 | 40 | local cost = {[ItemId.Exp] = curData.exp, [ItemId.Gold] = curData.gold} |
| 29 | 41 | if not role:checkItemEnough(cost) then return 3 end |
| 30 | 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 | 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 | 61 | role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")}) |
| 36 | 62 | SendPacket(actionCodes.Hero_levelUpRpc, '') |
| ... | ... | @@ -49,9 +75,15 @@ function _M.breakRpc( agent, data ) |
| 49 | 75 | local cost = {[ItemId.BreakCost] = curData.cost, [ItemId.Gold] = curData.gold} |
| 50 | 76 | if not role:checkItemEnough(cost) then return 4 end |
| 51 | 77 | role:costItems(cost, {log = {desc = "heroBreak", int1 = msg.id, int2 = hero:getProperty("type")}}) |
| 78 | + local oldAttr = hero:getTotalAttrs() | |
| 52 | 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 | 88 | SendPacket(actionCodes.Hero_breakRpc, '') |
| 57 | 89 | return true |
| ... | ... | @@ -74,6 +106,7 @@ function _M.wakeRpc(agent, data) |
| 74 | 106 | |
| 75 | 107 | role:costItems(cost, {log = {desc = "heroWake", int1 = msg.id, int2 = hero:getProperty("type")}}) |
| 76 | 108 | |
| 109 | + local oldAttr = hero:getTotalAttrs() | |
| 77 | 110 | hero:updateProperty({field = "wakeL", delta = 1}) |
| 78 | 111 | |
| 79 | 112 | local curLevel = hero:getProperty("wakeL") |
| ... | ... | @@ -81,9 +114,14 @@ function _M.wakeRpc(agent, data) |
| 81 | 114 | if curLevel == 4 then -- 解锁cg |
| 82 | 115 | role:checkTaskEnter("WakeCG", {heroType = typ}) |
| 83 | 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 | 125 | SendPacket(actionCodes.Hero_wakeRpc, '') |
| 88 | 126 | return true |
| 89 | 127 | end |
| ... | ... | @@ -103,7 +141,10 @@ function _M.talentRpc(agent, data) |
| 103 | 141 | local curStage = talent:getv(0, 1) |
| 104 | 142 | local curData = csvdb["unit_talentCsv"][curStage] |
| 105 | 143 | if not curData then return 4 end |
| 144 | + local oldSkillLv = hero:getSkillLevel(1) | |
| 145 | + | |
| 106 | 146 | |
| 147 | + local cost = {} | |
| 107 | 148 | if index == 0 then |
| 108 | 149 | --是否进阶 |
| 109 | 150 | local max = true |
| ... | ... | @@ -131,7 +172,7 @@ function _M.talentRpc(agent, data) |
| 131 | 172 | |
| 132 | 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 | 176 | local cost2 = talentData.cost:toNumMap() |
| 136 | 177 | for k,v in pairs(cost2) do |
| 137 | 178 | cost[globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp][k]] = v |
| ... | ... | @@ -152,7 +193,12 @@ function _M.talentRpc(agent, data) |
| 152 | 193 | |
| 153 | 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 | 203 | SendPacket(actionCodes.Hero_talentRpc, '') |
| 158 | 204 | return true |
| ... | ... | @@ -252,6 +298,14 @@ function _M.commentHeroRpc(agent, data) |
| 252 | 298 | comment.like = 0 |
| 253 | 299 | result.comment = comment |
| 254 | 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 | 309 | end |
| 256 | 310 | SendPacket(actionCodes.Hero_commentHeroRpc, MsgPack.pack(result)) |
| 257 | 311 | return true |
| ... | ... | @@ -322,7 +376,7 @@ function _M.likeCommentRpc(agent, data) |
| 322 | 376 | local commentIndex = heroType .. ":" .. commentId |
| 323 | 377 | local commentRoleKey = string.format("comment:%d:like", role:getProperty("id")) |
| 324 | 378 | local redret = redisproxy:pipelining(function (red) |
| 325 | - red:hexists(commentKey.commentKey, commentId) | |
| 379 | + red:hget(commentKey.commentKey, commentId) | |
| 326 | 380 | red:lrem(commentRoleKey, 1, commentIndex) |
| 327 | 381 | red:lpush(commentRoleKey, commentIndex) |
| 328 | 382 | red:ltrim(commentRoleKey, 0, 999) |
| ... | ... | @@ -330,7 +384,8 @@ function _M.likeCommentRpc(agent, data) |
| 330 | 384 | if (tonumber(redret[2]) or 0) > 0 then |
| 331 | 385 | result.status = 1 |
| 332 | 386 | else |
| 333 | - if redret[1] == 1 then-- 查不到也返回ture | |
| 387 | + if redret[1] then-- 查不到也返回ture | |
| 388 | + local comment = json.decode(redret[1]) | |
| 334 | 389 | local redret2 = redisproxy:pipelining(function (red) |
| 335 | 390 | red:zrevrange(commentKey.commentRankKey, 0, RankLikeNum - 1) --热门 |
| 336 | 391 | red:zincrby(commentKey.commentRankKey, add, commentId) |
| ... | ... | @@ -356,6 +411,13 @@ function _M.likeCommentRpc(agent, data) |
| 356 | 411 | red:lrem(commentKey.commentListKey, 0, tempId) |
| 357 | 412 | end |
| 358 | 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 | 421 | end |
| 360 | 422 | end |
| 361 | 423 | |
| ... | ... | @@ -363,108 +425,6 @@ function _M.likeCommentRpc(agent, data) |
| 363 | 425 | return true |
| 364 | 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 | 428 | function _M.createHeroRpc(agent, data) |
| 469 | 429 | local role = agent.role |
| 470 | 430 | local msg = MsgPack.unpack(data) |
| ... | ... | @@ -493,6 +453,7 @@ function _M.referEquipsRpc(agent, data) |
| 493 | 453 | local hero = role.heros[msg.id] |
| 494 | 454 | if not hero then return 10 end |
| 495 | 455 | local equips = msg.equips |
| 456 | + local isAuto = msg.isAuth | |
| 496 | 457 | if not equips or not next(equips) then return 11 end |
| 497 | 458 | |
| 498 | 459 | for typ = 1, 4 do -- 4件装备 |
| ... | ... | @@ -502,6 +463,11 @@ function _M.referEquipsRpc(agent, data) |
| 502 | 463 | end |
| 503 | 464 | end |
| 504 | 465 | end |
| 466 | + | |
| 467 | + local oldAttr = hero:getTotalAttrs() | |
| 468 | + local oldBattleV = hero:getProperty("battleV") | |
| 469 | + local wear = {} | |
| 470 | + | |
| 505 | 471 | local curEquip = hero:getProperty("equip") |
| 506 | 472 | for typ = 1, 4 do -- 4件装备 |
| 507 | 473 | if equips[typ] then |
| ... | ... | @@ -512,17 +478,37 @@ function _M.referEquipsRpc(agent, data) |
| 512 | 478 | else |
| 513 | 479 | role:addEquip(typ, equips[typ], -1, {log = {desc = "refer"}}) -- 穿上 |
| 514 | 480 | curEquip = curEquip:setv(typ, equips[typ]) |
| 481 | + | |
| 482 | + wear[typ] = {id = equips[typ], act = 0} | |
| 515 | 483 | end |
| 516 | 484 | |
| 517 | 485 | if cur ~= 0 then |
| 518 | 486 | role:addEquip(typ, cur, 1, {log = {desc = "refer"}}) -- 脱掉 |
| 487 | + | |
| 488 | + wear[typ] = {id = cur, act = 1} | |
| 519 | 489 | end |
| 520 | 490 | end |
| 521 | 491 | end |
| 522 | 492 | end |
| 493 | + | |
| 523 | 494 | -- 更新角色 |
| 524 | 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 | 512 | SendPacket(actionCodes.Hero_referEquipsRpc, "") |
| 527 | 513 | return true |
| 528 | 514 | end |
| ... | ... | @@ -559,6 +545,9 @@ function _M.referRunesRpc(agent, data) |
| 559 | 545 | chero:updateProperty({field = "rune", value = hrunes}) |
| 560 | 546 | end |
| 561 | 547 | |
| 548 | + local oldAttr = hero:getTotalAttrs() | |
| 549 | + local oldBattleV = hero:getProperty("battleV") | |
| 550 | + local wear = {} | |
| 562 | 551 | local curRune = hero:getProperty("rune") |
| 563 | 552 | for typ = 1, 6 do |
| 564 | 553 | if runes[typ] then |
| ... | ... | @@ -570,6 +559,7 @@ function _M.referRunesRpc(agent, data) |
| 570 | 559 | local newRune = role.runeBag[runes[typ]] |
| 571 | 560 | newRune:updateProperty({field = "refer",value = hero:getProperty("id")}) |
| 572 | 561 | curRune = curRune:setv(typ, runes[typ]) |
| 562 | + wear[runes[typ]] = typ | |
| 573 | 563 | end |
| 574 | 564 | |
| 575 | 565 | if cur ~= 0 then |
| ... | ... | @@ -581,7 +571,22 @@ function _M.referRunesRpc(agent, data) |
| 581 | 571 | end |
| 582 | 572 | end |
| 583 | 573 | end |
| 574 | + | |
| 584 | 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 | 590 | SendPacket(actionCodes.Hero_referRunesRpc, "") |
| 586 | 591 | return true |
| 587 | 592 | end |
| ... | ... | @@ -600,15 +605,12 @@ function _M.createHeroRandomRpc(agent, data) |
| 600 | 605 | |
| 601 | 606 | local temp = randomData.gift1:randWeight(true) |
| 602 | 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 | 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 | 614 | return true |
| 613 | 615 | end |
| 614 | 616 | |
| ... | ... | @@ -672,27 +674,33 @@ function _M.getResetRewardRpc(agent, data) |
| 672 | 674 | hero:updateProperty({field = "level", value = level}) |
| 673 | 675 | hero:updateProperty({field = "breakL", value = breakL}) |
| 674 | 676 | hero:updateProperty({field = "talent", value = ""}) |
| 675 | - hero:log({desc = "resetHero"}) | |
| 676 | 677 | |
| 677 | 678 | for itemId, count in pairs(reward) do |
| 678 | 679 | reward[itemId] = math.floor(count * globalCsv.unit_back_discount) |
| 679 | 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 | 690 | return true |
| 684 | 691 | end |
| 685 | 692 | |
| 686 | - | |
| 687 | - | |
| 688 | 693 | function _M.drawHeroRpc(agent, data) |
| 689 | 694 | local role = agent.role |
| 690 | 695 | local msg = MsgPack.unpack(data) |
| 691 | 696 | |
| 692 | 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 | 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 | 705 | local buildTypeData = csvdb["build_typeCsv"][btype] |
| 698 | 706 | if not buildTypeData then return 1 end |
| ... | ... | @@ -700,12 +708,10 @@ function _M.drawHeroRpc(agent, data) |
| 700 | 708 | local drawCount = {1, 10} -- 抽取次数 |
| 701 | 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 | 715 | local cost = {} |
| 710 | 716 | local lastCount = drawCount[drawType] |
| 711 | 717 | for _, costType in ipairs({"draw_card", "draw_coin"}) do |
| ... | ... | @@ -727,44 +733,36 @@ function _M.drawHeroRpc(agent, data) |
| 727 | 733 | return 3 |
| 728 | 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 | 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 | 747 | end |
| 754 | 748 | end |
| 755 | - if type(pool) ~= "number" then | |
| 756 | - pool = -1 | |
| 757 | - end | |
| 758 | - end | |
| 759 | 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 | 758 | if not unitPool then return 4 end |
| 762 | 759 | |
| 763 | 760 | -- 开始抽 |
| 764 | 761 | local resultPool = {} |
| 765 | - local function fillDrawPool(fixRare, fixCamp, ssrUp, floorBack) | |
| 762 | + local function fillDrawPool(isFloorBack) | |
| 766 | 763 | local condition = {"rare", "camp"} |
| 767 | - local values = {fixRare, fixCamp} | |
| 764 | + local values = {} | |
| 765 | + | |
| 768 | 766 | |
| 769 | 767 | for idx, field in ipairs(condition) do |
| 770 | 768 | if not values[idx] then |
| ... | ... | @@ -775,44 +773,30 @@ function _M.drawHeroRpc(agent, data) |
| 775 | 773 | curIdx = curIdx + 1 |
| 776 | 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 | 776 | if next(lpool) then |
| 797 | 777 | values[idx] = math.randWeight(lpool, 1) |
| 798 | 778 | end |
| 799 | 779 | end |
| 800 | 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 | 785 | local itemData = csvdb["itemCsv"][itemId] |
| 805 | 786 | while itemData do |
| 806 | 787 | if itemData.type ~= ItemType.Hero then break end |
| 807 | 788 | local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] |
| 808 | 789 | if not heroData then break end |
| 809 | 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 | 796 | end |
| 813 | 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 | 800 | end |
| 817 | 801 | break |
| 818 | 802 | end |
| ... | ... | @@ -820,61 +804,37 @@ function _M.drawHeroRpc(agent, data) |
| 820 | 804 | end |
| 821 | 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:checkOverGuide(11) and not role:checkOverGuide(12) then | |
| 811 | + guideHero = 613 | |
| 834 | 812 | end |
| 835 | 813 | |
| 836 | 814 | local ssrCount = 0 |
| 837 | 815 | local reward = {} |
| 838 | 816 | for i = 1, drawCount[drawType] do |
| 839 | 817 | floorHeroCount = floorHeroCount + 1 |
| 840 | - if btype == 4 then | |
| 841 | - newerDrawCount = newerDrawCount + 1 | |
| 842 | - end | |
| 843 | - | |
| 844 | - resultPool = {} | |
| 845 | 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 | 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 | 830 | end |
| 863 | 831 | |
| 864 | - -- 引导必送 613 丝路德 | |
| 865 | - local itemId = (guide and drawType == 1) and 613 or math.randWeight(resultPool, 1) | |
| 866 | 832 | local itemData = csvdb["itemCsv"][itemId] |
| 867 | - if itemData.quality == 4 then | |
| 833 | + if itemData.quality == HeroQuality.SSR then | |
| 868 | 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 | 835 | end |
| 876 | 836 | |
| 877 | - if itemData.quality >= 3 then | |
| 837 | + if itemData.quality >= HeroQuality.SR then | |
| 878 | 838 | floorHeroCount = 0 |
| 879 | 839 | end |
| 880 | 840 | |
| ... | ... | @@ -882,10 +842,10 @@ function _M.drawHeroRpc(agent, data) |
| 882 | 842 | local fragId = itemData.id - ItemStartId.Hero |
| 883 | 843 | local heroData = csvdb["unitCsv"][fragId] |
| 884 | 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 | 846 | table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1}) |
| 887 | 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 | 849 | table.insert(reward, {id = itemId, count = 1}) |
| 890 | 850 | end |
| 891 | 851 | end |
| ... | ... | @@ -896,59 +856,105 @@ function _M.drawHeroRpc(agent, data) |
| 896 | 856 | role:setProperty("floorHero", floorHero) |
| 897 | 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 | 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 | 865 | role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) |
| 918 | 866 | if ssrCount > 0 then |
| 919 | 867 | role:checkTaskEnter("DrawSSR", {count = ssrCount}) |
| 920 | 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 | 879 | SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 |
| 923 | 880 | return true |
| 924 | 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.changeCrownRpc(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 end | |
| 951 | + role:setProperty("crown", heroType) | |
| 952 | + | |
| 953 | + role:log("hero_show", { | |
| 954 | + hero_id = heroType, | |
| 955 | + }) | |
| 956 | + SendPacket(actionCodes.Hero_changeCrownRpc, "") | |
| 957 | + return true | |
| 958 | +end | |
| 953 | 959 | |
| 954 | 960 | return _M |
| 955 | 961 | \ No newline at end of file | ... | ... |
src/actions/HttpAction.lua
| ... | ... | @@ -148,13 +148,32 @@ function _M.gm_action(query) |
| 148 | 148 | end |
| 149 | 149 | |
| 150 | 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 | 177 | return "广播成功" |
| 159 | 178 | end |
| 160 | 179 | ... | ... |
src/actions/PvpAction.lua
| ... | ... | @@ -287,7 +287,7 @@ function _M.startBattleRpc(agent, data) |
| 287 | 287 | if pvpFree >= globalCsv.pvp_battle_free_count then |
| 288 | 288 | local cost = {[ItemId.PvpKey] = 1} |
| 289 | 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 | 291 | else |
| 292 | 292 | role.dailyData:updateProperty({field = "pvpFree", delta = 1}) |
| 293 | 293 | end |
| ... | ... | @@ -296,9 +296,6 @@ function _M.startBattleRpc(agent, data) |
| 296 | 296 | _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge} |
| 297 | 297 | |
| 298 | 298 | role:checkTaskEnter("PvpBattle") |
| 299 | - | |
| 300 | - | |
| 301 | - role:log("pvp_action", {desc = "startBattle", short1 = 1, int1 = revenge and 1 or 0}) | |
| 302 | 299 | end |
| 303 | 300 | |
| 304 | 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 | 308 | local msg = MsgPack.unpack(data) |
| 312 | 309 | |
| 313 | 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 | 313 | end |
| 316 | 314 | |
| 317 | 315 | if not msg.idx or msg.idx ~= _pvpStartBattleCacheC.idx then |
| ... | ... | @@ -334,7 +332,7 @@ function _M.endBattleRpc(agent, data) |
| 334 | 332 | if not match then return end |
| 335 | 333 | |
| 336 | 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 | 336 | local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin) |
| 339 | 337 | |
| 340 | 338 | _pvpBattleInfoCacheC = {} --重新发阵容了 没毛病 |
| ... | ... | @@ -349,12 +347,13 @@ function _M.endBattleRpc(agent, data) |
| 349 | 347 | ["time"] = now, |
| 350 | 348 | } |
| 351 | 349 | local status, body = httpc.get(remoteUrl, "/applyvideo?" .. httpGetFormatData(params), {}, {}) |
| 352 | - local video = nil | |
| 350 | + local video, headers = nil, nil | |
| 353 | 351 | if tonumber(status) == 200 then |
| 354 | 352 | local result = json.decode(body) |
| 355 | 353 | video = result.name |
| 354 | + headers = result.headers | |
| 356 | 355 | else |
| 357 | - skynet.error("applyvideo", "error", status, body, content) | |
| 356 | + skynet.error("applyvideo", "error", status, body) | |
| 358 | 357 | end |
| 359 | 358 | |
| 360 | 359 | -- 加入战斗记录 |
| ... | ... | @@ -389,11 +388,10 @@ function _M.endBattleRpc(agent, data) |
| 389 | 388 | if isWin then |
| 390 | 389 | role:checkTaskEnter("PvpWin", {score = myScore}) |
| 391 | 390 | end |
| 392 | - | |
| 393 | - role:log("pvp_action", {desc = "battleEnd", short1 = 1, int1 = isWin and 1 or 0, int2 = revenge and 1 or 0}) | |
| 394 | 391 | |
| 395 | 392 | SendPacket(actionCodes.Pvp_endBattleRpc, MsgPack.pack({ |
| 396 | 393 | reward = reward, |
| 394 | + change = change, | |
| 397 | 395 | myScore = myScore, |
| 398 | 396 | matchScore = matchScore, |
| 399 | 397 | oldmyScore = oldmyScore, |
| ... | ... | @@ -401,6 +399,7 @@ function _M.endBattleRpc(agent, data) |
| 401 | 399 | myRank = myRank, |
| 402 | 400 | oldMyRank = oldMyRank, |
| 403 | 401 | video = video, |
| 402 | + headers = headers, | |
| 404 | 403 | })) |
| 405 | 404 | return true |
| 406 | 405 | end |
| ... | ... | @@ -490,7 +489,7 @@ function _M.startBattleHRpc(agent, data) |
| 490 | 489 | if pvpFreeH >= globalCsv.pvp_battle_free_count_high then |
| 491 | 490 | local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost} |
| 492 | 491 | if not role:checkItemEnough(cost) then return 5 end |
| 493 | - role:costItems(cost, {log = {desc = "startPvp", short1 = 2}}) | |
| 492 | + role:costItems(cost, {log = {desc = "startPvp", int1 = 2}}) | |
| 494 | 493 | else |
| 495 | 494 | role.dailyData:updateProperty({field = "pvpFreeH", delta = 1}) |
| 496 | 495 | end |
| ... | ... | @@ -516,8 +515,6 @@ function _M.startBattleHRpc(agent, data) |
| 516 | 515 | |
| 517 | 516 | role:checkTaskEnter("PvpBattle") |
| 518 | 517 | |
| 519 | - role:log("pvp_action", {desc = "startBattle", short1 = 2, int1 = revenge and 1 or 0}) | |
| 520 | - | |
| 521 | 518 | end |
| 522 | 519 | |
| 523 | 520 | SendPacket(actionCodes.Pvp_startBattleHRpc, MsgPack.pack({ |
| ... | ... | @@ -536,7 +533,8 @@ function _M.endBattleHRpc(agent, data) |
| 536 | 533 | local msg = MsgPack.unpack(data) |
| 537 | 534 | |
| 538 | 535 | if not msg.key or not _pvpStartBattleCacheH or msg.key ~= _pvpStartBattleCacheH.key then |
| 539 | - return 1 | |
| 536 | + SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({errorCode = 1})) | |
| 537 | + return true | |
| 540 | 538 | end |
| 541 | 539 | |
| 542 | 540 | if not msg.idx or msg.idx ~= _pvpStartBattleCacheH.idx then |
| ... | ... | @@ -565,12 +563,13 @@ function _M.endBattleHRpc(agent, data) |
| 565 | 563 | ["time"] = now, |
| 566 | 564 | } |
| 567 | 565 | local status, body = httpc.get(remoteUrl, "/applyvideo?" .. httpGetFormatData(params), {}, {}) |
| 568 | - local video = nil | |
| 566 | + local video, headers = nil, nil | |
| 569 | 567 | if tonumber(status) == 200 then |
| 570 | 568 | local result = json.decode(body) |
| 571 | 569 | video = result.name |
| 570 | + headers = result.headers | |
| 572 | 571 | else |
| 573 | - skynet.error("applyvideo", "error", status, body, content) | |
| 572 | + skynet.error("applyvideo", "error", status, body) | |
| 574 | 573 | end |
| 575 | 574 | |
| 576 | 575 | table.insert(_pvpStartBattleCacheH.result, { |
| ... | ... | @@ -611,13 +610,14 @@ function _M.endBattleHRpc(agent, data) |
| 611 | 610 | key = key, --战斗校验 key |
| 612 | 611 | round = round, -- 战斗场数索引 |
| 613 | 612 | video = video, -- 返回让客户端上传录像 |
| 613 | + headers = headers, | |
| 614 | 614 | })) |
| 615 | 615 | return true |
| 616 | 616 | end |
| 617 | 617 | |
| 618 | 618 | -- 战斗结束了发奖 |
| 619 | 619 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true) |
| 620 | - local reward = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleH"}}) | |
| 620 | + local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleH"}}) | |
| 621 | 621 | local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, 0, 0 |
| 622 | 622 | if role:isTimeResetOpen(TimeReset.PvpHight) then |
| 623 | 623 | myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin) |
| ... | ... | @@ -686,10 +686,10 @@ function _M.endBattleHRpc(agent, data) |
| 686 | 686 | if isWin then |
| 687 | 687 | role:checkTaskEnter("PvpWin", {score = myScore}) |
| 688 | 688 | end |
| 689 | - role:log("pvp_action", {desc = "battleEnd", short1 = 2, int1 = isWin and 1 or 0, int2 = revenge and 1 or 0}) | |
| 690 | 689 | |
| 691 | 690 | SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({ |
| 692 | 691 | reward = reward, |
| 692 | + change = change, | |
| 693 | 693 | myScore = myScore, |
| 694 | 694 | matchScore = matchScore, |
| 695 | 695 | oldmyScore = oldmyScore, |
| ... | ... | @@ -833,10 +833,9 @@ function _M.highDivisionGiftRpc(agent, data) |
| 833 | 833 | pvpHGift = {}, |
| 834 | 834 | }) |
| 835 | 835 | |
| 836 | - local reward = role:award(newReward, {log = {desc = "pvpDivisionH"}}) | |
| 837 | - role:log("pvp_action", {desc = "pvpDivisionH"}) | |
| 836 | + local reward, change = role:award(newReward, {log = {desc = "pvpDivisionH"}}) | |
| 838 | 837 | |
| 839 | - SendPacket(actionCodes.Pvp_highDivisionGiftRpc, MsgPack.pack({reward = reward})) | |
| 838 | + SendPacket(actionCodes.Pvp_highDivisionGiftRpc, MsgPack.pack(role:packReward(reward, change))) | |
| 840 | 839 | return true |
| 841 | 840 | end |
| 842 | 841 | |
| ... | ... | @@ -867,11 +866,9 @@ function _M.shopBuyRpc(agent, data) |
| 867 | 866 | for id, c in pairs(gift) do |
| 868 | 867 | gift[id] = c * count |
| 869 | 868 | 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}) | |
| 869 | + local reward, change = role:award(gift, {log = {desc = "pvpShop", int1 = id, int2 = count}}) | |
| 873 | 870 | |
| 874 | - SendPacket(actionCodes.Pvp_shopBuyRpc, MsgPack.pack({reward = reward})) | |
| 871 | + SendPacket(actionCodes.Pvp_shopBuyRpc, MsgPack.pack(role:packReward(reward, change))) | |
| 875 | 872 | return true |
| 876 | 873 | end |
| 877 | 874 | |
| ... | ... | @@ -962,7 +959,6 @@ function _M.crossBetRpc(agent, data) |
| 962 | 959 | local result, code = role:setCrossServerPvpBet(msg.idx) |
| 963 | 960 | if not result then return 10 + code end |
| 964 | 961 | |
| 965 | - role:log("pvp_action", {desc = "crossBet"}) | |
| 966 | 962 | SendPacket(actionCodes.Pvp_crossBetRpc, MsgPack.pack(result)) |
| 967 | 963 | return true |
| 968 | 964 | end | ... | ... |
src/actions/RoleAction.lua
| ... | ... | @@ -95,11 +95,33 @@ function _M.loginRpc( agent, data ) |
| 95 | 95 | role:load() |
| 96 | 96 | role:loadAll() |
| 97 | 97 | role:startActionUcode() |
| 98 | - role:setProperty("ltime", now) | |
| 99 | 98 | else |
| 100 | 99 | role:reloadWhenLogin() |
| 101 | 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 | 125 | if not msg.isGMlogin then |
| 104 | 126 | local banTime = role:getProperty("banTime") |
| 105 | 127 | if banTime > now then |
| ... | ... | @@ -115,6 +137,20 @@ function _M.loginRpc( agent, data ) |
| 115 | 137 | role:setBan(0) |
| 116 | 138 | end |
| 117 | 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 | 154 | SERV_OPEN = redisproxy:hget("autoincrement_set", "server_start") |
| 119 | 155 | |
| 120 | 156 | role:changeStructVersion() -- 数据结构 版本更新 |
| ... | ... | @@ -128,8 +164,10 @@ function _M.loginRpc( agent, data ) |
| 128 | 164 | |
| 129 | 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 | 168 | response[name] = role[name]:data() |
| 169 | + --print("["..name.."]") | |
| 170 | + --dump(response[name]) | |
| 133 | 171 | end |
| 134 | 172 | |
| 135 | 173 | response.role = role:data() |
| ... | ... | @@ -252,7 +290,7 @@ function _M.loginRpc( agent, data ) |
| 252 | 290 | role:savePvpHTeam() |
| 253 | 291 | |
| 254 | 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 | 295 | return true |
| 258 | 296 | end |
| ... | ... | @@ -285,7 +323,8 @@ function _M.createRpc(agent, data) |
| 285 | 323 | sid = msg.subId or 0, |
| 286 | 324 | name = roleName, |
| 287 | 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 | 330 | if newRole:create() then |
| ... | ... | @@ -299,11 +338,20 @@ function _M.createRpc(agent, data) |
| 299 | 338 | return true |
| 300 | 339 | end |
| 301 | 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 | 346 | newRole:award(globalCsv.birthItem, {log = {desc = "birth"}, notNotify = true}) |
| 303 | 347 | -- 欢迎邮件 |
| 304 | 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 | 356 | SendPacket(actionCodes.Role_createRpc, MsgPack.pack(response)) |
| 309 | 357 | return true |
| ... | ... | @@ -405,12 +453,22 @@ function _M.saleItemRpc(agent, data) |
| 405 | 453 | end |
| 406 | 454 | local sellEffect = itemData.sell_effect:toArray(true, "=") |
| 407 | 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 | 465 | end |
| 409 | 466 | |
| 410 | 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 | 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 | 472 | return true |
| 415 | 473 | end |
| 416 | 474 | |
| ... | ... | @@ -447,9 +505,10 @@ function _M.openItemRpc(agent, data) |
| 447 | 505 | reward[0] = nil |
| 448 | 506 | |
| 449 | 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 | 512 | return true |
| 454 | 513 | end |
| 455 | 514 | |
| ... | ... | @@ -458,10 +517,15 @@ function _M.openTimeBoxRpc(agent, data) |
| 458 | 517 | local msg = MsgPack.unpack(data) |
| 459 | 518 | local oper = msg.oper -- 操作 1 - 2 |
| 460 | 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 | 527 | local boxL = role:getProperty("boxL") |
| 464 | - local reward = {} | |
| 528 | + local reward, change = {} | |
| 465 | 529 | if oper == 1 then -- 打开 |
| 466 | 530 | local itemId = msg.itemId |
| 467 | 531 | if role:getItemCount(itemId) < 1 then return end |
| ... | ... | @@ -476,12 +540,14 @@ function _M.openTimeBoxRpc(agent, data) |
| 476 | 540 | elseif oper == 2 then -- 领取 |
| 477 | 541 | local quick = msg.quick |
| 478 | 542 | if not boxL[slot] then return end |
| 543 | + local costKey = 0 | |
| 544 | + local costTime = skynet.timex() - boxL[slot].time | |
| 479 | 545 | if boxL[slot].time > skynet.timex() then -- 没开完 |
| 480 | 546 | if not quick then return end |
| 481 | 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 | 551 | end |
| 486 | 552 | local boxId = boxL[slot].id |
| 487 | 553 | local itemData = csvdb["itemCsv"][boxId] |
| ... | ... | @@ -509,15 +575,26 @@ function _M.openTimeBoxRpc(agent, data) |
| 509 | 575 | reward[0] = nil |
| 510 | 576 | |
| 511 | 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 | 591 | else |
| 515 | 592 | return |
| 516 | 593 | end |
| 517 | 594 | |
| 518 | 595 | role:setProperty("boxL") --刷新 |
| 519 | 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 | 598 | return true |
| 522 | 599 | end |
| 523 | 600 | |
| ... | ... | @@ -568,9 +645,10 @@ function _M.openSpeedUpBoxRpc(agent, data) |
| 568 | 645 | end |
| 569 | 646 | |
| 570 | 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 | 652 | return true |
| 575 | 653 | end |
| 576 | 654 | |
| ... | ... | @@ -596,8 +674,17 @@ function _M.storyBookRewardRpc(agent, data) |
| 596 | 674 | storyStatus[storyId] = storyStatus[storyId] or {} |
| 597 | 675 | storyStatus[storyId].s = -1 |
| 598 | 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 | 688 | return true |
| 602 | 689 | end |
| 603 | 690 | |
| ... | ... | @@ -633,7 +720,7 @@ function _M.taskRpc(agent, data) |
| 633 | 720 | |
| 634 | 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 | 724 | local taskId = msg.id --任务id |
| 638 | 725 | local roleField = {"dTask", "wTask"} |
| 639 | 726 | if not roleField[taskType] then return 1 end |
| ... | ... | @@ -648,15 +735,24 @@ function _M.taskRpc(agent, data) |
| 648 | 735 | return 3 |
| 649 | 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 | 739 | local active = (taskStatus["a"] or 0) + taskData.active |
| 653 | 740 | |
| 654 | 741 | role:changeUpdates({ |
| 655 | 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 | 756 | return true |
| 661 | 757 | end |
| 662 | 758 | |
| ... | ... | @@ -681,12 +777,12 @@ function _M.taskActiveRpc(agent, data) |
| 681 | 777 | return |
| 682 | 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 | 781 | role:changeUpdates({ |
| 686 | 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 | 786 | return true |
| 691 | 787 | end |
| 692 | 788 | |
| ... | ... | @@ -712,7 +808,7 @@ function _M.achiveRpc(agent, data) |
| 712 | 808 | return 3 |
| 713 | 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 | 812 | role:changeUpdates({ |
| 717 | 813 | { type = "achiveV", field = taskId, value = skynet.timex() } |
| 718 | 814 | }) |
| ... | ... | @@ -745,7 +841,13 @@ function _M.achiveRpc(agent, data) |
| 745 | 841 | end |
| 746 | 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 | 851 | return true |
| 750 | 852 | end |
| 751 | 853 | |
| ... | ... | @@ -863,6 +965,13 @@ function _M.chatRpc(agent, data) |
| 863 | 965 | if not result then |
| 864 | 966 | check[cmd]() |
| 865 | 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 | 975 | SendPacket(actionCodes.Role_chatRpc, MsgPack.pack({result = result, waitTime = waitTime})) |
| 867 | 976 | return true |
| 868 | 977 | end |
| ... | ... | @@ -891,8 +1000,6 @@ function _M.changeSettingRpc(agent, data) |
| 891 | 1000 | setting[id] = status |
| 892 | 1001 | role:updateProperty({field = "setting", value = setting}) |
| 893 | 1002 | |
| 894 | - role:log("role_action", {desc = "changeSetting", int1 = id, int2 = status}) | |
| 895 | - | |
| 896 | 1003 | SendPacket(actionCodes.Role_changeSettingRpc, '') |
| 897 | 1004 | return true |
| 898 | 1005 | end |
| ... | ... | @@ -921,11 +1028,19 @@ function _M.drawCodeRpc(agent, data) |
| 921 | 1028 | if ret == 0 then |
| 922 | 1029 | local giftId = tonumber(result.giftId) |
| 923 | 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 | 1040 | SendPacket(actionCodes.Role_drawCodeRpc, MsgPack.pack({ |
| 927 | 1041 | result = ret, |
| 928 | 1042 | reward = reward, |
| 1043 | + change = change, | |
| 929 | 1044 | })) |
| 930 | 1045 | return true |
| 931 | 1046 | end |
| ... | ... | @@ -976,17 +1091,15 @@ function _M.guideRpc(agent, data) |
| 976 | 1091 | local cmdType = msg.cmdType |
| 977 | 1092 | |
| 978 | 1093 | local funcGuide = role:getProperty("funcGuide") |
| 979 | - local newerGuide = role:getProperty("newerGuide") | |
| 980 | 1094 | if cmdType == 1 then |
| 981 | 1095 | -- 新手引导 |
| 982 | 1096 | local master = msg.master or -1 |
| 983 | 1097 | local slave = msg.slave or -1 |
| 984 | 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 | 1101 | elseif cmdType == 2 then |
| 989 | - -- 系统引导 | |
| 1102 | + -- 系统引导(玩家可选择是否进行) | |
| 990 | 1103 | if not msg.skip then return end |
| 991 | 1104 | local new = math.min(funcGuide:getv(0, 0), msg.skip) |
| 992 | 1105 | if new < 0 then |
| ... | ... | @@ -997,15 +1110,23 @@ function _M.guideRpc(agent, data) |
| 997 | 1110 | |
| 998 | 1111 | if msg.funcType then |
| 999 | 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 | 1114 | end |
| 1002 | 1115 | role:updateProperty({field = "funcGuide", value = funcGuide}) |
| 1003 | 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 | 1126 | if msg.funcType then |
| 1006 | 1127 | local value = msg.value or 1 |
| 1007 | 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 | 1130 | funcGuide = funcGuide:setv(funcIdx, value) |
| 1010 | 1131 | end |
| 1011 | 1132 | role:updateProperty({field = "funcGuide", value = funcGuide}) |
| ... | ... | @@ -1044,10 +1165,25 @@ function _M.goldBuyRpc(agent, data) |
| 1044 | 1165 | if goldC == 0 then |
| 1045 | 1166 | return 3 |
| 1046 | 1167 | end |
| 1168 | + local coef = role.storeData:getGearExchangeCoef() | |
| 1169 | + goldC = goldC * coef | |
| 1047 | 1170 | role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1}) |
| 1048 | 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 | 1187 | return true |
| 1052 | 1188 | end |
| 1053 | 1189 | ... | ... |
src/actions/StoreAction.lua
| ... | ... | @@ -31,6 +31,7 @@ function _M.rechargeRpc(agent , data) |
| 31 | 31 | local partnerOrderId = makeOrder(roleId, id) |
| 32 | 32 | SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId })) |
| 33 | 33 | |
| 34 | + | |
| 34 | 35 | -- 测试的 直接发奖励了 |
| 35 | 36 | skynet.timeout(10, function () |
| 36 | 37 | role:handlePurchase({ |
| ... | ... | @@ -164,6 +165,22 @@ function _M.purchaseOrderResult(agent, data) |
| 164 | 165 | |
| 165 | 166 | if msg.status == "success" then |
| 166 | 167 | orderObject:setProperty("transactionId", msg.platformOrder or "") |
| 168 | + local rechargeId = orderObject:getProperty("rechargeId") | |
| 169 | + local dataSet = csvdb["shop_rechargeCsv"][rechargeId] | |
| 170 | + | |
| 171 | + role:log("setOrder", { | |
| 172 | + order_status = 100, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他" | |
| 173 | + item_id = rechargeId, -- 道具id | |
| 174 | + item_type = dataSet.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表 | |
| 175 | + item_name = dataSet.title, -- 购买的道具名 | |
| 176 | + item_number = 1, -- 购买的道具数量 | |
| 177 | + item_level = 1, -- 购买的道具等级 | |
| 178 | + order_cost = dataSet.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee' | |
| 179 | + order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范 | |
| 180 | + order_type = self.getProperty("rmbC") > 0 and 0 or 1, -- 订单类型,首充记录为1,否则为0 | |
| 181 | + order_id = msg.platformOrder, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no' | |
| 182 | + }) | |
| 183 | + | |
| 167 | 184 | return true |
| 168 | 185 | end |
| 169 | 186 | |
| ... | ... | @@ -178,79 +195,184 @@ function _M.purchaseOrderResult(agent, data) |
| 178 | 195 | end |
| 179 | 196 | |
| 180 | 197 | |
| 181 | -function _M.dailyBuyRpc(agent , data) | |
| 198 | +function _M.shopBuyRpc(agent , data) | |
| 182 | 199 | local role = agent.role |
| 183 | 200 | local msg = MsgPack.unpack(data) |
| 184 | 201 | local id = msg.id |
| 185 | 202 | local count = msg.count or 1 |
| 186 | 203 | |
| 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 | |
| 204 | + local dataSet = csvdb["shop_normalCsv"][id] | |
| 205 | + if not dataSet then return end | |
| 193 | 206 | |
| 194 | - local cost = dataSet.cost | |
| 207 | + if dataSet.unlock ~= "" then | |
| 208 | + if not role:checkHangPass(tonumber(config.unlock)) then | |
| 209 | + skynet.error(string.format("shopBuyRpc,user do not finish hang pass, user_id:%d", role:getProperty("id"))) | |
| 210 | + return 1 | |
| 211 | + end | |
| 212 | + end | |
| 195 | 213 | |
| 196 | - local dailySDD = role.dailyData:getProperty("dailySDD") | |
| 197 | - if dailySDD[id] then -- 折扣 | |
| 198 | - cost = math.ceil(cost * (1 - dataSet.disount / 100)) | |
| 214 | + local buyRecord = role.storeData:getProperty("buyR") | |
| 215 | + if math.illegalNum(count, 1, (dataSet.limit == 0 and math.huge or dataSet.limit - (buyRecord[id] or 0))) then | |
| 216 | + skynet.error(string.format("shop buy over limit, user_id:%d, goods_id:%d", role:getProperty("id"), id)) | |
| 217 | + return 1 | |
| 199 | 218 | end |
| 200 | 219 | |
| 201 | - if not role:costDiamond({count = cost * count, log = {desc = "dailyShop", int1 = id, int2 = count}}) then | |
| 202 | - return 4 | |
| 220 | + local cost = {[dataSet.icon] = dataSet.cost * count} | |
| 221 | + | |
| 222 | + local desc = "unknown" | |
| 223 | + if dataSet.shop == 1 then -- 普通商店 | |
| 224 | + desc = "dailyShop" | |
| 225 | + local dailySDD = role.dailyData:getProperty("dailySDD") | |
| 226 | + if dailySDD[id] then -- 折扣 | |
| 227 | + cost = math.ceil(dataSet.cost * (1 - dataSet.disount / 100)) | |
| 228 | + end | |
| 229 | + elseif dataSet.shop == 2 then -- 美食商店 | |
| 230 | + desc = "dinerShop" | |
| 231 | + elseif dataSet.shop == 3 then -- 竞技场商店 | |
| 232 | + desc = "pvpShop" | |
| 203 | 233 | end |
| 204 | 234 | |
| 235 | + if not role:checkItemEnough(cost) then return end | |
| 236 | + | |
| 205 | 237 | if dataSet.limit ~= 0 then |
| 206 | - dailySDC[id] = (dailySDC[id] or 0) + count | |
| 207 | - role.dailyData:updateProperty({field = "dailySDC", value = dailySDC}) | |
| 238 | + buyRecord[id] = (buyRecord[id] or 0) + count | |
| 239 | + role.storeData:updateProperty({field = "buyR", value = buyRecord}) | |
| 208 | 240 | end |
| 241 | + role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count}}) | |
| 242 | + | |
| 209 | 243 | local gift = {} |
| 210 | - for itemId, count_ in pairs(dataSet.gift:toNumMap()) do | |
| 211 | - gift[itemId] = count_ * count | |
| 244 | + for _id, _count in pairs(dataSet.gift:toNumMap()) do | |
| 245 | + gift[_id] = _count * count | |
| 246 | + end | |
| 247 | + local reward = role:award(gift, {log = {desc = desc, int1 = id, int2 = count}}) | |
| 248 | + | |
| 249 | + if dataSet.shop == 1 then | |
| 250 | + role:checkTaskEnter("ShopAll", {count = count}) | |
| 212 | 251 | end |
| 213 | - local reward = role:award(gift, {log = {desc = "dailyShop", int1 = id, int2 = count}}) | |
| 214 | - role:checkTaskEnter("ShopAll", {count = count}) | |
| 252 | + local costId, costCount = next(cost) | |
| 253 | + | |
| 254 | + role:log("shop_purchase", { | |
| 255 | + item_id = id, -- 道具id | |
| 256 | + item_type = 0, -- 道具类型,具体见枚举表中道具类型枚举表 | |
| 257 | + item_level = 0, -- 道具等级 | |
| 258 | + item_cnt = count, -- 购买数量技术 | |
| 259 | + currency_type = costId or 0, -- 购买道具消耗的货币类型,记录货币ID | |
| 260 | + shop_purchase_current = costCount or 0, -- 购买道具消耗的货币数量 | |
| 261 | + shop_id = dataSet.shop, -- 商店ID | |
| 262 | + }) | |
| 263 | + SendPacket(actionCodes.Store_shopBuyRpc, MsgPack.pack({reward = reward})) | |
| 264 | + return true | |
| 265 | +end | |
| 266 | + | |
| 267 | +function _M.getFreeChestRpc(agent, data) | |
| 268 | + local role = agent.role | |
| 269 | + local msg = MsgPack.unpack(data) | |
| 270 | + local id = msg.id | |
| 215 | 271 | |
| 216 | - role:log("role_action", {desc = "dailyShop", int1 = id, int2 = count}) | |
| 272 | + local config = csvdb["shop_rechargeCsv"][id] | |
| 273 | + if not config then return end | |
| 217 | 274 | |
| 218 | - SendPacket(actionCodes.Store_dailyBuyRpc, MsgPack.pack({reward = reward})) | |
| 275 | + local rechargeRecord = role.storeData:getProperty("payR") | |
| 276 | + local getCount = (rechargeRecord[id] or 0) | |
| 277 | + if getCount >= config.limit then | |
| 278 | + return 1 | |
| 279 | + end | |
| 280 | + local reward, _ = role:award(config.itemFirst, {log = {desc = "freeGift", int1 = id}}) | |
| 281 | + | |
| 282 | + rechargeRecord[id] = getCount + 1 | |
| 283 | + role.storeData:updateProperty({field = "payR", value = rechargeRecord}) | |
| 284 | + | |
| 285 | + SendPacket(actionCodes.Store_getFreeChestRpc, MsgPack.pack({reward = reward})) | |
| 219 | 286 | return true |
| 220 | 287 | end |
| 221 | 288 | |
| 289 | +function _M.getGrowFundRewardRpc(agent, data) | |
| 290 | + local role = agent.role | |
| 291 | + local msg = MsgPack.unpack(data) | |
| 292 | + local id = msg.id | |
| 293 | + | |
| 294 | + local config = csvdb["reward_newbeeCsv"][id] | |
| 295 | + if not config then return end | |
| 296 | + | |
| 297 | + local growFundFlag = role.storeData:getProperty("growFund") | |
| 298 | + local growFundRecord = role.storeData:getProperty("growFundR") | |
| 299 | + | |
| 300 | + if growFundFlag == 0 then | |
| 301 | + skynet.error("user do not buy grow fund") | |
| 302 | + return 1 | |
| 303 | + end | |
| 304 | + | |
| 305 | + if not role:checkHangPass(config.condition) then | |
| 306 | + skynet.error(string.format("user do not finish hang pass, user_id:%d", role:getProperty("id"))) | |
| 307 | + return 1 | |
| 308 | + end | |
| 309 | + | |
| 310 | + local b = string.getbit(growFundRecord, id) | |
| 311 | + if string.char(b) == "1" then | |
| 312 | + return 1 | |
| 313 | + end | |
| 314 | + | |
| 315 | + growFundRecord = string.setbit(growFundRecord, id) | |
| 316 | + role.storeData:updateProperty({field = "growFundR", value = growFundRecord}) | |
| 222 | 317 | |
| 223 | -function _M.dinerBuyRpc(agent , data) | |
| 318 | + local gift = config.giftFree .. " " .. config.giftLimit | |
| 319 | + local reward, _ = role:award(gift, {log = {desc = "grownFund", int1 = id}}) | |
| 320 | + | |
| 321 | + SendPacket(actionCodes.Store_getGrowFundRewardRpc, MsgPack.pack({reward = reward})) | |
| 322 | + return true | |
| 323 | +end | |
| 324 | + | |
| 325 | +function _M.getBattlePassRewardRpc(agent, data) | |
| 224 | 326 | local role = agent.role |
| 225 | 327 | local msg = MsgPack.unpack(data) |
| 226 | 328 | local id = msg.id |
| 227 | - local count = msg.count or 1 | |
| 228 | 329 | |
| 229 | - local dataSet = csvdb["shop_dinerCsv"][id] | |
| 230 | - if not dataSet then return end | |
| 330 | + local config = csvdb["reward_battlepassCsv"][id] | |
| 331 | + if not config then return end | |
| 231 | 332 | |
| 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 | |
| 333 | + local timeNow = skynet.timex() | |
| 334 | + local battleCardFlag = role.storeData:getProperty("battleCard") | |
| 335 | + local battleCardFreeRecord = role.storeData:getProperty("battleFR") | |
| 336 | + local battleCardLimitRecord = role.storeData:getProperty("battleLR") | |
| 234 | 337 | |
| 235 | - local cost = {[ItemId.DinerCoin] = dataSet.cost * count} | |
| 236 | - if not role:checkItemEnough(cost) then return end | |
| 338 | + local freeFlag = string.char(string.getbit(battleCardFreeRecord, id)) | |
| 339 | + local limitFlag = string.char(string.getbit(battleCardLimitRecord, id)) | |
| 237 | 340 | |
| 238 | - if dataSet.limit ~= 0 then | |
| 239 | - dinerS[id] = (dinerS[id] or 0) + count | |
| 240 | - role:updateProperty({field = "dinerS", value = dinerS}) | |
| 341 | + if freeFlag == "1" and limitFlag == "1" then | |
| 342 | + skynet.error("user already get battle pass reward") | |
| 343 | + return 1 | |
| 241 | 344 | end |
| 242 | 345 | |
| 243 | - role:costItems(cost, {log = {desc = "dinerShop", int1 = id, int2 = count}}) | |
| 346 | + if battleCardFlag == 1 and limitFlag == "1" then | |
| 347 | + return 1 | |
| 348 | + end | |
| 244 | 349 | |
| 245 | - local gift = {} | |
| 246 | - for _id, _count in pairs(dataSet.gift:toNumMap()) do | |
| 247 | - gift[_id] = _count * count | |
| 350 | + if role:getProperty("battlePoint") < config.point then | |
| 351 | + skynet.error(string.format("user do not have enough battle point, user_id:%d", role:getProperty("id"))) | |
| 352 | + return 1 | |
| 353 | + end | |
| 354 | + | |
| 355 | + local gift = "" | |
| 356 | + if freeFlag == "0" then | |
| 357 | + gift = config.giftFree | |
| 358 | + | |
| 359 | + battleCardFreeRecord = string.setbit(battleCardFreeRecord, id) | |
| 360 | + role.storeData:updateProperty({field = "battleFR", value = battleCardFreeRecord}) | |
| 361 | + end | |
| 362 | + | |
| 363 | + if battleCardFlag == 1 and limitFlag == "0" then | |
| 364 | + if gift ~= "" then | |
| 365 | + gift = gift .. " " | |
| 366 | + end | |
| 367 | + gift = gift .. config.giftLimit | |
| 368 | + | |
| 369 | + battleCardLimitRecord = string.setbit(battleCardLimitRecord, id) | |
| 370 | + role.storeData:updateProperty({field = "battleLR", value = battleCardLimitRecord}) | |
| 248 | 371 | end |
| 249 | - local reward = role:award(gift, {log = {desc = "dinerShop", int1 = id, int2 = count}}) | |
| 250 | 372 | |
| 251 | - role:log("role_action", {desc = "dinerShop", int1 = id, int2 = count}) | |
| 373 | + local reward, _ = role:award(gift, {log = {desc = "battleCard", int1 = id}}) | |
| 252 | 374 | |
| 253 | - SendPacket(actionCodes.Store_dinerBuyRpc, MsgPack.pack({reward = reward})) | |
| 375 | + SendPacket(actionCodes.Store_getBattlePassRewardRpc, MsgPack.pack({reward = reward})) | |
| 254 | 376 | return true |
| 255 | 377 | end |
| 256 | 378 | ... | ... |
src/actions/TowerAction.lua
| ... | ... | @@ -76,8 +76,6 @@ function _M.startBattleRpc(agent, data) |
| 76 | 76 | role:updateProperty({field = "towerInfo", value = towerInfo}) |
| 77 | 77 | role:checkTaskEnter("TowerBattle", {level = towerInfo.l}) |
| 78 | 78 | |
| 79 | - role:log("tower_action", {desc = "startBattle", int1 = id}) | |
| 80 | - | |
| 81 | 79 | SendPacket(actionCodes.Tower_startBattleRpc, '') |
| 82 | 80 | return true |
| 83 | 81 | end |
| ... | ... | @@ -90,21 +88,24 @@ function _M.endBattleRpc(agent, data) |
| 90 | 88 | local passTime = msg.passTime |
| 91 | 89 | |
| 92 | 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 | 95 | local curTower = csvdb["tower_battleCsv"][id] |
| 95 | 96 | if not curTower then return 2 end |
| 96 | 97 | |
| 97 | 98 | local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) |
| 98 | 99 | |
| 99 | 100 | |
| 100 | - local reward | |
| 101 | + local reward, change | |
| 101 | 102 | if msg.starNum and msg.starNum > 0 then --win |
| 102 | 103 | curCount = math.min(curCount + 1, globalCsv.tower_count_limit) -- 返还次数 |
| 103 | 104 | --排行榜 |
| 104 | 105 | role:setTowerRank(towerInfo.l) |
| 105 | 106 | |
| 106 | 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 | 109 | role:checkTaskEnter("TowerPass", {level = towerInfo.l - 1}) |
| 109 | 110 | end |
| 110 | 111 | |
| ... | ... | @@ -113,9 +114,7 @@ function _M.endBattleRpc(agent, data) |
| 113 | 114 | towerInfo.k = nil |
| 114 | 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 | - | |
| 118 | - SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({reward = reward})) | |
| 117 | + SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({reward = reward, change = change})) | |
| 119 | 118 | return true |
| 120 | 119 | end |
| 121 | 120 | |
| ... | ... | @@ -137,7 +136,6 @@ function _M.bugCountRpc(agent, data) |
| 137 | 136 | towerInfo.c = curCount |
| 138 | 137 | towerInfo.t = nextTime |
| 139 | 138 | role:updateProperty({field = "towerInfo", value = towerInfo}) |
| 140 | - role:log("tower_action", {desc = "bugCount"}) | |
| 141 | 139 | |
| 142 | 140 | SendPacket(actionCodes.Tower_bugCountRpc, '') |
| 143 | 141 | return true | ... | ... |
src/adv/Adv.lua
| ... | ... | @@ -24,17 +24,6 @@ function Adv:ctor(owner) |
| 24 | 24 | self:initByInfo(self.owner:getProperty("advInfo")) |
| 25 | 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 | 27 | --初始化adv 信息 |
| 39 | 28 | function Adv:initByInfo(advInfo) |
| 40 | 29 | if not next(advInfo) then return end --还没有 开始新地图 |
| ... | ... | @@ -509,18 +498,18 @@ function Adv:awardArtifact(id, params) |
| 509 | 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 | 513 | if not params.isChoose then |
| 525 | 514 | self:pushBackEvent(AdvBackEventType.Artifact, {id = id}) |
| 526 | 515 | end |
| ... | ... | @@ -609,7 +598,6 @@ function Adv:wearArtifact(slot, id) |
| 609 | 598 | else |
| 610 | 599 | id = nil |
| 611 | 600 | end |
| 612 | - self:log({desc = "wearArtifact", int1 = id}) | |
| 613 | 601 | |
| 614 | 602 | self.owner:changeUpdates({{type = "advAFWear", field = slot, value = id}}) |
| 615 | 603 | return true |
| ... | ... | @@ -668,9 +656,6 @@ function Adv:artifactLevelUp(id, level) |
| 668 | 656 | end |
| 669 | 657 | if newLv == advAFGet[id] then return end |
| 670 | 658 | |
| 671 | - self:log({desc = "artifactLevelUp", int1 = id, int2 = level}) | |
| 672 | - | |
| 673 | - | |
| 674 | 659 | local status = 0 |
| 675 | 660 | if curWear[id] then -- 穿着呢 |
| 676 | 661 | local oldData = csvdb["adv_artifactCsv"][id][advAFGet[id]] |
| ... | ... | @@ -715,8 +700,6 @@ function Adv:chooseArtifact(index) |
| 715 | 700 | if not self.waitArtifact or not self.waitArtifact[index] then return end |
| 716 | 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 | 703 | self.waitArtifact = nil |
| 721 | 704 | |
| 722 | 705 | -- 支援效果继续选择 |
| ... | ... | @@ -778,7 +761,7 @@ function Adv:over(success, rewardRatio, overType) |
| 778 | 761 | |
| 779 | 762 | local backAdvCount |
| 780 | 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 | 765 | self.owner:changeAdvCount(-backAdvCount) |
| 783 | 766 | end |
| 784 | 767 | |
| ... | ... | @@ -809,8 +792,6 @@ function Adv:over(success, rewardRatio, overType) |
| 809 | 792 | end |
| 810 | 793 | self:clearAdvUnlockCache() |
| 811 | 794 | |
| 812 | - self:log({desc = "over", short1 = success and 1 or 0, int1 = overType}) | |
| 813 | - | |
| 814 | 795 | local chapterId = self.chapterId |
| 815 | 796 | self:clear() |
| 816 | 797 | self.owner:checkTaskEnter("AdvScore", {score = score}) |
| ... | ... | @@ -903,6 +884,9 @@ function Adv:award(gift, params) |
| 903 | 884 | |
| 904 | 885 | if csvdb["adv_artifactCsv"][itemId] then -- 获得神器 |
| 905 | 886 | self:awardArtifact(itemId, params) |
| 887 | + if not self.owner:checkOverGuide(55) then | |
| 888 | + self.owner:saveGuide(55,1,true) | |
| 889 | + end | |
| 906 | 890 | else |
| 907 | 891 | if nums <= 0 then |
| 908 | 892 | items = items:delk(itemId) |
| ... | ... | @@ -911,23 +895,23 @@ function Adv:award(gift, params) |
| 911 | 895 | items = items:setv(itemId, nums) |
| 912 | 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 | 915 | end |
| 932 | 916 | end |
| 933 | 917 | if items ~= oldItems then |
| ... | ... | @@ -1021,7 +1005,6 @@ local function clickOut(self, room, block, params, isExit) |
| 1021 | 1005 | isRelay = true, |
| 1022 | 1006 | }) |
| 1023 | 1007 | else |
| 1024 | - self:log({desc = "pass"}) | |
| 1025 | 1008 | self:initByChapter({ |
| 1026 | 1009 | chapterId = self.chapterId, |
| 1027 | 1010 | level = self.level + 1, |
| ... | ... | @@ -1357,6 +1340,10 @@ local function clickDrop(self, room, block, params) |
| 1357 | 1340 | |
| 1358 | 1341 | local reward = self:award({[block.event.item[1]] = block.event.item[2]}, {log = {desc = "clickDrop"}}) |
| 1359 | 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 | 1347 | block:clear() |
| 1361 | 1348 | self:backReward(reward, {roomId = room.roomId, blockId = block.blockId}) |
| 1362 | 1349 | return true |
| ... | ... | @@ -1897,16 +1884,16 @@ function Adv:enemyDead(enemy, escape) |
| 1897 | 1884 | self:checkAchievement(Adv.AchievType.Kill, 1, enemyId) |
| 1898 | 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 | 1889 | self:checkAchievement(Adv.AchievType.KillWithMWeapon, 1) |
| 1903 | 1890 | self:checkAchievement(Adv.AchievType.KillWithAMWeapon, 1) |
| 1904 | 1891 | |
| 1905 | 1892 | if monsterData.type == 2 then |
| 1906 | 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 | 1897 | self:checkAchievement(Adv.AchievType.KillBossWithMWeapon, 1) |
| 1911 | 1898 | self:checkAchievement(Adv.AchievType.KillBossWithAMWeapon, 1) |
| 1912 | 1899 | elseif monsterData.type == 3 then | ... | ... |
src/adv/AdvBattle.lua
| ... | ... | @@ -332,6 +332,15 @@ function Battle:afterRound() |
| 332 | 332 | for i = #self.builds[mapIdx], 1, -1 do |
| 333 | 333 | if self.builds[mapIdx][i].isDead then |
| 334 | 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 | 344 | build:clear() |
| 336 | 345 | end |
| 337 | 346 | end | ... | ... |
src/adv/AdvMap.lua
| ... | ... | @@ -256,7 +256,7 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack) |
| 256 | 256 | |
| 257 | 257 | if status then |
| 258 | 258 | if isPlayer then |
| 259 | - self.adv.battle.player:triggerPassive(Passive.OPEN_BLOCK) | |
| 259 | + self.adv.battle:triggerPassive(Passive.OPEN_BLOCK) | |
| 260 | 260 | self.adv.owner:checkTaskEnter("AdvOpenBlock") |
| 261 | 261 | |
| 262 | 262 | -- 潜行检查 | ... | ... |
src/adv/AdvPassive.lua
| ... | ... | @@ -300,8 +300,8 @@ function Passive:canEffect(effType, effValue) |
| 300 | 300 | return |
| 301 | 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 | 305 | return |
| 306 | 306 | end |
| 307 | 307 | return true |
| ... | ... | @@ -466,7 +466,8 @@ function Passive:effect8(dropId) |
| 466 | 466 | skynet.error(string.format("CSVDATA Error adv_map_passive %s effect 8 not id %s in event_drop", self.id, dropId)) |
| 467 | 467 | end |
| 468 | 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 | 471 | end |
| 471 | 472 | |
| 472 | 473 | --9=直接获得item(可在结算触发时使用) |
| ... | ... | @@ -480,7 +481,7 @@ function Passive:effect9(itemId, triggerPms, ratio, max) |
| 480 | 481 | return |
| 481 | 482 | end |
| 482 | 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 | 485 | end |
| 485 | 486 | |
| 486 | 487 | --10=战斗额外掉落次数 | ... | ... |
src/adv/AdvPlayer.lua
| ... | ... | @@ -122,14 +122,16 @@ function BaseObject:getPassiveIdx(passive) |
| 122 | 122 | end |
| 123 | 123 | |
| 124 | 124 | function BaseObject:getDisablePassiveCount() |
| 125 | - local count, bc = 0, 0 | |
| 125 | + local count | |
| 126 | 126 | for _, buff in ipairs(self.buffs) do |
| 127 | 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 | 132 | end |
| 131 | 133 | end |
| 132 | - return count, bc | |
| 134 | + return count | |
| 133 | 135 | end |
| 134 | 136 | |
| 135 | 137 | function BaseObject:addBuff(buffId, releaser) |
| ... | ... | @@ -208,6 +210,9 @@ function BaseObject:hadBuffById(bId) |
| 208 | 210 | end |
| 209 | 211 | end |
| 210 | 212 | |
| 213 | +function BaseObject:reSetSpMax() | |
| 214 | +end | |
| 215 | + | |
| 211 | 216 | |
| 212 | 217 | -- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类 |
| 213 | 218 | function BaseObject:getCommonBuffEffect(bType, otherCond) | ... | ... |
src/adv/AdvTask.lua
| ... | ... | @@ -183,12 +183,12 @@ function AdvTask.bind(Adv) |
| 183 | 183 | |
| 184 | 184 | -- 完成主线任务 |
| 185 | 185 | function Adv:finishMTask() |
| 186 | - local ok, reward | |
| 186 | + local ok, reward, change | |
| 187 | 187 | if self.advMTask.status == -1 then --已完成带领取 |
| 188 | 188 | local mainTaskData = csvdb["adv_questCsv"][self.advMTask.id] |
| 189 | 189 | if not mainTaskData then return end |
| 190 | 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 | 192 | end |
| 193 | 193 | self.advMTask.id = self.advMTask.id + 1 |
| 194 | 194 | self.advMTask.status = 0 |
| ... | ... | @@ -204,7 +204,7 @@ function AdvTask.bind(Adv) |
| 204 | 204 | ok = true |
| 205 | 205 | advTaskChange.m = true |
| 206 | 206 | end |
| 207 | - return ok, reward | |
| 207 | + return ok, reward, change | |
| 208 | 208 | end |
| 209 | 209 | |
| 210 | 210 | function Adv:updateTask(notNotify) |
| ... | ... | @@ -365,7 +365,6 @@ function AdvTask.bind(Adv) |
| 365 | 365 | else |
| 366 | 366 | if (status or -1) >= data.value1 then |
| 367 | 367 | status = -1 |
| 368 | - self.owner:log("adv_action", {desc = "finishAchiev", short1 = 1, int1 = self.chapterId, int2 = taskId}) | |
| 369 | 368 | end |
| 370 | 369 | if status and status ~= oldStatus then |
| 371 | 370 | insertChange(self, self.chapterId, taskId, status) |
| ... | ... | @@ -388,7 +387,7 @@ function AdvTask.bind(Adv) |
| 388 | 387 | local achievData = (csvdb["adv_achievementCsv"][chapterId] or {})[taskId] |
| 389 | 388 | local status = (self.owner:getProperty(achievField)[chapterId] or {})[taskId] or -1 |
| 390 | 389 | |
| 391 | - local reward = {} | |
| 390 | + local reward, change = {} | |
| 392 | 391 | if status >= achievData.value1 then |
| 393 | 392 | insertChange(self, chapterId, taskId, -1) |
| 394 | 393 | local count = (self.owner:getProperty(achievField)[chapterId] or {})[-1] or 0 |
| ... | ... | @@ -396,8 +395,8 @@ function AdvTask.bind(Adv) |
| 396 | 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 | 400 | end |
| 402 | 401 | end |
| 403 | 402 | |
| ... | ... | @@ -408,9 +407,9 @@ function AdvTask.bind(Adv) |
| 408 | 407 | local status = ((self.owner:getProperty(achievField)[chapterId] or {})["pts"] or {})[taskId] or 0 |
| 409 | 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 | 411 | insertChange(self, chapterId, taskId, -1, true) |
| 413 | - return true, reward | |
| 412 | + return true, reward, change | |
| 414 | 413 | end |
| 415 | 414 | |
| 416 | 415 | function Adv:updateAchievement(notNotify) | ... | ... |
src/agent.lua
| ... | ... | @@ -282,7 +282,7 @@ function CMD.close() |
| 282 | 282 | mcast_util.usub_union() |
| 283 | 283 | local role = agentInfo.role |
| 284 | 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 | 286 | role:onOfflineEvent() |
| 287 | 287 | end |
| 288 | 288 | ... | ... |
src/models/Activity.lua
| ... | ... | @@ -3,6 +3,13 @@ local string_format = string.format |
| 3 | 3 | |
| 4 | 4 | Activity.ActivityType = { |
| 5 | 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 | 30 | |
| 24 | 31 | Activity.schema = { |
| 25 | 32 | actime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time} |
| 33 | + round = {"table", {}}, -- 记录活动到了第几轮 {id = roundnum} | |
| 26 | 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 | 41 | function Activity:data() |
| 30 | 42 | return { |
| 31 | 43 | actime = self:getProperty("actime"), |
| 44 | + round = self:getProperty("round"), | |
| 32 | 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 | 51 | end |
| 35 | 52 | |
| ... | ... | @@ -162,6 +179,142 @@ activityFunc[Activity.ActivityType.Sign] = { |
| 162 | 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 | 318 | function Activity:initActivity(actType, isCrossDay, notify) |
| 166 | 319 | if activityFunc[actType] and activityFunc[actType]['close'] then |
| 167 | 320 | activityFunc[actType]["init"](self, actType, isCrossDay, notify) |
| ... | ... | @@ -172,7 +325,9 @@ function Activity:closeActivity(actType, notify, notUpdateAct) |
| 172 | 325 | if activityFunc[actType] and activityFunc[actType]['close'] then |
| 173 | 326 | activityFunc[actType]["close"](self, actType, notify) |
| 174 | 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 | 331 | end |
| 177 | 332 | |
| 178 | 333 | function Activity:refreshDailyData(notify) |
| ... | ... | @@ -193,5 +348,41 @@ function Activity:checkActivity(notNotify, activityType, ...) |
| 193 | 348 | end |
| 194 | 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 | 388 | \ No newline at end of file |
| 389 | +return Activity | ... | ... |
src/models/Daily.lua
| ... | ... | @@ -25,6 +25,9 @@ Daily.schema = { |
| 25 | 25 | |
| 26 | 26 | advSupRe = {"number", 0}, -- 冒险支援效果刷新次数 |
| 27 | 27 | goldBuyT = {"number", 0}, -- 金币购买次数 |
| 28 | + | |
| 29 | + unlockPool = {"table", {}}, -- 解锁的属性卡池 | |
| 30 | + curPool = {"number", 0}, -- 属性卡池当前索引 | |
| 28 | 31 | } |
| 29 | 32 | |
| 30 | 33 | function Daily:updateProperty(params) |
| ... | ... | @@ -63,8 +66,8 @@ function Daily:refreshDailyData(notify) |
| 63 | 66 | -- 每日折扣搞一下 |
| 64 | 67 | local dailySDD = {} |
| 65 | 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 | 71 | table.insert(sddPool, id) |
| 69 | 72 | end |
| 70 | 73 | end |
| ... | ... | @@ -97,6 +100,8 @@ function Daily:data() |
| 97 | 100 | dailySDD = self:getProperty("dailySDD"), |
| 98 | 101 | advSupRe = self:getProperty("advSupRe"), |
| 99 | 102 | goldBuyT = self:getProperty("goldBuyT"), |
| 103 | + unlockPool = self:getProperty("unlockPool"), | |
| 104 | + curPool = self:getProperty("curPool"), | |
| 100 | 105 | } |
| 101 | 106 | end |
| 102 | 107 | ... | ... |
src/models/Diner.lua
| ... | ... | @@ -70,12 +70,10 @@ function Diner:refreshDailyData(notify) |
| 70 | 70 | end |
| 71 | 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 | 74 | entrust[1] = 1001 |
| 77 | 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 | 77 | local temp = entrust[1] |
| 80 | 78 | entrust[1] = 1 |
| 81 | 79 | entrust[2] = temp |
| ... | ... | @@ -306,6 +304,7 @@ function Diner:expediteSell(slot) |
| 306 | 304 | lastCount = lastCount, |
| 307 | 305 | reward = reward, |
| 308 | 306 | popular = popular, |
| 307 | + deltaTime = deltaTime, | |
| 309 | 308 | } |
| 310 | 309 | end |
| 311 | 310 | ... | ... |
src/models/Email.lua
| ... | ... | @@ -18,6 +18,23 @@ Email.schema = { |
| 18 | 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 | 38 | function Email:data() |
| 22 | 39 | local emailId = self:getProperty("emailId") |
| 23 | 40 | local title = self:getProperty("title") | ... | ... |
src/models/Role.lua
| ... | ... | @@ -20,12 +20,14 @@ function Role:ctor( properties ) |
| 20 | 20 | Role.super.ctor(self, properties) |
| 21 | 21 | self.ignoreHeartbeat = false |
| 22 | 22 | self.dailyData = nil |
| 23 | + self.storeData = nil | |
| 23 | 24 | self.heros = {} |
| 24 | 25 | self.runeBag = {} |
| 25 | 26 | self.advData = nil |
| 26 | 27 | self.activity = nil |
| 27 | 28 | self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节 |
| 28 | 29 | self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳 |
| 30 | + self.sendMailFlag = false --发送邮件标识 | |
| 29 | 31 | end |
| 30 | 32 | |
| 31 | 33 | Role.schema = { |
| ... | ... | @@ -36,6 +38,8 @@ Role.schema = { |
| 36 | 38 | headId = {"number", globalCsv.defaultHead}, |
| 37 | 39 | sid = {"number", 0}, |
| 38 | 40 | device = {"string", ""}, |
| 41 | + dmode = {"string", ""}, | |
| 42 | + lday = {"number", 0}, | |
| 39 | 43 | banTime = {"number", 0}, |
| 40 | 44 | banType = {"number", 0}, |
| 41 | 45 | heartWarning = {"number", 0}, |
| ... | ... | @@ -140,12 +144,13 @@ Role.schema = { |
| 140 | 144 | |
| 141 | 145 | rechargeF = {"table", {}}, -- 是否首次充值某一项 -- —{[id] = 1} -- 不存在就是没有充值过 |
| 142 | 146 | dinerS = {"table", {}}, -- 美食币商城 购买记录 {[id] = count} |
| 147 | + battlePoint = {"number", 0}, -- 赛季卡使用的活跃点 | |
| 143 | 148 | |
| 144 | 149 | rmbC = {"number", 0}, -- 人民币重置额 |
| 145 | 150 | |
| 146 | 151 | emailSync = {"number", 0}, -- 已经同步到的邮件Id |
| 147 | 152 | |
| 148 | - -- repayHero = {"number", 0}, -- 超级招募 回馈 | |
| 153 | + repayHero = {"number", 0}, -- 招募次数 (除去友情招募) | |
| 149 | 154 | floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} |
| 150 | 155 | ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} |
| 151 | 156 | newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr |
| ... | ... | @@ -156,6 +161,8 @@ Role.schema = { |
| 156 | 161 | redp = {"table", {}}, -- 待消除红点 -- 通常打开对应界面就消除的红点 红点消除的方法 在对应的协议中使用 {tag = pms } |
| 157 | 162 | |
| 158 | 163 | chatline = {"table", {}}, -- 奖励发放 id=时间 |
| 164 | + | |
| 165 | + downCvR = {"number", 0}, -- 下载cv扩展包奖励 | |
| 159 | 166 | } |
| 160 | 167 | |
| 161 | 168 | |
| ... | ... | @@ -360,9 +367,10 @@ function Role:data() |
| 360 | 367 | |
| 361 | 368 | rechargeF = self:getProperty("rechargeF"), |
| 362 | 369 | dinerS = self:getProperty("dinerS"), |
| 370 | + battlePoint = self:getProperty("battlePoint"), | |
| 363 | 371 | |
| 364 | 372 | rmbC = self:getProperty("rmbC"), |
| 365 | - -- repayHero = self:getProperty("repayHero"), | |
| 373 | + repayHero = self:getProperty("repayHero"), | |
| 366 | 374 | newerDraw = self:getProperty("newerDraw"), |
| 367 | 375 | floorHero = self:getProperty("floorHero"), |
| 368 | 376 | ... | ... |
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 = { --玩家副本完成情况 --TODO | |
| 176 | + mission_threadid = true, -- 大关卡ID | |
| 177 | + mission_id = true, -- 关卡ID | |
| 178 | + mission_type = true, -- 关卡类型,见关卡类型枚举表 | |
| 179 | + mission_sequenceid = "ucode", -- 本次对战ID,用于关联一次动作产生多条不同类型的日志 | |
| 180 | + mission_herolist = true, -- 英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] | |
| 181 | + mission_heroscore = true, -- 编队总评分 | |
| 182 | + mission_enemylist = true, -- 地方英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] | |
| 183 | + mission_damage = true, -- 英雄输出值。示例:{'heroid1':1000,'heroid2':2000,………..} | |
| 184 | + mission_ultskill = true, -- 大招使用情况。示例:{'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 = { --玩家挂机或排名奖励 --TODO | |
| 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 | 409 | local function printError(info) |
| ... | ... | @@ -77,136 +411,116 @@ local function printError(info) |
| 77 | 411 | print(debug.traceback()) |
| 78 | 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 | 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 | 458 | end |
| 177 | 459 | |
| 460 | + | |
| 461 | + | |
| 178 | 462 | local RoleLog = {} |
| 179 | 463 | function RoleLog.bind(Role) |
| 180 | 464 | function Role:log(logType, contents) |
| 181 | 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 | 469 | return |
| 186 | 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 | 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 | 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 | 492 | end |
| 207 | 493 | end |
| 208 | 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 | 524 | end |
| 211 | 525 | |
| 212 | 526 | function Role:startActionUcode() |
| ... | ... | @@ -225,7 +539,8 @@ function RoleLog.bind(Role) |
| 225 | 539 | |
| 226 | 540 | function Role:getActionUcode() |
| 227 | 541 | return self._actionUcode |
| 228 | - end | |
| 542 | + end | |
| 543 | + | |
| 229 | 544 | |
| 230 | 545 | end |
| 231 | 546 | return RoleLog |
| 232 | 547 | \ No newline at end of file | ... | ... |
src/models/RolePlugin.lua
| ... | ... | @@ -11,6 +11,7 @@ function RolePlugin.bind(Role) |
| 11 | 11 | self:loadHeros() |
| 12 | 12 | self:loadDiner() |
| 13 | 13 | self:loadActivity() |
| 14 | + self:loadStoreInfo() | |
| 14 | 15 | end |
| 15 | 16 | |
| 16 | 17 | function Role:reloadWhenLogin() |
| ... | ... | @@ -144,10 +145,16 @@ function RolePlugin.bind(Role) |
| 144 | 145 | end |
| 145 | 146 | end |
| 146 | 147 | end |
| 147 | - | |
| 148 | + if not next(allChange) then allChange = nil end | |
| 148 | 149 | return reward, allChange --实际获得的奖励 和 最高级奖励转化过程 |
| 149 | 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 | 158 | function Role:awardExpireItem(expireTime, gift, params) |
| 152 | 159 | if expireTime <= skynet.timex() then |
| 153 | 160 | return |
| ... | ... | @@ -200,6 +207,7 @@ function RolePlugin.bind(Role) |
| 200 | 207 | |
| 201 | 208 | function Role:addPlayExp(addExp, params) |
| 202 | 209 | local level = self:getProperty("level") |
| 210 | + local oldLevel = level | |
| 203 | 211 | if not csvdb["player_expCsv"][level + 1] then |
| 204 | 212 | return |
| 205 | 213 | end |
| ... | ... | @@ -210,24 +218,24 @@ function RolePlugin.bind(Role) |
| 210 | 218 | if csvdb["player_expCsv"][level + 1] then -- 有下一级 |
| 211 | 219 | newExp = newExp - csvdb["player_expCsv"][level].exp |
| 212 | 220 | level = level + 1 |
| 221 | + self:checkTaskEnter("RoleLevelUp", {level = level}) | |
| 213 | 222 | else |
| 214 | 223 | newExp = csvdb["player_expCsv"][level].exp - 1 -- 没有下一级了 经验溢出太多 扣除 |
| 215 | 224 | end |
| 216 | 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 | 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 | 239 | end |
| 232 | 240 | |
| 233 | 241 | self:updateProperties({level = level, exp = newExp}) |
| ... | ... | @@ -250,21 +258,7 @@ function RolePlugin.bind(Role) |
| 250 | 258 | items = items:incrv(params.itemId, params.count) |
| 251 | 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 | 263 | self:setProperty("items", items) |
| 270 | 264 | if not params.notNotify then |
| ... | ... | @@ -334,22 +328,12 @@ function RolePlugin.bind(Role) |
| 334 | 328 | self:incrProperty("diamond", count) |
| 335 | 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 | 332 | self:notifyUpdateProperty("diamond", self:getAllDiamond()) |
| 350 | 333 | return true |
| 351 | 334 | end |
| 352 | 335 | |
| 336 | + | |
| 353 | 337 | function Role:costDiamond(params) |
| 354 | 338 | if not params or type(params) ~= "table" then return false end |
| 355 | 339 | local count = tonum(params.count) |
| ... | ... | @@ -382,17 +366,8 @@ function RolePlugin.bind(Role) |
| 382 | 366 | self:incrProperty(costFirst[2], -last) |
| 383 | 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 | 372 | self:notifyUpdateProperty("diamond", self:getAllDiamond()) |
| 398 | 373 | return true |
| ... | ... | @@ -428,17 +403,9 @@ function RolePlugin.bind(Role) |
| 428 | 403 | local bin = MsgPack.pack(heroResponse) |
| 429 | 404 | SendPacket(actionCodes.Hero_loadInfos, bin) |
| 430 | 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 | 409 | return true, newHero |
| 443 | 410 | end |
| 444 | 411 | |
| ... | ... | @@ -451,33 +418,6 @@ function RolePlugin.bind(Role) |
| 451 | 418 | end |
| 452 | 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 | 422 | function Role:loadHeros() |
| 483 | 423 | local roleId = self:getProperty("id") |
| ... | ... | @@ -537,6 +477,18 @@ function RolePlugin.bind(Role) |
| 537 | 477 | -- 放role 里面了 |
| 538 | 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 | 492 | function Role:addEquip(equipType, equipLv, count, pms) |
| 541 | 493 | pms = pms or {} |
| 542 | 494 | if count ~= count then return end |
| ... | ... | @@ -544,7 +496,8 @@ function RolePlugin.bind(Role) |
| 544 | 496 | if not equipCsv then return end |
| 545 | 497 | local equips = self:getProperty("equips") |
| 546 | 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 | 503 | if curCount < 0 then |
| ... | ... | @@ -562,22 +515,7 @@ function RolePlugin.bind(Role) |
| 562 | 515 | |
| 563 | 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 | 520 | if not pms.notNotify then |
| 583 | 521 | self:changeUpdates({{type = "equips", field = {equipType, equipLv}, value = curCount, isOnlyToC = true}}) -- 通知客户端 |
| ... | ... | @@ -637,20 +575,7 @@ function RolePlugin.bind(Role) |
| 637 | 575 | end |
| 638 | 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 | 580 | return 0, newRune |
| 656 | 581 | else |
| ... | ... | @@ -666,20 +591,7 @@ function RolePlugin.bind(Role) |
| 666 | 591 | local rune = self.runeBag[runeId] |
| 667 | 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 | 596 | self.runeBag[runeId] = nil |
| 685 | 597 | table.insert(bDel, runeId) |
| ... | ... | @@ -925,19 +837,7 @@ function RolePlugin.bind(Role) |
| 925 | 837 | |
| 926 | 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 | 842 | if csvdb["itemCsv"][func] and csvdb["itemCsv"][func].type == ItemType.FuncOpen then |
| 943 | 843 | local unlockData = csvdb["unlockCsv"][func] |
| ... | ... | @@ -1324,9 +1224,13 @@ function RolePlugin.bind(Role) |
| 1324 | 1224 | self:checkNewEvent(now) |
| 1325 | 1225 | end |
| 1326 | 1226 | |
| 1327 | - local function breath(sec) | |
| 1227 | + local function breath(sec, name) | |
| 1328 | 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 | 1234 | if now >= last_breath then |
| 1331 | 1235 | last_breath = now + sec |
| 1332 | 1236 | return true |
| ... | ... | @@ -1335,8 +1239,8 @@ function RolePlugin.bind(Role) |
| 1335 | 1239 | end |
| 1336 | 1240 | end |
| 1337 | 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 | 1245 | function Role:checkNewEvent(now) |
| 1342 | 1246 | if now - self:getProperty("ltime") < 5 then |
| ... | ... | @@ -1377,6 +1281,8 @@ function RolePlugin.bind(Role) |
| 1377 | 1281 | red:hget(string.format(R_EMAIL_ITEM, roleId, id), "status") |
| 1378 | 1282 | end |
| 1379 | 1283 | end) |
| 1284 | + | |
| 1285 | + self.SendMailFlag = false | |
| 1380 | 1286 | for index, id in ipairs(emailIds) do |
| 1381 | 1287 | if tonumber(redret[index]) == 0 then |
| 1382 | 1288 | return true |
| ... | ... | @@ -1401,7 +1307,7 @@ function RolePlugin.bind(Role) |
| 1401 | 1307 | |
| 1402 | 1308 | local events = {} |
| 1403 | 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 | 1311 | local status = checks[name]() |
| 1406 | 1312 | if status then |
| 1407 | 1313 | if status == true then |
| ... | ... | @@ -1442,15 +1348,6 @@ function RolePlugin.bind(Role) |
| 1442 | 1348 | return RANK_ADV[idx] |
| 1443 | 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 | 1351 | -- 消除指定tag 红点 |
| 1455 | 1352 | function Role:clearRedPTag(tag) |
| 1456 | 1353 | local redp = self:getProperty("redp") |
| ... | ... | @@ -1485,8 +1382,8 @@ function RolePlugin.bind(Role) |
| 1485 | 1382 | SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ result = "handled" })) |
| 1486 | 1383 | return |
| 1487 | 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 | 1387 | if rechargeData.rmb ~= tonumber(params.amount) then |
| 1491 | 1388 | skynet.error(string.format("fake order: %s, roleId: %d, order: %s, rmb %s, get %s", |
| 1492 | 1389 | params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount |
| ... | ... | @@ -1494,18 +1391,36 @@ function RolePlugin.bind(Role) |
| 1494 | 1391 | return |
| 1495 | 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 | 1398 | orderObject:setProperty("finishTime", skynet.time()) |
| 1504 | 1399 | orderObject:setProperty("status", "finish") |
| 1505 | 1400 | |
| 1506 | 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 | 1422 | SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr, |
| 1508 | - result = "success", diamond = diamond})) | |
| 1423 | + result = "success", reward = reward})) | |
| 1509 | 1424 | |
| 1510 | 1425 | return orderObject:getProperty("rechargeId") |
| 1511 | 1426 | end |
| ... | ... | @@ -1516,11 +1431,16 @@ function RolePlugin.bind(Role) |
| 1516 | 1431 | local rechargeData = csvdb["shop_rechargeCsv"][id] |
| 1517 | 1432 | if not rechargeData then |
| 1518 | 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 | 1439 | end |
| 1521 | 1440 | |
| 1522 | 1441 | local diamondCount = 0 |
| 1523 | - if rechargeData.type == 0 then -- 钻石 | |
| 1442 | + local reward = {} | |
| 1443 | + if rechargeData.shop == 1 then -- 钻石 | |
| 1524 | 1444 | local rechargeF = self:getProperty("rechargeF") |
| 1525 | 1445 | diamondCount = rechargeData.diamond + rechargeData.diamondExtra |
| 1526 | 1446 | if not rechargeF[id] then |
| ... | ... | @@ -1529,23 +1449,89 @@ function RolePlugin.bind(Role) |
| 1529 | 1449 | self:updateProperty({field = "rechargeF", value = rechargeF}) |
| 1530 | 1450 | end |
| 1531 | 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 | 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 | 1464 | end |
| 1539 | 1465 | |
| 1540 | 1466 | -- 累充 |
| 1541 | 1467 | local rmb = rechargeData.rmb |
| 1542 | 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 | 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 | 1535 | end |
| 1550 | 1536 | |
| 1551 | 1537 | return RolePlugin |
| 1552 | 1538 | \ No newline at end of file | ... | ... |
src/models/RolePvp.lua
| ... | ... | @@ -500,7 +500,7 @@ function Role:setCrossServerPvpBet(idx) |
| 500 | 500 | local ok, result = pcall(skynet.call, pvpd, "lua", "setBet", idx, self:getProperty("id"), costNum) |
| 501 | 501 | if ok then |
| 502 | 502 | if result then |
| 503 | - self:costItems(cost, {log = {desc = "crossPvpBet", short1 = day}}) | |
| 503 | + self:costItems(cost, {log = {desc = "crossPvpBet", int1 = day}}) | |
| 504 | 504 | pvpBet[day] = {idx, cost[ItemId.Gold]} |
| 505 | 505 | self:setProperty("pvpBet", pvpBet) |
| 506 | 506 | end | ... | ... |
src/models/RoleTask.lua
| ... | ... | @@ -76,6 +76,9 @@ local TaskType = { |
| 76 | 76 | AddFriend = 802, -- 加入一个好友 - count |
| 77 | 77 | GetFriendP = 803, -- 获得友情点 - count |
| 78 | 78 | |
| 79 | + -- 角色相关 | |
| 80 | + RoleLevelUp = 901, -- 角色升级 - curlevel | |
| 81 | + | |
| 79 | 82 | --功能未实现 todo |
| 80 | 83 | AdvShop = 1002, -- 冒险商城 |
| 81 | 84 | UnionBoss = 1004, -- 工会boss |
| ... | ... | @@ -205,10 +208,23 @@ local SudokuListener = { |
| 205 | 208 | } |
| 206 | 209 | } |
| 207 | 210 | |
| 211 | +local Activity = require("models.Activity") | |
| 208 | 212 | local ActivityListener = { |
| 209 | 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 | 235 | AchievListener, |
| 220 | 236 | SudokuListener, |
| 221 | 237 | ActivityListener, |
| 238 | + StoreListener, | |
| 222 | 239 | } |
| 223 | 240 | |
| 224 | 241 | local RoleTask = {} |
| ... | ... | @@ -529,6 +546,10 @@ function RoleTask.bind(Role) |
| 529 | 546 | self.activity:checkActivity(notNotify, activityType, ...) |
| 530 | 547 | end |
| 531 | 548 | |
| 549 | + function Role:checkStoreTask(notNotify, triggerType, param) | |
| 550 | + self.storeData:OnTriggerLimitTimePack(triggerType, param) | |
| 551 | + end | |
| 552 | + | |
| 532 | 553 | end |
| 533 | 554 | |
| 534 | 555 | return RoleTask |
| 535 | 556 | \ No newline at end of file | ... | ... |
src/models/RoleTimeReset.lua
| ... | ... | @@ -10,8 +10,10 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) |
| 10 | 10 | self.dailyData:refreshDailyData(notify) |
| 11 | 11 | self.dinerData:refreshDailyData(notify) |
| 12 | 12 | self.activity:refreshDailyData(notify) |
| 13 | + self.storeData:onCrossDay() | |
| 13 | 14 | |
| 14 | 15 | self:setProperty("dTask", {}) |
| 16 | + self:incrProperty("lday", 1) | |
| 15 | 17 | self:advRandomSupportEffect(not notify) |
| 16 | 18 | |
| 17 | 19 | self:checkExpireItem(not notify) |
| ... | ... | @@ -29,6 +31,14 @@ ResetFunc["CrossWeek"] = function(self, notify, response) |
| 29 | 31 | response.dinerS = {} |
| 30 | 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 | 43 | ResetFunc["DinerRank"] = function(self, notify, response) |
| 34 | 44 | self.dinerData:rankResetData(notify) |
| ... | ... | @@ -51,9 +61,11 @@ function Role:updateTimeReset(now, notify) |
| 51 | 61 | |
| 52 | 62 | local needResetId = {} |
| 53 | 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 | 69 | end |
| 58 | 70 | end |
| 59 | 71 | if not next(needResetId) then return end |
| ... | ... | @@ -66,13 +78,19 @@ function Role:updateTimeReset(now, notify) |
| 66 | 78 | ResetFunc[funcName](self, notify, response, now) |
| 67 | 79 | resetMode[funcName] = true |
| 68 | 80 | end |
| 81 | + if needResetId[resetId] then | |
| 82 | + -- 充值商城购买记录 | |
| 83 | + self.storeData:resetStoreReored(resetId) | |
| 84 | + end | |
| 69 | 85 | end |
| 70 | 86 | |
| 71 | 87 | for resetId, round in pairs(needResetId) do |
| 72 | 88 | timeReset[resetId] = round |
| 73 | 89 | end |
| 74 | - self:setProperty("timeReset", timeReset) | |
| 90 | + self:setProperties({timeReset = timeReset, ltime = now}) | |
| 91 | + | |
| 75 | 92 | response.timeReset = timeReset |
| 93 | + response.ltime = ltime | |
| 76 | 94 | |
| 77 | 95 | if notify then |
| 78 | 96 | self:notifyUpdateProperties(response) | ... | ... |
| ... | ... | @@ -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 | 350 | \ No newline at end of file | ... | ... |
src/services/agent_ctrl.lua
| ... | ... | @@ -128,7 +128,7 @@ function _M:check_agent_status() |
| 128 | 128 | next_log_time = now + 60 |
| 129 | 129 | local count = table_nums(self.u2f) |
| 130 | 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 | 132 | end |
| 133 | 133 | end |
| 134 | 134 | ... | ... |
src/services/logd.lua
| ... | ... | @@ -55,38 +55,11 @@ skynet.register_protocol { |
| 55 | 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 | 59 | if not socketdriver.send(log_fd, json.encode(doc) .. "\n") then |
| 88 | 60 | if not connecting then |
| 89 | 61 | CMD.open() -- 连一下试试 |
| 62 | + socketdriver.send(log_fd, json.encode(doc) .. "\n") | |
| 90 | 63 | end |
| 91 | 64 | end |
| 92 | 65 | end | ... | ... |
src/utils/StringUtil.lua
| ... | ... | @@ -13,7 +13,7 @@ local strh = require "strh" |
| 13 | 13 | function string.setv(str, k, v, delimiter) |
| 14 | 14 | delimiter = delimiter or " " |
| 15 | 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 | 17 | end |
| 18 | 18 | |
| 19 | 19 | function string.msetv(str, vs, delimiter) |
| ... | ... | @@ -24,7 +24,7 @@ end |
| 24 | 24 | |
| 25 | 25 | function string.incrv(str, k, delta, delimiter) |
| 26 | 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 | 28 | end |
| 29 | 29 | |
| 30 | 30 | function string.mincrv(str, ds, delimiter) |
| ... | ... | @@ -331,4 +331,20 @@ function string.setbit(str, pos, yes) |
| 331 | 331 | else |
| 332 | 332 | return str:sub(1, pos-1) .. yes .. str:sub(pos+1, -1) |
| 333 | 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 | 350 | end |
| 335 | 351 | \ No newline at end of file | ... | ... |