Skip to content
Open
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
61 changes: 40 additions & 21 deletions app/game/post-match.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import React from "react";
import { Checkbox } from "../../lib/components/Checkbox";
import { RobotRole } from "../../lib/collection/RobotRole";
import { MatchEventType } from "../../lib/collection/MatchEventType";
import { stealingTypeDescriptions } from "../../lib/collection/StealingType";

export default function PostMatch() {
const reportState = useReportStateStore();
Expand All @@ -59,7 +60,7 @@ export default function PostMatch() {
);

const hasEndgameClimbEvent = reportState.hasEndgameClimbEvent();

const hasAutoClimbEvent = reportState.hasAutoClimbEvent();
const endgameClimbIsMismatched =
hasEndgameClimbEvent &&
reportState.climbResult === EndgameClimb.NotAttempted;
Expand Down Expand Up @@ -128,6 +129,19 @@ export default function PostMatch() {
multiSelect
/>
)}
{reportState.robotRole.includes(RobotRole.Stealing) && (
<PostMatchSelector
title="Stealing Type"
items={stealingTypeDescriptions.map((desc) => ({
label: desc.localizedDescription,
description: desc.localizedLongDescription,
value: desc.stealingType,
}))}
selected={reportState.stealingType}
onChange={reportState.setStealingType}
multiSelect
/>
)}
{shouldShowDefenseEffectiveness && (
<PostMatchSelector
title="Defense Effectiveness"
Expand Down Expand Up @@ -216,16 +230,19 @@ export default function PostMatch() {
return FieldTraversal.None;
}}
/>
<PostMatchSelector
title="Auto Climb"
items={autoClimbDescriptions.map((desc) => ({
label: desc.localizedDescription,
description: desc.localizedLongDescription,
value: desc.climb,
}))}
selected={reportState.autoClimb}
onChange={reportState.setAutoClimb}
/>
{hasAutoClimbEvent && (
<PostMatchSelector
title="Auto Climb"
items={autoClimbDescriptions.map((desc) => ({
label: desc.localizedDescription,
description: desc.localizedLongDescription,
value: desc.climb,
}))}
selected={reportState.autoClimb}
onChange={reportState.setAutoClimb}
/>
)}

{hasEndgameClimbEvent && (
<PostMatchSelector
title="Endgame Climb"
Expand Down Expand Up @@ -285,16 +302,18 @@ export default function PostMatch() {
onChange={reportState.setDriverAbility}
/>

<PostMatchSelector
title="Scores While Moving"
items={scoresWhileMovingDescriptions.map((desc) => ({
label: desc.localizedDescription,
description: desc.localizedLongDescription,
value: desc.scoresWhileMoving,
}))}
selected={reportState.scoresWhileMoving}
onChange={reportState.setScoresWhileMoving}
/>
{reportState.hasEventOfType(MatchEventType.StartScoring) && (
<PostMatchSelector
title="Scores While Moving"
items={scoresWhileMovingDescriptions.map((desc) => ({
label: desc.localizedDescription,
description: desc.localizedLongDescription,
value: desc.scoresWhileMoving,
}))}
selected={reportState.scoresWhileMoving}
onChange={reportState.setScoresWhileMoving}
/>
)}

<View style={{ marginVertical: 18 }}>
<Checkbox
Expand Down
1 change: 1 addition & 0 deletions app/settings/qrcode-size.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const EXAMPLE_SCOUT_REPORT: ScoutReport = {
autoClimb: "FAILED",
intakeType: "GROUND",
feederTypes: ["STOP_TO_SHOOT"],
stealingType: ["TO_ALLIANCE", "TO_NEUTRAL"],
beached: "ON_FUEL",
defenseEffectiveness: 4,
scoresWhileMoving: true,
Expand Down
7 changes: 7 additions & 0 deletions lib/collection/FeederType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export enum FeederType {
Continuous,
StopToShoot,
Dump,
Push,
}

export type FeederTypeDescription = {
Expand Down Expand Up @@ -31,4 +32,10 @@ export const feederTypeDescriptions = [
localizedLongDescription: "The robot dumps fuel when feeding.",
num: 2,
},
{
feederType: FeederType.Push,
localizedDescription: "Push",
localizedLongDescription: "The robot pushes fuel when feeding.",
num: 3,
},
] as const satisfies FeederTypeDescription[];
3 changes: 3 additions & 0 deletions lib/collection/ReportState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Beached } from "./Beached";
import { DefenseEffectiveness } from "./DefenseEffectiveness";
import { ScoresWhileMoving } from "./ScoresWhileMoving";
import { EndgameClimb } from "./EndgameClimb";
import { StealingType } from "./StealingType";

export enum GamePhase {
Auto,
Expand Down Expand Up @@ -45,6 +46,7 @@ export type ReportState = {
scoresWhileMoving: ScoresWhileMoving;
climbResult: EndgameClimb;
driverAbility: DriverAbility;
stealingType: StealingType[];
notes: string;

// Actions
Expand All @@ -61,6 +63,7 @@ export type ReportState = {
setAutoClimb: (value: AutoClimb) => void;
setIntakeType: (value: IntakeType) => void;
setFeederType: (value: FeederType[]) => void;
setStealingType: (value: StealingType[]) => void;
setBeached: (value: Beached) => void;
setDefenseEffectiveness: (value: DefenseEffectiveness) => void;
setScoresWhileMoving: (value: ScoresWhileMoving) => void;
Expand Down
8 changes: 8 additions & 0 deletions lib/collection/RobotRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export enum RobotRole {
Feeding,
Defending,
Immobile,
Stealing,
}

export type RobotRoleDescription = {
Expand Down Expand Up @@ -49,4 +50,11 @@ export const robotRoleDescriptions = [
"The robot was immobile or non-functional during the match.",
num: 4,
},
{
role: RobotRole.Stealing,
localizedDescription: "Stealing",
localizedLongDescription:
"The robot steals fuel from the opposing alliance.",
num: 5,
},
] as const satisfies RobotRoleDescription[];
12 changes: 10 additions & 2 deletions lib/collection/ScoutReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const RobotRoleString = z.enum([
"FEEDING",
"DEFENDING",
"IMMOBILE",
"STEALING",
]);
export const AutoClimbString = z.enum(["NOT_ATTEMPTED", "FAILED", "SUCCEEDED"]);
export const IntakeTypeString = z.enum([
Expand All @@ -28,7 +29,13 @@ export const IntakeTypeString = z.enum([
"BOTH",
"NEITHER",
]);
export const FeederTypeString = z.enum(["CONTINUOUS", "STOP_TO_SHOOT", "DUMP"]);
export const FeederTypeString = z.enum([
"CONTINUOUS",
"STOP_TO_SHOOT",
"DUMP",
"PUSH",
]);
export const StealingTypeString = z.enum(["TO_ALLIANCE", "TO_NEUTRAL"]);
export const BeachedString = z.enum(["ON_FUEL", "ON_BUMP", "BOTH", "NEITHER"]);
export const EndgameClimbString = z.enum([
"NOT_ATTEMPTED",
Expand All @@ -55,8 +62,9 @@ export const scoutReportSchema = z.object({
autoClimb: AutoClimbString,
intakeType: IntakeTypeString,
feederTypes: z.array(FeederTypeString),
stealingType: z.array(StealingTypeString),
beached: BeachedString,
defenseEffectiveness: z.number(),
defenseEffectiveness: z.number().or(z.null()),
scoresWhileMoving: z.boolean(),
endgameClimb: EndgameClimbString,
driverAbility: z.number(),
Expand Down
28 changes: 28 additions & 0 deletions lib/collection/StealingType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export enum StealingType {
toAlliance,
toNeutral,
}

export type StealingTypeDescription = {
stealingType: StealingType;
localizedDescription: string;
localizedLongDescription: string;
num: number;
};

export const stealingTypeDescriptions = [
{
stealingType: StealingType.toAlliance,
localizedDescription: "To Alliance",
localizedLongDescription:
"The robot moves fuel from the opposing alliance zone to its alliance zone.",
num: 0,
},
{
stealingType: StealingType.toNeutral,
localizedDescription: "To Neutral",
localizedLongDescription:
"The robot moves fuel from the opposing alliance zone to the neutral zone.",
num: 1,
},
] as const satisfies StealingTypeDescription[];
34 changes: 30 additions & 4 deletions lib/collection/reportStateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ScoresWhileMoving } from "./ScoresWhileMoving";
import { EndgameClimb } from "./EndgameClimb";
import { MatchEventType } from "./MatchEventType";
import Constants from "expo-constants";
import { StealingType } from "./StealingType";

const initialState = {
events: [],
Expand All @@ -39,6 +40,7 @@ const initialState = {
climbResult: EndgameClimb.NotAttempted,
driverAbility: DriverAbility.Average,
notes: "",
stealingType: [] as StealingType[],
};

export const useReportStateStore = create<ReportState>((set, get) => ({
Expand Down Expand Up @@ -75,6 +77,7 @@ export const useReportStateStore = create<ReportState>((set, get) => ({
setClimbResult: (value) => set({ climbResult: value }),
setDriverAbility: (value) => set({ driverAbility: value }),
setNotes: (value) => set({ notes: value }),
setStealingType: (value) => set({ stealingType: value }),

hasEventOfType: (...types: MatchEventType[]) => {
const reportState = get();
Expand Down Expand Up @@ -220,7 +223,13 @@ export const useReportStateStore = create<ReportState>((set, get) => ({
// Map RobotRole enum to string
const robotRoleToString = (
role: RobotRole,
): "CYCLING" | "SCORING" | "FEEDING" | "DEFENDING" | "IMMOBILE" => {
):
| "CYCLING"
| "SCORING"
| "FEEDING"
| "DEFENDING"
| "IMMOBILE"
| "STEALING" => {
switch (role) {
case RobotRole.Cycling:
return "CYCLING";
Expand All @@ -231,7 +240,10 @@ export const useReportStateStore = create<ReportState>((set, get) => ({
case RobotRole.Defending:
return "DEFENDING";
case RobotRole.Immobile:
default:
return "IMMOBILE";
case RobotRole.Stealing:
return "STEALING";
Comment on lines 242 to +246
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This switch statement looks really wrong

}
};

Expand Down Expand Up @@ -284,14 +296,27 @@ export const useReportStateStore = create<ReportState>((set, get) => ({
// Map FeederType enum to string
const feederTypeToString = (
feederType: FeederType,
): "CONTINUOUS" | "STOP_TO_SHOOT" | "DUMP" => {
): "CONTINUOUS" | "STOP_TO_SHOOT" | "PUSH" => {
switch (feederType) {
case FeederType.Continuous:
return "CONTINUOUS";
case FeederType.StopToShoot:
return "STOP_TO_SHOOT";
case FeederType.Dump:
return "DUMP";
case FeederType.Push:
return "PUSH";
default:
return "PUSH";
}
Comment on lines 300 to +309
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will return "PUSH" if you input FeederType.Dump

};

const stealingTypeToString = (
stealingType: StealingType,
): "TO_ALLIANCE" | "TO_NEUTRAL" => {
switch (stealingType) {
case StealingType.toAlliance:
return "TO_ALLIANCE";
case StealingType.toNeutral:
return "TO_NEUTRAL";
}
};

Expand Down Expand Up @@ -367,6 +392,7 @@ export const useReportStateStore = create<ReportState>((set, get) => ({
scoresWhileMoving:
reportState.scoresWhileMoving === ScoresWhileMoving.Yes,
endgameClimb: endgameClimbToString(reportState.climbResult),
stealingType: reportState.stealingType.map(stealingTypeToString),
driverAbility: driverAbilityDescriptions.find(
(desc) => desc.ability === reportState.driverAbility,
)!.numericalRating,
Expand Down
Loading