@@ -146,6 +146,100 @@ class APGameState {
146146 return matchingLocations ;
147147 }
148148
149+ public function noteData (songName : String , modName : String ): Array <Int > {
150+ trace (" Starting noteData function with songName: " + songName + " and modName: " + modName );
151+ var matchingNotes : Array <Int > = [];
152+ var reg = new EReg (" ^Note \\ d+: " + EReg .escape (songName ) + " $" , " " );
153+ var apInfo = info ();
154+
155+ trace (" Looking for locations matching pattern: " + " Note #: " + songName );
156+
157+ // Initial matching using the regular expression
158+ trace (" Iterating through APLocations..." );
159+ for (location in APLocations ) {
160+ var locationName = apInfo .get_location_name (location );
161+ if (reg .match (locationName )) {
162+ matchingNotes .push (location );
163+ }
164+ }
165+
166+ // Fallback logic if no matches are found
167+ if (matchingNotes .length == 0 ) {
168+ trace (" No matches found. Attempting fallback logic..." );
169+ for (song in WeekData .getCurrentWeek ().songs ) {
170+ trace (" Checking song in current week: " + song [0 ]);
171+ if ((cast song [0 ] : String ).toLowerCase ().trim () == songName .toLowerCase ().trim () ||
172+ (cast song [0 ] : String ).toLowerCase ().trim ().replace (" " , " -" ) == songName .toLowerCase ().trim ().replace (" " , " -" )) {
173+ var fallbackReg = new EReg (" ^Note \\ d+: " + EReg .escape (song [0 ]) + " $" , " " );
174+ for (location in APLocations ) {
175+ var locationName = apInfo .get_location_name (location );
176+ if (fallbackReg .match (locationName )) {
177+ trace (" Fallback match found: " + locationName );
178+ matchingNotes .push (location );
179+ }
180+ }
181+ break ;
182+ }
183+ }
184+ }
185+
186+ // Secondary fallback logic using JSON data
187+ if (matchingNotes .length == 0 ) {
188+ trace (" No matches found in fallback logic. Attempting secondary fallback..." );
189+ for (song in WeekData .getCurrentWeek ().songs ) {
190+ trace (" Checking song in secondary fallback logic: " + song [0 ]);
191+ var songPath = modName .trim () != " "
192+ ? " mods/" + modName + " /data/" + song [0 ] + " /" + song [0 ] + " -" + Difficulty .getString (PlayState .storyDifficulty ) + " .json"
193+ : " assets/shared" + (song [0 ] + Difficulty .getFilePath ());
194+ trace (" Constructed songPath: " + songPath );
195+
196+ var songJson : backend. Song . SwagSong = null ;
197+ var jsonStuff : Array <String > = Paths .crawlDirectoryOG (" mods/" + modName + " /data" , " .json" );
198+ trace (" Retrieved JSON files: " + jsonStuff );
199+
200+ for (json in jsonStuff ) {
201+ trace (" Checking JSON file: " + json );
202+ if (json .trim ().toLowerCase ().replace (" " , " -" ) == songPath .trim ().toLowerCase ().replace (" " , " -" )) {
203+ trace (" Match found for JSON file: " + json );
204+ songJson = backend. Song .parseJSON (File .getContent (json ));
205+ if (songJson != null ) {
206+ trace (" Parsed song JSON successfully. Checking song name..." );
207+ if (songJson .song .trim ().toLowerCase ().replace (" " , " -" ) == songName .toLowerCase ().trim ().replace (" " , " -" )) {
208+ trace (" Match found for song in JSON: " + songJson .song );
209+ var fallbackReg = new EReg (" ^Note \\ d+: " + EReg .escape (song [0 ]) + " $" , " " );
210+ for (location in APLocations ) {
211+ var locationName = apInfo .get_location_name (location );
212+ if (fallbackReg .match (locationName )) {
213+ trace (" Secondary fallback match found: " + locationName );
214+ matchingNotes .push (location );
215+ }
216+ }
217+ break ;
218+ }
219+ }
220+ }
221+ }
222+ }
223+ }
224+
225+ trace (" Finished iterating through APLocations." );
226+ trace (" Returning matching notes: " + matchingNotes );
227+ return matchingNotes ;
228+ }
229+
230+ public function excludeCheckedLocations (locations : Array <Int >): Array <Int > {
231+ var checkedLocations : Array <Int > = info ().checkedLocations ;
232+ var uncheckedLocations : Array <Int > = [];
233+
234+ for (location in locations ) {
235+ if (! checkedLocations .contains (location )) {
236+ uncheckedLocations .push (location );
237+ }
238+ }
239+
240+ return uncheckedLocations ;
241+ }
242+
149243 public static var currentPackages : DynamicAccess <GameData > = new DynamicAccess <GameData >();
150244
151245 public var itemManager (get , set ): Dynamic ;
0 commit comments