Example #1
0
        /// <summary>Get the fields to display for a monster.</summary>
        /// <param name="monster">The monster for which to show info.</param>
        /// <remarks>Derived from <see cref="Monster.parseMonsterInfo"/>.</remarks>
        private IEnumerable <ICustomField> GetDataForMonster(Monster monster)
        {
            // basic info
            bool canRerollDrops = Game1.player.isWearingRing(Ring.burglarsRing);

            yield return(new GenericField(this.GameHelper, L10n.Monster.Invincible(), L10n.Generic.Seconds(count: this.Reflection.GetField <int>(monster, "invincibleCountdown").GetValue()), hasValue: monster.isInvincible()));

            yield return(new PercentageBarField(this.GameHelper, L10n.Monster.Health(), monster.Health, monster.MaxHealth, Color.Green, Color.Gray, L10n.Generic.PercentRatio(percent: (int)Math.Round((monster.Health / (monster.MaxHealth * 1f) * 100)), value: monster.Health, max: monster.MaxHealth)));

            yield return(new ItemDropListField(this.GameHelper, L10n.Monster.Drops(), this.GetMonsterDrops(monster), fadeNonGuaranteed: true, crossOutNonGuaranteed: !canRerollDrops, defaultText: L10n.Monster.DropsNothing()));

            yield return(new GenericField(this.GameHelper, L10n.Monster.Experience(), this.Stringify(monster.ExperienceGained)));

            yield return(new GenericField(this.GameHelper, L10n.Monster.Defense(), this.Stringify(monster.resilience.Value)));

            yield return(new GenericField(this.GameHelper, L10n.Monster.Attack(), this.Stringify(monster.DamageToFarmer)));

            // Adventure Guild quest
            AdventureGuildQuestData adventureGuildQuest = this.Metadata.GetAdventurerGuildQuest(monster.Name);

            if (adventureGuildQuest != null)
            {
                int kills = adventureGuildQuest.Targets.Select(p => Game1.stats.getMonstersKilled(p)).Sum();
                yield return(new GenericField(this.GameHelper, L10n.Monster.AdventureGuild(), $"{(kills >= adventureGuildQuest.RequiredKills ? L10n.Monster.AdventureGuildComplete() : L10n.Monster.AdventureGuildIncomplete())} ({L10n.Monster.AdventureGuildProgress(count: kills, requiredCount: adventureGuildQuest.RequiredKills)})"));
            }
        }
