blob: 21bdac4956f5c46acded1dbb66ab2f1cbf2c07d6 [file] [log] [blame]
Philipp Schrader80587432022-03-05 15:41:22 -08001import { Component, OnInit } from '@angular/core';
2
3type Section = 'Auto'|'TeleOp'|'Climb'|'Defense'|'Review and Submit'|'Home'
4type Level = 'Low'|'Medium'|'High'|'Transversal'
5
6@Component({
7 selector: 'app-entry',
8 templateUrl: './entry.ng.html',
9 styleUrls: ['./entry.component.css']
10})
11export class EntryComponent {
12 section: Section = 'Auto'; //placeholder
13 autoUpperShotsMade: number = 0;
14 autoLowerShotsMade: number = 0;
15 autoShotsMissed: number = 0;
16 teleUpperShotsMade: number = 0;
17 teleLowerShotsMade: number = 0;
18 teleShotsMissed: number = 0;
19 defensePlayedOnScore: number = 50;
20 defensePlayedScore: number = 50;
21 level: Level;
22 proper: boolean = false;
23 climbed: boolean = false;
24
25 toggleProper() {
26 this.proper = !this.proper;
27 }
28
29 setLow() {
30 this.level = 'Low';
31 }
32
33 setMedium() {
34 this.level = 'Medium';
35 }
36
37 setHigh() {
38 this.level = 'High';
39 }
40
41 setTransversal() {
42 this.level = 'Transversal';
43 }
44
45 defensePlayedOnSlider(event) {
46 this.defensePlayedOnScore = event.target.value;
47 }
48
49 defensePlayedSlider(event) {
50 this.defensePlayedScore = event.target.value;
51 }
52
53 setClimbedTrue() {
54 this.climbed = true;
55 }
56
57 setClimbedFalse() {
58 this.climbed = false;
59 }
60
61 nextSection() {
62 if (this.section === 'Auto') {
63 this.section = 'TeleOp';
64 } else if (this.section === 'TeleOp') {
65 this.section = 'Climb';
66 } else if (this.section === 'Climb') {
67 this.section = 'Defense';
68 } else if (this.section === 'Defense') {
69 this.section = 'Review and Submit';
70 } else if (this.section === 'Review and Submit') {
71 this.section = 'Home';
72 }
73 }
74
75 adjustAutoUpper(by: number) {
76 this.autoUpperShotsMade = Math.max(0, this.autoUpperShotsMade + by);
77 }
78
79 adjustAutoLower(by: number) {
80 this.autoLowerShotsMade = Math.max(0, this.autoLowerShotsMade + by);
81 }
82
83 adjustAutoMissed(by: number) {
84 this.autoShotsMissed = Math.max(0, this.autoShotsMissed + by);
85 }
86
87 adjustTeleUpper(by: number) {
88 this.teleUpperShotsMade = Math.max(0, this.teleUpperShotsMade + by);
89 }
90
91 adjustTeleLower(by: number) {
92 this.teleLowerShotsMade = Math.max(0, this.teleLowerShotsMade + by);
93 }
94
95 adjustTeleMissed(by: number) {
96 this.teleShotsMissed = Math.max(0, this.teleShotsMissed + by);
97 }
98}