Added in precondition checks for events. Also added in special birthday precondition events.

This commit is contained in:
JoshuaNavarro 2019-12-04 13:24:21 -08:00
parent b550f66233
commit f450efdcc7
38 changed files with 731 additions and 70 deletions

View File

@ -34,84 +34,67 @@ namespace Omegasis.HappyBirthday.Framework.Events
}
private bool _precondition_snowWeather;
private bool _precondition_debrisWeather;
private bool _precondition_weddingDayWeather;
private bool _precondition_stormyWeather;
private bool _precondition_festivalWeather;
private StringBuilder eventData;
private StringBuilder eventPreconditionData;
public List<EventPrecondition> eventPreconditions;
public int eventID;
public EventHelper()
{
this.eventData = new StringBuilder();
this.eventPreconditionData = new StringBuilder();
this.eventPreconditions = new List<EventPrecondition>();
}
public EventHelper(int ID,TimePrecondition Time, EventDayExclusionPrecondition NotTheseDays)
public EventHelper(int ID, TimePrecondition Time, EventDayExclusionPrecondition NotTheseDays, EventStartData StartData)
{
this.eventData = new StringBuilder();
this.eventPreconditionData = new StringBuilder();
this.eventID = ID;
this.add(Time);
this.add(NotTheseDays);
this.add(StartData.ToString());
this.eventPreconditions = new List<EventPrecondition>();
this.eventPreconditions.Add(NotTheseDays);
this.eventPreconditions.Add(Time);
}
public EventHelper(List<EventPrecondition> Conditions)
public EventHelper(List<EventPrecondition> Conditions, EventStartData StartData)
{
this.eventData = new StringBuilder();
foreach(var v in Conditions)
this.eventPreconditions = new List<EventPrecondition>();
this.eventPreconditionData = new StringBuilder();
foreach (var v in Conditions)
{
if(v is WeatherPrecondition)
{
WeatherPrecondition w = (v as WeatherPrecondition);
if(w.weather== WeatherPrecondition.Weather.Sunny || w.weather== WeatherPrecondition.Weather.Rainy)
{
this.add(v);
}
else if(w.weather== WeatherPrecondition.Weather.Debris)
{
this._precondition_debrisWeather = true;
}
else if(w.weather== WeatherPrecondition.Weather.Festival)
{
this._precondition_festivalWeather = true;
}
else if(w.weather== WeatherPrecondition.Weather.Snow)
{
this._precondition_snowWeather = true;
}
else if(w.weather== WeatherPrecondition.Weather.Storm)
{
this._precondition_stormyWeather = true;
}
else if(w.weather== WeatherPrecondition.Weather.Wedding)
{
this._precondition_weddingDayWeather = true;
}
continue;
}
this.eventPreconditions.Add(v);
this.add(v);
}
this.add(StartData.ToString());
}
/// <summary>
/// Adds in the event data to the string builder and appends seperators as necessary.
/// Adds in the event precondition data to the string builder and appends seperators as necessary.
/// </summary>
/// <param name="Data"></param>
public virtual void add(EventPrecondition Data)
{
if (this.eventData.Length > 0)
if (this.eventPreconditionData.Length > 0)
{
this.eventData.Append(this.getSeperator());
this.eventPreconditionData.Append(this.getSeperator());
}
this.eventData.Append(Data.ToString());
this.eventPreconditionData.Append(Data.ToString());
}
/// <summary>
/// Adds in the data to the event data.Aka what happens during the event.
/// </summary>
/// <param name="Data"></param>
public virtual void add(string Data)
{
@ -122,6 +105,15 @@ namespace Omegasis.HappyBirthday.Framework.Events
this.eventData.Append(Data);
}
/// <summary>
/// Adds in the data to the event data. Aka what happens during the event.
/// </summary>
/// <param name="Builder"></param>
public virtual void add(StringBuilder Builder)
{
this.add(Builder.ToString());
}
/// <summary>
/// Converts the direction to enum.
@ -175,7 +167,7 @@ namespace Omegasis.HappyBirthday.Framework.Events
/// <returns></returns>
public virtual bool isIdValid(string IDToCheck)
{
if (Convert.ToInt32(IDToCheck) > 2147483647 ||Convert.ToInt32(IDToCheck) < 0) return false;
if (Convert.ToInt32(IDToCheck) > 2147483647 || Convert.ToInt32(IDToCheck) < 0) return false;
else return true;
}
@ -184,16 +176,35 @@ namespace Omegasis.HappyBirthday.Framework.Events
return this.eventData.ToString();
}
public virtual StardewValley.Event getEvent(Farmer PlayerActor=null)
public virtual StardewValley.Event getEvent(Farmer PlayerActor = null)
{
return new StardewValley.Event(this.getEventString(), Convert.ToInt32(this.getEventID()), PlayerActor);
}
//~~~~~~~~~~~~~~~~//
// Validation //
//~~~~~~~~~~~~~~~~//
public bool canEventOccur()
{
foreach(EventPrecondition eve in this.eventPreconditions)
{
if (eve.meetsCondition() == false) return false;
}
return true;
}
//~~~~~~~~~~~~~~~~//
// Actions //
//~~~~~~~~~~~~~~~~//
/// <summary>
/// Adds an object at the specified tile from the TileSheets\Craftables.png sprite sheet
/// </summary>
/// <param name="xTile"></param>
/// <param name="yTile"></param>
/// <param name="ID"></param>
public virtual void addBigProp(int xTile, int yTile, int ID)
{
StringBuilder b = new StringBuilder();
@ -203,9 +214,97 @@ namespace Omegasis.HappyBirthday.Framework.Events
b.Append(yTile.ToString());
b.Append(" ");
b.Append(ID.ToString());
this.add(b.ToString());
this.add(b);
}
/// <summary>
/// Starts an active dialogue event with the given ID and a length of 4 days.
/// </summary>
/// <param name="ID"></param>
public virtual void addConversationTopic(string ID)
{
StringBuilder b = new StringBuilder();
b.Append("addBigProp ");
b.Append(ID);
this.add(b);
}
/// <summary>
/// Adds the specified cooking recipe to the player.
/// </summary>
/// <param name="Recipe"></param>
public virtual void addCookingRecipe(string Recipe)
{
StringBuilder b = new StringBuilder();
b.Append("addCookingRecipe ");
b.Append(Recipe);
this.add(b);
}
/// <summary>
/// Adds the specified crafting recipe to the player.
/// </summary>
/// <param name="Recipe"></param>
public virtual void addCraftingRecipe(string Recipe)
{
StringBuilder b = new StringBuilder();
b.Append("addCraftingRecipe ");
b.Append(Recipe);
this.add(b);
}
/// <summary>
/// Add a non-solid prop from the current festival texture. Default solid width/height is 1. Default display height is solid height.
/// </summary>
public virtual void addFloorProp(int PropIndex, int XTile, int YTile, int SolidWidth, int SolidHeight, int DisplayHeight)
{
StringBuilder b = new StringBuilder();
b.Append("addFloorProp ");
b.Append(PropIndex.ToString());
b.Append(" ");
b.Append(XTile.ToString());
b.Append(" ");
b.Append(YTile.ToString());
b.Append(" ");
b.Append(SolidWidth.ToString());
b.Append(" ");
b.Append(SolidHeight.ToString());
b.Append(" ");
b.Append(DisplayHeight.ToString());
this.add(b);
}
/// <summary>
/// Adds a glowing temporary sprite at the specified tile from the Maps\springobjects.png sprite sheet. A light radius of 0 just places the sprite.
/// </summary>
/// <param name="ItemID"></param>
/// <param name="XPosition"></param>
/// <param name="YPosition"></param>
/// <param name="LightRadius"></param>
public virtual void addLantern(int ItemID, int XPosition, int YPosition, float LightRadius)
{
StringBuilder b = new StringBuilder();
b.Append("addLantern ");
b.Append(ItemID.ToString());
b.Append(" ");
b.Append(XPosition.ToString());
b.Append(" ");
b.Append(YPosition.ToString());
b.Append(" ");
b.Append(LightRadius.ToString());
this.add(b);
}
/// <summary>
/// Set a letter as received.
/// </summary>
/// <param name="ID"></param>
public virtual void addMailReceived(string ID)
{
StringBuilder b = new StringBuilder();
b.Append("addMailReceived ");
b.Append(ID);
this.add(b);
}
}
}

