体力恢复调整
This commit is contained in:
parent
f711ac613c
commit
6e89c06973
@ -643,6 +643,8 @@ const (
|
|||||||
//种族塔
|
//种族塔
|
||||||
Reddot29101 ReddotType = 29101 // 今日剩余可挑战关卡:x
|
Reddot29101 ReddotType = 29101 // 今日剩余可挑战关卡:x
|
||||||
|
|
||||||
|
Reddot30100 ReddotType = 30100 // 体力恢复
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type TaskType int32
|
type TaskType int32
|
||||||
|
@ -11,7 +11,7 @@ func (this *apiComp) GetCheck(session comm.IUserSession, req *pb.ReddotGetReq) (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// /获取系统公告
|
// 红点数据
|
||||||
func (this *apiComp) Get(session comm.IUserSession, req *pb.ReddotGetReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) Get(session comm.IUserSession, req *pb.ReddotGetReq) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
reddot map[int32]*pb.ReddotItem = make(map[int32]*pb.ReddotItem)
|
reddot map[int32]*pb.ReddotItem = make(map[int32]*pb.ReddotItem)
|
||||||
@ -92,6 +92,10 @@ func (this *apiComp) Get(session comm.IUserSession, req *pb.ReddotGetReq) (errda
|
|||||||
for k, v := range this.module.gourmet.Reddot(session, _rid) {
|
for k, v := range this.module.gourmet.Reddot(session, _rid) {
|
||||||
reddot[int32(k)] = v
|
reddot[int32(k)] = v
|
||||||
}
|
}
|
||||||
|
case comm.Reddot30100:
|
||||||
|
for k, v := range this.module.ModuleUser.Reddot(session, _rid) {
|
||||||
|
reddot[int32(k)] = v
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), "get", &pb.ReddotGetAllResp{Reddot: reddot})
|
session.SendMsg(string(this.module.GetType()), "get", &pb.ReddotGetAllResp{Reddot: reddot})
|
||||||
|
@ -128,6 +128,16 @@ func (this *Turntable) EventUserLogin(session comm.IUserSession) {
|
|||||||
turntable *pb.DBTurntable
|
turntable *pb.DBTurntable
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
endTime := this.ModuleTools.GetGlobalConf().SignAccount
|
||||||
|
if user := this.ModuleUser.GetUser(session.GetUserId()); user != nil {
|
||||||
|
if configure.Now().Unix() > user.Ctime+int64(endTime*24*3600) {
|
||||||
|
bEnd = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !bEnd {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if turntable, err = this.modelt.getUserTurntable(session.GetUserId()); err != nil {
|
if turntable, err = this.modelt.getUserTurntable(session.GetUserId()); err != nil {
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -135,13 +145,8 @@ func (this *Turntable) EventUserLogin(session comm.IUserSession) {
|
|||||||
if turntable.Reward {
|
if turntable.Reward {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
endTime := 28 // 等配置
|
|
||||||
if user := this.ModuleUser.GetUser(session.GetUserId()); user != nil {
|
// 活动结束 活动道具转换
|
||||||
if configure.Now().Unix() > user.Ctime+int64(endTime*24*3600) {
|
|
||||||
bEnd = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if bEnd { // 活动结束 活动道具转换
|
|
||||||
t := this.ModuleTools.GetGlobalConf().VenturegiftsDraw
|
t := this.ModuleTools.GetGlobalConf().VenturegiftsDraw
|
||||||
var reward []*pb.UserAssets
|
var reward []*pb.UserAssets
|
||||||
if item, err := this.configure.GetItemConfigureData(t); err != nil {
|
if item, err := this.configure.GetItemConfigureData(t); err != nil {
|
||||||
@ -163,5 +168,4 @@ func (this *Turntable) EventUserLogin(session comm.IUserSession) {
|
|||||||
this.modelt.Change(session.GetUserId(), map[string]interface{}{
|
this.modelt.Change(session.GetUserId(), map[string]interface{}{
|
||||||
"reward": turntable.Reward,
|
"reward": turntable.Reward,
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (err
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.module.ModuleHero.CheckPeachReward(session, user.Ctime)
|
this.module.ModuleHero.CheckPeachReward(session, user.Ctime)
|
||||||
// this.module.RecoverUserPsStart(user.Uid)
|
go this.module.RecoverUserPsStart(session.Clone())
|
||||||
// 日常登录任务
|
// 日常登录任务
|
||||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype7, 1))
|
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype7, 1))
|
||||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype230, 1, int32(configure.Now().Weekday())))
|
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype230, 1, int32(configure.Now().Weekday())))
|
||||||
|
@ -64,6 +64,7 @@ type User struct {
|
|||||||
modelSign *ModelSign // 签到
|
modelSign *ModelSign // 签到
|
||||||
timerLock sync.Mutex
|
timerLock sync.Mutex
|
||||||
timerMap map[string]*time.Ticker
|
timerMap map[string]*time.Ticker
|
||||||
|
reddot comm.IReddot
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *User) GetType() core.M_Modules {
|
func (this *User) GetType() core.M_Modules {
|
||||||
@ -97,7 +98,10 @@ func (this *User) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.chat = module.(comm.IChat)
|
this.chat = module.(comm.IChat)
|
||||||
|
if module, err = this.service.GetModule(comm.ModuleReddot); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.reddot = module.(comm.IReddot)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -946,31 +950,61 @@ func (this *User) BingoSetUserLv(session comm.IUserSession, lv int32) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 玩家体力恢复
|
// 玩家体力恢复
|
||||||
func (this *User) RecoverUserPsStart(uid string) {
|
func (this *User) RecoverUserPsStart(session comm.IUserSession) (recoverTime int64) {
|
||||||
go func(uid string) {
|
var (
|
||||||
timeSec := time.NewTicker(time.Second * 30)
|
yu int32
|
||||||
this.timerLock.Lock()
|
add int32
|
||||||
this.timerMap[uid] = timeSec
|
changed int32
|
||||||
this.timerLock.Unlock()
|
)
|
||||||
for {
|
// 推送红点信息
|
||||||
select {
|
re := this.ModuleTools.GetGlobalConf().PsRecovery
|
||||||
case <-timeSec.C:
|
if re <= 0 {
|
||||||
this.recoverUserPs(uid)
|
return
|
||||||
}
|
}
|
||||||
|
u := this.GetUser(session.GetUserId())
|
||||||
|
if u == nil {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}(uid)
|
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
|
||||||
|
}
|
||||||
|
} 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{
|
||||||
func (this *User) stopTicker(uid string) {
|
Rid: int32(comm.Reddot30100),
|
||||||
if t, ok := this.timerMap[uid]; ok {
|
Nextchanagetime: u.LastRecoverPsSec + int64(re),
|
||||||
if t != nil {
|
})
|
||||||
t.Stop()
|
session.Push()
|
||||||
this.timerLock.Lock()
|
|
||||||
delete(this.timerMap, uid)
|
|
||||||
this.timerLock.Unlock()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
recoverTime = u.LastRecoverPsSec + int64(re)
|
||||||
|
return recoverTime
|
||||||
}
|
}
|
||||||
|
|
||||||
// 玩家体力恢复
|
// 玩家体力恢复
|
||||||
@ -1220,7 +1254,15 @@ func (this *User) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (red
|
|||||||
Total: 1,
|
Total: 1,
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
case comm.Reddot30100: // 体力恢复
|
||||||
|
t := this.RecoverUserPsStart(session)
|
||||||
|
reddot[comm.Reddot30100] = &pb.ReddotItem{
|
||||||
|
Rid: int32(comm.Reddot30100),
|
||||||
|
Nextchanagetime: t,
|
||||||
}
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,17 @@ func (this *apiComp) SignGetList(session comm.IUserSession, req *pb.VentureSignG
|
|||||||
if errdata = this.SignGetListCheck(session, req); errdata != nil {
|
if errdata = this.SignGetListCheck(session, req); errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
endTime := this.module.ModuleTools.GetGlobalConf().SignAccount
|
||||||
|
if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil {
|
||||||
|
if configure.Now().Unix() > user.Ctime+int64(endTime*24*3600) {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ActivityOver,
|
||||||
|
Title: pb.ErrorCode_ActivityOver.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
if sign, err = this.module.ModelSign.getUserSign(session.GetUserId()); err != nil {
|
if sign, err = this.module.ModelSign.getUserSign(session.GetUserId()); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
|
Loading…
Reference in New Issue
Block a user