-
Notifications
You must be signed in to change notification settings - Fork 28
WIP: Achievements #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
WIP: Achievements #118
Changes from 60 commits
1b70332
be14b87
2ade8cd
335253e
4457c90
5e7609d
412661f
53918d2
cdf7144
1b83982
9dc167d
0ecde90
988d79a
9784dc1
0038afe
2d6a94e
3ffb1b9
262e7b9
a5db590
49c4c9b
1810eb3
ced6e24
b77fa45
a37d868
bbb3030
1261791
114c55c
091963f
59f017c
6b08021
9092992
d84f2e8
d358104
ad07af2
febcf13
0b8fdc9
87acc77
8796c37
129dc18
05a7839
5beb604
f987ce4
e6786e4
e2d7e79
c24521c
ef71dc7
3dd48aa
53d246f
b7da041
e8aadc5
f1b8ecb
f846283
6cb7b45
2b0396a
a935aeb
f758e4a
bb2738a
e36a518
e67d5dc
8b6779a
31c2ceb
4f8e0fb
6d6316b
1adf032
2a2b65e
fccc18f
fcb7eb6
d1dbfa4
ef56491
50b820c
a2dec22
7b97534
e0f93e0
51f629c
7175802
2325190
0f9ed82
d923eae
1c0ab51
1f2dd8c
8db29c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package de.sesu8642.feudaltactics.events.achievements; | ||
|
|
||
| import de.sesu8642.feudaltactics.menu.achievements.model.AbstractAchievement; | ||
| import lombok.Getter; | ||
|
|
||
| /** | ||
| * Event triggered when the progress of an achievement has changed, i.e. when the player has made progress towards unlocking it. | ||
| */ | ||
| public class AchievementProgressEvent { | ||
| @Getter | ||
| private final AbstractAchievement achievement; | ||
|
|
||
| /** | ||
| * Constructor. | ||
| * | ||
| * @param achievement the achievement for which the progress has changed | ||
| */ | ||
| public AchievementProgressEvent(AbstractAchievement achievement) { | ||
| this.achievement = achievement; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package de.sesu8642.feudaltactics.events.achievements; | ||
|
|
||
| import de.sesu8642.feudaltactics.menu.achievements.model.AbstractAchievement; | ||
| import lombok.Getter; | ||
|
|
||
| /** | ||
| * Event triggered when an achievement has just been unlocked. | ||
| */ | ||
| public class AchievementUnlockedEvent { | ||
| @Getter | ||
| private final AbstractAchievement achievement; | ||
|
|
||
| /** | ||
| * Constructor. | ||
| * | ||
| * @param achievement the achievement that has been unlocked | ||
| */ | ||
| public AchievementUnlockedEvent(AbstractAchievement achievement) { | ||
| this.achievement = achievement; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -282,5 +282,4 @@ public boolean isUndoPossible() { | |
| lock.unlock(); | ||
| } | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package de.sesu8642.feudaltactics.menu.achievements; | ||
|
|
||
| /** | ||
| * Marker interface for achievements that require full storage | ||
| */ | ||
| public interface AchievementNeedsFullStorage { | ||
|
|
||
| public String serializeToJson(); | ||
|
|
||
| public void deserializeFromJson(String serializedData); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package de.sesu8642.feudaltactics.menu.achievements; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| import javax.inject.Inject; | ||
| import javax.inject.Singleton; | ||
|
|
||
| import com.google.common.eventbus.EventBus; | ||
|
|
||
| import de.sesu8642.feudaltactics.ingame.NewGamePreferences.MapSizes; | ||
| import de.sesu8642.feudaltactics.lib.ingame.botai.Intelligence; | ||
| import de.sesu8642.feudaltactics.menu.achievements.model.AbortGameAchievement; | ||
| import de.sesu8642.feudaltactics.menu.achievements.model.AbstractAchievement; | ||
| import de.sesu8642.feudaltactics.menu.achievements.model.HistoricPersonOrEvent; | ||
| import de.sesu8642.feudaltactics.menu.achievements.model.LoseAgainstWeakestAiAchievement; | ||
| import de.sesu8642.feudaltactics.menu.achievements.model.PlayMoreThanNRoundsAchievement; | ||
| import de.sesu8642.feudaltactics.menu.achievements.model.WinAgainstAiLevelAchievement; | ||
| import de.sesu8642.feudaltactics.menu.achievements.model.WinAgainstManyEnemiesAchievement; | ||
| import de.sesu8642.feudaltactics.menu.achievements.model.WinInNRoundsAchievement; | ||
| import de.sesu8642.feudaltactics.menu.achievements.model.WinNGamesAchievement; | ||
| import de.sesu8642.feudaltactics.menu.achievements.model.WinOnMapSizeAchievement; | ||
| import de.sesu8642.feudaltactics.menu.achievements.model.WinVeryHardGamesInARowAchievement; | ||
| import de.sesu8642.feudaltactics.menu.achievements.model.WinWhenStartingLastAchievement; | ||
| import lombok.Getter; | ||
|
|
||
| /** | ||
| * Provides achievement classes, knows how to construct each individual achievement | ||
| */ | ||
| @Singleton | ||
| public class AchievementProvider { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would probably call this AchievementFacory, as provider may be confused with the @provides concept of Dagger. Speaking of which, there could be a provideAchievments method in a dagger module that uses this factory and makes the list of achievements injectable. That way, the AchievementService can be simplified as it only calls this method once anyway.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds interesting. I wasn't aware of this dagger concept. |
||
| private final EventBus eventBus; | ||
|
|
||
| @Inject | ||
| public AchievementProvider( | ||
| EventBus eventBus) { | ||
| this.eventBus = eventBus; | ||
| } | ||
|
|
||
| public List<AbstractAchievement> CreateAchievements() { | ||
| List<AbstractAchievement> list = new ArrayList<>(); | ||
| list.add(new WinNGamesAchievement(eventBus, 1)); | ||
| list.add(new WinNGamesAchievement(eventBus, 10)); | ||
| list.add(new WinNGamesAchievement(eventBus, 50).setHistoricConnection(HistoricPersonOrEvent.CHARLEMAGNE)); // Charlemagne won many battles | ||
| list.add(new WinInNRoundsAchievement(eventBus, 18)); | ||
| list.add(new WinInNRoundsAchievement(eventBus, 14)); | ||
| list.add(new WinInNRoundsAchievement(eventBus, 12).setHistoricConnection(HistoricPersonOrEvent.JEANNE_DARC)); // Jeanne d'Arc won battles when she was very young | ||
| list.add(new PlayMoreThanNRoundsAchievement(eventBus, 30).setHistoricConnection(HistoricPersonOrEvent.THIRTY_YEARS_WAR)); | ||
| list.add(new PlayMoreThanNRoundsAchievement(eventBus, 50).setHistoricConnection(HistoricPersonOrEvent.HUNDRED_YEARS_WAR)); // The Hundred Years' War lasted very long obviously | ||
| list.add(new LoseAgainstWeakestAiAchievement(eventBus).setHistoricConnection(HistoricPersonOrEvent.ROAD_TO_CANOSSA)); // The Walk to Canossa was a humiliation. And so is this achievement. | ||
| list.add(new WinVeryHardGamesInARowAchievement(eventBus, 3)); | ||
| list.add(new WinVeryHardGamesInARowAchievement(eventBus, 10)); | ||
| list.add(new WinVeryHardGamesInARowAchievement(eventBus, 20).setHistoricConnection(HistoricPersonOrEvent.WILLIAM_THE_CONQUEROR)); | ||
| list.add(new WinAgainstManyEnemiesAchievement(eventBus, 3)); | ||
| list.add(new WinAgainstManyEnemiesAchievement(eventBus, 4)); | ||
| list.add(new WinAgainstManyEnemiesAchievement(eventBus, 5).setHistoricConnection(HistoricPersonOrEvent.LOUIS_XI)); | ||
| list.add(new WinOnMapSizeAchievement(eventBus, MapSizes.SMALL)); | ||
| list.add(new WinOnMapSizeAchievement(eventBus, MapSizes.MEDIUM)); | ||
| list.add(new WinOnMapSizeAchievement(eventBus, MapSizes.LARGE)); | ||
| list.add(new WinOnMapSizeAchievement(eventBus, MapSizes.XLARGE)); | ||
| list.add(new WinOnMapSizeAchievement(eventBus, MapSizes.XXLARGE).setHistoricConnection(HistoricPersonOrEvent.RICHARD_THE_LIONHEART)); | ||
| list.add(new WinAgainstAiLevelAchievement(eventBus, Intelligence.LEVEL_1)); | ||
| list.add(new WinAgainstAiLevelAchievement(eventBus, Intelligence.LEVEL_2)); | ||
| list.add(new WinAgainstAiLevelAchievement(eventBus, Intelligence.LEVEL_3)); | ||
| list.add(new WinAgainstAiLevelAchievement(eventBus, Intelligence.LEVEL_4).setHistoricConnection(HistoricPersonOrEvent.FREDERICK_THE_GREAT)); | ||
| list.add(new WinWhenStartingLastAchievement(eventBus).setHistoricConnection(HistoricPersonOrEvent.TOKUGAWA_IEYASU)); | ||
| list.add(new AbortGameAchievement(eventBus).setHistoricConnection(HistoricPersonOrEvent.JOHN_THE_POSTHUMOUS)); | ||
|
|
||
| return Collections.unmodifiableList(list); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this font used somewhere? If not, it can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used by menu_heading, defined in SkinConstants as FONT_MENU_HEADING, and used as the heading in the dialog that opens when you tap on a specific achievement. The important thing is that it is white. This is better readable in the dialog box with its turquois/cyan/green-blue (?) background.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is generated and should not be edited directly. Instead, Skin Composer should be used. In addition to that, a new label style should be created and scaled in SkinFactory. Using the tool can be a bit tricky. Can I help you with that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean "do everything for me", then you have my permission ;-). If you have some pointers, and I'll take it from there, I would also be glad. I guess "Skin Composer" is that tool (=a standalone program?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take care of it :)