Commit d5c7ac6d111f01d842065245932c55ab84800460

Authored by 熊润斐
2 parents a3e27e79 56763ca7

Merge branch 'cn/develop' into cn/publish/release

src/actions/RadioAction.lua
@@ -35,6 +35,79 @@ local function getQuestMax(role) @@ -35,6 +35,79 @@ local function getQuestMax(role)
35 return count + (globalCsv.cursade_team_count_initial or 0) 35 return count + (globalCsv.cursade_team_count_initial or 0)
36 end 36 end
37 37
  38 +local function getCrusadeReward(role, id)
  39 + local radioTask = role:getProperty("radioTask")
  40 + local task = radioTask[id]
  41 + if not task then return 1 end
  42 + -- check id
  43 + local config = csvdb["crusadeCsv"][id]
  44 + if not config then return 2 end
  45 + local carbonData = csvdb["idle_battleCsv"][config.unlock]
  46 + if not carbonData then return 3 end
  47 + -- get heros
  48 + local totalCoef = 0
  49 + local exp = config.time / 60
  50 + local heroFaithMap = {}
  51 + for _, heroId in ipairs(task.heros) do
  52 + local hero = role.heros[heroId]
  53 + if hero then
  54 + totalCoef = totalCoef + getHeroCoef(hero, config.success)
  55 + -- 增加英雄信赖
  56 + hero:addHeroFaith(exp)
  57 + heroFaithMap[heroId] = hero:getProperty("faith")
  58 + end
  59 + end
  60 + -- send award
  61 + local bigSuccess = false
  62 + local result = math.randomInt(0, 100)
  63 + if result < totalCoef then
  64 + bigSuccess = true
  65 + end
  66 + local money = math.ceil(carbonData.money / 5) * config.time * config.money_clear
  67 + local exp = math.ceil(carbonData.exp / 5) * config.time * config.exp_clear
  68 + local itemReward = config.item_clear_special:toNumMap()
  69 + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money
  70 + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp
  71 + if bigSuccess then
  72 + for key, value in pairs(itemReward) do
  73 + itemReward[key] = math.ceil(1.5 * value)
  74 + end
  75 + end
  76 +
  77 + local r, change = role:award(itemReward, {log = {desc = "radioQuest", int1 = id}})
  78 +
  79 + radioTask[id] = nil
  80 + role:updateProperty({field="radioTask", value=radioTask, notNotify = true})
  81 +
  82 + local msg = role:packReward(r, change)
  83 + msg["big"] = bigSuccess
  84 + msg["id"] = id
  85 + msg["heroFaith"] = heroFaithMap
  86 +
  87 + role:checkTaskEnter("RadioTaskStart", {heroCnt = #task.heros})
  88 +
  89 + local herolist = {}
  90 + for _, heroId in ipairs(task.heros) do
  91 + local hero = role.heros[heroId]
  92 + if hero then
  93 + table.insert(herolist, hero:getProperty("type"))
  94 + end
  95 + end
  96 +
  97 + -- 讨伐行动
  98 + role:log("punitive_action", {
  99 + mission_id = id, --关卡ID
  100 + mission_herolist = herolist, -- 英雄ID,排序以玩家出战设置为准,示例:[111, 222, 333, 444, 555]
  101 + mission_success_rate = totalCoef, -- 大成功几率
  102 + mission_reward = r, -- 获得奖励,建议使用json格式记录。示例:{ itemid1: 1, itemid2: 3, itemid3: 5}
  103 + mission_result = 1, -- 战斗结果(0-无效,1-胜利,2-失败)
  104 + mission_roundtime = config.time, -- 完成耗时(秒)
  105 + mission_cleartype = 2, -- 1-开始; 2-完成(领取奖励时)
  106 + })
  107 + role:mylog("role_action", {desc = "radioTask", int1 = id, short1 = bigSuccess and 1 or 0})
  108 + return msg
  109 +end
  110 +
38 function _M.startQuestRpc(agent, data) 111 function _M.startQuestRpc(agent, data)
39 local role = agent.role 112 local role = agent.role
40 local msg = MsgPack.unpack(data) 113 local msg = MsgPack.unpack(data)
@@ -132,76 +205,15 @@ function _M.finishQuestRpc(agent, data) @@ -132,76 +205,15 @@ function _M.finishQuestRpc(agent, data)
132 -- check finish time 205 -- check finish time
133 local radioTask = role:getProperty("radioTask") 206 local radioTask = role:getProperty("radioTask")
134 local task = radioTask[id] 207 local task = radioTask[id]
135 - if not task then return 1 end  
136 - if skynet.timex() < task.time then return 2 end  
137 - -- check id  
138 - local config = csvdb["crusadeCsv"][id]  
139 - if not config then return 3 end  
140 - local carbonData = csvdb["idle_battleCsv"][config.unlock]  
141 - if not carbonData then return 4 end  
142 - -- get heros  
143 - local totalCoef = 0  
144 - local exp = config.time / 60  
145 - local heroFaithMap = {}  
146 - for _, heroId in ipairs(task.heros) do  
147 - local hero = role.heros[heroId]  
148 - if hero then  
149 - totalCoef = totalCoef + getHeroCoef(hero, config.success)  
150 - -- 增加英雄信赖  
151 - hero:addHeroFaith(exp)  
152 - heroFaithMap[heroId] = hero:getProperty("faith")  
153 - end  
154 - end  
155 - -- send award  
156 - local bigSuccess = false  
157 - local result = math.randomInt(0, 100)  
158 - if result < totalCoef then  
159 - bigSuccess = true  
160 - end  
161 - local money = math.ceil(carbonData.money / 5) * config.time * config.money_clear  
162 - local exp = math.ceil(carbonData.exp / 5) * config.time * config.exp_clear  
163 - local itemReward = config.item_clear_special:toNumMap()  
164 - itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money  
165 - itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp  
166 - if bigSuccess then  
167 - for key, value in pairs(itemReward) do  
168 - itemReward[key] = math.ceil(1.5 * value)  
169 - end  
170 - end  
171 -  
172 - local r, change = role:award(itemReward, {log = {desc = "radioQuest", int1 = id}})  
173 -  
174 - radioTask[id] = nil  
175 - role:updateProperty({field="radioTask", value=radioTask, notNotify = true})  
176 -  
177 - local msg = role:packReward(r, change)  
178 - msg["big"] = bigSuccess  
179 - msg["id"] = id  
180 - msg["heroFaith"] = heroFaithMap  
181 - SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg))  
182 -  
183 - role:checkTaskEnter("RadioTaskStart", {heroCnt = #task.heros})  
184 -  
185 - local herolist = {}  
186 - for _, heroId in ipairs(task.heros) do  
187 - local hero = role.heros[heroId]  
188 - if hero then  
189 - table.insert(herolist, hero:getProperty("type"))  
190 - end 208 + if not task then return 4 end
  209 + if skynet.timex() < task.time then return 5 end
  210 +
  211 + local reward = getCrusadeReward(role, id)
  212 + if type(reward) == "number" then
  213 + return reward
  214 + else
  215 + SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(reward))
191 end 216 end
192 -  
193 - -- 讨伐行动  
194 - role:log("punitive_action", {  
195 - mission_id = id, --关卡ID  
196 - mission_herolist = herolist, -- 英雄ID,排序以玩家出战设置为准,示例:[111, 222, 333, 444, 555]  
197 - mission_success_rate = totalCoef, -- 大成功几率  
198 - mission_reward = r, -- 获得奖励,建议使用json格式记录。示例:{ itemid1: 1, itemid2: 3, itemid3: 5}  
199 - mission_result = 1, -- 战斗结果(0-无效,1-胜利,2-失败)  
200 - mission_roundtime = config.time, -- 完成耗时(秒)  
201 - mission_cleartype = 2, -- 1-开始; 2-完成(领取奖励时)  
202 - })  
203 - role:mylog("role_action", {desc = "radioTask", int1 = id, short1 = bigSuccess and 1 or 0})  
204 -  
205 return true 217 return true
206 end 218 end
207 219
@@ -212,12 +224,23 @@ function _M.cancelQuestRpc(agent, data) @@ -212,12 +224,23 @@ function _M.cancelQuestRpc(agent, data)
212 -- check finish time 224 -- check finish time
213 local radioTask = role:getProperty("radioTask") 225 local radioTask = role:getProperty("radioTask")
214 local task = radioTask[id] 226 local task = radioTask[id]
215 - if not task then return 1 end  
216 - if skynet.timex() > task.time then return 2 end  
217 - radioTask[id] = nil  
218 - role:updateProperty({field="radioTask", value=radioTask, notNotify = true})  
219 -  
220 - SendPacket(actionCodes.Radio_cancelQuestRpc, MsgPack.pack({id = id})) 227 + if not task then return 4 end
  228 + if skynet.timex() > task.time then return 5 end
  229 +
  230 + local remainT = task.time - skynet.timex()
  231 + if remainT > 0 then
  232 + local cost = math.ceil(remainT / 3600) * globalCsv.crusade_quicken
  233 + if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 6 end
  234 + role:costItems({[ItemId.Jade] = cost}, {log = {desc = "radioQuest", int1 = id}})
  235 + local reward = getCrusadeReward(role, id)
  236 + if type(reward) == "number" then
  237 + return reward
  238 + else
  239 + SendPacket(actionCodes.Radio_cancelQuestRpc, MsgPack.pack(reward))
  240 + end
  241 + else
  242 + SendPacket(actionCodes.Radio_cancelQuestRpc, MsgPack.pack({id = id}))
  243 + end
221 return true 244 return true
222 end 245 end
223 246
src/actions/RoleAction.lua
@@ -493,6 +493,10 @@ function _M.changeNameRpc(agent, data) @@ -493,6 +493,10 @@ function _M.changeNameRpc(agent, data)
493 ["name"] = newName, 493 ["name"] = newName,
494 }) 494 })
495 495
  496 + role.dinerData:updateRankRoleName(newName)
  497 + role:updateTowerRankName(newName)
  498 + role:updateAdvRankName(newName)
  499 +
