Fix mamer crash on listmanagers command
[capablanca.git] / lasker-2.2.3 / bots / mamer / Tourney.hh
1 //--------------------------------------------------------------------------
2 // Tourney.hh - Class header for the Tourney class
3 //
4 // Matthew E. Moses & Michael A. Long
5 //
6 // $Revision: 1.11 $
7 // $Date: 1998/09/10 19:58:41 $
8 //
9 // $Author: mlong $
10 // $Locker:  $
11 //
12 //--------------------------------------------------------------------------
13
14 #ifndef _TOURNEY_
15 #define _TOURNEY_
16
17 #define log22(x) (log(x)/log(2))
18
19 #include <fstream>
20 #include <iostream>
21
22 extern "C" {
23 #include <sys/param.h>
24 #include <sys/types.h>
25
26 #include <ctype.h>
27 #include <errno.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <strings.h>
31 #include <sys/stat.h>
32
33 #include <time.h>
34 #include <unistd.h>
35 #include <math.h>
36 }
37
38 #include "config.h"
39 #include "link.hh"
40 #include "linklist.hh"
41 #include "User.hh"
42 #include "TourneyParameters.hh"
43 #include "TourneyPlayers.hh"
44 #include "Game.hh"
45 #include "Storage.hh"
46
47 class Tourney : public Link {
48  public:
49   Tourney();
50   Tourney(int, User *, TourneyParameters *);
51   Tourney(int, User *, TourneyParameters *, int, int, char, char, int);
52   Tourney(int, User *, TourneyParameters *, int, int, char, char, int, char);
53   ~Tourney();
54
55   void InitTourney(int, User *, int, int, char, char, int, char, int, int);
56
57   int intcmp(int, int);
58
59   void TellThemWhoTheyPlay(void);
60
61   int IsTourney(int);
62   short IsNotNew(void);
63   short IsNotClosed(void);
64   int IsPaused(void);
65   int Open(void);
66   void CloseAndStart(void);
67   int GetStatus(void);
68   void EndTourney();
69   void SetPause(int);
70
71   void Announce(void);
72
73   int AddPlayer(char *, int, float);
74   int RemovePlayer(char *);
75   void SetVariable(int, int);
76   void SetVariable(int, char *);
77   char *GetWild(int);
78   void CalculateAverage();
79
80   void SortPlayers();
81   int GetSortValueCount(double);
82   Player *GetSortPlayer(char *);
83   Player *GetSortPlayer(int);
84
85   TourneyPlayers *GetPlayer(char *);
86   int GetPlayerCount();
87   int GetVariant();
88   int GetRound();
89   int GetRoundsRemaining();
90   float GetAverageRating();
91
92   int MakeAssignments();
93   void SetOffsets();
94   void SetPairingScores(TourneyPlayers *);
95   TourneyPlayers *FindBestOpponent(TourneyPlayers *);
96   int PairPlayers(TourneyPlayers *, TourneyPlayers *);
97   void UnPairPlayer(TourneyPlayers *);
98   void AssignColors(TourneyPlayers *, TourneyPlayers *);
99   int SetGameResult(char *, char *, int);
100
101   long GetStartDate();
102   long GetEndDate();
103   void SetEndDate();
104   void SetPersist(int);
105   int GetPersist();
106   
107   int PopLastPairedPlayer();
108   void ClearPairedPlayers();
109
110   void PrintPotentialLists();
111
112  public:
113   int number;
114   long lastCshouted;
115
116   LinkList<TourneyPlayers> playerList;
117   LinkList<Game> gameList;
118   LinkList<Player> sortList;
119   LinkList<Storage> pairedPlayers;
120
121   TourneyParameters params;
122
123   char manager[NAMELEN];
124   int  managerLevel;
125
126  private:
127   int persist;
128   time_t startDate;
129   time_t endDate;
130
131   int status;
132   int paused;
133
134   float averageRating;
135
136   int currentRound;
137 };
138
139 #endif
140
141 //---------------------------------------------------------
142 // $Log: Tourney.hh,v $
143 // Revision 1.11  1998/09/10 19:58:41  mlong
144 // lots of little bug fixes and a few new features.
145 //
146 // Revision 1.10  1998/04/29 15:24:07  mlong
147 // prepairing for the move to daimi
148 // new sorting routine.
149 //
150 // Revision 1.9  1998/04/18 18:46:31  mlong
151 // fixed delete bug and
152 // added delete tourney function
153 //
154 // Revision 1.8  1998/02/12 18:44:25  mlong
155 // *** empty log message ***
156 //
157 // Revision 1.7  1997/10/28 21:03:48  mlong
158 // *** empty log message ***
159 //
160 // Revision 1.6  1997/10/23 19:56:44  mlong
161 // *** empty log message ***
162 //
163 // Revision 1.5  1997/10/23 19:37:22  chess
164 // lots of new stuff
165 //
166 // Revision 1.4  1997/05/15 18:29:12  chess
167 //  added pending and TourneyPlayers support
168 // added HandleGetPlayerInfo & HandleGetGameInfo
169 //
170 // Revision 1.3  1997/05/02 23:55:18  chess
171 // added TourneyParameters class include
172 //
173 // Revision 1.2  1996/10/01 20:14:43  moses
174 // added methods
175 //
176 // Revision 1.1  1996/09/30  20:52:48  moses
177 // Initial revision
178 //
179 //--------------------------------------------------------------------------