Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 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,
WEED,
} = itemType

export const categoryIds = enumify([
Expand All @@ -31,6 +32,7 @@ export const categoryIds = enumify([
'CRAFTED_ITEMS',
'CROPS',
'FIELD_TOOLS',
'FORAGED_ITEMS',
'MINED_RESOURCES',
'SEEDS',
'UPGRADES',
Expand All @@ -42,6 +44,7 @@ const {
CRAFTED_ITEMS,
CROPS,
FIELD_TOOLS,
FORAGED_ITEMS,
MINED_RESOURCES,
SEEDS,
UPGRADES,
Expand All @@ -61,6 +64,7 @@ const itemTypeCategoryMap = Object.freeze({
[SPRINKLER]: FIELD_TOOLS,
[STONE]: MINED_RESOURCES,
[TOOL_UPGRADE]: UPGRADES,
[WEED]: FORAGED_ITEMS,
})

const getItemCategories = () =>
Expand Down Expand Up @@ -97,6 +101,7 @@ export const Inventory = ({
{[
[CROPS, 'Crops'],
[SEEDS, 'Seeds'],
[FORAGED_ITEMS, 'Foraged Items'],
[FIELD_TOOLS, 'Field Tools'],
[ANIMAL_PRODUCTS, 'Animal Products'],
[ANIMAL_SUPPLIES, 'Animal Supplies'],
Expand Down
1 change: 1 addition & 0 deletions src/components/Inventory/Inventory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe('item sorting', () => {
)
).toEqual({
[categoryIds.CROPS]: [testItem({ id: 'sample-crop-1' })],
[categoryIds.FORAGED_ITEMS]: [],
[categoryIds.MINED_RESOURCES]: [
testItem({ id: 'coal' }),
testItem({ id: 'stone' }),
Expand Down
16 changes: 10 additions & 6 deletions src/components/Plot/Plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ export const Plot = ({
x,
y,

image = getPlotImage(plotContent),
image = getPlotImage(plotContent, x, y),
lifeStage = plotContent &&
getPlotContentType(plotContent) === itemType.CROP &&
getCropLifeStage(plotContent),
isRipe = lifeStage === cropLifeStage.GROWN,
canBeHarvested = lifeStage === cropLifeStage.GROWN ||
(plotContent && getPlotContentType(plotContent) === itemType.WEED),
}) => {
const item = plotContent ? itemsMap[plotContent.itemId] : null
const daysLeftToMature = getDaysLeftToMature(plotContent)
Expand All @@ -101,7 +102,10 @@ export const Plot = ({
}, [initialIsShoveledState, plotContent])

useEffect(() => {
if (plotContent === null) setInitialIsShoveledState(false)
if (plotContent === null) {
setInitialIsShoveledState(false)
setWasJustShoveled(false)
}
}, [plotContent])

const showPlotImage = Boolean(
Expand All @@ -120,7 +124,7 @@ export const Plot = ({

// For crops
crop: isCrop,
'is-ripe': isRipe,
'can-be-harvested': canBeHarvested,

// For crops and scarecrows
'can-be-fertilized':
Expand All @@ -145,8 +149,8 @@ export const Plot = ({
{...{
className: classNames('square', {
...(isCrop && {
animated: isRipe,
heartBeat: isRipe,
animated: canBeHarvested,
heartBeat: canBeHarvested,
}),
...(wasJustShoveled && {
animated: true,
Expand Down
6 changes: 3 additions & 3 deletions src/components/Plot/Plot.sass
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
&:hover
cursor: pointer

.harvest-mode &.is-ripe
.harvest-mode &.can-be-harvested
background-color: $colorGreenOk

&:hover
Expand All @@ -52,7 +52,7 @@
background-color: $colorYellow
cursor: pointer

.harvest-mode.is-inventory-full &.crop.is-ripe,
.harvest-mode.is-inventory-full &.crop.can-be-harvested,
.cleanup-mode.is-inventory-full &.is-replantable
background-color: $colorRedDanger
cursor: not-allowed
Expand All @@ -61,7 +61,7 @@
background-color: $colorGreenOk
cursor: pointer

.cleanup-mode &.is-ripe
.cleanup-mode &.can-be-harvested
background-color: $colorGreenOk
cursor: auto

Expand Down
4 changes: 2 additions & 2 deletions src/components/Plot/Plot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ test('renders is-replantable class', () => {
expect(component.find('.Plot').hasClass('is-replantable')).toBeTruthy()
})

test('renders "is-ripe" class', () => {
test('renders "can-be-harvested" class', () => {
component.setProps({ lifeStage: cropLifeStage.GROWN })
expect(component.find('.Plot').hasClass('is-ripe')).toBeTruthy()
expect(component.find('.Plot').hasClass('can-be-harvested')).toBeTruthy()
})

describe('"can-be-fertilized" class', () => {
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
2 changes: 1 addition & 1 deletion src/components/Workshop/ForgeTabPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function ForgeTabPanel({
{...{
linkTarget: '_blank',
className: 'markdown',
source: `Forge Recipes are learned by selling resources mined from the field.`,
source: `Forge recipes are learned by selling resources mined from the field.`,
Copy link
Owner

Choose a reason for hiding this comment

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

Good catch!

}}
/>
</CardContent>
Expand Down
53 changes: 53 additions & 0 deletions src/components/Workshop/RecyclingTabPanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react'
import PropTypes from 'prop-types'

import Card from '@material-ui/core/Card'
import CardContent from '@material-ui/core/CardContent'
import Divider from '@material-ui/core/Divider'
import ReactMarkdown from 'react-markdown'

import { recipeType } from '../../enums'

import { recipeCategories } from '../../data/maps'

import { TabPanel } from './TabPanel'
import { RecipeList } from './RecipeList'

export function RecyclingTabPanel({
Copy link
Owner

Choose a reason for hiding this comment

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

Nice! 😁

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this was so easy thanks to the panel refactors done recently. very glad i did that 😄

currentTab,
index,
learnedRecipes,
setCurrentTab,
}) {
return (
<TabPanel value={currentTab} index={index}>
<RecipeList
learnedRecipes={learnedRecipes}
allRecipes={recipeCategories[recipeType.RECYCLING]}
/>
<Divider />
<ul className="card-list">
<li>
<Card>
<CardContent>
<ReactMarkdown
{...{
linkTarget: '_blank',
className: 'markdown',
source: `Recyling recipes are learned by selling items foraged from the field.`,
}}
/>
</CardContent>
</Card>
</li>
</ul>
</TabPanel>
)
}

RecyclingTabPanel.propTypes = {
currentTab: PropTypes.number.isRequired,
index: PropTypes.number.isRequired,
learnedRecipes: PropTypes.array.isRequired,
setCurrentTab: PropTypes.func.isRequired,
}
26 changes: 25 additions & 1 deletion src/components/Workshop/Workshop.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ import { a11yProps } from './TabPanel'

import { ForgeTabPanel } from './ForgeTabPanel'
import { KitchenTabPanel } from './KitchenTabPanel'
import { RecyclingTabPanel } from './RecyclingTabPanel'

import './Workshop.sass'

const Workshop = ({ learnedRecipes, purchasedSmelter, toolLevels }) => {
const Workshop = ({
learnedRecipes,
purchasedComposter,
purchasedSmelter,
toolLevels,
}) => {
const [currentTab, setCurrentTab] = useState(0)

const learnedKitchenRecipes = Object.keys(learnedRecipes).filter(
Expand All @@ -29,8 +35,14 @@ const Workshop = ({ learnedRecipes, purchasedSmelter, toolLevels }) => {
recipeId => recipesMap[recipeId].recipeType === recipeType.FORGE
)

const learnedRecyclingRecipes = Object.keys(learnedRecipes).filter(
recipeId => recipesMap[recipeId].recipeType === recipeType.RECYCLING
)

const showForge = features.MINING && purchasedSmelter

const recyclingTabIndex = showForge ? 2 : 1

return (
<div className="Workshop">
<AppBar position="static" color="primary">
Expand All @@ -41,6 +53,9 @@ const Workshop = ({ learnedRecipes, purchasedSmelter, toolLevels }) => {
>
<Tab {...{ label: 'Kitchen', ...a11yProps(0) }} />
{showForge ? <Tab {...{ label: 'Forge', ...a11yProps(1) }} /> : null}
{purchasedComposter ? (
<Tab {...{ label: 'Recycling', ...a11yProps(recyclingTabIndex) }} />
) : null}
</Tabs>
</AppBar>
<KitchenTabPanel
Expand All @@ -58,12 +73,21 @@ const Workshop = ({ learnedRecipes, purchasedSmelter, toolLevels }) => {
toolLevels={toolLevels}
/>
) : null}
{purchasedComposter ? (
<RecyclingTabPanel
currentTab={currentTab}
index={recyclingTabIndex}
learnedRecipes={learnedRecyclingRecipes}
setCurrentTab={setCurrentTab}
/>
) : null}
</div>
)
}

Workshop.propTypes = {
learnedRecipes: object.isRequired,
purchasedComposter: number,
purchasedSmelter: number,
toolLevels: object.isRequired,
}
Expand Down
Loading