bool Room::check_team_ready() { int team_red = 0; // 准备好的 int team_blue = 0; // int num_red = 0; // 红队人数 int num_blue = 0; // 蓝队人数 for(int i = 0; i < MAX_ROOM_MEMBERS; i++) { auto m = m_members[i]; if(m) { if(i%2) { num_blue += 1; team_blue += m->get_ready(); } else { num_red += 1; team_red += m->get_ready(); } } } if(team_red && team_blue && team_red == num_red && team_blue == num_blue) return true; else return false; }
void main_app_handle_button_down() { pulse_blank_canvas(); if (state == 0) get_ready(); else if (state == 1) { pulse_cancel_timer(&hold_timer_value); state = 0; printf("XXX Too soon XXX\n\n"); printf("click to try \nagain"); printf("\n\n\n\n\n\n\n\n\n\n\nBest: %dms",best_time); } else if (state == 2) { state = 0; int reaction_time = (int)pulse_get_millis() - start_time; printf("You reacted in \n\n%d millisecs\n\n",reaction_time); printf("Click to try \nagain"); if (reaction_time < best_time) best_time = reaction_time; printf("\n\n\n\n\n\n\n\n\n\nBest: %dms",best_time); } }
int main(void) { uint8_t result; /////////////////////////////////////// sys_state = SYS_INIT; sd_avlb = 1; speeder_avlb = 1; gps_avlb = 1; /////////////////////////////////////// ///////////////////////////////////////////////////////////// result = init(); if(result) { #if DEBUG uart_puts_p(PSTR("\nINIT Failed! \n\n")); #endif Disp_Clear(); XY_Str_P(0,0,PSTR("NO SD Card! -")); XY_Num(13,0,result); XY_Char(11,1,m_arrow); XY_Str_P(12,1,PSTR("SKIP")); //XY_Str_P(12,1,m_item[4]); sd_avlb = 0; timer1_start(); while(!(key_scan() == KEY_OK)) _delay_ms(100); sei(); } #if DEBUG else uart_puts_p(PSTR("\nINIT Completed! \n\n")); #endif sys_state = SYS_READY; ///////////////////////////////////////////////////////////// while(1) { ///////////////////////////////////////////////////////////// #if DEBUG uart_puts_p(PSTR("get_ready() start! \n")); #endif while(sys_state == SYS_READY) get_ready(); ///////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// #if DEBUG uart_puts_p(PSTR("task() start! \n")); #endif while(sys_state == SYS_WORKING) task(); ///////////////////////////////////////////////////////////// } return 0; }
void generate_alerts(submarine sub, submarine enemy) { // prompt player for ready get_ready(sub); // print informational graphics alert_graphic(sub); // print current position and direction alert_status(sub); // alert if tried to move out of bounds alert_bounds(sub); // alert if enemy fired last phase alert_fire(sub, enemy); // alert if enemy moved or turned within vision last phase alert_motion(sub, enemy); // alert if enemy pinged alert_pingee(enemy); // alert the results from own ping last phase alert_pinger(sub, enemy); // give command menu and prompt for input printf(PLAYER_MENU); printf(PLAYER_PROMPT); }
int main(int argc, char **argv) { if (argc < 2) { show_usage(); } char *cmd_string = argv[1]; for (int i = 1; i < argc; i++) { if (!strcmp(argv[i], "-l")) { run_once = 0; cmd_string = argv[2]; } if (!strcmp(argv[i], "-h")) { show_usage(); } } if (cmd_string == NULL) { show_usage(); } get_user_host_rsrc(cmd_string); show_version(); check_remote_auth(); get_ready(); check_for_changes(directory); return EXIT_SUCCESS; }
int autok_flow() { std::list<struct host_progress*>::iterator it_prog; std::list<struct host_progress*> host_prog; struct timespec tstart={0,0}, tend={0,0}; while(1){ // [FIXME] uevent to trigger host autok operation? host_prog = get_ready(); for (it_prog=host_prog.begin(); it_prog!=host_prog.end() ; ++it_prog){ struct host_progress *prog = *it_prog; //printf("ID(%d) IS_DONE(%d)\n", prog->host_id, prog->is_done); //set_ready(2); //system("rm -rf /data/autok_*"); if(prog->host_id>=0 && !prog->is_done){ printf("[AUTOKD]Autok runs at host %d\n", prog->host_id); clock_gettime(CLOCK_MONOTONIC, &tstart); if(do_host_autok(prog->host_id)==-1) return -1; if(wait_autok_done(prog->host_id)==-1) return -1; clock_gettime(CLOCK_MONOTONIC, &tend); printf("autok computation took about %.5f seconds\n",((double)tend.tv_sec + 1.0e-9*tend.tv_nsec) - ((double)tstart.tv_sec + 1.0e-9*tstart.tv_nsec)); /*if(is_nvram_mode()){ system("rm -rf /data/autok_*"); }*/ } free(prog); } usleep(1000*1000); } return 0; }
void zz_vertex_buffer::update_buffer (const void * buf_in) { assert(znzin); assert(znzin->renderer); assert(ZZ_HANDLE_IS_VALID(device_handle)); assert(get_ready()); assert(get_created()); assert(size_total > 0); // main work znzin->renderer->update_vertex_buffer(*this, device_handle, buf_in, size_total, 0 /* offset */); make_updated(); }
int wait_autok_done(int id) { int is_stage2_done = 0; std::list<struct host_progress*>::iterator it_prog; std::list<struct host_progress*> host_prog; while(!is_stage2_done){ host_prog = get_ready(); for (it_prog=host_prog.begin(); it_prog!=host_prog.end() ; ++it_prog){ struct host_progress *prog = *it_prog; if(prog->host_id==id){ if(prog->is_done == 1){ is_stage2_done = 1; } break; } free(prog); } usleep(300*1000); } return 0; }
std::map<sf::String, sf::Sprite> AssetManager::generateSpriteSet(sf::Texture* tileset_texture) { sf::Sprite day_background(*tileset_texture, sf::Rect<int>(0, 0, 288, 512)); assetDict["day_background"] = day_background; sf::Sprite night_background(*tileset_texture, sf::Rect<int>(292, 0, 288, 512)); assetDict["night_background"] = night_background; sf::Sprite floor(*tileset_texture, sf::Rect<int>(584, 0, 288, 112)); assetDict["floor"] = floor; sf::Sprite floor_copy(*tileset_texture, sf::Rect<int>(584, 0, 288, 112)); assetDict["floor_copy"] = floor_copy; sf::Sprite title(*tileset_texture, sf::Rect<int>(702, 182, 178, 48)); assetDict["title"] = title; sf::Sprite get_ready(*tileset_texture, sf::Rect<int>(584, 114, 196, 62)); assetDict["get_ready"] = get_ready; sf::Sprite game_over(*tileset_texture, sf::Rect<int>(784, 114, 204, 62)); assetDict["game_over"] = game_over; return assetDict; }
int main(int argc, const char * argv[]) { get_ready(); /* stupid_tests(); printf("[tests.main]\tsanity check: sizeof(unsigned long) = %d\n", (int) sizeof(unsigned long)); printf("[tests.main]\trunning tests....\n"); Board board; setup(&board); printf("\n"); printb(&board); printf("\n"); test_to_play(&board); test_ply(&board); if(WIN == test_file_attacks()) printf("[tests.file_attacks]\tpassed\n"); else printf("[tests.file_attacks]\tFAILED!\n"); if(WIN == test_rank_attacks()) printf("[tests.rank_attacks]\tpassed\n"); else printf("[tests.rank_attacks]\tFAILED!\n"); if(WIN == test_initf()) printf("[tests.initf]\t\tpassed\n"); else printf("[tests.initf]\t\tFAILED!\n"); if(WIN == test_tl_br_attacks()) printf("[tests.tl_br_attacks]\tpassed\n"); else printf("[tests.tl_br_attacks]\tFAILED!\n"); if(WIN == test_knight_attacks()) printf("[tests.knight_attacks]\tpassed\n"); else printf("[tests.knight_attacks]\tFAILED!\n"); if(WIN == test_king_attacks()) printf("[tests.king_attacks]\tpassed\n"); else printf("[tests.king_attacks]\tFAILED!\n"); if(WIN == test_moves()) printf("[tests.moves]\t\tpassed\n"); else printf("[tests.moves]\t\tFAILED!\n"); if(WIN == test_conversions()) printf("[tests.conversions]\tpassed\n"); else printf("[tests.conversions]\tFAILED!\n"); if(WIN == test_apply_move()) printf("[tests.apply_move]\tpassed\n"); else printf("[tests.apply_move]\tFAILED!\n"); */ if(WIN == test_search()) printf("[tests.search]\t\tpassed\n"); else printf("[tests.search]\t\tFAILED!\n"); /* test_scout(); */ clean_up(); printf("\n[tests.main]\t\ttests complete\n"); return EXIT_SUCCESS; }