score.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* $NetBSD: score.c,v 1.5 2003/08/07 09:37:54 agc Exp $ */
  2. /*
  3. * Copyright (c) 1980, 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[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
  34. #else
  35. __RCSID("$NetBSD: score.c,v 1.5 2003/08/07 09:37:54 agc Exp $");
  36. #endif
  37. #endif /* not lint */
  38. #include <stdio.h>
  39. #include "trek.h"
  40. #include "getpar.h"
  41. /*
  42. ** PRINT OUT THE CURRENT SCORE
  43. */
  44. long score()
  45. {
  46. int u;
  47. int t;
  48. long s;
  49. double r;
  50. printf("\n*** Your score:\n");
  51. s = t = Param.klingpwr / 4 * (u = Game.killk);
  52. if (t != 0)
  53. printf("%d Klingons killed\t\t\t%6d\n", u, t);
  54. r = Now.date - Param.date;
  55. if (r < 1.0)
  56. r = 1.0;
  57. r = Game.killk / r;
  58. s += (t = 400 * r);
  59. if (t != 0)
  60. printf("Kill rate %.2f Klingons/stardate \t%6d\n", r, t);
  61. r = Now.klings;
  62. r /= Game.killk + 1;
  63. s += (t = -400 * r);
  64. if (t != 0)
  65. printf("Penalty for %d klingons remaining\t%6d\n", Now.klings, t);
  66. if (Move.endgame > 0)
  67. {
  68. s += (t = 100 * (u = Game.skill));
  69. printf("Bonus for winning a %s%s game\t\t%6d\n", Skitab[u - 1].abrev, Skitab[u - 1].full, t);
  70. }
  71. if (Game.killed)
  72. {
  73. s -= 500;
  74. printf("Penalty for getting killed\t\t -500\n");
  75. }
  76. s += (t = -100 * (u = Game.killb));
  77. if (t != 0)
  78. printf("%d starbases killed\t\t\t%6d\n", u, t);
  79. s += (t = -100 * (u = Game.helps));
  80. if (t != 0)
  81. printf("%d calls for help\t\t\t%6d\n", u, t);
  82. s += (t = -5 * (u = Game.kills));
  83. if (t != 0)
  84. printf("%d stars destroyed\t\t\t%6d\n", u, t);
  85. s += (t = -150 * (u = Game.killinhab));
  86. if (t != 0)
  87. printf("%d inhabited starsystems destroyed\t%6d\n", u, t);
  88. if (Ship.ship != ENTERPRISE)
  89. {
  90. s -= 200;
  91. printf("penalty for abandoning ship\t\t -200\n");
  92. }
  93. s += (t = 3 * (u = Game.captives));
  94. if (t != 0)
  95. printf("%d Klingons captured\t\t\t%6d\n", u, t);
  96. s += (t = -(u = Game.deaths));
  97. if (t != 0)
  98. printf("%d casualties\t\t\t\t%6d\n", u, t);
  99. printf("\n*** TOTAL\t\t\t%14ld\n", s);
  100. return (s);
  101. }