UNPKG

@jeremyckahn/farmhand

Version:
23 lines (17 loc) 609 B
import { WEEDS_SPAWN_CHANCE } from '../../constants.js' import { randomNumberService } from '../../common/services/randomNumber.js' import { weed } from '../../data/items.js' import { getPlotContentFromItemId } from '../../utils/index.js' /** * @param {?farmhand.plotContent} plotContents * @returns {?farmhand.plotContent} */ export function spawnWeeds(plotContents) { if (plotContents) return plotContents let contents = null if (randomNumberService.isRandomNumberLessThan(WEEDS_SPAWN_CHANCE)) { // @ts-expect-error contents = getPlotContentFromItemId(weed.id) } return contents }