#include "VegaMain.h" #include "Tournament.h" /* definition of classes - Tournament - Round : general methods (specific methods are in RoundRobin and RoundSwiss - TeamArchive */ TournamentStatus::TournamentStatus() { NAMETORNEO = "myTournament"; FILETORNEO = "myFile"; PLACETORNEO = "myTown";; HOSTFEDERATION = "fed";; DATATORNEO_B = DATATORNEO_E = "00000000"; ARBITER = "myArbiter"; PATHDIR = Null; WON = 1.; DRAW = 0.; tyebreakorder[0]= 0; // order of the tyebreak tyebreakorder[1]= 1; tyebreakorder[2]= 2; tyebreakorder[3]= tyebreakorder[4]= tyebreakorder[5]=tyebreakorder[6]=tyebreakorder[7]= tyebreakorder[8]=tyebreakorder[9]=tyebreakorder[10]=tyebreakorder[11]=tyebreakorder[12]=0; tyebreakname[0] = ""; tyebreakname[1] = " Buc1 "; tyebreakname[2] = " BucT "; tyebreakname[3] = " BucM "; tyebreakname[4] = " S-B "; tyebreakname[5] = " Cmlt "; tyebreakname[6] = " ARO "; tyebreakname[7] = " Mblk "; tyebreakname[8] = " Mwns "; tyebreakname[9] = " APRO "; tyebreakname[10] =" PMss "; tyebreakname[11] = ""; tyebreakname[12] = ""; NPlayer = 0; // player partecipating to the tournament NAval = 0; NRounds = 1; // rounds of the tournament SCORE_TYPE = 1; NBoards = 4; NAccRound = 0; currentRound = 0; //useful flag STATUS_ROUND = READY_FOR_PAIRING; IS_DONE_MANUAL = IS_TORNEO_STARTED = DROP_PLAYER = IS_CLOSED_REGISTRATION = IS_SAVED_ROUND = AVOID_SAME_COUNTRY = IS_FIDE_TOURNAMENT = PERMIT3COLOR = IS_SWISS = false; IS_SET_VERBOSE = true; PLAY_SYSTEM = 2; } /////////////////////// class round //////////////////////////////////// void RoundData::SaveVegFile(bool flag) // flag = true, save normal // flag = false, save the backup file { int i, k; String filename; if (flag) filename = PATHDIR + FILETORNEO + ".veg"; else filename = PATHDIR + FILETORNEO + ".bak"; FileOut out(filename); String s; s = VERSION; s << " # Do not edit this file!" ; out.PutLine( s ); out.PutLine( NAMETORNEO); // out.PutLine( PLACETORNEO ); // out.PutLine( HOSTFEDERATION); out.PutLine( NFormat("%-20.20s %s", PLACETORNEO, HOSTFEDERATION ) ); out.PutLine( DATATORNEO_B + ", " + DATATORNEO_E); out.PutLine( ARBITER); out.PutLine( NFormat("%3.1f %3.1f", DRAW, WON ) ); out.PutLine( NFormat(" %d %d %d %d %d %d %d %d %d %d", tyebreakorder[1], tyebreakorder[2], tyebreakorder[3], tyebreakorder[4], tyebreakorder[5], tyebreakorder[6], tyebreakorder[7], tyebreakorder[8], tyebreakorder[9], tyebreakorder[10]) ); out.PutLine( FILETORNEO ); out.PutLine( NFormat("%d %d %d %d %d %d", NRounds, PLAY_SYSTEM, IS_FIDE_TOURNAMENT, NAccRound, NBoards, SCORE_TYPE) ); out.PutLine( NFormat("%d", IS_SAVED_ROUND) ); out.PutLine( NFormat("%d", db.GetCount()) ); // out.PutLine( AsString(teamList.GetCount())); for (i=0; iN_PLAYER_MAX) || (idblack>N_PLAYER_MAX)) { Exclamation( t_("error in the data format")); return 9; } return StrIntValue( NFormat( "%d%03d%1d", idwhite, idblack, res) ); } void RoundData::SetPlayersResult(int round) // // PURPOSE: assign the result for each pair // // INPUT VARIABLE: // round = round at which is done the assign // pair[] = contains the code of the two players // // NOTE: code player result // 1: player win // 0: player lost // 2: draw // 3: win for forfeit // 4: lost for forfeit // 6: 1/2F - 1/2F draw forfeit // 8: 1/2F - 1/2F draw forfeit, no bucholz { int npairs; int i, idwhite, idblack, result, code; if (TD.IS_SWISS) { npairs = pairing[0][round]; for (i=1; i<=TD.NPlayer; i++) { // set the not available players if (player[i].isAvailable != "1" ) TD.playerColor[i][round] = NO_COLOR; } } else npairs = TD.pairingRR[0][round]; for (i=1; i<=npairs; i++) { if (TD.IS_SWISS) code = TD.pairing[i][round]; else code = TD.pairingRR[i][round]; TD.DecodeResult(code, &idwhite, &idblack, &result); // // NOTE: code player result set in roundresult // 1: player win // 0: player lost // 2: draw // 3: win for forfeit // i forfeit sono per res>2 // 4: lost for forfeit // 6: 1/2F - 1/2F draw forfeit // 5: no game (useful for round robin in case of odd player number //NEW // if (TD.IS_SWISS) { switch (result) { case 0: TD.playerColor[idwhite][round] = WHITE_COLOR; TD.playerColor[idblack][round] = BLACK_COLOR ; TD.playerOpponent[idwhite][round] = idblack; TD.playerOpponent[idblack][round] = idwhite; TD.roundResult[idwhite][round] = 0; // White lost TD.roundResult[idblack][round] = 1; // Black win break; case 1: TD.playerColor[idwhite][round] = WHITE_COLOR; TD.playerColor[idblack][round] = BLACK_COLOR ; TD.playerOpponent[idwhite][round] = idblack; TD.playerOpponent[idblack][round] = idwhite; TD.roundResult[idwhite][round] = 1; // White win TD.roundResult[idblack][round] = 0; // Black lost break; case 5: TD.playerColor[idwhite][round] = WHITE_COLOR; TD.playerColor[idblack][round] = BLACK_COLOR ; TD.playerOpponent[idwhite][round] = idblack; TD.playerOpponent[idblack][round] = idwhite; TD.roundResult[idwhite][round] = 2; // White draw TD.roundResult[idblack][round] = 2; // Black draw break; case 3: TD.playerColor[idwhite][round] = NO_COLOR; TD.playerColor[idblack][round] = NO_COLOR ; TD.playerOpponent[idwhite][round] = 0; TD.playerOpponent[idblack][round] = 0; TD.roundResult[idwhite][round] = 3; // win per forfeit TD.roundResult[idblack][round] = 4; // lost per forfeit break; case 4: TD.playerColor[idwhite][round] = NO_COLOR; // black win forfait TD.playerColor[idblack][round] = NO_COLOR ; TD.playerOpponent[idwhite][round] = 0; TD.playerOpponent[idblack][round] = 0; TD.roundResult[idwhite][round] = 4; // lost per forfeit TD.roundResult[idblack][round] = 3; // win per forfeit break; case 2: TD.playerColor[idwhite][round] = NO_COLOR; TD.playerColor[idblack][round] = NO_COLOR ; TD.playerOpponent[idwhite][round] = 0; TD.playerOpponent[idblack][round] = 0; TD.roundResult[idwhite][round] = 4; // lost per forfeit TD.roundResult[idblack][round] = 4; // lost per forfeit break; case 7: TD.playerColor[idwhite][round] = WHITE_COLOR; TD.playerColor[idblack][round] = BLACK_COLOR ; TD.playerOpponent[idwhite][round] = idblack; TD.playerOpponent[idblack][round] = idwhite; TD.roundResult[idwhite][round] = 6; // White draw TD.roundResult[idblack][round] = 6; // Black draw break; } } else {// Round Robin switch (result) { case 0: TD.playerColorRR[idwhite][round] = WHITE_COLOR; TD.playerColorRR[idblack][round] = BLACK_COLOR ; TD.playerOpponentRR[idwhite][round] = idblack; TD.playerOpponentRR[idblack][round] = idwhite; TD.roundResultRR[idwhite][round] = 0; // White lost TD.roundResultRR[idblack][round] = 1; // Black win break; case 1: TD.playerColorRR[idwhite][round] = WHITE_COLOR; TD.playerColorRR[idblack][round] = BLACK_COLOR ; TD.playerOpponentRR[idwhite][round] = idblack; TD.playerOpponentRR[idblack][round] = idwhite; TD.roundResultRR[idwhite][round] = 1; // White win TD.roundResultRR[idblack][round] = 0; // Black lost break; case 5: TD.playerColorRR[idwhite][round] = WHITE_COLOR; TD.playerColorRR[idblack][round] = BLACK_COLOR ; TD.playerOpponentRR[idwhite][round] = idblack; TD.playerOpponentRR[idblack][round] = idwhite; TD.roundResultRR[idwhite][round] = 2; // White draw TD.roundResultRR[idblack][round] = 2; // Black draw break; case 3: TD.playerColorRR[idwhite][round] = WHITE_COLOR; TD.playerColorRR[idblack][round] = BLACK_COLOR ; TD.playerOpponentRR[idwhite][round] = idblack; TD.playerOpponentRR[idblack][round] = idwhite; TD.roundResultRR[idwhite][round] = 3; // win per forfeit TD.roundResultRR[idblack][round] = 4; // lost per forfeit break; case 4: TD.playerColorRR[idwhite][round] = WHITE_COLOR; TD.playerColorRR[idblack][round] = BLACK_COLOR ; TD.playerOpponentRR[idwhite][round] = idblack; TD.playerOpponentRR[idblack][round] = idwhite; TD.roundResultRR[idwhite][round] = 4; // lost per forfeit TD.roundResultRR[idblack][round] = 3; // win per forfeit break; case 2: TD.playerColorRR[idwhite][round] = WHITE_COLOR; TD.playerColorRR[idblack][round] = BLACK_COLOR ; TD.playerOpponentRR[idwhite][round] = idblack; TD.playerOpponentRR[idblack][round] = idwhite; TD.roundResultRR[idwhite][round] = 4; // lost per forfeit TD.roundResultRR[idblack][round] = 4; // lost per forfeit break; case 7: TD.playerColorRR[idwhite][round] = WHITE_COLOR; TD.playerColorRR[idblack][round] = BLACK_COLOR ; TD.playerOpponentRR[idwhite][round] = idblack; TD.playerOpponentRR[idblack][round] = idwhite; TD.roundResultRR[idwhite][round] = 6; // White draw TD.roundResultRR[idblack][round] = 6; // Black draw break; } } } } /* void RoundData::PrepareHTMLindex(void) { int j; return; FileOut savehtml(PATHDIRWWW + "index.html"); // produce index.HTML file savehtml << "\n\n"<< NAMETORNEO << "\n"; savehtml << " \n"; savehtml << "\n"; savehtml << "\n"; savehtml << "\n"; savehtml << "

