| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301 |
- package model
- import (
- "errors"
- "math/rand"
- "reflect"
- "rocommon/service"
- "rocommon/util"
- "roserver/baseserver/set"
- "roserver/serverproto"
- "sort"
- "strconv"
- "strings"
- "time"
- )
- func BaseConfigInit(sConfig service.ConfigServerNode) {
- path := sConfig.Node.Config + "/"
- //不同服务器类型做不同配置文件加载(game服务器加载所有配置文件),内存优化处理
- switch sConfig.Node.Type {
- case SERVICE_NODE_TYPE_BOSS: //battleboss
- serverproto.WorldBossCfgLoad(path + "csv/")
- serverproto.WorldBossChangePlayCfgLoad(path + "csv/")
- serverproto.NpcCfgLoad(path + "csv/")
- convertWorldBossCfg()
- case SERVICE_NODE_TYPE_GUILD: //guild
- serverproto.GuildBossCfgLoad(path + "csv/")
- serverproto.GuildBossRewardCfgLoad(path + "csv/")
- serverproto.GuildWarDojoCfgLoad(path + "csv/")
- serverproto.GuildLvCfgLoad(path + "csv/")
- serverproto.GlobalCfgLoad(path + "csv/")
- serverproto.GuildDemonCfgLoad(path + "csv/")
- serverproto.GuildWarBuffCfgLoad(path + "csv/")
- convertGlobalCfg() //通用全局属性加载
- convertGuildLevelCfg() //公会等级相关
- convertGuildBosRewardsCfg() //公会BOSS奖励
- convertGuildBattleCfg() //公会战
- convertGuildDemonCfg() //公会魔王
- convertGuildWarCfg()
- case SERVICE_NODE_TYPE_DB: //db
- serverproto.PetCfgLoad(path + "csv/")
- convertPetCfg() //pet
- case SERVICE_NODE_TYPE_WEBGM: //gmweb
- //添加到热更新列表中
- serverproto.CFGNameList["AdvertisingScreen"] = serverproto.AdvertisingScreenLoad
- serverproto.CFGNameList["CombinedServiceCfg"] = serverproto.CombinedServiceCfgLoad
- case SERVICE_NODE_TYPE_RANK: //rank
- serverproto.CompetitionCfgLoad(path + "csv/")
- serverproto.HundredDojoCfgLoad(path + "csv/")
- serverproto.RobotCfgLoad(path + "csv/")
- serverproto.RushListCfgLoad(path + "csv/")
- serverproto.RushListTargetCfgLoad(path + "csv/")
- serverproto.GlobalCfgLoad(path + "csv/")
- convertGlobalCfg() //通用全局属性加载
- convertCompetitionCfg() //赛季玩法
- convertRobotCfg()
- convertDaoChang100Cfg() //百人道场
- convertRushListCfg() //冲榜相关
- case SERVICE_NODE_TYPE_CROSSSERVER:
- serverproto.TransportCfgLoad(path + "csv/")
- convertYuanHangTrailCfg() //远航试炼
- case SERVICE_NODE_TYPE_CROSSRANK: //跨服排行榜
- serverproto.TopTowerCfgLevelLoad(path + "csv/")
- serverproto.TopTowerCfgRewardLoad(path + "csv/")
- convertTopTowerCfg()
- case SERVICE_NODE_TYPE_GLOBALCROSSMAP:
- //TODO...
- default:
- //这边添加需要加载的配置文件列表,每个服务器不一样需要手动添加
- //热加载,需要加锁处理
- serverproto.ConfigInit(path + "csv/")
- convertGlobalCfg() //通用全局属性加载
- convertUIFuncUnLockCfg() //功能解锁问题
- //处理配置表数据,提高使用效率
- convertQualityPointCfg()
- convertCardCfg()
- convertDropCfg() //关卡掉落
- convertTaskCfg() //任务数据解析
- convertParterProgressCfg()
- convertParterSkillTreeCfg()
- convertRoleAttributeCfg()
- convertJobAttrCfg()
- convertPartnerAttrCfg()
- convertFashionCfg()
- convertCardAttCfg()
- convertEquipCfg()
- convertEquipRefineCfg()
- convertFightPowerCfg()
- convertEquipSuitCfg()
- //convertSlotCfg() //寻宝数据解析
- convertChangeJobCfg()
- convertCrossRankCfg() //飞艇排行榜奖励
- convertArenaCfg(int32(sConfig.Node.Zone)) //竞技场
- convertRobotCfg() //匹配机器人
- convertWorldBossCfg() //世界boss
- convertSkillUpEffect() //被动技能
- convertCompetitionCfg() //赛季玩法
- convertCompetitionPrizeWheelCfg() //第三赛季转盘
- convertCardResetCfg() //卡片分解
- convertShopCfg() //商店
- convertActiveCodeCfg() //激活码
- convertSignInCfg() //签到
- convertMapCfg() //关卡数据
- convertNatureCfg() //属性对抗处理
- convertTowerCfg() //爬塔奖励
- convertEvilCfg() //恶魔协会
- convertCardCollectCfg() //收集卡片奖励
- // convertVIPCfg() //vip相关次数
- convertPetCfg() //pet
- convertGuildLevelCfg() //公会等级相关
- convertGuildBosRewardsCfg() //公会BOSS奖励
- convertGuildBattleCfg() //公会战
- convertExpeditionCfg() //远征之门
- convertActivitiesCfg() //精彩活动
- convertHeadFrameCfg() //头像框
- convertInvitationCfg() //invitation邀请码
- convertVipCfg() //VIP
- convertSummonCfg() //抽卡
- convertRuneCfg() //卢恩商会
- convertRushListCfg() //冲榜
- convertDaoChang100Cfg() //百人道场
- convertKeepSakeCfg() //藏品
- convertCardSuitNewCfg() //卡片祝福
- covertFashionLevelUpCfg() //时装升级
- convertFashionRandomCfg() //时装洗练
- converFashionSuitCfg() //套装升级
- convertRuneShopExploreCfg() // 战令升级
- convertRuneShopExploreRewardCfg() // 战令
- convertGuildWarCfg() //公会战
- convertOnlineTimeRewardCfg() //累计在线时间奖励获取
- convertQualityFruitCfg() // 潜力果实
- convertJobChangeCfg() // 职业转职
- convertSysRewardCfg() //系统补偿数据表
- convertCompetitionDevineCfg() //占卜
- convertYuanHangTrailCfg() //远航试炼
- convertActivitiesKingTaskCfg() // 国王悬赏 任务
- convertSkillEquipCfg() // 神器
- convertHeadDataCfg() // 称号系统
- convertGuildDemonCfg() //公会魔王
- convertTopTowerCfg() //巅峰之塔
- convertActivitySignInCfg() //活动签到
- convertIdolSeasonCfg() //粉丝馈赠
- convertWishCfg() //许愿宝箱
- ConvertCombinedServer() //合服
- convertTowerWjCfg() //无尽模式
- }
- util.InfoF("config load success!!!")
- }
- // todo...热加载使用
- func ReloadConfig() {
- sConfig := service.GetServiceConfig()
- BaseConfigInit(sConfig)
- util.InfoF("config reloead success!!!")
- }
- func ReloadConfigByName(cfgName string) {
- sConfig := service.GetServiceConfig()
- path := sConfig.Node.Config + "/csv/"
- fuc, ok := serverproto.CFGNameList[cfgName]
- if ok {
- fuc(path)
- //转换数据部分
- switch cfgName {
- case "Transport":
- convertYuanHangTrailCfg()
- }
- }
- }
- var AdvSensitiveUtil *util.DFAUtil = nil
- func LoadAdvSensitiveWords() {
- AdvSensitiveUtil = util.NewDFAUtil(nil)
- for _, val := range serverproto.AdvertisingScreenLoader {
- //valList := strings.Split(val.Type, ",")
- util.DFAInsertWord(AdvSensitiveUtil, []string{val.Type})
- }
- }
- func ReloadAdvSensitiveWords(cfgName string) {
- sConfig := service.GetServiceConfig()
- path := sConfig.Node.Config + "/csv/"
- fuc, ok := serverproto.CFGNameList[cfgName]
- if ok {
- serverproto.AdvertisingScreenLoader = map[int32]*serverproto.AdvertisingScreen{}
- fuc(path)
- LoadAdvSensitiveWords()
- }
- }
- // 功能解锁问题
- func convertUIFuncUnLockCfg() {
- if cfgData, ok := serverproto.UIFuncUnLockCfgLoader[62]; ok {
- if len(cfgData.UnlockCond) <= 0 {
- return
- }
- k, v := Str2Res(cfgData.UnlockCond[0])
- if k <= 0 || v <= 0 {
- return
- }
- if k == int32(serverproto.TaskType_Level_Battle_Count) {
- GlobalDaoChangUnlockMapLevelId = v
- }
- }
- }
- // 转换后的属性点消耗
- var AttrConsumeList = map[int32]int32{}
- func convertQualityPointCfg() {
- //QulityPointCfg
- var idList []int32
- for _, data := range serverproto.QualityPointCfgLoader {
- idList = append(idList, data.Count)
- }
- sort.Slice(idList, func(i, j int) bool {
- return idList[i] < idList[j]
- })
- var count int32 = 1
- AttrConsumeList[count] = 0
- for _, id := range idList {
- cfgData, ok := serverproto.QualityPointCfgLoader[id]
- if ok {
- _, ok := AttrConsumeList[id]
- if !ok {
- util.PanicF("[QulityPointCfg] data error:%v", id-1)
- }
- AttrConsumeList[id+1] = AttrConsumeList[id] + cfgData.Cost
- }
- }
- }
- // 卡片数据
- type CardWeightDat struct {
- CardCfgId int32
- Weight int32
- }
- var CardNormalCfgList []*CardWeightDat
- var CardMiniCfgList []*CardWeightDat
- var CardMvpCfgList []*CardWeightDat
- var CardNormalWeightList []int32
- var CardMiniWeightList []int32
- var CardMvpWeightList []int32
- var ConvertCardList = map[int32]*ConvertCardData{}
- const (
- Card_Type_Normal = 1
- Card_Type_Mini = 2
- Card_Type_MVP = 3
- )
- type ConvertCardData struct {
- CardCfgId int32
- AttrList map[int32]float32
- TriggerBuffList map[int32]*serverproto.TriggerBuffData
- SourceCfgId int32
- }
- type ConvertCardUnlockData struct {
- CardSlotId int32
- ConditionList []*serverproto.KeyValueType
- }
- var ConvertCardUnlock = map[int32]*ConvertCardUnlockData{}
- func convertCardCfg() {
- CardNormalCfgList = []*CardWeightDat{}
- CardMiniCfgList = []*CardWeightDat{}
- CardMvpCfgList = []*CardWeightDat{}
- CardNormalWeightList = []int32{}
- CardMiniWeightList = []int32{}
- CardMvpWeightList = []int32{}
- ConvertCardList = map[int32]*ConvertCardData{}
- curWeight := map[int32]int32{}
- for _, data := range serverproto.CardCfgLoader {
- ConvertCardList[data.CardId] = &ConvertCardData{
- CardCfgId: data.CardId,
- AttrList: map[int32]float32{},
- TriggerBuffList: map[int32]*serverproto.TriggerBuffData{},
- }
- for idx := range data.Attribute1 {
- key, value := Str2Res(data.Attribute1[idx])
- if key > 0 && value > 0 {
- ConvertCardList[data.CardId].AttrList[key] = float32(value)
- }
- }
- for idx := range data.BUFF {
- buffId, rate, cd, triggType := Str2Res_4(data.BUFF[idx])
- if buffId > 0 {
- ConvertCardList[data.CardId].TriggerBuffList[buffId] = &serverproto.TriggerBuffData{
- BuffId: uint32(buffId),
- TriggerRatio: float32(rate) * 0.01,
- Cd: float32(cd),
- TriggerType: triggType,
- }
- }
- }
- if data.CardLevel > 1 {
- continue
- }
- weight, _ := curWeight[data.CardType]
- weight += data.Pro
- cardData := &CardWeightDat{
- CardCfgId: data.CardId,
- Weight: weight,
- }
- switch data.CardType {
- case Card_Type_Normal:
- CardNormalCfgList = append(CardNormalCfgList, cardData)
- case Card_Type_Mini:
- CardMiniCfgList = append(CardMiniCfgList, cardData)
- case Card_Type_MVP:
- CardMvpCfgList = append(CardMvpCfgList, cardData)
- }
- curWeight[data.CardType] = weight
- }
- cfgData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Card_Normal)]
- if ok && cfgData.SVal != "" {
- valList := strings.Split(cfgData.SVal, "-")
- for i, _ := range valList {
- weightVal, _ := Str2Num(valList[i])
- CardNormalWeightList = append(CardNormalWeightList, int32(weightVal))
- }
- }
- cfgMiniData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Card_Mini)]
- if ok && cfgMiniData.SVal != "" {
- valList := strings.Split(cfgMiniData.SVal, "-")
- for i, _ := range valList {
- weightVal, _ := Str2Num(valList[i])
- CardMiniWeightList = append(CardMiniWeightList, int32(weightVal))
- }
- }
- cfgMvpData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Card_Mvp)]
- if ok && cfgMvpData.SVal != "" {
- valList := strings.Split(cfgMvpData.SVal, "-")
- for i, _ := range valList {
- weightVal, _ := Str2Num(valList[i])
- CardMvpWeightList = append(CardMvpWeightList, int32(weightVal))
- }
- }
- cfgTowerBuff3Data, ok := serverproto.GlobalCfgLoader[363]
- if ok && cfgTowerBuff3Data.SVal != "" {
- valList := strings.Split(cfgMvpData.SVal, ";")
- for _, v := range valList {
- k, v2 := Str2Res(v)
- TowerBuff3Cost = append(TowerBuff3Cost, &TowerBuff{k, v2})
- }
- }
- cfgTowerBuff2Data, ok := serverproto.GlobalCfgLoader[364]
- if ok && cfgTowerBuff2Data.SVal != "" {
- valList := strings.Split(cfgMvpData.SVal, ";")
- for _, v := range valList {
- k, v2 := Str2Res(v)
- TowerBuff2Cost = append(TowerBuff2Cost, &TowerBuff{k, v2})
- }
- }
- cfgTowerBuffData, ok := serverproto.GlobalCfgLoader[365]
- if ok && cfgTowerBuffData.SVal != "" {
- valList := strings.Split(cfgMvpData.SVal, ";")
- for _, v := range valList {
- k, v2 := Str2Res(v)
- TowerBuff1Cost = append(TowerBuff1Cost, &TowerBuff{k, v2})
- }
- }
- //CardUnlockCfg
- for _, data := range serverproto.CardUnlockCfgLoader {
- addData := &ConvertCardUnlockData{
- CardSlotId: data.CardSlotID,
- }
- for idx := 0; idx < len(data.UnlockingCondition); idx++ {
- k, v := Str2Res(data.UnlockingCondition[idx])
- if k > 0 && v > 0 {
- addData.ConditionList = append(addData.ConditionList,
- &serverproto.KeyValueType{Key: k, Value: v})
- }
- }
- ConvertCardUnlock[addData.CardSlotId] = addData
- }
- for _, data := range ConvertCardList {
- cardCfg, ok := serverproto.CardCfgLoader[data.CardCfgId]
- if !ok || cardCfg.CardType <= 2 {
- continue
- }
- if cardCfg.CardLevel == 1 || cardCfg.FromCardId == 0 {
- data.SourceCfgId = data.CardCfgId
- continue
- }
- sourceID := (data.CardCfgId/1000)*1000 + 100 + data.CardCfgId%100
- _, ok2 := serverproto.CardCfgLoader[data.CardCfgId]
- if !ok2 {
- continue
- }
- data.SourceCfgId = sourceID
- }
- }
- func GetCardSource(cardId int32) int32 {
- cardData, ok := ConvertCardList[cardId]
- if !ok {
- return 0
- }
- return cardData.SourceCfgId
- }
- // DropCfg数据
- type WeightKeyValueData struct {
- Weight int32
- Key int32
- MinValue int32
- Maxvalue int32
- }
- func (this *WeightKeyValueData) GetValue() int32 {
- if this.MinValue == this.Maxvalue || this.MinValue > this.Maxvalue {
- return this.Maxvalue
- }
- return this.MinValue + rand.Int31n(this.Maxvalue-this.MinValue+1)
- }
- type ConvertDropData struct {
- Id int32
- TotalWeight int32 //掉了总权重
- DropList []*WeightKeyValueData //weight itemId,value
- }
- type ConvertPassBox struct {
- ItemList []*serverproto.KeyValueType
- }
- type DecayData struct {
- FactorParam int32
- FactorList []*serverproto.KeyValueType
- }
- type ConvertDecayData struct {
- Id int32
- DecayList []*DecayData
- }
- func (this *ConvertDecayData) GetDecayList(kvList map[int32]int32, param uint64) {
- if param <= 0 || len(this.DecayList) <= 0 {
- return
- }
- bFindIdx := false
- findIdx := 0
- for idx := 0; idx < len(this.DecayList); idx++ {
- if this.DecayList[idx].FactorParam > int32(param) {
- break
- }
- bFindIdx = true
- findIdx = idx
- }
- if bFindIdx {
- if findIdx >= len(this.DecayList) {
- findIdx = len(this.DecayList) - 1
- }
- for k := 0; k < len(this.DecayList[findIdx].FactorList); k++ {
- kvItem := this.DecayList[findIdx].FactorList[k]
- kvList[kvItem.Key] += kvItem.Value
- }
- }
- }
- var DropDataList = map[int32]*ConvertDropData{}
- var LevelDropCommonDataList = map[int32]*ConvertDropData{}
- var LevelDropBossDataList = map[int32]*ConvertDropData{}
- var LevelDropHDDataList = map[int32]*ConvertDropData{}
- var ConvertLevelPowerDecayFactorList = map[int32]*ConvertDecayData{}
- var ConvertLevelTimeDecayFactorList = map[int32]*ConvertDecayData{}
- var ConvertLevelSpAdd *serverproto.KeyValueType = nil
- //var LevelPassBox = map[int32]*ConvertPassBox{}
- func convertDropCfg() {
- //dropCfg
- for _, data := range serverproto.DropCfgLoader {
- convertData := &ConvertDropData{
- Id: data.Id,
- TotalWeight: 0,
- }
- DropDataList[data.Id] = convertData
- for index, _ := range data.Drop1 {
- weightVal, key, minValue, maxValue := Str2Res_4(data.Drop1[index])
- convertData.TotalWeight += weightVal
- convertData.DropList = append(convertData.DropList,
- &WeightKeyValueData{Weight: convertData.TotalWeight, Key: key, MinValue: minValue, Maxvalue: maxValue})
- }
- }
- //levelCfg
- for _, data := range serverproto.LevelCfgLoader {
- //关卡drop处理
- commonData := &ConvertDropData{
- Id: data.Id,
- TotalWeight: 0,
- }
- LevelDropCommonDataList[data.Id] = commonData
- for index, _ := range data.DropOl {
- weightVal, key := Str2Res(data.DropOl[index])
- commonData.TotalWeight = weightVal
- commonData.DropList = append(commonData.DropList,
- &WeightKeyValueData{Weight: commonData.TotalWeight, Key: key})
- }
- hdCommonData := &ConvertDropData{
- Id: data.Id,
- TotalWeight: 0,
- }
- LevelDropHDDataList[data.Id] = hdCommonData
- for index, _ := range data.HdDrop {
- weightVal, key, val := Str2Res_3(data.HdDrop[index])
- hdCommonData.TotalWeight = weightVal
- hdCommonData.DropList = append(hdCommonData.DropList,
- &WeightKeyValueData{Weight: hdCommonData.TotalWeight, Key: key,
- MinValue: val, Maxvalue: val})
- }
- //boss drop处理
- bossData := &ConvertDropData{
- Id: data.Id,
- TotalWeight: 0,
- }
- LevelDropBossDataList[data.Id] = bossData
- for index, _ := range data.Drop {
- weightVal, key := Str2Res(data.Drop[index])
- bossData.TotalWeight = weightVal
- bossData.DropList = append(bossData.DropList,
- &WeightKeyValueData{Weight: bossData.TotalWeight, Key: key})
- }
- //难度衰减系数
- //power
- parseDecay(data.Id, data.PowerWeaken, ConvertLevelPowerDecayFactorList)
- //time
- parseDecay(data.Id, data.StayTimeWeaken, ConvertLevelTimeDecayFactorList)
- //sp add
- k, v := Str2Res(data.SpAddition)
- if k > 0 && v > 0 {
- ConvertLevelSpAdd = &serverproto.KeyValueType{Key: k, Value: v}
- }
- }
- }
- func parseDecay(id int32, decayStr string, convertData map[int32]*ConvertDecayData) {
- decayData := &ConvertDecayData{
- Id: id,
- }
- tmpDataList := strings.Split(decayStr, "|")
- for idx := 0; idx < len(tmpDataList); idx++ {
- tmpPramList := strings.Split(tmpDataList[idx], ";")
- val, _ := Str2Num(tmpPramList[0])
- tmpDecayData := &DecayData{
- FactorParam: int32(val),
- }
- for k := 1; k < len(tmpPramList); k++ {
- k, v := Str2Res(tmpPramList[k])
- if k <= 0 {
- continue
- }
- tmpDecayData.FactorList = append(tmpDecayData.FactorList, &serverproto.KeyValueType{Key: k, Value: v})
- }
- decayData.DecayList = append(decayData.DecayList, tmpDecayData)
- }
- convertData[decayData.Id] = decayData
- sort.Slice(decayData.DecayList, func(i, j int) bool {
- return decayData.DecayList[i].FactorParam < decayData.DecayList[j].FactorParam
- })
- }
- func DropCfgProcess(dropList map[int32]int32, dropId int32) {
- if dropId <= 0 {
- return
- }
- dropData, ok := serverproto.DropCfgLoader[dropId]
- convertDropData, ok1 := DropDataList[dropId]
- if !ok || !ok1 {
- util.ErrorF("dropProcess drop data not found dropId=%v ok=%v ok1=%v", dropId, ok, ok1)
- return
- }
- //万分比随机
- dropRate := rand.Int31n(10000)
- if dropRate >= dropData.Rate {
- return
- }
- if dropData.DropType <= 0 {
- //累计权重随机
- for i := 0; i < int(dropData.Times); i++ {
- if convertDropData.TotalWeight <= 0 {
- break
- }
- dropRate = rand.Int31n(convertDropData.TotalWeight)
- for _, data := range convertDropData.DropList {
- if data.Weight > dropRate && data.Key > 0 {
- dropList[data.Key] += data.GetValue()
- break
- }
- }
- }
- } else { //drop all
- for _, data := range convertDropData.DropList {
- if data.Key > 0 {
- dropList[data.Key] += data.GetValue() * dropData.Times
- }
- }
- }
- }
- // TargetTask配置数据
- // 解析任务结构数据,避免使用时重复解析
- type ConvertTaskData struct {
- TaskId uint32
- TaskType int32
- PreTaskId uint32 //前置任务ID
- NextTaskId uint32 //后续接取任务
- TaskScore int32 //获取奖励后的任务积分
- IsBeginTask bool
- Condition map[int32][]int32
- TaskReward []*serverproto.KeyValueType
- }
- type HardMissionTaskData struct {
- TaskId uint32
- TaskType int32
- GroupTaskId uint32 //所属任务组ID
- Condition map[int32][]int32
- TaskReward []*serverproto.KeyValueType
- GroupTaskReward []*serverproto.KeyValueType
- }
- type CovertTaskScoreData struct {
- Idx uint32
- Active int32
- RewardList []*serverproto.KeyValueType
- HDRewardList []*serverproto.KeyValueType //活动期间制定掉落物品
- }
- var TargetTaskBeginID uint32 = 0
- var ConvertTaskList = map[uint32]*ConvertTaskData{}
- var ConvertAddTaskList = map[uint32]*ConvertTaskData{}
- var HardMissionTaskList = map[uint32]*HardMissionTaskData{}
- var HardMissionTaskIdList []uint32
- var HardGroupMissionTaskList = map[uint32]*HardMissionTaskData{}
- var HardGroupMissionTaskIdList []uint32
- var Hard2MissionTaskList = map[uint32]*HardMissionTaskData{}
- var Hard2MissionTaskIdList []uint32
- var Hard2GroupMissionTaskList = map[uint32]*HardMissionTaskData{}
- var Hard2GroupMissionTaskIdList []uint32
- var ConvertMainTaskOriginalList = map[uint32]uint32{} //[taskid,originaltask]
- var ConvertDailyTaskScoreRewardList = map[uint32]*CovertTaskScoreData{}
- var ConvertWeekTaskScoreRewardList = map[uint32]*CovertTaskScoreData{}
- const (
- TASK_TYPE_DAILY = 1
- TASK_TYPE_WEEK = 2
- TASK_TYPE_MAIN = 3
- TASK_TYPE_TODAY = 4
- TASK_TYPE_GROWUP = 5
- TASK_TYPE_HARD = 6
- TASK_TYPE_HARD_GROUP = 7
- TASK_TYPE_HARD2 = 8
- TASK_TYPE_HARD2_GROUP = 9
- )
- func convertTaskCfg() {
- //globalCfgData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Target_Task_Begin_ID)]
- //if ok {
- // TargetTaskBeginID = uint32(globalCfgData.IVal)
- //}
- //
- //for _, data := range serverproto.TargetTaskCfgLoader {
- // convertData := &ConvertTaskData{
- // TaskId: uint32(data.TargetTaskId),
- // TaskType: data.TargetTaskType,
- // NextTaskId: uint32(data.FollowTaskOld),
- // Condition: map[int32][]int32{},
- // }
- //
- // //任务条件
- // for index, _ := range data.TargetTaskCondition {
- // valueList := strings.Split(data.TargetTaskCondition[index], ":")
- // if len(valueList) >= 2 {
- // taskType, _ := Str2Num(valueList[0])
- // convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskType))
- // for i := 1; i < len(valueList); i++ {
- // taskValue, _ := Str2Num(valueList[i])
- // convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskValue))
- // }
- // }
- // }
- //
- // //任务奖励
- // for index, _ := range data.TargetReward {
- // key, value := Str2Res(data.TargetReward[index])
- // convertData.TaskReward = append(convertData.TaskReward, &serverproto.KeyValueType{
- // Key: key,
- // Value: value,
- // })
- // }
- //
- // ConvertTaskList[convertData.TaskId] = convertData
- //}
- for _, data := range serverproto.MissionCfgLoader {
- convertData := &ConvertTaskData{
- TaskId: uint32(data.MissionID),
- TaskType: data.MissionType,
- TaskScore: data.Active,
- Condition: map[int32][]int32{},
- }
- //任务条件
- for index, _ := range data.MissionCondition {
- valueList := strings.Split(data.MissionCondition[index], ":")
- if len(valueList) >= 2 {
- taskType, _ := Str2Num(valueList[0])
- convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskType))
- for i := 1; i < len(valueList); i++ {
- taskValue, _ := Str2Num(valueList[i])
- convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskValue))
- }
- }
- }
- ConvertTaskList[convertData.TaskId] = convertData
- ConvertAddTaskList[convertData.TaskId] = convertData
- }
- for _, data := range serverproto.HardMissionCfgLoader {
- convertData := &HardMissionTaskData{
- TaskId: uint32(data.MissionID),
- TaskType: TASK_TYPE_HARD,
- GroupTaskId: uint32(data.GroupID),
- Condition: map[int32][]int32{},
- }
- //任务条件
- for index, _ := range data.MissionCondition {
- valueList := strings.Split(data.MissionCondition[index], ":")
- if len(valueList) >= 2 {
- taskType, _ := Str2Num(valueList[0])
- convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskType))
- for i := 1; i < len(valueList); i++ {
- taskValue, _ := Str2Num(valueList[i])
- convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskValue))
- }
- }
- }
- //任务奖励
- for index, _ := range data.Reward {
- key, value := Str2Res(data.Reward[index])
- convertData.TaskReward = append(convertData.TaskReward, &serverproto.KeyValueType{
- Key: key,
- Value: value,
- })
- }
- for index, _ := range data.GroupReward {
- key2, value2 := Str2Res(data.GroupReward[index])
- convertData.GroupTaskReward = append(convertData.GroupTaskReward, &serverproto.KeyValueType{
- Key: key2,
- Value: value2,
- })
- }
- if convertData.TaskType == TASK_TYPE_HARD {
- HardMissionTaskIdList = append(HardMissionTaskIdList, convertData.TaskId)
- HardMissionTaskList[convertData.TaskId] = convertData
- }
- //util.InfoF("groupaward:%v", data.GroupReward)
- if len(data.GroupReward) > 0 && data.GroupReward[0] != "" {
- data2 := &HardMissionTaskData{
- TaskId: convertData.TaskId,
- TaskType: TASK_TYPE_HARD_GROUP,
- GroupTaskId: convertData.GroupTaskId,
- Condition: convertData.Condition,
- TaskReward: convertData.TaskReward,
- GroupTaskReward: convertData.GroupTaskReward,
- }
- //convertData.TaskId = uint32(data.GroupID)
- HardGroupMissionTaskIdList = append(HardGroupMissionTaskIdList, convertData.GroupTaskId)
- HardGroupMissionTaskList[convertData.GroupTaskId] = data2
- //util.InfoF("groupaward:%v len:%v", convertData, len(data.GroupReward))
- }
- }
- sort.Slice(HardMissionTaskIdList, func(i, j int) bool {
- return HardMissionTaskIdList[i] < HardMissionTaskIdList[j]
- })
- sort.Slice(HardGroupMissionTaskIdList, func(i, j int) bool {
- return HardGroupMissionTaskIdList[i] < HardGroupMissionTaskIdList[j]
- })
- for _, data := range serverproto.Hard2MissionCfgLoader {
- convertData := &HardMissionTaskData{
- TaskId: uint32(data.MissionID),
- TaskType: TASK_TYPE_HARD2,
- GroupTaskId: uint32(data.GroupID),
- Condition: map[int32][]int32{},
- }
- //任务条件
- for index, _ := range data.MissionCondition {
- valueList := strings.Split(data.MissionCondition[index], ":")
- if len(valueList) >= 2 {
- taskType, _ := Str2Num(valueList[0])
- convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskType))
- for i := 1; i < len(valueList); i++ {
- taskValue, _ := Str2Num(valueList[i])
- convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskValue))
- }
- }
- }
- //任务奖励
- for index, _ := range data.Reward {
- key, value := Str2Res(data.Reward[index])
- convertData.TaskReward = append(convertData.TaskReward, &serverproto.KeyValueType{
- Key: key,
- Value: value,
- })
- }
- for index, _ := range data.GroupReward {
- key2, value2 := Str2Res(data.GroupReward[index])
- convertData.GroupTaskReward = append(convertData.GroupTaskReward, &serverproto.KeyValueType{
- Key: key2,
- Value: value2,
- })
- }
- if convertData.TaskType == TASK_TYPE_HARD2 {
- Hard2MissionTaskIdList = append(Hard2MissionTaskIdList, convertData.TaskId)
- Hard2MissionTaskList[convertData.TaskId] = convertData
- }
- //util.InfoF("groupaward:%v", data.GroupReward)
- if len(data.GroupReward) > 0 && data.GroupReward[0] != "" {
- data2 := &HardMissionTaskData{
- TaskId: convertData.TaskId,
- TaskType: TASK_TYPE_HARD2_GROUP,
- GroupTaskId: convertData.GroupTaskId,
- Condition: convertData.Condition,
- TaskReward: convertData.TaskReward,
- GroupTaskReward: convertData.GroupTaskReward,
- }
- //convertData.TaskId = uint32(data.GroupID)
- Hard2GroupMissionTaskIdList = append(Hard2GroupMissionTaskIdList, convertData.GroupTaskId)
- Hard2GroupMissionTaskList[convertData.GroupTaskId] = data2
- //util.InfoF("groupaward:%v len:%v", convertData, len(data.GroupReward))
- }
- }
- sort.Slice(Hard2MissionTaskIdList, func(i, j int) bool {
- return Hard2MissionTaskIdList[i] < Hard2MissionTaskIdList[j]
- })
- sort.Slice(Hard2GroupMissionTaskIdList, func(i, j int) bool {
- return Hard2GroupMissionTaskIdList[i] < Hard2GroupMissionTaskIdList[j]
- })
- //util.InfoF("len taskId:%v,len task group:%v", len(HardMissionTaskIdList), len(HardGroupMissionTaskIdList))
- //util.InfoF("task group:%v", HardGroupMissionTaskIdList)
- for _, data := range serverproto.LineMissionCfgLoader {
- convertData := &ConvertTaskData{
- TaskId: uint32(data.MissionID),
- TaskType: TASK_TYPE_MAIN,
- Condition: map[int32][]int32{},
- }
- if data.BeginMission > 0 {
- convertData.IsBeginTask = true
- }
- convertData.NextTaskId = uint32(data.FollowMissionld)
- //任务条件
- for index, _ := range data.MissionCondition {
- valueList := strings.Split(data.MissionCondition[index], ":")
- if len(valueList) >= 2 {
- taskType, _ := Str2Num(valueList[0])
- convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskType))
- for i := 1; i < len(valueList); i++ {
- taskValue, _ := Str2Num(valueList[i])
- convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskValue))
- }
- }
- }
- //任务奖励
- for index, _ := range data.Reward {
- key, value := Str2Res(data.Reward[index])
- convertData.TaskReward = append(convertData.TaskReward, &serverproto.KeyValueType{
- Key: key,
- Value: value,
- })
- }
- ConvertTaskList[convertData.TaskId] = convertData
- if convertData.IsBeginTask {
- ConvertAddTaskList[convertData.TaskId] = convertData
- }
- }
- for _, originalTaskData := range ConvertAddTaskList {
- if !originalTaskData.IsBeginTask {
- continue
- }
- ConvertMainTaskOriginalList[originalTaskData.TaskId] = originalTaskData.TaskId
- if originalTaskData.NextTaskId == 0 || originalTaskData.TaskId == originalTaskData.NextTaskId {
- continue
- }
- ConvertMainTaskOriginalList[originalTaskData.NextTaskId] = originalTaskData.TaskId
- originalTaskProcess(originalTaskData.NextTaskId)
- }
- //积分奖励
- for _, data := range serverproto.ActRewardCfgLoader {
- scoreInfo := &CovertTaskScoreData{
- Idx: uint32(data.ID),
- Active: data.Active,
- }
- for index, _ := range data.Reward {
- key, value := Str2Res(data.Reward[index])
- if key <= 0 || value <= 0 {
- continue
- }
- scoreInfo.RewardList = append(scoreInfo.RewardList, &serverproto.KeyValueType{
- Key: key,
- Value: value,
- })
- }
- for index, _ := range data.HdDrop {
- key, value := Str2Res(data.HdDrop[index])
- if key <= 0 || value <= 0 {
- continue
- }
- scoreInfo.HDRewardList = append(scoreInfo.HDRewardList, &serverproto.KeyValueType{
- Key: key,
- Value: value,
- })
- }
- if data.ActiveType == TASK_TYPE_DAILY {
- ConvertDailyTaskScoreRewardList[scoreInfo.Idx] = scoreInfo
- } else if data.ActiveType == TASK_TYPE_WEEK {
- ConvertWeekTaskScoreRewardList[scoreInfo.Idx] = scoreInfo
- }
- }
- }
- func originalTaskProcess(taskId uint32) {
- if data, ok := serverproto.LineMissionCfgLoader[int32(taskId)]; ok && data.FollowMissionld > 0 {
- if data.MissionID == data.FollowMissionld {
- return
- }
- ConvertMainTaskOriginalList[uint32(data.FollowMissionld)] = ConvertMainTaskOriginalList[taskId]
- originalTaskProcess(uint32(data.FollowMissionld))
- }
- }
- // convertParterProgressCfg
- type ProgressLevelAttr struct {
- AttrSet map[int32]map[int32]int32
- }
- var ProgressAttrContainer = map[int32]*ProgressLevelAttr{}
- type PartnerSkillSet struct {
- SkillLevel map[int32][]int32
- }
- //var PartnerSkillContainer = map[int32]*PartnerSkillSet{}
- func convertParterProgressCfg() {
- for _, data := range serverproto.ParterProgressCfgLoader {
- paraStr := "Attribute"
- t := reflect.ValueOf(data).Elem()
- convertData := &ProgressLevelAttr{
- AttrSet: map[int32]map[int32]int32{},
- }
- for i := 1; i <= int(data.Times); i++ {
- keyStr := paraStr + strconv.Itoa(i)
- v := t.FieldByName(keyStr).Interface()
- var mapAttribute0 = make(map[int32]int32)
- for _, str := range v.([]string) {
- attrList := strings.Split(str, ":")
- if len(attrList) >= 2 {
- attrId, _ := Str2Num(attrList[0])
- attrValue, _ := Str2Num(attrList[1])
- mapAttribute0[int32(attrId)] = int32(attrValue)
- }
- }
- convertData.AttrSet[int32(i-1)] = mapAttribute0
- }
- ProgressAttrContainer[data.Id] = convertData
- }
- convertStrengthCfg()
- }
- var ConvertPartnerSkillIdxList = map[int32]*serverproto.ParterSkillTreeCfg{}
- type ConvertSkillSlotData struct {
- Id int32
- ConditionList []*serverproto.KeyValueType
- }
- var ConvertSkillSlotMain = map[int32]*ConvertSkillSlotData{}
- var ConvertSkillSlotPartner = map[int32]*ConvertSkillSlotData{}
- func convertParterSkillTreeCfg() {
- for _, data := range serverproto.ParterSkillTreeCfgLoader {
- ConvertPartnerSkillIdxList[data.SkillId] = data
- }
- convertSkillTree() //技能升级
- for _, data := range serverproto.SkillSlotCfgLoader {
- mainAddData := &ConvertSkillSlotData{
- Id: data.ID,
- }
- for idx := 0; idx < len(data.SCondition); idx++ {
- k, v := Str2Res(data.SCondition[idx])
- if k > 0 && v > 0 {
- mainAddData.ConditionList = append(mainAddData.ConditionList,
- &serverproto.KeyValueType{Key: k, Value: v})
- }
- }
- ConvertSkillSlotMain[mainAddData.Id] = mainAddData
- partnerAddData := &ConvertSkillSlotData{
- Id: data.ID,
- }
- for idx := 0; idx < len(data.SParterCondition); idx++ {
- k, v := Str2Res(data.SParterCondition[idx])
- if k > 0 && v > 0 {
- partnerAddData.ConditionList = append(partnerAddData.ConditionList,
- &serverproto.KeyValueType{Key: k, Value: v})
- }
- }
- ConvertSkillSlotPartner[partnerAddData.Id] = partnerAddData
- }
- }
- type StrengthCost struct {
- CostList []*serverproto.KeyValueType
- }
- var PartnerStrengthCost = map[int32]*StrengthCost{}
- type StrengthAttr struct {
- AttrSet map[int32]map[int32]int32
- }
- var StrengthAttrContainer = map[int32]*StrengthAttr{}
- // 伙伴突破 相关配置
- func convertStrengthCfg() {
- for _, data := range serverproto.ParterProgressCfgLoader {
- paraStr := "BreachAttribute"
- convertData := &StrengthAttr{
- AttrSet: map[int32]map[int32]int32{},
- }
- t := reflect.ValueOf(data).Elem()
- for i := 1; i <= int(data.BreachTimes); i++ {
- keyStr := paraStr + strconv.Itoa(i)
- v := t.FieldByName(keyStr)
- var mapAttribute0 = make(map[int32]int32)
- for _, str := range v.Interface().([]string) {
- attrList := strings.Split(str, ":")
- if len(attrList) >= 2 {
- attrId, _ := Str2Num(attrList[0])
- attrValue, _ := Str2Num(attrList[1])
- mapAttribute0[int32(attrId)] = int32(attrValue)
- }
- }
- convertData.AttrSet[int32(i-1)] = mapAttribute0
- }
- convertCost := &StrengthCost{}
- for index, _ := range data.BreachCost {
- attrList := strings.Split(data.BreachCost[index], ":")
- if len(attrList) >= 2 {
- attrId, _ := Str2Num(attrList[0])
- attrValue, _ := Str2Num(attrList[1])
- convertCost.CostList = append(convertCost.CostList, &serverproto.KeyValueType{
- Key: int32(attrId),
- Value: int32(attrValue),
- })
- }
- }
- PartnerStrengthCost[data.Id] = convertCost
- StrengthAttrContainer[data.Id] = convertData
- }
- }
- // 主角
- type RoleAttributeSet struct {
- AttrSet []*serverproto.KeyValueType
- }
- var RoleAttrContainer = map[int32]*RoleAttributeSet{}
- func convertRoleAttributeCfg() {
- for _, data := range serverproto.RoleAttributeCfgLoader {
- convertData := &RoleAttributeSet{}
- convertData.AttrSet = []*serverproto.KeyValueType{
- {Key: int32(serverproto.Attr_Life), Value: data.Hp},
- {Key: int32(serverproto.Attr_Sp), Value: data.Sp},
- {Key: int32(serverproto.Attr_Attack), Value: data.Atk},
- {Key: int32(serverproto.Attr_MagicAttack), Value: data.Matk},
- {Key: int32(serverproto.Attr_Defense), Value: data.Def},
- {Key: int32(serverproto.Attr_MagicDefense), Value: data.Mdef},
- {Key: int32(serverproto.Attr_Hit), Value: data.Hit},
- {Key: int32(serverproto.Attr_Dodge), Value: data.Dodge},
- {Key: int32(serverproto.Attr_Crit), Value: data.Crit},
- {Key: int32(serverproto.Attr_Ten), Value: data.Ten},
- }
- RoleAttrContainer[data.BaseLv] = convertData
- }
- }
- // 主角
- type JobAttrSet struct {
- // AttrSet []*serverproto.KeyValueType
- AttrSet map[int32]int32
- }
- var JobAttrContainer = map[int32]*JobAttrSet{}
- func convertJobAttrCfg() {
- for _, data := range serverproto.JobCfgLoader {
- convertData := &JobAttrSet{
- AttrSet: map[int32]int32{},
- }
- convertData.AttrSet[int32(serverproto.Attr_Life)] = data.HpRate
- convertData.AttrSet[int32(serverproto.Attr_Sp)] = data.SpRate
- convertData.AttrSet[int32(serverproto.Attr_Attack)] = data.AtkRate
- convertData.AttrSet[int32(serverproto.Attr_MagicAttack)] = data.MatkRate
- convertData.AttrSet[int32(serverproto.Attr_Defense)] = data.DefRate
- convertData.AttrSet[int32(serverproto.Attr_MagicDefense)] = data.MdefRate
- convertData.AttrSet[int32(serverproto.Attr_Hit)] = data.HitRate
- convertData.AttrSet[int32(serverproto.Attr_Dodge)] = data.DodgeRate
- convertData.AttrSet[int32(serverproto.Attr_Crit)] = data.CritRate
- convertData.AttrSet[int32(serverproto.Attr_Ten)] = data.TenRate
- JobAttrContainer[data.Id] = convertData
- }
- }
- // 伙伴
- type PartnerAttrSet struct {
- AttrSet []*serverproto.KeyValueType
- }
- var PartnerAttrContainer = map[int32]*PartnerAttrSet{}
- func convertPartnerAttrCfg() {
- for _, data := range serverproto.ParterCfgLoader {
- convertData := &PartnerAttrSet{}
- convertData.AttrSet = []*serverproto.KeyValueType{
- {Key: int32(serverproto.Attr_Life), Value: data.Hp},
- {Key: int32(serverproto.Attr_Sp), Value: data.Sp},
- {Key: int32(serverproto.Attr_Attack), Value: data.Atk},
- {Key: int32(serverproto.Attr_MagicAttack), Value: data.Matk},
- {Key: int32(serverproto.Attr_Defense), Value: data.Def},
- {Key: int32(serverproto.Attr_MagicDefense), Value: data.Mdef},
- {Key: int32(serverproto.Attr_Hit), Value: data.Hit},
- {Key: int32(serverproto.Attr_Dodge), Value: data.Dodge},
- {Key: int32(serverproto.Attr_Crit), Value: data.Crit},
- {Key: int32(serverproto.Attr_Ten), Value: data.Ten},
- {Key: int32(serverproto.Attr_AttackSpeed), Value: data.Aspd},
- }
- PartnerAttrContainer[data.ParterId] = convertData
- }
- }
- type FashionAttrSet struct {
- AttrSet []*serverproto.KeyValueType
- FashionUseJobList []int32
- FashionQuality int32
- //AttrNum int32
- }
- //var FashionAttrContainer = map[int32]*FashionAttrSet{}
- var ConvertFashionPaperData = map[int32]map[int32]int32{}
- func convertFashionCfg() {
- //for _, cfgData := range serverproto.FashionCfgLoader {
- // convertData := &FashionAttrSet{}
- // for _, attrSet := range cfgData.FashionAttr {
- // key, value := Str2Res(attrSet)
- // if key <= 0 || value <= 0 {
- // continue
- // }
- // convertData.AttrSet = append(convertData.AttrSet, &serverproto.KeyValueType{
- // Key: key,
- // Value: value,
- // })
- // }
- //
- // for idx := 0; idx < len(cfgData.FashionUseJob); idx++ {
- // useJob, _ := Str2Num(cfgData.FashionUseJob[idx])
- // convertData.FashionUseJobList = append(convertData.FashionUseJobList, int32(useJob))
- // }
- // //convertData.AttrNum = cfgData.AttrNum
- // convertData.FashionQuality = cfgData.FashionQuality
- // //FashionAttrContainer[int32(cfgData.FashionId)] = convertData
- //}
- //paper resolveItemList
- for _, data := range serverproto.FashionPaperCfgLoader {
- ConvertFashionPaperData[data.PaperId] = map[int32]int32{}
- for idx := range data.ResolveItem {
- key, val := Str2Res(data.ResolveItem[idx])
- if key > 0 && val > 0 {
- ConvertFashionPaperData[data.PaperId][key] += val
- }
- }
- }
- }
- type CardAttrSet struct {
- AttrSet []*serverproto.KeyValueType
- }
- var CardAttrContainer = map[int32]*CardAttrSet{}
- func convertCardAttCfg() {
- for _, cfgData := range serverproto.CardCfgLoader {
- convertData := &CardAttrSet{}
- for _, attrSet := range cfgData.Attribute1 {
- key, value := Str2Res(attrSet)
- if key <= 0 || value <= 0 {
- continue
- }
- convertData.AttrSet = append(convertData.AttrSet, &serverproto.KeyValueType{
- Key: key,
- Value: value,
- })
- }
- CardAttrContainer[int32(cfgData.CardId)] = convertData
- }
- }
- type EquipAttributeSet struct {
- AttrSet []*serverproto.KeyValueType
- SuitId int32
- }
- var EquipAttrContainer = map[int32]*EquipAttributeSet{}
- func convertEquipCfg() {
- for _, data := range serverproto.EquipCfgLoader {
- convertData := &EquipAttributeSet{
- SuitId: data.Suit,
- }
- convertData.AttrSet = []*serverproto.KeyValueType{
- {Key: int32(serverproto.Attr_Str), Value: data.Str},
- {Key: int32(serverproto.Attr_Agi), Value: data.Agi},
- {Key: int32(serverproto.Attr_Int), Value: data.Int},
- {Key: int32(serverproto.Attr_Vit), Value: data.Vit},
- {Key: int32(serverproto.Attr_Dex), Value: data.Dex},
- {Key: int32(serverproto.Attr_Luk), Value: data.Luk},
- {Key: int32(serverproto.Attr_Life), Value: data.Life},
- {Key: int32(serverproto.Attr_Sp), Value: data.Sp},
- {Key: int32(serverproto.Attr_Attack), Value: data.Attack},
- {Key: int32(serverproto.Attr_MagicAttack), Value: data.MagicAttack},
- {Key: int32(serverproto.Attr_Defense), Value: data.Defense},
- {Key: int32(serverproto.Attr_MagicDefense), Value: data.MagicDefense},
- {Key: int32(serverproto.Attr_Hit), Value: data.Hit},
- {Key: int32(serverproto.Attr_Dodge), Value: data.Dodge},
- {Key: int32(serverproto.Attr_Crit), Value: data.Crit},
- {Key: int32(serverproto.Attr_Ten), Value: data.Ten},
- {Key: int32(serverproto.Attr_PhysicDamage_Percent), Value: data.PhysicalDamageBonus},
- {Key: int32(serverproto.Attr_MagicDamage_Percent), Value: data.MagicDamageBonus},
- {Key: int32(serverproto.Attr_Attack_Percent), Value: data.AtkPercent},
- {Key: int32(serverproto.Attr_MagicAttack_Percent), Value: data.MatkPercent},
- }
- EquipAttrContainer[data.Id] = convertData
- }
- }
- // 神器id,星级,消耗材料map
- var SkillEquipStarLevelUpCostContainer = map[int32]map[int32]map[int32]int32{}
- // 返还 神器id,星级,返还材料map
- var SkillEquipDecomposeReturnContainer = map[int32]map[int32]map[int32]int32{}
- // 神器战力
- var SkillEquipAppendFightPowerContainer = map[int32]map[int32]int32{}
- // 神器技能 神器id,星级,技能id
- var SkillEquipAppendSkillContainer = map[int32]map[int32]int32{}
- // 神器槽位附加属性 槽位等级,属性map
- var SkillEquipSlotAppendAttrContainer = map[int32]map[serverproto.Attr]float32{}
- // 神器槽位升级消耗 槽位等级,消耗材料map
- var SkillEquipSlotLevelUpCostContainer = map[int32]map[int32]int32{}
- type SkillEquipRemake struct {
- Id int32 //批次
- BeginDay int32
- EndDay int32
- CurBegin uint64 //当前批次开始
- CurEnd uint64 //当前批次结束
- CurForgePool []int32 //当前重铸池子
- RealPool []int32 //实际重铸池子
- NextForgePool []int32 //下一批重铸池子
- NextBegin uint64 //下一轮开始时间
- }
- var SkillEquipRemakePool = map[int32]*SkillEquipRemake{}
- type RemakeCost struct {
- CostMap map[int32]int32
- }
- // 重铸消耗
- var SkillEquipRemakeCostContainer = map[int32]*RemakeCost{}
- func convertSkillEquipCfg() {
- for _, data := range serverproto.ArtifactCfgLoader {
- // 一个id 对应的所有星级的材料消耗
- costs := map[int32]map[int32]int32{}
- SkillEquipStarLevelUpCostContainer[data.Id] = costs
- for k, v := range data.Condition {
- resList := strings.Split(v, ":")
- // 当前星级对应的材料消耗 消耗的itemid,itemnum
- cost := map[int32]int32{}
- costs[int32(k)] = cost
- for _, v1 := range resList {
- r1, r2 := Str2ResBySep(v1, "|")
- _, ok1 := cost[r1]
- if ok1 {
- cost[r1] += r2
- } else {
- cost[r1] = r2
- }
- }
- }
- // 一个id 对应的所有星级的材料返还
- retResLists := map[int32]map[int32]int32{}
- SkillEquipDecomposeReturnContainer[data.Id] = retResLists
- for k, v := range data.SmeltReturn {
- resList := strings.Split(v, ":")
- // 当前星级对应的材料返还 itemid,itemnum
- retRes := map[int32]int32{}
- retResLists[int32(k)] = retRes
- for _, v1 := range resList {
- r1, r2 := Str2ResBySep(v1, "|")
- _, ok1 := retRes[r1]
- if ok1 {
- retRes[r1] += r2
- } else {
- retRes[r1] = r2
- }
- }
- }
- appendFights := map[int32]int32{}
- SkillEquipAppendFightPowerContainer[data.Id] = appendFights
- for k, v := range data.AddFight {
- fight, error := Str2Num(v)
- if error != nil {
- util.PanicF("convertSkillEquipCfg AddFight id=%d", data.Id)
- break
- }
- appendFights[int32(k)] = int32(fight)
- }
- //skillList := map[int32]int32{}
- //SkillEquipAppendSkillContainer[data.Id] = skillList
- //for k, v := range data.ArtifacFuncId {
- // skillId, error := Str2Num(v)
- // if error != nil {
- // util.ErrorF("convertSkillEquipCfg ArtifacFuncId id=%d", data.Id)
- // break
- // }
- // skillList[int32(k)] = int32(skillId)
- //}
- if len(data.ReforgeCost) >= 1 {
- costConvert := &RemakeCost{
- CostMap: map[int32]int32{},
- }
- for _, data := range data.ReforgeCost {
- itemId, itemNum := Str2Res(data)
- if itemId > 0 && itemNum > 0 {
- costConvert.CostMap[itemId] += itemNum
- }
- }
- SkillEquipRemakeCostContainer[data.Id] = costConvert
- }
- if data.Times != 0 {
- poolData, ok := SkillEquipRemakePool[data.Times]
- if !ok {
- convertData := &SkillEquipRemake{
- Id: data.Times,
- }
- startDay, endDay := Str2Res(data.ArtifactDuration[0])
- convertData.BeginDay = startDay
- convertData.EndDay = endDay
- convertData.CurForgePool = append(convertData.CurForgePool, data.Id)
- convertData.RealPool = append(convertData.RealPool, data.Id)
- SkillEquipRemakePool[data.Times] = convertData
- } else {
- poolData.CurForgePool = append(poolData.CurForgePool, data.Id)
- poolData.RealPool = append(poolData.RealPool, data.Id)
- }
- }
- }
- for i := 1; i <= len(SkillEquipRemakePool); i++ {
- curPool, ok := SkillEquipRemakePool[int32(i)]
- if !ok {
- //异常(当前批次不应该找不到)
- break
- }
- nextPool, okNext := SkillEquipRemakePool[int32(i+1)]
- if !okNext {
- //说明当前批次是最后一批
- break
- }
- //初始化下一阶段的重铸池
- curPool.NextForgePool = append(curPool.NextForgePool, nextPool.CurForgePool...)
- curPool.NextBegin = nextPool.NextBegin
- //初始化,下一阶段的重铸池子
- nextPool.RealPool = append(nextPool.RealPool, curPool.RealPool...)
- }
- for _, data := range serverproto.ArtifactExpCfgLoader {
- cost := map[int32]int32{}
- SkillEquipSlotLevelUpCostContainer[data.ArtifactLevel] = cost
- for _, v := range data.UpgradeCost {
- r1, r2 := Str2Res(v)
- _, ok1 := cost[r1]
- if ok1 {
- cost[r1] += r2
- } else {
- cost[r1] = r2
- }
- }
- attr := map[serverproto.Attr]float32{}
- SkillEquipSlotAppendAttrContainer[data.ArtifactLevel] = attr
- for _, v := range data.Nature {
- r1, r2 := Str2Res(v)
- _, ok1 := attr[serverproto.Attr(r1)]
- if ok1 {
- attr[serverproto.Attr(r1)] += float32(r2)
- } else {
- attr[serverproto.Attr(r1)] = float32(r2)
- }
- }
- }
- }
- func CheckNeedInitStartTime() {
- loc := util.GetLoc()
- startUpTime := service.GetServiceStartupTime()
- if startUpTime < 0 {
- util.ErrorF("[SkillEquipRemakePool] data error:%v")
- }
- startServer := time.Unix(int64(startUpTime/1000), 0).In(loc).Format(util.DATE_FORMAT1)
- startUpDayStr := util.GetDayByTimeStr1(startServer)
- for i := 1; i <= len(SkillEquipRemakePool); i++ {
- _, ok := SkillEquipRemakePool[int32(i)]
- if !ok {
- return
- }
- if SkillEquipRemakePool[int32(i)].CurBegin <= 0 {
- //计算开服时间
- startTime := time.Unix(startUpDayStr.Unix()+int64(SkillEquipRemakePool[int32(i)].BeginDay-1)*int64(DaySec), 0).In(loc)
- SkillEquipRemakePool[int32(i)].CurBegin = uint64(startTime.UnixNano()/1e6) + 3600*5*1000
- if SkillEquipRemakePool[int32(i)].EndDay > 0 {
- endTime := time.Unix(startUpDayStr.Unix()+int64(SkillEquipRemakePool[int32(i)].EndDay-1)*int64(DaySec), 0).In(loc)
- SkillEquipRemakePool[int32(i)].CurEnd = uint64(endTime.UnixNano()/1e6) + 3600*5*1000
- }
- util.InfoF("[SkillEquipRemakePool] CurBegin:%v, CurEnd:%v", SkillEquipRemakePool[int32(i)].CurBegin, SkillEquipRemakePool[int32(i)].CurEnd)
- }
- if i > 1 {
- _, ok2 := SkillEquipRemakePool[int32(i-1)]
- if ok2 {
- SkillEquipRemakePool[int32(i-1)].NextBegin = SkillEquipRemakePool[int32(i)].CurBegin
- }
- }
- }
- }
- func GetCurForgePool() *SkillEquipRemake {
- CheckNeedInitStartTime()
- curTime := util.GetCurrentTime()
- for i := 1; i <= len(SkillEquipRemakePool); i++ {
- _, ok := SkillEquipRemakePool[int32(i)]
- if !ok {
- return nil
- }
- if SkillEquipRemakePool[int32(i)].CurBegin <= 0 {
- return nil
- }
- if i == 1 {
- if curTime < SkillEquipRemakePool[int32(i)].CurBegin {
- return nil
- }
- }
- if SkillEquipRemakePool[int32(i)].CurBegin <= curTime {
- if (SkillEquipRemakePool[int32(i)].CurEnd != 0 && curTime < SkillEquipRemakePool[int32(i)].CurEnd) ||
- SkillEquipRemakePool[int32(i)].CurEnd == 0 {
- return SkillEquipRemakePool[int32(i)]
- }
- }
- }
- return nil
- }
- type EquipRefineSet struct {
- AttrSet []*serverproto.KeyValueType
- }
- var EquipRefineContainer = map[int32]*EquipRefineSet{}
- func convertEquipRefineCfg() {
- for _, data := range serverproto.EquipRefineCfgLoader {
- convertData := &EquipRefineSet{}
- for idx := range data.SuitServer {
- key, value := Str2Res(data.SuitServer[idx])
- if key <= 0 || value <= 0 {
- continue
- }
- convertData.AttrSet = append(convertData.AttrSet, &serverproto.KeyValueType{
- Key: key,
- Value: value,
- })
- }
- EquipRefineContainer[int32(data.Id)] = convertData
- }
- }
- type FightPowerSet struct {
- AttrSet []*serverproto.KeyValueType
- Mapping int32
- }
- var FightPowerContainer = map[int32]*FightPowerSet{}
- var ConvertFightPower = map[int32]map[int32]int32{} //[jobtype][attrkey][attrval]
- func convertFightPowerCfg() {
- for _, data := range serverproto.FightCfgLoader {
- convertData := &FightPowerSet{}
- for _, attrData := range data.Coefficient {
- key, value := Str2Res(attrData)
- if key < 0 || value <= 0 {
- continue
- }
- convertData.AttrSet = append(convertData.AttrSet, &serverproto.KeyValueType{
- Key: key,
- Value: value,
- })
- }
- convertData.Mapping = data.Mapping
- FightPowerContainer[int32(data.Id)] = convertData
- for idx := 0; idx < len(data.Coefficient); idx++ {
- k, v := Str2Res(data.Coefficient[idx])
- if _, ok := ConvertFightPower[k]; !ok {
- ConvertFightPower[k] = map[int32]int32{}
- }
- ConvertFightPower[k][data.Id] = v
- }
- }
- }
- type EquipSuitAttr struct {
- AttrSet map[int32]map[int32]int32
- }
- var SuitAttrContainer = map[int32]*EquipSuitAttr{}
- func convertEquipSuitCfg() {
- for _, data := range serverproto.EquipSuitNewCfgLoader {
- convertData := &EquipSuitAttr{
- AttrSet: map[int32]map[int32]int32{},
- }
- var mapAttribute0 map[int32]int32
- mapAttribute0 = make(map[int32]int32)
- for index, _ := range data.Suit1 {
- key, value := Str2Res(data.Suit1[index])
- if key <= 0 || value <= 0 {
- continue
- }
- mapAttribute0[key] = value
- }
- convertData.AttrSet[0] = mapAttribute0
- var mapAttribute1 map[int32]int32
- mapAttribute1 = make(map[int32]int32)
- for index, _ := range data.Suit2 {
- key, value := Str2Res(data.Suit2[index])
- if key <= 0 || value <= 0 {
- continue
- }
- mapAttribute1[key] = value
- }
- convertData.AttrSet[1] = mapAttribute1
- var mapAttribute2 map[int32]int32
- mapAttribute2 = make(map[int32]int32)
- for index, _ := range data.Suit3 {
- key, value := Str2Res(data.Suit3[index])
- if key <= 0 || value <= 0 {
- continue
- }
- mapAttribute2[key] = value
- }
- convertData.AttrSet[2] = mapAttribute2
- SuitAttrContainer[int32(data.Id)] = convertData
- }
- }
- type ChangeCondition struct {
- Condition map[int32][]int32
- }
- var ChangeJobCond = map[int32]*ChangeCondition{}
- func convertChangeJobCfg() {
- for _, data := range serverproto.ConditionCfgLoader {
- convertData := &ChangeCondition{
- Condition: make(map[int32][]int32),
- }
- for _, subData := range data.Condition {
- condList := strings.Split(subData, ":")
- if len(condList) < 2 {
- continue
- }
- taskType, _ := Str2Num(condList[0])
- convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(taskType))
- for i := 1; i < len(condList); i++ {
- cfgValue, _ := Str2Num(condList[i])
- convertData.Condition[int32(taskType)] = append(convertData.Condition[int32(taskType)], int32(cfgValue))
- }
- }
- ChangeJobCond[data.ConditionId] = convertData
- }
- }
- var ConvertCrossRankInfo *CrossRankInfo = nil
- type CrossRankInfo struct {
- RewardInfo []*CrossRankRewardInfo
- Duration int32
- }
- type CrossRankRewardInfo struct {
- Left, Right int32
- RewardList map[int32]int32
- }
- func convertCrossRankCfg() {
- for _, data := range serverproto.YuanHangTrialRankCfgLoader {
- if ConvertCrossRankInfo == nil {
- ConvertCrossRankInfo = &CrossRankInfo{}
- }
- rankRewardInfo := &CrossRankRewardInfo{
- RewardList: map[int32]int32{},
- }
- if len(data.YuanHangTrialRankCondition) == 1 {
- dataList := strings.Split(data.YuanHangTrialRankCondition[0], ":")
- left, _ := Str2Num(dataList[0])
- right, _ := Str2Num(dataList[1])
- rankRewardInfo.Left = int32(left)
- rankRewardInfo.Right = int32(right)
- }
- for idx := range data.YuanHangTrialRankReward {
- key, value := Str2Res(data.YuanHangTrialRankReward[idx])
- rankRewardInfo.RewardList[key] += value
- }
- ConvertCrossRankInfo.RewardInfo = append(ConvertCrossRankInfo.RewardInfo, rankRewardInfo)
- }
- }
- var TowerBuff1Cost []*TowerBuff
- var TowerBuff2Cost []*TowerBuff
- var TowerBuff3Cost []*TowerBuff
- type TowerBuff struct {
- Key int32
- Value int32
- }
- type ArenaRankSeasonInfo struct {
- ZoneId int32
- SeasonId int32
- RewardInfo []*ArenaRankRewardInfo
- Duration int32
- Reset int32
- StartTimeStr, EndTimeStr string
- StartTime, EndTime time.Time
- DiffDurationDay int64
- }
- type ArenaRankRewardInfo struct {
- Left, Right int32
- RewardList map[int32]int32
- }
- // var ConvertArenaSeasonReward = map[int32]*ArenaRankSeasonInfo{} //赛季对应top排行奖励
- var ConvertArenaSeason *ArenaRankSeasonInfo = nil
- type ArenaMatchInfo struct {
- LevelId int32 //段位ID
- MinScore int32 //段位对应的最低分
- Score int32 //段位对应的最高分
- ScoreRewardList, WinRewardList, FailedRewardList map[int32]int32 //段位奖励 胜利奖励 失败奖励
- WinScore, WinScore1, WinScore2 int32 //score 与强敌胜利获得积分
- FailedScore, FailedScore1, FailedScore2 int32
- ScoreSectionLeft, ScoreSectionRight float32 //强弱区间
- WinStreak []int32
- //match
- WinMatchList, FailedMatchList []serverproto.KeyValueType
- LevelReduce int32
- }
- var ConvertArenaMatch []*ArenaMatchInfo //arena胜利失败奖励
- var ConvertArenaMatchList = map[int32]*ArenaMatchInfo{}
- var ConvertScoreToArenaLevelList = map[int32]int32{} //最低分数对应段位
- var MinTopRankScore int32 = 0 //入top排行榜最低积分(段位的积分)
- func convertArenaCfg(zoneId int32) {
- //clean for reload
- ConvertArenaMatch = []*ArenaMatchInfo{}
- ConvertArenaMatchList = map[int32]*ArenaMatchInfo{}
- ConvertScoreToArenaLevelList = map[int32]int32{}
- MinTopRankScore = 0
- //ArenaRewardCfg
- //加载对应服务器赛季数据
- for _, data := range serverproto.ArenaRewardCfgLoader {
- if data.Zone != zoneId {
- continue
- }
- if ConvertArenaSeason == nil {
- ConvertArenaSeason = &ArenaRankSeasonInfo{
- ZoneId: data.Zone,
- SeasonId: 0,
- }
- }
- if data.StartTime != "" && data.CloseTime != "" {
- //loc := util.GetLoc()
- //sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.StartTime, loc)
- //if err1 != nil {
- // util.PanicF("convertArenaCfg startTime err:%v", err1)
- //}
- //ConvertArenaSeason.StartTime = sTime
- ConvertArenaSeason.StartTimeStr = data.StartTime
- //cTime, err2 := time.ParseInLocation(util.DATE_FORMAT, data.CloseTime, loc)
- //if err2 != nil {
- // util.PanicF("convertArenaCfg endTime err:%v", err2)
- //}
- //ConvertArenaSeason.EndTime = cTime
- ConvertArenaSeason.EndTimeStr = data.CloseTime
- }
- rankRewardInfo := &ArenaRankRewardInfo{
- RewardList: map[int32]int32{},
- }
- if len(data.ArenaRank) > 1 {
- left, _ := Str2Num(data.ArenaRank[0])
- right, _ := Str2Num(data.ArenaRank[1])
- rankRewardInfo.Left = int32(left)
- rankRewardInfo.Right = int32(right)
- } else {
- left, _ := Str2Num(data.ArenaRank[0])
- rankRewardInfo.Left = int32(left)
- }
- for idx := range data.ArenaReward {
- key, value := Str2Res(data.ArenaReward[idx])
- rankRewardInfo.RewardList[key] += value
- }
- ConvertArenaSeason.RewardInfo = append(ConvertArenaSeason.RewardInfo, rankRewardInfo)
- ConvertArenaSeason.Reset = data.Rest
- }
- //未找到对应zone数据,默认使用zone=1数据
- zoneId = 1
- if ConvertArenaSeason == nil {
- for _, data := range serverproto.ArenaRewardCfgLoader {
- if data.Zone != zoneId {
- continue
- }
- if ConvertArenaSeason == nil {
- ConvertArenaSeason = &ArenaRankSeasonInfo{
- ZoneId: data.Zone,
- SeasonId: 0,
- }
- }
- if data.StartTime != "" && data.CloseTime != "" {
- //loc := util.GetLoc()
- //sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.StartTime, loc)
- //if err1 != nil {
- // util.PanicF("convertArenaCfg startTime err:%v", err1)
- //}
- //ConvertArenaSeason.StartTime = sTime
- ConvertArenaSeason.StartTimeStr = data.StartTime
- //cTime, err2 := time.ParseInLocation(util.DATE_FORMAT, data.CloseTime, loc)
- //if err2 != nil {
- // util.PanicF("convertArenaCfg endTime err:%v", err2)
- //}
- //ConvertArenaSeason.EndTime = cTime
- ConvertArenaSeason.EndTimeStr = data.CloseTime
- }
- rankRewardInfo := &ArenaRankRewardInfo{
- RewardList: map[int32]int32{},
- }
- if len(data.ArenaRank) > 1 {
- left, _ := Str2Num(data.ArenaRank[0])
- right, _ := Str2Num(data.ArenaRank[1])
- rankRewardInfo.Left = int32(left)
- rankRewardInfo.Right = int32(right)
- } else {
- left, _ := Str2Num(data.ArenaRank[0])
- rankRewardInfo.Left = int32(left)
- }
- for idx := range data.ArenaReward {
- key, value := Str2Res(data.ArenaReward[idx])
- rankRewardInfo.RewardList[key] += value
- }
- ConvertArenaSeason.RewardInfo = append(ConvertArenaSeason.RewardInfo, rankRewardInfo)
- ConvertArenaSeason.Reset = data.Rest
- }
- }
- sort.Slice(ConvertArenaSeason.RewardInfo, func(i, j int) bool {
- return ConvertArenaSeason.RewardInfo[i].Left < ConvertArenaSeason.RewardInfo[j].Left
- })
- ConvertArenaSeason.DiffDurationDay = util.GetDurationDay(ConvertArenaSeason.StartTimeStr, ConvertArenaSeason.EndTimeStr)
- //ArenaLevelCfg
- var minScore int32 = 0
- var levelKeyList []int32
- for _, data := range serverproto.ArenaLevelCfgLoader {
- levelKeyList = append(levelKeyList, data.ArenaLevelId)
- }
- sort.Slice(levelKeyList, func(i, j int) bool {
- return levelKeyList[i] < levelKeyList[j]
- })
- for idx := 0; idx < len(levelKeyList); idx++ {
- data := serverproto.ArenaLevelCfgLoader[levelKeyList[idx]]
- info := &ArenaMatchInfo{
- LevelId: data.ArenaLevelId,
- Score: data.ArenaLevelScore,
- ScoreRewardList: map[int32]int32{},
- WinRewardList: map[int32]int32{},
- FailedRewardList: map[int32]int32{},
- WinScore: data.WinScore,
- WinScore1: data.WinScore1,
- WinScore2: data.WinScore2,
- FailedScore: data.LostScore,
- FailedScore1: data.LostScore1,
- FailedScore2: data.LostScore2,
- }
- for idx := range data.ArenaLevelReward {
- key, value := Str2Res(data.ArenaLevelReward[idx])
- if key > 0 && value > 0 {
- info.ScoreRewardList[key] = value
- }
- }
- for idx := range data.WinReward {
- key, value := Str2Res(data.WinReward[idx])
- if key > 0 && value > 0 {
- info.WinRewardList[key] = value
- }
- }
- for idx := range data.FailReward {
- key, value := Str2Res(data.FailReward[idx])
- if key > 0 && value > 0 {
- info.FailedRewardList[key] = value
- }
- }
- if len(data.Section) == 2 {
- left, _ := Str2Num(data.Section[0])
- right, _ := Str2Num(data.Section[1])
- info.ScoreSectionLeft = 1 + float32(left)*0.01
- info.ScoreSectionRight = 1 + float32(right)*0.01
- }
- info.WinStreak = append(info.WinStreak, 0)
- for idx := range data.WinStreak {
- val, _ := Str2Num(data.WinStreak[idx])
- info.WinStreak = append(info.WinStreak, int32(val))
- }
- for idx := range data.Win {
- left, right := Str2Res(data.Win[idx])
- info.WinMatchList = append(info.WinMatchList, serverproto.KeyValueType{Key: left, Value: right})
- }
- for idx := range data.Fail {
- left, right := Str2Res(data.Fail[idx])
- info.FailedMatchList = append(info.FailedMatchList, serverproto.KeyValueType{Key: left, Value: right})
- }
- info.LevelReduce = data.LevelReduce
- if minScore == 0 {
- info.MinScore = minScore
- } else {
- info.MinScore = minScore + 1
- }
- ConvertArenaMatch = append(ConvertArenaMatch, info)
- ConvertArenaMatchList[info.LevelId] = info
- ConvertScoreToArenaLevelList[info.MinScore] = info.LevelId
- minScore = info.Score
- }
- sort.Slice(ConvertArenaMatch, func(i, j int) bool {
- return ConvertArenaMatch[i].Score < ConvertArenaMatch[j].Score
- })
- MinTopRankScore = ConvertArenaMatch[len(ConvertArenaMatch)-3].MinScore
- }
- type ConvertDaoChang100Info struct {
- posIdx int32
- posIdxType int32
- PosIdxFuncType int32
- RewardList []*serverproto.KeyValueType
- RobotId int32
- TimeProtect uint64
- TimeReward uint64
- }
- var ConvertDaoChang100List = map[int32]*ConvertDaoChang100Info{}
- func convertDaoChang100Cfg() {
- for _, data := range serverproto.HundredDojoCfgLoader {
- info := &ConvertDaoChang100Info{
- posIdx: data.Id,
- posIdxType: data.AreaType,
- PosIdxFuncType: data.FunType,
- RobotId: data.Robot,
- TimeProtect: uint64(data.TimeProtect) * 60 * 1000,
- TimeReward: uint64(data.TimeReward) * 60 * 1000,
- }
- for idx := 0; idx < len(data.RewardList); idx++ {
- k, v := Str2Res(data.RewardList[idx])
- if k > 0 && v > 0 {
- info.RewardList = append(info.RewardList, &serverproto.KeyValueType{Key: k, Value: v})
- }
- }
- if data.FunType == 1 {
- if _, ok := ConvertRobotDaoChang100[data.Robot]; !ok {
- panic("ConvertRobotDaoChang100 nil")
- }
- }
- ConvertDaoChang100List[info.posIdx] = info
- }
- }
- type ConvertPartnerInfo struct {
- PartnerId int32
- EquipList []int32
- Level int32
- }
- type ConvertRobotInfo struct {
- RobotId int32
- RobotName string
- ArenaId int32
- Level int32
- Avatar int32
- EquipList []int32
- SkillList []int32
- Head int32
- PartnerIdList []*ConvertPartnerInfo
- FightInfo *serverproto.FightRoleInfo
- }
- func (this *ConvertRobotInfo) initFightInfo() {
- this.FightInfo = &serverproto.FightRoleInfo{
- IsRobot: true,
- BriefInfo: &serverproto.CommonPlayerBriefInfo{
- Uid: uint64(this.RobotId),
- NickName: this.RobotName,
- },
- }
- }
- var ConvertArenaRobot []int32 //[ArenaLevelId,RobotId]
- var ConvertRobot = map[int32]*ConvertRobotInfo{}
- var ConvertRobotDaoChang100 = map[int32]*ConvertRobotInfo{}
- var ConvertRobotCrossTopTower []*ConvertRobotInfo
- func convertRobotCfg() {
- //clean for reload
- ConvertArenaRobot = []int32{}
- ConvertRobot = map[int32]*ConvertRobotInfo{}
- ConvertRobotDaoChang100 = map[int32]*ConvertRobotInfo{}
- for _, data := range serverproto.RobotCfgLoader {
- //道场使用(段位对应机器人列表)
- ConvertArenaRobot = append(ConvertArenaRobot, data.RobotId)
- robotData := &ConvertRobotInfo{
- RobotId: data.RobotId,
- ArenaId: data.ArenaLevelId,
- Level: data.RobotLevel,
- Avatar: data.RobotAvatar,
- Head: data.RobotHeadPortrait,
- RobotName: data.RobotName,
- }
- for idx := range data.RobotEquip {
- equipId, _ := Str2Num(data.RobotEquip[idx])
- robotData.EquipList = append(robotData.EquipList, int32(equipId))
- }
- for idx := range data.RobotSkill {
- skillId, _ := Str2Num(data.RobotSkill[idx])
- robotData.SkillList = append(robotData.SkillList, int32(skillId))
- }
- //伙伴列表
- for idx := range data.PartnerId {
- partnerInfo := &ConvertPartnerInfo{}
- partnerId, _ := Str2Num(data.PartnerId[idx])
- partnerInfo.PartnerId = int32(partnerId)
- //伙伴装备
- partnerEquipStrList := strings.Split(data.PartnerEquip[idx], ":")
- for j := range partnerEquipStrList {
- partnerEquipId, _ := Str2Num(partnerEquipStrList[j])
- partnerInfo.EquipList = append(partnerInfo.EquipList, int32(partnerEquipId))
- }
- //伙伴等级
- partnerLevel, _ := Str2Num(data.PartnerLevel[idx])
- partnerInfo.Level = int32(partnerLevel)
- robotData.PartnerIdList = append(robotData.PartnerIdList, partnerInfo)
- }
- robotData.initFightInfo()
- switch data.SystemType {
- case 0:
- ConvertRobot[data.RobotId] = robotData
- case 1:
- ConvertRobotDaoChang100[data.RobotId] = robotData
- case 2:
- ConvertRobotCrossTopTower = append(ConvertRobotCrossTopTower, robotData)
- //ConvertRobotCrossTopTower[data.RobotId] = robotData
- }
- }
- }
- // WorldBossCfg
- var ConvertWorldBoss = map[int32][]*ConvertWorldBossData{} //[1,info][2,info][3,info][0,info]
- type KillRewardInfo struct {
- RewardWeight int32
- DeductionWeight int32
- RewardList []*serverproto.KeyValueType //1大奖,2中奖,3参与奖
- }
- const (
- SummonBossType_Normal = iota //普通世界boss
- SummonBossType_ChangePlay //变身世界boss
- )
- type ConvertWorldBossData struct {
- Id int32
- RefreshId int32
- SummonId int32
- SummonType int32 //
- StartDay int32 //=0表示根据给定的时间来开启[BossBeginTime,BossEndTime]
- SummonTime []time.Time //刷新时间
- DurationTime int32
- RollTotalWeight int32
- DeductionWeight int32
- RollList []*KillRewardInfo
- ReduceHp *serverproto.KeyValueType //1大奖,2中奖,3参与奖
- RefreshTime time.Time //刷新boss的时间错,逻辑中使用
- //WorldBossChangePlay
- BossBeginTimeStamp uint64
- BossEndTimeStmp uint64
- BossBeginTime time.Time
- BossEndTime time.Time
- ConsumeList map[int32]int32
- ChangePlayIdList []*serverproto.KeyValueType
- TotalChangePlayWeight int32
- }
- func (this *ConvertWorldBossData) RandChangePlayId() int32 {
- var retBossId int32 = 0
- randWeight := rand.Int31n(this.TotalChangePlayWeight) + 1
- for idx := 0; idx < len(this.ChangePlayIdList); idx++ {
- retBossId = this.ChangePlayIdList[idx].Key
- if this.ChangePlayIdList[idx].Value >= randWeight {
- break
- }
- }
- return retBossId
- }
- var ConvertWorldBossList = map[int32]*ConvertWorldBossData{}
- var ConvertWorldBossChangePlayList = map[int32]*ConvertWorldBossData{}
- const (
- WorldBossListNum = 6
- )
- func convertWorldBossCfg() {
- //WorldBossCfg
- for _, data := range serverproto.WorldBossCfgLoader {
- refreshId := data.Id % 4
- convertData, ok := ConvertWorldBossList[data.Id]
- if !ok {
- convertData = &ConvertWorldBossData{
- RefreshId: refreshId,
- Id: data.Id,
- DurationTime: 3600,
- SummonId: data.SummonId,
- }
- }
- convertData.StartDay = data.StartDay
- //convertData.Roll = data.Roll
- convertData.DurationTime = data.LifeTime
- loc := util.GetLoc()
- for idx := range data.SummonTime {
- sTime, err := time.ParseInLocation(util.DATE_FORMAT3, data.SummonTime[idx], loc)
- if err == nil {
- convertData.SummonTime = append(convertData.SummonTime, sTime)
- //util.DebugF("bossid=%v summontime=%v", convertData.Id, sTime.String())
- }
- }
- for idx := 0; idx < len(data.Roll); idx++ {
- rollVal, _ := Str2Num(data.Roll[idx]) //正常概率
- if rollVal <= 0 {
- continue
- }
- rollVal2, _ := Str2Num(data.Roll2[idx]) //衰减概率
- if rollVal2 <= 0 {
- continue
- }
- convertData.RollTotalWeight += int32(rollVal)
- convertData.DeductionWeight += int32(rollVal2)
- RollData := &KillRewardInfo{
- RewardWeight: convertData.RollTotalWeight,
- DeductionWeight: convertData.DeductionWeight,
- }
- if idx == 0 {
- for idx := 0; idx < len(data.FirstRewardServer); idx++ {
- key, val := Str2Res(data.FirstRewardServer[idx])
- if key <= 0 || val <= 0 {
- continue
- }
- RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
- Key: key,
- Value: val,
- })
- }
- } else if idx == 1 {
- for idx := 0; idx < len(data.SecondRewardServer); idx++ {
- key, val := Str2Res(data.SecondRewardServer[idx])
- if key <= 0 || val <= 0 {
- continue
- }
- RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
- Key: key,
- Value: val,
- })
- }
- } else if idx == 2 {
- for idx := 0; idx < len(data.ThreeRewardServer); idx++ {
- key, val := Str2Res(data.ThreeRewardServer[idx])
- if key <= 0 || val <= 0 {
- continue
- }
- RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
- Key: key,
- Value: val,
- })
- }
- }
- key, value := Str2Res(data.AutoHp[0])
- convertData.ReduceHp = &serverproto.KeyValueType{
- Key: key,
- Value: value,
- }
- convertData.RollList = append(convertData.RollList, RollData)
- }
- ConvertWorldBossList[data.Id] = convertData
- //log.Print("time:", convertData.SummonTime[0].String(), convertData.SummonTime[1].String(), convertData.SummonTime[2].String())
- ConvertWorldBoss[refreshId] = append(ConvertWorldBoss[refreshId], convertData)
- sort.Slice(ConvertWorldBoss[refreshId], func(i, j int) bool {
- return ConvertWorldBoss[refreshId][i].StartDay < ConvertWorldBoss[refreshId][j].StartDay
- })
- }
- //WorldBossChangePlayCfg
- for _, data := range serverproto.WorldBossChangePlayCfgLoader {
- convertData := &ConvertWorldBossData{
- //RefreshId: refreshId,
- Id: data.Id,
- DurationTime: data.LifeTime,
- SummonId: data.SummonId,
- ConsumeList: map[int32]int32{},
- }
- convertData.SummonType = SummonBossType_ChangePlay
- loc := util.GetLoc()
- for idx := range data.SummonTime {
- sTime, err := time.ParseInLocation(util.DATE_FORMAT3, data.SummonTime[idx], loc)
- if err == nil {
- convertData.SummonTime = append(convertData.SummonTime, sTime)
- //util.DebugF("bossid=%v summontime=%v", convertData.Id, sTime.String())
- }
- }
- //beginTime endTime
- tmpStartTimeList := strings.Split(data.StartTime, ";")
- if tmpStartTimeList[0] == "1" && len(tmpStartTimeList) >= 2 {
- convertData.BossBeginTime = util.GetTimeByStr(tmpStartTimeList[1])
- convertData.BossBeginTimeStamp = uint64(convertData.BossBeginTime.UnixNano() / 1e6)
- }
- tmpEndTimeList := strings.Split(data.EndTime, ";")
- if tmpEndTimeList[0] == "1" && len(tmpEndTimeList) >= 2 {
- convertData.BossEndTime = util.GetTimeByStr(tmpEndTimeList[1])
- convertData.BossEndTimeStmp = uint64(convertData.BossEndTime.UnixNano() / 1e6)
- }
- //consume list
- Str2ResMapList(data.Consume, convertData.ConsumeList)
- //ChangePlayList
- var totalWeight int32 = 0
- for idx := 0; idx < len(data.ChangePlayId); idx++ {
- k, v := Str2Res(data.ChangePlayId[idx])
- if k <= 0 || v <= 0 {
- continue
- }
- totalWeight += k
- convertData.ChangePlayIdList = append(convertData.ChangePlayIdList,
- &serverproto.KeyValueType{
- Key: v,
- Value: totalWeight,
- })
- }
- convertData.TotalChangePlayWeight = totalWeight
- for idx := 0; idx < len(data.Roll); idx++ {
- rollVal, _ := Str2Num(data.Roll[idx]) //正常概率
- if rollVal <= 0 {
- continue
- }
- rollVal2, _ := Str2Num(data.Roll2[idx]) //衰减概率
- if rollVal2 <= 0 {
- continue
- }
- convertData.RollTotalWeight += int32(rollVal)
- convertData.DeductionWeight += int32(rollVal2)
- RollData := &KillRewardInfo{
- RewardWeight: convertData.RollTotalWeight,
- DeductionWeight: convertData.DeductionWeight,
- }
- if idx == 0 {
- for idx := 0; idx < len(data.FirstRewardServer); idx++ {
- key, val := Str2Res(data.FirstRewardServer[idx])
- if key <= 0 || val <= 0 {
- continue
- }
- RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
- Key: key,
- Value: val,
- })
- }
- } else if idx == 1 {
- for idx := 0; idx < len(data.SecondRewardServer); idx++ {
- key, val := Str2Res(data.SecondRewardServer[idx])
- if key <= 0 || val <= 0 {
- continue
- }
- RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
- Key: key,
- Value: val,
- })
- }
- } else if idx == 2 {
- for idx := 0; idx < len(data.ThreeRewardServer); idx++ {
- key, val := Str2Res(data.ThreeRewardServer[idx])
- if key <= 0 || val <= 0 {
- continue
- }
- RollData.RewardList = append(RollData.RewardList, &serverproto.KeyValueType{
- Key: key,
- Value: val,
- })
- }
- }
- key, value := Str2Res(data.AutoHp[0])
- convertData.ReduceHp = &serverproto.KeyValueType{
- Key: key,
- Value: value,
- }
- convertData.RollList = append(convertData.RollList, RollData)
- }
- ConvertWorldBossChangePlayList[data.Id] = convertData
- }
- }
- type SkillAttr struct {
- AttrList map[int32][]*serverproto.KeyValueType
- }
- var ConvertSkillAttr = map[int32]*SkillAttr{}
- func convertSkillUpEffect() {
- for _, data := range serverproto.SkillUpEffectCfgLoader {
- if data == nil {
- //有错误,直接返回
- return
- }
- passData := ConvertSkillAttr[data.SkillId]
- if passData == nil {
- key, value := Str2Res(data.AddAttributes[0])
- attrData := &SkillAttr{
- AttrList: map[int32][]*serverproto.KeyValueType{},
- }
- skillLevel := data.Id % 1000
- attrData.AttrList[skillLevel] = append(attrData.AttrList[skillLevel], &serverproto.KeyValueType{
- Key: key,
- Value: value,
- })
- ConvertSkillAttr[data.SkillId] = attrData
- } else {
- key, value := Str2Res(data.AddAttributes[0])
- skillLevel := data.Id % 1000
- passData.AttrList[skillLevel] = append(passData.AttrList[skillLevel], &serverproto.KeyValueType{
- Key: key,
- Value: value,
- })
- }
- }
- }
- type keyValList struct {
- KeyType int32
- ValList []float32
- RankList []int32
- }
- type compConditionAndRewardData struct {
- Id int32 //档位
- CfgId int32 //配置表ID
- ConditionList []*keyValList //条件
- RewardList []map[int32]int32 //对应结算周期奖励
- }
- type CompetitionTypeData struct {
- CompetitionId int32
- CompetitionType int32
- ConditionList map[int32]*compConditionAndRewardData //对应档位数据
- LastConditionId int32
- //赛季特殊道具ID
- CompetitionItemList set.Interface
- }
- var ConvertCompTypeList = map[int32]*CompetitionTypeData{} //赛季类型数据
- func (this *CompetitionTypeData) GetCompetitionType() int32 {
- return this.CompetitionType
- }
- func (this *CompetitionTypeData) GetRankSection(selfRank, totalRank int64) (int32, bool, int32) {
- if selfRank <= 0 || totalRank <= 0 {
- return this.LastConditionId, false, this.LastConditionId
- } else {
- if totalRank < GlobalCompetitionSectionTotal {
- totalRank = GlobalCompetitionSectionTotal
- }
- rankPercent := 1 - float32(selfRank)*GlobalCompetitionSectionFactor/float32(totalRank)
- rankPercent = rankPercent * 100
- //first rank 直接返回第一档
- if totalRank > 0 && selfRank == 1 {
- rankPercent = 100
- }
- //rankPercent := (1 - float32(selfRank-1)/float32(totalRank)) * 100
- for _, data := range this.ConditionList {
- for _, conditionData := range data.ConditionList {
- if conditionData.KeyType == 5 {
- if conditionData.RankList[0] <= int32(selfRank) &&
- int32(selfRank) <= conditionData.RankList[1] {
- return data.Id, (data.Id == 1), data.CfgId
- }
- } else {
- if len(conditionData.ValList) >= 2 &&
- rankPercent > float32(conditionData.ValList[0]) &&
- rankPercent <= float32(conditionData.ValList[1]) {
- return data.Id, (data.Id == 1), data.CfgId
- // return data.Id, data.Id%int32(len(this.ConditionList)) == 1
- }
- }
- }
- }
- util.ErrorF("GetRankSection not find correct sectionId rankPercent=%v [please find cehua!!!]", rankPercent)
- }
- return this.LastConditionId, false, this.LastConditionId
- }
- type CompetitionBeginEndTimeData struct {
- CalBeginTime, CalEndTime time.Time //根据开服时间计算后的开启和结束时间
- }
- type CompetitionTimeData struct {
- CompetitionId int32
- CompetitionType int32 //赛季类型
- Duration int32 //持续天数,天为单位
- PeriodEndStrList []int
- BeginTimeStr, EndTimeStr string //开始/结束时间
- ResetTime int32 //休赛季时间,天为单位
- RewardTimeStr []string
- RewardTime []time.Time //周期结算时间
- CalBeginTime, CalEndTime time.Time //根据开服时间计算后的开启和结束时间
- PeriodEndTimeList []time.Time //中间结算时间点
- }
- func (this *CompetitionTimeData) GetCalEndTime() time.Time {
- return this.CalEndTime
- }
- func (this *CompetitionTimeData) GetCompetitionType() int32 {
- return this.CompetitionType
- }
- var ConvertCompTimeList = map[int32]*CompetitionTimeData{} //赛季时间数据
- var ConvertCompTimeIdList []*CompetitionTimeData //赛季时间顺序数据
- func convertCompetitionCfg() {
- //clean for reload
- ConvertCompTimeIdList = []*CompetitionTimeData{}
- ConvertCompTimeList = map[int32]*CompetitionTimeData{}
- //CompetitionCfg
- ConvertCompTypeList = map[int32]*CompetitionTypeData{}
- for _, data := range serverproto.CompetitionCfgLoader {
- info, ok := ConvertCompTypeList[data.CompetitionId]
- if !ok {
- info = &CompetitionTypeData{
- CompetitionId: data.CompetitionId,
- CompetitionType: data.CompetitionType,
- ConditionList: map[int32]*compConditionAndRewardData{},
- CompetitionItemList: set.New(set.NonThreadSafe),
- }
- }
- //条件
- conditionData := &compConditionAndRewardData{
- // Id: data.Id,
- Id: data.Level,
- CfgId: data.Id,
- }
- for idx := range data.CompetitionCondition {
- dataList := strings.Split(data.CompetitionCondition[idx], ":")
- keyType, _ := Str2Num(dataList[0])
- keyData := &keyValList{KeyType: int32(keyType)}
- for i := 1; i < len(dataList); i++ {
- if keyType == 5 {
- val, _ := Str2Num(dataList[i])
- keyData.RankList = append(keyData.RankList, int32(val))
- } else {
- val, _ := Str2Float32(dataList[i])
- //val, _ := Str2Num(dataList[i])
- keyData.ValList = append(keyData.ValList, float32(val))
- }
- }
- conditionData.ConditionList = append(conditionData.ConditionList, keyData)
- }
- //结算奖励
- if data.CompetitionType == 1 || data.CompetitionType == 2 || data.CompetitionType == 3 || data.CompetitionType == 4 ||
- data.CompetitionType == 5 {
- //第一次结算
- var reward1List = map[int32]int32{}
- for k := 0; k < len(data.CompetitionReward1); k++ {
- key, val := Str2Res(data.CompetitionReward1[k])
- if key > 0 && val > 0 {
- reward1List[key] += val
- }
- }
- conditionData.RewardList = append(conditionData.RewardList, reward1List)
- //第二次结算
- var reward2List = map[int32]int32{}
- for k := 0; k < len(data.CompetitionReward2); k++ {
- key, val := Str2Res(data.CompetitionReward2[k])
- if key > 0 && val > 0 {
- reward2List[key] += val
- }
- }
- conditionData.RewardList = append(conditionData.RewardList, reward2List)
- //第三次次结算
- var reward3List = map[int32]int32{}
- for k := 0; k < len(data.CompetitionReward3); k++ {
- key, val := Str2Res(data.CompetitionReward3[k])
- if key > 0 && val > 0 {
- reward3List[key] += val
- }
- }
- conditionData.RewardList = append(conditionData.RewardList, reward3List)
- }
- info.ConditionList[data.Id] = conditionData
- if info.LastConditionId < data.Id {
- info.LastConditionId = data.Id
- }
- //活动道具
- for idx := 0; idx < len(data.HuodongItem); idx++ {
- val, _ := Str2Num(data.HuodongItem[idx])
- if val > 0 {
- info.CompetitionItemList.Add(int32(val))
- }
- }
- ConvertCompTypeList[info.CompetitionId] = info
- }
- //赛季时间处理
- for _, data := range serverproto.CompetitionCfgLoader {
- if data.BeginTime == "" || data.EndTime == "" {
- continue
- }
- timeInfo, ok := ConvertCompTimeList[data.CompetitionId]
- if ok {
- continue
- }
- timeInfo = &CompetitionTimeData{
- CompetitionId: data.CompetitionId,
- CompetitionType: data.CompetitionType,
- ResetTime: data.RestTime,
- BeginTimeStr: data.BeginTime,
- EndTimeStr: data.EndTime,
- }
- for k := 0; k < len(data.CompetitionPeriod); k++ {
- val, _ := Str2Num(data.CompetitionPeriod[k])
- if val <= 0 {
- util.PanicF("CompetitionCfgLoader CompetitionPeriod Invalid!!!")
- }
- timeInfo.PeriodEndStrList = append(timeInfo.PeriodEndStrList, val)
- }
- sort.Ints(timeInfo.PeriodEndStrList)
- if len(timeInfo.PeriodEndStrList) <= 0 {
- util.PanicF("CompetitionCfgLoader CompetitionPeriod Invalid!!!")
- }
- timeInfo.Duration = int32(timeInfo.PeriodEndStrList[len(timeInfo.PeriodEndStrList)-1])
- ConvertCompTimeList[timeInfo.CompetitionId] = timeInfo
- ConvertCompTimeIdList = append(ConvertCompTimeIdList, timeInfo)
- }
- sort.Slice(ConvertCompTimeIdList, func(i, j int) bool {
- return ConvertCompTimeIdList[i].CompetitionId < ConvertCompTimeIdList[j].CompetitionId
- })
- }
- const (
- WheelRewardType_Level = 1
- WheelRewardType_Normal = 2
- WheelRewardType_Mini = 3
- WheelRewardType_MVp = 4
- )
- type CompetitionPrizeWheelInfo struct {
- ID int32
- //奖励数据
- LowRewardKv serverproto.KeyValueType
- NormalRewardKv serverproto.KeyValueType //normal [掉落ID,数量]
- MiniRewardKV serverproto.KeyValueType
- MVPRewardKV serverproto.KeyValueType
- Weight int32
- RewardFactorList map[int]int32 //抽奖概率 1low 2normal 3mini 4mvp
- MvpFactorList []int32 //4mvp
- }
- type WheelItemInfo struct {
- Key int32 //道具id
- Val int32 //道具数量
- Money int32 //金币消耗
- Score int32 //积分
- }
- type ConvertPrizeWheelInfo struct {
- RewardTemplateList []*CompetitionPrizeWheelInfo
- TotalWeight int32
- WheelCostItem []*WheelItemInfo //道具/金币消耗 抽一次
- WheelAllCostItem WheelItemInfo //抽全部道具/金币消耗
- RefreshCostMoney []int32 // 刷新价格(金币)
- NoMVPRewardNum int32 //前面无大奖次数
- ItemToMoney int32 //单个道具对应金币数量
- }
- func (this *ConvertPrizeWheelInfo) genWheelRewardByType(itemIdx *int32, rewardType int32,
- kv serverproto.KeyValueType, rewardList *[]*serverproto.WheelRewardItemInfo) {
- for idx := 0; idx < int(kv.Value); idx++ {
- *itemIdx++
- rewardItem := &serverproto.WheelRewardItemInfo{
- ItemIdx: *itemIdx,
- RewardType: rewardType, //1
- }
- tmpDropReward := map[int32]int32{}
- DropCfgProcess(tmpDropReward, kv.Key)
- for k, v := range tmpDropReward {
- if k > 0 && v > 0 {
- rewardItem.ItemId = k
- rewardItem.ItemNum = v
- }
- break
- }
- *rewardList = append(*rewardList, rewardItem)
- }
- }
- func (this *ConvertPrizeWheelInfo) GenWheelReward(rewardList *[]*serverproto.WheelRewardItemInfo) int32 {
- if this.TotalWeight <= 0 {
- return 0
- }
- var tmpRewardList []*serverproto.WheelRewardItemInfo
- randWeight := rand.Int31n(this.TotalWeight) + 1 //[0,randWeight]
- templateIdx := 0
- for idx := 0; idx < len(this.RewardTemplateList); idx++ {
- templateIdx = idx
- if randWeight <= this.RewardTemplateList[idx].Weight {
- break
- }
- }
- templateInfo := this.RewardTemplateList[templateIdx]
- var itemIdx int32 = 0
- //level
- this.genWheelRewardByType(&itemIdx, WheelRewardType_Level, templateInfo.LowRewardKv, &tmpRewardList)
- //normal
- this.genWheelRewardByType(&itemIdx, WheelRewardType_Normal, templateInfo.NormalRewardKv, &tmpRewardList)
- //mini
- this.genWheelRewardByType(&itemIdx, WheelRewardType_Mini, templateInfo.MiniRewardKV, &tmpRewardList)
- //mvp
- this.genWheelRewardByType(&itemIdx, WheelRewardType_MVp, templateInfo.MVPRewardKV, &tmpRewardList)
- randArray := GenRandomArrayByLen(len(tmpRewardList))
- for idx := 0; idx < len(randArray); idx++ {
- *rewardList = append(*rewardList, tmpRewardList[randArray[idx]-1])
- }
- util.DebugF("templateIdx=%v GenWheelReward=%v", templateInfo.ID, *rewardList)
- return templateInfo.ID
- }
- func (this *ConvertPrizeWheelInfo) GetTemplateData(templateIdx int32) *CompetitionPrizeWheelInfo {
- for idx := 0; idx < len(this.RewardTemplateList); idx++ {
- if this.RewardTemplateList[idx].ID == templateIdx {
- return this.RewardTemplateList[idx]
- }
- }
- return nil
- }
- var ConvertPrizeWheelData *ConvertPrizeWheelInfo
- var ConvertActivityPrizeWheelData = map[int32]*ConvertPrizeWheelInfo{}
- func convertCompetitionPrizeWheelCfg() {
- ConvertPrizeWheelData = &ConvertPrizeWheelInfo{}
- //赛季转盘
- for _, cfgData := range serverproto.CompetitionPrizeWheelCfgLoader {
- convertCompetitionPrizeWheelCfgLoad(cfgData, ConvertPrizeWheelData)
- }
- //活动转盘
- for _, cfgData := range serverproto.ActivityRoulettelCfgLoader {
- if _, ok := ConvertActivityPrizeWheelData[cfgData.ActivitiesId]; !ok {
- ConvertActivityPrizeWheelData[cfgData.ActivitiesId] = &ConvertPrizeWheelInfo{}
- }
- convertActivityPrizeWheelCfgLoad(cfgData, ConvertActivityPrizeWheelData[cfgData.ActivitiesId])
- }
- }
- func convertCompetitionPrizeWheelCfgLoad(cfgData *serverproto.CompetitionPrizeWheelCfg, tmpData *ConvertPrizeWheelInfo) {
- //赛季转盘
- tmpData.TotalWeight += cfgData.ModProbability
- if cfgData.NoRewardNum > 0 {
- tmpData.NoMVPRewardNum = cfgData.NoRewardNum
- }
- if cfgData.ItemPrice > 0 {
- tmpData.ItemToMoney = cfgData.ItemPrice
- }
- if len(cfgData.RefreshPrice) > 0 && cfgData.RefreshPrice[0] != "" {
- for idx := 0; idx < len(cfgData.RefreshPrice); idx++ {
- tmpVal, _ := Str2Num(cfgData.RefreshPrice[idx])
- tmpData.RefreshCostMoney = append(tmpData.RefreshCostMoney, int32(tmpVal))
- }
- }
- templateData := &CompetitionPrizeWheelInfo{
- ID: cfgData.Id,
- Weight: tmpData.TotalWeight,
- RewardFactorList: map[int]int32{},
- }
- //low
- k, v := Str2Res(cfgData.LowNormalNum[0])
- templateData.LowRewardKv.Key = v
- templateData.LowRewardKv.Value = k
- //normal
- k, v = Str2Res(cfgData.NormalNum[0])
- templateData.NormalRewardKv.Key = v
- templateData.NormalRewardKv.Value = k
- //mini
- k, v = Str2Res(cfgData.MiniNum[0])
- templateData.MiniRewardKV.Key = v
- templateData.MiniRewardKV.Value = k
- //mvp
- k, v = Str2Res(cfgData.MvpNum[0])
- templateData.MVPRewardKV.Key = v
- templateData.MVPRewardKV.Value = k
- for idx := 0; idx < len(cfgData.Probability); idx++ {
- factor, _ := Str2Num(cfgData.Probability[idx])
- templateData.RewardFactorList[idx+1] = int32(factor)
- }
- for idx := 0; idx < len(cfgData.MvpProbability); idx++ {
- factor, _ := Str2Num(cfgData.MvpProbability[idx])
- templateData.MvpFactorList = append(templateData.MvpFactorList, int32(factor))
- }
- if len(cfgData.RewardOneItem) > 0 && cfgData.RewardOneItem[0] != "" {
- if len(cfgData.RewardOneItem) != len(cfgData.RewardOneGold) {
- util.PanicF("convertCompetitionPrizeWheelCfg")
- }
- for idx := 0; idx < len(cfgData.RewardOneItem); idx++ {
- k, v := Str2Res(cfgData.RewardOneItem[idx])
- score, _ := Str2Num(cfgData.RewardOnePoint[idx])
- tmpMoney, _ := Str2Num(cfgData.RewardOneGold[idx])
- tmpWheelInfo := &WheelItemInfo{
- Key: k,
- Val: v,
- Money: int32(tmpMoney),
- Score: int32(score),
- }
- tmpData.WheelCostItem = append(tmpData.WheelCostItem, tmpWheelInfo)
- }
- k, v := Str2Res(cfgData.RewardAllItem[0])
- tmpData.WheelAllCostItem.Key = k
- tmpData.WheelAllCostItem.Val = v
- tmpData.WheelAllCostItem.Money = cfgData.RewardAdllGold
- tmpData.WheelAllCostItem.Score = cfgData.RewardAllPoint
- }
- tmpData.RewardTemplateList = append(tmpData.RewardTemplateList, templateData)
- }
- func convertActivityPrizeWheelCfgLoad(cfgData *serverproto.ActivityRoulettelCfg, tmpData *ConvertPrizeWheelInfo) {
- //赛季转盘
- tmpData.TotalWeight += cfgData.ModProbability
- if cfgData.NoRewardNum > 0 {
- tmpData.NoMVPRewardNum = cfgData.NoRewardNum
- }
- if cfgData.ItemPrice > 0 {
- tmpData.ItemToMoney = cfgData.ItemPrice
- }
- if len(cfgData.RefreshPrice) > 0 && cfgData.RefreshPrice[0] != "" {
- for idx := 0; idx < len(cfgData.RefreshPrice); idx++ {
- tmpVal, _ := Str2Num(cfgData.RefreshPrice[idx])
- tmpData.RefreshCostMoney = append(tmpData.RefreshCostMoney, int32(tmpVal))
- }
- }
- templateData := &CompetitionPrizeWheelInfo{
- ID: cfgData.Id,
- Weight: tmpData.TotalWeight,
- RewardFactorList: map[int]int32{},
- }
- //low
- k, v := Str2Res(cfgData.LowNormalNum[0])
- templateData.LowRewardKv.Key = v
- templateData.LowRewardKv.Value = k
- //normal
- k, v = Str2Res(cfgData.NormalNum[0])
- templateData.NormalRewardKv.Key = v
- templateData.NormalRewardKv.Value = k
- //mini
- k, v = Str2Res(cfgData.MiniNum[0])
- templateData.MiniRewardKV.Key = v
- templateData.MiniRewardKV.Value = k
- //mvp
- k, v = Str2Res(cfgData.MvpNum[0])
- templateData.MVPRewardKV.Key = v
- templateData.MVPRewardKV.Value = k
- for idx := 0; idx < len(cfgData.Probability); idx++ {
- factor, _ := Str2Num(cfgData.Probability[idx])
- templateData.RewardFactorList[idx+1] = int32(factor)
- }
- for idx := 0; idx < len(cfgData.MvpProbability); idx++ {
- factor, _ := Str2Num(cfgData.MvpProbability[idx])
- templateData.MvpFactorList = append(templateData.MvpFactorList, int32(factor))
- }
- if len(cfgData.RewardOneItem) > 0 && cfgData.RewardOneItem[0] != "" {
- if len(cfgData.RewardOneItem) != len(cfgData.RewardOneGold) {
- util.PanicF("convertCompetitionPrizeWheelCfg")
- }
- for idx := 0; idx < len(cfgData.RewardOneItem); idx++ {
- k, v := Str2Res(cfgData.RewardOneItem[idx])
- tmpMoney, _ := Str2Num(cfgData.RewardOneGold[idx])
- tmpWheelInfo := &WheelItemInfo{
- Key: k,
- Val: v,
- Money: int32(tmpMoney),
- }
- tmpData.WheelCostItem = append(tmpData.WheelCostItem, tmpWheelInfo)
- }
- k, v := Str2Res(cfgData.RewardAllItem[0])
- tmpData.WheelAllCostItem.Key = k
- tmpData.WheelAllCostItem.Val = v
- tmpData.WheelAllCostItem.Money = cfgData.RewardAdllGold
- }
- tmpData.RewardTemplateList = append(tmpData.RewardTemplateList, templateData)
- }
- // 卡片重置
- var ConvertCardResetList = map[int32]*serverproto.CardReset{} //赛季类型数据
- func convertCardResetCfg() {
- for _, data := range serverproto.CardResetLoader {
- index := data.CardType*1000 + data.CardLv
- if index == 0 {
- //打印一下日志。有问题的
- continue
- }
- ConvertCardResetList[index] = data
- }
- }
- type ResetSkill struct {
- BackResource map[int32]int32
- }
- type levelUpInfo struct {
- HeroLevel map[int32]int32 //技能升级对应的等级限制
- OpenCost []*serverproto.KeyValueType //解锁消耗
- UpGradeCost map[int32]*serverproto.KeyValueType //升级消耗
- ResetBack map[int32]int32 //重置返还
- }
- var ConvertSkillTree = map[int32]*levelUpInfo{}
- var ConvertPartnerSkillTree = map[int32]*levelUpInfo{}
- var ConvertResetSkill = map[int32]*serverproto.KeyValueType{}
- var ConvertSkillJobAndStage = map[int32][]*serverproto.KeyValueType{} //[jobType*100+jobStage*10 +jobBranch,skillIdList]
- // var ConvertParterSkillJobAndStage = map[int32][]*serverproto.KeyValueType{} //[jobType*100+jobStage*10 +jobBranch,skillIdList]
- var ConvertBattleAttrSkill = map[int32]map[serverproto.Attr]float32{} //优化属性计算
- func convertSkillTree() {
- //解析伙伴的技能升级数据
- for _, data := range serverproto.ParterSkillTreeCfgLoader {
- convertData := &levelUpInfo{
- HeroLevel: map[int32]int32{},
- UpGradeCost: map[int32]*serverproto.KeyValueType{},
- ResetBack: map[int32]int32{},
- }
- dem, ok := serverproto.SkillDemandCfgLoader[data.OpenLevel]
- if !ok {
- panic("技能升级表 对应伙伴技能表错误")
- }
- for i, lv := range dem.LvupDemand {
- level, _ := Str2Num(lv)
- convertData.HeroLevel[int32(i)] = int32(level)
- }
- for _, openCost := range data.OpenNeedCost {
- key, val := Str2Res(openCost)
- if key == 0 && val == 0 {
- continue
- }
- convertData.OpenCost = append(convertData.OpenCost, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(val),
- })
- }
- var backCount int32 = 0
- for index, upCost := range dem.LvupCost {
- key, val := Str2Res(upCost)
- if key == 0 && val == 0 {
- continue
- }
- convertData.UpGradeCost[int32(index)] = &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(val),
- }
- //初始化返还数量
- backCount += val
- convertData.ResetBack[int32(index+2)] += backCount
- }
- ConvertPartnerSkillTree[data.SkillId] = convertData
- }
- //解析伙伴的技能升级数据
- for _, data := range serverproto.SkillTreeCfgLoader {
- convertData := &levelUpInfo{
- HeroLevel: map[int32]int32{},
- UpGradeCost: map[int32]*serverproto.KeyValueType{},
- ResetBack: map[int32]int32{},
- }
- dem, ok := serverproto.SkillDemandCfgLoader[data.OpenLevel]
- if !ok {
- panic("技能升级表 对应主角技能表错误")
- }
- for index, rLevel := range dem.LvupDemand {
- level, _ := Str2Num(rLevel)
- convertData.HeroLevel[int32(index)] = int32(level)
- }
- for _, openCost := range data.OpenNeedCost {
- key, val := Str2Res(openCost)
- if key == 0 && val == 0 {
- continue
- }
- convertData.OpenCost = append(convertData.OpenCost, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(val),
- })
- }
- var backCount int32 = 0
- for index, cost := range dem.LvupCost {
- key, val := Str2Res(cost)
- if key == 0 && val == 0 {
- continue
- }
- convertData.UpGradeCost[int32(index)] = &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(val),
- }
- //初始化返还数量
- backCount += val
- convertData.ResetBack[int32(index+2)] += backCount
- }
- ConvertSkillTree[data.SkillId] = convertData
- }
- globalCfg, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Reset_Skill_Level_Cost)]
- if !ok {
- util.InfoF("skill reset cost config not found")
- }
- strList := strings.Split(globalCfg.SVal, ";")
- for idx := range strList {
- key, value := Str2Res(strList[idx])
- if key == 0 && value == 0 {
- continue
- }
- ConvertResetSkill[int32(idx)] = &serverproto.KeyValueType{
- Key: key,
- Value: value,
- }
- }
- }
- type ShopRefreshCost struct {
- ItemList map[int32]int32
- }
- type SpecialShop struct {
- ItemList []*SpecialShopItem
- TotalWeight int32 //权重1
- TotalWeight1 int32 //权重2
- TotalWeight2 int32 //权重3
- TotalWeight3 int32 //权重4
- TotalWeight4 int32 //权重5
- RefreshTime []int32
- RefreshCost map[int32]*ShopRefreshCost
- RefreshCount int32
- }
- type SpecialShopItem struct {
- ShopItem *serverproto.ShopItem
- Weight int32
- Weight1 int32
- Weight2 int32
- Weight3 int32
- Weight4 int32
- }
- type RedBagShopTime struct {
- ShopItem *serverproto.ShopItem
- ItemList map[int32]int32
- }
- var ConvertShopItemData = map[int32]*serverproto.ShopItem{}
- var ConvertRoleShopData = map[int32]*SpecialShop{}
- var ConvertRedBagShopItemData = map[int32]*RedBagShopTime{}
- type ItemCondition struct {
- Conditions []*serverproto.KeyValueType
- }
- var ConvertShopItemCondition = map[int32]*ItemCondition{}
- func convertShopCfg() {
- //初始化商店类型
- for _, shopData := range serverproto.ShopTypeCfgLoader {
- ConvertRoleShopData[shopData.Id] = &SpecialShop{
- TotalWeight: 0,
- TotalWeight1: 0,
- TotalWeight2: 0,
- TotalWeight3: 0,
- TotalWeight4: 0,
- RefreshCost: make(map[int32]*ShopRefreshCost),
- }
- //刷新时间
- for _, refTime := range shopData.RefreshTime {
- hour, _ := Str2Num(refTime)
- ConvertRoleShopData[shopData.Id].RefreshTime = append(ConvertRoleShopData[shopData.Id].RefreshTime, int32(hour))
- }
- //刷新消耗
- for index, costData := range shopData.PayForRefresh {
- limitRes := strings.Split(costData, ":")
- if len(limitRes) >= 2 {
- itemId, _ := Str2Num(limitRes[0])
- itemNum, _ := Str2Num(limitRes[1])
- _, ok := ConvertRoleShopData[shopData.Id].RefreshCost[int32(index)]
- if !ok {
- refreshCost := &ShopRefreshCost{
- ItemList: make(map[int32]int32),
- }
- refreshCost.ItemList[int32(itemId)] += int32(itemNum)
- ConvertRoleShopData[shopData.Id].RefreshCost[int32(index)] = refreshCost
- } else {
- ConvertRoleShopData[shopData.Id].RefreshCost[int32(index)].ItemList[int32(itemId)] += int32(itemNum)
- }
- }
- }
- ConvertRoleShopData[shopData.Id].RefreshCount = shopData.RefreshNum
- }
- for _, data := range serverproto.ShopCfgLoader {
- convertData := &serverproto.ShopItem{}
- convertData.GoodsId = data.GoodsId
- convertData.Price = data.PayForNum
- convertData.CurPrice = data.DiscountPayForNum
- convertData.Dispercent = data.Proportion
- convertData.Hot = true
- convertData.HdItemId = data.HdDrop
- if data.SellWell == 0 {
- convertData.Hot = false
- }
- var limitType int32 = 0
- limitRes := strings.Split(data.RestrictedType, ":")
- if len(limitRes) >= 2 {
- lType, _ := Str2Num(limitRes[0])
- convertData.LimitType = int32(lType)
- limitType = convertData.LimitType
- if len(limitRes) == 2 {
- lCount, _ := Str2Num(limitRes[1])
- convertData.Count = int32(lCount)
- }
- if len(limitRes) >= 3 {
- lCircle, _ := Str2Num(limitRes[1])
- convertData.Circle = int32(lCircle)
- lCount, _ := Str2Num(limitRes[2])
- convertData.Count = int32(lCount)
- }
- }
- if limitType == 3 {
- loc := util.GetLoc()
- if data.BeginTime != "" {
- sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.BeginTime, loc)
- if err1 != nil {
- util.PanicF("convertShop startTime err:%v", err1)
- }
- convertData.StartTime = int64(sTime.Unix())
- }
- if data.EndTime != "" {
- cTime, err2 := time.ParseInLocation(util.DATE_FORMAT, data.EndTime, loc)
- if err2 != nil {
- util.PanicF("convertShop endTime err:%v", err2)
- }
- convertData.EndTime = int64(cTime.Unix())
- }
- }
- //特殊商店单独处理
- shopType, ok2 := serverproto.ShopTypeCfgLoader[data.GoodsType]
- if ok2 && shopType.ShopType == 2 {
- _, ok4 := ConvertRoleShopData[data.GoodsType]
- if !ok4 {
- //道具没有对应的商店。这策划不靠谱!!!!
- util.PanicF("convertShop shopType not found err:%v", data.GoodsType)
- }
- //计算最新的权重
- ConvertRoleShopData[data.GoodsType].TotalWeight += data.Weight
- ConvertRoleShopData[data.GoodsType].TotalWeight1 += data.Weight1
- ConvertRoleShopData[data.GoodsType].TotalWeight2 += data.Weight2
- ConvertRoleShopData[data.GoodsType].TotalWeight3 += data.Weight3
- ConvertRoleShopData[data.GoodsType].TotalWeight4 += data.Weight4
- shopItem := &SpecialShopItem{}
- shopItem.Weight = ConvertRoleShopData[data.GoodsType].TotalWeight
- shopItem.Weight1 = ConvertRoleShopData[data.GoodsType].TotalWeight1
- shopItem.Weight2 = ConvertRoleShopData[data.GoodsType].TotalWeight2
- shopItem.Weight3 = ConvertRoleShopData[data.GoodsType].TotalWeight3
- shopItem.Weight4 = ConvertRoleShopData[data.GoodsType].TotalWeight4
- shopItem.ShopItem = convertData
- ConvertRoleShopData[data.GoodsType].ItemList = append(ConvertRoleShopData[data.GoodsType].ItemList, shopItem)
- continue
- }
- //
- if data.GoodsType == 50 {
- shopItem := &RedBagShopTime{}
- shopItem.ShopItem = convertData
- shopItem.ItemList = make(map[int32]int32)
- for _, items := range data.Reward {
- limitRes := strings.Split(items, ":")
- if len(limitRes) >= 2 {
- itemId, _ := Str2Num(limitRes[0])
- itemCount, _ := Str2Num(limitRes[1])
- shopItem.ItemList[int32(itemId)] = int32(itemCount)
- }
- }
- ConvertRedBagShopItemData[data.GoodsId] = shopItem
- continue
- }
- ConvertShopItemData[data.GoodsId] = convertData
- if len(data.Condition) > 0 {
- condition := &ItemCondition{}
- for _, cond := range data.Condition {
- condId, condArg := Str2Res(cond)
- if condId != 0 && condArg != 0 {
- condition.Conditions = append(condition.Conditions, &serverproto.KeyValueType{
- Key: int32(condId),
- Value: int32(condArg),
- })
- }
- }
- ConvertShopItemCondition[data.GoodsId] = condition
- }
- }
- }
- // 比较refTime 和当前时间是否在同一时间段内
- func CheckShopNeedRefresh(refTime int64) bool {
- if refTime < util.GetTimeSeconds() {
- return true
- }
- return false
- }
- func GetNextShopRefreshHour(shopType int32, curHour int32) int32 {
- shopData, ok := ConvertRoleShopData[shopType]
- if !ok {
- return -1
- }
- for _, data := range shopData.RefreshTime {
- if curHour < data {
- return data
- }
- }
- return shopData.RefreshTime[0]
- }
- func GetShopItemByShopType(shopType int32, vipWeight int32) []int32 {
- shop, ok1 := serverproto.ShopTypeCfgLoader[shopType]
- if !ok1 {
- return nil
- }
- if shop.ShopType != 2 || shop.GoodsRefreshNum <= 0 {
- return nil
- }
- shopData, ok2 := ConvertRoleShopData[shopType]
- if !ok2 {
- return nil
- }
- if int32(len(shopData.ItemList)) < shop.GoodsRefreshNum {
- return nil
- }
- var itemList []int32
- selected := map[int32]int32{}
- totalWeight := shopData.TotalWeight
- if vipWeight == 1 {
- totalWeight = shopData.TotalWeight1
- } else if vipWeight == 2 {
- totalWeight = shopData.TotalWeight2
- } else if vipWeight == 3 {
- totalWeight = shopData.TotalWeight3
- } else if vipWeight == 4 {
- totalWeight = shopData.TotalWeight4
- }
- if totalWeight == 0 {
- return nil
- }
- for i := 0; i < int(shop.GoodsRefreshNum); {
- randWeight := rand.Int31n(totalWeight) //[0,randWeight)
- for _, data := range shopData.ItemList {
- weight := data.Weight
- if vipWeight == 1 {
- weight = data.Weight1
- } else if vipWeight == 2 {
- weight = data.Weight2
- } else if vipWeight == 3 {
- weight = data.Weight3
- } else if vipWeight == 4 {
- weight = data.Weight4
- }
- if weight == 0 { //策划口头补充的需求
- continue
- }
- if randWeight <= weight {
- _, ok3 := selected[data.ShopItem.GoodsId]
- if ok3 { //找到重复的
- break
- }
- itemList = append(itemList, data.ShopItem.GoodsId)
- selected[data.ShopItem.GoodsId] = 1
- i++
- break
- }
- }
- }
- return itemList
- }
- type SignInData struct {
- VipLevel int32
- DaySign []*serverproto.KeyValueType //每日签到奖励
- AccuSign []*serverproto.KeyValueType //累积签到奖励
- }
- var ConvertSignUpData = map[int32]*SignInData{}
- func convertSignInCfg() {
- for _, data := range serverproto.SignInCfgLoader {
- convertData := SignInData{}
- if len(data.SignInReward) > 0 {
- for _, reward := range data.SignInReward {
- key, val := Str2Res(reward)
- if key == 0 || val == 0 {
- continue
- }
- convertData.DaySign = append(convertData.DaySign, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(val),
- })
- }
- }
- if len(data.SignInAddReward) > 0 {
- for _, reward := range data.SignInAddReward {
- key, val := Str2Res(reward)
- if key == 0 || val == 0 {
- continue
- }
- convertData.AccuSign = append(convertData.AccuSign, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(val),
- })
- }
- }
- convertData.VipLevel = data.VipLevel
- ConvertSignUpData[data.ID] = &convertData
- }
- if len(ConvertSignUpData)%30 != 0 {
- util.PanicF("convertSign total count err:%v", len(ConvertSignUpData))
- }
- }
- var ActiveCodeList = map[string]struct{}{}
- func convertActiveCodeCfg() {
- for _, val := range serverproto.ActiveCodeCfgLoader {
- ActiveCodeList[val.Code] = struct{}{}
- }
- }
- func CheckActiveCode(activeCode string) serverproto.ErrorCode {
- if activeCode == "" {
- return serverproto.ErrorCode_ERROR_ROLE_ACTIVECODE_ERROR
- }
- if len(ActiveCodeList) <= 0 {
- return serverproto.ErrorCode_ERROR_OK
- }
- if _, ok := ActiveCodeList[activeCode]; !ok {
- return serverproto.ErrorCode_ERROR_ROLE_ACTIVECODE_ERROR
- }
- return serverproto.ErrorCode_ERROR_OK
- }
- type LevelItem struct {
- MapId int32
- LevelId int32
- //boss战小怪
- MonsterList []*serverproto.KeyValueType
- BossId int32
- BossPos int32
- RageId uint32
- }
- var ConvertMapItemList = map[int32]*LevelItem{}
- func convertMapCfg() {
- //for _, mapItemData := range serverproto.MapCfgLoader {
- // var levelId int32 = 1
- // mapId := mapItemData.Id
- // for {
- // tmpId := mapId*10000 + levelId
- // data, ok := serverproto.LevelCfgLoader[tmpId]
- // if !ok {
- // break
- // }
- // addLevelItem := &LevelItem{
- // MapId: mapId,
- // LevelId: levelId,
- // }
- //
- // //boss战小怪处理
- // for idx := 0; idx <= len(data.Monsters); idx++ {
- // loc, monsterId := Str2Res(data.Monsters[idx])
- // if loc >= 1 && loc <= 6 && monsterId > 0 {
- // addLevelItem.MonsterList = append(addLevelItem.MonsterList,
- // &serverproto.KeyValueType{
- // Key: loc,
- // Value: monsterId,
- // })
- // }
- // }
- //
- // if data.BossId > 0 {
- // addLevelItem.BossId = data.BossId
- // addLevelItem.BossPos = data.BossPosition
- // addLevelItem.RageId = uint32(data.BossRageBuffId)
- // }
- //
- // ConvertMapItemList[tmpId] = addLevelItem
- // }
- //}
- }
- // NatureCfg.csv
- var ConvertNatureMap = map[int32]map[int32][]*serverproto.KeyValueType{}
- func convertNatureCfg() {
- //for _, data := range serverproto.NatureCfgLoader {
- // if data.AntiNature1 != "" {
- // convertNatureAttr(1, data.AntiNature1)
- // }
- // if data.AntiNature2 != "" {
- // convertNatureAttr(2, data.AntiNature2)
- // }
- // if data.AntiNature3 != "" {
- // convertNatureAttr(3, data.AntiNature3)
- // }
- // if data.AntiNature4 != "" {
- // convertNatureAttr(4, data.AntiNature4)
- // }
- // if data.AntiNature5 != "" {
- // convertNatureAttr(5, data.AntiNature5)
- // }
- // if data.AntiNature6 != "" {
- // convertNatureAttr(6, data.AntiNature6)
- // }
- // if data.AntiNature7 != "" {
- // convertNatureAttr(7, data.AntiNature7)
- // }
- //}
- }
- func convertNatureAttr(natureId int32, attr string) {
- attrList := strings.Split(attr, ";")
- for idx := range attrList {
- key, value := Str2Res(attrList[idx])
- if key > 0 && value > 0 {
- if ConvertNatureMap[natureId] == nil {
- ConvertNatureMap[natureId] = map[int32][]*serverproto.KeyValueType{}
- }
- ConvertNatureMap[natureId][key] = append(ConvertNatureMap[natureId][key], &serverproto.KeyValueType{
- Key: key,
- Value: value,
- })
- }
- }
- }
- type TowerReward struct {
- ItemList []*serverproto.KeyValueType
- ExItemList []*serverproto.KeyValueType
- FightCheck int32
- SPAdd *serverproto.KeyValueType
- }
- var ConvertTowerData = map[int32]*TowerReward{}
- var ConvertClimbPowerDecayFactorList = map[int32]*ConvertDecayData{}
- var ConvertClimbTimeDecayFactorList = map[int32]*ConvertDecayData{}
- func convertTowerCfg() {
- for _, tower := range serverproto.ClimbingTowerCfgLoader {
- convertReward := &TowerReward{}
- for _, items := range tower.RewardItems {
- key, value := Str2Res(items)
- if key == 0 || value == 0 {
- continue
- }
- convertReward.ItemList = append(convertReward.ItemList, &serverproto.KeyValueType{
- Key: key,
- Value: value,
- })
- }
- for _, special := range tower.SpecialReward {
- key, value := Str2Res(special)
- if key == 0 || value == 0 {
- continue
- }
- convertReward.ExItemList = append(convertReward.ExItemList, &serverproto.KeyValueType{
- Key: key,
- Value: value,
- })
- }
- convertReward.FightCheck = tower.FightCheck
- //power
- parseDecay(tower.Id, tower.PowerWeaken, ConvertClimbPowerDecayFactorList)
- //time
- parseDecay(tower.Id, tower.StayTimeWeaken, ConvertClimbTimeDecayFactorList)
- //sp add
- k, v := Str2Res(tower.SpAddition)
- if k > 0 && v > 0 {
- convertReward.SPAdd = &serverproto.KeyValueType{Key: k, Value: v}
- }
- ConvertTowerData[tower.Id] = convertReward
- }
- }
- var ConvertTowerWjData = map[int32][]*TowerWjReward{} //key是层数
- var ConvertTowerWjRankInfo *TowerWjRankInfo = nil
- type TowerWjReward struct {
- Min, Max int32
- ExItemList []*serverproto.KeyValueType
- FightCheck int32
- }
- type TowerWjRankInfo struct {
- RewardInfo []*TowerWjRankRewardInfo
- Duration int32
- }
- type TowerWjRankRewardInfo struct {
- Left, Right int32
- RewardList map[int32]int32
- }
- func convertTowerWjCfg() {
- for _, tower := range serverproto.TowerWjRewardCfgLoader {
- convertReward := &TowerWjReward{}
- for _, special := range tower.SpecialReward {
- key, value := Str2Res(special)
- if key == 0 || value == 0 {
- continue
- }
- convertReward.ExItemList = append(convertReward.ExItemList, &serverproto.KeyValueType{
- Key: key,
- Value: value,
- })
- }
- if len(tower.Levels) > 0 {
- key, value := Str2Res(tower.Levels[0])
- if key == 0 || value == 0 {
- continue
- convertReward.Min = key
- convertReward.Max = value
- }
- ConvertTowerWjData[tower.Day] = append(ConvertTowerWjData[tower.Day], convertReward)
- }
- for _, data := range serverproto.TowerWjRankCfgLoader {
- if ConvertTowerWjRankInfo == nil {
- ConvertTowerWjRankInfo = &TowerWjRankInfo{}
- }
- rankRewardInfo := &TowerWjRankRewardInfo{
- RewardList: map[int32]int32{},
- }
- if len(data.RankCondition) == 1 {
- dataList := strings.Split(data.RankCondition[0], ":")
- left, _ := Str2Num(dataList[0])
- right, _ := Str2Num(dataList[1])
- rankRewardInfo.Left = int32(left)
- rankRewardInfo.Right = int32(right)
- }
- for idx := range data.RankReward {
- key, value := Str2Res(data.RankReward[idx])
- rankRewardInfo.RewardList[key] += value
- }
- ConvertTowerWjRankInfo.RewardInfo = append(ConvertTowerWjRankInfo.RewardInfo, rankRewardInfo)
- }
- }
- }
- type ConvertEvilBossData struct {
- EvilLevel int32
- MaxFightingTime int32
- MonsterList []*serverproto.KeyValueTypeList
- LevelReward map[int32]int32
- LevelTimes int32
- }
- var ConvertEvilBossList = map[int32]*ConvertEvilBossData{}
- func convertEvilCfg() {
- for _, data := range serverproto.EvilCfgLoader {
- convertData := &ConvertEvilBossData{
- EvilLevel: data.Id,
- MaxFightingTime: data.MaxFightingTime,
- LevelReward: map[int32]int32{},
- }
- for idx := 0; idx < len(data.MonsterList); idx++ {
- //id,addexp,cd,quality,weight
- v1, v2, v3, v4, v5 := Str2Res_5(data.MonsterList[idx])
- if v1 > 0 && v2 > 0 && v3 > 0 {
- monsterData := &serverproto.KeyValueTypeList{
- Key: v1,
- }
- monsterData.ValueList = append(monsterData.ValueList, v2, v3, v4, v5)
- convertData.MonsterList = append(convertData.MonsterList, monsterData)
- }
- }
- for idx := 0; idx < len(data.LevelReward); idx++ {
- key, val := Str2Res(data.LevelReward[idx])
- if key > 0 && val > 0 {
- convertData.LevelReward[key] += val
- }
- }
- convertData.LevelTimes = data.LevelTimes
- ConvertEvilBossList[convertData.EvilLevel] = convertData
- }
- }
- /*
- type ConvertVIPData struct {
- VipId int32 //vip等级, 1表示vip0,默认数值
- EvilFreeRefreshCount int32 //恶魔免费刷新次数 数值0表示无限次数刷新
- }
- var ConvertVIPList = map[int32]*ConvertVIPData{}
- var maxVipLevel int32 = 0
- func convertVIPCfg() {
- for _, data := range serverproto.VipCfgLoader {
- vipData := &ConvertVIPData{
- VipId: data.Id,
- EvilFreeRefreshCount: data.FreeTimes,
- }
- ConvertVIPList[vipData.VipId-1] = vipData
- if data.Id > maxVipLevel {
- maxVipLevel = data.Id - 1
- }
- }
- }
- func GetVIPDataByLevel(vipLevel int32) *ConvertVIPData {
- if vipLevel < 0 {
- vipLevel = maxVipLevel
- }
- if vipLevel > maxVipLevel {
- vipLevel = maxVipLevel
- }
- if data, ok := ConvertVIPList[vipLevel]; ok {
- return data
- }
- return nil
- }
- */
- type CardCollectReward struct {
- CardId int32
- CardReward map[int32]*serverproto.KeyValueType
- }
- var ConvertCardCollectReward = map[int32]*CardCollectReward{}
- func convertCardCollectCfg() {
- for _, data := range serverproto.CardIdentificationLoader {
- convertData := &CardCollectReward{
- CardId: data.Cardid,
- CardReward: map[int32]*serverproto.KeyValueType{},
- }
- limitRes := strings.Split(data.CardReward1[0], ":")
- if len(limitRes) >= 2 {
- itemKey, _ := Str2Num(limitRes[0])
- itemValue, _ := Str2Num(limitRes[1])
- convertData.CardReward[1] = &serverproto.KeyValueType{
- Key: int32(itemKey),
- Value: int32(itemValue),
- }
- }
- limitRes = strings.Split(data.CardReward2[0], ":")
- if len(limitRes) >= 2 {
- itemKey, _ := Str2Num(limitRes[0])
- itemValue, _ := Str2Num(limitRes[1])
- convertData.CardReward[2] = &serverproto.KeyValueType{
- Key: int32(itemKey),
- Value: int32(itemValue),
- }
- }
- limitRes = strings.Split(data.CardReward3[0], ":")
- if len(limitRes) >= 2 {
- itemKey, _ := Str2Num(limitRes[0])
- itemValue, _ := Str2Num(limitRes[1])
- convertData.CardReward[3] = &serverproto.KeyValueType{
- Key: int32(itemKey),
- Value: int32(itemValue),
- }
- }
- limitRes = strings.Split(data.CardReward4[0], ":")
- if len(limitRes) >= 2 {
- itemKey, _ := Str2Num(limitRes[0])
- itemValue, _ := Str2Num(limitRes[1])
- convertData.CardReward[4] = &serverproto.KeyValueType{
- Key: int32(itemKey),
- Value: int32(itemValue),
- }
- }
- limitRes = strings.Split(data.CardReward5[0], ":")
- if len(limitRes) >= 2 {
- itemKey, _ := Str2Num(limitRes[0])
- itemValue, _ := Str2Num(limitRes[1])
- convertData.CardReward[5] = &serverproto.KeyValueType{
- Key: int32(itemKey),
- Value: int32(itemValue),
- }
- }
- ConvertCardCollectReward[data.Cardid] = convertData
- }
- }
- var ConvertGuildLevel = map[int32]int32{}
- var ConvertLeaveGuildTime = map[int32]int32{}
- func convertGuildLevelCfg() {
- for _, data := range serverproto.GuildLvCfgLoader {
- ConvertGuildLevel[data.Id] = data.ExpRequire
- }
- cfgData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Guild_Leave_Guild_CD)]
- if !ok {
- util.PanicF("convertSign total count err:%v", len(ConvertSignUpData))
- }
- limitRes := strings.Split(cfgData.SVal, ";")
- for _, res := range limitRes {
- cdData := strings.Split(res, ":")
- if len(cdData) >= 2 {
- cdCount, _ := Str2Num(cdData[0])
- cdTime, _ := Str2Num(cdData[1])
- ConvertLeaveGuildTime[int32(cdCount)] = int32(cdTime)
- }
- }
- }
- // pet
- const (
- Pet_Type_Normal = 1
- Pet_Type_Mini = 2
- Pet_Type_MVP = 3
- )
- type PetProgressData struct {
- PetCfgId int32
- ProgressList []*ConvertPetProgressDataDetail
- }
- type ConvertPetProgressDataDetail struct {
- ProgressLevel int32
- CostZeny int32 //消耗zeny
- AttrList []*serverproto.KeyValueType
- RateList []*serverproto.KeyValueType
- //1品质 2进阶等级 3特殊属性
- ConditionPet1 []*serverproto.KeyValueType //进阶消耗的材料
- ConditionPet2 []*serverproto.KeyValueType //进阶消耗的材料
- }
- type ConvertPetSkillData struct {
- SkillId int32
- RateList []int32 //技能发动概率
- MaxSkillLevel int32
- }
- type ConvertPetData struct {
- PetCfgId int32
- Exp int32 //等级1对应的经验
- ManualRewardList map[int32]*serverproto.KeyValueType //图鉴奖励
- Quality int32 //1normal 2mini 3mvp
- NatureType int32
- SkillList []*ConvertPetSkillData //技能列表
- JobType int32
- }
- func (this *ConvertPetData) GetSkill(skillId int32) *ConvertPetSkillData {
- for idx := 0; idx < len(this.SkillList); idx++ {
- if this.SkillList[idx].SkillId == skillId {
- return this.SkillList[idx]
- }
- }
- return nil
- }
- func (this *ConvertPetData) GetSkillRate(skillId, skillLevel int32) int32 {
- if skillLevel <= 0 {
- return 0
- }
- for idx := 0; idx < len(this.SkillList); idx++ {
- if this.SkillList[idx].SkillId == skillId &&
- this.SkillList[idx].MaxSkillLevel >= skillLevel {
- return this.SkillList[idx].RateList[int(skillLevel-1)]
- }
- }
- return 0
- }
- type ConvertExpData struct {
- PetLevel int32
- NormalExp int32
- NormalAccuExp int32 //累计需要经验
- NormalZeny int32
- NormalAccuZeny int32 //累计消耗zeny
- MiniExp int32
- MiniAccuExp int32
- MiniZeny int32
- MiniAccuZeny int32
- MvpExp int32
- MvpAccuExp int32
- MvpZeny int32
- MvpAccuZeny int32
- }
- type ConvertBondData struct {
- BondId int32
- ConditionList1 []*serverproto.KeyValueType
- ConditionList2 []*serverproto.KeyValueType
- ConditionList3 []*serverproto.KeyValueType
- }
- type PetBondFightData struct {
- FightPower1 []*serverproto.KeyValueType
- FightPower2 []*serverproto.KeyValueType
- FightPower3 []*serverproto.KeyValueType
- Attr1List []*serverproto.KeyValueType
- Attr2List []*serverproto.KeyValueType
- Attr3List []*serverproto.KeyValueType
- }
- type PetProFightPower struct {
- AttrMap map[int32]int32
- }
- type PetPartnerFightPower struct {
- FightPower1 map[int32]int32
- FightPower2 map[int32]int32
- FightPower3 map[int32]int32
- }
- type ConvertPetEquipData struct {
- CfgId int32
- Type int32 //位置编号
- Quality int32 //绿色,蓝色,紫色,金色,红色
- MaxLevel int32
- AdvanceTargetEquip int32
- AdvanceCost map[int32]int32
- SuitId int32
- LevelUpList map[int32]*ConvertPetEquipLevelUpData
- }
- type ConvertPetEquipLevelUpData struct {
- Level int32
- CostList map[int32]int32
- AttrList map[int32]int32
- FightPower uint64
- }
- type ConvertPetEquipSuitData struct {
- Id int32
- ConditionList []*serverproto.KeyValueType
- AttrList map[int32]int32
- }
- var ConvertPet = map[int32]*ConvertPetData{}
- var ConvertPetProgress = map[int32]*PetProgressData{}
- var ConvertPetExp = map[int32]*ConvertExpData{}
- var ConvertBond []*ConvertBondData
- var ConvertBondFight = map[int32]*PetBondFightData{}
- var ConvertPetProFight = map[int32]*PetProFightPower{}
- var ConvertPetPartnerFight = map[int32]*PetPartnerFightPower{}
- var ConvertPetEquip = map[int32]*ConvertPetEquipData{} //[equipcfgid][data]
- var ConvertPteEquipSuit []*ConvertPetEquipSuitData
- func getFieldData(fieldName string, data interface{}) []string {
- tmpDataType := reflect.ValueOf(data).Elem()
- tmpVal := tmpDataType.FieldByName(fieldName).Interface()
- switch val := tmpVal.(type) {
- case []string:
- return val
- default:
- panic(errors.New("field type error"))
- }
- return nil
- }
- func convertPetCfg() {
- //clean for reload
- ConvertBond = []*ConvertBondData{}
- //progress
- for _, data := range serverproto.PetProgressCfgLoader {
- progressData := &PetProgressData{
- PetCfgId: data.Id,
- }
- for idx := 0; idx < len(data.CostMoney); idx++ {
- constZeny, _ := Str2Num(data.CostMoney[idx])
- detailData := &ConvertPetProgressDataDetail{
- ProgressLevel: int32(idx) + 1,
- CostZeny: int32(constZeny),
- }
- //condition
- tmpCondition1Str := "Condition" + strconv.Itoa(idx+1) + "1"
- tmpCondition2Str := "Condition" + strconv.Itoa(idx+1) + "2"
- tmpAttrStr := "Attribute" + strconv.Itoa(idx+1)
- tmpAttributeRateAddStr := "AttributeRateAdd" + strconv.Itoa(idx+1)
- convertPetCfg_ProgressCondition(getFieldData(tmpCondition1Str, data), getFieldData(tmpCondition2Str, data), detailData)
- convertPetCfg_ProgressAttr(getFieldData(tmpAttrStr, data), getFieldData(tmpAttributeRateAddStr, data), detailData)
- ////condition
- //switch idx {
- //case 0:
- // convertPetCfg_ProgressCondition(data.Condition11, data.Condition12, detailData)
- // convertPetCfg_ProgressAttr(data.Attribute1, data.AttributeRateAdd1, detailData)
- //case 1:
- // convertPetCfg_ProgressCondition(data.Condition21, data.Condition22, detailData)
- // convertPetCfg_ProgressAttr(data.Attribute2, data.AttributeRateAdd2, detailData)
- //case 2:
- // convertPetCfg_ProgressCondition(data.Condition31, data.Condition32, detailData)
- // convertPetCfg_ProgressAttr(data.Attribute3, data.AttributeRateAdd3, detailData)
- //case 3:
- // convertPetCfg_ProgressCondition(data.Condition41, data.Condition42, detailData)
- // convertPetCfg_ProgressAttr(data.Attribute4, data.AttributeRateAdd4, detailData)
- //case 4:
- // convertPetCfg_ProgressCondition(data.Condition51, data.Condition52, detailData)
- // convertPetCfg_ProgressAttr(data.Attribute5, data.AttributeRateAdd5, detailData)
- //}
- progressData.ProgressList = append(progressData.ProgressList, detailData)
- ConvertPetProgress[progressData.PetCfgId] = progressData
- progressFight := &PetProFightPower{
- AttrMap: make(map[int32]int32),
- }
- var totalFight int32 = 0
- for idx, fightPower := range data.AddFight {
- val, _ := Str2Num(fightPower)
- totalFight += int32(val)
- progressFight.AttrMap[int32(idx)] = totalFight
- }
- ConvertPetProFight[progressData.PetCfgId] = progressFight
- }
- ConvertPetProgress[progressData.PetCfgId] = progressData
- }
- //petskillup global
- //pet
- for _, data := range serverproto.PetCfgLoader {
- petData := &ConvertPetData{
- PetCfgId: data.Id,
- Quality: data.Quality,
- NatureType: data.NatureType,
- JobType: data.JobType,
- }
- petData.ManualRewardList = map[int32]*serverproto.KeyValueType{}
- for idx := 0; idx < len(data.PetReward); idx++ {
- advLevel, key, val := Str2Res_3(data.PetReward[idx])
- if key > 0 && val > 0 {
- petData.ManualRewardList[advLevel] = &serverproto.KeyValueType{Key: key, Value: val}
- }
- }
- //skill
- convertPetCfg_Skill(data.Skill1, data.Skill1Rate, petData)
- convertPetCfg_Skill(data.Skill2, data.Skill2Rate, petData)
- convertPetCfg_Skill(data.Skill3, data.Skill3Rate, petData)
- convertPetCfg_Skill(data.Skill4, data.Skill4Rate, petData)
- ConvertPet[petData.PetCfgId] = petData
- }
- //pet exp
- var tmpList []*ConvertExpData
- for _, data := range serverproto.PetExpCfgLoader {
- expData := &ConvertExpData{
- PetLevel: data.PetLevel,
- NormalExp: data.Experience1,
- NormalZeny: data.CostMoney1,
- MiniExp: data.Experience2,
- MiniZeny: data.CostMoney2,
- MvpExp: data.Experience3,
- MvpZeny: data.CostMoney3,
- }
- ConvertPetExp[expData.PetLevel] = expData
- tmpList = append(tmpList, expData)
- }
- sort.Slice(tmpList, func(i, j int) bool {
- return tmpList[i].PetLevel < tmpList[j].PetLevel
- })
- for idx := 0; idx < len(tmpList); idx++ {
- tmpLevel := tmpList[idx].PetLevel
- if tmpLevel > 1 {
- tmpLevel := tmpList[idx].PetLevel
- ConvertPetExp[tmpLevel].NormalAccuExp = ConvertPetExp[tmpLevel-1].NormalAccuExp + ConvertPetExp[tmpLevel].NormalExp
- ConvertPetExp[tmpLevel].NormalAccuZeny = ConvertPetExp[tmpLevel-1].NormalAccuZeny + ConvertPetExp[tmpLevel].NormalZeny
- ConvertPetExp[tmpLevel].MiniAccuExp = ConvertPetExp[tmpLevel-1].MiniAccuExp + ConvertPetExp[tmpLevel].MiniExp
- ConvertPetExp[tmpLevel].MiniAccuZeny = ConvertPetExp[tmpLevel-1].MiniAccuZeny + ConvertPetExp[tmpLevel].MiniZeny
- ConvertPetExp[tmpLevel].MvpAccuExp = ConvertPetExp[tmpLevel-1].MvpAccuExp + ConvertPetExp[tmpLevel].MvpExp
- ConvertPetExp[tmpLevel].MvpAccuZeny = ConvertPetExp[tmpLevel-1].MvpAccuZeny + ConvertPetExp[tmpLevel].MvpZeny
- } else {
- ConvertPetExp[tmpLevel].NormalAccuExp = ConvertPetExp[tmpLevel].NormalExp
- ConvertPetExp[tmpLevel].NormalAccuZeny = ConvertPetExp[tmpLevel].NormalZeny
- ConvertPetExp[tmpLevel].MiniAccuExp = ConvertPetExp[tmpLevel].MiniExp
- ConvertPetExp[tmpLevel].MiniAccuZeny = ConvertPetExp[tmpLevel].MiniZeny
- ConvertPetExp[tmpLevel].MvpAccuExp = ConvertPetExp[tmpLevel].MvpExp
- ConvertPetExp[tmpLevel].MvpAccuZeny = ConvertPetExp[tmpLevel].MvpZeny
- }
- }
- //pet partner
- for _, data := range serverproto.PetpartnerCfgLoader {
- bondData := &ConvertBondData{
- BondId: data.Id,
- }
- for idx := 0; idx < len(data.Condition1); idx++ {
- key, val := Str2Res(data.Condition1[idx])
- if key <= 0 {
- continue
- }
- bondData.ConditionList1 = append(bondData.ConditionList1, &serverproto.KeyValueType{
- Key: key, Value: val,
- })
- }
- for idx := 0; idx < len(data.Condition2); idx++ {
- key, val := Str2Res(data.Condition2[idx])
- if key <= 0 {
- continue
- }
- bondData.ConditionList2 = append(bondData.ConditionList2, &serverproto.KeyValueType{
- Key: key, Value: val,
- })
- }
- for idx := 0; idx < len(data.Condition3); idx++ {
- key, val := Str2Res(data.Condition3[idx])
- if key <= 0 {
- continue
- }
- bondData.ConditionList3 = append(bondData.ConditionList3, &serverproto.KeyValueType{
- Key: key, Value: val,
- })
- }
- ConvertBond = append(ConvertBond, bondData)
- //战斗力相关 key= {0,1,2,3,4,5}
- bondFightData := &PetBondFightData{}
- for idx := 0; idx < len(data.AddHeroCap1); idx++ {
- key, val := Str2Res(data.AddHeroCap1[idx])
- if key < 0 {
- continue
- }
- bondFightData.FightPower1 = append(bondFightData.FightPower1, &serverproto.KeyValueType{
- Key: key, Value: val,
- })
- }
- for idx := 0; idx < len(data.AddHeroCap2); idx++ {
- key, val := Str2Res(data.AddHeroCap1[idx])
- if key < 0 {
- continue
- }
- bondFightData.FightPower2 = append(bondFightData.FightPower2, &serverproto.KeyValueType{
- Key: key, Value: val,
- })
- }
- for idx := 0; idx < len(data.AddHeroCap3); idx++ {
- key, val := Str2Res(data.AddHeroCap1[idx])
- if key < 0 {
- continue
- }
- bondFightData.FightPower3 = append(bondFightData.FightPower3, &serverproto.KeyValueType{
- Key: key, Value: val,
- })
- }
- //attr
- for idx := 0; idx < len(data.Attribute1); idx++ {
- k, v := Str2Res(data.Attribute1[idx])
- if k <= 0 || v <= 0 {
- continue
- }
- bondFightData.Attr1List = append(bondFightData.Attr1List, &serverproto.KeyValueType{Key: k, Value: v})
- }
- for idx := 0; idx < len(data.Attribute2); idx++ {
- k, v := Str2Res(data.Attribute2[idx])
- if k <= 0 || v <= 0 {
- continue
- }
- bondFightData.Attr2List = append(bondFightData.Attr2List, &serverproto.KeyValueType{Key: k, Value: v})
- }
- for idx := 0; idx < len(data.Attribute3); idx++ {
- k, v := Str2Res(data.Attribute3[idx])
- if k <= 0 || v <= 0 {
- continue
- }
- bondFightData.Attr3List = append(bondFightData.Attr3List, &serverproto.KeyValueType{Key: k, Value: v})
- }
- ConvertBondFight[data.Id] = bondFightData
- }
- sort.Slice(ConvertBond, func(i, j int) bool {
- return ConvertBond[i].BondId < ConvertBond[j].BondId
- })
- //pet equip
- //ConvertPetEquip
- for _, data := range serverproto.PetEquipCfgLoader {
- convertData := &ConvertPetEquipData{
- CfgId: data.Id,
- Quality: data.Quality,
- Type: data.Type,
- MaxLevel: data.MaxLevel,
- AdvanceTargetEquip: data.Advance,
- AdvanceCost: map[int32]int32{},
- LevelUpList: map[int32]*ConvertPetEquipLevelUpData{},
- }
- Str2ResMapList(data.AdvanceCost, convertData.AdvanceCost)
- ConvertPetEquip[convertData.CfgId] = convertData
- }
- for _, data := range serverproto.PetEquipExpCfgLoader {
- convertData, ok := ConvertPetEquip[data.PetEquipID]
- if !ok {
- continue
- }
- levelData := &ConvertPetEquipLevelUpData{
- Level: data.PetEquipLevel,
- CostList: map[int32]int32{},
- AttrList: map[int32]int32{},
- FightPower: uint64(data.FightPower),
- }
- Str2ResMapList(data.Cost, levelData.CostList)
- Str2ResMapList(data.Nature, levelData.AttrList)
- convertData.LevelUpList[data.PetEquipLevel] = levelData
- }
- for _, data := range serverproto.PetEquipSuitCfgLoader {
- convertData := &ConvertPetEquipSuitData{
- Id: data.Id,
- AttrList: map[int32]int32{},
- }
- Str2ResMapList(data.Suit, convertData.AttrList)
- convertData.ConditionList = append(convertData.ConditionList, Str2ResSliceList(data.Amount)...)
- ConvertPteEquipSuit = append(ConvertPteEquipSuit, convertData)
- }
- sort.Slice(ConvertPteEquipSuit, func(i, j int) bool {
- return ConvertPteEquipSuit[i].Id > ConvertPteEquipSuit[j].Id
- })
- }
- func convertPetCfg_ProgressCondition(conditionList1 []string, conditionList2 []string, detailData *ConvertPetProgressDataDetail) {
- for idx := 0; idx < len(conditionList1); idx++ {
- kvList := &serverproto.KeyValueType{}
- v1, v2 := Str2Res(conditionList1[idx])
- if v1 > 0 {
- kvList.Key = v1
- kvList.Value = v2
- }
- detailData.ConditionPet1 = append(detailData.ConditionPet1, kvList)
- }
- for idx := 0; idx < len(conditionList2); idx++ {
- kvList := &serverproto.KeyValueType{}
- v1, v2 := Str2Res(conditionList2[idx])
- if v1 > 0 {
- kvList.Key = v1
- kvList.Value = v2
- }
- detailData.ConditionPet2 = append(detailData.ConditionPet2, kvList)
- }
- }
- func convertPetCfg_ProgressAttr(attrList []string, rateList []string, detailData *ConvertPetProgressDataDetail) {
- for idx := 0; idx < len(attrList); idx++ {
- key, val := Str2Res(attrList[idx])
- if key > 0 && val > 0 {
- detailData.AttrList = append(detailData.AttrList, &serverproto.KeyValueType{
- Key: key, Value: val,
- })
- }
- }
- for idx := 0; idx < len(rateList); idx++ {
- key, val := Str2Res(rateList[idx])
- if key > 0 && val > 0 {
- detailData.RateList = append(detailData.RateList, &serverproto.KeyValueType{
- Key: key, Value: val,
- })
- }
- }
- }
- func convertPetCfg_Skill(skillId int32, skillRateList []string, petData *ConvertPetData) {
- if skillId > 0 {
- skill1 := &ConvertPetSkillData{
- SkillId: skillId,
- }
- for idx := 0; idx < len(skillRateList); idx++ {
- val, _ := Str2Num(skillRateList[idx])
- skill1.RateList = append(skill1.RateList, int32(val))
- }
- skill1.MaxSkillLevel = int32(len(skill1.RateList))
- petData.SkillList = append(petData.SkillList, skill1)
- }
- }
- type GuildBossReward struct {
- RewardList map[int32]int32
- }
- type RankReward struct {
- MaxDam int32
- MinDam int32
- RewardID int32
- MasterReward int32
- }
- type GuildBossRank struct {
- Reward []*RankReward
- MaxDamage int32
- }
- var ConvertGuildBossReward = map[int32]*GuildBossReward{}
- var ConvertGuildBossRewardRank = map[int32]*GuildBossRank{}
- func convertGuildBosRewardsCfg() {
- for _, reward := range serverproto.GuildBossRewardCfgLoader {
- convertReward := &GuildBossReward{
- RewardList: map[int32]int32{},
- }
- for _, data := range reward.Reward {
- strList := strings.Split(data, ":")
- if len(strList) >= 2 {
- itemKey, _ := Str2Num(strList[0])
- itemValue, _ := Str2Num(strList[1])
- convertReward.RewardList[int32(itemKey)] = int32(itemValue)
- }
- }
- ConvertGuildBossReward[reward.Id] = convertReward
- }
- for _, guildBoss := range serverproto.GuildBossCfgLoader {
- convertGuildBossRank := &GuildBossRank{}
- if len(guildBoss.RewardRange) != len(guildBoss.Reward) {
- util.PanicF("[convertGuildBosRewardsCfg] reward config error:%v, %v, %v", guildBoss.Id, len(guildBoss.RewardRange), len(guildBoss.Reward))
- }
- if guildBoss.BossType == 1 { //1 普通boss 2 精英boss
- if len(guildBoss.RewardRange) != len(guildBoss.MasterReward) {
- util.PanicF("[convertGuildBosRewardsCfg] MasterReward config error:%v", guildBoss.Id)
- }
- }
- for idx, rank := range guildBoss.RewardRange {
- strList := strings.Split(rank, ":")
- minDam, _ := Str2Num(strList[0])
- maxDam, _ := Str2Num(strList[1])
- if len(strList) >= 2 {
- rankReward := &RankReward{}
- rankReward.MinDam = int32(minDam)
- rankReward.MaxDam = int32(maxDam)
- rewardId, _ := Str2Num(guildBoss.Reward[idx])
- rankReward.RewardID = int32(rewardId)
- if guildBoss.BossType == 1 { //1 普通boss 2 精英boss
- masterId, _ := Str2Num(guildBoss.MasterReward[idx])
- rankReward.MasterReward = int32(masterId)
- }
- convertGuildBossRank.Reward = append(convertGuildBossRank.Reward, rankReward)
- }
- }
- ConvertGuildBossRewardRank[guildBoss.Id] = convertGuildBossRank
- }
- }
- var ConvertGuildBattleList = map[int32]int32{}
- func convertGuildBattleCfg() {
- for _, cfgData := range serverproto.GuildWarDojoCfgLoader {
- ConvertGuildBattleList[cfgData.Id] = cfgData.GuildWarPoint
- }
- }
- type ConvertExpedition struct {
- ExpeditionType int32
- LevelNum int32
- LevelUnlockAddNum int32
- //UnlockCondition []*serverproto.KeyValueType
- LevelInfo map[int32]*ConvertExpeditionDetailInfo
- LevelCoefficient float32
- PassRewardList []*serverproto.KeyValueType //通关奖励(每日获取一次)
- }
- func (this *ConvertExpedition) GetLevelReward(levelIdx int32, addItemList map[int32]int32) {
- levelData, ok := this.LevelInfo[levelIdx]
- if !ok {
- return
- }
- for idx := 0; idx < len(levelData.RewardList); idx++ {
- addItemList[levelData.RewardList[idx].Key] += levelData.RewardList[idx].Value
- }
- }
- type ConvertExpeditionBossInfo struct {
- Weight int32
- BossId int32
- BossLevel int32
- BossHP int32
- BossSP int32
- }
- type ConvertExpeditionDetailInfo struct {
- Id int32
- LevelId int32
- BossList []*ConvertExpeditionBossInfo
- BuffList []*serverproto.KeyValueType //key:id val:weight
- RewardList []*serverproto.KeyValueType
- MaxFightingTime int32
- WarriorScore int32 //勇士积分
- }
- func (this *ConvertExpeditionDetailInfo) RandBoss(tmpBossIdxList []int) (*ConvertExpeditionBossInfo, int) {
- var totalWeight int32 = 0
- var tmpList []*serverproto.KeyValueType
- for idx := 0; idx < len(this.BossList); idx++ {
- bFind := false
- for k := 0; k < len(tmpBossIdxList); k++ {
- if idx == tmpBossIdxList[k] {
- bFind = true
- break
- }
- }
- if bFind {
- continue
- }
- totalWeight += this.BossList[idx].Weight
- tmpList = append(tmpList, &serverproto.KeyValueType{Key: int32(idx), Value: totalWeight})
- }
- if totalWeight <= 0 {
- return nil, 0
- }
- var retBossIdx = 0
- randWeight := rand.Int31n(totalWeight) + 1
- for idx := 0; idx < len(tmpList); idx++ {
- retBossIdx = int(tmpList[idx].Key)
- if tmpList[idx].Value >= randWeight {
- break
- }
- }
- return this.BossList[retBossIdx], retBossIdx
- }
- func (this *ConvertExpeditionDetailInfo) RandBuff(hasBuffList set.Interface, tmpBuffList []int32, bossId uint64) int32 {
- var retBuffId int32 = 0
- var totalWeight int32 = 0
- var tmpList []*serverproto.KeyValueType
- bossBuffList, ok := ConvertExpeditionDropBuffList[bossId]
- if !ok {
- util.InfoF("Expedition bossid=%v randBuffList empty", bossId)
- return retBuffId
- }
- if len(bossBuffList.BuffList) <= 0 {
- util.InfoF("Expedition bossid=%v randBuffList empty", bossId)
- return retBuffId
- }
- for idx := 0; idx < len(bossBuffList.BuffList); idx++ {
- if hasBuffList.Has(bossBuffList.BuffList[idx].Key) {
- continue
- }
- bFind := false
- for k := 0; k < len(tmpBuffList); k++ {
- if tmpBuffList[k] == bossBuffList.BuffList[idx].Key {
- bFind = true
- break
- }
- }
- if bFind {
- continue
- }
- totalWeight += bossBuffList.BuffList[idx].Value
- tmpList = append(tmpList, &serverproto.KeyValueType{Key: bossBuffList.BuffList[idx].Key, Value: totalWeight})
- }
- if totalWeight <= 0 {
- return 0
- }
- randWeight := rand.Int31n(totalWeight) + 1
- for idx := 0; idx < len(tmpList); idx++ {
- retBuffId = tmpList[idx].Key
- if tmpList[idx].Value >= randWeight {
- break
- }
- }
- return retBuffId
- }
- type ConvertExpeditionBuffInfo struct {
- Id uint64
- BossId int32
- LevelId int32 //关卡唯一ID
- BuffList []*serverproto.KeyValueType //key:id val:weight
- WarriorScore int32 //勇士积分
- }
- var ConvertExpeditionDataList = map[int32]*ConvertExpedition{}
- var ConvertExpeditionDropBuffList = map[uint64]*ConvertExpeditionBuffInfo{}
- func convertExpeditionCfg() {
- //ExpeditionCfg
- for _, cfgData := range serverproto.ExpeditionCfgLoader {
- convertData, ok := ConvertExpeditionDataList[cfgData.Type]
- if !ok {
- convertData = &ConvertExpedition{
- ExpeditionType: cfgData.Type,
- LevelNum: cfgData.LevelNum,
- LevelInfo: map[int32]*ConvertExpeditionDetailInfo{},
- }
- ConvertExpeditionDataList[cfgData.Type] = convertData
- }
- if cfgData.Type > 0 {
- convertData.ExpeditionType = cfgData.Type
- }
- if cfgData.LevelNum > 0 {
- convertData.LevelNum = cfgData.LevelNum
- }
- if cfgData.ChallengeNum > 0 {
- convertData.LevelUnlockAddNum = cfgData.ChallengeNum
- }
- if cfgData.LevelCoefficient > 0 {
- convertData.LevelCoefficient = float32(cfgData.LevelCoefficient) / 100
- }
- if len(cfgData.DayReward) > 0 {
- for idx := 0; idx < len(cfgData.DayReward); idx++ {
- key, val := Str2Res(cfgData.DayReward[idx])
- if key <= 0 || val <= 0 {
- continue
- }
- convertData.PassRewardList = append(convertData.PassRewardList,
- &serverproto.KeyValueType{Key: key, Value: val})
- }
- }
- //level info
- levelInfo := &ConvertExpeditionDetailInfo{
- Id: cfgData.Id,
- LevelId: cfgData.LevelId,
- MaxFightingTime: cfgData.MaxFightingTime,
- WarriorScore: cfgData.WarriorScore,
- }
- //level boss list
- var totalWeight int32 = 0
- for idx := 0; idx < len(cfgData.BossList); idx++ {
- weight, bossId, level, hp, sp := Str2Res_5(cfgData.BossList[idx])
- if bossId <= 0 || level <= 0 || hp <= 0 || sp <= 0 {
- continue
- }
- totalWeight = weight
- bossInfo := &ConvertExpeditionBossInfo{
- Weight: totalWeight,
- BossId: bossId,
- BossLevel: level,
- BossHP: hp,
- BossSP: sp,
- }
- levelInfo.BossList = append(levelInfo.BossList, bossInfo)
- }
- //level reward list
- for idx := 0; idx < len(cfgData.Reward); idx++ {
- key, val := Str2Res(cfgData.Reward[idx])
- if key <= 0 || val <= 0 {
- continue
- }
- levelInfo.RewardList = append(levelInfo.RewardList, &serverproto.KeyValueType{Key: key, Value: val})
- }
- convertData.LevelInfo[levelInfo.LevelId] = levelInfo
- }
- //boss drop buff list
- for _, cfgData := range serverproto.ExpeditionBuffDropCfgLoader {
- bossBuffData := &ConvertExpeditionBuffInfo{
- BossId: cfgData.BossID,
- LevelId: cfgData.LevelId,
- WarriorScore: cfgData.WarriorScore,
- }
- bossBuffData.Id = uint64(bossBuffData.BossId)*100000 + uint64(bossBuffData.LevelId)
- for idx := 0; idx < len(cfgData.Buffs); idx++ {
- weight, buffId := Str2Res(cfgData.Buffs[idx])
- if buffId <= 0 {
- continue
- }
- bossBuffData.BuffList = append(bossBuffData.BuffList, &serverproto.KeyValueType{Key: buffId, Value: weight})
- }
- ConvertExpeditionDropBuffList[bossBuffData.Id] = bossBuffData
- }
- //检查boss数据是否存在
- for _, typeData := range ConvertExpeditionDataList {
- for _, levelData := range typeData.LevelInfo {
- for idx := 0; idx < len(levelData.BossList); idx++ {
- //对应level boss是否存在掉落buff数据
- tmpId := uint64(levelData.BossList[idx].BossId)*100000 + uint64(levelData.Id)
- if _, ok := ConvertExpeditionDropBuffList[tmpId]; !ok {
- //panic(errors.New("level boss not exist drop buff data:" + strconv.FormatUint(tmpId, 10)))
- }
- }
- }
- }
- }
- // /精彩活动
- type ConvertActivitiesData struct {
- Id int32
- ActivityType int32
- StartTimeStr string
- EndTimeStr string
- TerminalOpenTimeStr string
- OpenConditionList []*serverproto.KeyValueType
- BG string
- ServiceMark int32 //是否为合服活动
- TimeType int //1绝对时间 2相对开服时间 3相对角色创建时间
- StartTime time.Time
- EndTime time.Time
- StartDay int
- EndDay int
- CalStartTime time.Time
- CalEndTime time.Time
- CalEndTimeMs uint64
- HDItemList set.Interface
- //过期后的活动是否强制开启(之前没有开启过,只针对相对开服时间开启的活动类型)
- ExpiredActivities bool
- //活动开启最后截至时间(填写绝对时间)
- TerminalOpenTime time.Time
- TerminalOpenTimeMs uint64
- }
- type ConvertActivitiesTaskData struct {
- TaskId int32
- ConditionList map[int32][]int32
- RewardList map[int32]int32
- TaskScore int32
- }
- var ConvertActivitiesList = map[int32]*ConvertActivitiesData{}
- var ConvertActivitiesTaskList = map[int32]*ConvertActivitiesTaskData{}
- // 14日连续登录活动
- // key=ActivitiesId * 1000 + Day
- var ConvertActivitiesFOList = map[int32]map[int32]int32{}
- // 14日阶段目标
- type ConvertActivitiesFortnightDaysData struct {
- Days int32
- TaskList []uint32
- DailyTaskList []uint32
- }
- type ConvertActivitiesFortnightDaysScoreData struct {
- RewardIdx int32
- Score int32
- RewardList map[int32]int32
- }
- var ConvertActivitiesFortnightDaysList = map[int32]*ConvertActivitiesFortnightDaysData{}
- var ConvertActivitiesFortnightDaysScoreList = map[int32][]*ConvertActivitiesFortnightDaysScoreData{}
- // 首充/百元礼包
- type ConvertActFirstRechargeData struct {
- OpenConditionList []*serverproto.KeyValueType
- OpenConditionStrList []string
- RechargeAmount float32 //达到该金额解锁首充奖励获取
- Day1Reward []*serverproto.KeyValueType
- Day2Reward []*serverproto.KeyValueType
- Day3Reward []*serverproto.KeyValueType
- }
- var ConvertActFirstRecharge *ConvertActFirstRechargeData = nil
- var ConvertAct100Recharge *ConvertActFirstRechargeData = nil
- type StActTiredRecharge struct {
- Day int32
- Amount float32
- Rewards []*serverproto.KeyValueType
- }
- // 累计充值奖励
- var ConvertActTiredRecharge = map[int32]*StActTiredRecharge{}
- func GetActTiredRechargeDb(index, day int32) *StActTiredRecharge {
- dbDay := int32(0)
- for _, recharge := range ConvertActTiredRecharge {
- if day >= recharge.Day {
- if dbDay <= 0 || recharge.Day > dbDay {
- dbDay = recharge.Day
- }
- }
- }
- // 左16位 当天领奖档次, 右16位活动天数
- db := ConvertActTiredRecharge[index<<16|dbDay]
- return db
- }
- // [天数,[数据额列表]]
- var ConvertActTiredRechargeList = map[int32][]*StActTiredRecharge{}
- var ConvertActTiredRechargeByIdList = map[int32]*StActTiredRecharge{}
- // 超值礼包
- type ConvertActDiscountsRechargeData struct {
- Id int32
- ProductId int32
- Name string
- OpenCondition *serverproto.KeyValueTypeList
- Amount float32 //购买价格
- RewardList []*serverproto.KeyValueType
- DurationTime uint64 //持续时间
- UnlockCount int32 //触发次数
- Recharge int32 //历史累计充值档位
- }
- var ConvertActDiscountsRecharge = map[int32]*ConvertActDiscountsRechargeData{}
- // [type][id][data]
- var ConvertActDiscountsRechargeList = map[int32][]*ConvertActDiscountsRechargeData{}
- type ConvertActCollectionData struct {
- Id int32
- Name string
- Order int32
- ExchangeConditionList map[int32]int32
- ServerRewardNum int32 //全服奖励数量
- RewardNum int32 //兑换奖励次数上限
- RewardList []*serverproto.KeyValueType
- ActivitiesId int32
- }
- var ConvertActCollection = map[int32]*ConvertActCollectionData{}
- type ConvertActLikabilityItemData struct {
- ActivityId int32
- LikabilityItemId int32 //道具id
- LikabilityList []*serverproto.KeyValueTypeList
- }
- //var ConvertActLikabilityItem = map[int32]*ConvertActLikabilityItemData{}
- // [activityid][level][item...]
- var ConvertActLikabilityItemList = map[int32]map[int32]*ConvertActLikabilityItemData{}
- type ConvertActLikabilityData struct {
- ActivityId int32
- Level int32
- LikeValMax int32
- RewardList []*serverproto.KeyValueTypeList
- }
- // var ConvertActLikability = map[int32]*ConvertActLikabilityData{}
- var ConvertActLikabilityList = map[int32]map[int32]*ConvertActLikabilityData{}
- const (
- Exchange_Type_Special = 1
- Exchange_Type_Common = 2
- )
- const (
- Exchange_Activity_Type_Pet = 0
- Exchange_Activity_Type_Card = 1
- )
- type ExchangePetCondition struct {
- CondType int32
- ConditionId int32
- Id int32
- Level int32
- SkillLevel int32
- Count int32
- }
- type ExchangeCardCondition struct {
- CondType int32
- ConditionId int32
- ItemType int32
- ItemLevel int32
- ItemId int32
- ItemCount int32
- ItemQuality int32
- Scope map[int32]int32
- }
- type ConvertExchangeData struct {
- Id int32
- ActivitiesId int32
- ActivitiesType int32
- ConditionPet []*ExchangePetCondition
- ConditionCard []*ExchangeCardCondition
- Reward []*serverproto.KeyValueType
- RewardNum int32 //兑换次数
- ServerRewardNum int32
- BroadCast int32
- }
- var ConvertExchange = map[int32]*ConvertExchangeData{}
- type ResetIndexs struct {
- Id []int32
- }
- var ConvertExchangeReset = map[int32]*ResetIndexs{}
- const (
- ActivitiesTime_Type_None = 0 //永久活动时间
- ActivitiesTime_Type_Global = 1 //绝对时间
- ActivitiesTime_Type_Server = 2 //相对开服时间 //根据开服时间endday-startday(持续时间)
- ActivitiesTime_Type_Role = 3 //相对角色创建时间 //根据创建角色时间endday-startday + 1(持续时间)
- ActivitiesTime_Type_System = 4 //根据玩家开启系统决定活动开启时间
- )
- func convertActivitiesCfg() {
- //ActivitiesCfg
- for _, cfgData := range serverproto.ActivitiesCfgLoader {
- tmpData := &ConvertActivitiesData{
- Id: cfgData.Id,
- ActivityType: cfgData.Type,
- BG: cfgData.BG,
- HDItemList: set.New(set.NonThreadSafe),
- ServiceMark: cfgData.ServiceMark,
- }
- for idx := 0; idx < len(cfgData.OpenCondition); idx++ {
- key, val := Str2Res(cfgData.OpenCondition[idx])
- if key > 0 {
- tmpData.OpenConditionList = append(tmpData.OpenConditionList, &serverproto.KeyValueType{Key: key, Value: val})
- }
- }
- startDataList := strings.Split(cfgData.StartTime, ";")
- endDataList := strings.Split(cfgData.EndTime, ";")
- if len(startDataList) > 0 && len(endDataList) > 0 {
- tmpData.TimeType, _ = Str2Num(startDataList[0])
- switch tmpData.TimeType {
- case ActivitiesTime_Type_Global: //绝对时间
- loc := util.GetLoc()
- tmpData.StartTime, _ = time.ParseInLocation(util.DATE_FORMAT, startDataList[1], loc)
- tmpData.EndTime, _ = time.ParseInLocation(util.DATE_FORMAT, endDataList[1], loc)
- tmpData.StartTimeStr = startDataList[1]
- tmpData.EndTimeStr = endDataList[1]
- case ActivitiesTime_Type_Server: //相对开服时间
- fallthrough
- case ActivitiesTime_Type_Role: //相对创建角色时间
- tmpData.StartDay, _ = Str2Num(startDataList[1])
- tmpData.EndDay, _ = Str2Num(endDataList[1])
- tmpData.StartTimeStr = startDataList[2]
- tmpData.EndTimeStr = endDataList[2]
- if tmpData.EndDay < tmpData.StartDay {
- continue
- }
- loc := util.GetLoc()
- tmpData.StartTime, _ = time.ParseInLocation(util.DATE_FORMAT2, startDataList[2], loc)
- tmpData.EndTime, _ = time.ParseInLocation(util.DATE_FORMAT2, endDataList[2], loc)
- if len(startDataList) >= 4 {
- tmpData.TerminalOpenTimeStr = startDataList[3]
- tmpData.TerminalOpenTime = util.GetTimeByStr(tmpData.TerminalOpenTimeStr)
- tmpData.TerminalOpenTimeMs = uint64(tmpData.TerminalOpenTime.UnixNano() / 1e6)
- }
- case ActivitiesTime_Type_System: //根据玩家开启系统决定活动开启时间
- }
- } else {
- //永久活动时间
- tmpData.TimeType = 0
- }
- //过期后的活动是否强制开启(之前没有开启过,只针对相对开服时间开启的活动类型)
- if cfgData.ExpiredActivities > 0 && tmpData.TimeType == ActivitiesTime_Type_Server {
- tmpData.ExpiredActivities = true
- }
- //是否有活动道具
- for idx := 0; idx < len(cfgData.HdDrop); idx++ {
- hdItemId, _ := Str2Num(cfgData.HdDrop[idx])
- if hdItemId > 0 {
- tmpData.HDItemList.Add(int32(hdItemId))
- }
- }
- ConvertActivitiesList[tmpData.Id] = tmpData
- }
- //ActivityTaskCfg
- for _, cfgData := range serverproto.ActivitiesTaskCfgLoader {
- tmpData := &ConvertActivitiesTaskData{
- TaskId: cfgData.TaskId,
- TaskScore: cfgData.Integral,
- RewardList: map[int32]int32{},
- ConditionList: map[int32][]int32{},
- }
- for idx := 0; idx < len(cfgData.TaskCondition); idx++ {
- valueList := strings.Split(cfgData.TaskCondition[idx], ":")
- if len(valueList) >= 2 {
- taskType, _ := Str2Num(valueList[0])
- tmpData.ConditionList[int32(taskType)] = append(tmpData.ConditionList[int32(taskType)], int32(taskType))
- for i := 1; i < len(valueList); i++ {
- taskValue, _ := Str2Num(valueList[i])
- tmpData.ConditionList[int32(taskType)] = append(tmpData.ConditionList[int32(taskType)], int32(taskValue))
- }
- }
- }
- for idx := 0; idx < len(cfgData.Reward); idx++ {
- key, val := Str2Res(cfgData.Reward[idx])
- if key > 0 && val > 0 {
- tmpData.RewardList[key] += val
- }
- }
- ConvertActivitiesTaskList[tmpData.TaskId] = tmpData
- }
- //ActivitiesFortnightOnlineCfg
- for _, cfgData := range serverproto.ActivitiesFortnightOnlineCfgLoader {
- tempId := cfgData.ActivitiesId*1000 + cfgData.Day
- ConvertActivitiesFOList[tempId] = map[int32]int32{}
- for idx := 0; idx < len(cfgData.Rewards); idx++ {
- key, val := Str2Res(cfgData.Rewards[idx])
- if key > 0 && val > 0 {
- ConvertActivitiesFOList[tempId][key] += val
- }
- }
- }
- //ActivitiesFortnightDaysCfg
- duplicateSet := set.New(set.NonThreadSafe)
- for _, cfgData := range serverproto.ActivitiesFortnightDaysCfgLoader {
- tmpData := &ConvertActivitiesFortnightDaysData{
- Days: cfgData.Id,
- }
- for idx := 0; idx < len(cfgData.TaskIds); idx++ {
- taskId, _ := Str2Num(cfgData.TaskIds[idx])
- if duplicateSet.Has(taskId) {
- panic("task id repeated")
- }
- duplicateSet.Add(taskId)
- tmpData.TaskList = append(tmpData.TaskList, uint32(taskId))
- }
- for idx := 0; idx < len(cfgData.DailyTaskIds); idx++ {
- taskId, _ := Str2Num(cfgData.DailyTaskIds[idx])
- if duplicateSet.Has(taskId) {
- panic("task id repeated")
- }
- duplicateSet.Add(taskId)
- tmpData.DailyTaskList = append(tmpData.DailyTaskList, uint32(taskId))
- }
- ConvertActivitiesFortnightDaysList[tmpData.Days] = tmpData
- }
- //ActivitiesRewardCfg
- //task score reward
- for _, cfgData := range serverproto.ActivitiesRewardCfgLoader {
- scoreData := &ConvertActivitiesFortnightDaysScoreData{
- RewardIdx: cfgData.Id,
- Score: cfgData.Integral,
- RewardList: map[int32]int32{},
- }
- for idx := 0; idx < len(cfgData.Rewards); idx++ {
- key, val := Str2Res(cfgData.Rewards[idx])
- if key > 0 && val > 0 {
- scoreData.RewardList[key] += val
- }
- }
- //Type 1第一周 2第二周
- ConvertActivitiesFortnightDaysScoreList[cfgData.Type] = append(ConvertActivitiesFortnightDaysScoreList[cfgData.Type], scoreData)
- }
- //ActiviesFirstChargeCfg
- for _, cfgData := range serverproto.ActivitiesFirstChargeCfgLoader {
- tmpData := &ConvertActFirstRechargeData{
- RechargeAmount: float32(cfgData.RechargeAmount),
- }
- tmpData.OpenConditionStrList = cfgData.OpenCondition
- for idx := 0; idx < len(cfgData.OpenCondition); idx++ {
- k, v := Str2Res(cfgData.OpenCondition[idx])
- if k > 0 && v > 0 {
- tmpData.OpenConditionList = append(tmpData.OpenConditionList, &serverproto.KeyValueType{Key: k, Value: v})
- }
- }
- for idx := 0; idx < len(cfgData.Reward1); idx++ {
- k, v := Str2Res(cfgData.Reward1[idx])
- if k > 0 && v > 0 {
- tmpData.Day1Reward = append(tmpData.Day1Reward, &serverproto.KeyValueType{Key: k, Value: v})
- }
- }
- for idx := 0; idx < len(cfgData.Reward2); idx++ {
- k, v := Str2Res(cfgData.Reward2[idx])
- if k > 0 && v > 0 {
- tmpData.Day2Reward = append(tmpData.Day2Reward, &serverproto.KeyValueType{Key: k, Value: v})
- }
- }
- for idx := 0; idx < len(cfgData.Reward3); idx++ {
- k, v := Str2Res(cfgData.Reward3[idx])
- if k > 0 && v > 0 {
- tmpData.Day3Reward = append(tmpData.Day3Reward, &serverproto.KeyValueType{Key: k, Value: v})
- }
- }
- //first recharge
- if cfgData.Id == 1 {
- ConvertActFirstRecharge = tmpData
- } else if cfgData.Id == 2 {
- //百元大礼包
- ConvertAct100Recharge = tmpData
- }
- }
- //ActiviesTiredChargeCfg 累计充值奖励
- for _, cfgData := range serverproto.ActivitiesTiredChargeCfgLoader {
- dbData := &StActTiredRecharge{Amount: cfgData.RechargeAmount, Day: cfgData.Day}
- for idx := 0; idx < len(cfgData.Reward); idx++ {
- k, v := Str2Res(cfgData.Reward[idx])
- if k <= 0 || v <= 0 {
- continue
- }
- dbData.Rewards = append(dbData.Rewards, &serverproto.KeyValueType{Key: k, Value: v})
- }
- // 左16位 当天领奖档次, 右16位活动天数
- ConvertActTiredRecharge[cfgData.Index<<16|cfgData.Day] = dbData
- }
- //ActiviesDiscountsCfg //超值礼包
- for _, cfgData := range serverproto.ActivitiesDiscountsCfgLoader {
- tmpData := &ConvertActDiscountsRechargeData{
- Id: cfgData.Id,
- Amount: float32(cfgData.Money),
- DurationTime: uint64(cfgData.Time) * 1000,
- Name: cfgData.Name,
- UnlockCount: cfgData.Popup,
- Recharge: cfgData.Recharge,
- ProductId: cfgData.ProductID,
- }
- for idx := 0; idx < len(cfgData.Reward); idx++ {
- k, v := Str2Res(cfgData.Reward[idx])
- if k <= 0 || v <= 0 {
- continue
- }
- tmpData.RewardList = append(tmpData.RewardList, &serverproto.KeyValueType{Key: k, Value: v})
- }
- for idx := 0; idx < len(cfgData.TriggeringCondition); idx++ {
- valList := strings.Split(cfgData.TriggeringCondition[idx], ":")
- key, _ := Str2Num(valList[0])
- tmpData.OpenCondition = &serverproto.KeyValueTypeList{Key: int32(key)}
- for k := 1; k < len(valList); k++ {
- val, _ := Str2Num(valList[k])
- tmpData.OpenCondition.ValueList = append(tmpData.OpenCondition.ValueList, int32(val))
- }
- break
- }
- ConvertActDiscountsRecharge[cfgData.Id] = tmpData
- //分类优化性能
- ConvertActDiscountsRechargeList[tmpData.OpenCondition.Key] = append(
- ConvertActDiscountsRechargeList[tmpData.OpenCondition.Key], tmpData)
- }
- for key, _ := range ConvertActDiscountsRechargeList {
- sort.Slice(ConvertActDiscountsRechargeList[key], func(i, j int) bool {
- return ConvertActDiscountsRechargeList[key][i].OpenCondition.ValueList[0] < ConvertActDiscountsRechargeList[key][j].OpenCondition.ValueList[0]
- })
- }
- //ActivitiesCollectionCfg 集字活动
- //var ConvertActCollection = map[int32]*ConvertActCollectionData{}
- for _, cfgData := range serverproto.ActivitiesCollectionCfgLoader {
- tmpData := &ConvertActCollectionData{
- Id: cfgData.Id,
- ExchangeConditionList: map[int32]int32{},
- ServerRewardNum: cfgData.ServersReward,
- RewardNum: cfgData.Number,
- ActivitiesId: cfgData.ActivitiesId,
- }
- for idx := 0; idx < len(cfgData.ExchangeCondition); idx++ {
- k, v := Str2Res(cfgData.ExchangeCondition[idx])
- if k <= 0 || v <= 0 {
- continue
- }
- tmpData.ExchangeConditionList[k] += v
- }
- for idx := 0; idx < len(cfgData.Reward); idx++ {
- k, v := Str2Res(cfgData.Reward[idx])
- if k <= 0 || v <= 0 {
- continue
- }
- tmpData.RewardList = append(tmpData.RewardList,
- &serverproto.KeyValueType{Key: k, Value: v})
- }
- ConvertActCollection[tmpData.Id] = tmpData
- }
- //ActivitieslikabilityCfg ActivitiesGiftCfg 好感度活动
- for _, cfgData := range serverproto.ActivitiesGiftCfgLoader {
- tmpData := &ConvertActLikabilityItemData{
- ActivityId: cfgData.Activityid,
- LikabilityItemId: cfgData.Classitemid,
- }
- for idx := 0; idx < len(cfgData.Classcostaddlike); idx++ {
- v1, v2, v3 := Str2Res_3(cfgData.Classcostaddlike[idx])
- if v1 <= 0 {
- continue
- }
- tmpData.LikabilityList = append(tmpData.LikabilityList,
- &serverproto.KeyValueTypeList{Key: cfgData.Classitemid, ValueList: []int32{v1, v2, v3}})
- }
- if _, ok := ConvertActLikabilityItemList[cfgData.Activityid]; !ok {
- ConvertActLikabilityItemList[cfgData.Activityid] = map[int32]*ConvertActLikabilityItemData{}
- }
- ConvertActLikabilityItemList[cfgData.Activityid][cfgData.Classitemid] = tmpData
- //ConvertActLikabilityItem[cfgData.Classitemid] = tmpData
- }
- for _, cfgData := range serverproto.ActivitieslikabilityCfgLoader {
- tmpData := &ConvertActLikabilityData{
- ActivityId: cfgData.Activityid,
- Level: cfgData.Likelevel,
- LikeValMax: cfgData.LikeMax,
- }
- for idx := 0; idx < len(cfgData.Conditionrewards); idx++ {
- k, v1, v2 := Str2Res_3(cfgData.Conditionrewards[idx])
- if k <= 0 {
- continue
- }
- tmpData.RewardList = append(tmpData.RewardList, &serverproto.KeyValueTypeList{
- Key: k,
- ValueList: []int32{v1, v2},
- })
- }
- if _, ok := ConvertActLikabilityList[cfgData.Activityid]; !ok {
- ConvertActLikabilityList[cfgData.Activityid] = map[int32]*ConvertActLikabilityData{}
- }
- ConvertActLikabilityList[cfgData.Activityid][cfgData.Likelevel] = tmpData
- }
- for _, cfgData := range serverproto.ActivitiesPetExchangeCfgLoader {
- tmpData := &ConvertExchangeData{
- Id: cfgData.Id,
- ActivitiesId: cfgData.ActivitiesId,
- RewardNum: cfgData.Number,
- ServerRewardNum: cfgData.ServersReward,
- ActivitiesType: cfgData.Type,
- BroadCast: cfgData.Broadcast,
- }
- if cfgData.ResetDay != 0 {
- ResetData, resetOk := ConvertExchangeReset[cfgData.ActivitiesId]
- if resetOk {
- ResetData.Id = append(ResetData.Id, cfgData.Id)
- } else {
- convertResetData := &ResetIndexs{}
- convertResetData.Id = append(convertResetData.Id, cfgData.Id)
- ConvertExchangeReset[cfgData.ActivitiesId] = convertResetData
- }
- }
- if cfgData.Type == int32(Exchange_Activity_Type_Pet) {
- for _, condition := range cfgData.ExchangeCondition1 {
- strList := strings.Split(condition, ":")
- if len(strList) >= 5 {
- condId, _ := Str2Num(strList[0])
- id, _ := Str2Num(strList[1])
- level, _ := Str2Num(strList[2])
- skillLevel, _ := Str2Num(strList[3])
- count, _ := Str2Num(strList[4])
- cond := &ExchangePetCondition{
- CondType: Exchange_Type_Special,
- ConditionId: int32(condId),
- Id: int32(id),
- Level: int32(level),
- SkillLevel: int32(skillLevel),
- Count: int32(count),
- }
- tmpData.ConditionPet = append(tmpData.ConditionPet, cond)
- }
- }
- for _, condition := range cfgData.ExchangeCondition2 {
- strList := strings.Split(condition, ":")
- if len(strList) >= 5 {
- condId, _ := Str2Num(strList[0])
- id, _ := Str2Num(strList[1])
- level, _ := Str2Num(strList[2])
- skillLevel, _ := Str2Num(strList[3])
- count, _ := Str2Num(strList[4])
- cond := &ExchangePetCondition{
- CondType: Exchange_Type_Common,
- ConditionId: int32(condId),
- Id: int32(id),
- Level: int32(level),
- SkillLevel: int32(skillLevel),
- Count: int32(count),
- }
- tmpData.ConditionPet = append(tmpData.ConditionPet, cond)
- }
- }
- } else if cfgData.Type == int32(Exchange_Activity_Type_Card) {
- for _, condition := range cfgData.ExchangeCondition1 {
- strList := strings.Split(condition, ":")
- if len(strList) >= 4 {
- condId, _ := Str2Num(strList[0])
- itemType, _ := Str2Num(strList[1])
- itemId, _ := Str2Num(strList[2])
- itemNum, _ := Str2Num(strList[3])
- cond := &ExchangeCardCondition{
- CondType: Exchange_Type_Special,
- ConditionId: int32(condId),
- ItemType: int32(itemType),
- ItemId: int32(itemId),
- ItemCount: int32(itemNum),
- }
- tmpData.ConditionCard = append(tmpData.ConditionCard, cond)
- }
- }
- if len(cfgData.Scope) == len(cfgData.ExchangeCondition2) {
- for i := 0; i < len(cfgData.ExchangeCondition2); i++ {
- strList := strings.Split(cfgData.ExchangeCondition2[i], ":")
- if len(strList) >= 4 {
- condId, _ := Str2Num(strList[0])
- itemType, _ := Str2Num(strList[1])
- itemLevel, _ := Str2Num(strList[2])
- itemCount, _ := Str2Num(strList[3])
- itemQuality, _ := Str2Num(strList[4])
- cond := &ExchangeCardCondition{
- CondType: Exchange_Type_Common,
- ConditionId: int32(condId),
- ItemType: int32(itemType),
- ItemLevel: int32(itemLevel),
- ItemCount: int32(itemCount),
- ItemQuality: int32(itemQuality),
- }
- cond.Scope = map[int32]int32{}
- scopeList := strings.Split(cfgData.Scope[i], ":")
- for _, data := range scopeList {
- cardCfgId, _ := Str2Num(data)
- cond.Scope[int32(cardCfgId)] = 1
- }
- tmpData.ConditionCard = append(tmpData.ConditionCard, cond)
- }
- }
- } else {
- }
- }
- for _, reward := range cfgData.Reward {
- strList := strings.Split(reward, ":")
- if len(strList) >= 2 {
- petCfgId, _ := Str2Num(strList[0])
- petCount, _ := Str2Num(strList[1])
- tmpData.Reward = append(tmpData.Reward, &serverproto.KeyValueType{
- Key: int32(petCfgId),
- Value: int32(petCount),
- })
- }
- }
- ConvertExchange[cfgData.Id] = tmpData
- }
- }
- type HeadFrameAttr struct {
- AttrList map[int32]int32
- }
- var ConvertHeadFrameAttr = map[int32]*HeadFrameAttr{}
- func convertHeadFrameCfg() {
- for _, data := range serverproto.HeadFrameCfgLoader {
- convert := &HeadFrameAttr{
- AttrList: make(map[int32]int32),
- }
- for _, attr := range data.HeadFrameQuality {
- strList := strings.Split(attr, ":")
- if len(strList) >= 2 {
- attrId, _ := Str2Num(strList[0])
- attrValue, _ := Str2Num(strList[1])
- convert.AttrList[int32(attrId)] += int32(attrValue)
- }
- }
- ConvertHeadFrameAttr[data.HeadFrameId] = convert
- }
- }
- // invitation
- type ConvertInvitationTask struct {
- TaskId uint32
- RewardList map[int32]int32
- ConditionList map[int32][]int32
- CompleteNum int32
- }
- var ConvertInvitationTaskList = map[uint32]*ConvertInvitationTask{}
- var ConvertInvitationTaskTypeList = map[int32][]*ConvertInvitationTask{}
- func convertInvitationCfg() {
- for _, cfgData := range serverproto.InvitationTaskCfgLoader {
- tmpData := &ConvertInvitationTask{
- TaskId: uint32(cfgData.TaskId),
- CompleteNum: cfgData.CompleteNum,
- RewardList: map[int32]int32{},
- ConditionList: map[int32][]int32{},
- }
- for idx := 0; idx < len(cfgData.TaskCondition); idx++ {
- valueList := strings.Split(cfgData.TaskCondition[idx], ":")
- if len(valueList) >= 2 {
- taskType, _ := Str2Num(valueList[0])
- tmpData.ConditionList[int32(taskType)] = append(tmpData.ConditionList[int32(taskType)], int32(taskType))
- for i := 1; i < len(valueList); i++ {
- taskValue, _ := Str2Num(valueList[i])
- tmpData.ConditionList[int32(taskType)] = append(tmpData.ConditionList[int32(taskType)], int32(taskValue))
- }
- }
- }
- for idx := 0; idx < len(cfgData.Reward); idx++ {
- key, val := Str2Res(cfgData.Reward[idx])
- if key > 0 && val > 0 {
- tmpData.RewardList[key] += val
- }
- }
- for key := range tmpData.ConditionList {
- ConvertInvitationTaskTypeList[key] = append(ConvertInvitationTaskTypeList[key], tmpData)
- }
- ConvertInvitationTaskList[tmpData.TaskId] = tmpData
- }
- }
- type VipData struct {
- VipRight map[int32]int32
- VipReward map[int32]int32
- VipLevel int32
- }
- var ConvertVipRight = map[int32]*VipData{}
- // 特权卡商店
- type PrivilegeData struct {
- Id int32
- Price float32
- GoodsName string
- VipRight map[int32]int32
- VipReward map[int32]int32
- ConditionList []*serverproto.KeyValueType //到达对应地图条件
- AttrList map[int32]int32 //增加的属性
- }
- var ConvertSpecialPrivilegeRight []*PrivilegeData
- const (
- Vip_System_Levelup = 1 //vip升级需要经验
- Vip_System_Evil = 2 //vip恶魔协会免费刷新次数(0开始恶魔协会刷新金色条目)
- Vip_System_Online = 3 //vip上线提示
- Vip_System_PetAdvance = 4 //宠物进阶消耗
- Vip_System_CardReset = 5 //卡片重置
- Vip_System_PetDesolve = 6 //宠物分解
- Vip_System_SkillReset = 7 //技能重置
- Vip_System_GuildHunt = 8 //公会狩猎次数
- Vip_System_CardInsert = 9 //一键插卡
- Vip_System_ShopWeight = 10 //商店权重
- Vip_System_WorldBoss = 11 //世界boss
- Vip_System_Arena = 12 //英灵殿
- Vip_System_QuickBattle = 13 //快速战斗次数
- Vip_System_HungSilver = 14 //挂机银币
- Vip_System_HungExp = 15 //挂机经验
- Vip_System_HungPartnerExp = 16 //挂机伙伴经验
- Vip_System_HungSkillExp = 17 //技能经验
- Vip_System_HungExtraTime = 18 //挂机额外时长
- Vip_System_SignReward = 19 //签到翻倍
- Vip_System_WorldBoss_Count = 20 //世界boss次数
- Vip_System_FastBattleTime = 21 // 解锁战斗加速功能
- Vip_System_CreditRecharge = 22 // 充值钱包额度(添加的数值)
- Vip_System_QuickBattleBaseExp = 23 // 时光助力主角经验提升万分比 AddLeadExp
- Vip_System_DevilsUp = 24 // 挂机魔魂值加成
- Vip_System_TransportRobbery = 25 // 飞艇被抢劫掉落减少至
- Vip_System_LuxuryPrizeWheelTimes = 26 // 豪华转盘可使用次数
- )
- func convertVipCfg() {
- for _, data := range serverproto.VipCfgLoader {
- convertVip := &VipData{
- VipRight: make(map[int32]int32),
- VipReward: make(map[int32]int32),
- }
- convertVip.VipRight[Vip_System_Levelup] = data.VipExp
- convertVip.VipRight[Vip_System_Evil] = data.EvilFreeTimes
- convertVip.VipRight[Vip_System_Online] = data.VipLogin
- convertVip.VipRight[Vip_System_PetAdvance] = data.PetAdvance
- convertVip.VipRight[Vip_System_CardReset] = data.CardReset
- convertVip.VipRight[Vip_System_PetDesolve] = data.PetBreak
- convertVip.VipRight[Vip_System_SkillReset] = data.SkillReset
- convertVip.VipRight[Vip_System_GuildHunt] = data.GuildBossChallenge
- convertVip.VipRight[Vip_System_CardInsert] = data.CardInsertion
- convertVip.VipRight[Vip_System_ShopWeight] = data.ShopWeight
- convertVip.VipRight[Vip_System_WorldBoss] = data.WorldBoss
- convertVip.VipRight[Vip_System_Arena] = data.PvpReward
- convertVip.VipRight[Vip_System_QuickBattle] = data.HangupTimes
- convertVip.VipRight[Vip_System_HungSilver] = data.SilverUp
- convertVip.VipRight[Vip_System_HungExp] = data.BaseExpUp
- convertVip.VipRight[Vip_System_HungPartnerExp] = data.PartnerExpUp
- convertVip.VipRight[Vip_System_HungSkillExp] = data.SkillExpUp
- convertVip.VipRight[Vip_System_HungExtraTime] = data.HangupDuration
- convertVip.VipRight[Vip_System_SignReward] = data.SignInRewardUp
- convertVip.VipRight[Vip_System_WorldBoss_Count] = data.WorldBossCount
- for _, data := range data.Reward {
- strList := strings.Split(data, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- convertVip.VipReward[int32(key)] += int32(value)
- }
- }
- ConvertVipRight[data.Lv] = convertVip
- }
- // bt服务器版本配置文件
- convertSpecialPrivilegeCfg()
- convertPassCheckCfg()
- convertBtBoliCfg() // 波利商城
- convertBTRoCoinRechargeCfg() // RO币累计活动
- convertBTFirstAnd100RechargeCfg() // 超值首充 & 百元大礼包
- }
- // 特权卡
- func convertSpecialPrivilegeCfg() {
- for _, data := range serverproto.PrivilegeCardCfgLoader {
- tmpData := &PrivilegeData{
- Id: data.Lv,
- Price: data.RMB,
- VipReward: map[int32]int32{},
- VipRight: map[int32]int32{},
- }
- tmpData.VipRight[Vip_System_FastBattleTime] = data.QuickBattle
- tmpData.VipRight[Vip_System_CreditRecharge] = data.PurseQuota
- //可购买的解锁条件
- for idx := range data.UnlockCond {
- valueList := strings.Split(data.UnlockCond[idx], ":")
- if len(valueList) >= 2 {
- taskType, _ := Str2Num(valueList[0])
- taskValue, _ := Str2Num(valueList[1])
- tmpData.ConditionList = append(tmpData.ConditionList, &serverproto.KeyValueType{
- Key: int32(taskType),
- Value: int32(taskValue),
- })
- }
- }
- Str2ResMapList(data.Reward, tmpData.VipReward)
- ConvertSpecialPrivilegeRight = append(ConvertSpecialPrivilegeRight, tmpData)
- }
- sort.Slice(ConvertSpecialPrivilegeRight, func(i, j int) bool {
- return ConvertSpecialPrivilegeRight[i].Id < ConvertSpecialPrivilegeRight[j].Id
- })
- }
- // RO通行证
- var ConvertPassCheckData *PrivilegeData
- func convertPassCheckCfg() {
- ConvertPassCheckData = &PrivilegeData{
- VipRight: make(map[int32]int32),
- AttrList: make(map[int32]int32),
- }
- for _, cfgData := range serverproto.PassCheckCfgLoader {
- ConvertPassCheckData.Id = cfgData.Lv
- ConvertPassCheckData.Price = cfgData.RMB
- ConvertPassCheckData.VipRight[Vip_System_QuickBattleBaseExp] = cfgData.AddLeadExp
- //添加的属性
- Str2ResMapList(cfgData.AddAttrLevel, ConvertPassCheckData.AttrList)
- //目前只配置了一行数据
- break
- }
- }
- type SummonCost struct {
- ItemId int32
- ItemNum int32
- SourceId int32
- SourceNum int32
- DrawCount map[int32]int32
- ActivitiesId int32 //是否属于活动召唤数据
- SummonType int32 //召唤类型 1卡片 2宠物 3神器
- Total int32
- //根据开服时间获取不同掉落配置
- ServerDataList []*SummonCostByServerTime
- BigRewardShowList []int32 //大奖预览字段
- }
- // 相对开服时间天数
- func (this *SummonCost) GetDataByDiffDay(diffDay int32) *SummonCostByServerTime {
- for idx := 0; idx < len(this.ServerDataList); idx++ {
- if diffDay <= this.ServerDataList[idx].ServerTime {
- return this.ServerDataList[idx]
- }
- }
- if len(this.ServerDataList) > 0 {
- return this.ServerDataList[len(this.ServerDataList)-1]
- }
- return nil
- }
- type SummonCostByServerTime struct {
- Id int32
- ServerTime int32 //相对开服时间天数
- SummonType int32 //召唤类型
- SummonGroup int32 //召唤组
- DropId int32
- DropId2 int32
- ExtDropId int32
- }
- type DrawTemplate struct {
- ConfigId int32
- WeightItem int32
- WeightGold int32
- ExtraPoint int32
- DrawItem []*serverproto.KeyValueType
- }
- type DrawPool struct {
- TotalWeightItem int32
- TotalWeightGold int32
- DrawTemplate []*DrawTemplate
- }
- var ConvertSummonList = map[int32]*SummonCost{}
- var ConvertDrawTemplate = map[int32]*DrawPool{}
- const (
- Draw_ResType_Item = 1
- Draw_ResType_Gold = 2
- )
- func convertSummonCfg() {
- for _, data := range serverproto.SummonServerCfgLoader {
- convertData := &SummonCost{
- DrawCount: make(map[int32]int32),
- ActivitiesId: data.ActivitiesId,
- SummonType: data.Type,
- Total: data.Total,
- }
- if len(data.Cost) >= 1 {
- itemId, itemCount := Str2Res(data.Cost[0])
- convertData.ItemId = itemId
- convertData.ItemNum = itemCount
- }
- if len(data.Cost) >= 2 {
- sourceId, sourceCount := Str2Res(data.Cost[1])
- convertData.SourceId = sourceId
- convertData.SourceNum = sourceCount
- }
- for _, count := range data.Method {
- drawCount, _ := Str2Num(count)
- convertData.DrawCount[int32(drawCount)] = 1
- }
- serverData := &SummonCostByServerTime{
- Id: data.Id,
- ServerTime: data.StartDay,
- SummonType: data.Type,
- SummonGroup: data.SummoType,
- DropId: data.DropId,
- DropId2: data.DropId2,
- ExtDropId: data.ExtDropId,
- }
- //召唤组 只针对系统召唤(不包括活动)
- if data.SummoType > 0 {
- if summonData, ok := ConvertSummonList[data.SummoType]; ok {
- summonData.ServerDataList = append(summonData.ServerDataList, serverData)
- } else {
- convertData.ServerDataList = append(convertData.ServerDataList, serverData)
- ConvertSummonList[data.SummoType] = convertData
- }
- //无须读取导致之前没有赋值
- if data.Total > 0 && len(data.Cost) > 0 {
- ConvertSummonList[data.SummoType].Total = convertData.Total
- ConvertSummonList[data.SummoType].SummonType = convertData.SummonType
- ConvertSummonList[data.SummoType].ActivitiesId = convertData.ActivitiesId
- ConvertSummonList[data.SummoType].DrawCount = convertData.DrawCount
- ConvertSummonList[data.SummoType].ItemId = convertData.ItemId
- ConvertSummonList[data.SummoType].ItemNum = convertData.ItemNum
- ConvertSummonList[data.SummoType].SourceId = convertData.SourceId
- ConvertSummonList[data.SummoType].SourceNum = convertData.SourceNum
- }
- } else {
- convertData.ServerDataList = append(convertData.ServerDataList, serverData)
- ConvertSummonList[data.Id] = convertData
- }
- }
- // bt 砸蛋活动
- convertSummonForBTCfg()
- for _, v := range ConvertSummonList {
- sort.Slice(v.ServerDataList, func(i, j int) bool {
- return v.ServerDataList[i].ServerTime < v.ServerDataList[j].ServerTime
- })
- }
- for _, data := range serverproto.SummonTemplateCfgLoader {
- drawPool, ok := ConvertDrawTemplate[data.CardType]
- if !ok {
- drawPool = &DrawPool{
- TotalWeightItem: 0,
- TotalWeightGold: 0,
- }
- ConvertDrawTemplate[data.CardType] = drawPool
- }
- if drawPool == nil {
- // panic()
- return
- }
- drawPool.TotalWeightItem = drawPool.TotalWeightItem + data.Probability1
- drawPool.TotalWeightGold = drawPool.TotalWeightGold + data.Probability2
- //
- drawTemplate := &DrawTemplate{
- ConfigId: data.Id,
- WeightItem: drawPool.TotalWeightItem,
- WeightGold: drawPool.TotalWeightGold,
- ExtraPoint: data.SecurityNum,
- }
- if len(data.BlueNum) >= 1 {
- strList := strings.Split(data.BlueNum[0], ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- drawTemplate.DrawItem = append(drawTemplate.DrawItem, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- if len(data.PurpleNum) >= 1 {
- strList := strings.Split(data.PurpleNum[0], ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- drawTemplate.DrawItem = append(drawTemplate.DrawItem, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- if len(data.GoldNum) >= 1 {
- strList := strings.Split(data.GoldNum[0], ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- drawTemplate.DrawItem = append(drawTemplate.DrawItem, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- drawPool.DrawTemplate = append(drawPool.DrawTemplate, drawTemplate)
- }
- }
- func convertSummonForBTCfg() {
- for _, data := range serverproto.BTSmashEggsCfgLoader {
- convertData := &SummonCost{
- DrawCount: make(map[int32]int32),
- ActivitiesId: data.ActivitiesId,
- SummonType: data.Type,
- Total: data.Total,
- }
- if len(data.Cost) >= 1 {
- itemId, itemCount := Str2Res(data.Cost[0])
- convertData.ItemId = itemId
- convertData.ItemNum = itemCount
- }
- if len(data.Cost) >= 2 {
- sourceId, sourceCount := Str2Res(data.Cost[1])
- convertData.SourceId = sourceId
- convertData.SourceNum = sourceCount
- }
- for _, count := range data.Method {
- drawCount, _ := Str2Num(count)
- convertData.DrawCount[int32(drawCount)] = 1
- }
- //大奖预览字段
- for idx := 0; idx < len(data.Show); idx++ {
- showItemId, _ := Str2Num(data.Show[idx])
- if showItemId > 0 {
- convertData.BigRewardShowList = append(convertData.BigRewardShowList, int32(showItemId))
- }
- }
- serverData := &SummonCostByServerTime{
- Id: data.Id,
- ServerTime: data.StartDay,
- SummonType: data.Type,
- SummonGroup: data.SummoType,
- DropId: data.DropId,
- DropId2: data.DropId2,
- ExtDropId: data.ExtDropId,
- }
- convertData.ServerDataList = append(convertData.ServerDataList, serverData)
- ConvertSummonList[data.Id] = convertData
- }
- }
- func GetDrawProbItem(drawType int32, resType int32) *DrawTemplate {
- drawPool, ok := ConvertDrawTemplate[drawType]
- if !ok {
- return nil
- }
- var totalWeight int32 = 0
- if resType == Draw_ResType_Item {
- totalWeight = drawPool.TotalWeightItem
- } else if resType == Draw_ResType_Gold {
- totalWeight = drawPool.TotalWeightGold
- }
- randWeight := rand.Int31n(totalWeight)
- for _, data := range drawPool.DrawTemplate {
- target := data.WeightItem
- if resType == Draw_ResType_Gold {
- target = data.WeightGold
- }
- if target >= randWeight {
- return data
- }
- }
- return nil
- }
- type GiftBag struct {
- GoodsId int32
- BagType int32
- Price float32
- Name string
- BuyReward []*serverproto.KeyValueType
- FirstReward []*serverproto.KeyValueType
- ExtraReward []*serverproto.KeyValueType
- LimitCount int32
- RmbTotalPay int32
- }
- type LimitBag struct {
- GoodsId int32
- Price float32
- BeginTime int64
- EndTime int64
- LimitCount int32
- Name string
- StartDay int32
- EndDay int32
- LimitType int32
- SeasonId int32
- BuyReward []*serverproto.KeyValueType
- ActivityId int32
- }
- type MonthCard struct {
- GoodsId int32
- Price float32
- Duration int32
- Name string
- MailCfgId int32
- BuyReward []*serverproto.KeyValueType
- MailReward []*serverproto.KeyValueType
- }
- // 冲榜商店
- type RushShop struct {
- GoodsId int32
- Activity int32
- Price float32
- Name string
- LimitCount int32
- WorthRate int32
- BuyReward []*serverproto.KeyValueType
- Score int32
- Ticket int32
- }
- var ConvertFreeBag = map[int32]*GiftBag{}
- var ConvertGiftBag = map[int32]*GiftBag{}
- var ConvertLimitGag = map[int32]*LimitBag{}
- var ConvertMonthCard = map[int32]*MonthCard{}
- var ConvertGuildBattle = map[int32]*RushShop{}
- // 卢恩冲榜商店
- var ConvertTowerShop = map[int32]*RushShop{}
- var ConvertArenaShop = map[int32]*RushShop{}
- var ConvertMapShop = map[int32]*RushShop{}
- var ConvertPetShop = map[int32]*RushShop{}
- var ConvertSkillShop = map[int32]*RushShop{}
- var ConvertIdolShop = map[int32]*RushShop{}
- // 充值钱包商店
- var ConvertPurseShop = map[int32]*GiftBag{}
- func ConvertOldRedisRuneCfg() {
- convertRuneCfg()
- }
- func convertRuneCfg() {
- for _, data := range serverproto.RuneShopGiftsCfgLoader {
- convertGift := &GiftBag{
- GoodsId: data.Id,
- BagType: data.Type,
- Price: data.RMB,
- Name: data.Name,
- LimitCount: data.RestrictedType,
- RmbTotalPay: data.RmbTotalPay,
- }
- for _, reward := range data.Reward {
- strList := strings.Split(reward, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- convertGift.BuyReward = append(convertGift.BuyReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- for _, first := range data.FirstBuyReward {
- strList := strings.Split(first, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- convertGift.FirstReward = append(convertGift.FirstReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- for _, extra := range data.ExtraBuyReward {
- strList := strings.Split(extra, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- convertGift.ExtraReward = append(convertGift.ExtraReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- ConvertGiftBag[data.Id] = convertGift
- if data.RMB == 0 {
- ConvertFreeBag[data.Id] = convertGift
- }
- }
- for _, data := range serverproto.RuneShopLimitCfgLoader {
- convertLimitBag := &LimitBag{
- GoodsId: data.Id,
- Price: data.RMB,
- Name: data.Name,
- StartDay: data.SellingBegin,
- EndDay: data.SellingDuration,
- LimitCount: data.RestrictedType,
- LimitType: data.SellingType,
- SeasonId: data.SeasonId,
- ActivityId: data.ActiveId,
- }
- for _, extra := range data.BuyReward {
- strList := strings.Split(extra, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- convertLimitBag.BuyReward = append(convertLimitBag.BuyReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- loc := util.GetLoc()
- if data.BeginTime != "" {
- sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.BeginTime, loc)
- if err1 != nil {
- util.PanicF("convertRune startTime err:%v", err1)
- }
- convertLimitBag.BeginTime = int64(sTime.Unix() * 1000)
- }
- if data.EndTime != "" {
- cTime, err2 := time.ParseInLocation(util.DATE_FORMAT, data.EndTime, loc)
- if err2 != nil {
- util.PanicF("convertRune endTime err:%v", err2)
- }
- convertLimitBag.EndTime = int64(cTime.Unix() * 1000)
- }
- ConvertLimitGag[data.Id] = convertLimitBag
- }
- for _, data := range serverproto.RuneShopMonthCardCfgLoader {
- monthCard := &MonthCard{
- GoodsId: data.Id,
- Name: data.Name,
- Duration: data.AddTime,
- Price: data.RMB,
- MailCfgId: data.RewardMail,
- }
- for _, buyReward := range data.BuyRewardServer {
- strList := strings.Split(buyReward, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- monthCard.BuyReward = append(monthCard.BuyReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- for _, dayReward := range data.DayReward {
- strList := strings.Split(dayReward, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- monthCard.MailReward = append(monthCard.MailReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- ConvertMonthCard[data.Id] = monthCard
- }
- for _, data := range serverproto.RuneShopRankTowerCfgLoader {
- towerShop := &RushShop{
- GoodsId: data.Id,
- Name: data.Name,
- Price: data.RMB,
- Activity: data.RankId,
- LimitCount: data.RestrictedType,
- }
- for _, items := range data.Reward {
- strList := strings.Split(items, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- towerShop.BuyReward = append(towerShop.BuyReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- ConvertTowerShop[data.Id] = towerShop
- }
- for _, data := range serverproto.RuneShopRankArenaCfgLoader {
- arenaShop := &RushShop{
- GoodsId: data.Id,
- Name: data.Name,
- Price: data.RMB,
- Activity: data.RankId,
- LimitCount: data.RestrictedType,
- }
- for _, items := range data.Reward {
- strList := strings.Split(items, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- arenaShop.BuyReward = append(arenaShop.BuyReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- ConvertArenaShop[data.Id] = arenaShop
- }
- for _, data := range serverproto.RuneShopRankMapCfgLoader {
- mapShop := &RushShop{
- GoodsId: data.Id,
- Name: data.Name,
- Price: data.RMB,
- Activity: data.RankId,
- LimitCount: data.RestrictedType,
- Score: data.RewardScore,
- }
- for _, items := range data.SeverReward {
- strList := strings.Split(items, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- mapShop.BuyReward = append(mapShop.BuyReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- ConvertMapShop[data.Id] = mapShop
- }
- //公会战商店
- for _, data := range serverproto.RuneShopGuildBattleCfgLoader {
- convertGift := &RushShop{
- GoodsId: data.Id,
- Price: data.RMB,
- Name: data.Name,
- LimitCount: data.RestrictedType,
- }
- for _, reward := range data.Reward {
- strList := strings.Split(reward, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- convertGift.BuyReward = append(convertGift.BuyReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- ConvertGuildBattle[data.Id] = convertGift
- }
- for _, data := range serverproto.RuneShopRankPetCfgLoader {
- mapShop := &RushShop{
- GoodsId: data.Id,
- Name: data.Name,
- Price: data.RMB,
- Activity: data.RankId,
- LimitCount: data.RestrictedType,
- // Score: data.RewardScore,
- }
- for _, items := range data.Reward {
- strList := strings.Split(items, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- mapShop.BuyReward = append(mapShop.BuyReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- ConvertPetShop[data.Id] = mapShop
- }
- for _, data := range serverproto.RuneShopRankSkillCfgLoader {
- mapShop := &RushShop{
- GoodsId: data.Id,
- Name: data.Name,
- Price: data.RMB,
- Activity: data.RankId,
- LimitCount: data.RestrictedType,
- // Score: data.RewardScore,
- }
- for _, items := range data.Reward {
- strList := strings.Split(items, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- mapShop.BuyReward = append(mapShop.BuyReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- ConvertSkillShop[data.Id] = mapShop
- }
- for _, data := range serverproto.RuneShopRankAidouluCfgLoader {
- convertIdol := &RushShop{
- GoodsId: data.Id,
- Name: data.Name,
- Price: data.RMB,
- Activity: data.RankId,
- LimitCount: data.RestrictedType,
- Score: data.IfRequite,
- Ticket: data.RewardScore,
- }
- for _, items := range data.SeverReward {
- strList := strings.Split(items, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- convertIdol.BuyReward = append(convertIdol.BuyReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- ConvertIdolShop[data.Id] = convertIdol
- }
- // 充值钱包功能(配置和RuneSHoGifts一致)
- for _, data := range serverproto.PurseShopCfgLoader {
- convertGift := &GiftBag{
- GoodsId: data.Id,
- BagType: data.Type,
- Price: data.RMB,
- Name: data.Name,
- LimitCount: data.RestrictedType,
- RmbTotalPay: data.RmbTotalPay,
- }
- for _, reward := range data.Reward {
- strList := strings.Split(reward, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- convertGift.BuyReward = append(convertGift.BuyReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- for _, first := range data.FirstBuyReward {
- strList := strings.Split(first, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- convertGift.FirstReward = append(convertGift.FirstReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- for _, extra := range data.ExtraBuyReward {
- strList := strings.Split(extra, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- convertGift.ExtraReward = append(convertGift.ExtraReward, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- ConvertPurseShop[data.Id] = convertGift
- if data.RMB == 0 {
- ConvertPurseShop[data.Id] = convertGift
- }
- }
- }
- const (
- Rush_Type_Tower = 1 //爬塔
- Rush_Type_Arena = 2 //英灵殿
- Rush_Type_Map = 3 //推图进度
- Rush_Type_Pet = 4 //宠物
- Rush_Type_Skill = 5 //技能压制等级
- )
- const (
- Rush_Reward_Type_FightCount = 1 //战斗次数,或者地图等级
- Rush_Reward_Type_Rank = 2 //排行版奖励
- )
- type RewardRank struct {
- RankBegin int32
- RankEnd int32
- RankLevel int32 //所在档位
- RewardList []*serverproto.KeyValueType
- }
- type RankList struct {
- RankRound int32
- StartDay int32
- StartTime string
- CloseDay int32
- CloseTime string
- RestDay int32
- RestTime string
- Reward []*RewardRank
- }
- type RewardBase struct {
- RewardBegin int32
- RewardEnd int32
- RewardLevel int32 //所在档位
- // RewardList []*serverproto.KeyValueType
- RewardList map[int32]int32
- }
- type RushBaseReward struct {
- Reward []*RewardBase
- }
- type RankActivity struct {
- RushActivity map[int32]*RankList
- BaseReward map[int32]*RushBaseReward
- }
- var DaySec int32 = 24 * 60 * 60
- var ConvertRushList = map[int32]*RankActivity{}
- func convertRushListCfg() {
- for _, data := range serverproto.RushListCfgLoader {
- _, ok := ConvertRushList[data.RankType]
- if !ok {
- rankActivity := &RankActivity{
- RushActivity: map[int32]*RankList{},
- BaseReward: map[int32]*RushBaseReward{},
- }
- ConvertRushList[data.RankType] = rankActivity
- }
- _, ok2 := ConvertRushList[data.RankType].RushActivity[data.RankId]
- if !ok2 {
- rankList := &RankList{}
- rankList.RankRound = data.RankId
- rankList.StartDay = data.StartDay
- rankList.StartTime = data.StartTime
- rankList.CloseDay = data.CloseDay
- rankList.CloseTime = data.CloseTime
- rankList.RestDay = data.RestDay
- rankList.RestTime = data.RestTime
- ConvertRushList[data.RankType].RushActivity[data.RankId] = rankList
- }
- rush, ok3 := ConvertRushList[data.RankType].RushActivity[data.RankId]
- if ok3 {
- rewardRank := &RewardRank{
- RankLevel: data.RankGrade,
- }
- if len(data.Rank) >= 1 {
- strList := strings.Split(data.Rank[0], ":")
- if len(strList) >= 2 {
- begin, _ := Str2Num(strList[0])
- end, _ := Str2Num(strList[1])
- rewardRank.RankBegin = int32(begin)
- rewardRank.RankEnd = int32(end)
- }
- }
- for _, reward := range data.Reward {
- strList := strings.Split(reward, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- rewardRank.RewardList = append(rewardRank.RewardList, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- }
- }
- rush.Reward = append(rush.Reward, rewardRank)
- }
- }
- for _, data := range serverproto.RushListTargetCfgLoader {
- _, ok := ConvertRushList[data.RankType]
- if !ok {
- continue
- }
- //没有这个活动。也不能加载这个活动对应的奖励
- _, ok2 := ConvertRushList[data.RankType].RushActivity[data.RankId]
- if !ok2 {
- continue
- }
- _, ok3 := ConvertRushList[data.RankType].BaseReward[data.RankId]
- if !ok3 {
- rushBaseReward := &RushBaseReward{}
- ConvertRushList[data.RankType].BaseReward[data.RankId] = rushBaseReward
- }
- rushReward, ok4 := ConvertRushList[data.RankType].BaseReward[data.RankId]
- if ok4 {
- rewardRank := &RewardBase{
- RewardLevel: data.TargetGrade,
- RewardList: make(map[int32]int32),
- }
- if len(data.Rank) >= 1 {
- strList := strings.Split(data.Rank[0], ":")
- if len(strList) >= 2 {
- begin, _ := Str2Num(strList[0])
- end, _ := Str2Num(strList[1])
- rewardRank.RewardBegin = int32(begin)
- rewardRank.RewardEnd = int32(end)
- }
- }
- for _, reward := range data.Reward {
- strList := strings.Split(reward, ":")
- if len(strList) >= 2 {
- key, _ := Str2Num(strList[0])
- value, _ := Str2Num(strList[1])
- rewardRank.RewardList[int32(key)] = int32(value)
- /*
- rewardRank.RewardList = append(rewardRank.RewardList, &serverproto.KeyValueType{
- Key: int32(key),
- Value: int32(value),
- })
- */
- }
- }
- rushReward.Reward = append(rushReward.Reward, rewardRank)
- }
- }
- }
- func GetRushActivityTimeStamp(deltaDay int32, deltaTime string) uint64 {
- loc := util.GetLoc()
- startUpTime := service.GetServiceStartupTime()
- if startUpTime < 0 {
- util.ErrorF("[convertRushListCfg] data error:%v")
- return 0
- }
- startServer := time.Unix(int64(startUpTime/1000), 0).In(loc).Format(util.DATE_FORMAT1)
- startUpDayStr := util.GetDayByTimeStr1(startServer)
- rushBegin := util.GetTimeByStr(startUpDayStr.Format(util.DATE_FORMAT1) + " " + deltaTime)
- rushStart := time.Unix(rushBegin.Unix()+int64(deltaDay-1)*int64(DaySec), 0).In(loc)
- return uint64(rushStart.UnixNano() / 1e6)
- }
- func GetCurrentRushActivity(RankType int32, RushRound int32) *RankList {
- rushList, ok := ConvertRushList[RankType]
- if !ok {
- return nil
- }
- nowTime := util.GetCurrentTime()
- for _, data := range rushList.RushActivity {
- if RushRound != 0 {
- if data.RankRound != RushRound {
- continue
- }
- }
- rushBegin := GetRushActivityTimeStamp(data.StartDay, data.StartTime)
- rewardEnd := GetRushActivityTimeStamp(data.RestDay, data.RestTime)
- if rushBegin <= nowTime && nowTime <= rewardEnd {
- return data
- }
- }
- return nil
- }
- func GetNextRushActivity(RankType int32, RushRound int32) *RankList {
- rushList, ok := ConvertRushList[RankType]
- if !ok {
- return nil
- }
- nowTime := util.GetCurrentTime()
- for i := RushRound; i <= int32(len(rushList.RushActivity)); i++ {
- data, ok := rushList.RushActivity[i]
- if !ok {
- continue
- }
- if nowTime < GetRushActivityTimeStamp(data.StartDay, data.StartTime) {
- return data
- }
- }
- return nil
- }
- func GetRushActivityByRound(RankType int32, RushRound int32) *RankList {
- rushList, ok := ConvertRushList[RankType]
- if !ok {
- return nil
- }
- for _, data := range rushList.RushActivity {
- if data.RankRound != RushRound {
- continue
- }
- return data
- }
- return nil
- }
- func GetRushActivityBaseReward(RushRound int32, RankType int32, score int32, addItemList map[int32]int32) int32 {
- rushList, ok := ConvertRushList[RankType]
- if !ok {
- return 0
- }
- rewards, ok2 := rushList.BaseReward[RushRound]
- if !ok2 {
- return 0
- }
- for _, data := range rewards.Reward {
- if data.RewardEnd != 0 && data.RewardBegin <= score && score <= data.RewardEnd ||
- data.RewardEnd == 0 && data.RewardBegin <= score {
- for key, value := range data.RewardList {
- addItemList[key] += value
- }
- return data.RewardLevel
- }
- }
- return 0
- }
- type LevelUpMaterial struct {
- Materials map[int32]int32
- AddAttr map[int32]int32
- Level int32
- }
- type KeepSakeData struct {
- KeepSakeId int32
- LevelData map[int32]*LevelUpMaterial
- LevelDataList []*LevelUpMaterial
- Job []int32
- KeepLevel int32
- MaxLevel int32
- AllMaterials map[int32]int32
- }
- var ConvertMaterialToKeepSake = map[int32]int32{}
- var ConvertKeepSake = map[int32]*KeepSakeData{}
- func convertKeepSakeCfg() {
- for _, data := range serverproto.KeepSakeCfgLoader {
- convert := &KeepSakeData{
- KeepSakeId: data.Id,
- KeepLevel: data.CollectionLevel,
- }
- convert.LevelData = make(map[int32]*LevelUpMaterial)
- convert.AllMaterials = make(map[int32]int32)
- for _, jobs := range data.Job {
- jobId, _ := Str2Num(jobs)
- convert.Job = append(convert.Job, int32(jobId))
- }
- //等級1
- levelUpMaterial1 := &LevelUpMaterial{}
- levelUpMaterial1.Materials = make(map[int32]int32)
- levelUpMaterial1.AddAttr = make(map[int32]int32)
- for _, material1 := range data.MaterialLevel1 {
- material := strings.Split(material1, ":")
- if len(material) >= 2 {
- itemId, _ := Str2Num(material[0])
- itemCount, _ := Str2Num(material[1])
- levelUpMaterial1.Materials[int32(itemId)] = int32(itemCount)
- ConvertMaterialToKeepSake[int32(itemId)] = data.Id
- convert.MaxLevel = 1
- convert.AllMaterials[int32(itemId)] = 1
- }
- }
- for _, attr1 := range data.AddAttrLevel1 {
- addAttr := strings.Split(attr1, ":")
- if len(addAttr) >= 2 {
- attrKey, _ := Str2Num(addAttr[0])
- attrValue, _ := Str2Num(addAttr[1])
- levelUpMaterial1.AddAttr[int32(attrKey)] = int32(attrValue)
- }
- }
- levelUpMaterial1.Level = 1
- convert.LevelData[1] = levelUpMaterial1
- convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial1)
- //等級2
- levelUpMaterial2 := &LevelUpMaterial{}
- levelUpMaterial2.Materials = make(map[int32]int32)
- levelUpMaterial2.AddAttr = make(map[int32]int32)
- for _, material2 := range data.MaterialLevel2 {
- material := strings.Split(material2, ":")
- if len(material) >= 2 {
- itemId, _ := Str2Num(material[0])
- itemCount, _ := Str2Num(material[1])
- levelUpMaterial2.Materials[int32(itemId)] = int32(itemCount)
- ConvertMaterialToKeepSake[int32(itemId)] = data.Id
- convert.MaxLevel = 2
- convert.AllMaterials[int32(itemId)] = 1
- }
- }
- for _, attr2 := range data.AddAttrLevel2 {
- addAttr := strings.Split(attr2, ":")
- if len(addAttr) >= 2 {
- attrKey, _ := Str2Num(addAttr[0])
- attrValue, _ := Str2Num(addAttr[1])
- levelUpMaterial2.AddAttr[int32(attrKey)] = int32(attrValue)
- }
- }
- levelUpMaterial2.Level = 2
- convert.LevelData[2] = levelUpMaterial2
- convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial2)
- levelUpMaterial3 := &LevelUpMaterial{}
- levelUpMaterial3.Materials = make(map[int32]int32)
- levelUpMaterial3.AddAttr = make(map[int32]int32)
- for _, material3 := range data.MaterialLevel3 {
- material := strings.Split(material3, ":")
- if len(material) >= 2 {
- itemId, _ := Str2Num(material[0])
- itemCount, _ := Str2Num(material[1])
- levelUpMaterial3.Materials[int32(itemId)] = int32(itemCount)
- ConvertMaterialToKeepSake[int32(itemId)] = data.Id
- convert.MaxLevel = 3
- convert.AllMaterials[int32(itemId)] = 1
- }
- }
- for _, attr3 := range data.AddAttrLevel3 {
- attr := strings.Split(attr3, ":")
- if len(attr) >= 2 {
- attrKey, _ := Str2Num(attr[0])
- attrValue, _ := Str2Num(attr[1])
- levelUpMaterial3.AddAttr[int32(attrKey)] = int32(attrValue)
- }
- }
- levelUpMaterial3.Level = 3
- convert.LevelData[3] = levelUpMaterial3
- convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial3)
- levelUpMaterial4 := &LevelUpMaterial{}
- levelUpMaterial4.Materials = make(map[int32]int32)
- levelUpMaterial4.AddAttr = make(map[int32]int32)
- for _, material4 := range data.MaterialLevel4 {
- material := strings.Split(material4, ":")
- if len(material) >= 2 {
- itemId, _ := Str2Num(material[0])
- itemCount, _ := Str2Num(material[1])
- levelUpMaterial4.Materials[int32(itemId)] = int32(itemCount)
- ConvertMaterialToKeepSake[int32(itemId)] = data.Id
- convert.MaxLevel = 4
- convert.AllMaterials[int32(itemId)] = 1
- }
- }
- for _, attr4 := range data.AddAttrLevel4 {
- attr := strings.Split(attr4, ":")
- if len(attr) >= 2 {
- attrKey, _ := Str2Num(attr[0])
- attrValue, _ := Str2Num(attr[1])
- levelUpMaterial4.AddAttr[int32(attrKey)] = int32(attrValue)
- }
- }
- levelUpMaterial4.Level = 4
- convert.LevelData[4] = levelUpMaterial4
- convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial4)
- levelUpMaterial5 := &LevelUpMaterial{}
- levelUpMaterial5.Materials = make(map[int32]int32)
- levelUpMaterial5.AddAttr = make(map[int32]int32)
- for _, material5 := range data.MaterialLevel5 {
- material := strings.Split(material5, ":")
- if len(material) >= 2 {
- itemId, _ := Str2Num(material[0])
- itemCount, _ := Str2Num(material[1])
- levelUpMaterial5.Materials[int32(itemId)] = int32(itemCount)
- ConvertMaterialToKeepSake[int32(itemId)] = data.Id
- convert.MaxLevel = 5
- convert.AllMaterials[int32(itemId)] = 1
- }
- }
- for _, attr5 := range data.AddAttrLevel5 {
- attr := strings.Split(attr5, ":")
- if len(attr) >= 2 {
- attrKey, _ := Str2Num(attr[0])
- attrValue, _ := Str2Num(attr[1])
- levelUpMaterial5.AddAttr[int32(attrKey)] = int32(attrValue)
- }
- }
- levelUpMaterial5.Level = 5
- convert.LevelData[5] = levelUpMaterial5
- convert.LevelDataList = append(convert.LevelDataList, levelUpMaterial5)
- ConvertKeepSake[data.Id] = convert
- }
- for _, val := range ConvertKeepSake {
- sort.Slice(val.LevelDataList, func(i, j int) bool {
- return val.LevelDataList[i].Level < val.LevelDataList[j].Level
- })
- }
- }
- func GetMaxKeepSakeLevel(keepSakeId int32) int32 {
- data, ok := ConvertKeepSake[keepSakeId]
- if !ok {
- return 0
- }
- return data.MaxLevel
- }
- type SuitCondition struct {
- cardType int32
- cardLvl int32
- cardCnt int32
- }
- func (this SuitCondition) GetKey() int32 {
- return this.cardType
- }
- func (this SuitCondition) GetLvl() int32 {
- return this.cardLvl
- }
- func (this SuitCondition) GetCnt() int32 {
- return this.cardCnt
- }
- type CardSuitData struct {
- id int32
- suits []*serverproto.KeyValueType
- suitTerm []*SuitCondition
- SuitTotalCardNum map[int32]int32 //需要同种类型卡片的数量
- }
- func (this CardSuitData) GetConditions() []*SuitCondition {
- return this.suitTerm
- }
- func (this CardSuitData) GetSuits() []*serverproto.KeyValueType {
- return this.suits
- }
- func (this CardSuitData) Id() int32 {
- return this.id
- }
- var DbCardSuitData = map[int32]*CardSuitData{}
- var ConvertCardSuit []*CardSuitData
- func convertCardSuitNewCfg() {
- for _, v := range serverproto.CardSuitNewCfgLoader {
- data := &CardSuitData{
- SuitTotalCardNum: map[int32]int32{},
- }
- data.id = v.Id
- for _, v1 := range v.Suit1 {
- k, val := Str2Res(v1)
- data.suits = append(data.suits, &serverproto.KeyValueType{Key: k, Value: val})
- }
- for _, v2 := range v.TriggerConditions {
- t, l, c := Str2Res_3(v2)
- data.SuitTotalCardNum[t] += c
- data.suitTerm = append(data.suitTerm, &SuitCondition{t, l, c})
- }
- DbCardSuitData[v.Id] = data
- ConvertCardSuit = append(ConvertCardSuit, data)
- }
- sort.Slice(ConvertCardSuit, func(i, j int) bool {
- return ConvertCardSuit[i].id > ConvertCardSuit[j].id
- })
- }
- type TmapMaterial map[int32]int32
- type StFashionUp struct {
- level int32
- quality int32 // 品质 1:绿色 2:蓝色 3:紫色 4:金色 5:红色
- upAttr int32
- material TmapMaterial
- }
- func (this StFashionUp) Material() TmapMaterial {
- return this.material
- }
- func (this StFashionUp) UpAttr() int32 {
- return this.upAttr
- }
- func CreateKey16Offset(left, right int32) int32 {
- // 偏移16位作为 左值
- return left<<16 | right
- }
- var DbFashionLevelUp = make(map[int32]*StFashionUp)
- func CreateData(dbDate []string) *StFashionUp {
- data := &StFashionUp{material: make(TmapMaterial)}
- for _, v1 := range dbDate {
- id, cnt := Str2Res(v1)
- data.material[id] = cnt
- }
- return data
- }
- func covertFashionLevelUpCfg() {
- for _, v := range serverproto.FashionLevelUpLoader {
- data1 := CreateData(v.UpMaterial1)
- data1.level = v.Level
- data1.quality = 1
- data1.upAttr = v.UpAttribute
- DbFashionLevelUp[CreateKey16Offset(data1.level, data1.quality)] = data1
- data2 := CreateData(v.UpMaterial2)
- data2.level = v.Level
- data2.quality = 2
- data2.upAttr = v.UpAttribute
- DbFashionLevelUp[CreateKey16Offset(data2.level, data2.quality)] = data2
- data3 := CreateData(v.UpMaterial3)
- data3.level = v.Level
- data3.quality = 3
- data3.upAttr = v.UpAttribute
- DbFashionLevelUp[CreateKey16Offset(data3.level, data3.quality)] = data3
- data4 := CreateData(v.UpMaterial4)
- data4.level = v.Level
- data4.quality = 4
- data4.upAttr = v.UpAttribute
- DbFashionLevelUp[CreateKey16Offset(data4.level, data4.quality)] = data4
- data5 := CreateData(v.UpMaterial5)
- data5.level = v.Level
- data5.quality = 5
- data5.upAttr = v.UpAttribute
- DbFashionLevelUp[CreateKey16Offset(data5.level, data5.quality)] = data5
- }
- }
- type StFashionRandom struct {
- id int32
- roleid int32
- atrid []int32
- //refreshCost map[int32]int32
- }
- func (this StFashionRandom) GetAtrid() []int32 {
- return this.atrid[:]
- }
- func (this StFashionRandom) GetRoleid() int32 {
- return this.roleid
- }
- var DbFashionResetAttrCost = []map[int32]int32{}
- var DbFashionRandom = []*StFashionRandom{} // make(map[int32]*StFashionRandom)
- func convertFashionRandomCfg() {
- for _, v := range serverproto.FashionRandomLoader {
- //id, cnt := Str2Res(v.RefreshCost)
- data := &StFashionRandom{v.ID, int32(v.RoleId), []int32{}}
- for _, jobs := range v.AtrId {
- attrId, _ := Str2Num(jobs)
- data.atrid = append(data.atrid, int32(attrId))
- }
- DbFashionRandom = append(DbFashionRandom, data)
- //DbFashionRandom[data.roleid] = &data
- }
- var globalDb = serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Fashion_Attr)]
- if globalDb == nil {
- panic("299 全局配置错误")
- }
- items := strings.Split(globalDb.SVal, ";")
- for _, i2 := range items {
- id, cnt := Str2Res(i2)
- DbFashionResetAttrCost = append(DbFashionResetAttrCost, map[int32]int32{id: cnt})
- }
- }
- type StSuitLvlAttr struct {
- lvl int32
- attr *serverproto.KeyValueType
- }
- // 套装表
- type StFashionSuit struct {
- suitId int32
- fashionIds []int32
- mapAttr map[int32][]*serverproto.KeyValueType
- }
- func (this StFashionSuit) Id() int32 {
- return this.suitId
- }
- func (this StFashionSuit) GetIds() []int32 {
- return this.fashionIds[:]
- }
- func (this StFashionSuit) GetMapAttr() map[int32][]*serverproto.KeyValueType {
- return this.mapAttr
- }
- var DbFashionSuit = make(map[int32]*StFashionSuit)
- var DbFashionSuitID = make(map[int32][]*StFashionSuit)
- func converFashionSuitCfg() {
- for _, v := range serverproto.FashionSuitCfgLoader {
- data := &StFashionSuit{mapAttr: make(map[int32][]*serverproto.KeyValueType)}
- if len(v.LevelCondition) != len(v.Attribute) {
- panic("FashionSuitCfg 属性配置和等级配置不对应")
- }
- for i, val := range v.LevelCondition {
- lvl, _ := strconv.Atoi(val)
- resList := strings.Split(v.Attribute[i], ":")
- for _, i3 := range resList {
- values := strings.Split(i3, "-")
- if len(values) < 2 {
- continue
- }
- id, _ := Str2Num(values[0])
- attrVar, _ := Str2Num(values[1])
- data.mapAttr[int32(lvl)] = append(data.mapAttr[int32(lvl)], &serverproto.KeyValueType{Key: int32(id), Value: int32(attrVar)})
- }
- }
- for _, i2 := range v.FashionId {
- value, _ := Str2Num(i2)
- data.fashionIds = append(data.fashionIds, int32(value))
- }
- data.suitId = v.SuitId
- DbFashionSuit[v.SuitId] = data
- }
- for _, v := range serverproto.FashionSuitCfgLoader {
- data := &StFashionSuit{mapAttr: make(map[int32][]*serverproto.KeyValueType)}
- if len(v.LevelCondition) != len(v.Attribute) {
- panic("FashionSuitCfg 属性配置和等级配置不对应")
- }
- for i, val := range v.LevelCondition {
- lvl, _ := strconv.Atoi(val)
- resList := strings.Split(v.Attribute[i], ":")
- for _, i3 := range resList {
- values := strings.Split(i3, "-")
- if len(values) < 2 {
- continue
- }
- id, _ := Str2Num(values[0])
- attrVar, _ := Str2Num(values[1])
- data.mapAttr[int32(lvl)] = append(data.mapAttr[int32(lvl)], &serverproto.KeyValueType{Key: int32(id), Value: int32(attrVar)})
- }
- }
- for _, i2 := range v.FashionId {
- value, _ := Str2Num(i2)
- data.fashionIds = append(data.fashionIds, int32(value))
- }
- data.suitId = v.SuitId
- DbFashionSuit[v.SuitId] = data
- for _, id := range data.fashionIds {
- DbFashionSuitID[id] = append(DbFashionSuitID[id], data)
- }
- }
- }
- // //////////////////////////////////卢恩战令////////////////////
- type StRuneShopExplore struct {
- round int32
- goldExp int32
- missionExp int32
- missonExpUp int32
- rmb float32
- sellingBegin int32
- startTime string
- sellingDuration int32
- closeTime string
- maxlvrewads map[int32]int32
- expCost int32
- }
- func (this StRuneShopExplore) StartTime() string {
- return this.startTime
- }
- func (this StRuneShopExplore) CloseTime() string {
- return this.closeTime
- }
- func (this StRuneShopExplore) SellingBegin() int32 {
- return this.sellingBegin
- }
- func (this StRuneShopExplore) SellingDuration() int32 {
- return this.sellingDuration
- }
- func (this StRuneShopExplore) GetRound() int32 {
- return this.round
- }
- func (this StRuneShopExplore) GetRMB() float32 {
- return this.rmb
- }
- func (this StRuneShopExplore) GoldScale() int32 {
- return this.goldExp
- }
- func (this StRuneShopExplore) MissionScale() int32 {
- return this.missionExp
- }
- type GuildWarReward struct {
- Rank int32
- MemberRewardList []*serverproto.KeyValueType
- LeaderRewardList []*serverproto.KeyValueType
- }
- type GuildMvpReward struct {
- Rank int32
- RewardList []*serverproto.KeyValueType
- }
- type GuildBattleBuff struct {
- BuffId int32
- BuyData map[int32]*serverproto.KeyValueType
- }
- var GuildBattleRankReward = map[int32]*GuildWarReward{}
- var GuildBattleScoreMvpReward = map[int32]*GuildMvpReward{}
- var GuildBattleKillMvpReward = map[int32]*GuildMvpReward{}
- var GuildBattleBuffList = map[int32]*GuildBattleBuff{}
- func convertGuildWarCfg() {
- for _, data := range serverproto.GuildWarAgainstCfgLoader {
- rankReward := &GuildWarReward{
- Rank: data.Ranking,
- }
- for _, deacon := range data.DeaconReword {
- items := strings.Split(deacon, ":")
- if len(items) >= 2 {
- itemId, _ := Str2Num(items[0])
- itemCount, _ := Str2Num(items[1])
- rankReward.LeaderRewardList = append(rankReward.LeaderRewardList, &serverproto.KeyValueType{
- Key: int32(itemId),
- Value: int32(itemCount),
- })
- }
- }
- for _, member := range data.GuildsmenReword {
- items := strings.Split(member, ":")
- if len(items) >= 2 {
- itemId, _ := Str2Num(items[0])
- itemCount, _ := Str2Num(items[1])
- rankReward.MemberRewardList = append(rankReward.MemberRewardList, &serverproto.KeyValueType{
- Key: int32(itemId),
- Value: int32(itemCount),
- })
- }
- }
- GuildBattleRankReward[data.Ranking] = rankReward
- scoreMvpReward := &GuildMvpReward{
- Rank: data.PointMvp,
- }
- for _, score := range data.PointMvpReword {
- items := strings.Split(score, ":")
- if len(items) >= 2 {
- itemId, _ := Str2Num(items[0])
- itemCount, _ := Str2Num(items[1])
- scoreMvpReward.RewardList = append(scoreMvpReward.RewardList, &serverproto.KeyValueType{
- Key: int32(itemId),
- Value: int32(itemCount),
- })
- }
- }
- GuildBattleScoreMvpReward[data.PointMvp] = scoreMvpReward
- killerMvpReward := &GuildMvpReward{
- Rank: data.PointMvp,
- }
- for _, killer := range data.KillerMvpReword {
- items := strings.Split(killer, ":")
- if len(items) >= 2 {
- itemId, _ := Str2Num(items[0])
- itemCount, _ := Str2Num(items[1])
- killerMvpReward.RewardList = append(killerMvpReward.RewardList, &serverproto.KeyValueType{
- Key: int32(itemId),
- Value: int32(itemCount),
- })
- }
- }
- GuildBattleKillMvpReward[data.KillerMvp] = killerMvpReward
- }
- for _, data := range serverproto.GuildWarBuffCfgLoader {
- convertData := &GuildBattleBuff{
- BuffId: data.Id,
- BuyData: map[int32]*serverproto.KeyValueType{},
- }
- for idx, buffData := range data.Price {
- resType, count := Str2Res(buffData)
- convertData.BuyData[int32(idx+1)] = &serverproto.KeyValueType{
- Key: resType,
- Value: count,
- }
- }
- GuildBattleBuffList[data.Id] = convertData
- }
- }
- const (
- GuildBattle_Reward_GuildMember = 1
- GuildBattle_Reward_GuildLeader = 2
- GuildBattle_Reward_ScoreMvp = 3
- GuildBattle_Reward_KillerMvp = 4
- )
- func GetGuildBattleReward(rewardType int32, rank int32, rewardList []*serverproto.KeyValueType) {
- if rewardType == GuildBattle_Reward_GuildMember ||
- rewardType == GuildBattle_Reward_GuildLeader {
- data, ok := GuildBattleRankReward[rank]
- if !ok {
- return
- }
- if rewardType == GuildBattle_Reward_GuildMember {
- for _, items := range data.MemberRewardList {
- rewardList = append(rewardList, items)
- }
- } else if rewardType == GuildBattle_Reward_GuildLeader {
- for _, items := range data.LeaderRewardList {
- rewardList = append(rewardList, items)
- }
- }
- } else if rewardType == GuildBattle_Reward_ScoreMvp {
- data, ok := GuildBattleScoreMvpReward[rank]
- if !ok {
- return
- }
- for _, items := range data.RewardList {
- rewardList = append(rewardList, items)
- }
- } else if rewardType == GuildBattle_Reward_KillerMvp {
- data, ok := GuildBattleKillMvpReward[rank]
- if !ok {
- return
- }
- for _, items := range data.RewardList {
- rewardList = append(rewardList, items)
- }
- }
- }
- func (this StRuneShopExplore) MissionUp() int32 {
- return this.missonExpUp
- }
- func (this StRuneShopExplore) ExpCost() int32 {
- return this.expCost
- }
- func (this StRuneShopExplore) MaxAward() map[int32]int32 {
- return this.maxlvrewads
- }
- // var DbRuneShopExplore = make(map[int32]*StRuneShopExplore)
- var DbRuneShopExplore = []*StRuneShopExplore{}
- func GetRuneExploreDataByRound(round int32) *StRuneShopExplore {
- for _, explore := range DbRuneShopExplore {
- if explore.GetRound() != round {
- continue
- }
- return explore
- }
- return nil
- }
- func convertRuneShopExploreCfg() {
- for _, v := range serverproto.RuneShopExploreCfgLoader {
- data := &StRuneShopExplore{round: v.Round, rmb: v.RMB, sellingBegin: v.SellingBegin,
- sellingDuration: v.SellingDuration, expCost: v.ExpCost, maxlvrewads: make(map[int32]int32),
- startTime: v.StartTime, closeTime: v.CloseTime}
- _, val1 := Str2Res(v.GoldExp)
- data.goldExp = val1
- _, val2 := Str2Res(v.MissionExp)
- data.missionExp = val2
- up, _ := Str2Num(v.MissonExpUp)
- data.missonExpUp = data.missionExp * int32(up) / 100
- for _, i2 := range v.MaxLvRewad {
- id, cnt := Str2Res(i2)
- data.maxlvrewads[id] = cnt
- //data.maxlvrewads = append(data.maxlvrewads, &serverproto.KeyValueType{Key: id,Value: cnt})
- }
- DbRuneShopExplore = append(DbRuneShopExplore, data)
- //DbRuneShopExplore[data.round] = data
- }
- sort.Slice(DbRuneShopExplore, func(i, j int) bool {
- return DbRuneShopExplore[i].GetRound() < DbRuneShopExplore[j].GetRound()
- })
- }
- type StRuneShopExploreReward struct {
- lv int32
- round int32
- exp int32
- rewards map[int32]int32
- cashRewards map[int32]int32
- }
- func (this StRuneShopExploreReward) Exp() int32 {
- return this.exp
- }
- func (this StRuneShopExploreReward) Lvl() int32 {
- return this.lv
- }
- func (this StRuneShopExploreReward) GetAward() map[int32]int32 {
- return this.rewards
- }
- func (this StRuneShopExploreReward) GetCashAward() map[int32]int32 {
- return this.cashRewards
- }
- type StMaxData struct {
- MaxLvl int32
- MaxExp int32
- }
- var DbRuneShopExploreMax = make(map[int32]*StMaxData)
- var DbRuneShopExploreReward = make(map[int32]*StRuneShopExploreReward)
- func convertRuneShopExploreRewardCfg() {
- for _, v := range serverproto.RuneShopExploreRewardCfgLoader {
- data := &StRuneShopExploreReward{lv: v.Lv, round: v.ActiveRound, exp: v.Exp,
- rewards: make(map[int32]int32), cashRewards: make(map[int32]int32)}
- for _, i2 := range v.Reward {
- id, cnt := Str2Res(i2)
- data.rewards[id] = cnt
- //data.rewards = append(data.rewards, &serverproto.KeyValueType{Key: id,Value: cnt})
- }
- for _, i3 := range v.CashReward {
- id, cnt := Str2Res(i3)
- data.cashRewards[id] = cnt
- //data.cashRewards = append(data.cashRewards, &serverproto.KeyValueType{Key: id,Value: cnt})
- }
- DbRuneShopExploreReward[data.round<<16|data.lv] = data
- max, ok := DbRuneShopExploreMax[data.round]
- if !ok {
- max = &StMaxData{}
- }
- max.MaxExp += v.Exp
- if v.Lv > max.MaxLvl {
- max.MaxLvl = v.Lv
- }
- DbRuneShopExploreMax[data.round] = max
- }
- }
- // 在线累计时间奖励处理
- type OnlineRewardDayInfoST struct {
- Day int32
- Id int32
- RewardToTalTime int32 //累计时间 s
- RewardList []*serverproto.KeyValueType //奖励列表
- RewardCostCoin int32 //直接获取奖励消耗金币
- }
- var ConvertOnlineRewardList = map[int32][]*OnlineRewardDayInfoST{} //[Day,DayInfo]
- var ConvertOnlineRewardMaxDay int32 = 0
- func convertOnlineTimeRewardCfg() {
- ConvertOnlineRewardList = map[int32][]*OnlineRewardDayInfoST{}
- for _, cfgData := range serverproto.OnlineRewardsCfgLoader {
- rewardInfo := &OnlineRewardDayInfoST{
- Id: cfgData.Id,
- Day: cfgData.Day,
- RewardToTalTime: cfgData.Time,
- RewardCostCoin: cfgData.SpeedUp,
- }
- for idx := 0; idx < len(cfgData.Rewards); idx++ {
- k, v := Str2Res(cfgData.Rewards[idx])
- if k <= 0 || v <= 0 {
- continue
- }
- rewardInfo.RewardList = append(rewardInfo.RewardList, &serverproto.KeyValueType{
- Key: k,
- Value: v,
- })
- }
- ConvertOnlineRewardList[cfgData.Day] = append(ConvertOnlineRewardList[cfgData.Day], rewardInfo)
- if ConvertOnlineRewardMaxDay < cfgData.Day {
- ConvertOnlineRewardMaxDay = cfgData.Day
- }
- }
- //sort
- for key := range ConvertOnlineRewardList {
- sort.Slice(ConvertOnlineRewardList[key], func(i, j int) bool {
- return ConvertOnlineRewardList[key][i].Id <
- ConvertOnlineRewardList[key][j].Id
- })
- }
- }
- type StQualityData struct {
- ItemId int32
- QualityPoint int32
- MaxUse int32
- }
- var DBQualityFruit = map[int32]*StQualityData{}
- func convertQualityFruitCfg() {
- gload, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Quality_Fruit_Item)]
- if !ok {
- panic("GlobalCfg quality Fruit error")
- return
- }
- lis := strings.Split(gload.SVal, ";")
- for _, li := range lis {
- id, value, maxCnt := Str2Res_3(li)
- DBQualityFruit[id] = &StQualityData{id, value, maxCnt}
- }
- }
- type StJobChangeData struct {
- Id int32
- JobType int32
- JobStage int32 //职业阶数
- BeforeJobId int32
- JobBranch int32
- AfterJobIds []int32 // 下一阶职业
- ChangeCond []string // 转职条件
- ItemCosts map[int32]int32
- Skills []int32 // 默认装备技能
- NewSkills []int32
- }
- func (this *StJobChangeData) HasNextJob(jobId int32) bool {
- for _, v := range this.AfterJobIds {
- if jobId != v {
- continue
- }
- return true
- }
- return false
- }
- func (this *StJobChangeData) converRoleData(data *serverproto.JobCfg) *StJobChangeData {
- this.ItemCosts = make(map[int32]int32)
- this.Id = data.Id
- this.JobType = data.JobType
- this.JobStage = data.JobStage
- //this.ChangeCond = data.ChangeCond
- this.BeforeJobId = data.BeforeJobId
- this.JobBranch = data.JobBranch
- for _, v := range data.AfterJobId {
- num, err := Str2Num(v)
- if err != nil {
- continue
- }
- this.AfterJobIds = append(this.AfterJobIds, int32(num))
- }
- for _, v := range data.ItemCost {
- id, cnt := Str2Res(v)
- if id <= 0 || cnt <= 0 {
- continue
- }
- this.ItemCosts[id] = cnt //append(this.ItemCosts, &serverproto.KeyValueType{Key:id,Value: cnt})
- }
- for _, id := range data.SkillIds {
- skillId, _ := Str2Num(id)
- this.Skills = append(this.Skills, int32(skillId))
- }
- for _, s := range data.ChangeCond {
- if len(s) <= 0 {
- continue
- }
- this.ChangeCond = append(this.ChangeCond, s)
- }
- return this
- }
- func (this *StJobChangeData) converParterData(data *serverproto.ParterCfg) *StJobChangeData {
- this.ItemCosts = make(map[int32]int32)
- this.Id = data.ParterId
- this.JobType = data.JobType
- this.JobStage = data.JobStage
- //this.ChangeCond = data.ChangeCond
- this.BeforeJobId = data.BeforeJobId
- this.JobBranch = data.JobBranch
- for _, v := range data.AfterJobId {
- num, err := Str2Num(v)
- if err != nil {
- continue
- }
- this.AfterJobIds = append(this.AfterJobIds, int32(num))
- }
- for _, v := range data.ItemCost {
- id, cnt := Str2Res(v)
- if id <= 0 || cnt <= 0 {
- continue
- }
- this.ItemCosts[id] = cnt //append(this.ItemCosts, &serverproto.KeyValueType{Key:id,Value: cnt})
- }
- for _, id := range data.SkillIds {
- skillId, _ := Str2Res(id)
- this.Skills = append(this.Skills, int32(skillId))
- }
- for _, s := range data.ChangeCond {
- if len(s) <= 0 {
- continue
- }
- this.ChangeCond = append(this.ChangeCond, s)
- }
- return this
- }
- var DBJobChange = map[int32]*StJobChangeData{}
- // 生成职业表Id
- func GetJobChangeKey(isRoleMain bool, jobId int32) int32 {
- key := jobId
- // 伙伴职业Id与主角职业id相同, 伙伴Id增加10倍区分主角职业Id
- if !isRoleMain {
- key *= 10
- }
- return key
- }
- func convertJobChangeCfg() {
- // 临时记录, key值对应技能表中数据,根据组合参数索引出技能Id,保存到DBJobChange结构中
- var tmp = map[int32]*StJobChangeData{}
- var tmpky = map[int32][]*serverproto.KeyValueType{}
- // 生成技能表位移key值 偏移24位:是否主角数据, 偏移16位:职业类型 偏移8位:技能阶数 后八位:分支值
- calcKey := func(jobtype, jobstate, JobBranch int32, roleMain bool) int32 {
- first := int32(1) // 是否是主角表
- if roleMain == true {
- first = 0
- }
- return first<<24 | jobtype<<16 | jobstate<<8 | JobBranch
- }
- //----------------------------------------------------------------------
- for i, cfg := range serverproto.JobCfgLoader {
- db := new(StJobChangeData).converRoleData(cfg)
- DBJobChange[GetJobChangeKey(true, i)] = db
- tmp[calcKey(db.JobType, db.JobStage, db.JobBranch, true)] = db
- }
- for i, cfg := range serverproto.ParterCfgLoader {
- db := new(StJobChangeData).converParterData(cfg)
- DBJobChange[GetJobChangeKey(false, i)] = db
- tmp[calcKey(db.JobType, db.JobStage, db.JobBranch, false)] = db
- }
- // 从主角技能表解析出 对应的职业
- for _, skilldb := range serverproto.SkillTreeCfgLoader {
- key := calcKey(skilldb.JobType, skilldb.JobStage, skilldb.JobBranch, true) // 位移生成 key值
- if _, ok := tmp[key]; ok {
- tmpky[key] = append(tmpky[key], &serverproto.KeyValueType{Key: skilldb.SkillId, Value: skilldb.OpenLevel})
- sort.Slice(tmpky[key], func(i, j int) bool { return tmpky[key][i].Value < tmpky[key][j].Value })
- } else {
- panic("技能解析出错")
- }
- }
- // 从伙伴技能表解析出 对应的职业
- for _, skilldb := range serverproto.ParterSkillTreeCfgLoader {
- key := calcKey(skilldb.JobType, skilldb.JobStage, skilldb.JobBranch, false)
- if _, ok := tmp[key]; ok {
- tmpky[key] = append(tmpky[key], &serverproto.KeyValueType{Key: skilldb.SkillId, Value: skilldb.OpenLevel})
- sort.Slice(tmpky[key], func(i, j int) bool { return tmpky[key][i].Value < tmpky[key][j].Value })
- } else {
- panic("伙伴技能解析出错")
- }
- }
- // 根据等级排序写入对应职业
- for i, types := range tmpky {
- data, _ := tmp[i]
- for _, valueType := range types {
- data.NewSkills = append(data.NewSkills, valueType.Key)
- }
- }
- }
- type ConvertSysRewardData struct {
- TowerLevel int32
- RewardList map[int32]int32
- }
- var ConvertSysRewardList []*ConvertSysRewardData
- func convertSysRewardCfg() {
- for key, val := range serverproto.SysRewardLoader {
- convertData := &ConvertSysRewardData{
- TowerLevel: key,
- RewardList: map[int32]int32{},
- }
- for idx := 0; idx < len(val.Reward); idx++ {
- rewardId, _ := Str2Num(val.Reward[idx])
- if rewardId > 0 {
- convertData.RewardList[int32(rewardId)]++
- }
- }
- ConvertSysRewardList = append(ConvertSysRewardList, convertData)
- }
- sort.Slice(ConvertSysRewardList, func(i, j int) bool {
- return ConvertSysRewardList[i].TowerLevel < ConvertSysRewardList[j].TowerLevel
- })
- }
- // 占星
- type ConvertDevine struct {
- StarCount int32
- NormalRate int32
- SpecialRate int32
- ItemCost map[int32]int32
- GoldCost map[int32]int32
- RewardList map[int32]int32
- LuckyTicket int32
- TicketCount int32
- ScoreId int32
- ScorePoint int32
- BroadCast int32
- }
- var ConvertCompetitionDevine = map[int32]*ConvertDevine{}
- func convertCompetitionDevineCfg() {
- for _, data := range serverproto.CompetitionDevineCfgLoader {
- convertData := &ConvertDevine{
- StarCount: data.NowLightNum,
- NormalRate: data.Probability,
- SpecialRate: data.PledgeProbability,
- }
- convertData.ItemCost = make(map[int32]int32)
- convertData.GoldCost = make(map[int32]int32)
- convertData.RewardList = make(map[int32]int32)
- for _, item := range data.ItemPrice {
- itemId, itemNum := Str2Res(item)
- if itemId != 0 && itemNum != 0 {
- convertData.ItemCost[itemId] += itemNum
- }
- }
- for _, item := range data.GoldPrice {
- itemId, itemNum := Str2Res(item)
- if itemId != 0 && itemNum != 0 {
- convertData.GoldCost[itemId] += itemNum
- }
- }
- for _, item := range data.Rewards {
- itemId, itemNum := Str2Res(item)
- if itemId != 0 && itemNum != 0 {
- convertData.RewardList[itemId] += itemNum
- }
- }
- if len(data.LuckyPrice) > 0 {
- luckId, luckyNum := Str2Res(data.LuckyPrice[0])
- convertData.LuckyTicket = luckId
- convertData.TicketCount = luckyNum
- }
- if len(data.Point) > 0 {
- scoreId, scoreNum := Str2Res(data.Point[0])
- convertData.ScoreId = scoreId
- convertData.ScorePoint = scoreNum
- }
- convertData.BroadCast = data.IfBroadcast
- ConvertCompetitionDevine[data.NowLightNum] = convertData
- }
- }
- var ConvertYuanHangTrail = map[int32]*ConvertYuanHangTrialData{}
- var ConvertYuanHangMaxShipLevel int32 = 0
- type ConvertYuanHangTrialData struct {
- ShipLevel int32 //type id
- Duration int32 //s
- ConsumeSpecialItemList map[int32]int32 //特殊道具消耗
- ConsumeNormalList map[int32]int32 //普通金币消耗
- ShipRefreshSuccessRate int //100 rate
- ShipRefreshTopLevelCost []*serverproto.KeyValueType //直接升级到顶级消耗(根据列表优先级消耗)
- ShipRewardList map[int32]int32
- BeAttackNum int32 //被攻击丢失奖励次数
- BeAttackScore int32
- BeAttackRewardList map[int32]int32
- BeAttackRewardListSlice []*serverproto.KeyValueType
- BeAttackLoseItemList map[int32]int32 //被打劫损失奖励
- BeAttackLoseItemListSlice []*serverproto.KeyValueType
- }
- func (this *ConvertYuanHangTrialData) RefreshShip(force bool) (int32, serverproto.ErrorCode) {
- if force {
- return ConvertYuanHangMaxShipLevel, serverproto.ErrorCode_ERROR_OK
- }
- if this.ShipRefreshSuccessRate <= 0 {
- return this.ShipLevel, serverproto.ErrorCode_ERROR_CROSS_YUANHANGTRIAL_TOP_SHIPLEVEL
- }
- randNum := rand.Intn(100) + 1
- if randNum <= this.ShipRefreshSuccessRate {
- return this.ShipLevel + 1, serverproto.ErrorCode_ERROR_OK
- }
- return this.ShipLevel, serverproto.ErrorCode_ERROR_CROSS_YUANHANGTRIAL_REFRESH_FAILED
- }
- func convertYuanHangTrailCfg() {
- for _, data := range serverproto.TransportCfgLoader {
- trailItem := &ConvertYuanHangTrialData{
- ShipLevel: data.ShipLevel,
- Duration: data.Duration * 60,
- ShipRefreshSuccessRate: int(data.Probability),
- BeAttackNum: data.RobberyTimes,
- BeAttackScore: data.RobberyFraction,
- ConsumeSpecialItemList: map[int32]int32{},
- ConsumeNormalList: map[int32]int32{},
- ShipRewardList: map[int32]int32{},
- BeAttackRewardList: map[int32]int32{},
- BeAttackLoseItemList: map[int32]int32{},
- }
- if len(data.Consume) >= 1 {
- k, v := Str2Res(data.Consume[0])
- if k > 0 && v > 0 {
- trailItem.ConsumeSpecialItemList[k] += v
- }
- }
- if len(data.Consume) >= 2 {
- k, v := Str2Res(data.Consume[1])
- if k > 0 && v > 0 {
- trailItem.ConsumeNormalList[k] += v
- }
- }
- trailItem.ShipRefreshTopLevelCost = Str2ResSliceList(data.TopLevel)
- Str2ResMapList(data.TranspoertReward, trailItem.ShipRewardList)
- Str2ResMapList(data.RobberyReward, trailItem.BeAttackRewardList)
- for _, str := range data.RobberyReward {
- k, v := Str2Res(str)
- if k > 0 && v > 0 {
- trailItem.BeAttackRewardListSlice = append(trailItem.BeAttackRewardListSlice,
- &serverproto.KeyValueType{Key: k, Value: v})
- }
- }
- Str2ResMapList(data.RobberyLose, trailItem.BeAttackLoseItemList)
- for _, str := range data.RobberyLose {
- k, v := Str2Res(str)
- if k > 0 && v > 0 {
- trailItem.BeAttackLoseItemListSlice = append(trailItem.BeAttackLoseItemListSlice,
- &serverproto.KeyValueType{Key: k, Value: v})
- }
- }
- ConvertYuanHangTrail[trailItem.ShipLevel] = trailItem
- if data.ShipLevel > ConvertYuanHangMaxShipLevel {
- ConvertYuanHangMaxShipLevel = data.ShipLevel
- }
- }
- }
- type StDbKingTaskData struct {
- TaskIds []int32 `csv:"TaskIds"` //成长任务
- DailyTaskIds []int32 `csv:"DailyTaskIds"` //今日挑战
- ActivitiesId int32 `csv:"ActivitiesId"` //活动Id
- }
- var ConvertKingTask = map[int32]map[int32]*StDbKingTaskData{}
- func GetKingTaskData(AvtivitiesId, day int32) *StDbKingTaskData {
- avt, ok := ConvertKingTask[AvtivitiesId]
- if !ok {
- return nil
- }
- data, ok := avt[day]
- if !ok {
- return nil
- }
- return data
- }
- func convertActivitiesKingTaskCfg() {
- for _, data := range serverproto.ActivitiesKingTaskCfgLoader {
- taskItem := &StDbKingTaskData{ActivitiesId: data.ActivitiesId}
- for _, id := range data.TaskIds {
- taskId, err := Str2Num(id)
- if err != nil {
- panic("convertActivitiesKingTask TaskIds err")
- }
- taskItem.TaskIds = append(taskItem.TaskIds, int32(taskId))
- }
- for _, id := range data.DailyTaskIds {
- taskId, err := Str2Num(id)
- if err != nil {
- panic("convertActivitiesKingTask DailyTaskIds err")
- }
- taskItem.DailyTaskIds = append(taskItem.DailyTaskIds, int32(taskId))
- }
- maptmp, ok := ConvertKingTask[data.ActivitiesId]
- if !ok {
- maptmp = make(map[int32]*StDbKingTaskData)
- ConvertKingTask[data.ActivitiesId] = maptmp
- }
- maptmp[data.Day] = taskItem
- }
- }
- type MatchSection struct {
- LevelRank int32
- LeftSection int32
- RightSection int32
- }
- func (this *MatchSection) InSection(val int32) bool {
- if this.LeftSection <= val &&
- this.RightSection >= val {
- return true
- }
- return false
- }
- type TopTowerData struct {
- SelfRankSection *MatchSection
- MatchSection []*MatchSection
- }
- type TopTowerRewardData struct {
- ForceWinCostList map[int32]int32
- Idx int32
- WinRewardList map[int32]int32
- }
- var ConvertTopTowerDataList []*TopTowerData
- var ConvertTopTowerRewardList []*TopTowerRewardData
- func convertTopTowerCfg() {
- for _, data := range serverproto.TopTowerCfgLevelLoader {
- rankInfo := &TopTowerData{}
- rankInfo.SelfRankSection = convertTopTowerSectionCfg(data.RankId, 0)
- rankInfo.MatchSection = append(rankInfo.MatchSection,
- convertTopTowerSectionCfg(data.LevelRank1, 1),
- convertTopTowerSectionCfg(data.LevelRank2, 2),
- convertTopTowerSectionCfg(data.LevelRank3, 3),
- convertTopTowerSectionCfg(data.LevelRank4, 4),
- convertTopTowerSectionCfg(data.LevelRank5, 5),
- convertTopTowerSectionCfg(data.LevelRank6, 6),
- convertTopTowerSectionCfg(data.LevelRank7, 7),
- convertTopTowerSectionCfg(data.LevelRank8, 8),
- convertTopTowerSectionCfg(data.LevelRank9, 9),
- convertTopTowerSectionCfg(data.LevelRank10, 10))
- ConvertTopTowerDataList = append(ConvertTopTowerDataList, rankInfo)
- }
- for _, data := range serverproto.TopTowerCfgRewardLoader {
- rewardData := &TopTowerRewardData{
- Idx: data.LevelId,
- ForceWinCostList: map[int32]int32{},
- WinRewardList: map[int32]int32{},
- }
- Str2ResMapList(data.BuyRoadCost, rewardData.ForceWinCostList)
- Str2ResMapList(data.RewardItems, rewardData.WinRewardList)
- ConvertTopTowerRewardList = append(ConvertTopTowerRewardList, rewardData)
- }
- }
- func convertTopTowerSectionCfg(sectionStr []string, idx int32) *MatchSection {
- tmpMatchSection := &MatchSection{}
- v1, _ := Str2Num(sectionStr[0])
- v2, _ := Str2Num(sectionStr[1])
- tmpMatchSection.LeftSection = int32(v1)
- tmpMatchSection.RightSection = int32(v2)
- tmpMatchSection.LevelRank = idx
- return tmpMatchSection
- }
- type StDbHeadData struct {
- HeadId int32
- HeadType int32
- ContinueTime int32 // 时长 (小时)
- BRestTask bool // 每日重置任务
- Attr []*serverproto.KeyValueType
- Condition map[int32][]int32 // 任务条件
- ActivateItem map[int32]int32 // 激活消耗
- }
- var DbHeadData = map[int32]*StDbHeadData{}
- func convertHeadDataCfg() {
- for _, cfg := range serverproto.DesignationCfgLoader {
- taskItem := &StDbHeadData{HeadId: cfg.ID, HeadType: cfg.Type, Condition: map[int32][]int32{}, ActivateItem: map[int32]int32{}, ContinueTime: cfg.Time}
- if cfg.RefreshDaily > 0 {
- taskItem.BRestTask = true
- } else {
- taskItem.BRestTask = false
- }
- for _, s := range cfg.Attribute {
- k, v := Str2Res(s)
- taskItem.Attr = append(taskItem.Attr, &serverproto.KeyValueType{Key: k, Value: v})
- }
- for _, v := range cfg.TaskCondition {
- valueList := strings.Split(v, ":")
- if len(valueList) >= 2 {
- taskType, _ := Str2Num(valueList[0])
- taskItem.Condition[int32(taskType)] = append(taskItem.Condition[int32(taskType)], int32(taskType))
- for i := 1; i < len(valueList); i++ {
- taskValue, _ := Str2Num(valueList[i])
- taskItem.Condition[int32(taskType)] = append(taskItem.Condition[int32(taskType)], int32(taskValue))
- }
- }
- }
- for _, s := range cfg.TaskConditionItem {
- if len(s) <= 0 {
- continue
- }
- k, v := Str2Res(s)
- taskItem.ActivateItem[k] = v
- }
- DbHeadData[taskItem.HeadId] = taskItem
- }
- }
- type DemonRewardData struct {
- Level int32
- StageMax uint64
- StageMin uint64
- Reward []*serverproto.KeyValueType
- }
- type GuildDemonData struct {
- ConfigId int32
- DemonId int32
- DemonLevel int32
- StartDay int32
- EndDay int32
- WeekDay int32
- ChallengeCount int32 //免费战斗次数
- BuyChallengeCount int32 //最大购买次数
- ChallengePrice map[int32]*serverproto.KeyValueType
- StartTime string
- RewardStage []*DemonRewardData
- BaseReward map[int32]int32
- }
- type GuildWeekDemonData struct {
- DemonData []*GuildDemonData
- }
- var ConvertGuildDemon = map[int32]*GuildWeekDemonData{}
- func convertGuildDemonCfg() {
- for _, data := range serverproto.GuildDemonCfgLoader {
- if data.Id == 0 {
- continue
- }
- _, ok := ConvertGuildDemon[data.WeekDay]
- if !ok {
- ConvertGuildDemon[data.WeekDay] = &GuildWeekDemonData{}
- }
- convertData := &GuildDemonData{
- ConfigId: data.Id,
- DemonId: data.Id,
- WeekDay: data.WeekDay,
- ChallengeCount: data.FreeChallenge,
- BuyChallengeCount: data.ChallengeTimes,
- StartTime: data.SummonTime,
- DemonLevel: data.BossLevel,
- BaseReward: map[int32]int32{},
- }
- if len(data.BossLvCycle) >= 1 {
- start, end := Str2Res(data.BossLvCycle[0])
- convertData.StartDay = int32(start)
- convertData.EndDay = int32(end)
- }
- damageList := strings.Split(data.DamageSegment, ";")
- if len(damageList) != len(data.DamageReward)+1 {
- util.InfoF("convertGuildDemonCfg boss config reward bossId:%v error: %v %v", data.Id, len(damageList), len(data.DamageReward))
- panic("convertGuildDemonCfg boss config reward error")
- }
- for i := 0; i < len(data.DamageReward); i++ {
- convertReward := &DemonRewardData{}
- damage := strings.Split(damageList[i+1], ":")
- if len(damage) >= 2 {
- level, _ := Str2Num(damage[0])
- minDamage, _ := Str2NumU64(damage[1])
- maxDamage, _ := Str2NumU64(damage[2])
- convertReward.StageMax = maxDamage
- convertReward.StageMin = minDamage
- convertReward.Level = int32(level)
- }
- //todo 解析伤害区间
- //解析奖励
- reward := strings.Split(data.DamageReward[i], ":")
- if len(reward) >= 2 {
- itemId, itemNum := Str2Res(data.DamageReward[i])
- convertReward.Reward = append(convertReward.Reward, &serverproto.KeyValueType{
- Key: itemId,
- Value: itemNum,
- })
- }
- convertData.RewardStage = append(convertData.RewardStage, convertReward)
- }
- convertData.ChallengePrice = make(map[int32]*serverproto.KeyValueType)
- for _, baseReward := range data.ChallengeReward {
- itemId, itemNum := Str2Res(baseReward)
- convertData.BaseReward[itemId] += itemNum
- }
- startIndex := int32(1)
- for _, priceData := range data.ChallengePrice {
- itemId, itemNum := Str2Res(priceData)
- convertData.ChallengePrice[startIndex] = &serverproto.KeyValueType{
- Key: itemId,
- Value: itemNum,
- }
- startIndex++
- }
- ConvertGuildDemon[data.WeekDay].DemonData = append(ConvertGuildDemon[data.WeekDay].DemonData, convertData)
- //util.InfoF("[GetDemonInfo] get guildDemon config [%v] data:%v", int32(data.Id), convertData)
- }
- }
- func GetDemonDataByConfigId(configId int32) *GuildDemonData {
- for _, weekDemon := range ConvertGuildDemon {
- for _, demon := range weekDemon.DemonData {
- if configId == demon.DemonId {
- return demon
- }
- }
- }
- return nil
- }
- // (int32, int32):(bossId, bossLevel)
- func GetDemonInfo(weekDay int32, curTime time.Time) (*GuildDemonData, int32) {
- curWeekDay := weekDay
- // curTime := util.GetCurrentTimeNow()
- if curTime.Hour() <= 4 {
- curWeekDay--
- if curWeekDay == 0 {
- curWeekDay = 7
- }
- }
- startUpTime := service.GetServiceStartupTime()
- curServerDay := util.GetDurationDay2(startUpTime, uint64(util.GetTimeMilliseconds()))
- guildDemon, ok := ConvertGuildDemon[int32(curWeekDay)]
- if !ok {
- util.InfoF("[GetDemonInfo] get guildDemon config [%v] ", int32(curWeekDay))
- return nil, 0
- }
- demonData := &GuildDemonData{}
- maxStartDay := int32(0)
- for _, data := range guildDemon.DemonData {
- if data.StartDay <= curServerDay && curServerDay <= data.EndDay {
- return data, curServerDay
- }
- if maxStartDay <= data.StartDay {
- maxStartDay = data.StartDay
- demonData = data
- }
- }
- return demonData, curServerDay
- }
- // nextRefreshTime下次刷新的时间戳,取前一天的相关数据
- func GetDemonInfoByTimeStamp(nextRefreshTime uint64) *GuildDemonData {
- nowTime := util.GetTimeByUint64(nextRefreshTime - 24*3600*1000)
- curWeekDay := nowTime.Weekday()
- if curWeekDay == 0 {
- curWeekDay = 7
- }
- if nowTime.Hour() <= 4 {
- curWeekDay--
- if curWeekDay == 0 {
- curWeekDay = 7
- }
- }
- startUpTime := service.GetServiceStartupTime()
- curServerDay := util.GetDurationDay1(startUpTime, nextRefreshTime)
- guildDemon, ok := ConvertGuildDemon[int32(curWeekDay)]
- if !ok {
- util.InfoF("[GetDemonInfo] get guildDemon config [%v] ", int32(curWeekDay))
- return nil
- }
- demonData := &GuildDemonData{}
- maxStartDay := int32(0)
- for _, data := range guildDemon.DemonData {
- if data.StartDay <= curServerDay && curServerDay <= data.EndDay {
- return data
- }
- if maxStartDay <= data.StartDay {
- maxStartDay = data.StartDay
- demonData = data
- }
- }
- return demonData
- }
- type ActivitySignInData struct {
- SignDay int32
- IsDouble int32
- VipLevel int32
- ActivityId int32
- RewardList map[int32]int32
- }
- type ActivitySignIn struct {
- SignData map[int32]*ActivitySignInData
- }
- var ConvertActivitySignIn = map[int32]*ActivitySignIn{}
- func convertActivitySignInCfg() {
- for _, data := range serverproto.ActivitiesSignInCfgLoader {
- _, ok := ConvertActivitySignIn[data.ActivitiesId]
- if !ok {
- convertData := &ActivitySignIn{
- SignData: map[int32]*ActivitySignInData{},
- }
- ConvertActivitySignIn[data.ActivitiesId] = convertData
- }
- signData := &ActivitySignInData{
- RewardList: map[int32]int32{},
- }
- signData.VipLevel = data.VipLevel
- signData.IsDouble = data.SignInType
- signData.SignDay = data.Day
- signData.ActivityId = data.ActivitiesId
- for _, reward := range data.SignInReward {
- itemId, itemCount := Str2Res(reward)
- signData.RewardList[itemId] += itemCount
- }
- ConvertActivitySignIn[data.ActivitiesId].SignData[data.Day] = signData
- }
- }
- type IdolBoxData struct {
- Level int32
- BoxCount int32
- TicketCount int32
- Reward []*serverproto.KeyValueType
- }
- var ConvertIdolBoxData = map[int32]*IdolBoxData{}
- func convertIdolSeasonCfg() {
- //解析馈赠宝箱
- for _, data := range serverproto.CompetitionAidouluCfgLoader {
- convertData := &IdolBoxData{
- Level: data.BoxId,
- BoxCount: data.GoodNum,
- TicketCount: data.ConditionHot,
- }
- for _, reward := range data.Rewards {
- itemId, itemNum := Str2Res(reward)
- if itemNum > 0 {
- convertData.Reward = append(convertData.Reward, &serverproto.KeyValueType{
- Key: itemId,
- Value: itemNum,
- })
- }
- }
- ConvertIdolBoxData[data.BoxId] = convertData
- }
- }
- type StProbRewardData struct {
- Weight int32
- ItemId int32
- ItemCnt int32
- WaitTime int32
- }
- type StDbWishBox struct {
- IsRand bool
- ItemId int32
- BoxType int32 // 类型
- WaitTime int32 // 倒计时
- LuckyProb int32 // 暴击概率
- SpeedCost serverproto.KeyValueType // 加速消耗
- RewardList []*StProbRewardData // 许愿奖励
- LuckyReward []*StProbRewardData // 暴击奖励
- }
- func (this StDbWishBox) GetRewardItem(itemId int32) (ret *StProbRewardData) {
- for _, i2 := range this.RewardList {
- if i2.ItemId != itemId {
- continue
- }
- ret = i2
- break
- }
- return
- }
- func (this StDbWishBox) GetRandRewardItem() (ret *StProbRewardData) {
- total := this.RewardList[len(this.RewardList)-1].Weight
- value := rand.Int31n(total)
- for _, i2 := range this.RewardList {
- if value > i2.Weight {
- continue
- }
- ret = i2
- break
- }
- return
- }
- var ConvertWishBoxData = map[int32]*StDbWishBox{}
- func convertWishCfg() {
- for _, data := range serverproto.WishCfgLoader {
- dbData := &StDbWishBox{ItemId: data.Id, BoxType: data.BoxType, WaitTime: data.WishCountdown, LuckyProb: data.LuckyProbability}
- initWeight := int32(0)
- for _, i2 := range data.WishReward {
- rewardItem := strings.Split(i2, ":")
- if len(rewardItem) < 3 {
- panic("许愿表配置奖励错误")
- }
- weight, itemId, itemcnt := Str2Res_3(i2)
- initWeight += weight
- dbData.RewardList = append(dbData.RewardList, &StProbRewardData{Weight: int32(initWeight), ItemId: int32(itemId), ItemCnt: int32(itemcnt), WaitTime: data.WishCountdown})
- }
- sort.Slice(dbData.RewardList, func(i, j int) bool {
- return dbData.RewardList[i].Weight < dbData.RewardList[j].Weight
- })
- if initWeight > 0 {
- dbData.IsRand = true
- }
- initWeight = 0
- for _, i2 := range data.LuckyReward {
- rewardItem := strings.Split(i2, ":")
- if len(rewardItem) < 3 {
- panic("许愿表配置暴击奖励错误")
- }
- weight, itemId, itemcnt := Str2Res_3(i2)
- initWeight += weight
- dbData.LuckyReward = append(dbData.LuckyReward, &StProbRewardData{Weight: int32(initWeight), ItemId: int32(itemId), ItemCnt: int32(itemcnt), WaitTime: data.WishCountdown})
- }
- sort.Slice(dbData.LuckyReward, func(i, j int) bool {
- return dbData.LuckyReward[i].Weight < dbData.LuckyReward[j].Weight
- })
- for _, i2 := range data.AccelerateCost {
- dbData.SpeedCost.Key, dbData.SpeedCost.Value = Str2Res(i2)
- }
- ConvertWishBoxData[data.Id] = dbData
- }
- }
- type CombineServer struct {
- Id int32
- ServerList []*serverproto.KeyValueType
- CombineTime uint64
- Notice string
- }
- var ConvertCombineServerData = map[int32]*CombineServer{}
- func ConvertCombinedServer() {
- //热跟新的时候需要重新处理
- ConvertCombineServerData = make(map[int32]*CombineServer)
- for _, data := range serverproto.CombinedServiceCfgLoader {
- combineData := &CombineServer{}
- combineData.Id = data.Id
- loc := util.GetLoc()
- if data.Time != "" {
- sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, data.Time, loc)
- if err1 != nil {
- util.PanicF("combineData endTime err:%v", err1)
- }
- combineData.CombineTime = uint64(sTime.UnixNano() / 1e6)
- }
- for _, servers := range data.Number {
- start, end := Str2Res(servers)
- combineData.ServerList = append(combineData.ServerList, &serverproto.KeyValueType{
- Key: start,
- Value: end,
- })
- }
- combineData.Notice = data.Tips
- ConvertCombineServerData[data.Id] = combineData
- }
- }
- func CheckInCombined(zoneId int32) (bool, uint64) {
- data, ok := ConvertCombineServerData[1]
- if !ok {
- return false, 0
- }
- /*
- nowTime := util.GetCurrentTime()
- if data.CombineTime > nowTime {
- return false
- }
- */
- for _, server := range data.ServerList {
- if server.Key <= zoneId && zoneId <= server.Value {
- return true, data.CombineTime
- }
- }
- return false, 0
- }
- // bt版本服务器配置文件处理
- type CfgBoliVipData struct {
- Id int32
- VipExp int32 // 升级到下一级需要经验
- VipRight map[int32]int32 // 特权
- DayReward []*serverproto.KeyValueType
- }
- type CfgBoliShopData struct {
- ShopItem *serverproto.ShopItem
- Conditions []*serverproto.KeyValueType
- GoodsItem int32
- PayForType int32
- PayForNum int32
- DiscountPayForNum int32
- }
- var ConvertBoliVipData = map[int32]*CfgBoliVipData{}
- var ConvertBoliShopData = map[int32][]*CfgBoliShopData{} // level,[]CfgBoliShopData
- var ConvertBoliShopDataById = map[int32]*CfgBoliShopData{} // cfgId,CfgBoliShopData
- func convertBtBoliCfg() {
- //bolivip
- for _, cfgData := range serverproto.BoliVipCfgLoader {
- tmpData := &CfgBoliVipData{
- Id: cfgData.Lv,
- VipExp: cfgData.VipExp,
- VipRight: map[int32]int32{},
- }
- tmpData.VipRight[Vip_System_Levelup] = cfgData.VipExp
- tmpData.VipRight[Vip_System_Evil] = cfgData.EvilFreeTimes
- tmpData.VipRight[Vip_System_PetAdvance] = cfgData.PetAdvance
- tmpData.VipRight[Vip_System_CardReset] = cfgData.CardReset
- tmpData.VipRight[Vip_System_PetDesolve] = cfgData.PetBreak
- tmpData.VipRight[Vip_System_SkillReset] = cfgData.SkillReset
- tmpData.VipRight[Vip_System_GuildHunt] = cfgData.GuildBossChallenge
- tmpData.VipRight[Vip_System_Arena] = cfgData.PvpReward
- tmpData.VipRight[Vip_System_DevilsUp] = cfgData.DevilsUp
- tmpData.VipRight[Vip_System_TransportRobbery] = cfgData.TransportRobbery
- tmpData.VipRight[Vip_System_LuxuryPrizeWheelTimes] = cfgData.LuxuryPrizeWheelTimes
- tmpData.DayReward = Str2ResSliceList(cfgData.GiftRewards)
- ConvertBoliVipData[cfgData.Lv] = tmpData
- }
- //bolishop
- for _, cfgData := range serverproto.BoliShopCfgLoader {
- convertData := &CfgBoliShopData{
- ShopItem: &serverproto.ShopItem{
- GoodsId: cfgData.GoodsId,
- Price: cfgData.PayForNum,
- CurPrice: cfgData.DiscountPayForNum,
- Dispercent: cfgData.Proportion,
- Hot: true,
- },
- GoodsItem: cfgData.GoodsItem,
- PayForType: cfgData.PayForType,
- PayForNum: cfgData.PayForNum,
- DiscountPayForNum: cfgData.DiscountPayForNum,
- }
- if cfgData.SellWell <= 0 {
- convertData.ShopItem.Hot = false
- }
- /*
- 1.永久限购
- 2.每天限购
- 3.有效期内限购
- 4.周限购
- 5.刷新类型商店限购(黑市商品不能配置1~4)
- const (
- LIMIT_TYPE_NONE = iota //无限购
- LIMIT_TYPE_FOREVER = 1 //永久限购
- LIMIT_TYPE_DAY = 2 //天限购(限购时间策划配置)
- LIMIT_TYPE_RANGE = 3 //范围限购。比如:从XX-XX
- LIMIT_TYPE_WEEK = 4 //周限购(限购时间策划配置)
- LIMIT_TYPE_SPECIAL = 5 //黑市限购
- LIMIT_TYPE_ARENA = 6 //赛季道具
- LIMIT_MAX
- )
- */
- limitRes := strings.Split(cfgData.RestrictedType, ":")
- if len(limitRes) >= 2 {
- lType, _ := Str2Num(limitRes[0])
- convertData.ShopItem.LimitType = int32(lType)
- if len(limitRes) == 2 {
- lCount, _ := Str2Num(limitRes[1])
- convertData.ShopItem.Count = int32(lCount)
- }
- if len(limitRes) >= 3 {
- lCircle, _ := Str2Num(limitRes[1])
- convertData.ShopItem.Circle = int32(lCircle)
- lCount, _ := Str2Num(limitRes[2])
- convertData.ShopItem.Count = int32(lCount)
- }
- }
- if convertData.ShopItem.LimitType == 3 {
- loc := util.GetLoc()
- if cfgData.BeginTime != "" {
- sTime, err1 := time.ParseInLocation(util.DATE_FORMAT, cfgData.BeginTime, loc)
- if err1 != nil {
- util.PanicF("convertBtCfg startTime err:%v", err1)
- }
- convertData.ShopItem.StartTime = int64(sTime.Unix())
- }
- if cfgData.EndTime != "" {
- cTime, err2 := time.ParseInLocation(util.DATE_FORMAT, cfgData.EndTime, loc)
- if err2 != nil {
- util.PanicF("convertBtCfg endTime err:%v", err2)
- }
- convertData.ShopItem.EndTime = int64(cTime.Unix())
- }
- }
- if len(cfgData.Condition) > 0 {
- for _, cond := range cfgData.Condition {
- condId, condArg := Str2Res(cond)
- if condId != 0 && condArg != 0 {
- convertData.Conditions = append(convertData.Conditions, &serverproto.KeyValueType{
- Key: int32(condId),
- Value: int32(condArg),
- })
- }
- }
- }
- ConvertBoliShopData[cfgData.BoliVipLevel] = append(ConvertBoliShopData[cfgData.BoliVipLevel], convertData)
- ConvertBoliShopDataById[cfgData.GoodsId] = convertData
- }
- }
- type BTRoCoinType int32
- const (
- BTTaskRefreshType_Day BTRoCoinType = iota
- BTTaskRefreshType_Week
- )
- type StActBTRecharge struct {
- Id int32
- Day int32
- RefreshDay BTRoCoinType
- TaskList []int32
- }
- var ConvertBTRechargeData = map[int32][]*StActBTRecharge{}
- var ConvertBTRechargeRoCoinDailyData = map[int32][]*StActBTRecharge{}
- var ConvertBTRechargeRoCoinWeekData = map[int32][]*StActBTRecharge{}
- func convertBTRoCoinRechargeCfg() {
- // 每日累计充值
- //ActiviesTiredChargeCfg 累计充值奖励
- for _, cfgData := range serverproto.ActivitiesBtChargeTaskGoldCfgLoader {
- dbData := &StActBTRecharge{
- Day: cfgData.Day,
- Id: cfgData.Id,
- RefreshDay: BTTaskRefreshType_Day,
- }
- for idx := 0; idx < len(cfgData.DailyTaskIds); idx++ {
- taskId, _ := Str2Num(cfgData.DailyTaskIds[idx])
- if taskId > 0 {
- dbData.TaskList = append(dbData.TaskList, int32(taskId))
- }
- }
- ConvertBTRechargeData[cfgData.ActivitiesId] = append(ConvertBTRechargeData[cfgData.ActivitiesId], dbData)
- }
- for key := range ConvertBTRechargeData {
- sort.Slice(ConvertBTRechargeData[key], func(i, j int) bool {
- return ConvertBTRechargeData[key][i].Day < ConvertBTRechargeData[key][j].Day
- })
- }
- //RO币累计奖励
- for _, cfgData := range serverproto.ActivitiesBtChargeTaskRoMoneyCfgLoader {
- dbDataDaily := &StActBTRecharge{
- Day: cfgData.Day,
- Id: cfgData.Id,
- RefreshDay: BTTaskRefreshType_Week,
- }
- for idx := 0; idx < len(cfgData.DailyTaskIds); idx++ {
- taskId, _ := Str2Num(cfgData.DailyTaskIds[idx])
- if taskId > 0 {
- dbDataDaily.TaskList = append(dbDataDaily.TaskList, int32(taskId))
- }
- }
- ConvertBTRechargeRoCoinDailyData[cfgData.ActivitiesId] = append(ConvertBTRechargeRoCoinDailyData[cfgData.ActivitiesId], dbDataDaily)
- dbDataWeek := &StActBTRecharge{
- Day: cfgData.Day,
- Id: cfgData.Id,
- RefreshDay: BTTaskRefreshType_Week,
- }
- for idx := 0; idx < len(cfgData.TaskIds); idx++ {
- taskId, _ := Str2Num(cfgData.TaskIds[idx])
- if taskId > 0 {
- dbDataWeek.TaskList = append(dbDataWeek.TaskList, int32(taskId))
- }
- }
- ConvertBTRechargeRoCoinWeekData[cfgData.ActivitiesId] = append(ConvertBTRechargeRoCoinWeekData[cfgData.ActivitiesId], dbDataWeek)
- }
- for key := range ConvertBTRechargeRoCoinDailyData {
- sort.Slice(ConvertBTRechargeRoCoinDailyData[key], func(i, j int) bool {
- return ConvertBTRechargeRoCoinDailyData[key][i].Day < ConvertBTRechargeRoCoinDailyData[key][j].Day
- })
- }
- for key := range ConvertBTRechargeRoCoinWeekData {
- sort.Slice(ConvertBTRechargeRoCoinWeekData[key], func(i, j int) bool {
- return ConvertBTRechargeRoCoinWeekData[key][i].Day < ConvertBTRechargeRoCoinWeekData[key][j].Day
- })
- }
- }
- // RO币累计充值对应天数的数据列表
- func GetActBTROCoinRechargeDayDataList(activityId int32, day int32, dayType BTRoCoinType) (taskList []int32) {
- if dayType == BTTaskRefreshType_Day {
- cfgData, ok := ConvertBTRechargeRoCoinDailyData[activityId]
- if !ok {
- return
- }
- for idx := 0; idx < len(cfgData); idx++ {
- if cfgData[idx].Day > day {
- break
- }
- taskList = cfgData[idx].TaskList
- }
- } else {
- cfgData, ok := ConvertBTRechargeRoCoinWeekData[activityId]
- if !ok {
- return
- }
- for idx := 0; idx < len(cfgData); idx++ {
- if cfgData[idx].Day > day {
- break
- }
- taskList = cfgData[idx].TaskList
- }
- }
- return
- }
- // 每日累计充值
- func GetActBTRechargeDayDataList(activityId int32, day int32) (taskList []int32) {
- cfgData, ok := ConvertBTRechargeData[activityId]
- if !ok {
- return
- }
- for idx := 0; idx < len(cfgData); idx++ {
- if cfgData[idx].Day > day {
- break
- }
- taskList = cfgData[idx].TaskList
- }
- return
- }
- // 超值首充 & 百元大礼包
- type BTRechargeRewardData struct {
- Reward []*serverproto.KeyValueType
- RewardCondition int32
- }
- type ConvertBTFirstRechargeData struct {
- Name string
- OpenConditionList []*serverproto.KeyValueType
- OpenConditionStrList []string
- RechargeAmount float32 //达到该金额解锁首充奖励获取
- RewardList []BTRechargeRewardData
- }
- var ConvertBTFirstRecharge *ConvertBTFirstRechargeData = nil
- var ConvertBTRecharge100 *ConvertBTFirstRechargeData = nil
- func convertBTFirstAnd100RechargeCfg() {
- //超值首充
- if cfgData, ok := serverproto.ActivitiesBtFirstChargeCfgLoader[1]; ok {
- ConvertBTFirstRecharge = &ConvertBTFirstRechargeData{
- OpenConditionStrList: cfgData.OpenCondition,
- }
- ConvertBTFirstRecharge.OpenConditionList = Str2ResSliceList(cfgData.OpenCondition)
- //ConvertBTFirstRecharge.RechargeAmount = cfgData.RechargeAmount
- if len(cfgData.RechargeAmount) < 3 {
- return
- }
- value1, _ := Str2Num(cfgData.RechargeAmount[0])
- ConvertBTFirstRecharge.RewardList = append(ConvertBTFirstRecharge.RewardList, BTRechargeRewardData{
- RewardCondition: int32(value1),
- Reward: Str2ResSliceList(cfgData.Reward1),
- })
- value2, _ := Str2Num(cfgData.RechargeAmount[1])
- ConvertBTFirstRecharge.RewardList = append(ConvertBTFirstRecharge.RewardList, BTRechargeRewardData{
- RewardCondition: int32(value2),
- Reward: Str2ResSliceList(cfgData.Reward2),
- })
- value3, _ := Str2Num(cfgData.RechargeAmount[2])
- ConvertBTFirstRecharge.RewardList = append(ConvertBTFirstRecharge.RewardList, BTRechargeRewardData{
- RewardCondition: int32(value3),
- Reward: Str2ResSliceList(cfgData.Reward3),
- })
- }
- //百元大礼包
- if cfgData, ok := serverproto.ActivitiesBtFirstChargeCfgLoader[2]; ok {
- ConvertBTRecharge100 = &ConvertBTFirstRechargeData{
- OpenConditionStrList: cfgData.OpenCondition,
- Name: cfgData.Name,
- }
- ConvertBTRecharge100.OpenConditionList = Str2ResSliceList(cfgData.OpenCondition)
- if len(cfgData.RechargeAmount) < 0 {
- return
- }
- value0, _ := Str2Num(cfgData.RechargeAmount[0])
- ConvertBTRecharge100.RechargeAmount = float32(value0)
- ConvertBTRecharge100.RewardList = append(ConvertBTRecharge100.RewardList, BTRechargeRewardData{
- Reward: Str2ResSliceList(cfgData.Reward1),
- })
- ConvertBTRecharge100.RewardList = append(ConvertBTRecharge100.RewardList, BTRechargeRewardData{
- Reward: Str2ResSliceList(cfgData.Reward2),
- })
- ConvertBTRecharge100.RewardList = append(ConvertBTRecharge100.RewardList, BTRechargeRewardData{
- Reward: Str2ResSliceList(cfgData.Reward3),
- })
- }
- }
|