예제 #1
0
        /// <summary>
        ///		Carga en la lista una variación de movimientos
        /// </summary>
        private void LoadVariationMovements(VariationModel variation, int movementIndex, int movementLineIndex, int variationIndex)
        {
            MovementFigureDoubleViewModel          lastMovement          = null;
            MovementFigureVariationDoubleViewModel lastRecursiveMovement = null;

            foreach (MovementBaseModel movement in variation.Movements)
            {
                switch (movement)
                {
                case MovementFigureModel move:
                    // Añade a la lista un movimiento real o un movimiento recursivo
                    if (variationIndex == 0)
                    {
                        // Añade el movimiento a la lista de movimientos de piezas (sin comentarios)
                        FigureMovements.Add(move);
                        // Crea el movimiento para la lista
                        lastMovement          = CreateRealMovement(lastMovement, move, movementIndex, movementLineIndex);
                        lastRecursiveMovement = null;
                    }
                    else if (PgnGameViewModel.ShowVariations)
                    {
                        lastRecursiveMovement = CreateRecursiveMovement(lastRecursiveMovement, move, movementIndex, movementLineIndex, variationIndex);
                        lastMovement          = null;
                    }
                    // Incrementa los índices de movimientos
                    movementIndex++;
                    if (move.Color == Bau.Libraries.LibChessGame.Board.Pieces.PieceBaseModel.PieceColor.Black)
                    {
                        movementLineIndex++;
                    }
                    break;

                case MovementRemarksModel move:
                    Movements.Add(new MovementRemarkViewModel(move));
                    lastMovement          = null;
                    lastRecursiveMovement = null;
                    break;

                case MovementGameEndModel move:
                    Movements.Add(new MovementGameEndViewModel(move));
                    lastMovement          = null;
                    lastRecursiveMovement = null;
                    break;
                }
            }
        }
예제 #2
0
 /// <summary>
 ///		Carga los movimientos de la variación
 /// </summary>
 internal void LoadMovements(VariationModel variation)
 {
     // Limpia los movimientos
     Movements.Clear();
     FigureMovements.Clear();
     // Inicializa el tablero
     GameBoard = new GameBoardModel(variation);
     GameBoard.Reset();
     // Carga los movimientos
     if (variation != null)
     {
         LoadVariationMovements(variation, 1, 1, 0);
     }
     // Añade un comentario si no había ningún movimiento
     if (Movements.Count == 0)
     {
         Movements.Add(new MovementRemarkViewModel(new MovementRemarksModel("No hay ningún movimiento en este juego")));
     }
     // Inicializa los movimientos
     _actualMovementIndex = 0;
 }