-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathHarvestNotification.cs
107 lines (96 loc) · 3.7 KB
/
HarvestNotification.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Linq;
using Microsoft.Xna.Framework;
using StardewValley;
using StardewModdingAPI;
namespace StardewNotification
{
public class HarvestNotification
{
private readonly ITranslationHelper Trans;
public HarvestNotification(ITranslationHelper Helper)
{
Trans = Helper;
}
private const int MUSHROOM_CAVE = 2;
private const int FRUIT_CAVE = 1;
public void CheckHarvestsAroundFarm()
{
CheckSeasonalHarvests();
}
public void CheckHarvestsOnFarm()
{
CheckFarmCaveHarvests(Game1.getLocationFromName("FarmCave"));
CheckGreenhouseCrops(Game1.getLocationFromName("Greenhouse"));
}
public void CheckFarmCaveHarvests(GameLocation farmcave)
{
if (!StardewNotification.Config.NotifyFarmCave) return;
if (Game1.player.caveChoice.Value == MUSHROOM_CAVE)
{
var numReadyForHarvest = farmcave.Objects.Values.Where(c => c.readyForHarvest.Value).Count();
if (numReadyForHarvest > 0)
{
HUDMessage h = new HUDMessage(Trans.Get("CaveMushroom"), Color.OrangeRed, 3000, true)
{
whatType = 2
};
Game1.addHUDMessage(h);
}
}
else if (Game1.player.caveChoice.Value == FRUIT_CAVE && farmcave.Objects.Any())
{
var objList = farmcave.Objects.Values.Where(c => c.Category == 100 || c.Category == 80 || c.Category == -79).ToArray();
int iCount = objList.Count();
if (iCount > 1)
{
HUDMessage h = new HUDMessage(Trans.Get("CaveFruit"), Color.OrangeRed, 3000, true)
{
whatType = 2
};
Game1.addHUDMessage(h);
}
}
}
public void CheckSeasonalHarvests()
{
if (!StardewNotification.Config.NotifySeasonalForage) return;
string seasonal = null;
var dayOfMonth = Game1.dayOfMonth;
switch (Game1.currentSeason)
{
case "spring":
if (dayOfMonth > 14 && dayOfMonth < 19) seasonal = Trans.Get("Salmonberry");
break;
case "summer":
if (dayOfMonth > 11 && dayOfMonth < 15) seasonal = Trans.Get("Seashells");
break;
case "fall":
if (dayOfMonth > 7 && dayOfMonth < 12) seasonal = Trans.Get("Blackberry");
break;
default:
break;
}
if (!(seasonal is null))
{
Util.ShowMessage($"{seasonal}");
}
}
public void CheckGreenhouseCrops(GameLocation greenhouse)
{
if (!StardewNotification.Config.NotifyGreenhouseCrops) return;
//var counter = new Dictionary<string, Pair<StardewValley.TerrainFeatures.HoeDirt, int>>();
foreach (var pair in greenhouse.terrainFeatures.Pairs)
{
Console.Write($"Investigating {pair.Key} and {pair.Value.ToString()}");
if (pair.Value is StardewValley.TerrainFeatures.HoeDirt hoeDirt)
{
if (!hoeDirt.readyForHarvest()) continue;
Console.Write($"This is ready for harvest: {hoeDirt.crop}");
Util.ShowMessage(Trans.Get("greenhouse_crops"));
break;
}
}
}
}
}