Files
bl/logic/controller/user_action.go
昔念 502d497dce ```
refactor(controller): 重构控制器函数命名和代码注释

- 重命名 EGG 函数为 EggGamePlay,更新宠物生成逻辑
- 重命名 Leiyi 函数为 GetLeiyiTrainStatus
- 重命名 Cacthpet 函数为 CatchPet,添加详细函数注释
- 为 ArenaSetOwner、ArenaFightOwner、ArenaGetInfo、ArenaUpfight、ArenaOwnerAcce
  等擂台相关函数添加注释前缀
- 重命名 PETKing 函数为 PetKing
- 重命名 FRESH_CHOICE_FIGHT_LEVEL 函数为 FreshChoiceFightLevel,添加详细参数说明
- 重命名 BuyMItem 函数为 BuyMultipleItems
- 重命名 ITEM_S
2025-12-24 19:03:11 +08:00

129 lines
3.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package controller
import (
"blazing/common/socket/errorcode"
"blazing/common/utils"
"blazing/cool"
"blazing/logic/service/item"
"blazing/logic/service/player"
"blazing/logic/service/user"
"blazing/modules/blazing/model"
)
// PlayerAim 射击
func (h Controller) PlayerAim(data *user.AimatInboundInfo, c *player.Player) (result *user.AimatOutboundInfo, err errorcode.ErrorCode) {
result = &user.AimatOutboundInfo{
ItemId: data.ItemId,
Point: data.Point,
ShootType: data.ShootType,
UserId: c.Info.UserID,
}
c.GetSpace().Broadcast(c, data.Head.CMD, result)
return
}
func (h Controller) PlayerChat(data *user.ChatInboundInfo, c *player.Player) (result *user.ChatOutboundInfo, err errorcode.ErrorCode) {
result = &user.ChatOutboundInfo{
Message: utils.RemoveLast(data.Message),
SenderNickname: c.Info.Nick,
SenderId: c.Info.UserID,
}
result.Message = cool.Filter.Replace(result.Message, '*')
c.GetSpace().Broadcast(c, data.Head.CMD, result)
return
}
// ChangePlayerColor 修改玩家颜色消耗50赛尔豆
func (h Controller) ChangePlayerColor(data *user.ChangeColorInboundInfo, c *player.Player) (result *user.ChangeColorOutboundInfo, err errorcode.ErrorCode) {
const changeColorCost = 50
if !c.UseCoins(changeColorCost) {
return nil, errorcode.ErrorCodes.ErrSunDouInsufficient10016
}
c.Info.Coins -= changeColorCost
c.Info.Color = data.Color
c.Info.Texture = 0
result = &user.ChangeColorOutboundInfo{
UserId: c.Info.UserID,
Color: data.Color,
Coins: c.Info.Coins,
Texture: c.Info.Texture,
}
c.GetSpace().Broadcast(c, data.Head.CMD, result)
return
}
// ChangePlayerDoodle 修改玩家涂鸦消耗50赛尔豆
func (h Controller) ChangePlayerDoodle(data *user.ChangeDoodleInboundInfo, c *player.Player) (result *user.ChangeDoodleOutboundInfo, err errorcode.ErrorCode) {
const changeDoodleCost = 50
if !c.UseCoins(changeDoodleCost) {
return nil, errorcode.ErrorCodes.ErrSunDouInsufficient10016
}
c.Info.Coins -= changeDoodleCost
c.Info.Texture = data.Id
c.Info.Color = data.Color
result = &user.ChangeDoodleOutboundInfo{
UserId: c.Info.UserID,
Color: c.Info.Color,
Coins: c.Info.Coins,
Texture: c.Info.Texture,
}
c.GetSpace().Broadcast(c, data.Head.CMD, result)
return
}
func (h Controller) ChangeNONOColor(data *user.ChangeNONOColorInboundInfo, c *player.Player) (result *user.ChangeNONOColorOutboundInfo, err errorcode.ErrorCode) {
//c.Info.Coins -= 200
c.Info.NONO.NonoColor = data.Color
result = &user.ChangeNONOColorOutboundInfo{
Sataus: c.Info.UserID,
Color: c.Info.Color,
}
c.GetSpace().Broadcast(c, data.Head.CMD, result)
return
}
func (h Controller) DanceAction(data *user.C2SDanceAction, c *player.Player) (result *user.S2CDanceAction, err errorcode.ErrorCode) {
result = &user.S2CDanceAction{
Type: data.Type,
UserID: c.Info.UserID,
}
c.GetSpace().Broadcast(c, data.Head.CMD, result)
return
}
func (h Controller) PeopleTransform(data *user.C2SPEOPLE_TRANSFROM, c *player.Player) (result *user.S2CPEOPLE_TRANSFROM, err errorcode.ErrorCode) {
result = &user.S2CPEOPLE_TRANSFROM{
SuitID: data.SuitID,
UserID: c.Info.UserID,
}
c.GetSpace().Broadcast(c, data.Head.CMD, result)
return
}
func (h Controller) ChangePlayerCloth(data *item.ChangePlayerClothInboundInfo, c *player.Player) (result *item.ChangePlayerClothOutboundInfo, err errorcode.ErrorCode) {
result = &item.ChangePlayerClothOutboundInfo{
UserID: c.Info.UserID,
ClothList: make([]model.PeopleItemInfo, 0),
}
for _, clothID := range data.ClothList {
result.ClothList = append(result.ClothList, model.PeopleItemInfo{ID: clothID, Level: 1})
}
c.Info.Clothes = result.ClothList
c.GetSpace().Broadcast(c, data.Head.CMD, result)
return
}