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