上传体力修复
This commit is contained in:
parent
fce803d2ef
commit
fe22b55d46
@ -580,7 +580,8 @@ func (this *User) change(session comm.IUserSession, attrs map[string]int32) (atn
|
|||||||
}
|
}
|
||||||
change.Ps += add
|
change.Ps += add
|
||||||
userEx.ConsumPs += -add
|
userEx.ConsumPs += -add
|
||||||
this.ModuleUiGame.HDPSTodayConsum(session.GetUserId(), userEx.ConsumPs)
|
this.recoverUserPs(user)
|
||||||
|
go this.ModuleUiGame.HDPSTodayConsum(session.GetUserId(), userEx.ConsumPs)
|
||||||
} else {
|
} else {
|
||||||
if change.Ps+add > ggd.PsUl {
|
if change.Ps+add > ggd.PsUl {
|
||||||
change.Ps = ggd.PsUl
|
change.Ps = ggd.PsUl
|
||||||
@ -709,6 +710,7 @@ func (this *User) change(session comm.IUserSession, attrs map[string]int32) (atn
|
|||||||
comm.Integral: change.Integral,
|
comm.Integral: change.Integral,
|
||||||
comm.Profit: change.Profit,
|
comm.Profit: change.Profit,
|
||||||
comm.Deposit: change.Deposit,
|
comm.Deposit: change.Deposit,
|
||||||
|
"lastRecoverPsSec": user.LastRecoverPsSec,
|
||||||
}
|
}
|
||||||
|
|
||||||
//user ex
|
//user ex
|
||||||
@ -964,138 +966,107 @@ func (this *User) BingoSetUserLv(session comm.IUserSession, lv int32) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// // 玩家体力恢复
|
||||||
|
// func (this *User) RecoverUserPsStart(session comm.IUserSession) (recoverTime int64) {
|
||||||
|
// var (
|
||||||
|
// yu int32
|
||||||
|
// add int32
|
||||||
|
// changed int32
|
||||||
|
// )
|
||||||
|
// // 推送红点信息
|
||||||
|
// re := this.ModuleTools.GetGlobalConf().PsRecovery
|
||||||
|
// if re <= 0 {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// u, err := this.GetUser(session.GetUserId())
|
||||||
|
// if err != nil {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// if u.LastRecoverPsSec == 0 {
|
||||||
|
// u.LastRecoverPsSec = configure.Now().Unix()
|
||||||
|
// }
|
||||||
|
// diff := configure.Now().Unix() - u.LastRecoverPsSec
|
||||||
|
// yu = int32(diff / int64(re))
|
||||||
|
// if yu > 0 {
|
||||||
|
// pconf := this.configure.GetPlayerlvConf(u.Lv)
|
||||||
|
// if pconf == nil {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// if u.Ps < pconf.PsCeiling {
|
||||||
|
// total := u.Ps + yu
|
||||||
|
// if total > pconf.PsCeiling {
|
||||||
|
// add = pconf.PsCeiling - u.Ps
|
||||||
|
// changed = pconf.PsCeiling
|
||||||
|
// } else {
|
||||||
|
// add = yu
|
||||||
|
// changed = total
|
||||||
|
// u.LastRecoverPsSec += int64(yu * re)
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// add = 0
|
||||||
|
// }
|
||||||
|
// //u.LastRecoverPsSec = time.Now().Unix()
|
||||||
|
// update := map[string]interface{}{}
|
||||||
|
// if add > 0 {
|
||||||
|
// u.Ps += add
|
||||||
|
// update["ps"] = u.Ps
|
||||||
|
// update["lastRecoverPsSec"] = u.LastRecoverPsSec
|
||||||
|
// }
|
||||||
|
// if err := this.modelUser.Change(u.Uid, update); err == nil {
|
||||||
|
// if changed > 0 {
|
||||||
|
// this.reddot.PushReddot(session, &pb.ReddotItem{
|
||||||
|
// Rid: int32(comm.Reddot30100),
|
||||||
|
// Nextchanagetime: u.LastRecoverPsSec + int64(re),
|
||||||
|
// })
|
||||||
|
// session.Push()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// recoverTime = u.LastRecoverPsSec + int64(re)
|
||||||
|
// return recoverTime
|
||||||
|
// }
|
||||||
|
|
||||||
// 玩家体力恢复
|
// 玩家体力恢复
|
||||||
func (this *User) RecoverUserPsStart(session comm.IUserSession) (recoverTime int64) {
|
func (this *User) recoverUserPs(user *pb.DBUser) (total int32, nexttime int64) {
|
||||||
var (
|
var (
|
||||||
yu int32
|
yu int32
|
||||||
add int32
|
add int32
|
||||||
changed int32
|
|
||||||
)
|
)
|
||||||
// 推送红点信息
|
|
||||||
re := this.ModuleTools.GetGlobalConf().PsRecovery
|
|
||||||
if re <= 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
u, err := this.GetUser(session.GetUserId())
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
diff := time.Now().Unix() - u.LastRecoverPsSec
|
|
||||||
yu = int32(diff / int64(re))
|
|
||||||
if yu > 0 {
|
|
||||||
pconf := this.configure.GetPlayerlvConf(u.Lv)
|
|
||||||
if pconf == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if u.Ps < pconf.PsCeiling {
|
|
||||||
total := u.Ps + yu
|
|
||||||
if total > pconf.PsCeiling {
|
|
||||||
add = pconf.PsCeiling - u.Ps
|
|
||||||
changed = pconf.PsCeiling
|
|
||||||
} else {
|
|
||||||
add = yu
|
|
||||||
changed = total
|
|
||||||
if u.LastRecoverPsSec != 0 {
|
|
||||||
u.LastRecoverPsSec += int64(yu * re)
|
|
||||||
if u.LastRecoverPsSec > time.Now().Unix() {
|
|
||||||
u.LastRecoverPsSec = time.Now().Unix()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
add = 0
|
|
||||||
}
|
|
||||||
//u.LastRecoverPsSec = time.Now().Unix()
|
|
||||||
update := map[string]interface{}{}
|
|
||||||
if add > 0 {
|
|
||||||
u.Ps += add
|
|
||||||
update["ps"] = u.Ps
|
|
||||||
update["lastRecoverPsSec"] = u.LastRecoverPsSec
|
|
||||||
}
|
|
||||||
if err := this.modelUser.Change(u.Uid, update); err == nil {
|
|
||||||
if changed > 0 {
|
|
||||||
this.reddot.PushReddot(session, &pb.ReddotItem{
|
|
||||||
Rid: int32(comm.Reddot30100),
|
|
||||||
Nextchanagetime: u.LastRecoverPsSec + int64(re),
|
|
||||||
})
|
|
||||||
session.Push()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
recoverTime = u.LastRecoverPsSec + int64(re)
|
|
||||||
return recoverTime
|
|
||||||
}
|
|
||||||
|
|
||||||
// 玩家体力恢复
|
|
||||||
func (this *User) recoverUserPs(uid string) {
|
|
||||||
if this.IsCross() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
u, err := this.GetUser(uid)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ggd := this.ModuleTools.GetGlobalConf()
|
ggd := this.ModuleTools.GetGlobalConf()
|
||||||
if ggd == nil {
|
if ggd == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
pconf := this.configure.GetPlayerlvConf(user.Lv)
|
||||||
var (
|
if pconf == nil {
|
||||||
yu int32
|
return
|
||||||
add int32
|
|
||||||
changed int32
|
|
||||||
)
|
|
||||||
cur := time.Now().Unix()
|
|
||||||
if u.LastRecoverPsSec == 0 {
|
|
||||||
update := map[string]interface{}{
|
|
||||||
"lastRecoverPsSec": cur,
|
|
||||||
}
|
}
|
||||||
this.modelUser.Change(u.Uid, update)
|
if user.Ps >= pconf.PsCeiling {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
total = pconf.PsCeiling
|
||||||
|
cur := time.Now().Unix()
|
||||||
|
if user.LastRecoverPsSec == 0 {
|
||||||
|
user.LastRecoverPsSec = cur
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
diff := cur - u.LastRecoverPsSec
|
diff := cur - user.LastRecoverPsSec
|
||||||
yu = int32(diff / int64(ggd.PsRecovery))
|
yu = int32(diff / int64(ggd.PsRecovery))
|
||||||
}
|
}
|
||||||
|
|
||||||
if yu > 0 {
|
if yu > 0 {
|
||||||
pconf := this.configure.GetPlayerlvConf(u.Lv)
|
total := user.Ps + yu
|
||||||
if pconf == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if u.Ps < pconf.PsCeiling {
|
|
||||||
total := u.Ps + yu
|
|
||||||
if total > pconf.PsCeiling {
|
if total > pconf.PsCeiling {
|
||||||
add = pconf.PsCeiling - u.Ps
|
add = pconf.PsCeiling - user.Ps
|
||||||
changed = pconf.PsCeiling
|
|
||||||
} else {
|
} else {
|
||||||
add = yu
|
add = yu
|
||||||
changed = total
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
add = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
update := map[string]interface{}{
|
|
||||||
"lastRecoverPsSec": cur,
|
|
||||||
}
|
|
||||||
if add > 0 {
|
|
||||||
u.Ps += add
|
|
||||||
update["ps"] = u.Ps
|
|
||||||
}
|
|
||||||
if err := this.modelUser.Change(u.Uid, update); err == nil {
|
|
||||||
if changed > 0 {
|
|
||||||
if err := this.SendMsgToUser(string(this.GetType()), "pschanged",
|
|
||||||
&pb.UserPsChangedPush{Ps: changed}, u.Uid); err != nil {
|
|
||||||
this.Error("玩家体力变化 UserPsChangedPush推送失败",
|
|
||||||
log.Field{Key: "uid", Value: u.Uid},
|
|
||||||
log.Field{Key: comm.ResPs, Value: changed},
|
|
||||||
log.Field{Key: "err", Value: err.Error()},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
user.LastRecoverPsSec = cur
|
||||||
|
user.Ps += add
|
||||||
|
nexttime = user.LastRecoverPsSec + int64(ggd.PsRecovery)
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *User) BingoSetUserVipLv(session comm.IUserSession, lv int32) (errdata *pb.ErrorData) {
|
func (this *User) BingoSetUserVipLv(session comm.IUserSession, lv int32) (errdata *pb.ErrorData) {
|
||||||
@ -1256,6 +1227,7 @@ func (this *User) RemainingPS(uid string) (ps int32) {
|
|||||||
// 查询每日红点信息
|
// 查询每日红点信息
|
||||||
func (this *User) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) {
|
func (this *User) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) {
|
||||||
var (
|
var (
|
||||||
|
user *pb.DBUser
|
||||||
info *pb.DBSign
|
info *pb.DBSign
|
||||||
progress int32
|
progress int32
|
||||||
err error
|
err error
|
||||||
@ -1279,10 +1251,17 @@ func (this *User) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (red
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
case comm.Reddot30100: // 体力恢复
|
case comm.Reddot30100: // 体力恢复
|
||||||
t := this.RecoverUserPsStart(session)
|
user, err = this.GetUser(session.GetUserId())
|
||||||
|
if err != nil {
|
||||||
|
this.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
total, t := this.recoverUserPs(user)
|
||||||
reddot[comm.Reddot30100] = &pb.ReddotItem{
|
reddot[comm.Reddot30100] = &pb.ReddotItem{
|
||||||
Rid: int32(comm.Reddot30100),
|
Rid: int32(comm.Reddot30100),
|
||||||
Nextchanagetime: t,
|
Nextchanagetime: t,
|
||||||
|
Progress: user.Ps,
|
||||||
|
Total: total,
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user