1 //--------------------------------------------------------------------------
2 // Tourney.cc - Source file for Tourney class
7 // $Date: 2002/07/02 00:02:40 $
12 // $Log: Tourney.cc,v $
13 // Revision 1.12 2002/07/02 00:02:40 tridge
14 // - fixed compile on g++ 2.96
15 // - updated for lasker 'rmatch'
17 // Revision 1.11 1998/09/10 19:57:17 mlong
18 // lots of little bug fixes and a few new features
20 // Revision 1.10 1998/04/29 15:23:19 mlong
21 // prepairing for the move to daimi
22 // new sorting routine.
24 // Revision 1.9 1998/04/18 20:05:14 mlong
27 // Revision 1.8 1998/04/18 18:46:04 mlong
29 // added delete tourney function
31 // Revision 1.4 1997/10/08 21:03:35 chess
32 // preparing for move to oracle machine at eworks.
34 // Revision 1.3 1997/05/15 18:27:53 chess
35 // added pending and TourneyPlayers support
36 // added HandleGetPlayerInfo & HandleGetGameInfo
38 // Revision 1.2 1996/10/01 20:14:43 moses
39 // Added a new method IsTourney
41 // Revision 1.1 1996/09/30 20:52:48 moses
44 //--------------------------------------------------------------------------
46 //static char RCSid[] = "$Id: Tourney.cc,v 1.12 2002/07/02 00:02:40 tridge Exp $";
53 //- Constructor ------------------------------------------------------------
57 Tourney::Tourney(int n,User *u, TourneyParameters *tp) {
58 InitTourney(n, u, tp->time, tp->inc, tp->mode, tp->style, tp->rounds, tp->variant, tp->ratingLow, tp->ratingHigh);
61 Tourney::Tourney(int n, User *u, TourneyParameters *tp, int t, int i, char m, char s, int r) {
62 InitTourney(n, u, t, i, m, s, r, tp->variant, tp->ratingLow, tp->ratingHigh);
65 Tourney::Tourney(int n, User *u, TourneyParameters *tp, int t, int i, char m, char s, int r, char v) {
66 InitTourney(n, u, t, i, m, s, r, v, tp->ratingLow, tp->ratingHigh);
69 void Tourney::InitTourney(int n, User *u, int t, int i, char m, char s, int r, char v, int rl, int rh) {
71 strncpy(manager, u->name, NAMELEN - 1);
72 managerLevel = u->GetManagerLevel();
81 params.ratingLow = rl;
82 params.ratingHigh = rh;
83 params.currentRound = 0;
84 params.maxPlayers = DEFAULT_MAX_PLAYERS;
94 //- Deconstructor ---------------------------------------------------------
99 //- IsTourney -------------------------------------------------------------
100 int Tourney::IsTourney(int tourn) {
105 } //- End of IsTourney
107 //- IsNotNew-------------------------------------------------------------
108 short Tourney::IsNotNew(void) {
114 //- IsNotClosed-------------------------------------------------------------
115 short Tourney::IsNotClosed(void) {
121 //- AddPlayer ----------------------------------------------------------
122 int Tourney::AddPlayer(char *name, int rating, float score) {
123 TourneyPlayers *newPlayer = NULL, *tp = NULL;
124 Player *newSortPlayer = NULL;
126 if (status != OPEN) return 3; // If we are not open then we can't enter the tourney
128 tp = GetPlayer(name);
130 if(tp != NULL) return(2); // if we are already in the tourney we can't enter it again/
132 if(rating >= params.ratingLow && rating <= params.ratingHigh && status == OPEN) {
134 newPlayer = new TourneyPlayers(name, rating, score);
135 newSortPlayer = new Player(name, 0);
137 playerList.Append(newPlayer);
139 gMamer.XServerCom("%s %i %s %s%i%s %s%i %i %s%s", "tell", gMamer.channelNumber, name, "(", rating, ")",
140 "has joined tourney #", number, GetPlayerCount(), "players now.", "\n");
142 if(GetPlayerCount() >= params.maxPlayers)
144 return(1); // we entered the tourney
146 return(0); // sucks to be us cause our rating doesn't fit the params
149 //- RemovePlayer ----------------------------------------------------------
150 int Tourney::RemovePlayer(char *name) {
151 TourneyPlayers *tp = NULL, *p=NULL;
153 int roundsRemaining=0;
155 tp = GetPlayer(name);
156 printf("forfeiting %s\n", tp->name);
157 if(tp == NULL) return -1; // Player not in THIS tourney
161 roundsRemaining = GetRoundsRemaining();
163 // This code will go through a forfeited players list and give him a loss for current opponent
164 // with a quick modification it will give losses for all games played as well...
165 LinkListIter<Player> opponentIter(tp->opponentList); // List of opponents this player has had
166 opponentIter.Reset();
167 while((opp = opponentIter.Next())) {
168 if(strcmp("_BYE_", opp->name) != 0) { // If I am not _BYE_
169 p = GetPlayer(opp->name);
170 if(opp->floatValue == -1) { // floatValue stores the game result for this player
171 if(opp->value) { // if player leaving was white
172 SetGameResult(tp->name, opp->name, 0);
174 SetGameResult(opp->name, tp->name, 1);
181 LinkListIter<TourneyPlayers> playerIter(playerList);
183 while((p = playerIter.Next())) {
184 if(strcmp(p->name, "_BYE_") == 0) {
185 if(p->activeFlag != 0)
195 return roundsRemaining;
198 //- GetPlayer ----------------------------------------------------------
199 TourneyPlayers *Tourney::GetPlayer(char *name) {
200 LinkListIter<TourneyPlayers> playerIter(playerList);
201 TourneyPlayers *tp = NULL;
204 while((tp = playerIter.Next()))
205 if(!strcasecmp(tp->name, name))
211 //- GetRound ----------------------------------------------------------
212 int Tourney::GetRound() {
213 return params.currentRound;
214 }//- end of GetRound --------------------------------------------------
216 //- GetRoundsRemaining ------------------------------------------------
217 int Tourney::GetRoundsRemaining() {
218 return (params.rounds - params.currentRound);
219 }//- end of GetRoundsRemaining -----------------------------------------
221 //- SortPlayers ----------------------------------
222 void Tourney::SortPlayers() {
223 Player *temp=NULL, *s=NULL;
224 TourneyPlayers *tp = NULL;
227 LinkListIter<TourneyPlayers> playerIter(playerList);
228 LinkListIter<Player> sortIter(sortList);
231 while((s = sortIter.Next())) sortList.Delete(s);
234 while((tp = playerIter.Next())) {
235 (tp->activeFlag) ? tp->sortValue = (tp->score + tp->rating/10000.0) : tp->sortValue = -1.0;
238 if((status == OPEN) && (i < (GetPlayerCount()/2)))
239 (i % 2) ? tp->AddWhite() : tp->AddBlack();
244 while((tp = playerIter.Next())) {
247 temp = new Player(tp->name, tp->sortValue);
248 while((s = sortIter.Next())) {
249 if(tp->sortValue > s->floatValue) {
250 sortList.Insert(s, temp);
256 sortList.Append(temp);
261 while((s = sortIter.Next())) {
263 if(gMamer.debugLevel >= 10) printf("%4d %-18s\n", s->value, s->name);
266 }//- end of Sort Players ----------------------
268 //- GetSortValueCount -------------------------------------------------------
269 int Tourney::GetSortValueCount(double value) {
270 LinkListIter<TourneyPlayers> playerIter(playerList);
272 TourneyPlayers *tp=NULL;
275 while((tp = playerIter.Next())) {
276 if(tp->sortValue == value) {
277 s = GetSortPlayer(tp->name);
286 //- GetSortPlayer ----------
287 Player *Tourney::GetSortPlayer(char *name) {
289 LinkListIter<Player> sortIter(sortList);
291 while((p = sortIter.Next())) {
292 if(strcasecmp(p->name, name) == 0) {
298 }//- end of GetSortPlayer -----
300 //- GetSortPlayer ------------------------------
301 Player *Tourney::GetSortPlayer(int place) {
303 LinkListIter<Player> sortIter(sortList);
305 while((p = sortIter.Next())) {
306 if(p->value == place) {
312 }//- end of GetSortPlayer -----
314 //- CalculateAverage --------------------------------------------------
315 void Tourney::CalculateAverage(void) {
316 int total=0, count=0;
318 LinkListIter<TourneyPlayers> playerIter(playerList);
320 while((p = playerIter.Next())) {
327 averageRating = ((float)total/(float)count);
330 }//- end CalculateAverage
332 //- GetAverageRating ----------------------------------------------------------
333 float Tourney::GetAverageRating(void) {
334 return averageRating;
335 }//end GetAverageRating
337 //- GetVariant ----------------------------------------------------------
338 int Tourney::GetVariant(void) {
341 switch(params.variant) {
345 eTime = (float)params.time + (0.6666667 * (float)params.inc);
361 //- Open ----------------------------------------------------------
362 int Tourney::Open(void) {
371 //- GetPlayerCount ----------------------------------------------------------
372 int Tourney::GetPlayerCount() {
375 LinkListIter<TourneyPlayers> playerIter(playerList);
377 while((p = playerIter.Next())) {
378 if(p->activeFlag != 0)
383 }//- end GetPlayerCount ----------------------------------
385 //- SetPersist -------------------------------------------------------------
386 void Tourney::SetPersist(int i) {
390 //- GetPersist -------------------------------------------------------------
391 int Tourney::GetPersist() {
395 //- SetEndDate -------------------------------------------------------------
396 void Tourney::SetEndDate() {
398 } //- end of SetEndDate ----------------------------------------------------
400 //- CloseAndStart ----------------------------------------------------------
401 void Tourney::CloseAndStart(void) {
403 params.currentRound = 0;
407 cout << "tourney started at: " << ctime(&startDate) << endl;
409 if(params.rounds == 0) {
410 switch(params.style) {
412 params.rounds = GetPlayerCount() - 1;
415 params.rounds = (int)ceil(log2(GetPlayerCount()));
418 params.rounds = DEFAULT_ROUNDS;
423 // this is to stop a 4 player tourney from having 2 rounds
424 params.rounds = (params.rounds < MINIMUM_ROUNDS) ? MINIMUM_ROUNDS : params.rounds;
427 TellThemWhoTheyPlay(); // tell them who they play
430 int Tourney::PopLastPairedPlayer() {
431 Storage *p=NULL, *lastPlayer=NULL;
432 LinkListIter<Storage> pairedIter(pairedPlayers);
435 while((p = pairedIter.Next())) {
441 cout << "Popping: " << lastPlayer->name << " from the paired list " << endl;
442 pairedPlayers.Delete(lastPlayer);
444 cout << "Popping: _NOBODY_" << " from the paired list " << endl;
449 void Tourney::ClearPairedPlayers() {
451 LinkListIter<Storage> pairedIter(pairedPlayers);
453 while((p = pairedIter.Next())) pairedPlayers.Delete(p);
456 int Tourney::MakeAssignments(void) {
457 TourneyPlayers *tp = NULL, *opponent = NULL, *bye = NULL;
458 Storage *newPairedPlayer=NULL;
459 Player *p=NULL, *opp=NULL;
460 int everybodyPaired=0, byeFlag=1, playerCount=0, i=1;
461 LinkListIter<TourneyPlayers> playerIter(playerList);
463 params.currentRound++;
464 if(params.currentRound > params.rounds) {
465 cout << "Returning because current round is > rounds" << endl;
466 cerr << "Returning because current round is > rounds" << endl;
469 // Initialize a few things...make sure nobody is paired,
471 while((tp = playerIter.Next())) {
473 if(strcmp(tp->name, "_BYE_") == 0) { byeFlag = 0; } // unset the byeFlag
475 playerCount = GetPlayerCount();
476 if((byeFlag) && (playerCount % 2)){ // we need to add a bye
477 bye = new TourneyPlayers("_BYE_", 0, 0);
478 playerList.Append(bye); // add the bye to the tourney players list
483 // Set up the PairingScores
485 while((tp = playerIter.Next())) { if(!tp->IsPaired()) SetPairingScores(tp); }
488 while((tp = playerIter.Next())) { UnPairPlayer(tp); tp->oppChoice=0; } // unpair all the players
491 ClearPairedPlayers();
492 while(everybodyPaired == 0) {
494 p = GetSortPlayer(i);
495 tp = GetPlayer(p->name);
496 opponent = (TourneyPlayers *)NULL;
497 // PrintPotentialLists();
498 if((tp->IsPaired() == FALSE) && tp->activeFlag) { // If I am not paired and I am active pair me
499 if((opponent = FindBestOpponent(tp))) {
500 newPairedPlayer = new Storage(tp->name, i);
501 pairedPlayers.Append(newPairedPlayer);
502 cerr << "Adding: " << tp->name << " " << i << " " << "to the paired list " << opponent->name << endl;
503 everybodyPaired = PairPlayers(tp, opponent); // Actually Pair me
504 i++; // go to the next player
505 } else { // If there is no opponent for me go back and repair up the tree
506 if(tp->oppChoice > playerCount) { // If I have tried all my opponents
507 tp->oppChoice = 0; // reset me so I can try again later
508 i = PopLastPairedPlayer(); // returns the last player paired & removes him from the paired list
509 cerr << "i=" << i << endl;
510 if(i <= 0) { // this would be really bad means we can't even find
511 cout << "Returning because we can't find pairings" << endl;
512 cerr << "Returning because we can't find pairings" << endl;
513 return 0; // an opponent for the first player. Tourney has to be over now
515 p = GetSortPlayer(i);
516 tp = GetPlayer(p->name);
517 opponent = GetPlayer(tp->oppName);
518 cout << "UnPairing: " << tp->name << " " << opponent->name << " choice: " << tp->oppChoice << endl;
519 tp->RemoveLastOpponent(); // removes the person we were planning on playing
520 opponent->RemoveLastOpponent();
521 UnPairPlayer(tp); // unpair us so we can be re-paired
522 UnPairPlayer(opponent);
523 tp->oppChoice++; // try his next possible opponent
525 tp->oppChoice++; // Try my next opponent
528 } else { // if I am already paired go to the next player and pair him
533 if(everybodyPaired > 0) {
535 while((tp = playerIter.Next())) UnPairPlayer(tp); // unpair all players so we can use that to tell
536 playerIter.Reset(); // if they have been assiged a color
537 while((tp = playerIter.Next())) {
538 if((!tp->IsPaired()) && (tp->activeFlag != 0)) {
539 opponent = GetPlayer(tp->oppName);
540 AssignColors(tp, opponent);
541 tp->NowPaired(TRUE); // mark BOTH players as having a color
542 opponent->NowPaired(TRUE); // this is important for when we hit this player later in the Iter
548 while((tp = playerIter.Next())) {
549 if(0 == strcmp(tp->name, "_BYE_")) { // If I am the bye
550 LinkListIter<Player> opponentIter(tp->opponentList);
551 while((opp = opponentIter.Next())) { // Got through my opponents and find the one I am playing now
552 if(0 == strcasecmp(opp->name, tp->oppName)) { // & Give him a win
554 SetGameResult(tp->name, tp->oppName, 0);
556 SetGameResult(tp->oppName, tp->name, 1);
557 gMamer.XServerCom("tell %s you get a BYE this round.%s", opp->name, "\n");
565 //- PrintPotentialLists
566 void Tourney::PrintPotentialLists() {
567 TourneyPlayers *tp=NULL;
570 LinkListIter<TourneyPlayers> playerIter(playerList);
572 while((tp = playerIter.Next())) {
573 printf("%-10s %i\n", tp->name, tp->oppChoice);
574 LinkListIter<Player> oppIter(tp->potentialOpponentList);
575 while((o = oppIter.Next())) {
576 printf("%d %-10s ", o->value, o->name);
582 //- Start of FindBestOpponent
583 TourneyPlayers *Tourney::FindBestOpponent(TourneyPlayers *tp) {
586 LinkListIter<Player> opponentIter(tp->potentialOpponentList);
587 while((tmp = opponentIter.Next())) {
588 if((tmp->value == tp->oppChoice) && (0 == GetPlayer(tmp->name)->IsPaired())) {
589 return GetPlayer(tmp->name);
596 //- Start of SetPairingSores -------------------------------
597 void Tourney::SetPairingScores(TourneyPlayers *tp) {
599 TourneyPlayers *opponent = NULL;
600 Player *temp=NULL, *newOpp=NULL, *t=NULL, *me=NULL;
601 int offset=2, place=1, i=0, added=0;
603 tp->RemovePotentialOppList();
605 LinkListIter<TourneyPlayers> playerIter(playerList);
609 while((opponent = playerIter.Next())) {
610 if((strcmp(tp->name, opponent->name) != 0) &&
611 (tp->score == opponent->score)) {
613 if(opponent->rating > tp->rating) {
619 if(place > offset) { offset *= -1; }
621 me = GetSortPlayer(tp->name);
623 while((opponent = playerIter.Next())) {
624 if(strcmp(tp->name, opponent->name) && (tp->activeFlag !=0)) { // If this isn't MY name & I am active
625 if((!tp->AlreadyPlayed(opponent->name)) && (!opponent->IsPaired()) && (opponent->activeFlag != 0)) {
626 // and I haven't played this person and this person is active. (not forfeited)
627 t = GetSortPlayer(opponent->name);
628 score = ((abs(t->value - (me->value + offset))) * 1000);
629 if(opponent->score >= tp->score) {
630 score = score + ((opponent->score - tp->score) * 10.0);
632 score = score + ((tp->score - opponent->score) * 10.0);
634 score += abs(opponent->ColorDue() - tp->ColorDue());
635 score += (abs(opponent->rating - tp->rating)) * 0.0001;
637 if(!strcmp(opponent->name, "_BYE_")) { score = 999999; }
640 newOpp = new Player(opponent->name, score);
641 LinkListIter<Player> opponentIter(tp->potentialOpponentList);
642 opponentIter.Reset();
643 while((temp = opponentIter.Next())) {
644 if(score < temp->floatValue) {
645 tp->potentialOpponentList.Insert(temp, newOpp);
651 tp->potentialOpponentList.Append(newOpp);
652 opponentIter.Reset();
654 while((temp = opponentIter.Next())) {
663 //- Start of PairPlayers ----------------------------------
664 int Tourney::PairPlayers(TourneyPlayers *p1, TourneyPlayers *p2) {
668 LinkListIter<TourneyPlayers> playerIter(playerList);
670 temp = new Player(p2->name, -1.0, 0, p2->rating);
671 p1->opponentList.Append(temp);
673 strcpy(p1->oppName, p2->name);
675 temp = new Player(p1->name, -1.0, 0, p1->rating);
676 p2->opponentList.Append(temp);
678 strcpy(p2->oppName, p1->name);
681 while((tp = playerIter.Next())) {
682 if((!tp->IsPaired()) && (tp->activeFlag != 0))
689 //- Start of UnPairPlayer ----------------------------------
690 void Tourney::UnPairPlayer(TourneyPlayers *p1) {
692 p1->NowPaired(FALSE);
693 }//- end of UnPairPlayer
696 int Tourney::intcmp(int a, int b) {
709 //- AssignColors ----------------------------------------------------------
710 void Tourney::AssignColors(TourneyPlayers *p1, TourneyPlayers *p2) {
711 int p1Color=0, rated = 1;
713 Player *opp1 = NULL, *opp2 = NULL;
715 if(params.mode != 'r') { rated = 0; }
716 if(intcmp(p1->ColorDue(), p2->ColorDue()) != 0) {
717 if(p1->ColorDue()) { p1Color = 1; }
719 if(p1->ColorDue()) { // Both are due white; need to find out how due.
720 switch (intcmp(p1->GetConsecutiveBlacks(), p2->GetConsecutiveBlacks())) {
726 switch (intcmp(p1->GetTotalBlacks(), p2->GetTotalBlacks())) {
732 if((p1->score * 10000 + p1->rating) >= (p2->score * 10000 + p2->rating))
739 switch (intcmp(p1->GetConsecutiveWhites(), p2->GetConsecutiveWhites())) {
745 switch (intcmp(p1->GetTotalWhites(), p2->GetTotalWhites())) {
751 if((p1->score * 10000 + p1->rating) >= (p2->score * 10000 + p2->rating))
759 LinkListIter<Player> opponentIter1(p1->opponentList);
760 LinkListIter<Player> opponentIter2(p2->opponentList);
761 while((opp1 = opponentIter1.Next())) {
762 if(!strcasecmp(opp1->name, p2->name)) { break; }
764 while((opp2 = opponentIter2.Next())) {
765 if(!strcasecmp(opp2->name, p1->name)) { break; }
768 p1->AddWhite(); p2->AddBlack();
770 g = new Game(p1->name, p2->name, params.time, params.inc, rated, 'r');
772 p1->AddBlack(); p2->AddWhite();
774 g = new Game(p2->name, p1->name, params.time, params.inc, rated, 'r');
779 //- GetStatus --------------------------------------------------------
780 int Tourney::GetStatus(void) {
784 //- EndTourney -----------------------
785 void Tourney::EndTourney(void) {
789 //- Announce ----------------------------------------------------------
790 void Tourney::Announce(void) {
795 announce = new char[MAX_LINE_SIZE];
796 memset(announce, '\0', MAX_LINE_SIZE);
797 sprintf(announce, "*****Tourney Announcement***** %80s Trny #%d %d %d %c ",
798 "", number, params.time, params.inc, params.mode);
799 if(params.style == 's') { strcat(announce, " SWISS"); } else { strcat(announce, " RR"); }
800 switch(params.variant) {
802 strcat(announce, " Wild ");
803 strcat(announce, GetWild(params.wild));
806 strcat(announce, " Bug"); break;
808 strcat(announce, " Suicide"); break;
812 memset(temp, '\0', 128);
813 sprintf(temp, " %i-%i %i plr(s). tell %s join %d. Avg: %5.1f",
814 params.ratingLow, params.ratingHigh, GetPlayerCount(), gMamer.username, number, averageRating);
815 strcat(announce, temp);
817 printf("%s + cha 49\n", announce);
820 gMamer.XServerCom("%s %i %s%s", "tell", gMamer.channelNumber, announce, "\n");
823 if((now - lastCshouted) > (SEC_BETWEEN_CSHOUTS)) {
824 gMamer.XServerCom("%s %s%s", "cshout", announce, "\n");
831 //- SetVariable ---------------------------------------------------------------
832 void Tourney::SetVariable(int why, int newValue) {
836 if((newValue >= 0) && (newValue <= MAX_TIME))
837 params.time = newValue;
840 if((newValue >= 0) && (newValue <= MAX_INCREMENT))
841 params.inc = newValue;
844 params.rounds = newValue;
845 params.rounds = MIN(params.rounds, MAX_ROUNDS);
846 params.rounds = MIN((params.maxPlayers - 1), params.rounds);
849 if(((newValue >= 0) && (newValue <= 5)) ||
850 ((newValue >= 8) || (newValue <= 10)))
851 params.wild = newValue;
854 params.ratingLow = newValue;
855 params.ratingLow = MAX(0, params.ratingLow);
856 if(params.ratingLow >= (params.ratingHigh - 200))
857 params.ratingLow = params.ratingHigh - 200;
860 params.ratingHigh = newValue;
861 if(params.ratingHigh <= (params.ratingLow + 200))
862 params.ratingHigh = params.ratingLow + 200;
865 params.maxPlayers = newValue;
866 params.maxPlayers = MAX(params.maxPlayers, MINIMUM_PLAYERS);
867 params.maxPlayers = MAX(params.maxPlayers, (params.rounds + 1));
874 //- SetVariable ---------------------------------------------------------------
875 void Tourney::SetVariable(int why, char *newValue) {
879 if((newValue[0] == 's') || (newValue[0] == 'r'))
880 params.style = newValue[0];
883 if((newValue[0] == 'r') || (newValue[0] == 'w') || (newValue[0] == 'b') || (newValue[0] == 's'))
884 params.variant = newValue[0];
887 if((newValue[0] == 'r') || (newValue[0] == 'u'))
888 params.mode = newValue[0];
895 //- Begin GetWild - take a int return a string
896 char *Tourney::GetWild(int w) {
921 //- TellThemWhoTheyPlay ------------------------------------------
922 void Tourney::TellThemWhoTheyPlay() {
924 LinkListIter<Game> gameIter(gameList); // List of games in this tourney
925 char *Variant=new char[MAX_LINE_SIZE];
927 memset(Variant, '\0', MAX_LINE_SIZE);
929 if(params.variant == 'w')
930 sprintf(Variant, "wild %2s", GetWild(params.wild));
931 else if(params.variant == 's')
932 sprintf(Variant, "suicide");
933 else if(params.variant == 'b')
934 sprintf(Variant, "bug");
936 while((g = gameIter.Next())) {
937 /* note that we rely on rmatch and on the ; separated commands from lasker */
938 gMamer.XServerCom("rmatch %s %s %i %i %c %s white ; rmatch %s %s %i %i %c %s black\n",
939 g->whiteName, g->blackName, g->time, g->inc, params.mode, Variant,
940 g->blackName, g->whiteName, g->time, g->inc, params.mode, Variant);
943 }//- end TellThemWhoTheyPlay --------------------------------------
945 //- SetGameResult --------------------------------------------
946 int Tourney::SetGameResult(char *white, char *black, int result) {
947 Player *opp1 = NULL, *opp2 = NULL;
948 TourneyPlayers *tp1 = NULL, *tp2 = NULL;
952 tp1 = GetPlayer(white);
953 tp2 = GetPlayer(black);
955 if((NULL == tp1) || (NULL == tp2)) { return 0; }
957 LinkListIter<Player> opponentIter1(tp1->opponentList); // List of opponents this player has had
958 while((opp1 = opponentIter1.Next())) {
959 if(!strcasecmp(opp1->name, black)) { break; }
961 LinkListIter<Player> opponentIter2(tp2->opponentList);
962 while((opp2 = opponentIter2.Next())) {
963 if(!strcasecmp(opp2->name, white)) { break; }
965 if((NULL == opp1) || (NULL == opp2)) { return -1; }
967 switch (result) { // set the result
969 opp1->floatValue = 1.0;
970 opp2->floatValue = 0.0;
973 opp1->floatValue = 0.0;
974 opp2->floatValue = 1.0;
977 opp1->floatValue = 0.5;
978 opp2->floatValue = 0.5;
983 tp1->CalculateScore();
984 tp2->CalculateScore();
986 LinkListIter<Game> gameIter(gameList); // List of games in this tourney
987 while((g = gameIter.Next())) {
988 if(!(strcasecmp(g->whiteName, white)) && !(strcasecmp(g->blackName, black))) {
996 if((g = gameIter.Next())) {
1004 } //- End SetGameResult --------------------------------------
1006 //- GetStartDate ---------------------------------------------
1007 long Tourney::GetStartDate() {
1009 } //- end of GetStartDate ------------------------------------
1011 //- GetEndDate ---------------------------------------------
1012 long Tourney::GetEndDate() {
1014 } //- end of GetEndDate ------------------------------------