public static void PreparePlayersType(GameRestriction restriction)
 {
     _playerCreators.Add(PlayerType.Cheater, name => new CheaterPlayer(name, new MemorizeGuessStrategy(restriction)));
     _playerCreators.Add(PlayerType.Memory, name => new MemoryPlayer(name, new MemorizeGuessStrategy(restriction)));
     _playerCreators.Add(PlayerType.Random, name => new RandomPlayer(name, new RandomGuessStrategy(restriction)));
     _playerCreators.Add(PlayerType.Thorough, name => new ThoroughPlayer(name, new ThoroughGuessStrategy(restriction)));
     _playerCreators.Add(PlayerType.ThoroughCheater, name => new ThoroughCheaterPlayer(name, new ThoroughMemorizeGuessStrategy(restriction)));
 }
示例#2
0
        private static void Main()
        {
            var game        = new Game();
            var restriction = new GameRestriction(MinPlayers, MaxPlayers, MinWeight, MaxWeight, MaxAttempts, MaxMilliseconds);

            ShowPlayerTypes();
            var playersNumber = ReadPlayersNumber(restriction);
            var players       = ReadPlayersInfo(playersNumber);

            game.Initialize(players, restriction);
            Console.WriteLine($"Game is started! The real basket weight: {game.GetBasketWeight()}\n");
            var resultState = game.Play();

            Console.WriteLine(resultState.ToString());
        }
示例#3
0
        private static int ReadPlayersNumber(GameRestriction restriction)
        {
            bool isValid;
            int  result;

            do
            {
                Console.Write("Enter players number: ");
                var input = Console.ReadLine();
                isValid = int.TryParse(input, out result);
                isValid = isValid && (result <= restriction.MaxPlayers &&
                                      result >= restriction.MinPlayers);

                if (!isValid)
                {
                    Console.WriteLine($"Type correct integer number between {restriction.MinPlayers} and {restriction.MaxPlayers}.");
                }
            } while (!isValid);

            return(result);
        }
 public ThoroughMemorizeGuessStrategy(GameRestriction res) : base(res)
 {
 }
 public MemorizeGuessStrategy(GameRestriction res) : base(res)
 {
     _numbersToGuess = Enumerable.Range(_min, _max - _min + 1).ToList();
 }
示例#6
0
 public ThoroughGuessStrategy(GameRestriction res) : base(res)
 {
     _currentValue = res.MinWeight;
 }
示例#7
0
 protected GenericGuessStrategy(GameRestriction res)
 {
     _min = res.MinWeight;
     _max = res.MaxWeight;
 }
 public void Start(GameRestriction g)
 {
     _executingThread.Start();
 }
 public RandomGuessStrategy(GameRestriction res) : base(res)
 {
 }