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

<> card search: extend to Rush Duel #341

Closed
kevinlul opened this issue Jul 17, 2023 · 0 comments · Fixed by #463
Closed

<> card search: extend to Rush Duel #341

kevinlul opened this issue Jul 17, 2023 · 0 comments · Fixed by #463

Comments

@kevinlul
Copy link
Contributor

kevinlul commented Jul 17, 2023

<> card search should support Rush Duel cards in addition to OCG/TCG cards. Unlike old Bastion, this will be achieved with prefix and postfix operators. This avoids name collisions (e.g. Blue-Eyes White Dragon exists in both) as well as unwanted hits in the separate card pool (e.g. fuzzy search retrieving a Rush Duel card instead of an OCG card). Furthermore, depending on the choice of operator, this system is extensible to other card pools, such as Speed Duel skills.

r<>, R<>, <>r, and <>R will be the syntax for searching Rush Duel cards. This should produce an embed, as /rush-duel search, while supporting all the same syntax as regular <> search, such as Konami ID matching with % and language mapping.

{} search in the old bot (mobile view) should attach an informational message to all Rush Duel hits directing users to use the new search syntax.

Implementation

export function parseSummons(cleanMessage: string, regex: RegExp): string[] {
return [...cleanMessage.matchAll(regex)]
.map(match => match[1].trim())
.filter(summon => {
// Ignore matches containing only whitespace or containing the following three tokens
if (summon.length === 0) {
return false;
}
const lower = summon.toLowerCase();
return !["://", "(", "anime"].some(token => lower.includes(token));
});
}
Extend parseSummons to find the character immediately before and after the summon. Before: [match.input[match.index - 1]. After: match.input[match.index + e[0].length]]. These are added to the return array and changes preprocess's signature accordingly.

const [resultLanguage, type, searchTerm, inputLanguage] = inputToGetCardArguments(input, language);
const card = await getCard(this.got, type, searchTerm, inputLanguage);

The inputToGetCardArguments -> getCard approach needs to be updated to support multiple implementations of search. The follow-up formatting needs to be aware as well
const embeds = createCardEmbed(card, resultLanguage);

Current Rush Duel equivalents:

private async search(query: string, lang: Locale, count: number): Promise<Static<typeof RushCardSchema>[]> {
const url = new URL(`${process.env.API_URL}/rush/search`);
url.searchParams.set("name", query);
url.searchParams.set("lang", lang);
url.searchParams.set("count", `${count}`);
return await this.got(url, { throwHttpErrors: true }).json<Static<typeof RushCardSchema>[]>();
}

function createRushCardEmbed(card: Static<typeof RushCardSchema>, lang: Locale): EmbedBuilder {

Metrics reporting should be updated to account for multiple search types. Unit testing on the message search module should be vastly expanded to cover the range of inputs.

@kevinlul kevinlul pinned this issue Oct 8, 2023
kevinlul added a commit that referenced this issue May 25, 2024
kevinlul added a commit that referenced this issue May 25, 2024
…arch

Based on prior work 850ae19, 0311288
This will take longer to process due to checking for "r" before and after, and using immutables to identify duplicates
The only difference in behaviour is that a duplicate with a Rush flag is no longer treated as a duplicate
e.g. <code> r<code> only counted as one summon for "code" before and now counts as two distinct summons
 #341
kevinlul added a commit that referenced this issue May 26, 2024
kevinlul added a commit that referenced this issue May 26, 2024
kevinlul added a commit that referenced this issue May 26, 2024
@kevinlul kevinlul unpinned this issue Jun 13, 2024
kevinlul added a commit that referenced this issue Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant