1: # include   "mille.h"
   2: 
   3: /*
   4:  * @(#)init.c	1.1 (Berkeley) 4/1/82
   5:  */
   6: 
   7: init() {
   8: 
   9:     reg PLAY    *pp;
  10:     reg int     i, j;
  11:     reg CARD    card;
  12: 
  13:     bzero(Numseen, sizeof Numseen);
  14:     Numgos = 0;
  15: 
  16:     for (i = 0; i < 2; i++) {
  17:         pp = &Player[i];
  18:         pp->hand[0] = C_INIT;
  19:         for (j = 0; j < NUM_SAFE; j++) {
  20:             pp->safety[j] = S_UNKNOWN;
  21:             pp->coups[j] = FALSE;
  22:         }
  23:         for (j = 1; j < HAND_SZ; j++) {
  24:             pp->hand[j] = *--Topcard;
  25:             if (i == COMP) {
  26:                 account(card = *Topcard);
  27:                 if (issafety(card))
  28:                     pp->safety[card - S_CONV] = S_IN_HAND;
  29:             }
  30:         }
  31:         pp->mileage = 0;
  32:         pp->hand_tot = 0;
  33:         pp->safescore = 0;
  34:         pp->coupscore = 0;
  35:         pp->can_go = FALSE;
  36:         pp->speed = C_INIT;
  37:         pp->battle = C_INIT;
  38:         pp->new_speed = FALSE;
  39:         pp->new_battle = FALSE;
  40:         for (j = 0; j < NUM_MILES; j++)
  41:             pp->nummiles[j] = 0;
  42:     }
  43:     if (Order)
  44:         sort(Player[PLAYER].hand);
  45:     Discard = C_INIT;
  46:     Finished = FALSE;
  47:     End = 700;
  48: }
  49: 
  50: shuffle() {
  51: 
  52:     reg int     i, r;
  53:     reg CARD    temp;
  54: 
  55:     for (i = 0; i < DECK_SZ; i++) {
  56:         r = roll(1, DECK_SZ) - 1;
  57:         if (r < 0 || r > DECK_SZ - 1) {
  58:             fprintf(stderr, "shuffle: card no. error: %d\n", r);
  59:             die();
  60:         }
  61:         temp = Deck[r];
  62:         Deck[r] = Deck[i];
  63:         Deck[i] = temp;
  64:     }
  65:     Topcard = &Deck[DECK_SZ];
  66: }
  67: 
  68: newboard() {
  69: 
  70:     register int    i;
  71:     register PLAY   *pp;
  72:     static int  first = TRUE;
  73: 
  74:     if (first) {
  75:         werase(Board);
  76:         werase(Score);
  77:         mvaddstr(5, 0, "--HAND--");
  78:         mvaddch(6, 0, 'P');
  79:         mvaddch(7, 0, '1');
  80:         mvaddch(8, 0, '2');
  81:         mvaddch(9, 0, '3');
  82:         mvaddch(10, 0, '4');
  83:         mvaddch(11, 0, '5');
  84:         mvaddch(12, 0, '6');
  85:         mvaddstr(13, 0, "--BATTLE--");
  86:         mvaddstr(15, 0, "--SPEED--");
  87:         mvaddstr(5, 20, "--DECK--");
  88:         mvaddstr(7, 20, "--DISCARD--");
  89:         mvaddstr(13, 20, "--BATTLE--");
  90:         mvaddstr(15, 20, "--SPEED--");
  91:         mvwaddstr(Miles, 0, 0, "--MILEAGE--");
  92:         mvwaddstr(Miles, 0, 41, "--MILEAGE--");
  93:         Sh_discard = -1;
  94:         for (pp = Player; pp <= &Player[COMP]; pp++) {
  95:             for (i = 0; i < HAND_SZ; i++)
  96:                 pp->sh_hand[i] = -1;
  97:             pp->sh_battle = -1;
  98:             pp->sh_speed = -1;
  99:             pp->sh_mileage = -1;
 100:         }
 101:         first = FALSE;
 102:     }
 103:     else {
 104:         for (i = 0; i < 5; i++) {
 105:             move(i, 0);
 106:             clrtoeol();
 107:         }
 108:         wmove(Miles, 1, 0);
 109:         wclrtobot(Miles);
 110:         wmove(Board, MOVE_Y + 1, MOVE_X);
 111:         wclrtoeol(Board);
 112:         wmove(Board, MOVE_Y + 2, MOVE_X);
 113:         wclrtoeol(Board);
 114:     }
 115:     Sh_discard = -1;
 116:     for (pp = Player; pp <= &Player[COMP]; pp++) {
 117:         for (i = 0; i < NUM_SAFE; i++)
 118:             pp->sh_safety[i] = FALSE;
 119:         for (i = 0; i < NUM_MILES; i++)
 120:             pp->sh_nummiles[i] = 0;
 121:         pp->sh_safescore = -1;
 122:     }
 123:     newscore();
 124: }
 125: 
 126: newscore() {
 127: 
 128:     reg int     i, new;
 129:     register PLAY   *pp;
 130:     static int  was_full = -1;
 131:     static int  last_win = -1;
 132: 
 133:     if (was_full < 0)
 134:         was_full = (Window != W_FULL);
 135:     stdscr = Score;
 136:     move(0, 22);
 137:     new = FALSE;
 138:     if (inch() != 'Y') {
 139:         erase();
 140:         mvaddstr(0, 22,  "You   Comp   Value");
 141:         mvaddstr(1, 2, "Milestones Played");
 142:         mvaddstr(2, 8, "Each Safety");
 143:         mvaddstr(3, 5, "All 4 Safeties");
 144:         mvaddstr(4, 3, "Each Coup Fourre");
 145:         mvaddstr(2, 37, "100");
 146:         mvaddstr(3, 37, "300");
 147:         mvaddstr(4, 37, "300");
 148:         new = TRUE;
 149:     }
 150:     else if (((Window == W_FULL || Finished) ^ was_full) ||
 151:          pp->was_finished != Finished) {
 152:         move(5, 1);
 153:         clrtobot();
 154:         new = TRUE;
 155:     }
 156:     else if (Window != last_win)
 157:         new = TRUE;
 158:     if (new) {
 159:         for (i = 0; i < SCORE_Y; i++)
 160:             mvaddch(i, 0, '|');
 161:         move(SCORE_Y - 1, 1);
 162:         while (addch('_') != ERR)
 163:             continue;
 164:         for (pp = Player; pp <= &Player[COMP]; pp++) {
 165:             pp->sh_hand_tot = -1;
 166:             pp->sh_total = -1;
 167:             pp->sh_games = -1;
 168:             pp->sh_safescore = -1;
 169:         }
 170:     }
 171:     Player[PLAYER].was_finished = !Finished;
 172:     Player[COMP].was_finished = !Finished;
 173:     if (Window == W_FULL || Finished) {
 174:         if (!was_full || new) {
 175:             mvaddstr(5, 5, "Trip Completed");
 176:             mvaddstr(6, 10, "Safe Trip");
 177:             mvaddstr(7, 5, "Delayed Action");
 178:             mvaddstr(8, 10, "Extension");
 179:             mvaddstr(9, 11, "Shut-Out");
 180:             mvaddstr(10, 21, "----   ----   -----");
 181:             mvaddstr(11, 9, "Hand Total");
 182:             mvaddstr(12, 20, "-----  -----");
 183:             mvaddstr(13, 6, "Overall Total");
 184:             mvaddstr(14, 15, "Games");
 185:             mvaddstr(5, 37, "400");
 186:             mvaddstr(6, 37, "300");
 187:             mvaddstr(7, 37, "300");
 188:             mvaddstr(8, 37, "200");
 189:             mvaddstr(9, 37, "500");
 190:         }
 191:     }
 192:     else
 193:         if (was_full || new) {
 194:             mvaddstr(5, 21, "----   ----   -----");
 195:             mvaddstr(6, 9, "Hand Total");
 196:             mvaddstr(7, 20, "-----  -----");
 197:             mvaddstr(8, 6, "Overall Total");
 198:             mvaddstr(9, 15, "Games");
 199:             mvaddstr(11, 2, "p: pick");
 200:             mvaddstr(12, 2, "u: use #");
 201:             mvaddstr(13, 2, "d: discard #");
 202:             mvaddstr(14, 2, "w: toggle window");
 203:             mvaddstr(11, 21, "q: quit");
 204:             if (!Order)
 205:                 mvaddstr(12, 21, "o: order hand");
 206:             else
 207:                 mvaddstr(12, 21, "o: stop ordering");
 208:             mvaddstr(13, 21, "s: save");
 209:             mvaddstr(14, 21, "r: reprint");
 210:         }
 211:     stdscr = Board;
 212:     was_full = (Window == W_FULL || Finished);
 213:     last_win = Window;
 214: }

Defined functions

init defined in line 7; used 1 times
newboard defined in line 68; used 1 times
newscore defined in line 126; used 4 times
shuffle defined in line 50; used 1 times
Last modified: 1985-11-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3688
Valid CSS Valid XHTML 1.0 Strict