role.go 123 KB

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