130199Sbostic /*
2*60812Sbostic * Copyright (c) 1982, 1993
3*60812Sbostic * The Regents of the University of California. All rights reserved.
433171Sbostic *
542578Sbostic * %sccs.include.redist.c%
630199Sbostic */
730199Sbostic
830199Sbostic #ifndef lint
9*60812Sbostic static char sccsid[] = "@(#)end.c 8.1 (Berkeley) 05/31/93";
1033171Sbostic #endif /* not lint */
1130199Sbostic
1230199Sbostic # include "mille.h"
1330199Sbostic
1430199Sbostic /*
1530199Sbostic * @(#)end.c 1.1 (Berkeley) 4/1/82
1630199Sbostic */
1730199Sbostic
1830199Sbostic /*
1930199Sbostic * print out the score as if it was final, and add the totals for
2030199Sbostic * the end-of-games points to the user who deserves it (if any).
2130199Sbostic */
finalscore(pp)2230199Sbostic finalscore(pp)
2330199Sbostic reg PLAY *pp; {
2430199Sbostic
2530199Sbostic reg int temp, tot, num;
2630199Sbostic
2730199Sbostic if (pp->was_finished == Finished)
2830199Sbostic return;
2930199Sbostic
3030199Sbostic pp->was_finished = Finished;
3130199Sbostic num = pp - Player;
3230199Sbostic temp = num * 6 + 21 + 1;
3330199Sbostic for (tot = 5; tot <= 9; tot++)
3430199Sbostic mvaddstr(tot, temp, " 0");
3530199Sbostic if (pp->mileage == End) {
3630199Sbostic mvaddstr(5, temp, "40");
3730199Sbostic tot = SC_TRIP;
3830199Sbostic if (pp->nummiles[C_200] == 0) {
3930199Sbostic mvaddstr(6, temp, "30");
4030199Sbostic tot = SC_TRIP + SC_SAFE;
4130199Sbostic }
4230199Sbostic if (Topcard <= Deck) {
4330199Sbostic mvaddstr(7, temp, "30");
4430199Sbostic tot += SC_DELAY;
4530199Sbostic }
4630199Sbostic if (End == 1000) {
4730199Sbostic mvaddstr(8, temp, "20");
4830199Sbostic tot += SC_EXTENSION;
4930199Sbostic }
5030199Sbostic if (Player[other(num)].mileage == 0) {
5130199Sbostic mvaddstr(9, temp, "50");
5230199Sbostic tot += SC_SHUT_OUT;
5330199Sbostic }
5430199Sbostic pp->total += tot;
5530199Sbostic pp->hand_tot += tot;
5630199Sbostic }
5730199Sbostic }
5830199Sbostic
5930199Sbostic # ifdef EXTRAP
6030199Sbostic static int Last_tot[2]; /* last tot used for extrapolate */
6130199Sbostic
6230199Sbostic /*
6330199Sbostic * print out the score as if it was final, and add the totals for
6430199Sbostic * the end-of-games points to the user who deserves it (if any).
6530199Sbostic */
extrapolate(pp)6630199Sbostic extrapolate(pp)
6730199Sbostic reg PLAY *pp; {
6830199Sbostic
6930199Sbostic reg int x, num, tot, count;
7030199Sbostic
7130199Sbostic num = pp - Player;
7230199Sbostic tot += SC_TRIP + SC_DELAY + SC_EXT;
7330199Sbostic x = num * 6 + 21 + 3;
7430199Sbostic for (tot = 5; tot <= 9; tot++)
7530199Sbostic mvaddch(tot, x, '0');
7630199Sbostic x -= 2;
7730199Sbostic pp = &Player[other(num)];
7830199Sbostic for (count = 0, tot = 0; tot < NUM_SAFE; tot++)
7930199Sbostic if (pp->safety[tot] != S_PLAYED)
8030199Sbostic count += SC_SAFE;
8130199Sbostic mvprintw(3, x, "%3d", count);
8230199Sbostic tot += count;
8330199Sbostic if (count == 400) {
8430199Sbostic mvaddstr(4, x, "30");
8530199Sbostic tot += SC_ALL_SAFE;
8630199Sbostic }
8730199Sbostic pp = &Player[num];
8830199Sbostic for (count = 0, tot = 0; tot < NUM_SAFE; tot++)
8930199Sbostic if (pp->safety[tot] != S_PLAYED)
9030199Sbostic count += SC_COUP / 10;
9130199Sbostic mvprintw(4, x - 1, "%3d", count);
9230199Sbostic tot += count;
9330199Sbostic tot += 1000 - pp->mileage;
9430199Sbostic mvaddstr(5, x, "40");
9530199Sbostic mvaddstr(7, x, "30");
9630199Sbostic mvaddstr(8, x, "20");
9730199Sbostic if (pp->nummiles[C_200] == 0) {
9830199Sbostic mvaddstr(6, x, "30");
9930199Sbostic tot = SC_TRIP + SC_SAFE;
10030199Sbostic }
10130199Sbostic if (Player[other(num)].mileage == 0) {
10230199Sbostic mvaddstr(9, x, "50");
10330199Sbostic tot += SC_SHUT_OUT;
10430199Sbostic }
10530199Sbostic pp->total += tot;
10630199Sbostic pp->hand_tot += tot;
10730199Sbostic Last_tot[num] = tot;
10830199Sbostic }
10930199Sbostic
undoex()11030199Sbostic undoex() {
11130199Sbostic
11230199Sbostic reg PLAY *pp;
11330199Sbostic reg int i;
11430199Sbostic
11530199Sbostic i = 0;
11630199Sbostic for (pp = Player; pp < &Player[2]; pp++) {
11730199Sbostic pp->total -= Last_tot[i];
11830199Sbostic pp->hand_tot -= Last_tot[i++];
11930199Sbostic }
12030199Sbostic }
12130199Sbostic # endif
12230199Sbostic
123