refactor(fight): 重构战斗模块逻辑

- 修改 BattleAction.Compare 方法,使其成为 FightC 类的成员方法
- 移除未使用的 action.go 文件
- 在 BattlePetEntity 中添加 Input 字段,用于处理战斗输入
- 为 Compare 方法添加 TODO 注释,提示后续需完成的速度计算逻辑
This commit is contained in:
2025-09-16 23:58:03 +08:00
parent 72e6b8c706
commit a33f108f98
4 changed files with 9 additions and 3 deletions

View File

@@ -23,7 +23,7 @@ var PlayerOperations = enum.New[struct {
}]()
// Compare 比较两个1v1战斗动作的执行优先级核心逻辑
func Compare(a, b BattleActionI) (BattleActionI, BattleActionI) {
func (f *FightC) Compare(a, b BattleActionI) (BattleActionI, BattleActionI) {
// 动作本身的优先级比较
p1 := b.Priority() - a.Priority()
if p1 > 0 { // 对手优先级更高
@@ -52,7 +52,11 @@ func Compare(a, b BattleActionI) (BattleActionI, BattleActionI) {
}
// 比较宠物相关属性(假设Value(4)返回速度相关值)
p2 = int(bskill.PetInfo.Speed()) - int(askill.PetInfo.Speed())
p2s := bskill.PetInfo.Info.Speed
//todo 待计算速度
f.Opp.Exec(fn func(input.Effect) bool)
p1s := askill.PetInfo.Info.Speed
p2 = int(bskill.PetInfo.Info.Speed) - int(askill.PetInfo.Speed())
if p2 > 0 {
return b, a
} else if p2 < 0 {

View File

@@ -288,7 +288,7 @@ func (f *FightC) battleLoop() {
fmt.Println("开始结算回合")
var BattleActionI [2]BattleActionI
BattleActionI[0], BattleActionI[1] = Compare(p1Action, p2Action)
BattleActionI[0], BattleActionI[1] = f.Compare(p1Action, p2Action)
switch faction := BattleActionI[0].(type) {
case *EscapeAction: //优先逃跑

View File

@@ -3,6 +3,7 @@ package info
import (
element "blazing/common/data/Element"
"blazing/common/data/xmlres"
"blazing/logic/service/fight/input"
"blazing/modules/blazing/model"
"fmt"
"math/rand"
@@ -108,6 +109,7 @@ func abs(x int8) int8 {
type BattlePetEntity struct {
xmlres.PetInfo
Info *model.PetInfo //通过偏移赋值
*input.Input
statusConditions sync.Map // key: StatusCondition, value: int (剩余回合)
Skills [4]*SkillEntity // 技能槽最多4个技能