4551 lines
137 KiB
Go
4551 lines
137 KiB
Go
package model
|
||
|
||
import (
|
||
"errors"
|
||
"fmt"
|
||
"math/rand"
|
||
"reflect"
|
||
_ "rocommon/rpc"
|
||
"rocommon/service"
|
||
"rocommon/util"
|
||
"roserver/baseserver/model"
|
||
"roserver/serverproto"
|
||
"strconv"
|
||
"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加载之后加载数据
|
||
LoadAfter()
|
||
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
|
||
SetU8ServerUserID(userID string)
|
||
GetU8ServerUserID() 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)
|
||
SetRoleStoryNpc(story *serverproto.KeyValueType)
|
||
SetMapCartoon(id, status int32)
|
||
OnAddQualityPoint(msg *serverproto.CSAddQualityPointReq)
|
||
//hero
|
||
AddHero(configId int32) bool
|
||
GMSetHeroLevel(roleId, level 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()
|
||
PetDataExchange(sourcePetId, targetPetId uint32)
|
||
GetPetTotalSkillLevel(petId int32) int32
|
||
|
||
//精彩活动Activities
|
||
ActivitiesReward(activityId, param, rewardNum int32, watchAd bool)
|
||
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)
|
||
LevelUpSummon(group, summonCount int32)
|
||
ActivitySignIn(activityId int32)
|
||
SetCollectionNotice(activityId int32, CollectId int32, notice bool)
|
||
|
||
//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
|
||
ThirdPay(goodsType, goodsId, count int32, rushStage, rushRound int32, activityId int32)
|
||
PayInfoGet(goodsType, goodsId, count int32, rushStage, rushRound int32, activityId int32)
|
||
OnPayCallback(payRewardInfo *serverproto.PayOrderSaveInfo, bSave bool, bAck bool)
|
||
|
||
//卢恩商会
|
||
GetRuneShopInfo(shopType int32, subShop int32, activityId int32)
|
||
OnRuneExploreInfo()
|
||
OnRuneMaxLvlAward()
|
||
OnRuneReward(msg *serverproto.CSExploreRewardReq)
|
||
OnRuneRewardOnekey()
|
||
|
||
//抽卡
|
||
OnDrawReq(drawType int32, drawCount int32, watchAd bool)
|
||
|
||
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()
|
||
|
||
GetGoogleCommentReward()
|
||
|
||
//妙聚
|
||
OnMujoyGetInfo(*serverproto.CSMujoyGetReq)
|
||
OnMujoyLoginAward(*serverproto.CSMujoyLoginAwardReq)
|
||
OnMujoyUseDice(*serverproto.CSMujoyUseDiceReq)
|
||
OnMujoyDiceAward(req *serverproto.CSMujoyDiceAwardReq)
|
||
OnMujoyFlipAward(req *serverproto.CSMujoyFlipReq)
|
||
|
||
//收集屋获取奖励
|
||
GetCollectionReward(rewardType int32)
|
||
ActivityFundAwardOnekeyReq(activityId int32)
|
||
|
||
GetActivityData(actId int32) *serverproto.ActivitiesDetailData
|
||
OnPetRankAward(ackMsg *serverproto.SCGetPetRankAwardAck) bool
|
||
}
|
||
|
||
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(watchAd bool)
|
||
|
||
//Evil
|
||
BattleEvilRefresh(bForce bool, watchAd 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, watchAd 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
|
||
}
|
||
|
||
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: 1 * 1000,
|
||
}
|
||
}
|
||
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 //是否已经加载过
|
||
isCliLoad bool //客户端是否加载完成
|
||
activeCode string //激活码
|
||
u8ServerUserID string //秒聚sdk的userID
|
||
|
||
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 // 许愿箱
|
||
roleMujoy *RoleMujoy //妙聚
|
||
roleLevelupSummon *RoleLevelupSummon //可升级卡池
|
||
|
||
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.roleMujoy = newRoleMujoy(this)
|
||
this.roleLevelupSummon = newRoleLevelupSummon(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.roleRune,
|
||
this.roleActivity,
|
||
this.roleTower,
|
||
this.roleGuild,
|
||
this.rolePet,
|
||
this.roleInvitation,
|
||
this.roleDraw,
|
||
this.roleDaoChang100,
|
||
this.roleStatistic,
|
||
this.roleKeepSake,
|
||
this.roleRush,
|
||
this.roleCross,
|
||
this.roleSkillEquip,
|
||
this.roleHead,
|
||
this.roleWish,
|
||
this.roleMujoy,
|
||
this.roleLevelupSummon,
|
||
)
|
||
}
|
||
|
||
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) SetU8ServerUserID(userID string) {
|
||
this.u8ServerUserID = userID
|
||
}
|
||
func (this *Role) GetU8ServerUserID() string {
|
||
return this.u8ServerUserID
|
||
}
|
||
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) GetLunaAccount() string {
|
||
serverIdStr := strconv.FormatUint(uint64(this.GetSelectZone()), 10)
|
||
roleIdStr := strconv.FormatUint(this.GetUUid(), 10)
|
||
return serverIdStr + "_" + roleIdStr
|
||
}
|
||
|
||
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) ForceSave() {
|
||
if !this.isLoad {
|
||
return
|
||
}
|
||
|
||
bSave := false
|
||
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)
|
||
this.roleMujoy.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.GetRoleBase().DailyReset(notify)
|
||
}
|
||
|
||
func (this *Role) LoadAfter() {
|
||
util.InfoF("LoadAfter uid=%d", this.GetUUid())
|
||
this.rolePet.LoadAfter()
|
||
}
|
||
|
||
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() {
|
||
nowTime := util.GetTimeMilliseconds()
|
||
startUpTime := service.GetServiceStartupTime()
|
||
fucDisableFlag := this.getPlayerFuncDisableFlag(RoleMag.funcDisableFlag)
|
||
ntfMsg := &serverproto.SCStartupInfoNtf{
|
||
ServerTime: nowTime,
|
||
CreateTime: this.RegisterTime,
|
||
FuncDisable: this.FuncDisable(),
|
||
ServiceStartTime: startUpTime,
|
||
FuncDisableFlag: fucDisableFlag,
|
||
ServerRegion: service.GetServiceConfig().Node.ServerRegion,
|
||
}
|
||
//角色基础信息
|
||
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,
|
||
FuncDisableFlag: fucDisableFlag,
|
||
ServerRegion: service.GetServiceConfig().Node.ServerRegion,
|
||
}
|
||
|
||
//碎片
|
||
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)
|
||
|
||
//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,
|
||
FuncDisableFlag: fucDisableFlag,
|
||
ServerRegion: service.GetServiceConfig().Node.ServerRegion,
|
||
}
|
||
//跨服个人数据
|
||
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.roleLevelupSummon.StartupNtf()
|
||
|
||
//邀请码系统
|
||
this.roleInvitation.StartupNtf()
|
||
|
||
//初始化结束函数标志
|
||
endMsgNtf := &serverproto.SCStartupInfoEndNtf{}
|
||
this.ReplayGate(endMsgNtf, true)
|
||
|
||
this.GetRoleRune().GetFreeGoodsData()
|
||
|
||
this.CombineServerNtf()
|
||
//设置客户端加载完成标记
|
||
this.isCliLoad = true
|
||
}
|
||
|
||
// 上线处理
|
||
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) U8ServerLogNtf() {
|
||
|
||
}
|
||
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
|
||
}
|
||
|
||
// 添加通用资源
|
||
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:
|
||
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:
|
||
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_Unique:
|
||
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) 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 this.GetRoleBase().roleBase.FirstChange == 0 {
|
||
this.GetRoleBase().roleBase.FirstChange = 1
|
||
if len(model.GlobalChangeNameReward) > 0 {
|
||
addItemList := make(map[int32]int32)
|
||
for _, data := range model.GlobalChangeNameReward {
|
||
addItemList[data.Key] += data.Value
|
||
}
|
||
this.AddItemList(addItemList, AddFrom_ChangeName, true)
|
||
}
|
||
this.GetRoleBase().SetDirty(true)
|
||
}
|
||
|
||
//更新玩家简介信息
|
||
if bRet == serverproto.ErrorCode_ERROR_OK {
|
||
this.GetRoleBase().UpdatePlayerBriefInfo(false)
|
||
this.rolePet.checkAllPetsCanInertIntoPetRank(true)
|
||
}
|
||
}
|
||
|
||
func (this *Role) SetRoleGuide(guideId int32) {
|
||
this.GetRoleBase().SetGuideId(guideId)
|
||
}
|
||
|
||
// storyRewardId格式: {storyId}0{storyStoreType}
|
||
func (this *Role) SetRoleStory(story *serverproto.KeyValueType) {
|
||
storyId := story.Key
|
||
storyRewardId := story.Value
|
||
storyStoreType := story.Value % 10
|
||
if storyStoreType < 0 && storyStoreType > 8 {
|
||
util.InfoF("SetRoleStory: storyStoreType is not correct, storyId=%d storyRewardId=%d ", storyId, storyRewardId)
|
||
return
|
||
}
|
||
preStoryVal := this.GetRoleBase().GetStoryVal(storyId)
|
||
newStoryVal := preStoryVal | (1 << uint32(storyStoreType))
|
||
if newStoryVal == preStoryVal {
|
||
util.InfoF("SetRoleStory: reward has been got, storyId=%d storyRewardId=%d ", storyId, storyRewardId)
|
||
return
|
||
}
|
||
util.InfoF("SetRoleStory: storyId=%d storyBitVal=%d, preStoryVal=%d, storyVal=%d", storyId, storyStoreType, preStoryVal, newStoryVal)
|
||
newStoryId := &serverproto.KeyValueType{Key: storyId, Value: newStoryVal}
|
||
nRet := this.GetRoleBase().SetStoryId(newStoryId)
|
||
storyRewards := make([]*serverproto.KeyValueType, 0)
|
||
|
||
// 每个Story存储信息只有8个存储位
|
||
// giftId: 0-0001-0000, 0-0000-1000, 0-0000-0100, 0-0000-0010
|
||
// dateId: 1-0000-0000, 0-1000-0000, 0-0100-0000, 0-0010-0000
|
||
storyRewardCfgMap := serverproto.StoryRewardCfgLoader
|
||
storyRewardCfg, storyExist := storyRewardCfgMap[storyRewardId]
|
||
mapLevel := this.roleBattle.mapId*10000 + this.roleBattle.mapLevel
|
||
if storyExist && int32(storyRewardCfg.StoryId/10) == int32(storyId/10) &&
|
||
int32(mapLevel) >= storyRewardCfg.MapLevel {
|
||
if storyRewardCfg.RewardType == Story_Reward_Gift {
|
||
rewardCfg := storyRewardCfg.GiftReward
|
||
rewardItems := make(map[int32]int32)
|
||
for _, v := range rewardCfg {
|
||
key, value := model.Str2Res(v)
|
||
storyRewards = append(storyRewards, &serverproto.KeyValueType{
|
||
Key: key,
|
||
Value: value,
|
||
})
|
||
rewardItems[key] = value
|
||
}
|
||
util.InfoF("SetRoleStory: storyId=%d storyRewardId=%d storyRewards num %d", storyId, storyRewardId, len(storyRewards))
|
||
if len(rewardItems) > 0 {
|
||
this.AddItemList(rewardItems, AddFrom_StoryChat, true)
|
||
}
|
||
}
|
||
}
|
||
ackMsg := &serverproto.SCRoleStoryAck{
|
||
Error: int32(nRet),
|
||
StoryId: newStoryId,
|
||
StoryRewards: storyRewards,
|
||
}
|
||
this.ReplayGate(ackMsg, true)
|
||
}
|
||
|
||
// 增加StoryNpc的好感度
|
||
func (this *Role) SetRoleStoryNpc(storyNpc *serverproto.KeyValueType) {
|
||
storyId := storyNpc.Key
|
||
storyRewardId := storyNpc.Value
|
||
storyStoreType := storyNpc.Value % 10
|
||
if storyStoreType < 0 && storyStoreType > 8 {
|
||
util.InfoF("[SetRoleStoryNpc]: storyStoreType is not correct, storyId=%d storyRewardId=%d ", storyId, storyRewardId)
|
||
return
|
||
}
|
||
preStoryVal := this.GetRoleBase().GetStoryVal(storyId)
|
||
newStoryVal := preStoryVal | (1 << uint32(storyStoreType))
|
||
if newStoryVal == preStoryVal {
|
||
util.InfoF("SetRoleStory: reward has been got, storyId=%d storyRewardId=%d ", storyId, storyRewardId)
|
||
return
|
||
}
|
||
newStoryNpcId := &serverproto.KeyValueType{}
|
||
storyRewardCfgMap := serverproto.StoryRewardCfgLoader
|
||
storyRewardCfg, storyExist := storyRewardCfgMap[storyRewardId]
|
||
mapLevel := this.roleBattle.mapId*10000 + this.roleBattle.mapLevel
|
||
util.InfoF("SetRoleStory: Add Heart storyId=%d, storyRewardId=%d, mapLevel=%d", storyId, storyRewardId, mapLevel)
|
||
if storyExist && int32(storyRewardCfg.StoryId/10) == int32(storyId/10) &&
|
||
storyRewardCfg.RewardType == Story_Reward_Heart && int32(mapLevel) >= storyRewardCfg.MapLevel {
|
||
heartRewardStr := storyRewardCfg.HeartReward
|
||
storyNpcId, addHeartVal := model.Str2Res(heartRewardStr)
|
||
preStoryNpcHeart := this.GetRoleBase().GetStoryNpcHeart(storyNpcId)
|
||
heart := preStoryNpcHeart + addHeartVal
|
||
util.InfoF("SetRoleStory: Add Heart storyId=%d, storyNpcId=%d, preStoryNpcHeart=%d, heart=%d", storyId, storyNpcId, preStoryNpcHeart, heart)
|
||
newStoryNpcId.Key = storyNpcId
|
||
newStoryNpcId.Value = heart
|
||
this.GetRoleBase().SetStoryNpcId(newStoryNpcId)
|
||
|
||
util.InfoF("SetRoleStory: storyId=%d storyBitVal=%d, preStoryVal=%d, storyVal=%d", storyId, storyStoreType, preStoryVal, newStoryVal)
|
||
newStoryId := &serverproto.KeyValueType{Key: storyId, Value: newStoryVal}
|
||
this.GetRoleBase().SetStoryId(newStoryId)
|
||
}
|
||
ackMsg := &serverproto.SCRoleStoryNpcAck{
|
||
Error: int32(serverproto.ErrorCode_ERROR_OK),
|
||
StoryNpcId: newStoryNpcId,
|
||
}
|
||
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) GMSetHeroLevel(heroId, level int32) bool {
|
||
var hero *serverproto.HeroData
|
||
if heroId == 0 {
|
||
hero = this.GetRoleBase().roleBase.RoleData.HeroData
|
||
} else {
|
||
hero = this.GetRoleHero().GetHero(heroId)
|
||
}
|
||
|
||
if hero == nil {
|
||
return false
|
||
}
|
||
|
||
hero.BaseLevel = level
|
||
return true
|
||
}
|
||
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)
|
||
this.SendAllFruit(ntfMsg)
|
||
}
|
||
|
||
func (this *Role) playerSocialOffline() {
|
||
ntfMsg := &serverproto.SSPlayerOfflineNtf{
|
||
Uid: this.GetUUid(),
|
||
}
|
||
this.SendAllSocial(ntfMsg)
|
||
this.SendAllFruit(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) 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(watchAd bool) {
|
||
if this.roleBattle != nil {
|
||
this.roleBattle.GetQuickBattleReward(watchAd)
|
||
}
|
||
}
|
||
|
||
// 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) 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, watchAd bool) {
|
||
ackMsg := &serverproto.SCDrawCardAck{
|
||
DrawType: drawType,
|
||
DrawCount: drawCount,
|
||
}
|
||
if this.roleDraw != nil {
|
||
bRet := this.GetRoleDraw().DrawReq(drawType, drawCount, ackMsg, watchAd)
|
||
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) ThirdPay(goodsType, goodsId, count int32, rushStage, rushRound int32, activityId 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,
|
||
PayNotifyUrl: service.GetServiceConfig().SDKConfig.PayNotifyUrl,
|
||
}
|
||
this.ReplayGate(ackMsg, true)
|
||
return
|
||
}
|
||
}
|
||
|
||
ret, payOrderInfo := this.payInfoGet(goodsType, goodsId, count, rushStage, rushRound, activityId)
|
||
|
||
ackMsg := &serverproto.SCPayInfoGetAck{
|
||
Error: int32(ret),
|
||
GoodsType: goodsType,
|
||
GoodsId: goodsId,
|
||
Count: count,
|
||
ActivityId: activityId,
|
||
PayNotifyUrl: service.GetServiceConfig().SDKConfig.PayNotifyUrl,
|
||
}
|
||
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
|
||
}
|
||
|
||
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
|
||
|
||
// 直接发货
|
||
this.OnPayCallback(payOrderInfo, true, false)
|
||
this.ForceSave()
|
||
} else {
|
||
this.ReplayGate(ackMsg, true)
|
||
}
|
||
}
|
||
|
||
func (this *Role) PayInfoGet(goodsType, goodsId, count int32, rushStage, rushRound int32, activityId 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,
|
||
PayNotifyUrl: service.GetServiceConfig().SDKConfig.PayNotifyUrl,
|
||
}
|
||
this.ReplayGate(ackMsg, true)
|
||
return
|
||
}
|
||
}
|
||
|
||
ret, payOrderInfo := this.payInfoGet(goodsType, goodsId, count, rushStage, rushRound, activityId)
|
||
|
||
ackMsg := &serverproto.SCPayInfoGetAck{
|
||
Error: int32(ret),
|
||
GoodsType: goodsType,
|
||
GoodsId: goodsId,
|
||
Count: count,
|
||
ActivityId: activityId,
|
||
PayNotifyUrl: service.GetServiceConfig().SDKConfig.PayNotifyUrl,
|
||
}
|
||
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
|
||
}
|
||
|
||
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, activityId 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_Fund:
|
||
bRet := this.roleRune.BuyFundActive(payRewardInfo, activityId)
|
||
if bRet != serverproto.ErrorCode_ERROR_OK {
|
||
return bRet, 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_Fund:
|
||
this.GetRoleRune().OnBuyFundSuccess(payRewardInfo)
|
||
}
|
||
|
||
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)
|
||
}
|
||
this.WriteMiaojuLogCharge(payRewardInfo)
|
||
}
|
||
|
||
func (this *Role) WriteMiaojuLogCharge(payRewardInfo *serverproto.PayOrderSaveInfo) {
|
||
if payRewardInfo == nil {
|
||
return
|
||
}
|
||
//支付成功写商品数据
|
||
paySuccessLog := &MiaojuLogPaySuccess{
|
||
Properties: PaySuccess{
|
||
StoreId: int(payRewardInfo.GoodsPayId),
|
||
PayId: int(payRewardInfo.GoodsId),
|
||
PayMoney: payRewardInfo.Amount,
|
||
},
|
||
}
|
||
for _, item := range payRewardInfo.RewardList {
|
||
paySuccessLog.Properties.ItemList = append(paySuccessLog.Properties.ItemList, &PayItem{
|
||
ItemId: int(item.Key),
|
||
ItemNum: int(item.Value),
|
||
})
|
||
}
|
||
paySuccessLog.Properties.RoleId = strconv.FormatUint(this.GetUUid(), 10)
|
||
paySuccessLog.Properties.OpenId = this.GetOpenId()
|
||
|
||
if this.clientParamInfo != nil {
|
||
paySuccessLog.Properties.ChannelId = this.clientParamInfo.AppChannel
|
||
paySuccessLog.Properties.DeviceId = this.clientParamInfo.UnisdkDeviceId
|
||
}
|
||
|
||
paySuccessLog.Properties.ServerId = strconv.Itoa(int(this.GetSelectZone()))
|
||
paySuccessLog.Properties.RoleName = this.GetNickName()
|
||
paySuccessLog.Properties.RoleLevel = int(this.GetRoleLevel())
|
||
paySuccessLog.Properties.VIPLevel = int(this.GetRoleVipLevel())
|
||
paySuccessLog.Properties.RegisterCountry = ""
|
||
paySuccessLog.Properties.CurTime = time.Unix(int64(util.GetTimeSeconds()), 0).Format(util.DATE_FORMAT)
|
||
|
||
paySuccessLog.UUID = "" //strconv.FormatUint(this.GetUUid(), 10)
|
||
paySuccessLog.OpenId = this.GetLunaAccount()
|
||
paySuccessLog.DistinctId = ""
|
||
paySuccessLog.Type = "track"
|
||
paySuccessLog.CurTime = time.Unix(int64(util.GetTimeSeconds()), 0).Format(util.DATE_FORMAT)
|
||
paySuccessLog.EventName = "pay_success"
|
||
|
||
paySuccessLog.Log(this)
|
||
}
|
||
|
||
func (this *Role) WriteMiaojuLogChangeCode(msg *serverproto.SCGiftRewardAck) {
|
||
if msg == nil {
|
||
return
|
||
}
|
||
miaoJuLog := &MiaojuLogChangeCodeGet{
|
||
Properties: ChangeCodeGet{
|
||
ChangeCode: msg.GiftCode,
|
||
},
|
||
}
|
||
for _, item := range msg.RewardList {
|
||
miaoJuLog.Properties.ItemList = append(miaoJuLog.Properties.ItemList, &PayItem{
|
||
ItemId: int(item.Key),
|
||
ItemNum: int(item.Value),
|
||
})
|
||
}
|
||
miaoJuLog.Properties.RoleId = strconv.FormatUint(this.GetUUid(), 10)
|
||
miaoJuLog.Properties.OpenId = this.GetOpenId()
|
||
miaoJuLog.Properties.ChannelId = this.clientParamInfo.AppChannel
|
||
miaoJuLog.Properties.DeviceId = this.clientParamInfo.UnisdkDeviceId
|
||
miaoJuLog.Properties.ServerId = strconv.Itoa(int(this.GetSelectZone()))
|
||
miaoJuLog.Properties.RoleName = this.GetNickName()
|
||
miaoJuLog.Properties.RoleLevel = int(this.GetRoleLevel())
|
||
miaoJuLog.Properties.VIPLevel = int(this.GetRoleVipLevel())
|
||
miaoJuLog.Properties.RegisterCountry = ""
|
||
miaoJuLog.Properties.CurTime = time.Unix(int64(util.GetTimeSeconds()), 0).Format(util.DATE_FORMAT)
|
||
|
||
miaoJuLog.UUID = "" //strconv.FormatUint(this.GetUUid(), 10)
|
||
miaoJuLog.OpenId = this.GetLunaAccount()
|
||
miaoJuLog.DistinctId = ""
|
||
miaoJuLog.Type = "track"
|
||
miaoJuLog.CurTime = time.Unix(int64(util.GetTimeSeconds()), 0).Format(util.DATE_FORMAT)
|
||
miaoJuLog.EventName = "changecode_get"
|
||
|
||
miaoJuLog.Log(this)
|
||
}
|
||
|
||
// GM充值
|
||
func (this *Role) GMPay(amount float32) {
|
||
payRewardInfo := &serverproto.PayOrderSaveInfo{
|
||
KrCur: 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, activityId 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,
|
||
ActivityId: activityId,
|
||
}
|
||
if this.GetRoleRune() != nil {
|
||
this.GetRoleRune().GetShopInfo(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) OnRuneRewardOnekey() {
|
||
err := serverproto.ErrorCode_ERROR_FAIL
|
||
if rune := this.GetRoleRune(); rune != nil {
|
||
err = rune.OnRuneRewardOnekey()
|
||
}
|
||
if err != serverproto.ErrorCode_ERROR_OK {
|
||
ackMsg := &serverproto.SCExploreRewardAck{
|
||
Error: int32(err),
|
||
}
|
||
|
||
this.ReplayGate(ackMsg, 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 {
|
||
//【【Luna】取消光环倍速封停判定-服务器】 https://www.tapd.cn/62490630/prong/tasks/view/1162490630001023827
|
||
//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)
|
||
}
|
||
this.WriteMiaojuLogChangeCode(ackMsg)
|
||
} 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, req.WatchAd)
|
||
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
|
||
//当前区服ID
|
||
zoneId := this.GetSelectZone()
|
||
|
||
bFind := false
|
||
for _, data := range model.ConvertCombineServerData {
|
||
for _, server := range data.ServerList {
|
||
if server.Key <= zoneId && zoneId <= server.Value {
|
||
ntfMsg.CombineTime = data.CombineTime
|
||
bFind = true
|
||
break
|
||
}
|
||
}
|
||
if bFind == true {
|
||
break
|
||
}
|
||
}
|
||
this.ReplayGate(ntfMsg, true)
|
||
}
|
||
|
||
func (this *Role) GetCombineServerInfo() {
|
||
ntfMsg := &serverproto.SCCombineServerInfoAck{}
|
||
//当前区服ID
|
||
zoneId := this.GetSelectZone()
|
||
|
||
bFind := false
|
||
for _, data := range model.ConvertCombineServerData {
|
||
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 == 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))
|
||
}
|
||
|
||
func (this *Role) playerFuncDisableFlagInfo() {
|
||
nowTime := util.GetTimeMilliseconds()
|
||
if nowTime-RoleMag.funcDisableFlagRefreshTime > 1000 {
|
||
RoleMag.funcDisableFlagRefreshTime = nowTime
|
||
|
||
ssMsg := &serverproto.SSBTFuncDisableFlagReq{}
|
||
this.SendDb(ssMsg)
|
||
}
|
||
}
|
||
func (this *Role) getPlayerFuncDisableFlag(val uint64) []uint32 {
|
||
var flagList []uint32
|
||
flag1 := uint32(val & 0xffffffff)
|
||
flag2 := uint32(val >> 32)
|
||
flagList = append(flagList, flag1, flag2)
|
||
return flagList
|
||
}
|
||
func (this *Role) OnPlayerFuncDisableFlag(flag uint64) {
|
||
ackMsg := &serverproto.SCBTFuncDisableFlagNtf{
|
||
FuncDisableFlag: this.getPlayerFuncDisableFlag(flag),
|
||
}
|
||
this.ReplayGate(ackMsg, true)
|
||
}
|
||
|
||
func (this *Role) GetGoogleCommentReward() {
|
||
ackMsg := &serverproto.SCGoogleCommentAck{
|
||
Error: int32(serverproto.ErrorCode_ERROR_FAIL),
|
||
}
|
||
if this.GetRoleBase() != nil {
|
||
bRet := this.GetRoleBase().GetGoogleCommentReward()
|
||
ackMsg.Error = int32(bRet)
|
||
}
|
||
|
||
this.ReplayGate(ackMsg, true)
|
||
}
|
||
|
||
// 妙聚
|
||
func (this *Role) OnMujoyGetInfo(*serverproto.CSMujoyGetReq) {
|
||
ackMsg := &serverproto.SCMujoyGetAck{
|
||
Mujoy: this.roleMujoy.GetMujoyInfo(),
|
||
}
|
||
|
||
this.ReplayGate(ackMsg, true)
|
||
}
|
||
func (this *Role) OnMujoyLoginAward(req *serverproto.CSMujoyLoginAwardReq) {
|
||
err, id, rewardList := this.roleMujoy.OnMujoyLoginAward(req.UseItem)
|
||
ackMsg := &serverproto.SCMujoyLoginAwardAck{
|
||
Error: int32(err),
|
||
UseItem: req.UseItem,
|
||
DayAwardId: id,
|
||
RewardList: rewardList,
|
||
}
|
||
|
||
this.ReplayGate(ackMsg, true)
|
||
}
|
||
|
||
func (this *Role) OnMujoyUseDice(*serverproto.CSMujoyUseDiceReq) {
|
||
err := this.roleMujoy.OnMujoyUseDice()
|
||
ackMsg := &serverproto.SCMujoyUseDiceAck{
|
||
Error: int32(err),
|
||
}
|
||
if err == serverproto.ErrorCode_ERROR_OK {
|
||
ackMsg.Rich = this.roleMujoy.GetMujoyInfo().Rich
|
||
}
|
||
|
||
this.ReplayGate(ackMsg, true)
|
||
}
|
||
|
||
func (this *Role) OnMujoyDiceAward(req *serverproto.CSMujoyDiceAwardReq) {
|
||
err, rewardList := this.roleMujoy.OnMujoyDiceAward(req.UseItem)
|
||
ackMsg := &serverproto.SCMujoyDiceAwardAck{
|
||
Error: int32(err),
|
||
UseItem: req.UseItem,
|
||
RewardList: rewardList,
|
||
}
|
||
|
||
this.ReplayGate(ackMsg, true)
|
||
}
|
||
|
||
func (this *Role) OnMujoyFlipAward(req *serverproto.CSMujoyFlipReq) {
|
||
err, cfgId, rewardList := this.roleMujoy.OnMujoyFlipAward(req.UseItem)
|
||
ackMsg := &serverproto.SCMujoyFlipAck{
|
||
Error: int32(err),
|
||
UseItem: req.UseItem,
|
||
CfgId: cfgId,
|
||
RewardList: rewardList,
|
||
}
|
||
|
||
this.ReplayGate(ackMsg, true)
|
||
}
|
||
|
||
func (this *Role) GetCollectionReward(rewardType int32) {
|
||
ackMsg := &serverproto.SCCollectionRewardGetAck{
|
||
Type: rewardType,
|
||
}
|
||
bRet := serverproto.ErrorCode_ERROR_FAIL
|
||
if rewardType == 1 {
|
||
bRet = this.GetRoleCard().GetAllCardCollectReward(ackMsg)
|
||
} else if rewardType == 2 {
|
||
bRet = this.GetRolePet().GetAllPetManualReward(ackMsg)
|
||
} else {
|
||
|
||
}
|
||
|
||
ackMsg.Error = int32(bRet)
|
||
this.ReplayGate(ackMsg, true)
|
||
}
|
||
|
||
func (this *Role) GetActivityData(actId int32) *serverproto.ActivitiesDetailData {
|
||
return this.roleActivity.getActivityData(actId)
|
||
}
|
||
|
||
func (this *Role) InsertIntoCommonActivityRank(actId int32, score uint64, force bool) {
|
||
if score == 0 {
|
||
return
|
||
}
|
||
|
||
time := util.GetCurrentTime()
|
||
snap := &serverproto.CommonRankSnapShot{
|
||
Uid: this.GetUUid(),
|
||
NickName: this.GetNickName(),
|
||
Gender: this.GetRoleBase().GetRoleSex(),
|
||
ImgId: this.GetImageId(),
|
||
HeadFrameId: this.GetRoleBase().RoleData().HeadFrameId,
|
||
ConfigId: this.GetRoleHero().GetMainHero().ConfigId,
|
||
Level: this.GetRoleLevel(),
|
||
FightPower: this.GetRoleBase().RoleData().FightPower,
|
||
//TitleId: this.GetTitleId(),
|
||
Time: time,
|
||
}
|
||
|
||
err, snapStr := model.GetEncodeMessage(snap)
|
||
if err != nil {
|
||
util.ErrorF("[Role] InsertIntoCommonActivityRank encode failed err=%v actId=%d uid=%d score=%d", err, actId, this.GetUUid(), score)
|
||
return
|
||
}
|
||
|
||
//expand snapshot todo
|
||
msg := &serverproto.SSCommonActivityInsertRank{
|
||
ActivityId: actId,
|
||
Key: this.GetUUid(),
|
||
Score: score,
|
||
Time: time,
|
||
Snapshot: snapStr,
|
||
ExpandSnapshot: "", // todo
|
||
Force: force,
|
||
}
|
||
|
||
this.SendRank(msg)
|
||
}
|
||
|
||
func (this *Role) DeleteFromCommonActivityRank(actId int32) {
|
||
msg := &serverproto.SSCommonActivityDelRank{
|
||
ActivityId: actId,
|
||
Key: this.GetUUid(),
|
||
}
|
||
|
||
this.SendRank(msg)
|
||
}
|
||
|
||
func (this *Role) OnPetRankAward(ackMsg *serverproto.SCGetPetRankAwardAck) bool {
|
||
|
||
actDetail := this.GetActivityData(ackMsg.ActivityId)
|
||
if actDetail == nil {
|
||
util.ErrorF("OnPetRankAward act not open actId=%d uid=%d", ackMsg.ActivityId, this.GetUUid())
|
||
ackMsg.Error = int32(serverproto.ErrorCode_ERROR_FAIL)
|
||
this.ReplayGate(ackMsg, true)
|
||
return false
|
||
}
|
||
|
||
if actDetail.PetRankData.RankAwarded == true {
|
||
ackMsg.Error = int32(serverproto.ErrorCode_ERROR_FAIL)
|
||
this.ReplayGate(ackMsg, true)
|
||
return false
|
||
}
|
||
|
||
awardM := make(map[int32]int32, len(ackMsg.RewardList))
|
||
for _, awardInfo := range ackMsg.RewardList {
|
||
awardM[awardInfo.Key] += awardInfo.Value
|
||
}
|
||
ret := this.CanAddItemList(awardM)
|
||
if ret != serverproto.ErrorCode_ERROR_OK {
|
||
util.ErrorF("OnPetRankAward additem failed id=%d uid=%d ret=%d", ackMsg.ActivityId, this.GetUUid())
|
||
ackMsg.Error = int32(ret)
|
||
this.ReplayGate(ackMsg, true)
|
||
return false
|
||
}
|
||
|
||
actDetail.PetRankData.RankAwarded = true
|
||
this.roleActivity.addChangeActivity(ackMsg.ActivityId, 0)
|
||
ActivitiesMag.SetCommonRankAwarded(ackMsg.ActivityId, this.GetUUid())
|
||
|
||
this.AddItemList(awardM, AddFrom_PetRankAward, true)
|
||
this.GetRoleActivity().SetDirty(true)
|
||
this.ReplayGate(ackMsg, true)
|
||
|
||
//通知数据变更
|
||
ntfMsg := &serverproto.SCActivitiesChangeNtf{
|
||
CurDayEndTime: this.GetRoleActivity().curDayEndTime,
|
||
}
|
||
detailData := &serverproto.ActivitiesDetailData{
|
||
ActivitiesId: actDetail.ActivitiesId,
|
||
ActivitiesType: actDetail.ActivitiesType,
|
||
StartTime: actDetail.StartTime,
|
||
EndTime: actDetail.EndTime,
|
||
PetRankData: actDetail.PetRankData,
|
||
}
|
||
ntfMsg.ActivityDataList = append(ntfMsg.ActivityDataList, detailData)
|
||
this.ReplayGate(ntfMsg, true)
|
||
util.InfoF("OnPetRankAward suc uid=%d actId=%d rewardList=%v", this.GetUUid(), ackMsg.ActivityId, ackMsg.RewardList)
|
||
return true
|
||
}
|
||
|
||
func (this *Role) GetPetTotalSkillLevel(petId int32) int32 {
|
||
total := int32(0)
|
||
for _, petData := range this.rolePet.petList {
|
||
if petData.ConfigId != petId {
|
||
continue
|
||
}
|
||
|
||
tmpTotal := int32(0)
|
||
for _, skillInfo := range petData.SkillList {
|
||
tmpTotal += skillInfo.Level
|
||
}
|
||
|
||
if tmpTotal > total {
|
||
total = tmpTotal
|
||
}
|
||
}
|
||
|
||
return total
|
||
}
|