home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / games / volume15 / reversi2 / part02 / fini.c < prev    next >
Text File  |  1993-01-27  |  599b  |  32 lines

  1. /*
  2.  *    fini.c
  3.  *
  4.  *    count up score and display winner
  5.  */
  6.  
  7. # include    "reversi.h"
  8.  
  9. fini (board)
  10. boardT    board;
  11. {
  12.     register int    x,y;
  13.     register int    wscore, bscore;
  14.     char            sbuf[80];
  15.  
  16.     wscore = bscore = 0;
  17.  
  18.     for (x = 1; x <= SIZE; x++)
  19.         for (y = 1; y <= SIZE; y++)
  20.             if (board[x][y] == WHITE)
  21.                 ++wscore;
  22.             else if (board[x][y] == BLACK)
  23.                 ++bscore;
  24.     if (wscore > bscore)
  25.         sprintf (sbuf, "white wins %d to %d.", wscore, bscore);
  26.     else if (bscore > wscore)
  27.         sprintf (sbuf, "black wins %d to %d.", bscore, wscore);
  28.     else
  29.         sprintf (sbuf, "tie game %d to %d.", wscore, bscore);
  30.     dispError (sbuf);
  31. }
  32.