refactor: 重构 CurrentPet 为 CurPet
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-04-04 04:34:43 +08:00
committed by cnb
parent 6439995434
commit 9c6f3988de
395 changed files with 1424 additions and 1424 deletions

View File

@@ -59,7 +59,7 @@ func (our *Input) GetAction() {
s.DamageValue = our.CalculatePower(our.Opp, s)
// 判断是否能秒杀(伤害 >= 对方当前生命值)
if s.DamageValue.Cmp(our.Opp.CurrentPet[0].GetHP()) != -1 { // 假设oppPet.HP为对方当前剩余生命值
if s.DamageValue.Cmp(our.Opp.CurPet[0].GetHP()) != -1 { // 假设oppPet.HP为对方当前剩余生命值
if usedskill != nil {
if s.DamageValue.Cmp(usedskill.DamageValue) != -1 {

View File

@@ -1,7 +1,7 @@
package input
func (our *Input) CurrentDivineEnergy() int {
currentPet := our.PrimaryCurrentPet()
currentPet := our.PrimaryCurPet()
if currentPet == nil {
return 0
}
@@ -9,7 +9,7 @@ func (our *Input) CurrentDivineEnergy() int {
}
func (our *Input) AddDivineEnergy(value int) bool {
currentPet := our.PrimaryCurrentPet()
currentPet := our.PrimaryCurPet()
if currentPet == nil || value <= 0 {
return false
}
@@ -22,7 +22,7 @@ func (our *Input) AddDivineEnergy(value int) bool {
}
func (our *Input) ConsumeDivineEnergy() int {
currentPet := our.PrimaryCurrentPet()
currentPet := our.PrimaryCurPet()
if currentPet == nil {
return 0
}
@@ -33,7 +33,7 @@ func (our *Input) ConsumeDivineEnergy() int {
}
func (our *Input) ClearDivineEnergy() {
currentPet := our.PrimaryCurrentPet()
currentPet := our.PrimaryCurPet()
if currentPet == nil {
return
}

View File

@@ -93,7 +93,7 @@ func (our *Input) InitEffect(etype EnumEffectType, id int, a ...int) Effect {
func (our *Input) GetProp(id int) alpacadecimal.Decimal {
// 计算实际值(这里可以插入后续优化的函数调用)
realValue := info.CalculateRealValue(alpacadecimal.NewFromInt(int64(our.CurrentPet[0].Info.Prop[id])), our.AttackValue.Prop[id])
realValue := info.CalculateRealValue(alpacadecimal.NewFromInt(int64(our.CurPet[0].Info.Prop[id])), our.AttackValue.Prop[id])
// todo: 插入获取后处理函数,例如:
// realValue = postProcessValue(realValue, id, c)

View File

@@ -30,11 +30,11 @@ func (our *Input) CalculateCrit(opp *Input, skill *info.SkillEntity) {
CritRate = 16
}
// CritSelfHalfHp: 自身体力低于一半时必定致命一击; 默认: 0
if skill.XML.CritSelfHalfHp != 0 && (our.CurrentPet[0].HP < int(our.CurrentPet[0].Info.MaxHp)/2) {
if skill.XML.CritSelfHalfHp != 0 && (our.CurPet[0].HP < int(our.CurPet[0].Info.MaxHp)/2) {
CritRate = 16
}
// CritFoeHalfHp: 对方体力低于一半时必定致命一击; 默认: 0
if skill.XML.CritSelfHalfHp != 0 && (opp.CurrentPet[0].HP < int(opp.CurrentPet[0].Info.MaxHp)/2) {
if skill.XML.CritSelfHalfHp != 0 && (opp.CurPet[0].HP < int(opp.CurPet[0].Info.MaxHp)/2) {
CritRate = 16
}
@@ -67,30 +67,30 @@ func (our *Input) Heal(in *Input, ac action.BattleActionI, value alpacadecimal.D
}
if healValue >= 0 {
our.CurrentPet[0].Info.ModelHP(int64(healValue))
our.CurPet[0].Info.ModelHP(int64(healValue))
return
}
damage := uint32(-healValue)
if damage >= our.CurrentPet[0].Info.Hp {
our.CurrentPet[0].Info.Hp = 0
if damage >= our.CurPet[0].Info.Hp {
our.CurPet[0].Info.Hp = 0
return
}
our.CurrentPet[0].Info.Hp -= damage
our.CurPet[0].Info.Hp -= damage
}
func (our *Input) HealPP(value int) {
our.CurrentPet[0].Info.HealPP(value)
our.CurPet[0].Info.HealPP(value)
}
func (our *Input) DelPP(value int) {
for i := 0; i < len(our.CurrentPet[0].Info.SkillList); i++ {
if uint32(value) > our.CurrentPet[0].Info.SkillList[i].PP {
our.CurrentPet[0].Info.SkillList[i].PP = 0
for i := 0; i < len(our.CurPet[0].Info.SkillList); i++ {
if uint32(value) > our.CurPet[0].Info.SkillList[i].PP {
our.CurPet[0].Info.SkillList[i].PP = 0
} else {
our.CurrentPet[0].Info.SkillList[i].PP -= uint32(value)
our.CurPet[0].Info.SkillList[i].PP -= uint32(value)
}
}
@@ -196,11 +196,11 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) {
}
if uint32(sub.Damage.IntPart()) > our.CurrentPet[0].Info.Hp {
if uint32(sub.Damage.IntPart()) > our.CurPet[0].Info.Hp {
our.CurrentPet[0].Info.Hp = 0
our.CurPet[0].Info.Hp = 0
} else {
our.CurrentPet[0].Info.Hp = our.CurrentPet[0].Info.Hp - uint32(sub.Damage.IntPart())
our.CurPet[0].Info.Hp = our.CurPet[0].Info.Hp - uint32(sub.Damage.IntPart())
}
//todo 待实现死亡effet
@@ -211,7 +211,7 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) {
func (our *Input) CalculatePower(deftype *Input, skill *info.SkillEntity) alpacadecimal.Decimal {
// 1. 计算等级因子 (level * 0.4 + 2)
levelFactor := alpacadecimal.NewFromInt(int64(our.CurrentPet[0].Info.Level)).
levelFactor := alpacadecimal.NewFromInt(int64(our.CurPet[0].Info.Level)).
Mul(alpacadecimal.NewFromFloat(0.4)).Add(alpacadecimal.NewFromInt(2))
var (
@@ -239,17 +239,17 @@ func (our *Input) CalculatePower(deftype *Input, skill *info.SkillEntity) alpaca
// 11. DmgBindHpDv: 造成的伤害等于自身剩余体力*1/2+潜力(个体值); 默认: 0
if skill.XML.DmgBindLv != 0 {
skill.XML.Power = int(deftype.CurrentPet[0].Info.Level)
skill.XML.Power = int(deftype.CurPet[0].Info.Level)
}
if skill.XML.PwrBindDv != 0 {
if skill.XML.PwrBindDv == 1 {
skill.XML.Power = int(our.CurrentPet[0].Info.Dv * 5)
skill.XML.Power = int(our.CurPet[0].Info.Dv * 5)
}
if skill.XML.PwrBindDv == 2 {
skill.XML.Power = int(our.CurrentPet[0].Info.Hp/3 + our.CurrentPet[0].Info.Dv)
skill.XML.Power = int(our.CurPet[0].Info.Hp/3 + our.CurPet[0].Info.Dv)
}
}
@@ -261,7 +261,7 @@ func (our *Input) CalculatePower(deftype *Input, skill *info.SkillEntity) alpaca
}
if skill.XML.DmgBindHpDv != 0 {
skill.XML.Power = int(our.CurrentPet[0].Info.Hp/2 + our.CurrentPet[0].Info.Dv)
skill.XML.Power = int(our.CurPet[0].Info.Hp/2 + our.CurPet[0].Info.Dv)
}
// 5. 基础伤害公式:等级因子 * 威力因子 * 攻击 / 防御 / 50 + 2
@@ -272,8 +272,8 @@ func (our *Input) CalculatePower(deftype *Input, skill *info.SkillEntity) alpaca
Add(alpacadecimal.NewFromInt(2))
var typeRate alpacadecimal.Decimal
//fmt.Println(skill.Type().ID, deftype.CurrentPet[0].Type().ID)
t, _ := element.Calculator.GetOffensiveMultiplier(skill.GetType().ID, deftype.CurrentPet[0].GetType().ID)
//fmt.Println(skill.Type().ID, deftype.CurPet[0].Type().ID)
t, _ := element.Calculator.GetOffensiveMultiplier(skill.GetType().ID, deftype.CurPet[0].GetType().ID)
our.AttackValue.Offensive = gconv.Float32(t)
typeRate = alpacadecimal.NewFromFloat(t)

View File

@@ -18,7 +18,7 @@ import (
type Input struct {
CanChange uint32 //是否可以死亡切换CanChange
// CanAction bool //是否可以行动
CurrentPet []*info.BattlePetEntity //当前上场精灵
CurPet []*info.BattlePetEntity //当前上场精灵
AllPet []*info.BattlePetEntity
Player common.PlayerI
Opp *Input
@@ -53,7 +53,7 @@ type Input struct {
func NewInput(c common.FightI, p common.PlayerI) *Input {
ret := &Input{FightC: c, Player: p}
ret.Effects = make([]Effect, 0)
ret.CurrentPet = make([]*info.BattlePetEntity, 0)
ret.CurPet = make([]*info.BattlePetEntity, 0)
// t := Geteffect(EffectType.Damage, 0)
// t.Effect.SetArgs(ret)
@@ -64,25 +64,25 @@ func NewInput(c common.FightI, p common.PlayerI) *Input {
}
func (our *Input) CurrentPetAt(index int) *info.BattlePetEntity {
if our == nil || index < 0 || index >= len(our.CurrentPet) {
func (our *Input) CurPetAt(index int) *info.BattlePetEntity {
if our == nil || index < 0 || index >= len(our.CurPet) {
return nil
}
return our.CurrentPet[index]
return our.CurPet[index]
}
func (our *Input) PrimaryCurrentPet() *info.BattlePetEntity {
return our.CurrentPetAt(0)
func (our *Input) PrimaryCurPet() *info.BattlePetEntity {
return our.CurPetAt(0)
}
func (our *Input) SetCurrentPetAt(index int, pet *info.BattlePetEntity) {
func (our *Input) SetCurPetAt(index int, pet *info.BattlePetEntity) {
if our == nil || index < 0 {
return
}
for len(our.CurrentPet) <= index {
our.CurrentPet = append(our.CurrentPet, nil)
for len(our.CurPet) <= index {
our.CurPet = append(our.CurPet, nil)
}
our.CurrentPet[index] = pet
our.CurPet[index] = pet
}
// 非原地交换收集非0血量精灵 + 0血量精灵拼接后返回
@@ -124,7 +124,7 @@ func (our *Input) SortPet() {
func (our *Input) GetPetInfo() *info.BattlePetEntity {
return our.PrimaryCurrentPet()
return our.PrimaryCurPet()
}
func (our *Input) SetOPP(t *Input) {
@@ -186,7 +186,7 @@ func (our *Input) GenSataus() {
}
func (our *Input) GenInfo() {
currentPet := our.PrimaryCurrentPet()
currentPet := our.PrimaryCurPet()
if currentPet == nil {
return
}
@@ -194,8 +194,8 @@ func (our *Input) GenInfo() {
our.RemainHp = int32(currentPet.Info.Hp)
our.SkillList = currentPet.Info.SkillList
// f.Second.SkillList = f.Second.CurrentPet.Info.SkillList
// f.Second.RemainHp = int32(f.Second.CurrentPet.Info.Hp)
// f.Second.SkillList = f.Second.CurPet.Info.SkillList
// f.Second.RemainHp = int32(f.Second.CurPet.Info.Hp)
// ret.FAttack = *f.First.AttackValue
// ret.SAttack = *f.Second.AttackValue

View File

@@ -7,7 +7,7 @@ type shieldChangeEffect interface {
}
func (our *Input) CurrentShield() alpacadecimal.Decimal {
currentPet := our.PrimaryCurrentPet()
currentPet := our.PrimaryCurPet()
if currentPet == nil {
return alpacadecimal.Zero
}
@@ -19,7 +19,7 @@ func (our *Input) HasShield() bool {
}
func (our *Input) AddShield(value alpacadecimal.Decimal) bool {
currentPet := our.PrimaryCurrentPet()
currentPet := our.PrimaryCurPet()
if currentPet == nil {
return false
}
@@ -33,7 +33,7 @@ func (our *Input) AddShield(value alpacadecimal.Decimal) bool {
}
func (our *Input) AbsorbShieldDamage(damage alpacadecimal.Decimal) alpacadecimal.Decimal {
currentPet := our.PrimaryCurrentPet()
currentPet := our.PrimaryCurPet()
if currentPet == nil {
return alpacadecimal.Zero
}
@@ -52,7 +52,7 @@ func (our *Input) AbsorbShieldDamage(damage alpacadecimal.Decimal) alpacadecimal
}
func (our *Input) ConsumeAllShield() alpacadecimal.Decimal {
currentPet := our.PrimaryCurrentPet()
currentPet := our.PrimaryCurPet()
if currentPet == nil {
return alpacadecimal.Zero
}