-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:tsaxking/template-scouting-app into…
… chore-update-scripts-to-27051fcd9f8cd70f3942b348534e33f8ec2a315f
- Loading branch information
Showing
48 changed files
with
3,808 additions
and
850 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ | |
[submodule "shared/submodules/calculations"] | ||
path = shared/submodules/calculations | ||
url = [email protected]:tsaxking/calculations.git | ||
[submodule "shared/submodules/tatorscout-calculations"] | ||
path = shared/submodules/tatorscout-calculations | ||
url = [email protected]:tsaxking/tatorscout-calculations.git |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import '../utilities/imports'; | ||
|
||
import Main from '../views/Main.svelte'; | ||
|
||
new Main({ | ||
target: document.body, | ||
}); | ||
|
||
import { Settings } from '../models/settings'; | ||
Object.assign(window, { Settings }); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,241 @@ | ||
import { Color } from '../../submodules/colors/color'; | ||
import { Iterator } from './app-object'; | ||
import { Drawable } from '../canvas/drawable'; | ||
import { | ||
amps, | ||
autoZone, | ||
border, | ||
srcs, | ||
stages, | ||
zones, | ||
} from '../../../shared/submodules/tatorscout-calculations/2024-areas'; | ||
import { | ||
Action2024, | ||
TraceParse2024, | ||
Zones2024, | ||
} from '../../../shared/submodules/tatorscout-calculations/trace'; | ||
import { App, Tick } from './app'; | ||
import { Point2D } from '../../../shared/submodules/calculations/src/linear-algebra/point'; | ||
import { Icon } from '../canvas/material-icons'; | ||
import { SVG } from '../canvas/svg'; | ||
|
||
/** | ||
* Builds the app for the 2024 game | ||
* @date 1/25/2024 - 4:59:26 PM | ||
*/ | ||
export const generate2024App = ( | ||
alliance: 'red' | 'blue' | null = null, | ||
): App<Action2024> => { | ||
const icons: { | ||
[key in Action2024]: Icon | SVG; | ||
} = { | ||
spk: new Icon('speaker'), | ||
amp: new Icon('campaign'), | ||
src: new Icon('back_hand'), | ||
clb: new Icon('dry_cleaning'), | ||
trp: new Icon('place_item'), | ||
}; | ||
|
||
const app = new App<Action2024, Zones2024, TraceParse2024>(2024, alliance, icons); | ||
|
||
const isIn = (d: Drawable) => | ||
app.currentLocation ? d.isIn(app.currentLocation) : false; | ||
|
||
// const colors = { | ||
// red: new Color(255, 0, 0), | ||
// redFade: new Color(255, 0, 0, 0.25), | ||
// blue: new Color(0, 0, 255), | ||
// blueFade: new Color(0, 0, 255, 0.25), | ||
// black: new Color(0, 0, 0), | ||
// blackFade: new Color(0, 0, 0, 0.25), | ||
// }; | ||
|
||
const colors = { | ||
red: Color.fromBootstrap('red'), | ||
blue: Color.fromBootstrap('blue'), | ||
redFade: Color.fromBootstrap('red').setAlpha(0.1), | ||
blueFade: Color.fromBootstrap('blue').setAlpha(0.1), | ||
black: Color.fromBootstrap('dark'), | ||
blackFade: Color.fromBootstrap('dark').setAlpha(0.5), | ||
} | ||
|
||
app.addArea('blue-stage', stages.blue, colors.blueFade, isIn); | ||
app.addArea('blue-amp', amps.blue, colors.blueFade, isIn); | ||
app.addArea('blue-src', srcs.blue, colors.blueFade, isIn); | ||
app.addArea('blue-zone', zones.blue, colors.blueFade, isIn); | ||
app.addArea('blue-auto', autoZone.blue, colors.blueFade, isIn); | ||
|
||
app.addArea('red-auto', autoZone.red, colors.redFade, isIn); | ||
app.addArea('red-zone', zones.red, colors.redFade, isIn); | ||
app.addArea('red-src', srcs.red, colors.redFade, isIn); | ||
app.addArea('red-amp', amps.red, colors.redFade, isIn); | ||
app.addArea('red-stage', stages.red, colors.redFade, isIn); | ||
|
||
app.setBorder(border as Point2D[], colors.blackFade); | ||
|
||
// app.border = new Border(border as [number, number][]); | ||
|
||
// app.border.$properties.doDraw = isIn; | ||
// app.border.$properties.fill = { | ||
// color: Color.fromName('black').setAlpha(0.5).toString('rgba'), | ||
// } | ||
|
||
// gameObject buttons | ||
const blueAmp = document.createElement('button'); | ||
const redAmp = document.createElement('button'); | ||
const blueSpeaker = document.createElement('button'); | ||
const redSpeaker = document.createElement('button'); | ||
const blueSource = document.createElement('button'); | ||
const redSource = document.createElement('button'); | ||
|
||
const blueButtonClasses = ['btn', 'btn-primary', 'btn-lg']; | ||
const redButtonClasses = ['btn', 'btn-danger', 'btn-lg']; | ||
|
||
blueAmp.classList.add(...blueButtonClasses); | ||
blueAmp.innerHTML = `<i class="material-icons">campaign</i>`; | ||
redAmp.classList.add(...redButtonClasses); | ||
redAmp.innerHTML = `<i class="material-icons">campaign</i>`; | ||
blueSpeaker.classList.add(...blueButtonClasses); | ||
blueSpeaker.innerHTML = `<i class="material-icons">speaker</i>`; | ||
redSpeaker.classList.add(...redButtonClasses); | ||
redSpeaker.innerHTML = `<i class="material-icons">speaker</i>`; | ||
blueSource.classList.add(...blueButtonClasses); | ||
blueSource.innerHTML = `<i class="material-icons">back_hand</i>`; | ||
redSource.classList.add(...redButtonClasses); | ||
redSource.innerHTML = `<i class="material-icons">back_hand</i>`; | ||
|
||
const I = Iterator<Action2024>; | ||
|
||
app.addAppObject( | ||
[0.16976556184316896, 0.021018593371059015], | ||
new I('Blue Amp', 'Placing any note into the blue amp', 'amp', 0), | ||
blueAmp, | ||
(i) => i.toString(), | ||
'blue', | ||
); | ||
|
||
app.addAppObject( | ||
[0.8274050121261115, 0.018593371059013743], | ||
new I('Red Amp', 'Placing any note into the red amp', 'amp'), | ||
redAmp, | ||
(i) => i.toString(), | ||
'red', | ||
); | ||
|
||
app.addAppObject( | ||
[0.06345998383185125, 0.33063864187550523], | ||
new I('Blue Speaker', 'Shot a note into the blue speaker', 'spk'), | ||
blueSpeaker, | ||
(i) => i.toString(), | ||
'blue', | ||
); | ||
|
||
app.addAppObject( | ||
[0.9365400161681487, 0.32740501212611156], | ||
new I('Red Speaker', 'Shot a note into the red speaker', 'spk'), | ||
redSpeaker, | ||
(i) => i.toString(), | ||
'red', | ||
); | ||
|
||
app.addAppObject( | ||
[0.8823767178658044, 0.9062247372675829], | ||
new I( | ||
'Blue Source', | ||
'Robot retrieves a note from the blue source', | ||
'src', | ||
), | ||
blueSource, | ||
(i) => i.toString(), | ||
'blue', | ||
); | ||
|
||
app.addAppObject( | ||
[0.11156022635408246, 0.9086499595796281], | ||
new I( | ||
'Red Source', | ||
'Robot retrieves a note from the red source', | ||
'src', | ||
), | ||
redSource, | ||
(i) => i.toString(), | ||
'red', | ||
); | ||
|
||
const drawButton = (z: Zones2024) => (app: App): boolean => { | ||
const { currentLocation } = app; | ||
if (!currentLocation) return false; | ||
const zone = app.areas[z]; | ||
if (!zone) { | ||
console.warn('Zone not found'); | ||
return false; | ||
} | ||
return zone.area.isIn(currentLocation); | ||
}; | ||
|
||
app.buttonCircle | ||
.addButton( | ||
'Blue Climb', | ||
'Click when the robot has successfully pulled themselves up for the last time in the match', | ||
'clb', | ||
0, | ||
drawButton('blue-stage'), | ||
colors.blue, | ||
'blue', | ||
icons.clb | ||
) | ||
.addButton( | ||
'Blue Trap', | ||
'When the robot has successfully placed an item in the trap', | ||
'trp', | ||
0, | ||
drawButton('blue-stage'), | ||
colors.blue, | ||
'blue', | ||
icons.trp | ||
) | ||
.addButton( | ||
'Red Climb', | ||
'Click when the robot has successfully pulled themselves up for the last time in the match', | ||
'clb', | ||
0, | ||
drawButton('red-stage'), | ||
colors.red, | ||
'red', | ||
icons.clb | ||
) | ||
.addButton( | ||
'Red Trap', | ||
'When the robot has successfully placed an item in the trap', | ||
'trp', | ||
0, | ||
drawButton('red-stage'), | ||
colors.red, | ||
'red', | ||
icons.trp | ||
); | ||
|
||
const em = app.clickPoints(); | ||
em.on('point', console.log); | ||
|
||
Object.assign(window, { app }); | ||
|
||
return app; | ||
}; | ||
|
||
export const update2024 = (tick: Tick) => { | ||
const { app, section } = tick; | ||
const { currentLocation } = app; | ||
|
||
if (!currentLocation) return; | ||
|
||
if (section === 'auto') { | ||
const { area: redAuto } = app.areas['red-auto']; | ||
const { area: blueAuto } = app.areas['blue-auto']; | ||
|
||
// if the robot is not in the auto zone during auto, then they crossed the auto line | ||
if (!redAuto.isIn(currentLocation) && !blueAuto.isIn(currentLocation)) { | ||
app.parsed.mobility = true; | ||
} | ||
} | ||
}; |
Oops, something went wrong.