public static void TestCards(string cmd, string sender, MatrixRoom room) { List <PlayingCard> deck = PlayingCard.GetStandardDeck(); PlayingCard.ShuffleDeck(ref deck); string cards = PlayingCard.GetDeckHTML(deck); MMessageCustomHTML htmlmsg = new MMessageCustomHTML(); htmlmsg.formatted_body = cards; htmlmsg.body = string.Join <PlayingCard>(" ", deck); room.SendMessage(htmlmsg); }
public static void ShuffleDeck(ref List <PlayingCard> cards) { Random random = new Random(); for (int i = 0; i < random.Next(75, 150); i++) { int x = random.Next(0, cards.Count - 1); int y = random.Next(0, cards.Count - 1); PlayingCard card = new PlayingCard(cards[x].suit, cards[x].value); cards[x] = cards[y]; cards[y] = card; } }
public override void GameStart() { playerLied = false; currentPlayer = 0; lastPlayer = -1; expectedValue = 2; base.GameStart(); //Dish out cards to players deck = PlayingCard.GetStandardDeck(); PlayingCard.ShuffleDeck(ref deck); hands = new Dictionary <string, List <PlayingCard> >(); user_rooms = new Dictionary <string, MatrixRoom>(); foreach (MatrixUser user in users) { hands.Add(user.UserID, new List <PlayingCard>()); } int i = 0; while (deck.Count > 0) { hands[users[i].UserID].Add(deck[0]); deck.RemoveAt(0); i = (i + 1) % users.Count; } foreach (KeyValuePair <string, List <PlayingCard> > deck in hands) { //Create a room and send the player their cards. Console.WriteLine(deck.Key + "'s hand:" + string.Join <PlayingCard>(" ", deck.Value)); MatrixRoom uroom = client.CreateRoom(new MatrixCreateRoom() { invite = new string[1] { deck.Key }, name = "[Card:Hand] Hand for Cheat Lobby", topic = "This room will pass you information", visibility = EMatrixCreateRoomVisibility.Private }); user_rooms.Add(deck.Key, uroom); SendDeckUpdate(deck.Key); uroom.SendNotice("To play a card, type [H,D,S,C] [2-10,J,Q,K,A] in your **private room**. You may type multiple cards seperated by a space."); uroom.SendNotice("To to check your hand, type 'hand'."); uroom.OnMessage += HandMessage; string name = (users.First(x => x.UserID == deck.Key)).DisplayName; } }
public static bool TryParse(string cardset, out PlayingCard card) { int val = 0; card = null; if (cardset.Length > 3) { return(false); } char suit = LetterToSuit(cardset[0]); val = StringToValue(cardset.Substring(1)); if (val < 1 || val > 13 || SuitToValue(suit) == -1) { return(false); } card = new PlayingCard(suit, val); return(true); }
private void NextTurn() { lastPlayer = currentPlayer; currentPlayer = (currentPlayer + 1) % users.Count; expectedValue++; if (expectedValue > 13) { expectedValue = 1; } cheatCalled = false; room.SendNotice(users[currentPlayer].DisplayName + " is up next, expecting cards valued at " + PlayingCard.ValueToString(expectedValue)); }