@@ -4,11 +4,13 @@ import 'dart:io';
44
55import 'package:permission_handler/permission_handler.dart' ;
66import 'package:scouting_platform/utils/data/constants/AppConstants.dart' ;
7+ import 'package:scouting_platform/utils/data/values/PrematchValues.dart' ;
78import 'package:scouting_platform/utils/data/values/SettingValues.dart' ;
89
910class Schedulehelper {
1011 static late int argumentReadingIndex;
1112 static late int driverStationIdentifier;
13+ static List <String > simbotMatches = [];
1214
1315 static Future <String > get _scheduleDirecotyPath async {
1416 final directory = Directory ('/storage/emulated/0/Documents' );
@@ -53,6 +55,56 @@ class Schedulehelper {
5355 return null ;
5456 }
5557
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+
56108 static Future <int > getTeamNumberFromSchedule (int matchNumber) async {
57109 switch (SettingValues .selectedDriverStation.text) {
58110 case "Red 1" :
0 commit comments