From 1f4c0a5d86e1648aaafac1becd70ffe64703551e Mon Sep 17 00:00:00 2001 From: James Tanner Date: Sat, 26 Aug 2023 20:19:30 -0700 Subject: [PATCH] Implement icd on cooldown with reaction time for apl --- proto/apl.proto | 7 ++++- sim/core/apl_value.go | 2 ++ sim/core/apl_values_aura.go | 29 ++++++++++++++++++- .../individual_sim_ui/apl_values.ts | 23 +++++++++++---- 4 files changed, 53 insertions(+), 8 deletions(-) diff --git a/proto/apl.proto b/proto/apl.proto index 88b34d0512..f7ac12034e 100644 --- a/proto/apl.proto +++ b/proto/apl.proto @@ -52,7 +52,7 @@ message APLAction { } } -// NextIndex: 51 +// NextIndex: 52 message APLValue { oneof value { // Operators @@ -113,6 +113,7 @@ message APLValue { APLValueAuraRemainingTime aura_remaining_time = 23; APLValueAuraNumStacks aura_num_stacks = 24; APLValueAuraInternalCooldown aura_internal_cooldown = 39; + APLValueAuraICDOnCooldownWithReactionTime aura_icd_on_cooldown_with_reaction_time = 51; APLValueAuraShouldRefresh aura_should_refresh = 43; // Dot values @@ -363,6 +364,10 @@ message APLValueAuraInternalCooldown { UnitReference source_unit = 2; ActionID aura_id = 1; } +message APLValueAuraICDOnCooldownWithReactionTime { + UnitReference source_unit = 2; + ActionID aura_id = 1; +} message APLValueAuraShouldRefresh { UnitReference source_unit = 2; ActionID aura_id = 1; diff --git a/sim/core/apl_value.go b/sim/core/apl_value.go index 3ac1ea03b3..26227571d2 100644 --- a/sim/core/apl_value.go +++ b/sim/core/apl_value.go @@ -163,6 +163,8 @@ func (rot *APLRotation) newAPLValue(config *proto.APLValue) APLValue { return rot.newValueAuraNumStacks(config.GetAuraNumStacks()) case *proto.APLValue_AuraInternalCooldown: return rot.newValueAuraInternalCooldown(config.GetAuraInternalCooldown()) + case *proto.APLValue_AuraIcdOnCooldownWithReactionTime: + return rot.newValueAuraICDOnCooldownWithReactionTime(config.GetAuraIcdOnCooldownWithReactionTime()) case *proto.APLValue_AuraShouldRefresh: return rot.newValueAuraShouldRefresh(config.GetAuraShouldRefresh()) diff --git a/sim/core/apl_values_aura.go b/sim/core/apl_values_aura.go index 1f42ef4720..8ac9dedd6e 100644 --- a/sim/core/apl_values_aura.go +++ b/sim/core/apl_values_aura.go @@ -131,7 +131,34 @@ func (value *APLValueAuraInternalCooldown) GetDuration(sim *Simulation) time.Dur return value.aura.Get().Icd.TimeToReady(sim) } func (value *APLValueAuraInternalCooldown) String() string { - return fmt.Sprintf("Aura ICD(%s)", value.aura.String()) + return fmt.Sprintf("Aura Remaining ICD(%s)", value.aura.String()) +} + +type APLValueAuraICDOnCooldownWithReactionTime struct { + DefaultAPLValueImpl + aura AuraReference + reactionTime time.Duration +} + +func (rot *APLRotation) newValueAuraICDOnCooldownWithReactionTime(config *proto.APLValueAuraICDOnCooldownWithReactionTime) APLValue { + aura := rot.GetAPLICDAura(rot.GetSourceUnit(config.SourceUnit), config.AuraId) + if aura.Get() == nil { + return nil + } + return &APLValueAuraICDOnCooldownWithReactionTime{ + aura: aura, + reactionTime: rot.unit.ReactionTime, + } +} +func (value *APLValueAuraICDOnCooldownWithReactionTime) Type() proto.APLValueType { + return proto.APLValueType_ValueTypeBool +} +func (value *APLValueAuraICDOnCooldownWithReactionTime) GetBool(sim *Simulation) bool { + aura := value.aura.Get() + return !aura.Icd.IsReady(sim) && aura.TimeActive(sim) >= value.reactionTime +} +func (value *APLValueAuraICDOnCooldownWithReactionTime) String() string { + return fmt.Sprintf("Aura ICD on Cooldown with Reaction Time(%s)", value.aura.String()) } type APLValueAuraShouldRefresh struct { diff --git a/ui/core/components/individual_sim_ui/apl_values.ts b/ui/core/components/individual_sim_ui/apl_values.ts index 3f1ed0c2bd..01669ce40e 100644 --- a/ui/core/components/individual_sim_ui/apl_values.ts +++ b/ui/core/components/individual_sim_ui/apl_values.ts @@ -51,6 +51,7 @@ import { APLValueAuraRemainingTime, APLValueAuraNumStacks, APLValueAuraInternalCooldown, + APLValueAuraICDOnCooldownWithReactionTime, APLValueAuraShouldRefresh, APLValueDotIsActive, APLValueDotRemainingTime, @@ -748,7 +749,7 @@ const valueKindFactories: {[f in NonNullable]: ValueKindConfigTrue if the aura is currently active on self, otherwise False.', + shortDescription: 'True if the aura is currently active, otherwise False.', newValue: APLValueAuraIsActive.create, fields: [ AplHelpers.unitFieldConfig('sourceUnit', 'aura_sources'), @@ -758,7 +759,7 @@ const valueKindFactories: {[f in NonNullable]: ValueKindConfigTrue if the aura is currently active on self AND it has been active for at least as long as the player reaction time (configured in Settings), otherwise False.', + shortDescription: 'True if the aura is currently active AND it has been active for at least as long as the player reaction time (configured in Settings), otherwise False.', newValue: APLValueAuraIsActiveWithReactionTime.create, fields: [ AplHelpers.unitFieldConfig('sourceUnit', 'aura_sources'), @@ -768,7 +769,7 @@ const valueKindFactories: {[f in NonNullable]: ValueKindConfig]: ValueKindConfig]: ValueKindConfig0 if the ICD is ready now.', newValue: APLValueAuraInternalCooldown.create, fields: [ AplHelpers.unitFieldConfig('sourceUnit', 'aura_sources'), AplHelpers.actionIdFieldConfig('auraId', 'icd_auras', 'sourceUnit'), ], }), + 'auraIcdOnCooldownWithReactionTime': inputBuilder({ + label: 'Aura ICD On Cooldown (with Reaction Time)', + submenu: ['Aura'], + shortDescription: 'True if the aura\'s ICD is currently on cooldown AND it has been active for at least as long as the player reaction time (configured in Settings), otherwise False.', + newValue: APLValueAuraICDOnCooldownWithReactionTime.create, + fields: [ + AplHelpers.unitFieldConfig('sourceUnit', 'aura_sources'), + AplHelpers.actionIdFieldConfig('auraId', 'icd_auras', 'sourceUnit'), + ], + }), 'auraShouldRefresh': inputBuilder({ label: 'Should Refresh Aura', submenu: ['Aura'],