Пример #1
0
 public void AddPlayer(int id, string name)
 {
     if (!PlayersMoves.ContainsKey(id))
     {
         PlayersMoves.Add(id, new Player(id, name));
         PlayerQueue.Enqueue(id);
     }
 }
Пример #2
0
 private void UpdateMove(int id, char move)
 {
     if (PlayersMoves.ContainsKey(id))
     {
         var player = PlayersMoves[id];
         player.Moves.Movestring += move;
     }
 }
Пример #3
0
        private void Move(int id, char move)
        {
            if (PlayersMoves.ContainsKey(id))
            {
                var player = PlayersMoves[id];
                player.Moves.Score = BowlingAllyCalc.GetScore(player.Moves.Movestring, move, player.Moves.Score);

                player.Moves.Movestring += move;
            }
        }
Пример #4
0
        public void Play()
        {
            while (PlayerQueue.Count >= 0)
            {
                var playerId = PlayerQueue.Peek();
                if (PlayersMoves.ContainsKey(playerId))
                {
                    var player = PlayersMoves[playerId];
                    player.Moves.CurrentSet++;
                }

                for (int i = 0; i < 2; i++)
                {
                    Console.WriteLine($"{playerId} Move. enter move: ");
                    var move = Convert.ToChar(Console.ReadLine());

                    if (i == 0 && char.IsDigit(move))
                    {
                        UpdateMove(playerId, move);
                    }
                    else if (i == 0 && !char.IsDigit(move))
                    {
                        Move(playerId, move);
                    }
                    else if (i == 1 && char.IsDigit(move))
                    {
                        Move(playerId, move);
                    }
                    else if (i == 1 && !char.IsDigit(move))
                    {
                        UpdateMove(playerId, move);
                    }
                }

                if (PlayersMoves.ContainsKey(playerId))
                {
                    var player = PlayersMoves[playerId];
                    if (player.Moves.CurrentSet == 2)
                    {
                        PlayerQueue.Dequeue();
                    }
                    else
                    {
                        PlayerQueue.Enqueue(PlayerQueue.Dequeue());
                    }
                }
            }
        }