| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- local Msg = require("core.Msg")
- local Util = require("common.Util")
- local CombatPosLogic = require("combat.CombatPosLogic")
- local HeroGrid = require("hero.HeroGrid")
- local BeSkill = require("combat.BeSkill")
- local CombatDefine = require("combat.CombatDefine")
- local JibanExcel = require("excel.jiban")
- local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
- local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
- local Broadcast = require("broadcast.Broadcast")
- local Lang = require("common.Lang")
- local HeroLogic = require("hero.HeroLogic")
- local GuideLogic = require("guide.GuideLogic")
- local CombatExcel = require("excel.combat")
- CMD1 = 1 -- 主线通关
- CMD2 = 2 -- 获得英雄
- CMD3 = 3 -- 通关通天塔
- CMD4 = 4 -- 等级
- FATHER2ID = nil
- HERO2ID = nil
- CMD2POS = nil
- local function getDB(human)
- human.db.jiban = human.db.jiban or {[1] = 1}
- return human.db.jiban
- end
- local function fontJibanInfo(net,id)
- local conf = JibanExcel.jiban[id]
- net.id = id
- net.name = conf.name
- net.desc = conf.desc
- net.quality = conf.quality
- local len = 0
- for _,v in ipairs(conf.hero) do
- len = len + 1
- HeroGrid.makeHeroSimpleByID(net.heroList[len], v)
- end
- net.heroList[0] = len
- end
- function initAfterHot()
- FATHER2ID = {}
- HERO2ID = {}
- local temp = {}
- for k,v in ipairs(JibanExcel.jiban) do
- temp[#temp + 1] = {v.quality,k}
- for _,v1 in ipairs(v.hero) do
- HERO2ID[v1] = HERO2ID[v1] or {}
- HERO2ID[v1][#HERO2ID[v1] + 1] = k
- end
- end
- table.sort(temp,function(a,b)
- if a[1] > b[1] then
- return true
- elseif a[1] == b[1] and a[2] < b[2] then
- return true
- else
- return false
- end
- end)
- local msgRet = Msg.gc.GC_JIBAN_PREVIEW
- local len = 0
- for k,v in ipairs(temp) do
- local conf = JibanExcel.jiban[v[2]]
- FATHER2ID[conf.father] = FATHER2ID[conf.father] or {}
- FATHER2ID[conf.father][#FATHER2ID[conf.father] + 1] = v[2]
- len = len + 1
- local net = msgRet.list[len]
- fontJibanInfo(net,k)
- end
- msgRet.list[0] = len
- CMD2POS = {}
- for k,v in ipairs(JibanExcel.pos) do
- if v.cmd > 0 then
- CMD2POS[v.cmd] = k
- end
- end
- end
- function query(human,combatType,heroID)
- local flag = RoleSystemLogic.isOpen(human,RoleSystemDefine.ROLE_SYS_ID_207)
- if flag ~= true then
- return
- end
- local msgRet = Msg.gc.GC_JIBAN_QUERY
- local len = 0
- if HERO2ID[heroID] then
- for k,v in ipairs(HERO2ID[heroID]) do
- len = len + 1
- local net = msgRet.jibanList[len]
- fontJibanInfo(net,v)
- end
- end
- msgRet.jibanList[0] = len
- len = 0
- local db = getDB(human)
- local combatHeroDB = CombatPosLogic.getCombatHeroDB(human,combatType)
- local jibanDB = combatHeroDB.jiban or {}
- for k,v in ipairs(JibanExcel.pos) do
- len = len + 1
- local net = msgRet.posList[len]
- net.id = k
- net.tip = v.tip
- net.isOpen = db[k] or 0
- net.sort = v.sort
- local heroGrid
- if jibanDB[k] and jibanDB[k] ~= "" and jibanDB[k] ~= "0" then
- heroGrid = HeroLogic.getHeroGridByUuid(human, jibanDB[k])
- end
- index = heroGrid and heroGrid.bagIndex or 0
- HeroGrid.makeHeroSimple(net.hero, heroGrid, index)
- end
- msgRet.posList[0] = len
- Msg.send(msgRet,human.fd)
- end
- --
- function sendQuery(human,combatType, teamType)
- local msgRet = Msg.gc.GC_JIBAN_QUERY_ALL
- local len = 0
- local db = getDB(human)
- msgRet.type = teamType
- local combatHeroDB = CombatPosLogic.getCombatHeroDB(human,combatType)
- local jibanDB = combatHeroDB.jiban or {}
- for k,v in ipairs(JibanExcel.pos) do
- len = len + 1
- local net = msgRet.posList[len]
- net.id = k
- net.tip = v.tip
- net.isOpen = db[k] or 0
- net.sort = v.sort
- local heroGrid
- if jibanDB[k] and jibanDB[k] ~= "" and jibanDB[k] ~= "0" then
- heroGrid = HeroLogic.getHeroGridByUuid(human, jibanDB[k])
- end
- index = heroGrid and heroGrid.bagIndex or 0
- HeroGrid.makeHeroSimple(net.hero, heroGrid, index)
- end
- msgRet.posList[0] = len
- Msg.send(msgRet,human.fd)
- end
- function preview(human)
- local msgRet = Msg.gc.GC_JIBAN_PREVIEW
- Msg.send(msgRet,human.fd)
- end
- function getPosList(human)
- return getDB(human)
- end
- function onCallback(human,cmd,arg)
- local pos = CMD2POS[cmd]
- local db = getDB(human)
- if db[pos] then
- return
- end
- local conf = JibanExcel.pos[pos]
- if arg >= conf.arg then
- db[pos] = 1
- end
- end
- function getJiban(objList,jibanList)
- local objHero = {}
- local jibanHero = {}
- for i = 1,CombatDefine.COMBAT_HERO_CNT - 1 do
- local obj = objList[i]
- -- 不是玩家不计算羁绊
- if obj and obj.type == CombatDefine.COMBAT_OBJ_TYPE1 then
- objHero[obj.id] = objHero[obj.id] or 0
- objHero[obj.id] = objHero[obj.id] + 1
- end
- end
- if jibanList then
- for k,v in pairs(jibanList) do
- if v > 0 then
- objHero[v] = objHero[v] or 0
- objHero[v] = objHero[v] + 1
- end
- end
- end
- local jiban = {}
- for _,v in pairs(FATHER2ID) do
- for _,v1 in ipairs(v) do
- local conf = JibanExcel.jiban[v1]
- local canUse = true
- for _,v2 in ipairs(conf.hero) do
- if not objHero[v2] then
- canUse = false
- break
- end
- end
- if canUse then
- jiban[v1] = 1
- break
- end
- end
- end
- return jiban
- end
- function getJibanHero(human,combatHeroDB)
- local jibanHero = {}
- if combatHeroDB.jiban then
- for k, uuid in pairs(combatHeroDB.jiban) do
- if uuid ~= "0" and uuid ~= "" then
- heroGrid = HeroLogic.getHeroGridByUuid(human, uuid)
- if heroGrid then
- jibanHero[k] = heroGrid.id
- end
- end
- end
- end
- return jibanHero
- end
- function getDesc(jiban)
- local desc = {}
- local len = 0
- for k,v in pairs(jiban) do
- local conf = JibanExcel.jiban[k]
- if len > 0 then
- len = len + 1
- desc[len] = "|"
- end
- len = len + 1
- desc[len] = conf.name
- len = len + 1
- desc[len] = ","
- len = len + 1
- desc[len] = conf.desc
- len = len + 1
- desc[len] = ","
- len = len + 1
- desc[len] = conf.quality
- end
- local descStr = table.concat(desc)
- return descStr
- end
- function setBeSkill(objList,jiban)
- if not jiban then return end
- local skillList = {}
- for k in pairs(jiban) do
- local conf = JibanExcel.jiban[k]
- local skillID = conf.skill
- if skillID > 0 then
- for i = 1,CombatDefine.COMBAT_HERO_CNT - 1 do
- local obj = objList[i]
- if obj then
- BeSkill.setBeSkillID(obj,skillID)
- end
- end
- end
- end
- end
- function update(human,combatType,jibanListStr)
- local conf = CombatExcel.combat[combatType]
- if not conf then return end
- local posList = getPosList(human)
- local jibanList = Util.split(jibanListStr,",")
- local combatHeroDB = CombatPosLogic.getCombatHeroDB(human,combatType)
- for k,v in ipairs(jibanList) do
- local uuid = v or "0"
- if uuid ~= "" and uuid ~= "0" then
- --检测有没有再阵容上
- for _, combatUuid in ipairs(combatHeroDB.list) do
- if uuid == combatUuid then return end
- end
- if not posList[k] then return end
- local heroGrid = HeroLogic.getHeroGridByUuid(human, uuid)
- if not heroGrid then return end
- end
- end
- combatHeroDB.jiban = jibanList
- GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_JIBAN_GROUP)
- sendQuery(human,combatType, conf.teamType)
- end
|