Files
bl/logic/controller/user_info.go
xinian a5485de510
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
1
2026-02-10 22:09:15 +08:00

60 lines
2.1 KiB
Go

package controller
import (
"blazing/common/socket/errorcode"
"blazing/logic/service/item"
"blazing/logic/service/player"
"blazing/logic/service/user"
"github.com/jinzhu/copier"
)
// GetUserSimInfo 根据用户ID获取模拟用户信息
// data: 包含用户ID的输入信息
// player: 玩家对象
// 返回: 模拟用户信息及错误码
func (h Controller) GetUserSimInfo(data *user.SimUserInfoInboundInfo, player *player.Player) (result *user.SimUserInfoOutboundInfo, err errorcode.ErrorCode) {
result = &user.SimUserInfoOutboundInfo{}
copier.Copy(result, player.Service.Info.Person(data.UserId).Data)
return result, 0
}
// GetUserMoreInfo 获取用户的更多信息
// data: 包含用户ID的输入信息
// player: 当前玩家对象
// 返回: 包含用户更多信息的输出结果和错误码
func (h Controller) GetUserMoreInfo(data *user.MoreUserInfoInboundInfo, player *player.Player) (result *user.MoreUserInfoOutboundInfo, err errorcode.ErrorCode) {
result = &user.MoreUserInfoOutboundInfo{}
info := player.Service.Info.Person(data.UserId)
copier.CopyWithOption(result, info.Data, copier.Option{IgnoreEmpty: true, DeepCopy: true})
//todo 待实现
return result, 0
}
// GetPlayerGoldCount 获取玩家金币数量
// data: 输入信息(无实际内容)
// player: 当前玩家对象
// 返回: 玩家金币和代币数量及错误码
func (h Controller) GetPlayerGoldCount(data *item.GoldOnlineRemainInboundInfo, player *player.Player) (result *item.GoldOnlineRemainOutboundInfo, err errorcode.ErrorCode) {
return &item.GoldOnlineRemainOutboundInfo{
GoldNumber: uint32(player.User.GetGold(uint(player.Info.UserID))),
Coin: player.Info.Coins,
}, 0
}
// GetPlayerExp 获取玩家经验值
// data: 输入信息(无实际内容)
// player: 当前玩家对象
// 返回: 玩家总经验值及错误码
func (h Controller) GetPlayerExp(data *item.ExpTotalRemainInboundInfo, player *player.Player) (result *item.ExpTotalRemainOutboundInfo, err errorcode.ErrorCode) {
return &item.ExpTotalRemainOutboundInfo{
TotalExp: uint32(player.Info.ExpPool),
}, 0
}