From 65325e8a4e7c10e2f18ab09c2748a4598697ed1c Mon Sep 17 00:00:00 2001 From: caidenhaynes Date: Fri, 17 Apr 2026 14:53:16 +0000 Subject: [PATCH 1/4] Added paths for add and pow /path?x=val1&y=val2 --- index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 47b7e31..a607a99 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,17 @@ const app = express(); const port = process.env.PORT || 3000; // Use Codespaces port app.get("/", (req, res) => { - res.json({ message: "Hello from Express!" }); + res.send('Specify /add?x=val1&y=val2, /subtract?x=val1&y=val2, etc.'); +}); + +app.get("/add", (req, res) => { + let sum = parseFloat(req.query.x) + parseFloat(req.query.y); + res.json({sum: sum, x: req.query.x, y: req.query.y}); +}); + +app.get("/pow", (req, res) => { + let pow = req.query.x ** req.query.y; + res.json({pow: pow, x: req.query.x, y: req.query.y}); }); app.listen(port, () => { From 4545d29f34a1a6be5fa7fe2bc4d410513d5f8f5d Mon Sep 17 00:00:00 2001 From: caidenhaynes Date: Thu, 23 Apr 2026 17:35:16 +0000 Subject: [PATCH 2/4] Got rid of both /add and /pow to add /harvest and got variables from query string --- crops.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ index.js | 15 ++++++++------- 2 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 crops.js diff --git a/crops.js b/crops.js new file mode 100644 index 0000000..bc76659 --- /dev/null +++ b/crops.js @@ -0,0 +1,44 @@ +export let crops = { + 'blue jazz' : 50, + carrot : 35, + cauliflower : 175, + 'coffee bean' : 15, + garlic : 60, + 'green bean' : 40, + kale : 110, + parsnip : 35, + potato : 80, + rhubarb : 220, + strawberry : 120, + tulip : 30, + 'unmilled rice' : 30, + blueberry : 50, + corn : 50, + hops : 25, + 'hot pepper' : 40, + melon : 250, + poppy : 140, + radish : 90, + 'red cabbage' : 260, + starfruit : 750, + 'summer spangle' : 90, + 'summer squash' : 45, + sunflower : 80, + tomato : 60, + wheat : 25, + amaranth : 150, + artichoke : 160, + beet : 100, + 'bok choy' : 80, + broccoli : 70, + cranberries : 75, + eggplant : 60, + 'fairy rose' : 290, + grape : 80, + pumpkin : 320, + yam : 160, + powdermelon : 60, + 'ancient fruit' : 550, + 'cactus fruit' : 75, + fiber : 1 +} \ No newline at end of file diff --git a/index.js b/index.js index a607a99..a97ddc7 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ Reflection (including LLM use): */ import express from "express"; +import crops from './crops.js'; const app = express(); const port = process.env.PORT || 3000; // Use Codespaces port @@ -15,14 +16,14 @@ app.get("/", (req, res) => { res.send('Specify /add?x=val1&y=val2, /subtract?x=val1&y=val2, etc.'); }); -app.get("/add", (req, res) => { - let sum = parseFloat(req.query.x) + parseFloat(req.query.y); - res.json({sum: sum, x: req.query.x, y: req.query.y}); -}); +app.get("/harvest", (req, res) => { + //let sum = parseFloat(req.query.x) + parseFloat(req.query.y); + //res.json({sum: sum, x: req.query.x, y: req.query.y}); + let crop = req.query.crop; + let baseValue = crops[crop.toLowerCase()]; + let amount = parseFloat(req.query.amount); + let quality = req.query.quality; -app.get("/pow", (req, res) => { - let pow = req.query.x ** req.query.y; - res.json({pow: pow, x: req.query.x, y: req.query.y}); }); app.listen(port, () => { From f40110dd7aa06cb919c5ee19e8b0ce9c7758cbc5 Mon Sep 17 00:00:00 2001 From: caidenhaynes Date: Thu, 23 Apr 2026 17:54:30 +0000 Subject: [PATCH 3/4] finished the math to figure out the total gold of a harvest --- crops.js | 6 ++++++ index.js | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/crops.js b/crops.js index bc76659..f360ada 100644 --- a/crops.js +++ b/crops.js @@ -41,4 +41,10 @@ export let crops = { 'ancient fruit' : 550, 'cactus fruit' : 75, fiber : 1 +} +export let cropAmount = { + 'coffee bean' : 4, + blueberry : 3, + cranberries : 2, + fiber : 4 } \ No newline at end of file diff --git a/index.js b/index.js index a97ddc7..ea0add0 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ Reflection (including LLM use): import express from "express"; import crops from './crops.js'; +import cropAmount from './crops.js'; const app = express(); const port = process.env.PORT || 3000; // Use Codespaces port @@ -21,9 +22,23 @@ app.get("/harvest", (req, res) => { //res.json({sum: sum, x: req.query.x, y: req.query.y}); let crop = req.query.crop; let baseValue = crops[crop.toLowerCase()]; + let lowestNumCrops = 1; + if (crops.toLowerCase() in cropAmount) { + lowestNumCrops = cropAmount[crops.toLowerCase()]; + } let amount = parseFloat(req.query.amount); let quality = req.query.quality; - + let qualityMultiplyer = 1; + if (quality.toLowerCase() == 'silver') { + qualityMultiplyer = 1.25; + } else if (quality.toLowerCase() == 'gold') { + qualityMultiplyer = 1.5; + } else if (quality.toLowerCase() == 'iridium') { + qualityMultiplyer = 2; + } + baseValue = Math.trunc(baseValue * qualityMultiplyer); + let totalGold = baseValue * amount * lowestNumCrops; + res.json({crop: crop, amount: amount, quality: quality, 'total gold': totalGold}); }); app.listen(port, () => { From ff4fa781765f3dbf8fbbd7f1e0b6cb6a81d4a569 Mon Sep 17 00:00:00 2001 From: caidenhaynes Date: Thu, 23 Apr 2026 18:35:33 +0000 Subject: [PATCH 4/4] Bug fixed some crashes and issues with importing and added reflection comment --- index.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/index.js b/index.js index ea0add0..2cc7649 100644 --- a/index.js +++ b/index.js @@ -1,42 +1,42 @@ /** -Name: -Date: -Description: -Bugs: -Reflection (including LLM use): +Name: Caiden Haynes +Date: 4/23/2026 +Description: API that will send you the minimum amount of money you will get from a harvest in stardew valley specifying crop, amount of that crop, and the quality you expect to get. +Bugs: None Known +Reflection (including LLM use): I had a lot of fun with this project. I decided pretty early on that it would be a good idea to make an api that in some way was connected to a game I play, as that would be the best way to ensure novelty, but I was struggling to come up with an idea that I thought would be useful in anyway. I was scrolling through my steam library for ideas, when I thought about doing it for Stardew Valley. When I play stardew I tend to have a spread sheet open and I am constantly doing math about my crop yield and how much crops I can plant. Using this api would help with planning as it would very quickly show me how much money I could plan around after a harvest. There are a lot of other potential features that I could implement, but most of them seem to complex for me to implement so I decided on a simple, but useful, version that I have. I used chatGPT for help fixing a crash that would occur if the crop wasn't in the JS object. */ import express from "express"; -import crops from './crops.js'; -import cropAmount from './crops.js'; +import { crops, cropAmount } from './crops.js'; const app = express(); const port = process.env.PORT || 3000; // Use Codespaces port app.get("/", (req, res) => { - res.send('Specify /add?x=val1&y=val2, /subtract?x=val1&y=val2, etc.'); + res.send('API tells you the min amount of money you will make from a harvest in Stardew Valley. Specify /harvest?crop=crop&amount=amount&quality=quality'); }); app.get("/harvest", (req, res) => { - //let sum = parseFloat(req.query.x) + parseFloat(req.query.y); - //res.json({sum: sum, x: req.query.x, y: req.query.y}); - let crop = req.query.crop; - let baseValue = crops[crop.toLowerCase()]; + let crop = req.query.crop.toLowerCase(); + let baseValue = crops[crop]; let lowestNumCrops = 1; - if (crops.toLowerCase() in cropAmount) { - lowestNumCrops = cropAmount[crops.toLowerCase()]; + if (crop in cropAmount) { //checks if the crop produces more than a minimum of 1 crop per harvest + lowestNumCrops = cropAmount[crop]; } let amount = parseFloat(req.query.amount); - let quality = req.query.quality; + let quality = req.query.quality.toLowerCase(); let qualityMultiplyer = 1; - if (quality.toLowerCase() == 'silver') { + if (quality == 'silver') { //checks for a silver modifier on crops qualityMultiplyer = 1.25; - } else if (quality.toLowerCase() == 'gold') { + } else if (quality == 'gold') { //checks for a gold modifier on crops qualityMultiplyer = 1.5; - } else if (quality.toLowerCase() == 'iridium') { + } else if (quality == 'iridium' && crop != 'fiber') { //checks for an iridium modifier on crops and that the crop is not fiber as fiber gets no modifier qualityMultiplyer = 2; } - baseValue = Math.trunc(baseValue * qualityMultiplyer); + if (!baseValue) { //checks if there is a base value + return res.json({error: 'Invalid crop'}); //no base value means the crop was not found + } + baseValue = Math.trunc(baseValue * qualityMultiplyer); //base value of crop is the selling price of normal quality * the multiplier from the quality (truncated) let totalGold = baseValue * amount * lowestNumCrops; res.json({crop: crop, amount: amount, quality: quality, 'total gold': totalGold}); });