imported hobo11 data... this is a fragment of vmware svn, whatever I had
[tues-crep.git] / sites / hobo11.nerdland.org / coursework / 20070 / Blackjack / Card.cs
blob264eaadbb76c318a9fe6091d521d7bc9ed6d41e9
1 using System;
2 using System.Reflection;
3 using System.Resources;
4 using System.Collections;
5 using System.Globalization;
7 namespace BlackJack
9 /// <summary>
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
13 /// same value as 10.
14 /// </summary>
15 public class Card : ICloneable
17 private CardType cardType;
18 private Suits cardSuit;
19 private int value;
20 private int trueValue;
22 public enum CardType
24 Ace = 0,
25 Two = 1,
26 Three = 2,
27 Four = 3,
28 Five = 4,
29 Six = 5,
30 Seven = 6,
31 Eight = 7,
32 Nine = 8,
33 Ten = 9,
34 Jack = 10,
35 Queen = 11,
36 King = 12
39 public enum Suits
41 Clubs = 0,
42 Diamonds = 1,
43 Hearts = 2,
44 Spades = 3
47 /// <summary>
48 /// Method to instantiate a new Card object.
49 /// </summary>
50 public Card( CardType type, Suits suit )
52 cardSuit = suit;
53 cardType = type;
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;
59 if( trueValue > 9 )
60 trueValue = 9;
62 //cardSize = image.PhysicalDimension;
63 //cardSpacing.Width = cardSize.Width / 5;
64 //cardSpacing.Height = cardSize.Height / 7;
67 /// <summary>
68 /// This method was removed to make way for Cocoa.
69 /// </summary>
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 );
94 public int Value
96 get { return value; }
99 public CardType FaceValue
101 get { return cardType; }
104 public int TrueValue
106 get { return trueValue; }
109 public Suits Suit
111 get { return cardSuit; }
114 // ICloneable
115 Object ICloneable.Clone()
117 return new Card(cardType, cardSuit);
120 public Card Clone()
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;
136 static Resources()
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);
157 } // Resources