专武升星逻辑补充
This commit is contained in:
parent
34c96d5684
commit
87473994f1
@ -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,
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user