| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543 |
- package model
- import (
- "rocommon/service"
- "rocommon/util"
- "roserver/baseserver/model"
- "roserver/serverproto"
- "strconv"
- "time"
- "unsafe"
- )
- const (
- Rune_Shop_Type_MonthCard = 1 //月卡商店
- Rune_Shop_Type_Bag = 2 //礼包商店
- Rune_Shop_Type_TimeLimit = 3 //限时商店
- Rune_Shop_Type_RushTower = 4 //爬塔冲榜商店
- Rune_Shop_Type_RushArena = 5 //英灵殿冲榜商店
- Rune_Shop_Type_RushMap = 6 //推图冲榜商店
- Rune_Shop_Type_GuildBattle = 8 //公会战商店
- Rune_Shop_Type_RushPet = 9 //宠物冲榜商店
- Rune_Shop_Type_RushSkill = 10 //技能冲榜商店
- Rune_Shop_Type_Idol = 11 //偶像季商店
- Rune_Shop_Type_CreditRecharge = 100 // 充值钱包商店
- )
- const (
- Rune_BagShop_Type_Day = 1
- Rune_BagShop_Type_Week = 2
- Rune_BagShop_Type_Month = 3
- Rune_BagShop_Type_Gold = 4
- Rune_BagShop_Type_CreditRecharge = 5 // 充值钱包类型
- Rune_BagShop_Type_ROCoin = 6 // RO币礼包类型
- )
- type RoleRune struct {
- SaveObject
- runeGiftShop map[int32]*serverproto.RuneShop
- runeLimitShop *serverproto.RuneShop
- runeMonthCardShop *serverproto.RuneShop
- runeRushTowerShop *serverproto.RuneShop
- runeRushArenaShop *serverproto.RuneShop
- runeRushMapShop *serverproto.RuneShop
- runeGuildBattleShop *serverproto.RuneShop
- runeRushPetShop *serverproto.RuneShop
- runeRushSkillShop *serverproto.RuneShop
- runeIdolSeasonShop *serverproto.RuneShop
- runeCreditRecharge map[int32]*serverproto.RuneShop // 充值钱包商店
- runeBase *serverproto.RuneBaseData
- runeExplore *StRuneExplore
- saveShopLists map[int32]bool //卢恩商店变化
- tickTime uint64
- }
- type StRuneExplore struct {
- serverproto.RuneExplore
- }
- func (this *StRuneExplore) init(data *serverproto.RuneExplore) {
- if data == nil {
- return
- }
- if !RuneShopMag.IsOpen() || data.AlreadyRune != RuneShopMag.GetCurRound() {
- this.resetData()
- } else {
- this.RuneExplore = *data
- }
- }
- func (this *StRuneExplore) resetData() {
- util.InfoF("resetdata rune Explore, %v, %v, %v", RuneShopMag.IsOpen(), RuneShopMag.GetCurRound(), this.AlreadyRune)
- this.CurLvl = 1
- this.TotalExp = 0
- this.MissionExp = 0
- this.BUnlock = false
- this.FullMaxAward = false
- this.State = this.State[0:0]
- this.AlreadyRune = 0
- }
- func (this StRuneExplore) GetTotalExp() int32 {
- return this.TotalExp
- }
- func (this StRuneExplore) GetMissionExp() int32 {
- return this.MissionExp
- }
- func (this StRuneExplore) ConvertMsg(msg *serverproto.SCExploreInfoAck) {
- if msg == nil {
- return
- }
- msg.Level = this.CurLvl
- msg.TotalExp = this.GetTotalExp()
- msg.EndTime = RuneShopMag.GetEndTime()
- msg.MissionExp = this.MissionExp
- msg.CurRoune = RuneShopMag.GetCurRound()
- msg.BUnlock = this.BUnlock
- msg.DrawRewar = this.State
- msg.FullAward = this.FullMaxAward
- msg.StartTime = RuneShopMag.GetStartTime()
- msg.NextStartTime = RuneShopMag.GetNextStartTime()
- }
- //func (this *StRuneExplore) reset() {
- // this.CurLvl = 1
- // this.TotalExp = 0
- // this.MissionExp = 0
- // this.BUnlock = false
- // this.FullMaxAward = false
- // this.State = this.State[0:0]
- //}
- func (this *StRuneExplore) AddGoldExp(value int32) {
- db := RuneShopMag.GetCurDb()
- if db == nil {
- return
- }
- this.TotalExp += value * db.GoldScale()
- this.RuneUpLvl()
- }
- func (this *StRuneExplore) AddMissionExp(value int32) {
- db := RuneShopMag.GetCurDb()
- if db == nil {
- return
- }
- scale := db.MissionScale()
- if this.BUnlock {
- scale = db.MissionUp()
- }
- this.MissionExp += value * scale
- this.TotalExp += value * scale
- this.RuneUpLvl()
- }
- func (this *StRuneExplore) RuneUpLvl() {
- if !RuneShopMag.IsOpen() {
- return
- }
- db := RuneShopMag.GetCurDb()
- if db == nil {
- return
- }
- max, ok := model.DbRuneShopExploreMax[db.GetRound()]
- if !ok {
- return
- }
- if this.CurLvl >= max.MaxLvl {
- return
- }
- var totalExp int32 = 0
- var levle int32 = 1
- for {
- rewardDb, ok1 := model.DbRuneShopExploreReward[db.GetRound()<<16|levle+1]
- if !ok1 {
- break
- }
- totalExp += rewardDb.Exp()
- if totalExp > this.GetTotalExp() {
- break
- }
- levle++
- }
- this.CurLvl = levle
- this.AlreadyRune = db.GetRound()
- }
- func (this *RoleRune) OnRuneReward(lvl int32, awardtype int32) *serverproto.SCExploreRewardAck {
- ackMsg := &serverproto.SCExploreRewardAck{}
- ackMsg.Level = lvl
- ackMsg.Type = awardtype
- if !RuneShopMag.IsOpen() {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_RUNE_NO_OPEN)
- return ackMsg
- }
- if this.runeExplore.CurLvl < lvl {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_RUNE_LEVLEL_NOT)
- return ackMsg
- }
- db := RuneShopMag.GetCurDb()
- if db == nil {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_RUNE_DATA_ERROR)
- return ackMsg
- }
- rewardDb, ok := model.DbRuneShopExploreReward[db.GetRound()<<16|lvl]
- if !ok {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_RUNE_DATA_ERROR)
- return ackMsg
- }
- index, offset := this.runeExplore.GetStateOffset(lvl)
- var awardItems map[int32]int32 = nil
- var stateValue *int32 = nil
- if awardtype == 1 {
- stateValue = &this.runeExplore.State[index].Key
- awardItems = rewardDb.GetAward()
- } else {
- stateValue = &this.runeExplore.State[index].Value
- awardItems = rewardDb.GetCashAward()
- if !this.runeExplore.BUnlock {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_RUNE_NO_ULOCK)
- return ackMsg
- }
- }
- if awardItems == nil || stateValue == nil {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_RUNE_DATA_ERROR)
- return ackMsg
- }
- if this.runeExplore.GetAwardState(*stateValue, offset) {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_RUNE_AWARD_GET)
- return ackMsg
- }
- if err := this.role.CanAddItemList(awardItems); err != serverproto.ErrorCode_ERROR_OK {
- ackMsg.Error = int32(err)
- return ackMsg
- }
- this.role.AddItemList(awardItems, AddFrom_Rune, true)
- this.runeExplore.SetAwardState(stateValue, offset)
- for k, v := range awardItems {
- ackMsg.AwardItem = append(ackMsg.AwardItem, &serverproto.KeyValueType{Key: k, Value: v})
- }
- this.runeExplore.AlreadyRune = db.GetRound()
- this.SetDirty(true)
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_OK)
- ackMsg.DrawRewar = this.runeExplore.GetState()
- return ackMsg
- }
- // 获得等级对应 状态下标以及偏移
- func (this *StRuneExplore) GetStateOffset(lvl int32) (int32, uint) {
- if len(this.State) <= 0 {
- this.State = append(this.State, &serverproto.KeyValueType{})
- }
- size := unsafe.Sizeof(this.State[0].Key) * 8
- index := lvl / int32(size)
- cnt := index
- if int(lvl%int32(size)) > 0 {
- cnt += 1
- }
- if len(this.State) < int(cnt) {
- for i := 0; i < int(cnt)-len(this.State); i++ {
- this.State = append(this.State, &serverproto.KeyValueType{})
- }
- }
- return index, uint(lvl - index*int32(size) - 1)
- }
- func (this StRuneExplore) GetAwardState(value int32, offset uint) bool {
- return uint(value)&(uint(1)<<uint(offset)) != 0
- }
- func (this *StRuneExplore) SetAwardState(value *int32, offset uint) {
- if value == nil {
- return
- }
- *value |= (1 << uint(offset))
- }
- func (this *StRuneExplore) GetAllAward(roune int32) map[int32]int32 {
- retMap := make(map[int32]int32)
- for lvl := int32(1); lvl <= this.CurLvl; lvl++ {
- index, offset := this.GetStateOffset(lvl)
- rewardDb, ok := model.DbRuneShopExploreReward[roune<<16|lvl]
- if !ok {
- continue
- }
- if int(index) >= len(this.State) {
- continue
- }
- var stateKey = &this.State[index].Key
- if !this.GetAwardState(*stateKey, offset) {
- for k, v := range rewardDb.GetAward() {
- retMap[k] += v
- }
- }
- var stateValue = &this.State[index].Value
- if this.BUnlock && !this.GetAwardState(*stateValue, offset) {
- for k, v := range rewardDb.GetCashAward() {
- retMap[k] += v
- }
- }
- }
- dbMax, ok := model.DbRuneShopExploreMax[roune]
- dbExplore := model.GetRuneExploreDataByRound(roune)
- if ok && dbExplore != nil && this.CurLvl >= dbMax.MaxLvl {
- diffExp := this.GetTotalExp() - dbMax.MaxExp
- multiple := diffExp / dbExplore.ExpCost()
- if multiple > 0 {
- for k, v := range dbExplore.MaxAward() {
- retMap[k] += v * multiple
- }
- }
- }
- return retMap
- }
- // 解锁高级奖励
- func (this *RoleRune) RuneUnlock() {
- //if payRewardInfo.GoodsType != int32(serverproto.PayGoodsType_EPayType_RuneExplore) {
- // return
- //}
- if this.runeExplore.BUnlock {
- return
- }
- db := RuneShopMag.GetCurDb()
- if db == nil {
- return
- }
- this.AddMissionExp(this.runeExplore.GetMissionExp() * (db.MissionUp() - db.MissionScale()) / 100)
- this.runeExplore.BUnlock = true
- msg := &serverproto.SCExploreInfoAck{}
- this.runeExplore.ConvertMsg(msg)
- this.role.ReplayGate(msg, true)
- this.SetDirty(true)
- }
- // 满级奖励
- func (this *RoleRune) MaxLvlAward() *serverproto.SCExploreExtraRewardAck {
- runeE := this.runeExplore
- ret := &serverproto.SCExploreExtraRewardAck{}
- if !RuneShopMag.IsOpen() {
- ret.Error = int32(serverproto.ErrorCode_ERROR_OK)
- return ret
- }
- db := RuneShopMag.GetCurDb()
- if db == nil {
- ret.Error = int32(serverproto.ErrorCode_ERROR_RUNE_DATA_ERROR)
- return ret
- }
- dbMax, ok := model.DbRuneShopExploreMax[db.GetRound()]
- if !ok {
- ret.Error = int32(serverproto.ErrorCode_ERROR_RUNE_DATA_ERROR)
- return ret
- }
- if runeE.CurLvl < dbMax.MaxLvl {
- ret.Error = int32(serverproto.ErrorCode_ERROR_RUNE_LEVLEL_NOT)
- return ret
- }
- dbExplore := model.GetRuneExploreDataByRound(db.GetRound())
- if dbExplore == nil {
- ret.Error = int32(serverproto.ErrorCode_ERROR_RUNE_DATA_ERROR)
- return ret
- }
- if runeE.GetTotalExp() < dbMax.MaxExp+dbExplore.ExpCost() {
- ret.Error = int32(serverproto.ErrorCode_ERROR_FAIL)
- return ret
- }
- if err := this.role.CanAddItemList(dbExplore.MaxAward()); err != serverproto.ErrorCode_ERROR_OK {
- ret.Error = int32(err)
- return ret
- }
- runeE.FullMaxAward = true
- diffExp := runeE.GetTotalExp() - dbMax.MaxExp
- multiple := diffExp / dbExplore.ExpCost()
- var items = make(map[int32]int32)
- for k, v := range dbExplore.MaxAward() {
- items[k] = v * multiple
- }
- this.role.AddItemList(items, AddFrom_Rune, true)
- runeE.TotalExp -= dbExplore.ExpCost() * multiple
- for k, v := range items {
- ret.AwardItem = append(ret.AwardItem, &serverproto.KeyValueType{Key: k, Value: v})
- }
- this.SetDirty(true)
- ret.TotalExp = runeE.GetTotalExp()
- ret.MissionExp = runeE.GetMissionExp()
- ret.Error = int32(serverproto.ErrorCode_ERROR_OK)
- return ret
- }
- func (this *RoleRune) AddGoldExp(value int32) {
- if !RuneShopMag.IsOpen() {
- return
- }
- this.runeExplore.AddGoldExp(value)
- this.SetDirty(true)
- this.SendExpChange()
- }
- func (this *RoleRune) AddMissionExp(value int32) {
- if !RuneShopMag.IsOpen() {
- return
- }
- this.runeExplore.AddMissionExp(value)
- this.SetDirty(true)
- this.SendExpChange()
- }
- func (this RoleRune) SendExpChange() {
- msg := &serverproto.SCExploreExpChangeNtf{}
- msg.TotalExp = this.runeExplore.GetTotalExp()
- msg.MissionExp = this.runeExplore.GetMissionExp()
- msg.Level = this.runeExplore.GetCurLvl()
- this.role.ReplayGate(msg, true)
- }
- func newRoleRune(r *Role) *RoleRune {
- roleRune := &RoleRune{
- SaveObject: SaveObject{
- role: r,
- },
- }
- roleRune.runeGiftShop = make(map[int32]*serverproto.RuneShop)
- roleRune.runeLimitShop = &serverproto.RuneShop{}
- roleRune.runeMonthCardShop = &serverproto.RuneShop{}
- roleRune.runeRushTowerShop = &serverproto.RuneShop{}
- roleRune.runeRushArenaShop = &serverproto.RuneShop{}
- roleRune.runeRushMapShop = &serverproto.RuneShop{}
- roleRune.runeGuildBattleShop = &serverproto.RuneShop{}
- roleRune.runeRushPetShop = &serverproto.RuneShop{}
- roleRune.runeRushSkillShop = &serverproto.RuneShop{}
- roleRune.runeIdolSeasonShop = &serverproto.RuneShop{}
- roleRune.saveShopLists = make(map[int32]bool)
- roleRune.runeBase = &serverproto.RuneBaseData{}
- roleRune.runeExplore = &StRuneExplore{}
- roleRune.runeExplore.resetData()
- return roleRune
- }
- func (this *RoleRune) Load(msg interface{}) bool {
- proRole := msg.(*serverproto.Role)
- if proRole == nil {
- return false
- }
- if proRole.RoleRune != nil {
- this.runeBase = proRole.RoleRune.RuneBase
- if this.runeBase == nil {
- this.runeBase = &serverproto.RuneBaseData{
- PrivilegeData: &serverproto.RuneSpecialPrivilegeData{},
- }
- }
- // 充值钱包没有达到上限时处理
- // 特权卡商店初始化
- this.loadCreditRecharge()
- util.InfoF("proRole.RoleRune.ShopList :%v", proRole.RoleRune.ShopList)
- for _, data := range proRole.RoleRune.ShopList {
- if data.ShopId == Rune_Shop_Type_MonthCard {
- this.runeMonthCardShop = data
- } else if data.ShopId == Rune_Shop_Type_Bag {
- this.runeGiftShop[data.SubShopId] = data
- } else if data.ShopId == Rune_Shop_Type_TimeLimit {
- this.runeLimitShop = data
- } else if data.ShopId == Rune_Shop_Type_RushTower {
- this.runeRushTowerShop = data
- } else if data.ShopId == Rune_Shop_Type_RushArena {
- this.runeRushArenaShop = data
- } else if data.ShopId == Rune_Shop_Type_RushMap {
- this.runeRushMapShop = data
- } else if data.SubShopId == Rune_Shop_Type_GuildBattle {
- this.runeGuildBattleShop = data
- } else if data.ShopId == Rune_Shop_Type_RushPet {
- this.runeRushPetShop = data
- } else if data.ShopId == Rune_Shop_Type_RushSkill {
- this.runeRushSkillShop = data
- } else if data.ShopId == Rune_Shop_Type_Idol {
- this.runeIdolSeasonShop = data
- util.InfoF("this.runeIdolSeasonShop: %v", this.runeIdolSeasonShop)
- } else if data.ShopId == Rune_Shop_Type_CreditRecharge {
- this.runeCreditRecharge[data.SubShopId] = data
- }
- }
- if len(proRole.RoleRune.ShopList) <= 0 {
- this.InitGiftShop()
- this.InitLimitShop()
- this.InitMonthCardShop()
- this.InitRushTowerShop()
- this.InitRushArenaShop()
- this.InitRushMapShop()
- this.InitGuildBattleShop()
- this.InitRushPetShop()
- this.InitRushSkillShop()
- this.InitIdolSeasonShop()
- this.initCreditRechargeShop()
- this.initSpecialShop()
- } else {
- this.CheckNewGoodsAdd()
- }
- if !RuneShopMag.IsValid() {
- util.ErrorF("RuneShopMag init not finish")
- return false
- }
- //if proRole.RoleRune.RuneExplore != nil {
- this.runeExplore.init(proRole.RoleRune.RuneExplore)
- //}
- }
- this.tickTime = util.GetCurrentTime()
- util.InfoF("[Rune] InitGiftShop:%v", this.runeGiftShop)
- return true
- }
- func (this *RoleRune) loadCreditRecharge() {
- this.runeCreditRecharge = map[int32]*serverproto.RuneShop{}
- // 充值钱包没有达到上限时处理
- if !this.runeBase.CreditRechargeLimit {
- if this.runeBase.MaxCreditRecharge <= 0 {
- this.runeBase.MaxCreditRecharge = model.GlobalCreditRechargeInitMax
- this.SetDirty(true)
- }
- }
- // 特权卡商店初始化
- if this.runeBase.PrivilegeData == nil {
- this.runeBase.PrivilegeData = &serverproto.RuneSpecialPrivilegeData{}
- }
- }
- func (this *RoleRune) Save() {
- this.SetDirty(false)
- util.DebugF("uid=%v RoleRune save... %v", this.role.GetUUid(), this.runeExplore)
- saveMsg := &serverproto.SSRuneDataSaveReq{
- RoleRune: &serverproto.RoleRune{},
- }
- for key, value := range this.saveShopLists {
- if value == true {
- if key == Rune_Shop_Type_MonthCard {
- saveMsg.RoleRune.ShopList = append(saveMsg.RoleRune.ShopList, this.runeMonthCardShop)
- } else if key == Rune_Shop_Type_Bag {
- for _, shop := range this.runeGiftShop {
- saveMsg.RoleRune.ShopList = append(saveMsg.RoleRune.ShopList, shop)
- }
- } else if key == Rune_Shop_Type_TimeLimit {
- saveMsg.RoleRune.ShopList = append(saveMsg.RoleRune.ShopList, this.runeLimitShop)
- } else if key == Rune_Shop_Type_RushTower {
- saveMsg.RoleRune.ShopList = append(saveMsg.RoleRune.ShopList, this.runeRushTowerShop)
- } else if key == Rune_Shop_Type_RushArena {
- saveMsg.RoleRune.ShopList = append(saveMsg.RoleRune.ShopList, this.runeRushArenaShop)
- } else if key == Rune_Shop_Type_RushMap {
- saveMsg.RoleRune.ShopList = append(saveMsg.RoleRune.ShopList, this.runeRushMapShop)
- } else if key == Rune_Shop_Type_RushPet {
- saveMsg.RoleRune.ShopList = append(saveMsg.RoleRune.ShopList, this.runeRushPetShop)
- } else if key == Rune_Shop_Type_RushSkill {
- saveMsg.RoleRune.ShopList = append(saveMsg.RoleRune.ShopList, this.runeRushSkillShop)
- } else if key == Rune_Shop_Type_Idol {
- saveMsg.RoleRune.ShopList = append(saveMsg.RoleRune.ShopList, this.runeIdolSeasonShop)
- } else if key == Rune_Shop_Type_CreditRecharge {
- for _, shop := range this.runeCreditRecharge {
- saveMsg.RoleRune.ShopList = append(saveMsg.RoleRune.ShopList, shop)
- }
- }
- }
- delete(this.saveShopLists, key)
- }
- saveMsg.RoleRune.RuneExplore = &this.runeExplore.RuneExplore
- saveMsg.RoleRune.RuneBase = this.runeBase
- //if len(saveMsg.RoleRune.ShopList) > 0 {
- this.role.SendDb(saveMsg)
- //}
- }
- func (this *RoleRune) RuneExploreEndAward() {
- roleRune := this.runeExplore
- if roleRune.AlreadyRune <= 0 {
- return
- }
- if RuneShopMag.GetCurRound() == roleRune.AlreadyRune {
- return
- }
- mapAward := roleRune.GetAllAward(roleRune.AlreadyRune)
- if len(mapAward) > 0 {
- this.role.AddMail(model.GlobalMailRuneExplore, serverproto.MailType_MailType_Rune_Explore, mapAward, []int32{}, "", "")
- }
- util.InfoF("uid=%v RuneExploreEndAward over Award Reset", this.role.GetUUid())
- //roleRune.AlreadyRune = 0
- roleRune.resetData()
- this.SetDirty(true)
- }
- func (this *RoleRune) CopyData(rune *serverproto.RoleRune) {
- rune.ShopList = append(rune.ShopList, this.runeLimitShop)
- for _, data := range this.runeGiftShop {
- rune.ShopList = append(rune.ShopList, data)
- }
- }
- func (this *RoleRune) addShopChange(shopId int32) {
- this.saveShopLists[shopId] = true
- this.SetDirty(true)
- }
- // 上线是否有可领取的礼包
- func (this *RoleRune) HasFreeBag() bool {
- for _, data := range model.ConvertFreeBag {
- _, ok := this.runeGiftShop[data.BagType]
- if !ok {
- return false
- }
- for _, goods := range this.runeGiftShop[data.BagType].GoodsInfo {
- if goods.BuyNum < data.LimitCount {
- return true
- }
- }
- }
- return false
- }
- func (this *RoleRune) GetNextRefresh(bagType int32) uint64 {
- if bagType == Rune_BagShop_Type_Day ||
- bagType == Rune_BagShop_Type_CreditRecharge ||
- bagType == Rune_BagShop_Type_ROCoin {
- return util.GetLatest5Hour()
- } else if bagType == Rune_BagShop_Type_Week {
- return util.GetLatestWeek5Hour(0)
- } else if bagType == Rune_BagShop_Type_Month {
- return util.GetLatestMonth5Hour()
- }
- return 0
- }
- func (this *RoleRune) InitGiftShop() {
- //初始化礼包商店
- this.runeGiftShop = make(map[int32]*serverproto.RuneShop)
- for _, data := range model.ConvertGiftBag {
- _, ok := this.runeGiftShop[data.BagType]
- if !ok {
- shopData := &serverproto.RuneShop{
- ShopId: Rune_Shop_Type_Bag,
- SubShopId: data.BagType,
- NextRefresh: int64(this.GetNextRefresh(data.BagType)),
- }
- this.runeGiftShop[data.BagType] = shopData
- }
- goods := &serverproto.RuneGoods{
- GoodsId: data.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeGiftShop[data.BagType].GoodsInfo = append(this.runeGiftShop[data.BagType].GoodsInfo, goods)
- }
- this.addShopChange(Rune_Shop_Type_Bag)
- }
- // 初次加载或者大版本重置。
- func (this *RoleRune) InitLimitShop() {
- //初始化限时商店
- this.runeLimitShop = &serverproto.RuneShop{
- ShopId: Rune_Shop_Type_TimeLimit,
- SubShopId: 0,
- NextRefresh: 0,
- }
- for _, data := range model.ConvertLimitGag {
- goods := &serverproto.RuneGoods{
- GoodsId: data.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeLimitShop.GoodsInfo = append(this.runeLimitShop.GoodsInfo, goods)
- }
- this.addShopChange(Rune_Shop_Type_TimeLimit)
- }
- const restTime = 1000
- func (this *RoleRune) Update(ms uint64) {
- if this.tickTime == 0 {
- return
- }
- if this.tickTime+restTime > ms {
- return
- }
- this.tickTime += ms
- bChange := false
- if this.runeBase.MonthCardModify == false {
- this.CheckMonthCardLeftTime()
- bChange = true
- } else {
- for _, data := range this.runeMonthCardShop.GoodsInfo {
- if data.NextRewardTime >= data.EndTime && data.EndTime < int64(ms) && data.EndTime > 0 {
- data.EndTime = 0
- bChange = true
- }
- }
- }
- if bChange {
- this.addShopChange(Rune_Shop_Type_MonthCard)
- }
- }
- func (this *RoleRune) CheckMonthCardLeftTime() {
- nowTime := util.GetCurrentTime()
- for _, data := range this.runeMonthCardShop.GoodsInfo {
- if data.EndTime == 0 {
- continue
- }
- realEndTime := this.ModifyCardEndTime(data.EndTime)
- if realEndTime != 0 {
- data.EndTime = realEndTime
- }
- if data.NextRewardTime >= data.EndTime && data.EndTime < int64(nowTime) {
- data.EndTime = 0
- }
- }
- this.runeBase.MonthCardModify = true
- }
- // 初次加载或者大版本重置。
- func (this *RoleRune) InitMonthCardShop() {
- //初始化限时商店
- this.runeMonthCardShop = &serverproto.RuneShop{
- ShopId: Rune_Shop_Type_MonthCard,
- SubShopId: 0,
- NextRefresh: 0,
- }
- for _, data := range model.ConvertMonthCard {
- goods := &serverproto.RuneGoods{
- GoodsId: data.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeMonthCardShop.GoodsInfo = append(this.runeMonthCardShop.GoodsInfo, goods)
- }
- this.addShopChange(Rune_Shop_Type_MonthCard)
- }
- // 初次加载或者大版本重置。
- func (this *RoleRune) InitRushTowerShop() {
- //初始化限时商店
- this.runeRushTowerShop = &serverproto.RuneShop{
- ShopId: Rune_Shop_Type_RushTower,
- SubShopId: 0,
- NextRefresh: 0,
- }
- for _, data := range model.ConvertTowerShop {
- goods := &serverproto.RuneGoods{
- GoodsId: data.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeRushTowerShop.GoodsInfo = append(this.runeRushTowerShop.GoodsInfo, goods)
- }
- this.addShopChange(Rune_Shop_Type_RushTower)
- }
- // 初次加载或者大版本重置。
- func (this *RoleRune) InitRushArenaShop() {
- //初始化限时商店
- this.runeRushArenaShop = &serverproto.RuneShop{
- ShopId: Rune_Shop_Type_RushArena,
- SubShopId: 0,
- NextRefresh: 0,
- }
- for _, data := range model.ConvertArenaShop {
- goods := &serverproto.RuneGoods{
- GoodsId: data.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeRushArenaShop.GoodsInfo = append(this.runeRushArenaShop.GoodsInfo, goods)
- }
- this.addShopChange(Rune_Shop_Type_RushArena)
- }
- // 初次加载或者大版本重置。
- func (this *RoleRune) InitRushMapShop() {
- //初始化限时商店
- this.runeRushMapShop = &serverproto.RuneShop{
- ShopId: Rune_Shop_Type_RushMap,
- SubShopId: 0,
- NextRefresh: 0,
- }
- for _, data := range model.ConvertMapShop {
- goods := &serverproto.RuneGoods{
- GoodsId: data.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeRushMapShop.GoodsInfo = append(this.runeRushMapShop.GoodsInfo, goods)
- }
- this.addShopChange(Rune_Shop_Type_RushMap)
- }
- // 初次加载或者大版本重置。
- func (this *RoleRune) InitRushPetShop() {
- //初始化限时商店
- this.runeRushPetShop = &serverproto.RuneShop{
- ShopId: Rune_Shop_Type_RushPet,
- SubShopId: 0,
- NextRefresh: 0,
- }
- for _, data := range model.ConvertPetShop {
- goods := &serverproto.RuneGoods{
- GoodsId: data.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeRushPetShop.GoodsInfo = append(this.runeRushPetShop.GoodsInfo, goods)
- }
- this.addShopChange(Rune_Shop_Type_RushPet)
- }
- // 初次加载或者大版本重置。
- func (this *RoleRune) InitRushSkillShop() {
- //初始化限时商店
- this.runeRushSkillShop = &serverproto.RuneShop{
- ShopId: Rune_Shop_Type_RushSkill,
- SubShopId: 0,
- NextRefresh: 0,
- }
- for _, data := range model.ConvertSkillShop {
- goods := &serverproto.RuneGoods{
- GoodsId: data.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeRushSkillShop.GoodsInfo = append(this.runeRushSkillShop.GoodsInfo, goods)
- }
- this.addShopChange(Rune_Shop_Type_RushSkill)
- }
- // 初次加载或者大版本重置。
- func (this *RoleRune) InitIdolSeasonShop() {
- //初始化限时商店
- this.runeIdolSeasonShop = &serverproto.RuneShop{
- ShopId: Rune_Shop_Type_Idol,
- SubShopId: 0,
- NextRefresh: 0,
- }
- for _, data := range model.ConvertIdolShop {
- goods := &serverproto.RuneGoods{
- GoodsId: data.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeIdolSeasonShop.GoodsInfo = append(this.runeIdolSeasonShop.GoodsInfo, goods)
- }
- this.addShopChange(Rune_Shop_Type_Idol)
- }
- // 初次加载或者大版本重置。
- func (this *RoleRune) InitGuildBattleShop() {
- //初始化限时商店
- this.runeGuildBattleShop = &serverproto.RuneShop{
- ShopId: Rune_Shop_Type_GuildBattle,
- SubShopId: 0,
- NextRefresh: 0,
- }
- for _, data := range model.ConvertMapShop {
- goods := &serverproto.RuneGoods{
- GoodsId: data.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeGuildBattleShop.GoodsInfo = append(this.runeGuildBattleShop.GoodsInfo, goods)
- }
- this.addShopChange(Rune_Shop_Type_GuildBattle)
- }
- func (this *RoleRune) initCreditRechargeShop() {
- // 充值钱包商店
- // 初始化礼包商店
- //this.runeCreditRecharge = make(map[int32]*serverproto.RuneShop)
- for _, data := range model.ConvertPurseShop {
- _, ok := this.runeCreditRecharge[data.BagType] // Rune_BagShop_Type_CreditRecharge
- if !ok {
- shopData := &serverproto.RuneShop{
- ShopId: Rune_Shop_Type_CreditRecharge,
- SubShopId: data.BagType,
- NextRefresh: int64(this.GetNextRefresh(data.BagType)), // 日,周,月需要获取下次更新时间的goods
- }
- this.runeCreditRecharge[data.BagType] = shopData
- }
- goods := &serverproto.RuneGoods{
- GoodsId: data.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeCreditRecharge[data.BagType].GoodsInfo = append(this.runeCreditRecharge[data.BagType].GoodsInfo, goods)
- }
- this.addShopChange(Rune_Shop_Type_CreditRecharge)
- }
- func (this *RoleRune) initSpecialShop() {
- // 特权卡商店
- }
- func (this *RoleRune) DailyReset(notify bool) {
- this.ResetGiftShop()
- this.ResetLimitShop()
- this.ResetMonthCardShop()
- this.ResetRushTowerShop()
- this.ResetRushArenaShop()
- this.ResetRushMapShop()
- this.ResetGuildBattleShop()
- this.ResetRushSkillShop()
- // 充值钱包商店
- this.ResetCreditRechargeShop(notify)
- this.CheckNewGoodsAdd()
- if notify == true {
- this.GetFreeGoodsData()
- }
- //给奖励
- this.SendMonthCardMail()
- }
- func (this *RoleRune) ModifyCardEndTime(endTime int64) int64 {
- //获得结束天数的凌晨5点。
- loc := util.GetLoc()
- tmpTime := util.GetTimeByUint64(uint64(endTime))
- dayT1Str := tmpTime.Format(util.DATE_FORMAT1)
- dayT1, _ := time.ParseInLocation(util.DATE_FORMAT1, dayT1Str, loc)
- dayT1 = dayT1.Add(time.Hour * 5)
- dayT1Sec := dayT1.UnixNano() / 1e6
- if dayT1Sec != endTime {
- dayT1 = dayT1.AddDate(0, 0, int(1))
- dayT1Sec = dayT1.UnixNano() / 1e6
- return dayT1Sec
- }
- return 0
- }
- func (this *RoleRune) SendMonthCardMail() {
- if len(this.runeMonthCardShop.GoodsInfo) <= 0 {
- return
- }
- bChanged := false
- if this.runeBase.MonthCardModify == false {
- this.CheckMonthCardLeftTime()
- bChanged = true
- }
- nowTime := util.GetCurrentTime()
- for _, data := range this.runeMonthCardShop.GoodsInfo {
- shopItemCfg, ok := model.ConvertMonthCard[data.GoodsId]
- if !ok {
- continue
- }
- if data.EndTime == 0 || data.NextRewardTime == 0 || data.NextRewardTime > int64(nowTime) || len(shopItemCfg.MailReward) <= 0 {
- continue
- }
- reward := make(map[int32]int32)
- for _, item := range shopItemCfg.MailReward {
- reward[item.Key] = item.Value
- }
- if len(reward) <= 0 {
- continue
- }
- //循环 前次下线间隔天数的邮件奖励
- for data.NextRewardTime < data.EndTime {
- if data.NextRewardTime > int64(util.GetCurrentTime()) {
- break
- }
- leftDay := uint64(data.EndTime-data.NextRewardTime) / (24 * 3600 * 1000) //剩余天数
- this.role.GetRoleMail().AddMail(shopItemCfg.MailCfgId, serverproto.MailType_MailType_MonthCard,
- reward, []int32{int32(leftDay - 1)}, "", "")
- loc := util.GetLoc()
- tmpTime := util.GetTimeByUint64(uint64(data.NextRewardTime))
- dayT1Str := tmpTime.Format(util.DATE_FORMAT1)
- dayT1, _ := time.ParseInLocation(util.DATE_FORMAT1, dayT1Str, loc)
- //设定下次领奖时间
- dayT1 = dayT1.AddDate(0, 0, int(1))
- dayT1 = dayT1.Add(time.Hour * 5)
- data.NextRewardTime = dayT1.UnixNano() / 1e6 //下一次领奖时间
- bChanged = true
- if data.NextRewardTime >= data.EndTime {
- // data.EndTime = 0
- break
- }
- }
- if data.EndTime < int64(nowTime) {
- data.EndTime = 0
- }
- }
- if bChanged == true {
- this.addShopChange(Rune_BagShop_Type_Month)
- }
- }
- func (this *RoleRune) GetFreeGoodsData() {
- ntfMsg := &serverproto.SCRuneFreeRedChangeInfoNtf{}
- for _, goods := range model.ConvertFreeBag {
- _, ok := this.runeGiftShop[goods.BagType]
- if !ok {
- continue
- }
- for _, item := range this.runeGiftShop[goods.BagType].GoodsInfo {
- if item.GoodsId == goods.GoodsId {
- if goods.LimitCount >= 9999 {
- break
- }
- if item.BuyNum < goods.LimitCount {
- ntfMsg.RuneRed = append(ntfMsg.RuneRed, &serverproto.KeyValueType{
- Key: Rune_Shop_Type_Bag,
- Value: goods.BagType,
- })
- }
- break
- }
- }
- }
- curTime := int64(util.GetCurrentTime())
- for i := 0; i < len(this.runeLimitShop.GoodsInfo); i++ {
- shopItem, ok := model.ConvertLimitGag[this.runeLimitShop.GoodsInfo[i].GoodsId]
- if !ok {
- continue
- }
- //判定时间 if 绝对时间判定,else 开服时间判定
- if shopItem.LimitType == LimitType_Abs_Time {
- if curTime < shopItem.BeginTime ||
- shopItem.BeginTime == 0 || shopItem.EndTime == 0 ||
- shopItem.EndTime < curTime {
- continue
- }
- } else if shopItem.LimitType == LimitType_StartServer {
- bRet := this.CheckInShowTime(shopItem.StartDay, shopItem.EndDay, uint64(curTime))
- if bRet == Shop_Time_Not_Ready_To_Show || bRet == Shop_Time_Out_Of_Date {
- continue
- }
- } else {
- bRet, _ := this.role.roleCompetition.CheckInCompetitionSeason(shopItem.SeasonId)
- if bRet == Shop_Time_Not_Ready_To_Show || bRet == Shop_Time_Out_Of_Date {
- continue
- }
- }
- //如果该商品已经售罄,不推送红点道具
- if shopItem.LimitCount < 9999 {
- var buyNum int32 = shopItem.LimitCount - this.runeLimitShop.GoodsInfo[i].BuyNum
- if buyNum <= 0 {
- continue
- }
- }
- ntfMsg.LimitRed = append(ntfMsg.LimitRed, shopItem.GoodsId)
- }
- if len(ntfMsg.RuneRed) > 0 || len(ntfMsg.LimitRed) > 0 {
- this.role.ReplayGate(ntfMsg, true)
- }
- this.runeBaseDataChangeNtf()
- }
- func (this *RoleRune) CheckRushShopData() {
- for _, value := range model.ConvertPetShop {
- bFind := false
- for _, goods := range this.runeRushPetShop.GoodsInfo {
- if goods.GoodsId == value.GoodsId {
- bFind = true
- break
- }
- }
- if bFind == true {
- continue
- }
- runGoods := &serverproto.RuneGoods{
- GoodsId: value.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeRushPetShop.GoodsInfo = append(this.runeRushPetShop.GoodsInfo, runGoods)
- this.addShopChange(Rune_Shop_Type_RushPet)
- }
- }
- func (this *RoleRune) CheckNewGoodsAdd() {
- this.CheckRushShopData()
- //上线判定是否有新道具更新
- for _, value := range model.ConvertGiftBag {
- _, ok := this.runeGiftShop[value.BagType]
- if !ok {
- shopData := &serverproto.RuneShop{
- ShopId: Rune_Shop_Type_Bag,
- SubShopId: value.BagType,
- }
- shopData.NextRefresh = int64(this.GetNextRefresh(value.BagType))
- this.runeGiftShop[value.BagType] = shopData
- runGoods := &serverproto.RuneGoods{
- GoodsId: value.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeGiftShop[value.BagType].GoodsInfo = append(this.runeGiftShop[value.BagType].GoodsInfo, runGoods)
- this.addShopChange(Rune_Shop_Type_Bag)
- }
- bFind := false
- for _, goods := range this.runeGiftShop[value.BagType].GoodsInfo {
- if goods.GoodsId == value.GoodsId {
- bFind = true
- break
- }
- }
- if bFind == true {
- continue
- }
- runGoods := &serverproto.RuneGoods{
- GoodsId: value.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeGiftShop[value.BagType].GoodsInfo = append(this.runeGiftShop[value.BagType].GoodsInfo, runGoods)
- this.addShopChange(Rune_Shop_Type_Bag)
- }
- //限时商店
- for _, value := range model.ConvertLimitGag {
- bFind := false
- for _, goods := range this.runeLimitShop.GoodsInfo {
- if goods.GoodsId == value.GoodsId {
- bFind = true
- break
- }
- }
- if bFind == true {
- continue
- }
- runGoods := &serverproto.RuneGoods{
- GoodsId: value.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeLimitShop.GoodsInfo = append(this.runeLimitShop.GoodsInfo, runGoods)
- this.addShopChange(Rune_Shop_Type_TimeLimit)
- }
- for _, value := range model.ConvertMonthCard {
- bFind := false
- for _, goods := range this.runeMonthCardShop.GoodsInfo {
- if goods.GoodsId == value.GoodsId {
- bFind = true
- break
- }
- }
- if bFind == true {
- continue
- }
- runGoods := &serverproto.RuneGoods{
- GoodsId: value.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeMonthCardShop.GoodsInfo = append(this.runeMonthCardShop.GoodsInfo, runGoods)
- this.addShopChange(Rune_Shop_Type_MonthCard)
- }
- //检查三个冲榜表格是否有新物品加载
- //todo wangzhaocan 检查卢恩商店物品是否有新加
- for _, value := range model.ConvertGuildBattle {
- bFind := false
- for _, goods := range this.runeGuildBattleShop.GoodsInfo {
- if goods.GoodsId == value.GoodsId {
- bFind = true
- break
- }
- }
- if bFind == true {
- continue
- }
- runGoods := &serverproto.RuneGoods{
- GoodsId: value.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeGuildBattleShop.GoodsInfo = append(this.runeGuildBattleShop.GoodsInfo, runGoods)
- this.addShopChange(Rune_Shop_Type_GuildBattle)
- }
- for _, value := range model.ConvertSkillShop {
- bFind := false
- for _, goods := range this.runeRushSkillShop.GoodsInfo {
- if goods.GoodsId == value.GoodsId {
- bFind = true
- break
- }
- }
- if bFind == true {
- continue
- }
- runGoods := &serverproto.RuneGoods{
- GoodsId: value.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeRushSkillShop.GoodsInfo = append(this.runeRushSkillShop.GoodsInfo, runGoods)
- this.addShopChange(Rune_Shop_Type_RushSkill)
- }
- if this.runeIdolSeasonShop.ShopId == 0 {
- this.runeIdolSeasonShop.ShopId = Rune_Shop_Type_Idol
- this.addShopChange(Rune_Shop_Type_Idol)
- }
- for _, value := range model.ConvertIdolShop {
- bFind := false
- for _, goods := range this.runeIdolSeasonShop.GoodsInfo {
- if goods.GoodsId == value.GoodsId {
- bFind = true
- break
- }
- }
- if bFind == true {
- continue
- }
- runGoods := &serverproto.RuneGoods{
- GoodsId: value.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeIdolSeasonShop.GoodsInfo = append(this.runeIdolSeasonShop.GoodsInfo, runGoods)
- this.addShopChange(Rune_Shop_Type_Idol)
- }
- //充值钱包商店
- this.CheckNewGoodsCreditRecharge()
- // 该函数需要放在最后处理
- this.ResetGiftGoldShop()
- }
- func (this *RoleRune) CheckNewGoodsCreditRecharge() {
- for _, value := range model.ConvertPurseShop {
- _, ok := this.runeCreditRecharge[value.BagType]
- if !ok {
- shopData := &serverproto.RuneShop{
- ShopId: Rune_Shop_Type_CreditRecharge,
- SubShopId: value.BagType,
- }
- shopData.NextRefresh = int64(this.GetNextRefresh(value.BagType))
- this.runeCreditRecharge[value.BagType] = shopData
- runGoods := &serverproto.RuneGoods{
- GoodsId: value.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeCreditRecharge[value.BagType].GoodsInfo = append(this.runeCreditRecharge[value.BagType].GoodsInfo, runGoods)
- this.addShopChange(Rune_Shop_Type_CreditRecharge)
- }
- bFind := false
- for _, goods := range this.runeCreditRecharge[value.BagType].GoodsInfo {
- if goods.GoodsId == value.GoodsId {
- bFind = true
- break
- }
- }
- if bFind == true {
- continue
- }
- runGoods := &serverproto.RuneGoods{
- GoodsId: value.GoodsId,
- BuyNum: 0,
- HistoryBuy: 0,
- }
- this.runeCreditRecharge[value.BagType].GoodsInfo = append(this.runeCreditRecharge[value.BagType].GoodsInfo, runGoods)
- this.addShopChange(Rune_Shop_Type_CreditRecharge)
- }
- }
- func (this *RoleRune) ResetGiftGoldShop() {
- if this.runeBase == nil {
- this.runeBase = &serverproto.RuneBaseData{
- ResetVersion: 0,
- }
- }
- bNeedReset := false
- if this.runeBase.ResetVersion < model.GlobalRuneGiftGoldShopResetVersion {
- this.runeBase.ResetVersion = model.GlobalRuneGiftGoldShopResetVersion
- bNeedReset = true
- this.addShopChange(Rune_Shop_Type_Bag)
- } else {
- return
- }
- for _, data := range this.runeGiftShop {
- if bNeedReset && data.SubShopId == Rune_BagShop_Type_Gold {
- for _, good := range data.GoodsInfo {
- good.HistoryBuy = 0
- }
- break
- }
- }
- // 充值钱包也需要
- for _, data := range this.runeCreditRecharge {
- if bNeedReset && data.SubShopId == Rune_BagShop_Type_CreditRecharge {
- for _, good := range data.GoodsInfo {
- good.HistoryBuy = 0
- }
- break
- }
- }
- if bNeedReset == true {
- this.addShopChange(Rune_Shop_Type_Bag)
- // 充值钱包也需要
- this.addShopChange(Rune_BagShop_Type_CreditRecharge)
- }
- }
- func (this *RoleRune) ResetGiftShop() {
- for _, data := range this.runeGiftShop {
- needRefresh := false
- if data.NextRefresh < int64(util.GetCurrentTime()) {
- needRefresh = true
- }
- if needRefresh == false {
- continue
- }
- for i := 0; i < len(data.GoodsInfo); {
- _, ok := serverproto.RuneShopGiftsCfgLoader[data.GoodsInfo[i].GoodsId]
- if !ok {
- //配置表没找到,删除这个商品信息
- data.GoodsInfo = append(data.GoodsInfo[:i], data.GoodsInfo[i+1:]...)
- continue
- }
- //重置次数次数
- data.GoodsInfo[i].BuyNum = 0
- i++
- }
- data.NextRefresh = int64(this.GetNextRefresh(data.SubShopId))
- }
- this.addShopChange(Rune_Shop_Type_Bag)
- }
- func (this *RoleRune) ResetLimitShop() {
- if len(this.runeLimitShop.GoodsInfo) >= 0 {
- for i := 0; i < len(this.runeLimitShop.GoodsInfo); {
- _, ok := model.ConvertLimitGag[this.runeLimitShop.GoodsInfo[i].GoodsId] //serverproto.RuneShopGiftsCfgLoader[this.runeLimitShop.GoodsInfo[i].GoodsId]
- if !ok {
- //配置表没找到,删除这个商品信息
- this.runeLimitShop.GoodsInfo = append(this.runeLimitShop.GoodsInfo[:i], this.runeLimitShop.GoodsInfo[i+1:]...)
- continue
- }
- i++
- }
- }
- this.addShopChange(Rune_Shop_Type_TimeLimit)
- }
- func (this *RoleRune) ResetMonthCardShop() {
- if len(this.runeMonthCardShop.GoodsInfo) >= 0 {
- for i := 0; i < len(this.runeMonthCardShop.GoodsInfo); {
- _, ok := model.ConvertMonthCard[this.runeMonthCardShop.GoodsInfo[i].GoodsId]
- if !ok {
- //配置表没找到,删除这个商品信息
- this.runeMonthCardShop.GoodsInfo = append(this.runeMonthCardShop.GoodsInfo[:i], this.runeMonthCardShop.GoodsInfo[i+1:]...)
- continue
- }
- i++
- }
- }
- this.addShopChange(Rune_Shop_Type_MonthCard)
- }
- func (this *RoleRune) ResetRushTowerShop() {
- if len(this.runeRushTowerShop.GoodsInfo) >= 0 {
- for i := 0; i < len(this.runeRushTowerShop.GoodsInfo); {
- _, ok := model.ConvertTowerShop[this.runeRushTowerShop.GoodsInfo[i].GoodsId]
- if !ok {
- //配置表没找到,删除这个商品信息
- this.runeRushTowerShop.GoodsInfo = append(this.runeRushTowerShop.GoodsInfo[:i], this.runeRushTowerShop.GoodsInfo[i+1:]...)
- continue
- }
- i++
- }
- }
- this.addShopChange(Rune_Shop_Type_RushTower)
- }
- func (this *RoleRune) ResetRushArenaShop() {
- if len(this.runeRushArenaShop.GoodsInfo) >= 0 {
- for i := 0; i < len(this.runeRushArenaShop.GoodsInfo); {
- _, ok := model.ConvertArenaShop[this.runeRushArenaShop.GoodsInfo[i].GoodsId]
- if !ok {
- //配置表没找到,删除这个商品信息
- this.runeRushArenaShop.GoodsInfo = append(this.runeRushArenaShop.GoodsInfo[:i], this.runeRushArenaShop.GoodsInfo[i+1:]...)
- continue
- }
- i++
- }
- }
- this.addShopChange(Rune_Shop_Type_RushArena)
- }
- func (this *RoleRune) ResetRushMapShop() {
- if len(this.runeRushMapShop.GoodsInfo) >= 0 {
- for i := 0; i < len(this.runeRushMapShop.GoodsInfo); {
- _, ok := model.ConvertMapShop[this.runeRushMapShop.GoodsInfo[i].GoodsId]
- if !ok {
- //配置表没找到,删除这个商品信息
- this.runeRushMapShop.GoodsInfo = append(this.runeRushMapShop.GoodsInfo[:i], this.runeRushMapShop.GoodsInfo[i+1:]...)
- continue
- }
- i++
- }
- }
- this.addShopChange(Rune_Shop_Type_RushMap)
- }
- func (this *RoleRune) ResetRushSkillShop() {
- if len(this.runeRushSkillShop.GoodsInfo) >= 0 {
- for i := 0; i < len(this.runeRushSkillShop.GoodsInfo); {
- _, ok := model.ConvertSkillShop[this.runeRushSkillShop.GoodsInfo[i].GoodsId]
- if !ok {
- //配置表没找到,删除这个商品信息
- this.runeRushSkillShop.GoodsInfo = append(this.runeRushSkillShop.GoodsInfo[:i], this.runeRushSkillShop.GoodsInfo[i+1:]...)
- continue
- }
- i++
- }
- }
- this.addShopChange(Rune_Shop_Type_RushSkill)
- }
- func (this *RoleRune) ResetRushPetShop() {
- if len(this.runeRushPetShop.GoodsInfo) >= 0 {
- for i := 0; i < len(this.runeRushPetShop.GoodsInfo); {
- _, ok := model.ConvertPetShop[this.runeRushPetShop.GoodsInfo[i].GoodsId]
- if !ok {
- //配置表没找到,删除这个商品信息
- this.runeRushPetShop.GoodsInfo = append(this.runeRushPetShop.GoodsInfo[:i], this.runeRushPetShop.GoodsInfo[i+1:]...)
- continue
- }
- i++
- }
- }
- this.addShopChange(Rune_Shop_Type_RushPet)
- }
- func (this *RoleRune) ResetGuildBattleShop() {
- if len(this.runeGuildBattleShop.GoodsInfo) >= 0 {
- for i := 0; i < len(this.runeGuildBattleShop.GoodsInfo); {
- _, ok := model.ConvertGuildBattle[this.runeGuildBattleShop.GoodsInfo[i].GoodsId]
- if !ok {
- //配置表没找到,删除这个商品信息
- this.runeGuildBattleShop.GoodsInfo = append(this.runeGuildBattleShop.GoodsInfo[:i], this.runeGuildBattleShop.GoodsInfo[i+1:]...)
- continue
- }
- i++
- }
- }
- this.addShopChange(Rune_Shop_Type_GuildBattle)
- }
- func (this *RoleRune) ResetCreditRechargeShop(notify bool) {
- for _, data := range this.runeCreditRecharge {
- needRefresh := false
- if data.NextRefresh < int64(util.GetCurrentTime()) {
- needRefresh = true
- }
- if needRefresh == false {
- continue
- }
- for i := 0; i < len(data.GoodsInfo); {
- _, ok := serverproto.PurseShopCfgLoader[data.GoodsInfo[i].GoodsId]
- if !ok {
- //配置表没找到,删除这个商品信息
- data.GoodsInfo = append(data.GoodsInfo[:i], data.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_CreditRecharge)
- continue
- }
- //重置次数次数
- data.GoodsInfo[i].BuyNum = 0
- i++
- }
- data.NextRefresh = int64(this.GetNextRefresh(data.SubShopId))
- this.addShopChange(Rune_Shop_Type_CreditRecharge)
- }
- // 充值钱包对应的资源数据重置
- this.role.GetRoleBase().ResetCommonRes(int32(serverproto.ResType_Res_CreditRecharge), notify)
- // 充值钱包使用额度重置
- this.runeBase.UsedCreditRecharge = 0
- // 特权卡商店每日领取奖励重置
- if this.runeBase.PrivilegeData.ProcessTime > 0 { //说明已经购买
- nowTime := util.GetTimeMilliseconds()
- diffDay := util.GetDurationDay2(this.runeBase.PrivilegeData.ProcessTime, nowTime) - 1
- if this.runeBase.PrivilegeData.RewardTime > 0 { //之前没有领取
- diffDay -= 1
- }
- cfgData := this.getSpecialPrivilegeCfgData(this.runeBase.PrivilegeData.SpecialId)
- if cfgData != nil {
- // 奖励邮件发送
- for idx := 0; idx < int(diffDay); idx++ {
- this.role.GetRoleMail().AddMail(model.GlobalMailSpecialPrivilegeCard, serverproto.MailType_MailType_SpecialPrivilege,
- cfgData.VipReward, nil, "", "")
- }
- }
- this.runeBase.PrivilegeData.RewardTime = 0
- this.runeBase.PrivilegeData.ProcessTime = util.GetTimeMilliseconds()
- }
- if notify {
- this.runeBaseDataChangeNtf()
- }
- this.SetDirty(true)
- }
- func (this *RoleRune) runeBaseDataChangeNtf() {
- ntfMsg := &serverproto.SCRuneBaseDataNtf{
- RuneBaseData: this.runeBase,
- }
- this.role.ReplayGate(ntfMsg, true)
- }
- func (this *RoleRune) GetRuneShopInfo(msg *serverproto.SSGetRushShopInfoAck, ackMsg *serverproto.SCRuneShopInfoAck) {
- if ackMsg == nil {
- return
- }
- if msg.RushRound == 0 {
- return
- }
- if msg.ShopType == Rune_Shop_Type_RushTower {
- this.PackRushTowerData(ackMsg, msg.RushRound)
- } else if msg.ShopType == Rune_Shop_Type_RushArena {
- this.PackRushArenaData(ackMsg, msg.RushRound)
- } else if msg.ShopType == Rune_Shop_Type_RushMap {
- this.PackRushMapData(ackMsg, msg.RushRound)
- } else if msg.ShopType == Rune_Shop_Type_RushPet {
- this.PackRushPetData(ackMsg, msg.RushRound)
- } else if msg.ShopType == Rune_Shop_Type_RushSkill {
- this.PackRushSkillData(ackMsg, msg.RushRound)
- }
- }
- func (this *RoleRune) GetShopInfo(shopType, subType int32, ackMsg *serverproto.SCRuneShopInfoAck) {
- if ackMsg == nil {
- return
- }
- if shopType == Rune_Shop_Type_Bag {
- this.PackBagData(subType, ackMsg)
- } else if shopType == Rune_Shop_Type_TimeLimit {
- this.PackLimitData(ackMsg)
- util.InfoF("Rune_Shop_Type_TimeLimit items : ackMsg : %v", ackMsg)
- } else if shopType == Rune_Shop_Type_MonthCard {
- this.PackMonthCardData(ackMsg)
- } else if shopType == Rune_Shop_Type_GuildBattle {
- this.PackGuildBattleData(ackMsg)
- } else if shopType == Rune_Shop_Type_Idol {
- this.PackIdolSeasonShopData(ackMsg)
- }
- }
- func (this *RoleRune) GetBTShopInfo(shopType, subType int32, ackMsg *serverproto.SCBTShopInfoAck) {
- util.InfoF("[GetBTShopInfo] shopType=%v subShop:%v", shopType, subType)
- if shopType == Rune_Shop_Type_CreditRecharge {
- this.PackCreditRechargeShopData(ackMsg)
- } else if shopType == Rune_Shop_Type_Bag {
- this.PackROCoinShopData(subType, ackMsg)
- }
- }
- // 打包礼包商店
- func (this *RoleRune) PackBagData(subType int32, ackMsg *serverproto.SCRuneShopInfoAck) {
- if ackMsg == nil {
- return
- }
- shopData, ok := this.runeGiftShop[subType]
- if !ok {
- return
- }
- for i := 0; i < len(shopData.GoodsInfo); {
- shopItem, ok := model.ConvertGiftBag[shopData.GoodsInfo[i].GoodsId]
- if !ok {
- shopData.GoodsInfo = append(shopData.GoodsInfo[:i], shopData.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_Bag)
- continue
- }
- goods := &serverproto.RuneShopItem{}
- goods.GoodsId = shopData.GoodsInfo[i].GoodsId
- goods.EndTime = 0
- if shopItem.LimitCount >= 9999 {
- goods.BuyNums = 0
- } else {
- var buyNum int32 = shopItem.LimitCount - shopData.GoodsInfo[i].BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- goods.BuyNums = buyNum
- }
- goods.Price = shopItem.Price
- goods.FirstBuy = true
- if shopData.GoodsInfo[i].HistoryBuy > 0 {
- goods.FirstBuy = false
- }
- goods.BuyLimit = true
- if shopItem.LimitCount >= 9999 {
- goods.BuyLimit = false
- }
- i++
- if shopItem.RmbTotalPay > 0 && this.role.GetTotalRecharge() < float32(shopItem.RmbTotalPay) {
- continue
- }
- ackMsg.GoodsList = append(ackMsg.GoodsList, goods)
- }
- ackMsg.EndTime = shopData.NextRefresh
- }
- func (this *RoleRune) PackMonthCardData(ackMsg *serverproto.SCRuneShopInfoAck) {
- if ackMsg == nil || this.runeMonthCardShop == nil || len(this.runeMonthCardShop.GoodsInfo) <= 0 {
- return
- }
- for i := 0; i < len(this.runeMonthCardShop.GoodsInfo); {
- shopItem, ok := model.ConvertMonthCard[this.runeMonthCardShop.GoodsInfo[i].GoodsId]
- if !ok {
- this.runeMonthCardShop.GoodsInfo = append(this.runeMonthCardShop.GoodsInfo[:i], this.runeMonthCardShop.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_MonthCard)
- continue
- }
- goods := &serverproto.RuneShopItem{}
- goods.GoodsId = this.runeMonthCardShop.GoodsInfo[i].GoodsId
- goods.EndTime = 0
- goods.BuyNums = 9999 //表示不限制购买
- goods.Price = shopItem.Price
- goods.FirstBuy = true
- if this.runeMonthCardShop.GoodsInfo[i].HistoryBuy > 0 {
- goods.FirstBuy = false
- }
- goods.EndTime = this.runeMonthCardShop.GoodsInfo[i].EndTime
- goods.BuyLimit = false
- ackMsg.GoodsList = append(ackMsg.GoodsList, goods)
- i++
- }
- }
- func (this *RoleRune) PackRushTowerData(ackMsg *serverproto.SCRuneShopInfoAck, rushRound int32) {
- if ackMsg == nil || this.runeRushTowerShop == nil || len(this.runeRushTowerShop.GoodsInfo) <= 0 {
- return
- }
- for i := 0; i < len(this.runeRushTowerShop.GoodsInfo); {
- shopItem, ok := model.ConvertTowerShop[this.runeRushTowerShop.GoodsInfo[i].GoodsId]
- if !ok {
- this.runeRushTowerShop.GoodsInfo = append(this.runeRushTowerShop.GoodsInfo[:i], this.runeRushTowerShop.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_RushTower)
- continue
- }
- if shopItem.Activity != rushRound {
- i++
- continue
- }
- goods := &serverproto.RuneShopItem{}
- goods.GoodsId = this.runeRushTowerShop.GoodsInfo[i].GoodsId
- goods.EndTime = 0
- if shopItem.LimitCount >= 9999 {
- goods.BuyNums = 0
- } else {
- var buyNum int32 = shopItem.LimitCount - this.runeRushTowerShop.GoodsInfo[i].BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- goods.BuyNums = buyNum
- }
- goods.BuyLimit = true
- if shopItem.LimitCount >= 9999 {
- goods.BuyLimit = false
- }
- goods.Price = shopItem.Price
- goods.FirstBuy = true
- if this.runeRushTowerShop.GoodsInfo[i].HistoryBuy > 0 {
- goods.FirstBuy = false
- }
- goods.EndTime = this.runeRushTowerShop.GoodsInfo[i].EndTime
- ackMsg.GoodsList = append(ackMsg.GoodsList, goods)
- i++
- }
- }
- func (this *RoleRune) PackRushArenaData(ackMsg *serverproto.SCRuneShopInfoAck, rushRound int32) {
- if ackMsg == nil || this.runeRushArenaShop == nil || len(this.runeRushArenaShop.GoodsInfo) <= 0 {
- return
- }
- if rushRound == 0 {
- return
- }
- for i := 0; i < len(this.runeRushArenaShop.GoodsInfo); {
- shopItem, ok := model.ConvertArenaShop[this.runeRushArenaShop.GoodsInfo[i].GoodsId]
- if !ok {
- this.runeRushArenaShop.GoodsInfo = append(this.runeRushArenaShop.GoodsInfo[:i], this.runeRushArenaShop.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_RushArena)
- continue
- }
- if shopItem.Activity != rushRound {
- i++
- continue
- }
- goods := &serverproto.RuneShopItem{}
- goods.GoodsId = this.runeRushArenaShop.GoodsInfo[i].GoodsId
- goods.EndTime = 0
- goods.BuyNums = 9999 //表示不限制购买
- if shopItem.LimitCount >= 9999 {
- goods.BuyNums = 0
- } else {
- var buyNum int32 = shopItem.LimitCount - this.runeRushArenaShop.GoodsInfo[i].BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- goods.BuyNums = buyNum
- }
- goods.BuyLimit = true
- if shopItem.LimitCount >= 9999 {
- goods.BuyLimit = false
- }
- goods.Price = shopItem.Price
- goods.FirstBuy = true
- if this.runeRushArenaShop.GoodsInfo[i].HistoryBuy > 0 {
- goods.FirstBuy = false
- }
- goods.EndTime = this.runeRushArenaShop.GoodsInfo[i].EndTime
- ackMsg.GoodsList = append(ackMsg.GoodsList, goods)
- i++
- }
- }
- func (this *RoleRune) PackRushMapData(ackMsg *serverproto.SCRuneShopInfoAck, rushRound int32) {
- if ackMsg == nil || this.runeRushMapShop == nil || len(this.runeRushMapShop.GoodsInfo) <= 0 {
- return
- }
- if rushRound == 0 {
- return
- }
- for i := 0; i < len(this.runeRushMapShop.GoodsInfo); {
- shopItem, ok := model.ConvertMapShop[this.runeRushMapShop.GoodsInfo[i].GoodsId]
- if !ok {
- this.runeRushMapShop.GoodsInfo = append(this.runeRushMapShop.GoodsInfo[:i], this.runeRushMapShop.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_RushMap)
- continue
- }
- if shopItem.Activity != rushRound {
- i++
- continue
- }
- goods := &serverproto.RuneShopItem{}
- goods.GoodsId = this.runeRushMapShop.GoodsInfo[i].GoodsId
- goods.EndTime = 0
- goods.BuyNums = 9999 //表示不限制购买
- if shopItem.LimitCount >= 9999 {
- goods.BuyNums = 0
- } else {
- var buyNum int32 = shopItem.LimitCount - this.runeRushMapShop.GoodsInfo[i].BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- goods.BuyNums = buyNum
- }
- goods.BuyLimit = true
- if shopItem.LimitCount >= 9999 {
- goods.BuyLimit = false
- }
- goods.Price = shopItem.Price
- goods.FirstBuy = true
- if this.runeRushMapShop.GoodsInfo[i].HistoryBuy > 0 {
- goods.FirstBuy = false
- }
- goods.EndTime = this.runeRushMapShop.GoodsInfo[i].EndTime
- ackMsg.GoodsList = append(ackMsg.GoodsList, goods)
- i++
- }
- }
- func (this *RoleRune) PackRushPetData(ackMsg *serverproto.SCRuneShopInfoAck, rushRound int32) {
- if ackMsg == nil || this.runeRushPetShop == nil || len(this.runeRushPetShop.GoodsInfo) <= 0 {
- return
- }
- if rushRound == 0 {
- return
- }
- for i := 0; i < len(this.runeRushPetShop.GoodsInfo); {
- shopItem, ok := model.ConvertPetShop[this.runeRushPetShop.GoodsInfo[i].GoodsId]
- if !ok {
- this.runeRushPetShop.GoodsInfo = append(this.runeRushPetShop.GoodsInfo[:i], this.runeRushPetShop.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_RushPet)
- continue
- }
- if shopItem.Activity != rushRound {
- i++
- continue
- }
- goods := &serverproto.RuneShopItem{}
- goods.GoodsId = this.runeRushPetShop.GoodsInfo[i].GoodsId
- goods.EndTime = 0
- goods.BuyNums = 9999 //表示不限制购买
- if shopItem.LimitCount >= 9999 {
- goods.BuyNums = 0
- } else {
- var buyNum int32 = shopItem.LimitCount - this.runeRushPetShop.GoodsInfo[i].BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- goods.BuyNums = buyNum
- }
- goods.BuyLimit = true
- if shopItem.LimitCount >= 9999 {
- goods.BuyLimit = false
- }
- goods.Price = shopItem.Price
- goods.FirstBuy = true
- if this.runeRushPetShop.GoodsInfo[i].HistoryBuy > 0 {
- goods.FirstBuy = false
- }
- goods.EndTime = this.runeRushPetShop.GoodsInfo[i].EndTime
- ackMsg.GoodsList = append(ackMsg.GoodsList, goods)
- i++
- }
- }
- func (this *RoleRune) PackRushSkillData(ackMsg *serverproto.SCRuneShopInfoAck, rushRound int32) {
- if ackMsg == nil || this.runeRushSkillShop == nil || len(this.runeRushSkillShop.GoodsInfo) <= 0 {
- return
- }
- if rushRound == 0 {
- return
- }
- for i := 0; i < len(this.runeRushSkillShop.GoodsInfo); {
- shopItem, ok := model.ConvertSkillShop[this.runeRushSkillShop.GoodsInfo[i].GoodsId]
- if !ok {
- this.runeRushSkillShop.GoodsInfo = append(this.runeRushSkillShop.GoodsInfo[:i], this.runeRushSkillShop.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_RushSkill)
- continue
- }
- if shopItem.Activity != rushRound {
- i++
- continue
- }
- goods := &serverproto.RuneShopItem{}
- goods.GoodsId = this.runeRushSkillShop.GoodsInfo[i].GoodsId
- goods.EndTime = 0
- goods.BuyNums = 9999 //表示不限制购买
- if shopItem.LimitCount >= 9999 {
- goods.BuyNums = 0
- } else {
- var buyNum int32 = shopItem.LimitCount - this.runeRushSkillShop.GoodsInfo[i].BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- goods.BuyNums = buyNum
- }
- goods.BuyLimit = true
- if shopItem.LimitCount >= 9999 {
- goods.BuyLimit = false
- }
- goods.Price = shopItem.Price
- goods.FirstBuy = true
- if this.runeRushSkillShop.GoodsInfo[i].HistoryBuy > 0 {
- goods.FirstBuy = false
- }
- goods.EndTime = this.runeRushSkillShop.GoodsInfo[i].EndTime
- ackMsg.GoodsList = append(ackMsg.GoodsList, goods)
- i++
- }
- }
- func (this *RoleRune) PackGuildBattleData(ackMsg *serverproto.SCRuneShopInfoAck) {
- if ackMsg == nil || this.runeGuildBattleShop == nil || len(this.runeGuildBattleShop.GoodsInfo) <= 0 {
- return
- }
- //todo wangzhaocan 公会战时间判定
- for i := 0; i < len(this.runeGuildBattleShop.GoodsInfo); {
- shopItem, ok := model.ConvertGuildBattle[this.runeGuildBattleShop.GoodsInfo[i].GoodsId]
- if !ok {
- this.runeGuildBattleShop.GoodsInfo = append(this.runeGuildBattleShop.GoodsInfo[:i], this.runeGuildBattleShop.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_GuildBattle)
- continue
- }
- goods := &serverproto.RuneShopItem{}
- goods.GoodsId = this.runeGuildBattleShop.GoodsInfo[i].GoodsId
- goods.EndTime = 0
- goods.BuyNums = 9999 //表示不限制购买
- if shopItem.LimitCount >= 9999 {
- goods.BuyNums = 0
- } else {
- var buyNum int32 = shopItem.LimitCount - this.runeGuildBattleShop.GoodsInfo[i].BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- goods.BuyNums = buyNum
- }
- goods.BuyLimit = true
- if shopItem.LimitCount >= 9999 {
- goods.BuyLimit = false
- }
- goods.Price = shopItem.Price
- goods.FirstBuy = true
- if this.runeGuildBattleShop.GoodsInfo[i].HistoryBuy > 0 {
- goods.FirstBuy = false
- }
- goods.EndTime = this.runeGuildBattleShop.GoodsInfo[i].EndTime
- ackMsg.GoodsList = append(ackMsg.GoodsList, goods)
- i++
- }
- }
- func (this *RoleRune) PackIdolSeasonShopData(ackMsg *serverproto.SCRuneShopInfoAck) {
- if ackMsg == nil || this.runeIdolSeasonShop == nil || len(this.runeIdolSeasonShop.GoodsInfo) <= 0 {
- return
- }
- //todo wangzhaocan 公会战时间判定
- for i := 0; i < len(this.runeIdolSeasonShop.GoodsInfo); {
- shopItem, ok := model.ConvertIdolShop[this.runeIdolSeasonShop.GoodsInfo[i].GoodsId]
- if !ok {
- this.runeIdolSeasonShop.GoodsInfo = append(this.runeIdolSeasonShop.GoodsInfo[:i], this.runeIdolSeasonShop.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_Idol)
- continue
- }
- goods := &serverproto.RuneShopItem{}
- goods.GoodsId = this.runeIdolSeasonShop.GoodsInfo[i].GoodsId
- goods.EndTime = 0
- goods.BuyNums = 9999 //表示不限制购买
- if shopItem.LimitCount >= 9999 {
- goods.BuyNums = 0
- } else {
- var buyNum int32 = shopItem.LimitCount - this.runeIdolSeasonShop.GoodsInfo[i].BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- goods.BuyNums = buyNum
- }
- goods.BuyLimit = true
- if shopItem.LimitCount >= 9999 {
- goods.BuyLimit = false
- }
- goods.Price = shopItem.Price
- goods.FirstBuy = true
- if this.runeIdolSeasonShop.GoodsInfo[i].HistoryBuy > 0 {
- goods.FirstBuy = false
- }
- goods.EndTime = this.runeIdolSeasonShop.GoodsInfo[i].EndTime
- ackMsg.GoodsList = append(ackMsg.GoodsList, goods)
- i++
- }
- }
- func (this *RoleRune) PackCreditRechargeShopData(ackMsg *serverproto.SCBTShopInfoAck) {
- shopData, ok := this.runeCreditRecharge[Rune_BagShop_Type_CreditRecharge]
- if !ok {
- return
- }
- for i := 0; i < len(shopData.GoodsInfo); {
- shopItem, ok := model.ConvertPurseShop[shopData.GoodsInfo[i].GoodsId]
- if !ok {
- shopData.GoodsInfo = append(shopData.GoodsInfo[:i], shopData.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_CreditRecharge)
- continue
- }
- goods := &serverproto.RuneShopItem{
- GoodsId: shopData.GoodsInfo[i].GoodsId,
- Price: shopItem.Price,
- FirstBuy: true,
- BuyLimit: true,
- }
- if shopItem.LimitCount >= 9999 {
- goods.BuyNums = 0
- } else {
- buyNum := shopItem.LimitCount - shopData.GoodsInfo[i].BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- goods.BuyNums = buyNum
- }
- if shopData.GoodsInfo[i].HistoryBuy > 0 {
- goods.FirstBuy = false
- }
- if shopItem.LimitCount >= 9999 {
- goods.BuyLimit = false
- }
- i++
- if shopItem.RmbTotalPay > 0 && this.role.GetTotalRecharge() < float32(shopItem.RmbTotalPay) {
- continue
- }
- ackMsg.GoodsList = append(ackMsg.GoodsList, goods)
- }
- ackMsg.EndTime = shopData.NextRefresh
- }
- func (this *RoleRune) PackROCoinShopData(subType int32, ackMsg *serverproto.SCBTShopInfoAck) {
- util.InfoF("[PackROCoinShopData] subShop:%v", subType)
- shopData, ok := this.runeGiftShop[subType]
- util.InfoF("[PackROCoinShopData] shopData:%v ok:%v", shopData, ok)
- if !ok {
- return
- }
- for i := 0; i < len(shopData.GoodsInfo); {
- shopItem, ok := model.ConvertGiftBag[shopData.GoodsInfo[i].GoodsId]
- if !ok {
- shopData.GoodsInfo = append(shopData.GoodsInfo[:i], shopData.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_Bag)
- continue
- }
- goods := &serverproto.RuneShopItem{
- GoodsId: shopData.GoodsInfo[i].GoodsId,
- Price: shopItem.Price,
- FirstBuy: true,
- BuyLimit: true,
- }
- if shopItem.LimitCount >= 9999 {
- goods.BuyNums = 0
- } else {
- buyNum := shopItem.LimitCount - shopData.GoodsInfo[i].BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- goods.BuyNums = buyNum
- }
- if shopData.GoodsInfo[i].HistoryBuy > 0 {
- goods.FirstBuy = false
- }
- if shopItem.LimitCount >= 9999 {
- goods.BuyLimit = false
- }
- i++
- if shopItem.RmbTotalPay > 0 && this.role.GetTotalRecharge() < float32(shopItem.RmbTotalPay) {
- continue
- }
- ackMsg.GoodsList = append(ackMsg.GoodsList, goods)
- }
- ackMsg.EndTime = shopData.NextRefresh
- }
- func (this *RoleRune) CheckInSellingTime(startDay int32, endDay int32) bool {
- if startDay > endDay {
- return false
- }
- startUpTime := service.GetServiceStartupTime()
- if startUpTime <= 0 {
- return false
- }
- beginTime := startUpTime + (uint64(startDay)-1)*24*3600*1000
- endTime := startUpTime + (uint64(endDay)-1)*24*3600*1000
- if beginTime <= util.GetCurrentTime() && util.GetCurrentTime() <= endTime {
- return true
- }
- return false
- }
- const (
- Shop_Time_Out_Of_Date = 0
- Shop_Time_Not_Ready_To_Show = 1
- Shop_Time_Show = 2
- Shop_Time_Not_In_Season = 3
- )
- func (this *RoleRune) CheckInShowTime(startDay int32, endDay int32, nowTime uint64) int32 {
- if startDay > endDay {
- return Shop_Time_Out_Of_Date
- }
- startUpTime := service.GetServiceStartupTime()
- if startUpTime <= 0 {
- return Shop_Time_Out_Of_Date
- }
- beginTime := startUpTime + (uint64(startDay)-1)*24*3600*1000
- endTime := startUpTime + (uint64(endDay)-1)*24*3600*1000
- if nowTime >= endTime {
- return Shop_Time_Out_Of_Date
- }
- if nowTime < beginTime {
- return Shop_Time_Not_Ready_To_Show
- }
- return Shop_Time_Show
- }
- const (
- LimitType_Abs_Time = 0 //绝对时间
- LimitType_StartServer = 1 //开服时间
- LimitType_Competition = 2 //赛季
- LimitType_Activity = 3 //活动
- )
- // 打包限时商店
- func (this *RoleRune) PackLimitData(ackMsg *serverproto.SCRuneShopInfoAck) {
- if ackMsg == nil || this.runeLimitShop == nil || len(this.runeLimitShop.GoodsInfo) < 0 {
- return
- }
- curTime := util.GetCurrentTime()
- startUpTime := service.GetServiceStartupTime()
- activityEndTime := int64(0)
- for i := 0; i < len(this.runeLimitShop.GoodsInfo); {
- shopItem, ok := model.ConvertLimitGag[this.runeLimitShop.GoodsInfo[i].GoodsId]
- if !ok {
- this.runeLimitShop.GoodsInfo = append(this.runeLimitShop.GoodsInfo[:i], this.runeLimitShop.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_TimeLimit)
- continue
- }
- //判定时间 if 绝对时间判定,else 开服时间判定
- if shopItem.LimitType == LimitType_Abs_Time {
- if int64(curTime) < shopItem.BeginTime {
- i++
- continue
- }
- if shopItem.BeginTime == 0 || shopItem.EndTime == 0 || shopItem.EndTime < int64(curTime) {
- this.runeLimitShop.GoodsInfo = append(this.runeLimitShop.GoodsInfo[:i], this.runeLimitShop.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_TimeLimit)
- continue
- }
- } else if shopItem.LimitType == LimitType_StartServer {
- bRet := this.CheckInShowTime(shopItem.StartDay, shopItem.EndDay, curTime)
- if bRet == Shop_Time_Not_Ready_To_Show {
- i++
- continue
- }
- if bRet == Shop_Time_Out_Of_Date {
- this.runeLimitShop.GoodsInfo = append(this.runeLimitShop.GoodsInfo[:i], this.runeLimitShop.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_TimeLimit)
- continue
- }
- } else if shopItem.LimitType == LimitType_Activity {
- bRet := this.role.GetRoleActivity().ActivityHDRuneGoodsAdd(shopItem.ActivityId)
- if bRet == 0 {
- i++
- continue
- }
- activityEndTime = int64(bRet)
- //todo wangzhaocan 卢恩活动道具,后续补充删除过期商品
- } else {
- bRet, _ := this.role.roleCompetition.CheckInCompetitionSeason(shopItem.SeasonId)
- if bRet == Shop_Time_Not_Ready_To_Show {
- i++
- continue
- }
- if bRet == Shop_Time_Out_Of_Date {
- this.runeLimitShop.GoodsInfo = append(this.runeLimitShop.GoodsInfo[:i], this.runeLimitShop.GoodsInfo[i+1:]...)
- this.addShopChange(Rune_Shop_Type_TimeLimit)
- continue
- }
- }
- goods := &serverproto.RuneShopItem{}
- goods.GoodsId = this.runeLimitShop.GoodsInfo[i].GoodsId
- if shopItem.EndTime != 0 {
- goods.EndTime = shopItem.EndTime
- } else {
- if shopItem.LimitType == LimitType_StartServer {
- goods.EndTime = int64(startUpTime) + int64(shopItem.EndDay-1)*24*3600*1000
- } else if shopItem.LimitType == LimitType_Activity {
- goods.EndTime = activityEndTime
- } else if shopItem.LimitType == LimitType_Competition {
- goods.EndTime = int64(this.role.roleCompetition.curCompInfo.CurEndTime)
- }
- }
- if shopItem.LimitCount >= 9999 {
- goods.BuyNums = 0
- } else {
- var buyNum = shopItem.LimitCount - this.runeLimitShop.GoodsInfo[i].BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- goods.BuyNums = buyNum
- }
- goods.Price = shopItem.Price
- goods.FirstBuy = true
- if this.runeLimitShop.GoodsInfo[i].HistoryBuy > 0 {
- goods.FirstBuy = false
- }
- goods.BuyLimit = true
- if shopItem.LimitCount >= 9999 {
- goods.BuyLimit = false
- }
- ackMsg.GoodsList = append(ackMsg.GoodsList, goods)
- i++
- }
- }
- // 购买礼包商店道具
- func (this *RoleRune) BuyBagShopItem(payRewardInfo *serverproto.PayOrderSaveInfo) serverproto.ErrorCode {
- if payRewardInfo == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- shopItem, ok := model.ConvertGiftBag[payRewardInfo.GoodsId]
- if !ok {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- _, ok1 := this.runeGiftShop[shopItem.BagType]
- if !ok1 {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- bFind := false
- bFirst := true
- for _, goods := range this.runeGiftShop[shopItem.BagType].GoodsInfo {
- if goods.GoodsId == payRewardInfo.GoodsId {
- if shopItem.LimitCount != 0 && goods.BuyNum >= shopItem.LimitCount {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- if goods.HistoryBuy > 0 {
- bFirst = false
- }
- bFind = true
- break
- }
- }
- //商店找不到此商品,返回
- if bFind == false {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- util.InfoF("BuyBagShopItem payRewardInfo=%v shopItem:%v", *payRewardInfo, shopItem)
- payRewardInfo.Count = 1
- payRewardInfo.GoodsId = payRewardInfo.GoodsId
- payRewardInfo.Amount = shopItem.Price * float32(payRewardInfo.Count)
- payRewardInfo.GoodsName = shopItem.Name
- //打包正常购买
- reward := make(map[int32]int32)
- for _, items := range shopItem.BuyReward {
- payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- reward[items.Key] += items.Value
- }
- //打包额外道具 //首冲或者非首冲
- if bFirst == true {
- for _, items := range shopItem.FirstReward {
- payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- reward[items.Key] += items.Value
- }
- } else {
- for _, items := range shopItem.ExtraReward {
- payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- reward[items.Key] += items.Value
- }
- }
- util.InfoF("uid=%v bag shop: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- if payRewardInfo.Amount == 0 {
- this.role.AddItemList(reward, AddFrom_Rune, true)
- this.addShopChange(Rune_Shop_Type_Bag)
- this.OnBuyItemSuccess(payRewardInfo)
- }
- return serverproto.ErrorCode_ERROR_OK
- }
- // 购买限时商店道具
- func (this *RoleRune) BuyLimitShopItem(payRewardInfo *serverproto.PayOrderSaveInfo) serverproto.ErrorCode {
- if payRewardInfo == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- shopItem, ok := model.ConvertLimitGag[payRewardInfo.GoodsId]
- if !ok {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- if shopItem.BeginTime != 0 && shopItem.EndTime != 0 {
- if int64(util.GetCurrentTime()) < shopItem.BeginTime || shopItem.EndTime < int64(util.GetCurrentTime()) {
- return serverproto.ErrorCode_ERROR_SHOP_NOT_IN_RANGE_TIME
- }
- } else {
- if shopItem.LimitType == LimitType_StartServer {
- bRet := this.CheckInSellingTime(shopItem.StartDay, shopItem.EndDay)
- if bRet == false {
- return serverproto.ErrorCode_ERROR_SHOP_NOT_IN_RANGE_TIME
- }
- } else if shopItem.LimitType == LimitType_Activity {
- bRet := this.role.GetRoleActivity().ActivityHDRuneGoodsAdd(shopItem.ActivityId)
- if bRet == 0 {
- return serverproto.ErrorCode_ERROR_SHOP_NOT_IN_RANGE_TIME
- }
- } else if shopItem.LimitType == LimitType_Competition {
- bRet, _ := this.role.roleCompetition.CheckInCompetitionSeason(shopItem.SeasonId)
- if bRet != Shop_Time_Show {
- return serverproto.ErrorCode_ERROR_SHOP_NOT_IN_RANGE_TIME
- }
- }
- }
- bFind := false
- for _, goods := range this.runeLimitShop.GoodsInfo {
- if goods.GoodsId == payRewardInfo.GoodsId {
- if goods.BuyNum >= shopItem.LimitCount {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- bFind = true
- break
- }
- }
- //商店找不到此商品,返回
- if bFind == false {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- payRewardInfo.Count = 1
- payRewardInfo.GoodsId = payRewardInfo.GoodsId
- payRewardInfo.Amount = shopItem.Price * float32(payRewardInfo.Count)
- payRewardInfo.GoodsName = shopItem.Name
- //打包正常购买
- reward := make(map[int32]int32)
- for _, items := range shopItem.BuyReward {
- payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- }
- util.InfoF("uid=%v limit shop: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- if payRewardInfo.Amount == 0 {
- this.role.AddItemList(reward, AddFrom_Rune, true)
- this.addShopChange(Rune_Shop_Type_TimeLimit)
- this.OnBuyItemSuccess(payRewardInfo)
- }
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *RoleRune) BuyMonthCardShopItem(payRewardInfo *serverproto.PayOrderSaveInfo) serverproto.ErrorCode {
- if payRewardInfo == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- shopItem, ok := model.ConvertMonthCard[payRewardInfo.GoodsId]
- if !ok {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- payRewardInfo.Count = 1
- payRewardInfo.GoodsId = payRewardInfo.GoodsId
- payRewardInfo.Amount = shopItem.Price
- payRewardInfo.GoodsName = shopItem.Name
- //打包正常购买
- for _, items := range shopItem.BuyReward {
- payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- }
- util.InfoF("uid=%v monthcard: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *RoleRune) BuyRushTowerShopItem(payRewardInfo *serverproto.PayOrderSaveInfo, rushStage, rushRound int32) serverproto.ErrorCode {
- if this.role.GetRoleTower() == nil || payRewardInfo == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- if rushStage != 1 {
- return serverproto.ErrorCode_ERROR_SHOP_NOT_IN_RANGE_TIME
- }
- shopItem, ok := model.ConvertTowerShop[payRewardInfo.GoodsId]
- if !ok {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- for _, goods := range this.runeRushTowerShop.GoodsInfo {
- if goods.GoodsId == payRewardInfo.GoodsId {
- if goods.BuyNum >= shopItem.LimitCount {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- break
- }
- }
- if rushRound != 0 && rushRound != shopItem.Activity {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- payRewardInfo.Count = 1
- payRewardInfo.GoodsId = payRewardInfo.GoodsId
- payRewardInfo.Amount = shopItem.Price
- payRewardInfo.GoodsName = shopItem.Name
- //打包正常购买
- for _, items := range shopItem.BuyReward {
- payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- }
- util.InfoF("uid=%v rushtower: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *RoleRune) BuyRushArenaShopItem(payRewardInfo *serverproto.PayOrderSaveInfo, rushStage, rushRound int32) serverproto.ErrorCode {
- if this.role.GetRoleArena() == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- if rushStage != 1 {
- return serverproto.ErrorCode_ERROR_SHOP_NOT_IN_RANGE_TIME
- }
- if payRewardInfo == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- shopItem, ok := model.ConvertArenaShop[payRewardInfo.GoodsId]
- if !ok {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- for _, goods := range this.runeRushArenaShop.GoodsInfo {
- if goods.GoodsId == payRewardInfo.GoodsId {
- if goods.BuyNum >= shopItem.LimitCount {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- break
- }
- }
- if rushRound != 0 && rushRound != shopItem.Activity {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- payRewardInfo.Count = 1
- payRewardInfo.GoodsId = payRewardInfo.GoodsId
- payRewardInfo.Amount = shopItem.Price
- payRewardInfo.GoodsName = shopItem.Name
- //打包正常购买
- for _, items := range shopItem.BuyReward {
- payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- }
- util.InfoF("uid=%v rusharena: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *RoleRune) BuyRushMapShopItem(payRewardInfo *serverproto.PayOrderSaveInfo, rushStage, rushRound int32) serverproto.ErrorCode {
- if this.role.GetRoleBattle() == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- if rushStage != 1 {
- return serverproto.ErrorCode_ERROR_SHOP_NOT_IN_RANGE_TIME
- }
- if payRewardInfo == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- shopItem, ok := model.ConvertMapShop[payRewardInfo.GoodsId]
- if !ok {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- for _, goods := range this.runeRushMapShop.GoodsInfo {
- if goods.GoodsId == payRewardInfo.GoodsId {
- if goods.BuyNum >= shopItem.LimitCount {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- break
- }
- }
- if rushRound != 0 && rushRound != shopItem.Activity {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- payRewardInfo.Count = 1
- payRewardInfo.GoodsId = payRewardInfo.GoodsId
- payRewardInfo.Amount = shopItem.Price
- payRewardInfo.GoodsName = shopItem.Name
- //打包正常购买
- for _, items := range shopItem.BuyReward {
- payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- }
- util.InfoF("uid=%v rushmap: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *RoleRune) BuyRushPetShopItem(payRewardInfo *serverproto.PayOrderSaveInfo, rushStage, rushRound int32) serverproto.ErrorCode {
- if this.role.GetRolePet() == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- if rushStage != 1 {
- return serverproto.ErrorCode_ERROR_SHOP_NOT_IN_RANGE_TIME
- }
- if payRewardInfo == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- shopItem, ok := model.ConvertPetShop[payRewardInfo.GoodsId]
- if !ok {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- for _, goods := range this.runeRushPetShop.GoodsInfo {
- if goods.GoodsId == payRewardInfo.GoodsId {
- if goods.BuyNum >= shopItem.LimitCount {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- break
- }
- }
- if rushRound != 0 && rushRound != shopItem.Activity {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- payRewardInfo.Count = 1
- payRewardInfo.GoodsId = payRewardInfo.GoodsId
- payRewardInfo.Amount = shopItem.Price
- payRewardInfo.GoodsName = shopItem.Name
- //打包正常购买
- for _, items := range shopItem.BuyReward {
- payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- }
- util.InfoF("uid=%v rushmap: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *RoleRune) BuyRushSkillShopItem(payRewardInfo *serverproto.PayOrderSaveInfo, rushStage, rushRound int32) serverproto.ErrorCode {
- if this.role.GetRoleRush() == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- if rushStage != 1 {
- return serverproto.ErrorCode_ERROR_SHOP_NOT_IN_RANGE_TIME
- }
- if payRewardInfo == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- shopItem, ok := model.ConvertSkillShop[payRewardInfo.GoodsId]
- if !ok {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- for _, goods := range this.runeRushSkillShop.GoodsInfo {
- if goods.GoodsId == payRewardInfo.GoodsId {
- if goods.BuyNum >= shopItem.LimitCount {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- break
- }
- }
- if rushRound != 0 && rushRound != shopItem.Activity {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- payRewardInfo.Count = 1
- payRewardInfo.GoodsId = payRewardInfo.GoodsId
- payRewardInfo.Amount = shopItem.Price
- payRewardInfo.GoodsName = shopItem.Name
- //打包正常购买
- for _, items := range shopItem.BuyReward {
- payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- }
- util.InfoF("uid=%v rushmap: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *RoleRune) BuyIdolSeasonShopItem(payRewardInfo *serverproto.PayOrderSaveInfo) serverproto.ErrorCode {
- if payRewardInfo == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- shopItem, ok := model.ConvertIdolShop[payRewardInfo.GoodsId]
- if !ok {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- for _, goods := range this.runeIdolSeasonShop.GoodsInfo {
- if goods.GoodsId == payRewardInfo.GoodsId {
- if goods.BuyNum >= shopItem.LimitCount {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- break
- }
- }
- payRewardInfo.Count = 1
- payRewardInfo.GoodsId = payRewardInfo.GoodsId
- payRewardInfo.Amount = shopItem.Price
- payRewardInfo.GoodsName = shopItem.Name
- //打包正常购买
- for _, items := range shopItem.BuyReward {
- payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- }
- util.InfoF("uid=%v idol season: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *RoleRune) BuyRuneExplore(payRewardInfo *serverproto.PayOrderSaveInfo) serverproto.ErrorCode {
- if payRewardInfo == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- if this.runeExplore.BUnlock {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- if !RuneShopMag.IsOpen() {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- db := model.GetRuneExploreDataByRound(RuneShopMag.GetCurRound())
- if db == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- payRewardInfo.Amount = db.GetRMB()
- payRewardInfo.Count = 1
- payRewardInfo.GoodsName = strconv.Itoa(int(RuneShopMag.GetCurRound()))
- util.InfoF("uid=%v guildbattle: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- return serverproto.ErrorCode_ERROR_OK
- }
- // 公会战购买
- func (this *RoleRune) BuyGuildBattleShopItem(payRewardInfo *serverproto.PayOrderSaveInfo) serverproto.ErrorCode {
- if this.role.GetRoleBattle() == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- //todo wangzhaocan 判定是否在购买时间内
- /*
- if this.role.GetRoleBattle().IsInRushMapStage() == false {
- return serverproto.ErrorCode_ERROR_SHOP_NOT_IN_RANGE_TIME
- }
- */
- if payRewardInfo == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- shopItem, ok := model.ConvertGuildBattle[payRewardInfo.GoodsId]
- if !ok {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- for _, goods := range this.runeGuildBattleShop.GoodsInfo {
- if goods.GoodsId == payRewardInfo.GoodsId {
- if goods.BuyNum >= shopItem.LimitCount {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- break
- }
- }
- payRewardInfo.Count = 1
- payRewardInfo.GoodsId = payRewardInfo.GoodsId
- payRewardInfo.Amount = shopItem.Price
- payRewardInfo.GoodsName = shopItem.Name
- //打包正常购买
- for _, items := range shopItem.BuyReward {
- payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- }
- util.InfoF("uid=%v guildbattle: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- return serverproto.ErrorCode_ERROR_OK
- }
- // 充值钱包商店购买(假购买消耗对应道具)
- func (this *RoleRune) BuyCreditRechargeShopItem(goodsId, count int32) serverproto.ErrorCode {
- if count <= 0 || goodsId <= 0 {
- return serverproto.ErrorCode_ERROR_PAY_ITEM_NO
- }
- shipItemCfg, ok := model.ConvertPurseShop[goodsId]
- if !ok {
- return serverproto.ErrorCode_ERROR_PAY_ITEM_NO
- }
- if _, ok := this.runeCreditRecharge[shipItemCfg.BagType]; !ok {
- util.WarnF("uid=%v CreditRechargeShop item not init", this.role.GetUUid())
- return serverproto.ErrorCode_ERROR_FAIL
- }
- bFind := false
- bFirst := true
- for _, goods := range this.runeCreditRecharge[shipItemCfg.BagType].GoodsInfo {
- if goods.GoodsId == goodsId {
- if shipItemCfg.LimitCount != 0 && goods.BuyNum >= shipItemCfg.LimitCount {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- if goods.HistoryBuy > 0 {
- bFirst = false
- }
- bFind = true
- break
- }
- }
- // 商店找不到此商品,返回
- if !bFind {
- util.WarnF("uid=%v CreditRechargeShop itemList not find", this.role.GetUUid())
- return serverproto.ErrorCode_ERROR_PAY_ITEM_NO
- }
- // 判断资源道具是否足够
- delItemList := map[int32]int32{}
- delItemList[int32(serverproto.ResType_Res_CreditRecharge)] += int32(shipItemCfg.Price) //消耗特定资源
- if !this.role.GetRoleBag().CanDelItemList(delItemList) {
- return serverproto.ErrorCode_ERROR_PAY_CREDITRECHARGE_NOT_ENOUGH
- }
- // 判断是否有足够的(充值钱包额度)
- if !this.runeBase.CreditRechargeLimit {
- price := int32(shipItemCfg.Price)
- curVal := price + this.runeBase.UsedCreditRecharge
- if this.runeBase.MaxCreditRecharge < curVal {
- return serverproto.ErrorCode_ERROR_PAY_CREDITRECHARGE_LIMIT_NOT_ENOUGH
- } else {
- this.runeBase.UsedCreditRecharge += price
- this.runeBaseDataChangeNtf()
- this.SetDirty(true)
- }
- }
- this.role.GetRoleBag().DelItemList(delItemList, AddItemST{AddFrom: AddFrom_CreditRecharge})
- // 奖励物品处理
- ackMsg := &serverproto.SCCreditRechargeShopItemBuyAck{
- GoodsId: goodsId,
- ShopItem: &serverproto.RuneShopItem{},
- }
- rewardList := map[int32]int32{}
- for _, items := range shipItemCfg.BuyReward {
- ackMsg.RewardItemList = append(ackMsg.RewardItemList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- rewardList[items.Key] += items.Value
- }
- // 首冲或者非首冲获得
- if bFirst == true {
- for _, items := range shipItemCfg.FirstReward {
- ackMsg.RewardItemList = append(ackMsg.RewardItemList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- rewardList[items.Key] += items.Value
- }
- } else {
- for _, items := range shipItemCfg.ExtraReward {
- ackMsg.RewardItemList = append(ackMsg.RewardItemList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- rewardList[items.Key] += items.Value
- }
- }
- util.InfoF("uid=%v CreditRechargeShop id=%v count=%v", this.role.GetUUid(), goodsId, count)
- this.role.AddItemList(rewardList, AddFrom_Rune, true)
- // 获取物品后的后续逻辑处理
- for _, goods := range this.runeCreditRecharge[shipItemCfg.BagType].GoodsInfo {
- if goods.GoodsId == goodsId {
- goods.BuyNum += 1
- goods.HistoryBuy += 1
- ackMsg.ShopItem.GoodsId = goods.GoodsId
- ackMsg.ShopItem.Price = shipItemCfg.Price
- ackMsg.ShopItem.FirstBuy = false
- if shipItemCfg.LimitCount >= 9999 {
- ackMsg.ShopItem.BuyNums = 0
- ackMsg.ShopItem.BuyLimit = false
- } else {
- buyNum := shipItemCfg.LimitCount - goods.BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- ackMsg.ShopItem.BuyNums = buyNum
- ackMsg.ShopItem.BuyLimit = true
- }
- ackMsg.ShopItem.EndTime = 0
- this.addShopChange(Rune_Shop_Type_CreditRecharge)
- break
- }
- }
- this.role.ReplayGate(ackMsg, true)
- return serverproto.ErrorCode_ERROR_OK
- }
- // 特权卡商店道具购买
- func (this *RoleRune) BuySpecialPrivilegeShopItem(payRewardInfo *serverproto.PayOrderSaveInfo) serverproto.ErrorCode {
- if this.runeBase.PrivilegeData == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- goodsId := this.runeBase.PrivilegeData.SpecialId
- if goodsId <= 0 && len(model.ConvertSpecialPrivilegeRight) > 0 {
- goodsId = model.ConvertSpecialPrivilegeRight[0].Id
- } else {
- nextCfgData := this.getNextSpecialPrivilegeCfgData(goodsId)
- if nextCfgData != nil {
- goodsId = nextCfgData.Id
- }
- }
- if goodsId <= 0 {
- util.InfoF("uid=%v BuySpecialPrivilegeShopItem data not find!!!", this.role.GetUUid())
- return serverproto.ErrorCode_ERROR_PAY_ITEM_NO
- }
- if goodsId == this.runeBase.PrivilegeData.SpecialId {
- //无后续特权卡可购买
- return serverproto.ErrorCode_ERROR_PAY_ITEM_NO
- }
- shopItemCfg := this.getSpecialPrivilegeCfgData(goodsId)
- if shopItemCfg == nil {
- return serverproto.ErrorCode_ERROR_PAY_ITEM_NO
- }
- // 初级开荒特权是否购买/是否具备购买高级开荒特权条件
- // 任务条件不存在或者已经完成的状态下可以进行购买
- ret := this.role.GetRoleBase().checkUnLockState(0, shopItemCfg.ConditionList)
- if ret != serverproto.ErrorCode_ERROR_OK {
- return serverproto.ErrorCode_ERROR_PAY_SPECIALPRIVILEGE_UNLOCK
- }
- payRewardInfo.Count = 1
- payRewardInfo.GoodsId = goodsId
- payRewardInfo.Amount = shopItemCfg.Price
- payRewardInfo.GoodsName = shopItemCfg.GoodsName
- // 购买获得道具
- //for k, v := range shopItemCfg.VipReward {
- // payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{
- // Key: k,
- // Value: v,
- // })
- //}
- util.InfoF("uid=%v BuySpecialPrivilegeShopItem id=%v price=%v", this.role.GetUUid(), payRewardInfo.GoodsId, payRewardInfo.Amount)
- return serverproto.ErrorCode_ERROR_OK
- }
- // RO通行证购买
- func (this *RoleRune) BuyPassCheck(payRewardInfo *serverproto.PayOrderSaveInfo) serverproto.ErrorCode {
- if model.ConvertPassCheckData == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- if this.runeBase.IsPassCheck {
- return serverproto.ErrorCode_ERROR_PAY_PASSCHECK_BUY
- }
- payRewardInfo.Count = 1
- payRewardInfo.GoodsId = model.ConvertPassCheckData.Id
- payRewardInfo.Amount = model.ConvertPassCheckData.Price
- payRewardInfo.GoodsName = model.ConvertPassCheckData.GoodsName
- //特权在购买成功后生效
- util.InfoF("uid=%v BuyPassCheck id=%v price=%v", this.role.GetUUid(), payRewardInfo.GoodsId, payRewardInfo.Amount)
- return serverproto.ErrorCode_ERROR_OK
- }
- // RO币礼包商店购买
- func (this *RoleRune) PayInfoGetForRoCoin(goodsId, count int32) serverproto.ErrorCode {
- if count <= 0 || goodsId <= 0 {
- return serverproto.ErrorCode_ERROR_PAY_ITEM_NO
- }
- shipItemCfg, ok := model.ConvertGiftBag[goodsId]
- if !ok || shipItemCfg.BagType != Rune_BagShop_Type_ROCoin {
- return serverproto.ErrorCode_ERROR_PAY_ITEM_NO
- }
- bFind := false
- bFirst := true
- shopDataInfo, ok := this.runeGiftShop[shipItemCfg.BagType]
- if ok {
- for _, goods := range shopDataInfo.GoodsInfo {
- if goods.GoodsId == goodsId {
- if shipItemCfg.LimitCount != 0 && goods.BuyNum >= shipItemCfg.LimitCount {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- if goods.HistoryBuy > 0 {
- bFirst = false
- }
- bFind = true
- break
- }
- }
- } else {
- util.WarnF("uid=%v PayInfoGetForRoCoin item not init goodsId=%v ", this.role.GetUUid(), goodsId)
- return serverproto.ErrorCode_ERROR_FAIL
- }
- //商店找不到此商品,返回
- if bFind == false {
- util.WarnF("uid=%v PayInfoGetForRoCoin item not find goodsId=%v", this.role.GetUUid(), goodsId)
- return serverproto.ErrorCode_ERROR_FAIL
- }
- consumeVal := int32(shipItemCfg.Price)
- if !this.role.GetRoleBag().CanDelItem(int32(serverproto.ResType_Res_ROCoin), consumeVal) {
- return this.role.GetResNotice(int32(serverproto.ResType_Res_ROCoin))
- }
- this.role.DelItem(int32(serverproto.ResType_Res_ROCoin), consumeVal, AddItemST{
- AddFrom: AddFrom_Rune,
- Notify: true,
- })
- ackMsg := &serverproto.SCBTRoCoinShopItemBuyAck{
- GoodsType: Rune_Shop_Type_Bag,
- SubType: Rune_BagShop_Type_ROCoin,
- GoodsId: goodsId,
- ShopItem: &serverproto.RuneShopItem{},
- }
- reward := make(map[int32]int32)
- for _, items := range shipItemCfg.BuyReward {
- ackMsg.RewardItemList = append(ackMsg.RewardItemList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- reward[items.Key] += items.Value
- }
- //打包额外道具 //首冲或者非首冲
- if bFirst == true {
- for _, items := range shipItemCfg.FirstReward {
- ackMsg.RewardItemList = append(ackMsg.RewardItemList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- reward[items.Key] += items.Value
- }
- } else {
- for _, items := range shipItemCfg.ExtraReward {
- ackMsg.RewardItemList = append(ackMsg.RewardItemList, &serverproto.KeyValueType{
- Key: items.Key,
- Value: items.Value,
- })
- reward[items.Key] += items.Value
- }
- }
- util.InfoF("uid=%v PayInfoGetForRoCoin additemlist=%v", this.role.GetUUid(), ackMsg.RewardItemList)
- this.role.AddItemList(reward, AddFrom_Rune, true)
- // 获取物品后的后续逻辑处理
- for _, goods := range shopDataInfo.GoodsInfo {
- if goods.GoodsId == goodsId {
- goods.BuyNum += 1
- goods.HistoryBuy += 1
- ackMsg.ShopItem.GoodsId = goods.GoodsId
- ackMsg.ShopItem.Price = shipItemCfg.Price
- ackMsg.ShopItem.FirstBuy = false
- if shipItemCfg.LimitCount >= 9999 {
- ackMsg.ShopItem.BuyNums = 0
- ackMsg.ShopItem.BuyLimit = false
- } else {
- buyNum := shipItemCfg.LimitCount - goods.BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- ackMsg.ShopItem.BuyNums = buyNum
- ackMsg.ShopItem.BuyLimit = true
- }
- ackMsg.ShopItem.EndTime = 0
- this.addShopChange(Rune_Shop_Type_Bag)
- break
- }
- }
- this.role.ReplayGate(ackMsg, true)
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *RoleRune) getSpecialPrivilegeCfgData(privilegeCfgId int32) *model.PrivilegeData {
- for idx := 0; idx < len(model.ConvertSpecialPrivilegeRight); idx++ {
- if model.ConvertSpecialPrivilegeRight[idx].Id == privilegeCfgId {
- return model.ConvertSpecialPrivilegeRight[idx]
- }
- }
- return nil
- }
- func (this *RoleRune) getNextSpecialPrivilegeCfgData(privilegeCfgId int32) *model.PrivilegeData {
- // ConvertSpecialPrivilegeRight已经排序
- for idx := 0; idx < len(model.ConvertSpecialPrivilegeRight); idx++ {
- if model.ConvertSpecialPrivilegeRight[idx].Id > privilegeCfgId {
- return model.ConvertSpecialPrivilegeRight[idx]
- }
- }
- return nil
- }
- func (this *RoleRune) AddMonthCardItem(goodId, cnt int32) {
- ntfMsg := &serverproto.SCRuneShopBuyItemNtf{
- ShopType: Rune_Shop_Type_MonthCard,
- ShopItem: &serverproto.RuneShopItem{},
- SubShop: 0,
- }
- shopItemCfg, shopItemOk := model.ConvertMonthCard[goodId]
- for _, data := range this.runeMonthCardShop.GoodsInfo {
- if data.GoodsId == goodId {
- //首次充值
- if data.EndTime == 0 {
- data.EndTime = (int64(util.GetLatest5Hour()) + int64(shopItemCfg.Duration)*24*3600*1000)
- data.NextRewardTime = int64(util.GetLatest5Hour())
- //非续时,给邮件奖励
- reward := make(map[int32]int32)
- for _, item := range shopItemCfg.MailReward {
- reward[item.Key] = item.Value
- }
- if len(reward) > 0 {
- this.role.GetRoleMail().AddMail(shopItemCfg.MailCfgId, serverproto.MailType_MailType_MonthCard,
- reward, []int32{29}, "", "")
- }
- } else {
- data.EndTime += int64(shopItemCfg.Duration) * 24 * 3600 * 1000 //30天d
- }
- data.BuyNum += cnt
- data.HistoryBuy += cnt
- if shopItemOk {
- ntfMsg.ShopItem.GoodsId = data.GoodsId
- ntfMsg.ShopItem.Price = shopItemCfg.Price
- ntfMsg.ShopItem.FirstBuy = false
- ntfMsg.ShopItem.BuyNums = data.BuyNum
- ntfMsg.ShopItem.BuyLimit = false
- ntfMsg.ShopItem.EndTime = data.EndTime
- }
- }
- }
- //购买成功,给VIP经验
- //util.InfoF("uid=%v buy succ: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- this.role.ReplayGate(ntfMsg, true)
- this.addShopChange(Rune_Shop_Type_MonthCard)
- }
- func (this *RoleRune) SpecialPrivilegeReward() serverproto.ErrorCode {
- if this.runeBase.PrivilegeData == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- cfgData := this.getSpecialPrivilegeCfgData(this.runeBase.PrivilegeData.SpecialId)
- if cfgData == nil {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- if this.runeBase.PrivilegeData.RewardTime > 0 {
- return serverproto.ErrorCode_ERROR_PAY_SPECIALPRIVILEGE_HAS_REWARD
- }
- nowTime := util.GetTimeMilliseconds()
- this.runeBase.PrivilegeData.RewardTime = nowTime
- this.runeBase.PrivilegeData.ProcessTime = nowTime
- this.SetDirty(true)
- this.runeBaseDataChangeNtf()
- this.role.AddItemList(cfgData.VipReward, AddFrom_SpecialPrivilege, true)
- ackMsg := &serverproto.SCRuneSpecialPrivilegeRewardAck{}
- for k, v := range cfgData.VipReward {
- ackMsg.RewardItemList = append(ackMsg.RewardItemList, &serverproto.KeyValueType{
- Key: k,
- Value: v,
- })
- }
- this.role.ReplayGate(ackMsg, true)
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *RoleRune) OnBuyMonthCardShopItem(payRewardInfo *serverproto.PayOrderSaveInfo) {
- if payRewardInfo == nil {
- return
- }
- this.AddMonthCardItem(payRewardInfo.GoodsId, payRewardInfo.Count)
- //购买成功,给VIP经验
- util.InfoF("uid=%v buy succ: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- taskT := serverproto.TaskType_Eve_Month_Card
- if payRewardInfo.GoodsId == 2 {
- taskT = serverproto.TaskType_Eve_Month_Card_High
- }
- this.role.roleTask.AddTypeCnt(taskT, 1)
- TaskMagCheck(this.role, taskT, payRewardInfo.GoodsId)
- //ntfMsg := &serverproto.SCRuneShopBuyItemNtf{
- // ShopType: Rune_Shop_Type_MonthCard,
- // ShopItem: &serverproto.RuneShopItem{},
- // SubShop: 0,
- //}
- //
- //shopItemCfg, shopItemOk := model.ConvertMonthCard[payRewardInfo.GoodsId]
- //for _, data := range this.runeMonthCardShop.GoodsInfo {
- // if data.GoodsId == payRewardInfo.GoodsId {
- // //首次充值
- // if data.EndTime == 0 {
- // data.EndTime = (int64(util.GetCurrentTime()) + 29*24*3600*1000)
- // data.NextRewardTime = int64(util.GetLatest5Hour())
- //
- // //非续时,给邮件奖励
- // reward := make(map[int32]int32)
- // for _, item := range shopItemCfg.MailReward {
- // reward[item.Key] = item.Value
- // }
- //
- // if len(reward) > 0 {
- // this.role.GetRoleMail().AddMail(shopItemCfg.MailCfgId, serverproto.MailType_MailType_MonthCard,
- // reward, []int32{29}, "", "")
- // }
- // } else {
- // data.EndTime += 30 * 24 * 3600 * 1000 //30天d
- // }
- // data.BuyNum += payRewardInfo.Count
- // data.HistoryBuy += payRewardInfo.Count
- //
- // if shopItemOk {
- // ntfMsg.ShopItem.GoodsId = data.GoodsId
- // ntfMsg.ShopItem.Price = shopItemCfg.Price
- // ntfMsg.ShopItem.FirstBuy = false
- // ntfMsg.ShopItem.BuyNums = data.BuyNum
- // ntfMsg.ShopItem.BuyLimit = false
- // ntfMsg.ShopItem.EndTime = data.EndTime
- // }
- // }
- //}
- //
- ////购买成功,给VIP经验
- //util.InfoF("uid=%v buy succ: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- //
- //this.role.ReplayGate(ntfMsg, true)
- //this.addShopChange(Rune_Shop_Type_MonthCard)
- }
- // 给VIP经验
- func (this *RoleRune) OnBuyItemSuccess(payRewardInfo *serverproto.PayOrderSaveInfo) {
- ntfMsg := &serverproto.SCRuneShopBuyItemNtf{
- ShopItem: &serverproto.RuneShopItem{},
- }
- if payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_NormalBag) {
- goodCfg, ok := model.ConvertGiftBag[payRewardInfo.GoodsId]
- if !ok {
- return
- }
- _, ok1 := this.runeGiftShop[goodCfg.BagType]
- if !ok1 {
- return
- }
- ntfMsg.ShopType = Rune_Shop_Type_Bag
- ntfMsg.SubShop = goodCfg.BagType
- for _, goods := range this.runeGiftShop[goodCfg.BagType].GoodsInfo {
- if goods.GoodsId == payRewardInfo.GoodsId {
- goods.BuyNum += payRewardInfo.Count
- goods.HistoryBuy += payRewardInfo.Count
- //打包购买后商品信息
- ntfMsg.ShopItem.GoodsId = goods.GoodsId
- ntfMsg.ShopItem.Price = goodCfg.Price
- ntfMsg.ShopItem.FirstBuy = false
- if goodCfg.LimitCount >= 9999 {
- ntfMsg.ShopItem.BuyNums = 0
- ntfMsg.ShopItem.BuyLimit = false
- } else {
- var buyNum int32 = goodCfg.LimitCount - goods.BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- ntfMsg.ShopItem.BuyNums = buyNum
- ntfMsg.ShopItem.BuyLimit = true
- }
- ntfMsg.ShopItem.EndTime = 0
- this.addShopChange(Rune_Shop_Type_Bag)
- break
- }
- }
- } else if payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_LimitBag) {
- ntfMsg.ShopType = Rune_Shop_Type_TimeLimit
- for _, goods := range this.runeLimitShop.GoodsInfo {
- if goods.GoodsId == payRewardInfo.GoodsId {
- goods.BuyNum += payRewardInfo.Count
- goods.HistoryBuy += payRewardInfo.Count
- //打包购买后商品信息
- goodCfg, ok := model.ConvertLimitGag[payRewardInfo.GoodsId]
- if ok {
- ntfMsg.ShopItem.GoodsId = goods.GoodsId
- ntfMsg.ShopItem.Price = goodCfg.Price
- ntfMsg.ShopItem.FirstBuy = false
- if goodCfg.LimitCount >= 9999 {
- ntfMsg.ShopItem.BuyNums = 0
- ntfMsg.ShopItem.BuyLimit = false
- } else {
- var buyNum int32 = goodCfg.LimitCount - goods.BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- ntfMsg.ShopItem.BuyNums = buyNum
- ntfMsg.ShopItem.BuyLimit = true
- }
- ntfMsg.ShopItem.EndTime = 0
- if goodCfg.EndTime != 0 {
- ntfMsg.ShopItem.EndTime = goodCfg.EndTime
- } else {
- if goodCfg.LimitType == LimitType_StartServer {
- startUpTime := service.GetServiceStartupTime()
- if startUpTime > 0 {
- ntfMsg.ShopItem.EndTime = int64(startUpTime) + int64(goodCfg.EndDay-1)*24*3600*1000
- }
- } else if goodCfg.LimitType == LimitType_Activity {
- endTime := this.role.GetRoleActivity().ActivityHDRuneGoodsAdd(goodCfg.ActivityId)
- ntfMsg.ShopItem.EndTime = int64(endTime)
- } else if goodCfg.LimitType == LimitType_Competition {
- ntfMsg.ShopItem.EndTime = int64(this.role.roleCompetition.curCompInfo.CurEndTime)
- }
- }
- }
- this.addShopChange(Rune_Shop_Type_TimeLimit)
- break
- }
- }
- }
- util.InfoF("uid=%v buy succ: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- this.role.ReplayGate(ntfMsg, true)
- }
- // 爬塔、英灵殿、推图商店购买
- func (this *RoleRune) OnBuyRushShopSuccess(payRewardInfo *serverproto.PayOrderSaveInfo) {
- ntfMsg := &serverproto.SCRuneShopBuyItemNtf{
- ShopItem: &serverproto.RuneShopItem{},
- }
- var rushShop *serverproto.RuneShop = nil
- var goodCfg *model.RushShop = nil
- var ok bool = false
- var changedShop int32
- if payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushTower) {
- rushShop = this.runeRushTowerShop
- goodCfg, ok = model.ConvertTowerShop[payRewardInfo.GoodsId]
- changedShop = Rune_Shop_Type_RushTower
- } else if payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushArena) {
- goodCfg, ok = model.ConvertArenaShop[payRewardInfo.GoodsId]
- rushShop = this.runeRushArenaShop
- changedShop = Rune_Shop_Type_RushArena
- } else if payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushMap) {
- goodCfg, ok = model.ConvertMapShop[payRewardInfo.GoodsId]
- rushShop = this.runeRushMapShop
- changedShop = Rune_Shop_Type_RushMap
- } else if payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushPet) {
- goodCfg, ok = model.ConvertPetShop[payRewardInfo.GoodsId]
- rushShop = this.runeRushPetShop
- changedShop = Rune_Shop_Type_RushPet
- } else if payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushSkill) {
- goodCfg, ok = model.ConvertSkillShop[payRewardInfo.GoodsId]
- rushShop = this.runeRushSkillShop
- changedShop = Rune_Shop_Type_RushSkill
- }
- ntfMsg.ShopType = changedShop
- if rushShop == nil || !ok || goodCfg == nil {
- //严重报错
- return
- }
- for _, goods := range rushShop.GoodsInfo {
- if goods.GoodsId == payRewardInfo.GoodsId {
- goods.BuyNum += payRewardInfo.Count
- goods.HistoryBuy += payRewardInfo.Count
- //打包购买后商品信息
- ntfMsg.ShopItem.GoodsId = goods.GoodsId
- ntfMsg.ShopItem.Price = goodCfg.Price
- ntfMsg.ShopItem.FirstBuy = false
- if goodCfg.LimitCount >= 9999 {
- ntfMsg.ShopItem.BuyNums = 0
- ntfMsg.ShopItem.BuyLimit = false
- } else {
- var buyNum int32 = goodCfg.LimitCount - goods.BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- ntfMsg.ShopItem.BuyNums = buyNum
- ntfMsg.ShopItem.BuyLimit = true
- }
- ntfMsg.ShopItem.EndTime = 0
- break
- }
- }
- if payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushMap) {
- if goodCfg.Score != 0 {
- this.role.GetRoleBattle().OnRushMapScoreChange(0, goodCfg.Score)
- }
- }
- this.addShopChange(changedShop)
- util.InfoF("uid=%v rush shop buy succ: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- this.role.ReplayGate(ntfMsg, true)
- }
- // 爬塔、英灵殿、推图商店购买
- func (this *RoleRune) OnBuyGuildBattleSuccess(payRewardInfo *serverproto.PayOrderSaveInfo) {
- ntfMsg := &serverproto.SCRuneShopBuyItemNtf{
- ShopItem: &serverproto.RuneShopItem{},
- }
- var rushShop *serverproto.RuneShop = nil
- var goodCfg *model.RushShop = nil
- var ok bool = false
- var changedShop int32
- if payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_GuildBattle) {
- ntfMsg.ShopType = Rune_Shop_Type_GuildBattle
- rushShop = this.runeGuildBattleShop
- goodCfg, ok = model.ConvertGuildBattle[payRewardInfo.GoodsId]
- changedShop = Rune_Shop_Type_GuildBattle
- }
- if rushShop == nil || !ok || goodCfg == nil {
- util.ErrorF("uid=%v buy guildbattle shop failed : shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- //严重报错
- return
- }
- for _, goods := range rushShop.GoodsInfo {
- if goods.GoodsId == payRewardInfo.GoodsId {
- goods.BuyNum += payRewardInfo.Count
- goods.HistoryBuy += payRewardInfo.Count
- //打包购买后商品信息
- ntfMsg.ShopItem.GoodsId = goods.GoodsId
- ntfMsg.ShopItem.Price = goodCfg.Price
- ntfMsg.ShopItem.FirstBuy = false
- if goodCfg.LimitCount >= 9999 {
- ntfMsg.ShopItem.BuyNums = 0
- ntfMsg.ShopItem.BuyLimit = false
- } else {
- var buyNum int32 = goodCfg.LimitCount - goods.BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- ntfMsg.ShopItem.BuyNums = buyNum
- ntfMsg.ShopItem.BuyLimit = true
- }
- ntfMsg.ShopItem.EndTime = 0
- break
- }
- }
- this.addShopChange(changedShop)
- util.InfoF("uid=%v guildbattle shop buy succ: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- this.role.ReplayGate(ntfMsg, true)
- }
- func (this *RoleRune) OnBuyIdolSeasonSuccess(payRewardInfo *serverproto.PayOrderSaveInfo) {
- ntfMsg := &serverproto.SCRuneShopBuyItemNtf{
- ShopItem: &serverproto.RuneShopItem{},
- }
- var rushShop *serverproto.RuneShop = nil
- var goodCfg *model.RushShop = nil
- var ok bool = false
- var changedShop int32
- if payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushIdol) {
- rushShop = this.runeIdolSeasonShop
- goodCfg, ok = model.ConvertIdolShop[payRewardInfo.GoodsId]
- changedShop = Rune_Shop_Type_Idol
- }
- ntfMsg.ShopType = changedShop
- if rushShop == nil || !ok || goodCfg == nil {
- util.ErrorF("uid=%v buy idol season shop failed : shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- //严重报错
- return
- }
- for _, goods := range rushShop.GoodsInfo {
- if goods.GoodsId == payRewardInfo.GoodsId {
- goods.BuyNum += payRewardInfo.Count
- goods.HistoryBuy += payRewardInfo.Count
- //打包购买后商品信息
- ntfMsg.ShopItem.GoodsId = goods.GoodsId
- ntfMsg.ShopItem.Price = goodCfg.Price
- ntfMsg.ShopItem.FirstBuy = false
- if goodCfg.LimitCount >= 9999 {
- ntfMsg.ShopItem.BuyNums = 0
- ntfMsg.ShopItem.BuyLimit = false
- } else {
- var buyNum int32 = goodCfg.LimitCount - goods.BuyNum
- if buyNum < 0 {
- buyNum = 0
- }
- ntfMsg.ShopItem.BuyNums = buyNum
- ntfMsg.ShopItem.BuyLimit = true
- }
- ntfMsg.ShopItem.EndTime = 0
- break
- }
- }
- if goodCfg.Score > 0 {
- this.role.GetRoleCompetition().AddSeasonBoxScore(goodCfg.Score, true)
- }
- if goodCfg.Ticket > 0 {
- this.role.GetRoleCompetition().VoteIdol(this.role.GetUUid(), goodCfg.Ticket, false)
- }
- this.addShopChange(changedShop)
- util.InfoF("uid=%v idol season shop buy succ: shop:%v id:%v, count:%v,price:%v", this.role.GetUUid(), payRewardInfo.GoodsType, payRewardInfo.GoodsId, payRewardInfo.Count, payRewardInfo.Amount)
- this.role.ReplayGate(ntfMsg, true)
- }
- func (this *RoleRune) OnBuySpecialPrivilege(payRewardInfo *serverproto.PayOrderSaveInfo) {
- // 判断初级特权没领取的情况下,直接升级到高级特权
- oldSpecialId := this.runeBase.PrivilegeData.SpecialId
- if oldSpecialId != payRewardInfo.GoodsId && this.runeBase.PrivilegeData.RewardTime <= 0 {
- cfgData := this.getSpecialPrivilegeCfgData(oldSpecialId)
- if cfgData != nil {
- // 奖励邮件发送
- this.role.GetRoleMail().AddMail(model.GlobalMailSpecialPrivilegeCard, serverproto.MailType_MailType_SpecialPrivilege,
- cfgData.VipReward, nil, "", "")
- }
- }
- // 特权购买
- this.runeBase.PrivilegeData.SpecialId = payRewardInfo.GoodsId
- this.runeBase.PrivilegeData.RewardTime = 0
- this.runeBase.PrivilegeData.ProcessTime = util.GetTimeMilliseconds()
- this.SetDirty(true)
- cfgData := this.getSpecialPrivilegeCfgData(payRewardInfo.GoodsId)
- if cfgData == nil {
- util.ErrorF("uid=%v OnBuySpecialPrivilege cfgData not found=%v", this.role.GetUUid(), payRewardInfo.GoodsId)
- return
- }
- // 特权处理
- // 充值钱包额度,战斗内加速
- for k, v := range cfgData.VipRight {
- switch k {
- case model.Vip_System_FastBattleTime:
- // 解锁战斗加速功能
- // 客户端判定购买过特权卡就拥有加速功能
- case model.Vip_System_CreditRecharge:
- // 充值钱包额度(添加的数值)
- if v < 0 {
- // 无额度上限
- this.runeBase.CreditRechargeLimit = true
- } else {
- this.runeBase.MaxCreditRecharge += v
- }
- }
- }
- this.runeBaseDataChangeNtf()
- util.InfoF("uid=%v OnBuySpecialPrivilege GoodsId=%v success", this.role.GetUUid(), payRewardInfo.GoodsId)
- }
- func (this *RoleRune) GMAddCreditRecharge(val int32, limit bool) {
- if limit {
- this.runeBase.CreditRechargeLimit = true
- } else {
- this.runeBase.MaxCreditRecharge += val
- }
- this.SetDirty(true)
- this.runeBaseDataChangeNtf()
- }
- func (this *RoleRune) OnBuyPassCheck(payRewardInfo *serverproto.PayOrderSaveInfo) {
- if model.ConvertPassCheckData == nil {
- return
- }
- this.runeBase.IsPassCheck = true
- this.SetDirty(true)
- // 特权处理
- // 3.添加属性
- this.role.roleBattleAttr.AttrChange(AttrChangeST{
- ChangeType: Attr_Change_VipPrivilege,
- ChangeHeroData: this.role.GetRoleHero().GetMainHero(),
- })
- this.runeBaseDataChangeNtf()
- util.ErrorF("uid=%v OnBuyPassCheck GoodsId=%v", this.role.GetUUid(), payRewardInfo.GoodsId)
- }
|