void MainWindow::enterRoom(){ // add current ip to history if(!Config.HistoryIPs.contains(Config.HostAddress)){ Config.HistoryIPs << Config.HostAddress; Config.HistoryIPs.sort(); Config.setValue("HistoryIPs", Config.HistoryIPs); } ui->actionStart_Game->setEnabled(false); ui->actionStart_Server->setEnabled(false); int player_count = Sanguosha->getPlayerCount(ServerInfo.GameMode); RoomScene *room_scene = new RoomScene(player_count, this); ui->actionView_Discarded->setEnabled(true); ui->actionView_distance->setEnabled(true); ui->actionServerInformation->setEnabled(true); ui->actionKick->setEnabled(true); ui->actionSurrender->setEnabled(true); ui->actionSaveRecord->setEnabled(true); connect(ui->actionView_Discarded, SIGNAL(triggered()), room_scene, SLOT(toggleDiscards())); connect(ui->actionView_distance, SIGNAL(triggered()), room_scene, SLOT(viewDistance())); connect(ui->actionServerInformation, SIGNAL(triggered()), room_scene, SLOT(showServerInformation())); connect(ui->actionKick, SIGNAL(triggered()), room_scene, SLOT(kick())); connect(ui->actionSurrender, SIGNAL(triggered()), room_scene, SLOT(surrender())); connect(ui->actionSaveRecord, SIGNAL(triggered()), room_scene, SLOT(saveReplayRecord())); connect(room_scene, SIGNAL(restart()), this, SLOT(restartConnection())); gotoScene(room_scene); }
void MainWindow::enterRoom(){ // add current ip to history if(!Config.HistoryIPs.contains(Config.HostAddress)){ Config.HistoryIPs << Config.HostAddress; Config.HistoryIPs.sort(); Config.setValue("HistoryIPs", Config.HistoryIPs); } ui->actionStart_Game->setEnabled(false); ui->actionStart_Server->setEnabled(false); ui->actionAI_Melee->setEnabled(false); RoomScene *room_scene = new RoomScene(this); ui->actionView_Discarded->setEnabled(true); ui->actionView_distance->setEnabled(true); ui->actionServerInformation->setEnabled(true); ui->actionKick->setEnabled(true); ui->actionSurrender->setEnabled(true); ui->actionSaveRecord->setEnabled(true); connect(ui->actionView_Discarded, SIGNAL(triggered()), room_scene, SLOT(toggleDiscards())); connect(ui->actionView_distance, SIGNAL(triggered()), room_scene, SLOT(viewDistance())); connect(ui->actionServerInformation, SIGNAL(triggered()), room_scene, SLOT(showServerInformation())); connect(ui->actionKick, SIGNAL(triggered()), room_scene, SLOT(kick())); connect(ui->actionSurrender, SIGNAL(triggered()), room_scene, SLOT(surrender())); connect(ui->actionSaveRecord, SIGNAL(triggered()), room_scene, SLOT(saveReplayRecord())); connect(ui->actionExpand_dashboard, SIGNAL(toggled(bool)), room_scene, SLOT(adjustDashboard(bool))); if(Config.value("UI/ExpandDashboard").toBool()) ui->actionExpand_dashboard->toggle(); if(ServerInfo.FreeChoose){ ui->menuCheat->setEnabled(true); connect(ui->actionGet_card, SIGNAL(triggered()), ui->actionCard_Overview, SLOT(trigger())); connect(ui->actionDeath_note, SIGNAL(triggered()), room_scene, SLOT(makeKilling())); connect(ui->actionDamage_maker, SIGNAL(triggered()), room_scene, SLOT(makeDamage())); connect(ui->actionRevive_wand, SIGNAL(triggered()), room_scene, SLOT(makeReviving())); connect(ui->actionSend_lowlevel_command, SIGNAL(triggered()), this, SLOT(sendLowLevelCommand())); connect(ui->actionExecute_script_at_server_side, SIGNAL(triggered()), room_scene, SLOT(doScript())); } else{ ui->menuCheat->setEnabled(false); ui->actionGet_card->disconnect(); ui->actionDeath_note->disconnect(); ui->actionDamage_maker->disconnect(); ui->actionRevive_wand->disconnect(); ui->actionSend_lowlevel_command->disconnect(); ui->actionExecute_script_at_server_side->disconnect(); } connect(room_scene, SIGNAL(restart()), this, SLOT(startConnection())); connect(room_scene, SIGNAL(return_to_start()), this, SLOT(gotoStartScene())); room_scene->adjustItems(); gotoScene(room_scene); }
//----- Begin of function Nation::think_surrender -----// // int Nation::think_surrender() { //--- don't surrender if the nation still has a town ---// int rc=0; if( total_population == 0 ) rc = 1; if( cash <= 0 && income_365days()==0 ) rc = 1; if( !rc ) return 0; //---- see if there is any nation worth getting our surrender ---// Nation* nationPtr; int curRating, bestRating=0, bestNationRecno=0; if( !king_unit_recno ) // if there is no successor to the king, the nation will tend more to surrender bestRating = -100; for( int i=nation_array.size() ; i>0 ; i-- ) { if( nation_array.is_deleted(i) || i==nation_recno ) continue; nationPtr = nation_array[i]; if( nationPtr->cash <= 300 ) // don't surrender to an ecnomically handicapped nation continue; curRating = ai_surrender_to_rating(i); //--- if the nation will tend to surrender if there is only a small number of units left ---// curRating += 50 - total_unit_count*5; if( curRating > bestRating ) { bestRating = curRating; bestNationRecno = i; } } //---------------------------------------// if( bestNationRecno ) { surrender(bestNationRecno); return 1; } return 0; }
void MainWindow::enterRoom(){ // add current ip to history if(!Config.HistoryIPs.contains(Config.HostAddress)){ Config.HistoryIPs << Config.HostAddress; Config.HistoryIPs.sort(); Config.setValue("HistoryIPs", Config.HistoryIPs); } ui->actionStart_Game->setEnabled(false); ui->actionStart_Server->setEnabled(false); RoomScene *room_scene = new RoomScene(this); ui->actionView_Discarded->setEnabled(true); ui->actionView_distance->setEnabled(true); ui->actionServerInformation->setEnabled(true); ui->actionKick->setEnabled(true); ui->actionSurrender->setEnabled(true); ui->actionSaveRecord->setEnabled(true); connect(ui->actionView_Discarded, SIGNAL(triggered()), room_scene, SLOT(toggleDiscards())); connect(ui->actionView_distance, SIGNAL(triggered()), room_scene, SLOT(viewDistance())); connect(ui->actionServerInformation, SIGNAL(triggered()), room_scene, SLOT(showServerInformation())); connect(ui->actionKick, SIGNAL(triggered()), room_scene, SLOT(kick())); connect(ui->actionSurrender, SIGNAL(triggered()), room_scene, SLOT(surrender())); connect(ui->actionSaveRecord, SIGNAL(triggered()), room_scene, SLOT(saveReplayRecord())); connect(ui->actionExpand_dashboard, SIGNAL(triggered()), room_scene, SLOT(adjustDashboard())); if(ServerInfo.FreeChoose){ ui->menuCheat->setEnabled(true); connect(ui->actionGet_card, SIGNAL(triggered()), ui->actionCard_Overview, SLOT(trigger())); connect(ui->actionDeath_note, SIGNAL(triggered()), room_scene, SLOT(makeKilling())); connect(ui->actionDamage_maker, SIGNAL(triggered()), room_scene, SLOT(makeDamage())); connect(ui->actionRevive_wand, SIGNAL(triggered()), room_scene, SLOT(makeReviving())); //modify by ce connect(ui->actionMp_maker, SIGNAL(triggered()), room_scene, SLOT(makeMp())); } connect(room_scene, SIGNAL(restart()), this, SLOT(startConnection())); gotoScene(room_scene); }
/** * Menu du joueur lors de la partie */ void gameMenu(){ int choix; if(noPlayer == FIRST_PLAYER) fontColor(red); else fontColor(blue); printf("\nJoueur no %i à vous de jouer !\n", noPlayer + 1); reinitColor(); do{ printf("\nMenu :\n"); printf(" 1 - Unités pouvant se déplacer\n"); printf(" 2 - Unités pouvant attaquer\n"); printf(" 3 - Changer de direction\n"); printf(" 4 - Passer tour\n"); printf(" 5 - Sauvegarder\n"); printf(" 6 - Abandonner la partie\n"); printf("Votre choix : "); choix = readLong(); if(choix == 0) { printf("Erreur : Veuillez rentrer un chiffre et non un caractère \n"); } switch(choix){ case 1: unitMenu(1); break; case 2: unitMenu(2); break; case 3: unitMenu(3); break; case 4: passTurn(); break; case 5: save(); clearScreen(); gridDisp(); printf("La partie a été sauvegardée !\n"); break; case 6: surrender(); break; default: printf("Erreur: votre choix doit etre compris entre 1 et 5\n"); } }while(choix < 0 || choix > 6); }
//------- Begin of function TalkMsg::msg_str --------// // // Return the text of this message. // // <int> viewingNationRecno = the recno of the nation viewing this message // [int] dispReply = whether display the reply if there is one // (default: 1) // [int] dispSecondLine = whether should display the second line of the // message (default: 0) // char* TalkMsg::msg_str(int viewingNationRecno, int dispReply, int dispSecondLine) { viewing_nation_recno = viewingNationRecno; should_disp_reply = dispReply; disp_second_line = dispSecondLine; //-------- compose the message str -------// switch(talk_id) { case TALK_PROPOSE_TRADE_TREATY: propose_treaty("accord commercial"); break; case TALK_PROPOSE_FRIENDLY_TREATY: propose_treaty("pacte de non-agression"); break; case TALK_PROPOSE_ALLIANCE_TREATY: propose_treaty("traité d'alliance"); break; case TALK_END_TRADE_TREATY: end_treaty("accord commercial"); break; case TALK_END_FRIENDLY_TREATY: end_treaty("pacte de non-agression"); break; case TALK_END_ALLIANCE_TREATY: end_treaty("traité d'alliance"); break; case TALK_REQUEST_MILITARY_AID: request_military_aid(); break; case TALK_REQUEST_TRADE_EMBARGO: request_trade_embargo(); break; case TALK_REQUEST_CEASE_WAR: request_cease_war(); break; case TALK_REQUEST_DECLARE_WAR: request_declare_war(); break; case TALK_REQUEST_BUY_FOOD: request_buy_food(); break; case TALK_DECLARE_WAR: declare_war(); break; case TALK_GIVE_TRIBUTE: give_tribute("tribut"); break; case TALK_DEMAND_TRIBUTE: demand_tribute(0); // 1-is tribute, not aid break; case TALK_GIVE_AID: give_tribute("aide"); break; case TALK_DEMAND_AID: demand_tribute(1); // 1-is aid, not tribute break; case TALK_GIVE_TECH: give_tech(); break; case TALK_DEMAND_TECH: demand_tech(); break; case TALK_REQUEST_SURRENDER: request_surrender(); break; case TALK_SURRENDER: surrender(); break; default: err_here(); } return str; }
//----- Begin of function Nation::think_unite_against_big_enemy -----// // int Nation::think_unite_against_big_enemy() { if( info.game_date - info.game_start_date < 365 * 3 * (100+pref_military_development) / 100 ) // only do this after 3 to 6 years into the game { return 0; } //-----------------------------------------------// if( config.ai_aggressiveness < OPTION_HIGH ) return 0; if( config.ai_aggressiveness == OPTION_HIGH ) { if( misc.random(10)!=0 ) return 0; } else // OPTION_VERY_HIGH { if( misc.random(5)!=0 ) return 0; } //---------------------------------------// int enemyNationRecno = nation_array.max_overall_nation_recno; if( !enemyNationRecno ) return 0; Nation* enemyNation = nation_array[enemyNationRecno]; //----- only against human players -----// if( enemyNation->is_ai() ) return 0; //---- find the overall rank rating of the second most powerful computer kingdom ---// Nation* nationPtr; int secondBestOverall=0, secondBestNationRecno=0; for( int i=nation_array.size() ; i>0 ; i-- ) { if( nation_array.is_deleted(i) || i==enemyNationRecno ) continue; nationPtr = nation_array[i]; if( !nationPtr->is_ai() ) // don't count human players continue; if( nationPtr->overall_rank_rating() > secondBestOverall ) { secondBestOverall = nationPtr->overall_rank_rating(); secondBestNationRecno = i; } } if( !secondBestNationRecno || secondBestNationRecno==nation_recno ) return 0; //------- don't surrender to hostile nation -------// if( get_relation_status(secondBestNationRecno) < NATION_NEUTRAL ) return 0; //--- if all AI kingdoms are way behind the human players, unite to against the human player ---// int compareRating; if( config.ai_aggressiveness == OPTION_HIGH ) compareRating = 50; else // OPTION_VERY_AGGRESSIVE compareRating = 80; if( secondBestOverall < compareRating && secondBestNationRecno != nation_recno ) { surrender(secondBestNationRecno); return 1; } return 0; }
/*calls surrender function, which also changes and displays bet amount and money*/ void cb_surrender(GtkWidget *widget, gpointer data) { config *c; c = (config *)data; surrender(c->p, c->bamt, c->mamt); gtk_widget_show_all((GtkWidget *)c->window); }