From dbe7e342abff70e3485d09d45dbddc0724f245ba Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Thu, 19 Sep 2024 18:21:10 -0500 Subject: [PATCH] Update rules with proper IDs --- src/rules/lights_under_10k.ts | 2 +- src/rules/speed_under_10k.ts | 2 +- src/rules/strobes_in_flights.ts | 10 +++------- src/rules/strobes_on_during_taxi.ts | 2 +- src/types/global.d.ts | 6 ++++-- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/rules/lights_under_10k.ts b/src/rules/lights_under_10k.ts index ba7dd31..6366d52 100644 --- a/src/rules/lights_under_10k.ts +++ b/src/rules/lights_under_10k.ts @@ -29,7 +29,7 @@ export default class LightsUnder10K implements Rule { } return Acars.ViolatedAfterDelay( - this.meta.name, + this.meta.id, this.meta.delay_time, (): RuleValue => { // Ignore landing lights being turned on diff --git a/src/rules/speed_under_10k.ts b/src/rules/speed_under_10k.ts index fcf0061..060a224 100644 --- a/src/rules/speed_under_10k.ts +++ b/src/rules/speed_under_10k.ts @@ -24,7 +24,7 @@ export default class SpeedUnder10K implements Rule { } return Acars.ViolatedAfterDelay( - this.meta.name, + this.meta.id, this.meta.delay_time, (): RuleValue => { // Ignore landing lights being turned on diff --git a/src/rules/strobes_in_flights.ts b/src/rules/strobes_in_flights.ts index 2fc7e15..7d64eff 100644 --- a/src/rules/strobes_in_flights.ts +++ b/src/rules/strobes_in_flights.ts @@ -29,12 +29,8 @@ export default class StrobesInFlight implements Rule { return [false] } - return Acars.ViolatedAfterDelay( - this.meta.name, - this.meta.delay_time, - () => { - return !data.strobeLights ? [true] : [false] - }, - ) + return Acars.ViolatedAfterDelay(this.meta.id, this.meta.delay_time, () => { + return !data.strobeLights ? [true] : [false] + }) } } diff --git a/src/rules/strobes_on_during_taxi.ts b/src/rules/strobes_on_during_taxi.ts index 9dec00b..e00bfdc 100644 --- a/src/rules/strobes_on_during_taxi.ts +++ b/src/rules/strobes_on_during_taxi.ts @@ -31,7 +31,7 @@ export default class LightsOffDuringTaxi implements Rule { } return Acars.ViolatedAfterDelay( - this.meta.name, + this.meta.id, this.meta.delay_time, (): RuleValue => { // Ignore landing lights being turned on diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 9907636..fce7f45 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -10,6 +10,8 @@ declare global { function IsFeatureEnabled(feature: AircraftFeature): boolean {} /** Get something from storage */ function Get(key: string): string {} + /** Save something to storage */ + function Set(key: string, value?: string): void {} /** * @param key * @param value @@ -45,12 +47,12 @@ declare global { * where the rule evaluation takes place. This method is evaluated often (many times a second), * and if at any point before the timeout is hit, it will stop and reset. * - * @param name The name to use to track this internally + * @param id The ID of the rule to be tracked. You can add additional info * @param timeout Amount of time, in milliseconds * @param callback Needs to return an array matching the RuleValue type */ function ViolatedAfterDelay( - name: string, + id: string, timeout: number, callback: () => RuleValue, ): RuleValue {}