Skip to content

Commit

Permalink
made achievement resetting a bit better
Browse files Browse the repository at this point in the history
  • Loading branch information
Joalor64GH authored Oct 24, 2024
1 parent 30e1a68 commit 803cfe0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion assets/achievements/full_combo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Full Combo",
"desc": "Great job!",
"hint": "Complete a song without missing."
"hint": "Complete any song without missing."
}
44 changes: 41 additions & 3 deletions source/states/AchievementsState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class AchievementsState extends ExtendableState {
var iconArray:Array<AchievementIcon> = [];
var isUnlocked:Array<Bool> = [];
var description:FlxText;

var curSelected:Int = 0;
var camFollow:FlxObject;

Expand Down Expand Up @@ -89,7 +88,7 @@ class AchievementsState extends ExtendableState {
for (i in 0...achievementArray.length) {
var formattedName:String = StringTools.replace(achievementArray[i].name.toLowerCase(), " ", "_");
Achievements.forget(formattedName);
ExtendableState.resetState();
regenList();
}
}, () -> {
FlxG.sound.play(Paths.sound('cancel'));
Expand All @@ -99,7 +98,7 @@ class AchievementsState extends ExtendableState {
FlxG.sound.play(Paths.sound('select'));
var formattedName:String = StringTools.replace(achievementArray[curSelected].name.toLowerCase(), " ", "_");
Achievements.forget(formattedName);
ExtendableState.resetState();
regenList();
}, () -> {
FlxG.sound.play(Paths.sound('cancel'));
}));
Expand Down Expand Up @@ -134,6 +133,45 @@ class AchievementsState extends ExtendableState {
description.screenCenter(X);
}
}

function regenList() {
achievementArray = [];

achievementGrp.forEach(ach -> {
achievementGrp.remove(ach, true);
ach.destroy();
});
achievementGrp.clear(); // clear whatever is left

iconArray = [];

for (i in 0...Achievements.achievements.length) {
var coolAchieve:AchievementData = cast Json.parse(File.getContent(Paths.json('achievements/' + Achievements.achievements[i])));
achievementArray.push(coolAchieve);

var stringToUse:String = coolAchieve.name;
var unlocked:Bool = true;

if (!Achievements.achievementsMap.exists(Achievements.achievements[i])) {
stringToUse = "???";
unlocked = false;
}

isUnlocked.push(unlocked);

var text:FlxText = new FlxText(20, 60 + (i * 80), stringToUse, 32);
text.setFormat(Paths.font('vcr.ttf'), 60, FlxColor.WHITE, FlxTextAlign.LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
text.ID = i;
achievementGrp.add(text);

var icon:AchievementIcon = new AchievementIcon(0, 0, Achievements.achievements[i].trim());
icon.sprTracker = text;
iconArray.push(icon);
add(icon);
}

changeSelection(0, false);
}
}

class AchievementIcon extends GameSprite {
Expand Down
3 changes: 2 additions & 1 deletion source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@ class PlayState extends ExtendableState {
noteDataTimes[Utilities.getNoteIndex(note.dir)] = note.strum;
doNotHit[Utilities.getNoteIndex(note.dir)] = true;

strumline.members[Utilities.getNoteIndex(note.dir)].press();
if (!SaveData.settings.botPlay)
strumline.members[Utilities.getNoteIndex(note.dir)].press();

switch (curRating) {
case "perfect" | "perfect-golden":
Expand Down

0 comments on commit 803cfe0

Please sign in to comment.