Skip to content

Commit

Permalink
Merge branch 'main' of github.com:tsaxking/template-scouting-app into…
Browse files Browse the repository at this point in the history
… chore-update-scripts-to-6685247d555a9731a3958d7a0eeded11c62be41f
  • Loading branch information
tsaxking committed Feb 13, 2024
2 parents c406819 + 1e47a2a commit 6ab2623
Show file tree
Hide file tree
Showing 60 changed files with 26,206 additions and 271 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*

*.js

*/templates/entries/

*/dir-tree.txt
Expand All @@ -14,6 +16,7 @@ branch-transfer/

deno.lock

event-data.json
credentials.json
token.json

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 7 additions & 7 deletions client/declaration-merging/document-extended.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
declare function create<K extends keyof HTMLElementTagNameMap>(
tag: K,
attrs?: any
attrs?: any,
): HTMLElementTagNameMap[K];
/**
* Creates an element with the specified tag name.
Expand All @@ -23,7 +23,7 @@ declare function create<K extends keyof HTMLElementTagNameMap>(
*/
declare function create<K extends keyof HTMLElementDeprecatedTagNameMap>(
tag: string,
attrs?: any
attrs?: any,
): HTMLElementDeprecatedTagNameMap[K];
/**
* Creates an element with the specified tag name.
Expand Down Expand Up @@ -58,7 +58,7 @@ declare function create(html: string, attrs?: any): HTMLElement;
*/
declare function createDeep(
tag: string,
attrs?: any
attrs?: any,
): (
| HTMLElementDeprecatedTagNameMap[keyof HTMLElementDeprecatedTagNameMap]
| HTMLElementTagNameMap[keyof HTMLElementTagNameMap]
Expand All @@ -74,7 +74,7 @@ declare function createDeep(
* @returns {HTMLElementTagNameMap[K]}
*/
declare function find<K extends keyof HTMLElementTagNameMap>(
selector: K
selector: K,
): HTMLElementTagNameMap[K];
/**
* Using querySelector, returns the first element that matches the selector
Expand All @@ -85,7 +85,7 @@ declare function find<K extends keyof HTMLElementTagNameMap>(
* @returns {HTMLElementDeprecatedTagNameMap[K]}
*/
declare function find<K extends keyof HTMLElementDeprecatedTagNameMap>(
selector: string
selector: string,
): HTMLElementDeprecatedTagNameMap[K];
/**
* Using querySelector, returns the first element that matches the selector
Expand All @@ -105,7 +105,7 @@ declare function find(selector: string): HTMLElement;
* @returns {HTMLElementTagNameMap[K][]}
*/
declare function findAll<K extends keyof HTMLElementTagNameMap>(
selector: K
selector: K,
): HTMLElementTagNameMap[K][];

/**
Expand All @@ -117,7 +117,7 @@ declare function findAll<K extends keyof HTMLElementTagNameMap>(
* @returns {HTMLElementDeprecatedTagNameMap[K][]}
*/
declare function findAll<K extends keyof HTMLElementDeprecatedTagNameMap>(
selector: string
selector: string,
): HTMLElementDeprecatedTagNameMap[K][];

/**
Expand Down
6 changes: 3 additions & 3 deletions client/declaration-merging/pdfjslib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export interface PdfJsPage {
scale:
| number
| {
scale: number;
rotation: number;
}
scale: number;
rotation: number;
},
): PdfJsViewport;
getTextContent(): Promise<PdfJsTextContent>;
getAnnotations(): Promise<PdfJsAnnotation[]>;
Expand Down
8 changes: 0 additions & 8 deletions client/entries/account/sign-up.ts

This file was deleted.

6 changes: 0 additions & 6 deletions client/entries/admin.ts

This file was deleted.

10 changes: 10 additions & 0 deletions client/entries/app.ts
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 });
Empty file removed client/entries/main.ts
Empty file.
7 changes: 0 additions & 7 deletions client/entries/test/dashboard.ts

This file was deleted.

245 changes: 245 additions & 0 deletions client/models/app/2024-app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
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 Trap',
'When the robot has successfully placed an item in the trap',
'trp',
0,
drawButton('blue-stage'),
colors.blue,
'blue',
icons.trp,
)
.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(
'Red Trap',
'When the robot has successfully placed an item in the trap',
'trp',
0,
drawButton('red-stage'),
colors.red,
'red',
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,
);

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;
}
}
};
Loading

0 comments on commit 6ab2623

Please sign in to comment.