public void SetPawnColumn(RealTimeChessDbContext context, int nFileNumber, int nBoardHeight) { ChessPieceType typePawn = context.ChessPieceType.SingleOrDefault(t => t.ChessPieceTypeName == "Pawn"); int nPawnTypeId = typePawn.ChessPieceTypeId; for (int i = 1; i < 9; i++) { ChessPiece pawn = new ChessPiece(this.MatchPlayerId, nPawnTypeId, i, nFileNumber); context.ChessPiece.Add(pawn); } context.SaveChanges(); }
public void SetRoyalColumn(RealTimeChessDbContext context, int nFileNum, int nBoardWidth) { int nTypeIdKing = (context.ChessPieceType.SingleOrDefault(t => t.ChessPieceTypeName == "King")).ChessPieceTypeId; int nTypeIdQueen = (context.ChessPieceType.SingleOrDefault(t => t.ChessPieceTypeName == "Queen")).ChessPieceTypeId; int nTypeIdBishop = (context.ChessPieceType.SingleOrDefault(t => t.ChessPieceTypeName == "Bishop")).ChessPieceTypeId; int nKTypeIdKnight = (context.ChessPieceType.SingleOrDefault(t => t.ChessPieceTypeName == "King")).ChessPieceTypeId; int nTypeIdRook = (context.ChessPieceType.SingleOrDefault(t => t.ChessPieceTypeName == "Rook")).ChessPieceTypeId; context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nTypeIdRook, 8, nFileNum)); // ChessPiece RookLeft context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nKTypeIdKnight, 7, nFileNum)); // ChessPiece KnightLeft context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nTypeIdBishop, 6, nFileNum)); // ChessPiece BishopLeft context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nTypeIdKing, 5, nFileNum)); // ChessPiece King context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nTypeIdQueen, 4, nFileNum)); // ChessPiece Queen context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nTypeIdBishop, 3, nFileNum)); // ChessPiece BishopRight context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nKTypeIdKnight, 2, nFileNum)); // ChessPiece KnightRight context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nTypeIdRook, 1, nFileNum)); // ChessPiece RookRight context.SaveChanges(); }
public void SetRoyalRow(RealTimeChessDbContext context, int nRankNumber, int nBoardWidth) { int nTypeIdKing = context.ChessPieceType.SingleOrDefault(t => t.ChessPieceTypeName == "King").ChessPieceTypeId; int nTypeIdQueen = context.ChessPieceType.SingleOrDefault(t => t.ChessPieceTypeName == "Queen").ChessPieceTypeId; int nTypeIdBishop = context.ChessPieceType.SingleOrDefault(t => t.ChessPieceTypeName == "Bishop").ChessPieceTypeId; int nKTypeIdKnight = context.ChessPieceType.SingleOrDefault(t => t.ChessPieceTypeName == "King").ChessPieceTypeId; int nTypeIdRook = context.ChessPieceType.SingleOrDefault(t => t.ChessPieceTypeName == "Rook").ChessPieceTypeId; context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nTypeIdRook, nRankNumber, 8)); context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nKTypeIdKnight, nRankNumber, 7)); context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nTypeIdBishop, nRankNumber, 6)); context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nTypeIdKing, nRankNumber, 5)); context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nTypeIdQueen, nRankNumber, 4)); context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nTypeIdBishop, nRankNumber, 3)); context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nKTypeIdKnight, nRankNumber, 2)); context.ChessPiece.Add(new ChessPiece(MatchPlayerId, nTypeIdRook, nRankNumber, 1)); context.SaveChanges(); }
public bool SetUpChessBoard(RealTimeChessDbContext context, int nBoardWidth, int nBoardHeight) { bool bSuccess = true; if (false == IsSetup) { foreach (MatchPlayer matchPlayer in this.MatchPlayers) { IsSetup = matchPlayer.SetUpChessPieces(context, this.NumPlayers, nBoardWidth, nBoardHeight); //context.Entry(matchPlayer).Collection(p => p.Pieces).Load(); } IsSetup = true; context.SaveChanges(); } else { bSuccess = false; } return(bSuccess); }