Commit 8ef1416bff08d185b37cb85cd9dc3ba53034990f
Merge branch 'cn/develop' of 120.26.43.151:wasteland/server into cn/develop
Showing
11 changed files
with
161 additions
and
60 deletions
Show diff stats
src/ProtocolCode.lua
src/actions/DinerAction.lua
... | ... | @@ -747,7 +747,7 @@ function _M.addWantFoodRpc(agent , data) |
747 | 747 | gfood[slot] = {id = itemId, st = skynet.timex()} |
748 | 748 | end |
749 | 749 | |
750 | - role:finishGuide(36) | |
750 | + role:finishGuide(30) | |
751 | 751 | role:mylog("diner_action", {desc = "wantFood"}) |
752 | 752 | |
753 | 753 | role.dinerData:updateProperty({field = "gfood", value = gfood}) | ... | ... |
src/actions/GmAction.lua
... | ... | @@ -992,16 +992,19 @@ table.insert(helpDes, {"宝藏图鉴", "treasure", "list"} ) |
992 | 992 | function _M.treasure(role, pms) |
993 | 993 | local pm1 = pms.pm1 |
994 | 994 | if pm1 == "LIST" then |
995 | - local treasureList= role.dailyData:getTreasrueList(role) | |
996 | - for id, val in pairs(treasureList) do | |
997 | - print(string.format("%s:%d:%d:%d:%d", val.name, val.weight, val.treasure_value, val.expire_time or 0, val.cool_time or 0)) | |
998 | - end | |
995 | + local treasureList= role.dailyData:getProperty("treasureList") | |
996 | + dump(treasureList) | |
999 | 997 | return "宝藏图鉴" |
998 | + elseif pm1 == "FLUSH" then | |
999 | + local treasureList= role.dailyData:getTreasrueList(role) | |
1000 | + dump(treasureList) | |
1001 | + return "宝藏图鉴" | |
1000 | 1002 | elseif pm1 == "CHECK" then |
1001 | 1003 | local treasureList = role.dailyData:checkTreasureList(role) |
1002 | - for id, val in pairs(treasureList) do | |
1003 | - print(string.format("%s:%d:%d:%d:%d", val.name, val.weight, val.treasure_value, val.expire_time or 0, val.cool_time or 0)) | |
1004 | + if treasureList == nil then | |
1005 | + return "未挖到宝藏" | |
1004 | 1006 | end |
1007 | + dump(treasureList) | |
1005 | 1008 | return "挖宝成功" |
1006 | 1009 | elseif pm1 == "RESET" then |
1007 | 1010 | role.dailyData:resetTreasureList() |
... | ... | @@ -1011,4 +1014,17 @@ function _M.treasure(role, pms) |
1011 | 1014 | end |
1012 | 1015 | end |
1013 | 1016 | |
1017 | +table.insert(helpDes, {"天赋点设置", "savegenius", "heroId", "wakeL", "awake"}) | |
1018 | +function _M.savegenius(role, pms) | |
1019 | + local heroId = pms.pm1 | |
1020 | + local wakeL = pms.pm2 | |
1021 | + local awake = pms.pm3 | |
1022 | + local hero = role.heros[tonumber(heroId)] | |
1023 | + | |
1024 | + if not hero then return "英雄不存在" end | |
1025 | + local genius = hero:saveGeniusTree(wakeL, awake) | |
1026 | + print(genius) | |
1027 | + return "天赋点设置成功" | |
1028 | +end | |
1029 | + | |
1014 | 1030 | return _M |
1015 | 1031 | \ No newline at end of file | ... | ... |
src/actions/HangAction.lua
... | ... | @@ -27,7 +27,7 @@ local function getHangTime(role) |
27 | 27 | return nowCoinTime - hangInfo.coinTime |
28 | 28 | end |
29 | 29 | |
30 | -local function checkReward(role, isTreasure) | |
30 | +local function checkReward(role, isTreasure, carbonId) | |
31 | 31 | local hangInfo = role:getProperty("hangInfo") |
32 | 32 | if not hangInfo.carbonId or not hangInfo.coinTime or not hangInfo.itemTime then |
33 | 33 | return false |
... | ... | @@ -56,7 +56,7 @@ local function checkReward(role, isTreasure) |
56 | 56 | coinCount = (coinCount + coinDoubleCount) * expCoef |
57 | 57 | items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * (expCarbonData.money or 0)) |
58 | 58 | items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * (expCarbonData.exp or 0)) |
59 | - items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + (coinCount * expCarbonData.playerExp or 0)) | |
59 | + items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * (expCarbonData.playerExp or 0)) | |
60 | 60 | |
61 | 61 | local pool = {} |
62 | 62 | for _, temp in pairs(carbonData.item:toArray()) do |
... | ... | @@ -171,7 +171,7 @@ function _M.startRpc( agent, data ) |
171 | 171 | end |
172 | 172 | end |
173 | 173 | |
174 | - if checkReward(role) then | |
174 | + if checkReward(role, true, carbonId) then | |
175 | 175 | role:updateProperty({field = "hangBag", value = role:getProperty("hangBag")}) |
176 | 176 | end |
177 | 177 | ... | ... |
src/actions/HeroAction.lua
... | ... | @@ -1277,4 +1277,25 @@ function _M.changeSparkRpc(agent, data) |
1277 | 1277 | return true |
1278 | 1278 | end |
1279 | 1279 | |
1280 | +function _M.saveGeniusTreeRpc(agent, data) | |
1281 | + local role = agent.role | |
1282 | + local msg = MsgPack.unpack(data) | |
1283 | + | |
1284 | + local awake = msg.awake | |
1285 | + local wakeL = msg.wakeL | |
1286 | + local heroId = msg.hero_id | |
1287 | + local hero = role.heros[tonumber(heroId)] | |
1288 | + | |
1289 | + if not hero then print("hero is nil") return 0 end | |
1290 | + local genius = hero:saveGeniusTree(wakeL, awake) | |
1291 | + if #genius == 0 then | |
1292 | + genius = "" | |
1293 | + end | |
1294 | + hero:updateProperty({field="genius", value=genius}) | |
1295 | + print("genius:") | |
1296 | + print(#genius) | |
1297 | + SendPacket(actionCodes.Hero_saveGeniusTreeRpc, MsgPack.pack({genius = genius})) | |
1298 | + return true | |
1299 | +end | |
1300 | + | |
1280 | 1301 | return _M | ... | ... |
src/actions/SeaportAction.lua
... | ... | @@ -59,6 +59,12 @@ function _M.donateRpc(agent, data) |
59 | 59 | redisproxy:hincrby(SEAPORT_TRADE_TASK_2,id,itemCount) |
60 | 60 | end |
61 | 61 | |
62 | + local seaport = role:getProperty("seaport") or {} | |
63 | + if not seaport.join then | |
64 | + seaport.join = 1 | |
65 | + role:updateProperty({field = "seaport", value = seaport}) | |
66 | + end | |
67 | + | |
62 | 68 | role:costItems({[itemId] = itemCount}, {log = {desc = "seaportDonate", int1 = phase, int2 = id}}) |
63 | 69 | local reward, change = role:award(rewards, {log = {desc = "seaportDonate", int1 = ddata.phase, int2 = ddata.id}}) |
64 | 70 | ... | ... |
src/models/Daily.lua
... | ... | @@ -155,18 +155,20 @@ end |
155 | 155 | --资源 |
156 | 156 | function Daily:checkTreasureBase(treasureList, treasureBase, removeId) |
157 | 157 | local tmptreasure = {} |
158 | + local num = 0 | |
158 | 159 | for k, val in pairs(treasureList) do |
159 | 160 | if removeId and val.id == removeId then |
160 | - table.remove(treasureList, k) | |
161 | + treasureList[k] = nil | |
161 | 162 | else |
162 | 163 | if treasureBase >= val.treasure_value then |
163 | 164 | treasureBase = treasureBase - val.treasure_value |
164 | 165 | tmptreasure[val.id] = val |
166 | + num = num + 1 | |
165 | 167 | end |
166 | 168 | end |
167 | 169 | |
168 | 170 | end |
169 | - return tmptreasure | |
171 | + return tmptreasure, num | |
170 | 172 | end |
171 | 173 | |
172 | 174 | --绑定通关关卡 |
... | ... | @@ -177,14 +179,9 @@ function Daily:checkChapters() |
177 | 179 | if next(treasureList) ~= nil then |
178 | 180 | for id, curInfo in pairs(treasureList) do |
179 | 181 | if curInfo["end_time"] then |
180 | - if skynet.timex() >= curInfo["end_time"] then | |
181 | - curInfo = nil | |
182 | + if skynet.timex() < curInfo["end_time"] then | |
183 | + tmp_chapters[curInfo.chapter_id] = curInfo | |
182 | 184 | end |
183 | - else | |
184 | - curInfo = nil | |
185 | - end | |
186 | - if curInfo ~= nil then | |
187 | - tmp_chapters[curInfo.chapter_id] = curInfo | |
188 | 185 | end |
189 | 186 | end |
190 | 187 | end |
... | ... | @@ -207,16 +204,26 @@ end |
207 | 204 | function Daily:checkTreasureWeight(treasureList, tmptreasure, treasureBase) |
208 | 205 | local removeId |
209 | 206 | local chapters = self:checkChapters() |
207 | + local treasure | |
210 | 208 | if next(chapters) == nil then return end |
211 | 209 | |
212 | 210 | while next(tmptreasure) do |
213 | - local tmp = self:checkTreasureBase(tmptreasure, treasureBase, removeId) | |
214 | - local id = math.randWeight(tmp, "weight") --宝藏id | |
215 | - if not id then | |
211 | + local tmp, num = self:checkTreasureBase(tmptreasure, treasureBase, removeId) | |
212 | + | |
213 | + if num == 0 then | |
216 | 214 | break |
215 | + elseif num == 1 then | |
216 | + for _, val in pairs(tmp) do | |
217 | + treasure = val | |
218 | + end | |
219 | + else | |
220 | + local id = math.randWeight(tmp, "weight") --宝藏id | |
221 | + if not id then | |
222 | + break | |
223 | + end | |
224 | + treasure = tmp[id] | |
217 | 225 | end |
218 | - | |
219 | - local treasure = tmp[id] | |
226 | + | |
220 | 227 | if treasureBase >= treasure.treasure_value then |
221 | 228 | --扣除资源值 |
222 | 229 | treasureBase = treasureBase - treasure.treasure_value |
... | ... | @@ -229,8 +236,8 @@ function Daily:checkTreasureWeight(treasureList, tmptreasure, treasureBase) |
229 | 236 | end |
230 | 237 | |
231 | 238 | treasure.chapter_id = chapterId |
232 | - treasureList[id] = treasure | |
233 | - removeId = id | |
239 | + treasureList[treasure.id] = treasure | |
240 | + removeId = treasure.id | |
234 | 241 | end |
235 | 242 | end |
236 | 243 | |
... | ... | @@ -249,49 +256,45 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId) |
249 | 256 | if not curInfo["end_time"] then |
250 | 257 | curInfo["end_time"] = skynet.timex() + curInfo.working_time |
251 | 258 | else |
252 | - --宝藏冷却时间 | |
253 | - if not curInfo["expire_time"] then | |
254 | - --已挖到 | |
255 | - if skynet.timex() >= curInfo["end_time"] then | |
256 | - treasure = treasureList[curInfo.id] | |
257 | - if curInfo.cool_time > 1 then | |
259 | + if skynet.timex() >= curInfo["end_time"] then | |
260 | + if curInfo.cool_time > 1 then | |
261 | + --宝藏冷却时间 | |
262 | + if not curInfo["expire_time"] then | |
263 | + treasure = treasureList[curInfo.id] | |
258 | 264 | curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay |
259 | 265 | else |
260 | - curInfo["expire_time"] = skynet.timex() | |
266 | + --已经领取宝藏 检索宝藏冷却时间 | |
267 | + if skynet.timex() >= curInfo["expire_time"] then | |
268 | + treasureList[curInfo.id] = nil | |
269 | + end | |
261 | 270 | end |
262 | - if skynet.timex() >= curInfo["expire_time"] then | |
263 | - table.remove(treasureList, curInfo.id) | |
264 | - end | |
265 | - end | |
266 | - else | |
267 | - --已经领取宝藏 检索宝藏冷却时间 | |
268 | - if skynet.timex() >= curInfo["expire_time"] then | |
269 | - table.remove(treasureList, curInfo.id) | |
271 | + else | |
272 | + treasure = treasureList[curInfo.id] | |
273 | + treasureList[curInfo.id] = nil | |
270 | 274 | end |
271 | 275 | end |
272 | 276 | end |
273 | 277 | else |
274 | 278 | --已经开始挖宝 |
275 | 279 | if curInfo["end_time"] then |
276 | - if not curInfo["expire_time"] then --宝藏冷却时间 | |
277 | - if skynet.timex() >= curInfo["end_time"] then --已挖到 | |
278 | - treasure = treasureList[curInfo.id] | |
279 | - if curInfo.cool_time > 1 then | |
280 | + if skynet.timex() >= curInfo["end_time"] then | |
281 | + if curInfo.cool_time > 1 then | |
282 | + --宝藏冷却时间 | |
283 | + if not curInfo["expire_time"] then | |
284 | + treasure = treasureList[curInfo.id] | |
280 | 285 | curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay |
281 | 286 | else |
282 | - curInfo["expire_time"] = skynet.timex() | |
283 | - end | |
284 | - if skynet.timex() >= curInfo["expire_time"] then | |
285 | - table.remove(treasureList, curInfo.id) | |
287 | + --已经领取宝藏 检索宝藏冷却时间 | |
288 | + if skynet.timex() >= curInfo["expire_time"] then | |
289 | + treasureList[curInfo.id] = nil | |
290 | + end | |
286 | 291 | end |
287 | 292 | else |
288 | - --未挖到直接删除 | |
289 | - table.remove(treasureList, curInfo.id) | |
290 | - end | |
291 | - else --已经领取宝藏 检索宝藏冷却时间 | |
292 | - if skynet.timex() >= curInfo["expire_time"] then | |
293 | - table.remove(treasureList, curInfo.id) | |
293 | + treasure = treasureList[curInfo.id] | |
294 | + treasureList[curInfo.id] = nil | |
294 | 295 | end |
296 | + else | |
297 | + curInfo["end_time"] = nil | |
295 | 298 | end |
296 | 299 | end |
297 | 300 | end |
... | ... | @@ -310,7 +313,7 @@ function Daily:buyTreasure(treasureList) |
310 | 313 | boughtTreasurer[id] = val |
311 | 314 | end |
312 | 315 | end |
313 | - self:updateProperty({field = "treasureBase", value = treasureBase}) | |
316 | + --self:updateProperty({field = "treasureBase", value = treasureBase}) | |
314 | 317 | return boughtTreasurer |
315 | 318 | end |
316 | 319 | |
... | ... | @@ -322,7 +325,7 @@ end |
322 | 325 | --宝藏图鉴 |
323 | 326 | function Daily:getTreasrueList() |
324 | 327 | local tmpcsv = csvdb["idle_treasureCsv"] |
325 | - local treasureList = self:getProperty("treasureList") --挖宝列表 过期删除 领取奖励删除 跨天更新 | |
328 | + local treasureList = self:getProperty("treasureList") or {} --挖宝列表 过期删除 领取奖励删除 跨天更新 | |
326 | 329 | local tmptreasure = {} |
327 | 330 | local treasureBase = globalCsv.idle_treasure_base |
328 | 331 | for id, val in pairs(tmpcsv) do |
... | ... | @@ -343,7 +346,7 @@ end |
343 | 346 | |
344 | 347 | --检索挖宝列表 |
345 | 348 | function Daily:checkTreasureList(chapterId) |
346 | - local treasureList = self:getProperty("treasureList") | |
349 | + local treasureList = self:getProperty("treasureList") or {} | |
347 | 350 | local tmptreasure = {} |
348 | 351 | for id, val in pairs(treasureList) do |
349 | 352 | local treasure = self:checkTreasureChapterId(val, treasureList, chapterId) |
... | ... | @@ -353,6 +356,7 @@ function Daily:checkTreasureList(chapterId) |
353 | 356 | end |
354 | 357 | |
355 | 358 | if next(tmptreasure) == nil then |
359 | + self:updateProperty({field = "treasureList", value = treasureList}) | |
356 | 360 | return nil |
357 | 361 | end |
358 | 362 | local boughtTreasurer = self:buyTreasure(tmptreasure) | ... | ... |
src/models/Hero.lua
... | ... | @@ -18,6 +18,7 @@ Hero.schema = { |
18 | 18 | rune = {"string",""}, --零件 type=id |
19 | 19 | faith = {"number", 0}, -- 信赖 |
20 | 20 | spark = {"table", {}}, -- 火花属性 |
21 | + genius = {"string", "" }, --天赋点 4=10201 5=10201 6=10203 7=10204 | |
21 | 22 | } |
22 | 23 | |
23 | 24 | function Hero:ctor( properties ) |
... | ... | @@ -111,6 +112,7 @@ function Hero:data() |
111 | 112 | rune = self:getProperty("rune"), |
112 | 113 | faith = self:getProperty("faith"), |
113 | 114 | spark = self:getProperty("spark"), |
115 | + genius = self:getProperty("genius"), | |
114 | 116 | } |
115 | 117 | end |
116 | 118 | ... | ... |
src/models/HeroPlugin.lua
... | ... | @@ -384,6 +384,57 @@ function HeroPlugin.bind(Hero) |
384 | 384 | self:mylog({desc = "addFaith", int1 = exp}) |
385 | 385 | end |
386 | 386 | |
387 | + --检验天赋树是否合理 | |
388 | + function Hero:checkGeniusTree(genius) | |
389 | + local maxWakeL = 0 | |
390 | + local star = self:getProperty("wakeL") | |
391 | + if star < 4 then return maxWakeL end | |
392 | + if #genius == 0 then return maxWakeL end | |
393 | + | |
394 | + local geniusTree = genius:toNumMap() | |
395 | + local tmpgenius = "" | |
396 | + for wakeL, val in pairs(geniusTree) do | |
397 | + print("wakeL:") | |
398 | + print(wakeL) | |
399 | + if wakeL < 4 then return maxWakeL end | |
400 | + if wakeL % 2 == 0 then | |
401 | + if geniusTree[wakeL+1] and geniusTree[wakeL+1] ~= val then | |
402 | + return 0 | |
403 | + end | |
404 | + end | |
405 | + maxWakeL = math.max(maxWakeL, wakeL) | |
406 | + if #tmpgenius == 0 then | |
407 | + tmpgenius = string.format("%s=%s", tostring(wakeL), tostring(val)) | |
408 | + else | |
409 | + tmpgenius = string.format("%s %s=%s", tmpgenius, tostring(wakeL), tostring(val)) | |
410 | + end | |
411 | + end | |
412 | + return tonumber(maxWakeL),tmpgenius | |
413 | + end | |
414 | + | |
415 | + function Hero:saveGeniusTree(wakeL, awake) | |
416 | + local genius = self:getProperty("genius") | |
417 | + local tid = self:getProperty("type") | |
418 | + if not wakeL and not awake then return "" end | |
419 | + | |
420 | + | |
421 | + local heroUnit = csvdb["unitCsv"][tid] | |
422 | + if not heroUnit then return genius end | |
423 | + if not heroUnit.awake_1 or not heroUnit.awake_2 then return genius end | |
424 | + | |
425 | + if #genius == 0 then | |
426 | + genius = string.format("%s=%s", tostring(wakeL), tostring(awake)) | |
427 | + else | |
428 | + genius = string.format("%s %s=%s", genius, tostring(wakeL), tostring(awake)) | |
429 | + end | |
430 | + | |
431 | + local maxWakeL, genius = self:checkGeniusTree(genius) | |
432 | + if maxWakeL ~= wakeL then | |
433 | + genius = self:getProperty("genius") | |
434 | + end | |
435 | + return genius | |
436 | + end | |
437 | + | |
387 | 438 | end |
388 | 439 | |
389 | 440 | ... | ... |
src/models/Role.lua
... | ... | @@ -198,7 +198,7 @@ Role.schema = { |
198 | 198 | nbTask = {"table", {}}, -- 新用户活动 |
199 | 199 | radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv |
200 | 200 | |
201 | - seaport = {"table", {}}, -- 海岛贸易季 {time = 1234567890, donate = {}, collect = {[1] = {team = "1=2=3", time = 1234567890}}, shop = {}} | |
201 | + seaport = {"table", {}}, -- 海岛贸易季 {time = 1234567890, donate = {}, collect = {[1] = {team = "1=2=3", time = 1234567890}}, shop = {}, join = 1} | |
202 | 202 | |
203 | 203 | returner = {"table", {}}, -- 回归者 {time = 12334233423, [1] = 1, [2] = 2, status = {[1] = 1}} |
204 | 204 | ... | ... |
src/models/RolePlugin.lua
... | ... | @@ -1371,7 +1371,7 @@ function RolePlugin.bind(Role) |
1371 | 1371 | local function getReward(reset) |
1372 | 1372 | -- 全服捐赠奖励 |
1373 | 1373 | local donate = seaport.donate or {} |
1374 | - if not reset and (not donate[1] or not donate[2]) then | |
1374 | + if not reset and seaport.join and (not donate[1] or not donate[2]) then | |
1375 | 1375 | local result = self:getSeaportServerProgress() |
1376 | 1376 | for idx, set in ipairs(csvdb["seaport_purchaseCsv"]) do |
1377 | 1377 | local done = true | ... | ... |