refactor: 重构战斗结构体以支持双打模式
This commit is contained in:
@@ -20,6 +20,8 @@ type Input struct {
|
||||
// CanAction bool //是否可以行动
|
||||
CurPet []*info.BattlePetEntity //当前上场精灵
|
||||
AllPet []*info.BattlePetEntity
|
||||
Team []*Input
|
||||
OppTeam []*Input
|
||||
Player common.PlayerI
|
||||
Opp *Input
|
||||
CanCapture int
|
||||
@@ -30,8 +32,8 @@ type Input struct {
|
||||
EffectLost []Effect
|
||||
// 删掉伤害记录,可以在回调中记录,而不是每次调用记录
|
||||
*model.AttackValue
|
||||
FightC common.FightI
|
||||
SumDamage alpacadecimal.Decimal //伤害
|
||||
FightC common.FightI
|
||||
SumDamage alpacadecimal.Decimal //伤害
|
||||
ShieldDamageTaken alpacadecimal.Decimal
|
||||
// 记录上一回合结束时的能力等级,供效果727等回溯使用。
|
||||
LastTurnEndProp [6]int8
|
||||
@@ -76,6 +78,63 @@ func (our *Input) PrimaryCurPet() *info.BattlePetEntity {
|
||||
return our.CurPetAt(0)
|
||||
}
|
||||
|
||||
// CurrentPet 返回“当前输入槽位”的出战精灵。
|
||||
// 注意:Input 本身已对应一个 actor 槽位,这里不是“整队的 0 号主位”。
|
||||
func (our *Input) CurrentPet() *info.BattlePetEntity {
|
||||
return our.PrimaryCurPet()
|
||||
}
|
||||
|
||||
func (our *Input) IsCurrentPetCatchTime(catchTime uint32) bool {
|
||||
current := our.CurrentPet()
|
||||
if current == nil {
|
||||
return false
|
||||
}
|
||||
return current.Info.CatchTime == catchTime
|
||||
}
|
||||
|
||||
func (our *Input) ControlledBy(userID uint32) bool {
|
||||
return our != nil && our.Player != nil && our.Player.GetInfo().UserID == userID
|
||||
}
|
||||
|
||||
// BenchPets 返回当前站位后备精灵(不含当前出战精灵)。
|
||||
func (our *Input) BenchPets() []*info.BattlePetEntity {
|
||||
if our == nil {
|
||||
return nil
|
||||
}
|
||||
current := our.CurrentPet()
|
||||
if current == nil {
|
||||
return append([]*info.BattlePetEntity(nil), our.AllPet...)
|
||||
}
|
||||
bench := make([]*info.BattlePetEntity, 0, len(our.AllPet))
|
||||
for _, pet := range our.AllPet {
|
||||
if pet == nil || pet.Info.CatchTime == current.Info.CatchTime {
|
||||
continue
|
||||
}
|
||||
bench = append(bench, pet)
|
||||
}
|
||||
return bench
|
||||
}
|
||||
|
||||
func (our *Input) OpponentSlots() []*Input {
|
||||
if our == nil {
|
||||
return nil
|
||||
}
|
||||
if len(our.OppTeam) == 0 {
|
||||
if our.Opp != nil {
|
||||
return []*Input{our.Opp}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
slots := make([]*Input, 0, len(our.OppTeam))
|
||||
for _, in := range our.OppTeam {
|
||||
if in == nil {
|
||||
continue
|
||||
}
|
||||
slots = append(slots, in)
|
||||
}
|
||||
return slots
|
||||
}
|
||||
|
||||
func (our *Input) SetCurPetAt(index int, pet *info.BattlePetEntity) {
|
||||
if our == nil || index < 0 {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user