| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452 |
- -- 魔兽 --
- Json = Json or require("common.Json")
- local Log = require("common.Log")
- local MoShouExcel = require("excel.moshou")
- local Msg = require("core.Msg")
- local Grid = require("bag.Grid")
- local CommonDB = require("common.CommonDB")
- local Broadcast = require("broadcast.Broadcast")
- local Lang = require("common.Lang")
- local ItemDefine = require("bag.ItemDefine")
- local RoleDefine = require("role.RoleDefine")
- local BagLogic = require("bag.BagLogic")
- local RoleAttr = require("role.RoleAttr")
- local SkillExcel = require("excel.skill")
- local HeroExcel = require("excel.hero")
- local ObjHuman = require("core.ObjHuman")
- local SkillExcel = require("excel.skill")
- local Util = require("common.Util")
- local CombatPosLogic = require("combat.CombatPosLogic")
- local CombatDefine = require("combat.CombatDefine")
- local CombatImpl = require("combat.CombatImpl")
- local ChengjiuLogic = require("chengjiu.ChengjiuLogic")
- local ChengjiuDefine = require("chengjiu.ChengjiuDefine")
- local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
- local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
- local BuyLogic = require("topup.BuyLogic")
- local YunYingLogic = require("yunying.YunYingLogic")
- local TriggerDefine = require("trigger.TriggerDefine")
- local TriggerLogic = require("trigger.TriggerLogic")
- local TalismanLogic = require("talisman.TalismanLogic")
- -- human.db.moshou = {
- -- lv = nil --等级
- -- lvExp = nil --魔兽等级经验
- -- jingLian = nil --精炼
- -- zhuHun = nil --铸魂
- -- skillLV = nil --魔兽技能等级
- -- putOnMoshou = nil --已上阵魔兽
- -- xilian = nil -- 洗练
- -- }
- -- human.db.moshou[moshouID] = {
- -- taskGet = nil --魔兽激活任务领取
- -- }
- -- human.db.moshou[moshouID].taskGet[taskID] = nil --任务领取奖励即记录
- -- human.db.moshou.jingLian = jingLianLV --精炼等级
- -- human.db.moshou.zhuHun = zhuHunCnt --铸魂石已使用个数
- -- human.db.moshou.task[taskType] = cnt --任务类型->已完成数
- MOSHOU_SKILLLV_ARGE1 = 1 --魔兽技能等级限制 魔兽等级
- MOSHOU_SKILLLV_ARGE2 = 2 --魔兽技能等级限制 君主等级
- MOSHOU_JINGLIANLV_ARGE1 = 1 --魔兽精炼等级限制 魔兽等级
- MOSHOU_JINGLIANLV_ARGE2 = 2 --魔兽精炼等级限制 聚义厅等级
- MOSHOU_ID1 = 1 -- 魔兽ID
- MOSHOU_MIN_LEVEL = 4 -- 魔兽技能使用最低要求
- MOSHOU_SKILL = MOSHOU_SKILL or {}
- MOSHOU_XILIAN_OP_1 = 1 -- 洗练
- MOSHOU_XILIAN_OP_2 = 2 -- 保存洗练
- -- 获取来自秘宝的属性倍数加成
- local function getLvAttrMulFromTalisman(human)
- local attrMul = TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.Moshou_LvAttr_Mul)
- attrMul = attrMul / 100
- return attrMul
- end
- local function initMoShouSkill(moshouID)
- local moshouSkillExcel = MoShouExcel.moshouSkill
- if not MOSHOU_SKILL[moshouID] then
- for k, v in ipairs(moshouSkillExcel) do
- if v.moshouId == moshouID then
- MOSHOU_SKILL[moshouID] = MOSHOU_SKILL[moshouID] or {}
- MOSHOU_SKILL[moshouID][k] = v.moshouSkill
- end
- end
- end
- end
- function initXilian()
- for _, config in ipairs(MoShouExcel.moshouxlRandom) do
- config.rareSum1 = 0
- config.rareSum2 = 0
- for i = config.random[1], config.random[2] do
- local templeConfig = MoShouExcel.moshouXiLian[i]
- config.rareSum1 = config.rareSum1 + templeConfig.rare1
- config.rareSum2 = config.rareSum2 + templeConfig.rare2
- end
- end
- for _, config in ipairs(MoShouExcel.moshouXiLian) do
- local rare = 0
- for k, v in ipairs(config.attrs1) do
- rare = rare + v[3]
- end
- config.attrRareMax = rare
- end
-
- end
- function initAfterHot()
- initMoShouSkill(MOSHOU_ID1)
- initXilian()
- end
- local function makeMoshouLvAttrs(human, net, moshouID)
- local lvAttrMul = getLvAttrMulFromTalisman(human)
- lvAttrMul = 1 + lvAttrMul
- net[0] = 0
- local nowLV = getMoshouLv(human)
- local config = MoShouExcel.moshouLv[nowLV]
- if config then
- net[0] = #config.lvAttrs
- for i = 1, #config.lvAttrs do
- net[i].key = config.lvAttrs[i][1]
- net[i].value = config.lvAttrs[i][2] * lvAttrMul
- end
- end
- local lvAttrsAdd = human.db.moshou and human.db.moshou.lvAttrsAdd or nil
- if lvAttrsAdd then
- for k,v in pairs(lvAttrsAdd) do
- for i=1,#config.lvAttrs do
- if net[i].key == k then
- net[i].value = net[i].value + v * lvAttrMul
- end
- end
- end
- end
- end
- local function makeMoshouLvUp(human, net)
- net[0] = 0
- local nowLV = getMoshouLv(human)
- if nowLV >= #MoShouExcel.moshouLv then return end
- net[0] = 1
- net[1].nowJinDu = human.db.moshou and human.db.moshou.lvExp or 0
- local nextConfig = MoShouExcel.moshouLv[nowLV + 1]
- net[1].needJinDu = nextConfig.needJinDu
- net[1].needItem[0] = #nextConfig.lvUpNeed
- for i = 1, #nextConfig.lvUpNeed do
- local itemID = nextConfig.lvUpNeed[i][1]
- local itemCnt = nextConfig.lvUpNeed[i][2]
- Grid.makeItem(net[1].needItem[i], itemID, itemCnt)
- end
- end
- local function makeMoshouLvUpNet(net, human, moshouID)
- local config = MoShouExcel.moshouActive[MOSHOU_ID1]
- net.moshouID = moshouID
- net.name = config.moshouName
- net.body = config.body
- net.moshouLv = getMoshouLv(human)
- makeMoshouLvAttrs(human, net.lvAttrs, moshouID)
- makeMoshouLvUp(human, net.moshouLvUp)
- end
- local function makeMoshouReds(net, human)
- net.lvUpRed = moshouLVupRed(human) and 1 or 0
- net.jinglianRed = moshouJinglianRed(human) and 1 or 0
- net.zhuHunRed = moshouZhunHunRed(human) and 1 or 0
- net.skillRed = moshouSkillUpRed(human) and 1 or 0
- net.xilianRed = moshouXilianUpRed(human) and 1 or 0
- end
- local function makeJingLianLvData(human, net, attr, targrtLv)
- net.lv = targrtLv
- net.attr.key = attr[1]
- net.attr.value = attr[2]
- end
- function moshouLvUpQuery(human, moshouID)
- local msgRet = Msg.gc.GC_MOSHOU_LVUP_QUERY
- local config = MoShouExcel.moshouActive[MOSHOU_ID1]
- if not config then return end
- makeMoshouLvUpNet(msgRet.moshouLv, human, MOSHOU_ID1)
- makeMoshouReds(msgRet.moshouReds, human)
- msgRet.jingLianLvData[0] = 0
- local nowLV = getMoShouJiLian(human)
- local nowConfig = MoShouExcel.moshouJingLian[nowLV]
- if nowConfig then
- msgRet.jingLianLvData[0] = 1
- makeJingLianLvData(human, msgRet.jingLianLvData[1], nowConfig.lvAttrs, nowLV)
- end
- msgRet.xilianOpen = xilianIsOpen(human)
- Msg.send(msgRet, human.fd)
- end
- local function makeMoshouSkill(human, net, moshouID, posSkillID)
- local len = 0
- local skillLV = getMoShouSkillLv(human)
- for k, v in ipairs(MOSHOU_SKILL[moshouID]) do
- local skillID = v[skillLV]
- if skillID then
- local skillConfig = SkillExcel.skill[skillID]
- len = len + 1
- if len > #net then
- break
- end
- net[len].id = skillID
- net[len].icon = skillConfig.icon
- net[len].name = skillConfig.name
- net[len].desc = skillConfig.desc
- net[len].lv = skillLV
- net[len].index = k
- net[len].state = 1
- if k == posSkillID then
- net[len].state = 2
- end
- end
- end
- net[0] = len
- end
- function makeXilianQuery(human, msgRet)
- msgRet.list[0] = 0
- if human.db.moshou and human.db.moshou.xilian then
- for k, db in ipairs(human.db.moshou.xilian) do
- local net = msgRet.list[k]
- local config = MoShouExcel.moshouXiLian[db.id]
- net.id = db.id
- net.index = k
- net.rare = config.pinzhiLv
- net.name = config.name
- net.lv = config.pinzhi
- -- print(" net.rare ", net.rare , net.lv, db.type)
- net.attrs[1].key = db.key
- net.attrs[1].value = db.value
- net.attrs[0] = 1
- net.needZuanshi = getXilianNeed(config, MOSHOU_XILIAN_OP_2, k)
- Grid.makeItem(net.item, ItemDefine.ITEM_LONGXUE_ID , getXilianNeed(config, MOSHOU_XILIAN_OP_1, k))
- net.nextRate = 0
- net.nextAttr[0] = 0
- net.nextName = ""
- local lastID = db.lastId
- if lastID and db.lastKey then
- local lastConfig = MoShouExcel.moshouXiLian[lastID]
- net.nextRate = lastConfig.pinzhiLv
- net.nextAttr[1].key = db.lastKey
- net.nextAttr[1].value = db.lastValue
- net.nextAttr[0] = 1
- net.nextName = lastConfig.name
- end
- end
- msgRet.list[0] = #human.db.moshou.xilian
- end
- end
- -- 刚打开魔兽界面查询 moshouID默认1
- -- 魔兽已全部激活 返回升级界面协议
- -- 魔兽未全部激活 返回魔兽激活任务协议(已激活的魔兽+正在完成任务的魔兽)
- function CG_MOSHOU_QUERY(human, moshouID)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- -- 升级界面协议
- moshouLvUpQuery(human, moshouID)
- end
- function CG_MOSHOU_LVUP_UP(human, upType)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- local nowLV = getMoshouLv(human)
- local maxLV = #MoShouExcel.moshouLv
- if nowLV >= maxLV then
- Broadcast.sendErr(human,Lang.MOSHOU_LV_UP_ERR)
- return
- end
- local config = MoShouExcel.moshouLv[nowLV+1]
- local lvUpNeed = config.lvUpNeed
- for i=1,#lvUpNeed do
- local itemID = lvUpNeed[i][1]
- local itemCnt = lvUpNeed[i][2]
- local now = BagLogic.getItemCnt(human, itemID)
- if now < itemCnt then
- Broadcast.sendErr(human,Lang.MOSHOU_LV_UP_NOT)
- return
- end
- end
- for i=1,#lvUpNeed do
- local itemID = lvUpNeed[i][1]
- local itemCnt = lvUpNeed[i][2]
- BagLogic.delItem(human, itemID, itemCnt, "moshou")
- end
-
- local nowConf = MoShouExcel.moshouLv[nowLV]
- local upGetJinDuCnf = nowConf.upGetJinDu
- local totalWeight = nil
- for i=1,#upGetJinDuCnf do
- totalWeight = (totalWeight or 0) + upGetJinDuCnf[i][2]
- end
- if not totalWeight then return end
- local weight = nil
- local upGetJinDuIndex = nil
- local randWeight = math.random(1,totalWeight)
- for i=1,#upGetJinDuCnf do
- weight = (weight or 0) + upGetJinDuCnf[i][2]
- if randWeight <= weight then
- upGetJinDuIndex = i
- break
- end
- end
- if not upGetJinDuIndex then return end
- local upGetJinDu = upGetJinDuCnf[upGetJinDuIndex][1]
- local lvAttrsAddCnf = nowConf.lvAttrsAdd[upGetJinDuIndex]
- local lvUpState = false
- human.db.moshou = human.db.moshou or {}
- human.db.moshou.lvExp = (human.db.moshou.lvExp or 0) + upGetJinDu
- if human.db.moshou.lvExp >= config.needJinDu * config.upNeedRate then
- human.db.moshou.lv = getMoshouLv(human)
- human.db.moshou.lv = human.db.moshou.lv + 1
- human.db.moshou.lvExp = 0
- human.db.moshou.lvAttrsAdd = nil
- lvUpState = true
- -- 守护之龙的等级记录
- --Log.write(Log.LOGID_OSS_DRAGON_LEVEL, human.db._id, human.db.account, human.db.name, human.db.moshou.lv, getMoShouSkillLv(human))
- Log.write(Log.LOGID_OSS_DRAGON_LEVEL, human.db._id, human.db.newUniqueTag, human.db.name, human.db.moshou.lv, getMoShouSkillLv(human))
- TriggerLogic.PublishEvent(TriggerDefine.FENGHUANGLV, human.db._id, human.db.moshou.lv)
- else
- human.db.moshou.lvAttrsAdd = human.db.moshou.lvAttrsAdd or {}
- for i=1,#lvAttrsAddCnf do
- local key = lvAttrsAddCnf[i][1]
- local value = lvAttrsAddCnf[i][2]
- human.db.moshou.lvAttrsAdd[key] = (human.db.moshou.lvAttrsAdd[key] or 0) + value
- end
- end
- local msgRet = Msg.gc.GC_MOSHOU_LVUP_UP
- makeMoshouLvAttrs(human,msgRet.lvAttrs)
- makeMoshouLvUp(human,msgRet.moshouLvUp)
- msgRet.moshouLv = getMoshouLv(human)
- Msg.send(msgRet,human.fd)
- moshouLvUpQuery(human)
- RoleAttr.cleanHeroAttrCache(human)
- RoleAttr.doCalc(human)
- ObjHuman.sendAttr(human, RoleDefine.ZHANDOULI)
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2002)
- if lvUpState then
- moshouLvUpToXilianBreak(human)
- end
- end
- local function getLangByCanUpType(human,canUpType)
- if canUpType == MOSHOU_SKILLLV_ARGE1 then
- return Lang.MOSHOU_UP_DESC_MOSHOULV
- elseif canUpType == MOSHOU_SKILLLV_ARGE2 then
- return Lang.MOSHOU_UP_DESC_JUNZHU
- elseif canUpType == MOSHOU_JINGLIANLV_ARGE1 then
- return Lang.MOSHOU_UP_DESC_MOSHOULV
- elseif canUpType == MOSHOU_JINGLIANLV_ARGE2 then
- return Lang.MOSHOU_UP_DESC_JUYI
- end
- end
- local function getSkillCanUpNeed(human)
- local skillLV = getMoShouSkillLv(human)
- if skillLV >= #MoShouExcel.moshouSkillLv then
- return 0,0
- end
- local nextConf = MoShouExcel.moshouSkillLv[skillLV+1]
- return nextConf.canUpNeed[1] or 0,nextConf.canUpNeed[2] or 0
- end
- local function getSkillMaxLV(human)
- local moshouLV = getMoshouLv(human)
- local conf = MoShouExcel.moshouSkillLv
- local skillLV = getMoShouSkillLv(human)
- if skillLV >= #conf then
- return skillLV
- end
- for i=skillLV+1,#conf do
- local arge = conf[i].canUpNeed[1]
- local argeNeed = conf[i].canUpNeed[2]
- if arge == MOSHOU_SKILLLV_ARGE1 then
- if moshouLV < argeNeed then
- return i - 1
- end
- elseif arge == MOSHOU_SKILLLV_ARGE2 then
- return 0
- end
- end
- return #conf
- end
- function CG_MOSHOU_SKILL_QUERY(human, moshouID)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- if not MoShouExcel.moshouActive[MOSHOU_ID1] then return end
- local msgRet = Msg.gc.GC_MOSHOU_SKILL_QUERY
- msgRet.moshouID = MOSHOU_ID1
- makeMoshouSkill(human, msgRet.moshouSkill, MOSHOU_ID1)
- local moshouLV = getMoshouLv(human)
- local skillMaxLv = getSkillMaxLV(human)
- msgRet.skillMaxLv = skillMaxLv
- msgRet.needItem[0] = 0
- local skillLV = getMoShouSkillLv(human)
- local config = MoShouExcel.moshouSkillLv[skillLV + 1]
- if config and skillLV < skillMaxLv then
- msgRet.needItem[0] = #config.upCost
- for i = 1, #config.upCost do
- local itemID = config.upCost[i][1]
- local itemCnt = config.upCost[i][2]
- Grid.makeItem(msgRet.needItem[i], itemID, itemCnt)
- end
- end
- msgRet.skillCanUp = ""
- if skillLV >= #MoShouExcel.moshouSkillLv then
- msgRet.skillCanUp = Lang.MOSHOU_SKILL_LV_MAX
- else
- if skillLV >= skillMaxLv then
- local arge,argeNeed = getSkillCanUpNeed(human)
- local content = getLangByCanUpType(human,arge)
- if content then
- content = Util.format(content,argeNeed)
- msgRet.skillCanUp = content
- end
- end
- end
- Msg.send(msgRet, human.fd)
- end
- function CG_MOSHOU_SKILL_UP(human, moshouID)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- if not MoShouExcel.moshouActive[MOSHOU_ID1] then return end
- if not MOSHOU_SKILL[moshouID] then return end
- local moshouLV = getMoshouLv(human)
- local skillLV = getMoShouSkillLv(human)
- local config = MoShouExcel.moshouSkillLv
- if skillLV >= #config then return end
- local nextSkillLv = skillLV + 1
- if not MOSHOU_SKILL[moshouID][1][nextSkillLv] then return end
-
- local nowArgeCnt = nil
- local canUpNeedType = config[nextSkillLv].canUpNeed[1] or 0
- local canUpNeedValue = config[nextSkillLv].canUpNeed[2] or 0
- if canUpNeedType == MOSHOU_SKILLLV_ARGE1 then
- nowArgeCnt = moshouLV
- else
- return
- end
-
- if not nowArgeCnt then return end
- if nowArgeCnt < canUpNeedValue then return end
- local upCost = config[nextSkillLv].upCost
- for i = 1, #upCost do
- local itemID = upCost[i][1]
- local itemCnt = upCost[i][2]
- local nowCnt = BagLogic.getItemCnt(human, itemID)
- if nowCnt < itemCnt then return Broadcast.sendErr(human, Lang.MOSHOU_LV_UP_NOT) end
- end
- for i = 1, #upCost do
- local itemID = upCost[i][1]
- local itemCnt = upCost[i][2]
- BagLogic.delItem(human, itemID, itemCnt, "moshou")
- end
- human.db.moshou = human.db.moshou or {}
- human.db.moshou.skillLV = nextSkillLv
- --Log.write(Log.LOGID_OSS_DRAGON_LEVEL, human.db._id, human.db.account, human.db.name, human.db.moshou.lv, getMoShouSkillLv(human))
- Log.write(Log.LOGID_OSS_DRAGON_LEVEL, human.db._id, human.db.newUniqueTag, human.db.name, human.db.moshou.lv, getMoShouSkillLv(human))
- Broadcast.sendErr(human, Lang.MOSHOU_SKILL_LV_UP)
- moshouLvUpQuery(human)
- CG_MOSHOU_SKILL_QUERY(human, moshouID)
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2002)
- end
- function CG_MOSHOU_JINGLIAN_QUERY(human)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- local msgRet = Msg.gc.GC_MOSHOU_JINGLIAN_QUERY
- local jinglianLV = getMoShouJiLian(human)
- local moshouLV = getMoshouLv(human)
- local jingLianConfig = MoShouExcel.moshouJingLian
- local jingLianCanLV = #jingLianConfig
- msgRet.jingLianCanLV = jingLianCanLV
- msgRet.nowLvData[0] = 0
- msgRet.nextLvData[0] = 0
- msgRet.needItem[0] = 0
- local nowLV = getMoShouJiLian(human)
- local nextConfig = MoShouExcel.moshouJingLian[nowLV + 1]
- if nextConfig then
- local showLeft = nextConfig.showLeft
- local showRight = nextConfig.showRight
- msgRet.nowLvData[0] = 1
- makeJingLianLvData(human, msgRet.nowLvData[1], showLeft, nowLV)
- msgRet.nextLvData[0] = 1
- makeJingLianLvData(human, msgRet.nextLvData[1], showRight, nowLV + 1)
- msgRet.needItem[0] = #nextConfig.lvUpNeed
- for i = 1, #nextConfig.lvUpNeed do
- local itemID = nextConfig.lvUpNeed[i][1]
- local itemCnt = nextConfig.lvUpNeed[i][2]
- Grid.makeItem(msgRet.needItem[i], itemID, itemCnt)
- end
- else
- local nowConfig = MoShouExcel.moshouJingLian[nowLV]
- msgRet.nowLvData[0] = 1
- makeJingLianLvData(human, msgRet.nowLvData[1], nowConfig.lvAttrs, nowLV)
- end
- msgRet.attrs[0] = 0
- local attrs = nil
- if jingLianConfig[jinglianLV] then
- attrs = { }
- for i = 1, jinglianLV do
- local key = jingLianConfig[i].lvAttrs[1]
- local value = jingLianConfig[i].lvAttrs[2]
- attrs[key] =(attrs[key] or 0) + value
- end
- end
- if attrs then
- for key, value in pairs(attrs) do
- msgRet.attrs[0] = msgRet.attrs[0] + 1
- local index = msgRet.attrs[0]
- msgRet.attrs[index].key = key
- msgRet.attrs[index].value = value
- end
- end
- -- Msg.trace(msgRet)
- Msg.send(msgRet, human.fd)
- end
- function CG_MOSHOU_JINGLIAN_DO(human)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- local jingLianLV = getMoShouJiLian(human)
- local moshouLV = getMoshouLv(human)
- local jingLianMaxLV = #MoShouExcel.moshouJingLian
- if jingLianLV >= jingLianMaxLV then return end
- local nextConfig = MoShouExcel.moshouJingLian[jingLianLV + 1]
- local lvUpNeed = nextConfig.lvUpNeed
- for i = 1, #lvUpNeed do
- local itemID = lvUpNeed[i][1]
- local itemCnt = lvUpNeed[i][2]
- local nowCnt = BagLogic.getItemCnt(human, itemID)
- if nowCnt < itemCnt then return Broadcast.sendErr(human, Lang.MOSHOU_LV_UP_NOT) end
- end
- for i = 1, #lvUpNeed do
- local itemID = lvUpNeed[i][1]
- local itemCnt = lvUpNeed[i][2]
- BagLogic.delItem(human, itemID, itemCnt, "moshou")
- end
- human.db.moshou = human.db.moshou or { }
- human.db.moshou.jingLian = jingLianLV + 1
- Broadcast.sendErr(human, Lang.MOSHOU_JINGLIAN_LV_UP)
- CG_MOSHOU_JINGLIAN_QUERY(human)
- RoleAttr.cleanHeroAttrCache(human)
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2002)
- end
- function CG_MOSHOU_ZHUHUN_QUERY(human)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- local msgRet = Msg.gc.GC_MOSHOU_ZHUHUN_QUERY
- local config = MoShouExcel.moshouZhuHun[1]
- Grid.makeItem(msgRet.needItem, config.costID, 1)
- msgRet.nowAttr[0] = 0
- local nowUseCnt = human.db.moshou and human.db.moshou.zhuHun or 0
- if nowUseCnt > 0 then
- msgRet.nowAttr[0] = #config.zhuHunAttrs
- for i = 1, #config.zhuHunAttrs do
- msgRet.nowAttr[i].key = config.zhuHunAttrs[i][1]
- msgRet.nowAttr[i].value = config.zhuHunAttrs[i][2] + config.addZhuHun * nowUseCnt
- end
- end
- msgRet.nowUseCnt = nowUseCnt
- local moshouLV = getMoshouLv(human)
- local zhuHunCntMax = MoShouExcel.moshouLv[moshouLV].zhuHunCntMax
- msgRet.maxUseCan = zhuHunCntMax
- Msg.send(msgRet, human.fd)
- end
- function CG_MOSHOU_ZHUHUN_DO(human, useCnt)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- local moshouLV = getMoshouLv(human)
- local zhuHunCntMax = MoShouExcel.moshouLv[moshouLV].zhuHunCntMax
- local nowUseCnt = human.db.moshou and human.db.moshou.zhuHun or 0
- if nowUseCnt >= zhuHunCntMax or(nowUseCnt + useCnt) > zhuHunCntMax then return Broadcast.sendErr(human, Lang.MOSHOU_ZHUHUN_MAX) end
- local config = MoShouExcel.moshouZhuHun[1]
- local nowCnt = BagLogic.getItemCnt(human, config.costID)
- if useCnt > nowCnt then return Broadcast.sendErr(human, Lang.MOSHOU_LV_UP_NOT) end
- BagLogic.delItem(human, config.costID, useCnt, "moshou")
- human.db.moshou = human.db.moshou or { }
- human.db.moshou.zhuHun = nowUseCnt + useCnt
- Broadcast.sendErr(human, Lang.MOSHOU_ZHUHUN_LV_UP)
- CG_MOSHOU_ZHUHUN_QUERY(human)
- RoleAttr.cleanHeroAttrCache(human)
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2002)
- end
- local function makeMoshouPutOn(human, net, moshouID)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- net.moshouID = MOSHOU_ID1
- local config = MoShouExcel.moshouActive[MOSHOU_ID1]
- net.moshouName = config.moshouName
- net.moshouIcon = config.icon
- net.moshouLv = getMoshouLv(human)
- makeMoshouSkill(human, net.moshouSkill, MOSHOU_ID1)
- end
- -- 上阵界面 查询魔兽信息
- function CG_MOSHOU_PUT_QUERY(human)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- local config = MoShouExcel.moshouActive
- local msgRet = Msg.gc.GC_MOSHOU_PUT_QUERY
- msgRet.moshouPutOn[0] = #config
- for i = 1, #config do
- makeMoshouPutOn(human, msgRet.moshouPutOn[i], i)
- end
- Msg.send(msgRet, human.fd)
- end
- function doCalcHero(human, heroGrid, attrs)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- -- 魔兽等级属性加成
- local nowLV = getMoshouLv(human)
- local moshouLvConfig = MoShouExcel.moshouLv[nowLV]
- if moshouLvConfig and #moshouLvConfig.lvAttrs > 0 then
- local lvAttrs = nil
- for i=1,#moshouLvConfig.lvAttrs do
- local key = moshouLvConfig.lvAttrs[i][1]
- local value = moshouLvConfig.lvAttrs[i][2]
- lvAttrs = lvAttrs or {}
- lvAttrs[key] = (lvAttrs[key] or 0) + value
- end
- if human.db.moshou and human.db.moshou.lvAttrsAdd then
- local lvAttrsAdd = human.db.moshou.lvAttrsAdd
- for k,v in pairs(lvAttrsAdd) do
- lvAttrs = lvAttrs or {}
- lvAttrs[k] = (lvAttrs[k] or 0) + v
- end
- end
- local lvAttrMul = getLvAttrMulFromTalisman(human)
- lvAttrMul = 1 + lvAttrMul
- if lvAttrs then
- for k,v in pairs(lvAttrs) do
- RoleAttr.updateValue(k,v * lvAttrMul,attrs)
- end
- end
- end
- --魔兽精练等级属性加成
- local jingLianLV = human.db.moshou and human.db.moshou.jingLian or 0
- local jingLianConfig = MoShouExcel.moshouJingLian
- if jingLianConfig[jingLianLV] then
- for i=1,jingLianLV do
- local key = jingLianConfig[i].lvAttrs[1]
- local value = jingLianConfig[i].lvAttrs[2]
- RoleAttr.updateValue(key,value,attrs)
- end
- end
- --魔兽铸魂属性加成
- local zhuHun = human.db.moshou and human.db.moshou.zhuHun or 0
- local zhuHunConfig = MoShouExcel.moshouZhuHun[1]
- if zhuHun > 0 and #zhuHunConfig.zhuHunAttrs > 0 then
- for i=1,#zhuHunConfig.zhuHunAttrs do
- RoleAttr.updateValue(zhuHunConfig.zhuHunAttrs[i][1],zhuHunConfig.zhuHunAttrs[i][2] * zhuHun,attrs)
- end
- end
- -- 魔兽洗练的加成
- if human.db.moshou and human.db.moshou.xilian then
- for k, db in ipairs(human.db.moshou.xilian) do
- if db and db.key and db.value ~= 0 then
- RoleAttr.updateValue(db.key ,db.value ,attrs)
- end
- end
- local bestCnt = getXilianBestCnt(human)
- if bestCnt > 0 then
- local config = MoShouExcel.moshouxlHx[bestCnt]
- for k, v in ipairs(config.attrs) do
- RoleAttr.updateValue(v[1] ,v[2] ,attrs)
- end
- end
- end
- end
- function CG_MOSHOU_PREVIEW(human)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- local config = MoShouExcel.moshouActive
- local msgRet = Msg.gc.GC_MOSHOU_PREVIEW
- msgRet.preViews[0] = #config
- for i = 1, #config do
- msgRet.preViews[i].moshouID = i
- msgRet.preViews[i].name = config[i].moshouName
- msgRet.preViews[i].body = config[i].body
- end
- Msg.send(msgRet, human.fd)
- end
- -- 布阵界面查询魔兽
- function CG_MOSHOU_COMBAT_SKILL_QUERY(human, combatType)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- local posSkillID = CombatPosLogic.getCombatMoshou(human, combatType)
- local msgRet = Msg.gc.GC_MOSHOU_COMBAT_SKILL_QUERY
- local config = MoShouExcel.moshouSkill
- makeMoshouSkill(human, msgRet.skill, MOSHOU_ID1, posSkillID)
- Msg.send(msgRet,human.fd)
- end
- function xilianIsOpen(human)
- if not RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_2003) then
- return 0
- end
- if not human.db.moshou then
- return 0
- end
-
- if human.db.moshou.xilian and human.db.moshou.xilian.init then
- return 1
- end
-
- return 0
-
- end
- function xilianZDLUpdate(human)
- RoleAttr.cleanHeroAttrCache(human)
- RoleAttr.doCalc(human)
- ObjHuman.sendAttr(human, RoleDefine.ZHANDOULI)
- end
- function onLogin(human)
- initXilianDB(human)
- end
- -- 魔兽 洗练
- function initXilianDB(human)
- -- if not human.db.moshou then
- -- return
- -- end
- human.db.moshou = human.db.moshou or {}
- if not xilianIsOpen(human) then
- return
- end
- if human.db.moshou.xilian and human.db.moshou.xilian.init then
- return
- end
- -- local weekDay = Util.getWeekDay()
- -- if weekDay ~= 4 and weekDay ~= 7 then
- -- return
- -- end
- local lv = human.db.moshou.lv or 0
- local isChange = false
- for index, config in ipairs(MoShouExcel.moshouxlCao) do
- if lv >= config.breakLv then
- breakXiLianCao(human, index)
- isChange = true
- end
- end
- human.db.moshou.xilian.init = 1
-
- if isChange then
- xilianZDLUpdate(human)
- if not human.db.moshou.xilian.initTime then
- human.db.moshou.xilian.initTime = os.time()
- end
- end
- end
- function moshouLvUpToXilianBreak(human)
- if not xilianIsOpen(human) then
- return
- end
- local lv = human.db.moshou.lv or 0
- initXilianDB(human)
- local isChange = false
- for index, config in ipairs(MoShouExcel.moshouxlCao) do
- if lv >= config.breakLv then
- breakXiLianCao(human, index)
- isChange = true
- end
- end
- if isChange then
- xilianZDLUpdate(human)
- if not human.db.moshou.xilian.initTime then
- human.db.moshou.xilian.initTime = os.time()
- end
- end
- end
- function breakXiLianCao(human, index)
- if not human.db.moshou then return end
- human.db.moshou.xilian = human.db.moshou.xilian or {}
- if not human.db.moshou.xilian.cnt then
- human.db.moshou.xilian.cnt = 0
- end
- if human.db.moshou.xilian[index] then return end
- local newKey
- local newValue
- local haveList = {}
- if human.db.moshou and human.db.moshou.xilian then
- for _, db in ipairs(human.db.moshou.xilian) do
- haveList[db.key] = 1
- end
- end
- human.db.moshou.xilian[index] = {}
- local xilian = human.db.moshou.xilian[index]
- xilian.id = math.random(1, 5)
- local newConfig = MoShouExcel.moshouXiLian[xilian.id]
- for k , v in pairs(newConfig.attrs1) do
- if v and not haveList[v[1]] then
- newKey = v[1]
- newValue = v[2]
- end
- end
-
- xilian.key = newKey
- xilian.value = newValue
- end
- function getXilianNeed(config, type, index)
- local need = config["need"..type]
- local templateConfig = MoShouExcel.moshouxlCao[index]
- return math.floor(need * templateConfig.add)
- end
- function CG_MOSHOU_XILIAN_QUERY(human, index)
- initXilianDB(human)
- if index == 0 then
- index = human.db.moshou and human.db.moshou.xilian and #human.db.moshou.xilian or 0
- end
- local msgRet = Msg.gc.GC_MOSHOU_XILIAN_QUERY
- makeXilianQuery(human, msgRet)
- msgRet.index = index
- msgRet.fjAttrs[0] = 0
- for k, config in ipairs(MoShouExcel.moshouxlCao) do
- msgRet.openLv[k] = config.breakLv
- end
- msgRet.openLv[0] = #MoShouExcel.moshouxlCao
- local bestCnt = getXilianBestCnt(human)
- if bestCnt > 0 then
- local config = MoShouExcel.moshouxlHx[bestCnt]
- for k, v in ipairs(config.attrs) do
- msgRet.fjAttrs[k].key = v[1]
- msgRet.fjAttrs[k].value = v[2]
- end
- msgRet.fjAttrs[0] = #config.attrs
- end
- -- Util.printTable(human.db.moshou.xilian)
- -- Msg.trace(msgRet)
- Msg.send(msgRet,human.fd)
- end
- function xilianRandom(type, cnt)
- local min = 0
- local max = 0
- local random = 0
- for k, v in ipairs(MoShouExcel.moshouxlRandom) do
- if cnt >= v.cnt then
- min = v.random[1]
- max = v.random[2]
- random = v["rareSum"..type]
- end
- end
- local random = math.random(1, random)
- for i = min, max do
- local config = MoShouExcel.moshouXiLian[i]
- if random <= config["rare"..type] then
- return i
- else
- random = random - config["rare"..type]
- end
- end
- end
- function CG_MOSHOU_XILIAN_OP(human, op, type, index)
- if op == MOSHOU_XILIAN_OP_1 then
- xilianDo(human, index, type)
- elseif op == MOSHOU_XILIAN_OP_2 then
- saveXilian(human, index)
- end
- end
- function randomXilian(id)
- local config = MoShouExcel.moshouXiLian[id]
- local random = math.random(1, config.attrRareMax)
-
- for k ,v in ipairs(config.attrs1) do
- if v and v[3] >= random then
- return v[1], v[2]
- else
- random = random - v[3]
- end
- end
- end
- function xilianDo(human, index, type)
- if not human.db.moshou or not human.db.moshou.xilian then
- return
- end
- local xilian = human.db.moshou.xilian[index]
- if not xilian then return end
- if type ~= MOSHOU_XILIAN_OP_1 then -- and type ~= MOSHOU_XILIAN_OP_2 取消钻石洗练
- return
- end
- -- print(" xilianDo xilianDo ", index , type)
- local oldConfig = MoShouExcel.moshouXiLian[xilian.id]
- -- 洗练方式 验证材料是否够
- local itemID
- if type == MOSHOU_XILIAN_OP_1 then
- itemID = ItemDefine.ITEM_LONGXUE_ID
- else
- itemID = ItemDefine.ITEM_ZUANSHI_ID
- end
- local itemCnt = BagLogic.getItemCnt(human, itemID)
- local needCnt = oldConfig["need"..type]
- if itemCnt < needCnt then
- return
- end
- local newId = xilianRandom(type, human.db.moshou.xilian.cnt or 0)
- if not newId then return end
- -- print(" new ID ", newId)
- local newConfig = MoShouExcel.moshouXiLian[newId]
- -- local random = math.random(1, #newConfig["attrs"..type])
- -- local key = newConfig["attrs"..type][random][1]
- -- local value = newConfig["attrs"..type][random][2]
- local key, value = randomXilian(newId)
- -- 除所需材料
- BagLogic.delItem(human, itemID, needCnt, "moshou")
- xilian.lastId = newId
- xilian.lastKey = key
- xilian.lastValue = value
- human.db.moshou.xilian.cnt = human.db.moshou.xilian.cnt + 1
- CG_MOSHOU_XILIAN_QUERY(human, index)
- end
- function saveXilian(human, index)
- if not human.db.moshou or not human.db.moshou.xilian then
- return
- end
- local xilian = human.db.moshou.xilian[index]
- if not xilian then return end
- if not xilian.lastId then return end
- local haveIndex
- if human.db.moshou and human.db.moshou.xilian then
- for k, v in ipairs(human.db.moshou.xilian) do
- if v.key == xilian.lastKey then
- haveIndex = k
- end
- end
- end
- if haveIndex then
- local haveDb = human.db.moshou.xilian[haveIndex]
- haveDb.id = xilian.lastId
- haveDb.key = xilian.lastKey
- haveDb.value = xilian.lastValue
- xilian.lastId = nil
- xilian.lastKey = nil
- xilian.lastValue = nil
- else
- xilian.id = xilian.lastId
- xilian.key = xilian.lastKey
- xilian.value = xilian.lastValue
- xilian.lastId = nil
- xilian.lastKey = nil
- xilian.lastValue = nil
- end
-
- CG_MOSHOU_XILIAN_QUERY(human, index)
- xilianZDLUpdate(human)
- end
- function CG_MOSHOU_XILIAN_GIFT_QUERY(human)
- local msgRet = Msg.gc.GC_MOSHOU_XILIAN_GIFT_QUERY
- local absAct = YunYingLogic.onCallBack(human, "onQueryLongXue", nil, true)
- local len = 0
- for k, config in pairs(MoShouExcel.xiLianGift) do
- len = len + 1
- for j = 1, #config.reward do
- Grid.makeItem(msgRet.list[len].item[j], config.reward[j][1], config.reward[j][2])
- end
- local absCnt = 0
- if absAct and absAct ~= 0 and absAct[config.buyID] then
- absCnt = absAct[config.buyID].cnt or 0
- end
- local intCnt = getXilianInitDoubleCnt(human, config.buyID)
- local isInitDouble = isXilianInitDouble(human)
- local absMax = absAct and absAct[config.buyID] and absAct[config.buyID].max or 0
- local initMax = isInitDouble and config.frequency or 0
- msgRet.list[len].item[0] = #config.reward
- msgRet.list[len].cnt = absCnt + intCnt
- msgRet.list[len].id = k
- msgRet.list[len].maxCnt = absMax + initMax
- msgRet.list[len].icon = config.icon or 0
- msgRet.list[len].name = config.name or ""
- local buyID = config.buyID
- msgRet.list[len].buyMsg[0] = 0
- msgRet.list[len].needItem[0] = 0
- BuyLogic.fontBuyItem(human, msgRet.list[len].buyMsg[1], buyID)
- msgRet.list[len].buyMsg[0] = 1
- end
- msgRet.list[0] = len
- Msg.send(msgRet, human.fd)
- end
- function isXilianInitDouble(human)
- if human.db.moshou.xilian.initTime then
- local now = os.time()
- local endTime = human.db.moshou.xilian.initTime + 24 * 60 * 60 * 3
- if now <= endTime then
- return true
- end
- end
- end
- function getXilianInitDoubleCnt(human, buyID)
- if human.db.moshou.xilian.initTime then
- local max = MoShouExcel.xiLianGift[buyID].frequency
- local now = os.time()
- local endTime = human.db.moshou.xilian.initTime + 24 * 60 * 60 * 3
- if now <= endTime then
- human.db.moshou.xilian.giftBuy = human.db.moshou.xilian.giftBuy or {}
- local oldCnt = human.db.moshou.xilian.giftBuy[buyID] or 0
- if oldCnt < max then
- return max - oldCnt
- end
- end
- end
- return 0
- end
- function xlianGiftBuy(human, buyID)
- local isDouble = false
- local doubleBuyCnt = 0
- local absCnt = YunYingLogic.onCallBack(human, "onBuyLongXue", buyID, true)
-
- if absCnt then
- isDouble = true
- end
- if human.db.moshou.xilian.initTime and not isDouble then
- local intCnt = getXilianInitDoubleCnt(human, buyID)
- if intCnt > 0 then
- human.db.moshou.xilian.giftBuy[buyID] = human.db.moshou.xilian.giftBuy[buyID] or 0
- human.db.moshou.xilian.giftBuy[buyID] = human.db.moshou.xilian.giftBuy[buyID] + 1
- isDouble = true
- end
- end
- BagLogic.cleanMomentItemList()
- for k, config in pairs(MoShouExcel.xiLianGift) do
- if config and config.buyID == buyID then
- for _, item in ipairs(config.reward) do
- local itemCnt = item[2]
- if isDouble then
- itemCnt = itemCnt * 2
- end
- BagLogic.updateMomentItem(1, item[1], itemCnt)
- end
- BagLogic.addMomentItemList(human, "moshouXlGift")
- return
- end
- end
- end
- -- 获取魔兽 洗练中有几条传说属性
- function getXilianBestCnt(human)
- if not human.db.moshou or not human.db.moshou.xilian then
- return 0
- end
- local cnt = 0
- for _, db in ipairs(human.db.moshou.xilian) do
- local config = MoShouExcel.moshouXiLian[db.id]
- if config and config.isSS == 1 then
- cnt = cnt + 1
- end
- end
- return cnt
- end
- -- 魔兽可升级红点
- function moshouLVupRed(human)
- local nowLV = getMoshouLv(human)
- local config = MoShouExcel.moshouLv[nowLV + 1]
- if not config then return end
- local lvUpNeed = config.lvUpNeed
- local enough = nil
- for i = 1, #lvUpNeed do
- local itemID = lvUpNeed[i][1]
- local itemCnt = lvUpNeed[i][2]
- local now = BagLogic.getItemCnt(human, itemID)
- if now >= itemCnt then
- enough =(enough or 0) + 1
- end
- end
- if enough and enough >= #lvUpNeed then return true end
- end
- function moshouSkillUpRed(human)
- if not MoShouExcel.moshouActive[MOSHOU_ID1] then return end
- if not MOSHOU_SKILL[MOSHOU_ID1] then return end
- local moshouLV = getMoshouLv(human)
- local skillLV = getMoShouSkillLv(human)
- local config = MoShouExcel.moshouSkillLv
- if skillLV >= #config then return end
- local nextSkillLv = skillLV + 1
- if not MOSHOU_SKILL[MOSHOU_ID1][1][nextSkillLv] then return end
- local nowArgeCnt = nil
- local canUpNeedType = config[nextSkillLv].canUpNeed[1] or 0
- local canUpNeedValue = config[nextSkillLv].canUpNeed[2] or 0
- if canUpNeedType == MOSHOU_SKILLLV_ARGE1 then
- nowArgeCnt = moshouLV
- else
- return
- end
-
- if not nowArgeCnt then return end
- if nowArgeCnt < canUpNeedValue then return end
- local upCost = config[nextSkillLv].upCost
- for i = 1, #upCost do
- local itemID = upCost[i][1]
- local itemCnt = upCost[i][2]
- local nowCnt = BagLogic.getItemCnt(human, itemID)
- if nowCnt < itemCnt then
- return
- end
- end
- return true
- end
- -- 魔兽可精炼红点
- function moshouJinglianRed(human)
- local jingLianLV = getMoShouJiLian(human)
- local moshouLV = getMoshouLv(human)
- local jingLianMaxLV = #MoShouExcel.moshouJingLian
- if jingLianLV < jingLianMaxLV then
- local nextConfig = MoShouExcel.moshouJingLian[jingLianLV + 1]
- local lvUpNeed = nextConfig.lvUpNeed
- local enough = nil
- for i = 1, #lvUpNeed do
- local itemID = lvUpNeed[i][1]
- local itemCnt = lvUpNeed[i][2]
- local nowCnt = BagLogic.getItemCnt(human, itemID, itemCnt)
- if nowCnt >= itemCnt then
- enough =(enough or 0) + 1
- end
- end
- if enough and enough >= #lvUpNeed then return true end
- end
- end
- -- 魔兽可铸魂红点
- function moshouZhunHunRed(human)
- local moshouLV = getMoshouLv(human)
- local zhuHunCntMax = MoShouExcel.moshouLv[moshouLV].zhuHunCntMax
- local nowUseCnt = human.db.moshou and human.db.moshou.zhuHun or 0
- if nowUseCnt < zhuHunCntMax then
- local config = MoShouExcel.moshouZhuHun[1]
- local nowCnt = BagLogic.getItemCnt(human, config.costID)
- if nowCnt > 0 then return true end
- end
- end
- -- 魔兽洗练红点
- function moshouXilianUpRed(human)
- if human.db.moshou and human.db.moshou.xilian then
- local itemCnt = BagLogic.getItemCnt(human, ItemDefine.ITEM_LONGXUE_ID)
- for k, db in ipairs(human.db.moshou.xilian) do
- local config = MoShouExcel.moshouXiLian[db.id]
- if itemCnt >= config.need1 then
- return true
- end
- end
- end
- end
- function isDot(human)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then
- return ChengjiuLogic.isFinish(human, 402)
- end
- -- 魔兽可升级
- if moshouLVupRed(human) then return true end
- -- 魔兽可精炼
- if moshouJinglianRed(human) then return true end
- -- 魔兽可铸魂
- if moshouZhunHunRed(human) then return true end
- -- 技能可升级
- if moshouSkillUpRed(human) then return true end
- end
- ------------------------------外部接口相关-----------------------------------------
- -- 创建魔兽结构体
- function createCombatMoshow(human, combatType)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- local id = CombatPosLogic.getCombatMoshou(human, combatType)
- if not id or id < 1 then return end
-
- if not MOSHOU_SKILL[MOSHOU_ID1][id] then return end
- local config = MoShouExcel.moshouActive[MOSHOU_ID1]
- local pet = { }
- pet.isPet = true
- pet.petID = MOSHOU_ID1
- pet.id = id
- pet.lv = getMoshouLv(human)
-
- pet.body = config.body
- pet.jinglianLV = getMoShouJiLian(human)
- pet.zhuHun = getMoShouZhuHunNum(human)
- pet.skillLV = getMoShouSkillLv(human)
- if human.db.moshou and human.db.moshou.lvAttrsAdd then
- pet.lvAttrsAdd = Util.copyTable(human.db.moshou.lvAttrsAdd)
-
- local lvAttrMul = getLvAttrMulFromTalisman(human)
- lvAttrMul = 1 + lvAttrMul
- for attrId, attrVal in pairs(pet.lvAttrsAdd) do
- pet.lvAttrsAdd[attrId] = attrVal * lvAttrMul
- end
- else
- pet.lvAttrsAdd = {}
- end
- if MOSHOU_SKILL[MOSHOU_ID1][id][pet.skillLV] then
- local skillID = MOSHOU_SKILL[1][id][pet.skillLV]
- local skillConfig = SkillExcel.skill[skillID]
- local cd1 = skillConfig.cd[1] or 0
- local cd2 = skillConfig.cd[2] or 0
- pet.icon = skillID
- pet.skillList = { }
- pet.skillList[1] = { skillID, cd1, cd2 }
- pet.cd = cd2
- end
- return pet
- end
- -- 获取出战魔兽的skillID
- function getPutMoshouSkillID(human, combatType)
- local putOnMoshou = CombatPosLogic.getCombatMoshou(human, combatType)
- if not putOnMoshou or putOnMoshou < 1 then return end
- if not MOSHOU_SKILL[MOSHOU_ID1][putOnMoshou] then return end
- local skillLV = getMoShouSkillLv(human)
- local skillID = MOSHOU_SKILL[MOSHOU_ID1][putOnMoshou][skillLV]
- return skillID
- end
- -- 获取出战魔兽形象
- function getCombatMoshouBody(human, combatType)
- local id = CombatPosLogic.getCombatMoshou(human, combatType)
- if not id or id < 1 then return 0 end
- local config = MoShouExcel.moshouActive[MOSHOU_ID1]
- return config and config.body or 0
- end
-
- -- 获取魔兽等级
- function getMoshouLv(human)
- if human.db.moshou and human.db.moshou.lv then
- return human.db.moshou.lv
- end
- return 1
- end
- -- 获取精炼等级
- function getMoShouJiLian(human)
- return human.db.moshou and human.db.moshou.jingLian or 0
- end
- -- 获取技能等级
- function getMoShouSkillLv(human)
- if human.db.moshou and human.db.moshou.skillLV then
- return human.db.moshou.skillLV
- end
- return 1
- end
- -- 获取铸魂数
- function getMoShouZhuHunNum(human)
- return human.db.moshou and human.db.moshou.zhuHun or 0
- end
- -- 出战界面
- function setHelp(net, moshouID)
- net.type = CombatDefine.HELP_TYPE1
- net.id = moshouID
- net.icon = MoShouExcel.moshouActive[MOSHOU_ID1].icon
- end
- function setPosHelp(net, moshouID)
- net.type = CombatDefine.HELP_TYPE1
- net.id = moshouID
- net.icon = MoShouExcel.moshouActive[MOSHOU_ID1].icon
- end
- -- 战斗阵容封装
- function setCombatHelp(net, moshouObj, pos)
- net.pos = pos
- net.id = moshouObj.petID
- net.head = moshouObj.head
- net.body = moshouObj.body
- net.args[0] = 0
- end
- --
- function setSkillAndBeskill(human, combatInfo)
- for atkPos, atkObj in pairs(CombatImpl.helpList) do
- local skill = human.db.moshou.putOnMoshou
- if atkObj.side == CombatDefine.ATTACK_SIDE and skill then
- atkObj.skillList = {skill}
- atkObj.beSkillList = {}
- end
- --print("===============", atkPos, skill and skill.skillList, skill and skill.beSkillList)
- end
- end
|