feat(login): 重构登录逻辑并迁移每日重置功能到 Personself 方法
将原本在 Controller.Login 中处理的每日重置逻辑(如电池、任务等)迁移到 service.Info.Personself 方法中,并移除对 gtime.Now().Time 的旧引用。同时更新了 相关的时间判断函数 IsToday,使其支持 *gtime.Time 类型。 此外,清理无用导入包,优化日志打印方式,并修复部分结构体字段定义与使用问题。
This commit is contained in:
@@ -50,6 +50,7 @@ func (h Controller) ItemUsePet(data *item.C2S_USE_PET_ITEM_OUT_OF_FIGHT, c *play
|
||||
|
||||
copier.CopyWithOption(onpet, oldpet.Data, copier.Option{DeepCopy: true})
|
||||
onpet.CatchTime = oldpetc
|
||||
onpet.EffectInfo = oldpet.Data.EffectInfo
|
||||
} else {
|
||||
hd := item.PetItemRegistry.GetHandler(data.ItemID)
|
||||
if hd == nil {
|
||||
|
||||
@@ -2,7 +2,6 @@ package controller
|
||||
|
||||
import (
|
||||
"blazing/common/data/share"
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/cool"
|
||||
"fmt"
|
||||
|
||||
@@ -17,7 +16,6 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/panjf2000/gnet/v2"
|
||||
)
|
||||
|
||||
@@ -59,7 +57,7 @@ func (h *Controller) Login(data *user.MAIN_LOGIN_IN, c gnet.Conn) (result *user.
|
||||
}
|
||||
t.Service = blservice.NewUserService(data.Head.UserID)
|
||||
t.User = service.NewBaseSysUserService()
|
||||
t.Info = t.Service.Info.Person(data.Head.UserID)
|
||||
t.Info = t.Service.Info.Personself()
|
||||
if t.Info == nil {
|
||||
defer c.Close()
|
||||
return
|
||||
@@ -67,32 +65,6 @@ func (h *Controller) Login(data *user.MAIN_LOGIN_IN, c gnet.Conn) (result *user.
|
||||
t.Info.UserID = data.Head.UserID
|
||||
t.Logintime = uint32(time.Now().Unix()) //保存时间戳
|
||||
|
||||
cool.Loger.Info(context.Background(), "用户上次重置日期", t.Info.LastResetTime.String())
|
||||
if !IsToday(t.Info.LastResetTime) { //判断是否是今天
|
||||
t.Info.LastResetTime = gtime.Now().Time
|
||||
//每天login时候检查重置时间,然后把电池,任务,挖矿重置
|
||||
//挖矿需要单独存,因为防止多开挖矿
|
||||
t.Info.TimeToday = 0 //重置电池
|
||||
|
||||
for i := 400; i < 500; i++ { //每日任务区段
|
||||
|
||||
tttL, ok := xmlres.TaskMap[i]
|
||||
if ok {
|
||||
if tttL.Type == 1 { //日常任务
|
||||
t.Info.TaskList[i-1] = 0 //重置每日任务
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for i := 0; i < 50; i++ { //每日任务区段
|
||||
t.Info.DailyResArr[i] = 0 //重置每日任务
|
||||
|
||||
}
|
||||
//defer t.Service.Talk_Reset()
|
||||
|
||||
}
|
||||
|
||||
t.CompleteLogin() //通知客户端登录成功
|
||||
|
||||
result = user.NewOutInfo() //设置登录消息
|
||||
|
||||
Reference in New Issue
Block a user