2025-09-20 00:17:29 +08:00
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/common/socket/errorcode"
|
2025-10-24 00:31:38 +08:00
|
|
|
"blazing/cool"
|
2025-10-20 01:39:07 +08:00
|
|
|
"blazing/logic/service/common"
|
2025-09-20 00:17:29 +08:00
|
|
|
"blazing/logic/service/player"
|
2025-10-20 01:39:07 +08:00
|
|
|
"blazing/logic/service/space"
|
2025-09-20 00:17:29 +08:00
|
|
|
"blazing/logic/service/user"
|
|
|
|
|
|
|
|
|
|
"github.com/jinzhu/copier"
|
|
|
|
|
)
|
|
|
|
|
|
2025-09-22 09:15:26 +00:00
|
|
|
// UserSimInfo 根据用户ID获取模拟用户信息
|
|
|
|
|
// data: 包含用户ID的输入信息
|
|
|
|
|
// c: 玩家对象
|
|
|
|
|
// 返回: 模拟用户信息及错误码
|
2025-09-20 00:17:29 +08:00
|
|
|
func (h Controller) UserSimInfo(data *user.SimUserInfoInboundInfo, c *player.Player) (result *user.SimUserInfoOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
|
ret := &user.SimUserInfoOutboundInfo{}
|
|
|
|
|
|
2025-09-24 12:40:13 +08:00
|
|
|
copier.Copy(ret, c.Service.Person(data.UserId))
|
2025-09-20 00:17:29 +08:00
|
|
|
return ret, 0
|
|
|
|
|
}
|
2025-09-22 09:15:26 +00:00
|
|
|
|
|
|
|
|
// UserMoreInfo 获取用户的更多信息。
|
|
|
|
|
// data: 包含用户ID的输入信息。
|
|
|
|
|
// c: 当前玩家对象。
|
|
|
|
|
// 返回: 包含用户更多信息的输出结果和错误码。
|
2025-09-20 00:17:29 +08:00
|
|
|
func (h Controller) UserMoreInfo(data *user.MoreUserInfoInboundInfo, c *player.Player) (result *user.MoreUserInfoOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
|
ret := &user.MoreUserInfoOutboundInfo{}
|
2025-09-24 12:40:13 +08:00
|
|
|
info := c.Service.Person(data.UserId)
|
2025-09-20 00:17:29 +08:00
|
|
|
copier.Copy(ret, info)
|
|
|
|
|
|
|
|
|
|
//todo 待实现
|
|
|
|
|
return ret, 0
|
|
|
|
|
}
|
2025-10-20 01:39:07 +08:00
|
|
|
|
|
|
|
|
func (h Controller) Aimat(data *user.AimatInboundInfo, c *player.Player) (result *user.AimatOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
|
|
|
|
|
|
defer space.GetSpace(c.Info.MapID).User.IterCb(func(playerID uint32, player common.PlayerI) {
|
2025-10-24 00:31:38 +08:00
|
|
|
ret := &user.AimatOutboundInfo{
|
|
|
|
|
|
|
|
|
|
ItemId: data.ItemId,
|
|
|
|
|
Point: data.Point,
|
|
|
|
|
ShootType: data.ShootType,
|
|
|
|
|
UserId: c.Info.UserID,
|
|
|
|
|
}
|
2025-10-20 01:39:07 +08:00
|
|
|
data.Head.Result = 0
|
|
|
|
|
player.SendPack(data.Head.Pack(ret))
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
2025-10-24 00:31:38 +08:00
|
|
|
return nil, -1
|
2025-10-20 01:39:07 +08:00
|
|
|
}
|
2025-10-23 01:02:19 +08:00
|
|
|
func (h Controller) Chat(data *user.ChatInboundInfo, c *player.Player) (result *user.ChatOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
|
|
2025-10-24 00:31:38 +08:00
|
|
|
defer space.GetSpace(c.Info.MapID).User.IterCb(func(playerID uint32, v common.PlayerI) {
|
|
|
|
|
result = &user.ChatOutboundInfo{
|
|
|
|
|
|
|
|
|
|
Message: string([]byte(data.Message)[:data.MessageLen-1]),
|
|
|
|
|
SenderNickname: c.Info.Nick,
|
|
|
|
|
SenderId: c.Info.UserID,
|
|
|
|
|
}
|
|
|
|
|
result.Message = cool.Filter.Replace(result.Message, '*')
|
|
|
|
|
data.Head.Result = 0
|
|
|
|
|
v.SendPack(data.Head.Pack(result))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return nil, -1
|
|
|
|
|
}
|
|
|
|
|
func (h Controller) ChangePlayerColor(data *user.ChangeColorInboundInfo, c *player.Player) (result *user.ChangeColorOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
|
c.Info.Coins -= 200
|
|
|
|
|
c.Info.Color = data.Color
|
2025-10-23 01:02:19 +08:00
|
|
|
|
|
|
|
|
defer space.GetSpace(c.Info.MapID).User.IterCb(func(playerID uint32, v common.PlayerI) {
|
2025-10-24 00:31:38 +08:00
|
|
|
data.Head.Result = 0
|
|
|
|
|
result = &user.ChangeColorOutboundInfo{
|
|
|
|
|
UserId: c.Info.UserID,
|
|
|
|
|
Color: data.Color,
|
|
|
|
|
Coins: c.Info.Coins,
|
|
|
|
|
Texture: c.Info.Texture,
|
|
|
|
|
}
|
|
|
|
|
v.SendPack(data.Head.Pack(result))
|
|
|
|
|
})
|
2025-10-23 01:02:19 +08:00
|
|
|
|
2025-10-24 00:31:38 +08:00
|
|
|
return nil, -1
|
|
|
|
|
}
|
|
|
|
|
func (h Controller) ChangePlayerDoodle(data *user.ChangeDoodleInboundInfo, c *player.Player) (result *user.ChangeDoodleOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
|
c.Info.Coins -= 200
|
|
|
|
|
c.Info.Texture = data.Id
|
|
|
|
|
c.Info.Color = data.Color
|
|
|
|
|
defer space.GetSpace(c.Info.MapID).User.IterCb(func(playerID uint32, v common.PlayerI) {
|
|
|
|
|
data.Head.Result = 0
|
|
|
|
|
result = &user.ChangeDoodleOutboundInfo{
|
|
|
|
|
UserId: c.Info.UserID,
|
|
|
|
|
Color: c.Info.Color,
|
|
|
|
|
Coins: c.Info.Coins,
|
|
|
|
|
Texture: c.Info.Texture,
|
|
|
|
|
}
|
2025-10-23 01:02:19 +08:00
|
|
|
v.SendPack(data.Head.Pack(result))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return nil, -1
|
|
|
|
|
}
|
2025-10-24 00:31:38 +08:00
|
|
|
func (h Controller) ChangeNONOColor(data *user.ChangeNONOColorInboundInfo, c *player.Player) (result *user.ChangeNONOColorOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
|
//c.Info.Coins -= 200
|
|
|
|
|
c.Info.NONO.Color = data.Color
|
|
|
|
|
|
|
|
|
|
result = &user.ChangeNONOColorOutboundInfo{
|
|
|
|
|
Sataus: c.Info.UserID,
|
|
|
|
|
Color: c.Info.Color,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result, 0
|
|
|
|
|
}
|