Beispiel #1
0
        private void RunGame()
        {
            while (true)
            {
                if (game.HeroInTown())
                {
                    console.TellStory($"Day {game.DayCount}: You are in a town.");
                    int townOption = console.GetOption(townOptions);
                    switch (townOption)
                    {
                    case 1:
                        console.PrintHeroInfo();
                        continue;

                    case 2:
                        console.PrintGrid();
                        continue;

                    case 3:
                        Move();
                        break;

                    case 4:
                        game.HeroRest();
                        break;

                    case 5:
                        gameFactory.Save(game);
                        break;

                    case 6:
                        if (console.ConfirmSelection("exit to main menu"))
                        {
                            console.BackToMainMenu();
                            return;
                        }
                        break;

                    default:
                        throw new ArgumentException("No such option: " + townOption);
                    }
                }
                else
                {
                    console.TellStory($"Day {game.DayCount}: You are out in the open.");
                    if (game.EncounterEnemy())
                    {
                        switch (RunAttack())
                        {
                        case AttackResult.HeroLost:
                        case AttackResult.HeroWon:
                            console.BackToMainMenu();
                            return;
                        }
                    }
                    int openOption = console.GetOption(openOptions);
                    switch (openOption)
                    {
                    case 1:
                        console.PrintHeroInfo();
                        continue;

                    case 2:
                        console.PrintGrid();
                        continue;

                    case 3:
                        Move();
                        break;

                    case 4:
                        console.PrintOrbState(game.SenseOrb());
                        break;

                    case 5:
                        if (console.ConfirmSelection("exit to main menu"))
                        {
                            console.BackToMainMenu();
                            return;
                        }
                        break;

                    default:
                        throw new ArgumentException("No such option: " + openOption);
                    }
                }

                game.NextDay();
            }
        }