Exemple #1
0
        internal static SpaceShip BuyShip(SpaceShip[] shipShop, SpaceShip currentShip, UserProfile player, TradeGood[] cargoHold)
        {
            int numOptions = shipShop.Length;
            int shipChoice = 0;

            UserProfile.PrintUserInfo(player, currentShip);

            Console.WriteLine($"Please enter the number for the spaceship you want to buy or fly");
            Console.WriteLine($"===============================================================================================================");
            Console.WriteLine($"     Ship            || Cost of Ship  || Amount of Cargo space avalible   ||  Fuel Capacity     ||   Top Speed");
            Console.WriteLine($"===============================================================================================================");
            Console.WriteLine($"1. {shipShop[0].shipName}     || {shipShop[0].shipCost}CC           ||  {shipShop[0].cargoCapacity}     ||    {shipShop[0].totalFuelCapacity}    " +
                              $"  ||     {shipShop[0].topSpeed} ");
            Console.WriteLine($"2. {shipShop[1].shipName}     || {shipShop[1].shipCost}CC           ||  {shipShop[1].cargoCapacity}     ||    {shipShop[1].totalFuelCapacity}    " +
                              $"  ||     {shipShop[1].topSpeed} ");
            Console.WriteLine($"3. {shipShop[2].shipName}     || {shipShop[2].shipCost}CC           ||  {shipShop[2].cargoCapacity}     ||    {shipShop[2].totalFuelCapacity}    " +
                              $"  ||     {shipShop[0].topSpeed} ");

            shipChoice = Utility.ErrorHandler(numOptions) - 1;
            if (shipChoice < 0)
            {
                Console.WriteLine("Invalid Option.  \"Good bye\"");
                System.Threading.Thread.Sleep(1000);
                return(currentShip);
            }
            else if (shipShop[shipChoice].shipCost > player.cosmicCredits)
            {
                Console.WriteLine("Sorry bud, you dont have enough cosmic credits to buy a new ride. ");
                Console.WriteLine("Please try again");
                Console.Read();
                return(currentShip);
            }
            else
            {
                // subtract the current cargo space from the new ship
                shipShop[shipChoice].cargoCapacity -= TradeGood.TotalCargoSize(cargoHold);
                player.cosmicCredits         -= shipShop[shipChoice].shipCost;
                shipShop[shipChoice].shipCost = 0;
                currentShip.cargoCapacity    += TradeGood.TotalCargoSize(cargoHold);

                Console.WriteLine($"You have purchased the {shipShop[shipChoice].shipName}!");
                Console.ReadLine();
                Console.Clear();
                return(shipShop[shipChoice]);
            }
        }
Exemple #2
0
        internal static SpaceShip ShipGarage(SpaceShip[] shipShop, SpaceShip currentShip, UserProfile player, TradeGood[] cargoHold)
        {
            int option     = 0;
            int numOptions = 3;

            do
            {
                UserProfile.PrintUserInfo(player, currentShip);
                Console.WriteLine($"Welcome to Ship Shape's Ship Shop! What would you like to do? " +
                                  $"\n1. Buy a ship \n2. Refuel your ship \n3. Return to Planet Menu");

                option = Utility.ErrorHandler(numOptions);

                switch (option)
                {
                case 1:
                    currentShip = BuyShip(shipShop, currentShip, player, cargoHold);
                    break;

                case 2:
                    RefuelShip(currentShip, player);
                    break;

                default:
                    break;
                }
                Console.Clear();
            } while (option != 3);

            return(currentShip);
        }