end.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /* $NetBSD: end.c,v 1.7 2003/08/07 09:37:25 agc Exp $ */
  2. /*
  3. * Copyright (c) 1982, 1993
  4. * The Regents of the University of California. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the University nor the names of its contributors
  15. * may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  22. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. */
  30. #include <sys/cdefs.h>
  31. #ifndef lint
  32. #if 0
  33. static char sccsid[] = "@(#)end.c 8.1 (Berkeley) 5/31/93";
  34. #else
  35. __RCSID("$NetBSD: end.c,v 1.7 2003/08/07 09:37:25 agc Exp $");
  36. #endif
  37. #endif /* not lint */
  38. # include "mille.h"
  39. /*
  40. * @(#)end.c 1.1 (Berkeley) 4/1/82
  41. */
  42. /*
  43. * print out the score as if it was final, and add the totals for
  44. * the end-of-games points to the user who deserves it (if any).
  45. */
  46. void
  47. finalscore(pp)
  48. PLAY *pp;
  49. {
  50. int temp, tot, num;
  51. if (pp->was_finished == Finished)
  52. return;
  53. pp->was_finished = Finished;
  54. num = pp - Player;
  55. temp = num * 6 + 21 + 1;
  56. for (tot = 5; tot <= 9; tot++)
  57. mvaddstr(tot, temp, " 0");
  58. if (pp->mileage == End) {
  59. mvaddstr(5, temp, "40");
  60. tot = SC_TRIP;
  61. if (pp->nummiles[C_200] == 0) {
  62. mvaddstr(6, temp, "30");
  63. tot = SC_TRIP + SC_SAFE;
  64. }
  65. if (Topcard <= Deck) {
  66. mvaddstr(7, temp, "30");
  67. tot += SC_DELAY;
  68. }
  69. if (End == 1000) {
  70. mvaddstr(8, temp, "20");
  71. tot += SC_EXTENSION;
  72. }
  73. if (Player[other(num)].mileage == 0) {
  74. mvaddstr(9, temp, "50");
  75. tot += SC_SHUT_OUT;
  76. }
  77. pp->total += tot;
  78. pp->hand_tot += tot;
  79. }
  80. }
  81. # ifdef EXTRAP
  82. static int Last_tot[2]; /* last tot used for extrapolate */
  83. /*
  84. * print out the score as if it was final, and add the totals for
  85. * the end-of-games points to the user who deserves it (if any).
  86. */
  87. extrapolate(pp)
  88. reg PLAY *pp; {
  89. reg int x, num, tot, count;
  90. num = pp - Player;
  91. tot += SC_TRIP + SC_DELAY + SC_EXT;
  92. x = num * 6 + 21 + 3;
  93. for (tot = 5; tot <= 9; tot++)
  94. mvaddch(tot, x, '0');
  95. x -= 2;
  96. pp = &Player[other(num)];
  97. for (count = 0, tot = 0; tot < NUM_SAFE; tot++)
  98. if (pp->safety[tot] != S_PLAYED)
  99. count += SC_SAFE;
  100. mvprintw(3, x, "%3d", count);
  101. tot += count;
  102. if (count == 400) {
  103. mvaddstr(4, x, "30");
  104. tot += SC_ALL_SAFE;
  105. }
  106. pp = &Player[num];
  107. for (count = 0, tot = 0; tot < NUM_SAFE; tot++)
  108. if (pp->safety[tot] != S_PLAYED)
  109. count += SC_COUP / 10;
  110. mvprintw(4, x - 1, "%3d", count);
  111. tot += count;
  112. tot += 1000 - pp->mileage;
  113. mvaddstr(5, x, "40");
  114. mvaddstr(7, x, "30");
  115. mvaddstr(8, x, "20");
  116. if (pp->nummiles[C_200] == 0) {
  117. mvaddstr(6, x, "30");
  118. tot = SC_TRIP + SC_SAFE;
  119. }
  120. if (Player[other(num)].mileage == 0) {
  121. mvaddstr(9, x, "50");
  122. tot += SC_SHUT_OUT;
  123. }
  124. pp->total += tot;
  125. pp->hand_tot += tot;
  126. Last_tot[num] = tot;
  127. }
  128. undoex() {
  129. reg PLAY *pp;
  130. reg int i;
  131. i = 0;
  132. for (pp = Player; pp < &Player[2]; pp++) {
  133. pp->total -= Last_tot[i];
  134. pp->hand_tot -= Last_tot[i++];
  135. }
  136. }
  137. # endif