Exemplo n.º 1
0
        /*********
        ** Private methods
        *********/
        /*****
        ** Data fields
        ****/
        /// <summary>Get the fields to display for a child.</summary>
        /// <param name="child">The child for which to show info.</param>
        /// <remarks>Derived from <see cref="Child.dayUpdate"/>.</remarks>
        private IEnumerable <ICustomField> GetDataForChild(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]);
                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)));
            }
        }
        public static PreBookRequest prepareAvailabilityObj(List <SearchRoomResult> rooms, string hotelcode, string arrivalData, string Dur)
        {
            PreBookRequest preBook = new PreBookRequest();

            preBook.BookingDetails.ArrivalDate = arrivalData;
            preBook.BookingDetails.Duration    = Dur;
            preBook.BookingDetails.PropertyID  = hotelcode;
            foreach (var item in rooms)
            {
                RoomBooking room = new RoomBooking();
                room.Adults   = item.Adults.ToString();
                room.Children = item.Childern.ToString();
                if (item.RoomReference != "0")
                {
                    room.PropertyRoomTypeID = item.RoomReference;
                }
                else
                {
                    room.BookingToken = item.ProviderBookingKey;
                }
                room.MealBasisID = item.MealId;
                room.Infants     = "0";
                for (int i = 0; i < item.Childern; i++)
                {
                    ChildAge childAge = new ChildAge();
                    childAge.Age = "5";
                    room.ChildAges.ChildAge.Add(childAge);
                }
                preBook.BookingDetails.RoomBookings.RoomBooking.Add(room);
            }

            return(preBook);
        }
Exemplo n.º 3
0
        /// <summary>Get the number of days until a child grows to the next stage.</summary>
        /// <param name="stage">The child's current growth stage.</param>
        /// <param name="daysOld">The child's current age in days.</param>
        /// <returns>Returns a number of days, or <c>-1</c> if the child won't grow any further.</returns>
        /// <remarks>Derived from <see cref="Child.dayUpdate"/>.</remarks>
        private int GetDaysToNextChildGrowth(ChildAge stage, int daysOld)
        {
            switch (stage)
            {
            case ChildAge.Newborn:
                return(13 - daysOld);

            case ChildAge.Baby:
                return(27 - daysOld);

            case ChildAge.Crawler:
                return(55 - daysOld);

            default:
                return(-1);
            }
        }
Exemplo n.º 4
0
        public IEnumerable <IGrouping <string, Nanny> > GroupNannyByChildAge(bool sort = false)//grouping the nannies by child age
        {
            Idal mydal = FactoryDal.getDal();
            IEnumerable <IGrouping <string, Nanny> > ChildAge;

            if (sort)
            {
                ChildAge = from n in mydal.GetNannysList()
                           orderby n.range //field in nanny that contain the range of the children's ages
                           group n by n.range;
            }
            else
            {
                ChildAge = from n in mydal.GetNannysList()
                           group n by n.range;
            }

            return(ChildAge.ToList());
        }
Exemplo n.º 5
0
        public IEnumerable <IGrouping <float, Nanny> > GroupNannyByChildAgeMaxOrMin(bool max, bool sort = false)//grouping the nannies by maximum child age or minimum
        {
            Idal mydal = FactoryDal.getDal();
            IEnumerable <IGrouping <float, Nanny> > ChildAge;

            if (max)
            {
                if (sort)
                {
                    ChildAge = from n in mydal.GetNannysList()
                               orderby n.MaxChildrensAge
                               group n by n.MaxChildrensAge;
                }
                else
                {
                    ChildAge = from n in mydal.GetNannysList()
                               group n by n.MaxChildrensAge;
                }
            }

            else
            {
                if (sort)
                {
                    ChildAge = from n in mydal.GetNannysList()
                               orderby n.MinChildrensAge
                               group n by n.MinChildrensAge;
                }
                else
                {
                    ChildAge = from n in mydal.GetNannysList()
                               group n by n.MinChildrensAge;
                }
            }

            return(ChildAge.ToList());
        }
Exemplo n.º 6
0
 /// <summary>Get a translation for an enum value.</summary>
 /// <param name="age">The child age.</param>
 public static Translation For(ChildAge age)
 {
     return(L10n.Helper.Get($"npc.child.age.{age.ToString().ToLower()}"));
 }
Exemplo n.º 7
0
 /// <summary>A value like <c>{{label}}</c>.</summary>
 public static Translation AgeDescriptionGrown(ChildAge label) => L10n.Helper.Get("npc.child.age.description-grown", new { label = L10n.For(label) });
Exemplo n.º 8
0
 /****
 ** Values
 ****/
 /// <summary>A value like <c>{{label}} ({{count}} days to {{nextLabel}})</c>.</summary>
 public static Translation AgeDescriptionPartial(ChildAge label, int count, ChildAge nextLabel) => L10n.Helper.Get("npc.child.age.description-partial", new { label = L10n.For(label), count, nextLabel = L10n.For(nextLabel) });
Exemplo n.º 9
0
 /// <summary>Get a translation key for an enum value.</summary>
 /// <param name="age">The child age.</param>
 public static string For(ChildAge age)
 {
     return($"npc.child.age.{age.ToString().ToLower()}");
 }
Exemplo n.º 10
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;
            }
        }
Exemplo n.º 11
0
 /// <summary>Get a translation for an enum value.</summary>
 /// <param name="age">The child age.</param>
 public static string For(ChildAge age)
 {
     return(I18n.GetByKey($"npc.child.age.{age.ToString().ToLower()}"));
 }
Exemplo n.º 12
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;
            }
        }