예제 #1
0
        public static SpaceshipOrVehicle GetRandomVehicleOrStarship(PersonResult visitor)
        {
            int available = 0;

            if (visitor.Starships != null && visitor.Vehicles != null)
            {
                available = visitor.Starships.Count + visitor.Vehicles.Count;
            }
            if (available == 0)
            {
                return(GetRandomVehicleOrStarship());
            }
            else
            {
                List <string> VehicleAndStarship = new List <string>();
                VehicleAndStarship.AddRange(visitor.Starships);
                VehicleAndStarship.AddRange(visitor.Vehicles);

                return(SpacePark.APICall.GetSpaceShipInfo(VehicleAndStarship[SpacePark.RandomSeed.Next(0, VehicleAndStarship.Count)]).Result);
            }
        }
예제 #2
0
        public static PersonResult AddRandomGeneratedVisitor()
        {
            PersonResult result       = null;
            int          randomNumber = SpacePark.RandomSeed.Next(1, (int)(SpacePark.NumberOfValidNames * 1.15));

            if (randomNumber > SpacePark.NumberOfValidNames)
            {
                SpacePark.Print("Guard", $"You must leave! This is stictly a VIP SpacePort, {GetRandomName()}!", true);
            }
            else
            {
                result = SpacePark.APICall.GetPersonInfoByID(randomNumber).Result;
                //SpacePark.RandomSleepTimer += 5;
                if (result == null)
                {
                    SpacePark.Print("World", "It seems as if SWAPI is unable to respond at the moment.");
                    return(null);
                }
                SpacePark.Print("Guard", $"Welcome {result.Name} to my Spaceport");
            }
            return(result);
        }
예제 #3
0
 public static void GenerateRandomVisit()
 {
     if (RandomMethods.NewRandomVisit())
     {
         PersonResult visitor = RandomMethods.AddRandomGeneratedVisitor();
         if (visitor != null)
         {
             var starship = GetRandomVehicleOrStarship(visitor);
             if (SpacePark.IsCorrectLength(starship.doubleLength))
             {
                 SpacePark.ParkSpaceship(visitor.Name, starship.Name);
                 SpacePark.Print("Guard", "Your ship is parked.", true);
             }
             else
             {
                 SpacePark.Print("Guard", $"I'm sorry but your spaceship is too big!", true);
             }
         }
         else
         {
             SpacePark.Print("World", "The visitor left.", true);
         }
     }
 }