|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T b
Length: 2872 (0xb38) Types: TextFile Names: »board.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Dots/board.c«
/* board.c routines that deal with the playing board's display or data */ #include "dots.h" setup() { Length = Width = 0; comptally = persontally = 0; xposit = 2, yposit = 1; mvprintw(LINES - 6, 0, "Enter LENGTH of board (%d - %d).", (level == DUMB)? MINL : H_MINL, MAXL); do { mvaddstr(LINES - 4, 0, "->> "), clrtoeol(), refresh(); x_start = COLS / 2 - (Length = get_dimensions()) * 2; } while (Length > MAXL || (level == DUMB && Length < MINL) || (level != DUMB && Length < H_MINL)); mvprintw(LINES - 6, 0, "Enter WIDTH of board (%d - %d).", (level==DUMB)? MINW:H_MINW, MAXW), clrtoeol(); do { mvaddstr(LINES - 4, 0, "->> "), clrtoeol(), refresh(); y_start = LINES / 2 - (Width = get_dimensions()); } while (Width > MAXW || (level == DUMB && Width < MINW) || (level != DUMB && Width < H_MINW)); mvprintw(LINES - 6, 0, "Length is %d, width is %d.", Length, Width); clrtoeol(), refresh(); if (mode == INTERACTIVE) mvprintw(LINES-4, 0, "Your boxes will be initialed with \"%c\"",Initial[US]), clrtoeol(); msg("Hit any key to continue. "); getchar(); } free_board() { register int x, y; for (x = 0; x <= Length * 2; ++x) for (y = 0; y <= Width * 2; ++y) board[x][y] = FREE; no_good_moves = control_already_established = 0; } get_dimensions() { char string[10]; register char c; register int place_on_line = 0, x = 0; string[0] = '\0'; move(LINES - 4, 4), clrtoeol(); refresh(); while ((c = getchar()) != '\n') { if (c == erase_char || c == '\027') if (place_on_line != 0) { string[--x] = '\0'; --place_on_line; addstr("\b \b"); refresh(); } else continue; else if (isdigit(c)) { if (place_on_line == 4) continue; place_on_line++; addch(string[x++] = c); refresh(); } } string[x] = '\0'; return atoi(string); } drawboard() { register int x, y; clear(); for (y = 1; y < 2 * Width; y++) for (x = 1; x < 2 * Length; x++) { move(y_start + (y - 1), x_start + (2 * x - 2)); if (iseven(x) && isodd(y) && board[x][y] == USED) addstr("\b---\b\b"); if (iseven(y) && isodd(x) && board[x][y] == USED) addch('|'); else if (iseven(x) && iseven(y) && closure(GOOD, x, y) == 4) { if (board[x][y] == 1) mover = 1; else mover = 0; putinitial(x, y); } else if (isodd(x) && isodd(y)) addch('*'); } if (mode == TWOPLAYER) { mvaddstr(LINES - 3, 0, "Your Messages: "); mvprintw(LINES - 2, 0, "%s's Messages: ", opponent); } } chlevel(c) { if (!sure(c)) return; level = (level + 1) % 3; bottom_line(); } sure(c) char c; { register int count; register char C; for (count = 0; count <= 3; ++count) if ((C = getchar()) != c) { ungetc(C, stdin); return FALSE; } return TRUE; }