Skip to content

Commit 39995fc

Browse files
committed
Hope and Pray
1 parent db65d76 commit 39995fc

File tree

7 files changed

+130
-24
lines changed

7 files changed

+130
-24
lines changed

source/archipelago/APGameState.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,9 @@ class APGameState
11641164
}
11651165

11661166
function sendMessageSimple(text:Dynamic)
1167+
{
11671168
archipelago.console.MainTab.addMessage(text);
1169+
}
11681170

11691171
public function disconnectAP()
11701172
{

source/archipelago/APItem.hx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ class APItem {
143143

144144
public static var unoColorsUnlocked:Array<{name:String, color:String}> = [];
145145

146+
public static var unknownSongs:Bool = false; // If true, songs are unknown.
147+
146148
private var toSync:Bool = true;
147149
public var triggered:Bool = false;
148150

@@ -1352,6 +1354,37 @@ class APItem {
13521354
t.isTrap = true;
13531355
});
13541356

1357+
case "Ultimate Confusion Trap":
1358+
return new APTrap(name, ConditionHelper.Everywhere(), function() {
1359+
unknownSongs = true;
1360+
popup('Huh? Where am I?', "Ultimate Confusion Trap");
1361+
1362+
// Set a timer to revert after 5 minutes (300000 milliseconds)
1363+
haxe.Timer.delay(function() {
1364+
unknownSongs = false;
1365+
popup('The confusion has worn off!', "Clarity Restored");
1366+
1367+
// Reload freeplay to refresh the display
1368+
if (APEntryState.inArchipelagoMode) {
1369+
if (states.freeplay.FreeplayState.instance != null)
1370+
states.freeplay.FreeplayState.instance.reloadSongs(true);
1371+
if (states.freeplay.OsuFreeplayState.instance != null)
1372+
@:privateAccess states.freeplay.OsuFreeplayState.instance.loadSongArray(false);
1373+
}
1374+
}, 300000); // 5 minutes = 300000 milliseconds
1375+
1376+
// Reload freeplay immediately to show the confusion
1377+
if (APEntryState.inArchipelagoMode) {
1378+
if (states.freeplay.FreeplayState.instance != null)
1379+
states.freeplay.FreeplayState.instance.reloadSongs(true);
1380+
if (states.freeplay.OsuFreeplayState.instance != null)
1381+
@:privateAccess states.freeplay.OsuFreeplayState.instance.loadSongArray(false);
1382+
}
1383+
}, true, false).funcAndReturn(function(t:APItem) {
1384+
// Set it as a trap.
1385+
t.isTrap = true;
1386+
});
1387+
13551388
default:
13561389
throw "Unknown item name: " + name;
13571390
}

