-
Notifications
You must be signed in to change notification settings - Fork 1
/
Player.cs
88 lines (74 loc) · 2.71 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace Monopoly
{
public class Player
{
private int mID;
private int mMoney;
private int mPosition;
private int mJailFreeCards;
private Boolean mIsJailed;
private int mRailroads;
private int mUtilities;
public Player(int id)
{
this.Money = 1500;
this.ID = id;
this.Position = 1;
this.JailFreeCards = 0;
this.Railroads = 0;
this.Utilities = 0;
this.OwnedProperties = new List<Tiles.Property>();
this.GameID = this.ID + 1;
this.Lost = false;
}//Player
//PROPERTIES
public int ID { get { return mID; } private set { mID = value; } } //represents GameState.Players array index
public int Money { get { return mMoney; } set { mMoney = value; } }
public int JailFreeCards { get { return mJailFreeCards; } set { mJailFreeCards = value; } }
public int Railroads { get { return mRailroads; } set { mRailroads = value; } }
public int Utilities { get { return mUtilities; } set { mUtilities = value; } }
public Boolean IsJailed { get { return mIsJailed; } set { mIsJailed = value; } }
public List<Tiles.Property> OwnedProperties { get; private set; }
public int GameID { get; private set; } //represents player number as it appears to user
public bool Lost { get; set; }
public int Position //between 1 and 40
{
get { return mPosition; }
set
{
if (value > 40)
{
UI ui = new UI();
mPosition = value - 40;
ui.UIDebug("Player position " + value + " is greater than 40. Position set to " + (value - 40));
}
else
{
mPosition = value;
}//ifelse
}//set
}//Position
//METHODS
public String PropsToString()
{
String result = String.Empty;
foreach (Tiles.Property p in OwnedProperties)
{
result += p.Name + Environment.NewLine;
}//foreach
return result;
}//PropsString
public override string ToString()
{
String result;
result = String.Format("ID: {0}, Position: {1}, Money: {2}, Jailed: {3}, JailFreeCards: {4}", this.ID, this.Position, this.Money, this.IsJailed, this.JailFreeCards);
return result;
}//ToString()
}//Player
}