@@ -4,11 +4,13 @@ import 'dart:io';
4
4
5
5
import 'package:permission_handler/permission_handler.dart' ;
6
6
import 'package:scouting_platform/utils/data/constants/AppConstants.dart' ;
7
+ import 'package:scouting_platform/utils/data/values/PrematchValues.dart' ;
7
8
import 'package:scouting_platform/utils/data/values/SettingValues.dart' ;
8
9
9
10
class Schedulehelper {
10
11
static late int argumentReadingIndex;
11
12
static late int driverStationIdentifier;
13
+ static List <String > simbotMatches = [];
12
14
13
15
static Future <String > get _scheduleDirecotyPath async {
14
16
final directory = Directory ('/storage/emulated/0/Documents' );
@@ -53,6 +55,56 @@ class Schedulehelper {
53
55
return null ;
54
56
}
55
57
58
+ static Future <int > getNumberOfLinesInSchedule () async {
59
+ final file = File (
60
+ "/storage/emulated/0/Documents/match_schedule_${SettingValues .eventID .text }.csv" );
61
+
62
+ if (await file.exists ()) {
63
+ final lines = await file.readAsLines ();
64
+ return lines.length - 1 ;
65
+ }
66
+ return 0 ;
67
+ }
68
+
69
+ static Future <List <String >> getSimbotMatches () async {
70
+ simbotMatches.clear ();
71
+ for (var i = 0 ; i < await getNumberOfLinesInSchedule (); i++ ) {
72
+ String ? matchData = await readLineFromSchedule (i);
73
+ if (matchData == null ) {
74
+ break ;
75
+ }
76
+ if (matchData.contains ("1114" )) {
77
+ simbotMatches.add (matchData);
78
+ }
79
+ }
80
+ return simbotMatches;
81
+ }
82
+
83
+ static Future <bool > isTeamInUpcomingMatches (int teamNumber) async {
84
+ if (PrematchValues .matchNumber.text.isEmpty) {
85
+ return false ;
86
+ }
87
+
88
+ List <String > simbotMatches = await getSimbotMatches ();
89
+ for (String simbotMatch in simbotMatches) {
90
+ List <String > simbotMatchData = simbotMatch.split ("," );
91
+ String matchNumber = simbotMatchData[0 ];
92
+ simbotMatchData.removeAt (0 );
93
+ int teamIndex = simbotMatchData.indexOf (teamNumber.toString ());
94
+ int simbotIndex = simbotMatchData.indexOf ("1114" );
95
+
96
+ bool teamAlliance = teamIndex < 2 && teamIndex != - 1 ;
97
+ bool simbotAlliance = simbotIndex < 2 && simbotIndex != - 1 ;
98
+
99
+ if (int .parse (matchNumber) >
100
+ int .parse (PrematchValues .matchNumber.text) + 1 &&
101
+ teamAlliance == simbotAlliance) {
102
+ return true ;
103
+ }
104
+ }
105
+ return false ;
106
+ }
107
+
56
108
static Future <int > getTeamNumberFromSchedule (int matchNumber) async {
57
109
switch (SettingValues .selectedDriverStation.text) {
58
110
case "Red 1" :
0 commit comments