| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463 |
- -- 魔兽 --
- 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, moshowIdArr)
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
- if not cjPrivilege then return end
- local id
- if combatType == CombatDefine.COMBAT_TYPE35 and moshowIdArr then
- id = moshowIdArr[1]
- else
- id = CombatPosLogic.getCombatMoshou(human, combatType)
- end
- 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, helpList)
- local putOnMoshou
- if combatType == CombatDefine.COMBAT_TYPE36 and helpList then
- putOnMoshou = helpList[1]
- else
- putOnMoshou = CombatPosLogic.getCombatMoshou(human, combatType)
- end
- 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
|