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