Skip to content

Persists achievements when we start the game/get a new one#342

Open
Nathan84625 wants to merge 8 commits intojvondermarck:mainfrom
Nathan84625:Persists-achievements-when-we-start-the-game/get-a-new-one
Open

Persists achievements when we start the game/get a new one#342
Nathan84625 wants to merge 8 commits intojvondermarck:mainfrom
Nathan84625:Persists-achievements-when-we-start-the-game/get-a-new-one

Conversation

@Nathan84625
Copy link
Contributor

✅ PR Checklist

Tip

Please check the boxes below to confirm you followed the contribution guidelines:

  • [ X] My PR title follows the format: type(scope): description (#issue) (scope and #issue optional)
  • [ X] I used the correct type: feat, fix, refactor, docs, test, chore
  • [X ] I reviewed my code and removed unnecessary debug logs or comments.
  • [X ] I tested my changes and verified they work as expected.
  • [X ] I ran the project to confirm it compiles and runs correctly.
  • [X ] I read the Code of Conduct and the Contribution Guidelines.

📝 What does this PR do?

-Achievement now persist. Exemple, if you get the achievement kill one dinausaure, you won't obtain it again if you restart the game.
-Achievement keep their progression in memory. Exemple if in your first game you kill 10 dino, you will obtaine the achievement for killing 20 dino after 10 kill on your seconde run.

🔗 Related Issue

Link to the issue this PR addresses (if any)

  • [ X] This PR fixes/closes: #<308>

📸 Screenshots / Demos (if applicable)

Note

🦖 No screenshots or demo provided.

💬 Extra Notes (Optional)

Currently, if we had a new achievement to the list, we need to delete the achievement file manually than launch the game to have the new achievement. Should we implemente a check to see if there is a new achievement add ? Also, the achievement file is a .ser, beacause it's more difficult for player to access it, altought if we would really want player to not being able we should crypt the achievement file. I did not do the crypting, because it would affect the performance a bit and I don't think it's worth it to slow down the application to prevent some player to cheat.

Note

🦕 No extra notes.

❤️ Thanks again for your contribution to Dinosaur Exploder!
Your efforts help make this project awesome for everyone. 🦖✨

@vercel
Copy link

vercel bot commented Feb 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
dinosaur-exploder Ignored Ignored Preview Feb 12, 2026 7:14pm

package com.dinosaur.dinosaurexploder.achievements;

import com.almasb.fxgl.dsl.FXGL;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💄Spotless - Format] reported by reviewdog 🐶

Suggested change

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

🎨 Code Formatting Issues

badge

4 Java file(s) need formatting.

💡 Quick fix

Click the suggestions below:

  1. Go to "Files changed" tab
  2. Click ✅ Commit suggestion on each [💄 Spotless] comment

Or run locally:

mvn spotless:apply
git add -A && git commit -m "style: apply Spotless" && git push
📚 More options

Auto-format in your IDE:

Style guide: Google Java Style Guide


🤖 The DinoBot Team 🦖

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

Build preview 🚀

badge

Thanks for your contribution to this open-source project! ❤️

A new build has been generated for this pull request:

  • 🎮 Game Artifacts: 🐧 Linux / 🍎 macOS / 🪟 Windows
  • 🧪 Workflow Run: View Logs
  • 🔖 Commit: 2a86198898c10e7149b95912f709fb6101d1b6d6

Tip

This JAR lets you test the latest version of the game from this PR.

Note: Artifacts auto-expire after ~90 days.

Happy testing & enjoy the game! 🎮

The DinoBot Team 🦖

Nathan84625 and others added 3 commits February 12, 2026 14:03
…vement.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

💄Spotless - Format

[💄Spotless - Format] reported by reviewdog 🐶

@Test
void achievementSaveInFile() {
List<Achievement> listToCheck;


[💄Spotless - Format] reported by reviewdog 🐶

achievementManager.getActiveAchievement().completed = true;
achievementManager.saveAchievement(achievementManager.getActiveAchievements());
listToCheck = achievementManager.loadAchievement();
assert listToCheck.getFirst().isCompleted();
}


[💄Spotless - Format] reported by reviewdog 🐶


[💄Spotless - Format] reported by reviewdog 🐶

achievementManager.saveAchievement(currentAchievement);
}


public abstract class Achievement {
import com.almasb.fxgl.dsl.FXGL;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💄Spotless - Format] reported by reviewdog 🐶

Suggested change

Comment on lines +9 to +10
protected boolean completed = false;
protected int rewardCoins;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💄Spotless - Format] reported by reviewdog 🐶

Suggested change
protected boolean completed = false;
protected int rewardCoins;
protected boolean completed = false;
protected int rewardCoins;

