summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@vistahigherlearning.com>2022-01-25 17:34:15 -0500
committerDavid Thompson <dthompson@vistahigherlearning.com>2022-01-25 17:34:15 -0500
commite102cf9234d2842d25759d8d5067b10a8f8ed011 (patch)
tree3f177c911195886b50493a33f5578d0138b623a4 /js
parent4579efdad2b09a9ca342005cca4142d1d2b90129 (diff)
Add overwinterPlant property to Crop to support a Garlic crop.
Diffstat (limited to 'js')
-rw-r--r--js/garden.js28
1 files changed, 23 insertions, 5 deletions
diff --git a/js/garden.js b/js/garden.js
index f9f5f06..daf014b 100644
--- a/js/garden.js
+++ b/js/garden.js
@@ -25,7 +25,7 @@ function seasonLengthInWeeks(lastFrostDate, firstFrostDate) {
}
function seasonWeeks(lastFrostDate, seasonLength) {
- return range(-WEEKS_BEFORE_LAST_FROST, seasonLength + 1).map(offset => {
+ return range(-WEEKS_BEFORE_LAST_FROST, seasonLength + 3).map(offset => {
return {
date: weeksLater(lastFrostDate, offset),
offset: offset
@@ -44,8 +44,8 @@ class Season {
class Crop {
constructor(name, {fallCrop, family, headStart, interval, maturity, multisow,
- pause, spacing, springPlant, resume, species,
- transplant, trellis}) {
+ overwinterPlant, pause, spacing, springPlant, resume,
+ species, transplant, trellis}) {
// Plant again in the fall?
this.fallCrop = fallCrop;
// Broad category (brassica, cucurbit, nightshade, etc.)
@@ -60,6 +60,12 @@ class Crop {
this.multisow = multisow || 1;
// Human readable name
this.name = name;
+ // Overwintered crops are fall crops but they are not subject to
+ // the same rules as plants that are harvested the same year.
+ // Instead of planting them relative to their time to maturity,
+ // they are planted relative to the first frost date so they can
+ // be harvested in the spring/summer of the following year.
+ this.overwinterPlant = overwinterPlant;
// When to pause succession planting (weeks after last frost)
this.pause = pause || 99;
// When to resume succession planting (weeks before first frost)
@@ -70,7 +76,8 @@ class Crop {
// Latin names.
this.species = species || [];
// Earliest sowing/transplanting week (offset relative to last
- // frost date.)
+ // frost date.) Null if the crop should not be planted in the
+ // spring.
this.springPlant = springPlant;
// Transplanted or direct sown?
this.transplant = transplant || false;
@@ -247,6 +254,13 @@ const CROPS = [
species: ["foeniculum vulgare"],
springPlant: 0
}),
+ new Crop("Garlic", {
+ fallCrop: true,
+ overwinterPlant: 2,
+ maturity: 28,
+ spacing: 4,
+ species: ["allium sativum"]
+ }),
new Crop("Kale", {
fallCrop: true,
family: "Brassica",
@@ -471,7 +485,11 @@ function makeCropSchedule(crop, season) {
}
if(crop.fallCrop) {
- if(crop.transplant && week.offset == fallStart) {
+ if(crop.overwinterPlant) {
+ if(week.offset == season.length + crop.overwinterPlant) {
+ actions.push("sow");
+ }
+ } else if(crop.transplant && week.offset == fallStart) {
actions.push("start");
} else if(crop.transplant && week.offset == fallPlant) {
actions.push("transplant");