예제 #1
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);
        }
예제 #2
0
        private static double GetWarpSpeed(SpaceShip currentShip)
        {
            int warpSpeed;

            do
            {
                Console.WriteLine($"Please enter your warp speed (Your ship has a max warp speed of {currentShip.topSpeed}):");
                warpSpeed = Utility.ErrorHandler(currentShip.topSpeed);
            } while (warpSpeed > currentShip.topSpeed);
            return(warpSpeed);
        }
예제 #3
0
        static void BeginAdventure(UserProfile player, PlanetFactory[] smallGalaxy, SpaceShip[] spaceShip, TradeGood[] cargoTypes)
        {
            bool   quit = false;
            string option;

            PlanetFactory currentPlanet = smallGalaxy[0]; //The user starts at Plant '0' which is Earth

            SpaceShip currentShip = spaceShip[0];         //This is the beginning ship

            do                                            //The program will loop through this until they decide to quit or 14600 days (40 years) have passed
            {
                for (int i = 0; i < cargoTypes.Length; i++)
                {
                    cargoTypes[i].cost = TradeGood.MarketValue(cargoTypes[i].goodName);
                }

                do                                                  //The user will stay at this planet until they decide to travel to another planet
                {
                    UserProfile.PrintUserInfo(player, currentShip); //Keeps a header at the top of the game that displays the player's information as well as some information about the ship
                    Console.WriteLine($"Welcome to {currentPlanet.planetName}!  What would you like to do? \nVisit the Trader's Market    <Market>\nGo to Shipshape's Ship Shop  <Ship>\n" +
                                      $"Travel to the next planet    <Travel>\nQuit the Game <Quit>");

                    option = Console.ReadLine();  //String input for the option chosen by the player    //Error checked by the switch statement

                    switch (option)
                    {
                    case "Market":
                        Economy.MarketPlace(cargoTypes, player, currentShip);      //Goes to the Marketplace to buy and sell goods, as well as view their inventory
                        break;

                    case "Ship":
                        currentShip = SpaceShip.ShipGarage(spaceShip, currentShip, player, cargoTypes);      //Goes to the shipyard to buy a new ship
                        break;

                    case "Travel":
                        currentPlanet = Travel.GoSomewhere(player, currentShip, currentPlanet, smallGalaxy);      //Go somewhere else in this small part of the galaxy
                        break;

                    case "Quit":
                        quit = true;
                        break;

                    default:                                                                                    //Error handles any incorrect input
                        Console.WriteLine("Please enter a valid option.  The input is Case-sensative");
                        Console.WriteLine("Press <Enter> to try again.");
                        Console.ReadLine();
                        break;
                    }
                    Console.Clear();
                } while (option != "Travel" && !quit);
            } while(!quit && player.daysPlayed <= 14600);
        }
예제 #4
0
        internal static void RefuelShip(SpaceShip currentShip, UserProfile player)
        {
            int    fuelCost;
            int    totFuelCost;
            double option;
            double costToFill;
            double neededFuel;
            bool   enoughMoney = false;

            Random rand = new Random();

            fuelCost   = rand.Next(20);
            neededFuel = currentShip.totalFuelCapacity - currentShip.currentFuelCapacity;
            costToFill = fuelCost * neededFuel;

            Console.WriteLine($"Fuel Cost: {fuelCost}");
            Console.WriteLine($"Current Fuel Level: {currentShip.currentFuelCapacity}");
            Console.WriteLine($"Fuel Capacity: {currentShip.totalFuelCapacity}");
            Console.WriteLine($"Cost to fill: {costToFill}/n");

            Console.WriteLine($"How many units of fuel would you like to put into the {currentShip.shipName}?/n" +
                              $"You can fill up to {neededFuel}");

            do
            {
                int canPay = player.cosmicCredits / fuelCost;

                option     = Utility.DoubleErrorHandler(neededFuel);
                costToFill = option * fuelCost;
                if (costToFill > player.cosmicCredits)
                {
                    Console.WriteLine("You don't have enough CC to purchase that much fuel");
                    Console.WriteLine($"You only have enough CC to buy {canPay} units of fuel.");
                    enoughMoney = false;
                }
                else
                {
                    enoughMoney = true;
                }
            } while (!enoughMoney);

            totFuelCost = Convert.ToInt32(costToFill);

            Console.WriteLine($"You have purchased {option} units of fuel for {totFuelCost} CC.");
            Console.ReadLine();
            Console.Clear();

            player.cosmicCredits            -= totFuelCost;
            currentShip.currentFuelCapacity += option;
        }
