Skip to content

Commit c948f82

Browse files
authored
Merge pull request #35 from 4201VitruvianBots/pit-part-two
app bug fixes yessir
2 parents 79a3b84 + a37c63e commit c948f82

File tree

8 files changed

+110
-96
lines changed

8 files changed

+110
-96
lines changed

client/src/apps/pit/PitApp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function PitApp() {
111111
</div>
112112

113113
<div className='mb-2 flex items-center justify-center'>
114-
<div className='flex h-40 w-2/4 flex-col items-center justify-center rounded-lg border-4 border-[#2f3646] bg-[#2f3646]'>
114+
<div className='flex h-72 w-2/4 flex-col items-center justify-center rounded-lg border-4 border-[#2f3646] bg-[#2f3646]'>
115115
<h1 className='text-center text-white'>Team Number</h1>
116116
<TeamDropdown
117117
onChange={setTeamNumber}
@@ -125,7 +125,7 @@ function PitApp() {
125125

126126

127127
<div className='mb-8 flex items-center justify-center'>
128-
<div className='flex h-40 w-2/4 flex-col items-center justify-center rounded-lg border-4 border-[#2f3646] bg-[#2f3646] '>
128+
<div className='flex h-72 w-2/4 flex-col items-center justify-center rounded-lg border-4 border-[#2f3646] bg-[#2f3646] '>
129129
<h1 className='text-center text-white'>
130130
Number of Batteries?
131131
</h1>

client/src/apps/score_calculator/ScoreCalculator.tsx

Lines changed: 42 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import React, { Dispatch, SetStateAction, useState } from 'react';
33

44
import LinkButton from '../../components/LinkButton';
55
import { MaterialSymbol } from 'react-material-symbols';
6-
import NumberInput from '../../components/NumberInput';
76

87
function Counter({
98
value,
@@ -17,12 +16,12 @@ function Counter({
1716
return (
1817
<>
1918
<button
20-
className='text-md my-2 rounded-l-lg bg-red-400 px-4 py-2 text-zinc-100 active:brightness-75'
19+
className=' rounded-l-lg bg-red-400 px-4 border py-8 text-zinc-100 active:brightness-75'
2120
onClick={() => onChange(value > 0 ? value - 1 : value)}>
2221
-
2322
</button>
2423
<button
25-
className='text-md min-w-55 my-2 rounded-r-lg bg-slate-600 px-3 py-2 text-zinc-100 active:brightness-75'
24+
className='rounded-r-lg px-1 text-clip bg-slate-600 border text-zinc-100 active:brightness-75'
2625
onClick={() => onChange(value + 1)}>
2726
+ {children} ({value})
2827
</button>
@@ -48,20 +47,18 @@ function ScoreCalculator() {
4847
const [Deep, setDeep] = useState(0);
4948
const [Shallow, setShallow] = useState(0);
5049

51-
const [foulPoints, setFoulPoints] = useState<number | undefined>(0);
52-
5350
const autoPoints = autoLeave * 3 ;
5451
const CoralPoints =
5552
autoCoral1 * 3 + autoCoral2 * 4 + autoCoral3 * 6 + autoCoral4 * 7 + teleCoral1 * 2 + teleCoral2 * 3 + teleCoral3 * 4 + teleCoral4 * 5;
56-
const AlgaePoints = autoAlgaeProcessor * 6 + teleAlgaeProcessor * 6 + autoAlgaeNet *4; teleAlgaeNet * 4;
53+
const AlgaePoints =
54+
autoAlgaeProcessor * 6 + teleAlgaeProcessor * 6 + autoAlgaeNet *4 + teleAlgaeNet * 4;
5755
const cagePoints =
5856
park * 2 + Deep * 12 + Shallow * 6;
5957
const totalPoints =
6058
autoPoints +
6159
CoralPoints +
6260
AlgaePoints +
63-
cagePoints +
64-
(foulPoints ?? 0);
61+
cagePoints ;
6562

6663
const handleReset = () => {
6764
setAutoLeave(0);
@@ -80,14 +77,13 @@ function ScoreCalculator() {
8077
setPark(0);
8178
setDeep(0);
8279
setShallow(0);
83-
setFoulPoints(0);
8480
};
8581

8682
return (
87-
<div className='flex h-dvh flex-col'>
83+
<div className='flex h-dvh flex-col bg-gray-800'>
8884
<div className='mb-2 bg-gray-800'>
8985
<br />
90-
<h1 className='mb-4 text-center text-3xl font-bold text-[#48c55c]'>
86+
<h1 className='mb-4 text-center text-6xl font-bold text-[#48c55c]'>
9187
Score Calculator
9288
</h1>
9389
</div>
@@ -108,14 +104,14 @@ function ScoreCalculator() {
108104
<div className='flex flex-grow flex-col'>
109105
<button
110106
onClick={handleReset}
111-
className='text-md col-span-2 mx-2 rounded-md bg-blue-400/70 px-3 py-2 text-black active:brightness-75'>
107+
className='text-2xl col-span-2 mx-2 rounded-md bg-blue-400/70 px-3 py-2 text-black active:brightness-75'>
112108
Reset All
113109
</button>
114-
<div className='flex flex-grow snap-x snap-mandatory flex-row gap-2 overflow-x-auto p-2 *:flex-shrink-0'>
115-
<div className='grid w-[calc(100%_-_1rem)] snap-center snap-always auto-rows-fr grid-cols-[auto_1fr] grid-rows-[auto] gap-1 md:w-auto md:flex-grow md:basis-0'>
116-
<h2 className='col-span-2 text-center text-xl font-bold text-green-600'>
110+
<h2 className='text-center text-5xl font-bold text-green-400 my-2'>
117111
Auto
118112
</h2>
113+
<>
114+
<div className='snap-center flex justify-center gap-2 my-2'>
119115
<Counter value={autoLeave} onChange={setAutoLeave}>
120116
Auto Leave
121117
</Counter>
@@ -131,17 +127,24 @@ function ScoreCalculator() {
131127
<Counter value={autoCoral4} onChange={setAutoCoral4}>
132128
Auto Coral L4
133129
</Counter>
134-
<Counter value={autoAlgaeProcessor} onChange={setAutoAlgaeProcessor}>
130+
</div>
131+
</>
132+
<>
133+
<div className='snap-center flex justify-center gap-2 my-2'>
134+
<Counter value={autoAlgaeProcessor} onChange={setAutoAlgaeProcessor}>
135135
Auto Algae Processor
136136
</Counter>
137137
<Counter value={autoAlgaeNet} onChange={setAutoAlgaeNet}>
138138
Auto Algae Net
139139
</Counter>
140140
</div>
141-
<div className='grid w-[calc(100%_-_2rem)] snap-center snap-always auto-rows-fr grid-cols-[auto_1fr] grid-rows-[auto] gap-1 md:w-auto md:flex-grow md:basis-0'>
142-
<h2 className='col-span-2 text-center text-xl font-bold text-green-600'>
141+
</>
142+
<h2 className='col-span-2 text-center text-5xl font-bold text-green-400 my-2'>
143143
Teleop
144-
</h2>
144+
</h2>
145+
<>
146+
<div className='snap-center flex justify-center my-2 gap-2'>
147+
145148
<Counter value={teleCoral1} onChange={setTeleCoral1}>
146149
Tele Coral L1
147150
</Counter>
@@ -154,22 +157,23 @@ function ScoreCalculator() {
154157
<Counter value={teleCoral4} onChange={setTeleCoral4}>
155158
Tele Coral L4
156159
</Counter>
157-
160+
</div>
161+
</>
162+
<>
163+
<div className='snap-center flex justify-center gap-2 my-2'>
158164
<Counter value={teleAlgaeProcessor} onChange={setTeleAlgaeProcessor}>
159165
Tele Algae Processor
160166
</Counter>
161-
162-
<Counter
163-
value={teleAlgaeNet}
164-
onChange={setTeleAlgaeNet}>
167+
<Counter value={teleAlgaeNet} onChange={setTeleAlgaeNet}>
165168
Tele Algae Net
166169
</Counter>
167-
</div>
168-
169-
<div className='grid w-[calc(100%_-_1rem)] snap-center snap-always auto-rows-fr grid-cols-[auto_1fr] grid-rows-[auto] gap-1 md:w-auto md:flex-grow md:basis-0'>
170-
<h2 className='col-span-2 text-center text-xl font-bold text-green-600'>
170+
</div>
171+
</>
172+
<h2 className='col-span-2 my-2 text-center text-5xl font-bold text-green-400'>
171173
Endgame
172-
</h2>
174+
</h2>
175+
<div className='snap-center flex justify-center text-3xl my-2 gap-2'>
176+
173177
<Counter value={park} onChange={setPark}>
174178
Park
175179
</Counter>
@@ -183,54 +187,43 @@ function ScoreCalculator() {
183187
</div>
184188
</div>
185189

186-
<div className='col-span-2 grid grid-cols-2 justify-center gap-2 bg-slate-200 p-3'>
187-
<p className='text-black-100 text-md rounded-md border-green-800 bg-green-400/70 px-3 py-2 text-center'>
190+
<div className='col-span-2 grid grid-cols-2 justify-center gap-2 py-2 bg-gray-800'>
191+
<p className='text-black-100 text-md rounded-md border-green-800 bg-green-400 px-3 py-2 text-center'>
188192
Leave:{' '}
189193
<span className='rounded-lg bg-black/15 p-2 py-1'>
190194
{autoPoints}
191195
</span>
192196
</p>
193197

194198
<p
195-
className={` text-black-100 text-md rounded-md border-green-800 bg-green-400/70 px-3 py-2 text-center`}>
199+
className={` text-black-100 text-md rounded-md border-green-800 bg-green-400 px-3 py-2 text-center`}>
196200
Coral:{' '}
197201
<span className='rounded-lg bg-black/15 p-2 py-1'>
198202
{CoralPoints}
199203
</span>
200204
</p>
201205

202-
<p className='text-black-100 text-md rounded-md border-green-800 bg-green-400/70 px-3 py-2 text-center'>
206+
<p className='text-black-100 text-md rounded-md border-green-800 bg-green-400 px-3 py-2 text-center'>
203207
Algae:{' '}
204208
<span className='rounded-lg bg-black/15 p-2 py-1'>
205209
{AlgaePoints}
206210
</span>
207211
</p>
208212

209-
<p className='text-black-100 text-md rounded-md border-green-800 bg-green-400/70 px-3 py-2 text-center'>
210-
Cage:{' '}
211-
<span className='rounded-lg bg-black/15 p-2 py-1'>
213+
<p className='text-black-100 text-md rounded-md border-green-800 bg-green-400 px-3 py-2 text-center'>
214+
Barge:{' '}
215+
<span className='rounded-lg bg-black/15 p-2 py-2'>
212216
{cagePoints}
213217
</span>
214218
</p>
215-
216-
<p className='text-black-100 text-md rounded-md border-green-800 bg-green-400/70 px-3 py-2 text-center'>
217-
Foul Points:{' '}
218-
<NumberInput
219-
className='w-16 rounded-lg bg-black/15 p-2 py-1 text-center'
220-
value={foulPoints}
221-
onChange={setFoulPoints}
222-
/>
223-
</p>
224-
225-
<p className='text-black-100 text-md rounded-md border-green-800 bg-green-400/70 px-3 py-2 text-center font-black'>
219+
</div>
220+
<p className='text-black-100 text-md rounded-md border-green-800 bg-green-400/70 px-3 py-2 text-center font-black'>
226221
Total:{' '}
227222
<span className='rounded-lg bg-black/15 p-2 py-1'>
228223
{totalPoints}
229224
</span>
230225
</p>
231-
</div>
232226
</div>
233-
</div>
234227
);
235228
}
236229

client/src/apps/super/SuperApp.tsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ function SuperApp() {
6969
const [sendQueue, sendAll, queue, sending] = useQueue();
7070
const [matchNumber, setMatchNumber] = useState<number>();
7171
const [showCheck, setShowCheck] = useState(false);
72-
const [history, setHistory] = useState<
73-
{ 1: SuperTeamState; 2: SuperTeamState; 3: SuperTeamState }[]
74-
>([]);
72+
const [history, setHistory] = useState< { 1: SuperTeamState; 2: SuperTeamState; 3: SuperTeamState; 4: SuperScores }[] >([]);
7573
useStatus(superPosition, matchNumber, scouterName);
7674

7775
const saveHistory = () => {
@@ -81,6 +79,7 @@ function SuperApp() {
8179
1: team1,
8280
2: team2,
8381
3: team3,
82+
4: count
8483
},
8584
]);
8685
};
@@ -96,7 +95,10 @@ function SuperApp() {
9695
setTeam3(teamValue);
9796
saveHistory();
9897
};
99-
98+
const handleCount = (scoreValue: SuperScores) => {
99+
setCount(scoreValue);
100+
saveHistory();
101+
}
100102

101103
const handleSubmit = async () => {
102104
if (
@@ -186,6 +188,7 @@ function SuperApp() {
186188
setTeam1(last[1]);
187189
setTeam2(last[2]);
188190
setTeam3(last[3]);
191+
setCount(last[4]);
189192
}
190193
};
191194

@@ -268,6 +271,19 @@ function SuperApp() {
268271
className='m-2 p-2 text-xl text-black'
269272
/>
270273
</div>
274+
<p
275+
className={'mt-10 text-white text-2xl'}>
276+
Human Player Points
277+
</p>
278+
279+
<HumanCounter
280+
count={count}
281+
className='mt-10 mb-5 p-10 mx-4 bg-green-500 text-white text-2xl rounded'
282+
setCount={handleCount} >
283+
</HumanCounter>
284+
285+
286+
<div/>
271287
<p className='text-white pt-5 text-2xl'>Human Player</p>
272288
<div className='grid grid-cols-3 justify-items-center gap-10 px-10'>
273289
<MultiButton
@@ -291,20 +307,7 @@ function SuperApp() {
291307
<SuperTeam teamState={team2} setTeamState={handleTeam2} bgClass={`${shooterPlayerTeam == -2 ? 'bg-[#003805] rounded-lg p-5' : ''} `}/>
292308
<SuperTeam teamState={team3} setTeamState={handleTeam3} bgClass={`${shooterPlayerTeam == -3 ? 'bg-[#003805] rounded-lg p-5' : ''} `}/>
293309

294-
</div>
295-
296-
<p
297-
className={'mt-10 text-white text-2xl'}>
298-
Human Player Points
299-
</p>
300-
<HumanCounter
301-
302-
count={count}
303-
className='mt-10 mb-5 p-10 mx-2 justify-center bg-green-500 text-white text-2xl rounded flex flex-nowrap'
304-
setCount={setCount} >
305-
</HumanCounter>
306-
307-
<br/>
310+
</div>
308311
<button
309312
onClick={() => {
310313
handleSubmit();

client/src/apps/super/components/CannedComments.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const commentOptions: SelectOption<CommentValues>[] = [
2121
{ label: 'great driving', value: 'great_driving', color: '#5ac750' },
2222
{ label: 'good driving', value: 'good_driving', color: '#50a1c7' },
2323
{ label: 'source only', value: 'source_only', color: '#c78450' },
24+
{ label: 'knock pieces', value: 'knock_pieces', color: '#c107f0' },
2425
{ label: 'clogging', value: 'clogging', color: '#c78450' },
2526
{
2627
label: 'effective defense',

client/src/apps/super/components/HumanNetCounter.tsx

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
//import React, { useState } from "react";
2-
import { Dispatch, SetStateAction } from "react";
2+
import { Dispatch } from "react";
33
import { SuperScores } from "../SuperApp";
44

55
type countKeys = keyof SuperScores;
66

7-
87
function HumanButton({
98
// Declare a state variable to keep track of the count
109
handleCount,
@@ -22,31 +21,34 @@ import { SuperScores } from "../SuperApp";
2221
}){
2322
return (
2423
<>
25-
<p className={'mt-8 text-white text-2xl'}>
26-
Successes
27-
</p>
28-
24+
<div className="snap-center flex justify-center w-auto">
25+
<p className={'mt-8 text-white text-2xl mx-16'}>
26+
Successes
27+
</p>
28+
<p className={'mt-8 text-white text-2xl mx-20'}>
29+
Fails
30+
</p>
31+
</div>
32+
<div className="snap-center flex justify-center">
2933
<button
3034
// className="mt-10 p-10 mx-4 bg-green-500 text-white Ftext-2xl rounded"
3135
onClick={() => handleCount(successKey)}
32-
className='mt-10 mb-5 p-10 mx-4 bg-green-500 text-white text-2xl rounded'
36+
className='mt-10 mb-5 p-10 mx-20 bg-green-500 text-white text-2xl rounded'
3337

3438
id='one'>
3539
<p>
3640
{count[successKey]}
3741
</p>
3842
</button>
39-
<div/>
40-
<p className={'mt-8 text-white text-2xl'}>
41-
Fails</p>
4243
<button
43-
className='mt-10 mb-5 p-10 mx-4 bg-red-500 text-white text-2xl rounded'
44+
className='mt-10 mb-5 p-10 mx-16 bg-red-500 text-white text-2xl rounded'
4445
onClick={() => handleCount(failKey)}
4546
id='one'>
4647
<p>
4748
{count[failKey]}
4849
</p>
4950
</button>
51+
</div>
5052
</>
5153
);
5254
};
@@ -60,16 +62,17 @@ function HumanCounter({
6062

6163
count: SuperScores;
6264
className?:string;
63-
setCount:Dispatch<SetStateAction<SuperScores>>;
65+
setCount:Dispatch<SuperScores>;
6466

6567
}){
6668

6769
const handleCount = (key: countKeys) => {
68-
setCount(prevCount => ({
69-
...prevCount,
70-
[key]: prevCount[key] + 1,
71-
}));
72-
// }
70+
// get current human count
71+
const grabCount = {...count};
72+
grabCount[key] = (grabCount[key] || 0) + 1;
73+
setCount(grabCount);
74+
// add 1 to specific
75+
7376
};
7477

7578
return(

0 commit comments

Comments
 (0)