| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300 |
- package model
- import (
- "errors"
- "fmt"
- "math"
- "math/rand"
- "reflect"
- _ "rocommon/rpc"
- "rocommon/service"
- "rocommon/util"
- "roserver/baseserver/model"
- "roserver/serverproto"
- "strings"
- "time"
- "unicode/utf8"
- )
- var TmpLeaseId int64 = 0
- type RoleOuter interface {
- model.StateMachine
- ReqAckConfirm(msgId, seqId uint32)
- SetOpenId(openId string)
- GetOpenId() string
- SetSelectZone(selectZone int32) //玩家当前选择的服务器,用户合服操作
- GetSelectZone() int32
- SetCliID(cId model.ClientID)
- SetCliIDSessionID(sessionID uint64)
- ReplayGate(msg interface{}, transmit bool) int
- GetUUid() uint64
- GetNickName() string
- GetImageId() int32
- KickNotSave(err int32)
- KickWithSave(err int32)
- LoginAck(err serverproto.ErrorCode)
- Load(role *serverproto.Role) error
- LoadOther(msg interface{}) error //load加载之后加载数据
- Update(ms uint64)
- DailyReset(notify bool)
- SetUpdateDailyReset(ms uint64, bReset bool)
- CliID() model.ClientID
- SetCreateData(msg *serverproto.CSCreateRoleReq)
- IsLogout(ms uint64) bool
- Logout()
- Save()
- SetReLogin(re bool)
- BanRole(isBan bool, banTime uint64, cheatType int32)
- BanRoleChat(isBan bool, banTime uint64, cheatType int32)
- SetPlatform(platform string)
- GetPlatform() string
- SetSubPlatform(subPlatform string)
- GetSubPlatform() string
- SetClientParam(clientInfo *serverproto.ClientParamInfo)
- GetClientParam() *NeteaseLogCommonInfo
- SetClientIP(ip string)
- GetClientIP() string
- GetHardFight() int
- SetHardFight(b int)
- SetYuanRankScore()
- SetSdkJson(a string)
- GetSdkJson() string
- }
- // 逻辑操作主接口(可以按照每个系统设定一个接口)
- type RoleLogicOuter interface {
- AddMoney(st AddItemST, add bool)
- AddBaseExp(st AddItemST) bool
- AddJobExp(st AddItemST) bool
- AddHeroExp(st AddItemST, add bool) bool
- AddAttrPoint(heroID int32, point interface{})
- AddRes(resType int32, st AddItemST, add bool)
- //AddItem(configId int32, count int32, addFrom int32)
- ResetAttrPoint(heroID int32)
- ActiveHead(headId int32)
- SetRoleHeadPic(headId int32)
- HeadInfoReq()
- SetRoleHeadFrameId(frameId int32)
- GetRoleHeadFrameInfo()
- UseHeadFrameItem(itemId uint64, itemNum uint32)
- ChangeRoleName(name string)
- SetRoleGuide(guideId int32)
- SetRoleStory(story *serverproto.KeyValueType)
- SetMapCartoon(id, status int32)
- OnAddQualityPoint(msg *serverproto.CSAddQualityPointReq)
- //hero
- AddHero(configId int32) bool
- HeroLevelUp(id int32) bool
- HeroAdvance(id int32) bool
- HeroBattle(id int32, isBattle bool)
- HeroStrength(id int32) bool
- HeroChangeJob(heroId int32, jobId int32) bool
- HeroRecruit(configId int32)
- FightPowerReq(heroId int32)
- HeroReplaceJob(heroId int32, replaceJob int32)
- //equip
- EquipForge(equipId, once, equipType, subEquipType int32)
- AddEquip(configId, num int32, notify bool, ignore bool)
- EquipUp(heroId, slotType, equipId int32)
- EquipDown(heroId int32, subIndex int32)
- EquipLevelUpAll(heroId int32)
- EquipSlotLevelUp(heroId, subSlotIndex int32)
- ComposeChip(configId int32)
- ChipDecompose(cardList []*serverproto.KeyValueType, cardType []int32)
- //skill equip
- SkillEquipSlotLevelUp(heroId, subIndex int32)
- SkillEquipStarLevelUp(heroId int32, skillEquipId uint32, cost []uint32)
- SkillEquipUp(heroId int32, skillEquipId uint32, slotIndex int32)
- SkillEquipDown(heroId int32, slotIndex int32)
- SkillEquipDecompose(skillEquipIds []uint32)
- SkillEquipRemade(skillEquipId uint32)
- GetSkillEquipPool()
- SkillEquipShift(msg *serverproto.CSSkillEquipShiftReq)
- //card
- CardMount(heroId, subSlotIndex, cardSlotIndex, cardCfgId int32)
- CardDown(heroId, subSlotIndex, cardSlotIndex int32)
- CardMountAll(msg *serverproto.CSCardEquipAllReq)
- CardDownAll(heroId int32)
- CardUpGradeAll(msg *serverproto.CSCardUpGradeAllReq)
- CardCollect()
- CardCollectReward(cardId, level int32)
- CardCompose(cardList []int32)
- CardDecompose(cardList []*serverproto.KeyValueType, cardType int32)
- CardUpGrade(msg *serverproto.CSCardUpGradeReq)
- CardLevelExchange(sourceCardId, targetCardId int32)
- //skill
- SkillReplace(heroId, idx, replaceSkillId int32)
- ActiveSkill(heroId int32, skillId int32)
- SwapSkill(heroId, firstSlotId, secondSlotId int32)
- SetSkillList(heroId int32, skillList []int32)
- SkillLevelUp(heroId int32, skillId int32)
- ResetSkillLevel(heroId int32, bsuper bool)
- ConverSkillExp(msg *serverproto.CSConverSkillExpReq)
- //fashion
- FashionUp(fashionCfgId []int32)
- FashionDown(fashionCfgId []int32)
- FashionCompose(paperCfgId int32)
- FashionPaperDecompose(paperCfgId int32)
- FashionResetAttr(fashionId int32, enter bool)
- FashionUpLvl(fashionId int32)
- //商店
- BuyItem(shopId, goodsId, goodsNum int32)
- ShopInfoReq(goodsType int32)
- ShopRefresh(goodsType int32)
- RedBagShopExchange()
- //task
- GetTaskReward(taskId uint32)
- GetTaskScoreReward(rewardType, rewardIdx int32)
- //item
- UseItem(itemId uint64, itemNum uint32, itemIdxList []int32, bForceItemId bool)
- DelItemByList(itemId []uint64, delFrom AddFromType)
- //chat
- CheckChatInvalid(targetId uint64, msgType int32, msg *serverproto.CSChatMessageReq) bool
- GetOfflineMsg(targetId uint64)
- //英灵殿
- GetArena()
- ArenaMatch(heroList []int32)
- ArenaResult(result int32)
- ArenaByCount(buyCount int32)
- ArenaRankList(rankType, startIdx int32)
- SetArenaRank(rankIdx int32, notify bool)
- //mail
- GetMailIst()
- MailRead(idList []int32)
- MailReward(idList []int32)
- MailDelRead()
- AddMail(configId int32, mailType serverproto.MailType, itemList map[int32]int32, paramList []int32,
- title, content string)
- AddMail1(configId int32, mailType int32, itemList []*serverproto.KeyValueType, paramList []int32,
- title, content string)
- //competition
- GetCompetition(competitionId int32) //competitionId为0表示获得当前正在进行的赛季
- CompetitionAddScore(itemList []*serverproto.KeyValueType) //上交道具获取积分
- VoteIdol(uid uint64, ticketCount int32)
- CheckInSeason() (serverproto.ErrorCode, int32)
- GetSelfVoteData(ackMsg *serverproto.SCCompetitionFansRewardRankAck)
- CheckFansReward(uid uint64, rewardLevel int32) serverproto.ErrorCode
- GetFansReward(idolUid uint64, rewardLevel int32, boxCount int32)
- CompulsoryGuidance(storyId, status int32) //强制引导
- //ClimbingTower 爬塔/无尽试炼
- ClimbingTowerInfoReq()
- GetFriendTowerInfo(begin, end int32)
- ClimbingTowerBegin(towerLevel int32)
- ClimbingTowerEnd(towerLevel, loadingTime int32, recordTimeStamp uint64)
- GetFriendBriefFromDB(final bool, begin int32, end int32, briefs []*serverproto.CommonPlayerBriefInfo)
- ClimbingTowerWjBegin(towerLevel int32)
- ClimbingTowerWjBuff(buff1, buff2, buff3 int32)
- ClimbingTowerWjEnd(towerLevel, loadingTime int32, recordTimeStamp uint64)
- //冲榜相关
- GetTowerFightCountReward(rushRound int32, rewardType int32)
- GetRushTowerInfo(ackMsg *serverproto.SCTowerActivityAck, curRushRound int32)
- GetRushTowerRankReward(ssAck *serverproto.SSGetRushRewardAck)
- GetArenaFightCountReward(rushRound int32, rewardType int32)
- GetRushArenaInfo(ackMsg *serverproto.SCArenaActivityAck, curRushRound int32)
- GetRushArenaRankReward(ssAck *serverproto.SSGetRushRewardAck)
- GetRushMapLevelReward(rushRound int32, rewardType int32)
- GetRushMapInfo(ackMsg *serverproto.SCMapActivityAck, curRushRound int32)
- GetRushMapRankReward(ssAck *serverproto.SSGetRushRewardAck)
- GetPetFightCountReward(rushRound int32, rewardType int32)
- GetRushPetInfo(ackMsg *serverproto.SCPetActivityAck, curRushRound int32)
- GetRushPetRankReward(ssAck *serverproto.SSGetRushRewardAck)
- GetFightCountReward(rushRound int32, rushType int32, rewardType int32)
- GetRushInfo(ackMsg *serverproto.SCRushActivityAck, curRushRound int32)
- GetRushRankReward(ssAck *serverproto.SSGetRushRewardAck)
- GetRushShopInfo(ackMsg *serverproto.SSGetRushShopInfoAck)
- //guild公会相关操作
- CheckBuildGuild(guildName string, guildBadge int32) serverproto.ErrorCode
- CheckApplyGuild(guildId uint64) bool
- CheckApplyInfo(msg *serverproto.CSApplyInfoHandleReq) serverproto.ErrorCode
- CheckGuildModifyInfo(msg *serverproto.CSSetGuildInfoReq) serverproto.ErrorCode
- CheckGuildRename(guildName string) serverproto.ErrorCode
- CheckGuildRenotice(notice string) serverproto.ErrorCode
- OnChangeGuileNameSuccess()
- CheckGuildBossChallenge(bossId uint32, damage uint32, fightTime uint32) serverproto.ErrorCode
- GetRoleGuildId() uint64
- GuildDemonBuyFightCount(buyCount int32)
- PackRoleViewInfo(info *serverproto.ViewRoleInfo)
- //获取战斗记录
- GetBattleRecord(recordType int32, paramList []uint32)
- //宠物
- PetLevelUp(petId uint32)
- PetAdvance(petId uint32, petList []uint32)
- PetManualReward(petCfgId, petId, advLevel int32)
- PetSkillLevelUp(petId uint32, costPetId uint32)
- PetDecompose(petIdList []uint32)
- PetBattle(battleList []*serverproto.KeyValueType)
- PetBondListGet()
- PetAssist(petIdList []uint32)
- PetBondAssistListGet(bondCfgId int32)
- PetBondActive(bondData []*serverproto.PetBondData)
- PetAdvAchievement(petCfgId int32)
- PetEquipLevelUp(petEquipId uint32)
- PetEquipUp(petId uint32, slotIndexList []*serverproto.KeyValueType)
- PetEquipDown(petId uint32, slotIndex int32)
- PetGetPetDetailInfo(petIdList []uint32)
- PetQiyueUnlock(heroId int32)
- PetQiyueSlotIn(heroId, slotIdx int32, petId uint32)
- PetQiyueSlotOut(heroId, slotIdx int32)
- PetQiyueBattlePetAttr()
- //精彩活动Activities
- ActivitiesReward(activityId, param, rewardNum int32)
- ActivitiesScoreReward(activityId, boxId int32)
- ActivitiesFirstChargeReward()
- ActivitiesExchange(msg *serverproto.CSActivitiesExchangeReq)
- ActivityWheelRefresh(activityId int32)
- ActivityWheelOpenReward(activityId int32)
- ActivityWheelReward(activityId int32, rewardAll bool)
- ActivityWheelClose(activityId int32)
- ActivitySummon(activityId, summonCount int32)
- ActivitySignIn(activityId int32)
- SetCollectionNotice(activityId int32, CollectId int32, notice bool)
- ActivitySmashEggs(activityId, drawType, drawCount int32)
- ActivitySmashEggsMsg(activityId, drawType int32)
- //invitation
- InvitationNumberGet()
- InvitationNumberUserInfoGet(number uint64)
- InvitationBeToMember(number, uid uint64)
- InvitationReward(taskIdList []uint32)
- InvitationClick(memberUidList []uint64)
- InvitationClickReplay(replayMasterUid uint64)
- InvitationDelMember(memberUidList []uint64)
- //vip等级获取
- GetRoleVipLevel() int32
- //pay
- CheckRushShopInfoGet(goodsType, goodsId, count int32) bool
- PayInfoGet(goodsType, goodsId, count int32, rushStage, rushRound int32, cpOrderId uint64, sdkOrderId string)
- OnPayCallback(payRewardInfo *serverproto.PayOrderSaveInfo, bSave bool, bAck bool)
- OnPayCallback2(cpOrderId uint64)
- CheckOrderInfo(payRewardInfo *serverproto.PayOrderSaveInfo) bool
- //卢恩商会
- GetRuneShopInfo(shopType int32, subShop int32)
- OnRuneExploreInfo()
- OnRuneMaxLvlAward()
- OnRuneReward(msg *serverproto.CSExploreRewardReq)
- //抽卡
- OnDrawReq(drawType int32, drawCount int32)
- GetResNotice(resType int32) serverproto.ErrorCode
- //百人道场
- GetDaoChang100SelfPosInfo(msg *serverproto.CSDaoChang100PlayerInfoReq)
- GetDaoChang100PosInfo(posIdxList []int32)
- GetDaoChang100Log(beginTime uint64)
- DaoChang100ChallengeReq(posIdx int32)
- DaoChang100TimeRewardReq()
- DaoChang100ChallengeResultReq(msg *serverproto.CSDaoChang100ChallengeResultReq)
- DaoChang100BuyChallengeCount()
- DaoChang100SetTips(tipDesc string)
- OnAntiCheatReq(cheatType int32)
- GiftReward(ackMsg *serverproto.SCGiftRewardAck)
- //问卷奖励获取
- QuestionReward()
- GetKeepSake()
- KeepSakeLevelUp(keepSakeId int32)
- // 称号操作
- OnHeadOperate(*serverproto.CSHeadOperateReq)
- OnHeadData(req *serverproto.CSHeadDataReq)
- // 许愿箱
- OnWishUse(*serverproto.CSWishBoxUseReq)
- OnWishSlotUnlock(*serverproto.CSWishUnlockSlotReq)
- OnWishSlotAction(req *serverproto.CSWishSlotReq)
- GetCombineServerInfo()
- }
- type BattleLogicOuter interface {
- //income
- Income()
- OnlineTimeReward() //累计在线时间奖励获取
- BossReward(challengeTime uint32, mapId, mapLevel uint32, recordTimeStamp uint64)
- BattleBossReq()
- //mapRank
- SetMapRank(selfRank, totalRanks uint32, topRankList []*serverproto.RankPlayerInfo, addSystemMsg bool)
- GetMapRank()
- GetQuickBattleReward()
- //Evil
- BattleEvilRefresh(bForce bool)
- BattleEvilChallenge(posIdx int32)
- //expedition
- ExpeditionChallengePre(expeditionType int32)
- ExpeditionChallenge(expeditionType, battleLevel int32, heroInfoList []*serverproto.BattleExpeditionActor,
- bossChangeHpList []*serverproto.BattleExpeditionActor, battleTime int32, bossIdx, flag int32)
- ExpeditionBuffSelect(selectBuf int32)
- ExpeditionReward(expeditionType, boxIdx int32)
- ExpeditionBattleHero(battleHeroList []int32)
- ExpeditionCallForHelp(assistHelpUid uint64)
- ExpeditionHelp(beHelpedUid uint64, msgType int32, helpMsgSendTime uint64)
- ExpeditionScoreRankList(startIdx int32)
- //actor attr(获取英雄属性,宠物属性)
- GetActorAttr(reqMsg *serverproto.CSActorAttrGetReq)
- }
- type CrossLogicOuter interface {
- //远航试炼
- YuanHangTrialViewList()
- //刷新远航试炼品质
- RefreshYuanHangTrialType(force bool)
- //发起远航试炼
- YuanHangTrial()
- YuanHangTrialReward()
- YuanHangTrialChallenge(challengeUid, challengeUidEndTime uint64)
- YuanHangTrialChallengeBuy()
- YuanHangTrialChallengeResult(msg *serverproto.CSCrossYuanHangTrialChallengeResultReq)
- YuanHangTrialInfoQuery(trialUid, trialEndTime uint64)
- YuanHangTrialLog(logTime uint64)
- //from router
- OnYuanHangTrialChallengeResult(msg *serverproto.SSCrossYuanHangTrialChallengeResultAck)
- YuanHangTrialRankList(startIdx int32)
- //巅峰之塔
- //获取挑战列表
- TopTowerFightListReq()
- //战斗结果通知
- TopTowerChallengeResultReq(bWin bool, fightIdx int32)
- //买路操作(直接胜利)
- TopTowerForceWinReq(fightIdx int32)
- }
- // //全局跨服地图相关
- type RoleCrossMapRouter interface {
- PlayerEnterMap(msg *serverproto.CSGCrossPlayerEnterMapReq)
- PlayerLeave(msg *serverproto.CSGCrossPlayerLeaveMapReq)
- PlayerMoveSync(msg *serverproto.CSGCrossPlayerMapSyncPosReq)
- PlayerSyncParam(msg *serverproto.CSGCrossPlayerMapSyncParamReq)
- //获取玩家地图展示信息
- GetPlayerMapShowInfo() *serverproto.PlayerShowInfo
- }
- // // bt服务器版本使用
- type RoleBTRouter interface {
- // 充值钱包商店购买(假钱购买)
- PayInfoGetForCreditRecharge(goodsId, count int32)
- // 特权卡商店每日礼包领取
- SpecialPrivilegeReward()
- // 充值钱包商店,Ro币礼包商店
- GetBTShopInfo(shopType int32, subShop int32)
- // Ro币礼包商店购买(消耗RO币)
- PayInfoGetForRoCoin(goodsId, count int32)
- // 获取爬塔馈赠奖励
- GetTowerLevelDayReward()
- // 波利商城
- BoliShopInfo()
- BoliLevelUp(num int32)
- BoliReward(RewardLevel, idx int32)
- BoliShopBuy(goodsId, num int32)
- //超值首充 & 百元大礼包
- FirstRechargeReward(rewardIdx int32)
- Recharge100Reward()
- }
- type RoleSaveObject interface {
- Load(msg interface{}) bool
- Save()
- IsDirty() bool
- SetDirty(b bool)
- }
- const (
- SLOT_NUM = 4 //4个上阵位置
- SLOT_TYPE_NUM = Equip_Type_Max - 1
- SKILL_EQUIP_SLOT_TYPE_NUM = Skill_Equip_Type_Max - 1
- )
- // 任务唯一id
- var timeWheelKeyUid uint64 = 1
- type SaveObject struct {
- isDirty bool
- role *Role
- }
- func (this *SaveObject) IsDirty() bool {
- return this.isDirty
- }
- func (this *SaveObject) SetDirty(b bool) {
- if this.isDirty == b {
- return
- }
- this.isDirty = b
- if this.isDirty {
- if this.role.twTask == nil {
- timeWheelKeyUid++
- this.role.twTask = &util.TWTask{
- Uid: this.role.GetUUid(),
- Key: timeWheelKeyUid, //任务唯一id
- CallbackType: util.TWTASK_TYPE_Save, //表示save操作
- Delay: 20,
- }
- }
- RoleMag.tw.AddTask(this.role.twTask)
- }
- }
- type Role struct {
- model.StateMachineCore
- soList []RoleSaveObject
- //在upate中标记是否需要重置,随后再每个玩家自身的update中进行reset操作,降低
- //同一时间的reset操作次数
- dailyResetTimer util.OnceTimer
- twTask *util.TWTask
- mysqlLogList []*serverproto.SSRoleLogData //mysql数据保存
- mysqlLogSaveTimer util.DurationTimer
- reqAckConfirmList map[uint32][]uint32
- cliID model.ClientID //在Gate上的信息
- dbNode string //选择处理信息的db节点
- socialNode string //选择处理信息的social节点
- //aoiNode string //aoi服务器节点(工会主城只会有一个)
- bossNode string //BattleBoss服务器节点
- rankNode string //Rank服务器节点
- guildNode string //Guild服务器接点
- platform string //平台
- subPlatform string //平台对应不同分发媒体
- clientParamInfo *NeteaseLogCommonInfo //客户端上报信息
- clientIp string //客户端IP
- tmpState bool //临时控制使用
- selectZone int32 ////玩家当前选择的服务器,用户合服操作
- uuid uint64 //Role的用户ID
- openId string //平台账号
- RegisterTime uint64 //注册时间
- UuidList []uint64 //用户拥有的所有角色ID
- UuidRoleList map[uint64]*serverproto.AccountRole //用户拥有的所有角色数据AccountRole
- SelectedUuid uint64 //用户选择的角色ID
- reLogin bool //是否是重新登陆
- isLoad bool //是否已经加载过
- activeCode string //激活码
- isHardFight int //是否是困难模式 //0普通.1困难,2噩梦
- Guid string //小七uid
- base *RoleBase //角色基础信息
- roleHero *RoleHero //伙伴信息
- roleBag *RoleBag //角色背包信息
- roleEquip *RoleEquip //装备信息
- roleChip *RoleChip //英雄碎片信息
- roleMap *RoleMap //地图信息
- roleSkill *RoleSkill //技能信息
- roleCard *RoleCard //卡片系统
- roleFashion *RoleFashion //时装
- roleBattle *RoleBattle //战斗相关信息
- roleTask *RoleTask //任务系统
- roleChat *RoleChat
- roleArena *RoleArena //竞技场
- roleRed *RoleRed //小红点
- roleMail *RoleMail //邮件
- roleShop *RoleShop //
- roleCompetition *RoleCompetition //赛季
- roleSocial *RoleSocial //social相关(friend)
- roleActivity *RoleActivity //活动信息
- roleTower *RoleTower //爬塔
- roleGuild *RoleGuild //公会
- rolePet *RolePet //宠物
- roleInvitation *RoleInvitation //邀请码功能
- roleDraw *RoleDraw //抽取系统
- roleRune *RoleRune //卢恩商店
- roleDaoChang100 *RoleDaoChang100 //百人道场
- roleStatistic *RoleStatistic //统计数据
- roleKeepSake *RoleKeepSake
- roleSkillEquip *RoleSkillEquip //神器系统
- roleCross *RoleCross //跨服数据
- roleRush *RoleRush //跨服数据
- roleBattleAttr *RoleBattleAttr //战斗属性计算,每个玩法的属性都放到该类中处理
- roleHead *RoleHead // 称号数据
- roleWish *RoleWishBox // 许愿箱
- roleBT *RoleBT // bt版本数据
- delete bool
- delete1 bool
- delete2 bool
- saveTimer util.DurationTimer //保存数据定时器
- offlineTimer util.OnceTimer //离线定时器
- lastProcessTime uint64 //无数据操作
- }
- var roleSaveTimeout time.Duration = 500 //保存数据的间隔时间
- var roleOfflineTimeout time.Duration = 30 * 60 * 1000 //
- var mysqlSaveTimeout time.Duration = 2000
- func NewRole(cId model.ClientID) RoleOuter {
- role := &Role{
- reqAckConfirmList: map[uint32][]uint32{},
- cliID: cId,
- uuid: 0,
- reLogin: false,
- }
- //初始化角色信息
- role.Init()
- return role
- }
- func (this *Role) Init() {
- this.UuidRoleList = map[uint64]*serverproto.AccountRole{}
- //初始化角色状态机
- this.InitState()
- this.RegisterState(int32(ROLE_STATE_PULLING_LIST), pullingRoleList)
- this.RegisterState(int32(ROLE_STATE_PULLED_LIST), pulledRoleList)
- this.RegisterState(int32(ROLE_STATE_CREATE), createRole)
- this.RegisterState(int32(ROLE_STATE_DB_ADD_ROLE_SUCCESS), createDbRoleSuccess)
- this.RegisterState(int32(ROLE_STATE_DB_ADD_ROLE_FAILURE), createDbRoleFailure)
- this.RegisterState(int32(ROLE_STATE_SELECT_ROLE), SelectingRole)
- this.RegisterState(int32(ROLE_STATE_SELECT_ROLE_SUCCESS), SelectRoleSuccess)
- this.RegisterState(int32(ROLE_STATE_ONLINE), RoleOnline)
- this.RegisterState(int32(ROLE_STATE_OFFLINE), RoleOffline)
- this.roleBattleAttr = newRoleBattleAttr(this)
- //this.base = roleBasePool.Get().(*RoleBase)
- this.base = newRoleBase()
- this.base.role = this
- this.roleHero = newRoleHero(this)
- this.roleBag = newRoleBag(this)
- this.roleEquip = newRoleEquip(this)
- this.roleChip = newRoleChip(this)
- this.roleMap = newRoleMap(this)
- this.roleSkill = newRoleSkill(this)
- this.roleCard = newRoleCard(this)
- this.roleFashion = newRoleFashion(this)
- this.roleBattle = newRoleBattle(this)
- this.roleTask = newRoleTask(this)
- //this.roleFightPower = newRoleFightPower(this)
- this.roleChat = newRoleChat(this)
- this.roleArena = newRoleArena(this)
- this.roleMail = newRoleMail(this)
- this.roleRed = newRoleRed(this)
- this.roleShop = newRoleShop(this)
- this.roleCompetition = newRoleCompetition(this)
- this.roleSocial = newRoleSocial(this)
- this.roleActivity = newRoleActivity(this)
- this.roleTower = newRoleTower(this)
- this.roleGuild = newRoleGuild(this)
- this.rolePet = newRolePet(this)
- this.roleInvitation = newRoleInvitation(this)
- this.roleDraw = newRoleDraw(this)
- this.roleRune = newRoleRune(this)
- this.roleDaoChang100 = newRoleDaoChang100(this)
- this.roleStatistic = newRoleStatistic(this)
- this.roleKeepSake = newRoleKeepSake(this)
- this.roleCross = newRoleCross(this)
- this.roleRush = newRoleRush(this)
- this.roleSkillEquip = newRoleSkillEquip(this)
- this.roleHead = newRoleHead(this)
- this.roleWish = newRoleWish(this)
- this.roleBT = newRoleBT(this)
- this.soList = append(this.soList,
- this.base,
- this.roleHero,
- this.roleBag,
- this.roleCard,
- this.roleEquip,
- this.roleChip,
- this.roleMap,
- this.roleMap,
- this.roleSkill,
- this.roleFashion,
- this.roleBattle,
- this.roleTask,
- this.roleChat,
- this.roleArena,
- this.roleMail,
- this.roleRed,
- this.roleShop,
- this.roleCompetition,
- this.roleSocial,
- this.roleActivity,
- this.roleTower,
- this.roleGuild,
- this.rolePet,
- this.roleInvitation,
- this.roleDraw,
- this.roleRune,
- this.roleDaoChang100,
- this.roleStatistic,
- this.roleKeepSake,
- this.roleRush,
- this.roleCross,
- this.roleSkillEquip,
- this.roleHead,
- this.roleWish,
- this.roleBT,
- )
- }
- //func (this *Role) SetIsChallenge(b bool) {
- // this.isChallenge = b
- //}
- //
- //func (this *Role) GetIsChallenge() bool {
- // return this.isChallenge
- //}
- func (this *Role) ReqAckConfirm(msgId, seqId uint32) {
- this.reqAckConfirmList[msgId] = append(this.reqAckConfirmList[msgId], seqId)
- }
- func (this *Role) SetOpenId(openId string) {
- this.openId = openId
- }
- func (this *Role) GetOpenId() string {
- return this.openId
- }
- func (this *Role) GetHardFight() int {
- return this.isHardFight
- }
- func (this *Role) GetSdkJson() string {
- return this.Guid
- }
- func (this *Role) SetSdkJson(a string) {
- this.Guid = a
- }
- func (this *Role) SetSelectZone(selectZone int32) {
- if selectZone <= 0 {
- this.selectZone = int32(service.GetServiceConfig().Node.Zone)
- } else {
- this.selectZone = selectZone
- }
- }
- func (this *Role) GetSelectZone() int32 {
- return this.selectZone
- }
- func (this *Role) SetPlatform(platform string) {
- this.platform = platform
- }
- func (this *Role) SetHardFight(b int) {
- this.isHardFight = b
- }
- func (this *Role) SetYuanRankScore() {
- this.roleCross.roleCrossInfo.Yuanhangtrial.TrialScore = 0
- this.roleCross.selfRank = 0
- this.roleCross.selfScore = 0
- this.roleCross.totalRank = 0
- }
- func (this *Role) GetPlatform() string {
- return this.platform
- }
- func (this *Role) SetSubPlatform(subPlatform string) {
- this.subPlatform = subPlatform
- }
- func (this *Role) GetSubPlatform() string {
- return this.subPlatform
- }
- func (this *Role) SetClientParam(clientInfo *serverproto.ClientParamInfo) {
- if clientInfo == nil {
- return
- }
- if this.clientParamInfo == nil {
- this.clientParamInfo = &NeteaseLogCommonInfo{}
- }
- this.clientParamInfo.DeviceModel = clientInfo.DeviceModel
- this.clientParamInfo.DeviceHeight = int(clientInfo.DeviceHeight)
- this.clientParamInfo.DeviceWidth = int(clientInfo.DeviceWidth)
- this.clientParamInfo.OsName = clientInfo.OsName
- this.clientParamInfo.OsVer = clientInfo.OsVer
- this.clientParamInfo.MacAddr = clientInfo.MacAddr
- this.clientParamInfo.Udid = clientInfo.Udid
- this.clientParamInfo.Isp = clientInfo.Isp
- this.clientParamInfo.Network = clientInfo.Network
- this.clientParamInfo.AppChannel = clientInfo.AppChannel
- this.clientParamInfo.AppVer = clientInfo.AppVer
- this.clientParamInfo.TransId = clientInfo.TransId
- this.clientParamInfo.UnisdkDeviceId = clientInfo.UnisdkDeviceid
- this.clientParamInfo.IsEmulator = int(clientInfo.IsEmulator)
- this.clientParamInfo.IsRoot = int(clientInfo.IsRoot)
- this.clientParamInfo.AccountId = clientInfo.AccountId
- this.clientParamInfo.OldAccountId = clientInfo.OldAccountid
- this.clientParamInfo.IMEI = clientInfo.IMEI
- this.clientParamInfo.CountryCode = clientInfo.CountryCode
- this.clientParamInfo.EnterSN = clientInfo.EnterSn
- this.clientParamInfo.OAid = clientInfo.Oaid
- this.clientParamInfo.EngineVer = clientInfo.EngineVer
- this.clientParamInfo.Server = service.GetServiceConfig().Node.Zone*100 + service.GetServiceConfig().Node.Id
- }
- func (this *Role) GetClientParam() *NeteaseLogCommonInfo {
- return this.clientParamInfo
- }
- func (this *Role) SetClientIP(ip string) {
- this.clientIp = ip
- if this.clientParamInfo == nil {
- this.clientParamInfo = &NeteaseLogCommonInfo{}
- }
- ipStr := this.GetClientIP()
- //先区分是否是IPV6
- strList := strings.Split(ipStr, ":")
- if len(strList) == 2 {
- this.clientParamInfo.IPv4 = strList[0]
- } else if len(strList) > 2 {
- position := strings.LastIndex(ipStr, ":")
- this.clientParamInfo.Ipv6 = ipStr[1 : position-1]
- }
- }
- func (this *Role) GetClientIP() string {
- return this.clientIp
- }
- func (this *Role) DBNode() string {
- return this.dbNode
- }
- func (this *Role) SocialNode() string {
- return this.socialNode
- }
- func (this *Role) AoiNode() string {
- //return this.aoiNode
- return ""
- }
- func (this *Role) BossNode() string {
- return this.bossNode
- }
- func (this *Role) RankNode() string {
- return this.rankNode
- }
- func (this *Role) GuildNode() string {
- return this.guildNode
- }
- func (this *Role) CliID() model.ClientID {
- return this.cliID
- }
- func (this *Role) SetCliID(cId model.ClientID) {
- this.cliID = cId
- }
- func (this *Role) SetCliIDSessionID(sessionID uint64) {
- this.cliID.SessID = sessionID
- }
- func (this *Role) setUUid(id uint64) {
- this.uuid = id
- }
- func (this *Role) GetUUid() uint64 {
- return this.uuid
- }
- func (this *Role) GetNickName() string {
- return this.GetRoleBase().GetRoleName()
- }
- func (this *Role) GetImageId() int32 {
- return this.GetRoleBase().RoleData().HeadId
- }
- func (this *Role) SetSelectUUid(id uint64) {
- this.SelectedUuid = id
- if data, ok := this.UuidRoleList[id]; ok {
- this.RegisterTime = data.RegisterTime
- }
- }
- func (this *Role) SetReLogin(re bool) {
- this.reLogin = re
- if re {
- this.isHardFight = 0
- }
- }
- func (this *Role) GetRoleBase() *RoleBase {
- return this.base
- }
- func (this *Role) GetRoleBag() *RoleBag {
- return this.roleBag
- }
- func (this *Role) GetRoleEquip() *RoleEquip {
- return this.roleEquip
- }
- func (this *Role) GetRoleHero() *RoleHero {
- return this.roleHero
- }
- func (this *Role) GetRoleChip() *RoleChip {
- return this.roleChip
- }
- func (this *Role) GetRoleMap() *RoleMap {
- return this.roleMap
- }
- func (this *Role) GetRoleSkill() *RoleSkill {
- return this.roleSkill
- }
- func (this *Role) GetRoleSkillEquip() *RoleSkillEquip {
- return this.roleSkillEquip
- }
- func (this *Role) GetRoleCard() *RoleCard {
- return this.roleCard
- }
- func (this *Role) GetRoleFashion() *RoleFashion {
- return this.roleFashion
- }
- func (this *Role) GetRoleBattle() *RoleBattle {
- return this.roleBattle
- }
- func (this *Role) GetRoleChat() *RoleChat {
- return this.roleChat
- }
- func (this *Role) GetRoleArena() *RoleArena {
- return this.roleArena
- }
- func (this *Role) GetRoleRed() *RoleRed {
- return this.roleRed
- }
- func (this *Role) GetRoleMail() *RoleMail {
- return this.roleMail
- }
- func (this *Role) GetRoleCompetition() *RoleCompetition {
- return this.roleCompetition
- }
- func (this *Role) GetRoleShop() *RoleShop {
- return this.roleShop
- }
- func (this *Role) GetRoleSocial() *RoleSocial {
- return this.roleSocial
- }
- func (this *Role) GetRoleTask() *RoleTask {
- return this.roleTask
- }
- // func (this *Role) GetRoleFightPower1() *RoleFightPower {
- // return this.roleFightPower
- // }
- func (this *Role) GetRoleActivity() *RoleActivity {
- return this.roleActivity
- }
- func (this *Role) GetRoleTower() *RoleTower {
- return this.roleTower
- }
- func (this *Role) GetRoleGuild() *RoleGuild {
- return this.roleGuild
- }
- func (this *Role) GetRolePet() *RolePet {
- return this.rolePet
- }
- func (this *Role) GetRoleInvitation() *RoleInvitation {
- return this.roleInvitation
- }
- func (this *Role) GetRoleDraw() *RoleDraw {
- return this.roleDraw
- }
- func (this *Role) GetRoleRune() *RoleRune {
- return this.roleRune
- }
- func (this *Role) GetRoleDaoChang100() *RoleDaoChang100 {
- return this.roleDaoChang100
- }
- func (this *Role) GetRoleStatistic() *RoleStatistic {
- return this.roleStatistic
- }
- func (this *Role) GetRoleKeepSake() *RoleKeepSake {
- return this.roleKeepSake
- }
- func (this *Role) GetRoleCross() *RoleCross {
- return this.roleCross
- }
- func (this *Role) GetRoleRush() *RoleRush {
- return this.roleRush
- }
- func (this *Role) GetRoleBT() *RoleBT {
- return this.roleBT
- }
- func (this *Role) SetCreateData(msg *serverproto.CSCreateRoleReq) {
- this.base.roleBase.Sex = msg.Sex
- this.base.roleBase.Country = msg.Country
- //JobId
- this.base.roleBase.RoleData.HeroData.ConfigId = msg.JobId
- this.base.roleBase.FashionData.Hair = msg.Hair
- this.base.roleBase.FashionData.HairAvatar = msg.HairAvatar
- this.base.roleBase.FashionData.Eye = msg.Eye
- if msg.Head != 0 {
- this.base.roleBase.FashionData.FashionUpList =
- append(this.base.roleBase.FashionData.FashionUpList, msg.Head)
- }
- this.activeCode = msg.ActiveCode
- }
- func (this *Role) IsLogout(ms uint64) bool {
- return this.offlineTimer.IsStart() && this.offlineTimer.IsExpired(ms)
- }
- func (this *Role) isBan() uint64 {
- if this.GetRoleBase().roleBase != nil && this.GetRoleBase().roleBase.BanTime > uint64(util.GetTimeSeconds()) {
- delTime := this.GetRoleBase().roleBase.BanTime - uint64(util.GetTimeSeconds())
- return delTime
- }
- return 0
- }
- func (this *Role) BanRole(isBan bool, banTime uint64, cheatType int32) {
- if this.GetRoleBase().roleBase == nil {
- util.InfoF("BanRole isBan=%v err=rolebase is nil", isBan)
- return
- }
- if banTime <= 0 {
- banTime = 24 * 60 * 60
- }
- if isBan {
- this.GetRoleBase().roleBase.BanTime = uint64(util.GetTimeSeconds()) + banTime
- this.GetRoleBase().roleBase.BanType = cheatType
- this.GetRoleBase().SetDirty(true)
- //作弊方式封号
- ssMsg := &serverproto.SSGameBanRoleNtf{
- BanUid: this.GetUUid(),
- BanEndTime: this.GetRoleBase().roleBase.BanTime,
- BanType: 1, //1封号,2禁言
- }
- this.SendDb(ssMsg)
- errCode := this.roleStatistic.GetCheatErrorCode(cheatType)
- this.KickWithSaveAndBan(errCode, banTime)
- } else {
- if this.GetRoleBase().roleBase.BanTime > 0 {
- this.GetRoleBase().roleBase.BanTime = 0
- this.GetRoleBase().roleBase.BanType = 0
- this.GetRoleBase().SetDirty(true)
- //清空作弊数据
- if this.GetRoleStatistic() != nil {
- this.GetRoleStatistic().ClearCheatData()
- }
- }
- }
- }
- // 禁言
- func (this *Role) BanRoleChat(isBan bool, banTime uint64, cheatType int32) {
- if this.GetRoleBase().roleBase == nil {
- util.InfoF("BanRole isBan=%v err=rolebase is nil", isBan)
- return
- }
- if banTime <= 0 {
- banTime = 24 * 60 * 60
- }
- if isBan {
- this.GetRoleBase().roleBase.ChatBanTime = uint64(util.GetTimeSeconds()) + banTime
- this.GetRoleBase().roleBase.ChatBanType = cheatType
- this.GetRoleBase().SetDirty(true)
- //禁言
- ssMsg := &serverproto.SSGameBanRoleNtf{
- BanUid: this.GetUUid(),
- BanEndTime: this.GetRoleBase().roleBase.BanTime,
- BanType: 2, //1封号,2禁言
- }
- this.SendDb(ssMsg)
- util.InfoF("uid=%v BanRoleChat endtime=%v", this.GetUUid(), this.GetRoleBase().roleBase.ChatBanTime)
- } else {
- if this.GetRoleBase().roleBase.ChatBanTime > 0 {
- this.GetRoleBase().roleBase.ChatBanTime = 0
- this.GetRoleBase().roleBase.ChatBanType = 0
- this.GetRoleBase().SetDirty(true)
- //清空作弊数据
- if this.GetRoleStatistic() != nil {
- this.GetRoleStatistic().ClearCheatData()
- }
- }
- }
- }
- // 来自gmweb的删除背包道具操作
- func (this *Role) WebGMDelItem(delItemList []*serverproto.KeyValueType) {
- util.InfoF("uid=%v WebGMDelItem delitemlist=%v", this.uuid, delItemList)
- for idx := 0; idx < len(delItemList); idx++ {
- this.GetRoleBag().DelItem(delItemList[idx].Key, delItemList[idx].Value, AddItemST{
- AddFrom: AddFrom_System,
- })
- }
- }
- func (this *Role) KickNotSave(err int32) {
- //通知gate踢人,并且不再反向通知logic服务器
- kickNtf := &serverproto.SSUserKickNtf{
- Error: err,
- ClientId: this.CliID().SessID,
- }
- this.ReplayGate(kickNtf, false)
- util.InfoF("uid=%v sessionID=%v KickNotSave game kick user err=%v", this.GetUUid(), this.CliID().SessID, err)
- this.SwitchState(ROLE_STATE_ZOMBIE, nil)
- }
- func (this *Role) KickWithSave(err int32) {
- //通知gate踢人,并且不再反向通知logic服务器
- kickNtf := &serverproto.SSUserKickNtf{
- Error: err,
- ClientId: this.CliID().SessID,
- }
- this.ReplayGate(kickNtf, false)
- util.InfoF("uid=%v sessionID=%v KickWithSave game kick user err=%v", this.GetUUid(), this.CliID().SessID, err)
- this.SwitchState(ROLE_STATE_OFFLINE, nil)
- }
- func (this *Role) KickWithSaveAndBan(err int32, banEndTime uint64) {
- //通知gate踢人,并且不再反向通知logic服务器
- kickNtf := &serverproto.SSUserKickNtf{
- Error: err,
- ClientId: this.CliID().SessID,
- BanEndTime: banEndTime,
- }
- this.ReplayGate(kickNtf, false)
- util.InfoF("uid=%v sessionID=%v KickWithSaveAndBan game kick user", this.GetUUid(), this.CliID().SessID)
- this.SwitchState(ROLE_STATE_OFFLINE, nil)
- }
- func (this *Role) Load(role *serverproto.Role) error {
- if this.reLogin && this.isLoad {
- //已经加载过
- return nil
- }
- //每个系统类型信息加载
- for _, data := range this.soList {
- if !data.Load(role) {
- return errors.New(fmt.Sprintf("uid=%v load savedObject module=%v failed",
- this.GetUUid(), reflect.TypeOf(data).Elem().Name()))
- }
- }
- this.isLoad = true
- return nil
- }
- func (this *Role) LoadOther(msg interface{}) error {
- //主角基本数据还未加载
- if !this.isLoad {
- return nil
- }
- switch m := msg.(type) {
- //在登陆流程中
- case *serverproto.SSLoadArenaNtf:
- if this.roleArena != nil {
- if !this.roleArena.LoadOther(m.RoleArena) {
- return errors.New(fmt.Sprintf("uid=%v load SSLoadArenaNtf failed", this.GetUUid()))
- }
- }
- case *serverproto.SSLoadMailNtf:
- if this.roleMail != nil {
- if !this.roleMail.LoadOther(m.Mail) {
- return errors.New(fmt.Sprintf("uid=%v load SSLoadMailNtf failed", this.GetUUid()))
- }
- }
- case *serverproto.SSLoadFriendDataNtf:
- if this.roleSocial != nil {
- if !this.roleSocial.LoadOther(m.Friend) {
- return errors.New(fmt.Sprintf("uid=%v SSLoadFriendDataNtf failed", this.GetUUid()))
- }
- }
- case *serverproto.SSLoadPetNtf:
- if this.rolePet != nil {
- if !this.rolePet.LoadOther(m) {
- return errors.New(fmt.Sprintf("uid=%v SSLoadPetNtf failed", this.GetUUid()))
- }
- }
- case *serverproto.SSLoadInvitationDataNtf:
- if this.roleInvitation != nil {
- if !this.roleInvitation.LoadOther(m.InvitationInfo) {
- return errors.New(fmt.Sprintf("uid=%v SSLoadInvitationDataNtf failed", this.GetUUid()))
- }
- }
- case *serverproto.SSLoadCrossDataNtf:
- if this.roleCross != nil {
- if !this.roleCross.LoadOther(m.LoadData) {
- return errors.New(fmt.Sprintf("uid=%v SSLoadCrossDataNtf failed", this.GetUUid()))
- }
- }
- default:
- return errors.New(fmt.Sprintf("uid=%v load unkonw model !!!", this.GetUUid()))
- //不在登陆流程中,后续通过协议主动获取
- }
- return nil
- }
- func (this *Role) Save() {
- if !this.isLoad {
- return
- }
- bSave := false
- if this.GetState() == ROLE_STATE_ONLINE || this.GetState() == ROLE_STATE_OFFLINE {
- for _, data := range this.soList {
- //data.(*SaveObject).IsDirty()
- if data.IsDirty() {
- data.Save()
- bSave = true
- }
- }
- }
- if bSave {
- //最后save时间戳
- this.lastProcessTime = util.GetTimeMilliseconds()
- }
- }
- func (this *Role) Update(ms uint64) {
- if this.GetState() == ROLE_STATE_ZOMBIE {
- return
- }
- //放到time wheel中处理
- //if this.saveTimer.IsStart() && this.saveTimer.IsExpired(ms) {
- // this.Save()
- //}
- //活动数据更新定时器相关代码
- if this.dailyResetTimer.IsStart() && this.dailyResetTimer.IsExpired(ms) {
- //update过程中玩家已经通过上下线进行了重置操作
- this.DailyReset(true)
- ResetCount++
- this.dailyResetTimer.Cancel()
- }
- this.roleArena.Update(ms)
- this.roleMail.Update(ms)
- if this.base == nil {
- util.WarnF("uid=%v Role.Update skip: base==nil", this.GetUUid())
- } else {
- this.GetRoleBase().Update(ms)
- }
- this.roleTower.Update(ms)
- this.roleRune.Update(ms)
- this.roleHead.Update(ms)
- this.roleWish.Update(ms)
- if this.mysqlLogSaveTimer.IsStart() && this.mysqlLogSaveTimer.IsExpired(ms) {
- this.saveMysqlLog()
- }
- ////1小时无任何保存操作,直接设置成离线状态
- //if ms > this.lastProcessTime && this.lastProcessTime > 0 && ms-this.lastProcessTime > 60*60*1000 {
- // if this.GetState() == ROLE_STATE_ONLINE {
- // this.SwitchState(ROLE_STATE_OFFLINE, nil)
- // util.DebugF("uid=%v online->offline", this.GetUUid())
- // }
- //}
- }
- func (this *Role) isDailyReset() bool {
- if this.GetRoleBase().roleBase.DailyResetTimeStamp <= 0 {
- this.GetRoleBase().roleBase.DailyResetTimeStamp = this.GetRoleBase().RoleData().LastLoginTime
- }
- return model.IsDailyResetHour5(this.GetRoleBase().roleBase.DailyResetTimeStamp)
- //return model.IsDailyResetHour5(this.GetRoleBase().RoleData().LastLoginTime)
- }
- func (this *Role) DailyReset(notify bool) {
- //加载完成后做重置操作
- util.ErrorF("uid=%v daily reset nickname=%s", this.GetUUid(), this.GetNickName())
- oldDailyResetTimeStamp := this.GetRoleBase().roleBase.DailyResetTimeStamp
- this.roleArena.DailyReset(notify)
- //this.roleTower.DailyReset(notify)
- this.roleBattle.DailyReset(notify)
- this.roleMap.DailyReset(notify)
- this.roleTask.DailyReset(notify, oldDailyResetTimeStamp)
- this.roleSkill.DailyReset(notify)
- this.roleGuild.DailyReset(notify)
- this.roleShop.DailyReset(notify)
- this.roleActivity.DailyReset(notify)
- this.roleInvitation.DailyReset(notify)
- this.roleRune.DailyReset(notify)
- this.roleDaoChang100.DailyReset(notify)
- this.roleCross.DailyReset(notify, oldDailyResetTimeStamp)
- this.roleHead.DailyReset(notify)
- this.roleCompetition.DailyReset(notify)
- this.roleBT.DailyReset(notify, oldDailyResetTimeStamp)
- //最后重置,切记!
- this.GetRoleBase().DailyReset(notify)
- }
- func (this *Role) SetUpdateDailyReset(ms uint64, bReset bool) {
- //已经重置不需要再次重置
- if !this.isDailyReset() {
- return
- }
- randNum := rand.Int31n(3000)
- this.dailyResetTimer.Reset(ms, time.Duration(randNum), false)
- }
- func (this *Role) FuncDisable() bool {
- //RobotMode 1:机器人模式 2:无法注册 3:关闭付费功能
- if service.GetServiceConfig().Node.RobotMode == 3 {
- return true
- }
- return false
- }
- // 推送客户端启动时需要的信息,例如基本信息,背包信息等
- func (this *Role) StartupProto() {
- // todo 测试使用
- time.Sleep(200 * time.Millisecond)
- nowTime := util.GetTimeMilliseconds()
- startUpTime := service.GetServiceStartupTime()
- ntfMsg := &serverproto.SCStartupInfoNtf{
- ServerTime: nowTime,
- CreateTime: this.RegisterTime,
- FuncDisable: this.FuncDisable(),
- ServiceStartTime: startUpTime,
- }
- //角色基础信息
- ntfMsg.RoleBase = &serverproto.RoleBase{}
- this.GetRoleBase().CopyData(ntfMsg.RoleBase)
- //小红点信息
- ntfMsg.RoleRed = this.roleRed.redInfo
- //伙伴
- ntfMsg.RoleHero = &serverproto.RoleHero{}
- this.roleHero.CopyData(ntfMsg.RoleHero)
- //背包
- ntfMsg.RoleBag = &serverproto.RoleBag{}
- this.roleBag.CopyData(ntfMsg.RoleBag)
- // 许愿箱
- ntfMsg.RoleWishBox = &serverproto.RoleWish{}
- this.roleWish.CopyData(ntfMsg.RoleWishBox)
- // 特殊处理
- ntfMsg.RoleBase.BtJiaDayRecharge = int32(float32(ntfMsg.RoleBase.BtJiaDayRecharge) * BTJiaChangeDollar)
- ntfMsg.RoleBase.BtJiaTotalRecharge = uint64(float32(ntfMsg.RoleBase.BtJiaTotalRecharge) * BTJiaChangeDollar)
- //分成多条协议进行发送
- sendLen := this.ReplayGate(ntfMsg, true)
- ntfMsg = &serverproto.SCStartupInfoNtf{
- ServerTime: nowTime,
- CreateTime: this.RegisterTime,
- FuncDisable: this.FuncDisable(),
- ServiceStartTime: startUpTime,
- }
- //碎片
- ntfMsg.RoleChip = &serverproto.RoleChip{}
- this.roleChip.CopyData(ntfMsg.RoleChip)
- //时装
- ntfMsg.RoleFashion = &serverproto.RoleFashion{}
- //this.roleFashion.CopyDatatmp(ntfMsg.RoleFashion)
- this.roleFashion.CopyData(ntfMsg.RoleFashion)
- //战斗数据
- ntfMsg.RoleBattle = &serverproto.RoleBattle{}
- this.roleBattle.CopyData(ntfMsg.RoleBattle)
- //私聊消息列表
- ntfMsg.RoleChat = &serverproto.RoleChat{}
- this.roleChat.CopyData(ntfMsg.RoleChat)
- //rolemap
- ntfMsg.RoleMap = this.roleMap.CopyData()
- ntfMsg.RoleTower = &serverproto.RoleTower{}
- this.roleTower.CopyData(ntfMsg.RoleTower)
- //任务模块
- ntfMsg.RoleTask = this.roleTask.CopyData()
- ntfMsg.RoleDraw = &serverproto.RoleDraw{}
- this.roleDraw.CopyData(ntfMsg.RoleDraw)
- //赛季玩法数据
- ntfMsg.RoleCompetition = &serverproto.RoleCompetition{}
- this.roleCompetition.CopyData(ntfMsg.RoleCompetition)
- //百人道场
- ntfMsg.RoleDaochang100 = &serverproto.RoleDaoChang100{}
- this.roleDaoChang100.CopyData(ntfMsg.RoleDaochang100)
- //战斗力值
- ntfMsg.RoleFightpower = &serverproto.FightPowerData{}
- //this.roleFightPower.CopyData(ntfMsg.RoleFightpower)
- this.roleBattleAttr.CopyData(ntfMsg.RoleFightpower)
- // BT
- ntfMsg.RoleBt = &serverproto.RoleBT{}
- this.roleBT.CopyData(ntfMsg.RoleBt)
- //RobotMode 1:机器人模式 2:无法注册 3:关闭付费功能
- ntfMsg.FuncDisable = this.FuncDisable()
- //分成多条协议进行发送
- sendLen = this.ReplayGate(ntfMsg, true) + sendLen
- ntfMsg = &serverproto.SCStartupInfoNtf{
- ServerTime: nowTime,
- CreateTime: this.RegisterTime,
- FuncDisable: this.FuncDisable(),
- ServiceStartTime: startUpTime,
- }
- //跨服个人数据
- ntfMsg.RoleCross = &serverproto.RoleCross{}
- this.roleCross.CopyData(ntfMsg.RoleCross)
- ntfMsg.RoleSkillEquip = &serverproto.RoleSkillEquip{}
- this.roleSkillEquip.CopyData(ntfMsg.RoleSkillEquip)
- sendLen = this.ReplayGate(ntfMsg, true) + sendLen
- this.tmpState = false
- util.DebugF("uid=%v StartupProto ntfMsgLen=%v", this.GetUUid(), sendLen)
- storyNtf := &serverproto.SCRoleStoryNtf{}
- this.GetRoleBase().CopyStoryData(storyNtf)
- this.ReplayGate(storyNtf, true)
- //通知最近世界聊天信息
- if this.roleChat != nil {
- this.roleChat.WorldMsgNtf()
- }
- //走马灯公告
- RoleMag.NoticeInfoNtf(this)
- //装备
- equipNtfMsg := &serverproto.SCStartupInfoEquipNtf{
- RoleEquipInfo: &serverproto.RoleEquip{},
- }
- this.roleEquip.CopyData(equipNtfMsg.RoleEquipInfo)
- sendLen = this.ReplayGate(equipNtfMsg, true)
- util.DebugF("uid=%v StartupProto ntfMsgLen=%v equip", this.GetUUid(), sendLen)
- //卡片
- cardNtfMsg := &serverproto.SCStartupInfoCardNtf{
- RoleCardInfo: &serverproto.RoleCard{},
- }
- this.roleCard.CopyData(cardNtfMsg.RoleCardInfo)
- sendLen = this.ReplayGate(cardNtfMsg, true)
- util.DebugF("uid=%v StartupProto ntfMsgLen=%v card", this.GetUUid(), sendLen)
- //pet
- this.rolePet.StartupNtf()
- //精彩活动
- this.roleActivity.StartupNtf()
- //邀请码系统
- this.roleInvitation.StartupNtf()
- //初始化结束函数标志
- endMsgNtf := &serverproto.SCStartupInfoEndNtf{}
- this.ReplayGate(endMsgNtf, true)
- this.GetRoleRune().GetFreeGoodsData()
- this.CombineServerNtf()
- }
- // 上线处理
- func (this *Role) onlineProcess(bRelogin bool) {
- //清空缓存列表
- this.reqAckConfirmList = map[uint32][]uint32{}
- this.GetRoleBase().OnlineProcess()
- if this.roleArena != nil {
- this.roleArena.OnlineProcess()
- }
- if this.roleCross != nil {
- this.roleCross.OnlineProcess()
- }
- if this.roleTower != nil {
- this.roleTower.OnlineProcess()
- }
- if this.roleBattle != nil {
- this.roleBattle.OnlineProcess()
- }
- if this.rolePet != nil {
- this.rolePet.OnlineProcess()
- }
- if this.roleRush != nil {
- this.roleRush.OnlineProcess()
- }
- if this.roleTask != nil {
- this.roleTask.OnlineProcess()
- }
- if this.roleActivity != nil {
- this.roleActivity.OnlineProcess()
- }
- if this.roleHead != nil {
- this.roleHead.OnlineProcess()
- }
- // 上线获取赛季奖励处理
- if this.roleCompetition != nil {
- this.roleCompetition.OnlineGetCompetitionReward()
- }
- //上线日志记录
- model.ElasticPutLogInfo(&model.ElasticLogST{
- Uid: this.GetUUid(),
- NickName: this.GetNickName(),
- OpenId: this.GetOpenId(),
- LogType: "RoleOnline",
- LogDesc: "RoleOnline",
- })
- this.MysqlLogNtf(serverproto.MysqlLogType_LType_Online, nil, 0)
- //更新简介信息中的离线时间(上线时也进行一次时间更新)
- this.GetRoleBase().UpdatePlayerBriefInfo(false)
- //获取离线信息玩家列表
- ssOfflineMsg := &serverproto.SSChatOfflinePlayerReq{}
- this.SendDb(ssOfflineMsg)
- //后续功能往后加,,尽量不要影响上面的逻辑
- this.GetRoleGuild().GuildBattleOnline()
- }
- func (this *Role) Logout() {
- this.Save()
- //清空角色信息数据
- if this.base != nil {
- //roleBasePool.Put(this.base)
- this.base = nil
- //删除连接信息
- delConnInfo := &serverproto.SSSaveUserConnectInfo{
- OpenId: this.GetOpenId(),
- Platform: this.GetPlatform(),
- }
- this.SendDb(delConnInfo)
- }
- this.roleHero = nil
- this.roleBag = nil
- this.roleChip = nil
- this.roleEquip = nil
- this.roleMap = nil
- this.roleSkill = nil
- this.roleCard = nil
- this.roleFashion = nil
- this.roleBattle = nil
- this.soList = this.soList[:0]
- }
- func (this *Role) BaseChangeNtf() {
- this.base.BaseChangeNtf()
- }
- func (this *Role) MysqlLogNtf(logType serverproto.MysqlLogType, paramList []int32, subType int32) {
- logData := &serverproto.SSRoleLogData{
- Uid: this.GetUUid(),
- Type: int32(logType),
- SubType: subType,
- ParamList: paramList, //oldval,newval,delval,param
- }
- if logType == serverproto.MysqlLogType_LType_Online {
- if this.GetClientParam() != nil {
- logData.StrList = append(logData.StrList, this.GetClientParam().DeviceModel)
- }
- logData.StrList = append(logData.StrList, this.GetClientIP())
- }
- this.mysqlLogList = append(this.mysqlLogList, logData)
- //mysqlNtf := &serverproto.SSRoleLogNtf{}
- //mysqlNtf.LogList = append(mysqlNtf.LogList, logData)
- //
- //this.SendDb(mysqlNtf)
- }
- func (this *Role) AddMysqlLog(logData *serverproto.SSRoleLogData) {
- this.mysqlLogList = append(this.mysqlLogList, logData)
- }
- func (this *Role) saveMysqlLog() {
- if len(this.mysqlLogList) > 0 {
- mysqlNtf := &serverproto.SSRoleLogNtf{}
- mysqlNtf.LogList = append(mysqlNtf.LogList, this.mysqlLogList...)
- this.SendDb(mysqlNtf)
- this.mysqlLogList = this.mysqlLogList[:0]
- }
- }
- func (this *Role) AddRmb(st AddItemST, add bool) {
- this.base.AddRMB(st, add)
- }
- func (this *Role) GetRmb() uint32 {
- return this.base.GetRmb()
- }
- func (this *Role) AddMoney(st AddItemST, add bool) {
- this.base.AddMoney(st, add)
- }
- func (this *Role) GetMoney() uint64 {
- return this.base.GetMoney()
- }
- func (this *Role) AddHeroExp(st AddItemST, add bool) bool {
- this.base.AddHeroExp(st, add)
- return true
- }
- func (this *Role) AddCruise(st AddItemST, add bool) bool {
- this.base.AddCruise(st, add)
- return true
- }
- // 增加角色基础经验
- func (this *Role) AddBaseExp(st AddItemST) bool {
- //添加属性涉及到升级操作(自动升级)
- this.base.AddBaseExp(st)
- return true
- }
- // 增加职业经验
- func (this *Role) AddJobExp(st AddItemST) bool {
- this.base.AddJobExp(st)
- return false
- }
- func (this *Role) GetRoleLevel() int32 {
- return this.GetRoleBase().GetRoleLevel()
- }
- func (this *Role) GetJobLevel() int32 {
- return this.GetRoleBase().GetRoleJobLevel()
- }
- // 创建角色开始的累计充值
- func (this *Role) GetTotalRecharge() float32 {
- return this.GetRoleBase().GetRoleTotalRecharge()
- }
- // 每日累计充值
- func (this *Role) GetDayRecharge() float32 {
- return this.GetRoleBase().roleBase.DayRecharge
- }
- // bt每日累计充值(真累计充值+假累计充值)
- func (this *Role) GetBTDayRecharge() float32 {
- return this.GetBTZhenDayRecharge() + this.GetBTJiaDayRecharge()
- }
- func (this *Role) GetBTZhenDayRecharge() float32 {
- return this.GetRoleBase().roleBase.BtZhenDayRecharge
- }
- func (this *Role) GetBTJiaDayRecharge() float32 {
- return float32(this.GetRoleBase().roleBase.BtJiaDayRecharge) * BTJiaChangeDollar
- }
- func (this *Role) GetBTJiaTotalRecharge() float32 {
- return float32(this.GetRoleBase().roleBase.BtJiaTotalRecharge) * BTJiaChangeDollar
- }
- // 添加通用资源
- func (this *Role) addCommonRes(resType int32, st AddItemST, add bool) {
- this.base.AddCommonRes(resType, st, add)
- }
- func (this *Role) getCommonResNum(resType int32) int32 {
- return this.base.GetCommonRes(resType)
- }
- func (this *Role) getChipResNum(resType int32) uint32 {
- return this.roleChip.getChipResNum(resType)
- }
- func (this *Role) AddRes(resType int32, st AddItemST, add bool) {
- switch serverproto.ResType(resType) {
- case serverproto.ResType_Res_Coin:
- this.AddMoney(st, add)
- case serverproto.ResType_Res_Rmb:
- this.AddRmb(st, add)
- case serverproto.ResType_Res_RoleBaseExp:
- this.AddBaseExp(st)
- case serverproto.ResType_Res_RoleJobExp:
- this.AddJobExp(st)
- case serverproto.ResType_Res_HeroBaseExp:
- this.AddHeroExp(st, add)
- case serverproto.ResType_Res_Cruise:
- this.AddCruise(st, add)
- //添加通用资源
- case serverproto.ResType_Res_Sprite:
- fallthrough
- case serverproto.ResType_Res_Reslove:
- fallthrough
- case serverproto.ResType_Res_EvilExp:
- fallthrough
- case serverproto.ResType_Res_Guild:
- fallthrough
- case serverproto.ResType_Res_DaoChang100:
- fallthrough
- case serverproto.ResType_Res_VipExp:
- fallthrough
- case serverproto.ResType_Res_Guild_Battle:
- fallthrough
- case serverproto.ResType_Res_PetCoin:
- fallthrough
- case serverproto.ResType_Res_PetExp:
- fallthrough
- case serverproto.ResType_Res_HightSkillExp:
- fallthrough
- case serverproto.ResType_Res_PetLevelUP_Exp:
- fallthrough
- case serverproto.ResType_Res_CreditRecharge:
- fallthrough
- case serverproto.ResType_Res_ROCoin:
- fallthrough
- case serverproto.ResType_Res_BoliShopExp:
- this.addCommonRes(resType, st, add)
- case serverproto.ResType_Res_RushMap:
- this.GetRoleBattle().OnRushMapScoreChange(st.ItemCount, 0)
- default:
- }
- this.GetRoleBase().SetDirty(true)
- }
- func (this *Role) GetResNum(resId int32) uint64 {
- cfgData, ok := serverproto.ItemCfgLoader[resId]
- if !ok {
- util.InfoF("uid=%v item cfg data not found resid=%v", this.GetUUid(), resId)
- return 0
- }
- switch serverproto.ResType(cfgData.ResType) {
- case serverproto.ResType_Res_Coin:
- return this.GetMoney()
- case serverproto.ResType_Res_Rmb:
- return uint64(this.GetRmb())
- case serverproto.ResType_Res_RoleBaseExp:
- return uint64(this.GetRoleBase().GetRoleBaseExp())
- case serverproto.ResType_Res_HeroBaseExp:
- return uint64(this.GetRoleBase().GetHeroBaseExp())
- case serverproto.ResType_Res_RoleJobExp:
- return uint64(this.GetRoleBase().GetRoleJobExp())
- case serverproto.ResType_Res_Cruise:
- return uint64(this.GetRoleBase().GetCruise())
- case serverproto.ResType_Res_Sprite:
- fallthrough
- case serverproto.ResType_Res_Reslove:
- fallthrough
- case serverproto.ResType_Res_EvilExp:
- fallthrough
- case serverproto.ResType_Res_Guild:
- fallthrough
- case serverproto.ResType_Res_DaoChang100:
- fallthrough
- case serverproto.ResType_Res_VipExp:
- fallthrough
- case serverproto.ResType_Res_Guild_Battle:
- fallthrough
- case serverproto.ResType_Res_PetCoin:
- fallthrough
- case serverproto.ResType_Res_PetExp:
- fallthrough
- case serverproto.ResType_Res_HightSkillExp:
- fallthrough
- case serverproto.ResType_Res_PetLevelUP_Exp:
- fallthrough
- case serverproto.ResType_Res_CreditRecharge:
- fallthrough
- case serverproto.ResType_Res_ROCoin:
- fallthrough
- case serverproto.ResType_Res_BoliShopExp:
- return uint64(this.getCommonResNum(resId))
- //背包中
- case serverproto.ResType_Res_SkillBook:
- fallthrough
- case serverproto.ResType_Res_Item:
- fallthrough
- case serverproto.ResType_Res_HeadFrame:
- fallthrough
- case serverproto.ResType_Res_QuickBattle:
- fallthrough
- case serverproto.ResType_Res_CashTicket:
- fallthrough
- case serverproto.ResType_Res_Gift:
- return uint64(this.GetItemNum(resId))
- case serverproto.ResType_Res_Chip:
- return uint64(this.getChipResNum(resId))
- case serverproto.ResType_Res_Equip:
- fallthrough
- case serverproto.ResType_Res_Fashion:
- fallthrough
- case serverproto.ResType_Res_Skill_Equip:
- fallthrough
- default:
- return 0
- }
- }
- func (this *Role) CheckResNum(resTypeList map[int32]int32) (bool, int32) {
- for resType, resValue := range resTypeList {
- if this.GetResNum(resType) < uint64(resValue) {
- return false, resType
- }
- }
- return true, 0
- }
- func (this *Role) CheckResLitNum(resTypeList map[int32]int32) bool {
- for resType, resValue := range resTypeList {
- if this.GetResNum(resType) < uint64(resValue) {
- return false
- }
- }
- return true
- }
- func (this *Role) CanAddItemList(resTypeList map[int32]int32) serverproto.ErrorCode {
- if this.GetRoleBag() != nil {
- return this.GetRoleBag().CanAddItemList(resTypeList)
- }
- return serverproto.ErrorCode_ERROR_FAIL
- }
- func (this *Role) AddItemList(resTypeList map[int32]int32, addFrom AddFromType, notify bool) {
- if this.GetRoleBag() != nil {
- this.GetRoleBag().AddItemList(resTypeList, AddItemST{AddFrom: addFrom, Notify: notify})
- }
- }
- func (this *Role) AddItem(configId int32, count int32, addFrom AddFromType) {
- if this.roleBag != nil {
- this.roleBag.AddItem(configId, count, AddItemST{AddFrom: addFrom, Notify: true})
- }
- }
- func (this *Role) DelItemList(resTypeList map[int32]int32, delFrom AddItemST) {
- if this.GetRoleBag() != nil {
- this.GetRoleBag().DelItemList(resTypeList, delFrom)
- }
- }
- func (this *Role) DelItem(configId int32, count int32, delFrom AddItemST) {
- if this.roleBag != nil {
- this.roleBag.DelItem(configId, count, delFrom)
- }
- }
- // 根据给定的道具动态ID(创建道具时生成的唯一ID)做删除操作
- func (this *Role) DelItemByList(itemIdList []uint64, delFrom AddFromType) {
- if this.roleBag == nil {
- return
- }
- util.InfoF("uid=%v DelItem itemlist=%v ", this.GetUUid(), itemIdList)
- ackMsg := &serverproto.SCDelItemAck{
- Error: int32(serverproto.ErrorCode_ERROR_OK),
- }
- for idx := 0; idx < len(itemIdList); idx++ {
- itemData := this.GetRoleBag().getItemById(itemIdList[idx])
- if itemData != nil && itemData.Num > 0 {
- this.GetRoleBag().DelItemById(itemIdList[idx], int32(itemData.Num), delFrom)
- ackMsg.DelCfgIdList = append(ackMsg.DelCfgIdList, itemData.ConfigId)
- }
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) GetItemNum(configId int32) uint32 {
- if this.roleBag != nil {
- return this.roleBag.getItemNum(configId)
- }
- return 0
- }
- func (this *Role) UseItem(itemId uint64, itemNum uint32, itemIdxList []int32, bForceItemId bool) {
- if this.roleBag != nil {
- //默认使用一个
- if itemNum == 0 {
- itemNum = 1
- }
- err := this.roleBag.UseItem(itemId, itemNum, itemIdxList, bForceItemId)
- if err != serverproto.ErrorCode_ERROR_OK {
- ackMsg := &serverproto.SCUseItemAck{
- Error: int32(err),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- }
- func (this *Role) OnlineTimeReward() {
- err := this.GetRoleBase().OnlineTimeReward()
- if err != serverproto.ErrorCode_ERROR_OK {
- ackMsg := &serverproto.SCOnlineTimeRewardAck{
- Error: int32(err),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- // 获取当前累计充值所属档位
- // 玩家累计充值金额档位1:[0-100] 2:(100,1000] 3:(1000,10000]
- func (this *Role) GetTotalRechargeTap() int32 {
- var tmpTap int32 = 0
- tmpTotalRecharge := int32(this.GetTotalRecharge())
- for idx := 0; idx < len(model.GlobalTotalRechargeList); idx++ {
- if tmpTotalRecharge < model.GlobalTotalRechargeList[idx].Value {
- return model.GlobalTotalRechargeList[idx].Key
- }
- tmpTap = model.GlobalTotalRechargeList[idx].Key
- }
- return tmpTap
- }
- func (this *Role) GetRoleBriefInfo(briefInfo *serverproto.CommonPlayerBriefInfo) {
- briefInfo.Uid = this.GetUUid()
- briefInfo.NickName = this.GetNickName()
- briefInfo.Gender = this.GetRoleBase().GetRoleSex()
- briefInfo.ImgId = this.GetImageId()
- briefInfo.Level = this.GetRoleLevel()
- briefInfo.ConfigId = this.GetRoleBase().RoleData().HeroData.ConfigId
- briefInfo.FightPower = int32(this.roleBattleAttr.curTotalFightPower)
- //briefInfo.FightPower = int32(this.GetRoleFightPower().TotalFightPower) //(this.GetRoleBase().RoleData().FightPower)
- briefInfo.TowerLevel = this.GetRoleTower().nowTowerLevel
- briefInfo.TowerTime = uint64(this.GetRoleTower().nowTowerPassTime)
- briefInfo.HeadFrameId = this.GetRoleBase().RoleData().HeadFrameId
- briefInfo.VipLevel = this.GetRoleVipLevel()
- briefInfo.HeadId = this.GetHeadId()
- briefInfo.TowerWjLevel = this.GetRoleTower().nowTowerWjLevel - 1
- //1000层默认置为-1但是客户端显示需要1000
- if this.GetRoleTower().nowTowerWjLevel == -1 {
- briefInfo.TowerWjLevel = 1000
- }
- briefInfo.TowerWjTime = uint64(this.GetRoleTower().nowTowerWjPassTime)
- if this.GetState() == ROLE_STATE_ONLINE {
- briefInfo.OnlineState = true
- } else {
- briefInfo.OnlineTime = this.GetRoleBase().GetLastLoginTime()
- }
- }
- func (this *Role) GetRoleFightInfo(fightInfo *serverproto.FightRoleInfo, isMainRole bool) {
- fightInfo.IsRobot = false
- fightInfo.BriefInfo = &serverproto.CommonPlayerBriefInfo{
- Uid: this.GetUUid(),
- NickName: this.GetNickName(),
- Gender: this.GetRoleBase().GetRoleSex(),
- ImgId: this.GetImageId(),
- HeadFrameId: this.GetRoleBase().RoleData().HeadFrameId,
- VipLevel: this.GetRoleVipLevel(),
- SelectZone: this.GetSelectZone(),
- ConfigId: this.GetRoleHero().GetMainHero().ConfigId,
- Level: this.GetRoleLevel(),
- }
- fightInfo.JobLevel = this.GetJobLevel()
- //后续需要处理
- fightInfo.AttrList = this.GetRoleHero().GetMainHero().AttrList
- fightInfo.FashionData = this.GetRoleBase().roleBase.FashionData
- //技能竞技压制
- fightInfo.RepressSkillPvpVal = this.GetRoleBase().roleBase.RepressSkillPvpVal
- fightInfo.MaxFightPower = int32(this.GetRoleBase().RoleData().FightPower)
- //世界boss,只上阵主角
- mainHeroData := this.GetRoleBase().RoleData().HeroData
- fightInfo.HeroDataList = append(fightInfo.HeroDataList, this.GetRoleBase().RoleData().HeroData)
- if mainHeroData.BattlePetId > 0 && this.GetRolePet() != nil {
- battlePetInfo := this.GetRolePet().getPet(mainHeroData.BattlePetId)
- if battlePetInfo != nil {
- fightInfo.BattlePetList = append(fightInfo.BattlePetList, battlePetInfo)
- }
- }
- if !isMainRole {
- //其他上阵伙伴
- for _, data := range this.GetRoleHero().heroList {
- if data.IsBattle {
- fightInfo.HeroDataList = append(fightInfo.HeroDataList, data)
- if data.BattlePetId > 0 && this.GetRolePet() != nil {
- battlePetInfo := this.GetRolePet().getPet(data.BattlePetId)
- if battlePetInfo != nil {
- fightInfo.BattlePetList = append(fightInfo.BattlePetList, battlePetInfo)
- }
- }
- }
- }
- }
- }
- type AddSystemMsg struct {
- ParamId int32
- ParamCount int32
- AddFromType int32
- UseItemCfgId int32
- ParamList []int32
- ParaStr string
- }
- func (this *Role) GenSystemMessage(sType SystemMessageType, st AddSystemMsg) *serverproto.SystemMessage {
- ssMsgNtf := &serverproto.SSSystemMessageNtf{}
- sysMsg := &serverproto.SystemMessage{
- Type: int32(sType),
- NickName: this.GetNickName(),
- SendTime: util.GetTimeMilliseconds(),
- }
- if st.ParamId > 0 {
- sysMsg.ParamId = append(sysMsg.ParamId, st.ParamId) //id
- }
- if st.ParamCount > 0 {
- sysMsg.ParamId = append(sysMsg.ParamId, st.ParamCount) //count
- }
- if st.AddFromType > 0 {
- sysMsg.ParamId = append(sysMsg.ParamId, st.AddFromType) //AddFromType
- }
- if st.UseItemCfgId > 0 {
- sysMsg.ParamId = append(sysMsg.ParamId, st.UseItemCfgId) //UseItemCfgId
- }
- if len(st.ParamList) > 0 {
- sysMsg.ParamId = append(sysMsg.ParamId, st.ParamList...)
- }
- if sType == SystemmessageType_GuildDemon {
- sysMsg.NickName = st.ParaStr
- }
- ssMsgNtf.SysMsg = append(ssMsgNtf.SysMsg, sysMsg)
- //util.InfoF("uid=%v GenSystemMessage type=%v param=%v", this.GetUUid(), sysMsg.Type, sysMsg.ParamId)
- return sysMsg
- }
- func (this *Role) AddSystemMessage(sType SystemMessageType, st AddSystemMsg) {
- ssMsgNtf := &serverproto.SSSystemMessageNtf{}
- sysMsg := &serverproto.SystemMessage{
- Type: int32(sType),
- NickName: this.GetNickName(),
- SendTime: util.GetTimeMilliseconds(),
- }
- if st.ParamId > 0 {
- sysMsg.ParamId = append(sysMsg.ParamId, st.ParamId) //id
- }
- if st.ParamCount > 0 {
- sysMsg.ParamId = append(sysMsg.ParamId, st.ParamCount) //count
- }
- if st.AddFromType > 0 {
- sysMsg.ParamId = append(sysMsg.ParamId, st.AddFromType) //AddFromType
- }
- if st.UseItemCfgId > 0 {
- sysMsg.ParamId = append(sysMsg.ParamId, st.UseItemCfgId) //UseItemCfgId
- }
- if len(st.ParamList) > 0 {
- sysMsg.ParamId = append(sysMsg.ParamId, st.ParamList...)
- }
- if sType == SystemmessageType_GuildDemon {
- sysMsg.NickName = st.ParaStr
- }
- ssMsgNtf.SysMsg = append(ssMsgNtf.SysMsg, sysMsg)
- this.SendSocial(ssMsgNtf)
- }
- // 分配属性点
- func (this *Role) AddAttrPoint(heroID int32, point interface{}) {
- ret := this.GetRoleHero().AddAttrPoint(heroID, point)
- if ret != serverproto.ErrorCode_ERROR_OK {
- ackMsg := &serverproto.SCAddAttrPointAck{
- Error: int32(ret),
- HeroId: heroID,
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- // 分配属性点
- func (this *Role) ReduceAttrPoint(count, itemid int32) {
- this.GetRoleHero().ReduceAttrPoint(count, itemid)
- }
- // 重置属性点
- func (this *Role) ResetAttrPoint(heroID int32) {
- this.GetRoleHero().ResetAttrPoint(heroID, false)
- }
- // 增加素质点
- func (this *Role) OnAddQualityPoint(msg *serverproto.CSAddQualityPointReq) {
- if msg == nil {
- return
- }
- ackMsg := &serverproto.SCAddQualityPointAck{}
- ackMsg.HeroId = msg.HeroId
- ackMsg.ItemId = msg.ItemId
- ackMsg.Error = int32(this.GetRoleHero().UseQualityItem(msg.HeroId, msg.ItemId))
- this.ReplayGate(ackMsg, true)
- }
- // 激活头像
- func (this *Role) ActiveHead(headId int32) {
- ackMsg := &serverproto.SCActiveHeadAck{
- HeadId: headId,
- }
- bRet := this.base.ActiveHead(headId)
- ackMsg.Error = int32(bRet)
- this.ReplayGate(ackMsg, true)
- }
- // 设置头像
- func (this *Role) SetRoleHeadPic(headId int32) {
- ackMsg := &serverproto.SCSetHeadIdAck{
- HeadId: headId,
- }
- bRet := this.GetRoleBase().SetRoleHeadPic(headId)
- ackMsg.Error = int32(bRet)
- this.ReplayGate(ackMsg, true)
- //更新玩家简介信息
- if bRet == serverproto.ErrorCode_ERROR_OK {
- this.GetRoleBase().UpdatePlayerBriefInfo(false)
- }
- }
- func (this *Role) SetRoleHeadFrameId(frameId int32) {
- ackMsg := &serverproto.SCChangeHeadFrameAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- HeadFrameId: frameId,
- }
- bRet := this.GetRoleBase().SetHeadFrameId(frameId)
- ackMsg.Error = int32(bRet)
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) UseHeadFrameItem(itemId uint64, itemNum uint32) {
- ackMsg := &serverproto.SCUseHeadFrameItemAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- bRet, res_list := this.GetRoleBag().UseHeadFrameItem(itemId, itemNum)
- ackMsg.Error = int32(bRet)
- ackMsg.ItemList = res_list
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) GetRoleHeadFrameInfo() {
- ackMsg := &serverproto.SCHeadFrameInfoAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- bRet := this.GetRoleBase().PackHeadFrameInfo(ackMsg)
- ackMsg.Error = int32(bRet)
- this.ReplayGate(ackMsg, true)
- }
- // 请求头像信息
- func (this *Role) HeadInfoReq() {
- this.base.HeadInfoReq()
- }
- func (this *Role) ChangeRoleName(name string) {
- ackMsg := &serverproto.SCRenameAck{
- Name: name,
- }
- bRet := this.base.ChangeRoleName(name)
- ackMsg.Error = int32(bRet)
- this.ReplayGate(ackMsg, true)
- //更新玩家简介信息
- if bRet == serverproto.ErrorCode_ERROR_OK {
- this.GetRoleBase().UpdatePlayerBriefInfo(false)
- }
- }
- func (this *Role) SetRoleGuide(guideId int32) {
- this.GetRoleBase().SetGuideId(guideId)
- }
- func (this *Role) SetRoleStory(story *serverproto.KeyValueType) {
- nRet := this.GetRoleBase().SetStoryId(story)
- ackMsg := &serverproto.SCRoleStoryAck{
- Error: int32(nRet),
- StoryId: story,
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) SetMapCartoon(id, status int32) {
- bRet := this.GetRoleBase().SetNewMapCartoonId(id, status)
- ackMsg := &serverproto.SCNewMapCartoonAck{
- Error: int32(bRet),
- MapCart: &serverproto.KeyValueType{
- Key: id,
- Value: status,
- },
- }
- this.ReplayGate(ackMsg, true)
- }
- // /hero/partner
- // 添加伙伴
- func (this *Role) AddHero(configId int32) bool {
- if this.roleHero != nil {
- return this.roleHero.AddHero(configId)
- }
- return false
- }
- func (this *Role) HeroLevelUp(id int32) bool {
- if this.roleHero != nil {
- return this.roleHero.LevelUp(id)
- }
- return false
- }
- func (this *Role) HeroAdvance(id int32) bool {
- if this.roleHero != nil {
- ret := this.roleHero.Advance(id)
- if ret == serverproto.ErrorCode_ERROR_OK {
- ////进阶重新处理属性
- //this.roleFightPower.onFighterAttrChange(id)
- } else {
- ackMsg := &serverproto.SCHeroAdvanceAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- return ret == serverproto.ErrorCode_ERROR_OK
- }
- return false
- }
- func (this *Role) HeroStrength(id int32) bool {
- if this.roleHero != nil {
- ret := this.roleHero.HeroStrength(id)
- return ret
- }
- return false
- }
- func (this *Role) HeroChangeJob(heroId int32, jobId int32) bool {
- ackMsg := &serverproto.SCHeroChangeJobAck{
- Error: int32(serverproto.ErrorCode_ERROR_OK),
- HeroId: heroId,
- }
- if this.roleHero != nil {
- ret := this.roleHero.HeroChangeJob(heroId, jobId)
- if ret == serverproto.ErrorCode_ERROR_OK {
- ////转职重新处理属性 后续重新开发
- //this.roleFightPower.onFighterAttrChange(heroId)
- }
- ackMsg.Error = int32(ret)
- this.ReplayGate(ackMsg, true)
- return true
- }
- return false
- }
- func (this *Role) HeroRecruit(configId int32) {
- ackMsg := &serverproto.SCHeroActiveAck{
- HeroId: configId,
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- if this.roleHero != nil {
- nRet := this.roleHero.RecruitHero(configId)
- ackMsg.Error = int32(nRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) FightPowerReq(heroId int32) {
- ackMsg := &serverproto.SCHeroFighPowerAck{
- Error: int32(serverproto.ErrorCode_ERROR_OK),
- HeroId: heroId,
- }
- //this.roleFightPower.calcHeroFightPower(heroId)
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) HeroBattle(heroId int32, isBattle bool) {
- if this.roleHero != nil {
- ret := this.roleHero.HeroBattle(heroId, isBattle)
- ackMsg := &serverproto.SCHeroBattleAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) ComposeChip(configId int32) {
- if this.roleChip != nil && this.roleHero != nil {
- ret := this.roleChip.ComposeChip(configId)
- if ret != serverproto.ErrorCode_ERROR_OK {
- util.DebugF("uid=%v ComposeChip err=%v", this.GetUUid(), ret)
- }
- ackMsg := &serverproto.SCChipComposeAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) ChipDecompose(chipList []*serverproto.KeyValueType, heroChipType []int32) {
- if this.roleChip != nil {
- ret := this.roleChip.ChipDecompose(chipList, heroChipType)
- if ret != serverproto.ErrorCode_ERROR_OK {
- ackMsg := &serverproto.SCHeroChipDecomposeAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- }
- // /equip
- func (this *Role) EquipForge(equipConfigId int32, once int32, equipType, subEquipType int32) {
- if this.roleEquip != nil {
- this.roleEquip.EquipForge(equipConfigId, once, equipType, subEquipType)
- }
- }
- func (this *Role) AddEquip(configId int32, num int32, notify bool, ignore bool) {
- if this.roleEquip != nil {
- addEquip, _ := this.roleEquip.AddEquip(configId, num)
- if addEquip != nil {
- if notify {
- ntfMsg := &serverproto.SCEquipChangeNtf{
- Ignore: ignore,
- }
- ntfMsg.EquipList = append(ntfMsg.EquipList, addEquip.(*serverproto.EquipData))
- this.ReplayGate(ntfMsg, true)
- }
- util.InfoF("uid=%v AddEquip id=%v now=%v num=%v", this.GetUUid(), configId,
- addEquip.(*serverproto.EquipData).Num, num)
- }
- }
- }
- func (this *Role) AddSkillEquip(configId int32, num int32, notify bool, ignore bool) {
- if this.roleSkillEquip != nil {
- changeIdList := map[uint32]int32{}
- var i int32 = 0
- for ; i < num; i++ {
- addSkillEquip, _ := this.roleSkillEquip.AddSkillEquip(configId, 0)
- if addSkillEquip != nil {
- detail, ok := addSkillEquip.(*serverproto.SkillEquipData)
- if !ok {
- continue
- }
- changeIdList[detail.Id] = detail.ConfigId
- }
- }
- this.roleSkillEquip.ChangeNtf(changeIdList, ignore)
- }
- }
- func (this *Role) EquipUp(heroId int32, slotIndex int32, equipId int32) {
- if this.roleEquip != nil && this.roleHero != nil &&
- heroId > 0 && slotIndex >= 0 && equipId >= 0 {
- ret := this.base.EquipUp(heroId, slotIndex, equipId)
- ackMsg := &serverproto.SCEquipUpAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- } else {
- ackMsg := &serverproto.SCEquipUpAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) EquipDown(heroId int32, subIndex int32) {
- if this.roleEquip != nil && this.roleHero != nil {
- this.base.EquipDown(heroId, subIndex)
- }
- }
- func (this *Role) EquipLevelUpAll(heroId int32) {
- if this.roleEquip != nil && this.roleHero != nil {
- this.base.EquipLevelUpAll(heroId)
- }
- }
- func (this *Role) EquipSlotLevelUp(heroId int32, subSlotIndex int32) {
- if this.roleEquip != nil {
- ret := this.base.EquipSlotLevelUp(heroId, subSlotIndex)
- util.DebugF("uid=%v [EquipSlotLevelUp] err=%v", this.GetUUid(), ret)
- ackMsg := &serverproto.SCEquipSlotLevelUpAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- // 神器槽位升级
- func (this *Role) SkillEquipSlotLevelUp(heroId, subIndex int32) {
- if this.roleSkillEquip != nil && this.roleHero != nil {
- slotData := this.base.getSkillEquipSlotData(heroId)
- ret := this.roleSkillEquip.SkillEquipSlotLevelUp(slotData, heroId, subIndex)
- util.DebugF("uid=%v [EquipSlotLevelUp] err=%v", this.GetUUid(), ret)
- ackMsg := &serverproto.SCSkillEquipSlotLevelUpAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- // 神器升星
- func (this *Role) SkillEquipStarLevelUp(heroId int32, skillEquipId uint32, cost []uint32) {
- if this.roleSkillEquip != nil && this.roleHero != nil {
- slotData := this.base.getSkillEquipSlotData(heroId)
- ret := this.roleSkillEquip.SkillEquipStarLevelUp(heroId, slotData, skillEquipId, cost)
- util.DebugF("uid=%v [SkillEquipStarLevelUp] err=%v", this.GetUUid(), ret)
- ackMsg := &serverproto.SCSkillEquipLevelUpAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- // 神器转移
- func (this *Role) SkillEquipShift(msg *serverproto.CSSkillEquipShiftReq) {
- if msg == nil {
- return
- }
- ret := this.roleSkillEquip.SkillEquipShift(msg.SrcId, msg.DstId)
- util.DebugF("uid=%v [SkillEquipShift] err=%v", this.GetUUid(), ret)
- ackMsg := &serverproto.SCSkillEquipShiftAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- // 佩戴替换神器
- func (this *Role) SkillEquipUp(heroId int32, skillEquipId uint32, slotIndex int32) {
- if this.roleSkillEquip != nil && this.roleHero != nil {
- slotData := this.base.getSkillEquipSlotData(heroId)
- ret := this.roleSkillEquip.SkillEquipUp(heroId, slotData, skillEquipId, slotIndex)
- util.DebugF("uid=%v [SkillEquipUp] err=%v", this.GetUUid(), ret)
- ackMsg := &serverproto.SCSkillEquipUpAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- // 卸下神器
- func (this *Role) SkillEquipDown(heroId int32, slotIndex int32) {
- if this.roleSkillEquip != nil && this.roleHero != nil {
- slotData := this.base.getSkillEquipSlotData(heroId)
- ret := this.roleSkillEquip.SkillEquipDown(heroId, slotData, slotIndex)
- util.DebugF("uid=%v [SkillEquipDown] err=%v", this.GetUUid(), ret)
- ackMsg := &serverproto.SCSkillEquipDownAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- // 分解神器
- func (this *Role) SkillEquipDecompose(skillEquipIds []uint32) {
- if this.roleSkillEquip != nil && this.roleHero != nil {
- reward, ret := this.roleSkillEquip.SkillEquipDecompose(skillEquipIds)
- util.DebugF("uid=%v [SkillEquipDecompose] err=%v", this.GetUUid(), ret)
- ackMsg := &serverproto.SCSkillEquipDecomposeAck{
- Error: int32(ret),
- }
- if reward != nil && len(reward) > 0 {
- for k, v := range reward {
- ackMsg.ItemList = append(ackMsg.ItemList, &serverproto.KeyValueType{
- Key: k,
- Value: v,
- })
- }
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) SkillEquipRemade(skillEquipId uint32) {
- if this.roleSkillEquip != nil && this.roleHero != nil {
- ackMsg := &serverproto.SCSkillEquipRemadeAck{
- OldId: skillEquipId,
- }
- ret, newId := this.roleSkillEquip.SkillEquipReforge(skillEquipId)
- ackMsg.Error = int32(ret)
- ackMsg.NewId = newId
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) GetSkillEquipPool() {
- if this.roleSkillEquip != nil {
- ackMsg := &serverproto.SCSkillEquipPoolAck{}
- ret := this.roleSkillEquip.GetSkillEquipPool(ackMsg)
- ackMsg.Error = int32(ret)
- this.ReplayGate(ackMsg, true)
- }
- }
- // /card
- func (this *Role) CardMount(heroId, subSlotIndex, cardSlotIndex, cardCfgId int32) {
- if this.roleEquip != nil && this.roleCard != nil {
- ret := this.base.SlotCardMount(heroId, subSlotIndex, cardSlotIndex, cardCfgId)
- util.DebugF("uid=%v CardMount err=%v", this.GetUUid(), ret)
- ackMsg := &serverproto.SCCardMountAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) CardDown(heroId, subSlotIndex, cardSlotIndex int32) {
- if this.roleCard != nil {
- ret := this.base.SlotCardDown(heroId, subSlotIndex, cardSlotIndex)
- util.DebugF("uid=%v CardDown err=%v", this.GetUUid(), ret)
- ackMsg := &serverproto.SCCardDownAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) CardMountAll(msg *serverproto.CSCardEquipAllReq) {
- if msg == nil || len(msg.EqiupSlotData) <= 0 {
- return
- }
- if this.roleEquip != nil && this.roleCard != nil {
- ret := this.base.SlotCardMountAll(msg)
- util.DebugF("uid=%v CardMountAll err=%v", this.GetUUid(), ret)
- ackMsg := &serverproto.SCCardEquipAllAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) CardDownAll(heroId int32) {
- if this.roleEquip != nil && this.roleCard != nil {
- ret := this.base.SlotCardDownAll(heroId)
- util.DebugF("uid=%v CardDownAll err=%v", this.GetUUid(), ret)
- ackMsg := &serverproto.SCCardEquipDownAck{
- Error: int32(ret),
- HeroId: heroId,
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) CardUpGradeAll(msg *serverproto.CSCardUpGradeAllReq) {
- if this.roleCard != nil {
- ret := this.base.SlotCardUpGradeAll(msg)
- util.DebugF("uid=%v CardUpGradeAll err=%v", this.GetUUid(), ret)
- ackMsg := &serverproto.SCCardUpGradeAllAck{
- Error: int32(ret),
- HeroId: msg.HeroId,
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) CardLevelExchange(sourceCardId, targetCardId int32) {
- ackMsg := &serverproto.SCCardLevelExchangeAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- if this.roleCard != nil {
- ret := this.roleCard.CardExchange(sourceCardId, targetCardId, ackMsg)
- ackMsg.Error = int32(ret)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) CardCollect() {
- if this.roleCard != nil {
- ackMsg := &serverproto.SCCardCollectInfoAck{
- Error: int32(serverproto.ErrorCode_ERROR_OK),
- }
- this.GetRoleCard().GetCardCollect(ackMsg)
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) CardCollectReward(cardId, level int32) {
- if this.roleCard != nil {
- ackMsg := &serverproto.SCCardCollectRewardAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- ret := this.GetRoleCard().GetCollectReward(cardId, level, ackMsg)
- ackMsg.Error = int32(ret)
- ackMsg.CardId = cardId
- ackMsg.Level = level
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) CardCompose(cardList []int32) {
- if this.roleCard != nil {
- ret, newCardId := this.roleCard.CardCompose(cardList)
- util.DebugF("uid=%v CardCompose err=%v", this.GetUUid(), ret)
- ackMsg := &serverproto.SCCardComposeAck{
- Error: int32(ret),
- NewCardId: newCardId,
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) CardDecompose(cardList []*serverproto.KeyValueType, cardType int32) {
- if this.roleCard != nil {
- this.roleCard.CardDecompose(cardList, cardType)
- }
- }
- func (this *Role) CardUpGrade(msg *serverproto.CSCardUpGradeReq) {
- ackMsg := &serverproto.SCCardUpGradeAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- if this.roleCard != nil && len(msg.ConfigIds) > 0 {
- this.roleCard.BagCardUpGrade(msg, ackMsg)
- }
- this.ReplayGate(ackMsg, true)
- }
- // /skill
- func (this *Role) SkillReplace(heroId, idx, replaceSkillId int32) {
- if this.roleSkill != nil {
- ret := this.roleSkill.SkillReplace(heroId, idx, replaceSkillId, true, true)
- util.DebugF("uid=%v SkillReplace] err=%v", this.GetUUid(), ret)
- this.ReplayGate(&serverproto.SCReplaceSkillAck{Error: int32(ret)}, true)
- }
- }
- func (this *Role) ActiveSkill(heroId int32, skillId int32) {
- if this.roleSkill != nil {
- ret := this.roleSkill.ActiveSkill(heroId, skillId)
- util.DebugF("uid=%v ActiveSkill err=%v heroid=%v skillid=%v", this.GetUUid(), ret, heroId, skillId)
- this.ReplayGate(&serverproto.SCActiveSkillAck{Error: int32(ret)}, true)
- }
- }
- func (this *Role) SwapSkill(heroId, firstSlotId, secondSlotId int32) {
- if this.roleSkill != nil {
- ret := this.roleSkill.SwapSkill(heroId, firstSlotId, secondSlotId)
- util.DebugF("uid=%v SwapSkill err=%v s1=%v s2=%v", this.GetUUid(), ret, firstSlotId, secondSlotId)
- this.ReplayGate(&serverproto.SCSwapSkillAck{Error: int32(ret)}, true)
- }
- }
- func (this *Role) SetSkillList(heroId int32, skillList []int32) {
- ackMsg := &serverproto.SCSetSkillListAck{
- HeroId: heroId,
- }
- if this.roleSkill != nil {
- ret := this.roleSkill.SetSkillList(heroId, skillList)
- ackMsg.Error = int32(ret)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) SkillLevelUp(heroId int32, skillId int32) {
- ackMsg := &serverproto.SCSkillLevelUpAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- SkillId: skillId,
- HeroId: heroId,
- }
- if this.roleHero == nil {
- this.ReplayGate(ackMsg, true)
- return
- }
- heroData := this.roleHero.GetHero(heroId)
- if heroData == nil {
- this.ReplayGate(ackMsg, true)
- return
- }
- bRet := this.roleSkill.SkillLevelUp(heroData, skillId)
- ackMsg.Error = int32(bRet)
- this.ReplayGate(ackMsg, true)
- }
- // 兑换高级技能经验
- func (this *Role) ConverSkillExp(msg *serverproto.CSConverSkillExpReq) {
- ackMsg := &serverproto.SCConverSkillExpAck{}
- ackMsg.Error = int32(this.roleSkill.ConverSkillExp(msg.Cnt))
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) ResetSkillLevel(heroId int32, bsuper bool) {
- if this.roleHero == nil {
- return
- }
- heroData := this.roleHero.GetHero(heroId)
- if heroData == nil {
- return
- }
- ackMsg := &serverproto.SCResetSkillLevelAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- HeroId: heroId,
- }
- bRet := this.roleSkill.ResetSkillLevel(heroId, bsuper)
- ackMsg.Error = int32(bRet)
- ackMsg.ResetCount = this.GetRoleBase().RoleData().SkillResetCount
- this.ReplayGate(ackMsg, true)
- }
- // /card 相关
- func (this *Role) FashionUp(fashionCfgIdList []int32) {
- if this.roleFashion != nil {
- ackMsg := &serverproto.SCFashionUpAck{}
- for _, data := range fashionCfgIdList {
- if ret := this.roleFashion.FashionUp(data); ret == serverproto.ErrorCode_ERROR_OK {
- ackMsg.Error = int32(ret)
- }
- }
- this.roleFashion.SetFashion()
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) FashionDown(fashionCfgIdList []int32) {
- if this.roleFashion != nil {
- ackMsg := &serverproto.SCFashionDownAck{}
- for _, data := range fashionCfgIdList {
- if ret := this.roleFashion.FashionDown(data); ret == serverproto.ErrorCode_ERROR_OK {
- ackMsg.Error = int32(ret)
- }
- }
- this.roleFashion.SetFashion()
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) FashionCompose(paperCfgId int32) {
- if this.roleFashion != nil {
- ret := this.roleFashion.FashionCompose(paperCfgId)
- this.ReplayGate(&serverproto.SCFashionComposeAck{Error: int32(ret)}, true)
- }
- }
- func (this *Role) FashionPaperDecompose(paperCfgId int32) {
- if this.roleFashion != nil {
- ret := this.roleFashion.FashionPaperDecompose(paperCfgId)
- if ret != serverproto.ErrorCode_ERROR_OK {
- this.ReplayGate(&serverproto.SCFashionPaperDecomposeAck{Error: int32(ret)}, true)
- }
- }
- }
- func (this *Role) FashionResetAttr(fashionId int32, enter bool) {
- if this.roleFashion == nil {
- return
- }
- ret, _ := this.roleFashion.FashionResetAttr(fashionId, enter)
- this.roleFashion.FashionChangeNtf([]int32{fashionId})
- this.ReplayGate(&serverproto.SCFashionResetAttrAck{Error: int32(ret)}, true)
- }
- func (this *Role) FashionUpLvl(fashionId int32) {
- if this.roleFashion == nil {
- return
- }
- ret := this.roleFashion.FashionUpLvl(fashionId)
- this.roleFashion.FashionChangeNtf([]int32{fashionId})
- this.ReplayGate(&serverproto.SCFashionUpLvlAck{Error: int32(ret)}, true)
- }
- func (this *Role) BuyItem(shopId, goodsId, goodsNum int32) {
- ackMsg := &serverproto.SCShopBuyItemAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- GoodsType: shopId,
- GoodsId: goodsId,
- }
- if this.roleBag != nil && goodsNum > 0 {
- bRet, buyTime, buyNum := this.roleShop.BuyItem(shopId, goodsId, goodsNum, ackMsg)
- ackMsg.Error = int32(bRet)
- ackMsg.CurNum = buyNum
- ackMsg.CurBuyTime = buyTime
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) ShopInfoReq(goodsType int32) {
- ackMsg := &serverproto.SCShopInfoAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- if this.roleBag != nil {
- shopTypeData, ok := serverproto.ShopTypeCfgLoader[goodsType]
- if ok {
- if shopTypeData.ShopType == 2 {
- bRet := this.roleShop.GetSpecialShopInfo(goodsType, ackMsg)
- ackMsg.Error = int32(bRet)
- } else {
- bRet := this.roleShop.GetShopInfo(goodsType, ackMsg)
- ackMsg.Error = int32(bRet)
- }
- }
- }
- util.DebugF("send ackMsg msg=%v", ackMsg)
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) ShopRefresh(goodsType int32) {
- ackMsg := &serverproto.SCShopRefreshAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- if this.roleBag != nil {
- bRet := this.roleShop.HandleSpecialShopRefresh(goodsType, ackMsg)
- ackMsg.Error = int32(bRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) RedBagShopExchange() {
- ackMsg := &serverproto.SCRedBagExchangeAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- if this.roleBag != nil {
- bRet := this.roleShop.ExchangeRedBagTicket(ackMsg)
- ackMsg.Error = int32(bRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- // /social相关
- func (this *Role) playerSocialOnline() {
- ntfMsg := &serverproto.SSPlayerOnlineNtf{
- BriefInfo: &serverproto.PlayerBriefInfo{
- Uid: this.GetUUid(),
- NickName: this.GetRoleBase().roleBase.NickName,
- },
- }
- ntfMsg.ServiceNode = service.GetLocalServiceID()
- this.SendAllSocial(ntfMsg)
- }
- func (this *Role) playerSocialOffline() {
- ntfMsg := &serverproto.SSPlayerOfflineNtf{
- Uid: this.GetUUid(),
- }
- this.SendAllSocial(ntfMsg)
- }
- func (this *Role) playerGuildOnline(changeType int32) {
- ntfMsg := &serverproto.SSPlayerStateChangeNtf{
- Uid: this.GetUUid(),
- GuildId: this.GetRoleGuildId(),
- ChangeType: changeType,
- DemonFightTime: this.GetRoleGuild().GetDemonFightTime(),
- }
- if changeType == 2 {
- ntfMsg.DemonFightTime = 0
- }
- this.SendGuild(ntfMsg)
- }
- func (this *Role) PlayerBattleBossOffline() {
- if this.roleMap.ChallengeBossId > 0 {
- ntfMsg := &serverproto.SSPlayerOfflineNtf{
- Uid: this.GetUUid(),
- }
- this.SendBattleBoss(ntfMsg)
- this.roleMap.ChallengeBossId = 0
- }
- }
- func (this *Role) playerMapOffline() {
- if this.roleCross != nil {
- this.roleCross.PlayerLeave(nil)
- }
- }
- func (this *Role) playerBattleOffline() {
- if this.roleBattle != nil {
- this.roleBattle.FastBattleTimeOffline()
- }
- }
- func (this *Role) SetMapRank(selfRank, totalRanks uint32, topRankList []*serverproto.RankPlayerInfo, addSystemMsg bool) {
- if this.roleBattle != nil {
- this.roleBattle.SetMapRank(selfRank, totalRanks, topRankList, addSystemMsg)
- }
- }
- func (this *Role) GetMapRank() {
- if this.roleBattle != nil {
- this.roleBattle.GetMapRank()
- }
- }
- func (this *Role) GetQuickBattleReward() {
- if this.roleBattle != nil {
- this.roleBattle.GetQuickBattleReward()
- }
- }
- // chat
- func (this *Role) CheckChatInvalid(targetId uint64, msgType int32, msg *serverproto.CSChatMessageReq) bool {
- if this.roleChat != nil {
- ret := this.roleChat.CheckChatInvalid(targetId, msgType, msg)
- if ret != serverproto.ErrorCode_ERROR_OK {
- ackMsg := &serverproto.SCChatMessageAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- return false
- }
- //发送消息
- this.roleChat.SendMsg(targetId, msgType, msg, false)
- }
- return true
- }
- func (this *Role) GetOfflineMsg(targetId uint64) {
- if this.roleChat != nil {
- ret := this.roleChat.GetOfflineMsg(targetId)
- if ret != serverproto.ErrorCode_ERROR_OK {
- ackMsg := &serverproto.SCChatOfflineMsgAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- }
- // mail
- // 添加邮件
- type AddMailST struct {
- ConfigId int32
- MailType serverproto.MailType
- ItemList map[int32]int32
- ParamList []int32
- Title string
- Content string
- }
- func (this *Role) AddMail(configId int32, mailType serverproto.MailType, itemList map[int32]int32, paramList []int32, title, content string) {
- if this.roleMail != nil {
- this.roleMail.AddMail(configId, mailType, itemList, paramList, title, content)
- }
- }
- func (this *Role) AddMailByST(st *AddMailST) {
- if this.roleMail != nil {
- this.roleMail.AddMail(st.ConfigId, st.MailType, st.ItemList, st.ParamList, st.Title, st.Content)
- }
- }
- func (this *Role) AddMail1(configId int32, mailType int32, itemList []*serverproto.KeyValueType, paramList []int32, title, content string) {
- if this.roleMail != nil {
- this.roleMail.AddMail1(configId, serverproto.MailType(mailType), itemList, paramList,
- title, content)
- }
- }
- func (this *Role) GetMailIst() {
- if this.roleMail != nil {
- this.roleMail.GetMailList()
- }
- }
- func (this *Role) MailRead(idList []int32) {
- if this.roleMail != nil {
- ret := this.roleMail.MailRead(idList)
- ackMsg := &serverproto.SCMailReadAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) MailDelRead() {
- if this.roleMail != nil {
- ret := this.roleMail.MailDelRead()
- ackMsg := &serverproto.SCMailDelReadAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) MailReward(idList []int32) {
- if this.roleMail != nil {
- ret := this.roleMail.MailReward(idList)
- if ret != serverproto.ErrorCode_ERROR_OK {
- ackMsg := &serverproto.SCMailRewardAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- }
- // 打包数据
- func (this *Role) PackRoleViewInfo(info *serverproto.ViewRoleInfo) {
- info.Id = this.uuid
- info.Brief = &serverproto.CommonPlayerBriefInfo{
- Uid: this.GetUUid(),
- NickName: this.GetNickName(),
- Gender: this.GetRoleBase().GetRoleSex(),
- ImgId: this.GetImageId(),
- FightPower: int32(this.GetRoleBase().RoleData().FightPower),
- HeadFrameId: this.GetRoleBase().RoleData().HeadFrameId,
- ConfigId: this.GetRoleBase().RoleData().HeroData.ConfigId,
- VipLevel: this.GetRoleVipLevel(),
- HeadId: this.GetHeadId(),
- }
- //这里也是有问题的,后续需要处理
- info.AttrList = this.GetRoleHero().GetMainHero().AttrList
- info.FashionData = this.GetRoleBase().roleBase.FashionData
- info.DanScore = this.GetRoleArena().arenaInfo.Score
- //世界boss,只上阵主角
- info.RoleHero = this.GetRoleBase().RoleData().HeroData
- info.Hero = &serverproto.RoleHero{}
- for _, data := range this.GetRoleHero().heroList {
- info.Hero.HeroData = append(info.Hero.HeroData, data)
- }
- info.Fashion = &serverproto.RoleFashion{}
- //for _, data := range this.roleFashion.fashionData {
- //info.Fashion.FashionList = append(info.Fashion.FashionList, data.id)
- this.roleFashion.CopyData(info.Fashion)
- //}
- for _, data := range this.roleFashion.fashionData {
- info.Fashion.FashionList = append(info.Fashion.FashionList, data.id)
- }
- if this.GetRoleGuild().roleGuild.GuildId != 0 {
- info.GuildName = this.GetRoleGuild().roleGuild.GuildName
- }
- if this.GetRolePet() != nil {
- if info.RoleHero.BattlePetId != 0 {
- pet := this.GetRolePet().getPet(info.RoleHero.BattlePetId)
- if pet != nil {
- info.PetList = append(info.PetList, pet)
- }
- }
- for _, hero := range info.Hero.HeroData {
- if hero.BattlePetId != 0 {
- pet := this.GetRolePet().getPet(hero.BattlePetId)
- if pet != nil {
- info.PetList = append(info.PetList, pet)
- }
- }
- }
- }
- }
- func (this *Role) GetSignUpInfo() {
- ackMsg := &serverproto.SCSignUpInfoAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- if this.roleActivity != nil {
- //检查是否大周期重置
- this.roleActivity.CheckNewCircle()
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_OK)
- ackMsg.SignInfo = this.roleActivity.signInfo
- ackMsg.CurSignDay = this.roleActivity.GetCurSignDay()
- ackMsg.NextSignTime = this.roleActivity.signInfo.CurSignInfo.LastSign
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) OnSignUp() {
- ackMsg := &serverproto.SCSignUpAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- if this.roleActivity != nil {
- bRet := this.roleActivity.SignUp(ackMsg)
- ackMsg.Error = int32(bRet)
- ackMsg.NextSignTime = int64(util.GetLatest5Hour())
- ackMsg.SignInfo = this.roleActivity.signInfo
- ackMsg.CurSignDay = this.roleActivity.GetCurSignDay()
- }
- this.ReplayGate(ackMsg, true)
- }
- // 强制引导
- func (this *Role) CompulsoryGuidance(storyId, status int32) {
- ackMsg := &serverproto.SCCompulsoryGuidanceAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- if this.GetRoleBase() != nil {
- //设置强制引导
- nRet := this.GetRoleBase().SetCompulsoryId(storyId, status)
- ackMsg.StoryId = storyId
- ackMsg.Status = status
- ackMsg.Error = int32(nRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- // 爬塔功能信息
- // 请求个人的爬塔信息
- func (this *Role) ClimbingTowerInfoReq() {
- if this.roleTower != nil {
- this.roleTower.GetClimbingTowerInfo()
- }
- }
- // 获取试炼馈赠
- func (this *Role) GetTowerLevelDayReward() {
- if this.roleTower != nil {
- ret := this.roleTower.GetTowerLevelDayReward()
- if ret != serverproto.ErrorCode_ERROR_OK {
- ackMsg := &serverproto.SCClimbingTowerDayRewardAck{
- Error: int32(ret),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- }
- // 查找好友数据
- func (this *Role) GetFriendTowerInfo(begin, end int32) {
- if this.roleTower != nil {
- this.roleTower.GetFriendTowerRange(begin, end)
- }
- }
- // 爬塔开始
- func (this *Role) ClimbingTowerBegin(towerLevel int32) {
- ackMsg := &serverproto.SCClimbingTowerBeginAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- TowerLevel: towerLevel,
- }
- if this.roleTower != nil {
- nRet, factorList := this.roleTower.OnTowerFightBegin(towerLevel)
- ackMsg.Error = int32(nRet)
- ackMsg.FactorList = factorList
- }
- this.ReplayGate(ackMsg, true)
- }
- // 爬塔开始
- func (this *Role) ClimbingTowerWjBegin(towerLevel int32) {
- ackMsg := &serverproto.SCClimbingTowerWjBeginAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- TowerLevel: towerLevel,
- }
- if this.roleTower != nil {
- nRet := this.roleTower.OnTowerWjFightBegin(towerLevel)
- ackMsg.Error = int32(nRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) ClimbingTowerWjBuff(buff1, buff2, buff3 int32) {
- ackMsg := &serverproto.SCClimbingTowerWjBuffAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- if this.roleTower != nil {
- var nRet serverproto.ErrorCode
- ackMsg.Buff1, ackMsg.Buff2, ackMsg.Buff3, nRet = this.roleTower.OnTowerWjFightBuff(buff1, buff2, buff3)
- ackMsg.Error = int32(nRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- // 爬塔结束
- func (this *Role) ClimbingTowerWjEnd(towerLevel, loadingTime int32, recordTimeStamp uint64) {
- ackMsg := &serverproto.SCClimbingTowerWjEndAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- if this.roleTower != nil {
- nRet := this.roleTower.OnTowerWjFightEnd(towerLevel, loadingTime, recordTimeStamp, ackMsg)
- ackMsg.Error = int32(nRet)
- //打包newTowerLevel=2的所有好友的数据
- //this.roleTower.PackFriendFightTower(towerLevel, ackMsg)
- }
- this.ReplayGate(ackMsg, true)
- }
- // 爬塔结束
- func (this *Role) ClimbingTowerEnd(towerLevel, loadingTime int32, recordTimeStamp uint64) {
- ackMsg := &serverproto.SCClimbingTowerEndAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- if this.roleTower != nil {
- nRet := this.roleTower.OnTowerFightEnd(towerLevel, loadingTime, recordTimeStamp, ackMsg)
- ackMsg.Error = int32(nRet)
- //打包newTowerLevel=2的所有好友的数据
- this.roleTower.PackFriendFightTower(towerLevel, ackMsg)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) GetFriendBriefFromDB(final bool, begin int32, end int32, briefs []*serverproto.CommonPlayerBriefInfo) {
- if this.roleTower != nil {
- this.roleTower.SetFriendBriefInfo(briefs)
- //同时返回数据到客户端
- if final == true {
- this.roleTower.SendClimbingTowerInfo(begin, end)
- }
- }
- }
- func (this *Role) GetTowerFightCountReward(rushRound int32, rewardType int32) {
- ackMsg := &serverproto.SCRushActivityRewardAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- RewardType: rewardType,
- RushType: model.Rush_Type_Tower,
- }
- if this.GetRoleTower() != nil {
- nRet := this.GetRoleTower().GetRushTowerBaseReward(ackMsg, rushRound)
- ackMsg.Error = int32(nRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) GetRushTowerInfo(ackMsg *serverproto.SCTowerActivityAck, curRushRound int32) {
- if this.GetRoleTower() != nil {
- this.GetRoleTower().GetRushTowerInfo(ackMsg, curRushRound)
- }
- }
- func (this *Role) GetRushTowerRankReward(ssAck *serverproto.SSGetRushRewardAck) {
- ackMsg := &serverproto.SCRushActivityRewardAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- RewardType: model.Rush_Reward_Type_Rank,
- RushType: model.Rush_Type_Tower,
- }
- if this.GetRoleTower() != nil {
- nRet := this.GetRoleTower().GetRushTowerRankReward(ssAck)
- if nRet == serverproto.ErrorCode_ERROR_OK {
- ackMsg.ItemList = ssAck.ItemList
- }
- ackMsg.Error = int32(nRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- // 英灵殿冲榜
- func (this *Role) GetArenaFightCountReward(rushRound int32, rewardType int32) {
- ackMsg := &serverproto.SCRushActivityRewardAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- RewardType: rewardType,
- RushType: model.Rush_Type_Arena,
- }
- if this.GetRoleArena() != nil {
- nRet := this.GetRoleArena().GetRushArenaBaseReward(ackMsg, rushRound)
- ackMsg.Error = int32(nRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) GetRushArenaInfo(ackMsg *serverproto.SCArenaActivityAck, curRushRound int32) {
- if this.GetRoleArena() != nil {
- this.GetRoleArena().GetRushArenaInfo(ackMsg, curRushRound)
- }
- }
- func (this *Role) GetRushArenaRankReward(ssAck *serverproto.SSGetRushRewardAck) {
- ackMsg := &serverproto.SCRushActivityRewardAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- RewardType: model.Rush_Reward_Type_Rank,
- RushType: model.Rush_Type_Arena,
- }
- if this.GetRoleArena() != nil {
- nRet := this.GetRoleArena().GetRushArenaRankReward(ssAck)
- if nRet == serverproto.ErrorCode_ERROR_OK {
- ackMsg.ItemList = ssAck.ItemList
- }
- ackMsg.Error = int32(nRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- // 宠物冲榜
- func (this *Role) GetPetFightCountReward(rushRound int32, rewardType int32) {
- ackMsg := &serverproto.SCRushActivityRewardAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- RewardType: rewardType,
- RushType: model.Rush_Type_Pet,
- }
- if this.GetRolePet() != nil {
- nRet := this.GetRolePet().GetBaseScoreReward(ackMsg, rushRound)
- ackMsg.Error = int32(nRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) GetRushPetRankReward(ssAck *serverproto.SSGetRushRewardAck) {
- ackMsg := &serverproto.SCRushActivityRewardAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- RewardType: model.Rush_Reward_Type_Rank,
- RushType: model.Rush_Type_Pet,
- }
- if this.GetRolePet() != nil {
- nRet := this.GetRolePet().GetRushPetRankReward(ssAck)
- if nRet == serverproto.ErrorCode_ERROR_OK {
- ackMsg.ItemList = ssAck.ItemList
- }
- ackMsg.Error = int32(nRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) GetRushPetInfo(ackMsg *serverproto.SCPetActivityAck, curRushRound int32) {
- if this.GetRolePet() != nil {
- this.GetRolePet().GetRushPetInfo(ackMsg, curRushRound)
- }
- }
- // 英灵殿冲榜
- func (this *Role) GetFightCountReward(rushRound int32, rushType int32, rewardType int32) {
- ackMsg := &serverproto.SCRushActivityRewardAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- RewardType: rewardType,
- RushType: rushType,
- }
- if this.GetRoleRush() != nil {
- nRet := this.GetRoleRush().GetBaseReward(ackMsg, rushType, rushRound)
- ackMsg.Error = int32(nRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) GetRushInfo(ackMsg *serverproto.SCRushActivityAck, curRushRound int32) {
- if this.GetRoleRush() != nil {
- this.GetRoleRush().GetRushInfo(ackMsg, curRushRound)
- }
- }
- func (this *Role) GetRushRankReward(ssAck *serverproto.SSGetRushRewardAck) {
- ackMsg := &serverproto.SCRushActivityRewardAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- RewardType: model.Rush_Reward_Type_Rank,
- RushType: ssAck.RushType,
- }
- if this.GetRoleRush() != nil {
- nRet := this.GetRoleRush().GetRushRankReward(ssAck)
- if nRet == serverproto.ErrorCode_ERROR_OK {
- ackMsg.ItemList = ssAck.ItemList
- }
- ackMsg.Error = int32(nRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- //1:bossReward 2:pvp
- func (this *Role) GetBattleRecord(recordType int32, paramList []uint32) {
- if len(paramList) <= 0 {
- ackMsg := &serverproto.SCPlayerBattleRecordAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- this.ReplayGate(ackMsg, true)
- return
- }
- msgReq := &serverproto.CSPlayerBattleRecordReq{
- RecordType: recordType,
- ParamList: paramList,
- }
- this.SendRank(msgReq)
- }
- func (this *Role) OnGetBattleRecordAck(ssMsg *serverproto.SCPlayerBattleRecordAck) {
- ackMsg := &serverproto.SCPlayerBattleRecordAck{}
- for idx := 0; idx < len(ssMsg.RecordList); idx++ {
- levelCfgData, ok := serverproto.LevelCfgLoader[ssMsg.RecordList[idx].MapLevelId]
- if !ok || levelCfgData.Version > ssMsg.RecordList[idx].BattleVersion {
- continue
- }
- ackMsg.RecordList = append(ackMsg.RecordList, ssMsg.RecordList[idx])
- }
- this.ReplayGate(ackMsg, true)
- }
- // //////////////////////////// 公会功能 //////////////////////////////////////
- // 创建工会
- func (this *Role) CheckBuildGuild(guildName string, guildBadge int32) serverproto.ErrorCode {
- //检查是否有公会,有就据掉,没有就转GuildServer
- bRet := this.GetRoleGuild().CanBuildGuild(guildName)
- if bRet != serverproto.ErrorCode_ERROR_OK { //有工会不能创建
- ackMsg := &serverproto.SCBuildGuildAck{
- Error: int32(bRet),
- }
- this.ReplayGate(ackMsg, true)
- return bRet
- }
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *Role) CheckApplyGuild(guildId uint64) bool {
- //检查是否有公会,有就据掉,没有就转GuildServer
- //检查是否在被拒绝列表中
- bRet := this.GetRoleGuild().CheckApply(guildId)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- ackMsg := &serverproto.SCApplyGuildAck{
- Error: int32(bRet),
- }
- this.ReplayGate(ackMsg, true)
- return false
- }
- return true
- }
- // 申请处理
- func (this *Role) CheckApplyInfo(msg *serverproto.CSApplyInfoHandleReq) serverproto.ErrorCode {
- if this.GetRoleGuild().roleGuild.GuildId == 0 {
- ackMsg := &serverproto.SCApplyInfoHandleAck{
- Error: int32(serverproto.ErrorCode_ERROR_GUILD_NOT_IN_GUILD),
- }
- this.ReplayGate(ackMsg, true)
- return serverproto.ErrorCode_ERROR_GUILD_NOT_IN_GUILD
- }
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *Role) CheckGuildModifyInfo(msg *serverproto.CSSetGuildInfoReq) serverproto.ErrorCode {
- if this.GetRoleGuildId() == 0 {
- return serverproto.ErrorCode_ERROR_GUILD_NOT_IN_GUILD
- }
- //公告长度
- lenData, ok1 := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Guild_Recruit_Max_Len)]
- if !ok1 {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- noticeLen := utf8.RuneCountInString(msg.RecruitNotice)
- if int32(noticeLen) > lenData.IVal {
- return serverproto.ErrorCode_ERROR_GUILD_NOTICE_LEN
- }
- //检查敏感字
- bSensitive := SensitiveUtil.IsMatch(msg.RecruitNotice)
- if bSensitive == true {
- return serverproto.ErrorCode_ERROR_GUILD_NAME_SENSITIVE
- }
- //校验徽章是否存在,
- _, ok := serverproto.GuildBadgeCfgLoader[msg.GuildBadge]
- if ok == false {
- return serverproto.ErrorCode_ERROR_GUILD_CONFIG_NOT_FOUND
- }
- //校验入会等级是否合理
- globalData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Guild_Apply_Level)]
- if !ok {
- return serverproto.ErrorCode_ERROR_GUILD_CONFIG_NOT_FOUND
- }
- levelRes := strings.Split(globalData.SVal, ":")
- if len(levelRes) >= 2 {
- minLevel, _ := model.Str2Num(levelRes[0])
- maxLevel, _ := model.Str2Num(levelRes[1])
- if int32(minLevel) > msg.JoinLevel || msg.JoinLevel > int32(maxLevel) {
- return serverproto.ErrorCode_ERROR_GUILD_OUT_APPLY_LEVEL
- }
- }
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *Role) CheckGuildRename(guildName string) serverproto.ErrorCode {
- if this.GetRoleGuildId() == 0 {
- return serverproto.ErrorCode_ERROR_GUILD_NOT_IN_GUILD
- }
- nameLen := utf8.RuneCountInString(guildName)
- if int32(nameLen) < model.GlobalGuildMinNameStringLen || int32(nameLen) > model.GlobalGuildMaxNameStringLen {
- return serverproto.ErrorCode_ERROR_GUILD_NAME_LEN
- }
- //检查敏感字
- bSensitive := SensitiveUtil.IsMatch(guildName)
- if bSensitive == true {
- return serverproto.ErrorCode_ERROR_GUILD_NAME_SENSITIVE
- }
- //校验消耗
- globalData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Guild_Rename_Cost)]
- if !ok {
- return serverproto.ErrorCode_ERROR_GUILD_CONFIG_NOT_FOUND
- }
- var costItemList = map[int32]int32{}
- costRes := strings.Split(globalData.SVal, ":")
- if len(costRes) >= 2 {
- itemId, _ := model.Str2Num(costRes[0])
- itemNum, _ := model.Str2Num(costRes[1])
- costItemList[int32(itemId)] += int32(itemNum)
- }
- bRet := this.CheckResLitNum(costItemList)
- if bRet == false {
- return serverproto.ErrorCode_ERROR_RES_NOT_ENOUGH
- }
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *Role) CheckGuildRenotice(notice string) serverproto.ErrorCode {
- globalData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Guild_Notice_Max_Len)]
- if !ok {
- return serverproto.ErrorCode_ERROR_FAIL
- }
- if this.GetRoleGuildId() == 0 {
- return serverproto.ErrorCode_ERROR_GUILD_NOT_IN_GUILD
- }
- //检查敏感字
- bSensitive := SensitiveUtil.IsMatch(notice)
- if bSensitive == true {
- return serverproto.ErrorCode_ERROR_GUILD_NAME_SENSITIVE
- }
- noticeLen := utf8.RuneCountInString(notice)
- if int32(noticeLen) > globalData.IVal {
- return serverproto.ErrorCode_ERROR_GUILD_NOTICE_LEN
- }
- return serverproto.ErrorCode_ERROR_OK
- }
- func (this *Role) CheckGuildBossChallenge(bossId uint32, damage uint32, fightTime uint32) serverproto.ErrorCode {
- //检查是否有公会,
- guildId := this.GetRoleGuildId()
- if guildId == 0 {
- return serverproto.ErrorCode_ERROR_GUILD_NOT_IN_GUILD
- }
- bRet := this.GetRoleGuild().CheckBossFight(bossId, damage, fightTime)
- return bRet
- }
- func (this *Role) OnChangeGuileNameSuccess() {
- //扣除消耗
- globalData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Guild_Rename_Cost)]
- if !ok {
- return
- }
- var costItemList = map[int32]int32{}
- costRes := strings.Split(globalData.SVal, ":")
- if len(costRes) >= 2 {
- itemId, _ := model.Str2Num(costRes[0])
- itemNum, _ := model.Str2Num(costRes[1])
- costItemList[int32(itemId)] += int32(itemNum)
- }
- bRet := this.CheckResLitNum(costItemList)
- if bRet == false {
- return
- }
- this.DelItemList(costItemList, AddItemST{AddFrom: AddFrom_Guild})
- }
- func (this *Role) GetRoleGuildId() uint64 {
- if this.GetRoleGuild() == nil {
- return 0
- }
- return this.GetRoleGuild().roleGuild.GuildId
- }
- func (this *Role) GuildDemonBuyFightCount(buyCount int32) {
- if this.GetRoleGuild() != nil {
- ackMsg := &serverproto.SCGuildDemonBuyFightCountAck{}
- err, leftUseCount, leftBuyCount := this.GetRoleGuild().BuyDemonFightCount(buyCount)
- ackMsg.Error = int32(err)
- ackMsg.LeftFightCount = leftUseCount
- ackMsg.LeftBuyCount = leftBuyCount
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) GetRoleVipLevel() int32 {
- if this.GetRoleBase() != nil {
- return this.GetRoleBase().roleBase.VipLevel
- }
- return 0
- }
- func (this *Role) GetHeadId() int32 {
- if this.roleHead != nil {
- return this.roleHead.GetHeadIdIng()
- }
- return 0
- }
- func (this *Role) GetHeadMag() *RoleHead {
- return this.roleHead
- }
- func (this *Role) OnDrawReq(drawType int32, drawCount int32) {
- ackMsg := &serverproto.SCDrawCardAck{
- DrawType: drawType,
- DrawCount: drawCount,
- }
- if this.roleDraw != nil {
- bRet := this.GetRoleDraw().DrawReq(drawType, drawCount, ackMsg)
- ackMsg.Error = int32(bRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) CheckRushShopInfoGet(goodsType, goodsId, count int32) bool {
- reqMsg := &serverproto.SSGetRushShopBuyReq{}
- switch (serverproto.PayGoodsType)(goodsType) {
- case serverproto.PayGoodsType_EPayType_RushTower:
- reqMsg.RushType = model.Rush_Type_Tower
- case serverproto.PayGoodsType_EPayType_RushArena:
- reqMsg.RushType = model.Rush_Type_Arena
- case serverproto.PayGoodsType_EPayType_RushMap:
- reqMsg.RushType = model.Rush_Type_Map
- case serverproto.PayGoodsType_EPayType_RushPet:
- reqMsg.RushType = model.Rush_Type_Pet
- case serverproto.PayGoodsType_EPayType_RushSkill:
- reqMsg.RushType = model.Rush_Type_Skill
- default:
- return false
- }
- reqMsg.Uid = this.GetUUid()
- reqMsg.ShopType = goodsType
- reqMsg.GoodsId = goodsId
- reqMsg.GoodsNum = count
- this.SendRank(reqMsg)
- return true
- }
- func (this *Role) OnPayCallback2(cpOrderId uint64) {
- msg33 := &serverproto.SSPayOrderDbReq{
- Uid: this.GetUUid(),
- CpOrderId: cpOrderId,
- }
- this.SendDb(msg33)
- }
- func (this *Role) CheckOrderInfo(payRewardInfo *serverproto.PayOrderSaveInfo) bool {
- if payRewardInfo == nil {
- return false
- }
- if this.roleBag.CanDelItem(40001, int32(payRewardInfo.Amount*100)) {
- this.DelItem(40001, int32(payRewardInfo.Amount*100), AddItemST{
- AddFrom: AddFrom_Activities,
- })
- util.ErrorF("uid:%v use cash buy :%v", this.GetUUid(), payRewardInfo.CpOrderId)
- return true
- }
- return false
- }
- func (this *Role) PayInfoGet(goodsType, goodsId, count int32, rushStage, rushRound int32, cpOrderId uint64, sdkOrderId string) {
- //合服期间,无法进行飞艇探索
- if goodsType == int32(serverproto.PayGoodsType_EPayType_RuneExplore) {
- bRet := this.CheckInCombinedService()
- if bRet == true {
- ackMsg := &serverproto.SCPayInfoGetAck{
- Error: int32(serverproto.ErrorCode_ERROR_RUNE_EXPLORE_ON_COMBINE_SERVER),
- GoodsType: goodsType,
- GoodsId: goodsId,
- Count: count,
- }
- this.ReplayGate(ackMsg, true)
- return
- }
- }
- ret, payOrderInfo := this.payInfoGet(goodsType, goodsId, count, rushStage, rushRound, cpOrderId)
- ackMsg := &serverproto.SCPayInfoGetAck{
- Error: int32(ret),
- GoodsType: goodsType,
- GoodsId: goodsId,
- Count: count,
- }
- msg33 := &serverproto.SSGetServerPayMailReq{
- Uid: this.GetUUid(),
- //ZoneId: int32(service.GetServiceConfig().Node.Zone),
- }
- this.SendDb(msg33)
- if ret == serverproto.ErrorCode_ERROR_OK {
- // 如果是免费或者价格为0时直接购买成功
- if payOrderInfo.Amount <= 0 {
- ntfMsg := &serverproto.SCPayForGoodsNtf{}
- ntfMsg.GoodsId = goodsId
- ntfMsg.ItemList = payOrderInfo.RewardList
- ntfMsg.GoodsType = goodsType
- ntfMsg.GoodsNum = count
- ntfMsg.CpOrderId = 0
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_PAY_GOOD_PRICE_FREE)
- this.ReplayGate(ackMsg, true)
- this.ReplayGate(ntfMsg, true)
- util.InfoF("uid=%v free: shop:%v id:%v, count:%v", this.GetUUid(), payOrderInfo.GoodsType, payOrderInfo.GoodsId, payOrderInfo.Count)
- return
- }
- calCeilAmount := math.Ceil(float64(payOrderInfo.Amount))
- // 按照配置比例获取RO币
- if model.GlobalRoCoinFactor > 0 {
- tmpRoCoin := calCeilAmount * float64(model.GlobalRoCoinFactor)
- //util.ErrorF("ro1111:%v ,%v ,%v", tmpRoCoin, calCeilAmount, model.GlobalRoCoinFactor)
- payOrderInfo.RewardList = append(payOrderInfo.RewardList, &serverproto.KeyValueType{
- Key: int32(serverproto.ResType_Res_ROCoin),
- Value: int32(tmpRoCoin),
- })
- }
- //给VIP经验
- if model.GlobalRMBToVipExpRMB > 0 {
- vipExp := float32(calCeilAmount) * model.GlobalRMBToVipExpVip / float32(model.GlobalRMBToVipExpRMB)
- payOrderInfo.RewardList = append(payOrderInfo.RewardList, &serverproto.KeyValueType{
- Key: int32(serverproto.ResType_Res_VipExp),
- Value: int32(vipExp),
- })
- //this.role.AddRes(int32(serverproto.ResType_Res_VipExp), AddItemST{ItemCount: int32(vipExp)}, true)
- }
- if service.GetServiceConfig().Node.AuthMode == AUTHMODE_PC {
- //内网PC模式下直接购买成功
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_PAY_PRODUCTION_MODE)
- this.ReplayGate(ackMsg, true)
- this.OnPayCallback(payOrderInfo, false, false)
- util.InfoF("uid=%v pc mode: shop:%v id:%v, count:%v, price:%v", this.GetUUid(), payOrderInfo.GoodsType, payOrderInfo.GoodsId, payOrderInfo.Count, payOrderInfo.Amount)
- return
- } else if service.GetServiceConfig().Node.AuthMode == AUTHMODE_ACTIVE {
- //激活码模式下提示充值功能未开放
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_PAY_NOT_OPEN)
- this.ReplayGate(ackMsg, true)
- util.InfoF("uid=%v pc mode: shop:%v id:%v, count:%v, price:%v", this.GetUUid(), payOrderInfo.GoodsType, payOrderInfo.GoodsId, payOrderInfo.Count, payOrderInfo.Amount)
- return
- }
- payOrderInfo.SdkOrderId = sdkOrderId
- //保存订单信息到数据库
- ackMsg.Amount = payOrderInfo.Amount
- ackMsg.CpOrderId = payOrderInfo.CpOrderId
- ackMsg.GoodsName = payOrderInfo.GoodsName
- //ackMsg.GoodsName = service.GetServiceConfig().Node.PayCallBack
- ssSaveReqMsg := &serverproto.SSPayInfoSaveReq{
- PayOrderInfo: payOrderInfo,
- SaveNotify: true,
- }
- this.SendDb(ssSaveReqMsg)
- } else {
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) payInfoGet(goodsType, goodsId, count int32, rushStage, rushRound int32, cpOrderId uint64) (serverproto.ErrorCode, *serverproto.PayOrderSaveInfo) {
- if count <= 0 {
- return serverproto.ErrorCode_ERROR_PAY_ITEM_NO, nil
- }
- payRewardInfo := &serverproto.PayOrderSaveInfo{
- OrderState: int32(serverproto.PayOrderState_EPayOrderState_Gen),
- GoodsId: goodsId,
- GoodsType: goodsType,
- //早期uid生成规则修改过一次,老的uid无法通过uid来获取到zoneid
- //CpOrderId: model.GenerateUidByZone(int(this.GetSelectZone())),
- Uid: this.GetUUid(),
- OrderProcessTime: util.GetTimeMilliseconds(),
- SId: int32(service.GetServiceConfig().Node.Zone),
- }
- if cpOrderId > 0 {
- payRewardInfo.CpOrderId = cpOrderId
- } else {
- payRewardInfo.CpOrderId = model.GenerateUidByZone(int(this.GetSelectZone()))
- }
- // 根据goodsType查找对应系统物品是否存在,并获得价格,物品
- // for test
- //payRewardInfo.Count = count
- //payRewardInfo.Amount = 1
- //payRewardInfo.GoodsName = "testgoods"
- //payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{Key: 1, Value: 1000})
- switch (serverproto.PayGoodsType)(goodsType) {
- case serverproto.PayGoodsType_EPayType_Discount: //超值礼包购买
- if !this.roleActivity.PayInfoGetDiscount(payRewardInfo) {
- return serverproto.ErrorCode_ERROR_PAY_ITEM_NO, nil
- }
- case serverproto.PayGoodsType_EPayType_MonthCard:
- bRet := this.roleRune.BuyMonthCardShopItem(payRewardInfo)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- return bRet, nil
- }
- case serverproto.PayGoodsType_EPayType_NormalBag:
- bRet := this.roleRune.BuyBagShopItem(payRewardInfo)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- return bRet, nil
- }
- case serverproto.PayGoodsType_EPayType_LimitBag:
- bRet := this.roleRune.BuyLimitShopItem(payRewardInfo)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- return bRet, nil
- }
- case serverproto.PayGoodsType_EPayType_RushTower:
- bRet := this.roleRune.BuyRushTowerShopItem(payRewardInfo, rushStage, rushRound)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- return bRet, nil
- }
- case serverproto.PayGoodsType_EPayType_RushArena:
- bRet := this.roleRune.BuyRushArenaShopItem(payRewardInfo, rushStage, rushRound)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- return bRet, nil
- }
- case serverproto.PayGoodsType_EPayType_RushMap:
- bRet := this.roleRune.BuyRushMapShopItem(payRewardInfo, rushStage, rushRound)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- return bRet, nil
- }
- case serverproto.PayGoodsType_EPayType_GuildBattle:
- bRet := this.roleRune.BuyGuildBattleShopItem(payRewardInfo)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- return bRet, nil
- }
- case serverproto.PayGoodsType_EPayType_RuneExplore:
- bRet := this.roleRune.BuyRuneExplore(payRewardInfo)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- return bRet, nil
- }
- case serverproto.PayGoodsType_EPayType_RushPet:
- bRet := this.roleRune.BuyRushPetShopItem(payRewardInfo, rushStage, rushRound)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- return bRet, nil
- }
- case serverproto.PayGoodsType_EPayType_RushSkill:
- bRet := this.roleRune.BuyRushSkillShopItem(payRewardInfo, rushStage, rushRound)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- return bRet, nil
- }
- case serverproto.PayGoodsType_EPayType_RushIdol:
- bRet := this.roleRune.BuyIdolSeasonShopItem(payRewardInfo)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- return bRet, nil
- }
- case serverproto.PayGoodsType_EPayType_SpecialPrivilege:
- // 特权卡商店
- bRet := this.roleRune.BuySpecialPrivilegeShopItem(payRewardInfo)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- return bRet, nil
- }
- case serverproto.PayGoodsType_EPayType_PassCheck:
- // RO通行证
- bRet := this.roleRune.BuyPassCheck(payRewardInfo)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- return bRet, nil
- }
- case serverproto.PayGoodsType_EPayType_BTRecharge100:
- // bt百元大礼包充值
- bRet := this.roleBT.BuyRecharge100(payRewardInfo)
- if bRet != serverproto.ErrorCode_ERROR_OK {
- return bRet, nil
- }
- default:
- return serverproto.ErrorCode_ERROR_FAIL, nil
- }
- payRewardInfo.GoodsName = service.GetServiceConfig().Node.PayCallBack
- util.ErrorF("uid:%v pay info platform:%v order:%v", this.GetUUid(), this.platform, payRewardInfo)
- //if this.platform == SDKPlatform_YouYi_IOS || this.platform == "PC" {
- // payRewardInfo.GoodsName += ",1"
- //}
- return serverproto.ErrorCode_ERROR_OK, payRewardInfo
- }
- func (this *Role) OnPayCallback(payRewardInfo *serverproto.PayOrderSaveInfo, bSave bool, bAck bool) {
- //获取充值奖励
- var addItemList = map[int32]int32{}
- for idx := 0; idx < len(payRewardInfo.RewardList); idx++ {
- addItemList[payRewardInfo.RewardList[idx].Key] += payRewardInfo.RewardList[idx].Value
- }
- if this.GetRoleBag().CanAddItemList(addItemList) == serverproto.ErrorCode_ERROR_OK {
- if payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_MonthCard) ||
- payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_NormalBag) ||
- payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_LimitBag) ||
- payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushTower) ||
- payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushMap) ||
- payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushPet) ||
- payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushSkill) ||
- payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushArena) ||
- payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushIdol) {
- this.AddItemList(addItemList, AddFrom_Rune, true)
- } else {
- this.AddItemList(addItemList, AddFrom_Pay, true)
- }
- } else {
- mailST := &AddMailST{
- ConfigId: model.GlobalMailIdPayReward,
- MailType: serverproto.MailType_MailType_Pay,
- ItemList: addItemList,
- }
- this.AddMailByST(mailST)
- util.InfoF("uid=%v OnPayCallback add bag error, use mail payRewardInfo=%v", this.GetUUid(), payRewardInfo)
- }
- if bAck {
- ackMsg := &serverproto.SCPayInfoOrderOKListGetAck{}
- for k, v := range addItemList {
- ackMsg.RewardItemList = append(ackMsg.RewardItemList, &serverproto.KeyValueType{Key: k, Value: v})
- }
- this.ReplayGate(ackMsg, true)
- }
- //根据各个系统处理不同情况
- switch (serverproto.PayGoodsType)(payRewardInfo.GoodsType) {
- case serverproto.PayGoodsType_EPayType_Discount: //超值礼包购买
- this.roleActivity.OnPayInfoGetDiscount(payRewardInfo)
- case serverproto.PayGoodsType_EPayType_MonthCard: //
- this.GetRoleRune().OnBuyMonthCardShopItem(payRewardInfo)
- case serverproto.PayGoodsType_EPayType_NormalBag: //
- fallthrough
- case serverproto.PayGoodsType_EPayType_LimitBag: //
- this.GetRoleRune().OnBuyItemSuccess(payRewardInfo)
- case serverproto.PayGoodsType_EPayType_RushTower: //
- fallthrough
- case serverproto.PayGoodsType_EPayType_RushMap: //
- fallthrough
- case serverproto.PayGoodsType_EPayType_RushPet: //
- fallthrough
- case serverproto.PayGoodsType_EPayType_RushSkill: //
- fallthrough
- case serverproto.PayGoodsType_EPayType_RushArena: //
- this.GetRoleRune().OnBuyRushShopSuccess(payRewardInfo)
- case serverproto.PayGoodsType_EPayType_GuildBattle:
- this.GetRoleRune().OnBuyGuildBattleSuccess(payRewardInfo)
- case serverproto.PayGoodsType_EPayType_RuneExplore:
- this.GetRoleRune().RuneUnlock()
- case serverproto.PayGoodsType_EPayType_RushIdol:
- this.GetRoleRune().OnBuyIdolSeasonSuccess(payRewardInfo)
- case serverproto.PayGoodsType_EPayType_SpecialPrivilege:
- // 特权卡商店
- this.GetRoleRune().OnBuySpecialPrivilege(payRewardInfo)
- case serverproto.PayGoodsType_EPayType_PassCheck:
- // RO通行证
- this.GetRoleRune().OnBuyPassCheck(payRewardInfo)
- case serverproto.PayGoodsType_EPayType_BTRecharge100:
- // bt百元大礼包充值
- this.roleBT.OnBuyRecharge100(payRewardInfo)
- default:
- }
- ntfMsg := &serverproto.SCPayForGoodsNtf{}
- ntfMsg.GoodsId = payRewardInfo.GoodsId
- ntfMsg.ItemList = payRewardInfo.RewardList
- ntfMsg.GoodsType = payRewardInfo.GoodsType
- ntfMsg.GoodsNum = payRewardInfo.Count
- ntfMsg.CpOrderId = payRewardInfo.CpOrderId
- this.ReplayGate(ntfMsg, true)
- //充值金额 payRewardInfo.Amount
- // 充值成功后的系统相关处理
- this.GetRoleBase().AddPayRecharge(payRewardInfo)
- ////////
- if bSave {
- payRewardInfo.OrderState = int32(serverproto.PayOrderState_EPayOrderState_PayOkReward)
- ssSaveReqMsg := &serverproto.SSPayInfoSaveReq{
- PayOrderInfo: payRewardInfo,
- }
- this.SendDb(ssSaveReqMsg)
- }
- }
- func (this *Role) PayInfoGetForCreditRecharge(goodsId, count int32) {
- err := this.roleRune.BuyCreditRechargeShopItem(goodsId, count)
- if err != serverproto.ErrorCode_ERROR_OK {
- ackMsg := &serverproto.SCCreditRechargeShopItemBuyAck{
- Error: int32(err),
- GoodsId: goodsId,
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- // 领取特权卡奖励
- func (this *Role) SpecialPrivilegeReward() {
- err := this.roleRune.SpecialPrivilegeReward()
- if err != serverproto.ErrorCode_ERROR_OK {
- ackMsg := &serverproto.SCRuneSpecialPrivilegeRewardAck{
- Error: int32(err),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) PayInfoGetForRoCoin(goodsId, count int32) {
- err := this.roleRune.PayInfoGetForRoCoin(goodsId, count)
- if err != serverproto.ErrorCode_ERROR_OK {
- ackMsg := &serverproto.SCBTRoCoinShopItemBuyAck{
- GoodsType: Rune_Shop_Type_Bag,
- SubType: Rune_BagShop_Type_ROCoin,
- Error: int32(err),
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- // GM充值
- func (this *Role) GMPay(amount float32) {
- payRewardInfo := &serverproto.PayOrderSaveInfo{
- Amount: amount,
- OrderProcessTime: util.GetTimeMilliseconds(),
- }
- this.OnPayCallback(payRewardInfo, false, false)
- }
- func (this *Role) GMCalAttr() {
- //var heroList []*serverproto.HeroData
- //heroList = append(heroList, this.roleHero.GetMainHero())
- this.roleBattleAttr.AttrChange(AttrChangeST{
- ChangeType: Attr_Change_None,
- ChangeHeroData: this.roleHero.GetMainHero(),
- })
- for _, val := range this.roleHero.heroList {
- //heroList = append(heroList, val)
- this.roleBattleAttr.AttrChange(AttrChangeST{
- ChangeType: Attr_Change_None,
- ChangeHeroData: val,
- })
- //this.roleBattleAttr.calcAttrHero(val, AttrChangeST{})
- }
- }
- func (this *Role) GetRuneShopInfo(shopType int32, subShop int32) {
- //冲榜卢恩商店流程
- if shopType == Rune_Shop_Type_RushTower ||
- shopType == Rune_Shop_Type_RushArena ||
- shopType == Rune_Shop_Type_RushMap ||
- shopType == Rune_Shop_Type_RushSkill ||
- shopType == Rune_Shop_Type_RushPet {
- reqMsg := &serverproto.SSGetRushShopInfoReq{}
- reqMsg.Uid = this.GetUUid()
- if shopType == Rune_Shop_Type_RushTower {
- reqMsg.RushType = model.Rush_Type_Tower
- } else if shopType == Rune_Shop_Type_RushArena {
- reqMsg.RushType = model.Rush_Type_Arena
- } else if shopType == Rune_Shop_Type_RushMap {
- reqMsg.RushType = model.Rush_Type_Map
- } else if shopType == Rune_Shop_Type_RushPet {
- reqMsg.RushType = model.Rush_Type_Pet
- } else if shopType == Rune_Shop_Type_RushSkill {
- reqMsg.RushType = model.Rush_Type_Skill
- }
- reqMsg.ShopType = shopType
- reqMsg.SubShopId = subShop
- this.SendRank(reqMsg)
- return
- }
- //其他商店
- ackMsg := &serverproto.SCRuneShopInfoAck{
- ShopType: shopType,
- SubShop: subShop,
- }
- if this.GetRoleRune() != nil {
- this.GetRoleRune().GetShopInfo(shopType, subShop, ackMsg)
- }
- util.InfoF("[role.go] GetRuneShopInfo:%+v", *ackMsg)
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) GetBTShopInfo(shopType int32, subShop int32) {
- util.InfoF("[GetBTShopInfo] shopType=%v subShop:%v", shopType, subShop)
- // 100充值钱包商店
- // RO币礼包商店
- ackMsg := &serverproto.SCBTShopInfoAck{
- ShopType: shopType,
- SubShop: subShop,
- }
- switch shopType {
- case Rune_Shop_Type_CreditRecharge: // 充值钱包商店
- fallthrough
- case Rune_Shop_Type_Bag: // RO币礼包商店
- if this.GetRoleRune() != nil {
- this.GetRoleRune().GetBTShopInfo(shopType, subShop, ackMsg)
- }
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) GetRushShopInfo(msg *serverproto.SSGetRushShopInfoAck) {
- ackMsg := &serverproto.SCRuneShopInfoAck{
- ShopType: msg.ShopType,
- SubShop: msg.SubShopId,
- }
- if this.GetRoleRune() != nil {
- this.GetRoleRune().GetRuneShopInfo(msg, ackMsg)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) OnRuneExploreInfo() {
- ackMsg := &serverproto.SCExploreInfoAck{}
- if this.GetRoleRune() != nil {
- this.GetRoleRune().runeExplore.ConvertMsg(ackMsg)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) OnRuneMaxLvlAward() {
- var ackMsg *serverproto.SCExploreExtraRewardAck = nil
- if this.GetRoleRune() != nil {
- ackMsg = this.GetRoleRune().MaxLvlAward()
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) OnRuneReward(msg *serverproto.CSExploreRewardReq) {
- if msg == nil {
- return
- }
- var ret *serverproto.SCExploreRewardAck = nil
- if rune := this.GetRoleRune(); rune != nil {
- //领取类型:1表示普通奖励,2高级奖励
- ret = rune.OnRuneReward(msg.Level, msg.RewardType)
- //if msg.RewardType == 1 {
- // ret = this.GetRoleRune().RuneReward(msg.Level)
- //} else if msg.RewardType == 2 {
- // ret = this.GetRoleRune().RuneCashReward(msg.Level)
- //}
- }
- this.ReplayGate(ret, true)
- }
- func (this *Role) GetResNotice(resType int32) serverproto.ErrorCode {
- switch serverproto.ResType(resType) {
- case serverproto.ResType_Res_Coin:
- return serverproto.ErrorCode_ERROR_MONEY_NOT_ENOUGH
- case serverproto.ResType_Res_Rmb:
- return serverproto.ErrorCode_ERROR_RMB_NOT_ENOUGH
- case serverproto.ResType_Res_Cruise:
- return serverproto.ErrorCode_ERROR_SHOP_RESOURCE_NOT_NEOUGH_CRUISE
- case serverproto.ResType_Res_SkillBook:
- return serverproto.ErrorCode_ERROR_SHOP_RESOURCE_NOT_NEOUGH_SKILLBOOK
- case serverproto.ResType_Res_Sprite:
- return serverproto.ErrorCode_ERROR_SHOP_RESOURCE_NOT_NEOUGH_SPRITE
- case serverproto.ResType_Res_PetCoin:
- return serverproto.ErrorCode_ERROR_SHOP_RESOURCE_NOT_NEOUGH_PETPIECE
- case serverproto.ResType_Res_Guild:
- return serverproto.ErrorCode_ERROR_SHOP_RESOURCE_NOT_NEOUGH_GUILD
- case serverproto.ResType_Res_HightSkillExp:
- return serverproto.ErrorCode_ERROR_SHOP_RESOURCE_NOT_NEOUGH_SKILLBOOK
- }
- return serverproto.ErrorCode_ERROR_SHOP_RESOURCE_NOT_NEOUGH
- }
- func (this *Role) OnAntiCheatReq(cheatType int32) {
- if this.GetRoleStatistic() != nil {
- this.GetRoleStatistic().RecordCheatData(cheatType)
- ackMsg := &serverproto.SCAntiCheatAck{}
- this.ReplayGate(ackMsg, true)
- }
- }
- func (this *Role) GiftReward(ackMsg *serverproto.SCGiftRewardAck) {
- if ackMsg == nil {
- return
- }
- if ackMsg.Error == 0 {
- if len(ackMsg.RewardList) <= 0 {
- util.DebugF("uid=%v gift code item empty uid=%v", this.GetUUid())
- } else {
- totalItemList := make(map[int32]int32)
- for _, data := range ackMsg.RewardList {
- totalItemList[data.Key] += data.Value
- }
- this.AddItemList(totalItemList, AddFrom_GiftCode, true)
- }
- } else if ackMsg.Error == 1 {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_USED)
- } else if ackMsg.Error == 2 {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_OUTDATE)
- } else if ackMsg.Error == 3 {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_NOT_FOUND)
- } else if ackMsg.Error == 4 {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_FORBID)
- } else if ackMsg.Error == int32(serverproto.ErrorCode_ERROR_GIFT_CODE_USE_FAIL) {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_USE_FAIL)
- } else if ackMsg.Error == 5 {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_REUSE)
- } else {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_FAIL)
- }
- }
- func (this *Role) QuestionReward() {
- //model.GlobalQuestionRewardList
- ackMsg := &serverproto.SCQuestionRewardAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- if this.base.roleBase.QuestionReward <= 0 {
- ret := this.CanAddItemList(model.GlobalQuestionRewardList)
- ackMsg.Error = int32(ret)
- if ret == serverproto.ErrorCode_ERROR_OK {
- this.AddItemList(model.GlobalQuestionRewardList, AddFrom_QuestionReward, true)
- this.base.roleBase.QuestionReward = 1
- this.GetRoleBase().SetDirty(true)
- }
- } else {
- ackMsg.Error = int32(serverproto.ErrorCode_ERROR_QUESTION_REWARDED)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) GetKeepSake() {
- ackMsg := &serverproto.SCOnlineGetKeepSakeAck{}
- if this.GetRoleKeepSake() != nil {
- ackMsg.RoleKeepSake = &serverproto.RoleKeepSake{}
- this.GetRoleKeepSake().GetKeepSakeData(ackMsg.RoleKeepSake)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) KeepSakeLevelUp(keepSakeId int32) {
- ackMsg := &serverproto.SCKeepSakeLevelUpAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- }
- if this.GetRoleKeepSake() != nil {
- nRet := this.GetRoleKeepSake().KeepSakeLevelUp(keepSakeId)
- ackMsg.Error = int32(nRet)
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) OnHeadOperate(msg *serverproto.CSHeadOperateReq) {
- if msg == nil {
- return
- }
- ackMsg := &serverproto.SCHeadOperateAck{
- Error: int32(serverproto.ErrorCode_ERROR_FAIL),
- HeadId: msg.HeadId,
- OperateType: msg.OperateType,
- }
- head := this.roleHead.GetHeadByHeadId(msg.HeadId)
- if head != nil {
- if head.State == int32(Head_Not_Activate) {
- ackMsg.Error = int32(this.roleHead.HeadActivate(msg.HeadId))
- } else if head.State == int32(Head_Wear) {
- ackMsg.Error = int32(this.roleHead.HeadUnload(msg.HeadId))
- } else if head.State == int32(Head_Unload) {
- ackMsg.Error = int32(this.roleHead.HeadWear(msg.HeadId))
- }
- }
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) OnHeadData(req *serverproto.CSHeadDataReq) {
- ackMsg := &serverproto.SCHeadDataAck{}
- this.roleHead.SendAllHeadData()
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) OnWishUse(msg *serverproto.CSWishBoxUseReq) {
- ackMsg := &serverproto.SCWishBoxUseAck{}
- error, index := this.roleWish.OnWishBoxUse(msg.ItemId, msg.SelectItem)
- ackMsg.Error, ackMsg.Index = int32(error), index
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) OnWishSlotUnlock(msg *serverproto.CSWishUnlockSlotReq) {
- ackMsg := &serverproto.SCWishUnlockSlotAck{}
- ackMsg.Error = int32(this.roleWish.OnUnlockWishSlot())
- this.ReplayGate(ackMsg, true)
- }
- func (this *Role) OnWishSlotAction(req *serverproto.CSWishSlotReq) {
- error, awardItem, luckyItem := this.roleWish.OnWishRewardGet(req.Index)
- ackMsg := &serverproto.SCWishSlotReqAck{Error: int32(error), AwardItem: awardItem, LuckyItem: luckyItem}
- this.ReplayGate(ackMsg, true)
- }
- // 检查是否在合服期间
- func (this *Role) CheckInCombinedService() bool {
- bRet, _ := model.CheckInCombined(this.GetSelectZone())
- return bRet
- }
- func (this *Role) CombineServerNtf() {
- ntfMsg := &serverproto.SCCombineServerOnlineNtf{}
- ntfMsg.CombineTime = 0
- data, ok := model.ConvertCombineServerData[1]
- if ok {
- zoneId := this.GetSelectZone()
- for _, server := range data.ServerList {
- if server.Key <= zoneId && zoneId <= server.Value {
- ntfMsg.CombineTime = data.CombineTime
- break
- }
- }
- }
- this.ReplayGate(ntfMsg, true)
- }
- func (this *Role) GetCombineServerInfo() {
- ntfMsg := &serverproto.SCCombineServerInfoAck{}
- bFind := false
- data, ok := model.ConvertCombineServerData[1]
- if ok {
- zoneId := this.GetSelectZone()
- for _, server := range data.ServerList {
- if server.Key <= zoneId && zoneId <= server.Value {
- ntfMsg.Error = int32(serverproto.ErrorCode_ERROR_OK)
- ntfMsg.CombineTime = data.CombineTime
- ntfMsg.Notice = data.Notice
- bFind = true
- break
- }
- }
- }
- if bFind == false {
- ntfMsg.Error = int32(serverproto.ErrorCode_ERROR_COMBINE_SERVER_NOT_IN_STATE)
- ntfMsg.CombineTime = 0
- }
- this.ReplayGate(ntfMsg, true)
- }
- func (this *Role) GMSetCombineServerFinish() {
- model.ConvertCombineServerData = make(map[int32]*model.CombineServer)
- util.InfoF("ConvertCombineServerData len:%v", len(model.ConvertCombineServerData))
- }
|