From d0997870b2f146625e484f4dc4dae724167a13c3 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Mon, 15 Apr 2024 09:01:56 -0500 Subject: [PATCH] docs(#491): define wine type --- src/data/crops/grape.js | 31 +++++++++++++---------------- src/enums.js | 1 + src/index.js | 43 +++++++++++++++++++++++++++-------------- 3 files changed, 42 insertions(+), 33 deletions(-) diff --git a/src/data/crops/grape.js b/src/data/crops/grape.js index fa724eb78..7b69b60a1 100644 --- a/src/data/crops/grape.js +++ b/src/data/crops/grape.js @@ -1,18 +1,13 @@ /** @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 @@ -20,7 +15,7 @@ export const isGrape = item => { /** * @param {Omit} grapeProps - * @returns {Grape} + * @returns {farmhand.grape} */ const grape = grapeProps => { const newGrape = { @@ -60,7 +55,7 @@ export const grapeSeed = crop({ /** * @property farmhand.module:items.grapeChardonnay - * @type {Grape} + * @type {farmhand.grape} */ export const grapeChardonnay = grape({ ...fromSeed(grapeSeed, { @@ -72,7 +67,7 @@ export const grapeChardonnay = grape({ /** * @property farmhand.module:items.grapeSauvignonBlanc - * @type {Grape} + * @type {farmhand.grape} */ export const grapeSauvignonBlanc = grape({ ...fromSeed(grapeSeed, { @@ -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') }), @@ -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') }), @@ -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') }), @@ -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') }), @@ -124,7 +119,7 @@ export const grapeSauvignonBlanc = grape({ /** * @property farmhand.module:items.grapeCabernetSauvignon - * @type {Grape} + * @type {farmhand.grape} */ export const grapeCabernetSauvignon = grape({ ...fromSeed(grapeSeed, { @@ -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') }), @@ -146,7 +141,7 @@ export const grapeCabernetSauvignon = grape({ /** * @property farmhand.module:items.grapeTempranillo - * @type {Grape} + * @type {farmhand.grape} */ export const grapeTempranillo = grape({ ...fromSeed(grapeSeed, { @@ -158,7 +153,7 @@ export const grapeTempranillo = grape({ /** * @property farmhand.module:items.grapeNebbiolo - * @type {Grape} + * @type {farmhand.grape} */ export const grapeNebbiolo = grape({ ...fromSeed(grapeSeed, { diff --git a/src/enums.js b/src/enums.js index 4f47e8ff2..31b548e54 100644 --- a/src/enums.js +++ b/src/enums.js @@ -183,6 +183,7 @@ export const cowTradeRejectionReason = enumify(['REQUESTED_COW_UNAVAILABLE']) /** * @property farmhand.module:enums.cropFamily * @readonly + * @enum {string} */ export const cropFamily = { GRAPE: 'GRAPE', diff --git a/src/index.js b/src/index.js index 54b968e2b..6c82dbaee 100644 --- a/src/index.js +++ b/src/index.js @@ -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 */ /** @@ -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 @@ -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. */ /** @@ -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 => ReactDOM.render(