예제 #5
0
        internal static void BuyGoods(UserProfile player, TradeGood[] tradeGoods, SpaceShip spaceShip)
        {
            int numOptions = 4;
            int goodChoice = 0;

            Console.WriteLine($"Please enter the number for the good you would like to purchase");
            Console.WriteLine($"=========================================================================");
            Console.WriteLine($"Item          Cost per Unit        Cargo space required per unit");
            Console.WriteLine($"1. {tradeGoods[0].goodName}              {tradeGoods[0].cost}CC                    {tradeGoods[0].size} ");
            Console.WriteLine($"2. {tradeGoods[1].goodName}           {tradeGoods[1].cost}CC                    {tradeGoods[1].size} ");
            Console.WriteLine($"3. {tradeGoods[2].goodName}             {tradeGoods[2].cost}CC                   {tradeGoods[2].size} ");
            Console.WriteLine($"4. {tradeGoods[3].goodName}         {tradeGoods[3].cost}CC                    {tradeGoods[3].size} ");

            goodChoice = (Utility.ErrorHandler(numOptions) - 1);

            TotalCost(player, tradeGoods[goodChoice], spaceShip);
        }
예제 #6
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]);
            }
        }
예제 #7
0
        internal static void TotalCost(UserProfile player, TradeGood tradeGoods, SpaceShip spaceShips)
        {
            int     totalCost    = 0;
            int     newCargo     = 0;
            int     quantity     = 0;
            Boolean insufficient = true;

            do
            {
                Console.Write($"How much of {tradeGoods.goodName} do you want to purchase?  ");

                quantity = Utility.ErrorHandler(1000000);

                totalCost = tradeGoods.cost * quantity;
                newCargo  = tradeGoods.size * quantity;

                if (totalCost > player.cosmicCredits)
                {
                    Console.WriteLine($"Insufficient funds.  You have {player.cosmicCredits}cc and {quantity} of {tradeGoods.goodName} costs {totalCost}");
                    Console.WriteLine("Please try again.");
                    insufficient = true;
                }
                else if (newCargo > spaceShips.cargoCapacity)
                {
                    Console.WriteLine($"Insufficient cargo space.  You need {newCargo} space and you only have {spaceShips.cargoCapacity}.");
                    Console.WriteLine("Please try again.");
                    insufficient = true;
                }
                else
                {
                    insufficient = false;
                }
            } while (insufficient == true);

            player.cosmicCredits -= totalCost;
            TradeGood.AddGoods(tradeGoods, quantity);

            spaceShips.cargoCapacity -= (quantity * tradeGoods.size);

            if (quantity > 0)
            {
                tradeGoods.prevBuy = (tradeGoods.prevBuy + totalCost) / (tradeGoods.quantity + quantity);
            }
        }