Example #2
0
        /// <summary>Get the data to display for this subject.</summary>
        /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
        public override IEnumerable <ICustomField> GetData(Metadata metadata)
        {
            NPC npc = this.Target;

            switch (this.TargetType)
            {
            case TargetType.Villager:
                if (!metadata.Constants.AsocialVillagers.Contains(npc.getName()))
                {
                    var giftTastes = this.GetGiftTastes(npc, metadata);

                    yield return(new GenericField("Birthday", $"{Utility.capitalizeFirstLetter(npc.birthday_Season)} {npc.birthday_Day}"));

                    // friendship
                    if (Game1.player.friendships.ContainsKey(npc.name))
                    {
                        FriendshipModel friendship = DataParser.GetFriendshipForVillager(Game1.player, npc, metadata);
                        yield return(new GenericField("Can romance", friendship.IsSpouse ? "you're married! <" : TextHelper.Stringify(npc.datable)));

                        yield return(new CharacterFriendshipField("Friendship", friendship));

                        yield return(new GenericField("Talked today", Game1.player.friendships[npc.name][2] == 1));

                        yield return(new GenericField("Gifted today", Game1.player.friendships[npc.name][3] > 0));

                        if (!friendship.IsSpouse)
                        {
                            yield return(new GenericField("Gifted this week", $"{Game1.player.friendships[npc.name][1]} of {NPC.maxGiftsPerWeek}"));
                        }
                    }
                    else
                    {
                        yield return(new GenericField("Friendship", "You haven't met them yet."));
                    }
                    yield return(new CharacterGiftTastesField("Loves gifts", giftTastes, GiftTaste.Love));

                    yield return(new CharacterGiftTastesField("Likes gifts", giftTastes, GiftTaste.Like));
                }
                break;

            case TargetType.Pet:
                Pet pet = (Pet)npc;
                yield return(new CharacterFriendshipField("Love", DataParser.GetFriendshipForPet(Game1.player, pet)));

                yield return(new GenericField("Petted today", this.Reflection.GetPrivateValue <bool>(pet, "wasPetToday")));

                break;

            case TargetType.Monster:
                // basic info
                Monster monster = (Monster)npc;
                yield return(new GenericField("Invincible", $"For {this.Reflection.GetPrivateValue<int>(monster, "invincibleCountdown")} seconds", hasValue: monster.isInvincible()));

                yield return(new PercentageBarField("Health", monster.health, monster.maxHealth, Color.Green, Color.Gray, $"{Math.Round((monster.health / (monster.maxHealth * 1f) * 100))}% ({monster.health} of {monster.maxHealth})"));

                yield return(new ItemDropListField("Drops", this.GetMonsterDrops(monster), defaultText: "nothing"));

                yield return(new GenericField("XP", monster.experienceGained));

                yield return(new GenericField("Defence", monster.resilience));

                yield return(new GenericField("Attack", monster.damageToFarmer));

                // Adventure Guild quest
                AdventureGuildQuestData adventureGuildQuest = metadata.GetAdventurerGuildQuest(monster.name);
                if (adventureGuildQuest != null)
                {
                    int kills = adventureGuildQuest.Targets.Select(p => Game1.stats.getMonstersKilled(p)).Sum();
                    yield return(new GenericField("Adventure Guild", $"{(kills >= adventureGuildQuest.RequiredKills ? "complete" : "in progress")} (killed {kills} of {adventureGuildQuest.RequiredKills})"));
                }
                break;
            }
        }
