diff --git a/src/lib/field.ts b/src/lib/field/chargedUp.ts similarity index 90% rename from src/lib/field.ts rename to src/lib/field/chargedUp.ts index 5f727f4..3a0c940 100644 --- a/src/lib/field.ts +++ b/src/lib/field/chargedUp.ts @@ -1,12 +1,10 @@ import fs from "fs/promises"; import fsSync from "fs"; import type { GoogleSpreadsheetRow } from "google-spreadsheet"; -import type { Match } from "./match"; +import type { Match } from "../match/chargedUp"; -export const SUSTAINABILITY_BONUS_RP = 9; -export const ACTIVATION_BONUS_RP = 32; - -export const PLAYOFF_MATCHES_BEFORE_FINALS = 13; +const SUSTAINABILITY_BONUS_RP = 9; +const ACTIVATION_BONUS_RP = 32; export async function getMatchData( scheduledMatch: GoogleSpreadsheetRow, @@ -173,19 +171,3 @@ export async function getMatchData( return match; } - -export async function setMatchNumber(matchType: string, matchNumber: number) { - const type = - matchType === "Qual" - ? "Quals" - : matchNumber > PLAYOFF_MATCHES_BEFORE_FINALS - ? "Finals" - : "Playoff"; - - fsSync.existsSync("TourneyData/") || (await fs.mkdir("TourneyData/")); - await fs.writeFile("TourneyData/MatchNumber.txt", `${type} ${matchNumber}`); - await fs.writeFile( - "TourneyData/PrevMatchNumber.txt", - `${type} ${matchNumber - 1}` - ); -} diff --git a/src/lib/field/index.ts b/src/lib/field/index.ts new file mode 100644 index 0000000..c3b734f --- /dev/null +++ b/src/lib/field/index.ts @@ -0,0 +1,33 @@ +import fs from "fs/promises"; +import fsSync from "fs"; + +import { getMatchData as chargedUpGetMatchData } from "./chargedUp"; + +export const PLAYOFF_MATCHES_BEFORE_FINALS = 13; + +export async function setMatchNumber(matchType: string, matchNumber: number) { + const type = + matchType === "Qual" + ? "Quals" + : matchNumber > PLAYOFF_MATCHES_BEFORE_FINALS + ? "Finals" + : "Playoff"; + + fsSync.existsSync("TourneyData/") || (await fs.mkdir("TourneyData/")); + await fs.writeFile("TourneyData/MatchNumber.txt", `${type} ${matchNumber}`); + await fs.writeFile( + "TourneyData/PrevMatchNumber.txt", + `${type} ${matchNumber - 1}` + ); +} + +let gameGetMatchData; + +switch (process.env.GAME_NAME) { + case "CHARGED UP": + default: + gameGetMatchData = chargedUpGetMatchData; + break; +} + +export const getMatchData = gameGetMatchData; diff --git a/src/lib/match.ts b/src/lib/match/chargedUp.ts similarity index 100% rename from src/lib/match.ts rename to src/lib/match/chargedUp.ts diff --git a/src/lib/match/index.ts b/src/lib/match/index.ts new file mode 100644 index 0000000..f2c77d2 --- /dev/null +++ b/src/lib/match/index.ts @@ -0,0 +1,24 @@ +import { + type Match as chargedUpMatch, + headerValues as chargedUpHeaderValues, + matchToArray as chargedUpMatchToArray, + saveMatchToRow as chargedUpSaveMatchToRow, +} from "./chargedUp"; + +let gameHeaderValues; +let gameMatchToArray; +let gameSaveMatchToRow; + +switch (process.env.GAME_NAME) { + case "CHARGED UP": + default: + gameHeaderValues = chargedUpHeaderValues; + gameMatchToArray = chargedUpMatchToArray; + gameSaveMatchToRow = chargedUpSaveMatchToRow; + break; +} + +export type Match = chargedUpMatch; // | otherMatch; +export const headerValues = gameHeaderValues; +export const matchToArray = gameMatchToArray; +export const saveMatchToRow = gameSaveMatchToRow; diff --git a/src/lib/resultEmbed.ts b/src/lib/resultEmbed/chargedUp.ts similarity index 96% rename from src/lib/resultEmbed.ts rename to src/lib/resultEmbed/chargedUp.ts index c681c05..d0383e1 100644 --- a/src/lib/resultEmbed.ts +++ b/src/lib/resultEmbed/chargedUp.ts @@ -1,6 +1,6 @@ import { EmbedBuilder, type Guild } from "discord.js"; -import type { Match } from "./match"; -import { PLAYOFF_MATCHES_BEFORE_FINALS } from "./field"; +import type { Match } from "../match"; +import { PLAYOFF_MATCHES_BEFORE_FINALS } from "../field"; const codeBlock = (str: string) => `\`\`\`\n${str}\n\`\`\``; diff --git a/src/lib/resultEmbed/index.ts b/src/lib/resultEmbed/index.ts new file mode 100644 index 0000000..7b2c1f0 --- /dev/null +++ b/src/lib/resultEmbed/index.ts @@ -0,0 +1,18 @@ +import { + sendQualMatchEmbed as chargedUpSendQualMatchEmbed, + sendPlayoffMatchEmbed as chargedUpSendPlayoffMatchEmbed, +} from "./chargedUp"; + +let gameSendQualMatchEmbed; +let gameSendPlayoffMatchEmbed; + +switch (process.env.GAME_NAME) { + case "CHARGED UP": + default: + gameSendQualMatchEmbed = chargedUpSendQualMatchEmbed; + gameSendPlayoffMatchEmbed = chargedUpSendPlayoffMatchEmbed; + break; +} + +export const sendQualMatchEmbed = gameSendQualMatchEmbed; +export const sendPlayoffMatchEmbed = gameSendPlayoffMatchEmbed;