diff --git a/src/lib/types.ts b/src/lib/types.ts index b8e462e..14bef75 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -68,16 +68,22 @@ export type TeleActionData = { }; // Action Types +// Naming Convention: action_type + game_piece + where export type TeleAction = | 'IntakeTote' | 'IntakeBalloon' - | 'IntakeCoral' - | 'ScoreYourHeldTote' - | 'ScoreOtherHeldTote' - | 'ScoreExternalTote' + | 'IntakeBalloonCoral' + | 'ScoreBalloonInternalTote' // Held by scorer + | 'ScoreBalloonExternalTote' // Held by alliance member + | 'ScoreBalloonUncontrolledTote' | 'ScoreBalloonLow'; -export type BunnyAction = 'IntakeBunny' | 'ScoreBunnyTote' | 'ScoreBunnyLow'; +export type BunnyAction = + | 'IntakeBunny' + | 'ScoreBunnyInternalTote' + | 'ScoreBunnyExternalTote' + | 'ScoreBunnyUncontrolledTote' + | 'ScoreBunnyLow'; export type AutoAction = TeleAction | BunnyAction; // For state machine diff --git a/src/routes/scout/ActionInputs.svelte b/src/routes/scout/ActionInputs.svelte index 5b8bba3..8bf785b 100644 --- a/src/routes/scout/ActionInputs.svelte +++ b/src/routes/scout/ActionInputs.svelte @@ -5,7 +5,11 @@ const { actions = $bindable() }: { actions: AutoActionData[] } = $props(); let actionState: AutoInputState = $state('None') as AutoInputState; - let held_pieces: number = $state(0); + + let held_bunnies: number = $state(0); + let held_balloons: number = $state(0); + let held_totes: number = $state(0); + let held_pieces: number = $derived(held_balloons + held_bunnies); function intake_piece() { actionState = actionState === 'None' ? 'Intake' : actionState; @@ -14,10 +18,19 @@ if (held_pieces < 1) return; actionState = actionState === 'None' ? 'Score' : actionState; } + function score_bunny(where: 'Low' | 'ExternalTote' | 'InternalTote' | 'UncontrolledTote') { + actionState = `ScoreBunny${where}`; + } + function score_balloon(where: 'Low' | 'InternalTote' | 'ExternalTote' | 'UncontrolledTote') { + actionState = `ScoreBalloon${where}`; + } function complete(success: boolean) { // Assume that the robot ejects even if they fail to score - if (actionState.substring(0, 5) === 'Score') held_pieces--; - else if (actionState.substring(0, 6) === 'Intake' && success) held_pieces++; + if (actionState.includes('IntakeBalloon')) held_balloons++; + else if (actionState.includes('IntakeBunny')) held_bunnies++; + else if (actionState.includes('IntakeTote')) held_totes++; + else if (actionState.includes('ScoreBalloon')) held_balloons--; + else if (actionState.includes('ScoreBunny')) held_bunnies--; const action: AutoActionData = { action: actionState as AutoAction, @@ -50,7 +63,9 @@ - - - - - - + {#if held_bunnies > 0} + + + {#if held_totes > 0} + + {/if} + + {/if} + {#if held_balloons > 0} + + + {#if held_totes > 0} + + {/if} + + {/if}