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

View File

@ -159,7 +159,15 @@ func (this *UserSession) Push() (err error) {
// 克隆 // 克隆
func (this *UserSession) Clone() (clone *UserSession) { 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 return
} }

View File

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

View File

@ -48,7 +48,6 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (errd
info = &pb.DBArenaUser{ info = &pb.DBArenaUser{
Uid: session.GetUserId(), Uid: session.GetUserId(),
Name: user.Name, Name: user.Name,
// Avatar: user.Avatar,
Lv: user.Lv, Lv: user.Lv,
Sex: user.Gender, Sex: user.Gender,
Skin: user.CurSkin, Skin: user.CurSkin,

View File

@ -57,6 +57,7 @@ func (this *modelPasson) getUserPasson(uid string) (results *pb.DBPasson, err er
func (this *modelPasson) updateUserPasson(uid string, data *pb.DBPasson) (err error) { func (this *modelPasson) updateUserPasson(uid string, data *pb.DBPasson) (err error) {
if err = this.Change(uid, map[string]interface{}{ if err = this.Change(uid, map[string]interface{}{
"passonlv": data.Passonlv,
"teacher": data.Teacher, "teacher": data.Teacher,
"student": data.Student, "student": data.Student,
}); err != nil { }); err != nil {