496 role:changeCrossServerPvpSelfInfo("name") 500 role:changeCrossServerPvpSelfInfo("name")
497 role:checkTaskEnter("Rename", {}) 501 role:checkTaskEnter("Rename", {})
498 SendPacket(actionCodes.Role_changeNameRpc, MsgPack.pack({result = 0})) 502 SendPacket(actionCodes.Role_changeNameRpc, MsgPack.pack({result = 0}))
@@ -661,9 +665,8 @@ function _M.openTimeBoxRpc(agent, data) @@ -661,9 +665,8 @@ function _M.openTimeBoxRpc(agent, data)
661 if not role:checkItemEnough({[ItemId.Jade] = costKey}) then return 5 end 665 if not role:checkItemEnough({[ItemId.Jade] = costKey}) then return 5 end
662 role:costItems({[ItemId.Jade] = costKey}, {log = {desc = "openTimeBox", int1 = slot, int2 = oper}}) 666 role:costItems({[ItemId.Jade] = costKey}, {log = {desc = "openTimeBox", int1 = slot, int2 = oper}})
663 else 667 else
664 - stopTime = math.min(nowTime,time + globalCsv.box_productLine_time * 3600) 668 + stopTime = math.min(nowTime,time + globalCsv.box_productLine_time * 3600 + role:getBnousDismantlingMaximum())
665 end 669 end
666 - stopTime = stopTime + role:getBnousDismantlingMaximum()  
667 670
668 role:pushCancel({type = "box", slot = slot}) 671 role:pushCancel({type = "box", slot = slot})
669 672
src/models/Diner.lua
@@ -394,6 +394,18 @@ function Diner:getPopularRank() @@ -394,6 +394,18 @@ function Diner:getPopularRank()
394 return {list = list, rank = rank} 394 return {list = list, rank = rank}
395 end 395 end
396 396
  397 +function Diner:updateRankRoleName(name)
  398 + if name:len() <= 0 then return end
  399 +
  400 + local roleId = self.owner:getProperty("id")
  401 + local redret = redisproxy:hget(RANK_DINER_INFO, roleId)
  402 + if redret:len() > 0 then
  403 + local player = MsgPack.unpack(redret)
  404 + player.name = name
  405 + redisproxy:hset(RANK_DINER_INFO, roleId, MsgPack.pack(player))
  406 + end
  407 +end
  408 +