예제 #8
0
        static void BeginAdventure(UserProfile player, string currentPlanet)
        {
            int option      = 0;
            int menuOptions = 3;

            //Create the types of Tradable Goods as objects
            TradeGood[] cargoInventory = new TradeGood[4];

            TradeGood tOil      = new TradeGood("Oil", 5);
            TradeGood tSilver   = new TradeGood("Silver", 10);
            TradeGood tGold     = new TradeGood("Gold", 25);
            TradeGood tTitanium = new TradeGood("Titanium", 10);

            cargoInventory[0] = tOil;
            cargoInventory[1] = tSilver;
            cargoInventory[2] = tGold;
            cargoInventory[3] = tTitanium;

            int[] setGoodPrice = new int[cargoInventory.Length];

            //Create the planets as objects
            PlanetFactory earth        = new PlanetFactory("Earth", 0, 0);
            PlanetFactory alphaCentari = new PlanetFactory("Alpha Centari", 0, -4.367);
            PlanetFactory m63          = new PlanetFactory("M63", -5, 4);
            PlanetFactory magrathea    = new PlanetFactory("Magrathea", 50, 50);
            PlanetFactory vogosphere   = new PlanetFactory("Vogosphere", -15, 10);
            PlanetFactory arrakis      = new PlanetFactory("Arrakis", 7, 3);
            PlanetFactory corrin       = new PlanetFactory("Corrin", -3, -9);
            PlanetFactory helionPrime  = new PlanetFactory("Helion Prime", -5, -5);

            // Create space ships as objects
            SpaceShip[] shipShop = new SpaceShip[3];

            SpaceShip beginnerShip = new SpaceShip("Simple Simon", 000, 3000, 10, 4);
            SpaceShip MidLevelShip = new SpaceShip("Space Knight", 1500, 3500, 40, 7);
            SpaceShip ExpertShip   = new SpaceShip("Avenger jet", 2500, 2000, 100, 9);

            shipShop[0] = beginnerShip;
            shipShop[1] = MidLevelShip;
            shipShop[2] = ExpertShip;

            // Need a loop here so that the player can continue to play for '40' years

            setGoodPrice = PlanetFactory.MarketValue(setGoodPrice.Length);
            for (int i = 0; i < setGoodPrice.Length; i++)
            {
                cargoInventory[i].cost = setGoodPrice[i];
            }

            SpaceShip currentShip = beginnerShip;

            UserProfile.PrintUserInfo(player, currentShip);
            Console.WriteLine($"Welcome to {currentPlanet}!  What would you like to do? \n1.The Trader's Market \n2.Shipshape Ship Shop\n3.Travel to next planet");

            option = Utility.ErrorHandler(menuOptions);

            Console.Clear();

            switch (option)
            {
            case 1:
                Economy.MarketPlace(cargoInventory, player, currentShip);      //Pass current ShipObject, GoodObjects, and UserProfile object
                Console.Read();
                break;

            case 2:
                SpaceShip.ShipGarage(shipShop, player);
                currentShip = SpaceShip.ShipGarage(shipShop, player);
                Console.WriteLine($"You have purchased the {currentShip.shipName}");
                Console.ReadLine();
                break;

            case 3:
                Travel();
                break;

            default:
                break;
            }
        }
예제 #9
0
 internal static void PrintUserInfo(UserProfile player, SpaceShip currentShip)
 {
     Console.WriteLine($"Name: {player.userName}   Credits: {player.cosmicCredits}      Ship: {currentShip.shipName}      Fuel: {currentShip.fuelCapacity} \n");
 }
예제 #10
0
        internal static void MarketPlace(TradeGood[] cargoInventory, UserProfile player, SpaceShip currentShip)
        {
            int option = 0;

            int numOptions = 4;

            Console.Clear();

            do
            {
                UserProfile.PrintUserInfo(player, currentShip);
                Console.WriteLine($"What would you like to do? \n1. Buy \n2. Sell \n3. View Inventory \n4. Go to Planet Menu");

                option = Utility.ErrorHandler(numOptions);

                switch (option)
                {
                case 1:
                    BuyGoods(player, cargoInventory, currentShip);
                    //TotalCost(player, cargoInventory[goodChoice], currentShip);
                    //TradeGood.AddGoods(cargoInventory[goodChoice], addQuantity);
                    //Console.WriteLine($"There are now {cargoInventory[goodChoice].quantity} pieces of {cargoInventory[goodChoice].goodName} in your inventory.");
                    //Console.WriteLine("Press <ENTER> to continue...");
                    //Console.ReadLine();
                    break;

                case 2:
                    SellGoods(cargoInventory, player, currentShip);
                    break;

                case 3:
                    ViewInventory(cargoInventory);
                    Console.ReadLine();
                    break;

                default:
                    break;
                }
                Console.Clear();
            } while (option != 4);
        }
