Skip to content

Commit

Permalink
feat(experience): [#460] grant experience for selling coal and ores
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyckahn committed Oct 13, 2023
1 parent 9207fd8 commit 460621c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
35 changes: 35 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 } from '../../data/items'
import { carrotSoup } from '../../data/recipes'

import { sellItem } from './sellItem'

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

const experienceTestArgs = [
carrot,
milk1,
coal,
carrotSoup,
bronzeOre,
].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)
}
)
})
8 changes: 7 additions & 1 deletion src/utils/isItemAFarmProduct.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
/** @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,
]

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

0 comments on commit 460621c

Please sign in to comment.