base_config.go 246 KB

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