2025-08-24 17:33:19 +08:00
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/common/socket/errorcode"
|
2025-09-04 02:00:57 +08:00
|
|
|
|
|
|
|
|
"blazing/logic/service"
|
2025-08-24 17:33:19 +08:00
|
|
|
"blazing/logic/service/fight"
|
2025-08-25 04:23:32 +08:00
|
|
|
"blazing/logic/service/fight/info"
|
2025-08-24 17:33:19 +08:00
|
|
|
"blazing/modules/blazing/model"
|
2025-09-01 01:03:46 +08:00
|
|
|
|
|
|
|
|
"github.com/jinzhu/copier"
|
2025-08-24 17:33:19 +08:00
|
|
|
)
|
|
|
|
|
|
2025-09-04 02:00:57 +08:00
|
|
|
func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-09-02 00:45:29 +08:00
|
|
|
|
2025-08-25 04:23:32 +08:00
|
|
|
ttt := info.NoteReadyToFightInfo{
|
2025-09-04 23:57:22 +08:00
|
|
|
|
2025-08-24 17:33:19 +08:00
|
|
|
FightId: 3,
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-02 00:45:29 +08:00
|
|
|
copier.Copy(&ttt.OurInfo, &c.Info)
|
2025-09-01 01:03:46 +08:00
|
|
|
len := len(c.Info.PetList)
|
|
|
|
|
ttt.OurPetList = make([]info.ReadyFightPetInfo, len)
|
|
|
|
|
for i := 0; i < len; i++ {
|
2025-08-24 17:33:19 +08:00
|
|
|
|
2025-09-01 01:03:46 +08:00
|
|
|
err := copier.CopyWithOption(&ttt.OurPetList[i], &c.Info.PetList[i], copier.Option{IgnoreEmpty: true, DeepCopy: true})
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
2025-08-24 17:33:19 +08:00
|
|
|
}
|
2025-09-01 01:03:46 +08:00
|
|
|
|
2025-08-25 04:23:32 +08:00
|
|
|
ttt.OpponentInfo = info.FightUserInfo{UserID: 0}
|
2025-09-02 00:45:29 +08:00
|
|
|
refpet := c.OgreInfo.Data[data.Number]
|
2025-09-06 00:31:08 +08:00
|
|
|
if refpet.Id == 0 {
|
2025-09-02 00:45:29 +08:00
|
|
|
|
2025-09-06 00:31:08 +08:00
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
|
|
|
}
|
2025-09-05 00:26:42 +08:00
|
|
|
mo := model.GenPetInfo(
|
|
|
|
|
int(refpet.Id), []int{0, 31},
|
|
|
|
|
[]int{0, 24},
|
|
|
|
|
[]int{0}, //野怪没特性
|
|
|
|
|
[]int{int(refpet.Shiny)},
|
|
|
|
|
[]int{int(refpet.Lv)})
|
2025-09-02 00:45:29 +08:00
|
|
|
ttt.OpponentPetList = make([]info.ReadyFightPetInfo, 1)
|
|
|
|
|
|
|
|
|
|
err1 := copier.CopyWithOption(&ttt.OpponentPetList[0], &mo, copier.Option{IgnoreEmpty: true, DeepCopy: true})
|
|
|
|
|
if err1 != nil {
|
|
|
|
|
panic(err)
|
2025-08-24 17:33:19 +08:00
|
|
|
}
|
2025-09-05 22:40:36 +08:00
|
|
|
|
|
|
|
|
if c.FightC != nil {
|
2025-09-06 00:31:08 +08:00
|
|
|
return nil, errorcode.ErrorCodes.ErrOnlineOver6HoursCannotFight
|
2025-09-05 22:40:36 +08:00
|
|
|
}
|
2025-09-08 01:23:12 +08:00
|
|
|
ai := service.NewAI_player(*mo)
|
|
|
|
|
service.NewFight(ttt, c, ai)
|
|
|
|
|
|
2025-09-04 23:57:22 +08:00
|
|
|
c.FightC.OwnerID = c.Info.UserID
|
2025-09-06 00:31:08 +08:00
|
|
|
|
2025-08-24 17:33:19 +08:00
|
|
|
return nil, -1
|
|
|
|
|
}
|
2025-09-01 01:03:46 +08:00
|
|
|
|
|
|
|
|
// 准备战斗
|
2025-09-04 02:00:57 +08:00
|
|
|
func (h Controller) OnReadyToFight(data *fight.ReadyToFightInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-09-02 00:45:29 +08:00
|
|
|
|
2025-09-04 02:00:57 +08:00
|
|
|
c.FightC.ReadyFight(c)
|
2025-08-24 17:33:19 +08:00
|
|
|
return nil, -1
|
|
|
|
|
}
|
2025-08-27 05:10:10 +00:00
|
|
|
|
2025-09-01 01:03:46 +08:00
|
|
|
// 接收战斗或者取消战斗的包
|
2025-09-04 02:00:57 +08:00
|
|
|
func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-08-27 05:10:10 +00:00
|
|
|
|
|
|
|
|
return nil, -1
|
|
|
|
|
}
|
2025-09-01 01:03:46 +08:00
|
|
|
|
|
|
|
|
// 使用技能包
|
2025-09-04 02:00:57 +08:00
|
|
|
func (h Controller) UseSkill(data *fight.UseSkillInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-09-06 00:31:08 +08:00
|
|
|
c.FightC.UseSkill(c, int32(data.SkillId))
|
2025-09-01 01:03:46 +08:00
|
|
|
return nil, 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 战斗逃跑
|
2025-09-04 02:00:57 +08:00
|
|
|
func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-09-01 01:03:46 +08:00
|
|
|
|
2025-09-05 22:40:36 +08:00
|
|
|
c.FightC.Escape(c)
|
2025-09-01 01:03:46 +08:00
|
|
|
return nil, 0
|
|
|
|
|
}
|
2025-09-07 00:23:28 +08:00
|
|
|
|
|
|
|
|
// 切换精灵
|
|
|
|
|
func (h Controller) ChangePet(data *fight.ChangePetInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
|
|
|
|
|
|
c.FightC.ChangePet(c, int32(data.CatchTime))
|
|
|
|
|
return nil, 0
|
|
|
|
|
}
|