73 lines
1.9 KiB
Go
73 lines
1.9 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
|
|
"blazing/logic/service/fight"
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/logic/service/player"
|
|
)
|
|
|
|
// 准备战斗
|
|
func (h Controller) OnReadyToFight(data *fight.ReadyToFightInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
c.FightC.ReadyFight(c)
|
|
return nil, -1
|
|
}
|
|
|
|
// 使用技能包
|
|
func (h Controller) UseSkill(data *fight.UseSkillInInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
if c.FightC != nil {
|
|
c.FightC.UseSkill(c, int32(data.SkillId))
|
|
}
|
|
|
|
return nil, 0
|
|
}
|
|
|
|
// 战斗逃跑
|
|
func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
if c.FightC == nil {
|
|
|
|
return nil, 0
|
|
}
|
|
if !c.FightC.CanEscape() { //用户对战不能逃跑
|
|
|
|
return nil, errorcode.ErrorCodes.ErrCannotFleePlayerBattle
|
|
}
|
|
c.FightC.Over(c, info.BattleOverReason.PlayerEscape)
|
|
return nil, 0
|
|
}
|
|
|
|
// 切换精灵
|
|
func (h Controller) ChangePet(data *fight.ChangePetInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
if c.FightC != nil {
|
|
c.FightC.ChangePet(c, data.CatchTime)
|
|
}
|
|
return nil, -1
|
|
}
|
|
|
|
// 切换精灵
|
|
func (h Controller) Capture(data *fight.CatchMonsterInboundInfo, c *player.Player) (result *info.CatchMonsterOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
c.FightC.Capture(c, data.CapsuleId)
|
|
return nil, -1
|
|
}
|
|
|
|
// 加载进度
|
|
func (h Controller) LoadPercent(data *fight.LoadPercentInboundInfo, c *player.Player) (result *info.LoadPercentOutboundInfo, err errorcode.ErrorCode) {
|
|
if c.FightC != nil {
|
|
|
|
c.FightC.LoadPercent(c, int32(data.Percent))
|
|
}
|
|
|
|
return nil, -1
|
|
}
|
|
func (h Controller) UsePetItemInboundInfo(data *fight.UsePetItemInboundInfo, c *player.Player) (result *info.UsePetIteminfo, err errorcode.ErrorCode) {
|
|
if c.FightC != nil {
|
|
|
|
c.FightC.UseItem(c, data.CatchTime, data.ItemId)
|
|
}
|
|
|
|
return nil, -1
|
|
}
|