Ejemplo n.º 1
0
        //-----------------------------------------------------------------------------
        // Main
        //-----------------------------------------------------------------------------
        static void Main(string[] args)
        {
            RectangularPlatform southParkingDeck = new RectangularPlatform(PARKINGLOTCAPACITY);   // 26 is the equvilant of 2 default ships. use while debuging % for predictibility


            while (true)      //⚠ Gameloop	⚠
            {
                Console.Clear();
                intiiateDialouge(southParkingDeck).Wait();   // major parking company, thus we can manage different places / parking decks.
                Thread.Sleep(1500);
            }
        }
Ejemplo n.º 2
0
        const int Parkinglotcapacity = 100;  // Macro Substitude
                                             // 26 is the equvilant of 2 default ships (Char 0, Ship 0). used while debuging % for predictibility

        public static void InitiateDialogue(RectangularPlatform parkingDeck)
        {
            parkingDeck.ShowCapacity();

            Console.WriteLine("What's your name?");
            var customerName = Console.ReadLine();

            var customer = ApiUtils.LoadCharacter(customerName);

            var currentPilot = new StarWarsPerson
            {
                Name = customer.Name
            };

            if (DbUtils.IsDocked(currentPilot))
            {
                Logger.ShowSystemErrorText("You already have a ship here, do you want to check it out? Y/N");
                var answer = Console.ReadLine();
                if (answer.ToLower().Contains("y"))
                {
                    parkingDeck.CheckoutShip(currentPilot);
                    return;
                }
            }
            else if (customer.Exists)
            {
                var ship = PickVehicle(customer);
                customer.CurrentShipName = ship.name;
                currentPilot.ShipName    = ship.name;
                currentPilot.Length      = ship.length;

                if (parkingDeck.ShipWillFit(ship.length))
                {
                    if (customer.Wealth > parkingDeck.CalculateDockingFee(ship.length))
                    {
                        parkingDeck.DockShip(currentPilot);
                    }
                    else
                    {
                        Logger.ShowSystemErrorText("Sorry, you can't afford that");
                    }
                }
                else
                {
                    Logger.ShowSystemErrorText("Your ship wont fit");
                }
            }
            else
            {
                Logger.ShowSystemErrorText("You do not have access to this garage");
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            RectangularPlatform southParkingDeck = new RectangularPlatform(Parkinglotcapacity);


            while (true)      //⚠ Gameloop	⚠
            {
                Console.Clear();
                Gui.InitiateDialogueAsync(southParkingDeck).Wait();   // major parking company, thus we can manage different places / parking decks.

                Logger.systemLog("Press enter to continue", ConsoleColor.DarkGreen);
                Console.ReadLine();
            }
        }
Ejemplo n.º 4
0
        const int Parkinglotcapacity = 100;  // Macro Substitude
                                             // 26 is the equvilant of 2 default ships (Char 0, Ship 0). used while debuging % for predictibility

        public static async Task InitiateDialogueAsync(RectangularPlatform parkingDeck)
        {
            parkingDeck.ShowCapacity();

            Console.WriteLine("What's your name?");
            var customerName = Console.ReadLine();



            // Connect to DB here while api is loading :desktop:
            //  establishDataBaseConnection();



            Character customer = ApiUtils.LoadCharacter(customerName);


            //Task<Character> taskLoadChar = new Task<Character>(function: () => ApiUtils.LoadCharacter(customerName));

            //Task<List<Ship.Result>> taskLoadShips = new Task<List<Ship.Result>>(function: () => loadAllVehiclesAsync(customer));

            var taskLoadShips = Task.Factory.StartNew(() => loadAllVehiclesAsync(customer));

            //Task<int> taskLoadShips = new Task<int>(function: ()=>loadAllVehiclesAsync(customer));
            //taskLoadShips.Start();

            //System.Console.WriteLine("FROM UI");   // should be called last but appear first. ✔

            var currentPilot = new StarWarsPerson
            {
                Name = customer.Name
            };



            if (DbUtils.IsDocked(currentPilot))
            {
                Logger.systemLog("You already have a ship here, do you want to check it out or swap it for another one? ", ConsoleColor.DarkYellow);
                Logger.systemLog("S = swap, E = check out ", ConsoleColor.DarkYellow);
                string sAnswer = Console.ReadLine();
                //char cAnswer = Console.ReadLine();


                if (sAnswer[0] == 'e' || sAnswer[0] == 'E')
                {
                    parkingDeck.CheckoutShip(currentPilot);
                    return;
                }


                if (sAnswer[0] == 's' || sAnswer[0] == 'S')
                {
                    parkingDeck.CheckoutShip(currentPilot);
                }



                // switch (sAnswer[0])
                // {
                //     case 'e':
                //     case 'E':
                //         parkingDeck.CheckoutShip(currentPilot);
                //         break;
                //
                //     case 's':
                //     case 'S':
                //         parkingDeck.CheckoutShip(currentPilot);
                //         break;
                //
                //     default:
                //         break;
                // }
            }


            if (customer.Exists)
            {
                List <Ship.Result> vShip = await await taskLoadShips; //"await await" <-- intellisense  WTF

                Console.WriteLine();
                Logger.systemLog("Which ship?", ConsoleColor.DarkYellow);


                for (int i = 0; i != vShip.Count; i++)
                {
                    Console.WriteLine(i + " - " + vShip[i].name);
                }
                int iAnswer = Convert.ToInt32(Console.ReadLine());

                Ship.Result ship = new Ship.Result();
                ship = vShip[iAnswer];

                customer.CurrentShipName = ship.name;
                currentPilot.ShipName    = ship.name;
                currentPilot.Length      = ship.length;

                if (parkingDeck.ShipWillFit(ship.length))
                {
                    if (customer.Wealth > parkingDeck.CalculateDockingFee(ship.length))
                    {
                        parkingDeck.DockShip(currentPilot);
                    }

                    else
                    {
                        Logger.systemLog("Sorry, you can't afford that");
                    }
                }

                else
                {
                    Logger.systemLog("Your ship wont fit");
                }
            }
            else
            {
                Logger.systemLog("You do not have access to this garage");
            }
        }
Ejemplo n.º 5
0
        //public static int delayed()
        //{
        //    Thread.Sleep(500);
        //    systemLog("delay", ConsoleColor.Cyan);
        //    return 0;
        //}

        //-----------------------------------------------------------------------------
        // intiiateDialouge
        //-----------------------------------------------------------------------------
        public static async Task intiiateDialouge(RectangularPlatform parkingDeck)
        {
            parkingDeck.showCapacity();


            // Task<int> task = new Task<int>(delayed);
            // task.Start();
            // systemLog("FROM intiiateDialouge2", ConsoleColor.DarkYellow);   // TASK SPEED TEST, Remove!



            Character cCustomer = new Character();

            Console.WriteLine("What's your name?");
            string sCustomerName = Console.ReadLine();


            //Task.Run(async () => await LoadCharacterAsync(sCustomerName));

            Task <Character> taskLoadChar = new Task <Character>(function: () => loadCharacters(sCustomerName));

            taskLoadChar.Start();


            // Connect to DB here while api is loading 🖥
            //  establishDataBaseConnection();

            cCustomer = await taskLoadChar;

            #region UNCOMMENT : Customer has parked a vehicle here but never check it out, thus its still here. Checkout now? : REQUIERES ENTITYFRAMEWORK INTERGRATION
            // select * from SpacePark where Name = [cCustomer.sName] && checkOut == NULL <<<<<<<<<<<<<<<<<<<<<<<<<<<<<    // REQUIERES ENTITYFRAMEWORK INTERGRATION
            // if (sqlResults != null)
            // {
            //     systemLog("you already have (a) ship(s) here, do you want to check one of them out? Y/N");
            //     char cAnswer = Console.ReadKey();
            //     switch (cAnswer)
            //     {
            //         case 'y':
            //         case 'Y':
            //             checkOutShip();
            //             return;
            //
            //         default:
            //             break;
            //     }
            // }
            // Customer has parked a vehicle here but never check it out, thus its still here. Checkout now?
            #endregion

            if (cCustomer.bValid)
            {
                Ship.Result ship = pickVehicle(cCustomer);

                #region OLD CRAP
                // Pick a random person that wants to park
                //Random random = new Random();
                //int iPersonAproaching = /*random.Next(0, vCharacters.Count);*/ 0;       // ⚠ HardCoded while debuging, re-enable random later


                //  GITHUB: "...be able to pay before they can leave the parking lot and get an invoice in the end." , No entry fee? Current wallet irrelevant?
                //if (!  (parkingDeck.calculatePrice( Ship.getShipDetails(vCharacters[iPersonAproaching].vShips[iPersonAproaching]).length) > vCharacters[iPersonAproaching].iCoins)  )
                #endregion

                //if (isAuthorized(cCustomer))
                if (cCustomer.bValid)
                {                                                                    // replace 0 with iPersonAproaching
                    if (parkingDeck.shipWillFit(ship.length))
                    {
                        if (cCustomer.dWealth > parkingDeck.calculatePrice(Ship.getShipDetails(cCustomer.vShips[cCustomer.iDrivingShipNumber]).length))
                        {
                            parkingDeck.dockShip(Ship.getShipDetails(cCustomer.vShips[cCustomer.iDrivingShipNumber]).length, cCustomer);
                        }

                        else
                        {
                            systemLog("Sorry, you can't afford that");
                        }
                    }
                    else
                    {
                        systemLog("Your ship wont fit");
                    }
                }
            }

            else
            {
                systemLog("You do not have acces to this garage");
            }



            #region NOW TEMPORARYLY CACHES (using) SHIP FROM 'pickVehicle' WHILE DIALOUGE IS GOING ON

            //while (true)
            //{
            //    if(isAuthorized(vCharacters, sCustomerName))
            //    {                                                                    // replace 0 with iPersonAproaching
            //        if (parkingDeck.shipWillFit(      Ship.getShipDetails( vCharacters[0].vShips[  vCharacters[0].iDrivingShipNumber   ]    ).length    )    )
            //        {
            //            if (vCharacters[0].dWealth > parkingDeck.calculatePrice(Ship.getShipDetails(vCharacters[0].vShips[vCharacters[0].iDrivingShipNumber]).length))
            //            {
            //                parkingDeck.dockShip(Ship.getShipDetails(vCharacters[0].vShips[vCharacters[0].iDrivingShipNumber]).length,  vCharacters[0] );
            //            }
            //            else
            //            {
            //               systemLog("Sorry, you can't afford that");
            //            }
            //        }
            //        else
            //        {
            //           systemLog("Parkinglot is full, please come back later");
            //        }
            //    }
            //    else
            //    {
            //       systemLog("You do not have acces to this garage");
            //    }
            //
            //}

            #endregion
        }