BattleLogic.lua 129 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410
  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_SetBattleGuaJiID 参数不正确")
  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_SetBattleGuaJiID 获取到的战斗类型不正确 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. if not attrID then
  1013. print("[fontVideoInfo] 获取到的 attrID 为空 k = "..k)
  1014. else
  1015. print("[fontVideoInfo] 获取到的 attrID k = "..k.." attrID = "..attrID)
  1016. end
  1017. local attrConfig = MonsterExcel.monsterAttr[attrID].attrs
  1018. if not attrConfig then
  1019. print("[fontVideoInfo] 根据attrID获取到的 attrConfig 为空 k = "..k.. " attrID = "..attrID)
  1020. end
  1021. for _, value in pairs(attrConfig) do
  1022. if value[1] == RoleDefine.HP then
  1023. net.enemyBody[cnt].hp = value[2]
  1024. break
  1025. end
  1026. end
  1027. end
  1028. end
  1029. net.enemyBody[0] = cnt
  1030. end
  1031. end
  1032. -- 战役主界面查询
  1033. function query(human)
  1034. local msgRet = Msg.gc.GC_BATTLE_QUERY
  1035. local nNowBattleID = BattleLogic_GetBattleBattleID(human)
  1036. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1037. local nNowGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  1038. if -1 >= nNowBattleID or not tBattleConfig or -1 >= nNowGuaJiID then
  1039. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[query] 获取到的战斗ID或奖励配置不正确")
  1040. print("[query] 获取到的战斗ID或奖励配置不正确 id = "..human.db._id)
  1041. return
  1042. end
  1043. print("[BattleLogic query] nNowGuaJiID ="..nNowGuaJiID.." nNowBattleID ="..nNowBattleID)
  1044. msgRet.nowBattleID = nNowBattleID
  1045. local configNode = #tBattleConfig.node
  1046. if nNowBattleID > configNode then
  1047. print("[query] 玩家的战斗ID不正确,进行纠正 nNowBattleID = "..nNowBattleID.." 最大战斗ID = "..configNode)
  1048. nNowBattleID = configNode
  1049. BattleLogic_SetBattleBattleID(human, nNowBattleID)
  1050. end
  1051. if nNowGuaJiID > configNode then
  1052. print("[query] 玩家的挂机ID不正确,进行纠正 nNowGuaJiID = "..nNowGuaJiID.." 最大挂机ID = "..configNode)
  1053. nNowGuaJiID = configNode
  1054. BattleLogic_SetBattleGuaJiID(human, nNowGuaJiID)
  1055. end
  1056. -- local nowBattleID = human.db.battleID > configNode and configNode or human.db.battleID
  1057. local nowNodeConfig = tBattleConfig.node[nNowBattleID]
  1058. if not nowNodeConfig then
  1059. print("[query] 不存在对应的当前战斗ID对应的配置 nNowBattleID = ", nNowBattleID)
  1060. return
  1061. end
  1062. local nowMapConfig = tBattleConfig.map[nowNodeConfig.mapID]
  1063. if not nowMapConfig then
  1064. print("[query] 不存在对应的当前地图对应的地图配置 nNowBattleID = "
  1065. ..nNowBattleID.." mapID ="..nowNodeConfig.mapID)
  1066. return
  1067. end
  1068. msgRet.maxBattleID = configNode
  1069. msgRet.mapID = nowNodeConfig.mapID
  1070. msgRet.nodeID = nowNodeConfig.curLevel
  1071. msgRet.sceneID = nowNodeConfig.sceneID
  1072. msgRet.mapName = nowMapConfig.name
  1073. msgRet.nodeName = nowNodeConfig.name
  1074. msgRet.needLv = nowNodeConfig.needLv
  1075. msgRet.bg = nowMapConfig.bg
  1076. msgRet.canBattle = 0
  1077. msgRet.doubleCnt = 0
  1078. if nowNodeConfig.needLv > human.db.lv then
  1079. msgRet.canBattle = nowNodeConfig.needLv
  1080. end
  1081. local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_1104)
  1082. if
  1083. double and human.db.bar and human.db.bar.doubleCnt and
  1084. human.db.bar.doubleCnt <= BarTaskLogic.DEFAULT_MAX_DOUBLE_CNT
  1085. then
  1086. msgRet.doubleCnt = BarTaskLogic.DEFAULT_MAX_DOUBLE_CNT - human.db.bar.doubleCnt
  1087. elseif double and not human.db.bar then
  1088. msgRet.doubleCnt = BarTaskLogic.DEFAULT_MAX_DOUBLE_CNT
  1089. end
  1090. msgRet.tongguan[0] = 0
  1091. local id = getTongguanIndex(human)
  1092. if id == nil then
  1093. msgRet.tongguan[0] = 0
  1094. else
  1095. msgRet.tongguan[0] = 1
  1096. local state = isGetReward(human, id)
  1097. local cf = tBattleConfig.node[id].tongguan
  1098. local net = msgRet.tongguan[1]
  1099. if state == true then
  1100. net.status = STATUS_NONE
  1101. else
  1102. net.status =(id > nNowGuaJiID) and STATUS_CANGET or STATUS_NONE
  1103. end
  1104. net.levelName = getBattleName(human,id)
  1105. net.index = id
  1106. net.nowBattle = getBattleName(human,nNowGuaJiID)
  1107. net.reward[0] = 0
  1108. net.heroReward[0] = 0
  1109. -- 是英雄
  1110. if cf[1][3] then
  1111. net.heroReward[0] = 1
  1112. local other = { }
  1113. other.star = cf[1][3]
  1114. HeroGrid.makeHeroSimpleByID(net.heroReward[1], cf[1][1], nil, other, human)
  1115. HeroGrid.makeHeroSimpleByGeneral(net.heroReward[1], cf[1][1])
  1116. else
  1117. net.reward[0] = 1
  1118. for i = 1, net.reward[0] do
  1119. local itemID = cf[i][1]
  1120. local itemCnt = cf[i][2]
  1121. Grid.makeItem(net.reward[i], itemID, itemCnt)
  1122. end
  1123. end
  1124. end
  1125. local outSec = 0
  1126. local tBattleOut = BattleLogic_GetBattleOut(human)
  1127. --if human.db.battleOut ~= nil then
  1128. if tBattleOut ~= nil then
  1129. local now = os.time()
  1130. outSec = now - tBattleOut.expTs1
  1131. end
  1132. local maxHangTime = getHangMaxTime(human)
  1133. msgRet.maxTime = maxHangTime
  1134. if maxHangTime >= outSec then
  1135. msgRet.time = outSec
  1136. else
  1137. msgRet.time = maxHangTime
  1138. end
  1139. -- 悬赏情报数量
  1140. msgRet.xushang = human.db.bar and human.db.bar.qingbao or 0
  1141. msgRet.xushangMax = RoleExcel.exp[human.db.lv].qingBaoMax
  1142. -- 悬赏红点
  1143. msgRet.xsDot = 0
  1144. if BarTaskLogic.isDot(human) then
  1145. msgRet.xsDot = 1
  1146. end
  1147. msgRet.canMopup = 0
  1148. if TequanShopLogic.isActiveMopup(human) then
  1149. msgRet.canMopup = human.db.mopupDoCnt < BATTLE_MOPUP_CNT_VIP and 1 or 0
  1150. else
  1151. msgRet.canMopup = human.db.mopupDoCnt < BATTLE_MOPUP_CNT and 1 or 0
  1152. end
  1153. local monsterOutId = nowNodeConfig.monsterOutID
  1154. if not monsterOutId then
  1155. print("[BattleLogic query] monsterOutId 为空")
  1156. else
  1157. print("[BattleLogic query] monsterOutId 的值为 = "..monsterOutId)
  1158. end
  1159. local monsterConfig = MonsterExcel.monsterOut[monsterOutId]
  1160. if not monsterConfig then
  1161. print("[BattleLogic query] 获取到的 monsterConfig 为空 monsterOutId = "..monsterOutId)
  1162. return
  1163. else
  1164. print("[BattleLogic query] 获取到的 monsterConfig 存在 monsterOutId = "..monsterOutId)
  1165. end
  1166. fontVideoInfo(human, msgRet.videoInfo, monsterConfig)
  1167. fontExtraDataSSZH(msgRet.extraDataSSZH, nowNodeConfig.mapID, nNowBattleID, human)
  1168. -- Msg.trace(msgRet)
  1169. Msg.send(msgRet, human.fd)
  1170. hangFightQuery(human)
  1171. end
  1172. -- 获取当前地图ID
  1173. function getMapID(human, args)
  1174. local msgRet = Msg.gc.GC_BATTLE_QUERY
  1175. local nNowBattleID = BattleLogic_GetBattleBattleID(human)
  1176. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1177. if -1 >= nNowBattleID or not tBattleConfig then
  1178. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getMapID] 获取到的战斗ID或奖励配置不正确")
  1179. print("[getMapID] 获取到的战斗ID或奖励配置不正确 id = "..human.db._id)
  1180. return
  1181. end
  1182. -- local battleID = human.db.battleID
  1183. -- local config = BattleExcel.node[battleID]
  1184. local config = tBattleConfig.node[nNowBattleID]
  1185. if not config then
  1186. return
  1187. end
  1188. local mapConfig = tBattleConfig.map[config.mapID]
  1189. if not mapConfig then
  1190. return
  1191. end
  1192. return config.sceneID
  1193. end
  1194. -- 战役挂机界面查询
  1195. function onHookQuery(human)
  1196. local msgRet = Msg.gc.GC_BATTLE_HANG_QUERY
  1197. calcBattleOut(human)
  1198. local tBattleOut = BattleLogic_GetBattleOut(human)
  1199. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1200. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  1201. if not tBattleConfig or 0 > nGuaJiID or not tBattleOut then
  1202. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[onHookQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、挂机ID不正确 id = "..human.db._id)
  1203. print("[onHookQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、挂机ID不正确 id = "..human.db._id)
  1204. return
  1205. end
  1206. -- local expAdd = human.db.battleOut.exp
  1207. -- local jinbiAdd = human.db.battleOut.jinbi
  1208. -- local greenExpAdd = human.db.battleOut.greenExp
  1209. -- local qingbaoAdd = human.db.battleOut.qingbao
  1210. local expAdd = tBattleOut.exp
  1211. local jinbiAdd = tBattleOut.jinbi
  1212. local greenExpAdd = tBattleOut.greenExp
  1213. local qingbaoAdd = tBattleOut.qingbao
  1214. local skip = GuideLogic.getGuideSkip(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_EXP)
  1215. if not skip then
  1216. expAdd = 1510
  1217. end
  1218. local items = { }
  1219. local len = #items
  1220. local tempTable = { }
  1221. if tBattleOut.items then
  1222. tempTable = Util.copyTable(tBattleOut.items)
  1223. end
  1224. tempTable[ItemDefine.ITEM_EXP_ID] = tempTable[ItemDefine.ITEM_EXP_ID] or 0
  1225. tempTable[ItemDefine.ITEM_EXP_ID] = expAdd
  1226. tempTable[ItemDefine.ITEM_JINBI_ID] = tempTable[ItemDefine.ITEM_JINBI_ID] or 0
  1227. tempTable[ItemDefine.ITEM_JINBI_ID] = jinbiAdd
  1228. tempTable[ItemDefine.ITEM_GREEN_EXP_ID] = tempTable[ItemDefine.ITEM_GREEN_EXP_ID] or 0
  1229. tempTable[ItemDefine.ITEM_GREEN_EXP_ID] = greenExpAdd
  1230. tempTable[ItemDefine.ITEM_QINGBAO_ID] = tempTable[ItemDefine.ITEM_QINGBAO_ID] or 0
  1231. tempTable[ItemDefine.ITEM_QINGBAO_ID] = qingbaoAdd
  1232. local list = DropExchangeLogic.getAbsCanDrop(human)
  1233. if list then
  1234. for k, v in pairs(list) do
  1235. if tempTable[k] and tempTable[k] > 0 then
  1236. len = len + 1
  1237. items[len] = { }
  1238. items[len].id = k
  1239. items[len].cnt = tempTable[k]
  1240. end
  1241. end
  1242. end
  1243. for k, v in pairs(tempTable) do
  1244. if not list or not list[k] then
  1245. len = len + 1
  1246. items[len] = { }
  1247. items[len].id = k
  1248. items[len].cnt = v
  1249. end
  1250. end
  1251. -- 发消息
  1252. local guajiID = nGuaJiID > #tBattleConfig.node and #tBattleConfig.node or nGuaJiID
  1253. if guajiID == 0 then
  1254. return Broadcast.sendErr(human, Lang.BATTLE_GUAJI_ERR)
  1255. end
  1256. local nodeConfig = tBattleConfig.node[guajiID]
  1257. local now = os.time()
  1258. local outSec = now - human.db.battleOut.expTs1
  1259. local maxHangTime = getHangMaxTime(human)
  1260. local idx = 1
  1261. for i = 1, #items do
  1262. Grid.makeItem(msgRet.items[i], items[i].id, items[i].cnt)
  1263. end
  1264. local len = #items
  1265. if human.db.battleOut.equip then
  1266. for k, equipGrid in ipairs(tBattleOut.equip) do
  1267. if len >= 10 then
  1268. msgRet.items[0] = len
  1269. msgRet.isEnd = 0
  1270. msgRet.index = idx
  1271. msgRet.maxTime = maxHangTime
  1272. if maxHangTime >= outSec then
  1273. msgRet.time = outSec
  1274. else
  1275. msgRet.time = maxHangTime
  1276. end
  1277. local minHour = math.floor(msgRet.time / HOUR_SEC)
  1278. minHour = (minHour ~= 0) and minHour or 1
  1279. msgRet.diamond = minHour * DIAMOND_COST_PER_HOUR
  1280. msgRet.exp = nodeConfig.hangExp
  1281. msgRet.jinbi = nodeConfig.hangJinbi
  1282. msgRet.greenExp = nodeConfig.hangGreenExp
  1283. msgRet.qingbao = nodeConfig.hangQingbao or 0
  1284. Msg.send(msgRet, human.fd)
  1285. len = 0
  1286. idx = idx + 1
  1287. msgRet = Msg.gc.GC_BATTLE_HANG_QUERY
  1288. end
  1289. len = len + 1
  1290. Grid.makeItem(msgRet.items[len], equipGrid.id, 1, nil, equipGrid)
  1291. end
  1292. end
  1293. msgRet.isEnd = 1
  1294. msgRet.index = idx
  1295. msgRet.items[0] = len
  1296. msgRet.maxTime = maxHangTime
  1297. if maxHangTime >= outSec then
  1298. msgRet.time = outSec
  1299. else
  1300. msgRet.time = maxHangTime
  1301. end
  1302. local minHour = math.floor(msgRet.time / HOUR_SEC)
  1303. minHour = (minHour ~= 0) and minHour or 1
  1304. msgRet.diamond = minHour * DIAMOND_COST_PER_HOUR
  1305. msgRet.exp = nodeConfig.hangExp
  1306. msgRet.jinbi = nodeConfig.hangJinbi
  1307. msgRet.greenExp = nodeConfig.hangGreenExp
  1308. msgRet.qingbao = nodeConfig.hangQingbao or 0
  1309. Msg.send(msgRet, human.fd)
  1310. end
  1311. local function isChapterDot(human, mapID)
  1312. local chapterReward = BattleLogic_GetChapterReward(human)
  1313. local nBattleID = BattleLogic_GetBattleBattleID(human)
  1314. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1315. if not chapterReward or not tBattleConfig or -1 >= nBattleID or chapterReward[mapID] then
  1316. return false
  1317. end
  1318. local battleID = nBattleID
  1319. local battleNodeConfig = tBattleConfig.node[battleID]
  1320. if not battleNodeConfig then
  1321. if battleID == #tBattleConfig.node + 1 then
  1322. return true
  1323. else
  1324. return false
  1325. end
  1326. else
  1327. local roleMapId = battleNodeConfig.mapID
  1328. if roleMapId <= mapID then
  1329. return false
  1330. end
  1331. end
  1332. return true
  1333. end
  1334. function battleWorldMapQuery(human)
  1335. -- 先取配置
  1336. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1337. local nBattleID = BattleLogic_GetBattleBattleID(human)
  1338. if not tBattleConfig or -1 >= nBattleID then
  1339. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[battleWorldMapQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、战斗关卡ID不正确 id = "..human.db._id)
  1340. print("[battleWorldMapQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、挂机ID不正确 id = "..human.db._id)
  1341. return
  1342. end
  1343. local msgRet = Msg.gc.GC_BATTLE_WORLD_MAP_QUERY
  1344. local worldMapConfig = tBattleConfig.map
  1345. local battleID = nBattleID > #tBattleConfig.node and #tBattleConfig.node or nBattleID
  1346. local battleNodeConfig = tBattleConfig.node[battleID]
  1347. local len = #worldMapConfig
  1348. for i = 1, len do
  1349. local v = worldMapConfig[i]
  1350. msgRet.worldMap[i].mapID = i
  1351. msgRet.worldMap[i].mapName = v.name or ""
  1352. msgRet.worldMap[i].mapBuild = v.build or 0
  1353. msgRet.worldMap[i].mapBg = v.bg or 0
  1354. msgRet.worldMap[i].mapPos[0] = 2
  1355. msgRet.worldMap[i].mapPos[1] = v.pos[1]
  1356. msgRet.worldMap[i].mapPos[2] = v.pos[2]
  1357. msgRet.worldMap[i].status =(battleNodeConfig.mapID >= i) and 1 or 0
  1358. msgRet.worldMap[i].story = v.des or ""
  1359. if battleNodeConfig.mapID == i then
  1360. msgRet.worldMap[i].maxLevel = battleNodeConfig.maxLevel
  1361. msgRet.worldMap[i].curLevel = battleNodeConfig.curLevel
  1362. else
  1363. msgRet.worldMap[i].maxLevel = 0
  1364. msgRet.worldMap[i].curLevel = 0
  1365. end
  1366. local reward = v.reward
  1367. local l = 0
  1368. msgRet.worldMap[i].chapterReward[0] = #reward
  1369. for _, rewardData in pairs(reward) do
  1370. l = l + 1
  1371. Grid.makeItem(msgRet.worldMap[i].chapterReward[l], rewardData[1], rewardData[2])
  1372. end
  1373. msgRet.worldMap[i].chapterDot = 0
  1374. if isChapterDot(human, i) then
  1375. msgRet.worldMap[i].chapterDot = 1
  1376. end
  1377. local cnt = 0
  1378. BATTLE_LEVEL_PLAYER_LIST[i] = BATTLE_LEVEL_PLAYER_LIST[i] or { }
  1379. for s, t in pairs(BATTLE_LEVEL_PLAYER_LIST[i]) do
  1380. cnt = cnt + 1
  1381. RoleLogic.makeRoleBase(t, msgRet.worldMap[i].roleList[cnt])
  1382. if cnt >= 3 then
  1383. break
  1384. end
  1385. end
  1386. msgRet.worldMap[i].roleList[0] = cnt
  1387. end
  1388. msgRet.worldMap[0] = len
  1389. Msg.send(msgRet, human.fd)
  1390. end
  1391. function battleNodeQuery(human, mapID)
  1392. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1393. local nBattleID = BattleLogic_GetBattleBattleID(human)
  1394. if not tBattleConfig or -1 >= nBattleID then
  1395. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[battleNodeQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、战斗关卡ID不正确 id = "..human.db._id)
  1396. print("[battleNodeQuery] 获取到的战斗挂机奖励配置不正确 或 配置信息、挂机ID不正确 id = "..human.db._id)
  1397. return
  1398. end
  1399. local msgRet = Msg.gc.GC_BATTLE_NODE_QUERY
  1400. local nodeConfig = tBattleConfig.node
  1401. local lenConfig = #nodeConfig
  1402. local len = 0
  1403. msgRet.battleID = nBattleID or 0
  1404. for i = 1, lenConfig do
  1405. local v = nodeConfig[i]
  1406. if v.mapID == mapID then
  1407. len = len + 1
  1408. msgRet.nodeInfo[len].nodeName = v.name
  1409. msgRet.nodeInfo[len].battleID = i
  1410. msgRet.nodeInfo[len].needLv = v.needLv
  1411. msgRet.nodeInfo[len].needZDL = v.needZDL
  1412. msgRet.nodeInfo[len].hasSuipian = v.hasSuipian
  1413. end
  1414. end
  1415. msgRet.nodeInfo[0] = len
  1416. Msg.send(msgRet, human.fd)
  1417. end
  1418. function initBattleOut(human, now)
  1419. if human.db.battleOut then
  1420. return
  1421. end
  1422. if false == BattleLogic_InitAllBattleOut(human, now) then
  1423. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "initBattleOut 初始化挂机奖励表失败 id = "
  1424. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1425. return
  1426. end
  1427. -- human.db.battleOut = { }
  1428. -- human.db.battleOut.expTs1 = now
  1429. -- -- 经验开始产出时间戳
  1430. -- human.db.battleOut.expTs2 = now
  1431. -- -- 经验产出结算时间戳
  1432. -- human.db.battleOut.itemTs1 = now
  1433. -- -- 道具产出时间戳
  1434. -- human.db.battleOut.itemTs2 = now
  1435. -- -- 道具产出结算时间戳
  1436. -- human.db.battleOut.exp = 0
  1437. -- human.db.battleOut.jinbi = 0
  1438. -- human.db.battleOut.greenExp = 0
  1439. -- human.db.battleOut.qingbao = 0
  1440. -- human.db.battleOut.items = nil
  1441. -- -- 产出的待收获的战利品
  1442. -- human.db.battleOut.equip = nil
  1443. -- -- 产出的待收获的装备
  1444. end
  1445. function calcBattleOut(human,isDiamond)
  1446. local now = os.time()
  1447. initBattleOut(human, now)
  1448. calcBattleExpOut(human, now)
  1449. calcBattleItemOut(human, now)
  1450. if isDiamond then -- 钻石消耗 所有产出翻1.5倍
  1451. local tBattleOut = BattleLogic_GetBattleOut(human)
  1452. if not tBattleOut then
  1453. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleOut 获取挂机奖励列表失败 id = "
  1454. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1455. return
  1456. end
  1457. -- human.db.battleOut.exp = math.floor(human.db.battleOut.exp * DIAMOND_ADDITION)
  1458. -- human.db.battleOut.jinbi = math.floor(human.db.battleOut.jinbi * DIAMOND_ADDITION)
  1459. -- human.db.battleOut.greenExp = math.floor(human.db.battleOut.greenExp * DIAMOND_ADDITION)
  1460. -- human.db.battleOut.qingbao = math.floor(human.db.battleOut.qingbao * DIAMOND_ADDITION)
  1461. -- local items = human.db.battleOut.items or {}
  1462. tBattleOut.exp = math.floor(tBattleOut.exp * DIAMOND_ADDITION)
  1463. tBattleOut.jinbi = math.floor(tBattleOut.jinbi * DIAMOND_ADDITION)
  1464. tBattleOut.greenExp = math.floor(tBattleOut.greenExp * DIAMOND_ADDITION)
  1465. tBattleOut.qingbao = math.floor(tBattleOut.qingbao * DIAMOND_ADDITION)
  1466. local items = tBattleOut.items or {}
  1467. for id,cnt in pairs(items) do
  1468. items[id] = math.floor(cnt * DIAMOND_ADDITION)
  1469. end
  1470. -- local equipList = human.db.battleOut.equip or {}
  1471. local equipList = tBattleOut.equip or {}
  1472. local equipMap = {}
  1473. for _,equip in ipairs(equipList) do
  1474. equipMap[equip.id] = equipMap[equip.id] or 0
  1475. equipMap[equip.id] = equipMap[equip.id] + 1
  1476. end
  1477. for id,cnt in pairs(equipMap) do
  1478. local count = math.floor(cnt * DIAMOND_ADDITION)
  1479. for i = cnt,count do
  1480. local equipGrid = EquipLogic.makeEquip(id)
  1481. equipList[#equipList + 1] = equipGrid
  1482. end
  1483. end
  1484. end
  1485. end
  1486. -- 获取正确的剩余可收益的结算时间
  1487. function getSurMaxHangTime(maxHangTime, ts1, now)
  1488. if ts1 + maxHangTime > now then
  1489. return now
  1490. else
  1491. return ts1 + maxHangTime
  1492. end
  1493. end
  1494. -- function calcBattleExpOut(human, now)
  1495. -- local maxHangTime = getHangMaxTime(human)
  1496. -- if human.db.battleOut.expTs2 - human.db.battleOut.expTs1 >= maxHangTime then
  1497. -- return
  1498. -- end
  1499. -- local outTime = getSurMaxHangTime(maxHangTime, human.db.battleOut.expTs1, now)
  1500. -- local outSec = outTime - human.db.battleOut.expTs2
  1501. -- local outCnt = math.floor(outSec / BATTLE_HANG_EXP_OUT_PERIOD)
  1502. -- if outCnt < 1 then
  1503. -- return
  1504. -- end
  1505. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  1506. -- if guajiID == 0 then
  1507. -- return
  1508. -- end
  1509. -- local nowNodeConfig = BattleExcel.node[guajiID]
  1510. -- human.db.battleOut.expTs2 = human.db.battleOut.expTs2 + outCnt * BATTLE_HANG_EXP_OUT_PERIOD
  1511. -- if now - human.db.battleOut.expTs1 >= maxHangTime then
  1512. -- human.db.battleOut.expTs2 = now
  1513. -- end
  1514. -- local vipExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER7) or 0) / 100
  1515. -- local vipJinAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER8) or 0) / 100
  1516. -- local vipGreenExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER9) or 0) / 100
  1517. -- local vipQingbaoAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER19) or 0) / 100
  1518. -- local exp = nowNodeConfig.hangExp
  1519. -- local jinbi = nowNodeConfig.hangJinbi
  1520. -- local greenExp = nowNodeConfig.hangGreenExp
  1521. -- local qingbao = nowNodeConfig.hangQingbao
  1522. -- human.db.battleOut.exp = human.db.battleOut.exp + math.floor(outCnt * exp *(1 + vipExpAdd))
  1523. -- human.db.battleOut.jinbi = human.db.battleOut.jinbi + math.floor(outCnt * jinbi *(1 + vipJinAdd))
  1524. -- human.db.battleOut.greenExp = human.db.battleOut.greenExp + math.floor(outCnt * greenExp *(1 + vipGreenExpAdd))
  1525. -- human.db.battleOut.qingbao = human.db.battleOut.qingbao + math.floor(outCnt * qingbao *(1 + vipQingbaoAdd))
  1526. -- end
  1527. function calcBattleExpOut(human, now)
  1528. local tBattleOut = BattleLogic_GetBattleOut(human)
  1529. if not tBattleOut then
  1530. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleExpOut 获取挂机奖励列表失败 id = "
  1531. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1532. return
  1533. end
  1534. local maxHangTime = getHangMaxTime(human)
  1535. if tBattleOut.expTs2 - tBattleOut.expTs1 >= maxHangTime then
  1536. return
  1537. end
  1538. local outTime = getSurMaxHangTime(maxHangTime, tBattleOut.expTs1, now)
  1539. local outSec = outTime - tBattleOut.expTs2
  1540. local outCnt = math.floor(outSec / BATTLE_HANG_EXP_OUT_PERIOD)
  1541. if outCnt < 1 then
  1542. return
  1543. end
  1544. local tBattleNodeConfig = BattleLogic_GetBattleConfig(human)
  1545. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  1546. if not tBattleNodeConfig or 0 > nGuaJiID then
  1547. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleExpOut 获取到的配置表不正确或挂机ID不正确 id = "
  1548. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1549. return
  1550. end
  1551. local guajiID = nGuaJiID > #tBattleNodeConfig.node and #tBattleNodeConfig.node or nGuaJiID
  1552. if guajiID == 0 then
  1553. return
  1554. end
  1555. local nowNodeConfig = tBattleNodeConfig.node[guajiID]
  1556. tBattleOut.expTs2 = tBattleOut.expTs2 + outCnt * BATTLE_HANG_EXP_OUT_PERIOD
  1557. if now - tBattleOut.expTs1 >= maxHangTime then
  1558. tBattleOut.expTs2 = now
  1559. end
  1560. local vipExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER7) or 0) / 100
  1561. local vipJinAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER8) or 0) / 100
  1562. local vipGreenExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER9) or 0) / 100
  1563. local vipQingbaoAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER19) or 0) / 100
  1564. local exp = nowNodeConfig.hangExp
  1565. local jinbi = nowNodeConfig.hangJinbi
  1566. local greenExp = nowNodeConfig.hangGreenExp
  1567. local qingbao = nowNodeConfig.hangQingbao
  1568. tBattleOut.exp = tBattleOut.exp + math.floor(outCnt * exp *(1 + vipExpAdd))
  1569. tBattleOut.jinbi = tBattleOut.jinbi + math.floor(outCnt * jinbi *(1 + vipJinAdd))
  1570. tBattleOut.greenExp = tBattleOut.greenExp + math.floor(outCnt * greenExp *(1 + vipGreenExpAdd))
  1571. tBattleOut.qingbao = tBattleOut.qingbao + math.floor(outCnt * qingbao *(1 + vipQingbaoAdd))
  1572. end
  1573. -- 根据时间计算道具产出
  1574. local ITEM_OUT_LIST = { }
  1575. function getItemOutsByTime(config, sec)
  1576. Util.cleanTable(ITEM_OUT_LIST)
  1577. local outCnt = math.floor(sec / BATTLE_HANG_ITEM_OUT_PERIOD)
  1578. if outCnt < 1 then
  1579. return ITEM_OUT_LIST
  1580. end
  1581. -- 普通掉落
  1582. local dropID = config.dropID
  1583. local dropConfig = DropExcel.dropBattle[dropID]
  1584. local weightSum = 0
  1585. for i = 1, #dropConfig.dropRule do
  1586. local tempConfig = dropConfig.dropRule[i]
  1587. weightSum = weightSum + tempConfig[4]
  1588. end
  1589. for i = 1, outCnt do
  1590. local itemID, itemCnt = randItemOut(dropConfig.dropRule, weightSum)
  1591. if itemID and itemCnt and itemCnt > 0 then
  1592. ITEM_OUT_LIST[itemID] =(ITEM_OUT_LIST[itemID] or 0) + itemCnt
  1593. end
  1594. end
  1595. for i = 1, #dropConfig.dropRule2 do
  1596. local tempConfig = dropConfig.dropRule2[i]
  1597. local itemID = tempConfig[1]
  1598. local itemMin = tempConfig[2]
  1599. local itemMax = tempConfig[3]
  1600. local itemCnt = math.random(itemMin, itemMax) * outCnt
  1601. if itemCnt > 0 then
  1602. ITEM_OUT_LIST[itemID] =(ITEM_OUT_LIST[itemID] or 0) + itemCnt
  1603. end
  1604. end
  1605. -- 三小时掉落
  1606. outCnt = math.floor(sec / BATTLE_HANG_ITEM_OUT_PERIOD_2)
  1607. if outCnt < 1 then
  1608. return ITEM_OUT_LIST
  1609. end
  1610. weightSum = 0
  1611. for i = 1, #dropConfig.dropRule3 do
  1612. local tempConfig = dropConfig.dropRule3[i]
  1613. weightSum = weightSum + tempConfig[4]
  1614. end
  1615. for i = 1, outCnt do
  1616. local itemID, itemCnt = randItemOut(dropConfig.dropRule3, weightSum)
  1617. if itemID and itemCnt and itemCnt > 0 then
  1618. ITEM_OUT_LIST[itemID] =(ITEM_OUT_LIST[itemID] or 0) + itemCnt
  1619. end
  1620. end
  1621. return ITEM_OUT_LIST
  1622. end
  1623. -- function calcBattleItemOut(human, now,isDiamond)
  1624. -- local maxHangTime = getHangMaxTime(human)
  1625. -- if human.db.battleOut.itemTs2 - human.db.battleOut.itemTs1 >= maxHangTime then
  1626. -- return
  1627. -- end
  1628. -- local outTime = getSurMaxHangTime(maxHangTime, human.db.battleOut.itemTs1, now)
  1629. -- local outSec = outTime - human.db.battleOut.itemTs2
  1630. -- local outCnt = math.floor(outSec / BATTLE_HANG_ITEM_OUT_PERIOD)
  1631. -- if outCnt < 1 then
  1632. -- return
  1633. -- end
  1634. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  1635. -- if guajiID == 0 then
  1636. -- return
  1637. -- end
  1638. -- local sec = outCnt * BATTLE_HANG_ITEM_OUT_PERIOD
  1639. -- human.db.battleOut.itemTs2 = human.db.battleOut.itemTs2 + sec
  1640. -- if now - human.db.battleOut.itemTs1 >= maxHangTime then
  1641. -- human.db.battleOut.itemTs2 = now
  1642. -- end
  1643. -- local nodeConfig = BattleExcel.node[guajiID]
  1644. -- local items = getItemOutsByTime(nodeConfig, sec)
  1645. -- for itemID, itemCnt in pairs(items) do
  1646. -- -- 判定是否是装备
  1647. -- if ItemDefine.isEquip(itemID) then
  1648. -- -- 生成装备
  1649. -- local equipGrid = EquipLogic.makeEquip(itemID)
  1650. -- if equipGrid then
  1651. -- human.db.battleOut.equip = human.db.battleOut.equip or { }
  1652. -- human.db.battleOut.equip[#human.db.battleOut.equip + 1] = equipGrid
  1653. -- end
  1654. -- else
  1655. -- human.db.battleOut.items = human.db.battleOut.items or { }
  1656. -- human.db.battleOut.items[itemID] = human.db.battleOut.items[itemID] or 0
  1657. -- human.db.battleOut.items[itemID] = human.db.battleOut.items[itemID] + itemCnt
  1658. -- end
  1659. -- end
  1660. -- DropExchangeLogic.getDropItem(human, outSec, BATTLE_HANG_ITEM_OUT_PERIOD, human.db.battleOut)
  1661. -- end
  1662. function calcBattleItemOut(human, now,isDiamond)
  1663. local tBattleOut = BattleLogic_GetBattleOut(human)
  1664. if not tBattleOut then
  1665. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleItemOut 获取挂机奖励列表失败 id = "
  1666. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1667. return
  1668. end
  1669. local maxHangTime = getHangMaxTime(human)
  1670. if tBattleOut.itemTs2 - tBattleOut.itemTs1 >= maxHangTime then
  1671. return
  1672. end
  1673. local outTime = getSurMaxHangTime(maxHangTime, tBattleOut.itemTs1, now)
  1674. local outSec = outTime - tBattleOut.itemTs2
  1675. local outCnt = math.floor(outSec / BATTLE_HANG_ITEM_OUT_PERIOD)
  1676. if outCnt < 1 then
  1677. return
  1678. end
  1679. local tBattleNodeConfig = BattleLogic_GetBattleConfig(human)
  1680. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  1681. if not tBattleNodeConfig or 0 > nGuaJiID then
  1682. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "calcBattleItemOut 获取到的配置表不正确或挂机ID不正确 id = "
  1683. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1684. return
  1685. end
  1686. local guajiID = nGuaJiID > #tBattleNodeConfig.node and #tBattleNodeConfig.node or nGuaJiID
  1687. if guajiID == 0 then
  1688. return
  1689. end
  1690. local sec = outCnt * BATTLE_HANG_ITEM_OUT_PERIOD
  1691. tBattleOut.itemTs2 = tBattleOut.itemTs2 + sec
  1692. if now - tBattleOut.itemTs1 >= maxHangTime then
  1693. tBattleOut.itemTs2 = now
  1694. end
  1695. local nodeConfig = tBattleNodeConfig.node[guajiID]
  1696. local items = getItemOutsByTime(nodeConfig, sec)
  1697. for itemID, itemCnt in pairs(items) do
  1698. -- 判定是否是装备
  1699. if ItemDefine.isEquip(itemID) then
  1700. -- 生成装备
  1701. local equipGrid = EquipLogic.makeEquip(itemID)
  1702. if equipGrid then
  1703. tBattleOut.equip = tBattleOut.equip or { }
  1704. tBattleOut.equip[#tBattleOut.equip + 1] = equipGrid
  1705. end
  1706. else
  1707. tBattleOut.items = tBattleOut.items or { }
  1708. tBattleOut.items[itemID] = tBattleOut.items[itemID] or 0
  1709. tBattleOut.items[itemID] = tBattleOut.items[itemID] + itemCnt
  1710. end
  1711. end
  1712. DropExchangeLogic.getDropItem(human, outSec, BATTLE_HANG_ITEM_OUT_PERIOD, tBattleOut)
  1713. end
  1714. local function hangExpGet(human,isDiamond)
  1715. local tBattleOut = BattleLogic_GetBattleOut(human)
  1716. if not tBattleOut then
  1717. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "hangExpGet 获取挂机奖励列表失败 id = "
  1718. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1719. return
  1720. end
  1721. local needDiamond = 0
  1722. -- 是否消耗钻石
  1723. if isDiamond then
  1724. local now = os.time()
  1725. local outSec = now - tBattleOut.expTs1
  1726. local maxHangTime = getHangMaxTime(human)
  1727. outSec = outSec > maxHangTime and maxHangTime or outSec
  1728. local minHour = math.floor(outSec / HOUR_SEC)
  1729. minHour = (minHour ~= 0) and minHour or 1
  1730. local diamondCnt = minHour * DIAMOND_COST_PER_HOUR
  1731. if not ObjHuman.checkRMB(human,diamondCnt) then
  1732. return
  1733. end
  1734. needDiamond = -diamondCnt
  1735. end
  1736. print("==================== needDiamond is ",needDiamond)
  1737. calcBattleOut(human,isDiamond)
  1738. if tBattleOut.exp == 0 then
  1739. return 1
  1740. end
  1741. local jinbiAdd = tBattleOut.jinbi
  1742. if not ObjHuman.canAddJinbi(human, jinbiAdd) then
  1743. return 2
  1744. end
  1745. -- 检测装备数量
  1746. if tBattleOut.equip then
  1747. local equipCnt = #htBattleOut.equip
  1748. if not EquipLogic.checkEmptyCnt(human, equipCnt) then
  1749. return
  1750. end
  1751. end
  1752. local items = { }
  1753. local len = #items
  1754. local maxHangTime = getHangMaxTime(human)
  1755. if tBattleOut.expTs2 - tBattleOut.expTs1 >= maxHangTime then
  1756. local now = os.time()
  1757. tBattleOut.expTs2 = now
  1758. end
  1759. if tBattleOut.itemTs2 - tBattleOut.itemTs1 >= maxHangTime then
  1760. local now = os.time()
  1761. tBattleOut.itemTs2 = now
  1762. end
  1763. tBattleOut.itemTs1 = tBattleOut.itemTs2
  1764. -- 改db
  1765. local tempTable = tBattleOut.items or { }
  1766. tBattleOut.items = nil
  1767. for k, v in pairs(tempTable) do
  1768. len = len + 1
  1769. items[len] = { }
  1770. items[len].id = k
  1771. items[len].cnt = v
  1772. end
  1773. tBattleOut.expTs1 = tBattleOut.expTs2
  1774. local expAdd = tBattleOut.exp
  1775. local greenExpAdd = tBattleOut.greenExp
  1776. local qingbaoAdd = tBattleOut.qingbao
  1777. -- 新手指引 强制经验
  1778. local flag = GuideLogic.getGuideSkip(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_EXP)
  1779. if not flag then
  1780. expAdd = 1510
  1781. end
  1782. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_EXP)
  1783. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_GUAJI)
  1784. tBattleOut.exp = 0
  1785. tBattleOut.jinbi = 0
  1786. tBattleOut.greenExp = 0
  1787. tBattleOut.qingbao = 0
  1788. len = len + 1
  1789. items[len] = { }
  1790. items[len].id = ItemDefine.ITEM_EXP_ID
  1791. items[len].cnt = expAdd
  1792. len = len + 1
  1793. items[len] = { }
  1794. items[len].id = ItemDefine.ITEM_JINBI_ID
  1795. items[len].cnt = jinbiAdd
  1796. len = len + 1
  1797. items[len] = { }
  1798. items[len].id = ItemDefine.ITEM_GREEN_EXP_ID
  1799. items[len].cnt = greenExpAdd
  1800. len = len + 1
  1801. items[len] = { }
  1802. items[len].id = ItemDefine.ITEM_QINGBAO_ID
  1803. items[len].cnt = qingbaoAdd
  1804. -- 给道具
  1805. for i = 1, #items do
  1806. local tempID = items[i].id
  1807. local tempCnt = items[i].cnt
  1808. BagLogic.addItem(human, tempID, tempCnt, "battle")
  1809. end
  1810. -- 给装备
  1811. if tBattleOut.equip then
  1812. for k, equipGrid in ipairs(tBattleOut.equip) do
  1813. EquipLogic.addByEquipGrid(human, equipGrid, "battle", true)
  1814. end
  1815. tBattleOut.equip = nil
  1816. end
  1817. if needDiamond < 0 then
  1818. ObjHuman.decZuanshi(human,needDiamond,"battle")
  1819. end
  1820. return 0, items
  1821. end
  1822. -- 获取挂机收益
  1823. function hangGet(human,isDiamond)
  1824. local ret, items = hangExpGet(human,false)
  1825. if ret == 1 then
  1826. return Broadcast.sendErr(human, Lang.BATTLE_HANG_GET_EXP_ERR_NONE)
  1827. elseif ret == 2 then
  1828. return Broadcast.sendErr(human, Lang.COMMON_ADD_JINBI_LIMIT)
  1829. elseif ret == 0 then
  1830. query(human)
  1831. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  1832. end
  1833. end
  1834. -- 挂机节点设置
  1835. function nodeSet(human, battleID)
  1836. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1837. local nNowBattleID = BattleLogic_GetBattleBattleID(human)
  1838. if not tBattleConfig or -1 >= nNowBattleID then
  1839. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "hangExpGet 获取挂机奖励列表失败 id = "
  1840. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1841. print("[nodeSet] 获取不到战斗配置")
  1842. return
  1843. end
  1844. local nodeConfig = tBattleConfig.node[battleID]
  1845. if nodeConfig == nil then
  1846. return
  1847. end
  1848. -- 前置条件判断
  1849. if battleID > nNowBattleID then
  1850. return Broadcast.sendErr(human, Lang.BATTLE_ID_OVER)
  1851. end
  1852. -- 等级判断
  1853. if human.db.lv < nodeConfig.needLv then
  1854. return Broadcast.sendErr(human, Util.format(Lang.ROLE_LEV_ERROR, nodeConfig.needLv))
  1855. end
  1856. calcBattleOut(human)
  1857. BattleLogic_SetBattleGuaJiID(human ,battleID)
  1858. --human.db.guajiID = battleID
  1859. setBattleID(human, battleID)
  1860. Msg.send(Msg.gc.GC_BATTLE_NODE_SET, human.fd)
  1861. query(human)
  1862. end
  1863. -- 挂机节点详细信息查询
  1864. function nodeDetailQuery(human, battleID)
  1865. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1866. local nNowBattleID = BattleLogic_GetBattleBattleID(human)
  1867. if not tBattleConfig or -1 >= nNowBattleID then
  1868. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "nodeDetailQuery 获取挂机奖励列表失败 id = "
  1869. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1870. print("[nodeDetailQuery] 获取不到战斗配置")
  1871. return
  1872. end
  1873. -- local nodeConfig = BattleExcel.node[battleID]
  1874. local nodeConfig = tBattleConfig.node[battleID]
  1875. if nodeConfig == nil then
  1876. return
  1877. end
  1878. local msgRet = Msg.gc.GC_BATTLE_NODE_DETAIL_QUERY
  1879. msgRet.battleID = battleID
  1880. msgRet.exp = nodeConfig.hangExp
  1881. msgRet.jinbi = nodeConfig.hangJinbi
  1882. msgRet.greenExp = nodeConfig.hangGreenExp
  1883. msgRet.qingbao = nodeConfig.hangQingbao or 0
  1884. msgRet.nodeName = getBattleName(human, battleID)
  1885. local dropID = nodeConfig.dropID
  1886. local dropConfig = DropExcel.dropBattle[dropID]
  1887. local dropCnt = 0
  1888. local list = DropExchangeLogic.getAbsCanDrop(human)
  1889. if list then
  1890. for k, v in pairs(list) do
  1891. dropCnt = dropCnt + 1
  1892. Grid.makeItem(msgRet.items[dropCnt], k, v)
  1893. end
  1894. end
  1895. for i = 1, #dropConfig.dropRule do
  1896. local tempConfig = dropConfig.dropRule[i]
  1897. local itemID = tempConfig[1]
  1898. local itemCnt = tempConfig[3]
  1899. local itemRate = tempConfig[4]
  1900. if itemCnt > 0 and itemRate > 0 then
  1901. dropCnt = dropCnt + 1
  1902. Grid.makeItem(msgRet.items[dropCnt], itemID, 1)
  1903. end
  1904. end
  1905. for i = 1, #dropConfig.dropRule3 do
  1906. local tempConfig = dropConfig.dropRule3[i]
  1907. local itemID = tempConfig[1]
  1908. local itemCnt = tempConfig[3]
  1909. local itemRate = tempConfig[4]
  1910. if itemCnt > 0 and itemRate > 0 then
  1911. dropCnt = dropCnt + 1
  1912. Grid.makeItem(msgRet.items[dropCnt], itemID, 1)
  1913. end
  1914. end
  1915. msgRet.items[0] = dropCnt
  1916. Msg.send(msgRet, human.fd)
  1917. end
  1918. -- 挑战当前挂机节点
  1919. function fight(human)
  1920. local battleID = BattleLogic_GetBattleBattleID(human)
  1921. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1922. if not tBattleConfig or -1 >= battleID then
  1923. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "nodeDetailQuery 获取挂机奖励列表失败 id = "
  1924. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1925. print("[nodeDetailQuery] 获取不到战斗配置")
  1926. return
  1927. end
  1928. -- local battleID = human.db.battleID
  1929. -- if BattleExcel.node[human.db.battleID] == nil then
  1930. if tBattleConfig.node[battleID] == nil then
  1931. local msgRet = Msg.gc.GC_BATTLE_GOBACK_MAIN
  1932. msgRet.panelIDs[0] = 1
  1933. msgRet.panelIDs[1] = PanelDefine.PANEL_ID_1008
  1934. Msg.send(msgRet, human.fd)
  1935. return Broadcast.sendErr(human, Lang.BATTLE_MAX_LEVEL)
  1936. end
  1937. -- if human.db.lv < BattleExcel.node[human.db.battleID].needLv then
  1938. if human.db.lv < tBattleConfig.node[battleID].needLv then
  1939. local msgRet = Msg.gc.GC_BATTLE_GOBACK_MAIN
  1940. msgRet.panelIDs[0] = 1
  1941. msgRet.panelIDs[1] = PanelDefine.PANEL_ID_1008
  1942. Msg.send(msgRet, human.fd)
  1943. return Broadcast.sendErr(human, Util.format(Lang.ROLE_LEV_ERROR, tBattleConfig.node[battleID].needLv))
  1944. end
  1945. local config = tBattleConfig.node[battleID]
  1946. local mapConfig = tBattleConfig.map[config.mapID]
  1947. local monsterOutID = config.monsterOutID
  1948. local mapID = mapConfig.bg
  1949. CombatLogic.combatBegin(human, config.sceneID, monsterOutID, CombatDefine.COMBAT_TYPE1, battleID)
  1950. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE)
  1951. end
  1952. function onFightEnd(human, result, fightTypeID, param1, combatInfo)
  1953. -- 设置一些战斗结算信息
  1954. combatInfo.defender.name = Util.format(Lang.COMBAT_BATTLE_DEFEND_NAME, param1)
  1955. if CombatDefine.RESULT_WIN ~= result then
  1956. return
  1957. end
  1958. local nBattleType = BattleLogic_GetBattleType(human)
  1959. local guajiID = BattleLogic_GetBattleGuaJiID(human)
  1960. local battleID = BattleLogic_GetBattleBattleID(human)
  1961. if EliteDefine.COPY_ELITE_ERROR == nBattleType or -1 >= guajiID or -1 >= battleID then
  1962. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "onFightEnd 获取战斗类型、挂机ID、战斗关卡ID失败 id = "
  1963. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1964. print("[onFightEnd] 获取战斗类型、挂机ID、战斗关卡ID失败")
  1965. return
  1966. end
  1967. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  1968. if not tBattleConfig then
  1969. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "onFightEnd 获取战斗配置失败 id = "
  1970. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  1971. print("[onFightEnd] 获取战斗配置失败")
  1972. return
  1973. end
  1974. -- local guajiID = human.db.guajiID
  1975. -- local battleID = human.db.battleID
  1976. if battleID ~= param1 then
  1977. return
  1978. end
  1979. local nAllFightLen = #tBattleConfig.node
  1980. local oldGuajiID = guajiID
  1981. local nextGuajiID = (guajiID + 1) > nAllFightLen and nAllFightLen or guajiID + 1
  1982. local nextBattleID = (battleID + 1) > nAllFightLen and nAllFightLen or battleID + 1
  1983. -- local nextBattleConfig = BattleExcel.node[nextBattleID]
  1984. -- local config = BattleExcel.node[battleID]
  1985. local nextBattleConfig = tBattleConfig.node[nextBattleID]
  1986. local config = tBattleConfig.node[battleID]
  1987. if not BATTLE_LEVEL_PLAYER_LIST[nBattleType] then
  1988. BATTLE_LEVEL_PLAYER_LIST[nBattleType] = {}
  1989. end
  1990. local tBattleLevelPlayerList = BATTLE_LEVEL_PLAYER_LIST[nBattleType]
  1991. -- 如果过大关卡
  1992. if nextBattleConfig and nextBattleConfig.mapID ~= config.mapID then
  1993. -- 清除记录
  1994. tBattleLevelPlayerList[config.mapID] = tBattleLevelPlayerList[config.mapID] or { }
  1995. tBattleLevelPlayerList[config.mapID][human.db._id] = nil
  1996. -- 增加新纪录
  1997. tBattleLevelPlayerList[nextBattleConfig.mapID] = tBattleLevelPlayerList[nextBattleConfig.mapID] or { }
  1998. tBattleLevelPlayerList[nextBattleConfig.mapID][human.db._id] = { }
  1999. RoleLogic.getRoleBase(human, tBattleLevelPlayerList[nextBattleConfig.mapID][human.db._id])
  2000. else
  2001. if config.mapID == 1 then
  2002. tBattleLevelPlayerList[config.mapID] = tBattleLevelPlayerList[config.mapID] or { }
  2003. if tBattleLevelPlayerList[config.mapID][human.db._id] == nil then
  2004. -- 增加新纪录
  2005. tBattleLevelPlayerList[config.mapID][human.db._id] = { }
  2006. RoleLogic.getRoleBase(human, tBattleLevelPlayerList[config.mapID][human.db._id])
  2007. end
  2008. else
  2009. if not tBattleLevelPlayerList[config.mapID] or not tBattleLevelPlayerList[config.mapID][human.db._id] then
  2010. tBattleLevelPlayerList[config.mapID] = tBattleLevelPlayerList[config.mapID] or { }
  2011. tBattleLevelPlayerList[config.mapID][human.db._id] = { }
  2012. RoleLogic.getRoleBase(human, tBattleLevelPlayerList[config.mapID][human.db._id])
  2013. end
  2014. end
  2015. end
  2016. -- -- 如果过大关卡
  2017. -- if nextBattleConfig and nextBattleConfig.mapID ~= config.mapID then
  2018. -- -- 清除记录
  2019. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID] = BATTLE_LEVEL_PLAYER_LIST[config.mapID] or { }
  2020. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] = nil
  2021. -- -- 增加新纪录
  2022. -- BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID] = BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID] or { }
  2023. -- BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID][human.db._id] = { }
  2024. -- RoleLogic.getRoleBase(human, BATTLE_LEVEL_PLAYER_LIST[nextBattleConfig.mapID][human.db._id])
  2025. -- else
  2026. -- if config.mapID == 1 then
  2027. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID] = BATTLE_LEVEL_PLAYER_LIST[config.mapID] or { }
  2028. -- if BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] == nil then
  2029. -- -- 增加新纪录
  2030. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] = { }
  2031. -- RoleLogic.getRoleBase(human, BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id])
  2032. -- end
  2033. -- else
  2034. -- if not BATTLE_LEVEL_PLAYER_LIST[config.mapID] or not BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] then
  2035. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID] = BATTLE_LEVEL_PLAYER_LIST[config.mapID] or { }
  2036. -- BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id] = { }
  2037. -- RoleLogic.getRoleBase(human, BATTLE_LEVEL_PLAYER_LIST[config.mapID][human.db._id])
  2038. -- end
  2039. -- end
  2040. -- end
  2041. BattleLogic_SetBattleBattleID(human, nextBattleID)
  2042. -- human.db.battleID = battleID + 1
  2043. -- 通过第10关,默认开启二倍速
  2044. if nextBattleID == 10 and EliteDefine.COPY_ELITE_NORMAL == nBattleType then
  2045. human.db.combatSpeed = 2
  2046. end
  2047. combatInfo.attacker.oldLv = human.db.lv
  2048. -- 给奖励
  2049. combatInfo.rewardItem = { }
  2050. for i = 1, #config.winReward do
  2051. local itemID = config.winReward[i][1]
  2052. local itemCnt = config.winReward[i][2]
  2053. -- 装备不在这显示
  2054. combatInfo.rewardItem[i] = combatInfo.rewardItem[i] or { }
  2055. combatInfo.rewardItem[i] = { itemID, itemCnt }
  2056. BagLogic.addItem(human, itemID, itemCnt, "battle_win")
  2057. end
  2058. combatInfo.attacker.lv = human.db.lv
  2059. combatInfo.getEquip = human.getEquip
  2060. human.getEquip = nil
  2061. -- TODO:记录主线关卡
  2062. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, human.db._id, human.db.account, human.db.name, human.db.battleID)
  2063. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  2064. GuideLogic.onCallback(human)
  2065. JibanLogic.onCallback(human, 1, battleID)
  2066. TuiSongLiBao.tuiSongLiBaoOnTask(
  2067. human,
  2068. TuiSongLiBao.TUISONGLIBAOTASK_ZHENGZHAN,
  2069. -- human.db.guajiID - 1,
  2070. -- human.db.guajiID - 2
  2071. guajiID - 1,
  2072. guajiID - 2
  2073. )
  2074. ChengjiuLogic.onCallback(human, ChengjiuDefine.CJ_TASK_TYPE_1, nextGuajiID)
  2075. MengxinLogic.onCallBack(human, MengxinLogic.MX_TASK_TYPE_1, nextGuajiID)
  2076. for k, v in pairs(KingWorldLogic.funcID) do
  2077. YunYingLogic.updateIcon(KingWorldLogic.YYInfo[k], human)
  2078. break
  2079. end
  2080. -- 存储战斗记录
  2081. local videoUuid = CombatVideo.saveBattleVideo(human.db._id, combatInfo)
  2082. human.db.battleVideoUuid = videoUuid
  2083. BattleDBLogic.updateBattleDB(combatInfo.attacker, battleID, combatInfo, videoUuid, nBattleType)
  2084. if nextBattleConfig and nextBattleConfig.mapID ~= config.mapID then
  2085. -- 新的地图
  2086. -- 通知客户端
  2087. Msg.send(Msg.gc.GC_BATTLE_NODE_SET, human.fd)
  2088. end
  2089. BattleLogic_SetBattleGuaJiID(human, nextGuajiID)
  2090. --human.db.guajiID = nextGuajiID
  2091. if nextBattleConfig then
  2092. setBattleID(human, nextGuajiID)
  2093. end
  2094. local showNext = 1
  2095. -- if BattleExcel.node[human.db.battleID] and human.db.lv < BattleExcel.node[human.db.battleID].needLv then
  2096. if tBattleConfig.node[nextBattleID] and human.db.lv < tBattleConfig.node[nextBattleID].needLv then
  2097. showNext = 2
  2098. end
  2099. if human.db.lv < 5 then
  2100. showNext = 0
  2101. end
  2102. -- nextBattleConfig = BattleExcel.node[human.db.battleID]
  2103. nextBattleConfig = tBattleConfig.node[nextBattleID]
  2104. if not nextBattleConfig then
  2105. showNext = 0
  2106. end
  2107. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1105)
  2108. -- 额外奖励
  2109. local needLevel, itemName = getNextRewardName(human)
  2110. if needLevel ~= nil then
  2111. local tb = { needLevel, Lang.BATTLE_FIGHT_GUAN, "|", itemName, "|", showNext }
  2112. local str = table.concat(tb)
  2113. combatInfo.endParam = str
  2114. else
  2115. local tb = { showNext }
  2116. local str = table.concat(tb)
  2117. combatInfo.endParam = str
  2118. end
  2119. -- 触发事件
  2120. GiftLogic.trigger(human,PRINCIPAL_LINE_EVNET,{id = battleID})
  2121. WarOrder.trigger(human,BATTLE_ORDER_TYPE)
  2122. end
  2123. function setBattleID(human, guajiID)
  2124. local nNowGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2125. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2126. if -1 >= nNowGuaJiID or not tBattleConfig then
  2127. return
  2128. end
  2129. -- if guajiID > human.db.guajiID and human.db.guajiID ~= 0 then
  2130. if guajiID > nNowGuaJiID and nNowGuaJiID ~= 0 then
  2131. -- 下发挂机收益升级提示
  2132. local msgRet = Msg.gc.GC_BATTLE_REWARD_UP
  2133. Grid.makeItem(msgRet.itemExp, ItemDefine.ITEM_EXP_ID, 1)
  2134. Grid.makeItem(msgRet.itemJinbi, ItemDefine.ITEM_JINBI_ID, 1)
  2135. Grid.makeItem(msgRet.itemGreenExp, ItemDefine.ITEM_GREEN_EXP_ID, 1)
  2136. Grid.makeItem(msgRet.itemQingbao, ItemDefine.ITEM_QINGBAO_ID, 1)
  2137. -- local oldConfig = BattleExcel.node[human.db.guajiID]
  2138. -- local newConfig = BattleExcel.node[guajiID]
  2139. local oldConfig = tBattleConfig.node[human.db.guajiID]
  2140. local newConfig = tBattleConfig.node[guajiID]
  2141. msgRet.expOld = oldConfig.hangExp
  2142. msgRet.expNew = newConfig.hangExp
  2143. msgRet.jinbiOld = oldConfig.hangJinbi
  2144. msgRet.jinbiNew = newConfig.hangJinbi
  2145. msgRet.greenExpOld = oldConfig.hangGreenExp
  2146. msgRet.greenExpNew = newConfig.hangGreenExp
  2147. msgRet.qingbaoOld = oldConfig.hangQingbao
  2148. msgRet.qingbaoNew = newConfig.hangQingbao
  2149. Msg.send(msgRet, human.fd)
  2150. end
  2151. -- 刷新排行榜
  2152. BRoleLogic.updateData(BillboardDefine.TYPE_BATTLE, human.db)
  2153. end
  2154. -- GM
  2155. function setBattleByGm(human, val, maxBattleID)
  2156. val = tonumber(val)
  2157. if not val or val <= 1 then
  2158. return
  2159. end
  2160. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2161. if not tBattleConfig then
  2162. return
  2163. end
  2164. local nodeConfig = tBattleConfig.node[val]
  2165. if not nodeConfig then
  2166. return
  2167. end
  2168. if maxBattleID then
  2169. maxBattleID = tonumber(maxBattleID)
  2170. else
  2171. maxBattleID = val
  2172. end
  2173. BattleLogic_SetBattleBattleID(human, val)
  2174. BattleLogic_SetBattleGuaJiID(human, val)
  2175. setBattleID(human, val)
  2176. --human.db.battleID = val
  2177. BattleLogic_QueryDifficulty(human)
  2178. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1105)
  2179. end
  2180. function mopupQuery(human)
  2181. ObjHuman.updateDaily(human)
  2182. local nNowGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2183. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2184. if -1 >= nNowGuaJiID or not tBattleConfig then
  2185. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "mopupQuery 获取战斗配置、挂机ID 失败 id = "
  2186. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  2187. print("[mopupQuery] 获取战斗配置、挂机ID 失败")
  2188. return
  2189. end
  2190. local msgRet = Msg.gc.GC_BATTLE_MOPUP_QUERY
  2191. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  2192. local guajiID = nNowGuaJiID > #tBattleConfig.node and #tBattleConfig.node or nNowGuaJiID
  2193. if guajiID == 0 then
  2194. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_ERR)
  2195. end
  2196. human.db.mopupDoCnt = human.db.mopupDoCnt or 0
  2197. local nextDoCnt = human.db.mopupDoCnt + 1
  2198. -- local nodeConfig = BattleExcel.node[guajiID]
  2199. local nodeConfig = tBattleConfig.node[guajiID]
  2200. local dropID = nodeConfig.dropID
  2201. local dropConfig = DropExcel.dropBattle[dropID]
  2202. local dropCnt = 0
  2203. -- ABS掉落活动显示到第一个
  2204. dropCnt = DropExchangeLogic.getDropItemSaoQuery(human, msgRet, dropCnt)
  2205. for i = 1, #dropConfig.dropRule do
  2206. if dropCnt >= #msgRet.item then
  2207. break
  2208. end
  2209. dropCnt = dropCnt + 1
  2210. local tempConfig = dropConfig.dropRule[i]
  2211. local itemID = tempConfig[1]
  2212. Grid.makeItem(msgRet.item[dropCnt], itemID, 1)
  2213. end
  2214. for i = 1, #dropConfig.dropRule3 do
  2215. if dropCnt >= #msgRet.item then
  2216. break
  2217. end
  2218. dropCnt = dropCnt + 1
  2219. local tempConfig = dropConfig.dropRule3[i]
  2220. local itemID = tempConfig[1]
  2221. Grid.makeItem(msgRet.item[dropCnt], itemID, 1)
  2222. end
  2223. -- local mapConfig = BattleExcel.map[nodeConfig.mapID]
  2224. local mapConfig = tBattleConfig.map[nodeConfig.mapID]
  2225. msgRet.name = mapConfig.name
  2226. msgRet.item[0] = dropCnt
  2227. if TequanShopLogic.isActiveMopup(human) then
  2228. msgRet.leftCnt = BATTLE_MOPUP_CNT_VIP - human.db.mopupDoCnt
  2229. else
  2230. msgRet.leftCnt = BATTLE_MOPUP_CNT - human.db.mopupDoCnt
  2231. end
  2232. -- local mupopExcel = BattleExcel.mupop[nextDoCnt]
  2233. local mupopExcel = tBattleConfig.mupop[nextDoCnt]
  2234. if mupopExcel then
  2235. if not TequanShopLogic.isActiveMopup(human) then
  2236. msgRet.need = mupopExcel.cost
  2237. if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT then
  2238. msgRet.need = 0
  2239. end
  2240. else
  2241. msgRet.need = mupopExcel.vipCost
  2242. if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT_VIP then
  2243. msgRet.need = 0
  2244. end
  2245. end
  2246. else
  2247. msgRet.need = 0
  2248. end
  2249. msgRet.vip = TequanShopLogic.isActiveMopup(human) and 1 or 0
  2250. msgRet.nowCnt = human.db.mopupDoCnt
  2251. msgRet.exp = nodeConfig.hangExp
  2252. msgRet.jinbi = nodeConfig.hangJinbi
  2253. msgRet.greenExp = nodeConfig.hangGreenExp
  2254. msgRet.qingbao = nodeConfig.hangQingbao
  2255. Msg.send(msgRet, human.fd)
  2256. end
  2257. function mopupFight(human)
  2258. -- 等级判断
  2259. ObjHuman.updateDaily(human)
  2260. local nNowGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2261. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2262. if -1 >= nNowGuaJiID or not tBattleConfig then
  2263. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "mopupFight 获取战斗配置、挂机ID 失败 id = "
  2264. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  2265. print("[mopupFight] 获取战斗配置、挂机ID 失败")
  2266. return
  2267. end
  2268. local need = 0
  2269. human.db.mopupDoCnt = human.db.mopupDoCnt or 0
  2270. human.db.mopupFreeCnt = human.db.mopupFreeCnt or 0
  2271. local nextDoCnt = human.db.mopupDoCnt + 1
  2272. -- local mupopExcel = BattleExcel.mupop[nextDoCnt]
  2273. local mupopExcel = tBattleConfig.mupop[nextDoCnt]
  2274. if not mupopExcel then
  2275. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
  2276. end
  2277. if not TequanShopLogic.isActiveMopup(human) then
  2278. if human.db.mopupDoCnt >= BATTLE_MOPUP_CNT then
  2279. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
  2280. end
  2281. need = mupopExcel.cost
  2282. -- 如果免费次数小于1次,则按免费算
  2283. if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT then
  2284. need = 0
  2285. end
  2286. else
  2287. if human.db.mopupDoCnt >= BATTLE_MOPUP_CNT_VIP then
  2288. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
  2289. end
  2290. need = mupopExcel.vipCost
  2291. -- 如果免费次数小于3次,则按免费算
  2292. if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT_VIP then
  2293. need = 0
  2294. end
  2295. end
  2296. if not ObjHuman.checkRMB(human, need) then
  2297. return
  2298. end
  2299. if need <= 0 then
  2300. human.db.mopupFreeCnt = human.db.mopupFreeCnt + 1
  2301. end
  2302. ObjHuman.decZuanshi(human, - need, "battleMopup")
  2303. human.db.mopupDoCnt = human.db.mopupDoCnt + 1
  2304. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  2305. local guajiID = nNowGuaJiID > #tBattleConfig.node and #tBattleConfig.node or nNowGuaJiID
  2306. if guajiID == 0 then
  2307. return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_ERR)
  2308. end
  2309. -- local config = BattleExcel.node[guajiID]
  2310. local config = tBattleConfig.node[guajiID]
  2311. local msgRet = Msg.gc.GC_BATTLE_MOPUP_FIGHT
  2312. local vipExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER7) or 0) / 100
  2313. local vipJinAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER8) or 0) / 100
  2314. local vipGreenExpAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER9) or 0) / 100
  2315. local vipQingbaoAdd =(VipLogic.getPowerArgs(human, VipLogic.VIP_POWER19) or 0) / 100
  2316. local exp = config.hangExp * 120
  2317. local jinbi = config.hangJinbi * 120
  2318. local greenExp = config.hangGreenExp * 120
  2319. local qingbao = config.hangQingbao * 120
  2320. local addExp = math.floor(exp *(1 + vipExpAdd))
  2321. local addJinbi = math.floor(jinbi *(1 + vipJinAdd))
  2322. local addGreenExp = math.floor(greenExp *(1 + vipGreenExpAdd))
  2323. local addQingbao = math.floor(qingbao *(1 + vipQingbaoAdd))
  2324. local time = 7200
  2325. local itemTable = getItemOutsByTime(config, time)
  2326. -- 掉落活动
  2327. DropExchangeLogic.getDropItemSao(human, time, itemTable)
  2328. local flag = GuideLogic.getGuideSkip(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_SD)
  2329. if not flag then
  2330. local equipID = SysParameter.getSysParameter(SysParameter.PARAMETER_10)
  2331. itemTable[equipID] = 1
  2332. end
  2333. itemTable[ItemDefine.ITEM_JINBI_ID] = itemTable[ItemDefine.ITEM_JINBI_ID] or 0
  2334. itemTable[ItemDefine.ITEM_EXP_ID] = itemTable[ItemDefine.ITEM_EXP_ID] or 0
  2335. itemTable[ItemDefine.ITEM_GREEN_EXP_ID] = itemTable[ItemDefine.ITEM_GREEN_EXP_ID] or 0
  2336. itemTable[ItemDefine.ITEM_QINGBAO_ID] = itemTable[ItemDefine.ITEM_QINGBAO_ID] or 0
  2337. itemTable[ItemDefine.ITEM_JINBI_ID] = itemTable[ItemDefine.ITEM_JINBI_ID] + addJinbi
  2338. itemTable[ItemDefine.ITEM_EXP_ID] = itemTable[ItemDefine.ITEM_EXP_ID] + addExp
  2339. itemTable[ItemDefine.ITEM_GREEN_EXP_ID] = itemTable[ItemDefine.ITEM_GREEN_EXP_ID] + addGreenExp
  2340. itemTable[ItemDefine.ITEM_QINGBAO_ID] = itemTable[ItemDefine.ITEM_QINGBAO_ID] + addQingbao
  2341. msgRet.item[0] = 0
  2342. -- 双倍日
  2343. local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  2344. local rewardCnt = double and 2 or 1
  2345. for itemID, itemCnt in pairs(itemTable) do
  2346. itemCnt = itemCnt * rewardCnt
  2347. if not ItemDefine.isEquip(itemID) then
  2348. msgRet.item[0] = msgRet.item[0] + 1
  2349. Grid.makeItem(msgRet.item[msgRet.item[0]], itemID, itemCnt)
  2350. end
  2351. BagLogic.addItem(human, itemID, itemCnt, "battle")
  2352. end
  2353. msgRet.item[0] = EquipLogic.makeEquipItem(human, msgRet.item, msgRet.item[0])
  2354. msgRet.double = double and 1 or 0
  2355. msgRet.exp = itemTable[ItemDefine.ITEM_EXP_ID] * rewardCnt
  2356. msgRet.jinbi = itemTable[ItemDefine.ITEM_JINBI_ID] * rewardCnt
  2357. msgRet.greenExp = itemTable[ItemDefine.ITEM_GREEN_EXP_ID] * rewardCnt
  2358. msgRet.qingbao = itemTable[ItemDefine.ITEM_QINGBAO_ID] * rewardCnt
  2359. Msg.send(msgRet, human.fd)
  2360. mopupQuery(human)
  2361. query(human)
  2362. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  2363. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_BATTLE_SD)
  2364. DailyTaskLogic.recordDailyTaskFinishCnt(human, DailyTaskLogic.DAILY_TASK_ID_12, 1)
  2365. ChengjiuLogic.onCallback(human, ChengjiuDefine.CJ_TASK_TYPE_3, 1)
  2366. HeroLogLogic.finishTaskCB(human, HeroLogLogic.HERO_LOG_TYPE_3, 1)
  2367. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2001)
  2368. YunYingLogic.onCallBack(human, "onMopup", 1)
  2369. end
  2370. function updateDaily(human)
  2371. human.db.mopupFreeCnt = 0
  2372. human.db.mopupDoCnt = 0
  2373. end
  2374. function getTongGuanReward(human, id)
  2375. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2376. local nNowGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2377. if not tBattleConfig or -1 >= nNowGuaJiID then
  2378. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getTongGuanReward] 获取战斗配置、挂机ID 失败 id = "
  2379. ..human.db._id.. "account = "..human.db.account.." name = "..human.db.name)
  2380. print("[getTongGuanReward] 获取战斗配置、挂机ID 失败")
  2381. return
  2382. end
  2383. local cf = tBattleConfig.node[id]
  2384. if not cf then
  2385. return
  2386. end
  2387. if #cf.tongguan < 1 then
  2388. return
  2389. end
  2390. print("human.db.guajiID,id", nNowGuaJiID, id)
  2391. if nNowGuaJiID < id then
  2392. return
  2393. end
  2394. if isGetReward(human, id) then
  2395. return
  2396. end
  2397. if #cf.tongguan == 1 and cf.tongguan[1][3] then
  2398. -- 英雄
  2399. if HeroLogic.getEmptyCnt(human) < 1 then
  2400. return Broadcast.sendErr(human, Lang.HERO_BAG_FULL)
  2401. end
  2402. local heroID = cf.tongguan[1][1]
  2403. local cnt = cf.tongguan[1][2]
  2404. local star = cf.tongguan[1][3]
  2405. if cnt <= 0 then
  2406. return
  2407. end
  2408. setGetReward(human, id)
  2409. local msg = Msg.gc.GC_SUIPIAN_SUMMON
  2410. for i = 1, cnt do
  2411. local heroGrid = HeroGrid.createHeroGrid(heroID, star)
  2412. HeroLogic.addHeroByGrid(human, heroGrid, "battle_extra_reward")
  2413. SuipianLogic.makeResultItemData(msg.heroList[i], heroID, 1, 1)
  2414. end
  2415. msg.isHero = 1
  2416. msg.list[0] = 0
  2417. msg.heroList[0] = cnt
  2418. msg.fenJieList[0] = 0
  2419. Msg.send(msg, human.fd)
  2420. else
  2421. setGetReward(human, id)
  2422. BagLogic.addItemList(human, cf.tongguan, "tongguan")
  2423. end
  2424. -- 触发国王君临奖励
  2425. ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE5, id)
  2426. query(human)
  2427. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
  2428. if id == 80 then
  2429. KingWorldLogic.setState(human, 1)
  2430. end
  2431. end
  2432. function isDot(human)
  2433. -- 通过大关卡奖励
  2434. local chapterReward = BattleLogic_GetChapterReward(human)
  2435. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2436. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2437. if -1 >= nBattleID or not tBattleExcel or not chapterReward then
  2438. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[isDot] 获取不到对应的大关卡奖励表 或配置表、战斗ID")
  2439. print("[isDot] 获取不到对应的大关卡奖励表 或配置表、战斗ID id = "..human.db._id)
  2440. return
  2441. end
  2442. -- local chapterReward = human.db.chapterReward or { }
  2443. -- local battleID = human.db.battleID
  2444. -- local battleNodeConfig = BattleExcel.node[battleID]
  2445. local battleID = nBattleID
  2446. local battleNodeConfig = tBattleExcel.node[battleID]
  2447. if not battleNodeConfig then
  2448. local nodeCnt = #tBattleExcel.node
  2449. local mapCnt = #tBattleExcel.map
  2450. if battleID == nodeCnt + 1 and not chapterReward[mapCnt] then
  2451. return true
  2452. else
  2453. return false
  2454. end
  2455. else
  2456. local mapID = battleNodeConfig.mapID
  2457. for i = mapID - 1, 1, -1 do
  2458. if not chapterReward[i] then
  2459. return true
  2460. end
  2461. end
  2462. end
  2463. return false
  2464. -- if human.db.lv < 9 then
  2465. -- return false
  2466. -- end
  2467. -- -- 有免费扫荡次数的时候有红点
  2468. -- human.db.mopupFreeCnt = human.db.mopupFreeCnt or 0
  2469. -- if TequanShopLogic.isActiveMopup(human) then
  2470. -- if human.db.mopupFreeCnt < 3 then
  2471. -- return true
  2472. -- end
  2473. -- else
  2474. -- if human.db.mopupFreeCnt < 1 then
  2475. -- return true
  2476. -- end
  2477. -- end
  2478. -- -- 有通关奖励可领取的时候有红点
  2479. -- if hasCanGetReward(human) then
  2480. -- return true
  2481. -- end
  2482. -- -- 战役挂机时间超过1小时的时候有红点
  2483. -- if human.db.battleOut ~= nil then
  2484. -- local now = os.time()
  2485. -- local outSec = now - human.db.battleOut.expTs1
  2486. -- if outSec >= 3600 then
  2487. -- return true
  2488. -- end
  2489. -- end
  2490. -- return false
  2491. end
  2492. function clacItemTwoHours(human)
  2493. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2494. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2495. if not tBattleConfig or -1 >= nGuaJiID then
  2496. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[clacItemTwoHours] 获取到的挂机ID、战斗配置不正确 id = "..human.db._id)
  2497. print("[clacItemTwoHours] 获取到的挂机ID、战斗配置不正确 id = "..human.db._id)
  2498. return
  2499. end
  2500. local items = { }
  2501. local outCnt = math.floor(7200 / BATTLE_HANG_ITEM_OUT_PERIOD)
  2502. -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
  2503. local guajiID = nGuaJiID > #tBattleConfig.node and #tBattleConfig.node or nGuaJiID
  2504. if guajiID == 0 then
  2505. return items
  2506. end
  2507. -- local nodeConfig = BattleExcel.node[guajiID]
  2508. local nodeConfig = tBattleConfig.node[guajiID]
  2509. local dropID = nodeConfig.dropID
  2510. local dropConfig = DropExcel.dropBattle[dropID]
  2511. local totalWeight = 0
  2512. for i = 1, #dropConfig.dropRule do
  2513. local tempConfig = dropConfig.dropRule[i]
  2514. totalWeight = totalWeight + tempConfig[4]
  2515. end
  2516. for j = 1, outCnt do
  2517. local randomNum = math.random(1, totalWeight)
  2518. for i = 1, #dropConfig.dropRule do
  2519. local tempConfig = dropConfig.dropRule[i]
  2520. local itemID = tempConfig[1]
  2521. local itemCnt1 = tempConfig[2]
  2522. local itemCnt2 = tempConfig[3]
  2523. local itemRate = tempConfig[4]
  2524. if randomNum <= itemRate then
  2525. local realAdd = math.random(itemCnt1, itemCnt2)
  2526. items[itemID] = realAdd
  2527. break
  2528. end
  2529. randomNum = randomNum - itemRate
  2530. end
  2531. end
  2532. return items
  2533. end
  2534. local MailManager = require("mail.MailManager")
  2535. function clacItemCntGM(human, cnt, guajiID)
  2536. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2537. if not tBattleConfig then
  2538. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[clacItemCntGM] 获取到战斗配置不正确 id = "..human.db._id)
  2539. print("[clacItemTwoHours] 获取到的战斗配置不正确 id = "..human.db._id)
  2540. return
  2541. end
  2542. local items = { }
  2543. local outCnt = cnt
  2544. local nodeConfig = tBattleConfig.node[guajiID]
  2545. local dropID = nodeConfig.dropID
  2546. local dropConfig = DropExcel.dropBattle[dropID]
  2547. local totalWeight = 0
  2548. for i = 1, #dropConfig.dropRule do
  2549. local tempConfig = dropConfig.dropRule[i]
  2550. totalWeight = totalWeight + tempConfig[4]
  2551. end
  2552. for j = 1, outCnt do
  2553. local randomNum = math.random(1, totalWeight)
  2554. for i = 1, #dropConfig.dropRule do
  2555. local tempConfig = dropConfig.dropRule[i]
  2556. local itemID = tempConfig[1]
  2557. local itemCnt1 = tempConfig[2]
  2558. local itemCnt2 = tempConfig[3]
  2559. local itemRate = tempConfig[4]
  2560. if randomNum <= itemRate then
  2561. local realAdd = math.random(itemCnt1, itemCnt2)
  2562. items[itemID] = items[itemID] or 0
  2563. items[itemID] = items[itemID] + realAdd
  2564. break
  2565. end
  2566. randomNum = randomNum - itemRate
  2567. end
  2568. end
  2569. local item = { }
  2570. local index = 0
  2571. for k, v in pairs(items) do
  2572. index = index + 1
  2573. item[index] = { k, v }
  2574. end
  2575. MailManager.add(MailManager.SYSTEM, human.db._id, "", "", item, "")
  2576. end
  2577. function getBattleID(human)
  2578. local num = 0
  2579. local nGuaJiID = BattleLogic_GetBattleGuaJiID(human)
  2580. if -1 < nGuaJiID then
  2581. num = nGuaJiID
  2582. end
  2583. -- if human.db.guajiID then
  2584. -- num = human.db.guajiID or 0
  2585. -- end
  2586. return num
  2587. end
  2588. --------------------------------------------- combat ----------------------------------------------
  2589. function getCombatMonsterOutID(human, side)
  2590. if side ~= CombatDefine.DEFEND_SIDE then
  2591. return
  2592. end
  2593. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2594. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2595. if not tBattleExcel or -1 >= nBattleID then
  2596. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getCombatMonsterOutID] 获取到的战斗配置、或战斗ID不正确 id = "..human.db._id)
  2597. print("[getCombatMonsterOutID] 获取到的战斗配置、或战斗ID不正确 id = "..human.db._id)
  2598. return
  2599. end
  2600. -- local config = BattleExcel.node[human.db.battleID]
  2601. local config = tBattleExcel.node[nBattleID]
  2602. if not config then
  2603. return
  2604. end
  2605. return config.monsterOutID
  2606. end
  2607. function getCombatName(human)
  2608. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2609. if -1 >= nBattleID then
  2610. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[getCombatMonsterOutID] 获取到的战斗ID不正确 id = "..human.db._id)
  2611. print("[getCombatMonsterOutID] 获取到的战斗ID不正确 id = "..human.db._id)
  2612. return ""
  2613. end
  2614. local name = getBattleName(human, nBattleID)
  2615. return Util.format(Lang.COMBAT_BATTLE_EXNAME, name)
  2616. end
  2617. -------------------------------------------combat end--------------------
  2618. function battleSharkQuery(human, nodeID)
  2619. local msgRet = Msg.gc.GC_BATTLE_SHARK_QUERY
  2620. local videoTb = BattleDBLogic.queryBattleDbByNodeID(nodeID)
  2621. if videoTb == nil then
  2622. msgRet.battleShark[0] = 0
  2623. else
  2624. local len = #videoTb.shark
  2625. for i = 1, len do
  2626. local v = videoTb.shark[i]
  2627. RoleLogic.makeRoleBase(v.roleBase, msgRet.battleShark[i].roleBase)
  2628. msgRet.battleShark[i].type = i
  2629. msgRet.battleShark[i].videoUuid = v.videoUuid
  2630. msgRet.battleShark[i].param = v.param or 0
  2631. end
  2632. msgRet.battleShark[0] = len
  2633. end
  2634. -- Msg.trace(msgRet)
  2635. Msg.send(msgRet, human.fd)
  2636. end
  2637. local QueryRoleByNodeID = { }
  2638. function worldMapRoleListQuery(human, worldMapId)
  2639. -- if worldMapId == 1 then return end
  2640. local msgRet = Msg.gc.GC_BATTLE_WORLD_MAP_ROLELIST_QUERY
  2641. local len = 0
  2642. for k, v in pairs(BATTLE_LEVEL_PLAYER_LIST[worldMapId]) do
  2643. len = len + 1
  2644. RoleLogic.makeRoleBase(v, msgRet.roleList[len])
  2645. if len >= 50 then
  2646. break
  2647. end
  2648. end
  2649. msgRet.roleList[0] = len
  2650. Msg.send(msgRet, human.fd)
  2651. end
  2652. -- 章节(地图)掉落列表
  2653. function sendMapDroItemsList(human)
  2654. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2655. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2656. if not tBattleExcel then
  2657. print("[sendMapDroItemsList] 获取当前战斗配置失败 id = "..human.db._id)
  2658. return
  2659. end
  2660. local battleID = 1
  2661. if -1 < nBattleID then
  2662. battleID = nBattleID
  2663. end
  2664. local maxBattleConfig = tBattleExcel.node[battleID]
  2665. local maxMapID = maxBattleConfig and maxBattleConfig.mapID or(#tBattleExcel.node + 1)
  2666. local msgRet = Msg.gc.GC_BATTLE_MAP_DROPITEMS_LIST
  2667. msgRet.list[0] = 0
  2668. for mapID, mapConfig in ipairs(tBattleExcel.map) do
  2669. msgRet.list[0] = msgRet.list[0] + 1
  2670. local net = msgRet.list[msgRet.list[0]]
  2671. net.mapID = mapID
  2672. net.mapName = mapConfig.name
  2673. net.isOpen =(mapID <= maxMapID) and 1 or 0
  2674. end
  2675. -- Msg.trace(msgRet)
  2676. Msg.send(msgRet, human.fd)
  2677. end
  2678. -- 章节(地图)掉落详情
  2679. function sendMapDroItemsDetail(human, mapID)
  2680. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2681. if not tBattleExcel then
  2682. print("[sendMapDroItemsDetail] 获取当前战斗配置失败 id = "..human.db._id)
  2683. return
  2684. end
  2685. local mapConfig = tBattleExcel.map[mapID]
  2686. if not mapConfig then
  2687. return
  2688. end
  2689. local msgRet = Msg.gc.GC_BATTLE_MAP_DROPITEMS_DETAIL
  2690. msgRet.mapID = mapID
  2691. msgRet.items[0] = math.min(#mapConfig.dropItemsShow, #msgRet.items)
  2692. for i = 1, msgRet.items[0] do
  2693. local itemID = mapConfig.dropItemsShow[i][1]
  2694. local itemCnt = mapConfig.dropItemsShow[i][2]
  2695. Grid.makeItem(msgRet.items[i], itemID, itemCnt)
  2696. end
  2697. -- Msg.trace(msgRet)
  2698. Msg.send(msgRet, human.fd)
  2699. end
  2700. -- 获取当前战役的 怪物ID
  2701. function getBattleMonsterOutID(human)
  2702. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2703. local tBattleExcel = BattleLogic_GetBattleConfig(human)
  2704. if -1 >= nBattleID or not tBattleExcel then
  2705. print("[getBattleMonsterOutID] 获取当前战斗ID、配置失败 id = "..human.db._id)
  2706. return 0
  2707. end
  2708. -- local battleID = human.db.battleID
  2709. -- local config = BattleExcel.node[battleID]
  2710. local config = tBattleExcel.node[nBattleID]
  2711. return config.monsterOutID
  2712. end
  2713. function onUpdatePos(human)
  2714. BRoleLogic.updateData(BillboardDefine.TYPE_ZHANDOULI, human.db)
  2715. end
  2716. function getNextRewardName(human)
  2717. local guajiID = BattleLogic_GetBattleGuaJiID(human)
  2718. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2719. if not tBattleConfig or -1 >= guajiID then
  2720. return nil, nil
  2721. end
  2722. -- for i = human.db.guajiID + 1, #BattleExcel.node do
  2723. for i = guajiID + 1, #tBattleConfig.node do
  2724. if #tBattleConfig.node[i].tongguan > 0 then
  2725. local itemID = tBattleConfig.node[i].tongguan[1][1]
  2726. local itemConfig = ItemDefine.getConfig(itemID)
  2727. if itemConfig == nil then
  2728. return
  2729. else
  2730. return i - guajiID, itemConfig.name
  2731. end
  2732. end
  2733. end
  2734. end
  2735. --[[
  2736. 通关章节后领取奖励
  2737. ]]
  2738. function battleChapterReward(human, mapID)
  2739. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2740. local nBattleID = BattleLogic_GetBattleBattleID(human)
  2741. local tChapterReward = BattleLogic_GetChapterReward(human)
  2742. if not tBattleConfig or -1 >= nBattleID or not tChapterReward then
  2743. print("[battleChapterReward] 获取到的战斗ID、配置、通关章节奖励表 不正确 id = "..human.db._id)
  2744. return
  2745. end
  2746. local mapConf = tBattleConfig.map[mapID]
  2747. if not mapConf then
  2748. return
  2749. end
  2750. -- 没有通过当前大关卡
  2751. local battleID = nBattleID
  2752. local battleNodeConfig = tBattleConfig.node[battleID]
  2753. local roleMapId
  2754. if not battleNodeConfig then
  2755. if battleID ~= #tBattleConfig.node + 1 then
  2756. return
  2757. else
  2758. roleMapId = #tBattleConfig.map
  2759. end
  2760. else
  2761. roleMapId = battleNodeConfig.mapID
  2762. end
  2763. if mapID > roleMapId then
  2764. return
  2765. end
  2766. -- if not human.db.chapterReward then
  2767. -- human.db.chapterReward = { }
  2768. -- end
  2769. -- 判断是否已经领取了当前大关卡的奖励
  2770. -- local chapterReward = human.db.chapterReward
  2771. local chapterReward = tChapterReward
  2772. if chapterReward[mapID] then
  2773. return Broadcast.sendErr(human, Lang.FRIEND_HEART_GET_HAD)
  2774. end
  2775. chapterReward[mapID] = true
  2776. ObjHuman.save(human)
  2777. local reward = mapConf.reward
  2778. BagLogic.addItemList(human, reward, "chapterReward")
  2779. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1105)
  2780. local msgRet = Msg.gc.GC_BATTLE_CHAPTER_REWARD
  2781. msgRet.mapID = mapID
  2782. Msg.send(msgRet, human.fd)
  2783. end
  2784. -- 判断难度是否解锁
  2785. local function BattleLogic_CheckDiffIsOK(human, nSelectDiff)
  2786. -- 默认难度直接通过
  2787. if EliteDefine.COPY_ELITE_NORMAL == nSelectDiff then
  2788. return EliteDefine.COPY_SELECT_SUCC
  2789. end
  2790. -- 等级不够
  2791. if human.db.lv < EliteDefine.COPY_ELITE_ULEV then
  2792. return EliteDefine.COPY_SELECT_LEV
  2793. end
  2794. local nChoseBattleID = (EliteDefine.COPY_LEVEL_ELITE == nSelectDiff) and human.db.battleID or human.db.battleID_elite
  2795. return nChoseBattleID >= EliteDefine.COPY_ELITE_LEVEL and EliteDefine.COPY_SELECT_SUCC or EliteDefine.COPY_SELECT_MAIN
  2796. end
  2797. -- 获取未领取奖励
  2798. local function BattleLogic_GetNorewardReceived(human, nBattleType, cIndex)
  2799. print("1:[BattleLogic_GetNorewardReceived] id = "..human.db._id.." nBattleType = "..nBattleType)
  2800. local nBattleID = BattleLogic_GetBattleIDByType(human, nBattleType)
  2801. local tBattleConfig = BattleLogic_GetBattleConfigByType(nBattleType)
  2802. local nGuaJiID = BattleLogic_GetBattleGuaJiIDByType(human, nBattleType)
  2803. if -1 >= nBattleID or not tBattleConfig or -1 >= nGuaJiID then
  2804. print("[BattleLogic_GetNorewardReceived] 获取配置失败")
  2805. return
  2806. end
  2807. local msgRet = Msg.gc.GC_BATTLE_QUERY_ALL
  2808. msgRet.index = nBattleType
  2809. msgRet.list[0] = 0
  2810. msgRet.isEnd = 0
  2811. msgRet.curIndex = 0
  2812. local curIndex = 1
  2813. -- human.db.battleID = human.db.battleID or 1
  2814. -- if human.db.battleID == 0 then
  2815. -- human.db.battleID = 1
  2816. -- end
  2817. human.db.mopupDoCnt = human.db.mopupDoCnt or 0
  2818. local curBattleNumber = cIndex
  2819. local curTotalNumber = 0
  2820. local battleNumber = #tBattleConfig.node
  2821. -- local nGuajiID = human.db.guajiID or 0
  2822. print("[BattleLogic_GetNorewardReceived] nGuajiID = "..nGuaJiID)
  2823. for k,v in ipairs(tBattleConfig.node) do
  2824. if #v.tongguan ~= 0 then
  2825. -- 领取状态
  2826. local state = false
  2827. if k <= nGuaJiID then
  2828. state = isGetRewardByType(human,k, nBattleType)
  2829. end
  2830. if not (state == true) then
  2831. local r = STATUS_CANGET
  2832. --(k > nGuaJiID) and STATUS_CANGET or STATUS_NONE
  2833. --未领取
  2834. if r == STATUS_CANGET then
  2835. curTotalNumber = curTotalNumber + 1
  2836. if curTotalNumber > curBattleNumber then
  2837. --构造
  2838. local cf = tBattleConfig.node[k].tongguan
  2839. local net = msgRet.list[curIndex]
  2840. net.status = k <= nGuaJiID and STATUS_CANGET or STATUS_NONE
  2841. net.levelName = getBattleNameByType(k, nBattleType)
  2842. net.index = k
  2843. net.nowBattle = getBattleNameByType(nGuaJiID, nBattleType)
  2844. net.reward[0] = 0
  2845. net.heroReward[0] = 0
  2846. if cf[1][3] then
  2847. net.heroReward[0] = 1
  2848. local other = { }
  2849. other.star = cf[1][3]
  2850. HeroGrid.makeHeroSimpleByID(net.heroReward[1], cf[1][1], nil, other, human)
  2851. HeroGrid.makeHeroSimpleByGeneral(net.heroReward[1], cf[1][1])
  2852. local tHeroInfo = Util.printTable(net.heroReward)
  2853. -- print("[BattleLogic_GetNorewardReceived] 英雄数据 k = "..k.." 获取的数据 = "..tHeroInfo)
  2854. else
  2855. net.reward[0] = 1
  2856. for i = 1, net.reward[0] do
  2857. local itemID = cf[i][1]
  2858. local itemCnt = cf[i][2]
  2859. Grid.makeItem(net.reward[i], itemID, itemCnt)
  2860. end
  2861. end
  2862. curIndex = curIndex + 1
  2863. msgRet.list[0] = msgRet.list[0] + 1
  2864. if msgRet.list[0] >= 15 then
  2865. local ret = 0
  2866. if k < battleNumber then
  2867. for kk, vv in ipairs(tBattleConfig.node) do
  2868. if kk > k then
  2869. if v.tongguan ~= 0 then
  2870. local nNextstate = isGetRewardByType(human,kk, nBattleType)
  2871. if not (nNextstate == true) then
  2872. local rr =(kk > nGuaJiID) and STATUS_CANGET or STATUS_NONE
  2873. --未领取
  2874. if rr == STATUS_CANGET then
  2875. ret = 1
  2876. break
  2877. end
  2878. end
  2879. end
  2880. end
  2881. end
  2882. end
  2883. if ret == 1 then
  2884. --没有结束
  2885. msgRet.isEnd = 0
  2886. else
  2887. msgRet.isEnd = 1
  2888. end
  2889. msgRet.curIndex=curTotalNumber
  2890. -- curIndex = 1
  2891. Msg.send(msgRet, human.fd)
  2892. print("[BattleLogic_GetNorewardReceived] send client msgRet.curIndex:"..msgRet.curIndex.." msgRet.isEnd:"..msgRet.isEnd.." msgRet.list[0]:"..msgRet.list[0])
  2893. --local info=Util.printTable(msgRet)
  2894. --print("getNorewardReceived0->>:"..info)
  2895. return
  2896. end
  2897. end
  2898. end
  2899. else
  2900. print("[BattleLogic_GetNorewardReceived] 奖励已领取:"..k)
  2901. end
  2902. end
  2903. end
  2904. --结束
  2905. msgRet.isEnd = 1
  2906. msgRet.curIndex=0
  2907. Msg.send(msgRet, human.fd)
  2908. end
  2909. -- 客户端请求查询难度
  2910. function CG_ELITE_OPEN(human)
  2911. BattleLogic_QueryDifficulty(human)
  2912. end
  2913. -- 客户端请求切换难度
  2914. function CG_ELITE_SELECT(human, nSelectDiff)
  2915. if EliteDefine.COPY_ELITE_NORMAL > nSelectDiff or EliteDefine.COPY_ELITE_DIFFICULTY < nSelectDiff then
  2916. Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[CG_ELITE_SELECT] 客户端传入的参数不正确 id = "..human.db._id .. "nSelectDiff = "..nSelectDiff)
  2917. print("[CG_ELITE_SELECT] 客户端选择难度,上传的难度不正确 id = "..human.db._id .. "nSelectDiff = "..nSelectDiff)
  2918. return
  2919. end
  2920. local nStatus = BattleLogic_CheckDiffIsOK(human, nSelectDiff)
  2921. print("[CG_ELITE_SELECT] nStatus = "..nStatus.. " 选择的难度 nSelectDiff = "..nSelectDiff)
  2922. -- 设置类型
  2923. if EliteDefine.COPY_SELECT_SUCC == nStatus then
  2924. BattleLogic_SetBattleType(human,nSelectDiff)
  2925. end
  2926. local msgRet = Msg.gc.GC_ELITE_SELECT
  2927. msgRet.status = nStatus
  2928. Msg.send(msgRet,human.fd)
  2929. end
  2930. -- 客户端请求领取奖励
  2931. function CG_BATTLE_TONGGUAN_REWARD_GET_COPY(human, nBattleType, nBattleID)
  2932. local tBattleConfig = BattleLogic_GetBattleConfig(human)
  2933. local nGuaJiID = BattleLogic_GetBattleGuaJiIDByType(human, nBattleType)
  2934. if not tBattleConfig or -1 >= nGuaJiID then
  2935. return
  2936. end
  2937. local tMsgRet = Msg.gc.GC_BATTLE_TONGGUAN_REWARD_GET_COPY
  2938. local tConfig = tBattleConfig.node[nBattleID].tongguan
  2939. if #tConfig < 1 then
  2940. tMsgRet.status = 0
  2941. Msg.send(tMsgRet, human.fd)
  2942. return
  2943. end
  2944. tMsgRet.status = 1
  2945. getTongGuanReward(human, nBattleID)
  2946. tMsgRet.tongguan[0] = 0
  2947. if #tConfig ~= 0 then
  2948. tMsgRet.tongguan[0] = 1
  2949. local tNet = tMsgRet.tongguan[1]
  2950. tNet.status = STATUS_NONE
  2951. tNet.levelName = getBattleNameByType(nBattleID, nBattleType)
  2952. tNet.index = nBattleID
  2953. tNet.nowBattle = getBattleNameByType(nGuaJiID, nBattleType)
  2954. tNet.reward[0] = 0
  2955. tNet.heroReward[0] = 0
  2956. if tConfig[1][3] then
  2957. tNet.heroReward[0] = 1
  2958. local other = { }
  2959. other.star = tConfig[1][3]
  2960. HeroGrid.makeHeroSimpleByID(tNet.heroReward[1], tConfig[1][1], nil, other, human)
  2961. HeroGrid.makeHeroSimpleByGeneral(tNet.heroReward[1], tConfig[1][1])
  2962. else
  2963. tNet.reward[0] = 1
  2964. for i = 1, tNet.reward[0] do
  2965. local itemID = tConfig[i][1]
  2966. local itemCnt = tConfig[i][2]
  2967. Grid.makeItem(tNet.reward[i], itemID, itemCnt)
  2968. end
  2969. end
  2970. end
  2971. Msg.send(tMsgRet, human.fd)
  2972. end
  2973. -- 客户端请求查询所有未领取奖励
  2974. function CG_BATTLE_QUERY_ALL(human, nBattleType, curIndex)
  2975. if EliteDefine.COPY_ELITE_NORMAL > nBattleType or EliteDefine.COPY_ELITE_DIFFICULTY < nBattleType then
  2976. print("[CG_BATTLE_QUERY_ALL] 客户端请求的战斗类型不正确 id = "..human.db._id.." nType = "..nBattleType)
  2977. return
  2978. end
  2979. BattleLogic_GetNorewardReceived(human, nBattleType, curIndex)
  2980. end