Skip to content

Commit

Permalink
docs(#491): define wine type
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyckahn committed Apr 15, 2024
1 parent 430cbcc commit d099787
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 33 deletions.
31 changes: 13 additions & 18 deletions src/data/crops/grape.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
/** @typedef {import("../../index").farmhand.item} farmhand.item */
/** @typedef {import("../../index").farmhand.grape} farmhand.grape */
/** @typedef {import("../../index").farmhand.cropVariety} farmhand.cropVariety */

import { crop, fromSeed, cropVariety } from '../crop'
import { cropFamily, cropType } from '../../enums'

/**
* @typedef {cropVariety & {
* cropFamily: cropFamily['GRAPE']
* }} Grape
*/

/**
* @param {farmhand.item | farmhand.cropVariety} item
* @returns {item is Grape}
* @returns {item is farmhand.grape}
*/
export const isGrape = item => {
return 'cropFamily' in item && item.cropFamily === cropFamily.GRAPE
}

/**
* @param {Omit<farmhand.cropVariety, 'cropFamily'>} grapeProps
* @returns {Grape}
* @returns {farmhand.grape}
*/
const grape = grapeProps => {
const newGrape = {
Expand Down Expand Up @@ -60,7 +55,7 @@ export const grapeSeed = crop({

/**
* @property farmhand.module:items.grapeChardonnay
* @type {Grape}
* @type {farmhand.grape}
*/
export const grapeChardonnay = grape({
...fromSeed(grapeSeed, {
Expand All @@ -72,7 +67,7 @@ export const grapeChardonnay = grape({

/**
* @property farmhand.module:items.grapeSauvignonBlanc
* @type {Grape}
* @type {farmhand.grape}
*/
export const grapeSauvignonBlanc = grape({
...fromSeed(grapeSeed, {
Expand All @@ -84,7 +79,7 @@ export const grapeSauvignonBlanc = grape({

/**
* @property farmhand.module:items.grapePinotBlanc
* @type {Grape}
* @type {farmhand.grape}
*/
// export const grapePinotBlanc = grape({
// ...fromSeed(grapeSeed, { variantIdx: grapeSeed.growsInto?.indexOf('grape-pinot-blanc') }),
Expand All @@ -94,7 +89,7 @@ export const grapeSauvignonBlanc = grape({

/**
* @property farmhand.module:items.grapeMuscat
* @type {Grape}
* @type {farmhand.grape}
*/
// export const grapeMuscat = grape({
// ...fromSeed(grapeSeed, { variantIdx: grapeSeed.growsInto?.indexOf('grape-muscat') }),
Expand All @@ -104,7 +99,7 @@ export const grapeSauvignonBlanc = grape({

/**
* @property farmhand.module:items.grapeRiesling
* @type {Grape}
* @type {farmhand.grape}
*/
// export const grapeRiesling = grape({
// ...fromSeed(grapeSeed, { variantIdx: grapeSeed.growsInto?.indexOf('grape-riesling') }),
Expand All @@ -114,7 +109,7 @@ export const grapeSauvignonBlanc = grape({

/**
* @property farmhand.module:items.grapeMerlot
* @type {Grape}
* @type {farmhand.grape}
*/
// export const grapeMerlot = grape({
// ...fromSeed(grapeSeed, { variantIdx: grapeSeed.growsInto?.indexOf('grape-merlot') }),
Expand All @@ -124,7 +119,7 @@ export const grapeSauvignonBlanc = grape({

/**
* @property farmhand.module:items.grapeCabernetSauvignon
* @type {Grape}
* @type {farmhand.grape}
*/
export const grapeCabernetSauvignon = grape({
...fromSeed(grapeSeed, {
Expand All @@ -136,7 +131,7 @@ export const grapeCabernetSauvignon = grape({

/**
* @property farmhand.module:items.grapeSyrah
* @type {Grape}
* @type {farmhand.grape}
*/
// export const grapeSyrah = grape({
// ...fromSeed(grapeSeed, { variantIdx: grapeSeed.growsInto?.indexOf('grape-syrah') }),
Expand All @@ -146,7 +141,7 @@ export const grapeCabernetSauvignon = grape({

/**
* @property farmhand.module:items.grapeTempranillo
* @type {Grape}
* @type {farmhand.grape}
*/
export const grapeTempranillo = grape({
...fromSeed(grapeSeed, {
Expand All @@ -158,7 +153,7 @@ export const grapeTempranillo = grape({

/**
* @property farmhand.module:items.grapeNebbiolo
* @type {Grape}
* @type {farmhand.grape}
*/
export const grapeNebbiolo = grape({
...fromSeed(grapeSeed, {
Expand Down
1 change: 1 addition & 0 deletions src/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export const cowTradeRejectionReason = enumify(['REQUESTED_COW_UNAVAILABLE'])
/**
* @property farmhand.module:enums.cropFamily
* @readonly
* @enum {string}
*/
export const cropFamily = {
GRAPE: 'GRAPE',
Expand Down
43 changes: 28 additions & 15 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@
* @namespace farmhand
*/

import './polyfills'
import React from 'react'
import ReactDOM from 'react-dom'
import { HashRouter as Router, Route } from 'react-router-dom'

import * as serviceWorkerRegistration from './serviceWorkerRegistration'
import './index.sass'
import Farmhand from './components/Farmhand'
import { features } from './config'
import 'typeface-francois-one'
import 'typeface-public-sans'

// eslint-disable-next-line no-unused-vars
import { cropFamily } from './enums'

/**
* @typedef {import("./components/Farmhand/Farmhand").farmhand.state} farmhand.state
* @typedef {import("./enums").cropFamily} cropFamily
*/

/**
Expand Down Expand Up @@ -45,6 +59,17 @@
* cropFamily: cropFamily
* }} farmhand.cropVariety
/**
* @typedef {farmhand.cropVariety & {
* cropFamily: 'GRAPE'
* }} farmhand.grape
*/

/**
* @typedef farmhand.wine
* @property {farmhand.grape} sourceCrop
*/

/**
* This is a minimalist base type to be inherited and expanded on by types like
* farmhand.crop. This also represents non-crop plot content like scarecrows
Expand Down Expand Up @@ -144,8 +169,8 @@
* @property {string} id UUID to uniquely identify the keg.
* @property {string} itemId The item that this keg is based on.
* @property {number} daysUntilMature Days remaining until this recipe can be
* sold. This value can go negative to indicate "days since fermented." When
* negative, the value of the keg is increased.
* sold. This value can go negative to indicate "days since fermented" or "days
* open" When negative, the value of the keg is increased.
*/

/**
Expand Down Expand Up @@ -246,18 +271,6 @@
* @property {number} price
*/

import './polyfills'
import React from 'react'
import ReactDOM from 'react-dom'
import { HashRouter as Router, Route } from 'react-router-dom'

import * as serviceWorkerRegistration from './serviceWorkerRegistration'
import './index.sass'
import Farmhand from './components/Farmhand'
import { features } from './config'
import 'typeface-francois-one'
import 'typeface-public-sans'

const FarmhandRoute = props => <Farmhand {...{ ...props, features }} />

ReactDOM.render(
Expand Down

0 comments on commit d099787

Please sign in to comment.