Compare commits

...

2 Commits

2 changed files with 22 additions and 1 deletions

View File

@ -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 {

View File

@ -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
}