BattleLogic.lua 130 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440
  1. local Lang = require("common.Lang")
  2. local BattleExcel = require("excel.battle")
  3. local BattleExcel_Elite = require("excel.battle_elite")
  4. local BattleExcel_Hard = require("excel.battle_hard")
  5. local MonsterExcel = require("excel.monster")
  6. local DropExcel = require("excel.drop")
  7. local Msg = require("core.Msg")
  8. local ObjHuman = require("core.ObjHuman")
  9. local Grid = require("bag.Grid")
  10. local BagLogic = require("bag.BagLogic")
  11. local ItemDefine = require("bag.ItemDefine")
  12. local Broadcast = require("broadcast.Broadcast")
  13. local CombatDefine = require("combat.CombatDefine")
  14. local CombatPosLogic = require("combat.CombatPosLogic")
  15. local CombatLogic = require("combat.CombatLogic")
  16. local DailyTaskLogic = require("dailyTask.DailyTaskLogic")
  17. local RoleDefine = require("role.RoleDefine")
  18. local ChengjiuLogic = require("chengjiu.ChengjiuLogic")
  19. local ChengjiuDefine = require("chengjiu.ChengjiuDefine")
  20. local HeroExcel = require("excel.hero")
  21. local SkillExcel = require("excel.skill")
  22. local MonthactExcel = require("excel.monthAct")
  23. local Util = require("common.Util")
  24. local KingWorldLogic = require("present.KingWorldLogic")
  25. local ChatPaoMaLogic = require("chat.ChatPaoMaLogic")
  26. local BRoleLogic = require("billboard.BRoleLogic")
  27. local BillboardDefine = require("billboard.BillboardDefine")
  28. local SkinLogic = require("skin.SkinLogic")
  29. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  30. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  31. local GuideLogic = require("guide.GuideLogic")
  32. local PanelDefine = require("broadcast.PanelDefine")
  33. local HeroGrid = require("hero.HeroGrid")
  34. local TuiSongLiBao = require("present.TuiSongLiBao")
  35. local CombatVideo = require("combat.CombatVideo")
  36. local RoleLogic = require("role.RoleLogic")
  37. local BattleDBLogic = require("battle.BattleDBLogic")
  38. local ProjectLogic = require("platform.ProjectLogic")
  39. local LuaMongo = _G.lua_mongo
  40. local DB = require("common.DB")
  41. local VipLogic = require("vip.VipLogic")
  42. local MoshouLogic = require("moshou.MoshouLogic")
  43. local RoleExcel = require("excel.role")
  44. local TequanShopLogic = require("present.TequanShopLogic")
  45. local HeroDefine = require("hero.HeroDefine")
  46. local BarTaskLogic = require("bar.BarTaskLogic")
  47. local ItemExcel = require("excel.item").item
  48. local EquipExcel = require("excel.equip").equip
  49. local HeroLogic = require("hero.HeroLogic")
  50. local SuipianLogic = require("bag.SuipianLogic")
  51. local JibanLogic = require("combat.JibanLogic")
  52. local YunYingLogic = require("yunying.YunYingLogic")
  53. local PanelDefine = require("broadcast.PanelDefine")
  54. local YyHandler = require("yunying.Handler")
  55. local EquipLogic = require("equip.EquipLogic")
  56. local SysParameter = require("common.SysParameter")
  57. local XingYaoGongMing = require("xingYaoMen.XingYaoGongMing")
  58. local AbsActLogic = require("absAct.AbsActLogic")
  59. local HeroLogLogic = require("absAct.HeroLogLogic")
  60. local DropExchangeLogic = require("absAct.DropExchangeLogic")
  61. local MengxinLogic = require("present.MengxinLogic")
  62. local GiftLogic = require("topup.GiftLogic")
  63. local WarOrder = require("shop.WarOrder")
  64. local Log = require("common.Log")
  65. local EliteDefine = require("battle.EliteDefine")
  66. BATTLE_HANG_EXP_OUT_PERIOD = 60 -- 经验产出时间间隔
  67. BATTLE_HANG_ITEM_OUT_PERIOD = 300 -- 战利品道具产出时间间隔
  68. BATTLE_HANG_ITEM_OUT_PERIOD_2 = 7200 -- 战利品道具产出时间间隔2小时掉落一次
  69. BATTLE_LOGIN_LEV_TIPS = 50 -- 登录检测挂机时间过久提示 最高等级
  70. BATTLE_LOGIN_TIME_TIPS = 10 * 60 -- 登录检测挂机超过多久提示
  71. BATTLE_MOPUP_CNT = 4
  72. BATTLE_MOPUP_CNT_VIP = 11
  73. BATTLE_MOPUP_FREE_CNT = 1
  74. BATTLE_MOPUP_FREE_CNT_VIP = 3
  75. BATTLE_LEVEL_PLAYER_LIST = { }
  76. local STATUS_NONE = 1 -- 不可领
  77. local STATUS_CANGET = 2 -- 可领
  78. local DIAMOND_COST_PER_HOUR = 20
  79. local HOUR_SEC = 60 * 60
  80. local DIAMOND_ADDITION = 1.5
  81. -- @mafei 是否需要集中定义一个define 枚举
  82. local PRINCIPAL_LINE_EVNET = 1
  83. local BATTLE_ORDER_TYPE = 1
  84. -- 挂机收益最多累计x秒
  85. function getHangMaxTime(human)
  86. local hour = VipLogic.getPowerArgs(human, VipLogic.VIP_POWER10)
  87. return(hour or 0) * 3600
  88. end
  89. local function wrapHangFightNet(net, heroConfig, skillConfig)
  90. net.body = heroConfig.body
  91. net.height = heroConfig.height
  92. net.weight = heroConfig.width
  93. net.fireType = skillConfig and skillConfig.fireType or 0
  94. net.attackEffect = skillConfig and skillConfig.attackEffect or ""
  95. net.flyEffect = skillConfig and skillConfig.flyEffect or ""
  96. net.flyCoords = skillConfig and skillConfig.flyCoords or ""
  97. net.hitEffect = skillConfig and skillConfig.hitEffect or ""
  98. net.hitSound = skillConfig and skillConfig.hitSound or ""
  99. end
  100. local function fontBattleSkillNet(skillNet, skillID)
  101. local skillConfig = SkillExcel.skill[skillID]
  102. if not skillConfig then
  103. return
  104. end
  105. skillNet.skillID = skillID
  106. skillNet.fireType = skillConfig.fireType
  107. skillNet.readyAction = skillConfig.readyAction
  108. skillNet.attackPart = skillConfig.attackPart
  109. skillNet.attackAction = skillConfig.attackAction
  110. skillNet.readyEffect = skillConfig.readyEffect
  111. skillNet.attackEffect = skillConfig.attackEffect
  112. skillNet.hitEffect = skillConfig.hitEffect
  113. skillNet.flyEffect = skillConfig.flyEffect
  114. skillNet.flyCoords = skillConfig.flyCoords
  115. skillNet.hitBack = skillConfig.hitBack
  116. skillNet.effectTime = skillConfig.effectTime
  117. skillNet.contentType = skillConfig.contentType
  118. skillNet.content = skillConfig.content
  119. skillNet.movieEffect = skillConfig.movieEffect
  120. skillNet.quake = skillConfig.quake
  121. skillNet.flySound = skillConfig.flySound
  122. skillNet.fireSound = skillConfig.fireSound
  123. skillNet.hitSound = skillConfig.hitSound
  124. skillNet.cvSound = skillConfig.cvSound
  125. skillNet.screenMask = skillConfig.screenMask
  126. skillNet.screenCam = skillConfig.screenCam
  127. skillNet.largeEffect = skillConfig.largeEffect
  128. skillNet.lie = skillConfig.lie
  129. skillNet.cuoZhen = skillConfig.cuoZhen
  130. skillNet.skillDelay = skillConfig.skillDelay
  131. skillNet.isFraming = skillConfig.isFraming
  132. return true
  133. end
  134. -- 获取当前战役类型
  135. local function BattleLogic_GetBattleType(human)
  136. if not human then
  137. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleType human is null")
  138. return EliteDefine.COPY_ELITE_ERROR
  139. end
  140. return human.db.battleType
  141. end
  142. -- 设置当前战役类型
  143. local function BattleLogic_SetBattleType(human, nBattleType)
  144. if not human or EliteDefine.COPY_ELITE_NORMAL > nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  145. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_SetBattleType 参数不正确!!!")
  146. return false
  147. end
  148. human.db.battleType = nBattleType
  149. print("[BattleLogic_SetBattleType] 玩家设置战役类型成功 id = "
  150. ..human.db._id.." nBattleType1 = "..nBattleType.." nBattleType2 = "..human.db.battleType)
  151. return true
  152. end
  153. -- 获取战役即将战斗id
  154. local function BattleLogic_GetBattleBattleID(human)
  155. if not human then
  156. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[BattleLogic_GetBattleBattleID] human is null")
  157. return -1
  158. end
  159. local nBattleType = BattleLogic_GetBattleType(human)
  160. --print("[BattleLogic_GetBattleBattleID] 获取到的战斗类型信息 id = "..human.db._id.." nBattleType = "..nBattleType)
  161. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  162. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleBattleID 获取到的战斗类型不正确 id = "
  163. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  164. return -1
  165. end
  166. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  167. return human.db.battleID
  168. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  169. return human.db.battleID_elite
  170. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  171. return human.db.battleID_hard
  172. else
  173. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleBattleID 未处理的战斗类型 id = "
  174. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  175. return -1
  176. end
  177. end
  178. -- 根据类型获取战斗ID
  179. local function BattleLogic_GetBattleIDByType(human, nBattleType)
  180. if not human or EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  181. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleIDByType 传入的参数不正确 id = "
  182. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  183. return -1
  184. end
  185. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  186. return human.db.battleID
  187. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  188. return human.db.battleID_elite
  189. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  190. return human.db.battleID_hard
  191. end
  192. return -1
  193. end
  194. -- 设置 战役即将战斗id
  195. local function BattleLogic_SetBattleBattleID(human, nValue)
  196. if not human or 0 > nValue then
  197. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_SetBattleBattleID 参数不正确")
  198. return false
  199. end
  200. local nBattleType = BattleLogic_GetBattleType(human)
  201. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  202. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_SetBattleBattleID 获取到的战斗类型不正确 id = "
  203. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  204. return false
  205. end
  206. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  207. human.db.battleID = nValue
  208. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  209. human.db.battleID_elite = nValue
  210. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  211. human.db.battleID_hard = nValue
  212. else
  213. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiID 未处理的战斗类型 id = "
  214. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  215. return false
  216. end
  217. return true
  218. end
  219. -- 获取当前战役 已通关关卡/挂机关卡
  220. local function BattleLogic_GetBattleGuaJiID(human)
  221. if not human then
  222. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiID human is null")
  223. return -1
  224. end
  225. local nBattleType = BattleLogic_GetBattleType(human)
  226. print("[BattleLogic_GetBattleGuaJiID] 获取到的战斗类型信息 id = "..human.db._id.." nBattleType = "..nBattleType)
  227. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  228. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiID 获取到的战斗类型不正确 id = "
  229. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  230. return -1
  231. end
  232. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  233. return human.db.guajiID
  234. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  235. return human.db.guajiID_elite
  236. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  237. return human.db.guajiID_hard
  238. else
  239. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiID 未处理的战斗类型 id = "
  240. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  241. return -1
  242. end
  243. end
  244. -- 通过战斗类型获取当前战役 已通关关卡/挂机关卡
  245. local function BattleLogic_GetBattleGuaJiIDByType(human, nBattleType)
  246. if not human or EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  247. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiIDByType 传入的参数不正确 id = "
  248. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  249. return -1
  250. end
  251. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  252. return human.db.guajiID
  253. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  254. return human.db.guajiID_elite
  255. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  256. return human.db.guajiID_hard
  257. else
  258. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiIDByType 未处理的战斗类型 id = "
  259. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  260. return -1
  261. end
  262. end
  263. -- 设置当前战役 已通关关卡/挂机关卡
  264. local function BattleLogic_SetBattleGuaJiID(human, nValue)
  265. if not human or 0 > nValue then
  266. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_SetBattleGuaJiID 参数不正确")
  267. return false
  268. end
  269. local nBattleType = BattleLogic_GetBattleType(human)
  270. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  271. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_SetBattleGuaJiID 获取到的战斗类型不正确 id = "
  272. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  273. return false
  274. end
  275. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  276. human.db.guajiID = nValue
  277. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  278. human.db.guajiID_elite = nValue
  279. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  280. human.db.guajiID_hard = nValue
  281. else
  282. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiID 未处理的战斗类型 id = "
  283. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  284. return false
  285. end
  286. return true
  287. end
  288. -- 获取奖励信息
  289. local function BattleLogic_GetBattleRewards(human)
  290. if not human then
  291. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 参数不正确")
  292. return nil
  293. end
  294. local nBattleType = BattleLogic_GetBattleType(human)
  295. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  296. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 获取到的战斗类型不正确 id = "
  297. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  298. return nil
  299. end
  300. local tRewards = nil
  301. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  302. if not human.db.battleRewards then
  303. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 玩家普通奖励未初始化进行初始化 id = "
  304. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  305. human.db.battleRewards = {}
  306. end
  307. tRewards = human.db.battleRewards
  308. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  309. if not human.db.battleRewards_elite then
  310. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 玩家精英奖励未初始化进行初始化 id = "
  311. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  312. human.db.battleRewards_elite = {}
  313. end
  314. tRewards = human.db.battleRewards_elite
  315. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  316. if not human.db.battleRewards_hard then
  317. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 玩家困难奖励未初始化进行初始化 id = "
  318. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  319. human.db.battleRewards_hard = {}
  320. end
  321. tRewards = human.db.battleRewards_hard
  322. else
  323. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 未处理的战斗类型 id = "
  324. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  325. end
  326. return tRewards
  327. end
  328. -- 根据类型获取奖励信息
  329. local function BattleLogic_GetBattleRewardsByType(human, nBattleType)
  330. if not human or EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  331. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[BattleLogic_GetBattleRewardsByType] 参数不正确")
  332. return nil
  333. end
  334. local tRewards = nil
  335. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  336. if not human.db.battleRewards then
  337. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[BattleLogic_GetBattleRewardsByType] 玩家普通奖励未初始化进行初始化 id = "
  338. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  339. human.db.battleRewards = {}
  340. end
  341. --print("[BattleLogic_GetBattleRewardsByType] 返回普通奖励表")
  342. tRewards = human.db.battleRewards
  343. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  344. if not human.db.battleRewards_elite then
  345. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[BattleLogic_GetBattleRewardsByType] 玩家精英奖励未初始化进行初始化 id = "
  346. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  347. human.db.battleRewards_elite = {}
  348. end
  349. --print("[BattleLogic_GetBattleRewardsByType] 返回精英奖励表")
  350. tRewards = human.db.battleRewards_elite
  351. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  352. if not human.db.battleRewards_hard then
  353. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[BattleLogic_GetBattleRewardsByType] 玩家困难奖励未初始化进行初始化 id = "
  354. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  355. human.db.battleRewards_hard = {}
  356. end
  357. --print("[BattleLogic_GetBattleRewardsByType] 返回困难奖励表")
  358. tRewards = human.db.battleRewards_hard
  359. else
  360. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[BattleLogic_GetBattleRewardsByType] 未处理的战斗类型 id = "
  361. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  362. end
  363. return tRewards
  364. end
  365. local WeiLen = 30
  366. -- 设置奖励信息
  367. local function BattleLogic_SetBattleRewards(human, id)
  368. if not human or 0 >= id then
  369. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_SetBattleRewards 参数不正确")
  370. return false
  371. end
  372. local tRewards = BattleLogic_GetBattleRewards(human)
  373. if not tRewards then
  374. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_SetBattleRewards 获取到的奖励为空 id = "
  375. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  376. return false
  377. end
  378. local intIndex = math.ceil(id / WeiLen)
  379. local byteIndex = id % WeiLen
  380. tRewards[intIndex] = tRewards[intIndex] or 0
  381. tRewards[intIndex] = Util.setBit(tRewards[intIndex], byteIndex)
  382. return true
  383. end
  384. -- 获取挂机奖励表
  385. local function BattleLogic_GetBattleOut(human)
  386. if not human then
  387. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleOut 参数不正确")
  388. return nil
  389. end
  390. local nBattleType = BattleLogic_GetBattleType(human)
  391. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  392. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleOut 获取到的战斗类型不正确 id = "
  393. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  394. return nil
  395. end
  396. return human.db.battleOut
  397. -- if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  398. -- -- if not human.db.battleRewards then
  399. -- -- Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 玩家普通奖励未初始化进行初始化 id = "
  400. -- -- ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  401. -- -- human.db.battleOut = {}
  402. -- -- end
  403. -- tRewards = human.db.battleOut
  404. -- elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  405. -- -- if not human.db.battleRewards_elite then
  406. -- -- Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 玩家精英奖励未初始化进行初始化 id = "
  407. -- -- ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  408. -- -- human.db.battleRewards_elite = {}
  409. -- -- end
  410. -- tRewards = human.db.battleOut_elite
  411. -- elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  412. -- -- if not human.db.battleRewards_hard then
  413. -- -- Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 玩家困难奖励未初始化进行初始化 id = "
  414. -- -- ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  415. -- -- human.db.battleRewards_hard = {}
  416. -- -- end
  417. -- tRewards = human.db.battleOut_hard
  418. -- else
  419. -- Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleOut 未处理的战斗类型 id = "
  420. -- ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  421. -- end
  422. end
  423. function BattleLogic_InitOneBattleOut(human, now)
  424. human.db.battleOut = { }
  425. human.db.battleOut.expTs1 = now
  426. -- 经验开始产出时间戳
  427. human.db.battleOut.expTs2 = now
  428. -- 经验产出结算时间戳
  429. human.db.battleOut.itemTs1 = now
  430. -- 道具产出时间戳
  431. human.db.battleOut.itemTs2 = now
  432. -- 道具产出结算时间戳
  433. human.db.battleOut.exp = 0
  434. human.db.battleOut.jinbi = 0
  435. human.db.battleOut.greenExp = 0
  436. human.db.battleOut.qingbao = 0
  437. human.db.battleOut.items = nil
  438. -- 产出的待收获的战利品
  439. human.db.battleOut.equip = nil
  440. -- 产出的待收获的装备
  441. return true
  442. end
  443. -- 初始化所有挂机奖励领取列表
  444. local function BattleLogic_InitAllBattleOut(human, now)
  445. if not human then
  446. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_InitAllBattleOut 参数不正确")
  447. return false
  448. end
  449. if not human.db.battleOut then
  450. BattleLogic_InitOneBattleOut(human, now)
  451. end
  452. -- if not human.db.battleOut_elite then
  453. -- human.db.battleOut_elite = {}
  454. -- BattleLogic_InitOneBattleOut(human.db.battleOut_elite, now)
  455. -- end
  456. -- if not human.db.battleOut_hard then
  457. -- human.db.battleOut_hard = {}
  458. -- BattleLogic_InitOneBattleOut(human.db.battleOut_hard, now)
  459. -- end
  460. return true
  461. end
  462. -- 获取配置信息
  463. local function BattleLogic_GetBattleConfig(human)
  464. if not human then
  465. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleConfig 参数不正确")
  466. return nil
  467. end
  468. local nBattleType = BattleLogic_GetBattleType(human)
  469. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  470. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleConfig 获取到的战斗类型不正确 id = "
  471. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  472. return nil
  473. end
  474. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  475. return BattleExcel
  476. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  477. return BattleExcel_Elite
  478. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  479. return BattleExcel_Hard
  480. else
  481. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleGuaJiID 未处理的战斗类型 id = "
  482. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  483. return nil
  484. end
  485. end
  486. -- 根据战斗类型获取配置
  487. local function BattleLogic_GetBattleConfigByType(nBattleType)
  488. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  489. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleConfigByType 参数不正确")
  490. return nil
  491. end
  492. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  493. return BattleExcel
  494. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  495. return BattleExcel_Elite
  496. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  497. return BattleExcel_Hard
  498. end
  499. return nil
  500. end
  501. -- 获取章节奖励
  502. local function BattleLogic_GetChapterReward(human)
  503. if not human then
  504. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetChapterReward 参数不正确")
  505. return nil
  506. end
  507. local nBattleType = BattleLogic_GetBattleType(human)
  508. print("[BattleLogic_GetChapterReward] nBattleType = "..nBattleType)
  509. if EliteDefine.COPY_ELITE_ERROR >= nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  510. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetChapterReward 获取到的战斗类型不正确 id = "
  511. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  512. return nil
  513. end
  514. if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  515. if not human.db.chapterReward then
  516. human.db.chapterReward = {}
  517. end
  518. return human.db.chapterReward
  519. elseif EliteDefine.COPY_LEVEL_ELITE == nBattleType then
  520. if not human.db.chapterReward_Elite then
  521. human.db.chapterReward_Elite = {}
  522. end
  523. return human.db.chapterReward_Elite
  524. elseif EliteDefine.COPY_ELITE_DIFFICULTY == nBattleType then
  525. if not human.db.chapterReward_Hard then
  526. human.db.chapterReward_Hard = {}
  527. end
  528. return human.db.chapterReward_Hard
  529. else
  530. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetChapterReward 未处理的战斗类型 id = "
  531. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name.." nBattleType = "..nBattleType)
  532. return nil
  533. end
  534. end
  535. -- 查询难度
  536. local function BattleLogic_QueryDifficulty(human)
  537. local nNowBattleType = BattleLogic_GetBattleType(human)
  538. if EliteDefine.COPY_ELITE_ERROR >= nNowBattleType then
  539. print("[BattleLogic_QueryDifficulty] 查询难度获取到的战斗ID数值、战斗类型不正确 id = "
  540. ..human.db._id.." nNowBattleType = "..nNowBattleType)
  541. return
  542. end
  543. local msgRet = Msg.gc.GC_ELITE_OPEN
  544. msgRet.curCopyType = nNowBattleType
  545. msgRet.copyOpenType[0]=0
  546. --精英副本开启, 普通关卡符合条件
  547. local nBattleID = human.db.battleID
  548. local nIndex = EliteDefine.COPY_LEVEL_ELITE - 1
  549. if human.db.lv >= EliteDefine.COPY_ELITE_ULEV and
  550. nBattleID > EliteDefine.COPY_ELITE_LEVEL then
  551. msgRet.copyOpenType[0] = msgRet.copyOpenType[0]+1
  552. msgRet.copyOpenType[nIndex] = 1
  553. else
  554. msgRet.copyOpenType[0] = msgRet.copyOpenType[0]+1
  555. msgRet.copyOpenType[nIndex] = 0
  556. end
  557. --困难副本开启,精英关卡符合条件
  558. local nBattleIDElite = human.db.battleID_elite
  559. nIndex = EliteDefine.COPY_ELITE_DIFFICULTY - 1
  560. if human.db.lv >= EliteDefine.COPY_ELITE_ULEV and
  561. nBattleIDElite > EliteDefine.COPY_ELITE_LEVEL then
  562. msgRet.copyOpenType[0] = msgRet.copyOpenType[0]+1
  563. msgRet.copyOpenType[nIndex] = 1
  564. else
  565. msgRet.copyOpenType[0] = msgRet.copyOpenType[0]+1
  566. msgRet.copyOpenType[nIndex] = 0
  567. end
  568. Msg.send(msgRet,human.fd)
  569. local info=Util.printTable(msgRet)
  570. print(info)
  571. end
  572. function getBattleRoleList(nBattleType, worldMapId)
  573. if not BATTLE_LEVEL_PLAYER_LIST then
  574. BATTLE_LEVEL_PLAYER_LIST = {}
  575. end
  576. if not BATTLE_LEVEL_PLAYER_LIST[nBattleType] then
  577. BATTLE_LEVEL_PLAYER_LIST[nBattleType] = {}
  578. end
  579. BATTLE_LEVEL_PLAYER_LIST[nBattleType][worldMapId] = BATTLE_LEVEL_PLAYER_LIST[nBattleType][worldMapId] or { }
  580. local tBattleConfig = BattleLogic_GetBattleConfigByType(nBattleType)
  581. if not tBattleConfig then
  582. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getBattleRoleList] 获取不到对应的配置 nBattleType = "
  583. ..nBattleType.." worldMapId ="..worldMapId)
  584. print("[getBattleRoleList] 获取配置失败")
  585. return
  586. end
  587. -- local config = BattleExcel.map[worldMapId]
  588. local config = tBattleConfig.map[worldMapId]
  589. QueryRoleByNodeID = { guajiID = { ["$gte"] = config.minLevel, ["$lte"] = config.maxLevel }, nBattleType = nBattleType}
  590. local fields = { }
  591. RoleLogic.makeRoleBaseFields(fields)
  592. LuaMongo.find(DB.db_char, QueryRoleByNodeID, fields, 50)
  593. local len = 0
  594. while true do
  595. local charDb = { }
  596. if not LuaMongo.next(charDb) then
  597. break
  598. end
  599. len = len + 1
  600. BATTLE_LEVEL_PLAYER_LIST[nBattleType][worldMapId][charDb._id] = { }
  601. RoleLogic.makeRoleBase(charDb, BATTLE_LEVEL_PLAYER_LIST[nBattleType][worldMapId][charDb._id])
  602. if len >= 50 then
  603. return
  604. end
  605. end
  606. end
  607. function initAfterStart()
  608. local len = #BattleExcel.map
  609. for i = 1, len do
  610. getBattleRoleList(EliteDefine.COPY_ELITE_NORMAL, i)
  611. end
  612. len = #BattleExcel_Elite.map
  613. for i = 1, len do
  614. getBattleRoleList(EliteDefine.COPY_LEVEL_ELITE, i)
  615. end
  616. len = #BattleExcel_Hard.map
  617. for i = 1, len do
  618. getBattleRoleList(EliteDefine.COPY_ELITE_DIFFICULTY, i)
  619. end
  620. end
  621. function onLogin(human)
  622. if human.db.lv >= BATTLE_LOGIN_LEV_TIPS then
  623. return
  624. end
  625. calcBattleOut(human)
  626. local now = os.time()
  627. -- local expTime = now - human.db.battleOut.expTs1
  628. local tBattleOut = BattleLogic_GetBattleOut(human)
  629. if tBattleOut then
  630. local expTime = now - tBattleOut.expTs1
  631. if expTime >= BATTLE_LOGIN_TIME_TIPS then
  632. local msgRet = Msg.gc.GC_BATTLE_HANG_TIME_SPILL
  633. msgRet.time = expTime
  634. Msg.send(msgRet, human.fd)
  635. end
  636. else
  637. print("[BattleLogic_onLogin] 获取不到奖励数据 id = "
  638. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  639. end
  640. end
  641. -- 是否领取
  642. -- local WeiLen = 30
  643. function isGetReward(human, id)
  644. local flags = BattleLogic_GetBattleRewards(human)
  645. if not flags then
  646. return false
  647. end
  648. -- if not human.db.battleRewards then
  649. -- return
  650. -- end
  651. --local flags = human.db.battleRewards
  652. local intIndex = math.ceil(id / WeiLen)
  653. if not flags[intIndex] then
  654. return
  655. end
  656. local byteIndex = id % WeiLen
  657. if Util.getBit(flags[intIndex], byteIndex) > 0 then
  658. return true
  659. end
  660. end
  661. -- 通过类型获取奖励 判断是否领取
  662. function isGetRewardByType(human, id, nBattleType)
  663. local flags = BattleLogic_GetBattleRewardsByType(human, nBattleType)
  664. if not flags then
  665. print("[isGetRewardByType] 获取不到对应的奖励表 id = "..human.db._id .. " nBattleType = "..nBattleType)
  666. return false
  667. end
  668. local intIndex = math.ceil(id / WeiLen)
  669. if not flags[intIndex] then
  670. print("[isGetRewardByType] 没有对对应的ID领取奖励 intIndex id = "..id .. " nBattleType = "..nBattleType)
  671. return false
  672. end
  673. local byteIndex = id % WeiLen
  674. -- if Util.getBit(flags[intIndex], byteIndex) > 0 then
  675. -- return true
  676. -- end
  677. local nBit = Util.getBit(flags[intIndex], byteIndex)
  678. -- print("[isGetRewardByType] nBit = ".. nBit)
  679. return Util.getBit(flags[intIndex], byteIndex) > 0 and true or false
  680. end
  681. function getTongguanIndex(human)
  682. local tBattleRewards = BattleLogic_GetBattleRewards(human)
  683. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  684. if not tBattleRewards or not tBattleConfig then
  685. return 1
  686. end
  687. --local flags = human.db.battleRewards
  688. -- for id, v in ipairs(BattleExcel.node) do
  689. for id, v in ipairs(tBattleConfig.node) do
  690. if #v.tongguan ~= 0 then
  691. local intIndex = math.ceil(id / WeiLen)
  692. -- if not flags[intIndex] then
  693. if not tBattleRewards[intIndex] then
  694. return id
  695. end
  696. local byteIndex = id % WeiLen
  697. -- if Util.getBit(flags[intIndex], byteIndex) == 0 then
  698. if Util.getBit(tBattleRewards[intIndex], byteIndex) == 0 then
  699. return id
  700. end
  701. end
  702. end
  703. return
  704. end
  705. -- 设置领取
  706. function setGetReward(human, id)
  707. local tBattleRewards = BattleLogic_GetBattleRewards(human)
  708. if not tBattleRewards then
  709. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 参数不正确")
  710. print("[setGetReward] 不存在对应的 奖励配置")
  711. return
  712. end
  713. -- if not human.db.battleRewards then
  714. -- human.db.battleRewards = { }
  715. -- end
  716. -- local flags = human.db.battleRewards
  717. local intIndex = math.ceil(id / WeiLen)
  718. local byteIndex = id % WeiLen
  719. tBattleRewards[intIndex] = tBattleRewards[intIndex] or 0
  720. tBattleRewards[intIndex] = Util.setBit(tBattleRewards[intIndex], byteIndex)
  721. end
  722. -- 是否有可领取的
  723. function hasCanGetReward(human)
  724. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  725. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  726. if not tBattleConfig or -1 >= nGuaJiID then
  727. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 参数不正确")
  728. print("[hasCanGetReward] 不存在对应的 奖励配置")
  729. return
  730. end
  731. for id, cf in ipairs(tBattleConfig.node) do
  732. if id > nGuaJiID then
  733. break
  734. end
  735. if #cf.tongguan > 0 and not isGetReward(human, id) then
  736. return true
  737. end
  738. end
  739. end
  740. local BATTLEID_2_NAME = nil
  741. function getBattleName(human, battleID)
  742. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  743. local nBattleType = BattleLogic_GetBattleType(human)
  744. if not tBattleConfig or EliteDefine.COPY_ELITE_ERROR >= nBattleType then
  745. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 参数不正确")
  746. print("[getBattleName] 不存在对应的 奖励配置")
  747. return
  748. end
  749. if not BATTLEID_2_NAME then
  750. BATTLEID_2_NAME = { }
  751. end
  752. if not BATTLEID_2_NAME[nBattleType] then
  753. BATTLEID_2_NAME[nBattleType] = {}
  754. for id, cf in ipairs(tBattleConfig.node) do
  755. -- BATTLEID_2_NAME[id] = cf.name
  756. BATTLEID_2_NAME[nBattleType][id] = cf.name
  757. end
  758. end
  759. local nodeConfig = tBattleConfig.node[battleID]
  760. local mapConfig = nodeConfig and tBattleConfig.map[nodeConfig.mapID]
  761. local mapName = mapConfig and mapConfig.name or ""
  762. return BATTLEID_2_NAME[nBattleType][battleID] or "", mapName
  763. end
  764. function getBattleNameByType(battleID, nBattleType)
  765. local tBattleConfig = BattleLogic_GetBattleConfigByType( nBattleType)
  766. if not tBattleConfig or EliteDefine.COPY_ELITE_ERROR >= nBattleType then
  767. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 参数不正确")
  768. print("[getBattleNameByType] 不存在对应的 奖励配置")
  769. return
  770. end
  771. if not BATTLEID_2_NAME then
  772. BATTLEID_2_NAME = { }
  773. end
  774. if not BATTLEID_2_NAME[nBattleType] then
  775. BATTLEID_2_NAME[nBattleType] = {}
  776. for id, cf in ipairs(tBattleConfig.node) do
  777. -- BATTLEID_2_NAME[id] = cf.name
  778. BATTLEID_2_NAME[nBattleType][id] = cf.name
  779. end
  780. end
  781. local nodeConfig = tBattleConfig.node[battleID]
  782. local mapConfig = nodeConfig and tBattleConfig.map[nodeConfig.mapID]
  783. local mapName = mapConfig and mapConfig.name or ""
  784. return BATTLEID_2_NAME[nBattleType][battleID] or "", mapName
  785. end
  786. function hangFightQuery(human)
  787. local nBattleID = BattleLogic_GetBattleBattleID(human)
  788. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  789. if -1 >= nBattleID or not tBattleExcel then
  790. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "hangFightQuery 参数不正确")
  791. print("[hangFightQuery] 不存在对应的 奖励配置 和战斗关卡ID id = "..human.db._id)
  792. return
  793. end
  794. -- local battleID = human.db.battleID > #BattleExcel.node and #BattleExcel.node or human.db.battleID
  795. local battleID = nBattleID > #tBattleExcel.node and #tBattleExcel.node or nBattleID
  796. local nowNodeConfig = tBattleExcel.node[battleID]
  797. local monsterOutID = nowNodeConfig.monsterOutID
  798. local monsterOutConfig = MonsterExcel.monsterOut[monsterOutID]
  799. local msgRet = Msg.gc.GC_BATTLE_HANG_FIGHT
  800. local len = 0
  801. for _, monster in ipairs(monsterOutConfig.member) do
  802. local monsterID = monster[1]
  803. len = len + 1
  804. local monsterConfig = MonsterExcel.monster[monsterID]
  805. local skillConfig = SkillExcel.skill[monsterConfig.normalAtkID]
  806. wrapHangFightNet(msgRet.monsterList[len], monsterConfig, skillConfig)
  807. end
  808. msgRet.monsterList[0] = len
  809. len = 0
  810. if human.db.combatHero[CombatDefine.COMBAT_TYPE1] then
  811. local tb = { }
  812. for i = 1, #human.db.combatHero[CombatDefine.COMBAT_TYPE1] do
  813. tb[#tb + 1] = human.db.combatHero[CombatDefine.COMBAT_TYPE1][i]
  814. end
  815. local tb2 = { }
  816. for i = 1, 3 do
  817. local r = math.ceil(math.random(0, #tb))
  818. r = r == 0 and 1 or r
  819. tb2[#tb2 + 1] = tb[r]
  820. tb[r] = tb[#tb]
  821. tb[#tb] = nil
  822. if not tb[1] then
  823. break
  824. end
  825. end
  826. for i = 1, #tb2 do
  827. len = len + 1
  828. local heroGrid = HeroLogic.getHeroGridByUuid(human, tb2[i])
  829. if heroGrid then
  830. local heroConfig = HeroExcel.hero[heroGrid.id]
  831. local _, skinSkillConf = SkinLogic.getHeroSkin(human, tb2[i])
  832. local skillConfig = SkillExcel.skill[heroConfig.normalAtkID]
  833. if skinSkillConf then
  834. skillConfig = SkillExcel.skill[skinSkillConf.normalAtkID]
  835. end
  836. wrapHangFightNet(msgRet.attackerList[i], heroConfig, skillConfig)
  837. local body, head = SkinLogic.getBody(human, tb2[i])
  838. if body then
  839. msgRet.attackerList[i].body = body
  840. end
  841. end
  842. end
  843. end
  844. msgRet.attackerList[0] = len
  845. -- Msg.trace(msgRet)
  846. Msg.send(msgRet, human.fd)
  847. end
  848. local function getExtraRewardID(human)
  849. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  850. if not tBattleExcel then
  851. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getExtraRewardID] 参数不正确")
  852. print("[getExtraRewardID] 不存在对应的 奖励配置 id = "..human.db._id)
  853. return nil, nil
  854. end
  855. local config = tBattleExcel.extraReward
  856. local battleExtraReward = human.db.battleExtraReward
  857. for id, data in ipairs(config) do
  858. if not battleExtraReward or not battleExtraReward[id] then
  859. return id, data
  860. end
  861. end
  862. end
  863. local function getExtraRewardState(human, extraRewardID)
  864. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  865. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  866. if not tBattleExcel or -1 >= nGuaJiID then
  867. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getExtraRewardState] 参数不正确")
  868. print("[getExtraRewardState] 不存在对应的 奖励配置 id = "..human.db._id)
  869. return 0
  870. end
  871. local config = tBattleExcel.extraReward[extraRewardID]
  872. if not config then
  873. return 0
  874. end
  875. if human.db.battleExtraReward and human.db.battleExtraReward[extraRewardID] then
  876. return 0
  877. end
  878. local guajiID = nGuaJiID
  879. if guajiID >= config.needBattleID then
  880. return 1
  881. end
  882. return 0
  883. end
  884. local function makeExtraRewardShow(human, net)
  885. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  886. if not tBattleExcel then
  887. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[makeExtraRewardShow] 参数不正确")
  888. print("[makeExtraRewardShow] 不存在对应的 奖励配置 id = "..human.db._id)
  889. return
  890. end
  891. local config = tBattleExcel.extraReward
  892. local extraID, data = getExtraRewardID(human)
  893. if not extraID or not data then
  894. return
  895. end
  896. net[0] = 1
  897. net[1].needBattleID = data.needBattleID
  898. net[1].descID = data.descID
  899. net[1].desc = data.desc or ""
  900. net[1].extraHero[0] = 0
  901. net[1].extraItem[0] = 0
  902. if data.extraHeroID > 0 then
  903. net[1].extraHero[0] = 1
  904. HeroGrid.makeHeroSimpleByID(net[1].extraHero[1], data.extraHeroID, nil, nil, human)
  905. HeroGrid.makeHeroSimpleByGeneral(net[1].extraHero[1], data.extraHeroID)
  906. else
  907. net[1].extraItem[0] = 1
  908. Grid.makeItem(net[1].extraItem[1], data.extraReward[1], data.extraReward[2])
  909. end
  910. net[1].state = getExtraRewardState(human, extraID)
  911. end
  912. -- 随机道具
  913. local function randItemOut(dropRule, weightSum)
  914. if weightSum < 1 then
  915. return
  916. end
  917. local r = math.random(1, weightSum)
  918. for i = 1, #dropRule do
  919. local itemID = dropRule[i][1]
  920. local itemCnt1 = dropRule[i][2]
  921. local itemCnt2 = dropRule[i][3]
  922. local weight = dropRule[i][4]
  923. if r <= weight then
  924. local itemCnt = math.random(itemCnt1, itemCnt2)
  925. return itemID, itemCnt
  926. end
  927. r = r - weight
  928. end
  929. end
  930. function fontExtraDataSSZH(net, mapID, nowBattleID, human)
  931. local nodeCnt = 0
  932. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  933. if not tBattleExcel then
  934. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[fontExtraDataSSZH] 参数不正确")
  935. print("[fontExtraDataSSZH] 不存在对应的 奖励配置 id = "..human.db._id)
  936. return
  937. end
  938. if ProjectLogic.isSszh() then
  939. for i = 1, #tBattleExcel.node do
  940. local nodeTempConfig = tBattleExcel.node[i]
  941. if nodeTempConfig.mapID == mapID then
  942. nodeCnt = nodeCnt + 1
  943. local posNet = net.posList[nodeCnt]
  944. local pos = nodeTempConfig.pos
  945. posNet.battleID = i
  946. posNet.posX = pos and pos[1] or 0
  947. posNet.posY = pos and pos[2] or 0
  948. posNet.nodeName = getBattleName(human, i)
  949. posNet.roleBase[0] = 0
  950. if i == nowBattleID then
  951. local videoTb = BattleDBLogic.queryBattleDbByNodeID(i)
  952. local sharkData = videoTb and videoTb.shark[2]
  953. if sharkData then
  954. posNet.roleBase[0] = 1
  955. RoleLogic.makeRoleBase(videoTb.roleBase, posNet.roleBase[1])
  956. end
  957. end
  958. posNet.isBig = nodeTempConfig.isBig or 0
  959. end
  960. end
  961. end
  962. net.posList[0] = nodeCnt
  963. end
  964. function fontVideoInfo(human, net, monsterConfig)
  965. local combatHero = CombatPosLogic.getCombatHeros(human, CombatDefine.COMBAT_TYPE1)
  966. local len = #combatHero
  967. -- 自己没队伍时,不显示
  968. if len == 0 then
  969. net.ownBody[0] = 0
  970. net.enemyBody[0] = 0
  971. else
  972. -- 设置真实数据
  973. local cnt = 0
  974. for k, v in pairs(combatHero) do
  975. -- body数据
  976. if v ~= "0" then
  977. local heroGird, bagIndex = HeroLogic.getHeroGridByUuid(human, v)
  978. if heroGird ~= nil then
  979. cnt = cnt + 1
  980. local config = HeroExcel.hero[heroGird.id]
  981. if config then
  982. local attrConfig = HeroDefine.getAttrConfig(heroGird.id, config.star)
  983. local normalAtkID = attrConfig.normalAtkID
  984. local skill = attrConfig.battleSkill
  985. local body, head = SkinLogic.getBody(human, bagIndex)
  986. net.ownBody[cnt].body = body or config.body
  987. fontBattleSkillNet(net.ownBody[cnt].atkId, normalAtkID)
  988. fontBattleSkillNet(net.ownBody[cnt].skill, skill)
  989. net.ownBody[cnt].pos = k
  990. net.ownBody[cnt].atkType = SkillExcel.skill[normalAtkID].areaPara
  991. local attrs = ObjHuman.getHeroAttrs(human, heroGird.bagIndex)
  992. net.ownBody[cnt].hp = attrs[RoleDefine.HP]
  993. end
  994. end
  995. end
  996. end
  997. net.ownBody[0] = cnt
  998. cnt = 0
  999. local memberConfig = monsterConfig.member
  1000. for k, v in pairs(memberConfig) do
  1001. -- body数据
  1002. cnt = cnt + 1
  1003. local config = MonsterExcel.monster[v[1]]
  1004. if config then
  1005. local normalAtkID = config.normalAtkID
  1006. net.enemyBody[cnt].body = config.body
  1007. fontBattleSkillNet(net.enemyBody[cnt].atkId, normalAtkID)
  1008. fontBattleSkillNet(net.enemyBody[cnt].skill, normalAtkID)
  1009. net.enemyBody[cnt].pos = k
  1010. net.enemyBody[cnt].atkType = SkillExcel.skill[normalAtkID].areaPara
  1011. local attrID = monsterConfig.attrID[k]
  1012. local attrConfig = MonsterExcel.monsterAttr[attrID].attrs
  1013. if not attrConfig then
  1014. print("[fontVideoInfo] 根据attrID获取到的 attrConfig 为空 k = "..k.. " attrID = "..attrID)
  1015. end
  1016. for _, value in pairs(attrConfig) do
  1017. if value[1] == RoleDefine.HP then
  1018. net.enemyBody[cnt].hp = value[2]
  1019. break
  1020. end
  1021. end
  1022. end
  1023. end
  1024. net.enemyBody[0] = cnt
  1025. end
  1026. end
  1027. -- 战役主界面查询
  1028. function query(human)
  1029. local msgRet = Msg.gc.GC_BATTLE_QUERY
  1030. local nNowBattleID = BattleLogic_GetBattleBattleID(human)
  1031. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1032. local nNowGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  1033. if -1 >= nNowBattleID or not tBattleConfig or -1 >= nNowGuaJiID then
  1034. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[query] 获取到的战斗ID或奖励配置不正确")
  1035. print("[query] 获取到的战斗ID或奖励配置不正确 id = "..human.db._id)
  1036. return
  1037. end
  1038. print("[BattleLogic query] nNowGuaJiID ="..nNowGuaJiID.." nNowBattleID ="..nNowBattleID)
  1039. msgRet.nowBattleID = nNowBattleID
  1040. local configNode = #tBattleConfig.node
  1041. if nNowBattleID > configNode then
  1042. print("[query] 玩家的战斗ID不正确,进行纠正 nNowBattleID = "..nNowBattleID.." 最大战斗ID = "..configNode)
  1043. nNowBattleID = configNode
  1044. BattleLogic_SetBattleBattleID(human, nNowBattleID)
  1045. end
  1046. if nNowGuaJiID > configNode then
  1047. print("[query] 玩家的挂机ID不正确,进行纠正 nNowGuaJiID = "..nNowGuaJiID.." 最大挂机ID = "..configNode)
  1048. nNowGuaJiID = configNode
  1049. BattleLogic_SetBattleGuaJiID(human, nNowGuaJiID)
  1050. end
  1051. if nNowBattleID == nNowGuaJiID and nNowBattleID == configNode then
  1052. print("[query] nNowBattleID 为最大值 nNowBattleID = "..nNowBattleID.." nNowGuaJiID = "..nNowGuaJiID)
  1053. msgRet.nowBattleID = configNode + 1
  1054. end
  1055. -- local nowBattleID = human.db.battleID > configNode and configNode or human.db.battleID
  1056. local nowNodeConfig = tBattleConfig.node[nNowBattleID]
  1057. if not nowNodeConfig then
  1058. print("[query] 不存在对应的当前战斗ID对应的配置 nNowBattleID = ", nNowBattleID)
  1059. return
  1060. end
  1061. local nowMapConfig = tBattleConfig.map[nowNodeConfig.mapID]
  1062. if not nowMapConfig then
  1063. print("[query] 不存在对应的当前地图对应的地图配置 nNowBattleID = "
  1064. ..nNowBattleID.." mapID ="..nowNodeConfig.mapID)
  1065. return
  1066. end
  1067. local nJudeNum = nNowGuaJiID
  1068. if nNowGuaJiID ~= nNowBattleID then
  1069. if nNowGuaJiID + 1 < nNowBattleID then
  1070. nJudeNum = nNowBattleID - 1
  1071. end
  1072. end
  1073. msgRet.maxBattleID = configNode
  1074. msgRet.mapID = nowNodeConfig.mapID
  1075. msgRet.nodeID = nowNodeConfig.curLevel
  1076. msgRet.sceneID = nowNodeConfig.sceneID
  1077. msgRet.mapName = nowMapConfig.name
  1078. msgRet.nodeName = nowNodeConfig.name
  1079. msgRet.needLv = nowNodeConfig.needLv
  1080. msgRet.bg = nowMapConfig.bg
  1081. msgRet.canBattle = 0
  1082. msgRet.doubleCnt = 0
  1083. if nowNodeConfig.needLv > human.db.lv then
  1084. msgRet.canBattle = nowNodeConfig.needLv
  1085. end
  1086. local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_1104)
  1087. if
  1088. double and human.db.bar and human.db.bar.doubleCnt and
  1089. human.db.bar.doubleCnt <= BarTaskLogic.DEFAULT_MAX_DOUBLE_CNT
  1090. then
  1091. msgRet.doubleCnt = BarTaskLogic.DEFAULT_MAX_DOUBLE_CNT - human.db.bar.doubleCnt
  1092. elseif double and not human.db.bar then
  1093. msgRet.doubleCnt = BarTaskLogic.DEFAULT_MAX_DOUBLE_CNT
  1094. end
  1095. msgRet.tongguan[0] = 0
  1096. local id = getTongguanIndex(human)
  1097. if id == nil then
  1098. msgRet.tongguan[0] = 0
  1099. else
  1100. msgRet.tongguan[0] = 1
  1101. local state = isGetReward(human, id)
  1102. local cf = tBattleConfig.node[id].tongguan
  1103. local net = msgRet.tongguan[1]
  1104. if state == true then
  1105. net.status = STATUS_NONE
  1106. else
  1107. net.status =(id > nJudeNum) and STATUS_CANGET or STATUS_NONE
  1108. end
  1109. net.levelName = getBattleName(human,id)
  1110. net.index = id
  1111. net.nowBattle = getBattleName(human,nJudeNum)
  1112. net.reward[0] = 0
  1113. net.heroReward[0] = 0
  1114. -- 是英雄
  1115. if cf[1][3] then
  1116. net.heroReward[0] = 1
  1117. local other = { }
  1118. other.star = cf[1][3]
  1119. HeroGrid.makeHeroSimpleByID(net.heroReward[1], cf[1][1], nil, other, human)
  1120. HeroGrid.makeHeroSimpleByGeneral(net.heroReward[1], cf[1][1])
  1121. else
  1122. net.reward[0] = 1
  1123. for i = 1, net.reward[0] do
  1124. local itemID = cf[i][1]
  1125. local itemCnt = cf[i][2]
  1126. Grid.makeItem(net.reward[i], itemID, itemCnt)
  1127. end
  1128. end
  1129. end
  1130. local outSec = 0
  1131. local tBattleOut = BattleLogic_GetBattleOut(human)
  1132. --if human.db.battleOut ~= nil then
  1133. if tBattleOut ~= nil then
  1134. local now = os.time()
  1135. outSec = now - tBattleOut.expTs1
  1136. end
  1137. local maxHangTime = getHangMaxTime(human)
  1138. msgRet.maxTime = maxHangTime
  1139. if maxHangTime >= outSec then
  1140. msgRet.time = outSec
  1141. else
  1142. msgRet.time = maxHangTime
  1143. end
  1144. -- 悬赏情报数量
  1145. msgRet.xushang = human.db.bar and human.db.bar.qingbao or 0
  1146. msgRet.xushangMax = RoleExcel.exp[human.db.lv].qingBaoMax
  1147. -- 悬赏红点
  1148. msgRet.xsDot = 0
  1149. if BarTaskLogic.isDot(human) then
  1150. msgRet.xsDot = 1
  1151. end
  1152. msgRet.canMopup = 0
  1153. if TequanShopLogic.isActiveMopup(human) then
  1154. msgRet.canMopup = human.db.mopupDoCnt < BATTLE_MOPUP_CNT_VIP and 1 or 0
  1155. else
  1156. msgRet.canMopup = human.db.mopupDoCnt < BATTLE_MOPUP_CNT and 1 or 0
  1157. end
  1158. local monsterOutId = nowNodeConfig.monsterOutID
  1159. if not monsterOutId then
  1160. print("[BattleLogic query] monsterOutId 为空")
  1161. return
  1162. end
  1163. local monsterConfig = MonsterExcel.monsterOut[monsterOutId]
  1164. if not monsterConfig then
  1165. print("[BattleLogic query] 获取到的 monsterConfig 为空 monsterOutId = "..monsterOutId)
  1166. return
  1167. end
  1168. fontVideoInfo(human, msgRet.videoInfo, monsterConfig)
  1169. fontExtraDataSSZH(msgRet.extraDataSSZH, nowNodeConfig.mapID, nNowBattleID, human)
  1170. -- Msg.trace(msgRet)
  1171. Msg.send(msgRet, human.fd)
  1172. hangFightQuery(human)
  1173. end
  1174. -- 获取当前地图ID
  1175. function getMapID(human, args)
  1176. local nNowBattleID = BattleLogic_GetBattleBattleID(human)
  1177. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1178. if -1 >= nNowBattleID or not tBattleConfig then
  1179. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getMapID] 获取到的战斗ID或奖励配置不正确")
  1180. print("[getMapID] 获取到的战斗ID或奖励配置不正确 id = "..human.db._id)
  1181. return
  1182. end
  1183. -- local battleID = human.db.battleID
  1184. -- local config = BattleExcel.node[battleID]
  1185. local config = tBattleConfig.node[nNowBattleID]
  1186. if not config then
  1187. return
  1188. end
  1189. local mapConfig = tBattleConfig.map[config.mapID]
  1190. if not mapConfig then
  1191. return
  1192. end
  1193. return config.sceneID
  1194. end
  1195. -- 战役挂机界面查询
  1196. function onHookQuery(human)
  1197. local msgRet = Msg.gc.GC_BATTLE_HANG_QUERY
  1198. calcBattleOut(human)
  1199. local tBattleOut = BattleLogic_GetBattleOut(human)
  1200. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1201. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  1202. if not tBattleConfig or 0 > nGuaJiID or not tBattleOut then
  1203. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[onHookQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、挂机ID不正确 id = "..human.db._id)
  1204. print("[onHookQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、挂机ID不正确 id = "..human.db._id)
  1205. return
  1206. end
  1207. -- local expAdd = human.db.battleOut.exp
  1208. -- local jinbiAdd = human.db.battleOut.jinbi
  1209. -- local greenExpAdd = human.db.battleOut.greenExp
  1210. -- local qingbaoAdd = human.db.battleOut.qingbao
  1211. local expAdd = tBattleOut.exp
  1212. local jinbiAdd = tBattleOut.jinbi
  1213. local greenExpAdd = tBattleOut.greenExp
  1214. local qingbaoAdd = tBattleOut.qingbao
  1215. local skip = GuideLogic.getGuideSkip(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_EXP)
  1216. if not skip then
  1217. expAdd = 1510
  1218. end
  1219. local items = { }
  1220. local len = #items
  1221. local tempTable = { }
  1222. if tBattleOut.items then
  1223. tempTable = Util.copyTable(tBattleOut.items)
  1224. end
  1225. tempTable[ItemDefine.ITEM_EXP_ID] = tempTable[ItemDefine.ITEM_EXP_ID] or 0
  1226. tempTable[ItemDefine.ITEM_EXP_ID] = expAdd
  1227. tempTable[ItemDefine.ITEM_JINBI_ID] = tempTable[ItemDefine.ITEM_JINBI_ID] or 0
  1228. tempTable[ItemDefine.ITEM_JINBI_ID] = jinbiAdd
  1229. tempTable[ItemDefine.ITEM_GREEN_EXP_ID] = tempTable[ItemDefine.ITEM_GREEN_EXP_ID] or 0
  1230. tempTable[ItemDefine.ITEM_GREEN_EXP_ID] = greenExpAdd
  1231. tempTable[ItemDefine.ITEM_QINGBAO_ID] = tempTable[ItemDefine.ITEM_QINGBAO_ID] or 0
  1232. tempTable[ItemDefine.ITEM_QINGBAO_ID] = qingbaoAdd
  1233. local list = DropExchangeLogic.getAbsCanDrop(human)
  1234. if list then
  1235. for k, v in pairs(list) do
  1236. if tempTable[k] and tempTable[k] > 0 then
  1237. len = len + 1
  1238. items[len] = { }
  1239. items[len].id = k
  1240. items[len].cnt = tempTable[k]
  1241. end
  1242. end
  1243. end
  1244. for k, v in pairs(tempTable) do
  1245. if not list or not list[k] then
  1246. len = len + 1
  1247. items[len] = { }
  1248. items[len].id = k
  1249. items[len].cnt = v
  1250. end
  1251. end
  1252. -- 发消息
  1253. local guajiID = nGuaJiID > #tBattleConfig.node and #tBattleConfig.node or nGuaJiID
  1254. if guajiID == 0 then
  1255. return Broadcast.sendErr(human, Lang.BATTLE_GUAJI_ERR)
  1256. end
  1257. local nodeConfig = tBattleConfig.node[guajiID]
  1258. local now = os.time()
  1259. local outSec = now - human.db.battleOut.expTs1
  1260. local maxHangTime = getHangMaxTime(human)
  1261. local idx = 1
  1262. for i = 1, #items do
  1263. Grid.makeItem(msgRet.items[i], items[i].id, items[i].cnt)
  1264. end
  1265. local len = #items
  1266. if human.db.battleOut.equip then
  1267. for k, equipGrid in ipairs(tBattleOut.equip) do
  1268. if len >= 10 then
  1269. msgRet.items[0] = len
  1270. msgRet.isEnd = 0
  1271. msgRet.index = idx
  1272. msgRet.maxTime = maxHangTime
  1273. if maxHangTime >= outSec then
  1274. msgRet.time = outSec
  1275. else
  1276. msgRet.time = maxHangTime
  1277. end
  1278. local minHour = math.floor(msgRet.time / HOUR_SEC)
  1279. minHour = (minHour ~= 0) and minHour or 1
  1280. msgRet.diamond = minHour * DIAMOND_COST_PER_HOUR
  1281. msgRet.exp = nodeConfig.hangExp
  1282. msgRet.jinbi = nodeConfig.hangJinbi
  1283. msgRet.greenExp = nodeConfig.hangGreenExp
  1284. msgRet.qingbao = nodeConfig.hangQingbao or 0
  1285. Msg.send(msgRet, human.fd)
  1286. len = 0
  1287. idx = idx + 1
  1288. msgRet = Msg.gc.GC_BATTLE_HANG_QUERY
  1289. end
  1290. len = len + 1
  1291. Grid.makeItem(msgRet.items[len], equipGrid.id, 1, nil, equipGrid)
  1292. end
  1293. end
  1294. msgRet.isEnd = 1
  1295. msgRet.index = idx
  1296. msgRet.items[0] = len
  1297. msgRet.maxTime = maxHangTime
  1298. if maxHangTime >= outSec then
  1299. msgRet.time = outSec
  1300. else
  1301. msgRet.time = maxHangTime
  1302. end
  1303. local minHour = math.floor(msgRet.time / HOUR_SEC)
  1304. minHour = (minHour ~= 0) and minHour or 1
  1305. msgRet.diamond = minHour * DIAMOND_COST_PER_HOUR
  1306. msgRet.exp = nodeConfig.hangExp
  1307. msgRet.jinbi = nodeConfig.hangJinbi
  1308. msgRet.greenExp = nodeConfig.hangGreenExp
  1309. msgRet.qingbao = nodeConfig.hangQingbao or 0
  1310. Msg.send(msgRet, human.fd)
  1311. end
  1312. local function isChapterDot(human, mapID)
  1313. local chapterReward = BattleLogic_GetChapterReward(human)
  1314. local nBattleID = BattleLogic_GetBattleBattleID(human)
  1315. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1316. if not chapterReward or not tBattleConfig or -1 >= nBattleID or chapterReward[mapID] then
  1317. return false
  1318. end
  1319. local battleID = nBattleID
  1320. local battleNodeConfig = tBattleConfig.node[battleID]
  1321. if not battleNodeConfig then
  1322. if battleID == #tBattleConfig.node + 1 then
  1323. return true
  1324. else
  1325. return false
  1326. end
  1327. else
  1328. local roleMapId = battleNodeConfig.mapID
  1329. if roleMapId <= mapID then
  1330. return false
  1331. end
  1332. end
  1333. return true
  1334. end
  1335. function battleWorldMapQuery(human)
  1336. -- 先取配置
  1337. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1338. local nBattleID = BattleLogic_GetBattleBattleID(human)
  1339. if not tBattleConfig or -1 >= nBattleID then
  1340. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[battleWorldMapQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、战斗关卡ID不正确 id = "..human.db._id)
  1341. print("[battleWorldMapQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、挂机ID不正确 id = "..human.db._id)
  1342. return
  1343. end
  1344. local msgRet = Msg.gc.GC_BATTLE_WORLD_MAP_QUERY
  1345. local worldMapConfig = tBattleConfig.map
  1346. local battleID = nBattleID > #tBattleConfig.node and #tBattleConfig.node or nBattleID
  1347. local battleNodeConfig = tBattleConfig.node[battleID]
  1348. local len = #worldMapConfig
  1349. for i = 1, len do
  1350. local v = worldMapConfig[i]
  1351. msgRet.worldMap[i].mapID = i
  1352. msgRet.worldMap[i].mapName = v.name or ""
  1353. msgRet.worldMap[i].mapBuild = v.build or 0
  1354. msgRet.worldMap[i].mapBg = v.bg or 0
  1355. msgRet.worldMap[i].mapPos[0] = 2
  1356. msgRet.worldMap[i].mapPos[1] = v.pos[1]
  1357. msgRet.worldMap[i].mapPos[2] = v.pos[2]
  1358. msgRet.worldMap[i].status =(battleNodeConfig.mapID >= i) and 1 or 0
  1359. msgRet.worldMap[i].story = v.des or ""
  1360. if battleNodeConfig.mapID == i then
  1361. msgRet.worldMap[i].maxLevel = battleNodeConfig.maxLevel
  1362. msgRet.worldMap[i].curLevel = battleNodeConfig.curLevel
  1363. else
  1364. msgRet.worldMap[i].maxLevel = 0
  1365. msgRet.worldMap[i].curLevel = 0
  1366. end
  1367. local reward = v.reward
  1368. local l = 0
  1369. msgRet.worldMap[i].chapterReward[0] = #reward
  1370. for _, rewardData in pairs(reward) do
  1371. l = l + 1
  1372. Grid.makeItem(msgRet.worldMap[i].chapterReward[l], rewardData[1], rewardData[2])
  1373. end
  1374. msgRet.worldMap[i].chapterDot = 0
  1375. if isChapterDot(human, i) then
  1376. msgRet.worldMap[i].chapterDot = 1
  1377. end
  1378. local cnt = 0
  1379. BATTLE_LEVEL_PLAYER_LIST[i] = BATTLE_LEVEL_PLAYER_LIST[i] or { }
  1380. for s, t in pairs(BATTLE_LEVEL_PLAYER_LIST[i]) do
  1381. cnt = cnt + 1
  1382. RoleLogic.makeRoleBase(t, msgRet.worldMap[i].roleList[cnt])
  1383. if cnt >= 3 then
  1384. break
  1385. end
  1386. end
  1387. msgRet.worldMap[i].roleList[0] = cnt
  1388. end
  1389. msgRet.worldMap[0] = len
  1390. Msg.send(msgRet, human.fd)
  1391. end
  1392. function battleNodeQuery(human, mapID)
  1393. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1394. local nBattleID = BattleLogic_GetBattleBattleID(human)
  1395. if not tBattleConfig or -1 >= nBattleID then
  1396. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[battleNodeQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、战斗关卡ID不正确 id = "..human.db._id)
  1397. print("[battleNodeQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、挂机ID不正确 id = "..human.db._id)
  1398. return
  1399. end
  1400. local msgRet = Msg.gc.GC_BATTLE_NODE_QUERY
  1401. local nodeConfig = tBattleConfig.node
  1402. local lenConfig = #nodeConfig
  1403. local len = 0
  1404. msgRet.battleID = nBattleID or 0
  1405. for i = 1, lenConfig do
  1406. local v = nodeConfig[i]
  1407. if v.mapID == mapID then
  1408. len = len + 1
  1409. msgRet.nodeInfo[len].nodeName = v.name
  1410. msgRet.nodeInfo[len].battleID = i
  1411. msgRet.nodeInfo[len].needLv = v.needLv
  1412. msgRet.nodeInfo[len].needZDL = v.needZDL
  1413. msgRet.nodeInfo[len].hasSuipian = v.hasSuipian
  1414. end
  1415. end
  1416. msgRet.nodeInfo[0] = len
  1417. Msg.send(msgRet, human.fd)
  1418. end
  1419. function initBattleOut(human, now)
  1420. if human.db.battleOut then
  1421. return
  1422. end
  1423. if false == BattleLogic_InitAllBattleOut(human, now) then
  1424. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "initBattleOut 初始化挂机奖励表失败 id = "
  1425. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1426. return
  1427. end
  1428. -- human.db.battleOut = { }
  1429. -- human.db.battleOut.expTs1 = now
  1430. -- -- 经验开始产出时间戳
  1431. -- human.db.battleOut.expTs2 = now
  1432. -- -- 经验产出结算时间戳
  1433. -- human.db.battleOut.itemTs1 = now
  1434. -- -- 道具产出时间戳
  1435. -- human.db.battleOut.itemTs2 = now
  1436. -- -- 道具产出结算时间戳
  1437. -- human.db.battleOut.exp = 0
  1438. -- human.db.battleOut.jinbi = 0
  1439. -- human.db.battleOut.greenExp = 0
  1440. -- human.db.battleOut.qingbao = 0
  1441. -- human.db.battleOut.items = nil
  1442. -- -- 产出的待收获的战利品
  1443. -- human.db.battleOut.equip = nil
  1444. -- -- 产出的待收获的装备
  1445. end
  1446. function calcBattleOut(human,isDiamond)
  1447. local now = os.time()
  1448. initBattleOut(human, now)
  1449. calcBattleExpOut(human, now)
  1450. calcBattleItemOut(human, now)
  1451. if isDiamond then -- 钻石消耗 所有产出翻1.5倍
  1452. local tBattleOut = BattleLogic_GetBattleOut(human)
  1453. if not tBattleOut then
  1454. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleOut 获取挂机奖励列表失败 id = "
  1455. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1456. return
  1457. end
  1458. -- human.db.battleOut.exp = math.floor(human.db.battleOut.exp * DIAMOND_ADDITION)
  1459. -- human.db.battleOut.jinbi = math.floor(human.db.battleOut.jinbi * DIAMOND_ADDITION)
  1460. -- human.db.battleOut.greenExp = math.floor(human.db.battleOut.greenExp * DIAMOND_ADDITION)
  1461. -- human.db.battleOut.qingbao = math.floor(human.db.battleOut.qingbao * DIAMOND_ADDITION)
  1462. -- local items = human.db.battleOut.items or {}
  1463. tBattleOut.exp = math.floor(tBattleOut.exp * DIAMOND_ADDITION)
  1464. tBattleOut.jinbi = math.floor(tBattleOut.jinbi * DIAMOND_ADDITION)
  1465. tBattleOut.greenExp = math.floor(tBattleOut.greenExp * DIAMOND_ADDITION)
  1466. tBattleOut.qingbao = math.floor(tBattleOut.qingbao * DIAMOND_ADDITION)
  1467. local items = tBattleOut.items or {}
  1468. for id,cnt in pairs(items) do
  1469. items[id] = math.floor(cnt * DIAMOND_ADDITION)
  1470. end
  1471. -- local equipList = human.db.battleOut.equip or {}
  1472. local equipList = tBattleOut.equip or {}
  1473. local equipMap = {}
  1474. for _,equip in ipairs(equipList) do
  1475. equipMap[equip.id] = equipMap[equip.id] or 0
  1476. equipMap[equip.id] = equipMap[equip.id] + 1
  1477. end
  1478. for id,cnt in pairs(equipMap) do
  1479. local count = math.floor(cnt * DIAMOND_ADDITION)
  1480. for i = cnt,count do
  1481. local equipGrid = EquipLogic.makeEquip(id)
  1482. equipList[#equipList + 1] = equipGrid
  1483. end
  1484. end
  1485. end
  1486. end
  1487. -- 获取正确的剩余可收益的结算时间
  1488. function getSurMaxHangTime(maxHangTime, ts1, now)
  1489. if ts1 + maxHangTime > now then
  1490. return now
  1491. else
  1492. return ts1 + maxHangTime
  1493. end
  1494. end
  1495. -- function calcBattleExpOut(human, now)
  1496. -- local maxHangTime = getHangMaxTime(human)
  1497. -- if human.db.battleOut.expTs2 - human.db.battleOut.expTs1 >= maxHangTime then
  1498. -- return
  1499. -- end
  1500. -- local outTime = getSurMaxHangTime(maxHangTime, human.db.battleOut.expTs1, now)
  1501. -- local outSec = outTime - human.db.battleOut.expTs2
  1502. -- local outCnt = math.floor(outSec / BATTLE_HANG_EXP_OUT_PERIOD)
  1503. -- if outCnt < 1 then
  1504. -- return
  1505. -- end
  1506. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  1507. -- if guajiID == 0 then
  1508. -- return
  1509. -- end
  1510. -- local nowNodeConfig = BattleExcel.node[guajiID]
  1511. -- human.db.battleOut.expTs2 = human.db.battleOut.expTs2 + outCnt * BATTLE_HANG_EXP_OUT_PERIOD
  1512. -- if now - human.db.battleOut.expTs1 >= maxHangTime then
  1513. -- human.db.battleOut.expTs2 = now
  1514. -- end
  1515. -- local vipExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER7) or 0) / 100
  1516. -- local vipJinAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER8) or 0) / 100
  1517. -- local vipGreenExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER9) or 0) / 100
  1518. -- local vipQingbaoAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER19) or 0) / 100
  1519. -- local exp = nowNodeConfig.hangExp
  1520. -- local jinbi = nowNodeConfig.hangJinbi
  1521. -- local greenExp = nowNodeConfig.hangGreenExp
  1522. -- local qingbao = nowNodeConfig.hangQingbao
  1523. -- human.db.battleOut.exp = human.db.battleOut.exp + math.floor(outCnt * exp *(1 + vipExpAdd))
  1524. -- human.db.battleOut.jinbi = human.db.battleOut.jinbi + math.floor(outCnt * jinbi *(1 + vipJinAdd))
  1525. -- human.db.battleOut.greenExp = human.db.battleOut.greenExp + math.floor(outCnt * greenExp *(1 + vipGreenExpAdd))
  1526. -- human.db.battleOut.qingbao = human.db.battleOut.qingbao + math.floor(outCnt * qingbao *(1 + vipQingbaoAdd))
  1527. -- end
  1528. function calcBattleExpOut(human, now)
  1529. local tBattleOut = BattleLogic_GetBattleOut(human)
  1530. if not tBattleOut then
  1531. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleExpOut 获取挂机奖励列表失败 id = "
  1532. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1533. return
  1534. end
  1535. local maxHangTime = getHangMaxTime(human)
  1536. if tBattleOut.expTs2 - tBattleOut.expTs1 >= maxHangTime then
  1537. return
  1538. end
  1539. local outTime = getSurMaxHangTime(maxHangTime, tBattleOut.expTs1, now)
  1540. local outSec = outTime - tBattleOut.expTs2
  1541. local outCnt = math.floor(outSec / BATTLE_HANG_EXP_OUT_PERIOD)
  1542. if outCnt < 1 then
  1543. return
  1544. end
  1545. local tBattleNodeConfig = BattleLogic_GetBattleConfig(human)
  1546. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  1547. if not tBattleNodeConfig or 0 > nGuaJiID then
  1548. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleExpOut 获取到的配置表不正确或挂机ID不正确 id = "
  1549. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1550. return
  1551. end
  1552. local guajiID = nGuaJiID > #tBattleNodeConfig.node and #tBattleNodeConfig.node or nGuaJiID
  1553. if guajiID == 0 then
  1554. return
  1555. end
  1556. local nowNodeConfig = tBattleNodeConfig.node[guajiID]
  1557. tBattleOut.expTs2 = tBattleOut.expTs2 + outCnt * BATTLE_HANG_EXP_OUT_PERIOD
  1558. if now - tBattleOut.expTs1 >= maxHangTime then
  1559. tBattleOut.expTs2 = now
  1560. end
  1561. local vipExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER7) or 0) / 100
  1562. local vipJinAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER8) or 0) / 100
  1563. local vipGreenExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER9) or 0) / 100
  1564. local vipQingbaoAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER19) or 0) / 100
  1565. local exp = nowNodeConfig.hangExp
  1566. local jinbi = nowNodeConfig.hangJinbi
  1567. local greenExp = nowNodeConfig.hangGreenExp
  1568. local qingbao = nowNodeConfig.hangQingbao
  1569. tBattleOut.exp = tBattleOut.exp + math.floor(outCnt * exp *(1 + vipExpAdd))
  1570. tBattleOut.jinbi = tBattleOut.jinbi + math.floor(outCnt * jinbi *(1 + vipJinAdd))
  1571. tBattleOut.greenExp = tBattleOut.greenExp + math.floor(outCnt * greenExp *(1 + vipGreenExpAdd))
  1572. tBattleOut.qingbao = tBattleOut.qingbao + math.floor(outCnt * qingbao *(1 + vipQingbaoAdd))
  1573. end
  1574. -- 根据时间计算道具产出
  1575. local ITEM_OUT_LIST = { }
  1576. function getItemOutsByTime(config, sec)
  1577. Util.cleanTable(ITEM_OUT_LIST)
  1578. local outCnt = math.floor(sec / BATTLE_HANG_ITEM_OUT_PERIOD)
  1579. if outCnt < 1 then
  1580. return ITEM_OUT_LIST
  1581. end
  1582. -- 普通掉落
  1583. local dropID = config.dropID
  1584. local dropConfig = DropExcel.dropBattle[dropID]
  1585. local weightSum = 0
  1586. for i = 1, #dropConfig.dropRule do
  1587. local tempConfig = dropConfig.dropRule[i]
  1588. weightSum = weightSum + tempConfig[4]
  1589. end
  1590. for i = 1, outCnt do
  1591. local itemID, itemCnt = randItemOut(dropConfig.dropRule, weightSum)
  1592. if itemID and itemCnt and itemCnt > 0 then
  1593. ITEM_OUT_LIST[itemID] =(ITEM_OUT_LIST[itemID] or 0) + itemCnt
  1594. end
  1595. end
  1596. for i = 1, #dropConfig.dropRule2 do
  1597. local tempConfig = dropConfig.dropRule2[i]
  1598. local itemID = tempConfig[1]
  1599. local itemMin = tempConfig[2]
  1600. local itemMax = tempConfig[3]
  1601. local itemCnt = math.random(itemMin, itemMax) * outCnt
  1602. if itemCnt > 0 then
  1603. ITEM_OUT_LIST[itemID] =(ITEM_OUT_LIST[itemID] or 0) + itemCnt
  1604. end
  1605. end
  1606. -- 三小时掉落
  1607. outCnt = math.floor(sec / BATTLE_HANG_ITEM_OUT_PERIOD_2)
  1608. if outCnt < 1 then
  1609. return ITEM_OUT_LIST
  1610. end
  1611. weightSum = 0
  1612. for i = 1, #dropConfig.dropRule3 do
  1613. local tempConfig = dropConfig.dropRule3[i]
  1614. weightSum = weightSum + tempConfig[4]
  1615. end
  1616. for i = 1, outCnt do
  1617. local itemID, itemCnt = randItemOut(dropConfig.dropRule3, weightSum)
  1618. if itemID and itemCnt and itemCnt > 0 then
  1619. ITEM_OUT_LIST[itemID] =(ITEM_OUT_LIST[itemID] or 0) + itemCnt
  1620. end
  1621. end
  1622. return ITEM_OUT_LIST
  1623. end
  1624. -- function calcBattleItemOut(human, now,isDiamond)
  1625. -- local maxHangTime = getHangMaxTime(human)
  1626. -- if human.db.battleOut.itemTs2 - human.db.battleOut.itemTs1 >= maxHangTime then
  1627. -- return
  1628. -- end
  1629. -- local outTime = getSurMaxHangTime(maxHangTime, human.db.battleOut.itemTs1, now)
  1630. -- local outSec = outTime - human.db.battleOut.itemTs2
  1631. -- local outCnt = math.floor(outSec / BATTLE_HANG_ITEM_OUT_PERIOD)
  1632. -- if outCnt < 1 then
  1633. -- return
  1634. -- end
  1635. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  1636. -- if guajiID == 0 then
  1637. -- return
  1638. -- end
  1639. -- local sec = outCnt * BATTLE_HANG_ITEM_OUT_PERIOD
  1640. -- human.db.battleOut.itemTs2 = human.db.battleOut.itemTs2 + sec
  1641. -- if now - human.db.battleOut.itemTs1 >= maxHangTime then
  1642. -- human.db.battleOut.itemTs2 = now
  1643. -- end
  1644. -- local nodeConfig = BattleExcel.node[guajiID]
  1645. -- local items = getItemOutsByTime(nodeConfig, sec)
  1646. -- for itemID, itemCnt in pairs(items) do
  1647. -- -- 判定是否是装备
  1648. -- if ItemDefine.isEquip(itemID) then
  1649. -- -- 生成装备
  1650. -- local equipGrid = EquipLogic.makeEquip(itemID)
  1651. -- if equipGrid then
  1652. -- human.db.battleOut.equip = human.db.battleOut.equip or { }
  1653. -- human.db.battleOut.equip[#human.db.battleOut.equip + 1] = equipGrid
  1654. -- end
  1655. -- else
  1656. -- human.db.battleOut.items = human.db.battleOut.items or { }
  1657. -- human.db.battleOut.items[itemID] = human.db.battleOut.items[itemID] or 0
  1658. -- human.db.battleOut.items[itemID] = human.db.battleOut.items[itemID] + itemCnt
  1659. -- end
  1660. -- end
  1661. -- DropExchangeLogic.getDropItem(human, outSec, BATTLE_HANG_ITEM_OUT_PERIOD, human.db.battleOut)
  1662. -- end
  1663. function calcBattleItemOut(human, now,isDiamond)
  1664. local tBattleOut = BattleLogic_GetBattleOut(human)
  1665. if not tBattleOut then
  1666. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleItemOut 获取挂机奖励列表失败 id = "
  1667. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1668. return
  1669. end
  1670. local maxHangTime = getHangMaxTime(human)
  1671. if tBattleOut.itemTs2 - tBattleOut.itemTs1 >= maxHangTime then
  1672. return
  1673. end
  1674. local outTime = getSurMaxHangTime(maxHangTime, tBattleOut.itemTs1, now)
  1675. local outSec = outTime - tBattleOut.itemTs2
  1676. local outCnt = math.floor(outSec / BATTLE_HANG_ITEM_OUT_PERIOD)
  1677. if outCnt < 1 then
  1678. return
  1679. end
  1680. local tBattleNodeConfig = BattleLogic_GetBattleConfig(human)
  1681. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  1682. if not tBattleNodeConfig or 0 > nGuaJiID then
  1683. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleItemOut 获取到的配置表不正确或挂机ID不正确 id = "
  1684. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1685. return
  1686. end
  1687. local guajiID = nGuaJiID > #tBattleNodeConfig.node and #tBattleNodeConfig.node or nGuaJiID
  1688. if guajiID == 0 then
  1689. return
  1690. end
  1691. local sec = outCnt * BATTLE_HANG_ITEM_OUT_PERIOD
  1692. tBattleOut.itemTs2 = tBattleOut.itemTs2 + sec
  1693. if now - tBattleOut.itemTs1 >= maxHangTime then
  1694. tBattleOut.itemTs2 = now
  1695. end
  1696. local nodeConfig = tBattleNodeConfig.node[guajiID]
  1697. local items = getItemOutsByTime(nodeConfig, sec)
  1698. for itemID, itemCnt in pairs(items) do
  1699. -- 判定是否是装备
  1700. if ItemDefine.isEquip(itemID) then
  1701. -- 生成装备
  1702. local equipGrid = EquipLogic.makeEquip(itemID)
  1703. if equipGrid then
  1704. tBattleOut.equip = tBattleOut.equip or { }
  1705. tBattleOut.equip[#tBattleOut.equip + 1] = equipGrid
  1706. end
  1707. else
  1708. tBattleOut.items = tBattleOut.items or { }
  1709. tBattleOut.items[itemID] = tBattleOut.items[itemID] or 0
  1710. tBattleOut.items[itemID] = tBattleOut.items[itemID] + itemCnt
  1711. end
  1712. end
  1713. DropExchangeLogic.getDropItem(human, outSec, BATTLE_HANG_ITEM_OUT_PERIOD, tBattleOut)
  1714. end
  1715. local function hangExpGet(human,isDiamond)
  1716. local tBattleOut = BattleLogic_GetBattleOut(human)
  1717. if not tBattleOut then
  1718. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "hangExpGet 获取挂机奖励列表失败 id = "
  1719. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1720. return
  1721. end
  1722. local needDiamond = 0
  1723. -- 是否消耗钻石
  1724. if isDiamond then
  1725. local now = os.time()
  1726. local outSec = now - tBattleOut.expTs1
  1727. local maxHangTime = getHangMaxTime(human)
  1728. outSec = outSec > maxHangTime and maxHangTime or outSec
  1729. local minHour = math.floor(outSec / HOUR_SEC)
  1730. minHour = (minHour ~= 0) and minHour or 1
  1731. local diamondCnt = minHour * DIAMOND_COST_PER_HOUR
  1732. if not ObjHuman.checkRMB(human,diamondCnt) then
  1733. return
  1734. end
  1735. needDiamond = -diamondCnt
  1736. end
  1737. print("==================== needDiamond is ",needDiamond)
  1738. calcBattleOut(human,isDiamond)
  1739. if tBattleOut.exp == 0 then
  1740. return 1
  1741. end
  1742. local jinbiAdd = tBattleOut.jinbi
  1743. if not ObjHuman.canAddJinbi(human, jinbiAdd) then
  1744. return 2
  1745. end
  1746. -- 检测装备数量
  1747. if tBattleOut.equip then
  1748. local equipCnt = #htBattleOut.equip
  1749. if not EquipLogic.checkEmptyCnt(human, equipCnt) then
  1750. return
  1751. end
  1752. end
  1753. local items = { }
  1754. local len = #items
  1755. local maxHangTime = getHangMaxTime(human)
  1756. if tBattleOut.expTs2 - tBattleOut.expTs1 >= maxHangTime then
  1757. local now = os.time()
  1758. tBattleOut.expTs2 = now
  1759. end
  1760. if tBattleOut.itemTs2 - tBattleOut.itemTs1 >= maxHangTime then
  1761. local now = os.time()
  1762. tBattleOut.itemTs2 = now
  1763. end
  1764. tBattleOut.itemTs1 = tBattleOut.itemTs2
  1765. -- 改db
  1766. local tempTable = tBattleOut.items or { }
  1767. tBattleOut.items = nil
  1768. for k, v in pairs(tempTable) do
  1769. len = len + 1
  1770. items[len] = { }
  1771. items[len].id = k
  1772. items[len].cnt = v
  1773. end
  1774. tBattleOut.expTs1 = tBattleOut.expTs2
  1775. local expAdd = tBattleOut.exp
  1776. local greenExpAdd = tBattleOut.greenExp
  1777. local qingbaoAdd = tBattleOut.qingbao
  1778. -- 新手指引 强制经验
  1779. local flag = GuideLogic.getGuideSkip(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_EXP)
  1780. if not flag then
  1781. expAdd = 1510
  1782. end
  1783. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_EXP)
  1784. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_GUAJI)
  1785. tBattleOut.exp = 0
  1786. tBattleOut.jinbi = 0
  1787. tBattleOut.greenExp = 0
  1788. tBattleOut.qingbao = 0
  1789. len = len + 1
  1790. items[len] = { }
  1791. items[len].id = ItemDefine.ITEM_EXP_ID
  1792. items[len].cnt = expAdd
  1793. len = len + 1
  1794. items[len] = { }
  1795. items[len].id = ItemDefine.ITEM_JINBI_ID
  1796. items[len].cnt = jinbiAdd
  1797. len = len + 1
  1798. items[len] = { }
  1799. items[len].id = ItemDefine.ITEM_GREEN_EXP_ID
  1800. items[len].cnt = greenExpAdd
  1801. len = len + 1
  1802. items[len] = { }
  1803. items[len].id = ItemDefine.ITEM_QINGBAO_ID
  1804. items[len].cnt = qingbaoAdd
  1805. -- 给道具
  1806. for i = 1, #items do
  1807. local tempID = items[i].id
  1808. local tempCnt = items[i].cnt
  1809. BagLogic.addItem(human, tempID, tempCnt, "battle")
  1810. end
  1811. -- 给装备
  1812. if tBattleOut.equip then
  1813. for k, equipGrid in ipairs(tBattleOut.equip) do
  1814. EquipLogic.addByEquipGrid(human, equipGrid, "battle", true)
  1815. end
  1816. tBattleOut.equip = nil
  1817. end
  1818. if needDiamond < 0 then
  1819. ObjHuman.decZuanshi(human,needDiamond,"battle")
  1820. end
  1821. return 0, items
  1822. end
  1823. -- 获取挂机收益
  1824. function hangGet(human,isDiamond)
  1825. local ret, items = hangExpGet(human,false)
  1826. if ret == 1 then
  1827. return Broadcast.sendErr(human, Lang.BATTLE_HANG_GET_EXP_ERR_NONE)
  1828. elseif ret == 2 then
  1829. return Broadcast.sendErr(human, Lang.COMMON_ADD_JINBI_LIMIT)
  1830. elseif ret == 0 then
  1831. query(human)
  1832. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  1833. end
  1834. end
  1835. -- 挂机节点设置
  1836. function nodeSet(human, battleID)
  1837. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1838. local nNowBattleID = BattleLogic_GetBattleBattleID(human)
  1839. if not tBattleConfig or -1 >= nNowBattleID then
  1840. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "hangExpGet 获取挂机奖励列表失败 id = "
  1841. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1842. print("[nodeSet] 获取不到战斗配置")
  1843. return
  1844. end
  1845. local nodeConfig = tBattleConfig.node[battleID]
  1846. if nodeConfig == nil then
  1847. return
  1848. end
  1849. -- 前置条件判断
  1850. if battleID > nNowBattleID then
  1851. return Broadcast.sendErr(human, Lang.BATTLE_ID_OVER)
  1852. end
  1853. -- 等级判断
  1854. if human.db.lv < nodeConfig.needLv then
  1855. return Broadcast.sendErr(human, Util.format(Lang.ROLE_LEV_ERROR, nodeConfig.needLv))
  1856. end
  1857. calcBattleOut(human)
  1858. print("[nodeSet] 玩家进行了挂机节点设置 battleID = ".. battleID)
  1859. BattleLogic_SetBattleGuaJiID(human ,battleID)
  1860. --human.db.guajiID = battleID
  1861. setBattleID(human, battleID)
  1862. Msg.send(Msg.gc.GC_BATTLE_NODE_SET, human.fd)
  1863. query(human)
  1864. end
  1865. -- 挂机节点详细信息查询
  1866. function nodeDetailQuery(human, battleID)
  1867. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1868. local nNowBattleID = BattleLogic_GetBattleBattleID(human)
  1869. if not tBattleConfig or -1 >= nNowBattleID then
  1870. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "nodeDetailQuery 获取挂机奖励列表失败 id = "
  1871. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1872. print("[nodeDetailQuery] 获取不到战斗配置")
  1873. return
  1874. end
  1875. -- local nodeConfig = BattleExcel.node[battleID]
  1876. local nodeConfig = tBattleConfig.node[battleID]
  1877. if nodeConfig == nil then
  1878. return
  1879. end
  1880. local msgRet = Msg.gc.GC_BATTLE_NODE_DETAIL_QUERY
  1881. msgRet.battleID = battleID
  1882. msgRet.exp = nodeConfig.hangExp
  1883. msgRet.jinbi = nodeConfig.hangJinbi
  1884. msgRet.greenExp = nodeConfig.hangGreenExp
  1885. msgRet.qingbao = nodeConfig.hangQingbao or 0
  1886. msgRet.nodeName = getBattleName(human, battleID)
  1887. local dropID = nodeConfig.dropID
  1888. local dropConfig = DropExcel.dropBattle[dropID]
  1889. local dropCnt = 0
  1890. local list = DropExchangeLogic.getAbsCanDrop(human)
  1891. if list then
  1892. for k, v in pairs(list) do
  1893. dropCnt = dropCnt + 1
  1894. Grid.makeItem(msgRet.items[dropCnt], k, v)
  1895. end
  1896. end
  1897. for i = 1, #dropConfig.dropRule do
  1898. local tempConfig = dropConfig.dropRule[i]
  1899. local itemID = tempConfig[1]
  1900. local itemCnt = tempConfig[3]
  1901. local itemRate = tempConfig[4]
  1902. if itemCnt > 0 and itemRate > 0 then
  1903. dropCnt = dropCnt + 1
  1904. Grid.makeItem(msgRet.items[dropCnt], itemID, 1)
  1905. end
  1906. end
  1907. for i = 1, #dropConfig.dropRule3 do
  1908. local tempConfig = dropConfig.dropRule3[i]
  1909. local itemID = tempConfig[1]
  1910. local itemCnt = tempConfig[3]
  1911. local itemRate = tempConfig[4]
  1912. if itemCnt > 0 and itemRate > 0 then
  1913. dropCnt = dropCnt + 1
  1914. Grid.makeItem(msgRet.items[dropCnt], itemID, 1)
  1915. end
  1916. end
  1917. msgRet.items[0] = dropCnt
  1918. Msg.send(msgRet, human.fd)
  1919. end
  1920. -- 挑战当前挂机节点
  1921. function fight(human)
  1922. local battleID = BattleLogic_GetBattleBattleID(human)
  1923. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1924. if not tBattleConfig or -1 >= battleID then
  1925. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "nodeDetailQuery 获取挂机奖励列表失败 id = "
  1926. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1927. print("[nodeDetailQuery] 获取不到战斗配置")
  1928. return
  1929. end
  1930. -- local battleID = human.db.battleID
  1931. -- if BattleExcel.node[human.db.battleID] == nil then
  1932. if tBattleConfig.node[battleID] == nil then
  1933. local msgRet = Msg.gc.GC_BATTLE_GOBACK_MAIN
  1934. msgRet.panelIDs[0] = 1
  1935. msgRet.panelIDs[1] = PanelDefine.PANEL_ID_1008
  1936. Msg.send(msgRet, human.fd)
  1937. return Broadcast.sendErr(human, Lang.BATTLE_MAX_LEVEL)
  1938. end
  1939. -- if human.db.lv < BattleExcel.node[human.db.battleID].needLv then
  1940. if human.db.lv < tBattleConfig.node[battleID].needLv then
  1941. local msgRet = Msg.gc.GC_BATTLE_GOBACK_MAIN
  1942. msgRet.panelIDs[0] = 1
  1943. msgRet.panelIDs[1] = PanelDefine.PANEL_ID_1008
  1944. Msg.send(msgRet, human.fd)
  1945. return Broadcast.sendErr(human, Util.format(Lang.ROLE_LEV_ERROR, tBattleConfig.node[battleID].needLv))
  1946. end
  1947. local config = tBattleConfig.node[battleID]
  1948. local mapConfig = tBattleConfig.map[config.mapID]
  1949. local monsterOutID = config.monsterOutID
  1950. local mapID = mapConfig.bg
  1951. CombatLogic.combatBegin(human, config.sceneID, monsterOutID, CombatDefine.COMBAT_TYPE1, battleID)
  1952. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE)
  1953. end
  1954. function onFightEnd(human, result, fightTypeID, param1, combatInfo)
  1955. -- 设置一些战斗结算信息
  1956. combatInfo.defender.name = Util.format(Lang.COMBAT_BATTLE_DEFEND_NAME, param1)
  1957. if CombatDefine.RESULT_WIN ~= result then
  1958. return
  1959. end
  1960. local nBattleType = BattleLogic_GetBattleType(human)
  1961. local guajiID = BattleLogic_GetBattleGuaJiID(human)
  1962. local battleID = BattleLogic_GetBattleBattleID(human)
  1963. if EliteDefine.COPY_ELITE_ERROR == nBattleType or -1 >= guajiID or -1 >= battleID then
  1964. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "onFightEnd 获取战斗类型、挂机ID、战斗关卡ID失败 id = "
  1965. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1966. print("[onFightEnd] 获取战斗类型、挂机ID、战斗关卡ID失败")
  1967. return
  1968. end
  1969. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1970. if not tBattleConfig then
  1971. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "onFightEnd 获取战斗配置失败 id = "
  1972. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1973. print("[onFightEnd] 获取战斗配置失败")
  1974. return
  1975. end
  1976. -- local guajiID = human.db.guajiID
  1977. -- local battleID = human.db.battleID
  1978. if battleID ~= param1 then
  1979. return
  1980. end
  1981. local nAllFightLen = #tBattleConfig.node
  1982. local nextGuajiID = (guajiID + 1) > nAllFightLen and nAllFightLen or guajiID + 1
  1983. local nextBattleID = (battleID + 1) > nAllFightLen and nAllFightLen or battleID + 1
  1984. -- local nextBattleConfig = BattleExcel.node[nextBattleID]
  1985. -- local config = BattleExcel.node[battleID]
  1986. local nextBattleConfig = tBattleConfig.node[nextBattleID]
  1987. local config = tBattleConfig.node[battleID]
  1988. if not BATTLE_LEVEL_PLAYER_LIST[nBattleType] then
  1989. BATTLE_LEVEL_PLAYER_LIST[nBattleType] = {}
  1990. end
  1991. local tBattleLevelPlayerList = BATTLE_LEVEL_PLAYER_LIST[nBattleType]
  1992. -- 如果过大关卡
  1993. if nextBattleConfig and nextBattleConfig.mapID ~= config.mapID then
  1994. -- 清除记录
  1995. tBattleLevelPlayerList[config.mapID] = tBattleLevelPlayerList[config.mapID] or { }
  1996. tBattleLevelPlayerList[config.mapID][human.db._id] = nil
  1997. -- 增加新纪录
  1998. tBattleLevelPlayerList[nextBattleConfig.mapID] = tBattleLevelPlayerList[nextBattleConfig.mapID] or { }
  1999. tBattleLevelPlayerList[nextBattleConfig.mapID][human.db._id] = { }
  2000. RoleLogic.getRoleBase(human, tBattleLevelPlayerList[nextBattleConfig.mapID][human.db._id])
  2001. else
  2002. if config.mapID == 1 then
  2003. tBattleLevelPlayerList[config.mapID] = tBattleLevelPlayerList[config.mapID] or { }
  2004. if tBattleLevelPlayerList[config.mapID][human.db._id] == nil then
  2005. -- 增加新纪录
  2006. tBattleLevelPlayerList[config.mapID][human.db._id] = { }
  2007. RoleLogic.getRoleBase(human, tBattleLevelPlayerList[config.mapID][human.db._id])
  2008. end
  2009. else
  2010. if not tBattleLevelPlayerList[config.mapID] or not tBattleLevelPlayerList[config.mapID][human.db._id] then
  2011. tBattleLevelPlayerList[config.mapID] = tBattleLevelPlayerList[config.mapID] or { }
  2012. tBattleLevelPlayerList[config.mapID][human.db._id] = { }
  2013. RoleLogic.getRoleBase(human, tBattleLevelPlayerList[config.mapID][human.db._id])
  2014. end
  2015. end
  2016. end
  2017. -- -- 如果过大关卡
  2018. -- if nextBattleConfig and nextBattleConfig.mapID ~= config.mapID then
  2019. -- -- 清除记录
  2020. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID] = BATTLE_LEVEL_PLAYER_LIST[config.mapID] or { }
  2021. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] = nil
  2022. -- -- 增加新纪录
  2023. -- BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID] = BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID] or { }
  2024. -- BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID][human.db._id] = { }
  2025. -- RoleLogic.getRoleBase(human, BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID][human.db._id])
  2026. -- else
  2027. -- if config.mapID == 1 then
  2028. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID] = BATTLE_LEVEL_PLAYER_LIST[config.mapID] or { }
  2029. -- if BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] == nil then
  2030. -- -- 增加新纪录
  2031. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] = { }
  2032. -- RoleLogic.getRoleBase(human, BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id])
  2033. -- end
  2034. -- else
  2035. -- if not BATTLE_LEVEL_PLAYER_LIST[config.mapID] or not BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] then
  2036. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID] = BATTLE_LEVEL_PLAYER_LIST[config.mapID] or { }
  2037. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] = { }
  2038. -- RoleLogic.getRoleBase(human, BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id])
  2039. -- end
  2040. -- end
  2041. -- end
  2042. BattleLogic_SetBattleBattleID(human, nextBattleID)
  2043. -- human.db.battleID = battleID + 1
  2044. -- 通过第10关,默认开启二倍速
  2045. if nextBattleID == 10 and EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  2046. human.db.combatSpeed = 2
  2047. end
  2048. combatInfo.attacker.oldLv = human.db.lv
  2049. -- 给奖励
  2050. combatInfo.rewardItem = { }
  2051. for i = 1, #config.winReward do
  2052. local itemID = config.winReward[i][1]
  2053. local itemCnt = config.winReward[i][2]
  2054. -- 装备不在这显示
  2055. combatInfo.rewardItem[i] = combatInfo.rewardItem[i] or { }
  2056. combatInfo.rewardItem[i] = { itemID, itemCnt }
  2057. BagLogic.addItem(human, itemID, itemCnt, "battle_win")
  2058. end
  2059. combatInfo.attacker.lv = human.db.lv
  2060. combatInfo.getEquip = human.getEquip
  2061. human.getEquip = nil
  2062. -- TODO:记录主线关卡
  2063. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, human.db._id, human.db.account, human.db.name, human.db.battleID)
  2064. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  2065. GuideLogic.onCallback(human)
  2066. JibanLogic.onCallback(human, 1, battleID)
  2067. TuiSongLiBao.tuiSongLiBaoOnTask(
  2068. human,
  2069. TuiSongLiBao.TUISONGLIBAOTASK_ZHENGZHAN,
  2070. -- human.db.guajiID - 1,
  2071. -- human.db.guajiID - 2
  2072. guajiID - 1,
  2073. guajiID - 2
  2074. )
  2075. ChengjiuLogic.onCallback(human, ChengjiuDefine.CJ_TASK_TYPE_1, nextGuajiID)
  2076. MengxinLogic.onCallBack(human, MengxinLogic.MX_TASK_TYPE_1, nextGuajiID)
  2077. for k, v in pairs(KingWorldLogic.funcID) do
  2078. YunYingLogic.updateIcon(KingWorldLogic.YYInfo[k], human)
  2079. break
  2080. end
  2081. -- 存储战斗记录
  2082. local videoUuid = CombatVideo.saveBattleVideo(human.db._id, combatInfo)
  2083. human.db.battleVideoUuid = videoUuid
  2084. BattleDBLogic.updateBattleDB(combatInfo.attacker, battleID, combatInfo, videoUuid, nBattleType)
  2085. if nextBattleConfig and nextBattleConfig.mapID ~= config.mapID then
  2086. -- 新的地图
  2087. -- 通知客户端
  2088. Msg.send(Msg.gc.GC_BATTLE_NODE_SET, human.fd)
  2089. end
  2090. BattleLogic_SetBattleGuaJiID(human, nextGuajiID)
  2091. --human.db.guajiID = nextGuajiID
  2092. if nextBattleConfig then
  2093. setBattleID(human, nextGuajiID)
  2094. end
  2095. local showNext = 1
  2096. -- if BattleExcel.node[human.db.battleID] and human.db.lv < BattleExcel.node[human.db.battleID].needLv then
  2097. if tBattleConfig.node[nextBattleID] and human.db.lv < tBattleConfig.node[nextBattleID].needLv then
  2098. showNext = 2
  2099. end
  2100. if human.db.lv < 5 then
  2101. showNext = 0
  2102. end
  2103. -- nextBattleConfig = BattleExcel.node[human.db.battleID]
  2104. nextBattleConfig = tBattleConfig.node[nextBattleID]
  2105. if not nextBattleConfig then
  2106. showNext = 0
  2107. end
  2108. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1105)
  2109. -- 额外奖励
  2110. local needLevel, itemName = getNextRewardName(human)
  2111. if needLevel ~= nil then
  2112. local tb = { needLevel, Lang.BATTLE_FIGHT_GUAN, "|", itemName, "|", showNext }
  2113. local str = table.concat(tb)
  2114. combatInfo.endParam = str
  2115. else
  2116. local tb = { showNext }
  2117. local str = table.concat(tb)
  2118. combatInfo.endParam = str
  2119. end
  2120. -- 触发事件
  2121. GiftLogic.trigger(human,PRINCIPAL_LINE_EVNET,{id = battleID})
  2122. WarOrder.trigger(human,BATTLE_ORDER_TYPE)
  2123. end
  2124. function setBattleID(human, guajiID)
  2125. local nNowGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2126. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2127. if -1 >= nNowGuaJiID or not tBattleConfig then
  2128. return
  2129. end
  2130. -- if guajiID > human.db.guajiID and human.db.guajiID ~= 0 then
  2131. if guajiID > nNowGuaJiID and nNowGuaJiID ~= 0 then
  2132. -- 下发挂机收益升级提示
  2133. local msgRet = Msg.gc.GC_BATTLE_REWARD_UP
  2134. Grid.makeItem(msgRet.itemExp, ItemDefine.ITEM_EXP_ID, 1)
  2135. Grid.makeItem(msgRet.itemJinbi, ItemDefine.ITEM_JINBI_ID, 1)
  2136. Grid.makeItem(msgRet.itemGreenExp, ItemDefine.ITEM_GREEN_EXP_ID, 1)
  2137. Grid.makeItem(msgRet.itemQingbao, ItemDefine.ITEM_QINGBAO_ID, 1)
  2138. -- local oldConfig = BattleExcel.node[human.db.guajiID]
  2139. -- local newConfig = BattleExcel.node[guajiID]
  2140. local oldConfig = tBattleConfig.node[human.db.guajiID]
  2141. local newConfig = tBattleConfig.node[guajiID]
  2142. msgRet.expOld = oldConfig.hangExp
  2143. msgRet.expNew = newConfig.hangExp
  2144. msgRet.jinbiOld = oldConfig.hangJinbi
  2145. msgRet.jinbiNew = newConfig.hangJinbi
  2146. msgRet.greenExpOld = oldConfig.hangGreenExp
  2147. msgRet.greenExpNew = newConfig.hangGreenExp
  2148. msgRet.qingbaoOld = oldConfig.hangQingbao
  2149. msgRet.qingbaoNew = newConfig.hangQingbao
  2150. Msg.send(msgRet, human.fd)
  2151. end
  2152. -- 刷新排行榜
  2153. BRoleLogic.updateData(BillboardDefine.TYPE_BATTLE, human.db)
  2154. end
  2155. -- GM
  2156. function setBattleByGm(human, val, maxBattleID)
  2157. val = tonumber(val)
  2158. if not val or val <= 1 then
  2159. return
  2160. end
  2161. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2162. if not tBattleConfig then
  2163. return
  2164. end
  2165. local nodeConfig = tBattleConfig.node[val]
  2166. if not nodeConfig then
  2167. return
  2168. end
  2169. if maxBattleID then
  2170. maxBattleID = tonumber(maxBattleID)
  2171. else
  2172. maxBattleID = val
  2173. end
  2174. BattleLogic_SetBattleBattleID(human, val)
  2175. BattleLogic_SetBattleGuaJiID(human, val)
  2176. setBattleID(human, val)
  2177. --human.db.battleID = val
  2178. BattleLogic_QueryDifficulty(human)
  2179. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1105)
  2180. end
  2181. function mopupQuery(human)
  2182. ObjHuman.updateDaily(human)
  2183. local nNowGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2184. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2185. if -1 >= nNowGuaJiID or not tBattleConfig then
  2186. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "mopupQuery 获取战斗配置、挂机ID 失败 id = "
  2187. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  2188. print("[mopupQuery] 获取战斗配置、挂机ID 失败")
  2189. return
  2190. end
  2191. local msgRet = Msg.gc.GC_BATTLE_MOPUP_QUERY
  2192. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  2193. local guajiID = nNowGuaJiID > #tBattleConfig.node and #tBattleConfig.node or nNowGuaJiID
  2194. if guajiID == 0 then
  2195. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_ERR)
  2196. end
  2197. human.db.mopupDoCnt = human.db.mopupDoCnt or 0
  2198. local nextDoCnt = human.db.mopupDoCnt + 1
  2199. -- local nodeConfig = BattleExcel.node[guajiID]
  2200. local nodeConfig = tBattleConfig.node[guajiID]
  2201. local dropID = nodeConfig.dropID
  2202. local dropConfig = DropExcel.dropBattle[dropID]
  2203. local dropCnt = 0
  2204. -- ABS掉落活动显示到第一个
  2205. dropCnt = DropExchangeLogic.getDropItemSaoQuery(human, msgRet, dropCnt)
  2206. for i = 1, #dropConfig.dropRule do
  2207. if dropCnt >= #msgRet.item then
  2208. break
  2209. end
  2210. dropCnt = dropCnt + 1
  2211. local tempConfig = dropConfig.dropRule[i]
  2212. local itemID = tempConfig[1]
  2213. Grid.makeItem(msgRet.item[dropCnt], itemID, 1)
  2214. end
  2215. for i = 1, #dropConfig.dropRule3 do
  2216. if dropCnt >= #msgRet.item then
  2217. break
  2218. end
  2219. dropCnt = dropCnt + 1
  2220. local tempConfig = dropConfig.dropRule3[i]
  2221. local itemID = tempConfig[1]
  2222. Grid.makeItem(msgRet.item[dropCnt], itemID, 1)
  2223. end
  2224. -- local mapConfig = BattleExcel.map[nodeConfig.mapID]
  2225. local mapConfig = tBattleConfig.map[nodeConfig.mapID]
  2226. msgRet.name = mapConfig.name
  2227. msgRet.item[0] = dropCnt
  2228. if TequanShopLogic.isActiveMopup(human) then
  2229. msgRet.leftCnt = BATTLE_MOPUP_CNT_VIP - human.db.mopupDoCnt
  2230. else
  2231. msgRet.leftCnt = BATTLE_MOPUP_CNT - human.db.mopupDoCnt
  2232. end
  2233. -- local mupopExcel = BattleExcel.mupop[nextDoCnt]
  2234. local mupopExcel = tBattleConfig.mupop[nextDoCnt]
  2235. if mupopExcel then
  2236. if not TequanShopLogic.isActiveMopup(human) then
  2237. msgRet.need = mupopExcel.cost
  2238. if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT then
  2239. msgRet.need = 0
  2240. end
  2241. else
  2242. msgRet.need = mupopExcel.vipCost
  2243. if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT_VIP then
  2244. msgRet.need = 0
  2245. end
  2246. end
  2247. else
  2248. msgRet.need = 0
  2249. end
  2250. msgRet.vip = TequanShopLogic.isActiveMopup(human) and 1 or 0
  2251. msgRet.nowCnt = human.db.mopupDoCnt
  2252. msgRet.exp = nodeConfig.hangExp
  2253. msgRet.jinbi = nodeConfig.hangJinbi
  2254. msgRet.greenExp = nodeConfig.hangGreenExp
  2255. msgRet.qingbao = nodeConfig.hangQingbao
  2256. Msg.send(msgRet, human.fd)
  2257. end
  2258. function mopupFight(human)
  2259. -- 等级判断
  2260. ObjHuman.updateDaily(human)
  2261. local nNowGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2262. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2263. if -1 >= nNowGuaJiID or not tBattleConfig then
  2264. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "mopupFight 获取战斗配置、挂机ID 失败 id = "
  2265. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  2266. print("[mopupFight] 获取战斗配置、挂机ID 失败")
  2267. return
  2268. end
  2269. local need = 0
  2270. human.db.mopupDoCnt = human.db.mopupDoCnt or 0
  2271. human.db.mopupFreeCnt = human.db.mopupFreeCnt or 0
  2272. local nextDoCnt = human.db.mopupDoCnt + 1
  2273. -- local mupopExcel = BattleExcel.mupop[nextDoCnt]
  2274. local mupopExcel = tBattleConfig.mupop[nextDoCnt]
  2275. if not mupopExcel then
  2276. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
  2277. end
  2278. if not TequanShopLogic.isActiveMopup(human) then
  2279. if human.db.mopupDoCnt >= BATTLE_MOPUP_CNT then
  2280. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
  2281. end
  2282. need = mupopExcel.cost
  2283. -- 如果免费次数小于1次,则按免费算
  2284. if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT then
  2285. need = 0
  2286. end
  2287. else
  2288. if human.db.mopupDoCnt >= BATTLE_MOPUP_CNT_VIP then
  2289. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
  2290. end
  2291. need = mupopExcel.vipCost
  2292. -- 如果免费次数小于3次,则按免费算
  2293. if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT_VIP then
  2294. need = 0
  2295. end
  2296. end
  2297. if not ObjHuman.checkRMB(human, need) then
  2298. return
  2299. end
  2300. if need <= 0 then
  2301. human.db.mopupFreeCnt = human.db.mopupFreeCnt + 1
  2302. end
  2303. ObjHuman.decZuanshi(human, - need, "battleMopup")
  2304. human.db.mopupDoCnt = human.db.mopupDoCnt + 1
  2305. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  2306. local guajiID = nNowGuaJiID > #tBattleConfig.node and #tBattleConfig.node or nNowGuaJiID
  2307. if guajiID == 0 then
  2308. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_ERR)
  2309. end
  2310. -- local config = BattleExcel.node[guajiID]
  2311. local config = tBattleConfig.node[guajiID]
  2312. local msgRet = Msg.gc.GC_BATTLE_MOPUP_FIGHT
  2313. local vipExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER7) or 0) / 100
  2314. local vipJinAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER8) or 0) / 100
  2315. local vipGreenExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER9) or 0) / 100
  2316. local vipQingbaoAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER19) or 0) / 100
  2317. local exp = config.hangExp * 120
  2318. local jinbi = config.hangJinbi * 120
  2319. local greenExp = config.hangGreenExp * 120
  2320. local qingbao = config.hangQingbao * 120
  2321. local addExp = math.floor(exp *(1 + vipExpAdd))
  2322. local addJinbi = math.floor(jinbi *(1 + vipJinAdd))
  2323. local addGreenExp = math.floor(greenExp *(1 + vipGreenExpAdd))
  2324. local addQingbao = math.floor(qingbao *(1 + vipQingbaoAdd))
  2325. local time = 7200
  2326. local itemTable = getItemOutsByTime(config, time)
  2327. -- 掉落活动
  2328. DropExchangeLogic.getDropItemSao(human, time, itemTable)
  2329. local flag = GuideLogic.getGuideSkip(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_SD)
  2330. if not flag then
  2331. local equipID = SysParameter.getSysParameter(SysParameter.PARAMETER_10)
  2332. itemTable[equipID] = 1
  2333. end
  2334. itemTable[ItemDefine.ITEM_JINBI_ID] = itemTable[ItemDefine.ITEM_JINBI_ID] or 0
  2335. itemTable[ItemDefine.ITEM_EXP_ID] = itemTable[ItemDefine.ITEM_EXP_ID] or 0
  2336. itemTable[ItemDefine.ITEM_GREEN_EXP_ID] = itemTable[ItemDefine.ITEM_GREEN_EXP_ID] or 0
  2337. itemTable[ItemDefine.ITEM_QINGBAO_ID] = itemTable[ItemDefine.ITEM_QINGBAO_ID] or 0
  2338. itemTable[ItemDefine.ITEM_JINBI_ID] = itemTable[ItemDefine.ITEM_JINBI_ID] + addJinbi
  2339. itemTable[ItemDefine.ITEM_EXP_ID] = itemTable[ItemDefine.ITEM_EXP_ID] + addExp
  2340. itemTable[ItemDefine.ITEM_GREEN_EXP_ID] = itemTable[ItemDefine.ITEM_GREEN_EXP_ID] + addGreenExp
  2341. itemTable[ItemDefine.ITEM_QINGBAO_ID] = itemTable[ItemDefine.ITEM_QINGBAO_ID] + addQingbao
  2342. msgRet.item[0] = 0
  2343. -- 双倍日
  2344. local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  2345. local rewardCnt = double and 2 or 1
  2346. for itemID, itemCnt in pairs(itemTable) do
  2347. itemCnt = itemCnt * rewardCnt
  2348. if not ItemDefine.isEquip(itemID) then
  2349. msgRet.item[0] = msgRet.item[0] + 1
  2350. Grid.makeItem(msgRet.item[msgRet.item[0]], itemID, itemCnt)
  2351. end
  2352. BagLogic.addItem(human, itemID, itemCnt, "battle")
  2353. end
  2354. msgRet.item[0] = EquipLogic.makeEquipItem(human, msgRet.item, msgRet.item[0])
  2355. msgRet.double = double and 1 or 0
  2356. msgRet.exp = itemTable[ItemDefine.ITEM_EXP_ID] * rewardCnt
  2357. msgRet.jinbi = itemTable[ItemDefine.ITEM_JINBI_ID] * rewardCnt
  2358. msgRet.greenExp = itemTable[ItemDefine.ITEM_GREEN_EXP_ID] * rewardCnt
  2359. msgRet.qingbao = itemTable[ItemDefine.ITEM_QINGBAO_ID] * rewardCnt
  2360. Msg.send(msgRet, human.fd)
  2361. mopupQuery(human)
  2362. query(human)
  2363. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  2364. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_SD)
  2365. DailyTaskLogic.recordDailyTaskFinishCnt(human, DailyTaskLogic.DAILY_TASK_ID_12, 1)
  2366. ChengjiuLogic.onCallback(human, ChengjiuDefine.CJ_TASK_TYPE_3, 1)
  2367. HeroLogLogic.finishTaskCB(human, HeroLogLogic.HERO_LOG_TYPE_3, 1)
  2368. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2001)
  2369. YunYingLogic.onCallBack(human, "onMopup", 1)
  2370. end
  2371. function updateDaily(human)
  2372. human.db.mopupFreeCnt = 0
  2373. human.db.mopupDoCnt = 0
  2374. end
  2375. function getTongGuanReward(human, id)
  2376. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2377. local nNowGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2378. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2379. if not tBattleConfig or -1 >= nNowGuaJiID or -1 >= nBattleID then
  2380. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getTongGuanReward] 获取战斗配置、挂机ID、战斗节点ID 失败 id = "
  2381. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  2382. print("[getTongGuanReward] 获取战斗配置、挂机ID 失败")
  2383. return
  2384. end
  2385. local cf = tBattleConfig.node[id]
  2386. if not cf then
  2387. return
  2388. end
  2389. if #cf.tongguan < 1 then
  2390. return
  2391. end
  2392. print("[getTongGuanReward] 玩家请求领取奖励 当前的节点信息 id = "
  2393. ..id.." nNowGuaJiID = "..nNowGuaJiID.." nBattleID = "..nBattleID)
  2394. if nBattleID < id then
  2395. return
  2396. end
  2397. if isGetReward(human, id) then
  2398. return
  2399. end
  2400. if #cf.tongguan == 1 and cf.tongguan[1][3] then
  2401. -- 英雄
  2402. if HeroLogic.getEmptyCnt(human) < 1 then
  2403. return Broadcast.sendErr(human, Lang.HERO_BAG_FULL)
  2404. end
  2405. local heroID = cf.tongguan[1][1]
  2406. local cnt = cf.tongguan[1][2]
  2407. local star = cf.tongguan[1][3]
  2408. if cnt <= 0 then
  2409. return
  2410. end
  2411. setGetReward(human, id)
  2412. local msg = Msg.gc.GC_SUIPIAN_SUMMON
  2413. for i = 1, cnt do
  2414. local heroGrid = HeroGrid.createHeroGrid(heroID, star)
  2415. HeroLogic.addHeroByGrid(human, heroGrid, "battle_extra_reward")
  2416. SuipianLogic.makeResultItemData(msg.heroList[i], heroID, 1, 1)
  2417. end
  2418. msg.isHero = 1
  2419. msg.list[0] = 0
  2420. msg.heroList[0] = cnt
  2421. msg.fenJieList[0] = 0
  2422. Msg.send(msg, human.fd)
  2423. else
  2424. setGetReward(human, id)
  2425. BagLogic.addItemList(human, cf.tongguan, "tongguan")
  2426. end
  2427. -- 触发国王君临奖励
  2428. ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE5, id)
  2429. query(human)
  2430. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  2431. if id == 80 then
  2432. KingWorldLogic.setState(human, 1)
  2433. end
  2434. end
  2435. function isDot(human)
  2436. -- 通过大关卡奖励
  2437. local chapterReward = BattleLogic_GetChapterReward(human)
  2438. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2439. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2440. if -1 >= nBattleID or not tBattleExcel or not chapterReward then
  2441. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[isDot] 获取不到对应的大关卡奖励表 或配置表、战斗ID")
  2442. print("[isDot] 获取不到对应的大关卡奖励表 或配置表、战斗ID id = "..human.db._id)
  2443. return
  2444. end
  2445. -- local chapterReward = human.db.chapterReward or { }
  2446. -- local battleID = human.db.battleID
  2447. -- local battleNodeConfig = BattleExcel.node[battleID]
  2448. local battleID = nBattleID
  2449. local battleNodeConfig = tBattleExcel.node[battleID]
  2450. if not battleNodeConfig then
  2451. local nodeCnt = #tBattleExcel.node
  2452. local mapCnt = #tBattleExcel.map
  2453. if battleID == nodeCnt + 1 and not chapterReward[mapCnt] then
  2454. return true
  2455. else
  2456. return false
  2457. end
  2458. else
  2459. local mapID = battleNodeConfig.mapID
  2460. for i = mapID - 1, 1, -1 do
  2461. if not chapterReward[i] then
  2462. return true
  2463. end
  2464. end
  2465. end
  2466. return false
  2467. -- if human.db.lv < 9 then
  2468. -- return false
  2469. -- end
  2470. -- -- 有免费扫荡次数的时候有红点
  2471. -- human.db.mopupFreeCnt = human.db.mopupFreeCnt or 0
  2472. -- if TequanShopLogic.isActiveMopup(human) then
  2473. -- if human.db.mopupFreeCnt < 3 then
  2474. -- return true
  2475. -- end
  2476. -- else
  2477. -- if human.db.mopupFreeCnt < 1 then
  2478. -- return true
  2479. -- end
  2480. -- end
  2481. -- -- 有通关奖励可领取的时候有红点
  2482. -- if hasCanGetReward(human) then
  2483. -- return true
  2484. -- end
  2485. -- -- 战役挂机时间超过1小时的时候有红点
  2486. -- if human.db.battleOut ~= nil then
  2487. -- local now = os.time()
  2488. -- local outSec = now - human.db.battleOut.expTs1
  2489. -- if outSec >= 3600 then
  2490. -- return true
  2491. -- end
  2492. -- end
  2493. -- return false
  2494. end
  2495. function clacItemTwoHours(human)
  2496. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2497. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2498. if not tBattleConfig or -1 >= nGuaJiID then
  2499. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[clacItemTwoHours] 获取到的挂机ID、战斗配置不正确 id = "..human.db._id)
  2500. print("[clacItemTwoHours] 获取到的挂机ID、战斗配置不正确 id = "..human.db._id)
  2501. return
  2502. end
  2503. local items = { }
  2504. local outCnt = math.floor(7200 / BATTLE_HANG_ITEM_OUT_PERIOD)
  2505. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  2506. local guajiID = nGuaJiID > #tBattleConfig.node and #tBattleConfig.node or nGuaJiID
  2507. if guajiID == 0 then
  2508. return items
  2509. end
  2510. -- local nodeConfig = BattleExcel.node[guajiID]
  2511. local nodeConfig = tBattleConfig.node[guajiID]
  2512. local dropID = nodeConfig.dropID
  2513. local dropConfig = DropExcel.dropBattle[dropID]
  2514. local totalWeight = 0
  2515. for i = 1, #dropConfig.dropRule do
  2516. local tempConfig = dropConfig.dropRule[i]
  2517. totalWeight = totalWeight + tempConfig[4]
  2518. end
  2519. for j = 1, outCnt do
  2520. local randomNum = math.random(1, totalWeight)
  2521. for i = 1, #dropConfig.dropRule do
  2522. local tempConfig = dropConfig.dropRule[i]
  2523. local itemID = tempConfig[1]
  2524. local itemCnt1 = tempConfig[2]
  2525. local itemCnt2 = tempConfig[3]
  2526. local itemRate = tempConfig[4]
  2527. if randomNum <= itemRate then
  2528. local realAdd = math.random(itemCnt1, itemCnt2)
  2529. items[itemID] = realAdd
  2530. break
  2531. end
  2532. randomNum = randomNum - itemRate
  2533. end
  2534. end
  2535. return items
  2536. end
  2537. local MailManager = require("mail.MailManager")
  2538. function clacItemCntGM(human, cnt, guajiID)
  2539. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2540. if not tBattleConfig then
  2541. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[clacItemCntGM] 获取到战斗配置不正确 id = "..human.db._id)
  2542. print("[clacItemTwoHours] 获取到的战斗配置不正确 id = "..human.db._id)
  2543. return
  2544. end
  2545. local items = { }
  2546. local outCnt = cnt
  2547. local nodeConfig = tBattleConfig.node[guajiID]
  2548. local dropID = nodeConfig.dropID
  2549. local dropConfig = DropExcel.dropBattle[dropID]
  2550. local totalWeight = 0
  2551. for i = 1, #dropConfig.dropRule do
  2552. local tempConfig = dropConfig.dropRule[i]
  2553. totalWeight = totalWeight + tempConfig[4]
  2554. end
  2555. for j = 1, outCnt do
  2556. local randomNum = math.random(1, totalWeight)
  2557. for i = 1, #dropConfig.dropRule do
  2558. local tempConfig = dropConfig.dropRule[i]
  2559. local itemID = tempConfig[1]
  2560. local itemCnt1 = tempConfig[2]
  2561. local itemCnt2 = tempConfig[3]
  2562. local itemRate = tempConfig[4]
  2563. if randomNum <= itemRate then
  2564. local realAdd = math.random(itemCnt1, itemCnt2)
  2565. items[itemID] = items[itemID] or 0
  2566. items[itemID] = items[itemID] + realAdd
  2567. break
  2568. end
  2569. randomNum = randomNum - itemRate
  2570. end
  2571. end
  2572. local item = { }
  2573. local index = 0
  2574. for k, v in pairs(items) do
  2575. index = index + 1
  2576. item[index] = { k, v }
  2577. end
  2578. MailManager.add(MailManager.SYSTEM, human.db._id, "", "", item, "")
  2579. end
  2580. function getBattleID(human)
  2581. local num = 0
  2582. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2583. if -1 < nGuaJiID then
  2584. num = nGuaJiID
  2585. end
  2586. -- if human.db.guajiID then
  2587. -- num = human.db.guajiID or 0
  2588. -- end
  2589. return num
  2590. end
  2591. --------------------------------------------- combat ----------------------------------------------
  2592. function getCombatMonsterOutID(human, side)
  2593. if side ~= CombatDefine.DEFEND_SIDE then
  2594. return
  2595. end
  2596. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2597. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2598. if not tBattleExcel or -1 >= nBattleID then
  2599. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getCombatMonsterOutID] 获取到的战斗配置、或战斗ID不正确 id = "..human.db._id)
  2600. print("[getCombatMonsterOutID] 获取到的战斗配置、或战斗ID不正确 id = "..human.db._id)
  2601. return
  2602. end
  2603. -- local config = BattleExcel.node[human.db.battleID]
  2604. local config = tBattleExcel.node[nBattleID]
  2605. if not config then
  2606. return
  2607. end
  2608. return config.monsterOutID
  2609. end
  2610. function getCombatName(human)
  2611. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2612. if -1 >= nBattleID then
  2613. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getCombatMonsterOutID] 获取到的战斗ID不正确 id = "..human.db._id)
  2614. print("[getCombatMonsterOutID] 获取到的战斗ID不正确 id = "..human.db._id)
  2615. return ""
  2616. end
  2617. local name = getBattleName(human, nBattleID)
  2618. return Util.format(Lang.COMBAT_BATTLE_EXNAME, name)
  2619. end
  2620. -------------------------------------------combat end--------------------
  2621. function battleSharkQuery(human, nodeID)
  2622. local msgRet = Msg.gc.GC_BATTLE_SHARK_QUERY
  2623. local videoTb = BattleDBLogic.queryBattleDbByNodeID(nodeID)
  2624. if videoTb == nil then
  2625. msgRet.battleShark[0] = 0
  2626. else
  2627. local len = #videoTb.shark
  2628. for i = 1, len do
  2629. local v = videoTb.shark[i]
  2630. RoleLogic.makeRoleBase(v.roleBase, msgRet.battleShark[i].roleBase)
  2631. msgRet.battleShark[i].type = i
  2632. msgRet.battleShark[i].videoUuid = v.videoUuid
  2633. msgRet.battleShark[i].param = v.param or 0
  2634. end
  2635. msgRet.battleShark[0] = len
  2636. end
  2637. -- Msg.trace(msgRet)
  2638. Msg.send(msgRet, human.fd)
  2639. end
  2640. local QueryRoleByNodeID = { }
  2641. function worldMapRoleListQuery(human, worldMapId)
  2642. -- if worldMapId == 1 then return end
  2643. local msgRet = Msg.gc.GC_BATTLE_WORLD_MAP_ROLELIST_QUERY
  2644. local len = 0
  2645. for k, v in pairs(BATTLE_LEVEL_PLAYER_LIST[worldMapId]) do
  2646. len = len + 1
  2647. RoleLogic.makeRoleBase(v, msgRet.roleList[len])
  2648. if len >= 50 then
  2649. break
  2650. end
  2651. end
  2652. msgRet.roleList[0] = len
  2653. Msg.send(msgRet, human.fd)
  2654. end
  2655. -- 章节(地图)掉落列表
  2656. function sendMapDroItemsList(human)
  2657. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2658. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2659. if not tBattleExcel then
  2660. print("[sendMapDroItemsList] 获取当前战斗配置失败 id = "..human.db._id)
  2661. return
  2662. end
  2663. local battleID = 1
  2664. if -1 < nBattleID then
  2665. battleID = nBattleID
  2666. end
  2667. local maxBattleConfig = tBattleExcel.node[battleID]
  2668. local maxMapID = maxBattleConfig and maxBattleConfig.mapID or(#tBattleExcel.node + 1)
  2669. local msgRet = Msg.gc.GC_BATTLE_MAP_DROPITEMS_LIST
  2670. msgRet.list[0] = 0
  2671. for mapID, mapConfig in ipairs(tBattleExcel.map) do
  2672. msgRet.list[0] = msgRet.list[0] + 1
  2673. local net = msgRet.list[msgRet.list[0]]
  2674. net.mapID = mapID
  2675. net.mapName = mapConfig.name
  2676. net.isOpen =(mapID <= maxMapID) and 1 or 0
  2677. end
  2678. -- Msg.trace(msgRet)
  2679. Msg.send(msgRet, human.fd)
  2680. end
  2681. -- 章节(地图)掉落详情
  2682. function sendMapDroItemsDetail(human, mapID)
  2683. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2684. if not tBattleExcel then
  2685. print("[sendMapDroItemsDetail] 获取当前战斗配置失败 id = "..human.db._id)
  2686. return
  2687. end
  2688. local mapConfig = tBattleExcel.map[mapID]
  2689. if not mapConfig then
  2690. return
  2691. end
  2692. local msgRet = Msg.gc.GC_BATTLE_MAP_DROPITEMS_DETAIL
  2693. msgRet.mapID = mapID
  2694. msgRet.items[0] = math.min(#mapConfig.dropItemsShow, #msgRet.items)
  2695. for i = 1, msgRet.items[0] do
  2696. local itemID = mapConfig.dropItemsShow[i][1]
  2697. local itemCnt = mapConfig.dropItemsShow[i][2]
  2698. Grid.makeItem(msgRet.items[i], itemID, itemCnt)
  2699. end
  2700. -- Msg.trace(msgRet)
  2701. Msg.send(msgRet, human.fd)
  2702. end
  2703. -- 获取当前战役的 怪物ID
  2704. function getBattleMonsterOutID(human)
  2705. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2706. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2707. if -1 >= nBattleID or not tBattleExcel then
  2708. print("[getBattleMonsterOutID] 获取当前战斗ID、配置失败 id = "..human.db._id)
  2709. return 0
  2710. end
  2711. -- local battleID = human.db.battleID
  2712. -- local config = BattleExcel.node[battleID]
  2713. local config = tBattleExcel.node[nBattleID]
  2714. return config.monsterOutID
  2715. end
  2716. function onUpdatePos(human)
  2717. BRoleLogic.updateData(BillboardDefine.TYPE_ZHANDOULI, human.db)
  2718. end
  2719. function getNextRewardName(human)
  2720. local guajiID = BattleLogic_GetBattleGuaJiID(human)
  2721. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2722. if not tBattleConfig or -1 >= guajiID then
  2723. return nil, nil
  2724. end
  2725. -- for i = human.db.guajiID + 1, #BattleExcel.node do
  2726. for i = guajiID + 1, #tBattleConfig.node do
  2727. if #tBattleConfig.node[i].tongguan > 0 then
  2728. local itemID = tBattleConfig.node[i].tongguan[1][1]
  2729. local itemConfig = ItemDefine.getConfig(itemID)
  2730. if itemConfig == nil then
  2731. return
  2732. else
  2733. return i - guajiID, itemConfig.name
  2734. end
  2735. end
  2736. end
  2737. end
  2738. --[[
  2739. 通关章节后领取奖励
  2740. ]]
  2741. function battleChapterReward(human, mapID)
  2742. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2743. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2744. local tChapterReward = BattleLogic_GetChapterReward(human)
  2745. if not tBattleConfig or -1 >= nBattleID or not tChapterReward then
  2746. print("[battleChapterReward] 获取到的战斗ID、配置、通关章节奖励表 不正确 id = "..human.db._id)
  2747. return
  2748. end
  2749. local mapConf = tBattleConfig.map[mapID]
  2750. if not mapConf then
  2751. return
  2752. end
  2753. -- 没有通过当前大关卡
  2754. local battleID = nBattleID
  2755. local battleNodeConfig = tBattleConfig.node[battleID]
  2756. local roleMapId
  2757. if not battleNodeConfig then
  2758. if battleID ~= #tBattleConfig.node + 1 then
  2759. return
  2760. else
  2761. roleMapId = #tBattleConfig.map
  2762. end
  2763. else
  2764. roleMapId = battleNodeConfig.mapID
  2765. end
  2766. if mapID > roleMapId then
  2767. return
  2768. end
  2769. -- if not human.db.chapterReward then
  2770. -- human.db.chapterReward = { }
  2771. -- end
  2772. -- 判断是否已经领取了当前大关卡的奖励
  2773. -- local chapterReward = human.db.chapterReward
  2774. local chapterReward = tChapterReward
  2775. if chapterReward[mapID] then
  2776. return Broadcast.sendErr(human, Lang.FRIEND_HEART_GET_HAD)
  2777. end
  2778. chapterReward[mapID] = true
  2779. ObjHuman.save(human)
  2780. local reward = mapConf.reward
  2781. BagLogic.addItemList(human, reward, "chapterReward")
  2782. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1105)
  2783. local msgRet = Msg.gc.GC_BATTLE_CHAPTER_REWARD
  2784. msgRet.mapID = mapID
  2785. Msg.send(msgRet, human.fd)
  2786. end
  2787. -- 判断难度是否解锁
  2788. local function BattleLogic_CheckDiffIsOK(human, nSelectDiff)
  2789. -- 默认难度直接通过
  2790. if EliteDefine.COPY_ELITE_NORMAL == nSelectDiff then
  2791. return EliteDefine.COPY_SELECT_SUCC
  2792. end
  2793. -- 等级不够
  2794. if human.db.lv < EliteDefine.COPY_ELITE_ULEV then
  2795. return EliteDefine.COPY_SELECT_LEV
  2796. end
  2797. local nChoseBattleID = (EliteDefine.COPY_LEVEL_ELITE == nSelectDiff) and human.db.battleID or human.db.battleID_elite
  2798. return nChoseBattleID > EliteDefine.COPY_ELITE_LEVEL and EliteDefine.COPY_SELECT_SUCC or EliteDefine.COPY_SELECT_MAIN
  2799. end
  2800. -- 获取未领取奖励
  2801. local function BattleLogic_GetNorewardReceived(human, nBattleType, cIndex)
  2802. print("1:[BattleLogic_GetNorewardReceived] id = "..human.db._id.." nBattleType = "..nBattleType)
  2803. local nBattleID = BattleLogic_GetBattleIDByType(human, nBattleType)
  2804. local tBattleConfig = BattleLogic_GetBattleConfigByType(nBattleType)
  2805. local nGuaJiID = BattleLogic_GetBattleGuaJiIDByType(human, nBattleType)
  2806. if -1 >= nBattleID or not tBattleConfig or -1 >= nGuaJiID then
  2807. print("[BattleLogic_GetNorewardReceived] 获取配置失败")
  2808. return
  2809. end
  2810. local msgRet = Msg.gc.GC_BATTLE_QUERY_ALL
  2811. msgRet.index = nBattleType
  2812. msgRet.list[0] = 0
  2813. msgRet.isEnd = 0
  2814. msgRet.curIndex = 0
  2815. local curIndex = 1
  2816. -- human.db.battleID = human.db.battleID or 1
  2817. -- if human.db.battleID == 0 then
  2818. -- human.db.battleID = 1
  2819. -- end
  2820. human.db.mopupDoCnt = human.db.mopupDoCnt or 0
  2821. local curBattleNumber = cIndex
  2822. local curTotalNumber = 0
  2823. local battleNumber = #tBattleConfig.node
  2824. -- local nGuajiID = human.db.guajiID or 0
  2825. print("[BattleLogic_GetNorewardReceived] nGuajiID = "..nGuaJiID.. " nBattleID = "..nBattleID)
  2826. -- 判断ID得用战斗ID-1, 因为挂机ID可以设置
  2827. local nJudeNum = nGuaJiID
  2828. if nGuaJiID ~= nBattleID then
  2829. if nGuaJiID + 1 < nBattleID then
  2830. nJudeNum = nBattleID - 1
  2831. end
  2832. end
  2833. print("[BattleLogic_GetNorewardReceived] nJudeNum = "..nJudeNum)
  2834. for k,v in ipairs(tBattleConfig.node) do
  2835. if #v.tongguan ~= 0 then
  2836. -- 领取状态
  2837. local state = false
  2838. if k <= nJudeNum then
  2839. state = isGetRewardByType(human, k, nBattleType)
  2840. end
  2841. if not (state == true) then
  2842. local r = STATUS_CANGET
  2843. --(k > nGuaJiID) and STATUS_CANGET or STATUS_NONE
  2844. --未领取
  2845. if r == STATUS_CANGET then
  2846. curTotalNumber = curTotalNumber + 1
  2847. if curTotalNumber > curBattleNumber then
  2848. --构造
  2849. local cf = tBattleConfig.node[k].tongguan
  2850. local net = msgRet.list[curIndex]
  2851. net.status = k <= nJudeNum and STATUS_CANGET or STATUS_NONE
  2852. net.levelName = getBattleNameByType(k, nBattleType)
  2853. net.index = k
  2854. net.nowBattle = getBattleNameByType(nJudeNum, nBattleType)
  2855. net.reward[0] = 0
  2856. net.heroReward[0] = 0
  2857. if cf[1][3] then
  2858. net.heroReward[0] = 1
  2859. local other = { }
  2860. other.star = cf[1][3]
  2861. HeroGrid.makeHeroSimpleByID(net.heroReward[1], cf[1][1], nil, other, human)
  2862. HeroGrid.makeHeroSimpleByGeneral(net.heroReward[1], cf[1][1])
  2863. local tHeroInfo = Util.printTable(net.heroReward)
  2864. -- print("[BattleLogic_GetNorewardReceived] 英雄数据 k = "..k.." 获取的数据 = "..tHeroInfo)
  2865. else
  2866. net.reward[0] = 1
  2867. for i = 1, net.reward[0] do
  2868. local itemID = cf[i][1]
  2869. local itemCnt = cf[i][2]
  2870. Grid.makeItem(net.reward[i], itemID, itemCnt)
  2871. end
  2872. end
  2873. curIndex = curIndex + 1
  2874. msgRet.list[0] = msgRet.list[0] + 1
  2875. if msgRet.list[0] >= 15 then
  2876. local ret = 0
  2877. if k < battleNumber then
  2878. for kk, vv in ipairs(tBattleConfig.node) do
  2879. if kk > k then
  2880. if v.tongguan ~= 0 then
  2881. local nNextstate = isGetRewardByType(human,kk, nBattleType)
  2882. if not (nNextstate == true) then
  2883. local rr =(kk > nGuaJiID) and STATUS_CANGET or STATUS_NONE
  2884. --未领取
  2885. if rr == STATUS_CANGET then
  2886. ret = 1
  2887. break
  2888. end
  2889. end
  2890. end
  2891. end
  2892. end
  2893. end
  2894. if ret == 1 then
  2895. --没有结束
  2896. msgRet.isEnd = 0
  2897. else
  2898. msgRet.isEnd = 1
  2899. end
  2900. msgRet.curIndex=curTotalNumber
  2901. -- curIndex = 1
  2902. Msg.send(msgRet, human.fd)
  2903. print("[BattleLogic_GetNorewardReceived] send client msgRet.curIndex:"..msgRet.curIndex.." msgRet.isEnd:"..msgRet.isEnd.." msgRet.list[0]:"..msgRet.list[0])
  2904. --local info=Util.printTable(msgRet)
  2905. --print("getNorewardReceived0->>:"..info)
  2906. return
  2907. end
  2908. end
  2909. end
  2910. else
  2911. print("[BattleLogic_GetNorewardReceived] 奖励已领取:"..k)
  2912. end
  2913. end
  2914. end
  2915. --结束
  2916. msgRet.isEnd = 1
  2917. msgRet.curIndex=0
  2918. Msg.send(msgRet, human.fd)
  2919. end
  2920. -- 客户端请求查询难度
  2921. function CG_ELITE_OPEN(human)
  2922. BattleLogic_QueryDifficulty(human)
  2923. end
  2924. -- 客户端请求切换难度
  2925. function CG_ELITE_SELECT(human, nSelectDiff)
  2926. if EliteDefine.COPY_ELITE_NORMAL > nSelectDiff or EliteDefine.COPY_ELITE_DIFFICULTY < nSelectDiff then
  2927. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[CG_ELITE_SELECT] 客户端传入的参数不正确 id = "..human.db._id .. "nSelectDiff = "..nSelectDiff)
  2928. print("[CG_ELITE_SELECT] 客户端选择难度,上传的难度不正确 id = "..human.db._id .. "nSelectDiff = "..nSelectDiff)
  2929. return
  2930. end
  2931. local nStatus = BattleLogic_CheckDiffIsOK(human, nSelectDiff)
  2932. print("[CG_ELITE_SELECT] nStatus = "..nStatus.. " 选择的难度 nSelectDiff = "..nSelectDiff)
  2933. -- 设置类型
  2934. if EliteDefine.COPY_SELECT_SUCC == nStatus then
  2935. BattleLogic_SetBattleType(human,nSelectDiff)
  2936. end
  2937. local msgRet = Msg.gc.GC_ELITE_SELECT
  2938. msgRet.status = nStatus
  2939. Msg.send(msgRet,human.fd)
  2940. end
  2941. -- 客户端请求领取奖励
  2942. function CG_BATTLE_TONGGUAN_REWARD_GET_COPY(human, nBattleType, nBattleID)
  2943. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2944. local nGuaJiID = BattleLogic_GetBattleGuaJiIDByType(human, nBattleType)
  2945. if not tBattleConfig or -1 >= nGuaJiID then
  2946. return
  2947. end
  2948. local tMsgRet = Msg.gc.GC_BATTLE_TONGGUAN_REWARD_GET_COPY
  2949. local tConfig = tBattleConfig.node[nBattleID].tongguan
  2950. if #tConfig < 1 then
  2951. tMsgRet.status = 0
  2952. Msg.send(tMsgRet, human.fd)
  2953. return
  2954. end
  2955. tMsgRet.status = 1
  2956. getTongGuanReward(human, nBattleID)
  2957. tMsgRet.tongguan[0] = 0
  2958. if #tConfig ~= 0 then
  2959. tMsgRet.tongguan[0] = 1
  2960. local tNet = tMsgRet.tongguan[1]
  2961. tNet.status = STATUS_NONE
  2962. tNet.levelName = getBattleNameByType(nBattleID, nBattleType)
  2963. tNet.index = nBattleID
  2964. tNet.nowBattle = getBattleNameByType(nGuaJiID, nBattleType)
  2965. tNet.reward[0] = 0
  2966. tNet.heroReward[0] = 0
  2967. if tConfig[1][3] then
  2968. tNet.heroReward[0] = 1
  2969. local other = { }
  2970. other.star = tConfig[1][3]
  2971. HeroGrid.makeHeroSimpleByID(tNet.heroReward[1], tConfig[1][1], nil, other, human)
  2972. HeroGrid.makeHeroSimpleByGeneral(tNet.heroReward[1], tConfig[1][1])
  2973. else
  2974. tNet.reward[0] = 1
  2975. for i = 1, tNet.reward[0] do
  2976. local itemID = tConfig[i][1]
  2977. local itemCnt = tConfig[i][2]
  2978. Grid.makeItem(tNet.reward[i], itemID, itemCnt)
  2979. end
  2980. end
  2981. end
  2982. Msg.send(tMsgRet, human.fd)
  2983. end
  2984. -- 客户端请求查询所有未领取奖励
  2985. function CG_BATTLE_QUERY_ALL(human, nBattleType, curIndex)
  2986. if EliteDefine.COPY_ELITE_NORMAL > nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  2987. print("[CG_BATTLE_QUERY_ALL] 客户端请求的战斗类型不正确 id = "..human.db._id.." nType = "..nBattleType)
  2988. return
  2989. end
  2990. BattleLogic_GetNorewardReceived(human, nBattleType, curIndex)
  2991. end
  2992. -- 判断是否是最后一关
  2993. function BattleLogic_IsLastLevels(human, nBattleType)
  2994. local tBattleConfig = BattleLogic_GetBattleConfigByType(nBattleType)
  2995. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2996. if not tBattleConfig or -1 >= nBattleID then
  2997. return false
  2998. end
  2999. local nNodeLen = #tBattleConfig.node
  3000. return nBattleID == nNodeLen
  3001. end