//TODO : REFACTOR IT!! public void StartRound() { DateTime roundStartTIme; //roundStartTIme = DateTime.Now.Add(TimeSpan.FromSeconds(Constants.LENGTH_OF_ROUND)); while (isActive) { //Wait while client Catch Cards if ((p1.Ready && p2.Ready)) { SendCards(); p1.Ready = false; p2.Ready = false; roundStartTIme = DateTime.Now; ServerTCP.PACKET_StartRound(p1.connectionID); ServerTCP.PACKET_StartRound(p2.connectionID); while ((!p1.Ready || !p2.Ready) && DateTime.Now.Subtract(roundStartTIme).Seconds <= Constants.LENGTH_OF_ROUND) { } int p1SelectedCardID = p1.selectedCardID; int p2SelectedCardID = p2.selectedCardID; CalculateResults(); SendResults(); p1.SetDefaultValuesForResult(); p2.SetDefaultValuesForResult(); } if (p1.health <= 0 || p2.health <= 0) { isActive = false; } } string winnerUsername = "******"; if (p1.health <= 0 && p2.health <= 0) { ServerTCP.PACKET_FinishGame(p1.connectionID, winnerUsername); ServerTCP.PACKET_FinishGame(p2.connectionID, winnerUsername); } else { winnerUsername = p1.health < p2.health ? p2.username : p1.username; ServerTCP.PACKET_FinishGame(p1.connectionID, winnerUsername); ServerTCP.PACKET_FinishGame(p2.connectionID, winnerUsername); } }