消耗体力加经验

This commit is contained in:
wh_zcy 2023-06-16 18:04:16 +08:00
parent c730cf7cee
commit d8a25f4459
2 changed files with 27 additions and 0 deletions

View File

@ -170,6 +170,8 @@ type (
AddPer(session IUserSession, pers map[string]int32, bPush bool) (errdata *pb.ErrorData)
SetUserCaravanLvChange(session IUserSession, caravanlv int32) error
//消耗体力加经验
ConsumePsAddExp(session IUserSession, ps int) (errdata *pb.ErrorData)
}
//武器模块
IEquipment interface {

View File

@ -12,6 +12,7 @@ import (
"go_dreamfactory/sys/configure"
"go_dreamfactory/sys/db"
"go_dreamfactory/utils"
"math"
"strings"
"sync"
"time"
@ -1122,3 +1123,27 @@ func (this *User) SetUserCaravanLvChange(session comm.IUserSession, caravanlv in
}
return this.modelUser.Change(session.GetUserId(), update)
}
func (this *User) ConsumePsAddExp(session comm.IUserSession, ps int) (errdata *pb.ErrorData) {
var (
user *pb.DBUser
)
if user = this.GetUser(session.GetUserId()); user == nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_UserNofound,
Title: pb.ErrorCode_UserNofound.ToString(),
}
return
}
ggd := this.ModuleTools.GetGlobalConf()
if ggd == nil {
return
}
//体力消耗,增加玩家经验
exp := int32(math.Abs(float64(ps))) * ggd.FightPs
user.Exp += int64(exp)
attrs := make(map[string]int32, 0)
attrs["exp"] = int32(user.Exp)
return this.AddAttributeValues(session, attrs, true)
}