jail.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* $NetBSD: jail.c,v 1.6 2003/08/07 09:37:28 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[] = "@(#)jail.c 8.1 (Berkeley) 5/31/93";
  34. #else
  35. __RCSID("$NetBSD: jail.c,v 1.6 2003/08/07 09:37:28 agc Exp $");
  36. #endif
  37. #endif /* not lint */
  38. #include "monop.ext"
  39. /*
  40. * This routine uses a get-out-of-jail-free card to get the
  41. * player out of jail.
  42. */
  43. void
  44. card()
  45. {
  46. if (cur_p->loc != JAIL) {
  47. printf("But you're not IN Jail\n");
  48. return;
  49. }
  50. if (cur_p->num_gojf == 0) {
  51. printf("But you don't HAVE a get out of jail free card\n");
  52. return;
  53. }
  54. ret_card(cur_p);
  55. cur_p->loc = 10; /* just visiting */
  56. cur_p->in_jail = 0;
  57. }
  58. /*
  59. * This routine returns the players get-out-of-jail-free card
  60. * to a deck.
  61. */
  62. void
  63. ret_card(plr)
  64. PLAY *plr;
  65. {
  66. plr->num_gojf--;
  67. if (CC_D.gojf_used)
  68. CC_D.gojf_used = FALSE;
  69. else
  70. CH_D.gojf_used = FALSE;
  71. }
  72. /*
  73. * This routine deals with paying your way out of jail.
  74. */
  75. void
  76. pay()
  77. {
  78. if (cur_p->loc != JAIL) {
  79. printf("But you're not IN Jail\n");
  80. return;
  81. }
  82. cur_p->loc = 10;
  83. cur_p->money -= 50;
  84. cur_p->in_jail = 0;
  85. printf("That cost you $50\n");
  86. }
  87. /*
  88. * This routine deals with a move in jail
  89. */
  90. int
  91. move_jail(r1, r2)
  92. int r1, r2;
  93. {
  94. if (r1 != r2) {
  95. printf("Sorry, that doesn't get you out\n");
  96. if (++(cur_p->in_jail) == 3) {
  97. printf("It's your third turn and you didn't roll "
  98. "doubles. You have to pay $50\n");
  99. cur_p->money -= 50;
  100. moveit:
  101. cur_p->loc = 10;
  102. cur_p->in_jail = 0;
  103. move(r1+r2);
  104. r1 = r2 - 1; /* kludge: stop new roll w/doub */
  105. return TRUE;
  106. }
  107. return FALSE;
  108. }
  109. else {
  110. printf("Double roll gets you out.\n");
  111. goto moveit;
  112. }
  113. }
  114. void
  115. printturn()
  116. {
  117. if (cur_p->loc != JAIL)
  118. return;
  119. printf("(This is your ");
  120. switch (cur_p->in_jail) {
  121. case 0:
  122. printf("1st");
  123. break;
  124. case 1:
  125. printf("2nd");
  126. break;
  127. case 2:
  128. printf("3rd (and final)");
  129. break;
  130. }
  131. printf(" turn in JAIL)\n");
  132. }