Check in modified mamer
[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.h>
20 #include <iostream.h>
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 Open(void);
65   void CloseAndStart(void);
66   int GetStatus(void);
67   void EndTourney();
68
69   void Announce(void);
70
71   int AddPlayer(char *, int, float);
72   int RemovePlayer(char *);
73   void SetVariable(int, int);
74   void SetVariable(int, char *);
75   char *GetWild(int);
76   void CalculateAverage();
77
78   void SortPlayers();
79   int GetSortValueCount(double);
80   Player *GetSortPlayer(char *);
81   Player *GetSortPlayer(int);
82
83   TourneyPlayers *GetPlayer(char *);
84   int GetPlayerCount();
85   int GetVariant();
86   int GetRound();
87   int GetRoundsRemaining();
88   float GetAverageRating();
89
90   int MakeAssignments();
91   void SetOffsets();
92   void SetPairingScores(TourneyPlayers *);
93   TourneyPlayers *FindBestOpponent(TourneyPlayers *);
94   int PairPlayers(TourneyPlayers *, TourneyPlayers *);
95   void UnPairPlayer(TourneyPlayers *);
96   void AssignColors(TourneyPlayers *, TourneyPlayers *);
97   int SetGameResult(char *, char *, int);
98
99   long GetStartDate();
100   long GetEndDate();
101   void SetEndDate();
102   void SetPersist(int);
103   int GetPersist();
104   
105   int PopLastPairedPlayer();
106   void ClearPairedPlayers();
107
108   void PrintPotentialLists();
109
110  public:
111   int number;
112   long lastCshouted;
113
114   LinkList<TourneyPlayers> playerList;
115   LinkList<Game> gameList;
116   LinkList<Player> sortList;
117   LinkList<Storage> pairedPlayers;
118
119   TourneyParameters params;
120
121   char manager[NAMELEN];
122   int  managerLevel;
123
124  private:
125   int persist;
126   time_t startDate;
127   time_t endDate;
128
129   int status;
130
131   float averageRating;
132
133   int currentRound;
134 };
135
136 #endif
137
138 //---------------------------------------------------------
139 // $Log: Tourney.hh,v $
140 // Revision 1.11  1998/09/10 19:58:41  mlong
141 // lots of little bug fixes and a few new features.
142 //
143 // Revision 1.10  1998/04/29 15:24:07  mlong
144 // prepairing for the move to daimi
145 // new sorting routine.
146 //
147 // Revision 1.9  1998/04/18 18:46:31  mlong
148 // fixed delete bug and
149 // added delete tourney function
150 //
151 // Revision 1.8  1998/02/12 18:44:25  mlong
152 // *** empty log message ***
153 //
154 // Revision 1.7  1997/10/28 21:03:48  mlong
155 // *** empty log message ***
156 //
157 // Revision 1.6  1997/10/23 19:56:44  mlong
158 // *** empty log message ***
159 //
160 // Revision 1.5  1997/10/23 19:37:22  chess
161 // lots of new stuff
162 //
163 // Revision 1.4  1997/05/15 18:29:12  chess
164 //  added pending and TourneyPlayers support
165 // added HandleGetPlayerInfo & HandleGetGameInfo
166 //
167 // Revision 1.3  1997/05/02 23:55:18  chess
168 // added TourneyParameters class include
169 //
170 // Revision 1.2  1996/10/01 20:14:43  moses
171 // added methods
172 //
173 // Revision 1.1  1996/09/30  20:52:48  moses
174 // Initial revision
175 //
176 //--------------------------------------------------------------------------