diff --git a/modules/exclusive/api_starup.go b/modules/exclusive/api_starup.go index f9930eab6..5058eb051 100644 --- a/modules/exclusive/api_starup.go +++ b/modules/exclusive/api_starup.go @@ -4,6 +4,7 @@ import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" ) //参数校验 @@ -17,6 +18,7 @@ func (this *apiComp) StarUp(session comm.IUserSession, req *pb.ExclusiveStarUpRe var ( info *pb.DB_Exclusive list []*pb.DB_Exclusive + conf *cfg.GameExclusiveStarData change []*pb.DB_Exclusive stars int32 err error @@ -44,6 +46,7 @@ func (this *apiComp) StarUp(session comm.IUserSession, req *pb.ExclusiveStarUpRe stars += v.Star } } + if info == nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, @@ -51,7 +54,18 @@ func (this *apiComp) StarUp(session comm.IUserSession, req *pb.ExclusiveStarUpRe } return } + if conf, err = this.module.configure.GetMaxGameExclusiveStarData(info.CId); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Message: err.Error(), + } + return + } info.Star += stars + if info.Star > conf.Star { + info.Star = conf.Star + } + if err = this.module.model.updateExclusive(session.GetUserId(), info); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, diff --git a/modules/exclusive/configure.go b/modules/exclusive/configure.go index 95ff8bc72..cd169ebd2 100644 --- a/modules/exclusive/configure.go +++ b/modules/exclusive/configure.go @@ -180,6 +180,23 @@ func (this *configureComp) GetGameExclusiveStarData(cid string, star int32) (con } } +//获取全部资源 +func (this *configureComp) GetMaxGameExclusiveStarData(cid string) (conf *cfg.GameExclusiveStarData, err error) { + this.lock.RLock() + defer this.lock.RUnlock() + if _, ok := this.stars[cid]; ok { + if len(this.stars[cid]) > 0 { + conf = this.stars[cid][len(this.stars[cid])-1] + return + } + err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_exclusiveupgrade, cid) + return + } else { + err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_exclusiveupgrade, cid) + return + } +} + //获取全部资源 func (this *configureComp) GetGameExclusiveRankData(cid string, rank int32) (conf *cfg.GameExclusiveRankData, err error) { this.lock.RLock()