Esempio n. 1
0
        /// <summary>
        /// Calculates the total amount of stops that this Starship will require for resupply, depending of the distance settet up.
        /// </summary>
        /// <param name="distance">Specified distance to calculate. 1000000 by default.</param>
        public void CalculateNoStops(int distance = 1000000)
        {
            int hoursPerTravel = 0;

            if (Consumables.Contains("hour"))
            {
                hoursPerTravel = Convert.ToInt32(Consumables.Replace("hours", "").Replace("hour", "").Replace(" ", ""));
                hoursPerTravel = hoursPerTravel * Convert.ToInt32(this.MGLT);
                this.NoStops   = distance / hoursPerTravel;
            }
            else if (Consumables.Contains("day"))
            {
                hoursPerTravel = Convert.ToInt32(Consumables.Replace("days", "").Replace("day", "").Replace(" ", ""));
                hoursPerTravel = (hoursPerTravel * 24) * Convert.ToInt32(this.MGLT);
                this.NoStops   = distance / hoursPerTravel;
            }
            else if (Consumables.Contains("week"))
            {
                hoursPerTravel = Convert.ToInt32(Consumables.Replace("weeks", "").Replace("week", "").Replace(" ", ""));
                hoursPerTravel = (hoursPerTravel * 7 * 24) * Convert.ToInt32(this.MGLT);
                this.NoStops   = distance / hoursPerTravel;
            }
            else if (Consumables.Contains("month"))
            {
                hoursPerTravel = Convert.ToInt32(Consumables.Replace("months", "").Replace("month", "").Replace(" ", ""));
                hoursPerTravel = (hoursPerTravel * 4 * 7 * 24) * Convert.ToInt32(this.MGLT);
                this.NoStops   = distance / hoursPerTravel;
            }
            else if (Consumables.Contains("year"))
            {
                int leapYears = 0;

                hoursPerTravel = Convert.ToInt32(Consumables.Replace("years", "").Replace("year", "").Replace(" ", ""));
                // For every leap year, we add 24h to final time. Anyway, I think in the interstellar travels they should not have 29th February!
                leapYears      = (hoursPerTravel / 4) * 24;
                hoursPerTravel = (hoursPerTravel * 12 * 4 * 7 * 24 + leapYears) * Convert.ToInt32(this.MGLT);
                this.NoStops   = distance / hoursPerTravel;
            }
        }