source/archipelago/ArchPopup.hx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,15 @@ class ArchPopup extends openfl.display.Sprite {
192192
{
193193
var songName = daSong.song;
194194
var modName = daSong.mod;
195-
var title = (modName != null && modName != "")
196-
? '$songName (from $modName)'
197-
: songName;
198-
var newPop:ArchPopup = new ArchPopup('New Song!', title, songName, image, endFunc);
195+
196+
// Hide song name if unknownSongs is true
197+
var displaySongName = archipelago.APItem.unknownSongs ? "Unknown Song" : songName;
198+
var displayModName = archipelago.APItem.unknownSongs ? "" : modName;
199+
200+
var title = (displayModName != null && displayModName != "")
201+
? '$displaySongName (from $displayModName)'
202+
: displaySongName;
203+
var newPop:ArchPopup = new ArchPopup('New Song!', title, displaySongName, image, endFunc);
199204
_popups.push(newPop);
200205

201206
var time:Int = openfl.Lib.getTimer();

source/managers/APFreeplayManager.hx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,16 @@ class APFreeplayManager extends FreeplayManager {
346346
APEntryState.apGame.info().poll();
347347
}
348348

349+
var songsHidden:Bool = archipelago.APItem.unknownSongs;
349350
override public function reloadFreeplay(refresh:Bool = false, searchText:String = '')
350351
{
351352
trace("Reloading Songs!");
352353
songs = [];
354+
songsHidden = archipelago.APItem.unknownSongs;
355+
356+
// Check all current allowed songs and make sure there's no duplicates.
357+
if (curUnlocked != null)
358+
curUnlocked = curUnlocked.arrayRemoveDuplicates();
353359

354360
for (i in 0...WeekData.weeksList.length) {
355361
if(weekIsLocked(WeekData.weeksList[i]) && !APEntryState.inArchipelagoMode) continue;

source/states/freeplay/FreeplayState.hx

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,14 @@ class FreeplayState extends MusicBeatState
283283

284284
// if(curSelected >= songs.length) curSelected = -1;
285285
try {
286-
bg.color = fpManager.songList[curSelected].color[1][0];
287-
intendedColor = bg.color;
286+
// Use default color if songs are hidden to avoid identifying the song
287+
if (APEntryState.inArchipelagoMode && archipelago.APItem.unknownSongs) {
288+
bg.color = FlxColor.fromString('#FD719B'); // Default pink color
289+
intendedColor = bg.color;
290+
} else {
291+
bg.color = fpManager.songList[curSelected].color[1][0];
292+
intendedColor = bg.color;
293+
}
288294
}
289295
catch(e)
290296
{
@@ -435,13 +441,14 @@ class FreeplayState extends MusicBeatState
435441
if (APEntryState.inArchipelagoMode) {
436442
var isBronze:Bool = FlxG.random.bool(50); // Randomly decide between orange and bronze
437443
var bronzeOrOrangeColor:Int = isBronze ? 0xFFCD7F32 : 0xFFFFA500; // Bronze or Orange color
444+
var displayName = archipelago.APItem.unknownSongs ? "Unknown" : songName;
438445
songText = APFreeplayManager.isVictorySong(songName, modName) ?
439446
(isMissing ?
440447
(someLocationsNotMissing ?
441-
new DynamicColoredAlphabet(90, 320, songName, true, bronzeOrOrangeColor, true)
442-
: new VictorySong(90, 320, songName, color, true))
443-
: new DynamicColoredAlphabet(90, 320, songName, true, 0xFFFFD700, true))
444-
: new DynamicColoredAlphabet(90, 320, songName, true, color, true);
448+
new DynamicColoredAlphabet(90, 320, displayName, true, bronzeOrOrangeColor, true)
449+
: new VictorySong(90, 320, displayName, color, true))
450+
: new DynamicColoredAlphabet(90, 320, displayName, true, 0xFFFFD700, true))
451+
: new DynamicColoredAlphabet(90, 320, displayName, true, color, true);
445452
} else {
446453
songText = new DynamicAlphabet(90, 320, fpManager.songList[i].songName, true, true);
447454
}
@@ -466,7 +473,8 @@ class FreeplayState extends MusicBeatState
466473
songText.visible = songText.active = songText.isMenuItem = false;
467474

468475
var isLock:Bool = APEntryState.inArchipelagoMode && CategoryState.loadWeekForce == "all" && isMissing && !APFreeplayManager.unplayedList.contains(songName);
469-
var icon:HealthIcon = new HealthIcon(isLock ? "lock" : fpManager.songList[i].songCharacter);
476+
var iconName = isLock ? "lock" : (archipelago.APItem.unknownSongs ? "face" : fpManager.songList[i].songCharacter);
477+
var icon:HealthIcon = new HealthIcon(iconName);
470478
icon.sprTracker = songText;
471479
icon.visible = icon.active = false;
472480
iconArray.push(icon);
@@ -1167,7 +1175,10 @@ class FreeplayState extends MusicBeatState
11671175
if (curSelected >= fpManager.songList.length)
11681176
curSelected = -1;
11691177

1170-
var newColor:Int = curSelected != -1 ? fpManager.songList[curSelected].color[1][0] : FlxColor.fromString('#FD719B');
1178+
var newColor:Int = FlxColor.fromString('#FD719B'); // Default color
1179+
if (!APEntryState.inArchipelagoMode || !archipelago.APItem.unknownSongs) {
1180+
newColor = curSelected != -1 ? fpManager.songList[curSelected].color[1][0] : FlxColor.fromString('#FD719B');
1181+
}
11711182
if(newColor != intendedColor) {
11721183
if(colorTween != null) {
11731184
colorTween.cancel();
@@ -1294,7 +1305,8 @@ class FreeplayState extends MusicBeatState
12941305
}
12951306

12961307
if (metadata != null && metadata.freeplay != null) {
1297-
if (metadata.freeplay.bg != null && metadata.freeplay.bg != '') {
1308+
// Always use default background if songs are hidden
1309+
if (!archipelago.APItem.unknownSongs && metadata.freeplay.bg != null && metadata.freeplay.bg != '') {
12981310
bg.loadGraphic(Paths.image(metadata.freeplay.bg));
12991311
bg.screenCenter();
13001312
} else {
@@ -1303,7 +1315,8 @@ class FreeplayState extends MusicBeatState
13031315
}
13041316

13051317
if (albumPhoto != null) {
1306-
if (metadata.freeplay.album != null && metadata.freeplay.album != '') {
1318+
// Always use default album if songs are hidden
1319+
if (!archipelago.APItem.unknownSongs && metadata.freeplay.album != null && metadata.freeplay.album != '') {
13071320
albumPhoto.loadGraphic(Paths.image('albums/${Std.string(metadata.freeplay.album)}'));
13081321
albumPhoto.setGraphicSize(Std.int(albumPhoto.width * 1.6));
13091322
albumPhoto.screenCenter(Y);

source/states/freeplay/OsuFreeplayState.hx

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,8 @@ class OsuFreeplayState extends MusicBeatState
723723
this.songBox.add(songBox);
724724

725725
var isLock:Bool = APEntryState.inArchipelagoMode && CategoryState.loadWeekForce == "all" && isMissing && !APFreeplayManager.unplayedList.contains(songName);
726-
var icon:HealthIcon = new HealthIcon(isLock ? "lock" : fpManager.songList[i].songCharacter, false);
726+
var iconName = isLock ? "lock" : (APEntryState.inArchipelagoMode && archipelago.APItem.unknownSongs ? "face" : fpManager.songList[i].songCharacter);
727+
var icon:HealthIcon = new HealthIcon(iconName, false);
727728
icon.setPosition(320, 100);
728729
icon.ID = i;
729730
icon.setGraphicSize(Std.int(icon.width / 1.7), Std.int(icon.height / 1.7));
@@ -733,10 +734,15 @@ class OsuFreeplayState extends MusicBeatState
733734
catch(e) {metadata = null;}
734735

735736
var text:FlxText = new FlxText(0, 0, 500, '', 20);
736-
if (metadata != null)
737-
text.text = fpManager.songList[i].songName + '\nBy ${metadata.song.artist}';
738-
else
739-
text.text = fpManager.songList[i].songName + '\nBy Unknown';
737+
var displayName = (APEntryState.inArchipelagoMode && archipelago.APItem.unknownSongs) ? "Unknown" : fpManager.songList[i].songName;
738+
var displayArtist = "Unknown";
739+
740+
// Only show real artist if songs are not hidden
741+
if (!archipelago.APItem.unknownSongs && metadata != null) {
742+
displayArtist = metadata.song.artist;
743+
}
744+
745+
text.text = displayName + '\nBy ${displayArtist}';
740746
text.alignment = 'left';
741747
text.ID = i;
742748
textGrp.add(text);
@@ -809,10 +815,15 @@ class OsuFreeplayState extends MusicBeatState
809815
catch(e) {metadata = null;}
810816

811817
var text:FlxText = new FlxText(0, 0, 500, '', 20);
812-
if (metadata != null)
813-
text.text = fpManager.songList[i].songName + '\nBy ${metadata.song.artist}';
814-
else
815-
text.text = fpManager.songList[i].songName + '\nBy Unknown';
818+
var displayName = (APEntryState.inArchipelagoMode && archipelago.APItem.unknownSongs) ? "Unknown" : fpManager.songList[i].songName;
819+
var displayArtist = "Unknown";
820+
821+
// Only show real artist if songs are not hidden
822+
if (!archipelago.APItem.unknownSongs && metadata != null) {
823+
displayArtist = metadata.song.artist;
824+
}
825+
826+
text.text = displayName + '\nBy ${displayArtist}';
816827
text.alignment = 'left';
817828
text.ID = i + trueInt;
818829
textGrp.add(text);
@@ -843,7 +854,8 @@ class OsuFreeplayState extends MusicBeatState
843854
catch(e) {metadata = null;}
844855

845856
var text:FlxText = new FlxText(0, 0, 500, '', 20);
846-
text.text = fpManager.songList[i].songName + '\n' + Difficulty.list[j];
857+
var displayName = (APEntryState.inArchipelagoMode && archipelago.APItem.unknownSongs) ? "Unknown" : fpManager.songList[i].songName;
858+
text.text = displayName + '\n' + Difficulty.list[j];
847859
text.alignment = 'left';
848860
text.ID = trueInt;
849861
this.textGrp.add(text);

source/yutautil/CollectionUtils.hx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,41 @@ class CollectionUtils
728728
return false;
729729
}
730730

731+
public static function arrayContainsHowMany<T>(arr:Array<T>, obj:T):Int
732+
{
733+
var count = 0;
734+
for (item in arr)
735+
{
736+
if (compareObjects(item, obj)) count++;
737+
}
738+
return count;
739+
}
740+
741+
public static function arrayContainsDuplicates<T>(arr:Array<T>):Bool
742+
{
743+
// Compare each item with every other item.
744+
for (i in 0...arr.length)
745+
{
746+
for (j in 0...arr.length)
747+
{
748+
if (i != j && compareObjects(arr[i], arr[j])) return true;
749+
}
750+
}
751+
return false;
752+
}
753+
754+
public static function arrayRemoveDuplicates<T>(arr:Array<T>):Array<T>
755+
{
756+
var result = new Array<T>();
757+
for (item in arr)
758+
{
759+
if (!arrayContainsObject(result, item))
760+
{
761+
result.push(item);
762+
}
763+
}
764+
return result;
765+
}
731766

732767
public static inline function truthy(input:Dynamic):Bool
733768
{

0 commit comments

Comments
 (0)