| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177 |
- --[[
- ʧ������
- ]]
- local Msg = require("core.Msg")
- local LuaMongo = _G.lua_mongo
- local DB = require("common.DB")
- local LostTempleExcel = require("excel.lostTemple")
- local ElementExcel = require("excel.lostTemple").Element
- local CombatPosLogic = require("combat.CombatPosLogic")
- local CombatDefine = require("combat.CombatDefine")
- local MonsterOutExcel = require("excel.monster").monsterOut
- local HeroLogic = require("hero.HeroLogic")
- local MonsterExcel = require("excel.monster")
- local CombatLogic = require("combat.CombatLogic")
- local Grid = require("bag.Grid")
- local HeroGrid = require("hero.HeroGrid")
- local CombatPosExcel = require("excel.combatPos")
- local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
- local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
- local Util = require("common.Util")
- local LostTempleCombatLogic = require("lostTemple.lostTempleCombatLogic")
- local HeroDefine = require("hero.HeroDefine")
- local BagLogic = require("bag.BagLogic")
- local Broadcast = require("broadcast.Broadcast")
- local Lang = require("common.Lang")
- local CommonDB = require("common.CommonDB")
- local Lost_Handle_Func = { }
- QUEUE_LEN = 3 -- ÿ�����͵ĺ��������
- START_X = 1 -- ��ʼ����λ��
- START_LAYER = 1 -- ��ʼ����
- OP_QUERY = 0
- OP_CONFIRM = 1
- INIT_HP_MAX = 100
- DAY_7s = 604800
- DAY_2s = 172800
- DAY_1s = 86400
- function initAfterHot()
- end
- function getLeftTime()
- local openDay = CommonDB.getServerOpenDay()
- if not openDay then
- return 0
- end
- local openTime = CommonDB.getServerOpenTime()
- local curTime = os.time()
- if openDay <= 7 and openDay > 0 then
- local endTime = openTime + DAY_7s
- return (endTime - curTime)
- elseif openDay > 7 then
- if (openDay - 7 + 1)%2 ~= 1 then
- local endTime = openTime + DAY_7s + (openDay-7)*DAY_1s
- return (endTime - curTime)
- end
- if(openDay - 7 + 1)%2 == 1 then
- return 0
- end
- end
- return 0
- end
- --
- local function isOpen(human)
- local openDay = CommonDB.getServerOpenDay()
- if not openDay then
- return
- end
-
- if openDay < 7 then
- return
- end
-
- ---- �Ѿ�����
- if (openDay - 7 + 1) % 2 ~= 1 then
- return
- end
-
- if not RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_1208) then
- return
- end
- return true
- end
- function onZero()
- local openDay = CommonDB.getServerOpenDay()
- if not openDay then
- return
- end
- if openDay < 7 then
- return
- end
- -- �Ѿ��ر�
- if (openDay - 7 + 1) % 2 ~= 0 then
- return
- end
- LuaMongo.remove(DB.db_lost_temple)
- end
- function updateDaily(human)
- if not isOpen(human) then
- return
- end
-
- human.lostTemple = nil
-
- local msgRet = Msg.gc.GC_LOST_TEMPLE_CLOSE
- Msg.send(msgRet, human.fd)
- end
- -- db
- local QueryByUuid = { _id = nil }
- -- �����µ�����
- function dbRead(human)
- if not isOpen(human) then return end
- human.lostTemple = { }
- QueryByUuid._id = human.db._id
- LuaMongo.find(DB.db_lost_temple, QueryByUuid)
- if not LuaMongo.next(human.lostTemple) then
- human.lostTemple = nil
- end
- end
- --
- local DB_DATA = { }
- function dbSave(human)
- if not human.lostTemple then return end
- if not human.db then return end
- DB_DATA = { }
- LuaMongo.find(DB.db_lost_temple, QueryByUuid)
- if not LuaMongo.next(DB_DATA) then
- human.lostTemple._id = human.db._id
- LuaMongo.insert(DB.db_lost_temple, human.lostTemple)
- return
- end
- QueryByUuid._id = human.db._id
- LuaMongo.update(DB.db_lost_temple, QueryByUuid, human.lostTemple)
- end
- -- db
- function onLogin(human)
- if not isOpen(human) then return end
- dbRead(human)
- end
- -- ��ʼ����ҵ�ǰ����
- local function printGrid(human)
- if not human.lostTemple then return end
- local startX = human.lostTemple.x + 1
- local endX = human.lostTemple.x + QUEUE_LEN
- local layer = human.lostTemple.layer
- local random = human.lostTemple.random
- local LostTempleConfig = LostTempleExcel[layer]
- if not LostTempleConfig then return end
- local LostTemple = LostTempleConfig[random]
- if not LostTemple then return end
- print("layler=", human.lostTemple.layer, "random=", human.lostTemple.random, "playerX=", human.lostTemple.x, "playerY=", human.lostTemple.y)
- for x = startX, endX do
- human.lostTemple.grid[x] = human.lostTemple.grid[x] or { }
- local LostTempleX = LostTemple[x]
- if LostTempleX then
- for y = 1, LostTemple.vertical do
- if LostTempleX[y] then
- print("x=", x, "y=", y, "id=", human.lostTemple.grid[x][y].id)
- end
- end
- end
- end
- return true
- end
- --
- local function makeMonsterGrid(human, cmd)
- if not human.lostTemple then return end
- local x = human.lostTemple.x
- local layer = human.lostTemple.layer
- local LostTempleMonster = LostTempleExcel.Lost[x]
- if not LostTempleMonster then return end
- -- ȡ����Ӣ�۵ĵȼ�
- local totalLv = 0
- local equally = 0
- local equallyLv = 0
- local db = human.db.xingYaoGongMing
- if db and db.defList then
- for heroIndex in pairs(db.defList) do
- local heroGrid = human.db.heroBag[heroIndex]
- if heroGrid then
- totalLv = totalLv + heroGrid.lv
- equally = equally + 1
- end
- end
- end
- local randomId = 0
- if cmd == "nomalMonster" then
- randomId = math.random(LostTempleMonster.nomal[layer][1], LostTempleMonster.nomal[layer][2])
- elseif cmd == "eliteMonster" then
- randomId = math.random(LostTempleMonster.elite[layer][1], LostTempleMonster.elite[layer][2])
- elseif cmd == "eliteBoss" then
- randomId = math.random(LostTempleMonster.elite[layer][1], LostTempleMonster.elite[layer][2])
- end
- equallyLv = math.ceil(totalLv / equally * randomId / 10000)
- local monsterOutID = 0
- for i = 1, #LostTempleExcel.Monster do
- if equallyLv >= LostTempleExcel.Monster[i].lvminmax[1] and equallyLv <= LostTempleExcel.Monster[i].lvminmax[2] then
- local randomIndex = math.random(1, #LostTempleExcel.Monster[i].monsteroutid)
- monsterOutID = LostTempleExcel.Monster[i].monsteroutid[randomIndex]
- break
- end
- end
- if monsterOutID == 0 then
- assert(nil, "monsterOutID is error equallyLv=" .. equallyLv .. "-randomId=" .. randomId)
- end
- return monsterOutID
- end
- -- ����һ���ٻ���̳
- local function makeSummonHeroGrid(human)
- -- ȡ����Ӣ�۵ĵȼ�
- local totalLv = 0
- local equally = 0
- local equallyLv = 0
- local db = human.db.xingYaoGongMing
- if db and db.defList then
- for heroIndex in pairs(db.defList) do
- local heroGrid = human.db.heroBag[heroIndex]
- if heroGrid then
- totalLv = totalLv + heroGrid.lv
- equally = equally + 1
- end
- end
- end
- equallyLv = math.ceil(totalLv / equally)
- local heroIndex = nil
- for i = 1, #LostTempleExcel.Hero do
- if equallyLv >= LostTempleExcel.Hero[i].lvminmax[1] and equallyLv <= LostTempleExcel.Hero[i].lvminmax[2] then
- heroIndex = i
- break
- end
- end
- if heroIndex == nil then
- assert(nil, "heroid is error equallyLv=" .. equallyLv)
- end
- --
- local summonHero = { }
- local weightHeroTb = Util.copyTable(LostTempleExcel.Hero[heroIndex].heroid)
- -- ����Ȩ��ȡ��4Ӣ��
- local totalWeight = 0
- for i = 1, #weightHeroTb do
- totalWeight = totalWeight + weightHeroTb[i][4]
- end
- -- ȡ4��
- local len = 0
- for k = 1, 4 do
- local random = math.random(1, totalWeight)
- for i = 1, #weightHeroTb do
- if random <= weightHeroTb[i][4] then
- len = len + 1
- summonHero[len] = { }
- summonHero[len].id = weightHeroTb[i][1]
- summonHero[len].lv = weightHeroTb[i][2]
- local maxStar = HeroDefine.getMaxHeroStar(weightHeroTb[i][1])
- summonHero[len].star = maxStar > weightHeroTb[i][3] and weightHeroTb[i][3] or maxStar
- -- ���һ�����뵽 ��һ������ ɾ�����һ��
- totalWeight = totalWeight - weightHeroTb[i][4]
- weightHeroTb[i] = weightHeroTb[#weightHeroTb]
- weightHeroTb[#weightHeroTb] = nil
- break
- end
- random = random - weightHeroTb[i][4]
- end
- end
- if #summonHero == 0 then
- assert(nil, "summonHero is error equallyLv=" .. equallyLv)
- end
- return summonHero
- end
- -- ����һ���ǻ���
- local function makeSummonTreeGrid(human)
- --
- local summonTree = { }
- local weightTreeTb = Util.copyTable(LostTempleExcel.Tree)
- -- ����Ȩ��ȡ��4Ӣ��
- local totalWeight = 0
- for i = 1, #weightTreeTb do
- totalWeight = totalWeight + weightTreeTb[i].weight
- end
- -- ȡ3��
- local len = 0
- for k = 1, 3 do
- local random = math.random(1, totalWeight)
- for i = 1, #weightTreeTb do
- if random <= weightTreeTb[i].weight then
- len = len + 1
- summonTree[len] = i
- -- ���һ�����뵽 ��һ������ ɾ�����һ��
- totalWeight = totalWeight - weightTreeTb[i].weight
- weightTreeTb[i] = weightTreeTb[#weightTreeTb]
- weightTreeTb[#weightTreeTb] = nil
- break
- end
- random = random - weightTreeTb[i].weight
- end
- end
- if #summonTree == 0 then
- assert(nil, "summonTree is error")
- end
- return summonTree
- end
- -- ����̵�
- local function makeSummonShopGrid(human)
- --
- local summonShop = { }
- local weightShopTb = Util.copyTable(LostTempleExcel.LostShop)
- -- ����Ȩ��ȡ��4Ӣ��
- local totalWeight = 0
- for i = 1, #weightShopTb do
- totalWeight = totalWeight + weightShopTb[i].weight
- end
- -- ȡ3��
- local len = 0
- for k = 1, 4 do
- local random = math.random(1, totalWeight)
- for i = 1, #weightShopTb do
- if random <= weightShopTb[i].weight then
- len = len + 1
- summonShop[len] = i
- -- ���һ�����뵽 ��һ������ ɾ�����һ��
- totalWeight = totalWeight - weightShopTb[i].weight
- weightShopTb[i] = weightShopTb[#weightShopTb]
- weightShopTb[#weightShopTb] = nil
- break
- end
- random = random - weightShopTb[i].weight
- end
- end
- if #summonShop == 0 then
- assert(nil, "summonShop is error")
- end
- return summonShop
- end
- -- ����һ������
- local function makeBoxGrid(human)
- for i = 1, #ElementExcel do
- local element = ElementExcel[i]
- if element.cmd == "summonBox" then
- return i
- end
- end
- end
- -- ����һ��������
- local function makeConverDoorGrid(human)
- for i = 1, #ElementExcel do
- local element = ElementExcel[i]
- if element.cmd == "conveyDoor" then
- return i
- end
- end
- end
- -- ��ʼ����ҵ�ǰ����
- local function makeGrid(human)
- if not human.lostTemple then return end
- local layer = human.lostTemple.layer
- local random = human.lostTemple.random
- local LostTempleConfig = LostTempleExcel[layer]
- if not LostTempleConfig then return end
- local LostTemple = LostTempleConfig[random]
- if not LostTemple then return end
- -- �����ҵ�ǰλ�õ�����
- human.lostTemple.grid = human.lostTemple.grid or { }
- human.lostTemple.grid[human.lostTemple.x] = nil
- local startX = human.lostTemple.x + 1
- local endX = human.lostTemple.x + QUEUE_LEN
- for x = startX, endX do
- local LostTempleX = LostTemple[x]
- if LostTempleX then
- human.lostTemple.grid[x] = human.lostTemple.grid[x] or { }
- for y = 1, LostTemple.vertical do
- if LostTempleX[y] then
- if not human.lostTemple.grid[x][y] then
- human.lostTemple.grid[x][y] = { id = LostTempleX[y][1] }
- end
- local element = ElementExcel[LostTempleX[y][1]]
- -- �ٻ���̳
- if element.cmd == "summonHero" then
- human.lostTemple.grid[x][y].summonHero = makeSummonHeroGrid(human)
- end
- -- �ǻ���
- if element.cmd == "summonTree" then
- human.lostTemple.grid[x][y].summonTree = makeSummonTreeGrid(human)
- end
- -- ����̵�
- if element.cmd == "summonShop" then
- human.lostTemple.grid[x][y].summonShop = makeSummonShopGrid(human)
- end
- -- ֻ���� ��һ��Ĺ���
- if x == startX then
- if element.cmd == "nomalMonster" or element.cmd == "eliteMonster" or element.cmd == "eliteBoss" then
- human.lostTemple.grid[x][y].monsterOutID = makeMonsterGrid(human, element.cmd)
- end
- end
- end
- end
- end
- end
- return true
- end
- -- ����һ��Ĭ�ϵ�λ������
- local function makeLostTempLe(layer)
- -- ��һ��
- local LostTempleConfig = LostTempleExcel[layer]
- if not LostTempleConfig then
- assert(nil, "lostTemple startLayer error = " .. layer)
- end
- -- ���һ�ŵ�ͼ
- local startRandom = math.random(1, #LostTempleConfig)
- local LostTemple = LostTempleConfig[startRandom]
- if not LostTemple then return end
- -- ��ʼλ��
- local LostTempleX = LostTemple[START_X]
- if not LostTempleX then
- assert(nil, "lostTemple startX error = " .. START_LAYER)
- end
- -- �ҵ��������վ����λ��
- local startY = 1
- for y = 1, LostTemple.vertical do
- if LostTempleX[y] and LostTempleX[y][1] == 0 then
- startY = y
- break
- end
- end
- return layer, START_X, startY, startRandom
- end
- -- ��ʼ��
- local function initDB(human)
- if human.lostTemple then return end
- local lostLayer, lostX, lostY, lostRandom = makeLostTempLe(START_LAYER)
- if not lostLayer then return end
- human.lostTemple = { layer = lostLayer, x = lostX, y = lostY, random = lostRandom, box = nil, grid = nil }
- makeGrid(human)
- dbSave(human)
- end
- -- human = { }
- -- initDB(human)
- -- printGrid(human)
- -- print("-----------------------------")
- -- ��һ��
- function nextGrid(human, y)
- if not human.lostTemple then return end
- local layer = human.lostTemple.layer
- local LostTempleConfig = LostTempleExcel[layer]
- if not LostTempleConfig then
- assert(nil, "lostTemple startLayer error = " .. layer)
- end
- local random = human.lostTemple.random
- local LostTemple = LostTempleConfig[random]
- if not LostTemple then return end
- local x = human.lostTemple.x + 1
- local LostTempleX = LostTemple[x]
- if not LostTempleX then return end
- local LostTempleY = LostTempleX[y]
- if not LostTempleY then return end
- human.lostTemple.x = x
- human.lostTemple.y = y
- makeGrid(human)
- end
- -- ��һ��
- local function nextDB(human)
- if not human.lostTemple then return end
- local nextLayer = human.lostTemple.layer + 1
- local LostTempleConfig = LostTempleExcel[nextLayer]
- if not LostTempleConfig then return end
- local lostLayer, lostX, lostY, lostRandom = makeLostTempLe(nextLayer)
- if not lostLayer then return end
- human.lostTemple.layer = lostLayer
- human.lostTemple.x = lostX
- human.lostTemple.y = lostY
- human.lostTemple.random = lostRandom
- human.lostTemple.grid = nil
- makeGrid(human)
- end
- --
- local function makeGridNet(human, net)
- if not human.lostTemple then return end
- local startX = human.lostTemple.x + 1
- local endX = human.lostTemple.x + QUEUE_LEN
- local layer = human.lostTemple.layer
- local random = human.lostTemple.random
- local LostTempleConfig = LostTempleExcel[layer]
- if not LostTempleConfig then return end
- local LostTemple = LostTempleConfig[random]
- if not LostTemple then return end
- net[0] = 0
- local len = 0
- for x = startX, endX do
- if human.lostTemple.grid[x] then
- for y = 1, LostTemple.vertical do
- if human.lostTemple.grid[x][y] then
- len = len + 1
- local grid = human.lostTemple.grid[x][y]
- local element = ElementExcel[grid.id]
- if not element then
- assert(nil, "lostTemple element error = " .. grid.id)
- end
- net[len].id = grid.id
- net[len].name = element.name
- net[len].type = element.type
- net[len].desc = element.desc
- net[len].x = x
- net[len].y = y
- net[len].body = 0
- if grid.monsterOutID then
- if not MonsterOutExcel[grid.monsterOutID] then
- assert(nil, "lostTemple monsterOutID error = " .. grid.monsterOutID)
- end
- local monsterConfig = MonsterExcel.monster[MonsterOutExcel[grid.monsterOutID].member[1][1]]
- if not monsterConfig then
- assert(nil, "lostTemple monsterOutID error = " .. MonsterOutExcel[grid.monsterOutID].member[1][1])
- end
- net[len].body = monsterConfig.body
- end
- end
- end
- end
- end
- net[0] = len
- return true
- end
- -- ��ѯ
- function query(human)
- local leftTime = getLeftTime()
- local msgRet = Msg.gc.GC_LOST_TEMPLE_QUERY
- msgRet.playerX = 0
- msgRet.playerY = 0
- msgRet.layer = 0
- msgRet.list[0]= 0
- msgRet.leftTime = leftTime
- if not isOpen(human) then
- Msg.send(msgRet, human.fd)
- return
- end
- -- û�й���
- local db = human.db.xingYaoGongMing
- if not db or not db.defList then
- Msg.send(msgRet, human.fd)
- return
- end
- initDB(human)
-
- if not makeGridNet(human, msgRet.list) then return end
- msgRet.playerX = human.lostTemple.x
- msgRet.playerY = human.lostTemple.y
- msgRet.layer = human.lostTemple.layer
- msgRet.leftTime = leftTime
- Msg.send(msgRet, human.fd)
- sendHeroStatus(human)
- end
- -- ����
- function update(human)
- local msgRet = Msg.gc.GC_LOST_TEMPLE_UPDATE
- local leftTime = getLeftTime()
- msgRet.playerX = 0
- msgRet.playerY = 0
- msgRet.layer = 0
- msgRet.list[0]= 0
- msgRet.leftTime = leftTime
- if not human.lostTemple then
- Msg.send(msgRet, human.fd)
- return
- end
-
- if not makeGridNet(human, msgRet.list) then
- Msg.send(msgRet, human.fd)
- return
- end
- msgRet.playerX = human.lostTemple.x
- msgRet.playerY = human.lostTemple.y
- msgRet.layer = human.lostTemple.layer
- Msg.send(msgRet, human.fd)
- end
- -- ����������Ƿ�Ϸ�
- function checkPutByY(human, y)
- local startX = human.lostTemple.x + 1
- if not human.lostTemple.grid or not human.lostTemple.grid[startX] or not human.lostTemple.grid[startX][y] then return end
- local grid = human.lostTemple.grid[startX][y]
- -- �����λ���Ƿ�Ϸ�
- return grid
- end
- -- ����������Ƿ�Ϸ�
- function checkPut(human, x, y)
- local startX = x
- if not human.lostTemple.grid or not human.lostTemple.grid[startX] or not human.lostTemple.grid[startX][y] then return end
- local grid = human.lostTemple.grid[startX][y]
- -- �����λ���Ƿ�Ϸ�
- return grid
- end
- -- ���ø���
- function putSet(human, y, cmd)
- local startX = human.lostTemple.x + 1
- if not human.lostTemple.grid or not human.lostTemple.grid[startX] or not human.lostTemple.grid[startX][y] then return end
- if cmd == "eliteBoss" then
- human.lostTemple.grid[startX][y] = { id = makeBoxGrid(human) }
- return true
- end
- if cmd == "summonBox" then
- human.lostTemple.grid[startX][y] = { id = makeConverDoorGrid(human) }
- return true
- end
- end
- -- �ߵ���һ��
- function put(human, op, x, y, arg)
- if not isOpen(human) then return end
- if not human.lostTemple then return end
- if op ~= OP_QUERY and op ~= OP_CONFIRM then return end
- local grid = checkPut(human, x, y)
- if not grid then return end
- local elementConfig = ElementExcel[grid.id]
- if not elementConfig then return end
- local ret = nil
- if Lost_Handle_Func[elementConfig.cmd] then
- ret = Lost_Handle_Func[elementConfig.cmd](human, op, y, grid, arg, elementConfig)
- end
- if ret then
- nextGrid(human, y)
- dbSave(human)
- update(human)
- end
- end
- -- �������
- local function monsterQuery(human, grid, elementConfig)
- if not human.lostTemple then return end
- if not grid.monsterOutID then return end
- local rewardConfig = LostTempleExcel.Drop[elementConfig.arg[1]]
- if not rewardConfig then return end
- local msgRet = Msg.gc.GC_LOST_TEMPLE_MONSTER
- msgRet.gdReward[0] = 0
- for _, item in ipairs(rewardConfig.drop) do
- msgRet.gdReward[0] = msgRet.gdReward[0] + 1
- Grid.makeItem(msgRet.gdReward[msgRet.gdReward[0]], item[1], item[2])
- end
- msgRet.randomReward[0] = 0
- for _, item in ipairs(rewardConfig.randomdrop) do
- if type(item) == "table" then
- msgRet.randomReward[0] = msgRet.randomReward[0] + 1
- Grid.makeItem(msgRet.randomReward[msgRet.randomReward[0]], item[1], item[2])
- end
- end
- local monsterOutConfig = MonsterOutExcel[grid.monsterOutID]
- if not monsterOutConfig then return end
- local formation = monsterOutConfig.formation
- formation = formation == 0 and 1 or formation
- local mationConfig = CombatPosExcel.formation[formation]
- local posList = mationConfig.pos
- if not posList then return end
- msgRet.list[0] = 0
- for i, member in ipairs(monsterOutConfig.member) do
- local monsterID = member[1]
- local monsterConfig = MonsterExcel.monster[monsterID]
- if posList[i] then
- local defPos = CombatLogic.getPos(CombatDefine.DEFEND_SIDE, posList[i])
- local monsterLv = member[2]
- local obj = grid.objStatus and grid.objStatus[defPos] or nil
- local hpRate = obj and obj.hpRate or 1
- local hp = math.ceil(INIT_HP_MAX * hpRate)
- local hpMax = INIT_HP_MAX
- local others = HeroGrid.createOthers(monsterLv, hp, hpMax, monsterConfig.star)
- msgRet.list[0] = msgRet.list[0] + 1
- HeroGrid.makeHeroSimpleByMonsterID(msgRet.list[msgRet.list[0]], monsterID, others)
- end
- end
- Msg.send(msgRet, human.fd)
- end
- -- Ӣ���б�
- function sendHeroStatus(human)
- if not human.lostTemple then return end
- local msgRet = Msg.gc.GC_LOST_TEMPLE_HERO_STATUS
- msgRet.list[0] = 0
- msgRet.isEnd = 0
- local len = 0
- if human.lostTemple.heroStatus then
- for k, hpRate in pairs(human.lostTemple.heroStatus) do
- local hp = math.ceil(INIT_HP_MAX * hpRate)
- local hpMax = INIT_HP_MAX
-
- len = len + 1
- local net = msgRet.list[len]
- net.hp = hp
- net.hpMax = hpMax
- net.uuid = k
-
- if len >= 30 then
- msgRet.isEnd = 0
- msgRet.list[0] = len
- Msg.send(msgRet, human.fd)
- len = 0
- end
- end
- end
- msgRet.isEnd = 1
- msgRet.list[0] = len
- Msg.send(msgRet, human.fd)
- end
- -- �����ٻ���̳Ӣ���б�
- function sendSummonHeroList(human)
- if not human.lostTemple then return end
- if not human.lostTemple.summonHero then return end
- local msgRet = Msg.gc.GC_LOST_TEMPLE_SUMMON_LIST
- msgRet.list[0] = 0
- for index = 1, human.lostTemple.summonHero[0] do
- msgRet.list[0] = msgRet.list[0] + 1
- HeroGrid.makeHeroSimple(msgRet.list[msgRet.list[0]], human.lostTemple.summonHero[index], index)
- end
- Msg.send(msgRet, human.fd)
- end
- -- ����buff����
- function sendSummonTreeList(human)
- if not human.lostTemple then return end
- if not human.lostTemple.summonTree then return end
- local msgRet = Msg.gc.GC_LOST_TEMPLE_BUFF_LIST
- msgRet.list[0] = 0
- for k, v in pairs(human.lostTemple.summonTree) do
- msgRet.list[0] = msgRet.list[0] + 1
- local net = msgRet.list[msgRet.list[0]]
- net.attr.key = k
- net.attr.value = v
- net.name = ""
- for i = 1, #LostTempleExcel.Tree do
- if LostTempleExcel.Tree[i].icon == k then
- net.name = LostTempleExcel.Tree[i].buffname
- break
- end
- end
- end
- Msg.send(msgRet, human.fd)
- end
- -- �����������
- function sendRandomBox(human)
- if not human.lostTemple then return end
- local msgRet = Msg.gc.GC_LOGT_TEMPLE_RANDOM_BOX
- local len = 0
- if human.lostTemple.randomReward then
- for k, v in pairs(human.lostTemple.randomReward) do
- len = len + 1
- Grid.makeItem(msgRet.randomReward[len], k, v)
- end
- end
- msgRet.randomReward[0] = len
- Msg.send(msgRet, human.fd)
- end
- --
- function Lost_Handle_Func.nomalMonster(human, op, y, grid, arg, elementConfig)
- if op == OP_QUERY then
- monsterQuery(human, grid, elementConfig)
- end
- end
- --
- function Lost_Handle_Func.eliteMonster(human, op, y, grid, arg, elementConfig)
- if op == OP_QUERY then
- monsterQuery(human, grid, elementConfig)
- end
- end
- --
- function Lost_Handle_Func.eliteBoss(human, op, y, grid, arg, elementConfig)
- if op == OP_QUERY then
- monsterQuery(human, grid, elementConfig)
- end
- end
- --
- function Lost_Handle_Func.summonHero(human, op, y, grid, arg, elementConfig)
- -- �ٻ���̳��ѯ
- if op == OP_QUERY then
- if not grid.summonHero then return end
- local msgRet = Msg.gc.GC_LOST_TEMPLE_SUMMON
- msgRet.list[0] = 0
- for i = 1, #grid.summonHero do
- local hero = grid.summonHero[i]
- msgRet.list[0] = msgRet.list[0] + 1
- local others = HeroGrid.createOthers(hero.lv, INIT_HP_MAX, INIT_HP_MAX, hero.star)
- HeroGrid.makeHeroSimpleByID(msgRet.list[msgRet.list[0]], hero.id, i, others)
- end
- Msg.send(msgRet, human.fd)
- return
- end
- -- ����ٻ�Ӣ��
- if op == OP_CONFIRM then
- local index = tonumber(arg)
- if not grid.summonHero then return end
- local hero = grid.summonHero[index]
- if not hero then return end
- local heroGrid = HeroGrid.createHeroGrid(hero.id, hero.star)
- if not heroGrid then return end
- heroGrid.isLostTemple = 1
- -- ��ʼ������
- local attrConfig = HeroDefine.getAttrConfig(hero.id, heroGrid.star)
- if not attrConfig then return end
- local quality = HeroGrid.getMaxQualityByLv(heroGrid.star, hero.lv)
- local maxLv = HeroGrid.getMaxLv(heroGrid.star, quality)
- heroGrid.lv = math.min(maxLv, hero.lv or 0)
- heroGrid.quality = math.max(heroGrid.quality, quality or 0)
- -- ����װ��
- -- ���뵽Ӣ�۶���
- human.lostTemple.summonHero = human.lostTemple.summonHero or { }
- human.lostTemple.summonHero[0] = human.lostTemple.summonHero[0] or 0
- human.lostTemple.summonHero[0] = human.lostTemple.summonHero[0] + 1
- local addIndex = human.lostTemple.summonHero[0]
- human.lostTemple.summonHero[addIndex] = heroGrid
- heroGrid.bagIndex = addIndex
- -- ��������
- LostTempleCombatLogic.getHeroAttrs(human, addIndex)
- -- ֪ͨ�ͻ���
- sendSummonHeroList(human)
- return true
- end
- end
- -- �ǻ���
- function Lost_Handle_Func.summonTree(human, op, y, grid, arg, elementConfig)
- -- �ٻ���̳��ѯ
- if op == OP_QUERY then
- if not grid.summonTree then return end
- local msgRet = Msg.gc.GC_LOST_TEMPLE_BUFF
- msgRet.list[0] = 0
- for i = 1, #grid.summonTree do
- local hero = grid.summonTree[i]
- msgRet.list[0] = msgRet.list[0] + 1
- local config = LostTempleExcel.Tree[grid.summonTree[i]]
- local net = msgRet.list[msgRet.list[0]]
- net.id = i
- net.icon = config.icon
- net.name = config.buffname
- net.attr[0] = #config.Buffid
- for i = 1, #config.Buffid do
- net.attr[i].key = config.Buffid[i][1]
- net.attr[i].value = config.Buffid[i][2]
- end
- end
- Msg.send(msgRet, human.fd)
- return
- end
- -- ����ٻ�Ӣ��
- if op == OP_CONFIRM then
- local index = tonumber(arg)
- if not grid.summonTree then return end
- local buffID = grid.summonTree[index]
- if not buffID then return end
- local config = LostTempleExcel.Tree[buffID]
- if not config then return end
- human.lostTemple.summonTree = human.lostTemple.summonTree or { }
- for i = 1, #config.Buffid do
- local key = config.Buffid[i][1]
- local value = config.Buffid[i][2]
- human.lostTemple.summonTree[key] = human.lostTemple.summonTree[key] or 0
- human.lostTemple.summonTree[key] = human.lostTemple.summonTree[key] + value
- end
- sendSummonTreeList(human)
- return true
- end
- end
- -- ����ʹ
- function Lost_Handle_Func.treatRevive(human, op, y, grid, arg, elementConfig)
- if op == OP_QUERY then
- return
- end
- -- ��������
- if op == OP_CONFIRM then
- local opType = tonumber(arg)
- local heroStatus = human.lostTemple.heroStatus
- if not heroStatus then return true end
- -- ����
- if opType == 1 then
- local len = 0
- local cnt = 0
- local revice = {}
- local hpList = {}
- for k, hpRate in pairs(heroStatus) do
- if hpRate <= 0.0 then
- len = len + 1
- revice[len]=k
- else
- if hpRate < 1.0 then
- cnt = cnt + 1
- hpList[cnt] = k
- end
- end
- end
- if #revice > 0 then
- local random = math.random(1, #revice)
- heroStatus[revice[random]] = nil
- elseif #hpList > 0 then
- local random = math.random(1, #hpList)
- heroStatus[hpList[random]] = nil
- end
- end
- -- ����
- if opType == 2 then
- for k, hpRate in pairs(heroStatus) do
- if heroStatus[k] > 0.0 then
- heroStatus[k] = hpRate + 0.5
- if heroStatus[k] >= 1.0 then
- heroStatus[k] = nil
- end
- end
- end
- end
- sendHeroStatus(human)
- return true
- end
- end
- -- ����̵�
- function Lost_Handle_Func.summonShop(human, op, y, grid, arg, elementConfig)
- if op == OP_QUERY then
- if not grid.summonShop then return end
- local msgRet = Msg.gc.GC_LOST_TEMPLE_SHOP
- msgRet.list[0] = 0
- for i = 1, #grid.summonShop do
- msgRet.list[0] = msgRet.list[0] + 1
- local config = LostTempleExcel.LostShop[grid.summonShop[i]]
- local net = msgRet.list[msgRet.list[0]]
- Grid.makeItem(net.item, config.itemid, config.itemnum)
- Grid.makeItem(net.needItem, config.spenditem, config.spendnum)
- net.discount = config.discount
- net.id = i
- end
- Msg.send(msgRet, human.fd)
- return
- end
- -- ������
- if op == OP_CONFIRM then
- local index = tonumber(arg)
- if not grid.summonShop then return end
- local shopID = grid.summonShop[index]
- if not shopID then return end
- local config = LostTempleExcel.LostShop[shopID]
- if not config then return end
- if not BagLogic.checkItemCnt(human, config.spenditem, config.spendnum) then
- return
- end
- BagLogic.delItem(human, config.spenditem, config.spendnum, "lostTemple")
- BagLogic.addItem(human, config.itemid, config.itemnum, "lostTemple")
- return true
- end
- end
- -- ����
- function Lost_Handle_Func.summonBox(human, op, y, grid, arg, elementConfig)
- if op == OP_QUERY then
- sendRandomBox(human)
- return
- end
- --
- if op == OP_CONFIRM then
- if human.lostTemple.randomReward then
- local item = { }
- local len = 0
- for k, v in pairs(human.lostTemple.randomReward) do
- len = len + 1
- item[len] = { k, v }
- end
- BagLogic.addItemList(human, item, "lostTemple")
- human.lostTemple.randomReward = nil
- end
- -- �ж���û����һ��
- local nextLayer = human.lostTemple.layer + 1
- local LostTempleConfig = LostTempleExcel[nextLayer]
- if LostTempleConfig then
- -- ��ɴ�����
- putSet(human, y, elementConfig.cmd)
- end
- dbSave(human)
- update(human)
- end
- end
- -- ������
- function Lost_Handle_Func.conveyDoor(human, op, y, grid, arg, elementConfig)
- if op == OP_QUERY then
- return
- end
- -- ������һ��
- if op == OP_CONFIRM then
- nextDB(human)
- dbSave(human)
- update(human)
- end
- end
- function lostTempleRevice(human)
- if not human.lostTemple then return end
- human.lostTemple.heroStatus = nil
- sendHeroStatus(human)
- end
|