Skip to content

Commit

Permalink
feat(experience): [closes #460] Grant experience for selling coal, or…
Browse files Browse the repository at this point in the history
…es, and stones (#461)

* feat(experience): [#460] grant experience for selling coal and ores
* feat(experience): [#460] grant experience for selling stones
  • Loading branch information
jeremyckahn authored Oct 13, 2023
1 parent 9207fd8 commit f82e3cc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/game-logic/reducers/sellItem.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { testItem } from '../../test-utils'
import { LOAN_PAYOFF } from '../../templates'
import { carrot } from '../../data/crops'
import { bronzeOre, coal, milk1, saltRock } from '../../data/items'
import { carrotSoup } from '../../data/recipes'

import { sellItem } from './sellItem'

Expand Down Expand Up @@ -226,4 +229,37 @@ describe('sellItem', () => {
})
})
})

const experienceTestArgs = [
carrot,
milk1,
coal,
carrotSoup,
bronzeOre,
saltRock,
].map(item => [item.type, item])

test.each(experienceTestArgs)(
'selling item of type %s gives experience',
(_, item) => {
const state = sellItem(
{
experience: 0,
inventory: [testItem({ id: item.id, quantity: 1 })],
itemsSold: {},
loanBalance: 0,
money: 100,
pendingPeerMessages: [],
todaysNotifications: [],
revenue: 0,
todaysRevenue: 0,
valueAdjustments: { [item.id]: 1 },
},
testItem({ id: item.id }),
1
)

expect(state.experience).toEqual(1)
}
)
})
9 changes: 8 additions & 1 deletion src/utils/isItemAFarmProduct.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
/** @typedef {import('../index').farmhand.item} farmhand.item */
import { itemType } from '../enums'

import { isItemAGrownCrop } from './isItemAGrownCrop'

const FARM_PRODUCT_TYPES = [itemType.MILK, itemType.CRAFTED_ITEM]
const FARM_PRODUCT_TYPES = [
itemType.CRAFTED_ITEM,
itemType.FUEL,
itemType.MILK,
itemType.ORE,
itemType.STONE,
]

/**
* @param {farmhand.item} item
Expand Down

0 comments on commit f82e3cc

Please sign in to comment.