-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.cs
166 lines (162 loc) · 7.77 KB
/
Game.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
using System;
using System.Collections.Generic;
using System.Text;
namespace battle_of_cards_grupauderzeniowa
{
class Game
{
private Deck deck = new Deck();
private Gambler gambler = new Gambler(250);
public void Run()
{
int ante = 20;
bool anothergame = true;
while(anothergame)
{
// utworzenie potasowanej talii 52 kart
deck.Shuffle();
// utworzenie dwóch "rąk"
List <Card> dealerHand = new List<Card>();
List<Card> playerHand = new List<Card>();
List<Card> twoHAND = new List<Card>();
twoHAND = deck.handDeck();
for (int i = 0; i < 10; i++)
{
if (i<5) dealerHand.Add(twoHAND[i]);
else playerHand.Add(twoHAND[i]);
}
List<Card> dealerHandCover = Turn(dealerHand);
// karta playera uporzadkowana
playerHand.Sort(new CardComparer_Value());
//plansza przed Call ale juz z Ante
bool beforeCall = true;
gambler.SetMoney(gambler.GetMoney()-ante);
DisplayTable.DisplayBoard(dealerHandCover, playerHand, ante, 0, gambler.GetMoney(), beforeCall);
bool setcal = gambler.SetCall();
if (setcal)
{
beforeCall = false;
gambler.SetMoney(gambler.GetMoney()- 2* ante);
DisplayTable.DisplayBoard(dealerHand, playerHand, ante, 2*ante, gambler.GetMoney(), beforeCall);
HandCombination dealer = Analisis.HandAnalizer(dealerHand);
HandCombination player = Analisis.HandAnalizer(playerHand);
// sprawdzenie czy ręka delera kwlifikuje sie do porównania
if (dealer != HandCombination.nothing)
{
Hand handpower = new Hand(dealer);
int outcome = handpower.CompareTo(player);
if (outcome == 1)
{
Console.WriteLine("You lost 60$");
Console.WriteLine("Press any key");
Console.ReadKey();
gambler.SetMoney(gambler.GetMoney() - 3 * ante);
}
if(outcome == -1)
{
Console.WriteLine("You won aggregate money!!!");
Console.WriteLine("Press any key");
int agregate = 1;
string generalhand = player.ToString().Substring(0,2);
if (generalhand == "PO") {agregate = 100;}
if (generalhand == "po") {agregate = 50;}
if (generalhand == "qu") {agregate = 20;}
if (generalhand == "fu") {agregate = 7;}
if (generalhand == "fl") {agregate = 5;}
if (generalhand == "st") {agregate = 4;}
if (generalhand == "tr") {agregate = 3;}
if (generalhand == "dp") {agregate = 2;}
gambler.SetMoney(gambler.GetMoney() + agregate*3*ante +2* ante);
}
if(outcome == 0)
{
Console.WriteLine("draw, get back Call");
Console.WriteLine("Press any key");
Console.ReadKey();
gambler.SetMoney(gambler.GetMoney()+ 2*ante);
}
}
else //dealer: nothing
{
foreach (Card item in dealerHand)
{
if (item.Rank == Ranks.Ace || item.Rank==Ranks.King) //reka kwalifikacyjna
{
Hand handpower = new Hand(dealer);
int outcome = handpower.CompareTo(player);
if (outcome == 1)
{
Console.WriteLine("Dealer won, you lost 60$");
Console.WriteLine("Press any key");
Console.ReadKey();
gambler.SetMoney(gambler.GetMoney() - 3*ante);
break;
}
if(outcome == -1)
{
Console.WriteLine ("You won aggregate money!!!");
Console.WriteLine("Press any key");
Console.ReadKey();
int agregate = 1;
string generalhand = player.ToString().Substring(0,2);
if (generalhand == "PO") {agregate = 100;}
if (generalhand == "po") {agregate = 50;}
if (generalhand == "qu") {agregate = 20;}
if (generalhand == "fu") {agregate = 7;}
if (generalhand == "fl") {agregate = 5;}
if (generalhand == "st") {agregate = 4;}
if (generalhand == "tr") {agregate = 3;}
if (generalhand == "dp") {agregate = 2;}
gambler.SetMoney(gambler.GetMoney() + agregate*3*ante + 3*ante);
break;
}
if(outcome == 0)
{
Console.WriteLine("draw, get back Call");
Console.WriteLine("Press any key");
Console.ReadKey();
gambler.SetMoney(gambler.GetMoney()+2*ante);
break;
}
}
else
{
Console.WriteLine("You get back your Ante & Call plus extra Ante");
Console.WriteLine("Press any key");
Console.ReadKey();
gambler.SetMoney(gambler.GetMoney() + 4 *ante);
break;
}
}
}
}
else
{
Console.Write("Would you like to play? - press Y: ");
string choice2 = Console.ReadLine().ToUpper();
if (choice2 != "Y")
{
anothergame = false;
}
}
//beforeCall = true;
if (gambler.GetMoney()<= 0)
{
anothergame = false;
}
}
Console.WriteLine("End of the Game. You lost all your money");
}
public List<Card> Turn(List<Card> lc)
{
Card backside = new Card(Suits.Clubs, Ranks.King, "\U0001F0A0 ");
List<Card> outcome = new List<Card>();
outcome.Add(lc[0]);
for (int i = 0; i<4; i++)
{
outcome.Add(backside);
}
return outcome;
}
}
}