Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0d5e470
feat: add weeds and compost
lstebner Jul 17, 2022
c92808e
updates based on feedback
lstebner Jul 17, 2022
6e95990
remove fertilizer from items in favor of one in recipes
lstebner Jul 17, 2022
724f4c4
fixing some references to items.fertilizer since it is now part of re…
lstebner Jul 18, 2022
172722a
add field to saveDataStubFactory
lstebner Jul 18, 2022
5a27de1
remove type COMPOST
lstebner Jul 18, 2022
159e671
change WEEDS to WEED
lstebner Jul 18, 2022
b4eed15
change composter name to 'Basic' and change export to be inline
lstebner Jul 18, 2022
dac5556
change weeds to weed
lstebner Jul 18, 2022
2583b13
more code review feedback updates
lstebner Jul 18, 2022
6b7d09e
categorize weeds in new Foraged Items category and associated recipes…
lstebner Jul 18, 2022
c03b15b
add some variety to weed image and remove original one
lstebner Jul 18, 2022
a42cf79
jsdoc
lstebner Jul 18, 2022
d572730
fix fertilizer image not showing in workshop, change compost recipe i…
lstebner Jul 18, 2022
140c9e0
update mock for RECYCLING
lstebner Jul 18, 2022
5a02753
spec fix
lstebner Jul 18, 2022
b0878a6
fix more specs
lstebner Jul 18, 2022
9b82a13
some tests for weed scenario in harvestPlot
lstebner Jul 18, 2022
1f493b1
change default weed image to pink weed
lstebner Jul 18, 2022
c0d7d8f
add purchaseComposter tests
lstebner Jul 18, 2022
64a5675
add tests for purchaseSmelter
lstebner Jul 18, 2022
6d96ae6
add description for compost
lstebner Jul 18, 2022
54086a5
fix string casing and add recycling tests to Workshop
lstebner Jul 18, 2022
3235c17
add some missing piskel files for images
lstebner Jul 18, 2022
33d7d91
Update src/game-logic/reducers/purchaseSmelter.test.js
lstebner Jul 19, 2022
99fdcaa
add wasJustShoveled to plotContents when mined
lstebner Jul 19, 2022
760bcb4
fix: update clearPlot to handle weeds
jeremyckahn Jul 20, 2022
ba36404
update specs for wasJustShoveled changes
lstebner Jul 20, 2022
06a5b1f
slightly simpler way to write this bit
lstebner Jul 20, 2022
e8f48b4
add compost piskel file
lstebner Jul 20, 2022
e7908c4
fix: update JSDoc
jeremyckahn Jul 21, 2022
e830fad
fix: prevent shoveled plot animations from replaying
jeremyckahn Jul 21, 2022
8cf4ccd
refactor: remove wasJustShoveled from farmhand.crop typedef
jeremyckahn Jul 21, 2022
bc9e211
refactor: rename resetWasShoveled to updatePlotShoveledState
jeremyckahn Jul 21, 2022
e7aef69
refactor: rename isRipe to canBeHarvested
jeremyckahn Jul 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/Farmhand/Farmhand.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ export default class Farmhand extends Component {
redirect: '',
room: decodeURIComponent(this.props.match.params.room || DEFAULT_ROOM),
purchasedCombine: 0,
purchasedComposter: 0,
purchasedCowPen: 0,
purchasedField: 0,
purchasedSmelter: 0,
Expand Down Expand Up @@ -539,6 +540,7 @@ export default class Farmhand extends Component {
'plantInPlot',
'prependPendingPeerMessage',
'purchaseCombine',
'purchaseComposter',
'purchaseCow',
'purchaseCowPen',
'purchaseField',
Expand Down
2 changes: 2 additions & 0 deletions src/components/Inventory/Inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const {
STONE,
FUEL,
TOOL_UPGRADE,
WEEDS,
} = itemType

export const categoryIds = enumify([
Expand Down Expand Up @@ -61,6 +62,7 @@ const itemTypeCategoryMap = Object.freeze({
[SPRINKLER]: FIELD_TOOLS,
[STONE]: MINED_RESOURCES,
[TOOL_UPGRADE]: UPGRADES,
[WEEDS]: CROPS,
})

const getItemCategories = () =>
Expand Down
6 changes: 5 additions & 1 deletion src/components/Plot/Plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export const getBackgroundStyles = plotContent => {

const backgroundImages = []

if (plotContent.fertilizerType === fertilizerType.STANDARD) {
if (
[fertilizerType.STANDARD, fertilizerType.COMPOST].includes(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we drop fertilizerType.COMPOST, we can revert this change.

plotContent.fertilizerType
)
) {
backgroundImages.push(`url(${plotStates['fertilized-plot']})`)
} else if (plotContent.fertilizerType === fertilizerType.RAINBOW) {
backgroundImages.push(`url(${plotStates['rainbow-fertilized-plot']})`)
Expand Down
18 changes: 18 additions & 0 deletions src/components/Shop/Shop.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { itemType, toolType } from '../../enums'
import {
INFINITE_STORAGE_LIMIT,
PURCHASEABLE_COMBINES,
PURCHASEABLE_COMPOSTERS,
PURCHASEABLE_COW_PENS,
PURCHASEABLE_FIELD_SIZES,
PURCHASEABLE_SMELTERS,
Expand Down Expand Up @@ -55,13 +56,15 @@ const categorizeShopInventory = memoize(shopInventory =>

export const Shop = ({
handleCombinePurchase,
handleComposterPurchase,
handleCowPenPurchase,
handleFieldPurchase,
handleSmelterPurchase,
handleStorageExpansionPurchase,
inventoryLimit,
money,
purchasedCombine,
purchasedComposter,
purchasedCowPen,
purchasedField,
purchasedSmelter,
Expand Down Expand Up @@ -211,6 +214,21 @@ export const Shop = ({
/>
</li>
) : null}
<li>
<TierPurchase
{...{
description:
'You can purchase a Composter to turn weeds into fertilizer.',
onBuyClick: handleComposterPurchase,
maxedOutPlaceholder: "You've already purchased the composter!",
purchasedTier: purchasedComposter,
renderTierLabel: ({ type, price }) =>
`${dollarString(price)}: ${type} Composter`,
tiers: PURCHASEABLE_COMPOSTERS,
title: 'Buy composter',
}}
/>
</li>
</ul>
</TabPanel>
</div>
Expand Down
7 changes: 7 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export const PURCHASEABLE_COMBINES = freeze(
new Map([[1, { type: 'Basic', price: 500_000 }]])
)

export const PURCHASEABLE_COMPOSTERS = freeze(
new Map([[1, { type: 'Bin', price: 1_000 }]])
)

export const PURCHASEABLE_SMELTERS = freeze(
new Map([[1, { type: 'Basic', price: 500_000 }]])
)
Expand Down Expand Up @@ -149,6 +153,7 @@ export const PERSISTED_STATE_KEYS = [
'priceSurges',
'profitabilityStreak',
'purchasedCombine',
'purchasedComposter',
'purchasedCowPen',
'purchasedField',
'purchasedSmelter',
Expand Down Expand Up @@ -231,3 +236,5 @@ export const COW_COLORS_HEX_MAP = {
}

export const COW_TRADE_TIMEOUT = 10000

export const WEEDS_SPAWN_CHANCE = 0.15
7 changes: 0 additions & 7 deletions src/data/__mocks__/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,6 @@ export const sampleFieldTool1 = testItem({
value: 5,
})

export const fertilizer = testItem({
id: 'fertilizer',
value: 60,
enablesFieldMode: 'FERTILIZE',
type: itemType.FERTILIZER,
})

export const sprinkler = testItem({
enablesFieldMode: 'SET_SPRINKLER',
id: 'sprinkler',
Expand Down
24 changes: 11 additions & 13 deletions src/data/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const {
MILK,
SCARECROW,
SPRINKLER,
WEEDS,
} = itemType

export {
Expand Down Expand Up @@ -50,6 +51,16 @@ export {
wheatSeed,
} from './crops'

const weeds = freeze({
id: 'weeds',
name: 'Weeds',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about changing these terms to be be singular rather than plural, to be consistent with the other items? So, weed/Weed instead of weeds/Weeds.

value: 0.1,
doesPriceFluctuate: false,
type: WEEDS,
})

export { weeds }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally not a big deal, but if you have to go back in here it might be worth exporting the weeds variable directly from its definition above to keep consistent with other item definitions.


export { bronzeOre, coal, goldOre, ironOre, silverOre, stone } from './ores'

////////////////////////////////////////
Expand All @@ -58,19 +69,6 @@ export { bronzeOre, coal, goldOre, ironOre, silverOre, stone } from './ores'
//
////////////////////////////////////////

/**
* @property farmhand.module:items.fertilizer
* @type {farmhand.item}
*/
export const fertilizer = freeze({
description: 'Helps crops grow and mature a little faster.',
enablesFieldMode: fieldMode.FERTILIZE,
id: 'fertilizer',
name: 'Fertilizer',
type: FERTILIZER,
value: 25,
})

/**
* @property farmhand.module:items.rainbowFertilizer
* @type {farmhand.item}
Expand Down
3 changes: 2 additions & 1 deletion src/data/levels.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { toolType } from '../enums'
import { features } from '../config'

import * as items from './items'
import * as recipes from './recipes'

export const levels = []

Expand All @@ -15,7 +16,7 @@ levels[2] = {
}

levels[3] = {
unlocksShopItem: items.fertilizer.id,
unlocksShopItem: recipes.fertilizer.id,
}

levels[4] = {
Expand Down
2 changes: 2 additions & 0 deletions src/data/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const {
TOMATO,
WATERMELON,
WHEAT,
WEEDS,
} = cropType

export const recipeCategories = {
Expand Down Expand Up @@ -64,4 +65,5 @@ export const cropIdToTypeMap = {
[TOMATO]: 'tomato',
[WATERMELON]: 'watermelon',
[WHEAT]: 'wheat',
[WEEDS]: 'weeds',
}
35 changes: 33 additions & 2 deletions src/data/recipes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @module farmhand.recipes
*/
import { itemType, recipeType } from '../enums'
import { itemType, fieldMode, recipeType } from '../enums'
import { RECIPE_INGREDIENT_VALUE_MULTIPLIER } from '../constants'

import * as items from './items'
Expand All @@ -11,7 +11,6 @@ const itemsMap = { ...baseItemsMap }

const itemify = recipe => {
const item = Object.freeze({
...recipe,
type: itemType.CRAFTED_ITEM,
value: Object.keys(recipe.ingredients).reduce(
(sum, itemId) =>
Expand All @@ -21,6 +20,7 @@ const itemify = recipe => {
recipe.ingredients[itemId],
0
),
...recipe,
})

itemsMap[recipe.id] = item
Expand Down Expand Up @@ -392,3 +392,34 @@ export const goldIngot = itemify({
state.purchasedSmelter && state.itemsSold[items.goldOre.id] >= 50,
recipeType: recipeType.FORGE,
})

export const compost = itemify({
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this item may not be obvious to players, so we might want to add a description explaining what it's for.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah. added, but where does that show up in the UI?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That... is an excellent question! It looks like they only show in the Shop screen:

{isPurchaseView && (description || isReplantable) && (
<CardContent>
{description && <Typography>{description}</Typography>}
{isReplantable && (
<Typography {...{ color: 'textSecondary' }}>
Once planted in the field, this item can be returned to your
inventory with the hoe and then replanted elsewhere.
</Typography>
)}
</CardContent>

We should tweak that in a follow up PR, and I've opened #313 do get this done later. Thanks for adding this in the meantime!

id: 'compost',
name: 'Compost',
ingredients: {
[items.weeds.id]: 100,
},
condition: state =>
state.purchasedComposter && state.itemsSold[items.weeds.id] >= 100,
recipeType: recipeType.KITCHEN,
type: itemType.CRAFTED_ITEM,
})

/**
* @property farmhand.module:recipes.fertilizer
* @type {farmhand.item}
*/
export const fertilizer = itemify({
id: 'fertilizer',
name: 'Fertilizer',
ingredients: {
[compost.id]: 10,
},
condition: state =>
state.purchasedComposter && state.itemsSold[compost.id] >= 10,
description: 'Helps crops grow and mature a little faster.',
enablesFieldMode: fieldMode.FERTILIZE,
recipeType: recipeType.KITCHEN,
type: itemType.FERTILIZER,
value: 25,
})
3 changes: 2 additions & 1 deletion src/data/shop-inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import {
wheatSeed,

// Field items
fertilizer,
scarecrow,
sprinkler,
} from './items'

import { fertilizer } from './recipes'

const inventory = [
// Plantable crops
asparagusSeed,
Expand Down
9 changes: 8 additions & 1 deletion src/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const cropType = enumify([
'TOMATO',
'WATERMELON',
'WHEAT',
'WEEDS',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about switching from plural "weeds" semantics to singular ("weed") for both the cropType here and the itemType below in order to remain consistent with the other cropType and itemType semantics?

])

/**
Expand Down Expand Up @@ -90,13 +91,19 @@ export const itemType = enumify([
'SPRINKLER',
'STONE',
'TOOL_UPGRADE',
'WEEDS',
])

/**
* @property farmhand.module:enums.fertilizerType
* @enum {string}
*/
export const fertilizerType = enumify(['NONE', 'STANDARD', 'RAINBOW'])
export const fertilizerType = enumify([
'NONE',
'STANDARD',
'RAINBOW',
'COMPOST',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to drop the COMPOST fertilizer type and instead craft STANDARD fertilizer with pulled weeds? I'm thinking that would be simplify the implementation and perhaps be a little more straightforward for players too.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we drop the mechanic of using compost as fertilizer directly, I think we can drop this addition.

])

/**
* @property farmhand.module:enums.genders
Expand Down
2 changes: 1 addition & 1 deletion src/game-logic/reducers/computeStateForNextDay.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const adjustItemValues = state => ({
*/
export const computeStateForNextDay = (state, isFirstDay = false) =>
(isFirstDay
? []
? [processField]
: [
computeCowInventoryForNextDay,
processCowBreeding,
Expand Down
Loading