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