private bool LastPassDialogue(DialogueConditions conditions, out IDialogueWrapper dialogue)
        {
            if (conditions.Npc.Name.Equals("Caroline") && _gameWrapper.isLocationAccessible("CommunityCenter") &&
                (conditions.Season == Season.Summer && conditions.DayOfWeek == DayOfWeek.Mon))
            {
                dialogue = _factory.CreateInstance <IDialogueWrapper>(
                    conditions.Npc.Dialogue["summer_Wed"], conditions.Npc);
                return(true);
            }

            if (CheckIfDialogueContainsKey(conditions.Npc,
                                           FluentDialogueBuilder.New(conditions).Season().DayOfWeek().FirstOrSecondYear().Married().Build(_logger),
                                           out dialogue))
            {
                return(true);
            }

            if (CheckIfDialogueContainsKey(conditions.Npc,
                                           FluentDialogueBuilder.New(conditions).Season().DayOfWeek().Married().Build(_logger),
                                           out dialogue))
            {
                return(true);
            }

            dialogue = null;
            return(false);
        }
 public DialogueLogic(IConditionRepository conditionRepository, IMonitor logger, IWrapperFactory factory)
 {
     _factory             = factory;
     _conditionRepository = conditionRepository;
     _logger      = logger;
     _gameWrapper = _factory.CreateInstance <IGameWrapper>();
 }
        private static bool Prefix(ref NPC __instance, ref string preface, ref Dialogue __result)
        {
            var npc = _wrapperFactory.CreateInstance <INPCWrapper>(__instance, Logger);

            __result = _dialogueLogic.GetDialogue(ref npc, !string.IsNullOrEmpty(preface)).GetBaseType;
            if (__result == null)
            {
                Logger.Log("Value is null", LogLevel.Alert);
            }
            else
            {
                Logger.Log(__result.getCurrentDialogue(), LogLevel.Alert);
            }
            return(true);
        }
        private void BuildConditions(string name, int year,
                                     Season season, int day, DayOfWeek weekday, string spouse, int hearts, bool cc, bool key)
        {
            var exNpc = new ExtendNPC()
            {
                SetDialogue = MockData.CharacterDialogue(name) as Dictionary <string, string>
            };
            var npc = _factory.CreateInstance <INPCWrapper>(exNpc);

            npc.Name = name;
            ((MockNPCWrapper)npc).MockDialogue = MockData.CharacterDialogue(name);

            dynamic game = _factory.CreateInstance <IGameWrapper>();

            game.year          = year;
            game.currentSeason = season == Season.Unknown ? string.Empty : season.ToString().ToLower();
            game.dayOfMonth    = day;
            game.shortDayNameFromDayOfSeason = new Func <int, string>(i => weekday.ToString());
            game.player.spouse         = spouse;
            game.player.friendshipData = new Dictionary <string, IFriendshipWrapper>();
            if (hearts > 0)
            {
                var friendship = _factory.CreateInstance <IFriendshipWrapper>();
                friendship.Points = hearts;
                ((Dictionary <string, IFriendshipWrapper>)game.player.friendshipData).Add(name, friendship);
            }

            game.isLocationAccessible = new Func <string, bool>(s => cc);
            game.player.HasTownKey    = key;
            Game1.content             = new MockLocalizedContentManager(new MockServiceProvider(), Path.Combine("..", "..", ".."));
            Game1.random = new Random();

            ((MockWrapperFactory)_factory).SetInstance <IGameWrapper>(objects => game);
            //Console.WriteLine($"{name} {year} {season} {day} {weekday} {spouse} {hearts} {cc} {key}");

            if (name == "Jodi" && year == 1 && season == Season.Unknown && day == 2 && weekday == DayOfWeek.Tue && spouse == "" && hearts == 250)
            {
                var x = 45;
            }

            var vanillaTest = new TestNPC {
                Game = game, NPC = npc
            };
            var vanillaResult = vanillaTest.tryToRetrieveDialogue(season == Season.Unknown ? string.Empty : season.ToString().ToLower() + "_", hearts / 250);
            var patchTest     = new DialogueLogic(new ConditionRepository(), _logger, _factory);

            var patchResult = patchTest.GetDialogue(ref npc, season != Season.Unknown);

            if (vanillaResult == null)
            {
                if (patchResult != null)
                {
                    Console.WriteLine(string.Join(",", patchResult.CurrentEmotion));
                    Console.WriteLine($"{name} {year} {season} {day} {weekday} {spouse} {hearts} {cc} {key}");
                }
                Assert.AreEqual(null, patchResult);
                //Console.WriteLine("Is Null");
            }
            else
            {
                if (vanillaResult?.CurrentEmotion != patchResult?.CurrentEmotion)
                {
                    Console.WriteLine(vanillaResult.CurrentEmotion);
                    Console.WriteLine(patchResult?.CurrentEmotion);
                    Console.WriteLine($"{name} {year} {season} {day} {weekday} {spouse} {hearts} {cc} {key}");
                }
                Assert.That(vanillaResult?.CurrentEmotion == patchResult?.CurrentEmotion);
            }
        }