-
Notifications
You must be signed in to change notification settings - Fork 1
/
player.cs
191 lines (165 loc) · 4.36 KB
/
player.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
using System;
using System.Collections.Generic;
using System.Text;
namespace Cards
{
[Serializable]
public class player
{
private Hand _hand = new Hand();
private int _id = -1;
private bool isHuman = false;
private int _totalBid = 0;
private string _name = "";
private int _totalTrick = 0;
private float _totalScore = 0;
public float TotalScore
{
get { return _totalScore; }
set { _totalScore = value; }
}
public int TotalTrick
{
get { return _totalTrick; }
set { _totalTrick = value; }
}
public bool _activePlayer = false;
private int _positionX= 0;
private int _positionY = 0;
/// <summary>
/// Player's Y coordinate on the screen
/// </summary>
public int PositionY
{
get { return _positionY; }
set { _positionY = value; }
}
/// <summary>
/// Player X coordinate on the screen
/// </summary>
public int PositionX
{
set
{
_positionX = value;
}
get
{
return _positionX;
}
}
/// <summary>
/// sets player as active player ( its his turn to play)
/// </summary>
public bool IsActivePlayer
{
set
{
_activePlayer = value;
}
get
{
return _activePlayer;
}
}
/// <summary>
/// sets or gets Total number of bid the player made in a round
/// </summary>
public int TotalBid
{
set
{
_totalBid = value;
}
get
{
return _totalBid;
}
}
/// <summary>
/// sets or gets player Name
/// </summary>
public string Name
{
set
{
_name = value;
}
get
{
return _name.Substring(0, Math.Min(_name.Length, 10)); // if name is greater than 10 trucncate it
}
}
/// <summary>
/// sets or gets the current Hand of the player
/// </summary>
public Hand Hand
{
get { return _hand; }
set { _hand = value; }
}
/// <summary>
/// sets or gets the ID of the player
/// </summary>
public int ID
{
get { return _id; }
set { _id = value;}
}
/// <summary>
/// gets or sets if player is Human or AI ( not useful )
/// Because there is class called AIPLAYER AND HUMANPLAYER
/// </summary>
public bool IsHuman
{
get
{
return isHuman;
}
set
{
isHuman = value;
}
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="id">Player ID</param>
/// <param name="isHuman">isHuman or not</param>
public player(int id,bool isHuman)
{
// Hand = hand;
ID = id;
IsHuman = isHuman;
}
/// <summary>
/// This method is overloaded by subclass to initialize the Name of the player
/// </summary>
public virtual void InitializeName(){}
/// <summary>
/// Must be overridden by sub class to implement the bidding function i.e AI and Human
///
/// </summary>
/// <param name="gData">GameData Structure</param>
/// <returns></returns>
public virtual int Bid(GameData gData) { return 0; }
/// <summary>
/// Must be overridden by subclass
/// </summary>
/// <param name="gameData">GameData structure</param>
/// <returns></returns>
public virtual SpadesCard makeMove(GameData gameData)
{
return null;
}
/// <summary>
/// Reset Score, Bid and Trick of player
/// </summary>
public void ResetPlayerData()
{
TotalBid = 0;
TotalScore = 0;
TotalTrick = 0;
}
}
}