View File

@ -0,0 +1,204 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events
{
public class EventStartData
{
/// <summary>
/// Data pertaining to npcs information necessary for the event.
/// </summary>
public class NPCData
{
private NPC npc;
int xPosition;
int yPosition;
EventHelper.FacingDirection direction;
public NPCData()
{
}
public NPCData(NPC NPC, int XTile, int YTile, EventHelper.FacingDirection Direction)
{
this.npc = NPC;
this.xPosition = XTile;
this.yPosition = YTile;
this.direction = Direction;
}
public override string ToString()
{
StringBuilder b = new StringBuilder();
b.Append(this.npc.Name);
b.Append(" ");
b.Append(this.xPosition.ToString());
b.Append(" ");
b.Append(this.yPosition.ToString());
b.Append(" ");
b.Append(((int)this.direction).ToString());
return b.ToString();
}
}
/// <summary>
/// Data pertaining to the farmer data for the event.
/// </summary>
public class FarmerData
{
int xPosition;
int yPosition;
EventHelper.FacingDirection direction;
public FarmerData()
{
}
public FarmerData(int XTile, int YTile, EventHelper.FacingDirection Direction)
{
this.xPosition = XTile;
this.yPosition = YTile;
this.direction = Direction;
}
public override string ToString()
{
StringBuilder b = new StringBuilder();
b.Append("farmer");
b.Append(" ");
b.Append(this.xPosition.ToString());
b.Append(" ");
b.Append(this.yPosition.ToString());
b.Append(" ");
b.Append(((int)this.direction).ToString());
return b.ToString();
}
}
/// <summary>
/// The string builder to output the information.
/// </summary>
private StringBuilder builder;
public enum MusicToPlayType
{
None,
Continue,
}
public EventStartData()
{
this.builder = new StringBuilder();
}
/// <summary>
/// Create the start data necessary for the event.
/// </summary>
/// <param name="MusicType">A special type to determine what music is played. None or Continue.</param>
/// <param name="CameraTileX">The starting xtile for the camera</param>
/// <param name="CameraTileY">The starting y tile for the camera</param>
/// <param name="Farmer">The farmer data for the event. If null then the farmer won't be in this event.</param>
/// <param name="NPCS">The npc data for the event. If null then no npcs will be in the event.</param>
public EventStartData(MusicToPlayType MusicType, int CameraTileX, int CameraTileY, FarmerData Farmer, List<NPCData> NPCS)
{
this.builder = new StringBuilder();
if(MusicType== MusicToPlayType.None)
{
this.add("none");
}
if(MusicType== MusicToPlayType.Continue)
{
this.add("continue");
}
this.add(CameraTileX.ToString());
this.add(CameraTileY.ToString());
StringBuilder npcData = new StringBuilder();
if (Farmer != null)
{
npcData.Append(Farmer.ToString());
}
if (NPCS != null)
{
foreach(var v in NPCS)
{
npcData.Append(v.ToString());
}
}
this.add(npcData.ToString());
this.add("skippable");
}
/// <summary>
/// Create the start data necessary for the event.
/// </summary>
/// <param name="SongToPlay">The name of the song to play.</param>
/// <param name="CameraTileX">The starting xtile for the camera</param>
/// <param name="CameraTileY">The starting y tile for the camera</param>
/// <param name="Farmer">The farmer data for the event. If null then the farmer won't be in this event.</param>
/// <param name="NPCS">The npc data for the event. If null then no npcs will be in the event.</param>
public EventStartData(string SongToPlay, int CameraTileX, int CameraTileY, FarmerData Farmer, List<NPCData> NPCS)
{
this.builder = new StringBuilder();
this.add(SongToPlay);
this.add(CameraTileX.ToString());
this.add(CameraTileY.ToString());
StringBuilder npcData = new StringBuilder();
if (Farmer != null)
{
npcData.Append(Farmer.ToString());
}
if (NPCS != null)
{
foreach (var v in NPCS)
{
npcData.Append(v.ToString());
}
}
this.add(npcData.ToString());
this.add("skippable");
}
/// <summary>
/// Adds the data to a string builder to seperate out the data.
/// </summary>
/// <param name="Data"></param>
public virtual void add(string Data)
{
if (this.builder.Length > 0)
{
this.builder.Append(this.getSeperator());
}
this.builder.Append(Data);
}
/// <summary>
/// The seperator character for events.
/// </summary>
/// <returns></returns>
public string getSeperator()
{
return "/";
}
/// <summary>
/// Returns the event data.
/// </summary>
/// <returns></returns>
public override string ToString()
{
return this.builder.ToString();
}
}
}

