/// <summary> /// Sets the Suit and Number properties using parameters. Face is null since the card is not a face card. /// Image path is set using the newly set Suit and Number properties. /// </summary> /// <param name="suit">The suit of the card</param> /// <param name="number">The number on the card</param> public Card(Suits suit, int number) { Suit = suit; Number = number; Face = null; Image = $"../images/cards/{Suit.ToString().ToLower()}{Number}.png"; }
private bool trumpCard = false; //Козырная масть public Card(Suits _suit, int _rank, string _imageName) { suit = _suit.ToString(); rank = _rank; imageName = _imageName; LoadDefaultSettings(); }
public void ToEnum_ValidEnum_ConvertsToEnumWithGenericOverload() { string strEnum = "SPADE"; Suits suit = strEnum.ToEnum <Suits>(true); Assert.IsTrue(suit.ToString().Equals(strEnum, StringComparison.OrdinalIgnoreCase)); }
public void ToEnum_ValidEnum_ConvertsToEnum() { string strEnum = "SPADE"; Suits suit = strEnum.ToEnum(typeof(Suits)); Assert.IsTrue(suit.ToString().Equals(strEnum, StringComparison.OrdinalIgnoreCase)); }
public Seats Owner(Suits suit, Ranks rank) { for (int i = 0; i <= lastCard; i++) { if (!deal[i].played && deal[i].Suit == suit && deal[i].Rank == rank) { return(deal[i].Seat); } } throw new FatalBridgeException("No owner found for " + suit.ToString() + " " + rank.ToString()); }
public void ShowCard() { string msg = ""; if ((int)_rank != 11) { msg = ((int)_rank).ToString(); } else { msg = ((int)_rank).ToString() + " or 1"; } Console.WriteLine($"#{ _suit.ToString()} _ { _rank.ToString()}# Value: " + msg); }
public string SuitToString(Suits s) { StringBuilder sb = new StringBuilder(); sb.Append($"{DeckName}: Cards for Suit {s.ToString()}{Environment.NewLine}"); foreach (PlayingCard p in cards) { if (p.Suit == s) { sb.Append(p.ToString() + Environment.NewLine); } } return(sb.ToString()); }
public static string ToString(Suits suit) { switch (suit) { case Suits.Clubs: return "C"; case Suits.Diamonds: return "D"; case Suits.Hearts: return "H"; case Suits.Spades: return "S"; default: throw new InvalidEnumArgumentException(suit.ToString()); } }
/// <summary>Constructor</summary> /// <param name="s">Suit of the bid</param> /// <param name="l">Level of the bid</param> public Bid(Suits s, BidLevels l) { if (l > BidLevels.Level7) { throw new ArgumentOutOfRangeException("l", l.ToString()); } if (s > Suits.NoTrump) { throw new ArgumentOutOfRangeException("s", s.ToString()); } this.suit = s; this.level = l; this.special = SpecialBids.NormalBid; this.explanation = ""; this.alert = false; this.Hint = false; }
/// <summary> /// 创建n副牌 /// </summary> void CreateDeck(int deck_count) { library.Clear(); //指定几副牌 for (int i = 0; i < deck_count; i++) { //创建普通扑克 for (int color = 0; color < 4; color++) { for (int value = 1; value < 14; value++) { Weight w = (Weight)value; Suits s = (Suits)color; string name = s.ToString() + w.ToString(); Card card = new Card(name, w, s); library.Add(card); } } } }
public static string ToString(Suits suit) { switch (suit) { case Suits.Clubs: return("C"); case Suits.Diamonds: return("D"); case Suits.Hearts: return("H"); case Suits.Spades: return("S"); default: throw new InvalidEnumArgumentException(suit.ToString()); } }
void CreateDeck() { for (int color = 0; color < 4; color++) { for (int value = 0; value < 13; value++) { Weight w = (Weight)value; Suits s = (Suits)color; string name = s.ToString() + w.ToString(); Card card = new Card(name, w, s, ctype); library.Add(card); } } //创建大小joker Card smallJoker = new Card("SJoker", Weight.SJoker, Suits.None, ctype); Card largeJoker = new Card("LJoker", Weight.LJoker, Suits.None, ctype); library.Add(smallJoker); library.Add(largeJoker); }
public override string ToString() { return(Value.ToString() + " of " + Suit.ToString()); }
public CardSerializer ConvertCardToCardSerializer() { return(new CardSerializer(Rank.ToString(), Suit.ToString())); }
public bool Suits(Suits suit) { return(HotelSuits.Contains(suit.ToString())); }
public override string ToString() { return(Values + Suits.ToString()); }
public string ShowCard() { return("Suit: " + Suits.ToString() + "\r\nValue: " + Values.ToString()); }
/// <summary> /// Sets the Suit and Face properties using parameters. Face property will set the Number property. /// Image path is set using the newly set Suit and Face properties. /// </summary> /// <param name="suit">The suit of the card</param> /// <param name="face">The face of the card</param> public Card(Suits suit, string face) { Suit = suit; Face = face; Image = $"../images/cards/{Suit.ToString().ToLower()}{Face}.png"; }
//This is the replacement for the constructor, in a way. This is a contructor to construct a GAMEOBJECT IN UNITY, which is different than creating an OBJECT in code. //At no time should an object of this class be needed, except for in this method. All we need is the GameObject in Unity that the player will be interacting with. /// <summary> /// Initiates an object of type Card, with the supplied prefab, position, rank and suit. /// </summary> /// <param name="prefab">The prefab that represents the object in Unity.</param> /// <param name="position">Position to instantiate at.</param> /// <param name="_rank">The card's rank.</param> /// <param name="_suit">The card's suit.</param> public static Card Init(GameObject prefab, Vector3 position, Ranks _rank, Suits _suit) { //Instantiate the prefab into the scene with the provided arguments, then store in a variable GameObject card_obj = Instantiate(prefab, position, Quaternion.identity) as GameObject; //Get that variable's Card component, which it inherited from the prefab, and store THAT inside a variable Card _card = card_obj.GetComponent <Card>(); //Set the rank and suit to the ones provided _card.rank = _rank; _card.suit = _suit; //Set the card name, and set the name of the object in the scene to the same name _card.cardName = string.Format("{0} of {1}", _rank.ToString(), _suit.ToString()); card_obj.name = _card.cardName; //If the card is a jack, queen, or king, set FaceCard equal to true if (_card.rank == Ranks.JACK || _card.rank == Ranks.QUEEN || _card.rank == Ranks.KING) { _card.faceCard = true; } #region SWITCH STATEMENT FOR TEXTURING //Texture each card according to name switch (_card.cardName) { case "ACE of CLUBS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[0]; break; case "TWO of CLUBS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[1]; break; case "THREE of CLUBS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[2]; break; case "FOUR of CLUBS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[3]; break; case "FIVE of CLUBS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[4]; break; case "SIX of CLUBS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[5]; break; case "SEVEN of CLUBS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[6]; break; case "EIGHT of CLUBS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[7]; break; case "NINE of CLUBS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[8]; break; case "TEN of CLUBS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[9]; break; case "JACK of CLUBS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[10]; break; case "QUEEN of CLUBS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[11]; break; case "KING of CLUBS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[12]; break; case "ACE of DIAMONDS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[13]; break; case "TWO of DIAMONDS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[14]; break; case "THREE of DIAMONDS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[15]; break; case "FOUR of DIAMONDS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[16]; break; case "FIVE of DIAMONDS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[17]; break; case "SIX of DIAMONDS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[18]; break; case "SEVEN of DIAMONDS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[19]; break; case "EIGHT of DIAMONDS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[20]; break; case "NINE of DIAMONDS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[21]; break; case "TEN of DIAMONDS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[22]; break; case "JACK of DIAMONDS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[23]; break; case "QUEEN of DIAMONDS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[24]; break; case "KING of DIAMONDS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[25]; break; case "ACE of HEARTS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[26]; break; case "TWO of HEARTS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[27]; break; case "THREE of HEARTS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[28]; break; case "FOUR of HEARTS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[29]; break; case "FIVE of HEARTS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[30]; break; case "SIX of HEARTS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[31]; break; case "SEVEN of HEARTS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[32]; break; case "EIGHT of HEARTS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[33]; break; case "NINE of HEARTS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[34]; break; case "TEN of HEARTS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[35]; break; case "JACK of HEARTS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[36]; break; case "QUEEN of HEARTS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[37]; break; case "KING of HEARTS": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[38]; break; case "ACE of SPADES": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[39]; break; case "TWO of SPADES": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[40]; break; case "THREE of SPADES": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[41]; break; case "FOUR of SPADES": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[42]; break; case "FIVE of SPADES": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[43]; break; case "SIX of SPADES": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[44]; break; case "SEVEN of SPADES": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[45]; break; case "EIGHT of SPADES": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[46]; break; case "NINE of SPADES": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[47]; break; case "TEN of SPADES": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[48]; break; case "JACK of SPADES": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[49]; break; case "QUEEN of SPADES": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[50]; break; case "KING of SPADES": _card.GetComponent <Renderer>().material.mainTexture = cardTextures[51]; break; } #endregion return(_card); }
private string GetSuit() { Array values = Enum.GetValues(typeof(Suits)); Suits suit = (Suits) values.GetValue(random.Next(values.Length)); return suit.ToString(); }
public override string ToString() { // This was created to get the results out to the page relatively // quickly. Again, this was only done an quick programming exercise. StringBuilder printableHand = new StringBuilder(); printableHand.Append("<h4>You were dealt the following cards: "); string separator = ""; // Need to iterate through the hand and generate a string for output of the hand foreach (string Card in pokerHand) { // Not the most efficient way to handle something like this, // but given the limited time this was supposed to take // the simplest way to handle this was to just user a series of // if else statements, otherwise the replacement of "s" would affect // every card option as they all have the letter s in them. string printCard = Card; if (printCard.Contains("c")) { printCard = printCard.Replace("c", "<span style='color: black;'>♣</span>"); } else if (printCard.Contains("d")) { printCard = printCard.Replace("d", "<span style='color: red;'>♦</span>"); } else if (printCard.Contains("h")) { printCard = printCard.Replace("h", "<span style='color: red;'>♥</span>"); } else if (printCard.Contains("s")) { printCard = printCard.Replace("s", "<span style='color: black;'>♠</span>"); } printableHand.Append(separator + printCard); separator = " "; } printableHand.AppendLine("</h4>"); printableHand.Append("<h4>The rank of your hand was determined to be: "); // Just an attempt to give it some english sounding phrasing switch (PokerHandRank) { case HandRanks.RoyalFlush: printableHand.Append("Royal Flush in the suit of " + pokerHandSuit.ToString() + ""); break; case HandRanks.StraightFlush: printableHand.Append(pokerHandPrimaryCard.ToString() + "-high Straight Flush in the suit of " + pokerHandSuit.ToString() + ""); break; case HandRanks.FourOfaKind: printableHand.Append("Four of a Kind " + pokerHandPrimaryCard.ToString() + "s"); break; case HandRanks.FullHouse: printableHand.Append("Full House " + pokerHandPrimaryCard.ToString() + "s and " + pokerHandSecondaryCard.ToString() + "s"); break; case HandRanks.Flush: printableHand.Append("Flush in the suit of " + pokerHandSuit.ToString() + ""); break; case HandRanks.Straight: printableHand.Append(pokerHandPrimaryCard.ToString() + "-high Straight"); break; case HandRanks.ThreeOfaKind: printableHand.Append("Three of a Kind " + pokerHandPrimaryCard.ToString() + "s"); break; case HandRanks.TwoPairs: printableHand.Append("Two Pairs " + pokerHandPrimaryCard.ToString() + "s and " + pokerHandSecondaryCard.ToString() + "s"); break; case HandRanks.OnePair: printableHand.Append("One Pair of " + pokerHandPrimaryCard.ToString() + "s"); break; case HandRanks.HighCard: printableHand.Append(pokerHandPrimaryCard.ToString() + "-high Random Cards"); break; } printableHand.AppendLine("</h4>"); return(printableHand.ToString()); }
public Card(Type _rank, Suits _suit) { Rank = _rank; Suit = _suit; Name = (_rank.ToString() + " of " + _suit.ToString()); }
public String GetSuitasString() { return(CardSuit.ToString()); }
public Card(Suits suit, Ranks rank) { Suit = suit.ToString(); Rank = rank; Value = (int)rank; }