void shoot() { extern void check_shot(), move_wumpus(); int j9; finished = NOT; badrange: j9 = getnum("No. of rooms (1-5)"); if (j9 < 1 || j9 > 5) goto badrange; for (k = 0; k < j9; k++) { path[k] = getnum("Room #") - 1; if (k <= 1) continue; if (path[k] != path[k - 2]) continue; (void) puts("Arrows aren't that crooked - Try another room"); k--; } scratchloc = loc[YOU]; for (k = 0; k < j9; k++) { int k1; for (k1 = 0; k1 < 3; k1++) { if (cave[scratchloc][k1] == path[k]) { scratchloc = path[k]; check_shot(); if (finished != NOT) return; } } scratchloc = cave[scratchloc][FNB()]; check_shot(); } if (finished == NOT) { (void) puts("Missed"); scratchloc = loc[YOU]; move_wumpus(); if (--arrows <= 0) finished = LOSE; } }
void shot_attempt (char board[10][10], Player *player) { int row = 0, col = 0, hit = -1; while(hit < 0) { printf("\nx and y coordinate to shoot: "); scanf("%d %d", &row, &col); check_shot(board, row, col, &hit, player); } if (hit > 0){ player->player_stats.num_hits++; } else if (hit == 0){ player->player_stats.num_misses++; } }
void shot_attempt_random (char board[10][10], Player *player2) { int row = 0, col = 0, hit = -1; while(hit < 0) { row = rand() % 10; col = rand() % 10; printf("\nComputer fires at: %d, %d\n", row, col); check_shot(board, row, col, &hit, player2); } if (hit > 0){ player2->player_stats.num_hits++; } else if (hit == 0){ player2->player_stats.num_misses++; } }
void shot_attempt_blind (char board[10][10], char board_blind[10][10], Player *player1) { int row = 0, col = 0, hit = -1; while(hit < 0) { printf("\nx and y coordinate to shoot: "); scanf("%d %d", &row, &col); check_shot(board, row, col, &hit, player1); } if (hit == 1) { board_blind[col][row] = 'X'; } else { board_blind[col][row] = 'O'; } }