Example #3
0
        /// <summary>Get the data to display for this subject.</summary>
        /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
        public override IEnumerable <ICustomField> GetData(Metadata metadata)
        {
            NPC npc = this.Target;

            switch (this.TargetType)
            {
            case TargetType.Villager:
                // special NPCs like Gunther
                if (metadata.Constants.AsocialVillagers.Contains(npc.Name))
                {
                    // no data
                }

                // children
                else if (npc is Child child)
                {
                    // birthday
                    SDate birthday = SDate.Now().AddDays(-child.daysOld.Value);
                    yield return(new GenericField(this.GameHelper, L10n.Npc.Birthday(), this.Text.Stringify(birthday, withYear: true)));

                    // age
                    {
                        ChildAge stage      = (ChildAge)child.Age;
                        int      daysOld    = child.daysOld.Value;
                        int      daysToNext = this.GetDaysToNextChildGrowth(stage, daysOld);
                        bool     isGrown    = daysToNext == -1;
                        int      daysAtNext = daysOld + (isGrown ? 0 : daysToNext);

                        string ageDesc = isGrown
                                ? L10n.NpcChild.AgeDescriptionGrown(label: stage)
                                : L10n.NpcChild.AgeDescriptionPartial(label: stage, count: daysToNext, nextLabel: stage + 1);

                        yield return(new PercentageBarField(this.GameHelper, L10n.NpcChild.Age(), child.daysOld.Value, daysAtNext, Color.Green, Color.Gray, ageDesc));
                    }

                    // friendship
                    if (Game1.player.friendshipData.ContainsKey(child.Name))
                    {
                        FriendshipModel friendship = this.GameHelper.GetFriendshipForVillager(Game1.player, child, Game1.player.friendshipData[child.Name], metadata);
                        yield return(new CharacterFriendshipField(this.GameHelper, L10n.Npc.Friendship(), friendship, this.Text));

                        yield return(new GenericField(this.GameHelper, L10n.Npc.TalkedToday(), this.Stringify(Game1.player.friendshipData[child.Name].TalkedToToday)));
                    }
                }

                // villagers
                else
                {
                    // birthday
                    if (npc.Birthday_Season != null)
                    {
                        SDate birthday = new SDate(npc.Birthday_Day, npc.Birthday_Season);
                        yield return(new GenericField(this.GameHelper, L10n.Npc.Birthday(), this.Text.Stringify(birthday)));
                    }

                    // friendship
                    if (Game1.player.friendshipData.ContainsKey(npc.Name))
                    {
                        // friendship/romance
                        FriendshipModel friendship = this.GameHelper.GetFriendshipForVillager(Game1.player, npc, Game1.player.friendshipData[npc.Name], metadata);
                        yield return(new GenericField(this.GameHelper, L10n.Npc.CanRomance(), friendship.IsSpouse ? L10n.Npc.CanRomanceMarried() : this.Stringify(friendship.CanDate)));

                        yield return(new CharacterFriendshipField(this.GameHelper, L10n.Npc.Friendship(), friendship, this.Text));

                        // talked/gifted today
                        yield return(new GenericField(this.GameHelper, L10n.Npc.TalkedToday(), this.Stringify(friendship.TalkedToday)));

                        yield return(new GenericField(this.GameHelper, L10n.Npc.GiftedToday(), this.Stringify(friendship.GiftsToday > 0)));

                        // kissed today
                        if (friendship.IsSpouse)
                        {
                            yield return(new GenericField(this.GameHelper, L10n.Npc.KissedToday(), this.Stringify(npc.hasBeenKissedToday.Value)));
                        }

                        // gifted this week
                        if (!friendship.IsSpouse)
                        {
                            yield return(new GenericField(this.GameHelper, L10n.Npc.GiftedThisWeek(), L10n.Generic.Ratio(value: friendship.GiftsThisWeek, max: NPC.maxGiftsPerWeek)));
                        }
                    }
                    else
                    {
                        yield return(new GenericField(this.GameHelper, L10n.Npc.Friendship(), L10n.Npc.FriendshipNotMet()));
                    }

                    // gift tastes
                    var giftTastes = this.GetGiftTastes(npc, metadata);
                    yield return(new CharacterGiftTastesField(this.GameHelper, L10n.Npc.LovesGifts(), giftTastes, GiftTaste.Love));

                    yield return(new CharacterGiftTastesField(this.GameHelper, L10n.Npc.LikesGifts(), giftTastes, GiftTaste.Like));

                    yield return(new CharacterGiftTastesField(this.GameHelper, L10n.Npc.NeutralGifts(), giftTastes, GiftTaste.Neutral));
                }
                break;

            case TargetType.Pet:
                Pet pet = (Pet)npc;
                yield return(new CharacterFriendshipField(this.GameHelper, L10n.Pet.Love(), this.GameHelper.GetFriendshipForPet(Game1.player, pet), this.Text));

                yield return(new GenericField(this.GameHelper, L10n.Pet.PettedToday(), this.Stringify(this.Reflection.GetField <bool>(pet, "wasPetToday").GetValue())));

                break;

            case TargetType.Monster:
                // basic info
                Monster monster        = (Monster)npc;
                bool    canRerollDrops = Game1.player.isWearingRing(Ring.burglarsRing);

                yield return(new GenericField(this.GameHelper, L10n.Monster.Invincible(), L10n.Generic.Seconds(count: this.Reflection.GetField <int>(monster, "invincibleCountdown").GetValue()), hasValue: monster.isInvincible()));

                yield return(new PercentageBarField(this.GameHelper, L10n.Monster.Health(), monster.Health, monster.MaxHealth, Color.Green, Color.Gray, L10n.Generic.PercentRatio(percent: (int)Math.Round((monster.Health / (monster.MaxHealth * 1f) * 100)), value: monster.Health, max: monster.MaxHealth)));

                yield return(new ItemDropListField(this.GameHelper, L10n.Monster.Drops(), this.GetMonsterDrops(monster), fadeNonGuaranteed: true, crossOutNonGuaranteed: !canRerollDrops, defaultText: L10n.Monster.DropsNothing()));

                yield return(new GenericField(this.GameHelper, L10n.Monster.Experience(), this.Stringify(monster.ExperienceGained)));

                yield return(new GenericField(this.GameHelper, L10n.Monster.Defence(), this.Stringify(monster.resilience.Value)));

                yield return(new GenericField(this.GameHelper, L10n.Monster.Attack(), this.Stringify(monster.DamageToFarmer)));

                // Adventure Guild quest
                AdventureGuildQuestData adventureGuildQuest = metadata.GetAdventurerGuildQuest(monster.Name);
                if (adventureGuildQuest != null)
                {
                    int kills = adventureGuildQuest.Targets.Select(p => Game1.stats.getMonstersKilled(p)).Sum();
                    yield return(new GenericField(this.GameHelper, L10n.Monster.AdventureGuild(), $"{(kills >= adventureGuildQuest.RequiredKills ? L10n.Monster.AdventureGuildComplete() : L10n.Monster.AdventureGuildIncomplete())} ({L10n.Monster.AdventureGuildProgress(count: kills, requiredCount: adventureGuildQuest.RequiredKills)})"));
                }
                break;
            }
        }
