예제 #1
0
 public void UpdateRoomPlayer(RoomPlayer roomPlayer)
 {
     WordsPerMinute                = roomPlayer.WordsPerMinute;
     CorrectlyTypedTextIndex       = roomPlayer.CorrectlyTypedTextIndex;
     IncorrectilyTypedTextEndIndex = roomPlayer.IncorrectilyTypedTextEndIndex;
     CurrentTextIndex              = roomPlayer.CurrentTextIndex;
     CorrectlyTypedWordNumber      = roomPlayer.CorrectlyTypedWordNumber;
     HasWon       = roomPlayer.HasWon;
     CurrentInput = roomPlayer.CurrentInput;
     IsRoomAdmin  = roomPlayer.IsRoomAdmin;
 }
예제 #2
0
 public void UpdateRoomPlayer(RoomPlayer player)
 {
     if (!HasFinished && !player.IsDone)
     {
         var FinishedWord = player.CheckInput();
         if (FinishedWord)
         {
             if (player.CurrentWord != WordList[WordList.Count - 1])
             {
                 player.UpdateCurrentWord(WordList[player.CorrectlyTypedWordNumber]);
             }
             else
             {
                 player.PlayerDone();
             }
             player.UpdateWordsPerMinute(Convert.ToInt32(player.CorrectlyTypedWordNumber / (DateTime.Now - TimeStarted).TotalMinutes));
         }
     }
 }
예제 #3
0
        public bool CheckIfOver()
        {
            var isOver = false;

            if ((DateTime.Now - TimeStarted).TotalSeconds >= GameLengthSeconds)
            {
                isOver      = true;
                HasFinished = true;
                int        maxWords      = -1;
                RoomPlayer maxWordPlayer = null;
                foreach (var player in roomPlayers)
                {
                    if (player.CorrectlyTypedWordNumber > maxWords)
                    {
                        maxWords      = player.CorrectlyTypedWordNumber;
                        maxWordPlayer = player;
                    }
                }
                maxWordPlayer.PlayerWon();
            }
            else
            {
                foreach (var player in roomPlayers)
                {
                    if (player.IsDone && roomPlayers.Where(p => p.HasWon == true).Count() == 0)
                    {
                        player.PlayerWon();
                    }
                }
                if (roomPlayers.All(p => p.IsDone))
                {
                    isOver      = true;
                    HasFinished = true;
                }
            }
            return(isOver);
        }