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

raidboss: refactor trigger loading #5047

Closed
wants to merge 20 commits into from
Closed
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
5 changes: 5 additions & 0 deletions resources/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ export type Lang = typeof languages[number];

export type NonEnLang = Exclude<Lang, 'en'>;

/**
* @deprecated remove this after we don't support `netRegexCn` style triggers
*/
export type LegacyLangSuffix = 'En' | 'De' | 'Fr' | 'Ja' | 'Cn' | 'Ko';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this get used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regex${lang as LegacyLangSuffix} netRegex${lang as LegacyLangSuffix}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't see what you're referring to. Which file is that in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's used to get legacy regexDe/netRegexDe property in popup-text.ts

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ git grep LegacyLangSuffix
resources/languages.ts:export type LegacyLangSuffix = 'En' | 'De' | 'Fr' | 'Ja' | 'Cn
' | 'Ko';

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the confusion, I just don't see what you mean. Did you mean to add these changes and they didn't save/commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's strange, I remembered I used it in popup-test.ts, maybe I lost it by mistake.


export const langMap: { [lang in Lang]: { [lang in Lang]: string } } = {
en: {
en: 'English',
Expand Down
30 changes: 25 additions & 5 deletions types/trigger.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ export type TriggerField<Data extends RaidbossData, MatchType extends NetAnyMatc
// This trigger type is what we expect cactbot triggers to be written as,
// in other words `id` is not technically required for triggers but for
// built-in triggers it is.
export type BaseTrigger<
Data extends RaidbossData,
Type extends TriggerTypes,
> = Omit<BaseNetTrigger<Data, Type>, 'type' | 'netRegex'>;
export type BaseTrigger<Data extends RaidbossData, Type extends TriggerTypes> = Omit<
BaseNetTrigger<Data, Type>,
'type' | 'netRegex'
>;

type BaseNetTrigger<Data extends RaidbossData, Type extends TriggerTypes> = {
id: string;
Expand Down Expand Up @@ -200,6 +200,26 @@ export type TriggerSet<Data extends RaidbossData = RaidbossData> =
// Less strict type for user triggers + built-in triggers, including deprecated fields.
export type LooseTimelineTrigger = Partial<TimelineTrigger<RaidbossData>>;

/**
* @deprecated
*/
export type LegacyTrigger = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be combined into LooseTrigger. LooseTrigger is the "user trigger, that could be missing fields, and could have old deprecated fields in it" type. It's the same reason that LooseTriggerSet has zoneRegex in it.

regexEn?: RegExp;
regexDe?: RegExp;
regexFr?: RegExp;
regexCn?: RegExp;
regexJa?: RegExp;
regexKo?: RegExp;

// @deprecated
netRegexEn?: RegExp;
netRegexFr?: RegExp;
netRegexDe?: RegExp;
netRegexCn?: RegExp;
netRegexJa?: RegExp;
netRegexKo?: RegExp;
};

export type LooseTrigger = Partial<BaseNetTrigger<RaidbossData, 'None'> & PartialRegexTrigger>;

export type LooseTriggerSet =
Expand All @@ -209,7 +229,7 @@ export type LooseTriggerSet =
zoneRegex?:
| RegExp
| { [lang in Lang]?: RegExp };
triggers?: LooseTrigger[];
triggers?: (LooseTrigger & LegacyTrigger)[];
timelineTriggers?: LooseTimelineTrigger[];
};

Expand Down
2 changes: 1 addition & 1 deletion ui/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export type ConfigLooseTrigger = LooseTrigger & LooseTimelineTrigger & {

export type ConfigLooseTriggerSet = LooseTriggerSet & {
filename?: string;
isUserTriggerSet?: boolean;
loaded?: boolean;
};

export type ConfigLooseOopsyTrigger = LooseOopsyTrigger;
Expand Down
Loading