-
Notifications
You must be signed in to change notification settings - Fork 1
Update for Rebuilt #20
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
Open
GavinRC
wants to merge
11
commits into
SecondRobotics:main
Choose a base branch
from
GavinRC:rebuilt-update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
42277a5
Updated tsconfig.json
GavinRC 2ac65d6
Added rebuilt to tournament bot
GavinRC f291e23
Final Changes
GavinRC 75dd4b0
Ran Prettier
GavinRC e8e9607
Eslint
GavinRC f6b1389
Merge branch 'main' into rebuilt-update
GavinRC 0db6e0c
Requested Changes
GavinRC ecedb6e
Merge branch 'rebuilt-update' of https://github.com/GavinRC/SimTourne…
GavinRC 13153fb
Merge branch 'main' into rebuilt-update
GavinRC 9a95cbb
Accidently Backspaced Too Far
GavinRC 242e7dc
Merge branch 'rebuilt-update' of https://github.com/GavinRC/SimTourne…
GavinRC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,4 +60,4 @@ | |
| "@typescript-eslint/consistent-type-imports": "warn" | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| import fs from "fs/promises"; | ||
| import fsSync from "fs"; | ||
| import type { GoogleSpreadsheetRow } from "google-spreadsheet"; | ||
| import type { Match } from "../match/rebuilt"; | ||
|
|
||
| const ENERGIZED_RP_THRESHOLD = 360; | ||
| const SUPERCHARGED_RP_THRESHOLD = 500; | ||
| const TRAVERSAL_RP_THRESHOLD = 50; | ||
| const AUTO_CLIMB_POINTS = 15; | ||
|
|
||
| export async function getMatchData( | ||
| scheduledMatch: GoogleSpreadsheetRow, | ||
| dataDirectory: string, | ||
| matchNumber: number | ||
| ): Promise<Match> { | ||
| if (!fsSync.existsSync(dataDirectory)) { | ||
| throw new Error(`Data directory ${dataDirectory} does not exist`); | ||
| } | ||
|
|
||
| if (!fsSync.existsSync(`${dataDirectory}/Auto_R.txt`)) { | ||
| throw new Error( | ||
| `Data directory ${dataDirectory} is not populated with data` | ||
| ); | ||
| } | ||
|
|
||
| const red1 = scheduledMatch["Red 1"]; | ||
| const red2 = scheduledMatch["Red 2"]; | ||
| const red3 = scheduledMatch["Red 3"]; | ||
| const blue1 = scheduledMatch["Blue 1"]; | ||
| const blue2 = scheduledMatch["Blue 2"]; | ||
| const blue3 = scheduledMatch["Blue 3"]; | ||
|
|
||
| const [ | ||
| redAutoString, | ||
| blueAutoString, | ||
| redAutoFuelString, | ||
| blueAutoFuelString, | ||
| redAutoLvl1String, | ||
| blueAutoLvl1String, | ||
| redTeleString, | ||
| blueTeleString, | ||
| redTeleFuelString, | ||
| blueTeleFuelString, | ||
| redEndString, | ||
| blueEndString, | ||
| redScoreString, | ||
| blueScoreString, | ||
| ] = await Promise.all([ | ||
| fs.readFile(`${dataDirectory}/Auto_R.txt`, "utf-8"), | ||
| fs.readFile(`${dataDirectory}/Auto_B.txt`, "utf-8"), | ||
| fs.readFile(`${dataDirectory}/Auto_Fuel_R.txt`, "utf-8"), | ||
| fs.readFile(`${dataDirectory}/Auto_Fuel_B.txt`, "utf-8"), | ||
| fs.readFile(`${dataDirectory}/Auto_lvl_1_R.txt`, "utf-8"), | ||
| fs.readFile(`${dataDirectory}/Auto_lvl_1_B.txt`, "utf-8"), | ||
| fs.readFile(`${dataDirectory}/Tele_R.txt`, "utf-8"), | ||
| fs.readFile(`${dataDirectory}/Tele_B.txt`, "utf-8"), | ||
| fs.readFile(`${dataDirectory}/Tele_Fuel_R.txt`, "utf-8"), | ||
| fs.readFile(`${dataDirectory}/Tele_Fuel_B.txt`, "utf-8"), | ||
| fs.readFile(`${dataDirectory}/End_R.txt`, "utf-8"), | ||
| fs.readFile(`${dataDirectory}/End_B.txt`, "utf-8"), | ||
| fs.readFile(`${dataDirectory}/Score_R.txt`, "utf-8"), | ||
| fs.readFile(`${dataDirectory}/Score_B.txt`, "utf-8"), | ||
| ]); | ||
|
|
||
| // Parse values | ||
| const redAuto = parseInt(redAutoString.trim()); | ||
| const blueAuto = parseInt(blueAutoString.trim()); | ||
| const redAutoFuel = parseInt(redAutoFuelString.trim()); | ||
| const blueAutoFuel = parseInt(blueAutoFuelString.trim()); | ||
| const redAutoLvl1 = parseInt(redAutoLvl1String.trim()); | ||
| const blueAutoLvl1 = parseInt(blueAutoLvl1String.trim()); | ||
| const redTele = parseInt(redTeleString.trim()); | ||
| const blueTele = parseInt(blueTeleString.trim()); | ||
| const redTeleFuel = parseInt(redTeleFuelString.trim()); | ||
| const blueTeleFuel = parseInt(blueTeleFuelString.trim()); | ||
| const redEnd = parseInt(redEndString.trim()); | ||
| const blueEnd = parseInt(blueEndString.trim()); | ||
| const redScore = parseInt(redScoreString.trim()); | ||
| const blueScore = parseInt(blueScoreString.trim()); | ||
|
|
||
| // Calculate total fuel (auto + tele) | ||
| const redTotalFuel = redAutoFuel + redTeleFuel; | ||
| const blueTotalFuel = blueAutoFuel + blueTeleFuel; | ||
|
|
||
| // Calculate ranking points | ||
| let redBonusRP = 0; | ||
| let blueBonusRP = 0; | ||
|
|
||
| // Energized RP - 360+ total fuel | ||
| if (redTotalFuel >= ENERGIZED_RP_THRESHOLD) { | ||
| redBonusRP += 1; | ||
| } | ||
| if (blueTotalFuel >= ENERGIZED_RP_THRESHOLD) { | ||
| blueBonusRP += 1; | ||
| } | ||
|
|
||
| // Supercharged RP - 500+ total fuel | ||
| if (redTotalFuel >= SUPERCHARGED_RP_THRESHOLD) { | ||
| redBonusRP += 1; | ||
| } | ||
| if (blueTotalFuel >= SUPERCHARGED_RP_THRESHOLD) { | ||
| blueBonusRP += 1; | ||
| } | ||
|
|
||
| // Traversal RP - 50+ climb points (end climb points + (auto climbs * 15)) | ||
| const redClimbPoints = redEnd + redAutoLvl1 * AUTO_CLIMB_POINTS; | ||
| const blueClimbPoints = blueEnd + blueAutoLvl1 * AUTO_CLIMB_POINTS; | ||
| if (redClimbPoints >= TRAVERSAL_RP_THRESHOLD) { | ||
| redBonusRP += 1; | ||
| } | ||
| if (blueClimbPoints >= TRAVERSAL_RP_THRESHOLD) { | ||
| blueBonusRP += 1; | ||
| } | ||
|
|
||
| return { | ||
| matchNumber, | ||
| red1, | ||
| red2, | ||
| red3, | ||
| blue1, | ||
| blue2, | ||
| blue3, | ||
| redScore, | ||
| blueScore, | ||
| redAuto, | ||
| blueAuto, | ||
| redTele, | ||
| blueTele, | ||
| redEnd, | ||
| blueEnd, | ||
| redBonusRP, | ||
| blueBonusRP, | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| import type { GoogleSpreadsheetRow } from "google-spreadsheet"; | ||
|
|
||
| export interface Match { | ||
| matchNumber: number; | ||
|
|
||
| red1: string; | ||
| red2: string; | ||
| red3: string; | ||
| blue1: string; | ||
| blue2: string; | ||
| blue3: string; | ||
|
|
||
| redScore: number; | ||
| blueScore: number; | ||
| redAuto: number; | ||
| blueAuto: number; | ||
| redTele: number; | ||
| blueTele: number; | ||
| redEnd: number; | ||
| blueEnd: number; | ||
| redBonusRP: number; | ||
| blueBonusRP: number; | ||
| } | ||
|
|
||
| export const headerValues = [ | ||
| "Match", | ||
| "Red 1", | ||
| "Red 2", | ||
| "Red 3", | ||
| "Blue 1", | ||
| "Blue 2", | ||
| "Blue 3", | ||
| "Red Score", | ||
| "Blue Score", | ||
| "Red Auto", | ||
| "Blue Auto", | ||
| "Red Tele", | ||
| "Blue Tele", | ||
| "Red End", | ||
| "Blue End", | ||
| "Red Bonus RP", | ||
| "Blue Bonus RP", | ||
| ]; | ||
|
|
||
| export function matchToArray(match: Match): (string | number)[] { | ||
| return [ | ||
| match.matchNumber, | ||
| match.red1, | ||
| match.red2, | ||
| match.red3, | ||
| match.blue1, | ||
| match.blue2, | ||
| match.blue3, | ||
| match.redScore, | ||
| match.blueScore, | ||
| match.redAuto, | ||
| match.blueAuto, | ||
| match.redTele, | ||
| match.blueTele, | ||
| match.redEnd, | ||
| match.blueEnd, | ||
| match.redBonusRP, | ||
| match.blueBonusRP, | ||
| ]; | ||
| } | ||
|
|
||
| export function saveMatchToRow(match: Match, row: GoogleSpreadsheetRow) { | ||
| row["Match"] = match.matchNumber; | ||
| row["Red 1"] = match.red1; | ||
| row["Red 2"] = match.red2; | ||
| row["Red 3"] = match.red3; | ||
| row["Blue 1"] = match.blue1; | ||
| row["Blue 2"] = match.blue2; | ||
| row["Blue 3"] = match.blue3; | ||
| row["Red Score"] = match.redScore; | ||
| row["Blue Score"] = match.blueScore; | ||
| row["Red Auto"] = match.redAuto; | ||
| row["Blue Auto"] = match.blueAuto; | ||
| row["Red Tele"] = match.redTele; | ||
| row["Blue Tele"] = match.blueTele; | ||
| row["Red End"] = match.redEnd; | ||
| row["Blue End"] = match.blueEnd; | ||
| row["Red Bonus RP"] = match.redBonusRP; | ||
| row["Blue Bonus RP"] = match.blueBonusRP; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,4 +28,4 @@ | |
| }, | ||
| "exclude": ["node_modules"], | ||
| "include": ["src"] | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.