diff --git a/cmd/wowsimcli/cmd/decode_link.go b/cmd/wowsimcli/cmd/decode_link.go index 9c6491761f..bb7aa2d15b 100644 --- a/cmd/wowsimcli/cmd/decode_link.go +++ b/cmd/wowsimcli/cmd/decode_link.go @@ -8,10 +8,10 @@ import ( "fmt" "strings" - goproto "github.com/golang/protobuf/proto" "github.com/spf13/cobra" "github.com/wowsims/wotlk/sim/core/proto" "google.golang.org/protobuf/encoding/protojson" + goproto "google.golang.org/protobuf/proto" ) var decodeLinkCmd = &cobra.Command{ diff --git a/go.mod b/go.mod index 14338b8225..dac974b0c8 100644 --- a/go.mod +++ b/go.mod @@ -3,14 +3,13 @@ module github.com/wowsims/wotlk go 1.21 require ( - github.com/golang/protobuf v1.5.3 github.com/google/go-cmp v0.5.8 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 github.com/satori/go.uuid v1.2.0 github.com/spf13/cobra v1.7.0 github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a golang.org/x/exp v0.0.0-20221028150844-83b7d23a625f - google.golang.org/protobuf v1.30.0 + google.golang.org/protobuf v1.31.0 ) require ( diff --git a/go.sum b/go.sum index 184c3f9132..6b79c8a8e0 100644 --- a/go.sum +++ b/go.sum @@ -33,6 +33,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/sim/common/tbc/melee_items.go b/sim/common/tbc/melee_items.go index 5c1b7fc6e3..7f40d11c0f 100644 --- a/sim/common/tbc/melee_items.go +++ b/sim/common/tbc/melee_items.go @@ -55,7 +55,7 @@ func init() { }) } - numHits := core.MinInt32(5, character.Env.GetNumTargets()) + numHits := min(5, character.Env.GetNumTargets()) debuffAuras := make([]*core.Aura, len(character.Env.Encounter.TargetUnits)) for i, target := range character.Env.Encounter.TargetUnits { debuffAuras[i] = makeDebuffAura(target) diff --git a/sim/common/wotlk/other_effects.go b/sim/common/wotlk/other_effects.go index 6fee56fec2..584dc6581a 100644 --- a/sim/common/wotlk/other_effects.go +++ b/sim/common/wotlk/other_effects.go @@ -22,7 +22,7 @@ func init() { character.AddDynamicDamageTakenModifier(func(sim *core.Simulation, spell *core.Spell, result *core.SpellResult) { if procAura.IsActive() { - result.Damage = core.MaxFloat(0, result.Damage-140) + result.Damage = max(0, result.Damage-140) } }) @@ -52,7 +52,7 @@ func init() { character.AddDynamicDamageTakenModifier(func(sim *core.Simulation, spell *core.Spell, result *core.SpellResult) { if procAura.IsActive() { - result.Damage = core.MaxFloat(0, result.Damage-205) + result.Damage = max(0, result.Damage-205) } }) diff --git a/sim/core/apl_values_operators.go b/sim/core/apl_values_operators.go index b10c13eb7b..0744faf6aa 100644 --- a/sim/core/apl_values_operators.go +++ b/sim/core/apl_values_operators.go @@ -486,14 +486,14 @@ func (value *APLValueMax) Type() proto.APLValueType { func (value *APLValueMax) GetInt(sim *Simulation) int32 { result := value.vals[0].GetInt(sim) for i := 1; i < len(value.vals); i++ { - result = MaxInt32(result, value.vals[i].GetInt(sim)) + result = max(result, value.vals[i].GetInt(sim)) } return result } func (value *APLValueMax) GetFloat(sim *Simulation) float64 { result := value.vals[0].GetFloat(sim) for i := 1; i < len(value.vals); i++ { - result = MaxFloat(result, value.vals[i].GetFloat(sim)) + result = max(result, value.vals[i].GetFloat(sim)) } return result } @@ -537,14 +537,14 @@ func (value *APLValueMin) Type() proto.APLValueType { func (value *APLValueMin) GetInt(sim *Simulation) int32 { result := value.vals[0].GetInt(sim) for i := 1; i < len(value.vals); i++ { - result = MinInt32(result, value.vals[i].GetInt(sim)) + result = min(result, value.vals[i].GetInt(sim)) } return result } func (value *APLValueMin) GetFloat(sim *Simulation) float64 { result := value.vals[0].GetFloat(sim) for i := 1; i < len(value.vals); i++ { - result = MinFloat(result, value.vals[i].GetFloat(sim)) + result = min(result, value.vals[i].GetFloat(sim)) } return result } diff --git a/sim/core/attack.go b/sim/core/attack.go index 5dae44aea4..08ae1d4455 100644 --- a/sim/core/attack.go +++ b/sim/core/attack.go @@ -1,9 +1,10 @@ package core import ( - "golang.org/x/exp/slices" "time" + "golang.org/x/exp/slices" + "github.com/wowsims/wotlk/sim/core/proto" "github.com/wowsims/wotlk/sim/core/stats" ) @@ -294,13 +295,13 @@ func (unit *Unit) EnableAutoAttacks(agent Agent, options AutoAttackOptions) { if unit.Type == EnemyUnit { unit.AutoAttacks.MHConfig.ApplyEffects = func(sim *Simulation, target *Unit, spell *Spell) { - ap := MaxFloat(0, spell.Unit.stats[stats.AttackPower]) + ap := max(0, spell.Unit.stats[stats.AttackPower]) baseDamage := spell.Unit.AutoAttacks.MH.EnemyWeaponDamage(sim, ap, spell.Unit.PseudoStats.DamageSpread) spell.CalcAndDealDamage(sim, target, baseDamage, spell.OutcomeEnemyMeleeWhite) } unit.AutoAttacks.OHConfig.ApplyEffects = func(sim *Simulation, target *Unit, spell *Spell) { - ap := MaxFloat(0, spell.Unit.stats[stats.AttackPower]) + ap := max(0, spell.Unit.stats[stats.AttackPower]) baseDamage := spell.Unit.AutoAttacks.MH.EnemyWeaponDamage(sim, ap, spell.Unit.PseudoStats.DamageSpread) * 0.5 spell.CalcAndDealDamage(sim, target, baseDamage, spell.OutcomeEnemyMeleeWhite) diff --git a/sim/core/aura.go b/sim/core/aura.go index bebc4cac27..c75cdbb3b0 100644 --- a/sim/core/aura.go +++ b/sim/core/aura.go @@ -2,11 +2,12 @@ package core import ( "fmt" - "golang.org/x/exp/constraints" "math" "strconv" "time" + "golang.org/x/exp/constraints" + "github.com/wowsims/wotlk/sim/core/proto" "github.com/wowsims/wotlk/sim/core/stats" ) @@ -183,7 +184,7 @@ func (aura *Aura) SetStacks(sim *Simulation, newStacks int32) { panic("MaxStacks required to set Aura stacks: " + aura.Label) } oldStacks := aura.stacks - newStacks = MinInt32(newStacks, aura.MaxStacks) + newStacks = min(newStacks, aura.MaxStacks) if oldStacks == newStacks { return diff --git a/sim/core/buffs.go b/sim/core/buffs.go index dc344f5139..b1e4c3b4f8 100644 --- a/sim/core/buffs.go +++ b/sim/core/buffs.go @@ -162,7 +162,7 @@ func applyBuffEffects(agent Agent, raidBuffs *proto.RaidBuffs, partyBuffs *proto kingsStrStamAmount = 1.1 } else if raidBuffs.DrumsOfForgottenKings { kingsAgiIntSpiAmount = 1.08 - kingsStrStamAmount = MaxFloat(kingsStrStamAmount, 1.08) + kingsStrStamAmount = max(kingsStrStamAmount, 1.08) } if kingsStrStamAmount > 0 { character.MultiplyStat(stats.Strength, kingsStrStamAmount) @@ -379,7 +379,7 @@ func ApplyInspiration(character *Character, uptime float64) { if uptime <= 0 { return } - uptime = MinFloat(1, uptime) + uptime = min(1, uptime) inspirationAura := InspirationAura(&character.Unit, 3) diff --git a/sim/core/bulksim.go b/sim/core/bulksim.go index 52c5bee564..85de99c47c 100644 --- a/sim/core/bulksim.go +++ b/sim/core/bulksim.go @@ -12,7 +12,7 @@ import ( "sync/atomic" "time" - goproto "github.com/golang/protobuf/proto" + goproto "google.golang.org/protobuf/proto" "github.com/wowsims/wotlk/sim/core/proto" ) diff --git a/sim/core/bulksim_test.go b/sim/core/bulksim_test.go index d203020671..3defe75e8c 100644 --- a/sim/core/bulksim_test.go +++ b/sim/core/bulksim_test.go @@ -4,9 +4,9 @@ import ( "context" "testing" - goproto "github.com/golang/protobuf/proto" "github.com/google/go-cmp/cmp" "github.com/wowsims/wotlk/sim/core/proto" + goproto "google.golang.org/protobuf/proto" ) const ( diff --git a/sim/core/cast.go b/sim/core/cast.go index 8deccda11b..5d7663f648 100644 --- a/sim/core/cast.go +++ b/sim/core/cast.go @@ -139,7 +139,7 @@ func (spell *Spell) makeCastFunc(config CastConfig) CastSuccessFunc { if spell.CurCast.CastTime > 0 { if sim.Log != nil && !spell.Flags.Matches(SpellFlagNoLogs) { spell.Unit.Log(sim, "Casting %s (Cost = %0.03f, Cast Time = %s, Effective Time = %s)", - spell.ActionID, MaxFloat(0, spell.CurCast.Cost), spell.CurCast.CastTime, spell.CurCast.EffectiveTime()) + spell.ActionID, max(0, spell.CurCast.Cost), spell.CurCast.CastTime, spell.CurCast.EffectiveTime()) } spell.Unit.Hardcast = Hardcast{ @@ -177,7 +177,7 @@ func (spell *Spell) makeCastFunc(config CastConfig) CastSuccessFunc { if sim.Log != nil && !spell.Flags.Matches(SpellFlagNoLogs) { spell.Unit.Log(sim, "Casting %s (Cost = %0.03f, Cast Time = %s, Effective Time = %s)", - spell.ActionID, MaxFloat(0, spell.CurCast.Cost), spell.CurCast.CastTime, spell.CurCast.EffectiveTime()) + spell.ActionID, max(0, spell.CurCast.Cost), spell.CurCast.CastTime, spell.CurCast.EffectiveTime()) spell.Unit.Log(sim, "Completed cast %s", spell.ActionID) } @@ -260,6 +260,6 @@ func (spell *Spell) makeCastFuncAutosOrProcs() CastSuccessFunc { func (spell *Spell) ApplyCostModifiers(cost float64) float64 { cost -= spell.Unit.PseudoStats.CostReduction - cost = MaxFloat(0, cost*spell.Unit.PseudoStats.CostMultiplier) - return MaxFloat(0, cost*spell.CostMultiplier) + cost = max(0, cost*spell.Unit.PseudoStats.CostMultiplier) + return max(0, cost*spell.CostMultiplier) } diff --git a/sim/core/dot.go b/sim/core/dot.go index 94b318ec1d..4b0ff35f4d 100644 --- a/sim/core/dot.go +++ b/sim/core/dot.go @@ -76,7 +76,7 @@ func (dot *Dot) MaxTicksRemaining() int32 { func (dot *Dot) NumTicksRemaining(sim *Simulation) int { maxTicksRemaining := dot.MaxTicksRemaining() finalTickAt := dot.lastTickTime + dot.tickPeriod*time.Duration(maxTicksRemaining) - return MaxInt(0, int((finalTickAt-sim.CurrentTime)/dot.tickPeriod)+1) + return max(0, int((finalTickAt-sim.CurrentTime)/dot.tickPeriod)+1) } // Roll over = gets carried over with everlasting refresh and doesn't get applied if triggered when the spell is already up. diff --git a/sim/core/energy.go b/sim/core/energy.go index 1366def16b..3c130ff5b5 100644 --- a/sim/core/energy.go +++ b/sim/core/energy.go @@ -36,7 +36,7 @@ func (unit *Unit) EnableEnergyBar(maxEnergy float64, onEnergyGain OnEnergyGain) unit.energyBar = energyBar{ unit: unit, - maxEnergy: MaxFloat(100, maxEnergy), + maxEnergy: max(100, maxEnergy), onEnergyGain: func(sim *Simulation) { if !sim.Options.Interactive && (!unit.IsWaitingForEnergy() || unit.DoneWaitingForEnergy(sim)) { if unit.IsUsingAPL { @@ -69,7 +69,7 @@ func (eb *energyBar) addEnergyInternal(sim *Simulation, amount float64, metrics panic("Trying to add negative energy!") } - newEnergy := MinFloat(eb.currentEnergy+amount, eb.maxEnergy) + newEnergy := min(eb.currentEnergy+amount, eb.maxEnergy) metrics.AddEvent(amount, newEnergy-eb.currentEnergy) if sim.Log != nil { @@ -114,7 +114,7 @@ func (eb *energyBar) ResetEnergyTick(sim *Simulation) { } func (eb *energyBar) AddComboPoints(sim *Simulation, pointsToAdd int32, metrics *ResourceMetrics) { - newComboPoints := MinInt32(eb.comboPoints+pointsToAdd, 5) + newComboPoints := min(eb.comboPoints+pointsToAdd, 5) metrics.AddEvent(float64(pointsToAdd), float64(newComboPoints-eb.comboPoints)) if sim.Log != nil { diff --git a/sim/core/focus.go b/sim/core/focus.go index 8bc979b50f..fa75f650a3 100644 --- a/sim/core/focus.go +++ b/sim/core/focus.go @@ -46,7 +46,7 @@ func (fb *focusBar) AddFocus(sim *Simulation, amount float64, actionID ActionID) panic("Trying to add negative focus!") } - newFocus := MinFloat(fb.currentFocus+amount, MaxFocus) + newFocus := min(fb.currentFocus+amount, MaxFocus) if sim.Log != nil { fb.unit.Log(sim, "Gained %0.3f focus from %s (%0.3f --> %0.3f).", amount, actionID, fb.currentFocus, newFocus) @@ -119,7 +119,7 @@ func newFocusCost(spell *Spell, options FocusCostOptions) *FocusCost { } func (fc *FocusCost) MeetsRequirement(spell *Spell) bool { - spell.CurCast.Cost = MaxFloat(0, spell.CurCast.Cost*spell.Unit.PseudoStats.CostMultiplier) + spell.CurCast.Cost = max(0, spell.CurCast.Cost*spell.Unit.PseudoStats.CostMultiplier) return spell.Unit.CurrentFocus() >= spell.CurCast.Cost } func (fc *FocusCost) LogCostFailure(sim *Simulation, spell *Spell) { diff --git a/sim/core/health.go b/sim/core/health.go index b9b401d248..280b55a0d9 100644 --- a/sim/core/health.go +++ b/sim/core/health.go @@ -51,7 +51,7 @@ func (hb *healthBar) GainHealth(sim *Simulation, amount float64, metrics *Resour } oldHealth := hb.currentHealth - newHealth := MinFloat(oldHealth+amount, hb.unit.MaxHealth()) + newHealth := min(oldHealth+amount, hb.unit.MaxHealth()) metrics.AddEvent(amount, newHealth-oldHealth) if sim.Log != nil { @@ -67,7 +67,7 @@ func (hb *healthBar) RemoveHealth(sim *Simulation, amount float64) { } oldHealth := hb.currentHealth - newHealth := MaxFloat(oldHealth-amount, 0) + newHealth := max(oldHealth-amount, 0) metrics := hb.DamageTakenHealthMetrics metrics.AddEvent(-amount, newHealth-oldHealth) @@ -151,7 +151,7 @@ func (character *Character) applyHealingModel(healingModel *proto.HealingModel) if medianCadence == 0 { medianCadence = 2.0 } - minCadence := MaxFloat(0.0, medianCadence-healingModel.CadenceVariation) + minCadence := max(0.0, medianCadence-healingModel.CadenceVariation) cadenceVariationLow := medianCadence - minCadence healthMetrics := character.NewHealthMetrics(ActionID{OtherID: proto.OtherAction_OtherActionHealingModel}) diff --git a/sim/core/mana.go b/sim/core/mana.go index 018bc72aaf..470399d665 100644 --- a/sim/core/mana.go +++ b/sim/core/mana.go @@ -94,7 +94,7 @@ func (unit *Unit) AddMana(sim *Simulation, amount float64, metrics *ResourceMetr } oldMana := unit.CurrentMana() - newMana := MinFloat(oldMana+amount, unit.MaxMana()) + newMana := min(oldMana+amount, unit.MaxMana()) metrics.AddEvent(amount, newMana-oldMana) if sim.Log != nil { @@ -194,10 +194,10 @@ func (unit *Unit) UpdateManaRegenRates() { func (unit *Unit) ManaTick(sim *Simulation) { if sim.CurrentTime < unit.PseudoStats.FiveSecondRuleRefreshTime { regen := unit.manaTickWhileCasting - unit.AddMana(sim, MaxFloat(0, regen), unit.manaCastingMetrics) + unit.AddMana(sim, max(0, regen), unit.manaCastingMetrics) } else { regen := unit.manaTickWhileNotCasting - unit.AddMana(sim, MaxFloat(0, regen), unit.manaNotCastingMetrics) + unit.AddMana(sim, max(0, regen), unit.manaNotCastingMetrics) } } @@ -307,7 +307,7 @@ func newManaCost(spell *Spell, options ManaCostOptions) *ManaCost { baseCost := TernaryFloat64(options.FlatCost > 0, options.FlatCost, options.BaseCost*spell.Unit.BaseMana) if player := spell.Unit.Env.Raid.GetPlayerFromUnit(spell.Unit); player != nil { if player.GetCharacter().HasTrinketEquipped(45703) { // Spark of Hope - baseCost = MaxFloat(0, baseCost-44) + baseCost = max(0, baseCost-44) } } diff --git a/sim/core/rage.go b/sim/core/rage.go index 24dbf8230b..aaf6883bc9 100644 --- a/sim/core/rage.go +++ b/sim/core/rage.go @@ -70,7 +70,7 @@ func (unit *Unit) EnableRageBar(options RageBarOptions, onRageGain OnRageGain) { } // generatedRage is capped for very low damage swings - generatedRage := MinFloat((damage*7.5/RageFactor+hitFactor*speed)/2, damage*15/RageFactor) + generatedRage := min((damage*7.5/RageFactor+hitFactor*speed)/2, damage*15/RageFactor) generatedRage *= options.RageMultiplier @@ -101,7 +101,7 @@ func (unit *Unit) EnableRageBar(options RageBarOptions, onRageGain OnRageGain) { unit.rageBar = rageBar{ unit: unit, - startingRage: MaxFloat(0, MinFloat(options.StartingRage, MaxRage)), + startingRage: max(0, min(options.StartingRage, MaxRage)), onRageGain: onRageGain, RageRefundMetrics: unit.NewRageMetrics(ActionID{OtherID: proto.OtherAction_OtherActionRefund}), @@ -121,7 +121,7 @@ func (rb *rageBar) AddRage(sim *Simulation, amount float64, metrics *ResourceMet panic("Trying to add negative rage!") } - newRage := MinFloat(rb.currentRage+amount, MaxRage) + newRage := min(rb.currentRage+amount, MaxRage) metrics.AddEvent(amount, newRage-rb.currentRage) if sim.Log != nil { diff --git a/sim/core/raid.go b/sim/core/raid.go index 6a31dedbd4..02374ff1a1 100644 --- a/sim/core/raid.go +++ b/sim/core/raid.go @@ -206,7 +206,7 @@ func NewRaid(raidConfig *proto.Raid) *Raid { } } - numDummies := MinInt(24, int(raidConfig.TargetDummies)) + numDummies := min(24, int(raidConfig.TargetDummies)) for i := 0; i < numDummies; i++ { party, partyIndex := raid.GetFirstEmptyRaidIndex() dummy := NewTargetDummy(i, party, partyIndex) @@ -383,7 +383,7 @@ func (raid *Raid) GetPlayerFromUnit(unit *Unit) Agent { } func (raid *Raid) GetFirstNPlayersOrPets(n int32) []*Unit { - return raid.AllUnits[:MinInt32(n, int32(len(raid.AllUnits)))] + return raid.AllUnits[:min(n, int32(len(raid.AllUnits)))] } func (raid *Raid) GetPlayerFromUnitIndex(unitIndex int32) Agent { diff --git a/sim/core/runic_power.go b/sim/core/runic_power.go index b065de467c..18df9163fb 100644 --- a/sim/core/runic_power.go +++ b/sim/core/runic_power.go @@ -156,7 +156,7 @@ func (rp *runicPowerBar) addRunicPowerInterval(sim *Simulation, amount float64, panic("Trying to add negative runic power!") } - newRunicPower := MinFloat(rp.currentRunicPower+amount, rp.maxRunicPower) + newRunicPower := min(rp.currentRunicPower+amount, rp.maxRunicPower) metrics.AddEvent(amount, newRunicPower-rp.currentRunicPower) diff --git a/sim/core/spell.go b/sim/core/spell.go index ef5cbe3292..f82ca92b31 100644 --- a/sim/core/spell.go +++ b/sim/core/spell.go @@ -224,7 +224,7 @@ func (unit *Unit) RegisterSpell(config SpellConfig) *Spell { ThreatMultiplier: config.ThreatMultiplier, FlatThreatBonus: config.FlatThreatBonus, - splitSpellMetrics: make([][]SpellMetrics, MaxInt(1, config.MetricSplits)), + splitSpellMetrics: make([][]SpellMetrics, max(1, config.MetricSplits)), RelatedAuras: config.RelatedAuras, } diff --git a/sim/core/spell_outcome.go b/sim/core/spell_outcome.go index 27ef49834a..dc91175b15 100644 --- a/sim/core/spell_outcome.go +++ b/sim/core/spell_outcome.go @@ -381,7 +381,7 @@ func (result *SpellResult) applyAttackTableMiss(spell *Spell, attackTable *Attac if spell.Unit.AutoAttacks.IsDualWielding && !spell.Unit.PseudoStats.DisableDWMissPenalty { missChance += 0.19 } - *chance = MaxFloat(0, missChance) + *chance = max(0, missChance) if roll < *chance { result.Outcome = OutcomeMiss @@ -394,7 +394,7 @@ func (result *SpellResult) applyAttackTableMiss(spell *Spell, attackTable *Attac func (result *SpellResult) applyAttackTableMissNoDWPenalty(spell *Spell, attackTable *AttackTable, roll float64, chance *float64) bool { missChance := attackTable.BaseMissChance - spell.PhysicalHitChance(attackTable) - *chance = MaxFloat(0, missChance) + *chance = max(0, missChance) if roll < *chance { result.Outcome = OutcomeMiss @@ -411,7 +411,7 @@ func (result *SpellResult) applyAttackTableBlock(spell *Spell, attackTable *Atta if roll < *chance { result.Outcome |= OutcomeBlock spell.SpellMetrics[result.Target.UnitIndex].Blocks++ - result.Damage = MaxFloat(0, result.Damage-result.Target.BlockValue()) + result.Damage = max(0, result.Damage-result.Target.BlockValue()) return true } return false @@ -422,7 +422,7 @@ func (result *SpellResult) applyAttackTableDodge(spell *Spell, attackTable *Atta return false } - *chance += MaxFloat(0, attackTable.BaseDodgeChance-spell.ExpertisePercentage()-spell.Unit.PseudoStats.DodgeReduction) + *chance += max(0, attackTable.BaseDodgeChance-spell.ExpertisePercentage()-spell.Unit.PseudoStats.DodgeReduction) if roll < *chance { result.Outcome = OutcomeDodge @@ -434,7 +434,7 @@ func (result *SpellResult) applyAttackTableDodge(spell *Spell, attackTable *Atta } func (result *SpellResult) applyAttackTableParry(spell *Spell, attackTable *AttackTable, roll float64, chance *float64) bool { - *chance += MaxFloat(0, attackTable.BaseParryChance-spell.ExpertisePercentage()) + *chance += max(0, attackTable.BaseParryChance-spell.ExpertisePercentage()) if roll < *chance { result.Outcome = OutcomeParry @@ -508,7 +508,7 @@ func (result *SpellResult) applyEnemyAttackTableMiss(spell *Spell, attackTable * if spell.Unit.AutoAttacks.IsDualWielding && !spell.Unit.PseudoStats.DisableDWMissPenalty { missChance += 0.19 } - *chance = MaxFloat(0, missChance) + *chance = max(0, missChance) if roll < *chance { result.Outcome = OutcomeMiss @@ -527,12 +527,12 @@ func (result *SpellResult) applyEnemyAttackTableBlock(spell *Spell, attackTable blockChance := attackTable.BaseBlockChance + result.Target.stats[stats.Block]/BlockRatingPerBlockChance/100 + result.Target.stats[stats.Defense]*DefenseRatingToChanceReduction - *chance += MaxFloat(0, blockChance) + *chance += max(0, blockChance) if roll < *chance { result.Outcome |= OutcomeBlock spell.SpellMetrics[result.Target.UnitIndex].Blocks++ - result.Damage = MaxFloat(0, result.Damage-result.Target.BlockValue()) + result.Damage = max(0, result.Damage-result.Target.BlockValue()) return true } return false @@ -547,7 +547,7 @@ func (result *SpellResult) applyEnemyAttackTableDodge(spell *Spell, attackTable result.Target.PseudoStats.BaseDodge + result.Target.GetDiminishedDodgeChance() - spell.Unit.PseudoStats.DodgeReduction - *chance += MaxFloat(0, dodgeChance) + *chance += max(0, dodgeChance) if roll < *chance { result.Outcome = OutcomeDodge @@ -566,7 +566,7 @@ func (result *SpellResult) applyEnemyAttackTableParry(spell *Spell, attackTable parryChance := attackTable.BaseParryChance + result.Target.PseudoStats.BaseParry + result.Target.GetDiminishedParryChance() - *chance += MaxFloat(0, parryChance) + *chance += max(0, parryChance) if roll < *chance { result.Outcome = OutcomeParry @@ -584,7 +584,7 @@ func (result *SpellResult) applyEnemyAttackTableCrit(spell *Spell, _ *AttackTabl critChance -= result.Target.stats[stats.Defense] * DefenseRatingToChanceReduction critChance -= result.Target.stats[stats.Resilience] / ResilienceRatingPerCritReductionChance / 100 critChance -= result.Target.PseudoStats.ReducedCritTakenChance - *chance += MaxFloat(0, critChance) + *chance += max(0, critChance) if roll < *chance { result.Outcome = OutcomeCrit diff --git a/sim/core/spell_resistances.go b/sim/core/spell_resistances.go index e808a66c95..7d84f3727a 100644 --- a/sim/core/spell_resistances.go +++ b/sim/core/spell_resistances.go @@ -63,7 +63,7 @@ func (spell *Spell) ResistanceMultiplier(sim *Simulation, isPeriodic bool, attac func (at *AttackTable) GetArmorDamageModifier(spell *Spell) float64 { armorConstant := float64(at.Attacker.Level)*467.5 - 22167.5 defenderArmor := at.Defender.Armor() - reducibleArmor := MinFloat((defenderArmor+armorConstant)/3, defenderArmor) + reducibleArmor := min((defenderArmor+armorConstant)/3, defenderArmor) armorPenRating := at.Attacker.stats[stats.ArmorPenetration] + spell.BonusArmorPenRating effectiveArmor := defenderArmor - reducibleArmor*at.Attacker.ArmorPenetrationPercentage(armorPenRating) return 1 - effectiveArmor/(effectiveArmor+armorConstant) diff --git a/sim/core/spell_result.go b/sim/core/spell_result.go index 91ca7e7bea..6b27318f43 100644 --- a/sim/core/spell_result.go +++ b/sim/core/spell_result.go @@ -161,7 +161,7 @@ func (spell *Spell) ApplyPostOutcomeDamageModifiers(sim *Simulation, result *Spe for i := range result.Target.DynamicDamageTakenModifiers { result.Target.DynamicDamageTakenModifiers[i](sim, spell, result) } - result.Damage = MaxFloat(0, result.Damage) + result.Damage = max(0, result.Damage) } // For spells that do no damage but still have a hit/miss check. diff --git a/sim/core/target.go b/sim/core/target.go index ec24a8b46a..9df107e6bb 100644 --- a/sim/core/target.go +++ b/sim/core/target.go @@ -30,15 +30,15 @@ type Encounter struct { } func NewEncounter(options *proto.Encounter) Encounter { - options.ExecuteProportion_25 = MaxFloat(options.ExecuteProportion_25, options.ExecuteProportion_20) - options.ExecuteProportion_35 = MaxFloat(options.ExecuteProportion_35, options.ExecuteProportion_25) + options.ExecuteProportion_25 = max(options.ExecuteProportion_25, options.ExecuteProportion_20) + options.ExecuteProportion_35 = max(options.ExecuteProportion_35, options.ExecuteProportion_25) encounter := Encounter{ Duration: DurationFromSeconds(options.Duration), DurationVariation: DurationFromSeconds(options.DurationVariation), - ExecuteProportion_20: MaxFloat(options.ExecuteProportion_20, 0), - ExecuteProportion_25: MaxFloat(options.ExecuteProportion_25, 0), - ExecuteProportion_35: MaxFloat(options.ExecuteProportion_35, 0), + ExecuteProportion_20: max(options.ExecuteProportion_20, 0), + ExecuteProportion_25: max(options.ExecuteProportion_25, 0), + ExecuteProportion_35: max(options.ExecuteProportion_35, 0), Targets: []*Target{}, } // If UseHealth is set, we use the sum of targets health. @@ -79,7 +79,7 @@ func (encounter *Encounter) AOECapMultiplier() float64 { return encounter.aoeCapMultiplier } func (encounter *Encounter) updateAOECapMultiplier() { - encounter.aoeCapMultiplier = MinFloat(10/float64(len(encounter.Targets)), 1) + encounter.aoeCapMultiplier = min(10/float64(len(encounter.Targets)), 1) } func (encounter *Encounter) doneIteration(sim *Simulation) { diff --git a/sim/core/test_generators.go b/sim/core/test_generators.go index d4d55fcbda..af47f32dd8 100644 --- a/sim/core/test_generators.go +++ b/sim/core/test_generators.go @@ -118,7 +118,7 @@ type SettingsCombos struct { } func (combos *SettingsCombos) NumTests() int { - return len(combos.Races) * len(combos.GearSets) * len(combos.TalentSets) * len(combos.SpecOptions) * len(combos.Buffs) * len(combos.Encounters) * MaxInt(1, len(combos.Rotations)) + return len(combos.Races) * len(combos.GearSets) * len(combos.TalentSets) * len(combos.SpecOptions) * len(combos.Buffs) * len(combos.Encounters) * max(1, len(combos.Rotations)) } func (combos *SettingsCombos) GetTest(testIdx int) (string, *proto.ComputeStatsRequest, *proto.StatWeightsRequest, *proto.RaidSimRequest) { diff --git a/sim/core/unit.go b/sim/core/unit.go index 3f9a97f92e..e80e8bd5f4 100644 --- a/sim/core/unit.go +++ b/sim/core/unit.go @@ -353,7 +353,7 @@ func (unit *Unit) BlockValue() float64 { } func (unit *Unit) ArmorPenetrationPercentage(armorPenRating float64) float64 { - return MaxFloat(MinFloat(armorPenRating/ArmorPenPerPercentArmor, 100.0)*0.01, 0.0) + return max(min(armorPenRating/ArmorPenPerPercentArmor, 100.0)*0.01, 0.0) } func (unit *Unit) RangedSwingSpeed() float64 { diff --git a/sim/core/utils.go b/sim/core/utils.go index 525a601c58..3c9767ab1f 100644 --- a/sim/core/utils.go +++ b/sim/core/utils.go @@ -8,54 +8,6 @@ import ( "github.com/wowsims/wotlk/sim/core/proto" ) -func MinInt(a int, b int) int { - if a < b { - return a - } else { - return b - } -} - -func MaxInt(a int, b int) int { - if a > b { - return a - } else { - return b - } -} - -func MinInt32(a int32, b int32) int32 { - if a < b { - return a - } else { - return b - } -} - -func MaxInt32(a int32, b int32) int32 { - if a > b { - return a - } else { - return b - } -} - -func MinFloat(a float64, b float64) float64 { - if a < b { - return a - } else { - return b - } -} - -func MaxFloat(a float64, b float64) float64 { - if a > b { - return a - } else { - return b - } -} - func MinDuration(a time.Duration, b time.Duration) time.Duration { if a < b { return a diff --git a/sim/deathknight/anti_magic_shell.go b/sim/deathknight/anti_magic_shell.go index 7119375c87..79a70d47d8 100644 --- a/sim/deathknight/anti_magic_shell.go +++ b/sim/deathknight/anti_magic_shell.go @@ -68,7 +68,7 @@ func (dk *Deathknight) registerAntiMagicShellSpell() { pa.NextActionAt = sim.CurrentTime + time.Duration(sim.RandomFloat("ams induced damage")*5.0*float64(time.Second)) pa.Priority = core.ActionPriorityAuto pa.OnAction = func(sim *core.Simulation) { - if sim.RandomFloat("AMS trigger chance") < core.MinFloat(dk.Inputs.AvgAMSSuccessRate, 1.0) { + if sim.RandomFloat("AMS trigger chance") < min(dk.Inputs.AvgAMSSuccessRate, 1.0) { targetDummySpell.Cast(sim, aura.Unit) } } diff --git a/sim/deathknight/death_strike.go b/sim/deathknight/death_strike.go index 06d2efee09..f45bb4d5a1 100644 --- a/sim/deathknight/death_strike.go +++ b/sim/deathknight/death_strike.go @@ -59,7 +59,7 @@ func (dk *Deathknight) newDeathStrikeSpell(isMH bool) *core.Spell { } baseDamage *= dk.RoRTSBonus(target) if hasGlyph { - baseDamage *= 1 + 0.01*core.MinFloat(dk.CurrentRunicPower(), 25) + baseDamage *= 1 + 0.01*min(dk.CurrentRunicPower(), 25) } result := spell.CalcDamage(sim, target, baseDamage, dk.threatOfThassarianOutcomeApplier(spell)) @@ -116,7 +116,7 @@ func (dk *Deathknight) registerDrwDeathStrikeSpell() { baseDamage := 297 + bonusBaseDamage + dk.DrwWeaponDamage(sim, spell) if hasGlyph { - baseDamage *= 1 + 0.01*core.MinFloat(dk.CurrentRunicPower(), 25) + baseDamage *= 1 + 0.01*min(dk.CurrentRunicPower(), 25) } spell.CalcAndDealDamage(sim, target, baseDamage, spell.OutcomeMeleeWeaponSpecialHitAndCrit) }, diff --git a/sim/deathknight/ghoul_focus.go b/sim/deathknight/ghoul_focus.go index b5049ca0fd..ce3c86cf78 100644 --- a/sim/deathknight/ghoul_focus.go +++ b/sim/deathknight/ghoul_focus.go @@ -43,7 +43,7 @@ func (fb *focusBar) AddFocus(sim *core.Simulation, amount float64, actionID core panic("Trying to add negative focus!") } - newFocus := core.MinFloat(fb.currentFocus+amount, MaxFocus) + newFocus := min(fb.currentFocus+amount, MaxFocus) if sim.Log != nil { fb.ghoulPet.Log(sim, "Gained %0.3f focus from %s (%0.3f --> %0.3f).", amount, actionID, fb.currentFocus, newFocus) diff --git a/sim/deathknight/ghoul_pet.go b/sim/deathknight/ghoul_pet.go index dd189c806e..d1383dc891 100644 --- a/sim/deathknight/ghoul_pet.go +++ b/sim/deathknight/ghoul_pet.go @@ -147,7 +147,7 @@ func (ghoulPet *GhoulPet) Initialize() { func (ghoulPet *GhoulPet) Reset(_ *core.Simulation) { if !ghoulPet.IsGuardian() { - ghoulPet.uptimePercent = core.MinFloat(1, core.MaxFloat(0, ghoulPet.dkOwner.Inputs.PetUptime)) + ghoulPet.uptimePercent = min(1, max(0, ghoulPet.dkOwner.Inputs.PetUptime)) } else { ghoulPet.uptimePercent = 1.0 } diff --git a/sim/deathknight/icebound_fortitude.go b/sim/deathknight/icebound_fortitude.go index f2d60d98fc..87f9744afd 100644 --- a/sim/deathknight/icebound_fortitude.go +++ b/sim/deathknight/icebound_fortitude.go @@ -22,7 +22,7 @@ func (dk *Deathknight) registerIceboundFortitudeSpell() { Duration: time.Second*12 + time.Second*2*time.Duration(float64(dk.Talents.GuileOfGorefiend)) + dk.scourgebornePlateIFDurationBonus(), OnGain: func(aura *core.Aura, sim *core.Simulation) { def := dk.IceboundFortitudeAura.Unit.GetStat(stats.Defense) - dmgTakenMult = 1.0 - core.TernaryFloat64(hasGlyph, core.MaxFloat(0.4, 0.3+0.0015*(def-400)), 0.3+0.0015*(def-400)) + dmgTakenMult = 1.0 - core.TernaryFloat64(hasGlyph, max(0.4, 0.3+0.0015*(def-400)), 0.3+0.0015*(def-400)) dk.IceboundFortitudeAura.Unit.PseudoStats.DamageTakenMultiplier *= dmgTakenMult }, diff --git a/sim/druid/balance/rotation.go b/sim/druid/balance/rotation.go index c42173e4f7..5a1cf0a435 100644 --- a/sim/druid/balance/rotation.go +++ b/sim/druid/balance/rotation.go @@ -107,7 +107,7 @@ func (moonkin *BalanceDruid) rotation(sim *core.Simulation) (*druid.DruidSpell, } // Player "brain" latency - playerLatency := time.Duration(core.MaxInt32(rotation.PlayerLatency, 0)) * time.Millisecond + playerLatency := time.Duration(max(rotation.PlayerLatency, 0)) * time.Millisecond lunarICD := moonkin.LunarICD.Timer.TimeToReady(sim) solarICD := moonkin.SolarICD.Timer.TimeToReady(sim) canExtendMf := rotation.MfExtension == proto.BalanceDruid_Rotation_ExtendAlways || rotation.MfExtension == proto.BalanceDruid_Rotation_ExtendOutsideSolar diff --git a/sim/druid/druid.go b/sim/druid/druid.go index 550fbee037..56e03c0aca 100644 --- a/sim/druid/druid.go +++ b/sim/druid/druid.go @@ -209,7 +209,7 @@ func (druid *Druid) Initialize() { if druid.RaidBuffTargets == 0 { // 17 is an arbitrary compromise between 10 and 25, plus pets - druid.RaidBuffTargets = core.MaxInt(17, len(druid.Env.Raid.AllUnits)) + druid.RaidBuffTargets = max(17, len(druid.Env.Raid.AllUnits)) } } diff --git a/sim/druid/feral/feral.go b/sim/druid/feral/feral.go index 43342e6ce0..cc2cff27d4 100644 --- a/sim/druid/feral/feral.go +++ b/sim/druid/feral/feral.go @@ -31,7 +31,7 @@ func NewFeralDruid(character core.Character, options *proto.Player) *FeralDruid cat := &FeralDruid{ Druid: druid.New(character, druid.Cat, selfBuffs, options.TalentsString), - latency: time.Duration(core.MaxInt32(feralOptions.Options.LatencyMs, 1)) * time.Millisecond, + latency: time.Duration(max(feralOptions.Options.LatencyMs, 1)) * time.Millisecond, } cat.SelfBuffs.InnervateTarget = &proto.UnitReference{} diff --git a/sim/druid/feral/rotation.go b/sim/druid/feral/rotation.go index ec8302fbfd..2966d68799 100644 --- a/sim/druid/feral/rotation.go +++ b/sim/druid/feral/rotation.go @@ -108,7 +108,7 @@ func (cat *FeralDruid) checkReplaceMaul(sim *core.Simulation, mhSwingSpell *core ripDot := cat.Rip.CurDot() - furorCap := core.MinFloat(20.0*float64(cat.Talents.Furor), 85.0) + furorCap := min(20.0*float64(cat.Talents.Furor), 85.0) ripRefreshPending := ripDot.IsActive() && (ripDot.RemainingDuration(sim) < sim.GetRemainingDuration()-time.Second*10) gcdTimeToRdy := cat.GCD.TimeToReady(sim) energyLeeway := furorCap - 15.0 - float64((gcdTimeToRdy+cat.latency)/core.EnergyTickDuration) @@ -392,7 +392,7 @@ func (cat *FeralDruid) doRotation(sim *core.Simulation) (bool, time.Duration) { maxRipDur := time.Duration(cat.maxRipTicks) * ripDot.TickLength remainingExt := cat.maxRipTicks - ripDot.NumberOfTicks energyForShreds := curEnergy - cat.CurrentRakeCost() - 30 + float64((ripDot.StartedAt()+maxRipDur-sim.CurrentTime)/core.EnergyTickDuration) + core.Ternary(cat.tfExpectedBefore(sim, ripDot.StartedAt()+maxRipDur), 60.0, 0.0) - maxShredsPossible := core.MinFloat(energyForShreds/cat.Shred.DefaultCast.Cost, (ripDot.ExpiresAt() - (sim.CurrentTime + time.Second)).Seconds()) + maxShredsPossible := min(energyForShreds/cat.Shred.DefaultCast.Cost, (ripDot.ExpiresAt() - (sim.CurrentTime + time.Second)).Seconds()) rakeNow = remainingExt == 0 || (maxShredsPossible > float64(remainingExt)) } @@ -437,8 +437,8 @@ func (cat *FeralDruid) doRotation(sim *core.Simulation) (bool, time.Duration) { if ffNow { simTimeSecs := sim.GetRemainingDuration().Seconds() maxShredsWithoutFF := (int)((curEnergy + simTimeSecs*10) / cat.Shred.DefaultCast.Cost) - numShredsWithoutFF := core.MinInt(maxShredsWithoutFF, int(simTimeSecs)+1) - numShredsWithFF := core.MinInt(maxShredsWithoutFF+1, int(simTimeSecs)) + numShredsWithoutFF := min(maxShredsWithoutFF, int(simTimeSecs)+1) + numShredsWithFF := min(maxShredsWithoutFF+1, int(simTimeSecs)) ffNow = numShredsWithFF > numShredsWithoutFF } @@ -474,7 +474,7 @@ func (cat *FeralDruid) doRotation(sim *core.Simulation) (bool, time.Duration) { latencySecs := cat.latency.Seconds() // Allow for bearweaving if the next pending action is >= 4.5s away - furorCap := core.MinFloat(20.0*float64(cat.Talents.Furor), 85) + furorCap := min(20.0*float64(cat.Talents.Furor), 85) weaveEnergy := furorCap - 30 - 20*latencySecs // With 4/5 or 5/5 Furor, force 2-GCD bearweaves whenever possible @@ -513,7 +513,7 @@ func (cat *FeralDruid) doRotation(sim *core.Simulation) (bool, time.Duration) { // analagous conditions to the above. Only difference is that there is // more available time/Energy leeway for the technique, since // flowershifts take only 3 seconds to execute. - flowershiftEnergy := core.MinFloat(furorCap, 75) - 10*cat.SpellGCD().Seconds() - 20*latencySecs + flowershiftEnergy := min(furorCap, 75) - 10*cat.SpellGCD().Seconds() - 20*latencySecs flowerEnd := time.Duration(float64(sim.CurrentTime) + float64(cat.SpellGCD()) + (2.5+2*latencySecs)*float64(time.Second)) flowerFfDelay := flowerEnd - cat.FaerieFire.ReadyAt() diff --git a/sim/druid/feral/rotation_aoe.go b/sim/druid/feral/rotation_aoe.go index e516829122..2364547618 100644 --- a/sim/druid/feral/rotation_aoe.go +++ b/sim/druid/feral/rotation_aoe.go @@ -34,8 +34,8 @@ func (cat *FeralDruid) doAoeRotation(sim *core.Simulation) (bool, time.Duration) if ffNow { simTimeSecs := sim.GetRemainingDuration().Seconds() maxSwipesWithoutFF := (int)((curEnergy + simTimeSecs*10) / cat.SwipeCat.DefaultCast.Cost) - numSwipesWithoutFF := core.MinInt(maxSwipesWithoutFF, int(simTimeSecs)+1) - numSwipesWithFF := core.MinInt(maxSwipesWithoutFF+1, int(simTimeSecs)) + numSwipesWithoutFF := min(maxSwipesWithoutFF, int(simTimeSecs)+1) + numSwipesWithFF := min(maxSwipesWithoutFF+1, int(simTimeSecs)) ffNow = numSwipesWithFF > numSwipesWithoutFF } @@ -44,8 +44,8 @@ func (cat *FeralDruid) doAoeRotation(sim *core.Simulation) (bool, time.Duration) nextFfEnergy := curEnergy + float64((cat.FaerieFire.TimeToReady(sim)+cat.latency)/core.EnergyTickDuration) waitForFf := (cat.FaerieFire.TimeToReady(sim) < time.Second-rotation.MaxFfDelay) && (nextFfEnergy < ffThresh) && !isClearcast - furorCap := core.MinFloat(20.0*float64(cat.Talents.Furor), 85) - flowershiftEnergy := core.MinFloat(furorCap, 75) - 10*cat.SpellGCD().Seconds() - 20*latencySecs + furorCap := min(20.0*float64(cat.Talents.Furor), 85) + flowershiftEnergy := min(furorCap, 75) - 10*cat.SpellGCD().Seconds() - 20*latencySecs flowerEnd := time.Duration(float64(sim.CurrentTime) + float64(cat.SpellGCD()) + (2.5+2*latencySecs)*float64(time.Second)) flowerFfDelay := flowerEnd - cat.FaerieFire.ReadyAt() diff --git a/sim/druid/ferocious_bite.go b/sim/druid/ferocious_bite.go index b1423bb325..a96fe831a2 100644 --- a/sim/druid/ferocious_bite.go +++ b/sim/druid/ferocious_bite.go @@ -41,7 +41,7 @@ func (druid *Druid) registerFerociousBiteSpell() { ApplyEffects: func(sim *core.Simulation, target *core.Unit, spell *core.Spell) { comboPoints := float64(druid.ComboPoints()) attackPower := spell.MeleeAttackPower() - excessEnergy := core.MinFloat(druid.CurrentEnergy(), 30) + excessEnergy := min(druid.CurrentEnergy(), 30) baseDamage := 120.0 + sim.RandomFloat("Ferocious Bite")*140.0 + diff --git a/sim/druid/frenzied_regeneration.go b/sim/druid/frenzied_regeneration.go index cea7d00074..b7a15a82d0 100644 --- a/sim/druid/frenzied_regeneration.go +++ b/sim/druid/frenzied_regeneration.go @@ -46,7 +46,7 @@ func (druid *Druid) registerFrenziedRegenerationCD() { NumTicks: 10, Period: time.Second * 1, OnAction: func(sim *core.Simulation) { - rageDumped := core.MinFloat(druid.CurrentRage(), 10.0) + rageDumped := min(druid.CurrentRage(), 10.0) healthGained := rageDumped * 0.3 / 100 * druid.MaxHealth() * druid.PseudoStats.HealingTakenMultiplier if druid.FrenziedRegenerationAura.IsActive() { diff --git a/sim/druid/maul.go b/sim/druid/maul.go index 7eba7599b3..600d2399e4 100644 --- a/sim/druid/maul.go +++ b/sim/druid/maul.go @@ -88,7 +88,7 @@ func (druid *Druid) registerMaulSpell(rageThreshold float64) { }, }) - druid.MaulRageThreshold = core.MaxFloat(druid.Maul.DefaultCast.Cost, rageThreshold) + druid.MaulRageThreshold = max(druid.Maul.DefaultCast.Cost, rageThreshold) if druid.IsUsingAPL { druid.MaulRageThreshold = 0 } diff --git a/sim/druid/rake.go b/sim/druid/rake.go index aa8a63d8a3..953e6cc634 100644 --- a/sim/druid/rake.go +++ b/sim/druid/rake.go @@ -71,7 +71,7 @@ func (druid *Druid) registerRakeSpell() { ExpectedDamage: func(sim *core.Simulation, target *core.Unit, spell *core.Spell, _ bool) *core.SpellResult { baseDamage := 176 + 0.01*spell.MeleeAttackPower() - potentialTicks := core.MinInt32(numTicks, int32(sim.GetRemainingDuration()/time.Second*3)) + potentialTicks := min(numTicks, int32(sim.GetRemainingDuration()/time.Second*3)) tickBase := (358 + 0.06*spell.MeleeAttackPower()) * float64(potentialTicks) initial := spell.CalcPeriodicDamage(sim, target, baseDamage, spell.OutcomeExpectedMagicAlwaysHit) diff --git a/sim/druid/savage_defense.go b/sim/druid/savage_defense.go index 98e55fa928..79c5382647 100644 --- a/sim/druid/savage_defense.go +++ b/sim/druid/savage_defense.go @@ -20,7 +20,7 @@ func (druid *Druid) registerSavageDefensePassive() { druid.AddDynamicDamageTakenModifier(func(sim *core.Simulation, spell *core.Spell, result *core.SpellResult) { if druid.SavageDefenseAura.IsActive() && (result.Damage > 0) && spell.SpellSchool.Matches(core.SpellSchoolPhysical) { - result.Damage = core.MaxFloat(0, result.Damage-0.25*druid.GetStat(stats.AttackPower)) + result.Damage = max(0, result.Damage-0.25*druid.GetStat(stats.AttackPower)) druid.SavageDefenseAura.Deactivate(sim) } }) diff --git a/sim/encounters/toc/anub25h_ai.go b/sim/encounters/toc/anub25h_ai.go index 9b9d3906e7..7a90a9b072 100644 --- a/sim/encounters/toc/anub25h_ai.go +++ b/sim/encounters/toc/anub25h_ai.go @@ -150,7 +150,7 @@ func (ai *Anub25HAI) registerLeechingSwarmSpell(target *core.Target) { TickLength: time.Second, OnTick: func(sim *core.Simulation, target *core.Unit, dot *core.Dot) { - baseDamage := core.MaxFloat(0.3*target.CurrentHealth(), 250.) + baseDamage := max(0.3*target.CurrentHealth(), 250.) result := dot.Spell.CalcAndDealPeriodicDamage(sim, target, baseDamage, dot.Spell.OutcomeAlwaysHit) if ai.Target.CurrentTarget != nil && ai.Target.Env.Raid.Size() == 1 { diff --git a/sim/encounters/ulduar/hodir_ai.go b/sim/encounters/ulduar/hodir_ai.go index 64f20edec3..36d468fe25 100644 --- a/sim/encounters/ulduar/hodir_ai.go +++ b/sim/encounters/ulduar/hodir_ai.go @@ -275,7 +275,7 @@ func (ai *HodirAI) registerBuffsDebuffs(target *core.Target) { }, }) - core.ApplyFixedUptimeAura(aura, core.MinFloat(core.MaxFloat(ai.StarlightUptime, 0.0), 100.0)/100.0, time.Second*15, time.Second*10) + core.ApplyFixedUptimeAura(aura, min(max(ai.StarlightUptime, 0.0), 100.0)/100.0, time.Second*15, time.Second*10) ai.Starlight = append(ai.Starlight, aura) } } @@ -423,7 +423,7 @@ func (ai *HodirAI) DoAction(sim *core.Simulation) { storm2 := storm1 // Set max possible spreads - maxBuffs := core.MinInt(6, sim.Raid.Size()-1) + maxBuffs := min(6, sim.Raid.Size()-1) // 2 storms on 25m if ai.raidSize == 25 { @@ -433,7 +433,7 @@ func (ai *HodirAI) DoAction(sim *core.Simulation) { } // Set max possible spreads - maxBuffs = core.MinInt(12, sim.Raid.Size()-2) + maxBuffs = min(12, sim.Raid.Size()-2) } // Prio order for storm power diff --git a/sim/hunter/multi_shot.go b/sim/hunter/multi_shot.go index a2732f635c..bba28896ad 100644 --- a/sim/hunter/multi_shot.go +++ b/sim/hunter/multi_shot.go @@ -8,7 +8,7 @@ import ( ) func (hunter *Hunter) registerMultiShotSpell(timer *core.Timer) { - numHits := core.MinInt32(3, hunter.Env.GetNumTargets()) + numHits := min(3, hunter.Env.GetNumTargets()) hunter.MultiShot = hunter.RegisterSpell(core.SpellConfig{ ActionID: core.ActionID{SpellID: 49048}, diff --git a/sim/hunter/pet.go b/sim/hunter/pet.go index d2e700da43..17f366e9b0 100644 --- a/sim/hunter/pet.go +++ b/sim/hunter/pet.go @@ -89,7 +89,7 @@ func (hp *HunterPet) Initialize() { } func (hp *HunterPet) Reset(_ *core.Simulation) { - hp.uptimePercent = core.MinFloat(1, core.MaxFloat(0, hp.hunterOwner.Options.PetUptime)) + hp.uptimePercent = min(1, max(0, hp.hunterOwner.Options.PetUptime)) } func (hp *HunterPet) OnGCDReady(sim *core.Simulation) { diff --git a/sim/hunter/talents.go b/sim/hunter/talents.go index f1a1900fdf..b4fa9b4d13 100644 --- a/sim/hunter/talents.go +++ b/sim/hunter/talents.go @@ -730,7 +730,7 @@ func (hunter *Hunter) applySniperTraining() { if uptime <= 0 { return } - uptime = core.MinFloat(1, uptime) + uptime = min(1, uptime) dmgMod := .02 * float64(hunter.Talents.SniperTraining) diff --git a/sim/paladin/avengers_shield.go b/sim/paladin/avengers_shield.go index e2a8a8ae16..60899c088c 100644 --- a/sim/paladin/avengers_shield.go +++ b/sim/paladin/avengers_shield.go @@ -10,7 +10,7 @@ import ( func (paladin *Paladin) registerAvengersShieldSpell() { glyphedSingleTargetAS := paladin.HasMajorGlyph(proto.PaladinMajorGlyph_GlyphOfAvengerSShield) // Glyph to single target, OR apply to up to 3 targets - numHits := core.TernaryInt32(glyphedSingleTargetAS, 1, core.MinInt32(3, paladin.Env.GetNumTargets())) + numHits := core.TernaryInt32(glyphedSingleTargetAS, 1, min(3, paladin.Env.GetNumTargets())) results := make([]*core.SpellResult, numHits) paladin.AvengersShield = paladin.RegisterSpell(core.SpellConfig{ diff --git a/sim/paladin/divine_storm.go b/sim/paladin/divine_storm.go index f8219626d7..dc92287f2c 100644 --- a/sim/paladin/divine_storm.go +++ b/sim/paladin/divine_storm.go @@ -9,7 +9,7 @@ import ( func (paladin *Paladin) registerDivineStormSpell() { bonusDmg := core.TernaryFloat64(paladin.Ranged().ID == 45510, 235, 0) + // Libram of Discord core.TernaryFloat64(paladin.Ranged().ID == 38362, 81, 0) // Venture Co. Libram of Retribution - numHits := core.MinInt32(4, paladin.Env.GetNumTargets()) + numHits := min(4, paladin.Env.GetNumTargets()) results := make([]*core.SpellResult, numHits) paladin.DivineStorm = paladin.RegisterSpell(core.SpellConfig{ diff --git a/sim/paladin/hammer_of_the_righteous.go b/sim/paladin/hammer_of_the_righteous.go index fa6d4fa809..c6ec636f2d 100644 --- a/sim/paladin/hammer_of_the_righteous.go +++ b/sim/paladin/hammer_of_the_righteous.go @@ -8,7 +8,7 @@ import ( ) func (paladin *Paladin) registerHammerOfTheRighteousSpell() { - numHits := core.MinInt32(core.TernaryInt32(paladin.HasMajorGlyph(proto.PaladinMajorGlyph_GlyphOfHammerOfTheRighteous), 4, 3), paladin.Env.GetNumTargets()) + numHits := min(core.TernaryInt32(paladin.HasMajorGlyph(proto.PaladinMajorGlyph_GlyphOfHammerOfTheRighteous), 4, 3), paladin.Env.GetNumTargets()) results := make([]*core.SpellResult, numHits) paladin.HammerOfTheRighteous = paladin.RegisterSpell(core.SpellConfig{ diff --git a/sim/paladin/retribution/rotation.go b/sim/paladin/retribution/rotation.go index c8d2a1cc62..462e187e9b 100644 --- a/sim/paladin/retribution/rotation.go +++ b/sim/paladin/retribution/rotation.go @@ -9,12 +9,12 @@ import ( ) func (ret *RetributionPaladin) OnAutoAttack(sim *core.Simulation, _ *core.Spell) { - if ret.SealOfVengeanceAura.IsActive() && core.MinInt32(ret.MaxSoVTargets, ret.Env.GetNumTargets()) > 1 { + if ret.SealOfVengeanceAura.IsActive() && min(ret.MaxSoVTargets, ret.Env.GetNumTargets()) > 1 { minVengeanceDotDuration := time.Second * 15 var minVengeanceDotDurationTarget *core.Unit minVengeanceDotStacks := int32(5) var minVengeanceDotStacksTarget *core.Unit - for i := int32(0); i < core.MinInt32(ret.MaxSoVTargets, ret.Env.GetNumTargets()); i++ { + for i := int32(0); i < min(ret.MaxSoVTargets, ret.Env.GetNumTargets()); i++ { target := ret.Env.GetTargetUnit(i) dot := ret.SovDotSpell.Dot(target) remainingDuration := dot.RemainingDuration(sim) diff --git a/sim/paladin/soc.go b/sim/paladin/soc.go index 8ed308760c..f72daac941 100644 --- a/sim/paladin/soc.go +++ b/sim/paladin/soc.go @@ -24,7 +24,7 @@ func (paladin *Paladin) registerSealOfCommandSpellAndAura() { * - CAN MISS, BE DODGED/PARRIED/BLOCKED. */ - numHits := core.MinInt32(3, paladin.Env.GetNumTargets()) // primary target + 2 others + numHits := min(3, paladin.Env.GetNumTargets()) // primary target + 2 others results := make([]*core.SpellResult, numHits) onJudgementProc := paladin.RegisterSpell(core.SpellConfig{ diff --git a/sim/paladin/talents.go b/sim/paladin/talents.go index 6b7cbcfa6f..9108713d36 100644 --- a/sim/paladin/talents.go +++ b/sim/paladin/talents.go @@ -236,7 +236,7 @@ func (paladin *Paladin) applyArdentDefender() { } // 540 defense (+140) yields the full heal amount - ardentHealAmount := core.MaxFloat(1.0, float64(paladin.GetStat(stats.Defense))/core.DefenseRatingPerDefense/140.0) * 0.10 * float64(paladin.Talents.ArdentDefender) + ardentHealAmount := max(1.0, float64(paladin.GetStat(stats.Defense))/core.DefenseRatingPerDefense/140.0) * 0.10 * float64(paladin.Talents.ArdentDefender) // TBD? Buff to mark time spent fully below 35% and attribute absorbs // rangeAura := paladin.RegisterAura(core.Aura{ diff --git a/sim/priest/shadow/rotation.go b/sim/priest/shadow/rotation.go index f8724d32ec..4794910b3b 100644 --- a/sim/priest/shadow/rotation.go +++ b/sim/priest/shadow/rotation.go @@ -184,8 +184,8 @@ func (spriest *ShadowPriest) chooseSpellIdeal(sim *core.Simulation) (*core.Spell swStacks = float64(spriest.ShadowWeavingAura.GetStacks()) // Reduce number of DP/VT ticks based on remaining duration - num_DP_ticks = core.MinFloat(float64(spriest.DevouringPlague.CurDot().NumberOfTicks), math.Floor(remain_fight/dotTickSpeed)) - num_VT_ticks = core.MinFloat(float64(spriest.VampiricTouch.CurDot().NumberOfTicks), math.Floor(remain_fight/dotTickSpeed)) + num_DP_ticks = min(float64(spriest.DevouringPlague.CurDot().NumberOfTicks), math.Floor(remain_fight/dotTickSpeed)) + num_VT_ticks = min(float64(spriest.VampiricTouch.CurDot().NumberOfTicks), math.Floor(remain_fight/dotTickSpeed)) // Spell damage numbers that are updated before each cast in order to determine the most optimal next cast based on dps over a finite window // This is needed throughout the code to determine the optimal spell(s) to cast next diff --git a/sim/priest/smite/rotation.go b/sim/priest/smite/rotation.go index b1a455a23b..b37fcca221 100644 --- a/sim/priest/smite/rotation.go +++ b/sim/priest/smite/rotation.go @@ -55,7 +55,7 @@ func (spriest *SmitePriest) chooseSpell(sim *core.Simulation) *core.Spell { } else if spriest.Talents.MindFlay { mfTickLength := spriest.MindFlayTickDuration() hfTimeToReady := spriest.HolyFire.TimeToReady(sim) - numTicks := core.MinInt(3, int(hfTimeToReady/mfTickLength+1)) + numTicks := min(3, int(hfTimeToReady/mfTickLength+1)) return spriest.MindFlay[numTicks] } else { return spriest.Smite diff --git a/sim/rogue/envenom.go b/sim/rogue/envenom.go index 8061475961..c05ad63166 100644 --- a/sim/rogue/envenom.go +++ b/sim/rogue/envenom.go @@ -65,7 +65,7 @@ func (rogue *Rogue) registerEnvenom() { dp := rogue.DeadlyPoison.Dot(target) // - 215 base is scaled by consumed doses (<= comboPoints) // - apRatio is independent of consumed doses (== comboPoints) - consumed := core.MinInt32(dp.GetStacks(), comboPoints) + consumed := min(dp.GetStacks(), comboPoints) baseDamage := 215*float64(consumed) + 0.09*float64(comboPoints)*spell.MeleeAttackPower() result := spell.CalcDamage(sim, target, baseDamage, spell.OutcomeMeleeSpecialHitAndCrit) diff --git a/sim/rogue/rotation_assassination.go b/sim/rogue/rotation_assassination.go index 56ac7f04c0..c02dd024f9 100644 --- a/sim/rogue/rotation_assassination.go +++ b/sim/rogue/rotation_assassination.go @@ -130,7 +130,7 @@ func (x *rotation_assassination) setup(sim *core.Simulation, rogue *Rogue) { return Skip } timeLeft := rogue.ExposeArmorAuras.Get(rogue.CurrentTarget).RemainingDuration(sim) - minPoints := core.MaxInt32(1, core.MinInt32(rogue.Rotation.MinimumComboPointsExposeArmor, 5)) + minPoints := max(1, min(rogue.Rotation.MinimumComboPointsExposeArmor, 5)) if rogue.Rotation.ExposeArmorFrequency != proto.Rogue_Rotation_Once { minPoints = 1 } diff --git a/sim/rogue/rotation_combat.go b/sim/rogue/rotation_combat.go index 19d654b434..091e7ca925 100644 --- a/sim/rogue/rotation_combat.go +++ b/sim/rogue/rotation_combat.go @@ -148,7 +148,7 @@ func (x *rotation_combat) setup(_ *core.Simulation, rogue *Rogue) { return Skip } timeLeft := rogue.ExposeArmorAuras.Get(rogue.CurrentTarget).RemainingDuration(sim) - minPoints := core.MaxInt32(1, core.MinInt32(rogue.Rotation.MinimumComboPointsExposeArmor, 5)) + minPoints := max(1, min(rogue.Rotation.MinimumComboPointsExposeArmor, 5)) if rogue.Rotation.ExposeArmorFrequency != proto.Rogue_Rotation_Once { minPoints = 1 } diff --git a/sim/rogue/rotation_generic.go b/sim/rogue/rotation_generic.go index b450f00e8e..e4750835ef 100644 --- a/sim/rogue/rotation_generic.go +++ b/sim/rogue/rotation_generic.go @@ -1,10 +1,11 @@ package rogue import ( - "golang.org/x/exp/slices" "log" "time" + "golang.org/x/exp/slices" + "github.com/wowsims/wotlk/sim/core" "github.com/wowsims/wotlk/sim/core/proto" ) @@ -175,7 +176,7 @@ func (x *rotation_generic) setup(_ *core.Simulation, rogue *Rogue) { return Skip } timeLeft := rogue.ExposeArmorAuras.Get(rogue.CurrentTarget).RemainingDuration(sim) - minPoints := core.MaxInt32(1, core.MinInt32(rogue.Rotation.MinimumComboPointsExposeArmor, 5)) + minPoints := max(1, min(rogue.Rotation.MinimumComboPointsExposeArmor, 5)) if rogue.Rotation.ExposeArmorFrequency != proto.Rogue_Rotation_Once { minPoints = 1 } diff --git a/sim/rogue/rotation_multi.go b/sim/rogue/rotation_multi.go index 262e434c9e..a5cc449e33 100644 --- a/sim/rogue/rotation_multi.go +++ b/sim/rogue/rotation_multi.go @@ -80,7 +80,7 @@ func (x *rotation_multi) setup(sim *core.Simulation, rogue *Rogue) { }, } if rogue.Rotation.MultiTargetSliceFrequency != proto.Rogue_Rotation_Never { - sliceAndDice.MinimumComboPoints = core.MaxInt32(1, rogue.Rotation.MinimumComboPointsMultiTargetSlice) + sliceAndDice.MinimumComboPoints = max(1, rogue.Rotation.MinimumComboPointsMultiTargetSlice) if rogue.Rotation.MultiTargetSliceFrequency == proto.Rogue_Rotation_Once { sliceAndDice.MaxCasts = 1 } @@ -374,8 +374,8 @@ func (x *rotation_multi) planRotation(sim *core.Simulation, rogue *Rogue) []rogu } currentTime += item.MaximumBuildDuration } else { - cpUsed := core.MaxInt32(0, prio.MinimumComboPoints-comboPoints) - energyUsed := core.MaxFloat(0, prio.EnergyCost-currentEnergy) + cpUsed := max(0, prio.MinimumComboPoints-comboPoints) + energyUsed := max(0, prio.EnergyCost-currentEnergy) minBuildTime := x.timeToBuild(cpUsed, x.builderPoints, eps, energyUsed) if currentTime+minBuildTime <= item.ExpiresAt || !prio.IsFiller { prioStack = append(prioStack, item) diff --git a/sim/rogue/rotation_subtlety.go b/sim/rogue/rotation_subtlety.go index c1ce4b286a..e97ac1e29e 100644 --- a/sim/rogue/rotation_subtlety.go +++ b/sim/rogue/rotation_subtlety.go @@ -116,7 +116,7 @@ func (x *rotation_subtlety) setup(sim *core.Simulation, rogue *Rogue) { return Skip } timeLeft := rogue.ExposeArmorAuras.Get(rogue.CurrentTarget).RemainingDuration(sim) - minPoints := core.MaxInt32(1, core.MinInt32(rogue.Rotation.MinimumComboPointsExposeArmor, 5)) + minPoints := max(1, min(rogue.Rotation.MinimumComboPointsExposeArmor, 5)) if rogue.Rotation.ExposeArmorFrequency != proto.Rogue_Rotation_Once { minPoints = 1 } diff --git a/sim/shaman/chain_lightning.go b/sim/shaman/chain_lightning.go index 579119015e..8438d0314f 100644 --- a/sim/shaman/chain_lightning.go +++ b/sim/shaman/chain_lightning.go @@ -8,7 +8,7 @@ import ( ) func (shaman *Shaman) registerChainLightningSpell() { - numHits := core.MinInt32(core.TernaryInt32(shaman.HasMajorGlyph(proto.ShamanMajorGlyph_GlyphOfChainLightning), 4, 3), shaman.Env.GetNumTargets()) + numHits := min(core.TernaryInt32(shaman.HasMajorGlyph(proto.ShamanMajorGlyph_GlyphOfChainLightning), 4, 3), shaman.Env.GetNumTargets()) shaman.ChainLightning = shaman.newChainLightningSpell(false) shaman.ChainLightningLOs = []*core.Spell{} for i := int32(0); i < numHits; i++ { @@ -30,7 +30,7 @@ func (shaman *Shaman) newChainLightningSpell(isLightningOverload bool) *core.Spe } } - numHits := core.MinInt32(core.TernaryInt32(shaman.HasMajorGlyph(proto.ShamanMajorGlyph_GlyphOfChainLightning), 4, 3), shaman.Env.GetNumTargets()) + numHits := min(core.TernaryInt32(shaman.HasMajorGlyph(proto.ShamanMajorGlyph_GlyphOfChainLightning), 4, 3), shaman.Env.GetNumTargets()) dmgReductionPerBounce := core.TernaryFloat64(shaman.HasSetBonus(ItemSetTidefury, 2), 0.83, 0.7) dmgBonus := shaman.electricSpellBonusDamage(0.5714) spellCoeff := 0.5714 + 0.04*float64(shaman.Talents.Shamanism) diff --git a/sim/shaman/heals.go b/sim/shaman/heals.go index 960f102e81..34fb24fe1c 100644 --- a/sim/shaman/heals.go +++ b/sim/shaman/heals.go @@ -312,7 +312,7 @@ func (shaman *Shaman) registerChainHealSpell() { hasGlyph := shaman.HasMajorGlyph(proto.ShamanMajorGlyph_GlyphOfChainHeal) - numHits := core.MinInt32(core.TernaryInt32(hasGlyph, 4, 3), int32(len(shaman.Env.Raid.AllUnits))) + numHits := min(core.TernaryInt32(hasGlyph, 4, 3), int32(len(shaman.Env.Raid.AllUnits))) bonusHeal := 0 + core.TernaryFloat64(shaman.Ranged().ID == 28523, 87, 0) + diff --git a/sim/warlock/drain_soul.go b/sim/warlock/drain_soul.go index 07b775d592..884209f71c 100644 --- a/sim/warlock/drain_soul.go +++ b/sim/warlock/drain_soul.go @@ -29,7 +29,7 @@ func (warlock *Warlock) registerDrainSoulSpell() { numActive++ } } - return 1.0 + float64(core.MinInt(3, numActive))*soulSiphonMultiplier + return 1.0 + float64(min(3, numActive))*soulSiphonMultiplier } warlock.DrainSoul = warlock.RegisterSpell(core.SpellConfig{ diff --git a/sim/warlock/pet_abilities.go b/sim/warlock/pet_abilities.go index 97c0b8fb64..ce52f1b069 100644 --- a/sim/warlock/pet_abilities.go +++ b/sim/warlock/pet_abilities.go @@ -8,7 +8,7 @@ import ( ) func (wp *WarlockPet) registerCleaveSpell() { - numHits := core.MinInt32(2, wp.Env.GetNumTargets()) + numHits := min(2, wp.Env.GetNumTargets()) wp.primaryAbility = wp.RegisterSpell(core.SpellConfig{ ActionID: core.ActionID{SpellID: 47994}, diff --git a/sim/warlock/rotation.go b/sim/warlock/rotation.go index 1ee2f2f053..95c7e2eb18 100644 --- a/sim/warlock/rotation.go +++ b/sim/warlock/rotation.go @@ -150,7 +150,7 @@ func (warlock *Warlock) defineRotation() { } var multidotTargets, uaDotTargets []*core.Unit - multidotCount := core.MinInt(len(allUnits), 3) + multidotCount := min(len(allUnits), 3) if warlock.Rotation.Type == proto.Warlock_Rotation_Affliction { // up to 3 targets: multidot, no seed // 4 targets: corruption+UA 3x, seed on 4th; possibly only 1x UA since it's close in value @@ -158,7 +158,7 @@ func (warlock *Warlock) defineRotation() { // 6 targets: corruption x2, UA 1x, seed; only 1x corruption + UA is close in value // 7-9 targets: corruption x1, no UA, seed // 10+ targets: no corruption anymore probably - uaCount := core.MinInt(len(allUnits), 3) + uaCount := min(len(allUnits), 3) if len(allUnits) > 4 { uaCount = 1 @@ -172,7 +172,7 @@ func (warlock *Warlock) defineRotation() { uaDotTargets = allUnits[:uaCount] } else if warlock.Rotation.Type == proto.Warlock_Rotation_Destruction { - multidotCount = core.MinInt(len(allUnits), 4) + multidotCount = min(len(allUnits), 4) } multidotTargets = allUnits[:multidotCount] @@ -527,13 +527,13 @@ func (warlock *Warlock) defineRotation() { // the amount of ticks we have left, assuming we continue channeling ticksLeft := int(timeUntilRefresh/dsDot.TickPeriod()) + 1 - ticksLeft = core.MinInt(ticksLeft, int(hauntRefresh/dsDot.TickPeriod())) - ticksLeft = core.MinInt(ticksLeft, dsDot.NumTicksRemaining(sim)) + ticksLeft = min(ticksLeft, int(hauntRefresh/dsDot.TickPeriod())) + ticksLeft = min(ticksLeft, dsDot.NumTicksRemaining(sim)) // amount of ticks we'd get assuming we recast drain soul recastTicks := int(timeUntilRefresh/warlock.ApplyCastSpeed(dsDot.TickLength)) + 1 - recastTicks = core.MinInt(recastTicks, int(hauntRefresh/warlock.ApplyCastSpeed(dsDot.TickLength))) - recastTicks = core.MinInt(recastTicks, int(dsDot.NumberOfTicks)) + recastTicks = min(recastTicks, int(hauntRefresh/warlock.ApplyCastSpeed(dsDot.TickLength))) + recastTicks = min(recastTicks, int(dsDot.NumberOfTicks)) if ticksLeft <= 0 || recastTicks <= 0 { return ACLCast, mainTarget diff --git a/sim/warrior/devastate.go b/sim/warrior/devastate.go index bbda677a54..4ed326eedd 100644 --- a/sim/warrior/devastate.go +++ b/sim/warrior/devastate.go @@ -50,7 +50,7 @@ func (warrior *Warrior) registerDevastateSpell() { sunderBonus := 0.0 saStacks := warrior.SunderArmorAuras.Get(target).GetStacks() if saStacks != 0 { - sunderBonus = 242 * float64(core.MinInt32(saStacks+1, 5)) + sunderBonus = 242 * float64(min(saStacks+1, 5)) } baseDamage := (weaponMulti * spell.Unit.MHNormalizedWeaponDamage(sim, spell.MeleeAttackPower())) + sunderBonus diff --git a/sim/warrior/heroic_strike_cleave.go b/sim/warrior/heroic_strike_cleave.go index dcc2ada7e7..c828d76424 100644 --- a/sim/warrior/heroic_strike_cleave.go +++ b/sim/warrior/heroic_strike_cleave.go @@ -54,7 +54,7 @@ func (warrior *Warrior) registerCleaveSpell() *core.Spell { flatDamageBonus := 222 * (1 + 0.4*float64(warrior.Talents.ImprovedCleave)) targets := core.TernaryInt32(warrior.HasMajorGlyph(proto.WarriorMajorGlyph_GlyphOfCleaving), 3, 2) - numHits := core.MinInt32(targets, warrior.Env.GetNumTargets()) + numHits := min(targets, warrior.Env.GetNumTargets()) results := make([]*core.SpellResult, numHits) return warrior.RegisterSpell(core.SpellConfig{ @@ -180,7 +180,7 @@ func (warrior *Warrior) RegisterHSOrCleave(useCleave bool, rageThreshold float64 warrior.hsOrCleaveQueueSpell = cleaveQueueSpell } - warrior.HSRageThreshold = core.MaxFloat(autoSpell.DefaultCast.Cost, rageThreshold) + warrior.HSRageThreshold = max(autoSpell.DefaultCast.Cost, rageThreshold) if warrior.IsUsingAPL { warrior.HSRageThreshold = 0 } diff --git a/sim/warrior/rend.go b/sim/warrior/rend.go index a994204d83..4a761d5724 100644 --- a/sim/warrior/rend.go +++ b/sim/warrior/rend.go @@ -87,7 +87,7 @@ func (warrior *Warrior) RegisterRendSpell(rageThreshold float64, healthThreshold }) warrior.RendHealthThresholdAbove = healthThreshold / 100 - warrior.RendRageThresholdBelow = core.MaxFloat(warrior.Rend.DefaultCast.Cost, rageThreshold) + warrior.RendRageThresholdBelow = max(warrior.Rend.DefaultCast.Cost, rageThreshold) } func (warrior *Warrior) ShouldRend(sim *core.Simulation) bool { diff --git a/sim/warrior/talents.go b/sim/warrior/talents.go index 580580a0cb..798ff9658c 100644 --- a/sim/warrior/talents.go +++ b/sim/warrior/talents.go @@ -83,7 +83,7 @@ func (warrior *Warrior) applyCriticalBlock() { procChance := 0.2 * float64(warrior.Talents.CriticalBlock) if sim.RandomFloat("Critical Block Roll") <= procChance { blockValue := warrior.BlockValue() - result.Damage = core.MaxFloat(0, result.Damage-blockValue) + result.Damage = max(0, result.Damage-blockValue) dummyCriticalBlockSpell.Cast(sim, spell.Unit) } } @@ -794,7 +794,7 @@ func (warrior *Warrior) RegisterBladestormCD() { } actionID := core.ActionID{SpellID: 46924} - numHits := core.MinInt32(4, warrior.Env.GetNumTargets()) + numHits := min(4, warrior.Env.GetNumTargets()) results := make([]*core.SpellResult, numHits) if warrior.AutoAttacks.IsDualWielding { diff --git a/sim/warrior/whirlwind.go b/sim/warrior/whirlwind.go index 89774bd750..2b1e0f8fce 100644 --- a/sim/warrior/whirlwind.go +++ b/sim/warrior/whirlwind.go @@ -9,7 +9,7 @@ import ( func (warrior *Warrior) registerWhirlwindSpell() { actionID := core.ActionID{SpellID: 1680} - numHits := core.MinInt32(4, warrior.Env.GetNumTargets()) + numHits := min(4, warrior.Env.GetNumTargets()) results := make([]*core.SpellResult, numHits) if warrior.AutoAttacks.IsDualWielding && warrior.GetOHWeapon().WeaponType != proto.WeaponType_WeaponTypeStaff &&