View File

@ -8,5 +8,11 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions
{
public class EventPrecondition
{
public virtual bool meetsCondition()
{
return false;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.MISC
{
@ -40,5 +41,12 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.MISC
b.Append(this.chance.ToString());
return b.ToString();
}
public override bool meetsCondition()
{
float check = (float)Game1.random.NextDouble();
if (this.chance >= check) return true;
else return false;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.MISC
{
@ -40,5 +41,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.MISC
b.Append(this.id.ToString());
return b.ToString();
}
public override bool meetsCondition()
{
return Game1.player.activeDialogueEvents.ContainsKey(this.id) == false;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.MISC
{
@ -28,5 +29,14 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.MISC
b.Append("J");
return b.ToString();
}
/// <summary>
/// TODO: Check if this is valid.
/// </summary>
/// <returns></returns>
public override bool meetsCondition()
{
return (Game1.MasterPlayer.hasCompletedCommunityCenter() && Game1.MasterPlayer.mailReceived.Contains("JojaMember"));
}
}
}

View File

@ -35,5 +35,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.NPCSpecific
b.Append(this.npc.Name);
return b.ToString();
}
public override bool meetsCondition()
{
return Game1.player.friendshipData[this.npc.Name].IsDating();
}
}
}

View File

@ -42,5 +42,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.NPCSpecific
b.Append(this.amount.ToString());
return b.ToString();
}
public override bool meetsCondition()
{
return Game1.player.friendshipData[this.npc.Name].Points >= this.amount;
}
}
}

