Skip to content

Commit 246257b

Browse files
authored
feat: Halloween Harvest achievement (#331)
* feat: implement Halloween Harvest achievement * test: mock getMonth
1 parent e397b25 commit 246257b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/data/achievements.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ const achievements = [
104104
reward: state => addItemToInventory(state, cowFeed, reward, true),
105105
}))(),
106106

107+
((reward = 150) => ({
108+
id: 'play-during-october',
109+
name: 'Halloween Harvest',
110+
description: 'Play Farmhand in October and get the gift of the season.',
111+
rewardDescription: `${reward} units of ${itemsMap.jackolantern.name}`,
112+
condition: () => new Date().getMonth() === 9,
113+
reward: state =>
114+
addItemToInventory(state, itemsMap.jackolantern, reward, true),
115+
}))(),
116+
107117
((reward = 100, goal = 10_000) => ({
108118
id: 'sell-10000-jack-o-lanterns',
109119
name: 'Spooky Pumpkin Patch',

src/setupTests.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ configure({
88
setupFilesAfterEnv: ['jest-extended'],
99
})
1010

11+
beforeEach(() => {
12+
// Return an invalid month number so that any conditional logic that depends
13+
// on a specific month is not run in tests (unless getMonth is re-mocked).
14+
jest.spyOn(Date.prototype, 'getMonth').mockReturnValue(-1)
15+
})
16+
1117
afterEach(() => {
1218
jest.restoreAllMocks()
1319
})

0 commit comments

Comments
 (0)