Persists achievements when we start the game/get a new one#342
Persists achievements when we start the game/get a new one#342Nathan84625 wants to merge 8 commits intojvondermarck:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
| package com.dinosaur.dinosaurexploder.achievements; | ||
|
|
||
| import com.almasb.fxgl.dsl.FXGL; | ||
|
|
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
🎨 Code Formatting Issues4 Java file(s) need formatting. 💡 Quick fixClick the suggestions below:
Or run locally: mvn spotless:apply
git add -A && git commit -m "style: apply Spotless" && git push📚 More optionsAuto-format in your IDE:
Style guide: Google Java Style Guide 🤖 The DinoBot Team 🦖 |
Build preview 🚀Thanks for your contribution to this open-source project! ❤️ A new build has been generated for this pull request:
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 🦖 |
…vement.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
|
|
||
| public abstract class Achievement { | ||
| import com.almasb.fxgl.dsl.FXGL; | ||
|
|
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| protected boolean completed = false; | ||
| protected int rewardCoins; |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| protected boolean completed = false; | |
| protected int rewardCoins; | |
| protected boolean completed = false; | |
| protected int rewardCoins; |
| public boolean isCompleted() { | ||
| return completed; | ||
| } |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| public boolean isCompleted() { | |
| return completed; | |
| } | |
| public boolean isCompleted() { | |
| return completed; | |
| } |
| public void onComplete(String description) { | ||
| FXGL.getNotificationService().pushNotification("Achievement unlocked: " + description); | ||
| } |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| public void onComplete(String description) { | |
| FXGL.getNotificationService().pushNotification("Achievement unlocked: " + description); | |
| } | |
| public void onComplete(String description) { | |
| FXGL.getNotificationService().pushNotification("Achievement unlocked: " + description); | |
| } |
| public int getRewardCoins() { | ||
| return rewardCoins; | ||
| } |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| public int getRewardCoins() { | |
| return rewardCoins; | |
| } | |
| public int getRewardCoins() { | |
| return rewardCoins; | |
| } |
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| 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; | ||
|
|
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| import org.junit.jupiter.api.AfterEach; | |
| import org.junit.jupiter.api.BeforeEach; | |
| import org.junit.jupiter.api.Test; |
| private LevelManager levelManager; | ||
| private List<Achievement> currentAchievement = new ArrayList<>(); | ||
| AchievementManager achievementManager = new AchievementManager(); | ||
|
|
||
| @BeforeEach | ||
| void setUp() { |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| 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(); |
| List<Achievement> emptyList = new ArrayList<>(); | ||
| currentAchievement = achievementManager.loadAchievement(); | ||
| achievementManager.saveAchievement(emptyList); | ||
| achievementManager.init(); |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| List<Achievement> emptyList = new ArrayList<>(); | |
| currentAchievement = achievementManager.loadAchievement(); | |
| achievementManager.saveAchievement(emptyList); | |
| achievementManager.init(); | |
| @BeforeEach | |
| void setUp() { |
| achievementManager.saveAchievement(emptyList); | ||
| achievementManager.init(); | ||
|
|
||
| } |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| } | |
| List<Achievement> emptyList = new ArrayList<>(); | |
| currentAchievement = achievementManager.loadAchievement(); | |
| achievementManager.saveAchievement(emptyList); | |
| achievementManager.init(); | |
| } |
|
There was a problem hiding this comment.
Hey @Nathan84625, thanks for your PR. Few things:
- Can you run the command
mvn spotless:applyto fix formatting issues, please? - Can you check your PR title according to the PR guidelines please, it needs to have a specific formatting
- Can you check Sonar issues above, there are three issues --> https://sonarcloud.io/project/issues?id=jvondermarck_dinosaur-exploder&pullRequest=342&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true
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
.serfile! 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,.seris enough for this game currently :)
Thanks a lot for your PR and looking forward hearing from you again :)
|
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 :) |



✅ PR Checklist
Tip
Please check the boxes below to confirm you followed the contribution guidelines:
type(scope): description (#issue)(scope and #issue optional)type: feat, fix, refactor, docs, test, chore📝 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
📸 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. 🦖✨