Compare commits
3 Commits
601e45a4bc
...
ee97d178ca
Author | SHA1 | Date | |
---|---|---|---|
ee97d178ca | |||
f10ca5b24c | |||
d8a25f4459 |
@ -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) (addExp int32, errdata *pb.ErrorData)
|
||||
}
|
||||
//武器模块
|
||||
IEquipment interface {
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"go_dreamfactory/sys/configure"
|
||||
"go_dreamfactory/sys/db"
|
||||
"go_dreamfactory/utils"
|
||||
"math"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@ -1122,3 +1123,35 @@ 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) (addExp int32, errdata *pb.ErrorData) {
|
||||
if ps <= 0 {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
//体力消耗,增加玩家经验
|
||||
addExp = int32(math.Abs(float64(ps))) * ggd.FightPs
|
||||
user.Exp += int64(addExp)
|
||||
|
||||
attrs := make(map[string]int32, 0)
|
||||
attrs["exp"] = int32(user.Exp)
|
||||
return addExp, this.AddAttributeValues(session, attrs, true)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user