refactor(effectarg): 移动EffectArgs初始化逻辑 将EffectArgs的初始化从effectarg.go中的init函数移动到file.go的initfile函数中, 确保在使用前正确加载配置并初始化映射。 refactor(login): 更新Login方法中的Person调用 修改Login方法中对Person函数的调用,传递UserID参数以获取正确的用户信息。 refactor(user): 统一使用Person方法替代PersonOther 在UserSimInfo和UserMoreInfo方法中,将原先调用的PersonOther方法统一替换为 Person方法,保持代码一致性。 refactor(effect_damage): 简化属性获取和伤害计算逻辑 移除deepcopy相关逻辑,简化Effect0的OnSkill方法中的属性获取和伤害计算流程, 直接通过输入参数进行计算。 refactor(fightc): 优化玩家输入处理和战斗逻辑 更新GetInputByPlayer方法中的玩家判断逻辑,使用UserID比较代替对象比较; 在initplayer中添加InitAttackValue调用; 修复battleLoop中打印语句的格式问题; 调整技能攻击处理流程,增加SkillUseEnd回调调用。 refactor(attr): 改进属性获取方法和伤害计算逻辑 将GetProp方法重命名为Prop,并支持传入对方输入参数; 更新CalculatePower方法签名,使用Input类型代替BattlePetEntity; 在属性获取和伤害计算中正确处理双方属性影响。 refactor(playeraction): 简化技能使用逻辑 简化UseSkill方法中获取当前宠物信息的逻辑,去除冗余的条件判断; 在找到对应技能后添加break语句,提高执行效率。 refactor(reg): 更新Person方法实现 合并Person和PersonOther方法为统一的Person方法; 在数据库查询失败时添加错误处理,避免潜在的空指针异常。 ```
88 lines
2.5 KiB
Go
88 lines
2.5 KiB
Go
package effect
|
|
|
|
import (
|
|
"blazing/common/utils"
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/logic/service/fight/input"
|
|
"blazing/logic/service/fight/node"
|
|
)
|
|
|
|
// 施加一个基类effect
|
|
type Effect0 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
// 技能命中计算
|
|
func (this *Effect0) IsHit(opp *input.Input, skill *info.SkillEntity) {
|
|
skill.AttackTimeC(int(opp.GetProp(5, true))) //计算命中
|
|
}
|
|
|
|
// 比如xx技能无效
|
|
func (this *Effect0) UseSkill(opp *input.Input) bool {
|
|
return true
|
|
}
|
|
|
|
func (e *Effect0) TurnEnd(opp *input.Input) {
|
|
e.Input.AttackValue.RemainHp = int32(e.Input.CurrentPet.Info.Hp)
|
|
|
|
// ret.FAttack.LostHp = uint32(f.First.GetDamageEffect(0).Stack()) //先手方造成血量
|
|
//opp.AttackValue.RemainHp = int32(opp.CurrentPet.Info.Hp)
|
|
//ret.SAttack.LostHp = uint32(f.Second.GetDamageEffect(0).Stack()) //后手方造成血量
|
|
|
|
}
|
|
|
|
// 使用技能时
|
|
func (e *Effect0) OnSkill(opp *input.Input, skill *info.SkillEntity) {
|
|
|
|
e.Input.AttackValue.LostHp = uint32(e.Input.CalculatePower(opp, skill).IntPart())
|
|
|
|
e.Input.Exec(func(t input.Effect) bool { //计算暴击率加成
|
|
|
|
t.IsCrit(opp, skill)
|
|
e.Input.AttackValue.IsCritical = skill.Crit
|
|
return e.Input.AttackValue.IsCritical == 0
|
|
})
|
|
if e.Input.AttackValue.IsCritical == 1 {
|
|
e.Input.AttackValue.LostHp = e.Input.AttackValue.LostHp * 2
|
|
|
|
}
|
|
//这里注释掉,扣血在对方回合
|
|
if uint32(e.Input.AttackValue.LostHp) > opp.CurrentPet.Info.Hp {
|
|
opp.CurrentPet.Info.Hp = 0
|
|
} else {
|
|
opp.CurrentPet.Info.Hp = opp.CurrentPet.Info.Hp - e.Input.AttackValue.LostHp
|
|
}
|
|
|
|
}
|
|
func (this *Effect0) IsCrit(opp *input.Input, skill *info.SkillEntity) {
|
|
skill.Crit = 0
|
|
CritRate := utils.Max(skill.CritRate, 1)
|
|
CritRateR := this.Input.FightC.GetRand().Int31n(16)
|
|
//CritAtkFirst: 先出手时必定致命一击; 默认: 0
|
|
if skill.CritAtkFirst != 0 && this.Input.First {
|
|
CritRate = 16
|
|
}
|
|
//CritAtkSecond: 后出手时必定致命一击; 默认: 0
|
|
if skill.CritAtkSecond != 0 && !this.Input.First {
|
|
CritRate = 16
|
|
}
|
|
// CritSelfHalfHp: 自身体力低于一半时必定致命一击; 默认: 0
|
|
if skill.CritSelfHalfHp != 0 && (this.Input.CurrentPet.HP < int(this.Input.CurrentPet.Info.MaxHp)/2) {
|
|
CritRate = 16
|
|
}
|
|
// CritFoeHalfHp: 对方体力低于一半时必定致命一击; 默认: 0
|
|
if skill.CritSelfHalfHp != 0 && (opp.CurrentPet.HP < int(opp.CurrentPet.Info.MaxHp)/2) {
|
|
CritRate = 16
|
|
}
|
|
|
|
//todo 暴击伤害
|
|
if CritRateR <= int32(CritRate) {
|
|
skill.Crit = 1
|
|
}
|
|
|
|
}
|
|
func init() {
|
|
input.InitDamageEffect(0, &Effect0{})
|
|
|
|
}
|