From 2adbe3b5730840b2398dfc25a1ec61965fdf80df Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Mon, 26 Jun 2023 18:16:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=93=E5=8A=9B=E6=BA=A2?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 2 ++ modules/user/module.go | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) 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/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 +}