Skip to content

Commit 09797ce

Browse files
committed
Add two achievements for Treasures
1 parent 50cb077 commit 09797ce

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

javascript/features/collectables/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Quick Addict | Win 100 reaction tests |
3030
Electrolyte | Win 1,000 reaction tests |
3131
The Streak | Win 10 reaction tests in a row |
3232
keybind.cs | Win a reaction test in <2s |
33+
Blackbeard | Collect 10 Treasures |
34+
Jack Sparrow | Collect all Treasures |
3335

3436
Beginning another round of earning the achievements _will not_ reset the benefits. Once granted, you
3537
will keep them indefinitely.

javascript/features/collectables/achievements.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { CollectableBase } from 'features/collectables/collectable_base.js';
66
import { CollectableDatabase } from 'features/collectables/collectable_database.js';
77

88
// -------------------------------------------------------------------------------------------------
9-
// Next ID: 9
9+
// Next ID: 16
1010
// -------------------------------------------------------------------------------------------------
1111

1212
// Spray Tag achievements: awarded when the player gathers { 10, 40, 90, 100 } spray tags.
@@ -32,6 +32,10 @@ export const kAchievementReactionTestSequence = 12;
3232
// Reaction Test performance achievement: awarded when answering a reaction test super quickly.
3333
export const kAchievementReactionTestSpeed = 13;
3434

35+
// Treasures achievements: awarded when the player gathers 10, or all, treasures.
36+
export const kAchievementTreasuresBronze = 14;
37+
export const kAchievementTreasuresPlatinium = 15;
38+
3539
// -------------------------------------------------------------------------------------------------
3640

3741
// Textual descriptions of the achievements that can be awarded by the game.
@@ -62,6 +66,10 @@ export const kAchievements = new Map([
6266
{ name: 'The Streak', text: 'Won 10 reaction tests in a row' } ],
6367
[ kAchievementReactionTestSpeed,
6468
{ name: 'keybind.cs', text: 'Won a reaction test in under two seconds' } ],
69+
[ kAchievementTreasuresBronze,
70+
{ name: 'Blackbeard', text: 'Collect 10 Treasures' } ],
71+
[ kAchievementTreasuresPlatinium,
72+
{ name: 'Jack Sparrow', text: 'Collect all the Treasures' } ],
6573
]);
6674

6775
// -------------------------------------------------------------------------------------------------

javascript/features/collectables/collectable_commands.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('CollectableCommands', (it, beforeEach) => {
3030
rows: [
3131
[
3232
'Achievements',
33-
'2 / 13',
33+
'2 / 15',
3434
],
3535
[
3636
'{FF5252}Red Barrels',

javascript/features/collectables/treasures.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { Vector } from 'base/vector.js';
99
import { createSeed, random, randomSeed } from 'base/random.js';
1010
import { intersect } from 'base/set_extensions.js';
1111

12+
import * as achievements from 'features/collectables/achievements.js';
13+
1214
// Title of the notification that will be shown to the player when finding a book, and another one
1315
// for the notification to be shown when a treasure associated with that book has been found.
1416
const kBookNotificationTitle = 'uncovered!';
@@ -380,7 +382,14 @@ export class Treasures extends CollectableBase {
380382
// Awards an achievement to the |player| when their collectable stats in the current round are
381383
// applicable to be awarded one. The thresholds are defined in achievements.js as well.
382384
awardAchievementWhenApplicable(player, collected) {
383-
// TODO: Achievements?
385+
const kMilestones = new Map([
386+
[ 10, achievements.kAchievementTreasuresBronze ],
387+
[ 50, achievements.kAchievementTreasuresPlatinium ],
388+
]);
389+
390+
const achievement = kMilestones.get(collected);
391+
if (achievement)
392+
this.collectables_.awardAchievement(player, achievement);
384393
}
385394

386395
// ---------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)