View File

@ -43,5 +43,11 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.NPCSpecific
b.Append(hearts.ToString());
return b.ToString();
}
public override bool meetsCondition()
{
int hearts = Game1.player.friendshipData[this.npc.Name].Points / 250;
return hearts >= this.amount;
}
}
}

View File

@ -7,7 +7,7 @@ using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.NPCSpecific
{
public class NPCInThisLocation
public class NPCInThisLocation:EventPrecondition
{
public NPC npc;
@ -41,5 +41,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.NPCSpecific
return b.ToString();
}
public override bool meetsCondition()
{
return Game1.player.currentLocation.getCharacters().Contains(this.npc);
}
}
}

View File

@ -37,5 +37,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.NPCSpecific
b.Append(this.npc.Name);
return b.ToString();
}
public override bool meetsCondition()
{
return this.npc.IsInvisible == false;
}
}
}

View File

@ -7,7 +7,7 @@ using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.NPCSpecific
{
public class NotMarriedTo:EventPrecondition
public class NotMarriedTo : EventPrecondition
{
public NPC npc;
@ -40,5 +40,12 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.NPCSpecific
return b.ToString();
}
public override bool meetsCondition()
{
if (Game1.player.getSpouse() == null) return true;
if (Game1.player.getSpouse() == this.npc) return false;
return true;
}
}
}

View File

