Ejemplo n.º 1
0
        /// <summary>Get the custom fields for a crop.</summary>
        /// <param name="dirt">The dirt the crop is planted in, if applicable.</param>
        /// <param name="crop">The crop to represent.</param>
        /// <param name="isSeed">Whether the crop being displayed is for an unplanted seed.</param>
        private IEnumerable <ICustomField> GetCropFields(HoeDirt?dirt, Crop?crop, bool isSeed)
        {
            if (crop == null)
            {
                yield break;
            }

            var  data     = new CropDataParser(crop, isPlanted: !isSeed);
            bool isForage = crop.whichForageCrop.Value > 0 && crop.fullyGrown.Value; // show crop fields for growing mixed seeds

            // add next-harvest field
            if (!isSeed)
            {
                // get next harvest
                SDate nextHarvest = data.GetNextHarvest();

                // generate field
                string summary;
                if (data.CanHarvestNow)
                {
                    summary = I18n.Generic_Now();
                }
                else if (!Game1.currentLocation.SeedsIgnoreSeasonsHere() && !data.Seasons.Contains(nextHarvest.Season))
                {
                    summary = I18n.Crop_Harvest_TooLate(date: this.Stringify(nextHarvest));
                }
                else
                {
                    summary = $"{this.Stringify(nextHarvest)} ({this.GetRelativeDateStr(nextHarvest)})";
                }

                yield return(new GenericField(I18n.Crop_Harvest(), summary));
            }

            // crop summary
            if (!isForage)
            {
                List <string> summary = new();

                // harvest
                if (!crop.forageCrop.Value)
                {
                    summary.Add(data.HasMultipleHarvests
                        ? I18n.Crop_Summary_HarvestOnce(daysToFirstHarvest: data.DaysToFirstHarvest)
                        : I18n.Crop_Summary_HarvestMulti(daysToFirstHarvest: data.DaysToFirstHarvest, daysToNextHarvests: data.DaysToSubsequentHarvest)
                                );
                }

                // seasons
                summary.Add(I18n.Crop_Summary_Seasons(seasons: string.Join(", ", I18n.GetSeasonNames(data.Seasons))));

                // drops
                if (crop.minHarvest != crop.maxHarvest && crop.chanceForExtraCrops.Value > 0)
                {
                    summary.Add(I18n.Crop_Summary_DropsXToY(min: crop.minHarvest.Value, max: crop.maxHarvest.Value, percent: (int)Math.Round(crop.chanceForExtraCrops.Value * 100, 2)));
                }
                else if (crop.minHarvest.Value > 1)
                {
                    summary.Add(I18n.Crop_Summary_DropsX(count: crop.minHarvest.Value));
                }

                // crop sale price
                Item drop = data.GetSampleDrop();
                summary.Add(I18n.Crop_Summary_SellsFor(price: GenericField.GetSaleValueString(this.GetSaleValue(drop, false), 1) !));

                // generate field
                yield return(new GenericField(I18n.Crop_Summary(), "-" + string.Join($"{Environment.NewLine}-", summary)));
            }

            // dirt water/fertilizer state
            if (dirt != null && !isForage)
            {
                // watered
                yield return(new GenericField(I18n.Crop_Watered(), this.Stringify(dirt.state.Value == HoeDirt.watered)));

                // fertilizer
                string[] appliedFertilizers = this.GetAppliedFertilizers(dirt)
                                              .Select(GameI18n.GetObjectName)
                                              .Distinct()
                                              .DefaultIfEmpty(this.Stringify(false))
                                              .OrderBy(p => p)
                                              .ToArray();

                yield return(new GenericField(I18n.Crop_Fertilized(), string.Join(", ", appliedFertilizers)));
            }
        }
