Esempio n. 1
0
        public override void propertize(int n, ref Panel x, int pic, ref player obj, ref Board game_obj)

        {
            //write this function as a friend one

            // Loading community chest pictures
            if (pic == 1)
            {//here.............................................
                x.BackgroundImage = Image.FromFile(@"chance\ch1.jpg");
                // player.money -= 20;

                obj.set_money(obj.get_money() - 150);
            }
            else if (pic == 2)
            {
                obj.set_money(obj.get_money() - 150);
                x.BackgroundImage = Image.FromFile(@"chance\ch2.jpg");
                // player.money-= 50;
            }
            else if (pic == 3)
            {
                obj.set_money(obj.get_money() + 50);
                x.BackgroundImage = Image.FromFile(@"chance\ch3.jpg");
                // player.money -= 50;
            }
            else if (pic == 4)
            {
                x.BackgroundImage = Image.FromFile(@"chance\ch4.jpg");
                //call go_to_jail  function;
                MessageBox.Show("you sent to jail by  chance .");
                game_obj.jail.set_prisoners_with_going_jail(ref obj);
            }
            else if (pic == 5)
            {
                obj.set_money(obj.get_money() - 12);
                x.BackgroundImage = Image.FromFile(@"chance\ch5.jpg");
                // player.money -= 100;
            }
            else if (pic == 6)
            {
                //here
                x.BackgroundImage = Image.FromFile(@"chance\ch6.jpg");
                // player.money-= 100;
                obj.set_money(obj.get_money() + 50);
            }
        }
Esempio n. 2
0
 private void btn_rent_Click(object sender, EventArgs e)
 {
     if (game.get_country_with_pos(play.get_position()).get_build_hotel() == true)
     {
         if (play.get_money() >= (game.get_country_with_pos(play.get_position()).get_over_rent() + game.get_country_with_pos(play.get_position()).get_rent()))
         {
             play.set_money(play.get_money() - game.get_country_with_pos(play.get_position()).get_over_rent() - game.get_country_with_pos(play.get_position()).get_rent());
             btn_leave.Enabled    = true;
             btn_end_turn.Enabled = true;
         }
         else
         {
             MessageBox.Show("you dont have money sell anything or leave the game.");
             btn_leave.Enabled      = true;
             btn_sell_hotel.Enabled = true;
             btn_sell_land.Enabled  = true;
         }
     }
     else
     {
         if (play.get_money() >= game.get_country_with_pos(play.get_position()).get_rent())
         {
             play.set_money(play.get_money() - game.get_country_with_pos(play.get_position()).get_over_rent());
             btn_leave.Enabled    = true;
             btn_end_turn.Enabled = true;
         }
         else
         {
             btn_sell_hotel.Enabled = true;
             btn_sell_land.Enabled  = true;
             MessageBox.Show("you dont have money sell anything  U OWNE or leave the game.");
             btn_leave.Enabled = true;
         }
     }
 }
Esempio n. 3
0
        public override void propertize(int n, ref Panel x, int pic, ref player obj, ref Board game_obj)

        {
            //write this function as a friend one

            // Loading community chest pictures
            if (pic == 1)
            {
                x.BackgroundImage = Image.FromFile(@"commuinty\c1.jpg");
                // player.money -= 20;
                obj.set_money(obj.get_money() - 20);
            }
            else if (pic == 2)
            {
                obj.set_money(obj.get_money() - 50);
                x.BackgroundImage = Image.FromFile(@"commuinty\c2.jpg");
                // player.money-= 50;
            }
            else if (pic == 3)
            {
                obj.set_money(obj.get_money() - 50);
                x.BackgroundImage = Image.FromFile(@"commuinty\c3.jpg");
                // player.money -= 50;
            }
            else if (pic == 4)
            {
                x.BackgroundImage = Image.FromFile(@"commuinty\c4.jpg");
                // player.money -= 25;
                obj.set_money(obj.get_money() - 25);
            }
            else if (pic == 5)
            {
                obj.set_money(obj.get_money() - 100);
                x.BackgroundImage = Image.FromFile(@"commuinty\c5.jpg");
                // player.money -= 100;
            }
            else if (pic == 6)
            {
                x.BackgroundImage = Image.FromFile(@"commuinty\c6.jpg");
                // player.money-= 100;
                obj.set_money(obj.get_money() - 100);
            }
            else if (pic == 7)
            {
                x.BackgroundImage = Image.FromFile(@"commuinty\c7.jpg");
                //call go_to_jail  function;
                MessageBox.Show("you will sent to jail because of commuinty chest.");
                game_obj.jail.set_prisoners_with_going_jail(ref obj);
            }
        }
Esempio n. 4
0
 public bool Checker_double_get_out_from_jail(ref player check_player, bool doub, int no_rolled)
 {
     if (doub == false)
     {
         for (int i = 0; i < prisoners.Count; i++)
         {
             if (prisoners[i].Item1 == check_player)
             {
                 if (prisoners[i].Item2 == 2)
                 {
                     MessageBox.Show("you should pay a fine (50 $).");
                     check_player.set_money(check_player.get_money() - 50);
                     get_out_jail(ref check_player, no_rolled);
                     // prisoners.Remove(prisoners[i]);
                     return(true);
                 }
                 else
                 {
                     prisoners[i] = new Tuple <player, int>(prisoners[i].Item1, (prisoners[i].Item2) + 1);
                     return(false);
                 }
             }
         }
     }
     else
     {
         for (int i = 0; i < prisoners.Count; i++)
         {
             if (prisoners[i].Item1 == check_player)
             {
                 get_out_jail(ref check_player, no_rolled);
                 //  prisoners.Remove(prisoners[i]);
                 return(true);
             }
         }
     }
     return(true);
 }
Esempio n. 5
0
 public override void propertize(int n, ref Panel x, int pic, ref player obj, ref Board game_obj)
 {
     MessageBox.Show("you are in water works so the bank will take 125 $.");
     obj.set_money(obj.get_money() - 125);
 }
Esempio n. 6
0
 public override void propertize(int n, ref Panel x, int pic, ref player obj, ref Board game_obj)
 {
     MessageBox.Show("you are in Electric Company so the bank will take 100 $.");
     obj.set_money(obj.get_money() - 100);
 }
Esempio n. 7
0
        // 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);
            }
        }
Esempio n. 8
0
 public override void propertize(int n, ref Panel x, int pic, ref player obj, ref Board game_obj)
 {
     MessageBox.Show("you are in Super Tax so the bank will take 260 $.");
     obj.set_money(obj.get_money() - 260);
 }