Files
bl/logic/controller/fight.go
2025-09-19 00:29:55 +08:00

106 lines
2.8 KiB
Go

package controller
import (
"blazing/common/socket/errorcode"
"blazing/logic/service/fight"
"blazing/logic/service/fight/info"
"blazing/logic/service/player"
"blazing/modules/blazing/model"
)
func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
var petid int
var mo *model.PetInfo
if c.MapID() == 515 && data.BossId == 0 { //说明是新手,随机生成
switch c.Info.PetList[0].ID {
case 1:
petid = 4
case 7:
petid = 1
case 4:
petid = 7
}
mo = model.GenPetInfo(
int(petid), []int{0, 31},
[]int{0, 24},
[]int{0}, //野怪没特性
[]int{int(0)},
[]int{int(2)})
}
if c.FightC != nil {
return nil, errorcode.ErrorCodes.ErrOnlineOver6HoursCannotFight
}
ai := player.NewAI_player(model.PlayerInfo{}, *mo)
fight.NewFight(info.BattleMode.PVE, c, ai)
return nil, -1
}
func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
refpet := c.OgreInfo.Data[data.Number]
if refpet.Id == 0 {
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
}
mo := model.GenPetInfo(
int(refpet.Id), []int{0, 31},
[]int{0, 24},
[]int{0}, //野怪没特性
[]int{int(refpet.Shiny)},
[]int{int(refpet.Lv)})
if c.FightC != nil {
return nil, errorcode.ErrorCodes.ErrOnlineOver6HoursCannotFight
}
ai := player.NewAI_player(model.PlayerInfo{}, *mo)
fight.NewFight(info.BattleMode.PVE, c, ai)
return nil, -1
}
// 准备战斗
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) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
return nil, -1
}
// 使用技能包
func (h Controller) UseSkill(data *fight.UseSkillInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
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) {
c.FightC.Escape(c)
return nil, 0
}
// 切换精灵
func (h Controller) ChangePet(data *fight.ChangePetInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
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
}