base_config.go 241 KB

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