Skip to content

Commit

Permalink
fix: totes not checked
Browse files Browse the repository at this point in the history
  • Loading branch information
azaleacolburn committed Dec 10, 2024
1 parent 9f4dedd commit 410b17c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/lib/ActionInputStateMachine.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export class ActionInputVerifier {
verify_new_action(action_data: AutoActionData): boolean {
const success = action_data.success;
const action = action_data.action;
console.log(action);
if (action.includes('InternalTote') && this.held_totes === 0) return false;
if (success) {
if (action.includes('IntakeBalloon')) this.held_balloons++;
else if (action.includes('IntakeBunny')) this.held_bunnies++;
Expand Down
6 changes: 2 additions & 4 deletions src/lib/components/Timeline.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,20 @@
}
function shift(index: number, change: -1 | 1) {
//if (furthest_auto_index === index) furthest_auto_index += change;
//else if (furthest_auto_index === index + change) furthest_auto_index = index;
[actions[index], actions[index + change]] = [actions[index + change], actions[index]];
verify();
}
function verify() {
const action_input_verifier = new ActionInputVerifier();
action_input_verifier.verify_actions(actions);
console.log(actions);
// TODO: Fix this horrible and jank solution
held = Object.hasOwn(held, 'bunnies')
? action_input_verifier.get_held_auto()
: action_input_verifier.get_held_tele();
}
const is_valid_timeline = $derived(actions.filter((action) => !action.ok).length === 0);
const is_valid_timeline: boolean = $derived(!actions.find((action) => !action.ok));
</script>

<button
Expand Down
18 changes: 11 additions & 7 deletions src/routes/scout/[team_data]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
// The furthest index in actions that was made during auto
let furthest_auto_index = $state(0);
let speed = $state(3);
let awareness = $state(3);
let broke = $state(false);
let died = $state(false);
let notes = $state('');
let speed: number = $state(3);
let awareness: number = $state(3);
let broke: boolean = $state(false);
let died: boolean = $state(false);
let notes: string = $state('');
let prematch = $state(false);
let timeline_extended = $state(false);
let gamePhase = $state('Auto') as 'Auto' | 'Tele' | 'Post';
let gamePhase = $state('Prematch') as 'Prematch' | 'Auto' | 'Tele' | 'Post';
let pageName = $state('');
function phaseShiftRight() {
Expand Down Expand Up @@ -86,7 +88,9 @@
</div>
</div>

{#if gamePhase === 'Auto'}
{#if gamePhase === 'Prematch'}
<button class="h-9/12 w-9/12 border">Preload?</button>
{:else if gamePhase === 'Auto'}
<AutoActionInputs
bind:furthest_auto_index
bind:held
Expand Down
8 changes: 4 additions & 4 deletions src/routes/scout/[team_data]/AutoActionInputs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
>
<button
class="rounded bg-gunmetal p-2"
onclick={() => (actionState = 'IntakeBalloonCoral')}>Ballon: Coral</button
onclick={() => (actionState = 'IntakeBalloonCoral')}>Balloon: Coral</button
>
</div>
<button
Expand Down Expand Up @@ -156,7 +156,7 @@
{/if}
{#if held.balloons > 0}
<div class="flex w-full flex-grow flex-col items-center gap-2 py-2 text-lg">
<h1>Ballon</h1>
<h1>Balloon</h1>
<div class="grid w-full flex-grow grid-cols-2 grid-rows-2 gap-2">
<button class="rounded bg-gunmetal p-2" onclick={() => score_balloon('Low')}
>Low Zone</button
Expand Down Expand Up @@ -186,7 +186,7 @@
>
</div>
{:else if is_eject_state}
<div class="grid w-full flex-grow grid-flow-row gap-2 py-2 font-heading font-bold">
<div class="grid w-full flex-grow grid-flow-row gap-2 py-2 font-heading text-lg font-bold">
{#if held.bunnies > 0}
<button
class="w-full rounded bg-gunmetal p-2"
Expand All @@ -196,7 +196,7 @@
{#if held.balloons > 0}
<button
class="w-full rounded bg-gunmetal p-2"
onclick={() => (actionState = 'EjectBalloon')}>Ballon</button
onclick={() => (actionState = 'EjectBalloon')}>Balloon</button
>
{/if}
{#if held.totes > 0}
Expand Down
6 changes: 3 additions & 3 deletions src/routes/scout/[team_data]/TeleActionInputs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
>
<button
class="rounded bg-gunmetal p-2"
onclick={() => (actionState = 'IntakeBalloonCoral')}>Ballon: Coral</button
onclick={() => (actionState = 'IntakeBalloonCoral')}>Balloon: Coral</button
>
</div>
<button
Expand All @@ -100,7 +100,7 @@
class="flex w-full flex-grow flex-col items-center gap-2 py-2 font-heading text-lg font-bold"
>
<div class="flex w-full flex-grow flex-col items-center gap-2 py-2 text-lg">
<h1>Ballon</h1>
<h1>Balloon</h1>
<div class="grid w-full flex-grow grid-cols-2 grid-rows-2 gap-2">
<button class="rounded bg-gunmetal p-2" onclick={() => score_balloon('Low')}
>Low Zone</button
Expand Down Expand Up @@ -131,7 +131,7 @@
{#if held.balloons > 0}
<button
class="w-full rounded bg-gunmetal p-2"
onclick={() => (actionState = 'EjectBalloon')}>Ballon</button
onclick={() => (actionState = 'EjectBalloon')}>Balloon</button
>
{/if}
{#if held.totes > 0}
Expand Down

0 comments on commit 410b17c

Please sign in to comment.