Beispiel #1
0
        public void ChangeTactic(EFormation eFormation)
        {
            TacticBuildDirector tacticBuildDirector = new TacticBuildDirector();

            BestTactic = tacticBuildDirector.GetTactic(eFormation, this.Players);
        }
Beispiel #2
0
        public void Init()
        {
            dataLayer.SetIPlayerListener(this);
            _run = true;
            while (_run)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Please select one option: ");
                Console.WriteLine("1. Show all players ");
                Console.WriteLine("2. Add player ");
                Console.WriteLine("3. Show Team ");
                Console.WriteLine("4. Show best tactic ");
                Console.WriteLine("5. Change Tactic ");
                Console.WriteLine("6. Iterate Team");
                Console.WriteLine("0. Exit ");
                Console.WriteLine("Enter option: ");
                Console.ForegroundColor = ConsoleColor.White;

                var optionString = Console.ReadLine();

                int option = -1;
                try
                {
                    option = Convert.ToInt32(optionString);
                }
                catch
                {
                    Console.WriteLine("Please insert a valid option ");
                    continue;
                }

                if (option >= 0 && option <= 6)
                {
                    switch (option)
                    {
                    case 1:
                        foreach (Player p in team.Players)
                        {
                            Console.WriteLine(p);
                        }
                        break;

                    case 2:
                        Player player = InsertNewPlayer();
                        if (player == null)
                        {
                            Console.WriteLine("Error, please try again");
                            break;
                        }
                        else
                        {
                            dataLayer.AddPlayer(player);
                            Console.WriteLine("Player added");
                        }
                        break;

                    case 3:
                        Console.WriteLine(team);
                        break;

                    case 4:
                        if (team.BestTactic == null)
                        {
                            Console.WriteLine("No best tactic");
                        }
                        else
                        {
                            Console.WriteLine(team.BestTactic);
                        }
                        break;

                    case 5:
                        Console.WriteLine("Tactic: ");
                        Console.WriteLine("1. Formation 2_3_5");
                        Console.WriteLine("2. Formation 3_2_5");
                        Console.WriteLine("3. Formation 2_3_2_3");
                        Console.WriteLine("4. Formation 4_2_4");
                        Console.WriteLine("5. Formation 4_3_3");
                        Console.WriteLine("6. Formation 5_4_1");
                        Console.WriteLine("7. Formation 4_4_2");
                        Console.WriteLine("8. Formation 3_5_2");
                        Console.WriteLine("9. Formation 4_2_3_1");

                        var formationString = Console.ReadLine();
                        int formation       = Convert.ToInt32(formationString);
                        switch (formation)
                        {
                        case 1:
                            team.BestTactic = tacticDir.GetTactic(EFormation.Formation2_3_5, new List <Player>(team.Players));
                            break;

                        case 2:
                            team.BestTactic = tacticDir.GetTactic(EFormation.Formation3_2_5, new List <Player>(team.Players));
                            break;

                        case 3:
                            team.BestTactic = tacticDir.GetTactic(EFormation.Formation2_3_2_3, new List <Player>(team.Players));
                            break;

                        case 4:
                            team.BestTactic = tacticDir.GetTactic(EFormation.Formation4_2_4, new List <Player>(team.Players));
                            break;

                        case 5:
                            team.BestTactic = tacticDir.GetTactic(EFormation.Formation4_3_3, new List <Player>(team.Players));
                            break;

                        case 6:
                            team.BestTactic = tacticDir.GetTactic(EFormation.Formation5_4_1, new List <Player>(team.Players));
                            break;

                        case 7:
                            team.BestTactic = tacticDir.GetTactic(EFormation.Formation4_4_2, new List <Player>(team.Players));
                            break;

                        case 8:
                            team.BestTactic = tacticDir.GetTactic(EFormation.Formation3_5_2, new List <Player>(team.Players));
                            break;

                        case 9:
                            team.BestTactic = tacticDir.GetTactic(EFormation.Formation4_2_3_1, new List <Player>(team.Players));
                            break;

                        default:
                            Console.WriteLine("No formation selected...");
                            break;
                        }
                        break;

                    case 6:
                        IterateTeamPlayers();
                        break;

                    case 0:
                        _run = false;
                        Environment.Exit(0);
                        break;

                    default:
                        Console.WriteLine("Unknown option " + option);
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("Unknown option " + option);
                }
            }
        }