Skip to content

Commit

Permalink
Add IsExecutePhase APL value
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyt857 committed Jul 29, 2023
1 parent be89c7c commit b87b14b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
13 changes: 11 additions & 2 deletions proto/apl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ message APLAction {
}
}

// NextIndex: 42
message APLValue {
oneof value {
// Operators
Expand All @@ -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
Expand Down Expand Up @@ -104,8 +106,6 @@ message APLValue {
// Dot values
APLValueDotIsActive dot_is_active = 6;
APLValueDotRemainingTime dot_remaining_time = 13;

// Last Index - 35
}
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions sim/core/apl_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
28 changes: 28 additions & 0 deletions sim/core/apl_values_encounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
28 changes: 28 additions & 0 deletions ui/core/components/individual_sim_ui/apl_values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
APLValueCurrentTimePercent,
APLValueRemainingTime,
APLValueRemainingTimePercent,
APLValueIsExecutePhase,
APLValueIsExecutePhase_ExecutePhaseThreshold as ExecutePhaseThreshold,
APLValueCurrentHealth,
APLValueCurrentHealthPercent,
APLValueCurrentMana,
Expand Down Expand Up @@ -265,6 +267,23 @@ function mathOperatorFieldConfig(field: string): AplHelpers.APLPickerBuilderFiel
};
}

function executePhaseThresholdFieldConfig(field: string): AplHelpers.APLPickerBuilderFieldConfig<any, any> {
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<any, any>>): AplHelpers.APLPickerBuilderFieldConfig<any, any> {
return {
field: field,
Expand Down Expand Up @@ -412,6 +431,15 @@ const valueKindFactories: {[f in NonNullable<APLValueKind>]: ValueKindConfig<APL
newValue: APLValueRemainingTimePercent.create,
fields: [],
}),
'isExecutePhase': inputBuilder({
label: 'Is Execute Phase',
submenu: ['Encounter'],
shortDescription: '<b>True</b> if the encounter is in Execute Phase, meaning the target\'s health is less than the given threshold, otherwise <b>False</b>.',
newValue: APLValueIsExecutePhase.create,
fields: [
executePhaseThresholdFieldConfig('threshold'),
],
}),
'numberTargets': inputBuilder({
label: 'Number of Targets',
submenu: ['Encounter'],
Expand Down

0 comments on commit b87b14b

Please sign in to comment.