Ejemplo n.º 2
0
        /// <summary>Get the custom fields for a crop.</summary>
        /// <param name="dirt">The dirt the crop is planted in, if applicable.</param>
        /// <param name="crop">The crop to represent.</param>
        /// <param name="isSeed">Whether the crop being displayed is for an unplanted seed.</param>
        private IEnumerable <ICustomField> GetCropFields(HoeDirt dirt, Crop crop, bool isSeed)
        {
            if (crop == null)
            {
                yield break;
            }

            var  data     = new CropDataParser(crop, isPlanted: !isSeed);
            bool isForage = crop.whichForageCrop.Value > 0 && crop.fullyGrown.Value; // show crop fields for growing mixed seeds

            // add next-harvest field
            if (!isSeed)
            {
                // get next harvest
                SDate nextHarvest = data.GetNextHarvest();

                // generate field
                string summary;
                if (data.CanHarvestNow)
                {
                    summary = I18n.Generic_Now();
                }
                else if (!Game1.currentLocation.SeedsIgnoreSeasonsHere() && !data.Seasons.Contains(nextHarvest.Season))
                {
                    summary = I18n.Crop_Harvest_TooLate(date: this.Stringify(nextHarvest));
                }
                else
                {
                    summary = $"{this.Stringify(nextHarvest)} ({this.GetRelativeDateStr(nextHarvest)})";
                }

                yield return(new GenericField(I18n.Crop_Harvest(), summary));
            }

            // crop summary
            if (!isForage)
            {
                List <string> summary = new List <string>();

                // harvest
                if (!crop.forageCrop.Value)
                {
                    summary.Add(data.HasMultipleHarvests
                        ? I18n.Crop_Summary_HarvestOnce(daysToFirstHarvest: data.DaysToFirstHarvest)
                        : I18n.Crop_Summary_HarvestMulti(daysToFirstHarvest: data.DaysToFirstHarvest, daysToNextHarvests: data.DaysToSubsequentHarvest)
                                );
                }

                // seasons
                summary.Add(I18n.Crop_Summary_Seasons(seasons: string.Join(", ", I18n.GetSeasonNames(data.Seasons))));

                // drops
                if (crop.minHarvest != crop.maxHarvest && crop.chanceForExtraCrops.Value > 0)
                {
                    summary.Add(I18n.Crop_Summary_DropsXToY(min: crop.minHarvest.Value, max: crop.maxHarvest.Value, percent: (int)Math.Round(crop.chanceForExtraCrops.Value * 100, 2)));
                }
                else if (crop.minHarvest.Value > 1)
                {
                    summary.Add(I18n.Crop_Summary_DropsX(count: crop.minHarvest.Value));
                }

                // crop sale price
                Item drop = data.GetSampleDrop();
                summary.Add(I18n.Crop_Summary_SellsFor(price: GenericField.GetSaleValueString(this.GetSaleValue(drop, false), 1)));

                // generate field
                yield return(new GenericField(I18n.Crop_Summary(), "-" + string.Join($"{Environment.NewLine}-", summary)));
            }

            // dirt water/fertilizer state
            if (dirt != null && !isForage)
            {
                // watered
                yield return(new GenericField(I18n.Crop_Watered(), this.Stringify(dirt.state.Value == HoeDirt.watered)));

                // fertilizer
                yield return(new GenericField(I18n.Crop_Fertilized(), dirt.fertilizer.Value switch
                {
                    HoeDirt.noFertilizer => this.Stringify(false),

                    HoeDirt.speedGro => GameI18n.GetObjectName(465),                  // Speed-Gro
                    HoeDirt.superSpeedGro => GameI18n.GetObjectName(466),             // Deluxe Speed-Gro
                    HoeDirt.hyperSpeedGro => GameI18n.GetObjectName(918),             // Hyper Speed-Gro

                    HoeDirt.fertilizerLowQuality => GameI18n.GetObjectName(368),      // Basic Fertilizer
                    HoeDirt.fertilizerHighQuality => GameI18n.GetObjectName(369),     // Quality Fertilizer
                    HoeDirt.fertilizerDeluxeQuality => GameI18n.GetObjectName(919),   // Deluxe Fertilizer

                    HoeDirt.waterRetentionSoil => GameI18n.GetObjectName(370),        // Basic Retaining Soil
                    HoeDirt.waterRetentionSoilQuality => GameI18n.GetObjectName(371), // Quality Retaining Soil
                    HoeDirt.waterRetentionSoilDeluxe => GameI18n.GetObjectName(920),  // Deluxe Retaining Soil

                    _ => I18n.Generic_Unknown()
                }));
Ejemplo n.º 3
0
        /// <summary>Get the custom fields for a crop.</summary>
        /// <param name="crop">The crop to represent.</param>
        /// <param name="isSeed">Whether the crop being displayed is for an unplanted seed.</param>
        /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
        private IEnumerable <ICustomField> GetCropFields(Crop crop, bool isSeed, Metadata metadata)
        {
            if (crop == null)
            {
                yield break;
            }

            var data = new CropDataParser(crop);

            // add next-harvest field
            if (!isSeed)
            {
                // get next harvest
                SDate nextHarvest       = data.GetNextHarvest();
                int   daysToNextHarvest = nextHarvest.DaysSinceStart - SDate.Now().DaysSinceStart;

                // generate field
                string summary;
                if (data.CanHarvestNow)
                {
                    summary = this.Translate(L10n.Crop.HarvestNow);
                }
                else if (!Game1.currentLocation.IsGreenhouse && !data.Seasons.Contains(nextHarvest.Season))
                {
                    summary = this.Translate(L10n.Crop.HarvestTooLate, new { date = this.Stringify(nextHarvest) });
                }
                else
                {
                    summary = $"{this.Stringify(nextHarvest)} ({this.Text.GetPlural(daysToNextHarvest, L10n.Generic.Tomorrow, L10n.Generic.InXDays).Tokens(new { count = daysToNextHarvest })})";
                }

                yield return(new GenericField(this.GameHelper, this.Translate(L10n.Crop.Harvest), summary));
            }

            // crop summary
            {
                List <string> summary = new List <string>();

                // harvest
                summary.Add(data.HasMultipleHarvests
                    ? this.Translate(L10n.Crop.SummaryHarvestOnce, new { daysToFirstHarvest = data.DaysToFirstHarvest })
                    : this.Translate(L10n.Crop.SummaryHarvestMulti, new { daysToFirstHarvest = data.DaysToFirstHarvest, daysToNextHarvests = data.DaysToSubsequentHarvest })
                            );

                // seasons
                summary.Add(this.Translate(L10n.Crop.SummarySeasons, new { seasons = string.Join(", ", this.Text.GetSeasonNames(data.Seasons)) }));

                // drops
                if (crop.minHarvest != crop.maxHarvest && crop.chanceForExtraCrops.Value > 0)
                {
                    summary.Add(this.Translate(L10n.Crop.SummaryDropsXToY, new { min = crop.minHarvest, max = crop.maxHarvest, percent = Math.Round(crop.chanceForExtraCrops.Value * 100, 2) }));
                }
                else if (crop.minHarvest.Value > 1)
                {
                    summary.Add(this.Translate(L10n.Crop.SummaryDropsX, new { count = crop.minHarvest }));
                }

                // crop sale price
                Item drop = data.GetSampleDrop();
                summary.Add(this.Translate(L10n.Crop.SummarySellsFor, new { price = GenericField.GetSaleValueString(this.GetSaleValue(drop, false, metadata), 1, this.Text) }));

                // generate field
                yield return(new GenericField(this.GameHelper, this.Translate(L10n.Crop.Summary), "-" + string.Join($"{Environment.NewLine}-", summary)));
            }
        }
Ejemplo n.º 4
0
        /// <summary>Get the custom fields for a crop.</summary>
        /// <param name="crop">The crop to represent.</param>
        /// <param name="isSeed">Whether the crop being displayed is for an unplanted seed.</param>
        private IEnumerable <ICustomField> GetCropFields(Crop crop, bool isSeed)
        {
            if (crop == null)
            {
                yield break;
            }

            var data = new CropDataParser(crop, isPlanted: !isSeed);

            // add next-harvest field
            if (!isSeed)
            {
                // get next harvest
                SDate nextHarvest = data.GetNextHarvest();

                // generate field
                string summary;
                if (data.CanHarvestNow)
                {
                    summary = I18n.Generic_Now();
                }
                else if (!Game1.currentLocation.IsGreenhouse && !data.Seasons.Contains(nextHarvest.Season))
                {
                    summary = I18n.Crop_Harvest_TooLate(date: this.Stringify(nextHarvest));
                }
                else
                {
                    summary = $"{this.Stringify(nextHarvest)} ({this.GetRelativeDateStr(nextHarvest)})";
                }

                yield return(new GenericField(I18n.Crop_Harvest(), summary));
            }

            // crop summary
            if (crop.whichForageCrop.Value <= 0)
            {
                List <string> summary = new List <string>();

                // harvest
                if (!crop.forageCrop.Value)
                {
                    summary.Add(data.HasMultipleHarvests
                        ? I18n.Crop_Summary_HarvestOnce(daysToFirstHarvest: data.DaysToFirstHarvest)
                        : I18n.Crop_Summary_HarvestMulti(daysToFirstHarvest: data.DaysToFirstHarvest, daysToNextHarvests: data.DaysToSubsequentHarvest)
                                );
                }

                // seasons
                summary.Add(I18n.Crop_Summary_Seasons(seasons: string.Join(", ", I18n.GetSeasonNames(data.Seasons))));

                // drops
                if (crop.minHarvest != crop.maxHarvest && crop.chanceForExtraCrops.Value > 0)
                {
                    summary.Add(I18n.Crop_Summary_DropsXToY(min: crop.minHarvest.Value, max: crop.maxHarvest.Value, percent: (int)Math.Round(crop.chanceForExtraCrops.Value * 100, 2)));
                }
                else if (crop.minHarvest.Value > 1)
                {
                    summary.Add(I18n.Crop_Summary_DropsX(count: crop.minHarvest.Value));
                }

                // crop sale price
                Item drop = data.GetSampleDrop();
                summary.Add(I18n.Crop_Summary_SellsFor(price: GenericField.GetSaleValueString(this.GetSaleValue(drop, false), 1)));

                // generate field
                yield return(new GenericField(I18n.Crop_Summary(), "-" + string.Join($"{Environment.NewLine}-", summary)));
            }
        }