/// <summary> /// Escribe los datos de una variación /// </summary> private void WriteVariation(int indent, int index, MovementVariationModel variation) { // Cabecera Console.WriteLine(new string('\t', indent) + $"Variation {index.ToString()}"); // Movimientos WriteMovements(indent + 1, variation.Movements); }
public MovementSelectVariationViewModel(GameBoardViewModel gameBoardViewModel, MovementVariationModel variation, MovementFigureModel movement) { // Inicializa los objetos GameBoardViewModel = gameBoardViewModel; Movement = movement; Variation = variation; // Inicializa las propiedades Piece = movement.OriginPiece; Color = movement.Color; Text = movement.Content; // Inicializa los comandos SelectMovementCommand = new Mvvm.BaseCommand(parameter => ExecuteMovement(), parameter => CanExecuteMovement()); }
/// <summary> /// Crea los movimientos hasta una variación /// </summary> internal void GoToVariation(MovementVariationModel variation, MovementFigureModel movement) { if (variation != null && movement != null) { // Cambia la variación actual y guarda el movimiento de la variación ActualVariationGame = VariationGame.CloneTo(null, variation, movement); VariationMovement = variation.Parent as MovementFigureModel; // y carga la lista LoadListViewMovements(ActualVariationGame.Movements); // Selecciona el movimiento en la lista y mueve MovementsList.SelectMovement(movement); GoToMovement(MovementsList.ActualMovement); // Indica que está en una variación IsAtVariation = true; } }
/// <summary> /// Convierte una variación /// </summary> private MovementVariationModel ConvertVariation(VariationModel variation, MovementBaseModel parent) { MovementVariationModel movementVariation = new MovementVariationModel(parent); SquareModel board = Board.Clone(); // Ajusta el movimiento al color de inicio de la variación board.Parameters.IsWhiteMove = variation.Movements[0].Turn.Type == TurnModel.TurnType.White; // Presenta el tablero //#if DEBUG // System.Diagnostics.Debug.WriteLine("Board for variation:"); // System.Diagnostics.Debug.WriteLine(board.GetText()); // System.Diagnostics.Debug.WriteLine(new string('-', 80)); //#endif // Convierte los movimientos movementVariation.Movements.AddRange(new MovementConversor(board).Convert(variation.Movements)); // Presenta el tablero real //#if DEBUG // System.Diagnostics.Debug.WriteLine("Board after variation:"); // System.Diagnostics.Debug.WriteLine(Board.GetText()); // System.Diagnostics.Debug.WriteLine(new string('-', 80)); //#endif // Devuelve la variación return(movementVariation); }