Esempio n. 1
0
        public IHttpActionResult EndMove(EndMoveModel m)
        {
            Board board = db.Boards.Find(m.BoardId);

            if (board == null)
            {
                return(null);
            }

            var newMove = board.EndCurrentPlayerTurn();

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                throw;
            }

            MoveResponseModel response = new MoveResponseModel();

            response.move         = newMove;
            response.ActivePlayer = board.ActiveBoardPlayer;

            return(CreatedAtRoute("DefaultApi", null, response));
        }
Esempio n. 2
0
        public IHttpActionResult BuildHotel(EndMoveModel m)
        {
            Board     board = db.Boards.Find(m.BoardId);
            BoardUser bu    = board.GetBoardUser(board.ActiveBoardPlayer.UserName);
            Property  p     = board.GetPropertyWithPos(bu.Position);

            bu.BuildHotel(p);

            Move newMove = new Move();

            newMove.Roll        = 0;
            newMove.Board       = board;
            newMove.Description = board.ActiveBoardPlayer.UserName + " built a hotel.";
            newMove.UserName    = board.ActiveBoardPlayer.UserName;
            newMove.User        = board.ActiveBoardPlayer;

            board.Moves.Add(newMove);

            MoveResponseModel response = new MoveResponseModel();

            response.move         = newMove;
            response.ActivePlayer = board.ActiveBoardPlayer;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                throw;
            }

            return(CreatedAtRoute("DefaultApi", null, response));
        }