" << NAMETORNEO << "

\n"; savehtml << "

" << PLACETORNEO << ",  " << DATATORNEO_B <<", "<\n"; savehtml << "
\n"; savehtml << "

" << t_("Cross Table") << "

\n"; savehtml << "

" << t_("Ranking List") << "

\n"; savehtml << "

" << t_("Player Card") << "

\n"; if(IS_FIDE_TOURNAMENT) savehtml << "

" << t_("Rating Report") << "

\n"; if(PLAY_SYSTEM==DUBOV) savehtml << "

" << t_("Score Groups") << "

\n"; savehtml << " \n"; savehtml << "\n"; savehtml << ""; savehtml << " \n"; savehtml << "\n"; savehtml << "\n"; savehtml << "\n"; savehtml << "\n"; savehtml << "
" << t_("Pairing/Results") << "
\n"; for(j=1; j<=currentRound; j++) { savehtml << " [ " << j <<" ] \n"; } savehtml << "
\n"; savehtml << "

Generated by Vega

\n"; savehtml << "\n\n"; savehtml.Close(); if(IS_FIDE_TOURNAMENT) FideEloVariationHTML(); } */ void RoundData::ShowTableCategoryScore(int nplayers) // // PURPOSE: sort the database according to the category, score and bucholz // // INPUT VARIABLE // n = number of players to be sorted // { int i, k, j, pos; int arr[N_PLAYER_MAX+1]; String stringa, strname, str; String filename; extern int CompareCategoryScoreName(const void *pid1, const void *pid2); filename = PATHDIR + "rankcat.txt"; // FileOut save( NFormat("%srankcat.txt", PATHDIR) ); FileOut save( filename ); save<< NAMETORNEO << "\n"; save<< PLACETORNEO << " - " << DATATORNEO_B <<", "<=1) && (player[i].title != player[ arr[k-1] ].title) ) { save << "\n" << t_("Ranking for category: ") << player[ arr[k] ].codetitle << "\n"; pos = 1; } else pos++; if (player[i].isAvailable != "0") strname = NFormat("%-20.20s", player[i].name); else strname = NFormat("%-17.17s(W)", player[i].name); save << NFormat("%3d %4.1f %3d %s | %4d %3s %3s | ", pos, //position player[i].tiebreak[SCORE], i, strname, player[i].RATING, player[i].codetitle, player[i].country); j=1; while (tyebreakorder[j]) { switch ( tyebreakorder[j] ) // color the editSearch { case 1: save << NFormat(" %6.2f ", player[i].tiebreak[BUC_CUT1]); break; case 2: save << NFormat(" %6.2f ", player[i].tiebreak[BUC_TOT]); break; case 3: save << NFormat(" %6.2f ", player[i].tiebreak[BUC_MED]); break; case 4: save << NFormat(" %6.2f ", player[i].tiebreak[SONN_BERG]); break; case 5: save << NFormat(" %6.2f ", player[i].tiebreak[CUMUL]); break; case 6: save << NFormat(" %6.2f ", player[i].tiebreak[ARO]); break; case 7: save << NFormat(" %4.0f ", player[i].tiebreak[MOST_BLACKS]); break; case 8: save << NFormat(" %4.0f ", player[i].tiebreak[MOST_WINS]); break; case 9: save << NFormat(" %4.0f ", player[i].tiebreak[APRO]); break; } j++; } save << "\n"; } save<<"\n Generated by Vega - www.vegachess.com\n"; save.Close(); } void RoundData::ShowTableScore(int nplayers) // // PURPOSE: rank the database according the score and bucholz // // INPUT VARIABLE // n = number of players to be sorted // { int i, inext, iprev, n, p, k, j; int arr[N_PLAYER_MAX+1], next[11]; int tb, tbp=0; String stringa, strname, str; extern int CompareScoreName(const void *pid1, const void *pid2); extern int (*cmpfunc[FUNC_CMP+1])(int, int); FileOut save(PATHDIR + "tblscore.txt" ); FileOut savehtml(PATHDIRWWW + "index.html" ); save << NAMETORNEO << "\n"; save << PLACETORNEO << " - " << DATATORNEO_B <<", "<=0 && n && player[i].tiebreak[SCORE] == player[inext].tiebreak[SCORE]) tb = (*cmpfunc[ tyebreakorder[j-1] ])(i, inext); else tb=1; if (iprev>=0 && p && player[i].tiebreak[SCORE] == player[iprev].tiebreak[SCORE]) tbp = (*cmpfunc[ tyebreakorder[j-1] ])(i, iprev); //stampa il ritorno else tbp=1; if (tb==0 || tbp==0) { switch ( tyebreakorder[j] ) // color the editSearch { case 1: save << NFormat(" %6.2f ", player[i].tiebreak[BUC_CUT1]); break; case 2: save << NFormat(" %6.2f ", player[i].tiebreak[BUC_TOT]); break; case 3: save << NFormat(" %6.2f ", player[i].tiebreak[BUC_MED]); break; case 4: save << NFormat(" %6.2f ", player[i].tiebreak[SONN_BERG]); break; case 5: save << NFormat(" %6.2f ", player[i].tiebreak[CUMUL]); break; case 6: save << NFormat(" %6.2f ", player[i].tiebreak[ARO]); break; case 7: save << NFormat(" %4.0f ", player[i].tiebreak[MOST_BLACKS]); break; case 8: save << NFormat(" %4.0f ", player[i].tiebreak[MOST_WINS]); break; case 9: save << NFormat(" %4.0f ", player[i].tiebreak[APRO]); break; } //save << str; if ( tb != 0) n = 0; if ( tbp != 0) p = 0; j++; } else break; } save << "\n"; } save<<"\n Generated by Vega - www.vegachess.com\n"; save.Close(); // produce HTML files savehtml << TD.HTMLCommonHeader(); savehtml << HTMLNavBar(); savehtml << "