@ -3,25 +3,26 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
public class AnsweredDialogueOptions:EventPrecondition
{
public List<string> answeredOptions;
public List<int> answeredOptions;
public AnsweredDialogueOptions()
{
this.answeredOptions = new List<string>();
this.answeredOptions = new List<int>();
}
public AnsweredDialogueOptions(string Options)
public AnsweredDialogueOptions(int Options)
{
this.answeredOptions = new List<string>();
this.answeredOptions = new List<int>();
this.answeredOptions.Add(Options);
}
public AnsweredDialogueOptions(List<string> Options)
public AnsweredDialogueOptions(List<int> Options)
{
this.answeredOptions = Options.ToList();
}
@ -50,5 +51,14 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
}
return b.ToString();
}
public override bool meetsCondition()
{
foreach(int i in this.answeredOptions)
{
if (Game1.player.DialogueQuestionsAnswered.Contains(i) == false) return false;
}
return true;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
@ -38,5 +39,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
b.Append(this.amount.ToString());
return b.ToString();
}
public override bool meetsCondition()
{
return Game1.player.Money >= this.amount;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
@ -41,5 +42,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
b.Append(this.amount.ToString());
return b.ToString();
}
public override bool meetsCondition()
{
return Game1.player.stats.DaysPlayed >= this.amount;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
@ -37,5 +38,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
b.Append(this.amount.ToString());
return b.ToString();
}
public override bool meetsCondition()
{
return Game1.player.freeSpotsInInventory() >= this.amount;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
@ -57,5 +58,9 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
return b.ToString();
}
public override bool meetsCondition()
{
return this.isMale == Game1.player.IsMale;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
@ -10,15 +11,17 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
public int id;
public int amount;
public HasItem()
{
}
public HasItem(int ID)
public HasItem(int ID,int Amount=1)
{
this.id = ID;
this.amount = Amount;
}
@ -40,5 +43,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
b.Append(this.id.ToString());
return b.ToString();
}
public override bool meetsCondition()
{
return Game1.player.hasItemInInventory(this.id,this.amount);
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
@ -38,5 +39,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
b.Append(this.id.ToString());
return b.ToString();
}
public override bool meetsCondition()
{
return Game1.player.hasOrWillReceiveMail(this.id)==false;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
@ -39,5 +40,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
return b.ToString();
}
public override bool meetsCondition()
{
return Game1.player.hasOrWillReceiveMail(this.id);
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
@ -38,5 +39,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
b.Append(this.amount.ToString());
return b.ToString();
}
public override bool meetsCondition()
{
return Game1.player.timesReachedMineBottom >= this.amount;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
@ -56,5 +57,21 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
return b.ToString();
}
public override bool meetsCondition()
{
//Cat breeds
if (Game1.player.whichPetBreed == 0 || Game1.player.whichPetBreed == 1 || Game1.player.whichPetBreed == 2)
{
if (this.wantsDog == false) return true;
else return false;
}
else
{
//Dog breeds.
if (this.wantsDog == true) return true;
else return false;
}
}
}
}

View File

@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
@ -57,5 +58,11 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
return b.ToString();
}
public override bool meetsCondition()
{
return (int)Game1.player.getTileLocation().X == this.x && (int)Game1.player.getTileLocation().Y == this.y;
}
}
}

View File

@ -3,25 +3,26 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
public class SeenEvents:EventPrecondition
public class SeenEvents : EventPrecondition
{
public List<string> seenEvents;
public List<int> seenEvents;
public SeenEvents()
{
this.seenEvents = new List<string>();
this.seenEvents = new List<int>();
}
public SeenEvents(string ID)
public SeenEvents(int ID)
{
this.seenEvents.Add(ID);
}
public SeenEvents(List<string> IDS)
public SeenEvents(List<int> IDS)
{
this.seenEvents = IDS.ToList();
}
@ -42,7 +43,7 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
b.Append("e ");
for (int i = 0; i < this.seenEvents.Count; i++)
{
b.Append(this.seenEvents[i]);
b.Append(this.seenEvents[i].ToString());
if (i != this.seenEvents.Count - 1)
{
b.Append(" ");
@ -51,5 +52,14 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
return b.ToString();
}
public override bool meetsCondition()
{
foreach (int v in this.seenEvents)
{
if (Game1.player.eventsSeen.Contains(v) == false) return false;
}
return true;
}
}
}

View File

@ -3,20 +3,21 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
public class SeenSecretNote:EventPrecondition
{
public string id;
public int id;
public SeenSecretNote()
{
}
public SeenSecretNote(string ID)
public SeenSecretNote(int ID)
{
this.id = ID;
}
@ -38,5 +39,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
b.Append(this.id.ToString());
return b.ToString();
}
public override bool meetsCondition()
{
return Game1.player.secretNotesSeen.Contains(this.id);
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
@ -59,5 +60,16 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
return b.ToString();
}
public override bool meetsCondition()
{
foreach (KeyValuePair<int, int> pair in this.shippedItems) {
if (Game1.player.basicShipped.ContainsKey(pair.Key)){
if (Game1.player.basicShipped[pair.Key] <= pair.Value) return false;
}
else return false;
}
return true;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
@ -38,5 +39,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
b.Append(this.amount.ToString());
return b.ToString();
}
public override bool meetsCondition()
{
return Game1.player.totalMoneyEarned >= this.amount;
}
}
}

View File

