Commit 020d02ee23cbbec11243408f4be221a6e2ac09a4
Merge branch 'tr/bugfix' into cn/develop
Showing
10 changed files
with
510 additions
and
4 deletions
Show diff stats
src/ProtocolCode.lua
| @@ -245,6 +245,13 @@ actionCodes = { | @@ -245,6 +245,13 @@ actionCodes = { | ||
| 245 | Radio_startQuestRpc = 700, | 245 | Radio_startQuestRpc = 700, |
| 246 | Radio_finishQuestRpc = 701, | 246 | Radio_finishQuestRpc = 701, |
| 247 | Radio_cancelQuestRpc = 702, | 247 | Radio_cancelQuestRpc = 702, |
| 248 | + | ||
| 249 | + Seaport_getServerProcessRpc = 750, | ||
| 250 | + Seaport_donateRpc = 751, | ||
| 251 | + Seaport_donateRewardRpc = 752, | ||
| 252 | + Seaport_taskRpc = 753, | ||
| 253 | + Seaport_shopRpc = 754, | ||
| 254 | + Seaport_resetRpc = 755, | ||
| 248 | } | 255 | } |
| 249 | 256 | ||
| 250 | rpcResponseBegin = 10000 | 257 | rpcResponseBegin = 10000 |
src/RedisKeys.lua
| @@ -49,8 +49,8 @@ RANK_PVP_HIGHT = "rank:pvph" | @@ -49,8 +49,8 @@ RANK_PVP_HIGHT = "rank:pvph" | ||
| 49 | RANK_PVP_HIGHT_KEY = {"rank:pvph1", "rank:pvph2"} | 49 | RANK_PVP_HIGHT_KEY = {"rank:pvph1", "rank:pvph2"} |
| 50 | RECORD_PVP_HIGH = "record:pvph:%d" | 50 | RECORD_PVP_HIGH = "record:pvph:%d" |
| 51 | 51 | ||
| 52 | - | ||
| 53 | - | 52 | +SEAPORT_TRADE_TASK_1 = "seaport:task1" |
| 53 | +SEAPORT_TRADE_TASK_2 = "seaport:task2" | ||
| 54 | 54 | ||
| 55 | FRIEND_KEY = "role:%d:friend" --哈希表 好友 | 55 | FRIEND_KEY = "role:%d:friend" --哈希表 好友 |
| 56 | FRIEND_APPLY_KEY = "role:%d:apply" -- sort set 申请列表 | 56 | FRIEND_APPLY_KEY = "role:%d:apply" -- sort set 申请列表 |
src/actions/RoleAction.lua
| @@ -159,6 +159,7 @@ function _M.loginRpc( agent, data ) | @@ -159,6 +159,7 @@ function _M.loginRpc( agent, data ) | ||
| 159 | role:changeStructVersion() -- 数据结构 版本更新 | 159 | role:changeStructVersion() -- 数据结构 版本更新 |
| 160 | role:getAdvData(true) -- 清掉不合格的数据 | 160 | role:getAdvData(true) -- 清掉不合格的数据 |
| 161 | role:advEndlessSeasonCheck(true) -- 冒险赛季更新检查 | 161 | role:advEndlessSeasonCheck(true) -- 冒险赛季更新检查 |
| 162 | + role:checkSeaportTrade() -- 检查海港贸易季活动 | ||
| 162 | 163 | ||
| 163 | -- 跨天登陆事件 | 164 | -- 跨天登陆事件 |
| 164 | local resetMode = role:updateTimeReset(now) | 165 | local resetMode = role:updateTimeReset(now) |
| @@ -0,0 +1,306 @@ | @@ -0,0 +1,306 @@ | ||
| 1 | +local ipairs = ipairs | ||
| 2 | +local table = table | ||
| 3 | +local math = math | ||
| 4 | +local redisproxy = redisproxy | ||
| 5 | +local MsgPack = MsgPack | ||
| 6 | + | ||
| 7 | +local _M = {} | ||
| 8 | + | ||
| 9 | +function _M.getServerProcessRpc(agent, data) | ||
| 10 | + local role = agent.role | ||
| 11 | + local result = role:getSeaportServerProgress() | ||
| 12 | + | ||
| 13 | + SendPacket(actionCodes.Seaport_getServerProcessRpc, MsgPack.pack(result)) | ||
| 14 | + return true | ||
| 15 | +end | ||
| 16 | + | ||
| 17 | +function _M.donateRpc(agent, data) | ||
| 18 | + local role = agent.role | ||
| 19 | + local msg = MsgPack.unpack(data) | ||
| 20 | + | ||
| 21 | + local phase = msg.phase or 0 | ||
| 22 | + local id = msg.id or 0 | ||
| 23 | + local itemId = msg.itemId or 0 | ||
| 24 | + local itemCount = msg.count or 0 | ||
| 25 | + | ||
| 26 | + if itemId == 0 or itemCount == 0 then return 0 end | ||
| 27 | + if role:getItemCount(itemId) < itemCount then return 1 end | ||
| 28 | + local DonateCsv = csvdb["seaport_purchaseCsv"] | ||
| 29 | + if not DonateCsv[phase] or not DonateCsv[phase][id] then return 2 end | ||
| 30 | + | ||
| 31 | + local ddata = DonateCsv[phase][id] | ||
| 32 | + local needs = ddata.need_item:toArray(true,"=") | ||
| 33 | + if itemId ~= needs[1] then return 3 end | ||
| 34 | + if itemCount % needs[2] ~= 0 then return 4 end | ||
| 35 | + | ||
| 36 | + local group = itemCount / needs[2] | ||
| 37 | + local rewards = ddata.award:toNumMap() | ||
| 38 | + | ||
| 39 | + for id, value in pairs(rewards) do | ||
| 40 | + rewards[id] = value * group | ||
| 41 | + end | ||
| 42 | + | ||
| 43 | + if phase == 1 then | ||
| 44 | + local old = tonumber(redisproxy:hget(SEAPORT_TRADE_TASK_1,id)) or 0 | ||
| 45 | + local need = ddata.need_num - old | ||
| 46 | + if need >= itemCount then | ||
| 47 | + redisproxy:hincrby(SEAPORT_TRADE_TASK_1,id,itemCount) | ||
| 48 | + else | ||
| 49 | + redisproxy:hincrby(SEAPORT_TRADE_TASK_1,id,need) | ||
| 50 | + for _, temp in pairs(DonateCsv[2]) do | ||
| 51 | + local items = temp.need_item:toArray(true,"=") | ||
| 52 | + if items[1] == itemId then | ||
| 53 | + redisproxy:hincrby(SEAPORT_TRADE_TASK_2,temp.id,itemCount - need) | ||
| 54 | + break | ||
| 55 | + end | ||
| 56 | + end | ||
| 57 | + end | ||
| 58 | + else | ||
| 59 | + redisproxy:hincrby(SEAPORT_TRADE_TASK_2,id,itemCount) | ||
| 60 | + end | ||
| 61 | + | ||
| 62 | + role:costItems({[itemId] = itemCount}, {log = {desc = "seaportDonate", int1 = phase, int2 = id}}) | ||
| 63 | + local reward, change = role:award(rewards, {log = {desc = "seaportDonate", int1 = ddata.phase, int2 = ddata.id}}) | ||
| 64 | + | ||
| 65 | + role:mylog("role_action", {desc = "seaportDonate", int1 = itemId, int2 = itemCount}) | ||
| 66 | + | ||
| 67 | + SendPacket(actionCodes.Seaport_donateRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 68 | + return true | ||
| 69 | +end | ||
| 70 | + | ||
| 71 | +function _M.donateRewardRpc(agent, data) | ||
| 72 | + local role = agent.role | ||
| 73 | + local msg = MsgPack.unpack(data) | ||
| 74 | + | ||
| 75 | + local id = msg.id | ||
| 76 | + local dataCsv = csvdb["seaport_purchaseCsv"] | ||
| 77 | + if not dataCsv[id] then return 0 end | ||
| 78 | + | ||
| 79 | + local seaport = role:getProperty("seaport") or {} | ||
| 80 | + local donate = seaport.donate or {} | ||
| 81 | + if donate[id] then return 3 end | ||
| 82 | + | ||
| 83 | + local data = dataCsv[id][1] | ||
| 84 | + | ||
| 85 | + local result = role:getSeaportServerProgress() | ||
| 86 | + if not result[id] then return 1 end | ||
| 87 | + | ||
| 88 | + for _, tempData in ipairs(dataCsv[id]) do | ||
| 89 | + if tempData.need_num > (result[id][tempData.id] or 0) then | ||
| 90 | + return 2 | ||
| 91 | + end | ||
| 92 | + end | ||
| 93 | + | ||
| 94 | + donate[id] = 1 | ||
| 95 | + seaport.donate = donate | ||
| 96 | + | ||
| 97 | + local reward, change = role:award(data.phase_award, {log = {desc = "seaportReward", int1 = data.phase, int2 = data.id}}) | ||
| 98 | + | ||
| 99 | + role:updateProperty({field = "seaport", value = seaport}) | ||
| 100 | + SendPacket(actionCodes.Seaport_donateRewardRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 101 | + return true | ||
| 102 | +end | ||
| 103 | + | ||
| 104 | +-- 获取英雄大成功率 | ||
| 105 | +local function getHeroCoef(hero, condition) | ||
| 106 | + -- 基础概率 | ||
| 107 | + local rareMap = {[HeroQuality.N] = 10, [HeroQuality.R] = 10, [HeroQuality.SR] = 15, [HeroQuality.SSR] = 20} | ||
| 108 | + local rare = hero:getRare() | ||
| 109 | + local result = 0 | ||
| 110 | + for _, it in ipairs(condition:toTableArray(true)) do | ||
| 111 | + local type = it[1] | ||
| 112 | + local value = it[2] | ||
| 113 | + local add = it[3] | ||
| 114 | + if type == 1 then -- 种族加成 | ||
| 115 | + if hero:getCamp() == value then | ||
| 116 | + result = result + add | ||
| 117 | + end | ||
| 118 | + elseif type == 2 then -- 定位加成 | ||
| 119 | + if hero:getPosition() == value then | ||
| 120 | + result = result + add | ||
| 121 | + end | ||
| 122 | + end | ||
| 123 | + end | ||
| 124 | + | ||
| 125 | + return result + (rareMap[rare] or 0) | ||
| 126 | +end | ||
| 127 | + | ||
| 128 | +function _M.taskRpc(agent, data) | ||
| 129 | + local role = agent.role | ||
| 130 | + local msg = MsgPack.unpack(data) | ||
| 131 | + | ||
| 132 | + local oper = msg.oper or 0 | ||
| 133 | + local team = msg.team or "" | ||
| 134 | + local taskId = msg.id or 0 | ||
| 135 | + local level = msg.level or 0 | ||
| 136 | + | ||
| 137 | + if oper == 0 then return 0 end | ||
| 138 | + local TaskCsv = csvdb["seaport_taskCsv"] | ||
| 139 | + if not TaskCsv[taskId] or not TaskCsv[taskId][level] then return 1 end | ||
| 140 | + | ||
| 141 | + local reward, change = {}, {} | ||
| 142 | + local heroFaithMap = {} | ||
| 143 | + local seaport = role:getProperty("seaport") | ||
| 144 | + | ||
| 145 | + local data = TaskCsv[taskId][level] | ||
| 146 | + if data.phase == 2 then | ||
| 147 | + local openTime = tonumber(redisproxy:hget("autoincrement_set", "seaportTime0")) or 0 | ||
| 148 | + local nowTime = skynet.timex() | ||
| 149 | + if nowTime < (openTime + 86400) or nowTime > (openTime + 172800) then return 9 end | ||
| 150 | + end | ||
| 151 | + | ||
| 152 | + if oper == 1 then -- 开始委托 | ||
| 153 | + if team == "" then return 3 end | ||
| 154 | + local conditions = data.condition:toTableArray(true) | ||
| 155 | + local heros = team:toArray(true,"=") | ||
| 156 | + if not next(heros) then return 8 end | ||
| 157 | + local UnitCsv = csvdb["unitCsv"] | ||
| 158 | + for _, conds in pairs(conditions) do | ||
| 159 | + local count = 0 | ||
| 160 | + for _, heroId in pairs(heros) do | ||
| 161 | + local hero = role.heros[heroId] | ||
| 162 | + if not hero then return 8 end | ||
| 163 | + | ||
| 164 | + if conds[1] == 1 then | ||
| 165 | + if hero:getProperty("level") >= conds[2] then | ||
| 166 | + count = count + 1 | ||
| 167 | + end | ||
| 168 | + elseif conds[1] == 2 then | ||
| 169 | + if UnitCsv[hero:getProperty("type")].rare >= conds[2] then | ||
| 170 | + count = count + 1 | ||
| 171 | + end | ||
| 172 | + elseif conds[1] == 3 then | ||
| 173 | + count = count + 1 | ||
| 174 | + end | ||
| 175 | + end | ||
| 176 | + if count < conds[#conds] then | ||
| 177 | + return 4 | ||
| 178 | + end | ||
| 179 | + end | ||
| 180 | + | ||
| 181 | + local collect = seaport.collect or {} | ||
| 182 | + collect[taskId] = {} | ||
| 183 | + collect[taskId].time = skynet.timex() | ||
| 184 | + collect[taskId].level = level | ||
| 185 | + collect[taskId].team = team | ||
| 186 | + | ||
| 187 | + seaport.collect = collect | ||
| 188 | + elseif oper == 2 then -- 领取委托奖励 | ||
| 189 | + local collects = seaport.collect or {} | ||
| 190 | + local collect = collects[taskId] or {} | ||
| 191 | + if not next(collects) or not next(collect) then | ||
| 192 | + return 5 | ||
| 193 | + end | ||
| 194 | + local quick = msg.quick | ||
| 195 | + local endTime = data.time + collect.time | ||
| 196 | + local remainT = endTime - skynet.timex() | ||
| 197 | + if not quick and remainT > 0 then return 6 end | ||
| 198 | + | ||
| 199 | + if quick and remainT > 0 then | ||
| 200 | + local cost = math.ceil(remainT / 3600) * globalCsv.seaport_task_quick | ||
| 201 | + if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return 8 end | ||
| 202 | + role:costItems({[ItemId.Diamond] = cost}, {log = {desc = "seaportTask", int1 = taskId, int2 = level}}) | ||
| 203 | + end | ||
| 204 | + | ||
| 205 | + local carbonCsv = csvdb["idle_battleCsv"] | ||
| 206 | + local expCarbonId = role:getProperty("hangInfo").expCarbonId | ||
| 207 | + if not carbonCsv[expCarbonId] then return 7 end | ||
| 208 | + | ||
| 209 | + local totalCoef = 0 | ||
| 210 | + for _, heroId in ipairs(collect.team:toArray(true,"=")) do | ||
| 211 | + local hero = role.heros[heroId] | ||
| 212 | + if hero then | ||
| 213 | + totalCoef = totalCoef + getHeroCoef(hero, data.success) | ||
| 214 | + hero:addHeroFaith(data.trust) | ||
| 215 | + heroFaithMap[heroId] = hero:getProperty("faith") | ||
| 216 | + end | ||
| 217 | + end | ||
| 218 | + | ||
| 219 | + local bigSuccess = false | ||
| 220 | + local result = math.randomInt(0, 100) | ||
| 221 | + if result < totalCoef then | ||
| 222 | + bigSuccess = true | ||
| 223 | + end | ||
| 224 | + | ||
| 225 | + local money = math.ceil(carbonCsv[expCarbonId].money / 5 * data.time * data.money_clear) | ||
| 226 | + local exp = math.ceil(carbonCsv[expCarbonId].exp / 5 * data.time * data.exp_clear) | ||
| 227 | + local itemReward = data.item_clear_special:toNumMap() | ||
| 228 | + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money | ||
| 229 | + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp | ||
| 230 | + | ||
| 231 | + if bigSuccess then | ||
| 232 | + for key, value in pairs(itemReward) do | ||
| 233 | + itemReward[key] = math.ceil(1.5 * value) | ||
| 234 | + end | ||
| 235 | + end | ||
| 236 | + | ||
| 237 | + reward, change = role:award(itemReward, {log = {desc = "seaportTask", int1 = taskId, int2 = level}}) | ||
| 238 | + | ||
| 239 | + seaport.collect[taskId] = nil | ||
| 240 | + else | ||
| 241 | + return 0 | ||
| 242 | + end | ||
| 243 | + | ||
| 244 | + role:updateProperty({field = "seaport", value = seaport}) | ||
| 245 | + | ||
| 246 | + local result = role:packReward(reward, change) | ||
| 247 | + result["heroFaith"] = heroFaithMap | ||
| 248 | + | ||
| 249 | + SendPacket(actionCodes.Seaport_taskRpc, MsgPack.pack(result)) | ||
| 250 | + return true | ||
| 251 | +end | ||
| 252 | + | ||
| 253 | +function _M.shopRpc(agent, data) | ||
| 254 | + local role = agent.role | ||
| 255 | + local msg = MsgPack.unpack(data) | ||
| 256 | + local id = msg.id or 0 | ||
| 257 | + local count = msg.count or 1 | ||
| 258 | + | ||
| 259 | + local shopCsv = {} | ||
| 260 | + local dataSet = csvdb["shop_normalCsv"] | ||
| 261 | + for _, datat in pairs(dataSet) do | ||
| 262 | + if datat.shop == 5 then | ||
| 263 | + shopCsv[datat.id] = datat | ||
| 264 | + end | ||
| 265 | + end | ||
| 266 | + local sdata = shopCsv[id] | ||
| 267 | + | ||
| 268 | + if not sdata then return 2 end | ||
| 269 | + | ||
| 270 | + local seaport = role:getProperty("seaport") | ||
| 271 | + local shop = seaport.shop or {} | ||
| 272 | + | ||
| 273 | + if (shop[id] or 0) >= sdata.limit then return 1 end | ||
| 274 | + | ||
| 275 | + | ||
| 276 | + | ||
| 277 | + | ||
| 278 | + | ||
| 279 | + if role:getItemCount(sdata.icon) < sdata.cost * count then return 3 end | ||
| 280 | + | ||
| 281 | + role:costItems({[sdata.icon] = sdata.cost * count}, {log = {desc = "seaportShop", int1 = id, int2 = count}}) | ||
| 282 | + | ||
| 283 | + local itemReward = sdata.gift:toNumMap() | ||
| 284 | + for itemId, value in pairs(itemReward) do | ||
| 285 | + itemReward[itemId] = value * count | ||
| 286 | + end | ||
| 287 | + | ||
| 288 | + local reward, change = role:award(itemReward, {log = {desc = "seaportShop", int1 = id, int2 = count}}) | ||
| 289 | + | ||
| 290 | + shop[id] = (shop[id] or 0) + count | ||
| 291 | + seaport.shop = shop | ||
| 292 | + | ||
| 293 | + role:updateProperty({field = "seaport", value = seaport}) | ||
| 294 | + | ||
| 295 | + SendPacket(actionCodes.Seaport_shopRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 296 | + return true | ||
| 297 | +end | ||
| 298 | + | ||
| 299 | +function _M.resetRpc(agent, data) | ||
| 300 | + local role = agent.role | ||
| 301 | + role:checkSeaportTrade() | ||
| 302 | + SendPacket(actionCodes.Seaport_resetRpc, MsgPack.pack("")) | ||
| 303 | + return true | ||
| 304 | +end | ||
| 305 | + | ||
| 306 | +return _M |
src/actions/TowerAction.lua
| @@ -109,7 +109,9 @@ function _M.endBattleRpc(agent, data) | @@ -109,7 +109,9 @@ function _M.endBattleRpc(agent, data) | ||
| 109 | 109 | ||
| 110 | curLevel = curLevel + 1 | 110 | curLevel = curLevel + 1 |
| 111 | reward, change = role:award(curTower.reward, {log = {desc = "towerBattle", int1 = id}}) | 111 | reward, change = role:award(curTower.reward, {log = {desc = "towerBattle", int1 = id}}) |
| 112 | - role:checkTaskEnter("TowerPass", {count = 1, type = towerType + 1}) | 112 | + if towerType == 0 then |
| 113 | + role:checkTaskEnter("TowerPass", {level = towerInfo.l}) | ||
| 114 | + end | ||
| 113 | end | 115 | end |
| 114 | 116 | ||
| 115 | if towerType == 0 then | 117 | if towerType == 0 then |
src/models/Role.lua
| @@ -189,6 +189,8 @@ Role.schema = { | @@ -189,6 +189,8 @@ Role.schema = { | ||
| 189 | calTask = {"table", {}}, -- 英雄令活动 日历任务活动 | 189 | calTask = {"table", {}}, -- 英雄令活动 日历任务活动 |
| 190 | bcTask = {"table", {}}, -- 英雄令活动 日历任务活动 临时使用 | 190 | bcTask = {"table", {}}, -- 英雄令活动 日历任务活动 临时使用 |
| 191 | radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv | 191 | radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv |
| 192 | + | ||
| 193 | + seaport = {"table", {}}, -- 海岛贸易季 {time = 1234567890, donate = {}, collect = {[1] = {team = "1=2=3", time = 1234567890}}, shop = {}} | ||
| 192 | } | 194 | } |
| 193 | 195 | ||
| 194 | 196 | ||
| @@ -419,6 +421,8 @@ function Role:data() | @@ -419,6 +421,8 @@ function Role:data() | ||
| 419 | calTask = self:getProperty("calTask"), | 421 | calTask = self:getProperty("calTask"), |
| 420 | bcTask = self:getProperty("bcTask"), | 422 | bcTask = self:getProperty("bcTask"), |
| 421 | radioTask = self:getProperty("radioTask"), | 423 | radioTask = self:getProperty("radioTask"), |
| 424 | + | ||
| 425 | + seaport = self:getProperty("seaport"), | ||
| 422 | } | 426 | } |
| 423 | end | 427 | end |
| 424 | 428 |
src/models/RoleLog.lua
| @@ -135,6 +135,11 @@ local ItemReason = { | @@ -135,6 +135,11 @@ local ItemReason = { | ||
| 135 | --adv | 135 | --adv |
| 136 | chooseEvent = 1351, -- 冒险选择 | 136 | chooseEvent = 1351, -- 冒险选择 |
| 137 | clickTrader = 1352, -- 冒险商店 | 137 | clickTrader = 1352, -- 冒险商店 |
| 138 | + | ||
| 139 | + seaportDonate = 1400, -- 贸易港捐赠 | ||
| 140 | + seaportShop = 1401, -- 贸易港商店兑换 | ||
| 141 | + seaportReward = 1402, -- 贸易港阶段奖励 | ||
| 142 | + seaportTask = 1403, -- 贸易港任务奖励 | ||
| 138 | } | 143 | } |
| 139 | 144 | ||
| 140 | 145 |
src/models/RolePlugin.lua
| @@ -1217,6 +1217,156 @@ function RolePlugin.bind(Role) | @@ -1217,6 +1217,156 @@ function RolePlugin.bind(Role) | ||
| 1217 | end | 1217 | end |
| 1218 | end | 1218 | end |
| 1219 | 1219 | ||
| 1220 | + -- 结算上期海港贸易季 | ||
| 1221 | + function Role:checkSeaportTrade() | ||
| 1222 | + local openTime0 = tonum(redisproxy:hget("autoincrement_set", "seaportTime0") or 0) | ||
| 1223 | + local openTime1 = tonum(redisproxy:hget("autoincrement_set", "seaportTime1") or 0) | ||
| 1224 | + local openTime2 = tonum(redisproxy:hget("autoincrement_set", "seaportTime2") or 0) | ||
| 1225 | + local seaport = self:getProperty("seaport") or {} | ||
| 1226 | + local oldTime = seaport.time or 0 | ||
| 1227 | + local update = false | ||
| 1228 | + | ||
| 1229 | + local function getReward(reset) | ||
| 1230 | + -- 全服捐赠奖励 | ||
| 1231 | + local donate = seaport.donate or {} | ||
| 1232 | + if not reset and (not donate[1] or not donate[2]) then | ||
| 1233 | + local result = self:getSeaportServerProgress() | ||
| 1234 | + local seaportCsv = csvdb["seaport_purchaseCsv"] | ||
| 1235 | + for idx, set in ipairs(seaportCsv) do | ||
| 1236 | + local done = true | ||
| 1237 | + for id, data in ipairs(set) do | ||
| 1238 | + if donate[id] or not result[idx] or not result[idx][id] or result[idx][id] < data.need_num then | ||
| 1239 | + done = false | ||
| 1240 | + break | ||
| 1241 | + end | ||
| 1242 | + end | ||
| 1243 | + if done then | ||
| 1244 | + update = true | ||
| 1245 | + self:award(set[1].phase_award, {log = {desc = "seaportReward", int1 = set[1].phase, int2 = set[1].id}}) | ||
| 1246 | + donate[idx] = 1 | ||
| 1247 | + end | ||
| 1248 | + end | ||
| 1249 | + seaport.donate = donate | ||
| 1250 | + end | ||
| 1251 | + | ||
| 1252 | + -- 委托任务的奖励 | ||
| 1253 | + local collect = seaport.collect or {} | ||
| 1254 | + if next(collect) then | ||
| 1255 | + local function getHeroCoef(hero, condition) | ||
| 1256 | + -- 基础概率 | ||
| 1257 | + local rareMap = {[HeroQuality.N] = 10, [HeroQuality.R] = 10, [HeroQuality.SR] = 15, [HeroQuality.SSR] = 20} | ||
| 1258 | + local rare = hero:getRare() | ||
| 1259 | + local result = 0 | ||
| 1260 | + for _, it in ipairs(condition:toTableArray(true)) do | ||
| 1261 | + local type = it[1] | ||
| 1262 | + local value = it[2] | ||
| 1263 | + local add = it[3] | ||
| 1264 | + if type == 1 then -- 种族加成 | ||
| 1265 | + if hero:getCamp() == value then | ||
| 1266 | + result = result + add | ||
| 1267 | + end | ||
| 1268 | + elseif type == 2 then -- 定位加成 | ||
| 1269 | + if hero:getPosition() == value then | ||
| 1270 | + result = result + add | ||
| 1271 | + end | ||
| 1272 | + end | ||
| 1273 | + end | ||
| 1274 | + | ||
| 1275 | + return result + (rareMap[rare] or 0) | ||
| 1276 | + end | ||
| 1277 | + | ||
| 1278 | + local carbonCsv = csvdb["idle_battleCsv"] | ||
| 1279 | + local expCarbonId = self:getProperty("hangInfo").expCarbonId | ||
| 1280 | + local taskCsv = csvdb["seaport_taskCsv"] | ||
| 1281 | + local endTime = openTime0 + 86400 * 2 | ||
| 1282 | + for slot, set in pairs(taskCsv) do | ||
| 1283 | + if collect[slot] then | ||
| 1284 | + update = true | ||
| 1285 | + local level = collect[slot].level | ||
| 1286 | + local data = set[level] | ||
| 1287 | + local teams = collect[slot].team | ||
| 1288 | + local time = collect[slot].time | ||
| 1289 | + if time + data.time <= endTime then | ||
| 1290 | + if not carbonCsv[expCarbonId] then break end | ||
| 1291 | + | ||
| 1292 | + local totalCoef = 0 | ||
| 1293 | + for _, heroId in ipairs(teams:toArray(true,"=")) do | ||
| 1294 | + local hero = self.heros[heroId] | ||
| 1295 | + if hero then | ||
| 1296 | + totalCoef = totalCoef + getHeroCoef(hero, data.success) | ||
| 1297 | + hero:addHeroFaith(data.trust) | ||
| 1298 | + end | ||
| 1299 | + end | ||
| 1300 | + | ||
| 1301 | + local bigSuccess = false | ||
| 1302 | + local result = math.randomInt(0, 100) | ||
| 1303 | + if result < totalCoef then | ||
| 1304 | + bigSuccess = true | ||
| 1305 | + end | ||
| 1306 | + | ||
| 1307 | + local money = math.ceil(carbonCsv[expCarbonId].money / 5 * data.time * data.money_clear) | ||
| 1308 | + local exp = math.ceil(carbonCsv[expCarbonId].exp / 5 * data.time * data.exp_clear) | ||
| 1309 | + local itemReward = data.item_clear_special:toNumMap() | ||
| 1310 | + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money | ||
| 1311 | + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp | ||
| 1312 | + | ||
| 1313 | + if bigSuccess then | ||
| 1314 | + for key, value in pairs(itemReward) do | ||
| 1315 | + itemReward[key] = math.ceil(1.5 * value) | ||
| 1316 | + end | ||
| 1317 | + end | ||
| 1318 | + self:award(itemReward, {log = {desc = "seaportTask", int1 = slot, int2 = level}}) | ||
| 1319 | + end | ||
| 1320 | + end | ||
| 1321 | + end | ||
| 1322 | + end | ||
| 1323 | + seaport.collect = {} | ||
| 1324 | + | ||
| 1325 | + if update or reset then | ||
| 1326 | + if reset then | ||
| 1327 | + seaport = { | ||
| 1328 | + time = openTime0, | ||
| 1329 | + shop = {}, | ||
| 1330 | + collect = {}, | ||
| 1331 | + donate = {} | ||
| 1332 | + } | ||
| 1333 | + end | ||
| 1334 | + self:updateProperty({field = "seaport", value = seaport}) | ||
| 1335 | + end | ||
| 1336 | + end | ||
| 1337 | + | ||
| 1338 | + if oldTime == openTime0 then | ||
| 1339 | + if openTime1 == 1 or openTime2 == 1 then | ||
| 1340 | + return | ||
| 1341 | + end | ||
| 1342 | + getReward() | ||
| 1343 | + else | ||
| 1344 | + getReward(true) | ||
| 1345 | + end | ||
| 1346 | + end | ||
| 1347 | + | ||
| 1348 | + function Role:getSeaportServerProgress() | ||
| 1349 | + local result = {} | ||
| 1350 | + | ||
| 1351 | + local dataCsv = csvdb["seaport_purchaseCsv"] | ||
| 1352 | + local rediskey = {SEAPORT_TRADE_TASK_1,SEAPORT_TRADE_TASK_2} | ||
| 1353 | + for idx, set in ipairs(dataCsv) do | ||
| 1354 | + local temp = {} | ||
| 1355 | + temp = redisproxy:pipelining(function (red) | ||
| 1356 | + for id, data in ipairs(set) do | ||
| 1357 | + red:hget(rediskey[idx], id) | ||
| 1358 | + end | ||
| 1359 | + end) | ||
| 1360 | + result[idx] = {} | ||
| 1361 | + for i,v in pairs(temp) do | ||
| 1362 | + if v then | ||
| 1363 | + result[idx][i] = tonumber(v) | ||
| 1364 | + end | ||
| 1365 | + end | ||
| 1366 | + end | ||
| 1367 | + return result | ||
| 1368 | + end | ||
| 1369 | + | ||
| 1220 | -- 获得激活的冒险效果 | 1370 | -- 获得激活的冒险效果 |
| 1221 | function Role:getAdvActiveSupportEffect() | 1371 | function Role:getAdvActiveSupportEffect() |
| 1222 | local effect = {} | 1372 | local effect = {} |
src/models/RoleTask.lua
| @@ -191,7 +191,7 @@ local AchievListener = { | @@ -191,7 +191,7 @@ local AchievListener = { | ||
| 191 | [TaskType.OverOderTask] = {{14}}, | 191 | [TaskType.OverOderTask] = {{14}}, |
| 192 | [TaskType.FoodSellGold] = {{15, f("count")}}, | 192 | [TaskType.FoodSellGold] = {{15, f("count")}}, |
| 193 | [TaskType.DinerPopular] = {{16, f("count")}}, | 193 | [TaskType.DinerPopular] = {{16, f("count")}}, |
| 194 | - [TaskType.TowerPass] = {{17, f("count"), f("type")}}, | 194 | + [TaskType.TowerPass] = {{17, f("level")}}, |
| 195 | [TaskType.OpenBox] = {{18, f("count")}}, | 195 | [TaskType.OpenBox] = {{18, f("count")}}, |
| 196 | [TaskType.DinerLevelUp] = {{19, f("level"), f("type")}}, | 196 | [TaskType.DinerLevelUp] = {{19, f("level"), f("type")}}, |
| 197 | [TaskType.DinerTalentUp] = {{20, 1, f("type")}}, | 197 | [TaskType.DinerTalentUp] = {{20, 1, f("type")}}, |
| @@ -493,6 +493,7 @@ function RoleTask.bind(Role) | @@ -493,6 +493,7 @@ function RoleTask.bind(Role) | ||
| 493 | [6] = true, | 493 | [6] = true, |
| 494 | [7] = true, | 494 | [7] = true, |
| 495 | [16] = true, | 495 | [16] = true, |
| 496 | + [17] = true, | ||
| 496 | [19] = true, | 497 | [19] = true, |
| 497 | [22] = true, | 498 | [22] = true, |
| 498 | [23] = true, | 499 | [23] = true, |
src/services/globald.lua
| @@ -153,7 +153,36 @@ local function check_battle_act_close() | @@ -153,7 +153,36 @@ local function check_battle_act_close() | ||
| 153 | skynet.timeout(CHECK_BATTLE_ACT_CLOSE_INTERVAL, check_battle_act_close) | 153 | skynet.timeout(CHECK_BATTLE_ACT_CLOSE_INTERVAL, check_battle_act_close) |
| 154 | end | 154 | end |
| 155 | 155 | ||
| 156 | +-- @desc: 检查海港贸易开启、关闭 | ||
| 157 | +local function check_trade_seaport_status() | ||
| 158 | + local nowTime = skynet.timex() | ||
| 159 | + local nextTime = dayLater(nowTime) | ||
| 160 | + local interval = 100 * (nextTime - nowTime + 1) | ||
| 161 | + | ||
| 162 | + local curTm = os.date("*t", nowTime) | ||
| 163 | + if curTm.wday == 7 and curTm.hour >= 4 then -- 周六 | ||
| 164 | + local oldTime = tonumber(redisproxy:hget("autoincrement_set", "seaportTime0")) or 0 | ||
| 165 | + local cur4Time = specTime({hour = 4},nowTime) | ||
| 166 | + if cur4Time ~= oldTime then | ||
| 167 | + redisproxy:hset("autoincrement_set", "seaportTime0", cur4Time) | ||
| 168 | + redisproxy:hset("autoincrement_set", "seaportTime1", 1) | ||
| 169 | + redisproxy:del(SEAPORT_TRADE_TASK_1) | ||
| 170 | + redisproxy:del(SEAPORT_TRADE_TASK_2) | ||
| 171 | + end | ||
| 172 | + end | ||
| 173 | + if curTm.wday == 1 and curTm.hour >= 4 then -- 周日 | ||
| 174 | + if (tonumber(redisproxy:hget("autoincrement_set", "seaportTime1")) or 0) == 1 then | ||
| 175 | + redisproxy:hset("autoincrement_set", "seaportTime2", 1) | ||
| 176 | + end | ||
| 177 | + end | ||
| 178 | + if curTm.wday == 2 and curTm.hour >= 4 then -- 周一 | ||
| 179 | + -- redisproxy:hset("autoincrement_set", "seaportTime0", 0) | ||
| 180 | + redisproxy:hset("autoincrement_set", "seaportTime1", 0) | ||
| 181 | + redisproxy:hset("autoincrement_set", "seaportTime2", 0) | ||
| 182 | + end | ||
| 156 | 183 | ||
| 184 | + skynet.timeout(interval, check_trade_seaport_status) | ||
| 185 | +end | ||
| 157 | 186 | ||
| 158 | local CMD = {} | 187 | local CMD = {} |
| 159 | 188 | ||
| @@ -178,6 +207,7 @@ end | @@ -178,6 +207,7 @@ end | ||
| 178 | function CMD.start() | 207 | function CMD.start() |
| 179 | check_mail_queue() | 208 | check_mail_queue() |
| 180 | --check_battle_act_close() | 209 | --check_battle_act_close() |
| 210 | + check_trade_seaport_status() | ||
| 181 | end | 211 | end |
| 182 | 212 | ||
| 183 | local function __init__() | 213 | local function __init__() |
-
mentioned in commit 3bfb5fbe05bdb05d79d540526a71b3d8972ec84f