#include <curses.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
// Item costs, growing times, selling prices, and so on.
// Spring crops.
// Count down towards 0 each time the user ends the day. When the user calls Harvest(), check for crops that have 0 in their .Time and add the value of .Regrow to .Time. Next, check if .Time is 0. If it is, remove the crop since it can only be harvested once.
// At the end of a month, wipe the crops. Obviously.
//Remember Wednsday!
// Add SpeedGro adjusters at some point.
// Figure out how to handle multi-harvest crops for Artisan goods. For now we'll entirely ignore this and just figure out what time it's best to grow which crops and be happy with that, but at some point we'll need to figure out how to handle Potatoes. Blueberries and Cranberries are easy, but Potatoes is weird since it's at 1.25. owo.
// Fopen, fclose.. Need to log what ypu dfp EVERY day in case the run's really good! OwO! Check current directory/StardewSimulatorLogs, just name then 1.txt, 2.txt and so on. owo.
// Consider adding one hour per 100 crops harvested. That's been a problem before at some points for me.
//++ Make it so that the extra space at the bottom of the Crops panel shows like "Crops planted: 0/1,765".
// Line 1017, read around there! Ucj, gotta do so much. <w<'
struct CropStruct {
int ID;
int Seeds;
int Sell;
int Time;
int Regrow;
int Season;
char ShopText[52];
char InventoryTextSeeds[22];
char InventoryTextCrop[22];
};
struct ItemStruct {
int ID;
int Quantity;
char Text[22];
};
struct CropPlotStruct {
int ID;
int Quantity;
int DateSeeded;
int DateHarvest;
int DateRemaining;
// For ease of readability, gunna reference the Crop[] stuff for the name and calculate the sell value on-the-fly every time. Might optimize that later. Might. -w-.
int Watered;
};
int CurrentMonth = 1;
int CurrentDate = 1;
int CurrentDayName = 2; // Figure out what day of the week the game actually starts on. For sanity's sake, let's call Sunday "1", Monday "2" and so on. Makes it easier since Wednesday is "4", which is the very middle of the scale. owo. Remember to somehow tell the user not to buy seeds on this day!
// Starts on Monday. Wheeee. x.x And the calendar says "1" in Stardew. Greaaaaat.
int CurrentGold = 500;
int KeyPressed;
int ActiveWindow = 1;
int ShopSelection = 1;
int ShopQuantity = 1;
int ShopQuantitySelect = 0;
int InventorySelection = 1;
int FarmSelection = 0;
int WorkingCropPlot;
// More initilization. owo.
/* static struct CropStruct Cauliflower;
static struct CropStruct Garlic;
static struct CropStruct GreenBean;
static struct CropStruct Kale;
static struct CropStruct Parsnip;
static struct CropStruct Potato;
static struct CropStruct Rhubarb;
static struct CropStruct Strawberry;
static struct CropStruct BlueJazz;
static struct CropStruct Tulip;
static struct CropStruct Blueberry;
static struct CropStruct Corn;
static struct CropStruct Hops;
static struct CropStruct HotPepper;
static struct CropStruct Melon;
static struct CropStruct Radish;
static struct CropStruct RedCabbage;
static struct CropStruct Starfruit;
static struct CropStruct Tomato;
static struct CropStruct Wheat;
static struct CropStruct Poppy;
static struct CropStruct SummerSpangle;
static struct CropStruct Amaranth;
static struct CropStruct Artichoke;
static struct CropStruct Beet;
static struct CropStruct BokChoy;
static struct CropStruct Cranberries;
static struct CropStruct Eggplant;
static struct CropStruct Grape;
static struct CropStruct Pumpkin;
static struct CropStruct Yam;
static struct CropStruct FairyRose;
static struct CropStruct Sunflower;
static struct CropStruct SweetGemBerry;
static struct CropStruct AncientFruit;
static struct CropStruct Empty; */
/* struct ItemStruct InventorySlotOne;
struct ItemStruct InventorySlotTwo;
struct ItemStruct InventorySlotThree;
struct ItemStruct InventorySlotFour;
struct ItemStruct InventorySlotFive;
struct ItemStruct InventorySlotSix;
struct ItemStruct InventorySlotSeven;
struct ItemStruct InventorySlotEight;
struct ItemStruct InventorySlotNine;
struct ItemStruct InventorySlotTen;
struct ItemStruct InventorySlotEleven;
struct ItemStruct InventorySlotTwelve; */
//struct Item InventorySlotOverflow;
struct CropStruct Crop[36];
struct ItemStruct ItemSlot[13];
struct CropPlotStruct CropPlot[12];
static int Cauliflower = 1;
static int Garlic = 2;
static int GreenBean = 3;
static int Kale = 4;
static int Parsnip = 5;
static int Potato = 6;
static int Rhubarb = 7;
static int Strawberry = 8;
static int BlueJazz = 9;
static int Tulip = 10;
static int Blueberry = 11;
static int Corn = 12;
static int Hops = 13;
static int HotPepper = 14;
static int Melon = 15;
static int Radish = 16;
static int RedCabbage = 17;
static int Starfruit = 18;
static int Tomato = 19;
static int Wheat = 20;
static int Poppy = 21;
static int SummerSpangle = 22;
static int Amaranth = 23;
static int Artichoke = 24;
static int Beet = 25;
static int BokChoy = 26;
static int Cranberries = 27;
static int Eggplant = 28;
static int Grape = 29;
static int Pumpkin = 30;
static int Yam = 31;
static int FairyRose = 32;
static int Sunflower = 33;
static int SweetGemBerry = 34;
static int AncientFruit = 35;
static int Empty = 0;
int MakeCropStructs() {
// Array of references. This is glorious. Thank you so much, Tom-Boudreaux. o_o...
// Spring crops.
Crop[Cauliflower].ID = 1;
Crop[Cauliflower].Seeds = 80;
Crop[Cauliflower].Sell = 175;
Crop[Cauliflower].Time = 12;
Crop[Cauliflower].Regrow = 0;
Crop[Cauliflower].Season = 1;
strncpy(Crop[Cauliflower].ShopText, "Cauliflower Seeds 80G (S/T/R/L/X: 175/12/0/16/ )", 51);
strncpy(Crop[Cauliflower].InventoryTextSeeds, "Cauliflower Seeds", 21);
strncpy(Crop[Cauliflower].InventoryTextCrop, "Cauliflower", 21);
Crop[Garlic].ID = 2;
Crop[Garlic].Seeds = 40;
Crop[Garlic].Sell = 60;
Crop[Garlic].Time = 4;
Crop[Garlic].Regrow = 0;
Crop[Garlic].Season = 1;
strncpy(Crop[Garlic].ShopText, "Garlic Seeds 40G (S/T/R/L/X: 60/ 4/0/24/ )", 51);
strncpy(Crop[Garlic].InventoryTextSeeds, "Garlic Seeds", 21);
strncpy(Crop[Garlic].InventoryTextCrop, "Garlic", 21);
Crop[GreenBean].ID = 3;
Crop[GreenBean].Seeds = 60;
Crop[GreenBean].Sell = 40;
Crop[GreenBean].Time = 10;
Crop[GreenBean].Regrow = 3;
Crop[GreenBean].Season = 1;
strncpy(Crop[GreenBean].ShopText, "GreenBean Seeds 60G (S/T/R/L/X: 40/10/3/14/ )", 51);
strncpy(Crop[GreenBean].InventoryTextSeeds, "GreenBean Seeds", 21);
strncpy(Crop[GreenBean].InventoryTextCrop, "GreenBean", 21);
Crop[Kale].ID = 4;
Crop[Kale].Seeds = 70;
Crop[Kale].Sell = 110;
Crop[Kale].Time = 6;
Crop[Kale].Regrow = 0;
Crop[Kale].Season = 1;
strncpy(Crop[Kale].ShopText, "Kale Seeds 70G (S/T/R/L/X: 110/ 6/0/22/ )", 51);
strncpy(Crop[Kale].InventoryTextSeeds, "Kale Seeds", 21);
strncpy(Crop[Kale].InventoryTextCrop, "Kale", 21);
Crop[Parsnip].ID = 5;
Crop[Parsnip].Seeds = 20;
Crop[Parsnip].Sell = 35;
Crop[Parsnip].Time = 4;
Crop[Parsnip].Regrow = 0;
Crop[Parsnip].Season = 1;
strncpy(Crop[Parsnip].ShopText, "Parsnip Seeds 20G (S/T/R/L/X: 35/ 4/0/24/ )", 51);
strncpy(Crop[Parsnip].InventoryTextSeeds, "Parsnip Seeds", 21);
strncpy(Crop[Parsnip].InventoryTextCrop, "Parsnip", 21);
Crop[Potato].ID = 6;
Crop[Potato].Seeds = 50;
Crop[Potato].Sell = 100; // Real price is 80, but there's about 1.25 potatos per harvest.
Crop[Potato].Time = 6;
Crop[Potato].Regrow = 0;
Crop[Potato].Season = 1;
strncpy(Crop[Potato].ShopText, "Potato Seeds 50G (S/T/R/L/X: 50/ 6/0/22/ )", 51);
strncpy(Crop[Potato].InventoryTextSeeds, "Potato Seeds", 21);
strncpy(Crop[Potato].InventoryTextCrop, "Potato", 21);
Crop[Rhubarb].ID = 7;
Crop[Rhubarb].Seeds = 100;
Crop[Rhubarb].Sell = 220;
Crop[Rhubarb].Time = 13;
Crop[Rhubarb].Regrow = 0;
Crop[Rhubarb].Season = 1;
strncpy(Crop[Rhubarb].ShopText, "Rhubarb Seeds 100G (S/T/R/L/X: 220/13/0/15/ )", 51);
strncpy(Crop[Rhubarb].InventoryTextSeeds, "Rhubarb Seeds", 21);
strncpy(Crop[Rhubarb].InventoryTextCrop, "Rhubarb", 21);
Crop[Strawberry].ID = 8;
Crop[Strawberry].Seeds = 100; // NOTE: These are only available on the 13th of Spring!
Crop[Strawberry].Sell = 120;
Crop[Strawberry].Time = 8;
Crop[Strawberry].Regrow = 4;
Crop[Strawberry].Season = 1;
strncpy(Crop[Strawberry].ShopText, "Strawberry Seeds 100G (S/T/R/L/X: 120/ 8/4/20/ )", 51);
strncpy(Crop[Strawberry].InventoryTextSeeds, "Strawberry Seeds", 21);
strncpy(Crop[Strawberry].InventoryTextCrop, "Strawberry", 21);
Crop[BlueJazz].ID = 9;
Crop[BlueJazz].Seeds = 30;
Crop[BlueJazz].Sell = 50;
Crop[BlueJazz].Time = 7;
Crop[BlueJazz].Regrow = 0;
Crop[BlueJazz].Season = 1;
strncpy(Crop[BlueJazz].ShopText, "BlueJazz Seeds 30G (S/T/R/L/X: 50/ 7/0/21/ )", 51);
strncpy(Crop[BlueJazz].InventoryTextSeeds, "BlueJazz Seeds", 21);
strncpy(Crop[BlueJazz].InventoryTextCrop, "BlueJazz", 21);
Crop[Tulip].ID = 10;
Crop[Tulip].Seeds = 20;
Crop[Tulip].Sell = 30;
Crop[Tulip].Time = 6;
Crop[Tulip].Regrow = 0;
Crop[Tulip].Season = 1;
strncpy(Crop[Tulip].ShopText, "Tulip Seeds 20G (S/T/R/L/X: 30/ 6/0/22/ )", 51);
strncpy(Crop[Tulip].InventoryTextSeeds, "Tulip Seeds", 21);
strncpy(Crop[Tulip].InventoryTextCrop, "Tulip", 21);
// Summer crops.
Crop[Blueberry].ID = 11;
Crop[Blueberry].Seeds = 80;
Crop[Blueberry].Sell = 150; // Actually 80, but always drops 3. ... ... ... Might need to actually work this out to drop three that sell for 80, because Artisan goods. We'll do that when it comes time to actually try to use those.
Crop[Blueberry].Time = 13;
Crop[Blueberry].Regrow = 4;
Crop[Blueberry].Season = 2;
strncpy(Crop[Blueberry].ShopText, "Blueberry Seeds 80G (S/T/R/L/X: 240/13/4/15/5)", 51);
strncpy(Crop[Blueberry].InventoryTextSeeds, "Blueberry Seeds", 21);
strncpy(Crop[Blueberry].InventoryTextCrop, "Blueberry", 21);
//Blueberry.ShopText[52] = "Blueberry Seeds 80G (S/T/R/L/X: 240/13/4/15/5)";
Crop[Corn].ID = 12;
Crop[Corn].Seeds = 150; // This crop is weird. It grows through Summer and Fall. It's easy enough to just tell the Events system not to remove it when the season changes, but it might throw the estimates funny. That said, I know from experience that corn *sucks* compared to blueberries and cranberries, so I doubt that people will complain /too/ hard about this if they're trying to /really/ minmax.
Crop[Corn].Sell = 50;
Crop[Corn].Time = 14;
Crop[Corn].Regrow = 4;
Crop[Corn].Season = 2;
strncpy(Crop[Corn].ShopText, "Corn Seeds 150G (S/T/R/L/X: 50/14/4/14/4) ", 51);
strncpy(Crop[Corn].InventoryTextSeeds, "Corn Seeds", 21);
strncpy(Crop[Corn].InventoryTextCrop, "Corn", 21);
Crop[Hops].ID = 13;
Crop[Hops].Seeds = 60;
Crop[Hops].Sell = 25;
Crop[Hops].Time = 11;
Crop[Hops].Regrow = 1;
Crop[Hops].Season = 2;
strncpy(Crop[Hops].ShopText, "Hop Seeds 60G (S/T/R/L/X: 25/11/1/17/7) ", 51);
strncpy(Crop[Hops].InventoryTextSeeds, "Hops Seeds", 21);
strncpy(Crop[Hops].InventoryTextCrop, "Hops", 21);
Crop[HotPepper].ID = 14;
Crop[HotPepper].Seeds = 40;
Crop[HotPepper].Sell = 40;
Crop[HotPepper].Time = 5;
Crop[HotPepper].Regrow = 3;
Crop[HotPepper].Season = 2;
strncpy(Crop[HotPepper].ShopText, "Hot Pepper Seeds 40G (X/T/R/L/X: 40/5/3/23/13)", 51);
strncpy(Crop[HotPepper].InventoryTextSeeds, "Hot Pepper Seeds", 21);
strncpy(Crop[HotPepper].InventoryTextCrop, "HotPepper", 21);
Crop[Melon].ID = 15;
Crop[Melon].Seeds = 80;
Crop[Melon].Sell = 250;
Crop[Melon].Time = 12;
Crop[Melon].Regrow = 0;
Crop[Melon].Season = 2;
strncpy(Crop[Melon].ShopText, "Melon Seeds 80G (S/T/R/L/X: 220/12/0/16/6) ", 51);
strncpy(Crop[Melon].InventoryTextSeeds, "Melon Seeds", 21);
strncpy(Crop[Melon].InventoryTextCrop, "Melon", 21);
Crop[Radish].ID = 16;
Crop[Radish].Seeds = 40;
Crop[Radish].Sell = 90;
Crop[Radish].Time = 6;
Crop[Radish].Regrow = 0;
Crop[Radish].Season = 2;
strncpy(Crop[Radish].ShopText, "Radish Seeds 40G (S/T/R/L/X: 90/6/0/22/12) ", 51);
strncpy(Crop[Radish].InventoryTextSeeds, "Radish Seeds", 21);
strncpy(Crop[Radish].InventoryTextCrop, "Radish", 21);
Crop[RedCabbage].ID = 17;
Crop[RedCabbage].Seeds = 100;
Crop[RedCabbage].Sell = 260;
Crop[RedCabbage].Time = 9;
Crop[RedCabbage].Regrow = 0;
Crop[RedCabbage].Season = 2;
strncpy(Crop[RedCabbage].ShopText, "Red Cabbage Seeds 100G (S/T/R/L/X: 260/9/0/19/9)", 51);
strncpy(Crop[RedCabbage].InventoryTextSeeds, "Red Cabbage Seeds", 21);
strncpy(Crop[RedCabbage].InventoryTextCrop, "RedCabbage", 21);
Crop[Starfruit].ID = 18;
Crop[Starfruit].Seeds = 400;
Crop[Starfruit].Sell = 750;
Crop[Starfruit].Time = 13;
Crop[Starfruit].Regrow = 0;
Crop[Starfruit].Season = 2;
strncpy(Crop[Starfruit].ShopText, "Starfruit Seeds 400G (S/T/R/L/X: 800/13/0/15/5)", 51);
strncpy(Crop[Starfruit].InventoryTextSeeds, "Starfruit Seeds", 21);
strncpy(Crop[Starfruit].InventoryTextCrop, "Starfruit", 21);
Crop[Tomato].ID = 19;
Crop[Tomato].Seeds = 50;
Crop[Tomato].Sell = 60;
Crop[Tomato].Time = 11;
Crop[Tomato].Regrow = 4;
Crop[Tomato].Season = 2;
strncpy(Crop[Tomato].ShopText, "Tomato Seeds 50G (S/T/R/L/X: 60/11/4/17/7) ", 51);
strncpy(Crop[Tomato].InventoryTextSeeds, "Tomato Seeds", 21);
strncpy(Crop[Tomato].InventoryTextCrop, "Tomato", 21);
Crop[Wheat].ID = 20;
Crop[Wheat].Seeds = 10;
Crop[Wheat].Sell = 25;
Crop[Wheat].Time = 4;
Crop[Wheat].Regrow = 0;
Crop[Wheat].Season = 2;
strncpy(Crop[Wheat].ShopText, "Wheat Seeds 10G (S/T/R/L/X: 25/4/0/24/14) ", 51);
strncpy(Crop[Wheat].InventoryTextSeeds, "Wheat Seeds", 21);
strncpy(Crop[Wheat].InventoryTextCrop, "Wheat", 21);
Crop[Poppy].ID = 21;
Crop[Poppy].Seeds = 100;
Crop[Poppy].Sell = 140;
Crop[Poppy].Time = 7;
Crop[Poppy].Regrow = 0;
Crop[Poppy].Season = 2;
strncpy(Crop[Poppy].ShopText, "Poppy Seeds 100G (S/T/R/L/X/: 140/7/0/21/11) ", 51);
strncpy(Crop[Poppy].InventoryTextSeeds, "Poppy Seeds", 21);
strncpy(Crop[Poppy].InventoryTextCrop, "Poppy", 21);
Crop[SummerSpangle].ID = 22;
Crop[SummerSpangle].Seeds = 50;
Crop[SummerSpangle].Sell = 90;
Crop[SummerSpangle].Time = 8;
Crop[SummerSpangle].Regrow = 0;
Crop[SummerSpangle].Season = 2;
strncpy(Crop[SummerSpangle].ShopText, "Summer Spangle 50G (S/T/R/L/X: 90/8/0/20/10) ", 51);
strncpy(Crop[SummerSpangle].InventoryTextSeeds, "Summer Spangle Seeds", 21);
strncpy(Crop[SummerSpangle].InventoryTextCrop, "SummerSpangle", 21);
// Fall crops.
Crop[Amaranth].ID = 23;
Crop[Amaranth].Seeds = 70;
Crop[Amaranth].Sell = 150;
Crop[Amaranth].Time = 7;
Crop[Amaranth].Regrow = 0;
Crop[Amaranth].Season = 3;
strncpy(Crop[Amaranth].ShopText, "Amaranth Seeds 70G (S/T/R/L/X: 150/ 7/0/21/ )", 51);
strncpy(Crop[Amaranth].InventoryTextSeeds, "Amaranth Seeds", 21);
strncpy(Crop[Amaranth].InventoryTextCrop, "Amaranth", 21);
Crop[Artichoke].ID = 24;
Crop[Artichoke].Seeds = 30;
Crop[Artichoke].Sell = 160;
Crop[Artichoke].Time = 8;
Crop[Artichoke].Regrow = 0;
Crop[Artichoke].Season = 3;
strncpy(Crop[Artichoke].ShopText, "Artichoke Seeds 30G (S/T/R/L/X: 160/ 8/0/20/ 0)", 51);
strncpy(Crop[Artichoke].InventoryTextSeeds, "Artichoke Seeds", 21);
strncpy(Crop[Artichoke].InventoryTextCrop, "Artichoke", 21);
Crop[Beet].ID = 25;
Crop[Beet].Seeds = 20;
Crop[Beet].Sell = 100;
Crop[Beet].Time = 6;
Crop[Beet].Regrow = 0;
Crop[Beet].Season = 3;
strncpy(Crop[Beet].ShopText, "Beet Seeds 20G (S/T/R/L/X: 100/ 6/0/22/ )", 51);
strncpy(Crop[Beet].InventoryTextSeeds, "Beet Seeds", 21);
strncpy(Crop[Beet].InventoryTextCrop, "Beet", 21);
Crop[BokChoy].ID = 26;
Crop[BokChoy].Seeds = 50;
Crop[BokChoy].Sell = 80;
Crop[BokChoy].Time = 4;
Crop[BokChoy].Regrow = 0;
Crop[BokChoy].Season = 3;
strncpy(Crop[BokChoy].ShopText, "BokChoy Seeds 50G (S/T/R/L/X: 80/ 4/0/24/0 ", 51);
strncpy(Crop[BokChoy].InventoryTextSeeds, "BokChoy Seeds", 21);
strncpy(Crop[BokChoy].InventoryTextCrop, "BokChoy", 21);
Crop[Cranberries].ID = 27;
Crop[Cranberries].Seeds = 240;
Crop[Cranberries].Sell = 150; //Really 130, but always harvests two.
Crop[Cranberries].Time = 7;
Crop[Cranberries].Regrow = 5;
Crop[Cranberries].Season = 3;
strncpy(Crop[Cranberries].ShopText, "Cranberry Seeds 240G (S/T/R/L/X: 260/ 7/5/21/ )", 51);
strncpy(Crop[Cranberries].InventoryTextSeeds, "Cranberries Seeds", 21);
strncpy(Crop[Cranberries].InventoryTextCrop, "Cranberries", 21);
Crop[Eggplant].ID = 28;
Crop[Eggplant].Seeds = 20;
Crop[Eggplant].Sell = 60;
Crop[Eggplant].Time = 5;
Crop[Eggplant].Regrow = 5;
Crop[Eggplant].Season = 3;
strncpy(Crop[Eggplant].ShopText, "Eggplant Seeds 20G (S/T/R/L/X: 60/ 5/5/25/ )", 51);
strncpy(Crop[Eggplant].InventoryTextSeeds, "Eggplant Seeds", 21);
strncpy(Crop[Eggplant].InventoryTextCrop, "Eggplant", 21);
Crop[Grape].ID = 29;
Crop[Grape].Seeds = 60;
Crop[Grape].Sell = 80;
Crop[Grape].Time = 10;
Crop[Grape].Regrow = 3;
Crop[Grape].Season = 3;
strncpy(Crop[Grape].ShopText, "Grape Seeds 60G (S/T/R/L/X: 80/10/3/14/0 ", 51);
strncpy(Crop[Grape].InventoryTextSeeds, "Grape Seeds", 21);
strncpy(Crop[Grape].InventoryTextCrop, "Grape", 21);
Crop[Pumpkin].ID = 30;
Crop[Pumpkin].Seeds = 100;
Crop[Pumpkin].Sell = 320;
Crop[Pumpkin].Time = 13;
Crop[Pumpkin].Regrow = 0;
Crop[Pumpkin].Season = 3;
strncpy(Crop[Pumpkin].ShopText, "Pumpkin Seeds 100G (S/T/R/L/X: 320/13/0/15/0 ", 51);
strncpy(Crop[Pumpkin].InventoryTextSeeds, "Pumpkin Seeds", 21);
strncpy(Crop[Pumpkin].InventoryTextCrop, "Pumpkin", 21);
Crop[Yam].ID = 31;
Crop[Yam].Seeds = 60;
Crop[Yam].Sell = 160;
Crop[Yam].Time = 10;
Crop[Yam].Regrow = 0;
Crop[Yam].Season = 3;
strncpy(Crop[Yam].ShopText, "Yam Seeds 60G (S/T/R/L/X: 160/10/0/14/ ", 51);
strncpy(Crop[Yam].InventoryTextSeeds, "Yam Seeds", 21);
strncpy(Crop[Yam].InventoryTextCrop, "Yam", 21);
Crop[FairyRose].ID = 32;
Crop[FairyRose].Seeds = 200;
Crop[FairyRose].Sell = 290;
Crop[FairyRose].Time = 12;
Crop[FairyRose].Regrow = 0;
Crop[FairyRose].Season = 3;
strncpy(Crop[FairyRose].ShopText, "FairyRose Seeds 200G (S/T/R/L/X: 290/12/0/16/ )", 51);
strncpy(Crop[FairyRose].InventoryTextSeeds, "FairyRose Seeds", 21);
strncpy(Crop[FairyRose].InventoryTextCrop, "FairyRose", 21);
// Sunflowers are a mess here. In reality they produce seeds when harvested and don't automatically regrow. While this will be mildly trivial to add since we have an inventory system, for the moment I'm just super-simplifying it and fudging the numbers a bunch. Actual values are commented by the values.
Crop[Sunflower].ID = 33; // 33
Crop[Sunflower].Seeds = 200; // 200
Crop[Sunflower].Sell = 80; // 80
Crop[Sunflower].Time = 8; // 8
Crop[Sunflower].Regrow = 6; // 0
Crop[Sunflower].Season = 3;
strncpy(Crop[Sunflower].ShopText, "Sunflower Seeds 200G (S/T/R/L/X: 80/ 8/6/20/ )", 51);
strncpy(Crop[Sunflower].InventoryTextSeeds, "Sunflower Seeds", 21);
strncpy(Crop[Sunflower].InventoryTextCrop, "Sunflower", 21);
// Special seeds.
Crop[SweetGemBerry].ID = 34;
Crop[SweetGemBerry].Seeds = 1000;
Crop[SweetGemBerry].Sell = 3000;
Crop[SweetGemBerry].Time = 24;
Crop[SweetGemBerry].Regrow = 0;
Crop[SweetGemBerry].Season = 3;
strncpy(Crop[SweetGemBerry].ShopText, "Rare Seeds 1000G (S/T/R/L/X: 3000/24/0/4/*) ", 51);
strncpy(Crop[SweetGemBerry].InventoryTextSeeds, "Rare Seeds", 21);
strncpy(Crop[SweetGemBerry].InventoryTextCrop, "SweetGemBerry", 21);
Crop[AncientFruit].ID = 35;
Crop[AncientFruit].Seeds = 0;
Crop[AncientFruit].Sell = 550;
Crop[AncientFruit].Time = 28;
Crop[AncientFruit].Regrow = 7;
Crop[AncientFruit].Season = 0;
strncpy(Crop[AncientFruit].ShopText, "Ancient Seeds 0G (S/T/R/L/X: 750/28/7/0/*) ", 51);
strncpy(Crop[AncientFruit].InventoryTextSeeds, "Ancient Seeds", 21);
strncpy(Crop[AncientFruit].InventoryTextCrop, "AncientFruit", 21);
Crop[Empty].ID = 0;
Crop[Empty].Seeds = 0;
Crop[Empty].Sell = 0;
Crop[Empty].Time = 0;
Crop[Empty].Regrow = 0;
Crop[Empty].Season = 0;
Crop[Empty].ShopText[0] = '\0';
Crop[Empty].InventoryTextSeeds[0] = '\0';
Crop[Empty].InventoryTextCrop[0] = '\0';
/*strncpy(Crop[Empty].ShopText, '\0', 51);
strncpy(Crop[Empty].InventoryTextSeeds, '\0', 21);
strncpy(Crop[Empty].InventoryTextCrop, '\0', 21);*/
// Whew...
return 0;
}
int MakeInventoryStructs() {
int i;
for(i=0; i<12; i++) {
ItemSlot[i].ID = 0;
ItemSlot[i].Quantity = 0;
ItemSlot[i].Text[0] = '\0';
}
/*
InventorySlotOne.ItemName = 0;
InventorySlotOne.ItemQuantity = 0;
InventorySlotTwo.ItemName = 0;
InventorySlotTwo.ItemQuantity = 0;
InventorySlotThree.ItemName = 0;
InventorySlotThree.ItemQuantity = 0;
InventorySlotFour.ItemName = 0;
InventorySlotFour.ItemQuantity = 0;
InventorySlotFive.ItemName = 0;
InventorySlotFive.ItemQuantity = 0;
InventorySlotSix.ItemName = 0;
InventorySlotSix.ItemQuantity = 0;
InventorySlotSeven.ItemName = 0;
InventorySlotSeven.ItemQuantity = 0;
InventorySlotEight.ItemName = 0;
InventorySlotEight.ItemQuantity = 0;
InventorySlotNine.ItemName = 0;
InventorySlotNine.ItemQuantity = 0;
InventorySlotTen.ItemName = 0;
InventorySlotTen.ItemQuantity = 0;
InventorySlotEleven.ItemName = 0;
InventorySlotEleven.ItemQuantity = 0;
InventorySlotTwelve.ItemName = 0;
InventorySlotTwelve.ItemQuantity = 0;*/
return 0;
}
int MakeCropPlotStructs() {
int i;
for(i=0; i<12; i++) {
CropPlot[i].ID = 0;
}
return 0;
}
// Window declorations.
WINDOW *WindowStats; // Top left.
WINDOW *WindowQuickref; // Top right.
WINDOW *WindowInventory; // Middle left.
WINDOW *WindowCaneldar; // Bottom part of the Inventory.
WINDOW *WindowShop; // Middle right.
WINDOW *WindowFarm; // Big guy on the bottom left.
WINDOW *WindowGreenhouse; // Top of bottom right.
WINDOW *WindowArtisan; //Bottom of bottom right.
WINDOW *WindowCrop[12];
/*WINDOW *WindowCropOne; // Top left.
WINDOW *WindowCropTwo; // Under it.
WINDOW *WindowCropThree; // Under..
WINDOW *WindowCropFour; // Still under...
WINDOW *WindowCropFive; // Guess what? Under!
WINDOW *WindowCropSix; // UNDER! O_O!
WINDOW *WindowCropSeven; // Top right!
WINDOW *WindowCropEight; // Under that.
WINDOW *WindowCropNine; // And so it goes.
WINDOW *WindowCropTen; // And goes.
WINDOW *WindowCropEleven; // Still going...
WINDOW *WindowCropTwelve; // Done.*/
int CreateWindowsInMemory() {
// Major windows.
WindowStats = newwin(4, 42, 0, 0);
WindowQuickref = newwin(4, 58, 0, 42);
WindowInventory = newwin(17, 42, 4, 0);
WindowShop = newwin(17, 58, 4, 42);
WindowFarm = newwin(29, 79, 21, 0);
box(WindowStats, 0, 0);
box(WindowQuickref, 0, 0);
box(WindowInventory, 0, 0);
box(WindowShop, 0, 0);
box(WindowFarm, 0, 0);
refresh();
wrefresh(WindowStats);
wrefresh(WindowQuickref);
wrefresh(WindowInventory);
wrefresh(WindowShop);
wrefresh(WindowFarm);
WindowCrop[0] = subwin(WindowFarm, 4, 37, 23, 2);
WindowCrop[1] = subwin(WindowFarm, 4, 37, 27, 2);
WindowCrop[2] = subwin(WindowFarm, 4, 37, 31, 2);
WindowCrop[3] = subwin(WindowFarm, 4, 37, 35, 2);
WindowCrop[4] = subwin(WindowFarm, 4, 37, 39, 2);
WindowCrop[5] = subwin(WindowFarm, 4, 37, 43, 2);
WindowCrop[6] = subwin(WindowFarm, 4, 37, 23, 40);
WindowCrop[7] = subwin(WindowFarm, 4, 37, 27, 40);
WindowCrop[8] = subwin(WindowFarm, 4, 37, 31, 40);
WindowCrop[9] = subwin(WindowFarm, 4, 37, 35, 40);
WindowCrop[10] = subwin(WindowFarm, 4, 37, 39, 40);
WindowCrop[11] = subwin(WindowFarm, 4, 37, 43, 40);
/*WindowCropOne = subwin(WindowFarm, 4, 37, 23, 2);
WindowCropTwo = subwin(WindowFarm, 4, 37, 27, 2);
WindowCropThree = subwin(WindowFarm, 4, 37, 31, 2);
WindowCropFour = subwin(WindowFarm, 4, 37, 35, 2);
WindowCropFive = subwin(WindowFarm, 4, 37, 39, 2);
WindowCropSix = subwin(WindowFarm, 4, 37, 43, 2);
WindowCropSeven = subwin(WindowFarm, 4, 37, 23, 40);
WindowCropEight = subwin(WindowFarm, 4, 37, 27, 40);
WindowCropNine = subwin(WindowFarm, 4, 37, 31, 40);
WindowCropTen = subwin(WindowFarm, 4, 37, 35, 40);
WindowCropEleven = subwin(WindowFarm, 4, 37, 39, 40);
WindowCropTwelve = subwin(WindowFarm, 4, 37, 43, 40);*/
return 0;
}
int SwitchActiveWindow() {
wborder(WindowStats, ACS_VLINE | A_NORMAL, ACS_VLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_ULCORNER | A_NORMAL, ACS_URCORNER | A_NORMAL, ACS_LLCORNER | A_NORMAL, ACS_LRCORNER | A_NORMAL);
wborder(WindowQuickref, ACS_VLINE | A_NORMAL, ACS_VLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_ULCORNER | A_NORMAL, ACS_URCORNER | A_NORMAL, ACS_LLCORNER | A_NORMAL, ACS_LRCORNER | A_NORMAL);
wborder(WindowInventory, ACS_VLINE | A_NORMAL, ACS_VLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_ULCORNER | A_NORMAL, ACS_URCORNER | A_NORMAL, ACS_LLCORNER | A_NORMAL, ACS_LRCORNER | A_NORMAL);
wborder(WindowShop, ACS_VLINE | A_NORMAL, ACS_VLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_ULCORNER | A_NORMAL, ACS_URCORNER | A_NORMAL, ACS_LLCORNER | A_NORMAL, ACS_LRCORNER | A_NORMAL);
wborder(WindowFarm, ACS_VLINE | A_NORMAL, ACS_VLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_ULCORNER | A_NORMAL, ACS_URCORNER | A_NORMAL, ACS_LLCORNER | A_NORMAL, ACS_LRCORNER | A_NORMAL);
mvwaddch(WindowInventory, 13, 0, ACS_LTEE | A_NORMAL);
mvwaddch(WindowInventory, 13, 41, ACS_RTEE | A_NORMAL);
wnoutrefresh(WindowStats);
wnoutrefresh(WindowQuickref);
wnoutrefresh(WindowInventory);
wnoutrefresh(WindowShop);
wnoutrefresh(WindowFarm);
if(ActiveWindow == 1) { // WindowStats
wborder(WindowStats, ACS_VLINE | A_BOLD, ACS_VLINE | A_BOLD, ACS_HLINE | A_BOLD, ACS_HLINE | A_BOLD, ACS_ULCORNER | A_BOLD, ACS_URCORNER | A_BOLD, ACS_LLCORNER | A_BOLD, ACS_LRCORNER | A_BOLD);
wrefresh(WindowStats);
}
if(ActiveWindow == 2) { // WindowQuickref
wborder(WindowQuickref, ACS_VLINE | A_BOLD, ACS_VLINE | A_BOLD, ACS_HLINE | A_BOLD, ACS_HLINE | A_BOLD, ACS_ULCORNER | A_BOLD, ACS_URCORNER | A_BOLD, ACS_LLCORNER | A_BOLD, ACS_LRCORNER | A_BOLD);
wrefresh(WindowQuickref);
}
if(ActiveWindow == 3) { // WindowInventory
wborder(WindowInventory, ACS_VLINE | A_BOLD, ACS_VLINE | A_BOLD, ACS_HLINE | A_BOLD, ACS_HLINE | A_BOLD, ACS_ULCORNER | A_BOLD, ACS_URCORNER | A_BOLD, ACS_LLCORNER | A_BOLD, ACS_LRCORNER | A_BOLD);
mvwaddch(WindowInventory, 13, 0, ACS_LTEE | A_BOLD);
mvwaddch(WindowInventory, 13, 41, ACS_RTEE | A_BOLD);
wrefresh(WindowInventory);
}
if(ActiveWindow == 4) { // WindowShop
wborder(WindowShop, ACS_VLINE | A_BOLD, ACS_VLINE | A_BOLD, ACS_HLINE | A_BOLD, ACS_HLINE | A_BOLD, ACS_ULCORNER | A_BOLD, ACS_URCORNER | A_BOLD, ACS_LLCORNER | A_BOLD, ACS_LRCORNER | A_BOLD);
wrefresh(WindowShop);
}
if(ActiveWindow == 5) { // WindowFarm
wborder(WindowFarm, ACS_VLINE | A_BOLD, ACS_VLINE | A_BOLD, ACS_HLINE | A_BOLD, ACS_HLINE | A_BOLD, ACS_ULCORNER | A_BOLD, ACS_URCORNER | A_BOLD, ACS_LLCORNER | A_BOLD, ACS_LRCORNER | A_BOLD );
wrefresh(WindowFarm);
}
return 0;
}
int DrawStaticElements(int i) {
int j;
// Setting up static content of major windows.
if(i == 0 || i == 1) {
mvwprintw(WindowStats, 1, 1, "Date: Stam: Gold: .........G");
mvwprintw(WindowStats, 2, 1, "Day: Season: ");
wrefresh(WindowStats);
}
if(i == 0 || i == 2) {
mvwprintw(WindowQuickref, 1, 1, " (W)ater All (H)arvest All (N)ext Day (Tab/`) Select ");
mvwprintw(WindowQuickref, 2, 1, " F1-F5/Arrows move, Enter selects, Esc cancels (R)ain ");
wrefresh(WindowQuickref);
}
if(i == 0 || i == 3) {
mvwprintw(WindowInventory, 1, 1, " 1. ");
mvwprintw(WindowInventory, 2, 1, " 2. ");
mvwprintw(WindowInventory, 3, 1, " 3. ");
mvwprintw(WindowInventory, 4, 1, " 4. ");
mvwprintw(WindowInventory, 5, 1, " 5. ");
mvwprintw(WindowInventory, 6, 1, " 6. ");
mvwprintw(WindowInventory, 7, 1, " 7. ");
mvwprintw(WindowInventory, 8, 1, " 8. ");
mvwprintw(WindowInventory, 9, 1, " 9. ");
mvwprintw(WindowInventory, 10, 1, " 10. ");
mvwprintw(WindowInventory, 11, 1, " 11. ");
mvwprintw(WindowInventory, 12, 1, " 12. ");
//mvwprintw(WindowInventory, 13, 0, "+---------------------------------------¦");
mvwaddch(WindowInventory, 13, 0, ACS_LTEE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_HLINE);
waddch(WindowInventory, ACS_RTEE);
mvwprintw(WindowInventory, 14, 1, " Sun Mon Tues WEDNESDAY Thurs Fri Sat ");
wrefresh(WindowInventory);
}
if(i == 0 || i == 4) {
mvwprintw(WindowShop, 1, 1, " 1.");
mvwprintw(WindowShop, 2, 1, " 2.");
mvwprintw(WindowShop, 3, 1, " 3.");
mvwprintw(WindowShop, 4, 1, " 4.");
mvwprintw(WindowShop, 5, 1, " 5.");
mvwprintw(WindowShop, 6, 1, " 6.");
mvwprintw(WindowShop, 7, 1, " 7.");
mvwprintw(WindowShop, 8, 1, " 8.");
mvwprintw(WindowShop, 9, 1, " 9.");
mvwprintw(WindowShop, 10, 1, "10.");
mvwprintw(WindowShop, 11, 1, "11.");
mvwprintw(WindowShop, 12, 1, "12.");
mvwprintw(WindowShop, 13, 1, "13.");
mvwprintw(WindowShop, 14, 1, "14.");
mvwprintw(WindowShop, 15, 1, "BUY 1 BUY 5 BUY 9 BUY 10 BUY 25 BUY 36 BUY 100");
//waddch(WindowShop, ACS_VLINE);
//wprintw(WindowShop, "ALL");
wrefresh(WindowShop);
}
// Minor windows and static content.
if(i == 0 || i == 5) {
for(j=0; j<12; j++) {
box(WindowCrop[j], 0, 0);
mvwprintw(WindowCrop[j], 1, 1, "Crop: ");
mvwprintw(WindowCrop[j], 2, 1, "Seeded: Harvest: ToGo: DRY");
wrefresh(WindowCrop[j]);
}
/*box(WindowCropOne, 0, 0);
mvwprintw(WindowCropOne, 1, 1, "Crop: ");
mvwprintw(WindowCropOne, 2, 1, "Seeded: Harvest: ToGo: DRY");
wrefresh(WindowCropOne);
box(WindowCropTwo, 0, 0);
mvwprintw(WindowCropTwo, 1, 1, "Crop: ");
mvwprintw(WindowCropTwo, 2, 1, "Seeded: Harvest: ToGo: DRY");
wrefresh(WindowCropTwo);
box(WindowCropThree, 0, 0);
mvwprintw(WindowCropThree, 1, 1, "Crop: ");
mvwprintw(WindowCropThree, 2, 1, "Seeded: Harvest: ToGo: DRY");
wrefresh(WindowCropThree);
box(WindowCropFour, 0, 0);
mvwprintw(WindowCropFour, 1, 1, "Crop: ");
mvwprintw(WindowCropFour, 2, 1, "Seeded: Harvest: ToGo: DRY");
wrefresh(WindowCropFour);
box(WindowCropFive, 0, 0);
mvwprintw(WindowCropFive, 1, 1, "Crop: ");
mvwprintw(WindowCropFive, 2, 1, "Seeded: Harvest: ToGo: DRY");
wrefresh(WindowCropFive);
box(WindowCropSix, 0, 0);
mvwprintw(WindowCropSix, 1, 1, "Crop: ");
mvwprintw(WindowCropSix, 2, 1, "Seeded: Harvest: ToGo: DRY");
wrefresh(WindowCropSix);
box(WindowCropSeven, 0, 0);
mvwprintw(WindowCropSeven, 1, 1, "Crop: ");
mvwprintw(WindowCropSeven, 2, 1, "Seeded: Harvest: ToGo: DRY");
wrefresh(WindowCropSeven);
box(WindowCropEight, 0, 0);
mvwprintw(WindowCropEight, 1, 1, "Crop: ");
mvwprintw(WindowCropEight, 2, 1, "Seeded: Harvest: ToGo: DRY");
wrefresh(WindowCropEight);
box(WindowCropNine, 0, 0);
mvwprintw(WindowCropNine, 1, 1, "Crop: ");
mvwprintw(WindowCropNine, 2, 1, "Seeded: Harvest: ToGo: DRY");
wrefresh(WindowCropNine);
box(WindowCropTen, 0, 0);
mvwprintw(WindowCropTen, 1, 1, "Crop: ");
mvwprintw(WindowCropTen, 2, 1, "Seeded: Harvest: ToGo: DRY");
wrefresh(WindowCropTen);
box(WindowCropEleven, 0, 0);
mvwprintw(WindowCropEleven, 1, 1, "Crop: ");
mvwprintw(WindowCropEleven, 2, 1, "Seeded: Harvest: ToGo: DRY");
wrefresh(WindowCropEleven);
box(WindowCropTwelve, 0, 0);
mvwprintw(WindowCropTwelve, 1, 1, "Crop: ");
mvwprintw(WindowCropTwelve, 2, 1, "Seeded: Harvest: ToGo: DRY");
wrefresh(WindowCropTwelve);*/
}
SwitchActiveWindow(); // To draw the highlighted border. owo.
return 0;
}
int StackInventoryItems() {
int i;
for(i=0; i<13; i++) {
if(ItemSlot[10].Text[0] == '\0') {
strcpy(ItemSlot[10].Text, ItemSlot[11].Text);
ItemSlot[10].Quantity = ItemSlot[11].Quantity;
ItemSlot[10].ID = ItemSlot[11].ID;
ItemSlot[11].Text[0] = '\0';
ItemSlot[11].Quantity = 0;
ItemSlot[11].ID = -1; // Because clearly I didn't think ahead when I made Cauliflower "0".
}
if(ItemSlot[9].Text[0] == '\0') {
strcpy(ItemSlot[9].Text, ItemSlot[10].Text);
ItemSlot[9].Quantity = ItemSlot[10].Quantity;
ItemSlot[9].ID = ItemSlot[10].ID;
ItemSlot[10].Text[0] = '\0';
ItemSlot[10].Quantity = 0;
ItemSlot[10].ID = -1;
}
if(ItemSlot[8].Text[0] == '\0') {
strcpy(ItemSlot[8].Text, ItemSlot[9].Text);
ItemSlot[8].Quantity = ItemSlot[9].Quantity;
ItemSlot[8].ID = ItemSlot[9].ID;
ItemSlot[9].Text[0] = '\0';
ItemSlot[9].Quantity = 0;
ItemSlot[9].ID = -1;
}
if(ItemSlot[7].Text[0] == '\0') {
strcpy(ItemSlot[7].Text, ItemSlot[8].Text);
ItemSlot[7].Quantity = ItemSlot[8].Quantity;
ItemSlot[7].ID = ItemSlot[8].ID;
ItemSlot[8].Text[0] = '\0';
ItemSlot[8].Quantity = 0;
ItemSlot[8].ID = -1;
}
if(ItemSlot[6].Text[0] == '\0') {
strcpy(ItemSlot[6].Text, ItemSlot[7].Text);
ItemSlot[6].Quantity = ItemSlot[7].Quantity;
ItemSlot[6].ID = ItemSlot[7].ID;
ItemSlot[7].Text[0] = '\0';
ItemSlot[7].Quantity = 0;
ItemSlot[7].ID = -1;
}
if(ItemSlot[5].Text[0] == '\0') {
strcpy(ItemSlot[5].Text, ItemSlot[6].Text);
ItemSlot[5].Quantity = ItemSlot[6].Quantity;
ItemSlot[5].ID = ItemSlot[6].ID;
ItemSlot[6].Text[0] = '\0';
ItemSlot[6].Quantity = 0;
ItemSlot[6].ID = -1;
}
if(ItemSlot[4].Text[0] == '\0') {
strcpy(ItemSlot[4].Text, ItemSlot[5].Text);
ItemSlot[4].Quantity = ItemSlot[5].Quantity;
ItemSlot[4].ID = ItemSlot[5].ID;
ItemSlot[5].Text[0] = '\0';
ItemSlot[5].Quantity = 0;
ItemSlot[5].ID = -1;
}
if(ItemSlot[3].Text[0] == '\0') {
strcpy(ItemSlot[3].Text, ItemSlot[4].Text);
ItemSlot[3].Quantity = ItemSlot[4].Quantity;
ItemSlot[3].ID = ItemSlot[4].ID;
ItemSlot[4].Text[0] = '\0';
ItemSlot[4].Quantity = 0;
ItemSlot[4].ID = -1;
}
if(ItemSlot[2].Text[0] == '\0') {
strcpy(ItemSlot[2].Text, ItemSlot[3].Text);
ItemSlot[2].Quantity = ItemSlot[3].Quantity;
ItemSlot[2].ID = ItemSlot[3].ID;
ItemSlot[3].Text[0] = '\0';
ItemSlot[3].Quantity = 0;
ItemSlot[3].ID = -1;
}
if(ItemSlot[1].Text[0] == '\0') {
strcpy(ItemSlot[1].Text, ItemSlot[2].Text);
ItemSlot[1].Quantity = ItemSlot[2].Quantity;
ItemSlot[1].ID = ItemSlot[2].ID;
ItemSlot[2].Text[0] = '\0';
ItemSlot[2].Quantity = 0;
ItemSlot[2].ID = -1;
}
if(ItemSlot[0].Text[0] == '\0') {
strcpy(ItemSlot[0].Text, ItemSlot[1].Text);
ItemSlot[0].Quantity = ItemSlot[1].Quantity;
ItemSlot[0].ID = ItemSlot[1].ID;
ItemSlot[1].Text[0] = '\0';
ItemSlot[1].Quantity = 0;
ItemSlot[1].ID = -1;
}
}
return 0;
}
int InitalizeNewGame() {
mvwprintw(WindowStats, 1, 8, "1");
mvwprintw(WindowStats, 1, 18, "270");
mvwprintw(WindowStats, 1, 36, "500");
waddch(WindowStats, 'G');
mvwprintw(WindowStats, 2, 7, "(2) Monday");
mvwprintw(WindowStats, 2, 30, "(1) Spring");
wrefresh(WindowStats);
MakeInventoryStructs();
strcpy(ItemSlot[0].Text, "Parsnip Seeds");
ItemSlot[0].Quantity = 15;
ItemSlot[0].ID = 5;
UpdateWindowInventory();
return 0;
}
int RemoveCrop(int j) {
CropPlot[j].ID = 0;
CropPlot[j].Quantity = 0;
CropPlot[j].DateSeeded = 0;
CropPlot[j].DateHarvest = 0;
return 0;
}
int GrowCrops() {
int i;
for(i=0; i<12; i++) {
if(CropPlot[i].ID != 0) {
if(CropPlot[i].DateRemaining != 0) {
if(CropPlot[i].Watered == 1) {
CropPlot[i].DateRemaining = CropPlot[i].DateRemaining - 1;
}
}
}
}
UpdateWindowFarm();
return 0;
}
int DoHarvest() {
int i;
int k; // &Being used to calculate how much a sale should be worth. Probably not needed anymore, but will be needed(?) in SellItem().
for(i=0; i<12; i++) {
if(CropPlot[i].ID != 0) {
if(CropPlot[i].DateRemaining == 0) { // All valid, let's do a harvest.
if(ItemSlot[11].Text[0] == '\0') { // If final inventory slot is empty, thus we have space in the inventory..
// First we gotta put the desired item into slot 12, the 'overflow slot'. This isn't ever actually shown to the user; it's just used so we can make the item entry first and then put it where it needs to go in the inventory list instead of trying to do it the other way around.
// **PICK UP FROM HERE THIS IS UNDONE ***
/*k = Crop[CropPlot[i].ID].Sell * CropPlot[i].Quantity;
CurrentGold = CurrentGold + k;*/
if(Crop[CropPlot[i].ID].Regrow > 0) {
CropPlot[i].DateRemaining += Crop[CropPlot[i].ID].Regrow;
CropPlot[i].DateHarvest += Crop[CropPlot[i].ID].Regrow;
}
else {
CropPlot[i].ID = 0;
CropPlot[i].Quantity = 0;
CropPlot[i].DateSeeded = 0;
CropPlot[i].DateHarvest = 0;
}
UpdateWindowFarm();
UpdateWindowStats();
}
}
}
return 0;
}
int BuyItem() {
//ShopSelection
//ShopQuantity
//CurrentMonth
int i; // Crop selection counter.
int j; // Slot-occupationifier-chekcifier-countifier-variabifiliacifir-thing. owo.
int k = 1; // Because I can't remember how to write a "Negative If" statement. <w<'...
int Cost;
// 0 - 9 for Spring.
// 10 - 21 for Summer.
// 22 - 32 for Autumn.
if(ItemSlot[11].Text[0] == '\0') {
if(CurrentMonth == 1) {
i = 0;
}
else if(CurrentMonth == 2) {
i = 10;
}
else if(CurrentMonth == 3) {
i = 22;
}
if(ShopSelection == 12) {
i = 34;
}
else if(ShopSelection == 13) {
i = 35;
}
i = (ShopSelection + i);
// GoldCalculation();
Cost = Crop[i].Seeds * ShopQuantity;
if(CurrentGold >= Cost) {
strncpy(ItemSlot[12].Text, Crop[i].InventoryTextSeeds, 21);
ItemSlot[12].ID = Crop[i].ID; // Yeah, I know, I can just copy "i" here instead of having a reference to the ID in the Array. I'd rather not rely on the list being in perfect order, just in case, so I'm doing it this way. Besides, it makes it easier since Empty isn't 0 and Cauliflower is. owo.
ItemSlot[12].Quantity = ShopQuantity;
//Item is now in the "Overflow" slot.
//Now we need to check if another item has the same name.
for(j=0; j<12 && k == 1; j++) {
if(ItemSlot[j].ID == ItemSlot[12].ID) {
k = 0;
}
}
//k = strcmp(ItemSlot[j].Text, ItemSlot[12].Text);
if(k == 0) {
k = 1;
j--;
ItemSlot[j].Quantity = ItemSlot[j].Quantity + ShopQuantity;
}
else {
strcpy(ItemSlot[11].Text, ItemSlot[12].Text);
ItemSlot[11].Quantity = ItemSlot[12].Quantity;
ItemSlot[11].ID = ItemSlot[12].ID;
}
CurrentGold = CurrentGold - Cost;
StackInventoryItems();
UpdateWindowInventory();
DrawStaticElements(3);
UpdateWindowStats();
}
else {
// 'You don't have enough money!' here.
}
}
else {
// 'Full inventory!' here.
}
return 0;
}
int SellItem() {
//InventorySelection
//ItemSlot[0].Quantity
int k;
k = Crop[ItemSlot[InventorySelection-1].ID].Seeds * ItemSlot[InventorySelection-1].Quantity;
CurrentGold = CurrentGold + k;
ItemSlot[InventorySelection-1].ID = -1;
ItemSlot[InventorySelection-1].Quantity = 0;
ItemSlot[InventorySelection-1].Text[0] = '\0';
StackInventoryItems();
UpdateWindowStats();
UpdateWindowInventory();
return 0;
}
int PlantSeeds() {
//InventorySelection
//WorkingCropPlot
int i;
/* Okay, the process is going to be *something*, man. o_o...
So, here's my issue: Unlike the inventory, I don't want these plots to "move" and autostack. This creates some very obvious management problems!
...Oh, duh. We can just For i=0 over them all and poke the first empty one. Derp.
Selecting one would be nice, but we'll add that /later/. Functionality first. <w<...
Anyway! So we'll just iterate over them all, first empty one we come across breaks the loop and we're happy. Loop counter'll say "12" when it's done, so
if we get that, we know we ran out. (Check "if i==12") -- Don't plant stuff if the farm's full, obviously! OwO!
Anyway, general procedure:
* User hits P from their inventory.
* Loop through the CropPlots. Break(); if one has an .ID of 0.
* If we don't Break();, SUPER-DUPER-BREAK() after that and don't do anything!
* Copy Crop[].ID to the located CropPlot, along with all other relevant information.
* Remove the item from the user's inventory.
* StackInventoryItems();
That's all for the moment. Right now we're just gunna plant stuff, not make it grow. owo. */
for(i=0; i<12; i++) {
if(CropPlot[i].ID == 0) {
WorkingCropPlot = i;
break; // YO! YO! YO!!!! CHECK HERE! "i" may need to have "1" subtracted from it! I'm not sure when "break" happens! DEBUG!! OWO!!!!
// All good. It's 0, owo.
}
}
if(i == 12) {
return 1;
}
CropPlot[WorkingCropPlot].ID = ItemSlot[InventorySelection-1].ID;
CropPlot[WorkingCropPlot].Quantity = ItemSlot[InventorySelection-1].Quantity;
CropPlot[WorkingCropPlot].DateSeeded = CurrentDate;
CropPlot[WorkingCropPlot].DateHarvest = CurrentDate + Crop[CropPlot[WorkingCropPlot].ID].Time;
CropPlot[WorkingCropPlot].DateRemaining = Crop[CropPlot[WorkingCropPlot].ID].Time;
//CropPlot[WorkingCropPlot].Watered = 0; -- Want to keep it watered if it's already watered. owo.
// Should be planted now. owo.
ItemSlot[InventorySelection-1].ID = -1;
ItemSlot[InventorySelection-1].Quantity = 0;
ItemSlot[InventorySelection-1].Text[0] = '\0';
UpdateWindowFarm();
StackInventoryItems();
return 0;
}
/*if(CurrentMonth == 1) {
if(ShopSelection == 1) {
if(InventorySlotTwelve.ItemName == 0) {
InventorySlotTwelve.ItemName = 1;
if(ShopQuantity == 1) {
InventorySlotTwelve.ItemQuantity = InventorySlotTwelve.ItemQuantity+1;
}
else if(ShopQuantity == 2) {
InventorySlotTwelve.ItemQuantity = InventorySlotTwelve.ItemQuantity+5;
}
else if(ShopQuantity == 3) {
InventorySlotTwelve.ItemQuantity = InventorySlotTwelve.ItemQuantity+9;
}
else if(ShopQuantity == 4) {
InventorySlotTwelve.ItemQuantity = InventorySlotTwelve.ItemQuantity+10;
}
else if(ShopQuantity == 5) {
InventorySlotTwelve.ItemQuantity = InventorySlotTwelve.ItemQuantity+25;
}
else if(ShopQuantity == 6) {
InventorySlotTwelve.ItemQuantity = InventorySlotTwelve.ItemQuantity+36;
}
else if(ShopQuantity == 7) {
InventorySlotTwelve.ItemQuantity = InventorySlotTwelve.ItemQuantity+100;
}
}
}
}
return 0;
} */
int UpdateWindowStats() {
// "Date:" update. ...Heh, up/date/.
if(CurrentDate > 9) {
mvwprintw(WindowStats, 1, 7, "%i", CurrentDate);
}
else {
mvwprintw(WindowStats, 1, 7, " %i", CurrentDate);
}
// Day-of-the-Week update.
if(CurrentDayName == 1) {
mvwprintw(WindowStats, 2, 7, "(1) Sunday ");
}
else if(CurrentDayName == 2) {
mvwprintw(WindowStats, 2, 7, "(2) Monday ");
}
else if(CurrentDayName == 3) {
mvwprintw(WindowStats, 2, 7, "(3) Tuesday ");
}
else if(CurrentDayName == 4) {
mvwprintw(WindowStats, 2, 7, "(4) Wednesday");
}
else if(CurrentDayName == 5) {
mvwprintw(WindowStats, 2, 7, "(5) Thursday ");
}
else if(CurrentDayName == 6) {
mvwprintw(WindowStats, 2, 7, "(6) Friday ");
}
else if(CurrentDayName == 7) {
mvwprintw(WindowStats, 2, 7, "(7) Saturday ");
}
// Season update.
if(CurrentMonth == 1) {
mvwprintw(WindowStats, 2, 30, "(1) Spring");
}
else if(CurrentMonth == 2) {
mvwprintw(WindowStats, 2, 30, "(2) Summer");
}
else if(CurrentMonth == 3) {
mvwprintw(WindowStats, 2, 30, "(3) Autumn");
}
else if(CurrentMonth == 4) {
mvwprintw(WindowStats, 2, 30, "(4) Winter");
}
// Gold update.
if(CurrentGold < 10) {
mvwprintw(WindowStats, 1, 30, "........%iG", CurrentGold);
} else
if(CurrentGold < 100) {
mvwprintw(WindowStats, 1, 30, ".......%iG", CurrentGold);
} else
if(CurrentGold < 1000) {
mvwprintw(WindowStats, 1, 30, "......%iG", CurrentGold);
} else
if(CurrentGold < 10000) {
mvwprintw(WindowStats, 1, 30, ".....%iG", CurrentGold);
} else
if(CurrentGold < 100000) {
mvwprintw(WindowStats, 1, 30, "....%iG", CurrentGold);
} else
if(CurrentGold < 1000000) {
mvwprintw(WindowStats, 1, 30, "...%iG", CurrentGold);
} else
if(CurrentGold < 10000000) {
mvwprintw(WindowStats, 1, 30, "..%iG", CurrentGold);
} else
if(CurrentGold < 100000000) {
mvwprintw(WindowStats, 1, 30, ".%iG", CurrentGold);
} else
if(CurrentGold < 1000000000) {
mvwprintw(WindowStats, 1, 30, "%iG", CurrentGold);
} else
if(CurrentGold >= 1000000000) {
mvwprintw(WindowStats, 1, 30, ".You win.G", CurrentGold);
}
wrefresh(WindowStats);
return 0;
}
int UpdateWindowQuickref(int a) {
if(a == 0) {
mvwprintw(WindowQuickref, 1, 1, " (W)ater All (H)arvest All (N)ext Day (Tab/`) Select ");
mvwprintw(WindowQuickref, 2, 1, " F1-F5/Arrows move, Enter selects, Esc cancels (R)ain ");
wrefresh(WindowQuickref);
}
else if(a == 1) {
mvwprintw(WindowQuickref, 1, 1, " (E)dit mode (Enter) Return to panel selection ");
mvwprintw(WindowQuickref, 2, 1, " ");
wrefresh(WindowQuickref);
}
else if(a == 2) {
mvwprintw(WindowQuickref, 1, 1, " Move the cursor with the arrow keys. Edit any (number) ");
mvwprintw(WindowQuickref, 2, 1, " (Tab) cycles between editable values. (Enter) saves. ");
wrefresh(WindowQuickref);
}
else if(a == 3) {
mvwprintw(WindowQuickref, 1, 1, " Arrows select/quantity (B)uy Buy (A)ll ");
mvwprintw(WindowQuickref, 2, 1, " (Enter) when done Sell/Time/Regrow/LastDay/eXpiration ");
wrefresh(WindowQuickref);
}
return 0;
}
int ChangeShopInventory() {
werase(WindowShop);
DrawStaticElements(4);
if(CurrentMonth == 1) {
mvwprintw(WindowShop, 1, 5, Crop[Cauliflower].ShopText);
mvwprintw(WindowShop, 2, 5, Crop[Garlic].ShopText);
mvwprintw(WindowShop, 3, 5, Crop[GreenBean].ShopText);
mvwprintw(WindowShop, 4, 5, Crop[Kale].ShopText);
mvwprintw(WindowShop, 5, 5, Crop[Parsnip].ShopText);
mvwprintw(WindowShop, 6, 5, Crop[Potato].ShopText);
mvwprintw(WindowShop, 7, 5, Crop[Rhubarb].ShopText);
mvwprintw(WindowShop, 8, 5, Crop[Strawberry].ShopText);
mvwprintw(WindowShop, 9, 5, Crop[BlueJazz].ShopText);
mvwprintw(WindowShop, 10, 5, Crop[Tulip].ShopText);
mvwprintw(WindowShop, 11, 5, Crop[Empty].ShopText);
mvwprintw(WindowShop, 12, 5, Crop[Empty].ShopText);
mvwprintw(WindowShop, 13, 5, Crop[SweetGemBerry].ShopText);
mvwprintw(WindowShop, 14, 5, Crop[AncientFruit].ShopText);
}
// Jake helped here. With 'w's. :3
else if(CurrentMonth == 2) {
mvwprintw(WindowShop, 1, 5, Crop[Blueberry].ShopText);
mvwprintw(WindowShop, 2, 5, Crop[Corn].ShopText);
mvwprintw(WindowShop, 3, 5, Crop[Hops].ShopText);
mvwprintw(WindowShop, 4, 5, Crop[HotPepper].ShopText);
mvwprintw(WindowShop, 5, 5, Crop[Melon].ShopText);
mvwprintw(WindowShop, 6, 5, Crop[Radish].ShopText);
mvwprintw(WindowShop, 7, 5, Crop[RedCabbage].ShopText);
mvwprintw(WindowShop, 8, 5, Crop[Starfruit].ShopText);
mvwprintw(WindowShop, 9, 5, Crop[Tomato].ShopText);
mvwprintw(WindowShop, 10, 5, Crop[Wheat].ShopText);
mvwprintw(WindowShop, 11, 5, Crop[Poppy].ShopText);
mvwprintw(WindowShop, 12, 5, Crop[SummerSpangle].ShopText);
mvwprintw(WindowShop, 13, 5, Crop[SweetGemBerry].ShopText);
mvwprintw(WindowShop, 14, 5, Crop[AncientFruit].ShopText);
}
else if(CurrentMonth == 3) {
mvwprintw(WindowShop, 1, 5, Crop[Amaranth].ShopText);
mvwprintw(WindowShop, 2, 5, Crop[Artichoke].ShopText);
mvwprintw(WindowShop, 3, 5, Crop[Beet].ShopText);
mvwprintw(WindowShop, 4, 5, Crop[BokChoy].ShopText);
mvwprintw(WindowShop, 5, 5, Crop[Cranberries].ShopText);
mvwprintw(WindowShop, 6, 5, Crop[Eggplant].ShopText);
mvwprintw(WindowShop, 7, 5, Crop[Grape].ShopText);
mvwprintw(WindowShop, 8, 5, Crop[Pumpkin].ShopText);
mvwprintw(WindowShop, 9, 5, Crop[Yam].ShopText);
mvwprintw(WindowShop, 10, 5, Crop[FairyRose].ShopText);
mvwprintw(WindowShop, 11, 5, Crop[Sunflower].ShopText);
mvwprintw(WindowShop, 12, 5, Crop[Empty].ShopText);
mvwprintw(WindowShop, 13, 5, Crop[SweetGemBerry].ShopText);
mvwprintw(WindowShop, 14, 5, Crop[AncientFruit].ShopText);
}
return 0;
}
int UpdateWindowShop() {
ChangeShopInventory();
wrefresh(WindowShop);
return 0;
}
int UpdateWindowInventory() {
int i;
for(i=0; i<12; i++) { // This was at i<13 before. Commenting in case weird stuff happens. CHECKHEREGAIN OWO
wmove(WindowInventory, i+1, 6);
wclrtoeol(WindowInventory);
DrawStaticElements(2);
mvwprintw(WindowInventory, i+1, 6, "%s", ItemSlot[i].Text);
mvwaddch(WindowInventory, i+1, getmaxx(WindowInventory)-9, ACS_VLINE);
mvwprintw(WindowInventory, i+1, getmaxx(WindowInventory)-8, "(%i)", ItemSlot[i].Quantity);
wrefresh(WindowInventory);
}
return 0;
}
int UpdateWindowFarm() {
int i;
for(i=0; i<12; i++) {
mvwprintw(WindowCrop[i], 1, 7, "%s (%i)", Crop[CropPlot[i].ID].InventoryTextCrop, CropPlot[i].Quantity);
mvwprintw(WindowCrop[i], 2, 9, "%.2i", CropPlot[i].DateSeeded);
mvwprintw(WindowCrop[i], 2, 21, "%.2i", CropPlot[i].DateHarvest);
mvwprintw(WindowCrop[i], 2, 30, "%.2i", CropPlot[i].DateRemaining);
if(CropPlot[i].Watered == 0) {
mvwprintw(WindowCrop[i], 2, 33, "DRY");
}
else if(CropPlot[i].Watered == 1) {
mvwprintw(WindowCrop[i], 2, 33, "WET");
}
// Clear empty plots.
if(CropPlot[i].ID == 0) {
mvwprintw(WindowCrop[i], 1, 7, " ");
mvwprintw(WindowCrop[i], 2, 9, " ");
mvwprintw(WindowCrop[i], 2, 21, " ");
mvwprintw(WindowCrop[i], 2, 30, " ");
}
wrefresh(WindowCrop[i]);
}
return 0;
}
int DoGlobalAction(char Action) {
int i;
if(Action == 'n' || Action == 'N') {
// Date advancement.
CurrentDate++;
if(CurrentDate > 28) {
CurrentDate = 1;
CurrentMonth++;
if(CurrentMonth > 4) {
CurrentMonth = 1;
}
}
CurrentDayName++;
if(CurrentDayName > 7) {
CurrentDayName = 1;
};
GrowCrops();
for(i=0; i<12; i++) {
CropPlot[i].Watered = 0;
if(Crop[CropPlot[i].ID].Season != CurrentMonth) {
RemoveCrop(i);
}
}
UpdateWindowStats();
UpdateWindowShop();
UpdateWindowFarm();
//GrowCrops();
}
if(Action == 'w' || Action == 'W') {
for(i=0; i<12; i++) {
CropPlot[i].Watered = 1;
}
UpdateWindowFarm();
}
if(Action == 'h' || Action == 'H') {
DoHarvest();
}
return 0;
}
int InteractWindowStats() {
int PanelOneSelection = 1;
int PanelOneEditing = 0;
int KeyPressed;
int ScanDate;
int ScanStam;
char ScanGold[102];
char ScanGoldConversion[102];
char ScanBuffer[102];
int ScanDay;
int ScanSeason;
int i;
int j = 0;
keypad(WindowStats, TRUE);
KeyPressed = 0;
while(KeyPressed != '\r' && KeyPressed != '\n' && KeyPressed != KEY_ENTER) {
wrefresh(WindowStats);
UpdateWindowQuickref(1);
KeyPressed = getch();
if(KeyPressed == 'n' || KeyPressed == 'N') {
DoGlobalAction('n');
}
if(KeyPressed == 'w' || KeyPressed == 'W') {
DoGlobalAction('w');
}
if(KeyPressed == 'h' || KeyPressed == 'H') {
DoGlobalAction('h');
}
if(KeyPressed == 'E' || KeyPressed == 'e') {
curs_set(2);
UpdateWindowQuickref(2);
PanelOneEditing = 1;
// Get last input location.
if(PanelOneSelection == 1) {
wmove(WindowStats, 1, 8);
} else
if(PanelOneSelection == 2) {
wmove(WindowStats, 1, 18);
} else
if(PanelOneSelection == 3) {
wmove(WindowStats, 1, 30);
} else
if(PanelOneSelection == 4) {
wmove(WindowStats, 2, 8);
} else
if(PanelOneSelection == 5) {
wmove(WindowStats, 2, 31);
}
while(PanelOneEditing == 1) {
wrefresh(WindowStats);
refresh();
// Actual editing happens here!
KeyPressed = wgetch(WindowStats);
// Jump to specific cells (See code above too!).
if(KeyPressed == '\t') {
PanelOneSelection++;
if(PanelOneSelection > 5) {
PanelOneSelection = 1;
}
if(PanelOneSelection == 1) {
wmove(WindowStats, 1, 8);
} else
if(PanelOneSelection == 2) {
wmove(WindowStats, 1, 18);
} else
if(PanelOneSelection == 3) {
wmove(WindowStats, 1, 30);
} else
if(PanelOneSelection == 4) {
wmove(WindowStats, 2, 8);
} else
if(PanelOneSelection == 5) {
wmove(WindowStats, 2, 31);
}
} else
// Move to another cell using the arrow keys.
if(KeyPressed == KEY_LEFT) {
wmove(WindowStats, getcury(WindowStats), getcurx(WindowStats)-1);
} else
if(KeyPressed == KEY_RIGHT) {
wmove(WindowStats, getcury(WindowStats), getcurx(WindowStats)+1);
} else
if(KeyPressed == KEY_UP) {
wmove(WindowStats, getcury(WindowStats)-1, getcurx(WindowStats));
} else
if(KeyPressed == KEY_DOWN) {
wmove(WindowStats, getcury(WindowStats)+1, getcurx(WindowStats));
} else
if(KeyPressed == '0') {
waddch(WindowStats, '0');
} else
if(KeyPressed == '1') {
waddch(WindowStats, '1');
} else
if(KeyPressed == '2') {
waddch(WindowStats, '2');
} else
if(KeyPressed == '3') {
waddch(WindowStats, '3');
} else
if(KeyPressed == '4') {
waddch(WindowStats, '4');
} else
if(KeyPressed == '5') {
waddch(WindowStats, '5');
} else
if(KeyPressed == '6') {
waddch(WindowStats, '6');
} else
if(KeyPressed == '7') {
waddch(WindowStats, '7');
} else
if(KeyPressed == '8') {
waddch(WindowStats, '8');
} else
if(KeyPressed == '9') {
waddch(WindowStats, '9');
} else
if(KeyPressed == ' ') {
waddch(WindowStats, ' ');
}
if(KeyPressed == '(') {
waddch(WindowStats, '(');
}
if(KeyPressed == ')') {
waddch(WindowStats, ')');
}
if(KeyPressed == 'g' || KeyPressed == 'G') {
waddch(WindowStats, 'G');
}
if(KeyPressed == KEY_BACKSPACE || KeyPressed == KEY_DC || KeyPressed == '\b') {
mvwaddch(WindowStats, getcury(WindowStats), getcurx(WindowStats)-1, ' ');
}
if(KeyPressed == '\r' || KeyPressed == '\n' || KeyPressed == KEY_ENTER) {
PanelOneEditing = 0;
curs_set(FALSE);
}
}
// Now we process the user's edits!
mvwinnstr(WindowStats, 1, 1, ScanBuffer, 100);
sscanf(ScanBuffer, "%s %i %s %i %s %s", ScanGold, &ScanDate, ScanGold, &ScanStam, ScanGold, ScanGold);
if(ScanDate < 29) {
CurrentDate = ScanDate;
}
//Parsing the gold may be tricky.
for(i = 0; i < 102; i++) {
if(ScanGold[i] == '0' || ScanGold[i] == '1' || ScanGold[i] == '2' || ScanGold[i] == '3' || ScanGold[i] == '4' || ScanGold[i] == '5' || ScanGold[i] == '6' || ScanGold[i] == '7' || ScanGold[i] == '8' || ScanGold[i] == '9') {
ScanGoldConversion[j] = ScanGold[i];
j++;
}
else if(ScanGold[i] == 'G') {
ScanGoldConversion[j] = '\0';
j = 0;
break;
}
}
if(atoi(ScanGoldConversion) < 1000000000 && ScanGoldConversion[0] != '\0') {
CurrentGold = atoi(ScanGoldConversion);
}
// Second line of the user's edits.
mvwinnstr(WindowStats, 2, 1, ScanBuffer, 100);
sscanf(ScanBuffer, "%s (%i) %s %s (%i) %s", ScanGold, &ScanDay, ScanGold, ScanGold, &ScanSeason, ScanGold);
if(ScanDay < 8) {
CurrentDayName = ScanDay;
}
if(ScanSeason < 5) {
CurrentMonth = ScanSeason;
}
UpdateWindowStats();
UpdateWindowShop(); // In case the season changes. owo.
KeyPressed = 0;
}
}
return 0;
}
int InteractWindowQuickref() {
return 0;
}
int InteractWindowInventory() {
int InteractingInventory = 1;
int i;
keypad(WindowInventory, TRUE);
while(InteractingInventory == 1) {
UpdateWindowInventory();
mvwchgat(WindowInventory, InventorySelection, 6, 27, A_REVERSE, 0, NULL);
mvwchgat(WindowInventory, InventorySelection, getmaxx(WindowInventory)-8, 7, A_REVERSE, 0, NULL);
KeyPressed = wgetch(WindowInventory);
if(KeyPressed == 'n' || KeyPressed == 'N') {
DoGlobalAction('n');
}
if(KeyPressed == 'w' || KeyPressed == 'W') {
DoGlobalAction('w');
}
if(KeyPressed == 'h' || KeyPressed == 'H') {
DoGlobalAction('h');
}
else if(KeyPressed == KEY_DOWN) {
if(InventorySelection < 12) {
mvwchgat(WindowInventory, InventorySelection, 6, 27, A_NORMAL, 0, NULL);
mvwchgat(WindowInventory, InventorySelection, getmaxx(WindowInventory)-8, 7, A_NORMAL, 0, NULL);
InventorySelection++;
}
}
else if(KeyPressed == KEY_UP) {
if(InventorySelection > 1) {
mvwchgat(WindowInventory, InventorySelection, 6, 27, A_NORMAL, 0, NULL);
mvwchgat(WindowInventory, InventorySelection, getmaxx(WindowInventory)-8, 7, A_NORMAL, 0, NULL);
InventorySelection--;
}
}
/*else if(KeyPressed == KEY_RIGHT) {
if(ShopQuantitySelect < 7) {
ShopQuantitySelect++;
}
}
else if(KeyPressed == KEY_LEFT) {
if(ShopQuantitySelect > 1) {
ShopQuantitySelect--;
}
} -- Considering using this for buying and selling, maybe.. Somehow. -w-. */
else if(KeyPressed == 'S' || KeyPressed == 's') {
SellItem();
}
else if(KeyPressed == 'P' || KeyPressed == 'p') {
PlantSeeds();
}
else if(KeyPressed == '\r' || KeyPressed == '\n' || KeyPressed == KEY_ENTER) {
InteractingInventory = 0;
mvwchgat(WindowInventory, InventorySelection, 6, 27, A_NORMAL, 0, NULL);
mvwchgat(WindowInventory, InventorySelection, getmaxx(WindowInventory)-8, 7, A_NORMAL, 0, NULL);
UpdateWindowInventory();
}
}
return 0;
}
int InteractWindowShop() {
keypad(WindowShop, TRUE);
int Shopping = 1;
UpdateWindowQuickref(3);
if(ShopQuantitySelect == 0) {
ShopQuantitySelect = 1;
}
while(Shopping == 1) {
mvwchgat(WindowShop, ShopSelection, 5, getmaxx(WindowShop)-7, A_REVERSE, 0, NULL);
mvwchgat(WindowShop, 15, 1, getmaxx(WindowShop)-2, A_NORMAL, 0, NULL);
if(ShopQuantitySelect == 1) {
mvwchgat(WindowShop, 15, 1, 5, A_REVERSE, 0, NULL);
ShopQuantity = 1;
}
else if(ShopQuantitySelect == 2) {
mvwchgat(WindowShop, 15, 9, 5, A_REVERSE, 0, NULL);
ShopQuantity = 5;
}
/*else if(ShopQuantitySelect == 2) {
mvwchgat(WindowShop, 15, 9, 5, A_REVERSE, 0, NULL);
ShopQuantity = 9;
}*/
else if(ShopQuantitySelect == 3) {
mvwchgat(WindowShop, 15, 17, 5, A_REVERSE, 0, NULL);
ShopQuantity = 9;
}
else if(ShopQuantitySelect == 4) {
mvwchgat(WindowShop, 15, 25, 6, A_REVERSE, 0, NULL);
ShopQuantity = 10;
}
else if(ShopQuantitySelect == 5) {
mvwchgat(WindowShop, 15, 34, 6, A_REVERSE, 0, NULL);
ShopQuantity = 25;
}
else if(ShopQuantitySelect == 6) {
mvwchgat(WindowShop, 15, 43, 6, A_REVERSE, 0, NULL);
ShopQuantity = 36;
}
else if(ShopQuantitySelect == 7) {
mvwchgat(WindowShop, 15, 50, 7, A_REVERSE, 0, NULL);
ShopQuantity = 100;
}
wrefresh(WindowShop);
wrefresh(WindowInventory);
KeyPressed = wgetch(WindowShop);
if(KeyPressed == 'n' || KeyPressed == 'N') {
DoGlobalAction('n');
}
if(KeyPressed == 'w' || KeyPressed == 'W') {
DoGlobalAction('w');
}
if(KeyPressed == 'h' || KeyPressed == 'H') {
DoGlobalAction('h');
}
else if(KeyPressed == KEY_DOWN) {
if(ShopSelection < 14) {
mvwchgat(WindowShop, ShopSelection, 5, getmaxx(WindowShop)-7, A_NORMAL, 0, NULL);
ShopSelection++;
}
}
else if(KeyPressed == KEY_UP) {
if(ShopSelection > 1) {
mvwchgat(WindowShop, ShopSelection, 5, getmaxx(WindowShop)-7, A_NORMAL, 0, NULL);
ShopSelection--;
}
}
else if(KeyPressed == KEY_RIGHT) {
if(ShopQuantitySelect < 7) {
ShopQuantitySelect++;
}
}
else if(KeyPressed == KEY_LEFT) {
if(ShopQuantitySelect > 1) {
ShopQuantitySelect--;
}
}
else if(KeyPressed == 'B' || KeyPressed == 'b') {
BuyItem();
}
else if(KeyPressed == 'A' || KeyPressed == 'a') {
// BuyAll();
}
else if(KeyPressed == '\r' || KeyPressed == '\n' || KeyPressed == KEY_ENTER) {
Shopping = 0;
mvwchgat(WindowShop, ShopSelection, 5, getmaxx(WindowShop)-7, A_NORMAL, 0, NULL);
mvwchgat(WindowShop, 15, 1, getmaxx(WindowShop)-2, A_NORMAL, 0, NULL);
wrefresh(WindowShop);
}
}
return 0;
}
int InteractWindowFarm() {
int i;
keypad(WindowFarm, TRUE);
int Farming = 1;
//DrawStaticElements(5);
//FarmSelection
while(Farming == 1) {
for(i=0; i<12; i++) {
wborder(WindowCrop[i], ACS_VLINE | A_NORMAL, ACS_VLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_ULCORNER | A_NORMAL, ACS_URCORNER | A_NORMAL, ACS_LLCORNER | A_NORMAL, ACS_LRCORNER | A_NORMAL);
wrefresh(WindowCrop[i]);
}
wborder(WindowCrop[FarmSelection], ACS_VLINE | A_BOLD, ACS_VLINE | A_BOLD, ACS_HLINE | A_BOLD, ACS_HLINE | A_BOLD, ACS_ULCORNER | A_BOLD, ACS_URCORNER | A_BOLD, ACS_LLCORNER | A_BOLD, ACS_LRCORNER | A_BOLD);
wrefresh(WindowCrop[FarmSelection]);
KeyPressed = wgetch(WindowFarm);
if(KeyPressed == 'n' || KeyPressed == 'N') {
DoGlobalAction('n');
}
if(KeyPressed == 'w' || KeyPressed == 'W') {
DoGlobalAction('w');
}
if(KeyPressed == 'h' || KeyPressed == 'H') {
DoGlobalAction('h');
}
else if(KeyPressed == KEY_DOWN) {
if(FarmSelection < 11) {
FarmSelection++; // Code above'll handle actually updating the windows! I hope! Whee! OwO!
}
}
else if(KeyPressed == KEY_UP) {
if(FarmSelection > 0) {
FarmSelection--;
}
}
else if(KeyPressed == KEY_RIGHT) {
if(FarmSelection < 6) {
FarmSelection+=6;
}
}
else if(KeyPressed == KEY_LEFT) {
if(FarmSelection > 5) {
FarmSelection-=6;
}
}
else if(KeyPressed == '\r' || KeyPressed == '\n' || KeyPressed == KEY_ENTER) {
Farming = 0;
}
}
// When done, clear the highlighted one.
for(i=0; i<12; i++) {
wborder(WindowCrop[i], ACS_VLINE | A_NORMAL, ACS_VLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_HLINE | A_NORMAL, ACS_ULCORNER | A_NORMAL, ACS_URCORNER | A_NORMAL, ACS_LLCORNER | A_NORMAL, ACS_LRCORNER | A_NORMAL);
wrefresh(WindowCrop[i]);
}
return 0;
}
int DoEvents() {
return 0;
}
int main(void) {
initscr(); // Here we go!
resize_term(50, 100);
raw();
noecho();
keypad(stdscr, TRUE);
curs_set(FALSE);
MakeCropStructs();
MakeCropPlotStructs();
CreateWindowsInMemory();
DrawStaticElements(0);
InitalizeNewGame();
UpdateWindowStats();
UpdateWindowShop();
SwitchActiveWindow(); // Calling so it's obvious that there's /a/ selection.
while(1) {
UpdateWindowQuickref(0);
keypad(stdscr, TRUE); // Always re-get arrow and F-keys from any other windows that take it.
DrawStaticElements(3);
KeyPressed = getch();
if(KeyPressed == 'n' || KeyPressed == 'N') {
DoGlobalAction('n');
}
if(KeyPressed == 'w' || KeyPressed == 'W') {
DoGlobalAction('w');
}
if(KeyPressed == 'h' || KeyPressed == 'H') {
DoGlobalAction('h');
}
if(KeyPressed == KEY_STAB || KeyPressed == KEY_BTAB || KeyPressed == '\t' || KeyPressed == '`' || KeyPressed == '~') { // Active Window switching.
if(KeyPressed == '`' || KeyPressed == '~') {
ActiveWindow--;
if(ActiveWindow == 0) {
ActiveWindow = 5;
}
}
else {
ActiveWindow++;
if(ActiveWindow > 5) {
ActiveWindow = 1;
}
}
SwitchActiveWindow();
} else
if(KeyPressed == '\r' || KeyPressed == '\n' || KeyPressed == KEY_ENTER) {
if(ActiveWindow == 1) {
InteractWindowStats();
}
else if(ActiveWindow == 2) {
InteractWindowQuickref();
}
else if(ActiveWindow == 3) {
InteractWindowInventory();
}
else if(ActiveWindow == 4) {
InteractWindowShop();
}
else if(ActiveWindow == 5) {
InteractWindowFarm();
}
}
DoEvents();
}
endwin();
return 0;
}
Comments