role.go 123 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144
  1. package model
  2. import (
  3. "errors"
  4. "fmt"
  5. "math/rand"
  6. "reflect"
  7. _ "rocommon/rpc"
  8. "rocommon/service"
  9. "rocommon/util"
  10. "roserver/baseserver/model"
  11. "roserver/serverproto"
  12. "strings"
  13. "time"
  14. "unicode/utf8"
  15. )
  16. var TmpLeaseId int64 = 0
  17. type RoleOuter interface {
  18. model.StateMachine
  19. ReqAckConfirm(msgId, seqId uint32)
  20. SetOpenId(openId string)
  21. GetOpenId() string
  22. SetSelectZone(selectZone int32) //玩家当前选择的服务器,用户合服操作
  23. GetSelectZone() int32
  24. SetCliID(cId model.ClientID)
  25. SetCliIDSessionID(sessionID uint64)
  26. ReplayGate(msg interface{}, transmit bool) int
  27. GetUUid() uint64
  28. GetNickName() string
  29. GetImageId() int32
  30. KickNotSave(err int32)
  31. KickWithSave(err int32)
  32. LoginAck(err serverproto.ErrorCode)
  33. Load(role *serverproto.Role) error
  34. LoadOther(msg interface{}) error //load加载之后加载数据
  35. Update(ms uint64)
  36. DailyReset(notify bool)
  37. SetUpdateDailyReset(ms uint64, bReset bool)
  38. CliID() model.ClientID
  39. SetCreateData(msg *serverproto.CSCreateRoleReq)
  40. IsLogout(ms uint64) bool
  41. Logout()
  42. Save()
  43. SetReLogin(re bool)
  44. BanRole(isBan bool, banTime uint64, cheatType int32)
  45. BanRoleChat(isBan bool, banTime uint64, cheatType int32)
  46. SetPlatform(platform string)
  47. GetPlatform() string
  48. SetSubPlatform(subPlatform string)
  49. GetSubPlatform() string
  50. SetClientParam(clientInfo *serverproto.ClientParamInfo)
  51. GetClientParam() *NeteaseLogCommonInfo
  52. SetClientIP(ip string)
  53. GetClientIP() string
  54. }
  55. // 逻辑操作主接口(可以按照每个系统设定一个接口)
  56. type RoleLogicOuter interface {
  57. AddMoney(st AddItemST, add bool)
  58. AddBaseExp(st AddItemST) bool
  59. AddJobExp(st AddItemST) bool
  60. AddHeroExp(st AddItemST, add bool) bool
  61. AddAttrPoint(heroID int32, point interface{})
  62. AddRes(resType int32, st AddItemST, add bool)
  63. //AddItem(configId int32, count int32, addFrom int32)
  64. ResetAttrPoint(heroID int32)
  65. ActiveHead(headId int32)
  66. SetRoleHeadPic(headId int32)
  67. HeadInfoReq()
  68. SetRoleHeadFrameId(frameId int32)
  69. GetRoleHeadFrameInfo()
  70. UseHeadFrameItem(itemId uint64, itemNum uint32)
  71. ChangeRoleName(name string)
  72. SetRoleGuide(guideId int32)
  73. SetRoleStory(story *serverproto.KeyValueType)
  74. SetMapCartoon(id, status int32)
  75. OnAddQualityPoint(msg *serverproto.CSAddQualityPointReq)
  76. //hero
  77. AddHero(configId int32) bool
  78. HeroLevelUp(id int32) bool
  79. HeroAdvance(id int32) bool
  80. HeroBattle(id int32, isBattle bool)
  81. HeroStrength(id int32) bool
  82. HeroChangeJob(heroId int32, jobId int32) bool
  83. HeroRecruit(configId int32)
  84. FightPowerReq(heroId int32)
  85. HeroReplaceJob(heroId int32, replaceJob int32)
  86. //equip
  87. EquipForge(equipId, once, equipType, subEquipType int32)
  88. AddEquip(configId, num int32, notify bool, ignore bool)
  89. EquipUp(heroId, slotType, equipId int32)
  90. EquipDown(heroId int32, subIndex int32)
  91. EquipLevelUpAll(heroId int32)
  92. EquipSlotLevelUp(heroId, subSlotIndex int32)
  93. ComposeChip(configId int32)
  94. ChipDecompose(cardList []*serverproto.KeyValueType, cardType []int32)
  95. //skill equip
  96. SkillEquipSlotLevelUp(heroId, subIndex int32)
  97. SkillEquipStarLevelUp(heroId int32, skillEquipId uint32, cost []uint32)
  98. SkillEquipUp(heroId int32, skillEquipId uint32, slotIndex int32)
  99. SkillEquipDown(heroId int32, slotIndex int32)
  100. SkillEquipDecompose(skillEquipIds []uint32)
  101. SkillEquipRemade(skillEquipId uint32)
  102. GetSkillEquipPool()
  103. SkillEquipShift(msg *serverproto.CSSkillEquipShiftReq)
  104. //card
  105. CardMount(heroId, subSlotIndex, cardSlotIndex, cardCfgId int32)
  106. CardDown(heroId, subSlotIndex, cardSlotIndex int32)
  107. CardMountAll(msg *serverproto.CSCardEquipAllReq)
  108. CardDownAll(heroId int32)
  109. CardUpGradeAll(msg *serverproto.CSCardUpGradeAllReq)
  110. CardCollect()
  111. CardCollectReward(cardId, level int32)
  112. CardCompose(cardList []int32)
  113. CardDecompose(cardList []*serverproto.KeyValueType, cardType int32)
  114. CardUpGrade(msg *serverproto.CSCardUpGradeReq)
  115. CardLevelExchange(sourceCardId, targetCardId int32)
  116. //skill
  117. SkillReplace(heroId, idx, replaceSkillId int32)
  118. ActiveSkill(heroId int32, skillId int32)
  119. SwapSkill(heroId, firstSlotId, secondSlotId int32)
  120. SetSkillList(heroId int32, skillList []int32)
  121. SkillLevelUp(heroId int32, skillId int32)
  122. ResetSkillLevel(heroId int32, bsuper bool)
  123. ConverSkillExp(msg *serverproto.CSConverSkillExpReq)
  124. //fashion
  125. FashionUp(fashionCfgId []int32)
  126. FashionDown(fashionCfgId []int32)
  127. FashionCompose(paperCfgId int32)
  128. FashionPaperDecompose(paperCfgId int32)
  129. FashionResetAttr(fashionId int32, enter bool)
  130. FashionUpLvl(fashionId int32)
  131. //商店
  132. BuyItem(shopId, goodsId, goodsNum int32)
  133. ShopInfoReq(goodsType int32)
  134. ShopRefresh(goodsType int32)
  135. RedBagShopExchange()
  136. //task
  137. GetTaskReward(taskId uint32)
  138. GetTaskScoreReward(rewardType, rewardIdx int32)
  139. //item
  140. UseItem(itemId uint64, itemNum uint32, itemIdxList []int32, bForceItemId bool)
  141. DelItemByList(itemId []uint64, delFrom AddFromType)
  142. //chat
  143. CheckChatInvalid(targetId uint64, msgType int32, msg *serverproto.CSChatMessageReq) bool
  144. GetOfflineMsg(targetId uint64)
  145. //英灵殿
  146. GetArena()
  147. ArenaMatch(heroList []int32)
  148. ArenaResult(result int32)
  149. ArenaByCount(buyCount int32)
  150. ArenaRankList(rankType, startIdx int32)
  151. SetArenaRank(rankIdx int32, notify bool)
  152. //mail
  153. GetMailIst()
  154. MailRead(idList []int32)
  155. MailReward(idList []int32)
  156. MailDelRead()
  157. AddMail(configId int32, mailType serverproto.MailType, itemList map[int32]int32, paramList []int32,
  158. title, content string)
  159. AddMail1(configId int32, mailType int32, itemList []*serverproto.KeyValueType, paramList []int32,
  160. title, content string)
  161. //competition
  162. GetCompetition(competitionId int32) //competitionId为0表示获得当前正在进行的赛季
  163. CompetitionAddScore(itemList []*serverproto.KeyValueType) //上交道具获取积分
  164. VoteIdol(uid uint64, ticketCount int32)
  165. CheckInSeason() (serverproto.ErrorCode, int32)
  166. GetSelfVoteData(ackMsg *serverproto.SCCompetitionFansRewardRankAck)
  167. CheckFansReward(uid uint64, rewardLevel int32) serverproto.ErrorCode
  168. GetFansReward(idolUid uint64, rewardLevel int32, boxCount int32)
  169. CompulsoryGuidance(storyId, status int32) //强制引导
  170. //ClimbingTower 爬塔/无尽试炼
  171. ClimbingTowerInfoReq()
  172. GetFriendTowerInfo(begin, end int32)
  173. ClimbingTowerBegin(towerLevel int32)
  174. ClimbingTowerEnd(towerLevel, loadingTime int32, recordTimeStamp uint64)
  175. GetFriendBriefFromDB(final bool, begin int32, end int32, briefs []*serverproto.CommonPlayerBriefInfo)
  176. //冲榜相关
  177. GetTowerFightCountReward(rushRound int32, rewardType int32)
  178. GetRushTowerInfo(ackMsg *serverproto.SCTowerActivityAck, curRushRound int32)
  179. GetRushTowerRankReward(ssAck *serverproto.SSGetRushRewardAck)
  180. GetArenaFightCountReward(rushRound int32, rewardType int32)
  181. GetRushArenaInfo(ackMsg *serverproto.SCArenaActivityAck, curRushRound int32)
  182. GetRushArenaRankReward(ssAck *serverproto.SSGetRushRewardAck)
  183. GetRushMapLevelReward(rushRound int32, rewardType int32)
  184. GetRushMapInfo(ackMsg *serverproto.SCMapActivityAck, curRushRound int32)
  185. GetRushMapRankReward(ssAck *serverproto.SSGetRushRewardAck)
  186. GetPetFightCountReward(rushRound int32, rewardType int32)
  187. GetRushPetInfo(ackMsg *serverproto.SCPetActivityAck, curRushRound int32)
  188. GetRushPetRankReward(ssAck *serverproto.SSGetRushRewardAck)
  189. GetFightCountReward(rushRound int32, rushType int32, rewardType int32)
  190. GetRushInfo(ackMsg *serverproto.SCRushActivityAck, curRushRound int32)
  191. GetRushRankReward(ssAck *serverproto.SSGetRushRewardAck)
  192. GetRushShopInfo(ackMsg *serverproto.SSGetRushShopInfoAck)
  193. //guild公会相关操作
  194. CheckBuildGuild(guildName string, guildBadge int32) serverproto.ErrorCode
  195. CheckApplyGuild(guildId uint64) bool
  196. CheckApplyInfo(msg *serverproto.CSApplyInfoHandleReq) serverproto.ErrorCode
  197. CheckGuildModifyInfo(msg *serverproto.CSSetGuildInfoReq) serverproto.ErrorCode
  198. CheckGuildRename(guildName string) serverproto.ErrorCode
  199. CheckGuildRenotice(notice string) serverproto.ErrorCode
  200. OnChangeGuileNameSuccess()
  201. CheckGuildBossChallenge(bossId uint32, damage uint32, fightTime uint32) serverproto.ErrorCode
  202. GetRoleGuildId() uint64
  203. GuildDemonBuyFightCount(buyCount int32)
  204. PackRoleViewInfo(info *serverproto.ViewRoleInfo)
  205. //获取战斗记录
  206. GetBattleRecord(recordType int32, paramList []uint32)
  207. //宠物
  208. PetLevelUp(petId uint32)
  209. PetAdvance(petId uint32, petList []uint32)
  210. PetManualReward(petCfgId, petId, advLevel int32)
  211. PetSkillLevelUp(petId uint32, costPetId uint32)
  212. PetDecompose(petIdList []uint32)
  213. PetBattle(battleList []*serverproto.KeyValueType)
  214. PetBondListGet()
  215. PetAssist(petIdList []uint32)
  216. PetBondAssistListGet(bondCfgId int32)
  217. PetBondActive(bondData []*serverproto.PetBondData)
  218. PetAdvAchievement(petCfgId int32)
  219. PetEquipLevelUp(petEquipId uint32)
  220. PetEquipUp(petId uint32, slotIndexList []*serverproto.KeyValueType)
  221. PetEquipDown(petId uint32, slotIndex int32)
  222. PetGetPetDetailInfo(petIdList []uint32)
  223. PetQiyueUnlock(heroId int32)
  224. PetQiyueSlotIn(heroId, slotIdx int32, petId uint32)
  225. PetQiyueSlotOut(heroId, slotIdx int32)
  226. PetQiyueBattlePetAttr()
  227. //精彩活动Activities
  228. ActivitiesReward(activityId, param, rewardNum int32)
  229. ActivitiesScoreReward(activityId, boxId int32)
  230. ActivitiesFirstChargeReward()
  231. ActivitiesExchange(msg *serverproto.CSActivitiesExchangeReq)
  232. ActivityWheelRefresh(activityId int32)
  233. ActivityWheelOpenReward(activityId int32)
  234. ActivityWheelReward(activityId int32, rewardAll bool)
  235. ActivityWheelClose(activityId int32)
  236. ActivitySummon(activityId, summonCount int32)
  237. ActivitySignIn(activityId int32)
  238. SetCollectionNotice(activityId int32, CollectId int32, notice bool)
  239. ActivitySmashEggs(activityId, drawType, drawCount int32)
  240. ActivitySmashEggsMsg(activityId, drawType int32)
  241. //invitation
  242. InvitationNumberGet()
  243. InvitationNumberUserInfoGet(number uint64)
  244. InvitationBeToMember(number, uid uint64)
  245. InvitationReward(taskIdList []uint32)
  246. InvitationClick(memberUidList []uint64)
  247. InvitationClickReplay(replayMasterUid uint64)
  248. InvitationDelMember(memberUidList []uint64)
  249. //vip等级获取
  250. GetRoleVipLevel() int32
  251. //pay
  252. CheckRushShopInfoGet(goodsType, goodsId, count int32) bool
  253. PayInfoGet(goodsType, goodsId, count int32, rushStage, rushRound int32)
  254. OnPayCallback(payRewardInfo *serverproto.PayOrderSaveInfo, bSave bool, bAck bool)
  255. //卢恩商会
  256. GetRuneShopInfo(shopType int32, subShop int32)
  257. OnRuneExploreInfo()
  258. OnRuneMaxLvlAward()
  259. OnRuneReward(msg *serverproto.CSExploreRewardReq)
  260. //抽卡
  261. OnDrawReq(drawType int32, drawCount int32)
  262. GetResNotice(resType int32) serverproto.ErrorCode
  263. //百人道场
  264. GetDaoChang100SelfPosInfo(msg *serverproto.CSDaoChang100PlayerInfoReq)
  265. GetDaoChang100PosInfo(posIdxList []int32)
  266. GetDaoChang100Log(beginTime uint64)
  267. DaoChang100ChallengeReq(posIdx int32)
  268. DaoChang100TimeRewardReq()
  269. DaoChang100ChallengeResultReq(msg *serverproto.CSDaoChang100ChallengeResultReq)
  270. DaoChang100BuyChallengeCount()
  271. DaoChang100SetTips(tipDesc string)
  272. OnAntiCheatReq(cheatType int32)
  273. GiftReward(ackMsg *serverproto.SCGiftRewardAck)
  274. //问卷奖励获取
  275. QuestionReward()
  276. GetKeepSake()
  277. KeepSakeLevelUp(keepSakeId int32)
  278. // 称号操作
  279. OnHeadOperate(*serverproto.CSHeadOperateReq)
  280. OnHeadData(req *serverproto.CSHeadDataReq)
  281. // 许愿箱
  282. OnWishUse(*serverproto.CSWishBoxUseReq)
  283. OnWishSlotUnlock(*serverproto.CSWishUnlockSlotReq)
  284. OnWishSlotAction(req *serverproto.CSWishSlotReq)
  285. GetCombineServerInfo()
  286. }
  287. type BattleLogicOuter interface {
  288. //income
  289. Income()
  290. OnlineTimeReward() //累计在线时间奖励获取
  291. BossReward(challengeTime uint32, mapId, mapLevel uint32, recordTimeStamp uint64)
  292. BattleBossReq()
  293. //mapRank
  294. SetMapRank(selfRank, totalRanks uint32, topRankList []*serverproto.RankPlayerInfo, addSystemMsg bool)
  295. GetMapRank()
  296. GetQuickBattleReward()
  297. //Evil
  298. BattleEvilRefresh(bForce bool)
  299. BattleEvilChallenge(posIdx int32)
  300. //expedition
  301. ExpeditionChallengePre(expeditionType int32)
  302. ExpeditionChallenge(expeditionType, battleLevel int32, heroInfoList []*serverproto.BattleExpeditionActor,
  303. bossChangeHpList []*serverproto.BattleExpeditionActor, battleTime int32, bossIdx, flag int32)
  304. ExpeditionBuffSelect(selectBuf int32)
  305. ExpeditionReward(expeditionType, boxIdx int32)
  306. ExpeditionBattleHero(battleHeroList []int32)
  307. ExpeditionCallForHelp(assistHelpUid uint64)
  308. ExpeditionHelp(beHelpedUid uint64, msgType int32, helpMsgSendTime uint64)
  309. ExpeditionScoreRankList(startIdx int32)
  310. //actor attr(获取英雄属性,宠物属性)
  311. GetActorAttr(reqMsg *serverproto.CSActorAttrGetReq)
  312. }
  313. type CrossLogicOuter interface {
  314. //远航试炼
  315. YuanHangTrialViewList()
  316. //刷新远航试炼品质
  317. RefreshYuanHangTrialType(force bool)
  318. //发起远航试炼
  319. YuanHangTrial()
  320. YuanHangTrialReward()
  321. YuanHangTrialChallenge(challengeUid, challengeUidEndTime uint64)
  322. YuanHangTrialChallengeResult(msg *serverproto.CSCrossYuanHangTrialChallengeResultReq)
  323. YuanHangTrialInfoQuery(trialUid, trialEndTime uint64)
  324. YuanHangTrialLog(logTime uint64)
  325. //from router
  326. OnYuanHangTrialChallengeResult(msg *serverproto.SSCrossYuanHangTrialChallengeResultAck)
  327. YuanHangTrialRankList(startIdx int32)
  328. //巅峰之塔
  329. //获取挑战列表
  330. TopTowerFightListReq()
  331. //战斗结果通知
  332. TopTowerChallengeResultReq(bWin bool, fightIdx int32)
  333. //买路操作(直接胜利)
  334. TopTowerForceWinReq(fightIdx int32)
  335. }
  336. // //全局跨服地图相关
  337. type RoleCrossMapRouter interface {
  338. PlayerEnterMap(msg *serverproto.CSGCrossPlayerEnterMapReq)
  339. PlayerLeave(msg *serverproto.CSGCrossPlayerLeaveMapReq)
  340. PlayerMoveSync(msg *serverproto.CSGCrossPlayerMapSyncPosReq)
  341. PlayerSyncParam(msg *serverproto.CSGCrossPlayerMapSyncParamReq)
  342. //获取玩家地图展示信息
  343. GetPlayerMapShowInfo() *serverproto.PlayerShowInfo
  344. }
  345. // // bt服务器版本使用
  346. type RoleBTRouter interface {
  347. // 充值钱包商店购买(假钱购买)
  348. PayInfoGetForCreditRecharge(goodsId, count int32)
  349. // 特权卡商店每日礼包领取
  350. SpecialPrivilegeReward()
  351. // 充值钱包商店,Ro币礼包商店
  352. GetBTShopInfo(shopType int32, subShop int32)
  353. // Ro币礼包商店购买(消耗RO币)
  354. PayInfoGetForRoCoin(goodsId, count int32)
  355. // 获取爬塔馈赠奖励
  356. GetTowerLevelDayReward()
  357. // 波利商城
  358. BoliShopInfo()
  359. BoliLevelUp(num int32)
  360. BoliReward(RewardLevel, idx int32)
  361. BoliShopBuy(goodsId, num int32)
  362. //超值首充 & 百元大礼包
  363. FirstRechargeReward(rewardIdx int32)
  364. Recharge100Reward()
  365. }
  366. type RoleSaveObject interface {
  367. Load(msg interface{}) bool
  368. Save()
  369. IsDirty() bool
  370. SetDirty(b bool)
  371. }
  372. const (
  373. SLOT_NUM = 4 //4个上阵位置
  374. SLOT_TYPE_NUM = Equip_Type_Max - 1
  375. SKILL_EQUIP_SLOT_TYPE_NUM = Skill_Equip_Type_Max - 1
  376. )
  377. // 任务唯一id
  378. var timeWheelKeyUid uint64 = 1
  379. type SaveObject struct {
  380. isDirty bool
  381. role *Role
  382. }
  383. func (this *SaveObject) IsDirty() bool {
  384. return this.isDirty
  385. }
  386. func (this *SaveObject) SetDirty(b bool) {
  387. if this.isDirty == b {
  388. return
  389. }
  390. this.isDirty = b
  391. if this.isDirty {
  392. if this.role.twTask == nil {
  393. timeWheelKeyUid++
  394. this.role.twTask = &util.TWTask{
  395. Uid: this.role.GetUUid(),
  396. Key: timeWheelKeyUid, //任务唯一id
  397. CallbackType: util.TWTASK_TYPE_Save, //表示save操作
  398. Delay: 20,
  399. }
  400. }
  401. RoleMag.tw.AddTask(this.role.twTask)
  402. }
  403. }
  404. type Role struct {
  405. model.StateMachineCore
  406. soList []RoleSaveObject
  407. //在upate中标记是否需要重置,随后再每个玩家自身的update中进行reset操作,降低
  408. //同一时间的reset操作次数
  409. dailyResetTimer util.OnceTimer
  410. twTask *util.TWTask
  411. mysqlLogList []*serverproto.SSRoleLogData //mysql数据保存
  412. mysqlLogSaveTimer util.DurationTimer
  413. reqAckConfirmList map[uint32][]uint32
  414. cliID model.ClientID //在Gate上的信息
  415. dbNode string //选择处理信息的db节点
  416. socialNode string //选择处理信息的social节点
  417. //aoiNode string //aoi服务器节点(工会主城只会有一个)
  418. bossNode string //BattleBoss服务器节点
  419. rankNode string //Rank服务器节点
  420. guildNode string //Guild服务器接点
  421. platform string //平台
  422. subPlatform string //平台对应不同分发媒体
  423. clientParamInfo *NeteaseLogCommonInfo //客户端上报信息
  424. clientIp string //客户端IP
  425. tmpState bool //临时控制使用
  426. selectZone int32 ////玩家当前选择的服务器,用户合服操作
  427. uuid uint64 //Role的用户ID
  428. openId string //平台账号
  429. RegisterTime uint64 //注册时间
  430. UuidList []uint64 //用户拥有的所有角色ID
  431. UuidRoleList map[uint64]*serverproto.AccountRole //用户拥有的所有角色数据AccountRole
  432. SelectedUuid uint64 //用户选择的角色ID
  433. reLogin bool //是否是重新登陆
  434. isLoad bool //是否已经加载过
  435. activeCode string //激活码
  436. base *RoleBase //角色基础信息
  437. roleHero *RoleHero //伙伴信息
  438. roleBag *RoleBag //角色背包信息
  439. roleEquip *RoleEquip //装备信息
  440. roleChip *RoleChip //英雄碎片信息
  441. roleMap *RoleMap //地图信息
  442. roleSkill *RoleSkill //技能信息
  443. roleCard *RoleCard //卡片系统
  444. roleFashion *RoleFashion //时装
  445. roleBattle *RoleBattle //战斗相关信息
  446. roleTask *RoleTask //任务系统
  447. roleChat *RoleChat
  448. roleArena *RoleArena //竞技场
  449. roleRed *RoleRed //小红点
  450. roleMail *RoleMail //邮件
  451. roleShop *RoleShop //
  452. roleCompetition *RoleCompetition //赛季
  453. roleSocial *RoleSocial //social相关(friend)
  454. roleActivity *RoleActivity //活动信息
  455. roleTower *RoleTower //爬塔
  456. roleGuild *RoleGuild //公会
  457. rolePet *RolePet //宠物
  458. roleInvitation *RoleInvitation //邀请码功能
  459. roleDraw *RoleDraw //抽取系统
  460. roleRune *RoleRune //卢恩商店
  461. roleDaoChang100 *RoleDaoChang100 //百人道场
  462. roleStatistic *RoleStatistic //统计数据
  463. roleKeepSake *RoleKeepSake
  464. roleSkillEquip *RoleSkillEquip //神器系统
  465. roleCross *RoleCross //跨服数据
  466. roleRush *RoleRush //跨服数据
  467. roleBattleAttr *RoleBattleAttr //战斗属性计算,每个玩法的属性都放到该类中处理
  468. roleHead *RoleHead // 称号数据
  469. roleWish *RoleWishBox // 许愿箱
  470. roleBT *RoleBT // bt版本数据
  471. saveTimer util.DurationTimer //保存数据定时器
  472. offlineTimer util.OnceTimer //离线定时器
  473. lastProcessTime uint64 //无数据操作
  474. }
  475. var roleSaveTimeout time.Duration = 500 //保存数据的间隔时间
  476. var roleOfflineTimeout time.Duration = 30 * 60 * 1000 //
  477. var mysqlSaveTimeout time.Duration = 2000
  478. func NewRole(cId model.ClientID) RoleOuter {
  479. role := &Role{
  480. reqAckConfirmList: map[uint32][]uint32{},
  481. cliID: cId,
  482. uuid: 0,
  483. reLogin: false,
  484. }
  485. //初始化角色信息
  486. role.Init()
  487. return role
  488. }
  489. func (this *Role) Init() {
  490. this.UuidRoleList = map[uint64]*serverproto.AccountRole{}
  491. //初始化角色状态机
  492. this.InitState()
  493. this.RegisterState(int32(ROLE_STATE_PULLING_LIST), pullingRoleList)
  494. this.RegisterState(int32(ROLE_STATE_PULLED_LIST), pulledRoleList)
  495. this.RegisterState(int32(ROLE_STATE_CREATE), createRole)
  496. this.RegisterState(int32(ROLE_STATE_DB_ADD_ROLE_SUCCESS), createDbRoleSuccess)
  497. this.RegisterState(int32(ROLE_STATE_DB_ADD_ROLE_FAILURE), createDbRoleFailure)
  498. this.RegisterState(int32(ROLE_STATE_SELECT_ROLE), SelectingRole)
  499. this.RegisterState(int32(ROLE_STATE_SELECT_ROLE_SUCCESS), SelectRoleSuccess)
  500. this.RegisterState(int32(ROLE_STATE_ONLINE), RoleOnline)
  501. this.RegisterState(int32(ROLE_STATE_OFFLINE), RoleOffline)
  502. this.roleBattleAttr = newRoleBattleAttr(this)
  503. //this.base = roleBasePool.Get().(*RoleBase)
  504. this.base = newRoleBase()
  505. this.base.role = this
  506. this.roleHero = newRoleHero(this)
  507. this.roleBag = newRoleBag(this)
  508. this.roleEquip = newRoleEquip(this)
  509. this.roleChip = newRoleChip(this)
  510. this.roleMap = newRoleMap(this)
  511. this.roleSkill = newRoleSkill(this)
  512. this.roleCard = newRoleCard(this)
  513. this.roleFashion = newRoleFashion(this)
  514. this.roleBattle = newRoleBattle(this)
  515. this.roleTask = newRoleTask(this)
  516. //this.roleFightPower = newRoleFightPower(this)
  517. this.roleChat = newRoleChat(this)
  518. this.roleArena = newRoleArena(this)
  519. this.roleMail = newRoleMail(this)
  520. this.roleRed = newRoleRed(this)
  521. this.roleShop = newRoleShop(this)
  522. this.roleCompetition = newRoleCompetition(this)
  523. this.roleSocial = newRoleSocial(this)
  524. this.roleActivity = newRoleActivity(this)
  525. this.roleTower = newRoleTower(this)
  526. this.roleGuild = newRoleGuild(this)
  527. this.rolePet = newRolePet(this)
  528. this.roleInvitation = newRoleInvitation(this)
  529. this.roleDraw = newRoleDraw(this)
  530. this.roleRune = newRoleRune(this)
  531. this.roleDaoChang100 = newRoleDaoChang100(this)
  532. this.roleStatistic = newRoleStatistic(this)
  533. this.roleKeepSake = newRoleKeepSake(this)
  534. this.roleCross = newRoleCross(this)
  535. this.roleRush = newRoleRush(this)
  536. this.roleSkillEquip = newRoleSkillEquip(this)
  537. this.roleHead = newRoleHead(this)
  538. this.roleWish = newRoleWish(this)
  539. this.roleBT = newRoleBT(this)
  540. this.soList = append(this.soList,
  541. this.base,
  542. this.roleHero,
  543. this.roleBag,
  544. this.roleCard,
  545. this.roleEquip,
  546. this.roleChip,
  547. this.roleMap,
  548. this.roleMap,
  549. this.roleSkill,
  550. this.roleFashion,
  551. this.roleBattle,
  552. this.roleTask,
  553. this.roleChat,
  554. this.roleArena,
  555. this.roleMail,
  556. this.roleRed,
  557. this.roleShop,
  558. this.roleCompetition,
  559. this.roleSocial,
  560. this.roleActivity,
  561. this.roleTower,
  562. this.roleGuild,
  563. this.rolePet,
  564. this.roleInvitation,
  565. this.roleDraw,
  566. this.roleRune,
  567. this.roleDaoChang100,
  568. this.roleStatistic,
  569. this.roleKeepSake,
  570. this.roleRush,
  571. this.roleCross,
  572. this.roleSkillEquip,
  573. this.roleHead,
  574. this.roleWish,
  575. this.roleBT,
  576. )
  577. }
  578. func (this *Role) ReqAckConfirm(msgId, seqId uint32) {
  579. this.reqAckConfirmList[msgId] = append(this.reqAckConfirmList[msgId], seqId)
  580. }
  581. func (this *Role) SetOpenId(openId string) {
  582. this.openId = openId
  583. }
  584. func (this *Role) GetOpenId() string {
  585. return this.openId
  586. }
  587. func (this *Role) SetSelectZone(selectZone int32) {
  588. if selectZone <= 0 {
  589. this.selectZone = int32(service.GetServiceConfig().Node.Zone)
  590. } else {
  591. this.selectZone = selectZone
  592. }
  593. }
  594. func (this *Role) GetSelectZone() int32 {
  595. return this.selectZone
  596. }
  597. func (this *Role) SetPlatform(platform string) {
  598. this.platform = platform
  599. }
  600. func (this *Role) GetPlatform() string {
  601. return this.platform
  602. }
  603. func (this *Role) SetSubPlatform(subPlatform string) {
  604. this.subPlatform = subPlatform
  605. }
  606. func (this *Role) GetSubPlatform() string {
  607. return this.subPlatform
  608. }
  609. func (this *Role) SetClientParam(clientInfo *serverproto.ClientParamInfo) {
  610. if clientInfo == nil {
  611. return
  612. }
  613. if this.clientParamInfo == nil {
  614. this.clientParamInfo = &NeteaseLogCommonInfo{}
  615. }
  616. this.clientParamInfo.DeviceModel = clientInfo.DeviceModel
  617. this.clientParamInfo.DeviceHeight = int(clientInfo.DeviceHeight)
  618. this.clientParamInfo.DeviceWidth = int(clientInfo.DeviceWidth)
  619. this.clientParamInfo.OsName = clientInfo.OsName
  620. this.clientParamInfo.OsVer = clientInfo.OsVer
  621. this.clientParamInfo.MacAddr = clientInfo.MacAddr
  622. this.clientParamInfo.Udid = clientInfo.Udid
  623. this.clientParamInfo.Isp = clientInfo.Isp
  624. this.clientParamInfo.Network = clientInfo.Network
  625. this.clientParamInfo.AppChannel = clientInfo.AppChannel
  626. this.clientParamInfo.AppVer = clientInfo.AppVer
  627. this.clientParamInfo.TransId = clientInfo.TransId
  628. this.clientParamInfo.UnisdkDeviceId = clientInfo.UnisdkDeviceid
  629. this.clientParamInfo.IsEmulator = int(clientInfo.IsEmulator)
  630. this.clientParamInfo.IsRoot = int(clientInfo.IsRoot)
  631. this.clientParamInfo.AccountId = clientInfo.AccountId
  632. this.clientParamInfo.OldAccountId = clientInfo.OldAccountid
  633. this.clientParamInfo.IMEI = clientInfo.IMEI
  634. this.clientParamInfo.CountryCode = clientInfo.CountryCode
  635. this.clientParamInfo.EnterSN = clientInfo.EnterSn
  636. this.clientParamInfo.OAid = clientInfo.Oaid
  637. this.clientParamInfo.EngineVer = clientInfo.EngineVer
  638. this.clientParamInfo.Server = service.GetServiceConfig().Node.Zone*100 + service.GetServiceConfig().Node.Id
  639. }
  640. func (this *Role) GetClientParam() *NeteaseLogCommonInfo {
  641. return this.clientParamInfo
  642. }
  643. func (this *Role) SetClientIP(ip string) {
  644. this.clientIp = ip
  645. if this.clientParamInfo == nil {
  646. this.clientParamInfo = &NeteaseLogCommonInfo{}
  647. }
  648. ipStr := this.GetClientIP()
  649. //先区分是否是IPV6
  650. strList := strings.Split(ipStr, ":")
  651. if len(strList) == 2 {
  652. this.clientParamInfo.IPv4 = strList[0]
  653. } else if len(strList) > 2 {
  654. position := strings.LastIndex(ipStr, ":")
  655. this.clientParamInfo.Ipv6 = ipStr[1 : position-1]
  656. }
  657. }
  658. func (this *Role) GetClientIP() string {
  659. return this.clientIp
  660. }
  661. func (this *Role) DBNode() string {
  662. return this.dbNode
  663. }
  664. func (this *Role) SocialNode() string {
  665. return this.socialNode
  666. }
  667. func (this *Role) AoiNode() string {
  668. //return this.aoiNode
  669. return ""
  670. }
  671. func (this *Role) BossNode() string {
  672. return this.bossNode
  673. }
  674. func (this *Role) RankNode() string {
  675. return this.rankNode
  676. }
  677. func (this *Role) GuildNode() string {
  678. return this.guildNode
  679. }
  680. func (this *Role) CliID() model.ClientID {
  681. return this.cliID
  682. }
  683. func (this *Role) SetCliID(cId model.ClientID) {
  684. this.cliID = cId
  685. }
  686. func (this *Role) SetCliIDSessionID(sessionID uint64) {
  687. this.cliID.SessID = sessionID
  688. }
  689. func (this *Role) setUUid(id uint64) {
  690. this.uuid = id
  691. }
  692. func (this *Role) GetUUid() uint64 {
  693. return this.uuid
  694. }
  695. func (this *Role) GetNickName() string {
  696. return this.GetRoleBase().GetRoleName()
  697. }
  698. func (this *Role) GetImageId() int32 {
  699. return this.GetRoleBase().RoleData().HeadId
  700. }
  701. func (this *Role) SetSelectUUid(id uint64) {
  702. this.SelectedUuid = id
  703. if data, ok := this.UuidRoleList[id]; ok {
  704. this.RegisterTime = data.RegisterTime
  705. }
  706. }
  707. func (this *Role) SetReLogin(re bool) {
  708. this.reLogin = re
  709. }
  710. func (this *Role) GetRoleBase() *RoleBase {
  711. return this.base
  712. }
  713. func (this *Role) GetRoleBag() *RoleBag {
  714. return this.roleBag
  715. }
  716. func (this *Role) GetRoleEquip() *RoleEquip {
  717. return this.roleEquip
  718. }
  719. func (this *Role) GetRoleHero() *RoleHero {
  720. return this.roleHero
  721. }
  722. func (this *Role) GetRoleChip() *RoleChip {
  723. return this.roleChip
  724. }
  725. func (this *Role) GetRoleMap() *RoleMap {
  726. return this.roleMap
  727. }
  728. func (this *Role) GetRoleSkill() *RoleSkill {
  729. return this.roleSkill
  730. }
  731. func (this *Role) GetRoleSkillEquip() *RoleSkillEquip {
  732. return this.roleSkillEquip
  733. }
  734. func (this *Role) GetRoleCard() *RoleCard {
  735. return this.roleCard
  736. }
  737. func (this *Role) GetRoleFashion() *RoleFashion {
  738. return this.roleFashion
  739. }
  740. func (this *Role) GetRoleBattle() *RoleBattle {
  741. return this.roleBattle
  742. }
  743. func (this *Role) GetRoleChat() *RoleChat {
  744. return this.roleChat
  745. }
  746. func (this *Role) GetRoleArena() *RoleArena {
  747. return this.roleArena
  748. }
  749. func (this *Role) GetRoleRed() *RoleRed {
  750. return this.roleRed
  751. }
  752. func (this *Role) GetRoleMail() *RoleMail {
  753. return this.roleMail
  754. }
  755. func (this *Role) GetRoleCompetition() *RoleCompetition {
  756. return this.roleCompetition
  757. }
  758. func (this *Role) GetRoleShop() *RoleShop {
  759. return this.roleShop
  760. }
  761. func (this *Role) GetRoleSocial() *RoleSocial {
  762. return this.roleSocial
  763. }
  764. func (this *Role) GetRoleTask() *RoleTask {
  765. return this.roleTask
  766. }
  767. // func (this *Role) GetRoleFightPower1() *RoleFightPower {
  768. // return this.roleFightPower
  769. // }
  770. func (this *Role) GetRoleActivity() *RoleActivity {
  771. return this.roleActivity
  772. }
  773. func (this *Role) GetRoleTower() *RoleTower {
  774. return this.roleTower
  775. }
  776. func (this *Role) GetRoleGuild() *RoleGuild {
  777. return this.roleGuild
  778. }
  779. func (this *Role) GetRolePet() *RolePet {
  780. return this.rolePet
  781. }
  782. func (this *Role) GetRoleInvitation() *RoleInvitation {
  783. return this.roleInvitation
  784. }
  785. func (this *Role) GetRoleDraw() *RoleDraw {
  786. return this.roleDraw
  787. }
  788. func (this *Role) GetRoleRune() *RoleRune {
  789. return this.roleRune
  790. }
  791. func (this *Role) GetRoleDaoChang100() *RoleDaoChang100 {
  792. return this.roleDaoChang100
  793. }
  794. func (this *Role) GetRoleStatistic() *RoleStatistic {
  795. return this.roleStatistic
  796. }
  797. func (this *Role) GetRoleKeepSake() *RoleKeepSake {
  798. return this.roleKeepSake
  799. }
  800. func (this *Role) GetRoleCross() *RoleCross {
  801. return this.roleCross
  802. }
  803. func (this *Role) GetRoleRush() *RoleRush {
  804. return this.roleRush
  805. }
  806. func (this *Role) GetRoleBT() *RoleBT {
  807. return this.roleBT
  808. }
  809. func (this *Role) SetCreateData(msg *serverproto.CSCreateRoleReq) {
  810. this.base.roleBase.Sex = msg.Sex
  811. this.base.roleBase.Country = msg.Country
  812. //JobId
  813. this.base.roleBase.RoleData.HeroData.ConfigId = msg.JobId
  814. this.base.roleBase.FashionData.Hair = msg.Hair
  815. this.base.roleBase.FashionData.HairAvatar = msg.HairAvatar
  816. this.base.roleBase.FashionData.Eye = msg.Eye
  817. if msg.Head != 0 {
  818. this.base.roleBase.FashionData.FashionUpList =
  819. append(this.base.roleBase.FashionData.FashionUpList, msg.Head)
  820. }
  821. this.activeCode = msg.ActiveCode
  822. }
  823. func (this *Role) IsLogout(ms uint64) bool {
  824. return this.offlineTimer.IsStart() && this.offlineTimer.IsExpired(ms)
  825. }
  826. func (this *Role) isBan() uint64 {
  827. if this.GetRoleBase().roleBase != nil && this.GetRoleBase().roleBase.BanTime > uint64(util.GetTimeSeconds()) {
  828. delTime := this.GetRoleBase().roleBase.BanTime - uint64(util.GetTimeSeconds())
  829. return delTime
  830. }
  831. return 0
  832. }
  833. func (this *Role) BanRole(isBan bool, banTime uint64, cheatType int32) {
  834. if this.GetRoleBase().roleBase == nil {
  835. util.InfoF("BanRole isBan=%v err=rolebase is nil", isBan)
  836. return
  837. }
  838. if banTime <= 0 {
  839. banTime = 24 * 60 * 60
  840. }
  841. if isBan {
  842. this.GetRoleBase().roleBase.BanTime = uint64(util.GetTimeSeconds()) + banTime
  843. this.GetRoleBase().roleBase.BanType = cheatType
  844. this.GetRoleBase().SetDirty(true)
  845. //作弊方式封号
  846. ssMsg := &serverproto.SSGameBanRoleNtf{
  847. BanUid: this.GetUUid(),
  848. BanEndTime: this.GetRoleBase().roleBase.BanTime,
  849. BanType: 1, //1封号,2禁言
  850. }
  851. this.SendDb(ssMsg)
  852. errCode := this.roleStatistic.GetCheatErrorCode(cheatType)
  853. this.KickWithSaveAndBan(errCode, banTime)
  854. } else {
  855. if this.GetRoleBase().roleBase.BanTime > 0 {
  856. this.GetRoleBase().roleBase.BanTime = 0
  857. this.GetRoleBase().roleBase.BanType = 0
  858. this.GetRoleBase().SetDirty(true)
  859. //清空作弊数据
  860. if this.GetRoleStatistic() != nil {
  861. this.GetRoleStatistic().ClearCheatData()
  862. }
  863. }
  864. }
  865. }
  866. // 禁言
  867. func (this *Role) BanRoleChat(isBan bool, banTime uint64, cheatType int32) {
  868. if this.GetRoleBase().roleBase == nil {
  869. util.InfoF("BanRole isBan=%v err=rolebase is nil", isBan)
  870. return
  871. }
  872. if banTime <= 0 {
  873. banTime = 24 * 60 * 60
  874. }
  875. if isBan {
  876. this.GetRoleBase().roleBase.ChatBanTime = uint64(util.GetTimeSeconds()) + banTime
  877. this.GetRoleBase().roleBase.ChatBanType = cheatType
  878. this.GetRoleBase().SetDirty(true)
  879. //禁言
  880. ssMsg := &serverproto.SSGameBanRoleNtf{
  881. BanUid: this.GetUUid(),
  882. BanEndTime: this.GetRoleBase().roleBase.BanTime,
  883. BanType: 2, //1封号,2禁言
  884. }
  885. this.SendDb(ssMsg)
  886. util.InfoF("uid=%v BanRoleChat endtime=%v", this.GetUUid(), this.GetRoleBase().roleBase.ChatBanTime)
  887. } else {
  888. if this.GetRoleBase().roleBase.ChatBanTime > 0 {
  889. this.GetRoleBase().roleBase.ChatBanTime = 0
  890. this.GetRoleBase().roleBase.ChatBanType = 0
  891. this.GetRoleBase().SetDirty(true)
  892. //清空作弊数据
  893. if this.GetRoleStatistic() != nil {
  894. this.GetRoleStatistic().ClearCheatData()
  895. }
  896. }
  897. }
  898. }
  899. // 来自gmweb的删除背包道具操作
  900. func (this *Role) WebGMDelItem(delItemList []*serverproto.KeyValueType) {
  901. util.InfoF("uid=%v WebGMDelItem delitemlist=%v", this.uuid, delItemList)
  902. for idx := 0; idx < len(delItemList); idx++ {
  903. this.GetRoleBag().DelItem(delItemList[idx].Key, delItemList[idx].Value, AddItemST{
  904. AddFrom: AddFrom_System,
  905. })
  906. }
  907. }
  908. func (this *Role) KickNotSave(err int32) {
  909. //通知gate踢人,并且不再反向通知logic服务器
  910. kickNtf := &serverproto.SSUserKickNtf{
  911. Error: err,
  912. ClientId: this.CliID().SessID,
  913. }
  914. this.ReplayGate(kickNtf, false)
  915. util.InfoF("uid=%v sessionID=%v KickNotSave game kick user err=%v", this.GetUUid(), this.CliID().SessID, err)
  916. this.SwitchState(ROLE_STATE_ZOMBIE, nil)
  917. }
  918. func (this *Role) KickWithSave(err int32) {
  919. //通知gate踢人,并且不再反向通知logic服务器
  920. kickNtf := &serverproto.SSUserKickNtf{
  921. Error: err,
  922. ClientId: this.CliID().SessID,
  923. }
  924. this.ReplayGate(kickNtf, false)
  925. util.InfoF("uid=%v sessionID=%v KickWithSave game kick user err=%v", this.GetUUid(), this.CliID().SessID, err)
  926. this.SwitchState(ROLE_STATE_OFFLINE, nil)
  927. }
  928. func (this *Role) KickWithSaveAndBan(err int32, banEndTime uint64) {
  929. //通知gate踢人,并且不再反向通知logic服务器
  930. kickNtf := &serverproto.SSUserKickNtf{
  931. Error: err,
  932. ClientId: this.CliID().SessID,
  933. BanEndTime: banEndTime,
  934. }
  935. this.ReplayGate(kickNtf, false)
  936. util.InfoF("uid=%v sessionID=%v KickWithSaveAndBan game kick user", this.GetUUid(), this.CliID().SessID)
  937. this.SwitchState(ROLE_STATE_OFFLINE, nil)
  938. }
  939. func (this *Role) Load(role *serverproto.Role) error {
  940. if this.reLogin && this.isLoad {
  941. //已经加载过
  942. return nil
  943. }
  944. //每个系统类型信息加载
  945. for _, data := range this.soList {
  946. if !data.Load(role) {
  947. return errors.New(fmt.Sprintf("uid=%v load savedObject module=%v failed",
  948. this.GetUUid(), reflect.TypeOf(data).Elem().Name()))
  949. }
  950. }
  951. this.isLoad = true
  952. return nil
  953. }
  954. func (this *Role) LoadOther(msg interface{}) error {
  955. //主角基本数据还未加载
  956. if !this.isLoad {
  957. return nil
  958. }
  959. switch m := msg.(type) {
  960. //在登陆流程中
  961. case *serverproto.SSLoadArenaNtf:
  962. if this.roleArena != nil {
  963. if !this.roleArena.LoadOther(m.RoleArena) {
  964. return errors.New(fmt.Sprintf("uid=%v load SSLoadArenaNtf failed", this.GetUUid()))
  965. }
  966. }
  967. case *serverproto.SSLoadMailNtf:
  968. if this.roleMail != nil {
  969. if !this.roleMail.LoadOther(m.Mail) {
  970. return errors.New(fmt.Sprintf("uid=%v load SSLoadMailNtf failed", this.GetUUid()))
  971. }
  972. }
  973. case *serverproto.SSLoadFriendDataNtf:
  974. if this.roleSocial != nil {
  975. if !this.roleSocial.LoadOther(m.Friend) {
  976. return errors.New(fmt.Sprintf("uid=%v SSLoadFriendDataNtf failed", this.GetUUid()))
  977. }
  978. }
  979. case *serverproto.SSLoadPetNtf:
  980. if this.rolePet != nil {
  981. if !this.rolePet.LoadOther(m) {
  982. return errors.New(fmt.Sprintf("uid=%v SSLoadPetNtf failed", this.GetUUid()))
  983. }
  984. }
  985. case *serverproto.SSLoadInvitationDataNtf:
  986. if this.roleInvitation != nil {
  987. if !this.roleInvitation.LoadOther(m.InvitationInfo) {
  988. return errors.New(fmt.Sprintf("uid=%v SSLoadInvitationDataNtf failed", this.GetUUid()))
  989. }
  990. }
  991. case *serverproto.SSLoadCrossDataNtf:
  992. if this.roleCross != nil {
  993. if !this.roleCross.LoadOther(m.LoadData) {
  994. return errors.New(fmt.Sprintf("uid=%v SSLoadCrossDataNtf failed", this.GetUUid()))
  995. }
  996. }
  997. default:
  998. return errors.New(fmt.Sprintf("uid=%v load unkonw model !!!", this.GetUUid()))
  999. //不在登陆流程中,后续通过协议主动获取
  1000. }
  1001. return nil
  1002. }
  1003. func (this *Role) Save() {
  1004. if !this.isLoad {
  1005. return
  1006. }
  1007. bSave := false
  1008. if this.GetState() == ROLE_STATE_ONLINE || this.GetState() == ROLE_STATE_OFFLINE {
  1009. for _, data := range this.soList {
  1010. //data.(*SaveObject).IsDirty()
  1011. if data.IsDirty() {
  1012. data.Save()
  1013. bSave = true
  1014. }
  1015. }
  1016. }
  1017. if bSave {
  1018. //最后save时间戳
  1019. this.lastProcessTime = util.GetTimeMilliseconds()
  1020. }
  1021. }
  1022. func (this *Role) Update(ms uint64) {
  1023. if this.GetState() == ROLE_STATE_ZOMBIE {
  1024. return
  1025. }
  1026. //放到time wheel中处理
  1027. //if this.saveTimer.IsStart() && this.saveTimer.IsExpired(ms) {
  1028. // this.Save()
  1029. //}
  1030. //活动数据更新定时器相关代码
  1031. if this.dailyResetTimer.IsStart() && this.dailyResetTimer.IsExpired(ms) {
  1032. //update过程中玩家已经通过上下线进行了重置操作
  1033. this.DailyReset(true)
  1034. ResetCount++
  1035. this.dailyResetTimer.Cancel()
  1036. }
  1037. this.roleArena.Update(ms)
  1038. this.roleMail.Update(ms)
  1039. this.GetRoleBase().Update(ms)
  1040. this.roleTower.Update(ms)
  1041. this.roleRune.Update(ms)
  1042. this.roleHead.Update(ms)
  1043. this.roleWish.Update(ms)
  1044. if this.mysqlLogSaveTimer.IsStart() && this.mysqlLogSaveTimer.IsExpired(ms) {
  1045. this.saveMysqlLog()
  1046. }
  1047. ////1小时无任何保存操作,直接设置成离线状态
  1048. //if ms > this.lastProcessTime && this.lastProcessTime > 0 && ms-this.lastProcessTime > 60*60*1000 {
  1049. // if this.GetState() == ROLE_STATE_ONLINE {
  1050. // this.SwitchState(ROLE_STATE_OFFLINE, nil)
  1051. // util.DebugF("uid=%v online->offline", this.GetUUid())
  1052. // }
  1053. //}
  1054. }
  1055. func (this *Role) isDailyReset() bool {
  1056. if this.GetRoleBase().roleBase.DailyResetTimeStamp <= 0 {
  1057. this.GetRoleBase().roleBase.DailyResetTimeStamp = this.GetRoleBase().RoleData().LastLoginTime
  1058. }
  1059. return model.IsDailyResetHour5(this.GetRoleBase().roleBase.DailyResetTimeStamp)
  1060. //return model.IsDailyResetHour5(this.GetRoleBase().RoleData().LastLoginTime)
  1061. }
  1062. func (this *Role) DailyReset(notify bool) {
  1063. //加载完成后做重置操作
  1064. util.DebugF("uid=%v daily reset nickname=%s", this.GetUUid(), this.GetNickName())
  1065. oldDailyResetTimeStamp := this.GetRoleBase().roleBase.DailyResetTimeStamp
  1066. this.roleArena.DailyReset(notify)
  1067. this.roleBattle.DailyReset(notify)
  1068. this.roleMap.DailyReset(notify)
  1069. this.roleTask.DailyReset(notify, oldDailyResetTimeStamp)
  1070. this.roleSkill.DailyReset(notify)
  1071. this.roleGuild.DailyReset(notify)
  1072. this.roleShop.DailyReset(notify)
  1073. this.roleActivity.DailyReset(notify)
  1074. this.roleInvitation.DailyReset(notify)
  1075. this.roleRune.DailyReset(notify)
  1076. this.roleDaoChang100.DailyReset(notify)
  1077. this.roleCross.DailyReset(notify)
  1078. this.roleHead.DailyReset(notify)
  1079. this.roleCompetition.DailyReset(notify)
  1080. this.roleBT.DailyReset(notify, oldDailyResetTimeStamp)
  1081. //最后重置,切记!
  1082. this.GetRoleBase().DailyReset(notify)
  1083. }
  1084. func (this *Role) SetUpdateDailyReset(ms uint64, bReset bool) {
  1085. //已经重置不需要再次重置
  1086. if !this.isDailyReset() {
  1087. return
  1088. }
  1089. randNum := rand.Int31n(3000)
  1090. this.dailyResetTimer.Reset(ms, time.Duration(randNum), false)
  1091. }
  1092. func (this *Role) FuncDisable() bool {
  1093. //RobotMode 1:机器人模式 2:无法注册 3:关闭付费功能
  1094. if service.GetServiceConfig().Node.RobotMode == 3 {
  1095. return true
  1096. }
  1097. return false
  1098. }
  1099. // 推送客户端启动时需要的信息,例如基本信息,背包信息等
  1100. func (this *Role) StartupProto() {
  1101. // todo 测试使用
  1102. time.Sleep(200 * time.Millisecond)
  1103. nowTime := util.GetTimeMilliseconds()
  1104. startUpTime := service.GetServiceStartupTime()
  1105. ntfMsg := &serverproto.SCStartupInfoNtf{
  1106. ServerTime: nowTime,
  1107. CreateTime: this.RegisterTime,
  1108. FuncDisable: this.FuncDisable(),
  1109. ServiceStartTime: startUpTime,
  1110. }
  1111. //角色基础信息
  1112. ntfMsg.RoleBase = &serverproto.RoleBase{}
  1113. this.GetRoleBase().CopyData(ntfMsg.RoleBase)
  1114. //小红点信息
  1115. ntfMsg.RoleRed = this.roleRed.redInfo
  1116. //伙伴
  1117. ntfMsg.RoleHero = &serverproto.RoleHero{}
  1118. this.roleHero.CopyData(ntfMsg.RoleHero)
  1119. //背包
  1120. ntfMsg.RoleBag = &serverproto.RoleBag{}
  1121. this.roleBag.CopyData(ntfMsg.RoleBag)
  1122. // 许愿箱
  1123. ntfMsg.RoleWishBox = &serverproto.RoleWish{}
  1124. this.roleWish.CopyData(ntfMsg.RoleWishBox)
  1125. //分成多条协议进行发送
  1126. sendLen := this.ReplayGate(ntfMsg, true)
  1127. ntfMsg = &serverproto.SCStartupInfoNtf{
  1128. ServerTime: nowTime,
  1129. CreateTime: this.RegisterTime,
  1130. FuncDisable: this.FuncDisable(),
  1131. ServiceStartTime: startUpTime,
  1132. }
  1133. //碎片
  1134. ntfMsg.RoleChip = &serverproto.RoleChip{}
  1135. this.roleChip.CopyData(ntfMsg.RoleChip)
  1136. //时装
  1137. ntfMsg.RoleFashion = &serverproto.RoleFashion{}
  1138. //this.roleFashion.CopyDatatmp(ntfMsg.RoleFashion)
  1139. this.roleFashion.CopyData(ntfMsg.RoleFashion)
  1140. //战斗数据
  1141. ntfMsg.RoleBattle = &serverproto.RoleBattle{}
  1142. this.roleBattle.CopyData(ntfMsg.RoleBattle)
  1143. //私聊消息列表
  1144. ntfMsg.RoleChat = &serverproto.RoleChat{}
  1145. this.roleChat.CopyData(ntfMsg.RoleChat)
  1146. //rolemap
  1147. ntfMsg.RoleMap = this.roleMap.CopyData()
  1148. ntfMsg.RoleTower = &serverproto.RoleTower{}
  1149. this.roleTower.CopyData(ntfMsg.RoleTower)
  1150. //任务模块
  1151. ntfMsg.RoleTask = this.roleTask.CopyData()
  1152. ntfMsg.RoleDraw = &serverproto.RoleDraw{}
  1153. this.roleDraw.CopyData(ntfMsg.RoleDraw)
  1154. //赛季玩法数据
  1155. ntfMsg.RoleCompetition = &serverproto.RoleCompetition{}
  1156. this.roleCompetition.CopyData(ntfMsg.RoleCompetition)
  1157. //百人道场
  1158. ntfMsg.RoleDaochang100 = &serverproto.RoleDaoChang100{}
  1159. this.roleDaoChang100.CopyData(ntfMsg.RoleDaochang100)
  1160. //战斗力值
  1161. ntfMsg.RoleFightpower = &serverproto.FightPowerData{}
  1162. //this.roleFightPower.CopyData(ntfMsg.RoleFightpower)
  1163. this.roleBattleAttr.CopyData(ntfMsg.RoleFightpower)
  1164. // BT
  1165. ntfMsg.RoleBt = &serverproto.RoleBT{}
  1166. this.roleBT.CopyData(ntfMsg.RoleBt)
  1167. //RobotMode 1:机器人模式 2:无法注册 3:关闭付费功能
  1168. ntfMsg.FuncDisable = this.FuncDisable()
  1169. //分成多条协议进行发送
  1170. sendLen = this.ReplayGate(ntfMsg, true) + sendLen
  1171. ntfMsg = &serverproto.SCStartupInfoNtf{
  1172. ServerTime: nowTime,
  1173. CreateTime: this.RegisterTime,
  1174. FuncDisable: this.FuncDisable(),
  1175. ServiceStartTime: startUpTime,
  1176. }
  1177. //跨服个人数据
  1178. ntfMsg.RoleCross = &serverproto.RoleCross{}
  1179. this.roleCross.CopyData(ntfMsg.RoleCross)
  1180. ntfMsg.RoleSkillEquip = &serverproto.RoleSkillEquip{}
  1181. this.roleSkillEquip.CopyData(ntfMsg.RoleSkillEquip)
  1182. sendLen = this.ReplayGate(ntfMsg, true) + sendLen
  1183. this.tmpState = false
  1184. util.DebugF("uid=%v StartupProto ntfMsgLen=%v", this.GetUUid(), sendLen)
  1185. storyNtf := &serverproto.SCRoleStoryNtf{}
  1186. this.GetRoleBase().CopyStoryData(storyNtf)
  1187. this.ReplayGate(storyNtf, true)
  1188. //通知最近世界聊天信息
  1189. if this.roleChat != nil {
  1190. this.roleChat.WorldMsgNtf()
  1191. }
  1192. //走马灯公告
  1193. RoleMag.NoticeInfoNtf(this)
  1194. //装备
  1195. equipNtfMsg := &serverproto.SCStartupInfoEquipNtf{
  1196. RoleEquipInfo: &serverproto.RoleEquip{},
  1197. }
  1198. this.roleEquip.CopyData(equipNtfMsg.RoleEquipInfo)
  1199. sendLen = this.ReplayGate(equipNtfMsg, true)
  1200. util.DebugF("uid=%v StartupProto ntfMsgLen=%v equip", this.GetUUid(), sendLen)
  1201. //卡片
  1202. cardNtfMsg := &serverproto.SCStartupInfoCardNtf{
  1203. RoleCardInfo: &serverproto.RoleCard{},
  1204. }
  1205. this.roleCard.CopyData(cardNtfMsg.RoleCardInfo)
  1206. sendLen = this.ReplayGate(cardNtfMsg, true)
  1207. util.DebugF("uid=%v StartupProto ntfMsgLen=%v card", this.GetUUid(), sendLen)
  1208. //pet
  1209. this.rolePet.StartupNtf()
  1210. //精彩活动
  1211. this.roleActivity.StartupNtf()
  1212. //邀请码系统
  1213. this.roleInvitation.StartupNtf()
  1214. //初始化结束函数标志
  1215. endMsgNtf := &serverproto.SCStartupInfoEndNtf{}
  1216. this.ReplayGate(endMsgNtf, true)
  1217. this.GetRoleRune().GetFreeGoodsData()
  1218. this.CombineServerNtf()
  1219. }
  1220. // 上线处理
  1221. func (this *Role) onlineProcess(bRelogin bool) {
  1222. //清空缓存列表
  1223. this.reqAckConfirmList = map[uint32][]uint32{}
  1224. this.GetRoleBase().OnlineProcess()
  1225. if this.roleArena != nil {
  1226. this.roleArena.OnlineProcess()
  1227. }
  1228. if this.roleTower != nil {
  1229. this.roleTower.OnlineProcess()
  1230. }
  1231. if this.roleBattle != nil {
  1232. this.roleBattle.OnlineProcess()
  1233. }
  1234. if this.rolePet != nil {
  1235. this.rolePet.OnlineProcess()
  1236. }
  1237. if this.roleRush != nil {
  1238. this.roleRush.OnlineProcess()
  1239. }
  1240. if this.roleTask != nil {
  1241. this.roleTask.OnlineProcess()
  1242. }
  1243. if this.roleActivity != nil {
  1244. this.roleActivity.OnlineProcess()
  1245. }
  1246. if this.roleHead != nil {
  1247. this.roleHead.OnlineProcess()
  1248. }
  1249. // 上线获取赛季奖励处理
  1250. if this.roleCompetition != nil {
  1251. this.roleCompetition.OnlineGetCompetitionReward()
  1252. }
  1253. //上线日志记录
  1254. model.ElasticPutLogInfo(&model.ElasticLogST{
  1255. Uid: this.GetUUid(),
  1256. NickName: this.GetNickName(),
  1257. OpenId: this.GetOpenId(),
  1258. LogType: "RoleOnline",
  1259. LogDesc: "RoleOnline",
  1260. })
  1261. this.MysqlLogNtf(serverproto.MysqlLogType_LType_Online, nil, 0)
  1262. //更新简介信息中的离线时间(上线时也进行一次时间更新)
  1263. this.GetRoleBase().UpdatePlayerBriefInfo(false)
  1264. //获取离线信息玩家列表
  1265. ssOfflineMsg := &serverproto.SSChatOfflinePlayerReq{}
  1266. this.SendDb(ssOfflineMsg)
  1267. //后续功能往后加,,尽量不要影响上面的逻辑
  1268. this.GetRoleGuild().GuildBattleOnline()
  1269. }
  1270. func (this *Role) Logout() {
  1271. this.Save()
  1272. //清空角色信息数据
  1273. if this.base != nil {
  1274. //roleBasePool.Put(this.base)
  1275. this.base = nil
  1276. //删除连接信息
  1277. delConnInfo := &serverproto.SSSaveUserConnectInfo{
  1278. OpenId: this.GetOpenId(),
  1279. Platform: this.GetPlatform(),
  1280. }
  1281. this.SendDb(delConnInfo)
  1282. }
  1283. this.roleHero = nil
  1284. this.roleBag = nil
  1285. this.roleChip = nil
  1286. this.roleEquip = nil
  1287. this.roleMap = nil
  1288. this.roleSkill = nil
  1289. this.roleCard = nil
  1290. this.roleFashion = nil
  1291. this.roleBattle = nil
  1292. this.soList = this.soList[:0]
  1293. }
  1294. func (this *Role) BaseChangeNtf() {
  1295. this.base.BaseChangeNtf()
  1296. }
  1297. func (this *Role) MysqlLogNtf(logType serverproto.MysqlLogType, paramList []int32, subType int32) {
  1298. logData := &serverproto.SSRoleLogData{
  1299. Uid: this.GetUUid(),
  1300. Type: int32(logType),
  1301. SubType: subType,
  1302. ParamList: paramList, //oldval,newval,delval,param
  1303. }
  1304. if logType == serverproto.MysqlLogType_LType_Online {
  1305. if this.GetClientParam() != nil {
  1306. logData.StrList = append(logData.StrList, this.GetClientParam().DeviceModel)
  1307. }
  1308. logData.StrList = append(logData.StrList, this.GetClientIP())
  1309. }
  1310. this.mysqlLogList = append(this.mysqlLogList, logData)
  1311. //mysqlNtf := &serverproto.SSRoleLogNtf{}
  1312. //mysqlNtf.LogList = append(mysqlNtf.LogList, logData)
  1313. //
  1314. //this.SendDb(mysqlNtf)
  1315. }
  1316. func (this *Role) AddMysqlLog(logData *serverproto.SSRoleLogData) {
  1317. this.mysqlLogList = append(this.mysqlLogList, logData)
  1318. }
  1319. func (this *Role) saveMysqlLog() {
  1320. if len(this.mysqlLogList) > 0 {
  1321. mysqlNtf := &serverproto.SSRoleLogNtf{}
  1322. mysqlNtf.LogList = append(mysqlNtf.LogList, this.mysqlLogList...)
  1323. this.SendDb(mysqlNtf)
  1324. this.mysqlLogList = this.mysqlLogList[:0]
  1325. }
  1326. }
  1327. func (this *Role) AddRmb(st AddItemST, add bool) {
  1328. this.base.AddRMB(st, add)
  1329. }
  1330. func (this *Role) GetRmb() uint32 {
  1331. return this.base.GetRmb()
  1332. }
  1333. func (this *Role) AddMoney(st AddItemST, add bool) {
  1334. this.base.AddMoney(st, add)
  1335. }
  1336. func (this *Role) GetMoney() uint64 {
  1337. return this.base.GetMoney()
  1338. }
  1339. func (this *Role) AddHeroExp(st AddItemST, add bool) bool {
  1340. this.base.AddHeroExp(st, add)
  1341. return true
  1342. }
  1343. func (this *Role) AddCruise(st AddItemST, add bool) bool {
  1344. this.base.AddCruise(st, add)
  1345. return true
  1346. }
  1347. // 增加角色基础经验
  1348. func (this *Role) AddBaseExp(st AddItemST) bool {
  1349. //添加属性涉及到升级操作(自动升级)
  1350. this.base.AddBaseExp(st)
  1351. return true
  1352. }
  1353. // 增加职业经验
  1354. func (this *Role) AddJobExp(st AddItemST) bool {
  1355. this.base.AddJobExp(st)
  1356. return false
  1357. }
  1358. func (this *Role) GetRoleLevel() int32 {
  1359. return this.GetRoleBase().GetRoleLevel()
  1360. }
  1361. func (this *Role) GetJobLevel() int32 {
  1362. return this.GetRoleBase().GetRoleJobLevel()
  1363. }
  1364. // 创建角色开始的累计充值
  1365. func (this *Role) GetTotalRecharge() float32 {
  1366. return this.GetRoleBase().GetRoleTotalRecharge()
  1367. }
  1368. // 每日累计充值
  1369. func (this *Role) GetDayRecharge() float32 {
  1370. return this.GetRoleBase().roleBase.DayRecharge
  1371. }
  1372. // bt每日累计充值(真累计充值+假累计充值)
  1373. func (this *Role) GetBTDayRecharge() float32 {
  1374. return this.GetBTZhenDayRecharge() + this.GetBTJiaDayRecharge()
  1375. }
  1376. func (this *Role) GetBTZhenDayRecharge() float32 {
  1377. return this.GetRoleBase().roleBase.BtZhenDayRecharge
  1378. }
  1379. func (this *Role) GetBTJiaDayRecharge() float32 {
  1380. return float32(this.GetRoleBase().roleBase.BtJiaDayRecharge) * BTJiaChangeDollar
  1381. }
  1382. func (this *Role) GetBTJiaTotalRecharge() float32 {
  1383. return float32(this.GetRoleBase().roleBase.BtJiaTotalRecharge) * BTJiaChangeDollar
  1384. }
  1385. // 添加通用资源
  1386. func (this *Role) addCommonRes(resType int32, st AddItemST, add bool) {
  1387. this.base.AddCommonRes(resType, st, add)
  1388. }
  1389. func (this *Role) getCommonResNum(resType int32) int32 {
  1390. return this.base.GetCommonRes(resType)
  1391. }
  1392. func (this *Role) getChipResNum(resType int32) uint32 {
  1393. return this.roleChip.getChipResNum(resType)
  1394. }
  1395. func (this *Role) AddRes(resType int32, st AddItemST, add bool) {
  1396. switch serverproto.ResType(resType) {
  1397. case serverproto.ResType_Res_Coin:
  1398. this.AddMoney(st, add)
  1399. case serverproto.ResType_Res_Rmb:
  1400. this.AddRmb(st, add)
  1401. case serverproto.ResType_Res_RoleBaseExp:
  1402. this.AddBaseExp(st)
  1403. case serverproto.ResType_Res_RoleJobExp:
  1404. this.AddJobExp(st)
  1405. case serverproto.ResType_Res_HeroBaseExp:
  1406. this.AddHeroExp(st, add)
  1407. case serverproto.ResType_Res_Cruise:
  1408. this.AddCruise(st, add)
  1409. //添加通用资源
  1410. case serverproto.ResType_Res_Sprite:
  1411. fallthrough
  1412. case serverproto.ResType_Res_Reslove:
  1413. fallthrough
  1414. case serverproto.ResType_Res_EvilExp:
  1415. fallthrough
  1416. case serverproto.ResType_Res_Guild:
  1417. fallthrough
  1418. case serverproto.ResType_Res_DaoChang100:
  1419. fallthrough
  1420. case serverproto.ResType_Res_VipExp:
  1421. fallthrough
  1422. case serverproto.ResType_Res_Guild_Battle:
  1423. fallthrough
  1424. case serverproto.ResType_Res_PetCoin:
  1425. fallthrough
  1426. case serverproto.ResType_Res_PetExp:
  1427. fallthrough
  1428. case serverproto.ResType_Res_HightSkillExp:
  1429. fallthrough
  1430. case serverproto.ResType_Res_PetLevelUP_Exp:
  1431. fallthrough
  1432. case serverproto.ResType_Res_CreditRecharge:
  1433. fallthrough
  1434. case serverproto.ResType_Res_ROCoin:
  1435. fallthrough
  1436. case serverproto.ResType_Res_BoliShopExp:
  1437. this.addCommonRes(resType, st, add)
  1438. case serverproto.ResType_Res_RushMap:
  1439. this.GetRoleBattle().OnRushMapScoreChange(st.ItemCount, 0)
  1440. default:
  1441. }
  1442. this.GetRoleBase().SetDirty(true)
  1443. }
  1444. func (this *Role) GetResNum(resId int32) uint64 {
  1445. cfgData, ok := serverproto.ItemCfgLoader[resId]
  1446. if !ok {
  1447. util.InfoF("uid=%v item cfg data not found resid=%v", this.GetUUid(), resId)
  1448. return 0
  1449. }
  1450. switch serverproto.ResType(cfgData.ResType) {
  1451. case serverproto.ResType_Res_Coin:
  1452. return this.GetMoney()
  1453. case serverproto.ResType_Res_Rmb:
  1454. return uint64(this.GetRmb())
  1455. case serverproto.ResType_Res_RoleBaseExp:
  1456. return uint64(this.GetRoleBase().GetRoleBaseExp())
  1457. case serverproto.ResType_Res_HeroBaseExp:
  1458. return uint64(this.GetRoleBase().GetHeroBaseExp())
  1459. case serverproto.ResType_Res_RoleJobExp:
  1460. return uint64(this.GetRoleBase().GetRoleJobExp())
  1461. case serverproto.ResType_Res_Cruise:
  1462. return uint64(this.GetRoleBase().GetCruise())
  1463. case serverproto.ResType_Res_Sprite:
  1464. fallthrough
  1465. case serverproto.ResType_Res_Reslove:
  1466. fallthrough
  1467. case serverproto.ResType_Res_EvilExp:
  1468. fallthrough
  1469. case serverproto.ResType_Res_Guild:
  1470. fallthrough
  1471. case serverproto.ResType_Res_DaoChang100:
  1472. fallthrough
  1473. case serverproto.ResType_Res_VipExp:
  1474. fallthrough
  1475. case serverproto.ResType_Res_Guild_Battle:
  1476. fallthrough
  1477. case serverproto.ResType_Res_PetCoin:
  1478. fallthrough
  1479. case serverproto.ResType_Res_PetExp:
  1480. fallthrough
  1481. case serverproto.ResType_Res_HightSkillExp:
  1482. fallthrough
  1483. case serverproto.ResType_Res_PetLevelUP_Exp:
  1484. fallthrough
  1485. case serverproto.ResType_Res_CreditRecharge:
  1486. fallthrough
  1487. case serverproto.ResType_Res_ROCoin:
  1488. fallthrough
  1489. case serverproto.ResType_Res_BoliShopExp:
  1490. return uint64(this.getCommonResNum(resId))
  1491. //背包中
  1492. case serverproto.ResType_Res_SkillBook:
  1493. fallthrough
  1494. case serverproto.ResType_Res_Item:
  1495. fallthrough
  1496. case serverproto.ResType_Res_HeadFrame:
  1497. fallthrough
  1498. case serverproto.ResType_Res_QuickBattle:
  1499. fallthrough
  1500. case serverproto.ResType_Res_CashTicket:
  1501. fallthrough
  1502. case serverproto.ResType_Res_Gift:
  1503. return uint64(this.GetItemNum(resId))
  1504. case serverproto.ResType_Res_Chip:
  1505. return uint64(this.getChipResNum(resId))
  1506. case serverproto.ResType_Res_Equip:
  1507. fallthrough
  1508. case serverproto.ResType_Res_Fashion:
  1509. fallthrough
  1510. case serverproto.ResType_Res_Skill_Equip:
  1511. fallthrough
  1512. default:
  1513. return 0
  1514. }
  1515. }
  1516. func (this *Role) CheckResNum(resTypeList map[int32]int32) (bool, int32) {
  1517. for resType, resValue := range resTypeList {
  1518. if this.GetResNum(resType) < uint64(resValue) {
  1519. return false, resType
  1520. }
  1521. }
  1522. return true, 0
  1523. }
  1524. func (this *Role) CheckResLitNum(resTypeList map[int32]int32) bool {
  1525. for resType, resValue := range resTypeList {
  1526. if this.GetResNum(resType) < uint64(resValue) {
  1527. return false
  1528. }
  1529. }
  1530. return true
  1531. }
  1532. func (this *Role) CanAddItemList(resTypeList map[int32]int32) serverproto.ErrorCode {
  1533. if this.GetRoleBag() != nil {
  1534. return this.GetRoleBag().CanAddItemList(resTypeList)
  1535. }
  1536. return serverproto.ErrorCode_ERROR_FAIL
  1537. }
  1538. func (this *Role) AddItemList(resTypeList map[int32]int32, addFrom AddFromType, notify bool) {
  1539. if this.GetRoleBag() != nil {
  1540. this.GetRoleBag().AddItemList(resTypeList, AddItemST{AddFrom: addFrom, Notify: notify})
  1541. }
  1542. }
  1543. func (this *Role) AddItem(configId int32, count int32, addFrom AddFromType) {
  1544. if this.roleBag != nil {
  1545. this.roleBag.AddItem(configId, count, AddItemST{AddFrom: addFrom, Notify: true})
  1546. }
  1547. }
  1548. func (this *Role) DelItemList(resTypeList map[int32]int32, delFrom AddItemST) {
  1549. if this.GetRoleBag() != nil {
  1550. this.GetRoleBag().DelItemList(resTypeList, delFrom)
  1551. }
  1552. }
  1553. func (this *Role) DelItem(configId int32, count int32, delFrom AddItemST) {
  1554. if this.roleBag != nil {
  1555. this.roleBag.DelItem(configId, count, delFrom)
  1556. }
  1557. }
  1558. // 根据给定的道具动态ID(创建道具时生成的唯一ID)做删除操作
  1559. func (this *Role) DelItemByList(itemIdList []uint64, delFrom AddFromType) {
  1560. if this.roleBag == nil {
  1561. return
  1562. }
  1563. util.InfoF("uid=%v DelItem itemlist=%v ", this.GetUUid(), itemIdList)
  1564. ackMsg := &serverproto.SCDelItemAck{
  1565. Error: int32(serverproto.ErrorCode_ERROR_OK),
  1566. }
  1567. for idx := 0; idx < len(itemIdList); idx++ {
  1568. itemData := this.GetRoleBag().getItemById(itemIdList[idx])
  1569. if itemData != nil && itemData.Num > 0 {
  1570. this.GetRoleBag().DelItemById(itemIdList[idx], int32(itemData.Num), delFrom)
  1571. ackMsg.DelCfgIdList = append(ackMsg.DelCfgIdList, itemData.ConfigId)
  1572. }
  1573. }
  1574. this.ReplayGate(ackMsg, true)
  1575. }
  1576. func (this *Role) GetItemNum(configId int32) uint32 {
  1577. if this.roleBag != nil {
  1578. return this.roleBag.getItemNum(configId)
  1579. }
  1580. return 0
  1581. }
  1582. func (this *Role) UseItem(itemId uint64, itemNum uint32, itemIdxList []int32, bForceItemId bool) {
  1583. if this.roleBag != nil {
  1584. //默认使用一个
  1585. if itemNum == 0 {
  1586. itemNum = 1
  1587. }
  1588. err := this.roleBag.UseItem(itemId, itemNum, itemIdxList, bForceItemId)
  1589. if err != serverproto.ErrorCode_ERROR_OK {
  1590. ackMsg := &serverproto.SCUseItemAck{
  1591. Error: int32(err),
  1592. }
  1593. this.ReplayGate(ackMsg, true)
  1594. }
  1595. }
  1596. }
  1597. func (this *Role) OnlineTimeReward() {
  1598. err := this.GetRoleBase().OnlineTimeReward()
  1599. if err != serverproto.ErrorCode_ERROR_OK {
  1600. ackMsg := &serverproto.SCOnlineTimeRewardAck{
  1601. Error: int32(err),
  1602. }
  1603. this.ReplayGate(ackMsg, true)
  1604. }
  1605. }
  1606. // 获取当前累计充值所属档位
  1607. // 玩家累计充值金额档位1:[0-100] 2:(100,1000] 3:(1000,10000]
  1608. func (this *Role) GetTotalRechargeTap() int32 {
  1609. var tmpTap int32 = 0
  1610. tmpTotalRecharge := int32(this.GetTotalRecharge())
  1611. for idx := 0; idx < len(model.GlobalTotalRechargeList); idx++ {
  1612. if tmpTotalRecharge < model.GlobalTotalRechargeList[idx].Value {
  1613. return model.GlobalTotalRechargeList[idx].Key
  1614. }
  1615. tmpTap = model.GlobalTotalRechargeList[idx].Key
  1616. }
  1617. return tmpTap
  1618. }
  1619. func (this *Role) GetRoleBriefInfo(briefInfo *serverproto.CommonPlayerBriefInfo) {
  1620. briefInfo.Uid = this.GetUUid()
  1621. briefInfo.NickName = this.GetNickName()
  1622. briefInfo.Gender = this.GetRoleBase().GetRoleSex()
  1623. briefInfo.ImgId = this.GetImageId()
  1624. briefInfo.Level = this.GetRoleLevel()
  1625. briefInfo.ConfigId = this.GetRoleBase().RoleData().HeroData.ConfigId
  1626. briefInfo.FightPower = int32(this.roleBattleAttr.curTotalFightPower)
  1627. //briefInfo.FightPower = int32(this.GetRoleFightPower().TotalFightPower) //(this.GetRoleBase().RoleData().FightPower)
  1628. briefInfo.TowerLevel = this.GetRoleTower().nowTowerLevel
  1629. briefInfo.TowerTime = uint64(this.GetRoleTower().nowTowerPassTime)
  1630. briefInfo.HeadFrameId = this.GetRoleBase().RoleData().HeadFrameId
  1631. briefInfo.VipLevel = this.GetRoleVipLevel()
  1632. briefInfo.HeadId = this.GetHeadId()
  1633. if this.GetState() == ROLE_STATE_ONLINE {
  1634. briefInfo.OnlineState = true
  1635. } else {
  1636. briefInfo.OnlineTime = this.GetRoleBase().GetLastLoginTime()
  1637. }
  1638. }
  1639. func (this *Role) GetRoleFightInfo(fightInfo *serverproto.FightRoleInfo, isMainRole bool) {
  1640. fightInfo.IsRobot = false
  1641. fightInfo.BriefInfo = &serverproto.CommonPlayerBriefInfo{
  1642. Uid: this.GetUUid(),
  1643. NickName: this.GetNickName(),
  1644. Gender: this.GetRoleBase().GetRoleSex(),
  1645. ImgId: this.GetImageId(),
  1646. HeadFrameId: this.GetRoleBase().RoleData().HeadFrameId,
  1647. VipLevel: this.GetRoleVipLevel(),
  1648. SelectZone: this.GetSelectZone(),
  1649. ConfigId: this.GetRoleHero().GetMainHero().ConfigId,
  1650. Level: this.GetRoleLevel(),
  1651. }
  1652. fightInfo.JobLevel = this.GetJobLevel()
  1653. //后续需要处理
  1654. fightInfo.AttrList = this.GetRoleHero().GetMainHero().AttrList
  1655. fightInfo.FashionData = this.GetRoleBase().roleBase.FashionData
  1656. //技能竞技压制
  1657. fightInfo.RepressSkillPvpVal = this.GetRoleBase().roleBase.RepressSkillPvpVal
  1658. fightInfo.MaxFightPower = int32(this.GetRoleBase().RoleData().FightPower)
  1659. //世界boss,只上阵主角
  1660. mainHeroData := this.GetRoleBase().RoleData().HeroData
  1661. fightInfo.HeroDataList = append(fightInfo.HeroDataList, this.GetRoleBase().RoleData().HeroData)
  1662. if mainHeroData.BattlePetId > 0 && this.GetRolePet() != nil {
  1663. battlePetInfo := this.GetRolePet().getPet(mainHeroData.BattlePetId)
  1664. if battlePetInfo != nil {
  1665. fightInfo.BattlePetList = append(fightInfo.BattlePetList, battlePetInfo)
  1666. }
  1667. }
  1668. if !isMainRole {
  1669. //其他上阵伙伴
  1670. for _, data := range this.GetRoleHero().heroList {
  1671. if data.IsBattle {
  1672. fightInfo.HeroDataList = append(fightInfo.HeroDataList, data)
  1673. if data.BattlePetId > 0 && this.GetRolePet() != nil {
  1674. battlePetInfo := this.GetRolePet().getPet(data.BattlePetId)
  1675. if battlePetInfo != nil {
  1676. fightInfo.BattlePetList = append(fightInfo.BattlePetList, battlePetInfo)
  1677. }
  1678. }
  1679. }
  1680. }
  1681. }
  1682. }
  1683. type AddSystemMsg struct {
  1684. ParamId int32
  1685. ParamCount int32
  1686. AddFromType int32
  1687. UseItemCfgId int32
  1688. ParamList []int32
  1689. ParaStr string
  1690. }
  1691. func (this *Role) GenSystemMessage(sType SystemMessageType, st AddSystemMsg) *serverproto.SystemMessage {
  1692. ssMsgNtf := &serverproto.SSSystemMessageNtf{}
  1693. sysMsg := &serverproto.SystemMessage{
  1694. Type: int32(sType),
  1695. NickName: this.GetNickName(),
  1696. SendTime: util.GetTimeMilliseconds(),
  1697. }
  1698. if st.ParamId > 0 {
  1699. sysMsg.ParamId = append(sysMsg.ParamId, st.ParamId) //id
  1700. }
  1701. if st.ParamCount > 0 {
  1702. sysMsg.ParamId = append(sysMsg.ParamId, st.ParamCount) //count
  1703. }
  1704. if st.AddFromType > 0 {
  1705. sysMsg.ParamId = append(sysMsg.ParamId, st.AddFromType) //AddFromType
  1706. }
  1707. if st.UseItemCfgId > 0 {
  1708. sysMsg.ParamId = append(sysMsg.ParamId, st.UseItemCfgId) //UseItemCfgId
  1709. }
  1710. if len(st.ParamList) > 0 {
  1711. sysMsg.ParamId = append(sysMsg.ParamId, st.ParamList...)
  1712. }
  1713. if sType == SystemmessageType_GuildDemon {
  1714. sysMsg.NickName = st.ParaStr
  1715. }
  1716. ssMsgNtf.SysMsg = append(ssMsgNtf.SysMsg, sysMsg)
  1717. //util.InfoF("uid=%v GenSystemMessage type=%v param=%v", this.GetUUid(), sysMsg.Type, sysMsg.ParamId)
  1718. return sysMsg
  1719. }
  1720. func (this *Role) AddSystemMessage(sType SystemMessageType, st AddSystemMsg) {
  1721. ssMsgNtf := &serverproto.SSSystemMessageNtf{}
  1722. sysMsg := &serverproto.SystemMessage{
  1723. Type: int32(sType),
  1724. NickName: this.GetNickName(),
  1725. SendTime: util.GetTimeMilliseconds(),
  1726. }
  1727. if st.ParamId > 0 {
  1728. sysMsg.ParamId = append(sysMsg.ParamId, st.ParamId) //id
  1729. }
  1730. if st.ParamCount > 0 {
  1731. sysMsg.ParamId = append(sysMsg.ParamId, st.ParamCount) //count
  1732. }
  1733. if st.AddFromType > 0 {
  1734. sysMsg.ParamId = append(sysMsg.ParamId, st.AddFromType) //AddFromType
  1735. }
  1736. if st.UseItemCfgId > 0 {
  1737. sysMsg.ParamId = append(sysMsg.ParamId, st.UseItemCfgId) //UseItemCfgId
  1738. }
  1739. if len(st.ParamList) > 0 {
  1740. sysMsg.ParamId = append(sysMsg.ParamId, st.ParamList...)
  1741. }
  1742. if sType == SystemmessageType_GuildDemon {
  1743. sysMsg.NickName = st.ParaStr
  1744. }
  1745. ssMsgNtf.SysMsg = append(ssMsgNtf.SysMsg, sysMsg)
  1746. this.SendSocial(ssMsgNtf)
  1747. }
  1748. // 分配属性点
  1749. func (this *Role) AddAttrPoint(heroID int32, point interface{}) {
  1750. ret := this.GetRoleHero().AddAttrPoint(heroID, point)
  1751. if ret != serverproto.ErrorCode_ERROR_OK {
  1752. ackMsg := &serverproto.SCAddAttrPointAck{
  1753. Error: int32(ret),
  1754. HeroId: heroID,
  1755. }
  1756. this.ReplayGate(ackMsg, true)
  1757. }
  1758. }
  1759. // 重置属性点
  1760. func (this *Role) ResetAttrPoint(heroID int32) {
  1761. this.GetRoleHero().ResetAttrPoint(heroID, false)
  1762. }
  1763. // 增加素质点
  1764. func (this *Role) OnAddQualityPoint(msg *serverproto.CSAddQualityPointReq) {
  1765. if msg == nil {
  1766. return
  1767. }
  1768. ackMsg := &serverproto.SCAddQualityPointAck{}
  1769. ackMsg.HeroId = msg.HeroId
  1770. ackMsg.ItemId = msg.ItemId
  1771. ackMsg.Error = int32(this.GetRoleHero().UseQualityItem(msg.HeroId, msg.ItemId))
  1772. this.ReplayGate(ackMsg, true)
  1773. }
  1774. // 激活头像
  1775. func (this *Role) ActiveHead(headId int32) {
  1776. ackMsg := &serverproto.SCActiveHeadAck{
  1777. HeadId: headId,
  1778. }
  1779. bRet := this.base.ActiveHead(headId)
  1780. ackMsg.Error = int32(bRet)
  1781. this.ReplayGate(ackMsg, true)
  1782. }
  1783. // 设置头像
  1784. func (this *Role) SetRoleHeadPic(headId int32) {
  1785. ackMsg := &serverproto.SCSetHeadIdAck{
  1786. HeadId: headId,
  1787. }
  1788. bRet := this.GetRoleBase().SetRoleHeadPic(headId)
  1789. ackMsg.Error = int32(bRet)
  1790. this.ReplayGate(ackMsg, true)
  1791. //更新玩家简介信息
  1792. if bRet == serverproto.ErrorCode_ERROR_OK {
  1793. this.GetRoleBase().UpdatePlayerBriefInfo(false)
  1794. }
  1795. }
  1796. func (this *Role) SetRoleHeadFrameId(frameId int32) {
  1797. ackMsg := &serverproto.SCChangeHeadFrameAck{
  1798. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  1799. HeadFrameId: frameId,
  1800. }
  1801. bRet := this.GetRoleBase().SetHeadFrameId(frameId)
  1802. ackMsg.Error = int32(bRet)
  1803. this.ReplayGate(ackMsg, true)
  1804. }
  1805. func (this *Role) UseHeadFrameItem(itemId uint64, itemNum uint32) {
  1806. ackMsg := &serverproto.SCUseHeadFrameItemAck{
  1807. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  1808. }
  1809. bRet, res_list := this.GetRoleBag().UseHeadFrameItem(itemId, itemNum)
  1810. ackMsg.Error = int32(bRet)
  1811. ackMsg.ItemList = res_list
  1812. this.ReplayGate(ackMsg, true)
  1813. }
  1814. func (this *Role) GetRoleHeadFrameInfo() {
  1815. ackMsg := &serverproto.SCHeadFrameInfoAck{
  1816. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  1817. }
  1818. bRet := this.GetRoleBase().PackHeadFrameInfo(ackMsg)
  1819. ackMsg.Error = int32(bRet)
  1820. this.ReplayGate(ackMsg, true)
  1821. }
  1822. // 请求头像信息
  1823. func (this *Role) HeadInfoReq() {
  1824. this.base.HeadInfoReq()
  1825. }
  1826. func (this *Role) ChangeRoleName(name string) {
  1827. ackMsg := &serverproto.SCRenameAck{
  1828. Name: name,
  1829. }
  1830. bRet := this.base.ChangeRoleName(name)
  1831. ackMsg.Error = int32(bRet)
  1832. this.ReplayGate(ackMsg, true)
  1833. //更新玩家简介信息
  1834. if bRet == serverproto.ErrorCode_ERROR_OK {
  1835. this.GetRoleBase().UpdatePlayerBriefInfo(false)
  1836. }
  1837. }
  1838. func (this *Role) SetRoleGuide(guideId int32) {
  1839. this.GetRoleBase().SetGuideId(guideId)
  1840. }
  1841. func (this *Role) SetRoleStory(story *serverproto.KeyValueType) {
  1842. nRet := this.GetRoleBase().SetStoryId(story)
  1843. ackMsg := &serverproto.SCRoleStoryAck{
  1844. Error: int32(nRet),
  1845. StoryId: story,
  1846. }
  1847. this.ReplayGate(ackMsg, true)
  1848. }
  1849. func (this *Role) SetMapCartoon(id, status int32) {
  1850. bRet := this.GetRoleBase().SetNewMapCartoonId(id, status)
  1851. ackMsg := &serverproto.SCNewMapCartoonAck{
  1852. Error: int32(bRet),
  1853. MapCart: &serverproto.KeyValueType{
  1854. Key: id,
  1855. Value: status,
  1856. },
  1857. }
  1858. this.ReplayGate(ackMsg, true)
  1859. }
  1860. // /hero/partner
  1861. // 添加伙伴
  1862. func (this *Role) AddHero(configId int32) bool {
  1863. if this.roleHero != nil {
  1864. return this.roleHero.AddHero(configId)
  1865. }
  1866. return false
  1867. }
  1868. func (this *Role) HeroLevelUp(id int32) bool {
  1869. if this.roleHero != nil {
  1870. return this.roleHero.LevelUp(id)
  1871. }
  1872. return false
  1873. }
  1874. func (this *Role) HeroAdvance(id int32) bool {
  1875. if this.roleHero != nil {
  1876. ret := this.roleHero.Advance(id)
  1877. if ret == serverproto.ErrorCode_ERROR_OK {
  1878. ////进阶重新处理属性
  1879. //this.roleFightPower.onFighterAttrChange(id)
  1880. } else {
  1881. ackMsg := &serverproto.SCHeroAdvanceAck{
  1882. Error: int32(ret),
  1883. }
  1884. this.ReplayGate(ackMsg, true)
  1885. }
  1886. return ret == serverproto.ErrorCode_ERROR_OK
  1887. }
  1888. return false
  1889. }
  1890. func (this *Role) HeroStrength(id int32) bool {
  1891. if this.roleHero != nil {
  1892. ret := this.roleHero.HeroStrength(id)
  1893. return ret
  1894. }
  1895. return false
  1896. }
  1897. func (this *Role) HeroChangeJob(heroId int32, jobId int32) bool {
  1898. ackMsg := &serverproto.SCHeroChangeJobAck{
  1899. Error: int32(serverproto.ErrorCode_ERROR_OK),
  1900. HeroId: heroId,
  1901. }
  1902. if this.roleHero != nil {
  1903. ret := this.roleHero.HeroChangeJob(heroId, jobId)
  1904. if ret == serverproto.ErrorCode_ERROR_OK {
  1905. ////转职重新处理属性 后续重新开发
  1906. //this.roleFightPower.onFighterAttrChange(heroId)
  1907. }
  1908. ackMsg.Error = int32(ret)
  1909. this.ReplayGate(ackMsg, true)
  1910. return true
  1911. }
  1912. return false
  1913. }
  1914. func (this *Role) HeroRecruit(configId int32) {
  1915. ackMsg := &serverproto.SCHeroActiveAck{
  1916. HeroId: configId,
  1917. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  1918. }
  1919. if this.roleHero != nil {
  1920. nRet := this.roleHero.RecruitHero(configId)
  1921. ackMsg.Error = int32(nRet)
  1922. }
  1923. this.ReplayGate(ackMsg, true)
  1924. }
  1925. func (this *Role) FightPowerReq(heroId int32) {
  1926. ackMsg := &serverproto.SCHeroFighPowerAck{
  1927. Error: int32(serverproto.ErrorCode_ERROR_OK),
  1928. HeroId: heroId,
  1929. }
  1930. //this.roleFightPower.calcHeroFightPower(heroId)
  1931. this.ReplayGate(ackMsg, true)
  1932. }
  1933. func (this *Role) HeroBattle(heroId int32, isBattle bool) {
  1934. if this.roleHero != nil {
  1935. ret := this.roleHero.HeroBattle(heroId, isBattle)
  1936. ackMsg := &serverproto.SCHeroBattleAck{
  1937. Error: int32(ret),
  1938. }
  1939. this.ReplayGate(ackMsg, true)
  1940. }
  1941. }
  1942. func (this *Role) ComposeChip(configId int32) {
  1943. if this.roleChip != nil && this.roleHero != nil {
  1944. ret := this.roleChip.ComposeChip(configId)
  1945. if ret != serverproto.ErrorCode_ERROR_OK {
  1946. util.DebugF("uid=%v ComposeChip err=%v", this.GetUUid(), ret)
  1947. }
  1948. ackMsg := &serverproto.SCChipComposeAck{
  1949. Error: int32(ret),
  1950. }
  1951. this.ReplayGate(ackMsg, true)
  1952. }
  1953. }
  1954. func (this *Role) ChipDecompose(chipList []*serverproto.KeyValueType, heroChipType []int32) {
  1955. if this.roleChip != nil {
  1956. ret := this.roleChip.ChipDecompose(chipList, heroChipType)
  1957. if ret != serverproto.ErrorCode_ERROR_OK {
  1958. ackMsg := &serverproto.SCHeroChipDecomposeAck{
  1959. Error: int32(ret),
  1960. }
  1961. this.ReplayGate(ackMsg, true)
  1962. }
  1963. }
  1964. }
  1965. // /equip
  1966. func (this *Role) EquipForge(equipConfigId int32, once int32, equipType, subEquipType int32) {
  1967. if this.roleEquip != nil {
  1968. this.roleEquip.EquipForge(equipConfigId, once, equipType, subEquipType)
  1969. }
  1970. }
  1971. func (this *Role) AddEquip(configId int32, num int32, notify bool, ignore bool) {
  1972. if this.roleEquip != nil {
  1973. addEquip, _ := this.roleEquip.AddEquip(configId, num)
  1974. if addEquip != nil {
  1975. if notify {
  1976. ntfMsg := &serverproto.SCEquipChangeNtf{
  1977. Ignore: ignore,
  1978. }
  1979. ntfMsg.EquipList = append(ntfMsg.EquipList, addEquip.(*serverproto.EquipData))
  1980. this.ReplayGate(ntfMsg, true)
  1981. }
  1982. util.InfoF("uid=%v AddEquip id=%v now=%v num=%v", this.GetUUid(), configId,
  1983. addEquip.(*serverproto.EquipData).Num, num)
  1984. }
  1985. }
  1986. }
  1987. func (this *Role) AddSkillEquip(configId int32, num int32, notify bool, ignore bool) {
  1988. if this.roleSkillEquip != nil {
  1989. changeIdList := map[uint32]int32{}
  1990. var i int32 = 0
  1991. for ; i < num; i++ {
  1992. addSkillEquip, _ := this.roleSkillEquip.AddSkillEquip(configId, 0)
  1993. if addSkillEquip != nil {
  1994. detail, ok := addSkillEquip.(*serverproto.SkillEquipData)
  1995. if !ok {
  1996. continue
  1997. }
  1998. changeIdList[detail.Id] = detail.ConfigId
  1999. }
  2000. }
  2001. this.roleSkillEquip.ChangeNtf(changeIdList, ignore)
  2002. }
  2003. }
  2004. func (this *Role) EquipUp(heroId int32, slotIndex int32, equipId int32) {
  2005. if this.roleEquip != nil && this.roleHero != nil &&
  2006. heroId > 0 && slotIndex >= 0 && equipId >= 0 {
  2007. ret := this.base.EquipUp(heroId, slotIndex, equipId)
  2008. ackMsg := &serverproto.SCEquipUpAck{
  2009. Error: int32(ret),
  2010. }
  2011. this.ReplayGate(ackMsg, true)
  2012. } else {
  2013. ackMsg := &serverproto.SCEquipUpAck{
  2014. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2015. }
  2016. this.ReplayGate(ackMsg, true)
  2017. }
  2018. }
  2019. func (this *Role) EquipDown(heroId int32, subIndex int32) {
  2020. if this.roleEquip != nil && this.roleHero != nil {
  2021. this.base.EquipDown(heroId, subIndex)
  2022. }
  2023. }
  2024. func (this *Role) EquipLevelUpAll(heroId int32) {
  2025. if this.roleEquip != nil && this.roleHero != nil {
  2026. this.base.EquipLevelUpAll(heroId)
  2027. }
  2028. }
  2029. func (this *Role) EquipSlotLevelUp(heroId int32, subSlotIndex int32) {
  2030. if this.roleEquip != nil {
  2031. ret := this.base.EquipSlotLevelUp(heroId, subSlotIndex)
  2032. util.DebugF("uid=%v [EquipSlotLevelUp] err=%v", this.GetUUid(), ret)
  2033. ackMsg := &serverproto.SCEquipSlotLevelUpAck{
  2034. Error: int32(ret),
  2035. }
  2036. this.ReplayGate(ackMsg, true)
  2037. }
  2038. }
  2039. // 神器槽位升级
  2040. func (this *Role) SkillEquipSlotLevelUp(heroId, subIndex int32) {
  2041. if this.roleSkillEquip != nil && this.roleHero != nil {
  2042. slotData := this.base.getSkillEquipSlotData(heroId)
  2043. ret := this.roleSkillEquip.SkillEquipSlotLevelUp(slotData, heroId, subIndex)
  2044. util.DebugF("uid=%v [EquipSlotLevelUp] err=%v", this.GetUUid(), ret)
  2045. ackMsg := &serverproto.SCSkillEquipSlotLevelUpAck{
  2046. Error: int32(ret),
  2047. }
  2048. this.ReplayGate(ackMsg, true)
  2049. }
  2050. }
  2051. // 神器升星
  2052. func (this *Role) SkillEquipStarLevelUp(heroId int32, skillEquipId uint32, cost []uint32) {
  2053. if this.roleSkillEquip != nil && this.roleHero != nil {
  2054. slotData := this.base.getSkillEquipSlotData(heroId)
  2055. ret := this.roleSkillEquip.SkillEquipStarLevelUp(heroId, slotData, skillEquipId, cost)
  2056. util.DebugF("uid=%v [SkillEquipStarLevelUp] err=%v", this.GetUUid(), ret)
  2057. ackMsg := &serverproto.SCSkillEquipLevelUpAck{
  2058. Error: int32(ret),
  2059. }
  2060. this.ReplayGate(ackMsg, true)
  2061. }
  2062. }
  2063. // 神器转移
  2064. func (this *Role) SkillEquipShift(msg *serverproto.CSSkillEquipShiftReq) {
  2065. if msg == nil {
  2066. return
  2067. }
  2068. ret := this.roleSkillEquip.SkillEquipShift(msg.SrcId, msg.DstId)
  2069. util.DebugF("uid=%v [SkillEquipShift] err=%v", this.GetUUid(), ret)
  2070. ackMsg := &serverproto.SCSkillEquipShiftAck{
  2071. Error: int32(ret),
  2072. }
  2073. this.ReplayGate(ackMsg, true)
  2074. }
  2075. // 佩戴替换神器
  2076. func (this *Role) SkillEquipUp(heroId int32, skillEquipId uint32, slotIndex int32) {
  2077. if this.roleSkillEquip != nil && this.roleHero != nil {
  2078. slotData := this.base.getSkillEquipSlotData(heroId)
  2079. ret := this.roleSkillEquip.SkillEquipUp(heroId, slotData, skillEquipId, slotIndex)
  2080. util.DebugF("uid=%v [SkillEquipUp] err=%v", this.GetUUid(), ret)
  2081. ackMsg := &serverproto.SCSkillEquipUpAck{
  2082. Error: int32(ret),
  2083. }
  2084. this.ReplayGate(ackMsg, true)
  2085. }
  2086. }
  2087. // 卸下神器
  2088. func (this *Role) SkillEquipDown(heroId int32, slotIndex int32) {
  2089. if this.roleSkillEquip != nil && this.roleHero != nil {
  2090. slotData := this.base.getSkillEquipSlotData(heroId)
  2091. ret := this.roleSkillEquip.SkillEquipDown(heroId, slotData, slotIndex)
  2092. util.DebugF("uid=%v [SkillEquipDown] err=%v", this.GetUUid(), ret)
  2093. ackMsg := &serverproto.SCSkillEquipDownAck{
  2094. Error: int32(ret),
  2095. }
  2096. this.ReplayGate(ackMsg, true)
  2097. }
  2098. }
  2099. // 分解神器
  2100. func (this *Role) SkillEquipDecompose(skillEquipIds []uint32) {
  2101. if this.roleSkillEquip != nil && this.roleHero != nil {
  2102. reward, ret := this.roleSkillEquip.SkillEquipDecompose(skillEquipIds)
  2103. util.DebugF("uid=%v [SkillEquipDecompose] err=%v", this.GetUUid(), ret)
  2104. ackMsg := &serverproto.SCSkillEquipDecomposeAck{
  2105. Error: int32(ret),
  2106. }
  2107. if reward != nil && len(reward) > 0 {
  2108. for k, v := range reward {
  2109. ackMsg.ItemList = append(ackMsg.ItemList, &serverproto.KeyValueType{
  2110. Key: k,
  2111. Value: v,
  2112. })
  2113. }
  2114. }
  2115. this.ReplayGate(ackMsg, true)
  2116. }
  2117. }
  2118. func (this *Role) SkillEquipRemade(skillEquipId uint32) {
  2119. if this.roleSkillEquip != nil && this.roleHero != nil {
  2120. ackMsg := &serverproto.SCSkillEquipRemadeAck{
  2121. OldId: skillEquipId,
  2122. }
  2123. ret, newId := this.roleSkillEquip.SkillEquipReforge(skillEquipId)
  2124. ackMsg.Error = int32(ret)
  2125. ackMsg.NewId = newId
  2126. this.ReplayGate(ackMsg, true)
  2127. }
  2128. }
  2129. func (this *Role) GetSkillEquipPool() {
  2130. if this.roleSkillEquip != nil {
  2131. ackMsg := &serverproto.SCSkillEquipPoolAck{}
  2132. ret := this.roleSkillEquip.GetSkillEquipPool(ackMsg)
  2133. ackMsg.Error = int32(ret)
  2134. this.ReplayGate(ackMsg, true)
  2135. }
  2136. }
  2137. // /card
  2138. func (this *Role) CardMount(heroId, subSlotIndex, cardSlotIndex, cardCfgId int32) {
  2139. if this.roleEquip != nil && this.roleCard != nil {
  2140. ret := this.base.SlotCardMount(heroId, subSlotIndex, cardSlotIndex, cardCfgId)
  2141. util.DebugF("uid=%v CardMount err=%v", this.GetUUid(), ret)
  2142. ackMsg := &serverproto.SCCardMountAck{
  2143. Error: int32(ret),
  2144. }
  2145. this.ReplayGate(ackMsg, true)
  2146. }
  2147. }
  2148. func (this *Role) CardDown(heroId, subSlotIndex, cardSlotIndex int32) {
  2149. if this.roleCard != nil {
  2150. ret := this.base.SlotCardDown(heroId, subSlotIndex, cardSlotIndex)
  2151. util.DebugF("uid=%v CardDown err=%v", this.GetUUid(), ret)
  2152. ackMsg := &serverproto.SCCardDownAck{
  2153. Error: int32(ret),
  2154. }
  2155. this.ReplayGate(ackMsg, true)
  2156. }
  2157. }
  2158. func (this *Role) CardMountAll(msg *serverproto.CSCardEquipAllReq) {
  2159. if msg == nil || len(msg.EqiupSlotData) <= 0 {
  2160. return
  2161. }
  2162. if this.roleEquip != nil && this.roleCard != nil {
  2163. ret := this.base.SlotCardMountAll(msg)
  2164. util.DebugF("uid=%v CardMountAll err=%v", this.GetUUid(), ret)
  2165. ackMsg := &serverproto.SCCardEquipAllAck{
  2166. Error: int32(ret),
  2167. }
  2168. this.ReplayGate(ackMsg, true)
  2169. }
  2170. }
  2171. func (this *Role) CardDownAll(heroId int32) {
  2172. if this.roleEquip != nil && this.roleCard != nil {
  2173. ret := this.base.SlotCardDownAll(heroId)
  2174. util.DebugF("uid=%v CardDownAll err=%v", this.GetUUid(), ret)
  2175. ackMsg := &serverproto.SCCardEquipDownAck{
  2176. Error: int32(ret),
  2177. HeroId: heroId,
  2178. }
  2179. this.ReplayGate(ackMsg, true)
  2180. }
  2181. }
  2182. func (this *Role) CardUpGradeAll(msg *serverproto.CSCardUpGradeAllReq) {
  2183. if this.roleCard != nil {
  2184. ret := this.base.SlotCardUpGradeAll(msg)
  2185. util.DebugF("uid=%v CardUpGradeAll err=%v", this.GetUUid(), ret)
  2186. ackMsg := &serverproto.SCCardUpGradeAllAck{
  2187. Error: int32(ret),
  2188. HeroId: msg.HeroId,
  2189. }
  2190. this.ReplayGate(ackMsg, true)
  2191. }
  2192. }
  2193. func (this *Role) CardLevelExchange(sourceCardId, targetCardId int32) {
  2194. ackMsg := &serverproto.SCCardLevelExchangeAck{
  2195. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2196. }
  2197. if this.roleCard != nil {
  2198. ret := this.roleCard.CardExchange(sourceCardId, targetCardId, ackMsg)
  2199. ackMsg.Error = int32(ret)
  2200. }
  2201. this.ReplayGate(ackMsg, true)
  2202. }
  2203. func (this *Role) CardCollect() {
  2204. if this.roleCard != nil {
  2205. ackMsg := &serverproto.SCCardCollectInfoAck{
  2206. Error: int32(serverproto.ErrorCode_ERROR_OK),
  2207. }
  2208. this.GetRoleCard().GetCardCollect(ackMsg)
  2209. this.ReplayGate(ackMsg, true)
  2210. }
  2211. }
  2212. func (this *Role) CardCollectReward(cardId, level int32) {
  2213. if this.roleCard != nil {
  2214. ackMsg := &serverproto.SCCardCollectRewardAck{
  2215. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2216. }
  2217. ret := this.GetRoleCard().GetCollectReward(cardId, level, ackMsg)
  2218. ackMsg.Error = int32(ret)
  2219. ackMsg.CardId = cardId
  2220. ackMsg.Level = level
  2221. this.ReplayGate(ackMsg, true)
  2222. }
  2223. }
  2224. func (this *Role) CardCompose(cardList []int32) {
  2225. if this.roleCard != nil {
  2226. ret, newCardId := this.roleCard.CardCompose(cardList)
  2227. util.DebugF("uid=%v CardCompose err=%v", this.GetUUid(), ret)
  2228. ackMsg := &serverproto.SCCardComposeAck{
  2229. Error: int32(ret),
  2230. NewCardId: newCardId,
  2231. }
  2232. this.ReplayGate(ackMsg, true)
  2233. }
  2234. }
  2235. func (this *Role) CardDecompose(cardList []*serverproto.KeyValueType, cardType int32) {
  2236. if this.roleCard != nil {
  2237. this.roleCard.CardDecompose(cardList, cardType)
  2238. }
  2239. }
  2240. func (this *Role) CardUpGrade(msg *serverproto.CSCardUpGradeReq) {
  2241. ackMsg := &serverproto.SCCardUpGradeAck{
  2242. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2243. }
  2244. if this.roleCard != nil && len(msg.ConfigIds) > 0 {
  2245. this.roleCard.BagCardUpGrade(msg, ackMsg)
  2246. }
  2247. this.ReplayGate(ackMsg, true)
  2248. }
  2249. // /skill
  2250. func (this *Role) SkillReplace(heroId, idx, replaceSkillId int32) {
  2251. if this.roleSkill != nil {
  2252. ret := this.roleSkill.SkillReplace(heroId, idx, replaceSkillId, true, true)
  2253. util.DebugF("uid=%v SkillReplace] err=%v", this.GetUUid(), ret)
  2254. this.ReplayGate(&serverproto.SCReplaceSkillAck{Error: int32(ret)}, true)
  2255. }
  2256. }
  2257. func (this *Role) ActiveSkill(heroId int32, skillId int32) {
  2258. if this.roleSkill != nil {
  2259. ret := this.roleSkill.ActiveSkill(heroId, skillId)
  2260. util.DebugF("uid=%v ActiveSkill err=%v heroid=%v skillid=%v", this.GetUUid(), ret, heroId, skillId)
  2261. this.ReplayGate(&serverproto.SCActiveSkillAck{Error: int32(ret)}, true)
  2262. }
  2263. }
  2264. func (this *Role) SwapSkill(heroId, firstSlotId, secondSlotId int32) {
  2265. if this.roleSkill != nil {
  2266. ret := this.roleSkill.SwapSkill(heroId, firstSlotId, secondSlotId)
  2267. util.DebugF("uid=%v SwapSkill err=%v s1=%v s2=%v", this.GetUUid(), ret, firstSlotId, secondSlotId)
  2268. this.ReplayGate(&serverproto.SCSwapSkillAck{Error: int32(ret)}, true)
  2269. }
  2270. }
  2271. func (this *Role) SetSkillList(heroId int32, skillList []int32) {
  2272. ackMsg := &serverproto.SCSetSkillListAck{
  2273. HeroId: heroId,
  2274. }
  2275. if this.roleSkill != nil {
  2276. ret := this.roleSkill.SetSkillList(heroId, skillList)
  2277. ackMsg.Error = int32(ret)
  2278. }
  2279. this.ReplayGate(ackMsg, true)
  2280. }
  2281. func (this *Role) SkillLevelUp(heroId int32, skillId int32) {
  2282. ackMsg := &serverproto.SCSkillLevelUpAck{
  2283. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2284. SkillId: skillId,
  2285. HeroId: heroId,
  2286. }
  2287. if this.roleHero == nil {
  2288. this.ReplayGate(ackMsg, true)
  2289. return
  2290. }
  2291. heroData := this.roleHero.GetHero(heroId)
  2292. if heroData == nil {
  2293. this.ReplayGate(ackMsg, true)
  2294. return
  2295. }
  2296. bRet := this.roleSkill.SkillLevelUp(heroData, skillId)
  2297. ackMsg.Error = int32(bRet)
  2298. this.ReplayGate(ackMsg, true)
  2299. }
  2300. // 兑换高级技能经验
  2301. func (this *Role) ConverSkillExp(msg *serverproto.CSConverSkillExpReq) {
  2302. ackMsg := &serverproto.SCConverSkillExpAck{}
  2303. ackMsg.Error = int32(this.roleSkill.ConverSkillExp(msg.Cnt))
  2304. this.ReplayGate(ackMsg, true)
  2305. }
  2306. func (this *Role) ResetSkillLevel(heroId int32, bsuper bool) {
  2307. if this.roleHero == nil {
  2308. return
  2309. }
  2310. heroData := this.roleHero.GetHero(heroId)
  2311. if heroData == nil {
  2312. return
  2313. }
  2314. ackMsg := &serverproto.SCResetSkillLevelAck{
  2315. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2316. HeroId: heroId,
  2317. }
  2318. bRet := this.roleSkill.ResetSkillLevel(heroId, bsuper)
  2319. ackMsg.Error = int32(bRet)
  2320. ackMsg.ResetCount = this.GetRoleBase().RoleData().SkillResetCount
  2321. this.ReplayGate(ackMsg, true)
  2322. }
  2323. // /card 相关
  2324. func (this *Role) FashionUp(fashionCfgIdList []int32) {
  2325. if this.roleFashion != nil {
  2326. ackMsg := &serverproto.SCFashionUpAck{}
  2327. for _, data := range fashionCfgIdList {
  2328. if ret := this.roleFashion.FashionUp(data); ret == serverproto.ErrorCode_ERROR_OK {
  2329. ackMsg.Error = int32(ret)
  2330. }
  2331. }
  2332. this.roleFashion.SetFashion()
  2333. this.ReplayGate(ackMsg, true)
  2334. }
  2335. }
  2336. func (this *Role) FashionDown(fashionCfgIdList []int32) {
  2337. if this.roleFashion != nil {
  2338. ackMsg := &serverproto.SCFashionDownAck{}
  2339. for _, data := range fashionCfgIdList {
  2340. if ret := this.roleFashion.FashionDown(data); ret == serverproto.ErrorCode_ERROR_OK {
  2341. ackMsg.Error = int32(ret)
  2342. }
  2343. }
  2344. this.roleFashion.SetFashion()
  2345. this.ReplayGate(ackMsg, true)
  2346. }
  2347. }
  2348. func (this *Role) FashionCompose(paperCfgId int32) {
  2349. if this.roleFashion != nil {
  2350. ret := this.roleFashion.FashionCompose(paperCfgId)
  2351. this.ReplayGate(&serverproto.SCFashionComposeAck{Error: int32(ret)}, true)
  2352. }
  2353. }
  2354. func (this *Role) FashionPaperDecompose(paperCfgId int32) {
  2355. if this.roleFashion != nil {
  2356. ret := this.roleFashion.FashionPaperDecompose(paperCfgId)
  2357. if ret != serverproto.ErrorCode_ERROR_OK {
  2358. this.ReplayGate(&serverproto.SCFashionPaperDecomposeAck{Error: int32(ret)}, true)
  2359. }
  2360. }
  2361. }
  2362. func (this *Role) FashionResetAttr(fashionId int32, enter bool) {
  2363. if this.roleFashion == nil {
  2364. return
  2365. }
  2366. ret, _ := this.roleFashion.FashionResetAttr(fashionId, enter)
  2367. this.roleFashion.FashionChangeNtf([]int32{fashionId})
  2368. this.ReplayGate(&serverproto.SCFashionResetAttrAck{Error: int32(ret)}, true)
  2369. }
  2370. func (this *Role) FashionUpLvl(fashionId int32) {
  2371. if this.roleFashion == nil {
  2372. return
  2373. }
  2374. ret := this.roleFashion.FashionUpLvl(fashionId)
  2375. this.roleFashion.FashionChangeNtf([]int32{fashionId})
  2376. this.ReplayGate(&serverproto.SCFashionUpLvlAck{Error: int32(ret)}, true)
  2377. }
  2378. func (this *Role) BuyItem(shopId, goodsId, goodsNum int32) {
  2379. ackMsg := &serverproto.SCShopBuyItemAck{
  2380. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2381. GoodsType: shopId,
  2382. GoodsId: goodsId,
  2383. }
  2384. if this.roleBag != nil && goodsNum > 0 {
  2385. bRet, buyTime, buyNum := this.roleShop.BuyItem(shopId, goodsId, goodsNum, ackMsg)
  2386. ackMsg.Error = int32(bRet)
  2387. ackMsg.CurNum = buyNum
  2388. ackMsg.CurBuyTime = buyTime
  2389. }
  2390. this.ReplayGate(ackMsg, true)
  2391. }
  2392. func (this *Role) ShopInfoReq(goodsType int32) {
  2393. ackMsg := &serverproto.SCShopInfoAck{
  2394. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2395. }
  2396. if this.roleBag != nil {
  2397. shopTypeData, ok := serverproto.ShopTypeCfgLoader[goodsType]
  2398. if ok {
  2399. if shopTypeData.ShopType == 2 {
  2400. bRet := this.roleShop.GetSpecialShopInfo(goodsType, ackMsg)
  2401. ackMsg.Error = int32(bRet)
  2402. } else {
  2403. bRet := this.roleShop.GetShopInfo(goodsType, ackMsg)
  2404. ackMsg.Error = int32(bRet)
  2405. }
  2406. }
  2407. }
  2408. util.DebugF("send ackMsg msg=%v", ackMsg)
  2409. this.ReplayGate(ackMsg, true)
  2410. }
  2411. func (this *Role) ShopRefresh(goodsType int32) {
  2412. ackMsg := &serverproto.SCShopRefreshAck{
  2413. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2414. }
  2415. if this.roleBag != nil {
  2416. bRet := this.roleShop.HandleSpecialShopRefresh(goodsType, ackMsg)
  2417. ackMsg.Error = int32(bRet)
  2418. }
  2419. this.ReplayGate(ackMsg, true)
  2420. }
  2421. func (this *Role) RedBagShopExchange() {
  2422. ackMsg := &serverproto.SCRedBagExchangeAck{
  2423. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2424. }
  2425. if this.roleBag != nil {
  2426. bRet := this.roleShop.ExchangeRedBagTicket(ackMsg)
  2427. ackMsg.Error = int32(bRet)
  2428. }
  2429. this.ReplayGate(ackMsg, true)
  2430. }
  2431. // /social相关
  2432. func (this *Role) playerSocialOnline() {
  2433. ntfMsg := &serverproto.SSPlayerOnlineNtf{
  2434. BriefInfo: &serverproto.PlayerBriefInfo{
  2435. Uid: this.GetUUid(),
  2436. NickName: this.GetRoleBase().roleBase.NickName,
  2437. },
  2438. }
  2439. ntfMsg.ServiceNode = service.GetLocalServiceID()
  2440. this.SendAllSocial(ntfMsg)
  2441. }
  2442. func (this *Role) playerSocialOffline() {
  2443. ntfMsg := &serverproto.SSPlayerOfflineNtf{
  2444. Uid: this.GetUUid(),
  2445. }
  2446. this.SendAllSocial(ntfMsg)
  2447. }
  2448. func (this *Role) playerGuildOnline(changeType int32) {
  2449. ntfMsg := &serverproto.SSPlayerStateChangeNtf{
  2450. Uid: this.GetUUid(),
  2451. GuildId: this.GetRoleGuildId(),
  2452. ChangeType: changeType,
  2453. DemonFightTime: this.GetRoleGuild().GetDemonFightTime(),
  2454. }
  2455. if changeType == 2 {
  2456. ntfMsg.DemonFightTime = 0
  2457. }
  2458. this.SendGuild(ntfMsg)
  2459. }
  2460. func (this *Role) PlayerBattleBossOffline() {
  2461. if this.roleMap.ChallengeBossId > 0 {
  2462. ntfMsg := &serverproto.SSPlayerOfflineNtf{
  2463. Uid: this.GetUUid(),
  2464. }
  2465. this.SendBattleBoss(ntfMsg)
  2466. this.roleMap.ChallengeBossId = 0
  2467. }
  2468. }
  2469. func (this *Role) playerMapOffline() {
  2470. if this.roleCross != nil {
  2471. this.roleCross.PlayerLeave(nil)
  2472. }
  2473. }
  2474. func (this *Role) playerBattleOffline() {
  2475. if this.roleBattle != nil {
  2476. this.roleBattle.FastBattleTimeOffline()
  2477. }
  2478. }
  2479. func (this *Role) SetMapRank(selfRank, totalRanks uint32, topRankList []*serverproto.RankPlayerInfo, addSystemMsg bool) {
  2480. if this.roleBattle != nil {
  2481. this.roleBattle.SetMapRank(selfRank, totalRanks, topRankList, addSystemMsg)
  2482. }
  2483. }
  2484. func (this *Role) GetMapRank() {
  2485. if this.roleBattle != nil {
  2486. this.roleBattle.GetMapRank()
  2487. }
  2488. }
  2489. func (this *Role) GetQuickBattleReward() {
  2490. if this.roleBattle != nil {
  2491. this.roleBattle.GetQuickBattleReward()
  2492. }
  2493. }
  2494. // chat
  2495. func (this *Role) CheckChatInvalid(targetId uint64, msgType int32, msg *serverproto.CSChatMessageReq) bool {
  2496. if this.roleChat != nil {
  2497. ret := this.roleChat.CheckChatInvalid(targetId, msgType, msg)
  2498. if ret != serverproto.ErrorCode_ERROR_OK {
  2499. ackMsg := &serverproto.SCChatMessageAck{
  2500. Error: int32(ret),
  2501. }
  2502. this.ReplayGate(ackMsg, true)
  2503. return false
  2504. }
  2505. //发送消息
  2506. this.roleChat.SendMsg(targetId, msgType, msg, false)
  2507. }
  2508. return true
  2509. }
  2510. func (this *Role) GetOfflineMsg(targetId uint64) {
  2511. if this.roleChat != nil {
  2512. ret := this.roleChat.GetOfflineMsg(targetId)
  2513. if ret != serverproto.ErrorCode_ERROR_OK {
  2514. ackMsg := &serverproto.SCChatOfflineMsgAck{
  2515. Error: int32(ret),
  2516. }
  2517. this.ReplayGate(ackMsg, true)
  2518. }
  2519. }
  2520. }
  2521. // mail
  2522. // 添加邮件
  2523. type AddMailST struct {
  2524. ConfigId int32
  2525. MailType serverproto.MailType
  2526. ItemList map[int32]int32
  2527. ParamList []int32
  2528. Title string
  2529. Content string
  2530. }
  2531. func (this *Role) AddMail(configId int32, mailType serverproto.MailType, itemList map[int32]int32, paramList []int32, title, content string) {
  2532. if this.roleMail != nil {
  2533. this.roleMail.AddMail(configId, mailType, itemList, paramList, title, content)
  2534. }
  2535. }
  2536. func (this *Role) AddMailByST(st *AddMailST) {
  2537. if this.roleMail != nil {
  2538. this.roleMail.AddMail(st.ConfigId, st.MailType, st.ItemList, st.ParamList, st.Title, st.Content)
  2539. }
  2540. }
  2541. func (this *Role) AddMail1(configId int32, mailType int32, itemList []*serverproto.KeyValueType, paramList []int32, title, content string) {
  2542. if this.roleMail != nil {
  2543. this.roleMail.AddMail1(configId, serverproto.MailType(mailType), itemList, paramList,
  2544. title, content)
  2545. }
  2546. }
  2547. func (this *Role) GetMailIst() {
  2548. if this.roleMail != nil {
  2549. this.roleMail.GetMailList()
  2550. }
  2551. }
  2552. func (this *Role) MailRead(idList []int32) {
  2553. if this.roleMail != nil {
  2554. ret := this.roleMail.MailRead(idList)
  2555. ackMsg := &serverproto.SCMailReadAck{
  2556. Error: int32(ret),
  2557. }
  2558. this.ReplayGate(ackMsg, true)
  2559. }
  2560. }
  2561. func (this *Role) MailDelRead() {
  2562. if this.roleMail != nil {
  2563. ret := this.roleMail.MailDelRead()
  2564. ackMsg := &serverproto.SCMailDelReadAck{
  2565. Error: int32(ret),
  2566. }
  2567. this.ReplayGate(ackMsg, true)
  2568. }
  2569. }
  2570. func (this *Role) MailReward(idList []int32) {
  2571. if this.roleMail != nil {
  2572. ret := this.roleMail.MailReward(idList)
  2573. if ret != serverproto.ErrorCode_ERROR_OK {
  2574. ackMsg := &serverproto.SCMailRewardAck{
  2575. Error: int32(ret),
  2576. }
  2577. this.ReplayGate(ackMsg, true)
  2578. }
  2579. }
  2580. }
  2581. // 打包数据
  2582. func (this *Role) PackRoleViewInfo(info *serverproto.ViewRoleInfo) {
  2583. info.Id = this.uuid
  2584. info.Brief = &serverproto.CommonPlayerBriefInfo{
  2585. Uid: this.GetUUid(),
  2586. NickName: this.GetNickName(),
  2587. Gender: this.GetRoleBase().GetRoleSex(),
  2588. ImgId: this.GetImageId(),
  2589. FightPower: int32(this.GetRoleBase().RoleData().FightPower),
  2590. HeadFrameId: this.GetRoleBase().RoleData().HeadFrameId,
  2591. ConfigId: this.GetRoleBase().RoleData().HeroData.ConfigId,
  2592. VipLevel: this.GetRoleVipLevel(),
  2593. HeadId: this.GetHeadId(),
  2594. }
  2595. //这里也是有问题的,后续需要处理
  2596. info.AttrList = this.GetRoleHero().GetMainHero().AttrList
  2597. info.FashionData = this.GetRoleBase().roleBase.FashionData
  2598. info.DanScore = this.GetRoleArena().arenaInfo.Score
  2599. //世界boss,只上阵主角
  2600. info.RoleHero = this.GetRoleBase().RoleData().HeroData
  2601. info.Hero = &serverproto.RoleHero{}
  2602. for _, data := range this.GetRoleHero().heroList {
  2603. info.Hero.HeroData = append(info.Hero.HeroData, data)
  2604. }
  2605. info.Fashion = &serverproto.RoleFashion{}
  2606. //for _, data := range this.roleFashion.fashionData {
  2607. //info.Fashion.FashionList = append(info.Fashion.FashionList, data.id)
  2608. this.roleFashion.CopyData(info.Fashion)
  2609. //}
  2610. for _, data := range this.roleFashion.fashionData {
  2611. info.Fashion.FashionList = append(info.Fashion.FashionList, data.id)
  2612. }
  2613. if this.GetRoleGuild().roleGuild.GuildId != 0 {
  2614. info.GuildName = this.GetRoleGuild().roleGuild.GuildName
  2615. }
  2616. if this.GetRolePet() != nil {
  2617. if info.RoleHero.BattlePetId != 0 {
  2618. pet := this.GetRolePet().getPet(info.RoleHero.BattlePetId)
  2619. if pet != nil {
  2620. info.PetList = append(info.PetList, pet)
  2621. }
  2622. }
  2623. for _, hero := range info.Hero.HeroData {
  2624. if hero.BattlePetId != 0 {
  2625. pet := this.GetRolePet().getPet(hero.BattlePetId)
  2626. if pet != nil {
  2627. info.PetList = append(info.PetList, pet)
  2628. }
  2629. }
  2630. }
  2631. }
  2632. }
  2633. func (this *Role) GetSignUpInfo() {
  2634. ackMsg := &serverproto.SCSignUpInfoAck{
  2635. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2636. }
  2637. if this.roleActivity != nil {
  2638. //检查是否大周期重置
  2639. this.roleActivity.CheckNewCircle()
  2640. ackMsg.Error = int32(serverproto.ErrorCode_ERROR_OK)
  2641. ackMsg.SignInfo = this.roleActivity.signInfo
  2642. ackMsg.CurSignDay = this.roleActivity.GetCurSignDay()
  2643. ackMsg.NextSignTime = this.roleActivity.signInfo.CurSignInfo.LastSign
  2644. }
  2645. this.ReplayGate(ackMsg, true)
  2646. }
  2647. func (this *Role) OnSignUp() {
  2648. ackMsg := &serverproto.SCSignUpAck{
  2649. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2650. }
  2651. if this.roleActivity != nil {
  2652. bRet := this.roleActivity.SignUp(ackMsg)
  2653. ackMsg.Error = int32(bRet)
  2654. ackMsg.NextSignTime = int64(util.GetLatest5Hour())
  2655. ackMsg.SignInfo = this.roleActivity.signInfo
  2656. ackMsg.CurSignDay = this.roleActivity.GetCurSignDay()
  2657. }
  2658. this.ReplayGate(ackMsg, true)
  2659. }
  2660. // 强制引导
  2661. func (this *Role) CompulsoryGuidance(storyId, status int32) {
  2662. ackMsg := &serverproto.SCCompulsoryGuidanceAck{
  2663. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2664. }
  2665. if this.GetRoleBase() != nil {
  2666. //设置强制引导
  2667. nRet := this.GetRoleBase().SetCompulsoryId(storyId, status)
  2668. ackMsg.StoryId = storyId
  2669. ackMsg.Status = status
  2670. ackMsg.Error = int32(nRet)
  2671. }
  2672. this.ReplayGate(ackMsg, true)
  2673. }
  2674. // 爬塔功能信息
  2675. // 请求个人的爬塔信息
  2676. func (this *Role) ClimbingTowerInfoReq() {
  2677. if this.roleTower != nil {
  2678. this.roleTower.GetClimbingTowerInfo()
  2679. }
  2680. }
  2681. // 获取试炼馈赠
  2682. func (this *Role) GetTowerLevelDayReward() {
  2683. if this.roleTower != nil {
  2684. ret := this.roleTower.GetTowerLevelDayReward()
  2685. if ret != serverproto.ErrorCode_ERROR_OK {
  2686. ackMsg := &serverproto.SCClimbingTowerDayRewardAck{
  2687. Error: int32(ret),
  2688. }
  2689. this.ReplayGate(ackMsg, true)
  2690. }
  2691. }
  2692. }
  2693. // 查找好友数据
  2694. func (this *Role) GetFriendTowerInfo(begin, end int32) {
  2695. if this.roleTower != nil {
  2696. this.roleTower.GetFriendTowerRange(begin, end)
  2697. }
  2698. }
  2699. // 爬塔开始
  2700. func (this *Role) ClimbingTowerBegin(towerLevel int32) {
  2701. ackMsg := &serverproto.SCClimbingTowerBeginAck{
  2702. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2703. TowerLevel: towerLevel,
  2704. }
  2705. if this.roleTower != nil {
  2706. nRet, factorList := this.roleTower.OnTowerFightBegin(towerLevel)
  2707. ackMsg.Error = int32(nRet)
  2708. ackMsg.FactorList = factorList
  2709. }
  2710. this.ReplayGate(ackMsg, true)
  2711. }
  2712. // 爬塔结束
  2713. func (this *Role) ClimbingTowerEnd(towerLevel, loadingTime int32, recordTimeStamp uint64) {
  2714. ackMsg := &serverproto.SCClimbingTowerEndAck{
  2715. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2716. }
  2717. if this.roleTower != nil {
  2718. nRet := this.roleTower.OnTowerFightEnd(towerLevel, loadingTime, recordTimeStamp, ackMsg)
  2719. ackMsg.Error = int32(nRet)
  2720. //打包newTowerLevel=2的所有好友的数据
  2721. this.roleTower.PackFriendFightTower(towerLevel, ackMsg)
  2722. }
  2723. this.ReplayGate(ackMsg, true)
  2724. }
  2725. func (this *Role) GetFriendBriefFromDB(final bool, begin int32, end int32, briefs []*serverproto.CommonPlayerBriefInfo) {
  2726. if this.roleTower != nil {
  2727. this.roleTower.SetFriendBriefInfo(briefs)
  2728. //同时返回数据到客户端
  2729. if final == true {
  2730. this.roleTower.SendClimbingTowerInfo(begin, end)
  2731. }
  2732. }
  2733. }
  2734. func (this *Role) GetTowerFightCountReward(rushRound int32, rewardType int32) {
  2735. ackMsg := &serverproto.SCRushActivityRewardAck{
  2736. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2737. RewardType: rewardType,
  2738. RushType: model.Rush_Type_Tower,
  2739. }
  2740. if this.GetRoleTower() != nil {
  2741. nRet := this.GetRoleTower().GetRushTowerBaseReward(ackMsg, rushRound)
  2742. ackMsg.Error = int32(nRet)
  2743. }
  2744. this.ReplayGate(ackMsg, true)
  2745. }
  2746. func (this *Role) GetRushTowerInfo(ackMsg *serverproto.SCTowerActivityAck, curRushRound int32) {
  2747. if this.GetRoleTower() != nil {
  2748. this.GetRoleTower().GetRushTowerInfo(ackMsg, curRushRound)
  2749. }
  2750. }
  2751. func (this *Role) GetRushTowerRankReward(ssAck *serverproto.SSGetRushRewardAck) {
  2752. ackMsg := &serverproto.SCRushActivityRewardAck{
  2753. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2754. RewardType: model.Rush_Reward_Type_Rank,
  2755. RushType: model.Rush_Type_Tower,
  2756. }
  2757. if this.GetRoleTower() != nil {
  2758. nRet := this.GetRoleTower().GetRushTowerRankReward(ssAck)
  2759. if nRet == serverproto.ErrorCode_ERROR_OK {
  2760. ackMsg.ItemList = ssAck.ItemList
  2761. }
  2762. ackMsg.Error = int32(nRet)
  2763. }
  2764. this.ReplayGate(ackMsg, true)
  2765. }
  2766. // 英灵殿冲榜
  2767. func (this *Role) GetArenaFightCountReward(rushRound int32, rewardType int32) {
  2768. ackMsg := &serverproto.SCRushActivityRewardAck{
  2769. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2770. RewardType: rewardType,
  2771. RushType: model.Rush_Type_Arena,
  2772. }
  2773. if this.GetRoleArena() != nil {
  2774. nRet := this.GetRoleArena().GetRushArenaBaseReward(ackMsg, rushRound)
  2775. ackMsg.Error = int32(nRet)
  2776. }
  2777. this.ReplayGate(ackMsg, true)
  2778. }
  2779. func (this *Role) GetRushArenaInfo(ackMsg *serverproto.SCArenaActivityAck, curRushRound int32) {
  2780. if this.GetRoleArena() != nil {
  2781. this.GetRoleArena().GetRushArenaInfo(ackMsg, curRushRound)
  2782. }
  2783. }
  2784. func (this *Role) GetRushArenaRankReward(ssAck *serverproto.SSGetRushRewardAck) {
  2785. ackMsg := &serverproto.SCRushActivityRewardAck{
  2786. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2787. RewardType: model.Rush_Reward_Type_Rank,
  2788. RushType: model.Rush_Type_Arena,
  2789. }
  2790. if this.GetRoleArena() != nil {
  2791. nRet := this.GetRoleArena().GetRushArenaRankReward(ssAck)
  2792. if nRet == serverproto.ErrorCode_ERROR_OK {
  2793. ackMsg.ItemList = ssAck.ItemList
  2794. }
  2795. ackMsg.Error = int32(nRet)
  2796. }
  2797. this.ReplayGate(ackMsg, true)
  2798. }
  2799. // 宠物冲榜
  2800. func (this *Role) GetPetFightCountReward(rushRound int32, rewardType int32) {
  2801. ackMsg := &serverproto.SCRushActivityRewardAck{
  2802. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2803. RewardType: rewardType,
  2804. RushType: model.Rush_Type_Pet,
  2805. }
  2806. if this.GetRolePet() != nil {
  2807. nRet := this.GetRolePet().GetBaseScoreReward(ackMsg, rushRound)
  2808. ackMsg.Error = int32(nRet)
  2809. }
  2810. this.ReplayGate(ackMsg, true)
  2811. }
  2812. func (this *Role) GetRushPetRankReward(ssAck *serverproto.SSGetRushRewardAck) {
  2813. ackMsg := &serverproto.SCRushActivityRewardAck{
  2814. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2815. RewardType: model.Rush_Reward_Type_Rank,
  2816. RushType: model.Rush_Type_Pet,
  2817. }
  2818. if this.GetRolePet() != nil {
  2819. nRet := this.GetRolePet().GetRushPetRankReward(ssAck)
  2820. if nRet == serverproto.ErrorCode_ERROR_OK {
  2821. ackMsg.ItemList = ssAck.ItemList
  2822. }
  2823. ackMsg.Error = int32(nRet)
  2824. }
  2825. this.ReplayGate(ackMsg, true)
  2826. }
  2827. func (this *Role) GetRushPetInfo(ackMsg *serverproto.SCPetActivityAck, curRushRound int32) {
  2828. if this.GetRolePet() != nil {
  2829. this.GetRolePet().GetRushPetInfo(ackMsg, curRushRound)
  2830. }
  2831. }
  2832. // 英灵殿冲榜
  2833. func (this *Role) GetFightCountReward(rushRound int32, rushType int32, rewardType int32) {
  2834. ackMsg := &serverproto.SCRushActivityRewardAck{
  2835. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2836. RewardType: rewardType,
  2837. RushType: rushType,
  2838. }
  2839. if this.GetRoleRush() != nil {
  2840. nRet := this.GetRoleRush().GetBaseReward(ackMsg, rushType, rushRound)
  2841. ackMsg.Error = int32(nRet)
  2842. }
  2843. this.ReplayGate(ackMsg, true)
  2844. }
  2845. func (this *Role) GetRushInfo(ackMsg *serverproto.SCRushActivityAck, curRushRound int32) {
  2846. if this.GetRoleRush() != nil {
  2847. this.GetRoleRush().GetRushInfo(ackMsg, curRushRound)
  2848. }
  2849. }
  2850. func (this *Role) GetRushRankReward(ssAck *serverproto.SSGetRushRewardAck) {
  2851. ackMsg := &serverproto.SCRushActivityRewardAck{
  2852. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2853. RewardType: model.Rush_Reward_Type_Rank,
  2854. RushType: ssAck.RushType,
  2855. }
  2856. if this.GetRoleRush() != nil {
  2857. nRet := this.GetRoleRush().GetRushRankReward(ssAck)
  2858. if nRet == serverproto.ErrorCode_ERROR_OK {
  2859. ackMsg.ItemList = ssAck.ItemList
  2860. }
  2861. ackMsg.Error = int32(nRet)
  2862. }
  2863. this.ReplayGate(ackMsg, true)
  2864. }
  2865. //1:bossReward 2:pvp
  2866. func (this *Role) GetBattleRecord(recordType int32, paramList []uint32) {
  2867. if len(paramList) <= 0 {
  2868. ackMsg := &serverproto.SCPlayerBattleRecordAck{
  2869. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  2870. }
  2871. this.ReplayGate(ackMsg, true)
  2872. return
  2873. }
  2874. msgReq := &serverproto.CSPlayerBattleRecordReq{
  2875. RecordType: recordType,
  2876. ParamList: paramList,
  2877. }
  2878. this.SendRank(msgReq)
  2879. }
  2880. func (this *Role) OnGetBattleRecordAck(ssMsg *serverproto.SCPlayerBattleRecordAck) {
  2881. ackMsg := &serverproto.SCPlayerBattleRecordAck{}
  2882. for idx := 0; idx < len(ssMsg.RecordList); idx++ {
  2883. levelCfgData, ok := serverproto.LevelCfgLoader[ssMsg.RecordList[idx].MapLevelId]
  2884. if !ok || levelCfgData.Version > ssMsg.RecordList[idx].BattleVersion {
  2885. continue
  2886. }
  2887. ackMsg.RecordList = append(ackMsg.RecordList, ssMsg.RecordList[idx])
  2888. }
  2889. this.ReplayGate(ackMsg, true)
  2890. }
  2891. // //////////////////////////// 公会功能 //////////////////////////////////////
  2892. // 创建工会
  2893. func (this *Role) CheckBuildGuild(guildName string, guildBadge int32) serverproto.ErrorCode {
  2894. //检查是否有公会,有就据掉,没有就转GuildServer
  2895. bRet := this.GetRoleGuild().CanBuildGuild(guildName)
  2896. if bRet != serverproto.ErrorCode_ERROR_OK { //有工会不能创建
  2897. ackMsg := &serverproto.SCBuildGuildAck{
  2898. Error: int32(bRet),
  2899. }
  2900. this.ReplayGate(ackMsg, true)
  2901. return bRet
  2902. }
  2903. return serverproto.ErrorCode_ERROR_OK
  2904. }
  2905. func (this *Role) CheckApplyGuild(guildId uint64) bool {
  2906. //检查是否有公会,有就据掉,没有就转GuildServer
  2907. //检查是否在被拒绝列表中
  2908. bRet := this.GetRoleGuild().CheckApply(guildId)
  2909. if bRet != serverproto.ErrorCode_ERROR_OK {
  2910. ackMsg := &serverproto.SCApplyGuildAck{
  2911. Error: int32(bRet),
  2912. }
  2913. this.ReplayGate(ackMsg, true)
  2914. return false
  2915. }
  2916. return true
  2917. }
  2918. // 申请处理
  2919. func (this *Role) CheckApplyInfo(msg *serverproto.CSApplyInfoHandleReq) serverproto.ErrorCode {
  2920. if this.GetRoleGuild().roleGuild.GuildId == 0 {
  2921. ackMsg := &serverproto.SCApplyInfoHandleAck{
  2922. Error: int32(serverproto.ErrorCode_ERROR_GUILD_NOT_IN_GUILD),
  2923. }
  2924. this.ReplayGate(ackMsg, true)
  2925. return serverproto.ErrorCode_ERROR_GUILD_NOT_IN_GUILD
  2926. }
  2927. return serverproto.ErrorCode_ERROR_OK
  2928. }
  2929. func (this *Role) CheckGuildModifyInfo(msg *serverproto.CSSetGuildInfoReq) serverproto.ErrorCode {
  2930. if this.GetRoleGuildId() == 0 {
  2931. return serverproto.ErrorCode_ERROR_GUILD_NOT_IN_GUILD
  2932. }
  2933. //公告长度
  2934. lenData, ok1 := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Guild_Recruit_Max_Len)]
  2935. if !ok1 {
  2936. return serverproto.ErrorCode_ERROR_FAIL
  2937. }
  2938. noticeLen := utf8.RuneCountInString(msg.RecruitNotice)
  2939. if int32(noticeLen) > lenData.IVal {
  2940. return serverproto.ErrorCode_ERROR_GUILD_NOTICE_LEN
  2941. }
  2942. //检查敏感字
  2943. bSensitive := SensitiveUtil.IsMatch(msg.RecruitNotice)
  2944. if bSensitive == true {
  2945. return serverproto.ErrorCode_ERROR_GUILD_NAME_SENSITIVE
  2946. }
  2947. //校验徽章是否存在,
  2948. _, ok := serverproto.GuildBadgeCfgLoader[msg.GuildBadge]
  2949. if ok == false {
  2950. return serverproto.ErrorCode_ERROR_GUILD_CONFIG_NOT_FOUND
  2951. }
  2952. //校验入会等级是否合理
  2953. globalData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Guild_Apply_Level)]
  2954. if !ok {
  2955. return serverproto.ErrorCode_ERROR_GUILD_CONFIG_NOT_FOUND
  2956. }
  2957. levelRes := strings.Split(globalData.SVal, ":")
  2958. if len(levelRes) >= 2 {
  2959. minLevel, _ := model.Str2Num(levelRes[0])
  2960. maxLevel, _ := model.Str2Num(levelRes[1])
  2961. if int32(minLevel) > msg.JoinLevel || msg.JoinLevel > int32(maxLevel) {
  2962. return serverproto.ErrorCode_ERROR_GUILD_OUT_APPLY_LEVEL
  2963. }
  2964. }
  2965. return serverproto.ErrorCode_ERROR_OK
  2966. }
  2967. func (this *Role) CheckGuildRename(guildName string) serverproto.ErrorCode {
  2968. if this.GetRoleGuildId() == 0 {
  2969. return serverproto.ErrorCode_ERROR_GUILD_NOT_IN_GUILD
  2970. }
  2971. nameLen := utf8.RuneCountInString(guildName)
  2972. if int32(nameLen) < model.GlobalGuildMinNameStringLen || int32(nameLen) > model.GlobalGuildMaxNameStringLen {
  2973. return serverproto.ErrorCode_ERROR_GUILD_NAME_LEN
  2974. }
  2975. //检查敏感字
  2976. bSensitive := SensitiveUtil.IsMatch(guildName)
  2977. if bSensitive == true {
  2978. return serverproto.ErrorCode_ERROR_GUILD_NAME_SENSITIVE
  2979. }
  2980. //校验消耗
  2981. globalData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Guild_Rename_Cost)]
  2982. if !ok {
  2983. return serverproto.ErrorCode_ERROR_GUILD_CONFIG_NOT_FOUND
  2984. }
  2985. var costItemList = map[int32]int32{}
  2986. costRes := strings.Split(globalData.SVal, ":")
  2987. if len(costRes) >= 2 {
  2988. itemId, _ := model.Str2Num(costRes[0])
  2989. itemNum, _ := model.Str2Num(costRes[1])
  2990. costItemList[int32(itemId)] += int32(itemNum)
  2991. }
  2992. bRet := this.CheckResLitNum(costItemList)
  2993. if bRet == false {
  2994. return serverproto.ErrorCode_ERROR_RES_NOT_ENOUGH
  2995. }
  2996. return serverproto.ErrorCode_ERROR_OK
  2997. }
  2998. func (this *Role) CheckGuildRenotice(notice string) serverproto.ErrorCode {
  2999. globalData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Guild_Notice_Max_Len)]
  3000. if !ok {
  3001. return serverproto.ErrorCode_ERROR_FAIL
  3002. }
  3003. if this.GetRoleGuildId() == 0 {
  3004. return serverproto.ErrorCode_ERROR_GUILD_NOT_IN_GUILD
  3005. }
  3006. //检查敏感字
  3007. bSensitive := SensitiveUtil.IsMatch(notice)
  3008. if bSensitive == true {
  3009. return serverproto.ErrorCode_ERROR_GUILD_NAME_SENSITIVE
  3010. }
  3011. noticeLen := utf8.RuneCountInString(notice)
  3012. if int32(noticeLen) > globalData.IVal {
  3013. return serverproto.ErrorCode_ERROR_GUILD_NOTICE_LEN
  3014. }
  3015. return serverproto.ErrorCode_ERROR_OK
  3016. }
  3017. func (this *Role) CheckGuildBossChallenge(bossId uint32, damage uint32, fightTime uint32) serverproto.ErrorCode {
  3018. //检查是否有公会,
  3019. guildId := this.GetRoleGuildId()
  3020. if guildId == 0 {
  3021. return serverproto.ErrorCode_ERROR_GUILD_NOT_IN_GUILD
  3022. }
  3023. bRet := this.GetRoleGuild().CheckBossFight(bossId, damage, fightTime)
  3024. return bRet
  3025. }
  3026. func (this *Role) OnChangeGuileNameSuccess() {
  3027. //扣除消耗
  3028. globalData, ok := serverproto.GlobalCfgLoader[int32(serverproto.GlobalType_Global_Guild_Rename_Cost)]
  3029. if !ok {
  3030. return
  3031. }
  3032. var costItemList = map[int32]int32{}
  3033. costRes := strings.Split(globalData.SVal, ":")
  3034. if len(costRes) >= 2 {
  3035. itemId, _ := model.Str2Num(costRes[0])
  3036. itemNum, _ := model.Str2Num(costRes[1])
  3037. costItemList[int32(itemId)] += int32(itemNum)
  3038. }
  3039. bRet := this.CheckResLitNum(costItemList)
  3040. if bRet == false {
  3041. return
  3042. }
  3043. this.DelItemList(costItemList, AddItemST{AddFrom: AddFrom_Guild})
  3044. }
  3045. func (this *Role) GetRoleGuildId() uint64 {
  3046. if this.GetRoleGuild() == nil {
  3047. return 0
  3048. }
  3049. return this.GetRoleGuild().roleGuild.GuildId
  3050. }
  3051. func (this *Role) GuildDemonBuyFightCount(buyCount int32) {
  3052. if this.GetRoleGuild() != nil {
  3053. ackMsg := &serverproto.SCGuildDemonBuyFightCountAck{}
  3054. err, leftUseCount, leftBuyCount := this.GetRoleGuild().BuyDemonFightCount(buyCount)
  3055. ackMsg.Error = int32(err)
  3056. ackMsg.LeftFightCount = leftUseCount
  3057. ackMsg.LeftBuyCount = leftBuyCount
  3058. this.ReplayGate(ackMsg, true)
  3059. }
  3060. }
  3061. func (this *Role) GetRoleVipLevel() int32 {
  3062. if this.GetRoleBase() != nil {
  3063. return this.GetRoleBase().roleBase.VipLevel
  3064. }
  3065. return 0
  3066. }
  3067. func (this *Role) GetHeadId() int32 {
  3068. if this.roleHead != nil {
  3069. return this.roleHead.GetHeadIdIng()
  3070. }
  3071. return 0
  3072. }
  3073. func (this *Role) GetHeadMag() *RoleHead {
  3074. return this.roleHead
  3075. }
  3076. func (this *Role) OnDrawReq(drawType int32, drawCount int32) {
  3077. ackMsg := &serverproto.SCDrawCardAck{
  3078. DrawType: drawType,
  3079. DrawCount: drawCount,
  3080. }
  3081. if this.roleDraw != nil {
  3082. bRet := this.GetRoleDraw().DrawReq(drawType, drawCount, ackMsg)
  3083. ackMsg.Error = int32(bRet)
  3084. }
  3085. this.ReplayGate(ackMsg, true)
  3086. }
  3087. func (this *Role) CheckRushShopInfoGet(goodsType, goodsId, count int32) bool {
  3088. reqMsg := &serverproto.SSGetRushShopBuyReq{}
  3089. switch (serverproto.PayGoodsType)(goodsType) {
  3090. case serverproto.PayGoodsType_EPayType_RushTower:
  3091. reqMsg.RushType = model.Rush_Type_Tower
  3092. case serverproto.PayGoodsType_EPayType_RushArena:
  3093. reqMsg.RushType = model.Rush_Type_Arena
  3094. case serverproto.PayGoodsType_EPayType_RushMap:
  3095. reqMsg.RushType = model.Rush_Type_Map
  3096. case serverproto.PayGoodsType_EPayType_RushPet:
  3097. reqMsg.RushType = model.Rush_Type_Pet
  3098. case serverproto.PayGoodsType_EPayType_RushSkill:
  3099. reqMsg.RushType = model.Rush_Type_Skill
  3100. default:
  3101. return false
  3102. }
  3103. reqMsg.Uid = this.GetUUid()
  3104. reqMsg.ShopType = goodsType
  3105. reqMsg.GoodsId = goodsId
  3106. reqMsg.GoodsNum = count
  3107. this.SendRank(reqMsg)
  3108. return true
  3109. }
  3110. func (this *Role) PayInfoGet(goodsType, goodsId, count int32, rushStage, rushRound int32) {
  3111. //合服期间,无法进行飞艇探索
  3112. if goodsType == int32(serverproto.PayGoodsType_EPayType_RuneExplore) {
  3113. bRet := this.CheckInCombinedService()
  3114. if bRet == true {
  3115. ackMsg := &serverproto.SCPayInfoGetAck{
  3116. Error: int32(serverproto.ErrorCode_ERROR_RUNE_EXPLORE_ON_COMBINE_SERVER),
  3117. GoodsType: goodsType,
  3118. GoodsId: goodsId,
  3119. Count: count,
  3120. }
  3121. this.ReplayGate(ackMsg, true)
  3122. return
  3123. }
  3124. }
  3125. ret, payOrderInfo := this.payInfoGet(goodsType, goodsId, count, rushStage, rushRound)
  3126. ackMsg := &serverproto.SCPayInfoGetAck{
  3127. Error: int32(ret),
  3128. GoodsType: goodsType,
  3129. GoodsId: goodsId,
  3130. Count: count,
  3131. }
  3132. if ret == serverproto.ErrorCode_ERROR_OK {
  3133. // 如果是免费或者价格为0时直接购买成功
  3134. if payOrderInfo.Amount <= 0 {
  3135. ntfMsg := &serverproto.SCPayForGoodsNtf{}
  3136. ntfMsg.GoodsId = goodsId
  3137. ntfMsg.ItemList = payOrderInfo.RewardList
  3138. ntfMsg.GoodsType = goodsType
  3139. ntfMsg.GoodsNum = count
  3140. ntfMsg.CpOrderId = 0
  3141. ackMsg.Error = int32(serverproto.ErrorCode_ERROR_PAY_GOOD_PRICE_FREE)
  3142. this.ReplayGate(ackMsg, true)
  3143. this.ReplayGate(ntfMsg, true)
  3144. util.InfoF("uid=%v free: shop:%v id:%v, count:%v", this.GetUUid(), payOrderInfo.GoodsType, payOrderInfo.GoodsId, payOrderInfo.Count)
  3145. return
  3146. }
  3147. // 按照配置比例获取RO币
  3148. if model.GlobalRoCoinFactor > 0 {
  3149. tmpRoCoin := payOrderInfo.Amount * model.GlobalRoCoinFactor
  3150. payOrderInfo.RewardList = append(payOrderInfo.RewardList, &serverproto.KeyValueType{
  3151. Key: int32(serverproto.ResType_Res_ROCoin),
  3152. Value: int32(tmpRoCoin),
  3153. })
  3154. }
  3155. //给VIP经验
  3156. if model.GlobalRMBToVipExpRMB > 0 {
  3157. vipExp := payOrderInfo.Amount * float32(model.GlobalRMBToVipExpVip) / float32(model.GlobalRMBToVipExpRMB)
  3158. payOrderInfo.RewardList = append(payOrderInfo.RewardList, &serverproto.KeyValueType{
  3159. Key: int32(serverproto.ResType_Res_VipExp),
  3160. Value: int32(vipExp),
  3161. })
  3162. //this.role.AddRes(int32(serverproto.ResType_Res_VipExp), AddItemST{ItemCount: int32(vipExp)}, true)
  3163. }
  3164. if service.GetServiceConfig().Node.AuthMode == AUTHMODE_PC {
  3165. //内网PC模式下直接购买成功
  3166. ackMsg.Error = int32(serverproto.ErrorCode_ERROR_PAY_PRODUCTION_MODE)
  3167. this.ReplayGate(ackMsg, true)
  3168. this.OnPayCallback(payOrderInfo, false, false)
  3169. util.InfoF("uid=%v pc mode: shop:%v id:%v, count:%v, price:%v", this.GetUUid(), payOrderInfo.GoodsType, payOrderInfo.GoodsId, payOrderInfo.Count, payOrderInfo.Amount)
  3170. return
  3171. } else if service.GetServiceConfig().Node.AuthMode == AUTHMODE_ACTIVE {
  3172. //激活码模式下提示充值功能未开放
  3173. ackMsg.Error = int32(serverproto.ErrorCode_ERROR_PAY_NOT_OPEN)
  3174. this.ReplayGate(ackMsg, true)
  3175. util.InfoF("uid=%v pc mode: shop:%v id:%v, count:%v, price:%v", this.GetUUid(), payOrderInfo.GoodsType, payOrderInfo.GoodsId, payOrderInfo.Count, payOrderInfo.Amount)
  3176. return
  3177. }
  3178. //保存订单信息到数据库
  3179. ackMsg.Amount = payOrderInfo.Amount
  3180. ackMsg.CpOrderId = payOrderInfo.CpOrderId
  3181. ackMsg.GoodsName = payOrderInfo.GoodsName
  3182. ssSaveReqMsg := &serverproto.SSPayInfoSaveReq{
  3183. PayOrderInfo: payOrderInfo,
  3184. SaveNotify: true,
  3185. }
  3186. this.SendDb(ssSaveReqMsg)
  3187. } else {
  3188. this.ReplayGate(ackMsg, true)
  3189. }
  3190. }
  3191. func (this *Role) payInfoGet(goodsType, goodsId, count int32, rushStage, rushRound int32) (serverproto.ErrorCode, *serverproto.PayOrderSaveInfo) {
  3192. if count <= 0 {
  3193. return serverproto.ErrorCode_ERROR_PAY_ITEM_NO, nil
  3194. }
  3195. payRewardInfo := &serverproto.PayOrderSaveInfo{
  3196. OrderState: int32(serverproto.PayOrderState_EPayOrderState_Gen),
  3197. GoodsId: goodsId,
  3198. GoodsType: goodsType,
  3199. //早期uid生成规则修改过一次,老的uid无法通过uid来获取到zoneid
  3200. CpOrderId: model.GenerateUidByZone(int(this.GetSelectZone())),
  3201. Uid: this.GetUUid(),
  3202. OrderProcessTime: util.GetTimeMilliseconds(),
  3203. SId: int32(service.GetServiceConfig().Node.Zone),
  3204. }
  3205. // 根据goodsType查找对应系统物品是否存在,并获得价格,物品
  3206. // for test
  3207. //payRewardInfo.Count = count
  3208. //payRewardInfo.Amount = 1
  3209. //payRewardInfo.GoodsName = "testgoods"
  3210. //payRewardInfo.RewardList = append(payRewardInfo.RewardList, &serverproto.KeyValueType{Key: 1, Value: 1000})
  3211. switch (serverproto.PayGoodsType)(goodsType) {
  3212. case serverproto.PayGoodsType_EPayType_Discount: //超值礼包购买
  3213. if !this.roleActivity.PayInfoGetDiscount(payRewardInfo) {
  3214. return serverproto.ErrorCode_ERROR_PAY_ITEM_NO, nil
  3215. }
  3216. case serverproto.PayGoodsType_EPayType_MonthCard:
  3217. bRet := this.roleRune.BuyMonthCardShopItem(payRewardInfo)
  3218. if bRet != serverproto.ErrorCode_ERROR_OK {
  3219. return bRet, nil
  3220. }
  3221. case serverproto.PayGoodsType_EPayType_NormalBag:
  3222. bRet := this.roleRune.BuyBagShopItem(payRewardInfo)
  3223. if bRet != serverproto.ErrorCode_ERROR_OK {
  3224. return bRet, nil
  3225. }
  3226. case serverproto.PayGoodsType_EPayType_LimitBag:
  3227. bRet := this.roleRune.BuyLimitShopItem(payRewardInfo)
  3228. if bRet != serverproto.ErrorCode_ERROR_OK {
  3229. return bRet, nil
  3230. }
  3231. case serverproto.PayGoodsType_EPayType_RushTower:
  3232. bRet := this.roleRune.BuyRushTowerShopItem(payRewardInfo, rushStage, rushRound)
  3233. if bRet != serverproto.ErrorCode_ERROR_OK {
  3234. return bRet, nil
  3235. }
  3236. case serverproto.PayGoodsType_EPayType_RushArena:
  3237. bRet := this.roleRune.BuyRushArenaShopItem(payRewardInfo, rushStage, rushRound)
  3238. if bRet != serverproto.ErrorCode_ERROR_OK {
  3239. return bRet, nil
  3240. }
  3241. case serverproto.PayGoodsType_EPayType_RushMap:
  3242. bRet := this.roleRune.BuyRushMapShopItem(payRewardInfo, rushStage, rushRound)
  3243. if bRet != serverproto.ErrorCode_ERROR_OK {
  3244. return bRet, nil
  3245. }
  3246. case serverproto.PayGoodsType_EPayType_GuildBattle:
  3247. bRet := this.roleRune.BuyGuildBattleShopItem(payRewardInfo)
  3248. if bRet != serverproto.ErrorCode_ERROR_OK {
  3249. return bRet, nil
  3250. }
  3251. case serverproto.PayGoodsType_EPayType_RuneExplore:
  3252. bRet := this.roleRune.BuyRuneExplore(payRewardInfo)
  3253. if bRet != serverproto.ErrorCode_ERROR_OK {
  3254. return bRet, nil
  3255. }
  3256. case serverproto.PayGoodsType_EPayType_RushPet:
  3257. bRet := this.roleRune.BuyRushPetShopItem(payRewardInfo, rushStage, rushRound)
  3258. if bRet != serverproto.ErrorCode_ERROR_OK {
  3259. return bRet, nil
  3260. }
  3261. case serverproto.PayGoodsType_EPayType_RushSkill:
  3262. bRet := this.roleRune.BuyRushSkillShopItem(payRewardInfo, rushStage, rushRound)
  3263. if bRet != serverproto.ErrorCode_ERROR_OK {
  3264. return bRet, nil
  3265. }
  3266. case serverproto.PayGoodsType_EPayType_RushIdol:
  3267. bRet := this.roleRune.BuyIdolSeasonShopItem(payRewardInfo)
  3268. if bRet != serverproto.ErrorCode_ERROR_OK {
  3269. return bRet, nil
  3270. }
  3271. case serverproto.PayGoodsType_EPayType_SpecialPrivilege:
  3272. // 特权卡商店
  3273. bRet := this.roleRune.BuySpecialPrivilegeShopItem(payRewardInfo)
  3274. if bRet != serverproto.ErrorCode_ERROR_OK {
  3275. return bRet, nil
  3276. }
  3277. case serverproto.PayGoodsType_EPayType_PassCheck:
  3278. // RO通行证
  3279. bRet := this.roleRune.BuyPassCheck(payRewardInfo)
  3280. if bRet != serverproto.ErrorCode_ERROR_OK {
  3281. return bRet, nil
  3282. }
  3283. case serverproto.PayGoodsType_EPayType_BTRecharge100:
  3284. // bt百元大礼包充值
  3285. bRet := this.roleBT.BuyRecharge100(payRewardInfo)
  3286. if bRet != serverproto.ErrorCode_ERROR_OK {
  3287. return bRet, nil
  3288. }
  3289. default:
  3290. return serverproto.ErrorCode_ERROR_FAIL, nil
  3291. }
  3292. return serverproto.ErrorCode_ERROR_OK, payRewardInfo
  3293. }
  3294. func (this *Role) OnPayCallback(payRewardInfo *serverproto.PayOrderSaveInfo, bSave bool, bAck bool) {
  3295. //获取充值奖励
  3296. var addItemList = map[int32]int32{}
  3297. for idx := 0; idx < len(payRewardInfo.RewardList); idx++ {
  3298. addItemList[payRewardInfo.RewardList[idx].Key] += payRewardInfo.RewardList[idx].Value
  3299. }
  3300. if this.GetRoleBag().CanAddItemList(addItemList) == serverproto.ErrorCode_ERROR_OK {
  3301. if payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_MonthCard) ||
  3302. payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_NormalBag) ||
  3303. payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_LimitBag) ||
  3304. payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushTower) ||
  3305. payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushMap) ||
  3306. payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushPet) ||
  3307. payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushSkill) ||
  3308. payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushArena) ||
  3309. payRewardInfo.GoodsType == int32(serverproto.PayGoodsType_EPayType_RushIdol) {
  3310. this.AddItemList(addItemList, AddFrom_Rune, true)
  3311. } else {
  3312. this.AddItemList(addItemList, AddFrom_Pay, true)
  3313. }
  3314. } else {
  3315. mailST := &AddMailST{
  3316. ConfigId: model.GlobalMailIdPayReward,
  3317. MailType: serverproto.MailType_MailType_Pay,
  3318. ItemList: addItemList,
  3319. }
  3320. this.AddMailByST(mailST)
  3321. util.InfoF("uid=%v OnPayCallback add bag error, use mail payRewardInfo=%v", this.GetUUid(), payRewardInfo)
  3322. }
  3323. if bAck {
  3324. ackMsg := &serverproto.SCPayInfoOrderOKListGetAck{}
  3325. for k, v := range addItemList {
  3326. ackMsg.RewardItemList = append(ackMsg.RewardItemList, &serverproto.KeyValueType{Key: k, Value: v})
  3327. }
  3328. this.ReplayGate(ackMsg, true)
  3329. }
  3330. //根据各个系统处理不同情况
  3331. switch (serverproto.PayGoodsType)(payRewardInfo.GoodsType) {
  3332. case serverproto.PayGoodsType_EPayType_Discount: //超值礼包购买
  3333. this.roleActivity.OnPayInfoGetDiscount(payRewardInfo)
  3334. case serverproto.PayGoodsType_EPayType_MonthCard: //
  3335. this.GetRoleRune().OnBuyMonthCardShopItem(payRewardInfo)
  3336. case serverproto.PayGoodsType_EPayType_NormalBag: //
  3337. fallthrough
  3338. case serverproto.PayGoodsType_EPayType_LimitBag: //
  3339. this.GetRoleRune().OnBuyItemSuccess(payRewardInfo)
  3340. case serverproto.PayGoodsType_EPayType_RushTower: //
  3341. fallthrough
  3342. case serverproto.PayGoodsType_EPayType_RushMap: //
  3343. fallthrough
  3344. case serverproto.PayGoodsType_EPayType_RushPet: //
  3345. fallthrough
  3346. case serverproto.PayGoodsType_EPayType_RushSkill: //
  3347. fallthrough
  3348. case serverproto.PayGoodsType_EPayType_RushArena: //
  3349. this.GetRoleRune().OnBuyRushShopSuccess(payRewardInfo)
  3350. case serverproto.PayGoodsType_EPayType_GuildBattle:
  3351. this.GetRoleRune().OnBuyGuildBattleSuccess(payRewardInfo)
  3352. case serverproto.PayGoodsType_EPayType_RuneExplore:
  3353. this.GetRoleRune().RuneUnlock()
  3354. case serverproto.PayGoodsType_EPayType_RushIdol:
  3355. this.GetRoleRune().OnBuyIdolSeasonSuccess(payRewardInfo)
  3356. case serverproto.PayGoodsType_EPayType_SpecialPrivilege:
  3357. // 特权卡商店
  3358. this.GetRoleRune().OnBuySpecialPrivilege(payRewardInfo)
  3359. case serverproto.PayGoodsType_EPayType_PassCheck:
  3360. // RO通行证
  3361. this.GetRoleRune().OnBuyPassCheck(payRewardInfo)
  3362. case serverproto.PayGoodsType_EPayType_BTRecharge100:
  3363. // bt百元大礼包充值
  3364. this.roleBT.OnBuyRecharge100(payRewardInfo)
  3365. default:
  3366. }
  3367. ntfMsg := &serverproto.SCPayForGoodsNtf{}
  3368. ntfMsg.GoodsId = payRewardInfo.GoodsId
  3369. ntfMsg.ItemList = payRewardInfo.RewardList
  3370. ntfMsg.GoodsType = payRewardInfo.GoodsType
  3371. ntfMsg.GoodsNum = payRewardInfo.Count
  3372. ntfMsg.CpOrderId = payRewardInfo.CpOrderId
  3373. this.ReplayGate(ntfMsg, true)
  3374. //充值金额 payRewardInfo.Amount
  3375. // 充值成功后的系统相关处理
  3376. this.GetRoleBase().AddPayRecharge(payRewardInfo)
  3377. ////////
  3378. if bSave {
  3379. payRewardInfo.OrderState = int32(serverproto.PayOrderState_EPayOrderState_PayOkReward)
  3380. ssSaveReqMsg := &serverproto.SSPayInfoSaveReq{
  3381. PayOrderInfo: payRewardInfo,
  3382. }
  3383. this.SendDb(ssSaveReqMsg)
  3384. }
  3385. }
  3386. func (this *Role) PayInfoGetForCreditRecharge(goodsId, count int32) {
  3387. err := this.roleRune.BuyCreditRechargeShopItem(goodsId, count)
  3388. if err != serverproto.ErrorCode_ERROR_OK {
  3389. ackMsg := &serverproto.SCCreditRechargeShopItemBuyAck{
  3390. Error: int32(err),
  3391. GoodsId: goodsId,
  3392. }
  3393. this.ReplayGate(ackMsg, true)
  3394. }
  3395. }
  3396. // 领取特权卡奖励
  3397. func (this *Role) SpecialPrivilegeReward() {
  3398. err := this.roleRune.SpecialPrivilegeReward()
  3399. if err != serverproto.ErrorCode_ERROR_OK {
  3400. ackMsg := &serverproto.SCRuneSpecialPrivilegeRewardAck{
  3401. Error: int32(err),
  3402. }
  3403. this.ReplayGate(ackMsg, true)
  3404. }
  3405. }
  3406. func (this *Role) PayInfoGetForRoCoin(goodsId, count int32) {
  3407. err := this.roleRune.PayInfoGetForRoCoin(goodsId, count)
  3408. if err != serverproto.ErrorCode_ERROR_OK {
  3409. ackMsg := &serverproto.SCBTRoCoinShopItemBuyAck{
  3410. GoodsType: Rune_Shop_Type_Bag,
  3411. SubType: Rune_BagShop_Type_ROCoin,
  3412. Error: int32(err),
  3413. }
  3414. this.ReplayGate(ackMsg, true)
  3415. }
  3416. }
  3417. // GM充值
  3418. func (this *Role) GMPay(amount float32) {
  3419. payRewardInfo := &serverproto.PayOrderSaveInfo{
  3420. Amount: amount,
  3421. OrderProcessTime: util.GetTimeMilliseconds(),
  3422. }
  3423. this.OnPayCallback(payRewardInfo, false, false)
  3424. }
  3425. func (this *Role) GMCalAttr() {
  3426. //var heroList []*serverproto.HeroData
  3427. //heroList = append(heroList, this.roleHero.GetMainHero())
  3428. this.roleBattleAttr.AttrChange(AttrChangeST{
  3429. ChangeType: Attr_Change_None,
  3430. ChangeHeroData: this.roleHero.GetMainHero(),
  3431. })
  3432. for _, val := range this.roleHero.heroList {
  3433. //heroList = append(heroList, val)
  3434. this.roleBattleAttr.AttrChange(AttrChangeST{
  3435. ChangeType: Attr_Change_None,
  3436. ChangeHeroData: val,
  3437. })
  3438. //this.roleBattleAttr.calcAttrHero(val, AttrChangeST{})
  3439. }
  3440. }
  3441. func (this *Role) GetRuneShopInfo(shopType int32, subShop int32) {
  3442. //冲榜卢恩商店流程
  3443. if shopType == Rune_Shop_Type_RushTower ||
  3444. shopType == Rune_Shop_Type_RushArena ||
  3445. shopType == Rune_Shop_Type_RushMap ||
  3446. shopType == Rune_Shop_Type_RushSkill ||
  3447. shopType == Rune_Shop_Type_RushPet {
  3448. reqMsg := &serverproto.SSGetRushShopInfoReq{}
  3449. reqMsg.Uid = this.GetUUid()
  3450. if shopType == Rune_Shop_Type_RushTower {
  3451. reqMsg.RushType = model.Rush_Type_Tower
  3452. } else if shopType == Rune_Shop_Type_RushArena {
  3453. reqMsg.RushType = model.Rush_Type_Arena
  3454. } else if shopType == Rune_Shop_Type_RushMap {
  3455. reqMsg.RushType = model.Rush_Type_Map
  3456. } else if shopType == Rune_Shop_Type_RushPet {
  3457. reqMsg.RushType = model.Rush_Type_Pet
  3458. } else if shopType == Rune_Shop_Type_RushSkill {
  3459. reqMsg.RushType = model.Rush_Type_Skill
  3460. }
  3461. reqMsg.ShopType = shopType
  3462. reqMsg.SubShopId = subShop
  3463. this.SendRank(reqMsg)
  3464. return
  3465. }
  3466. //其他商店
  3467. ackMsg := &serverproto.SCRuneShopInfoAck{
  3468. ShopType: shopType,
  3469. SubShop: subShop,
  3470. }
  3471. if this.GetRoleRune() != nil {
  3472. this.GetRoleRune().GetShopInfo(shopType, subShop, ackMsg)
  3473. }
  3474. util.InfoF("[role.go] GetRuneShopInfo:%+v", *ackMsg)
  3475. this.ReplayGate(ackMsg, true)
  3476. }
  3477. func (this *Role) GetBTShopInfo(shopType int32, subShop int32) {
  3478. util.InfoF("[GetBTShopInfo] shopType=%v subShop:%v", shopType, subShop)
  3479. // 100充值钱包商店
  3480. // RO币礼包商店
  3481. ackMsg := &serverproto.SCBTShopInfoAck{
  3482. ShopType: shopType,
  3483. SubShop: subShop,
  3484. }
  3485. switch shopType {
  3486. case Rune_Shop_Type_CreditRecharge: // 充值钱包商店
  3487. fallthrough
  3488. case Rune_Shop_Type_Bag: // RO币礼包商店
  3489. if this.GetRoleRune() != nil {
  3490. this.GetRoleRune().GetBTShopInfo(shopType, subShop, ackMsg)
  3491. }
  3492. this.ReplayGate(ackMsg, true)
  3493. }
  3494. }
  3495. func (this *Role) GetRushShopInfo(msg *serverproto.SSGetRushShopInfoAck) {
  3496. ackMsg := &serverproto.SCRuneShopInfoAck{
  3497. ShopType: msg.ShopType,
  3498. SubShop: msg.SubShopId,
  3499. }
  3500. if this.GetRoleRune() != nil {
  3501. this.GetRoleRune().GetRuneShopInfo(msg, ackMsg)
  3502. }
  3503. this.ReplayGate(ackMsg, true)
  3504. }
  3505. func (this *Role) OnRuneExploreInfo() {
  3506. ackMsg := &serverproto.SCExploreInfoAck{}
  3507. if this.GetRoleRune() != nil {
  3508. this.GetRoleRune().runeExplore.ConvertMsg(ackMsg)
  3509. }
  3510. this.ReplayGate(ackMsg, true)
  3511. }
  3512. func (this *Role) OnRuneMaxLvlAward() {
  3513. var ackMsg *serverproto.SCExploreExtraRewardAck = nil
  3514. if this.GetRoleRune() != nil {
  3515. ackMsg = this.GetRoleRune().MaxLvlAward()
  3516. }
  3517. this.ReplayGate(ackMsg, true)
  3518. }
  3519. func (this *Role) OnRuneReward(msg *serverproto.CSExploreRewardReq) {
  3520. if msg == nil {
  3521. return
  3522. }
  3523. var ret *serverproto.SCExploreRewardAck = nil
  3524. if rune := this.GetRoleRune(); rune != nil {
  3525. //领取类型:1表示普通奖励,2高级奖励
  3526. ret = rune.OnRuneReward(msg.Level, msg.RewardType)
  3527. //if msg.RewardType == 1 {
  3528. // ret = this.GetRoleRune().RuneReward(msg.Level)
  3529. //} else if msg.RewardType == 2 {
  3530. // ret = this.GetRoleRune().RuneCashReward(msg.Level)
  3531. //}
  3532. }
  3533. this.ReplayGate(ret, true)
  3534. }
  3535. func (this *Role) GetResNotice(resType int32) serverproto.ErrorCode {
  3536. switch serverproto.ResType(resType) {
  3537. case serverproto.ResType_Res_Coin:
  3538. return serverproto.ErrorCode_ERROR_MONEY_NOT_ENOUGH
  3539. case serverproto.ResType_Res_Rmb:
  3540. return serverproto.ErrorCode_ERROR_RMB_NOT_ENOUGH
  3541. case serverproto.ResType_Res_Cruise:
  3542. return serverproto.ErrorCode_ERROR_SHOP_RESOURCE_NOT_NEOUGH_CRUISE
  3543. case serverproto.ResType_Res_SkillBook:
  3544. return serverproto.ErrorCode_ERROR_SHOP_RESOURCE_NOT_NEOUGH_SKILLBOOK
  3545. case serverproto.ResType_Res_Sprite:
  3546. return serverproto.ErrorCode_ERROR_SHOP_RESOURCE_NOT_NEOUGH_SPRITE
  3547. case serverproto.ResType_Res_PetCoin:
  3548. return serverproto.ErrorCode_ERROR_SHOP_RESOURCE_NOT_NEOUGH_PETPIECE
  3549. case serverproto.ResType_Res_Guild:
  3550. return serverproto.ErrorCode_ERROR_SHOP_RESOURCE_NOT_NEOUGH_GUILD
  3551. case serverproto.ResType_Res_HightSkillExp:
  3552. return serverproto.ErrorCode_ERROR_SHOP_RESOURCE_NOT_NEOUGH_SKILLBOOK
  3553. }
  3554. return serverproto.ErrorCode_ERROR_SHOP_RESOURCE_NOT_NEOUGH
  3555. }
  3556. func (this *Role) OnAntiCheatReq(cheatType int32) {
  3557. if this.GetRoleStatistic() != nil {
  3558. this.GetRoleStatistic().RecordCheatData(cheatType)
  3559. ackMsg := &serverproto.SCAntiCheatAck{}
  3560. this.ReplayGate(ackMsg, true)
  3561. }
  3562. }
  3563. func (this *Role) GiftReward(ackMsg *serverproto.SCGiftRewardAck) {
  3564. if ackMsg == nil {
  3565. return
  3566. }
  3567. if ackMsg.Error == 0 {
  3568. if len(ackMsg.RewardList) <= 0 {
  3569. util.DebugF("uid=%v gift code item empty uid=%v", this.GetUUid())
  3570. } else {
  3571. totalItemList := make(map[int32]int32)
  3572. for _, data := range ackMsg.RewardList {
  3573. totalItemList[data.Key] += data.Value
  3574. }
  3575. this.AddItemList(totalItemList, AddFrom_GiftCode, true)
  3576. }
  3577. } else if ackMsg.Error == 1 {
  3578. ackMsg.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_USED)
  3579. } else if ackMsg.Error == 2 {
  3580. ackMsg.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_OUTDATE)
  3581. } else if ackMsg.Error == 3 {
  3582. ackMsg.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_NOT_FOUND)
  3583. } else if ackMsg.Error == 4 {
  3584. ackMsg.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_FORBID)
  3585. } else if ackMsg.Error == int32(serverproto.ErrorCode_ERROR_GIFT_CODE_USE_FAIL) {
  3586. ackMsg.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_USE_FAIL)
  3587. } else if ackMsg.Error == 5 {
  3588. ackMsg.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_REUSE)
  3589. } else {
  3590. ackMsg.Error = int32(serverproto.ErrorCode_ERROR_FAIL)
  3591. }
  3592. }
  3593. func (this *Role) QuestionReward() {
  3594. //model.GlobalQuestionRewardList
  3595. ackMsg := &serverproto.SCQuestionRewardAck{
  3596. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  3597. }
  3598. if this.base.roleBase.QuestionReward <= 0 {
  3599. ret := this.CanAddItemList(model.GlobalQuestionRewardList)
  3600. ackMsg.Error = int32(ret)
  3601. if ret == serverproto.ErrorCode_ERROR_OK {
  3602. this.AddItemList(model.GlobalQuestionRewardList, AddFrom_QuestionReward, true)
  3603. this.base.roleBase.QuestionReward = 1
  3604. this.GetRoleBase().SetDirty(true)
  3605. }
  3606. } else {
  3607. ackMsg.Error = int32(serverproto.ErrorCode_ERROR_QUESTION_REWARDED)
  3608. }
  3609. this.ReplayGate(ackMsg, true)
  3610. }
  3611. func (this *Role) GetKeepSake() {
  3612. ackMsg := &serverproto.SCOnlineGetKeepSakeAck{}
  3613. if this.GetRoleKeepSake() != nil {
  3614. ackMsg.RoleKeepSake = &serverproto.RoleKeepSake{}
  3615. this.GetRoleKeepSake().GetKeepSakeData(ackMsg.RoleKeepSake)
  3616. }
  3617. this.ReplayGate(ackMsg, true)
  3618. }
  3619. func (this *Role) KeepSakeLevelUp(keepSakeId int32) {
  3620. ackMsg := &serverproto.SCKeepSakeLevelUpAck{
  3621. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  3622. }
  3623. if this.GetRoleKeepSake() != nil {
  3624. nRet := this.GetRoleKeepSake().KeepSakeLevelUp(keepSakeId)
  3625. ackMsg.Error = int32(nRet)
  3626. }
  3627. this.ReplayGate(ackMsg, true)
  3628. }
  3629. func (this *Role) OnHeadOperate(msg *serverproto.CSHeadOperateReq) {
  3630. if msg == nil {
  3631. return
  3632. }
  3633. ackMsg := &serverproto.SCHeadOperateAck{
  3634. Error: int32(serverproto.ErrorCode_ERROR_FAIL),
  3635. HeadId: msg.HeadId,
  3636. OperateType: msg.OperateType,
  3637. }
  3638. head := this.roleHead.GetHeadByHeadId(msg.HeadId)
  3639. if head != nil {
  3640. if head.State == int32(Head_Not_Activate) {
  3641. ackMsg.Error = int32(this.roleHead.HeadActivate(msg.HeadId))
  3642. } else if head.State == int32(Head_Wear) {
  3643. ackMsg.Error = int32(this.roleHead.HeadUnload(msg.HeadId))
  3644. } else if head.State == int32(Head_Unload) {
  3645. ackMsg.Error = int32(this.roleHead.HeadWear(msg.HeadId))
  3646. }
  3647. }
  3648. this.ReplayGate(ackMsg, true)
  3649. }
  3650. func (this *Role) OnHeadData(req *serverproto.CSHeadDataReq) {
  3651. ackMsg := &serverproto.SCHeadDataAck{}
  3652. this.roleHead.SendAllHeadData()
  3653. this.ReplayGate(ackMsg, true)
  3654. }
  3655. func (this *Role) OnWishUse(msg *serverproto.CSWishBoxUseReq) {
  3656. ackMsg := &serverproto.SCWishBoxUseAck{}
  3657. error, index := this.roleWish.OnWishBoxUse(msg.ItemId, msg.SelectItem)
  3658. ackMsg.Error, ackMsg.Index = int32(error), index
  3659. this.ReplayGate(ackMsg, true)
  3660. }
  3661. func (this *Role) OnWishSlotUnlock(msg *serverproto.CSWishUnlockSlotReq) {
  3662. ackMsg := &serverproto.SCWishUnlockSlotAck{}
  3663. ackMsg.Error = int32(this.roleWish.OnUnlockWishSlot())
  3664. this.ReplayGate(ackMsg, true)
  3665. }
  3666. func (this *Role) OnWishSlotAction(req *serverproto.CSWishSlotReq) {
  3667. error, awardItem, luckyItem := this.roleWish.OnWishRewardGet(req.Index)
  3668. ackMsg := &serverproto.SCWishSlotReqAck{Error: int32(error), AwardItem: awardItem, LuckyItem: luckyItem}
  3669. this.ReplayGate(ackMsg, true)
  3670. }
  3671. // 检查是否在合服期间
  3672. func (this *Role) CheckInCombinedService() bool {
  3673. bRet, _ := model.CheckInCombined(this.GetSelectZone())
  3674. return bRet
  3675. }
  3676. func (this *Role) CombineServerNtf() {
  3677. ntfMsg := &serverproto.SCCombineServerOnlineNtf{}
  3678. ntfMsg.CombineTime = 0
  3679. data, ok := model.ConvertCombineServerData[1]
  3680. if ok {
  3681. zoneId := this.GetSelectZone()
  3682. for _, server := range data.ServerList {
  3683. if server.Key <= zoneId && zoneId <= server.Value {
  3684. ntfMsg.CombineTime = data.CombineTime
  3685. break
  3686. }
  3687. }
  3688. }
  3689. this.ReplayGate(ntfMsg, true)
  3690. }
  3691. func (this *Role) GetCombineServerInfo() {
  3692. ntfMsg := &serverproto.SCCombineServerInfoAck{}
  3693. bFind := false
  3694. data, ok := model.ConvertCombineServerData[1]
  3695. if ok {
  3696. zoneId := this.GetSelectZone()
  3697. for _, server := range data.ServerList {
  3698. if server.Key <= zoneId && zoneId <= server.Value {
  3699. ntfMsg.Error = int32(serverproto.ErrorCode_ERROR_OK)
  3700. ntfMsg.CombineTime = data.CombineTime
  3701. ntfMsg.Notice = data.Notice
  3702. bFind = true
  3703. break
  3704. }
  3705. }
  3706. }
  3707. if bFind == false {
  3708. ntfMsg.Error = int32(serverproto.ErrorCode_ERROR_COMBINE_SERVER_NOT_IN_STATE)
  3709. ntfMsg.CombineTime = 0
  3710. }
  3711. this.ReplayGate(ntfMsg, true)
  3712. }
  3713. func (this *Role) GMSetCombineServerFinish() {
  3714. model.ConvertCombineServerData = make(map[int32]*model.CombineServer)
  3715. util.InfoF("ConvertCombineServerData len:%v", len(model.ConvertCombineServerData))
  3716. }