base_config.go 246 KB

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