Exemplo n.º 1
0
        public PartialViewResult ActivateCell(string x, string y)
        {
            int            USERID      = int.Parse(new JavaScriptSerializer().Serialize(Session["userid"]));
            int            Column      = int.Parse(x.Trim());
            int            Row         = int.Parse(y.Trim());
            GameLogicBLL   gameService = new GameLogicBLL();
            GameBoardModel grid        = Globals.Grid;

            grid.Cells[Column, Row].IsVisited = true;

            Globals.numberClicks++;
            grid.Clicks = Globals.numberClicks;

            if (grid.Cells[Column, Row].IsLive)
            {
                gameService.PublishGameStats(grid, USERID, this.ElapsedTime());
                return(EndGame());
            }
            else
            {
                if (grid.Cells[Column, Row].LiveNeighbors == 0)
                {
                    gameService.showNeighbors(Globals.Grid, Globals.Grid.Cells[Column, Row].Column, Globals.Grid.Cells[Column, Row].Row);
                }
                gameService.UpdateGrid(grid, USERID);
            }

            return(PartialView("Index", grid));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public BattlePage()
        {
            InitializeComponent();

            GameBoardModel.Wipe();

            int left = 0;

            foreach (PlayerInfoModel character in EngineViewModel.Engine.CharacterList)
            {
                MapObject location = GameBoardModel.Locations.Find(a => (a.x == left && a.y == 0));
                location.Id            = character.Id;
                location.ImageURI      = character.ImageURI;
                location.MapObjectType = MapObjectEnum.Character;
                location.Selected      = false;
                left++;
            }

            left = 0;
            foreach (PlayerInfoModel monster in EngineViewModel.Engine.MonsterList)
            {
                MapObject location = GameBoardModel.Locations.Find(a => (a.x == left && a.y == GameBoardModel.Size - 1));
                location.Id            = monster.Id;
                location.ImageURI      = monster.ImageURI;
                location.MapObjectType = MapObjectEnum.Monster;
                location.Selected      = false;
                left++;
            }

            RefreshGameBoard();
        }
Exemplo n.º 3
0
    private void updatePlayerPos()
    {
        GameBoardModel gb   = app.game_board_model;
        Vector3        dest = new Vector3(gb.player.col, gb.player.row, -.05f);

        player.transform.position = Vector3.Lerp(player.transform.position, dest, speed * Time.deltaTime);
    }
Exemplo n.º 4
0
        /// <summary>
        /// Get the closest item to the specified Player
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public int[] GetClosestItem(PlayerInfoModel player)
        {
            int[] PlayerLocation = GameBoardModel.GetPlayerLocation(player);
            int[] location       = { Int32.MaxValue, Int32.MaxValue };

            // Get closest Character
            int closestDistance = Int32.MaxValue;

            for (int x = 0; x < GameBoardModel.Size; ++x)
            {
                for (int y = 0; y < GameBoardModel.Size; ++y)
                {
                    if (GameBoardModel.ItemLocations[x, y] != null)
                    {
                        int distance = GameBoardHelper.Distance(x, y, PlayerLocation[0], PlayerLocation[1]);
                        if (distance < closestDistance)
                        {
                            location[0] = x;
                            location[1] = y;
                        }
                    }
                }
            }

            return(location);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Attack as a Turn
        ///
        /// Pick who to go after
        ///
        /// Determine the Attack score
        /// Determine the Defense score
        ///
        /// Do the Attack
        ///
        /// </summary>
        /// <param name="Attacker"></param>
        /// <returns></returns>
        public bool Attack(PlayerInfoModel Attacker)
        {
            // For Attack, Choose Who
            var TargetLocation = AttackChoice(Attacker);

            if (TargetLocation[0] == Int32.MaxValue)
            {
                return(false);
            }

            int[] attackerLocation = GameBoardModel.GetPlayerLocation(Attacker);
            int   Distance         = GameBoardHelper.Distance(attackerLocation[0], attackerLocation[1], TargetLocation[0], TargetLocation[1]);

            int AttackRange = 1;

            if (Attacker.Head != null)
            {
                AttackRange = ItemIndexViewModel.Instance.GetItem(Attacker.Head).Range;
            }

            if (Distance > AttackRange || Attacker.CurrentStamina < 3)
            {
                return(false);
            }

            // Do Attack
            PlayerInfoModel TargetModel = GameBoardModel.GetPlayer(TargetLocation[0], TargetLocation[1]);

            TurnAsAttack(Attacker, TargetModel);

            CurrentAttacker = new PlayerInfoModel(Attacker);
            CurrentDefender = new PlayerInfoModel(TargetModel);

            return(true);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Clear the List between Rounds
 /// </summary>
 /// <returns></returns>
 private bool ClearLists()
 {
     GameBoardModel.Wipe();
     ItemPool.Clear();
     MonsterList.Clear();
     return(true);
 }
Exemplo n.º 7
0
    private bool checkWin()
    {
        GameBoardModel gb = app.game_board_model;

        if (gb.player.currentTile == null)
        {
            return(false);
        }
        if (gb.player.currentTile.type != TileType.End)
        {
            return(false);
        }

        for (int row = 0; row < gb.height; row++)
        {
            for (int col = 0; col < gb.width; col++)
            {
                if (gb.board[row][col].type == TileType.Dirty)
                {
                    return(false);
                }
            }
        }


        print("you win");
        return(true);
    }
        /// <summary>
        ///		Crea las acciones asociadas a un movimiento
        /// </summary>
        internal void CreateActions(GameBoardModel board, MovementFigureModel movement,
                                    CellModel target, CellModel origin, PieceBaseModel.PieceType?targetPiece)
        {
            PieceBaseModel piece = board.SearchMoveTo(movement, target, origin);

            // Comprueba que se haya localizado la pieza que hizo el movimiento
            if (piece == null)
            {
                throw new Exceptions.GameReaderException($"No se encuentra ninguna pieza que pueda realizar el movimiento {movement.Text}");
            }
            // Crea el movimiento
            CreateMoveAction(piece.Type, piece.Color, piece.Cell, target);
            // Crea la captura
            if (movement.Type == MovementFigureModel.MovementType.Capture || movement.Type == MovementFigureModel.MovementType.CaptureEnPassant)
            {
                CreateCaptureAction(board, targetPiece, GetNextColor(movement.Color), target);
            }
            // Crea la promoción
            if (movement.PromotedPiece != null)
            {
                // Crea un movimiento para eliminar el peón que se ha promocionado
                //? No llama a CreateCaptureAction porque si ha habido una captura en este mismo movimiento
                //? la pieza aún no se habrá eliminado del destino y por tanto nos creará una captura
                //? sobre la pieza que se ha eliminado ya
                Add(new ActionCaptureModel(piece.Type, movement.Color, target));
                // Crea una promoción
                CreatePromoteAction(movement.PromotedPiece, movement.Color, target);
            }
        }
Exemplo n.º 9
0
        public void UpdateGrid(GameBoardModel grid, int userID)
        {
            // Send updated Grid to DB
            DAObusiness businessService = new DAObusiness();

            businessService.UpdateGrid(grid, userID);
        }
Exemplo n.º 10
0
        public void OnGet()
        {
            Games            = _igame.GetCurrentGame();
            UserGame         = _igame.GetUserGame();
            navyBattlePieces = _igame.GetBoard();

            GameBoard = new GameBoardModel(navyBattlePieces, UserGame, _igame.GetActiveUserId());
        }
        /// <summary>
        ///		Crea una captura
        /// </summary>
        private void CreateCaptureAction(GameBoardModel board, PieceBaseModel.PieceType?piece, PieceBaseModel.PieceColor color, CellModel from)
        {
            PieceBaseModel targetPiece = board.Pieces.GetPiece(from);

            //? En ocasiones la pieza leída no es la real del tablero, por eso buscamos la pieza adecuada
            // Añade la pieza
            Add(new ActionCaptureModel(targetPiece?.Type ?? piece ?? PieceBaseModel.PieceType.Unknown, color, from));
        }
Exemplo n.º 12
0
        private void InitGameBoard(int columnsCount, int rowsCount)
        {
            Buttons = new ObservableCollection <Button>();

            gameBoardModel = new GameBoardModel()
            {
                GameField = CreateGameFieldArray(columnsCount, rowsCount)
            };
        }
Exemplo n.º 13
0
        public async Task <HttpResponseMessage> Get(long id)
        {
            var player = ApplicationUser.GetCurrentPlayer(this.User);

            var game = await this.gameService.GetGameAsync(id);

            var result = new GameBoardModel(game, player);

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Exemplo n.º 14
0
    // Load a new script
    internal bool LoadGame(ScriptInfo script)
    {
        var model = GameBoardModel.Create(this, script);

        if (model != null)
        {
            Launch(model);
        }
        return(model != null);
    }
Exemplo n.º 15
0
 /// <summary>
 ///		Comprueba si la pieza se puede mover a una fila / columna
 /// </summary>
 public override bool CanMoveTo(GameBoardModel board, CellModel target, Movements.MovementFigureModel.MovementType type)
 {
     // Comprueba si es un movimiento horizontal / diagonal de un solo recuadro
     if (IsVerticalHorizontalMovement(target, true) || IsDiagonalMovement(target, true))
     {
         return(IsLegal(board, target, type));
     }
     // Si ha llegado hasta aquí es porque el movimiento no era legal
     return(false);
 }
Exemplo n.º 16
0
 /// <summary>
 ///		Comprueba si la pieza se puede mover a una fila / columna
 /// </summary>
 public override bool CanMoveTo(GameBoardModel board, CellModel target, Movements.MovementFigureModel.MovementType type)
 {
     // Comprueba si puede mover
     if (IsDiagonalMovement(target, false))
     {
         return(board.IsEmpty(Cell, target) && IsLegal(board, target, type));
     }
     // Devuelve el valor que indica si puede mover
     return(false);
 }
Exemplo n.º 17
0
        public void UpdateGrid(GameBoardModel grid, int userid)
        {
            try {
                // Setup INSERT query with parameters
                string query = "UPDATE dbo.Grids SET ROWS = @Rows, COLS = @Cols, UserID = @UserID, HasWon = @HasWon, Clicks = @Clicks WHERE ID=@ID";

                SqlCommand cmd = new SqlCommand(query, this.conn);

                cmd.Parameters.Add("@Rows", SqlDbType.Int, 11).Value   = grid.Rows;
                cmd.Parameters.Add("@Cols", SqlDbType.Int, 11).Value   = grid.Cols;
                cmd.Parameters.Add("@UserID", SqlDbType.Int, 11).Value = userid;
                cmd.Parameters.Add("@HasWon", SqlDbType.VarChar).Value = grid.HasWon;
                cmd.Parameters.Add("@Clicks", SqlDbType.Int, 11).Value = grid.Clicks;
                cmd.Parameters.Add("@ID", SqlDbType.Int, 11).Value     = grid.ID;

                conn.Open();

                cmd.ExecuteNonQuery();

                conn.Close();
            } catch (SqlException e) {
                throw e;
            }


            try {
                // Setup INSERT query with parameters
                string query = "UPDATE dbo.Cells SET Col = @Col, Row = @Row, IsLive = @IsLive, IsVisited = @IsVisited, LiveNeighbors = @LiveNeighbors, " +
                               "GridID = @GridID WHERE ID=@ID";

                // Create connection and command
                for (int y = 0; y < grid.Rows; y++)
                {
                    for (int x = 0; x < grid.Cols; x++)
                    {
                        SqlCommand cmd = new SqlCommand(query, this.conn);
                        cmd.Parameters.Add("@Col", SqlDbType.Int, 11).Value           = grid.Cells[x, y].Column;
                        cmd.Parameters.Add("@Row", SqlDbType.Int, 11).Value           = grid.Cells[x, y].Row;
                        cmd.Parameters.Add("@IsLive", SqlDbType.VarChar).Value        = grid.Cells[x, y].IsLive;
                        cmd.Parameters.Add("@IsVisited", SqlDbType.VarChar).Value     = grid.Cells[x, y].IsVisited;
                        cmd.Parameters.Add("@LiveNeighbors", SqlDbType.Int, 11).Value = grid.Cells[x, y].LiveNeighbors;
                        cmd.Parameters.Add("@GridID", SqlDbType.Int, 11).Value        = grid.ID;
                        cmd.Parameters.Add("@ID", SqlDbType.Int, 11).Value            = grid.Cells[x, y].ID;

                        // Open the connection, execute INSERT, and close the connection
                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                }
            } catch (SqlException e) {
                throw e;
            }
        }
Exemplo n.º 18
0
 public void OnGet()
 {
     Games     = _igame.GetCurrentGame();
     UserGames = _igame.GetUserGames();
     for (int board = 0; board < UserGames.Count(); board++)
     {
         IList <NavyBattlePiece> navyBattlePieces = _igame.GetNavyBattlePieces(UserGames[board].Id);
         GameBoardModel          newBoard         = new GameBoardModel(navyBattlePieces, UserGames[board], _igame.GetActiveUserId());
         GameBoardModels.Add(newBoard);
     }
 }
Exemplo n.º 19
0
        public async Task <IActionResult> GetGameStatus([FromHeader] string authToken)
        {
            var user = UserContext.User;

            var gameBoard = GameContext.GetContextByPlayer(user).GameBoard;
            //to do view model
            var gameBoardModel = new GameBoardModel(gameBoard);
            var result         = await Task.Run(() => { return(gameBoardModel.GetInfo()); });

            return(await SuccessResponse(result));
        }
Exemplo n.º 20
0
        public void CreateGrid(GameBoardModel grid, int userid)
        {
            int gridID;

            try {
                // Setup INSERT query with parameters
                string query = "INSERT INTO dbo.Grids (Rows, Cols, UserID, HasWon, Clicks) " +
                               "VALUES (@Rows, @Cols, @UserID, @HasWon, @Clicks) SELECT SCOPE_IDENTITY()";
                SqlCommand cmd = new SqlCommand(query, this.conn);

                cmd.Parameters.Add("@Rows", SqlDbType.Int, 11).Value   = grid.Rows;
                cmd.Parameters.Add("@Cols", SqlDbType.Int, 11).Value   = grid.Cols;
                cmd.Parameters.Add("@UserID", SqlDbType.Int, 11).Value = userid;
                cmd.Parameters.Add("@HasWon", SqlDbType.VarChar).Value = grid.HasWon;
                cmd.Parameters.Add("@Clicks", SqlDbType.Int, 11).Value = grid.Clicks;

                conn.Open();

                gridID = Convert.ToInt32(cmd.ExecuteScalar());

                conn.Close();
            } catch (SqlException e) {
                throw e;
            }


            try {
                // Setup INSERT query with parameters
                string query = "INSERT INTO dbo.Cells (Col, Row, IsLive, IsVisited, LiveNeighbors, GridID) " +
                               "VALUES (@Col, @Row, @IsLive, @IsVisited, @LiveNeighbors, @GridID)";

                // Create connection and command
                for (int y = 0; y < grid.Rows; y++)
                {
                    for (int x = 0; x < grid.Cols; x++)
                    {
                        SqlCommand cmd = new SqlCommand(query, this.conn);
                        cmd.Parameters.Add("@Col", SqlDbType.Int, 11).Value           = grid.Cells[x, y].Column;
                        cmd.Parameters.Add("@Row", SqlDbType.Int, 11).Value           = grid.Cells[x, y].Row;
                        cmd.Parameters.Add("@IsLive", SqlDbType.VarChar).Value        = grid.Cells[x, y].IsLive;
                        cmd.Parameters.Add("@IsVisited", SqlDbType.VarChar).Value     = grid.Cells[x, y].IsVisited;
                        cmd.Parameters.Add("@LiveNeighbors", SqlDbType.Int, 11).Value = grid.Cells[x, y].LiveNeighbors;
                        cmd.Parameters.Add("@GridID", SqlDbType.Int, 11).Value        = gridID;

                        // Open the connection, execute INSERT, and close the connection
                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                }
            } catch (SqlException e) {
                throw e;
            }
        }
Exemplo n.º 21
0
        // Attack or Move
        // Roll To Hit
        // Decide Hit or Miss
        // Decide Damage
        // Death
        // Drop Items
        // Turn Over
        #endregion Algrorithm

        /// <summary>
        /// Perform a turn and attack the target
        /// </summary>
        /// <param name="Attacker"></param>
        /// <returns></returns>
        public bool TakeTurn(PlayerInfoModel Attacker)
        {
            // Replenish Stamina
            Attacker.CurrentStamina = Attacker.BaseStamina;

            // Choose Action.  Such as Move, Attack etc.

            // while an action is possible
            // If Nearest enemy in range and have an item, then Attack
            // If in range of an item, then move onto Item

            // if we don't have an item
            if (Attacker.Head == null)
            {
                // move to item
                int[] closestItem = GetClosestItem(Attacker);
                if (closestItem[0] != Int32.MaxValue && closestItem[1] != Int32.MaxValue)
                {
                    // Move towards the Item, conserving 3 stamina for the attack
                    Attacker.CurrentStamina = MoveTowards(Attacker, closestItem, 3, GameBoardModel.GetItem(closestItem[0], closestItem[1]).Name);
                }

                int[] PlayerLocation = GameBoardModel.GetPlayerLocation(Attacker);

                int[] newestClosest = GetClosestItem(Attacker);
                if (newestClosest[0] != Int32.MaxValue && newestClosest[1] != Int32.MaxValue &&
                    GameBoardHelper.Distance(newestClosest[0], newestClosest[1], PlayerLocation[0], PlayerLocation[1]) <= 1)
                {
                    ItemModel temp = GameBoardModel.ItemLocations[newestClosest[0], newestClosest[1]];
                    Attacker.Head = temp.Id;
                    Debug.WriteLine(Attacker.Name + " picked up " + temp.Name);
                    GameBoardModel.ItemLocations[newestClosest[0], newestClosest[1]] = null;
                }
            }

            // then try an attack
            var attacks = Attack(Attacker);

            if (!attacks)
            {
                // move toward enemy
                int[] TargetLocation = AttackChoice(Attacker);

                if (TargetLocation[0] == Int32.MaxValue)
                {
                    return(attacks);
                }
            }

            BattleScore.TurnCount++;

            return(attacks);
        }
Exemplo n.º 22
0
        public JsonResult TakeShot([FromBody] TakeShotViewModel shot)
        {
            GameBoardModel   player        = JsonConvert.DeserializeObject <GameBoardModel>(HttpContext.Session.GetString("player"));
            GameBoardModel   opponentModel = JsonConvert.DeserializeObject <GameBoardModel>(HttpContext.Session.GetString("opponentModel"));
            ezbot            opponent      = new ezbot(opponentModel);
            Tuple <int, int> incomingShotGuess;
            //Resolve player shot
            var opponentHit = false;

            switch (opponent.ReceiveShot(shot.row, shot.col))
            {
            case ShotStatus.Hit:
                opponentHit = true;
                break;

            case ShotStatus.Miss:
                opponentHit = false;
                break;

            case ShotStatus.OutofBounds:
                return(Json(new { modelResponse = opponent.model.Error }));
            }
            player.UpdateAfterShot(shot.row, shot.col, opponentHit);
            //Check for player win condition
            var playerWin = false;

            playerWin = opponent.model.CheckLose();
            //Opponent takes a shot
            incomingShotGuess = opponent.TakeShot();
            //Player Receives shot
            var  playerHit     = player.ReceiveShot(incomingShotGuess.Item1, incomingShotGuess.Item2);
            bool playerHitData = true;

            if (playerHit == ShotStatus.Hit)
            {
                playerHitData = true;
            }
            else if (playerHit == ShotStatus.Miss)
            {
                playerHitData = false;
            }
            opponent.model.UpdateAfterShot(incomingShotGuess.Item1, incomingShotGuess.Item2, playerHitData);
            //check for opponent win condition
            var opponentWin = false;

            opponentWin = player.CheckLose();
            //return the results


            HttpContext.Session.SetString("player", JsonConvert.SerializeObject(player));
            HttpContext.Session.SetString("opponentModel", JsonConvert.SerializeObject(opponent.model));
            return(Json(new { win = new { playerWin = playerWin, opponentWin = opponentWin }, modelResponse = opponentHit, incomingShot = new { playerHit = playerHitData, row = incomingShotGuess.Item1, col = incomingShotGuess.Item2 } }));
        }
    public override void OnNotification(string p_event_path, UnityEngine.Object p_target, params object[] p_data)
    {
        GameBoardModel gb     = app.game_board_model;
        GameBoardEvent action = null;

        switch (p_event_path)
        {
        case "user.press.up":
        {
            ActorMoveEvent a = gameObject.AddComponent <ActorMoveEventUp>();
            a.addActor(gb.player);
            action = a;
            break;
        }

        case "user.press.down":
        {
            ActorMoveEvent a = gameObject.AddComponent <ActorMoveEventDown>();
            a.addActor(gb.player);
            action = a;
            break;
        }

        case "user.press.left":
        {
            ActorMoveEvent a = gameObject.AddComponent <ActorMoveEventLeft>();
            a.addActor(gb.player);
            action = a;
            break;
        }

        case "user.press.right":
        {
            ActorMoveEvent a = gameObject.AddComponent <ActorMoveEventRight>();
            a.addActor(gb.player);
            action = a;
            break;
        }

        case "user.undo":
        {
            GameBoardEvent a = gameObject.AddComponent <GameBoardUndoEvent>();
            action = a;
            break;
        }
        }

        if (action != null)
        {
            gb.events.Enqueue(action);
        }
    }
Exemplo n.º 24
0
    private void updateMud()
    {
        GameBoardModel gb = app.game_board_model;

        for (int col = 0; col < gb.width; col++)
        {
            for (int row = 0; row < gb.height; row++)
            {
                bool muddy = (gb.board[row][col].type == TileType.Dirty);
                mud_array[row][col].gameObject.GetComponent <Renderer>().enabled = muddy;
            }
        }
    }
Exemplo n.º 25
0
    private void updateClean()
    {
        GameBoardModel gb = app.game_board_model;

        for (int col = 0; col < gb.width; col++)
        {
            for (int row = 0; row < gb.height; row++)
            {
                bool clean = (gb.board[row][col].type == TileType.Clean);
                clean_array[row][col].gameObject.GetComponent <Renderer>().enabled = clean;
            }
        }
    }
Exemplo n.º 26
0
        public GameBoardView()
        {
            this.InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            var firstPlayer = new HumanPlayer("Koko", "X")
            {
                IsOnTurn = true
            };

            var secondPlayer   = new HumanPlayer("Boko", "O");
            var gameBoardModel = new GameBoardModel(firstPlayer, secondPlayer);

            this.presenter = new GameBoardPresenter(this, gameBoardModel);
        }
Exemplo n.º 27
0
    //----- implementation -----

    // Called to start a game previously selected
    void Launch(GameBoardModel model)
    {
        if (model == null)
        {
            return;
        }
        SetState(GameState.NewGame);
        _model = model;
        // reset AI params
        _model.ThinkTime = ThinkTime;
        _model.StepCount = StepCount;
        _model.MaxDepth  = MaxDepth;
        _uimx.CloseCurrent();
        StartCoroutine(FadeAndGo());
    }
        /// <summary>
        ///		Crea las acciones de enroque
        /// </summary>
        internal void CreateCastleKingActions(GameBoardModel board, MovementFigureModel movement)
        {
            int row = movement.Color == PieceBaseModel.PieceColor.White ? 7 : 0;

            if (movement.Type == MovementFigureModel.MovementType.CastleKingSide)                     // enroque corto
            {
                CreateMoveAction(PieceBaseModel.PieceType.Rook, movement.Color, new CellModel(row, 7), new CellModel(row, 5));
                CreateMoveAction(PieceBaseModel.PieceType.King, movement.Color, new CellModel(row, 4), new CellModel(row, 6));
            }
            else                     // enroque largo
            {
                CreateMoveAction(PieceBaseModel.PieceType.Rook, movement.Color, new CellModel(row, 0), new CellModel(row, 3));
                CreateMoveAction(PieceBaseModel.PieceType.King, movement.Color, new CellModel(row, 4), new CellModel(row, 2));
            }
        }
Exemplo n.º 29
0
    void Start()
    {
        Items.FindAllGames();
        var initial = Items.ScriptList.Find(s => s.Filename.ToLower() == InitialScript.ToLower()) ?? Items.ScriptList[0];
        var model   = GameBoardModel.Create(this, initial);

        if (model != null && InitialVariant > 0 && InitialVariant < model.GameList.Count)
        {
            model = model.Create(InitialVariant);
        }
        if (model == null)
        {
            Quit();
        }
        Launch(model);
    }
        /// <summary>
        ///		Añade un movimiento a la lista
        /// </summary>
        private MovementFigureModel ParseMovement(GameBoardModel board, PieceBaseModel.PieceColor actualColor, Move move)
        {
            MovementFigureModel newMovement   = new MovementFigureModel();
            CellConversor       cellConversor = new CellConversor();

            // Asigna los datos
            newMovement.Color         = actualColor;
            newMovement.Type          = ConvertMovement(move.Type);
            newMovement.Text          = move.ToString();
            newMovement.IsCheck       = move.IsCheck ?? false;
            newMovement.IsDoubleCheck = move.IsDoubleCheck ?? false;
            newMovement.IsCheckMate   = move.IsCheckMate ?? false;
            switch (newMovement.Type)
            {
            case MovementFigureModel.MovementType.CastleKingSide:
            case MovementFigureModel.MovementType.CastleQueenSide:
                // Asigna la pieza de origen
                newMovement.OriginPiece = PieceBaseModel.PieceType.Rook;
                // Crea las acciones de enroque
                newMovement.Actions.CreateCastleKingActions(board, newMovement);
                break;

            default:
                PieceBaseModel.PieceType?targetPiece = null;

                // Asigna los datos
                newMovement.OriginPiece = ConvertPiece(move.Piece);
                targetPiece             = ConvertPiece(move.TargetPiece);
                // Añade la pieza promocionada
                if (move.PromotedPiece != null)
                {
                    newMovement.PromotedPiece = ConvertPiece(move.PromotedPiece);
                }
                // Crea las acciones
                newMovement.Actions.CreateActions(board, newMovement,
                                                  cellConversor.ConvertCell(move.TargetSquare.Rank, move.TargetSquare.File),
                                                  cellConversor.ConvertCell(move.OriginRank, move.OriginFile),
                                                  targetPiece);
                break;
            }
            newMovement.Annotation = ConvertAnnotation(move.Annotation);
            // Ejecuta los movimientos sobre el tablero
            board.Execute(newMovement);
            // Devuelve el movimiento
            return(newMovement);
        }