string StartDetailView(TamagotchiContract tama) { if (tama == null) { return(""); } while (true) { System.Console.Clear(); WriteHeader(); WriteTamagotchiStatus(tama); if (tama.IsInCoolDown) { WriteLine(); WriteLine($"Cooldown in effect until {tama.CoolDownUntilUtc.ToLocalTime()}."); if (tama.CoolDownLeft.Hours > 0) { WriteLine($" Cooldown will take another {tama.CoolDownLeft.Hours} hours {tama.CoolDownLeft.Minutes} minutes and {tama.CoolDownLeft.Seconds} seconds."); } else if (tama.CoolDownLeft.Hours == 0 && tama.CoolDownLeft.Minutes > 0) { WriteLine($" Cooldown will take another {tama.CoolDownLeft.Minutes} minutes and {tama.CoolDownLeft.Seconds} seconds."); } else if (tama.CoolDownLeft.Hours == 0 && tama.CoolDownLeft.Minutes == 0) { WriteLine($" Cooldown will take another {tama.CoolDownLeft.Seconds} seconds."); } } WriteLine(); WriteLine("Type [quit] to close the application." + NewLine + "Type [back] to go back to the Tamgotchi overview." + NewLine + "Type [rules] to view the rules for this Tamagotchi." + NewLine + "Type [refresh]/[r] to update this page."); if (tama.HasDied) { WriteLine("Type [delete] to delete this Tamagotchi."); } if (!tama.IsInCoolDown && !tama.HasDied) { WriteLine("Available actions:" + NewLine + " [eat] [sleep] [play] [workout] [hug]"); } WriteLine(); try { _repo.HasData(); } catch (Exception) { ShowConnectionError(); } string input = AskForInput(); if (input == "quit" || input == "back") { return(input); } switch (input) { case "quit": case "back": return(input); case "refresh": case "r": try { tama = _repo.Get(tama.Name); } catch (Exception) { ShowConnectionError(); } break; case "eat": if (!_repo.Eat(tama.Name)) { AskForInput("Action not available, press any button to continue"); } try { tama = _repo.Get(tama.Name); } catch (Exception) { ShowConnectionError(); } break; case "sleep": if (!_repo.Sleep(tama.Name)) { AskForInput("Action not available, press any button to continue"); } try { tama = _repo.Get(tama.Name); } catch (Exception) { ShowConnectionError(); } break; case "play": if (!_repo.Play(tama.Name)) { AskForInput("Action not available, press any button to continue"); } try { tama = _repo.Get(tama.Name); } catch (Exception) { ShowConnectionError(); } break; case "workout": if (!_repo.Workout(tama.Name)) { AskForInput("Action not available, press any button to continue"); } try { tama = _repo.Get(tama.Name); } catch (Exception) { ShowConnectionError(); } break; case "hug": if (!_repo.Hug(tama.Name)) { AskForInput("Action not available, press any button to continue"); } try { tama = _repo.Get(tama.Name); } catch (Exception) { ShowConnectionError(); } break; case "rule": case "rules": var output = StartRulesView(tama); if (output == "quit") { return("quit"); } try { tama = _repo.Get(tama.Name); } catch (Exception) { ShowConnectionError(); } break; case "delete": case "remove": case "d": if (!tama.HasDied) { WriteLine("Alive Tamagotchis cannot be deleted.", ConsoleColor.Red); AskForInput("Press any button to continue"); break; } try { _repo.Remove(tama.Name); } catch (Exception) { ShowConnectionError(); } return("back"); case "delete -g": case "remove -g": case "d -g": try { _repo.Remove(tama.Name); } catch (Exception) { ShowConnectionError(); } return("back"); default: WriteLine("Command not recognized.", ConsoleColor.Red); AskForInput("Press any button to continue"); break; } } }