Files
bl/logic/controller/user_action.go
昔念 39dc79f706 ```
feat(xml): 添加进化配置映射并更新错误码提示

- 在 `common/data/xmlres/file.go` 中添加 EVOLVMAP 用于加载进化配置
- 更新多个控制器中的金币不足错误码,统一使用骄阳余额不足错误码 `ErrSunDouInsufficient10016`
- 修改战斗逻辑中 AI 动作触发机制,并优化战斗流程
- 增加对融合材料合法性的校验
- 调整战斗动作通道缓冲区大小以提升并发处理能力
- 更新 XML 配置
2025-12-16 02:50:10 +08:00

118 lines
3.5 KiB
Go

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"
)
// 射击
func (h Controller) Aimat(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) Chat(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
}
func (h Controller) ChangePlayerColor(data *user.ChangeColorInboundInfo, c *player.Player) (result *user.ChangeColorOutboundInfo, err errorcode.ErrorCode) {
if !c.UseCoins(200) { //如果花不了200,直接返回
return nil, errorcode.ErrorCodes.ErrSunDouInsufficient10016
}
c.Info.Coins -= 50
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
}
func (h Controller) ChangePlayerDoodle(data *user.ChangeDoodleInboundInfo, c *player.Player) (result *user.ChangeDoodleOutboundInfo, err errorcode.ErrorCode) {
if !c.UseCoins(200) { //如果花不了200,直接返回
return nil, errorcode.ErrorCodes.ErrSunDouInsufficient10016
}
c.Info.Coins -= 50
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) DANCE_ACTION(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) PEOPLE_TRANSFROM(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 _, v := range data.ClothList {
result.ClothList = append(result.ClothList, model.PeopleItemInfo{ID: v, Level: 1})
}
c.Info.Clothes = result.ClothList
c.GetSpace().Broadcast(c, data.Head.CMD, result)
return
}