-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspidertypes.pas
More file actions
115 lines (98 loc) · 2.49 KB
/
Copy pathspidertypes.pas
File metadata and controls
115 lines (98 loc) · 2.49 KB
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
unit SpiderTypes;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, fpjson, jsonparser;
const
NUM_OF_DECKS = 2;
CARDS_PER_DECK = 52;
TOTAL_CARDS = 104;
USERS_FILE = 'userdata.json';
type
TSuit = (Hearts, Diamonds, Clubs, Spades);
TRank = (Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King);
TSpiderDifficulty = (sdOneSuit, sdTwoSuit, sdFourSuit);
TCard = record
Rank: TRank;
Suit: TSuit;
FaceUp: Boolean;
Value: Integer;
end;
TDeck = array[0..TOTAL_CARDS - 1] of TCard;
TPile = array of TCard; // A tableau pile
TTableau = array[0..9] of TPile; // 10 piles
TSpiderLogger = record
Active: Boolean;
F: Text;
end;
TSpiderGameState = record
Tableau: TTableau;
Stock: array[0..49] of TCard;
StockPos: Integer;
CompletedRuns: Integer;
end;
TSpiderStats = record
GamesPlayed: integer;
GamesWon: Integer;
GamesLost: Integer;
GamesDrawn: Integer;
WinPercentage: Integer;
HighScore: Integer;
AverageScorePerGame: Integer; { #todo : Need to a new field to track total points from all games }
BestTime: TDateTime;
AverageTimePerGame: TDateTime;
TotalMoves: Integer;
TotalStacks: Integer;
AverageStacksPerGame: Integer;
OneSuitPlayed: Integer;
OneSuitWon: Integer;
TwoSuitPlayed: Integer;
TwoSuitWon: Integer;
FourSuitPlayed: Integer;
FourSuitWon: Integer;
LastDifficulty: Integer;
HasSavedGame: Boolean;
end;
TSpiderGame = record
Tableau: TTableau;
Stock: array[0..49] of TCard;
StockPos: Integer;
CompletedRuns: Integer;
Logger: TSpiderLogger;
Stats: TSpiderStats;
MovesThisGame: Integer; { #todo : What is this for? Really needed? }
Difficulty: TSpiderDifficulty;
UndoStack: array of TSpiderGameState;
RedoStack: array of TSpiderGameState;
end;
TUserProfile = record
UserName: string[32];
Stats: TSpiderStats;
end;
TUserList = record
Count: Integer;
Players: array of TUserProfile;
end;
var
JSONData: TJSONData;
JSONObject: TJSONObject;
JSONArray: TJSONArray;
JSONFileName: string;
FileStream: TFileStream;
ActiveUserIndex: Integer;
Users: TUserList;
G: TSpiderGame;
F: Text;
cardStr: string;
cmd: string;
FromPile, ToPile, StartIndex: Integer;
ViewMenu: Boolean;
ViewStatsMenu: Boolean;
ViewUtilMenu: Boolean;
ViewPlayersMenu: Boolean;
Stats: TSpiderStats;
Diff: TSpiderDifficulty;
intDiff: Integer;
Won: Boolean;
implementation
end.