Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add APL values for max hp, max mana and current AP #53

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"name": "classic",
"version": "0.1.0",
"private": true,
"engines": {
"node": ">=20"
},
"volta": {
"node": "20.13.1"
},
"scripts": {
"build": "bazel build //...",
"test": "bazel test //...",
Expand Down
11 changes: 10 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: 74
// NextIndex: 78
message APLValue {
oneof value {
// Operators
Expand All @@ -106,13 +106,18 @@ message APLValue {
// Resource values
APLValueCurrentHealth current_health = 26;
APLValueCurrentHealthPercent current_health_percent = 27;
APLValueMaxHealth max_health = 76;
APLValueCurrentMana current_mana = 11;
APLValueCurrentManaPercent current_mana_percent = 12;
APLValueMaxMana max_mana = 75;
APLValueCurrentRage current_rage = 14;
APLValueCurrentEnergy current_energy = 15;
APLValueCurrentComboPoints current_combo_points = 16;
APLValueTimeToEnergyTick time_to_energy_tick = 66;
APLValueEnergyThreshold energy_threshold = 72;

// Stats
APLValueCurrentAttackPower current_attack_power = 77;

// GCD values
APLValueGCDIsReady gcd_is_ready = 17;
Expand Down Expand Up @@ -374,12 +379,14 @@ message APLValueCurrentHealth {
message APLValueCurrentHealthPercent {
UnitReference source_unit = 1;
}
message APLValueMaxHealth {}
message APLValueCurrentMana {
UnitReference source_unit = 1;
}
message APLValueCurrentManaPercent {
UnitReference source_unit = 1;
}
message APLValueMaxMana {}
message APLValueCurrentRage {}
message APLValueCurrentEnergy {}
message APLValueCurrentComboPoints {}
Expand All @@ -388,6 +395,8 @@ message APLValueEnergyThreshold {
int32 threshold = 1;
}

message APLValueCurrentAttackPower {}

message APLValueGCDIsReady {}
message APLValueGCDTimeToReady {}

Expand Down
8 changes: 8 additions & 0 deletions sim/core/apl_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,14 @@ func (rot *APLRotation) newAPLValue(config *proto.APLValue) APLValue {
return rot.newValueCurrentHealth(config.GetCurrentHealth())
case *proto.APLValue_CurrentHealthPercent:
return rot.newValueCurrentHealthPercent(config.GetCurrentHealthPercent())
case *proto.APLValue_MaxHealth:
return rot.newValueMaxHealth(config.GetMaxHealth())
case *proto.APLValue_CurrentMana:
return rot.newValueCurrentMana(config.GetCurrentMana())
case *proto.APLValue_CurrentManaPercent:
return rot.newValueCurrentManaPercent(config.GetCurrentManaPercent())
case *proto.APLValue_MaxMana:
return rot.newValueMaxMana(config.GetMaxMana())
case *proto.APLValue_CurrentRage:
return rot.newValueCurrentRage(config.GetCurrentRage())
case *proto.APLValue_CurrentEnergy:
Expand All @@ -114,6 +118,10 @@ func (rot *APLRotation) newAPLValue(config *proto.APLValue) APLValue {
case *proto.APLValue_EnergyThreshold:
return rot.newValueEnergyThreshold(config.GetEnergyThreshold())

// Stats
case *proto.APLValue_CurrentAttackPower:
return rot.newValueCurrentAttackPower(config.GetCurrentAttackPower())

// GCD
case *proto.APLValue_GcdIsReady:
return rot.newValueGCDIsReady(config.GetGcdIsReady())
Expand Down
50 changes: 50 additions & 0 deletions sim/core/apl_values_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,31 @@ func (value *APLValueCurrentHealthPercent) String() string {
return fmt.Sprintf("Current Health %%")
}

type APLValueMaxHealth struct {
DefaultAPLValueImpl
unit *Unit
}

func (rot *APLRotation) newValueMaxHealth(_ *proto.APLValueMaxHealth) APLValue {
unit := rot.unit
if !unit.HasHealthBar() {
rot.ValidationWarning("%s does not use Health", unit.Label)
return nil
}
return &APLValueMaxHealth{
unit: unit,
}
}
func (value *APLValueMaxHealth) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeFloat
}
func (value *APLValueMaxHealth) GetFloat(_ *Simulation) float64 {
return value.unit.MaxHealth()
}
func (value *APLValueMaxHealth) String() string {
return "Max Health"
}

type APLValueCurrentMana struct {
DefaultAPLValueImpl
unit UnitReference
Expand Down Expand Up @@ -119,6 +144,31 @@ func (value *APLValueCurrentManaPercent) String() string {
return fmt.Sprintf("Current Mana %%")
}

type APLValueMaxMana struct {
DefaultAPLValueImpl
unit *Unit
}

func (rot *APLRotation) newValueMaxMana(_ *proto.APLValueMaxMana) APLValue {
unit := rot.unit
if !unit.HasManaBar() {
rot.ValidationWarning("%s does not use Mana", unit.Label)
return nil
}
return &APLValueMaxMana{
unit: unit,
}
}
func (value *APLValueMaxMana) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeFloat
}
func (value *APLValueMaxMana) GetFloat(_ *Simulation) float64 {
return value.unit.MaxMana()
}
func (value *APLValueMaxMana) String() string {
return "Max Mana"
}

type APLValueCurrentRage struct {
DefaultAPLValueImpl
unit *Unit
Expand Down
26 changes: 26 additions & 0 deletions sim/core/apl_values_stats.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package core

import (
"github.com/wowsims/classic/sim/core/proto"
"github.com/wowsims/classic/sim/core/stats"
)

type APLValueCurrentAttackPower struct {
DefaultAPLValueImpl
unit *Unit
}

func (rot *APLRotation) newValueCurrentAttackPower(_ *proto.APLValueCurrentAttackPower) APLValue {
return &APLValueCurrentAttackPower{
unit: rot.unit,
}
}
func (value *APLValueCurrentAttackPower) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeFloat
}
func (value *APLValueCurrentAttackPower) GetFloat(_ *Simulation) float64 {
return value.unit.GetStat(stats.AttackPower)
}
func (value *APLValueCurrentAttackPower) String() string {
return "Current Attack Power"
}
27 changes: 27 additions & 0 deletions ui/core/components/individual_sim_ui/apl_values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
APLValueCompare,
APLValueCompare_ComparisonOperator as ComparisonOperator,
APLValueConst,
APLValueCurrentAttackPower,
APLValueCurrentComboPoints,
APLValueCurrentEnergy,
APLValueCurrentHealth,
Expand All @@ -40,6 +41,8 @@ import {
APLValueMath,
APLValueMath_MathOperator as MathOperator,
APLValueMax,
APLValueMaxHealth,
APLValueMaxMana,
APLValueMin,
APLValueNot,
APLValueNumberTargets,
Expand Down Expand Up @@ -611,6 +614,13 @@ const valueKindFactories: { [f in NonNullable<APLValueKind>]: ValueKindConfig<AP
newValue: APLValueCurrentHealthPercent.create,
fields: [AplHelpers.unitFieldConfig('sourceUnit', 'aura_sources')],
}),
maxHealth: inputBuilder({
label: 'Max Health',
submenu: ['Resources'],
shortDescription: 'Maximum amount of Health.',
newValue: APLValueMaxHealth.create,
fields: [],
}),
currentMana: inputBuilder({
label: 'Mana',
submenu: ['Resources'],
Expand All @@ -627,6 +637,14 @@ const valueKindFactories: { [f in NonNullable<APLValueKind>]: ValueKindConfig<AP
fields: [],
includeIf: (player: Player<any>, _isPrepull: boolean) => player.getClass() !== Class.ClassRogue && player.getClass() !== Class.ClassWarrior,
}),
maxMana: inputBuilder({
label: 'Max Mana',
submenu: ['Resources'],
shortDescription: 'Maximum amount of Mana.',
newValue: APLValueMaxMana.create,
fields: [],
includeIf: (player: Player<any>, _isPrepull: boolean) => player.getClass() !== Class.ClassRogue && player.getClass() !== Class.ClassWarrior,
}),
currentRage: inputBuilder({
label: 'Rage',
submenu: ['Resources'],
Expand Down Expand Up @@ -673,6 +691,15 @@ const valueKindFactories: { [f in NonNullable<APLValueKind>]: ValueKindConfig<AP
includeIf: (player: Player<any>, _isPrepull: boolean) => player.getClass() === Class.ClassRogue || player.getClass() === Class.ClassDruid,
}),

// Stats
currentAttackPower: inputBuilder({
label: 'Current Attack Power',
submenu: ['Stats'],
shortDescription: 'Current Attack Power includuing temporary bonuses.',
newValue: APLValueCurrentAttackPower.create,
fields: [],
}),

// GCD
gcdIsReady: inputBuilder({
label: 'GCD Is Ready',
Expand Down
Loading