/// <summary> /// release a player from the game /// </summary> /// <param name="player"></param> public void leave(int player) { if (player == 1) { player1 = null; } else if (player == 2) { player2 = null; } string leaveMsg = string.Format("Player {0} has left", player); sendGameMessage(leaveMsg); }
/// <summary> /// Reset the game and its objects /// </summary> public void resetGame() { if (gameIsNotRunning) { deck = new Deck(); deck.Shuffle(); dealer = new Player(-1, "Dealer", 0); if (player1 != null) player1.resetCards(); if (player2 != null) player2.resetCards(); gameIsNotRunning = false; } }
/// <summary> /// Add a palyer to the game /// </summary> /// <param name="username"></param> /// <param name="money"></param> /// <param name="numOfGames"></param> /// <param name="ID"></param> /// <returns></returns> public int join(string username, int money, int numOfGames, int ID) { if (player1 == null) { player1 = new Player(ID, username, money); return 1; } else if (player2 == null) { player2 = new Player(ID, username, money); return 2; } else { return -1; } }