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 >
Wrap
Text File
|
1988-07-28
|
1KB
|
55 lines
/* finish.c
* contains tasks to complete at the end of each game.
*/
#include "defs.h"
#include <curses.h>
#define BONUS 35
#define BONUS_TARGET 63
extern int scoreboard[max_players][max_marks];
extern int subtotals[max_players];
extern WINDOW *screen;
finish(totals, player_count)
int totals[max_players], player_count;
{
int i, categories1_6, categories7_13, player, col, best_player = 0;
for (player = 0; player < player_count; ++player)
{
categories7_13 = 0;
col = player * 10 + 25;
/* if the player's score in the categories 1 to 6 is greater than or equal to
* BONUS_TARGET then award BONUS */
categories1_6 = subtotals[player];
if (categories1_6 >= BONUS_TARGET)
{
categories1_6 += BONUS;
wmove(screen, 21, col);
wprintw(screen, "%3d", BONUS);
}
totals[player] = categories1_6;
/* sum the rest of the player's score */
for (i = 7; i <= 13; ++i)
categories7_13 += scoreboard[player][i];
/* display sub-total for categories 7 to 13 */
mvwprintw(screen, 22, col, "%3d", categories7_13);
totals[player] += categories7_13;
if (totals[player] > totals[best_player])
best_player = player;
/* display player's score for the game */
mvwprintw(screen, 23, col, "%3d", totals[player]);
}
/* return the number of the player with the best score (for update of
* the high score file) */
return(best_player);
}