public bool AssignPlayerReferencesToPlayers(Guid player1ReferenceId, Guid player2ReferenceId) { bool matchHasNotBegun = GetPlayState() == PlayStateEnum.NotBegun; if (matchHasNotBegun) { bool anyPlayerReferenceIsInvalid = player1ReferenceId == Guid.Empty || player2ReferenceId == Guid.Empty; bool bothPlayerReferencesDiffer = anyPlayerReferenceIsInvalid || player1ReferenceId != player2ReferenceId; if (bothPlayerReferencesDiffer) { Player1.AssignPlayerReference(player1ReferenceId); Player2.AssignPlayerReference(player2ReferenceId); return(true); } } return(false); }
public bool AssignPlayerReferenceToFirstAvailablePlayer(Guid playerReferenceId) { bool matchHasNotBegun = GetPlayState() == PlayStateEnum.NotBegun; bool playerReferenceIsValid = playerReferenceId != Guid.Empty; if (matchHasNotBegun && playerReferenceIsValid) { bool firstPlayerHasNoPlayerReference = Player1.PlayerReferenceId == Guid.Empty; if (firstPlayerHasNoPlayerReference) { Player1.AssignPlayerReference(playerReferenceId); return(true); } bool secondPlayerHasNoPlayerReference = Player2.PlayerReferenceId == Guid.Empty; if (secondPlayerHasNoPlayerReference) { Player2.AssignPlayerReference(playerReferenceId); return(true); } } return(false); }