/* * Main "user interface" loop. */ void legacy_main() { char menuin[80]; char buf[128]; keystroke_help(); for (;;) { printf(">>> "); fflush(stdout); if (fgets(menuin, sizeof(menuin), stdin) == NULL) { /* * Be friendly to users who redirect commands into * program, when file ends, resume with kbd. * If exit is desired end script with q for quit */ /* Reopen stdin/stdout/stderr to /dev/console */ #if ((defined(PJ_WIN32) && PJ_WIN32!=0) || \ (defined(PJ_WIN64) && PJ_WIN64!=0)) && \ (!defined(PJ_WIN32_WINCE) || PJ_WIN32_WINCE==0) if (freopen ("CONIN$", "r", stdin) == NULL) { #else if (1) { #endif puts("Cannot switch back to console from file redirection"); menuin[0] = 'q'; menuin[1] = '\0'; } else { puts("Switched back to console from file redirection"); continue; } } if (cmd_echo) { printf("%s", menuin); } /* Update call setting */ pjsua_call_setting_default(&call_opt); call_opt.aud_cnt = app_config.aud_cnt; call_opt.vid_cnt = app_config.vid.vid_cnt; switch (menuin[0]) { case 'm': /* Make call! : */ ui_make_new_call(); break; case 'M': /* Make multiple calls! : */ ui_make_multi_call(); break; case 'n': ui_detect_nat_type(); break; case 'i': /* Send instant messaeg */ ui_send_instant_message(); break; case 'a': ui_answer_call(); break; case 'h': ui_hangup_call(menuin); break; case ']': case '[': /* * Cycle next/prev dialog. */ ui_cycle_dialog(menuin); break; case '>': case '<': ui_cycle_account(); break; case '+': if (menuin[1] == 'b') { ui_add_buddy(); } else if (menuin[1] == 'a') { ui_add_account(&app_config.rtp_cfg); } else { printf("Invalid input %s\n", menuin); } break; case '-': if (menuin[1] == 'b') { ui_delete_buddy(); } else if (menuin[1] == 'a') { ui_delete_account(); } else { printf("Invalid input %s\n", menuin); } break; case 'H': /* * Hold call. */ ui_call_hold(); break; case 'v': #if PJSUA_HAS_VIDEO if (menuin[1]=='i' && menuin[2]=='d' && menuin[3]==' ') { vid_handle_menu(menuin); } else #endif if (current_call != -1) { /* * re-INVITE */ ui_call_reinvite(); } else { PJ_LOG(3,(THIS_FILE, "No current call")); } break; case 'U': /* * Send UPDATE */ ui_send_update(); break; case 'C': if (menuin[1] == 'p') { ui_manage_codec_prio(); } break; case 'x': /* * Transfer call. */ ui_call_transfer(app_config.no_refersub); break; case 'X': /* * Transfer call with replaces. */ ui_call_transfer_replaces(app_config.no_refersub); break; case '#': /* * Send DTMF strings. */ ui_send_dtmf_2833(); break; case '*': /* Send DTMF with INFO */ ui_send_dtmf_info(); break; case 'S': /* * Send arbitrary request */ ui_send_arbitrary_request(); break; case 'e': ui_echo(menuin); break; case 's': if (pj_ansi_strnicmp(menuin, "sleep", 5)==0) { ui_sleep(menuin); break; } /* Continue below */ case 'u': /* * Subscribe/unsubscribe presence. */ ui_subscribe(menuin); break; case 'r': ui_register(menuin); break; case 't': ui_toggle_state(); break; case 'T': ui_change_online_status(); break; case 'c': switch (menuin[1]) { case 'l': ui_conf_list(); break; case 'c': case 'd': ui_conf_connect(menuin); break; } break; case 'V': /* Adjust audio volume */ ui_adjust_volume(); break; case 'd': if (menuin[1] == 'c') { ui_dump_configuration(); } else if (menuin[1] == 'q') { ui_dump_call_quality(); } else { ui_app_dump(menuin[1]=='d'); } break; case 'f': if (simple_input("Enter output filename", buf, sizeof(buf))) { ui_write_settings(); } break; case 'L': /* Restart */ case 'q': legacy_on_stopped(menuin[0]=='L'); goto on_exit; case 'R': ui_call_redirect(menuin); break; default: if (menuin[0] != '\n' && menuin[0] != '\r') { printf("Invalid input %s", menuin); } keystroke_help(); break; } } on_exit: ; }
void player_turn(player_t* player) { decision_t decision; if (player == game_last_player()) return; if (player->cash <= 0) { /* player have no cash and only watching */ ui_refresh_msg(M1, "%s has no cash to turn.", player->name); ui_sleep(game.sleep_time); } else { ui_refresh_msg(M1, "%s is thinking...", player->name); if (player->is_ai) ui_sleep(game.sleep_time); decision = (player->is_ai) ? ai_decision(player) : ui_selector(player); switch (decision) { case CHECK: set_msg(M2, "%s: checks.", player->name); break; case BET: set_msg(M2, "%s bets %u", player->name, BIG_BLIND); player_bet(player, BIG_BLIND); break; case RAISE: set_msg(M2, "%s raises to %u", player->name, game.bet * 2); player_raise(player); break; case FOLD: LOG("%s says fold\n", player->name); set_msg(M2, "%s: folds.", player->name); player_bank(player); player->is_in_game = FALSE; break; case CALL: set_msg(M2, "%s calls %u", player->name, game.bet); player_bet(player, game.bet - player->bet); break; } ai_update_behaviour(player, decision, behaviour); } player->is_move_made = TRUE; /*FOR_EACH_PLAYER(i) { LOG("%s's statistics: %u %u %u %u %u %u %u %u %u %u %u\n", game.players[i].name, behaviour[i].raises, behaviour[i].bets, behaviour[i].calls, behaviour[i].checks, behaviour[i].folds, behaviour[i].raises_total, behaviour[i].bets_total, behaviour[i].calls_total, behaviour[i].checks_total, behaviour[i].folds_total, behaviour[i].last); }*/ }