// static Random s = new Random();//static make good randomisation private void button4_Click(object sender, EventArgs e) { listBox1.Items.Clear(); btn_roll_dice.Enabled = false; btn_end_turn.Enabled = true; play = game.get_player_at_index(game.get_index()); first_dice = play.get_rolld_dice(); //game.get_list_country()[play.get_position()].propertize(3, ref panel1, 0, ref play, ref game); second_dice = play.get_rolld_dice(); // if ((play.get_position() + first_dice + second_dice) >= 36 && play.get_first_time_to_roll_done() == false) { btn_leave.Enabled = true; play.set_first_time_to_roll_done(true); if (play.get_Was_in_jail() == false) { play.set_money(play.get_money() + 200); MessageBox.Show("you have earned 200$."); } else if (play.get_Was_in_jail() == true) { play.set_Was_in_jail(false); } } else if ((play.get_position() + first_dice + second_dice) >= 36 && play.get_first_time_to_roll_done() == true) { if (play.get_Was_in_jail() == false) { play.set_money(play.get_money() + 200); MessageBox.Show("you have earned 200$."); } else if (play.get_Was_in_jail() == true) { play.set_Was_in_jail(false); } } if (play.get_In_jail_now() == true) { if (second_dice == first_dice) { game.jail.Checker_double_get_out_from_jail(ref play, true, first_dice + second_dice); } else { game.jail.Checker_double_get_out_from_jail(ref play, false, first_dice + second_dice); } } if (play.get_In_jail_now() == false) { if (second_dice == first_dice) { if (play.add_double_list_to_go_to_jail(true) == true) { game.jail.set_prisoners_with_going_jail(ref play); MessageBox.Show("you will send to jail As you played three doubles. "); } } else { play.add_double_list_to_go_to_jail(false); } } if (play.get_In_jail_now() == false) { play.set_position((play.get_position() + first_dice + second_dice) % 36); } btn_leave.Visible = true; //country if ((game.get_list_country()[play.get_position()]).GetType() == typeof(Jail)) { if (play.get_In_jail_now() == false) { listBox1.Items.Add("you are in jail "); //game.get_list_country()[play.get_position()].propertize(3, ref panel1, 0, ref play, ref game); // game.jail.set_prisoners_with_going_jail(ref play); btn_sell_hotel.Enabled = true; btn_sell_land.Enabled = true; btn_leave.Enabled = true; btn_end_turn.Enabled = true; } } else if ((game.get_list_country()[play.get_position()]).GetType() == typeof(station)) { game.get_list_country()[play.get_position()].propertize(3, ref panel1, 0, ref play, ref game); btn_sell_hotel.Enabled = true; btn_sell_land.Enabled = true; btn_leave.Enabled = true; btn_end_turn.Enabled = true; } else if ((game.get_list_country()[play.get_position()]).GetType() == typeof(income_tax)) { game.get_list_country()[play.get_position()].propertize(3, ref panel1, 0, ref play, ref game); btn_sell_hotel.Enabled = true; btn_sell_land.Enabled = true; btn_leave.Enabled = true; btn_end_turn.Enabled = true; } else if ((game.get_list_country()[play.get_position()]).GetType() == typeof(water_works)) { game.get_list_country()[play.get_position()].propertize(3, ref panel1, 0, ref play, ref game); btn_sell_hotel.Enabled = true; btn_sell_land.Enabled = true; btn_leave.Enabled = true; btn_end_turn.Enabled = true; } else if ((game.get_list_country()[play.get_position()]).GetType() == typeof(go_token)) { game.get_list_country()[play.get_position()].propertize(3, ref panel1, 0, ref play, ref game); btn_sell_hotel.Enabled = true; btn_sell_land.Enabled = true; btn_leave.Enabled = true; btn_end_turn.Enabled = true; } else if ((game.get_list_country()[play.get_position()]).GetType() == typeof(GoToJail)) { //game.get_list_country()[play.get_position()].propertize(3, ref panel1, 0, ref play, ref game); game.jail.set_prisoners_with_going_jail(ref play); MessageBox.Show(" you will go to jail by go to jail token. "); btn_sell_hotel.Enabled = true; btn_sell_land.Enabled = true; btn_leave.Enabled = true; btn_end_turn.Enabled = true; } else if ((game.get_list_country()[play.get_position()]).GetType() == typeof(community_chest)) { int pic2 = R.Next(1, 7); game.get_list_country()[play.get_position()].propertize(3, ref panel53, pic2, ref play, ref game); btn_sell_hotel.Enabled = true; btn_sell_land.Enabled = true; btn_leave.Enabled = true; btn_end_turn.Enabled = true; panel53.Visible = true; } else if ((game.get_list_country()[play.get_position()]).GetType() == typeof(chance)) { int pic2 = R.Next(1, 7); game.get_list_country()[play.get_position()].propertize(3, ref panel53, pic2, ref play, ref game); btn_sell_hotel.Enabled = true; btn_sell_land.Enabled = true; btn_leave.Enabled = true; btn_end_turn.Enabled = true; panel53.Visible = true; } else if ((game.get_list_country()[play.get_position()]).GetType() == typeof(electric_company)) { game.get_list_country()[play.get_position()].propertize(3, ref panel1, 0, ref play, ref game); btn_sell_hotel.Enabled = true; btn_sell_land.Enabled = true; btn_leave.Enabled = true; btn_end_turn.Enabled = true; } else if ((game.get_list_country()[play.get_position()]).GetType() == typeof(Super_tax)) { game.get_list_country()[play.get_position()].propertize(3, ref panel1, 0, ref play, ref game); btn_sell_hotel.Enabled = true; btn_sell_land.Enabled = true; btn_leave.Enabled = true; btn_end_turn.Enabled = true; } listBox1.Items.Add("Player Name: " + play.get_name()); listBox1.Items.Add("Player Money: " + play.get_money()); listBox1.Items.Add("Player Country: "); if (play.get_countrylist().Count == 0) { listBox1.Items.Add("You dont have countries."); } for (int i = 0; i < play.get_countrylist().Count; i++) { listBox1.Items.Add("you have " + play.get_countrylist()[i].get_name() + "and it`s price is " + play.get_countrylist()[i].get_cost() + "$."); if (play.get_countrylist()[i].get_build_hotel() == true) { listBox1.Items.Add("you have an hotel on this country and its price " + play.get_countrylist()[i].get_over_cost()); } } if ((game.get_list_country()[play.get_position()]).GetType() == typeof(country)) { //this player is owner listBox1.Items.Add(".................................................."); listBox1.Items.Add("this token is called " + game.get_country_with_pos(play.get_position()).get_name()); listBox1.Items.Add("It costs " + game.get_country_with_pos(play.get_position()).get_cost() + " and its rent =" + game.get_country_with_pos(play.get_position()).get_rent()); listBox1.Items.Add("The hotel costs " + game.get_country_with_pos(play.get_position()).get_over_cost() + " and its hotel rent =" + game.get_country_with_pos(play.get_position()).get_over_rent()); } if (play.get_first_time_to_roll_done() == true && (game.get_list_country()[play.get_position()]).GetType() == typeof(country)) { //this player is owner // MessageBox.Show("hahahaahah"); btn_sell_hotel.Enabled = true; btn_sell_land.Enabled = true; if (play.check_if_this_player_is_owener_of_this_country(game.get_country_with_pos(play.get_position())) == true) { // MessageBox.Show("0000000000000000000"); btn_rent.Enabled = false; //check_if_player_owner_of_the_group if (play.check_if_player_owner_of_the_group(game.get_list_group(), (game.get_country_with_pos(play.get_position()))) == true) { if (game.get_country_with_pos(play.get_position()).get_build_hotel() == false) { btn_buy_hotel.Enabled = true; } } } else { //rent if (game.get_country_with_pos(play.get_position()).get_available() == false) { btn_buy_land.Enabled = true; } else { btn_sell_hotel.Enabled = true; btn_sell_land.Enabled = true; btn_rent.Enabled = true; btn_end_turn.Enabled = false; btn_buy_hotel.Enabled = false; btn_buy_land.Enabled = false; } } } //check if the player is the owner of this coutry /* (n == 1)//PLAYER is the owner of country &you want sell land * (n == 2)//PLAYER is the owner of country &you want sell hotel * (n == 3)//PLAYER is Not the owner of country &you want buy land * (n == 4)//PLAYER is Not the owner of country &you want buy hotel*/ //loading dice pictures////////// if (first_dice == 6) { pic_dice_1.BackgroundImage = Image.FromFile(@"dices\dice(6).png"); } if (first_dice == 5) { pic_dice_1.BackgroundImage = Image.FromFile(@"dices\dice(5).png"); } if (first_dice == 4) { pic_dice_1.BackgroundImage = Image.FromFile(@"dices\dice(4).png"); } if (first_dice == 3) { pic_dice_1.BackgroundImage = Image.FromFile(@"dices\dice(3).png"); } if (first_dice == 2) { pic_dice_1.BackgroundImage = Image.FromFile(@"dices\dice(2).png"); } if (first_dice == 1) { pic_dice_1.BackgroundImage = Image.FromFile(@"dices\dice(1).png"); } if (second_dice == 6) { pic_dice_2.BackgroundImage = Image.FromFile(@"dices\dice(6).png"); } if (second_dice == 5) { pic_dice_2.BackgroundImage = Image.FromFile(@"dices\dice(5).png"); } if (second_dice == 4) { pic_dice_2.BackgroundImage = Image.FromFile(@"dices\dice(4).png"); } if (second_dice == 3) { pic_dice_2.BackgroundImage = Image.FromFile(@"dices\dice(3).png"); } if (second_dice == 2) { pic_dice_2.BackgroundImage = Image.FromFile(@"dices\dice(2).png"); } if (second_dice == 1) { pic_dice_2.BackgroundImage = Image.FromFile(@"dices\dice(1).png"); } if (game.get_index() == 0) { pictureBox1.Location = new Point(location_country[play.get_position()].Item1, location_country[play.get_position()].Item2); } else if (game.get_index() == 1) { pictureBox2.Location = new Point(location_country[play.get_position()].Item1, location_country[play.get_position()].Item2); } else if (game.get_index() == 2) { pictureBox3.Location = new Point(location_country[play.get_position()].Item1, location_country[play.get_position()].Item2); } else if (game.get_index() == 3) { pictureBox4.Location = new Point(location_country[play.get_position()].Item1, location_country[play.get_position()].Item2); } else if (game.get_index() == 4) { pictureBox5.Location = new Point(location_country[play.get_position()].Item1, location_country[play.get_position()].Item2); } else if (game.get_index() == 5) { pictureBox6.Location = new Point(location_country[play.get_position()].Item1, location_country[play.get_position()].Item2); } else if (game.get_index() == 6) { pictureBox7.Location = new Point(location_country[play.get_position()].Item1, location_country[play.get_position()].Item2); } else if (game.get_index() == 7) { pictureBox8.Location = new Point(location_country[play.get_position()].Item1, location_country[play.get_position()].Item2); } }
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; } } }