home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / TOP / USR / SRC / yahtzee.t.Z / yahtzee.t / finish.c < prev    next >
Text File  |  1988-07-28  |  1KB  |  55 lines

  1. /* finish.c
  2.  *    contains tasks to complete at the end of each game.
  3.  */
  4. #include "defs.h"
  5. #include <curses.h>
  6.  
  7. #define BONUS 35
  8. #define BONUS_TARGET 63
  9.  
  10. extern int scoreboard[max_players][max_marks];
  11. extern int subtotals[max_players];
  12. extern WINDOW *screen;
  13.  
  14. finish(totals, player_count)
  15.  
  16. int totals[max_players], player_count;
  17.  
  18.     {
  19.     int i, categories1_6, categories7_13, player, col, best_player = 0;
  20.  
  21.     for (player = 0; player < player_count; ++player)
  22.         {
  23.         categories7_13 = 0;
  24.         col = player * 10 + 25;
  25.  
  26. /* if the player's score in the categories 1 to 6 is greater than or equal to
  27.  * BONUS_TARGET then award BONUS */
  28.         categories1_6 = subtotals[player];
  29.         if (categories1_6 >= BONUS_TARGET)
  30.             {
  31.             categories1_6 += BONUS;
  32.             wmove(screen, 21, col);
  33.             wprintw(screen, "%3d", BONUS);
  34.             }
  35.         totals[player] = categories1_6;
  36.  
  37. /* sum the rest of the player's score */
  38.         for (i = 7; i <= 13; ++i)
  39.             categories7_13 += scoreboard[player][i];
  40.  
  41. /* display sub-total for categories 7 to 13 */
  42.         mvwprintw(screen, 22, col, "%3d", categories7_13);
  43.         totals[player] += categories7_13;
  44.         if (totals[player] > totals[best_player])
  45.             best_player = player;
  46.  
  47. /* display player's score for the game */
  48.         mvwprintw(screen, 23, col, "%3d", totals[player]);
  49.         }
  50.  
  51. /* return the number of the player with the best score (for update of
  52.  * the high score file) */
  53.     return(best_player);
  54.     }
  55.