Commit e59430d511988d1c9f5bd01a61e1d9567c6cd150

Authored by zhouhaihai
1 parent 111937b9

宝藏怪刷新,计数

Showing 2 changed files with 56 additions and 39 deletions   Show diff stats
src/adv/Adv.lua
... ... @@ -1538,6 +1538,24 @@ local function clickBuild(self, room, block, params)
1538 1538 local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "build")
1539 1539 if not status then return end
1540 1540  
  1541 + local isMine = false -- 是不是宝藏怪
  1542 + for _, mid in ipairs(globalCsv.adv_egg_treasureLayer_id) do
  1543 + if mid == oldId then
  1544 + isMine = true
  1545 + break
  1546 + end
  1547 + end
  1548 + if isMine then
  1549 + local advMine = self.owner:getProperty("advMine")
  1550 + advMine[2] = advMine[2] or {}
  1551 + local mineCo2 = advMine[2].co or {}
  1552 + if chooseData.limit ~= 0 then
  1553 + mineCo2[oldId] = (mineCo2[oldId] or 0) + 1
  1554 + end
  1555 + advMine[2].co = mineCo2
  1556 + self.owner:setProperty("advMine", advMine)
  1557 + end
  1558 +
1541 1559 self:checkTask(Adv.TaskType.Build, 1, oldId)
1542 1560 self:checkAchievement(Adv.AchievType.Build, 1, oldId)
1543 1561 self:checkAchievement(Adv.AchievType.BuildBySelect, 1, oldId, choose)
... ... @@ -1972,6 +1990,7 @@ function Adv:enemyDead(enemy, escape)
1972 1990 break
1973 1991 end
1974 1992 end
  1993 +
1975 1994 if isMine then
1976 1995 local advMine = self.owner:getProperty("advMine")
1977 1996 advMine[1] = advMine[1] or {}
... ... @@ -1998,9 +2017,6 @@ function Adv:enemyDead(enemy, escape)
1998 2017 etype = AdvEventType.Build,
1999 2018 id = cId
2000 2019 })
2001   - if csvdb["event_buildingCsv"][cId].limit ~= 0 then
2002   - mineCo2[cId] = (mineCo2[cId] or 0) + 1
2003   - end
2004 2020 had = true
2005 2021 end
2006 2022 end
... ...
src/adv/AdvMap.lua
... ... @@ -13,12 +13,12 @@ local createMap, getEventLib
13 13 function Map:ctor(adv, mapIdx, mapInfo, isEnter, isNewRelay)
14 14 self.adv = adv
15 15 local isNew = type(mapInfo) == "number"
  16 + self.mapIdx = mapIdx
16 17 if isNew then -- mapInfo 传入 id
17 18 mapInfo = createMap(self, mapInfo, isEnter, isNewRelay) -- 生成地图
18 19 end
19 20 if not mapInfo then return end
20 21  
21   - self.mapIdx = mapIdx
22 22 self.mapId = mapInfo.mapId
23 23 self.isShow = mapInfo.isShow -- 是否全部展示 -- 客户端用
24 24 self.rooms = {}
... ... @@ -811,46 +811,47 @@ createMap = function(self, mapId, isEnter, isNewRelay)
811 811 end
812 812 end
813 813 end
814   -
815 814 -- 宝藏怪刷新
816   - for idx = #(stagePool["global"][AdvCodeRandomStage] or {}), 1, -1 do
817   - local c = stagePool["global"][AdvCodeRandomStage][idx] -- {room = roomId, block = blockId}
818   - if mapInfo.rooms[c["room"]]["event"][c["block"]] then -- 存在
819   - table.remove(stagePool["global"][AdvCodeRandomStage], idx)
820   - end
821   - end
822   - local ln = #(stagePool["global"][AdvCodeRandomStage] or {})
823   - local advMine = self.adv.owner:getProperty("advMine")
824   - advMine[1] = advMine[1] or {}
825   - local mineCh = advMine[1].ch or globalCsv.adv_egg_treasureMonster_showup
826   - local mineCo = advMine[1].co or {}
827   - local had = false
828   - if ln > 0 then
829   - if math.randomInt(1, 100) <= mineCh then -- 刷出来了
830   - local mpool = {}
831   - for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do
832   - local monster = csvdb["event_monsterCsv"][mid]
833   - if (not mineCo[mid] or monster.limit == 0 or mineCo[mid] < monster.limit) and monster.showup > 0 then
834   - mpool[mid] = {monster.showup}
835   - end
836   - end
837   - if next(mpool) then
838   - local idx = math.randomInt(1, ln)
839   - local cur = stagePool["global"][AdvCodeRandomStage][idx]
840   - giveEvent(cur["room"], cur["block"], AdvEventType.Monster, math.randWeight(mpool, 1))
  815 + if self.mapIdx == 1 and not self.adv.isRelay then
  816 + for idx = #(stagePool["global"][AdvCodeRandomStage] or {}), 1, -1 do
  817 + local c = stagePool["global"][AdvCodeRandomStage][idx] -- {room = roomId, block = blockId}
  818 + if mapInfo.rooms[c["room"]]["event"][c["block"]] then -- 存在
841 819 table.remove(stagePool["global"][AdvCodeRandomStage], idx)
842   - ln = ln - 1
843   - had = true
844 820 end
845 821 end
  822 + local ln = #(stagePool["global"][AdvCodeRandomStage] or {})
  823 + local advMine = self.adv.owner:getProperty("advMine")
  824 + advMine[1] = advMine[1] or {}
  825 + local mineCh = advMine[1].ch or globalCsv.adv_egg_treasureMonster_showup
  826 + local mineCo = advMine[1].co or {}
  827 + local had = false
  828 + if ln > 0 then
  829 + if math.randomInt(1, 100) <= mineCh then -- 刷出来了
  830 + local mpool = {}
  831 + for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do
  832 + local monster = csvdb["event_monsterCsv"][mid]
  833 + if (not mineCo[mid] or monster.limit == 0 or mineCo[mid] < monster.limit) and monster.showup > 0 then
  834 + mpool[mid] = {monster.showup}
  835 + end
  836 + end
  837 + if next(mpool) then
  838 + local idx = math.randomInt(1, ln)
  839 + local cur = stagePool["global"][AdvCodeRandomStage][idx]
  840 + giveEvent(cur["room"], cur["block"], AdvEventType.Monster, math.randWeight(mpool, 1))
  841 + table.remove(stagePool["global"][AdvCodeRandomStage], idx)
  842 + ln = ln - 1
  843 + had = true
  844 + end
  845 + end
  846 + end
  847 + if not had then
  848 + mineCh = math.min(mineCh + globalCsv.adv_egg_treasureMonster_showup_add, 100)
  849 + else
  850 + mineCh = nil
  851 + end
  852 + advMine[1].ch = mineCh
  853 + self.adv.owner:setProperty("advMine", advMine)
846 854 end
847   - if not had then
848   - mineCh = math.min(mineCh + globalCsv.adv_egg_treasureMonster_showup_add, 100)
849   - else
850   - mineCh = nil
851   - end
852   - advMine[1].ch = mineCh
853   - self.adv.owner:setProperty("advMine", advMine)
854 855  
855 856  
856 857 if mapCsvData.clearType == 1 and not haveBoss then
... ...