UNPKG

@jeremyckahn/farmhand

Version:
24 lines (18 loc) 669 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: farmhand.plotContent | null = null if (randomNumberService.isRandomNumberLessThan(WEEDS_SPAWN_CHANCE)) { contents = getPlotContentFromItemId( (weed as farmhand.item).id ) as farmhand.plotContent } return contents }