static int GameOver(void) { int anFinalScore[2]; int nMatch; const listOLD* firstGame = lMatch.plNext->p; if (firstGame) { const moverecord* pmr = firstGame->plNext->p; if (pmr) { g_assert(pmr->mt == MOVE_GAMEINFO); nMatch = pmr->g.nMatch; if (ms.nMatchTo) { /* Match - check someone has won */ return (getFinalScore(anFinalScore) && ((anFinalScore[0] >= nMatch) || (anFinalScore[1] >= nMatch))); } else { /* Session - check game over */ return (ms.gs == GAME_OVER); } } } return FALSE; }
static int MatchResult(int nMatchTo) { /* Work out the result (-1,0,1) - (p0 win, unfinished, p1 win) */ int result = 0; int anFinalScore[2]; if (nMatchTo && getFinalScore(anFinalScore)) { if (anFinalScore[0] > nMatchTo) result = -1; else if (anFinalScore[1] > nMatchTo) result = 1; } return result; }
void printStadistics(){ FILE *file; int i = 0, cont=0; char line[300]; file = fopen("scores.txt","r"); if (file == NULL){ printf("\nError de apertura del archivo. \n\n"); }else{ printf("\n\n"); printf("\t\t\t STADISTICS\n"); while (feof(file) == 0){ fgets(line,300,file); cont++; getFinalScore(line, cont); //printf("%s", line); } } fclose(file); }