/** Choose the known brick in the discard or a unknown brick in the pile. * Input: * wall: A 2D array denoting our game wall. * owall: A 2D array denoting the opponent's game wall. * discard_brick: The integer value of the known brick in the discard. * Output: * 'd': Accept the known brick in the discard. * 'p': Reject the known brick in the discard and draw from the pile. */ std::string choose_discard_or_pile(const Game::wall_type& wall, const Game::wall_type& owall, int discard_brick) { std::cout << "\nOpponent:" << std::endl; print_wall(owall, initialized); std::cout << "\nMy Wall:" << std::endl; print_wall(wall); lwall = owall; initialized = true; int replace = 0; int brick = discard_brick; // find a correctable error for(unsigned i = 0; i < wall.size(); i++) { for(unsigned j = 0; j < wall.size(); j++) { replace = wall[i][j]; if (brick <= allowed[i][j][MAX] && brick >= allowed[i][j][MIN] && (replace > allowed[i][j][MAX] || replace < allowed[i][j][MIN])) { std::cout << "Able to use " << brick << " at " << char(i+'a') << j << std::endl; return "d"; } } } std::cout << "Taking frome pile" << std::endl; return "p"; }
int main(void) { initscr(); print_board(); put_in_case(4, 0, "W"); put_in_case(4, 8, "B"); print_wall(3,3,VERTICAL); getch(); endwin(); return 0; }
void print_object(int y, int x, int c){ switch (c) { case 'b': print_brick(y, x); break; case 'w': print_water(y, x); break; case 'g': print_grass(y, x); break; case 'c': print_wall(y, x); break; case '1': print_red(y, x); break; case '2': print_blue(y, x); break; case '3': print_white(y, x); break; case 'h': print_head(y, x); break; default: print_blanko(y, x); break; } }
void bogoman_map_dump(struct bogoman_map *map) { unsigned int x, y; for (y = 0; y < map->h; y++) { for (x = 0; x < map->w; x++) { struct bogoman_map_elem *elem; elem = bogoman_get_map_elem(map, x, y); switch (elem->id) { case BOGOMAN_NONE: printf(" "); break; case BOGOMAN_PLAYER: printf("@"); break; case BOGOMAN_DIAMOND: printf("$"); break; case BOGOMAN_MOVEABLE: printf("M"); break; case BOGOMAN_EDIBLE: printf("E"); break; case BOGOMAN_WALL: print_wall(elem); break; case BOGOMAN_PARTICLE: print_particle(elem); break; } } printf("\n"); } printf("Player at %ux%u diamonds total %u\n", map->player_x, map->player_y, map->diamonds_total); }
void execute_powerups(clock_t *pw_shield_start, clock_t *pw_clock_start, clock_t *pw_shovel_start, unsigned long int*random_pup_gen){ int i, j, check, x, y; List *current,*temp; (*random_pup_gen)++; if (*random_pup_gen == 700000) *random_pup_gen = 0, rand_pup_gen(); if (powerup.bomb){ PlaySound(TEXT("Sound\\bomb.wav"),NULL, SND_ASYNC); for (current = lst->first->next; current != NULL; ){ check=0; for (i = 0; i < 3; i++) // proverava da li je u travi. for (j = 0; j < 3; j++) if(current->tankAll.tank.visit_grass[i][j]) { check = 1; break; } if (!check){ temp=current; current=current->next; free_tank(temp); }// ako nije u travi brise ga. else current=current->next; } powerup.bomb = 0; } if (powerup.clock){ // if unutar delay-a za botove, ali to cu promeniti kad dodju normalni. if (powerup.clock == 1){ *pw_clock_start = clock(); powerup.clock = 2; for (current = lst->first->next; current != NULL; current = current->next) current->tankAll.tank.phase = 5; } if (((clock()-*pw_clock_start)*1000/CLOCKS_PER_SEC) > PW_DURATION){ for (current = lst->first->next; current != NULL; current = current->next) current->tankAll.tank.phase = 2; powerup.clock = 0; } } if (powerup.shovel){ if (powerup.shovel == 1){ *pw_shovel_start = clock(); x = 41; for (y = 62; y < 67; y++) print_wall(y, x); x = 49; for (y = 62; y < 67; y++) print_wall(y, x); y = 62; for (x = 41; x < 50; x++) print_wall(y, x); refresh(); powerup.shovel = 2; } if (((clock() - *pw_shovel_start) * 1000 / CLOCKS_PER_SEC) > PW_DURATION * 2){ // konstanta! PW_DURATION x = 41; for (y = 62; y < 67; y++) print_head(y, x); x = 49; for (y = 62; y < 67; y++) print_head(y, x); y = 62; for (x = 41; x < 50; x++) print_head(y, x); refresh(); powerup.shovel = 0; } } if (powerup.shield){ // imam if u funkciji collision: if (!((temp == lst->first) && powerup.shield)) free_tank(temp); if (powerup.shield == 1){ *pw_shield_start = clock(); powerup.shield = 2; } if (((clock()-*pw_shield_start)*1000/CLOCKS_PER_SEC) > PW_DURATION){ powerup.shield = 0; } } }