2025-08-24 17:33:19 +08:00
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
import (
|
2025-09-21 14:56:37 +00:00
|
|
|
"blazing/common/data/xmlres"
|
2025-08-24 17:33:19 +08:00
|
|
|
"blazing/common/socket/errorcode"
|
2025-09-04 02:00:57 +08:00
|
|
|
|
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-09-14 01:35:16 +08:00
|
|
|
"blazing/logic/service/player"
|
2025-08-24 17:33:19 +08:00
|
|
|
"blazing/modules/blazing/model"
|
|
|
|
|
)
|
|
|
|
|
|
2025-09-19 00:29:55 +08:00
|
|
|
func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
|
var petid int
|
|
|
|
|
var mo *model.PetInfo
|
2025-09-21 14:56:37 +00:00
|
|
|
if c.Info.MapID == 515 && data.BossId == 0 { //说明是新手,随机生成
|
2025-09-19 00:29:55 +08:00
|
|
|
switch c.Info.PetList[0].ID {
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
petid = 4
|
|
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
|
petid = 1
|
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
petid = 7
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mo = model.GenPetInfo(
|
2025-09-20 13:12:45 +08:00
|
|
|
int(petid), 24, //24个体
|
|
|
|
|
-1,
|
|
|
|
|
0, //野怪没特性
|
|
|
|
|
0,
|
|
|
|
|
2)
|
2025-09-19 00:29:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if c.FightC != nil {
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrOnlineOver6HoursCannotFight
|
|
|
|
|
}
|
2025-09-21 14:56:37 +00:00
|
|
|
moinfo := &model.PlayerInfo{}
|
|
|
|
|
moinfo.Nick = xmlres.PetMAP[int(mo.ID)].DefName
|
|
|
|
|
moinfo.PetList = append(moinfo.PetList, *mo)
|
|
|
|
|
ai := player.NewAI_player(moinfo)
|
2025-09-19 00:29:55 +08:00
|
|
|
fight.NewFight(info.BattleMode.PVE, c, ai)
|
|
|
|
|
|
|
|
|
|
return nil, -1
|
|
|
|
|
}
|
2025-09-20 13:12:45 +08:00
|
|
|
|
|
|
|
|
// 战斗野怪
|
2025-09-14 01:35:16 +08:00
|
|
|
func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-08-24 17:33:19 +08:00
|
|
|
|
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(
|
2025-09-20 13:12:45 +08:00
|
|
|
int(refpet.Id), -1,
|
|
|
|
|
-1,
|
|
|
|
|
0, //野怪没特性
|
|
|
|
|
int(refpet.Shiny),
|
|
|
|
|
int(refpet.Lv))
|
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-21 14:56:37 +00:00
|
|
|
moinfo := &model.PlayerInfo{}
|
|
|
|
|
moinfo.Nick = xmlres.PetMAP[int(mo.ID)].DefName
|
|
|
|
|
moinfo.PetList = append(moinfo.PetList, *mo)
|
|
|
|
|
ai := player.NewAI_player(moinfo)
|
|
|
|
|
|
2025-09-14 01:35:16 +08:00
|
|
|
fight.NewFight(info.BattleMode.PVE, c, ai)
|
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-14 01:35:16 +08:00
|
|
|
func (h Controller) OnReadyToFight(data *fight.ReadyToFightInboundInfo, c *player.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-14 01:35:16 +08:00
|
|
|
func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-08-27 05:10:10 +00:00
|
|
|
|
2025-09-20 00:17:29 +08:00
|
|
|
if ok, p1 := c.AgreeBattle(data.UserID, data.Flag, data.Mode); ok {
|
|
|
|
|
fight.NewFight(info.EnumBattleMode(data.Mode), p1, c) ///开始对战,房主方以及被邀请方
|
|
|
|
|
}
|
2025-08-27 05:10:10 +00:00
|
|
|
return nil, -1
|
|
|
|
|
}
|
2025-09-01 01:03:46 +08:00
|
|
|
|
2025-09-20 00:17:29 +08:00
|
|
|
// 邀请其他人进行战斗
|
|
|
|
|
func (h Controller) OnPlayerInviteOtherFight(data *fight.InviteToFightInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-09-23 16:48:40 +00:00
|
|
|
c.InvitePlayerToBattle(&info.PVPinfo{PlayerID: data.UserID, Mode: data.Mode})
|
2025-09-20 00:17:29 +08:00
|
|
|
|
|
|
|
|
return nil, 0
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-01 01:03:46 +08:00
|
|
|
// 使用技能包
|
2025-09-14 01:35:16 +08:00
|
|
|
func (h Controller) UseSkill(data *fight.UseSkillInboundInfo, c *player.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-14 01:35:16 +08:00
|
|
|
func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-09-01 01:03:46 +08:00
|
|
|
|
2025-09-23 16:42:10 +00:00
|
|
|
c.FightC.Over(c,info.BattleOverReason.PlayerEscape)
|
2025-09-01 01:03:46 +08:00
|
|
|
return nil, 0
|
|
|
|
|
}
|
2025-09-07 00:23:28 +08:00
|
|
|
|
|
|
|
|
// 切换精灵
|
2025-09-14 01:35:16 +08:00
|
|
|
func (h Controller) ChangePet(data *fight.ChangePetInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-09-07 00:23:28 +08:00
|
|
|
|
2025-09-14 01:35:16 +08:00
|
|
|
c.FightC.ChangePet(c, data.CatchTime)
|
2025-09-11 02:44:21 +08:00
|
|
|
return nil, -1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 切换精灵
|
2025-09-14 01:35:16 +08:00
|
|
|
func (h Controller) Capture(data *fight.CatchMonsterInboundInfo, c *player.Player) (result *info.CatchMonsterOutboundInfo, err errorcode.ErrorCode) {
|
2025-09-11 02:44:21 +08:00
|
|
|
|
|
|
|
|
c.FightC.Capture(c, (data.CapsuleId))
|
|
|
|
|
return nil, -1
|
2025-09-07 00:23:28 +08:00
|
|
|
}
|