-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(Cellar): stand up inventory tab * docs(types): define keg data * feat(fermentation): add support for daysToFerment item property * feat(FermentationRecipeList): add FermentationRecipe card list * feat(FermentationRecipe): show fermented recipe name * feat(FermentationRecipe): add avatar drop shadow * feat(FermentationRecipe): show days to ferment * feat(fermentation): implement maxYieldOfFermentationRecipe * refactor(crops): change fromSeed to accept config object * refactor(utils): move memoize to its own file * refactor(utils): move getCropLifecycleDuration to its own file * feat(fermentation): make daysToFerment a computed value * feat(fermentation): implement doesCellarSpaceRemain * feat(fermentation): show recipe instance in cellar count * feat(fermentation): implement makeFermentationRecipe reducer * feat(fermentation): implement processCellar reducer * feat(Cellar): stand up sellKeg logic * feat(Cellar): remove keg from cellarInventory when sold * refactor(Cellar): make sellKeg support only one keg * feat(Cellar): calculate keg value * feat(Cellar): animate keg value * feat(Cellar): add button to throw away keg * feat(Cellar): track cellarItemsSold * feat(Cellar): show peer notification when a fermented item is sold * feat(Cellar): show salt inventory in fermentation recipe cards * feat(Cellar): show cellar capacity * feat(Fermentation): enable feature * test(FermentationRecipeList): validate header display * fix(test): update getLevelEntitlements test * test(maxYieldOfFermentationRecipe): validate functionality * test(makeFermentationRecipe): validate functionality * test(processCellar): validate implementation * test(getCropsAvailableToFerment): validate functionality * feat(fermentation): make more crops ferment-able * chore(todos): add TODO links * test(sellKeg): test behavior
- Loading branch information
1 parent
eea169a
commit 7d5b529
Showing
80 changed files
with
1,689 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** @typedef {import("../../index").farmhand.keg} keg */ | ||
import React, { useContext } from 'react' | ||
import { number } from 'prop-types' | ||
import Divider from '@material-ui/core/Divider' | ||
import Card from '@material-ui/core/Card' | ||
import CardContent from '@material-ui/core/CardContent' | ||
import ReactMarkdown from 'react-markdown' | ||
|
||
import FarmhandContext from '../Farmhand/Farmhand.context' | ||
import { KEG_INTEREST_RATE, PURCHASEABLE_CELLARS } from '../../constants' | ||
|
||
import { integerString } from '../../utils' | ||
|
||
import { TabPanel } from './TabPanel' | ||
import { Keg } from './Keg' | ||
|
||
/** | ||
* @param {Object} props | ||
* @param {number} props.index | ||
* @param {number} props.currentTab | ||
*/ | ||
export const CellarInventoryTabPanel = ({ index, currentTab }) => { | ||
/** | ||
* @type {{ | ||
* gameState: { | ||
* cellarInventory:Array.<keg>, | ||
* purchasedCellar: number | ||
* } | ||
* }} | ||
*/ | ||
const { | ||
gameState: { cellarInventory, purchasedCellar }, | ||
} = useContext(FarmhandContext) | ||
|
||
return ( | ||
<TabPanel value={currentTab} index={index}> | ||
<h3> | ||
Capacity: {integerString(cellarInventory.length)} /{' '} | ||
{integerString(PURCHASEABLE_CELLARS.get(purchasedCellar).space)} | ||
</h3> | ||
<ul className="card-list"> | ||
{cellarInventory.map(keg => ( | ||
<li key={keg.id}> | ||
<Keg keg={keg} /> | ||
</li> | ||
))} | ||
</ul> | ||
<Divider /> | ||
<ul className="card-list"> | ||
<li> | ||
<Card> | ||
<CardContent> | ||
<ReactMarkdown | ||
{...{ | ||
linkTarget: '_blank', | ||
className: 'markdown', | ||
source: `This is your inventory of cellar kegs. Keg contents take time to reach maturity before they can be sold. Once they reach maturity, keg contents become higher in quality and their value compounds at a rate of ${KEG_INTEREST_RATE}% a day.`, | ||
}} | ||
/> | ||
</CardContent> | ||
</Card> | ||
</li> | ||
</ul> | ||
</TabPanel> | ||
) | ||
} | ||
|
||
CellarInventoryTabPanel.propTypes = { | ||
currentTab: number.isRequired, | ||
index: number.isRequired, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/** @typedef {import("../../index").farmhand.keg} keg */ | ||
import React, { useContext } from 'react' | ||
import { object } from 'prop-types' | ||
import Card from '@material-ui/core/Card' | ||
import CardHeader from '@material-ui/core/CardHeader' | ||
import CardActions from '@material-ui/core/CardActions' | ||
import Button from '@material-ui/core/Button' | ||
|
||
import { itemsMap } from '../../data/maps' | ||
import { items } from '../../img' | ||
|
||
import FarmhandContext from '../Farmhand/Farmhand.context' | ||
import { getKegValue } from '../../utils/getKegValue' | ||
import { moneyString } from '../../utils/moneyString' | ||
import { getSalePriceMultiplier } from '../../utils' | ||
import { FERMENTED_CROP_NAME } from '../../templates' | ||
import AnimatedNumber from '../AnimatedNumber' | ||
|
||
import './Keg.sass' | ||
|
||
/** | ||
* @param {Object} props | ||
* @param {keg} props.keg | ||
*/ | ||
export function Keg({ keg }) { | ||
/** | ||
* @type {{ | ||
* handlers: { | ||
* handleSellKegClick: function(keg): void, | ||
* handleThrowAwayKegClick: function(keg): void | ||
* }, | ||
* gameState: { | ||
* completedAchievements: Object.<string, boolean> | ||
* } | ||
* }} | ||
*/ | ||
const { | ||
handlers: { handleSellKegClick, handleThrowAwayKegClick }, | ||
gameState: { completedAchievements }, | ||
} = useContext(FarmhandContext) | ||
|
||
const item = itemsMap[keg.itemId] | ||
const fermentationRecipeName = FERMENTED_CROP_NAME`${item}` | ||
|
||
const handleSellClick = () => { | ||
handleSellKegClick(keg) | ||
} | ||
|
||
const handleThrowAwayClick = () => { | ||
handleThrowAwayKegClick(keg) | ||
} | ||
|
||
const canBeSold = keg.daysUntilMature <= 0 | ||
const kegValue = | ||
getKegValue(keg) * getSalePriceMultiplier(completedAchievements) | ||
|
||
return ( | ||
<Card className="Keg"> | ||
<CardHeader | ||
title={fermentationRecipeName} | ||
avatar={ | ||
<img | ||
{...{ | ||
src: items[item.id], | ||
}} | ||
alt={fermentationRecipeName} | ||
/> | ||
} | ||
subheader={ | ||
<> | ||
{canBeSold ? ( | ||
<p>Days since ready: {Math.abs(keg.daysUntilMature)}</p> | ||
) : ( | ||
<p>Days until ready: {keg.daysUntilMature}</p> | ||
)} | ||
{canBeSold ? ( | ||
<p> | ||
Current value:{' '} | ||
<AnimatedNumber | ||
{...{ number: kegValue, formatter: moneyString }} | ||
/> | ||
</p> | ||
) : null} | ||
</> | ||
} | ||
></CardHeader> | ||
<CardActions> | ||
<Button | ||
{...{ | ||
className: 'sell-keg', | ||
color: 'secondary', | ||
onClick: handleSellClick, | ||
variant: 'contained', | ||
disabled: !canBeSold, | ||
}} | ||
> | ||
Sell | ||
</Button> | ||
{!canBeSold ? ( | ||
<Button | ||
{...{ | ||
className: 'throw-away-keg', | ||
color: 'secondary', | ||
onClick: handleThrowAwayClick, | ||
variant: 'contained', | ||
}} | ||
> | ||
Throw away | ||
</Button> | ||
) : null} | ||
</CardActions> | ||
</Card> | ||
) | ||
} | ||
|
||
Keg.propTypes = { | ||
keg: object.isRequired, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.Keg | ||
position: relative | ||
|
||
.MuiCardHeader-avatar | ||
img | ||
width: 3em | ||
filter: drop-shadow(1px 1px 2px rgba(255, 0, 131, 0.63)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.