예제 #1
0
        private static void RunRobotMatch(int matches)
        {
            int matchId = 1;
            var ui      = Chat.GetUI();

            var allStrategies = _strategyFactory.GetAllRobots().Select(s => s.Name).ToArray();

            ui.Send("Robot disponibili:");
            for (int i = 0; i < allStrategies.Length; i++)
            {
                ui.Send($" {i + 1} | {allStrategies[i]}");
            }
            ui.Send("");
            ui.Send(" 0 | Annulla");

            ui.Send("");
            var s1Choiche       = ui.GetInt("Scegli il primo robot", null);
            var s2Choiche       = ui.GetInt("Scegli il secondo robot", null);
            var strategyHome    = allStrategies[s1Choiche - 1];
            var strategyVisitor = allStrategies[s2Choiche - 1];

            var numPlayers = ui.GetInt("Scegli il numero di giocatori (default = 4)", 4);


            var scores = new List <Tuple <int, int> >();

            for (int i = 0; i < matches; i++)
            {
                var g      = new BriscolaGame(new ItalianDeckFactory(), new PlayerFactory());
                var runner = new GameRunner(g, ui, _strategyFactory);
                runner.InitializeRoboMatch(strategyHome, strategyVisitor, numPlayers);
                var result = runner.Play();
                scores.Add(result);
            }

            foreach (var score in scores)
            {
                ui.Send("MATCH " + matchId + ": " + score.Item1 + " - " + score.Item2);
                matchId++;
            }

            var team1Score = scores.Count(x => x.Item1 > 60) * 2 + scores.Count(x => x.Item1 == 60);
            var team2Score = scores.Count(x => x.Item2 > 60) * 2 + scores.Count(x => x.Item2 == 60);

            ui.Send("Squadra 1: " + team1Score);
            ui.Send("Squadra 2: " + team2Score);
        }