-
Notifications
You must be signed in to change notification settings - Fork 0
/
uTile.pas
197 lines (167 loc) · 4.56 KB
/
uTile.pas
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
192
193
194
195
196
197
unit uTile;
interface
uses
SysUtils, Dialogs, Classes, types;
type
TTile = class
protected
FID, FCost:integer;
FName:string;
FRentPrices:array[0..5] of integer;
FIsProperty, FSpecialCase, FOwned, FMortgaged:boolean;
FMortgagePrice, FBuildingPrice, FOwnedBy, FProperties:integer;
function GetID:integer;
function GetName:string;
function GetCost:integer;
function IsSpecialCase:boolean;
function GetMortgagePrice:integer;
function GetBuildingPrice:integer;
function GetOwned:boolean;
procedure SetOwned(b:boolean);
function GetOwnedBy:integer;
procedure SetOwnedBy(p:integer);
function IsMortgaged:boolean;
procedure SetMortgaged(m:boolean);
public
constructor Create(tileinfo:TStringDynArray);
//Property which enabled interaction with the field FID
property ID:integer read GetID;
//Property which enabled interaction with the field FName
property Name:string read GetName;
//Property which enabled interaction with the field FCost
property cost:integer read GetCost;
//Retunrs the value in FIsProperty
function IsProperty:boolean;
//Property which enabled interaction with the field FSpecialCase
property SpecialCase:boolean read IsSpecialCase;
//Property which enabled interaction with the field FMortgagePrice
property MortgagePrice:integer read GetMortgagePrice;
//Property which enabled interaction with the field FBuildingPrice
property BuildingPrice:integer read GetBuildingPrice;
//Property which enabled interaction with the field FOwned
property owned:boolean read GetOwned write SetOwned;
//Property which enabled interaction with the field FOwnedBy
property OwnedBy:integer read GetOwnedBy write SetOwnedBy;
//Property which enabled interaction with the field FMortgaged
property Mortgaged:boolean read IsMortgaged write SetMortgaged;
//Increments the number of houses/hotels as FProperties by 1
procedure IncProperties;
//Returns the number of houses/hotels as FProperties
function GetProperties:integer;
//Returns the rent expected for landing on that tile depending on the type and the
//number of houses on it
function GetRent:integer;
end;
implementation
{ TTile }
constructor TTile.Create(tileinfo:TStringDynArray);
var
i : integer;
begin
Fid := strtoint(tileinfo[0]);
Fname := tileinfo[2];
if tileinfo[1] = 'True' then
begin
FisProperty := True;
FCost := strtoint(tileinfo[3]);
if tileinfo[4] = 'True' then
begin
FSpecialcase := True;
end
else
begin
for i := 0 to 5 do
begin
FRentPrices[i] := strtoint(tileinfo[i+5]);
end;
Fbuildingprice := strtoint(tileinfo[11]);
end;
Fmortgageprice := cost div 2;
end
else
begin
FisProperty := False;
end;
owned := False;
ownedby := -1;
FProperties := 0;
mortgaged := False;
if Fid = 0 then
begin
Fisproperty := False;
end;
end;
function TTile.GetBuildingPrice: integer;
begin
result := FBuildingPrice;
end;
function TTile.GetCost: integer;
begin
result := FCost;
end;
function TTile.GetID: integer;
begin
result := FID;
end;
function TTile.GetMortgagePrice: integer;
begin
result := FMortgagePrice;
end;
function TTile.GetName: string;
begin
result := Fname;
end;
function TTile.GetOwned: boolean;
begin
result := FOwned;
end;
function TTile.GetOwnedBy: integer;
begin
result := FOwnedBy;
end;
function TTile.GetProperties:integer;
begin
result := FProperties;
end;
function TTile.GetRent: integer;
begin
result := FRentPrices[FProperties];
end;
procedure TTile.IncProperties;
begin
inc(FProperties);
try
FMortgageprice := FMortgageprice + round(0.5 * FBuildingprice);
except
On E: EInvalidOp do
begin
FMortgagePrice := FMortgagePrice + (FBuildingPrice div 2);
end;
end;
end;
function TTile.IsMortgaged: boolean;
begin
result := FMortgaged;
end;
function TTile.IsProperty: boolean;
begin
result := FIsProperty;
end;
function TTile.IsSpecialCase: boolean;
begin
result := FSpecialCase;
end;
procedure TTile.SetMortgaged(m: boolean);
begin
FMortgaged := m;
if m = True then FProperties := 0
end;
procedure TTile.SetOwned(b: boolean);
begin
FOwned := b;
end;
procedure TTile.SetOwnedBy(p: integer);
begin
FOwnedBy := p;
end;
end.