-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.cs
64 lines (59 loc) · 1.74 KB
/
Card.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Drawing;
namespace Apophenia
{
public enum Suit { Trumps, Swords, Wands, Coins, Cups };
public enum Rank
{
Fool, Magician, HighPriestess, Empress, Emperor, Hierophant, Lovers, Chariot, Strength, Hermit, WheelOfFortune, Justice,
HangedMan, Death, Temperance, Devil, Tower, Star, Moon, Sun, Judgment, World,
Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Page, Knight, Queen, King
};
public enum Rotation { Zero, Ninety, OneEighty, TwoSeventy };
public class Card
{
public Suit Suit { get; private set; }
public Rank Rank { get; private set; }
public Bitmap Front { get; private set; }
public Bitmap Back { get; private set; }
public Bitmap FrontOriginal { get; private set; }
public Bitmap BackOriginal { get; private set; }
public bool Flipped { get; set; }
public Rotation Rotation { get; private set; }
public Card(string frontFilename, string backFilename)
{
Front = new Bitmap(frontFilename);
Back = new Bitmap(backFilename);
FrontOriginal = (Bitmap)Front.Clone();
BackOriginal = (Bitmap)Back.Clone();
}
public void RotateRight()
{
switch (Rotation)
{
case Rotation.Zero:
Rotation = Rotation.Ninety;
break;
case Rotation.Ninety:
Rotation = Rotation.OneEighty;
break;
case Rotation.OneEighty:
Rotation = Rotation.TwoSeventy;
break;
case Rotation.TwoSeventy:
Rotation = Rotation.Zero;
break;
}
Front.RotateFlip(RotateFlipType.Rotate90FlipNone);
Back.RotateFlip(RotateFlipType.Rotate90FlipNone);
}
public override string ToString()
{
if (Suit == Suit.Trumps)
{
return Enum.GetName(typeof(Rank), Rank);
}
return Enum.GetName(typeof(Rank), Rank) + " of " + Enum.GetName(typeof(Suit), Suit);
}
}
}