From 78f36cc2a4d13b63ae9a028a9b0e1ee3117d7486 Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Tue, 19 Nov 2024 19:29:50 -0800 Subject: [PATCH] fix: bind held items in timeline modification --- src/lib/ActionInputStateMachine.svelte.ts | 14 ++++ src/lib/components/Action.svelte | 2 +- src/lib/components/Timeline.svelte | 22 ++++-- src/lib/types.ts | 6 ++ src/routes/scout/[team_data]/+page.svelte | 34 +++++++-- .../scout/[team_data]/AutoActionInputs.svelte | 46 ++++++------ .../scout/[team_data]/TeleActionInputs.svelte | 72 +++++++++---------- 7 files changed, 121 insertions(+), 75 deletions(-) diff --git a/src/lib/ActionInputStateMachine.svelte.ts b/src/lib/ActionInputStateMachine.svelte.ts index ef2ebd6..c06a3c1 100644 --- a/src/lib/ActionInputStateMachine.svelte.ts +++ b/src/lib/ActionInputStateMachine.svelte.ts @@ -5,6 +5,20 @@ export class ActionInputVerifier { private held_balloons: number = 0; private held_totes: number = 0; + public get_held_tele(): { balloons: number; totes: number } { + return { + balloons: this.held_balloons, + totes: this.held_totes + }; + } + public get_held_auto(): { bunnies: number; balloons: number; totes: number } { + return { + bunnies: this.held_bunnies, + balloons: this.held_balloons, + totes: this.held_totes + }; + } + public verify_actions(action_data: AutoActionData[]) { action_data .reverse() diff --git a/src/lib/components/Action.svelte b/src/lib/components/Action.svelte index cd2caf7..75bac0f 100644 --- a/src/lib/components/Action.svelte +++ b/src/lib/components/Action.svelte @@ -10,7 +10,7 @@ }: { action_data: AutoActionData; index: number; - shift: (index: number, change: number) => void; + shift: (index: number, change: -1 | 1) => void; remove: (index: number) => void; } = $props(); diff --git a/src/lib/components/Timeline.svelte b/src/lib/components/Timeline.svelte index 16ef430..2f212c5 100644 --- a/src/lib/components/Timeline.svelte +++ b/src/lib/components/Timeline.svelte @@ -1,12 +1,17 @@ diff --git a/src/lib/types.ts b/src/lib/types.ts index bba036e..a4907ba 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -91,6 +91,12 @@ export type BunnyAction = | 'ScoreBunnyLow'; export type AutoAction = TeleAction | BunnyAction; +export type TeleHeldItems = { + balloons: number; + totes: number; +}; +export type AutoHeldItems = TeleHeldItems & { bunnies: number }; + // For state machine export type ItemInputState = 'Intake' | 'Score' | 'Eject' | 'None'; export type TeleInputState = TeleAction | ItemInputState; diff --git a/src/routes/scout/[team_data]/+page.svelte b/src/routes/scout/[team_data]/+page.svelte index d038bb8..630a5ce 100644 --- a/src/routes/scout/[team_data]/+page.svelte +++ b/src/routes/scout/[team_data]/+page.svelte @@ -1,5 +1,11 @@