base_config.go 244 KB

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