Skip to content

Commit ba1f121

Browse files
committed
HELP-
1 parent 9fd1814 commit ba1f121

File tree

3 files changed

+106
-3
lines changed

3 files changed

+106
-3
lines changed

source/archipelago/APGameState.hx

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

source/archipelago/APNote.hx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class APNote extends objects.Note {
1414
this.noteType = note.noteType;
1515

1616
// Copy the properties from the original note to this new note, via reflection
17-
// This is a bit of a hack, but it works for now.
1817
trace("Copying properties from original note to new note...");
1918
for (field in Reflect.fields(note)) {
2019
if (field != "ignoreNote" && field != "noteType" && field != "strumTime" && field != "noteData" && field != "prevNote" && field != "isSustainNote") {
@@ -25,13 +24,16 @@ class APNote extends objects.Note {
2524
trace("Properties copied. Destroying original note...");
2625

2726
APItem = item;
28-
2927
APItemLocation = location;
3028

29+
// Set a unique RGBShader color for APNotes
30+
this.rgbShader.r = Std.int(Std.int((0x3380CC >> 16) & 0xFF) / Std.int(0xFF));
31+
this.rgbShader.g = Std.int(Std.int((0x3380CC >> 8) & 0xFF) / Std.int(0xFF));
32+
this.rgbShader.b = Std.int(Std.int(0x3380CC & 0xFF) / Std.int(0xFF));
3133
}
3234

3335
// Replace notes with a certain amount of locations.
34-
public static function replaceNotes(notes:Array<objects.Note>, locations:Array<Int>, ?ignoreNonEmptyNoteType:Bool = false):Array<APNote> {
36+
public static function replaceNotes(notes:Array<objects.Note>, locations:Array<Int>, ?ignoreNonEmptyNoteType:Bool = true):Array<APNote> {
3537
var newNotes:Array<APNote> = [];
3638
var randomIndices:Array<Int> = [];
3739

source/archipelago/APPlayState.hx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,13 @@ class APPlayState extends PlayState {
14921492
super.stepHit();
14931493
}
14941494

1495+
private override function generateSong():Void
1496+
{
1497+
super.generateSong();
1498+
if (PlayState.SONG == null) return;
1499+
archipelago.APNote.replaceNotes(unspawnNotes, apGame.excludeCheckedLocations(apGame.noteData(PlayState.SONG.song, currentMod)));
1500+
}
1501+
14951502
// override public function generateNotes(song:SwagSong, AI:Array<Array<Float>>):Void
14961503
// super.generateNotes(song, AI);
14971504

0 commit comments

Comments
 (0)