forked from cpe200-158-sec1-0601/OOP_week9
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.cs
99 lines (90 loc) · 3.47 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HILowCard
{
class Game
{
public static void playgame(Player s1, Player s2)
{
int indexofdeck = 0;
int round = 0;
int sum = 0;
deck deck_card = new deck();
deck_card.Deck();
deck_card.Shuffle();
deck_card.DealCard(s1, s2);
Console.WriteLine(" ");
while (indexofdeck != 26)
{
if (card.CardRank(s1.Deck_card[indexofdeck]) < card.CardRank(s2.Deck_card[indexofdeck]))
{
Console.WriteLine(s1._name + " : " + s1.Deck_card[indexofdeck] + " Win " + s2._name + " : " + s2.Deck_card[indexofdeck]);
s1.num_of_card += (2 + (2 * sum));
indexofdeck++;
round = 0;
sum = 0;
}
else if (card.CardRank(s1.Deck_card[indexofdeck]) > card.CardRank(s2.Deck_card[indexofdeck]))
{
Console.WriteLine(s2._name + " : " + s2.Deck_card[indexofdeck] + " Win " + s1._name + " : " + s1.Deck_card[indexofdeck]);
s2.num_of_card += (2 + (2 * sum));
indexofdeck++;
round = 0;
sum = 0;
}
else
{
if (round == 0)
{
Console.WriteLine(s1._name + " : " + s1.Deck_card[indexofdeck] + " Equal " + s2._name + " : " + s2.Deck_card[indexofdeck]);
if (indexofdeck + card.CardRank(s1.Deck_card[indexofdeck]) <= 25)
{
sum = card.CardRank(s1.Deck_card[indexofdeck]);
indexofdeck += sum;
round = 1;
}
else
{
sum = (25 - indexofdeck);
indexofdeck = 25;
round = 1;
}
}
else
{
if (indexofdeck < 25)
{
Console.WriteLine(s1._name + " : " + s1.Deck_card[indexofdeck] + " Equal(again) " + s2._name + " : " + s2.Deck_card[indexofdeck] + "(Shuffle Card)");
round = 0;
indexofdeck -= sum;
sum = 0;
deck_card.Shuffle(s1, indexofdeck);
deck_card.Shuffle(s2, indexofdeck);
}
else
{
indexofdeck++;
}
}
}
}
Console.WriteLine(" ");
if (s1.num_of_card < s2.num_of_card)
{
Console.WriteLine(s1._name + " get " + s1.num_of_card + " cards Win");
}
else if (s2.num_of_card < s1.num_of_card)
{
Console.WriteLine(s2._name + " get " + s2.num_of_card + " cards Win");
}
else
{
Console.WriteLine(s1._name + " and " + s2._name + " get " + s2.num_of_card + " cards Draw");
}
Console.WriteLine(" ");
}
}
}