Exemplo n.º 1
0
        // -- Free action play
        private void Free_Play()
        {
            displaySpace = YoteClass.SpaceOpponentBoard(Board, (CurrentPlayer == Type_Player.One) ? State_Space.Two
                                                                                                 : State_Space.One);

            foreach (var val in displaySpace)
            {
                // -- Disply new space
                ((PictureBox)pan_game.Controls.Find($"{id_block_name}{val.Row}{val.Column}", false)[0]).BackColor = Color.Green;

                // -- Action to free play
                actionFree = true;
            }
        }
Exemplo n.º 2
0
        // -- Generate victory
        private void Generate_Victory(Type_Player player)
        {
            if (isNotFirstplay && YoteClass.IsVictory(Board, player))
            {
                MessageBox.Show(
                    $"Félicitation, le joueur{((player == Type_Player.One) ? "1 (" + Player_2.name + ")" : "2 (" + Player_1.name + ")")} a gagné!",
                    "Information",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                    );

                // -- Event new gae
                nouvellePartieToolStripMenuItem1.PerformClick();
            }
        }
Exemplo n.º 3
0
        // -- Computer play
        private void Computer_Play()
        {
            toolStripProgressBar.Value = 0;
            // -- Affichier le jeux -- //
            this.panTransform.Visible = false;
            timer.Stop();

            // -- Bulid bloc forgame -- //
            string id_block = MinMax.IA_jouer(YoteClass.CloneBoard(Board), Player_1, Player_2);

            var block = (PictureBox)pan_game.Controls.Find($"{id_block_name}{id_block}", false)[0];

            // -- Call action play -- //
            Action_Player(block);
        }
Exemplo n.º 4
0
        private void bt_go_Click(object sender, EventArgs e)
        {
            // -- Valisation form -- //
            if (!YoteClass.isValue(new string[] { txtBox_name1.Text, cBox_name2.Text }))
            {
                MessageBox.Show("Veuillez entrer les noms des joueurs!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                // -- Initialise -- //
                Program.form_application = new Form_Main(txtBox_name1.Text, cBox_name2.Text);
                Program.form_application.Show();

                // -- me close -- //
                this.Hide();
            }
        }
Exemplo n.º 5
0
        // -- Display move -- //
        private void Display_Move(Space space_block)
        {
            // -- Get display space -- //
            displaySpace = Space.Enable_Space(Board, space_block, CurrentPlayer);

            // -- Disply selected
            ((PictureBox)pan_game.Controls.Find($"{id_block_name}{space_block.Row}{space_block.Column}", false)[0]).BackColor = Color.LightGoldenrodYellow;
            // -- Display all enable space -- //
            foreach (var space in displaySpace)
            {
                // -- Check previous action
                if (!YoteClass.IsPreviousAction(CurrentPlayer == Type_Player.One ? Player_1 : Player_2, space_block, space, actionFree))
                {
                    ((PictureBox)pan_game.Controls.Find($"{id_block_name}{space.Row}{space.Column}", false)[0]).BackColor = (space.State == State_Space.None) ? Color.Green
                                                                                                                                                              : ((CurrentPlayer == Type_Player.One && space.State == State_Space.Two) || (CurrentPlayer == Type_Player.Two && space.State == State_Space.One)) ? Color.Red
                                                                                                                                                                                                                                                                                                               : Color.Transparent;
                }
                lb_status_game.Text = "Vous devez selectionner un des emplacements de jeux!";
            }

            // -- Set currenttoken
            CurrentToken = space_block;
        }
Exemplo n.º 6
0
        // -- Move token -- //
        private void Move_Current_Token(Space new_space, ref Boolean isWin)
        {
            if (!actionFree)
            {
                // -- Update state boad
                Board[CurrentToken.Row, CurrentToken.Column] = State_Space.None;

                // -- Get win token -- //
                Space win_token = YoteClass.WinTokenExist(new_space, CurrentToken);

                if (CurrentPlayer == Type_Player.One)
                {
                    // -- Update state boad
                    Board[new_space.Row, new_space.Column] = State_Space.One;
                    // -- Add move in token
                    Add_Move_In_Token_Player(Player_1, new_space);

                    // -- Check if win token exist
                    if (win_token != null)
                    {
                        // -- increment score
                        Player_1.score++;
                        // -- Pic hand
                        pb_hand_player_1.Image = Resources.hand_get;

                        isWin = true;
                    }

                    // -- Disply new space
                    ((PictureBox)pan_game.Controls.Find($"{id_block_name}{new_space.Row}{new_space.Column}", false)[0]).Image = Resources.ball_gray;
                }
                else
                {
                    // -- Update state boad
                    Board[new_space.Row, new_space.Column] = State_Space.Two;
                    // -- Add move in token
                    Add_Move_In_Token_Player(Player_2, new_space);

                    // -- Check if win token exist
                    if (win_token != null)
                    {
                        // -- increment score
                        Player_2.score++;
                        // -- Pic hand
                        pb_hand_player_2.Image = Resources.hand_get;

                        isWin = true;
                    }

                    // -- Disply new space
                    ((PictureBox)pan_game.Controls.Find($"{id_block_name}{new_space.Row}{new_space.Column}", false)[0]).Image = Resources.ball_black;
                }
                // -- Update win token
                Win_Token(win_token, new_space);
            }
            else
            {
                if (CurrentPlayer == Type_Player.One)
                {
                    // -- increment score
                    Player_1.score++;
                    // -- Pic hand
                    pb_hand_player_1.Image = Resources.Hand;
                }
                else
                {
                    // -- increment score
                    Player_2.score++;
                    // -- Pic hand
                    pb_hand_player_2.Image = Resources.Hand;
                }
                // -- Update win token
                Win_Token(new_space, new_space);
            }
        }