/// <summary> /// ToString: Overrides System.Object.ToString() /// </summary> /// <returns>The name of the PlayingCard as a string</returns> public override string ToString() { string cardString; // holds the playing PlayingCard name if (faceUp) { if (myRank == CardRank.Joker) { // set the PlayingCard name string to {Red|Black} Joker if (mySuit == CardSuit.Clubs || mySuit == CardSuit.Spades) { cardString = "Black Joker"; } else { cardString = "Red Joker"; } } //otherwise PlayingCard is face up but not a joker else { cardString = myRank.ToString() + " of " + mySuit.ToString(); } } else { cardString = "Face Down"; } return(cardString); }
public override string ToString() { string cardString; if (faceUp) { //if rank joker if (myRank == CardRank.Joker) { //set card name to redblack joker //if suit black if (mySuit == CardSuit.clubs || mySuit == CardSuit.spades) { cardString = "Black Joker"; } else { cardString = "Red Joker"; } } else { cardString = myRank.ToString() + " of " + mySuit.ToString(); } } else { cardString = "Face Down"; } return(cardString); }
public void Draw() { //draw frame Console.ForegroundColor = frameColor; for (int i = pos.x; i < width + pos.x; i++) { Console.SetCursorPosition(i, pos.y); Console.Write(wallSimbol); Console.SetCursorPosition(i, pos.y + height - 1); Console.Write(wallSimbol); } for (int i = pos.y; i < height + pos.y; i++) { Console.SetCursorPosition(pos.x, i); Console.Write(wallSimbol); Console.SetCursorPosition(pos.x + width - 1, i); Console.Write(wallSimbol); } Console.ForegroundColor = unSelectedFrameColor; //draw rank and type Console.ForegroundColor = cardColor; Console.SetCursorPosition(pos.x + rankPos.x, pos.y + rankPos.y); Console.Write(rank); Console.SetCursorPosition(pos.x + width - rankPos.x - rank.ToString().Length, pos.y + (height - 1) - rankPos.y); Console.Write(rank); Console.SetCursorPosition(pos.x + typePos.x, pos.y + typePos.y); Console.Write(type); Console.ForegroundColor = ConsoleColor.Black; }
/// <summary> /// GetCardImage - retrieves card image from resource library - NOTE NAMING CONVENTIONS /// </summary> /// <returns></returns> public Image GetCardImage() { string imageName; Image cardImage; if (!FaceUp) { imageName = "Back"; } else { imageName = mySuit.ToString() + "_" + myRank.ToString(); } // Get Card Image cardImage = Properties.Resources.ResourceManager.GetObject(imageName) as Image; return(cardImage); }
/// <summary> /// ToString: Overrides System.Object.ToString() /// </summary> /// <returns>the name of the card as a string</returns> public override string ToString() { string cardString; // holds the playing card name. // if the card is face up if (faceUp) { // If the card is a joker if (myRank == CardRank.Joker) { // set the card name string to {Red|BLack} joker // if the suit is black if (mySuit == CardSuit.Clubs || mySuit == CardSuit.Spades) { // set the name string to black joker cardString = "Joker_Black"; } else // the suit must be red { // set the name string to red joker cardString = "Joker_Red"; } } // otherwise, the card is face up but not a joker else { // set the card name string to {Rank} of {Suit} cardString = myRank.ToString() + " of " + mySuit.ToString(); } } // otherwise the card is face down. else { // set the card name to face down cardString = "Face Down"; } // return the appropriate card name string return(cardString); }
/// <summary> /// Returns the corresponding Card Image /// </summary> /// <returns></returns> public Image GetImage() { string url; // the corresponding url for the card // if the card is face up, return it with the name // Rank_L (L being first letter of the suit) if (IsFaceUp) { url = myRank.ToString() + "_" + mySuit.ToString().Substring(0, 1).ToUpper().ToString(); } // otherwise, save the face down card else { url = "gray_back"; } // return the card as an image return(Properties.Resources.ResourceManager.GetObject(url) as Image); }
public override string ToString() { string rankString; var rankValue = (int)CardRank; switch (rankValue) { case 1: case 11: case 12: case 13: rankString = CardRank.ToString(); break; default: rankString = rankValue.ToString(); break; } return(string.Format("{0} {1}", CardSuit.ToString()[0], rankString)); }
/// <summary> /// Generates the string representation of the <see cref="Card"/> /// </summary> /// <returns>A string describing the <see cref="Card"/></returns> public override string ToString() { return($"{CardRank.ToString()} of {CardSuit.ToString()}"); }
private void DrawRank(Position pos, CardRank rank) { WriteAt(rank.ToString(), pos, (Width - rank.ToString().Length) / 2, Height / 2); }
public void PlayerAnnouncesRank(int playerId, CardRank rank) { Console.WriteLine("... and announces {0}", rank.ToString()); System.Threading.Thread.Sleep(sleepTime); }
public static void LoadCardsImages() { cardsImages = new Dictionary <Card, Image>(); string directory = "cards_graphics\\"; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 13; ++j) { CardRank curRank = (CardRank)j; CardSuit curSuit = (CardSuit)i; string fileName = directory + curSuit.ToString().ToLower() + "\\" + curRank.ToString().ToLower() + ".bmp"; try { cardsImages.Add(new Card(curRank, curSuit), new Bitmap(fileName)); } catch (ArgumentException) { throw new FileNotFoundException("File not found", fileName); } } } }