" << NAMETORNEO << "

\n"; savehtml << "

" << PLACETORNEO << " - " << DATATORNEO_B <<", "<\n"; savehtml << "

" << t_("Standing at round ")<< currentRound<< "

\n"; savehtml << " \n"; savehtml << "\n"; savehtml << " "; savehtml << " "; j=1; while (tyebreakorder[j]) { switch ( tyebreakorder[j] ) // color the editSearch { case 1: savehtml << NFormat("", tyebreakname[ tyebreakorder[j] ]); break; case 2: savehtml << NFormat("", tyebreakname[ tyebreakorder[j] ]); break; case 3: savehtml << NFormat("", tyebreakname[ tyebreakorder[j] ]); break; case 4: savehtml << NFormat("", tyebreakname[ tyebreakorder[j] ]); break; case 5: savehtml << NFormat("", tyebreakname[ tyebreakorder[j] ]); break; case 6: savehtml << NFormat("", tyebreakname[ tyebreakorder[j] ]); break; case 7: savehtml << NFormat("", tyebreakname[ tyebreakorder[j] ]); break; case 8: savehtml << NFormat("", tyebreakname[ tyebreakorder[j] ]); break; case 9: savehtml << NFormat("", tyebreakname[ tyebreakorder[j] ]); break; } j++; //savehtml << str; } savehtml << "\n \n"; for (k=0; k%3d ", k+1, player[i].tiebreak[SCORE], i, i, player[i].codetitle, strname, player[i].RATING, (int) player[i].tiebreak[PER_RAT], player[i].country); if ((k+1)&1) savehtml << " "; else savehtml << " "; savehtml << stringa; j=1; while (tyebreakorder[j]) { switch ( tyebreakorder[j] ) // color the editSearch { case 1: savehtml << NFormat(" ", player[i].tiebreak[BUC_CUT1]); break; case 2: savehtml << NFormat(" ", player[i].tiebreak[BUC_TOT]); break; case 3: savehtml << NFormat(" ", player[i].tiebreak[BUC_MED]); break; case 4: savehtml << NFormat(" ", player[i].tiebreak[SONN_BERG]); break; case 5: savehtml << NFormat(" ", player[i].tiebreak[CUMUL]); break; case 6: savehtml << NFormat(" ", player[i].tiebreak[ARO]); break; case 7: savehtml << NFormat(" ", player[i].tiebreak[MOST_BLACKS]); break; case 8: savehtml << NFormat(" ", player[i].tiebreak[MOST_WINS]); break; case 9: savehtml << NFormat(" ", player[i].tiebreak[APRO]); break; } j++; //savehtml << str; } savehtml << "\n \n"; } savehtml << "\n"; savehtml << "
Pos Scr ID NAME Rat PRat Nat %s %s %s %s %s %s %s %s %s
%4.1f %2d %3s %s %4d %4d %3s
%6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %4.0f %4.0f %4.0f
\n"; savehtml << "
Generated by Vega \n"; savehtml << "\n\n"; savehtml.Close(); if(IS_FIDE_TOURNAMENT) FideEloVariationHTML(); } void RoundData::NationalPlayerCard(int nplayers) { int i, j, idopp, per, var, aro, nopp, index; String stringa, color; double arrp[N_ROUND_MAX_RR+2][2]; double tot, totscore, result, sumtotscore, score_perform; int *roundRes; int *playerCol; int *playerOpp; extern int p_dp[]; extern int roundfloat( double per); if (IS_SWISS) { playerOpp = &playerOpponent[0][0]; roundRes = &roundResult[0][0]; playerCol = &playerColor[0][0]; } else { playerOpp = &playerOpponentRR[0][0]; roundRes = &roundResultRR[0][0]; playerCol = &playerColorRR[0][0]; } FileOut save(PATHDIR + "playercd.txt"); FileOut saveelo(PATHDIR + "elovar.txt"); saveelo << NAMETORNEO << "\n"; saveelo<< PLACETORNEO << " - " << DATATORNEO_B <<", "<9999) per=9999; player[i].tiebreak[PER_RAT] = (float) per; save <<"----------------------------------------------------------------\n"; save << NFormat(" var=%3d, PRat=%5d, ARO=%4d, %5.2f %4.1f %4.1f\n", var, per, aro, tot, player[i].tiebreak[SCORE], sumtotscore); saveelo << NFormat(" %3d %-20.20s %2d %4d %4d %5d\n", i, player[i].name, player[i].kcoeff, player[i].RATING, var, per); } save.Close(); saveelo << "\nGenerated by Vega - www.vegachess.com\n"; saveelo.Close(); NationalPlayerCardHTML(nplayers); } void RoundData::NationalPlayerCardHTML(int nplayers) { int i, j, idopp, nopp, index; String stringa, color; double arrp[N_ROUND_MAX_RR+2][2], tot, totscore, result, aro; int *roundRes; int *playerCol; int *playerOpp; if (PLAY_SYSTEM != ROUND_ROBIN && PLAY_SYSTEM != ROUND_ROBIN2) { playerOpp = &playerOpponent[0][0]; roundRes = &roundResult[0][0]; playerCol = &playerColor[0][0]; } else { playerOpp = &playerOpponentRR[0][0]; roundRes = &roundResultRR[0][0]; playerCol = &playerColorRR[0][0]; } // produce HTML files FileOut savehtml(PATHDIRWWW + "playercard.html"); savehtml << HTMLCommonHeader(); // savehtml << HTMLCommonHeader(); savehtml << HTMLNavBar(); savehtml << "

" << t_("National Player Cards") << "

\n"; savehtml << " \n"; savehtml << "\n"; for(i=1; i<=nplayers; i++) { savehtml << "\n\n"; } savehtml << "\n"; savehtml << "
\n"; tot=0.; aro = 0; nopp = 0; totscore=0.; //score without to consider the forfait stringa = NFormat(" %3d %s %-20.20s, K=%2d, Elo=%4d, ID=%d\n", i, player[i].codetitle, player[i].name, player[i].kcoeff, player[i].RATING, player[i].idnat); calcelo(i, arrp, currentRound); savehtml << "\n\n

" << NAMETORNEO << "
" << PLACETORNEO << ", " << DATATORNEO_B <<", "<\n"; savehtml << stringa << "

\n"; savehtml << " \n"; savehtml << "\n"; savehtml << " "; savehtml << "\n"; savehtml << " \n"; for(j=1; j<=currentRound; j++) { if (IS_SWISS) index = i*(N_ROUND_MAX+1) + j; else index = i*(N_ROUND_MAX_RR+1) + j; idopp = playerOpp[index]; if ( idopp!=0 && roundRes[index]<3 ) { // not forfait tot += arrp[j][1]; aro += player[idopp].RATING; nopp++; if (roundRes[index]==1 || roundRes[index]==3) { totscore += 1.0; result = WON;} else if (roundRes[index]==2 || roundRes[index]==6) { totscore += 0.5; result = DRAW;} else if (roundRes[index]==0 || roundRes[index]==4) result = 0.; if (playerCol[index] == WHITE_COLOR) color = "W "; else if (playerCol[index] == BLACK_COLOR) color = " B"; stringa = NFormat(" \n", j, color, idopp, idopp, player[idopp].codetitle, player[idopp].name, player[idopp].RATING, (int) arrp[j][0] ); stringa << NFormat("\n", arrp[j][1], result, totscore, player[idopp].tiebreak[SCORE]); if (j&1) savehtml << " "; else savehtml << " "; savehtml << stringa; savehtml << " \n"; } else { if (roundRes[index]==1 || roundRes[index]==3) result = 1.0; else if (roundRes[index]==2 || roundRes[index]==6) result = 0.5; else if (roundRes[index]==0 || roundRes[index]==4) result = 0.; stringa = NFormat("\n", j,idopp,player[idopp].RATING, result, totscore, 0.0); if (j&1) savehtml << " "; else savehtml << " "; savehtml << stringa; savehtml << " \n"; } } if (nopp!=0) aro = aro/nopp; stringa = NFormat("\n", (int) player[i].tiebreak[ELO_VAR], (int) player[i].tiebreak[PER_RAT], aro, tot, player[i].tiebreak[SCORE]); savehtml << " "; savehtml << stringa; savehtml << " \n"; savehtml << "\n"; savehtml << "
R C ID OPPONENT Rtg diff exp. res Cum Score
%d %s %d %s %-20.20s %d %d%5.2f %4.1f %4.1f %4.1f
%d -- %d not played %d -- -- %4.1f %4.1f %4.1f
var = %3d, PRat=%4d %.1f %5.2f %4.1f
\n"; savehtml << "\n
\n"; savehtml << "
Generated by Vega \n"; savehtml << "\n\n\n"; savehtml.Close(); } void RoundData::ShowRoundCard2(int round) { int i, nhalf; int code, idwhite, idblack, result; String stringa; FileOut save(PATHDIR + "boardcrd.txt"); if (IS_SWISS) nhalf = pairing[0][round]; else nhalf = pairingRR[0][round]; for (i=1; i<=nhalf; i++) { //if (i>0 && (i%4)==0) save << "\f\n"; // form feed each 4 cards if (PLAY_SYSTEM != ROUND_ROBIN && PLAY_SYSTEM != ROUND_ROBIN2) code = pairing[i][round]; else code = pairingRR[i][round]; DecodeResult(code, &idwhite, &idblack, &result); save<<"\n" << "Table " << i<< t_(", Round: ") << round<< ", " <0 && (i%5)==0) save<<"\n\n\n"; } save<< "\n"; save.Close(); ShowRoundCard3(round); } void RoundData::ShowRoundCard3(int round) { const int np =7; int i, r, c, nhalf, npages; int code, idwhite, idblack, result; String stringa; FileOut save(PATHDIR + "boardcrd.rtf"); if (IS_SWISS) nhalf = pairing[0][round]; else nhalf = pairingRR[0][round]; save<<"{\\rtf1\\ansi\\uc0 \\deff1 " << "\n"; save<<"{\\fonttbl{\\f1\\froman\\fcharset0\\fprq2 Courier ;}} " << "\n"; save<<"{\\colortbl;\\red0\\green0\\blue0;\\red0\\green0\\blue255;\\red0\\green255\\blue255;\\red0\\green255\\blue0;\\red255\\green0\\blue255;\\red255\\green0\\blue0; " << "\n"; save<<"\\red255\\green255\\blue0;\\red255\\green255\\blue255;\\red0\\green0\\blue128;\\red0\\green128\\blue128;\\red0\\green128\\blue0;\\red128\\green0\\blue128;\\red128\\green0\\blue0;\\red128\\green128\\blue0;\\red128\\green128\\blue128;\\red192\\green192\\blue192;} " << "\n"; save<<"{\\info }\\paperw11900\\paperh16820\\margl560\\margr560\\margt700\\margb700\\widowctrl\\ftnbj\\aenddoc\\formshade \\fet0\\sectd " << "\n"; save<<"\\linex0\\endnhere\\plain " << "\n"; if (IS_SWISS) npages = (int) ceil(1.*pairing[0][round]/np); else npages = (int) ceil(1.*pairingRR[0][round]/np); for (c=1; c<=npages; c++) { for(r=1; r<=np; r++) { i = c + (r-1) * npages; if (i<=nhalf) { if (IS_SWISS) code = pairing[i][round]; else code = pairingRR[i][round]; DecodeResult(code, &idwhite, &idblack, &result); save<<"\n \\pard{\\cf1{\\fs20\\f1 Table " << i<<", Round = "<< round<<", Tournament: "<" << NAMETORNEO << "

\n"; savehtml << "

" << PLACETORNEO << " - " << DATATORNEO_B <<", "<\n"; savehtml << "

Result at round "<< currentRound<< "

\n"; savehtml << " \n"; savehtml << "\n"; savehtml << "\n"; if (IS_SWISS) npairs = pairing[0][round]; else npairs = pairingRR[0][round]; for (i=1; i<=npairs; i++) { if (IS_SWISS) code = pairing[i][round]; else code = pairingRR[i][round]; DecodeResult(code, &iw, &ib, &res); if (i&1) savehtml << " "; else savehtml << " "; savehtml << NFormat(" \n", i, iw, iw, player[iw].codetitle, player[iw].name, ib, ib, player[ib].codetitle, player[ib].name, LabelResult(res, code, round)); } savehtml << "\n"; savehtml << "
Bo. White Black result
%3d %d %s %s %d %s %s %s
\n"; savehtml << "\n\n"; savehtml << "

Generated by Vega

\n"; savehtml.Close(); } void RoundData::setAPRO(int round, int numberPlayer) // // NOTE: it is called just after the iserting the result of the round // so at round N, the state refer to the previous N-1 rounds // { int id, j, np, jopp, index; float apro; int *roundRes; int *playerCol; int *playerOpp; if (IS_SWISS) { playerOpp = &playerOpponent[0][0]; roundRes = &roundResult[0][0]; playerCol = &playerColor[0][0]; } else { playerOpp = &playerOpponentRR[0][0]; roundRes = &roundResultRR[0][0]; playerCol = &playerColorRR[0][0]; } for (id=1; id<=numberPlayer; id++) { //set Average performance rating opponent apro = 0.; np = 0; for (j=1; j<=round; j++) { if (PLAY_SYSTEM != ROUND_ROBIN && PLAY_SYSTEM != ROUND_ROBIN2) index = id*(N_ROUND_MAX+1) + j; else index = id*(N_ROUND_MAX_RR+1) + j; jopp = playerOpp[index]; if (jopp != 0 && roundRes[index] < 3) // no BYE o game won for forfait { apro += player[jopp].tiebreak[PER_RAT]; np++; } } if (np != 0) player[id].tiebreak[APRO] = apro/np; else player[id].tiebreak[APRO] = 0.; } } void RoundData::SavePairsFile(int round) // // PURPOSE: show the current pairs, i.e. the last done // { int i, code, iw, ib, res, npairs; String name, stringa; FileOut savepair(PATHDIR + "pairs" + AsString( round ) + ".txt"); savepair << NAMETORNEO << t_(": Pairing of round ") << round <<"\n\n"; savepair << "=================================================================================\n"; if (IS_SWISS) npairs = pairing[0][round]; else npairs = pairingRR[0][round]; for (i=1; i<=npairs; i++) { if (IS_SWISS) code = pairing[i][round]; else code = pairingRR[i][round]; DecodeResult(code, &iw, &ib, &res); savepair << NFormat("%3d = %-20.20s (%4.1f) - %-20.20s (%4.1f) = %3d - %3d = ...\n", i, player[iw].name, player[iw].tiebreak[SCORE], player[ib].name, player[ib].tiebreak[SCORE], iw, ib ); savepair << "---------------------------------------------------------------------------------\n"; } savepair << t_("\n The following player(s) got a BYE:\n"); for (i=1; i<=TD.NPlayer; i++) { if ( IsNull(player[i].isAvailable) ) savepair << NFormat(" %3d - %-20.20s\n", i, player[i].name); } savepair << t_("\n The following player(s) withdrew:\n"); for (i=1; i<=TD.NPlayer; i++) { if (player[i].isAvailable== "0") savepair << NFormat(" %3d - %-20.20s\n", i, player[i].name); } savepair << "\n Generated by Vega - www.vegachess.com\n"; savepair.Close(); // produce HTML files FileOut savehtml(PATHDIRWWW + "pairs" + AsString(round) + ".html"); savehtml << TD.HTMLCommonHeader(); savehtml << HTMLNavBar(); savehtml << "

" << NAMETORNEO << "

\n"; savehtml << "

" << PLACETORNEO << " - " << DATATORNEO_B <<", "<\n"; savehtml << "

Pairing at round "<< currentRound<< "

\n"; savehtml << " \n"; savehtml << "\n"; savehtml << "\n"; if (IS_SWISS) npairs = pairing[0][round]; else npairs = pairingRR[0][round]; for (i=1; i<=npairs; i++) { if (IS_SWISS) code = pairing[i][round]; else code = pairingRR[i][round]; DecodeResult(code, &iw, &ib, &res); if (i&1) savehtml << " "; else savehtml << " "; savehtml << NFormat(" ", i, iw, iw, player[iw].codetitle, player[iw].name, player[iw].tiebreak[SCORE]); savehtml << NFormat(" \n", ib, ib, player[ib].codetitle, player[ib].name, player[ib].tiebreak[SCORE]); } savehtml << "\n"; savehtml << "
Bo. White Black result
%3d %d %s %s (%.1f) %d %s %s (%.1f) ...
\n"; savehtml << "

Generated by Vega

\n"; savehtml << "\n\n"; savehtml.Close(); // save the pairing on a file FileOut savepair2 (PATHDIR + "pairing" + AsString(round) + ".txt"); savepair2 << NAMETORNEO << " - Round " << round <<"\n"; savepair2 << "======================================================================\n"; savepair2 << " Board WHITE BLACK\n"; savepair2 << "======================================================================\n"; if (IS_SWISS) npairs = pairing[0][round]; else npairs = pairingRR[0][round]; for (i=1; i<=npairs; i++) { if (IS_SWISS) code = pairing[i][round]; else code = pairingRR[i][round]; DecodeResult(code, &iw, &ib, &res); savepair2 << NFormat(" %3d = %-20.20s - %-20.20s = ... - ...\n", i, player[iw].name, player[ib].name); } savepair2 << "\n"; savepair2 <<"\n Generated by Vega - www.vegachess.com\n"; savepair2.Close(); // repeat saving a file good for a manual pairing if (IS_SWISS) { FileOut savepair3(PATHDIR + "pairs" + AsString(round) + ".man"); savepair3 << pairing[0][round] << "\n"; for (i=1; i<=npairs; i++) { code = pairing[i][round]; DecodeResult(code, &iw, &ib, &res); savepair3 << iw << " " << ib << "\n"; } savepair3.Close(); } } String RoundData::LabelResult(int result, int code, int round) // return the explicit result corresponding to its code { String strres, str; int idw, idb, res; switch (result) { case 1: return "1 - 0"; break; case 0: return "0 - 1"; break; case 5: return "½ - ½"; break; case 3: return "1F- 0"; break; // white win to forfait and get the BYE case 4: return "0 -1F"; break; // black win to forfait and get the BYE case 2: return "0F-0F"; break; // they lost, no color for both case 7: return " adj "; break; // waitint a result case 8: // non standard result DecodeResult(code, &idw, &idb, &res); // get the id players return LabelResultNonStandard(idw, idb, round); break; case 9: return " ... "; break; // waiting a result } return " ... "; } String RoundData::LabelResultNonStandard(int idw, int idb, int round) // return the explicit result corresponding to its code { String r1, r2; if (TD.IS_SWISS) { //swiss switch (TD.roundResult[idw][round]) { case 1: r1 = "1 -"; break; case 0: r1 = "0 -"; break; case 2: r1 = "½ -"; break; case 3: r1 = "1F-"; break; case 4: r1 = "0F-"; break; case 6: r1 = "½F-"; break; case 8: r1 = "½T-"; break; } switch (TD.roundResult[idb][round]) { case 1: r2 = " 1"; break; case 0: r2 = " 0"; break; case 2: r2 = " ½"; break; case 3: r2 = "1F"; break; case 4: r2 = "0F"; break; case 6: r2 = "½F"; break; case 8: r2 = "½T"; break; } } else { //round robin if (idb==0) { TD.roundResultRR[idw][round] = 5; //new TD.roundResultRR[0][round] = 5; //new } switch (TD.roundResultRR[idw][round]) { case 1: r1 = "1 -"; break; case 0: r1 = "0 -"; break; case 2: r1 = "½ -"; break; case 3: r1 = "1F-"; break; case 4: r1 = "0F-"; break; case 6: r1 = "½F-"; break; case 8: r1 = "½T-"; break; case 5: r1 = " null "; break; //new } switch (TD.roundResultRR[idb][round]) { case 1: r2 = " 1"; break; case 0: r2 = " 0"; break; case 2: r2 = " ½"; break; case 3: r2 = "1F"; break; case 4: r2 = "0F"; break; case 6: r2 = "½F"; break; case 8: r2 = "½T"; break; } } return (r1 + r2); } void RoundData::DeleteRound(int fromround, int toround) { int i, j, id; if (IS_SWISS) { for (j=fromround; j<=toround; j++) { for (id=1; id<=NPlayer; id++) { playerColor[id][j] = 0; playerOpponent[id][j] = 0; playerFloater[id][j] = 0; roundResult[id][j] = 0; } } currentRound = fromround-1; for (j=fromround; j<=toround; j++) { for (i=1; i<=pairing[0][j]; i++) pairing[i][j]=0; } AdjournCrossTableSwiss(currentRound); } else { for (j=fromround; j<=toround; j++) { for (id=1; id<=NPlayer; id++) { playerColorRR[id][j] = 0; roundResultRR[id][j] = 0; } } currentRound = fromround-1; for (j=fromround; j<=toround; j++) { for (i=1; i<=pairingRR[0][j]; i++) { pairingRR[i][j] = pairingRR[i][j]/10; pairingRR[i][j] = pairingRR[i][j]*10+9; // set to "wait result" attento al giocatore dispari! } } AdjournCrossTableRR(currentRound); } } String RoundData::HTMLCommonHeader() { String header; // for Linux and windows header = ""; header << "\n\n"<< NAMETORNEO << "\n"; header << " \n"; header << "\n"; header << "\n\n
"; return header; } String RoundData::HTMLNavBar() //int n, String name[], String url[]) { int j; String header; header = ""; header << "

"; if (FileExists(TD.PATHDIRWWW + "tourstat.html")) header << " " << t_("Tournament Summary") << " :: \n"; header << " " << t_("Cross Table") << " :: " << t_("Standing") << " :: " << t_("Player Card") << " \n"; if(IS_FIDE_TOURNAMENT) header << " :: " << t_("Rating Report") << " \n"; if(PLAY_SYSTEM==DUBOV) header << " :: " << t_("Score Groups") << " \n"; if (FileExists(TD.PATHDIRWWW + "players.html")) header << " :: " << t_("Participants") << " \n"; header << "

\n"; header << "

" << t_("Pairings/Results: "); if (TD.STATUS_ROUND == READY_FOR_PAIRING ) { for(j=1; j<=currentRound+1; j++) { header << " [ " << j <<" ] "; } } else { for(j=1; j<=currentRound; j++) { header << " [ " << j <<" ] "; } } header << "

\n"; return header; } void RoundData::ConvertUSCFDB() { FileSel fs; // for Linux and windows String fn, dname; //if (!PromptYesNo( "All your data will be lost... continue?" ) ) return;; fs.Type( "File text tab delimited", "*.txt") .Type( "All file", "*.*") .DefaultExt("txt"); if(fs.ExecuteOpen()) { // file selected dname = fs.GetActiveDir(); //get directory fn = ~fs; } else return; #ifdef PLATFORM_WIN32 dname << "\\"; #endif #ifdef PLATFORM_POSIX dname << "/"; #endif FileIn in(fn); FileOut out(dname + "uscffxd.txt"); while( !in.IsEof() ) { Vector field = Split(in.GetLine(), '\t', false); out << NFormat(" %-20.20s" , field[0]); //name out << NFormat(" %8s" , field[1]); // USCF ID out << NFormat(" %-10.10s" , field[2]); // expiration date out << NFormat(" %3s" , field[3]); // state abbreviation if ( !IsNull(field[4]) ) out << NFormat(" %4d", StrIntValue(field[4]) ); // regular rating else out << NFormat(" %4d", 0 ); if (field.GetCount() == 6 && !IsNull(field[5]) ) out << NFormat(" %4d\n", StrIntValue(field[5]) ); // quick rating else out << NFormat(" % 4d\n", 0 ); } Exclamation( t_("UCSF archive converted") ); in.Close(); out.Close(); } ////////////////////// class Team ///////////////////////////////////////// TeamArchive::TeamArchive() { name = "BYE"; //25 chars max country = "---"; //3 chars max data = "00.00.00"; //10 chars max sex = "m"; //1 chars max idfide = 0; //8 chars max ratingfide = 0; //4 chars max idnat = 0; //8 chars max ratingnat = 0; //4 chars max kcoeff = 0; //3 chars max title = 0; // int corrispondent to codetitleused during pairing codetitle = "--"; // used during pairing, max 3 chars (GM, WGM, IM, ecc... // status isAvailable = "1"; //0=out, null=get the bye - only for swiss, 1=play // pairing data int rating = 0; // for DUBOV SYSTEM : rating = RATING, // for VEGA system : rating = BUCHOLZ float aro = 0.; // for DUBOV system : aro = ARO // for VEGA system : aro = BUCHOLZ int RATING = 0; // real rating used for pairing and printed in the output (it is useful when .rating is used for something else) // it depends by the FIDE flag // player state useful for swiss system duecolor = -1; //no duecolor canChangeDuecolor = true; tiebreak[SCORE] = 0.; } int TeamArchive::TitleToCode() { if ( codetitle == "GM" || codetitle == "IGM") return 20; else if ( codetitle == "WGM" ) return 18; else if ( codetitle == " IM" || codetitle == "IM") return 16; else if ( codetitle == "WIM" ) return 14; else if ( codetitle == " FM" || codetitle == "FM") return 12; else if ( codetitle == "WFM" ) return 11; else if ( codetitle == " M" || codetitle == "M" || codetitle == "-M") return 10; else if ( codetitle == " CM" || codetitle == "CM" ) return 9; else if ( codetitle == " A" || codetitle == "A" || codetitle == "AX" || codetitle == " 1N" || codetitle == "1N" ) return 8; else if ( codetitle == " B" || codetitle == "B" || codetitle == "BX" || codetitle == " 2N" || codetitle == "2N" ) return 7; else if ( codetitle == " C" || codetitle == "C" || codetitle == "CX" || codetitle == " 3N" || codetitle == "3N" ) return 6; else if ( codetitle == " D" || codetitle == "D" || codetitle == "DX" ) return 5; else if ( codetitle == " E" || codetitle == "E" || codetitle == "EX" ) return 4; else if ( codetitle == " F" || codetitle == "F" || codetitle == "FX" ) return 3; else if ( codetitle == " G" || codetitle == "G" || codetitle == "GX" ) return 2; else if ( codetitle == " H" || codetitle == "H" || codetitle == "HX" ) return 1; else if ( codetitle == " " || codetitle == " --" || codetitle == "--" || codetitle == "not" || codetitle == "NC" || codetitle == " NC" ) return 0; return 0; // silly return to remove a warning } ////////////////////// class Team ///////////////////////////////////////// PlayerArchive::PlayerArchive() { name = "BYE"; //25 chars max country = "---"; //3 chars max data = "00.00.00"; //10 chars max sex = "m"; //1 chars max idfide = 0; //8 chars max ratingfide = 0; //4 chars max idnat = 0; //8 chars max ratingnat = 0; //4 chars max kcoeff = 0; //3 chars max title = 0; // int corrispondent to codetitleused during pairing codetitle = "--"; // used during pairing, max 3 chars (GM, WGM, IM, ecc... // status isAvailable = "1"; //0=out, null=get the bye - only for swiss, 1=play // for VEGA system : aro = BUCHOLZ int RATING = 0; // real rating used for pairing and printed in the output (it is useful when .rating is used for something else) // it depends by the FIDE flag tiebreak[SCORE] = 0.; }