From f450efdcc798fea1759f2e4bb34ab320135e7927 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 4 Dec 2019 13:24:21 -0800 Subject: [PATCH] Added in precondition checks for events. Also added in special birthday precondition events. --- .../Framework/Events/EventHelper.cs | 193 +++++++++++++---- .../Framework/Events/EventStartData.cs | 204 ++++++++++++++++++ .../Events/Preconditions/EventPrecondition.cs | 6 + .../Preconditions/MISC/ChanceToOccur.cs | 8 + .../Preconditions/MISC/EventNotInProgress.cs | 6 + .../MISC/JojaWarehouseCompleted.cs | 10 + .../Preconditions/NPCSpecific/DatingNPC.cs | 5 + .../NPCSpecific/FriendshipPointsRequired.cs | 5 + .../NPCSpecific/HeartsRequired.cs | 6 + .../NPCSpecific/NPCInThisLocation.cs | 7 +- .../Preconditions/NPCSpecific/NotInvisible.cs | 5 + .../Preconditions/NPCSpecific/NotMarriedTo.cs | 9 +- .../PlayerSpecific/AnsweredDialogueOptions.cs | 20 +- .../PlayerSpecific/CurrentMoney.cs | 6 + .../PlayerSpecific/DaysPlayedFor.cs | 6 + .../PlayerSpecific/EmptyInventorySlots.cs | 6 + .../Preconditions/PlayerSpecific/Gender.cs | 5 + .../Preconditions/PlayerSpecific/HasItem.cs | 10 +- .../PlayerSpecific/HasNotRecievedLetter.cs | 6 + .../PlayerSpecific/HasRecievedLetter.cs | 6 + .../PlayerSpecific/MineBottomHit.cs | 6 + .../PlayerSpecific/PetPreference.cs | 17 ++ .../PlayerSpecific/PlayerOnThisTile.cs | 7 + .../PlayerSpecific/SeenEvents.cs | 22 +- .../PlayerSpecific/SeenSecretNote.cs | 10 +- .../PlayerSpecific/ShippedItems.cs | 12 ++ .../PlayerSpecific/TotalMoneyEarned.cs | 6 + .../PlayerSpecific/UnseenEvents.cs | 18 +- .../TimeSpecific/DayOfTheMonth.cs | 6 + .../EventDayExclusionPrecondition.cs | 43 ++++ .../TimeSpecific/NotAFestivalDay.cs | 6 + .../TimeSpecific/SeasonExclusion.cs | 24 ++- .../TimeSpecific/TimePrecondition.cs | 7 + .../TimeSpecific/WeatherPrecondition.cs | 6 +- .../TimeSpecific/YearPrecondition.cs | 14 ++ .../FarmerBirthdayPrecondition.cs | 30 +++ .../SpouseBirthdayPrecondition.cs | 36 ++++ GeneralMods/HappyBirthday/HappyBirthday.cs | 2 +- 38 files changed, 731 insertions(+), 70 deletions(-) create mode 100644 GeneralMods/HappyBirthday/Framework/Events/EventStartData.cs create mode 100644 GeneralMods/HappyBirthday/Framework/Events/SpecialPreconditions/FarmerBirthdayPrecondition.cs create mode 100644 GeneralMods/HappyBirthday/Framework/Events/SpecialPreconditions/SpouseBirthdayPrecondition.cs diff --git a/GeneralMods/HappyBirthday/Framework/Events/EventHelper.cs b/GeneralMods/HappyBirthday/Framework/Events/EventHelper.cs index 330935eb..129c448a 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/EventHelper.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/EventHelper.cs @@ -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 eventPreconditions; public int eventID; public EventHelper() { - + this.eventData = new StringBuilder(); + this.eventPreconditionData = new StringBuilder(); + this.eventPreconditions = new List(); } - 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(); + this.eventPreconditions.Add(NotTheseDays); + this.eventPreconditions.Add(Time); } - public EventHelper(List Conditions) + public EventHelper(List Conditions, EventStartData StartData) { this.eventData = new StringBuilder(); - foreach(var v in Conditions) + this.eventPreconditions = new List(); + 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()); } /// - /// 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. /// /// 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()); } + /// + /// Adds in the data to the event data.Aka what happens during the event. + /// + /// public virtual void add(string Data) { @@ -122,6 +105,15 @@ namespace Omegasis.HappyBirthday.Framework.Events this.eventData.Append(Data); } + /// + /// Adds in the data to the event data. Aka what happens during the event. + /// + /// + public virtual void add(StringBuilder Builder) + { + this.add(Builder.ToString()); + } + /// /// Converts the direction to enum. @@ -175,7 +167,7 @@ namespace Omegasis.HappyBirthday.Framework.Events /// 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 // //~~~~~~~~~~~~~~~~// + /// + /// Adds an object at the specified tile from the TileSheets\Craftables.png sprite sheet + /// + /// + /// + /// 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); } + /// + /// Starts an active dialogue event with the given ID and a length of 4 days. + /// + /// + public virtual void addConversationTopic(string ID) + { + StringBuilder b = new StringBuilder(); + b.Append("addBigProp "); + b.Append(ID); + this.add(b); + } + /// + /// Adds the specified cooking recipe to the player. + /// + /// + public virtual void addCookingRecipe(string Recipe) + { + StringBuilder b = new StringBuilder(); + b.Append("addCookingRecipe "); + b.Append(Recipe); + this.add(b); + } + + /// + /// Adds the specified crafting recipe to the player. + /// + /// + public virtual void addCraftingRecipe(string Recipe) + { + StringBuilder b = new StringBuilder(); + b.Append("addCraftingRecipe "); + b.Append(Recipe); + this.add(b); + } + + /// + /// Add a non-solid prop from the current festival texture. Default solid width/height is 1. Default display height is solid height. + /// + 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); + } + + /// + /// 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. + /// + /// + /// + /// + /// + 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); + } + + /// + /// Set a letter as received. + /// + /// + public virtual void addMailReceived(string ID) + { + StringBuilder b = new StringBuilder(); + b.Append("addMailReceived "); + b.Append(ID); + this.add(b); + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/EventStartData.cs b/GeneralMods/HappyBirthday/Framework/Events/EventStartData.cs new file mode 100644 index 00000000..df16c167 --- /dev/null +++ b/GeneralMods/HappyBirthday/Framework/Events/EventStartData.cs @@ -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 + { + /// + /// Data pertaining to npcs information necessary for the event. + /// + 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(); + } + } + + /// + /// Data pertaining to the farmer data for the event. + /// + 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(); + + } + } + + /// + /// The string builder to output the information. + /// + private StringBuilder builder; + + public enum MusicToPlayType + { + None, + Continue, + } + + + public EventStartData() + { + this.builder = new StringBuilder(); + } + + /// + /// Create the start data necessary for the event. + /// + /// A special type to determine what music is played. None or Continue. + /// The starting xtile for the camera + /// The starting y tile for the camera + /// The farmer data for the event. If null then the farmer won't be in this event. + /// The npc data for the event. If null then no npcs will be in the event. + public EventStartData(MusicToPlayType MusicType, int CameraTileX, int CameraTileY, FarmerData Farmer, List 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"); + + } + + /// + /// Create the start data necessary for the event. + /// + /// The name of the song to play. + /// The starting xtile for the camera + /// The starting y tile for the camera + /// The farmer data for the event. If null then the farmer won't be in this event. + /// The npc data for the event. If null then no npcs will be in the event. + public EventStartData(string SongToPlay, int CameraTileX, int CameraTileY, FarmerData Farmer, List 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"); + + } + + /// + /// Adds the data to a string builder to seperate out the data. + /// + /// + public virtual void add(string Data) + { + if (this.builder.Length > 0) + { + this.builder.Append(this.getSeperator()); + } + this.builder.Append(Data); + } + + /// + /// The seperator character for events. + /// + /// + public string getSeperator() + { + return "/"; + } + + /// + /// Returns the event data. + /// + /// + public override string ToString() + { + return this.builder.ToString(); + } + } +} diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/EventPrecondition.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/EventPrecondition.cs index f97ca340..27c8c70d 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/EventPrecondition.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/EventPrecondition.cs @@ -8,5 +8,11 @@ namespace Omegasis.HappyBirthday.Framework.Events.Preconditions { public class EventPrecondition { + + + public virtual bool meetsCondition() + { + return false; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/MISC/ChanceToOccur.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/MISC/ChanceToOccur.cs index 76770b7e..cdb7a0c5 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/MISC/ChanceToOccur.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/MISC/ChanceToOccur.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/MISC/EventNotInProgress.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/MISC/EventNotInProgress.cs index eaa421ae..a306481f 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/MISC/EventNotInProgress.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/MISC/EventNotInProgress.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/MISC/JojaWarehouseCompleted.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/MISC/JojaWarehouseCompleted.cs index 4b30e319..e658a79c 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/MISC/JojaWarehouseCompleted.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/MISC/JojaWarehouseCompleted.cs @@ -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(); } + + /// + /// TODO: Check if this is valid. + /// + /// + public override bool meetsCondition() + { + return (Game1.MasterPlayer.hasCompletedCommunityCenter() && Game1.MasterPlayer.mailReceived.Contains("JojaMember")); + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/DatingNPC.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/DatingNPC.cs index f0825441..8a63cdc0 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/DatingNPC.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/DatingNPC.cs @@ -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(); + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/FriendshipPointsRequired.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/FriendshipPointsRequired.cs index 016997eb..9f906338 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/FriendshipPointsRequired.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/FriendshipPointsRequired.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/HeartsRequired.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/HeartsRequired.cs index f4d71130..a6b0a0b6 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/HeartsRequired.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/HeartsRequired.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/NPCInThisLocation.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/NPCInThisLocation.cs index 9efc48a1..b3180d3b 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/NPCInThisLocation.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/NPCInThisLocation.cs @@ -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); + } + } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/NotInvisible.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/NotInvisible.cs index e41fa870..5d351186 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/NotInvisible.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/NotInvisible.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/NotMarriedTo.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/NotMarriedTo.cs index 6b77c845..545995b9 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/NotMarriedTo.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/NPCSpecific/NotMarriedTo.cs @@ -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; + } + } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/AnsweredDialogueOptions.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/AnsweredDialogueOptions.cs index 4af64eb5..46d406c0 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/AnsweredDialogueOptions.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/AnsweredDialogueOptions.cs @@ -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 answeredOptions; + public List answeredOptions; public AnsweredDialogueOptions() { - this.answeredOptions = new List(); + this.answeredOptions = new List(); } - public AnsweredDialogueOptions(string Options) + public AnsweredDialogueOptions(int Options) { - this.answeredOptions = new List(); + this.answeredOptions = new List(); this.answeredOptions.Add(Options); } - public AnsweredDialogueOptions(List Options) + public AnsweredDialogueOptions(List 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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/CurrentMoney.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/CurrentMoney.cs index dd1fd629..4e85192e 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/CurrentMoney.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/CurrentMoney.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/DaysPlayedFor.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/DaysPlayedFor.cs index 0150b349..7fc666ae 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/DaysPlayedFor.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/DaysPlayedFor.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/EmptyInventorySlots.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/EmptyInventorySlots.cs index ce81005a..92fade3c 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/EmptyInventorySlots.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/EmptyInventorySlots.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/Gender.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/Gender.cs index 5e2fd150..9e36e44c 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/Gender.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/Gender.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/HasItem.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/HasItem.cs index f51734b9..0f065207 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/HasItem.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/HasItem.cs @@ -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); + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/HasNotRecievedLetter.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/HasNotRecievedLetter.cs index 9bd38f98..013b9679 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/HasNotRecievedLetter.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/HasNotRecievedLetter.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/HasRecievedLetter.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/HasRecievedLetter.cs index 5415c8cc..7f8fdb1d 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/HasRecievedLetter.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/HasRecievedLetter.cs @@ -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); + } + } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/MineBottomHit.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/MineBottomHit.cs index 86856f11..c1ae5fb1 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/MineBottomHit.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/MineBottomHit.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/PetPreference.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/PetPreference.cs index e0f23876..475d6b9e 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/PetPreference.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/PetPreference.cs @@ -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; + } + } + } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/PlayerOnThisTile.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/PlayerOnThisTile.cs index 00c69256..1da78969 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/PlayerOnThisTile.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/PlayerOnThisTile.cs @@ -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; + } + } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/SeenEvents.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/SeenEvents.cs index 1a7ab2f5..22be7440 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/SeenEvents.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/SeenEvents.cs @@ -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 seenEvents; + public List seenEvents; public SeenEvents() { - this.seenEvents = new List(); + this.seenEvents = new List(); } - public SeenEvents(string ID) + public SeenEvents(int ID) { this.seenEvents.Add(ID); } - public SeenEvents(List IDS) + public SeenEvents(List 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; + } + } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/SeenSecretNote.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/SeenSecretNote.cs index 14ff9463..76303066 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/SeenSecretNote.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/SeenSecretNote.cs @@ -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); + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/ShippedItems.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/ShippedItems.cs index bb0b0ee6..8061494c 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/ShippedItems.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/ShippedItems.cs @@ -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 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; + } + } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/TotalMoneyEarned.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/TotalMoneyEarned.cs index 64faff19..ed4cf6b5 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/TotalMoneyEarned.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/TotalMoneyEarned.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/UnseenEvents.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/UnseenEvents.cs index 57a01d51..8556c5ab 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/UnseenEvents.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/PlayerSpecific/UnseenEvents.cs @@ -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 unseenEvents; + public List unseenEvents; public UnseenEvents() { - this.unseenEvents = new List(); + this.unseenEvents = new List(); } - public UnseenEvents(string ID) + public UnseenEvents(int ID) { this.unseenEvents.Add(ID); } - public UnseenEvents(List IDS) + public UnseenEvents(List 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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/DayOfTheMonth.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/DayOfTheMonth.cs index 59ee5b22..125dcb02 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/DayOfTheMonth.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/DayOfTheMonth.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/EventDayExclusionPrecondition.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/EventDayExclusionPrecondition.cs index 005430a7..57cacec5 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/EventDayExclusionPrecondition.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/EventDayExclusionPrecondition.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/NotAFestivalDay.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/NotAFestivalDay.cs index 5260edcc..8d92cc20 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/NotAFestivalDay.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/NotAFestivalDay.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/SeasonExclusion.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/SeasonExclusion.cs index 3f9747e6..fbb28637 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/SeasonExclusion.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/SeasonExclusion.cs @@ -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; + + } + } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/TimePrecondition.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/TimePrecondition.cs index d2268abb..3a5a5480 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/TimePrecondition.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/TimePrecondition.cs @@ -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; + } + } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/WeatherPrecondition.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/WeatherPrecondition.cs index d54a7de4..76c26e4f 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/WeatherPrecondition.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/WeatherPrecondition.cs @@ -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; + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/YearPrecondition.cs b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/YearPrecondition.cs index e5c0addc..fb5a9a3f 100644 --- a/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/YearPrecondition.cs +++ b/GeneralMods/HappyBirthday/Framework/Events/Preconditions/TimeSpecific/YearPrecondition.cs @@ -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; + } + } } } diff --git a/GeneralMods/HappyBirthday/Framework/Events/SpecialPreconditions/FarmerBirthdayPrecondition.cs b/GeneralMods/HappyBirthday/Framework/Events/SpecialPreconditions/FarmerBirthdayPrecondition.cs new file mode 100644 index 00000000..165db6c8 --- /dev/null +++ b/GeneralMods/HappyBirthday/Framework/Events/SpecialPreconditions/FarmerBirthdayPrecondition.cs @@ -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(); + } + + } +} diff --git a/GeneralMods/HappyBirthday/Framework/Events/SpecialPreconditions/SpouseBirthdayPrecondition.cs b/GeneralMods/HappyBirthday/Framework/Events/SpecialPreconditions/SpouseBirthdayPrecondition.cs new file mode 100644 index 00000000..c167090c --- /dev/null +++ b/GeneralMods/HappyBirthday/Framework/Events/SpecialPreconditions/SpouseBirthdayPrecondition.cs @@ -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; + } + } + } + } +} diff --git a/GeneralMods/HappyBirthday/HappyBirthday.cs b/GeneralMods/HappyBirthday/HappyBirthday.cs index c988934f..6912666c 100644 --- a/GeneralMods/HappyBirthday/HappyBirthday.cs +++ b/GeneralMods/HappyBirthday/HappyBirthday.cs @@ -698,7 +698,7 @@ namespace Omegasis.HappyBirthday } /// Get whether today is the player's birthday. - private bool IsBirthday() + public bool IsBirthday() { return this.PlayerData.BirthdayDay == Game1.dayOfMonth