refactor(fight): 重构战斗模块逻辑
- 修改 BattleAction.Compare 方法,使其成为 FightC 类的成员方法 - 移除未使用的 action.go 文件 - 在 BattlePetEntity 中添加 Input 字段,用于处理战斗输入 - 为 Compare 方法添加 TODO 注释,提示后续需完成的速度计算逻辑
This commit is contained in:
@@ -23,7 +23,7 @@ var PlayerOperations = enum.New[struct {
|
|||||||
}]()
|
}]()
|
||||||
|
|
||||||
// Compare 比较两个1v1战斗动作的执行优先级(核心逻辑)
|
// Compare 比较两个1v1战斗动作的执行优先级(核心逻辑)
|
||||||
func Compare(a, b BattleActionI) (BattleActionI, BattleActionI) {
|
func (f *FightC) Compare(a, b BattleActionI) (BattleActionI, BattleActionI) {
|
||||||
// 动作本身的优先级比较
|
// 动作本身的优先级比较
|
||||||
p1 := b.Priority() - a.Priority()
|
p1 := b.Priority() - a.Priority()
|
||||||
if p1 > 0 { // 对手优先级更高
|
if p1 > 0 { // 对手优先级更高
|
||||||
@@ -52,7 +52,11 @@ func Compare(a, b BattleActionI) (BattleActionI, BattleActionI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 比较宠物相关属性(假设Value(4)返回速度相关值)
|
// 比较宠物相关属性(假设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 {
|
if p2 > 0 {
|
||||||
return b, a
|
return b, a
|
||||||
} else if p2 < 0 {
|
} else if p2 < 0 {
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ func (f *FightC) battleLoop() {
|
|||||||
fmt.Println("开始结算回合")
|
fmt.Println("开始结算回合")
|
||||||
|
|
||||||
var BattleActionI [2]BattleActionI
|
var BattleActionI [2]BattleActionI
|
||||||
BattleActionI[0], BattleActionI[1] = Compare(p1Action, p2Action)
|
BattleActionI[0], BattleActionI[1] = f.Compare(p1Action, p2Action)
|
||||||
|
|
||||||
switch faction := BattleActionI[0].(type) {
|
switch faction := BattleActionI[0].(type) {
|
||||||
case *EscapeAction: //优先逃跑
|
case *EscapeAction: //优先逃跑
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package info
|
|||||||
import (
|
import (
|
||||||
element "blazing/common/data/Element"
|
element "blazing/common/data/Element"
|
||||||
"blazing/common/data/xmlres"
|
"blazing/common/data/xmlres"
|
||||||
|
"blazing/logic/service/fight/input"
|
||||||
"blazing/modules/blazing/model"
|
"blazing/modules/blazing/model"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
@@ -108,6 +109,7 @@ func abs(x int8) int8 {
|
|||||||
type BattlePetEntity struct {
|
type BattlePetEntity struct {
|
||||||
xmlres.PetInfo
|
xmlres.PetInfo
|
||||||
Info *model.PetInfo //通过偏移赋值
|
Info *model.PetInfo //通过偏移赋值
|
||||||
|
*input.Input
|
||||||
|
|
||||||
statusConditions sync.Map // key: StatusCondition, value: int (剩余回合)
|
statusConditions sync.Map // key: StatusCondition, value: int (剩余回合)
|
||||||
Skills [4]*SkillEntity // 技能槽(最多4个技能)
|
Skills [4]*SkillEntity // 技能槽(最多4个技能)
|
||||||
|
|||||||
Reference in New Issue
Block a user