Skip to content

Commit

Permalink
Initial Commit For Stardew Valley 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
GStefanowich committed Jan 6, 2021
0 parents commit 85c7cb1
Show file tree
Hide file tree
Showing 10 changed files with 376 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.git/
/.idea/
/assets/
/Stardew Valley/
/packages/
/obj/
/bin/
66 changes: 66 additions & 0 deletions ForecasterText.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DB67424C-151C-4F2B-9EE7-02594AEBE089}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ForecasterText</RootNamespace>
<AssemblyName>ForecasterText</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ModEntry.cs" />
<Compile Include="ModEvents.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VirtualTV.cs" />
</ItemGroup>
<ItemGroup>
<None Include="manifest.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="assets\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\Pathoschild.Stardew.ModBuildConfig.3.0.0\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('packages\Pathoschild.Stardew.ModBuildConfig.3.0.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Pathoschild.Stardew.ModBuildConfig.3.0.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Pathoschild.Stardew.ModBuildConfig.3.0.0\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
</Project>
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Gregory Stefanowich

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
50 changes: 50 additions & 0 deletions ModEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* This software is licensed under the MIT License
* https://github.com/GStefanowich/SDV-Forecaster
*
* Copyright (c) 2019 Gregory Stefanowich
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

using StardewModdingAPI;
using StardewValley;

namespace ForecasterText {
public class ModEntry : Mod {
public static IMonitor MONITOR;
public static string MOD_ID;
public static IModHelper MOD_HELPER;

/*
* Mod Initializer
*/
public override void Entry(IModHelper helper) {
// Initialize the Harmony Override Console
ModEntry.MOD_ID = this.ModManifest.UniqueID;
ModEntry.MOD_HELPER = this.Helper;
ModEntry.MONITOR = this.Monitor;

ModEntry.MOD_HELPER.Events.GameLoop.DayStarted += ModEvents.OnDayStart;
}

public static bool PlayerHasRecipe(string recipe) => Game1.player.cookingRecipes.ContainsKey(recipe);
public static bool PlayerBeenToIsland() => Game1.player.hasOrWillReceiveMail("Visited_Island");
}
}
164 changes: 164 additions & 0 deletions ModEvents.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/*
* This software is licensed under the MIT License
* https://github.com/GStefanowich/SDV-Forecaster
*
* Copyright (c) 2019 Gregory Stefanowich
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

using System;
using System.Collections.Generic;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;

namespace ForecasterText {
public static class ModEvents {
private static readonly VirtualTV TELEVISION = new VirtualTV();

public static void OnDayStart(object sender, DayStartedEventArgs e) {
if (!Context.IsWorldReady)
return;

// Send messages for each event
ModEvents.SendChatMessage(new [] {
ModEvents.GetTownForecast(),
ModEvents.GetIslandForecast(),
ModEvents.GetDailyLuck(),
ModEvents.GetQueenOfSauce()
});
}

/*
* Show messages in chat
*/

private static void SendChatMessage( IEnumerable<string> messages ) {
foreach (string message in messages) ModEvents.SendChatMessage(message);
}
private static void SendChatMessage( string message ) {
if (message != null) Game1.chatBox.addInfoMessage($"TV: {message}");
}

/*
* Weather
*/

private static string GetTownForecast() {
WorldDate date = new WorldDate(Game1.Date);
++date.TotalDays;
return ModEvents.GetWeatherInformation("Pelican Town forecast", !Game1.IsMasterGame ? Game1.getWeatherModificationsForDate(date, Game1.netWorldState.Value.WeatherForTomorrow) : Game1.getWeatherModificationsForDate(date, Game1.weatherForTomorrow));
}

private static string GetIslandForecast() {
if (!ModEntry.PlayerBeenToIsland())
return null;
return ModEvents.GetWeatherInformation("Ginger Island forecast", Game1.netWorldState.Value.GetWeatherForLocation(
Game1.getLocationFromName("IslandSouth").GetLocationContext()
).weatherForTomorrow.Value);
}

private static string GetWeatherInformation( string prefix, int num ) {
switch (num) {
case 0:
case 4:
case 6:
return $"{prefix} [99]";
case 1:
return $"{prefix} [101][100]";
case 2:
if (Game1.currentSeason.Equals("winter"))
return $"{prefix} [103]";
return $"{prefix} [99]";
case 3:
return $"{prefix} [102][100]";
case 5:
return $"{prefix} [103]";
}
return $"{prefix}: ???";
}

/*
* Luck
*/

private static string GetDailyLuck() {
Farmer who = Game1.player;
if (who.team.sharedDailyLuck.Value == -0.12)
return "[119]are[15]today"; // Furious (TV.cs.13191)
if (who.DailyLuck == 0.0)
return "[119]are[16]today"; // Neutral (TV.cs.13201)
if (who.DailyLuck >= -0.07 && who.DailyLuck < -0.02) {
Random random = new Random((int) Game1.stats.DaysPlayed + (int) Game1.uniqueIDForThisGame / 2);
if (random.NextDouble() < 0.5)
return "[119]are[18]today"; // Somewhat Annoyed (TV.cs.13193)
return "[119]are[11]today"; // Mildly Perturbed (TV.cs.13195)
}
if (who.DailyLuck >= -0.07 && who.team.sharedDailyLuck.Value != 0.12) {
if (who.DailyLuck > 0.07)
return "[119]are[43]today"; // Very Happy (TV.cs.13198)
if (who.DailyLuck <= 0.02)
return "[119]are[16]today"; // Neutral (TV.cs.13200)
return "[119]are[2]today"; // Good Humor (TV.cs.13199)
}
if (who.DailyLuck >= -0.07)
return "[119]are[1]today"; // Joyous (TV.cs.13197)
return "[119]are[14]today"; // Very Displeased (TV.cs.13192)
}

/*
* Recipes
*/

private static string GetQueenOfSauce() {
int num = (int)(Game1.stats.DaysPlayed % 224U / 7U);
if (Game1.stats.DaysPlayed % 224U == 0U)
num = 32;
FarmerTeam team = Game1.player.team;
switch (Game1.dayOfMonth % 7) {
case 0: // Sunday
break;
case 3: // Wednesday
if (team.lastDayQueenOfSauceRerunUpdated.Value != Game1.Date.TotalDays) {
team.lastDayQueenOfSauceRerunUpdated.Set(Game1.Date.TotalDays);
team.queenOfSauceRerunWeek.Set(ModEvents.TELEVISION.GetRerunWeek());
}
num = team.queenOfSauceRerunWeek.Value;
break;
default: return null;
}

// Dictionary of recipes
Dictionary<string, string> dictionary = Game1.temporaryContent.Load<Dictionary<string, string>>("Data\\TV\\CookingChannel");
if (!dictionary.TryGetValue($"{num}", out string translation))
return null;

// Split the translation info
string[] recipeInfo = translation.Split('/');
if (recipeInfo.Length <= 0)
return null;

// Get the recipe name
string recipeName = recipeInfo[0];
return $"[{(ModEntry.PlayerHasRecipe(recipeName) ? "135" : "132")}]Learn to make \"{recipeName}\"";
}

}
}
35 changes: 35 additions & 0 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ForecasterText")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ForecasterText")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("db67424c-151c-4f2b-9ee7-02594aebe089")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Forecaster Texts
**Forecaster Texts** is a **[Stardew Valley](https://www.stardewvalley.net/)** mod that uses the [Stardew Modding API](https://www.nexusmods.com/stardewvalley/mods/2400).

- See the mod on [Nexus](https://www.nexusmods.com/stardewvalley/mods/7541/).
13 changes: 13 additions & 0 deletions VirtualTV.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using StardewValley.Objects;

namespace ForecasterText {
public class VirtualTV : TV {

public VirtualTV() : base() {}

public int GetRerunWeek() {
return base.getRerunWeek();
}

}
}
12 changes: 12 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Name": "Forecaster Text",
"Author": "TheElm",
"Version": "1.0.0",
"Description": "Receive messages from the News station every day",
"UniqueID": "TheElm.ForecasterText",
"EntryDll": "ForecasterText.dll",
"MinimumApiVersion": "3.8.0",
"UpdateKeys": [
"Nexus:7541"
]
}
4 changes: 4 additions & 0 deletions packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Pathoschild.Stardew.ModBuildConfig" version="3.2.2" targetFramework="net472" />
</packages>

0 comments on commit 85c7cb1

Please sign in to comment.