Skip to content

Commit

Permalink
refactor(fermentation): use FERMENTED_CROP_NAME template
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyckahn committed May 21, 2023
1 parent 6f59014 commit 6d2a795
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/components/Cellar/Keg.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { items } from '../../img'
import FarmhandContext from '../Farmhand/Farmhand.context'
import { getKegValue } from '../../utils/getKegValue'
import { moneyString } from '../../utils/moneyString'
import { getFermentedRecipeName } from '../../utils/getFermentedRecipeName'
import { getSalePriceMultiplier } from '../../utils'
import { FERMENTED_CROP_NAME } from '../../templates'
import AnimatedNumber from '../AnimatedNumber'

import './Keg.sass'
Expand All @@ -40,7 +40,7 @@ export function Keg({ keg }) {
} = useContext(FarmhandContext)

const item = itemsMap[keg.itemId]
const fermentationRecipeName = getFermentedRecipeName(item)
const fermentationRecipeName = FERMENTED_CROP_NAME`${item}`

const handleSellClick = () => {
handleSellKegClick(keg)
Expand Down
10 changes: 6 additions & 4 deletions src/components/FermentationRecipeList/FermentationRecipe.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @typedef {import("../../index").farmhand.item} item */
/** @typedef {import("../../index").farmhand.keg} keg */
/**
* @typedef {import("../../index").farmhand.item} item
* @typedef {import("../../index").farmhand.keg} keg
*/

import React, { useContext, useEffect, useState } from 'react'
import { object } from 'prop-types'
Expand All @@ -13,7 +15,7 @@ import { items } from '../../img'
import { doesCellarSpaceRemain } from '../../utils/doesCellarSpaceRemain'
import { getMaxYieldOfFermentationRecipe } from '../../utils/getMaxYieldOfFermentationRecipe'
import { getSaltRequirementsForFermentationRecipe } from '../../utils/getSaltRequirementsForFermentationRecipe'
import { getFermentedRecipeName } from '../../utils/getFermentedRecipeName'
import { FERMENTED_CROP_NAME } from '../../templates'
import QuantityInput from '../QuantityInput'
import FarmhandContext from '../Farmhand/Farmhand.context'
import { fermentableItemsMap, itemsMap } from '../../data/maps'
Expand Down Expand Up @@ -70,7 +72,7 @@ export const FermentationRecipe = ({ item }) => {
const [quantity, setQuantity] = useState(1)

const inventoryQuantityMap = getInventoryQuantityMap(inventory)
const fermentationRecipeName = getFermentedRecipeName(item)
const fermentationRecipeName = FERMENTED_CROP_NAME`${item}`
const { space: cellarSize } = PURCHASEABLE_CELLARS.get(purchasedCellar)

useEffect(() => {
Expand Down
10 changes: 8 additions & 2 deletions src/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
getRandomLevelUpRewardQuantity,
integerString,
} from './utils'
import { getFermentedRecipeName } from './utils/getFermentedRecipeName'

/**
* @param {farmhand.crop} crop
Expand Down Expand Up @@ -274,7 +273,7 @@ export const SOLD_ITEM_PEER_NOTIFICATION = (_, quantity, { name }) =>
* @returns {string}
*/
export const SOLD_FERMENTED_ITEM_PEER_NOTIFICATION = (_, item) =>
`sold one unit of ${getFermentedRecipeName(item)}.`
`sold one unit of ${FERMENTED_CROP_NAME`${item}`}.`

/**
* @param {string} toolName - the name of the tool being replaced
Expand Down Expand Up @@ -329,3 +328,10 @@ export const COW_TRADED_NOTIFICATION = (
* @returns {string}
*/
export const SHOVELED_PLOT = (_, item) => `Shoveled plot of ${item.name}`

/**
* @param {string} _
* @param {farmhand.item} item
* @returns {string}
*/
export const FERMENTED_CROP_NAME = (_, item) => `Fermented ${item.name}`
8 changes: 0 additions & 8 deletions src/utils/getFermentedRecipeName.js

This file was deleted.

0 comments on commit 6d2a795

Please sign in to comment.