-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add pcm_get_team_roster tool #7
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
da45941
feat: add pcm_get_team_roster tool to list team rosters from PCM save…
mpicciolli 447c489
feat: enhance team roster tool with country and per-terrain ratings; …
mpicciolli 11b4405
Added try catch
mpicciolli 635d4ec
Merge commit 'fb5db935702cb70cc9083ee9274caf0c1334f6c4' into feat/add…
mpicciolli 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
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
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,79 @@ | ||
| import { z } from "zod"; | ||
|
|
||
| /** | ||
| * Per-terrain ability ratings shared by every tool that returns a cyclist | ||
| * (`pcm_search_cyclist`, `pcm_get_team_roster`). These map one-to-one to the | ||
| * `charac_i_*` columns on `DYN_cyclist`. | ||
| * | ||
| * Spread `ratingsSchema.shape` into a cyclist's output schema to keep the | ||
| * ratings flat, and use {@link mapRatings} to read them off a result row (both | ||
| * expect the columns to be aliased to the field names below). | ||
| */ | ||
| export const ratingsSchema = z.object({ | ||
| plain: z.number().describe("Plain rating (charac_i_plain)"), | ||
| mountain: z.number().describe("Mountain rating (charac_i_mountain)"), | ||
| mediumMountain: z | ||
| .number() | ||
| .nullable() | ||
| .describe( | ||
| "Medium mountain rating (charac_i_medium_mountain) — null on saves that pre-date this column", | ||
| ), | ||
| downhilling: z.number().describe("Downhilling rating (charac_i_downhilling)"), | ||
| cobble: z.number().describe("Cobblestone rating (charac_i_cobble)"), | ||
| timeTrial: z.number().describe("Time trial rating (charac_i_timetrial)"), | ||
| prologue: z.number().describe("Prologue rating (charac_i_prologue)"), | ||
| sprint: z.number().describe("Sprint rating (charac_i_sprint)"), | ||
| acceleration: z | ||
| .number() | ||
| .describe("Acceleration rating (charac_i_acceleration)"), | ||
| endurance: z.number().describe("Endurance rating (charac_i_endurance)"), | ||
| resistance: z.number().describe("Resistance rating (charac_i_resistance)"), | ||
| recuperation: z | ||
| .number() | ||
| .describe("Recuperation rating (charac_i_recuperation)"), | ||
| hill: z.number().describe("Hill rating (charac_i_hill)"), | ||
| baroudeur: z.number().describe("Baroudeur rating (charac_i_baroudeur)"), | ||
| }); | ||
|
|
||
| /** SQL `SELECT` fragment that aliases the rating columns to {@link ratingsSchema}'s | ||
| * field names. `mediumMountain` falls back to `NULL` on saves that pre-date the | ||
| * `charac_i_medium_mountain` column. */ | ||
| export function ratingsColumns(hasMediumMountain: boolean): string { | ||
| return `c.charac_i_plain AS plain, | ||
| c.charac_i_mountain AS mountain, | ||
| ${hasMediumMountain ? "c.charac_i_medium_mountain" : "NULL"} AS mediumMountain, | ||
| c.charac_i_downhilling AS downhilling, | ||
| c.charac_i_cobble AS cobble, | ||
| c.charac_i_timetrial AS timeTrial, | ||
| c.charac_i_prologue AS prologue, | ||
| c.charac_i_sprint AS sprint, | ||
| c.charac_i_acceleration AS acceleration, | ||
| c.charac_i_endurance AS endurance, | ||
| c.charac_i_resistance AS resistance, | ||
| c.charac_i_recuperation AS recuperation, | ||
| c.charac_i_hill AS hill, | ||
| c.charac_i_baroudeur AS baroudeur`; | ||
| } | ||
|
|
||
| /** Read the rating fields off a query row aliased per {@link ratingsColumns}. */ | ||
| export function mapRatings( | ||
| row: Record<string, unknown>, | ||
| ): z.infer<typeof ratingsSchema> { | ||
| return { | ||
| plain: Number(row.plain), | ||
| mountain: Number(row.mountain), | ||
| mediumMountain: | ||
| row.mediumMountain != null ? Number(row.mediumMountain) : null, | ||
| downhilling: Number(row.downhilling), | ||
| cobble: Number(row.cobble), | ||
| timeTrial: Number(row.timeTrial), | ||
| prologue: Number(row.prologue), | ||
| sprint: Number(row.sprint), | ||
| acceleration: Number(row.acceleration), | ||
| endurance: Number(row.endurance), | ||
| resistance: Number(row.resistance), | ||
| recuperation: Number(row.recuperation), | ||
| hill: Number(row.hill), | ||
| baroudeur: Number(row.baroudeur), | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.