Example #4
0
        /// <summary>Get the data to display for this subject.</summary>
        /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
        public override IEnumerable <ICustomField> GetData(Metadata metadata)
        {
            NPC npc = this.Target;

            switch (this.TargetType)
            {
            case TargetType.Villager:
                // special NPCs like Gunther
                if (metadata.Constants.AsocialVillagers.Contains(npc.name))
                {
                    // no data
                }

                // children
                else if (npc is Child child)
                {
                    // birthday
                    SDate birthday = SDate.Now().AddDays(-child.daysOld);
                    yield return(new GenericField(this.Text.Get(L10n.Npc.Birthday), this.Text.Stringify(birthday, withYear: true)));

                    // age
                    {
                        ChildAge stage      = (ChildAge)child.age;
                        int      daysOld    = child.daysOld;
                        int      daysToNext = this.GetDaysToNextChildGrowth(stage, daysOld);
                        bool     isGrown    = daysToNext == -1;
                        int      daysAtNext = daysOld + (isGrown ? 0 : daysToNext);

                        string ageLabel = this.Translate(L10n.NpcChild.Age);
                        string ageName  = this.Translate(L10n.For(stage));
                        string ageDesc  = isGrown
                                ? this.Translate(L10n.NpcChild.AgeDescriptionGrown, new { label = ageName })
                                : this.Translate(L10n.NpcChild.AgeDescriptionPartial, new { label = ageName, count = daysToNext, nextLabel = this.Text.Get(L10n.For(stage + 1)) });

                        yield return(new PercentageBarField(ageLabel, child.daysOld, daysAtNext, Color.Green, Color.Gray, ageDesc));
                    }

                    // friendship
                    if (Game1.player.friendships.ContainsKey(child.name))
                    {
                        FriendshipModel friendship = DataParser.GetFriendshipForVillager(Game1.player, child, metadata);
                        yield return(new CharacterFriendshipField(this.Translate(L10n.Npc.Friendship), friendship, this.Text));

                        yield return(new GenericField(this.Translate(L10n.Npc.TalkedToday), this.Stringify(Game1.player.friendships[child.name][2] == 1)));
                    }
                }

                // villagers
                else
                {
                    // birthday
                    if (npc.birthday_Season != null)
                    {
                        SDate birthday = new SDate(npc.birthday_Day, npc.birthday_Season);
                        yield return(new GenericField(this.Text.Get(L10n.Npc.Birthday), this.Text.Stringify(birthday)));
                    }

                    // friendship
                    if (Game1.player.friendships.ContainsKey(npc.name))
                    {
                        FriendshipModel friendship = DataParser.GetFriendshipForVillager(Game1.player, npc, metadata);
                        yield return(new GenericField(this.Translate(L10n.Npc.CanRomance), friendship.IsSpouse ? this.Translate(L10n.Npc.CanRomanceMarried) : this.Stringify(npc.datable)));

                        yield return(new CharacterFriendshipField(this.Translate(L10n.Npc.Friendship), friendship, this.Text));

                        yield return(new GenericField(this.Translate(L10n.Npc.TalkedToday), this.Stringify(Game1.player.friendships[npc.name][2] == 1)));

                        yield return(new GenericField(this.Translate(L10n.Npc.GiftedToday), this.Stringify(Game1.player.friendships[npc.name][3] > 0)));

                        if (!friendship.IsSpouse)
                        {
                            yield return(new GenericField(this.Translate(L10n.Npc.GiftedThisWeek), this.Translate(L10n.Generic.Ratio, new { value = Game1.player.friendships[npc.name][1], max = NPC.maxGiftsPerWeek })));
                        }
                    }
                    else
                    {
                        yield return(new GenericField(this.Translate(L10n.Npc.Friendship), this.Translate(L10n.Npc.FriendshipNotMet)));
                    }

                    // gift tastes
                    var giftTastes = this.GetGiftTastes(npc, metadata);
                    yield return(new CharacterGiftTastesField(this.Translate(L10n.Npc.LovesGifts), giftTastes, GiftTaste.Love));

                    yield return(new CharacterGiftTastesField(this.Translate(L10n.Npc.LikesGifts), giftTastes, GiftTaste.Like));
                }
                break;

            case TargetType.Pet:
                Pet pet = (Pet)npc;
                yield return(new CharacterFriendshipField(this.Translate(L10n.Pet.Love), DataParser.GetFriendshipForPet(Game1.player, pet), this.Text));

                yield return(new GenericField(this.Translate(L10n.Pet.PettedToday), this.Stringify(this.Reflection.GetField <bool>(pet, "wasPetToday").GetValue())));

                break;

            case TargetType.Monster:
                // basic info
                Monster monster = (Monster)npc;
                yield return(new GenericField(this.Translate(L10n.Monster.Invincible), this.Translate(L10n.Generic.Seconds, new { count = this.Reflection.GetField <int>(monster, "invincibleCountdown").GetValue() }), hasValue: monster.isInvincible()));

                yield return(new PercentageBarField(this.Translate(L10n.Monster.Health), monster.health, monster.maxHealth, Color.Green, Color.Gray, this.Translate(L10n.Generic.PercentRatio, new { percent = Math.Round((monster.health / (monster.maxHealth * 1f) * 100)), value = monster.health, max = monster.maxHealth })));

                yield return(new ItemDropListField(this.Translate(L10n.Monster.Drops), this.GetMonsterDrops(monster), this.Text, defaultText: this.Translate(L10n.Monster.DropsNothing)));

                yield return(new GenericField(this.Translate(L10n.Monster.Experience), this.Stringify(monster.experienceGained)));

                yield return(new GenericField(this.Translate(L10n.Monster.Defence), this.Stringify(monster.resilience)));

                yield return(new GenericField(this.Translate(L10n.Monster.Attack), this.Stringify(monster.damageToFarmer)));

                // Adventure Guild quest
                AdventureGuildQuestData adventureGuildQuest = metadata.GetAdventurerGuildQuest(monster.name);
                if (adventureGuildQuest != null)
                {
                    int kills = adventureGuildQuest.Targets.Select(p => Game1.stats.getMonstersKilled(p)).Sum();
                    yield return(new GenericField(this.Translate(L10n.Monster.AdventureGuild), $"{this.Translate(kills >= adventureGuildQuest.RequiredKills ? L10n.Monster.AdventureGuildComplete : L10n.Monster.AdventureGuildIncomplete)} ({this.Translate(L10n.Monster.AdventureGuildProgress, new { count = kills, requiredCount = adventureGuildQuest.RequiredKills })})"));
                }
                break;
            }
        }
