public override void Show() { base.Show(); try { // מציגים את רשימת המשחקים Task <List <ActionOptionDTO> > list = UIMain.api.GetAllFoodAsync(); ObjectsList foods = new ObjectsList("foods", list.Result.ToList <object>()); foods.Show(); Console.WriteLine(); Console.WriteLine("Please enter food option ID:"); int foodId = int.Parse(Console.ReadLine()); const int DEAD_STATUS_ID = 4; Task <List <PetDTO> > playerPets = UIMain.api.GetPlayerPetsAsync(); PetDTO p = playerPets.Result.Where(p => p.LifeStatusId != DEAD_STATUS_ID).FirstOrDefault(); ActionOptionDTO actionOptionDTO = list.Result.Where(a => a.OptionId == foodId).FirstOrDefault(); if (p == null) { Console.WriteLine("There is no active pet"); } else { Task <bool> task = UIMain.api.DoActionFeedAsync(actionOptionDTO); if (task.Result) { Console.WriteLine($"The pet ate {actionOptionDTO.OptioName}"); } else { Console.WriteLine("Something wrong happened!"); } } } catch (Exception e) { Console.Clear(); Console.WriteLine("Something wrong happened!"); Console.WriteLine($"Error message: {e.Message}"); } Console.WriteLine("Please press any key to get back to menu!"); Console.ReadKey(true); }
public override void Show() { base.Show(); ObjectView showPlayer = new ObjectView("", UIMain.CurrentPlayer); showPlayer.Show(); Console.WriteLine("Press A to see Player pets or other key to go back!"); char c = Console.ReadKey().KeyChar; if (c == 'a' || c == 'A') { //Read first the animals of the player Task <List <PetDTO> > t = UIMain.api.GetPlayerPetsAsync(); Console.WriteLine("Reading player pets..."); t.Wait(); List <PetDTO> list = t.Result; if (list != null) { //Create list to be displayed on screen //Format the desired fields to be shown! (screen is not wide enough to show all) List <Object> pets = list.ToList <Object>(); ObjectsList oList = new ObjectsList("pets", pets); oList.Show(); Console.WriteLine(); } else { Console.WriteLine("pets coud not be read!"); } Console.WriteLine(); Console.ReadKey(); } }