Files
bl/logic/service/fight/action/BattleAction.go

98 lines
2.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package action
import (
"blazing/logic/service/fight/info"
"github.com/tnnmigga/enum"
)
// EnumPlayerOperation 玩家操作枚举类型
type EnumPlayerOperation int
// 定义读秒倒计时期间玩家可执行的操作枚举
var PlayerOperations = enum.New[struct {
//SystemGiveUp EnumPlayerOperation `enum:"-1"` // 系统选择放弃出手(比如没有PP)
//系统放弃出手就是SKILL ID=0
SelectSkill EnumPlayerOperation `enum:"0"` // 选择技能-6到6
ActiveSwitch EnumPlayerOperation `enum:"2"` // 主动切换(中切)
UsePotion EnumPlayerOperation `enum:"3"` // 使用药剂(捕捉、逃跑等)
//Escape EnumPlayerOperation `enum:"4"` // 逃跑(等级最高,以及掉线)
// PlayerOffline EnumPlayerOperation `enum:"5"` // 玩家掉线
// BeExpelledSwitch EnumPlayerOperation `enum:"6"` // 被驱逐切换
}]()
// BattleActionI 战斗动作接口
type BattleActionI interface {
GetPlayerID() uint32
GetRound() uint32
SetRound(uint32)
Priority() int // 优先级
}
// SelectSkillAction 选择技能的战斗动作
type SelectSkillAction struct {
BaseAction
*info.SkillEntity // 使用的技能
//PetInfo *info.BattlePetEntity // 使用技能的宠物
//Attack info.AttackValue
}
// Priority 返回动作优先级
func (*SelectSkillAction) Priority() int {
return int(PlayerOperations.SelectSkill)
}
type BaseAction struct {
PlayerID uint32 // 玩家ID
Round uint32 // 所属回合
}
func NewBaseAction(t uint32) BaseAction {
return BaseAction{
PlayerID: t,
}
}
func (a *BaseAction) GetPlayerID() uint32 {
return a.PlayerID
// fmt.Printf("玩家[%d]主动切换宠物:从%s切换到%s原因%s\n",
// // a.PlayerID, a.CurrentPet.Name, a.TargetPet.Name, a.SwitchReason)
}
func (a *BaseAction) GetRound() uint32 {
return a.Round
}
func (a *BaseAction) SetRound(round uint32) {
a.Round = round
}
// ActiveSwitchAction 主动切换宠物的战斗动作
type ActiveSwitchAction struct {
BaseAction
Cid uint32
Reason info.ChangePetInfo
// CurrentPet BattlePetEntity // 当前在场宠物
// TargetPet BattlePetEntity // 要切换上场的宠物
// SwitchReason string // 切换原因
}
// Priority 返回动作优先级
func (*ActiveSwitchAction) Priority() int {
return int(PlayerOperations.ActiveSwitch)
}
// UsePotionAction 使用药剂的战斗动作
type UseItemAction struct {
BaseAction
ItemID uint32 // 药剂ID
CacthTime uint32
TargetPet info.BattlePetEntity // 药剂作用目标宠物
}
// Priority 返回动作优先级
func (*UseItemAction) Priority() int {
return int(PlayerOperations.UsePotion)
}