refactor(fight): 重构战斗系统
- 重构了 BattleSkillEntity 结构,改名为 SkillEntity - 优化了 Input 结构,移除了冗余的 Effect 容器 - 调整了 Effect 接口,增加了 SetInput 和 Alive 方法 - 重构了战斗逻辑中的技能使用和效果处理流程 - 优化了代码结构,提高了可读性和可维护性
This commit is contained in:
@@ -13,32 +13,33 @@ type Effect0 struct {
|
||||
}
|
||||
|
||||
// 技能命中计算
|
||||
func (this *Effect0) IsHit(attacker, defender *input.Input, skill *info.BattleSkillEntity) {
|
||||
func (this *Effect0) IsHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
skill.AttackTimeC() //计算命中
|
||||
}
|
||||
|
||||
func (this *Effect0) UseSkill(attacker, defender *input.Input) bool {
|
||||
// 比如xx技能无效
|
||||
func (this *Effect0) UseSkill(opp *input.Input, skill *info.SkillEntity) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *Effect0) IsCrit(attacker, defender *input.Input, skill *info.BattleSkillEntity) {
|
||||
func (this *Effect0) IsCrit(opp *input.Input, skill *info.SkillEntity) {
|
||||
skill.Crit = 0
|
||||
CritRate := utils.Max(skill.CritRate, 1)
|
||||
CritRateR := attacker.FightC.GetRand().Int31n(16)
|
||||
CritRateR := this.Input.FightC.GetRand().Int31n(16)
|
||||
//CritAtkFirst: 先出手时必定致命一击; 默认: 0
|
||||
if skill.CritAtkFirst != 0 && attacker.First {
|
||||
if skill.CritAtkFirst != 0 && this.Input.First {
|
||||
CritRate = 16
|
||||
}
|
||||
//CritAtkSecond: 后出手时必定致命一击; 默认: 0
|
||||
if skill.CritAtkSecond != 0 && !attacker.First {
|
||||
if skill.CritAtkSecond != 0 && !this.Input.First {
|
||||
CritRate = 16
|
||||
}
|
||||
// CritSelfHalfHp: 自身体力低于一半时必定致命一击; 默认: 0
|
||||
if skill.CritSelfHalfHp != 0 && (attacker.CurrentPet.HP < int(attacker.CurrentPet.Info.MaxHp)/2) {
|
||||
if skill.CritSelfHalfHp != 0 && (this.Input.CurrentPet.HP < int(this.Input.CurrentPet.Info.MaxHp)/2) {
|
||||
CritRate = 16
|
||||
}
|
||||
// CritFoeHalfHp: 对方体力低于一半时必定致命一击; 默认: 0
|
||||
if skill.CritSelfHalfHp != 0 && (defender.CurrentPet.HP < int(defender.CurrentPet.Info.MaxHp)/2) {
|
||||
if skill.CritSelfHalfHp != 0 && (opp.CurrentPet.HP < int(opp.CurrentPet.Info.MaxHp)/2) {
|
||||
CritRate = 16
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user