2017-08-06 03:51:44 +08:00
|
|
|
|
using Omegasis.DailyQuestAnywhere.Framework;
|
2017-07-28 08:28:39 +08:00
|
|
|
|
using StardewModdingAPI;
|
2017-07-30 02:28:23 +08:00
|
|
|
|
using StardewModdingAPI.Events;
|
2017-07-28 08:28:39 +08:00
|
|
|
|
using StardewValley;
|
2017-07-30 02:28:23 +08:00
|
|
|
|
using StardewValley.Menus;
|
2018-05-07 09:21:31 +08:00
|
|
|
|
using StardewValley.Quests;
|
|
|
|
|
using System;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-28 08:28:39 +08:00
|
|
|
|
namespace Omegasis.DailyQuestAnywhere
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2018-05-07 09:21:31 +08:00
|
|
|
|
/*
|
|
|
|
|
*TODO: Make quest core mod???
|
|
|
|
|
*/
|
|
|
|
|
|
2017-07-30 02:28:23 +08:00
|
|
|
|
/// <summary>The mod entry point.</summary>
|
|
|
|
|
public class DailyQuestAnywhere : Mod
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:28:23 +08:00
|
|
|
|
/*********
|
|
|
|
|
** Properties
|
|
|
|
|
*********/
|
2017-08-06 03:51:44 +08:00
|
|
|
|
/// <summary>The mod configuration.</summary>
|
|
|
|
|
private ModConfig Config;
|
2017-07-30 02:28:23 +08:00
|
|
|
|
|
2018-05-07 09:21:31 +08:00
|
|
|
|
Quest dailyQuest;
|
|
|
|
|
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:28:23 +08:00
|
|
|
|
/*********
|
|
|
|
|
** Public methods
|
|
|
|
|
*********/
|
|
|
|
|
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
|
|
|
|
|
/// <param name="helper">Provides simplified APIs for writing mods.</param>
|
2016-12-09 08:34:28 +08:00
|
|
|
|
public override void Entry(IModHelper helper)
|
|
|
|
|
{
|
2017-08-06 03:51:44 +08:00
|
|
|
|
this.Config = helper.ReadConfig<ModConfig>();
|
|
|
|
|
|
2017-07-30 02:28:23 +08:00
|
|
|
|
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
|
2018-05-07 09:21:31 +08:00
|
|
|
|
StardewModdingAPI.Events.SaveEvents.AfterSave += SaveEvents_AfterSave;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-05-07 09:21:31 +08:00
|
|
|
|
|
|
|
|
|
|
2017-07-30 02:28:23 +08:00
|
|
|
|
/*********
|
|
|
|
|
** Private methods
|
|
|
|
|
*********/
|
|
|
|
|
/// <summary>The method invoked when the presses a keyboard button.</summary>
|
|
|
|
|
/// <param name="sender">The event sender.</param>
|
|
|
|
|
/// <param name="e">The event data.</param>
|
|
|
|
|
private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-08-06 03:51:44 +08:00
|
|
|
|
if (Context.IsPlayerFree && e.KeyPressed.ToString() == this.Config.KeyBinding)
|
2018-05-07 09:21:31 +08:00
|
|
|
|
if (Game1.player.hasDailyQuest() == false )
|
|
|
|
|
{
|
|
|
|
|
if (this.dailyQuest == null)
|
|
|
|
|
{
|
|
|
|
|
this.dailyQuest = generateDailyQuest();
|
|
|
|
|
}
|
|
|
|
|
Game1.questOfTheDay = this.dailyQuest;
|
|
|
|
|
Game1.activeClickableMenu = new Billboard(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Makes my daily quest referene null so we can't just keep getting a new reference.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void SaveEvents_AfterSave(object sender, System.EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.dailyQuest = null; //Nullify my quest reference.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generate a daily quest for sure.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public Quest generateDailyQuest()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Random chanceRandom = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed);
|
|
|
|
|
int chance = chanceRandom.Next(0, 101);
|
|
|
|
|
float actualChance = chance / 100;
|
|
|
|
|
|
|
|
|
|
//If we hit the chance for actually generating a daily quest do so, otherwise don't generate a daily quest.
|
|
|
|
|
if (actualChance <= Config.chanceForDailyQuest)
|
|
|
|
|
{
|
|
|
|
|
Random r = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed);
|
|
|
|
|
int rand = r.Next(0, 7);
|
|
|
|
|
|
|
|
|
|
if (rand == 0) return new ItemDeliveryQuest();
|
|
|
|
|
if (rand == 1) return new FishingQuest();
|
|
|
|
|
if (rand == 2) return new StardewValley.Quests.CraftingQuest();
|
|
|
|
|
if (rand == 3) return new StardewValley.Quests.ItemDeliveryQuest();
|
|
|
|
|
if (rand == 4) return new StardewValley.Quests.ItemHarvestQuest();
|
|
|
|
|
if (rand == 5) return new StardewValley.Quests.ResourceCollectionQuest();
|
|
|
|
|
if (rand == 6) return new StardewValley.Quests.SlayMonsterQuest();
|
|
|
|
|
}
|
|
|
|
|
return null; //This should never happen.
|
2017-07-30 02:28:23 +08:00
|
|
|
|
}
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
}
|