2 using System
.Reflection
;
3 using System
.Resources
;
4 using System
.Collections
;
5 using System
.Globalization
;
10 /// Cards have identity that is composed of a suit and a value. Cards
11 /// also have a face point value which varies by game; in BlackJack,
12 /// the Ace has two point values, 11 or 1. All Face Cards have the
15 public class Card
: ICloneable
17 private CardType cardType
;
18 private Suits cardSuit
;
20 private int trueValue
;
48 /// Method to instantiate a new Card object.
50 public Card( CardType type
, Suits suit
)
54 value = ((int)suit
* 13) + (int)cardType
+ 1;
56 // Figure out how these Resources are loaded, and duplicate for Cocoa if necessary
57 //image = Resources.GetImage(value);
58 trueValue
= (int)cardType
;
62 //cardSize = image.PhysicalDimension;
63 //cardSpacing.Width = cardSize.Width / 5;
64 //cardSpacing.Height = cardSize.Height / 7;
68 /// This method was removed to make way for Cocoa.
70 public void Draw( bool show
, bool dim
, bool doubledownCard
)
72 // float opaqueness = dim ? .5F : 1;
73 // float rotationAngle = doubledownCard ? 45 : 0;
74 // float[][] ptsArray ={ new float[] {1, 0, 0, 0, 0},
75 // new float[] {0, 1, 0, 0, 0},
76 // new float[] {0, 0, 1, 0, 0},
77 // new float[] {0, 0, 0, opaqueness, 0},
78 // new float[] {0, 0, 0, 0, 1}};
79 // ColorMatrix clrMatrix = new ColorMatrix(ptsArray);
80 // ImageAttributes imgAttributes = new ImageAttributes();
81 // imgAttributes.SetColorMatrix(clrMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
83 // GraphicsState previousState = drawingSurface.Save();
85 // Point Pcenter = new Point( location.X + image.Width / 2, location.Y + image.Height / 2 );
86 // drawingSurface.TranslateTransform( Pcenter.X, Pcenter.Y );
87 // drawingSurface.RotateTransform( rotationAngle );
89 // // drawingSurface.DrawImage(shadow, new Rectangle( -curImage.Width/2, -curImage.Height/2 , shadow.Width, shadow.Height ), 0, 0, shadow.Width, shadow.Height, GraphicsUnit.Pixel, imgAttributesShadow );
90 // drawingSurface.DrawImage( show ? image : Shoe.BackImage, new Rectangle( -image.Width/2, -image.Height/2 , image.Width, image.Height ), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imgAttributes );
92 // drawingSurface.Restore( previousState );
99 public CardType FaceValue
101 get { return cardType; }
106 get { return trueValue; }
111 get { return cardSuit; }
115 Object ICloneable
.Clone()
117 return new Card(cardType
, cardSuit
);
122 return new Card(cardType
, cardSuit
);
125 public static Card
Clone(Card card
)
127 return new Card(card
.FaceValue
, card
.Suit
);
131 // A shared reference to access images and other resources.
132 internal abstract class Resources
134 private static ResourceManager images
;
138 images
= new ResourceManager("Blackjack.Images", Assembly
.GetExecutingAssembly());
141 public static ResourceManager Images
143 get { return images; }
146 //We also lost Images
147 //public static Image GetImage(int imageId)
149 // return (Image)images.GetObject(imageId.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture );
152 //.. by name and int both!
153 //public static Image GetImage(string imageId)
155 // return (Image)images.GetObject(imageId, CultureInfo.InvariantCulture);