diff --git a/comm/imodule.go b/comm/imodule.go index eb49be119..9bf81cc15 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -172,6 +172,8 @@ type ( SetUserCaravanLvChange(session IUserSession, caravanlv int32) error //消耗体力加经验 ConsumePsAddExp(session IUserSession, ps int32) (addExp int32, errdata *pb.ErrorData) + // 体力差 + RemainingPS(uid string) int32 } //武器模块 IEquipment interface { diff --git a/modules/user/api_puzzleaward.go b/modules/user/api_puzzleaward.go index 56cedba75..b1b9742b4 100644 --- a/modules/user/api_puzzleaward.go +++ b/modules/user/api_puzzleaward.go @@ -14,8 +14,9 @@ func (this *apiComp) PuzzleAwardCheck(session comm.IUserSession, req *pb.UserPuz //拼图领奖 func (this *apiComp) PuzzleAward(session comm.IUserSession, req *pb.UserPuzzleAwardReq) (errdata *pb.ErrorData) { var ( - sign *pb.DBSign - err error + sign *pb.DBSign + err error + completeCount int32 ) if sign, err = this.module.modelSign.GetUserSign(session.GetUserId()); err != nil { @@ -41,6 +42,14 @@ func (this *apiComp) PuzzleAward(session comm.IUserSession, req *pb.UserPuzzleAw } sign.Puzzle[req.Index] = 1 + for _, v := range sign.Puzzle { + if v == 1 { + completeCount++ + } + } + if conf := this.module.configure.GetSignExtarConf(completeCount, sign.Group); conf != nil { + this.module.DispenseRes(session, conf.Extra, true) // 签到额外奖励 + } if err = this.module.modelSign.Change(session.GetUserId(), map[string]interface{}{ "puzzle": sign.Puzzle, }); err != nil { diff --git a/modules/user/module.go b/modules/user/module.go index 180de05dc..7265de994 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -541,7 +541,7 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha // user.Exp += int64(exp) } - if change.Ps+add > ggd.PsUl { + if change.Ps >= ggd.PsUl { errdata = &pb.ErrorData{ Code: pb.ErrorCode_UserVitLimit, Title: pb.ErrorCode_UserVitLimit.ToString(), @@ -550,6 +550,9 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha return } change.Ps += add + if change.Ps > ggd.PsUl { + change.Ps = ggd.PsUl + } case comm.Talent1: if add < 0 { if user.Talent1+add < 0 { @@ -1163,3 +1166,19 @@ func (this *User) ConsumePsAddExp(session comm.IUserSession, ps int32) (addExp i attrs["exp"] = int32(user.Exp) return addExp, this.AddAttributeValues(session, attrs, true) } + +// 剩余体力 +func (this *User) RemainingPS(uid string) (ps int32) { + var ( + user *pb.DBUser + ) + + if user = this.GetUser(uid); user == nil { + return + } + ggd := this.ModuleTools.GetGlobalConf() + if ggd == nil { + return + } + return ggd.PsUl - user.Ps +}