Skip to content

Commit

Permalink
Add Pet Mana % APLValue
Browse files Browse the repository at this point in the history
  • Loading branch information
nathro committed Apr 17, 2024
1 parent d56fa00 commit 182da7f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
5 changes: 4 additions & 1 deletion proto/apl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ message APLAction {
}
}

// NextIndex: 71
// NextIndex: 72
message APLValue {
oneof value {
// Operators
Expand Down Expand Up @@ -166,6 +166,7 @@ message APLValue {
APLValueWarlockShouldRecastDrainSoul warlock_should_recast_drain_soul = 59;
APLValueWarlockShouldRefreshCorruption warlock_should_refresh_corruption = 60;
APLValueWarlockCurrentPetMana warlock_current_pet_mana = 70;
APLValueWarlockCurrentPetManaPercent warlock_current_pet_mana_percent = 71;
APLValueCurrentSealRemainingTime current_seal_remaining_time = 65;
}
}
Expand Down Expand Up @@ -512,5 +513,7 @@ message APLValueWarlockShouldRefreshCorruption {
}
message APLValueWarlockCurrentPetMana {
}
message APLValueWarlockCurrentPetManaPercent {
}
message APLValueCurrentSealRemainingTime {
}
31 changes: 31 additions & 0 deletions sim/warlock/apl_values.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package warlock

import (
"fmt"
"time"

"github.com/wowsims/sod/sim/core"
Expand All @@ -15,6 +16,8 @@ func (warlock *Warlock) NewAPLValue(rot *core.APLRotation, config *proto.APLValu
return warlock.newValueWarlockShouldRefreshCorruption(rot, config.GetWarlockShouldRefreshCorruption())
case *proto.APLValue_WarlockCurrentPetMana:
return warlock.newValueWarlockCurrentPetMana(rot, config.GetWarlockCurrentPetMana())
case *proto.APLValue_WarlockCurrentPetManaPercent:
return warlock.newValueWarlockCurrentPetManaPercent(rot, config.GetWarlockCurrentPetManaPercent())
default:
return nil
}
Expand Down Expand Up @@ -169,3 +172,31 @@ func (value *APLValueWarlockCurrentPetMana) GetFloat(sim *core.Simulation) float
func (value *APLValueWarlockCurrentPetMana) String() string {
return "Current Pet Mana"
}

type APLValueWarlockCurrentPetManaPercent struct {
core.DefaultAPLValueImpl
pet *WarlockPet
}

func (warlock *Warlock) newValueWarlockCurrentPetManaPercent(rot *core.APLRotation, config *proto.APLValueWarlockCurrentPetManaPercent) core.APLValue {
pet := warlock.Pet
if pet.GetPet() == nil {
return nil
}
if !pet.GetPet().HasManaBar() {
rot.ValidationWarning("%s does not use Mana", pet.GetPet().Label)
return nil
}
return &APLValueWarlockCurrentPetManaPercent{
pet: pet,
}
}
func (value *APLValueWarlockCurrentPetManaPercent) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeFloat
}
func (value *APLValueWarlockCurrentPetManaPercent) GetFloat(sim *core.Simulation) float64 {
return value.pet.GetPet().CurrentManaPercent()
}
func (value *APLValueWarlockCurrentPetManaPercent) String() string {
return fmt.Sprintf("Current Pet Mana %%")
}
9 changes: 9 additions & 0 deletions ui/core/components/individual_sim_ui/apl_values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {
APLValueWarlockShouldRecastDrainSoul,
APLValueWarlockShouldRefreshCorruption,
APLValueWarlockCurrentPetMana,
APLValueWarlockCurrentPetManaPercent,
} from '../../proto/apl.js';
import { Class, Spec } from '../../proto/common.js';
import { ShamanTotems_TotemType as TotemType } from '../../proto/shaman.js';
Expand Down Expand Up @@ -940,6 +941,14 @@ const valueKindFactories: { [f in NonNullable<APLValueKind>]: ValueKindConfig<AP
includeIf: (player: Player<any>, _isPrepull: boolean) => player.getClass() == Class.ClassWarlock,
fields: [],
}),
warlockCurrentPetManaPercent: inputBuilder({
label: 'Pet Mana (%)',
submenu: ['Warlock'],
shortDescription: 'Amount of currently available pet mana, as a percentage.',
newValue: APLValueWarlockCurrentPetManaPercent.create,
includeIf: (player: Player<any>, _isPrepull: boolean) => player.getClass() == Class.ClassWarlock,
fields: [],
}),
currentSealRemainingTime: inputBuilder({
label: 'Current Seal Remaining Time',
submenu: ['Paladin'],
Expand Down

0 comments on commit 182da7f

Please sign in to comment.