Example #1
0
        void DeplacerPiece(int x_depart, int y_depart, int x_arrivee, int y_arrivee, bool makeMove = true)
        {
            if (jeu.DeplacerPiece(x_depart, y_depart, x_arrivee, y_arrivee))
            {
                string[] row =
                { lvwMoveHistory.Items.Count.ToString(), (tempsBlancs.Elapsed + tempsNoirs.Elapsed).ToString(@"hh\:mm\:ss"),
                  $"{PieceStringFormatPosition(x_depart,y_depart)} to " +
                  $"{PieceStringFormatPosition(x_arrivee,y_arrivee)}" };

                lvwMoveHistory.Items.Add(new ListViewItem(row));

                List <string[]> newList = new List <string[]>();

                foreach (ListViewItem item in lvwMoveHistory.Items)
                {
                    string[] subrow = { item.SubItems[0].Text,
                                        item.SubItems[1].Text,
                                        item.SubItems[2].Text };

                    newList.Add(subrow);
                }

                Partie p = (Partie)jeu;

                if (historyIndex < MoveHistory.Count - 1)
                {
                    MoveHistory.RemoveRange(historyIndex, MoveHistory.Count - 1 - historyIndex);
                    tbrRedoMove.Enabled     = false;
                    tbrRedoAllMoves.Enabled = false;
                }

                MoveHistory.Add(new Snapshot()
                {
                    HistoryItems = newList,
                    BlackScore   = int.Parse(lblBlackScore.Text),
                    WhiteScore   = int.Parse(lblWhiteScore.Text),
                    partie       = new Partie(p)
                });

                historyIndex++;

                RefreshScoreAndTakenPieces();

                tbrUndoMove.Enabled     = true;
                tbrUndoAllMoves.Enabled = true;
            }
        }
Example #2
0
 void DeplacerPiece(int x_depart, int y_depart, int x_arrivee, int y_arrivee)
 {
     jeu.DeplacerPiece(x_depart, y_depart, x_arrivee, y_arrivee);
 }