예제 #11
0
        internal static void SellGoods(TradeGood[] cargoInventory, UserProfile player, SpaceShip currentShip)
        {
            ViewInventory(cargoInventory);
            int numOptions   = cargoInventory.Length;
            int goodType     = 0;
            int sellQuantity = 0;
            int moneyMade    = 0;

            Console.WriteLine("What would you like to sell?");
            goodType = Utility.ErrorHandler(numOptions) - 1;

            if (goodType == -1)
            {
                Console.WriteLine("You are now returning to the Market Menu...");
                System.Threading.Thread.Sleep(1500);
            }
            else if (cargoInventory[goodType].quantity > 0)
            {
                Console.WriteLine($"How much of {cargoInventory[goodType].goodName} would you like to sell?" +
                                  $"  You have currently have {cargoInventory[goodType].quantity} pieces of this product available to sell.");

                sellQuantity = Utility.ErrorHandler(cargoInventory[goodType].quantity);

                moneyMade = cargoInventory[goodType].cost * sellQuantity;

                Console.WriteLine($"Congratulations! You made {moneyMade}cc off this transaction");
                Console.WriteLine("Press <ENTER> to continue...");
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("You don't have any of this product to sell.");
                Console.WriteLine("We are now returning you to the Market Menu");
                Console.WriteLine("3...");
                System.Threading.Thread.Sleep(1000);
                Console.WriteLine("2...");
                System.Threading.Thread.Sleep(1000);
                Console.WriteLine("1...");
                System.Threading.Thread.Sleep(1000);
                Console.WriteLine("Goodbye");
                System.Threading.Thread.Sleep(500);
            }

            int cargoSpace = sellQuantity * cargoInventory[goodType].size;

            cargoInventory[goodType].quantity -= sellQuantity;
            currentShip.cargoCapacity         += (sellQuantity * cargoInventory[goodType].size);
            player.cosmicCredits += moneyMade;
        }
예제 #12
0
        internal static PlanetFactory GoSomewhere(UserProfile player, SpaceShip currentShip, PlanetFactory currentPlanet, PlanetFactory[] smallGalaxy)
        {
            double[] distance = new double[smallGalaxy.Length];
            int      i        = 0;
            int      j        = 0;
            int      option   = 0;

            UserProfile.PrintUserInfo(player, currentShip);

            for (i = 0; i < smallGalaxy.Length; i++)
            {
                distance[i] = DistanceToPlanet(currentPlanet, smallGalaxy[i]);
            }

            Console.WriteLine("Please choose a destination");
            do
            {
                for (i = 0; i < smallGalaxy.Length; i++)
                {
                    if (distance[i] > 0 && distance[i] <= currentShip.currentFuelCapacity)
                    {
                        Console.WriteLine($"{i + 1}. Planet {smallGalaxy[i].planetName} is {distance[i].ToString("#.000")} light years away");
                        j++;
                    }
                }

                if (j == 0)
                {
                    option = 0;
                    Console.WriteLine($"There are no planets within range.  Go fuel up the {currentShip.shipName}.");
                    Console.ReadLine();
                    distance[option] = 0;
                }
                else
                {
                    Console.WriteLine("\n");
                    option = (Utility.ErrorHandler(i) - 1);

                    if (currentShip.currentFuelCapacity < distance[option])
                    {
                        Console.WriteLine("You do not have enough fuel to reach that planet, please try again.\n");
                    }
                }
            }while (currentShip.currentFuelCapacity < distance[option]);

            if (j == 0)
            {
                return(currentPlanet);
            }
            else
            {
                double warpSpeed = GetWarpSpeed(currentShip);

                int timePassed = TravelTime(warpSpeed, distance[option]);

                currentShip.currentFuelCapacity -= distance[option];
                player.daysPlayed += timePassed;

                currentPlanet = smallGalaxy[option];

                return(currentPlanet);
            }
        }
예제 #13
0
 internal static void PrintUserInfo(UserProfile player, SpaceShip currentShip)
 {
     Console.WriteLine($"Name: {player.userName}   Credits: {player.cosmicCredits}      Ship: {currentShip.shipName}      " +
                       $"Fuel: {currentShip.currentFuelCapacity.ToString("#.000")}   Cargo Space: {currentShip.cargoCapacity}   " +
                       $"Days Elapsed: {player.daysPlayed} \n");
 }