diff --git a/logic/service/fight/info/BattlePetEntity.go b/logic/service/fight/info/BattlePetEntity.go index c6ff776b..7f9bd045 100644 --- a/logic/service/fight/info/BattlePetEntity.go +++ b/logic/service/fight/info/BattlePetEntity.go @@ -8,6 +8,9 @@ import ( "math/rand" "sync" "unsafe" + + "github.com/shopspring/decimal" + "github.com/tnnmigga/enum" ) // 战斗属性类型 @@ -69,7 +72,70 @@ type BattlePetEntity struct { Skills [4]*BattleSkillEntity // 技能槽(最多4个技能) Status StatusDict //精灵的状态 //能力提升属性 - Prop PropDict + Prop PropDict + DamageZone map[EnumCategory]map[EnumsZoneType]map[EnumsZoneType][]float64 // 三维map 伤害类型-》增还是减-》加还是乘-》值 +} + +// 获得指定的+-区 +func (s *BattlePetEntity) GetAddValue(e EnumCategory, c EnumsZoneType) decimal.Decimal { + + t, ok := s.DamageZone[e][c][DamageZone.add] + if ok { + var ttt decimal.Decimal + + for _, v := range t { + t1 := decimal.NewFromFloat(v) + ttt.Add(t1) + } + return ttt + } + return decimal.NewFromFloat(0) +} + +// 获得指定的*/区 +func (s *BattlePetEntity) GetMulValue(e EnumCategory, c EnumsZoneType) decimal.Decimal { + + t, ok := s.DamageZone[e][c][DamageZone.nul] + if ok { + var ttt decimal.Decimal + + for _, v := range t { + t1 := decimal.NewFromFloat(v) + ttt.Mul(t1) + } + return ttt + } + + return decimal.NewFromFloat(0) + +} + +// 设置指定的值 +// 三维map 伤害类型-》增还是减-》加还是乘-》值 +func (s *BattlePetEntity) PutDamageZone(e EnumCategory, dtype EnumsZoneType, value float64, ftype EnumsZoneType) { + s.DamageZone[e][dtype][ftype] = append(s.DamageZone[e][dtype][ftype], value) + // switch dtype { //判断伤害节点段 + + // //case Zone.Power: //特判乘算区的乘运算 + + // default: + // switch ftype { //判断设置哪个算区 + + // case true: // 乘算区 + // old := s.GetAddValue(e) + + // new := decimal.NewFromFloat(value) + // s.DamageZone[dtype] = float64(old.Add(new).IntPart()) + + // case false: // 加算区 + // old := s.GetMulValue(e) + + // new := decimal.NewFromFloat(value) + // s.DamageZone[dtype] = float64(old.Add(new).IntPart()) + + // } + // } + } // 创建精灵实例 @@ -82,7 +148,18 @@ func CreateBattlePetEntity(info model.PetInfo, rand *rand.Rand) *BattlePetEntity //todo 技能信息应该每回合进行深拷贝,保证每次的技能效果都是不一样的 ret.Skills[i] = CreateBattleSkillWithInfinity(&info.SkillList[i], rand, ret) } + ret.DamageZone = make(map[EnumCategory]map[EnumsZoneType]map[EnumsZoneType][]float64) //初始化第一层类型 + for _, v := range enum.Values[EnumCategory](Category) { + ret.DamageZone[v] = make(map[EnumsZoneType]map[EnumsZoneType][]float64) //初始化第二层是否是加还是减 + for _, t := range enum.Values[EnumsZoneType](DamageC) { + ret.DamageZone[v][t] = make(map[EnumsZoneType][]float64) //初始化第三层时乘还是加 + for _, s := range enum.Values[EnumsZoneType](DamageC) { + ret.DamageZone[v][t][s] = make([]float64, 0) //初始化第四层 数组 + + } + } + } return ret } diff --git a/logic/service/fight/info/BattleSkillEntity.go b/logic/service/fight/info/BattleSkillEntity.go index e3ad66fd..5168246f 100644 --- a/logic/service/fight/info/BattleSkillEntity.go +++ b/logic/service/fight/info/BattleSkillEntity.go @@ -37,9 +37,9 @@ var Category = enum.New[struct { // 战斗中可以修改技能实体值,比如是否暴击,是否必中等 type BattleSkillEntity struct { xmlres.Move - PP int - DamageZone map[EnumCategory]map[EnumsZoneType]map[EnumsZoneType][]float64 // 三维map 伤害类型-》增还是减-》加还是乘-》值 - DamageValue decimal.Decimal // 伤害值 + PP int + + DamageValue decimal.Decimal // 伤害值 Rand *rand.Rand Pet *BattlePetEntity } @@ -72,18 +72,6 @@ func CreateBattleSkillWithInfinity(skill *model.SkillInfo, rand *rand.Rand, pet // } ret.PP = int(skill.PP) // ret.SideEffectArgs = sideEffectArgs - ret.DamageZone = make(map[EnumCategory]map[EnumsZoneType]map[EnumsZoneType][]float64) //初始化第一层类型 - - for _, v := range enum.Values[EnumCategory](Category) { - ret.DamageZone[v] = make(map[EnumsZoneType]map[EnumsZoneType][]float64) //初始化第二层是否是加还是减 - for _, t := range enum.Values[EnumsZoneType](DamageC) { - ret.DamageZone[v][t] = make(map[EnumsZoneType][]float64) //初始化第三层时乘还是加 - for _, s := range enum.Values[EnumsZoneType](DamageC) { - ret.DamageZone[v][t][s] = make([]float64, 0) //初始化第四层 数组 - - } - } - } return &ret } @@ -166,68 +154,6 @@ var DamageC = enum.New[struct { // } -// 获得指定的+-区 -func (s *BattleSkillEntity) GetAddValue(e EnumCategory, c EnumsZoneType) decimal.Decimal { - - t, ok := s.DamageZone[e][c][DamageZone.add] - if ok { - var ttt decimal.Decimal - - for _, v := range t { - t1 := decimal.NewFromFloat(v) - ttt.Add(t1) - } - return ttt - } - return decimal.NewFromFloat(0) -} - -// 获得指定的*/区 -func (s *BattleSkillEntity) GetMulValue(e EnumCategory, c EnumsZoneType) decimal.Decimal { - - t, ok := s.DamageZone[e][c][DamageZone.nul] - if ok { - var ttt decimal.Decimal - - for _, v := range t { - t1 := decimal.NewFromFloat(v) - ttt.Mul(t1) - } - return ttt - } - - return decimal.NewFromFloat(0) - -} - -// 设置指定的值 -// 三维map 伤害类型-》增还是减-》加还是乘-》值 -func (s *BattleSkillEntity) PutDamageZone(e EnumCategory, dtype EnumsZoneType, value float64, ftype EnumsZoneType) { - s.DamageZone[e][dtype][ftype] = append(s.DamageZone[e][dtype][ftype], value) - // switch dtype { //判断伤害节点段 - - // //case Zone.Power: //特判乘算区的乘运算 - - // default: - // switch ftype { //判断设置哪个算区 - - // case true: // 乘算区 - // old := s.GetAddValue(e) - - // new := decimal.NewFromFloat(value) - // s.DamageZone[dtype] = float64(old.Add(new).IntPart()) - - // case false: // 加算区 - // old := s.GetMulValue(e) - - // new := decimal.NewFromFloat(value) - // s.DamageZone[dtype] = float64(old.Add(new).IntPart()) - - // } - // } - -} - // func (s *BattleSkillEntity) Pet() (*BattlePetEntity, bool) { // pet, ok := s.ctx.Value(Pet_O_Ctx).(*BattlePetEntity) @@ -287,8 +213,8 @@ func (s *BattleSkillEntity) CalculatePower(deftype int) uint32 { // 2. 计算威力因子 (基础威力 + 加算) * 乘算 //powerAdd := decimal.NewFromFloat(s.GetAddValue(EnumCategory., true)) //威力加算区 - powerAdd_all := s.GetAddValue(Category.ALL, DamageC.boost) - powerMul_all := s.GetMulValue(Category.ALL, DamageC.boost) + powerAdd_all := s.Pet.GetAddValue(Category.ALL, DamageC.boost) + powerMul_all := s.Pet.GetMulValue(Category.ALL, DamageC.boost) var ( powerAdd_p decimal.Decimal //威力加算 @@ -300,15 +226,15 @@ func (s *BattleSkillEntity) CalculatePower(deftype int) uint32 { switch s.Category() { //判断技能类型 case Category.PHYSICAL: - powerAdd_p = powerAdd_all.Add(s.GetAddValue(Category.PHYSICAL, DamageC.boost)) - powerMul_p = powerMul_all.Add(s.GetMulValue(Category.PHYSICAL, DamageC.boost)) + powerAdd_p = powerAdd_all.Add(s.Pet.GetAddValue(Category.PHYSICAL, DamageC.boost)) + powerMul_p = powerMul_all.Add(s.Pet.GetMulValue(Category.PHYSICAL, DamageC.boost)) attackDec = decimal.NewFromInt(int64(s.Pet.Attack())) defenseDec = decimal.NewFromInt(int64(s.Pet.Defense())) //damageReduction = decimal.NewFromFloat(s.DamageZone[DamageMultiplierZoneEnum.ATK_RESISTANCE]) case Category.SPECIAL: - powerAdd_p = powerAdd_all.Add(s.GetAddValue(Category.SPECIAL, DamageC.boost)) - powerMul_p = powerMul_all.Add(s.GetMulValue(Category.SPECIAL, DamageC.boost)) + powerAdd_p = powerAdd_all.Add(s.Pet.GetAddValue(Category.SPECIAL, DamageC.boost)) + powerMul_p = powerMul_all.Add(s.Pet.GetMulValue(Category.SPECIAL, DamageC.boost)) attackDec = decimal.NewFromInt(int64(s.Pet.SAttack())) defenseDec = decimal.NewFromInt(int64(s.Pet.SDefense())) //damageReduction = decimal.NewFromFloat(s.DamageZone[DamageMultiplierZoneEnum.SP_ATK_RESISTANCE]) diff --git a/logic/service/fight/info/info.go b/logic/service/fight/info/info.go index 2e1ddf01..996632e7 100644 --- a/logic/service/fight/info/info.go +++ b/logic/service/fight/info/info.go @@ -89,27 +89,32 @@ type AttackValue struct { // OwnerMaxShield uint32 `json:"ownerMaxShield" fieldDescription:"我方最大护盾"` // OwnerCurrentShield uint32 `json:"ownerCurrentShield" fieldDescription:"我方当前护盾"` } + +type WeakenedS struct { + Stack byte `struc:"skip"` + Round byte +} type StatusDict struct { - Paralysis_0 byte // 0: 麻痹 - Poisoned_1 byte // 1: 中毒 - Burned_2 byte // 2: 烧伤 - DrainHP_3 byte // 3: 吸取对方的体力 - DrainedHP_4 byte // 4: 被对方吸取体力 - Frozen_5 byte // 5: 冻伤 - Fear_6 byte // 6: 害怕 - Tired_7 byte // 7: 疲惫 - Sleep_8 byte // 8: 睡眠 - Petrified_9 byte // 9: 石化 - Confused_10 byte // 10: 混乱 - Weakened_11 byte // 11: 衰弱 - MountainGodGuard_12 byte // 12: 山神守护 - Flammable_13 byte // 13: 易燃 - Berserk_14 byte // 14: 狂暴 - IceBound_15 byte // 15: 冰封 - Bleeding_16 byte // 16: 流血 - ImmuneToStatDrop_17 byte // 17: 免疫能力下降 - ImmuneToAbnormal_18 byte // 18: 免疫异常状态 - Paralyzed_19 byte // 19: 瘫痪 + Paralysis_0 byte // 0: 麻痹 + Poisoned_1 byte // 1: 中毒 + Burned_2 byte // 2: 烧伤 + DrainHP_3 byte // 3: 吸取对方的体力 + DrainedHP_4 byte // 4: 被对方吸取体力 + Frozen_5 byte // 5: 冻伤 + Fear_6 byte // 6: 害怕 + Tired_7 byte // 7: 疲惫 + Sleep_8 byte // 8: 睡眠 + Petrified_9 byte // 9: 石化 + Confused_10 byte // 10: 混乱 + Weakened_11 WeakenedS // 11: 衰弱 + MountainGodGuard_12 byte // 12: 山神守护 + Flammable_13 byte // 13: 易燃 + Berserk_14 byte // 14: 狂暴 + IceBound_15 byte // 15: 冰封 + Bleeding_16 byte // 16: 流血 + ImmuneToStatDrop_17 byte // 17: 免疫能力下降 + ImmuneToAbnormal_18 byte // 18: 免疫异常状态 + Paralyzed_19 byte // 19: 瘫痪 //Blind_20 byte // 20: 失明 }