397 function Diner:data() 409 function Diner:data()
398 local properties = { 410 local properties = {
399 "buildL", 411 "buildL",
src/models/RolePlugin.lua
@@ -1697,6 +1697,30 @@ function RolePlugin.bind(Role) @@ -1697,6 +1697,30 @@ function RolePlugin.bind(Role)
1697 end 1697 end
1698 end 1698 end
1699 1699
  1700 + function Role:updateTowerRankName(name)
  1701 + if name:len() <= 0 then return end
  1702 + local roleId = self:getProperty("id")
  1703 + for _, info in pairs(TowerRankInfo) do
  1704 + local data = redisproxy:hget(info.rankInfo, roleId)
  1705 + if data then
  1706 + local player = MsgPack.unpack(data)
  1707 + player.name = name
  1708 + redisproxy:hset(info.rankInfo, roleId, MsgPack.pack(player))
  1709 + end
  1710 + end
  1711 + end
  1712 +
  1713 + function Role:updateAdvRankName(name)
  1714 + if name:len() <= 0 then return end
  1715 + local roleId = self:getProperty("id")
  1716 + local data = redisproxy:hget(RANK_ADV_INFO, roleId)
  1717 + if data then
  1718 + local player = MsgPack.unpack(data)
  1719 + player.name = name
  1720 + redisproxy:hset(RANK_ADV_INFO, roleId, MsgPack.pack(player))
  1721 + end
  1722 + end
  1723 +
1700 function Role:addAdvLvExp(exp) 1724 function Role:addAdvLvExp(exp)
1701 local advL = self:getProperty("advL") 1725 local advL = self:getProperty("advL")
1702 local level = advL[1] 1726 local level = advL[1]