修改部分代码
This commit is contained in:
@@ -16,6 +16,16 @@ import (
|
||||
"github.com/gogf/gf/v2/os/glog"
|
||||
)
|
||||
|
||||
func IsToday(t time.Time) bool {
|
||||
// 获取当前时间
|
||||
now := time.Now()
|
||||
|
||||
// 比较年、月、日是否相同
|
||||
return t.Year() == now.Year() &&
|
||||
t.Month() == now.Month() &&
|
||||
t.Day() == now.Day()
|
||||
}
|
||||
|
||||
// 处理命令: 1001
|
||||
func (h *Controller) Login(data *login.InInfo, c *socket.Conn) (result *login.OutInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
|
||||
@@ -27,7 +37,17 @@ func (h *Controller) Login(data *login.InInfo, c *socket.Conn) (result *login.Ou
|
||||
t.Info.UserID = data.Head.UserID
|
||||
t.Onlinetime = uint32(time.Now().Unix()) //保存时间戳
|
||||
share.ShareManager.SetUserOnline(data.Head.UserID, h.Port) //设置用户登录服务器
|
||||
t.CompleteLogin() //通知客户端登录成功
|
||||
|
||||
if !IsToday(t.Info.LastResetTime) { //判断是否是今天
|
||||
t.Info.LastResetTime = time.Now()
|
||||
//每天login时候检查重置时间,然后把电池,任务,挖矿重置
|
||||
t.Info.TimeToday = 0 //重置电池
|
||||
for i := 400; i < 500; i++ {//每日任务区段
|
||||
t.Info.TaskList[i] = 0 //重置每日任务
|
||||
}
|
||||
}
|
||||
|
||||
t.CompleteLogin() //通知客户端登录成功
|
||||
|
||||
glog.Debug(context.Background(), "登录成功,初始地图 人数:", space.GetSpace(t.Info.MapID).Len())
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"blazing/common/data/socket"
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/blazing/service"
|
||||
)
|
||||
|
||||
@@ -25,6 +26,33 @@ func (h *Controller) PetRelease(
|
||||
c *socket.Player) (
|
||||
result *pet.PetReleaseOutboundInfo,
|
||||
err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
//放入背包=数据库置1+添加到背包+pet release发包 仓库=数据库置0+移除背包 设置首发等于取到首发精灵后重新排序
|
||||
//这里只修改,因为添加和移除背包在宠物获取时已经做了
|
||||
result = &pet.PetReleaseOutboundInfo{}
|
||||
result.PetInfo = make([]model.PetInfo, 0)
|
||||
t := service.NewUserService(c.Info.UserID).PetM(int(data.CatchTime), int(data.Flag))
|
||||
switch data.Flag {
|
||||
case 0:
|
||||
//todo 仓库
|
||||
removeIndex := -1
|
||||
for i, v := range c.Info.PetList {
|
||||
if v.CatchTime == uint32(data.CatchTime) {
|
||||
removeIndex = i
|
||||
break // 只移除第一个匹配值,若需移除所有,可省略 break 继续循环
|
||||
}
|
||||
|
||||
return nil, 0
|
||||
}
|
||||
if removeIndex != -1 {
|
||||
c.Info.PetList = append(c.Info.PetList[:removeIndex], c.Info.PetList[removeIndex+1:]...)
|
||||
}
|
||||
result.FirstPetTime = c.Info.PetList[0].CatchTime //设置首发
|
||||
|
||||
case 1:
|
||||
//todo 背包
|
||||
PetAdd(c, t)
|
||||
result.PetInfo = append(result.PetInfo, t)
|
||||
}
|
||||
|
||||
//service.NewUserService(c.Info.UserID).PetAdd( *r)
|
||||
return result, 0
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package controller
|
||||
import (
|
||||
"blazing/common/data/socket"
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/common/socket/handler"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/task"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/blazing/service"
|
||||
@@ -15,9 +17,9 @@ import (
|
||||
*/
|
||||
func (h Controller) AcceptTask(data *task.AcceptTaskInboundInfo, c *socket.Player) (result *task.AcceptTaskOutboundInfo, err errorcode.ErrorCode) {
|
||||
//isdaliy := false
|
||||
if data.Head.CMD != 2201 { //判断是每日任务
|
||||
//isdaliy = true
|
||||
}
|
||||
// if data.Head.CMD != 2201 { //判断是每日任务
|
||||
// //isdaliy = true
|
||||
// }
|
||||
|
||||
if c.Info.TaskList[data.TaskId] == 0 {
|
||||
c.Info.TaskList[data.TaskId] = 1
|
||||
@@ -32,10 +34,10 @@ func (h Controller) AcceptTask(data *task.AcceptTaskInboundInfo, c *socket.Playe
|
||||
* 更新任务步骤
|
||||
*/
|
||||
func (h Controller) AddTaskBuf(data *task.AddTaskBufInboundInfo, c *socket.Player) (result *task.AddTaskBufOutboundInfo, err errorcode.ErrorCode) {
|
||||
isdaliy := false
|
||||
if data.Head.CMD != 2204 { //判断是每日任务
|
||||
isdaliy = true
|
||||
}
|
||||
// isdaliy := false
|
||||
// if data.Head.CMD != 2204 { //判断是每日任务
|
||||
// isdaliy = true
|
||||
// }
|
||||
service.NewUserService(c.Info.UserID).TaskExec(func(ttt []model.TaskInfo) []model.TaskInfo {
|
||||
var ttt2 []model.TaskInfo
|
||||
for _, v := range ttt {
|
||||
@@ -47,7 +49,7 @@ func (h Controller) AddTaskBuf(data *task.AddTaskBufInboundInfo, c *socket.Playe
|
||||
}
|
||||
|
||||
return ttt2
|
||||
}, isdaliy)
|
||||
})
|
||||
|
||||
return &task.AddTaskBufOutboundInfo{}, 0
|
||||
}
|
||||
@@ -93,7 +95,7 @@ func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *socket.
|
||||
r := model.GenPetInfo(1, 1, 1, 1, 1, 5)
|
||||
result.CaptureTime = r.CatchTime
|
||||
result.PetTypeId = r.ID
|
||||
service.NewUserService(c.Info.UserID).PetAdd(r.CatchTime, 1, *r)
|
||||
PetAdd(c, *r)
|
||||
}
|
||||
if data.TaskId == 87 { //新手注册任务
|
||||
|
||||
@@ -113,10 +115,10 @@ func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *socket.
|
||||
* 获取任务状态
|
||||
*/
|
||||
func (h Controller) Get_Task_Buf(data *task.GetTaskBufInboundInfo, c *socket.Player) (result *task.GetTaskBufOutboundInfo, err errorcode.ErrorCode) {
|
||||
isdaliy := false
|
||||
if data.Head.CMD == 2203 { //判断不是每日任务
|
||||
isdaliy = true
|
||||
}
|
||||
// isdaliy := false
|
||||
// if data.Head.CMD == 2203 { //判断不是每日任务
|
||||
// isdaliy = true
|
||||
// }
|
||||
|
||||
service.NewUserService(c.Info.UserID).TaskExec(func(ttt []model.TaskInfo) []model.TaskInfo {
|
||||
var ttt2 = make([]model.TaskInfo, 500)
|
||||
@@ -130,7 +132,7 @@ func (h Controller) Get_Task_Buf(data *task.GetTaskBufInboundInfo, c *socket.Pla
|
||||
}
|
||||
|
||||
return ttt2
|
||||
}, isdaliy)
|
||||
})
|
||||
|
||||
return result, 0
|
||||
}
|
||||
@@ -140,11 +142,22 @@ func (h Controller) Get_Task_Buf(data *task.GetTaskBufInboundInfo, c *socket.Pla
|
||||
*/
|
||||
func (h Controller) Delete_Task(data *task.DeleteTaskInboundInfo, c *socket.Player) (result *task.DeleteTaskOutboundInfo, err errorcode.ErrorCode) {
|
||||
|
||||
if data.Head.CMD == 2205 { //判断不是每日任务
|
||||
// if data.Head.CMD == 2205 { //判断不是每日任务
|
||||
|
||||
} else {
|
||||
// } else {
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
return &task.DeleteTaskOutboundInfo{}, 0
|
||||
}
|
||||
|
||||
// 添加精灵
|
||||
func PetAdd(c *socket.Player, y model.PetInfo) {
|
||||
c.Info.PetList = append(c.Info.PetList, y)
|
||||
|
||||
service.NewUserService(c.Info.UserID).PetAdd(y)
|
||||
t := handler.NewTomeeHeader(2304, c.Info.UserID)
|
||||
c.SendPack(t.Pack(&pet.PetReleaseOutboundInfo{PetInfo: []model.PetInfo{y}}))
|
||||
|
||||
//return lw.IsLogin
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user