diff --git a/proto/apl.proto b/proto/apl.proto index 82eda43c20..843a2c4619 100644 --- a/proto/apl.proto +++ b/proto/apl.proto @@ -45,6 +45,7 @@ message APLAction { } } +// NextIndex: 42 message APLValue { oneof value { // Operators @@ -60,6 +61,7 @@ message APLValue { APLValueCurrentTimePercent current_time_percent = 8; APLValueRemainingTime remaining_time = 9; APLValueRemainingTimePercent remaining_time_percent = 10; + APLValueIsExecutePhase is_execute_phase = 41; APLValueNumberTargets number_targets = 28; // Resource values @@ -104,8 +106,6 @@ message APLValue { // Dot values APLValueDotIsActive dot_is_active = 6; APLValueDotRemainingTime dot_remaining_time = 13; - - // Last Index - 35 } } @@ -217,6 +217,15 @@ message APLValueCurrentTimePercent {} message APLValueRemainingTime {} message APLValueRemainingTimePercent {} message APLValueNumberTargets {} +message APLValueIsExecutePhase { + enum ExecutePhaseThreshold { + Unknown = 0; + E20 = 1; + E25 = 2; + E35 = 3; + } + ExecutePhaseThreshold threshold = 1; +} message APLValueCurrentHealth { UnitReference source_unit = 1; diff --git a/sim/core/apl_value.go b/sim/core/apl_value.go index 6c3d955558..6c229351d1 100644 --- a/sim/core/apl_value.go +++ b/sim/core/apl_value.go @@ -68,6 +68,8 @@ func (rot *APLRotation) newAPLValue(config *proto.APLValue) APLValue { return rot.newValueRemainingTime(config.GetRemainingTime()) case *proto.APLValue_RemainingTimePercent: return rot.newValueRemainingTimePercent(config.GetRemainingTimePercent()) + case *proto.APLValue_IsExecutePhase: + return rot.newValueIsExecutePhase(config.GetIsExecutePhase()) case *proto.APLValue_NumberTargets: return rot.newValueNumberTargets(config.GetNumberTargets()) diff --git a/sim/core/apl_values_encounter.go b/sim/core/apl_values_encounter.go index 9bb3dd5410..29c1b8737e 100644 --- a/sim/core/apl_values_encounter.go +++ b/sim/core/apl_values_encounter.go @@ -75,3 +75,31 @@ func (value *APLValueNumberTargets) Type() proto.APLValueType { func (value *APLValueNumberTargets) GetInt(sim *Simulation) int32 { return sim.GetNumTargets() } + +type APLValueIsExecutePhase struct { + defaultAPLValueImpl + threshold proto.APLValueIsExecutePhase_ExecutePhaseThreshold +} + +func (rot *APLRotation) newValueIsExecutePhase(config *proto.APLValueIsExecutePhase) APLValue { + if config.Threshold == proto.APLValueIsExecutePhase_Unknown { + return nil + } + return &APLValueIsExecutePhase{ + threshold: config.Threshold, + } +} +func (value *APLValueIsExecutePhase) Type() proto.APLValueType { + return proto.APLValueType_ValueTypeBool +} +func (value *APLValueIsExecutePhase) GetBool(sim *Simulation) bool { + if value.threshold == proto.APLValueIsExecutePhase_E20 { + return sim.IsExecutePhase20() + } else if value.threshold == proto.APLValueIsExecutePhase_E25 { + return sim.IsExecutePhase25() + } else if value.threshold == proto.APLValueIsExecutePhase_E35 { + return sim.IsExecutePhase35() + } else { + panic("Should never reach here") + } +} diff --git a/ui/core/components/individual_sim_ui/apl_values.ts b/ui/core/components/individual_sim_ui/apl_values.ts index 5d561dba1e..8edf4f857e 100644 --- a/ui/core/components/individual_sim_ui/apl_values.ts +++ b/ui/core/components/individual_sim_ui/apl_values.ts @@ -12,6 +12,8 @@ import { APLValueCurrentTimePercent, APLValueRemainingTime, APLValueRemainingTimePercent, + APLValueIsExecutePhase, + APLValueIsExecutePhase_ExecutePhaseThreshold as ExecutePhaseThreshold, APLValueCurrentHealth, APLValueCurrentHealthPercent, APLValueCurrentMana, @@ -265,6 +267,23 @@ function mathOperatorFieldConfig(field: string): AplHelpers.APLPickerBuilderFiel }; } +function executePhaseThresholdFieldConfig(field: string): AplHelpers.APLPickerBuilderFieldConfig { + return { + field: field, + newValue: () => ExecutePhaseThreshold.E20, + factory: (parent, player, config) => new TextDropdownPicker(parent, player, { + ...config, + defaultLabel: 'None', + equals: (a, b) => a == b, + values: [ + { value: ExecutePhaseThreshold.E20, label: '20%' }, + { value: ExecutePhaseThreshold.E25, label: '25%' }, + { value: ExecutePhaseThreshold.E35, label: '35%' }, + ], + }), + }; +} + export function valueFieldConfig(field: string, options?: Partial>): AplHelpers.APLPickerBuilderFieldConfig { return { field: field, @@ -412,6 +431,15 @@ const valueKindFactories: {[f in NonNullable]: ValueKindConfigTrue if the encounter is in Execute Phase, meaning the target\'s health is less than the given threshold, otherwise False.', + newValue: APLValueIsExecutePhase.create, + fields: [ + executePhaseThresholdFieldConfig('threshold'), + ], + }), 'numberTargets': inputBuilder({ label: 'Number of Targets', submenu: ['Encounter'],