base_config.go 235 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003
  1. package model
  2. import (
  3. "errors"
  4. "math/rand"
  5. "reflect"
  6. "rocommon/service"
  7. "rocommon/util"
  8. "roserver/baseserver/set"
  9. "roserver/serverproto"
  10. "sort"
  11. "strconv"
  12. "strings"
  13. "time"
  14. )
  15. func BaseConfigInit(sConfig service.ConfigServerNode) {
  16. path := sConfig.Node.Config + "/"
  17. //不同服务器类型做不同配置文件加载(game服务器加载所有配置文件),内存优化处理
  18. switch sConfig.Node.Type {
  19. case SERVICE_NODE_TYPE_BOSS: //battleboss
  20. serverproto.WorldBossCfgLoad(path + "csv/")
  21. serverproto.WorldBossChangePlayCfgLoad(path + "csv/")
  22. serverproto.NpcCfgLoad(path + "csv/")
  23. convertWorldBossCfg()
  24. case SERVICE_NODE_TYPE_GUILD: //guild
  25. serverproto.GuildBossCfgLoad(path + "csv/")
  26. serverproto.GuildBossRewardCfgLoad(path + "csv/")
  27. serverproto.GuildWarDojoCfgLoad(path + "csv/")
  28. serverproto.GuildLvCfgLoad(path + "csv/")
  29. serverproto.GlobalCfgLoad(path + "csv/")
  30. serverproto.GuildDemonCfgLoad(path + "csv/")
  31. serverproto.GuildWarBuffCfgLoad(path + "csv/")
  32. convertGlobalCfg() //通用全局属性加载
  33. convertGuildLevelCfg() //公会等级相关
  34. convertGuildBosRewardsCfg() //公会BOSS奖励
  35. convertGuildBattleCfg() //公会战
  36. convertGuildDemonCfg() //公会魔王
  37. convertGuildWarCfg()
  38. case SERVICE_NODE_TYPE_DB: //db
  39. serverproto.PetCfgLoad(path + "csv/")
  40. convertPetCfg() //pet
  41. case SERVICE_NODE_TYPE_WEBGM: //gmweb
  42. //添加到热更新列表中
  43. serverproto.CFGNameList["AdvertisingScreen"] = serverproto.AdvertisingScreenLoad
  44. serverproto.CFGNameList["CombinedServiceCfg"] = serverproto.CombinedServiceCfgLoad
  45. case SERVICE_NODE_TYPE_RANK: //rank
  46. serverproto.CompetitionCfgLoad(path + "csv/")
  47. serverproto.HundredDojoCfgLoad(path + "csv/")
  48. serverproto.RobotCfgLoad(path + "csv/")
  49. serverproto.RushListCfgLoad(path + "csv/")
  50. serverproto.RushListTargetCfgLoad(path + "csv/")
  51. serverproto.GlobalCfgLoad(path + "csv/")
  52. convertGlobalCfg() //通用全局属性加载
  53. convertCompetitionCfg() //赛季玩法
  54. convertRobotCfg()
  55. convertDaoChang100Cfg() //百人道场
  56. convertRushListCfg() //冲榜相关
  57. case SERVICE_NODE_TYPE_CROSSSERVER:
  58. serverproto.TransportCfgLoad(path + "csv/")
  59. convertYuanHangTrailCfg() //远航试炼
  60. case SERVICE_NODE_TYPE_CROSSRANK: //跨服排行榜
  61. serverproto.TopTowerCfgLevelLoad(path + "csv/")
  62. serverproto.TopTowerCfgRewardLoad(path + "csv/")
  63. convertTopTowerCfg()
  64. case SERVICE_NODE_TYPE_GLOBALCROSSMAP:
  65. //TODO...
  66. default:
  67. //这边添加需要加载的配置文件列表,每个服务器不一样需要手动添加
  68. //热加载,需要加锁处理
  69. serverproto.ConfigInit(path + "csv/")
  70. convertGlobalCfg() //通用全局属性加载
  71. convertUIFuncUnLockCfg() //功能解锁问题
  72. //处理配置表数据,提高使用效率
  73. convertQualityPointCfg()
  74. convertCardCfg()
  75. convertDropCfg() //关卡掉落
  76. convertTaskCfg() //任务数据解析
  77. convertParterProgressCfg()
  78. convertParterSkillTreeCfg()
  79. convertRoleAttributeCfg()
  80. convertJobAttrCfg()
  81. convertPartnerAttrCfg()
  82. convertFashionCfg()
  83. convertCardAttCfg()
  84. convertEquipCfg()
  85. convertEquipRefineCfg()
  86. convertFightPowerCfg()
  87. convertEquipSuitCfg()
  88. //convertSlotCfg() //寻宝数据解析
  89. convertChangeJobCfg()
  90. convertArenaCfg(int32(sConfig.Node.Zone)) //竞技场
  91. convertRobotCfg() //匹配机器人
  92. convertWorldBossCfg() //世界boss
  93. convertSkillUpEffect() //被动技能
  94. convertCompetitionCfg() //赛季玩法
  95. convertCompetitionPrizeWheelCfg() //第三赛季转盘
  96. convertCardResetCfg() //卡片分解
  97. convertShopCfg() //商店
  98. convertActiveCodeCfg() //激活码
  99. convertSignInCfg() //签到
  100. convertMapCfg() //关卡数据
  101. convertNatureCfg() //属性对抗处理
  102. convertTowerCfg() //爬塔奖励
  103. convertEvilCfg() //恶魔协会
  104. convertCardCollectCfg() //收集卡片奖励
  105. // convertVIPCfg() //vip相关次数
  106. convertPetCfg() //pet
  107. convertGuildLevelCfg() //公会等级相关
  108. convertGuildBosRewardsCfg() //公会BOSS奖励
  109. convertGuildBattleCfg() //公会战
  110. convertExpeditionCfg() //远征之门
  111. convertActivitiesCfg() //精彩活动
  112. convertHeadFrameCfg() //头像框
  113. convertInvitationCfg() //invitation邀请码
  114. convertVipCfg() //VIP
  115. convertSummonCfg() //抽卡
  116. convertRuneCfg() //卢恩商会
  117. convertRushListCfg() //冲榜
  118. convertDaoChang100Cfg() //百人道场
  119. convertKeepSakeCfg() //藏品
  120. convertCardSuitNewCfg() //卡片祝福
  121. covertFashionLevelUpCfg() //时装升级
  122. convertFashionRandomCfg() //时装洗练
  123. converFashionSuitCfg() //套装升级
  124. convertRuneShopExploreCfg() // 战令升级
  125. convertRuneShopExploreRewardCfg() // 战令
  126. convertGuildWarCfg() //公会战
  127. convertOnlineTimeRewardCfg() //累计在线时间奖励获取
  128. convertQualityFruitCfg() // 潜力果实
  129. convertJobChangeCfg() // 职业转职
  130. convertSysRewardCfg() //系统补偿数据表
  131. convertCompetitionDevineCfg() //占卜
  132. convertYuanHangTrailCfg() //远航试炼
  133. convertActivitiesKingTaskCfg() // 国王悬赏 任务
  134. convertSkillEquipCfg() // 神器
  135. convertHeadDataCfg() // 称号系统
  136. convertGuildDemonCfg() //公会魔王
  137. convertTopTowerCfg() //巅峰之塔
  138. convertActivitySignInCfg() //活动签到
  139. convertIdolSeasonCfg() //粉丝馈赠
  140. convertWishCfg() //许愿宝箱
  141. ConvertCombinedServer() //合服
  142. }
  143. util.InfoF("config load success!!!")
  144. }
  145. //todo...热加载使用
  146. func ReloadConfig() {
  147. sConfig := service.GetServiceConfig()
  148. BaseConfigInit(sConfig)
  149. util.InfoF("config reloead success!!!")
  150. }
  151. func ReloadConfigByName(cfgName string) {
  152. sConfig := service.GetServiceConfig()
  153. path := sConfig.Node.Config + "/csv/"
  154. fuc, ok := serverproto.CFGNameList[cfgName]
  155. if ok {
  156. fuc(path)
  157. //转换数据部分
  158. switch cfgName {
  159. case "Transport":
  160. convertYuanHangTrailCfg()
  161. }
  162. }
  163. }
  164. var AdvSensitiveUtil *util.DFAUtil = nil
  165. func LoadAdvSensitiveWords() {
  166. AdvSensitiveUtil = util.NewDFAUtil(nil)
  167. for _, val := range serverproto.AdvertisingScreenLoader {
  168. //valList := strings.Split(val.Type, ",")
  169. util.DFAInsertWord(AdvSensitiveUtil, []string{val.Type})
  170. }
  171. }
  172. func ReloadAdvSensitiveWords(cfgName string) {
  173. sConfig := service.GetServiceConfig()
  174. path := sConfig.Node.Config + "/csv/"
  175. fuc, ok := serverproto.CFGNameList[cfgName]
  176. if ok {
  177. serverproto.AdvertisingScreenLoader = map[int32]*serverproto.AdvertisingScreen{}
  178. fuc(path)
  179. LoadAdvSensitiveWords()
  180. }
  181. }
  182. //功能解锁问题
  183. func convertUIFuncUnLockCfg() {
  184. if cfgData, ok := serverproto.UIFuncUnLockCfgLoader[62]; ok {
  185. if len(cfgData.UnlockCond) <= 0 {
  186. return
  187. }
  188. k, v := Str2Res(cfgData.UnlockCond[0])
  189. if k <= 0 || v <= 0 {
  190. return
  191. }
  192. if k == int32(serverproto.TaskType_Level_Battle_Count) {
  193. GlobalDaoChangUnlockMapLevelId = v
  194. }
  195. }
  196. }
  197. //转换后的属性点消耗
  198. var AttrConsumeList = map[int32]int32{}
  199. func convertQualityPointCfg() {
  200. //QulityPointCfg
  201. var idList []int32
  202. for _, data := range serverproto.QualityPointCfgLoader {
  203. idList = append(idList, data.Count)
  204. }
  205. sort.Slice(idList, func(i, j int) bool {
  206. return idList[i] < idList[j]
  207. })
  208. var count int32 = 1
  209. AttrConsumeList[count] = 0
  210. for _, id := range idList {
  211. cfgData, ok := serverproto.QualityPointCfgLoader[id]
  212. if ok {
  213. _, ok := AttrConsumeList[id]
  214. if !ok {
  215. util.PanicF("[QulityPointCfg] data error:%v", id-1)
  216. }
  217. AttrConsumeList[id+1] = AttrConsumeList[id] + cfgData.Cost
  218. }
  219. }
  220. }
  221. //卡片数据
  222. type CardWeightDat struct {
  223. CardCfgId int32
  224. Weight int32
  225. }
  226. var CardNormalCfgList []*CardWeightDat
  227. var CardMiniCfgList []*CardWeightDat
  228. var CardMvpCfgList []*CardWeightDat
  229. var CardNormalWeightList []int32
  230. var CardMiniWeightList []int32
  231. var CardMvpWeightList []int32
  232. var ConvertCardList = map[int32]*ConvertCardData{}
  233. const (
  234. Card_Type_Normal = 1
  235. Card_Type_Mini = 2
  236. Card_Type_MVP = 3
  237. )
  238. type ConvertCardData struct {
  239. CardCfgId int32
  240. AttrList map[int32]float32
  241. TriggerBuffList map[int32]*serverproto.TriggerBuffData
  242. SourceCfgId int32
  243. }
  244. type ConvertCardUnlockData struct {
  245. CardSlotId int32
  246. ConditionList []*serverproto.KeyValueType
  247. }
  248. var ConvertCardUnlock = map[int32]*ConvertCardUnlockData{}
  249. func convertCardCfg() {
  250. CardNormalCfgList = []*CardWeightDat{}
  251. CardMiniCfgList = []*CardWeightDat{}
  252. CardMvpCfgList = []*CardWeightDat{}
  253. CardNormalWeightList = []int32{}
  254. CardMiniWeightList = []int32{}
  255. CardMvpWeightList = []int32{}
  256. ConvertCardList = map[int32]*ConvertCardData{}
  257. curWeight := map[int32]int32{}
  258. for _, data := range serverproto.CardCfgLoader {
  259. ConvertCardList[data.CardId] = &ConvertCardData{
  260. CardCfgId: data.CardId,
  261. AttrList: map[int32]float32{},
  262. TriggerBuffList: map[int32]*serverproto.TriggerBuffData{},
  263. }
  264. for idx := range data.Attribute1 {
  265. key, value := Str2Res(data.Attribute1[idx])
  266. if key > 0 && value > 0 {
  267. ConvertCardList[data.CardId].AttrList[key] = float32(value)
  268. }
  269. }
  270. for idx := range data.BUFF {
  271. buffId, rate, cd, triggType := Str2Res_4(data.BUFF[idx])
  272. if buffId > 0 {
  273. ConvertCardList[data.CardId].TriggerBuffList[buffId] = &serverproto.TriggerBuffData{
  274. BuffId: uint32(buffId),
  275. TriggerRatio: float32(rate) * 0.01,
  276. Cd: float32(cd),
  277. TriggerType: triggType,
  278. }
  279. }
  280. }
  281. if data.CardLevel > 1 {
  282. continue
  283. }
  284. weight, _ := curWeight[data.CardType]
  285. weight += data.Pro
  286. cardData := &CardWeightDat{
  287. CardCfgId: data.CardId,
  288. Weight: weight,
  289. }
  290. switch data.CardType {
  291. case Card_Type_Normal:
  292. CardNormalCfgList = append(CardNormalCfgList, cardData)
  293. case Card_Type_Mini:
  294. CardMiniCfgList = append(CardMiniCfgList, cardData)
  295. case Card_Type_MVP:
  296. CardMvpCfgList = append(CardMvpCfgList, cardData)
  297. }
  298. curWeight[data.CardType] = weight
  299. }
  300. cfgData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Card_Normal)]
  301. if ok && cfgData.SVal != "" {
  302. valList := strings.Split(cfgData.SVal, "-")
  303. for i, _ := range valList {
  304. weightVal, _ := Str2Num(valList[i])
  305. CardNormalWeightList = append(CardNormalWeightList, int32(weightVal))
  306. }
  307. }
  308. cfgMiniData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Card_Mini)]
  309. if ok && cfgMiniData.SVal != "" {
  310. valList := strings.Split(cfgMiniData.SVal, "-")
  311. for i, _ := range valList {
  312. weightVal, _ := Str2Num(valList[i])
  313. CardMiniWeightList = append(CardMiniWeightList, int32(weightVal))
  314. }
  315. }
  316. cfgMvpData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Card_Mvp)]
  317. if ok && cfgMvpData.SVal != "" {
  318. valList := strings.Split(cfgMvpData.SVal, "-")
  319. for i, _ := range valList {
  320. weightVal, _ := Str2Num(valList[i])
  321. CardMvpWeightList = append(CardMvpWeightList, int32(weightVal))
  322. }
  323. }
  324. //CardUnlockCfg
  325. for _, data := range serverproto.CardUnlockCfgLoader {
  326. addData := &ConvertCardUnlockData{
  327. CardSlotId: data.CardSlotID,
  328. }
  329. for idx := 0; idx < len(data.UnlockingCondition); idx++ {
  330. k, v := Str2Res(data.UnlockingCondition[idx])
  331. if k > 0 && v > 0 {
  332. addData.ConditionList = append(addData.ConditionList,
  333. &serverproto.KeyValueType{Key: k, Value: v})
  334. }
  335. }
  336. ConvertCardUnlock[addData.CardSlotId] = addData
  337. }
  338. for _, data := range ConvertCardList {
  339. cardCfg, ok := serverproto.CardCfgLoader[data.CardCfgId]
  340. if !ok || cardCfg.CardType <= 2 {
  341. continue
  342. }
  343. if cardCfg.CardLevel == 1 || cardCfg.FromCardId == 0 {
  344. data.SourceCfgId = data.CardCfgId
  345. continue
  346. }
  347. sourceID := (data.CardCfgId/1000)*1000 + 100 + data.CardCfgId%100
  348. _, ok2 := serverproto.CardCfgLoader[data.CardCfgId]
  349. if !ok2 {
  350. continue
  351. }
  352. data.SourceCfgId = sourceID
  353. }
  354. }
  355. func GetCardSource(cardId int32) int32 {
  356. cardData, ok := ConvertCardList[cardId]
  357. if !ok {
  358. return 0
  359. }
  360. return cardData.SourceCfgId
  361. }
  362. //DropCfg数据
  363. type WeightKeyValueData struct {
  364. Weight int32
  365. Key int32
  366. MinValue int32
  367. Maxvalue int32
  368. }
  369. func (this *WeightKeyValueData) GetValue() int32 {
  370. if this.MinValue == this.Maxvalue || this.MinValue > this.Maxvalue {
  371. return this.Maxvalue
  372. }
  373. return this.MinValue + rand.Int31n(this.Maxvalue-this.MinValue+1)
  374. }
  375. type ConvertDropData struct {
  376. Id int32
  377. TotalWeight int32 //掉了总权重
  378. DropList []*WeightKeyValueData //weight itemId,value
  379. }
  380. type ConvertPassBox struct {
  381. ItemList []*serverproto.KeyValueType
  382. }
  383. type DecayData struct {
  384. FactorParam int32
  385. FactorList []*serverproto.KeyValueType
  386. }
  387. type ConvertDecayData struct {
  388. Id int32
  389. DecayList []*DecayData
  390. }
  391. func (this *ConvertDecayData) GetDecayList(kvList map[int32]int32, param uint64) {
  392. if param <= 0 || len(this.DecayList) <= 0 {
  393. return
  394. }
  395. bFindIdx := false
  396. findIdx := 0
  397. for idx := 0; idx < len(this.DecayList); idx++ {
  398. if this.DecayList[idx].FactorParam > int32(param) {
  399. break
  400. }
  401. bFindIdx = true
  402. findIdx = idx
  403. }
  404. if bFindIdx {
  405. if findIdx >= len(this.DecayList) {
  406. findIdx = len(this.DecayList) - 1
  407. }
  408. for k := 0; k < len(this.DecayList[findIdx].FactorList); k++ {
  409. kvItem := this.DecayList[findIdx].FactorList[k]
  410. kvList[kvItem.Key] += kvItem.Value
  411. }
  412. }
  413. }
  414. var DropDataList = map[int32]*ConvertDropData{}
  415. var LevelDropCommonDataList = map[int32]*ConvertDropData{}
  416. var LevelDropBossDataList = map[int32]*ConvertDropData{}
  417. var LevelDropHDDataList = map[int32]*ConvertDropData{}
  418. var ConvertLevelPowerDecayFactorList = map[int32]*ConvertDecayData{}
  419. var ConvertLevelTimeDecayFactorList = map[int32]*ConvertDecayData{}
  420. var ConvertLevelSpAdd *serverproto.KeyValueType = nil
  421. //var LevelPassBox = map[int32]*ConvertPassBox{}
  422. func convertDropCfg() {
  423. //dropCfg
  424. for _, data := range serverproto.DropCfgLoader {
  425. convertData := &ConvertDropData{
  426. Id: data.Id,
  427. TotalWeight: 0,
  428. }
  429. DropDataList[data.Id] = convertData
  430. for index, _ := range data.Drop1 {
  431. weightVal, key, minValue, maxValue := Str2Res_4(data.Drop1[index])
  432. convertData.TotalWeight += weightVal
  433. convertData.DropList = append(convertData.DropList,
  434. &WeightKeyValueData{Weight: convertData.TotalWeight, Key: key, MinValue: minValue, Maxvalue: maxValue})
  435. }
  436. }
  437. //levelCfg
  438. for _, data := range serverproto.LevelCfgLoader {
  439. //关卡drop处理
  440. commonData := &ConvertDropData{
  441. Id: data.Id,
  442. TotalWeight: 0,
  443. }
  444. LevelDropCommonDataList[data.Id] = commonData
  445. for index, _ := range data.DropOl {
  446. weightVal, key := Str2Res(data.DropOl[index])
  447. commonData.TotalWeight = weightVal
  448. commonData.DropList = append(commonData.DropList,
  449. &WeightKeyValueData{Weight: commonData.TotalWeight, Key: key})
  450. }
  451. hdCommonData := &ConvertDropData{
  452. Id: data.Id,
  453. TotalWeight: 0,
  454. }
  455. LevelDropHDDataList[data.Id] = hdCommonData
  456. for index, _ := range data.HdDrop {
  457. weightVal, key, val := Str2Res_3(data.HdDrop[index])
  458. hdCommonData.TotalWeight = weightVal
  459. hdCommonData.DropList = append(hdCommonData.DropList,
  460. &WeightKeyValueData{Weight: hdCommonData.TotalWeight, Key: key,
  461. MinValue: val, Maxvalue: val})
  462. }
  463. //boss drop处理
  464. bossData := &ConvertDropData{
  465. Id: data.Id,
  466. TotalWeight: 0,
  467. }
  468. LevelDropBossDataList[data.Id] = bossData
  469. for index, _ := range data.Drop {
  470. weightVal, key := Str2Res(data.Drop[index])
  471. bossData.TotalWeight = weightVal
  472. bossData.DropList = append(bossData.DropList,
  473. &WeightKeyValueData{Weight: bossData.TotalWeight, Key: key})
  474. }
  475. //难度衰减系数
  476. //power
  477. parseDecay(data.Id, data.PowerWeaken, ConvertLevelPowerDecayFactorList)
  478. //time
  479. parseDecay(data.Id, data.StayTimeWeaken, ConvertLevelTimeDecayFactorList)
  480. //sp add
  481. k, v := Str2Res(data.SpAddition)
  482. if k > 0 && v > 0 {
  483. ConvertLevelSpAdd = &serverproto.KeyValueType{Key: k, Value: v}
  484. }
  485. }
  486. }
  487. func parseDecay(id int32, decayStr string, convertData map[int32]*ConvertDecayData) {
  488. decayData := &ConvertDecayData{
  489. Id: id,
  490. }
  491. tmpDataList := strings.Split(decayStr, "|")
  492. for idx := 0; idx < len(tmpDataList); idx++ {
  493. tmpPramList := strings.Split(tmpDataList[idx], ";")
  494. val, _ := Str2Num(tmpPramList[0])
  495. tmpDecayData := &DecayData{
  496. FactorParam: int32(val),
  497. }
  498. for k := 1; k < len(tmpPramList); k++ {
  499. k, v := Str2Res(tmpPramList[k])
  500. if k <= 0 {
  501. continue
  502. }
  503. tmpDecayData.FactorList = append(tmpDecayData.FactorList, &serverproto.KeyValueType{Key: k, Value: v})
  504. }
  505. decayData.DecayList = append(decayData.DecayList, tmpDecayData)
  506. }
  507. convertData[decayData.Id] = decayData
  508. sort.Slice(decayData.DecayList, func(i, j int) bool {
  509. return decayData.DecayList[i].FactorParam < decayData.DecayList[j].FactorParam
  510. })
  511. }
  512. func DropCfgProcess(dropList map[int32]int32, dropId int32) {
  513. if dropId <= 0 {
  514. return
  515. }
  516. dropData, ok := serverproto.DropCfgLoader[dropId]
  517. convertDropData, ok1 := DropDataList[dropId]
  518. if !ok || !ok1 {
  519. util.ErrorF("dropProcess drop data not found dropId=%v ok=%v ok1=%v", dropId, ok, ok1)
  520. return
  521. }
  522. //万分比随机
  523. dropRate := rand.Int31n(10000)
  524. if dropRate >= dropData.Rate {
  525. return
  526. }
  527. if dropData.DropType <= 0 {
  528. //累计权重随机
  529. for i := 0; i < int(dropData.Times); i++ {
  530. if convertDropData.TotalWeight <= 0 {
  531. break
  532. }
  533. dropRate = rand.Int31n(convertDropData.TotalWeight)
  534. for _, data := range convertDropData.DropList {
  535. if data.Weight > dropRate && data.Key > 0 {
  536. dropList[data.Key] += data.GetValue()
  537. break
  538. }
  539. }
  540. }
  541. } else { //drop all
  542. for _, data := range convertDropData.DropList {
  543. if data.Key > 0 {
  544. dropList[data.Key] += data.GetValue() * dropData.Times
  545. }
  546. }
  547. }
  548. }
  549. //TargetTask配置数据
  550. //解析任务结构数据,避免使用时重复解析
  551. type ConvertTaskData struct {
  552. TaskId uint32
  553. TaskType int32
  554. PreTaskId uint32 //前置任务ID
  555. NextTaskId uint32 //后续接取任务
  556. TaskScore int32 //获取奖励后的任务积分
  557. IsBeginTask bool
  558. Condition map[int32][]int32
  559. TaskReward []*serverproto.KeyValueType
  560. }
  561. type CovertTaskScoreData struct {
  562. Idx uint32
  563. Active int32
  564. RewardList []*serverproto.KeyValueType
  565. HDRewardList []*serverproto.KeyValueType //活动期间制定掉落物品
  566. }
  567. var TargetTaskBeginID uint32 = 0
  568. var ConvertTaskList = map[uint32]*ConvertTaskData{}
  569. var ConvertAddTaskList = map[uint32]*ConvertTaskData{}
  570. var ConvertMainTaskOriginalList = map[uint32]uint32{} //[taskid,originaltask]
  571. var ConvertDailyTaskScoreRewardList = map[uint32]*CovertTaskScoreData{}
  572. var ConvertWeekTaskScoreRewardList = map[uint32]*CovertTaskScoreData{}
  573. const (
  574. TASK_TYPE_DAILY = 1
  575. TASK_TYPE_WEEK = 2
  576. TASK_TYPE_MAIN = 3
  577. TASK_TYPE_TODAY = 4
  578. TASK_TYPE_GROWUP = 5
  579. )
  580. func convertTaskCfg() {
  581. //globalCfgData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Target_Task_Begin_ID)]
  582. //if ok {
  583. // TargetTaskBeginID = uint32(globalCfgData.IVal)
  584. //}
  585. //
  586. //for _, data := range serverproto.TargetTaskCfgLoader {
  587. // convertData := &ConvertTaskData{
  588. // TaskId: uint32(data.TargetTaskId),
  589. // TaskType: data.TargetTaskType,
  590. // NextTaskId: uint32(data.FollowTaskOld),
  591. // Condition: map[int32][]int32{},
  592. // }
  593. //
  594. // //任务条件
  595. // for index, _ := range data.TargetTaskCondition {
  596. // valueList := strings.Split(data.TargetTaskCondition[index], ":")
  597. // if len(valueList) >= 2 {
  598. // taskType, _ := Str2Num(valueList[0])
  599. // convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskType))
  600. // for i := 1; i < len(valueList); i++ {
  601. // taskValue, _ := Str2Num(valueList[i])
  602. // convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskValue))
  603. // }
  604. // }
  605. // }
  606. //
  607. // //任务奖励
  608. // for index, _ := range data.TargetReward {
  609. // key, value := Str2Res(data.TargetReward[index])
  610. // convertData.TaskReward = append(convertData.TaskReward, &serverproto.KeyValueType{
  611. // Key: key,
  612. // Value: value,
  613. // })
  614. // }
  615. //
  616. // ConvertTaskList[convertData.TaskId] = convertData
  617. //}
  618. for _, data := range serverproto.MissionCfgLoader {
  619. convertData := &ConvertTaskData{
  620. TaskId: uint32(data.MissionID),
  621. TaskType: data.MissionType,
  622. TaskScore: data.Active,
  623. Condition: map[int32][]int32{},
  624. }
  625. //任务条件
  626. for index, _ := range data.MissionCondition {
  627. valueList := strings.Split(data.MissionCondition[index], ":")
  628. if len(valueList) >= 2 {
  629. taskType, _ := Str2Num(valueList[0])
  630. convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskType))
  631. for i := 1; i < len(valueList); i++ {
  632. taskValue, _ := Str2Num(valueList[i])
  633. convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskValue))
  634. }
  635. }
  636. }
  637. ConvertTaskList[convertData.TaskId] = convertData
  638. ConvertAddTaskList[convertData.TaskId] = convertData
  639. }
  640. for _, data := range serverproto.LineMissionCfgLoader {
  641. convertData := &ConvertTaskData{
  642. TaskId: uint32(data.MissionID),
  643. TaskType: TASK_TYPE_MAIN,
  644. Condition: map[int32][]int32{},
  645. }
  646. if data.BeginMission > 0 {
  647. convertData.IsBeginTask = true
  648. }
  649. convertData.NextTaskId = uint32(data.FollowMissionld)
  650. //任务条件
  651. for index, _ := range data.MissionCondition {
  652. valueList := strings.Split(data.MissionCondition[index], ":")
  653. if len(valueList) >= 2 {
  654. taskType, _ := Str2Num(valueList[0])
  655. convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskType))
  656. for i := 1; i < len(valueList); i++ {
  657. taskValue, _ := Str2Num(valueList[i])
  658. convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskValue))
  659. }
  660. }
  661. }
  662. //任务奖励
  663. for index, _ := range data.Reward {
  664. key, value := Str2Res(data.Reward[index])
  665. convertData.TaskReward = append(convertData.TaskReward, &serverproto.KeyValueType{
  666. Key: key,
  667. Value: value,
  668. })
  669. }
  670. ConvertTaskList[convertData.TaskId] = convertData
  671. if convertData.IsBeginTask {
  672. ConvertAddTaskList[convertData.TaskId] = convertData
  673. }
  674. }
  675. for _, originalTaskData := range ConvertAddTaskList {
  676. if !originalTaskData.IsBeginTask {
  677. continue
  678. }
  679. ConvertMainTaskOriginalList[originalTaskData.TaskId] = originalTaskData.TaskId
  680. if originalTaskData.NextTaskId == 0 || originalTaskData.TaskId == originalTaskData.NextTaskId {
  681. continue
  682. }
  683. ConvertMainTaskOriginalList[originalTaskData.NextTaskId] = originalTaskData.TaskId
  684. originalTaskProcess(originalTaskData.NextTaskId)
  685. }
  686. //积分奖励
  687. for _, data := range serverproto.ActRewardCfgLoader {
  688. scoreInfo := &CovertTaskScoreData{
  689. Idx: uint32(data.ID),
  690. Active: data.Active,
  691. }
  692. for index, _ := range data.Reward {
  693. key, value := Str2Res(data.Reward[index])
  694. if key <= 0 || value <= 0 {
  695. continue
  696. }
  697. scoreInfo.RewardList = append(scoreInfo.RewardList, &serverproto.KeyValueType{
  698. Key: key,
  699. Value: value,
  700. })
  701. }
  702. for index, _ := range data.HdDrop {
  703. key, value := Str2Res(data.HdDrop[index])
  704. if key <= 0 || value <= 0 {
  705. continue
  706. }
  707. scoreInfo.HDRewardList = append(scoreInfo.HDRewardList, &serverproto.KeyValueType{
  708. Key: key,
  709. Value: value,
  710. })
  711. }
  712. if data.ActiveType == TASK_TYPE_DAILY {
  713. ConvertDailyTaskScoreRewardList[scoreInfo.Idx] = scoreInfo
  714. } else if data.ActiveType == TASK_TYPE_WEEK {
  715. ConvertWeekTaskScoreRewardList[scoreInfo.Idx] = scoreInfo
  716. }
  717. }
  718. }
  719. func originalTaskProcess(taskId uint32) {
  720. if data, ok := serverproto.LineMissionCfgLoader[int32(taskId)]; ok && data.FollowMissionld > 0 {
  721. if data.MissionID == data.FollowMissionld {
  722. return
  723. }
  724. ConvertMainTaskOriginalList[uint32(data.FollowMissionld)] = ConvertMainTaskOriginalList[taskId]
  725. originalTaskProcess(uint32(data.FollowMissionld))
  726. }
  727. }
  728. //convertParterProgressCfg
  729. type ProgressLevelAttr struct {
  730. AttrSet map[int32]map[int32]int32
  731. }
  732. var ProgressAttrContainer = map[int32]*ProgressLevelAttr{}
  733. type PartnerSkillSet struct {
  734. SkillLevel map[int32][]int32
  735. }
  736. //var PartnerSkillContainer = map[int32]*PartnerSkillSet{}
  737. func convertParterProgressCfg() {
  738. for _, data := range serverproto.ParterProgressCfgLoader {
  739. paraStr := "Attribute"
  740. t := reflect.ValueOf(data).Elem()
  741. convertData := &ProgressLevelAttr{
  742. AttrSet: map[int32]map[int32]int32{},
  743. }
  744. for i := 1; i <= int(data.Times); i++ {
  745. keyStr := paraStr + strconv.Itoa(i)
  746. v := t.FieldByName(keyStr).Interface()
  747. var mapAttribute0 = make(map[int32]int32)
  748. for _, str := range v.([]string) {
  749. attrList := strings.Split(str, ":")
  750. if len(attrList) >= 2 {
  751. attrId, _ := Str2Num(attrList[0])
  752. attrValue, _ := Str2Num(attrList[1])
  753. mapAttribute0[int32(attrId)] = int32(attrValue)
  754. }
  755. }
  756. convertData.AttrSet[int32(i-1)] = mapAttribute0
  757. }
  758. ProgressAttrContainer[data.Id] = convertData
  759. }
  760. convertStrengthCfg()
  761. }
  762. var ConvertPartnerSkillIdxList = map[int32]*serverproto.ParterSkillTreeCfg{}
  763. type ConvertSkillSlotData struct {
  764. Id int32
  765. ConditionList []*serverproto.KeyValueType
  766. }
  767. var ConvertSkillSlotMain = map[int32]*ConvertSkillSlotData{}
  768. var ConvertSkillSlotPartner = map[int32]*ConvertSkillSlotData{}
  769. func convertParterSkillTreeCfg() {
  770. for _, data := range serverproto.ParterSkillTreeCfgLoader {
  771. ConvertPartnerSkillIdxList[data.SkillId] = data
  772. }
  773. convertSkillTree() //技能升级
  774. for _, data := range serverproto.SkillSlotCfgLoader {
  775. mainAddData := &ConvertSkillSlotData{
  776. Id: data.ID,
  777. }
  778. for idx := 0; idx < len(data.SCondition); idx++ {
  779. k, v := Str2Res(data.SCondition[idx])
  780. if k > 0 && v > 0 {
  781. mainAddData.ConditionList = append(mainAddData.ConditionList,
  782. &serverproto.KeyValueType{Key: k, Value: v})
  783. }
  784. }
  785. ConvertSkillSlotMain[mainAddData.Id] = mainAddData
  786. partnerAddData := &ConvertSkillSlotData{
  787. Id: data.ID,
  788. }
  789. for idx := 0; idx < len(data.SParterCondition); idx++ {
  790. k, v := Str2Res(data.SParterCondition[idx])
  791. if k > 0 && v > 0 {
  792. partnerAddData.ConditionList = append(partnerAddData.ConditionList,
  793. &serverproto.KeyValueType{Key: k, Value: v})
  794. }
  795. }
  796. ConvertSkillSlotPartner[partnerAddData.Id] = partnerAddData
  797. }
  798. }
  799. type StrengthCost struct {
  800. CostList []*serverproto.KeyValueType
  801. }
  802. var PartnerStrengthCost = map[int32]*StrengthCost{}
  803. type StrengthAttr struct {
  804. AttrSet map[int32]map[int32]int32
  805. }
  806. var StrengthAttrContainer = map[int32]*StrengthAttr{}
  807. //伙伴突破 相关配置
  808. func convertStrengthCfg() {
  809. for _, data := range serverproto.ParterProgressCfgLoader {
  810. paraStr := "BreachAttribute"
  811. convertData := &StrengthAttr{
  812. AttrSet: map[int32]map[int32]int32{},
  813. }
  814. t := reflect.ValueOf(data).Elem()
  815. for i := 1; i <= int(data.BreachTimes); i++ {
  816. keyStr := paraStr + strconv.Itoa(i)
  817. v := t.FieldByName(keyStr)
  818. var mapAttribute0 = make(map[int32]int32)
  819. for _, str := range v.Interface().([]string) {
  820. attrList := strings.Split(str, ":")
  821. if len(attrList) >= 2 {
  822. attrId, _ := Str2Num(attrList[0])
  823. attrValue, _ := Str2Num(attrList[1])
  824. mapAttribute0[int32(attrId)] = int32(attrValue)
  825. }
  826. }
  827. convertData.AttrSet[int32(i-1)] = mapAttribute0
  828. }
  829. convertCost := &StrengthCost{}
  830. for index, _ := range data.BreachCost {
  831. attrList := strings.Split(data.BreachCost[index], ":")
  832. if len(attrList) >= 2 {
  833. attrId, _ := Str2Num(attrList[0])
  834. attrValue, _ := Str2Num(attrList[1])
  835. convertCost.CostList = append(convertCost.CostList, &serverproto.KeyValueType{
  836. Key: int32(attrId),
  837. Value: int32(attrValue),
  838. })
  839. }
  840. }
  841. PartnerStrengthCost[data.Id] = convertCost
  842. StrengthAttrContainer[data.Id] = convertData
  843. }
  844. }
  845. //主角
  846. type RoleAttributeSet struct {
  847. AttrSet []*serverproto.KeyValueType
  848. }
  849. var RoleAttrContainer = map[int32]*RoleAttributeSet{}
  850. func convertRoleAttributeCfg() {
  851. for _, data := range serverproto.RoleAttributeCfgLoader {
  852. convertData := &RoleAttributeSet{}
  853. convertData.AttrSet = []*serverproto.KeyValueType{
  854. {Key: int32(serverproto.Attr_Life), Value: data.Hp},
  855. {Key: int32(serverproto.Attr_Sp), Value: data.Sp},
  856. {Key: int32(serverproto.Attr_Attack), Value: data.Atk},
  857. {Key: int32(serverproto.Attr_MagicAttack), Value: data.Matk},
  858. {Key: int32(serverproto.Attr_Defense), Value: data.Def},
  859. {Key: int32(serverproto.Attr_MagicDefense), Value: data.Mdef},
  860. {Key: int32(serverproto.Attr_Hit), Value: data.Hit},
  861. {Key: int32(serverproto.Attr_Dodge), Value: data.Dodge},
  862. {Key: int32(serverproto.Attr_Crit), Value: data.Crit},
  863. {Key: int32(serverproto.Attr_Ten), Value: data.Ten},
  864. }
  865. RoleAttrContainer[data.BaseLv] = convertData
  866. }
  867. }
  868. //主角
  869. type JobAttrSet struct {
  870. // AttrSet []*serverproto.KeyValueType
  871. AttrSet map[int32]int32
  872. }
  873. var JobAttrContainer = map[int32]*JobAttrSet{}
  874. func convertJobAttrCfg() {
  875. for _, data := range serverproto.JobCfgLoader {
  876. convertData := &JobAttrSet{
  877. AttrSet: map[int32]int32{},
  878. }
  879. convertData.AttrSet[int32(serverproto.Attr_Life)] = data.HpRate
  880. convertData.AttrSet[int32(serverproto.Attr_Sp)] = data.SpRate
  881. convertData.AttrSet[int32(serverproto.Attr_Attack)] = data.AtkRate
  882. convertData.AttrSet[int32(serverproto.Attr_MagicAttack)] = data.MatkRate
  883. convertData.AttrSet[int32(serverproto.Attr_Defense)] = data.DefRate
  884. convertData.AttrSet[int32(serverproto.Attr_MagicDefense)] = data.MdefRate
  885. convertData.AttrSet[int32(serverproto.Attr_Hit)] = data.HitRate
  886. convertData.AttrSet[int32(serverproto.Attr_Dodge)] = data.DodgeRate
  887. convertData.AttrSet[int32(serverproto.Attr_Crit)] = data.CritRate
  888. convertData.AttrSet[int32(serverproto.Attr_Ten)] = data.TenRate
  889. JobAttrContainer[data.Id] = convertData
  890. }
  891. }
  892. //伙伴
  893. type PartnerAttrSet struct {
  894. AttrSet []*serverproto.KeyValueType
  895. }
  896. var PartnerAttrContainer = map[int32]*PartnerAttrSet{}
  897. func convertPartnerAttrCfg() {
  898. for _, data := range serverproto.ParterCfgLoader {
  899. convertData := &PartnerAttrSet{}
  900. convertData.AttrSet = []*serverproto.KeyValueType{
  901. {Key: int32(serverproto.Attr_Life), Value: data.Hp},
  902. {Key: int32(serverproto.Attr_Sp), Value: data.Sp},
  903. {Key: int32(serverproto.Attr_Attack), Value: data.Atk},
  904. {Key: int32(serverproto.Attr_MagicAttack), Value: data.Matk},
  905. {Key: int32(serverproto.Attr_Defense), Value: data.Def},
  906. {Key: int32(serverproto.Attr_MagicDefense), Value: data.Mdef},
  907. {Key: int32(serverproto.Attr_Hit), Value: data.Hit},
  908. {Key: int32(serverproto.Attr_Dodge), Value: data.Dodge},
  909. {Key: int32(serverproto.Attr_Crit), Value: data.Crit},
  910. {Key: int32(serverproto.Attr_Ten), Value: data.Ten},
  911. {Key: int32(serverproto.Attr_AttackSpeed), Value: data.Aspd},
  912. }
  913. PartnerAttrContainer[data.ParterId] = convertData
  914. }
  915. }
  916. type FashionAttrSet struct {
  917. AttrSet []*serverproto.KeyValueType
  918. FashionUseJobList []int32
  919. FashionQuality int32
  920. //AttrNum int32
  921. }
  922. //var FashionAttrContainer = map[int32]*FashionAttrSet{}
  923. var ConvertFashionPaperData = map[int32]map[int32]int32{}
  924. func convertFashionCfg() {
  925. //for _, cfgData := range serverproto.FashionCfgLoader {
  926. // convertData := &FashionAttrSet{}
  927. // for _, attrSet := range cfgData.FashionAttr {
  928. // key, value := Str2Res(attrSet)
  929. // if key <= 0 || value <= 0 {
  930. // continue
  931. // }
  932. // convertData.AttrSet = append(convertData.AttrSet, &serverproto.KeyValueType{
  933. // Key: key,
  934. // Value: value,
  935. // })
  936. // }
  937. //
  938. // for idx := 0; idx < len(cfgData.FashionUseJob); idx++ {
  939. // useJob, _ := Str2Num(cfgData.FashionUseJob[idx])
  940. // convertData.FashionUseJobList = append(convertData.FashionUseJobList, int32(useJob))
  941. // }
  942. // //convertData.AttrNum = cfgData.AttrNum
  943. // convertData.FashionQuality = cfgData.FashionQuality
  944. // //FashionAttrContainer[int32(cfgData.FashionId)] = convertData
  945. //}
  946. //paper resolveItemList
  947. for _, data := range serverproto.FashionPaperCfgLoader {
  948. ConvertFashionPaperData[data.PaperId] = map[int32]int32{}
  949. for idx := range data.ResolveItem {
  950. key, val := Str2Res(data.ResolveItem[idx])
  951. if key > 0 && val > 0 {
  952. ConvertFashionPaperData[data.PaperId][key] += val
  953. }
  954. }
  955. }
  956. }
  957. type CardAttrSet struct {
  958. AttrSet []*serverproto.KeyValueType
  959. }
  960. var CardAttrContainer = map[int32]*CardAttrSet{}
  961. func convertCardAttCfg() {
  962. for _, cfgData := range serverproto.CardCfgLoader {
  963. convertData := &CardAttrSet{}
  964. for _, attrSet := range cfgData.Attribute1 {
  965. key, value := Str2Res(attrSet)
  966. if key <= 0 || value <= 0 {
  967. continue
  968. }
  969. convertData.AttrSet = append(convertData.AttrSet, &serverproto.KeyValueType{
  970. Key: key,
  971. Value: value,
  972. })
  973. }
  974. CardAttrContainer[int32(cfgData.CardId)] = convertData
  975. }
  976. }
  977. type EquipAttributeSet struct {
  978. AttrSet []*serverproto.KeyValueType
  979. SuitId int32
  980. }
  981. var EquipAttrContainer = map[int32]*EquipAttributeSet{}
  982. func convertEquipCfg() {
  983. for _, data := range serverproto.EquipCfgLoader {
  984. convertData := &EquipAttributeSet{
  985. SuitId: data.Suit,
  986. }
  987. convertData.AttrSet = []*serverproto.KeyValueType{
  988. {Key: int32(serverproto.Attr_Str), Value: data.Str},
  989. {Key: int32(serverproto.Attr_Agi), Value: data.Agi},
  990. {Key: int32(serverproto.Attr_Int), Value: data.Int},
  991. {Key: int32(serverproto.Attr_Vit), Value: data.Vit},
  992. {Key: int32(serverproto.Attr_Dex), Value: data.Dex},
  993. {Key: int32(serverproto.Attr_Luk), Value: data.Luk},
  994. {Key: int32(serverproto.Attr_Life), Value: data.Life},
  995. {Key: int32(serverproto.Attr_Sp), Value: data.Sp},
  996. {Key: int32(serverproto.Attr_Attack), Value: data.Attack},
  997. {Key: int32(serverproto.Attr_MagicAttack), Value: data.MagicAttack},
  998. {Key: int32(serverproto.Attr_Defense), Value: data.Defense},
  999. {Key: int32(serverproto.Attr_MagicDefense), Value: data.MagicDefense},
  1000. {Key: int32(serverproto.Attr_Hit), Value: data.Hit},
  1001. {Key: int32(serverproto.Attr_Dodge), Value: data.Dodge},
  1002. {Key: int32(serverproto.Attr_Crit), Value: data.Crit},
  1003. {Key: int32(serverproto.Attr_Ten), Value: data.Ten},
  1004. {Key: int32(serverproto.Attr_PhysicDamage_Percent), Value: data.PhysicalDamageBonus},
  1005. {Key: int32(serverproto.Attr_MagicDamage_Percent), Value: data.MagicDamageBonus},
  1006. {Key: int32(serverproto.Attr_Attack_Percent), Value: data.AtkPercent},
  1007. {Key: int32(serverproto.Attr_MagicAttack_Percent), Value: data.MatkPercent},
  1008. }
  1009. EquipAttrContainer[data.Id] = convertData
  1010. }
  1011. }
  1012. // 神器id,星级,消耗材料map
  1013. var SkillEquipStarLevelUpCostContainer = map[int32]map[int32]map[int32]int32{}
  1014. //返还 神器id,星级,返还材料map
  1015. var SkillEquipDecomposeReturnContainer = map[int32]map[int32]map[int32]int32{}
  1016. //神器战力
  1017. var SkillEquipAppendFightPowerContainer = map[int32]map[int32]int32{}
  1018. //神器技能 神器id,星级,技能id
  1019. var SkillEquipAppendSkillContainer = map[int32]map[int32]int32{}
  1020. //神器槽位附加属性 槽位等级,属性map
  1021. var SkillEquipSlotAppendAttrContainer = map[int32]map[serverproto.Attr]float32{}
  1022. //神器槽位升级消耗 槽位等级,消耗材料map
  1023. var SkillEquipSlotLevelUpCostContainer = map[int32]map[int32]int32{}
  1024. type SkillEquipRemake struct {
  1025. Id int32 //批次
  1026. BeginDay int32
  1027. EndDay int32
  1028. CurBegin uint64 //当前批次开始
  1029. CurEnd uint64 //当前批次结束
  1030. CurForgePool []int32 //当前重铸池子
  1031. RealPool []int32 //实际重铸池子
  1032. NextForgePool []int32 //下一批重铸池子
  1033. NextBegin uint64 //下一轮开始时间
  1034. }
  1035. var SkillEquipRemakePool = map[int32]*SkillEquipRemake{}
  1036. type RemakeCost struct {
  1037. CostMap map[int32]int32
  1038. }
  1039. //重铸消耗
  1040. var SkillEquipRemakeCostContainer = map[int32]*RemakeCost{}
  1041. func convertSkillEquipCfg() {
  1042. for _, data := range serverproto.ArtifactCfgLoader {
  1043. // 一个id 对应的所有星级的材料消耗
  1044. costs := map[int32]map[int32]int32{}
  1045. SkillEquipStarLevelUpCostContainer[data.Id] = costs
  1046. for k, v := range data.Condition {
  1047. resList := strings.Split(v, ":")
  1048. // 当前星级对应的材料消耗 消耗的itemid,itemnum
  1049. cost := map[int32]int32{}
  1050. costs[int32(k)] = cost
  1051. for _, v1 := range resList {
  1052. r1, r2 := Str2ResBySep(v1, "|")
  1053. _, ok1 := cost[r1]
  1054. if ok1 {
  1055. cost[r1] += r2
  1056. } else {
  1057. cost[r1] = r2
  1058. }
  1059. }
  1060. }
  1061. // 一个id 对应的所有星级的材料返还
  1062. retResLists := map[int32]map[int32]int32{}
  1063. SkillEquipDecomposeReturnContainer[data.Id] = retResLists
  1064. for k, v := range data.SmeltReturn {
  1065. resList := strings.Split(v, ":")
  1066. // 当前星级对应的材料返还 itemid,itemnum
  1067. retRes := map[int32]int32{}
  1068. retResLists[int32(k)] = retRes
  1069. for _, v1 := range resList {
  1070. r1, r2 := Str2ResBySep(v1, "|")
  1071. _, ok1 := retRes[r1]
  1072. if ok1 {
  1073. retRes[r1] += r2
  1074. } else {
  1075. retRes[r1] = r2
  1076. }
  1077. }
  1078. }
  1079. appendFights := map[int32]int32{}
  1080. SkillEquipAppendFightPowerContainer[data.Id] = appendFights
  1081. for k, v := range data.AddFight {
  1082. fight, error := Str2Num(v)
  1083. if error != nil {
  1084. util.PanicF("convertSkillEquipCfg AddFight id=%d", data.Id)
  1085. break
  1086. }
  1087. appendFights[int32(k)] = int32(fight)
  1088. }
  1089. //skillList := map[int32]int32{}
  1090. //SkillEquipAppendSkillContainer[data.Id] = skillList
  1091. //for k, v := range data.ArtifacFuncId {
  1092. // skillId, error := Str2Num(v)
  1093. // if error != nil {
  1094. // util.ErrorF("convertSkillEquipCfg ArtifacFuncId id=%d", data.Id)
  1095. // break
  1096. // }
  1097. // skillList[int32(k)] = int32(skillId)
  1098. //}
  1099. if len(data.ReforgeCost) >= 1 {
  1100. costConvert := &RemakeCost{
  1101. CostMap: map[int32]int32{},
  1102. }
  1103. for _, data := range data.ReforgeCost {
  1104. itemId, itemNum := Str2Res(data)
  1105. if itemId > 0 && itemNum > 0 {
  1106. costConvert.CostMap[itemId] += itemNum
  1107. }
  1108. }
  1109. SkillEquipRemakeCostContainer[data.Id] = costConvert
  1110. }
  1111. if data.Times != 0 {
  1112. poolData, ok := SkillEquipRemakePool[data.Times]
  1113. if !ok {
  1114. convertData := &SkillEquipRemake{
  1115. Id: data.Times,
  1116. }
  1117. startDay, endDay := Str2Res(data.ArtifactDuration[0])
  1118. convertData.BeginDay = startDay
  1119. convertData.EndDay = endDay
  1120. convertData.CurForgePool = append(convertData.CurForgePool, data.Id)
  1121. convertData.RealPool = append(convertData.RealPool, data.Id)
  1122. SkillEquipRemakePool[data.Times] = convertData
  1123. } else {
  1124. poolData.CurForgePool = append(poolData.CurForgePool, data.Id)
  1125. poolData.RealPool = append(poolData.RealPool, data.Id)
  1126. }
  1127. }
  1128. }
  1129. for i := 1; i <= len(SkillEquipRemakePool); i++ {
  1130. curPool, ok := SkillEquipRemakePool[int32(i)]
  1131. if !ok {
  1132. //异常(当前批次不应该找不到)
  1133. break
  1134. }
  1135. nextPool, okNext := SkillEquipRemakePool[int32(i+1)]
  1136. if !okNext {
  1137. //说明当前批次是最后一批
  1138. break
  1139. }
  1140. //初始化下一阶段的重铸池
  1141. curPool.NextForgePool = append(curPool.NextForgePool, nextPool.CurForgePool...)
  1142. curPool.NextBegin = nextPool.NextBegin
  1143. //初始化,下一阶段的重铸池子
  1144. nextPool.RealPool = append(nextPool.RealPool, curPool.RealPool...)
  1145. }
  1146. for _, data := range serverproto.ArtifactExpCfgLoader {
  1147. cost := map[int32]int32{}
  1148. SkillEquipSlotLevelUpCostContainer[data.ArtifactLevel] = cost
  1149. for _, v := range data.UpgradeCost {
  1150. r1, r2 := Str2Res(v)
  1151. _, ok1 := cost[r1]
  1152. if ok1 {
  1153. cost[r1] += r2
  1154. } else {
  1155. cost[r1] = r2
  1156. }
  1157. }
  1158. attr := map[serverproto.Attr]float32{}
  1159. SkillEquipSlotAppendAttrContainer[data.ArtifactLevel] = attr
  1160. for _, v := range data.Nature {
  1161. r1, r2 := Str2Res(v)
  1162. _, ok1 := attr[serverproto.Attr(r1)]
  1163. if ok1 {
  1164. attr[serverproto.Attr(r1)] += float32(r2)
  1165. } else {
  1166. attr[serverproto.Attr(r1)] = float32(r2)
  1167. }
  1168. }
  1169. }
  1170. }
  1171. func CheckNeedInitStartTime() {
  1172. loc := util.GetLoc()
  1173. startUpTime := service.GetServiceStartupTime()
  1174. if startUpTime < 0 {
  1175. util.ErrorF("[SkillEquipRemakePool] data error:%v")
  1176. }
  1177. startServer := time.Unix(int64(startUpTime/1000), 0).In(loc).Format(util.DATE_FORMAT1)
  1178. startUpDayStr := util.GetDayByTimeStr1(startServer)
  1179. for i := 1; i <= len(SkillEquipRemakePool); i++ {
  1180. _, ok := SkillEquipRemakePool[int32(i)]
  1181. if !ok {
  1182. return
  1183. }
  1184. if SkillEquipRemakePool[int32(i)].CurBegin <= 0 {
  1185. //计算开服时间
  1186. startTime := time.Unix(startUpDayStr.Unix()+int64(SkillEquipRemakePool[int32(i)].BeginDay-1)*int64(DaySec), 0).In(loc)
  1187. SkillEquipRemakePool[int32(i)].CurBegin = uint64(startTime.UnixNano()/1e6) + 3600*5*1000
  1188. if SkillEquipRemakePool[int32(i)].EndDay > 0 {
  1189. endTime := time.Unix(startUpDayStr.Unix()+int64(SkillEquipRemakePool[int32(i)].EndDay-1)*int64(DaySec), 0).In(loc)
  1190. SkillEquipRemakePool[int32(i)].CurEnd = uint64(endTime.UnixNano()/1e6) + 3600*5*1000
  1191. }
  1192. util.InfoF("[SkillEquipRemakePool] CurBegin:%v, CurEnd:%v", SkillEquipRemakePool[int32(i)].CurBegin, SkillEquipRemakePool[int32(i)].CurEnd)
  1193. }
  1194. if i > 1 {
  1195. _, ok2 := SkillEquipRemakePool[int32(i-1)]
  1196. if ok2 {
  1197. SkillEquipRemakePool[int32(i-1)].NextBegin = SkillEquipRemakePool[int32(i)].CurBegin
  1198. }
  1199. }
  1200. }
  1201. }
  1202. func GetCurForgePool() *SkillEquipRemake {
  1203. CheckNeedInitStartTime()
  1204. curTime := util.GetCurrentTime()
  1205. for i := 1; i <= len(SkillEquipRemakePool); i++ {
  1206. _, ok := SkillEquipRemakePool[int32(i)]
  1207. if !ok {
  1208. return nil
  1209. }
  1210. if SkillEquipRemakePool[int32(i)].CurBegin <= 0 {
  1211. return nil
  1212. }
  1213. if i == 1 {
  1214. if curTime < SkillEquipRemakePool[int32(i)].CurBegin {
  1215. return nil
  1216. }
  1217. }
  1218. if SkillEquipRemakePool[int32(i)].CurBegin <= curTime {
  1219. if (SkillEquipRemakePool[int32(i)].CurEnd != 0 && curTime < SkillEquipRemakePool[int32(i)].CurEnd) ||
  1220. SkillEquipRemakePool[int32(i)].CurEnd == 0 {
  1221. return SkillEquipRemakePool[int32(i)]
  1222. }
  1223. }
  1224. }
  1225. return nil
  1226. }
  1227. type EquipRefineSet struct {
  1228. AttrSet []*serverproto.KeyValueType
  1229. }
  1230. var EquipRefineContainer = map[int32]*EquipRefineSet{}
  1231. func convertEquipRefineCfg() {
  1232. for _, data := range serverproto.EquipRefineCfgLoader {
  1233. convertData := &EquipRefineSet{}
  1234. for idx := range data.SuitServer {
  1235. key, value := Str2Res(data.SuitServer[idx])
  1236. if key <= 0 || value <= 0 {
  1237. continue
  1238. }
  1239. convertData.AttrSet = append(convertData.AttrSet, &serverproto.KeyValueType{
  1240. Key: key,
  1241. Value: value,
  1242. })
  1243. }
  1244. EquipRefineContainer[int32(data.Id)] = convertData
  1245. }
  1246. }
  1247. type FightPowerSet struct {
  1248. AttrSet []*serverproto.KeyValueType
  1249. Mapping int32
  1250. }
  1251. var FightPowerContainer = map[int32]*FightPowerSet{}
  1252. var ConvertFightPower = map[int32]map[int32]int32{} //[jobtype][attrkey][attrval]
  1253. func convertFightPowerCfg() {
  1254. for _, data := range serverproto.FightCfgLoader {
  1255. convertData := &FightPowerSet{}
  1256. for _, attrData := range data.Coefficient {
  1257. key, value := Str2Res(attrData)
  1258. if key < 0 || value <= 0 {
  1259. continue
  1260. }
  1261. convertData.AttrSet = append(convertData.AttrSet, &serverproto.KeyValueType{
  1262. Key: key,
  1263. Value: value,
  1264. })
  1265. }
  1266. convertData.Mapping = data.Mapping
  1267. FightPowerContainer[int32(data.Id)] = convertData
  1268. for idx := 0; idx < len(data.Coefficient); idx++ {
  1269. k, v := Str2Res(data.Coefficient[idx])
  1270. if _, ok := ConvertFightPower[k]; !ok {
  1271. ConvertFightPower[k] = map[int32]int32{}
  1272. }
  1273. ConvertFightPower[k][data.Id] = v
  1274. }
  1275. }
  1276. }
  1277. type EquipSuitAttr struct {
  1278. AttrSet map[int32]map[int32]int32
  1279. }
  1280. var SuitAttrContainer = map[int32]*EquipSuitAttr{}
  1281. func convertEquipSuitCfg() {
  1282. for _, data := range serverproto.EquipSuitNewCfgLoader {
  1283. convertData := &EquipSuitAttr{
  1284. AttrSet: map[int32]map[int32]int32{},
  1285. }
  1286. var mapAttribute0 map[int32]int32
  1287. mapAttribute0 = make(map[int32]int32)
  1288. for index, _ := range data.Suit1 {
  1289. key, value := Str2Res(data.Suit1[index])
  1290. if key <= 0 || value <= 0 {
  1291. continue
  1292. }
  1293. mapAttribute0[key] = value
  1294. }
  1295. convertData.AttrSet[0] = mapAttribute0
  1296. var mapAttribute1 map[int32]int32
  1297. mapAttribute1 = make(map[int32]int32)
  1298. for index, _ := range data.Suit2 {
  1299. key, value := Str2Res(data.Suit2[index])
  1300. if key <= 0 || value <= 0 {
  1301. continue
  1302. }
  1303. mapAttribute1[key] = value
  1304. }
  1305. convertData.AttrSet[1] = mapAttribute1
  1306. var mapAttribute2 map[int32]int32
  1307. mapAttribute2 = make(map[int32]int32)
  1308. for index, _ := range data.Suit3 {
  1309. key, value := Str2Res(data.Suit3[index])
  1310. if key <= 0 || value <= 0 {
  1311. continue
  1312. }
  1313. mapAttribute2[key] = value
  1314. }
  1315. convertData.AttrSet[2] = mapAttribute2
  1316. SuitAttrContainer[int32(data.Id)] = convertData
  1317. }
  1318. }
  1319. type ChangeCondition struct {
  1320. Condition map[int32][]int32
  1321. }
  1322. var ChangeJobCond = map[int32]*ChangeCondition{}
  1323. func convertChangeJobCfg() {
  1324. for _, data := range serverproto.ConditionCfgLoader {
  1325. convertData := &ChangeCondition{
  1326. Condition: make(map[int32][]int32),
  1327. }
  1328. for _, subData := range data.Condition {
  1329. condList := strings.Split(subData, ":")
  1330. if len(condList) < 2 {
  1331. continue
  1332. }
  1333. taskType, _ := Str2Num(condList[0])
  1334. convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskType))
  1335. for i := 1; i < len(condList); i++ {
  1336. cfgValue, _ := Str2Num(condList[i])
  1337. convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(cfgValue))
  1338. }
  1339. }
  1340. ChangeJobCond[data.ConditionId] = convertData
  1341. }
  1342. }
  1343. type ArenaRankSeasonInfo struct {
  1344. ZoneId int32
  1345. SeasonId int32
  1346. RewardInfo []*ArenaRankRewardInfo
  1347. Duration int32
  1348. Reset int32
  1349. StartTimeStr, EndTimeStr string
  1350. StartTime, EndTime time.Time
  1351. DiffDurationDay int64
  1352. }
  1353. type ArenaRankRewardInfo struct {
  1354. Left, Right int32
  1355. RewardList map[int32]int32
  1356. }
  1357. //var ConvertArenaSeasonReward = map[int32]*ArenaRankSeasonInfo{} //赛季对应top排行奖励
  1358. var ConvertArenaSeason *ArenaRankSeasonInfo = nil
  1359. type ArenaMatchInfo struct {
  1360. LevelId int32 //段位ID
  1361. MinScore int32 //段位对应的最低分
  1362. Score int32 //段位对应的最高分
  1363. ScoreRewardList, WinRewardList, FailedRewardList map[int32]int32 //段位奖励 胜利奖励 失败奖励
  1364. WinScore, WinScore1, WinScore2 int32 //score 与强敌胜利获得积分
  1365. FailedScore, FailedScore1, FailedScore2 int32
  1366. ScoreSectionLeft, ScoreSectionRight float32 //强弱区间
  1367. WinStreak []int32
  1368. //match
  1369. WinMatchList, FailedMatchList []serverproto.KeyValueType
  1370. LevelReduce int32
  1371. }
  1372. var ConvertArenaMatch []*ArenaMatchInfo //arena胜利失败奖励
  1373. var ConvertArenaMatchList = map[int32]*ArenaMatchInfo{}
  1374. var ConvertScoreToArenaLevelList = map[int32]int32{} //最低分数对应段位
  1375. var MinTopRankScore int32 = 0 //入top排行榜最低积分(段位的积分)
  1376. func convertArenaCfg(zoneId int32) {
  1377. //clean for reload
  1378. ConvertArenaMatch = []*ArenaMatchInfo{}
  1379. ConvertArenaMatchList = map[int32]*ArenaMatchInfo{}
  1380. ConvertScoreToArenaLevelList = map[int32]int32{}
  1381. MinTopRankScore = 0
  1382. //ArenaRewardCfg
  1383. //加载对应服务器赛季数据
  1384. for _, data := range serverproto.ArenaRewardCfgLoader {
  1385. if data.Zone != zoneId {
  1386. continue
  1387. }
  1388. if ConvertArenaSeason == nil {
  1389. ConvertArenaSeason = &ArenaRankSeasonInfo{
  1390. ZoneId: data.Zone,
  1391. SeasonId: 0,
  1392. }
  1393. }
  1394. if data.StartTime != "" && data.CloseTime != "" {
  1395. //loc := util.GetLoc()
  1396. //sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.StartTime, loc)
  1397. //if err1 != nil {
  1398. // util.PanicF("convertArenaCfg startTime err:%v", err1)
  1399. //}
  1400. //ConvertArenaSeason.StartTime = sTime
  1401. ConvertArenaSeason.StartTimeStr = data.StartTime
  1402. //cTime, err2 := time.ParseInLocation(util.DATE_FORMAT, data.CloseTime, loc)
  1403. //if err2 != nil {
  1404. // util.PanicF("convertArenaCfg endTime err:%v", err2)
  1405. //}
  1406. //ConvertArenaSeason.EndTime = cTime
  1407. ConvertArenaSeason.EndTimeStr = data.CloseTime
  1408. }
  1409. rankRewardInfo := &ArenaRankRewardInfo{
  1410. RewardList: map[int32]int32{},
  1411. }
  1412. if len(data.ArenaRank) > 1 {
  1413. left, _ := Str2Num(data.ArenaRank[0])
  1414. right, _ := Str2Num(data.ArenaRank[1])
  1415. rankRewardInfo.Left = int32(left)
  1416. rankRewardInfo.Right = int32(right)
  1417. } else {
  1418. left, _ := Str2Num(data.ArenaRank[0])
  1419. rankRewardInfo.Left = int32(left)
  1420. }
  1421. for idx := range data.ArenaReward {
  1422. key, value := Str2Res(data.ArenaReward[idx])
  1423. rankRewardInfo.RewardList[key] += value
  1424. }
  1425. ConvertArenaSeason.RewardInfo = append(ConvertArenaSeason.RewardInfo, rankRewardInfo)
  1426. ConvertArenaSeason.Reset = data.Rest
  1427. }
  1428. //未找到对应zone数据,默认使用zone=1数据
  1429. zoneId = 1
  1430. if ConvertArenaSeason == nil {
  1431. for _, data := range serverproto.ArenaRewardCfgLoader {
  1432. if data.Zone != zoneId {
  1433. continue
  1434. }
  1435. if ConvertArenaSeason == nil {
  1436. ConvertArenaSeason = &ArenaRankSeasonInfo{
  1437. ZoneId: data.Zone,
  1438. SeasonId: 0,
  1439. }
  1440. }
  1441. if data.StartTime != "" && data.CloseTime != "" {
  1442. //loc := util.GetLoc()
  1443. //sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.StartTime, loc)
  1444. //if err1 != nil {
  1445. // util.PanicF("convertArenaCfg startTime err:%v", err1)
  1446. //}
  1447. //ConvertArenaSeason.StartTime = sTime
  1448. ConvertArenaSeason.StartTimeStr = data.StartTime
  1449. //cTime, err2 := time.ParseInLocation(util.DATE_FORMAT, data.CloseTime, loc)
  1450. //if err2 != nil {
  1451. // util.PanicF("convertArenaCfg endTime err:%v", err2)
  1452. //}
  1453. //ConvertArenaSeason.EndTime = cTime
  1454. ConvertArenaSeason.EndTimeStr = data.CloseTime
  1455. }
  1456. rankRewardInfo := &ArenaRankRewardInfo{
  1457. RewardList: map[int32]int32{},
  1458. }
  1459. if len(data.ArenaRank) > 1 {
  1460. left, _ := Str2Num(data.ArenaRank[0])
  1461. right, _ := Str2Num(data.ArenaRank[1])
  1462. rankRewardInfo.Left = int32(left)
  1463. rankRewardInfo.Right = int32(right)
  1464. } else {
  1465. left, _ := Str2Num(data.ArenaRank[0])
  1466. rankRewardInfo.Left = int32(left)
  1467. }
  1468. for idx := range data.ArenaReward {
  1469. key, value := Str2Res(data.ArenaReward[idx])
  1470. rankRewardInfo.RewardList[key] += value
  1471. }
  1472. ConvertArenaSeason.RewardInfo = append(ConvertArenaSeason.RewardInfo, rankRewardInfo)
  1473. ConvertArenaSeason.Reset = data.Rest
  1474. }
  1475. }
  1476. sort.Slice(ConvertArenaSeason.RewardInfo, func(i, j int) bool {
  1477. return ConvertArenaSeason.RewardInfo[i].Left < ConvertArenaSeason.RewardInfo[j].Left
  1478. })
  1479. ConvertArenaSeason.DiffDurationDay = util.GetDurationDay(ConvertArenaSeason.StartTimeStr, ConvertArenaSeason.EndTimeStr)
  1480. //ArenaLevelCfg
  1481. var minScore int32 = 0
  1482. var levelKeyList []int32
  1483. for _, data := range serverproto.ArenaLevelCfgLoader {
  1484. levelKeyList = append(levelKeyList, data.ArenaLevelId)
  1485. }
  1486. sort.Slice(levelKeyList, func(i, j int) bool {
  1487. return levelKeyList[i] < levelKeyList[j]
  1488. })
  1489. for idx := 0; idx < len(levelKeyList); idx++ {
  1490. data := serverproto.ArenaLevelCfgLoader[levelKeyList[idx]]
  1491. info := &ArenaMatchInfo{
  1492. LevelId: data.ArenaLevelId,
  1493. Score: data.ArenaLevelScore,
  1494. ScoreRewardList: map[int32]int32{},
  1495. WinRewardList: map[int32]int32{},
  1496. FailedRewardList: map[int32]int32{},
  1497. WinScore: data.WinScore,
  1498. WinScore1: data.WinScore1,
  1499. WinScore2: data.WinScore2,
  1500. FailedScore: data.LostScore,
  1501. FailedScore1: data.LostScore1,
  1502. FailedScore2: data.LostScore2,
  1503. }
  1504. for idx := range data.ArenaLevelReward {
  1505. key, value := Str2Res(data.ArenaLevelReward[idx])
  1506. if key > 0 && value > 0 {
  1507. info.ScoreRewardList[key] = value
  1508. }
  1509. }
  1510. for idx := range data.WinReward {
  1511. key, value := Str2Res(data.WinReward[idx])
  1512. if key > 0 && value > 0 {
  1513. info.WinRewardList[key] = value
  1514. }
  1515. }
  1516. for idx := range data.FailReward {
  1517. key, value := Str2Res(data.FailReward[idx])
  1518. if key > 0 && value > 0 {
  1519. info.FailedRewardList[key] = value
  1520. }
  1521. }
  1522. if len(data.Section) == 2 {
  1523. left, _ := Str2Num(data.Section[0])
  1524. right, _ := Str2Num(data.Section[1])
  1525. info.ScoreSectionLeft = 1 + float32(left)*0.01
  1526. info.ScoreSectionRight = 1 + float32(right)*0.01
  1527. }
  1528. info.WinStreak = append(info.WinStreak, 0)
  1529. for idx := range data.WinStreak {
  1530. val, _ := Str2Num(data.WinStreak[idx])
  1531. info.WinStreak = append(info.WinStreak, int32(val))
  1532. }
  1533. for idx := range data.Win {
  1534. left, right := Str2Res(data.Win[idx])
  1535. info.WinMatchList = append(info.WinMatchList, serverproto.KeyValueType{Key: left, Value: right})
  1536. }
  1537. for idx := range data.Fail {
  1538. left, right := Str2Res(data.Fail[idx])
  1539. info.FailedMatchList = append(info.FailedMatchList, serverproto.KeyValueType{Key: left, Value: right})
  1540. }
  1541. info.LevelReduce = data.LevelReduce
  1542. if minScore == 0 {
  1543. info.MinScore = minScore
  1544. } else {
  1545. info.MinScore = minScore + 1
  1546. }
  1547. ConvertArenaMatch = append(ConvertArenaMatch, info)
  1548. ConvertArenaMatchList[info.LevelId] = info
  1549. ConvertScoreToArenaLevelList[info.MinScore] = info.LevelId
  1550. minScore = info.Score
  1551. }
  1552. sort.Slice(ConvertArenaMatch, func(i, j int) bool {
  1553. return ConvertArenaMatch[i].Score < ConvertArenaMatch[j].Score
  1554. })
  1555. MinTopRankScore = ConvertArenaMatch[len(ConvertArenaMatch)-3].MinScore
  1556. }
  1557. type ConvertDaoChang100Info struct {
  1558. posIdx int32
  1559. posIdxType int32
  1560. PosIdxFuncType int32
  1561. RewardList []*serverproto.KeyValueType
  1562. RobotId int32
  1563. TimeProtect uint64
  1564. TimeReward uint64
  1565. }
  1566. var ConvertDaoChang100List = map[int32]*ConvertDaoChang100Info{}
  1567. func convertDaoChang100Cfg() {
  1568. for _, data := range serverproto.HundredDojoCfgLoader {
  1569. info := &ConvertDaoChang100Info{
  1570. posIdx: data.Id,
  1571. posIdxType: data.AreaType,
  1572. PosIdxFuncType: data.FunType,
  1573. RobotId: data.Robot,
  1574. TimeProtect: uint64(data.TimeProtect) * 60 * 1000,
  1575. TimeReward: uint64(data.TimeReward) * 60 * 1000,
  1576. }
  1577. for idx := 0; idx < len(data.RewardList); idx++ {
  1578. k, v := Str2Res(data.RewardList[idx])
  1579. if k > 0 && v > 0 {
  1580. info.RewardList = append(info.RewardList, &serverproto.KeyValueType{Key: k, Value: v})
  1581. }
  1582. }
  1583. if data.FunType == 1 {
  1584. if _, ok := ConvertRobotDaoChang100[data.Robot]; !ok {
  1585. panic("ConvertRobotDaoChang100 nil")
  1586. }
  1587. }
  1588. ConvertDaoChang100List[info.posIdx] = info
  1589. }
  1590. }
  1591. type ConvertPartnerInfo struct {
  1592. PartnerId int32
  1593. EquipList []int32
  1594. Level int32
  1595. }
  1596. type ConvertRobotInfo struct {
  1597. RobotId int32
  1598. RobotName string
  1599. ArenaId int32
  1600. Level int32
  1601. Avatar int32
  1602. EquipList []int32
  1603. SkillList []int32
  1604. Head int32
  1605. PartnerIdList []*ConvertPartnerInfo
  1606. FightInfo *serverproto.FightRoleInfo
  1607. }
  1608. func (this *ConvertRobotInfo) initFightInfo() {
  1609. this.FightInfo = &serverproto.FightRoleInfo{
  1610. IsRobot: true,
  1611. BriefInfo: &serverproto.CommonPlayerBriefInfo{
  1612. Uid: uint64(this.RobotId),
  1613. NickName: this.RobotName,
  1614. },
  1615. }
  1616. }
  1617. var ConvertArenaRobot []int32 //[ArenaLevelId,RobotId]
  1618. var ConvertRobot = map[int32]*ConvertRobotInfo{}
  1619. var ConvertRobotDaoChang100 = map[int32]*ConvertRobotInfo{}
  1620. var ConvertRobotCrossTopTower []*ConvertRobotInfo
  1621. func convertRobotCfg() {
  1622. //clean for reload
  1623. ConvertArenaRobot = []int32{}
  1624. ConvertRobot = map[int32]*ConvertRobotInfo{}
  1625. ConvertRobotDaoChang100 = map[int32]*ConvertRobotInfo{}
  1626. for _, data := range serverproto.RobotCfgLoader {
  1627. //道场使用(段位对应机器人列表)
  1628. ConvertArenaRobot = append(ConvertArenaRobot, data.RobotId)
  1629. robotData := &ConvertRobotInfo{
  1630. RobotId: data.RobotId,
  1631. ArenaId: data.ArenaLevelId,
  1632. Level: data.RobotLevel,
  1633. Avatar: data.RobotAvatar,
  1634. Head: data.RobotHeadPortrait,
  1635. RobotName: data.RobotName,
  1636. }
  1637. for idx := range data.RobotEquip {
  1638. equipId, _ := Str2Num(data.RobotEquip[idx])
  1639. robotData.EquipList = append(robotData.EquipList, int32(equipId))
  1640. }
  1641. for idx := range data.RobotSkill {
  1642. skillId, _ := Str2Num(data.RobotSkill[idx])
  1643. robotData.SkillList = append(robotData.SkillList, int32(skillId))
  1644. }
  1645. //伙伴列表
  1646. for idx := range data.PartnerId {
  1647. partnerInfo := &ConvertPartnerInfo{}
  1648. partnerId, _ := Str2Num(data.PartnerId[idx])
  1649. partnerInfo.PartnerId = int32(partnerId)
  1650. //伙伴装备
  1651. partnerEquipStrList := strings.Split(data.PartnerEquip[idx], ":")
  1652. for j := range partnerEquipStrList {
  1653. partnerEquipId, _ := Str2Num(partnerEquipStrList[j])
  1654. partnerInfo.EquipList = append(partnerInfo.EquipList, int32(partnerEquipId))
  1655. }
  1656. //伙伴等级
  1657. partnerLevel, _ := Str2Num(data.PartnerLevel[idx])
  1658. partnerInfo.Level = int32(partnerLevel)
  1659. robotData.PartnerIdList = append(robotData.PartnerIdList, partnerInfo)
  1660. }
  1661. robotData.initFightInfo()
  1662. switch data.SystemType {
  1663. case 0:
  1664. ConvertRobot[data.RobotId] = robotData
  1665. case 1:
  1666. ConvertRobotDaoChang100[data.RobotId] = robotData
  1667. case 2:
  1668. ConvertRobotCrossTopTower = append(ConvertRobotCrossTopTower, robotData)
  1669. //ConvertRobotCrossTopTower[data.RobotId] = robotData
  1670. }
  1671. }
  1672. }
  1673. //WorldBossCfg
  1674. var ConvertWorldBoss = map[int32][]*ConvertWorldBossData{} //[1,info][2,info][3,info][0,info]
  1675. type KillRewardInfo struct {
  1676. RewardWeight int32
  1677. DeductionWeight int32
  1678. RewardList []*serverproto.KeyValueType //1大奖,2中奖,3参与奖
  1679. }
  1680. const (
  1681. SummonBossType_Normal = iota //普通世界boss
  1682. SummonBossType_ChangePlay //变身世界boss
  1683. )
  1684. type ConvertWorldBossData struct {
  1685. Id int32
  1686. RefreshId int32
  1687. SummonId int32
  1688. SummonType int32 //
  1689. StartDay int32 //=0表示根据给定的时间来开启[BossBeginTime,BossEndTime]
  1690. SummonTime []time.Time //刷新时间
  1691. DurationTime int32
  1692. RollTotalWeight int32
  1693. DeductionWeight int32
  1694. RollList []*KillRewardInfo
  1695. ReduceHp *serverproto.KeyValueType //1大奖,2中奖,3参与奖
  1696. RefreshTime time.Time //刷新boss的时间错,逻辑中使用
  1697. //WorldBossChangePlay
  1698. BossBeginTimeStamp uint64
  1699. BossEndTimeStmp uint64
  1700. BossBeginTime time.Time
  1701. BossEndTime time.Time
  1702. ConsumeList map[int32]int32
  1703. ChangePlayIdList []*serverproto.KeyValueType
  1704. TotalChangePlayWeight int32
  1705. }
  1706. func (this *ConvertWorldBossData) RandChangePlayId() int32 {
  1707. var retBossId int32 = 0
  1708. randWeight := rand.Int31n(this.TotalChangePlayWeight) + 1
  1709. for idx := 0; idx < len(this.ChangePlayIdList); idx++ {
  1710. retBossId = this.ChangePlayIdList[idx].Key
  1711. if this.ChangePlayIdList[idx].Value >= randWeight {
  1712. break
  1713. }
  1714. }
  1715. return retBossId
  1716. }
  1717. var ConvertWorldBossList = map[int32]*ConvertWorldBossData{}
  1718. var ConvertWorldBossChangePlayList = map[int32]*ConvertWorldBossData{}
  1719. const (
  1720. WorldBossListNum = 6
  1721. )
  1722. func convertWorldBossCfg() {
  1723. //WorldBossCfg
  1724. for _, data := range serverproto.WorldBossCfgLoader {
  1725. refreshId := data.Id % WorldBossListNum
  1726. convertData, ok := ConvertWorldBossList[data.Id]
  1727. if !ok {
  1728. convertData = &ConvertWorldBossData{
  1729. RefreshId: refreshId,
  1730. Id: data.Id,
  1731. DurationTime: 3600,
  1732. SummonId: data.SummonId,
  1733. }
  1734. }
  1735. convertData.StartDay = data.StartDay
  1736. //convertData.Roll = data.Roll
  1737. convertData.DurationTime = data.LifeTime
  1738. loc := util.GetLoc()
  1739. for idx := range data.SummonTime {
  1740. sTime, err := time.ParseInLocation(util.DATE_FORMAT3, data.SummonTime[idx], loc)
  1741. if err == nil {
  1742. convertData.SummonTime = append(convertData.SummonTime, sTime)
  1743. //util.DebugF("bossid=%v summontime=%v", convertData.Id, sTime.String())
  1744. }
  1745. }
  1746. for idx := 0; idx < len(data.Roll); idx++ {
  1747. rollVal, _ := Str2Num(data.Roll[idx]) //正常概率
  1748. if rollVal <= 0 {
  1749. continue
  1750. }
  1751. rollVal2, _ := Str2Num(data.Roll2[idx]) //衰减概率
  1752. if rollVal2 <= 0 {
  1753. continue
  1754. }
  1755. convertData.RollTotalWeight += int32(rollVal)
  1756. convertData.DeductionWeight += int32(rollVal2)
  1757. RollData := &KillRewardInfo{
  1758. RewardWeight: convertData.RollTotalWeight,
  1759. DeductionWeight: convertData.DeductionWeight,
  1760. }
  1761. if idx == 0 {
  1762. for idx := 0; idx < len(data.FirstRewardServer); idx++ {
  1763. key, val := Str2Res(data.FirstRewardServer[idx])
  1764. if key <= 0 || val <= 0 {
  1765. continue
  1766. }
  1767. RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
  1768. Key: key,
  1769. Value: val,
  1770. })
  1771. }
  1772. } else if idx == 1 {
  1773. for idx := 0; idx < len(data.SecondRewardServer); idx++ {
  1774. key, val := Str2Res(data.SecondRewardServer[idx])
  1775. if key <= 0 || val <= 0 {
  1776. continue
  1777. }
  1778. RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
  1779. Key: key,
  1780. Value: val,
  1781. })
  1782. }
  1783. } else if idx == 2 {
  1784. for idx := 0; idx < len(data.ThreeRewardServer); idx++ {
  1785. key, val := Str2Res(data.ThreeRewardServer[idx])
  1786. if key <= 0 || val <= 0 {
  1787. continue
  1788. }
  1789. RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
  1790. Key: key,
  1791. Value: val,
  1792. })
  1793. }
  1794. }
  1795. key, value := Str2Res(data.AutoHp[0])
  1796. convertData.ReduceHp = &serverproto.KeyValueType{
  1797. Key: key,
  1798. Value: value,
  1799. }
  1800. convertData.RollList = append(convertData.RollList, RollData)
  1801. }
  1802. ConvertWorldBossList[data.Id] = convertData
  1803. //log.Print("time:", convertData.SummonTime[0].String(), convertData.SummonTime[1].String(), convertData.SummonTime[2].String())
  1804. ConvertWorldBoss[refreshId] = append(ConvertWorldBoss[refreshId], convertData)
  1805. sort.Slice(ConvertWorldBoss[refreshId], func(i, j int) bool {
  1806. return ConvertWorldBoss[refreshId][i].StartDay < ConvertWorldBoss[refreshId][j].StartDay
  1807. })
  1808. }
  1809. //WorldBossChangePlayCfg
  1810. for _, data := range serverproto.WorldBossChangePlayCfgLoader {
  1811. convertData := &ConvertWorldBossData{
  1812. //RefreshId: refreshId,
  1813. Id: data.Id,
  1814. DurationTime: data.LifeTime,
  1815. SummonId: data.SummonId,
  1816. ConsumeList: map[int32]int32{},
  1817. }
  1818. convertData.SummonType = SummonBossType_ChangePlay
  1819. loc := util.GetLoc()
  1820. for idx := range data.SummonTime {
  1821. sTime, err := time.ParseInLocation(util.DATE_FORMAT3, data.SummonTime[idx], loc)
  1822. if err == nil {
  1823. convertData.SummonTime = append(convertData.SummonTime, sTime)
  1824. //util.DebugF("bossid=%v summontime=%v", convertData.Id, sTime.String())
  1825. }
  1826. }
  1827. //beginTime endTime
  1828. tmpStartTimeList := strings.Split(data.StartTime, ";")
  1829. if tmpStartTimeList[0] == "1" && len(tmpStartTimeList) >= 2 {
  1830. convertData.BossBeginTime = util.GetTimeByStr(tmpStartTimeList[1])
  1831. convertData.BossBeginTimeStamp = uint64(convertData.BossBeginTime.UnixNano() / 1e6)
  1832. }
  1833. tmpEndTimeList := strings.Split(data.EndTime, ";")
  1834. if tmpEndTimeList[0] == "1" && len(tmpEndTimeList) >= 2 {
  1835. convertData.BossEndTime = util.GetTimeByStr(tmpEndTimeList[1])
  1836. convertData.BossEndTimeStmp = uint64(convertData.BossEndTime.UnixNano() / 1e6)
  1837. }
  1838. //consume list
  1839. Str2ResMapList(data.Consume, convertData.ConsumeList)
  1840. //ChangePlayList
  1841. var totalWeight int32 = 0
  1842. for idx := 0; idx < len(data.ChangePlayId); idx++ {
  1843. k, v := Str2Res(data.ChangePlayId[idx])
  1844. if k <= 0 || v <= 0 {
  1845. continue
  1846. }
  1847. totalWeight += k
  1848. convertData.ChangePlayIdList = append(convertData.ChangePlayIdList,
  1849. &serverproto.KeyValueType{
  1850. Key: v,
  1851. Value: totalWeight,
  1852. })
  1853. }
  1854. convertData.TotalChangePlayWeight = totalWeight
  1855. for idx := 0; idx < len(data.Roll); idx++ {
  1856. rollVal, _ := Str2Num(data.Roll[idx]) //正常概率
  1857. if rollVal <= 0 {
  1858. continue
  1859. }
  1860. rollVal2, _ := Str2Num(data.Roll2[idx]) //衰减概率
  1861. if rollVal2 <= 0 {
  1862. continue
  1863. }
  1864. convertData.RollTotalWeight += int32(rollVal)
  1865. convertData.DeductionWeight += int32(rollVal2)
  1866. RollData := &KillRewardInfo{
  1867. RewardWeight: convertData.RollTotalWeight,
  1868. DeductionWeight: convertData.DeductionWeight,
  1869. }
  1870. if idx == 0 {
  1871. for idx := 0; idx < len(data.FirstRewardServer); idx++ {
  1872. key, val := Str2Res(data.FirstRewardServer[idx])
  1873. if key <= 0 || val <= 0 {
  1874. continue
  1875. }
  1876. RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
  1877. Key: key,
  1878. Value: val,
  1879. })
  1880. }
  1881. } else if idx == 1 {
  1882. for idx := 0; idx < len(data.SecondRewardServer); idx++ {
  1883. key, val := Str2Res(data.SecondRewardServer[idx])
  1884. if key <= 0 || val <= 0 {
  1885. continue
  1886. }
  1887. RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
  1888. Key: key,
  1889. Value: val,
  1890. })
  1891. }
  1892. } else if idx == 2 {
  1893. for idx := 0; idx < len(data.ThreeRewardServer); idx++ {
  1894. key, val := Str2Res(data.ThreeRewardServer[idx])
  1895. if key <= 0 || val <= 0 {
  1896. continue
  1897. }
  1898. RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
  1899. Key: key,
  1900. Value: val,
  1901. })
  1902. }
  1903. }
  1904. key, value := Str2Res(data.AutoHp[0])
  1905. convertData.ReduceHp = &serverproto.KeyValueType{
  1906. Key: key,
  1907. Value: value,
  1908. }
  1909. convertData.RollList = append(convertData.RollList, RollData)
  1910. }
  1911. ConvertWorldBossChangePlayList[data.Id] = convertData
  1912. }
  1913. }
  1914. type SkillAttr struct {
  1915. AttrList map[int32][]*serverproto.KeyValueType
  1916. }
  1917. var ConvertSkillAttr = map[int32]*SkillAttr{}
  1918. func convertSkillUpEffect() {
  1919. for _, data := range serverproto.SkillUpEffectCfgLoader {
  1920. if data == nil {
  1921. //有错误,直接返回
  1922. return
  1923. }
  1924. passData := ConvertSkillAttr[data.SkillId]
  1925. if passData == nil {
  1926. key, value := Str2Res(data.AddAttributes[0])
  1927. attrData := &SkillAttr{
  1928. AttrList: map[int32][]*serverproto.KeyValueType{},
  1929. }
  1930. skillLevel := data.Id % 1000
  1931. attrData.AttrList[skillLevel] = append(attrData.AttrList[skillLevel], &serverproto.KeyValueType{
  1932. Key: key,
  1933. Value: value,
  1934. })
  1935. ConvertSkillAttr[data.SkillId] = attrData
  1936. } else {
  1937. key, value := Str2Res(data.AddAttributes[0])
  1938. skillLevel := data.Id % 1000
  1939. passData.AttrList[skillLevel] = append(passData.AttrList[skillLevel], &serverproto.KeyValueType{
  1940. Key: key,
  1941. Value: value,
  1942. })
  1943. }
  1944. }
  1945. }
  1946. type keyValList struct {
  1947. KeyType int32
  1948. ValList []float32
  1949. RankList []int32
  1950. }
  1951. type compConditionAndRewardData struct {
  1952. Id int32 //档位
  1953. CfgId int32 //配置表ID
  1954. ConditionList []*keyValList //条件
  1955. RewardList []map[int32]int32 //对应结算周期奖励
  1956. }
  1957. type CompetitionTypeData struct {
  1958. CompetitionId int32
  1959. CompetitionType int32
  1960. ConditionList map[int32]*compConditionAndRewardData //对应档位数据
  1961. LastConditionId int32
  1962. //赛季特殊道具ID
  1963. CompetitionItemList set.Interface
  1964. }
  1965. var ConvertCompTypeList = map[int32]*CompetitionTypeData{} //赛季类型数据
  1966. func (this *CompetitionTypeData) GetCompetitionType() int32 {
  1967. return this.CompetitionType
  1968. }
  1969. func (this *CompetitionTypeData) GetRankSection(selfRank, totalRank int64) (int32, bool, int32) {
  1970. if selfRank <= 0 || totalRank <= 0 {
  1971. return this.LastConditionId, false, this.LastConditionId
  1972. } else {
  1973. if totalRank < GlobalCompetitionSectionTotal {
  1974. totalRank = GlobalCompetitionSectionTotal
  1975. }
  1976. rankPercent := 1 - float32(selfRank)*GlobalCompetitionSectionFactor/float32(totalRank)
  1977. rankPercent = rankPercent * 100
  1978. //first rank 直接返回第一档
  1979. if totalRank > 0 && selfRank == 1 {
  1980. rankPercent = 100
  1981. }
  1982. //rankPercent := (1 - float32(selfRank-1)/float32(totalRank)) * 100
  1983. for _, data := range this.ConditionList {
  1984. for _, conditionData := range data.ConditionList {
  1985. if conditionData.KeyType == 5 {
  1986. if conditionData.RankList[0] <= int32(selfRank) &&
  1987. int32(selfRank) <= conditionData.RankList[1] {
  1988. return data.Id, (data.Id == 1), data.CfgId
  1989. }
  1990. } else {
  1991. if len(conditionData.ValList) >= 2 &&
  1992. rankPercent > float32(conditionData.ValList[0]) &&
  1993. rankPercent <= float32(conditionData.ValList[1]) {
  1994. return data.Id, (data.Id == 1), data.CfgId
  1995. // return data.Id, data.Id%int32(len(this.ConditionList)) == 1
  1996. }
  1997. }
  1998. }
  1999. }
  2000. util.ErrorF("GetRankSection not find correct sectionId rankPercent=%v [please find cehua!!!]", rankPercent)
  2001. }
  2002. return this.LastConditionId, false, this.LastConditionId
  2003. }
  2004. type CompetitionBeginEndTimeData struct {
  2005. CalBeginTime, CalEndTime time.Time //根据开服时间计算后的开启和结束时间
  2006. }
  2007. type CompetitionTimeData struct {
  2008. CompetitionId int32
  2009. CompetitionType int32 //赛季类型
  2010. Duration int32 //持续天数,天为单位
  2011. PeriodEndStrList []int
  2012. BeginTimeStr, EndTimeStr string //开始/结束时间
  2013. ResetTime int32 //休赛季时间,天为单位
  2014. RewardTimeStr []string
  2015. RewardTime []time.Time //周期结算时间
  2016. CalBeginTime, CalEndTime time.Time //根据开服时间计算后的开启和结束时间
  2017. PeriodEndTimeList []time.Time //中间结算时间点
  2018. }
  2019. func (this *CompetitionTimeData) GetCalEndTime() time.Time {
  2020. return this.CalEndTime
  2021. }
  2022. func (this *CompetitionTimeData) GetCompetitionType() int32 {
  2023. return this.CompetitionType
  2024. }
  2025. var ConvertCompTimeList = map[int32]*CompetitionTimeData{} //赛季时间数据
  2026. var ConvertCompTimeIdList []*CompetitionTimeData //赛季时间顺序数据
  2027. func convertCompetitionCfg() {
  2028. //clean for reload
  2029. ConvertCompTimeIdList = []*CompetitionTimeData{}
  2030. ConvertCompTimeList = map[int32]*CompetitionTimeData{}
  2031. //CompetitionCfg
  2032. ConvertCompTypeList = map[int32]*CompetitionTypeData{}
  2033. for _, data := range serverproto.CompetitionCfgLoader {
  2034. info, ok := ConvertCompTypeList[data.CompetitionId]
  2035. if !ok {
  2036. info = &CompetitionTypeData{
  2037. CompetitionId: data.CompetitionId,
  2038. CompetitionType: data.CompetitionType,
  2039. ConditionList: map[int32]*compConditionAndRewardData{},
  2040. CompetitionItemList: set.New(set.NonThreadSafe),
  2041. }
  2042. }
  2043. //条件
  2044. conditionData := &compConditionAndRewardData{
  2045. // Id: data.Id,
  2046. Id: data.Level,
  2047. CfgId: data.Id,
  2048. }
  2049. for idx := range data.CompetitionCondition {
  2050. dataList := strings.Split(data.CompetitionCondition[idx], ":")
  2051. keyType, _ := Str2Num(dataList[0])
  2052. keyData := &keyValList{KeyType: int32(keyType)}
  2053. for i := 1; i < len(dataList); i++ {
  2054. if keyType == 5 {
  2055. val, _ := Str2Num(dataList[i])
  2056. keyData.RankList = append(keyData.RankList, int32(val))
  2057. } else {
  2058. val, _ := Str2Float32(dataList[i])
  2059. //val, _ := Str2Num(dataList[i])
  2060. keyData.ValList = append(keyData.ValList, float32(val))
  2061. }
  2062. }
  2063. conditionData.ConditionList = append(conditionData.ConditionList, keyData)
  2064. }
  2065. //结算奖励
  2066. if data.CompetitionType == 1 || data.CompetitionType == 2 || data.CompetitionType == 3 || data.CompetitionType == 4 ||
  2067. data.CompetitionType == 5 {
  2068. //第一次结算
  2069. var reward1List = map[int32]int32{}
  2070. for k := 0; k < len(data.CompetitionReward1); k++ {
  2071. key, val := Str2Res(data.CompetitionReward1[k])
  2072. if key > 0 && val > 0 {
  2073. reward1List[key] += val
  2074. }
  2075. }
  2076. conditionData.RewardList = append(conditionData.RewardList, reward1List)
  2077. //第二次结算
  2078. var reward2List = map[int32]int32{}
  2079. for k := 0; k < len(data.CompetitionReward2); k++ {
  2080. key, val := Str2Res(data.CompetitionReward2[k])
  2081. if key > 0 && val > 0 {
  2082. reward2List[key] += val
  2083. }
  2084. }
  2085. conditionData.RewardList = append(conditionData.RewardList, reward2List)
  2086. //第三次次结算
  2087. var reward3List = map[int32]int32{}
  2088. for k := 0; k < len(data.CompetitionReward3); k++ {
  2089. key, val := Str2Res(data.CompetitionReward3[k])
  2090. if key > 0 && val > 0 {
  2091. reward3List[key] += val
  2092. }
  2093. }
  2094. conditionData.RewardList = append(conditionData.RewardList, reward3List)
  2095. }
  2096. info.ConditionList[data.Id] = conditionData
  2097. if info.LastConditionId < data.Id {
  2098. info.LastConditionId = data.Id
  2099. }
  2100. //活动道具
  2101. for idx := 0; idx < len(data.HuodongItem); idx++ {
  2102. val, _ := Str2Num(data.HuodongItem[idx])
  2103. if val > 0 {
  2104. info.CompetitionItemList.Add(int32(val))
  2105. }
  2106. }
  2107. ConvertCompTypeList[info.CompetitionId] = info
  2108. }
  2109. //赛季时间处理
  2110. for _, data := range serverproto.CompetitionCfgLoader {
  2111. if data.BeginTime == "" || data.EndTime == "" {
  2112. continue
  2113. }
  2114. timeInfo, ok := ConvertCompTimeList[data.CompetitionId]
  2115. if ok {
  2116. continue
  2117. }
  2118. timeInfo = &CompetitionTimeData{
  2119. CompetitionId: data.CompetitionId,
  2120. CompetitionType: data.CompetitionType,
  2121. ResetTime: data.RestTime,
  2122. BeginTimeStr: data.BeginTime,
  2123. EndTimeStr: data.EndTime,
  2124. }
  2125. for k := 0; k < len(data.CompetitionPeriod); k++ {
  2126. val, _ := Str2Num(data.CompetitionPeriod[k])
  2127. if val <= 0 {
  2128. util.PanicF("CompetitionCfgLoader CompetitionPeriod Invalid!!!")
  2129. }
  2130. timeInfo.PeriodEndStrList = append(timeInfo.PeriodEndStrList, val)
  2131. }
  2132. sort.Ints(timeInfo.PeriodEndStrList)
  2133. if len(timeInfo.PeriodEndStrList) <= 0 {
  2134. util.PanicF("CompetitionCfgLoader CompetitionPeriod Invalid!!!")
  2135. }
  2136. timeInfo.Duration = int32(timeInfo.PeriodEndStrList[len(timeInfo.PeriodEndStrList)-1])
  2137. ConvertCompTimeList[timeInfo.CompetitionId] = timeInfo
  2138. ConvertCompTimeIdList = append(ConvertCompTimeIdList, timeInfo)
  2139. }
  2140. sort.Slice(ConvertCompTimeIdList, func(i, j int) bool {
  2141. return ConvertCompTimeIdList[i].CompetitionId < ConvertCompTimeIdList[j].CompetitionId
  2142. })
  2143. }
  2144. const (
  2145. WheelRewardType_Level = 1
  2146. WheelRewardType_Normal = 2
  2147. WheelRewardType_Mini = 3
  2148. WheelRewardType_MVp = 4
  2149. )
  2150. type CompetitionPrizeWheelInfo struct {
  2151. ID int32
  2152. //奖励数据
  2153. LowRewardKv serverproto.KeyValueType
  2154. NormalRewardKv serverproto.KeyValueType //normal [掉落ID,数量]
  2155. MiniRewardKV serverproto.KeyValueType
  2156. MVPRewardKV serverproto.KeyValueType
  2157. Weight int32
  2158. RewardFactorList map[int]int32 //抽奖概率 1low 2normal 3mini 4mvp
  2159. MvpFactorList []int32 //4mvp
  2160. }
  2161. type WheelItemInfo struct {
  2162. Key int32 //道具id
  2163. Val int32 //道具数量
  2164. Money int32 //金币消耗
  2165. Score int32 //积分
  2166. }
  2167. type ConvertPrizeWheelInfo struct {
  2168. RewardTemplateList []*CompetitionPrizeWheelInfo
  2169. TotalWeight int32
  2170. WheelCostItem []*WheelItemInfo //道具/金币消耗 抽一次
  2171. WheelAllCostItem WheelItemInfo //抽全部道具/金币消耗
  2172. RefreshCostMoney []int32 // 刷新价格(金币)
  2173. NoMVPRewardNum int32 //前面无大奖次数
  2174. ItemToMoney int32 //单个道具对应金币数量
  2175. }
  2176. func (this *ConvertPrizeWheelInfo) genWheelRewardByType(itemIdx *int32, rewardType int32,
  2177. kv serverproto.KeyValueType, rewardList *[]*serverproto.WheelRewardItemInfo) {
  2178. for idx := 0; idx < int(kv.Value); idx++ {
  2179. *itemIdx++
  2180. rewardItem := &serverproto.WheelRewardItemInfo{
  2181. ItemIdx: *itemIdx,
  2182. RewardType: rewardType, //1
  2183. }
  2184. tmpDropReward := map[int32]int32{}
  2185. DropCfgProcess(tmpDropReward, kv.Key)
  2186. for k, v := range tmpDropReward {
  2187. if k > 0 && v > 0 {
  2188. rewardItem.ItemId = k
  2189. rewardItem.ItemNum = v
  2190. }
  2191. break
  2192. }
  2193. *rewardList = append(*rewardList, rewardItem)
  2194. }
  2195. }
  2196. func (this *ConvertPrizeWheelInfo) GenWheelReward(rewardList *[]*serverproto.WheelRewardItemInfo) int32 {
  2197. if this.TotalWeight <= 0 {
  2198. return 0
  2199. }
  2200. var tmpRewardList []*serverproto.WheelRewardItemInfo
  2201. randWeight := rand.Int31n(this.TotalWeight) + 1 //[0,randWeight]
  2202. templateIdx := 0
  2203. for idx := 0; idx < len(this.RewardTemplateList); idx++ {
  2204. templateIdx = idx
  2205. if randWeight <= this.RewardTemplateList[idx].Weight {
  2206. break
  2207. }
  2208. }
  2209. templateInfo := this.RewardTemplateList[templateIdx]
  2210. var itemIdx int32 = 0
  2211. //level
  2212. this.genWheelRewardByType(&itemIdx, WheelRewardType_Level, templateInfo.LowRewardKv, &tmpRewardList)
  2213. //normal
  2214. this.genWheelRewardByType(&itemIdx, WheelRewardType_Normal, templateInfo.NormalRewardKv, &tmpRewardList)
  2215. //mini
  2216. this.genWheelRewardByType(&itemIdx, WheelRewardType_Mini, templateInfo.MiniRewardKV, &tmpRewardList)
  2217. //mvp
  2218. this.genWheelRewardByType(&itemIdx, WheelRewardType_MVp, templateInfo.MVPRewardKV, &tmpRewardList)
  2219. randArray := GenRandomArrayByLen(len(tmpRewardList))
  2220. for idx := 0; idx < len(randArray); idx++ {
  2221. *rewardList = append(*rewardList, tmpRewardList[randArray[idx]-1])
  2222. }
  2223. util.DebugF("templateIdx=%v GenWheelReward=%v", templateInfo.ID, *rewardList)
  2224. return templateInfo.ID
  2225. }
  2226. func (this *ConvertPrizeWheelInfo) GetTemplateData(templateIdx int32) *CompetitionPrizeWheelInfo {
  2227. for idx := 0; idx < len(this.RewardTemplateList); idx++ {
  2228. if this.RewardTemplateList[idx].ID == templateIdx {
  2229. return this.RewardTemplateList[idx]
  2230. }
  2231. }
  2232. return nil
  2233. }
  2234. var ConvertPrizeWheelData *ConvertPrizeWheelInfo
  2235. var ConvertActivityPrizeWheelData = map[int32]*ConvertPrizeWheelInfo{}
  2236. func convertCompetitionPrizeWheelCfg() {
  2237. ConvertPrizeWheelData = &ConvertPrizeWheelInfo{}
  2238. //赛季转盘
  2239. for _, cfgData := range serverproto.CompetitionPrizeWheelCfgLoader {
  2240. convertCompetitionPrizeWheelCfgLoad(cfgData, ConvertPrizeWheelData)
  2241. }
  2242. //活动转盘
  2243. for _, cfgData := range serverproto.ActivityRoulettelCfgLoader {
  2244. if _, ok := ConvertActivityPrizeWheelData[cfgData.ActivitiesId]; !ok {
  2245. ConvertActivityPrizeWheelData[cfgData.ActivitiesId] = &ConvertPrizeWheelInfo{}
  2246. }
  2247. convertActivityPrizeWheelCfgLoad(cfgData, ConvertActivityPrizeWheelData[cfgData.ActivitiesId])
  2248. }
  2249. }
  2250. func convertCompetitionPrizeWheelCfgLoad(cfgData *serverproto.CompetitionPrizeWheelCfg, tmpData *ConvertPrizeWheelInfo) {
  2251. //赛季转盘
  2252. tmpData.TotalWeight += cfgData.ModProbability
  2253. if cfgData.NoRewardNum > 0 {
  2254. tmpData.NoMVPRewardNum = cfgData.NoRewardNum
  2255. }
  2256. if cfgData.ItemPrice > 0 {
  2257. tmpData.ItemToMoney = cfgData.ItemPrice
  2258. }
  2259. if len(cfgData.RefreshPrice) > 0 && cfgData.RefreshPrice[0] != "" {
  2260. for idx := 0; idx < len(cfgData.RefreshPrice); idx++ {
  2261. tmpVal, _ := Str2Num(cfgData.RefreshPrice[idx])
  2262. tmpData.RefreshCostMoney = append(tmpData.RefreshCostMoney, int32(tmpVal))
  2263. }
  2264. }
  2265. templateData := &CompetitionPrizeWheelInfo{
  2266. ID: cfgData.Id,
  2267. Weight: tmpData.TotalWeight,
  2268. RewardFactorList: map[int]int32{},
  2269. }
  2270. //low
  2271. k, v := Str2Res(cfgData.LowNormalNum[0])
  2272. templateData.LowRewardKv.Key = v
  2273. templateData.LowRewardKv.Value = k
  2274. //normal
  2275. k, v = Str2Res(cfgData.NormalNum[0])
  2276. templateData.NormalRewardKv.Key = v
  2277. templateData.NormalRewardKv.Value = k
  2278. //mini
  2279. k, v = Str2Res(cfgData.MiniNum[0])
  2280. templateData.MiniRewardKV.Key = v
  2281. templateData.MiniRewardKV.Value = k
  2282. //mvp
  2283. k, v = Str2Res(cfgData.MvpNum[0])
  2284. templateData.MVPRewardKV.Key = v
  2285. templateData.MVPRewardKV.Value = k
  2286. for idx := 0; idx < len(cfgData.Probability); idx++ {
  2287. factor, _ := Str2Num(cfgData.Probability[idx])
  2288. templateData.RewardFactorList[idx+1] = int32(factor)
  2289. }
  2290. for idx := 0; idx < len(cfgData.MvpProbability); idx++ {
  2291. factor, _ := Str2Num(cfgData.MvpProbability[idx])
  2292. templateData.MvpFactorList = append(templateData.MvpFactorList, int32(factor))
  2293. }
  2294. if len(cfgData.RewardOneItem) > 0 && cfgData.RewardOneItem[0] != "" {
  2295. if len(cfgData.RewardOneItem) != len(cfgData.RewardOneGold) {
  2296. util.PanicF("convertCompetitionPrizeWheelCfg")
  2297. }
  2298. for idx := 0; idx < len(cfgData.RewardOneItem); idx++ {
  2299. k, v := Str2Res(cfgData.RewardOneItem[idx])
  2300. score, _ := Str2Num(cfgData.RewardOnePoint[idx])
  2301. tmpMoney, _ := Str2Num(cfgData.RewardOneGold[idx])
  2302. tmpWheelInfo := &WheelItemInfo{
  2303. Key: k,
  2304. Val: v,
  2305. Money: int32(tmpMoney),
  2306. Score: int32(score),
  2307. }
  2308. tmpData.WheelCostItem = append(tmpData.WheelCostItem, tmpWheelInfo)
  2309. }
  2310. k, v := Str2Res(cfgData.RewardAllItem[0])
  2311. tmpData.WheelAllCostItem.Key = k
  2312. tmpData.WheelAllCostItem.Val = v
  2313. tmpData.WheelAllCostItem.Money = cfgData.RewardAdllGold
  2314. tmpData.WheelAllCostItem.Score = cfgData.RewardAllPoint
  2315. }
  2316. tmpData.RewardTemplateList = append(tmpData.RewardTemplateList, templateData)
  2317. }
  2318. func convertActivityPrizeWheelCfgLoad(cfgData *serverproto.ActivityRoulettelCfg, tmpData *ConvertPrizeWheelInfo) {
  2319. //赛季转盘
  2320. tmpData.TotalWeight += cfgData.ModProbability
  2321. if cfgData.NoRewardNum > 0 {
  2322. tmpData.NoMVPRewardNum = cfgData.NoRewardNum
  2323. }
  2324. if cfgData.ItemPrice > 0 {
  2325. tmpData.ItemToMoney = cfgData.ItemPrice
  2326. }
  2327. if len(cfgData.RefreshPrice) > 0 && cfgData.RefreshPrice[0] != "" {
  2328. for idx := 0; idx < len(cfgData.RefreshPrice); idx++ {
  2329. tmpVal, _ := Str2Num(cfgData.RefreshPrice[idx])
  2330. tmpData.RefreshCostMoney = append(tmpData.RefreshCostMoney, int32(tmpVal))
  2331. }
  2332. }
  2333. templateData := &CompetitionPrizeWheelInfo{
  2334. ID: cfgData.Id,
  2335. Weight: tmpData.TotalWeight,
  2336. RewardFactorList: map[int]int32{},
  2337. }
  2338. //low
  2339. k, v := Str2Res(cfgData.LowNormalNum[0])
  2340. templateData.LowRewardKv.Key = v
  2341. templateData.LowRewardKv.Value = k
  2342. //normal
  2343. k, v = Str2Res(cfgData.NormalNum[0])
  2344. templateData.NormalRewardKv.Key = v
  2345. templateData.NormalRewardKv.Value = k
  2346. //mini
  2347. k, v = Str2Res(cfgData.MiniNum[0])
  2348. templateData.MiniRewardKV.Key = v
  2349. templateData.MiniRewardKV.Value = k
  2350. //mvp
  2351. k, v = Str2Res(cfgData.MvpNum[0])
  2352. templateData.MVPRewardKV.Key = v
  2353. templateData.MVPRewardKV.Value = k
  2354. for idx := 0; idx < len(cfgData.Probability); idx++ {
  2355. factor, _ := Str2Num(cfgData.Probability[idx])
  2356. templateData.RewardFactorList[idx+1] = int32(factor)
  2357. }
  2358. for idx := 0; idx < len(cfgData.MvpProbability); idx++ {
  2359. factor, _ := Str2Num(cfgData.MvpProbability[idx])
  2360. templateData.MvpFactorList = append(templateData.MvpFactorList, int32(factor))
  2361. }
  2362. if len(cfgData.RewardOneItem) > 0 && cfgData.RewardOneItem[0] != "" {
  2363. if len(cfgData.RewardOneItem) != len(cfgData.RewardOneGold) {
  2364. util.PanicF("convertCompetitionPrizeWheelCfg")
  2365. }
  2366. for idx := 0; idx < len(cfgData.RewardOneItem); idx++ {
  2367. k, v := Str2Res(cfgData.RewardOneItem[idx])
  2368. tmpMoney, _ := Str2Num(cfgData.RewardOneGold[idx])
  2369. tmpWheelInfo := &WheelItemInfo{
  2370. Key: k,
  2371. Val: v,
  2372. Money: int32(tmpMoney),
  2373. }
  2374. tmpData.WheelCostItem = append(tmpData.WheelCostItem, tmpWheelInfo)
  2375. }
  2376. k, v := Str2Res(cfgData.RewardAllItem[0])
  2377. tmpData.WheelAllCostItem.Key = k
  2378. tmpData.WheelAllCostItem.Val = v
  2379. tmpData.WheelAllCostItem.Money = cfgData.RewardAdllGold
  2380. }
  2381. tmpData.RewardTemplateList = append(tmpData.RewardTemplateList, templateData)
  2382. }
  2383. //卡片重置
  2384. var ConvertCardResetList = map[int32]*serverproto.CardReset{} //赛季类型数据
  2385. func convertCardResetCfg() {
  2386. for _, data := range serverproto.CardResetLoader {
  2387. index := data.CardType*1000 + data.CardLv
  2388. if index == 0 {
  2389. //打印一下日志。有问题的
  2390. continue
  2391. }
  2392. ConvertCardResetList[index] = data
  2393. }
  2394. }
  2395. type ResetSkill struct {
  2396. BackResource map[int32]int32
  2397. }
  2398. type levelUpInfo struct {
  2399. HeroLevel map[int32]int32 //技能升级对应的等级限制
  2400. OpenCost []*serverproto.KeyValueType //解锁消耗
  2401. UpGradeCost map[int32]*serverproto.KeyValueType //升级消耗
  2402. ResetBack map[int32]int32 //重置返还
  2403. }
  2404. var ConvertSkillTree = map[int32]*levelUpInfo{}
  2405. var ConvertPartnerSkillTree = map[int32]*levelUpInfo{}
  2406. var ConvertResetSkill = map[int32]*serverproto.KeyValueType{}
  2407. var ConvertSkillJobAndStage = map[int32][]*serverproto.KeyValueType{} //[jobType*100+jobStage*10 +jobBranch,skillIdList]
  2408. //var ConvertParterSkillJobAndStage = map[int32][]*serverproto.KeyValueType{} //[jobType*100+jobStage*10 +jobBranch,skillIdList]
  2409. var ConvertBattleAttrSkill = map[int32]map[serverproto.Attr]float32{} //优化属性计算
  2410. func convertSkillTree() {
  2411. //解析伙伴的技能升级数据
  2412. for _, data := range serverproto.ParterSkillTreeCfgLoader {
  2413. convertData := &levelUpInfo{
  2414. HeroLevel: map[int32]int32{},
  2415. UpGradeCost: map[int32]*serverproto.KeyValueType{},
  2416. ResetBack: map[int32]int32{},
  2417. }
  2418. dem, ok := serverproto.SkillDemandCfgLoader[data.OpenLevel]
  2419. if !ok {
  2420. panic("技能升级表 对应伙伴技能表错误")
  2421. }
  2422. for i, lv := range dem.LvupDemand {
  2423. level, _ := Str2Num(lv)
  2424. convertData.HeroLevel[int32(i)] = int32(level)
  2425. }
  2426. for _, openCost := range data.OpenNeedCost {
  2427. key, val := Str2Res(openCost)
  2428. if key == 0 && val == 0 {
  2429. continue
  2430. }
  2431. convertData.OpenCost = append(convertData.OpenCost, &serverproto.KeyValueType{
  2432. Key: int32(key),
  2433. Value: int32(val),
  2434. })
  2435. }
  2436. var backCount int32 = 0
  2437. for index, upCost := range dem.LvupCost {
  2438. key, val := Str2Res(upCost)
  2439. if key == 0 && val == 0 {
  2440. continue
  2441. }
  2442. convertData.UpGradeCost[int32(index)] = &serverproto.KeyValueType{
  2443. Key: int32(key),
  2444. Value: int32(val),
  2445. }
  2446. //初始化返还数量
  2447. backCount += val
  2448. convertData.ResetBack[int32(index+2)] += backCount
  2449. }
  2450. ConvertPartnerSkillTree[data.SkillId] = convertData
  2451. }
  2452. //解析伙伴的技能升级数据
  2453. for _, data := range serverproto.SkillTreeCfgLoader {
  2454. convertData := &levelUpInfo{
  2455. HeroLevel: map[int32]int32{},
  2456. UpGradeCost: map[int32]*serverproto.KeyValueType{},
  2457. ResetBack: map[int32]int32{},
  2458. }
  2459. dem, ok := serverproto.SkillDemandCfgLoader[data.OpenLevel]
  2460. if !ok {
  2461. panic("技能升级表 对应主角技能表错误")
  2462. }
  2463. for index, rLevel := range dem.LvupDemand {
  2464. level, _ := Str2Num(rLevel)
  2465. convertData.HeroLevel[int32(index)] = int32(level)
  2466. }
  2467. for _, openCost := range data.OpenNeedCost {
  2468. key, val := Str2Res(openCost)
  2469. if key == 0 && val == 0 {
  2470. continue
  2471. }
  2472. convertData.OpenCost = append(convertData.OpenCost, &serverproto.KeyValueType{
  2473. Key: int32(key),
  2474. Value: int32(val),
  2475. })
  2476. }
  2477. var backCount int32 = 0
  2478. for index, cost := range dem.LvupCost {
  2479. key, val := Str2Res(cost)
  2480. if key == 0 && val == 0 {
  2481. continue
  2482. }
  2483. convertData.UpGradeCost[int32(index)] = &serverproto.KeyValueType{
  2484. Key: int32(key),
  2485. Value: int32(val),
  2486. }
  2487. //初始化返还数量
  2488. backCount += val
  2489. convertData.ResetBack[int32(index+2)] += backCount
  2490. }
  2491. ConvertSkillTree[data.SkillId] = convertData
  2492. }
  2493. globalCfg, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Reset_Skill_Level_Cost)]
  2494. if !ok {
  2495. util.InfoF("skill reset cost config not found")
  2496. }
  2497. strList := strings.Split(globalCfg.SVal, ";")
  2498. for idx := range strList {
  2499. key, value := Str2Res(strList[idx])
  2500. if key == 0 && value == 0 {
  2501. continue
  2502. }
  2503. ConvertResetSkill[int32(idx)] = &serverproto.KeyValueType{
  2504. Key: key,
  2505. Value: value,
  2506. }
  2507. }
  2508. }
  2509. type ShopRefreshCost struct {
  2510. ItemList map[int32]int32
  2511. }
  2512. type SpecialShop struct {
  2513. ItemList []*SpecialShopItem
  2514. TotalWeight int32 //权重1
  2515. TotalWeight1 int32 //权重2
  2516. TotalWeight2 int32 //权重3
  2517. TotalWeight3 int32 //权重4
  2518. TotalWeight4 int32 //权重5
  2519. RefreshTime []int32
  2520. RefreshCost map[int32]*ShopRefreshCost
  2521. RefreshCount int32
  2522. }
  2523. type SpecialShopItem struct {
  2524. ShopItem *serverproto.ShopItem
  2525. Weight int32
  2526. Weight1 int32
  2527. Weight2 int32
  2528. Weight3 int32
  2529. Weight4 int32
  2530. }
  2531. type RedBagShopTime struct {
  2532. ShopItem *serverproto.ShopItem
  2533. ItemList map[int32]int32
  2534. }
  2535. var ConvertShopItemData = map[int32]*serverproto.ShopItem{}
  2536. var ConvertRoleShopData = map[int32]*SpecialShop{}
  2537. var ConvertRedBagShopItemData = map[int32]*RedBagShopTime{}
  2538. type ItemCondition struct {
  2539. Conditions []*serverproto.KeyValueType
  2540. }
  2541. var ConvertShopItemCondition = map[int32]*ItemCondition{}
  2542. func convertShopCfg() {
  2543. //初始化商店类型
  2544. for _, shopData := range serverproto.ShopTypeCfgLoader {
  2545. ConvertRoleShopData[shopData.Id] = &SpecialShop{
  2546. TotalWeight: 0,
  2547. TotalWeight1: 0,
  2548. TotalWeight2: 0,
  2549. TotalWeight3: 0,
  2550. TotalWeight4: 0,
  2551. RefreshCost: make(map[int32]*ShopRefreshCost),
  2552. }
  2553. //刷新时间
  2554. for _, refTime := range shopData.RefreshTime {
  2555. hour, _ := Str2Num(refTime)
  2556. ConvertRoleShopData[shopData.Id].RefreshTime = append(ConvertRoleShopData[shopData.Id].RefreshTime, int32(hour))
  2557. }
  2558. //刷新消耗
  2559. for index, costData := range shopData.PayForRefresh {
  2560. limitRes := strings.Split(costData, ":")
  2561. if len(limitRes) >= 2 {
  2562. itemId, _ := Str2Num(limitRes[0])
  2563. itemNum, _ := Str2Num(limitRes[1])
  2564. _, ok := ConvertRoleShopData[shopData.Id].RefreshCost[int32(index)]
  2565. if !ok {
  2566. refreshCost := &ShopRefreshCost{
  2567. ItemList: make(map[int32]int32),
  2568. }
  2569. refreshCost.ItemList[int32(itemId)] += int32(itemNum)
  2570. ConvertRoleShopData[shopData.Id].RefreshCost[int32(index)] = refreshCost
  2571. } else {
  2572. ConvertRoleShopData[shopData.Id].RefreshCost[int32(index)].ItemList[int32(itemId)] += int32(itemNum)
  2573. }
  2574. }
  2575. }
  2576. ConvertRoleShopData[shopData.Id].RefreshCount = shopData.RefreshNum
  2577. }
  2578. for _, data := range serverproto.ShopCfgLoader {
  2579. convertData := &serverproto.ShopItem{}
  2580. convertData.GoodsId = data.GoodsId
  2581. convertData.Price = data.PayForNum
  2582. convertData.CurPrice = data.DiscountPayForNum
  2583. convertData.Dispercent = data.Proportion
  2584. convertData.Hot = true
  2585. convertData.HdItemId = data.HdDrop
  2586. if data.SellWell == 0 {
  2587. convertData.Hot = false
  2588. }
  2589. var limitType int32 = 0
  2590. limitRes := strings.Split(data.RestrictedType, ":")
  2591. if len(limitRes) >= 2 {
  2592. lType, _ := Str2Num(limitRes[0])
  2593. convertData.LimitType = int32(lType)
  2594. limitType = convertData.LimitType
  2595. if len(limitRes) == 2 {
  2596. lCount, _ := Str2Num(limitRes[1])
  2597. convertData.Count = int32(lCount)
  2598. }
  2599. if len(limitRes) >= 3 {
  2600. lCircle, _ := Str2Num(limitRes[1])
  2601. convertData.Circle = int32(lCircle)
  2602. lCount, _ := Str2Num(limitRes[2])
  2603. convertData.Count = int32(lCount)
  2604. }
  2605. }
  2606. if limitType == 3 {
  2607. loc := util.GetLoc()
  2608. if data.BeginTime != "" {
  2609. sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.BeginTime, loc)
  2610. if err1 != nil {
  2611. util.PanicF("convertShop startTime err:%v", err1)
  2612. }
  2613. convertData.StartTime = int64(sTime.Unix())
  2614. }
  2615. if data.EndTime != "" {
  2616. cTime, err2 := time.ParseInLocation(util.DATE_FORMAT, data.EndTime, loc)
  2617. if err2 != nil {
  2618. util.PanicF("convertShop endTime err:%v", err2)
  2619. }
  2620. convertData.EndTime = int64(cTime.Unix())
  2621. }
  2622. }
  2623. //特殊商店单独处理
  2624. shopType, ok2 := serverproto.ShopTypeCfgLoader[data.GoodsType]
  2625. if ok2 && shopType.ShopType == 2 {
  2626. _, ok4 := ConvertRoleShopData[data.GoodsType]
  2627. if !ok4 {
  2628. //道具没有对应的商店。这策划不靠谱!!!!
  2629. util.PanicF("convertShop shopType not found err:%v", data.GoodsType)
  2630. }
  2631. //计算最新的权重
  2632. ConvertRoleShopData[data.GoodsType].TotalWeight += data.Weight
  2633. ConvertRoleShopData[data.GoodsType].TotalWeight1 += data.Weight1
  2634. ConvertRoleShopData[data.GoodsType].TotalWeight2 += data.Weight2
  2635. ConvertRoleShopData[data.GoodsType].TotalWeight3 += data.Weight3
  2636. ConvertRoleShopData[data.GoodsType].TotalWeight4 += data.Weight4
  2637. shopItem := &SpecialShopItem{}
  2638. shopItem.Weight = ConvertRoleShopData[data.GoodsType].TotalWeight
  2639. shopItem.Weight1 = ConvertRoleShopData[data.GoodsType].TotalWeight1
  2640. shopItem.Weight2 = ConvertRoleShopData[data.GoodsType].TotalWeight2
  2641. shopItem.Weight3 = ConvertRoleShopData[data.GoodsType].TotalWeight3
  2642. shopItem.Weight4 = ConvertRoleShopData[data.GoodsType].TotalWeight4
  2643. shopItem.ShopItem = convertData
  2644. ConvertRoleShopData[data.GoodsType].ItemList = append(ConvertRoleShopData[data.GoodsType].ItemList, shopItem)
  2645. continue
  2646. }
  2647. //
  2648. if data.GoodsType == 50 {
  2649. shopItem := &RedBagShopTime{}
  2650. shopItem.ShopItem = convertData
  2651. shopItem.ItemList = make(map[int32]int32)
  2652. for _, items := range data.Reward {
  2653. limitRes := strings.Split(items, ":")
  2654. if len(limitRes) >= 2 {
  2655. itemId, _ := Str2Num(limitRes[0])
  2656. itemCount, _ := Str2Num(limitRes[1])
  2657. shopItem.ItemList[int32(itemId)] = int32(itemCount)
  2658. }
  2659. }
  2660. ConvertRedBagShopItemData[data.GoodsId] = shopItem
  2661. continue
  2662. }
  2663. ConvertShopItemData[data.GoodsId] = convertData
  2664. if len(data.Condition) > 0 {
  2665. condition := &ItemCondition{}
  2666. for _, cond := range data.Condition {
  2667. condId, condArg := Str2Res(cond)
  2668. if condId != 0 && condArg != 0 {
  2669. condition.Conditions = append(condition.Conditions, &serverproto.KeyValueType{
  2670. Key: int32(condId),
  2671. Value: int32(condArg),
  2672. })
  2673. }
  2674. }
  2675. ConvertShopItemCondition[data.GoodsId] = condition
  2676. }
  2677. }
  2678. }
  2679. //比较refTime 和当前时间是否在同一时间段内
  2680. func CheckShopNeedRefresh(refTime int64) bool {
  2681. if refTime < util.GetTimeSeconds() {
  2682. return true
  2683. }
  2684. return false
  2685. }
  2686. func GetNextShopRefreshHour(shopType int32, curHour int32) int32 {
  2687. shopData, ok := ConvertRoleShopData[shopType]
  2688. if !ok {
  2689. return -1
  2690. }
  2691. for _, data := range shopData.RefreshTime {
  2692. if curHour < data {
  2693. return data
  2694. }
  2695. }
  2696. return shopData.RefreshTime[0]
  2697. }
  2698. func GetShopItemByShopType(shopType int32, vipWeight int32) []int32 {
  2699. shop, ok1 := serverproto.ShopTypeCfgLoader[shopType]
  2700. if !ok1 {
  2701. return nil
  2702. }
  2703. if shop.ShopType != 2 || shop.GoodsRefreshNum <= 0 {
  2704. return nil
  2705. }
  2706. shopData, ok2 := ConvertRoleShopData[shopType]
  2707. if !ok2 {
  2708. return nil
  2709. }
  2710. if int32(len(shopData.ItemList)) < shop.GoodsRefreshNum {
  2711. return nil
  2712. }
  2713. var itemList []int32
  2714. selected := map[int32]int32{}
  2715. totalWeight := shopData.TotalWeight
  2716. if vipWeight == 1 {
  2717. totalWeight = shopData.TotalWeight1
  2718. } else if vipWeight == 2 {
  2719. totalWeight = shopData.TotalWeight2
  2720. } else if vipWeight == 3 {
  2721. totalWeight = shopData.TotalWeight3
  2722. } else if vipWeight == 4 {
  2723. totalWeight = shopData.TotalWeight4
  2724. }
  2725. if totalWeight == 0 {
  2726. return nil
  2727. }
  2728. for i := 0; i < int(shop.GoodsRefreshNum); {
  2729. randWeight := rand.Int31n(totalWeight) //[0,randWeight)
  2730. for _, data := range shopData.ItemList {
  2731. weight := data.Weight
  2732. if vipWeight == 1 {
  2733. weight = data.Weight1
  2734. } else if vipWeight == 2 {
  2735. weight = data.Weight2
  2736. } else if vipWeight == 3 {
  2737. weight = data.Weight3
  2738. } else if vipWeight == 4 {
  2739. weight = data.Weight4
  2740. }
  2741. if weight == 0 { //策划口头补充的需求
  2742. continue
  2743. }
  2744. if randWeight <= weight {
  2745. _, ok3 := selected[data.ShopItem.GoodsId]
  2746. if ok3 { //找到重复的
  2747. break
  2748. }
  2749. itemList = append(itemList, data.ShopItem.GoodsId)
  2750. selected[data.ShopItem.GoodsId] = 1
  2751. i++
  2752. break
  2753. }
  2754. }
  2755. }
  2756. return itemList
  2757. }
  2758. type SignInData struct {
  2759. VipLevel int32
  2760. DaySign []*serverproto.KeyValueType //每日签到奖励
  2761. AccuSign []*serverproto.KeyValueType //累积签到奖励
  2762. }
  2763. var ConvertSignUpData = map[int32]*SignInData{}
  2764. func convertSignInCfg() {
  2765. for _, data := range serverproto.SignInCfgLoader {
  2766. convertData := SignInData{}
  2767. if len(data.SignInReward) > 0 {
  2768. for _, reward := range data.SignInReward {
  2769. key, val := Str2Res(reward)
  2770. if key == 0 || val == 0 {
  2771. continue
  2772. }
  2773. convertData.DaySign = append(convertData.DaySign, &serverproto.KeyValueType{
  2774. Key: int32(key),
  2775. Value: int32(val),
  2776. })
  2777. }
  2778. }
  2779. if len(data.SignInAddReward) > 0 {
  2780. for _, reward := range data.SignInAddReward {
  2781. key, val := Str2Res(reward)
  2782. if key == 0 || val == 0 {
  2783. continue
  2784. }
  2785. convertData.AccuSign = append(convertData.AccuSign, &serverproto.KeyValueType{
  2786. Key: int32(key),
  2787. Value: int32(val),
  2788. })
  2789. }
  2790. }
  2791. convertData.VipLevel = data.VipLevel
  2792. ConvertSignUpData[data.ID] = &convertData
  2793. }
  2794. if len(ConvertSignUpData)%30 != 0 {
  2795. util.PanicF("convertSign total count err:%v", len(ConvertSignUpData))
  2796. }
  2797. }
  2798. var ActiveCodeList = map[string]struct{}{}
  2799. func convertActiveCodeCfg() {
  2800. for _, val := range serverproto.ActiveCodeCfgLoader {
  2801. ActiveCodeList[val.Code] = struct{}{}
  2802. }
  2803. }
  2804. func CheckActiveCode(activeCode string) serverproto.ErrorCode {
  2805. if activeCode == "" {
  2806. return serverproto.ErrorCode_ERROR_ROLE_ACTIVECODE_ERROR
  2807. }
  2808. if len(ActiveCodeList) <= 0 {
  2809. return serverproto.ErrorCode_ERROR_OK
  2810. }
  2811. if _, ok := ActiveCodeList[activeCode]; !ok {
  2812. return serverproto.ErrorCode_ERROR_ROLE_ACTIVECODE_ERROR
  2813. }
  2814. return serverproto.ErrorCode_ERROR_OK
  2815. }
  2816. type LevelItem struct {
  2817. MapId int32
  2818. LevelId int32
  2819. //boss战小怪
  2820. MonsterList []*serverproto.KeyValueType
  2821. BossId int32
  2822. BossPos int32
  2823. RageId uint32
  2824. }
  2825. var ConvertMapItemList = map[int32]*LevelItem{}
  2826. func convertMapCfg() {
  2827. //for _, mapItemData := range serverproto.MapCfgLoader {
  2828. // var levelId int32 = 1
  2829. // mapId := mapItemData.Id
  2830. // for {
  2831. // tmpId := mapId*10000 + levelId
  2832. // data, ok := serverproto.LevelCfgLoader[tmpId]
  2833. // if !ok {
  2834. // break
  2835. // }
  2836. // addLevelItem := &LevelItem{
  2837. // MapId: mapId,
  2838. // LevelId: levelId,
  2839. // }
  2840. //
  2841. // //boss战小怪处理
  2842. // for idx := 0; idx <= len(data.Monsters); idx++ {
  2843. // loc, monsterId := Str2Res(data.Monsters[idx])
  2844. // if loc >= 1 && loc <= 6 && monsterId > 0 {
  2845. // addLevelItem.MonsterList = append(addLevelItem.MonsterList,
  2846. // &serverproto.KeyValueType{
  2847. // Key: loc,
  2848. // Value: monsterId,
  2849. // })
  2850. // }
  2851. // }
  2852. //
  2853. // if data.BossId > 0 {
  2854. // addLevelItem.BossId = data.BossId
  2855. // addLevelItem.BossPos = data.BossPosition
  2856. // addLevelItem.RageId = uint32(data.BossRageBuffId)
  2857. // }
  2858. //
  2859. // ConvertMapItemList[tmpId] = addLevelItem
  2860. // }
  2861. //}
  2862. }
  2863. //NatureCfg.csv
  2864. var ConvertNatureMap = map[int32]map[int32][]*serverproto.KeyValueType{}
  2865. func convertNatureCfg() {
  2866. //for _, data := range serverproto.NatureCfgLoader {
  2867. // if data.AntiNature1 != "" {
  2868. // convertNatureAttr(1, data.AntiNature1)
  2869. // }
  2870. // if data.AntiNature2 != "" {
  2871. // convertNatureAttr(2, data.AntiNature2)
  2872. // }
  2873. // if data.AntiNature3 != "" {
  2874. // convertNatureAttr(3, data.AntiNature3)
  2875. // }
  2876. // if data.AntiNature4 != "" {
  2877. // convertNatureAttr(4, data.AntiNature4)
  2878. // }
  2879. // if data.AntiNature5 != "" {
  2880. // convertNatureAttr(5, data.AntiNature5)
  2881. // }
  2882. // if data.AntiNature6 != "" {
  2883. // convertNatureAttr(6, data.AntiNature6)
  2884. // }
  2885. // if data.AntiNature7 != "" {
  2886. // convertNatureAttr(7, data.AntiNature7)
  2887. // }
  2888. //}
  2889. }
  2890. func convertNatureAttr(natureId int32, attr string) {
  2891. attrList := strings.Split(attr, ";")
  2892. for idx := range attrList {
  2893. key, value := Str2Res(attrList[idx])
  2894. if key > 0 && value > 0 {
  2895. if ConvertNatureMap[natureId] == nil {
  2896. ConvertNatureMap[natureId] = map[int32][]*serverproto.KeyValueType{}
  2897. }
  2898. ConvertNatureMap[natureId][key] = append(ConvertNatureMap[natureId][key], &serverproto.KeyValueType{
  2899. Key: key,
  2900. Value: value,
  2901. })
  2902. }
  2903. }
  2904. }
  2905. type TowerReward struct {
  2906. ItemList []*serverproto.KeyValueType
  2907. ExItemList []*serverproto.KeyValueType
  2908. FightCheck int32
  2909. SPAdd *serverproto.KeyValueType
  2910. }
  2911. var ConvertTowerData = map[int32]*TowerReward{}
  2912. var ConvertClimbPowerDecayFactorList = map[int32]*ConvertDecayData{}
  2913. var ConvertClimbTimeDecayFactorList = map[int32]*ConvertDecayData{}
  2914. func convertTowerCfg() {
  2915. for _, tower := range serverproto.ClimbingTowerCfgLoader {
  2916. convertReward := &TowerReward{}
  2917. for _, items := range tower.RewardItems {
  2918. key, value := Str2Res(items)
  2919. if key == 0 || value == 0 {
  2920. continue
  2921. }
  2922. convertReward.ItemList = append(convertReward.ItemList, &serverproto.KeyValueType{
  2923. Key: key,
  2924. Value: value,
  2925. })
  2926. }
  2927. for _, special := range tower.SpecialReward {
  2928. key, value := Str2Res(special)
  2929. if key == 0 || value == 0 {
  2930. continue
  2931. }
  2932. convertReward.ExItemList = append(convertReward.ExItemList, &serverproto.KeyValueType{
  2933. Key: key,
  2934. Value: value,
  2935. })
  2936. }
  2937. convertReward.FightCheck = tower.FightCheck
  2938. //power
  2939. parseDecay(tower.Id, tower.PowerWeaken, ConvertClimbPowerDecayFactorList)
  2940. //time
  2941. parseDecay(tower.Id, tower.StayTimeWeaken, ConvertClimbTimeDecayFactorList)
  2942. //sp add
  2943. k, v := Str2Res(tower.SpAddition)
  2944. if k > 0 && v > 0 {
  2945. convertReward.SPAdd = &serverproto.KeyValueType{Key: k, Value: v}
  2946. }
  2947. ConvertTowerData[tower.Id] = convertReward
  2948. }
  2949. }
  2950. type ConvertEvilBossData struct {
  2951. EvilLevel int32
  2952. MaxFightingTime int32
  2953. MonsterList []*serverproto.KeyValueTypeList
  2954. LevelReward map[int32]int32
  2955. LevelTimes int32
  2956. }
  2957. var ConvertEvilBossList = map[int32]*ConvertEvilBossData{}
  2958. func convertEvilCfg() {
  2959. for _, data := range serverproto.EvilCfgLoader {
  2960. convertData := &ConvertEvilBossData{
  2961. EvilLevel: data.Id,
  2962. MaxFightingTime: data.MaxFightingTime,
  2963. LevelReward: map[int32]int32{},
  2964. }
  2965. for idx := 0; idx < len(data.MonsterList); idx++ {
  2966. //id,addexp,cd,quality,weight
  2967. v1, v2, v3, v4, v5 := Str2Res_5(data.MonsterList[idx])
  2968. if v1 > 0 && v2 > 0 && v3 > 0 {
  2969. monsterData := &serverproto.KeyValueTypeList{
  2970. Key: v1,
  2971. }
  2972. monsterData.ValueList = append(monsterData.ValueList, v2, v3, v4, v5)
  2973. convertData.MonsterList = append(convertData.MonsterList, monsterData)
  2974. }
  2975. }
  2976. for idx := 0; idx < len(data.LevelReward); idx++ {
  2977. key, val := Str2Res(data.LevelReward[idx])
  2978. if key > 0 && val > 0 {
  2979. convertData.LevelReward[key] += val
  2980. }
  2981. }
  2982. convertData.LevelTimes = data.LevelTimes
  2983. ConvertEvilBossList[convertData.EvilLevel] = convertData
  2984. }
  2985. }
  2986. /*
  2987. type ConvertVIPData struct {
  2988. VipId int32 //vip等级, 1表示vip0,默认数值
  2989. EvilFreeRefreshCount int32 //恶魔免费刷新次数 数值0表示无限次数刷新
  2990. }
  2991. var ConvertVIPList = map[int32]*ConvertVIPData{}
  2992. var maxVipLevel int32 = 0
  2993. func convertVIPCfg() {
  2994. for _, data := range serverproto.VipCfgLoader {
  2995. vipData := &ConvertVIPData{
  2996. VipId: data.Id,
  2997. EvilFreeRefreshCount: data.FreeTimes,
  2998. }
  2999. ConvertVIPList[vipData.VipId-1] = vipData
  3000. if data.Id > maxVipLevel {
  3001. maxVipLevel = data.Id - 1
  3002. }
  3003. }
  3004. }
  3005. func GetVIPDataByLevel(vipLevel int32) *ConvertVIPData {
  3006. if vipLevel < 0 {
  3007. vipLevel = maxVipLevel
  3008. }
  3009. if vipLevel > maxVipLevel {
  3010. vipLevel = maxVipLevel
  3011. }
  3012. if data, ok := ConvertVIPList[vipLevel]; ok {
  3013. return data
  3014. }
  3015. return nil
  3016. }
  3017. */
  3018. type CardCollectReward struct {
  3019. CardId int32
  3020. CardReward map[int32]*serverproto.KeyValueType
  3021. }
  3022. var ConvertCardCollectReward = map[int32]*CardCollectReward{}
  3023. func convertCardCollectCfg() {
  3024. for _, data := range serverproto.CardIdentificationLoader {
  3025. convertData := &CardCollectReward{
  3026. CardId: data.Cardid,
  3027. CardReward: map[int32]*serverproto.KeyValueType{},
  3028. }
  3029. limitRes := strings.Split(data.CardReward1[0], ":")
  3030. if len(limitRes) >= 2 {
  3031. itemKey, _ := Str2Num(limitRes[0])
  3032. itemValue, _ := Str2Num(limitRes[1])
  3033. convertData.CardReward[1] = &serverproto.KeyValueType{
  3034. Key: int32(itemKey),
  3035. Value: int32(itemValue),
  3036. }
  3037. }
  3038. limitRes = strings.Split(data.CardReward2[0], ":")
  3039. if len(limitRes) >= 2 {
  3040. itemKey, _ := Str2Num(limitRes[0])
  3041. itemValue, _ := Str2Num(limitRes[1])
  3042. convertData.CardReward[2] = &serverproto.KeyValueType{
  3043. Key: int32(itemKey),
  3044. Value: int32(itemValue),
  3045. }
  3046. }
  3047. limitRes = strings.Split(data.CardReward3[0], ":")
  3048. if len(limitRes) >= 2 {
  3049. itemKey, _ := Str2Num(limitRes[0])
  3050. itemValue, _ := Str2Num(limitRes[1])
  3051. convertData.CardReward[3] = &serverproto.KeyValueType{
  3052. Key: int32(itemKey),
  3053. Value: int32(itemValue),
  3054. }
  3055. }
  3056. limitRes = strings.Split(data.CardReward4[0], ":")
  3057. if len(limitRes) >= 2 {
  3058. itemKey, _ := Str2Num(limitRes[0])
  3059. itemValue, _ := Str2Num(limitRes[1])
  3060. convertData.CardReward[4] = &serverproto.KeyValueType{
  3061. Key: int32(itemKey),
  3062. Value: int32(itemValue),
  3063. }
  3064. }
  3065. limitRes = strings.Split(data.CardReward5[0], ":")
  3066. if len(limitRes) >= 2 {
  3067. itemKey, _ := Str2Num(limitRes[0])
  3068. itemValue, _ := Str2Num(limitRes[1])
  3069. convertData.CardReward[5] = &serverproto.KeyValueType{
  3070. Key: int32(itemKey),
  3071. Value: int32(itemValue),
  3072. }
  3073. }
  3074. ConvertCardCollectReward[data.Cardid] = convertData
  3075. }
  3076. }
  3077. var ConvertGuildLevel = map[int32]int32{}
  3078. var ConvertLeaveGuildTime = map[int32]int32{}
  3079. func convertGuildLevelCfg() {
  3080. for _, data := range serverproto.GuildLvCfgLoader {
  3081. ConvertGuildLevel[data.Id] = data.ExpRequire
  3082. }
  3083. cfgData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Guild_Leave_Guild_CD)]
  3084. if !ok {
  3085. util.PanicF("convertSign total count err:%v", len(ConvertSignUpData))
  3086. }
  3087. limitRes := strings.Split(cfgData.SVal, ";")
  3088. for _, res := range limitRes {
  3089. cdData := strings.Split(res, ":")
  3090. if len(cdData) >= 2 {
  3091. cdCount, _ := Str2Num(cdData[0])
  3092. cdTime, _ := Str2Num(cdData[1])
  3093. ConvertLeaveGuildTime[int32(cdCount)] = int32(cdTime)
  3094. }
  3095. }
  3096. }
  3097. //pet
  3098. const (
  3099. Pet_Type_Normal = 1
  3100. Pet_Type_Mini = 2
  3101. Pet_Type_MVP = 3
  3102. )
  3103. type PetProgressData struct {
  3104. PetCfgId int32
  3105. ProgressList []*ConvertPetProgressDataDetail
  3106. }
  3107. type ConvertPetProgressDataDetail struct {
  3108. ProgressLevel int32
  3109. CostZeny int32 //消耗zeny
  3110. AttrList []*serverproto.KeyValueType
  3111. RateList []*serverproto.KeyValueType
  3112. //1品质 2进阶等级 3特殊属性
  3113. ConditionPet1 []*serverproto.KeyValueType //进阶消耗的材料
  3114. ConditionPet2 []*serverproto.KeyValueType //进阶消耗的材料
  3115. }
  3116. type ConvertPetSkillData struct {
  3117. SkillId int32
  3118. RateList []int32 //技能发动概率
  3119. MaxSkillLevel int32
  3120. }
  3121. type ConvertPetData struct {
  3122. PetCfgId int32
  3123. Exp int32 //等级1对应的经验
  3124. ManualRewardList map[int32]*serverproto.KeyValueType //图鉴奖励
  3125. Quality int32 //1normal 2mini 3mvp
  3126. NatureType int32
  3127. SkillList []*ConvertPetSkillData //技能列表
  3128. JobType int32
  3129. }
  3130. func (this *ConvertPetData) GetSkill(skillId int32) *ConvertPetSkillData {
  3131. for idx := 0; idx < len(this.SkillList); idx++ {
  3132. if this.SkillList[idx].SkillId == skillId {
  3133. return this.SkillList[idx]
  3134. }
  3135. }
  3136. return nil
  3137. }
  3138. func (this *ConvertPetData) GetSkillRate(skillId, skillLevel int32) int32 {
  3139. if skillLevel <= 0 {
  3140. return 0
  3141. }
  3142. for idx := 0; idx < len(this.SkillList); idx++ {
  3143. if this.SkillList[idx].SkillId == skillId &&
  3144. this.SkillList[idx].MaxSkillLevel >= skillLevel {
  3145. return this.SkillList[idx].RateList[int(skillLevel-1)]
  3146. }
  3147. }
  3148. return 0
  3149. }
  3150. type ConvertExpData struct {
  3151. PetLevel int32
  3152. NormalExp int32
  3153. NormalAccuExp int32 //累计需要经验
  3154. NormalZeny int32
  3155. NormalAccuZeny int32 //累计消耗zeny
  3156. MiniExp int32
  3157. MiniAccuExp int32
  3158. MiniZeny int32
  3159. MiniAccuZeny int32
  3160. MvpExp int32
  3161. MvpAccuExp int32
  3162. MvpZeny int32
  3163. MvpAccuZeny int32
  3164. }
  3165. type ConvertBondData struct {
  3166. BondId int32
  3167. ConditionList1 []*serverproto.KeyValueType
  3168. ConditionList2 []*serverproto.KeyValueType
  3169. ConditionList3 []*serverproto.KeyValueType
  3170. }
  3171. type PetBondFightData struct {
  3172. FightPower1 []*serverproto.KeyValueType
  3173. FightPower2 []*serverproto.KeyValueType
  3174. FightPower3 []*serverproto.KeyValueType
  3175. Attr1List []*serverproto.KeyValueType
  3176. Attr2List []*serverproto.KeyValueType
  3177. Attr3List []*serverproto.KeyValueType
  3178. }
  3179. type PetProFightPower struct {
  3180. AttrMap map[int32]int32
  3181. }
  3182. type PetPartnerFightPower struct {
  3183. FightPower1 map[int32]int32
  3184. FightPower2 map[int32]int32
  3185. FightPower3 map[int32]int32
  3186. }
  3187. type ConvertPetEquipData struct {
  3188. CfgId int32
  3189. Type int32 //位置编号
  3190. Quality int32 //绿色,蓝色,紫色,金色,红色
  3191. MaxLevel int32
  3192. AdvanceTargetEquip int32
  3193. AdvanceCost map[int32]int32
  3194. SuitId int32
  3195. LevelUpList map[int32]*ConvertPetEquipLevelUpData
  3196. }
  3197. type ConvertPetEquipLevelUpData struct {
  3198. Level int32
  3199. CostList map[int32]int32
  3200. AttrList map[int32]int32
  3201. FightPower uint64
  3202. }
  3203. type ConvertPetEquipSuitData struct {
  3204. Id int32
  3205. ConditionList []*serverproto.KeyValueType
  3206. AttrList map[int32]int32
  3207. }
  3208. var ConvertPet = map[int32]*ConvertPetData{}
  3209. var ConvertPetProgress = map[int32]*PetProgressData{}
  3210. var ConvertPetExp = map[int32]*ConvertExpData{}
  3211. var ConvertBond []*ConvertBondData
  3212. var ConvertBondFight = map[int32]*PetBondFightData{}
  3213. var ConvertPetProFight = map[int32]*PetProFightPower{}
  3214. var ConvertPetPartnerFight = map[int32]*PetPartnerFightPower{}
  3215. var ConvertPetEquip = map[int32]*ConvertPetEquipData{} //[equipcfgid][data]
  3216. var ConvertPteEquipSuit []*ConvertPetEquipSuitData
  3217. func getFieldData(fieldName string, data interface{}) []string {
  3218. tmpDataType := reflect.ValueOf(data).Elem()
  3219. tmpVal := tmpDataType.FieldByName(fieldName).Interface()
  3220. switch val := tmpVal.(type) {
  3221. case []string:
  3222. return val
  3223. default:
  3224. panic(errors.New("field type error"))
  3225. }
  3226. return nil
  3227. }
  3228. func convertPetCfg() {
  3229. //clean for reload
  3230. ConvertBond = []*ConvertBondData{}
  3231. //progress
  3232. for _, data := range serverproto.PetProgressCfgLoader {
  3233. progressData := &PetProgressData{
  3234. PetCfgId: data.Id,
  3235. }
  3236. for idx := 0; idx < len(data.CostMoney); idx++ {
  3237. constZeny, _ := Str2Num(data.CostMoney[idx])
  3238. detailData := &ConvertPetProgressDataDetail{
  3239. ProgressLevel: int32(idx) + 1,
  3240. CostZeny: int32(constZeny),
  3241. }
  3242. //condition
  3243. tmpCondition1Str := "Condition" + strconv.Itoa(idx+1) + "1"
  3244. tmpCondition2Str := "Condition" + strconv.Itoa(idx+1) + "2"
  3245. tmpAttrStr := "Attribute" + strconv.Itoa(idx+1)
  3246. tmpAttributeRateAddStr := "AttributeRateAdd" + strconv.Itoa(idx+1)
  3247. convertPetCfg_ProgressCondition(getFieldData(tmpCondition1Str, data), getFieldData(tmpCondition2Str, data), detailData)
  3248. convertPetCfg_ProgressAttr(getFieldData(tmpAttrStr, data), getFieldData(tmpAttributeRateAddStr, data), detailData)
  3249. ////condition
  3250. //switch idx {
  3251. //case 0:
  3252. // convertPetCfg_ProgressCondition(data.Condition11, data.Condition12, detailData)
  3253. // convertPetCfg_ProgressAttr(data.Attribute1, data.AttributeRateAdd1, detailData)
  3254. //case 1:
  3255. // convertPetCfg_ProgressCondition(data.Condition21, data.Condition22, detailData)
  3256. // convertPetCfg_ProgressAttr(data.Attribute2, data.AttributeRateAdd2, detailData)
  3257. //case 2:
  3258. // convertPetCfg_ProgressCondition(data.Condition31, data.Condition32, detailData)
  3259. // convertPetCfg_ProgressAttr(data.Attribute3, data.AttributeRateAdd3, detailData)
  3260. //case 3:
  3261. // convertPetCfg_ProgressCondition(data.Condition41, data.Condition42, detailData)
  3262. // convertPetCfg_ProgressAttr(data.Attribute4, data.AttributeRateAdd4, detailData)
  3263. //case 4:
  3264. // convertPetCfg_ProgressCondition(data.Condition51, data.Condition52, detailData)
  3265. // convertPetCfg_ProgressAttr(data.Attribute5, data.AttributeRateAdd5, detailData)
  3266. //}
  3267. progressData.ProgressList = append(progressData.ProgressList, detailData)
  3268. ConvertPetProgress[progressData.PetCfgId] = progressData
  3269. progressFight := &PetProFightPower{
  3270. AttrMap: make(map[int32]int32),
  3271. }
  3272. var totalFight int32 = 0
  3273. for idx, fightPower := range data.AddFight {
  3274. val, _ := Str2Num(fightPower)
  3275. totalFight += int32(val)
  3276. progressFight.AttrMap[int32(idx)] = totalFight
  3277. }
  3278. ConvertPetProFight[progressData.PetCfgId] = progressFight
  3279. }
  3280. ConvertPetProgress[progressData.PetCfgId] = progressData
  3281. }
  3282. //petskillup global
  3283. //pet
  3284. for _, data := range serverproto.PetCfgLoader {
  3285. petData := &ConvertPetData{
  3286. PetCfgId: data.Id,
  3287. Quality: data.Quality,
  3288. NatureType: data.NatureType,
  3289. JobType: data.JobType,
  3290. }
  3291. petData.ManualRewardList = map[int32]*serverproto.KeyValueType{}
  3292. for idx := 0; idx < len(data.PetReward); idx++ {
  3293. advLevel, key, val := Str2Res_3(data.PetReward[idx])
  3294. if key > 0 && val > 0 {
  3295. petData.ManualRewardList[advLevel] = &serverproto.KeyValueType{Key: key, Value: val}
  3296. }
  3297. }
  3298. //skill
  3299. convertPetCfg_Skill(data.Skill1, data.Skill1Rate, petData)
  3300. convertPetCfg_Skill(data.Skill2, data.Skill2Rate, petData)
  3301. convertPetCfg_Skill(data.Skill3, data.Skill3Rate, petData)
  3302. convertPetCfg_Skill(data.Skill4, data.Skill4Rate, petData)
  3303. ConvertPet[petData.PetCfgId] = petData
  3304. }
  3305. //pet exp
  3306. var tmpList []*ConvertExpData
  3307. for _, data := range serverproto.PetExpCfgLoader {
  3308. expData := &ConvertExpData{
  3309. PetLevel: data.PetLevel,
  3310. NormalExp: data.Experience1,
  3311. NormalZeny: data.CostMoney1,
  3312. MiniExp: data.Experience2,
  3313. MiniZeny: data.CostMoney2,
  3314. MvpExp: data.Experience3,
  3315. MvpZeny: data.CostMoney3,
  3316. }
  3317. ConvertPetExp[expData.PetLevel] = expData
  3318. tmpList = append(tmpList, expData)
  3319. }
  3320. sort.Slice(tmpList, func(i, j int) bool {
  3321. return tmpList[i].PetLevel < tmpList[j].PetLevel
  3322. })
  3323. for idx := 0; idx < len(tmpList); idx++ {
  3324. tmpLevel := tmpList[idx].PetLevel
  3325. if tmpLevel > 1 {
  3326. tmpLevel := tmpList[idx].PetLevel
  3327. ConvertPetExp[tmpLevel].NormalAccuExp = ConvertPetExp[tmpLevel-1].NormalAccuExp + ConvertPetExp[tmpLevel].NormalExp
  3328. ConvertPetExp[tmpLevel].NormalAccuZeny = ConvertPetExp[tmpLevel-1].NormalAccuZeny + ConvertPetExp[tmpLevel].NormalZeny
  3329. ConvertPetExp[tmpLevel].MiniAccuExp = ConvertPetExp[tmpLevel-1].MiniAccuExp + ConvertPetExp[tmpLevel].MiniExp
  3330. ConvertPetExp[tmpLevel].MiniAccuZeny = ConvertPetExp[tmpLevel-1].MiniAccuZeny + ConvertPetExp[tmpLevel].MiniZeny
  3331. ConvertPetExp[tmpLevel].MvpAccuExp = ConvertPetExp[tmpLevel-1].MvpAccuExp + ConvertPetExp[tmpLevel].MvpExp
  3332. ConvertPetExp[tmpLevel].MvpAccuZeny = ConvertPetExp[tmpLevel-1].MvpAccuZeny + ConvertPetExp[tmpLevel].MvpZeny
  3333. } else {
  3334. ConvertPetExp[tmpLevel].NormalAccuExp = ConvertPetExp[tmpLevel].NormalExp
  3335. ConvertPetExp[tmpLevel].NormalAccuZeny = ConvertPetExp[tmpLevel].NormalZeny
  3336. ConvertPetExp[tmpLevel].MiniAccuExp = ConvertPetExp[tmpLevel].MiniExp
  3337. ConvertPetExp[tmpLevel].MiniAccuZeny = ConvertPetExp[tmpLevel].MiniZeny
  3338. ConvertPetExp[tmpLevel].MvpAccuExp = ConvertPetExp[tmpLevel].MvpExp
  3339. ConvertPetExp[tmpLevel].MvpAccuZeny = ConvertPetExp[tmpLevel].MvpZeny
  3340. }
  3341. }
  3342. //pet partner
  3343. for _, data := range serverproto.PetpartnerCfgLoader {
  3344. bondData := &ConvertBondData{
  3345. BondId: data.Id,
  3346. }
  3347. for idx := 0; idx < len(data.Condition1); idx++ {
  3348. key, val := Str2Res(data.Condition1[idx])
  3349. if key <= 0 {
  3350. continue
  3351. }
  3352. bondData.ConditionList1 = append(bondData.ConditionList1, &serverproto.KeyValueType{
  3353. Key: key, Value: val,
  3354. })
  3355. }
  3356. for idx := 0; idx < len(data.Condition2); idx++ {
  3357. key, val := Str2Res(data.Condition2[idx])
  3358. if key <= 0 {
  3359. continue
  3360. }
  3361. bondData.ConditionList2 = append(bondData.ConditionList2, &serverproto.KeyValueType{
  3362. Key: key, Value: val,
  3363. })
  3364. }
  3365. for idx := 0; idx < len(data.Condition3); idx++ {
  3366. key, val := Str2Res(data.Condition3[idx])
  3367. if key <= 0 {
  3368. continue
  3369. }
  3370. bondData.ConditionList3 = append(bondData.ConditionList3, &serverproto.KeyValueType{
  3371. Key: key, Value: val,
  3372. })
  3373. }
  3374. ConvertBond = append(ConvertBond, bondData)
  3375. //战斗力相关 key= {0,1,2,3,4,5}
  3376. bondFightData := &PetBondFightData{}
  3377. for idx := 0; idx < len(data.AddHeroCap1); idx++ {
  3378. key, val := Str2Res(data.AddHeroCap1[idx])
  3379. if key < 0 {
  3380. continue
  3381. }
  3382. bondFightData.FightPower1 = append(bondFightData.FightPower1, &serverproto.KeyValueType{
  3383. Key: key, Value: val,
  3384. })
  3385. }
  3386. for idx := 0; idx < len(data.AddHeroCap2); idx++ {
  3387. key, val := Str2Res(data.AddHeroCap1[idx])
  3388. if key < 0 {
  3389. continue
  3390. }
  3391. bondFightData.FightPower2 = append(bondFightData.FightPower2, &serverproto.KeyValueType{
  3392. Key: key, Value: val,
  3393. })
  3394. }
  3395. for idx := 0; idx < len(data.AddHeroCap3); idx++ {
  3396. key, val := Str2Res(data.AddHeroCap1[idx])
  3397. if key < 0 {
  3398. continue
  3399. }
  3400. bondFightData.FightPower3 = append(bondFightData.FightPower3, &serverproto.KeyValueType{
  3401. Key: key, Value: val,
  3402. })
  3403. }
  3404. //attr
  3405. for idx := 0; idx < len(data.Attribute1); idx++ {
  3406. k, v := Str2Res(data.Attribute1[idx])
  3407. if k <= 0 || v <= 0 {
  3408. continue
  3409. }
  3410. bondFightData.Attr1List = append(bondFightData.Attr1List, &serverproto.KeyValueType{Key: k, Value: v})
  3411. }
  3412. for idx := 0; idx < len(data.Attribute2); idx++ {
  3413. k, v := Str2Res(data.Attribute2[idx])
  3414. if k <= 0 || v <= 0 {
  3415. continue
  3416. }
  3417. bondFightData.Attr2List = append(bondFightData.Attr2List, &serverproto.KeyValueType{Key: k, Value: v})
  3418. }
  3419. for idx := 0; idx < len(data.Attribute3); idx++ {
  3420. k, v := Str2Res(data.Attribute3[idx])
  3421. if k <= 0 || v <= 0 {
  3422. continue
  3423. }
  3424. bondFightData.Attr3List = append(bondFightData.Attr3List, &serverproto.KeyValueType{Key: k, Value: v})
  3425. }
  3426. ConvertBondFight[data.Id] = bondFightData
  3427. }
  3428. sort.Slice(ConvertBond, func(i, j int) bool {
  3429. return ConvertBond[i].BondId < ConvertBond[j].BondId
  3430. })
  3431. //pet equip
  3432. //ConvertPetEquip
  3433. for _, data := range serverproto.PetEquipCfgLoader {
  3434. convertData := &ConvertPetEquipData{
  3435. CfgId: data.Id,
  3436. Quality: data.Quality,
  3437. Type: data.Type,
  3438. MaxLevel: data.MaxLevel,
  3439. AdvanceTargetEquip: data.Advance,
  3440. AdvanceCost: map[int32]int32{},
  3441. LevelUpList: map[int32]*ConvertPetEquipLevelUpData{},
  3442. }
  3443. Str2ResMapList(data.AdvanceCost, convertData.AdvanceCost)
  3444. ConvertPetEquip[convertData.CfgId] = convertData
  3445. }
  3446. for _, data := range serverproto.PetEquipExpCfgLoader {
  3447. convertData, ok := ConvertPetEquip[data.PetEquipID]
  3448. if !ok {
  3449. continue
  3450. }
  3451. levelData := &ConvertPetEquipLevelUpData{
  3452. Level: data.PetEquipLevel,
  3453. CostList: map[int32]int32{},
  3454. AttrList: map[int32]int32{},
  3455. FightPower: uint64(data.FightPower),
  3456. }
  3457. Str2ResMapList(data.Cost, levelData.CostList)
  3458. Str2ResMapList(data.Nature, levelData.AttrList)
  3459. convertData.LevelUpList[data.PetEquipLevel] = levelData
  3460. }
  3461. for _, data := range serverproto.PetEquipSuitCfgLoader {
  3462. convertData := &ConvertPetEquipSuitData{
  3463. Id: data.Id,
  3464. AttrList: map[int32]int32{},
  3465. }
  3466. Str2ResMapList(data.Suit, convertData.AttrList)
  3467. convertData.ConditionList = append(convertData.ConditionList, Str2ResSliceList(data.Amount)...)
  3468. ConvertPteEquipSuit = append(ConvertPteEquipSuit, convertData)
  3469. }
  3470. sort.Slice(ConvertPteEquipSuit, func(i, j int) bool {
  3471. return ConvertPteEquipSuit[i].Id > ConvertPteEquipSuit[j].Id
  3472. })
  3473. }
  3474. func convertPetCfg_ProgressCondition(conditionList1 []string, conditionList2 []string, detailData *ConvertPetProgressDataDetail) {
  3475. for idx := 0; idx < len(conditionList1); idx++ {
  3476. kvList := &serverproto.KeyValueType{}
  3477. v1, v2 := Str2Res(conditionList1[idx])
  3478. if v1 > 0 {
  3479. kvList.Key = v1
  3480. kvList.Value = v2
  3481. }
  3482. detailData.ConditionPet1 = append(detailData.ConditionPet1, kvList)
  3483. }
  3484. for idx := 0; idx < len(conditionList2); idx++ {
  3485. kvList := &serverproto.KeyValueType{}
  3486. v1, v2 := Str2Res(conditionList2[idx])
  3487. if v1 > 0 {
  3488. kvList.Key = v1
  3489. kvList.Value = v2
  3490. }
  3491. detailData.ConditionPet2 = append(detailData.ConditionPet2, kvList)
  3492. }
  3493. }
  3494. func convertPetCfg_ProgressAttr(attrList []string, rateList []string, detailData *ConvertPetProgressDataDetail) {
  3495. for idx := 0; idx < len(attrList); idx++ {
  3496. key, val := Str2Res(attrList[idx])
  3497. if key > 0 && val > 0 {
  3498. detailData.AttrList = append(detailData.AttrList, &serverproto.KeyValueType{
  3499. Key: key, Value: val,
  3500. })
  3501. }
  3502. }
  3503. for idx := 0; idx < len(rateList); idx++ {
  3504. key, val := Str2Res(rateList[idx])
  3505. if key > 0 && val > 0 {
  3506. detailData.RateList = append(detailData.RateList, &serverproto.KeyValueType{
  3507. Key: key, Value: val,
  3508. })
  3509. }
  3510. }
  3511. }
  3512. func convertPetCfg_Skill(skillId int32, skillRateList []string, petData *ConvertPetData) {
  3513. if skillId > 0 {
  3514. skill1 := &ConvertPetSkillData{
  3515. SkillId: skillId,
  3516. }
  3517. for idx := 0; idx < len(skillRateList); idx++ {
  3518. val, _ := Str2Num(skillRateList[idx])
  3519. skill1.RateList = append(skill1.RateList, int32(val))
  3520. }
  3521. skill1.MaxSkillLevel = int32(len(skill1.RateList))
  3522. petData.SkillList = append(petData.SkillList, skill1)
  3523. }
  3524. }
  3525. type GuildBossReward struct {
  3526. RewardList map[int32]int32
  3527. }
  3528. type RankReward struct {
  3529. MaxDam int32
  3530. MinDam int32
  3531. RewardID int32
  3532. MasterReward int32
  3533. }
  3534. type GuildBossRank struct {
  3535. Reward []*RankReward
  3536. MaxDamage int32
  3537. }
  3538. var ConvertGuildBossReward = map[int32]*GuildBossReward{}
  3539. var ConvertGuildBossRewardRank = map[int32]*GuildBossRank{}
  3540. func convertGuildBosRewardsCfg() {
  3541. for _, reward := range serverproto.GuildBossRewardCfgLoader {
  3542. convertReward := &GuildBossReward{
  3543. RewardList: map[int32]int32{},
  3544. }
  3545. for _, data := range reward.Reward {
  3546. strList := strings.Split(data, ":")
  3547. if len(strList) >= 2 {
  3548. itemKey, _ := Str2Num(strList[0])
  3549. itemValue, _ := Str2Num(strList[1])
  3550. convertReward.RewardList[int32(itemKey)] = int32(itemValue)
  3551. }
  3552. }
  3553. ConvertGuildBossReward[reward.Id] = convertReward
  3554. }
  3555. for _, guildBoss := range serverproto.GuildBossCfgLoader {
  3556. convertGuildBossRank := &GuildBossRank{}
  3557. if len(guildBoss.RewardRange) != len(guildBoss.Reward) {
  3558. util.PanicF("[convertGuildBosRewardsCfg] reward config error:%v, %v, %v", guildBoss.Id, len(guildBoss.RewardRange), len(guildBoss.Reward))
  3559. }
  3560. if guildBoss.BossType == 1 { //1 普通boss 2 精英boss
  3561. if len(guildBoss.RewardRange) != len(guildBoss.MasterReward) {
  3562. util.PanicF("[convertGuildBosRewardsCfg] MasterReward config error:%v", guildBoss.Id)
  3563. }
  3564. }
  3565. for idx, rank := range guildBoss.RewardRange {
  3566. strList := strings.Split(rank, ":")
  3567. minDam, _ := Str2Num(strList[0])
  3568. maxDam, _ := Str2Num(strList[1])
  3569. if len(strList) >= 2 {
  3570. rankReward := &RankReward{}
  3571. rankReward.MinDam = int32(minDam)
  3572. rankReward.MaxDam = int32(maxDam)
  3573. rewardId, _ := Str2Num(guildBoss.Reward[idx])
  3574. rankReward.RewardID = int32(rewardId)
  3575. if guildBoss.BossType == 1 { //1 普通boss 2 精英boss
  3576. masterId, _ := Str2Num(guildBoss.MasterReward[idx])
  3577. rankReward.MasterReward = int32(masterId)
  3578. }
  3579. convertGuildBossRank.Reward = append(convertGuildBossRank.Reward, rankReward)
  3580. }
  3581. }
  3582. ConvertGuildBossRewardRank[guildBoss.Id] = convertGuildBossRank
  3583. }
  3584. }
  3585. var ConvertGuildBattleList = map[int32]int32{}
  3586. func convertGuildBattleCfg() {
  3587. for _, cfgData := range serverproto.GuildWarDojoCfgLoader {
  3588. ConvertGuildBattleList[cfgData.Id] = cfgData.GuildWarPoint
  3589. }
  3590. }
  3591. type ConvertExpedition struct {
  3592. ExpeditionType int32
  3593. LevelNum int32
  3594. LevelUnlockAddNum int32
  3595. //UnlockCondition []*serverproto.KeyValueType
  3596. LevelInfo map[int32]*ConvertExpeditionDetailInfo
  3597. LevelCoefficient float32
  3598. PassRewardList []*serverproto.KeyValueType //通关奖励(每日获取一次)
  3599. }
  3600. func (this *ConvertExpedition) GetLevelReward(levelIdx int32, addItemList map[int32]int32) {
  3601. levelData, ok := this.LevelInfo[levelIdx]
  3602. if !ok {
  3603. return
  3604. }
  3605. for idx := 0; idx < len(levelData.RewardList); idx++ {
  3606. addItemList[levelData.RewardList[idx].Key] += levelData.RewardList[idx].Value
  3607. }
  3608. }
  3609. type ConvertExpeditionBossInfo struct {
  3610. Weight int32
  3611. BossId int32
  3612. BossLevel int32
  3613. BossHP int32
  3614. BossSP int32
  3615. }
  3616. type ConvertExpeditionDetailInfo struct {
  3617. Id int32
  3618. LevelId int32
  3619. BossList []*ConvertExpeditionBossInfo
  3620. BuffList []*serverproto.KeyValueType //key:id val:weight
  3621. RewardList []*serverproto.KeyValueType
  3622. MaxFightingTime int32
  3623. WarriorScore int32 //勇士积分
  3624. }
  3625. func (this *ConvertExpeditionDetailInfo) RandBoss(tmpBossIdxList []int) (*ConvertExpeditionBossInfo, int) {
  3626. var totalWeight int32 = 0
  3627. var tmpList []*serverproto.KeyValueType
  3628. for idx := 0; idx < len(this.BossList); idx++ {
  3629. bFind := false
  3630. for k := 0; k < len(tmpBossIdxList); k++ {
  3631. if idx == tmpBossIdxList[k] {
  3632. bFind = true
  3633. break
  3634. }
  3635. }
  3636. if bFind {
  3637. continue
  3638. }
  3639. totalWeight += this.BossList[idx].Weight
  3640. tmpList = append(tmpList, &serverproto.KeyValueType{Key: int32(idx), Value: totalWeight})
  3641. }
  3642. if totalWeight <= 0 {
  3643. return nil, 0
  3644. }
  3645. var retBossIdx = 0
  3646. randWeight := rand.Int31n(totalWeight) + 1
  3647. for idx := 0; idx < len(tmpList); idx++ {
  3648. retBossIdx = int(tmpList[idx].Key)
  3649. if tmpList[idx].Value >= randWeight {
  3650. break
  3651. }
  3652. }
  3653. return this.BossList[retBossIdx], retBossIdx
  3654. }
  3655. func (this *ConvertExpeditionDetailInfo) RandBuff(hasBuffList set.Interface, tmpBuffList []int32, bossId uint64) int32 {
  3656. var retBuffId int32 = 0
  3657. var totalWeight int32 = 0
  3658. var tmpList []*serverproto.KeyValueType
  3659. bossBuffList, ok := ConvertExpeditionDropBuffList[bossId]
  3660. if !ok {
  3661. util.InfoF("Expedition bossid=%v randBuffList empty", bossId)
  3662. return retBuffId
  3663. }
  3664. if len(bossBuffList.BuffList) <= 0 {
  3665. util.InfoF("Expedition bossid=%v randBuffList empty", bossId)
  3666. return retBuffId
  3667. }
  3668. for idx := 0; idx < len(bossBuffList.BuffList); idx++ {
  3669. if hasBuffList.Has(bossBuffList.BuffList[idx].Key) {
  3670. continue
  3671. }
  3672. bFind := false
  3673. for k := 0; k < len(tmpBuffList); k++ {
  3674. if tmpBuffList[k] == bossBuffList.BuffList[idx].Key {
  3675. bFind = true
  3676. break
  3677. }
  3678. }
  3679. if bFind {
  3680. continue
  3681. }
  3682. totalWeight += bossBuffList.BuffList[idx].Value
  3683. tmpList = append(tmpList, &serverproto.KeyValueType{Key: bossBuffList.BuffList[idx].Key, Value: totalWeight})
  3684. }
  3685. if totalWeight <= 0 {
  3686. return 0
  3687. }
  3688. randWeight := rand.Int31n(totalWeight) + 1
  3689. for idx := 0; idx < len(tmpList); idx++ {
  3690. retBuffId = tmpList[idx].Key
  3691. if tmpList[idx].Value >= randWeight {
  3692. break
  3693. }
  3694. }
  3695. return retBuffId
  3696. }
  3697. type ConvertExpeditionBuffInfo struct {
  3698. Id uint64
  3699. BossId int32
  3700. LevelId int32 //关卡唯一ID
  3701. BuffList []*serverproto.KeyValueType //key:id val:weight
  3702. WarriorScore int32 //勇士积分
  3703. }
  3704. var ConvertExpeditionDataList = map[int32]*ConvertExpedition{}
  3705. var ConvertExpeditionDropBuffList = map[uint64]*ConvertExpeditionBuffInfo{}
  3706. func convertExpeditionCfg() {
  3707. //ExpeditionCfg
  3708. for _, cfgData := range serverproto.ExpeditionCfgLoader {
  3709. convertData, ok := ConvertExpeditionDataList[cfgData.Type]
  3710. if !ok {
  3711. convertData = &ConvertExpedition{
  3712. ExpeditionType: cfgData.Type,
  3713. LevelNum: cfgData.LevelNum,
  3714. LevelInfo: map[int32]*ConvertExpeditionDetailInfo{},
  3715. }
  3716. ConvertExpeditionDataList[cfgData.Type] = convertData
  3717. }
  3718. if cfgData.Type > 0 {
  3719. convertData.ExpeditionType = cfgData.Type
  3720. }
  3721. if cfgData.LevelNum > 0 {
  3722. convertData.LevelNum = cfgData.LevelNum
  3723. }
  3724. if cfgData.ChallengeNum > 0 {
  3725. convertData.LevelUnlockAddNum = cfgData.ChallengeNum
  3726. }
  3727. if cfgData.LevelCoefficient > 0 {
  3728. convertData.LevelCoefficient = float32(cfgData.LevelCoefficient) / 100
  3729. }
  3730. if len(cfgData.DayReward) > 0 {
  3731. for idx := 0; idx < len(cfgData.DayReward); idx++ {
  3732. key, val := Str2Res(cfgData.DayReward[idx])
  3733. if key <= 0 || val <= 0 {
  3734. continue
  3735. }
  3736. convertData.PassRewardList = append(convertData.PassRewardList,
  3737. &serverproto.KeyValueType{Key: key, Value: val})
  3738. }
  3739. }
  3740. //level info
  3741. levelInfo := &ConvertExpeditionDetailInfo{
  3742. Id: cfgData.Id,
  3743. LevelId: cfgData.LevelId,
  3744. MaxFightingTime: cfgData.MaxFightingTime,
  3745. WarriorScore: cfgData.WarriorScore,
  3746. }
  3747. //level boss list
  3748. var totalWeight int32 = 0
  3749. for idx := 0; idx < len(cfgData.BossList); idx++ {
  3750. weight, bossId, level, hp, sp := Str2Res_5(cfgData.BossList[idx])
  3751. if bossId <= 0 || level <= 0 || hp <= 0 || sp <= 0 {
  3752. continue
  3753. }
  3754. totalWeight = weight
  3755. bossInfo := &ConvertExpeditionBossInfo{
  3756. Weight: totalWeight,
  3757. BossId: bossId,
  3758. BossLevel: level,
  3759. BossHP: hp,
  3760. BossSP: sp,
  3761. }
  3762. levelInfo.BossList = append(levelInfo.BossList, bossInfo)
  3763. }
  3764. //level reward list
  3765. for idx := 0; idx < len(cfgData.Reward); idx++ {
  3766. key, val := Str2Res(cfgData.Reward[idx])
  3767. if key <= 0 || val <= 0 {
  3768. continue
  3769. }
  3770. levelInfo.RewardList = append(levelInfo.RewardList, &serverproto.KeyValueType{Key: key, Value: val})
  3771. }
  3772. convertData.LevelInfo[levelInfo.LevelId] = levelInfo
  3773. }
  3774. //boss drop buff list
  3775. for _, cfgData := range serverproto.ExpeditionBuffDropCfgLoader {
  3776. bossBuffData := &ConvertExpeditionBuffInfo{
  3777. BossId: cfgData.BossID,
  3778. LevelId: cfgData.LevelId,
  3779. WarriorScore: cfgData.WarriorScore,
  3780. }
  3781. bossBuffData.Id = uint64(bossBuffData.BossId)*100000 + uint64(bossBuffData.LevelId)
  3782. for idx := 0; idx < len(cfgData.Buffs); idx++ {
  3783. weight, buffId := Str2Res(cfgData.Buffs[idx])
  3784. if buffId <= 0 {
  3785. continue
  3786. }
  3787. bossBuffData.BuffList = append(bossBuffData.BuffList, &serverproto.KeyValueType{Key: buffId, Value: weight})
  3788. }
  3789. ConvertExpeditionDropBuffList[bossBuffData.Id] = bossBuffData
  3790. }
  3791. //检查boss数据是否存在
  3792. for _, typeData := range ConvertExpeditionDataList {
  3793. for _, levelData := range typeData.LevelInfo {
  3794. for idx := 0; idx < len(levelData.BossList); idx++ {
  3795. //对应level boss是否存在掉落buff数据
  3796. tmpId := uint64(levelData.BossList[idx].BossId)*100000 + uint64(levelData.Id)
  3797. if _, ok := ConvertExpeditionDropBuffList[tmpId]; !ok {
  3798. //panic(errors.New("level boss not exist drop buff data:" + strconv.FormatUint(tmpId, 10)))
  3799. }
  3800. }
  3801. }
  3802. }
  3803. }
  3804. ///精彩活动
  3805. type ConvertActivitiesData struct {
  3806. Id int32
  3807. ActivityType int32
  3808. StartTimeStr string
  3809. EndTimeStr string
  3810. TerminalOpenTimeStr string
  3811. OpenConditionList []*serverproto.KeyValueType
  3812. BG string
  3813. ServiceMark int32 //是否为合服活动
  3814. TimeType int //1绝对时间 2相对开服时间 3相对角色创建时间
  3815. StartTime time.Time
  3816. EndTime time.Time
  3817. StartDay int
  3818. EndDay int
  3819. CalStartTime time.Time
  3820. CalEndTime time.Time
  3821. CalEndTimeMs uint64
  3822. HDItemList set.Interface
  3823. //过期后的活动是否强制开启(之前没有开启过,只针对相对开服时间开启的活动类型)
  3824. ExpiredActivities bool
  3825. //活动开启最后截至时间(填写绝对时间)
  3826. TerminalOpenTime time.Time
  3827. TerminalOpenTimeMs uint64
  3828. }
  3829. type ConvertActivitiesTaskData struct {
  3830. TaskId int32
  3831. ConditionList map[int32][]int32
  3832. RewardList map[int32]int32
  3833. TaskScore int32
  3834. }
  3835. var ConvertActivitiesList = map[int32]*ConvertActivitiesData{}
  3836. var ConvertActivitiesTaskList = map[int32]*ConvertActivitiesTaskData{}
  3837. //14日连续登录活动
  3838. //key=ActivitiesId * 1000 + Day
  3839. var ConvertActivitiesFOList = map[int32]map[int32]int32{}
  3840. //14日阶段目标
  3841. type ConvertActivitiesFortnightDaysData struct {
  3842. Days int32
  3843. TaskList []uint32
  3844. DailyTaskList []uint32
  3845. }
  3846. type ConvertActivitiesFortnightDaysScoreData struct {
  3847. RewardIdx int32
  3848. Score int32
  3849. RewardList map[int32]int32
  3850. }
  3851. var ConvertActivitiesFortnightDaysList = map[int32]*ConvertActivitiesFortnightDaysData{}
  3852. var ConvertActivitiesFortnightDaysScoreList = map[int32][]*ConvertActivitiesFortnightDaysScoreData{}
  3853. //首充/百元礼包
  3854. type ConvertActFirstRechargeData struct {
  3855. OpenConditionList []*serverproto.KeyValueType
  3856. OpenConditionStrList []string
  3857. RechargeAmount float32 //达到该金额解锁首充奖励获取
  3858. Day1Reward []*serverproto.KeyValueType
  3859. Day2Reward []*serverproto.KeyValueType
  3860. Day3Reward []*serverproto.KeyValueType
  3861. }
  3862. var ConvertActFirstRecharge *ConvertActFirstRechargeData = nil
  3863. var ConvertAct100Recharge *ConvertActFirstRechargeData = nil
  3864. type StActTiredRecharge struct {
  3865. Id int32
  3866. Day int32
  3867. Rewards []*serverproto.KeyValueType
  3868. RewardList map[int32]int32
  3869. ConditionList map[int32][]int32
  3870. }
  3871. //累计充值奖励
  3872. var ConvertActTiredRecharge = map[int32]*StActTiredRecharge{}
  3873. func GetActTiredRechargeDb(index, day int32) *StActTiredRecharge {
  3874. dbDay := int32(0)
  3875. for _, recharge := range ConvertActTiredRecharge {
  3876. if day >= recharge.Day {
  3877. if dbDay <= 0 || recharge.Day > dbDay {
  3878. dbDay = recharge.Day
  3879. }
  3880. }
  3881. }
  3882. // 左16位 当天领奖档次, 右16位活动天数
  3883. db := ConvertActTiredRecharge[index<<16|dbDay]
  3884. return db
  3885. }
  3886. //[天数,[数据额列表]]
  3887. var ConvertActTiredRechargeList = map[int32][]*StActTiredRecharge{}
  3888. var ConvertActTiredRechargeByIdList = map[int32]*StActTiredRecharge{}
  3889. //超值礼包
  3890. type ConvertActDiscountsRechargeData struct {
  3891. Id int32
  3892. ProductId int32
  3893. Name string
  3894. OpenCondition *serverproto.KeyValueTypeList
  3895. Amount float32 //购买价格
  3896. RewardList []*serverproto.KeyValueType
  3897. DurationTime uint64 //持续时间
  3898. UnlockCount int32 //触发次数
  3899. Recharge int32 //历史累计充值档位
  3900. }
  3901. var ConvertActDiscountsRecharge = map[int32]*ConvertActDiscountsRechargeData{}
  3902. //[type][id][data]
  3903. var ConvertActDiscountsRechargeList = map[int32][]*ConvertActDiscountsRechargeData{}
  3904. type ConvertActCollectionData struct {
  3905. Id int32
  3906. Name string
  3907. Order int32
  3908. ExchangeConditionList map[int32]int32
  3909. ServerRewardNum int32 //全服奖励数量
  3910. RewardNum int32 //兑换奖励次数上限
  3911. RewardList []*serverproto.KeyValueType
  3912. ActivitiesId int32
  3913. }
  3914. var ConvertActCollection = map[int32]*ConvertActCollectionData{}
  3915. type ConvertActLikabilityItemData struct {
  3916. ActivityId int32
  3917. LikabilityItemId int32 //道具id
  3918. LikabilityList []*serverproto.KeyValueTypeList
  3919. }
  3920. //var ConvertActLikabilityItem = map[int32]*ConvertActLikabilityItemData{}
  3921. //[activityid][level][item...]
  3922. var ConvertActLikabilityItemList = map[int32]map[int32]*ConvertActLikabilityItemData{}
  3923. type ConvertActLikabilityData struct {
  3924. ActivityId int32
  3925. Level int32
  3926. LikeValMax int32
  3927. RewardList []*serverproto.KeyValueTypeList
  3928. }
  3929. //var ConvertActLikability = map[int32]*ConvertActLikabilityData{}
  3930. var ConvertActLikabilityList = map[int32]map[int32]*ConvertActLikabilityData{}
  3931. const (
  3932. Exchange_Type_Special = 1
  3933. Exchange_Type_Common = 2
  3934. )
  3935. const (
  3936. Exchange_Activity_Type_Pet = 0
  3937. Exchange_Activity_Type_Card = 1
  3938. )
  3939. type ExchangePetCondition struct {
  3940. CondType int32
  3941. ConditionId int32
  3942. Id int32
  3943. Level int32
  3944. SkillLevel int32
  3945. Count int32
  3946. }
  3947. type ExchangeCardCondition struct {
  3948. CondType int32
  3949. ConditionId int32
  3950. ItemType int32
  3951. ItemLevel int32
  3952. ItemId int32
  3953. ItemCount int32
  3954. ItemQuality int32
  3955. Scope map[int32]int32
  3956. }
  3957. type ConvertExchangeData struct {
  3958. Id int32
  3959. ActivitiesId int32
  3960. ActivitiesType int32
  3961. ConditionPet []*ExchangePetCondition
  3962. ConditionCard []*ExchangeCardCondition
  3963. Reward []*serverproto.KeyValueType
  3964. RewardNum int32 //兑换次数
  3965. ServerRewardNum int32
  3966. BroadCast int32
  3967. }
  3968. var ConvertExchange = map[int32]*ConvertExchangeData{}
  3969. type ResetIndexs struct {
  3970. Id []int32
  3971. }
  3972. var ConvertExchangeReset = map[int32]*ResetIndexs{}
  3973. const (
  3974. ActivitiesTime_Type_None = 0 //永久活动时间
  3975. ActivitiesTime_Type_Global = 1 //绝对时间
  3976. ActivitiesTime_Type_Server = 2 //相对开服时间 //根据开服时间endday-startday(持续时间)
  3977. ActivitiesTime_Type_Role = 3 //相对角色创建时间 //根据创建角色时间endday-startday + 1(持续时间)
  3978. ActivitiesTime_Type_System = 4 //根据玩家开启系统决定活动开启时间
  3979. )
  3980. func convertActivitiesCfg() {
  3981. //ActivitiesCfg
  3982. for _, cfgData := range serverproto.ActivitiesCfgLoader {
  3983. tmpData := &ConvertActivitiesData{
  3984. Id: cfgData.Id,
  3985. ActivityType: cfgData.Type,
  3986. BG: cfgData.BG,
  3987. HDItemList: set.New(set.NonThreadSafe),
  3988. ServiceMark: cfgData.ServiceMark,
  3989. }
  3990. for idx := 0; idx < len(cfgData.OpenCondition); idx++ {
  3991. key, val := Str2Res(cfgData.OpenCondition[idx])
  3992. if key > 0 {
  3993. tmpData.OpenConditionList = append(tmpData.OpenConditionList, &serverproto.KeyValueType{Key: key, Value: val})
  3994. }
  3995. }
  3996. startDataList := strings.Split(cfgData.StartTime, ";")
  3997. endDataList := strings.Split(cfgData.EndTime, ";")
  3998. if len(startDataList) > 0 {
  3999. tmpData.TimeType, _ = Str2Num(startDataList[0])
  4000. switch tmpData.TimeType {
  4001. case ActivitiesTime_Type_Global: //绝对时间
  4002. loc := util.GetLoc()
  4003. tmpData.StartTime, _ = time.ParseInLocation(util.DATE_FORMAT, startDataList[1], loc)
  4004. tmpData.StartTimeStr = startDataList[1]
  4005. if len(endDataList) > 1 {
  4006. tmpData.EndTime, _ = time.ParseInLocation(util.DATE_FORMAT, endDataList[1], loc)
  4007. tmpData.EndTimeStr = endDataList[1]
  4008. }
  4009. case ActivitiesTime_Type_Server: //相对开服时间
  4010. fallthrough
  4011. case ActivitiesTime_Type_Role: //相对创建角色时间
  4012. tmpData.StartDay, _ = Str2Num(startDataList[1])
  4013. tmpData.StartTimeStr = startDataList[2]
  4014. loc := util.GetLoc()
  4015. tmpData.StartTime, _ = time.ParseInLocation(util.DATE_FORMAT2, startDataList[2], loc)
  4016. if len(startDataList) >= 4 {
  4017. tmpData.TerminalOpenTimeStr = startDataList[3]
  4018. tmpData.TerminalOpenTime = util.GetTimeByStr(tmpData.TerminalOpenTimeStr)
  4019. tmpData.TerminalOpenTimeMs = uint64(tmpData.TerminalOpenTime.UnixNano() / 1e6)
  4020. }
  4021. if len(endDataList) > 2 {
  4022. tmpData.EndDay, _ = Str2Num(endDataList[1])
  4023. tmpData.EndTimeStr = endDataList[2]
  4024. if tmpData.EndDay < tmpData.StartDay {
  4025. continue
  4026. }
  4027. tmpData.EndTime, _ = time.ParseInLocation(util.DATE_FORMAT2, endDataList[2], loc)
  4028. }
  4029. case ActivitiesTime_Type_System: //根据玩家开启系统决定活动开启时间
  4030. }
  4031. } else {
  4032. //永久活动时间
  4033. tmpData.TimeType = 0
  4034. }
  4035. //过期后的活动是否强制开启(之前没有开启过,只针对相对开服时间开启的活动类型)
  4036. if cfgData.ExpiredActivities > 0 && tmpData.TimeType == ActivitiesTime_Type_Server {
  4037. tmpData.ExpiredActivities = true
  4038. }
  4039. //是否有活动道具
  4040. for idx := 0; idx < len(cfgData.HdDrop); idx++ {
  4041. hdItemId, _ := Str2Num(cfgData.HdDrop[idx])
  4042. if hdItemId > 0 {
  4043. tmpData.HDItemList.Add(int32(hdItemId))
  4044. }
  4045. }
  4046. ConvertActivitiesList[tmpData.Id] = tmpData
  4047. }
  4048. //ActivityTaskCfg
  4049. for _, cfgData := range serverproto.ActivitiesTaskCfgLoader {
  4050. tmpData := &ConvertActivitiesTaskData{
  4051. TaskId: cfgData.TaskId,
  4052. TaskScore: cfgData.Integral,
  4053. RewardList: map[int32]int32{},
  4054. ConditionList: map[int32][]int32{},
  4055. }
  4056. for idx := 0; idx < len(cfgData.TaskCondition); idx++ {
  4057. valueList := strings.Split(cfgData.TaskCondition[idx], ":")
  4058. if len(valueList) >= 2 {
  4059. taskType, _ := Str2Num(valueList[0])
  4060. tmpData.ConditionList[int32(taskType)] = append(tmpData.ConditionList[int32(taskType)], int32(taskType))
  4061. for i := 1; i < len(valueList); i++ {
  4062. taskValue, _ := Str2Num(valueList[i])
  4063. tmpData.ConditionList[int32(taskType)] = append(tmpData.ConditionList[int32(taskType)], int32(taskValue))
  4064. }
  4065. }
  4066. }
  4067. for idx := 0; idx < len(cfgData.Reward); idx++ {
  4068. key, val := Str2Res(cfgData.Reward[idx])
  4069. if key > 0 && val > 0 {
  4070. tmpData.RewardList[key] += val
  4071. }
  4072. }
  4073. ConvertActivitiesTaskList[tmpData.TaskId] = tmpData
  4074. }
  4075. //ActivitiesFortnightOnlineCfg
  4076. for _, cfgData := range serverproto.ActivitiesFortnightOnlineCfgLoader {
  4077. tempId := cfgData.ActivitiesId*1000 + cfgData.Day
  4078. ConvertActivitiesFOList[tempId] = map[int32]int32{}
  4079. for idx := 0; idx < len(cfgData.Rewards); idx++ {
  4080. key, val := Str2Res(cfgData.Rewards[idx])
  4081. if key > 0 && val > 0 {
  4082. ConvertActivitiesFOList[tempId][key] += val
  4083. }
  4084. }
  4085. }
  4086. //ActivitiesFortnightDaysCfg
  4087. duplicateSet := set.New(set.NonThreadSafe)
  4088. for _, cfgData := range serverproto.ActivitiesFortnightDaysCfgLoader {
  4089. tmpData := &ConvertActivitiesFortnightDaysData{
  4090. Days: cfgData.Id,
  4091. }
  4092. for idx := 0; idx < len(cfgData.TaskIds); idx++ {
  4093. taskId, _ := Str2Num(cfgData.TaskIds[idx])
  4094. if duplicateSet.Has(taskId) {
  4095. panic("task id repeated")
  4096. }
  4097. duplicateSet.Add(taskId)
  4098. tmpData.TaskList = append(tmpData.TaskList, uint32(taskId))
  4099. }
  4100. for idx := 0; idx < len(cfgData.DailyTaskIds); idx++ {
  4101. taskId, _ := Str2Num(cfgData.DailyTaskIds[idx])
  4102. if duplicateSet.Has(taskId) {
  4103. panic("task id repeated")
  4104. }
  4105. duplicateSet.Add(taskId)
  4106. tmpData.DailyTaskList = append(tmpData.DailyTaskList, uint32(taskId))
  4107. }
  4108. ConvertActivitiesFortnightDaysList[tmpData.Days] = tmpData
  4109. }
  4110. //ActivitiesRewardCfg
  4111. //task score reward
  4112. for _, cfgData := range serverproto.ActivitiesRewardCfgLoader {
  4113. scoreData := &ConvertActivitiesFortnightDaysScoreData{
  4114. RewardIdx: cfgData.Id,
  4115. Score: cfgData.Integral,
  4116. RewardList: map[int32]int32{},
  4117. }
  4118. for idx := 0; idx < len(cfgData.Rewards); idx++ {
  4119. key, val := Str2Res(cfgData.Rewards[idx])
  4120. if key > 0 && val > 0 {
  4121. scoreData.RewardList[key] += val
  4122. }
  4123. }
  4124. //Type 1第一周 2第二周
  4125. ConvertActivitiesFortnightDaysScoreList[cfgData.Type] = append(ConvertActivitiesFortnightDaysScoreList[cfgData.Type], scoreData)
  4126. }
  4127. //ActiviesFirstChargeCfg
  4128. for _, cfgData := range serverproto.ActivitiesFirstChargeCfgLoader {
  4129. tmpData := &ConvertActFirstRechargeData{
  4130. RechargeAmount: float32(cfgData.RechargeAmount),
  4131. }
  4132. tmpData.OpenConditionStrList = cfgData.OpenCondition
  4133. for idx := 0; idx < len(cfgData.OpenCondition); idx++ {
  4134. k, v := Str2Res(cfgData.OpenCondition[idx])
  4135. if k > 0 && v > 0 {
  4136. tmpData.OpenConditionList = append(tmpData.OpenConditionList, &serverproto.KeyValueType{Key: k, Value: v})
  4137. }
  4138. }
  4139. for idx := 0; idx < len(cfgData.Reward1); idx++ {
  4140. k, v := Str2Res(cfgData.Reward1[idx])
  4141. if k > 0 && v > 0 {
  4142. tmpData.Day1Reward = append(tmpData.Day1Reward, &serverproto.KeyValueType{Key: k, Value: v})
  4143. }
  4144. }
  4145. for idx := 0; idx < len(cfgData.Reward2); idx++ {
  4146. k, v := Str2Res(cfgData.Reward2[idx])
  4147. if k > 0 && v > 0 {
  4148. tmpData.Day2Reward = append(tmpData.Day2Reward, &serverproto.KeyValueType{Key: k, Value: v})
  4149. }
  4150. }
  4151. for idx := 0; idx < len(cfgData.Reward3); idx++ {
  4152. k, v := Str2Res(cfgData.Reward3[idx])
  4153. if k > 0 && v > 0 {
  4154. tmpData.Day3Reward = append(tmpData.Day3Reward, &serverproto.KeyValueType{Key: k, Value: v})
  4155. }
  4156. }
  4157. //first recharge
  4158. if cfgData.Id == 1 {
  4159. ConvertActFirstRecharge = tmpData
  4160. } else if cfgData.Id == 2 {
  4161. //百元大礼包
  4162. ConvertAct100Recharge = tmpData
  4163. }
  4164. }
  4165. //ActiviesDiscountsCfg //超值礼包
  4166. for _, cfgData := range serverproto.ActivitiesDiscountsCfgLoader {
  4167. tmpData := &ConvertActDiscountsRechargeData{
  4168. Id: cfgData.Id,
  4169. Amount: float32(cfgData.Money),
  4170. DurationTime: uint64(cfgData.Time) * 1000,
  4171. Name: cfgData.Name,
  4172. UnlockCount: cfgData.Popup,
  4173. Recharge: cfgData.Recharge,
  4174. ProductId: cfgData.ProductID,
  4175. }
  4176. for idx := 0; idx < len(cfgData.Reward); idx++ {
  4177. k, v := Str2Res(cfgData.Reward[idx])
  4178. if k <= 0 || v <= 0 {
  4179. continue
  4180. }
  4181. tmpData.RewardList = append(tmpData.RewardList, &serverproto.KeyValueType{Key: k, Value: v})
  4182. }
  4183. for idx := 0; idx < len(cfgData.TriggeringCondition); idx++ {
  4184. valList := strings.Split(cfgData.TriggeringCondition[idx], ":")
  4185. key, _ := Str2Num(valList[0])
  4186. tmpData.OpenCondition = &serverproto.KeyValueTypeList{Key: int32(key)}
  4187. for k := 1; k < len(valList); k++ {
  4188. val, _ := Str2Num(valList[k])
  4189. tmpData.OpenCondition.ValueList = append(tmpData.OpenCondition.ValueList, int32(val))
  4190. }
  4191. break
  4192. }
  4193. ConvertActDiscountsRecharge[cfgData.Id] = tmpData
  4194. //分类优化性能
  4195. ConvertActDiscountsRechargeList[tmpData.OpenCondition.Key] = append(
  4196. ConvertActDiscountsRechargeList[tmpData.OpenCondition.Key], tmpData)
  4197. }
  4198. for key, _ := range ConvertActDiscountsRechargeList {
  4199. sort.Slice(ConvertActDiscountsRechargeList[key], func(i, j int) bool {
  4200. return ConvertActDiscountsRechargeList[key][i].OpenCondition.ValueList[0] < ConvertActDiscountsRechargeList[key][j].OpenCondition.ValueList[0]
  4201. })
  4202. }
  4203. //ActivitiesCollectionCfg 集字活动
  4204. //var ConvertActCollection = map[int32]*ConvertActCollectionData{}
  4205. for _, cfgData := range serverproto.ActivitiesCollectionCfgLoader {
  4206. tmpData := &ConvertActCollectionData{
  4207. Id: cfgData.Id,
  4208. ExchangeConditionList: map[int32]int32{},
  4209. ServerRewardNum: cfgData.ServersReward,
  4210. RewardNum: cfgData.Number,
  4211. ActivitiesId: cfgData.ActivitiesId,
  4212. }
  4213. for idx := 0; idx < len(cfgData.ExchangeCondition); idx++ {
  4214. k, v := Str2Res(cfgData.ExchangeCondition[idx])
  4215. if k <= 0 || v <= 0 {
  4216. continue
  4217. }
  4218. tmpData.ExchangeConditionList[k] += v
  4219. }
  4220. for idx := 0; idx < len(cfgData.Reward); idx++ {
  4221. k, v := Str2Res(cfgData.Reward[idx])
  4222. if k <= 0 || v <= 0 {
  4223. continue
  4224. }
  4225. tmpData.RewardList = append(tmpData.RewardList,
  4226. &serverproto.KeyValueType{Key: k, Value: v})
  4227. }
  4228. ConvertActCollection[tmpData.Id] = tmpData
  4229. }
  4230. //ActivitieslikabilityCfg ActivitiesGiftCfg 好感度活动
  4231. for _, cfgData := range serverproto.ActivitiesGiftCfgLoader {
  4232. tmpData := &ConvertActLikabilityItemData{
  4233. ActivityId: cfgData.Activityid,
  4234. LikabilityItemId: cfgData.Classitemid,
  4235. }
  4236. for idx := 0; idx < len(cfgData.Classcostaddlike); idx++ {
  4237. v1, v2, v3 := Str2Res_3(cfgData.Classcostaddlike[idx])
  4238. if v1 <= 0 {
  4239. continue
  4240. }
  4241. tmpData.LikabilityList = append(tmpData.LikabilityList,
  4242. &serverproto.KeyValueTypeList{Key: cfgData.Classitemid, ValueList: []int32{v1, v2, v3}})
  4243. }
  4244. if _, ok := ConvertActLikabilityItemList[cfgData.Activityid]; !ok {
  4245. ConvertActLikabilityItemList[cfgData.Activityid] = map[int32]*ConvertActLikabilityItemData{}
  4246. }
  4247. ConvertActLikabilityItemList[cfgData.Activityid][cfgData.Classitemid] = tmpData
  4248. //ConvertActLikabilityItem[cfgData.Classitemid] = tmpData
  4249. }
  4250. for _, cfgData := range serverproto.ActivitieslikabilityCfgLoader {
  4251. tmpData := &ConvertActLikabilityData{
  4252. ActivityId: cfgData.Activityid,
  4253. Level: cfgData.Likelevel,
  4254. LikeValMax: cfgData.LikeMax,
  4255. }
  4256. for idx := 0; idx < len(cfgData.Conditionrewards); idx++ {
  4257. k, v1, v2 := Str2Res_3(cfgData.Conditionrewards[idx])
  4258. if k <= 0 {
  4259. continue
  4260. }
  4261. tmpData.RewardList = append(tmpData.RewardList, &serverproto.KeyValueTypeList{
  4262. Key: k,
  4263. ValueList: []int32{v1, v2},
  4264. })
  4265. }
  4266. if _, ok := ConvertActLikabilityList[cfgData.Activityid]; !ok {
  4267. ConvertActLikabilityList[cfgData.Activityid] = map[int32]*ConvertActLikabilityData{}
  4268. }
  4269. ConvertActLikabilityList[cfgData.Activityid][cfgData.Likelevel] = tmpData
  4270. }
  4271. for _, cfgData := range serverproto.ActivitiesPetExchangeCfgLoader {
  4272. tmpData := &ConvertExchangeData{
  4273. Id: cfgData.Id,
  4274. ActivitiesId: cfgData.ActivitiesId,
  4275. RewardNum: cfgData.Number,
  4276. ServerRewardNum: cfgData.ServersReward,
  4277. ActivitiesType: cfgData.Type,
  4278. BroadCast: cfgData.Broadcast,
  4279. }
  4280. if cfgData.ResetDay != 0 {
  4281. ResetData, resetOk := ConvertExchangeReset[cfgData.ActivitiesId]
  4282. if resetOk {
  4283. ResetData.Id = append(ResetData.Id, cfgData.Id)
  4284. } else {
  4285. convertResetData := &ResetIndexs{}
  4286. convertResetData.Id = append(convertResetData.Id, cfgData.Id)
  4287. ConvertExchangeReset[cfgData.ActivitiesId] = convertResetData
  4288. }
  4289. }
  4290. if cfgData.Type == int32(Exchange_Activity_Type_Pet) {
  4291. for _, condition := range cfgData.ExchangeCondition1 {
  4292. strList := strings.Split(condition, ":")
  4293. if len(strList) >= 5 {
  4294. condId, _ := Str2Num(strList[0])
  4295. id, _ := Str2Num(strList[1])
  4296. level, _ := Str2Num(strList[2])
  4297. skillLevel, _ := Str2Num(strList[3])
  4298. count, _ := Str2Num(strList[4])
  4299. cond := &ExchangePetCondition{
  4300. CondType: Exchange_Type_Special,
  4301. ConditionId: int32(condId),
  4302. Id: int32(id),
  4303. Level: int32(level),
  4304. SkillLevel: int32(skillLevel),
  4305. Count: int32(count),
  4306. }
  4307. tmpData.ConditionPet = append(tmpData.ConditionPet, cond)
  4308. }
  4309. }
  4310. for _, condition := range cfgData.ExchangeCondition2 {
  4311. strList := strings.Split(condition, ":")
  4312. if len(strList) >= 5 {
  4313. condId, _ := Str2Num(strList[0])
  4314. id, _ := Str2Num(strList[1])
  4315. level, _ := Str2Num(strList[2])
  4316. skillLevel, _ := Str2Num(strList[3])
  4317. count, _ := Str2Num(strList[4])
  4318. cond := &ExchangePetCondition{
  4319. CondType: Exchange_Type_Common,
  4320. ConditionId: int32(condId),
  4321. Id: int32(id),
  4322. Level: int32(level),
  4323. SkillLevel: int32(skillLevel),
  4324. Count: int32(count),
  4325. }
  4326. tmpData.ConditionPet = append(tmpData.ConditionPet, cond)
  4327. }
  4328. }
  4329. } else if cfgData.Type == int32(Exchange_Activity_Type_Card) {
  4330. for _, condition := range cfgData.ExchangeCondition1 {
  4331. strList := strings.Split(condition, ":")
  4332. if len(strList) >= 4 {
  4333. condId, _ := Str2Num(strList[0])
  4334. itemType, _ := Str2Num(strList[1])
  4335. itemId, _ := Str2Num(strList[2])
  4336. itemNum, _ := Str2Num(strList[3])
  4337. cond := &ExchangeCardCondition{
  4338. CondType: Exchange_Type_Special,
  4339. ConditionId: int32(condId),
  4340. ItemType: int32(itemType),
  4341. ItemId: int32(itemId),
  4342. ItemCount: int32(itemNum),
  4343. }
  4344. tmpData.ConditionCard = append(tmpData.ConditionCard, cond)
  4345. }
  4346. }
  4347. if len(cfgData.Scope) == len(cfgData.ExchangeCondition2) {
  4348. for i := 0; i < len(cfgData.ExchangeCondition2); i++ {
  4349. strList := strings.Split(cfgData.ExchangeCondition2[i], ":")
  4350. if len(strList) >= 4 {
  4351. condId, _ := Str2Num(strList[0])
  4352. itemType, _ := Str2Num(strList[1])
  4353. itemLevel, _ := Str2Num(strList[2])
  4354. itemCount, _ := Str2Num(strList[3])
  4355. itemQuality, _ := Str2Num(strList[4])
  4356. cond := &ExchangeCardCondition{
  4357. CondType: Exchange_Type_Common,
  4358. ConditionId: int32(condId),
  4359. ItemType: int32(itemType),
  4360. ItemLevel: int32(itemLevel),
  4361. ItemCount: int32(itemCount),
  4362. ItemQuality: int32(itemQuality),
  4363. }
  4364. cond.Scope = map[int32]int32{}
  4365. scopeList := strings.Split(cfgData.Scope[i], ":")
  4366. for _, data := range scopeList {
  4367. cardCfgId, _ := Str2Num(data)
  4368. cond.Scope[int32(cardCfgId)] = 1
  4369. }
  4370. tmpData.ConditionCard = append(tmpData.ConditionCard, cond)
  4371. }
  4372. }
  4373. } else {
  4374. }
  4375. }
  4376. for _, reward := range cfgData.Reward {
  4377. strList := strings.Split(reward, ":")
  4378. if len(strList) >= 2 {
  4379. petCfgId, _ := Str2Num(strList[0])
  4380. petCount, _ := Str2Num(strList[1])
  4381. tmpData.Reward = append(tmpData.Reward, &serverproto.KeyValueType{
  4382. Key: int32(petCfgId),
  4383. Value: int32(petCount),
  4384. })
  4385. }
  4386. }
  4387. ConvertExchange[cfgData.Id] = tmpData
  4388. }
  4389. }
  4390. type HeadFrameAttr struct {
  4391. AttrList map[int32]int32
  4392. }
  4393. var ConvertHeadFrameAttr = map[int32]*HeadFrameAttr{}
  4394. func convertHeadFrameCfg() {
  4395. for _, data := range serverproto.HeadFrameCfgLoader {
  4396. convert := &HeadFrameAttr{
  4397. AttrList: make(map[int32]int32),
  4398. }
  4399. for _, attr := range data.HeadFrameQuality {
  4400. strList := strings.Split(attr, ":")
  4401. if len(strList) >= 2 {
  4402. attrId, _ := Str2Num(strList[0])
  4403. attrValue, _ := Str2Num(strList[1])
  4404. convert.AttrList[int32(attrId)] += int32(attrValue)
  4405. }
  4406. }
  4407. ConvertHeadFrameAttr[data.HeadFrameId] = convert
  4408. }
  4409. }
  4410. //invitation
  4411. type ConvertInvitationTask struct {
  4412. TaskId uint32
  4413. RewardList map[int32]int32
  4414. ConditionList map[int32][]int32
  4415. CompleteNum int32
  4416. }
  4417. var ConvertInvitationTaskList = map[uint32]*ConvertInvitationTask{}
  4418. var ConvertInvitationTaskTypeList = map[int32][]*ConvertInvitationTask{}
  4419. func convertInvitationCfg() {
  4420. for _, cfgData := range serverproto.InvitationTaskCfgLoader {
  4421. tmpData := &ConvertInvitationTask{
  4422. TaskId: uint32(cfgData.TaskId),
  4423. CompleteNum: cfgData.CompleteNum,
  4424. RewardList: map[int32]int32{},
  4425. ConditionList: map[int32][]int32{},
  4426. }
  4427. for idx := 0; idx < len(cfgData.TaskCondition); idx++ {
  4428. valueList := strings.Split(cfgData.TaskCondition[idx], ":")
  4429. if len(valueList) >= 2 {
  4430. taskType, _ := Str2Num(valueList[0])
  4431. tmpData.ConditionList[int32(taskType)] = append(tmpData.ConditionList[int32(taskType)], int32(taskType))
  4432. for i := 1; i < len(valueList); i++ {
  4433. taskValue, _ := Str2Num(valueList[i])
  4434. tmpData.ConditionList[int32(taskType)] = append(tmpData.ConditionList[int32(taskType)], int32(taskValue))
  4435. }
  4436. }
  4437. }
  4438. for idx := 0; idx < len(cfgData.Reward); idx++ {
  4439. key, val := Str2Res(cfgData.Reward[idx])
  4440. if key > 0 && val > 0 {
  4441. tmpData.RewardList[key] += val
  4442. }
  4443. }
  4444. for key := range tmpData.ConditionList {
  4445. ConvertInvitationTaskTypeList[key] = append(ConvertInvitationTaskTypeList[key], tmpData)
  4446. }
  4447. ConvertInvitationTaskList[tmpData.TaskId] = tmpData
  4448. }
  4449. }
  4450. type VipData struct {
  4451. VipRight map[int32]int32
  4452. VipReward map[int32]int32
  4453. VipLevel int32
  4454. }
  4455. var ConvertVipRight = map[int32]*VipData{}
  4456. // 特权卡商店
  4457. type PrivilegeData struct {
  4458. Id int32
  4459. Price float32
  4460. GoodsName string
  4461. VipRight map[int32]int32
  4462. VipReward map[int32]int32
  4463. ConditionList []*serverproto.KeyValueType //到达对应地图条件
  4464. AttrList map[int32]int32 //增加的属性
  4465. }
  4466. var ConvertSpecialPrivilegeRight []*PrivilegeData
  4467. const (
  4468. Vip_System_Levelup = 1 //vip升级需要经验
  4469. Vip_System_Evil = 2 //vip恶魔协会免费刷新次数(0开始恶魔协会刷新金色条目)
  4470. Vip_System_Online = 3 //vip上线提示
  4471. Vip_System_PetAdvance = 4 //宠物进阶消耗
  4472. Vip_System_CardReset = 5 //卡片重置
  4473. Vip_System_PetDesolve = 6 //宠物分解
  4474. Vip_System_SkillReset = 7 //技能重置
  4475. Vip_System_GuildHunt = 8 //公会狩猎次数
  4476. Vip_System_CardInsert = 9 //一键插卡
  4477. Vip_System_ShopWeight = 10 //商店权重
  4478. Vip_System_WorldBoss = 11 //世界boss
  4479. Vip_System_Arena = 12 //英灵殿
  4480. Vip_System_QuickBattle = 13 //快速战斗次数
  4481. Vip_System_HungSilver = 14 //挂机银币
  4482. Vip_System_HungExp = 15 //挂机经验
  4483. Vip_System_HungPartnerExp = 16 //挂机伙伴经验
  4484. Vip_System_HungSkillExp = 17 //技能经验
  4485. Vip_System_HungExtraTime = 18 //挂机额外时长
  4486. Vip_System_SignReward = 19 //签到翻倍
  4487. Vip_System_WorldBoss_Count = 20 //世界boss次数
  4488. Vip_System_FastBattleTime = 21 // 解锁战斗加速功能
  4489. Vip_System_CreditRecharge = 22 // 充值钱包额度(添加的数值)
  4490. Vip_System_QuickBattleBaseExp = 23 // 时光助力主角经验提升万分比 AddLeadExp
  4491. Vip_System_DevilsUp = 24 // 挂机魔魂值加成
  4492. Vip_System_TransportRobbery = 25 // 飞艇被抢劫掉落减少至
  4493. Vip_System_LuxuryPrizeWheelTimes = 26 // 豪华转盘可使用次数
  4494. )
  4495. func convertVipCfg() {
  4496. for _, data := range serverproto.VipCfgLoader {
  4497. convertVip := &VipData{
  4498. VipRight: make(map[int32]int32),
  4499. VipReward: make(map[int32]int32),
  4500. }
  4501. convertVip.VipRight[Vip_System_Levelup] = data.VipExp
  4502. convertVip.VipRight[Vip_System_Evil] = data.EvilFreeTimes
  4503. convertVip.VipRight[Vip_System_Online] = data.VipLogin
  4504. convertVip.VipRight[Vip_System_PetAdvance] = data.PetAdvance
  4505. convertVip.VipRight[Vip_System_CardReset] = data.CardReset
  4506. convertVip.VipRight[Vip_System_PetDesolve] = data.PetBreak
  4507. convertVip.VipRight[Vip_System_SkillReset] = data.SkillReset
  4508. convertVip.VipRight[Vip_System_GuildHunt] = data.GuildBossChallenge
  4509. convertVip.VipRight[Vip_System_CardInsert] = data.CardInsertion
  4510. convertVip.VipRight[Vip_System_ShopWeight] = data.ShopWeight
  4511. convertVip.VipRight[Vip_System_WorldBoss] = data.WorldBoss
  4512. convertVip.VipRight[Vip_System_Arena] = data.PvpReward
  4513. convertVip.VipRight[Vip_System_QuickBattle] = data.HangupTimes
  4514. convertVip.VipRight[Vip_System_HungSilver] = data.SilverUp
  4515. convertVip.VipRight[Vip_System_HungExp] = data.BaseExpUp
  4516. convertVip.VipRight[Vip_System_HungPartnerExp] = data.PartnerExpUp
  4517. convertVip.VipRight[Vip_System_HungSkillExp] = data.SkillExpUp
  4518. convertVip.VipRight[Vip_System_HungExtraTime] = data.HangupDuration
  4519. convertVip.VipRight[Vip_System_SignReward] = data.SignInRewardUp
  4520. convertVip.VipRight[Vip_System_WorldBoss_Count] = data.WorldBossCount
  4521. for _, data := range data.Reward {
  4522. strList := strings.Split(data, ":")
  4523. if len(strList) >= 2 {
  4524. key, _ := Str2Num(strList[0])
  4525. value, _ := Str2Num(strList[1])
  4526. convertVip.VipReward[int32(key)] += int32(value)
  4527. }
  4528. }
  4529. ConvertVipRight[data.Lv] = convertVip
  4530. }
  4531. // bt服务器版本配置文件
  4532. convertSpecialPrivilegeCfg()
  4533. convertPassCheckCfg()
  4534. convertBtBoliCfg() // 波利商城
  4535. convertBTRoCoinRechargeCfg() // RO币累计活动
  4536. convertBTFirstAnd100RechargeCfg() // 超值首充 & 百元大礼包
  4537. }
  4538. //特权卡
  4539. func convertSpecialPrivilegeCfg() {
  4540. for _, data := range serverproto.PrivilegeCardCfgLoader {
  4541. tmpData := &PrivilegeData{
  4542. Id: data.Lv,
  4543. Price: data.RMB,
  4544. VipReward: map[int32]int32{},
  4545. VipRight: map[int32]int32{},
  4546. }
  4547. tmpData.VipRight[Vip_System_FastBattleTime] = data.QuickBattle
  4548. tmpData.VipRight[Vip_System_CreditRecharge] = data.PurseQuota
  4549. //可购买的解锁条件
  4550. for idx := range data.UnlockCond {
  4551. valueList := strings.Split(data.UnlockCond[idx], ":")
  4552. if len(valueList) >= 2 {
  4553. taskType, _ := Str2Num(valueList[0])
  4554. taskValue, _ := Str2Num(valueList[1])
  4555. tmpData.ConditionList = append(tmpData.ConditionList, &serverproto.KeyValueType{
  4556. Key: int32(taskType),
  4557. Value: int32(taskValue),
  4558. })
  4559. }
  4560. }
  4561. Str2ResMapList(data.Reward, tmpData.VipReward)
  4562. ConvertSpecialPrivilegeRight = append(ConvertSpecialPrivilegeRight, tmpData)
  4563. }
  4564. sort.Slice(ConvertSpecialPrivilegeRight, func(i, j int) bool {
  4565. return ConvertSpecialPrivilegeRight[i].Id < ConvertSpecialPrivilegeRight[j].Id
  4566. })
  4567. }
  4568. //RO通行证
  4569. var ConvertPassCheckData *PrivilegeData
  4570. func convertPassCheckCfg() {
  4571. ConvertPassCheckData = &PrivilegeData{
  4572. VipRight: make(map[int32]int32),
  4573. AttrList: make(map[int32]int32),
  4574. }
  4575. for _, cfgData := range serverproto.PassCheckCfgLoader {
  4576. ConvertPassCheckData.Id = cfgData.Lv
  4577. ConvertPassCheckData.Price = cfgData.RMB
  4578. ConvertPassCheckData.VipRight[Vip_System_QuickBattleBaseExp] = cfgData.AddLeadExp
  4579. //添加的属性
  4580. Str2ResMapList(cfgData.AddAttrLevel, ConvertPassCheckData.AttrList)
  4581. //目前只配置了一行数据
  4582. break
  4583. }
  4584. }
  4585. type SummonCost struct {
  4586. ItemId int32
  4587. ItemNum int32
  4588. SourceId int32
  4589. SourceNum int32
  4590. DrawCount map[int32]int32
  4591. ActivitiesId int32 //是否属于活动召唤数据
  4592. SummonType int32 //召唤类型 1卡片 2宠物 3神器
  4593. Total int32
  4594. //根据开服时间获取不同掉落配置
  4595. ServerDataList []*SummonCostByServerTime
  4596. BigRewardShowList []int32 //大奖预览字段
  4597. }
  4598. //相对开服时间天数
  4599. func (this *SummonCost) GetDataByDiffDay(diffDay int32) *SummonCostByServerTime {
  4600. for idx := 0; idx < len(this.ServerDataList); idx++ {
  4601. if diffDay <= this.ServerDataList[idx].ServerTime {
  4602. return this.ServerDataList[idx]
  4603. }
  4604. }
  4605. if len(this.ServerDataList) > 0 {
  4606. return this.ServerDataList[len(this.ServerDataList)-1]
  4607. }
  4608. return nil
  4609. }
  4610. type SummonCostByServerTime struct {
  4611. Id int32
  4612. ServerTime int32 //相对开服时间天数
  4613. SummonType int32 //召唤类型
  4614. SummonGroup int32 //召唤组
  4615. DropId int32
  4616. DropId2 int32
  4617. ExtDropId int32
  4618. }
  4619. type DrawTemplate struct {
  4620. ConfigId int32
  4621. WeightItem int32
  4622. WeightGold int32
  4623. ExtraPoint int32
  4624. DrawItem []*serverproto.KeyValueType
  4625. }
  4626. type DrawPool struct {
  4627. TotalWeightItem int32
  4628. TotalWeightGold int32
  4629. DrawTemplate []*DrawTemplate
  4630. }
  4631. var ConvertSummonList = map[int32]*SummonCost{}
  4632. var ConvertDrawTemplate = map[int32]*DrawPool{}
  4633. const (
  4634. Draw_ResType_Item = 1
  4635. Draw_ResType_Gold = 2
  4636. )
  4637. func convertSummonCfg() {
  4638. for _, data := range serverproto.SummonServerCfgLoader {
  4639. convertData := &SummonCost{
  4640. DrawCount: make(map[int32]int32),
  4641. ActivitiesId: data.ActivitiesId,
  4642. SummonType: data.Type,
  4643. Total: data.Total,
  4644. }
  4645. if len(data.Cost) >= 1 {
  4646. itemId, itemCount := Str2Res(data.Cost[0])
  4647. convertData.ItemId = itemId
  4648. convertData.ItemNum = itemCount
  4649. }
  4650. if len(data.Cost) >= 2 {
  4651. sourceId, sourceCount := Str2Res(data.Cost[1])
  4652. convertData.SourceId = sourceId
  4653. convertData.SourceNum = sourceCount
  4654. }
  4655. for _, count := range data.Method {
  4656. drawCount, _ := Str2Num(count)
  4657. convertData.DrawCount[int32(drawCount)] = 1
  4658. }
  4659. serverData := &SummonCostByServerTime{
  4660. Id: data.Id,
  4661. ServerTime: data.StartDay,
  4662. SummonType: data.Type,
  4663. SummonGroup: data.SummoType,
  4664. DropId: data.DropId,
  4665. DropId2: data.DropId2,
  4666. ExtDropId: data.ExtDropId,
  4667. }
  4668. //召唤组 只针对系统召唤(不包括活动)
  4669. if data.SummoType > 0 {
  4670. if summonData, ok := ConvertSummonList[data.SummoType]; ok {
  4671. summonData.ServerDataList = append(summonData.ServerDataList, serverData)
  4672. } else {
  4673. convertData.ServerDataList = append(convertData.ServerDataList, serverData)
  4674. ConvertSummonList[data.SummoType] = convertData
  4675. }
  4676. //无须读取导致之前没有赋值
  4677. if data.Total > 0 && len(data.Cost) > 0 {
  4678. ConvertSummonList[data.SummoType].Total = convertData.Total
  4679. ConvertSummonList[data.SummoType].SummonType = convertData.SummonType
  4680. ConvertSummonList[data.SummoType].ActivitiesId = convertData.ActivitiesId
  4681. ConvertSummonList[data.SummoType].DrawCount = convertData.DrawCount
  4682. ConvertSummonList[data.SummoType].ItemId = convertData.ItemId
  4683. ConvertSummonList[data.SummoType].ItemNum = convertData.ItemNum
  4684. ConvertSummonList[data.SummoType].SourceId = convertData.SourceId
  4685. ConvertSummonList[data.SummoType].SourceNum = convertData.SourceNum
  4686. }
  4687. } else {
  4688. convertData.ServerDataList = append(convertData.ServerDataList, serverData)
  4689. ConvertSummonList[data.Id] = convertData
  4690. }
  4691. }
  4692. // bt 砸蛋活动
  4693. convertSummonForBTCfg()
  4694. for _, v := range ConvertSummonList {
  4695. sort.Slice(v.ServerDataList, func(i, j int) bool {
  4696. return v.ServerDataList[i].ServerTime < v.ServerDataList[j].ServerTime
  4697. })
  4698. }
  4699. for _, data := range serverproto.SummonTemplateCfgLoader {
  4700. drawPool, ok := ConvertDrawTemplate[data.CardType]
  4701. if !ok {
  4702. drawPool = &DrawPool{
  4703. TotalWeightItem: 0,
  4704. TotalWeightGold: 0,
  4705. }
  4706. ConvertDrawTemplate[data.CardType] = drawPool
  4707. }
  4708. if drawPool == nil {
  4709. // panic()
  4710. return
  4711. }
  4712. drawPool.TotalWeightItem = drawPool.TotalWeightItem + data.Probability1
  4713. drawPool.TotalWeightGold = drawPool.TotalWeightGold + data.Probability2
  4714. //
  4715. drawTemplate := &DrawTemplate{
  4716. ConfigId: data.Id,
  4717. WeightItem: drawPool.TotalWeightItem,
  4718. WeightGold: drawPool.TotalWeightGold,
  4719. ExtraPoint: data.SecurityNum,
  4720. }
  4721. if len(data.BlueNum) >= 1 {
  4722. strList := strings.Split(data.BlueNum[0], ":")
  4723. if len(strList) >= 2 {
  4724. key, _ := Str2Num(strList[0])
  4725. value, _ := Str2Num(strList[1])
  4726. drawTemplate.DrawItem = append(drawTemplate.DrawItem, &serverproto.KeyValueType{
  4727. Key: int32(key),
  4728. Value: int32(value),
  4729. })
  4730. }
  4731. }
  4732. if len(data.PurpleNum) >= 1 {
  4733. strList := strings.Split(data.PurpleNum[0], ":")
  4734. if len(strList) >= 2 {
  4735. key, _ := Str2Num(strList[0])
  4736. value, _ := Str2Num(strList[1])
  4737. drawTemplate.DrawItem = append(drawTemplate.DrawItem, &serverproto.KeyValueType{
  4738. Key: int32(key),
  4739. Value: int32(value),
  4740. })
  4741. }
  4742. }
  4743. if len(data.GoldNum) >= 1 {
  4744. strList := strings.Split(data.GoldNum[0], ":")
  4745. if len(strList) >= 2 {
  4746. key, _ := Str2Num(strList[0])
  4747. value, _ := Str2Num(strList[1])
  4748. drawTemplate.DrawItem = append(drawTemplate.DrawItem, &serverproto.KeyValueType{
  4749. Key: int32(key),
  4750. Value: int32(value),
  4751. })
  4752. }
  4753. }
  4754. drawPool.DrawTemplate = append(drawPool.DrawTemplate, drawTemplate)
  4755. }
  4756. }
  4757. func convertSummonForBTCfg() {
  4758. for _, data := range serverproto.BTSmashEggsCfgLoader {
  4759. convertData := &SummonCost{
  4760. DrawCount: make(map[int32]int32),
  4761. ActivitiesId: data.ActivitiesId,
  4762. SummonType: data.Type,
  4763. Total: data.Total,
  4764. }
  4765. if len(data.Cost) >= 1 {
  4766. itemId, itemCount := Str2Res(data.Cost[0])
  4767. convertData.ItemId = itemId
  4768. convertData.ItemNum = itemCount
  4769. }
  4770. if len(data.Cost) >= 2 {
  4771. sourceId, sourceCount := Str2Res(data.Cost[1])
  4772. convertData.SourceId = sourceId
  4773. convertData.SourceNum = sourceCount
  4774. }
  4775. for _, count := range data.Method {
  4776. drawCount, _ := Str2Num(count)
  4777. convertData.DrawCount[int32(drawCount)] = 1
  4778. }
  4779. //大奖预览字段
  4780. for idx := 0; idx < len(data.Show); idx++ {
  4781. showItemId, _ := Str2Num(data.Show[idx])
  4782. if showItemId > 0 {
  4783. convertData.BigRewardShowList = append(convertData.BigRewardShowList, int32(showItemId))
  4784. }
  4785. }
  4786. serverData := &SummonCostByServerTime{
  4787. Id: data.Id,
  4788. ServerTime: data.StartDay,
  4789. SummonType: data.Type,
  4790. SummonGroup: data.SummoType,
  4791. DropId: data.DropId,
  4792. DropId2: data.DropId2,
  4793. ExtDropId: data.ExtDropId,
  4794. }
  4795. convertData.ServerDataList = append(convertData.ServerDataList, serverData)
  4796. ConvertSummonList[data.Id] = convertData
  4797. }
  4798. }
  4799. func GetDrawProbItem(drawType int32, resType int32) *DrawTemplate {
  4800. drawPool, ok := ConvertDrawTemplate[drawType]
  4801. if !ok {
  4802. return nil
  4803. }
  4804. var totalWeight int32 = 0
  4805. if resType == Draw_ResType_Item {
  4806. totalWeight = drawPool.TotalWeightItem
  4807. } else if resType == Draw_ResType_Gold {
  4808. totalWeight = drawPool.TotalWeightGold
  4809. }
  4810. randWeight := rand.Int31n(totalWeight)
  4811. for _, data := range drawPool.DrawTemplate {
  4812. target := data.WeightItem
  4813. if resType == Draw_ResType_Gold {
  4814. target = data.WeightGold
  4815. }
  4816. if target >= randWeight {
  4817. return data
  4818. }
  4819. }
  4820. return nil
  4821. }
  4822. type GiftBag struct {
  4823. GoodsId int32
  4824. BagType int32
  4825. Price float32
  4826. Name string
  4827. BuyReward []*serverproto.KeyValueType
  4828. FirstReward []*serverproto.KeyValueType
  4829. ExtraReward []*serverproto.KeyValueType
  4830. LimitCount int32
  4831. RmbTotalPay int32
  4832. }
  4833. type LimitBag struct {
  4834. GoodsId int32
  4835. Price float32
  4836. BeginTime int64
  4837. EndTime int64
  4838. LimitCount int32
  4839. Name string
  4840. StartDay int32
  4841. EndDay int32
  4842. LimitType int32
  4843. SeasonId int32
  4844. BuyReward []*serverproto.KeyValueType
  4845. ActivityId int32
  4846. }
  4847. type MonthCard struct {
  4848. GoodsId int32
  4849. Price float32
  4850. Duration int32
  4851. Name string
  4852. MailCfgId int32
  4853. BuyReward []*serverproto.KeyValueType
  4854. MailReward []*serverproto.KeyValueType
  4855. }
  4856. //冲榜商店
  4857. type RushShop struct {
  4858. GoodsId int32
  4859. Activity int32
  4860. Price float32
  4861. Name string
  4862. LimitCount int32
  4863. WorthRate int32
  4864. BuyReward []*serverproto.KeyValueType
  4865. Score int32
  4866. Ticket int32
  4867. }
  4868. var ConvertFreeBag = map[int32]*GiftBag{}
  4869. var ConvertGiftBag = map[int32]*GiftBag{}
  4870. var ConvertLimitGag = map[int32]*LimitBag{}
  4871. var ConvertMonthCard = map[int32]*MonthCard{}
  4872. var ConvertGuildBattle = map[int32]*RushShop{}
  4873. //卢恩冲榜商店
  4874. var ConvertTowerShop = map[int32]*RushShop{}
  4875. var ConvertArenaShop = map[int32]*RushShop{}
  4876. var ConvertMapShop = map[int32]*RushShop{}
  4877. var ConvertPetShop = map[int32]*RushShop{}
  4878. var ConvertSkillShop = map[int32]*RushShop{}
  4879. var ConvertIdolShop = map[int32]*RushShop{}
  4880. // 充值钱包商店
  4881. var ConvertPurseShop = map[int32]*GiftBag{}
  4882. func ConvertOldRedisRuneCfg() {
  4883. convertRuneCfg()
  4884. }
  4885. func convertRuneCfg() {
  4886. for _, data := range serverproto.RuneShopGiftsCfgLoader {
  4887. convertGift := &GiftBag{
  4888. GoodsId: data.Id,
  4889. BagType: data.Type,
  4890. Price: data.RMB,
  4891. Name: data.Name,
  4892. LimitCount: data.RestrictedType,
  4893. RmbTotalPay: data.RmbTotalPay,
  4894. }
  4895. for _, reward := range data.Reward {
  4896. strList := strings.Split(reward, ":")
  4897. if len(strList) >= 2 {
  4898. key, _ := Str2Num(strList[0])
  4899. value, _ := Str2Num(strList[1])
  4900. convertGift.BuyReward = append(convertGift.BuyReward, &serverproto.KeyValueType{
  4901. Key: int32(key),
  4902. Value: int32(value),
  4903. })
  4904. }
  4905. }
  4906. for _, first := range data.FirstBuyReward {
  4907. strList := strings.Split(first, ":")
  4908. if len(strList) >= 2 {
  4909. key, _ := Str2Num(strList[0])
  4910. value, _ := Str2Num(strList[1])
  4911. convertGift.FirstReward = append(convertGift.FirstReward, &serverproto.KeyValueType{
  4912. Key: int32(key),
  4913. Value: int32(value),
  4914. })
  4915. }
  4916. }
  4917. for _, extra := range data.ExtraBuyReward {
  4918. strList := strings.Split(extra, ":")
  4919. if len(strList) >= 2 {
  4920. key, _ := Str2Num(strList[0])
  4921. value, _ := Str2Num(strList[1])
  4922. convertGift.ExtraReward = append(convertGift.ExtraReward, &serverproto.KeyValueType{
  4923. Key: int32(key),
  4924. Value: int32(value),
  4925. })
  4926. }
  4927. }
  4928. ConvertGiftBag[data.Id] = convertGift
  4929. if data.RMB == 0 {
  4930. ConvertFreeBag[data.Id] = convertGift
  4931. }
  4932. }
  4933. for _, data := range serverproto.RuneShopLimitCfgLoader {
  4934. convertLimitBag := &LimitBag{
  4935. GoodsId: data.Id,
  4936. Price: data.RMB,
  4937. Name: data.Name,
  4938. StartDay: data.SellingBegin,
  4939. EndDay: data.SellingDuration,
  4940. LimitCount: data.RestrictedType,
  4941. LimitType: data.SellingType,
  4942. SeasonId: data.SeasonId,
  4943. ActivityId: data.ActiveId,
  4944. }
  4945. for _, extra := range data.BuyReward {
  4946. strList := strings.Split(extra, ":")
  4947. if len(strList) >= 2 {
  4948. key, _ := Str2Num(strList[0])
  4949. value, _ := Str2Num(strList[1])
  4950. convertLimitBag.BuyReward = append(convertLimitBag.BuyReward, &serverproto.KeyValueType{
  4951. Key: int32(key),
  4952. Value: int32(value),
  4953. })
  4954. }
  4955. }
  4956. loc := util.GetLoc()
  4957. if data.BeginTime != "" {
  4958. sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.BeginTime, loc)
  4959. if err1 != nil {
  4960. util.PanicF("convertRune startTime err:%v", err1)
  4961. }
  4962. convertLimitBag.BeginTime = int64(sTime.Unix() * 1000)
  4963. }
  4964. if data.EndTime != "" {
  4965. cTime, err2 := time.ParseInLocation(util.DATE_FORMAT, data.EndTime, loc)
  4966. if err2 != nil {
  4967. util.PanicF("convertRune endTime err:%v", err2)
  4968. }
  4969. convertLimitBag.EndTime = int64(cTime.Unix() * 1000)
  4970. }
  4971. ConvertLimitGag[data.Id] = convertLimitBag
  4972. }
  4973. for _, data := range serverproto.RuneShopMonthCardCfgLoader {
  4974. monthCard := &MonthCard{
  4975. GoodsId: data.Id,
  4976. Name: data.Name,
  4977. Duration: data.AddTime,
  4978. Price: data.RMB,
  4979. MailCfgId: data.RewardMail,
  4980. }
  4981. for _, buyReward := range data.BuyRewardServer {
  4982. strList := strings.Split(buyReward, ":")
  4983. if len(strList) >= 2 {
  4984. key, _ := Str2Num(strList[0])
  4985. value, _ := Str2Num(strList[1])
  4986. monthCard.BuyReward = append(monthCard.BuyReward, &serverproto.KeyValueType{
  4987. Key: int32(key),
  4988. Value: int32(value),
  4989. })
  4990. }
  4991. }
  4992. for _, dayReward := range data.DayReward {
  4993. strList := strings.Split(dayReward, ":")
  4994. if len(strList) >= 2 {
  4995. key, _ := Str2Num(strList[0])
  4996. value, _ := Str2Num(strList[1])
  4997. monthCard.MailReward = append(monthCard.MailReward, &serverproto.KeyValueType{
  4998. Key: int32(key),
  4999. Value: int32(value),
  5000. })
  5001. }
  5002. }
  5003. ConvertMonthCard[data.Id] = monthCard
  5004. }
  5005. for _, data := range serverproto.RuneShopRankTowerCfgLoader {
  5006. towerShop := &RushShop{
  5007. GoodsId: data.Id,
  5008. Name: data.Name,
  5009. Price: data.RMB,
  5010. Activity: data.RankId,
  5011. LimitCount: data.RestrictedType,
  5012. }
  5013. for _, items := range data.Reward {
  5014. strList := strings.Split(items, ":")
  5015. if len(strList) >= 2 {
  5016. key, _ := Str2Num(strList[0])
  5017. value, _ := Str2Num(strList[1])
  5018. towerShop.BuyReward = append(towerShop.BuyReward, &serverproto.KeyValueType{
  5019. Key: int32(key),
  5020. Value: int32(value),
  5021. })
  5022. }
  5023. }
  5024. ConvertTowerShop[data.Id] = towerShop
  5025. }
  5026. for _, data := range serverproto.RuneShopRankArenaCfgLoader {
  5027. arenaShop := &RushShop{
  5028. GoodsId: data.Id,
  5029. Name: data.Name,
  5030. Price: data.RMB,
  5031. Activity: data.RankId,
  5032. LimitCount: data.RestrictedType,
  5033. }
  5034. for _, items := range data.Reward {
  5035. strList := strings.Split(items, ":")
  5036. if len(strList) >= 2 {
  5037. key, _ := Str2Num(strList[0])
  5038. value, _ := Str2Num(strList[1])
  5039. arenaShop.BuyReward = append(arenaShop.BuyReward, &serverproto.KeyValueType{
  5040. Key: int32(key),
  5041. Value: int32(value),
  5042. })
  5043. }
  5044. }
  5045. ConvertArenaShop[data.Id] = arenaShop
  5046. }
  5047. for _, data := range serverproto.RuneShopRankMapCfgLoader {
  5048. mapShop := &RushShop{
  5049. GoodsId: data.Id,
  5050. Name: data.Name,
  5051. Price: data.RMB,
  5052. Activity: data.RankId,
  5053. LimitCount: data.RestrictedType,
  5054. Score: data.RewardScore,
  5055. }
  5056. for _, items := range data.SeverReward {
  5057. strList := strings.Split(items, ":")
  5058. if len(strList) >= 2 {
  5059. key, _ := Str2Num(strList[0])
  5060. value, _ := Str2Num(strList[1])
  5061. mapShop.BuyReward = append(mapShop.BuyReward, &serverproto.KeyValueType{
  5062. Key: int32(key),
  5063. Value: int32(value),
  5064. })
  5065. }
  5066. }
  5067. ConvertMapShop[data.Id] = mapShop
  5068. }
  5069. //公会战商店
  5070. for _, data := range serverproto.RuneShopGuildBattleCfgLoader {
  5071. convertGift := &RushShop{
  5072. GoodsId: data.Id,
  5073. Price: data.RMB,
  5074. Name: data.Name,
  5075. LimitCount: data.RestrictedType,
  5076. }
  5077. for _, reward := range data.Reward {
  5078. strList := strings.Split(reward, ":")
  5079. if len(strList) >= 2 {
  5080. key, _ := Str2Num(strList[0])
  5081. value, _ := Str2Num(strList[1])
  5082. convertGift.BuyReward = append(convertGift.BuyReward, &serverproto.KeyValueType{
  5083. Key: int32(key),
  5084. Value: int32(value),
  5085. })
  5086. }
  5087. }
  5088. ConvertGuildBattle[data.Id] = convertGift
  5089. }
  5090. for _, data := range serverproto.RuneShopRankPetCfgLoader {
  5091. mapShop := &RushShop{
  5092. GoodsId: data.Id,
  5093. Name: data.Name,
  5094. Price: data.RMB,
  5095. Activity: data.RankId,
  5096. LimitCount: data.RestrictedType,
  5097. // Score: data.RewardScore,
  5098. }
  5099. for _, items := range data.Reward {
  5100. strList := strings.Split(items, ":")
  5101. if len(strList) >= 2 {
  5102. key, _ := Str2Num(strList[0])
  5103. value, _ := Str2Num(strList[1])
  5104. mapShop.BuyReward = append(mapShop.BuyReward, &serverproto.KeyValueType{
  5105. Key: int32(key),
  5106. Value: int32(value),
  5107. })
  5108. }
  5109. }
  5110. ConvertPetShop[data.Id] = mapShop
  5111. }
  5112. for _, data := range serverproto.RuneShopRankSkillCfgLoader {
  5113. mapShop := &RushShop{
  5114. GoodsId: data.Id,
  5115. Name: data.Name,
  5116. Price: data.RMB,
  5117. Activity: data.RankId,
  5118. LimitCount: data.RestrictedType,
  5119. // Score: data.RewardScore,
  5120. }
  5121. for _, items := range data.Reward {
  5122. strList := strings.Split(items, ":")
  5123. if len(strList) >= 2 {
  5124. key, _ := Str2Num(strList[0])
  5125. value, _ := Str2Num(strList[1])
  5126. mapShop.BuyReward = append(mapShop.BuyReward, &serverproto.KeyValueType{
  5127. Key: int32(key),
  5128. Value: int32(value),
  5129. })
  5130. }
  5131. }
  5132. ConvertSkillShop[data.Id] = mapShop
  5133. }
  5134. for _, data := range serverproto.RuneShopRankAidouluCfgLoader {
  5135. convertIdol := &RushShop{
  5136. GoodsId: data.Id,
  5137. Name: data.Name,
  5138. Price: data.RMB,
  5139. Activity: data.RankId,
  5140. LimitCount: data.RestrictedType,
  5141. Score: data.IfRequite,
  5142. Ticket: data.RewardScore,
  5143. }
  5144. for _, items := range data.SeverReward {
  5145. strList := strings.Split(items, ":")
  5146. if len(strList) >= 2 {
  5147. key, _ := Str2Num(strList[0])
  5148. value, _ := Str2Num(strList[1])
  5149. convertIdol.BuyReward = append(convertIdol.BuyReward, &serverproto.KeyValueType{
  5150. Key: int32(key),
  5151. Value: int32(value),
  5152. })
  5153. }
  5154. }
  5155. ConvertIdolShop[data.Id] = convertIdol
  5156. }
  5157. // 充值钱包功能(配置和RuneSHoGifts一致)
  5158. for _, data := range serverproto.PurseShopCfgLoader {
  5159. convertGift := &GiftBag{
  5160. GoodsId: data.Id,
  5161. BagType: data.Type,
  5162. Price: data.RMB,
  5163. Name: data.Name,
  5164. LimitCount: data.RestrictedType,
  5165. RmbTotalPay: data.RmbTotalPay,
  5166. }
  5167. for _, reward := range data.Reward {
  5168. strList := strings.Split(reward, ":")
  5169. if len(strList) >= 2 {
  5170. key, _ := Str2Num(strList[0])
  5171. value, _ := Str2Num(strList[1])
  5172. convertGift.BuyReward = append(convertGift.BuyReward, &serverproto.KeyValueType{
  5173. Key: int32(key),
  5174. Value: int32(value),
  5175. })
  5176. }
  5177. }
  5178. for _, first := range data.FirstBuyReward {
  5179. strList := strings.Split(first, ":")
  5180. if len(strList) >= 2 {
  5181. key, _ := Str2Num(strList[0])
  5182. value, _ := Str2Num(strList[1])
  5183. convertGift.FirstReward = append(convertGift.FirstReward, &serverproto.KeyValueType{
  5184. Key: int32(key),
  5185. Value: int32(value),
  5186. })
  5187. }
  5188. }
  5189. for _, extra := range data.ExtraBuyReward {
  5190. strList := strings.Split(extra, ":")
  5191. if len(strList) >= 2 {
  5192. key, _ := Str2Num(strList[0])
  5193. value, _ := Str2Num(strList[1])
  5194. convertGift.ExtraReward = append(convertGift.ExtraReward, &serverproto.KeyValueType{
  5195. Key: int32(key),
  5196. Value: int32(value),
  5197. })
  5198. }
  5199. }
  5200. ConvertPurseShop[data.Id] = convertGift
  5201. if data.RMB == 0 {
  5202. ConvertPurseShop[data.Id] = convertGift
  5203. }
  5204. }
  5205. }
  5206. const (
  5207. Rush_Type_Tower = 1
  5208. Rush_Type_Arena = 2
  5209. Rush_Type_Map = 3
  5210. Rush_Type_Pet = 4
  5211. Rush_Type_Skill = 5
  5212. )
  5213. const (
  5214. Rush_Reward_Type_FightCount = 1 //战斗次数,或者地图等级
  5215. Rush_Reward_Type_Rank = 2 //排行版奖励
  5216. )
  5217. type RewardRank struct {
  5218. RankBegin int32
  5219. RankEnd int32
  5220. RankLevel int32 //所在档位
  5221. RewardList []*serverproto.KeyValueType
  5222. }
  5223. type RankList struct {
  5224. RankRound int32
  5225. StartDay int32
  5226. StartTime string
  5227. CloseDay int32
  5228. CloseTime string
  5229. RestDay int32
  5230. RestTime string
  5231. Reward []*RewardRank
  5232. }
  5233. type RewardBase struct {
  5234. RewardBegin int32
  5235. RewardEnd int32
  5236. RewardLevel int32 //所在档位
  5237. // RewardList []*serverproto.KeyValueType
  5238. RewardList map[int32]int32
  5239. }
  5240. type RushBaseReward struct {
  5241. Reward []*RewardBase
  5242. }
  5243. type RankActivity struct {
  5244. RushActivity map[int32]*RankList
  5245. BaseReward map[int32]*RushBaseReward
  5246. }
  5247. var DaySec int32 = 24 * 60 * 60
  5248. var ConvertRushList = map[int32]*RankActivity{}
  5249. func convertRushListCfg() {
  5250. for _, data := range serverproto.RushListCfgLoader {
  5251. _, ok := ConvertRushList[data.RankType]
  5252. if !ok {
  5253. rankActivity := &RankActivity{
  5254. RushActivity: map[int32]*RankList{},
  5255. BaseReward: map[int32]*RushBaseReward{},
  5256. }
  5257. ConvertRushList[data.RankType] = rankActivity
  5258. }
  5259. _, ok2 := ConvertRushList[data.RankType].RushActivity[data.RankId]
  5260. if !ok2 {
  5261. rankList := &RankList{}
  5262. rankList.RankRound = data.RankId
  5263. rankList.StartDay = data.StartDay
  5264. rankList.StartTime = data.StartTime
  5265. rankList.CloseDay = data.CloseDay
  5266. rankList.CloseTime = data.CloseTime
  5267. rankList.RestDay = data.RestDay
  5268. rankList.RestTime = data.RestTime
  5269. ConvertRushList[data.RankType].RushActivity[data.RankId] = rankList
  5270. }
  5271. rush, ok3 := ConvertRushList[data.RankType].RushActivity[data.RankId]
  5272. if ok3 {
  5273. rewardRank := &RewardRank{
  5274. RankLevel: data.RankGrade,
  5275. }
  5276. if len(data.Rank) >= 1 {
  5277. strList := strings.Split(data.Rank[0], ":")
  5278. if len(strList) >= 2 {
  5279. begin, _ := Str2Num(strList[0])
  5280. end, _ := Str2Num(strList[1])
  5281. rewardRank.RankBegin = int32(begin)
  5282. rewardRank.RankEnd = int32(end)
  5283. }
  5284. }
  5285. for _, reward := range data.Reward {
  5286. strList := strings.Split(reward, ":")
  5287. if len(strList) >= 2 {
  5288. key, _ := Str2Num(strList[0])
  5289. value, _ := Str2Num(strList[1])
  5290. rewardRank.RewardList = append(rewardRank.RewardList, &serverproto.KeyValueType{
  5291. Key: int32(key),
  5292. Value: int32(value),
  5293. })
  5294. }
  5295. }
  5296. rush.Reward = append(rush.Reward, rewardRank)
  5297. }
  5298. }
  5299. for _, data := range serverproto.RushListTargetCfgLoader {
  5300. _, ok := ConvertRushList[data.RankType]
  5301. if !ok {
  5302. continue
  5303. }
  5304. //没有这个活动。也不能加载这个活动对应的奖励
  5305. _, ok2 := ConvertRushList[data.RankType].RushActivity[data.RankId]
  5306. if !ok2 {
  5307. continue
  5308. }
  5309. _, ok3 := ConvertRushList[data.RankType].BaseReward[data.RankId]
  5310. if !ok3 {
  5311. rushBaseReward := &RushBaseReward{}
  5312. ConvertRushList[data.RankType].BaseReward[data.RankId] = rushBaseReward
  5313. }
  5314. rushReward, ok4 := ConvertRushList[data.RankType].BaseReward[data.RankId]
  5315. if ok4 {
  5316. rewardRank := &RewardBase{
  5317. RewardLevel: data.TargetGrade,
  5318. RewardList: make(map[int32]int32),
  5319. }
  5320. if len(data.Rank) >= 1 {
  5321. strList := strings.Split(data.Rank[0], ":")
  5322. if len(strList) >= 2 {
  5323. begin, _ := Str2Num(strList[0])
  5324. end, _ := Str2Num(strList[1])
  5325. rewardRank.RewardBegin = int32(begin)
  5326. rewardRank.RewardEnd = int32(end)
  5327. }
  5328. }
  5329. for _, reward := range data.Reward {
  5330. strList := strings.Split(reward, ":")
  5331. if len(strList) >= 2 {
  5332. key, _ := Str2Num(strList[0])
  5333. value, _ := Str2Num(strList[1])
  5334. rewardRank.RewardList[int32(key)] = int32(value)
  5335. /*
  5336. rewardRank.RewardList = append(rewardRank.RewardList, &serverproto.KeyValueType{
  5337. Key: int32(key),
  5338. Value: int32(value),
  5339. })
  5340. */
  5341. }
  5342. }
  5343. rushReward.Reward = append(rushReward.Reward, rewardRank)
  5344. }
  5345. }
  5346. }
  5347. func GetRushActivityTimeStamp(deltaDay int32, deltaTime string) uint64 {
  5348. loc := util.GetLoc()
  5349. startUpTime := service.GetServiceStartupTime()
  5350. if startUpTime < 0 {
  5351. util.ErrorF("[convertRushListCfg] data error:%v")
  5352. return 0
  5353. }
  5354. startServer := time.Unix(int64(startUpTime/1000), 0).In(loc).Format(util.DATE_FORMAT1)
  5355. startUpDayStr := util.GetDayByTimeStr1(startServer)
  5356. rushBegin := util.GetTimeByStr(startUpDayStr.Format(util.DATE_FORMAT1) + " " + deltaTime)
  5357. rushStart := time.Unix(rushBegin.Unix()+int64(deltaDay-1)*int64(DaySec), 0).In(loc)
  5358. return uint64(rushStart.UnixNano() / 1e6)
  5359. }
  5360. func GetCurrentRushActivity(RankType int32, RushRound int32) *RankList {
  5361. rushList, ok := ConvertRushList[RankType]
  5362. if !ok {
  5363. return nil
  5364. }
  5365. nowTime := util.GetCurrentTime()
  5366. for _, data := range rushList.RushActivity {
  5367. if RushRound != 0 {
  5368. if data.RankRound != RushRound {
  5369. continue
  5370. }
  5371. }
  5372. rushBegin := GetRushActivityTimeStamp(data.StartDay, data.StartTime)
  5373. rewardEnd := GetRushActivityTimeStamp(data.RestDay, data.RestTime)
  5374. if rushBegin <= nowTime && nowTime <= rewardEnd {
  5375. return data
  5376. }
  5377. }
  5378. return nil
  5379. }
  5380. func GetNextRushActivity(RankType int32, RushRound int32) *RankList {
  5381. rushList, ok := ConvertRushList[RankType]
  5382. if !ok {
  5383. return nil
  5384. }
  5385. nowTime := util.GetCurrentTime()
  5386. for i := RushRound; i <= int32(len(rushList.RushActivity)); i++ {
  5387. data, ok := rushList.RushActivity[i]
  5388. if !ok {
  5389. continue
  5390. }
  5391. if nowTime < GetRushActivityTimeStamp(data.StartDay, data.StartTime) {
  5392. return data
  5393. }
  5394. }
  5395. return nil
  5396. }
  5397. func GetRushActivityByRound(RankType int32, RushRound int32) *RankList {
  5398. rushList, ok := ConvertRushList[RankType]
  5399. if !ok {
  5400. return nil
  5401. }
  5402. for _, data := range rushList.RushActivity {
  5403. if data.RankRound != RushRound {
  5404. continue
  5405. }
  5406. return data
  5407. }
  5408. return nil
  5409. }
  5410. func GetRushActivityBaseReward(RushRound int32, RankType int32, score int32, addItemList map[int32]int32) int32 {
  5411. rushList, ok := ConvertRushList[RankType]
  5412. if !ok {
  5413. return 0
  5414. }
  5415. rewards, ok2 := rushList.BaseReward[RushRound]
  5416. if !ok2 {
  5417. return 0
  5418. }
  5419. for _, data := range rewards.Reward {
  5420. if data.RewardEnd != 0 && data.RewardBegin <= score && score <= data.RewardEnd ||
  5421. data.RewardEnd == 0 && data.RewardBegin <= score {
  5422. for key, value := range data.RewardList {
  5423. addItemList[key] += value
  5424. }
  5425. return data.RewardLevel
  5426. }
  5427. }
  5428. return 0
  5429. }
  5430. type LevelUpMaterial struct {
  5431. Materials map[int32]int32
  5432. AddAttr map[int32]int32
  5433. Level int32
  5434. }
  5435. type KeepSakeData struct {
  5436. KeepSakeId int32
  5437. LevelData map[int32]*LevelUpMaterial
  5438. LevelDataList []*LevelUpMaterial
  5439. Job []int32
  5440. KeepLevel int32
  5441. MaxLevel int32
  5442. AllMaterials map[int32]int32
  5443. }
  5444. var ConvertMaterialToKeepSake = map[int32]int32{}
  5445. var ConvertKeepSake = map[int32]*KeepSakeData{}
  5446. func convertKeepSakeCfg() {
  5447. for _, data := range serverproto.KeepSakeCfgLoader {
  5448. convert := &KeepSakeData{
  5449. KeepSakeId: data.Id,
  5450. KeepLevel: data.CollectionLevel,
  5451. }
  5452. convert.LevelData = make(map[int32]*LevelUpMaterial)
  5453. convert.AllMaterials = make(map[int32]int32)
  5454. for _, jobs := range data.Job {
  5455. jobId, _ := Str2Num(jobs)
  5456. convert.Job = append(convert.Job, int32(jobId))
  5457. }
  5458. //等級1
  5459. levelUpMaterial1 := &LevelUpMaterial{}
  5460. levelUpMaterial1.Materials = make(map[int32]int32)
  5461. levelUpMaterial1.AddAttr = make(map[int32]int32)
  5462. for _, material1 := range data.MaterialLevel1 {
  5463. material := strings.Split(material1, ":")
  5464. if len(material) >= 2 {
  5465. itemId, _ := Str2Num(material[0])
  5466. itemCount, _ := Str2Num(material[1])
  5467. levelUpMaterial1.Materials[int32(itemId)] = int32(itemCount)
  5468. ConvertMaterialToKeepSake[int32(itemId)] = data.Id
  5469. convert.MaxLevel = 1
  5470. convert.AllMaterials[int32(itemId)] = 1
  5471. }
  5472. }
  5473. for _, attr1 := range data.AddAttrLevel1 {
  5474. addAttr := strings.Split(attr1, ":")
  5475. if len(addAttr) >= 2 {
  5476. attrKey, _ := Str2Num(addAttr[0])
  5477. attrValue, _ := Str2Num(addAttr[1])
  5478. levelUpMaterial1.AddAttr[int32(attrKey)] = int32(attrValue)
  5479. }
  5480. }
  5481. levelUpMaterial1.Level = 1
  5482. convert.LevelData[1] = levelUpMaterial1
  5483. convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial1)
  5484. //等級2
  5485. levelUpMaterial2 := &LevelUpMaterial{}
  5486. levelUpMaterial2.Materials = make(map[int32]int32)
  5487. levelUpMaterial2.AddAttr = make(map[int32]int32)
  5488. for _, material2 := range data.MaterialLevel2 {
  5489. material := strings.Split(material2, ":")
  5490. if len(material) >= 2 {
  5491. itemId, _ := Str2Num(material[0])
  5492. itemCount, _ := Str2Num(material[1])
  5493. levelUpMaterial2.Materials[int32(itemId)] = int32(itemCount)
  5494. ConvertMaterialToKeepSake[int32(itemId)] = data.Id
  5495. convert.MaxLevel = 2
  5496. convert.AllMaterials[int32(itemId)] = 1
  5497. }
  5498. }
  5499. for _, attr2 := range data.AddAttrLevel2 {
  5500. addAttr := strings.Split(attr2, ":")
  5501. if len(addAttr) >= 2 {
  5502. attrKey, _ := Str2Num(addAttr[0])
  5503. attrValue, _ := Str2Num(addAttr[1])
  5504. levelUpMaterial2.AddAttr[int32(attrKey)] = int32(attrValue)
  5505. }
  5506. }
  5507. levelUpMaterial2.Level = 2
  5508. convert.LevelData[2] = levelUpMaterial2
  5509. convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial2)
  5510. levelUpMaterial3 := &LevelUpMaterial{}
  5511. levelUpMaterial3.Materials = make(map[int32]int32)
  5512. levelUpMaterial3.AddAttr = make(map[int32]int32)
  5513. for _, material3 := range data.MaterialLevel3 {
  5514. material := strings.Split(material3, ":")
  5515. if len(material) >= 2 {
  5516. itemId, _ := Str2Num(material[0])
  5517. itemCount, _ := Str2Num(material[1])
  5518. levelUpMaterial3.Materials[int32(itemId)] = int32(itemCount)
  5519. ConvertMaterialToKeepSake[int32(itemId)] = data.Id
  5520. convert.MaxLevel = 3
  5521. convert.AllMaterials[int32(itemId)] = 1
  5522. }
  5523. }
  5524. for _, attr3 := range data.AddAttrLevel3 {
  5525. attr := strings.Split(attr3, ":")
  5526. if len(attr) >= 2 {
  5527. attrKey, _ := Str2Num(attr[0])
  5528. attrValue, _ := Str2Num(attr[1])
  5529. levelUpMaterial3.AddAttr[int32(attrKey)] = int32(attrValue)
  5530. }
  5531. }
  5532. levelUpMaterial3.Level = 3
  5533. convert.LevelData[3] = levelUpMaterial3
  5534. convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial3)
  5535. levelUpMaterial4 := &LevelUpMaterial{}
  5536. levelUpMaterial4.Materials = make(map[int32]int32)
  5537. levelUpMaterial4.AddAttr = make(map[int32]int32)
  5538. for _, material4 := range data.MaterialLevel4 {
  5539. material := strings.Split(material4, ":")
  5540. if len(material) >= 2 {
  5541. itemId, _ := Str2Num(material[0])
  5542. itemCount, _ := Str2Num(material[1])
  5543. levelUpMaterial4.Materials[int32(itemId)] = int32(itemCount)
  5544. ConvertMaterialToKeepSake[int32(itemId)] = data.Id
  5545. convert.MaxLevel = 4
  5546. convert.AllMaterials[int32(itemId)] = 1
  5547. }
  5548. }
  5549. for _, attr4 := range data.AddAttrLevel4 {
  5550. attr := strings.Split(attr4, ":")
  5551. if len(attr) >= 2 {
  5552. attrKey, _ := Str2Num(attr[0])
  5553. attrValue, _ := Str2Num(attr[1])
  5554. levelUpMaterial4.AddAttr[int32(attrKey)] = int32(attrValue)
  5555. }
  5556. }
  5557. levelUpMaterial4.Level = 4
  5558. convert.LevelData[4] = levelUpMaterial4
  5559. convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial4)
  5560. levelUpMaterial5 := &LevelUpMaterial{}
  5561. levelUpMaterial5.Materials = make(map[int32]int32)
  5562. levelUpMaterial5.AddAttr = make(map[int32]int32)
  5563. for _, material5 := range data.MaterialLevel5 {
  5564. material := strings.Split(material5, ":")
  5565. if len(material) >= 2 {
  5566. itemId, _ := Str2Num(material[0])
  5567. itemCount, _ := Str2Num(material[1])
  5568. levelUpMaterial5.Materials[int32(itemId)] = int32(itemCount)
  5569. ConvertMaterialToKeepSake[int32(itemId)] = data.Id
  5570. convert.MaxLevel = 5
  5571. convert.AllMaterials[int32(itemId)] = 1
  5572. }
  5573. }
  5574. for _, attr5 := range data.AddAttrLevel5 {
  5575. attr := strings.Split(attr5, ":")
  5576. if len(attr) >= 2 {
  5577. attrKey, _ := Str2Num(attr[0])
  5578. attrValue, _ := Str2Num(attr[1])
  5579. levelUpMaterial5.AddAttr[int32(attrKey)] = int32(attrValue)
  5580. }
  5581. }
  5582. levelUpMaterial5.Level = 5
  5583. convert.LevelData[5] = levelUpMaterial5
  5584. convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial5)
  5585. ConvertKeepSake[data.Id] = convert
  5586. }
  5587. for _, val := range ConvertKeepSake {
  5588. sort.Slice(val.LevelDataList, func(i, j int) bool {
  5589. return val.LevelDataList[i].Level < val.LevelDataList[j].Level
  5590. })
  5591. }
  5592. }
  5593. func GetMaxKeepSakeLevel(keepSakeId int32) int32 {
  5594. data, ok := ConvertKeepSake[keepSakeId]
  5595. if !ok {
  5596. return 0
  5597. }
  5598. return data.MaxLevel
  5599. }
  5600. type SuitCondition struct {
  5601. cardType int32
  5602. cardLvl int32
  5603. cardCnt int32
  5604. }
  5605. func (this SuitCondition) GetKey() int32 {
  5606. return this.cardType
  5607. }
  5608. func (this SuitCondition) GetLvl() int32 {
  5609. return this.cardLvl
  5610. }
  5611. func (this SuitCondition) GetCnt() int32 {
  5612. return this.cardCnt
  5613. }
  5614. type CardSuitData struct {
  5615. id int32
  5616. suits []*serverproto.KeyValueType
  5617. suitTerm []*SuitCondition
  5618. SuitTotalCardNum map[int32]int32 //需要同种类型卡片的数量
  5619. }
  5620. func (this CardSuitData) GetConditions() []*SuitCondition {
  5621. return this.suitTerm
  5622. }
  5623. func (this CardSuitData) GetSuits() []*serverproto.KeyValueType {
  5624. return this.suits
  5625. }
  5626. func (this CardSuitData) Id() int32 {
  5627. return this.id
  5628. }
  5629. var DbCardSuitData = map[int32]*CardSuitData{}
  5630. var ConvertCardSuit []*CardSuitData
  5631. func convertCardSuitNewCfg() {
  5632. for _, v := range serverproto.CardSuitNewCfgLoader {
  5633. data := &CardSuitData{
  5634. SuitTotalCardNum: map[int32]int32{},
  5635. }
  5636. data.id = v.Id
  5637. for _, v1 := range v.Suit1 {
  5638. k, val := Str2Res(v1)
  5639. data.suits = append(data.suits, &serverproto.KeyValueType{Key: k, Value: val})
  5640. }
  5641. for _, v2 := range v.TriggerConditions {
  5642. t, l, c := Str2Res_3(v2)
  5643. data.SuitTotalCardNum[t] += c
  5644. data.suitTerm = append(data.suitTerm, &SuitCondition{t, l, c})
  5645. }
  5646. DbCardSuitData[v.Id] = data
  5647. ConvertCardSuit = append(ConvertCardSuit, data)
  5648. }
  5649. sort.Slice(ConvertCardSuit, func(i, j int) bool {
  5650. return ConvertCardSuit[i].id > ConvertCardSuit[j].id
  5651. })
  5652. }
  5653. type TmapMaterial map[int32]int32
  5654. type StFashionUp struct {
  5655. level int32
  5656. quality int32 // 品质 1:绿色 2:蓝色 3:紫色 4:金色 5:红色
  5657. upAttr int32
  5658. material TmapMaterial
  5659. }
  5660. func (this StFashionUp) Material() TmapMaterial {
  5661. return this.material
  5662. }
  5663. func (this StFashionUp) UpAttr() int32 {
  5664. return this.upAttr
  5665. }
  5666. func CreateKey16Offset(left, right int32) int32 {
  5667. // 偏移16位作为 左值
  5668. return left<<16 | right
  5669. }
  5670. var DbFashionLevelUp = make(map[int32]*StFashionUp)
  5671. func CreateData(dbDate []string) *StFashionUp {
  5672. data := &StFashionUp{material: make(TmapMaterial)}
  5673. for _, v1 := range dbDate {
  5674. id, cnt := Str2Res(v1)
  5675. data.material[id] = cnt
  5676. }
  5677. return data
  5678. }
  5679. func covertFashionLevelUpCfg() {
  5680. for _, v := range serverproto.FashionLevelUpLoader {
  5681. data1 := CreateData(v.UpMaterial1)
  5682. data1.level = v.Level
  5683. data1.quality = 1
  5684. data1.upAttr = v.UpAttribute
  5685. DbFashionLevelUp[CreateKey16Offset(data1.level, data1.quality)] = data1
  5686. data2 := CreateData(v.UpMaterial2)
  5687. data2.level = v.Level
  5688. data2.quality = 2
  5689. data2.upAttr = v.UpAttribute
  5690. DbFashionLevelUp[CreateKey16Offset(data2.level, data2.quality)] = data2
  5691. data3 := CreateData(v.UpMaterial3)
  5692. data3.level = v.Level
  5693. data3.quality = 3
  5694. data3.upAttr = v.UpAttribute
  5695. DbFashionLevelUp[CreateKey16Offset(data3.level, data3.quality)] = data3
  5696. data4 := CreateData(v.UpMaterial4)
  5697. data4.level = v.Level
  5698. data4.quality = 4
  5699. data4.upAttr = v.UpAttribute
  5700. DbFashionLevelUp[CreateKey16Offset(data4.level, data4.quality)] = data4
  5701. data5 := CreateData(v.UpMaterial5)
  5702. data5.level = v.Level
  5703. data5.quality = 5
  5704. data5.upAttr = v.UpAttribute
  5705. DbFashionLevelUp[CreateKey16Offset(data5.level, data5.quality)] = data5
  5706. }
  5707. }
  5708. type StFashionRandom struct {
  5709. id int32
  5710. roleid int32
  5711. atrid []int32
  5712. //refreshCost map[int32]int32
  5713. }
  5714. func (this StFashionRandom) GetAtrid() []int32 {
  5715. return this.atrid[:]
  5716. }
  5717. func (this StFashionRandom) GetRoleid() int32 {
  5718. return this.roleid
  5719. }
  5720. var DbFashionResetAttrCost = []map[int32]int32{}
  5721. var DbFashionRandom = []*StFashionRandom{} // make(map[int32]*StFashionRandom)
  5722. func convertFashionRandomCfg() {
  5723. for _, v := range serverproto.FashionRandomLoader {
  5724. //id, cnt := Str2Res(v.RefreshCost)
  5725. data := &StFashionRandom{v.ID, int32(v.RoleId), []int32{}}
  5726. for _, jobs := range v.AtrId {
  5727. attrId, _ := Str2Num(jobs)
  5728. data.atrid = append(data.atrid, int32(attrId))
  5729. }
  5730. DbFashionRandom = append(DbFashionRandom, data)
  5731. //DbFashionRandom[data.roleid] = &data
  5732. }
  5733. var globalDb = serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Fashion_Attr)]
  5734. if globalDb == nil {
  5735. panic("299 全局配置错误")
  5736. }
  5737. items := strings.Split(globalDb.SVal, ";")
  5738. for _, i2 := range items {
  5739. id, cnt := Str2Res(i2)
  5740. DbFashionResetAttrCost = append(DbFashionResetAttrCost, map[int32]int32{id: cnt})
  5741. }
  5742. }
  5743. type StSuitLvlAttr struct {
  5744. lvl int32
  5745. attr *serverproto.KeyValueType
  5746. }
  5747. // 套装表
  5748. type StFashionSuit struct {
  5749. suitId int32
  5750. fashionIds []int32
  5751. mapAttr map[int32][]*serverproto.KeyValueType
  5752. }
  5753. func (this StFashionSuit) Id() int32 {
  5754. return this.suitId
  5755. }
  5756. func (this StFashionSuit) GetIds() []int32 {
  5757. return this.fashionIds[:]
  5758. }
  5759. func (this StFashionSuit) GetMapAttr() map[int32][]*serverproto.KeyValueType {
  5760. return this.mapAttr
  5761. }
  5762. var DbFashionSuit = make(map[int32]*StFashionSuit)
  5763. var DbFashionSuitID = make(map[int32][]*StFashionSuit)
  5764. func converFashionSuitCfg() {
  5765. for _, v := range serverproto.FashionSuitCfgLoader {
  5766. data := &StFashionSuit{mapAttr: make(map[int32][]*serverproto.KeyValueType)}
  5767. if len(v.LevelCondition) != len(v.Attribute) {
  5768. panic("FashionSuitCfg 属性配置和等级配置不对应")
  5769. }
  5770. for i, val := range v.LevelCondition {
  5771. lvl, _ := strconv.Atoi(val)
  5772. resList := strings.Split(v.Attribute[i], ":")
  5773. for _, i3 := range resList {
  5774. values := strings.Split(i3, "-")
  5775. if len(values) < 2 {
  5776. continue
  5777. }
  5778. id, _ := Str2Num(values[0])
  5779. attrVar, _ := Str2Num(values[1])
  5780. data.mapAttr[int32(lvl)] = append(data.mapAttr[int32(lvl)], &serverproto.KeyValueType{Key: int32(id), Value: int32(attrVar)})
  5781. }
  5782. }
  5783. for _, i2 := range v.FashionId {
  5784. value, _ := Str2Num(i2)
  5785. data.fashionIds = append(data.fashionIds, int32(value))
  5786. }
  5787. data.suitId = v.SuitId
  5788. DbFashionSuit[v.SuitId] = data
  5789. }
  5790. for _, v := range serverproto.FashionSuitCfgLoader {
  5791. data := &StFashionSuit{mapAttr: make(map[int32][]*serverproto.KeyValueType)}
  5792. if len(v.LevelCondition) != len(v.Attribute) {
  5793. panic("FashionSuitCfg 属性配置和等级配置不对应")
  5794. }
  5795. for i, val := range v.LevelCondition {
  5796. lvl, _ := strconv.Atoi(val)
  5797. resList := strings.Split(v.Attribute[i], ":")
  5798. for _, i3 := range resList {
  5799. values := strings.Split(i3, "-")
  5800. if len(values) < 2 {
  5801. continue
  5802. }
  5803. id, _ := Str2Num(values[0])
  5804. attrVar, _ := Str2Num(values[1])
  5805. data.mapAttr[int32(lvl)] = append(data.mapAttr[int32(lvl)], &serverproto.KeyValueType{Key: int32(id), Value: int32(attrVar)})
  5806. }
  5807. }
  5808. for _, i2 := range v.FashionId {
  5809. value, _ := Str2Num(i2)
  5810. data.fashionIds = append(data.fashionIds, int32(value))
  5811. }
  5812. data.suitId = v.SuitId
  5813. DbFashionSuit[v.SuitId] = data
  5814. for _, id := range data.fashionIds {
  5815. DbFashionSuitID[id] = append(DbFashionSuitID[id], data)
  5816. }
  5817. }
  5818. }
  5819. ////////////////////////////////////卢恩战令////////////////////
  5820. type StRuneShopExplore struct {
  5821. round int32
  5822. goldExp int32
  5823. missionExp int32
  5824. missonExpUp int32
  5825. rmb float32
  5826. sellingBegin int32
  5827. startTime string
  5828. sellingDuration int32
  5829. closeTime string
  5830. maxlvrewads map[int32]int32
  5831. expCost int32
  5832. }
  5833. func (this StRuneShopExplore) StartTime() string {
  5834. return this.startTime
  5835. }
  5836. func (this StRuneShopExplore) CloseTime() string {
  5837. return this.closeTime
  5838. }
  5839. func (this StRuneShopExplore) SellingBegin() int32 {
  5840. return this.sellingBegin
  5841. }
  5842. func (this StRuneShopExplore) SellingDuration() int32 {
  5843. return this.sellingDuration
  5844. }
  5845. func (this StRuneShopExplore) GetRound() int32 {
  5846. return this.round
  5847. }
  5848. func (this StRuneShopExplore) GetRMB() float32 {
  5849. return this.rmb
  5850. }
  5851. func (this StRuneShopExplore) GoldScale() int32 {
  5852. return this.goldExp
  5853. }
  5854. func (this StRuneShopExplore) MissionScale() int32 {
  5855. return this.missionExp
  5856. }
  5857. type GuildWarReward struct {
  5858. Rank int32
  5859. MemberRewardList []*serverproto.KeyValueType
  5860. LeaderRewardList []*serverproto.KeyValueType
  5861. }
  5862. type GuildMvpReward struct {
  5863. Rank int32
  5864. RewardList []*serverproto.KeyValueType
  5865. }
  5866. type GuildBattleBuff struct {
  5867. BuffId int32
  5868. BuyData map[int32]*serverproto.KeyValueType
  5869. }
  5870. var GuildBattleRankReward = map[int32]*GuildWarReward{}
  5871. var GuildBattleScoreMvpReward = map[int32]*GuildMvpReward{}
  5872. var GuildBattleKillMvpReward = map[int32]*GuildMvpReward{}
  5873. var GuildBattleBuffList = map[int32]*GuildBattleBuff{}
  5874. func convertGuildWarCfg() {
  5875. for _, data := range serverproto.GuildWarAgainstCfgLoader {
  5876. rankReward := &GuildWarReward{
  5877. Rank: data.Ranking,
  5878. }
  5879. for _, deacon := range data.DeaconReword {
  5880. items := strings.Split(deacon, ":")
  5881. if len(items) >= 2 {
  5882. itemId, _ := Str2Num(items[0])
  5883. itemCount, _ := Str2Num(items[1])
  5884. rankReward.LeaderRewardList = append(rankReward.LeaderRewardList, &serverproto.KeyValueType{
  5885. Key: int32(itemId),
  5886. Value: int32(itemCount),
  5887. })
  5888. }
  5889. }
  5890. for _, member := range data.GuildsmenReword {
  5891. items := strings.Split(member, ":")
  5892. if len(items) >= 2 {
  5893. itemId, _ := Str2Num(items[0])
  5894. itemCount, _ := Str2Num(items[1])
  5895. rankReward.MemberRewardList = append(rankReward.MemberRewardList, &serverproto.KeyValueType{
  5896. Key: int32(itemId),
  5897. Value: int32(itemCount),
  5898. })
  5899. }
  5900. }
  5901. GuildBattleRankReward[data.Ranking] = rankReward
  5902. scoreMvpReward := &GuildMvpReward{
  5903. Rank: data.PointMvp,
  5904. }
  5905. for _, score := range data.PointMvpReword {
  5906. items := strings.Split(score, ":")
  5907. if len(items) >= 2 {
  5908. itemId, _ := Str2Num(items[0])
  5909. itemCount, _ := Str2Num(items[1])
  5910. scoreMvpReward.RewardList = append(scoreMvpReward.RewardList, &serverproto.KeyValueType{
  5911. Key: int32(itemId),
  5912. Value: int32(itemCount),
  5913. })
  5914. }
  5915. }
  5916. GuildBattleScoreMvpReward[data.PointMvp] = scoreMvpReward
  5917. killerMvpReward := &GuildMvpReward{
  5918. Rank: data.PointMvp,
  5919. }
  5920. for _, killer := range data.KillerMvpReword {
  5921. items := strings.Split(killer, ":")
  5922. if len(items) >= 2 {
  5923. itemId, _ := Str2Num(items[0])
  5924. itemCount, _ := Str2Num(items[1])
  5925. killerMvpReward.RewardList = append(killerMvpReward.RewardList, &serverproto.KeyValueType{
  5926. Key: int32(itemId),
  5927. Value: int32(itemCount),
  5928. })
  5929. }
  5930. }
  5931. GuildBattleKillMvpReward[data.KillerMvp] = killerMvpReward
  5932. }
  5933. for _, data := range serverproto.GuildWarBuffCfgLoader {
  5934. convertData := &GuildBattleBuff{
  5935. BuffId: data.Id,
  5936. BuyData: map[int32]*serverproto.KeyValueType{},
  5937. }
  5938. for idx, buffData := range data.Price {
  5939. resType, count := Str2Res(buffData)
  5940. convertData.BuyData[int32(idx+1)] = &serverproto.KeyValueType{
  5941. Key: resType,
  5942. Value: count,
  5943. }
  5944. }
  5945. GuildBattleBuffList[data.Id] = convertData
  5946. }
  5947. }
  5948. const (
  5949. GuildBattle_Reward_GuildMember = 1
  5950. GuildBattle_Reward_GuildLeader = 2
  5951. GuildBattle_Reward_ScoreMvp = 3
  5952. GuildBattle_Reward_KillerMvp = 4
  5953. )
  5954. func GetGuildBattleReward(rewardType int32, rank int32, rewardList []*serverproto.KeyValueType) {
  5955. if rewardType == GuildBattle_Reward_GuildMember ||
  5956. rewardType == GuildBattle_Reward_GuildLeader {
  5957. data, ok := GuildBattleRankReward[rank]
  5958. if !ok {
  5959. return
  5960. }
  5961. if rewardType == GuildBattle_Reward_GuildMember {
  5962. for _, items := range data.MemberRewardList {
  5963. rewardList = append(rewardList, items)
  5964. }
  5965. } else if rewardType == GuildBattle_Reward_GuildLeader {
  5966. for _, items := range data.LeaderRewardList {
  5967. rewardList = append(rewardList, items)
  5968. }
  5969. }
  5970. } else if rewardType == GuildBattle_Reward_ScoreMvp {
  5971. data, ok := GuildBattleScoreMvpReward[rank]
  5972. if !ok {
  5973. return
  5974. }
  5975. for _, items := range data.RewardList {
  5976. rewardList = append(rewardList, items)
  5977. }
  5978. } else if rewardType == GuildBattle_Reward_KillerMvp {
  5979. data, ok := GuildBattleKillMvpReward[rank]
  5980. if !ok {
  5981. return
  5982. }
  5983. for _, items := range data.RewardList {
  5984. rewardList = append(rewardList, items)
  5985. }
  5986. }
  5987. }
  5988. func (this StRuneShopExplore) MissionUp() int32 {
  5989. return this.missonExpUp
  5990. }
  5991. func (this StRuneShopExplore) ExpCost() int32 {
  5992. return this.expCost
  5993. }
  5994. func (this StRuneShopExplore) MaxAward() map[int32]int32 {
  5995. return this.maxlvrewads
  5996. }
  5997. //var DbRuneShopExplore = make(map[int32]*StRuneShopExplore)
  5998. var DbRuneShopExplore = []*StRuneShopExplore{}
  5999. func GetRuneExploreDataByRound(round int32) *StRuneShopExplore {
  6000. for _, explore := range DbRuneShopExplore {
  6001. if explore.GetRound() != round {
  6002. continue
  6003. }
  6004. return explore
  6005. }
  6006. return nil
  6007. }
  6008. func convertRuneShopExploreCfg() {
  6009. for _, v := range serverproto.RuneShopExploreCfgLoader {
  6010. data := &StRuneShopExplore{round: v.Round, rmb: v.RMB, sellingBegin: v.SellingBegin,
  6011. sellingDuration: v.SellingDuration, expCost: v.ExpCost, maxlvrewads: make(map[int32]int32),
  6012. startTime: v.StartTime, closeTime: v.CloseTime}
  6013. _, val1 := Str2Res(v.GoldExp)
  6014. data.goldExp = val1
  6015. _, val2 := Str2Res(v.MissionExp)
  6016. data.missionExp = val2
  6017. up, _ := Str2Num(v.MissonExpUp)
  6018. data.missonExpUp = data.missionExp * int32(up) / 100
  6019. for _, i2 := range v.MaxLvRewad {
  6020. id, cnt := Str2Res(i2)
  6021. data.maxlvrewads[id] = cnt
  6022. //data.maxlvrewads = append(data.maxlvrewads, &serverproto.KeyValueType{Key: id,Value: cnt})
  6023. }
  6024. DbRuneShopExplore = append(DbRuneShopExplore, data)
  6025. //DbRuneShopExplore[data.round] = data
  6026. }
  6027. sort.Slice(DbRuneShopExplore, func(i, j int) bool {
  6028. return DbRuneShopExplore[i].GetRound() < DbRuneShopExplore[j].GetRound()
  6029. })
  6030. }
  6031. type StRuneShopExploreReward struct {
  6032. lv int32
  6033. round int32
  6034. exp int32
  6035. rewards map[int32]int32
  6036. cashRewards map[int32]int32
  6037. }
  6038. func (this StRuneShopExploreReward) Exp() int32 {
  6039. return this.exp
  6040. }
  6041. func (this StRuneShopExploreReward) Lvl() int32 {
  6042. return this.lv
  6043. }
  6044. func (this StRuneShopExploreReward) GetAward() map[int32]int32 {
  6045. return this.rewards
  6046. }
  6047. func (this StRuneShopExploreReward) GetCashAward() map[int32]int32 {
  6048. return this.cashRewards
  6049. }
  6050. type StMaxData struct {
  6051. MaxLvl int32
  6052. MaxExp int32
  6053. }
  6054. var DbRuneShopExploreMax = make(map[int32]*StMaxData)
  6055. var DbRuneShopExploreReward = make(map[int32]*StRuneShopExploreReward)
  6056. func convertRuneShopExploreRewardCfg() {
  6057. for _, v := range serverproto.RuneShopExploreRewardCfgLoader {
  6058. data := &StRuneShopExploreReward{lv: v.Lv, round: v.ActiveRound, exp: v.Exp,
  6059. rewards: make(map[int32]int32), cashRewards: make(map[int32]int32)}
  6060. for _, i2 := range v.Reward {
  6061. id, cnt := Str2Res(i2)
  6062. data.rewards[id] = cnt
  6063. //data.rewards = append(data.rewards, &serverproto.KeyValueType{Key: id,Value: cnt})
  6064. }
  6065. for _, i3 := range v.CashReward {
  6066. id, cnt := Str2Res(i3)
  6067. data.cashRewards[id] = cnt
  6068. //data.cashRewards = append(data.cashRewards, &serverproto.KeyValueType{Key: id,Value: cnt})
  6069. }
  6070. DbRuneShopExploreReward[data.round<<16|data.lv] = data
  6071. max, ok := DbRuneShopExploreMax[data.round]
  6072. if !ok {
  6073. max = &StMaxData{}
  6074. }
  6075. max.MaxExp += v.Exp
  6076. if v.Lv > max.MaxLvl {
  6077. max.MaxLvl = v.Lv
  6078. }
  6079. DbRuneShopExploreMax[data.round] = max
  6080. }
  6081. }
  6082. //在线累计时间奖励处理
  6083. type OnlineRewardDayInfoST struct {
  6084. Day int32
  6085. Id int32
  6086. RewardToTalTime int32 //累计时间 s
  6087. RewardList []*serverproto.KeyValueType //奖励列表
  6088. RewardCostCoin int32 //直接获取奖励消耗金币
  6089. }
  6090. var ConvertOnlineRewardList = map[int32][]*OnlineRewardDayInfoST{} //[Day,DayInfo]
  6091. var ConvertOnlineRewardMaxDay int32 = 0
  6092. func convertOnlineTimeRewardCfg() {
  6093. ConvertOnlineRewardList = map[int32][]*OnlineRewardDayInfoST{}
  6094. for _, cfgData := range serverproto.OnlineRewardsCfgLoader {
  6095. rewardInfo := &OnlineRewardDayInfoST{
  6096. Id: cfgData.Id,
  6097. Day: cfgData.Day,
  6098. RewardToTalTime: cfgData.Time,
  6099. RewardCostCoin: cfgData.SpeedUp,
  6100. }
  6101. for idx := 0; idx < len(cfgData.Rewards); idx++ {
  6102. k, v := Str2Res(cfgData.Rewards[idx])
  6103. if k <= 0 || v <= 0 {
  6104. continue
  6105. }
  6106. rewardInfo.RewardList = append(rewardInfo.RewardList, &serverproto.KeyValueType{
  6107. Key: k,
  6108. Value: v,
  6109. })
  6110. }
  6111. ConvertOnlineRewardList[cfgData.Day] = append(ConvertOnlineRewardList[cfgData.Day], rewardInfo)
  6112. if ConvertOnlineRewardMaxDay < cfgData.Day {
  6113. ConvertOnlineRewardMaxDay = cfgData.Day
  6114. }
  6115. }
  6116. //sort
  6117. for key := range ConvertOnlineRewardList {
  6118. sort.Slice(ConvertOnlineRewardList[key], func(i, j int) bool {
  6119. return ConvertOnlineRewardList[key][i].Id <
  6120. ConvertOnlineRewardList[key][j].Id
  6121. })
  6122. }
  6123. }
  6124. type StQualityData struct {
  6125. ItemId int32
  6126. QualityPoint int32
  6127. MaxUse int32
  6128. }
  6129. var DBQualityFruit = map[int32]*StQualityData{}
  6130. func convertQualityFruitCfg() {
  6131. gload, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Quality_Fruit_Item)]
  6132. if !ok {
  6133. panic("GlobalCfg quality Fruit error")
  6134. return
  6135. }
  6136. lis := strings.Split(gload.SVal, ";")
  6137. for _, li := range lis {
  6138. id, value, maxCnt := Str2Res_3(li)
  6139. DBQualityFruit[id] = &StQualityData{id, value, maxCnt}
  6140. }
  6141. }
  6142. type StJobChangeData struct {
  6143. Id int32
  6144. JobType int32
  6145. JobStage int32 //职业阶数
  6146. BeforeJobId int32
  6147. JobBranch int32
  6148. AfterJobIds []int32 // 下一阶职业
  6149. ChangeCond []string // 转职条件
  6150. ItemCosts map[int32]int32
  6151. Skills []int32 // 默认装备技能
  6152. NewSkills []int32
  6153. }
  6154. func (this *StJobChangeData) HasNextJob(jobId int32) bool {
  6155. for _, v := range this.AfterJobIds {
  6156. if jobId != v {
  6157. continue
  6158. }
  6159. return true
  6160. }
  6161. return false
  6162. }
  6163. func (this *StJobChangeData) converRoleData(data *serverproto.JobCfg) *StJobChangeData {
  6164. this.ItemCosts = make(map[int32]int32)
  6165. this.Id = data.Id
  6166. this.JobType = data.JobType
  6167. this.JobStage = data.JobStage
  6168. //this.ChangeCond = data.ChangeCond
  6169. this.BeforeJobId = data.BeforeJobId
  6170. this.JobBranch = data.JobBranch
  6171. for _, v := range data.AfterJobId {
  6172. num, err := Str2Num(v)
  6173. if err != nil {
  6174. continue
  6175. }
  6176. this.AfterJobIds = append(this.AfterJobIds, int32(num))
  6177. }
  6178. for _, v := range data.ItemCost {
  6179. id, cnt := Str2Res(v)
  6180. if id <= 0 || cnt <= 0 {
  6181. continue
  6182. }
  6183. this.ItemCosts[id] = cnt //append(this.ItemCosts, &serverproto.KeyValueType{Key:id,Value: cnt})
  6184. }
  6185. for _, id := range data.SkillIds {
  6186. skillId, _ := Str2Num(id)
  6187. this.Skills = append(this.Skills, int32(skillId))
  6188. }
  6189. for _, s := range data.ChangeCond {
  6190. if len(s) <= 0 {
  6191. continue
  6192. }
  6193. this.ChangeCond = append(this.ChangeCond, s)
  6194. }
  6195. return this
  6196. }
  6197. func (this *StJobChangeData) converParterData(data *serverproto.ParterCfg) *StJobChangeData {
  6198. this.ItemCosts = make(map[int32]int32)
  6199. this.Id = data.ParterId
  6200. this.JobType = data.JobType
  6201. this.JobStage = data.JobStage
  6202. //this.ChangeCond = data.ChangeCond
  6203. this.BeforeJobId = data.BeforeJobId
  6204. this.JobBranch = data.JobBranch
  6205. for _, v := range data.AfterJobId {
  6206. num, err := Str2Num(v)
  6207. if err != nil {
  6208. continue
  6209. }
  6210. this.AfterJobIds = append(this.AfterJobIds, int32(num))
  6211. }
  6212. for _, v := range data.ItemCost {
  6213. id, cnt := Str2Res(v)
  6214. if id <= 0 || cnt <= 0 {
  6215. continue
  6216. }
  6217. this.ItemCosts[id] = cnt //append(this.ItemCosts, &serverproto.KeyValueType{Key:id,Value: cnt})
  6218. }
  6219. for _, id := range data.SkillIds {
  6220. skillId, _ := Str2Res(id)
  6221. this.Skills = append(this.Skills, int32(skillId))
  6222. }
  6223. for _, s := range data.ChangeCond {
  6224. if len(s) <= 0 {
  6225. continue
  6226. }
  6227. this.ChangeCond = append(this.ChangeCond, s)
  6228. }
  6229. return this
  6230. }
  6231. var DBJobChange = map[int32]*StJobChangeData{}
  6232. // 生成职业表Id
  6233. func GetJobChangeKey(isRoleMain bool, jobId int32) int32 {
  6234. key := jobId
  6235. // 伙伴职业Id与主角职业id相同, 伙伴Id增加10倍区分主角职业Id
  6236. if !isRoleMain {
  6237. key *= 10
  6238. }
  6239. return key
  6240. }
  6241. func convertJobChangeCfg() {
  6242. // 临时记录, key值对应技能表中数据,根据组合参数索引出技能Id,保存到DBJobChange结构中
  6243. var tmp = map[int32]*StJobChangeData{}
  6244. var tmpky = map[int32][]*serverproto.KeyValueType{}
  6245. // 生成技能表位移key值 偏移24位:是否主角数据, 偏移16位:职业类型 偏移8位:技能阶数 后八位:分支值
  6246. calcKey := func(jobtype, jobstate, JobBranch int32, roleMain bool) int32 {
  6247. first := int32(1) // 是否是主角表
  6248. if roleMain == true {
  6249. first = 0
  6250. }
  6251. return first<<24 | jobtype<<16 | jobstate<<8 | JobBranch
  6252. }
  6253. //----------------------------------------------------------------------
  6254. for i, cfg := range serverproto.JobCfgLoader {
  6255. db := new(StJobChangeData).converRoleData(cfg)
  6256. DBJobChange[GetJobChangeKey(true, i)] = db
  6257. tmp[calcKey(db.JobType, db.JobStage, db.JobBranch, true)] = db
  6258. }
  6259. for i, cfg := range serverproto.ParterCfgLoader {
  6260. db := new(StJobChangeData).converParterData(cfg)
  6261. DBJobChange[GetJobChangeKey(false, i)] = db
  6262. tmp[calcKey(db.JobType, db.JobStage, db.JobBranch, false)] = db
  6263. }
  6264. // 从主角技能表解析出 对应的职业
  6265. for _, skilldb := range serverproto.SkillTreeCfgLoader {
  6266. key := calcKey(skilldb.JobType, skilldb.JobStage, skilldb.JobBranch, true) // 位移生成 key值
  6267. if _, ok := tmp[key]; ok {
  6268. tmpky[key] = append(tmpky[key], &serverproto.KeyValueType{Key: skilldb.SkillId, Value: skilldb.OpenLevel})
  6269. sort.Slice(tmpky[key], func(i, j int) bool { return tmpky[key][i].Value < tmpky[key][j].Value })
  6270. } else {
  6271. panic("技能解析出错")
  6272. }
  6273. }
  6274. // 从伙伴技能表解析出 对应的职业
  6275. for _, skilldb := range serverproto.ParterSkillTreeCfgLoader {
  6276. key := calcKey(skilldb.JobType, skilldb.JobStage, skilldb.JobBranch, false)
  6277. if _, ok := tmp[key]; ok {
  6278. tmpky[key] = append(tmpky[key], &serverproto.KeyValueType{Key: skilldb.SkillId, Value: skilldb.OpenLevel})
  6279. sort.Slice(tmpky[key], func(i, j int) bool { return tmpky[key][i].Value < tmpky[key][j].Value })
  6280. } else {
  6281. panic("伙伴技能解析出错")
  6282. }
  6283. }
  6284. // 根据等级排序写入对应职业
  6285. for i, types := range tmpky {
  6286. data, _ := tmp[i]
  6287. for _, valueType := range types {
  6288. data.NewSkills = append(data.NewSkills, valueType.Key)
  6289. }
  6290. }
  6291. }
  6292. type ConvertSysRewardData struct {
  6293. TowerLevel int32
  6294. RewardList map[int32]int32
  6295. }
  6296. var ConvertSysRewardList []*ConvertSysRewardData
  6297. func convertSysRewardCfg() {
  6298. for key, val := range serverproto.SysRewardLoader {
  6299. convertData := &ConvertSysRewardData{
  6300. TowerLevel: key,
  6301. RewardList: map[int32]int32{},
  6302. }
  6303. for idx := 0; idx < len(val.Reward); idx++ {
  6304. rewardId, _ := Str2Num(val.Reward[idx])
  6305. if rewardId > 0 {
  6306. convertData.RewardList[int32(rewardId)]++
  6307. }
  6308. }
  6309. ConvertSysRewardList = append(ConvertSysRewardList, convertData)
  6310. }
  6311. sort.Slice(ConvertSysRewardList, func(i, j int) bool {
  6312. return ConvertSysRewardList[i].TowerLevel < ConvertSysRewardList[j].TowerLevel
  6313. })
  6314. }
  6315. //占星
  6316. type ConvertDevine struct {
  6317. StarCount int32
  6318. NormalRate int32
  6319. SpecialRate int32
  6320. ItemCost map[int32]int32
  6321. GoldCost map[int32]int32
  6322. RewardList map[int32]int32
  6323. LuckyTicket int32
  6324. TicketCount int32
  6325. ScoreId int32
  6326. ScorePoint int32
  6327. BroadCast int32
  6328. }
  6329. var ConvertCompetitionDevine = map[int32]*ConvertDevine{}
  6330. func convertCompetitionDevineCfg() {
  6331. for _, data := range serverproto.CompetitionDevineCfgLoader {
  6332. convertData := &ConvertDevine{
  6333. StarCount: data.NowLightNum,
  6334. NormalRate: data.Probability,
  6335. SpecialRate: data.PledgeProbability,
  6336. }
  6337. convertData.ItemCost = make(map[int32]int32)
  6338. convertData.GoldCost = make(map[int32]int32)
  6339. convertData.RewardList = make(map[int32]int32)
  6340. for _, item := range data.ItemPrice {
  6341. itemId, itemNum := Str2Res(item)
  6342. if itemId != 0 && itemNum != 0 {
  6343. convertData.ItemCost[itemId] += itemNum
  6344. }
  6345. }
  6346. for _, item := range data.GoldPrice {
  6347. itemId, itemNum := Str2Res(item)
  6348. if itemId != 0 && itemNum != 0 {
  6349. convertData.GoldCost[itemId] += itemNum
  6350. }
  6351. }
  6352. for _, item := range data.Rewards {
  6353. itemId, itemNum := Str2Res(item)
  6354. if itemId != 0 && itemNum != 0 {
  6355. convertData.RewardList[itemId] += itemNum
  6356. }
  6357. }
  6358. if len(data.LuckyPrice) > 0 {
  6359. luckId, luckyNum := Str2Res(data.LuckyPrice[0])
  6360. convertData.LuckyTicket = luckId
  6361. convertData.TicketCount = luckyNum
  6362. }
  6363. if len(data.Point) > 0 {
  6364. scoreId, scoreNum := Str2Res(data.Point[0])
  6365. convertData.ScoreId = scoreId
  6366. convertData.ScorePoint = scoreNum
  6367. }
  6368. convertData.BroadCast = data.IfBroadcast
  6369. ConvertCompetitionDevine[data.NowLightNum] = convertData
  6370. }
  6371. }
  6372. var ConvertYuanHangTrail = map[int32]*ConvertYuanHangTrialData{}
  6373. var ConvertYuanHangMaxShipLevel int32 = 0
  6374. type ConvertYuanHangTrialData struct {
  6375. ShipLevel int32 //type id
  6376. Duration int32 //s
  6377. ConsumeSpecialItemList map[int32]int32 //特殊道具消耗
  6378. ConsumeNormalList map[int32]int32 //普通金币消耗
  6379. ShipRefreshSuccessRate int //100 rate
  6380. ShipRefreshTopLevelCost []*serverproto.KeyValueType //直接升级到顶级消耗(根据列表优先级消耗)
  6381. ShipRewardList map[int32]int32
  6382. BeAttackNum int32 //被攻击丢失奖励次数
  6383. BeAttackScore int32
  6384. BeAttackRewardList map[int32]int32
  6385. BeAttackRewardListSlice []*serverproto.KeyValueType
  6386. BeAttackLoseItemList map[int32]int32 //被打劫损失奖励
  6387. BeAttackLoseItemListSlice []*serverproto.KeyValueType
  6388. }
  6389. func (this *ConvertYuanHangTrialData) RefreshShip(force bool) (int32, serverproto.ErrorCode) {
  6390. if force {
  6391. return ConvertYuanHangMaxShipLevel, serverproto.ErrorCode_ERROR_OK
  6392. }
  6393. if this.ShipRefreshSuccessRate <= 0 {
  6394. return this.ShipLevel, serverproto.ErrorCode_ERROR_CROSS_YUANHANGTRIAL_TOP_SHIPLEVEL
  6395. }
  6396. randNum := rand.Intn(100) + 1
  6397. if randNum <= this.ShipRefreshSuccessRate {
  6398. return this.ShipLevel + 1, serverproto.ErrorCode_ERROR_OK
  6399. }
  6400. return this.ShipLevel, serverproto.ErrorCode_ERROR_CROSS_YUANHANGTRIAL_REFRESH_FAILED
  6401. }
  6402. func convertYuanHangTrailCfg() {
  6403. for _, data := range serverproto.TransportCfgLoader {
  6404. trailItem := &ConvertYuanHangTrialData{
  6405. ShipLevel: data.ShipLevel,
  6406. Duration: data.Duration * 60,
  6407. ShipRefreshSuccessRate: int(data.Probability),
  6408. BeAttackNum: data.RobberyTimes,
  6409. BeAttackScore: data.RobberyFraction,
  6410. ConsumeSpecialItemList: map[int32]int32{},
  6411. ConsumeNormalList: map[int32]int32{},
  6412. ShipRewardList: map[int32]int32{},
  6413. BeAttackRewardList: map[int32]int32{},
  6414. BeAttackLoseItemList: map[int32]int32{},
  6415. }
  6416. if len(data.Consume) >= 1 {
  6417. k, v := Str2Res(data.Consume[0])
  6418. if k > 0 && v > 0 {
  6419. trailItem.ConsumeSpecialItemList[k] += v
  6420. }
  6421. }
  6422. if len(data.Consume) >= 2 {
  6423. k, v := Str2Res(data.Consume[1])
  6424. if k > 0 && v > 0 {
  6425. trailItem.ConsumeNormalList[k] += v
  6426. }
  6427. }
  6428. trailItem.ShipRefreshTopLevelCost = Str2ResSliceList(data.TopLevel)
  6429. Str2ResMapList(data.TranspoertReward, trailItem.ShipRewardList)
  6430. Str2ResMapList(data.RobberyReward, trailItem.BeAttackRewardList)
  6431. for _, str := range data.RobberyReward {
  6432. k, v := Str2Res(str)
  6433. if k > 0 && v > 0 {
  6434. trailItem.BeAttackRewardListSlice = append(trailItem.BeAttackRewardListSlice,
  6435. &serverproto.KeyValueType{Key: k, Value: v})
  6436. }
  6437. }
  6438. Str2ResMapList(data.RobberyLose, trailItem.BeAttackLoseItemList)
  6439. for _, str := range data.RobberyLose {
  6440. k, v := Str2Res(str)
  6441. if k > 0 && v > 0 {
  6442. trailItem.BeAttackLoseItemListSlice = append(trailItem.BeAttackLoseItemListSlice,
  6443. &serverproto.KeyValueType{Key: k, Value: v})
  6444. }
  6445. }
  6446. ConvertYuanHangTrail[trailItem.ShipLevel] = trailItem
  6447. if data.ShipLevel > ConvertYuanHangMaxShipLevel {
  6448. ConvertYuanHangMaxShipLevel = data.ShipLevel
  6449. }
  6450. }
  6451. }
  6452. type StDbKingTaskData struct {
  6453. TaskIds []int32 `csv:"TaskIds"` //成长任务
  6454. DailyTaskIds []int32 `csv:"DailyTaskIds"` //今日挑战
  6455. ActivitiesId int32 `csv:"ActivitiesId"` //活动Id
  6456. }
  6457. var ConvertKingTask = map[int32]map[int32]*StDbKingTaskData{}
  6458. func GetKingTaskData(AvtivitiesId, day int32) *StDbKingTaskData {
  6459. avt, ok := ConvertKingTask[AvtivitiesId]
  6460. if !ok {
  6461. return nil
  6462. }
  6463. data, ok := avt[day]
  6464. if !ok {
  6465. return nil
  6466. }
  6467. return data
  6468. }
  6469. func convertActivitiesKingTaskCfg() {
  6470. for _, data := range serverproto.ActivitiesKingTaskCfgLoader {
  6471. taskItem := &StDbKingTaskData{ActivitiesId: data.ActivitiesId}
  6472. for _, id := range data.TaskIds {
  6473. taskId, err := Str2Num(id)
  6474. if err != nil {
  6475. panic("convertActivitiesKingTask TaskIds err")
  6476. }
  6477. taskItem.TaskIds = append(taskItem.TaskIds, int32(taskId))
  6478. }
  6479. for _, id := range data.DailyTaskIds {
  6480. taskId, err := Str2Num(id)
  6481. if err != nil {
  6482. panic("convertActivitiesKingTask DailyTaskIds err")
  6483. }
  6484. taskItem.DailyTaskIds = append(taskItem.DailyTaskIds, int32(taskId))
  6485. }
  6486. maptmp, ok := ConvertKingTask[data.ActivitiesId]
  6487. if !ok {
  6488. maptmp = make(map[int32]*StDbKingTaskData)
  6489. ConvertKingTask[data.ActivitiesId] = maptmp
  6490. }
  6491. maptmp[data.Day] = taskItem
  6492. }
  6493. }
  6494. type MatchSection struct {
  6495. LevelRank int32
  6496. LeftSection int32
  6497. RightSection int32
  6498. }
  6499. func (this *MatchSection) InSection(val int32) bool {
  6500. if this.LeftSection <= val &&
  6501. this.RightSection >= val {
  6502. return true
  6503. }
  6504. return false
  6505. }
  6506. type TopTowerData struct {
  6507. SelfRankSection *MatchSection
  6508. MatchSection []*MatchSection
  6509. }
  6510. type TopTowerRewardData struct {
  6511. ForceWinCostList map[int32]int32
  6512. Idx int32
  6513. WinRewardList map[int32]int32
  6514. }
  6515. var ConvertTopTowerDataList []*TopTowerData
  6516. var ConvertTopTowerRewardList []*TopTowerRewardData
  6517. func convertTopTowerCfg() {
  6518. for _, data := range serverproto.TopTowerCfgLevelLoader {
  6519. rankInfo := &TopTowerData{}
  6520. rankInfo.SelfRankSection = convertTopTowerSectionCfg(data.RankId, 0)
  6521. rankInfo.MatchSection = append(rankInfo.MatchSection,
  6522. convertTopTowerSectionCfg(data.LevelRank1, 1),
  6523. convertTopTowerSectionCfg(data.LevelRank2, 2),
  6524. convertTopTowerSectionCfg(data.LevelRank3, 3),
  6525. convertTopTowerSectionCfg(data.LevelRank4, 4),
  6526. convertTopTowerSectionCfg(data.LevelRank5, 5),
  6527. convertTopTowerSectionCfg(data.LevelRank6, 6),
  6528. convertTopTowerSectionCfg(data.LevelRank7, 7),
  6529. convertTopTowerSectionCfg(data.LevelRank8, 8),
  6530. convertTopTowerSectionCfg(data.LevelRank9, 9),
  6531. convertTopTowerSectionCfg(data.LevelRank10, 10))
  6532. ConvertTopTowerDataList = append(ConvertTopTowerDataList, rankInfo)
  6533. }
  6534. for _, data := range serverproto.TopTowerCfgRewardLoader {
  6535. rewardData := &TopTowerRewardData{
  6536. Idx: data.LevelId,
  6537. ForceWinCostList: map[int32]int32{},
  6538. WinRewardList: map[int32]int32{},
  6539. }
  6540. Str2ResMapList(data.BuyRoadCost, rewardData.ForceWinCostList)
  6541. Str2ResMapList(data.RewardItems, rewardData.WinRewardList)
  6542. ConvertTopTowerRewardList = append(ConvertTopTowerRewardList, rewardData)
  6543. }
  6544. }
  6545. func convertTopTowerSectionCfg(sectionStr []string, idx int32) *MatchSection {
  6546. tmpMatchSection := &MatchSection{}
  6547. v1, _ := Str2Num(sectionStr[0])
  6548. v2, _ := Str2Num(sectionStr[1])
  6549. tmpMatchSection.LeftSection = int32(v1)
  6550. tmpMatchSection.RightSection = int32(v2)
  6551. tmpMatchSection.LevelRank = idx
  6552. return tmpMatchSection
  6553. }
  6554. type StDbHeadData struct {
  6555. HeadId int32
  6556. HeadType int32
  6557. ContinueTime int32 // 时长 (小时)
  6558. BRestTask bool // 每日重置任务
  6559. Attr []*serverproto.KeyValueType
  6560. Condition map[int32][]int32 // 任务条件
  6561. ActivateItem map[int32]int32 // 激活消耗
  6562. }
  6563. var DbHeadData = map[int32]*StDbHeadData{}
  6564. func convertHeadDataCfg() {
  6565. for _, cfg := range serverproto.DesignationCfgLoader {
  6566. taskItem := &StDbHeadData{HeadId: cfg.ID, HeadType: cfg.Type, Condition: map[int32][]int32{}, ActivateItem: map[int32]int32{}, ContinueTime: cfg.Time}
  6567. if cfg.RefreshDaily > 0 {
  6568. taskItem.BRestTask = true
  6569. } else {
  6570. taskItem.BRestTask = false
  6571. }
  6572. for _, s := range cfg.Attribute {
  6573. k, v := Str2Res(s)
  6574. taskItem.Attr = append(taskItem.Attr, &serverproto.KeyValueType{Key: k, Value: v})
  6575. }
  6576. for _, v := range cfg.TaskCondition {
  6577. valueList := strings.Split(v, ":")
  6578. if len(valueList) >= 2 {
  6579. taskType, _ := Str2Num(valueList[0])
  6580. taskItem.Condition[int32(taskType)] = append(taskItem.Condition[int32(taskType)], int32(taskType))
  6581. for i := 1; i < len(valueList); i++ {
  6582. taskValue, _ := Str2Num(valueList[i])
  6583. taskItem.Condition[int32(taskType)] = append(taskItem.Condition[int32(taskType)], int32(taskValue))
  6584. }
  6585. }
  6586. }
  6587. for _, s := range cfg.TaskConditionItem {
  6588. if len(s) <= 0 {
  6589. continue
  6590. }
  6591. k, v := Str2Res(s)
  6592. taskItem.ActivateItem[k] = v
  6593. }
  6594. DbHeadData[taskItem.HeadId] = taskItem
  6595. }
  6596. }
  6597. type DemonRewardData struct {
  6598. Level int32
  6599. StageMax uint64
  6600. StageMin uint64
  6601. Reward []*serverproto.KeyValueType
  6602. }
  6603. type GuildDemonData struct {
  6604. ConfigId int32
  6605. DemonId int32
  6606. DemonLevel int32
  6607. StartDay int32
  6608. EndDay int32
  6609. WeekDay int32
  6610. ChallengeCount int32 //免费战斗次数
  6611. BuyChallengeCount int32 //最大购买次数
  6612. ChallengePrice map[int32]*serverproto.KeyValueType
  6613. StartTime string
  6614. RewardStage []*DemonRewardData
  6615. BaseReward map[int32]int32
  6616. }
  6617. type GuildWeekDemonData struct {
  6618. DemonData []*GuildDemonData
  6619. }
  6620. var ConvertGuildDemon = map[int32]*GuildWeekDemonData{}
  6621. func convertGuildDemonCfg() {
  6622. for _, data := range serverproto.GuildDemonCfgLoader {
  6623. if data.Id == 0 {
  6624. continue
  6625. }
  6626. _, ok := ConvertGuildDemon[data.WeekDay]
  6627. if !ok {
  6628. ConvertGuildDemon[data.WeekDay] = &GuildWeekDemonData{}
  6629. }
  6630. convertData := &GuildDemonData{
  6631. ConfigId: data.Id,
  6632. DemonId: data.Id,
  6633. WeekDay: data.WeekDay,
  6634. ChallengeCount: data.FreeChallenge,
  6635. BuyChallengeCount: data.ChallengeTimes,
  6636. StartTime: data.SummonTime,
  6637. DemonLevel: data.BossLevel,
  6638. BaseReward: map[int32]int32{},
  6639. }
  6640. if len(data.BossLvCycle) >= 1 {
  6641. start, end := Str2Res(data.BossLvCycle[0])
  6642. convertData.StartDay = int32(start)
  6643. convertData.EndDay = int32(end)
  6644. }
  6645. damageList := strings.Split(data.DamageSegment, ";")
  6646. if len(damageList) != len(data.DamageReward)+1 {
  6647. util.InfoF("convertGuildDemonCfg boss config reward bossId:%v error: %v %v", data.Id, len(damageList), len(data.DamageReward))
  6648. panic("convertGuildDemonCfg boss config reward error")
  6649. }
  6650. for i := 0; i < len(data.DamageReward); i++ {
  6651. convertReward := &DemonRewardData{}
  6652. damage := strings.Split(damageList[i+1], ":")
  6653. if len(damage) >= 2 {
  6654. level, _ := Str2Num(damage[0])
  6655. minDamage, _ := Str2NumU64(damage[1])
  6656. maxDamage, _ := Str2NumU64(damage[2])
  6657. convertReward.StageMax = maxDamage
  6658. convertReward.StageMin = minDamage
  6659. convertReward.Level = int32(level)
  6660. }
  6661. //todo 解析伤害区间
  6662. //解析奖励
  6663. reward := strings.Split(data.DamageReward[i], ":")
  6664. if len(reward) >= 2 {
  6665. itemId, itemNum := Str2Res(data.DamageReward[i])
  6666. convertReward.Reward = append(convertReward.Reward, &serverproto.KeyValueType{
  6667. Key: itemId,
  6668. Value: itemNum,
  6669. })
  6670. }
  6671. convertData.RewardStage = append(convertData.RewardStage, convertReward)
  6672. }
  6673. convertData.ChallengePrice = make(map[int32]*serverproto.KeyValueType)
  6674. for _, baseReward := range data.ChallengeReward {
  6675. itemId, itemNum := Str2Res(baseReward)
  6676. convertData.BaseReward[itemId] += itemNum
  6677. }
  6678. startIndex := int32(1)
  6679. for _, priceData := range data.ChallengePrice {
  6680. itemId, itemNum := Str2Res(priceData)
  6681. convertData.ChallengePrice[startIndex] = &serverproto.KeyValueType{
  6682. Key: itemId,
  6683. Value: itemNum,
  6684. }
  6685. startIndex++
  6686. }
  6687. ConvertGuildDemon[data.WeekDay].DemonData = append(ConvertGuildDemon[data.WeekDay].DemonData, convertData)
  6688. //util.InfoF("[GetDemonInfo] get guildDemon config [%v] data:%v", int32(data.Id), convertData)
  6689. }
  6690. }
  6691. func GetDemonDataByConfigId(configId int32) *GuildDemonData {
  6692. for _, weekDemon := range ConvertGuildDemon {
  6693. for _, demon := range weekDemon.DemonData {
  6694. if configId == demon.DemonId {
  6695. return demon
  6696. }
  6697. }
  6698. }
  6699. return nil
  6700. }
  6701. //(int32, int32):(bossId, bossLevel)
  6702. func GetDemonInfo(weekDay int32, curTime time.Time) (*GuildDemonData, int32) {
  6703. curWeekDay := weekDay
  6704. // curTime := util.GetCurrentTimeNow()
  6705. if curTime.Hour() <= 4 {
  6706. curWeekDay--
  6707. if curWeekDay == 0 {
  6708. curWeekDay = 7
  6709. }
  6710. }
  6711. startUpTime := service.GetServiceStartupTime()
  6712. curServerDay := util.GetDurationDay2(startUpTime, uint64(util.GetTimeMilliseconds()))
  6713. guildDemon, ok := ConvertGuildDemon[int32(curWeekDay)]
  6714. if !ok {
  6715. util.InfoF("[GetDemonInfo] get guildDemon config [%v] ", int32(curWeekDay))
  6716. return nil, 0
  6717. }
  6718. demonData := &GuildDemonData{}
  6719. maxStartDay := int32(0)
  6720. for _, data := range guildDemon.DemonData {
  6721. if data.StartDay <= curServerDay && curServerDay <= data.EndDay {
  6722. return data, curServerDay
  6723. }
  6724. if maxStartDay <= data.StartDay {
  6725. maxStartDay = data.StartDay
  6726. demonData = data
  6727. }
  6728. }
  6729. return demonData, curServerDay
  6730. }
  6731. //nextRefreshTime下次刷新的时间戳,取前一天的相关数据
  6732. func GetDemonInfoByTimeStamp(nextRefreshTime uint64) *GuildDemonData {
  6733. nowTime := util.GetTimeByUint64(nextRefreshTime - 24*3600*1000)
  6734. curWeekDay := nowTime.Weekday()
  6735. if curWeekDay == 0 {
  6736. curWeekDay = 7
  6737. }
  6738. if nowTime.Hour() <= 4 {
  6739. curWeekDay--
  6740. if curWeekDay == 0 {
  6741. curWeekDay = 7
  6742. }
  6743. }
  6744. startUpTime := service.GetServiceStartupTime()
  6745. curServerDay := util.GetDurationDay1(startUpTime, nextRefreshTime)
  6746. guildDemon, ok := ConvertGuildDemon[int32(curWeekDay)]
  6747. if !ok {
  6748. util.InfoF("[GetDemonInfo] get guildDemon config [%v] ", int32(curWeekDay))
  6749. return nil
  6750. }
  6751. demonData := &GuildDemonData{}
  6752. maxStartDay := int32(0)
  6753. for _, data := range guildDemon.DemonData {
  6754. if data.StartDay <= curServerDay && curServerDay <= data.EndDay {
  6755. return data
  6756. }
  6757. if maxStartDay <= data.StartDay {
  6758. maxStartDay = data.StartDay
  6759. demonData = data
  6760. }
  6761. }
  6762. return demonData
  6763. }
  6764. type ActivitySignInData struct {
  6765. SignDay int32
  6766. IsDouble int32
  6767. VipLevel int32
  6768. ActivityId int32
  6769. RewardList map[int32]int32
  6770. }
  6771. type ActivitySignIn struct {
  6772. SignData map[int32]*ActivitySignInData
  6773. }
  6774. var ConvertActivitySignIn = map[int32]*ActivitySignIn{}
  6775. func convertActivitySignInCfg() {
  6776. for _, data := range serverproto.ActivitiesSignInCfgLoader {
  6777. _, ok := ConvertActivitySignIn[data.ActivitiesId]
  6778. if !ok {
  6779. convertData := &ActivitySignIn{
  6780. SignData: map[int32]*ActivitySignInData{},
  6781. }
  6782. ConvertActivitySignIn[data.ActivitiesId] = convertData
  6783. }
  6784. signData := &ActivitySignInData{
  6785. RewardList: map[int32]int32{},
  6786. }
  6787. signData.VipLevel = data.VipLevel
  6788. signData.IsDouble = data.SignInType
  6789. signData.SignDay = data.Day
  6790. signData.ActivityId = data.ActivitiesId
  6791. for _, reward := range data.SignInReward {
  6792. itemId, itemCount := Str2Res(reward)
  6793. signData.RewardList[itemId] += itemCount
  6794. }
  6795. ConvertActivitySignIn[data.ActivitiesId].SignData[data.Day] = signData
  6796. }
  6797. }
  6798. type IdolBoxData struct {
  6799. Level int32
  6800. BoxCount int32
  6801. TicketCount int32
  6802. Reward []*serverproto.KeyValueType
  6803. }
  6804. var ConvertIdolBoxData = map[int32]*IdolBoxData{}
  6805. func convertIdolSeasonCfg() {
  6806. //解析馈赠宝箱
  6807. for _, data := range serverproto.CompetitionAidouluCfgLoader {
  6808. convertData := &IdolBoxData{
  6809. Level: data.BoxId,
  6810. BoxCount: data.GoodNum,
  6811. TicketCount: data.ConditionHot,
  6812. }
  6813. for _, reward := range data.Rewards {
  6814. itemId, itemNum := Str2Res(reward)
  6815. if itemNum > 0 {
  6816. convertData.Reward = append(convertData.Reward, &serverproto.KeyValueType{
  6817. Key: itemId,
  6818. Value: itemNum,
  6819. })
  6820. }
  6821. }
  6822. ConvertIdolBoxData[data.BoxId] = convertData
  6823. }
  6824. }
  6825. type StProbRewardData struct {
  6826. Weight int32
  6827. ItemId int32
  6828. ItemCnt int32
  6829. WaitTime int32
  6830. }
  6831. type StDbWishBox struct {
  6832. IsRand bool
  6833. ItemId int32
  6834. BoxType int32 // 类型
  6835. WaitTime int32 // 倒计时
  6836. LuckyProb int32 // 暴击概率
  6837. SpeedCost serverproto.KeyValueType // 加速消耗
  6838. RewardList []*StProbRewardData // 许愿奖励
  6839. LuckyReward []*StProbRewardData // 暴击奖励
  6840. }
  6841. func (this StDbWishBox) GetRewardItem(itemId int32) (ret *StProbRewardData) {
  6842. for _, i2 := range this.RewardList {
  6843. if i2.ItemId != itemId {
  6844. continue
  6845. }
  6846. ret = i2
  6847. break
  6848. }
  6849. return
  6850. }
  6851. func (this StDbWishBox) GetRandRewardItem() (ret *StProbRewardData) {
  6852. total := this.RewardList[len(this.RewardList)-1].Weight
  6853. value := rand.Int31n(total)
  6854. for _, i2 := range this.RewardList {
  6855. if value > i2.Weight {
  6856. continue
  6857. }
  6858. ret = i2
  6859. break
  6860. }
  6861. return
  6862. }
  6863. var ConvertWishBoxData = map[int32]*StDbWishBox{}
  6864. func convertWishCfg() {
  6865. for _, data := range serverproto.WishCfgLoader {
  6866. dbData := &StDbWishBox{ItemId: data.Id, BoxType: data.BoxType, WaitTime: data.WishCountdown, LuckyProb: data.LuckyProbability}
  6867. initWeight := int32(0)
  6868. for _, i2 := range data.WishReward {
  6869. rewardItem := strings.Split(i2, ":")
  6870. if len(rewardItem) < 3 {
  6871. panic("许愿表配置奖励错误")
  6872. }
  6873. weight, itemId, itemcnt := Str2Res_3(i2)
  6874. initWeight += weight
  6875. dbData.RewardList = append(dbData.RewardList, &StProbRewardData{Weight: int32(initWeight), ItemId: int32(itemId), ItemCnt: int32(itemcnt), WaitTime: data.WishCountdown})
  6876. }
  6877. sort.Slice(dbData.RewardList, func(i, j int) bool {
  6878. return dbData.RewardList[i].Weight < dbData.RewardList[j].Weight
  6879. })
  6880. if initWeight > 0 {
  6881. dbData.IsRand = true
  6882. }
  6883. initWeight = 0
  6884. for _, i2 := range data.LuckyReward {
  6885. rewardItem := strings.Split(i2, ":")
  6886. if len(rewardItem) < 3 {
  6887. panic("许愿表配置暴击奖励错误")
  6888. }
  6889. weight, itemId, itemcnt := Str2Res_3(i2)
  6890. initWeight += weight
  6891. dbData.LuckyReward = append(dbData.LuckyReward, &StProbRewardData{Weight: int32(initWeight), ItemId: int32(itemId), ItemCnt: int32(itemcnt), WaitTime: data.WishCountdown})
  6892. }
  6893. sort.Slice(dbData.LuckyReward, func(i, j int) bool {
  6894. return dbData.LuckyReward[i].Weight < dbData.LuckyReward[j].Weight
  6895. })
  6896. for _, i2 := range data.AccelerateCost {
  6897. dbData.SpeedCost.Key, dbData.SpeedCost.Value = Str2Res(i2)
  6898. }
  6899. ConvertWishBoxData[data.Id] = dbData
  6900. }
  6901. }
  6902. type CombineServer struct {
  6903. Id int32
  6904. ServerList []*serverproto.KeyValueType
  6905. CombineTime uint64
  6906. Notice string
  6907. }
  6908. var ConvertCombineServerData = map[int32]*CombineServer{}
  6909. func ConvertCombinedServer() {
  6910. //热跟新的时候需要重新处理
  6911. ConvertCombineServerData = make(map[int32]*CombineServer)
  6912. for _, data := range serverproto.CombinedServiceCfgLoader {
  6913. combineData := &CombineServer{}
  6914. combineData.Id = data.Id
  6915. loc := util.GetLoc()
  6916. if data.Time != "" {
  6917. sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.Time, loc)
  6918. if err1 != nil {
  6919. util.PanicF("combineData endTime err:%v", err1)
  6920. }
  6921. combineData.CombineTime = uint64(sTime.UnixNano() / 1e6)
  6922. }
  6923. for _, servers := range data.Number {
  6924. start, end := Str2Res(servers)
  6925. combineData.ServerList = append(combineData.ServerList, &serverproto.KeyValueType{
  6926. Key: start,
  6927. Value: end,
  6928. })
  6929. }
  6930. combineData.Notice = data.Tips
  6931. ConvertCombineServerData[data.Id] = combineData
  6932. }
  6933. }
  6934. func CheckInCombined(zoneId int32) (bool, uint64) {
  6935. data, ok := ConvertCombineServerData[1]
  6936. if !ok {
  6937. return false, 0
  6938. }
  6939. /*
  6940. nowTime := util.GetCurrentTime()
  6941. if data.CombineTime > nowTime {
  6942. return false
  6943. }
  6944. */
  6945. for _, server := range data.ServerList {
  6946. if server.Key <= zoneId && zoneId <= server.Value {
  6947. return true, data.CombineTime
  6948. }
  6949. }
  6950. return false, 0
  6951. }
  6952. // bt版本服务器配置文件处理
  6953. type CfgBoliVipData struct {
  6954. Id int32
  6955. VipExp int32 // 升级到下一级需要经验
  6956. VipRight map[int32]int32 // 特权
  6957. DayReward []*serverproto.KeyValueType
  6958. }
  6959. type CfgBoliShopData struct {
  6960. ShopItem *serverproto.ShopItem
  6961. Conditions []*serverproto.KeyValueType
  6962. GoodsItem int32
  6963. PayForType int32
  6964. PayForNum int32
  6965. DiscountPayForNum int32
  6966. }
  6967. var ConvertBoliVipData = map[int32]*CfgBoliVipData{}
  6968. var ConvertBoliShopData = map[int32][]*CfgBoliShopData{} // level,[]CfgBoliShopData
  6969. var ConvertBoliShopDataById = map[int32]*CfgBoliShopData{} // cfgId,CfgBoliShopData
  6970. func convertBtBoliCfg() {
  6971. //bolivip
  6972. for _, cfgData := range serverproto.BoliVipCfgLoader {
  6973. tmpData := &CfgBoliVipData{
  6974. Id: cfgData.Lv,
  6975. VipExp: cfgData.VipExp,
  6976. VipRight: map[int32]int32{},
  6977. }
  6978. tmpData.VipRight[Vip_System_Levelup] = cfgData.VipExp
  6979. tmpData.VipRight[Vip_System_Evil] = cfgData.EvilFreeTimes
  6980. tmpData.VipRight[Vip_System_PetAdvance] = cfgData.PetAdvance
  6981. tmpData.VipRight[Vip_System_CardReset] = cfgData.CardReset
  6982. tmpData.VipRight[Vip_System_PetDesolve] = cfgData.PetBreak
  6983. tmpData.VipRight[Vip_System_SkillReset] = cfgData.SkillReset
  6984. tmpData.VipRight[Vip_System_GuildHunt] = cfgData.GuildBossChallenge
  6985. tmpData.VipRight[Vip_System_Arena] = cfgData.PvpReward
  6986. tmpData.VipRight[Vip_System_DevilsUp] = cfgData.DevilsUp
  6987. tmpData.VipRight[Vip_System_TransportRobbery] = cfgData.TransportRobbery
  6988. tmpData.VipRight[Vip_System_LuxuryPrizeWheelTimes] = cfgData.LuxuryPrizeWheelTimes
  6989. tmpData.DayReward = Str2ResSliceList(cfgData.GiftRewards)
  6990. ConvertBoliVipData[cfgData.Lv] = tmpData
  6991. }
  6992. //bolishop
  6993. for _, cfgData := range serverproto.BoliShopCfgLoader {
  6994. convertData := &CfgBoliShopData{
  6995. ShopItem: &serverproto.ShopItem{
  6996. GoodsId: cfgData.GoodsId,
  6997. Price: cfgData.PayForNum,
  6998. CurPrice: cfgData.DiscountPayForNum,
  6999. Dispercent: cfgData.Proportion,
  7000. Hot: true,
  7001. },
  7002. GoodsItem: cfgData.GoodsItem,
  7003. PayForType: cfgData.PayForType,
  7004. PayForNum: cfgData.PayForNum,
  7005. DiscountPayForNum: cfgData.DiscountPayForNum,
  7006. }
  7007. if cfgData.SellWell <= 0 {
  7008. convertData.ShopItem.Hot = false
  7009. }
  7010. /*
  7011. 1.永久限购
  7012. 2.每天限购
  7013. 3.有效期内限购
  7014. 4.周限购
  7015. 5.刷新类型商店限购(黑市商品不能配置1~4)
  7016. const (
  7017. LIMIT_TYPE_NONE = iota //无限购
  7018. LIMIT_TYPE_FOREVER = 1 //永久限购
  7019. LIMIT_TYPE_DAY = 2 //天限购(限购时间策划配置)
  7020. LIMIT_TYPE_RANGE = 3 //范围限购。比如:从XX-XX
  7021. LIMIT_TYPE_WEEK = 4 //周限购(限购时间策划配置)
  7022. LIMIT_TYPE_SPECIAL = 5 //黑市限购
  7023. LIMIT_TYPE_ARENA = 6 //赛季道具
  7024. LIMIT_MAX
  7025. )
  7026. */
  7027. limitRes := strings.Split(cfgData.RestrictedType, ":")
  7028. if len(limitRes) >= 2 {
  7029. lType, _ := Str2Num(limitRes[0])
  7030. convertData.ShopItem.LimitType = int32(lType)
  7031. if len(limitRes) == 2 {
  7032. lCount, _ := Str2Num(limitRes[1])
  7033. convertData.ShopItem.Count = int32(lCount)
  7034. }
  7035. if len(limitRes) >= 3 {
  7036. lCircle, _ := Str2Num(limitRes[1])
  7037. convertData.ShopItem.Circle = int32(lCircle)
  7038. lCount, _ := Str2Num(limitRes[2])
  7039. convertData.ShopItem.Count = int32(lCount)
  7040. }
  7041. }
  7042. if convertData.ShopItem.LimitType == 3 {
  7043. loc := util.GetLoc()
  7044. if cfgData.BeginTime != "" {
  7045. sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, cfgData.BeginTime, loc)
  7046. if err1 != nil {
  7047. util.PanicF("convertBtCfg startTime err:%v", err1)
  7048. }
  7049. convertData.ShopItem.StartTime = int64(sTime.Unix())
  7050. }
  7051. if cfgData.EndTime != "" {
  7052. cTime, err2 := time.ParseInLocation(util.DATE_FORMAT, cfgData.EndTime, loc)
  7053. if err2 != nil {
  7054. util.PanicF("convertBtCfg endTime err:%v", err2)
  7055. }
  7056. convertData.ShopItem.EndTime = int64(cTime.Unix())
  7057. }
  7058. }
  7059. if len(cfgData.Condition) > 0 {
  7060. for _, cond := range cfgData.Condition {
  7061. condId, condArg := Str2Res(cond)
  7062. if condId != 0 && condArg != 0 {
  7063. convertData.Conditions = append(convertData.Conditions, &serverproto.KeyValueType{
  7064. Key: int32(condId),
  7065. Value: int32(condArg),
  7066. })
  7067. }
  7068. }
  7069. }
  7070. ConvertBoliShopData[cfgData.BoliVipLevel] = append(ConvertBoliShopData[cfgData.BoliVipLevel], convertData)
  7071. ConvertBoliShopDataById[cfgData.GoodsId] = convertData
  7072. }
  7073. }
  7074. type BTRoCoinType int32
  7075. const (
  7076. BTTaskRefreshType_Day BTRoCoinType = iota
  7077. BTTaskRefreshType_Week
  7078. )
  7079. type StActBTRecharge struct {
  7080. Id int32
  7081. Day int32
  7082. RefreshDay BTRoCoinType
  7083. TaskList []int32
  7084. }
  7085. var ConvertBTRechargeData = map[int32][]*StActBTRecharge{}
  7086. var ConvertBTRechargeRoCoinDailyData = map[int32][]*StActBTRecharge{}
  7087. var ConvertBTRechargeRoCoinWeekData = map[int32][]*StActBTRecharge{}
  7088. func convertBTRoCoinRechargeCfg() {
  7089. // 每日累计充值
  7090. //ActiviesTiredChargeCfg 累计充值奖励
  7091. for _, cfgData := range serverproto.ActivitiesBtChargeTaskGoldCfgLoader {
  7092. dbData := &StActBTRecharge{
  7093. Day: cfgData.Day,
  7094. Id: cfgData.Id,
  7095. RefreshDay: BTTaskRefreshType_Day,
  7096. }
  7097. for idx := 0; idx < len(cfgData.DailyTaskIds); idx++ {
  7098. taskId, _ := Str2Num(cfgData.DailyTaskIds[idx])
  7099. if taskId > 0 {
  7100. dbData.TaskList = append(dbData.TaskList, int32(taskId))
  7101. }
  7102. }
  7103. ConvertBTRechargeData[cfgData.ActivitiesId] = append(ConvertBTRechargeData[cfgData.ActivitiesId], dbData)
  7104. }
  7105. for key := range ConvertBTRechargeData {
  7106. sort.Slice(ConvertBTRechargeData[key], func(i, j int) bool {
  7107. return ConvertBTRechargeData[key][i].Day < ConvertBTRechargeData[key][j].Day
  7108. })
  7109. }
  7110. //RO币累计奖励
  7111. for _, cfgData := range serverproto.ActivitiesBtChargeTaskRoMoneyCfgLoader {
  7112. dbDataDaily := &StActBTRecharge{
  7113. Day: cfgData.Day,
  7114. Id: cfgData.Id,
  7115. RefreshDay: BTTaskRefreshType_Week,
  7116. }
  7117. for idx := 0; idx < len(cfgData.DailyTaskIds); idx++ {
  7118. taskId, _ := Str2Num(cfgData.DailyTaskIds[idx])
  7119. if taskId > 0 {
  7120. dbDataDaily.TaskList = append(dbDataDaily.TaskList, int32(taskId))
  7121. }
  7122. }
  7123. ConvertBTRechargeRoCoinDailyData[cfgData.ActivitiesId] = append(ConvertBTRechargeRoCoinDailyData[cfgData.ActivitiesId], dbDataDaily)
  7124. dbDataWeek := &StActBTRecharge{
  7125. Day: cfgData.Day,
  7126. Id: cfgData.Id,
  7127. RefreshDay: BTTaskRefreshType_Week,
  7128. }
  7129. for idx := 0; idx < len(cfgData.TaskIds); idx++ {
  7130. taskId, _ := Str2Num(cfgData.TaskIds[idx])
  7131. if taskId > 0 {
  7132. dbDataWeek.TaskList = append(dbDataWeek.TaskList, int32(taskId))
  7133. }
  7134. }
  7135. ConvertBTRechargeRoCoinWeekData[cfgData.ActivitiesId] = append(ConvertBTRechargeRoCoinWeekData[cfgData.ActivitiesId], dbDataWeek)
  7136. }
  7137. for key := range ConvertBTRechargeRoCoinDailyData {
  7138. sort.Slice(ConvertBTRechargeRoCoinDailyData[key], func(i, j int) bool {
  7139. return ConvertBTRechargeRoCoinDailyData[key][i].Day < ConvertBTRechargeRoCoinDailyData[key][j].Day
  7140. })
  7141. }
  7142. for key := range ConvertBTRechargeRoCoinWeekData {
  7143. sort.Slice(ConvertBTRechargeRoCoinWeekData[key], func(i, j int) bool {
  7144. return ConvertBTRechargeRoCoinWeekData[key][i].Day < ConvertBTRechargeRoCoinWeekData[key][j].Day
  7145. })
  7146. }
  7147. }
  7148. // RO币累计充值对应天数的数据列表
  7149. func GetActBTROCoinRechargeDayDataList(activityId int32, day int32, dayType BTRoCoinType) (taskList []int32) {
  7150. if dayType == BTTaskRefreshType_Day {
  7151. cfgData, ok := ConvertBTRechargeRoCoinDailyData[activityId]
  7152. if !ok {
  7153. return
  7154. }
  7155. for idx := 0; idx < len(cfgData); idx++ {
  7156. if cfgData[idx].Day > day {
  7157. break
  7158. }
  7159. taskList = cfgData[idx].TaskList
  7160. }
  7161. } else {
  7162. cfgData, ok := ConvertBTRechargeRoCoinWeekData[activityId]
  7163. if !ok {
  7164. return
  7165. }
  7166. for idx := 0; idx < len(cfgData); idx++ {
  7167. if cfgData[idx].Day > day {
  7168. break
  7169. }
  7170. taskList = cfgData[idx].TaskList
  7171. }
  7172. }
  7173. return
  7174. }
  7175. // 每日累计充值
  7176. func GetActBTRechargeDayDataList(activityId int32, day int32) (taskList []int32) {
  7177. cfgData, ok := ConvertBTRechargeData[activityId]
  7178. if !ok {
  7179. return
  7180. }
  7181. for idx := 0; idx < len(cfgData); idx++ {
  7182. if cfgData[idx].Day > day {
  7183. break
  7184. }
  7185. taskList = cfgData[idx].TaskList
  7186. }
  7187. return
  7188. }
  7189. // 超值首充 & 百元大礼包
  7190. type BTRechargeRewardData struct {
  7191. Reward []*serverproto.KeyValueType
  7192. RewardCondition int32
  7193. }
  7194. type ConvertBTFirstRechargeData struct {
  7195. Name string
  7196. OpenConditionList []*serverproto.KeyValueType
  7197. OpenConditionStrList []string
  7198. RechargeAmount float32 //达到该金额解锁首充奖励获取
  7199. RewardList []BTRechargeRewardData
  7200. }
  7201. var ConvertBTFirstRecharge *ConvertBTFirstRechargeData = nil
  7202. var ConvertBTRecharge100 *ConvertBTFirstRechargeData = nil
  7203. func convertBTFirstAnd100RechargeCfg() {
  7204. //超值首充
  7205. if cfgData, ok := serverproto.ActivitiesBtFirstChargeCfgLoader[1]; ok {
  7206. ConvertBTFirstRecharge = &ConvertBTFirstRechargeData{
  7207. OpenConditionStrList: cfgData.OpenCondition,
  7208. }
  7209. ConvertBTFirstRecharge.OpenConditionList = Str2ResSliceList(cfgData.OpenCondition)
  7210. //ConvertBTFirstRecharge.RechargeAmount = cfgData.RechargeAmount
  7211. if len(cfgData.RechargeAmount) < 3 {
  7212. return
  7213. }
  7214. value1, _ := Str2Num(cfgData.RechargeAmount[0])
  7215. ConvertBTFirstRecharge.RewardList = append(ConvertBTFirstRecharge.RewardList, BTRechargeRewardData{
  7216. RewardCondition: int32(value1),
  7217. Reward: Str2ResSliceList(cfgData.Reward1),
  7218. })
  7219. value2, _ := Str2Num(cfgData.RechargeAmount[1])
  7220. ConvertBTFirstRecharge.RewardList = append(ConvertBTFirstRecharge.RewardList, BTRechargeRewardData{
  7221. RewardCondition: int32(value2),
  7222. Reward: Str2ResSliceList(cfgData.Reward2),
  7223. })
  7224. value3, _ := Str2Num(cfgData.RechargeAmount[2])
  7225. ConvertBTFirstRecharge.RewardList = append(ConvertBTFirstRecharge.RewardList, BTRechargeRewardData{
  7226. RewardCondition: int32(value3),
  7227. Reward: Str2ResSliceList(cfgData.Reward3),
  7228. })
  7229. }
  7230. //百元大礼包
  7231. if cfgData, ok := serverproto.ActivitiesBtFirstChargeCfgLoader[2]; ok {
  7232. ConvertBTRecharge100 = &ConvertBTFirstRechargeData{
  7233. OpenConditionStrList: cfgData.OpenCondition,
  7234. Name: cfgData.Name,
  7235. }
  7236. ConvertBTRecharge100.OpenConditionList = Str2ResSliceList(cfgData.OpenCondition)
  7237. if len(cfgData.RechargeAmount) < 0 {
  7238. return
  7239. }
  7240. value0, _ := Str2Num(cfgData.RechargeAmount[0])
  7241. ConvertBTRecharge100.RechargeAmount = float32(value0)
  7242. ConvertBTRecharge100.RewardList = append(ConvertBTRecharge100.RewardList, BTRechargeRewardData{
  7243. Reward: Str2ResSliceList(cfgData.Reward1),
  7244. })
  7245. ConvertBTRecharge100.RewardList = append(ConvertBTRecharge100.RewardList, BTRechargeRewardData{
  7246. Reward: Str2ResSliceList(cfgData.Reward2),
  7247. })
  7248. ConvertBTRecharge100.RewardList = append(ConvertBTRecharge100.RewardList, BTRechargeRewardData{
  7249. Reward: Str2ResSliceList(cfgData.Reward3),
  7250. })
  7251. }
  7252. }