refactor: 拆分战斗规则文件为独立模块
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -1,153 +0,0 @@
|
||||
package rule
|
||||
|
||||
import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// 注册战斗规则300-316(注册逻辑不变)
|
||||
input.InitRule(300, &Rule300{})
|
||||
input.InitRule(301, &Rule301{})
|
||||
input.InitRule(302, &Rule302{})
|
||||
input.InitRule(303, &Rule303{})
|
||||
input.InitRule(304, &Rule304{})
|
||||
input.InitRule(305, &Rule305{})
|
||||
input.InitRule(306, &Rule306{})
|
||||
input.InitRule(307, &Rule307{})
|
||||
input.InitRule(308, &Rule308{})
|
||||
input.InitRule(309, &Rule309{})
|
||||
input.InitRule(310, &Rule310{})
|
||||
input.InitRule(311, &Rule311{})
|
||||
input.InitRule(312, &Rule312{})
|
||||
input.InitRule(313, &Rule313{})
|
||||
input.InitRule(314, &Rule314{})
|
||||
input.InitRule(315, &Rule315{})
|
||||
input.InitRule(316, &Rule316{})
|
||||
}
|
||||
|
||||
// RuleBase 规则基类:包含通用参数存储和基础方法
|
||||
type RuleBase struct {
|
||||
args []int // 通用参数存储,替代各个子类的 params
|
||||
}
|
||||
|
||||
// Exec 基类默认执行方法(子类可重写)
|
||||
func (r *RuleBase) Exec(f common.FightI, t *model.FightOverInfo) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// SetArgs 基类参数设置方法(所有子类继承使用)
|
||||
func (r *RuleBase) SetArgs(param ...int) {
|
||||
r.args = param
|
||||
}
|
||||
|
||||
// ------------------------------
|
||||
// 所有具体规则都嵌入 RuleBase 实现继承
|
||||
// 移除所有 params 字段,统一使用父类的 args
|
||||
// ------------------------------
|
||||
|
||||
// Rule300 致命一击击败后获取奖励
|
||||
type Rule300 struct {
|
||||
RuleBase // 嵌入基类,继承 args、SetArgs、Exec
|
||||
}
|
||||
|
||||
func (r *Rule300) Exec(f common.FightI, t *model.FightOverInfo) bool {
|
||||
if t.WinnerId == f.Ownerid() { //获胜
|
||||
|
||||
if f.GetAttackValue(false).IsCritical != 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Rule301 n回合内击败获取奖励
|
||||
type Rule301 struct {
|
||||
RuleBase // 继承基类的所有属性和方法
|
||||
}
|
||||
|
||||
func (r *Rule301) Exec(f common.FightI, t *model.FightOverInfo) bool {
|
||||
if t.WinnerId == f.Ownerid() { //获胜
|
||||
|
||||
if f.GetOverInfo().Round < uint32(r.args[0]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Rule302 n回合后击败获取奖励
|
||||
type Rule302 struct {
|
||||
RuleBase
|
||||
}
|
||||
|
||||
// Rule303 使用xx技能击败(攻击致死)获取奖励
|
||||
type Rule303 struct {
|
||||
RuleBase
|
||||
}
|
||||
|
||||
// Rule304 使用xx技能后(属性技能)击败获取奖励
|
||||
type Rule304 struct {
|
||||
RuleBase
|
||||
}
|
||||
|
||||
// Rule305 满血击败后获取奖励
|
||||
type Rule305 struct {
|
||||
RuleBase
|
||||
}
|
||||
|
||||
// Rule306 对方在xx异常状态下击败后获取奖励
|
||||
type Rule306 struct {
|
||||
RuleBase
|
||||
}
|
||||
|
||||
// Rule307 满足特定属性强化下击败后获取奖励
|
||||
type Rule307 struct {
|
||||
RuleBase
|
||||
}
|
||||
|
||||
// Rule308 战斗中超过n伤害获取奖励
|
||||
type Rule308 struct {
|
||||
RuleBase
|
||||
}
|
||||
|
||||
// Rule309 战斗持续n回合后获取奖励
|
||||
type Rule309 struct {
|
||||
RuleBase
|
||||
}
|
||||
|
||||
// Rule310 不使用xx药剂击败获取奖励
|
||||
type Rule310 struct {
|
||||
RuleBase
|
||||
}
|
||||
|
||||
// Rule311 偶数回合击败后获取奖励
|
||||
type Rule311 struct {
|
||||
RuleBase
|
||||
}
|
||||
|
||||
// Rule312 奇数回合击败后获取奖励
|
||||
type Rule312 struct {
|
||||
RuleBase
|
||||
}
|
||||
|
||||
// Rule313 特定回合击败后获取奖励
|
||||
type Rule313 struct {
|
||||
RuleBase
|
||||
}
|
||||
|
||||
// Rule314 自身处于xx状态击败后获取奖励
|
||||
type Rule314 struct {
|
||||
RuleBase
|
||||
}
|
||||
|
||||
// Rule315 自身不大于1/n血量击败
|
||||
type Rule315 struct {
|
||||
RuleBase
|
||||
}
|
||||
|
||||
// Rule316 在自身所有技能都进入PP耗尽状态的情况下获胜获取精灵
|
||||
type Rule316 struct {
|
||||
RuleBase
|
||||
}
|
||||
21
logic/service/fight/rule/rule300.go
Normal file
21
logic/service/fight/rule/rule300.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package rule
|
||||
|
||||
import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
// Rule300 致命一击击败后获取奖励
|
||||
type Rule300 struct {
|
||||
RuleBase // 嵌入基类,继承 args、SetArgs、Exec
|
||||
}
|
||||
|
||||
func (r *Rule300) Exec(f common.FightI, t *model.FightOverInfo) bool {
|
||||
if t.WinnerId == f.Ownerid() { //获胜
|
||||
|
||||
if f.GetAttackValue(false).IsCritical != 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
21
logic/service/fight/rule/rule301.go
Normal file
21
logic/service/fight/rule/rule301.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package rule
|
||||
|
||||
import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
// Rule301 n回合内击败获取奖励
|
||||
type Rule301 struct {
|
||||
RuleBase // 继承基类的所有属性和方法
|
||||
}
|
||||
|
||||
func (r *Rule301) Exec(f common.FightI, t *model.FightOverInfo) bool {
|
||||
if t.WinnerId == f.Ownerid() { //获胜
|
||||
|
||||
if f.GetOverInfo().Round < uint32(r.args[0]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
6
logic/service/fight/rule/rule302.go
Normal file
6
logic/service/fight/rule/rule302.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule302 n回合后击败获取奖励
|
||||
type Rule302 struct {
|
||||
RuleBase
|
||||
}
|
||||
6
logic/service/fight/rule/rule303.go
Normal file
6
logic/service/fight/rule/rule303.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule303 使用xx技能击败(攻击致死)获取奖励
|
||||
type Rule303 struct {
|
||||
RuleBase
|
||||
}
|
||||
6
logic/service/fight/rule/rule304.go
Normal file
6
logic/service/fight/rule/rule304.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule304 使用xx技能后(属性技能)击败获取奖励
|
||||
type Rule304 struct {
|
||||
RuleBase
|
||||
}
|
||||
6
logic/service/fight/rule/rule305.go
Normal file
6
logic/service/fight/rule/rule305.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule305 满血击败后获取奖励
|
||||
type Rule305 struct {
|
||||
RuleBase
|
||||
}
|
||||
6
logic/service/fight/rule/rule306.go
Normal file
6
logic/service/fight/rule/rule306.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule306 对方在xx异常状态下击败后获取奖励
|
||||
type Rule306 struct {
|
||||
RuleBase
|
||||
}
|
||||
6
logic/service/fight/rule/rule307.go
Normal file
6
logic/service/fight/rule/rule307.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule307 满足特定属性强化下击败后获取奖励
|
||||
type Rule307 struct {
|
||||
RuleBase
|
||||
}
|
||||
6
logic/service/fight/rule/rule308.go
Normal file
6
logic/service/fight/rule/rule308.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule308 战斗中超过n伤害获取奖励
|
||||
type Rule308 struct {
|
||||
RuleBase
|
||||
}
|
||||
6
logic/service/fight/rule/rule309.go
Normal file
6
logic/service/fight/rule/rule309.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule309 战斗持续n回合后获取奖励
|
||||
type Rule309 struct {
|
||||
RuleBase
|
||||
}
|
||||
6
logic/service/fight/rule/rule310.go
Normal file
6
logic/service/fight/rule/rule310.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule310 不使用xx药剂击败获取奖励
|
||||
type Rule310 struct {
|
||||
RuleBase
|
||||
}
|
||||
6
logic/service/fight/rule/rule311.go
Normal file
6
logic/service/fight/rule/rule311.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule311 偶数回合击败后获取奖励
|
||||
type Rule311 struct {
|
||||
RuleBase
|
||||
}
|
||||
6
logic/service/fight/rule/rule312.go
Normal file
6
logic/service/fight/rule/rule312.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule312 奇数回合击败后获取奖励
|
||||
type Rule312 struct {
|
||||
RuleBase
|
||||
}
|
||||
6
logic/service/fight/rule/rule313.go
Normal file
6
logic/service/fight/rule/rule313.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule313 特定回合击败后获取奖励
|
||||
type Rule313 struct {
|
||||
RuleBase
|
||||
}
|
||||
6
logic/service/fight/rule/rule314.go
Normal file
6
logic/service/fight/rule/rule314.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule314 自身处于xx状态击败后获取奖励
|
||||
type Rule314 struct {
|
||||
RuleBase
|
||||
}
|
||||
6
logic/service/fight/rule/rule315.go
Normal file
6
logic/service/fight/rule/rule315.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule315 自身不大于1/n血量击败
|
||||
type Rule315 struct {
|
||||
RuleBase
|
||||
}
|
||||
6
logic/service/fight/rule/rule316.go
Normal file
6
logic/service/fight/rule/rule316.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package rule
|
||||
|
||||
// Rule316 在自身所有技能都进入PP耗尽状态的情况下获胜获取精灵
|
||||
type Rule316 struct {
|
||||
RuleBase
|
||||
}
|
||||
21
logic/service/fight/rule/rule_base.go
Normal file
21
logic/service/fight/rule/rule_base.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package rule
|
||||
|
||||
import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
// RuleBase 规则基类:包含通用参数存储和基础方法
|
||||
type RuleBase struct {
|
||||
args []int // 通用参数存储,替代各个子类的 params
|
||||
}
|
||||
|
||||
// Exec 基类默认执行方法(子类可重写)
|
||||
func (r *RuleBase) Exec(f common.FightI, t *model.FightOverInfo) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// SetArgs 基类参数设置方法(所有子类继承使用)
|
||||
func (r *RuleBase) SetArgs(param ...int) {
|
||||
r.args = param
|
||||
}
|
||||
24
logic/service/fight/rule/rule_init.go
Normal file
24
logic/service/fight/rule/rule_init.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package rule
|
||||
|
||||
import "blazing/logic/service/fight/input"
|
||||
|
||||
func init() {
|
||||
// 注册战斗规则300-316
|
||||
input.InitRule(300, &Rule300{})
|
||||
input.InitRule(301, &Rule301{})
|
||||
input.InitRule(302, &Rule302{})
|
||||
input.InitRule(303, &Rule303{})
|
||||
input.InitRule(304, &Rule304{})
|
||||
input.InitRule(305, &Rule305{})
|
||||
input.InitRule(306, &Rule306{})
|
||||
input.InitRule(307, &Rule307{})
|
||||
input.InitRule(308, &Rule308{})
|
||||
input.InitRule(309, &Rule309{})
|
||||
input.InitRule(310, &Rule310{})
|
||||
input.InitRule(311, &Rule311{})
|
||||
input.InitRule(312, &Rule312{})
|
||||
input.InitRule(313, &Rule313{})
|
||||
input.InitRule(314, &Rule314{})
|
||||
input.InitRule(315, &Rule315{})
|
||||
input.InitRule(316, &Rule316{})
|
||||
}
|
||||
Reference in New Issue
Block a user