public override void Show() { base.Show(); //Show the logged in player details ObjectView showPlayer = new ObjectView("", UIMain.CurrentPlayer); showPlayer.Show(); Console.WriteLine(""); Console.WriteLine("Press A to see your animals"); Console.WriteLine(""); Console.WriteLine("Press C to change your details"); Console.WriteLine(""); Console.WriteLine("Press any key to go back to menu"); char c = Console.ReadKey().KeyChar; try { while (c == 'a' || c == 'A' || c == 'c' || c == 'C') { if (c == 'a' || c == 'A') { Console.WriteLine(); //Show all player's pets details(alive and dead)1 Task <List <PetDTO> > tt = UIMain.api.AnimalList(); tt.Wait(); List <PetDTO> lst = tt.Result; List <Object> animals = (from animalList in lst select new { ID = animalList.PetId, Name = animalList.PetName, BirthDate = animalList.BirthDate, Status = animalList.GetStatus() }).ToList <Object>(); ObjectsList list = new ObjectsList("Animals", animals); list.Show(); Console.WriteLine(); } //Showing screen according to the pressed key if (c == 'c' || c == 'C') { ChangeDetails change = new ChangeDetails(); change.Show(); } c = Console.ReadKey().KeyChar; } Console.WriteLine(""); //Returning to menu MainMenu m = new MainMenu(); m.Show(); Console.ReadKey(); } catch (Exception e) { Console.WriteLine($"Something went wrong: {e.Message}!"); } }
public override void Show() { base.Show(); try { //Print pet's levels Console.WriteLine($"Pet's hunger level:{UIMain.CurrentPet.GetHungerLevel()}"); Console.WriteLine("\n"); Task <List <FoodDTO> > t = UIMain.api.PrintFood(); t.Wait(); List <FoodDTO> p = t.Result; //Print a table that contains the details we need to feed the pet List <object> food = (from foodList in p select new { ID = foodList.FoodId, Name = foodList.ActivityName, SatiatyLevel = foodList.SatiatyLevel, Calories = foodList.Calories, cleanAdd = foodList.CleanAdd, joyAdd = foodList.JoyAdd }).ToList <Object>(); ObjectsList list = new ObjectsList("Feeding Options", food); list.Show(); Console.WriteLine(" "); //Input food id from the user Console.WriteLine("\nWould you like to feed your pet? (please enter yes/no)"); string answer = Console.ReadLine(); while (answer == "yes") { Console.WriteLine("\nHow would you like to feed your pet? (please enter food ID)"); int foodNumber = int.Parse(Console.ReadLine()); while (foodNumber < FIRSTFOOD || foodNumber > LASTFOOD) { Console.WriteLine("You entered an illogical number. \nPlease enter one of the numbers that are on the screen"); foodNumber = int.Parse(Console.ReadLine()); } Task <string> a = UIMain.api.Feed(foodNumber); a.Wait(); Console.WriteLine($"{a.Result}\n"); Task <PlayerDTO> player = UIMain.api.GetPlayer(); player.Wait(); UIMain.CurrentPlayer = player.Result; IEnumerable <PetDTO> petList = from pet in UIMain.CurrentPlayer.Pets where (pet.StatusId != DEAD) select pet; UIMain.CurrentPet = petList.FirstOrDefault(); Console.WriteLine("\nWould you like to feed your pet again? (please enter yes/no)"); answer = Console.ReadLine(); } //Return to previous screen MainMenu m = new MainMenu(); m.Show(); } catch (Exception e) { Console.WriteLine($"Fail with error: {e.Message}!"); } }
public override void Show() { base.Show(); try { //Print pet's levels Console.WriteLine($"Pet's clean level:{UIMain.CurrentPet.GetCleanLevel()}"); Console.WriteLine($"Pet's joy level:{UIMain.CurrentPet.GetJoyLevel()}"); Console.WriteLine("\n"); Task <List <ActivityDTO> > t = UIMain.api.CleanlList(); t.Wait(); List <ActivityDTO> list = t.Result; //Print a table that contains the details we need to clean the pet List <Object> clean = (from cleanList in list where (cleanList.ActivityId >= 6 && cleanList.ActivityId <= 11) select new { ID = cleanList.ActivityId, Name = cleanList.ActivityName, CleanAdd = cleanList.CleanAdd, JoyAdd = cleanList.JoyAdd }).ToList <Object>(); ObjectsList Cleanlist = new ObjectsList("Cleaning Options", clean); Cleanlist.Show(); Console.WriteLine(" "); //Input activity id from the user Console.WriteLine("\nWould you like to clean your pet? (please enter yes/no)"); string answer = Console.ReadLine(); while (answer == "yes") { Console.WriteLine("\nHow would you like to clean your pet? (please enter clean ID)"); int cleanNumber = int.Parse(Console.ReadLine()); //Check input while (cleanNumber < FIRSTCLEAN || cleanNumber > LASTCLEAN) { Console.WriteLine("You entered an illogical number. \nPlease enter one of the numbers that are on the screen"); cleanNumber = int.Parse(Console.ReadLine()); } //Clean the pet and add to pet's level Task <string> a = UIMain.api.UpdateClean(cleanNumber); a.Wait(); Console.WriteLine($"{a.Result}\n"); Task <PlayerDTO> player = UIMain.api.GetPlayer(); player.Wait(); UIMain.CurrentPlayer = player.Result; IEnumerable <PetDTO> petList = from p in UIMain.CurrentPlayer.Pets where (p.StatusId != DEAD) select p; UIMain.CurrentPet = petList.FirstOrDefault(); Console.WriteLine("\nWould you like to clean your pet again? (please enter yes/no)"); answer = Console.ReadLine(); } //Return to previous screen MainMenu m = new MainMenu(); m.Show(); } catch (Exception e) { Console.WriteLine($"Fail with error: {e.Message}!"); } }