@ -3,24 +3,25 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
{
public class UnseenEvents:EventPrecondition
{
public List<string> unseenEvents;
public List<int> unseenEvents;
public UnseenEvents()
{
this.unseenEvents = new List<string>();
this.unseenEvents = new List<int>();
}
public UnseenEvents(string ID)
public UnseenEvents(int ID)
{
this.unseenEvents.Add(ID);
}
public UnseenEvents(List<string> IDS)
public UnseenEvents(List<int> IDS)
{
this.unseenEvents = IDS.ToList();
}
@ -49,5 +50,14 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.PlayerSpecific
}
return b.ToString();
}
public override bool meetsCondition()
{
foreach (int v in this.unseenEvents)
{
if (Game1.player.eventsSeen.Contains(v) == true) return false;
}
return true;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.TimeSpecific
{
@ -43,5 +44,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.TimeSpecific
b.Append(this.day.ToString());
return b.ToString();
}
public override bool meetsCondition()
{
return Game1.dayOfMonth == this.day;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.TimeSpecific
{
@ -83,5 +84,47 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.TimeSpecific
}
return b.ToString();
}
public override bool meetsCondition()
{
int day = Game1.dayOfMonth;
if (day % 7 == 0)
{
//Sunday
if (this.sunday) return false;
}
if (day % 7 == 1)
{
//Monday
if (this.monday) return false;
}
if (day % 7 == 2)
{
//Tuesday
if (this.tuesday) return false;
}
if (day % 7 == 3)
{
//Wednesday
if (this.wednesday) return false;
}
if (day % 7 == 4)
{
//Thursday
if (this.thursday) return false;
}
if (day % 7 == 5)
{
//Friday
if (this.friday) return false;
}
if (day % 7 == 6)
{
//Saturday
if (this.saturday) return false;
}
return true;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.TimeSpecific
{
@ -23,5 +24,10 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.TimeSpecific
b.Append("F");
return b.ToString();
}
public override bool meetsCondition()
{
return string.IsNullOrEmpty(Game1.whereIsTodaysFest) == true;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.TimeSpecific
{
@ -68,11 +69,32 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.TimeSpecific
b.Append(words[i]);
if (i != words.Count - 1)
{
b.Append(" ");
b.Append("/");
}
}
return b.ToString();
}
public override bool meetsCondition()
{
if (Game1.currentSeason == "spring")
{
if (this.spring) return false;
}
if (Game1.currentSeason == "summer")
{
if (this.summer) return false;
}
if (Game1.currentSeason == "fall")
{
if (this.fall) return false;
}
if (Game1.currentSeason == "winter")
{
if (this.winter) return false;
}return true;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.TimeSpecific
{
@ -39,5 +40,11 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.TimeSpecific
}
public override bool meetsCondition()
{
if (Game1.timeOfDay >= this.start && Game1.timeOfDay <= this.end) return true;
else return false;
}
}
}

View File

@ -64,7 +64,11 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.TimeSpecific
return "";
}
//Experimental weather checks. May or may not be used when checking for when to use an event.
public override bool meetsCondition()
{
if (Game1.weatherIcon == (int)this.weather) return true;
else return false;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.TimeSpecific
{
@ -45,5 +46,18 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions.TimeSpecific
b.Append(this.year.ToString());
return b.ToString();
}
public override bool meetsCondition()
{
if (this.year == 1)
{
if (Game1.year == 1) return true;
else return false;
}
else
{
return this.year <= Game1.year;
}
}
}
}

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Omegasis.HappyBirthday.Framework.Events.Preconditions;
namespace Omegasis.HappyBirthday.Framework.Events.SpecialPreconditions
{
public class FarmerBirthdayPrecondition:EventPrecondition
{
public FarmerBirthdayPrecondition()
{
}
public override string ToString()
{
return "Omegasis.HappyBirthday";
}
public override bool meetsCondition()
{
return HappyBirthday.Instance.IsBirthday();
}
}
}

View File

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Omegasis.HappyBirthday.Framework.Events.Preconditions;
using StardewValley;
namespace Omegasis.HappyBirthday.Framework.Events.SpecialPreconditions
{
public class SpouseBirthdayPrecondition:EventPrecondition
{
public SpouseBirthdayPrecondition()
{
}
public override bool meetsCondition()
{
if (Game1.player.getSpouse() == null) return false;
else
{
NPC spouse = Game1.player.getSpouse();
if (spouse.isBirthday(Game1.currentSeason, Game1.dayOfMonth)){
return true;
}
else
{
return false;
}
}
}
}
}

View File

@ -698,7 +698,7 @@ namespace Omegasis.HappyBirthday
}
/// <summary>Get whether today is the player's birthday.</summary>
private bool IsBirthday()
public bool IsBirthday()
{
return
this.PlayerData.BirthdayDay == Game1.dayOfMonth