Skip to content

Commit

Permalink
Freeplay song locks (NOT TESTED)
Browse files Browse the repository at this point in the history
  • Loading branch information
poec987 committed Jun 20, 2024
1 parent 379ff47 commit 7a0aa15
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 13 deletions.
35 changes: 30 additions & 5 deletions source/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,26 @@ class FreeplayState extends MusicBeatState
super.create();
}

public function addSong(songName:String, weekNum:Int, songCharacter:String)
public function addSong(songName:String, weekNum:Int, songCharacter:String, ?isLocked:Bool=false)
{
songs.push(new SongMetadata(songName, weekNum, songCharacter));
if (isLocked) {
if (FlxG.save.data.beatSongs.contains(songName))
songs.push(new SongMetadata(songName, weekNum, songCharacter));
else
songs.push(new SongMetadata("LOCKED", 1, "monster"));
} else {
songs.push(new SongMetadata(songName, weekNum, songCharacter));
}
}

public function newSong(songName:String, weekNum:Int, songCharacter:String):SongMetadata {

public function newSong(songName:String, weekNum:Int, songCharacter:String, ?isLocked:Bool=false):SongMetadata {
if (isLocked) {
if (FlxG.save.data.beatSongs.contains(songName))
return new SongMetadata(songName, weekNum, songCharacter);
else
return new SongMetadata("LOCKED", 1, "monster");
}
return new SongMetadata(songName, weekNum, songCharacter);
}

Expand All @@ -147,15 +161,15 @@ class FreeplayState extends MusicBeatState
}
}

public function addWeek(songs:Array<String>, weekNum:Int, ?songCharacters:Array<String>)
public function addWeek(songs:Array<String>, weekNum:Int, ?songCharacters:Array<String>, ?isLocked:Bool=false)
{
if (songCharacters == null)
songCharacters = ['bf'];

var num:Int = 0;
for (song in songs)
{
addSong(song, weekNum, songCharacters[num]);
addSong(song, weekNum, songCharacters[num], isLocked);

if (songCharacters.length != 1)
num++;
Expand All @@ -164,6 +178,17 @@ class FreeplayState extends MusicBeatState

// I WANT TO FUCKING SHOOT MYSELF

public static function playSong(song:String, diff:Int, ?storyWeek:Int=1) {
var poop:String = Highscore.formatSong(song, diff); // Funny
PlayState.SONG = Song.loadFromJson(poop, song);
PlayState.isStoryMode = false;
PlayState.storyDifficulty = diff;

PlayState.storyWeek = storyWeek;
trace('CUR WEEK' + PlayState.storyWeek);
LoadingState.loadAndSwitchState(new PlayState());
}

public function refreshSongList(skipDestroy:Bool=false) {
if (!skipDestroy) {
for (i in 0...grpSongs.length) {
Expand Down
12 changes: 4 additions & 8 deletions source/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class MainMenuState extends MusicBeatState
FlxG.sound.playMusic(Paths.music('freakyMenu'));
}

if (FlxG.save.data.beatSongs == null) // shhhhhhh
FlxG.save.data.beatSongs = [];

persistentUpdate = persistentDraw = true;

#if desktop
Expand Down Expand Up @@ -146,14 +149,7 @@ class MainMenuState extends MusicBeatState
{
if (optionShit[curSelected] == 'donate')
{
var poop:String = Highscore.formatSong("do-you-get-the-refrance", 1); // Funny
PlayState.SONG = Song.loadFromJson(poop, "do-you-get-the-refrance");
PlayState.isStoryMode = false;
PlayState.storyDifficulty = 1;

PlayState.storyWeek = 1;
trace('CUR WEEK' + PlayState.storyWeek);
LoadingState.loadAndSwitchState(new PlayState());
FreeplayState.playSong("do-you-get-the-refrance", 1);
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,8 @@ class PlayState extends MusicBeatState
persistentUpdate = false;
persistentDraw = true;

FlxG.save.data.beatSongs.append(curSong.toLowerCase());

openSubState(new ResultsSubState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y, results, this));
}

Expand Down

0 comments on commit 7a0aa15

Please sign in to comment.