This commit is contained in:
meixiongfeng 2023-07-11 17:28:37 +08:00
commit 29e0cdda57
6 changed files with 27 additions and 18 deletions

View File

@ -24,7 +24,7 @@ type ISC_GateRouteComp interface {
PutUserSession(session IUserSession)
}
//游戏类资源类型
// 游戏类资源类型
const (
AttrType = "attr" //用户属性资源 例如货币 经验 之类的
PerType = "per" //用户皮肤,动作,背景 相关资源
@ -44,13 +44,13 @@ type Autogenerated struct {
D []interface{}
}
//Api Check 错误返回结构
// Api Check 错误返回结构
type ErrorCode struct {
Code pb.ErrorCode
Data interface{}
}
//用户会话
// 用户会话
type IUserSession interface {
SetSession(ip, sessionId, stag, sid, uid string)
GetSessionId() string
@ -66,10 +66,11 @@ type IUserSession interface {
Push() (err error) //警告 api传递过来的会话禁用此接口
Close() (err error)
Reset()
Clone() (clone *UserSession) //克隆
ToString() string
}
//对protobuf格式的数据进行反序列化
// 对protobuf格式的数据进行反序列化
func ProtoUnmarshal(msg *pb.UserMessage, req proto.Message) (ok bool) {
err := msg.Data.UnmarshalTo(req)
if err != nil {
@ -79,7 +80,7 @@ func ProtoUnmarshal(msg *pb.UserMessage, req proto.Message) (ok bool) {
return true
}
//对protobuf格式的数据进行序列化
// 对protobuf格式的数据进行序列化
func ProtoMarshal(rsp proto.Message, msg *pb.UserMessage) (ok bool) {
any, err := anypb.New(rsp)
if err != nil {
@ -90,7 +91,7 @@ func ProtoMarshal(rsp proto.Message, msg *pb.UserMessage) (ok bool) {
return true
}
/// 参数 权重数组 返回值 数组下标
// / 参数 权重数组 返回值 数组下标
func GetRandW(sz []int32) int32 {
if len(sz) > 0 {
var _totalW int64 // 总权重
@ -137,7 +138,7 @@ func GetRandNum(min, max int32) int32 {
return int32(n.Int64()) + min
}
///通过uid获取用户所在区服
// /通过uid获取用户所在区服
func UidToSTag(uid string) (stag string, err error) {
s := strings.SplitN(uid, "_", 2)
if len(s) < 2 {

View File

@ -14,7 +14,7 @@ var buriedParamPool = &sync.Pool{
},
}
//普通任务
// 普通任务
func GetBuriedParam(t TaskType, vaule int32, p ...int32) *pb.BuriedParam {
task := buriedParamPool.Get().(*pb.BuriedParam)
task.TaskType = int32(t)
@ -25,7 +25,7 @@ func GetBuriedParam(t TaskType, vaule int32, p ...int32) *pb.BuriedParam {
return task
}
//统计型任务
// 统计型任务
func GetBuriedParam2(t TaskType, statistics string, p ...int32) *pb.BuriedParam {
task := buriedParamPool.Get().(*pb.BuriedParam)
task.TaskType = int32(t)

View File

@ -159,7 +159,15 @@ func (this *UserSession) Push() (err error) {
// 克隆
func (this *UserSession) Clone() (clone *UserSession) {
clone = &UserSession{
msgqueue: make([]*pb.UserMessage, 0),
service: this.service,
IP: this.IP,
SessionId: this.SessionId,
GatewayServiceId: this.GatewayServiceId,
ServiceTag: this.ServiceTag,
UserId: this.UserId,
}
return
}

View File

@ -8,13 +8,13 @@ import (
cfg "go_dreamfactory/sys/configure/structs"
)
//参数校验
// 参数校验
func (this *apiComp) ChallengeRewardCheck(session comm.IUserSession, req *pb.ArenaChallengeRewardReq) (errdata *pb.ErrorData) {
return
}
///挑战奖励领取
// /挑战奖励领取
func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaChallengeRewardReq) (errdata *pb.ErrorData) {
var (
reward *cfg.GameArenaActiveRewardData
@ -46,7 +46,7 @@ func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaCha
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleValidationFailed,
Title: pb.ErrorCode_BattleValidationFailed.ToString(),
Message: err.Error(),
Message: "battle iswin fail",
}
return
}

View File

@ -46,9 +46,8 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (errd
if err == mgo.MongodbNil {
global = this.module.ModuleTools.GetGlobalConf()
info = &pb.DBArenaUser{
Uid: session.GetUserId(),
Name: user.Name,
// Avatar: user.Avatar,
Uid: session.GetUserId(),
Name: user.Name,
Lv: user.Lv,
Sex: user.Gender,
Skin: user.CurSkin,

View File

@ -57,8 +57,9 @@ func (this *modelPasson) getUserPasson(uid string) (results *pb.DBPasson, err er
func (this *modelPasson) updateUserPasson(uid string, data *pb.DBPasson) (err error) {
if err = this.Change(uid, map[string]interface{}{
"teacher": data.Teacher,
"student": data.Student,
"passonlv": data.Passonlv,
"teacher": data.Teacher,
"student": data.Student,
}); err != nil {
this.module.Error("更新用户任务数据 错误!", log.Field{Key: "err", Value: err.Error()})
return