-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
82 changed files
with
1,692 additions
and
278 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
188cef7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
farmhand – ./
farmhand-git-main-jeremyckahn.vercel.app
www.farmhand.life
farmhand-jeremyckahn.vercel.app
farmhand.life
farmhand.vercel.app