Comment on lines +12 to +14
public boolean isCompleted() {
return completed;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💄Spotless - Format] reported by reviewdog 🐶

Suggested change
public boolean isCompleted() {
return completed;
}
public boolean isCompleted() {
return completed;
}

Comment on lines +16 to +18
public void onComplete(String description) {
FXGL.getNotificationService().pushNotification("Achievement unlocked: " + description);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💄Spotless - Format] reported by reviewdog 🐶

Suggested change
public void onComplete(String description) {
FXGL.getNotificationService().pushNotification("Achievement unlocked: " + description);
}
public void onComplete(String description) {
FXGL.getNotificationService().pushNotification("Achievement unlocked: " + description);
}

Comment on lines +20 to +22
public int getRewardCoins() {
return rewardCoins;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💄Spotless - Format] reported by reviewdog 🐶

Suggested change
public int getRewardCoins() {
return rewardCoins;
}
public int getRewardCoins() {
return rewardCoins;
}

Comment on lines +4 to +7
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💄Spotless - Format] reported by reviewdog 🐶

Suggested change
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💄Spotless - Format] reported by reviewdog 🐶

Suggested change
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Comment on lines +15 to +20
private LevelManager levelManager;
private List<Achievement> currentAchievement = new ArrayList<>();
AchievementManager achievementManager = new AchievementManager();

@BeforeEach
void setUp() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💄Spotless - Format] reported by reviewdog 🐶

Suggested change
private LevelManager levelManager;
private List<Achievement> currentAchievement = new ArrayList<>();
AchievementManager achievementManager = new AchievementManager();
@BeforeEach
void setUp() {
private LevelManager levelManager;
private List<Achievement> currentAchievement = new ArrayList<>();
AchievementManager achievementManager = new AchievementManager();

Comment on lines +22 to +25
List<Achievement> emptyList = new ArrayList<>();
currentAchievement = achievementManager.loadAchievement();
achievementManager.saveAchievement(emptyList);
achievementManager.init();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💄Spotless - Format] reported by reviewdog 🐶

Suggested change
List<Achievement> emptyList = new ArrayList<>();
currentAchievement = achievementManager.loadAchievement();
achievementManager.saveAchievement(emptyList);
achievementManager.init();
@BeforeEach
void setUp() {

achievementManager.saveAchievement(emptyList);
achievementManager.init();

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💄Spotless - Format] reported by reviewdog 🐶

Suggested change
}
List<Achievement> emptyList = new ArrayList<>();
currentAchievement = achievementManager.loadAchievement();
achievementManager.saveAchievement(emptyList);
achievementManager.init();
}

@sonarqubecloud
Copy link

Copy link
Owner

@jvondermarck jvondermarck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Nathan84625, thanks for your PR. Few things:


Currently, if we had a new achievement to the list, we need to delete the achievement file manually than launch the game to have the new achievement. Should we implemente a check to see if there is a new achievement add ?

  • Ah yes it is a problem if we need to delete the file manually, it would be better to have something dynamic to avoid issues. But it's weird that if we add a new achievement to the list, that we can't reuse the same file ? I didn't know, so we need to find a solution to avoid doing this, we need to find the cleanest way, as new achievements will be added in the future... Can you have a look please ?

Also, the achievement file is a .ser, beacause it's more difficult for player to access it, altought if we would really want player to not being able we should crypt the achievement file. I did not do the crypting, because it would affect the performance a bit and I don't think it's worth it to slow down the application to prevent some player to cheat.

  • Yes perfect for the .ser file! I think let's make it simple, right now, ket's just not encrypt it, it's just a game to have fun, but great idea in any case, we could implement it in the future for sure! But not needed right now, .ser is enough for this game currently :)

Thanks a lot for your PR and looking forward hearing from you again :)

@jvondermarck jvondermarck added status: in-review PR currently in review status: pending-request-changes Request changes from the contributor labels Feb 12, 2026
@Nathan84625
Copy link
Contributor Author

I'll do the dynamic add off an achievement and I'll push my modification in this pr. Also, sorry for the other issue, it's my first reel pr and I am still guetting use to how it work.

@jvondermarck
Copy link
Owner

I'll do the dynamic add off an achievement and I'll push my modification in this pr. Also, sorry for the other issue, it's my first reel pr and I am still guetting use to how it work.

Awesome @Nathan84625 ! And no need to say sorry, don't worry. This project has many rules so that people learn new things and it would help you in the world of work, like in a company :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: in-review PR currently in review status: pending-request-changes Request changes from the contributor title needs formatting

Projects

Development

Successfully merging this pull request may close these issues.

2 participants