base_config.go 245 KB

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