refactor(controller): 重构控制器代码结构并优化战斗状态检查

- 添加包级注释说明controller包的功能和架构设计
- 重命名Controller结构体注释,使其更清晰明了
- 添加ParseCmd函数的
This commit is contained in:
2025-12-23 10:46:17 +08:00
parent 83ee9fba43
commit 9baca27033
11 changed files with 195 additions and 150 deletions

View File

@@ -35,14 +35,19 @@ func (h Controller) Chat(data *user.ChatInboundInfo, c *player.Player) (result *
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,直接返回
// 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 -= 50
c.Info.Coins -= changeColorCost
c.Info.Color = data.Color
c.Info.Texture = 0
result = &user.ChangeColorOutboundInfo{
UserId: c.Info.UserID,
Color: data.Color,
@@ -53,13 +58,19 @@ func (h Controller) ChangePlayerColor(data *user.ChangeColorInboundInfo, c *play
return
}
// ChangePlayerDoodle 修改玩家涂鸦消耗50赛尔豆
func (h Controller) ChangePlayerDoodle(data *user.ChangeDoodleInboundInfo, c *player.Player) (result *user.ChangeDoodleOutboundInfo, err errorcode.ErrorCode) {
if !c.UseCoins(200) { //如果花不了200,直接返回
const changeDoodleCost = 50
if !c.UseCoins(changeDoodleCost) {
return nil, errorcode.ErrorCodes.ErrSunDouInsufficient10016
}
c.Info.Coins -= 50
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,