public void Help(Server server) { server.SendMessageToAll("clear"); System.Threading.Thread.Sleep(500); server.SendMessageToAll("Hello and welcome in the game \"Crazy Eights\". The rules are the followings\n" + "\nThe goal is to be the first player to get rid of all the cards in his hand.\n\n" + "The player who is the first to have no cards left wins the game. The winning player collects from each other player the value of the cards remaining in that player’s hand as follows :\n\n" + "Each Eight = 50 Points\nEach King, Queen or Jack = 10 Points\nEach ace = 1 Point\nEach other card is the pip value.\n\n" + "This is a 3 set Match. The winner is the one who has least of points at the end of the game.\n" + "Let's begin. " + "Rock and Roll. Go."); }
private void IsAce(Player player, Player[] allPlayers, Server server) { if (sense == '+') { sense = '-'; } else { sense = '+'; } server.SendMessageToAll("Now the sense of the game changed."); }
private void IsJack(Player player, Player[] allPlayers, Server server) { if (sense == '+') { turn = turn + 1; if (turn == 4) { turn = 0; } } else { turn = turn - 1; if (turn == -1) { turn = 3; } } server.SendMessageToAll("The turn of Player n°" + (turn + 1) + " was skipped.\n"); }
private void IsEight(Player player, Player[] allPlayer, Server server) { int valid = 0; while (valid == 0) { server.SendMessageToOne(player.Id, "Which color do you choose ?\nHearts ?\tClubs ?\tSpades ?\tDiamonds ?"); valid = 1; server.LastPlayerId = null; while (server.LastPlayerId == null || !(player.Id.ConnectionInfo.Equals(server.LastPlayerId.ConnectionInfo))) { } if (server.LastMessaged == "Hearts" || server.LastMessaged == "hearts") { lastCard.Color = "Hearts"; lastCard.Face = ""; } else if (server.LastMessaged == "Clubs" || server.LastMessaged == "clubs") { lastCard.Color = "Clubs"; lastCard.Face = ""; } else if (server.LastMessaged == "Spades" || server.LastMessaged == "Spades") { lastCard.Color = "Spades"; lastCard.Face = ""; } else if (server.LastMessaged == "Diamonds" || server.LastMessaged == "Diamonds") { lastCard.Color = "Diamonds"; lastCard.Face = ""; } else { valid = 0; server.SendMessageToOne(player.Id, "Unknown color ? (Maybe a Typo Error)"); } System.Threading.Thread.Sleep(2000); } server.SendMessageToAll("The new color is : " + lastCard.Color); }
private void IsTwo(Player player, Player[] allPlayers, Server server) { int i; if (sense == '+') { i = turn + 1; if (i == 4) { i = 0; } } else { i = turn - 1; if (i == -1) { i = 3; } } allPlayers[i].hand.AddInHand(deck, 2, server, allPlayers[i]); server.SendMessageToAll("Player n°" + (i + 1) + " drew 2 cards\n"); }
public Rules(Server server, Player[] allPlayers) { round = 0; Help(server); sense = '+'; System.Threading.Thread.Sleep(10000); while (round < 3) { server.SendMessageToAll("clear"); System.Threading.Thread.Sleep(2000); server.SendMessageToAll("Time for another round.\nHere we Go"); deck = new Deck(); deck.Shuffle(); lastCard = deck.Deal(); InitPlayersHand(deck, allPlayers); end = -1; turn = 0; System.Threading.Thread.Sleep(1000); for (int i = 0; i < 4; i++) { allPlayers[i].hand.ShowHand(allPlayers[i].Id, server, this); } System.Threading.Thread.Sleep(1000); while (end == -1 && deck.Idx < 54) { YourTurn(allPlayers[turn], server, allPlayers); if (sense == '+') { turn = turn + 1; } else { turn = turn - 1; } if (turn == -1) { turn = 3; } else if (turn == 4) { turn = 0; } } server.SendMessageToAll("Player n°" + end + " is the winner of this round."); for (int i = 0; i < 4; i++) { if (i != end) { allPlayers[i].Score += GetScore(allPlayers[i].hand); } server.SendMessageToOne(allPlayers[i].Id, "Your total score is " + allPlayers[i].Score.ToString()); } round = round + 1; } server.SendMessageToAll("clear"); server.SendMessageToAll("Here is the final score :\nPlayer n°1 : " + allPlayers[0].Score.ToString() + "\nPlayer n°2 : " + allPlayers[1].Score.ToString() + "\nPlayer n°3 : " + allPlayers[2].Score.ToString() + "\nPlayer n°4 : " + allPlayers[3].Score.ToString()); winner = 0; winnerScore = allPlayers[0].Score; for (int i = 0; i < 4; i++) { if (allPlayers[i].Score < winnerScore) { winner = i; winnerScore = allPlayers[i].Score; } } System.Threading.Thread.Sleep(300); server.SendMessageToAll("The winner of this game is Player n°" + winner + " with a score of " + allPlayers[winner].Score.ToString() + "\nWell Done. I hope you enjoyed the game."); System.Threading.Thread.Sleep(10000); }