- 优化了 FightC 结构体,将 Info 字段改为指针类型 - 添加了 EffectNode 类型的 Type 方法,用于获取效果类型 - 修改了 BattlePetEntity 中的 Attribute 结构,移除了未使用的枚举类型 - 删除了 info.go 文件中未使用的结构体定义 - 在 effect_1.go 中更新了 Effect1 类的 PostDamage 方法,待重写实现
86 lines
2.3 KiB
Go
86 lines
2.3 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
|
|
"math/rand"
|
|
"time"
|
|
|
|
"blazing/logic/service"
|
|
"blazing/logic/service/fight"
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/modules/blazing/model"
|
|
|
|
"github.com/jinzhu/copier"
|
|
)
|
|
|
|
func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
ttt := info.NoteReadyToFightInfo{
|
|
OwnerID: data.Head.UserID,
|
|
FightId: 3,
|
|
}
|
|
|
|
copier.Copy(&ttt.OurInfo, &c.Info)
|
|
len := len(c.Info.PetList)
|
|
ttt.OurPetList = make([]info.ReadyFightPetInfo, len)
|
|
for i := 0; i < len; i++ {
|
|
|
|
err := copier.CopyWithOption(&ttt.OurPetList[i], &c.Info.PetList[i], copier.Option{IgnoreEmpty: true, DeepCopy: true})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
ttt.OpponentInfo = info.FightUserInfo{UserID: 0}
|
|
refpet := c.OgreInfo.Data[data.Number]
|
|
|
|
dv := rand.New(rand.NewSource(time.Now().UnixNano())).Intn(32)
|
|
mo := model.GenPetInfo(refpet.Id, uint32(dv), 0, 1006, refpet.Shiny, refpet.Lv)
|
|
ttt.OpponentPetList = make([]info.ReadyFightPetInfo, 1)
|
|
|
|
err1 := copier.CopyWithOption(&ttt.OpponentPetList[0], &mo, copier.Option{IgnoreEmpty: true, DeepCopy: true})
|
|
if err1 != nil {
|
|
panic(err)
|
|
}
|
|
c.FightC = &service.FightC{}
|
|
c.FightC.NewFight(&ttt, c) //把两个玩家都传进去
|
|
|
|
return nil, -1
|
|
}
|
|
|
|
// 准备战斗
|
|
func (h Controller) OnReadyToFight(data *fight.ReadyToFightInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
c.FightC.ReadyFight(c)
|
|
return nil, -1
|
|
}
|
|
|
|
// 接收战斗或者取消战斗的包
|
|
func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
return nil, -1
|
|
}
|
|
|
|
// 使用技能包
|
|
func (h Controller) UseSkill(data *fight.UseSkillInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
return nil, 0
|
|
}
|
|
|
|
// 战斗逃跑
|
|
func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
defer func() {
|
|
//战斗结束Escape
|
|
ttt := service.NewTomeeHeader(2506, c.Info.UserID)
|
|
|
|
c.SendPack(ttt.Pack(&fight.FightOverInfo{
|
|
Reason: 0,
|
|
}))
|
|
c.FightC = nil
|
|
}()
|
|
|
|
return nil, 0
|
|
}
|