Commit 53f77b2e1cd27eddc9822222c27cd714032274d0

Authored by 熊润斐
2 parents e6f86769 70fbe691

Merge branch 'tr/bugfix-qa' into tr/publish/qa-out

src/GlobalVar.lua
... ... @@ -81,6 +81,7 @@ ItemType = {
81 81 SelectItemBox = 17, -- 自选箱子
82 82 CommonPaster = 18, -- 万能贴纸
83 83 BossTicket = 20, -- boss挑战门票
  84 + Spark = 21, -- 火花
84 85 }
85 86  
86 87 --在这个里面的会记录的是功能开放 对应类型open 而不是 ID
... ... @@ -360,6 +361,7 @@ TriggerEventType = {
360 361 SSRCount = 6,
361 362 AfterTs = 7, -- 某时间以后
362 363 DrawHeroCnt = 8, -- 每日抽卡次数
  364 + Appoint = 0, -- 触发指定id礼包
363 365 }
364 366  
365 367 DrawCardType = {
... ...
src/ProtocolCode.lua
... ... @@ -51,6 +51,8 @@ actionCodes = {
51 51 Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄
52 52 Role_renameTeamRpc = 136, -- 编队改名
53 53 Role_accuseRpc = 137, -- 举报
  54 + Role_loadSparks = 138,
  55 + Role_updateSpark = 139, -- 更新火花
54 56  
55 57 Adv_startAdvRpc = 151,
56 58 Adv_startHangRpc = 152,
... ... @@ -102,6 +104,7 @@ actionCodes = {
102 104 Hero_drawHeroExtraRewardNtf = 224,
103 105 Hero_itemComposeRpc = 225,
104 106 Hero_setWishPoolRpc = 226,
  107 + Hero_changeSparkRpc = 227,
105 108  
106 109 Hang_startRpc = 251,
107 110 Hang_checkRpc = 252,
... ... @@ -152,6 +155,8 @@ actionCodes = {
152 155 Car_runeUpRpc = 402,
153 156 Car_saleEquipRpc = 403,
154 157 Car_saleRuneRpc = 404,
  158 + Car_sparkLvlUpRpc = 405,
  159 + Car_sparkQualityUpRpc = 406,
155 160  
156 161  
157 162 Friend_searchRpc = 450,
... ... @@ -237,6 +242,7 @@ actionCodes = {
237 242 Activity_newSignRpc = 670,
238 243 Activity_advLevelRpc = 671,
239 244 Activity_buyBattleCommandLvlRpc = 672,
  245 + Activity_returnerTaskRpc = 673,
240 246  
241 247 Radio_startQuestRpc = 700,
242 248 Radio_finishQuestRpc = 701,
... ...
src/RedisKeys.lua
... ... @@ -14,6 +14,8 @@ R_EMAIL_ITEM = "email:%d:%d" --邮件
14 14 R_STORE = "role:%d:store" -- 商店
15 15 R_ORDERS = "role:%d:orders" -- 订单
16 16 R_ORDER = "order:%d:%d"
  17 +R_SPARKIDS = "role:%d:sparkIds" -- 玩家拥有火花自增id
  18 +R_SPARK = "role:%d:spark:%d" -- 火花详细信息
17 19  
18 20 -- 通用排行榜
19 21 RANK_COMMON = "rank:common:"
... ...
src/actions/ActivityAction.lua
... ... @@ -1370,4 +1370,52 @@ function _M.advLevelRpc(agent, data)
1370 1370 return true
1371 1371 end
1372 1372  
  1373 +function _M.returnerTaskRpc(agent, data)
  1374 + local role = agent.role
  1375 + local msg = MsgPack.unpack(data)
  1376 +
  1377 + local taskId = msg.id or 0
  1378 + if taskId == 0 then return 0 end
  1379 +
  1380 + local returner = role:getProperty("returner") or {}
  1381 + if not returner[taskId] then return 1 end
  1382 +
  1383 + local tday = specTime({hour = 4})
  1384 + local curAllDay = (tday - returner.time) / 86400 + 1
  1385 +
  1386 + local TaskCsv = csvdb["activity_taskCsv"][76] or {}
  1387 + local taskData = TaskCsv[taskId]
  1388 + if not taskData then return 2 end
  1389 + if curAllDay < taskData.day then return 2 end
  1390 +
  1391 + local status = returner.status or {}
  1392 + if status[taskId] then return 3 end
  1393 +
  1394 + local done = true
  1395 + for _, data in pairs(TaskCsv) do
  1396 + if not status[data.id] then
  1397 + done = false
  1398 + break
  1399 + end
  1400 + end
  1401 +
  1402 + status[taskId] = 1
  1403 + returner.status = status
  1404 +
  1405 + local reward, change = role:award(taskData.reward, {log = {desc = "returner", int1 = taskData.day, int2 = taskId}})
  1406 +
  1407 + if done then
  1408 + returner = {}
  1409 + end
  1410 +
  1411 + local pack = globalCsv.returner_pack:toArray(true,"=")
  1412 + if pack[1] == taskData.id then
  1413 + role:checkTaskEnter("Appoint", {id = pack[2]})
  1414 + end
  1415 +
  1416 + role:updateProperty({field = "returner", value = returner})
  1417 + SendPacket(actionCodes.Activity_returnerTaskRpc, MsgPack.pack(role:packReward(reward, change)))
  1418 + return true
  1419 +end
  1420 +
1373 1421 return _M
... ...
src/actions/CarAction.lua
... ... @@ -211,4 +211,92 @@ function _M.saleRuneRpc(agent, data )
211 211 return true
212 212 end
213 213  
  214 +function _M.sparkQualityUpRpc( agent, data )
  215 + local role = agent.role
  216 + local msg = MsgPack.unpack(data)
  217 + local uid = msg.uid
  218 + local ownSpark = role.sparkBag[uid]
  219 + if not ownSpark then return 1 end
  220 +
  221 +
  222 + local cfg_id = ownSpark:getProperty("cfg_id")
  223 + local level = ownSpark:getProperty("level")
  224 +
  225 + local sparkSet = csvdb["sparkCsv"][cfg_id]
  226 + if not sparkSet then return 4 end
  227 + local sparkData = sparkSet[level]
  228 + if not sparkData then return 5 end
  229 +
  230 + if sparkData.star_up == 0 then return 6 end
  231 + local cost = sparkData.star_item:toNumMap()
  232 + if not role:checkItemEnough(cost) then
  233 + return 7
  234 + end
  235 +
  236 + role:costItems(cost, {log = {desc = "sparkQualityUp", int1 = uid, int2 = level}})
  237 +
  238 + local newSet = csvdb["sparkCsv"][sparkData.star_up]
  239 + if not newSet then return 8 end
  240 + local newSparkData = newSet[0]
  241 + if not newSparkData then return 9 end
  242 + local attrs = newSparkData.attr:toNumMap()
  243 + ownSpark:addAttr(attrs)
  244 + ownSpark:updateProperty({field = "level",value = 0})
  245 + ownSpark:updateProperty({field = "cfg_id",value = sparkData.star_up})
  246 + --role:checkTaskEnter("SparkQualityUp")
  247 +
  248 +
  249 + ownSpark:mylog({desc = "sparkQualityUp", int1 = sparkData.id , int2 = sparkData.star_up})
  250 +
  251 + SendPacket(actionCodes.Car_sparkQualityUpRpc, '')
  252 + return true
  253 +end
  254 +
  255 +function _M.sparkLvlUpRpc( agent, data )
  256 + local role = agent.role
  257 + local msg = MsgPack.unpack(data)
  258 + local uid = msg.uid
  259 + local ownSpark = role.sparkBag[uid]
  260 + if not ownSpark then return 1 end
  261 +
  262 +
  263 + local cfg_id = ownSpark:getProperty("cfg_id")
  264 + local level = ownSpark:getProperty("level")
  265 +
  266 + local sparkSet = csvdb["sparkCsv"][cfg_id]
  267 + if not sparkSet then return 4 end
  268 + local sparkData = sparkSet[level]
  269 + if not sparkData then return 5 end
  270 +
  271 + if level >= #sparkSet then return 6 end
  272 + local cost = sparkData.lv_up_item:toNumMap()
  273 + if not role:checkItemEnough(cost) then
  274 + return 7
  275 + end
  276 + local weight = math.random(0, 100)
  277 + local addLvl = 1
  278 + if weight < sparkData.probability then
  279 + addLvl = 2
  280 + end
  281 +
  282 + role:costItems(cost, {log = {desc = "sparkLvlUp", int1 = uid, int2 = level}})
  283 + local attrs = {}
  284 + for i = 1, addLvl do
  285 + local cfg = sparkSet[level + i]
  286 + if not cfg then break end
  287 + for k, v in pairs(cfg.attr:toNumMap()) do
  288 + attrs[k] = (attrs[k] or 0) + v
  289 + end
  290 + end
  291 + ownSpark:addAttr(attrs)
  292 + ownSpark:updateProperty({field = "level",value = level+addLvl})
  293 + --role:checkTaskEnter("SparkLvlUp")
  294 +
  295 +
  296 + ownSpark:mylog({desc = "sparkLvlUp", int1 = level + addLvl})
  297 +
  298 + SendPacket(actionCodes.Car_sparkLvlUpRpc, MsgPack.pack({big = (addLvl == 2)}))
  299 + return true
  300 +end
  301 +
214 302 return _M
215 303 \ No newline at end of file
... ...
src/actions/GmAction.lua
... ... @@ -166,6 +166,15 @@ function _M.rune(role, pms)
166 166 return result
167 167 end
168 168  
  169 +table.insert(helpDes, {"获得火花" , "spark", "零件id"})
  170 +function _M.spark(role, pms)
  171 + local id = tonum(pms.pm1)
  172 + local result = role:addSpark({id = id, log = {desc = "gm"}})
  173 + role:mylog("gm_action", {desc = "spark", int1 = id, key1 = pms.sender})
  174 +
  175 + return result == 0 and "成功" or "失败"
  176 +end
  177 +
169 178 table.insert(helpDes, {"通关挂机副本", "fb", "挂卡id"})
170 179 function _M.fb(role, pms) -- 直接通关
171 180 local carbonId = tonum(pms.pm1)
... ... @@ -594,6 +603,13 @@ function _M.clearbag(role, pms)
594 603 end
595 604 role:delRunes(uids, {log = {desc = "gm"}})
596 605  
  606 + -- 火花
  607 + uids = {}
  608 + for uid, _ in pairs(role.sparkBag) do
  609 + table.insert(uids, uid)
  610 + end
  611 + role:delSparks(uids, {log = {desc = "gm"}})
  612 +
597 613 return "成功"
598 614 end
599 615  
... ...
src/actions/HeroAction.lua
... ... @@ -105,6 +105,25 @@ function _M.wakeRpc(agent, data)
105 105 if not role:checkItemEnough(cost) then
106 106 return 4
107 107 end
  108 + local curLevel = hero:getProperty("wakeL")
  109 + local sparkInfo = hero:getProperty("spark")
  110 + -- 大于等于7的时候需要装备火花才能升
  111 + if curLevel >= 7 then
  112 + if #sparkInfo == 0 then
  113 + return 5
  114 + end
  115 + local ok = false
  116 + for _, info in ipairs(sparkInfo) do
  117 + local cfg = csvdb["sparkCsv"][info.cfg_id][info.level or 0]
  118 + if not cfg then return 6 end
  119 + if cfg.star == curLevel then
  120 + ok = true
  121 + break
  122 + end
  123 + end
  124 + if not ok then return 7 end
  125 + end
  126 +
108 127  
109 128 role:costItems(cost, {log = {desc = "heroWake", int1 = msg.id, int2 = hero:getProperty("type")}})
110 129  
... ... @@ -112,7 +131,6 @@ function _M.wakeRpc(agent, data)
112 131 local oldBattleV = hero:getProperty("battleV")
113 132 hero:updateProperty({field = "wakeL", delta = 1})
114 133  
115   - local curLevel = hero:getProperty("wakeL")
116 134 role:checkTaskEnter("Wake", {heroType = typ, wakeL = curLevel})
117 135 if curLevel == 3 then -- 解锁cg
118 136 role:checkTaskEnter("WakeCG", {heroType = typ})
... ... @@ -1193,4 +1211,52 @@ function _M.setWishPoolRpc(agent, data)
1193 1211 return true
1194 1212 end
1195 1213  
  1214 +function _M.changeSparkRpc(agent, data)
  1215 + local role = agent.role
  1216 + local msg = MsgPack.unpack(data)
  1217 +
  1218 + local idx = msg.index
  1219 + local sparkId = msg.spark_id
  1220 + local heroId = msg.hero_id
  1221 + local hero = role.heros[heroId]
  1222 + if not hero then return 1 end
  1223 +
  1224 + local spark = role.sparkBag[sparkId]
  1225 + if not spark then return 2 end
  1226 +
  1227 + local lvl = spark:getProperty("level")
  1228 + local cfgId = spark:getProperty("cfg_id")
  1229 +
  1230 + local dataSet = csvdb["sparkCsv"][cfgId]
  1231 + if not dataSet then return 3 end
  1232 + local cfg = dataSet[lvl]
  1233 + if not cfg then return 4 end
  1234 +
  1235 + if hero:getProperty("wakeL") < cfg.star then return 5 end
  1236 +
  1237 + local itemCfg = csvdb["itemCsv"][cfgId]
  1238 + if not itemCfg then return 6 end
  1239 + if itemCfg.quality ~= hero:getRare() then return 6 end
  1240 +
  1241 + local sparkList = hero:getProperty("spark") or {}
  1242 + local oldSparkInfo = sparkList[idx] or {}
  1243 + sparkList[idx] = spark:data()
  1244 + hero:updateProperty({field="spark", value=sparkList})
  1245 +
  1246 + role:delSparks({sparkId}, {log = {desc = "changeSpark"}})
  1247 + local oldId = oldSparkInfo["cfg_id"] or 0
  1248 + local oldLevel = oldSparkInfo["level"] or 0
  1249 + local oldSparkSet = csvdb["sparkCsv"][oldId]
  1250 + local reward = {}
  1251 + if oldSparkSet then
  1252 + local oldSparkCfg = oldSparkSet[oldLevel]
  1253 + if oldSparkSet then
  1254 + reward = oldSparkCfg.back:toNumMap()
  1255 + end
  1256 + end
  1257 +
  1258 + SendPacket(actionCodes.Hero_changeSparkRpc, MsgPack.pack({reward = reward}))
  1259 + return true
  1260 +end
  1261 +
1196 1262 return _M
... ...
src/actions/RoleAction.lua
... ... @@ -16,6 +16,7 @@ local httpc = require(&quot;http.httpc&quot;)
16 16  
17 17 local WAVE_HERO_NUMS = 150
18 18 local WAVE_RUNE_NUMS = 150
  19 +local WAVE_SPARK_NUMS = 150
19 20  
20 21 local function validName(name)
21 22 name = string.upper(name)
... ... @@ -204,6 +205,16 @@ function _M.loginRpc( agent, data )
204 205 table_insert(modules, "runeBag")
205 206 end
206 207  
  208 + local sparkIds = {}
  209 + for id ,_ in pairs(role.sparkBag) do
  210 + table.insert(sparkIds, id)
  211 + end
  212 + local sparkWave = math.ceil(#sparkIds / WAVE_SPARK_NUMS)
  213 + if #sparkIds <= 50 then
  214 + sparkWave = 0
  215 + table_insert(modules, "sparkBag")
  216 + end
  217 +
207 218 for _, name in ipairs(modules) do
208 219 response[name] = {}
209 220 for id, unit in pairs(role[name]) do
... ... @@ -211,12 +222,29 @@ function _M.loginRpc( agent, data )
211 222 end
212 223 end
213 224  
214   - response.wave = 1 + heroWave + runeWave + 1
  225 + response.wave = 1 + heroWave + runeWave + sparkWave + 1
215 226  
216 227 SendPacket(actionCodes.Role_loginRpc, MsgPack.pack(response))
217 228  
218 229 local curWave = 1
219 230  
  231 + local sparkIndex = 1
  232 + for index = curWave + 1, curWave + sparkWave do
  233 + local sparkResponse = {sparkBag = {}}
  234 + for i = sparkIndex, sparkIndex + WAVE_SPARK_NUMS do
  235 + local sparkId = sparkIds[i]
  236 + if not sparkId then
  237 + break
  238 + end
  239 + local spark = role.sparkBag[sparkId]
  240 + table.insert(sparkResponse.sparkBag, spark:data())
  241 + sparkIndex = sparkIndex + 1
  242 + end
  243 + sparkResponse.sparkWave = index
  244 + SendPacket(actionCodes.Role_loginRpc, MsgPack.pack(sparkResponse))
  245 + end
  246 + curWave = curWave + sparkWave
  247 +
220 248 local runeIndex = 1
221 249 for index = curWave + 1, curWave + runeWave do
222 250 local runeResponse = {runeBag = {}}
... ...
src/actions/SeaportAction.lua
... ... @@ -139,9 +139,16 @@ function _M.taskRpc(agent, data)
139 139 if not TaskCsv[taskId] or not TaskCsv[taskId][level] then return 1 end
140 140  
141 141 local reward, change = {}, {}
  142 + local heroFaithMap = {}
142 143 local seaport = role:getProperty("seaport")
143 144  
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 +
145 152 if oper == 1 then -- 开始委托
146 153 if team == "" then return 3 end
147 154 local conditions = data.condition:toTableArray(true)
... ... @@ -197,8 +204,7 @@ function _M.taskRpc(agent, data)
197 204  
198 205 local carbonCsv = csvdb["idle_battleCsv"]
199 206 local expCarbonId = role:getProperty("hangInfo").expCarbonId
200   - local coidCarbonId = role:getProperty("hangInfo").carbonId
201   - if not carbonCsv[expCarbonId] or not carbonCsv[coidCarbonId] then return 7 end
  207 + if not carbonCsv[expCarbonId] then return 7 end
202 208  
203 209 local totalCoef = 0
204 210 for _, heroId in ipairs(collect.team:toArray(true,"=")) do
... ... @@ -206,6 +212,7 @@ function _M.taskRpc(agent, data)
206 212 if hero then
207 213 totalCoef = totalCoef + getHeroCoef(hero, data.success)
208 214 hero:addHeroFaith(data.trust)
  215 + heroFaithMap[heroId] = hero:getProperty("faith")
209 216 end
210 217 end
211 218  
... ... @@ -215,8 +222,8 @@ function _M.taskRpc(agent, data)
215 222 bigSuccess = true
216 223 end
217 224  
218   - local money = math.ceil(carbonCsv[coidCarbonId].money / 5 * data.time * carbonCsv[coidCarbonId].money_clear)
219   - local exp = math.ceil(carbonCsv[expCarbonId].exp / 5 * data.time * carbonCsv[expCarbonId].exp_clear)
  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)
220 227 local itemReward = data.item_clear_special:toNumMap()
221 228 itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money
222 229 itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp
... ... @@ -236,7 +243,10 @@ function _M.taskRpc(agent, data)
236 243  
237 244 role:updateProperty({field = "seaport", value = seaport})
238 245  
239   - SendPacket(actionCodes.Seaport_taskRpc, MsgPack.pack(role:packReward(reward, change)))
  246 + local result = role:packReward(reward, change)
  247 + result["heroFaith"] = heroFaithMap
  248 +
  249 + SendPacket(actionCodes.Seaport_taskRpc, MsgPack.pack(result))
240 250 return true
241 251 end
242 252  
... ...
src/actions/TowerAction.lua
... ... @@ -109,7 +109,9 @@ function _M.endBattleRpc(agent, data)
109 109  
110 110 curLevel = curLevel + 1
111 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 115 end
114 116  
115 117 if towerType == 0 then
... ...
1   -Subproject commit 686b192263f5cc221e472e1b9a41d059d581da2d
  1 +Subproject commit ec92ed50d3d5ff9655b1715239e7fda48f8ef5cb
... ...
src/models/Hero.lua
... ... @@ -16,6 +16,7 @@ Hero.schema = {
16 16 equip = {"string",""}, --装备 type=level
17 17 rune = {"string",""}, --零件 type=id
18 18 faith = {"number", 0}, -- 信赖
  19 + spark = {"table", {}}, -- 火花属性
19 20 }
20 21  
21 22 function Hero:ctor( properties )
... ... @@ -47,7 +48,7 @@ end
47 48 function Hero:updateProperties(params, notNotify)
48 49 self:setProperties(params)
49 50  
50   - local check = {level = true, breakL = true, wakeL = true, talent = true, loveL = true, equip = true, rune = true}
  51 + local check = {level = true, breakL = true, wakeL = true, talent = true, loveL = true, equip = true, rune = true, spark = true}
51 52 local datas = {}
52 53 local updateBV = false
53 54 for k , v in pairs(params) do
... ... @@ -78,7 +79,7 @@ function Hero:updateProperty(params)
78 79 local datas = {}
79 80 table.insert(datas, {key = params.field, newValue = self:getProperty(params.field)})
80 81  
81   - local check = {level = true, breakL = true, wakeL = true, talent = true, loveL = true, equip = true, rune = true}
  82 + local check = {level = true, breakL = true, wakeL = true, talent = true, loveL = true, equip = true, rune = true, spark = true}
82 83 if check[params.field] then
83 84 local orginValue = self:getProperty("battleV")
84 85 local curValue = self:saveBattleValue()
... ... @@ -103,7 +104,8 @@ function Hero:data()
103 104 -- loveL = self:getProperty("loveL"),
104 105 equip = self:getProperty("equip"),
105 106 rune = self:getProperty("rune"),
106   - faith = self:getProperty("faith")
  107 + faith = self:getProperty("faith"),
  108 + spark = self:getProperty("spark"),
107 109 }
108 110 end
109 111  
... ...
src/models/HeroPlugin.lua
... ... @@ -121,11 +121,13 @@ function HeroPlugin.bind(Hero)
121 121 local attrs = self:getBaseAttrs()
122 122 -- 装备零件
123 123 local equipAttrs = self:getRuneEquipAttrs()
  124 + local sparkAttrs = self:getSparkAttrs()
124 125  
125 126 for _, attName in pairs(AttsEnumEx) do
126 127 attrs[attName] = attrs[attName] or 0
127 128 attrs[attName] = attrs[attName] + addAttr(attrs[attName], equipAttrs.percent[attName], 1, attName)
128 129 attrs[attName] = attrs[attName] + addAttr(attrs[attName], equipAttrs.value[attName], 0, attName)
  130 + attrs[attName] = attrs[attName] + addAttr(attrs[attName], sparkAttrs[attName], 0, attName)
129 131 end
130 132  
131 133 -- 羁绊加成
... ... @@ -225,6 +227,19 @@ function HeroPlugin.bind(Hero)
225 227 return attrs
226 228 end
227 229  
  230 + function Hero:getSparkAttrs()
  231 + local attrs = {}
  232 + for _, attName in pairs(AttsEnumEx) do
  233 + attrs[attName] = 0
  234 + end
  235 + for _, data in pairs(self.spark or {}) do
  236 + for k, v in pairs(data.attrs:toNumMap()) do
  237 + attrs[AttsEnumEx[k]] = attrs[AttsEnumEx[k]] + v
  238 + end
  239 + end
  240 + return attrs
  241 + end
  242 +
228 243  
229 244 -- 战斗力(当前属性)= POWER[(生命 + 防御 * 7 + 闪避 * 4)*(攻击*4 + 命中 * 2)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ]
230 245 -- function Hero:getBattleValue(activeRelation) -- isReal包括队伍加成
... ...
src/models/Role.lua
... ... @@ -25,6 +25,7 @@ function Role:ctor( properties )
25 25 self.storeData = nil
26 26 self.heros = {}
27 27 self.runeBag = {}
  28 + self.sparkBag = {}
28 29 self.advData = nil
29 30 self.activity = nil
30 31 self._pushToken = nil
... ... @@ -190,6 +191,8 @@ Role.schema = {
190 191 radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv
191 192  
192 193 seaport = {"table", {}}, -- 海岛贸易季 {time = 1234567890, donate = {}, collect = {[1] = {team = "1=2=3", time = 1234567890}}, shop = {}}
  194 +
  195 + returner = {"table", {}}, -- 回归者 {time = 12334233423, [1] = 1, [2] = 2, status = {[1] = 1}}
193 196 }
194 197  
195 198  
... ... @@ -422,6 +425,7 @@ function Role:data()
422 425 radioTask = self:getProperty("radioTask"),
423 426  
424 427 seaport = self:getProperty("seaport"),
  428 + returner = self:getProperty("returner"),
425 429 }
426 430 end
427 431  
... ...
src/models/RoleLog.lua
... ... @@ -127,6 +127,9 @@ local ItemReason = {
127 127 refer = 1210, -- 穿戴
128 128 itemCompose = 1211, -- 天赋道具合成
129 129 radioQuest = 1212, -- 电台任务奖励
  130 + changeSpark = 1213, -- 穿戴火花
  131 + sparkLvlUp = 1214, -- 火花强化
  132 + sparkQualityUp = 1215, -- 火花升华
130 133  
131 134 -- pvp
132 135 pvpCHead = 1301, -- pvp 跨服竞技场头像
... ... @@ -140,6 +143,8 @@ local ItemReason = {
140 143 seaportShop = 1401, -- 贸易港商店兑换
141 144 seaportReward = 1402, -- 贸易港阶段奖励
142 145 seaportTask = 1403, -- 贸易港任务奖励
  146 +
  147 + returner = 1410, -- 回归者奖励
143 148 }
144 149  
145 150  
... ... @@ -622,6 +627,8 @@ local LogType = {
622 627 in_adv = "common",
623 628 out_adv = "common",
624 629 in_artifact = "common",
  630 + in_spark = "common",
  631 + out_spark = "common",
625 632  
626 633 mail_action = "common",
627 634 role_action = "common",
... ... @@ -634,6 +641,7 @@ local LogType = {
634 641 tower_action = "common",
635 642 gm_action = "common",
636 643 act_action = "common",
  644 + spark_action = "common",
637 645 }
638 646  
639 647 -- 如要修改 要提前修改 _template mapping -- 对应 mapping 为 gamelog-*
... ...
src/models/RolePlugin.lua
... ... @@ -12,6 +12,7 @@ function RolePlugin.bind(Role)
12 12 self:loadDiner()
13 13 self:loadActivity()
14 14 self:loadStoreInfo()
  15 + self:loadSparks()
15 16 end
16 17  
17 18 function Role:reloadWhenLogin()
... ... @@ -96,6 +97,11 @@ function RolePlugin.bind(Role)
96 97 self:addRune({type = typ,id = itemId, notNotify = pms.notNotify, log = pms.log})
97 98 end
98 99 end,
  100 + [ItemType.Spark] = function()
  101 + for _= 1, count do
  102 + self:addSpark({id = itemId, notNotify = pms.notNotify, log = pms.log})
  103 + end
  104 + end,
99 105 [ItemType.AdvItem] = function() --冒险道具不会进入 玩家仓库
100 106 count = 0
101 107 end,
... ... @@ -748,6 +754,23 @@ function RolePlugin.bind(Role)
748 754 end
749 755 end
750 756  
  757 + function Role:loadSparks()
  758 + local roleId = self:getProperty("id")
  759 + local sparkIds = redisproxy:smembers(string.format(R_SPARKIDS, roleId))
  760 + local redret = redisproxy:pipelining(function (red)
  761 + for _, sparkId in ipairs(sparkIds) do
  762 + red:hgetall(string.format(R_SPARK, roleId, sparkId))
  763 + end
  764 + end)
  765 + for index, sparkId in ipairs(sparkIds) do
  766 + local spark = require("models.Spark").new({key = string.format(R_SPARK, roleId, sparkId)})
  767 + if spark:load(table.array2Table(redret[index])) then
  768 + spark.owner = self
  769 + self.sparkBag[tonumber(sparkId)] = spark
  770 + end
  771 + end
  772 + end
  773 +
751 774 -- 0 为操作成功
752 775 function Role:addRune(params)
753 776 if params.type and params.id then
... ... @@ -802,6 +825,101 @@ function RolePlugin.bind(Role)
802 825 end
803 826 end
804 827  
  828 + -- 0 为操作成功
  829 + function Role:addSpark(params)
  830 + if params.id then
  831 + local set = csvdb["sparkCsv"][params.id]
  832 + if not set then return 2 end
  833 + local data = set[0]
  834 + if not data then return 3 end
  835 +
  836 + local roleId = self:getProperty("id")
  837 + local sparkUid = tonum(redisproxy:hincrby(string.format(R_INCR, roleId), "spark", 1))
  838 +
  839 + redisproxy:sadd(string.format(R_SPARKIDS, roleId), sparkUid)
  840 +
  841 + local sparkInfo = {
  842 + key = string.format(R_SPARK, roleId, sparkUid),
  843 + id = sparkUid,
  844 + cfg_id = params.id,
  845 + }
  846 +
  847 + local newSpark = require("models.Spark").new(sparkInfo)
  848 + newSpark:create()
  849 + newSpark:addAttr(data.attr:toNumMap())
  850 + newSpark.owner = self
  851 + self.sparkBag[sparkUid] = newSpark
  852 + if not params.notNotify then
  853 + local response = {}
  854 + table.insert(response, newSpark:data())
  855 + dump(response)
  856 + SendPacket(actionCodes.Role_loadSparks, MsgPack.pack(response))
  857 + end
  858 + --self:checkTaskEnter("AddRune", {id = params.id, type = params.type, rarity = data.rarity}, params.notNotify)
  859 +
  860 + self:logItems(params.id, 0, 1, params.log)
  861 + if params.log then
  862 + local log = clone(params.log)
  863 + if log["cint1"] or log["cint2"] or log["cint3"] then
  864 + print("addRune error log have cint1 or cint2 or cint3 ", debug.traceback())
  865 + end
  866 +
  867 + log["cint1"] = sparkUid
  868 + log["cint2"] = params.cfg_id
  869 +
  870 + self:mylog("in_spark", log)
  871 + else
  872 + print("addSpark no log ", debug.traceback())
  873 + end
  874 +
  875 + return 0, newSpark
  876 + else
  877 + return 1
  878 + end
  879 + end
  880 +
  881 + function Role:delSparks(sparkIds, params) -- 批量删除 {id, }
  882 + params = params or {}
  883 + local roleId = self:getProperty('id')
  884 + local bDel = {}
  885 + for _, sparkId in pairs(sparkIds) do
  886 + local spark = self.sparkBag[sparkId]
  887 + if spark then
  888 +
  889 + self:logItems(spark:getProperty("id"), 1, 0, params.log)
  890 + if params.log then
  891 + local log = clone(params.log)
  892 + if log["cint1"] or log["cint2"] then
  893 + print("delSpark error log have cint1 or cint2 ", debug.traceback())
  894 + end
  895 +
  896 + log["cint1"] = sparkId
  897 + log["cint2"] = spark:getProperty("cfg_id")
  898 +
  899 + self:mylog("out_spark", log)
  900 + else
  901 + print("delSparks no log ", debug.traceback())
  902 + end
  903 +
  904 + self.sparkBag[sparkId] = nil
  905 + table.insert(bDel, sparkId)
  906 + end
  907 + end
  908 +
  909 + redisproxy:pipelining(function (red)
  910 + for _, sparkId in pairs(bDel) do
  911 + red:del(string.format(R_SPARK, roleId, sparkId))
  912 + red:srem(string.format(R_SPARKIDS, roleId), sparkId)
  913 + end
  914 + end)
  915 + local response = {}
  916 + for _, sparkId in pairs(bDel) do
  917 + table.insert(response, {id = sparkId, bDel = true})
  918 + end
  919 +
  920 + SendPacket(actionCodes.Role_loadSparks, MsgPack.pack(response))
  921 + end
  922 +
805 923 function Role:delRunes(runeIds, params) -- 批量删除 {id, }
806 924 params = params or {}
807 925 local roleId = self:getProperty('id')
... ... @@ -1233,8 +1351,8 @@ function RolePlugin.bind(Role)
1233 1351 end
1234 1352 if done then
1235 1353 update = true
1236   - self:award(data.phase_award, {log = {desc = "seaportReward", int1 = set[1].phase, int2 = set[1].id}})
1237   - donate[id] = 1
  1354 + self:award(set[1].phase_award, {log = {desc = "seaportReward", int1 = set[1].phase, int2 = set[1].id}})
  1355 + donate[idx] = 1
1238 1356 end
1239 1357 end
1240 1358 seaport.donate = donate
... ... @@ -1268,7 +1386,6 @@ function RolePlugin.bind(Role)
1268 1386  
1269 1387 local carbonCsv = csvdb["idle_battleCsv"]
1270 1388 local expCarbonId = self:getProperty("hangInfo").expCarbonId
1271   - local coidCarbonId = self:getProperty("hangInfo").carbonId
1272 1389 local taskCsv = csvdb["seaport_taskCsv"]
1273 1390 local endTime = openTime0 + 86400 * 2
1274 1391 for slot, set in pairs(taskCsv) do
... ... @@ -1279,7 +1396,7 @@ function RolePlugin.bind(Role)
1279 1396 local teams = collect[slot].team
1280 1397 local time = collect[slot].time
1281 1398 if time + data.time <= endTime then
1282   - if not carbonCsv[expCarbonId] or not carbonCsv[coidCarbonId] then break end
  1399 + if not carbonCsv[expCarbonId] then break end
1283 1400  
1284 1401 local totalCoef = 0
1285 1402 for _, heroId in ipairs(teams:toArray(true,"=")) do
... ... @@ -1296,8 +1413,8 @@ function RolePlugin.bind(Role)
1296 1413 bigSuccess = true
1297 1414 end
1298 1415  
1299   - local money = math.ceil(carbonCsv[coidCarbonId].money / 5 * data.time * carbonCsv[coidCarbonId].money_clear)
1300   - local exp = math.ceil(carbonCsv[expCarbonId].exp / 5 * data.time * carbonCsv[expCarbonId].exp_clear)
  1416 + local money = math.ceil(carbonCsv[expCarbonId].money / 5 * data.time * data.money_clear)
  1417 + local exp = math.ceil(carbonCsv[expCarbonId].exp / 5 * data.time * data.exp_clear)
1301 1418 local itemReward = data.item_clear_special:toNumMap()
1302 1419 itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money
1303 1420 itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp
... ... @@ -1323,7 +1440,7 @@ function RolePlugin.bind(Role)
1323 1440 donate = {}
1324 1441 }
1325 1442 end
1326   - self:setProperty("seaport",seaport)
  1443 + self:updateProperty({field = "seaport", value = seaport})
1327 1444 end
1328 1445 end
1329 1446  
... ... @@ -1337,6 +1454,17 @@ function RolePlugin.bind(Role)
1337 1454 end
1338 1455 end
1339 1456  
  1457 + -- 检查回归者
  1458 + function Role:checkReturner()
  1459 + local returner = self:getProperty("returner") or {}
  1460 + if next(returner) then return end
  1461 +
  1462 + local now = specTime({hour = 4})
  1463 + returner.time = now
  1464 +
  1465 + self:updateProperty({field = "returner", value = returner})
  1466 + end
  1467 +
1340 1468 function Role:getSeaportServerProgress()
1341 1469 local result = {}
1342 1470  
... ... @@ -1350,7 +1478,7 @@ function RolePlugin.bind(Role)
1350 1478 end
1351 1479 end)
1352 1480 result[idx] = {}
1353   - for i,v in ipairs(temp) do
  1481 + for i,v in pairs(temp) do
1354 1482 if v then
1355 1483 result[idx][i] = tonumber(v)
1356 1484 end
... ...
src/models/RoleTask.lua
... ... @@ -109,6 +109,7 @@ local TaskType = {
109 109 CostDiamond = 909, -- 消耗钻石
110 110 WeekTask = 910, -- 完成每周活跃任务
111 111 ActBattlePass = 911, -- 活动关卡通关 -- chapterId
  112 + Appoint = 912, -- 触发限时礼包,指定id
112 113  
113 114 --功能未实现 todo
114 115 AdvShop = 1002, -- 冒险商城
... ... @@ -191,7 +192,7 @@ local AchievListener = {
191 192 [TaskType.OverOderTask] = {{14}},
192 193 [TaskType.FoodSellGold] = {{15, f("count")}},
193 194 [TaskType.DinerPopular] = {{16, f("count")}},
194   - [TaskType.TowerPass] = {{17, f("count"), f("type")}},
  195 + [TaskType.TowerPass] = {{17, f("level")}},
195 196 [TaskType.OpenBox] = {{18, f("count")}},
196 197 [TaskType.DinerLevelUp] = {{19, f("level"), f("type")}},
197 198 [TaskType.DinerTalentUp] = {{20, 1, f("type")}},
... ... @@ -264,6 +265,7 @@ local StoreListener = {
264 265 [TaskType.AdvPassFirst] = {{TriggerEventType.AdvPass, f("id")}},
265 266 [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}},
266 267 [TaskType.DrawHeroLimitPack] = {{TriggerEventType.DrawHeroCnt, f("count")}},
  268 + [TaskType.Appoint] = {{TriggerEventType.Appoint, f("id")}},
267 269 }
268 270 }
269 271  
... ... @@ -319,6 +321,11 @@ local BattleCommandTaskListener = {
319 321 listen = CalendaTaskListener["listen"]
320 322 }
321 323  
  324 +local ReturnerTask = {
  325 + func = "checkReturnerTask",
  326 + listen = CalendaTaskListener["listen"]
  327 +}
  328 +
322 329 local TaskListeners = {
323 330 StoryListener,
324 331 CommonListener,
... ... @@ -328,6 +335,7 @@ local TaskListeners = {
328 335 StoreListener,
329 336 CalendaTaskListener,
330 337 BattleCommandTaskListener,
  338 + ReturnerTask,
331 339 }
332 340  
333 341 local RoleTask = {}
... ... @@ -493,6 +501,7 @@ function RoleTask.bind(Role)
493 501 [6] = true,
494 502 [7] = true,
495 503 [16] = true,
  504 + [17] = true,
496 505 [19] = true,
497 506 [22] = true,
498 507 [23] = true,
... ... @@ -824,6 +833,15 @@ function RoleTask.bind(Role)
824 833 self:checkActTask(notNotify, keyName, actData, mainType, subType, param1, param2)
825 834 end
826 835  
  836 + function Role:checkReturnerTask(notNotify, mainType, subType, param1, param2)
  837 + -- print("check returner task", mainType, subType, param1, param2)
  838 + local returner = self:getProperty("returner") or {}
  839 + if not returner.time then return end
  840 + local actData = csvdb["activity_ctrlCsv"][76]
  841 + local keyName = "returner"
  842 + self:checkActTask(notNotify, keyName, actData, mainType, subType, param1, param2)
  843 + end
  844 +
827 845 end
828 846  
829 847 return RoleTask
... ...
src/models/RoleTimeReset.lua
... ... @@ -28,6 +28,12 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response, now)
28 28 self.storeData:resetStoreReored(3) --商店跨月重置 time_reset表关联id
29 29 end
30 30  
  31 + -- 检查回归者
  32 + if (now - ltime) >= 86400 * globalCsv.returner_time then
  33 + -- if true then
  34 + self:checkReturner()
  35 + end
  36 +
31 37 response.dTask = {}
32 38 response.advSup = self:getProperty("advSup")
33 39 self:log("onLogin")
... ...
src/models/Spark.lua 0 → 100644
... ... @@ -0,0 +1,78 @@
  1 +local Spark = class("Spark", require("shared.ModelBase"))
  2 +Spark.schema = {
  3 + id = {"number"}, -- 唯一自增id
  4 + cfg_id = {"number"},
  5 + level = {"number", 0}, -- 等级
  6 + attrs = {"table", {}} -- 基础属性值 id=value
  7 +}
  8 +
  9 +function Spark:ctor( properties )
  10 + Spark.super.ctor(self, properties)
  11 +end
  12 +
  13 +function Spark:notifyUpdateProperty(field, newValue, oldValue)
  14 + local datas = {
  15 + id = self:getProperty("id"),
  16 + datas = {
  17 + {
  18 + key = field,
  19 + newValue = newValue,
  20 + oldValue = oldValue,
  21 + }
  22 + }
  23 + }
  24 + self:notifyUpdateProperties(datas)
  25 +end
  26 +
  27 +function Spark:mylog(contents)
  28 + contents = contents or {}
  29 + if contents["cint1"] or contents["cint2"] then
  30 + print("sparkLog error log have cint1 or cint2 ", debug.traceback())
  31 + end
  32 + contents["cint1"] = self:getProperty("id")
  33 + contents["cint2"] = self:getProperty("cfg_id")
  34 +
  35 + self.owner:mylog("spark_action", contents)
  36 +end
  37 +
  38 +function Spark:notifyUpdateProperties(params)
  39 + local updateData = {
  40 + id = self:getProperty("id"),
  41 + datas = params
  42 + }
  43 + SendPacket(actionCodes.Role_updateSpark, MsgPack.pack(updateData))
  44 +end
  45 +
  46 +function Spark:updateProperty(params)
  47 + if not params.field or (not params.delta and not params.value) then
  48 + return
  49 + end
  50 + if params.delta then
  51 + self:incrProperty(params.field, params.delta)
  52 + elseif params.value then
  53 + self:setProperty(params.field, params.value)
  54 + end
  55 + local datas = {}
  56 + table.insert(datas, {key = params.field, newValue = self:getProperty(params.field)})
  57 +
  58 + self:notifyUpdateProperties(datas)
  59 +end
  60 +
  61 +function Spark:addAttr(attrs)
  62 + local curAttrs = clone(self:getProperty("attrs"))
  63 + for k, v in pairs(attrs) do
  64 + curAttrs[k] = (curAttrs[k] or 0) + v
  65 + end
  66 + self:updateProperty({field = "attrs", value = curAttrs})
  67 +end
  68 +
  69 +function Spark:data()
  70 + return {
  71 + id = self:getProperty("id"),
  72 + cfg_id = self:getProperty("cfg_id"),
  73 + level = self:getProperty("level"),
  74 + attrs = self:getProperty("attrs"),
  75 + }
  76 +end
  77 +
  78 +return Spark
0 79 \ No newline at end of file
... ...