|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1982 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that the above copyright notice and this paragraph are ! 7: * duplicated in all such forms and that any documentation, ! 8: * advertising materials, and other materials related to such ! 9: * distribution and use acknowledge that the software was developed ! 10: * by the University of California, Berkeley. The name of the ! 11: * University may not be used to endorse or promote products derived ! 12: * from this software without specific prior written permission. ! 13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 16: */ ! 17: ! 18: #ifndef lint ! 19: static char sccsid[] = "@(#)init.c 5.3 (Berkeley) 6/18/88"; ! 20: #endif /* not lint */ ! 21: ! 22: # include "mille.h" ! 23: ! 24: /* ! 25: * @(#)init.c 1.1 (Berkeley) 4/1/82 ! 26: */ ! 27: ! 28: init() { ! 29: ! 30: reg PLAY *pp; ! 31: reg int i, j; ! 32: reg CARD card; ! 33: ! 34: bzero(Numseen, sizeof Numseen); ! 35: Numgos = 0; ! 36: ! 37: for (i = 0; i < 2; i++) { ! 38: pp = &Player[i]; ! 39: pp->hand[0] = C_INIT; ! 40: for (j = 0; j < NUM_SAFE; j++) { ! 41: pp->safety[j] = S_UNKNOWN; ! 42: pp->coups[j] = FALSE; ! 43: } ! 44: for (j = 1; j < HAND_SZ; j++) { ! 45: pp->hand[j] = *--Topcard; ! 46: if (i == COMP) { ! 47: account(card = *Topcard); ! 48: if (issafety(card)) ! 49: pp->safety[card - S_CONV] = S_IN_HAND; ! 50: } ! 51: } ! 52: pp->mileage = 0; ! 53: pp->hand_tot = 0; ! 54: pp->safescore = 0; ! 55: pp->coupscore = 0; ! 56: pp->can_go = FALSE; ! 57: pp->speed = C_INIT; ! 58: pp->battle = C_INIT; ! 59: pp->new_speed = FALSE; ! 60: pp->new_battle = FALSE; ! 61: for (j = 0; j < NUM_MILES; j++) ! 62: pp->nummiles[j] = 0; ! 63: } ! 64: if (Order) ! 65: sort(Player[PLAYER].hand); ! 66: Discard = C_INIT; ! 67: Finished = FALSE; ! 68: End = 700; ! 69: } ! 70: ! 71: shuffle() { ! 72: ! 73: reg int i, r; ! 74: reg CARD temp; ! 75: ! 76: for (i = 0; i < DECK_SZ; i++) { ! 77: r = roll(1, DECK_SZ) - 1; ! 78: if (r < 0 || r > DECK_SZ - 1) { ! 79: fprintf(stderr, "shuffle: card no. error: %d\n", r); ! 80: die(); ! 81: } ! 82: temp = Deck[r]; ! 83: Deck[r] = Deck[i]; ! 84: Deck[i] = temp; ! 85: } ! 86: Topcard = &Deck[DECK_SZ]; ! 87: } ! 88: ! 89: newboard() { ! 90: ! 91: register int i; ! 92: register PLAY *pp; ! 93: static int first = TRUE; ! 94: ! 95: if (first) { ! 96: werase(Board); ! 97: werase(Score); ! 98: mvaddstr(5, 0, "--HAND--"); ! 99: mvaddch(6, 0, 'P'); ! 100: mvaddch(7, 0, '1'); ! 101: mvaddch(8, 0, '2'); ! 102: mvaddch(9, 0, '3'); ! 103: mvaddch(10, 0, '4'); ! 104: mvaddch(11, 0, '5'); ! 105: mvaddch(12, 0, '6'); ! 106: mvaddstr(13, 0, "--BATTLE--"); ! 107: mvaddstr(15, 0, "--SPEED--"); ! 108: mvaddstr(5, 20, "--DECK--"); ! 109: mvaddstr(7, 20, "--DISCARD--"); ! 110: mvaddstr(13, 20, "--BATTLE--"); ! 111: mvaddstr(15, 20, "--SPEED--"); ! 112: mvwaddstr(Miles, 0, 0, "--MILEAGE--"); ! 113: mvwaddstr(Miles, 0, 41, "--MILEAGE--"); ! 114: Sh_discard = -1; ! 115: for (pp = Player; pp <= &Player[COMP]; pp++) { ! 116: for (i = 0; i < HAND_SZ; i++) ! 117: pp->sh_hand[i] = -1; ! 118: pp->sh_battle = -1; ! 119: pp->sh_speed = -1; ! 120: pp->sh_mileage = -1; ! 121: } ! 122: first = FALSE; ! 123: } ! 124: else { ! 125: for (i = 0; i < 5; i++) { ! 126: move(i, 0); ! 127: clrtoeol(); ! 128: } ! 129: wmove(Miles, 1, 0); ! 130: wclrtobot(Miles); ! 131: wmove(Board, MOVE_Y + 1, MOVE_X); ! 132: wclrtoeol(Board); ! 133: wmove(Board, MOVE_Y + 2, MOVE_X); ! 134: wclrtoeol(Board); ! 135: } ! 136: Sh_discard = -1; ! 137: for (pp = Player; pp <= &Player[COMP]; pp++) { ! 138: for (i = 0; i < NUM_SAFE; i++) ! 139: pp->sh_safety[i] = FALSE; ! 140: for (i = 0; i < NUM_MILES; i++) ! 141: pp->sh_nummiles[i] = 0; ! 142: pp->sh_safescore = -1; ! 143: } ! 144: newscore(); ! 145: } ! 146: ! 147: newscore() { ! 148: ! 149: reg int i, new; ! 150: register PLAY *pp; ! 151: static int was_full = -1; ! 152: static int last_win = -1; ! 153: ! 154: if (was_full < 0) ! 155: was_full = (Window != W_FULL); ! 156: stdscr = Score; ! 157: move(0, 22); ! 158: new = FALSE; ! 159: if (inch() != 'Y') { ! 160: erase(); ! 161: mvaddstr(0, 22, "You Comp Value"); ! 162: mvaddstr(1, 2, "Milestones Played"); ! 163: mvaddstr(2, 8, "Each Safety"); ! 164: mvaddstr(3, 5, "All 4 Safeties"); ! 165: mvaddstr(4, 3, "Each Coup Fourre"); ! 166: mvaddstr(2, 37, "100"); ! 167: mvaddstr(3, 37, "300"); ! 168: mvaddstr(4, 37, "300"); ! 169: new = TRUE; ! 170: } ! 171: else if (((Window == W_FULL || Finished) ^ was_full) || ! 172: pp->was_finished != Finished) { ! 173: move(5, 1); ! 174: clrtobot(); ! 175: new = TRUE; ! 176: } ! 177: else if (Window != last_win) ! 178: new = TRUE; ! 179: if (new) { ! 180: for (i = 0; i < SCORE_Y; i++) ! 181: mvaddch(i, 0, '|'); ! 182: move(SCORE_Y - 1, 1); ! 183: while (addch('_') != ERR) ! 184: continue; ! 185: for (pp = Player; pp <= &Player[COMP]; pp++) { ! 186: pp->sh_hand_tot = -1; ! 187: pp->sh_total = -1; ! 188: pp->sh_games = -1; ! 189: pp->sh_safescore = -1; ! 190: } ! 191: } ! 192: Player[PLAYER].was_finished = !Finished; ! 193: Player[COMP].was_finished = !Finished; ! 194: if (Window == W_FULL || Finished) { ! 195: if (!was_full || new) { ! 196: mvaddstr(5, 5, "Trip Completed"); ! 197: mvaddstr(6, 10, "Safe Trip"); ! 198: mvaddstr(7, 5, "Delayed Action"); ! 199: mvaddstr(8, 10, "Extension"); ! 200: mvaddstr(9, 11, "Shut-Out"); ! 201: mvaddstr(10, 21, "---- ---- -----"); ! 202: mvaddstr(11, 9, "Hand Total"); ! 203: mvaddstr(12, 20, "----- -----"); ! 204: mvaddstr(13, 6, "Overall Total"); ! 205: mvaddstr(14, 15, "Games"); ! 206: mvaddstr(5, 37, "400"); ! 207: mvaddstr(6, 37, "300"); ! 208: mvaddstr(7, 37, "300"); ! 209: mvaddstr(8, 37, "200"); ! 210: mvaddstr(9, 37, "500"); ! 211: } ! 212: } ! 213: else ! 214: if (was_full || new) { ! 215: mvaddstr(5, 21, "---- ---- -----"); ! 216: mvaddstr(6, 9, "Hand Total"); ! 217: mvaddstr(7, 20, "----- -----"); ! 218: mvaddstr(8, 6, "Overall Total"); ! 219: mvaddstr(9, 15, "Games"); ! 220: mvaddstr(11, 2, "p: pick"); ! 221: mvaddstr(12, 2, "u: use #"); ! 222: mvaddstr(13, 2, "d: discard #"); ! 223: mvaddstr(14, 2, "w: toggle window"); ! 224: mvaddstr(11, 21, "q: quit"); ! 225: if (!Order) ! 226: mvaddstr(12, 21, "o: order hand"); ! 227: else ! 228: mvaddstr(12, 21, "o: stop ordering"); ! 229: mvaddstr(13, 21, "s: save"); ! 230: mvaddstr(14, 21, "r: reprint"); ! 231: } ! 232: stdscr = Board; ! 233: was_full = (Window == W_FULL || Finished); ! 234: last_win = Window; ! 235: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.