Example #5
0
        /// <summary>Get the data to display for this subject.</summary>
        /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
        public override IEnumerable <ICustomField> GetData(Metadata metadata)
        {
            NPC npc = this.Target;

            switch (this.TargetType)
            {
            case TargetType.Villager:
                if (!metadata.Constants.AsocialVillagers.Contains(npc.name))
                {
                    var giftTastes = this.GetGiftTastes(npc, metadata);

                    // birthday
                    GameDate birthday = new GameDate(npc.birthday_Season, npc.birthday_Day, Game1.year, metadata.Constants.DaysInSeason);
                    yield return(new GenericField(this.Text.Get(L10n.Npc.Birthday), this.Text.Stringify(birthday)));

                    // friendship
                    if (Game1.player.friendships.ContainsKey(npc.name))
                    {
                        FriendshipModel friendship = DataParser.GetFriendshipForVillager(Game1.player, npc, metadata);
                        yield return(new GenericField(this.Translate(L10n.Npc.CanRomance), friendship.IsSpouse ? this.Translate(L10n.Npc.CanRomanceMarried) : this.Stringify(npc.datable)));

                        yield return(new CharacterFriendshipField(this.Translate(L10n.Npc.Friendship), friendship, this.Text));

                        yield return(new GenericField(this.Translate(L10n.Npc.TalkedToday), this.Stringify(Game1.player.friendships[npc.name][2] == 1)));

                        yield return(new GenericField(this.Translate(L10n.Npc.GiftedToday), this.Stringify(Game1.player.friendships[npc.name][3] > 0)));

                        if (!friendship.IsSpouse)
                        {
                            yield return(new GenericField(this.Translate(L10n.Npc.GiftedThisWeek), this.Translate(L10n.Generic.Ratio, new { value = Game1.player.friendships[npc.name][1], max = NPC.maxGiftsPerWeek })));
                        }
                    }
                    else
                    {
                        yield return(new GenericField(this.Translate(L10n.Npc.Friendship), this.Translate(L10n.Npc.FriendshipNotMet)));
                    }
                    yield return(new CharacterGiftTastesField(this.Translate(L10n.Npc.LovesGifts), giftTastes, GiftTaste.Love));

                    yield return(new CharacterGiftTastesField(this.Translate(L10n.Npc.LikesGifts), giftTastes, GiftTaste.Like));
                }
                break;

            case TargetType.Pet:
                Pet pet = (Pet)npc;
                yield return(new CharacterFriendshipField(this.Translate(L10n.Pet.Love), DataParser.GetFriendshipForPet(Game1.player, pet), this.Text));

                yield return(new GenericField(this.Translate(L10n.Pet.PettedToday), this.Stringify(this.Reflection.GetPrivateValue <bool>(pet, "wasPetToday"))));

                break;

            case TargetType.Monster:
                // basic info
                Monster monster = (Monster)npc;
                yield return(new GenericField(this.Translate(L10n.Monster.Invincible), this.Translate(L10n.Generic.Seconds, new { count = this.Reflection.GetPrivateValue <int>(monster, "invincibleCountdown") }), hasValue: monster.isInvincible()));

                yield return(new PercentageBarField(this.Translate(L10n.Monster.Health), monster.health, monster.maxHealth, Color.Green, Color.Gray, this.Translate(L10n.Generic.PercentRatio, new { percent = Math.Round((monster.health / (monster.maxHealth * 1f) * 100)), value = monster.health, max = monster.maxHealth })));

                yield return(new ItemDropListField(this.Translate(L10n.Monster.Drops), this.GetMonsterDrops(monster), this.Text, defaultText: this.Translate(L10n.Monster.DropsNothing)));

                yield return(new GenericField(this.Translate(L10n.Monster.Experience), this.Stringify(monster.experienceGained)));

                yield return(new GenericField(this.Translate(L10n.Monster.Defence), this.Stringify(monster.resilience)));

                yield return(new GenericField(this.Translate(L10n.Monster.Attack), this.Stringify(monster.damageToFarmer)));

                // Adventure Guild quest
                AdventureGuildQuestData adventureGuildQuest = metadata.GetAdventurerGuildQuest(monster.name);
                if (adventureGuildQuest != null)
                {
                    int kills = adventureGuildQuest.Targets.Select(p => Game1.stats.getMonstersKilled(p)).Sum();
                    yield return(new GenericField(this.Translate(L10n.Monster.AdventureGuild), $"{this.Translate(kills >= adventureGuildQuest.RequiredKills ? L10n.Monster.AdventureGuildComplete : L10n.Monster.AdventureGuildIncomplete)} ({this.Translate(L10n.Monster.AdventureGuildProgress, new { count = kills, requiredCount = adventureGuildQuest.RequiredKills })})"));
                }
                break;
            }
        }