Scid  4.6.5
crosstab.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////
2 //
3 // FILE: crosstab.h
4 // Crosstable class
5 //
6 // Part of: Scid (Shane's Chess Information Database)
7 // Version: 3.6
8 //
9 // Notice: Copyright (c) 2000-2004 Shane Hudson. All rights reserved.
10 //
11 // Author: Shane Hudson (sgh@users.sourceforge.net)
12 //
13 //////////////////////////////////////////////////////////////////////
14 
15 #ifndef WINCE
16 
17 #ifndef SCID_CROSSTAB_H
18 #define SCID_CROSSTAB_H
19 
20 #include "common.h"
21 #include "date.h"
22 #include "spellchk.h"
23 
24 class DString;
25 
26 const uint CROSSTABLE_MaxPlayers = 500; // Max. number of players.
27 const uint CROSSTABLE_MaxRounds = 60; // Max. number of Swiss event rounds.
28 
29 struct clashT
30 {
33  uint opponent; // For swiss crosstables.
37 };
38 
40 {
42 };
43 
45 {
47 };
48 
50 {
53 };
54 
56 {
58  char * name;
60  uint score; // Score, stored as 2 pts per win, 1 pt per draw.
62  uint tiebreak; // Sonneborn-Berger tiebreak for all-play-all,
63  // or Bucholz tiebreak for Swiss.
66  uint oppEloScore; // score against Elo opponents
67  clashT * firstClash [CROSSTABLE_MaxPlayers];
70  clashT * roundClash [CROSSTABLE_MaxRounds];
71  char title [8];
72  char country [8];
75  bool printed;
76 };
77 
78 
80 {
81  private:
82 
83  uint PlayerCount;
84  uint GameCount;
85  uint MaxClashes; // Maximum games between any two players
86  uint MaxRound;
87  uint ResultCount [NUM_RESULT_TYPES];
88  dateT FirstDate;
89 
90  bool ShowTitles;
91  bool ShowElos;
92  bool ShowCountries;
93  bool ShowTallies;
94  bool ShowAges;
95  bool ShowTiebreaks;
96  bool SwissColors; // If true, show colors in Swiss tables.
97  bool SeparateScoreGroups;
98  char DecimalPointChar;
99  bool APAColumnNums; // If true, print numbers instead of partial
100  // names above all-play-all table columns.
101 
102  crosstableOutputT OutputFormat;
103  crosstableSortT SortOption;
104  bool ThreeWin;
105 
106  playerDataT * PlayerData [CROSSTABLE_MaxPlayers];
107 
108  // The following fields are set in PrintTable() and then used in
109  // each of the private Print* methods:
110  bool PrintTitles;
111  bool PrintRatings;
112  bool PrintCountries;
113  bool PrintTallies;
114  bool PrintAges;
115  bool PrintTiebreaks;
116  const char * StartTable;
117  const char * EndTable;
118  const char * StartRow;
119  const char * EndRow;
120  const char * NewLine;
121  const char * BlankRowLine;
122  const char * StartCol;
123  const char * EndCol;
124  const char * StartRightCol;
125  const char * EndRightCol;
126  const char * StartBoldCol;
127  const char * EndBoldCol;
128  uint LongestNameLen;
129  uint LineWidth;
130  uint PlayerNumWidth;
131  uint SortedIndex [CROSSTABLE_MaxPlayers];
132  uint InvertedIndex [CROSSTABLE_MaxPlayers];
133  uint CurrentGame;
134 
135  void Tiebreaks (crosstableModeT mode);
136 
137  void PrintDashesLine (DString * dstr);
138  void PrintPlayer (DString * dstr, playerDataT * pdata);
139  void PrintPerformance (DString * dstr, playerDataT * pdata);
140  void PrintAllPlayAll (DString * dstr, uint playerLimit);
141  void PrintKnockout (DString * dstr, uint playerLimit);
142  void PrintSwiss (DString * dstr, uint playerLimit);
143 
144  void Init();
145  void Destroy();
146 
147  public:
148  Crosstable() { Init(); }
149  ~Crosstable() { Destroy(); }
150 
151  void SetOutputFormat (crosstableOutputT opt) { OutputFormat = opt; }
152  void SetPlainOutput() { OutputFormat = CROSSTABLE_Plain; }
153  void SetHtmlOutput() { OutputFormat = CROSSTABLE_Html; }
154  void SetHypertextOutput() { OutputFormat = CROSSTABLE_Hypertext; }
155  void SetLaTeXOutput() { OutputFormat = CROSSTABLE_LaTeX; }
156 
157  void SetSortOption (crosstableSortT option) { SortOption = option; }
158  void SetThreeWin (bool threewin) { ThreeWin = threewin; }
159 
160  void SortByName() { SortOption = CROSSTABLE_SortName; }
161  void SortByElo() { SortOption = CROSSTABLE_SortElo; }
162  void SortByScore() { SortOption = CROSSTABLE_SortScore; }
163  void SortByCountry() { SortOption = CROSSTABLE_SortCountry; }
164 
165  void SetAges (bool b) {ShowAges = b; }
166  void SetTitles (bool b) { ShowTitles = b; }
167  void SetElos (bool b) { ShowElos = b; }
168  void SetCountries (bool b) { ShowCountries = b; }
169  void SetTallies (bool b) { ShowTallies = b; }
170  void SetTiebreaks (bool b) { ShowTiebreaks = b; }
171  void SetSwissColors (bool b) { SwissColors = b; }
172  void SetSeparateScoreGroups (bool b) { SeparateScoreGroups = b; }
173  void SetDecimalPointChar (char ch) { DecimalPointChar = ch; }
174  void SetNumberedColumns (bool b) { APAColumnNums = b; }
175 
176  uint NumPlayers() { return PlayerCount; }
177  errorT AddPlayer (idNumberT id, const char * name, eloT elo, const SpellChecker*);
178  errorT AddResult (uint gameNumber, idNumberT white, idNumberT black,
180 
181  crosstableModeT BestMode (void);
182  eloT AvgRating();
183  void PrintTable (DString * dstr, crosstableModeT mode, uint playerLimit, int currentGame);
184 
185  static uint Performance (uint oppAvg, uint percentage);
186  static uint FideCategory (eloT rating);
187  static eloT OpponentElo (eloT player, eloT opponent);
188  static int RatingChange (eloT player, uint oppAvg, uint percentage,
189  uint count);
190 };
191 
192 #endif // #ifndef SCID_CROSSTAB_H
193 
194 #endif // WINCE
const uint CROSSTABLE_MaxPlayers
Definition: crosstab.h:26
uint oppEloScore
Definition: crosstab.h:66
byte resultT
Definition: common.h:183
void SetElos(bool b)
Definition: crosstab.h:167
void SortByElo()
Definition: crosstab.h:161
uint idNumberT
Definition: namebase.h:39
void SetDecimalPointChar(char ch)
Definition: crosstab.h:173
idNumberT id
Definition: crosstab.h:57
const uint CROSSTABLE_MaxRounds
Definition: crosstab.h:27
const uint NUM_RESULT_TYPES
Definition: common.h:182
void SetTiebreaks(bool b)
Definition: crosstab.h:170
void SetSeparateScoreGroups(bool b)
Definition: crosstab.h:172
void SetSwissColors(bool b)
Definition: crosstab.h:171
colorT color
Definition: crosstab.h:34
uint dateT
Definition: common.h:155
~Crosstable()
Definition: crosstab.h:149
crosstableModeT
Definition: crosstab.h:49
names
Definition: tablebase.tcl:260
clashT * next
Definition: crosstab.h:36
uint gameCount
Definition: crosstab.h:61
eloT elo
Definition: crosstab.h:59
void SortByName()
Definition: crosstab.h:160
Crosstable()
Definition: crosstab.h:148
class SpellChecker - name spelling
Definition: spellchk.h:257
uint score
Definition: crosstab.h:60
void SetLaTeXOutput()
Definition: crosstab.h:155
uint oppEloTotal
Definition: crosstab.h:65
void SetNumberedColumns(bool b)
Definition: crosstab.h:174
void SetTallies(bool b)
Definition: crosstab.h:169
void SetTitles(bool b)
Definition: crosstab.h:166
void SetSortOption(crosstableSortT option)
Definition: crosstab.h:157
void SetPlainOutput()
Definition: crosstab.h:152
void SetThreeWin(bool threewin)
Definition: crosstab.h:158
int ageInYears
Definition: crosstab.h:74
void SortByScore()
Definition: crosstab.h:162
crosstableOutputT
Definition: crosstab.h:44
uint32_t uint
Definition: common.h:99
bool printed
Definition: crosstab.h:75
void SetAges(bool b)
Definition: crosstab.h:165
void SetCountries(bool b)
Definition: crosstab.h:168
ushort eloT
Definition: common.h:160
uint gameNum
Definition: crosstab.h:32
dateT birthdate
Definition: crosstab.h:73
char * name
Definition: crosstab.h:58
void SetOutputFormat(crosstableOutputT opt)
Definition: crosstab.h:151
unsigned short errorT
Definition: error.h:20
void SortByCountry()
Definition: crosstab.h:163
uint tiebreak
Definition: crosstab.h:62
void SetHtmlOutput()
Definition: crosstab.h:153
crosstableSortT
Definition: crosstab.h:39
uint round
Definition: crosstab.h:35
byte colorT
Definition: common.h:112
uint oppEloCount
Definition: crosstab.h:64
uint opponent
Definition: crosstab.h:33
uint NumPlayers()
Definition: crosstab.h:176
resultT result
Definition: crosstab.h:31
void SetHypertextOutput()
Definition: crosstab.h:154