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; }
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)); } } }
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); }