private void btn_buy_land_Click(object sender, EventArgs e) { if (game.get_country_with_pos(play.get_position()).get_available() == false) { if (play.get_money() >= game.get_country_with_pos(play.get_position()).get_cost()) { List <bool> temp = new List <bool>(); play.add_country_to_list(game.get_country_with_pos(play.get_position())); play.set_money(play.get_money() - game.get_country_with_pos(play.get_position()).get_cost()); game.get_country_with_pos(play.get_position()).propertize(3, ref panel1, 0, ref play, ref game); game.set_player_at_pos(play, game.get_index()); game.get_country_with_pos(play.get_position()).set_owner(play.get_name()); for (int i = 0; i < game.get_list_group().Count; i++) { if (game.get_list_group()[i].get_color() == game.get_country_with_pos(play.get_position()).get_color()) { for (int gr_count = 0; gr_count < game.get_list_group()[i].get_list().Count; gr_count++) { for (int player_count = 0; player_count < play.get_countrylist().Count; player_count++) { if (game.get_list_group()[i].get_list()[gr_count] == play.get_countrylist()[player_count].get_name()) { temp.Add(true); break; } } } if (temp.Count == game.get_list_group()[i].get_list().Count) { game.get_list_group()[i].set_owner(play); } } } btn_buy_hotel.Enabled = true; btn_buy_land.Enabled = false; } else { btn_buy_land.Enabled = false; MessageBox.Show("you dont have money ."); btn_leave.Enabled = true; btn_end_turn.Enabled = true; btn_sell_hotel.Enabled = true; btn_sell_land.Enabled = true; } } else if (game.get_country_with_pos(play.get_position()).get_available() == true) { int o = 0; for (int i = 0; i < play.get_countrylist().Count; i++) { if (game.get_list_country()[play.get_position()].get_name() == play.get_countrylist()[i].get_name()) { o = 1; } } if (o == 1) { MessageBox.Show("you are the owner of this country ."); } else { MessageBox.Show("you should pay rent to this country."); btn_rent.Enabled = true; btn_sell_hotel.Enabled = true; btn_sell_land.Enabled = true; } } }